]> git.ipfire.org Git - thirdparty/util-linux.git/log
thirdparty/util-linux.git
8 years agolibmout: Reuse loop device safely
Stanislav Brabec [Thu, 14 Jul 2016 13:29:44 +0000 (15:29 +0200)] 
libmout: Reuse loop device safely

Add a safety check to mnt_context_setup_loopdev(). Only a loop device with equal
offset and sizelimit will be reused. If any overlapping loop device exists,
MNT_ERR_LOOPOVERLAP is returned.

Signed-off-by: Stanislav Brabec <sbrabec@suse.cz>
8 years agoImplement loopcxt_check_conflict()
Stanislav Brabec [Thu, 14 Jul 2016 13:29:21 +0000 (15:29 +0200)] 
Implement loopcxt_check_conflict()

Add a function that searches for a possible conflicting (i. e. overlaying loop
device).

Signed-off-by: Stanislav Brabec <sbrabec@suse.cz>
8 years agoAdd sizelimit to internal API
Stanislav Brabec [Thu, 14 Jul 2016 13:29:09 +0000 (15:29 +0200)] 
Add sizelimit to internal API

Fully safe checks of loop device need to check sizelimit. To prevent need of two
nearly equal functions, introduce sizelimit parameter to several internal
functions:
loopdev_is_used()
loopdev_find_by_backing_file()
loopcxt_is_used()
loopcxt_find_by_backing_file()

If sizelimit is zero, fall back to the old behavior (ignoring of sizelimit).

Signed-off-by: Stanislav Brabec <sbrabec@suse.cz>
8 years agomount: Handle MNT_ERR_LOOPOVERLAP
Stanislav Brabec [Thu, 14 Jul 2016 13:28:58 +0000 (15:28 +0200)] 
mount: Handle MNT_ERR_LOOPOVERLAP

Use warnx(), as there is no strerror() text associated with it.

There is currently no easy way to report name and type of conflict.

Signed-off-by: Stanislav Brabec <sbrabec@suse.cz>
8 years agolibmount: Introduce new error: MNT_ERR_LOOPOVERLAP
Stanislav Brabec [Thu, 14 Jul 2016 13:28:45 +0000 (15:28 +0200)] 
libmount: Introduce new error: MNT_ERR_LOOPOVERLAP

This error code is intended for situations where overlapping loop device exists
and cannot be reused.

Signed-off-by: Stanislav Brabec <sbrabec@suse.cz>
8 years agolibmount: Fix possible crash in mnt_context_setup_loopdev()
Stanislav Brabec [Thu, 14 Jul 2016 13:28:29 +0000 (15:28 +0200)] 
libmount: Fix possible crash in mnt_context_setup_loopdev()

If loopcxt_init() fails, Iloopcxt_deinit() should not be called.

Signed-off-by: Stanislav Brabec <sbrabec@suse.cz>
8 years agotests: remove unnecessary file
Sami Kerola [Fri, 22 Jul 2016 20:24:34 +0000 (21:24 +0100)] 
tests: remove unnecessary file

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
8 years agoMerge branch 'getopt' of git://github.com/kerolasa/lelux-utiliteetit
Karel Zak [Tue, 2 Aug 2016 14:08:31 +0000 (16:08 +0200)] 
Merge branch 'getopt' of git://github.com/kerolasa/lelux-utiliteetit

* 'getopt' of git://github.com/kerolasa/lelux-utiliteetit:
  getops: improve getopt-parse.bash example

8 years agoliblkid: fix probe_nilfs2 I/O error backup
Karel Zak [Fri, 15 Jul 2016 08:39:20 +0000 (10:39 +0200)] 
liblkid: fix probe_nilfs2 I/O error backup

Signed-off-by: Karel Zak <kzak@redhat.com>
8 years agoMerge branch 'oclint' of git://github.com/kerolasa/lelux-utiliteetit
Karel Zak [Tue, 2 Aug 2016 13:26:49 +0000 (15:26 +0200)] 
Merge branch 'oclint' of git://github.com/kerolasa/lelux-utiliteetit

