-
Notifications
You must be signed in to change notification settings - Fork 739
Create VRF signing key file with correct permissions #1948
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
Conversation
dc6079d to
76d29ff
Compare
d3f166c to
a62fc94
Compare
|
Yes please! I found that with version 1.21.2, It might be easier in general if Also to be able to use functions from the
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Basic idea is fine.
As far as I can see the owner permission stuff is completely portable, and not unix-specific at all. And there's no reason for us to want to do it on one platform and not another.
I think it would be reasonable to add writeTextEnvelopeFileWithOwnerPermissions to the API itself. We can also simplify the code by having a separate (not exported) writeFileWithOwnerPermissions. That would more clearly separate the concerns. Then writeTextEnvelopeFileWithOwnerPermissions would be implemented like writeTextEnvelopeFile but calling writeFileWithOwnerPermissions rather than writeFile.
Why is it worth adding this function to the API so it can be used for any TextEnvelope format file? Because actually we probably want to use it everywhere that we write secret/signing keys. The auditors asked us to do this for VRF but really it applies universally.
a62fc94 to
86becdb
Compare
|
@dcoutts Do you know, is there a cross-platform way of removing non-owner read permissions, if the file already exists? I couldn't find any helpful functions in System.Directory. Testing in ghci showed me that these functions only touch the owner permissions. I found a user posted to haskell-cafe more than 10 years ago noting the same. |
8c621f9 to
0208598
Compare
|
@rvl no I don't think there is. Sadly the file permission models are totally different between unix and windows, and indeed between classic unix and unix with extended permissions. The solution is to create the files with the correct permissions in the first place. |
c390bbf to
350bf60
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks much better. Nearly there.
Once the last bits are done I think we can also squash down to one patch.
| #ifdef UNIX | ||
| _ <- setFileCreationMask (otherModes `unionFileModes` groupModes) | ||
| #endif |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What do we need this for? The openTempFile makes files with the right permissions irrespective of the default file creation mask doesn't it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When I run a bash script that uses cardano-cli, the file appears to be created with the incorrect permissions. I either have to put umask 077 at the top of my script or use setFileCreationMask in the cardano-cli exec.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I cannot reproduce this.
Irrespective of the initial umask, the file is created without "other" or "group" getting any permissions. The only time I can get the umask to affect things is if I set it to a nonsensical value like 0777 which prevents even the owner from having any permissions. But this is not a case we need to deal with.
That said, irrespective of whether it's needed or not, it may not be a bad idea to override the umask anyway and use 0077 for all files the cli creates, since arguably all the files the cli makes should be readable only to the user creating them.
@disassembler any opinion?
| (left $ GenericPermissionsExist vrfPrivKey) | ||
| where | ||
| genericPermissions = gENERIC_ALL .|. gENERIC_READ .|. gENERIC_WRITE .|. gENERIC_EXECUTE | ||
| hasPermission fModeA fModeB = fModeA .&. fModeB /= gENERIC_NONE |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice.
ca0536c to
441fafa
Compare
441fafa to
f70dade
Compare
Thanks for the suggestion! Let's get this PR in and then I can look into what you've described. |
| #ifdef UNIX | ||
| _ <- setFileCreationMask (otherModes `unionFileModes` groupModes) | ||
| #endif |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I cannot reproduce this.
Irrespective of the initial umask, the file is created without "other" or "group" getting any permissions. The only time I can get the umask to affect things is if I set it to a nonsensical value like 0777 which prevents even the owner from having any permissions. But this is not a case we need to deal with.
That said, irrespective of whether it's needed or not, it may not be a bad idea to override the umask anyway and use 0077 for all files the cli creates, since arguably all the files the cli makes should be readable only to the user creating them.
@disassembler any opinion?
f70dade to
b6b88cc
Compare
|
bors merge |
1948: Create VRF signing key file with correct permissions r=dcoutts a=Jimbo4350 Since we are now checking that the VRF signing key file has the correct owner read/write permissions, it makes sense to create the VRF signing key file with the correct permissions in `cardano-cli`. - Related to #1936 Co-authored-by: Jordan Millar <jordan.millar@iohk.io>
|
Build failed: |
|
bors merge |
b6b88cc to
0cc2dc4
Compare
|
bors r+ |
|
Build succeeded: |
Since we are now checking that the VRF signing key file has the correct owner read/write permissions, it makes sense to create the VRF signing key file with the correct permissions in
cardano-cli.