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