]> rtime.felk.cvut.cz Git - edu/osp-wiki.git/blob - student/janovji3/index.mdwn
(no commit message)
[edu/osp-wiki.git] / student / janovji3 / index.mdwn
1 [[!meta title="Janovec Jiří"]]
2
3
4 **Project name and homepage:** [Busybox](http://busybox.net)
5
6 Assignment
7 ======
8
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.
11
12 (This can be done using [syslog man pages](http://linux.die.net/man/3/syslog). )
13
14
15 Links documenting the results of my work
16 ======
17
18 * [My communication with developers in a public mailing list archive](http://lists.busybox.net/pipermail/busybox/2016-March/083956.html)
19 * [Bugzilla attachment 1](https://bugs.busybox.net/attachment.cgi?id=6391&action=diff)
20 * [Bugzilla attachment 2](https://bugs.busybox.net/attachment.cgi?id=6396&action=diff)
21
22
23 Presentation
24 ==========
25
26 * [[Presentation of the aim of my work in PDF |OSPprvni.pdf]]
27
28
29 ----------
30
31
32 <!---
33
34  not completed yet
35
36
37 * [[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)
38 * [[Example] My commit in the project repository](http://git.kernel.org/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=ea90002b0fa7bdee86ec22eba1d951f30bf043a6)
39 * [[Example] Additional supporting material](http://lwn.net/Articles/385586/)
40
41 Presentation
42 ==========
43
44 * [[Presentation of the aim of my work in PDF or OpenDocument format (upload it as an *Attachment* to this page)|prezentace1.pdf]]
45 * [[Presentation of the results of my work|prezentace2.pdf]]
46
47 OpenHub
48 =======
49
50 Here, I'll fill in the HTML code of the [OpenHub widget][w] showing my KudoRank.
51
52 For example:
53 <a href='https://www.openhub.net/accounts/9897?ref=Detailed' target='_blank'>
54 <img alt='Ohloh profile for wentasah' border='0' height='35' src='https://www.openhub.net/accounts/9897/widgets/account_detailed.gif' width='230' />
55 </a>
56
57 [w]:https://www.openhub.net/accounts/janovji3/widgets
58
59 --->
60
61 Notes
62 ========
63   -   8.3. 2016, 10.h , busybox found, browsing bugzilla
64   -   8.3. 2016, 12-15.h, making patch
65   - 10.3. 2016, 10:34:00 consultations on RM35OSP
66   - 10.3. 2016, 12:52:29 CET , mailto:busybox@busybox.net, Subject: [PATCH] - Bugfix #8626, adds "option -i" to "lo... 
67     (I don't know where to find link yet.)
68   - waiting to response 
69   - 19.3. 2016 17:53:09 Patch upload to bugzilla (automatic send email to some emails)
70
71   - proč se sakra na bugzille zobrazuje diff proti minulému attachmentu a ne proti hlavní větvi ???
72
73 Small version:
74    <pre>
75 diff --git a/sysklogd/logger.c b/sysklogd/logger.c
76 index b3ca857..58f9374 100644
77 --- a/sysklogd/logger.c
78 +++ b/sysklogd/logger.c
79 @@ -103,10 +103,12 @@ int logger_main(int argc UNUSED_PARAM, char **argv)
80         str_t = uid2uname_utoa(geteuid());
81  
82         /* Parse any options */
83 -       opt = getopt32(argv, "p:st:", &str_p, &str_t);
84 +       opt = getopt32(argv, "p:st:i", &str_p, &str_t);
85  
86         if (opt & 0x2) /* -s */
87                 i |= LOG_PERROR;
88 +       if (opt & 0x8) /* -i */
89 +               i |= LOG_PID;
90         //if (opt & 0x4) /* -t */
91         openlog(str_t, i, 0);
92         i = LOG_USER | LOG_NOTICE;
93    </pre>
94
95 Full version:
96    <pre>
97 diff --git a/sysklogd/logger.c b/sysklogd/logger.c
98 index b3ca857..25b82cc 100644
99 --- a/sysklogd/logger.c
100 +++ b/sysklogd/logger.c
101 @@ -15,6 +15,13 @@
102  //config:          messages to the system log (i.e. the 'syslogd' utility) so
103  //config:          they can be logged. This is generally used to help locate
104  //config:          problems that occur within programs and scripts.
105 +//config:
106 +//config:config FEATURE_LOG_PID
107 +//config:       bool "Log PID of logger"
108 +//config:       default n
109 +//config:       depends on LOGGER
110 +//config:       help
111 +//config:         This enables logger to log process id (PID).
112  
113  //applet:IF_LOGGER(APPLET(logger, BB_DIR_USR_BIN, BB_SUID_DROP))
114  
115 @@ -24,6 +31,9 @@
116  //usage:       "[OPTIONS] [MESSAGE]"
117  //usage:#define logger_full_usage "\n\n"
118  //usage:       "Write MESSAGE (or stdin) to syslog\n"
119 +//usage:        IF_FEATURE_LOG_PID(
120 +//usage:     "\n       -i      Log the process ID too"
121 +//usage:        )
122  //usage:     "\n       -s      Log to stderr as well as the system log"
123  //usage:     "\n       -t TAG  Log using the specified tag (defaults to user name)"
124  //usage:     "\n       -p PRIO Priority (numeric or facility.level pair)"
125 @@ -39,6 +49,23 @@
126  #include <syslog.h>
127  */
128  
129 +/* Options */
130 +enum {
131 +        OPTBIT_priority = 0, // -p
132 +        OPTBIT_stderr, // -s
133 +        OPTBIT_tag, // -t
134 +        IF_FEATURE_LOG_PID(OPTBIT_pid   ,)  // -i
135 +
136 +        OPT_priority    = 1 << OPTBIT_priority   ,
137 +        OPT_stderr      = 1 << OPTBIT_stderr     ,
138 +        OPT_tag         = 1 << OPTBIT_tag        ,
139 +        OPT_pid         = IF_FEATURE_LOG_PID((1 << OPTBIT_pid   )) + 0,
140 +};
141 +#define OPTION_STR "p:st:" \
142 +        IF_FEATURE_LOG_PID("i:" )
143 +#define OPTION_DECL *str_p, *str_t
144 +#define OPTION_PARAM &str_p, &str_t
145 +
146  /* Decode a symbolic name to a numeric value
147   * this function is based on code
148   * Copyright (c) 1983, 1993
149 @@ -95,7 +122,7 @@ static int pencode(char *s)
150  int logger_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
151  int logger_main(int argc UNUSED_PARAM, char **argv)
152  {
153 -       char *str_p, *str_t;
154 +       char OPTION_DECL;
155         int opt;
156         int i = 0;
157  
158 @@ -103,14 +130,19 @@ int logger_main(int argc UNUSED_PARAM, char **argv)
159         str_t = uid2uname_utoa(geteuid());
160  
161         /* Parse any options */
162 -       opt = getopt32(argv, "p:st:", &str_p, &str_t);
163 +       opt = getopt32(argv, OPTION_STR, OPTION_PARAM);
164 +getopt32(argv, "p:st:i", &str_p, &str_t);
165  
166 -       if (opt & 0x2) /* -s */
167 +       if (opt & OPT_stderr) /* -s */
168                 i |= LOG_PERROR;
169 -       //if (opt & 0x4) /* -t */
170 +#if ENABLE_FEATURE_LOG_PID
171 +       if (opt & OPT_pid) /* -i */
172 +               i |= LOG_PID;
173 +#endif
174 +       //if (opt & OPT_tag) /* -t */
175         openlog(str_t, i, 0);
176         i = LOG_USER | LOG_NOTICE;
177 -       if (opt & 0x1) /* -p */
178 +       if (opt & OPT_priority) /* -p */
179                 i = pencode(str_p);
180  
181         argv += optind;
182    </pre>