]> git.ipfire.org Git - thirdparty/util-linux.git/log
thirdparty/util-linux.git
10 years agotests: add sfdisk resize tests
Karel Zak [Mon, 13 Apr 2015 08:56:03 +0000 (10:56 +0200)] 
tests: add sfdisk resize tests

Signed-off-by: Karel Zak <kzak@redhat.com>
10 years agotests: require wipefs for sfdisk/gpt
Karel Zak [Mon, 13 Apr 2015 08:35:51 +0000 (10:35 +0200)] 
tests: require wipefs for sfdisk/gpt

Signed-off-by: Karel Zak <kzak@redhat.com>
10 years agolibfdisk: (dos) retain existing boot flag when resizing a partition
Karel Zak [Mon, 13 Apr 2015 08:29:00 +0000 (10:29 +0200)] 
libfdisk: (dos)  retain existing boot flag when resizing a partition

Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=1210912
Signed-off-by: Karel Zak <kzak@redhat.com>
Co-Author:  awilliam@redhat.com

10 years agotests: simplify common logger options
Ruediger Meier [Thu, 9 Apr 2015 15:00:26 +0000 (17:00 +0200)] 
tests: simplify common logger options

Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
10 years agologger: --stderr and --no-act turn "auto-errors" on
Ruediger Meier [Thu, 26 Mar 2015 13:20:29 +0000 (14:20 +0100)] 
logger: --stderr and --no-act turn "auto-errors" on

Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
10 years agolibfdisk: recognize FAT32 partitions hidden by Acronis software
Jörg Jenderek [Wed, 8 Apr 2015 08:24:26 +0000 (10:24 +0200)] 
libfdisk: recognize FAT32 partitions hidden by Acronis software

References: http://www.acronis.de/products/trueimage
Signed-off-by: Karel Zak <kzak@redhat.com>
Signed-off-by: Jörg Jenderek <joerg.jen.der.ek@gmx.net>
10 years agowhereis: trivial spelling and grammar fix
Mike Place [Tue, 7 Apr 2015 08:44:50 +0000 (10:44 +0200)] 
whereis: trivial spelling and grammar fix

Signed-off-by: Karel Zak <kzak@redhat.com>
10 years agologger: fix memory leaks
Sami Kerola [Tue, 7 Apr 2015 07:58:19 +0000 (08:58 +0100)] 
logger: fix memory leaks

Reported-by: Patrick Plagwitz <patrick.plagwitz@fau.de>
Signed-off-by: Sami Kerola <sami.kerola@lastminute.com>
10 years agologger: generate header when reading message from stdin
Patrick Plagwitz [Mon, 6 Apr 2015 21:50:46 +0000 (22:50 +0100)] 
logger: generate header when reading message from stdin

This change fixes crashing error, that ought not to be simply avoided.

$ echo foo | logger -n localhost
Segmentation fault (core dumped)

If the ctl->hdr is just checked not to be NULL syslog message will not
have valid header, so generating such is not optional when reading
message from stdin and writing it to remote destination.

Reviewed-by: Bernhard Voelker <mail@bernhard-voelker.de>
Signed-off-by: Patrick Plagwitz <patrick.plagwitz@fau.de>
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
10 years agolibmount: add note about flock() to docs
Karel Zak [Thu, 2 Apr 2015 10:30:26 +0000 (12:30 +0200)] 
libmount: add note about flock() to docs

Signed-off-by: Karel Zak <kzak@redhat.com>
10 years agotests: mount/rlimit tries to restore mtab
Ruediger Meier [Thu, 2 Apr 2015 09:35:29 +0000 (11:35 +0200)] 
tests: mount/rlimit tries to restore mtab

Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
10 years agotests: fix, don't call ts_die from subshell
Ruediger Meier [Tue, 31 Mar 2015 14:07:37 +0000 (16:07 +0200)] 
tests: fix, don't call ts_die from subshell

Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
10 years agotests: ts_scsi_debug_init() sleeps a bit earlier
Ruediger Meier [Sat, 28 Mar 2015 14:32:30 +0000 (15:32 +0100)] 
tests: ts_scsi_debug_init() sleeps a bit earlier

Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
10 years agotests: fix cramfs/mkfs for BE and different pagesizes
Ruediger Meier [Sat, 28 Mar 2015 11:34:43 +0000 (12:34 +0100)] 
tests: fix cramfs/mkfs for BE and different pagesizes

Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
10 years agolsblk: don't ignore dependences for partitioned devies
Karel Zak [Wed, 1 Apr 2015 10:23:23 +0000 (12:23 +0200)] 
lsblk: don't ignore dependences for partitioned devies

