]> git.ipfire.org Git - thirdparty/util-linux.git/log
thirdparty/util-linux.git
9 years agobuild-sys: add tools/Makemodule.am
Karel Zak [Wed, 25 May 2016 13:59:15 +0000 (15:59 +0200)] 
build-sys: add tools/Makemodule.am

We have "make" targets which depends on tools/check*.sh scripts. It's
ugly to exclude these scripts from the release tar balls (as generated
by "make distcheck").

Signed-off-by: Karel Zak <kzak@redhat.com>
9 years agotools: add script to load .po from translationproject.org
Karel Zak [Wed, 25 May 2016 13:28:42 +0000 (15:28 +0200)] 
tools: add script to load .po from translationproject.org

I use it for years, let's keep it in the repository.

Signed-off-by: Karel Zak <kzak@redhat.com>
9 years agolibblkid: improve debug messages
Karel Zak [Wed, 25 May 2016 13:06:22 +0000 (15:06 +0200)] 
libblkid: improve debug messages

Signed-off-by: Karel Zak <kzak@redhat.com>
9 years agobuild-sys: add missing include/plymouth-ctrl.h
Karel Zak [Tue, 24 May 2016 12:50:07 +0000 (14:50 +0200)] 
build-sys: add missing include/plymouth-ctrl.h

Signed-off-by: Karel Zak <kzak@redhat.com>
9 years agodmesg: fix indention
Karel Zak [Tue, 24 May 2016 12:12:54 +0000 (14:12 +0200)] 
dmesg: fix indention

Signed-off-by: Karel Zak <kzak@redhat.com>
9 years agolast: fix logout time
Karel Zak [Tue, 24 May 2016 12:08:57 +0000 (14:08 +0200)] 
last: fix logout time

Signed-off-by: Karel Zak <kzak@redhat.com>
9 years agolsipc: use strtime_short()
Karel Zak [Tue, 24 May 2016 11:22:40 +0000 (13:22 +0200)] 
lsipc: use strtime_short()

Signed-off-by: Karel Zak <kzak@redhat.com>
9 years agolslogins: use strtime_short()
Karel Zak [Tue, 24 May 2016 11:22:23 +0000 (13:22 +0200)] 
lslogins: use strtime_short()

Signed-off-by: Karel Zak <kzak@redhat.com>
9 years agolib/timeutils: add strtime_short()
Karel Zak [Tue, 24 May 2016 11:21:26 +0000 (13:21 +0200)] 
lib/timeutils: add strtime_short()

Signed-off-by: Karel Zak <kzak@redhat.com>
9 years agotests: refresh cal(1) test
Karel Zak [Tue, 24 May 2016 09:16:12 +0000 (11:16 +0200)] 
tests: refresh cal(1) test

Signed-off-by: Karel Zak <kzak@redhat.com>
9 years agolsipc: use strtm_iso()
Karel Zak [Tue, 24 May 2016 09:10:57 +0000 (11:10 +0200)] 
lsipc: use strtm_iso()

Signed-off-by: Karel Zak <kzak@redhat.com>
9 years agohwclock: use strtimeval_iso()
Karel Zak [Tue, 24 May 2016 09:10:10 +0000 (11:10 +0200)] 
hwclock: use strtimeval_iso()

Signed-off-by: Karel Zak <kzak@redhat.com>
9 years agodmesg: use strtimeval_iso()
Karel Zak [Tue, 24 May 2016 09:09:41 +0000 (11:09 +0200)] 
dmesg: use strtimeval_iso()

Signed-off-by: Karel Zak <kzak@redhat.com>
9 years agolslogins: use strtm_iso()
Karel Zak [Tue, 24 May 2016 09:08:10 +0000 (11:08 +0200)] 
lslogins: use strtm_iso()

Signed-off-by: Karel Zak <kzak@redhat.com>
9 years agolast: cleanup time formatting code
Karel Zak [Tue, 24 May 2016 09:07:08 +0000 (11:07 +0200)] 
last: cleanup time formatting code

- describe difference between login and logout time formats in struct last_timefmt
- use strtime_iso()
- rename LAST_TIMEFTM_SHORT_CTIME to LAST_TIMEFTM_SHORT
- rename LAST_TIMEFTM_FULL_CTIME to LAST_TIMEFTM_CTIME
- add LAST_TIMEFTM_HHMM for internal purpose (logout format for "--time-format short")

Signed-off-by: Karel Zak <kzak@redhat.com>
9 years agoinclude/timeutils: rewrite iso formatting functions
Karel Zak [Tue, 24 May 2016 08:58:52 +0000 (10:58 +0200)] 
include/timeutils: rewrite iso formatting functions

- use buffers rather than allocate memory
- support .usec and ,usec convention
- use strftime for timezone (we need to care about daylight
  saving time)

Signed-off-by: Karel Zak <kzak@redhat.com>
9 years agoinclude/timeutils: use pointer for time_t
Karel Zak [Mon, 23 May 2016 09:56:31 +0000 (11:56 +0200)] 
include/timeutils: use pointer for time_t

Signed-off-by: Karel Zak <kzak@redhat.com>
9 years agosulogin: agetty: use the plymouth local protocol instead the plymouth binary
Werner Fink [Fri, 22 Apr 2016 10:16:04 +0000 (12:16 +0200)] 
sulogin: agetty: use the plymouth local protocol instead the plymouth binary

