Commit Graph

15123 Commits

Author SHA1 Message Date
Karel Zak 17d5b26436 su: (pty) change owner and mode for pty
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>
2021-02-23 11:52:45 +01:00
Karel Zak 726ffb4a26 login: move generic setting to ttyutils.h
Signed-off-by: Karel Zak <kzak@redhat.com>
2021-02-23 11:46:10 +01:00
Karel Zak 497c61f7b0 su: explicitly enable echo for --pty
Since 75ccd75a2f we need to explicitly
set echo flag by ul_pty_slave_echo(pty, 1).

Signed-off-by: Karel Zak <kzak@redhat.com>
2021-02-23 11:37:15 +01:00
Karel Zak 8d720dbed6 fdisk: support partition type name in dialogs
Command (m for help): t

Selected partition 1
Partition type or alias (type L to list all): linux root x86
Changed type of partition 'Linux /usr (x86)' to 'Linux root (x86)'.

Signed-off-by: Karel Zak <kzak@redhat.com>
2021-02-23 09:25:57 +01:00
Karel Zak 45c2daa612 sfdisk: support for type="partition type name"
For example:

 # echo 'size=10MiB, type="linux usr x86"' | sfdisk /dev/sdc
 ...
 New situation:

 Device     Start   End Sectors Size Type
 /dev/sdc1   2048 22527   20480  10M Linux /usr (x86)

Signed-off-by: Karel Zak <kzak@redhat.com>
2021-02-23 09:25:36 +01:00
Karel Zak 5353ba3f0d libfdisk: support partition type name parsing
Add to fdisk_label_advparse_parttype() support for
FDISK_PARTTYPE_PARSE_NAME to parse partition type name.

Signed-off-by: Karel Zak <kzak@redhat.com>
2021-02-23 09:19:51 +01:00
Karel Zak 27e6b3a92e lib/strutils: add ul_stralnumcmp()
Signed-off-by: Karel Zak <kzak@redhat.com>
2021-02-23 09:19:48 +01:00
Karel Zak 3d28996517 build-sys: set localstatedir and sysconfdir default
Let's follow our policy for default directories and explicitly default
to localstatedir=/var and sysconfdir=/etc when the default $prefix is
used.

Reported-by: Bruce Dubbs <bruce.dubbs@gmail.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
2021-02-19 12:04:39 +01:00
Karel Zak 4f62b0b1dd readprofile: fix static analyzer warning [coverity scan]
Make sure we do not use step=0 and zero "fn_add - add0" as divisor.

Signed-off-by: Karel Zak <kzak@redhat.com>
2021-02-18 11:24:12 +01:00
Karel Zak 061e26d06d rfkill: fix static analyzer warning [coverity scan]
>>>     CID 365738:  Uninitialized variables  (UNINIT)
>>>     Using uninitialized value "ret". Field "ret" is uninitialized.
326             return ret;

Signed-off-by: Karel Zak <kzak@redhat.com>
2021-02-18 11:09:31 +01:00
Karel Zak 36c67e033e hardlink: fix typo in man page
Addresses: 3292501316 (commitcomment-47222034)
Signed-off-by: Karel Zak <kzak@redhat.com>
2021-02-18 10:48:47 +01:00
Karel Zak 296b58a79e libmount: (python) fix compiler warning
Signed-off-by: Karel Zak <kzak@redhat.com>
2021-02-17 12:25:49 +01:00
Karel Zak 71ba2792ab lib: use procutils.c on Linux only
Fixes: https://github.com/karelzak/util-linux/issues/1251
Signed-off-by: Karel Zak <kzak@redhat.com>
2021-02-17 12:24:13 +01:00
Karel Zak 5c7cac85c9 hardlink: fix indention
The original Julian's hardlink.c code is pretty readable, but for
util-linux we use a little different indention (aka Linux kernel
coding style).

Signed-off-by: Karel Zak <kzak@redhat.com>
2021-02-17 11:50:21 +01:00
Karel Zak 4bf9ebca2b tests: update hardlink tests
The important is result, not summary or verbose output.

Signed-off-by: Karel Zak <kzak@redhat.com>
2021-02-17 11:50:21 +01:00
Karel Zak 4c467ebc5c hardlink: add --quiet option
Signed-off-by: Karel Zak <kzak@redhat.com>
2021-02-17 11:50:21 +01:00
Karel Zak 3292501316 hardlink: cleanup man page
Signed-off-by: Karel Zak <kzak@redhat.com>
2021-02-17 11:50:21 +01:00
Karel Zak 5034cd9f2b hardlink: s/DEBUG/VERBOSE/
We usually use "debug" for very detailed information. For end-user
information is better to talk about "verbose" output.

