Skip to content

Commit

Permalink
Fix help and command line arguments
Browse files Browse the repository at this point in the history
Fixes to the command line arguments and help messages in
ossec-syscheckd. This is related to the issues in ossec#207.

Found that syscheck.workdir wasn't really used for anything that I could
find. Removed it completely for now.
  • Loading branch information
awiddersheim committed Aug 25, 2014
1 parent e59e548 commit fd79dd1
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 23 deletions.
1 change: 0 additions & 1 deletion src/config/syscheck-config.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ typedef struct _config

int *opts; /* attributes set in the <directories> tag element */

char *workdir; /* set to the DEFAULTDIR (/var/ossec) */
char *remote_db;
char *db;

Expand Down
41 changes: 19 additions & 22 deletions src/syscheckd/syscheck.c
Original file line number Diff line number Diff line change
Expand Up @@ -102,10 +102,6 @@ int Start_win32_Syscheck()
debug1(STARTED_MSG, ARGV0);


/* Zeroing the structure */
syscheck.workdir = DEFAULTDIR;


/* Checking if the configuration is present */
if(File_DateofChange(cfg) < 0)
ErrorExit(NO_CONFIG, ARGV0, cfg);
Expand Down Expand Up @@ -191,7 +187,22 @@ int Start_win32_Syscheck()
}
#endif


/* print help statement */
void help_local()
{
print_header();
print_out(" %s: -[Vhdtf] [-c config]", ARGV0);
print_out(" -V Version and license message");
print_out(" -h This help message");
print_out(" -d Execute in debug mode. This parameter");
print_out(" can be specified multiple times");
print_out(" to increase the debug level.");
print_out(" -t Test configuration");
print_out(" -f Run in foreground");
print_out(" -c <config> Read the 'config' file");
print_out(" ");
exit(1);
}

/* Syscheck unix main.
*/
Expand All @@ -205,23 +216,19 @@ int main(int argc, char **argv)
char *cfg = DEFAULTCPATH;


/* Zeroing the structure */
syscheck.workdir = NULL;


/* Setting the name */
OS_SetName(ARGV0);


while((c = getopt(argc, argv, "VtdhfD:c:")) != -1)
while((c = getopt(argc, argv, "Vtdhfc:")) != -1)
{
switch(c)
{
case 'V':
print_version();
break;
case 'h':
help(ARGV0);
help_local();
break;
case 'd':
nowDebug();
Expand All @@ -230,11 +237,6 @@ int main(int argc, char **argv)
case 'f':
run_foreground = 1;
break;
case 'D':
if(!optarg)
ErrorExit("%s: -D needs an argument",ARGV0);
syscheck.workdir = optarg;
break;
case 'c':
if(!optarg)
ErrorExit("%s: -c needs an argument",ARGV0);
Expand All @@ -244,7 +246,7 @@ int main(int argc, char **argv)
test_config = 1;
break;
default:
help(ARGV0);
help_local();
break;
}
}
Expand Down Expand Up @@ -305,11 +307,6 @@ int main(int argc, char **argv)
exit(0);


/* Setting default values */
if(syscheck.workdir == NULL)
syscheck.workdir = DEFAULTDIR;


/* Setup libmagic */
#ifdef USE_MAGIC
init_magic(&magic_cookie);
Expand Down

0 comments on commit fd79dd1

Please sign in to comment.