working linux and freebsd shellcommands
authorivan <ivan>
Tue, 2 Jul 2002 13:00:25 +0000 (13:00 +0000)
committerivan <ivan>
Tue, 2 Jul 2002 13:00:25 +0000 (13:00 +0000)
FS/FS/part_export.pm
FS/FS/part_export/shellcommands.pm

index e025758..1579248 100644 (file)
@@ -526,12 +526,12 @@ tie my %shellcommands_options, 'Tie::IxHash',
   #'machine' => { label=>'Remote machine' },
   'user' => { label=>'Remote username', default=>'root' },
   'useradd' => { label=>'Insert command',
   #'machine' => { label=>'Remote machine' },
   'user' => { label=>'Remote username', default=>'root' },
   'useradd' => { label=>'Insert command',
-                 default=>'useradd -d $dir -m -s $shell -u $uid $username; passwd $username'
+                 default=>'useradd -d $dir -m -s $shell -u $uid -p $crypt_password $username'
                 #default=>'cp -pr /etc/skel $dir; chown -R $uid.$gid $dir'
                },
   'useradd_stdin' => { label=>'Insert command STDIN',
                        type =>'textarea',
                 #default=>'cp -pr /etc/skel $dir; chown -R $uid.$gid $dir'
                },
   'useradd_stdin' => { label=>'Insert command STDIN',
                        type =>'textarea',
-                       default=>"\$_password\n\$_password\n",
+                       default=>"",
                      },
   'userdel' => { label=>'Delete command',
                  default=>'userdel $username',
                      },
   'userdel' => { label=>'Delete command',
                  default=>'userdel $username',
@@ -542,7 +542,7 @@ tie my %shellcommands_options, 'Tie::IxHash',
                        default=>'',
                      },
   'usermod' => { label=>'Modify command',
                        default=>'',
                      },
   'usermod' => { label=>'Modify command',
-                 default=>'usermod -d $new_dir -l $new_username -s $new_shell -u $new_uid $old_username; passwd $new_username',
+                 default=>'usermod -d $new_dir -m -l $new_username -s $new_shell -u $new_uid -p $new_crypt_password $old_username',
                 #default=>'[ -d $old_dir ] && mv $old_dir $new_dir || ( '.
                  #  'chmod u+t $old_dir; mkdir $new_dir; cd $old_dir; '.
                  #  'find . -depth -print | cpio -pdm $new_dir; '.
                 #default=>'[ -d $old_dir ] && mv $old_dir $new_dir || ( '.
                  #  'chmod u+t $old_dir; mkdir $new_dir; cd $old_dir; '.
                  #  'find . -depth -print | cpio -pdm $new_dir; '.
@@ -552,7 +552,7 @@ tie my %shellcommands_options, 'Tie::IxHash',
                },
   'usermod_stdin' => { label=>'Modify command STDIN',
                        type =>'textarea',
                },
   'usermod_stdin' => { label=>'Modify command STDIN',
                        type =>'textarea',
-                       default=>"\$_password\n\$_password\n",
+                       default=>"",
                      },
 ;
 
                      },
 ;
 
@@ -675,7 +675,7 @@ tie my %sqlmail_options, 'Tie::IxHash',
       'desc' => 'Real-time export via remote SSH (i.e. useradd, userdel, etc.)',
       'options' => \%shellcommands_options,
       'nodomain' => 'Y',
       'desc' => 'Real-time export via remote SSH (i.e. useradd, userdel, etc.)',
       'options' => \%shellcommands_options,
       'nodomain' => 'Y',
