Skip to content

btcd: set umask 077 at startup - #2689

Open
fametrano wants to merge 1 commit into
btcsuite:masterfrom
fametrano:umask-077
Open

fametrano wants to merge 1 commit into
btcsuite:masterfrom
fametrano:umask-077

Conversation

@fametrano

Copy link
Copy Markdown
Contributor

btcd creates btcd.log with mode 0644 through the logrotate package, so other local users can read it wherever its directory allows, and the log holds peer addresses. rpc.cert is 0644 for the same reason.

This sets the process umask to 077 in an init() on Unix, before any file is created, as Bitcoin Core does. New files are then created private to the user, and existing files keep their modes. This includes rpc.cert, which becomes 0600, so a client running as another user then needs access to it some other way, such as a copy or group permissions. TestFileModes creates the log and the RPC key and certificate in a child process started under umask 022, so the result does not depend on the caller's umask, and asserts each file is 0600.

Closes #2645

btcd.log is created with mode 0644 by the logrotate package, so it is
readable by other local users wherever its directory allows it.  The
log holds peer addresses.

Set the process umask to 077 on Unix before any file is created, as
Bitcoin Core does.  New files are then created private to the user.
Existing files keep their modes.

This includes rpc.cert, which umask 022 made 0644 until now.  A client
running as another user needs access to it some other way, such as a
copy or group permissions.
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.

Set umask 077 at startup so new files are private to the user

1 participant