From f12bb6ca98a2c6225724aeade61cd315bdc9a361 Mon Sep 17 00:00:00 2001 From: katagia Date: Sat, 20 Sep 2003 13:59:13 +0000 Subject: [PATCH] no options in lamdaemon.pl anymore --- lam/docs/README.lamdaemon.pl | 18 +++++------------- lam/lib/account.inc | 11 +++++------ lam/lib/lamdaemon.pl | 23 +++++++---------------- 3 files changed, 17 insertions(+), 35 deletions(-) diff --git a/lam/docs/README.lamdaemon.pl b/lam/docs/README.lamdaemon.pl index 7f6461bb..e9b75687 100644 --- a/lam/docs/README.lamdaemon.pl +++ b/lam/docs/README.lamdaemon.pl @@ -8,14 +8,8 @@ thins to get it work. (e.g. 127.0.0.1) * Path to lamdaemon.pl, e.g. /srv/www/htdocs/lam/lib/lamdaemon.pl -2. Set up SSH - I don't know if this step is really needed but I had some - problems using Net::SSH without keys. - * Log in on remote host as $admin - * run "ssh-keygen -t dsa" to create all needed keys - if not yet done -3. Set up sudo +2. Set up sudo The perlskript has to run as root (very ugly I know but I haven't found any other solution). Therefor we need a wrapper, sudo. @@ -31,8 +25,8 @@ thins to get it work. This can be done by adding the following line: Defaults:$admin !syslog -4. Set up perl - We need some external perl-modules, Quota and Net::LDAP +3. Set up perl + We need some external perl-modules, Quota and Net::SSH::Perl Th install them, run: perl -MCPAN -e shell install Quota @@ -40,7 +34,7 @@ thins to get it work. Please answer all questions to describe your system Every additional needed module should be installed automaticly - LDAP isn't used in perl anymore + LDAP isn't used by lamdaemon.pl anymore I installed Math::Pari, a needed module, by hand. I had many problems to install Math::Pari, a module needed @@ -55,9 +49,7 @@ thins to get it work. * run make * run make install -5. Set up lamdaemon.pl - Make all needed changes in lamdaemon.pl - + Now everything should work fine This is a very incomplete Documention for Alpha-Release only. diff --git a/lam/lib/account.inc b/lam/lib/account.inc index 0b9b290b..052dca2c 100644 --- a/lam/lib/account.inc +++ b/lam/lib/account.inc @@ -178,8 +178,7 @@ function getquotas($type,$user='+') { // Whis function will return the quotas fr $towrite = $ldap_q[0].' '.$ldap_q[1].' '.$user.' quota get '; if ($type=='user') $towrite = $towrite.'u'; else $towrite = $towrite.'g'; - //exec("/usr/bin/ssh ".$_SESSION['config']->scriptServer." sudo ".$_SESSION['config']->scriptPath." $towrite", $vals); - exec("perl ".$_SESSION['config']->scriptPath." $towrite", $vals, $status); + exec("perl ../../lib/lamdaemon.pl ".$_SESSION['config']->scriptServer ." ".$_SESSION['config']->scriptPath." ".$towrite, $vals, $status); $vals = explode(':', $vals[0]); for ($i=0; $iscriptPath." $towrite", $vals); + if ($i!=0) exec("perl ../../lib/lamdaemon.pl ".$_SESSION['config']->scriptServer ." ".$_SESSION['config']->scriptPath." ".$towrite, $vals); } function remquotas($user, $type) { // Whis function will remove the quotas from the specified user. @@ -221,7 +220,7 @@ function remquotas($user, $type) { // Whis function will remove the quotas from $towrite = $ldap_q[0].' '.$ldap_q[1].' '.$user.' quota set '; if ($type=='user') $towrite = $towrite.'u '; else $towrite = $towrite.'g '; - exec($_SESSION['config']->scriptPath." $towrite", $vals); + exec("perl ../../lib/lamdaemon.pl ".$_SESSION['config']->scriptServer ." ".$_SESSION['config']->scriptPath." ".$towrite, $vals); } @@ -230,7 +229,7 @@ function addhomedir($user) { // Create Homedirectory // all other needed vars are taken from remotesystem getusrnam $ldap_q = $_SESSION['ldap']->decrypt(); $towrite = $ldap_q[0].' '.$ldap_q[1].' '.$user.' home add'; - exec($_SESSION['config']->scriptPath." $towrite", $vals); + exec("perl ../../lib/lamdaemon.pl ".$_SESSION['config']->scriptServer ." ".$_SESSION['config']->scriptPath." ".$towrite, $vals); } function remhomedir($user) { // Remove Homedirectory @@ -238,7 +237,7 @@ function remhomedir($user) { // Remove Homedirectory // all other needed vars are taken from remotesystem getusrnam $ldap_q = $_SESSION['ldap']->decrypt(); $towrite = $ldap_q[0].' '.$ldap_q[1].' '.$user.' home rem'; - exec($_SESSION['config']->scriptPath." $towrite", $vals); + exec("perl ../../lib/lamdaemon.pl ".$_SESSION['config']->scriptServer ." ".$_SESSION['config']->scriptPath." ".$towrite, $vals); } function ldapreload($type) { // This function will load an array th cache ldap-requests diff --git a/lam/lib/lamdaemon.pl b/lam/lib/lamdaemon.pl index 4b1d4375..8b1cd4d9 100755 --- a/lam/lib/lamdaemon.pl +++ b/lam/lib/lamdaemon.pl @@ -21,19 +21,8 @@ # # # LDAP Account Manager daemon to create and delete homedirecotries and quotas -###################################################### -# Configure-Options -# change only variables starting from here - -$server_ssh="127.0.0.1"; # IP or DNS of host to create homedirs, quota, .... -$server_ssh_ident = "/var/lib/wwwrun/.ssh/id_dsa"; # SSH-Key to use -$path = "/srv/www/htdocs/lam/lib/lamdaemon.pl"; # path to ldap on remote-host - $debug=true; # Show debug messages -# Don't change anything below this line -############################################################ - use Quota; # Needed to get and set quotas #use strict; # Use strict for security reasons @@ -192,14 +181,16 @@ if ($( == 0 ) { print "$return\n"; } else { + $hostname = shift @ARGV; + $remotepath = shift @ARGV; use Net::SSH::Perl; - @username = split (',', $vals[0]); + @username = split (',', $ARGV[0]); $username[0] =~ s/uid=//; - my $ssh = Net::SSH::Perl->new($server_ssh, options=>[ - "IdentityFile $server_ssh_ident", + my $ssh = Net::SSH::Perl->new($hostname, options=>[ + "IdentityFile /var/lib/wwwrun/.ssh/id_dsa", "UserKnownHostsFile /dev/null" ]); - $ssh->login($username[0], $vals[1]); - ($stdout, $stderr, $exit) = $ssh->cmd("sudo $path @ARGV"); + $ssh->login($username[0], $ARGV[1]); + ($stdout, $stderr, $exit) = $ssh->cmd("sudo $remotepath @ARGV"); print "$stdout"; }