* 'oclint' of git://github.com/kerolasa/lelux-utiliteetit:
  libblkid: fix debugging macro [oclint]
  agetty: move unreachable code to pre-processor #else segment [oclint]
  setterm: fix declarations shadowing variables in the global scope [oclint]
  misc: fix declarations shadowing variables in the global scope [oclint]
  dmesg: drop core at impossible case in read_buffer() [oclint]
  libmount, look: remove dead code [oclint]
  syspriv: flip inverted logic [oclint]
  logger: simplify if clause [oclint]
  libblkid: simplify if clause [oclint]
  lslogins: simplify if clause and move definition and comments [oclint]
  switch_root: simplify code and reduce indentation [oclint]
  misc: simplify if clauses [oclint]

8 years agolibsmartcols: Corrected JSON escaping
Karel Zak [Tue, 2 Aug 2016 09:58:50 +0000 (11:58 +0200)] 
libsmartcols: Corrected JSON escaping

Based on patch set https://github.com/karelzak/util-linux/pull/331
from Fordi.

Addresses: https://github.com/karelzak/util-linux/issues/330
Co-Author: Bryan Elliott <fordiman@gmail.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
8 years agogetops: improve getopt-parse.bash example
Sami Kerola [Wed, 27 Jul 2016 10:17:47 +0000 (11:17 +0100)] 
getops: improve getopt-parse.bash example

Use correct names of example scripts in the script.  Remove use of
backticks, they require quoting that makes the example harder to follow.
Split one-liners to one-command-at-a-time expressions.  Add continue keyword
to avoid additional case statement matching.  Be strict with quoting.

Reported-by: Benno Schulenberg <bensberg@justemail.net>
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
8 years agolibblkid: fix debugging macro [oclint]
Sami Kerola [Sun, 3 Jul 2016 19:57:23 +0000 (20:57 +0100)] 
libblkid: fix debugging macro [oclint]

The oclint was complaining 'empty do/while statement' that turned out to be
true and I started to think it is best to use the same DBG() macro as in
other source files for this library.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
8 years agoagetty: move unreachable code to pre-processor #else segment [oclint]
Sami Kerola [Sun, 3 Jul 2016 19:10:11 +0000 (20:10 +0100)] 
agetty: move unreachable code to pre-processor #else segment [oclint]

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
8 years agosetterm: fix declarations shadowing variables in the global scope [oclint]
Sami Kerola [Sun, 3 Jul 2016 12:13:21 +0000 (13:13 +0100)] 
setterm: fix declarations shadowing variables in the global scope [oclint]

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
8 years agomisc: fix declarations shadowing variables in the global scope [oclint]
Sami Kerola [Sun, 3 Jul 2016 12:20:30 +0000 (13:20 +0100)] 
misc: fix declarations shadowing variables in the global scope [oclint]

Fixes multiple occurences of 'optarg' overwrites.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
8 years agodmesg: drop core at impossible case in read_buffer() [oclint]
Sami Kerola [Sun, 3 Jul 2016 11:18:03 +0000 (12:18 +0100)] 
dmesg: drop core at impossible case in read_buffer() [oclint]

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
8 years agolibmount, look: remove dead code [oclint]
Sami Kerola [Sun, 3 Jul 2016 19:13:42 +0000 (20:13 +0100)] 
libmount, look: remove dead code [oclint]

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
8 years agosyspriv: flip inverted logic [oclint]
Sami Kerola [Sun, 3 Jul 2016 11:42:58 +0000 (12:42 +0100)] 
syspriv: flip inverted logic [oclint]

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
8 years agologger: simplify if clause [oclint]
Sami Kerola [Mon, 4 Jul 2016 21:14:41 +0000 (22:14 +0100)] 
logger: simplify if clause [oclint]

This has effect of collapsing rather long indentation block, so commit
separately.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
8 years agolibblkid: simplify if clause [oclint]
Sami Kerola [Mon, 4 Jul 2016 21:12:55 +0000 (22:12 +0100)] 
libblkid: simplify if clause [oclint]

