SeattleTestbed / softwareupdater

Software updater daemon
MIT License
1 stars 6 forks source link

Made changes to clear existing keys #54

Closed asm582 closed 9 years ago

XuefengHuang commented 9 years ago

I tested this PR on Mac OS X, this is my test result:

172-16-26-218:runnable Xuefeng$ python generatekeys.py abc 4096
Generating key files called 'abc.publickey' and 'abc.privatekey' of length 4096.
This may take a moment...
Success!
172-16-26-218:runnable Xuefeng$ wc abc*
       0       3    2469 abc.privatekey
       0       2    1239 abc.publickey
       0       5    3708 total
172-16-26-218:runnable Xuefeng$ python generatekeys.py abc 1024
Generating key files called 'abc.publickey' and 'abc.privatekey' of length 1024.
This may take a moment...
Success!
172-16-26-218:runnable Xuefeng$ wc abc*
       0       3     620 abc.privatekey
       0       2     315 abc.publickey
       0       5     935 total
172-16-26-218:runnable Xuefeng$ 

My suggestion is that it should print information to tell users when clearing existed keys. And it needs to add a unit test.

aaaaalbert commented 9 years ago

Thanks for your suggested patch. However, I'd prefer the script not overwrite existing files, especially if we are dealing with things that are likely irreplacable. (E.g., I wouldn't want to have to restore the production CH from backup because I accidentially recreated softwareupdater keys in the wrong dir).

I'd appreciate a new PR with generatekeys bailing out and commenting that it will not overwrite existing files. It should check both target files, .publickey and .privatekey before attempting to create keys. This forces the user to decide to remove / rename the existing files before proceeding.