X-Git-Url: http://git.freeside.biz/gitweb/?p=freeside.git;a=blobdiff_plain;f=fs_passwd%2Ffs_passwd_server;h=a29b2c7383fa8dd43021d91bbddcc96eb2905ead;hp=99e7c43515cf86a0d95a1010f27ad81d6b83c784;hb=92a72252a2340b013462d057a178f1681401b31c;hpb=27c6b438ae9d0449be370c0f62dd227c22758c19 diff --git a/fs_passwd/fs_passwd_server b/fs_passwd/fs_passwd_server index 99e7c4351..a29b2c738 100755 --- a/fs_passwd/fs_passwd_server +++ b/fs_passwd/fs_passwd_server @@ -11,25 +11,36 @@ # crypt-aware, s/password/_password/; ivan@sisd.com 98-aug-23 use strict; +use vars qw($pid); +use subs qw(killssh); use IO::Handle; -use FS::SSH qw(sshopen2); +use Net::SSH qw(sshopen2); use FS::UID qw(adminsuidsetup); use FS::Record qw(qsearchs); use FS::svc_acct; -$SIG{CHLD} = sub { wait() }; +my $user = shift or die &usage; +adminsuidsetup $user; -&adminsuidsetup; +my($shellmachine)=shift or die &usage; -my($fs_passwdd)="/usr/local/sbin/fs_passwdd"; +#causing trouble for some folks +#$SIG{CHLD} = sub { wait() }; + +$SIG{HUP} = \&killssh; +$SIG{INT} = \&killssh; +$SIG{QUIT} = \&killssh; +$SIG{TERM} = \&killssh; +$SIG{PIPE} = \&killssh; + +sub killssh { kill 'TERM', $pid if $pid; exit; }; -my($shellmachine)=shift; -die "Usage: fs_passwd_server shellmachine\n" unless $shellmachine; +my($fs_passwdd)="/usr/local/sbin/fs_passwdd"; while (1) { my($reader,$writer)=(new IO::Handle, new IO::Handle); $writer->autoflush(1); - sshopen2($shellmachine,$reader,$writer,$fs_passwdd); + $pid = sshopen2($shellmachine,$reader,$writer,$fs_passwdd); while (1) { my($username,$old_password,$new_password,$new_gecos,$new_shell); defined($username=<$reader>) or last; @@ -57,7 +68,7 @@ while (1) { unless ( $svc_acct ) { print $writer "Incorrect password.\n"; next; } my(%hash)=$svc_acct->hash; - my($new_svc_acct) = create FS::svc_acct ( \%hash ); + my($new_svc_acct) = new FS::svc_acct ( \%hash ); $new_svc_acct->setfield('_password',$new_password) if $new_password && $new_password ne $old_password; $new_svc_acct->setfield('finger',$new_gecos) if $new_gecos; @@ -71,3 +82,7 @@ while (1) { warn "Connection to $shellmachine lost! Reconnecting...\n"; } +sub usage { + die "Usage:\n\n fs_passwd_server user shellmachine\n"; +} +