The code only lists partitions, but ignore another dependencies
on whole-disk device:

$ lsblk /dev/sdb
NAME   MAJ:MIN RM   SIZE RO TYPE MOUNTPOINT
sdb      8:16   0 298.1G  0 disk
└─sdb1   8:17   0 298.1G  0 part

$ ls /sys/block/sdb/holders/
dm-0

fixed version:

$ lsblk /dev/sdb
NAME        MAJ:MIN RM   SIZE RO TYPE  MOUNTPOINT
sdb           8:16   0 298.1G  0 disk
├─sdb1        8:17   0 298.1G  0 part
└─mpatha    253:0    0 298.1G  0 mpath
  └─mpatha1 253:1    0 298.1G  0 part

Signed-off-by: Karel Zak <kzak@redhat.com>
10 years agolsblk: follow kernel for inverse tree
Karel Zak [Wed, 1 Apr 2015 10:06:41 +0000 (12:06 +0200)] 
lsblk: follow kernel for inverse tree

For multi-path devices kernel defines dependence between the device
and whole-list:

$ ls /sys/block/dm-0/slaves/
sdb

but lsblk inserts partition into the tree:

$ lsblk -s -oNAME,KNAME /dev/dm-1
mpatha1   dm-1
└─mpatha  dm-0
  └─sdb1  sdb1     <--- !
    └─sdb sdb

Signed-off-by: Karel Zak <kzak@redhat.com>
10 years agolsblk: add debug support
Karel Zak [Wed, 1 Apr 2015 10:06:15 +0000 (12:06 +0200)] 
lsblk: add debug support

Signed-off-by: Karel Zak <kzak@redhat.com>
10 years agobuild-sys: define cfdisk dependence on open_memstream
Karel Zak [Mon, 30 Mar 2015 11:54:08 +0000 (13:54 +0200)] 
build-sys: define cfdisk dependence on open_memstream

Signed-off-by: Karel Zak <kzak@redhat.com>
10 years agomount: fix lazytime docs
Karel Zak [Mon, 30 Mar 2015 10:52:22 +0000 (12:52 +0200)] 
mount: fix lazytime docs

Signed-off-by: Karel Zak <kzak@redhat.com>
10 years agolibmount: add support for MS_LAZYTIME
Karel Zak [Mon, 30 Mar 2015 10:43:45 +0000 (12:43 +0200)] 
libmount: add support for MS_LAZYTIME

Signed-off-by: Karel Zak <kzak@redhat.com>
10 years agosetarch: fix regression for sparc builds
Waldemar Brodkorb [Sun, 29 Mar 2015 13:00:30 +0000 (15:00 +0200)] 
setarch: fix regression for sparc builds

With following commit:
5edb0ea6bbd57dd916417737f98c9109dc1ecb5b

Sparc cross-compile fails.

Signed-off-by: Waldemar Brodkorb <wbx@openadk.org>
10 years agolibfdisk: don't return empty strings from fdisk_partition_to_string()
Karel Zak [Fri, 27 Mar 2015 12:47:13 +0000 (13:47 +0100)] 
libfdisk: don't return empty strings from fdisk_partition_to_string()

Signed-off-by: Karel Zak <kzak@redhat.com>
10 years agosfdisk: fix -a vs. -A bug
Karel Zak [Thu, 26 Mar 2015 17:21:53 +0000 (18:21 +0100)] 
sfdisk: fix -a vs. -A bug

The -A has been originally used for --activate, since v2.26 it's used
for --append. This is stupid mistake. This patch reverts the change to:

 -A, --activate
 -a, --append

Note that --append is a new command line option in v2.26.

Addresses: https://bugs.archlinux.org/task/44349
Signed-off-by: Karel Zak <kzak@redhat.com>
10 years agotests: verify logger return value
Ruediger Meier [Tue, 24 Mar 2015 18:37:01 +0000 (19:37 +0100)] 
tests: verify logger return value

Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
10 years agotests: avoid &>> for bash compatibility
Ruediger Meier [Tue, 24 Mar 2015 08:47:49 +0000 (09:47 +0100)] 
tests: avoid &>> for bash compatibility

Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
10 years agotests: fix getopt for old glibc
Ruediger Meier [Tue, 24 Mar 2015 08:37:30 +0000 (09:37 +0100)] 
tests: fix getopt for old glibc

Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
10 years agobuild-sys: python is optional, don't fail when missing
Karel Zak [Thu, 26 Mar 2015 11:09:50 +0000 (12:09 +0100)] 
build-sys: python is optional, don't fail when missing

