]> git.ipfire.org Git - thirdparty/util-linux.git/log
thirdparty/util-linux.git
10 years agohwclock: update man page for v2.26 rc
JWP [Thu, 8 Jan 2015 04:18:52 +0000 (23:18 -0500)] 
hwclock: update man page for v2.26 rc

Authored new section: DATE-TIME CONFIGURATION.
Subsections: Keeping Time..., LOCAL vs UTC, POSIX vs 'RIGHT'.
Errata and drop outdated language.
Updates for v2.26

Signed-off-by: J William Piggott <elseifthen@gmx.com>
10 years agohwclock: Incorrect UTC defaults
JWP [Thu, 8 Jan 2015 04:15:39 +0000 (23:15 -0500)] 
hwclock: Incorrect UTC defaults

Hwclock's default timescale was changed to UTC in:

commit 7894bf0f08740f75610990a2ba76af7a7cbce61e
Date:   Mon Feb 21 13:27:07 2011 +0000

This change was incomplete.

With no /etc/adjtime file the current behavior is:
hwclock --utc --adjust        #Creates a UTC file.
hwclock --localtime --adjust  #File is not created.

That is the opposite of what UTC default should do.

With this patch the behavior is:
hwclock --utc --adjust        #File is not created.
hwclock --localtime --adjust  #Creates a LOCAL file.

'Creates a xxxx file' means: An /etc/adjtime file
is created with zero for all parameters except the
Hardware Clock's timescale field, which is set to
the value indicated by xxxx.

The second item missed in the patch was a test in
the save_adjtime() function that defaults to LOCAL.

Theoretically we cannot get to the save function
without having a value set for adjtime.local_utc,
but the test is there so it needs be correct.

Signed-off-by: J William Piggott <elseifthen@gmx.com>
10 years agohwclock: enable --directisa for x86_64
JWP [Thu, 8 Jan 2015 04:13:21 +0000 (23:13 -0500)] 
hwclock: enable --directisa for x86_64

Currently only x86 and Alpha can use --directisa.
This patch allows x86_64 machines to use it as well.

Signed-off-by: J William Piggott <elseifthen@gmx.com>
10 years agonsenter: add --preserve-credentials and cleanup setgroups() usage
Karel Zak [Thu, 8 Jan 2015 11:52:43 +0000 (12:52 +0100)] 
nsenter: add --preserve-credentials and cleanup setgroups() usage

The new option --preserve-credentials completely disables all
operations related to UIGs and GIDs.

The patch also calls setgroups() before we enter user namespace (so
root can always clear their groups) and after we enter user namespace
(to detect /proc/self/setgroups "deny"). If both fail then nsenter
complains.

Acked-by: "Eric W. Biederman" <ebiederm@xmission.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
10 years agonsenter: keep semantic consistent
Karel Zak [Thu, 8 Jan 2015 11:27:59 +0000 (12:27 +0100)] 
nsenter: keep semantic consistent

The current nseneter behavior is inconsistent and depends on way how
namespace is specified on command line

    # nsenter --user
vs.
    # nseneter --user=filename

if the namespace is specified by <filename> than nsenter does not do
additinal setting and actions (e.g. does not call setgroups, setuid).
This is bug.

Signed-off-by: Karel Zak <kzak@redhat.com>
10 years agounshare: add --setgroups=deny|allow
Karel Zak [Thu, 8 Jan 2015 10:51:58 +0000 (11:51 +0100)] 
unshare: add --setgroups=deny|allow

Since Linux 3.19 the file /proc/self/setgroups controls setgroups(2)
syscall usage in user namespaces. This patch provides command line knob
for this feature.

The new --setgroups does not automatically implies --user to avoid
complexity, it's user's responsibility to use it in right context. The
exception is --map-root-user which is mutually exclusive to
--setgroups=allow.

CC: "Eric W. Biederman" <ebiederm@xmission.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
10 years agounshare: Fix --map-root-user to work on new kernels
Eric W. Biederman [Wed, 17 Dec 2014 23:06:03 +0000 (17:06 -0600)] 
unshare: Fix --map-root-user to work on new kernels

In rare cases droping groups with setgroups(0, NULL) is an operation
that can grant a user additional privileges.  User namespaces were
allwoing that operation to unprivileged users and that had to be
fixed.

Update unshare --map-root-user to disable the setgroups operation
before setting the gid_map.

This is needed as after the security fix gid_map is restricted to
privileged users unless setgroups has been disabled.

Signed-off-by: "Eric W. Biederman" <ebiederm@xmission.com>
10 years agoMerge branch '2015wk01' of https://github.com/kerolasa/lelux-utiliteetit
Karel Zak [Thu, 8 Jan 2015 13:53:01 +0000 (14:53 +0100)] 
Merge branch '2015wk01' of https://github.com/kerolasa/lelux-utiliteetit

