Commit | Line | Data |
---|---|---|
86530b38 AT |
1 | #!/import/bw/tools/local/perl-5.8.0/bin/perl |
2 | ||
3 | eval 'exec /import/bw/tools/local/perl-5.8.0/bin/perl -S $0 ${1+"$@"}' | |
4 | if 0; # not running under some shell | |
5 | ||
6 | use strict; | |
7 | ||
8 | require DBI::ProxyServer; | |
9 | ||
10 | # XXX these should probably be moved into DBI::ProxyServer | |
11 | delete $ENV{IFS}; | |
12 | delete $ENV{CDPATH}; | |
13 | delete $ENV{ENV}; | |
14 | delete $ENV{BASH_ENV}; | |
15 | ||
16 | if ($ARGV[0] eq '--test') { | |
17 | require RPC::PlServer::Test; | |
18 | shift @ARGV; | |
19 | @DBI::ProxyServer::ISA = qw(RPC::PlServer::Test DBI); | |
20 | } | |
21 | ||
22 | DBI::ProxyServer::main(@ARGV); | |
23 | exit(0); | |
24 | ||
25 | ||
26 | __END__ | |
27 | ||
28 | =head1 NAME | |
29 | ||
30 | dbiproxy - A proxy server for the DBD::Proxy driver | |
31 | ||
32 | ||
33 | =head1 SYNOPSIS | |
34 | ||
35 | dbiproxy <options> --port <port> | |
36 | ||
37 | ||
38 | =head1 DESCRIPTION | |
39 | ||
40 | This tool is just a front end for the DBI::ProxyServer package. All it | |
41 | does is picking options from the command line and calling | |
42 | DBI::ProxyServer::main(). See L<DBI::ProxyServer(3)> for details. | |
43 | ||
44 | Available options include: | |
45 | ||
46 | =over 4 | |
47 | ||
48 | =item B<--chroot=dir> | |
49 | ||
50 | (UNIX only) After doing a bind(), change root directory to the given | |
51 | directory by doing a chroot(). This is usefull for security, but it | |
52 | restricts the environment a lot. For example, you need to load DBI | |
53 | drivers in the config file or you have to create hard links to Unix | |
54 | sockets, if your drivers are using them. For example, with MySQL, a | |
55 | config file might contain the following lines: | |
56 | ||
57 | my $rootdir = '/var/dbiproxy'; | |
58 | my $unixsockdir = '/tmp'; | |
59 | my $unixsockfile = 'mysql.sock'; | |
60 | foreach $dir ($rootdir, "$rootdir$unixsockdir") { | |
61 | mkdir 0755, $dir; | |
62 | } | |
63 | link("$unixsockdir/$unixsockfile", | |
64 | "$rootdir$unixsockdir/$unixsockfile"); | |
65 | require DBD::mysql; | |
66 | ||
67 | { | |
68 | 'chroot' => $rootdir, | |
69 | ... | |
70 | } | |
71 | ||
72 | If you don't know chroot(), think of an FTP server where you can see a | |
73 | certain directory tree only after logging in. See also the --group and | |
74 | --user options. | |
75 | ||
76 | =item B<--configfile=file> | |
77 | ||
78 | Config files are assumed to return a single hash ref that overrides the | |
79 | arguments of the new method. However, command line arguments in turn take | |
80 | precedence over the config file. See the L<"CONFIGURATION FILE"> section | |
81 | below for details on the config file. | |
82 | ||
83 | =item B<--debug> | |
84 | ||
85 | Turn debugging mode on. Mainly this asserts that logging messages of | |
86 | level "debug" are created. | |
87 | ||
88 | =item B<--facility=mode> | |
89 | ||
90 | (UNIX only) Facility to use for L<Sys::Syslog (3)>. The default is | |
91 | B<daemon>. | |
92 | ||
93 | =item B<--group=gid> | |
94 | ||
95 | After doing a bind(), change the real and effective GID to the given. | |
96 | This is usefull, if you want your server to bind to a privileged port | |
97 | (<1024), but don't want the server to execute as root. See also | |
98 | the --user option. | |
99 | ||
100 | GID's can be passed as group names or numeric values. | |
101 | ||
102 | =item B<--localaddr=ip> | |
103 | ||
104 | By default a daemon is listening to any IP number that a machine | |
105 | has. This attribute allows to restrict the server to the given | |
106 | IP number. | |
107 | ||
108 | =item B<--localport=port> | |
109 | ||
110 | This attribute sets the port on which the daemon is listening. It | |
111 | must be given somehow, as there's no default. | |
112 | ||
113 | =item B<--logfile=file> | |
114 | ||
115 | Be default logging messages will be written to the syslog (Unix) or | |
116 | to the event log (Windows NT). On other operating systems you need to | |
117 | specify a log file. The special value "STDERR" forces logging to | |
118 | stderr. See L<Net::Daemon::Log(3)> for details. | |
119 | ||
120 | =item B<--mode=modename> | |
121 | ||
122 | The server can run in three different modes, depending on the environment. | |
123 | ||
124 | If you are running Perl 5.005 and did compile it for threads, then the | |
125 | server will create a new thread for each connection. The thread will | |
126 | execute the server's Run() method and then terminate. This mode is the | |
127 | default, you can force it with "--mode=threads". | |
128 | ||
129 | If threads are not available, but you have a working fork(), then the | |
130 | server will behave similar by creating a new process for each connection. | |
131 | This mode will be used automatically in the absence of threads or if | |
132 | you use the "--mode=fork" option. | |
133 | ||
134 | Finally there's a single-connection mode: If the server has accepted a | |
135 | connection, he will enter the Run() method. No other connections are | |
136 | accepted until the Run() method returns (if the client disconnects). | |
137 | This operation mode is usefull if you have neither threads nor fork(), | |
138 | for example on the Macintosh. For debugging purposes you can force this | |
139 | mode with "--mode=single". | |
140 | ||
141 | =item B<--pidfile=file> | |
142 | ||
143 | (UNIX only) If this option is present, a PID file will be created at the | |
144 | given location. | |
145 | ||
146 | =item B<--user=uid> | |
147 | ||
148 | After doing a bind(), change the real and effective UID to the given. | |
149 | This is usefull, if you want your server to bind to a privileged port | |
150 | (<1024), but don't want the server to execute as root. See also | |
151 | the --group and the --chroot options. | |
152 | ||
153 | UID's can be passed as group names or numeric values. | |
154 | ||
155 | =item B<--version> | |
156 | ||
157 | Supresses startup of the server; instead the version string will | |
158 | be printed and the program exits immediately. | |
159 | ||
160 | =back | |
161 | ||
162 | ||
163 | =head1 AUTHOR | |
164 | ||
165 | Copyright (c) 1997 Jochen Wiedmann | |
166 | Am Eisteich 9 | |
167 | 72555 Metzingen | |
168 | Germany | |
169 | ||
170 | Email: joe@ispsoft.de | |
171 | Phone: +49 7123 14881 | |
172 | ||
173 | The DBI::ProxyServer module is free software; you can redistribute it | |
174 | and/or modify it under the same terms as Perl itself. In particular | |
175 | permission is granted to Tim Bunce for distributing this as a part of | |
176 | the DBI. | |
177 | ||
178 | ||
179 | =head1 SEE ALSO | |
180 | ||
181 | L<DBI::ProxyServer(3)>, L<DBD::Proxy(3)>, L<DBI(3)> | |
182 |