From: Rob H. <for...@us...> - 2003-07-08 22:07:54
|
Update of /cvsroot/sandweb/sandweb/lib/SandWeb/Auth In directory sc8-pr-cvs1:/tmp/cvs-serv30111/lib/SandWeb/Auth Modified Files: FlatFile.pm Added Files: Unix.pm Log Message: * hackishly implemented Unix auth, identified what needs to be changed to make it cleaner * must've forgot to checkin batch_download, here it is --- NEW FILE --- =pod =head1 SandWeb::Auth::Unix This class verifies passwords for a given username using the Unix "su" command, and returns true if the user if authentic, false if not. =cut # SandWeb (Web-based VCS client) # # Copyright (C) 2002 Nick Jennings # Copyright (C) 2002 Robert Helmer # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # =head1 part of the SandWeb::Auth::Unix package =cut package SandWeb::Auth::Unix; =head1 =head1 uses SandWeb::Shell to call "su" =cut use SandWeb::Shell; =head1 Methods =cut =head1 METHOD new SYNOPSIS my $unix = SandWeb::Auth::Unix::->new( 'log_obj' => $log, ); DESCRIPTION This method is a constructor. PARAMETERS log_obj (type: string) (required) A reference to an instantiated log object. Default: none. RETURN CODES Returns a reference to a an Auth::Unix object. 0 = This means that the method got an error proccessing your request. Perhaps an invalid parameter? =cut sub new { my $class = shift; my %args = @_; my $self = bless { 'user_info' => {}, '_log_obj' => $args{'log_obj'}, }, $class; return $self; } =head1 METHOD verify_password SYNOPSIS my $user_is_authentic = $unix->verify_password( username => $username, password => $password, user_dir => $user_dir, }; DESCRIPTION This method verifies if a user is authentic or not by running "su" through sandweb-expect, and seeing if we can run the "echo" command". PARAMETERS username (type: string) (required) The current user's full username. Default: none. password (type: string) (required) The plain-text password to verify. Default: none. data_dir (type: string) (required) The root of where homedirs are stored. Default: none. RETURN CODES 1 = The operation completed successfully. 0 = This means that the method got an error proccessing your request. Perhaps an invalid parameter? =cut sub verify_password { my $self = shift; my $username = shift; my $password = shift; my $users_dir = shift; my $log = $self->_logobj(); $log->debug("Verifying Unix password"); $log->debug("before shell"); my %return = shell( username => $username, password => $password, users_dir => $users_dir, log => $log, ); $log->debug("after shell"); $log->debug("output : $return{'output'}"); my $message = $return{'output'}; if ($message =~ 'success'){ # user is authentic return 1; }else{ # user is NOT authentic return 0; } } sub shell { my %args = @_; my $username = $args{'username'} || ''; my $password = $args{'password'} || ''; my $users_dir = $args{'users_dir'} || ''; my $log = $args{'log'} || ''; my $file = $args{'file'}; my $param = $args{'param'}; $log->debug("Creating Shell object"); my $shell = SandWeb::Shell->new( 'system_timeout' => "100", 'bindir' => "/usr/bin", 'vcs_username' => "$username", 'users_dir' => "$users_dir/$username", 'vcs_password' => "$password", 'vcs' => 'none', 'log_obj' => $log, ); $log->debug('command' => "export SSH_BIN=/usr/bin/ssh && /usr/bin/sandweb-ssh $username\@localhost echo success"); my %return = $shell->execute('command' => "export SSH_BIN=/usr/bin/ssh && /usr/bin/sandweb-ssh $username\@localhost echo success"); return %return; } sub _logobj { my $self = shift; return $self->{'_log_obj'}; } 1; Index: FlatFile.pm =================================================================== RCS file: /cvsroot/sandweb/sandweb/lib/SandWeb/Auth/FlatFile.pm,v retrieving revision 1.11 retrieving revision 1.12 diff -U2 -r1.11 -r1.12 --- FlatFile.pm 14 Jan 2003 07:17:01 -0000 1.11 +++ FlatFile.pm 8 Jul 2003 22:07:51 -0000 1.12 @@ -135,6 +135,4 @@ The root of where homedirs are stored. - FIXME - why does verify_password need to know this? - Default: none. |