Signed-off-by: Karel Zak <kzak@redhat.com>
10 years agobuild-sys: ncurses is optional, don't fail when missing
Karel Zak [Thu, 26 Mar 2015 10:50:15 +0000 (11:50 +0100)] 
build-sys: ncurses is optional, don't fail when missing

Signed-off-by: Karel Zak <kzak@redhat.com>
10 years agotests: more(1) depends on terminal, force to TERM=linux
Karel Zak [Wed, 25 Mar 2015 16:36:28 +0000 (17:36 +0100)] 
tests: more(1) depends on terminal, force to TERM=linux

Signed-off-by: Karel Zak <kzak@redhat.com>
10 years agolibfdisk: fix symbols versioning script
Karel Zak [Wed, 25 Mar 2015 10:08:22 +0000 (11:08 +0100)] 
libfdisk: fix symbols versioning script

Really stupid copy & past mistake. The libfdisk symbols should not be
prefixed by MOUNT_ suffix.

This change makes binaries linked with libfdisk 2.26 incompatible with
new libfdisk. Fortunately, 2.26 has been the first release and very
probably the library has been used for util-linux fdisks only.

Signed-off-by: Karel Zak <kzak@redhat.com>
10 years agolast, fix race when comparing time stamps
Ruediger Meier [Tue, 24 Mar 2015 11:22:13 +0000 (12:22 +0100)] 
last, fix race when comparing time stamps

It is just luck if two time() calls happen within the same
second. Introduced in 31d28e09.

Actually I don't like adding another global variable but this
way we avoid bigger refactoring. IMO it's questionable why
lastdate, lastdown, etc. are initialized with current time() at
all. It looks unsafe to print "still running" always when
logout_time = now.

Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
10 years agolast: fix first (current) runlevel line
Ruediger Meier [Tue, 24 Mar 2015 13:38:09 +0000 (14:38 +0100)] 
last: fix first (current) runlevel line

Since 744c7fec lastrch was not set to current time anymore, but we need it.

 # broken:
 $ ./last -x | grep -m 2 runlevel
 runlevel (to lvl 5)   3.11.10-25-deskt Wed Feb 18 13:11 - 01:00 (-16484+-12:-11)
 runlevel (to lvl 5)   3.11.10-25-deskt Thu Jan 22 16:50 - 13:11 (26+20:21)

 # fixed:
 $ ./last -x | grep -m 2 runlevel
 runlevel (to lvl 5)   3.11.10-25-deskt Wed Feb 18 13:11   still running
 runlevel (to lvl 5)   3.11.10-25-deskt Thu Jan 22 16:50 - 13:11 (26+20:21)

Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
10 years agofsck: fix fsck -C {fd} parsing
Stanislav Brabec [Tue, 24 Mar 2015 20:01:10 +0000 (21:01 +0100)] 
fsck: fix fsck -C {fd} parsing

Both fsck(8) and fsck --help documents progress bar redirection as
-C {fd}

This did not work, and only -C{fd} and "-C {fd}" worked.

Signed-off-by: Karel Zak <kzak@redhat.com>
10 years agolibfdisk: (gpt) check header size before verify CRC
Karel Zak [Mon, 23 Mar 2015 11:03:30 +0000 (12:03 +0100)] 
libfdisk: (gpt) check header size before verify CRC

Addresses: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=780834
Signed-off-by: Karel Zak <kzak@redhat.com>
10 years agologger: fix LOGGER_TEST_TIMEOFDAY check
Karel Zak [Mon, 23 Mar 2015 10:40:45 +0000 (11:40 +0100)] 
logger: fix LOGGER_TEST_TIMEOFDAY check

Signed-off-by: Karel Zak <kzak@redhat.com>
10 years agodmesg: fix shadow declaration
Sami Kerola [Sun, 22 Mar 2015 23:05:26 +0000 (23:05 +0000)] 
dmesg: fix shadow declaration

sys-utils/dmesg.c:650:9: warning: declaration of 's' shadows a previous local [-Wshadow]
sys-utils/dmesg.c:619:12: warning: shadowed declaration is here [-Wshadow]

And since the code had to be touched deprecate loop printing one character
at a time, in favour of printf and instruction to repeat spaces the number
required.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
10 years agomount: don't remount read-only on --bind
Karel Zak [Fri, 20 Mar 2015 11:42:33 +0000 (12:42 +0100)] 
mount: don't remount read-only on --bind

mount(8) tries to mount read-only when the previous attempt ends with
EROFS or EACCES. This is bad idea for bind mounts as "ro,bind" has
a special semantic.