for stopping plymouthd.  That do not depend on the existence of
the plymouth binary if it e.g. becomes uninstalled or an other
service is providing plymouthd facilities.

[kzak@redhat.com: - fix compiler warnings [-Wpointer-sign]
                  - use sizeof() for write_all()
                  - cast to char* for read_all]

Signed-off-by: Werner Fink <werner@suse.de>
Signed-off-by: Karel Zak <kzak@redhat.com>
9 years agoMerge branch 'cal04'
Karel Zak [Fri, 20 May 2016 08:55:06 +0000 (10:55 +0200)] 
Merge branch 'cal04'

9 years agoman pages: fix spacing between man page name & section number
Mike Frysinger [Tue, 10 May 2016 19:26:54 +0000 (15:26 -0400)] 
man pages: fix spacing between man page name & section number

Most have standardized correctly, but fix a few latent ones.

Signed-off-by: Mike Frysinger <vapier@gentoo.org>
9 years agoscript: improve coding style and the "done" message
Karel Zak [Wed, 18 May 2016 13:06:31 +0000 (15:06 +0200)] 
script: improve coding style and the "done" message

Don't print the "done" message if the file does not exist.

Signed-off-by: Karel Zak <kzak@redhat.com>
9 years agocal: use %04d for year
Karel Zak [Wed, 18 May 2016 12:43:20 +0000 (14:43 +0200)] 
cal: use %04d for year

It seems that people are crazy enough to assume that "cal 16" is the
year 2016, rather than 16 (2000 years ago).

This patch makes it more clear as the output is 0016.

Addresses: https://github.com/karelzak/util-linux/issues/320
Signed-off-by: Karel Zak <kzak@redhat.com>
9 years agolibfdisk: use table-length in dump for non-standard PT
Karel Zak [Wed, 18 May 2016 12:29:50 +0000 (14:29 +0200)] 
libfdisk: use table-length in dump for non-standard PT

Signed-off-by: Karel Zak <kzak@redhat.com>
9 years agolibfdisk: make table-length usage more robust
Karel Zak [Wed, 18 May 2016 12:15:02 +0000 (14:15 +0200)] 
libfdisk: make table-length usage more robust

Signed-off-by: Karel Zak <kzak@redhat.com>
9 years agosfdisk: Add support for altering GPT size
Sassan Panahinejad [Thu, 12 May 2016 11:54:43 +0000 (12:54 +0100)] 
sfdisk: Add support for altering GPT size

Adds a header option to alter the GPT table length

9 years agolibfdisk: Add support for altering GPT size
Sassan Panahinejad [Fri, 13 May 2016 14:01:02 +0000 (15:01 +0100)] 
libfdisk: Add support for altering GPT size

This is useful in two situations:

1. More than 128 partitions are required. Or

2. The partition table must be restricted in size, such as when a system
expects to find a bootloader at a location that would otherwise overlap the
partition table.

The gdisk partitioner supports this feature.

libfdisk is already capable of reading and writing partition tables of any
size, but previously could only create ones of 128 entries and could not
resize.

This change should be fairly safe, as it has no effect unless explicitly
activated.

Signed-off-by: Karel Zak <kzak@redhat.com>
9 years agofdisk: Add support for altering GPT size
Sassan Panahinejad [Fri, 13 May 2016 10:42:14 +0000 (11:42 +0100)] 
fdisk: Add support for altering GPT size

Adds an options (l) to the GPT menu to resize the GPT.

9 years agolibfdisk: fix range checking for fdisk_set_last_lba
Sassan Panahinejad [Thu, 12 May 2016 12:09:00 +0000 (13:09 +0100)] 
libfdisk: fix range checking for fdisk_set_last_lba

9 years agologger: add man page note about the default --tag
Karel Zak [Mon, 16 May 2016 13:05:28 +0000 (15:05 +0200)] 
logger: add man page note about the default --tag

Signed-off-by: Karel Zak <kzak@redhat.com>
9 years agolibfdisk: add API for work with labelitems
Karel Zak [Thu, 12 May 2016 12:37:29 +0000 (14:37 +0200)] 
libfdisk: add API for work with labelitems

Signed-off-by: Karel Zak <kzak@redhat.com>
9 years agolibfdisk: move fdisk_field_...() functions to field.c
Karel Zak [Thu, 12 May 2016 10:21:59 +0000 (12:21 +0200)] 
libfdisk: move fdisk_field_...() functions to field.c

Signed-off-by: Karel Zak <kzak@redhat.com>
9 years agolib/timeutils: add strxxx_iso() functions
Karel Zak [Wed, 11 May 2016 13:31:02 +0000 (15:31 +0200)] 
lib/timeutils: add strxxx_iso() functions

Signed-off-by: Karel Zak <kzak@redhat.com>
9 years agoramctl: add support for zram-control
Karel Zak [Wed, 11 May 2016 10:43:40 +0000 (12:43 +0200)] 
ramctl: add support for zram-control

Based on patch from Timofey Titovets.

Addresses: https://github.com/karelzak/util-linux/issues/318
Reported-by: Timofey Titovets <nefelim4ag@gmail.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
9 years agolibfdisk: use fdisk_add_partition() for unused partno
Karel Zak [Tue, 10 May 2016 08:52:31 +0000 (10:52 +0200)] 
libfdisk: use fdisk_add_partition() for unused partno

For example:

   sfdisk -N <parno>

