]> git.ipfire.org Git - thirdparty/util-linux.git/log
thirdparty/util-linux.git
8 years agolibsmartcols: add scols_table_enable_noencoding()
Karel Zak [Mon, 31 Jul 2017 09:45:23 +0000 (11:45 +0200)] 
libsmartcols: add scols_table_enable_noencoding()

Now the library encode all output. It seems too strict and difficult
to use the library for some use-cases -- for example if you want to
use the library for already colorized output (by esc.sequences).

Signed-off-by: Karel Zak <kzak@redhat.com>
8 years agoagetty: fix --login-pause logic
Karel Zak [Mon, 31 Jul 2017 08:27:20 +0000 (10:27 +0200)] 
agetty: fix --login-pause logic

Let's "eat" ENTER key when pressed after login pause prompt.

Addresses: https://github.com/karelzak/util-linux/issues/491
Signed-off-by: Karel Zak <kzak@redhat.com>
8 years agolibblkid: add HPE extended-XFS to known filesystems
Mark Tinguely [Fri, 30 Jun 2017 14:30:39 +0000 (09:30 -0500)] 
libblkid: add HPE extended-XFS to known filesystems

The HPE (formerly SGI) enhanced XFS has changed its magic
version number to allow the use of EXFS and community XFS
filesystems at the same time.

This patch adds HPE EXFS support to libblkid.

[kzak@redhat.com: - removed EXFS log prober, it uses the same magic
                    string as XFS log]

Signed-off-by: Mark Tinguely <mark.tinguely@hpe.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
8 years agohwclock: fix regression from c3ae785
J William Piggott [Tue, 18 Jul 2017 19:42:55 +0000 (15:42 -0400)] 
hwclock: fix regression from c3ae785

hwclock --get foo
hwclock: 3 too many arguments given

Fixed:

hwclock --get foo
hwclock: 1 too many arguments given

Signed-off-by: J William Piggott <elseifthen@gmx.com>
8 years agohwclock: remove unused epoch_option
J William Piggott [Tue, 18 Jul 2017 18:37:30 +0000 (14:37 -0400)] 
hwclock: remove unused epoch_option

Also one whitespace fix.

Signed-off-by: J William Piggott <elseifthen@gmx.com>
8 years agotests: check sfdisk resize on unsorted offsets
Karel Zak [Wed, 19 Jul 2017 13:34:35 +0000 (15:34 +0200)] 
tests: check sfdisk resize on unsorted offsets

Signed-off-by: Karel Zak <kzak@redhat.com>
8 years agolibfdisk: allow to resize in unsorted partition table
Karel Zak [Wed, 19 Jul 2017 13:09:36 +0000 (15:09 +0200)] 
libfdisk: allow to resize in unsorted partition table

The current code assumes that partition offsets (starts) are sorted.
This is usual situation, but unsorted partition table is also valid...

Signed-off-by: Karel Zak <kzak@redhat.com>
8 years agolibfdisk: improve table print debugs
Karel Zak [Wed, 19 Jul 2017 13:09:12 +0000 (15:09 +0200)] 
libfdisk: improve table print debugs

Signed-off-by: Karel Zak <kzak@redhat.com>
8 years agocfdisk: add resize function
Karel Zak [Wed, 19 Jul 2017 11:27:50 +0000 (13:27 +0200)] 
cfdisk: add resize function

Signed-off-by: Karel Zak <kzak@redhat.com>
8 years agolibfdisk: support default partno in mkpart-fullspec sample
Karel Zak [Wed, 19 Jul 2017 09:42:50 +0000 (11:42 +0200)] 
libfdisk: support default partno in mkpart-fullspec sample

Signed-off-by: Karel Zak <kzak@redhat.com>
8 years agolibfdisk: add fdisk_disable_dialogs()
Karel Zak [Wed, 19 Jul 2017 09:30:57 +0000 (11:30 +0200)] 
libfdisk: add fdisk_disable_dialogs()

The default (for historical reasons) is to use dialog driven partitioning.
It's possible to avoid dialogs by fdisk_partition template for
fdisk_add_partition().

Unfortunately in some case (mostly DOS driver) it's not enough, because
we need to distinguish between logical and primary partitions. If we know
that dialogs are unwanted then we can default to primary partition, etc.

This function simplify semantic of the library for non-interactive
programs.

Signed-off-by: Karel Zak <kzak@redhat.com>
8 years agolibfdisk: (dos) return EINVAL when delete unused partition
Karel Zak [Wed, 19 Jul 2017 08:34:03 +0000 (10:34 +0200)] 
libfdisk: (dos) return EINVAL when delete unused partition

Signed-off-by: Karel Zak <kzak@redhat.com>
8 years agoblkid: Add dm-integrity superblock signature
Milan Broz [Tue, 18 Jul 2017 11:08:23 +0000 (13:08 +0200)] 
blkid: Add dm-integrity superblock signature

Since the kernel version 4.12 there is a new dm-integrity module
that provides an emulated per-sector metadata format for storing data integrity.

This patch adds dm-integrity magic signature to blkid to recognize such
a block device.

Signed-off-by: Milan Broz <gmazyland@gmail.com>
8 years agoscript: fix ambiguity about the optional argument of the -t option
Antonio Ospite [Tue, 18 Jul 2017 12:29:07 +0000 (14:29 +0200)] 
script: fix ambiguity about the optional argument of the -t option

