Commit Graph

1197 Commits

Author SHA1 Message Date
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
Sami Kerola fb038d27a1
login: move getlogindefs_num() after localization init
There are translations in getlogindefs_num() and they will not take effect
unless the function call is after the setlocale(), bindtextdomain(), and
textdomain().

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2020-12-03 20:06:51 +00:00
Sami Kerola 0b4d75fae5
login: move timeout from global to local scope
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2020-12-03 20:06:47 +00:00
Sami Kerola bfcba3f586
login: stop keeping timeout message in memory forever
When the timeout is cancelled the message can be removed from memory.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2020-12-03 19:54:29 +00:00
Sami Kerola 42ccc9cfb4
login: use sig_atomic_t type for variable accessed from signal handler
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2020-12-03 19:54:29 +00:00
Karel Zak cd588d6653 fuzzers: make tests setup more robust
- use robust functions like write_all()
- don't use assert() to check write/open/etc return values, because oss-fuzz.com
  report foreign (system, libc, ...) issues as our fails

Addresses: https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=28009
Signed-off-by: Karel Zak <kzak@redhat.com>
2020-12-01 11:35:02 +01:00
Karel Zak 30e8df968f lslogins: call close() for usable FD [coverity scan]
Signed-off-by: Karel Zak <kzak@redhat.com>
2020-11-25 14:02:11 +01:00
Karel Zak 57b74b0dcb Merge branch 'w45'
* 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
2020-11-20 12:01:22 +01:00
Pino Toscano 5547316c85 build-sys: do not build plymouth-ctrl.c w/ disabled plymouth
Do not build plymouth-ctrl.c in agetty and sulogin in case the plymouth
support is disabled.

Signed-off-by: Pino Toscano <toscano.pino@tiscali.it>
2020-11-17 11:27:48 +01:00
Sami Kerola 3ea54b843c
man: make tilde and caret characters to render correctly
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>
2020-11-14 15:22:34 +00:00
Karel Zak bb123ad503 Merge branch 'vipw-shortwrite' of https://github.com/DankRank/util-linux
* '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
2020-11-09 11:06:27 +01:00
Egor Chelak cabbf61fab ul_copy_file: make defines for return values
Suggested-by: Sami Kerola <kerolasa@iki.fi>
Signed-off-by: Egor Chelak <egor.chelak@gmail.com>
2020-11-09 07:20:14 +02:00
Egor Chelak 9203b41a4f nologin: use ul_copy_file
Suggested-by: Sami Kerola <kerolasa@iki.fi>
Reviewed-by: Sami Kerola <kerolasa@iki.fi>
Signed-off-by: Egor Chelak <egor.chelak@gmail.com>
2020-11-09 07:19:24 +02:00
Egor Chelak 8fcdbefb7b login: use ul_copy_file
Suggested-by: Karel Zak <kzak@redhat.com>
Reviewed-by: Sami Kerola <kerolasa@iki.fi>
Signed-off-by: Egor Chelak <egor.chelak@gmail.com>
2020-11-09 07:19:15 +02:00
Egor Chelak b9dcd38462 vipw: move copyfile to the lib
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>
2020-11-09 07:18:42 +02:00
Egor Chelak 1b10fa0ef7 cast NULL to char * when using execl
When calling variadic functions, NULL must be explicitly cast to a
desired type.
This is noted in the exec(3) manpage.

The call in newgrp.c was changed for consistency.

Signed-off-by: Egor Chelak <egor.chelak@gmail.com>
2020-10-29 19:49:07 +02:00
Egor Chelak 12235ef107 vipw: fix short write handling in copyfile
Since `off` and `nr` approach each other, the for-loop ends prematurely
when at least half of the buffer was written.  I think under certain
conditions this could cause the copy to be incomplete.

