]> git.ipfire.org Git - thirdparty/util-linux.git/log
thirdparty/util-linux.git
8 years agolscpu: don't use path_exist() before path_fopen()
Karel Zak [Tue, 31 Jan 2017 19:55:07 +0000 (20:55 +0100)] 
lscpu: don't use path_exist() before path_fopen()

Signed-off-by: Karel Zak <kzak@redhat.com>
8 years agodocs: add BUG REPORTING section to README
Karel Zak [Tue, 31 Jan 2017 15:18:11 +0000 (16:18 +0100)] 
docs: add BUG REPORTING section to README

Addresses: https://github.com/karelzak/util-linux/issues/405
Signed-off-by: Karel Zak <kzak@redhat.com>
8 years agolscpu: make osrelease file optional
Karel Zak [Tue, 31 Jan 2017 12:44:43 +0000 (13:44 +0100)] 
lscpu: make osrelease file optional

Signed-off-by: Karel Zak <kzak@redhat.com>
8 years agoMerge branch 'master' of https://github.com/Pedro-MC/util-linux
Karel Zak [Tue, 31 Jan 2017 12:01:01 +0000 (13:01 +0100)] 
Merge branch 'master' of https://github.com/Pedro-MC/util-linux

* 'master' of https://github.com/Pedro-MC/util-linux:
  findmnt: flush stdout after each (un)(re)mount event, when polling.

8 years agofallocate: Added posix_fallocate() support.
Denis Chaplygin [Tue, 31 Jan 2017 11:51:28 +0000 (12:51 +0100)] 
fallocate: Added posix_fallocate() support.

No all filesystems support Linux fallocate. The new option allow use
posix implementation if necessary.

Signed-off-by: Karel Zak <kzak@redhat.com>
8 years agolscpu: Detect Windows Subsystem for Linux
Stanislav Brabec [Mon, 30 Jan 2017 16:01:50 +0000 (17:01 +0100)] 
lscpu: Detect Windows Subsystem for Linux

Windows 10 implements Windows Subsystem for Linux (WSL).

WSL does not implement support for SIGSEGV handler, which is used inside
is_vmware_platform(). As a result, lscpu crashes there.

Implement WSL detection, and as a side effect, work around the crash.
Note that none of existing virtualization types exactly matches.
But the the closest would be "container".

References:

Provide a way to positively detect WSL from an app compiled on Linux.
https://github.com/Microsoft/BashOnWindows/issues/423

missing support for SIGSEGV handler
https://github.com/Microsoft/BashOnWindows/issues/1637

Signed-off-by: Stanislav Brabec <sbrabec@suse.cz>
8 years agofstrim: de-duplicate btrfs sub-volumes
Stanislav Brabec [Wed, 25 Jan 2017 17:30:26 +0000 (18:30 +0100)] 
fstrim: de-duplicate btrfs sub-volumes

There was a comparison of roots in uniq_fs_source_cmp(). As we care only on
device names, comparing roots makes only a little sense, and it breaks on btrfs.
As a result, FITRIM ioctl() is called for each subvolume. But by design, only
one TRIM is needed for the whole btrfs volume.

Remove it to be able to de-duplicate btrfs subvolumes.

Fixes opensuse #1020077.

Signed-off-by: Stanislav Brabec <sbrabec@suse.cz>
8 years agofindmnt: flush stdout after each (un)(re)mount event, when polling.
Pedro Miguel Carvalho [Sun, 29 Jan 2017 12:03:23 +0000 (12:03 +0000)] 
findmnt: flush stdout after each (un)(re)mount event, when polling.

Addresses: karelzak#407

8 years agologger: support sub-trees in the ID for RFC5424
Karel Zak [Sat, 28 Jan 2017 11:39:52 +0000 (12:39 +0100)] 
logger: support sub-trees in the ID for RFC5424

The current code supports <name>@<digit> only, but we also need
<name>@<digit>.<digit>[. ...]

RFC5424: 7.2.2 enterpriseId:

 In general, only the IANA-assigned private enterprise number is
 needed (a single number).  An enterprise might decide to use
 sub-identifiers below its private enterprise number.  If sub-
 identifiers are used, they MUST be separated by periods and be
 represented as decimal numbers.  An example for that would be
 "32473.1.2".

Addresses: https://github.com/karelzak/util-linux/issues/406
Signed-off-by: Karel Zak <kzak@redhat.com>
8 years agolib/strutils: return end pointer by isdigit_string()
Karel Zak [Sat, 28 Jan 2017 11:39:30 +0000 (12:39 +0100)] 
lib/strutils: return end pointer by isdigit_string()

Signed-off-by: Karel Zak <kzak@redhat.com>
8 years agolibfdisk: (gpt) add check for entries array size
Karel Zak [Wed, 25 Jan 2017 11:00:27 +0000 (12:00 +0100)] 
libfdisk: (gpt) add check for entries array size

Signed-off-by: Karel Zak <kzak@redhat.com>
8 years agolibblkid: Fix out of bounds reads in BEFS handling
Alden Tondettar [Tue, 24 Jan 2017 06:28:01 +0000 (23:28 -0700)] 
libblkid: Fix out of bounds reads in BEFS handling

The BEFS prober is quite trusting of whatever data is fed to it and
performs almost no bounds checks. There don't seem to be any
out-of-bounds writes as far as I can tell, but there are many ways a
corrupted image could cause libblkid to read OOB and segfault, or hang
in an infinite loop.

This fix makes a few sanity-checks of the superblock, add bounds checks
wherever they seem needed, and crudely checks for cycles in the B+ tree.

Signed-off-by: Alden Tondettar <alden.tondettar@gmail.com>
8 years agolibblkid: Fix out of bounds reads on bad GPT header
Alden Tondettar [Tue, 24 Jan 2017 06:28:00 +0000 (23:28 -0700)] 
libblkid: Fix out of bounds reads on bad GPT header

