Karel Zak [Thu, 10 May 2018 09:59:41 +0000 (11:59 +0200)]
Merge branch 'fixes' of https://github.com/yontalcar/util-linux
* 'fixes' of https://github.com/yontalcar/util-linux:
libfdisk: fix list_del after partition reset
choom: set oom_score_adj before exec
fdisk: fix typo in debug string
Sami Kerola [Thu, 3 May 2018 21:57:59 +0000 (22:57 +0100)]
last: fix false positive compiler warning
login-utils/last.c: In function ‘list’:
login-utils/last.c:398:36: warning: argument to ‘sizeof’ in ‘strncat’ call
is the same expression as the source; did you mean to use the size of the
destination? [-Wsizeof-pointer-memaccess]
strncat(utline, p->ut_line, sizeof(p->ut_line));
The sizeof(utline) is defined as sizeof(p->ut_line) + 1, so the compiler got
that wrong. Lets truncate strncat() otherway around to keep gcc 8.1 happy.
Sami Kerola [Thu, 3 May 2018 21:57:58 +0000 (22:57 +0100)]
zramctl: fix truncation warning
sys-utils/zramctl.c: In function ‘zram_get_sysfs’:
sys-utils/zramctl.c:220:52: warning: ‘%s’ directive output may be truncated
writing up to 4095 bytes into a region of size 27 [-Wformat-truncation=]
snprintf(z->devname, sizeof(z->devname), "/dev/%s", name);
As an additional good thing zramctl will no longer allocate 4096 bytes from
stack when just 23 bytes is enough.
[kzak@redhat.com: - use macro rather than hardcoded string for the path]
Signed-off-by: Sami Kerola <kerolasa@iki.fi> Signed-off-by: Karel Zak <kzak@redhat.com>
Sami Kerola [Thu, 3 May 2018 21:57:57 +0000 (22:57 +0100)]
lib/canonicalize: fix truncation warning
lib/canonicalize.c: In function ‘canonicalize_dm_name’:
lib/canonicalize.c:42:45: warning: ‘%s’ directive output may be truncated
writing up to 255 bytes into a region of size 244 [-Wformat-truncation=]
snprintf(path, sizeof(path), "/dev/mapper/%s", name);
Notice that this warnign fix does not improve code enormously. The earlier
snprintf() truncation will not happen a bit earlier when fgets() is called.
In that sense this change merely makes one easy to silence warning to
disappear, and therefore improve change of noticing useful messaging as such
crops up.
[kzak@redhat.com: - use macro rather than hardcoded string for mapper path]
Signed-off-by: Sami Kerola <kerolasa@iki.fi> Signed-off-by: Karel Zak <kzak@redhat.com>
Karel Zak [Fri, 20 Apr 2018 07:50:04 +0000 (09:50 +0200)]
umount: add note about --lazy
Unfortunately, it's pretty common that users on production systems use
lazy umount to fix some FS issues. The usual result is unwanted system
reboot, because -l is not the right way how to fix unreachable NFS or
mess with local FS with submounts.
Note that after lazy umount /proc/self/mountinfo does not contain the
FS entry, but kernel still references the FS. It makes it very
difficult to debug.
Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=1566674 Suggested-by: Steve Dickson <steved@redhat.com> Signed-off-by: Karel Zak <kzak@redhat.com>
libmount: fix mnt_table_is_fs_mounted() for NFS bind mounts.
When you bind-mount a subdirectory of a local filesystem, the
path to that subdirectory appears as the fourth field in mountinfo.
For nfs mounts, the fourth field is always "/", and the subdirectory
part is appended to the "special" (aka "device") field. This is
consistent with historical NFS usage which always includes a path in
the fs_spec field.
libmount needs to know about this when "mount -a" checks to see if
a filesystem is already mounted.
Richard Fuchs [Tue, 17 Apr 2018 13:40:20 +0000 (09:40 -0400)]
bugfix: fix possible segfault during umount -a
mnt_context_get_mtab() doesn't set its return **tb argument on error,
and so in mnt_context_next_umount() mtab will remain uninitialized on
error, later resulting in cxt->mtab containing garbage, possibly
resulting in segfault on exit.
Karel Zak [Mon, 16 Apr 2018 08:37:31 +0000 (10:37 +0200)]
Merge branch 'rename-interactive' of https://github.com/g-raud/util-linux
* 'rename-interactive' of https://github.com/g-raud/util-linux:
rename: fixup & style (no functional changes)
rename: test availability of __fpurge() and fpurge()
rename: ask(): call __fpurge() to cater for multi-byte characters
rename.1: describe interactive mode
rename: ask(): print n when EOF on input
rename: detect tty in cbreak mode to make ask() read a single byte
rename.1: fix warning section
rename: add option --interactive to ask before overwriting
rename: skip faccessat() failure if AT_SYMLINK_NOFOLLOW is not a valid flag
rename: check source file access early
Karel Zak [Fri, 13 Apr 2018 09:22:21 +0000 (11:22 +0200)]
lslocks: add info about OFD
It seems users are confused by PID -1 and missing path. This patch add
more information about OFD locks to the man page and "undefined" to
the COMMAND column.
References: http://austingroupbugs.net/view.php?id=768
Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=1527102 Signed-off-by: Karel Zak <kzak@redhat.com>
Karel Zak [Thu, 12 Apr 2018 12:21:47 +0000 (14:21 +0200)]
libblkid: (hfs) check allocation size
The current prober is based on signature only (two bytes!). It seems
pretty fragile. Linux kernel also checks for allocation size in the
superblock, let's use it too... it's better than nothing.
Reported-by: Milan Broz <gmazyland@gmail.com> Signed-off-by: Karel Zak <kzak@redhat.com>
The POSIX standard states that poll(3P) is being made available by
<poll.h>, not <sys/poll.h>. Most commands already include the correct
header, with the exception of rfkill. Fix that to avoid a warning on
musl-based systems.
The header <ncursesw/ncurses.h> defines the get_wch(3) function only
when `NCURSES_WIDECHAR` is defined. This define is actually getting set
in the same header file, but only in case `_XOPEN_SOURCE` is defined and
has a value of 500 or higher. As we already have the precedence of
defining `_XOPEN_SOURCE` to a value of 600 in some other files, simply
define it to the minimum required value of 500 in "cfdisk.c". This
silences a warning for `get_wch` being unknown.
setpriv: implement option to set parent death signal
When a process uses the syscall `prctl(PR_SET_PDEATHSIG, ...)`, it will
get notified with a process-defined signal as soon as its parent process
dies. This is for example being used by unshare(1)'s recently added
"--kill-child" option, causing the forked child to be killed as soon as
unshare itself dies.
Unfortunately, some LSMs will cause the parent death signal to be reset
when a process changes credentials, with the most important ones being
SELinux and AppArmor. The following command will thus not work as
expected:
unshare --fork --kill-child setpriv --reuid user <executable>
As soon as setpriv changes UID, the parent death signal is cleared and
the child will never get signalled when unshare gets killed.
Add a new option "--pdeathsig keep|clear|<signal>". Setting this flag
will cause us to either
- restore the previously active parent death signal as soon as the
setpriv has applied all credential changes
- clear the parent death signal
- set the parent death signal to "<signal>"
Furthermore, print out the currently set signal when dumping process
state.
[kzak@redhat.com: - small changes in codding style]
Signed-off-by: Patrick Steinhardt <ps@pks.im> Signed-off-by: Karel Zak <kzak@redhat.com>
rename: ask(): call __fpurge() to cater for multi-byte characters
Making a purge in cbreak mode also makes the code compatible with
canonical mode. This can be useful in the case a shell, like bash, does
not restore the tty state of stopped jobs before restarting them. An
alternative fix to this minor shortcoming would be to retest the tty
state each time inside ask().
G.raud Meyer [Thu, 29 Mar 2018 11:28:10 +0000 (13:28 +0200)]
rename: check source file access early
This change makes rename detect inexisting files given on the command
line and consider them faliures. This is particularly useful with
--no-act (to detect extraneous arguments).
It also prevents skipping non existing files (when the modified name
happens to exist). This makes --verbose not print skipping messages of
false positives (the access error is printed instead).
Karel Zak [Mon, 9 Apr 2018 09:46:22 +0000 (11:46 +0200)]
Merge branch 'rename-fix-noact-without-nooverwrite' of https://github.com/g-raud/util-linux
* 'rename-fix-noact-without-nooverwrite' of https://github.com/g-raud/util-linux:
rename: prevent --no-act from setting --no-overwrite
rename: when --no-overwrite skip verbosily only when --verbose
rename: consolidate printing the symlink in addition to its target
rename: fix/reverse the semantics of --no-overwrite in --symlink mode
misc-utils/getopt.1: minor corrections to the manual
Input file is getopt.1
Test nr. 2:
Enable and fix warnings from 'test-groff'.
Input file is /tmp/getopt.1
<getopt.1>:5 (macro BI): only 1 argument, but more are expected
<getopt.1>:419 (macro IR): only 1 argument, but more are expected
<getopt.1>:421 (macro IR): only 1 argument, but more are expected
chk_manuals: Output is from: test-groff -b -e -mandoc -T utf8 -rF0 -t -w w -z
and
Test nr. 15:
Change the name of a macro for two fonts (e.g., BR and IR) to one letter,
if there is only one argument.
Add the second argument if needed. It is sometimes part of the first one.
Protect a full stop (.) with "\&", if it has a blank (white-space) in front
of or (ignoring transparent characters to the full stop) after it, and it does
not mean an end of a sentence.
204:the next parameter (i.e. separated by whitespace on the command
219:or as the next argument (i.e. separated by whitespace on the command
352:(i.e. a parameter that does not start with a
379:will be parsed. It will still do parameter shuffling (i.e. all
#####
Test nr. 20:
Use a macro to change to the italic font, instead of \fI [1], if
possible.
The macros have the italic corrections, but "\c" removes them.
[1] man-pages(7)
57:is set, or if the first \fIparameter\fR is not an option (does not start
144:Set quoting conventions to those of \fIshell\fR.
#####
Test nr. 21:
Use the word (in)valid instead of (il)legal if not related to legal matters.
See "www.gnu.org/prep/standards".
25:check for legal options. It uses the
#####
Test nr. 28:
Wrong distance between sentences or protect the indicator.
1) Separate the sentences and subordinate clauses; each begins on a new
line. See man-pages(7) and "info groff".
Or
2) Adjust space between sentences (two spaces),
3) or protect the indicator by adding "\&" after it.
The "indicator" is an "end-of-sentence character" (.!?).
204:the next parameter (i.e. separated by whitespace on the command
219:or as the next argument (i.e. separated by whitespace on the command
352:(i.e. a parameter that does not start with a
379:will be parsed. It will still do parameter shuffling (i.e. all Signed-off-by: Bjarni Ingi Gislason <bjarniig@rhi.hi.is>
#####
<fallocate.1>:10 (macro IR): only 1 argument, but more are expected
<fallocate.1>:24 (macro RB): only 1 argument, but more are expected
<fallocate.1>:25 (macro IR): only 1 argument, but more are expected
chk_manuals: Output is from: test-groff -b -e -mandoc -T utf8 -rF0 -t -w w -z
and
Test nr. 15:
Change the name of a macro for two fonts (e.g., BR and IR) to one letter,
if there is only one argument.
Add the second argument if needed. It is sometimes part of the first one.
10:.IR length
24:.RB \-l
25:.IR length
#####
Test nr. 12:
Change -- in x--y to \(em (em-dash), or, if an
option, to \-\-
65:You can think of this option as doing a "\fBcp --sparse\fP" and then renaming
#####
Test nr. 20:
Use a macro to change to the italic font, instead of \fI [1], if
possible.
The macros have the italic corrections, but "\c" removes them.
[1] man-pages(7)
39:The \fIlength\fR and \fIoffset\fR
50:to be collapsed starts at \fIoffset\fP and continues
51:for \fIlength\fR bytes. At the completion of the operation, the contents of
52:the file starting at the location \fIoffset\fR+\fIlength\fR will be appended at the
53:location \fIoffset\fR, and the file will be \fIlength\fR bytes smaller. The option
71:Insert a hole of \fIlength\fR bytes from \fIoffset\fR, shifting existing data.
85:\fIoffset\fP and continuing for \fIlength\fR bytes. Within the
103:Zeroes space in the byte range starting at \fIoffset\fP and
104:continuing for \fIlength\fR bytes. Within the specified range, blocks are
#####
Test nr. 27:
Split lines longer than 80 characters into two or more lines.
Apropriate break points are the end of a sentence and a subordinate
clause.
fallocate.1: line 45 length 86
fallocate.1: line 52 length 83
fallocate.1: line 53 length 83
fallocate.1: line 100 length 95
#####
Test nr. 28:
Wrong distance between sentences or protect the indicator.
1) Separate the sentences and subordinate clauses; each begins on a new
line. See man-pages(7) and "info groff".
Or
2) Adjust space between sentences (two spaces),
3) or protect the indicator by adding "\&" after it.
The "indicator" is an "end-of-sentence character" (.!?).
99:Enable POSIX operation mode. In that mode allocation operation always completes,
#####
Test nr. 37:
Have a space after a comma in an argument to an alternating fonts macro.
The space belongs to the comma, so ', '.
Add a comma before "and", "or", or "nor" if a series contains three or
more words
41:MiB (=1024*1024), and so on for GiB, TiB, PiB, EiB, ZiB and YiB (the "iB" is
43:KB (=1000), MB (=1000*1000), and so on for GB, TB, PB, EB, ZB and YB.
45:The options \fB\-\-collapse\-range\fP, \fB\-\-dig\-holes\fP, \fB\-\-punch\-hole\fP and
Sami Kerola [Thu, 5 Apr 2018 19:56:54 +0000 (20:56 +0100)]
bash-completion: do not print eject --cdspeed error messages
Bash completion is proposing --cdspeed option argument from 'eject
--listspeed /dev/cdrom' output. Nowadays it is common not to have such
device, and this results to an unwanted error message to stderr merely
messing up command line. Lets stop that.
G.raud Meyer [Thu, 29 Mar 2018 10:58:44 +0000 (12:58 +0200)]
rename: prevent --no-act from setting --no-overwrite
This fixes a bug introduced by commit fabb90676 ("Added --no-override
option to rename.", 2017-05-27) where the fallthrough meant to let
--no-act set --verbose was changed to set --no-override (the previous
code was too smart).
Do not let --no-act set --verbose anymore but update the manual to
recommend adding option --verbose. This is to be able to make --no-act
detect only non existing file arguments (in a future commit).
G.raud Meyer [Sat, 24 Mar 2018 22:53:21 +0000 (23:53 +0100)]
rename: fix/reverse the semantics of --no-overwrite in --symlink mode
The previous behaviour was to overwrite a symlink only when the new
destination did not exist, i.e. to avoid creating a symlink to an
existing file! It had not been documented and it seems
counter-intuitive to me. So the new behavior protects symlinks pointing
to existing targets from being changed.
Karel Zak [Tue, 27 Mar 2018 12:21:46 +0000 (14:21 +0200)]
tests: remove namei(1) failed lstat test
The strerror() output is is nothing stable and may be different on
another systems. It would be possible to use sed(1) to unify the
output, but it seems overkill in this case.
Sami Kerola [Sat, 10 Mar 2018 21:20:24 +0000 (21:20 +0000)]
closestream: remove dummy function __fpending()
Exclude __fpending() from build when function is not available. This is
more obvious than adding a dummy function and expecting compiler to
eliminate it as dead code.
Karel Zak [Tue, 27 Mar 2018 10:54:53 +0000 (12:54 +0200)]
Merge branch 'master' of https://github.com/pali/util-linux
* 'master' of https://github.com/pali/util-linux:
tests: Add tests for FAT32 labels
blkid: Encode any field which starts with LABEL in same way as LABEL field
libblkid: vfat: Change parsing label in special cases
Karel Zak [Tue, 27 Mar 2018 08:40:13 +0000 (10:40 +0200)]
column: fix leading space characters bug
The bug has been introduced during column(1) rewrite. The function
read_input() need to skip leading space only temporary to detect empty
lines, but the rest of the code has to use the original buffer (line).
I've tried to fix one of the symptoms by 5c7b67fbbf41c973ca8d49b1e8bdba22dbb917aa
(alter), but this solution is unnecessary and too complex.