]> git.ipfire.org Git - thirdparty/util-linux.git/log
thirdparty/util-linux.git
9 years agoutmpdump: use iso-8601 timestamp format with subsecond accuracy
Sami Kerola [Sun, 15 May 2016 09:25:48 +0000 (10:25 +0100)] 
utmpdump: use iso-8601 timestamp format with subsecond accuracy

Newer 'struct utmp' is using 'struct timeval' to represent login and logout
times, so include the maximum accuracy to textual utmp format.  Notice that
this change does not remove support of converting earlier textual formats
back to binary.  But conversions from binary to former format will no longer
be available.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
9 years agolibcommon: add ISO_8601_GMTIME that will print UTC-0 timestamps
Sami Kerola [Sun, 19 Jun 2016 20:43:40 +0000 (21:43 +0100)] 
libcommon: add ISO_8601_GMTIME that will print UTC-0 timestamps

When timestamps are intented to be conversable back from string to binary it
is best to stick with UTC-0 timezone.  This is needed in utmpdump(1).

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
9 years agoutmpdump: use always UTC-0 timezone in textual output
Sami Kerola [Sun, 15 May 2016 08:50:40 +0000 (09:50 +0100)] 
utmpdump: use always UTC-0 timezone in textual output

Converting a time structure from text format that has timezone markup is
practically impossible.  See reference links for more information.  This
leads to situation where multiple utmpdump(1) conversions from binary to
text and back make timestamps to shift amount of timezone offset to UTC-0.

The easiest way to make multiple conversions to work without timeshifts is
to always use UTC-0 timezone.  Downside of this approach is that the textual
format is less human readable than local timestamps would be.

Reference: http://www.catb.org/esr/time-programming/#_strptime_3_and_getdate_3
Reference: http://man7.org/linux/man-pages/man3/strptime.3.html
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
9 years agoliblkid: Add length check in probe_nilfs2 before crc32
Torsten Hilbrich [Mon, 20 Jun 2016 05:09:10 +0000 (07:09 +0200)] 
liblkid: Add length check in probe_nilfs2 before crc32

The bytes variable is read from the file system to probe and must be
checked before used as length parameter in the crc32 call.

The following problems may occur here:

- bytes smaller than sumoff + 4: underflow in length calculation
- bytes larger than remaining space in sb: overflow of buffer

This fixes a problem where an encrypted volume had the correct magic
values 0x3434 at offset 0x406 and the following uint16_t (which is
read into the nilfs_super_block.s_bytes struct) was parsed as 1.

Then crc32 was called with the length value 18446744073709551597
causing a segmentation fault.

[kzak@redhat.com: - fix probe_nilfs2() return code]

Signed-off-by: Karel Zak <kzak@redhat.com>
9 years agolscpu: make lookup_cache() more robust
Karel Zak [Fri, 24 Jun 2016 09:07:00 +0000 (11:07 +0200)] 
lscpu: make lookup_cache() more robust

Signed-off-by: Karel Zak <kzak@redhat.com>
9 years agolscpu: fix MMHZ column entry within man page
Heiko Carstens [Wed, 22 Jun 2016 07:26:01 +0000 (09:26 +0200)] 
lscpu: fix MMHZ column entry within man page

The indentation for the MMHZ column within the man page is wrong. Also
there doesn't exist any column with the name MMHZ. The correct names
would be MAXMHZ and MINMHZ.

Therefore rename MMHZ to MAXMHZ and add the missong MINMHZ entry.

Signed-off-by: Heiko Carstens <heiko.carstens@de.ibm.com>
9 years agolscpu: update s390-lpar-drawer testcase
Heiko Carstens [Wed, 22 Jun 2016 07:26:00 +0000 (09:26 +0200)] 
lscpu: update s390-lpar-drawer testcase

I noticed that the "cpu" line within /proc/cpuinfo has a different
meaning on powerpc and sparc than on s390.

On s390 it represents the cpu number while on powerpc and sparc it
represent the model name. Given that the s390 kernel patch which adds
the "cpu" line to /proc/cpuinfo hasn't been merged into the kernel
yet, I changed that line to "cpu number" to avoid the unnecessary
conflict.