Signed-off-by: Karel Zak <kzak@redhat.com>
10 years agotests: start script/race test only when --force specified
Karel Zak [Thu, 19 Mar 2015 11:06:35 +0000 (12:06 +0100)] 
tests: start script/race test only when --force specified

The test generates 1000 processes and it seems too invasive for
test/build machines and containers.

Signed-off-by: Karel Zak <kzak@redhat.com>
10 years agotravis: add MAKE_CHECK_OPTS
Karel Zak [Tue, 17 Mar 2015 11:03:28 +0000 (12:03 +0100)] 
travis: add MAKE_CHECK_OPTS

Signed-off-by: Karel Zak <kzak@redhat.com>
10 years agotests: add --skip-loopdevs
Karel Zak [Tue, 17 Mar 2015 10:34:22 +0000 (11:34 +0100)] 
tests: add --skip-loopdevs

Signed-off-by: Karel Zak <kzak@redhat.com>
10 years agotests: use ts_skip for logger/journald
Karel Zak [Tue, 17 Mar 2015 10:21:39 +0000 (11:21 +0100)] 
tests: use ts_skip for logger/journald

Signed-off-by: Karel Zak <kzak@redhat.com>
10 years agoblockdev: fix whole-disk start sector usage
Karel Zak [Tue, 17 Mar 2015 10:10:20 +0000 (11:10 +0100)] 
blockdev: fix whole-disk start sector usage

Since 569d1dac7bc64457aac11163b6a91ce9b41a6715 we read device start
sector from the /sys/block/.../start file. The file exists only for
partitions, for wholedisk is the start of the device always zero.

References: https://bugzilla.redhat.com/show_bug.cgi?id=1202443
Signed-off-by: Karel Zak <kzak@redhat.com>
10 years agobuild-sys: add new compiler warnings
Karel Zak [Tue, 17 Mar 2015 09:15:50 +0000 (10:15 +0100)] 
build-sys: add new compiler warnings

Signed-off-by: Karel Zak <kzak@redhat.com>
10 years agolibblkid: fix compiler warnings
Sami Kerola [Mon, 16 Mar 2015 00:03:49 +0000 (00:03 +0000)] 
libblkid: fix compiler warnings

warning: extra ';' outside of a function [-Wextra-semi]

warning: embedding a directive within macro arguments has undefined
behavior [-Wembedded-directive]

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
10 years agotests: add logger(1) journald test
Sami Kerola [Mon, 16 Mar 2015 23:42:57 +0000 (23:42 +0000)] 
tests: add logger(1) journald test

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
10 years agotests: add logger(1) error condition tests
Sami Kerola [Sun, 15 Mar 2015 12:46:30 +0000 (12:46 +0000)] 
tests: add logger(1) error condition tests

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
10 years agotests: add logger(1) message format tests
Sami Kerola [Sun, 15 Mar 2015 12:00:57 +0000 (12:00 +0000)] 
tests: add logger(1) message format tests

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
10 years agotests: optionally skip tests where loop support is needed
Ruediger Meier [Mon, 16 Mar 2015 11:22:53 +0000 (12:22 +0100)] 
tests: optionally skip tests where loop support is needed

It can be hard to check for loop support (e.g. on LXC containers). Let
the user skip it manually by env:

TS_OPT_FEAT_SKIP_LOOP="yes"

Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
10 years agotravis: whitelist travis* branches
Ruediger Meier [Mon, 16 Mar 2015 11:20:53 +0000 (12:20 +0100)] 
travis: whitelist travis* branches

Sometimes we may want to test non-master branches.

Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
10 years agotravis: move install script to .travis-functions.sh
Ruediger Meier [Mon, 16 Mar 2015 10:21:49 +0000 (11:21 +0100)] 
travis: move install script to .travis-functions.sh

Now this snippet can be re-used by non-travis systems. For example
on drone.io we can use this simple build script:
......
MAKE_CHECK="root"
source ./.travis-functions.sh
travis_install_script || exit
travis_before_script || exit
ret=0
travis_script || ret=$?
travis_after_script
exit $ret
......

Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
10 years agotests: use --no-act for logger tests
Karel Zak [Mon, 16 Mar 2015 13:17:49 +0000 (14:17 +0100)] 
tests: use --no-act for logger tests

and also use --stderr on one place only.

Signed-off-by: Karel Zak <kzak@redhat.com>
10 years agotests: add logger(1) command line options tests
Sami Kerola [Sun, 15 Mar 2015 12:54:50 +0000 (12:54 +0000)] 
tests: add logger(1) command line options tests

