This commit was generated by cvs2svn to compensate for changes in r2523,
[freeside.git] / FS / FS / InitHandler.pm
1 package FS::InitHandler;
2
3 # this leaks memory under graceful restarts and i wouldn't use it on any
4 # modern server.  useful for very slow machines with memory to spare, just
5 # always do a full restart
6
7 use strict;
8 use vars qw($DEBUG);
9 use FS::UID qw(adminsuidsetup);
10 use FS::Record;
11
12 $DEBUG = 1;
13
14 sub handler {
15
16   use Date::Format;
17   use Date::Parse;
18   use Tie::IxHash;
19   use HTML::Entities;
20   use IO::Handle;
21   use IO::File;
22   use String::Approx;
23   use HTML::Widgets::SelectLayers 0.02;
24   #use FS::UID;
25   #use FS::Record;
26   use FS::Conf;
27   use FS::CGI;
28   use FS::Msgcat;
29   
30   use FS::agent;
31   use FS::agent_type;
32   use FS::domain_record;
33   use FS::cust_bill;
34   use FS::cust_bill_pay;
35   use FS::cust_credit;
36   use FS::cust_credit_bill;
37   use FS::cust_main;
38   use FS::cust_main_county;
39   use FS::cust_pay;
40   use FS::cust_pkg;
41   use FS::cust_refund;
42   use FS::cust_svc;
43   use FS::nas;
44   use FS::part_bill_event;
45   use FS::part_pkg;
46   use FS::part_referral;
47   use FS::part_svc;
48   use FS::pkg_svc;
49   use FS::port;
50   use FS::queue;
51   use FS::raddb;
52   use FS::session;
53   use FS::svc_acct;
54   use FS::svc_acct_pop;
55   use FS::svc_domain;
56   use FS::svc_forward;
57   use FS::svc_www;
58   use FS::type_pkgs;
59   use FS::part_export;
60   use FS::part_export_option;
61   use FS::export_svc;
62   use FS::msgcat;
63
64   warn "[FS::InitHandler] handler called\n" if $DEBUG;
65
66   #this is sure to be broken on freebsd
67   $> = $FS::UID::freeside_uid;
68
69   open(MAPSECRETS,"<$FS::UID::conf_dir/mapsecrets")
70     or die "can't read $FS::UID::conf_dir/mapsecrets: $!";
71
72   my %seen;
73   while (<MAPSECRETS>) {
74     next if /^\s*(#|$)/;
75     /^([\w\-\.]+)\s(.*)$/
76       or do { warn "strange line in mapsecrets: $_"; next; };
77     my($user, $datasrc) = ($1, $2);
78     next if $seen{$datasrc}++;
79     warn "[FS::InitHandler] preloading $datasrc for $user\n" if $DEBUG;
80     adminsuidsetup($user);
81   }
82
83   close MAPSECRETS;
84
85   #lalala probably broken on freebsd
86   ($<, $>) = ($>, $<);
87   $< = 0;
88
89 }
90
91 1;