Therefore this patch updates the testcase, which mainly changes the
contents of /proc/cpuinfo.

Signed-off-by: Heiko Carstens <heiko.carstens@de.ibm.com>
9 years agolscpu: show additional caches (s390)
Heiko Carstens [Wed, 22 Jun 2016 07:25:59 +0000 (09:25 +0200)] 
lscpu: show additional caches (s390)

The Linux kernel exposes the cache topology via sysfs. However on
virtualized machines like s390 the cache topology contains only cpu
private caches.

For shared caches it is not known which cpus share them. The
hypervisor would have to update this information whenever a virtual
cpu would be scheduled on a different physical cpu and make the guest
aware of that change. Given that there is hardly any benefit, if it
all, this isn't done.

However it is still of interest to know about the non-private
caches. Therefore this information is available via /proc/cpuinfo at
least on s390.

This patch adds additional lines to the summary output for all shared
caches for which information can be found in /proc/cpuinfo, since we
know these aren't exposed via sysfs.

Signed-off-by: Heiko Carstens <heiko.carstens@de.ibm.com>
9 years agolscpu: show machine type (s390)
Heiko Carstens [Wed, 22 Jun 2016 07:25:58 +0000 (09:25 +0200)] 
lscpu: show machine type (s390)

Show also the machine type within the lscpu output. With the machine
type it is possible to identify the cpu generation and the supported
features.

Signed-off-by: Heiko Carstens <heiko.carstens@de.ibm.com>
9 years agolscpu: show static and dynamic MHz (s390)
Heiko Carstens [Wed, 22 Jun 2016 07:25:57 +0000 (09:25 +0200)] 
lscpu: show static and dynamic MHz (s390)

s390 machines provide static and dynamic cpu mhz information via
/proc/cpuinfo. The static cpu mhz is the normal cpu frequency a cpu is
supposed to run with.

The dynamic cpu mhz is the actual frequency a cpu is running
with. This is usually the same as the static cpu mhz. Note that this
values are different to the min/max mhz values available on other
architecutes. The min/max values are unknown.

This patch adds two new fields to the summary output which display
these two values.

Signed-off-by: Heiko Carstens <heiko.carstens@de.ibm.com>
9 years agolscpu: fix typo in summary output
Heiko Carstens [Wed, 22 Jun 2016 07:25:56 +0000 (09:25 +0200)] 
lscpu: fix typo in summary output

The new drawer support did have a type in the summary output:
it reported Drawers(s) instead of Drawer(s). Fix this.

Signed-off-by: Heiko Carstens <heiko.carstens@de.ibm.com>
9 years agolscpu: add s390 drawer testcase
Heiko Carstens [Tue, 14 Jun 2016 10:38:08 +0000 (12:38 +0200)] 
lscpu: add s390 drawer testcase

Add a new s390 testcase so we get some coverage for the new drawer cpu
topology level.

Signed-off-by: Heiko Carstens <heiko.carstens@de.ibm.com>
9 years agolscpu: add drawer support
Heiko Carstens [Tue, 14 Jun 2016 07:22:34 +0000 (09:22 +0200)] 
lscpu: add drawer support

The s390 architecture gained another cpu topology level called
"drawer" which is above the book level.

Add support for this to lscpu.

Signed-off-by: Heiko Carstens <heiko.carstens@de.ibm.com>
9 years agolibfdisk: cleanup fdisk_gpt_set_npartitions()
Karel Zak [Tue, 21 Jun 2016 12:21:30 +0000 (14:21 +0200)] 
libfdisk: cleanup fdisk_gpt_set_npartitions()

Signed-off-by: Karel Zak <kzak@redhat.com>
9 years agolibfdisk: (gpt) be more careful with 64bit constants
Karel Zak [Tue, 21 Jun 2016 12:06:14 +0000 (14:06 +0200)] 
libfdisk: (gpt) be more careful with 64bit constants

It's probably more robust (and readable) to be explicit when we count
with constant and 64bit numbers.