Move negative and positive testing of 'has' variable to top level, and test
flag bit mask on second level.  This way the 'has' needs to be checked only
once.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
8 years agolslogins: simplify if clause and move definition and comments [oclint]
Sami Kerola [Mon, 4 Jul 2016 21:16:54 +0000 (22:16 +0100)] 
lslogins: simplify if clause and move definition and comments [oclint]

The if clause change is pretty trivial.  Moving the macro near to where it
is used makes sense to people who want to read the code.  And finally the
comment about user list was at wrong spot.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
8 years agoswitch_root: simplify code and reduce indentation [oclint]
Sami Kerola [Sun, 3 Jul 2016 11:30:46 +0000 (12:30 +0100)] 
switch_root: simplify code and reduce indentation [oclint]

The if statement in line 162 already ensures value of cfd to be 0 or
greater, so the later if is not needed.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
8 years agomisc: simplify if clauses [oclint]
Sami Kerola [Mon, 4 Jul 2016 21:09:10 +0000 (22:09 +0100)] 
misc: simplify if clauses [oclint]

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
8 years agoagetty: call uname() only when necessary
Karel Zak [Wed, 20 Jul 2016 11:20:14 +0000 (13:20 +0200)] 
agetty: call uname() only when necessary

Signed-off-by: Karel Zak <kzak@redhat.com>
8 years agoagetty: fix \S usage
Karel Zak [Wed, 20 Jul 2016 11:16:13 +0000 (13:16 +0200)] 
agetty: fix \S usage

If \S without argument used then uninitialized 'varname' compared with
ANSI_COLOR.

Addresses: https://github.com/karelzak/util-linux/issues/329
Signed-off-by: Karel Zak <kzak@redhat.com>
8 years agoRevert "sfdisk: exit with error if rereading partition table fails"
Karel Zak [Wed, 20 Jul 2016 09:24:36 +0000 (11:24 +0200)] 
Revert "sfdisk: exit with error if rereading partition table fails"

This reverts commit 14f644f386a1708483ed446e983c0976e3976a9d.

It seems we have mess in reread-after-write:

all old versions to v2.20  -- returns 0
from v2.20 to v2.26        -- returns 1
since v2.26                -- returns 0

I think re-read errors should not be interpreted as fatal errors,
because it's pretty common that you want to modify only one partition
(e.g. resize) and then another partitions are probably still in use
and re-read all PT does not make sense.

What we need is to improve granularity for re-read and calls it only
when really necessary (all PT modified) and otherwise call BLKPG
(add/delete/resize) ioctls.

Reported-by: Nikhil Valluru <vvnikhil@gmail.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
8 years agologger: remove trailing spaces when outputing to journal
Sami Kerola [Mon, 18 Jul 2016 20:49:27 +0000 (21:49 +0100)] 
logger: remove trailing spaces when outputing to journal

Issues:
1. Whitespace-ish \r is not stripped, while it should be.
2. In journal \r is considered unprintable.

Lennart: "it is the duty of the client side to drop the trailing whitespace,
which "logger" doesn't do".

Reported-by: Ivan Babrou <ibobrik@gmail.com>
Explained-by: Lennart Poettering <lennart@poettering.net>
Reference: https://github.com/systemd/systemd/issues/3416
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
8 years agotailf: Fix previously adjusted segfault patch
Tobias Stoeckmann [Sat, 16 Jul 2016 10:51:42 +0000 (12:51 +0200)] 
tailf: Fix previously adjusted segfault patch

Casting the value to be checked to size_t renders the check useless.
If st_size is SIZE_MAX+1, it will be truncated to 0 and the check
succeeds. In fact, this check can never be false because every value
stored in a size_t is smaller or equal to SIZE_MAX.

I think this adjustment was meant to fix a compiler warning for 64 bit
systems for which sizeof(off_t) is sizeof(size_t), but the signedness
differs.

Going unconditionally to the greatest possible unsigned int type if
st_size is positive (off_t is signed) will fix this issue.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
8 years agotests: fix ttyutils test
Karel Zak [Fri, 15 Jul 2016 08:11:35 +0000 (10:11 +0200)] 
tests: fix ttyutils test