-      'notes' => 'Run remote commands via SSH.  Usernames are considered unique (also see shellcommands_withdomain).  You probably want this if the commands you are running will not accept a domain as a parameter.  You will need to <a href="../docs/ssh.html">setup SSH for unattended operation</a>.<BR><BR>Use these buttons for some useful presets:<UL><LI><INPUT TYPE="button" VALUE="Linux/NetBSD" onClick=\'this.form.useradd.value = "useradd -d $dir -m -s $shell -u $uid $username; passwd $username"; this.form.useradd_stdin.value = "$_password\n$_password\n"; this.form.userdel.value = "userdel $username"; this.form.userdel_stdin.value=""; this.form.usermod.value = "usermod -d $new_dir -l $new_username -s $new_shell -u $new_uid $old_username; passwd $new_username"; this.form.usermod_stdin.value = "$_password\n$_password\n";\'><LI><INPUT TYPE="button" VALUE="FreeBSD" onClick=\'this.form.useradd.value = "pw useradd $username -d $dir -m -s $shell -u $uid; passwd $username"; this.form.useradd_stdin.value = "$_password\n$_password\n"; this.form.userdel.value = "pw userdel $username"; this.form.userdel_stdin.value=""; this.form.usermod.value = "pw usermod $old_username -d $new_dir -l $new_username -s $new_shell -u $new_uid; passwd $new_username"; this.form.usermod_stdin.value = "$_password\n$_password\n";\'><LI><INPUT TYPE="button" VALUE="Just maintain directories (use with sysvshell or bsdshell)" onClick=\'this.form.useradd.value = "cp -pr /etc/skel $dir; chown -R $uid.$gid $dir"; this.form.useradd_stdin.value = ""; this.form.usermod.value = "[ -d $old_dir ] && mv $old_dir $new_dir || ( chmod u+t $old_dir; mkdir $new_dir; cd $old_dir; find . -depth -print | cpio -pdm $new_dir; chmod u-t $new_dir; chown -R $uid.$gid $new_dir; rm -rf $old_dir )"; this.form.usermod_stdin.value = ""; this.form.userdel.value = "rm -rf $dir"; this.form.userdel_stdin.value="";\'></UL>',
+      'notes' => 'Run remote commands via SSH.  Usernames are considered unique (also see shellcommands_withdomain).  You probably want this if the commands you are running will not accept a domain as a parameter.  You will need to <a href="../docs/ssh.html">setup SSH for unattended operation</a>.<BR><BR>Use these buttons for some useful presets:<UL><LI><INPUT TYPE="button" VALUE="Linux/NetBSD" onClick=\'this.form.useradd.value = "useradd -d $dir -m -s $shell -u $uid -p $crypt_password $username"; this.form.useradd_stdin.value = ""; this.form.userdel.value = "userdel $username"; this.form.userdel_stdin.value=""; this.form.usermod.value = "usermod -d $new_dir -m -l $new_username -s $new_shell -u $new_uid -p $new_crypt_password $old_username"; this.form.usermod_stdin.value = "";\'><LI><INPUT TYPE="button" VALUE="FreeBSD" onClick=\'this.form.useradd.value = "pw useradd $username -d $dir -m -s $shell -u $uid -h 0"; this.form.useradd_stdin.value = "$_password\n"; this.form.userdel.value = "pw userdel $username"; this.form.userdel_stdin.value=""; this.form.usermod.value = "pw usermod $old_username -d $new_dir -m -l $new_username -s $new_shell -u $new_uid -h 0"; this.form.usermod_stdin.value = "$_password\n";\'><LI><INPUT TYPE="button" VALUE="Just maintain directories (use with sysvshell or bsdshell)" onClick=\'this.form.useradd.value = "cp -pr /etc/skel $dir; chown -R $uid.$gid $dir"; this.form.useradd_stdin.value = ""; this.form.usermod.value = "[ -d $old_dir ] && mv $old_dir $new_dir || ( chmod u+t $old_dir; mkdir $new_dir; cd $old_dir; find . -depth -print | cpio -pdm $new_dir; chmod u-t $new_dir; chown -R $uid.$gid $new_dir; rm -rf $old_dir )"; this.form.usermod_stdin.value = ""; this.form.userdel.value = "rm -rf $dir"; this.form.userdel_stdin.value="";\'></UL>',
     },
 
     'shellcommands_withdomain' => {
     },
 
     'shellcommands_withdomain' => {
index e95939b..4e94360 100644 (file)
@@ -1,10 +1,12 @@
 package FS::part_export::shellcommands;
 
 package FS::part_export::shellcommands;
 
-use vars qw(@ISA);
+use vars qw(@ISA @saltset);
 use FS::part_export;
 
 @ISA = qw(FS::part_export);
 
 use FS::part_export;
 
 @ISA = qw(FS::part_export);
 
+@saltset = ( 'a'..'z' , 'A'..'Z' , '0'..'9' , '.' , '/' );
+
 sub rebless { shift; }
 
 sub _export_insert {
 sub rebless { shift; }
 
 sub _export_insert {
@@ -23,6 +25,8 @@ sub _export_command {
   my $stdin = $self->option($action."_stdin");
   no strict 'refs';
   ${$_} = $svc_acct->getfield($_) foreach $svc_acct->fields;
   my $stdin = $self->option($action."_stdin");
   no strict 'refs';
   ${$_} = $svc_acct->getfield($_) foreach $svc_acct->fields;
+  $crypt_password = crypt( $svc_acct->_password,
+                           $saltset[int(rand(64))].$saltset[int(rand(64))] );
   $self->shellcommands_queue( $svc_acct->svcnum,
     user         => $self->option('user')||'root',
     host         => $self->machine,
   $self->shellcommands_queue( $svc_acct->svcnum,
     user         => $self->option('user')||'root',
     host         => $self->machine,
@@ -38,6 +42,8 @@ sub _export_replace {
   no strict 'refs';
   ${"old_$_"} = $old->getfield($_) foreach $old->fields;
   ${"new_$_"} = $new->getfield($_) foreach $new->fields;
   no strict 'refs';
   ${"old_$_"} = $old->getfield($_) foreach $old->fields;
   ${"new_$_"} = $new->getfield($_) foreach $new->fields;
+  $new_crypt_password = crypt( $svc_acct->_password,
+                               $saltset[int(rand(64))].$saltset[int(rand(64))]);
   $self->shellcommands_queue( $new->svcnum,
     user         => $self->option('user')||'root',
     host         => $self->machine,
   $self->shellcommands_queue( $new->svcnum,
     user         => $self->option('user')||'root',
     host         => $self->machine,