[kzak@redhat.com: - use LOGGER_TEST_* env]

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
Signed-off-by: Karel Zak <kzak@redhat.com>
10 years agologger: add -DTEST_LOGGER
Karel Zak [Mon, 16 Mar 2015 12:26:52 +0000 (13:26 +0100)] 
logger: add -DTEST_LOGGER

"make test_logger" now compiles logger(1) test program
to overwrite system datetime stuff, hostname and PID, for example:

   export TZ=GMT
   export LOGGER_TEST_TIMEOFDAY=1234567890.123456
   export LOGGER_TEST_HOSTNAME=foo
   export LOGGER_TEST_GETPID=123

   ./test_logger --rfc5424 --no-act --stderr -i --tag MyTag mesg
   <13>1 2009-02-13T23:31:30.123456+00:00 foo MyTag 123 - [timeQuality tzKnown="1" isSynced="0"] mesg

if the LOGGER_TEST_* variables are not specified then default to
standard logger(1) behavior.

Note that it would be possible to use for example "unshare --utc" to
make hostname stable and portable, but LOGGER_TEST_* variables allow
to keep the tests less complex.

Signed-off-by: Karel Zak <kzak@redhat.com>
10 years agologger: add --no-act for testing
Karel Zak [Mon, 16 Mar 2015 11:38:46 +0000 (12:38 +0100)] 
logger: add --no-act for testing

* force --journal mode to also output to stderr when the option
  --stderr specified on command line

* add --no-act to avoid all write() operations to make it possible to
  write tests without "spam" system logs

Signed-off-by: Karel Zak <kzak@redhat.com>
10 years agologger: fix rfc5424 format crash
Karel Zak [Mon, 16 Mar 2015 10:51:05 +0000 (11:51 +0100)] 
logger: fix rfc5424 format crash

$ logger --rfc5424=notq message
Segmentation fault (core dumped)

Reported-by: Sami Kerola <kerolasa@iki.fi>
Signed-off-by: Karel Zak <kzak@redhat.com>
10 years agologger: use errx() when checking user input
Sami Kerola [Sun, 15 Mar 2015 12:54:53 +0000 (12:54 +0000)] 
logger: use errx() when checking user input

Additionally inform in usage() the --msgid requires an argument.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
10 years agologger: check xgethostname() return value
Sami Kerola [Sun, 15 Mar 2015 12:54:48 +0000 (12:54 +0000)] 
logger: check xgethostname() return value

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
10 years agologger: tidy few indentation issues
Sami Kerola [Sun, 15 Mar 2015 12:54:47 +0000 (12:54 +0000)] 
logger: tidy few indentation issues

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
10 years agologger: Fix use of errno after strtol() without zeroing first
Stef Walter [Sun, 15 Mar 2015 13:23:32 +0000 (14:23 +0100)] 
logger: Fix use of errno after strtol() without zeroing first

References: https://bugzilla.redhat.com/show_bug.cgi?id=1202104
Signed-off-by: Karel Zak <kzak@redhat.com>
10 years agobuild-sys: release++ (v2.26.1) v2.26.1
Karel Zak [Fri, 13 Mar 2015 13:11:37 +0000 (14:11 +0100)] 
build-sys: release++ (v2.26.1)

Signed-off-by: Karel Zak <kzak@redhat.com>
10 years agodocs: update v2.26.1-ReleaseNotes
Karel Zak [Fri, 13 Mar 2015 13:06:11 +0000 (14:06 +0100)] 
docs: update v2.26.1-ReleaseNotes

Signed-off-by: Karel Zak <kzak@redhat.com>
10 years agodocs: update AUTHORS file
Karel Zak [Fri, 13 Mar 2015 12:53:16 +0000 (13:53 +0100)] 
docs: update AUTHORS file

Signed-off-by: Karel Zak <kzak@redhat.com>
10 years agopo: merge changes
Karel Zak [Fri, 13 Mar 2015 12:51:33 +0000 (13:51 +0100)] 
po: merge changes

Signed-off-by: Karel Zak <kzak@redhat.com>
10 years agologger: use xstrdup()
Karel Zak [Fri, 13 Mar 2015 12:35:20 +0000 (13:35 +0100)] 
logger: use xstrdup()

Signed-off-by: Karel Zak <kzak@redhat.com>
10 years agotests: fix fdisk/bsd for ppc64le
Ruediger Meier [Thu, 12 Mar 2015 18:08:26 +0000 (19:08 +0100)] 
tests: fix fdisk/bsd for ppc64le