* '2015wk01' of https://github.com/kerolasa/lelux-utiliteetit:
  eject: add verbosity to cdrom door lock error
  libblkid: assume strtoull() is available
  ipcs: remove FIXME markup
  ul: remove unexplained TERM=lpr override
  look: remove dead code
  docs: make tools/checkmans.sh to pass without warnings
  build-sys: fix make checkincludes warnings
  docs: add howto-pull-request.txt
  docs: small improvements to howto-contribute.txt

Conflicts:
Documentation/howto-pull-request.txt

10 years agoMerge branch 'master' of https://github.com/pali/util-linux
Karel Zak [Thu, 8 Jan 2015 13:36:20 +0000 (14:36 +0100)] 
Merge branch 'master' of https://github.com/pali/util-linux

* 'master' of https://github.com/pali/util-linux:
  tests: update UDF test (add identifiers)
  libblkid: udf: Fix reading LABEL, add support for UUID and other udf identifiers
  libblkid: superblocks: Add function blkid_probe_set_utf8_id_label for setting utf8 id label

10 years agodocs: add howto-pull-request.txt
Sami Kerola [Wed, 7 Jan 2015 19:25:39 +0000 (19:25 +0000)] 
docs: add howto-pull-request.txt

Reference: http://comments.gmane.org/gmane.linux.utilities.util-linux-ng/10431
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
10 years agodocs: small improvements to howto-contribute.txt
Sami Kerola [Wed, 7 Jan 2015 19:25:38 +0000 (19:25 +0000)] 
docs: small improvements to howto-contribute.txt

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
10 years agoeject: add verbosity to cdrom door lock error
Sami Kerola [Wed, 7 Jan 2015 22:33:09 +0000 (22:33 +0000)] 
eject: add verbosity to cdrom door lock error

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
10 years agolibblkid: assume strtoull() is available
Sami Kerola [Wed, 7 Jan 2015 22:05:43 +0000 (22:05 +0000)] 
libblkid: assume strtoull() is available

The strtoull() is part of ISO/IEC 9899:1999 (aka C99) and the function
has been happily used in prlimit(1) since 2011-10-19 without anyone
complaining compatibility issues.

Reference: http://pubs.opengroup.org/onlinepubs/009695399/functions/strtoul.html
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
10 years agoipcs: remove FIXME markup
Sami Kerola [Wed, 7 Jan 2015 21:44:44 +0000 (21:44 +0000)] 
ipcs: remove FIXME markup

The ipc message q_qbytes information is not in /proc, and it is unlikely
it will ever appear to there.

Reference: https://lkml.org/lkml/2012/11/25/18
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
10 years agoul: remove unexplained TERM=lpr override
Sami Kerola [Wed, 7 Jan 2015 21:30:54 +0000 (21:30 +0000)] 
ul: remove unexplained TERM=lpr override

The FIXME item has been in place since 2011-04-30, and the code has never
made sense, so remove it.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
10 years agolook: remove dead code
Sami Kerola [Wed, 7 Jan 2015 21:24:39 +0000 (21:24 +0000)] 
look: remove dead code

MAP_FILE is ignored compatibility flag.

Reference: http://man7.org/linux/man-pages/man2/mmap.2.html
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
10 years agodocs: make tools/checkmans.sh to pass without warnings
Sami Kerola [Wed, 7 Jan 2015 19:57:54 +0000 (19:57 +0000)] 
docs: make tools/checkmans.sh to pass without warnings

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
10 years agobuild-sys: fix make checkincludes warnings
Sami Kerola [Wed, 7 Jan 2015 19:44:26 +0000 (19:44 +0000)] 
build-sys: fix make checkincludes warnings

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
10 years agodocs: add howto-pull-request.txt
Sami Kerola [Tue, 6 Jan 2015 22:37:52 +0000 (22:37 +0000)] 
docs: add howto-pull-request.txt

Reference: http://comments.gmane.org/gmane.linux.utilities.util-linux-ng/10431
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
10 years agodocs: small improvements to howto-contribute.txt
Sami Kerola [Tue, 6 Jan 2015 20:25:16 +0000 (20:25 +0000)] 
docs: small improvements to howto-contribute.txt

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
10 years agolibsmartcols: use ASCII art for trees rather than padding
Karel Zak [Wed, 7 Jan 2015 14:20:22 +0000 (15:20 +0100)] 
libsmartcols: use ASCII art for trees rather than padding

Based on patch from  Roman Odaisky.

References: https://launchpad.net/bugs/1406133
Signed-off-by: Karel Zak <kzak@redhat.com>
10 years agobuild-sys: support nsenter.static
Karel Zak [Wed, 7 Jan 2015 09:59:16 +0000 (10:59 +0100)] 
build-sys: support nsenter.static

