Skip to content

Commit

Permalink
Fix ossec-execd command line arguments
Browse files Browse the repository at this point in the history
Move away from the shared help(). Not all binaries are created equal and
take the same arguments. The shared help caused confusion which was
brought up in ossec#207.

The '-c' option should now work so a user can specify an alternate
configuration location. Also, the '-D' and '-u' options were removed.
This is important to note because previously they would have just been
silently ignored. With this commit, specifying these options will
present the help() output and exit non-zero.

Of course this has the potential to break a setup out there but I would
imagine the likelyhood is low that people are specifying these options.
  • Loading branch information
awiddersheim committed Aug 22, 2014
1 parent 3ebc56c commit 6819f8e
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 13 deletions.
35 changes: 22 additions & 13 deletions src/os_execd/execd.c
Original file line number Diff line number Diff line change
Expand Up @@ -77,25 +77,21 @@ int main(int argc, char **argv)
int test_config = 0,run_foreground = 0;
int gid = 0,m_queue = 0;

// TODO: delete or implement
char *dir __attribute__((unused)) = DEFAULTDIR;
char *group = GROUPGLOBAL;
// TODO: delete or implement
char *cfg __attribute__((unused)) = DEFAULTARPATH;
char *xmlcfg = DEFAULTCPATH;


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


while((c = getopt(argc, argv, "Vtdhfu:g:D:c:")) != -1){
while((c = getopt(argc, argv, "Vtdhfg:c:")) != -1){
switch(c){
case 'V':
print_version();
break;
case 'h':
help(ARGV0);
help_local();
break;
case 'd':
nowDebug();
Expand All @@ -108,21 +104,16 @@ int main(int argc, char **argv)
ErrorExit("%s: -g needs an argument.",ARGV0);
group = optarg;
break;
case 'D':
if(!optarg)
ErrorExit("%s: -D needs an argument.",ARGV0);
dir = optarg;
break;
case 'c':
if(!optarg)
ErrorExit("%s: -c needs an argument.",ARGV0);
cfg = optarg;
xmlcfg = optarg;
break;
case 't':
test_config = 1;
break;
default:
help(ARGV0);
help_local();
break;
}

Expand Down Expand Up @@ -649,6 +640,24 @@ void ExecdStart(int q)
}
}

/* print help statement */
void help_local()
{
print_header();
print_out(" %s: -[Vhdt] [-g group] [-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 up to two times");
print_out(" to increase the debug level.");
print_out(" -t Test configuration");
print_out(" -f Run in foreground");
print_out(" -g <group> Run as 'group'");
print_out(" -c <config> Read the 'config' file");
print_out(" ");
exit(1);
}


#endif

Expand Down
2 changes: 2 additions & 0 deletions src/os_execd/execd.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@ void WinTimeoutRun(int timeout);

void FreeTimeoutEntry(void *timeout_entry);

void help_local();




Expand Down

0 comments on commit 6819f8e

Please sign in to comment.