1 [[!meta title="Janovec Jiří"]]
4 **Project name and homepage:** [Busybox](http://busybox.net)
9 [Bug #8626](https://bugs.busybox.net/show_bug.cgi?id=8626):
10 Add support -i option to command logger in busybox to log PID.
12 (This can be done using [syslog man pages](http://linux.die.net/man/3/syslog). )
23 Links documenting the results of my work
26 Here, I'll add links similar to the examples below and describe what
29 * [[Example] My communication with developers in a public mailing list archive](http://groups.google.com/group/comp.os.minix/browse_thread/thread/e3df794a2bce97da/2194d253268b0a1b?#2194d253268b0a1b)
30 * [[Example] Version control repository with the actual state of my work](http://git.kernel.org/?p=linux/kernel/git/torvalds/linux-2.6.git;a=summary)
31 * [[Example] My commit in the project repository](http://git.kernel.org/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=ea90002b0fa7bdee86ec22eba1d951f30bf043a6)
32 * [[Example] Additional supporting material](http://lwn.net/Articles/385586/)
37 * [[Presentation of the aim of my work in PDF or OpenDocument format (upload it as an *Attachment* to this page)|prezentace1.pdf]]
38 * [[Presentation of the results of my work|prezentace2.pdf]]
43 Here, I'll fill in the HTML code of the [OpenHub widget][w] showing my KudoRank.
46 <a href='https://www.openhub.net/accounts/9897?ref=Detailed' target='_blank'>
47 <img alt='Ohloh profile for wentasah' border='0' height='35' src='https://www.openhub.net/accounts/9897/widgets/account_detailed.gif' width='230' />
50 [w]:https://www.openhub.net/accounts/janovji3/widgets
56 - 8.3. 2016, 10.h , busybox found, browsing bugzilla
57 - 8.3. 2016, 12-15.h, making patch
58 - 10.3. 2016, 10:34:00 consultations on RM35OSP
59 - 10.3. 2016, 12:52:29 CET , mailto:busybox@busybox.net, Předmět: [PATCH] - Bugfix #8626, adds "option -i" to "lo...
60 (I don't know where to find link yet.)
65 diff --git a/sysklogd/logger.c b/sysklogd/logger.c
66 index b3ca857..58f9374 100644
67 --- a/sysklogd/logger.c
68 +++ b/sysklogd/logger.c
69 @@ -103,10 +103,12 @@ int logger_main(int argc UNUSED_PARAM, char **argv)
70 str_t = uid2uname_utoa(geteuid());
72 /* Parse any options */
73 - opt = getopt32(argv, "p:st:", &str_p, &str_t);
74 + opt = getopt32(argv, "p:st:i", &str_p, &str_t);
76 if (opt & 0x2) /* -s */
78 + if (opt & 0x8) /* -i */
80 //if (opt & 0x4) /* -t */
82 i = LOG_USER | LOG_NOTICE;
87 diff --git a/sysklogd/logger.c b/sysklogd/logger.c
88 index b3ca857..25b82cc 100644
89 --- a/sysklogd/logger.c
90 +++ b/sysklogd/logger.c
92 //config: messages to the system log (i.e. the 'syslogd' utility) so
93 //config: they can be logged. This is generally used to help locate
94 //config: problems that occur within programs and scripts.
96 +//config:config FEATURE_LOG_PID
97 +//config: bool "Log PID of logger"
99 +//config: depends on LOGGER
101 +//config: This enables logger to log process id (PID).
103 //applet:IF_LOGGER(APPLET(logger, BB_DIR_USR_BIN, BB_SUID_DROP))
106 //usage: "[OPTIONS] [MESSAGE]"
107 //usage:#define logger_full_usage "\n\n"
108 //usage: "Write MESSAGE (or stdin) to syslog\n"
109 +//usage: IF_FEATURE_LOG_PID(
110 +//usage: "\n -i Log the process ID too"
112 //usage: "\n -s Log to stderr as well as the system log"
113 //usage: "\n -t TAG Log using the specified tag (defaults to user name)"
114 //usage: "\n -p PRIO Priority (numeric or facility.level pair)"
121 + OPTBIT_priority = 0, // -p
122 + OPTBIT_stderr, // -s
124 + IF_FEATURE_LOG_PID(OPTBIT_pid ,) // -i
126 + OPT_priority = 1 << OPTBIT_priority ,
127 + OPT_stderr = 1 << OPTBIT_stderr ,
128 + OPT_tag = 1 << OPTBIT_tag ,
129 + OPT_pid = IF_FEATURE_LOG_PID((1 << OPTBIT_pid )) + 0,
131 +#define OPTION_STR "p:st:" \
132 + IF_FEATURE_LOG_PID("i:" )
133 +#define OPTION_DECL *str_p, *str_t
134 +#define OPTION_PARAM &str_p, &str_t
136 /* Decode a symbolic name to a numeric value
137 * this function is based on code
138 * Copyright (c) 1983, 1993
139 @@ -95,7 +122,7 @@ static int pencode(char *s)
140 int logger_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
141 int logger_main(int argc UNUSED_PARAM, char **argv)
143 - char *str_p, *str_t;
148 @@ -103,14 +130,19 @@ int logger_main(int argc UNUSED_PARAM, char **argv)
149 str_t = uid2uname_utoa(geteuid());
151 /* Parse any options */
152 - opt = getopt32(argv, "p:st:", &str_p, &str_t);
153 + opt = getopt32(argv, OPTION_STR, OPTION_PARAM);
154 +getopt32(argv, "p:st:i", &str_p, &str_t);
156 - if (opt & 0x2) /* -s */
157 + if (opt & OPT_stderr) /* -s */
159 - //if (opt & 0x4) /* -t */
160 +#if ENABLE_FEATURE_LOG_PID
161 + if (opt & OPT_pid) /* -i */
164 + //if (opt & OPT_tag) /* -t */
165 openlog(str_t, i, 0);
166 i = LOG_USER | LOG_NOTICE;
167 - if (opt & 0x1) /* -p */
168 + if (opt & OPT_priority) /* -p */