From dee233b25a6d76b28fcd14d86ab4539fb5e99919 Mon Sep 17 00:00:00 2001 From: Eric Torres Date: Sun, 14 Apr 2019 22:35:59 -0700 Subject: [PATCH] Change umask to 0000 when running backup --- README | 7 +++---- bin/backup | 8 ++++++++ 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/README b/README index 3905893..afc8396 100644 --- a/README +++ b/README @@ -57,19 +57,18 @@ Implementation Notes * pathlib is used for path handling * Only absolute paths are used internally for consistency * Use --link-dest= -* Use --suffix=, --backup, and --backup-dir= * When hardlinking, rbackup passes the entire path to avoid needing relative paths +* The backup script changes the process umask to 0000 to determine the file modes for the files it writes i.e. snapshots To-do ----- -* Use --suffix=, --backup, and --backup-dir= -* Create config module -* Study how snapshots behave when --delete is passed * Add __enter__ and __exit__ for PackageManager lockfiles to prevent transactions during backup * Create snapshot manipulation script * Interactive cleanup script * Repository.__delitem__() * Repository.delete_snapshot(name) +* Test functions in config module + * load_list_from_option() Dependencies ------------ diff --git a/bin/backup b/bin/backup index d2a4157..7a094c5 100644 --- a/bin/backup +++ b/bin/backup @@ -28,6 +28,7 @@ import rbackup.rsync from rbackup.struct.repository import Repository # ========== Constants ========== +SCRIPT_UMASK = 0000 LOGFORMAT = "==> %(levelname)s %(message)s" EXTRA_RSYNC_OPTS = { "dry_run": "--dry-run", @@ -103,6 +104,9 @@ def parse_cmdline_arguments(**kwargs): # ========== Main Script ========== if __name__ == "__main__": + # Create some sort of cleanup routine for resetting the umask to previous value + old_umask = os.umask(SCRIPT_UMASK) + args = parse_cmdline_arguments() parsed_config = config.parse_configfile() repo = Repository(args.repository) @@ -142,10 +146,12 @@ if __name__ == "__main__": ) except ValueError as e: syslog.critical(e) + os.umask(old_umask) exit(E_INVALID_SNAPSHOT_NAME) except CalledProcessError as e: syslog.critical("Backup process failed") syslog.critical(f"Failing command: {e.cmd}") + os.umask(old_umask) exit(E_FAILED_PROCESS) repo.symlink_snapshot(curr_snapshot) @@ -153,3 +159,5 @@ if __name__ == "__main__": if args.run_post_sync: syslog.info("Running sync operation") os.sync() + + os.umask(old_umask)