Professor Eggert, maintainer of the tz database, reviewed
the new POSIX vs 'RIGHT' man-page section and suggested
the following corrections.
Correct the subdirectory names and remove IANA from the
name of the Time Zone Database.
Signed-off-by: J William Piggott <elseifthen@gmx.com>
As said in include/c.h the usleep() is marked as obsolete, so do the same
that most of the other util-linux calls do with this interface.
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
The message "stat failed %s" seems to say that stat() failed to
do something, or failed to pass a test, but of course it means
that the statting of something failed. So say so. Also make
two very similar messages equal to this one.
Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
Messages containing line breaks somehow look broken when additional time,
facility or level information is displayed, because they partly appear in
time/facility/level column.
Indent them accordingly.
Signed-off-by: Karel Zak <kzak@redhat.com>
Intel compiler complains about printf style function calls with trivial
format string and no other arguments. Like this one:
../sys-utils/ipcrm.c(117): warning #2279: printf/scanf format not a string literal and no format arguments
err(EXIT_FAILURE, iskey ? _("key failed") : _("id failed"));
It's backwardly incompatible nonsense to prefer mtab on remount.
mount -o remount /foo
has to read mount options from fstab otherwise the remount has no
effect. (The ideal solution would be to read both mtab, then modify
the options according to fstab -- but for now more important is to be
backwardly compatible.)
References: https://bugzilla.redhat.com/show_bug.cgi?id=1182778
Signed-off-by: Karel Zak <kzak@redhat.com>
The old behavior when hwclock was unable to access
the rtc device was to fallback to direct ISA I/O.
This was sometimes allowing two processes to access
the Hardware Clock at the same time and hanging the
system. This is the reason the rtc device driver
only allows one process to open it.
Now hwclock defaults to using the rtc device and only
uses direct ISA when that option is given.
Signed-off-by: J William Piggott <elseifthen@gmx.com>
We have enabled CMOS also for x86_64, but it should be available only
if --directisa is explicitly specified.
Signed-off-by: Karel Zak <kzak@redhat.com>
* call --help, --verbose and --list from one place only
* add 'archwrapper' variable to detect when called by symplink
* make --list available only got setchar(8) (but no for symlinks)
Reported-by: Benno Schulenberg <bensberg@justemail.net>
Signed-off-by: Karel Zak <kzak@redhat.com>
When the provided string does not match any architecture that
setarch knows about, the response stays "Unrecognized architecture",
but when trying to set the specified architecture does not have any
effect, then respond with "Kernel cannot set architecture to...".
Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
Transform some of them into copyright lines.
Also fix three header lines and snip some trailing whitespace.
Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
Clean up the 'Since v2.26' man page notes.
They were redundant of information already
in the manual, and became too verbose.
Signed-off-by: J William Piggott <elseifthen@gmx.com>
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>
Hwclock's default timescale was changed to UTC in:
commit 7894bf0f08
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>
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>
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>
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>
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>
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>
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>
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>
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>
Commit c372860ddb 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>
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>
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>
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>
==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>
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>
As per the convention shown in Documentation/howto-man-page.txt.
Also make a few other tiny adjustments along the way.
Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
kernel does not require mount source (e.g. device name) on remount, it
means that fstab/mtab/mountinfo should be optional in this case.
For example:
mount -o rw,remount /
has to work on system without mounted /proc.
Signed-off-by: Karel Zak <kzak@redhat.com>
Patch add:
--intro-command string : send command to modem
--pause value : define delay between intro command and ldattach
Based on patch from Martin Schmid <scm@aps-systems.ch>
Signed-off-by: Karel Zak <kzak@redhat.com>
there is a theoretical buffer overflow possible in the hypervisor
parsing code of lscpu. It would require a proc entry to return way more
than expected so it's no high priority. But better be safe than sorry.
At first I thought about switching to fgets but there is another
code file that adds a format specifier. The diff is less intrusive
that way, too.
Signed-off-by: Karel Zak <kzak@redhat.com>
__SWORD_TYPE is not available everywhere, for example it's not defined
by musl libc. It also seems that __SWORD_TYPE is not used for f_type
on some architectures (s390x).
Reported-by: Natanael Copa <ncopa@alpinelinux.org>
Signed-off-by: Karel Zak <kzak@redhat.com>
A new option was added recently; seize this opportunity to cut the
usage text into small and easily managed chunks.
Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
Reading the code this initialization is not necessary, so the change is
mostly about silencing a compiler warning and ensuring the program keeps
on working if there is a future bug that could make uninitialized 'path'
reachable to use.
sys-utils/fstrim.c:247: warning: 'path' may be used uninitialized in this
function
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
To facilitate the calculation of 'cold' vs 'warm' Hardware Clock drift
factor the limit on the update period needs to be less than 8 hours.
4 hours should be enough drift to allow calculations that are not
grossly out of range.
For example, with a workstation that is shutdown every night the cold
drift factor can be significantly different than a drift factor based on
a 24 hour period.
Signed-off-by: J William Piggott <elseifthen@gmx.com>
The new option allows to specify swap options by fstab compatible
string. The concept is the same as for mount(8).
swapon -o pri=1,discard=pages,nofail /dev/sda2
The advantage is that tools (like systmed) that parses fstab can call
swapon without translation from fstab options to swapon(8) command
line options.
Signed-off-by: Karel Zak <kzak@redhat.com>
There are cases where we need to refresh the
timestamps in the adjtime file without updating the
drift factor.
For example, with ntpd and an Eleven Minute Mode
kernel, we need to call systohc at shutdown to
facilitate drift correction. With the current
behavior hwclock will clobber the drift factor to
near zero, because the Hardware Clock and System
Clock are synced by Eleven Minute Mode. What
actually needs to be done is refresh the adjtime
file timestamps and not calculate a new drift
factor.
Because it is a manual process to craft a good
Hardware Clock drift factor, that is, there is no
automated method that will produce a good drift
factor, this patch changes the default drift
calculation behavior to off, and it is turned on
by using the --update-drift option. Once we have a good
drift factor for a given machine we do not want
anything clobbering it, including an administrator
forgetting to turn off recalculation. A system
administrator should make a concious effort in
telling hwclock with the --update-drift option that
(s)he wants to recalculate the drift factor.
Without using the --update-drift option with calibrate
operations only the timestamps are refreshed in
the adjtime file. With the --update-drift option the old
default behavior of refreshing the timestamps and
updating the drift factor is performed.
Signed-off-by: J William Piggott <elseifthen@gmx.com>
When hctosys is used at boot time, making it the
first caller of settimeofday, the responsibility
of setting persistent_clock_is_local is thrust
upon it. Currently hctosys always leaves this
variable uninitialized. This causes a Hardware
Clock configured to use the local timescale to be
clobbered with the UTC timescale by the kernel's
NTP eleven minute mode.
This patch fixes this hctosys bug, by having it
properly set persistent_clock_is_local according
to the time scale configured for the Hardware
Clock.
It does this via the kernel warp_clock function
but this in inconsequential, because we set the
system time immediately afterward.
Signed-off-by: J William Piggott <elseifthen@gmx.com>
Allowing hctosys to drift compensate facilitates:
More precise setting of the System Clock early in
the boot process when --adjust cannot be used
because the file system is not writeable.
Applies sub second drift corrections immediately,
where as --adjust cannot.
Reduces boot time by not calling hwclock multiple
times, e.g., --hctosys early before fsck when the
file system is read-only, then --adjust later when
the file system is read-write and --hctosys again
for drift correction.
Use of --adjust elsewhere may no longer be
necessary.
Part II
After the original submission of this patch I
realized that now all operations except --systz
require drift corrected Hardware Clock time.
Therefore, it should be done only once early in
the process. Upon implementation of that premise
many improvements were facilitated:
* Adds drift correction to --hctosys.
* Adds setting system time with sub-second precision.
* Adds --get, a drift corrected 'show' operation.
* Improves drift factor calculation precision while
greatly simplifying its algorithm.
* Fixes --show bug, printing integer sub-seconds, and
now uses a more intuitive positive value.
* Fixes --predict bug, drift correction must be
negated to predict future RTC time.
* Reduces the number of function arguments and
lines of code.
Signed-off-by: J William Piggott <elseifthen@gmx.com>
If offset (range[0]) is greater than device size (blksize), the variable 'end'
will be greater than blksize, and range[1] (length) will be recalculated.
The underflow happens when subtracting range[0] (offset) from blksize, thus
range[1] will be the result of an underflow. The bug leads to unwanted behavior
from the program, where range[1] is likely to be a high number and then will
discard a considerable amount of blocks from the device. The fix consists of
exitting the program with an error message when the condition stated above is
true. Spotted while auditing the code.
Signed-off-by: Raphael S. Carvalho <raphaelsc@cloudius-systems.com>
This patch reverts Sami's "timeout cannot be zero", introduced
in commit 605325b23b.
The --timeout 0 has been originally interpreted as --nonblock. The
patch also add hint about this behavior to the man page.
Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=1149974
Signed-off-by: Karel Zak <kzak@redhat.com>
sys-utils/hwclock.c:1219:13: warning: using integer absolute value function
'abs' when argument is of floating point type [-Wabsolute-value]
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
Translating these text elements should happen only once, which is
more likely when the text macros are used properly.
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
In usage texts each word that is an argument should be marked
separately with angular brackets. Also add a translator comment.
Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
* 'misc' of git://github.com/kerolasa/lelux-utiliteetit:
textual: share crypt() error message in sulogin and newgrp
newgrp: avoid use of obsolete getpass() function
newgrp: use libc function to read gshadow if it is available
setarch: use personality() system call when it is available
setarch: reindent code
hwclock: remove referal to deprecated keyboard interface
eject: make open_device() and select_speed() to use struct eject_control
eject: add struct eject_control to remove global variables
mountpoint: simplify if statement
mkfs.minix: fix couple compiler warnings
mountpoint: add struct mountpoint_control
last: improve code readability by renaming variable names
last: make is_phantom() when kernel config does not include audit support
lib: remove xgetpass()
include: simplify fputc_careful() in carefulputc.h
libuuid: add extern qualifiers to uuid/uuid.h system header
* 'renice' of git://github.com/kerolasa/lelux-utiliteetit:
renice: reorder usage() option descriptions
rename: add getpriority() message lookup table
renice: fix numeric uid argument parsing
renice: avoid having same lines of code twice
renice: disallow --priority <arg> without pid argument
rename: use usage and version print out macros
renice: reorder functions to avoid need of function prototype
swapon - requires libmount and libblkid
swapoff - requires libmount
swaplabel - requires libblkid
This patch add lib/swapprober.c with blkid stuff for swap. It allows
to use and link libblkid only when necessary.
Signed-off-by: Karel Zak <kzak@redhat.com>
Make the Usage: and Options: sections to be in same order, which I found
to be quicker to use than alphabetical order.
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
The following was inconflict with what usage() tells are valid option
arguments.
$ renice 1 -u 1000
renice: unknown user 1000
$ id
uid=1000(kerolasa) ...
Reviewed-by: Karel Zak <kzak@redhat.com>
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
Earlier a lonely priority with an argument but without pid resulted to no
action and success, when the invocation should have failed.
$ renice --priority 42 ; echo $?
0
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
Returning straight after print_devno() makes the code to be more obvious
and removes need for long else statement.
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
CppCheck founds a few wrong arguments in format strings and a NULL
pointer dereference.
Amended version with fixed strcmp() usage.
Signed-off-by: Boris Egorov <egorov@linux.com>
fef4dfa174 removed the restriction that the argument must explicitly be
a directory, so let's fix up the documentation to reflect that.
Signed-off-by: Karel Zak <kzak@redhat.com>
This code is not PIC clean which means it fails to build on hardened
32bit x86 systems (i.e. building as PIE).
While here, optimize the existing cpuid logic slightly.
URL: https://bugs.gentoo.org/518936
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
Use of --algorithm or --streams is not expected to work without
reseting device, that happens when --size is specified, so ensure the
former options to be combined with the later.
[kzak@redhat.com: - make it more generic]
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
Signed-off-by: Karel Zak <kzak@redhat.com>
Now it's possible to set UID and GID for user namespaces only. This
patch removes this restriction and allow to use --set{uid,gid} in all
cases. The default for user namespaces is still GID=0, UID=0.
Reported-by: Tomas Doran <bobtfish@bobtfish.net>
Signed-off-by: Karel Zak <kzak@redhat.com>
Also sort the options alphabetically, and use the standard comma
instead of the vertical bar to separate short from long option.
Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
This fixes the following compiler warning.
disk-utils/swaplabel.c:175:2: warning: implicit declaration of function
'get_swap_prober' [-Wimplicit-function-declaration]
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
Signed-off-by: Karel Zak <kzak@redhat.com>
The xiafs filesystem was removed from the kernel fifteen years ago,
and any kernel that contained it reached end of life ten years ago.
It's time to stop mentioning it in the mount man page and elsewhere.
Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
Also sort the command-line options alphabetically
(with the customary exception of -V and -h).
Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
Mainly more option sorting, some formatting adjustments, and the adding
of a missing --version here and there.
Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
* remove the huge and unmaintained list of filesystems, just keep
only very basic FS types in the man pages
* add info about command delimited lists to fstab.5
Signed-off-by: Karel Zak <kzak@redhat.com>
# mkfs.ext4 /dev/sda1
# mount -t foo,bar /dev/sda1 /mnt
successfully mount the device, this is unexpected as extN is no
between wanted (by -t specified) filesystems.
Summary about -t:
* "mount -t foo" mount(2) with "foo" type
* "mount -t foo,bar" try mount(2) with "foo" or "bar"
* "mount -t foo,auto" try mount(2) with "foo" or ask libblkid for
the type
* "mount -t nofoo,bar" try types from /{etc,proc}/filesystems, but
exclude "foo" and "bar"
Note that more filesystems may be specified in fstab (as comma
delimited list). The stuff from fstab is always interpreted as list
and never as a pattern ("no" prefix makes no sense in fstab).
Reported-by: Benno Schulenberg <bensberg@justemail.net>
Signed-off-by: Karel Zak <kzak@redhat.com>
The swapon(8) listing was almost complete, apart from label and uuid.
This change moves the code from swaplabel(8) to shared scope to be used
for printouts in other swap commands, such as swapon.
Adding this feature to lsblk(8) was a consideration, but lsblk is not
interested of swapfiles, so the swapon seems like a better option to add
this information.
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
Also, for chcpu, the options -c, -d, -e and -g are mutually exclusive,
and for the mode argument the option -p is not optional. For ldattach,
use the standard options separator ", " instead of the unusual " | ".
And add the missing --version to several of the pages. Besides, improve
the wording and the consistency of the spacing.
Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
Also, for renice, adapt the descriptions to the behaviour: the -g,
-p and -u options do not actually need to be followed by any ID.
Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
In the IPC man pages strictly adhere to the memory, queue, semaphore
order, to reduce disorientation. And for 'ipcmk', the arguments for
-M and -S and -p are not optional. Add --version for 'mountpoint'.
Signed-off-by: Benno Schulenberg <bensberg@justemail.net>