diff options
Diffstat (limited to 'fs_passwd')
-rwxr-xr-x | fs_passwd/fs_passwd | 24 | ||||
-rwxr-xr-x | fs_passwd/fs_passwd_server | 73 | ||||
-rwxr-xr-x | fs_passwd/fs_passwdd | 49 |
3 files changed, 13 insertions, 133 deletions
diff --git a/fs_passwd/fs_passwd b/fs_passwd/fs_passwd index bcf09f1fe..feddb462c 100755 --- a/fs_passwd/fs_passwd +++ b/fs_passwd/fs_passwd @@ -10,17 +10,17 @@ # # password lengths 0,255 instead of 6,8 - we'll let the server process # check the data ivan@sisd.com 98-jul-17 +# +# updated for the exciting new world of self-service 2004-mar-10 use strict; use Getopt::Std; -use Socket; -use IO::Handle; +use FS::SelfService qw(passwd); use vars qw($opt_f $opt_s); -my($fs_passwdd_socket)="/usr/local/freeside/fs_passwdd_socket"; my($freeside_uid)=scalar(getpwnam('freeside')); -$ENV{'PATH'} ='/usr/bin:/usr/ucb:/bin'; +$ENV{'PATH'} ='/usr/local/bin:/usr/bin:/usr/ucb:/bin'; $ENV{'SHELL'} = '/bin/sh'; $ENV{'IFS'} = " \t\n"; $ENV{'CDPATH'} = ''; @@ -114,13 +114,15 @@ print "\n"; system '/bin/stty', 'echo'; -socket(SOCK, PF_UNIX, SOCK_STREAM, 0) or die "socket: $!"; -connect(SOCK, sockaddr_un($fs_passwdd_socket)) or die "connect: $!"; -print SOCK join("\n",$me,$old_password,$new_password,$new_gecos,$new_shell),"\n"; -SOCK->flush; -my($error); -$error = <SOCK>; -chop $error; +my $rv = passwd( + 'username' => $me, + 'old_password' => $old_password, + 'new_password' => $new_password, + 'new_gecos' => $new_gecos, + 'new_shell' => $new_shell, +); + +my $error = $rv->{error}; if ($error) { print "\nUpdate error: $error\n"; diff --git a/fs_passwd/fs_passwd_server b/fs_passwd/fs_passwd_server deleted file mode 100755 index 99e7c4351..000000000 --- a/fs_passwd/fs_passwd_server +++ /dev/null @@ -1,73 +0,0 @@ -#!/usr/bin/perl -Tw -# -# fs_passwd_server -# -# portions of this script are copied from the `passwd' script in the original -# (perl 4) camel book, now archived at -# http://www.perl.com/CPAN/scripts/nutshell/ch6/passwd -# -# ivan@sisd.com 98-mar-9 -# -# crypt-aware, s/password/_password/; ivan@sisd.com 98-aug-23 - -use strict; -use IO::Handle; -use FS::SSH qw(sshopen2); -use FS::UID qw(adminsuidsetup); -use FS::Record qw(qsearchs); -use FS::svc_acct; - -$SIG{CHLD} = sub { wait() }; - -&adminsuidsetup; - -my($fs_passwdd)="/usr/local/sbin/fs_passwdd"; - -my($shellmachine)=shift; -die "Usage: fs_passwd_server shellmachine\n" unless $shellmachine; - -while (1) { - my($reader,$writer)=(new IO::Handle, new IO::Handle); - $writer->autoflush(1); - sshopen2($shellmachine,$reader,$writer,$fs_passwdd); - while (1) { - my($username,$old_password,$new_password,$new_gecos,$new_shell); - defined($username=<$reader>) or last; - defined($old_password=<$reader>) or last; - defined($new_password=<$reader>) or last; - defined($new_gecos=<$reader>) or last; - defined($new_shell=<$reader>) or last; - chop($username); - chop($old_password); - chop($new_password); - chop($new_gecos); - chop($new_shell); - my($svc_acct); - - #need to try both $old_password and encrypted $old_password - #maybe the crypt function in svc_acct.export needs to be a library? - my $salt = substr($old_password,0,2); - my $cold_password = crypt($old_password,$salt); - $svc_acct=qsearchs('svc_acct',{'username'=>$username, - '_password'=>$old_password, - } ) - || qsearchs('svc_acct',{'username'=>$username, - '_password'=>$cold_password, - } ); - unless ( $svc_acct ) { print $writer "Incorrect password.\n"; next; } - - my(%hash)=$svc_acct->hash; - my($new_svc_acct) = create 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; - $new_svc_acct->setfield('shell',$new_shell) if $new_shell; - my($error)=$new_svc_acct->replace($svc_acct); - print $writer $error,"\n"; - } - close $writer; - close $reader; - sleep 60; - warn "Connection to $shellmachine lost! Reconnecting...\n"; -} - diff --git a/fs_passwd/fs_passwdd b/fs_passwd/fs_passwdd deleted file mode 100755 index 582e13ccd..000000000 --- a/fs_passwd/fs_passwdd +++ /dev/null @@ -1,49 +0,0 @@ -#!/usr/bin/perl -Tw -# -# fs_passwdd -# -# This is run REMOTELY over ssh by fs_passwd_server. -# -# ivan@sisd.com 98-mar-9 - -use strict; -use Socket; - -my($fs_passwdd_socket)="/usr/local/freeside/fs_passwdd_socket"; - -$ENV{'PATH'} ='/usr/bin:/usr/ucb:/bin'; -$ENV{'SHELL'} = '/bin/sh'; -$ENV{'IFS'} = " \t\n"; -$ENV{'CDPATH'} = ''; -$ENV{'ENV'} = ''; -$ENV{'BASH_ENV'} = ''; - -$|=1; - -my $uaddr = sockaddr_un($fs_passwdd_socket); -my $proto = getprotobyname('tcp'); - -socket(Server,PF_UNIX,SOCK_STREAM,0) or die "socket: $!"; -unlink($fs_passwdd_socket); -bind(Server, $uaddr) or die "bind: $!"; -listen(Server,SOMAXCONN) or die "listen: $!"; - -my($paddr); -for ( ; $paddr = accept(Client,Server); close Client) { - my($me,$old_password,$new_password,$new_gecos,$new_shell); - - $me=<Client>; - $old_password=<Client>; - $new_password=<Client>; - $new_gecos=<Client>; - $new_shell=<Client>; - - print $me,$old_password,$new_password,$new_gecos,$new_shell; - my($error); - - $error=<STDIN>; - - print Client $error; - close Client; -} - |