2.0.6.beta.14 argus startup problems
Carter Bullard
carter at qosient.com
Fri Dec 5 12:06:42 EST 2003
Hey Andreas,
You are absolutely correct, but what I was trying to do
with the first getopt() was to process a subset of the
commandline arguments, no matter where they were in the
commandline, and then after that, process them again in
another pass. Putting the '+' doesn't solve the problem,
as it can stop in the middle of the processing.
I just removed the first getopt() in my fix and processed
the string myself. Total avoidance fix ;)
Thanks for the bug hunt. I'm interested in the fact that
it was on your RH9 machine. I've been running it on RH9
for a while, and didn't notice any problems, but I almost
always get the options from /etc/argus.conf
Carter
-----Original Message-----
From: owner-argus-info at lists.andrew.cmu.edu
[mailto:owner-argus-info at lists.andrew.cmu.edu] On Behalf Of Andreas Östling
Sent: Friday, December 05, 2003 4:29 AM
To: argus-info at lists.andrew.cmu.edu
Subject: Re: 2.0.6.beta.14 argus startup problems
I was looking into the getopt stuff some more and a simple printf statement
showed that the first call to getopt messed things up (only on RH9).
Here is what it lookes like right after the second getopt call:
# bin/argus_linux -i eth1 -w /tmp/foo -i eth2
optind=3, opterr=0, optarg=-w, op=i
optind=5, opterr=0, optarg=eth1, op=i
argus_linux[9578]: ArgusInitSource: pcap_open_live ioctl: No such device
When commenting out the first getopt block, the result is instead:
# bin/argus_linux -i eth1 -w /tmp/foo -i eth2
optind=3, opterr=0, optarg=eth1, op=i
optind=5, opterr=0, optarg=/tmp/foo, op=w
optind=7, opterr=0, optarg=eth2, op=i
The getopt man page says "If the first character of optstring is `+' or
the
environment variable POSIXLY_CORRECT is set, then option processing
stops as soon as a non-option argument is encountered.", which acually seems
to do the trick.
This gigantic diff (against 2.0.6 rc) fixes it on my RH9 at least:
--- argus.c.org 2003-12-05 10:08:17.000000000 +0100
+++ argus.c 2003-12-05 10:08:25.000000000 +0100
@@ -231,7 +231,7 @@
setArgusMarReportInterval (ARGUS_MARSTATUSTIMER);
opterr = 0; optind = 1;
- while ((op = getopt (argc, argv, "F:Xh")) != EOF) {
+ while ((op = getopt (argc, argv, "+F:Xh")) != EOF) {
switch (op) {
case 'F':
ArgusParseResourceFile (optarg);
I don't know if this is the best way of fixing it or if it has other
implications on other OSes, but maybe it's a start.
/Andreas
On Friday 05 December 2003 06.26, Peter Van Epp wrote:
> It probably got introduced back about beta.12 or so. There was a
> problem with the BSDs and getopt (that didn't occur on linux at least not
> on RedHat 7.3) that Carter fixed. I don't remember if I tried the fix on
> RedHat 9 at that point, and I'm pretty sure Carter is still running 7.3.
It
> may be profitable to try the 2.0.6 release candidate (although I have a
few
> BSD fixes for it already, none of them are around the getopt stuff).
More information about the argus
mailing list