Commit Graph

795 Commits

Author SHA1 Message Date
Benno Schulenberg fc14ceba5e textual: grammarize and harmonize the stat error message
The message "stat failed %s" seems to say that stat() failed to
do something, or failed to pass a test, but of course it means
that the statting of something failed.  So say so.  Also make
two very similar messages equal to this one.

Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
2015-02-02 11:27:10 +01:00
Karel Zak 912a7077b2 utmpdump: don't pass parameter of type "struct utmp" by value [coverity scan]
Signed-off-by: Karel Zak <kzak@redhat.com>
2015-01-29 11:40:47 +01:00
Karel Zak 863d371c83 sulogin: make sure that fallback FD is valid [coverity scan]
Signed-off-by: Karel Zak <kzak@redhat.com>
2015-01-29 11:32:42 +01:00
Karel Zak 101c5838ac su: fix mem leak in modify_environ() [coverity scan]
Signed-off-by: Karel Zak <kzak@redhat.com>
2015-01-29 11:26:09 +01:00
Karel Zak 86cf1ff42a login: fix mem leak in init_environ() [coverity scan]
Signed-off-by: Karel Zak <kzak@redhat.com>
2015-01-29 11:25:07 +01:00
J William Piggott b06c1ca6f8 docs: restore minus symbols in long opts
Signed-off-by: J William Piggott <elseifthen@gmx.com>
2015-01-20 18:15:30 -05:00
J William Piggott 973252578d docs: fix-up man-pages flaged by checkmans.sh
disk-utils/sfdisk.8	Fix font escape
login-utils/vipw.8	Delete bogus macro
misc-utils/look.1	Delete bogus macro
sys-utils/prlimit.1	Delete bogus macro

Signed-off-by: J William Piggott <elseifthen@gmx.com>
2015-01-13 11:43:46 -05:00
Benno Schulenberg 3a60b1c26b docs: remove obsolete and unneeded comments from man-page files
Transform some of them into copyright lines.
Also fix three header lines and snip some trailing whitespace.

Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
2015-01-12 11:03:26 +01:00
Sami Kerola 7ee26cbf02 maint: fix shadow declaration
This change fixes all shadow declarations.  The worth while to mention
fix is with libfdisk sun geometry.  It comes from bitops.h cpu_to_be16
macro that further expands from include/bits/byteswap.h that has the
shadowing.

libfdisk/src/sun.c:961:173: warning: declaration of '__v' shadows a previous local [-Wshadow]
libfdisk/src/sun.c:961:69: warning: shadowed declaration is here [-Wshadow]
libfdisk/src/sun.c:961:178: warning: declaration of '__x' shadows a previous local [-Wshadow]
libfdisk/src/sun.c:961:74: warning: shadowed declaration is here [-Wshadow]

That could have caused earlier some unexpected results.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2015-01-07 10:08:21 +01:00
Benno Schulenberg 451dbcfae1 textual: add a docstring to most of the utilities
This adds a concise description of a tool to its usage text.

