2.0.6.beta.14 argus startup problems
Andreas Östling
andreaso at it.su.se
Fri Dec 5 04:28:39 EST 2003
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