may address unused partition. In this case we need to redirect from
fdisk_set_partition() to fdisk_add_partition() and follow default
setting (used all free space).

Signed-off-by: Karel Zak <kzak@redhat.com>
9 years agoMerge branch 'no-fork' of https://github.com/terryburton/util-linux
Karel Zak [Mon, 9 May 2016 11:28:52 +0000 (13:28 +0200)] 
Merge branch 'no-fork' of https://github.com/terryburton/util-linux

9 years agosetterm: remove unnecessary translation string
Sami Kerola [Sun, 8 May 2016 20:17:18 +0000 (21:17 +0100)] 
setterm: remove unnecessary translation string

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
9 years agosetterm: de-duplicate color option string parsing
Karel Zak [Mon, 9 May 2016 10:35:41 +0000 (12:35 +0200)] 
setterm: de-duplicate color option string parsing

Signed-off-by: Karel Zak <kzak@redhat.com>
9 years agowrite: fix setuid related regression
Wayne Pollock [Wed, 4 May 2016 16:15:14 +0000 (17:15 +0100)] 
write: fix setuid related regression

The write(1) is commonly a setuid binary, because common users cannot by
default write to each others terminals.  Since the commit in reference, that
is part of releases v2.24 to v2.28, the write(1) has used access(2) to check
capability to write to a destination terminal.  The catch is that access(2)
uses real UID and GID to when performing the accessibility.  The obvious
correction is to avoid access(2) when in context of setuid binaries.

As a smaller fix, but equally important fix, ensure the 'msgsok' variable is
initialized to indicate no access.  Uninitialized variable will almost
certainly do wrong thing at the time of check.

Breaking-commit: 0233a8ea18bec17dd59cfe1fec8281
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
Signed-off-by: Karel Zak <kzak@redhat.com>
Signed-off-by: Wayne Pollock <profwaynepollock@gmail.com>
9 years agoscriptreplay: avoid re-implementing strtod_or_err()
Sami Kerola [Sun, 1 May 2016 22:56:05 +0000 (23:56 +0100)] 
scriptreplay: avoid re-implementing strtod_or_err()

And use isnan() to detect NaN.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
9 years agoscriptreplay: improve error message
Sami Kerola [Sun, 1 May 2016 22:56:04 +0000 (23:56 +0100)] 
scriptreplay: improve error message

Use human numbering for lines - that is start counting from 1.  And tell in
error message what the number means.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
9 years agosfdisk: exit with error if rereading partition table fails
Victor Dodon [Thu, 21 Apr 2016 07:24:58 +0000 (00:24 -0700)] 
sfdisk: exit with error if rereading partition table fails

Use the return value of fdisk_reread_partition_table in write_changes so that
sfdisk exits with error if re-reading the partition table fails.

Signed-off-by: Victor Dodon <dodonvictor@gmail.com>
9 years agobuild-sys: remove obsolete [cs]fdisk LDADDs
Karel Zak [Wed, 4 May 2016 13:02:02 +0000 (15:02 +0200)] 
build-sys: remove obsolete [cs]fdisk LDADDs

Signed-off-by: Karel Zak <kzak@redhat.com>
9 years agosfdisk: add --wipe-partitions=auto|never|default
Karel Zak [Wed, 4 May 2016 10:43:35 +0000 (12:43 +0200)] 
sfdisk: add --wipe-partitions=auto|never|default

The option allows to remove filesystes/RAIDs from newly created
partitions before the partition table is updated (and partition
device created).

The default is "auto" in this case wipe is enabled in interactive mode
only and user's confirmation (yes/no dialog) is required. Note that
keep filesystem signature on partition is pretty valid use-case, so we
don't erase anything by default.

Signed-off-by: Karel Zak <kzak@redhat.com>
9 years agofdisk: add --wipe-partitions=auto|never|default
Karel Zak [Wed, 4 May 2016 10:43:35 +0000 (12:43 +0200)] 
fdisk: add --wipe-partitions=auto|never|default

The option allows to remove filesystes/RAIDs from newly created
partitions before the partition table is updated (and partition
device created).

The default is "auto" in this case wipe is enabled in interactive mode
only and user's confirmation (yes/no dialog) is required. Note that
keep filesystem signature on partition is pretty valid use-case, so we
don't erase anything by default.

Signed-off-by: Karel Zak <kzak@redhat.com>
9 years agolibfdisk: add fdisk_wipe_partition()
Karel Zak [Wed, 4 May 2016 10:32:52 +0000 (12:32 +0200)] 
libfdisk: add fdisk_wipe_partition()

Now libfdisk provides functionality wipe disk device only ([s]fdisk
option --wipe).

This patch allows to probe for filesystems/RAIDs on newly created
partitions.  It means we can remove signatures before the partition
node (device) is created. This reduces udev events and it's
unnecessary to call wipefs for all partitions.  For example

  sfdisk --wipe=always --wipe-partitions=always /dev/sda <<<
  ...
  EOF

is a elegant way how to create new disk layout without any obsolete
filesystems/RAIDs.

Signed-off-by: Karel Zak <kzak@redhat.com>
9 years agolibblkid: make I/O errors on CDROMs non-fatal
Karel Zak [Thu, 28 Apr 2016 11:54:01 +0000 (13:54 +0200)] 
libblkid: make I/O errors on CDROMs non-fatal

