[sysadmin-bin] run-rrsync-or-special-cmd: allow for running install-module command



commit 7d7f25d1e52dc6959f5709ad0e4aa4ebcefd2c6c
Author: Olav Vitters <olav vitters nl>
Date:   Mon Mar 7 23:34:47 2011 +0100

    run-rrsync-or-special-cmd: allow for running install-module command

 run-rrsync-or-special-cmd |    8 ++++++++
 1 files changed, 8 insertions(+), 0 deletions(-)
---
diff --git a/run-rrsync-or-special-cmd b/run-rrsync-or-special-cmd
index 2554899..e8ce28a 100755
--- a/run-rrsync-or-special-cmd
+++ b/run-rrsync-or-special-cmd
@@ -12,6 +12,8 @@ use File::Glob ':glob';
 # You may configure these values to your liking.  See also the section
 # of options if you want to disable any options that rsync accepts.
 use constant RSYNC => '/usr/bin/rsync';
+use constant SUDO => '/usr/bin/sudo';
+use constant INSTALL_MODULE => '/usr/local/bin/py-install-module';
 use constant LOGFILE => '/tmp/rrsync.log';
 
 my $Usage = <<EOM;
@@ -38,6 +40,12 @@ die "$0: Restricted directory does not exist!\n" if $subdir ne '/' && !-d $subdi
 
 my $command = $ENV{SSH_ORIGINAL_COMMAND};
 die "$0: Not invoked via sshd\n$Usage"	unless defined $command;
+
+if ( $command =~ s/^install-module\s+// ) {
+    my @im_opts = ('-g', 'ftpadmin', INSTALL_MODULE, '--sudo')
+    exec(SUDO, @im_opts) or die "exec(install-module) failed!";
+}
+
 die "$0: SSH_ORIGINAL_COMMAND='$command' is not rsync\n" unless $command =~ s/^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!



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]