[kzak@redhat.com: - merge two patches from Antonio to the one,
                  - update the patch]

Signed-off-by: Karel Zak <kzak@redhat.com>
Signed-off-by: Antonio Ospite <ao2@ao2.it>
8 years agosetpriv: support setting unnamed capabilities
Patrick Steinhardt [Mon, 17 Jul 2017 21:14:09 +0000 (23:14 +0200)] 
setpriv: support setting unnamed capabilities

When setting capabilities, we accept human readable names like for
example `sys_rawio` or `net_admin`. To do so the translation between the
capability name and its in-kernel index, we rely on the function
`capng_name_to_capability`. When the function does not know the named
capability, it will return an error value and we abort setting the
capability.

This relies upon the ability of libcap to know all capabilities inside
of the kernel. But actually, it is possible that new capabilities are
introduced inside of the Linux kernel which are not recognized yet by
the library. When dumping these unknown capabilities, libcap will simply
return a string like "cap_38", that is it will append the capability's
in-kernel index to the prefix "cap_". This may lead a user to also think
that "cap_38" may be passed to the switches "--inh-caps" or
"--ambient-caps", which is unfortunately not the case.

We can do better here by instead accepting strings in the form of
"cap_N". To do so, we can simply rely on the fact that capability
indices are steadily increasing and that the highest index known to the
kernel is stored inside of the kernel's procfs, made readily available
by our function `real_cap_last_cap()`. So in case libcap does not know a
capability name, we can simply parse the string and, if it is in the
correct format, check whether the detected index is between 0 and the
highest capability index. If so, we can treat it as a valid capability
string and apply it.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
8 years agolibfdisk: fix warning -Wunused-function
Ruediger Meier [Tue, 18 Jul 2017 09:07:49 +0000 (11:07 +0200)] 
libfdisk: fix warning -Wunused-function

Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
8 years agobuild-sys: don't use non-existing UUID_LIBS
Ruediger Meier [Thu, 27 Apr 2017 07:12:28 +0000 (09:12 +0200)] 
build-sys: don't use non-existing UUID_LIBS

We've added UUID_LIBS in f77a4d1087 but I don't see what it
was good for.

Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
8 years agolibfdisk: use fdisk_sector_t consistently and fix printf format strings
Ruediger Meier [Thu, 13 Jul 2017 18:00:03 +0000 (20:00 +0200)] 
libfdisk: use fdisk_sector_t consistently and fix printf format strings

Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
8 years agoparse-date: fix printf format
Ruediger Meier [Wed, 12 Jul 2017 19:41:50 +0000 (21:41 +0200)] 
parse-date: fix printf format

warning on 32bit systems:
../lib/parse-date.y: In function 'parse_date':
../lib/parse-date.y:1509:7: warning: format '%ld' expects argument of type 'long int', but argument 4 has type 'intmax_t' [-Wformat=]
       abs_time_zone_min);
       ^

Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
8 years agotests: remove UUIDs with time overflow from uuidparse
Karel Zak [Tue, 18 Jul 2017 08:01:22 +0000 (10:01 +0200)] 
tests: remove UUIDs with time overflow from uuidparse

The time_t used by timeval is "long", it means too small on 32-bits
archs to hold large numbers.

Reported-by: Ruediger Meier <ruediger.meier@ga-group.nl>
Signed-off-by: Karel Zak <kzak@redhat.com>
8 years agolibmount: make mnt_context_is_fs_mounted work for /proc
Ivan Delalande [Fri, 7 Jul 2017 01:27:11 +0000 (18:27 -0700)] 
libmount: make mnt_context_is_fs_mounted work for /proc

Assume that /proc is not mounted instead of returning an error when we
are unable to open the mounts and mountinfo files in /proc. Also set
cxt->mtab back to NULL so that it gets properly parsed when we check if
the next filesystem is mounted.

The goal is to have mount -a work when /proc is not mounted, typically
with /proc on the first line of fstab.

Signed-off-by: Ivan Delalande <colona@arista.com>
8 years agoMerge branch '170711' of github.com:jwpi/util-linux
Karel Zak [Mon, 17 Jul 2017 10:02:24 +0000 (12:02 +0200)] 
Merge branch '170711' of github.com:jwpi/util-linux

* '170711' of github.com:jwpi/util-linux:
  hwclock: improve RTC epoch messages
  hwclock: improve RTC epoch messages
  hwclock: remove dead ioctl check
  hwclock: --epoch presence test fails

8 years agoMerge branch '2017wk28' of git://github.com/kerolasa/lelux-utiliteetit
Karel Zak [Mon, 17 Jul 2017 09:59:35 +0000 (11:59 +0200)] 
Merge branch '2017wk28' of git://github.com/kerolasa/lelux-utiliteetit

* '2017wk28' of git://github.com/kerolasa/lelux-utiliteetit:
  bash-completion: make completions to work when bash set -u is in use
  uuidparse: add bash-completion file
  docs: add optional option back to struct option
  ldattach: simplify debugging function when vwarnx(3) is available
  reset: remove script from the package

8 years agotest: update PMBR hex dumps
Karel Zak [Mon, 17 Jul 2017 09:36:28 +0000 (11:36 +0200)] 
test: update PMBR hex dumps