It seems too tricky to get a real size of the data track on hybrid
disks with audio+data. It seems overkill to analyze all header in
libblkid and on some disks it's probably possible to get I/O error
almost everywhere due to crazy copy protection etc.

Signed-off-by: Karel Zak <kzak@redhat.com>
9 years agoRevert "libblkid: check for multi-session CDROMs"
Karel Zak [Wed, 27 Apr 2016 16:49:36 +0000 (18:49 +0200)] 
Revert "libblkid: check for multi-session CDROMs"

This reverts commit a14cc9a5046bc4954b4110323c83599f90f9f35e.

We need a better way (probably analyze track ioctls CDROMREADTOCHDR
and CDROMREADTOCENTRY) to get also proper track size.

The original patch works only if data track is the last track.

Signed-off-by: Karel Zak <kzak@redhat.com>
9 years agolibblkid: check for multi-session CDROMs
Karel Zak [Wed, 27 Apr 2016 12:18:41 +0000 (14:18 +0200)] 
libblkid: check for multi-session CDROMs

.. and read last session if probing offset is not specified.

udev uses cdrom_id to get last session offset, so people don't see a
problem with hybrid media (audio+data), but if you execute blkid on
command line (without -O <offset>) then you get I/O errors.

It seems that we can use the same way as kernel filesystem iso9960
driver when session= mount option is not specified ... just use
CDROMMULTISESSION ioctl to get last session offset and probe this last
session rather than all medium.

Signed-off-by: Karel Zak <kzak@redhat.com>
9 years agolibfdisk: don't offer zero length freespace
Karel Zak [Mon, 25 Apr 2016 09:59:06 +0000 (11:59 +0200)] 
libfdisk: don't offer zero length freespace

Reported-by: Kay Sievers <kay@vrfy.org>
Signed-off-by: Karel Zak <kzak@redhat.com>
9 years agolibsmartcols remove duplicate code
Karel Zak [Fri, 22 Apr 2016 11:59:06 +0000 (13:59 +0200)] 
libsmartcols remove duplicate code

For petty long time we have strdup_to_struct_member() macro to avoid
duplicate code when strdup() strings in setter functions. Let's use it
for libmount.

Signed-off-by: Karel Zak <kzak@redhat.com>
9 years agolibmount: remove duplicate code
Karel Zak [Fri, 22 Apr 2016 11:59:06 +0000 (13:59 +0200)] 
libmount: remove duplicate code

For petty long time we have strdup_to_struct_member() macro to avoid
duplicate code when strdup() strings in setter functions. Let's use it
for libmount.

Signed-off-by: Karel Zak <kzak@redhat.com>
9 years agotests: move getopt to separate directory
Karel Zak [Fri, 22 Apr 2016 11:39:31 +0000 (13:39 +0200)] 
tests: move getopt to separate directory

Signed-off-by: Karel Zak <kzak@redhat.com>
9 years agomount: add note about loopdev reuse to mount.8
Karel Zak [Fri, 22 Apr 2016 11:14:12 +0000 (13:14 +0200)] 
mount: add note about loopdev reuse to mount.8

Signed-off-by: Karel Zak <kzak@redhat.com>
9 years agomount: Handle EROFS before calling mount() syscall
Stanislav Brabec [Tue, 12 Apr 2016 18:23:25 +0000 (20:23 +0200)] 
mount: Handle EROFS before calling mount() syscall

If the loop device is already initialized read-only, the new code for loop
device reuse returns -EROFS. There is no solution of this situation. But mount
can behave in the same way, as it does for EROFS returned by mount syscall: Try
again in read-only mode.

Before:
mount: /mnt/2: mount failed: Read-only file system

After:
mount: /btrfs.img is used as read only loop, mounting read-only

Note: It would be nice to mention loop device name in the warning message, but
it is not available in the mount context.

Signed-off-by: Stanislav Brabec <sbrabec@suse.cz>
9 years agolibmount: reuse existing loop device
Stanislav Brabec [Tue, 12 Apr 2016 18:22:56 +0000 (20:22 +0200)] 
libmount: reuse existing loop device

According to the Al Viro[1], kernel has no way to detect that a single file is
used by multiple loop devices, and multiple mounts of the same file using
different loop devices will result in a data corruption. Exactly this now
happens, if multiple btrfs sub-volumes in one file are mounted with "-oloop".

Make use of multiple -oloop mounting the same file safe: Do a loop devices
lookup, and if a loop device is already initialized, use it.

Hopefully it is possible, as "losetup -d" will return OK, even if the device
itself is in use, and is not released.

Problems:

There is a risk of race condition between the lookup and real mount.

Once loop device is initialized read-only, kernel offers no way to turn it to
read-write. It has to fail.

References:
https://lkml.org/lkml/2016/2/26/897

Signed-off-by: Stanislav Brabec <sbrabec@suse.cz>
9 years agolibmount: Re-organize is_mounted_same_loopfile()
Stanislav Brabec [Tue, 12 Apr 2016 18:22:36 +0000 (20:22 +0200)] 
libmount: Re-organize is_mounted_same_loopfile()

First parse options, then initialize context.
No change in function.
The change is needed for loop device reuse.

Signed-off-by: Stanislav Brabec <sbrabec@suse.cz>
9 years agogetopt: keep pointer to 'name' in control struct
Karel Zak [Fri, 22 Apr 2016 09:29:46 +0000 (11:29 +0200)] 
getopt: keep pointer to 'name' in control struct

It's seems more readable than call free(argv[0]).