Signed-off-by: Karel Zak <kzak@redhat.com>
10 years agofsck.minix: fix segmentation fault
Sami Kerola [Sat, 3 Jan 2015 09:20:05 +0000 (09:20 +0000)] 
fsck.minix: fix segmentation fault

Return from check_file() and check_file2() functions when maximum name
depth is reached.  The use unsafe strncpy() is also removed just to be on
safe side.

Addresses: https://bugs.debian.org/773892
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
10 years agolslocks: fix type warning
Sami Kerola [Sat, 3 Jan 2015 09:20:04 +0000 (09:20 +0000)] 
lslocks: fix type warning

misc-utils/lslocks.c:229:2: warning: format '%x' expects argument of type
'unsigned int *', but argument 3 has type 'int *' [-Wformat=]

Reference: http://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/tree/fs/locks.c?id=5e0f872c7d7e371fbdf09e864eddd24bddfda8fe#n2533
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
10 years agomaint: fix shadow declaration
Sami Kerola [Wed, 31 Dec 2014 23:01:21 +0000 (23:01 +0000)] 
maint: fix shadow declaration

This change fixes all shadow declarations.  The worth while to mention
fix is with libfdisk sun geometry.  It comes from bitops.h cpu_to_be16
macro that further expands from include/bits/byteswap.h that has the
shadowing.

libfdisk/src/sun.c:961:173: warning: declaration of '__v' shadows a previous local [-Wshadow]
libfdisk/src/sun.c:961:69: warning: shadowed declaration is here [-Wshadow]
libfdisk/src/sun.c:961:178: warning: declaration of '__x' shadows a previous local [-Wshadow]
libfdisk/src/sun.c:961:74: warning: shadowed declaration is here [-Wshadow]

That could have caused earlier some unexpected results.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
10 years agofallocate: create mode 0666, that's what umask is for
Karel Zak [Wed, 7 Jan 2015 08:57:55 +0000 (09:57 +0100)] 
fallocate: create mode 0666, that's what umask is for

User's umask will typically mask the mode down to 0664 or 0644.

Reported-by: Peter Cordes <peter@cordes.ca>
Signed-off-by: Karel Zak <kzak@redhat.com>
10 years agolibmount: (monitor) make mnt_monitor_next_changed() usable for epoll version too
Karel Zak [Tue, 6 Jan 2015 15:18:52 +0000 (16:18 +0100)] 
libmount: (monitor) make mnt_monitor_next_changed() usable for epoll version too

Signed-off-by: Karel Zak <kzak@redhat.com>
10 years agolinmount: (monitor) refresh docs, headers and symbols table
Karel Zak [Wed, 17 Dec 2014 12:09:29 +0000 (13:09 +0100)] 
linmount: (monitor) refresh docs, headers and symbols table

Signed-off-by: Karel Zak <kzak@redhat.com>
10 years agolibmount: (monitor) use inotify for utab lock file
Karel Zak [Wed, 17 Dec 2014 11:50:29 +0000 (12:50 +0100)] 
libmount: (monitor) use inotify for utab lock file

It's better than monitor utab directly. The utab is updated by
rename(2) and it's really tricky for inotify, because it's necessary
to monitor all /run/mount directory and then it's necessary to verify
that the renamed file is really "utab".

The new concept is without possible false positives and it also
triggers the change when utab update is really done.

Signed-off-by: Karel Zak <kzak@redhat.com>
10 years agolibmount: (monitor) add kernel mountninfo monitoring
Karel Zak [Wed, 17 Dec 2014 09:39:37 +0000 (10:39 +0100)] 
libmount: (monitor) add kernel mountninfo monitoring

Signed-off-by: Karel Zak <kzak@redhat.com>
10 years agolibmount: (monitor) cleanup wait/verify stuff
Karel Zak [Tue, 16 Dec 2014 14:28:41 +0000 (15:28 +0100)] 
libmount: (monitor) cleanup wait/verify stuff

Signed-off-by: Karel Zak <kzak@redhat.com>
10 years agolibmount: make public top-level monitor FD only
Karel Zak [Tue, 16 Dec 2014 10:25:52 +0000 (11:25 +0100)] 
libmount: make public top-level monitor FD only

We need full control on changes evaluation, so it's better to
hide all in our private epoll. This change also significantly
simplify the API.

 mn = mnt_new_monitor();
 mnt_monitor_enable_userapce(mn, TRUE, NULL);
 mnt_monitor_enable_kenrel(mn, TRUE);

 fd = mnt_monitor_get_fd(mn);
 ...
   <use 'fd' in epoll controlled by your application>
 ...
 while (mnt_monitor_next_changed(mn, &filename, NULL) == 0)
  printf("%s: change detected\n", filename);

Signed-off-by: Karel Zak <kzak@redhat.com>
10 years agolibmount: monitor unref function refactoring
Karel Zak [Tue, 16 Dec 2014 08:16:09 +0000 (09:16 +0100)] 
libmount: monitor unref function refactoring