A first form of this patch was proposed by Steven Honeyman
(see http://www.spinics.net/lists/util-linux-ng/msg09994.html).

Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
2015-01-06 11:27:38 +01:00
Karel Zak 4a98629b29 chsh: keep struct options in .rodata
Signed-off-by: Karel Zak <kzak@redhat.com>
2015-01-06 11:00:51 +01:00
Karel Zak 84705c8b89 chsh: simplify get_shell_list()
Signed-off-by: Karel Zak <kzak@redhat.com>
2015-01-06 10:57:09 +01:00
Sami Kerola 1fd15f04b3 newgrp: set function arguments read-only when possible
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2015-01-05 22:53:01 +00:00
Sami Kerola 51c52acfb1 newgrp: move shell determination closer where it is used
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2015-01-05 22:53:01 +00:00
Sami Kerola 477135dfec newgrp: simplify if else clauses
The 'if' clauses that have termination as either of the control flow
results will never need 'else'.  Making the termination to happen true
flow is enough.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2015-01-05 22:53:01 +00:00
Sami Kerola 9a5cbe5223 chsh: fail get_shell_list() check when /etc/shells cannot be opened
And get rid of stdbool.h true/false usage.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2015-01-05 22:52:51 +00:00
Sami Kerola 1df0219f2c chsh: simplify check_shell()
Shell null check is redundant.  The shell can be null only after
ask_new_shell returned such, and that is checked earlier in program
logic.

Secondly the check_shell does not need to return values, in such cases
the program can simply exit.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2015-01-05 22:52:51 +00:00
Sami Kerola e323df25f5 chsh: rewrite function interacting with user to get path to new shell
Rename prompt() to ask_new_shell().  Remove fixed size buffer and
allocate path to new shell, that should make Hurd people happy.  Use
strutils.h for white space trimming.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2015-01-05 22:52:51 +00:00
Sami Kerola 68b24d53e1 chsh: clean up parse_argv()
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2015-01-05 22:52:51 +00:00
Sami Kerola f64979233f chsh: allow user to set shell to /bin/sh if none is set
Earlier setting a /bin/sh was impossible for users that had nothing set
as shell, as that was seen as no change.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2015-01-05 22:52:51 +00:00
Sami Kerola 561c48582c chsh: set few variables read-only and rename one of them
This change also improves couple variable initializations.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2015-01-05 22:52:51 +00:00
Sami Kerola 1cb122d591 chsh: use getline() to support arbitrarily long lines
Use of fgets() can make a single long line to be understood as two
entries, and someone could play tricks with the remainder part of the
buffer.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2015-01-05 22:52:50 +00:00
Sami Kerola 144ae70ef3 chfn, chsh: share illegal_passwd_chars() function
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2015-01-05 22:52:50 +00:00
Sami Kerola 5eef61296f chsh: remove function prototypes
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2015-01-05 22:52:50 +00:00
Karel Zak bf6c15ed4a chfn: fix compilation without libuser
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-12-19 15:05:04 +01:00
Sami Kerola e88f005949 chfn: make command to obey login.defs CHFN_RESTRICT instructions
Reference: http://man7.org/linux/man-pages/man5/login.defs.5.html
Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=138519
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2014-12-19 09:11:04 +00:00
Sami Kerola f723cbf544 chfn: remove set_changed_data() and add add_missing()
The add_missing() and find_field() functions are needed when input data
is incomplete, such as in case when chfn is instructed to change only
selected fields with command line options.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2014-12-19 09:11:04 +00:00
Sami Kerola d9e1ac99e4 chfn: rename prompt() to ask_new_field()
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2014-12-19 09:11:04 +00:00
Sami Kerola 5fe1c32f61 chfn: move new and old finger structs to chfn control struct
This change is a little bit messy, and requires a comment the struct
finfo should not have 'struct passwd *pw' as it's member.  The earlier
struct design would have been burden to maintain, and confusing to use.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2014-12-19 09:11:04 +00:00
Sami Kerola e4efecc4db chfn: clean up parse_argv()
Use switch() case ?: for all option parsing, as in most of the other
source files.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2014-12-19 09:11:04 +00:00
Sami Kerola d5fdba0346 chfn: add minimalistic struct chfn_control
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2014-12-19 09:11:04 +00:00
Sami Kerola 58985f6712 chfn: simplify parse_passwd() by using strsep()
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2014-12-19 09:11:03 +00:00
Sami Kerola 496083bad6 chfn: fix usage() regression
Commit db433bf737 changed -u for --help to
-h, that is not true.  The -h is short hand for --home-phone.  And the
--version is accompanied with -v not -V.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2014-12-19 09:11:03 +00:00
Sami Kerola 1b7a19ebbb chfn: use xasprintf() rather than bunch of strlen() and malloc() calls
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2014-12-19 09:11:03 +00:00
Sami Kerola 5a57c00af0 chfn: rewrite prompt() to use strutils
The left and right white space trimming can be done with strutils.h
[lr]trim_whitespace() functions.

As a minor fix when user input exceeds maxium allowed gecos field length
the remaining characters in stdin are purged so that re-prompting works
correctly.

Additionally the prompt() is made to add message to check_gecos_string(),
so that there are less similar strings for translation project to deal.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2014-12-19 09:11:03 +00:00
Sami Kerola 2401633559 chfn: remove function prototypes
Requires resuffling functions order they work without issues.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2014-12-19 09:11:03 +00:00
Sami Kerola 4ecc6dbb53 lslogins: use hardcoded paths from pathnames.h
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2014-12-19 09:11:03 +00:00
Sami Kerola 77006d95db lslogins: add space to systemd journal header and message
This commit changes journal messages in individual user printout the
following way.

Dec 13 16:02:05 systemd[324]:Time has been changed	(old)
Dec 13 16:02:05 systemd[324]: Time has been changed	(new)

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2014-12-19 09:11:02 +00:00
Sami Kerola cdf3896a05 lslogins: reject unknown time format arguments
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2014-12-19 09:11:02 +00:00
Sami Kerola dfd4359bb0 lslogins: fix short options
Usage is promising -e is an option alias of --export, so make it work.
And get rid of -x that was accepted, but not in use.

Long only enum member OPT_VER was probably a development time idea, that
never got to be used.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2014-12-19 09:11:02 +00:00
Sami Kerola 1025d21efe lslogins: tell why command failed
Printing usage() without hint what is wrong does not help an user.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2014-12-19 09:11:02 +00:00
Sami Kerola f838efeb67 lslogins: make journald last logs time stamps to honor --time-format
This makes by default the last logs to have year in output when necessary.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2014-12-19 09:11:02 +00:00
Sami Kerola aa45b344d3 lslogins: allow changing password changed and expiration time formats
The password change and expiry has are marked with resolution of a day,
so add a new short iso-8601 format.  With this system admins can easily
find users has not updated their password lately

$ lslogins --time-format=iso --user --output=pwd-change,user | sort -n

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2014-12-19 09:11:02 +00:00
Benno Schulenberg f49ccec212 docs: don't use bold or italics for "[option]" in synopsis of man pages
As per the convention shown in Documentation/howto-man-page.txt.
Also make a few other tiny adjustments along the way.

Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
2014-12-19 09:57:23 +01:00
Will Johansson ecc5632f09 login: Fix unused variables in login.c if _HAVE_UT_TV isn't defined
Wrap around the variable declaration for `tv' with ifdef so the compilers
don't warn about unused variables if we're compiling without UT_TV. This
happens with the musl libc, since it doesn't define _HAVE_UT_TV, even
though it _does_ have the ut_tv field in the utmp struct.

Signed-off-by: Will Johansson <will.johansson@gmail.com>
2014-12-18 11:02:08 +01:00
Will Johansson fe2c9909cd login-utils: Enable building util-linux against OpenPAM
OpenPAM is compatible with util-linux, with a few changes, namely
using OpenPAM's conversation function, openpam_ttyconv.

We check for Linux-PAM by querying for security/pam_misc.h, and OpenPAM
by querying for security/openpam.h.

Signed-off-by: Will Johansson <will.johansson@gmail.com>
2014-12-15 10:16:03 +01:00
Karel Zak 0d75c73d4f lslogins: fix -l -g logic
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-12-12 15:17:19 +01:00
Sami Kerola 228bb39a5e lslogins: align usage() and manual with struct option longopts
Short option -G goes together with long option --supp-groups, while
neither of -m or --groups-info has worked in a release so remove them
from usage() and manual.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2014-12-09 09:19:41 +01:00
Sami Kerola 123f0f5bf0 lslogins: fix assertion failure for none existing logins
This cange makes the following to retun none-zero value instead of a core
dump.

$ lslogins qwertyuiopasdfghjklzxcvbnm1234567
lslogins: libsmartcols/src/line.c:362: scols_line_get_cell: Assertion `ln' failed.
Aborted (core dumped)

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2014-12-09 09:19:39 +01:00
Sami Kerola 58fbb9b2d5 login-utils: use libc error printing facility
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2014-12-09 09:19:20 +01:00