Actually Aurelien's patch a80886e9 should have addressed this already
because it's the case LE, BSD_LABELSECTOR = 0, BSD_LABELOFFSET = 64.

I've asked about this on mailing list but couldn't get more
informations.
Thread "test fdisk/bsd on exotic archs":
http://comments.gmane.org/gmane.linux.utilities.util-linux-ng/10621

Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
10 years agotests: improve readability for fdisk/bsd
Ruediger Meier [Thu, 12 Mar 2015 18:08:25 +0000 (19:08 +0100)] 
tests: improve readability for fdisk/bsd

Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
10 years agolast: fix utmplist usage
Karel Zak [Fri, 13 Mar 2015 10:13:26 +0000 (11:13 +0100)] 
last: fix utmplist usage

last(1) uses a global list of entries, this is unnecessary and it's
also mistake because the pointer to the list is not set to NULL when
last(1) opens another utmp file. For example:

 last -f /var/log/wtmp -f /var/log/wtmp-20150220

ends with unexpected free() call or sometimes with never ending loop.

Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=1201033
Signed-off-by: Karel Zak <kzak@redhat.com>
10 years agocal: care about setuprterm() result
Karel Zak [Thu, 12 Mar 2015 10:50:07 +0000 (11:50 +0100)] 
cal: care about setuprterm() result

References: https://bugzilla.suse.com/show_bug.cgi?id=903440
Signed-off-by: Karel Zak <kzak@redhat.com>
10 years agolibmount: mark overlay as pseudo-FS
Karel Zak [Wed, 11 Mar 2015 10:38:07 +0000 (11:38 +0100)] 
libmount: mark overlay as pseudo-FS

Signed-off-by: Karel Zak <kzak@redhat.com>
10 years agolibmount: add mnt_table_get_fs_root() to header file
Karel Zak [Wed, 11 Mar 2015 10:11:19 +0000 (11:11 +0100)] 
libmount: add mnt_table_get_fs_root() to header file

Signed-off-by: Karel Zak <kzak@redhat.com>
10 years agotests: update sfdisk --dump test
Karel Zak [Wed, 11 Mar 2015 09:58:45 +0000 (10:58 +0100)] 
tests: update sfdisk --dump test

Signed-off-by: Karel Zak <kzak@redhat.com>
10 years agologger: small change in usage()
Karel Zak [Wed, 11 Mar 2015 09:51:13 +0000 (10:51 +0100)] 
logger: small change in usage()

Signed-off-by: Karel Zak <kzak@redhat.com>
10 years agologger man page: fix typo
Rainer Gerhards [Tue, 10 Mar 2015 16:48:05 +0000 (17:48 +0100)] 
logger man page: fix typo

10 years agologger: add --msgid option, permits to set RFC5424 MSGID field
Rainer Gerhards [Tue, 10 Mar 2015 16:47:30 +0000 (17:47 +0100)] 
logger: add --msgid option, permits to set RFC5424 MSGID field

10 years agologger: fix multiple format bugs in rfc5424 formatter
Rainer Gerhards [Tue, 10 Mar 2015 16:26:14 +0000 (17:26 +0100)] 
logger: fix multiple format bugs in rfc5424 formatter

This is more or less a complete rewrite of the formatter. It had
multiple issue, e.g. a missing field (MSGID?) and invalid handling
of nil values.

10 years agosilence compiler warning
Rainer Gerhards [Tue, 10 Mar 2015 13:13:38 +0000 (14:13 +0100)] 
silence compiler warning

This is primarily cosmetic, albeit it also provides an only very
slight improvement in compile time error checking.

10 years agolibmount: cleanup fs root detection code
Karel Zak [Tue, 10 Mar 2015 12:35:56 +0000 (13:35 +0100)] 
libmount: cleanup fs root detection code

Signed-off-by: Karel Zak <kzak@redhat.com>
10 years agofindmnt: don't rely on st_dev for --target
Karel Zak [Tue, 10 Mar 2015 11:51:44 +0000 (12:51 +0100)] 
findmnt: don't rely on st_dev for --target

The overlay filesystem does not provide usable st_dev (in traditional
UNIX way). It's necessary to search in /proc/self/mountinfo to detect
which path element is mountpoint.

$ findmnt --target /mnt/merged/dir-a/foo
TARGET      SOURCE  FSTYPE  OPTIONS
/mnt/merged overlay overlay rw,relatime,lowerdir=/mnt/low,upperdir=/mnt/high/data,workdir=/mnt/high/work

