Commit Graph

1196 Commits

Author SHA1 Message Date
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
Karel Zak 867df2617c lib: use ul_prefix for close_all_fds() and mkdir_p()
The names are too generic and it makes problems in static libraries.

Addresses: https://gitlab.com/cryptsetup/cryptsetup/-/issues/623
Signed-off-by: Karel Zak <kzak@redhat.com>
2021-01-28 10:27:21 +01:00
Karel Zak 0735d0efe1 lib/selinux-utils: tiny cleanup
Signed-off-by: Karel Zak <kzak@redhat.com>
2021-01-13 15:04:02 +01:00
Karel Zak e1de70b3c3 chfs-chfn: remove deprecated selinux_check_passwd_access()
Signed-off-by: Karel Zak <kzak@redhat.com>
2021-01-13 14:27:15 +01:00
Karel Zak b5debf7105 lib/selinux-utils: cleanup function names
Signed-off-by: Karel Zak <kzak@redhat.com>
2021-01-13 13:33:41 +01:00
Karel Zak 68f4aa2a2f build-sys: move selinux_utils.c
Signed-off-by: Karel Zak <kzak@redhat.com>
2021-01-13 13:30:31 +01:00
Karel Zak ca27216aa6 build-sys: remove fallback for security_context_t
It seems like overkill to provide this #ifdef. For example coreutils
use "char *" for all selinux contexts (since 2014).

Signed-off-by: Karel Zak <kzak@redhat.com>
2021-01-13 13:12:19 +01:00
Ville Skyttä 3c56068609 *: spelling and grammar fixes 2020-12-17 23:39:05 +02:00
Karel Zak e522815027 login-utils: don't use deprecated security_context_t
libselinux >= 3.1 makes security_context_t type deprecated. Let's
ifdef it to avoid unwanted warnings.

Signed-off-by: Karel Zak <kzak@redhat.com>
2020-12-14 15:54:08 +01:00
Karel Zak 96c8282584 login: fix compiler warning [-Werror=strict-prototypes]
Signed-off-by: Karel Zak <kzak@redhat.com>
2020-12-07 13:26:33 +01:00
Sami Kerola 07b12154dc
login: tidy up manual page
Add defaults to couple logindefs, and generally clean up  manual page a
little bit.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2020-12-03 20:09:15 +00:00
Sami Kerola a75700d86e
lib/fileutils: make close_all_fds() to be similar with close_range()
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>
2020-12-03 20:09:14 +00:00
Sami Kerola f0649c0d83
login: use close_range() system call when possible
This system call was added while back, but does not have glibc support yet.
Lets try to use the new facility early on.  The promise in reference link is
that the new call is faster, and works when /proc is not mounted.

Reference: https://lwn.net/Articles/789000/
Reference: https://lwn.net/Articles/789023/
Reference: https://kernelnewbies.org/LinuxChanges#Linux_5.9.New_close_range.28.29_system_call_for_easier_closing_of_file_descriptors
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2020-12-03 20:09:14 +00:00
Sami Kerola 931e60982e
login: move message printing out from main()
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2020-12-03 20:09:14 +00:00
Sami Kerola b04f183578
login: use xalloc memory allocation helpers everywhere
Apart two function calls login(1) already used xalloc functions.  If there
was a time when login tried to gracefully handle allocation errors that has
not been true for long time.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2020-12-03 20:07:30 +00:00
Sami Kerola 7679a2c5ca
login: fix coding style issues
Couple function had spaces instead of tabs in indent.  This change uses tabs
everywhere, and does handful of other spacing additions and removals.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2020-12-03 20:07:30 +00:00
Sami Kerola d515381901
login: use system definitions to determine maxium login name length
Allocating stack for about 10x more than longest possible user name is
wasteful, even if it happens for reletively short period of time.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2020-12-03 20:07:29 +00:00
Sami Kerola 5941a0db06
login: use calloc() when memory needs to be cleared
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2020-12-03 20:07:29 +00:00
Sami Kerola 0da0a5ed3b
login: use explicit_bzero() to get rid of confidental memory
Earlier code was most probably correct, but it is best to be safe than sorry
when dealing with confidental data removals.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2020-12-03 20:07:29 +00:00
Sami Kerola 5dd0896aa8
login: add initialize() function to have less stack allocated in main()
And move couple variables to the narrow scope they are used.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2020-12-03 20:07:28 +00:00
Sami Kerola 79a8afeb8f
login: replace function like definitions with inline functions
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2020-12-03 20:06:51 +00:00