Signed-off-by: Egor Chelak <egor.chelak@gmail.com>
2020-10-29 19:06:13 +02:00
Sami Kerola c60c65c37e login: close() only a file descriptor that is open [coverity scan]
CID: 360819
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2020-10-16 11:59:16 +02:00
Sami Kerola d2ab69ff61 login: ensure getutxid() does not use uninitialized variable [coverity scan]
Field ut.ut_pid is uninitialized when calling getutxline().  The safest
option is to ensure all struct data is initialized in the function.

CID: 360793
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2020-10-16 11:30:45 +02:00
Karel Zak b21d741c21 login: move proctitle code to login.c
The functions are used only by login(1), let's keep the code in
login.c only.

Signed-off-by: Karel Zak <kzak@redhat.com>
2020-10-06 15:15:15 +02:00
Karel Zak eee886ba1d build-sys: exclude GPL from libcommon
The library is not distributed and almost all code in this ar(1)
archive is Public Domain or LGPL ... but let's avoid any doubts and do
not mix non-GPL and GPL code there.

Addresses: https://github.com/karelzak/util-linux/issues/1157
Signed-off-by: Karel Zak <kzak@redhat.com>
2020-10-06 13:26:36 +02:00
Karel Zak b648917e0b login: use mem2strcpy() rather than rely on printf()
The strings from utmp does not have to be terminated. It's seems
better to explicitly terminate it than rely on "%.*s" printf()
functionality -- printf() man page assumes that "If a precision is
given, no null byte need be present", but static analyzers are pretty
unhappy with it.

Signed-off-by: Karel Zak <kzak@redhat.com>
2020-10-01 14:04:21 +02:00
Karel Zak 1e89f4fe18 su: remove useless assignment
Address: https://github.com/karelzak/util-linux/issues/1145
Signed-off-by: Karel Zak <kzak@redhat.com>
2020-09-23 16:54:34 +02:00
Thayne McCombs df09e21c24 login: add option to not reset username on each attempt
[kzak@redhat.com: - use different message on failed password]

Addresses: https://github.com/karelzak/util-linux/pull/1138
Addresses: https://github.com/karelzak/util-linux/issues/6
Signed-off-by: Karel Zak <kzak@redhat.com>
2020-09-11 12:20:37 +02:00
leeceeksdee 0c4bf7913c
her -> their 2020-08-28 19:19:23 +02:00
leeceeksdee c9c7de7932
her -> their 2020-08-28 19:18:33 +02:00
leeceeksdee 40d249fca0
his -> their 2020-08-28 19:15:34 +02:00
leeceeksdee c2fcf2f797
he -> they 2020-08-28 19:11:45 +02:00
Evgeny Vereshchagin 2cdbf06f5e tests: add a fuzzer for process_wtmp_file
Signed-off-by: Evgeny Vereshchagin <evvers@ya.ru>
2020-08-06 12:33:11 +00:00
Michael Kerrisk (man-pages) 95553ea0dd Manual pages: nologin.8: formatting fixes
Signed-off-by: Michael Kerrisk (man-pages) <mtk.manpages@gmail.com>
2020-07-24 14:41:49 +02:00
Michael Kerrisk (man-pages) 47c6012f2b Manual pages: lslogins.1: Minor wording and formatting fixres
Signed-off-by: Michael Kerrisk (man-pages) <mtk.manpages@gmail.com>
2020-07-24 14:41:49 +02:00
Michael Kerrisk (man-pages) 70dae020c9 Manual pages: runuser.1, su.1: miscellaneous wording and formatting fixes
Various wording and formatting fixes. Nothing too contentnious, I think,
so I rolled these changes into one patch.

Since there is much common text in su.1 and runuser.1, I've combined
the changes to both pages into one patch, and, as far as possible,
ensured that changes to the common pieces of text match across the
two pages.