Signed-off-by: Karel Zak <kzak@redhat.com>
10 years agologger: check for ntp_gettime() rather than for timex.h
Karel Zak [Tue, 10 Mar 2015 10:37:45 +0000 (11:37 +0100)] 
logger: check for ntp_gettime() rather than for timex.h

It seems that musl libc and uClibc without UCLIBC_NTP_LEGACY
does not provide ntp_gettime and compile will fail.

References: https://github.com/karelzak/util-linux/issues/174
Signed-off-by: Karel Zak <kzak@redhat.com>
10 years agologger: add --skip-empty to prevent logging empty lines
Rainer Gerhards [Sat, 7 Mar 2015 11:14:21 +0000 (12:14 +0100)] 
logger: add --skip-empty to prevent logging empty lines

Empty log messages are generally considered useless. This option
enables to turn them off when processing files (including stdin).

[kzak@redhat.com: - rename --skip-empty-lines to --skip-empty,
                  - add the option to getopt_long(),
                  - add the option to bash-completion]

Signed-off-by: Karel Zak <kzak@redhat.com>
10 years agologger man page: update --size doc
Rainer Gerhards [Sat, 7 Mar 2015 11:04:43 +0000 (12:04 +0100)] 
logger man page: update --size doc

now we have strict sizes

Signed-off-by: Karel Zak <kzak@redhat.com>
10 years agologger: bugfix: missing sanity checks with --prio-prefix option
Rainer Gerhards [Sat, 7 Mar 2015 10:49:00 +0000 (11:49 +0100)] 
logger: bugfix: missing sanity checks with --prio-prefix option

There were no apparent sanity checks other than applying the logmask
when reading PRI values from files. As such, invalid PRIs (tested with
values 192, 210, and 2100) are accepted. This in turn can trigger
problems in various receivers, especially older versions. See here
for details:

http://www.rsyslog.com/remote-syslog-pri-vulnerability-cve-2014-3683/

Note that 2100 was changed to 52 as described in above link.

This patch refactors PRI processing. Invalid PRIs are detected and in
this case the message is sent with the default priority, with the
invalid pri being part of the message to be sent. This is along the
line of what 2.26 did when it detected the PRI was invalid.

The refactoring now also enables pricese tracking of syslog header
length in all cases, so --size is now strictly obeyed.

[kzak@redhat.com: - fix compiler warning [-Wunused-variable]]

Signed-off-by: Karel Zak <kzak@redhat.com>
10 years agologger: refactor message generation
Rainer Gerhards [Fri, 6 Mar 2015 17:52:26 +0000 (18:52 +0100)] 
logger: refactor message generation

Previously, the message format was generated in one big step. Now
this is refactored to generate the header independently. This not
only provides a better isolation of functionality, but enables
to calculate the size of the header *before* generating the user
part of the message. That in turn is needed in order to precisely
enforce the message size limit. This is especially important while
processing files, as here parts of the message may be lost if the
receiver truncates the message. The file reader itself tries to
guard against this by reading only the permitted number of bytes,
but without knowing the header size, it would mis-guess here.

Note that when --prio-prefix is given, we still do not know exactly
the header length, because the PRI value is between 1 and 3 bytes.
Unfortunately, we do not know the actual size before reading. With
the current (simple) approach, we need to read the full line before
getting the PRI, so this is a hen-egg problem. To solve this, a
more complex reader would be required. It is questionable if this
is necessary for a tool like logger. So currently, we still have a
2-byte window of uncertainty if --prio-prefix is given.

[kzak@redhat.com: - fix compiler warnings [-Wunused-but-set-variable]]

Signed-off-by: Karel Zak <kzak@redhat.com>
10 years agologger: permit to send messages larger than 1024 characters
Rainer Gerhards [Fri, 6 Mar 2015 14:50:34 +0000 (15:50 +0100)] 
logger: permit to send messages larger than 1024 characters

This is an important capability that has been specified in RFC5424.
However, messages larger than 1024 chars are being accepted for years
now by at least rsyslog and syslog-ng.

This patch adds the option --size to permit setting a new max
size, with 1024 being the default.

Note that the size limit is only approximative, as we do not take the
header size in account (RFC talks about total message length).

