shellcommands w/passwords
[freeside.git] / FS / FS / part_export.pm
index 14e4676..20e3ab4 100644 (file)
@@ -370,8 +370,8 @@ sub rebless {
   my $self = shift;
   my $exporttype = $self->exporttype;
   my $class = ref($self). "::$exporttype";
-#  eval "use $class;" or die $@;
   eval "use $class;";
+  die $@ if $@;
   bless($self, $class);
 }
 
@@ -414,6 +414,26 @@ sub export_delete {
   $self->_export_delete(@_);
 }
 
+=item export_suspend
+
+=cut
+
+sub export_suspend {
+  my $self = shift;
+  $self->rebless;
+  $self->_export_suspend(@_);
+}
+
+=item export_unsuspend
+
+=cut
+
+sub export_unsuspend {
+  my $self = shift;
+  $self->rebless;
+  $self->_export_unsuspend(@_);
+}
+
 #fallbacks providing useful error messages intead of infinite loops
 sub _export_insert {
   my $self = shift;
@@ -430,6 +450,20 @@ sub _export_delete {
   return "_export_delete: unknown export type ". $self->exporttype;
 }
 
+#fallbacks providing null operations
+
+sub _export_suspend {
+  my $self = shift;
+  #warn "warning: _export_suspened unimplemented for". ref($self);
+  '';
+}
+
+sub _export_unsuspend {
+  my $self = shift;
+  #warn "warning: _export_unsuspend unimplemented for ". ref($self);
+  '';
+}
+
 =back
 
 =head1 SUBROUTINES
@@ -460,45 +494,65 @@ sub export_info {
   my $r = { map { %{$exports{$_}} } keys %exports };
 }
 
-=item exporttype2svcdb EXPORTTYPE
-
-Returns the applicable I<svcdb> for an I<exporttype>.
-
-=cut
+#=item exporttype2svcdb EXPORTTYPE
+#
+#Returns the applicable I<svcdb> for an I<exporttype>.
+#
+#=cut
+#
+#sub exporttype2svcdb {
+#  my $exporttype = $_[0];
+#  foreach my $svcdb ( keys %exports ) {
+#    return $svcdb if grep { $exporttype eq $_ } keys %{$exports{$svcdb}};
+#  }
+#  '';
+#}
 
-# This subroutine should be modified or removed.  In its present form, it
-# imposes the arbitrary restriction that no export type can be associated 
-# with more than one svcdb.  The only place it's used is in edit/part_svc.cgi
-# to generate the list of allowed exports, which can be done more cleanly by 
-# export_info anyway.
+tie my %sysvshell_options, 'Tie::IxHash',
+  'crypt' => { label=>'Password encryption',
+               type=>'select', options=>[qw(crypt md5)],
+               default=>'crypt',
+             },
+;
 
-sub exporttype2svcdb {
-  my $exporttype = $_[0];
-  foreach my $svcdb ( keys %exports ) {
-    return $svcdb if grep { $exporttype eq $_ } keys %{$exports{$svcdb}};
-  }
-  '';
-}
+tie my %bsdshell_options, 'Tie::IxHash', 
+  'crypt' => { label=>'Password encryption',
+               type=>'select', options=>[qw(crypt md5)],
+               default=>'crypt',
+             },
+;
 
 tie my %shellcommands_options, 'Tie::IxHash',
   #'machine' => { label=>'Remote machine' },
   'user' => { label=>'Remote username', default=>'root' },
   'useradd' => { label=>'Insert command',
-                 default=>'useradd -d $dir -m -s $shell -u $uid $username'
+                 default=>'useradd -d $dir -m -s $shell -u $uid $username; passwd $username'
                 #default=>'cp -pr /etc/skel $dir; chown -R $uid.$gid $dir'
                },
+  'useradd_stdin' => { label=>'Insert command STDIN',
+                       type =>'textarea',
+                       default=>'$_password\n$_password\n',
+                     },
   'userdel' => { label=>'Delete command',
                  default=>'userdel $username',
                  #default=>'rm -rf $dir',
                },
+  'userdel_stdin' => { label=>'Delete command STDIN',
+                       type =>'textarea',
+                       default=>'',
+                     },
   'usermod' => { label=>'Modify command',
-                 default=>'usermod -d $new_dir -l $new_username -s $new_shell -u $new_uid $old_username',
+                 default=>'usermod -d $new_dir -l $new_username -s $new_shell -u $new_uid $old_username; passwd $new_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; '.
                  #  'chmod u-t $new_dir; chown -R $uid.$gid $new_dir; '.
                  #  'rm -rf $old_dir'.
                  #')'
+  'usermod_stdin' => { label=>'Modify command STDIN',
+                       type =>'textarea',
+                       default=>'$_password\n$_password\n',
+                     },
                },
 ;
 
@@ -565,12 +619,16 @@ tie my %sqlmail_options, 'Tie::IxHash',
     'sysvshell' => {
       'desc' =>
         'Batch export of /etc/passwd and /etc/shadow files (Linux/SysV)',
-      'options' => {},
+      'options' => \%sysvshell_options,
+      'nodomain' => 'Y',
+      'notes' => 'MD5 crypt requires installation of <a href="http://search.cpan.org/search?dist=Crypt-PasswdMD5">Crypt::PasswdMD5</a> from CPAN.  Run shell.export, etc.',
     },
     'bsdshell' => {
       'desc' =>
         'Batch export of /etc/passwd and /etc/master.passwd files (BSD)',
-      'options' => {},
+      'options' => \%bsdshell_options,
+      'nodomain' => 'Y',
+      'notes' => 'MD5 crypt requires installation of <a href="http://search.cpan.org/search?dist=Crypt-PasswdMD5">Crypt::PasswdMD5</a> from CPAN.  Run shell.export, etc.',
     },
 #    'nis' => {
 #      'desc' =>
@@ -580,6 +638,7 @@ tie my %sqlmail_options, 'Tie::IxHash',
     'textradius' => {
       'desc' => 'Batch export of a text /etc/raddb/users file (Livingston, Cistron)',
       'options' => {},
+      'notes' => 'unfinished...',
     },
 
     'shellcommands' => {
@@ -600,8 +659,7 @@ tie my %sqlmail_options, 'Tie::IxHash',
       'desc' => 'Real-time export to SQL-backed mail server',
       'options' => \%sqlmail_options,
       'nodomain' => 'Y',
-      'notes' => 'Database schema can be made to work with Courier IMAP and
- Exim.  Others could work but are untested.',
+      'notes' => 'Database schema can be made to work with Courier IMAP and Exim.  Others could work but are untested.',
     },
 
     'cyrus' => {