X-Git-Url: http://ftp.carnet.hr/carnet-debian/scm?a=blobdiff_plain;f=src%2Fremoted%2Fmain.c;h=008eacd61ceca29e9de8d1e8f4712ee4bfbf21ee;hb=6ef2f786c6c8ead94841b5f93baf9f43421f08c8;hp=14708ba7aa32846009dbb94d0ddeed2b543cb310;hpb=914feba5d54f979cd5d7e69c349c3d01f630042a;p=ossec-hids.git diff --git a/src/remoted/main.c b/src/remoted/main.c index 14708ba..008eacd 100755 --- a/src/remoted/main.c +++ b/src/remoted/main.c @@ -1,11 +1,12 @@ -/* @(#) $Id: main.c,v 1.23 2009/11/18 19:07:41 dcid Exp $ */ +/* @(#) $Id: ./src/remoted/main.c, 2011/09/08 dcid Exp $ + */ /* Copyright (C) 2009 Trend Micro Inc. * All right reserved. * * This program is a free software; you can redistribute it * and/or modify it under the terms of the GNU General Public - * License (version 3) as published by the FSF - Free Software + * License (version 2) as published by the FSF - Free Software * Foundation */ @@ -20,17 +21,17 @@ int main(int argc, char **argv) int i = 0,c = 0; int uid = 0, gid = 0; int test_config = 0,run_foreground = 0; - + char *cfg = DEFAULTCPATH; char *dir = DEFAULTDIR; char *user = REMUSER; char *group = GROUPGLOBAL; - + /* Setting the name -- must be done ASAP */ OS_SetName(ARGV0); - + while((c = getopt(argc, argv, "Vdthfu:g:c:D:")) != -1){ switch(c){ case 'V': @@ -56,7 +57,7 @@ int main(int argc, char **argv) group = optarg; break; case 't': - test_config = 1; + test_config = 1; break; case 'c': if (!optarg) @@ -71,8 +72,8 @@ int main(int argc, char **argv) } debug1(STARTED_MSG,ARGV0); - - + + /* Return 0 if not configured */ if(RemotedConfig(cfg, &logr) < 0) { @@ -84,7 +85,12 @@ int main(int argc, char **argv) if(test_config) exit(0); - + if(logr.conn == NULL) + { + /* Not configured. */ + exit(0); + } + /* Check if the user and group given are valid */ uid = Privsep_GetUser(user); gid = Privsep_GetGroup(group); @@ -96,13 +102,13 @@ int main(int argc, char **argv) i = getpid(); - if(!run_foreground) + if(!run_foreground) { nowDaemon(); goDaemon(); } - + /* Setting new group */ if(Privsep_SetGroup(gid) < 0) ErrorExit(SETGID_ERROR, ARGV0, group); @@ -125,21 +131,21 @@ int main(int argc, char **argv) #else srandom( time(0) + getpid()+ i); #endif - + random(); - + /* Start up message */ verbose(STARTUP_MSG, ARGV0, (int)getpid()); /* Really starting the program. */ - i = 0; + i = 0; while(logr.conn[i] != 0) { /* Forking for each connection handler */ if(fork() == 0) - { + { /* On the child */ debug1("%s: DEBUG: Forking remoted: '%d'.",ARGV0, i); HandleRemote(i, uid);