If a GUID Partition Table claims to have more than 2**25 entries, or if the
size of each entry is not exactly 128 bytes, libblkid can read out of bounds
and segfault. Perform the appropriate checks.

[kzak@redhat.com: - fix typo]

Signed-off-by: Alden Tondettar <alden.tondettar@gmail.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
8 years agolibblkid: Fix out of bounds reads on bad NTFS Master File Table
Alden Tondettar [Tue, 24 Jan 2017 06:27:59 +0000 (23:27 -0700)] 
libblkid: Fix out of bounds reads on bad NTFS Master File Table

The NTFS prober does not validate certain fields in struct file_attribute,
and could attempt to read the disk label from outside the space allocated
for the Master File Table.  Perform the appropriate checks.

Note that one variable (attr_off) is now 64-bit, so a check for integer
overflow has been removed as unneeded/confusing.

Signed-off-by: Alden Tondettar <alden.tondettar@gmail.com>
8 years agolibblkid: Fix out of bounds byte swaps in ZFS handling
Alden Tondettar [Tue, 24 Jan 2017 06:27:58 +0000 (23:27 -0700)] 
libblkid: Fix out of bounds byte swaps in ZFS handling

A corrupted ZFS filesystem can trigger 32-bit endian-conversions of
unintended memory locations in zfs_extract_guid_name(), in several ways:

* The variable "left" (number of bytes remaining in the buffer) does not
  account for the 12 bytes of the nvlist header.

* The field nvp->nvp_namelen (name length in name/value pair) is rounded
  up to the nearest multiple of 4, but only the unrounded size is checked.

* The fields nvs->nvs_type, nvs_strlen, etc. are modified _before_ checking
  if they are within bounds.

* A negative value of nvp->nvp_namelen will bypass the check that
  nvp->nvp_namelen fits into nvp->nvp_size (size of name/value pair).

This allows for mangling of locations up to 12 + 3 + 8 == 23
bytes beyond the end of stack-based buff[4096], and up to 2**31 bytes
before its beginning.

Furthermore some debugging messages are printed from unchecked memory
locations, possibly resulting in OOB reads or setuid programs leaking
sensitive data when LIBBLKID_DEBUG is set.

This fix attempts to correct all of these problems. It also eliminates the
stack-based buffer (in case anything else was missed) and refactors things
a bit to (hopefully) make it easier to spot any mistakes.

Signed-off-by: Alden Tondettar <alden.tondettar@gmail.com>
8 years agoMerge branch 'shadow-man' of https://github.com/andhe/util-linux
Karel Zak [Fri, 20 Jan 2017 12:12:57 +0000 (13:12 +0100)] 
Merge branch 'shadow-man' of https://github.com/andhe/util-linux

* 'shadow-man' of https://github.com/andhe/util-linux:
  chsh: use -h as shorthand for --help instead of -u
  man: chsh(1): add login.defs to SEE ALSO
  man: chfn(1): add chsh and login.defs to SEE ALSO

8 years agobuild-sys: fix compilation with ncurses and uClibc or musl libc
Carlos Santos [Thu, 19 Jan 2017 19:27:37 +0000 (17:27 -0200)] 
build-sys: fix compilation with ncurses and uClibc or musl libc

Compiling util-linux with musl and uClibc-ng toolchains when wide-char
support is not enabled in ncurses results in compilation failures with
the following message:

    error: two or more data types in declaration specifiers
    #define
     wchar_t char

The problem occurs because util-linux #defines its own wchar_t (as char)
when configured without widechar support. This conflicts with definition
of wchar_t contained in stddef.h.

This error can be reproduced running "<toolchain-cc -o test test.c" with
the following test program:

    #include <ctype.h>
    #define wchar_t char
    #include <stddef.h>

    int main()
    {
        return 0;
    }

The only way to avoid the problem it to reorder the inclusion of headers
in some files under the text-utils directory.

Addresses:
  http://autobuild.buildroot.net/results/3a2f228e0fa7b5cc28a13d49f48f1a6aef8d9d7a
  http://autobuild.buildroot.net/results/99e96069f652d511c6212a5bb6be29e68fb1747c
  http://autobuild.buildroot.net/results/2dc5721aef93b7b410153bafad78248fac3db941
  http://autobuild.buildroot.net/results/8a9e197ba7a292b18f8c0c36dca974685556a38a

Signed-off-by: Carlos Santos <casantos@datacom.ind.br>
8 years agosu, runuser: fix typo in the /etc/default path
Karel Zak [Fri, 20 Jan 2017 10:02:23 +0000 (11:02 +0100)] 
su, runuser: fix typo in the /etc/default path

Reported-by: Andreas Henriksson <andreas@fatal.se>
Signed-off-by: Karel Zak <kzak@redhat.com>
8 years agochsh: use -h as shorthand for --help instead of -u
Andreas Henriksson [Thu, 19 Jan 2017 22:04:47 +0000 (23:04 +0100)] 
chsh: use -h as shorthand for --help instead of -u

The -u is still supported (but no longer documented).

(This matches the switches used by shadow chsh.)

8 years agoman: chsh(1): add login.defs to SEE ALSO
Andreas Henriksson [Thu, 19 Jan 2017 21:50:31 +0000 (22:50 +0100)] 
man: chsh(1): add login.defs to SEE ALSO

(The shadow equivalent manpage lists it.)

8 years agoman: chfn(1): add chsh and login.defs to SEE ALSO
Andreas Henriksson [Thu, 19 Jan 2017 21:39:31 +0000 (22:39 +0100)] 
man: chfn(1): add chsh and login.defs to SEE ALSO

(The shadow version of the same manpage mentions these utils,
but does not mention finger.)

8 years agorunuser: add "--" to SYNOPSIS
Karel Zak [Thu, 19 Jan 2017 11:01:51 +0000 (12:01 +0100)] 
runuser: add "--" to SYNOPSIS