Addresses: http://bugzilla.redhat.com/show_bug.cgi?id=1344482
Signed-off-by: Karel Zak <kzak@redhat.com>
9 years agologger: be more precise about --port description
Karel Zak [Tue, 21 Jun 2016 11:32:14 +0000 (13:32 +0200)] 
logger: be more precise about --port description

Signed-off-by: Karel Zak <kzak@redhat.com>
9 years agolibblkid: don't check nonnull attributes for NULL [-Wnonnull-compare]
Karel Zak [Tue, 14 Jun 2016 11:55:27 +0000 (13:55 +0200)] 
libblkid: don't check nonnull attributes for NULL [-Wnonnull-compare]

Signed-off-by: Karel Zak <kzak@redhat.com>
9 years agolibmount: don't check nonnull attributes for NULL [-Wnonnull-compare]
Karel Zak [Tue, 14 Jun 2016 11:55:27 +0000 (13:55 +0200)] 
libmount: don't check nonnull attributes for NULL [-Wnonnull-compare]

Signed-off-by: Karel Zak <kzak@redhat.com>
9 years agochfn: chsh: use selinux_check_passwd_access()
Karel Zak [Tue, 14 Jun 2016 11:15:44 +0000 (13:15 +0200)] 
chfn: chsh: use selinux_check_passwd_access()

* selinux/av_permissions.h and magic constants are deprecated, the
  recommended solution is to use string_to_security_class() and
  string_to_av_perm() to get access vector

* it also seems that selinux_check_passwd_access() does exactly the
  same as our checkAccess(), let's use it.

Signed-off-by: Karel Zak <kzak@redhat.com>
9 years agobuild-sys: remove global dependence between widechar and ncursesw
Karel Zak [Thu, 9 Jun 2016 10:39:44 +0000 (12:39 +0200)] 
build-sys: remove global dependence between widechar and ncursesw

It seems that globally defined dependence between ncursesw and
wide-char support is overkill, because in some cases (e.g. cal(1)) we
can use ncurses independently on wide-char support.

It would be better to care about relation between wide-char and
ncurses individually (per util).

Signed-off-by: Karel Zak <kzak@redhat.com>
9 years agotests: fix for non-ncurses version
Karel Zak [Thu, 9 Jun 2016 10:10:33 +0000 (12:10 +0200)] 
tests: fix for non-ncurses version

Signed-off-by: Karel Zak <kzak@redhat.com>
9 years agocal: cleanup non-ncurses build
Karel Zak [Thu, 9 Jun 2016 09:39:24 +0000 (11:39 +0200)] 
cal: cleanup non-ncurses build

9 years agobuild-sys: workaround for autoconf "present but cannot be compiled"
Karel Zak [Wed, 8 Jun 2016 11:38:48 +0000 (13:38 +0200)] 
build-sys: workaround for autoconf "present but cannot be compiled"

See also:
https://www.gnu.org/software/autoconf/manual/autoconf-2.64/html_node/Present-But-Cannot-Be-Compiled.html

Signed-off-by: Karel Zak <kzak@redhat.com>
9 years agobuild-sys: add non-action for ncurses pkg-cong test
Karel Zak [Wed, 8 Jun 2016 10:24:10 +0000 (12:24 +0200)] 
build-sys: add non-action for ncurses pkg-cong test

Signed-off-by: Karel Zak <kzak@redhat.com>
9 years agobuild-sys: clean up relation between ncurses[w] and wide-char support
Karel Zak [Wed, 8 Jun 2016 10:03:15 +0000 (12:03 +0200)] 
build-sys: clean up relation between ncurses[w] and wide-char support

* error if wide-char enabled/supported, but (non-wide) ncurses
  explicitly requested

* disable ncurses at all if widechar enabled/supported, but ncursesw
  not found

Reported-by: Stanislav Brabec <sbrabec@suse.cz>
Signed-off-by: Karel Zak <kzak@redhat.com>
9 years agobuild-sys: cleanup --with-ncurses
Karel Zak [Wed, 8 Jun 2016 09:31:31 +0000 (11:31 +0200)] 
build-sys: cleanup --with-ncurses

 * don't use UL_CHECK_LIB(), only use pkg-config to avoid complexity

 * split --with-ncursesw and --with-ncurses; ncurses (widechar) is the
   default, check for ncurses only if ncursesw disabled/unavailabled

 * don't use generic placeholders, just have_ncursesw and have_ncurses

