The code should be able to keep track about previous content and print
JSON objects separator automatically.
Signed-off-by: Karel Zak <kzak@redhat.com>
To build: meson build && ninja -C build
To run tests: ninja -C build check
To install for packaging: DESTDIR=/var/tmp/inst ninja -C build install
To install for realz: sudo ninja -C build install
v2:
- Optional items are now based on the 'feature' feature in meson.
Built libraries which are disabled turn into disabler() objects
and also poison any executables which link to them.
What is there:
- building of the binaries and libs and the python module
- installation of binaries, libs, python module, localization files,
man pages, pkgconfig files
- running of tests
- most options to configure build equivalently to the
./configure settings
Partially implemented:
- disabling of stuff when things missing. In the C code, the defines
are all used, so that should be fine. In the build system, some
files should be skipped, but that is probably not always done properly.
Getting this right might require some testing of various build option
combinations to get the details right.
Not implemented:
- static builds of fdisk and other binaries
- things marked with XXX or FIXME
- ???
Differences:
- .la files are not created. They are useless and everybody hates them.
- Requires.private in pkgconfig files are not present in the
autogenerated .pc file. Not sure if they should be there or not. If
necessary, they can be added by hand.
- man pages and systemd units are installed by the install target. Not
sure why 'make install' doesn't do that.
- the split between / and /usr is probably wrong. But it's all pointless
anyway, so maybe we could simplify things but not implementing it at
all under meson?
The current situation:
# su --pty - kzak
$ ll $(tty)
crw--w---- 1 root tty 136, 9 Feb 23 11:53 /dev/pts/9
$ mesg
mesg: cannot open /dev/pts/9: Permission denied
the pseudo-terminal is still owned by the original user.
New version:
# su --pty - kzak
# ll $(tty)
crw--w---- 1 kzak tty 136, 9 Feb 23 11:56 /dev/pts/9
# mesg
is y
The patch follows login(1) to change the pty owner and group. It
follows "TTYPERM" and "TTYGROUP" from login.defs (or econf lib).
Signed-off-by: Karel Zak <kzak@redhat.com>
Adapting tty eol settings from defaults misbehaves as CTRL('r') aka
REPRINT is confused with CR. Consequently --skip-login does not set
tty CR<->NL translations and thus acts against advertised CR as eol
default.
[kzak@redhat.com:
It seems this issue has been introduced by commit f566447 where we
merged sulogin and agetty terminal initialization together to the file
include/ttyutils.h.
The original agetty has really used .eol=13 (aka CR) for the default.
The problem is invisible for sulogin(1) because it always asks for a
password and .eol= is set to NL/CR, the same agetty when it asks for
username.]
Addresses: https://github.com/karelzak/util-linux/pull/1247
Signed-off-by: Karel Zak <kzak@redhat.com>
* 'gh-actions-bionic' of https://github.com/mrc0mmand/util-linux:
ci: run the build test for each pull request
ci: build both w/ and w/o sanitizers on GH Actions
ci: code cleanup
ci: deal with uninstrumented binaries using instrumented libs
text-utils: correctly detect ASan under clang
ci: use the correct compiler version
ci: 'downgrade' Ubuntu version to Bionic
* 'uclampset-v3' of https://github.com/qais-yousef/util-linux:
uclampset: Plumb in bash-completion
uclampset: Plump into the build system
uclampset: Add man page
Add uclampset schedutil
Move sched_attr struct and syscall definitions into header file
Utilization clamping is a new kernel feature that got merged in 5.3. It
allows controlling the performance of a process by manipulating the
utilization such that the task appears bigger or smaller than what it
really is.
There's a system-wide control to to restrict what maximum values the
process are allowed to use.
Man page added in a later patch attempts to explain the usage in more
detail.
Signed-off-by: Qais Yousef <qais.yousef@arm.com>
The util-linux close_all_fds() serves the same purpose as close_range()
that will over time obsolete local implementation completely. For
upcoming few years it is best to have a fallback that uses same input
arguments as the new system call. That allows surrounding code and
variables not to be affected by version of mass file descriptor closing
function.
Proposed-by: Karel Zak <kzak@redhat.com>
Reference: https://github.com/karelzak/util-linux/pull/1205#discussion_r534080128
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
The shells are very restrictive about variable names, only [:alnum:]
chars are allowed (and alphabetic chars as the first char). The
library will replace "bad" chars with "_". The char '%' at the end is
replaced by _PCT.
Addresses: https://github.com/karelzak/util-linux/issues/1201
Signed-off-by: Karel Zak <kzak@redhat.com>
* 'vipw-shortwrite' of https://github.com/DankRank/util-linux:
ul_copy_file: make defines for return values
read_all: return 0 when EOF occurs after 0 bytes
ul_copy_file: add test program
ul_copy_file: handle EAGAIN and EINTR
ul_copy_file: use all_read/all_write
ul_copy_file: use BUFSSIZ for buffer size
nologin: use ul_copy_file
login: use ul_copy_file
configure.ac: check for sendfile
ul_copy_file: use sendfile
vipw: move copyfile to the lib
vipw: fix short write handling in copyfile
Originally it would return -1 (without setting errno) if the fd was
already at EOF when you called read_all.
This is already fixed in sendfile_all.
Reviewed-by: Sami Kerola <kerolasa@iki.fi>
Signed-off-by: Egor Chelak <egor.chelak@gmail.com>
I did this by implementing a function called sendfile_all() similar to
read_all()/write_all().
The manpage for sendfile doesn't mention EINTR, but I decided to check
it anyway, just in case.
Suggested-by: Karel Zak <kzak@redhat.com>
Reviewed-by: Sami Kerola <kerolasa@iki.fi>
Signed-off-by: Egor Chelak <egor.chelak@gmail.com>
Also, a bug in pw_tmpfile was fixed: copyfile used tmp_file to report
errors, but pw_tmpfile only assigned that variable _after_ calling
copyfile.
Suggested-by: Sami Kerola <kerolasa@iki.fi>
Reviewed-by: Sami Kerola <kerolasa@iki.fi>
Signed-off-by: Egor Chelak <egor.chelak@gmail.com>
If a libuuid application is unable to access /dev/random or /dev/urandom
then uuid generation by uuid_generate falls back to uuid_generate_time.
This could happen in chroot or container environments.
The function ul_random_get_bytes from lib/randutils.c uses getrandom if
it is available. This could either mean that the libuuid application
skips good random bytes because the character special files do not exist
or the application trusts in good random bytes just because these files
are accessible but not necessarily usable, e.g. limit of open file
descriptors reached, lack of data, kernel without getrandom, etc.
This commit modifies ul_random_get_bytes to return an integer which
indicates if random bytes are of good quality (0) or not (1). Callers
can decide based on this information if they want to discard the random
bytes. Only libuuid checks the return value. I decided to return 1
instead of -1 because -1 feels more like an error, but weak random bytes
can be totally fine.
Another issue is that getrandom sets errno to specific values only in
case of an error, i.e. with return value -1. Set errno to 0 explicitly
if getrandom succeeds so we do not enter the fallback routine for
ENOSYS by mistake. I do not think that this is likely to happen, but it
really depends on possible wrapper function supplied by a C library.
Signed-off-by: Samanta Navarro <ferivoz@riseup.net>
The goal is to use it in libmount when generate options strings
and in libsmartcols to replace libscols_buffer.
Signed-off-by: Karel Zak <kzak@redhat.com>
* do not ignore all empty devices, we need more smart solution
* ignore only loop devices without backing file, for example:
# touch img
# losetup -f img
losetup: img: Warning: file is smaller than 512 bytes; the loop device may be useless or invisible for system tools.
- old version display nothing
- new version:
# lsblk /dev/loop0
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
loop0 7:0 0 0B 0 loop
Addresses: https://github.com/karelzak/util-linux/issues/1118
Signed-off-by: Karel Zak <kzak@redhat.com>
Permanently turn off current stdin ECHO when it is a terminal and enable setting slave ECHO instead.
Fix other minor typos, update documentation.
[kzak@redhat.com: - remove irrelevant changes
- keep --echo argument unchanged]
Signed-off-by: Karel Zak <kzak@redhat.com>
* 'fuzz' of https://github.com/evverx/util-linux:
tests: pack testcases into zip archives
tests: integrate test_last_fuzz into the testsuite
tests: add a fuzzer for process_wtmp_file
docs: mention OSS-Fuzz and CIFuzz and how to build fuzz targets locally
tools: make it possible to set all the fuzzing flags with config-gen
build-system: make "make distcheck" work
travis: set CXX correctly
travis: turn on --enable-fuzzing-engine
build-sys: add support for --enable-fuzzing-engine
tests: integrate test_mount_fuzz into the testsuite
tests: take exit codes into account
tests: add a fuzzer for mnt_table_parse_stream
Looks like those specifiers haven't been used since 6c9ab254ae
(where sscanf was removed) was merged. This should help to get
util-linux to compile with MSan. Currently it's failing with
```
...
configure: error: libmount selected, but required scanf string alloc modifier not available
...
configure:20240: ./conftest
==116617==WARNING: MemorySanitizer: use-of-uninitialized-value
#0 0x496fd6 in main /home/vagrant/util-linux/conftest.c:171:6
#1 0x7f5eb85ea1a2 in __libc_start_main (/lib64/libc.so.6+0x271a2)
#2 0x41c2cd in _start (/home/vagrant/util-linux/conftest+0x41c2cd)
SUMMARY: MemorySanitizer: use-of-uninitialized-value /home/vagrant/util-linux/conftest.c:171:6 in main
Exiting
configure:20240: $? = 77
...
configure:20265: $? = 0
configure:20265: ./conftest
MemorySanitizer: bad pointer 0x000000496e60
==116627==MemorySanitizer CHECK failed: /builddir/build/BUILD/compiler-rt-9.0.1.src/lib/msan/../sanitizer_common/sanitizer_allocator_secondary.h:177 "((IsAligned(reinterpret_cast<uptr>(p), page_size_))) != (0)" (0x0, 0x0)
#0 0x41d1d8 in MsanCheckFailed(char const*, int, char const*, unsigned long long, unsigned long long) (/home/vagrant/util-linux/conftest+0x41d1d8)
#1 0x484e1e in __sanitizer::CheckFailed(char const*, int, char const*, unsigned long long, unsigned long long) (/home/vagrant/util-linux/conftest+0x484e1e)
#2 0x42066c in __msan::MsanDeallocate(__sanitizer::StackTrace*, void*) (/home/vagrant/util-linux/conftest+0x42066c)
#3 0x424bc9 in free (/home/vagrant/util-linux/conftest+0x424bc9)
#4 0x496fae in main /home/vagrant/util-linux/conftest.c:173:2
#5 0x7f2245f311a2 in __libc_start_main (/lib64/libc.so.6+0x271a2)
#6 0x41c2cd in _start (/home/vagrant/util-linux/conftest+0x41c2cd)
configure:20265: $? = 77
configure: program exited with status 77
...
| }
configure:22568: result: no
configure:22926: error: libmount selected, but required scanf string alloc modifier not available
```
Signed-off-by: Evgeny Vereshchagin <evvers@ya.ru>