Signed-off-by: Karel Zak <kzak@redhat.com>
8 years agoMerge branch 'termutils-typo' of https://github.com/The-42/util-linux
Karel Zak [Thu, 19 Jan 2017 10:27:08 +0000 (11:27 +0100)] 
Merge branch 'termutils-typo' of https://github.com/The-42/util-linux

* 'termutils-typo' of https://github.com/The-42/util-linux:
  term-utils/script: fix typo leading to syntax error

8 years agobuild-sys: use MATH_LIBS for hwclock
Karel Zak [Thu, 19 Jan 2017 10:22:38 +0000 (11:22 +0100)] 
build-sys: use MATH_LIBS for hwclock

Reported-by: Bert van Hall <bert.vanhall@avionic-design.de>
Signed-off-by: Karel Zak <kzak@redhat.com>
8 years agoterm-utils/script: fix typo leading to syntax error
Bert van Hall [Wed, 18 Jan 2017 15:41:36 +0000 (16:41 +0100)] 
term-utils/script: fix typo leading to syntax error

Introduced in edc7e42, this typo is actually invalid C. Fix this.

Signed-off-by: Bert van Hall <bert.vanhall@avionic-design.de>
8 years agobuild-sys: use -lm for scriptreplay if necessary
Karel Zak [Wed, 18 Jan 2017 12:17:21 +0000 (13:17 +0100)] 
build-sys: use -lm for scriptreplay if necessary

Reported-by: Bert van Hall <bert.vanhall@avionic-design.de>
Addresses: https://github.com/karelzak/util-linux/pull/397
Signed-off-by: Karel Zak <kzak@redhat.com>
8 years agocolumn: rename --columns to --output-width
Karel Zak [Tue, 17 Jan 2017 12:11:27 +0000 (13:11 +0100)] 
column: rename --columns to --output-width

* rename to use less confusing option name
* cleanup usage()
* update man page

Addresses: https://github.com/karelzak/util-linux/pull/327
Signed-off-by: Karel Zak <kzak@redhat.com>
8 years agolast: use --time-format instruction when printing wtmp creation time
Sami Kerola [Mon, 16 Jan 2017 22:31:36 +0000 (22:31 +0000)] 
last: use --time-format instruction when printing wtmp creation time

This makes --time-format=iso timestamp to look the same as login/logout
times.  When --time-format=noformat is used the file creation time not
printed.  There is no change to default format.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
8 years agolibfdisk: (gpt) make calculations more robust
Karel Zak [Mon, 16 Jan 2017 13:57:02 +0000 (14:57 +0100)] 
libfdisk: (gpt) make calculations more robust

Signed-off-by: Karel Zak <kzak@redhat.com>
8 years agoMerge branch 'col' of git://github.com/kerolasa/lelux-utiliteetit
Karel Zak [Mon, 16 Jan 2017 11:33:56 +0000 (12:33 +0100)] 
Merge branch 'col' of git://github.com/kerolasa/lelux-utiliteetit

* 'col' of git://github.com/kerolasa/lelux-utiliteetit:
  col: backspacing widechars

8 years agonewgrp: use libc explicit_bzero() when it is available
Sami Kerola [Thu, 5 Jan 2017 22:33:40 +0000 (22:33 +0000)] 
newgrp: use libc explicit_bzero() when it is available

This currently new function will be part of glibc 2.25.

Reference: https://sourceware.org/git/?p=glibc.git;a=commit;h=ea1bd74defcf9d5291d14972e63105168ca9eb4f
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
8 years agotests: Introduce libmount/loop
Stanislav Brabec [Thu, 12 Jan 2017 14:45:56 +0000 (15:45 +0100)] 
tests: Introduce libmount/loop

Add libmount/loop test that tests various loop mount options.

Signed-off-by: Stanislav Brabec <sbrabec@suse.cz>
8 years agolibmount: Fix incorrect detach of reused loop device
Stanislav Brabec [Thu, 12 Jan 2017 14:45:42 +0000 (15:45 +0100)] 
libmount: Fix incorrect detach of reused loop device

If -oloop is used and the loop device is reused, the loop device is detached
after umount. It is incorrect as it could break the another task using the loop
device.

This is caused by mnt_context_enable_loopdel(,TRUE) that is called from
mnt_context_prepare_umount() whenever "loop" option is used, independently on
AUTOCLEAR flag.

Remove the "loop" option for reused devices to prevent detaching of reused loop
device.

Signed-off-by: Stanislav Brabec <sbrabec@suse.cz>
8 years agolibmount: fix mount -oloop=/dev/loopX regression
Stanislav Brabec [Thu, 12 Jan 2017 14:45:27 +0000 (15:45 +0100)] 
libmount: fix mount -oloop=/dev/loopX regression

If mount option "loop" is used with an argument, it should be respected. Commit
8efad715 introduced a regression. Even with an argument, overlaying loop device
is searched and argument is ignored. It could have unexpected side effects.

If argument is set, never allocate a new loop device.

How to reproduce:
mkdir -p cdrom
mkisofs -o cdrom.iso cdrom/ 2>/dev/null
losetup /dev/loop0 cdrom.iso
strace mount -t auto -o ro,loop=/dev/loop1 cdrom.iso /mnt 2>&1 | grep ^mount
cat /proc/self/mountinfo | grep /mnt
umount /mnt
losetup -d /dev/loop0

mount("/dev/loop0", "/mnt", "iso9660", MS_MGC_VAL|MS_RDONLY, NULL) = 0
327 60 7:0 / /mnt ro,relatime shared:241 - iso9660 /dev/loop0 ro
losetup: /dev/loop0: detach failed: No such device or address

Signed-off-by: Stanislav Brabec <sbrabec@suse.cz>
8 years agolibfdisk: apply label alignment properties
Karel Zak [Mon, 16 Jan 2017 10:20:32 +0000 (11:20 +0100)] 
libfdisk: apply label alignment properties

This fix changes from the previous patches.

Signed-off-by: Karel Zak <kzak@redhat.com>
8 years agopartx: add --sector-size option
Karel Zak [Fri, 13 Jan 2017 12:30:22 +0000 (13:30 +0100)] 
partx: add --sector-size option

/dev/sdc is 4K disk:

 # fdisk -l /dev/sdc
 Disk /dev/sdc: 100 MiB, 104857600 bytes, 25600 sectors
 ...
 Device     Boot Start   End Sectors Size Id Type
 /dev/sdc1        1024 25599   24576  96M 83 Linux

let's use it as disk image:

 # dd if=/dev/sdc of=~/sdc.img
 # losetup -f ~/sdc.img

old version:

 # partx --show /dev/loop0
 NR START   END SECTORS SIZE NAME UUID
 1  1024 25599   24576  12M      6a4ba75b-01

new version:

 # partx --show /dev/loop0 --sector-size 4096
 NR START    END SECTORS SIZE NAME UUID
  1  8192 204799  196608  96M      6a4ba75b-01

Addresses: https://github.com/karelzak/util-linux/issues/396
Signed-off-by: Karel Zak <kzak@redhat.com>
8 years agolibblkid: add blkid_probe_set_sectorsize()
Karel Zak [Fri, 13 Jan 2017 12:26:37 +0000 (13:26 +0100)] 
libblkid: add blkid_probe_set_sectorsize()

The usual way is to use ioctl to ask block device for sector size, but
this is useless for disk images (regular files). And the default
(512-bytes) may be pretty wrong for disk images from 4K disks. Let's
support a way how to specify proper sector size.

Signed-off-by: Karel Zak <kzak@redhat.com>
8 years agolibfdisk: change the way how apply user device properties
Karel Zak [Fri, 13 Jan 2017 11:44:35 +0000 (12:44 +0100)] 
libfdisk: change the way how apply user device properties

The current code calls fdisk_apply_user_device_properties() after
label probing, because we want to overwrite label geometry by user
settings (e.g. -C -H -S fdisk options).

Unfortunately, this way does not work if we need to use a different
sector size, because label probing depends on sector size... So, the
right way is to apply user setting to the fdisk context before we
start to read from device, and overwrite geometry again after label is
already read. Fortunately, this shit is necessary only rarely and for
SUN and SGI disk labels.

Addresses: https://github.com/karelzak/util-linux/issues/396
Signed-off-by: Karel Zak <kzak@redhat.com>
8 years agolibfdisk: recount size when apply user device properties
Karel Zak [Fri, 13 Jan 2017 11:16:06 +0000 (12:16 +0100)] 
libfdisk: recount size when apply user device properties

Signed-off-by: Karel Zak <kzak@redhat.com>
8 years agolibfdisk: don't use blkdev ioctls for regular files
Karel Zak [Fri, 13 Jan 2017 10:23:23 +0000 (11:23 +0100)] 
libfdisk: don't use blkdev ioctls for regular files

$ fdisk <diskimage>

open("sdc.img", O_RDONLY|O_CLOEXEC)     = 3
ioctl(3, BLKSSZGET, 0x7ffcf51357c4)     = -1 ENOTTY (Inappropriate ioctl for device)
ioctl(3, BLKGETSIZE64, 0x7ffcf51357b0)  = -1 ENOTTY (Inappropriate ioctl for device)
ioctl(3, BLKGETSIZE, 0x7ffcf51356c8)    = -1 ENOTTY (Inappropriate ioctl for device)
ioctl(3, FDGETPRM, 0x7ffcf51356d0)      = -1 ENOTTY (Inappropriate ioctl for device)
ioctl(3, HDIO_GETGEO, 0x7ffcf5135790)   = -1 ENOTTY (Inappropriate ioctl for device)

Signed-off-by: Karel Zak <kzak@redhat.com>
8 years agoIf mtab support is disabled, disable ro/rw mtab checks
Stanislav Brabec [Tue, 10 Jan 2017 12:54:17 +0000 (13:54 +0100)] 
If mtab support is disabled, disable ro/rw mtab checks

Commit f9906424 introduced a check that should prevent different information in
mtab and /proc/mounts. The check can require significant amount of time, and for
systems without mtab support it has no sense.

Execute this code only on systems with mtab.

When a systems with large number of nodes (thousands) mount the filesystems
simultaneously, the time required for serialization causes the utimensat() to
take a large amount of time (tens of minutes) when a large number of nodes are
simultaneously updating the timestamp.

Signed-off-by: Stanislav Brabec <sbrabec@suse.cz>
8 years agoman: fix couple tools/checkmans.sh warnings
Sami Kerola [Fri, 6 Jan 2017 23:54:34 +0000 (23:54 +0000)] 
man: fix couple tools/checkmans.sh warnings

<standard input>:407: warning: macro `fi.' not defined (possibly missing space after `fi')
From: cat ./disk-utils/fsck.8 | troff -mandoc -ww -z

<standard input>:71: warning: escape character ignored before `1'
From: cat ./disk-utils/partx.8 | troff -mandoc -ww -z

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
8 years agolibsmartcols: add scols_cell_get_alignment()
Karel Zak [Mon, 9 Jan 2017 12:28:24 +0000 (13:28 +0100)] 
libsmartcols: add scols_cell_get_alignment()

Just to hide that we use cell flags (bitwise operations) to define
cell content alignment. The patch also more explicitly specifies the
flags in the header file.

The alignment is evaluated in the order: right, center, left. The
default is left.

Note that SCOLS_CELL_FL_* are used for for table title only.

Signed-off-by: Karel Zak <kzak@redhat.com>
8 years agoMerge branch 'ignatenko/libsmartcols-dead' of https://github.com/ignatenkobrain/util...
Karel Zak [Mon, 9 Jan 2017 12:07:37 +0000 (13:07 +0100)] 
Merge branch 'ignatenko/libsmartcols-dead' of https://github.com/ignatenkobrain/util-linux

* 'ignatenko/libsmartcols-dead' of https://github.com/ignatenkobrain/util-linux:
  libsmartcols: remove dead checks

8 years agolscpu: add aarch64 specific names
Karel Zak [Mon, 9 Jan 2017 12:01:39 +0000 (13:01 +0100)] 
lscpu: add aarch64 specific names

It seems that aarch64 uses a different names for some /proc/cpuinfo
fields (e.g. intel: bogomips, flags, and aarch64: BogoMIPS, features, ...)

Addresses: https://github.com/karelzak/util-linux/issues/392
Signed-off-by: Karel Zak <kzak@redhat.com>
8 years agounshare: fix SYNOPSIS and usage()
Karel Zak [Mon, 9 Jan 2017 11:48:14 +0000 (12:48 +0100)] 
unshare: fix SYNOPSIS and usage()

The "program" is optional and $SHELL is executed by default.

Addresses: https://github.com/karelzak/util-linux/issues/389
Signed-off-by: Karel Zak <kzak@redhat.com>
8 years agonsenter: fix usage() and improve man page
Karel Zak [Mon, 9 Jan 2017 11:48:14 +0000 (12:48 +0100)] 
nsenter: fix usage() and improve man page

The "program" is optional and $SHELL is executed by default.

Addresses: https://github.com/karelzak/util-linux/issues/389
Signed-off-by: Karel Zak <kzak@redhat.com>
8 years agoMerge branch 'betterMinixChecks' of https://github.com/n3world/util-linux
Karel Zak [Fri, 6 Jan 2017 10:09:01 +0000 (11:09 +0100)] 
Merge branch 'betterMinixChecks' of https://github.com/n3world/util-linux

* 'betterMinixChecks' of https://github.com/n3world/util-linux:
  libblkid/minix: Sanity check superblock s_state for v 1 and 2
  libblkid/minix: Use same checks for version 3
  libblkid/minix: Match minix superblock types

8 years agowipefs: unused parameter [-Wunused-parameter]
Karel Zak [Thu, 5 Jan 2017 11:04:22 +0000 (12:04 +0100)] 
wipefs: unused parameter [-Wunused-parameter]

Signed-off-by: Karel Zak <kzak@redhat.com>
8 years agolibfdisk: (sun) use self_label()
Karel Zak [Thu, 5 Jan 2017 11:36:08 +0000 (12:36 +0100)] 
libfdisk: (sun) use self_label()

Signed-off-by: Karel Zak <kzak@redhat.com>
8 years agolibsmartcols: unused parameter [-Wunused-parameter]
Karel Zak [Thu, 5 Jan 2017 11:04:22 +0000 (12:04 +0100)] 
libsmartcols: unused parameter [-Wunused-parameter]

Signed-off-by: Karel Zak <kzak@redhat.com>
8 years agolibuuid: unused parameter [-Wunused-parameter]
Karel Zak [Thu, 5 Jan 2017 11:04:22 +0000 (12:04 +0100)] 
libuuid: unused parameter [-Wunused-parameter]

Signed-off-by: Karel Zak <kzak@redhat.com>
8 years agolib/list: remove LIST_HEAD macro
Karel Zak [Thu, 5 Jan 2017 10:54:59 +0000 (11:54 +0100)] 
lib/list: remove LIST_HEAD macro

* the variable definition with hidden type is always horrible, for
  example:

  int func() {
    LIST_HEAD(foo);
    ...
  }

  the more readable is:

          int func() {
            struct list_head foo;

            INIT_LIST_HEAD(&foo);
            ...
          }

* the name LIST_HEAD conflict with /usr/include/sys/queue.h

* we use it only on two places in sulogin

Signed-off-by: Karel Zak <kzak@redhat.com>
8 years agosfdisk: unused parameter 'sf' [-Wunused-parameter]
Karel Zak [Thu, 5 Jan 2017 10:53:56 +0000 (11:53 +0100)] 
sfdisk: unused parameter 'sf' [-Wunused-parameter]

Signed-off-by: Karel Zak <kzak@redhat.com>
8 years agoMerge branch 'fixMinixMkfs' of https://github.com/n3world/util-linux
Karel Zak [Thu, 5 Jan 2017 10:34:29 +0000 (11:34 +0100)] 
Merge branch 'fixMinixMkfs' of https://github.com/n3world/util-linux

* 'fixMinixMkfs' of https://github.com/n3world/util-linux:
  disk-utils/mkfs.minix: Set ninodes after checking max

8 years agocol: backspacing widechars
Grady Martin [Wed, 4 Jan 2017 22:01:40 +0000 (22:01 +0000)] 
col: backspacing widechars

Until now, backspace characters have not accounted for characters of widths
other than one.  This single line amends that.

Requsted-by: Grady Martin <admin@nosuck.org>
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
8 years agolibblkid/minix: Sanity check superblock s_state for v 1 and 2
Nate Clark [Wed, 4 Jan 2017 20:21:17 +0000 (15:21 -0500)] 
libblkid/minix: Sanity check superblock s_state for v 1 and 2

Swap devices with specific values in the uuid can look like minix
devices to blkid. Add an extra check to make sure the state of the
filesystem has valid state flags.

A couple of offending swap uuids include:
35f1f264-137f-471a-bc85-acc9f4bc04a3
35f1f264-7f13-471a-bc85-acc9f4bc04a3
35f1f264-138f-471a-bc85-acc9f4bc04a3
35f1f264-8f13-471a-bc85-acc9f4bc04a3

Without this change a swap device with any of those uuids would be
detected as minix and swap by blkid.

Signed-off-by: Nate Clark <nate@neworld.us>
8 years agolibblkid/minix: Use same checks for version 3
Nate Clark [Wed, 4 Jan 2017 20:24:32 +0000 (15:24 -0500)] 
libblkid/minix: Use same checks for version 3

fsck.minix performs the same sanity checks on all versions of the
superblock. Update the probe to perform the same sanity checks so it is
less likely a different type of filesystem will be identified as minix.

Signed-off-by: Nate Clark <nate@neworld.us>
8 years agolibblkid/minix: Match minix superblock types
Nate Clark [Wed, 4 Jan 2017 20:24:22 +0000 (15:24 -0500)] 
libblkid/minix: Match minix superblock types

All of the types in the minix super block are unsigned but in
probe_minix they were being treated as signed. This would cause some of
the extra sanity checks to pass on a non minix device. The types were
updated to match the return types of the helper functions in
disk-utils/minix_programs.h

This can be checked by creating a swap partition with one of these UUIDs
35f1f264-2468-471a-bc85-acc9f4bc04a3
35f1f264-6824-471a-bc85-acc9f4bc04a3
35f1f264-2478-471a-bc85-acc9f4bc04a3
35f1f264-7824-471a-bc85-acc9f4bc04a3

Prior to this change they would all be considered minix and swap by
blkid.

Signed-off-by: Nate Clark <nate@neworld.us>
8 years agodisk-utils/mkfs.minix: Set ninodes after checking max
Nate Clark [Wed, 4 Jan 2017 17:31:37 +0000 (12:31 -0500)] 
disk-utils/mkfs.minix: Set ninodes after checking max

ninodes in the superblock needs to be set after inodes is checked
against MINIX_MAX_INODES otherwise a value larger than MINIX_MAX_INODES
can be attempted to be stored in the superblock.

Without this change the command "mkfs.minix -2 -i 65530 <dev>" would
write a minix superblock with ninodes set to 0.

Signed-off-by: Nate Clark <nate@neworld.us>
8 years agobuild-sys: test_linux_version is Linux only
Karel Zak [Wed, 4 Jan 2017 14:44:51 +0000 (15:44 +0100)] 
build-sys: test_linux_version is Linux only

Signed-off-by: Karel Zak <kzak@redhat.com>
8 years agolib/linux_version: fix code indention
Karel Zak [Wed, 4 Jan 2017 14:42:02 +0000 (15:42 +0100)] 
lib/linux_version: fix code indention

Signed-off-by: Karel Zak <kzak@redhat.com>
8 years agoMerge branch 'setterm' of git://github.com/kerolasa/lelux-utiliteetit
Karel Zak [Wed, 4 Jan 2017 11:27:27 +0000 (12:27 +0100)] 
Merge branch 'setterm' of git://github.com/kerolasa/lelux-utiliteetit

* 'setterm' of git://github.com/kerolasa/lelux-utiliteetit:
  setterm: add --resize option

8 years agolib: use unique ifdefs for tests
Karel Zak [Wed, 4 Jan 2017 10:44:37 +0000 (11:44 +0100)] 
lib: use unique ifdefs for tests

Let's use unique TEST_PROGRAM_<NAME> ifdefs to make build system more
robust.

Signed-off-by: Karel Zak <kzak@redhat.com>
8 years agoMerge branch 'fixes' of https://github.com/rudimeier/util-linux
Karel Zak [Tue, 3 Jan 2017 11:16:43 +0000 (12:16 +0100)] 
Merge branch 'fixes' of https://github.com/rudimeier/util-linux

* 'fixes' of https://github.com/rudimeier/util-linux:
  agetty: fix ifdef typo

8 years agolib/linux_version: add test for manual testing
Karel Zak [Mon, 2 Jan 2017 10:36:53 +0000 (11:36 +0100)] 
lib/linux_version: add test for manual testing

Signed-off-by: Karel Zak <kzak@redhat.com>
8 years agolib/linux_version: fix stupid typo
Karel Zak [Mon, 2 Jan 2017 10:32:24 +0000 (11:32 +0100)] 
lib/linux_version: fix stupid typo

 ... introduced by commit d404065a. Sorry.

Signed-off-by: Karel Zak <kzak@redhat.com>
8 years agosetterm: add --resize option
Sami Kerola [Thu, 29 Dec 2016 10:28:54 +0000 (10:28 +0000)] 
setterm: add --resize option

Reset terminal size by assessing maximum row and column.  This is useful
when actual geometry and kernel terminal driver are not in sync.

Addresses: http://bugs.debian.org/835636
Based-on-work-by: Adam Borowski <kilobyte@angband.pl>
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
8 years agoMerge branch 'getrandom' of git://github.com/kerolasa/lelux-utiliteetit
Karel Zak [Thu, 22 Dec 2016 14:27:25 +0000 (15:27 +0100)] 
Merge branch 'getrandom' of git://github.com/kerolasa/lelux-utiliteetit

* 'getrandom' of git://github.com/kerolasa/lelux-utiliteetit:
  lib/randutils: use getrandom(2) when it is available

8 years agofsfreeze: move filesystem support info to manual page
Sami Kerola [Sun, 18 Dec 2016 18:32:41 +0000 (18:32 +0000)] 
fsfreeze: move filesystem support info to manual page

Include btrfs, f2fs, and nilfs to list of supported filesystems, with note
the list can be incomplete.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
8 years agofsfreeze: remove unnecessary functions
Sami Kerola [Sun, 18 Dec 2016 18:32:40 +0000 (18:32 +0000)] 
fsfreeze: remove unnecessary functions

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
8 years agotests: add findmnt output tests
Karel Zak [Thu, 22 Dec 2016 10:52:22 +0000 (11:52 +0100)] 
tests: add findmnt output tests

Signed-off-by: Karel Zak <kzak@redhat.com>
8 years agoagetty: fix ifdef typo
Ruediger Meier [Wed, 21 Dec 2016 21:39:17 +0000 (22:39 +0100)] 
agetty: fix ifdef typo

introduced in 77835be2

Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
8 years agotests: add new findmnt --options tests
Karel Zak [Tue, 20 Dec 2016 15:05:29 +0000 (16:05 +0100)] 
tests: add new findmnt --options tests

Signed-off-by: Karel Zak <kzak@redhat.com>
8 years agolibmount: support name=value for mnt_match_options()
Karel Zak [Tue, 20 Dec 2016 15:01:22 +0000 (16:01 +0100)] 
libmount: support name=value for mnt_match_options()

$ findmnt --options mode=755
TARGET         SOURCE FSTYPE   OPTIONS
/sys/fs/cgroup tmpfs  tmpfs    rw,nosuid,nodev,noexec,relatime,mode=755
/dev           udev   devtmpfs rw,relatime,size=1983516k,nr_inodes=495879,mode=755

Signed-off-by: Karel Zak <kzak@redhat.com>
8 years agolibmount: reimplement mnt_match_options()
Karel Zak [Tue, 20 Dec 2016 14:31:33 +0000 (15:31 +0100)] 
libmount: reimplement mnt_match_options()

Let's use optstr.c functions to parse pattern and options strings.
It's more robust that the old original mount(8) code and it supports
quotes in the options strings.

Signed-off-by: Karel Zak <kzak@redhat.com>
8 years agotests: add findmnt tests
Karel Zak [Tue, 20 Dec 2016 11:14:17 +0000 (12:14 +0100)] 
tests: add findmnt tests

Signed-off-by: Karel Zak <kzak@redhat.com>
8 years agolibsmartcols: remove dead checks
Igor Gnatenko [Mon, 19 Dec 2016 22:36:48 +0000 (23:36 +0100)] 
libsmartcols: remove dead checks

We initialize them before.

Signed-off-by: Igor Gnatenko <i.gnatenko.brain@gmail.com>
8 years agolsblk: use errtryhelp()
Karel Zak [Mon, 19 Dec 2016 12:30:56 +0000 (13:30 +0100)] 
lsblk: use errtryhelp()

Signed-off-by: Karel Zak <kzak@redhat.com>
8 years agoUse --help suggestion on invalid option
Karel Zak [Mon, 19 Dec 2016 12:13:34 +0000 (13:13 +0100)] 
Use --help suggestion on invalid option

The current default is to print all usage() output. This is overkill
in many case.

Addresses: https://github.com/karelzak/util-linux/issues/338
Signed-off-by: Karel Zak <kzak@redhat.com>
8 years agoinclude/c.h: add errtryhelp()
Karel Zak [Mon, 19 Dec 2016 10:33:40 +0000 (11:33 +0100)] 
include/c.h: add errtryhelp()

Add code to print:

Try '<progname> --help' for more information.

and exit.

Signed-off-by: Karel Zak <kzak@redhat.com>
8 years agodocs: replace FTP by HTTPS in kernel.org URLs
Sébastien Helleu [Sat, 17 Dec 2016 08:06:57 +0000 (09:06 +0100)] 
docs: replace FTP by HTTPS in kernel.org URLs

The links to ftp://ftp.kernel.org/ are replaced by
https://www.kernel.org/.

Signed-off-by: Karel Zak <kzak@redhat.com>
8 years agofindmnt: error on --target /non-exist
Karel Zak [Fri, 16 Dec 2016 11:46:45 +0000 (12:46 +0100)] 
findmnt: error on --target /non-exist

The original --target implementation (< v2.27) has been based on
stat(), so it was usable for valid paths only.

The new implementation is based on search in the mountinfo file, so it
works for arbitrary crazy path. This is not backwardly compatible and
if the path does not exist then it still returns at least root
directory mount entry.

This patch forces mnt_table_find_mountpoint() to check if the path is
valid before we search in the mountinfo file.

Signed-off-by: Karel Zak <kzak@redhat.com>
8 years agomore: avoid double free() on exit
Karel Zak [Thu, 15 Dec 2016 13:40:26 +0000 (14:40 +0100)] 
more: avoid double free() on exit

On 'q' command more(1) calls end_it() function with _exit(). The
_exit() may suspend program execution due to pending I/O on very
loaded server. In this time SIGINT may be delivered due to impatient
user who will press ^C.

And then end_it() cleanup function may be executed by signal handler
too. The result is double free()...

Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=1403971
Signed-off-by: Karel Zak <kzak@redhat.com>
8 years agotests: add missing file
Karel Zak [Tue, 13 Dec 2016 14:00:51 +0000 (15:00 +0100)] 
tests: add missing file

Signed-off-by: Karel Zak <kzak@redhat.com>
8 years agonsenter: add --all option
Karel Zak [Tue, 13 Dec 2016 13:44:33 +0000 (14:44 +0100)] 
nsenter: add --all option

Let's make it easy for users to enter target process namespaces.

Addresses: https://github.com/karelzak/util-linux/issues/382
Signed-off-by: Karel Zak <kzak@redhat.com>
8 years agobuild-sys: cleanup UL_NCURSES_CHECK
Karel Zak [Tue, 13 Dec 2016 11:41:18 +0000 (12:41 +0100)] 
build-sys: cleanup UL_NCURSES_CHECK

* use SUFFIX for upper-case suffix
* use AC_CHECK_TOOL() to search for ncurses-config (thanks to Mike Frysinger)
* separate checks by AS_IF()

Signed-off-by: Karel Zak <kzak@redhat.com>
8 years agofdisk: don't be silent when list non-existing device
Karel Zak [Tue, 13 Dec 2016 11:11:18 +0000 (12:11 +0100)] 
fdisk: don't be silent when list non-existing device

Addresses: https://github.com/karelzak/util-linux/issues/376
Signed-off-by: Karel Zak <kzak@redhat.com>
8 years agobuild-sys: prefer pkg-config for ncurses
Karel Zak [Mon, 12 Dec 2016 14:23:53 +0000 (15:23 +0100)] 
build-sys: prefer pkg-config for ncurses

and use ncurses{5,6}-config as fallback only.

Signed-off-by: Karel Zak <kzak@redhat.com>
8 years agolib/randutils: use getrandom(2) when it is available
Sami Kerola [Sun, 11 Dec 2016 11:43:37 +0000 (11:43 +0000)] 
lib/randutils: use getrandom(2) when it is available

System call getrandom(2) is relatively new, available since kernel 3.17 but
not supported by glibc 2.24.  That in mind autotools is made to check
availability of this function and keep old code as fallback.  It is
reasonable assume it will take years before the syscall(2) and fallback are
unproblematic to remove.

One might ask why bother using getrandom(2).  Main reason is to avoid
unnecessary system calls to achieve exactly same end result.  That
demonstrated with 'strace -c ./mcookie' showing 36 calls before, and 32
after this change.  Secondly the getrandom(2) function got to kernel with
promise it can be used to avoid file descriptor run down, and since uuidd
uses random_get_bytes() it should fulfill it's promise here.

Reference: http://man7.org/linux/man-pages/man2/getrandom.2.html
Reference: https://lwn.net/Articles/606141/
Reviewed-by: Karel Zak <kzak@redhat.com>
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
8 years agoMerge branch 'build-fixes' of https://github.com/rudimeier/util-linux
Karel Zak [Fri, 9 Dec 2016 14:37:09 +0000 (15:37 +0100)] 
Merge branch 'build-fixes' of https://github.com/rudimeier/util-linux

* 'build-fixes' of https://github.com/rudimeier/util-linux:
  build-sys: don't clean *.img files

8 years agolibmount: revert X-* and x-* meaning
Karel Zak [Fri, 9 Dec 2016 14:11:31 +0000 (15:11 +0100)] 
libmount: revert X-* and x-* meaning

Let's hope this is last change necessary to cleanup x-* usage:

  x-*  persistent option, stored in utab, available for umount, etc.
  X-*  fstab comment only

mount(8) supports x-mount.mkdir= as well as newly recommended X-mount.mkdir=

Advantages:

 * less invasive
 * does not require exception for x-systemd
 * does not require rename x-initrd to X-initrd

The systemd and dracut users will get the new (=fixed) functionality without a
change in fstab configuration. This is the primary goal.

Disadvantages:

 * not 100% compatible libmount behavior, x-* options have not been
   previously stored in utab. The API is the same, options will be still
   available, but on x-* libmount will write to /run/mount/utab. For now
   it seems only systemd uses x-*, and they like this behavior, so...

Addresses: https://github.com/systemd/systemd/pull/4515
Signed-off-by: Karel Zak <kzak@redhat.com>
8 years agobuild-sys: don't clean *.img files
Ruediger Meier [Wed, 7 Dec 2016 19:39:02 +0000 (20:39 +0100)] 
build-sys: don't clean *.img files

Don't know why this was added in d78df0ac but it can't be right that
libmount/python removes these files in the toplevel builddir. Moreover
I've never seen such *.img files appearing during build at all.

Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
8 years agoMerge branch doc_fixes
Karel Zak [Fri, 9 Dec 2016 12:48:34 +0000 (13:48 +0100)] 
Merge branch doc_fixes

  Rebase from
  http://git.kernel.org/pub/scm/linux/kernel/git/mtk/util-linux.git doc_fixes

  docs: renice(1): Add credentials(7) to SEE ALSO
  docs: renice(1): Add SEE ALSO entry for sched(7)
  docs: mount(8): Wording fix
  docs: ionice(1): SEE ALSO: add ioprio_set(2)
  docs: lsns(8): SEE ALSO: add namespaces(7)
  docs: last(1): Eliminate oddball formatting
  docs: last(1): SEE ALSO: add reference to wtmp(5)
  docs: taskset(1): Wording fix
  docs: namei(1): SEE ALSO: add symlink(7)
  docs: kill(1): Wording fix
  docs: various pages: Use 'UID" and "GID", not "uid" and "gid" in man pages
  docs: various pages: Use "PID" not "pid" in man-pages
  docs: various pages: Use "ID" not "id" in man pages
  docs: various pages: Use consistent terminology (set-user-ID and set-group-ID)
  docs: various pages: Format pathnames as italic (.I)

8 years agodocs: renice(1): Add credentials(7) to SEE ALSO
Michael Kerrisk [Mon, 5 Dec 2016 06:49:42 +0000 (07:49 +0100)] 
docs: renice(1): Add credentials(7) to SEE ALSO

credentials(7) explains concepts such as "process group".

Signed-off-by: Michael Kerrisk <mtk.man-pages@gmail.com>
8 years agodocs: renice(1): Add SEE ALSO entry for sched(7)
Michael Kerrisk [Mon, 5 Dec 2016 06:28:09 +0000 (07:28 +0100)] 
docs: renice(1): Add SEE ALSO entry for sched(7)

The sched(7) page as of the most recent release contains detailed
information on the 'nice' value, including a discussion of
autogrouping, which has surprising interactions with the process
nice value.

Signed-off-by: <mtk.man-pages@gmail.com>
8 years agodocs: mount(8): Wording fix
Michael Kerrisk [Sun, 4 Dec 2016 20:00:34 +0000 (21:00 +0100)] 
docs: mount(8): Wording fix

The correct word here is "practice"; "manner" would not be well
understood by most English speakers.

Signed-off-by: Michael Kerrisk <mtk.man-pages@gmail.com>
8 years agodocs: ionice(1): SEE ALSO: add ioprio_set(2)
Michael Kerrisk [Sat, 3 Dec 2016 19:39:35 +0000 (20:39 +0100)] 
docs: ionice(1): SEE ALSO: add ioprio_set(2)

ioprio_set(2) is the system call that underlies this command.

Signed-off-by: Michael Kerrisk <mtk.man-pages@gmail.com>
8 years agodocs: lsns(8): SEE ALSO: add namespaces(7)
Michael Kerrisk [Sat, 3 Dec 2016 19:38:52 +0000 (20:38 +0100)] 
docs: lsns(8): SEE ALSO: add namespaces(7)

Signed-off-by: Michael Kerrisk <mtk.man-pages@gmail.com>
8 years agodocs: last(1): Eliminate oddball formatting
Michael Kerrisk [Sun, 4 Dec 2016 19:23:54 +0000 (20:23 +0100)] 
docs: last(1): Eliminate oddball formatting

\s-2...\s0 is unused anywhere else. Remove it.

Signed-off-by: Michael Kerrisk <mtk.man-pages@gmail.com>