5 @ISA @EXPORT_OK $cgi $dbh $freeside_uid $conf $datasrc $db_user $db_pass
13 @EXPORT_OK = qw(checkeuid checkruid swapuid cgisuidsetup
14 adminsuidsetup getotaker dbh datasrc);
16 $freeside_uid = scalar(getpwnam('freeside'));
18 my $conf = new FS::Conf;
19 ($datasrc, $db_user, $db_pass) = $conf->config('secrets')
20 or die "Can't get secrets: $!";
24 FS::UID - Subroutines for database login and assorted other stuff
28 use FS::UID qw(adminsuidsetup cgisuidsetup dbh datasrc getotaker
29 checkeuid checkruid swapuid);
34 $dbh = cgisuidsetup($cgi);
42 Provides a hodgepodge of subroutines.
50 Cleans the environment.
51 Make sure the script is running as freeside, or setuid freeside.
52 Opens a connection to the database.
53 Swaps real and effective UIDs.
54 Returns the DBI database handle (usually you don't need this).
60 $ENV{'PATH'} ='/usr/local/bin:/usr/bin:/usr/ucb:/bin';
61 $ENV{'SHELL'} = '/bin/sh';
62 $ENV{'IFS'} = " \t\n";
65 $ENV{'BASH_ENV'} = '';
67 croak "Not running uid freeside!" unless checkeuid();
68 $dbh = DBI->connect($datasrc,$db_user,$db_pass, {
70 # my($user)=getotaker();
71 # $dbh = DBI->connect("$datasrc:$user",$db_user,$db_pass, {
72 'AutoCommit' => 'true',
73 'ChopBlanks' => 'true',
74 } ) or die "DBI->connect error: $DBI::errstr\n";;
76 swapuid(); #go to non-privledged user if running setuid freeside
81 =item cgisuidsetup CGI_object
83 Stores the CGI (see L<CGI>) object for later use. (CGI::Base is depriciated)
90 if ( $cgi->isa('CGI::Base') ) {
91 carp "Use of CGI::Base is depriciated";
92 } elsif ( ! $cgi->isa('CGI') ) {
93 croak "Pass a CGI object to cgisuidsetup!";
100 Returns the CGI (see L<CGI>) object.
110 Returns the DBI database handle.
120 Returns the DBI data source.
134 croak "suidsetup depriciated";
139 Returns the current Freeside user. Currently that means the CGI REMOTE_USER,
145 if ( $cgi && $cgi->can('var') && defined $cgi->var('REMOTE_USER')) {
146 carp "Use of CGI::Base is depriciated";
147 return $cgi->var('REMOTE_USER'); #for now
148 } elsif ( $cgi && $cgi->can('remote_user') && defined $cgi->remote_user ) {
149 return $cgi->remote_user;
157 Returns true if effective UID is that of the freeside user.
162 ( $> == $freeside_uid );
167 Returns true if the real UID is that of the freeside user.
172 ( $< == $freeside_uid );
177 Swaps real and effective UIDs.
191 No capabilities yet. When mod_perl and Authen::DBI are implemented,
192 cgisuidsetup will go away as well.
196 L<FS::Record>, L<CGI>, L<DBI>
200 ivan@voicenet.com 97-jun-4 - 9
202 untaint otaker ivan@voicenet.com 97-jul-7
204 generalize and auto-get uid (getotaker still needs to be db'ed)
205 ivan@sisd.com 97-nov-10
207 &cgisuidsetup logs into database. other cleaning.
208 ivan@sisd.com 97-nov-22,23
210 &adminsuidsetup logs into database with otaker='freeside' (for
211 automated tasks like billing)
212 ivan@sisd.com 97-dec-13
214 added sub datasrc for fs-setup ivan@sisd.com 98-feb-21
216 datasrc, user and pass now come from conf/secrets ivan@sisd.com 98-jun-28
218 added ChopBlanks to DBI call (see man DBI) ivan@sisd.com 98-aug-16
220 pod, use FS::Conf, implemented cgisuidsetup as adminsuidsetup,
222 ivan@sisd.com 98-sep-12
225 Revision 1.3 1998-11-08 10:45:42 ivan
226 got sub cgi for FS::CGI
228 Revision 1.2 1998/11/08 09:38:43 ivan
229 cgisuidsetup complains if you pass it a isa CGI::Base instead of an isa CGI
230 (first step in migrating from CGI-modules to CGI.pm)