The commit 8ffa3b651d7e74acba8f1d831b7f68fdb3c66aae has fixed PMBR
CHS addresses initialization to be more close to UEFI standard.

-000001c0  01 00 ee fe ff ff 01 00  00 00 ff 8f 01 00 00 00
+000001c0  02 00 ee ff ff ff 01 00  00 00 ff 8f 01 00 00 00

Signed-off-by: Karel Zak <kzak@redhat.com>
8 years agolibfdisk: use BLKPG_* ioctls on linux only
Karel Zak [Mon, 17 Jul 2017 07:47:42 +0000 (09:47 +0200)] 
libfdisk: use BLKPG_* ioctls on linux only

Signed-off-by: Karel Zak <kzak@redhat.com>
8 years agohwclock: improve RTC epoch messages
J William Piggott [Sat, 15 Jul 2017 20:01:13 +0000 (16:01 -0400)] 
hwclock: improve RTC epoch messages

Signed-off-by: J William Piggott <elseifthen@gmx.com>
8 years agohwclock: improve RTC epoch messages
J William Piggott [Sat, 15 Jul 2017 19:44:20 +0000 (15:44 -0400)] 
hwclock: improve RTC epoch messages

Make consistent and improve messages in get_epoch_rtc()
and set_epoch_rtc().

Signed-off-by: J William Piggott <elseifthen@gmx.com>
8 years agohwclock: remove dead ioctl check
J William Piggott [Sat, 15 Jul 2017 17:56:01 +0000 (13:56 -0400)] 
hwclock: remove dead ioctl check

The epoch ioctls test hasn't been valid for 20 years (v2.1.88).
RTC has returned ENOTTY for unimplemented ioctls for 15 years.

The check is made for RTC_EPOCH_SET, but not for RTC_EPOCH_READ.
They were both implemented at the same time.

Signed-off-by: J William Piggott <elseifthen@gmx.com>
8 years agohwclock: --epoch presence test fails
J William Piggott [Fri, 14 Jul 2017 19:51:47 +0000 (15:51 -0400)] 
hwclock: --epoch presence test fails

hwclock --setepoch --epoch 0
Will warn that the epoch option is required.

The --epoch presence test is made on its argument after it is
converted to an integer. This means any value it can be tested
for, can also be given as an input.

So make the conversion after the presence test, like the
--date option does.

Signed-off-by: J William Piggott <elseifthen@gmx.com>
8 years agobash-completion: make completions to work when bash set -u is in use
Sami Kerola [Fri, 30 Jun 2017 22:13:58 +0000 (23:13 +0100)] 
bash-completion: make completions to work when bash set -u is in use

User who want to avoid refering to none-existing variables got earlier the
following error.

$ set -u
$ findmnt --output <tab>bash: OUTPUT: unbound variable

Here is short explanation of this setting.

$ help set
 -u  Treat unset variables as an error when substituting.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
8 years agouuidparse: add bash-completion file
Sami Kerola [Fri, 30 Jun 2017 22:04:48 +0000 (23:04 +0100)] 
uuidparse: add bash-completion file

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
8 years agodocs: add optional option back to struct option
Sami Kerola [Wed, 28 Jun 2017 22:24:54 +0000 (23:24 +0100)] 
docs: add optional option back to struct option

The line was accidentally removed in the reference commit where only the
short option had to go.  Rest of the change is indentation.

Reference: 326c5c93b917a623f346155c8b3438b379d9fd60
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
8 years agoldattach: simplify debugging function when vwarnx(3) is available
Sami Kerola [Sat, 24 Jun 2017 16:01:22 +0000 (17:01 +0100)] 
ldattach: simplify debugging function when vwarnx(3) is available

The vwarnx(3) is probably not available in all libc implementations, in such
cases use the earlier printout as a fallback.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
8 years agoreset: remove script from the package
Sami Kerola [Sat, 24 Jun 2017 11:09:34 +0000 (12:09 +0100)] 
reset: remove script from the package

This script requires ncurses to work, and the ncurses provides reset so
there should not be need to keep this script hanging around.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
8 years agolibfdisk: make fdisk compliant to UEFI/GPT specification on PMBR
Karel Zak [Fri, 14 Jul 2017 10:48:18 +0000 (12:48 +0200)] 
libfdisk: make fdisk compliant to UEFI/GPT specification on PMBR

The PMBR partition record should be StartingCHS=0x002000 (0/0/2)
and EndingCHS=0xFFFFFF (1023/255/63)

Addresses: https://github.com/karelzak/util-linux/issues/485
Signed-off-by: Karel Zak <kzak@redhat.com>
8 years agolibfdisk: remove whitespaces
Karel Zak [Fri, 14 Jul 2017 09:36:22 +0000 (11:36 +0200)] 
libfdisk: remove whitespaces

Signed-off-by: Karel Zak <kzak@redhat.com>
8 years agocfdisk: use fdisk_reread_changes()
Karel Zak [Fri, 14 Jul 2017 09:08:54 +0000 (11:08 +0200)] 
cfdisk: use fdisk_reread_changes()

Let's make cfdisk usable for disks where some partitions are mounted.

