Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sign コマンドで失敗時に *.sig ファイルを削除する #41

Merged
merged 2 commits into from
Jun 3, 2021

Conversation

yoshi389111
Copy link
Collaborator

現象

sign コマンドで失敗した場合にも *.sig ファイルが作成されてしまう
(終了ステータスコードは正しく失敗扱いとなっている)

参考:

調査と対策方法

現状のソースでは、署名ファイルを標準出力に出力し、リダイレクトでファイルに保存している。
リダイレクトしているため必ずファイルが生成されている可能性があると思われるため、別の方法を検証する。
具体的には -out 署名ファイル で実行して署名失敗した場合に、署名ファイルが出力されるか確認する。

$ echo test > test
$ openssl dgst -sha1 -sign dummy-private-key -out test.sig test
Can't open dummy-private-key for reading, No such file or directory
140161001227584:error:02001002:system library:fopen:No such file or directory:../crypto/bio/bss_file.c:69:fopen('dummy-private-key','r')
140161001227584:error:2006D080:BIO routines:BIO_new_file:no such file:../crypto/bio/bss_file.c:76:
unable to load key file
$ ls
test  test.sig
$ 

調査の結果、出力先を -out 署名ファイル で指定して署名に失敗した場合でも、リダイレクトの場合と同様に署名ファイルが出力されることがわかった。
そのため署名ファイルの出力方法は現状通り(リダイレクト)で、署名失敗時にファイルを削除する方法で対策をする。

手順

  • まず、テストコードのみで PR を送付(shellspec でエラーとなる)
  • その後 sign コマンドを修正

@KEINOS
Copy link
Member

KEINOS commented Jun 3, 2021

ファイルよ!あばよ!
nhk_lgtm

@KEINOS KEINOS merged commit e5ba489 into Qithub-BOT:master Jun 3, 2021
@KEINOS KEINOS mentioned this pull request Jun 3, 2021
@yoshi389111 yoshi389111 deleted the fix_issue_34 branch June 5, 2021 13:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants