From 4d5485150720c91d9945c3ae3cad9427ece23833 Mon Sep 17 00:00:00 2001 From: ivan Date: Sat, 20 Apr 2002 11:57:36 +0000 Subject: working BIND import --- bin/passwd.import | 110 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 110 insertions(+) create mode 100755 bin/passwd.import (limited to 'bin/passwd.import') diff --git a/bin/passwd.import b/bin/passwd.import new file mode 100755 index 000000000..8b5826bfe --- /dev/null +++ b/bin/passwd.import @@ -0,0 +1,110 @@ +#!/usr/bin/perl -Tw +# $Id: passwd.import,v 1.1 2002-04-20 11:57:35 ivan Exp $ + +use strict; +use vars qw(%part_svc); +use Date::Parse; +use Term::Query qw(query); +use Net::SCP qw(iscp); +use FS::UID qw(adminsuidsetup datasrc); +use FS::Record qw(qsearch); +use FS::svc_acct; +use FS::part_svc; + +my $user = shift or die &usage; +adminsuidsetup $user; + +push @FS::svc_acct::shells, qw(/bin/sync /sbin/shuddown /bin/halt); #others? + +my($spooldir)="/usr/local/etc/freeside/export.". datasrc; + +#$FS::svc_acct::nossh_hack = 1; +$FS::svc_acct::noexport_hack = 1; + +### + +%part_svc=map { $_->svcpart, $_ } qsearch('part_svc',{'svcdb'=>'svc_acct'}); + +die "No services with svcdb svc_acct!\n" unless %part_svc; + +print "\n\n", &menu_svc, "\n", <svc, sort keys %part_svc ). "\n"; +} +sub getpart { + $^W=0; # Term::Query isn't -w-safe + my $return = query "Enter part number:", 'irk', [ keys %part_svc ]; + $^W=1; + $return; +} +sub getvalue { + my $prompt = shift; + $^W=0; # Term::Query isn't -w-safe + my $return = query $prompt, ''; + $^W=1; + $return; +} + +print "\n\n"; + +### + +open(PASSWD,"<$spooldir/passwd.import"); +open(SHADOW,"<$spooldir/shadow.import"); + +my(%password); +while () { + chop; + my($username,$password)=split(/:/); + #$password =~ s/^\!$/\*/; + #$password =~ s/\!+/\*SUSPENDED\* /; + $password{$username}=$password; +} + +while () { + chop; + my($username,$x,$uid,$gid,$finger,$dir,$shell)=split(/:/); + my($password)=$upassword{$username} || $password{$username}; + + $svcpart = $shell_svcpart; + + my($svc_acct) = new FS::svc_acct ({ + 'svcpart' => $svcpart, + 'username' => $username, + '_password' => $password, + 'uid' => $uid, + 'gid' => $gid, + 'finger' => $finger, + 'dir' => $dir, + 'shell' => $shell, + %{$allparam{$username}}, + }); + my($error); + $error=$svc_acct->insert; + die $error if $error; + + delete $upassword{$username}; +} + +sub usage { + die "Usage:\n\n passwd.import user\n"; +} + -- cgit v1.2.1 From 7f1985f56afc81912dbc86a1a3178cd128af76fe Mon Sep 17 00:00:00 2001 From: ivan Date: Fri, 21 Jun 2002 09:11:09 +0000 Subject: tiny bit better passwd.import --- bin/passwd.import | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) (limited to 'bin/passwd.import') diff --git a/bin/passwd.import b/bin/passwd.import index 8b5826bfe..aa4f90f98 100755 --- a/bin/passwd.import +++ b/bin/passwd.import @@ -1,5 +1,5 @@ #!/usr/bin/perl -Tw -# $Id: passwd.import,v 1.1 2002-04-20 11:57:35 ivan Exp $ +# $Id: passwd.import,v 1.2 2002-06-21 09:11:09 ivan Exp $ use strict; use vars qw(%part_svc); @@ -81,10 +81,15 @@ while () { while () { chop; - my($username,$x,$uid,$gid,$finger,$dir,$shell)=split(/:/); - my($password)=$upassword{$username} || $password{$username}; + my($username,$x,$uid,$gid,$finger,$dir,$shell) = split(/:/); + my $password = $password{$username}; - $svcpart = $shell_svcpart; + my $svcpart = $shell_svcpart; + + if ( qsearchs('svc_acct', { 'username' => $username } ) ) { + warn "warning: $username already exists; skipping\n"; + next; + } my($svc_acct) = new FS::svc_acct ({ 'svcpart' => $svcpart, @@ -95,13 +100,12 @@ while () { 'finger' => $finger, 'dir' => $dir, 'shell' => $shell, - %{$allparam{$username}}, + #%{$allparam{$username}}, }); my($error); $error=$svc_acct->insert; die $error if $error; - delete $upassword{$username}; } sub usage { -- cgit v1.2.1 From 4bcab14cb3f0dbbe755bcaba4a979ec8e68db268 Mon Sep 17 00:00:00 2001 From: ivan Date: Fri, 21 Jun 2002 09:13:16 +0000 Subject: import fixes... --- bin/passwd.import | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'bin/passwd.import') diff --git a/bin/passwd.import b/bin/passwd.import index aa4f90f98..09af6a3c7 100755 --- a/bin/passwd.import +++ b/bin/passwd.import @@ -1,5 +1,5 @@ #!/usr/bin/perl -Tw -# $Id: passwd.import,v 1.2 2002-06-21 09:11:09 ivan Exp $ +# $Id: passwd.import,v 1.3 2002-06-21 09:13:16 ivan Exp $ use strict; use vars qw(%part_svc); @@ -19,7 +19,7 @@ push @FS::svc_acct::shells, qw(/bin/sync /sbin/shuddown /bin/halt); #others? my($spooldir)="/usr/local/etc/freeside/export.". datasrc; #$FS::svc_acct::nossh_hack = 1; -$FS::svc_acct::noexport_hack = 1; +$FS::svc_Common::noexport_hack = 1; ### -- cgit v1.2.1 From 4b5b2b8c46413b294d96e52469016eddb016a750 Mon Sep 17 00:00:00 2001 From: ivan Date: Fri, 21 Jun 2002 09:15:59 +0000 Subject: oops --- bin/passwd.import | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'bin/passwd.import') diff --git a/bin/passwd.import b/bin/passwd.import index 09af6a3c7..d8fc01344 100755 --- a/bin/passwd.import +++ b/bin/passwd.import @@ -1,5 +1,5 @@ #!/usr/bin/perl -Tw -# $Id: passwd.import,v 1.3 2002-06-21 09:13:16 ivan Exp $ +# $Id: passwd.import,v 1.4 2002-06-21 09:15:59 ivan Exp $ use strict; use vars qw(%part_svc); @@ -7,7 +7,7 @@ use Date::Parse; use Term::Query qw(query); use Net::SCP qw(iscp); use FS::UID qw(adminsuidsetup datasrc); -use FS::Record qw(qsearch); +use FS::Record qw(qsearch qsearchs); use FS::svc_acct; use FS::part_svc; -- cgit v1.2.1 From 1e14a5e07df71cf985921cefac53b8873e813bcb Mon Sep 17 00:00:00 2001 From: ivan Date: Fri, 21 Jun 2002 09:57:05 +0000 Subject: no, don't check for duplicates like this by default... not new-export style --- bin/passwd.import | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'bin/passwd.import') diff --git a/bin/passwd.import b/bin/passwd.import index d8fc01344..fbf27370f 100755 --- a/bin/passwd.import +++ b/bin/passwd.import @@ -1,5 +1,5 @@ #!/usr/bin/perl -Tw -# $Id: passwd.import,v 1.4 2002-06-21 09:15:59 ivan Exp $ +# $Id: passwd.import,v 1.5 2002-06-21 09:57:05 ivan Exp $ use strict; use vars qw(%part_svc); @@ -86,10 +86,10 @@ while () { my $svcpart = $shell_svcpart; - if ( qsearchs('svc_acct', { 'username' => $username } ) ) { - warn "warning: $username already exists; skipping\n"; - next; - } + #if ( qsearchs('svc_acct', { 'username' => $username } ) ) { + # warn "warning: $username already exists; skipping\n"; + # next; + #} my($svc_acct) = new FS::svc_acct ({ 'svcpart' => $svcpart, -- cgit v1.2.1 From f0e07588b2eef04bf5a8cbf0b77c6bde27e02321 Mon Sep 17 00:00:00 2001 From: ivan Date: Thu, 12 Jun 2003 13:57:08 +0000 Subject: better error handling for re-imports --- bin/passwd.import | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'bin/passwd.import') diff --git a/bin/passwd.import b/bin/passwd.import index fbf27370f..304499e34 100755 --- a/bin/passwd.import +++ b/bin/passwd.import @@ -1,5 +1,5 @@ #!/usr/bin/perl -Tw -# $Id: passwd.import,v 1.5 2002-06-21 09:57:05 ivan Exp $ +# $Id: passwd.import,v 1.6 2003-06-12 13:57:08 ivan Exp $ use strict; use vars qw(%part_svc); @@ -104,7 +104,13 @@ while () { }); my($error); $error=$svc_acct->insert; - die $error if $error; + if ( $error ) { + if ( $error =~ /duplicate/i ) { + warn "$username: $error"; + } else { + die "$username: $error"; + } + } } -- cgit v1.2.1 From 1b7aca1fcbc4731099cd27d81e47200395abd316 Mon Sep 17 00:00:00 2001 From: ivan Date: Thu, 12 Jun 2003 14:06:06 +0000 Subject: tyop --- bin/passwd.import | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'bin/passwd.import') diff --git a/bin/passwd.import b/bin/passwd.import index 304499e34..a56be3aaa 100755 --- a/bin/passwd.import +++ b/bin/passwd.import @@ -1,5 +1,5 @@ #!/usr/bin/perl -Tw -# $Id: passwd.import,v 1.6 2003-06-12 13:57:08 ivan Exp $ +# $Id: passwd.import,v 1.7 2003-06-12 14:06:06 ivan Exp $ use strict; use vars qw(%part_svc); @@ -14,7 +14,7 @@ use FS::part_svc; my $user = shift or die &usage; adminsuidsetup $user; -push @FS::svc_acct::shells, qw(/bin/sync /sbin/shuddown /bin/halt); #others? +push @FS::svc_acct::shells, qw(/bin/sync /sbin/shutdown /bin/halt); #others? my($spooldir)="/usr/local/etc/freeside/export.". datasrc; -- cgit v1.2.1 From ce6df8eaa7ba3ba864cc58b2a51ab6b603e68dc1 Mon Sep 17 00:00:00 2001 From: ivan Date: Thu, 12 Jun 2003 14:08:00 +0000 Subject: /bin/halt and /sbin/halt --- bin/passwd.import | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'bin/passwd.import') diff --git a/bin/passwd.import b/bin/passwd.import index a56be3aaa..093f8bafd 100755 --- a/bin/passwd.import +++ b/bin/passwd.import @@ -1,5 +1,5 @@ #!/usr/bin/perl -Tw -# $Id: passwd.import,v 1.7 2003-06-12 14:06:06 ivan Exp $ +# $Id: passwd.import,v 1.8 2003-06-12 14:08:00 ivan Exp $ use strict; use vars qw(%part_svc); @@ -14,7 +14,7 @@ use FS::part_svc; my $user = shift or die &usage; adminsuidsetup $user; -push @FS::svc_acct::shells, qw(/bin/sync /sbin/shutdown /bin/halt); #others? +push @FS::svc_acct::shells, qw(/bin/sync /sbin/shutdown /bin/halt /sbin/halt); #others? my($spooldir)="/usr/local/etc/freeside/export.". datasrc; -- cgit v1.2.1 From 93f9e6282bb489fd4ddb7f0c6d38afb390d2ba62 Mon Sep 17 00:00:00 2001 From: ivan Date: Fri, 24 Dec 2004 23:27:34 +0000 Subject: import NP and *LK* from shadow file as * (no password) --- bin/passwd.import | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'bin/passwd.import') diff --git a/bin/passwd.import b/bin/passwd.import index 093f8bafd..26ffffb87 100755 --- a/bin/passwd.import +++ b/bin/passwd.import @@ -1,5 +1,5 @@ #!/usr/bin/perl -Tw -# $Id: passwd.import,v 1.8 2003-06-12 14:08:00 ivan Exp $ +# $Id: passwd.import,v 1.9 2004-12-24 23:27:34 ivan Exp $ use strict; use vars qw(%part_svc); @@ -76,6 +76,8 @@ while () { my($username,$password)=split(/:/); #$password =~ s/^\!$/\*/; #$password =~ s/\!+/\*SUSPENDED\* /; + $password =~ s/^NP$/\*/; + $password =~ s/^\*LK\*$/\*/; $password{$username}=$password; } -- cgit v1.2.1 From 1c0aee31ad213c682c8b9443d0deccf3897ea070 Mon Sep 17 00:00:00 2001 From: ivan Date: Fri, 24 Dec 2004 23:28:34 +0000 Subject: remove $Id$ line --- bin/passwd.import | 1 - 1 file changed, 1 deletion(-) (limited to 'bin/passwd.import') diff --git a/bin/passwd.import b/bin/passwd.import index 26ffffb87..8ab9e2ae3 100755 --- a/bin/passwd.import +++ b/bin/passwd.import @@ -1,5 +1,4 @@ #!/usr/bin/perl -Tw -# $Id: passwd.import,v 1.9 2004-12-24 23:27:34 ivan Exp $ use strict; use vars qw(%part_svc); -- cgit v1.2.1