Signed-off-by: Karel Zak <kzak@redhat.com>
9 years agoMerge branch 'scan-build' of https://github.com/kerolasa/lelux-utiliteetit
Karel Zak [Fri, 22 Apr 2016 09:21:16 +0000 (11:21 +0200)] 
Merge branch 'scan-build' of https://github.com/kerolasa/lelux-utiliteetit

* 'scan-build' of https://github.com/kerolasa/lelux-utiliteetit:
  getopt: fix memory leaks and integer overflows [ASAN & valgrind]
  lib: avoid double free in loopdev.c
  setpwnam: fix memory leak
  libmount: fix memory leak
  build-sys: test functions does not return void

9 years agofsck: fix racing between unlock/unlink and open
Yuriy M. Kaminskiy [Thu, 7 Apr 2016 21:38:56 +0000 (00:38 +0300)] 
fsck: fix racing between unlock/unlink and open

Process A Process B Process C
open()
[creates file]
lock()
[succeed]
open()
[open existing]
lock()...
running()
close()
[...succeed]
unlink()
running()
open()
[creates file] {BAD!}
lock()
[succeed] {BAD!}
running() {BAD!}
close()

Cons: leaves empty (unlocked/harmless) .lock files in /run/fsck/
Signed-off-by: Yuriy M. Kaminskiy <yumkam@gmail.com>
9 years agonsenter: enter namespaces in two passes
James Bottomley [Fri, 15 Apr 2016 15:10:20 +0000 (08:10 -0700)] 
nsenter: enter namespaces in two passes

We have two use cases for user namespaces, one to elevate the
privilege of an unprivileged user, in which case we have to enter the
user namespace before all other namespaces (otherwise there isn't
enough permission to enter any other namespace).  And the other one is
where we're deprivileging a user and thus have to enter the user
namespace last (because that's the point at which we lose the
privileges).  On the first pass, we start at the position one after
the user namespace clearing the file descriptors as we close them
after calling setns().  If setns() fails on the first pass, ignore the
failure assuming that it will succeed after we enter the user
namespace.

Addresses: https://github.com/karelzak/util-linux/issues/315
Signed-off-by: James Bottomley <James.Bottomley@HansenPartnership.com>
Acked-by: "Eric W. Biederman" <ebiederm@xmission.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
9 years agogetopt: fix memory leaks and integer overflows [ASAN & valgrind]
Sami Kerola [Mon, 14 Mar 2016 21:06:30 +0000 (21:06 +0000)] 
getopt: fix memory leaks and integer overflows [ASAN & valgrind]

The getopt(1) is short living command, and one could argue ensuring all
allocations are freed at end of execution is waste of time.  There is a
point in that, but making test-suite runs to be less noisy with ASAN is also
nice as it encourages reading the errors when/if they happen.

Reviewed-by: Yuriy M. Kaminskiy <yumkam@gmail.com>
Reviewed-by: Karel Zak <kzak@redhat.com>
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
9 years agolib: avoid double free in loopdev.c
Sami Kerola [Sun, 3 Apr 2016 16:43:19 +0000 (17:43 +0100)] 
lib: avoid double free in loopdev.c

Found with scan-build.

Reviewed-by: Yuriy M. Kaminskiy <yumkam@gmail.com>
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
9 years agosetpwnam: fix memory leak
Sami Kerola [Sun, 3 Apr 2016 16:39:41 +0000 (17:39 +0100)] 
setpwnam: fix memory leak

Found with scan-build.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
9 years agolibmount: fix memory leak
Sami Kerola [Sun, 3 Apr 2016 16:34:53 +0000 (17:34 +0100)] 
libmount: fix memory leak

Found with scan-build.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
9 years agobuild-sys: test functions does not return void
Sami Kerola [Sun, 3 Apr 2016 16:31:42 +0000 (17:31 +0100)] 
build-sys: test functions does not return void

Found using scan-build.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
9 years agolibblkid: fix mistake in debug message
Karel Zak [Tue, 19 Apr 2016 10:45:00 +0000 (12:45 +0200)] 
libblkid: fix mistake in debug message

Signed-off-by: Karel Zak <kzak@redhat.com>
9 years agolibblkid: reduce probing area for crazy CDROMs
Karel Zak [Tue, 19 Apr 2016 10:39:05 +0000 (12:39 +0200)] 
libblkid: reduce probing area for crazy CDROMs

Linux kernel reports devices greater than area readable by read(2).
The readable area is usually 2-3 CD blocks smaller (CD block is
2048-bytes) than size returned by BLKGETSIZE. This patch checks for
this issues to avoid I/O errors in probing functions.

Reported-by: Thomas Schmitt <scdbackup@gmx.net>
Signed-off-by: Karel Zak <kzak@redhat.com>
9 years agolibblkid: make blkid_do_wipe() work with probes with offset
Petr Uzel [Mon, 18 Apr 2016 14:22:05 +0000 (16:22 +0200)] 
libblkid: make blkid_do_wipe() work with probes with offset

When a probe is created with an offset, e.g. via
blkid_probe_set_device(), this offset is correctly used when looking for
the signatures, but is not respected by blkid_do_wipe() function.
Therefore the signature is removed from an invalid location.

Usecase: Wiping signatures from an area on the block device where
partition is to be created (but as it does not exist yet, there's no
device node for it and probe on the whole block device has to be used
with correct offset and length).