Signed-off-by: Karel Zak <kzak@redhat.com>
10 years agolibmount: cleanup monitor test
Karel Zak [Mon, 15 Dec 2014 13:23:54 +0000 (14:23 +0100)] 
libmount: cleanup monitor test

Signed-off-by: Karel Zak <kzak@redhat.com>
10 years agolibmount: split monitor initialization
Karel Zak [Mon, 15 Dec 2014 13:13:25 +0000 (14:13 +0100)] 
libmount: split monitor initialization

The patch introduces mnt_monitor_enable_*() functions (now for
userspace only) to make the API easy to use for high-level purpose.

Signed-off-by: Karel Zak <kzak@redhat.com>
10 years agoipcrm: fix usage
Karel Zak [Tue, 6 Jan 2015 10:55:21 +0000 (11:55 +0100)] 
ipcrm: fix usage

Signed-off-by: Karel Zak <kzak@redhat.com>
10 years agoipc*: use customary fputs() instead of fprintf() with the usage macros
Benno Schulenberg [Wed, 24 Dec 2014 16:56:10 +0000 (17:56 +0100)] 
ipc*: use customary fputs() instead of fprintf() with the usage macros

Also use the clearer word <number> with the --semaphore option.

Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
10 years agotailf: slice up the usage text for ease of translation
Benno Schulenberg [Wed, 24 Dec 2014 16:56:09 +0000 (17:56 +0100)] 
tailf: slice up the usage text for ease of translation

Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
10 years agolook: slice up the usage text for ease of translation
Benno Schulenberg [Wed, 24 Dec 2014 16:56:08 +0000 (17:56 +0100)] 
look: slice up the usage text for ease of translation

Also use the standard macros, and correct the synopsis: use angular
brackets and show that look accepts multiple files.

Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
10 years agocolcrt: slice up the usage text for ease of translation
Benno Schulenberg [Wed, 24 Dec 2014 16:56:07 +0000 (17:56 +0100)] 
colcrt: slice up the usage text for ease of translation

Also use the standard macros for outputting it.

Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
10 years agotextual: list the options of setarch in a more alphabetical order
Benno Schulenberg [Wed, 24 Dec 2014 16:56:06 +0000 (17:56 +0100)] 
textual: list the options of setarch in a more alphabetical order

Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
10 years agosetarch: make the usage synopsis comprehensible for translators
Benno Schulenberg [Wed, 24 Dec 2014 16:56:05 +0000 (17:56 +0100)] 
setarch: make the usage synopsis comprehensible for translators

Use two separate strings for the two different forms of setarch,
instead of filling in an untranslated word into a single string.
Also use the standard angular brackets for nonliteral arguments.

Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
10 years agodocs: restore the alternative form of setarch in its man page
Benno Schulenberg [Wed, 24 Dec 2014 16:56:04 +0000 (17:56 +0100)] 
docs: restore the alternative form of setarch in its man page

Commit c372860ddb4a768f7f6c50cd26d60119370d5cd accidentally removed
the alternative form of setarch in which the command name specifies
the architecture to be set.  Also improve some formatting.

Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
10 years agoipcrm: gettextize the command synopsis of the usage text
Benno Schulenberg [Wed, 24 Dec 2014 16:56:03 +0000 (17:56 +0100)] 
ipcrm: gettextize the command synopsis of the usage text

Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
10 years agoipcs: in usage show resource option as nonoptional when used with -i
Benno Schulenberg [Wed, 24 Dec 2014 16:56:02 +0000 (17:56 +0100)] 
ipcs: in usage show resource option as nonoptional when used with -i

Also, the resource option -a is not valid with -i, so show the valid
ones explicitly.  Also gettextize the synopsis as a single string, as
the two lines are tightly related and other synopses do this too.

Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
10 years agodocs: improve some wordings on the man page of wipefs
Benno Schulenberg [Wed, 24 Dec 2014 16:56:01 +0000 (17:56 +0100)] 
docs: improve some wordings on the man page of wipefs

Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
10 years agotextual: add a docstring to most of the utilities
Benno Schulenberg [Mon, 22 Dec 2014 21:57:17 +0000 (22:57 +0100)] 
textual: add a docstring to most of the utilities

This adds a concise description of a tool to its usage text.

