Commit Graph

1216 Commits

Author SHA1 Message Date
Karel Zak 08273c672b su: reset also RLIMIT_FSIZE and RLIMIT_NOFILE
Addresses: https://github.com/linux-pam/linux-pam/issues/85
Signed-off-by: Karel Zak <kzak@redhat.com>
2021-10-04 15:39:40 +02:00
Karel Zak e549619122 su: reset RLIMIT_{NICE,RTPRIO} to zero
Addresses: https://github.com/linux-pam/linux-pam/issues/85
Reported-by: Lennart Poettering <lennart@poettering.net>
Signed-off-by: Karel Zak <kzak@redhat.com>
2021-10-01 14:59:50 +02:00
Mario Blättermann e674323904 Man pages: Fix end extend formatting 2021-09-21 20:48:11 +02:00
Karel Zak 5cc37e883e Revert "sulogin: fix getpasswd()"
This patch is unnecessary in the master branch.

This reverts commit 2d8a9fcee2.

References: https://github.com/karelzak/util-linux/issues/1400
2021-07-30 14:16:03 +02:00
Karel Zak 2d8a9fcee2 sulogin: fix getpasswd()
Fixes: https://github.com/karelzak/util-linux/issues/1400
Signed-off-by: Karel Zak <kzak@redhat.com>
2021-07-29 21:29:18 +02:00
Karel Zak 2605d88379 vipw: use snprintf() rather than sprintf() 2021-07-27 13:30:14 +02:00
Karel Zak a6d7f918ac logindefs: use snprintf() rather than sprintf() 2021-07-27 13:30:01 +02:00
Karel Zak 79fb7e18f4 last: use snprintf() rather than sprintf() 2021-07-27 13:29:36 +02:00
Karel Zak 8344a81f7a lslogins: fix memory leak [asan]
Signed-off-by: Karel Zak <kzak@redhat.com>
2021-07-22 11:34:11 +02:00
Karel Zak 21ee5ef448 lslogins: ask for supplementary groups only once [asan]
Signed-off-by: Karel Zak <kzak@redhat.com>
2021-07-22 11:30:22 +02:00
Karel Zak 31d730eb77 lslogins: use sd_journal_get_data() in proper way
man sd_journal_get_data:
    The returned data is in a read-only memory map and is only valid until the next invocation
    of sd_journal_get_data().

It means that use data after 3x sd_journal_get_data() is really bad
idea. It also seems better to not assume the fields are zero
terminated as journal API works with void* and size_t to address the
data.

Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=1984704
Signed-off-by: Karel Zak <kzak@redhat.com>
2021-07-22 11:09:10 +02:00
Karel Zak cae071ed72 login: add callback for close_range()
Let's make it more robust for old kernels where is no close_range() or
in cases when it's unsuccessful.

Reported-by: Florian Weimer <fweimer@redhat.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
2021-07-15 12:51:39 +02:00
Karel Zak 913829559b lslogins: consolidate and optimize utmp files use
* the original read_utmp() code is from GPLv3+, but lslogins is GPLv2+
  (see a6bf40ee77 (commitcomment-53407151))

* remove redundant parse_btmp() and parse_wtmp() as it does not
  provide anything

* reduce realloc() calls, allocate all in one step

