Re: Inetd configuration message logging (or lack thereof)

2002-05-21 Thread BsdWins

- David Malone's Original Message -
 On Sat, May 18, 2002 at 06:51:31PM -0700, John De Boskey wrote:
  Comments on the following patch. The messages
  are invisible with a default install. This patch
  gets them into /var/log/messages where they can be
  seen.
 
 I have a different fix for this at home, included below. It uses
 syslog's LOG_PERROR flag when initially calling openlog. It then
 reopens the log without the LOG_PERROR when/if it becomes a daemon.
 
   David.

Merged patch works like a charm.  Invalid config lines are
sent to syslog() at init time and inetd -d now outputs all
(debug) info to the console.

-John


RCS file: /home/ncvs/src/usr.sbin/inetd/inetd.c,v
retrieving revision 1.96
diff -u -r1.96 inetd.c
--- inetd.c 8 May 2002 17:20:08 -   1.96
+++ inetd.c 20 May 2002 03:01:13 -
@@ -317,7 +317,7 @@
const char *servname;
int error;

-   openlog(inetd, LOG_PID | LOG_NOWAIT, LOG_DAEMON);
+   openlog(inetd, LOG_PID | LOG_NOWAIT | LOG_PERROR, LOG_DAEMON);

while ((ch = getopt(argc, argv, dlwWR:a:c:C:p:)) != -1)
switch(ch) {
@@ -434,6 +434,9 @@
if (daemon(0, 0)  0) {
syslog(LOG_WARNING, daemon(0,0) failed: %m);
}
+   /* From now on we don't want syslog messages going to stderr. */
+   closelog();
+   openlog(inetd, LOG_PID | LOG_NOWAIT, LOG_DAEMON);
/*
 * In case somebody has started inetd manually, we need to
 * clear the logname, so that old servers run as root do not
@@ -1613,7 +1616,7 @@
}
 if (strncmp(sep-se_proto, rpc/, 4) == 0) {
if (no_v4bind != 0) {
-   syslog(LOG_INFO, IPv4 bind is ignored for %s,
+   syslog(LOG_NOTICE, IPv4 bind is ignored for %s,
   sep-se_service);
freeconfig(sep);
goto more;
@@ -1654,7 +1657,7 @@
 #ifdef INET6
if (sep-se_proto[strlen(sep-se_proto) - 1] == '6') {
if (no_v6bind != 0) {
-   syslog(LOG_INFO, IPv6 bind is ignored for %s,
+   syslog(LOG_NOTICE, IPv6 bind is ignored for %s,
   sep-se_service);
freeconfig(sep);
goto more;
@@ -1686,7 +1689,7 @@
 #endif
{ /* default to v4 bind if not v6 bind */
if (no_v4bind != 0) {
-   syslog(LOG_INFO, IPv4 bind is ignored for %s,
+   syslog(LOG_NOTICE, IPv4 bind is ignored for %s,
   sep-se_service);
freeconfig(sep);
goto more;




To Unsubscribe: send mail to [EMAIL PROTECTED]
with unsubscribe freebsd-current in the body of the message



Re: Inetd configuration message logging (or lack thereof)

2002-05-19 Thread David Malone

On Sat, May 18, 2002 at 06:51:31PM -0700, John De Boskey wrote:
 Comments on the following patch. The messages
 are invisible with a default install. This patch
 gets them into /var/log/messages where they can be
 seen.

I have a different fix for this at home, included below. It uses
syslog's LOG_PERROR flag when initially calling openlog. It then
reopens the log without the LOG_PERROR when/if it becomes a daemon.

David.

diff -u -r1.96 inetd.c
--- inetd.c 8 May 2002 17:20:08 -   1.96
+++ inetd.c 13 May 2002 23:02:35 -
@@ -317,7 +317,7 @@
const char *servname;
int error;
 
-   openlog(inetd, LOG_PID | LOG_NOWAIT, LOG_DAEMON);
+   openlog(inetd, LOG_PID | LOG_NOWAIT | LOG_PERROR, LOG_DAEMON);
 
while ((ch = getopt(argc, argv, dlwWR:a:c:C:p:)) != -1)
switch(ch) {
@@ -434,6 +434,9 @@
if (daemon(0, 0)  0) {
syslog(LOG_WARNING, daemon(0,0) failed: %m);
}
+   /* From now on we don't want syslog messages going to stderr. */
+   closelog();
+   openlog(inetd, LOG_PID | LOG_NOWAIT, LOG_DAEMON);
/*
 * In case somebody has started inetd manually, we need to
 * clear the logname, so that old servers run as root do not


To Unsubscribe: send mail to [EMAIL PROTECTED]
with unsubscribe freebsd-current in the body of the message



Inetd configuration message logging (or lack thereof)

2002-05-18 Thread John De Boskey

Hi,

Comments on the following patch. The messages
are invisible with a default install. This patch
gets them into /var/log/messages where they can be
seen.

-John

ps: Not in this patch, but I wonder if syslog
cannot be redirected to the console when run -d.
Something like:

#define syslog InetdSyslog
void InetdSyslog(int,char *, ...);

void
InetdSyslog(int priority,char *message, ...)
{
   va_list ap;

   va_start(ap, message);
   if (debug) {
  vfprintf(stderr,message,ap);
  fprintf(stderr,\n);
   }
   else
  vsyslog(priority,message,ap);
   va_end(message);
   return;
}


 

RCS file: /home/ncvs/src/usr.sbin/inetd/inetd.c,v
retrieving revision 1.96
diff -u -r1.96 inetd.c
--- inetd.c 8 May 2002 17:20:08 -   1.96
+++ inetd.c 19 May 2002 01:04:56 -
@@ -1613,7 +1613,7 @@
}
 if (strncmp(sep-se_proto, rpc/, 4) == 0) {
if (no_v4bind != 0) {
-   syslog(LOG_INFO, IPv4 bind is ignored for %s,
+   syslog(LOG_NOTICE, IPv4 bind is ignored for %s,
   sep-se_service);
freeconfig(sep);
goto more;
@@ -1654,7 +1654,7 @@
 #ifdef INET6
if (sep-se_proto[strlen(sep-se_proto) - 1] == '6') {
if (no_v6bind != 0) {
-   syslog(LOG_INFO, IPv6 bind is ignored for %s,
+   syslog(LOG_NOTICE, IPv6 bind is ignored for %s,
   sep-se_service);
freeconfig(sep);
goto more;
@@ -1686,7 +1686,7 @@
 #endif
{ /* default to v4 bind if not v6 bind */
if (no_v4bind != 0) {
-   syslog(LOG_INFO, IPv4 bind is ignored for %s,
+   syslog(LOG_NOTICE, IPv4 bind is ignored for %s,
   sep-se_service);
freeconfig(sep);
goto more;


To Unsubscribe: send mail to [EMAIL PROTECTED]
with unsubscribe freebsd-current in the body of the message