]> git.ipfire.org Git - thirdparty/util-linux.git/log
thirdparty/util-linux.git
9 years agolibsmartcols: add scols_table_print_range()
Karel Zak [Fri, 19 Feb 2016 13:43:06 +0000 (14:43 +0100)] 
libsmartcols: add scols_table_print_range()

Signed-off-by: Karel Zak <kzak@redhat.com>
9 years agohwclock: use labs() for long
Karel Zak [Fri, 19 Feb 2016 10:38:04 +0000 (11:38 +0100)] 
hwclock: use labs() for long

Signed-off-by: Karel Zak <kzak@redhat.com>
9 years agoMerge branch 'port-osx' of https://github.com/rudimeier/util-linux
Karel Zak [Fri, 19 Feb 2016 10:30:53 +0000 (11:30 +0100)] 
Merge branch 'port-osx' of https://github.com/rudimeier/util-linux

* 'port-osx' of https://github.com/rudimeier/util-linux:
  include: fix sys/sysinfo.h
  libblkid: don't include endian.h
  lib: fix ismounted includes for FreeBSD
  lib: remove unused variable
  lsns: use xcalloc()
  include: remove unused mntent.h
  include: check for sys/sysmacros.h
  lib: define LOGIN_NAME_MAX fallback
  include: provide MAP_ANONYMOUS on OSX
  lib: rename strmode() and setmode()
  tests: fix ts_option helpers
  build-sys: fix [g]libtoolize version for OSX
  build-sys: check linker support for version scripts
  build-sys: portable usage of find command
  travis: minor cleanup

9 years agoinclude: fix sys/sysinfo.h
Ruediger Meier [Thu, 18 Feb 2016 02:18:38 +0000 (03:18 +0100)] 
include: fix sys/sysinfo.h

Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
9 years agolibblkid: don't include endian.h
Ruediger Meier [Wed, 17 Feb 2016 22:44:04 +0000 (23:44 +0100)] 
libblkid: don't include endian.h

Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
9 years agolib: fix ismounted includes for FreeBSD
Ruediger Meier [Wed, 17 Feb 2016 22:28:52 +0000 (23:28 +0100)] 
lib: fix ismounted includes for FreeBSD

Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
9 years agolib: remove unused variable
Ruediger Meier [Wed, 17 Feb 2016 21:46:11 +0000 (22:46 +0100)] 
lib: remove unused variable

Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
9 years agolsns: use xcalloc()
Ruediger Meier [Wed, 17 Feb 2016 19:58:23 +0000 (20:58 +0100)] 
lsns: use xcalloc()

... found by tools/checkxalloc.sh

Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
9 years agoinclude: remove unused mntent.h
Ruediger Meier [Wed, 17 Feb 2016 18:43:41 +0000 (19:43 +0100)] 
include: remove unused mntent.h

Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
9 years agoinclude: check for sys/sysmacros.h
Ruediger Meier [Wed, 17 Feb 2016 17:52:10 +0000 (18:52 +0100)] 
include: check for sys/sysmacros.h

Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
9 years agolib: define LOGIN_NAME_MAX fallback
Ruediger Meier [Sun, 7 Feb 2016 13:10:27 +0000 (14:10 +0100)] 
lib: define LOGIN_NAME_MAX fallback

LOGIN_NAME_MAX was unused in misc-utils/namei.c since 04a5cb58.

Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
9 years agoinclude: provide MAP_ANONYMOUS on OSX
Ruediger Meier [Thu, 18 Feb 2016 15:37:13 +0000 (16:37 +0100)] 
include: provide MAP_ANONYMOUS on OSX

Hope there are no side effect when defining _DARWIN_C_SOURCE
globally.

Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
9 years agolibfdisk: fix typo
Karel Zak [Thu, 18 Feb 2016 13:23:37 +0000 (14:23 +0100)] 
libfdisk: fix typo

Signed-off-by: Karel Zak <kzak@redhat.com>
9 years agocfdisk: wipe device if create a new label
Karel Zak [Thu, 18 Feb 2016 11:57:31 +0000 (12:57 +0100)] 
cfdisk: wipe device if create a new label

Signed-off-by: Karel Zak <kzak@redhat.com>
9 years agosfdisk: add --wipe
Karel Zak [Thu, 18 Feb 2016 11:57:13 +0000 (12:57 +0100)] 
sfdisk: add --wipe

This patch changes sfdisk behavior and it wipes foreign signatures
from the device to avoid collisions. The wipe functionality is
automatically enabled in the interactive mode only (user is always
warned about it), otherwise it's possible to control all by --wipe
<auto|never|always>.

The program does not change behavior when executed in scripts (echo
<something> | sfdisk), the option "--wipe=always" is required to enable
in this case.

Signed-off-by: Karel Zak <kzak@redhat.com>
9 years agofdisk: add --wipe
Karel Zak [Thu, 18 Feb 2016 11:50:11 +0000 (12:50 +0100)] 
fdisk: add --wipe

This patch changes fdisk behavior and it wipes foreign signatures
from the device to avoid collisions. The wipe functionality is
automatically enabled in the interactive mode only (user is always
warned about it), otherwise it's possible to control all by --wipe
<auto|never|always>.

The program does not change behavior when executed in scripts (echo
<something> | fdisk), the option "--wipe=always" is required to enable
in this case.

Signed-off-by: Karel Zak <kzak@redhat.com>
9 years agolibfdisk: add API to control signatures wiping
Karel Zak [Thu, 18 Feb 2016 11:42:06 +0000 (12:42 +0100)] 
libfdisk: add API to control signatures wiping

