templates!!!
[freeside.git] / bin / svc_acct.import
index 893a829..eaf0c03 100755 (executable)
@@ -1,6 +1,6 @@
 #!/usr/bin/perl -Tw
 #
-# $Id: svc_acct.import,v 1.8 2000-02-03 05:16:52 ivan Exp $
+# $Id: svc_acct.import,v 1.15 2001-07-30 06:07:47 ivan Exp $
 #
 # ivan@sisd.com 98-mar-9
 #
 # don't import /var/spool/freeside/conf/shells!  ivan@sisd.com 98-aug-13
 #
 # $Log: svc_acct.import,v $
-# Revision 1.8  2000-02-03 05:16:52  ivan
+# Revision 1.15  2001-07-30 06:07:47  ivan
+# allow !! for locked accounts instead of changing to *SUSPENDED*
+#
+# Revision 1.14  2001/05/07 15:24:15  ivan
+# s/!/*/
+#
+# Revision 1.13  2001/05/05 08:51:16  ivan
+# http://www.sisd.com/freeside/list-archive/msg01915.html
+#
+# Revision 1.12  2001/04/22 01:56:15  ivan
+# get rid of FS::SSH.pm (became Net::SSH and Net::SCP on CPAN)
+#
+# Revision 1.11  2000/06/29 12:27:01  ivan
+# s/password/_password/ for PostgreSQL wasn't done in the import.
+#
+# Revision 1.10  2000/06/28 12:32:30  ivan
+# allow RADIUS lines with "Auth-Type = Local" too
+#
+# Revision 1.8  2000/02/03 05:16:52  ivan
 # beginning of DNS and Apache support
 #
 # Revision 1.7  1999/07/08 02:32:26  ivan
@@ -43,7 +61,7 @@ use strict;
 use vars qw(%part_svc);
 use Date::Parse;
 use Term::Query qw(query);
-use FS::SSH qw(iscp);
+use Net::SCP qw(iscp);
 use FS::UID qw(adminsuidsetup datasrc);
 use FS::Record qw(qsearch);
 use FS::svc_acct;
@@ -145,12 +163,13 @@ my(%upassword,%ip,%allparam);
 my(%param,$username);
 while (<USERS>) {
   chop;
-  next if /^$/;
+  next if /^\s*$/;
+  next if /^\s*#/;
   if ( /^\S/ ) {
-    /^(\w+)\s+Password\s+=\s+"([^"]+)"(,\s+Expiration\s+=\s+"([^"]*")\s*)?$/
+    /^(\w+)\s+(Auth-Type\s+=\s+Local,\s+)Password\s+=\s+"([^"]+)"(,\s+Expiration\s+=\s+"([^"]*")\s*)?$/
       or die "1Unexpected line in users.import: $_";
     my($password,$expiration);
-    ($username,$password,$expiration)=(lc($1),$2,$4);
+    ($username,$password,$expiration)=(lc($1),$3,$5);
     $password = '' if $password eq 'UNIX';
     $upassword{$username}=$password;
     undef %param;
@@ -190,6 +209,8 @@ my(%password);
 while (<SHADOW>) {
   chop;
   my($username,$password)=split(/:/);
+  #$password =~ s/^\!$/\*/;
+  #$password =~ s/\!+/\*SUSPENDED\* /;
   $password{$username}=$password;
 }
 
@@ -215,15 +236,15 @@ while (<PASSWD>) {
   }
 
   my($svc_acct) = new FS::svc_acct ({
-    'svcpart'  => $svcpart,
-    'username' => $username,
-    'password' => $password,
-    'uid'      => $uid,
-    'gid'      => $gid,
-    'finger'   => $finger,
-    'dir'      => $dir,
-    'shell'    => $shell,
-    'slipip'   => $ip{$username},
+    'svcpart'   => $svcpart,
+    'username'  => $username,
+    '_password' => $password,
+    'uid'       => $uid,
+    'gid'       => $gid,
+    'finger'    => $finger,
+    'dir'       => $dir,
+    'shell'     => $shell,
+    'slipip'    => $ip{$username},
     %{$allparam{$username}},
   });
   my($error);
@@ -249,10 +270,10 @@ foreach $username ( keys %upassword ) {
   }
 
   my($svc_acct) = new FS::svc_acct ({
-    'svcpart'  => $svcpart,
-    'username' => $username,
-    'password' => $password,
-    'slipip'   => $ip{$username},
+    'svcpart'   => $svcpart,
+    'username'  => $username,
+    '_password' => $password,
+    'slipip'    => $ip{$username},
     %{$allparam{$username}},
   });
   my($error);