Signed-off-by: Karel Zak <kzak@redhat.com>
9 years agoionice: clarify description of --classdata
Daniel Shahaf [Fri, 3 Jun 2016 21:27:49 +0000 (21:27 +0000)] 
ionice: clarify description of --classdata

Before this patch, it wasn't clear whether '0' or '7' should be used to
specify "highest priority".  (The answer could have been inferred from
the 'Examples' section of the man page.)

Signed-off-by: Daniel Shahaf <danielsh@apache.org>
9 years agobuild-sys: fix uClibc-ng scanf check
Waldemar Brodkorb [Fri, 3 Jun 2016 02:23:28 +0000 (04:23 +0200)] 
build-sys: fix uClibc-ng scanf check

uClibc-ng tries to be compatible with GNU libc and defines
__GLIBC__ and pretend to be version 2.2.
We once changed it to 2.10, but then some hard to fix problems
in different software packages (gcc) occured.
It would be better if we disable the special GNU libc checks
for uClibc-ng here. uClibc-ng implements the required scanf
functionality.

Signed-off-by: Waldemar Brodkorb <wbx@uclibc-ng.org>
9 years agomore: don't include ncurses.h, fix for non-widechar
Karel Zak [Fri, 3 Jun 2016 12:51:01 +0000 (14:51 +0200)] 
more: don't include ncurses.h, fix for non-widechar

It seems our crazy widechar.h is in conflict with ncurses, but it
seems that nothing in more.c requires anything from ncurses. All we
need is probably <term.h>.

Signed-off-by: Karel Zak <kzak@redhat.com>
9 years agoinclude/widechar: add fallback for WEOF
Karel Zak [Fri, 3 Jun 2016 12:50:48 +0000 (14:50 +0200)] 
include/widechar: add fallback for WEOF

Signed-off-by: Karel Zak <kzak@redhat.com>
9 years agomisc: cleanup non-widechar compilation
Karel Zak [Fri, 3 Jun 2016 12:46:17 +0000 (14:46 +0200)] 
misc: cleanup non-widechar compilation

Signed-off-by: Karel Zak <kzak@redhat.com>
9 years agoinclude/widechar: add missing fallbacks
Karel Zak [Fri, 3 Jun 2016 12:41:04 +0000 (14:41 +0200)] 
include/widechar: add missing fallbacks

Signed-off-by: Karel Zak <kzak@redhat.com>
9 years agobuild-sys: use UL_DEFAULT_ENABLE() only for programs
Karel Zak [Fri, 3 Jun 2016 11:42:40 +0000 (13:42 +0200)] 
build-sys: use UL_DEFAULT_ENABLE() only for programs

The UL_DEFAULT_ENABLE modifies $enable_<name> according to the global
--enable-all-programs. This makes sense only for programs, but not for
any built-in code.

Signed-off-by: Karel Zak <kzak@redhat.com>
9 years agobuild-sys: add --disable-widechar
Karel Zak [Fri, 3 Jun 2016 11:41:51 +0000 (13:41 +0200)] 
build-sys: add --disable-widechar

Signed-off-by: Karel Zak <kzak@redhat.com>
9 years agobuild-sys: add UL_REQUIRES_COMPILE macro
Karel Zak [Fri, 3 Jun 2016 11:37:15 +0000 (13:37 +0200)] 
build-sys: add UL_REQUIRES_COMPILE macro

Signed-off-by: Karel Zak <kzak@redhat.com>
9 years agocfdisk: use libsmartcols ASCII for non-widechar environment
Karel Zak [Fri, 3 Jun 2016 10:20:24 +0000 (12:20 +0200)] 
cfdisk: use libsmartcols ASCII for non-widechar environment