Signed-off-by: Karel Zak <kzak@redhat.com>
8 years agofdisk: use fdisk_reread_changes()
Karel Zak [Fri, 14 Jul 2017 09:08:54 +0000 (11:08 +0200)] 
fdisk: use fdisk_reread_changes()

Let's make fdisk usable for disks where some partitions are mounted.

Signed-off-by: Karel Zak <kzak@redhat.com>
8 years agolibfdisk: use BLKPG ioctls to inform kernel about changes
Karel Zak [Fri, 14 Jul 2017 08:51:14 +0000 (10:51 +0200)] 
libfdisk: use BLKPG ioctls to inform kernel about changes

This patch introduces fdisk_reread_changes(). The function is
less invasive alternative to fdisk_reread_partition_table().

The new function uses BLKPG ioctls for modified partitions. The
another partitions are not affected. This solution allows to
successfully use fdisks on disk where some partitions are still use
(mounted). For example if you want to resize the last partition on the
device.

Signed-off-by: Karel Zak <kzak@redhat.com>
8 years agopartx: move partx.h to include/
Karel Zak [Thu, 13 Jul 2017 11:46:52 +0000 (13:46 +0200)] 
partx: move partx.h to include/

Let's make the ioctls usable also for libfdisk.

Signed-off-by: Karel Zak <kzak@redhat.com>
8 years agolibfdisk: add comment
Karel Zak [Mon, 3 Jul 2017 08:23:16 +0000 (10:23 +0200)] 
libfdisk: add comment

Signed-off-by: Karel Zak <kzak@redhat.com>
8 years agosfdisk: use fdisk_device_is_used()
Karel Zak [Fri, 30 Jun 2017 09:49:29 +0000 (11:49 +0200)] 
sfdisk: use fdisk_device_is_used()

Signed-off-by: Karel Zak <kzak@redhat.com>
8 years agolibfdisk: add fdisk_device_is_used()
Karel Zak [Fri, 30 Jun 2017 09:49:12 +0000 (11:49 +0200)] 
libfdisk: add fdisk_device_is_used()

Signed-off-by: Karel Zak <kzak@redhat.com>
8 years agolibfdisk: remove unnecessary fstat() call
Karel Zak [Fri, 30 Jun 2017 09:29:47 +0000 (11:29 +0200)] 
libfdisk: remove unnecessary fstat() call

Signed-off-by: Karel Zak <kzak@redhat.com>
8 years agolibfdisk: move fdisk_reread_partition_table() to another file
Karel Zak [Fri, 30 Jun 2017 09:24:36 +0000 (11:24 +0200)] 
libfdisk: move fdisk_reread_partition_table() to another file

Signed-off-by: Karel Zak <kzak@redhat.com>
8 years agolibblkid: don't use CDROM_GET_CAPABILITY ioctl for DM devices
Karel Zak [Wed, 12 Jul 2017 12:35:53 +0000 (14:35 +0200)] 
libblkid: don't use CDROM_GET_CAPABILITY ioctl for DM devices

For some reason kernel commit e980f62353c697cbf0c4325e43df6e44399aeb64
add extra warning when the ioctl is used for DM devices. It seems we
can avoid this ioctl when the device has dm/uuid.

Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=1469532
Signed-off-by: Karel Zak <kzak@redhat.com>
8 years agotests: don't use errno in output
Karel Zak [Wed, 12 Jul 2017 10:34:22 +0000 (12:34 +0200)] 
tests: don't use errno in output

Signed-off-by: Karel Zak <kzak@redhat.com>
8 years agoMerge branch 'master' of https://github.com/pali/util-linux
Karel Zak [Tue, 11 Jul 2017 12:31:23 +0000 (14:31 +0200)] 
Merge branch 'master' of https://github.com/pali/util-linux

* 'master' of https://github.com/pali/util-linux:
  tests: update UDF test, add ID_FS_VERSION
  libblkid: udf: Add support for ID_FS_VERSION
  libblkid: udf: Fix types
  libblkid: udf: De-duplicate code for dstring decoding

8 years agotests: use sample-fdisk-mkpart-fullspec
Karel Zak [Tue, 11 Jul 2017 12:26:33 +0000 (14:26 +0200)] 
tests: use sample-fdisk-mkpart-fullspec

Signed-off-by: Karel Zak <kzak@redhat.com>
8 years agolibfdisk: (dos) accept start for log.partitions on template
Karel Zak [Tue, 11 Jul 2017 12:24:32 +0000 (14:24 +0200)] 
libfdisk: (dos) accept start for log.partitions on template

Signed-off-by: Karel Zak <kzak@redhat.com>
8 years agotests: check for missing programs in last(1) test
Karel Zak [Tue, 11 Jul 2017 11:41:22 +0000 (13:41 +0200)] 
tests: check for missing programs in last(1) test

Signed-off-by: Karel Zak <kzak@redhat.com>
8 years agotests: use sample-fdisk-mkpart
Karel Zak [Tue, 11 Jul 2017 11:33:52 +0000 (13:33 +0200)] 
tests: use sample-fdisk-mkpart

Signed-off-by: Karel Zak <kzak@redhat.com>
8 years agolibfdisk: don't hardcode label type in samples
Karel Zak [Tue, 11 Jul 2017 11:27:01 +0000 (13:27 +0200)] 
libfdisk: don't hardcode label type in samples