A first form of this patch was proposed by Steven Honeyman
(see http://www.spinics.net/lists/util-linux-ng/msg09994.html).

Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
10 years agochsh: keep struct options in .rodata
Karel Zak [Tue, 6 Jan 2015 10:00:51 +0000 (11:00 +0100)] 
chsh: keep struct options in .rodata

Signed-off-by: Karel Zak <kzak@redhat.com>
10 years agochsh: simplify get_shell_list()
Karel Zak [Tue, 6 Jan 2015 09:57:09 +0000 (10:57 +0100)] 
chsh: simplify get_shell_list()

Signed-off-by: Karel Zak <kzak@redhat.com>
10 years agonewgrp: set function arguments read-only when possible
Sami Kerola [Sat, 20 Dec 2014 12:37:58 +0000 (12:37 +0000)] 
newgrp: set function arguments read-only when possible

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
10 years agonewgrp: move shell determination closer where it is used
Sami Kerola [Sat, 20 Dec 2014 12:26:17 +0000 (12:26 +0000)] 
newgrp: move shell determination closer where it is used

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
10 years agonewgrp: simplify if else clauses
Sami Kerola [Sat, 20 Dec 2014 12:23:06 +0000 (12:23 +0000)] 
newgrp: simplify if else clauses

The 'if' clauses that have termination as either of the control flow
results will never need 'else'.  Making the termination to happen true
flow is enough.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
10 years agochsh: fail get_shell_list() check when /etc/shells cannot be opened
Sami Kerola [Fri, 19 Dec 2014 22:49:32 +0000 (22:49 +0000)] 
chsh: fail get_shell_list() check when /etc/shells cannot be opened

And get rid of stdbool.h true/false usage.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
10 years agochsh: simplify check_shell()
Sami Kerola [Fri, 19 Dec 2014 19:56:29 +0000 (19:56 +0000)] 
chsh: simplify check_shell()

Shell null check is redundant.  The shell can be null only after
ask_new_shell returned such, and that is checked earlier in program
logic.

Secondly the check_shell does not need to return values, in such cases
the program can simply exit.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
10 years agochsh: rewrite function interacting with user to get path to new shell
Sami Kerola [Fri, 19 Dec 2014 19:28:19 +0000 (19:28 +0000)] 
chsh: rewrite function interacting with user to get path to new shell

Rename prompt() to ask_new_shell().  Remove fixed size buffer and
allocate path to new shell, that should make Hurd people happy.  Use
strutils.h for white space trimming.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
10 years agochsh: clean up parse_argv()
Sami Kerola [Sun, 14 Dec 2014 22:58:01 +0000 (22:58 +0000)] 
chsh: clean up parse_argv()

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
10 years agochsh: allow user to set shell to /bin/sh if none is set
Sami Kerola [Sun, 14 Dec 2014 23:20:01 +0000 (23:20 +0000)] 
chsh: allow user to set shell to /bin/sh if none is set

Earlier setting a /bin/sh was impossible for users that had nothing set
as shell, as that was seen as no change.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
10 years agochsh: set few variables read-only and rename one of them
Sami Kerola [Sun, 14 Dec 2014 23:10:48 +0000 (23:10 +0000)] 
chsh: set few variables read-only and rename one of them

This change also improves couple variable initializations.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
10 years agochsh: use getline() to support arbitrarily long lines
Sami Kerola [Sun, 14 Dec 2014 22:50:44 +0000 (22:50 +0000)] 
chsh: use getline() to support arbitrarily long lines

Use of fgets() can make a single long line to be understood as two
entries, and someone could play tricks with the remainder part of the
buffer.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
10 years agochfn, chsh: share illegal_passwd_chars() function
Sami Kerola [Sun, 14 Dec 2014 21:38:56 +0000 (21:38 +0000)] 
chfn, chsh: share illegal_passwd_chars() function

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
10 years agochsh: remove function prototypes
Sami Kerola [Sun, 14 Dec 2014 20:48:12 +0000 (20:48 +0000)] 
chsh: remove function prototypes

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
10 years agocfdisk: improve Dump dialog
Karel Zak [Mon, 5 Jan 2015 11:53:50 +0000 (12:53 +0100)] 
cfdisk: improve Dump dialog

Signed-off-by: Karel Zak <kzak@redhat.com>
10 years agocfdisk: improve menu clean function
Karel Zak [Mon, 5 Jan 2015 11:42:24 +0000 (12:42 +0100)] 
cfdisk: improve menu clean function

Signed-off-by: Karel Zak <kzak@redhat.com>
10 years agocfdisk: detect too small partition sizes
Karel Zak [Mon, 5 Jan 2015 11:13:25 +0000 (12:13 +0100)] 
cfdisk: detect too small partition sizes

References: https://github.com/karelzak/util-linux/issues/136
Signed-off-by: Karel Zak <kzak@redhat.com>
10 years agochfn: fix compilation without libuser
Karel Zak [Fri, 19 Dec 2014 14:05:04 +0000 (15:05 +0100)] 
chfn: fix compilation without libuser

Signed-off-by: Karel Zak <kzak@redhat.com>
10 years agomore: fix compiler warnings
Karel Zak [Fri, 19 Dec 2014 13:34:03 +0000 (14:34 +0100)] 
more: fix compiler warnings

Signed-off-by: Karel Zak <kzak@redhat.com>
10 years agoMerge remote-tracking branch 'sami/2014wk49'
Karel Zak [Fri, 19 Dec 2014 13:28:42 +0000 (14:28 +0100)] 
Merge remote-tracking branch 'sami/2014wk49'

* sami/2014wk49:
  chfn: make command to obey login.defs CHFN_RESTRICT instructions
  chfn: remove set_changed_data() and add add_missing()
  chfn: rename prompt() to ask_new_field()
  chfn: move new and old finger structs to chfn control struct
  chfn: clean up parse_argv()
  chfn: add minimalistic struct chfn_control
  chfn: simplify parse_passwd() by using strsep()
  chfn: fix usage() regression
  chfn: use xasprintf() rather than bunch of strlen() and malloc() calls
  chfn: rewrite prompt() to use strutils
  chfn: remove function prototypes
  lslogins: use hardcoded paths from pathnames.h
  lslogins: add space to systemd journal header and message
  lslogins: reject unknown time format arguments
  lslogins: fix short options
  lslogins: tell why command failed
  lslogins: make journald last logs time stamps to honor --time-format
  lslogins: allow changing password changed and expiration time formats

10 years agoipcs: fix shmctl() usage
Karel Zak [Fri, 19 Dec 2014 12:42:41 +0000 (13:42 +0100)] 
ipcs: fix shmctl() usage

The function shmctl() has to be called with 'struct shmid_ds', and if
you need 'struct shminfo' then the right way is to cast:

bad way:
  struct shm_info info;

  shmctl(0, SHM_INFO, &info);

right way:
  struct shmid_ds buf;
  struct shm_info *info;

  shmctl(0, SHM_INFO, &buf);
  info = (struct shm_info *) &buf);

