diff options
Diffstat (limited to 'bin')
-rwxr-xr-x | bin/bind.export | 8 | ||||
-rwxr-xr-x | bin/bind.import | 7 | ||||
-rwxr-xr-x | bin/bsdshell.export | 119 | ||||
-rwxr-xr-x | bin/fs-migrate-svc_acct_sm | 5 | ||||
-rwxr-xr-x | bin/fs-setup | 78 | ||||
-rwxr-xr-x | bin/passwd.import | 20 | ||||
-rwxr-xr-x | bin/pod2x | 2 | ||||
-rwxr-xr-x | bin/populate-msgcat | 2 | ||||
-rwxr-xr-x | bin/sysvshell.export | 117 |
9 files changed, 302 insertions, 56 deletions
diff --git a/bin/bind.export b/bin/bind.export index d49b3cf64..7d1452dc6 100755 --- a/bin/bind.export +++ b/bin/bind.export @@ -15,7 +15,7 @@ my $user = shift or die &usage; adminsuidsetup $user; my $spooldir = "/usr/local/etc/freeside/export.". datasrc. "/bind"; -mkdir $spooldir unless -d $spooldir; +mkdir $spooldir, 0700 unless -d $spooldir; my @exports = qsearch('part_export', { 'exporttype' => 'bind' } ); my @sexports = qsearch('part_export', { 'exporttype' => 'bind_slave' } ); @@ -33,7 +33,7 @@ foreach my $export ( @exports ) { #prevent old domain files from piling up #rmtree "$prefix" or die "can't rmtree $prefix.db: $!"; - mkdir $prefix unless -d $prefix; + mkdir $prefix, 0700 unless -d $prefix; open(NAMED_CONF,">$prefix/named.conf") or die "can't open $prefix/named.conf: $!"; @@ -45,7 +45,7 @@ foreach my $export ( @exports ) { my $zonepath = $export->option('zonepath'); $zonepath =~ s/\/$//; - #false laziness with freeside-sqlradius-reset + #false laziness with freeside-sqlradius-reset and shell.export my @svc_domain = map { qsearchs('svc_domain', { 'svcnum' => $_->svcnum } ) } map { qsearch('cust_svc', { 'svcpart' => $_->svcpart } ) } @@ -132,7 +132,7 @@ foreach my $sexport ( @sexports ) { #false laziness with above #prevent old domain files from piling up #rmtree "$prefix" or die "can't rmtree $prefix.db: $!"; - mkdir $prefix unless -d $prefix; + mkdir $prefix, 0700 unless -d $prefix; open(NAMED_CONF,">$prefix/named.conf") or die "can't open $prefix/named.conf: $!"; diff --git a/bin/bind.import b/bin/bind.import index 5c4149501..57eca2b63 100755 --- a/bin/bind.import +++ b/bin/bind.import @@ -1,6 +1,6 @@ #!/usr/bin/perl -w # -# $Id: bind.import,v 1.1 2002-05-23 13:00:08 ivan Exp $ +# $Id: bind.import,v 1.3 2002-07-15 01:44:23 ivan Exp $ #need to manually put header in /usr/local/etc/freeside/export.<datasrc./bind/<machine>/named.conf.HEADER @@ -8,7 +8,7 @@ use strict; use vars qw( %d_part_svc ); use Term::Query qw(query); #use BIND::Conf_Parser; -#use DNS::ZoneParse; +#use DNS::ZoneParse 0.81; #use Net::SCP qw(iscp); use Net::SCP qw(scp); @@ -23,6 +23,7 @@ use FS::domain_record; my $user = shift or die &usage; adminsuidsetup $user; +$FS::svc_Common::noexport_hack = 1; $FS::domain_record::noserial_hack = 1; use vars qw($spooldir); @@ -139,7 +140,7 @@ BEGIN { scp("root\@$main::named_machine:$sourcefile", "$main::prefix/$basefile.import"); - use DNS::ZoneParse; + use DNS::ZoneParse 0.81; my $zone = DNS::ZoneParse->new("$main::prefix/$basefile.import"); my $dump = $zone->Dump; diff --git a/bin/bsdshell.export b/bin/bsdshell.export new file mode 100755 index 000000000..10c27671e --- /dev/null +++ b/bin/bsdshell.export @@ -0,0 +1,119 @@ +#!/usr/bin/perl -w + +# bsdshell export + +use strict; +use File::Rsync; +use Net::SSH qw(ssh); +use FS::UID qw(adminsuidsetup datasrc); +use FS::Record qw(qsearch qsearchs); +use FS::part_export; +use FS::cust_svc; +use FS::svc_acct; + +my @saltset = ( 'a'..'z' , 'A'..'Z' , '0'..'9' , '.' , '/' ); + +my $user = shift or die &usage; +adminsuidsetup $user; + +my $spooldir = "/usr/local/etc/freeside/export.". datasrc; +#my $spooldir = "/usr/local/etc/freeside/export.". datasrc. "/shell"; + +my @bsd_exports = qsearch('part_export', { 'exporttype' => 'bsdshell' } ); + +my $rsync = File::Rsync->new({ + rsh => 'ssh', +# dry_run => 1, +}); + +foreach my $export ( @bsd_exports ) { + my $machine = $export->machine; + my $prefix = "$spooldir/$machine"; + mkdir $prefix, 0700 unless -d $prefix; + + #LOCKING!!! + + ( open(MASTER,">$prefix/master.passwd") + #!!! and flock(MASTER,LOCK_EX|LOCK_NB) + ) or die "Can't open $prefix/master.passwd: $!"; + ( open(PASSWD,">$prefix/passwd") + #!!! and flock(PASSWD,LOCK_EX|LOCK_NB) + ) or die "Can't open $prefix/passwd: $!"; + + chmod 0644, "$prefix/passwd"; + chmod 0600, "$prefix/master.passwd"; + + #false laziness with freeside-sqlradius-reset and bind.export + my @svc_acct = + map { qsearchs('svc_acct', { 'svcnum' => $_->svcnum } ) } + map { qsearch('cust_svc', { 'svcpart' => $_->svcpart } ) } + grep { qsearch('cust_svc', { 'svcpart' => $_->svcpart } ) } + $export->export_svc; + + next unless @svc_acct; + + foreach my $svc_acct ( sort { $a->uid <=> $b->uid } @svc_acct ) { + + my $password = $svc_acct->_password; + my $cpassword; + #if ( ( length($password) <= 8 ) + if ( ( length($password) <= 12 ) + && ( $password ne '*' ) + && ( $password ne '!!' ) + && ( $password ne '' ) + ) { + $cpassword=crypt($password, + $saltset[int(rand(64))].$saltset[int(rand(64))] + ); + # MD5 !!!! + } else { + $cpassword=$password; + } + + ### + # FORMAT OF THE PASSWD FILE HERE + print PASSWD join(":", + $svc_acct->username, + 'x', # "##". $username, + $svc_acct->uid, + $svc_acct->gid, + $svc_acct->finger, + $svc_acct->dir, + $svc_acct->shell, + ), "\n"; + + ### + # FORMAT OF FreeBSD MASTER PASSWD FILE HERE + print MASTER join(":", + $svc_acct->username, # User name + $cpassword, # Encrypted password + $svc_acct->uid, # User ID + $svc_acct->gid, # Group ID + "", # Login Class + "0", # Password Change Time + "0", # Password Expiration Time + $svc_acct->finger, # Users name + $svc_acct->dir, # Users home directory + $svc_acct->shell, # shell + ), "\n" ; + + } + + #!!! flock(MASTER,LOCK_UN); + #!!! flock(PASSWD,LOCK_UN); + close MASTER; + close PASSWD; + + $rsync->exec( { + src => "$prefix/passwd", + dest => "root\@$machine:/etc/passwd" + } ) or die "rsync to $machine failed: ". join(" / ", $rsync->err); + + $rsync->exec( { + src => "$prefix/master.passwd", + dest => "root\@$machine:/etc/master.passwd.new" + } ) or die "rsync to $machine failed: ". join(" / ", $rsync->err); + ssh("root\@$machine", "pwd_mkdb /etc/master.passwd.new"); + + # UNLOCK!! +} diff --git a/bin/fs-migrate-svc_acct_sm b/bin/fs-migrate-svc_acct_sm index ae2dc764d..e34b23596 100755 --- a/bin/fs-migrate-svc_acct_sm +++ b/bin/fs-migrate-svc_acct_sm @@ -1,6 +1,6 @@ #!/usr/bin/perl -Tw # -# $Id: fs-migrate-svc_acct_sm,v 1.3 2001-08-21 02:43:18 ivan Exp $ +# $Id: fs-migrate-svc_acct_sm,v 1.4 2002-06-21 09:13:16 ivan Exp $ # # jeff@cmh.net 01-Jul-20 @@ -52,8 +52,7 @@ my($dbh)=adminsuidsetup $user; $|=1; -$FS::svc_acct::nossh_hack = 1; -$FS::svc_forward::nossh_hack = 1; +$FS::svc_Common::noexport_hack = 1; $FS::svc_domain::whois_hack = 1; %part_domain_svc=map { $_->svcpart, $_ } qsearch('part_svc',{'svcdb'=>'svc_domain'}); diff --git a/bin/fs-setup b/bin/fs-setup index 87921d74e..9522ce370 100755 --- a/bin/fs-setup +++ b/bin/fs-setup @@ -1,6 +1,6 @@ #!/usr/bin/perl -Tw # -# $Id: fs-setup,v 1.91 2002-05-15 13:24:24 ivan Exp $ +# $Id: fs-setup,v 1.96 2002-07-06 12:13:49 ivan Exp $ #to delay loading dbdef until we're ready BEGIN { $FS::Record::setup_hack = 1; } @@ -165,6 +165,11 @@ foreach my $table ( grep { ! /^h_/ } $dbdef->tables ) { my $tableobj = $dbdef->table($table) or die "unknown table $table"; + die "unique->lol_ref undefined for $table" + unless defined $tableobj->unique->lol_ref; + die "index->lol_ref undefined for $table" + unless defined $tableobj->index->lol_ref; + my $h_tableobj = DBIx::DBSchema::Table->new( { name => "h_$table", primary_key => 'historynum', @@ -336,7 +341,7 @@ sub tables_hash_hack { 'prog', @perl_type, ], 'primary_key' => 'agentnum', - 'unique' => [ [] ], + 'unique' => [], 'index' => [ ['typenum'] ], }, @@ -346,8 +351,8 @@ sub tables_hash_hack { 'atype', 'varchar', '', $char_d, ], 'primary_key' => 'typenum', - 'unique' => [ [] ], - 'index' => [ [] ], + 'unique' => [], + 'index' => [], }, 'type_pkgs' => { @@ -370,7 +375,7 @@ sub tables_hash_hack { 'closed', 'char', 'NULL', 1, ], 'primary_key' => 'invnum', - 'unique' => [ [] ], + 'unique' => [], 'index' => [ ['custnum'] ], }, @@ -402,7 +407,7 @@ sub tables_hash_hack { 'disabled', 'char', 'NULL', 1, ], 'primary_key' => 'eventpart', - 'unique' => [ [] ], + 'unique' => [], 'index' => [ ['payby'] ], }, @@ -431,7 +436,7 @@ sub tables_hash_hack { 'closed', 'char', 'NULL', 1, ], 'primary_key' => 'crednum', - 'unique' => [ [] ], + 'unique' => [], 'index' => [ ['custnum'] ], }, @@ -444,7 +449,7 @@ sub tables_hash_hack { 'amount', @money_type, ], 'primary_key' => 'creditbillnum', - 'unique' => [ [] ], + 'unique' => [], 'index' => [ ['crednum'], ['invnum'] ], }, @@ -494,7 +499,7 @@ sub tables_hash_hack { 'comments', 'text', 'NULL', '', ], 'primary_key' => 'custnum', - 'unique' => [ [] ], + 'unique' => [], #'index' => [ ['last'], ['company'] ], 'index' => [ ['last'], [ 'company' ], [ 'referral_custnum' ] ], }, @@ -506,7 +511,7 @@ sub tables_hash_hack { 'dest', 'varchar', '', $char_d, ], 'primary_key' => 'destnum', - 'unique' => [ [] ], + 'unique' => [], 'index' => [ ['custnum'], ], }, @@ -523,9 +528,9 @@ sub tables_hash_hack { 'tax', 'real', '', '', #tax % ], 'primary_key' => 'taxnum', - 'unique' => [ [] ], + 'unique' => [], # 'unique' => [ ['taxnum'], ['state', 'county'] ], - 'index' => [ [] ], + 'index' => [], }, 'cust_pay' => { @@ -542,7 +547,7 @@ sub tables_hash_hack { 'closed', 'char', 'NULL', 1, ], 'primary_key' => 'paynum', - 'unique' => [ [] ], + 'unique' => [], 'index' => [ [ 'custnum' ], [ 'paybatch' ] ], }, @@ -555,7 +560,7 @@ sub tables_hash_hack { '_date', @date_type ], 'primary_key' => 'billpaynum', - 'unique' => [ [] ], + 'unique' => [], 'index' => [ [ 'paynum' ], [ 'invnum' ] ], }, @@ -570,7 +575,7 @@ sub tables_hash_hack { 'address1', 'varchar', '', $char_d, 'address2', 'varchar', 'NULL', $char_d, 'city', 'varchar', '', $char_d, - 'state', 'varchar', '', $char_d, + 'state', 'varchar', 'NULL', $char_d, 'zip', 'varchar', '', 10, 'country', 'char', '', 2, # 'trancode', 'int', '', '', @@ -581,7 +586,7 @@ sub tables_hash_hack { 'amount', @money_type, ], 'primary_key' => 'paybatchnum', - 'unique' => [ [] ], + 'unique' => [], 'index' => [ ['invnum'], ['custnum'] ], }, @@ -599,7 +604,7 @@ sub tables_hash_hack { 'manual_flag', 'char', 'NULL', 1, ], 'primary_key' => 'pkgnum', - 'unique' => [ [] ], + 'unique' => [], 'index' => [ ['custnum'] ], }, @@ -619,8 +624,8 @@ sub tables_hash_hack { 'closed', 'char', 'NULL', 1, ], 'primary_key' => 'refundnum', - 'unique' => [ [] ], - 'index' => [ [] ], + 'unique' => [], + 'index' => [], }, 'cust_credit_refund' => { @@ -632,7 +637,7 @@ sub tables_hash_hack { '_date', @date_type ], 'primary_key' => 'creditrefundnum', - 'unique' => [ [] ], + 'unique' => [], 'index' => [ [ 'crednum', 'refundnum' ] ], }, @@ -644,7 +649,7 @@ sub tables_hash_hack { 'svcpart', 'int', '', '', ], 'primary_key' => 'svcnum', - 'unique' => [ [] ], + 'unique' => [], 'index' => [ ['svcnum'], ['pkgnum'], ['svcpart'] ], }, @@ -664,8 +669,8 @@ sub tables_hash_hack { 'taxclass', 'varchar', 'NULL', $char_d, ], 'primary_key' => 'pkgpart', - 'unique' => [ [] ], - 'index' => [ [] ], + 'unique' => [], + 'index' => [], }, # 'part_title' => { @@ -695,8 +700,8 @@ sub tables_hash_hack { 'referral', 'varchar', '', $char_d, ], 'primary_key' => 'refnum', - 'unique' => [ [] ], - 'index' => [ [] ], + 'unique' => [], + 'index' => [], }, 'part_svc' => { @@ -707,8 +712,8 @@ sub tables_hash_hack { 'disabled', 'char', 'NULL', 1, ], 'primary_key' => 'svcpart', - 'unique' => [ [] ], - 'index' => [ [] ], + 'unique' => [], + 'index' => [], }, 'part_svc_column' => { @@ -735,7 +740,7 @@ sub tables_hash_hack { 'loc', 'char', 'NULL', 4, #NULL for legacy purposes ], 'primary_key' => 'popnum', - 'unique' => [ [] ], + 'unique' => [], 'index' => [ [ 'state' ] ], }, @@ -749,7 +754,7 @@ sub tables_hash_hack { 'nxx', 'char', '', 3, ], 'primary_key' => 'localnum', - 'unique' => [ [] ], + 'unique' => [], 'index' => [ [ 'npa', 'nxx' ], [ 'popnum' ] ], }, @@ -771,7 +776,8 @@ sub tables_hash_hack { 'domsvc', 'int', '', '', ], 'primary_key' => 'svcnum', - 'unique' => [ [ 'username', 'domsvc' ] ], + #'unique' => [ [ 'username', 'domsvc' ] ], + 'unique' => [], 'index' => [ ['username'], ['domsvc'] ], }, @@ -805,7 +811,7 @@ sub tables_hash_hack { ], 'primary_key' => 'svcnum', 'unique' => [ ['domain'] ], - 'index' => [ [] ], + 'index' => [], }, 'domain_record' => { @@ -818,7 +824,7 @@ sub tables_hash_hack { 'recdata', 'varchar', '', $char_d, ], 'primary_key' => 'recnum', - 'unique' => [ [] ], + 'unique' => [], 'index' => [ ['svcnum'] ], }, @@ -830,7 +836,7 @@ sub tables_hash_hack { 'dst', 'varchar', 'NULL', $char_d, ], 'primary_key' => 'svcnum', - 'unique' => [ [] ], + 'unique' => [], 'index' => [ ['srcsvc'], ['dstsvc'] ], }, @@ -841,8 +847,8 @@ sub tables_hash_hack { 'usersvc', 'int', '', '', ], 'primary_key' => 'svcnum', - 'unique' => [ [] ], - 'index' => [ [] ], + 'unique' => [], + 'index' => [], }, #'svc_wo' => { @@ -867,7 +873,7 @@ sub tables_hash_hack { ], 'primary_key' => 'prepaynum', 'unique' => [ ['identifier'] ], - 'index' => [ [] ], + 'index' => [], }, 'port' => { diff --git a/bin/passwd.import b/bin/passwd.import index 8b5826bfe..fbf27370f 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.5 2002-06-21 09:57:05 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; @@ -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; ### @@ -81,10 +81,15 @@ while (<SHADOW>) { while (<PASSWD>) { 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 (<PASSWD>) { '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 { @@ -33,7 +33,7 @@ foreach my $file ( glob("./fs_signup/FS-SignupClient/*.pm"), glob("./fs_selfadmin/FS-MailAdminServer/*.pm"), ) { - next if $file =~ /^blib\//; + next if $file =~ /(^|\/)blib\//; #$file =~ /\/([\w\-]+)\.pm$/ or die "oops file $file"; my $name; if ( $file =~ /fs_\w+\/FS\-\w+\/(.*)\.pm$/ ) { diff --git a/bin/populate-msgcat b/bin/populate-msgcat index 166f83720..f8e23cfa0 100755 --- a/bin/populate-msgcat +++ b/bin/populate-msgcat @@ -79,7 +79,7 @@ sub messages { 'en_US' => 'Illegal password (', }, - 'illeggal_password_characters' => { + 'illegal_password_characters' => { 'en_US' => ' characters)', }, diff --git a/bin/sysvshell.export b/bin/sysvshell.export new file mode 100755 index 000000000..859766103 --- /dev/null +++ b/bin/sysvshell.export @@ -0,0 +1,117 @@ +#!/usr/bin/perl -w + +# sysvshell export + +use strict; +use File::Rsync; +use Net::SSH qw(ssh); +use FS::UID qw(adminsuidsetup datasrc); +use FS::Record qw(qsearch qsearchs); +use FS::part_export; +use FS::cust_svc; +use FS::svc_acct; + +my @saltset = ( 'a'..'z' , 'A'..'Z' , '0'..'9' , '.' , '/' ); + +my $user = shift or die &usage; +adminsuidsetup $user; + +my $spooldir = "/usr/local/etc/freeside/export.". datasrc; +#my $spooldir = "/usr/local/etc/freeside/export.". datasrc. "/shell"; + +my @sysv_exports = qsearch('part_export', { 'exporttype' => 'sysvshell' } ); + +my $rsync = File::Rsync->new({ + rsh => 'ssh', +# dry_run => 1, +}); + +foreach my $export ( @sysv_exports ) { + my $machine = $export->machine; + my $prefix = "$spooldir/$machine"; + mkdir $prefix, 0700 unless -d $prefix; + + #LOCKING!!! + + ( open(SHADOW,">$prefix/shadow") + #!!! and flock(SHADOW,LOCK_EX|LOCK_NB) + ) or die "Can't open $prefix/shadow: $!"; + ( open(PASSWD,">$prefix/passwd") + #!!! and flock(PASSWD,LOCK_EX|LOCK_NB) + ) or die "Can't open $prefix/passwd: $!"; + + chmod 0644, "$prefix/passwd"; + chmod 0600, "$prefix/shadow"; + + #false laziness with freeside-sqlradius-reset and bind.export + my @svc_acct = + map { qsearchs('svc_acct', { 'svcnum' => $_->svcnum } ) } + map { qsearch('cust_svc', { 'svcpart' => $_->svcpart } ) } + grep { qsearch('cust_svc', { 'svcpart' => $_->svcpart } ) } + $export->export_svc; + + next unless @svc_acct; + + foreach my $svc_acct ( sort { $a->uid <=> $b->uid } @svc_acct ) { + + my $password = $svc_acct->_password; + my $cpassword; + #if ( ( length($password) <= 8 ) + if ( ( length($password) <= 12 ) + && ( $password ne '*' ) + && ( $password ne '!!' ) + && ( $password ne '' ) + ) { + $cpassword=crypt($password, + $saltset[int(rand(64))].$saltset[int(rand(64))] + ); + # MD5 !!!! + } else { + $cpassword=$password; + } + + ### + # FORMAT OF THE PASSWD FILE HERE + print PASSWD join(":", + $svc_acct->username, + 'x', # "##". $username, + $svc_acct->uid, + $svc_acct->gid, + $svc_acct->finger, + $svc_acct->dir, + $svc_acct->shell, + ), "\n"; + + ### + # FORMAT OF THE SHADOW FILE HERE + print SHADOW join(":", + $svc_acct->username, + $cpassword, + '', + '', + '', + '', + '', + '', + '', + ), "\n"; + + } + + #!!! flock(SHADOW,LOCK_UN); + #!!! flock(PASSWD,LOCK_UN); + close SHADOW; + close PASSWD; + + $rsync->exec( { + src => "$prefix/shadow", + dest => "root\@$machine:/etc/shadow" + } ) or die "rsync to $machine failed: ". join(" / ", $rsync->err); + + $rsync->exec( { + src => "$prefix/passwd", + dest => "root\@$machine:/etc/passwd" + } ) or die "rsync to $machine failed: ". join(" / ", $rsync->err); + + # UNLOCK!! +} |