Signed-off-by: Karel Zak <kzak@redhat.com>
8 years agolibfdisk: add sample-fdisk-mkpart-fullspec
Karel Zak [Tue, 11 Jul 2017 11:00:46 +0000 (13:00 +0200)] 
libfdisk: add sample-fdisk-mkpart-fullspec

Signed-off-by: Karel Zak <kzak@redhat.com>
8 years agolibfdisk: (dos) cleanup template based partitioning
Karel Zak [Tue, 11 Jul 2017 10:25:02 +0000 (12:25 +0200)] 
libfdisk: (dos) cleanup template based partitioning

Signed-off-by: Karel Zak <kzak@redhat.com>
8 years agolibblkid: don't check for size on UBI (char dev)
Karel Zak [Tue, 11 Jul 2017 10:17:40 +0000 (12:17 +0200)] 
libblkid: don't check for size on UBI (char dev)

Signed-off-by: Karel Zak <kzak@redhat.com>
8 years agohwclock: sync one-liner descriptions
J William Piggott [Sun, 2 Jul 2017 18:09:41 +0000 (14:09 -0400)] 
hwclock: sync one-liner descriptions

Make whatisdb/manpage and usage() one-line descriptions match.

Also update the description; hwclock has evolved into much more
than reading and setting the Hardware Clock. It also sets the
System Clock, warps the System Clock, sets the kernel time
configurations, and more.

Signed-off-by: J William Piggott <elseifthen@gmx.com>
8 years agodocs: update boilerplate.c usage()
J William Piggott [Sun, 2 Jul 2017 00:44:46 +0000 (20:44 -0400)] 
docs: update boilerplate.c usage()

Signed-off-by: J William Piggott <elseifthen@gmx.com>
8 years agohwclock: final usage() strings slice
J William Piggott [Sun, 2 Jul 2017 00:16:48 +0000 (20:16 -0400)] 
hwclock: final usage() strings slice

Signed-off-by: J William Piggott <elseifthen@gmx.com>
8 years agohwclock: usage() use program_invocation_short_name
J William Piggott [Sun, 2 Jul 2017 00:05:56 +0000 (20:05 -0400)] 
hwclock: usage() use program_invocation_short_name

Signed-off-by: J William Piggott <elseifthen@gmx.com>
8 years agohwclock: remove from usage() FILE *out = stdout
J William Piggott [Sat, 1 Jul 2017 18:07:14 +0000 (14:07 -0400)] 
hwclock: remove from usage() FILE *out = stdout

Signed-off-by: J William Piggott <elseifthen@gmx.com>
8 years agomount: remove extN from mount.8 man page
Karel Zak [Mon, 10 Jul 2017 10:51:53 +0000 (12:51 +0200)] 
mount: remove extN from mount.8 man page

The e2fsprogs package contains ext4(5) man page with all necessary
information. We do not have to duplicate effort and maintain copy of
the extN mount options in our mount.8.

(We already do the same for XFS.)

Signed-off-by: Karel Zak <kzak@redhat.com>
8 years agofdisk: reset context after failed script
Karel Zak [Mon, 10 Jul 2017 10:32:43 +0000 (12:32 +0200)] 
fdisk: reset context after failed script

Addresses: https://github.com/karelzak/util-linux/issues/481
Signed-off-by: Karel Zak <kzak@redhat.com>
8 years agolibfdisk: add fdisk_reassign_device()
Karel Zak [Mon, 10 Jul 2017 10:32:26 +0000 (12:32 +0200)] 
libfdisk: add fdisk_reassign_device()

Signed-off-by: Karel Zak <kzak@redhat.com>
8 years agoagetty: print /etc/issue on --skip-login
Karel Zak [Mon, 10 Jul 2017 08:42:49 +0000 (10:42 +0200)] 
agetty: print /etc/issue on --skip-login

The current --skip-login implementation disables also issue file
printing. This is unexpected behavior as /etc/issue may contains
important information and we have --noissue for admins who don't want
it.

This patch forces /etc/issue printing if --noissue no specified.

Addresses: https://github.com/karelzak/util-linux/issues/480
Signed-off-by: Karel Zak <kzak@redhat.com>
8 years agoMerge branch 'help' of https://github.com/rudimeier/util-linux
Karel Zak [Mon, 10 Jul 2017 08:15:22 +0000 (10:15 +0200)] 
Merge branch 'help' of https://github.com/rudimeier/util-linux

* 'help' of https://github.com/rudimeier/util-linux:
  setpriv: silence compiler warning
  misc: consolidate macro style USAGE_HELP_OPTIONS
  blockdev: correct man page name in --help

8 years agolast: condition (secs == 0) - now handled correctly
coastal-hiker [Tue, 27 Jun 2017 12:14:49 +0000 (14:14 +0200)] 
last: condition (secs == 0) - now handled correctly

Changed comparison "if (secs > 0)" to "if (secs >= 0)" to handle
condition (secs == 0) correctly.  Suggestions to improve the
less-than-elegant if-else chain are welcome.

Signed-off-by: Karel Zak <kzak@redhat.com>
8 years agolast: don't show negative time
coastal-hiker [Mon, 26 Jun 2017 16:40:28 +0000 (18:40 +0200)] 
last: don't show negative time

