| Summary: | logger(1) manpage has wrong with default value of -p option | ||
|---|---|---|---|
| Product: | Base System | Reporter: | sugimura <sugimura> |
| Component: | bin | Assignee: | freebsd-doc (Nobody) <doc> |
| Status: | Closed FIXED | ||
| Severity: | Affects Only Me | ||
| Priority: | Normal | ||
| Version: | 4.3-STABLE | ||
| Hardware: | Any | ||
| OS: | Any | ||
On Thu, Sep 06, 2001 at 01:46:51AM -0700, SUGIMURA Takashi wrote: > > In manpage of logger(1), > > -p pri Enter the message with the specified priority. The priority may > be specified numerically or as a ``facility.level'' pair. For > example, ``-p local3.info'' logs the message(s) as informational > level in the local3 facility. The default is ``user.notice.'' > > but this default value is wrong. > > It seems ``kern.notice.'' > > > >How-To-Repeat: > simply run logger such as following; > > % logger hogehoge > > getting syslog packet, it has "<5>hogehoge" sequence. > 5 is 0x0000 plus 0x0101, so its facility is "kern" > and its priority is "notice". > I see this: ``Sep 6 12:18:32 <1.5> perl ru: hogehoge'' which means (1<<3) | 5 == LOG_USER | LOG_NOTICE. This is also the default facility, as per syslog(3): : LOG_USER Messages generated by random user processes. This is the : default facility identifier if none is specified. And the logger(1)'s code matches the default. Cheers, -- Ruslan Ermilov Oracle Developer/DBA, ru@sunbay.com Sunbay Software AG, ru@FreeBSD.org FreeBSD committer, +380.652.512.251 Simferopol, Ukraine http://www.FreeBSD.org The Power To Serve http://www.oracle.com Enabling The Information Age Hello, >> getting syslog packet, it has "<5>hogehoge" sequence. >> 5 is 0x0000 plus 0x0101, so its facility is "kern" >> and its priority is "notice". >> >I see this: ``Sep 6 12:18:32 <1.5> perl ru: hogehoge'' >which means (1<<3) | 5 == LOG_USER | LOG_NOTICE. > No, I tried many other facility and priority, then I know that (LOG_USER | LOG_NOTICE) is <13>. --- SUGIMURA Takashi <sugimura@jp.FreeBSD.org> <sugimura@YasudaKei.org> On Thu, Sep 06, 2001 at 08:07:50PM +0900, SUGIMURA Takashi ?$B?yB<?(B ?$B5.;N?(B wrote: > Hello, > > >> getting syslog packet, it has "<5>hogehoge" sequence. > >> 5 is 0x0000 plus 0x0101, so its facility is "kern" > >> and its priority is "notice". > >> > >I see this: ``Sep 6 12:18:32 <1.5> perl ru: hogehoge'' > >which means (1<<3) | 5 == LOG_USER | LOG_NOTICE. > > > > No, I tried many other facility and priority, then I know that > (LOG_USER | LOG_NOTICE) is <13>. > Err. Is't impossible to generate a LOG_KERN using syslog(3). Only kernel can generate these. LOG_KERN | LOG_NOTICE == LOG_NOTICE, as LOG_KERN is defined as (0<<3). And libc/gen/syslog.c defaults facility to LOG_USER: : static int LogFacility = LOG_USER; /* default facility code */ [...] : /* Set default facility if none specified. */ : if ((pri & LOG_FACMASK) == 0) : pri |= LogFacility; LOG_KERN is defined as follows: #define LOG_KERN (0<<3) /* kernel messages */ #define LOG_USER (1<<3) /* random user-level messages */ So if you call ``logger -p kern.notice'', that becomes as if it were ``logger -p user.notice''. This is also documented in the syslog(3) manpage: : LOG_KERN Messages generated by the kernel. These cannot be : generated by any user processes. [...] : LOG_USER Messages generated by random user processes. This : is the default facility identifier if none is specified. Cheers, -- Ruslan Ermilov Oracle Developer/DBA, ru@sunbay.com Sunbay Software AG, ru@FreeBSD.org FreeBSD committer, +380.652.512.251 Simferopol, Ukraine http://www.FreeBSD.org The Power To Serve http://www.oracle.com Enabling The Information Age State Changed From-To: open->closed LOG_KERN cannot be generated by a user process. I am very sad you've closed the PR. >> No, I tried many other facility and priority, then I know that >> (LOG_USER | LOG_NOTICE) is <13>. >> >Err. Is't impossible to generate a LOG_KERN using syslog(3). >Only kernel can generate these. > I see, but this problem is not concern about syslog(3). >LOG_KERN | LOG_NOTICE == LOG_NOTICE, as LOG_KERN is defined as (0<<3). Yes, I know, of course. LOG_NOTICE is decoded to <5>, so LOG_KERN | LOG_NOTICE is <5>, not <13>. 13 = (1<<3) | 5. >So if you call ``logger -p kern.notice'', that becomes as if it >were ``logger -p user.notice''. This is also documented in the >syslog(3) manpage: > Is it right? I say that about logger(1). Please see main() on /usr/src/usr.bin/logger/logger.c: ---------------- int main(argc, argv) int argc; char *argv[]; { int ch, logflags, pri; char *tag, *host, buf[1024]; tag = NULL; host = NULL; pri = LOG_NOTICE; logflags = 0; unsetenv("TZ"); while ((ch = getopt(argc, argv, "46Af:h:ip:st:")) != -1) (snip) ---------------- This shows the default value of variable "pri" is "LOG_NOTICE", it is not (LOG_USER | LOG_NOTICE) as you said. And, logger(1) don't use syslog(3) functions, simply send a UDP packet to the port 514. --- SUGIMURA Takashi <sugimura@jp.FreeBSD.org> <sugimura@YasudaKei.org> On Thu, Sep 06, 2001 at 09:25:45PM +0900, SUGIMURA Takashi ?$B?yB<?(B ?$B5.;N?(B wrote: > I am very sad you've closed the PR. > > >> No, I tried many other facility and priority, then I know that > >> (LOG_USER | LOG_NOTICE) is <13>. > >> > >Err. Is't impossible to generate a LOG_KERN using syslog(3). > >Only kernel can generate these. > > > > I see, but this problem is not concern about syslog(3). > > > >LOG_KERN | LOG_NOTICE == LOG_NOTICE, as LOG_KERN is defined as (0<<3). > > Yes, I know, of course. > LOG_NOTICE is decoded to <5>, so LOG_KERN | LOG_NOTICE is <5>, not <13>. > 13 = (1<<3) | 5. > > > >So if you call ``logger -p kern.notice'', that becomes as if it > >were ``logger -p user.notice''. This is also documented in the > >syslog(3) manpage: > > > > Is it right? > > I say that about logger(1). > Please see main() on /usr/src/usr.bin/logger/logger.c: > > ---------------- > int > main(argc, argv) > int argc; > char *argv[]; > { > int ch, logflags, pri; > char *tag, *host, buf[1024]; > > tag = NULL; > host = NULL; > pri = LOG_NOTICE; > logflags = 0; > unsetenv("TZ"); > while ((ch = getopt(argc, argv, "46Af:h:ip:st:")) != -1) > (snip) > ---------------- > > This shows the default value of variable "pri" is "LOG_NOTICE", > it is not (LOG_USER | LOG_NOTICE) as you said. > > And, logger(1) don't use syslog(3) functions, simply send a UDP packet > to the port 514. > Are you sure? : if (host == NULL) { : syslog(pri, "%s", buf); : return; : } Cheers, -- Ruslan Ermilov Oracle Developer/DBA, ru@sunbay.com Sunbay Software AG, ru@FreeBSD.org FreeBSD committer, +380.652.512.251 Simferopol, Ukraine http://www.FreeBSD.org The Power To Serve http://www.oracle.com Enabling The Information Age On Thu, Sep 06, 2001 at 09:35:39PM +0900, SUGIMURA Takashi ?$B?yB<?(B ?$B5.;N?(B wrote: > >> And, logger(1) don't use syslog(3) functions, simply send a UDP packet > >> to the port 514. > >> > >Are you sure? > > > >: if (host == NULL) { > >: syslog(pri, "%s", buf); > >: return; > >: } > > > > If -h option is specified and -p is not, then? > You didn't mention it, do you? Cheers, -- Ruslan Ermilov Oracle Developer/DBA, ru@sunbay.com Sunbay Software AG, ru@FreeBSD.org FreeBSD committer, +380.652.512.251 Simferopol, Ukraine http://www.FreeBSD.org The Power To Serve http://www.oracle.com Enabling The Information Age >> And, logger(1) don't use syslog(3) functions, simply send a UDP packet >> to the port 514. >> >Are you sure? > >: if (host == NULL) { >: syslog(pri, "%s", buf); >: return; >: } > If -h option is specified and -p is not, then? --- SUGIMURA Takashi <sugimura@jp.FreeBSD.org> <sugimura@YasudaKei.org> >> If -h option is specified and -p is not, then? >> >You didn't mention it, do you? > I have been saying about -p option default value. -p pri Enter the message with the specified priority. The priority may be specified numerically or as a ``facility.level'' pair. For example, ``-p local3.info'' logs the message(s) as informational level in the local3 facility. The default is ``user.notice.'' --- SUGIMURA Takashi <sugimura@jp.FreeBSD.org> On Thu, Sep 06, 2001 at 09:41:00PM +0900, SUGIMURA Takashi ?$B?yB<?(B ?$B5.;N?(B wrote: > >> If -h option is specified and -p is not, then? > >> > >You didn't mention it, do you? > > > > I have been saying about -p option default value. > > -p pri Enter the message with the specified priority. The priority may > be specified numerically or as a ``facility.level'' pair. For > example, ``-p local3.info'' logs the message(s) as informational > level in the local3 facility. The default is ``user.notice.'' > The default value for -p in the local transport case was user.notice. The default value for -p in the network transport case was kern.notice. I've fixed logger.c so that in both cases it is user.notice. -- Ruslan Ermilov Oracle Developer/DBA, ru@sunbay.com Sunbay Software AG, ru@FreeBSD.org FreeBSD committer, +380.652.512.251 Simferopol, Ukraine http://www.FreeBSD.org The Power To Serve http://www.oracle.com Enabling The Information Age >> If -h option is specified and -p is not, then? >> >You didn't mention it, do you? > Oh, I read my send-pr again, "How-To-Repeat" is not right. I am sorry.. I called logger command to send syslog packet to other host, then I received it and decode original facility and priority. Would you check this again? --- SUGIMURA Takashi <sugimura@jp.FreeBSD.org> >The default value for -p in the local transport case was user.notice. >The default value for -p in the network transport case was kern.notice. >I've fixed logger.c so that in both cases it is user.notice. > Sure. Thank you very much. --- SUGIMURA Takashi <sugimura@jp.FreeBSD.org> State Changed From-To: closed->open Uhh, the default is really ``kern.notice'' with -h. State Changed From-To: open->closed Fixed in logger.c,v 1.8. |
In manpage of logger(1), -p pri Enter the message with the specified priority. The priority may be specified numerically or as a ``facility.level'' pair. For example, ``-p local3.info'' logs the message(s) as informational level in the local3 facility. The default is ``user.notice.'' but this default value is wrong. It seems ``kern.notice.'' How-To-Repeat: simply run logger such as following; % logger hogehoge getting syslog packet, it has "<5>hogehoge" sequence. 5 is 0x0000 plus 0x0101, so its facility is "kern" and its priority is "notice".