MAN page from Old RedHat 6.X DBI-1.13-1.i386.rpm
lib::DBI::ProxyServer
Section: User Contributed Perl Documentation (3)
Updated: perl 5.005, patch 03
Index NAME
DBI::ProxyServer - a server for the DBD::Proxy driver
SYNOPSIS
use DBI::ProxyServer; DBI::ProxyServer::main(@ARGV);
DESCRIPTION
DBI::Proxy Server is a module for implementing a proxy for the DBI proxydriver, DBD::Proxy. It allows access to databases over the network if theDBMS does not offer networked operations. But the proxy server might beusefull for you, even if you have a DBMS with integrated networkfunctionality: It can be used as a DBI proxy in a firewalled environment.
DBI::ProxyServer runs as a daemon on the machine with the DBMS or on thefirewall. The client connects to the agent using the DBI driver DBD::Proxy,thus in the exactly same way than using DBD::mysql, DBD::mSQL or any otherDBI driver.
The agent is implemented as a RPC::PlServer application. Thus you haveaccess to all the possibilities of this module, in particular encryptionand a similar configuration file. DBI::ProxyServer adds the possibility ofquery restrictions: You can define a set of queries that a client mayexecute and restrict access to those. (Requires a DBI driver that supportsparameter binding.) See the section on /CONFIGURATION FILE.
OPTIONS
When calling the
DBI::ProxyServer::main() function, you supply anarray of options. (@ARGV, the array of command line options is used,if you don't.) These options are parsed by the Getopt::Long module.The ProxyServer inherits all of RPC::PlServer's and hence Net::Daemon'soptions and option handling, in particular the ability to readoptions from either the command line or a config file. Seethe
RPC::PlServer(3) manpage. See the
Net::Daemon(3) manpage. Available options include
- chroot (--chroot=dir)
- (UNIX only) After doing a bind(), change root directory to the givendirectory by doing a chroot(). This is usefull for security, but itrestricts the environment a lot. For example, you need to load DBIdrivers in the config file or you have to create hard links to Unixsockets, if your drivers are using them. For example, with MySQL, aconfig file might contain the following lines:
my $rootdir = '/var/dbiproxy'; my $unixsockdir = '/tmp'; my $unixsockfile = 'mysql.sock'; foreach $dir ($rootdir, "$rootdir$unixsockdir") { mkdir 0755, $dir; } link("$unixsockdir/$unixsockfile", "$rootdir$unixsockdir/$unixsockfile"); require DBD::mysql; { 'chroot' => $rootdir, ... }If you don't know chroot(), think of an FTP server where you can see acertain directory tree only after logging in. See also the --group and--user options.
- clients
- An array ref with a list of clients. Clients are hash refs, the attributesaccept (0 for denying access and 1 for permitting) and mask, a Perlregular expression for the clients IP number or its host name. Seethe section on Access control below.
- configfile (--configfile=file)
- Config files are assumed to return a single hash ref that overrides thearguments of the new method. However, command line arguments in turn takeprecedence over the config file. See the the section on CONFIGURATION FILE sectionbelow for details on the config file.
- debug (--debug)
- Turn debugging mode on. Mainly this asserts that logging messages oflevel ``debug'' are created.
- facility (--facility=mode)
- (UNIX only) Facility to use for the section on Sys::Syslog (3). The default isdaemon.
- group (--group=gid)
- After doing a bind(), change the real and effective GID to the given.This is usefull, if you want your server to bind to a privileged port(<1024), but don't want the server to execute as root. See alsothe --user option.
GID's can be passed as group names or numeric values.
- localaddr (--localaddr=ip)
- By default a daemon is listening to any IP number that a machinehas. This attribute allows to restrict the server to the givenIP number.
- localport (--localport=port)
- This attribute sets the port on which the daemon is listening. Itmust be given somehow, as there's no default.
- logfile (--logfile=file)
- Be default logging messages will be written to the syslog (Unix) orto the event log (Windows NT). On other operating systems you need tospecify a log file. The special value ``STDERR'' forces logging tostderr. See the Net::Daemon::Log(3) manpage for details.
- mode (--mode=modename)
- The server can run in three different modes, depending on the environment.
If you are running Perl 5.005 and did compile it for threads, then theserver will create a new thread for each connection. The thread willexecute the server's Run() method and then terminate. This mode is thedefault, you can force it with ``---mode=threads''.
If threads are not available, but you have a working fork(), then theserver will behave similar by creating a new process for each connection.This mode will be used automatically in the absence of threads or ifyou use the ``---mode=fork'' option.
Finally there's a single-connection mode: If the server has accepted aconnection, he will enter the Run() method. No other connections areaccepted until the Run() method returns (if the client disconnects).This operation mode is usefull if you have neither threads nor fork(),for example on the Macintosh. For debugging purposes you can force thismode with ``---mode=single''.
- pidfile (--pidfile=file)
- (UNIX only) If this option is present, a PID file will be created at thegiven location.
- user (--user=uid)
- After doing a bind(), change the real and effective UID to the given.This is usefull, if you want your server to bind to a privileged port(<1024), but don't want the server to execute as root. See alsothe --group and the --chroot options.
UID's can be passed as group names or numeric values.
- version (--version)
- Supresses startup of the server; instead the version string willbe printed and the program exits immediately.
CONFIGURATION FILE
The configuration file is just that of
RPC::PlServer or
Net::Daemonwith some additional attributes in the client list.
The config file is a Perl script. At the top of the file you may includearbitraty Perl source, for example load drivers at the start (usefullto enhance performance), prepare a chroot environment and so on.
The important thing is that you finally return a hash ref of optionname/value pairs. The possible options are listed above.
All possibilities of Net::Daemon and RPC::PlServer apply, in particular
- Host and/or User dependent access control
- Host and/or User dependent encryption
- Changing UID and/or GID after binding to the port
- Running in a chroot() environment
Additionally the server offers you query restrictions. Suggest thefollowing client list:
'clients' => [ { 'mask' => '^admin\.company\.com$', 'accept' => 1, 'users' => [ 'root', 'wwwrun' ], }, { 'mask' => '^admin\.company\.com$', 'accept' => 1, 'users' => [ 'root', 'wwwrun' ], 'sql' => { 'select' => 'SELECT * FROM foo', 'insert' => 'INSERT INTO foo VALUES (?, ?, ?)' } }then only the users root and wwwrun may connect from admin.company.com,executing arbitrary queries, but only wwwrun may connect from otherhosts and is restricted to
$sth->prepare("select");or
$sth->prepare("insert");which in fact are ``
SELECT *
FROM foo'' or ``
INSERT INTO foo
VALUES (?, ?, ?)''.
AUTHOR
Copyright (c) 1997 Jochen Wiedmann Am Eisteich 9 72555 Metzingen Germany
Email: joeAATTispsoft.de Phone: +49 7123 14881
The DBI::ProxyServer module is free software; you can redistribute itand/or modify it under the same terms as Perl itself. In particularpermission is granted to Tim Bunce for distributing this as a part ofthe DBI.
SEE ALSO
the
dbiproxy(1) manpage, the
DBD::Proxy(3) manpage, the
DBI(3) manpage, the
RPC::PlServer(3) manpage,the
RPC::PlClient(3) manpage, the
Net::Daemon(3) manpage, the
Net::Daemon::Log(3) manpage,the
Sys::Syslog(3) manpage, the
Win32::EventLog(3) manpage, the
syslog(2) manpage
Index
- NAME
- SYNOPSIS
- DESCRIPTION
- OPTIONS
- CONFIGURATION FILE
- AUTHOR
- SEE ALSO
This document was created byman2html,using the manual pages.