Now libfdisk warns if another filesystem/RAID/PT signature is detected
on the device. It seems better and user-friendly to make it possible to
wipe the signatures when we write a new disk label to the device.

This patch adds to the library API

fdisk_enable_wipe()
fdisk_has_wipe()
fdisk_get_collision()

to control this new feature. The device modification is done by
libblkid (the same we use in some mkfs-like utils).

Signed-off-by: Karel Zak <kzak@redhat.com>
9 years agolib: rename strmode() and setmode()
Ruediger Meier [Sun, 7 Feb 2016 11:59:57 +0000 (12:59 +0100)] 
lib: rename strmode() and setmode()

On BSD they are part of the standard C library.

Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
9 years agotests: fix ts_option helpers
Ruediger Meier [Wed, 17 Feb 2016 14:01:21 +0000 (15:01 +0100)] 
tests: fix ts_option helpers

These two problems should be fixed now:
  - BSD awk only accepts 1-char field seperator
  - ts_has_option() did not returned "yes" if an option was given
    multiple times

Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
9 years agobuild-sys: fix [g]libtoolize version for OSX
Ruediger Meier [Thu, 18 Feb 2016 00:21:57 +0000 (01:21 +0100)] 
build-sys: fix [g]libtoolize version for OSX

follow-up 0024583c

Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
9 years agobuild-sys: check linker support for version scripts
Ruediger Meier [Wed, 17 Feb 2016 16:37:41 +0000 (17:37 +0100)] 
build-sys: check linker support for version scripts

The macro AX_CHECK_VSCRIPT was taken from gnu autoconf archive.
http://www.gnu.org/software/autoconf-archive/

Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
9 years agobuild-sys: portable usage of find command
Ruediger Meier [Wed, 17 Feb 2016 12:03:11 +0000 (13:03 +0100)] 
build-sys: portable usage of find command

 - use dot instead of skipping search-path
 - avoid -perm /a+x
 - avoid -path

Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
9 years agotravis: minor cleanup
Ruediger Meier [Mon, 15 Feb 2016 17:15:58 +0000 (18:15 +0100)] 
travis: minor cleanup

 - print env for debugging
 - remove unused builddir stuff
 - avoid non-portable find/xargs usage

Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
9 years agounshare: fix busyloop and reduce racing probability
Yuriy M. Kaminskiy [Sat, 30 Jan 2016 13:18:39 +0000 (16:18 +0300)] 
unshare: fix busyloop and reduce racing probability

Replace busy-loop with waiting on pipe from parent.

Note: reduces racing probability, but still there are window where
it is possible (if parent unshare process will be [externally] killed
between successful read(fds[0]) and mount() calls).

[kzak@redhat.com: - use all-io.h to avoid loops around write() and read(),
                  - use less generic 0x06 byte to sync parent and child]

Signed-off-by: Yuriy M. Kaminskiy <yumkam@gmail.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
9 years agoagetty: support \e{name} for issue file
Karel Zak [Wed, 17 Feb 2016 11:53:20 +0000 (12:53 +0100)] 
agetty: support \e{name} for issue file

Signed-off-by: Karel Zak <kzak@redhat.com>
9 years agolib/color: add more ESC seq.
Karel Zak [Wed, 17 Feb 2016 11:17:23 +0000 (12:17 +0100)] 
lib/color: add more ESC seq.

Signed-off-by: Karel Zak <kzak@redhat.com>
9 years agohwclock.c, hwclock.8.in: new --show format
J William Piggott [Wed, 17 Feb 2016 00:28:36 +0000 (19:28 -0500)] 
hwclock.c, hwclock.8.in: new --show format

* hwclock.c: change --get and --show functions to the ISO 8601
  format and concatenate fractional seconds to the time display.

* hwclock.8.in: document this.

Signed-off-by: J William Piggott <elseifthen@gmx.com>
9 years agoMerge branch 'wrap_padding' of https://github.com/ignatenkobrain/util-linux
Karel Zak [Tue, 16 Feb 2016 15:14:52 +0000 (16:14 +0100)] 
Merge branch 'wrap_padding' of https://github.com/ignatenkobrain/util-linux

9 years agolibmount: fix mnt_table_is_fs_mounted() loopdev use
Karel Zak [Tue, 16 Feb 2016 14:44:31 +0000 (15:44 +0100)] 
libmount: fix mnt_table_is_fs_mounted() loopdev use

The function does not detect already mounted loop devices on systems
with regular /etc/mtab file.

The patch also improves test_is_mounted() to be useful with mtab.

Reported-by: Ruediger Meier <sweet_f_a@gmx.de>
Signed-off-by: Karel Zak <kzak@redhat.com>
9 years agolibmount: add loop to debug output
Karel Zak [Tue, 16 Feb 2016 14:03:22 +0000 (15:03 +0100)] 
libmount: add loop to debug output

Signed-off-by: Karel Zak <kzak@redhat.com>
9 years agolibsmartcols: fill wrapped lines with space instead of 'x'
Igor Gnatenko [Tue, 16 Feb 2016 11:57:55 +0000 (12:57 +0100)] 
libsmartcols: fill wrapped lines with space instead of 'x'

Signed-off-by: Igor Gnatenko <i.gnatenko.brain@gmail.com>
9 years agobuild-sys: use $PKG_CONFIG
Karel Zak [Tue, 16 Feb 2016 09:27:56 +0000 (10:27 +0100)] 
build-sys: use $PKG_CONFIG