Signed-off-by: Karel Zak <kzak@redhat.com>
2021-07-15 12:24:07 +02:00
Karel Zak b8d99a618b login: fix close_range() use
This new syscall comes with three arguments (see kernel commit
278a5fbaed89dacd04e9d052f4594ffd0e0585de). Not sure why util-linux
assume only two.

Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=1981729
Signed-off-by: Karel Zak <kzak@redhat.com>
2021-07-14 17:25:57 +02:00
Karel Zak 55cbb788f8 utmpdump: do not use atoi()
Addresses: https://github.com/karelzak/util-linux/issues/1358
Signed-off-by: Karel Zak <kzak@redhat.com>
2021-06-22 17:04:24 +02:00
Karel Zak 2fc2bb7ebd lslogins: check errno after strto..()
Addresses: https://github.com/karelzak/util-linux/issues/1356
Signed-off-by: Karel Zak <kzak@redhat.com>
2021-06-21 15:31:43 +02:00
Karel Zak d3f77b4b8b sulogin: add missing ifdefs
Signed-off-by: Karel Zak <kzak@redhat.com>
2021-06-16 15:44:02 +02:00
Karel Zak 286865bf7e sulogin: use explicit_bzero() for buffer with password
Reported-by: Jan Pazdziora <jpazdziora@redhat.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
2021-06-16 15:39:32 +02:00
Karel Zak 59e2df8fe8 login: remove obsolete and confusing comment
Reported-by: Jan Pazdziora <jpazdziora@redhat.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
2021-06-16 15:13:50 +02:00
Karel Zak 777fe9f512 newgrp: fix memory leak [coverity scan]
Signed-off-by: Karel Zak <kzak@redhat.com>
2021-06-11 15:10:22 +02:00
Karel Zak 419861d5bf sulogin: fix whitespace error
Signed-off-by: Karel Zak <kzak@redhat.com>
2021-05-24 13:39:53 +02:00
Werner Fink 0d092db5c4 sulogin: ignore none-existing console devices
and also none-functional console devices. Redirect the error
messages to the appropiate console device.

Signed-off-by: Werner Fink <werner@suse.de>
2021-05-24 13:39:53 +02:00
Christian Hesse e08e3d587c fix whitespace issue in ducumentation
This removes trailing whitespaces and fixes minor issues.
2021-05-10 15:53:50 +02:00
Karel Zak d8d54e4bfc build-sys: keep adoc files in dist_noinst_DATA
* rename MANPAGES_EXTRA= to ADOCFILES_COMMON=

* keep track about individual adoc files by dist_noinst_DATA=
  This variable is not effected by automake conditions, so the files
  are always distributed.

Signed-off-by: Karel Zak <kzak@redhat.com>
2021-05-05 13:35:30 +02:00
Karel Zak e51c9822a9 lslogins: non-Linux fix
Reported-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
Signed-off-by: Karel Zak <kzak@redhat.com>
2021-04-12 16:20:01 +02:00
Karel Zak 625e9c61e8 build-sys: make man pages location independent
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>
2021-03-31 11:50:47 +02:00
Karel Zak 25ce8fb1ed Merge remote-tracking branch 'mariobl/topic/asciidoc'
* mariobl/topic/asciidoc: (71 commits)
  Asciidoc: Update .pot template
  Asciidoc: Reorder example command sequence
  Asciidoc: Update .pot template
  Asciidoc: Better gettext message splitting in nsenter.1.adoc
  Asciidoc: Update .pot template
  Asciidoc: Fix typo and remove invisible spaces which confuse po4a
  Asciidoc: Update .pot template
  Asciidoc: Fix typo
  Asciidoc: Fix artifact from initial import, sixth attempt
  Asciidoc: Update .pot template
  Asciidoc: Fix artifacts from initial import, fifth attempt
  Asciidoc: Fix artifacts from initial import, fourth attempt
  Asciidoc: Update .pot template
  Asciidoc: Fix artifacts from initial import, third attempt
  Asciidoc: Fix artifacts from initial import, second attempt
  Asciidoc: Fix artifacts from initial import
  Asciidoc: Add po4a config file and initial translation template for man pages
  Asciidoc: Small indentation fix in mount.8.adoc
  Asciidoc: Review sys-utils man pages, part 2
  build-sys: fix out-of-tree build
  ...

Signed-off-by: Karel Zak <kzak@redhat.com>
2021-03-29 15:09:27 +02:00
Mario Blättermann 544e64e09e Asciidoc: Fix typo and remove invisible spaces which confuse po4a 2021-03-28 10:47:00 +02:00
Mario Blättermann b53360d8a8 Asciidoc: Fix artifacts from initial import 2021-03-26 20:12:42 +01:00
Karel Zak ad67a438cf build-sys: fix typo
Signed-off-by: Karel Zak <kzak@redhat.com>
2021-03-26 11:57:07 +01:00
Karel Zak 4f79d3032e build-sys: split man pages and man page links
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>
2021-03-26 11:49:59 +01:00
Karel Zak c2096885af build-sys: remove man page link files
It seems asciidoctor generates all necessary files.