Under strange circumstances, the output of command 'last reboot'
showed the last time as a negative time, with both the hours and the
mins value having a minus sign. Example, taken from my workstation:

$last reboot
[...]
reboot   system boot  4.4.0-79-generic Wed Jun 14 09:20 - 07:33  (-1:-47)
[...]

I am aware this should happen only infrequently. Nevertheless, I
propose a more robust behaviour: show a minus sign only for the most
significant value (days or hours) and show the rest always as
positive. In the special case of ((secs < 0) && (secs >= -59)), print
mins as "-00".

Signed-off-by: Karel Zak <kzak@redhat.com>
8 years agotests: update UDF test, add ID_FS_VERSION
Pali Rohár [Wed, 5 Jul 2017 11:56:05 +0000 (13:56 +0200)] 
tests: update UDF test, add ID_FS_VERSION

8 years agolibblkid: udf: Add support for ID_FS_VERSION
Pali Rohár [Wed, 5 Jul 2017 11:50:52 +0000 (13:50 +0200)] 
libblkid: udf: Add support for ID_FS_VERSION

Set ID_FS_VERSION to Minimum UDF Read Revision.

8 years agolibblkid: udf: Fix types
Pali Rohár [Wed, 5 Jul 2017 11:46:12 +0000 (13:46 +0200)] 
libblkid: udf: Fix types

8 years agolibblkid: udf: De-duplicate code for dstring decoding
Pali Rohár [Wed, 5 Jul 2017 10:15:00 +0000 (12:15 +0200)] 
libblkid: udf: De-duplicate code for dstring decoding

8 years agologin: use IPv4 on IPv4-mapping-to-IPv6
Karel Zak [Tue, 4 Jul 2017 10:50:39 +0000 (12:50 +0200)] 
login: use IPv4 on IPv4-mapping-to-IPv6

It seems that on some systems (e.g. RHEL7) the libc function
getaddrinfo() is not able to translate ::ffff: address to IPv4. The
result is 0.0.0.0 host address in the last(1) and utmpdump(1) output.

 /sbin/login -h "::ffff:192.168.1.7"

utmpdump:

  [7] [03926] [1   ] [user1   ] [pts/1       ] [::ffff:192.168.1.7  ] [0.0.0.0        ] [Thu May 12 17:49:50 2016    ]

Not sure if this is about order of the getaddrinfo() results, system
configuration or libc version. It's irrelevant for login(1). We have
to be robust enough to write usable address to log files everywhere.

The solution is to detect IPv4-mapping-to-IPv6 and use IPv4 for utmp.

Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=1296233
Signed-off-by: Karel Zak <kzak@redhat.com>
8 years agosetpriv: silence compiler warning
Ruediger Meier [Thu, 29 Jun 2017 15:28:01 +0000 (17:28 +0200)] 
setpriv: silence compiler warning

This got lost in 30129e2f

sys-utils/setpriv.c:182:32: warning: implicit conversion from enumeration type
      'enum cap_type' to different enumeration type 'capng_type_t'
      [-Wenum-conversion]
                return capng_have_capability(which, i);
                       ~~~~~~~~~~~~~~~~~~~~~ ^~~~~

Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
8 years agomisc: consolidate macro style USAGE_HELP_OPTIONS
Ruediger Meier [Thu, 29 Jun 2017 13:52:16 +0000 (15:52 +0200)] 
misc: consolidate macro style USAGE_HELP_OPTIONS

changed in include/c.h and applied via sed:

  sed -i 's/fprintf.*\(USAGE_MAN_TAIL.*\)/printf(\1/' $(git ls-files -- "*.c")
  sed -i 's/print_usage_help_options\(.*\);/printf(USAGE_HELP_OPTIONS\1);/' $(git ls-files -- "*.c")

Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
8 years agoblockdev: correct man page name in --help
Ruediger Meier [Thu, 29 Jun 2017 13:03:23 +0000 (15:03 +0200)] 
blockdev: correct man page name in --help

Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
8 years agoMerge branch 'path-fixes' of https://github.com/rudimeier/util-linux
Karel Zak [Thu, 29 Jun 2017 13:29:33 +0000 (15:29 +0200)] 
Merge branch 'path-fixes' of https://github.com/rudimeier/util-linux

* 'path-fixes' of https://github.com/rudimeier/util-linux:
  hwclock: don't ifdef printf arguments
  setpriv: align --help
  tools: add segfault detection for checkusage.sh
  misc: avoid some dead initialization warnings
  lscpu: make clang analyzer happy
  lsmem: fix, using freed memory
  lib/path: add error handling to path_vcreate()
  lib/path: fix crash, pathbuf overflow

8 years agohwclock: don't ifdef printf arguments
Ruediger Meier [Wed, 28 Jun 2017 16:37:44 +0000 (18:37 +0200)] 
hwclock: don't ifdef printf arguments

This may fails if printf() is macro, introduced in cc7cb070.

clang compiler warnings:

    CC       sys-utils/hwclock.o
  ../sys-utils/hwclock.c:1228:2: warning: embedding a directive within macro arguments has undefined behavior [-Wembedded-directive]
  #ifdef __linux__
   ^
  ../sys-utils/hwclock.c:1230:2: warning: embedding a directive within macro arguments has undefined behavior [-Wembedded-directive]
  #endif
   ^
  2 warnings generated.

