8 use FS::UID qw(adminsuidsetup datasrc);
9 use FS::Record qw(qsearch qsearchs);
14 my @saltset = ( 'a'..'z' , 'A'..'Z' , '0'..'9' , '.' , '/' );
16 my $user = shift or die &usage;
19 my $spooldir = "/usr/local/etc/freeside/export.". datasrc;
20 #my $spooldir = "/usr/local/etc/freeside/export.". datasrc. "/shell";
22 my @sysv_exports = qsearch('part_export', { 'exporttype' => 'sysvshell' } );
24 my $rsync = File::Rsync->new({
29 foreach my $export ( @sysv_exports ) {
30 my $machine = $export->machine;
31 my $prefix = "$spooldir/$machine";
32 mkdir $prefix, 0700 unless -d $prefix;
36 ( open(SHADOW,">$prefix/shadow")
37 #!!! and flock(SHADOW,LOCK_EX|LOCK_NB)
38 ) or die "Can't open $prefix/shadow: $!";
39 ( open(PASSWD,">$prefix/passwd")
40 #!!! and flock(PASSWD,LOCK_EX|LOCK_NB)
41 ) or die "Can't open $prefix/passwd: $!";
43 chmod 0644, "$prefix/passwd";
44 chmod 0600, "$prefix/shadow";
46 my @svc_acct = $export->svc_x;
48 next unless @svc_acct;
50 foreach my $svc_acct ( sort { $a->uid <=> $b->uid } @svc_acct ) {
52 my $password = $svc_acct->_password;
54 #if ( ( length($password) <= 8 )
55 if ( ( length($password) <= 12 )
56 && ( $password ne '*' )
57 && ( $password ne '!!' )
58 && ( $password ne '' )
60 $cpassword=crypt($password,
61 $saltset[int(rand(64))].$saltset[int(rand(64))]
69 # FORMAT OF THE PASSWD FILE HERE
70 print PASSWD join(":",
72 'x', # "##". $username,
81 # FORMAT OF THE SHADOW FILE HERE
82 print SHADOW join(":",
96 #!!! flock(SHADOW,LOCK_UN);
97 #!!! flock(PASSWD,LOCK_UN);
102 src => "$prefix/shadow",
103 dest => "root\@$machine:/etc/shadow"
104 } ) or die "rsync to $machine failed: ". join(" / ", $rsync->err);
107 src => "$prefix/passwd",
108 dest => "root\@$machine:/etc/passwd"
109 } ) or die "rsync to $machine failed: ". join(" / ", $rsync->err);