Skip to content
This repository has been archived by the owner on Dec 29, 2020. It is now read-only.

Commit

Permalink
Provide ability to specify starting location for ng offline mode.
Browse files Browse the repository at this point in the history
  • Loading branch information
jvm3487 committed Jul 25, 2018
1 parent 80d5421 commit 36ff214
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 11 deletions.
51 changes: 41 additions & 10 deletions fw1-loggrabber.c
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ int
main (int argc, char *argv[])
{
int i;
int record_num = 0;
stringlist *lstptr;
char *foundstring;
char *field;
Expand Down Expand Up @@ -128,6 +129,25 @@ main (int argc, char *argv[])
{
audit_log = 0;
}
else if (strcmp (argv[i], "--loc") == 0)
{
i++;
if ( argv[i] == NULL )
{
fprintf (stderr, "ERROR: Value expected for argument: %s\n", argv[i - 1]);
usage (argv[0]);
exit_loggrabber (1);
}
if (argv[i][0] == '-')
{
fprintf (stderr, "ERROR: Value expected for argument %s\n",
argv[i - 1]);
usage (argv[0]);
exit_loggrabber (1);
}

record_num = atoi ( argv[i] );
}
else if ((strcmp (argv[i], "-f") == 0)
|| (strcmp (argv[i], "--logfile") == 0))
{
Expand Down Expand Up @@ -464,7 +484,7 @@ main (int argc, char *argv[])
fprintf (stderr, "DEBUG: Processing Logfile: %s\n",
lstptr->data);
}
read_fw1_logfile (&(lstptr->data));
read_fw1_logfile (&(lstptr->data), record_num);
lstptr = lstptr->next;
}
}
Expand All @@ -486,7 +506,7 @@ main (int argc, char *argv[])
fprintf (stderr, "DEBUG: Processing Logfile: %s\n",
cfgvalues.fw1_logfile);
}
read_fw1_logfile (&(cfgvalues.fw1_logfile));
read_fw1_logfile (&(cfgvalues.fw1_logfile), record_num);
}
while (lstptr)
{
Expand All @@ -495,7 +515,7 @@ main (int argc, char *argv[])
fprintf (stderr, "DEBUG: Processing Logfile: %s\n",
foundstring);
}
read_fw1_logfile (&foundstring);
read_fw1_logfile (&foundstring, record_num);
lstptr =
stringlist_search (&(lstptr->next), cfgvalues.fw1_logfile,
&foundstring);
Expand All @@ -513,7 +533,7 @@ main (int argc, char *argv[])
* function read_fw1_logfile
*/
int
read_fw1_logfile (char **LogfileName)
read_fw1_logfile (char **LogfileName, int record_num)
{
OpsecEntity *pClient = NULL;
OpsecEntity *pServer = NULL;
Expand Down Expand Up @@ -769,15 +789,24 @@ read_fw1_logfile (char **LogfileName)
}
else
{
pSession =
lea_new_suspended_session (pClient, pServer, LEA_OFFLINE,
LEA_UNIFIED_SINGLE, *LogfileName,
LEA_AT_START);
if ( record_num > 0 )
{
pSession = lea_new_suspended_session (pClient, pServer, LEA_OFFLINE,
LEA_UNIFIED_SINGLE, *LogfileName,
LEA_AT_POS, record_num);
}
else
{
pSession =
lea_new_suspended_session (pClient, pServer, LEA_OFFLINE,
LEA_UNIFIED_SINGLE, *LogfileName,
LEA_AT_START);
}
}
if (!pSession)
{
fprintf (stderr, "ERROR: failed to create session (%s)\n",
opsec_errno_str (opsec_errno));
fprintf (stderr, "ERROR: failed to create session (%s), loc=%d\n",
opsec_errno_str (opsec_errno), record_num);
cleanup_fw1_environment (pEnv, pClient, pServer);
exit_loggrabber (1);
}
Expand Down Expand Up @@ -1989,6 +2018,8 @@ usage (char *szProgName)
" --auditlog|--normallog : Get data of audit-logfile (fw.adtlog)(default: normallog)\n");
fprintf (stderr,
" --debug-level <level> : Specify Debuglevel (default: 0 - no debugging)\n");
fprintf (stderr,
" --loc <record number> : Starting record number (default: 0 - start at the beginning of the log, ng only)\n");
fprintf (stderr,
" --help : Show usage information\n");
}
Expand Down
2 changes: 1 addition & 1 deletion fw1-loggrabber.h
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ configvalues;
/*
* function to get the content of a given FW-1 Logfile
*/
int read_fw1_logfile (char **);
int read_fw1_logfile (char **,int);

/*
* event handler used by read_fw1_logfile to approve a rulebase
Expand Down

0 comments on commit 36ff214

Please sign in to comment.