CC: J William Piggott <elseifthen@gmx.com>
Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
8 years agosetpriv: align --help
Ruediger Meier [Tue, 27 Jun 2017 18:36:11 +0000 (20:36 +0200)] 
setpriv: align --help

This was forgotton during my last cleanup because the build was
auto-disabled on my system.

Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
8 years agotools: add segfault detection for checkusage.sh
Ruediger Meier [Tue, 27 Jun 2017 18:34:29 +0000 (20:34 +0200)] 
tools: add segfault detection for checkusage.sh

Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
8 years agomisc: avoid some dead initialization warnings
Ruediger Meier [Sat, 17 Jun 2017 20:40:41 +0000 (22:40 +0200)] 
misc: avoid some dead initialization warnings

Clang analyzer warnings:

Dead store, Dead initialization:

    lib/mbsedit.c:154:8: warning: Value stored to 'in' during its initialization is never read
            char *in = (char *) &c;
                  ^~   ~~~~~~~~~~~

    misc-utils/findmnt-verify.c:129:14: warning: Value stored to 'cn' during its initialization is never read
            const char *cn = tgt;
                        ^~   ~~~
Dead store, Dead increment:

    sys-utils/hwclock.c:1461:2: warning: Value stored to 'argv' is never read
            argv += optind;
            ^       ~~~~~~

Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
8 years agolscpu: make clang analyzer happy
Ruediger Meier [Tue, 27 Jun 2017 18:33:28 +0000 (20:33 +0200)] 
lscpu: make clang analyzer happy

Let read_nodes() work on uninitialized structs to silence these two
warnings:

  CC       sys-utils/lscpu-lscpu.o
warning: Path diagnostic report is not generated. Current output format does not support diagnostics that cross file boundaries. Refer to --analyzer-output for valid output formats
In file included from sys-utils/lscpu.c:63:
./include/xalloc.h:32:21: warning: Call to 'malloc' has an allocation size of 0 bytes
        void *ret = malloc(size);
                    ^~~~~~~~~~~~
