This commit was generated by cvs2svn to compensate for changes in r4888,
[freeside.git] / FS / FS / part_export / shellcommands.pm
index a3edd74..e488a52 100644 (file)
@@ -10,7 +10,7 @@ use FS::part_export;
 tie my %options, 'Tie::IxHash',
   'user' => { label=>'Remote username', default=>'root' },
   'useradd' => { label=>'Insert command',
-                 default=>'useradd -c $finger -d $dir -m -s $shell -u $uid -g $gid -p $crypt_password $username'
+                 default=>'useradd -c $finger -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',
@@ -38,9 +38,12 @@ tie my %options, 'Tie::IxHash',
                        type =>'textarea',
                        default=>'',
                      },
-  'usermod_pwonly' => { label=>'Disallow username changes',
+  'usermod_pwonly' => { label=>'Disallow username, domain, uid, gid, and dir changes', #and RADIUS group changes',
                         type =>'checkbox',
                       },
+  'usermod_nousername' => { label=>'Disallow just username changes',
+                            type =>'checkbox',
+                          },
   'suspend' => { label=>'Suspension command',
                  default=>'usermod -L $username',
                },
@@ -75,7 +78,7 @@ running will not accept a domain as a parameter.  You will need to
 <UL>
   <LI>
     <INPUT TYPE="button" VALUE="Linux" onClick='
-      this.form.useradd.value = "useradd -c $finger -d $dir -m -s $shell -u $uid -g $gid -p $crypt_password $username";
+      this.form.useradd.value = "useradd -c $finger -d $dir -m -s $shell -u $uid -p $crypt_password $username";
       this.form.useradd_stdin.value = "";
       this.form.userdel.value = "userdel -r $username";
       this.form.userdel_stdin.value="";
@@ -88,7 +91,7 @@ running will not accept a domain as a parameter.  You will need to
     '>
   <LI>
     <INPUT TYPE="button" VALUE="FreeBSD before 4.10 / 5.3" onClick='
-      this.form.useradd.value = "lockf /etc/passwd.lock pw useradd $username -d $dir -m -s $shell -u $uid -g $gid -c $finger -h 0";
+      this.form.useradd.value = "lockf /etc/passwd.lock pw useradd $username -d $dir -m -s $shell -u $uid -c $finger -h 0";
       this.form.useradd_stdin.value = "$_password\n";
       this.form.userdel.value = "lockf /etc/passwd.lock pw userdel $username -r"; this.form.userdel_stdin.value="";
       this.form.usermod.value = "lockf /etc/passwd.lock pw usermod $old_username -d $new_dir -m -l $new_username -s $new_shell -u $new_uid -g $new_gid -c $new_finger -h 0";
@@ -118,7 +121,7 @@ running will not accept a domain as a parameter.  You will need to
     '>
   <LI>
     <INPUT TYPE="button" VALUE="NetBSD/OpenBSD" onClick='
-      this.form.useradd.value = "useradd -c $finger -d $dir -m -s $shell -u $uid -g $gid -p $crypt_password $username";
+      this.form.useradd.value = "useradd -c $finger -d $dir -m -s $shell -u $uid -p $crypt_password $username";
       this.form.useradd_stdin.value = "";
       this.form.userdel.value = "userdel -r $username";
       this.form.userdel_stdin.value="";
@@ -148,8 +151,8 @@ old_ for replace operations):
 <UL>
   <LI><code>$username</code>
   <LI><code>$_password</code>
-  <LI><code>$quoted_password</code> - unencrypted password quoted for the shell
-  <LI><code>$crypt_password</code> - encrypted password (quoted for the shell)
+  <LI><code>$quoted_password</code> - unencrypted password, already quoted for the shell (do not add additional quotes)
+  <LI><code>$crypt_password</code> - encrypted password, already quoted for the shell (do not add additional quotes)
   <LI><code>$uid</code>
   <LI><code>$gid</code>
   <LI><code>$finger</code> - GECOS, already quoted for the shell (do not add additional quotes)
@@ -254,7 +257,7 @@ sub _export_replace {
     ${"old_$_"} = $old->getfield($_) foreach $old->fields;
     ${"new_$_"} = $new->getfield($_) foreach $new->fields;
   }
-  $new_finger =~ /^(.*)\s+(\S+)$/ or $finger =~ /^((.*))$/;
+  $new_finger =~ /^(.*)\s+(\S+)$/ or $new_finger =~ /^((.*))$/;
   ($new_first, $new_last ) = ( $1, $2 );
   $new_first = shell_quote $new_first;
   $new_last = shell_quote $new_last;
@@ -270,27 +273,33 @@ sub _export_replace {
   @old_radius_groups = $old->radius_groups;
   @new_radius_groups = $new->radius_groups;
 
-  if ( $self->option('usermod_pwonly') ) {
-    my $error = '';
+  my $error = '';
+  if ( $self->option('usermod_pwonly') || $self->option('usermod_nousername') ){
     if ( $old_username ne $new_username ) {
       $error ||= "can't change username";
     }
+  }
+  if ( $self->option('usermod_pwonly') ) {
     if ( $old_domain ne $new_domain ) {
       $error ||= "can't change domain";
     }
     if ( $old_uid != $new_uid ) {
       $error ||= "can't change uid";
     }
+    if ( $old_gid != $new_gid ) {
+      $error ||= "can't change gid";
+    }
     if ( $old_dir ne $new_dir ) {
       $error ||= "can't change dir";
     }
-    if ( join("\n", sort @old_radius_groups) ne
-         join("\n", sort @new_radius_groups)    ) {
-      $error ||= "can't change RADIUS groups";
-    }
-    return $error. ' ('. $self->exporttype. ' to '. $self->machine. ')'
-      if $error;
+    #if ( join("\n", sort @old_radius_groups) ne
+    #     join("\n", sort @new_radius_groups)    ) {
+    #  $error ||= "can't change RADIUS groups";
+    #}
   }
+  return $error. ' ('. $self->exporttype. ' to '. $self->machine. ')'
+    if $error;
+
   $self->shellcommands_queue( $new->svcnum,
     user         => $self->option('user')||'root',
     host         => $self->machine,