Re: [PATCH v2] ssh signing: return an error when signature cannot be read
- From
Fabian Stelzer <fs@gigacodes.de>
- Date
- Oct 6, 2022, 08:28 UTC
- Message-ID
- <20221006082817.4uxywfxjokfyml6y@fs>
- In-Reply-To
- <pull.1371.v2.git.1664877694430.gitgitgadget@gmail.com>
On 04.10.2022 10:01, Phillip Wood via GitGitGadget wrote:
Show 12 quoted lines
>From: Phillip Wood <phillip.wood@dunelm.org.uk> > >If the signature file cannot be read we print an error message but do >not return an error to the caller. In practice it seems unlikely that >the file would be unreadable if the call to ssh-keygen succeeds. > >The unlink_or_warn() call is moved to the end of the function so that >we always try and remove the signature file. This isn't strictly >necessary at the moment but it protects us against any extra code >being added between trying to read the signature file and the cleanup >at the end of the function in the future. unlink_or_warn() only prints >a warning if it exists and cannot be removed.
Sounds sensible and the change looks good to me.
Show 15 quoted lines
> >Signed-off-by: Phillip Wood <phillip.wood@dunelm.org.uk> >--- > ssh signing: return an error when signature cannot be read > > Thanks to Junio for his comments. I've updated the patch to always use > unlink_or_warn() to remove the signature file as it does not warn on > missing files. > > V1 cover letter > > This patch is based on maint. In the longer term the code could be > simplified by using pipes rather than tempfiles as we do for gpg. > ssh-keygen has supported reading the data to be signed from stdin and > writing the signature to stdout since it introduced signing.
The ssh-keygen call is already using stdin for the content to sign or verify. The signature and the signing key need to be files passed as parameters to ssh-keygen. I'm not aware of any other option of providing them to it.
Cheers, Fabian