Reproducer:
======================== wiper.c ===========================

const char *dev;
unsigned long offset;
unsigned long size;

int main(int argc, char** argv) {

        if (argc != 4) {
                printf("usage: wiper dev offset size\n");
                exit(1);
        }

        dev = argv[1];
        offset = strtoull(argv[2], NULL, 10);
        size = strtoull(argv[3], NULL, 10);

        printf("dev=%s, off=%llu, size=%llu\n", dev, offset, size);

        int fd = open (dev, O_RDWR);
        if (fd == -1) {
                perror("open");
                exit(1);
        }

        blkid_loff_t wipe_offset = offset * SECTOR_SIZE;
        blkid_loff_t wipe_size = size * SECTOR_SIZE;

        int ret;

        blkid_probe pr;
        pr = blkid_new_probe();
        if (!pr)
                return 0;
        ret = blkid_probe_set_device(pr, fd, wipe_offset, wipe_size);
        ret = blkid_probe_enable_superblocks(pr, 1);
        ret = blkid_probe_set_superblocks_flags(pr, BLKID_SUBLKS_MAGIC);

        while (blkid_do_probe(pr) == 0) {
                ret = blkid_do_wipe(pr, 0);
        }

        blkid_free_probe(pr);
        close(fd);
}
======================== wiper.c ===========================

Steps to reproduce:
modprobe scsi_debug
parted -s /dev/sdX mklabel gpt
parted -s /dev/sdX mkpart first 2048s 4095s
mkfs.ext2 /dev/sdX1

wipefs -np /dev/sdX1

./wiper /dev/sdX1 2048 2048

Actual result: wiper gets into endless loop, because
blkid_do_wipe() wipes at wrong location (1080), leaving the signature
on /dev/sdc1. So it is again found by blkid_do_probe(), and so on.

Expected result: wiper clears the ext2 signature at offset 1049656(=1080+2048*512).

Signed-off-by: Petr Uzel <petr.uzel@suse.cz>
9 years agopylibmount: include c.h
Karel Zak [Mon, 18 Apr 2016 11:19:12 +0000 (13:19 +0200)] 
pylibmount: include c.h

... for sys/sysmacros.h and major() and minor() macros.

Reported-by: Mike Frysinger <vapier@gentoo.org>
Signed-off-by: Karel Zak <kzak@redhat.com>
9 years agolosetup: fix outdated comment
Yuriy M. Kaminskiy [Wed, 13 Apr 2016 14:36:36 +0000 (17:36 +0300)] 
losetup: fix outdated comment

From abb2a420924c792be33aa3ed825b1348ea7d51a9 Mon Sep 17 00:00:00 2001
From: "Yuriy M. Kaminskiy" <yumkam@gmail.com>
Date: Wed, 13 Apr 2016 17:30:10 +0300
Subject: [PATCH] losetup: fix outdated comment

--direct-io argument was made optional by
f98d9641a371421640a8f1cfe497030758f86dca, but this comment was not
updated accordingly

Signed-off-by: Yuriy M. Kaminskiy <yumkam@gmail.com>
9 years agoMerge branch '2016wk15' of git://github.com/kerolasa/lelux-utiliteetit
Karel Zak [Mon, 18 Apr 2016 09:01:26 +0000 (11:01 +0200)] 
Merge branch '2016wk15' of git://github.com/kerolasa/lelux-utiliteetit

* '2016wk15' of git://github.com/kerolasa/lelux-utiliteetit:
  mount: try to tell what mount was doing when it failed
  dmesg: --notime should not suppress --show-delta
  script: check status of writes when closing outputs
  script: avoid trying fclose(NULL)
  sulogin: make fopen O_CLOEXEC specifier usage portable
  script: close file descriptors on exec
  docs: optinal option arguments should be long-only

9 years agomkswap: tolerate ENOTSUP when failing to relabel
Lubomir Rintel [Mon, 18 Apr 2016 07:01:23 +0000 (09:01 +0200)] 
mkswap: tolerate ENOTSUP when failing to relabel

It might be that the underlying filesystem just doesn't support SELinux
labeling. This fixes creating swap on vfat live media:

  # livecd-iso-to-disk.sh --msdos --swap-size-mb 666 ...

Signed-off-by: Lubomir Rintel <lkundrak@v3.sk>
9 years agomount: try to tell what mount was doing when it failed
Sami Kerola [Sat, 16 Apr 2016 18:05:58 +0000 (19:05 +0100)] 
mount: try to tell what mount was doing when it failed

Earlier output did not give enough information to system admin to fix an
issue in /etc/fstab effectively.

$ sudo mount -a
mount: mount(2) failed: No such file or directory

Addresses: https://bugs.launchpad.net/bugs/1557145
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
9 years agodmesg: --notime should not suppress --show-delta
Sami Kerola [Sat, 16 Apr 2016 17:35:02 +0000 (18:35 +0100)] 
dmesg: --notime should not suppress --show-delta

The --show-delta is off by default, which means it can be only on when user
has requested to see these time stamps.  The --notime option should not turn
the delta outputing off, because then option order matters and no-one wants
that.  Example of the old output:

$ dmesg --notime --show-delta | sed -n 's/ version.*//p; q'
[<    0.000000>] Linux
$ dmesg --show-delta --notime | sed -n 's/ version.*//p; q'
Linux