Reported-by: Stanislav Brabec <sbrabec@suse.cz>
Signed-off-by: Karel Zak <kzak@redhat.com>
9 years agolib/mbsalign: fix for non-widechar
Karel Zak [Fri, 3 Jun 2016 10:18:21 +0000 (12:18 +0200)] 
lib/mbsalign: fix for non-widechar

Signed-off-by: Karel Zak <kzak@redhat.com>
9 years agobuild-sys: fix comments in ul.m4
Karel Zak [Fri, 3 Jun 2016 08:20:03 +0000 (10:20 +0200)] 
build-sys: fix comments in ul.m4

Signed-off-by: Karel Zak <kzak@redhat.com>
9 years agolsblk: improve support for nvme
Karel Zak [Thu, 2 Jun 2016 12:41:08 +0000 (14:41 +0200)] 
lsblk: improve support for nvme

Signed-off-by: Karel Zak <kzak@redhat.com>
9 years agolib/sysfs: be more smart for non-scsi devices
Karel Zak [Thu, 2 Jun 2016 12:40:13 +0000 (14:40 +0200)] 
lib/sysfs: be more smart for non-scsi devices

Signed-off-by: Karel Zak <kzak@redhat.com>
9 years agolib/ttyutils: use stdout for get_terminal_width()
Karel Zak [Thu, 2 Jun 2016 10:31:45 +0000 (12:31 +0200)] 
lib/ttyutils: use stdout for get_terminal_width()

We use the function to be sure with *output* width. Note that the
current code (with STDIN) is broken because in some situations
libsmartcols is not able to detect terminal width and fall back to
default 80.

Signed-off-by: Karel Zak <kzak@redhat.com>
9 years agotests: check for mount(8) in minix test
Karel Zak [Wed, 1 Jun 2016 13:04:07 +0000 (15:04 +0200)] 
tests: check for mount(8) in minix test

Signed-off-by: Karel Zak <kzak@redhat.com>
9 years agofsck.minix: fix endless loop and out of stack
Karel Zak [Wed, 1 Jun 2016 12:55:15 +0000 (14:55 +0200)] 
fsck.minix: fix endless loop and out of stack

It seems there is no elegant way how to recovery if a directory i_zone
(and i_size) is out of reality. Let's require human interaction to
avoid endless loop when executed with --auto, etc.

Addresses: https://github.com/karelzak/util-linux/issues/228
Signed-off-by: Karel Zak <kzak@redhat.com>
9 years agofdisk: Fix typo RequiredPartiton -> RequiredPartition
Sebastian Rasmussen [Sun, 29 May 2016 20:11:52 +0000 (22:11 +0200)] 
fdisk: Fix typo RequiredPartiton -> RequiredPartition

This typo fix is backwards compatible in that fdisk will accept both
the GPT attribute RequiredPartition and RequiredPartiton with the typo.
Update documentation and tests to all use the new attribute name.

Signed-off-by: Sebastian Rasmussen <sebras@gmail.com>
9 years agomisc: Fix various typos
Sebastian Rasmussen [Sun, 29 May 2016 21:11:53 +0000 (23:11 +0200)] 
misc: Fix various typos

Fix various typos in error messages, warnings, debug strings,
comments and names of static functions.

Signed-off-by: Sebastian Rasmussen <sebras@gmail.com>
9 years agodocs: Fix various typos
Sebastian Rasmussen [Sun, 29 May 2016 20:54:03 +0000 (22:54 +0200)] 
docs: Fix various typos

Signed-off-by: Sebastian Rasmussen <sebras@gmail.com>
9 years agocal: support timestamps
Karel Zak [Tue, 31 May 2016 16:27:20 +0000 (18:27 +0200)] 
cal: support timestamps

For example

$ cal '2 weeks ago'

Signed-off-by: Karel Zak <kzak@redhat.com>
9 years agocal: allow to specify month by name
Karel Zak [Tue, 31 May 2016 11:53:58 +0000 (13:53 +0200)] 
cal: allow to specify month by name

For example:

$ cal August 2016

Signed-off-by: Karel Zak <kzak@redhat.com>
9 years agofsck.minix: Verify more fields in super-block.
Tobias Stoeckmann [Sun, 29 May 2016 16:56:58 +0000 (18:56 +0200)] 
fsck.minix: Verify more fields in super-block.