Signed-off-by: Karel Zak <kzak@redhat.com>
9 years agowrite: don't use strftime()
Karel Zak [Thu, 14 Jul 2016 11:20:58 +0000 (13:20 +0200)] 
write: don't use strftime()

Signed-off-by: Karel Zak <kzak@redhat.com>
9 years agoMerge branch 'write-improvements' of git://github.com/kerolasa/lelux-utiliteetit
Karel Zak [Thu, 14 Jul 2016 11:07:25 +0000 (13:07 +0200)] 
Merge branch 'write-improvements' of git://github.com/kerolasa/lelux-utiliteetit

* 'write-improvements' of git://github.com/kerolasa/lelux-utiliteetit:
  lib: try to find tty in get_terminal_name()
  write: stop removing and adding /dev/ in front of tty string
  write: tell when effective gid and tty path group mismatch
  write: improve coding style
  write: remove PUTC macro
  write: make timestamp to be obviously just a clock time
  write: remove unnecessary utmp variables
  write: improve function and variable names
  write: add control structure to clarify what is going on
  write: run atexit() checks at the end of execution
  write: use xstrncpy() from strutils.h
  write: set atime value in term_chk() only when needed
  write: remove pointless fileno(3) calls
  write: get rid of function prototypes
  write: remove unused variable

9 years agosulogin: remove __nonnull__ function attribute
Sami Kerola [Sat, 2 Jul 2016 09:28:55 +0000 (10:28 +0100)] 
sulogin: remove __nonnull__ function attribute

This change fixes compiler option -Werror=nonnull option warning:

login-utils/sulogin-consoles.c: In function 'append_console':
login-utils/sulogin-consoles.c:324:14: warning: nonnull argument 'consoles'
compared to NULL [-Wnonnull-compare]

The NULL check done with list_empty() looks valid, so  it is best to remove
the function attribute that allows compiler to optimize the check away.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
9 years agotests: Fix fdisk/id and fdisk/mbr-nondos-mode on Sparc
James Clarke [Thu, 14 Jul 2016 08:02:24 +0000 (09:02 +0100)] 
tests: Fix fdisk/id and fdisk/mbr-nondos-mode on Sparc

On Sparc, fdisk defaults to using SUN disk labels, which causes the
output from these tests to differ from non-Sparc.

Signed-off-by: James Clarke <jrtc27@jrtc27.com>
9 years agoblkdiscard: Improve man page
Allon Mureinik [Thu, 14 Jul 2016 10:19:25 +0000 (12:19 +0200)] 
blkdiscard: Improve man page

Improve the grammar and phrasing of the --verbose option and how it
interacts with the --step option.

Signed-off-by: Allon Mureinik <amureini@redhat.com>
9 years agotailf: Fix segmentation fault in tailf on 32 bit
Tobias Stoeckmann [Sun, 10 Jul 2016 14:14:08 +0000 (16:14 +0200)] 
tailf: Fix segmentation fault in tailf on 32 bit

tailf crashes with a segmentation fault when used with a file that is
exactly 4GB in size due to an integer overflow between off_t and size_t:

$ dd if=/dev/zero of=tailf.crash bs=1 count=1 seek=4294967295
$ tailf tailf.crash
Segmentation fault
$ _

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
Signed-off-by: Karel Zak <kzak@redhat.com>
9 years agofdisk: make -l <dev ...> behaves like fdisk -l
Thierry Vignaud [Tue, 5 Jul 2016 16:39:05 +0000 (18:39 +0200)] 
fdisk: make -l <dev ...> behaves like fdisk -l

aka having the same spacing between disks

Signed-off-by: Karel Zak <kzak@redhat.com>
9 years agolibblkid: avoid non-empty recursion in EBR
Karel Zak [Tue, 12 Jul 2016 11:34:54 +0000 (13:34 +0200)] 
libblkid: avoid non-empty recursion in EBR

This is extension to the patch 7164a1c34d18831ac61c6744ad14ce916d389b3f.