Addresses: https://bugs.launchpad.net/bugs/1544595
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
9 years agoscript: check status of writes when closing outputs
Sami Kerola [Sat, 16 Apr 2016 16:54:25 +0000 (17:54 +0100)] 
script: check status of writes when closing outputs

This should make possible output issues more obvious, for example when a
disk will get full.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
9 years agoscript: avoid trying fclose(NULL)
Sami Kerola [Sat, 16 Apr 2016 16:43:01 +0000 (17:43 +0100)] 
script: avoid trying fclose(NULL)

Here is a one-liner to reproduce the issue.

$ mkdir example && cd example && chmod 0500 . && script
Script started, file is typescript
script: cannot open typescript: Permission denied
                                                 Script done, file is typescript
Segmentation fault (core dumped)

Addresses: https://bugs.launchpad.net/bugs/1537518
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
9 years agosulogin: make fopen O_CLOEXEC specifier usage portable
Sami Kerola [Sat, 16 Apr 2016 14:43:17 +0000 (15:43 +0100)] 
sulogin: make fopen O_CLOEXEC specifier usage portable

The close at exit specifier "e" is glibc extension, so use it only if when
the extension is available.

Proposed-by: Ruediger Meier <sweet_f_a@gmx.de>
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
9 years agoscript: close file descriptors on exec
Sami Kerola [Sat, 2 Apr 2016 20:30:15 +0000 (21:30 +0100)] 
script: close file descriptors on exec

The commands spawned from script(1) will never need access various file
descriptors the script(1) is using.

Reviewed-by: Ruediger Meier <sweet_f_a@gmx.de>
Reviewed-by: Karel Zak <kzak@redhat.com>
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
9 years agodocs: optinal option arguments should be long-only
Sami Kerola [Sat, 16 Apr 2016 14:30:39 +0000 (15:30 +0100)] 
docs: optinal option arguments should be long-only

Deprecate adding new short optional option arguments.  They are problematic.

Proposed-by: Ruediger Meier <sweet_f_a@gmx.de>
Acked-by: Karel Zak <kzak@redhat.com>
Reviewed-by: Benno Schulenberg <bensberg@justemail.net>
Reference: https://lists.gnu.org/archive/html/coreutils/2012-11/msg00004.html
Reference: http://marc.info/?l=util-linux-ng&m=146062997618853&w=2
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
9 years agoflock: Introduce no-fork option.
Terry Burton [Thu, 14 Apr 2016 11:27:52 +0000 (12:27 +0100)] 
flock: Introduce no-fork option.

When guarding a command with flock it is sometimes preferable to not leave a
flock process waiting around for the command to exit.

9 years agolibmount: make kernel_fs_postparse() more robust
Karel Zak [Fri, 15 Apr 2016 12:48:29 +0000 (14:48 +0200)] 
libmount: make kernel_fs_postparse() more robust

Signed-off-by: Karel Zak <kzak@redhat.com>
9 years agolibmount: fix mnt_table_parse_stream() logic
Karel Zak [Fri, 15 Apr 2016 12:30:43 +0000 (14:30 +0200)] 
libmount: fix mnt_table_parse_stream() logic

Signed-off-by: Karel Zak <kzak@redhat.com>
9 years agotests: make tests more portable due to mtab
Karel Zak [Fri, 15 Apr 2016 12:10:23 +0000 (14:10 +0200)] 
tests: make tests more portable due to mtab

Signed-off-by: Karel Zak <kzak@redhat.com>
9 years agolibmount: fix mnt_table_parse_mtab() logic
Karel Zak [Fri, 15 Apr 2016 10:05:55 +0000 (12:05 +0200)] 
libmount: fix mnt_table_parse_mtab() logic

Signed-off-by: Karel Zak <kzak@redhat.com>
9 years agotests: remove USE_LIBMOUNT_FORCE_MOUNTINFO
Karel Zak [Fri, 15 Apr 2016 09:29:22 +0000 (11:29 +0200)] 
tests: remove USE_LIBMOUNT_FORCE_MOUNTINFO

Signed-off-by: Karel Zak <kzak@redhat.com>
9 years agoumount: add note about FS names differences to the man page
Karel Zak [Fri, 15 Apr 2016 08:47:12 +0000 (10:47 +0200)] 
umount: add note about FS names differences to the man page

Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=1327209
Signed-off-by: Karel Zak <kzak@redhat.com>
9 years agolibmount: don't support /etc/mtab by default
Karel Zak [Thu, 14 Apr 2016 12:26:54 +0000 (14:26 +0200)] 
libmount: don't support /etc/mtab by default

The file mtab is evil and already unused by mainstream distributions.

Now libmount is able to detect mtab->/proc/mounts and use
/proc/self/mountinfo if necessary. This heuristic seems overkill in
many cases. It's also dangerous on systems where mountinfo is strongly
required (systemd based distros).

This patch #ifdefs mtab code and forces libmount to always use
/proc/self/mountinfo.

The new configure option --enable-libmount-support-mtab is necessary
to enable old behavior to support mtab.

Signed-off-by: Karel Zak <kzak@redhat.com>
9 years agobuild-sys: add --enable-libuuid-force-uuidd
Ruediger Meier [Wed, 6 Apr 2016 13:43:07 +0000 (15:43 +0200)] 
build-sys: add --enable-libuuid-force-uuidd

To build libuuid with uuidd support even though the daemon is
disabled (--disable-uuidd).

Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
9 years agowipefs: force GPT detection
Karel Zak [Wed, 13 Apr 2016 12:41:47 +0000 (14:41 +0200)] 
wipefs: force GPT detection