The field s_ninodes in super-block is used for memory allocation and
division without verifications. The memory allocation increments the
unchecked value by 1, making it vulnerable to an integer overflow
on 32 bit systems with minix 3 file systems. I did not find a (good)
way to exploit this by crafting a malicious file system, so I consider
it as a reliability issue. If it's 0, a division by zero occurs when
"-v" has been used. A filesystem without any inodes is definitely
wrong, because it means that there's not even the root inode, which is
accessed unchecked later on.

The field s_firstdatazone has to be checked against s_(n)zones. If it
is larger than the highest allowed index, the file system is definitely
corrupted -- hard to say which value is wrong though, therefore I
decided to simply call die(). A maliciously created file system could
do more harm in this way: single bits inside the memory area could be
flipped because range checks would fail. Hard to consider it as a
security issue though, because these addresses are not arbitrarily
accessible without very careful crafting (if at all possible).

[kzak@redhat.com: - fix compiler warning (cast get_nzones()) [-Wsign-compare]]

Signed-off-by: Karel Zak <kzak@redhat.com>
9 years agobuild-sys: add --disable-plymouth-support
Karel Zak [Thu, 26 May 2016 13:05:14 +0000 (15:05 +0200)] 
build-sys: add --disable-plymouth-support

The plymouth support depends on Linux specific SOCK_* flags and all
the feature is probably unnecessary in some cases (non-plymouth
distros, etc.)

Signed-off-by: Karel Zak <kzak@redhat.com>
9 years agolibblkid: store only canonical devnames to the cache
Karel Zak [Thu, 26 May 2016 10:02:12 +0000 (12:02 +0200)] 
libblkid: store only canonical devnames to the cache

Let's try to use symlink:

 # ls -la /dev/block/8\:1
 # lrwxrwxrwx 1 root root 7 May 25 16:42 /dev/block/8:1 -> ../sda1

 # blkid /dev/block/8:1
 /dev/block/8:3: LABEL="HOME" UUID="196972ad-3b13-4bba-ac54-4cb3f7b409a4" TYPE="ext4" PARTUUID="6073277f-87bc-43ff-bcfd-724c4484a63a"

unfortunately the symlink is stored to the cache:

 <device DEVNO="0x0803" TIME="1464253300.715279" LABEL="HOME" UUID="196972ad-3b13-4bba-ac54-4cb3f7b409a4" TYPE="ext4" PARTUUID="6073277f-87bc-43ff-bcfd-724c4484a63a">/dev/block/8:3</device>

next time if you ask for LABEL=HOME the answer will be /dev/block/8:3
rather than /dev/sda3.

It seems better to canonicalize the paths we store to the cache.

Unfortunately if you ask for /dev/block/8:3 then you probably expect
that blkid_dev_devname() returns the same path. This patch introduces
dev->bid_xname, this is the path used by application (and never stored
in the cache).

Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=1332779
Signed-off-by: Karel Zak <kzak@redhat.com>
9 years agolsblk: use ID_WWN_WITH_EXTENSION is possible
Karel Zak [Wed, 25 May 2016 14:11:51 +0000 (16:11 +0200)] 
lsblk: use ID_WWN_WITH_EXTENSION is possible

Addresses: https://github.com/karelzak/util-linux/issues/321
Signed-off-by: Karel Zak <kzak@redhat.com>
9 years agobuild-sys: add tools/Makemodule.am
Karel Zak [Wed, 25 May 2016 13:59:15 +0000 (15:59 +0200)] 
build-sys: add tools/Makemodule.am

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Adds a header option to alter the GPT table length

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

This is useful in two situations:

1. More than 128 partitions are required. Or

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

The gdisk partitioner supports this feature.

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

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

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

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

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

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

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

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

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

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

Based on patch from Timofey Titovets.

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

For example:

   sfdisk -N <parno>

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

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

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

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

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

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

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

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

And use isnan() to detect NaN.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

This reverts commit a14cc9a5046bc4954b4110323c83599f90f9f35e.

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

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

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

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

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

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

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