export getsecrets from FS::UID instead of calling it explicitly
[freeside.git] / site_perl / UID.pm
index 77c40aa..889ccb6 100644 (file)
@@ -15,7 +15,7 @@ use FS::Conf;
 
 @ISA = qw(Exporter);
 @EXPORT_OK = qw(checkeuid checkruid swapuid cgisuidsetup
 
 @ISA = qw(Exporter);
 @EXPORT_OK = qw(checkeuid checkruid swapuid cgisuidsetup
-                adminsuidsetup getotaker dbh datasrc);
+                adminsuidsetup getotaker dbh datasrc getsecrets );
 
 $freeside_uid = scalar(getpwnam('freeside'));
 
 
 $freeside_uid = scalar(getpwnam('freeside'));
 
@@ -164,13 +164,13 @@ object.  Support for CGI::Base and derived classes is depriciated.
 sub cgisetotaker {
   if ( $cgi && $cgi->isa('CGI::Base') && defined $cgi->var('REMOTE_USER')) {
     carp "Use of CGI::Base is depriciated";
 sub cgisetotaker {
   if ( $cgi && $cgi->isa('CGI::Base') && defined $cgi->var('REMOTE_USER')) {
     carp "Use of CGI::Base is depriciated";
-    $user = $cgi->var('REMOTE_USER');
+    $user = lc ( $cgi->var('REMOTE_USER') );
   } elsif ( $cgi && $cgi->isa('CGI') && defined $cgi->remote_user ) {
   } elsif ( $cgi && $cgi->isa('CGI') && defined $cgi->remote_user ) {
-    $user = $cgi->remote_user;
+    $user = lc ( $cgi->remote_user );
   } else {
     die "fatal: Can't get REMOTE_USER!";
   }
   } else {
     die "fatal: Can't get REMOTE_USER!";
   }
-  return $user;
+  $user;
 }
 
 =item checkeuid
 }
 
 =item checkeuid
@@ -200,7 +200,7 @@ Swaps real and effective UIDs.
 =cut
 
 sub swapuid {
 =cut
 
 sub swapuid {
-  ($<,$>) = ($>,$<);
+  ($<,$>) = ($>,$<) if $< != $>;
 }
 
 =item getsecrets [ USER ]
 }
 
 =item getsecrets [ USER ]
@@ -217,12 +217,13 @@ sub getsecrets {
   die "No user!" unless $user;
   my($conf) = new FS::Conf $conf_dir;
   my($line) = grep /^\s*$user\s/, $conf->config('mapsecrets');
   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;
   $line =~ /^\s*$user\s+(.*)$/;
   $secrets = $1;
   $line =~ /^\s*$user\s+(.*)$/;
   $secrets = $1;
-  die "User not found in mapsecrets file!" unless $secrets;
+  die "Illegal mapsecrets line for user?!" unless $secrets;
   ($datasrc, $db_user, $db_pass) = $conf->config($secrets)
     or die "Can't get secrets: $!";
   ($datasrc, $db_user, $db_pass) = $conf->config($secrets)
     or die "Can't get secrets: $!";
-  $FS::Conf::default_dir .= "/conf.$datasrc";
+  $FS::Conf::default_dir = $conf_dir. "/conf.$datasrc";
   ($datasrc, $db_user, $db_pass);
 }
 
   ($datasrc, $db_user, $db_pass);
 }
 
@@ -238,6 +239,10 @@ coderef into the hash %FS::UID::callback :
     $coderef = sub { warn "Hi, I'm returning your call!" };
     $FS::UID::callback{'Package::Name'};
 
     $coderef = sub { warn "Hi, I'm returning your call!" };
     $FS::UID::callback{'Package::Name'};
 
+=head1 VERSION
+
+$Id: UID.pm,v 1.11 1999-04-14 07:58:39 ivan Exp $
+
 =head1 BUGS
 
 Too many package-global variables.
 =head1 BUGS
 
 Too many package-global variables.
@@ -282,7 +287,28 @@ inlined suidsetup
 ivan@sisd.com 98-sep-12
 
 $Log: UID.pm,v $
 ivan@sisd.com 98-sep-12
 
 $Log: UID.pm,v $
-Revision 1.4  1998-11-13 09:56:52  ivan
+Revision 1.11  1999-04-14 07:58:39  ivan
+export getsecrets from FS::UID instead of calling it explicitly
+
+Revision 1.10  1999/04/12 22:41:09  ivan
+bugfix; $user is a global (yuck)
+
+Revision 1.9  1999/04/12 21:09:39  ivan
+force username to lowercase
+
+Revision 1.8  1999/02/23 07:23:23  ivan
+oops, don't comment out &swapuid in &adminsuidsetup!
+
+Revision 1.7  1999/01/18 09:22:40  ivan
+changes to track email addresses for email invoicing
+
+Revision 1.6  1998/11/15 05:27:48  ivan
+bugfix for new configuration layout
+
+Revision 1.5  1998/11/15 00:51:51  ivan
+eliminated some warnings on certain fatal errors (well, it is less confusing)
+
+Revision 1.4  1998/11/13 09:56:52  ivan
 change configuration file layout to support multiple distinct databases (with
 own set of config files, export, etc.)
 
 change configuration file layout to support multiple distinct databases (with
 own set of config files, export, etc.)