Signed-off-by: Karel Zak <kzak@redhat.com>
2021-03-26 11:26:08 +01:00
Karel Zak bdda0dc051 build-sys: remove duplicate hook
Signed-off-by: Karel Zak <kzak@redhat.com>
2021-03-26 10:31:29 +01:00
Mario Blättermann 62fde24f47 Asciidoc: Review login-utils man pages 2021-03-24 20:01:34 +01:00
Mario Blättermann f42ed8190c Asciidoc: Unify spelling of »User Commands« 2021-03-21 10:00:16 +01:00
Mario Blättermann 295b3979d9 Asciidoc: Add Po4a hint to file headers 2021-03-20 16:42:47 +01:00
Mario Blättermann d315cc4d96 Asciidoc: Re-add empty lines to man pages 2021-03-19 20:52:00 +01:00
Mario Blättermann 4d29743519 Asciidoc: Some formatting cleanup in man pages 2021-03-19 18:25:50 +01:00
Mario Blättermann a48b5068a7 Asciidoc: Remove already imported login-utils *roff man pages 2021-03-17 20:00:15 +01:00
Mario Blättermann a7574d8878 Asciidoc: Import login-utils man pages 2021-03-17 19:57:15 +01:00
Zbigniew Jędrzejewski-Szmek d4c880d5a4 meson: add second build system
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?
2021-03-17 15:07:27 +01:00
Andrew Shapiro f3a7b057ac utmpdup: Ensure flushing when using follow flag
The following usages of utmpdump result in no output being flushed to the specified file because the default output buffering is fully buffered:

$ utmpdump --follow --output myOutputFile /var/log/utmp
$ utmpdump --follow /var/log/utmp > myOutputFile

This change configures line buffering for these scenarios so that output will be flushed after each log event.

Signed-off-by: Andrew Shapiro <anshapiro@gmail.com>
2021-03-02 10:49:53 +01:00
Štěpán Němec 3d0620a9a8 su: fix man page typos
Signed-off-by: Štěpán Němec <snemec@redhat.com>
2021-02-25 09:34:30 +01:00
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 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 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
Frantisek Sumsal 81edf9f0da ci: deal with uninstrumented binaries using instrumented libs
All `eject` tests were failing under ASan, since they call /bin/mount,
which is uninstrumented, but it picks up the instrumented `libblkid`
library, causing ASan to complain:

gcc:
ASan runtime does not come first in initial library list; you should either link runtime to your application or manually preload it with LD_PRELOAD.
eject: unmount of `/home/runner/work/util-linux/util-linux/tests/output/eject/umount-by-disk-mounted-mnt' failed

clang:
/bin/umount: symbol lookup error: /home/runner/work/util-linux/util-linux/.libs/libblkid.so.1: undefined symbol: __sancov_lowest_stack
eject: unmount of `/home/runner/work/util-linux/util-linux/tests/output/eject/umount-by-disk-mounted-mnt' failed

Subsequently, all tests which require the `scsi_debug` module get skipped,
since it's still in use due to the failed umount:

fdisk: align 512/4K                   ... SKIPPED (cannot remove scsi_debug module (rmmod))
fdisk: align 512/4K +alignment_offset ... SKIPPED (cannot remove scsi_debug module (rmmod))
fdisk: align 512/4K +MD               ... SKIPPED (cannot remove scsi_debug module (rmmod))

In case of gcc this can be easily resolved by setting $LD_PRELOAD to the
respective ASan library. clang makes this a bit more difficult, since it
compiles the ASan library statically, so firstly we need to force dynamic
linking (via -shared-asan), and then add the runtime DSO path to the
linker cache, since it's in a non-standard path.
2021-02-01 12:00:30 +01:00