Signed-off-by: Karel Zak <kzak@redhat.com>
2021-02-17 11:50:21 +01:00
Karel Zak 82e32c0659 hardlink: translate verbose messages
Signed-off-by: Karel Zak <kzak@redhat.com>
2021-02-17 11:50:21 +01:00
Karel Zak 053ef448a6 hardlink: cleanup summary
Signed-off-by: Karel Zak <kzak@redhat.com>
2021-02-17 11:50:21 +01:00
Karel Zak 423e80c1e9 hardlink: use size_to_human_string()
Signed-off-by: Karel Zak <kzak@redhat.com>
2021-02-17 11:50:21 +01:00
Karel Zak 3c52b1c83c hardlink: use only err.h to print errors and warnings
Signed-off-by: Karel Zak <kzak@redhat.com>
2021-02-17 11:50:21 +01:00
Karel Zak 06d8fe8909 hardlink: use monotonic time like other utils
- use out gettime_monotonic()
- use timeval for calculation rather than double

Signed-off-by: Karel Zak <kzak@redhat.com>
2021-02-17 11:50:21 +01:00
Karel Zak ec194114e1 hardlink: use errx() when parse options
Don't waste time with some cleanup on --exclude and --include regex
errors.

Signed-off-by: Karel Zak <kzak@redhat.com>
2021-02-17 11:50:21 +01:00
Karel Zak c12b639443 hardlink: use err() if possible
Signed-off-by: Karel Zak <kzak@redhat.com>
2021-02-17 11:50:21 +01:00
Karel Zak 631e6865e3 hardlink: cleanup --minimum-size stuff
* use uintmax_t
* use strtosize_or_err()
* add info about suffixes to man page

Signed-off-by: Karel Zak <kzak@redhat.com>
2021-02-17 11:50:21 +01:00
Karel Zak 9e7235e7e0 hardlink: move default to options initialization
Signed-off-by: Karel Zak <kzak@redhat.com>
2021-02-17 11:50:21 +01:00
Karel Zak d2c3c5a684 hardlink: cleanup usage()
Let's make --help more util-linux compatible.

Signed-off-by: Karel Zak <kzak@redhat.com>
2021-02-17 11:50:21 +01:00
Karel Zak 0361f7440c hardlink: use our xalloc.h
Signed-off-by: Karel Zak <kzak@redhat.com>
2021-02-17 11:50:21 +01:00
Karel Zak 40b119b990 hardlink: check and use sys/xattr.h
Signed-off-by: Karel Zak <kzak@redhat.com>
2021-02-17 11:50:21 +01:00
Karel Zak 43989bad9e hardlink: use PRCE2 posix header file
Signed-off-by: Karel Zak <kzak@redhat.com>
2021-02-17 11:50:21 +01:00
Karel Zak cd6b8d3926 hardlink: cleanup includes and types
* use config.h like other code on package
* use c.h and remove from code stuff defined in the header file
* remove FALSE/TRUE redefinition

Signed-off-by: Karel Zak <kzak@redhat.com>
2021-02-17 11:50:21 +01:00
Karel Zak 2180ecc81b hardlink: replace with code from Debian
The current version used in util-linux is based on original code from
Jakub Jelinek.

The new version is based on Debian implementation from
https://salsa.debian.org/jak/hardlink.  This new version uses nftw()
to walk on directories tree and organize internal data binary tree
(tsearch() and twalk()). This new version provides more features like
--ignore-{mode,owner,time}, --respect-xattrs, --respect-name,
--include, --keep-oldest, --minimize, --maximize, etc.

Note that the new version uses -f for --respect-name, the old version
uses -f to hardlinking across filesystems (very probably rarely unused
feature).

Addresses: https://github.com/karelzak/util-linux/issues/808
Signed-off-by: Karel Zak <kzak@redhat.com>
2021-02-17 11:50:21 +01:00
Evgeny Vereshchagin a7c22c164b ci: trigger CiFuzz for the master branch only
CIFuzz and OSS-Fuzz are in sync with the master branch so it would
probably make sense to avoid running it for long-lived branches.

Inspired by https://github.com/karelzak/util-linux/pull/1248#issuecomment-776342252

Signed-off-by: Evgeny Vereshchagin <evvers@ya.ru>
2021-02-15 13:25:19 +00:00
Karel Zak 15a37d00e5 tests: don't reply on scsi_debug partitions
The disk layout as created by scsi_debug depends on kernel version.
Let's make the partition sizes hardcoded in our tests than rely on
kernel.

