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 @bsd_exports = qsearch('part_export', { 'exporttype' => 'bsdshell' } );
24 my $rsync = File::Rsync->new({
29 foreach my $export ( @bsd_exports ) {
30 my $machine = $export->machine;
31 my $prefix = "$spooldir/$machine";
32 mkdir $prefix, 0700 unless -d $prefix;
36 ( open(MASTER,">$prefix/master.passwd")
37 #!!! and flock(MASTER,LOCK_EX|LOCK_NB)
38 ) or die "Can't open $prefix/master.passwd: $!";
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/master.passwd";
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 FreeBSD MASTER PASSWD FILE HERE
82 print MASTER join(":",
83 $svc_acct->username, # User name
84 $cpassword, # Encrypted password
85 $svc_acct->uid, # User ID
86 $svc_acct->gid, # Group ID
88 "0", # Password Change Time
89 "0", # Password Expiration Time
90 $svc_acct->finger, # Users name
91 $svc_acct->dir, # Users home directory
92 $svc_acct->shell, # shell
97 #!!! flock(MASTER,LOCK_UN);
98 #!!! flock(PASSWD,LOCK_UN);
103 src => "$prefix/passwd",
104 dest => "root\@$machine:/etc/passwd"
105 } ) or die "rsync to $machine failed: ". join(" / ", $rsync->err);
108 src => "$prefix/master.passwd",
109 dest => "root\@$machine:/etc/master.passwd.new"
110 } ) or die "rsync to $machine failed: ". join(" / ", $rsync->err);
111 ssh("root\@$machine", "pwd_mkdb /etc/master.passwd.new");