Reported-by: Helmut Grohne <helmut@subdivi.de>
References: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=811546
Signed-off-by: Karel Zak <kzak@redhat.com>
9 years agosu: clean up groups initialization
Karel Zak [Mon, 15 Feb 2016 12:55:37 +0000 (13:55 +0100)] 
su: clean up groups initialization

This patch does not change any su/runuser behaviour, code changes:

* don't use huge groups[NGROUPS_MAX]; the array has 256k, but we need
  it only occasionally when -G/-g specified.

* the current code uses groups[0] for -g and the rest for -G, this patch adds
  'gid' to remember -g argument to avoid memmove()

* add function add_supp_group() to simplify su_main()

* add note about -G and -g relation to the man pages (undocumented now)

Signed-off-by: Karel Zak <kzak@redhat.com>
9 years agolibsmartcols: print title only with SCOLS_FMT_HUMAN
Igor Gnatenko [Sat, 13 Feb 2016 15:13:04 +0000 (16:13 +0100)] 
libsmartcols: print title only with SCOLS_FMT_HUMAN

Reference: https://github.com/karelzak/util-linux/issues/279
Signed-off-by: Igor Gnatenko <i.gnatenko.brain@gmail.com>
9 years agotests: mkfs.ext3 image-file needs option -F
Ruediger Meier [Fri, 12 Feb 2016 16:28:04 +0000 (17:28 +0100)] 
tests: mkfs.ext3 image-file needs option -F

Maybe on newer systems it's not needed anymore.

CC: Stanislav Brabec <sbrabec@suse.cz>
Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
9 years agomisc: always cast timeval.tv_usec to long rather than int
Ruediger Meier [Fri, 12 Feb 2016 13:30:52 +0000 (14:30 +0100)] 
misc: always cast timeval.tv_usec to long rather than int

Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
9 years agotravis: install mdadm
Ruediger Meier [Tue, 9 Feb 2016 21:12:51 +0000 (22:12 +0100)] 
travis: install mdadm

Travis build host is able to load kernel modules nowadays!

Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
9 years agotests: disable eject for broken kernels
Ruediger Meier [Wed, 10 Feb 2016 22:29:42 +0000 (23:29 +0100)] 
tests: disable eject for broken kernels

Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
9 years agotests: add some check_test_command requirements
Ruediger Meier [Tue, 9 Feb 2016 15:24:25 +0000 (16:24 +0100)] 
tests: add some check_test_command requirements

Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
9 years agomisc-utils: build test_uuidd only if BUILD_UUIDD
Ruediger Meier [Mon, 8 Feb 2016 12:53:17 +0000 (13:53 +0100)] 
misc-utils: build test_uuidd only if BUILD_UUIDD

Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
9 years agobuild-sys: fix libtoolize for OSX
Ruediger Meier [Sun, 7 Feb 2016 10:01:22 +0000 (11:01 +0100)] 
build-sys: fix libtoolize for OSX

autoreconf would also call glibtoolize on Darwin.

Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
9 years agoMerge branch 'compiler-warnings' of https://github.com/rudimeier/util-linux
Karel Zak [Fri, 12 Feb 2016 12:35:18 +0000 (13:35 +0100)] 
Merge branch 'compiler-warnings' of https://github.com/rudimeier/util-linux

* 'compiler-warnings' of https://github.com/rudimeier/util-linux:
  exec_shell: prevent basename from modifying env
  lib/path: ifdef path_set_prefix() like in path.h
  lib: fix unused parameters and variables
  misc: fix some printf format strings
  include: add missing includes
  ipcs:  ulong -> unsigned long
  libcommon: don't include sysinfo.h

9 years agoMerge branch 'travis2' of https://github.com/filbranden/util-linux
Karel Zak [Fri, 12 Feb 2016 12:15:25 +0000 (13:15 +0100)] 
Merge branch 'travis2' of https://github.com/filbranden/util-linux

9 years agoMerge branch 'test-fixes' of https://github.com/rudimeier/util-linux
Karel Zak [Fri, 12 Feb 2016 12:15:00 +0000 (13:15 +0100)] 
Merge branch 'test-fixes' of https://github.com/rudimeier/util-linux

* 'test-fixes' of https://github.com/rudimeier/util-linux:
  tests: ts_fdisk_clean(), remove optimal iosize
  tests: minor cleanup ts_fdisk_clean()

9 years agolibmount: fix memleak in mnt_pretty_path()
Karel Zak [Fri, 12 Feb 2016 12:09:28 +0000 (13:09 +0100)] 
libmount: fix memleak in mnt_pretty_path()

References: https://github.com/karelzak/util-linux/issues/275
Signed-off-by: Karel Zak <kzak@redhat.com>
9 years agosulogin: keep initialization more robust
Karel Zak [Fri, 12 Feb 2016 10:21:50 +0000 (11:21 +0100)] 
sulogin: keep initialization more robust

Signed-off-by: Karel Zak <kzak@redhat.com>
9 years agosulogin: avoid shared memory area usemask but use waitid() for childs
Werner Fink [Thu, 11 Feb 2016 12:35:26 +0000 (13:35 +0100)] 
sulogin: avoid shared memory area usemask but use waitid() for childs

This small patch improves the console detection code and also avoids not
existing device nodes due strdup() which is used in canonicalize_path().
Beside this now the code for emergeny mount does work if enabled at
configure time.

Signed-off-by: Werner Fink <werner@suse.de>
9 years agotests: add test for loop option in fstab
Stanislav Brabec [Thu, 11 Feb 2016 19:45:56 +0000 (20:45 +0100)] 
tests: add test for loop option in fstab

