Commit Graph

1137 Commits

Author SHA1 Message Date
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