]> git.immae.eu Git - perso/Immae/Config/Nix/NUR.git/commitdiff
Add rsync backup via dilion
authorIsmaël Bouya <ismael.bouya@normalesup.org>
Thu, 13 Feb 2020 12:07:06 +0000 (13:07 +0100)
committerIsmaël Bouya <ismael.bouya@normalesup.org>
Fri, 24 Apr 2020 22:04:48 +0000 (00:04 +0200)
pkgs/default.nix
pkgs/rrsync_sudo/default.nix [new file with mode: 0644]
pkgs/rrsync_sudo/sudo.patch [new file with mode: 0644]

index 2ad79a2fd46fe9fdb9450d13712aa27a4a74aebe..b6f9eae18809b5595bd62f5dec33b5604c15337e 100644 (file)
@@ -24,6 +24,7 @@ rec {
   pg_activity = callPackage ../pkgs/pg_activity { inherit mylibs; };
   pgloader = callPackage ../pkgs/pgloader {};
   predixy = callPackage ../pkgs/predixy { inherit mylibs; };
+  rrsync_sudo = callPackage ../pkgs/rrsync_sudo {};
   telegram-cli = callPackage ../pkgs/telegram-cli { inherit mylibs; };
   telegram-history-dump = callPackage ../pkgs/telegram-history-dump { inherit mylibs; };
   telegramircd = callPackage ../pkgs/telegramircd { inherit mylibs; telethon = callPackage ../pkgs/telethon_sync {}; };
diff --git a/pkgs/rrsync_sudo/default.nix b/pkgs/rrsync_sudo/default.nix
new file mode 100644 (file)
index 0000000..7a47320
--- /dev/null
@@ -0,0 +1,8 @@
+{ rrsync }:
+
+rrsync.overrideAttrs(old: {
+  patches = old.patches or [] ++ [ ./sudo.patch ];
+  postPatch = old.postPatch + ''
+    substituteInPlace support/rrsync --replace /usr/bin/sudo /run/wrappers/bin/sudo
+  '';
+})
diff --git a/pkgs/rrsync_sudo/sudo.patch b/pkgs/rrsync_sudo/sudo.patch
new file mode 100644 (file)
index 0000000..6de9cc9
--- /dev/null
@@ -0,0 +1,20 @@
+--- a/support/rrsync   2015-09-14 01:23:54.000000000 +0200
++++ b/support/rrsync   2020-02-08 13:55:14.302163313 +0100
+@@ -48,7 +48,7 @@
+ my $command = $ENV{SSH_ORIGINAL_COMMAND};
+ die "$0: Not invoked via sshd\n$Usage"        unless defined $command;
+-die "$0: SSH_ORIGINAL_COMMAND='$command' is not rsync\n" unless $command =~ s/^rsync\s+//;
++die "$0: SSH_ORIGINAL_COMMAND='$command' is not rsync\n" unless $command =~ s/^sudo rsync\s+//;
+ die "$0: --server option is not first\n" unless $command =~ /^--server\s/;
+ our $am_sender = $command =~ /^--server\s+--sender\s/; # Restrictive on purpose!
+ die "$0 sending to read-only server not allowed\n" if $only eq 'r' && !$am_sender;
+@@ -227,7 +227,7 @@
+ }
+ # Note: This assumes that the rsync protocol will not be maliciously hijacked.
+-exec(RSYNC, @opts, @args) or die "exec(rsync @opts @args) failed: $? $!";
++exec("/usr/bin/sudo", RSYNC, @opts, @args) or die "exec(sudo rsync @opts @args) failed: $? $!";
+ sub check_arg
+ {