Signed-off-by: Karel Zak <kzak@redhat.com>
2021-02-11 12:44:44 +01:00
Karel Zak e1efda47dd libfdisk: (dos) fix last possible sector calculation
* rename 'last' to 'first' as we use this value as the first available free
  sector rather than last used

* use '-1' when calculate last partition sector to compare with last
  disk sector

* improve debug messages

Fixes: https://github.com/karelzak/util-linux/issues/1249
Signed-off-by: Karel Zak <kzak@redhat.com>
2021-02-11 12:18:34 +01:00
Sami Loone ee978576b1 agetty: tty eol defaults to REPRINT
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>
2021-02-10 17:48:46 +01:00
Karel Zak 78d43728b1 Merge branch 'switch_root-check-if-mounted' of https://github.com/Whissi/util-linux 2021-02-10 10:52:16 +01:00
Karel Zak c3a6350335 tests: be explicit with file permissions for cramfs
Signed-off-by: Karel Zak <kzak@redhat.com>
2021-02-09 18:02:13 +01:00
Karel Zak b6787fca02 libmount: fix /{etc,proc}/filesystems use
* always update context->helper
* consolidate helper and syscall status use

Signed-off-by: Karel Zak <kzak@redhat.com>
2021-02-09 10:36:04 +01:00
Thomas Deutschmann 037c7816ce
switch_root: check if mount point to move even exists
Signed-off-by: Thomas Deutschmann <whissi@gentoo.org>
2021-02-08 15:35:07 +01:00
Karel Zak d4b5887354 build-sys: add --disable-scriptutils
This new ./configure option disables script, scriptreplay ans
scriptlive.

Fixes: https://github.com/karelzak/util-linux/issues/1244
Signed-off-by: Karel Zak <kzak@redhat.com>
2021-02-08 15:01:33 +01:00
Karel Zak f458782f14 libsmartcols: remove unnecessary code
Fixes: https://github.com/karelzak/util-linux/pull/1243
Signed-off-by: Karel Zak <kzak@redhat.com>
2021-02-08 14:47:38 +01:00
Karel Zak 56fc4adac9 github: fix distcheck job
Signed-off-by: Karel Zak <kzak@redhat.com>
2021-02-05 15:21:56 +01:00
Karel Zak 63900c506b github: add 'distcheck' workflow job
Signed-off-by: Karel Zak <kzak@redhat.com>
2021-02-05 15:03:49 +01:00
Karel Zak ec89bec1cd Merge branch 'gh-actions-bionic' of https://github.com/mrc0mmand/util-linux
* '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
2021-02-05 10:29:26 +01:00
Karel Zak 0edc239542 build-sys: fix schedutils/sched_attr.h include
Signed-off-by: Karel Zak <kzak@redhat.com>
2021-02-05 10:23:04 +01:00
Karel Zak 9c7a613c82 login: use full tty path for PAM_TTY
pam_set_item() man page:
 PAM_TTY
   The terminal name: prefixed by /dev/ if it is a device file;
   for graphical, X-based, applications the value for this item
   should be the $DISPLAY variable.

It seems for example pam_timestamp module is not robust enough to
differentiate between /dev/ and pty/0 and it assumes that '/' in the
path always means '/dev/' prefix ...

Fixes: https://github.com/karelzak/util-linux/issues/1242
Signed-off-by: Karel Zak <kzak@redhat.com>
2021-02-03 14:49:09 +01:00
Karel Zak 6165376737 su: use full tty path for PAM_TTY
pam_set_item() man page:
 PAM_TTY
   The terminal name: prefixed by /dev/ if it is a device file;
   for graphical, X-based, applications the value for this item
   should be the $DISPLAY variable.

It seems for example pam_timestamp module is not robust enough to
differentiate between /dev/ and pty/0 and it assumes that '/' in the
path always means '/dev/' prefix ...

Fixes: https://github.com/karelzak/util-linux/issues/1242
Signed-off-by: Karel Zak <kzak@redhat.com>
2021-02-03 14:45:15 +01:00
Karel Zak 82643a9be5 build-sys: cleanup uclampset dependencies
chrt requires sched_setattr() or sched_setscheduler(), the both is
covered by have_schedsetter variable in ./configure.ac. This variable
is useless for uclampset, because it requires sched_setattr(). Let's
make it more explicit for uclampset.

Signed-off-by: Karel Zak <kzak@redhat.com>
2021-02-02 16:54:33 +01:00