We also need to detect non-empty recursion in the EBR chain. It's
possible to create standard valid logical partitions and in the last one
points back to the EBR chain. In this case all offsets will be non-empty.

Unfortunately, it's valid to create logical partitions that are not in
the "disk order" (sorted by start offset). So link somewhere back is
valid, but this link cannot points to already existing partition
(otherwise we will see recursion).

This patch forces libblkid to ignore duplicate logical partitions, the
duplicate chain segment is interpreted as non-data segment, after 100
iterations with non-data segments it will break the loop -- no memory
is allocated in this case by the loop.

Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=1349536
References: http://seclists.org/oss-sec/2016/q3/40
Signed-off-by: Karel Zak <kzak@redhat.com>
9 years agochrt: add fallback to be usable on kernels without sched_{get,set}attr
Karel Zak [Mon, 11 Jul 2016 13:33:46 +0000 (15:33 +0200)] 
chrt: add fallback to be usable on kernels without sched_{get,set}attr

We have fallback for compilation with/without proper glibc and kernel
headers, but it's not enough, because people can switch between
kernels with and without the syscalls. (For example RT kernels for
RHEL/CentOS).

Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=1353340
Signed-off-by: Karel Zak <kzak@redhat.com>
9 years agotests: mark chrt as TS_KNOWN_FAIL
Karel Zak [Mon, 11 Jul 2016 10:36:51 +0000 (12:36 +0200)] 
tests: mark chrt as TS_KNOWN_FAIL

Signed-off-by: Karel Zak <kzak@redhat.com>
9 years agotests: make chrt test more debug-able
Karel Zak [Mon, 11 Jul 2016 09:54:31 +0000 (11:54 +0200)] 
tests: make chrt test more debug-able

Signed-off-by: Karel Zak <kzak@redhat.com>
9 years agotests: mark chrt tests as root-only
Karel Zak [Mon, 11 Jul 2016 09:12:47 +0000 (11:12 +0200)] 
tests: mark chrt tests as root-only

Signed-off-by: Karel Zak <kzak@redhat.com>
9 years agotests: implement ts_skip_subtest
Karel Zak [Mon, 11 Jul 2016 09:01:14 +0000 (11:01 +0200)] 
tests: implement ts_skip_subtest

Signed-off-by: Karel Zak <kzak@redhat.com>
9 years agotests: add chrt test
Karel Zak [Mon, 11 Jul 2016 08:25:13 +0000 (10:25 +0200)] 
tests: add chrt test

Signed-off-by: Karel Zak <kzak@redhat.com>
9 years agocfisk: add /dev/vda as another default disk
Karel Zak [Thu, 7 Jul 2016 13:02:20 +0000 (15:02 +0200)] 
cfisk: add /dev/vda as another default disk

And use array for all default alternative disks.

Reported-by: Thierry Vignaud <thierry.vignaud@gmail.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
9 years agolibblkid: ignore extended partition at zero offset
Karel Zak [Thu, 7 Jul 2016 12:22:41 +0000 (14:22 +0200)] 
libblkid: ignore extended partition at zero offset

If the extended partition starts at zero LBA then MBR is interpreted
as EBR and all is recursively parsed... result is out-of-memory.

 MBR --extended-partition--> EBR --> MBR --> ENB --> MBR ...

Note that such PT is not possible to create by standard partitioning
tools.

Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=1349536
Signed-off-by: Karel Zak <kzak@redhat.com>
9 years agolib: try to find tty in get_terminal_name()
Sami Kerola [Sat, 14 May 2016 18:50:41 +0000 (19:50 +0100)] 
lib: try to find tty in get_terminal_name()

Try all standard terminal input/output file descriptors when finding tty
name in get_germinal_name().  This should make all invocations of the
function as robust as they can get.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
9 years agowrite: stop removing and adding /dev/ in front of tty string
Sami Kerola [Sat, 14 May 2016 18:39:37 +0000 (19:39 +0100)] 
write: stop removing and adding /dev/ in front of tty string