The library libblkid (as well as fdisks) requires protective MBR when
probe for GPT by default.  This is unnecessary for wipefs where we're
more promiscuous and we want to delete as much as possible. This patch
enables BLKID_PARTS_FORCE_GPT for wipefs.

Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=1326474
Signed-off-by: Karel Zak <kzak@redhat.com>
9 years agobuild-sys: remove obsolete comment
Karel Zak [Fri, 8 Apr 2016 08:58:34 +0000 (10:58 +0200)] 
build-sys: remove obsolete comment

Signed-off-by: Karel Zak <kzak@redhat.com>
9 years agotests: don't depend on GNU md5sum
Ruediger Meier [Wed, 6 Apr 2016 10:30:18 +0000 (12:30 +0200)] 
tests: don't depend on GNU md5sum

Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
9 years agotests: test_md5 prints md5sum only
Ruediger Meier [Wed, 6 Apr 2016 10:30:17 +0000 (12:30 +0200)] 
tests: test_md5 prints md5sum only

We want to to use it for other tests without depending on
gnu md5sum and without cut or awk.

Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
9 years agochrt: validate priority before trying to use it
Sami Kerola [Sun, 3 Apr 2016 08:35:29 +0000 (09:35 +0100)] 
chrt: validate priority before trying to use it

Earlier message:

$ chrt -i 1 ls
chrt: failed to set pid 0's policy: Invalid argument

basically told 'something failed', while the new one tries to be more
helpful.

$ chrt -i 1 ls
chrt: unsupported priority value for the policy: 1: see --max for valid range

Addresses: https://bugs.debian.org/791707
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
9 years agocolcrt: avoid the command getting hung [afl]
Sami Kerola [Sat, 2 Apr 2016 15:58:14 +0000 (16:58 +0100)] 
colcrt: avoid the command getting hung [afl]

Some inputs make getwc(3) not to progress file descriptor and neither to
report EILSEQ.  Detect such situation and skip the bad input.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
9 years agolibmount: try absolute target before canonicalize
Karel Zak [Thu, 24 Mar 2016 10:51:12 +0000 (11:51 +0100)] 
libmount: try absolute target before canonicalize

The path canonicalization is expensive and in many cases unwanted due
to problems with readlink() on unreachable NFS and automounters.

This patch add a possibility to search also by $(CWD)/<path> if the
<path> is relative to reduce number of situation when we convert the
path to the canonical absolute path.

The common use-case:

# cd /some/long/path
# umount ./mountpoint

old version:

15543: libmount:      TAB: [0x560a99a54230]: lookup TARGET: './test'
15543: libmount:    CACHE: [0x560a99a54290]: canonicalize path ./test
15543: libmount:    CACHE: [0x560a99a54290]: add entry [ 1] (path): /mnt/test: ./test
15543: libmount:      TAB: [0x560a99a54230]: lookup canonical TARGET: '/mnt/test'
15543: libmount:      CXT: [0x560a99a54050]: umount fs: /mnt/test

new version:

15597: libmount:      TAB: [0xabf230]: lookup TARGET: './test'
15597: libmount:      TAB: [0xabf230]: lookup absolute TARGET: '/mnt/test'
15597: libmount:      CXT: [0xabf050]: umount fs: /mnt/test

Signed-off-by: Karel Zak <kzak@redhat.com>
9 years agoscript: use empty-slave heuristic more carefully
Karel Zak [Wed, 13 Apr 2016 09:52:43 +0000 (11:52 +0200)] 
script: use empty-slave heuristic more carefully

script(1) waits for empty slave FD (shell stdin) before it writes to
master. This feature has been intorduiced by 54c6611d6f7b73609a5331f4d0bcf63c4af6429e
to avoid misbehavior when we need to send EOF to the shell.

Unfortunately, this feature has been used all time for all messages.
This is wrong because command in the session (or shell) may ignore
stdin at all and wait forever in busy loop is really bad idea. Test
case:

 script /dev/null
 tailf /etc/passwd
 <enter>
 <enter>

... script process taking 100% CPU.

This patch forces script to use empty-stave detection only when we
need to write EOF. The busy loop has been modified to use nanosleep
and it does not wait forever...

Addresses: http://bugs.debian.org/820843
Signed-off-by: Karel Zak <kzak@redhat.com>
9 years agobuild-sys: release++ (v2.28) v2.28
Karel Zak [Tue, 12 Apr 2016 10:33:03 +0000 (12:33 +0200)] 
build-sys: release++ (v2.28)

Signed-off-by: Karel Zak <kzak@redhat.com>
9 years agodocs: update v2.28-ReleaseNotes
Karel Zak [Tue, 12 Apr 2016 10:31:56 +0000 (12:31 +0200)] 
docs: update v2.28-ReleaseNotes

Signed-off-by: Karel Zak <kzak@redhat.com>
9 years agodocs: update AUTHORS file
Karel Zak [Tue, 12 Apr 2016 10:30:40 +0000 (12:30 +0200)] 
docs: update AUTHORS file

Signed-off-by: Karel Zak <kzak@redhat.com>
9 years agopo: merge changes
Karel Zak [Tue, 12 Apr 2016 10:29:25 +0000 (12:29 +0200)] 
po: merge changes

Signed-off-by: Karel Zak <kzak@redhat.com>