The patch also fixes bug in ipc_shm_get_limits() where is missing
lim->shmmax in code based on shmctl().

Signed-off-by: Karel Zak <kzak@redhat.com>
10 years agotests: don't check the current ipcs limits
Karel Zak [Fri, 19 Dec 2014 12:36:07 +0000 (13:36 +0100)] 
tests: don't check the current ipcs limits

The ipcs/limit test checks the current kernel limits, but we have no
clue about the current setting, so on on 64bit system it may overflow.

It's better to test for well known limits only. For the random setting
is there ipcs/limit2 test.

Signed-off-by: Karel Zak <kzak@redhat.com>
10 years agomore: blacklist unsigned integer overflow [AddressSanitizer]
Sami Kerola [Wed, 17 Dec 2014 22:57:02 +0000 (22:57 +0000)] 
more: blacklist unsigned integer overflow [AddressSanitizer]

The mbrtowc() return values are overflowing by design.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
10 years agoipcs: fix two data type errors [AddressSanitizer]
Sami Kerola [Tue, 25 Nov 2014 20:04:44 +0000 (20:04 +0000)] 
ipcs: fix two data type errors [AddressSanitizer]

==3218==ERROR: AddressSanitizer: stack-buffer-overflow on address 0x7fffa577e2b0 at pc 0x4501f9 bp 0x7fffa577e130 sp 0x7fffa577e108
WRITE of size 112 at 0x7fffa577e2b0 thread T0
    #0 0x4501f8 in shmctl /home/users/aadgrand/LLVM/releases/ubuntu/final/llvm.src/projects/compiler-rt/lib/sanitizer_common/sanitizer_common_interceptors.inc:2502
    #1 0x48bd13 in ipc_shm_get_info /home/travis/build/kerolasa/lelux-utiliteetit/sys-utils/ipcutils.c:157
    #2 0x488884 in do_shm /home/travis/build/kerolasa/lelux-utiliteetit/sys-utils/ipcs.c:279
    #3 0x4844a8 in main /home/travis/build/kerolasa/lelux-utiliteetit/sys-utils/ipcs.c:175
    #4 0x2afb3f8c176c (/lib/x86_64-linux-gnu/libc.so.6+0x2176c)
    #5 0x48408c in _start (/home/travis/build/kerolasa/lelux-utiliteetit/ipcs+0x48408c)

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
10 years agolscpu: blacklist vmware_bdoor() AddressSanitizer check
Sami Kerola [Sat, 22 Nov 2014 09:01:36 +0000 (09:01 +0000)] 
lscpu: blacklist vmware_bdoor() AddressSanitizer check

AddressSanitizer is identifying the __asm__ segment as suspicious.

==1215==ERROR: AddressSanitizer: SEGV on unknown address 0x000000000000
(pc 0x0000004ccffd bp 0x7fff9b7184f0 sp 0x7fff9b7184e0 T0)
    #0 0x4ccffc in vmware_bdoor /home/src/util-linux/sys-utils/lscpu.c:660

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
10 years agoinclude/c: define UL_ASAN_BLACKLIST address_sanitizer function attribute
Sami Kerola [Sat, 22 Nov 2014 08:49:34 +0000 (08:49 +0000)] 
include/c: define UL_ASAN_BLACKLIST address_sanitizer function attribute

