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

Use file templates to improve security, reproducibility #15

Merged
merged 3 commits into from Apr 26, 2019

Conversation

billwanjohi
Copy link

@billwanjohi billwanjohi commented Apr 26, 2019

By git-ignoring the files that will hold passwords, creating associated template files for them, and then conditionally creating the files with a couple of new make targets, we can help people install their configuration in a reproducible manner without compromising on security. The commits are separated logically, so you can cherry-pick what you see fit.

install -d $(DEST_CONF) -m 700
install $(SRCS_CONF) $(DEST_CONF)
# will create these files locally only if they don't already exist
install-conf: | etc/restic/b2_env.sh etc/restic/b2_pw.txt
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the pipe delimiter indicates that the succeeding files are order-only prerequisites, meaning they will only be made if they don't already exist

# will create these files locally only if they don't already exist
install-conf: | etc/restic/b2_env.sh etc/restic/b2_pw.txt
install -d $(DEST_CONF)
install -m 0600 $(SRCS_CONF) $(DEST_CONF)
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I figured that it's more important to restrict the reading of the files, rather than the listing of the contents of the directory.

@@ -44,4 +51,4 @@ install-exclude:
# target: install-systemd - Install systemd timer and service files
install-systemd:
install -d $(DEST_SYSTEMD)
install -m 0644 $(SRCS_SYSTEMD) $(DEST_SYSTEMD)
install $(SRCS_SYSTEMD) $(DEST_SYSTEMD)
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I found this file permission to be redundant, since this is what I get by default on new files placed in this destination.

@erikw
Copy link
Owner

erikw commented Apr 26, 2019

Nice contribution!

@erikw erikw merged commit 9a586f1 into erikw:master Apr 26, 2019
@billwanjohi billwanjohi deleted the tweak_file_permissions branch April 26, 2019 16:35
erikw added a commit that referenced this pull request Dec 3, 2021
The target that copies the *.template files (#15) had a '/' prefixed which
should not be there. The copy should be locally here. The real install
happens in the install-conf that respects $PREFIX

Fixes #40
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.

None yet

2 participants