Add both path and tty name representations of tty's to control structure,
that point to same string beginning from different depths.  This way there
is no need to removing and adding /dev/ in front of tty string all the time.

Secondly this change makes it possible to use of get_terminal_name() from
ttyutils.c.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
9 years agowrite: tell when effective gid and tty path group mismatch
Sami Kerola [Sat, 7 May 2016 22:44:17 +0000 (23:44 +0100)] 
write: tell when effective gid and tty path group mismatch

Most commonly this error happens when write(1) executable does not have
correct group ownership and setgid bit.  The earlier message was unclear
what exactly was wrong.

$ mesg
is y
$ write testuser
write: you have write permission turned off

Alternatively the 'getegid() == s.st_gid' could be considered unnecessary.
Afterall if to write to destination tty is denied that does not go unnoticed
at thet time when tty is opened.

Reviewed-by: Benno Schulenberg <bensberg@justemail.net>
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
9 years agowrite: improve coding style
Sami Kerola [Sun, 8 May 2016 20:00:21 +0000 (21:00 +0100)] 
write: improve coding style

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
9 years agowrite: remove PUTC macro
Sami Kerola [Sat, 14 May 2016 15:40:45 +0000 (16:40 +0100)] 
write: remove PUTC macro

Function like macros make following the execution flow unnecessarily
difficult, and deserves to be removed.

Requested-by: Karel Zak <kzak@redhat.com>
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
9 years agowrite: make timestamp to be obviously just a clock time
Sami Kerola [Sat, 7 May 2016 20:07:44 +0000 (21:07 +0100)] 
write: make timestamp to be obviously just a clock time

By looking the code one will had hard time knowing that a slice of ctime()
from characters 11 to 16 is HH:MM time format.  Use of strftime("%H:%M")
makes this a lot less mysterious.

In same go make \007 hex printouts to be \a that is the same thing: alarm.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
9 years agowrite: remove unnecessary utmp variables
Sami Kerola [Sat, 7 May 2016 11:50:01 +0000 (12:50 +0100)] 
write: remove unnecessary utmp variables

glibc documentation tells getutent() calls are not thread safe, and
recommends to copy the context of the structures when information is wished
to be stored.  This leads to excessive copying, that in this case is not
relevant.  write(1) is single threaded program and there is no reason to
assume this would change in future.

Reference: http://www.gnu.org/software/libc/manual/html_node/Manipulating-the-Database.html
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
9 years agowrite: improve function and variable names
Sami Kerola [Sat, 7 May 2016 11:36:44 +0000 (12:36 +0100)] 
write: improve function and variable names

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
9 years agowrite: add control structure to clarify what is going on
Sami Kerola [Sat, 7 May 2016 11:02:12 +0000 (12:02 +0100)] 
write: add control structure to clarify what is going on

This is done purely an improve readability of the source code.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
9 years agowrite: run atexit() checks at the end of execution
Sami Kerola [Sat, 7 May 2016 07:33:57 +0000 (08:33 +0100)] 
write: run atexit() checks at the end of execution

Earlier use of _exit() caused program to terminate abnormally from atexit()
perspective and standard file descriptor close checks did not run resulting
to blindness if writes were successful, or not.  Easy fix is to avoid
running _exit() altogether.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
9 years agowrite: use xstrncpy() from strutils.h
Sami Kerola [Fri, 6 May 2016 23:20:32 +0000 (00:20 +0100)] 
write: use xstrncpy() from strutils.h

Earlier if the tty path was exactly length of the maximum ut_line then last
character of the path was overwrote by \0.  This is in practise theoretical
bug, as it is unheard that a tty device path could be 32 characters long.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
9 years agowrite: set atime value in term_chk() only when needed
Sami Kerola [Fri, 6 May 2016 22:38:11 +0000 (23:38 +0100)] 
write: set atime value in term_chk() only when needed

The search_utmp() is needs atime but main() does not, so remove the later.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
9 years agowrite: remove pointless fileno(3) calls
Sami Kerola [Fri, 6 May 2016 22:27:17 +0000 (23:27 +0100)] 
write: remove pointless fileno(3) calls

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
9 years agowrite: get rid of function prototypes
Sami Kerola [Fri, 6 May 2016 21:47:41 +0000 (22:47 +0100)] 
write: get rid of function prototypes

