I concur. It should be the operating system's responsibility to come up with appropriate error messages, not every application that runs on the operating system. From: openssh-unix-dev <openssh-unix-dev-bounces+herbie.robinson=stratus.com@xxxxxxxxxxx> On Behalf Of Bob Proulx Sent: Thursday, January 9, 2025 10:45 AM To: openssh-unix-dev@xxxxxxxxxxx Subject: Re: ssh-keygen: error if file is directory You don't often get email from bob@xxxxxxxxxx<mailto:bob@xxxxxxxxxx>. Learn why this is important<https://aka.ms/LearnAboutSenderIdentification> SMART Modular Security Checkpoint: External email. Please make sure you trust this source before clicking links or opening attachments. Salar Nosrati-Ershad wrote: > On several tasks if you pass a directory as a file to ssh-keygen, the > program wouldn't check the file mode to check if it's a directory like: > `Saving key "./test/" failed: Is a directory` > After asking the user to overwrite or not. Seems an appropriate error message is emitted to the caller if the argument is of an incorrect type. It's good. Right? > The file mode is already readed when getting `stat` > Do you think checking it is a good idea? My opinion is that this is not a good thing to do. Going down that route eventually leads to a lot of unnecessary code bloat chasing all of the types of anything that is not a file. There is already an appropriate error message printed. Why isn't that good enough? Why is the caller passing a directory intead of a file? Just as a discussion point, what if someone else comes along and says, hey if someone passes a Unix domain socket path to the program and asks if there should be an explicit test for that type? And then someone else says what if someone passes a block device? And then someone what about a character device? And what if... You get the idea. This type of chase just keeps chasing different types. The message saying that the save failed and the error as to why feels perfect to me and I have no idea why that would not be understood already. Bob _______________________________________________ openssh-unix-dev mailing list openssh-unix-dev@xxxxxxxxxxx<mailto:openssh-unix-dev@xxxxxxxxxxx> https://lists.mindrot.org/mailman/listinfo/openssh-unix-dev<https://url.us.m.mimecastprotect.com/s/mlTSCQWgRWToy0ortPhMSGkFwl> _______________________________________________ openssh-unix-dev mailing list openssh-unix-dev@xxxxxxxxxxx https://lists.mindrot.org/mailman/listinfo/openssh-unix-dev