[[kzak@redhat.com: - add 'S' to getopt_long(),
                   - rename --message-size to --size
                   - add the option to bash-completion]

Signed-off-by: Karel Zak <kzak@redhat.com>
10 years agoagetty: reload issue on --autologin --login-pause too
Karel Zak [Mon, 9 Mar 2015 11:45:52 +0000 (12:45 +0100)] 
agetty: reload issue on --autologin --login-pause too

The current "agetty --reload" implementation does not refresh issue
file output on autologin. Let's support this use-case too.

Reported-by: Sitsofe Wheeler <sitsofe@gmail.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
10 years agoagetty: make sure that reload file exists
Karel Zak [Mon, 9 Mar 2015 11:26:55 +0000 (12:26 +0100)] 
agetty: make sure that reload file exists

agetty monitors /run/agetty.reload file, unfortunately if the file
does not exist when agetty starts up then "agetty" --reload does not
work. This patch forces agetty to create the file before inotify
is enabled.

Reported-by: Sitsofe Wheeler <sitsofe@gmail.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
10 years agologger man page: bump man page date to current
Rainer Gerhards [Fri, 6 Mar 2015 11:32:12 +0000 (12:32 +0100)] 
logger man page: bump man page date to current

10 years agologger man page: fix some "syslog(3) routine" remnants
Rainer Gerhards [Fri, 6 Mar 2015 11:30:56 +0000 (12:30 +0100)] 
logger man page: fix some "syslog(3) routine" remnants

10 years agologger: use username as the default tag
Karel Zak [Fri, 6 Mar 2015 11:15:23 +0000 (12:15 +0100)] 
logger: use username as the default tag

Reported-by: Rainer Gerhards <rgerhards@adiscon.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
10 years agologger: bugfix: tcp syslog framing is broken, -T unusable
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.

10 years agologger: refactor the way output is written
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.

10 years agologger: remove "interface to syslog(3)" from man page
Karel Zak [Fri, 6 Mar 2015 10:48:23 +0000 (11:48 +0100)] 
logger: remove "interface to syslog(3)" from man page

since v2.26 logger does not use syslog(3) anymore

Reported-by: Rainer Gerhards <rgerhards@adiscon.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
10 years agologger: fix whitespace and compiler warning [-Wunused-variable]
Karel Zak [Fri, 6 Mar 2015 10:27:16 +0000 (11:27 +0100)] 
logger: fix whitespace and compiler warning [-Wunused-variable]

misc-utils/logger.c: In function ‘syslog_rfc3164’:
misc-utils/logger.c:336:9: warning: unused variable ‘now’ [-Wunused-variable]

Signed-off-by: Karel Zak <kzak@redhat.com>
10 years agologger: add comment
Karel Zak [Fri, 6 Mar 2015 10:05:30 +0000 (11:05 +0100)] 
logger: add comment

Signed-off-by: Karel Zak <kzak@redhat.com>
10 years agologger: fix -p kern.* priority is accepted regression
Rainer Gerhards [Thu, 5 Mar 2015 15:54:34 +0000 (16:54 +0100)] 
logger: fix -p kern.* priority is accepted regression

Pre 2.26, syslog(3) was used for local logging, and it did not
accept kern.* priorities. This is re-enabled by the patch.

10 years agologger: messages are logged with kern.* priority by default
Rainer Gerhards [Thu, 5 Mar 2015 15:44:03 +0000 (16:44 +0100)] 
logger: messages are logged with kern.* priority by default

The default should be user.notice and kern.* should never be used
(syslog(3) forbids this).

This is a severe regression, as messages are now logged to the wrong
bin or not at all. So they get lost and may confuse readers of the
kernel bin.

regression from 2.25.2 to 2.26

10 years agologger: fix invalid timestamp regression in local format
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.

10 years agologger: fix inconsistent format regression when logging locally
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

10 years agoagetty: support /usr/lib/os-release too
Karel Zak [Thu, 5 Mar 2015 11:25:28 +0000 (12:25 +0100)] 
agetty: support /usr/lib/os-release too

http://www.freedesktop.org/software/systemd/man/os-release.html

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>
10 years agologger: fix -i argument parsing regression
Sami Kerola [Fri, 20 Feb 2015 19:42:34 +0000 (19:42 +0000)] 
logger: fix -i argument parsing regression

With earlier logger it's possible to combine the option -i with other
options, such as -s.  But currently:

$:~> logger -is
logger: failed to parse id: 's'

The changed behaviour breaks existing scripts like dhcpcd-run-hooks from
dhcpcd.

Broken-since: aab5b44405b9a6ada92e419e5a84cc0d1d4afee9
Reference: http://comments.gmane.org/gmane.linux.utilities.util-linux-ng/9683
Reported-by: Juergen Daubert <jue@jue.li>
Reviewed-by: Benno Schulenberg <bensberg@justemail.net>
Signed-off-by: Sami Kerola <kerolasa@iki.fi>