The current implementation of the function does not care if the device
is whole-disk device or partition, all is loopdev. This is regression
as the original is_loopdev() version was based on whole-disk devices
major numbers only.
Fixes: https://github.com/karelzak/util-linux/issues/1202
Signed-off-by: Karel Zak <kzak@redhat.com>
We need to evaluate "include::" directive relatively to project
top-level source directory rather than to the current document
location.
Signed-off-by: Karel Zak <kzak@redhat.com>
The symlinks are generated by asciidoctor and current dist_man_MANS
depends on order (nan page before man link). This solutions is useless
when execute "make -j". The real solution is to keep man pages in
separate variable and use only this variable evaluate what we need to
generate.
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?
noinst_LTLIBRARIES causes the libraries to be always built
unconditionally. EXTRA_LTLIBRARIES causes them to be built
only if other build target needs them.
In other words, avoid building libcommon.a and libtcolors.a
unless they are needed by another library/executable and
save some build time.
https://www.gnu.org/software/automake/manual/html_node/Libtool-Convenience-Libraries.html
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>
It seems the current kernel can create a loop devices with a different
major number. For example
# losetup /dev/loop12345678 file.img
# lsblk /dev/loop12345678
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
loop12345678 15:811342 0 5M 0 loop
We need a way how to verify the device is loopdev also when the device is
not associated with any backing file -- in this case there is no "loop"
directory in /sys/dev/block/<maj:min>/, but we can cannonicalize this sysfs
symlink as it points to /sys/devices/virtual/block/loop<n> (see "loop" in
the path).
Note that without this change losetup is not able to list and delete
the loop device.
Addresses: https://github.com/karelzak/util-linux/issues/1202
Signed-off-by: Karel Zak <kzak@redhat.com>
This patch add support to format multi-line cells (columns with
SCOLS_FL_WRAP) to arrays in JSON output.
For example mountpoints[] in lsblk output:
Normal output:
$ lsblk -oNAME,FSTYPE,TYPE,MOUNTPOINTS /dev/sdc1
NAME FSTYPE TYPE MOUNTPOINTS
sdc1 btrfs part /mnt/A
/mnt/test
/mnt/B
JSON output:
$ lsblk -J -oNAME,FSTYPE,TYPE,MOUNTPOINTS /dev/sdc1
{
"blockdevices": [
{
"name": "sdc1",
"fstype": "btrfs",
"type": "part",
"mountpoints": [
"/mnt/A",
"/mnt/test",
"/mnt/B"
]
}
]
}
Signed-off-by: Karel Zak <kzak@redhat.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>
* w45:
fdformat: remove command from default build
more: improve error messaging when input file is directory
ul: make set_column() zero check more obvious
colrm: fix argument parsing
rfkill: stop execution when rfkill device cannot be opened
cifuzz: reindent yaml file
man: make tilde and caret characters to render correctly
Let's split the code to make it possible to test separately bsearch as
well as procfs based cap_last_cap().
$ ./test_caputils --last-by-bsearch
last cap: 39
$ ./test_caputils --last-by-procfs
last cap: 39
$ ./test_caputils --last
last cap: 39
Signed-off-by: Karel Zak <kzak@redhat.com>
* add delay between attempts
* zeroize errno and check for EAGAIN (like in other code)
* add small test program
./test_procutils --is-procfs [<dir>]
Signed-off-by: Karel Zak <kzak@redhat.com>
The file is simple list of signal names and trivial function to search
in the list. We do not need any extra license here and as public
domain it will be more portable to other tools (GPL and BSD) in the
util-linux.
All previous contributors (Sami, Niklas and me) agree with this change.
Signed-off-by: Karel Zak <kzak@redhat.com>
This allows the rest of the programs using cap_last_cap to trust the
value returned by it, since it will either be obtained from procfs
(straight from kernel) or with prctl.
Also checked if the file under /proc is actually mounted in a procfs.
As mentioned in 'Generating optimal glyphs' title in the manual page
mentioned in reference:
Where a proper caret (^) that renders well in both a terminal and PDF is
required, use "\(ha".
Using a naked "~" character results in a poor rendering in PDF. Instead
use "\(ti".
Reference: https://man7.org/linux/man-pages/man7/man-pages.7.html#STYLE_GUIDE
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* '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
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>
Do note that according to man sendfile, "Other UNIX systems implement
sendfile() with different semantics and prototypes."
If this is something we care about, a better check is needed.
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>