Signed-off-by: Michael Kerrisk (man-pages) <mtk.manpages@gmail.com>
2020-07-14 14:37:26 +02:00
Karel Zak cdc08221ac Manual pages: reword su.1 description
Reported-by: "Michael Kerrisk (man-pages)" <mtk.manpages@gmail.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
2020-07-14 14:33:49 +02:00
Karel Zak 29e204d117 docs: reword others "allow to"
Signed-off-by: Karel Zak <kzak@redhat.com>
2020-07-14 14:31:29 +02:00
Michael Kerrisk (man-pages) 4f68c8b179 Manual pages: various: reword "allow(s) to"
The wording "allow(s) to" is not grammatical English. Reword various
pages to use a more correct form such "can be use to" or "allows
the [noun] of".

Aklong the way, fix a few nearby wording errors in some pages.

Signed-off-by: Michael Kerrisk (man-pages) <mtk.manpages@gmail.com>
2020-07-14 14:08:54 +02:00
Michael Kerrisk (man-pages) 10fa311d3e Manual pages: login.1: various minor wording fixes
Signed-off-by: Michael Kerrisk (man-pages) <mtk.manpages@gmail.com>
2020-07-14 13:58:59 +02:00
Michael Kerrisk (man-pages) 62dcaec071 Manual pages: login.1: formatting fixes
Bold for command names; italic for pathnames, etc.

Signed-off-by: Michael Kerrisk (man-pages) <mtk.manpages@gmail.com>
2020-07-14 13:58:59 +02:00
Michael Kerrisk (man-pages) f0fd830ea8 Manual pages: login.1: SEE ALSO: add utmp(5), lastlog(8)
utmp and lastlog are referred to in the manual page, and thus deserve a
cross references in SEE ALSO.

Signed-off-by: Michael Kerrisk (man-pages) <mtk.manpages@gmail.com>
2020-07-14 13:58:59 +02:00
Yuri Chornoivan 311e33afef Fix minor typos 2020-07-09 20:14:32 +03:00
Karel Zak 10a0a9cbc5 last: fix use of non-terminated utmp->ut_line
Addresses: https://github.com/karelzak/util-linux/pull/1097
Signed-off-by: Karel Zak <kzak@redhat.com>
2020-07-09 10:10:58 +02:00
Damien Goutte-Gattat 49848aa53a chfn: Make readline prompt for each field on a separate line
When readline is called to get user input, it is called without
a prompt argument. As a result, if the user does not enter anything
for a given field, then the next field is displayed on the same
line, yielding the following output:

  $ chfn
  Changing finger information for user.
  Password:
  Name []: Office []: Office Phone []: Home Phone []:

instead of the expected:

  $ chfn
  Changing finger information for user.
  Password:
  Full Name []:
  Room Number []:
  Work Phone []:
  Home Phone []:

This patch restores the expected behavior by feeding readline with
a character to display as "prompt".

[kzak@redhat.com: - do the same change in chsh
                  - use ' ' rather than '\n' for non-readline code]

Signed-off-by: Damien Goutte-Gattat <dgouttegattat@incenp.org>
Signed-off-by: Karel Zak <kzak@redhat.com>
2020-06-29 11:57:26 +02:00
Toni Uhlig fdadefe599
login: fixed invalid sizeof usage
Signed-off-by: Toni Uhlig <matzeton@googlemail.com>
2020-06-19 20:37:44 +02:00
Karel Zak 111b395aed login: cleanup get_hushlogin_status() use
* use 1 bit for context->quiet
* get_hushlogin_status() return -1 on error, make sure we do not
  interpret it as "hush mode enabled"

Signed-off-by: Karel Zak <kzak@redhat.com>
2020-06-16 14:00:58 +02:00
Karel Zak 31d79197c0 login: use PAM_SILENT to propagate hushlogin to PAM
login(1) follows /etc/hushlogin and ~/.hushlogin to enable silent
mode, but it's not propagated to PAM now. Note that login(1) from
shadow-utils uses PAM_SILENT too.

