* Copyright (c) 1998-2003, Index Data.
* See the file LICENSE for details.
*
- * $Id: yaz-proxy-main.cpp,v 1.22 2003-10-23 11:45:08 adam Exp $
+ * $Id: yaz-proxy-main.cpp,v 1.26 2003-10-24 12:19:23 adam Exp $
*/
#include <signal.h>
void usage(char *prog)
{
- fprintf (stderr, "%s: [-c config] [-a log] [-m num] [-v level] [-t target] [-i sec] "
- "[-u uid] [-p pidfile] [-o optlevel] @:port\n", prog);
+ fprintf (stderr, "%s: [-c config] [-l log] [-a log] [-v level] [-t target] "
+ "[-u uid] [-p pidfile] @:port\n", prog);
exit (1);
}
static char *pid_fname = 0;
static char *uid = 0;
+static char *log_file = 0;
int args(Yaz_Proxy *proxy, int argc, char **argv)
{
break;
case 'l':
yaz_log_init_file (arg);
+ log_file = xstrdup(arg);
break;
case 'm':
proxy->set_max_clients(atoi(arg));
}
if (addr)
{
+ yaz_log(LOG_LOG, "Starting proxy pid=%ld", (long) getpid());
if (proxy->server(addr))
{
yaz_log(LOG_FATAL|LOG_ERRNO, "listen %s", addr);
static Yaz_Proxy *static_yaz_proxy = 0;
static void sighup_handler(int num)
{
+ signal(SIGHUP, sighup_handler);
if (static_yaz_proxy)
static_yaz_proxy->reconfig();
}
if (uid)
{
struct passwd *pw;
-
+
if (!(pw = getpwnam(uid)))
{
yaz_log(LOG_FATAL, "%s: Unknown user", uid);
exit(3);
}
+ if (log_file)
+ {
+ chown(log_file, pw->pw_uid, pw->pw_gid);
+ xfree(log_file);
+ }
+
if (setuid(pw->pw_uid) < 0)
{
yaz_log(LOG_FATAL|LOG_ERRNO, "setuid");