Marking functions static and writing them in order where functions are
introduced before use is enough.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
9 years agowrite: remove unused variable
Sami Kerola [Fri, 6 May 2016 21:43:26 +0000 (22:43 +0100)] 
write: remove unused variable

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
9 years agolsns: check for OOM
Karel Zak [Fri, 1 Jul 2016 13:42:50 +0000 (15:42 +0200)] 
lsns: check for OOM

Signed-off-by: Karel Zak <kzak@redhat.com>
9 years agolslocks: add --noinaccessible
Karel Zak [Fri, 1 Jul 2016 12:45:04 +0000 (14:45 +0200)] 
lslocks: add --noinaccessible

* add --noinaccessible to not print incomplete information

* make incomplete paths more visible (append "...")

* don't print 0B size if lock file inaccessible

Signed-off-by: Karel Zak <kzak@redhat.com>
9 years agoMerge branch 'utmpdump' of git://github.com/kerolasa/lelux-utiliteetit
Karel Zak [Fri, 1 Jul 2016 11:51:59 +0000 (13:51 +0200)] 
Merge branch 'utmpdump' of git://github.com/kerolasa/lelux-utiliteetit

* 'utmpdump' of git://github.com/kerolasa/lelux-utiliteetit:
  docs: add file format note to utmpdump manual page
  tests: utmpdump add subsecond accuracy test
  tests: challenge utmpdump localization go-around
  tests: fix utmpdump timestamps to be in iso format
  utmpdump: use iso-8601 timestamp format with subsecond accuracy
  libcommon: add ISO_8601_GMTIME that will print UTC-0 timestamps
  utmpdump: use always UTC-0 timezone in textual output

9 years agolibblkid: Add metadata signature check for IMSM on 4Kn drives
Alexey Obitotskiy [Fri, 24 Jun 2016 09:59:35 +0000 (11:59 +0200)] 
libblkid: Add metadata signature check for IMSM on 4Kn drives

Drives with 512 and 4K sectors have different offset for
metadata signature. Without signature detected on 4Kn drives
those drives will not be recognized as raid member. This
patch adds checking for IMSM signature for 4Kn drives.

Signed-off-by: Alexey Obitotskiy <aleksey.obitotskiy@intel.com>
9 years agoagetty: don't modify argv[] when parse speeds
Karel Zak [Thu, 30 Jun 2016 12:00:44 +0000 (14:00 +0200)] 
agetty: don't modify argv[] when parse speeds

Signed-off-by: Karel Zak <kzak@redhat.com>
9 years agodocs: add file format note to utmpdump manual page
Sami Kerola [Mon, 27 Jun 2016 19:38:27 +0000 (20:38 +0100)] 
docs: add file format note to utmpdump manual page

Tell that the old textual format that does not use full utmp time precision,
and has issues with timezones.  Warn also that the textual format may become
incompatible, although there are no plans in foreseeable future to do so.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
9 years agotests: utmpdump add subsecond accuracy test
Sami Kerola [Sun, 15 May 2016 09:55:54 +0000 (10:55 +0100)] 
tests: utmpdump add subsecond accuracy test

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
9 years agotests: challenge utmpdump localization go-around
Sami Kerola [Sun, 15 May 2016 09:42:25 +0000 (10:42 +0100)] 
tests: challenge utmpdump localization go-around

The utmpdump timestamps are unambiguous, they always use UTC-0 regardless of
localization.  If thesse tests starts to fail after this change then the
timezone forcing is not working.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
9 years agotests: fix utmpdump timestamps to be in iso format
Sami Kerola [Sun, 15 May 2016 09:32:20 +0000 (10:32 +0100)] 
tests: fix utmpdump timestamps to be in iso format

The utmpdump-circle is slightly modified to use old timestamp format as
basis of conversion and to do cyclic conversion via new format.  This is
better from test coverage point of view.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
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>