X-Git-Url: http://git.freeside.biz/gitweb/?p=freeside.git;a=blobdiff_plain;f=FS%2FFS%2FUID.pm;h=15f15a171c8bc01b390e7801759fe52b2a0e3c87;hp=f80156e97b73de0e60200e44c6542792c66f8928;hb=98567e531e90ee1c7c195d5f1e708898d47a8452;hpb=57d69d5c1f98f778a0df82795ce21ee7bd21042a diff --git a/FS/FS/UID.pm b/FS/FS/UID.pm index f80156e97..15f15a171 100644 --- a/FS/FS/UID.pm +++ b/FS/FS/UID.pm @@ -15,8 +15,8 @@ use DBI; use FS::Conf; @ISA = qw(Exporter); -@EXPORT_OK = qw(checkeuid checkruid cgisuidsetup - adminsuidsetup getotaker dbh datasrc getsecrets driver_name ); +@EXPORT_OK = qw(checkeuid checkruid cgisuidsetup adminsuidsetup forksuidsetup + getotaker dbh datasrc getsecrets driver_name ); $freeside_uid = scalar(getpwnam('freeside')); @@ -65,10 +65,17 @@ Returns the DBI database handle (usually you don't need this). =cut sub adminsuidsetup { + $dbh->disconnect if $dbh; + &forksuidsetup(@_); +} +sub forksuidsetup { $user = shift; croak "fatal: adminsuidsetup called without arguements" unless $user; + $user =~ /^([\w\-\.]+)$/ or croak "fatal: illegal user $user"; + $user = $1; + $ENV{'PATH'} ='/usr/local/bin:/usr/bin:/usr/ucb:/bin'; $ENV{'SHELL'} = '/bin/sh'; $ENV{'IFS'} = " \t\n"; @@ -76,9 +83,8 @@ sub adminsuidsetup { $ENV{'ENV'} = ''; $ENV{'BASH_ENV'} = ''; - croak "Not running uid freeside!" unless checkeuid(); + croak "Not running uid freeside!" unless checkeuid() || !$>; getsecrets; - $dbh->disconnect if $dbh; $dbh = DBI->connect($datasrc,$db_user,$db_pass, { 'AutoCommit' => 0, 'ChopBlanks' => 1, @@ -86,6 +92,7 @@ sub adminsuidsetup { foreach ( keys %callback ) { &{$callback{$_}}; + # breaks multi-database installs # delete $callback{$_}; #run once } $dbh; @@ -118,7 +125,7 @@ Returns the CGI (see L) object. =cut sub cgi { - #carp "warning: \$FS::UID::cgi isa Apache" if $cgi->isa('Apache'); + carp "warning: \$FS::UID::cgi isa Apache" if $cgi->isa('Apache'); $cgi; } @@ -185,7 +192,7 @@ sub cgisetotaker { $user = lc ( $cgi->connection->user ); } else { die "fatal: Can't get REMOTE_USER! for cgi $cgi - you need to setup ". - "Apache user authentication as documented in htdocs/docs/config.html"; + "Apache user authentication as documented in httemplate/docs/install.html"; } $user; } @@ -224,7 +231,7 @@ sub getsecrets { die "No user!" unless $user; my($conf) = new FS::Conf $conf_dir; my($line) = grep /^\s*$user\s/, $conf->config('mapsecrets'); - die "User not found in mapsecrets!" unless $line; + die "User $user not found in mapsecrets!" unless $line; $line =~ /^\s*$user\s+(.*)$/; $secrets = $1; die "Illegal mapsecrets line for user?!" unless $secrets; @@ -249,7 +256,7 @@ coderef into the hash %FS::UID::callback : =head1 VERSION -$Id: UID.pm,v 1.9 2001-09-06 20:41:59 ivan Exp $ +$Id: UID.pm,v 1.17 2002-07-03 11:10:12 ivan Exp $ =head1 BUGS