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
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
b2_env.sh
b2_pw.txt
19 changes: 13 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

### Macros ###
SRCS_SCRIPTS = $(filter-out %cron_mail, $(wildcard usr/local/sbin/*))
SRCS_CONF = $(wildcard etc/restic/*)
SRCS_CONF = $(filter-out %template, $(wildcard etc/restic/*))
SRCS_EXCLUDE = .backup_exclude
SRCS_SYSTEMD = $(wildcard etc/systemd/system/*)

Expand All @@ -30,12 +30,19 @@ install: install-scripts install-conf install-exclude install-systemd
# target: install-scripts - Install executables.
install-scripts:
install -d $(DEST_SCRIPTS)
install -m 744 $(SRCS_SCRIPTS) $(DEST_SCRIPTS)
install -m 0744 $(SRCS_SCRIPTS) $(DEST_SCRIPTS)

etc/restic/b2_env.sh:
install -m 0600 etc/restic/b2_env.sh.template etc/restic/b2_env.sh

etc/restic/b2_pw.txt:
install -m 0600 etc/restic/b2_pw.txt.template etc/restic/b2_pw.txt

# target: install-conf - Install restic configuration files.
install-conf:
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

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.


# target: install-exclude - Install backup exclude file.
install-exclude:
Expand All @@ -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.

File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion usr/local/sbin/restic_check.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ source /etc/restic/b2_env.sh
B2_CONNECTIONS=50

# Remove locks from other stale processes to keep the automated backup running.
# NOTE nope, dont' unlock liek restic_backup.sh. restic_backup.sh should take preceedance over this script.
# NOTE nope, don't unlock like restic_backup.sh. restic_backup.sh should take precedence over this script.
#restic unlock &
#wait $!

Expand Down