Karel Zak [Fri, 6 Mar 2015 12:17:20 +0000 (13:17 +0100)]
lib/timer: use separate file for timers
It seems that static builds require -lpthread for timer_* functions.
It's better to keep it out of our libs (e.g. libmount) to avoid
unnecessary dependence.
Karel Zak [Fri, 6 Mar 2015 11:36:17 +0000 (12:36 +0100)]
Merge branch 'logger-man-syslog-routine' of https://github.com/rgerhards/util-linux
* 'logger-man-syslog-routine' of https://github.com/rgerhards/util-linux:
logger man page: bump man page date to current
logger man page: fix some "syslog(3) routine" remnants
Karel Zak [Fri, 6 Mar 2015 11:31:48 +0000 (12:31 +0100)]
Merge branch 'logger-fix-tcp-framing' of https://github.com/rgerhards/util-linux
* 'logger-fix-tcp-framing' of https://github.com/rgerhards/util-linux:
logger: bugfix: tcp syslog framing is broken, -T unusable
logger: refactor the way output is written
Rainer Gerhards [Fri, 6 Mar 2015 11:12:15 +0000 (12:12 +0100)]
logger: bugfix: tcp syslog framing is broken, -T unusable
Logger can send via plain tcp syslog if -n -T options are given.
However, the framing is broken so that a syslog receiver can not
know where the first message ends and the next one starts. It
actually looks like no framing at all is used. Plain TCP syslog
framing is described in RFC6587.
This patch adds RFC6587 octet-stuffed framing to TCP syslog. For
local logging, this is always fine, for remote logging this is
NOT recommended by the IETF (the RFC is historic). However, a
full blown RFC5425 TLS sender seems to be out of scope for a tool
like logger IMO.
This patch also refactors the way output is written, seperating
the message format generators from the output writer.
Rainer Gerhards [Fri, 6 Mar 2015 10:51:31 +0000 (11:51 +0100)]
logger: refactor the way output is written
Previously, output was written in exactly the same way in three
different places. This is now combined into a single function. This
hopefully makes it easier to adapt to changing output needs.
Karel Zak [Fri, 6 Mar 2015 10:32:17 +0000 (11:32 +0100)]
Merge branch 'logger-kernel-regression' of https://github.com/rgerhards/util-linux
* 'logger-kernel-regression' of https://github.com/rgerhards/util-linux:
logger: fix -p kern.* priority is accepted regression
logger: messages are logged with kern.* priority by default
libblkid/src/superblocks/zfs.c: In function 'probe_zfs':
libblkid/src/superblocks/zfs.c:199:11: warning: unused variable 'swab_magic' [-Wunused-variable]
Karel Zak [Thu, 5 Mar 2015 14:34:42 +0000 (15:34 +0100)]
build-sys: remove static builds from make-check
.. temporary, the final solution has to cleanup timer_* functions
usage. The function are unnecessary for libmount, but we use
lib/monotme.c in the library and it probably requires -lrt and *also*
-lpthread for static builds.
Rainer Gerhards [Thu, 5 Mar 2015 14:20:50 +0000 (15:20 +0100)]
logger: fix invalid timestamp regression in local format
Since 1d57503378bdcd838365d625f6d2d0a09da9c29d logger no longer uses
the syslog(3) call. The way the local timestamp is generated did not
match the syslog(3) format. Most importantly, the month name is
formatted based on the user's local. For example:
$ ./logger --stderr test with logger 2.26.39-eb651-dirty
<5>Mär 5 14:17:47 logger: test with logger 2.26.39-eb651-dirty
"Mär" like in German "März" for "March".
previously:
$ logger --stderr test with logger 2.25.2
rger: test with logger 2.25.2
In the system log file, this results to the following:
Mar 5 14:17:47 host Mär 5 14:17:47 logger: test with logger 2.26.39-eb651-dirty
Mar 5 14:18:01 host rger: test with logger 2.25.2
This local naming is invalid as of RFC3164. One may argue that
the local log socket traditionally does not have RFC3164 format,
but the timestamp always was as defined in RFC3164 (and along
the lines of the ctime() call). Anything else would also be impractical,
as a syslog parser would otherwise need to know about all
potential locale-specific representations of month names.
This patch corrects the problem and also refactors the timestamp
handling a bit. The same timestamp is needed in local and rfc3164
processing, so there now is a new function to create that stamp.
Rainer Gerhards [Wed, 4 Mar 2015 10:17:20 +0000 (11:17 +0100)]
logger: fix inconsistent format regression when logging locally
The message format when writing to local sockets is inconsistent. Example:
$ ./logger --stderr test
<5>Mär 4 11:03:30 logger: test
$ ./logger -u /dev/log --stderr test
<5>1 2015-03-04T11:03:31.699841+0100 ubuntu1404esp rger - [timeQuality tzKnown="1" isSynced="1" syncAccuracy="29000"] test
The regression was introduced with 4de2e8a03859aaab2c25dc98f33409cd28de6acc
As far as the commit comments and man page indicates, this was meant to affect
remote system logging only, but it also affects local logging when the -u
option is given.
This causes problems with receivers who do not expect full-blown RFC format
on the log socket, like rsyslog. In consequence, this can also affect
log analysis programs and invalidate some of their results.
The patch corrects the behaviour so that the same old-style format is used for
any type of local logging. New-style can always be selected by command line-options.
RFC5424 is still the default for remote logging, as intended in the orignal
commit.
Result with the patch:
$ ./logger --stderr test
<5>Mär 4 11:15:35 logger: test
$ ./logger -u /dev/log --stderr test
<5>Mär 4 11:15:40 logger: test
$ ./logger -u /dev/log --rfc5424 --stderr test
<5>1 2015-03-04T11:21:28.796170+0100 ubuntu1404esp rger - [timeQuality tzKnown="1" isSynced="1" syncAccuracy="27500"] test
The file /etc/os-release takes precedence over /usr/lib/os-release.
Applications should check for the former, and exclusively use its data
if it exists, and only fall back to /usr/lib/os-release if it is
missing.
Reported-by: Dimitri John Ledkov <dimitri.j.ledkov@intel.com> Signed-off-by: Karel Zak <kzak@redhat.com>
Sami Kerola [Tue, 17 Feb 2015 21:41:46 +0000 (21:41 +0000)]
tailf: ensure file argument really is a file
The tailf(1) never worked very well with block or character devices,
sockets, fifos and such. Now after mmap() is used to find last lines
even the little command used to work for example pipes is broken, so test
the tailf is asked to follow a file and when not fail. That said
symlinks are OK, as long they point to a file.
Sami Kerola [Sun, 15 Feb 2015 17:12:03 +0000 (17:12 +0000)]
tailf: do not allow minus signed last lines argument
Before mmap() the command behavior was not completely correct, as
demonstrated below, and after the mmap() it tried to print some eighteen
quintillion lines.
Sami Kerola [Sun, 15 Feb 2015 16:52:39 +0000 (16:52 +0000)]
tailf: count last lines correctly at initial print out
When last lines happen to be greater than string buffer size for fgets()
the number of printed lines resulted to too few. To avoid miscounts due
insufficient buffer size use mmap() to map the whole file and rewind
until requested number of new lines is found.
Sami Kerola [Mon, 9 Feb 2015 23:18:09 +0000 (23:18 +0000)]
flock: improve timeout handling
Signal ALRM raised by the timer, and the timer only, will be considered
as a timeout criteria.
Secondly time interval is made to use monotonic clock. Documentation of
ITIMER_REAL is unclear whether that time is affected various sources of
clock skew, or does it even tick when system is suspended.
Reviewed-by: Karel Zak <kzak@redhat.com> Signed-off-by: Sami Kerola <kerolasa@iki.fi>
Sami Kerola [Sat, 7 Feb 2015 23:45:24 +0000 (23:45 +0000)]
flock: add --verbose option
Jenkins script jobs using flock are a great example of a situation in
which one may want an automation to be verbose, so that when unexpected
events happen there is more hints in logs.
Reviewed-by: Benno Schulenberg <bensberg@justemail.net> Signed-off-by: Sami Kerola <kerolasa@iki.fi>
Karel Zak [Tue, 3 Mar 2015 10:36:59 +0000 (11:36 +0100)]
build-sys: add --enable-usrdir-path
The directories /{sbin,bin} are symliks to /usr/{sbin,bin} on many
systems. This patch add new ./configure option to remove the non-usr
paths from the default $PATH environment variable.
The default $PATH is hardcoded in login(1) and can be overwritten
by /etc/login.defs.
Peter Cordes [Wed, 25 Feb 2015 02:40:41 +0000 (22:40 -0400)]
docs: fstab(5) grammar / English fixes, and some other updates
I proofread the whole thing. I fixed everything that I thought could use
improvement.
various grammar and man page style-guide fixes (commas, word order, etc.).
Reworded a couple things to hopefully make it clear to someone that
didn't already know about fstab. Re-ordered the intro paragraphs
for easier skimming. And added an example line.
Expanded on a couple things other things.
Tightened up the wording in some other places to get the point across
faster and in less space.
Thanks to Benno Schulenberg <bensberg@justemail.net>
for several improvements.
Karel Zak [Fri, 27 Feb 2015 12:57:34 +0000 (13:57 +0100)]
lib/colors: use libtinfo to check terminal capability
The current implementation assumes that all terminals supports colors
and users are forcet to use terminal-colors.d/ to disable colors for
some terminals.
This patch checks for maximal supported colors for the current
terminal and colors are automatically disabled for terminals like
vt100.
The patch moves lib/colors.c from libcommon.la to libtcolors.la to
avoid collisions with another utils.
Karel Zak [Wed, 25 Feb 2015 09:06:40 +0000 (10:06 +0100)]
build-sys: add --disable-colors-default
The current util-linux is to have enabled colorized outputs by
default, this default behavior is possible to change by new configure
option --disable-colors-default.
The lp.h included earlier in the tunelp.c has the definitions that were
checked, so these statements could have not been false and such
impossible conditions does not need to be checked.
* cleanup function and variable names (s/vals/values/)
* in "safe probe" mode libblkid copies probing result from the first
attempt, this is unnecessary, with values list we can just move
values to another list rather than copy all.
* add new debug messages
Ondrej Oprala [Tue, 3 Feb 2015 15:30:15 +0000 (16:30 +0100)]
libblkid: make probing data structures more dynamic
* replace static probing result array with list
* use allocated buffers for probing result variables
[kzak@redhat.com: - rename some functions
- clean up \0 terminator usage in variables
- remove never used code to convert UUID to lower-case
- remove possible memory leaks on errors]
Signed-off-by: Ondrej Oprala <ooprala@redhat.com> Signed-off-by: Karel Zak <kzak@redhat.com>
Karel Zak [Mon, 16 Feb 2015 11:49:49 +0000 (12:49 +0100)]
libmount: add --enable-libmount-force-mountinfo
The default libmount mtab management depends on mtan symlink. If the
symlink exists than libmount parses /proc/self/mountinfo, otherwise it
parses regular classic /etc/mtab. This is backwardly compatible and
transparent solution.
Unfortunately, this is not robust enough because some broken init
scripts or 3-party mount helpers may remove the symlink and create
regular mtab file. This is pretty bad if initd (systemd) depends on
libmount.
Fortunately we known that mtab is absolutely unwanted on some distros,
so it's fine too ignore mtab at all and don't care about the symlink.
Reported-by: Martin Pitt <martin.pitt@ubuntu.com> Signed-off-by: Karel Zak <kzak@redhat.com>
Sami Kerola [Sun, 15 Feb 2015 09:50:23 +0000 (09:50 +0000)]
logger: add --socket-errors compatibility option
Hello,
Depending viewpoint this change is either regression fix, or
re-regression in context of none-systemd init. I ack the change is sent
very late to be part of v2.26, but then again the excess noise was found
only because of -rc1 was tested in sysvinit environment. IMHO it would
contradict purpose of having rc's if faults will not lead to fixes.
I also want to point out the sysvinit scripts are broken, not the
logger(1), but getting them corrected is practically impossible.
Assuming sysvinit script are further developed by various teams and
distributions who maintain them they should use --socket-error=on in
future, and write scripts that pass without noise. Meanwhile trying to
be clever when to silence errors seems like a reasonable thing to do.
--->8----
From: Sami Kerola <kerolasa@iki.fi>
Date: Sat, 14 Feb 2015 19:05:55 +0000
Subject: [PATCH] logger: add --socket-errors compatibility option
Now when logger(1) has stopped using openlog() for Unix sockets, in
commit mentioned in reference, the lack of /dev/log detected will report
error accordingly. According to Gabriele Balducci this makes sysvinit
style boot scripts to print a lot of errors. So make the logger to
detect whether it should be in compatibility mode, and not report errors
if logging device is missing. That imitates behavior of glibc openlog().
To allow full control to users the /dev/log error messages can be forced
to on or off. The automatic error messaging is explained in manual page.
Sami Kerola [Sun, 8 Feb 2015 20:44:40 +0000 (20:44 +0000)]
rename: use strrchr() instead of rindex()
The rindex() is marked legacy in POSIX.1-2001, and apparently Androids
bionic libc does not even have it so it is best not to use the legacy
interface.
Reference: https://lists.gnu.org/archive/html/weechat-dev/2014-02/msg00004.html Signed-off-by: Sami Kerola <kerolasa@iki.fi>