Add a new fstab tests which check loop mount of the same source multiple times
in multiple steps.

The test is currently failing, but it should not fail once the triggering bug
will be fixed.

Signed-off-by: Stanislav Brabec <sbrabec@suse.cz>
9 years agolibmount: fix mnt_table_is_fs_mounted() for loopdev
Karel Zak [Fri, 12 Feb 2016 10:03:32 +0000 (11:03 +0100)] 
libmount: fix mnt_table_is_fs_mounted() for loopdev

Reported-by: Stanislav Brabec <sbrabec@suse.cz>
Signed-off-by: Karel Zak <kzak@redhat.com>
9 years agotests: fix redirection
Stanislav Brabec [Thu, 11 Feb 2016 19:40:29 +0000 (20:40 +0100)] 
tests: fix redirection

Many tests do.
2>&1 >> $TS_OUTPUT
It redirects stdout to $TS_OUTPUT and stderr to stdout.

It could cause unintended ignoring of errors on strerr and false positive result
of the test.

Use
>> $TS_OUTPUT 2>&1
instead to redirect both stdout and stderr to $TS_OUTPUT.

Automatically created by:
cd tests/ts
sed -i 's:2>\&1 >> \$TS_OUTPUT:>> $TS_OUTPUT 2>\&1:g' $(fgrep -rl '2>&1 >> $TS_OUTPUT' .)

Signed-off-by: Stanislav Brabec <sbrabec@suse.cz>
9 years agotests: add btrfs mount tests
Stanislav Brabec [Thu, 11 Feb 2016 18:07:22 +0000 (19:07 +0100)] 
tests: add btrfs mount tests

btrfs needs a special support in mount. Add a testcase for btrfs specific
problems.

Coverage:
352740e8: bind mounts pointing to btrfs
2cd28fc8: mounting default subvolume
d2f82678: use of "auto"
618a8814: use of "subvolid"

Signed-off-by: Stanislav Brabec <sbrabec@suse.cz>
9 years agoexec_shell: prevent basename from modifying env
Ruediger Meier [Thu, 11 Feb 2016 02:45:11 +0000 (03:45 +0100)] 
exec_shell: prevent basename from modifying env

Fix warning:
passing 'const char *' to parameter of type 'char *' discards
qualifiers [-Wincompatible-pointer-types-discards-qualifiers]

Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
9 years agolib/path: ifdef path_set_prefix() like in path.h
Ruediger Meier [Thu, 11 Feb 2016 02:15:12 +0000 (03:15 +0100)] 
lib/path: ifdef path_set_prefix() like in path.h

Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
9 years agolib: fix unused parameters and variables
Ruediger Meier [Thu, 11 Feb 2016 01:58:03 +0000 (02:58 +0100)] 
lib: fix unused parameters and variables

Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
9 years agomisc: fix some printf format strings
Ruediger Meier [Tue, 9 Feb 2016 17:08:56 +0000 (18:08 +0100)] 
misc: fix some printf format strings

Fix the warnings below for OSX clang and add a few more
casts for timeval:

lib/at.c:131:27: warning: format specifies type 'intmax_t' (aka 'long') but the argument has type 'off_t' (aka 'long long') [-Wformat]

                        printf("%16jd bytes ", st.st_size);

                                ~~~~~          ^~~~~~~~~~

lib/strutils.c:522:52: warning: format specifies type 'intmax_t' (aka 'long') but the argument has type 'uint64_t' (aka 'unsigned long long') [-Wformat]

                snprintf(buf, sizeof(buf), "%d%s%jd%s", dec, dp, frac, suffix);

                                                ~~~              ^~~~

lib/sysfs.c:468:42: warning: format specifies type 'uintmax_t' (aka 'unsigned long') but the argument has type 'uint64_t' (aka 'unsigned long long') [-Wformat]

        len = snprintf(buf, sizeof(buf), "%ju", num);

                                          ~~~   ^~~

libuuid/src/gen_uuid.c:316:34: warning: format specifies type 'unsigned long' but the argument has type '__darwin_suseconds_t' (aka 'int') [-Wformat]

                              clock_seq, last.tv_sec, last.tv_usec, adjustment);

                                                      ^~~~~~~~~~~~

Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
9 years agoagetty: add support for \e in issue file to print \033
Karel Zak [Thu, 11 Feb 2016 11:33:57 +0000 (12:33 +0100)] 
agetty: add support for \e in issue file to print \033

Suggested-by: Victor Ananjevsky <ananasik@gmail.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
9 years agoinclude: add missing includes
Ruediger Meier [Tue, 9 Feb 2016 11:52:20 +0000 (12:52 +0100)] 
include: add missing includes

lib/pager.c: signal.h ... raise(3p)
lib/sysfs.c: libgen.h ... basename(3p)
lib/exec_shell.c: libgen.h ... basename(3p)

Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
9 years agoipcs: ulong -> unsigned long
Ruediger Meier [Mon, 8 Feb 2016 14:38:48 +0000 (15:38 +0100)] 
ipcs:  ulong -> unsigned long

Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
9 years agolibcommon: don't include sysinfo.h
Ruediger Meier [Mon, 8 Feb 2016 12:29:25 +0000 (13:29 +0100)] 
libcommon: don't include sysinfo.h

It was added in 929f939e but should have been removed again
in 08ca3e26.

Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
9 years agocolcrt: minor cosmetic changes
Karel Zak [Thu, 11 Feb 2016 11:21:14 +0000 (12:21 +0100)] 
colcrt: minor cosmetic changes