Addresses: https://github.com/linux-pam/linux-pam/issues/233
Addresses: https://github.com/karelzak/util-linux/issues/1059
Signed-off-by: Karel Zak <kzak@redhat.com>
2020-06-16 13:54:14 +02:00
Michael Kerrisk (man-pages) ee564ff41a Manual pages: runuser.1: Various wording and formatting fixes
Most of this is pretty straightforward English language fix-ups
and formatting fix-ups, so I've rolled it into one patch.

Signed-off-by: Michael Kerrisk (man-pages) <mtk.manpages@gmail.com>
2020-06-15 11:34:58 +02:00
Bjarni Ingi Gislason 54cbc11fe3 doc: login-utils/*: Fix some warnings from "mandoc -T lint"
mandoc: ./login-utils/chfn.1:96:2: WARNING: skipping paragraph macro: PP empty

mandoc: ./login-utils/lslogins.1:14:2: WARNING: skipping paragraph macro: PP after SH

mandoc: ./login-utils/newgrp.1:18:2: WARNING: skipping paragraph macro: PP empty

mandoc: ./login-utils/nologin.8:19:2: WARNING: skipping paragraph macro: PP empty

mandoc: ./login-utils/sulogin.8:57:2: WARNING: skipping paragraph macro: PP empty

mandoc: ./login-utils/utmpdump.1:61:2: WARNING: skipping paragraph macro: PP after SS

mandoc: ./login-utils/vipw.8:65:2: WARNING: line scope broken: TP breaks I

####

  There is no change in output from "nroff" or "groff".

Signed-off-by: Bjarni Ingi Gislason <bjarniig@rhi.hi.is>
2020-06-15 11:28:01 +02:00
Karel Zak 19a353947d logindefs: use xalloc.h, code cleanup
- remove else-after-return
- use else-if
- use xalloc stuff

Signed-off-by: Karel Zak <kzak@redhat.com>
2020-06-09 11:31:42 +02:00
Karel Zak 330b09976f build-sys: remove redundard includes
Signed-off-by: Karel Zak <kzak@redhat.com>
2020-06-09 10:53:14 +02:00
Karel Zak a437692943 login: cleanup -f in usage() and comments
Let's remove unnecessary comment and "second authentication" from
usage().

Addresses: https://github.com/karelzak/util-linux/issues/1053
Signed-off-by: Karel Zak <kzak@redhat.com>
2020-06-01 10:33:29 +02:00
Karel Zak f0833edc12 login: fix -f description in the man-page
Addresses: https://github.com/karelzak/util-linux/issues/1053
Signed-off-by: Karel Zak <kzak@redhat.com>
2020-05-29 14:50:36 +02:00
Michael Kerrisk (man-pages) 1538f6f636 Manual pages: wording fix: "another" ==> "other"
In several pages, there is a consistent wording problem: "another"
where "other" should be used. This wording problem can be
surprisingly confusing for native speakers, especially those
unaware that in some other languages, "another" and "other" can be
expressed with the same word.

Signed-off-by: Michael Kerrisk (man-pages) <mtk.manpages@gmail.com>
2020-05-29 14:31:47 +02:00
Karel Zak 498f910eeb build-sys: add $LDADD and libcommon to test_logindefs_LDADD
Addresses: https://travis-ci.org/github/karelzak/util-linux/jobs/690915120
Signed-off-by: Karel Zak <kzak@redhat.com>
2020-05-26 11:43:07 +02:00
Karel Zak fee9910661 build-sys: cleanup $vendordir use
- use --with-vendordir= (rather than --enable) to be compatible with
  another package stuuf

- add USE_VENDORDIR automake condition

- add vendordir to global AM_CPPFLAGS to avoid binary specific cflags
  modifications

Signed-off-by: Karel Zak <kzak@redhat.com>
2020-05-25 13:44:22 +02:00
Karel Zak d5e8818e03 Merge branch 'libeconf' of https://github.com/thkukuk/util-linux
* 'libeconf' of https://github.com/thkukuk/util-linux:
  Adjust test output to pass test suite
  Add support for libeconf
2020-05-25 12:23:13 +02:00
Michael Kerrisk (man-pages) 67e63c1263 Manual pages: order NOTES / HISTORY / BUGS / EXAMPLE consistently
There is value in ensuring that manual page sections use consistently
named sections, as far as possible, and also that sections have a
consistent order within manual pages. This is one of a series of patches
to place manual page sections in a consistent order.

In this patch, we ensure that the NOTES, HISTORY, BUGS, and EXAMPLE
sections are always placed near the end of the page, just above
AUTHORS, COPYRIGHT, SEE ALSO, and AVAILABILITY.

One page is not fixed by this patch: term-utils/agetty.8. This page
is a mess of unusual section names, and probably requires an individual
edit.

Testing that no gross editing mistake (causing accidental loss or addition
of text) was performed as follows:

    $ cat $(grep '\.SH' -l $(find . -name '*.[1-9]') |sort) | sort > a
    [Apply patch]
    $ cat $(grep '\.SH' -l $(find . -name '*.[1-9]') |sort) | sort > b
    $ diff a b
    $ echo $?
    0

Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2020-05-22 10:25:50 +02:00
Michael Kerrisk (man-pages) ade04bb89c Manual pages: order AUTHORS / COPYRIGHT / SEE ALSO / AVAILABILITY consistently
There is value in ensuring that manual page sections use consistently
named sections, as far as possible, and also that sections have a
consistent order within manual pages. This is one of a series of patches
to place manual page sections in a consistent order.

In this patch, we ensure that the AUTHORS, COPYRIGHT, SEE ALSO, and
AVAILABILITY sections are always placed at the end of the page.

Testing that no gross editing mistake (causing accidental loss or addition
of text) was performed as follows:

    $ cat $(grep '\.SH' -l $(find . -name '*.[1-9]') |sort) | sort > a
    [Apply patch]
    $ cat $(grep '\.SH' -l $(find . -name '*.[1-9]') |sort) | sort > b
    $ diff a b
    $ echo $?
    0

Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2020-05-22 10:25:49 +02:00
Michael Kerrisk (man-pages) a87f49f662 Manual pages: use the term "exit status"
The manual pages currently use a multitude of terms--"exit code",
"error code", "return code", "exit code", and so on--when what
is always meant is "exit status" (the POSIX term). This patch fixes
as many of these erroneous terms as I could find.

Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2020-05-20 12:56:52 +02:00
Michael Kerrisk (man-pages) 4259cff22e Manual pages: Standardize on ENVIRONMENT as section title
There is quite some value (in terms of readability and user
expectations) if consistent names are used for the sections
within manual pages. This patch is one of a series to bring
about this consistency.

But, let's make sure that the section is consistently titled
across pages. Currently we have ENVIRONMENT (many) or ENVIRONMENT
VARIABLES (3).  Let's standardize on ENVIRONMENT (which is also
what is suggested in man-pages(7)).

Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2020-05-20 12:56:12 +02:00
Michael Kerrisk (man-pages) a8d0d330cf Manual pages: Standardize on AUTHORS as section title
There is quite some value (in terms of readability and user
expectations) if consistent names are used for the sections
within manual pages. This patch is one of a series to bring
about this consistency.

In the Linux man-pages project, I long ago did away with the
AUTHOR(S) section, but I realize some projects like to keep this.

But, let's make sure that the section is consistently titled
across pages. Currently we have AUTHOR (47) or AUTHORS (41).
Let's standardize on the latter (which is also what is
suggested in man-pages(7)).

Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2020-05-20 12:56:12 +02:00
Michael Kerrisk (man-pages) 5a82980632 docs: (man) remove double quotes (") in .SH lines
Using double quotes in .SH lines containing multiple words is unneeded,
and in any case is not consistently done in the util-linux manual pages,
where double quotes are used in only around half of the cases.
(This usage was long ago elminated in the man-pages project, with
no ill effects reported to date.)

Remove these quotes, so that .SH lines are more uniform, in preparation
for some (more easily) scripted doiscovery of consistency problems in
(and possibly global fixes to) the manual pages.

Other than stripping the double quotes, this patch makes no changes to
the content of the manual pages.

Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2020-05-19 12:15:34 +02:00
Karel Zak e327a7acd6 agetty: extend --issue-file to support multiple paths
The current default behavior is to print the first issue file/dir and
all alternative locations are used as a backup solution only. If something
is found than the rest is ignored. The --issue-file allow to overwrite
this default behavior, but currently it supports only one file/dir.

This patch extend --issue-file to support ':' separated list of paths
and *all* the files (if exist and no empty) in the list are printed.

 agetty --issue-file=/etc/issue:/etc/issue.d:/run/issue:/run/issue.d:/usr/lib/issue:/usr/lib/issue.d

Addresses: https://github.com/karelzak/util-linux/issues/1041
Signed-off-by: Karel Zak <kzak@redhat.com>
2020-05-19 10:55:20 +02:00
Karel Zak 72b155ea6e login: keep default MOTD_FILE= backwardly compatible
It seems that directories like /etc/motd.d are already used by PAM or
by another stuff. Let's keep it in admin/distro hands and do not
change the current default.

Signed-off-by: Karel Zak <kzak@redhat.com>
2020-05-12 15:37:39 +02:00
Karel Zak 9789d21a96 login: add MOTD_FIRSTONLY=
This login.defs option allow to configure login to be more compatible
with pam_motd.

Addresses: https://github.com/karelzak/util-linux/issues/1034
Signed-off-by: Karel Zak <kzak@redhat.com>
2020-05-12 15:21:21 +02:00
Karel Zak 5a528e2c6f login: add support for directories in MOTD_FILE=
The current standard is to use directories to make it easy for
distributions to share resources. This patch also add /etc/motd.d
and /run/motd.d to the default MOTD_FILE=.

Addresses: https://github.com/karelzak/util-linux/issues/10341
Signed-off-by: Karel Zak <kzak@redhat.com>
2020-05-12 14:20:54 +02:00
Rosen Penev ad296391f9
[clang-tidy] fix wrong *cmp usage
Found with bugprone-suspicious-string-compare

Signed-off-by: Rosen Penev <rosenp@gmail.com>
2020-04-20 13:21:00 -07:00
Rosen Penev 042f62dfc5
[clang-tidy] do not use else after return
Found with readability-else-after-return

Signed-off-by: Rosen Penev <rosenp@gmail.com>
2020-04-20 13:20:59 -07:00
Rosen Penev bd89499e07
[clang-tidy] do not return in void functions
Found with readability-redundant-control-flow

Signed-off-by: Rosen Penev <rosenp@gmail.com>
2020-04-19 14:03:21 -07:00
Karel Zak cd52e392ac lslogins: remove unnecessary brackets
Just to be consistent with the rest of the code.

Signed-off-by: Karel Zak <kzak@redhat.com>
2020-03-31 13:12:11 +02:00
Sami Kerola 3434ac9720
lslogins: use lastlog as wtmp fallback
The wtmp file tends to rotate higher rate than lastlog, so use the later as
fallback in when wtmp tells nothing in LAST-LOGIN column.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2020-03-29 21:18:48 +01:00
Sami Kerola 370734a7eb
login: avoid lseek() with pread() and pwrite()
This makes code a little less complicated by avoiding couple system calls.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2020-03-29 20:19:12 +01:00
Karel Zak 57b9d60cb5 su, runuser: (man) add more info about PATH and PAM
Addresses: https://github.com/karelzak/util-linux/issues/964
Signed-off-by: Karel Zak <kzak@redhat.com>
2020-02-27 14:37:23 +01:00
Karel Zak 1f47d4a2f0 chsh: (man) fix default behavior description
Addresses: https://github.com/karelzak/util-linux/issues/967
Signed-off-by: Karel Zak <kzak@redhat.com>
2020-02-27 13:54:05 +01:00
Sami Kerola 3160589d86
various: use threadsafe versions of time functions [lgtm scan]
Deprecating calls to not-thread safe asctime(), ctime(), and localtime()
calls is pretty close to pointless change.  Lets do it to reduce lgtm scan
warnings with justification it's nicer to use static analysis tools when
they have very few positives.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2020-02-15 15:23:44 +00:00
Karel Zak 3b28b4686c lslogins: assume unterminated strings in wtmp/btmp [coverity scan]
Let's use mem2strcpy() to be robust.

Signed-off-by: Karel Zak <kzak@redhat.com>
2020-01-15 13:20:23 +01:00
Bjarni Ingi Gislason 1c4c602427 man pages: Change a HYPHEN-MINUS (-) to a minus (\-) for options and numbers
Change a HYPHEN-MINUS (code 0x55, 2D) to a minus (\-), if in front of

1) a name of an option

2) a negative number to be printed.

  See man-pages(7) [Debian package "manpages"].

  The output from "nroff" is unchanged.

Signed-off-by: Bjarni Ingi Gislason <bjarniig@rhi.hi.is>
2019-12-17 12:32:43 +01:00
Bjarni Ingi Gislason eb02489380 man pages: Add a comma after "e.g." and "i.e."
Add a comma (,) after "e.g." and "i.e.", or use English words
(man-pages(7) [package "manpages"]).

  Abbreviation points should be protected (usually with the
non-printing, zero width character '\&') from being interpreted as an
end of sentence, if they are not, and that independent of their current
place on the line.

  This is important when typing, as one does not usually know in
advance when the editor jumps to a new line.

Signed-off-by: Bjarni Ingi Gislason <bjarniig@rhi.hi.is>
2019-12-17 12:32:43 +01:00
Bjarni Ingi Gislason 2fb684f004 man pages: Fix misuse of two-fonts macros
Two-fonts macros are made for two or more arguments.

  Remove space at end of lines in the files "term-utils/{script.1,
scriptlive.1, scriptreplay.1}".

  Put "\-\-summary" to the correct indent in the file
"term-utils/script.1"

Signed-off-by: Bjarni Ingi Gislason <bjarniig@rhi.hi.is>
2019-12-17 12:32:43 +01:00
Manatsu Takahashi ebaf1d55b4 Slight change in terms 2019-12-08 22:26:26 +09:00
Manatsu Takahashi 1ffc4f7dcb Make the manpage of su clearer 2019-12-08 22:20:53 +09:00
Jouke Witteveen 1c788737d7 su: silence a useless warning
When the requested shell matches the restricted shell, there is no reason
to issue a warning, since we will be doing precisely as requested.

Signed-off-by: Jouke Witteveen <j.witteveen@gmail.com>
2019-12-06 12:40:55 +01:00
Sami Kerola beb61b07c2
nologin: silently ignore well known shell command-line options
nologin is typically used in /etc/passwd as a shell replacement.  Hence it
is reasonable to ignore well known command-line options silently to avoid
unwanted ugly error messages.

Addresses: https://github.com/karelzak/util-linux/issues/895
Requested-by: Lennart Poettering <lennart@poettering.net>
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2019-11-17 08:33:04 +00:00
Karel Zak bdc3cc65ab su: fix error message
Reported-by: Pedro Albuquerque <palbuquerque73@gmail.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
2019-10-29 10:04:29 +01:00
Karel Zak 70ff760d41 login: reduce file-descriptors cleanup overhead
Addresses: https://github.com/karelzak/util-linux/issues/883
Signed-off-by: Karel Zak <kzak@redhat.com>
2019-10-17 10:45:16 +02:00
Stanislav Brabec a174eefb41 nologin: Prevent error from su -c
"su -c" can pass "-c" to nologin. It causes ugly error:

su -c "echo OK" - man
-nologin: invalid option -- 'c'
Try '-nologin --help' for more information.

Accept -c to prevent this error.

Signed-off-by: Josef Cejka <jcejka@suse.com>
Signed-off-by: Stanislav Brabec <sbrabec@suse.cz>
2019-10-11 10:08:03 +02:00
Thorsten Kukuk b6b7348eee Adjust test output to pass test suite 2019-10-08 14:58:42 +02:00
Karel Zak bdd4335706 lib/pty-session: make wait_child callback optional
Now the code is duplicate on many places, but all we usually need is to
remember child status. It seems good enough to have very simple
callback child_die() to inform application about a change.

The patch also add PID to all signal related callbacks.

Signed-off-by: Karel Zak <kzak@redhat.com>
2019-10-08 13:11:54 +02:00
Karel Zak 46737a7332 su: (pty) remove unnecessary call
The pty code has to save the original signal mask without application
assistance.

Signed-off-by: Karel Zak <kzak@redhat.com>
2019-10-08 13:11:54 +02:00
Karel Zak 63869b842f build-sys: fix build with pty
Signed-off-by: Karel Zak <kzak@redhat.com>
2019-10-08 13:11:54 +02:00
Karel Zak b923bdbe52 su: use lib/pty-session.c code for --pty
Signed-off-by: Karel Zak <kzak@redhat.com>
2019-10-08 13:11:54 +02:00
Elliott Mitchell 2bb3aa36b2 cleanup: Remove some spurious spaces
Sorry detail-oriented people tend to wipe these out if they notice them.
Add in automated tools and lots of excess end-of-line spaces get wiped
out.

Addresses: https://github.com/karelzak/util-linux/pull/849
Signed-off-by: Karel Zak <kzak@redhat.com>
2019-10-01 13:01:43 +02:00
Quentin Rameau 83db544dda chsh: replace getpw unsafe functions with xgetpw 2019-09-26 15:55:41 +02:00
Karel Zak b04f7d0e01 login-utils: add header file guards [lgtm scan]
Signed-off-by: Karel Zak <kzak@redhat.com>
2019-09-20 16:10:43 +02:00
Sami Kerola 218b1dd6f9
misc: fix typos [codespell]
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2019-09-12 19:41:46 +01:00
Thorsten Kukuk 9e584ff324 Add support for libeconf 2019-09-03 15:04:43 +02:00
Sami Kerola 2e028ccce8
docs: correct su.1 runuser reference from section 8 to 1
Addresses: https://bugs.debian.org/929677
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2019-08-24 09:29:55 +01:00
Sami Kerola ff9da8efca setpwnam: use more appropriate allocation size types
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2019-08-21 15:00:16 +02:00
Karel Zak 9210c0d225 chfn: don't append extra tailing commas
# grep kzak /etc/passwd
 kzak1000:1000::/home/kzak:/bin/bash

 # chfn kzak
 ...
 grep kzak /etc/passwd

old version:
 kzak1000:1000:Karel Zak,,,,:/home/kzak:/bin/bash

fixed version:
 kzak1000:1000:Karel Zak:/home/kzak:/bin/bash

Reported-by: Filip Dvorak <fdvorak@redhat.com>
References: f723cbf544
Signed-off-by: Karel Zak <kzak@redhat.com>
2019-08-19 14:03:07 +02:00
Sami Kerola 1aaee548e3 login: simplify string handling
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2019-07-24 11:11:29 +02:00
Sami Kerola 0675f52ab5 last: replace strncat() with more robust mem2strcpy()
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2019-07-24 11:11:10 +02:00
Jakub Hrozek 9a1a982206 su: More descriptive error message on malformed user entry
With users coming from LDAP, it is often the case that the entry in LDAP
does not contain one or more attributes required by su or, because of
misconfigured access control rights, the attribute might not be readable
by the LDAP client. In that case, su just tells the user that the user
does not exist.

It might be more user-friendly to tell the user to check the user entry
for all required fields.
2019-05-31 13:23:57 +02:00