The UL_ASAN_BLACKLIST allows AddressSanitizer to be switched off for
functions that cannot be checked.

Reference: http://dxr.mozilla.org/mozilla-central/source/mfbt/Attributes.h
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
10 years agochfn: make command to obey login.defs CHFN_RESTRICT instructions
Sami Kerola [Sun, 14 Dec 2014 16:45:50 +0000 (16:45 +0000)] 
chfn: make command to obey login.defs CHFN_RESTRICT instructions

Reference: http://man7.org/linux/man-pages/man5/login.defs.5.html
Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=138519
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
10 years agochfn: remove set_changed_data() and add add_missing()
Sami Kerola [Wed, 17 Dec 2014 22:28:49 +0000 (22:28 +0000)] 
chfn: remove set_changed_data() and add add_missing()

The add_missing() and find_field() functions are needed when input data
is incomplete, such as in case when chfn is instructed to change only
selected fields with command line options.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
10 years agochfn: rename prompt() to ask_new_field()
Sami Kerola [Wed, 17 Dec 2014 22:28:03 +0000 (22:28 +0000)] 
chfn: rename prompt() to ask_new_field()

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
10 years agochfn: move new and old finger structs to chfn control struct
Sami Kerola [Sun, 14 Dec 2014 17:44:11 +0000 (17:44 +0000)] 
chfn: move new and old finger structs to chfn control struct

This change is a little bit messy, and requires a comment the struct
finfo should not have 'struct passwd *pw' as it's member.  The earlier
struct design would have been burden to maintain, and confusing to use.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
10 years agochfn: clean up parse_argv()
Sami Kerola [Sun, 14 Dec 2014 13:56:32 +0000 (13:56 +0000)] 
chfn: clean up parse_argv()

Use switch() case ?: for all option parsing, as in most of the other
source files.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
10 years agochfn: add minimalistic struct chfn_control
Sami Kerola [Sun, 14 Dec 2014 13:48:17 +0000 (13:48 +0000)] 
chfn: add minimalistic struct chfn_control

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
10 years agochfn: simplify parse_passwd() by using strsep()
Sami Kerola [Sun, 14 Dec 2014 13:28:57 +0000 (13:28 +0000)] 
chfn: simplify parse_passwd() by using strsep()

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
10 years agochfn: fix usage() regression
Sami Kerola [Sun, 14 Dec 2014 12:31:11 +0000 (12:31 +0000)] 
chfn: fix usage() regression

Commit db433bf737a5fd4e1c7cca5e3603934743eebd1c changed -u for --help to
-h, that is not true.  The -h is short hand for --home-phone.  And the
--version is accompanied with -v not -V.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
10 years agochfn: use xasprintf() rather than bunch of strlen() and malloc() calls
Sami Kerola [Sun, 14 Dec 2014 12:28:26 +0000 (12:28 +0000)] 
chfn: use xasprintf() rather than bunch of strlen() and malloc() calls

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
10 years agochfn: rewrite prompt() to use strutils
Sami Kerola [Sun, 14 Dec 2014 11:37:03 +0000 (11:37 +0000)] 
chfn: rewrite prompt() to use strutils

The left and right white space trimming can be done with strutils.h
[lr]trim_whitespace() functions.

As a minor fix when user input exceeds maxium allowed gecos field length
the remaining characters in stdin are purged so that re-prompting works
correctly.

Additionally the prompt() is made to add message to check_gecos_string(),
so that there are less similar strings for translation project to deal.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
10 years agochfn: remove function prototypes
Sami Kerola [Sat, 13 Dec 2014 22:16:21 +0000 (22:16 +0000)] 
chfn: remove function prototypes

Requires resuffling functions order they work without issues.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
10 years agolslogins: use hardcoded paths from pathnames.h
Sami Kerola [Sat, 13 Dec 2014 18:07:44 +0000 (18:07 +0000)] 
lslogins: use hardcoded paths from pathnames.h

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
10 years agolslogins: add space to systemd journal header and message
Sami Kerola [Sat, 13 Dec 2014 17:49:20 +0000 (17:49 +0000)] 
lslogins: add space to systemd journal header and message

This commit changes journal messages in individual user printout the
following way.

Dec 13 16:02:05 systemd[324]:Time has been changed (old)
Dec 13 16:02:05 systemd[324]: Time has been changed (new)

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
10 years agolslogins: reject unknown time format arguments
Sami Kerola [Sat, 13 Dec 2014 17:11:04 +0000 (17:11 +0000)] 
lslogins: reject unknown time format arguments

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
10 years agolslogins: fix short options
Sami Kerola [Sat, 13 Dec 2014 16:58:37 +0000 (16:58 +0000)] 
lslogins: fix short options

Usage is promising -e is an option alias of --export, so make it work.
And get rid of -x that was accepted, but not in use.

