Commit Graph

238 Commits

Author SHA1 Message Date
Denys Vlasenko
237bedd499 getopt32: add new syntax of 'o:+' and 'o:*' for -o NUM and -o LIST
In many cases, this aqllows to drop use of opt_complementary.
Approximately -400 bytes:

function                                             old     new   delta
getopt32                                            1423    1502     +79
opt_string                                            17      18      +1
OPT_STR                                               24      25      +1
uniq_main                                            416     406     -10
timeout_main                                         279     269     -10
sulogin_main                                         270     260     -10
readprofile_main                                    1825    1815     -10
ps_main                                              543     533     -10
pidof_main                                           245     235     -10
pgrep_main                                           611     601     -10
od_main                                             2600    2590     -10
mkfs_minix_main                                     2684    2674     -10
mkfs_ext2_main                                      2603    2593     -10
microcom_main                                        712     702     -10
makemime_main                                        315     305     -10
ionice_main                                          282     272     -10
inetd_main                                          2074    2064     -10
ifplugd_main                                        1144    1134     -10
halt_main                                            353     343     -10
getopt_main                                          636     626     -10
fdisk_main                                          2854    2844     -10
env_main                                             206     196     -10
dmesg_main                                           319     309     -10
conspy_main                                         1214    1204     -10
awk_main                                             981     971     -10
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 3/22 up/down: 81/-220)         Total: -139 bytes
   text	   data	    bss	    dec	    hex	filename
 919373	    906	  14060	 934339	  e41c3	busybox_old
 918969	    906	  14060	 933935	  e402f	busybox_unstripped

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-07-06 21:58:02 +02:00
Mike Frysinger
ea1b44412a syslogd: minor tweaks to text
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
2016-04-04 01:28:32 -04:00
Denys Vlasenko
accd9eeb71 remove systemd support
systemd people are not willing to play nice with the rest of the world.
Therefore there is no reason for the rest of the world to cooperate with them.

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2015-10-22 16:01:57 +02:00
Denys Vlasenko
d34f300db6 sysklogd/*: convert to new-style "one file" applets
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2015-10-18 22:40:09 +02:00
Maninder Singh
97f2f7ca7f Removes stray empty line from code
This patch removes stray empty line from busybox code
reported by script find_stray_empty_lines

Signed-off-by: Maninder Singh <maninder1.s@samsung.com>
Signed-off-by: Akhilesh Kumar <akhilesh.k@samsung.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2015-07-13 03:25:46 +02:00
Joshua Judson Rosen
ae57fcad5d syslogd: make "reopen log file every second" logic work for multiple logs
Move last_log_time from a single global to *each logFile_t*
so that we can actually apply the logic to every log-file
in multi-file configurations, rather than working only
for the first file written in each 1-second interval
and then leaving the others connected to possibly wrong files.

Signed-off-by: Joshua Judson Rosen <jrosen@harvestai.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2014-07-03 14:51:47 +02:00
Joshua Judson Rosen
e46047aa87 syslogd: syslogd: don't *decrement* log_file->size on write failures
Even if we fail to write to a log-file, and it's not growing,
it's not *shrinking* either....

Signed-off-by: Joshua Judson Rosen <jrosen@harvestai.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2014-07-02 19:41:41 +02:00
Denys Vlasenko
a28c1b21e1 syslogd: make "-O -" log to stdout
function                                             old     new   delta
packed_usage                                       29871   29908     +37
log_locally                                          404     440     +36
syslogd_main                                        1966    1956     -10
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 2/1 up/down: 73/-10)             Total: 63 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2014-07-02 15:21:30 +02:00
Joshua Judson Rosen
9aa6ffb22b syslogd: Unify unlink/truncate + unlock log-rotation logic
Always unlink + reopen, rather than sometimes using ftruncate();
using a single code-path reduces the opportunity for either
mistakes or duplicate code.

Signed-off-by: Joshua Judson Rosen <jrosen@harvestai.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2014-06-02 03:11:40 +02:00
Joshua Judson Rosen
b905d6c2ea syslogd: remember to un-writelock log-files even when called with "-b 0"
Signed-off-by: Joshua Judson Rosen <jrosen@harvestai.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2014-06-02 03:11:39 +02:00
Joshua Judson Rosen
1b90e031c3 syslogd: avoid spurious ftrunctate() calls for "-b 0"
Forgetting to re-set log_file->size after truncating to zero
discards log-data for the next 1 second following an oversize-induced purge,
when we shouldn't necessarily throw that data away.

Signed-off-by: Joshua Judson Rosen <jrosen@harvestai.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2014-06-02 03:11:38 +02:00
Cédric Cabessa
adc30b4cf9 syslogd: use _PATH_LOG when available
Signed-off-by: Cédric Cabessa <ccabessa@genymobile.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2013-08-05 02:09:16 +02:00
Denys Vlasenko
257a77568a sysklogd: trim help text
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2013-03-15 01:50:35 +01:00
Denys Vlasenko
81fa999540 syslogd: do not segfault on parse error when using default config. Closes 5762
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2013-01-20 16:05:41 +01:00
Peter Korsgaard
9980707efc syslogd: convert dummy functions to statics and get rid of IF_FEATURE_* checks
As suggested by Mike. No bloat-o-meter difference, but a bit nicer to look at.
We cannot convert the call to log_to_shmem() as it checks for G.shbuf outside
the function, and G.shbuf is only available when IPC support is enabled.

Signed-off-by: Peter Korsgaard <jacmet@sunsite.dk>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2013-01-18 19:46:47 +01:00
Denys Vlasenko
6967578728 whitespace fixes. no code changes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2013-01-14 01:34:48 +01:00
Peter Korsgaard
cd776cf967 syslogd: add option to log to Linux kernel printk buffer
Why invent our own shared memory circular buffer when the kernel has a
perfectly fine one already?

This can be used as a smaller/simpler alternative to the syslogd IPC support
(as IPC shmem/klogd/logread aren't needed), while also allowing centralised
logging of everything (kernel messages, userspace bootup and syslog)
when used together with ttyprintk.

Notice that kernel 3.5+ is needed to store syslog facility in printk buffer,
otherwise only the priority is stored.

bloat-o-meter compared to IPC+klogd+logread:
function                                             old     new   delta
get_linux_version_code                                 -      84     +84
lbb_prepare                                           25      90     +65
applet_nameofs                                         6       -      -6
static.stdout@@GLIBC_2                                 8       -      -8
applet_names                                          23       9     -14
bb_msg_standard_output                                16       -     -16
init_sem                                              18       -     -18
xatoull_range                                         19       -     -19
overlapping_strcpy                                    21       -     -21
init_data                                             56      32     -24
applet_main                                           24       -     -24
main                                                 124      99     -25
full_write2_str                                       26       -     -26
error_exit                                            26       -     -26
bb_basename                                           30       -     -30
sem_up                                                32       -     -32
interrupted                                           35       -     -35
fflush_stdout_and_exit                                38       -     -38
bb_banner                                             46       -     -46
find_applet_by_name                                   59       -     -59
bb_signals_recursive_norestart                        90       -     -90
run_applet_no_and_exit                               104       -    -104
timestamp_and_log                                    651     523    -128
syslogd_main                                         798     581    -217
xstrtoull_range_sfx                                  267       -    -267
run_applet_and_exit                                  432       -    -432
klogd_main                                           490       -    -490
logread_main                                         508       -    -508
.rodata                                             1870     937    -933
bb_common_bufsiz1                                   8193       -   -8193
------------------------------------------------------------------------------
(add/remove: 2/26 grow/shrink: 1/6 up/down: 149/-11829)    Total: -11680 bytes

Signed-off-by: Peter Korsgaard <jacmet@sunsite.dk>
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
2013-01-06 13:30:50 -05:00
Anthony G. Basile
12677acf0a CONFIG_PID_FILE_PATH: new configuration option for pidfile paths
We set a default path for the directory where pidfiles are create
when FEATURE_PIDFILE is selected.  The default has no effect on
applets which must specify a pidfile path on the command line to
run, and it can be overridden by applets which optionally allow
the user to specify the pidfile path.

We also add pidfile write/remove support for klogd, ntpd and watchdog.
For syslogd, we add a missing remove_pidfile() for better cleanup
on daemon exit.

Signed-off-by: Anthony G. Basile <blueness@gentoo.org>
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
2012-12-19 15:53:33 -05:00
Christian Engelmayer
8de2e42201 syslogd: work around rename() not renaming hardlinks to themselves
Function log_locally() within the syslogd can potentially lock up when
restarting the daemon after a power loss in case the unplanned shutdown hit the
rename operation during logfile rotation.

While POSIX requires the rename operation to be atomic, many file systems such
as JFFS2 implement the rename operation in 2 steps by linking the new name
followed by unlinking the original name. In case of a power loss during the
rename the system can end up with /var/log/messages and /var/log/messages.0
being 2 hard links to the same file.

When the syslog daemon restarts in such a situation it will rediscover the need
to rotate the log files, however, POSIX also requires that rename does nothing
and reports success in case oldpath and newpath are existing hard links to the
same file. Looping through reopen: by (O_CREAT | O_APPEND), the daemon
eternally reopens the same file without succeeding to rotate.

Signed-off-by: Christian Engelmayer <christian.engelmayer@frequentis.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2011-10-28 18:12:42 +02:00
Denys Vlasenko
514cbfc593 syslogd: fix missing newline problen in memory log buffer. Closes 4159
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2011-09-16 13:28:52 +02:00
Denys Vlasenko
66426760be *: remove "Options:" string from help texts
function                                             old     new   delta
packed_usage                                       28706   28623     -83

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2011-06-05 03:58:28 +02:00
Denys Vlasenko
aeab42e3f4 syslogd,klogd: better help text
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2011-05-25 11:58:56 +02:00
Denys Vlasenko
0288b27ad8 small fixes atop syslog config patch
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2011-04-16 20:15:14 +02:00
Sergey Naumov
e9c8bed4d3 syslogd: small fix to config patch
Signed-off-by: Sergey Naumov <sknaumov@gmail.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2011-04-16 19:36:15 +02:00
Pere Orga
5bc8c005a8 move remaining help text from include/usage.src.h
Signed-off-by: Pere Orga <gotrunks@gmail.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2011-04-11 03:29:49 +02:00
Sergey Naumov
73ef15cf38 syslogd: optional support for /etc/syslog.conf
function                                             old     new   delta
syslogd_main                                        1241    1870    +629
timestamp_and_log                                    301     540    +239
find_by_name                                           -      37     +37
find_by_val                                            -      22     +22
init_data                                             64      68      +4
log_locally                                          603     413    -190
------------------------------------------------------------------------------
(add/remove: 2/0 grow/shrink: 3/1 up/down: 931/-190)          Total: 741 bytes

Signed-off-by: Sergey Naumov <sknaumov@gmail.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2011-04-10 07:34:27 +02:00
Davide Cavalca
9b3b9790b3 add ENABLE_FEATURE_SYSTEMD and use it in syslogd
Signed-off-by: Davide Cavalca <davide@geexbox.org>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2011-01-25 02:26:03 +01:00
Denys Vlasenko
0ef64bdb40 *: make GNU licensing statement forms more regular
This change retains "or later" state! No licensing _changes_ here,
only form is adjusted (article, space between "GPL" and "v2" and so on).

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2010-08-16 20:14:46 +02:00
Daniel Dickinson
e74d79866c syslogd: close/re-resolve/reopen remote sockets on some sendto() errors
function                                             old     new   delta
syslogd_main                                        1201    1262     +61

Signed-off-by: Daniel Dickinson <cshore@csolve.net>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2010-08-03 04:26:20 +02:00
Janne Kiviluoto
c897dfe011 syslogd: make maximum message length configurable
Signed-off-by: Janne Kiviluoto <janne.kiviluoto@bluegiga.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2010-03-31 15:58:58 +02:00
Thomas Geulig
d2f7779671 syslog: allow multiple -R options
function                                             old     new   delta
syslogd_main                                        1082    1177     +95
init_data                                             72      64      -8

Signed-off-by: Thomas Geulig <geulig@nentec.de>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2010-02-28 13:01:59 +01:00
Denys Vlasenko
a42524251e syslog: remove stray umask(0)
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2010-01-29 16:44:48 +01:00
Denys Vlasenko
606291beab *: more portability fixes by Dan Fandrich
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-09-23 23:15:43 +02:00
Denis Vlasenko
574c316e5a syslogd: added comment, no code changes 2009-04-22 02:53:02 +00:00
Denis Vlasenko
5e34ff29bc *: mass renaming of USE_XXXX to IF_XXXX
and SKIP_XXXX to IF_NOT_XXXX - the second one was especially
badly named. It was not skipping anything!
2009-04-21 11:09:40 +00:00
Denis Vlasenko
d9415d6335 syslogd: create logfile with 0666, not 0600. 2009-03-02 14:26:28 +00:00
Denis Vlasenko
0d94820adf syslogd: comment out file locking;
make signal handling syncronous (old was racy)

function                                             old     new   delta
syslogd_main                                         963    1090    +127
quit_signal                                           96       -     -96
log_locally                                          743     595    -148
------------------------------------------------------------------------------
(add/remove: 0/1 grow/shrink: 1/1 up/down: 127/-244)         Total: -117 bytes
2008-12-09 22:53:31 +00:00
Denis Vlasenko
9504e444b8 whitespace fixes, no code changes 2008-10-29 01:19:15 +00:00
Denis Vlasenko
a60f84ebf0 *: rename ATTRIBUTE_XXX to just XXX. 2008-07-05 09:18:54 +00:00
Denis Vlasenko
bd1aeeb850 logger: "clean up" a dirty hack a bit 2008-06-11 15:43:19 +00:00
Denis Vlasenko
69dc325397 syslogd: do not error out on missing files to rotate. closes bug 3404. 2008-05-24 21:03:53 +00:00
Denis Vlasenko
6b06cb80be more of -Wall fixes from Cristian Ionescu-Idbohrn.
Some are fixing real bugs.

function                                             old     new   delta
syslogd_main                                         938     958     +20
get_signum                                           136     143      +7
obj_load                                             777     782      +5
recv_from_to                                         210     214      +4
get_next_block                                      1795    1799      +4
display_topmem_process_list                         1117    1121      +4
logread_main                                         484     487      +3
buffer_fill_and_print                                 73      76      +3
kill_main                                            687     689      +2
ll_remember_index                                    240     241      +1
do_stats                                             452     453      +1
if_readconf                                          166     165      -1
display_process_list                                1192    1191      -1
run_applet_and_exit                                  507     505      -2
print_signames                                        33      31      -2
parse_one_line                                      1092    1090      -2
find_out_spec                                         57      55      -2
add_ksymoops_symbols                                 421     419      -2
ash_main                                            1407    1402      -5
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 11/8 up/down: 54/-17)            Total: 37 bytes
2008-05-15 21:30:45 +00:00
Denis Vlasenko
68404f13d4 *: add -Wunused-parameter; fix resulting breakage
function                                             old     new   delta
procps_scan                                         1265    1298     +33
aliascmd                                             278     283      +5
parse_file_cmd                                       116     120      +4
dname_enc                                            373     377      +4
setcmd                                                90      93      +3
execcmd                                               57      60      +3
count_lines                                           72      74      +2
process_command_subs                                 340     339      -1
test_main                                            409     407      -2
mknod_main                                           179     177      -2
handle_incoming_and_exit                            2653    2651      -2
argstr                                              1312    1310      -2
shiftcmd                                             131     128      -3
exitcmd                                               46      43      -3
dotcmd                                               297     294      -3
breakcmd                                              86      83      -3
evalpipe                                             353     349      -4
evalcommand                                         1180    1176      -4
evalcmd                                              109     105      -4
send_tree                                            374     369      -5
mkfifo_main                                           82      77      -5
evalsubshell                                         152     147      -5
typecmd                                               75      69      -6
letcmd                                                61      55      -6
add_cmd                                             1190    1183      -7
main                                                 891     883      -8
ash_main                                            1415    1407      -8
parse_stream                                        1377    1367     -10
alloc_procps_scan                                     55       -     -55
------------------------------------------------------------------------------
(add/remove: 0/1 grow/shrink: 7/21 up/down: 54/-148)          Total: -94 bytes
   text    data     bss     dec     hex filename
 797195     658    7428  805281   c49a1 busybox_old
 797101     658    7428  805187   c4943 busybox_unstripped
2008-03-17 09:00:54 +00:00
Denis Vlasenko
574f2f4394 *: add optimization barrier to all "G trick" locations 2008-02-27 18:41:59 +00:00
Denis Vlasenko
be048f21e6 syslogd: optional support for dropping dups. closes bug 436. 2008-02-26 20:13:52 +00:00
Denis Vlasenko
6f1713f216 *: intrduce and use safe_gethostname. By Tito <farmatito AT tiscali.it>
safe_gethostname                                       -      48     +48
glob3                                                 35      37      +2
timestamp_and_log                                    314     315      +1
udhcp_send_kernel_packet                             234     231      -3
scan_tree                                            275     271      -4
passwd_main                                         1074    1070      -4
print_login_prompt                                    68      58     -10
obscure                                              392     377     -15
syslogd_main                                         882     866     -16
print_login_issue                                    516     478     -38
hostname_main                                        278     223     -55
parse_and_put_prompt                                 825     756     -69
------------------------------------------------------------------------------
(add/remove: 1/0 grow/shrink: 2/9 up/down: 51/-214)          Total: -163 bytes
   text    data     bss     dec     hex filename
 798791     728    7484  807003   c505b busybox_old
 798631     728    7484  806843   c4fbb busybox_unstripped
2008-02-25 23:23:58 +00:00
Denis Vlasenko
400d8bb45e less,klogd,syslogd,nc,tcpudp: exit on signal by killing itself, not exit(1)
*: minor shrink
2008-02-24 13:36:01 +00:00
Denis Vlasenko
a7259b64e8 syslogd: small shrink 2008-02-23 12:08:36 +00:00
Denis Vlasenko
84da0bf475 udhcp: make paths configurable
syslogd: trivial build fix
2008-02-20 22:29:52 +00:00
Denis Vlasenko
92657d484f syslogd: tighten up hostname handling. 2008-02-19 01:10:20 +00:00