Signed-off-by: Karel Zak <kzak@redhat.com>
9 years agoswapon: drop perms if setuid before call mkswap
Karel Zak [Thu, 11 Feb 2016 11:07:34 +0000 (12:07 +0100)] 
swapon: drop perms if setuid before call mkswap

Signed-off-by: Karel Zak <kzak@redhat.com>
9 years agoMerge branch 'colcrt' of git://github.com/kerolasa/lelux-utiliteetit
Karel Zak [Thu, 11 Feb 2016 10:59:58 +0000 (11:59 +0100)] 
Merge branch 'colcrt' of git://github.com/kerolasa/lelux-utiliteetit

* 'colcrt' of git://github.com/kerolasa/lelux-utiliteetit:
  tests: update colcrt test expectations
  colcrt: reimplementation
  tests: add colcrt functional tests

9 years agoswapon: simplify ctl->device usage
Karel Zak [Thu, 11 Feb 2016 10:39:16 +0000 (11:39 +0100)] 
swapon: simplify ctl->device usage

* use and initialize ctl->{label,uuid,device} by do_swapon() only
* remove ctl->canonic, function arguments are good enough for this

Signed-off-by: Karel Zak <kzak@redhat.com>
9 years agoswapon: do not run execvp() calls when swapon is setuid binary
Sami Kerola [Tue, 2 Feb 2016 13:40:10 +0000 (13:40 +0000)] 
swapon: do not run execvp() calls when swapon is setuid binary

swapon(8) is not expected to be setuid binary, but if it is try to avoid
obvious security vulnerability of executing user preferred mkswap file as
someone else, such as root.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
9 years agoswapon: move function arguments to control structure
Sami Kerola [Tue, 2 Feb 2016 13:40:09 +0000 (13:40 +0000)] 
swapon: move function arguments to control structure

This makes reading what the code does easier.  This change also makes error
messages to prefer none-canonical device path, e.g., the one user supplied
rather than the canonical path needed internally.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
9 years agoswapon: add control struct
Sami Kerola [Tue, 2 Feb 2016 13:40:08 +0000 (13:40 +0000)] 
swapon: add control struct

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
9 years agotests: ts_fdisk_clean(), remove optimal iosize
Ruediger Meier [Wed, 3 Feb 2016 23:58:04 +0000 (00:58 +0100)] 
tests: ts_fdisk_clean(), remove optimal iosize

It's a pity a pity that we have to remove it. In past our test suite
could discover a kernel bug (4.4). But now they've changed optimal
iosizes on purpose.

Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
9 years agotests: minor cleanup ts_fdisk_clean()
Ruediger Meier [Wed, 3 Feb 2016 22:44:42 +0000 (23:44 +0100)] 
tests: minor cleanup ts_fdisk_clean()

Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
9 years agobuild-sys: remove AM_CONDITIONAL from UL_CHECK_SYSCALL
Karel Zak [Wed, 10 Feb 2016 15:59:41 +0000 (16:59 +0100)] 
build-sys: remove AM_CONDITIONAL from UL_CHECK_SYSCALL

Unused, unnecessary, wrong.

Reported-by: J William Piggott <elseifthen@gmx.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
9 years agolibsmartcols: rewrite ./sample-scols-wrap
Karel Zak [Wed, 10 Feb 2016 14:37:30 +0000 (15:37 +0100)] 
libsmartcols: rewrite ./sample-scols-wrap

Signed-off-by: Karel Zak <kzak@redhat.com>
9 years agolibsmartcols: support multi-line cells
Karel Zak [Wed, 10 Feb 2016 14:25:38 +0000 (15:25 +0100)] 
libsmartcols: support multi-line cells

The initial implementation has been introduced by SCOLS_FL_WRAP columns,
but this patch clean ups all and makes things more elegant.

Note that use SCOLS_FL_TREE | SCOLS_FL_WRAP for a column is bad idea
and I don't think we need to fix it.

References: https://github.com/karelzak/util-linux/issues/269
Signed-off-by: Karel Zak <kzak@redhat.com>
9 years agotravis: Remove workaround for libtool install of pylibmount
Filipe Brandenburger [Tue, 9 Feb 2016 23:13:43 +0000 (15:13 -0800)] 
travis: Remove workaround for libtool install of pylibmount