Long only enum member OPT_VER was probably a development time idea, that
never got to be used.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
10 years agolslogins: tell why command failed
Sami Kerola [Sat, 13 Dec 2014 16:41:06 +0000 (16:41 +0000)] 
lslogins: tell why command failed

Printing usage() without hint what is wrong does not help an user.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
10 years agolslogins: make journald last logs time stamps to honor --time-format
Sami Kerola [Fri, 12 Dec 2014 23:07:28 +0000 (23:07 +0000)] 
lslogins: make journald last logs time stamps to honor --time-format

This makes by default the last logs to have year in output when necessary.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
10 years agolslogins: allow changing password changed and expiration time formats
Sami Kerola [Fri, 12 Dec 2014 22:46:04 +0000 (22:46 +0000)] 
lslogins: allow changing password changed and expiration time formats

The password change and expiry has are marked with resolution of a day,
so add a new short iso-8601 format.  With this system admins can easily
find users has not updated their password lately

$ lslogins --time-format=iso --user --output=pwd-change,user | sort -n

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
10 years agostrutils: fix unsigned integer overflows [AddressSanitizer]
Sami Kerola [Sat, 22 Nov 2014 08:18:17 +0000 (08:18 +0000)] 
strutils: fix unsigned integer overflows [AddressSanitizer]

include/strutils.h:174:10: runtime error: unsigned integer overflow: 0 -
1 cannot be represented in type 'size_t' (aka 'unsigned long')

include/strutils.h:178:6: runtime error: unsigned integer overflow:
18446744073709551615 + 1 cannot be represented in type 'size_t' (aka
'unsigned long')

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
10 years agofdisk: (sgi) fix unsigned integer overflow [AddressSanitizer]
Sami Kerola [Sat, 22 Nov 2014 08:13:59 +0000 (08:13 +0000)] 
fdisk: (sgi) fix unsigned integer overflow [AddressSanitizer]

include/pt-sgi.h:103:7: runtime error: unsigned integer overflow: 0 -
1186450447 cannot be represented in type 'unsigned int'

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
10 years agolib: fix crc32 and crc64 interger overflows [AddressSanitizer]
Sami Kerola [Sat, 22 Nov 2014 00:31:07 +0000 (00:31 +0000)] 
lib: fix crc32 and crc64 interger overflows [AddressSanitizer]

lib/crc32.c:111:11: runtime error: unsigned integer overflow: 0 - 1
cannot be represented in type 'size_t' (aka 'unsigned long')

lib/crc64.c:101:12: runtime error: unsigned integer overflow: 0 - 1
cannot be represented in type 'size_t' (aka 'unsigned long')

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
10 years agocal: fix signed integer overflow [AddressSanitizer]
Sami Kerola [Fri, 21 Nov 2014 23:33:33 +0000 (23:33 +0000)] 
cal: fix signed integer overflow [AddressSanitizer]

misc-utils/cal.c:811:16: runtime error: signed integer overflow:
2147483645 + 536870911 cannot be represented in type 'int'

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
10 years agolib/mbalign: fix unsigned integer overflow [AddressSanitizer]
Sami Kerola [Fri, 21 Nov 2014 23:11:31 +0000 (23:11 +0000)] 
lib/mbalign: fix unsigned integer overflow [AddressSanitizer]

This error was reported 155 times.

lib/mbsalign.c:322:18: runtime error: unsigned integer overflow: 0 - 1
cannot be represented in type 'size_t' (aka 'unsigned long')

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
10 years agosfdisk: in the usage text show -v for --version instead of -V
Benno Schulenberg [Sun, 14 Dec 2014 19:45:33 +0000 (20:45 +0100)] 
sfdisk: in the usage text show -v for --version instead of -V

In sfdisk -V is taken by --verify.  Use for the description of --version
the same indentation as for --help, not that of the other options.

Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
10 years agodocs: fix the grammar and formatting in the man page of sfdisk
Benno Schulenberg [Sun, 14 Dec 2014 19:45:32 +0000 (20:45 +0100)] 
docs: fix the grammar and formatting in the man page of sfdisk

Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
10 years agodocs: adjust some formatting and wordings in a handful of man pages
Benno Schulenberg [Sun, 14 Dec 2014 19:45:31 +0000 (20:45 +0100)] 
docs: adjust some formatting and wordings in a handful of man pages

Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
10 years agodocs: adjust the grammar, text, sorting and formatting of logger man page
Benno Schulenberg [Sun, 14 Dec 2014 19:45:30 +0000 (20:45 +0100)] 
docs: adjust the grammar, text, sorting and formatting of logger man page

The message argument is not an option and should not be listed among
those.  Describe the optional argument of --rfc5424 better.  Use the
= and no space for optional option arguments.  Don't italicize words
unnecessarily.  Use bold for literal things.  And sort the options
alphabetically (apart from -V and -h).

Signed-off-by: Benno Schulenberg <bensberg@justemail.net>