Stanislav Brabec [Wed, 10 Oct 2018 17:26:34 +0000 (19:26 +0200)]
agetty: Reload only if it is really needed
If netlink event arrives and related escapes are part of issue, agetty
reloads and re-display the prompt. Reload is triggered not only by IP
address change, but also by IPv6 RAs. In some environments it causes
reload several times in a minute, and even complicates the login.
To prevent this, reload only if a real change appears.
This consists of:
split print_issue_file() to several functions:
eval_issue_file() prints issue to memory. It does not affect terminal in
any way.
print_issue_file() prints issue file from memory.
cmp_issue_file() compares the issue file and returns true, if reload is
needed.
The implementation requires additional change:
do_prompt() does not evaluate the issue file. It is responsibility of
calling function.
Test suite:
Use issue that contais \4 and/or \6 escape.
After installing new instance, restart agetty by typing a letter and then
Enter 6 times.
To check whether reload happens, type a letter. When reload happens,
letter disappears.
1. Unplug network cable. Wait a while and re-plug network cable.
You should see 2 reloads on single stack and 3 reloads on dual stack.
2. Run a loop
while : ; do
sed -i '$areload_test' /etc/issue
agetty --reload
sleep 3
sed -i '/reload_test/d' /etc/issue
agetty --reload
sleep 3
done
You should see regular reload every 3 seconds.
3. Run a loop
while : ; do
agetty --reload
sleep 3
done
Before: You see regular reload every 3 seconds.
After: No reloads.
4. Run a loop
while : ; do
ifconfig lo 127.0.0.1 netmask 255.0.0.0
sleep 3
ifconfig lo 127.0.0.2 netmask 255.0.0.0
sleep 3
done
Before: You see regular reload every 3 seconds.
After: No reloads.
Stanislav Brabec [Wed, 10 Oct 2018 17:26:21 +0000 (19:26 +0200)]
agetty: rename variable changed to triggered
changed variable name is not correct. It does not say that network
interface changed its address. It just says that the netlink message
processing was triggered.
rename: avoid undefined function prototype for `fpurge`
In case where the non-standard `fpurge` function is available, we
redefine `__fpurge` to `fpurge`. We can do so because the only
difference between both functions is that one returns an error code
while the other does not. But as we do not check the error code either
way, we do not care about which one of them we use.
The above redefinition happens unconditionally if we know that `fpurge`
exists. Most notably, we also redefine it if we already do have an
`__fpurge` function available that could be used. This causes problems
on musl-based platforms, where we detect availability of `fpurge` in
libc, but where no function declaration for it exists in "stdio_ext.h".
The compiler thus prints a warning due to an unknown function, even
though it will link just fine.
Avoid this warning by only redefining `__fpurge` to `fpurge` when
HAVE___FPURGE is not defined.
lsblk: fix unknown type `stat` caused by missing header
The structure `blkdev_cxt` has a `struct stat` member embedded, whose
size may not be known on some systems because of a missing include for
"sys/stat.h". On glibc-based systems, this header is included
transitively via "sys/statvfs.h", but on musl-based systems it is not.
Fix the resulting compile error due to unknown size of the struct by
including "sys/stat.h".
libfdisk/src/script.c: In function ‘fdisk_script_read_context’:
libfdisk/src/script.c:452:33: error: format ‘%zu’ expects argument of type ‘size_t’, but argument 4 has type ‘long unsigned int’ [-Werror=format=]
snprintf(buf, sizeof(buf), "%zu", fdisk_get_grain_size(cxt));
^
Karel Zak [Wed, 3 Oct 2018 12:39:57 +0000 (14:39 +0200)]
lsblk: always use "part" as TYPE for partitions
The current code uses "part" or "disk" only if nothing else is
possible to recognize. It means for example partitions on loops (or
RAIDs, etc) are marked as "loop" rather than "part".
Addresses: https://github.com/karelzak/util-linux/issues/700 Signed-off-by: Karel Zak <kzak@redhat.com>
Karel Zak [Mon, 17 Sep 2018 09:58:50 +0000 (11:58 +0200)]
libfdisk: count gaps to possible size when resize
The current code counts only partition sizes when it counts possible
space, but we have gaps between the partitions. It seems better to
count all based on offsets rather than sizes.
Addresses: https://github.com/karelzak/util-linux/issues/693 Signed-off-by: Karel Zak <kzak@redhat.com>
Karel Zak [Wed, 12 Sep 2018 11:18:08 +0000 (13:18 +0200)]
libfdisk: accept grain script header
The "grain" variable is used to calculate partitions alignment. The
default is 1MiB (or minimal I/O size). The libfdisk provides API to overwrite
this default, but this feature has been nowhere accessible for
end-user.
This patch support for "grain: <size>" in libfdisk scripts.
Addresses: https://github.com/karelzak/util-linux/issues/688 Signed-off-by: Karel Zak <kzak@redhat.com>
Karel Zak [Tue, 11 Sep 2018 11:42:52 +0000 (13:42 +0200)]
Merge branch 'more' of https://github.com/kerolasa/util-linux
* 'more' of https://github.com/kerolasa/util-linux:
more: rename functions
more: rename variable names
more: remove unnecessary ifdef preprosessor directives
more: do not call fileno() for std{in,out,err} streams
more: remove 'register' keywords
more: remove pointless functions
more: return is statement not a function
more: remove dead code and useless comments
Karel Zak [Tue, 11 Sep 2018 07:53:18 +0000 (09:53 +0200)]
lsblk: don't ask udev when --sysroot specified
We use --sysroot to get information about block devices from /proc and
/sys dumps. In this case does not make sense to read anything from
udev as udevd is about the current system devices.
Matti Niemenmaa [Mon, 10 Sep 2018 12:21:31 +0000 (15:21 +0300)]
fallocate: add missing semicolon
This broke compilation when HAVE_POSIX_FALLOCATE was undefined. The typo
dates to the original posix_fallocate support added in commit 833f9a7aae713278eec5f85266597482f18c7370.
Signed-off-by: Matti Niemenmaa <matti.niemenmaa+git@iki.fi>
Ludwig Nussel [Fri, 7 Sep 2018 07:47:25 +0000 (09:47 +0200)]
Add built in fallbacks for motd file
Use several locations for built in default for motd to allow for
e.g. run time generated motd without having to modify config files.
login.c already splits by colon.
/usr/share/misc/motd
- chould be shipped by distributions
/run/motd
- potentially run time created file with dynamic information
/etc/motd
- for the admin fill with local information
Signed-off-by: Ludwig Nussel <ludwig.nussel@suse.de>
Karel Zak [Tue, 4 Sep 2018 09:42:19 +0000 (11:42 +0200)]
build-sys: default to /lib64 for ${exec_prefix}/lib64
We already default to /lib for the default $exec_prefix, but the current
configure does not care about /lib64 although the use-case is exactly
same as for /lib.
Sami Kerola [Sun, 27 May 2018 16:29:09 +0000 (17:29 +0100)]
more: rename variable names
Try to make variable names to tell what they do. Earlier names have been in
more(1) since the command was first wrote, and it looks like coding
practices has changed since late 70's.
Sami Kerola [Sat, 26 May 2018 20:24:31 +0000 (21:24 +0100)]
more: remove 'register' keywords
One can only assume someone tried to make more(1) to run quicker. More up
to date assumption is that compilers are fully capable optimizing binaries
without these sort of hints.
Sami Kerola [Sat, 26 May 2018 19:08:34 +0000 (20:08 +0100)]
more: remove dead code and useless comments
Removal of STOP requires explanation. Looking unix-history-repo getline()
function in first BSD-3 version could return STOP. By next tag BSD-4 the
return STOP had disappeared. If I read this correctly that was a partial
removal, and second part has waited to be completed since 1980-11-16 when
BSD-4 was released.
Reference: https://github.com/dspinellis/unix-history-repo/blob/BSD-3-Snapshot-Development/usr/src/cmd/more.c#L501 Signed-off-by: Sami Kerola <kerolasa@iki.fi>
The patch uses uuid_unpack and uuid_pack. It makes code more readable
and allow to access proper octens. The same way we already use for
time and random based UUIDs.
Addresses: https://github.com/karelzak/util-linux/issues/683 Signed-off-by: Karel Zak <kzak@redhat.com>
Karel Zak [Thu, 23 Aug 2018 08:13:17 +0000 (10:13 +0200)]
libsmartcols: don't mark as extreme where average is zero
The columns with NOEXTREME flag are internally marked as extreme
(=contains extreme width) if maximal with is greater than 2 *
average_width. This detection has to sure that the average is non-zero
otherwise the column is always "extreme".
Karel Zak [Thu, 23 Aug 2018 08:02:49 +0000 (10:02 +0200)]
libsmartcols: allow to add line to table without columns
The table allows to add columns on the fly when lines already exist.
So, it does not make sense to reject request to add line to table
without columns.
Karel Zak [Wed, 22 Aug 2018 09:43:32 +0000 (11:43 +0200)]
setpriv: add --reset-env
Clear environment in way like su(1), but PATH is set to hard-coded
defaults and /etc/login.defs is not used at all (I guess we want to
keep setpriv(1) simple).
If you need anything more advanced than use env(1).
Addresses: https://github.com/karelzak/util-linux/issues/325 Signed-off-by: Karel Zak <kzak@redhat.com>
Karel Zak [Thu, 16 Aug 2018 14:16:40 +0000 (16:16 +0200)]
sulogin: restore signals after failed exec() only
* removes unnecessary variable
* the current code restores signals always when shell has not been
executed -- this is correct as function sushell() modify signal
mask, but in all another cases we do not need touch the mask.
Especially when we ask for the password in endless while() loop...
Karel Zak [Thu, 16 Aug 2018 13:43:53 +0000 (15:43 +0200)]
libmount: cleanup licenses sections in the files
* add SPDX-License-Identifier (see https://spdx.org/licenses/)
* add "This file part of libmount from util-linux project."
* use proper text for LGPL-2.1-or-later
* use the same texts everywhere
Karel Zak [Thu, 16 Aug 2018 12:47:21 +0000 (14:47 +0200)]
docs: use SPDX license names
Let's use standardized names for licenses. The names used by SPDX
makes things more obvious at first glance. For complete list see:
https://spdx.org/licenses/
Note, this commit does not change any license or so...