Commit 324330aca6443d ("build-sys: Properly order install dependencies
of pylibmount") introduces a proper make dependency for the install
rules, in a way that the workaround is no longer necessary.

Tested that a PR with this commit passes Travis-CI.

Signed-off-by: Filipe Brandenburger <filbranden@google.com>
9 years agolibsmartcols: use libscols_cell for title
Karel Zak [Tue, 9 Feb 2016 10:21:21 +0000 (11:21 +0100)] 
libsmartcols: use libscols_cell for title

References: https://github.com/karelzak/util-linux/issues/270
Signed-off-by: Karel Zak <kzak@redhat.com>
9 years agolibfdisk: add missing break
Karel Zak [Tue, 9 Feb 2016 09:04:36 +0000 (10:04 +0100)] 
libfdisk: add missing break

Signed-off-by: Karel Zak <kzak@redhat.com>
9 years agoMerge branch 'pylibmount_dependency' of https://github.com/filbranden/util-linux
Karel Zak [Tue, 9 Feb 2016 08:57:48 +0000 (09:57 +0100)] 
Merge branch 'pylibmount_dependency' of https://github.com/filbranden/util-linux

9 years agosfdisk: add ESP shortcut also for Legacy MBR
Karel Zak [Mon, 8 Feb 2016 15:34:14 +0000 (16:34 +0100)] 
sfdisk: add ESP shortcut also for Legacy MBR

References: https://github.com/karelzak/util-linux/issues/267
Signed-off-by: Karel Zak <kzak@redhat.com>
9 years agobuild-sys: Properly order install dependencies of pylibmount
Filipe Brandenburger [Fri, 5 Feb 2016 18:13:40 +0000 (10:13 -0800)] 
build-sys: Properly order install dependencies of pylibmount

Introduce a dependency so that libmount.so is installed before
pylibmount.so, so that when libtool tries to relink it, it can find
libmount.so in the destdir.

We introduce this additional make rule through an AC_SUBST variable, to
prevent automake from trying to interpret that.  This trick has been
suggested in http://stackoverflow.com/a/8643550.

This fixes a failure of `make install DESTDIR=...` when trying to relink
pylibmount against libmount.la.  libtool will look for libmount.so under
${DESTDIR}/${libdir} in that case, but if it is not yet present there,
libtool assumes it is a system installed library and use -lmount
instead, which causes the following failure if libmount is not installed
on the base system yet:

  libtool: install: warning: relinking `pylibmount.la'
  libtool: install: (... libtool --mode=relink gcc -o pylibmount.la \
        -rpath /usr/lib/python2.7/dist-packages/libmount \
        libmount/python/*.lo libmount.la ... -lpython2.7 \
        -inst-prefix-dir /path/to/destdir)
  /usr/bin/ld: cannot find -lmount
  collect2: error: ld returned 1 exit status
  libtool: install: error: relink `pylibmount.la' ...
  make[3]: *** [install-pylibmountexecLTLIBRARIES] Error 1

This seems to be a previously encountered issue, since automake includes
a hack to insert such a dependency rule to install all libLTLIBRARIES
before attempting to install binPROGRAMS, initially introduced in the
commit below:
http://git.savannah.gnu.org/cgit/automake.git/commit/?id=bd4a1d5ad1a72fa780a8b7fd6c365a5dad2e6220

Also related bug from Ubuntu tracker:
https://bugs.launchpad.net/ubuntu/+source/util-linux/+bug/1442076

Tested that `make install` starts working again after this commit, even
when libmount-dev is not installed on the system.  Also confirmed that
`make distcheck` is now functional.

Confirmed that the all the files expected in the Python directory (both
__init__.py and pylibmount.so) are present after an install.

Tested that parallel install works, the dependency is always respected
since it's explicit.

Inspected the generated Makefile and confirmed that the definition of
install-pylibmountexecLTLIBRARIES (generated by automake) and the
explicit dependency we introduced are both present.

Signed-off-by: Filipe Brandenburger <filbranden@google.com>
9 years agoRevert "build-sys: Order pylibmount after usrlib on install"
Filipe Brandenburger [Fri, 5 Feb 2016 18:08:50 +0000 (10:08 -0800)] 
Revert "build-sys: Order pylibmount after usrlib on install"

This reverts commit e61f406913fb9356aed013da7ece34e73929cff6.

9 years agoMerge branch 'master' of https://github.com/rudimeier/util-linux
Karel Zak [Thu, 4 Feb 2016 15:02:17 +0000 (16:02 +0100)] 
Merge branch 'master' of https://github.com/rudimeier/util-linux

* 'master' of https://github.com/rudimeier/util-linux:
  script: fix misspelling
  docs: fix typos found by codespell

9 years agoscript: fix misspelling
Ruediger Meier [Wed, 3 Feb 2016 15:34:12 +0000 (16:34 +0100)] 
script: fix misspelling

9 years agodocs: fix typos found by codespell
Ruediger Meier [Wed, 3 Feb 2016 14:00:37 +0000 (15:00 +0100)] 
docs: fix typos found by codespell

Using "codespell" from https://github.com/lucasdemarchi/codespell

Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
9 years agofdisk: make 'f' command more verbose
Karel Zak [Wed, 3 Feb 2016 12:40:25 +0000 (13:40 +0100)] 
fdisk: make 'f' command more verbose

Signed-off-by: Karel Zak <kzak@redhat.com>
9 years agotests: update colcrt test expectations
Sami Kerola [Sat, 3 Oct 2015 22:39:33 +0000 (23:39 +0100)] 
tests: update colcrt test expectations

The reimplementation caused output to change in some corner cases, such as
how binary inputs, long lines with underscores, and white space trimming,
are handled.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
9 years agocolcrt: reimplementation
Sami Kerola [Wed, 23 Sep 2015 08:42:58 +0000 (09:42 +0100)] 
colcrt: reimplementation

This implementation aims to be easier to read, more robust dealing all sorts
of unexpected inputs, and possibly even more correct.  The correctness
refers to last line handling this implementation does differently than the
previous.  With the previous last line that ended to EOF without \n was not
printed.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
9 years agotests: add colcrt functional tests
Sami Kerola [Tue, 22 Sep 2015 09:40:13 +0000 (10:40 +0100)] 
tests: add colcrt functional tests

Output formats are based on colcrt before recent asan fixes and magic
constant replace, that are the commits ee24ab6f1..70e3fcf29.  It seems the
fixes caused unintentional, and not detected change to output format - which
to me means colcrt has a regression that got to be part of release v2.27.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
9 years agosfdisk: make --quiet really quiet
Karel Zak [Mon, 1 Feb 2016 13:30:31 +0000 (14:30 +0100)] 
sfdisk: make --quiet really quiet

References: https://github.com/karelzak/util-linux/issues/268
Signed-off-by: Karel Zak <kzak@redhat.com>
9 years agosfdisk: add 'U' shortcut for ESP
Karel Zak [Mon, 1 Feb 2016 13:08:04 +0000 (14:08 +0100)] 
sfdisk: add 'U' shortcut for ESP

 echo -e ',512M,U\n,,L' | sfdisk --label gpt /dev/foo

to make ESP system partition.

References: https://github.com/karelzak/util-linux/issues/267
Signed-off-by: Karel Zak <kzak@redhat.com>
9 years agohwclock: remove extra space from --show output
Karel Zak [Mon, 1 Feb 2016 12:43:22 +0000 (13:43 +0100)] 
hwclock: remove extra space from --show output

Signed-off-by: Karel Zak <kzak@redhat.com>
9 years agoMerge branch 'master' of https://github.com/annajonna/util-linux
Karel Zak [Mon, 1 Feb 2016 12:39:48 +0000 (13:39 +0100)] 
Merge branch 'master' of https://github.com/annajonna/util-linux

9 years agolibmount: move btrfs subvol code refactoring
Karel Zak [Mon, 1 Feb 2016 12:10:33 +0000 (13:10 +0100)] 
libmount: move btrfs subvol code refactoring

Signed-off-by: Karel Zak <kzak@redhat.com>
9 years agolibmount: fix target resolving for btrfs stuff
Karel Zak [Mon, 1 Feb 2016 11:36:07 +0000 (12:36 +0100)] 
libmount: fix target resolving for btrfs stuff

and make the code more verbose.

Signed-off-by: Karel Zak <kzak@redhat.com>
9 years agolibmount: code re-indentation
Stanislav Brabec [Wed, 27 Jan 2016 20:37:29 +0000 (21:37 +0100)] 
libmount: code re-indentation

For easier review, the fix of libmount comes in two patches:
PATCH 1/2: libmount: run btrfs subvol checks for "subvolid" option
PATCH 2/2: code re-indentation

No code change is present in this patch.

Signed-off-by: Stanislav Brabec <sbrabec@suse.cz>
9 years agolibmount: run btrfs subvol checks for "subvolid" option
Stanislav Brabec [Wed, 27 Jan 2016 20:37:00 +0000 (21:37 +0100)] 
libmount: run btrfs subvol checks for "subvolid" option

It is possible to identify btrfs subvolume with "subvolid" instead of "subvol".
In such case, btrfs specific check mistakenly assumes that the default subvolume
is going to be mounted, even if subvolid specifies id of non-default subvolume.

Implement a code for "subvolid" option.

For easier review, this fix comes in two patches:
PATCH 1/2: libmount: run btrfs subvol checks for "subvolid" option
PATCH 2/2: code re-indentation

How to reproduce:
truncate -s1G btrfs_test.img
mkdir -p btrfs_mnt
/sbin/mkfs.btrfs -f -d single -m single ./btrfs_test.img
mount -o loop btrfs_test.img btrfs_mnt
pushd .
cd btrfs_mnt
mkdir -p d0/dd0/ddd0
cd d0/dd0/ddd0
touch file{1..5}
btrfs subvol create s1
cd s1
touch file{1..5}
mkdir -p d1/dd1/ddd1
cd d1/dd1/ddd1
btrfs subvol create s2
rid=$(btrfs inspect rootid s2)
echo new default $rid
btrfs subvol get-default .
btrfs subvol set-default $rid .
popd
DEFAULT_SUBVOLID=`btrfs subvolume get-default btrfs_mnt | while read dummy id rest ; do echo $id ; done`
NON_DEFAULT_SUBVOLID=`btrfs subvolume list btrfs_mnt | while read dummy id rest ; do if test $id = $DEFAULT_SUBVOLID ; then continue ; fi ; echo $id ; done`
umount btrfs_mnt
losetup /dev/loop0 $PWD/btrfs_test.img
echo "/dev/loop0 $PWD/btrfs_mnt btrfs subvolid=$NON_DEFAULT_SUBVOLID 0 0" >>/etc/fstab
./mount -a
./mount -a
umount btrfs_mnt
sed -i "/\/dev\/loop0/d" /etc/fstab
losetup -d /dev/loop0
rm btrfs_test.img
rmdir btrfs_mnt

Current behavior of second "mount -a":
    mount: /dev/loop0 is already mounted or /root/btrfs_mnt busy
           /dev/loop0 is already mounted on /root/btrfs_mnt

Signed-off-by: Stanislav Brabec <sbrabec@suse.cz>
9 years agolibmount: run btrfs subvol checks for "auto" fs type
Stanislav Brabec [Tue, 26 Jan 2016 20:59:55 +0000 (21:59 +0100)] 
libmount: run btrfs subvol checks for "auto" fs type

It is possible to mount btrfs using "auto" keyword in fstab. In such
case, btrfs specific checks are skipped. Run them for "auto" as well.

Looking at the code, it is a safe approach. In case of btrfs, it will do
what is needed, in case of no btrfs, btrfs_get_default_subvol_id() will
fail, and the rest of the code is skipped.

How to reproduce:
See reproducer in 2cd28fc and replace fstab line by
echo "/dev/loop0 $PWD/btrfs_mnt btrfs auto 0 0" >>/etc/fstab

Current behavior of second "mount -a":
mount: /dev/loop0 is already mounted or /root/btrfs_mnt busy
       /dev/loop0 is already mounted on /root/btrfs_mnt

Testcases for btrfs and ext4:
truncate -s1G btrfs_test.img
truncate -s1G ext4_test.img
mkdir -p btrfs_mnt
mkdir -p ext4_mnt
/sbin/mkfs.btrfs -f -d single -m single ./btrfs_test.img
/sbin/mkfs.ext4 ./ext4_test.img
losetup /dev/loop0 $PWD/btrfs_test.img
losetup /dev/loop1 $PWD/ext4_test.img
echo "/dev/loop0 $PWD/btrfs_mnt auto defaults 0 0" >>/etc/fstab
echo "/dev/loop1 $PWD/ext4_mnt auto defaults 0 0" >>/etc/fstab
./mount -a
./mount -a
umount btrfs_mnt
umount ext4_mnt
sed -i "/\/dev\/loop[01]/d" /etc/fstab
losetup -d /dev/loop0
losetup -d /dev/loop1
rm btrfs_test.img
rm ext4_test.img
rmdir btrfs_mnt
rmdir ext4_mnt

Signed-off-by: Stanislav Brabec <sbrabec@suse.cz>
9 years agolibmount: add 'force-mountinfo' to features list, improve debug
Karel Zak [Mon, 1 Feb 2016 10:01:44 +0000 (11:01 +0100)] 
libmount: add 'force-mountinfo' to features list, improve debug

Signed-off-by: Karel Zak <kzak@redhat.com>
9 years agoChange of output format and documentation.
Anna Jonna Ármannsdóttir [Thu, 28 Jan 2016 19:03:20 +0000 (19:03 +0000)] 
Change of output format and documentation.

9 years agoMerge branch 'fix_pylibmount_install' of https://github.com/filbranden/util-linux
Karel Zak [Wed, 27 Jan 2016 12:00:13 +0000 (13:00 +0100)] 
Merge branch 'fix_pylibmount_install' of https://github.com/filbranden/util-linux

* 'fix_pylibmount_install' of https://github.com/filbranden/util-linux:
  build-sys: Order pylibmount after usrlib on install

9 years agoMerge branch 'fix-static-configuration-and-building' of https://github.com/ladatrimas...
Karel Zak [Wed, 27 Jan 2016 11:52:02 +0000 (12:52 +0100)] 
Merge branch 'fix-static-configuration-and-building' of https://github.com/ladatrimasova/util-linux

* 'fix-static-configuration-and-building' of https://github.com/ladatrimasova/util-linux:
  buildsys: fix static configuration and building

9 years agobuild-sys: Order pylibmount after usrlib on install
Filipe Brandenburger [Thu, 31 Dec 2015 06:36:15 +0000 (22:36 -0800)] 
build-sys: Order pylibmount after usrlib on install

This fixes a failure of `make install DESTDIR=...` when trying to relink
pylibmount against libmount.la.

libtool will look for libmount.so under ${DESTDIR}/${libdir}, but if it
is not yet present, it will assume it is a system installed library and
use -lmount instead.

This makes the install order significant.

Automake lists the install entries in alphabetical order, and as
install-pylibmountexecLTLIBRARIES < install-usrlib_execLTLIBRARIES,
make will try to install pylibmount.so before libmount.so is present
in the DESTDIR, which will then cause libtool to fallback to -lmount
when relinking. This causes the error below:

  libtool: install: warning: relinking `pylibmount.la'
  libtool: install: (... libtool --mode=relink gcc -o pylibmount.la \
        -rpath /usr/lib/python2.7/dist-packages/libmount \
        libmount/python/*.lo libmount.la ... -lpython2.7 \
        -inst-prefix-dir /path/to/destdir)
  /usr/bin/ld: cannot find -lmount
  collect2: error: ld returned 1 exit status
  libtool: install: error: relink `pylibmount.la' ...
  make[3]: *** [install-pylibmountexecLTLIBRARIES] Error 1

Work around this issue by using a zz_ prefix for the pylibmount exec
dir, in order to install it last.

This does not work if parallel make is used for the install step, but
that should be a minor issue (parallel install is probably not that
useful for util-linux, which is not that large a package to actually
benefit from it.) The proper fix should be to introduce a make
dependency of target install-pylibmountexecLTLIBRARIES on target
install-usrlib_execLTLIBRARIES, but unfortunately there is no good way
to accomplish that in automake without overriding it completely.

This issue seems to be previously encountered in automake context, since
automake includes a hack to insert such a dependency rule to install all
libLTLIBRARIES before attempting to install binPROGRAMS, initially
introduced in the commit below:
http://git.savannah.gnu.org/cgit/automake.git/commit/?id=bd4a1d5ad1a72fa780a8b7fd6c365a5dad2e6220

Also, a related bug from Ubuntu tracker:
https://bugs.launchpad.net/ubuntu/+source/util-linux/+bug/1442076

Tested that `make install` starts working again after this commit, even
when libmount-dev is not installed on the system. Also confirmed that
`make distcheck` is now functional.

Confirmed that both __init__.py and the .so library are still installed
in the Python directory.

Tested that it still works without python-devel installed, also
inspected Makefile.in which looks correct.

Tested that `make install pylibmountexecdir=...` still works to override
destination directory at `make install` time.

Signed-off-by: Filipe Brandenburger <filbranden@google.com>
9 years agotests: make swaplabel test more robust
Karel Zak [Tue, 26 Jan 2016 15:49:39 +0000 (16:49 +0100)] 
tests: make swaplabel test more robust

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