sys-utils/lscpu.c:1468:23: warning: Function call argument is an uninitialized value
                desc->nodemaps[i] = path_read_cpuset(maxcpus,
                                    ^~~~~~~~~~~~~~~~~~~~~~~~~
2 warnings generated.

Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
8 years agolsmem: fix, using freed memory
Ruediger Meier [Tue, 27 Jun 2017 18:33:18 +0000 (20:33 +0200)] 
lsmem: fix, using freed memory

Simply avoiding strdup(). Error handling improved.

This was the Clang Analyzer warning:

    Memory Error, Use-after-free
    sys-utils/lsmem.c:259:3: warning: Use of memory after it is freed
                    err(EXIT_FAILURE, _("Failed to open %s"), path);
                    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
8 years agolib/path: add error handling to path_vcreate()
Ruediger Meier [Tue, 27 Jun 2017 18:33:08 +0000 (20:33 +0200)] 
lib/path: add error handling to path_vcreate()

Do not operate on truncated/random paths. Note, path_strdup()
can now really return NULL, to be handled in next commit.

Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
8 years agotests: explicitly define wipefs outpuit columns
Karel Zak [Thu, 29 Jun 2017 11:31:35 +0000 (13:31 +0200)] 
tests: explicitly define wipefs outpuit columns

Signed-off-by: Karel Zak <kzak@redhat.com>
8 years agotests: update wipefs outputs
Karel Zak [Thu, 29 Jun 2017 11:07:10 +0000 (13:07 +0200)] 
tests: update wipefs outputs

Signed-off-by: Karel Zak <kzak@redhat.com>
8 years agocolumn: fix compilation when libc lacks wide-character support
Carlos Santos [Thu, 29 Jun 2017 10:55:42 +0000 (07:55 -0300)] 
column: fix compilation when libc lacks wide-character support

Commit 4762ae9d removed mtsafe_strtok() but left behind calls to wcstok
and wcspbrk. This leads to build failures when libc does not have the
wide-character functions, like some uClibc builds.

Solve the problem by using strtok_r and strpbrk when HAVE_WIDECHAR is
not defined.

Fixes:
  http://autobuild.buildroot.net/results/fd8a1a8e0cef3aeed9588540e8e663664f6b43aa
  http://autobuild.buildroot.net/results/5ad73ea8b471321988c50d80a5e50d4504151dd6
  http://autobuild.buildroot.net/results/04411b7280dc51ecd51236967981a42352bbeb3e

Signed-off-by: Carlos Santos <casantos@datacom.ind.br>
8 years agolibmount: use _exit() in <type> handlers
Karel Zak [Thu, 29 Jun 2017 10:58:57 +0000 (12:58 +0200)] 
libmount: use _exit() in <type> handlers

The originally used exit() is bad idea for the shared library.

Reported-by: Ruediger Meier <sweet_f_a@gmx.de>
Signed-off-by: Karel Zak <kzak@redhat.com>
8 years agodocs: correct line(1) deprecation comment
Ruediger Meier [Thu, 29 Jun 2017 02:09:08 +0000 (04:09 +0200)] 
docs: correct line(1) deprecation comment

Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
8 years agolib/blkdev: remove support for Linux < 2.6
Ruediger Meier [Thu, 29 Jun 2017 02:09:07 +0000 (04:09 +0200)] 
lib/blkdev: remove support for Linux < 2.6

Remove a hack for kernels between  2.4.15 and 2.4.17

Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
8 years agodocs: remove some old history from manpages
Ruediger Meier [Thu, 29 Jun 2017 02:09:06 +0000 (04:09 +0200)] 
docs: remove some old history from manpages

We assume that users will have a kernel >= 2.6.0 and removel
references to earlier kernels. There are still a few ones
left.

Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
8 years agouuidgen: improve --help
Karel Zak [Thu, 29 Jun 2017 10:40:22 +0000 (12:40 +0200)] 
uuidgen: improve --help

Signed-off-by: Karel Zak <kzak@redhat.com>
8 years agowipefs: improve --help
Karel Zak [Thu, 29 Jun 2017 10:38:40 +0000 (12:38 +0200)] 
wipefs: improve --help

Signed-off-by: Karel Zak <kzak@redhat.com>
8 years agowipefs: use libsmartcols
Karel Zak [Thu, 29 Jun 2017 09:57:22 +0000 (11:57 +0200)] 
wipefs: use libsmartcols

The old output is horrible and useless when more devices specified.
The old format is also too tricky if more signatures detected. The new
output uses one line for each signature, prefixed by device name.

For example my workstation:

# wipefs /dev/sda* /dev/sdb*
DEVICE OFFSET       TYPE UUID                                 LABEL
sda    0x1fe        PMBR
sda    0x37e4895e00 gpt
sda    0x200        gpt
sda1   0x1fe        vfat F2BC-BFEC                            EFI
sda1   0x0          vfat F2BC-BFEC                            EFI
sda1   0x36         vfat F2BC-BFEC                            EFI
sda2   0x438        ext4 c5490147-2a6c-4c8a-aa1b-33492034f927 BOOT
sda3   0x438        ext4 196972ad-3b13-4bba-ac54-4cb3f7b409a4 HOME
sda4   0x438        ext4 d834bc84-0089-4be1-9013-cd8bf35d5ffa ROOT
sda5   0x438        ext4 e8ce5375-29d4-4e2f-a688-d3bae4b8d162 WINE
sda6   0xff6        swap 210337c6-f8b5-4d65-aab5-a0f343fa9ad4 SWAP
sdb    0x200        gpt
sdb    0x1fe        dos
sdb1   0x438        ext4 6467a684-0d10-4f61-a301-67bb26934d90

This patch add --noheadings, --json and --output.

Signed-off-by: Karel Zak <kzak@redhat.com>
8 years agouuidparse: se JSON table name on -J
Karel Zak [Thu, 29 Jun 2017 09:07:54 +0000 (11:07 +0200)] 
uuidparse: se JSON table name on -J

Signed-off-by: Karel Zak <kzak@redhat.com>
8 years agowipefs: try another magic strings on -o and -t
Karel Zak [Wed, 28 Jun 2017 10:08:25 +0000 (12:08 +0200)] 
wipefs: try another magic strings on -o and -t

The commit 92296e9ba2bf95259520fa7537ff8edc2aa9edbc introduces "try
all permutations for the same superblock". This feature has to be also
available if -o and -t is specified.

Signed-off-by: Karel Zak <kzak@redhat.com>
8 years agowipefs: add control struct
Karel Zak [Wed, 28 Jun 2017 09:51:12 +0000 (11:51 +0200)] 
wipefs: add control struct

Signed-off-by: Karel Zak <kzak@redhat.com>
8 years agowipefs: don't do step-back if <type> does not match
Karel Zak [Fri, 16 Jun 2017 09:36:41 +0000 (11:36 +0200)] 
wipefs: don't do step-back if <type> does not match

Signed-off-by: Karel Zak <kzak@redhat.com>
8 years agowipefs: print all signature permutations
Karel Zak [Fri, 26 May 2017 11:11:37 +0000 (13:11 +0200)] 
wipefs: print all signature permutations

The same FS/RAID/PT signature may be detected by more ways and on more
places on the device. The libblkid returns only the first detected
signature by default. This patch use blkid_probe_hide_range() to
re-scan device for all possible permutations of the same signature.

For example the default wipefs(8) output as well as --no-act output will
contains primary as well as backup GPT signature now.

Reported-by: Ruediger Meier <sweet_f_a@gmx.de>
Signed-off-by: Karel Zak <kzak@redhat.com>
8 years agolibblkid: allow to hide already detected signatures
Karel Zak [Fri, 26 May 2017 10:58:09 +0000 (12:58 +0200)] 
libblkid: allow to hide already detected signatures

The libblkid probing functions returns the first successful result of
the filesystem/RAID/PT. Unfortunately, some signatures is possible to
detect by more ways or device may contains more copies (e.g. GPT).

This is no problem when we wipe signatures from the device. In this
case we zeroize on-device signature and re-scan for the signature (by
blkid_probe_step_back()).

The problem is if we want to read all permutations without the device
modification (for example wipefs(8) dry run).

This patch add blkid_probe_hide_range(). The function remove (zeroize)
specified signature from in-memory cached buffers. If the buffer is
later re-used by probing functions then the signature is invisible and
we can try detect another variant of the magic string.

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