My critique of it is that it should use traceEvent(TRACE_ERROR) since the
terminal is detached, the fprintf should be thrown away... And if you're
not in daemon mode, it shouldn't trip the test.
I added it (both as a belt & suspenders):
if (myGlobals.daemonMode) {
/*
* We need a password for the admin user, but the user requested
* daemon mode. stdin is already detached, but syslog is not yet
* activated. So we can use neither getpass() nor traceEvent()
*/
traceEvent(TRACE_ERROR, "No password for admin user. Please re-run
ntop in non-daemon mode first.\n");
fprintf(stderr, "No password for admin user. Please re-run ntop in
non-daemon mode first.\n");
exit(1);
}
memset(pw1, 0, sizeof(pw1)); memset(pw2, 0, sizeof(pw2));
and the trace worked fine under linux:
Oct 12 17:15:29 tigger ntop[9599]: Initializing plugins (if any)...
Oct 12 17:15:29 tigger ntop[9599]: No password for admin user. Please re-run
ntop in non-daemon mode first.
Oct 12 17:15:29 tigger kernel: device eth0 left promiscuous mode
I'm not sure why it's not logging for you...
With that change, it seems reasonable.
Send the patch file to Luca at the patches address... [EMAIL PROTECTED] ... he
ignores attachments sent to other addresses.
-----Burton
-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]On Behalf Of
Ambrose Li
Sent: Saturday, October 12, 2002 4:29 PM
To: [EMAIL PROTECTED]
Subject: Re: [Ntop] admin password for ntop 2.1.50
Hi,
On Sat, Oct 12, 2002 at 03:03:46PM -0500, Burton M. Strauss III
wrote:
> Perhaps it should ... develop and test the patch and post
> it... probably easiest to log an error and stop at that point.
attached is a patch to make it display an error message and exit
if it is already in daemon mode and finds itself wanting to
get an admin password. My criticism of my own patch is that it
does not display the error message using the correct way (using
traceEvent); but traceEvent is non-functional when it wants
to call getpass(). In other words, the patch seems to work (in
Unix), but it's exceedingly ugly.
I tried to see if I can do it the other way, i.e., check
to see if the admin password exists before it calls
daemonize(). However, at that point the mutexes are not yet
created, and every time it would think the admin password does
not exist, even if it really does already exist.
> Or, you could read 1STRUN.TXT and follow that procedure. If
> you do, it's all done before it detaches the terminal.
--
Ambrose Li <[EMAIL PROTECTED]>
http://trends.ca/~acli/ http://www.cccgt.org/
DRM is theft - We are the stakeholders
_______________________________________________
Ntop mailing list
[EMAIL PROTECTED]
http://listgateway.unipi.it/mailman/listinfo/ntop