Karel Zak [Tue, 4 Feb 2025 09:10:57 +0000 (10:10 +0100)]
include/debug: Relicense to Public Domain
After reaching an agreement with Ondrej Oprala, we have decided to
change the license of debug.h and debugobj.h from LGPL to Public
Domain. This change is more suitable for the files in the include/
directory of util-linux.
CC: Ondrej Oprala <ondrej.oprala@gmail.com> Signed-off-by: Karel Zak <kzak@redhat.com>
Karel Zak [Tue, 4 Feb 2025 09:06:22 +0000 (10:06 +0100)]
Merge branch 'PR/Benno-text-fixes' of https://github.com/karelzak/util-linux-work
* 'PR/Benno-text-fixes' of https://github.com/karelzak/util-linux-work:
setpriv: describe --groups more correctly in the usage text
setpriv: consistently use "<caps>" to indicate a list of capabilities
readprofile: put two things that belong together into a single message
lsmem: make an error message identical to one used in seven other places
logger: grammarize the description of --socket-errors in the man page
The current check relies on "*sfile" to recognize if a configuration has
been found in the current directory. However this condition is only true
for "type == UL_COLORFILE_SCHEME", breaking the .enable and .disable
configurations.
Instead reorder the logic a bit so that any valid configuration returns
rc == 0.
Ricardo Neri [Fri, 31 Jan 2025 03:25:32 +0000 (19:25 -0800)]
lscpu: skip frequencies of 0 MHz when getting minmhz
read_mhz() sets cpu->mhz_min_freq from /sys/devices/system/cpu/cpuN/
cpufreq/cpuinfo_min_freq. The file read fails if cpuN is offline and
cpu->mhz_min_freq is left as 0. 0 MHz is treated as invalid frequency.
lsblk_cputype_get_minmhz() iterates through all possible CPUs to find the
minimum frequency. If one or more CPUs are offline, the minimum frequency
will be 0. This is reflected in the output of lscpu:
$ ./lscpu | grep min
CPU min MHz: 0.0000
Ignore 0-MHz frequencies to find the actual minimum frequency:
setpriv: consistently use "<caps>" to indicate a list of capabilities
The existing "<caps,...>" did not indicate that each capability name
must be preceded by "+" or "-". Also, to indicate that the list needs
to be separated by commas, one would have to use "<cap>[,...]", not
"<cap,...>". So... instead of trying to cram all that info in there,
just say "<caps>", like for --bounding-set.
Karel Zak [Mon, 3 Feb 2025 12:21:51 +0000 (13:21 +0100)]
Merge branch 'PR/mkswap-nocow' of https://github.com/karelzak/util-linux-work
* 'PR/mkswap-nocow' of https://github.com/karelzak/util-linux-work:
mkswap: remove unused variable for non-nocow systems
mkswap: add features list to --version output
mkswap: fix includes
mkswap: improve --file option for use on btrfs
Karel Zak [Mon, 3 Feb 2025 10:48:23 +0000 (11:48 +0100)]
mkswap: fix includes
It is preferable to use #ifdefs in code that relies on available
features, rather than solely depending on the presence of header
files. This is especially important if the functionality of FIEMAP
relies on multiple include files. Additionally, note that we also need
linux/fs.h for S_NOCOW_FL, regardless of FIEMAP.
Karel Zak [Mon, 3 Feb 2025 10:29:44 +0000 (11:29 +0100)]
dmesg: fix --notime use
The --notime command line option disables parsing of timestamps from
kmsg. This is a bug because the timestamps can be used for operations
other than just output. For example, they can be used for filters like
--since (dmesg --since '1 day ago' --notime).
Addresses: https://github.com/util-linux/util-linux/issues/3392 Signed-off-by: Karel Zak <kzak@redhat.com>
lscpu: make three column descriptions more grammatical
Change an adverb to an adjective, use the plural "lines",
and use the plural form of the verb "have". Also, put a
clarification between parentheses, and reshuffle it a bit
for clarity.
Generating all documentation (man pages, man page translations, and
library API docs) is a very time-consuming task. It is also
architecture-independent, as it involves text conversions using
Python, Ruby, etc. It would be better to only do this once in CI and
only when all other tasks have been successfully completed.
This commit also enables verbose output for autotools to make the
compiler command line visible in logs.
* Add V=1 (verbose) for "make" command.
* Add CONFIGUREFAST phase with disabled po-man, asciidoc, and gtk-doc.
* Use full version CONFIGURE phase only for the distcheck CI job.
Karel Zak [Mon, 27 Jan 2025 13:28:36 +0000 (14:28 +0100)]
libuuid: support non-cached scenarios (when -lpthread is unavailable)
This patch makes the dependence on pthread optional for libuuid. In
certain cases, such as Buildroot Linux, uClibc-ng, and very low
resource systems, libpthread may be unavailable.
If libuuid is compiled without pthread, it will not use a local cache
and will instead request a UUID from uuidd for each call. This may
result in less efficient performance, but the UUIDs generated will
still be unique and reliable.
On minimalistic systems, it is highly likely that uuidd will not be
installed, making this change important for portability and robust
code.
Addresses: https://github.com/util-linux/util-linux/pull/3375 Signed-off-by: Karel Zak <kzak@redhat.com>
AntonMoryakov [Thu, 16 Jan 2025 16:24:20 +0000 (19:24 +0300)]
setpriv.c: fix memory leak in parse_groups function
The static analyzer flagged a memory leak in the parse_groups function.
The memory allocated for 'buf' (via xstrdup) was not freed at the end
of the function, leading to a memory leak.
Changes:
- Added free(buf) at the end of the function to release allocated memory.
Triggers found by static analyzer Svace.
Signed-off-by: Anton Moryakov <ant.v.moryakov@gmail.com>
Karel Zak [Thu, 16 Jan 2025 12:14:43 +0000 (13:14 +0100)]
sulogin: fix POSIX locale use
In some cases, sulogin can set LC_CTYPE="POSIX" while retaining the
original LC_MESSAGES. In this scenario, the gettext() function may not
work as intended and sulogin returns "???" (for example for
ja_JP.UTF-8). GNU gettext FAQ:
This symptom occurs when the LC_CTYPE facet of the locale is not set;
then gettext() doesn't know which character set to use, and converts
all messages to ASCII, as far as possible.
Addresses: https://issues.redhat.com/browse/RHEL-56983
Addresses: https://github.com/util-linux/util-linux/issues/2185 Signed-off-by: Karel Zak <kzak@redhat.com>
This will allow the user to be created automatically and the scriptlets
to create the user and group dropped from the spec file:
https://fedoraproject.org/wiki/Changes/RPMSuportForSystemdSysusers
The config is equivalent to what the Fedora package does, i.e. a
dynamically-allocated uid and gid, and an account with nologin as the
shell.
Stanislav Brabec [Tue, 14 Jan 2025 21:09:11 +0000 (22:09 +0100)]
Add fuse.portal to list of pseudo file systems
Fixes output of findmnt --real (opensuse#1234736).
Reported-by: Stephan Wefing <wefing@gmx.de> Co-authored-by: Anthony Iliopoulos <ailiopoulos@suse.com> Signed-off-by: Stanislav Brabec <sbrabec@suse.cz>
AntonMoryakov [Tue, 14 Jan 2025 15:06:49 +0000 (18:06 +0300)]
sys-utils: fix add NULL check for mnt_fs_get_target return value
The static analyzer flagged a potential issue: the return value of
mnt_fs_get_target(fs) could be NULL, but it was dereferenced without
a check. This could lead to undefined behavior.
Added a NULL check before using the tgt pointer. If tgt is NULL,
the current iteration is skipped.
ChanChanges:
- Added if (!tgt) check before using tgt.
Signed-off-by: Anton Moryakov <ant.v.moryakov@gmail.com>
Mark Harfouche [Mon, 13 Jan 2025 23:07:20 +0000 (18:07 -0500)]
Include errno.h within lsfd.c
This is needed for ENOSYS to be defined
libgcc: 14.2.0
```
2025-01-13T22:59:57.1752408Z misc-utils/lsfd.c: In function 'kcmp':
2025-01-13T22:59:57.1762407Z misc-utils/lsfd.c:66:9: error: 'errno' undeclared (first use in this function)
2025-01-13T22:59:57.1762947Z 66 | errno = ENOSYS;
2025-01-13T22:59:57.1770931Z | ^~~~~
2025-01-13T22:59:57.1771263Z misc-utils/lsfd.c:40:1: note: 'errno' is defined in header '<errno.h>'; did you forget to '#include <errno.h>'?
2025-01-13T22:59:57.1771555Z 39 | #include <sys/syscall.h>
2025-01-13T22:59:57.1771767Z +++ |+#include <errno.h>
2025-01-13T22:59:57.1771955Z 40 |
2025-01-13T22:59:57.1772231Z misc-utils/lsfd.c:66:9: note: each undeclared identifier is reported only once for each function it appears in
2025-01-13T22:59:57.1772507Z 66 | errno = ENOSYS;
2025-01-13T22:59:57.1772684Z | ^~~~~
2025-01-13T22:59:57.1779860Z misc-utils/lsfd.c:66:17: error: 'ENOSYS' undeclared (first use in this function)
2025-01-13T22:59:57.1780285Z 66 | errno = ENOSYS;
2025-01-13T22:59:57.1780499Z | ^~~~~~
2025-01-13T22:59:57.2204441Z CC misc-utils/lsfd-lsfd-decode-file-flags.o
2025-01-13T22:59:57.2803898Z make[2]: *** [Makefile:13624: misc-utils/lsfd-lsfd.o]
```
When login is almost done it chdir()'s into the user's home directory.
It currently uses pwd->pw_dir, i.e the home dir actually assigned to the
user.
OTOH it explicitly allows overriding HOME (see comment in
init_environ()), and explicitly imports PAM's env vars (which quite
possibly contain $HOME) into its env block.
This patch makes sure that HOME is *properly* overridable via the env
var and via PAM: it actually honours it for the chdir().
(Background: I am working on a PAM module that under some conditions
would like to redirect the home dir to some other dir, and while I can
nicely set $HOME from the PAM module, it has not as much as effect as I
wish, because whie the rest of userspace respects it login so far didn't
and leaves the user in the wrong dir).
Karel Zak [Mon, 13 Jan 2025 11:06:23 +0000 (12:06 +0100)]
hardlink: fix memory corruption in read buffers
The size of the eq->buf_a and eq->buf_b buffers depends on the
readsize setting. This setting is modified by ul_fileeq_set_size(), so
the buffers need to be resized accordingly. Deallocating is
sufficient, as they will be allocated later with the correct size.
Addresses: https://github.com/util-linux/util-linux/issues/3330 Signed-off-by: Karel Zak <kzak@redhat.com>
Samuel Thibault [Sun, 12 Jan 2025 15:39:44 +0000 (16:39 +0100)]
Fix non-Linux build
This fixes non-Linux builds, by:
- making sfdisk discard option conditioned by availability of BLKDISCARD
- defining and using blkid_probe_get_buffer only if O_DIRECT is
available
- always building src/fs_statmount.c and src/tab_listmount.c, they
already contain proper conditions to make them void if support is not
available.
Signed-off-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
Karel Zak [Tue, 3 Dec 2024 17:56:41 +0000 (18:56 +0100)]
libmount: read all types of kernel messages
Previously, libmount only read error messages from fsopen() file
descriptor. This commit improves the library to read all messages
and keep them in their original format ("<type> <mesg>") in the library mount context.
Applications can now read all messages by using mnt_context_get_mesgs().
Furthermore, private functions have been implemented to include new
library-specific messages in the log. Currently, these messages are
only managed in mnt_context_get_excode(), but it would be beneficial
to relocate them to the appropriate locations where errors are
triggered.
In the future, mnt_context_get_excode() should only be utilized by
basic applications that require an one error message. For more
critical purposes (e.g. mount(8)), it will be recommended to utilize
the messages array.
The public function mnt_context_get_excode() has been modified to use
the new functionality and provide messages in a backwardly compatible
way.
Karel Zak [Mon, 11 Nov 2024 14:05:59 +0000 (15:05 +0100)]
findmnt: improve --help output
The current help output is quite lengthy. It would be beneficial to
organize it into sections, such as data sources, data filters, and
options. This would make it easier for users to navigate and
understand the available features.
Karel Zak [Mon, 11 Nov 2024 13:52:53 +0000 (14:52 +0100)]
findmnt: improve reliability of match testing
The "match" is defined if a string or void data is defined for the
matching function. It is necessary to test both variants instead of
relying solely on get_match(), which only returns string data.
This patch introduces the is_defined_match() macro to hide this detail
in the code and make it more readable.
Karel Zak [Mon, 23 Sep 2024 14:39:24 +0000 (16:39 +0200)]
libmount: improve fs->stmnt_done mask use
It is possible that one field in the libmnt_fs struct requires
fetching multiple statmount fields using multiple STATMOUNT_* mask
items. This requires changes to the way the fs->stmnt_done mask is
used.