Commit Graph

769 Commits

Author SHA1 Message Date
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
Karel Zak 6f7eba20af login: ignore SIGXFSZ when write to lastlog
the lastlog file is huge and on systems with large UIDs, it's so huge that
it generates SIGXFSZ when the FSIZE limit is too small.

Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=1165702
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-11-19 15:45:42 +01:00
Karel Zak cd2876d252 build-sys: move all around clock_gettime() to monotonic.c
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-11-19 11:54:47 +01:00
Karel Zak 8fc4a88630 build-sys: properly check for -lrt
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-10-27 11:05:14 +01:00
Sami Kerola db433bf737 textual: use usage() text element macros
Translating these text elements should happen only once, which is
more likely when the text macros are used properly.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2014-10-01 12:33:26 +02:00
Sami Kerola a587cc5520 textual: use manual tail usage() macro
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2014-10-01 12:33:24 +02:00
Sami Kerola 7d2600e2d0 docs: update deprecation banners
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2014-10-01 12:33:11 +02:00
pcpa 1d966345df su: print proper core dump message when killed
An example is, in one terminal "sudo su -; echo $$", and in
another terminal, "kill -9  $PID" (the pid of the su -). It
should not print "(core dumped)", unless the kill signal
specified so, e.g. kill -7 or kill -11.

Signed-off-by: pcpa <paulo.cesar.pereira.de.andrade@gmail.com>
2014-10-01 10:23:48 +02:00
Benno Schulenberg ee7ea5c85e textual: use a somewhat clearer and more standard failure message
Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
2014-10-01 09:37:04 +02:00
Karel Zak 30ea015b87 lslogins: cleanup after error [coverity scan]
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-09-26 11:23:32 +02:00
Sami Kerola 453fc7165d textual: share crypt() error message in sulogin and newgrp
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2014-09-19 19:31:03 +01:00
Sami Kerola 8f663a674d newgrp: avoid use of obsolete getpass() function
Read a password from user with termios, and once the password data is no
longer needed ensure it gets overwrote before unallocating memory.

Reference: http://man7.org/linux/man-pages/man3/getpass.3.html
Reference: https://www.securecoding.cert.org/confluence/display/seccode/MSC06-C.+Beware+of+compiler+optimizations
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2014-09-19 19:31:03 +01:00
Sami Kerola c829aebc39 newgrp: use libc function to read gshadow if it is available
The glib versionf of getsgnam() is using /etc/nsswitch.conf, allowing the
group passwords to come from external database.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2014-09-19 19:31:02 +01:00
Sami Kerola d4ce90d47c last: improve code readability by renaming variable names
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2014-09-19 19:31:01 +01:00
Sami Kerola 8813da1ea2 last: make is_phantom() when kernel config does not include audit support
When kernel CONFIG_AUDIT is not set the /proc/<pid>/loginuid information
is not present resulting live sessions to be marked 'gone - no logout' in
last(1) print out.  To go-around this change makes last(1) to look
/dev/<tty> device ownership as a substitute of loginuid.

The go-around seems to work fairly well, but it has it short comings.
For example after closing a X window session the /dev/ttyN file seems to
be owned by root, not the user who had it before entering to the X
session.  While that is suboptimal it is still better than an attmempt to
determine uid_t by looking owner of the /proc/<struct utmp ut_pid>, that
is a login(1) process running as root.

The issue was found using Archlinux installation.

$ pacman -Qi linux
Name           : linux
Version        : 3.16-2
[...]
Build Date     : Mon Aug 4 18:06:51 2014

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2014-09-19 19:31:01 +01:00
Benno Schulenberg 1d23119072 textual: remove some inconsistent periods from error messages
While doing so, also improve translatability and some wordings.

Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
2014-08-11 14:51:54 +02:00
Benno Schulenberg b45413a860 docs: bring the runuser and su man pages closer to standard formatting
Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
2014-07-29 12:14:58 +02:00
Benno Schulenberg 75ca43bbb2 docs: give the man page of utmpdump the proper User Commands header
Also bring the formatting closer to standard.

Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
2014-07-29 12:14:58 +02:00
Benno Schulenberg bf967a6cab docs: improve the formatting of the chfn and chsh man pages
Also fix a pasting mistake where the chfn man page suggested
to use ypchsh or lchsh for non-local entries.

Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
2014-07-29 12:14:57 +02:00
Benno Schulenberg 09af3db48e textual: fix some typos and inconsistencies in various messages
Fixing plain typos, miswordings, inconsistent periods, some missing
angular brackets, and a proper pluralization (even when it involves
a constant, because for some languages the precise value matters).

Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
2014-07-23 08:56:00 +02:00
Karel Zak ccef45168b Merge branch 'master' of https://github.com/yurchor/util-linux
* 'master' of https://github.com/yurchor/util-linux:
  Fix typos in user visible messages
2014-07-22 12:01:50 +02:00
Karel Zak 3df45c7cdc Merge branch 'ioclt' of https://github.com/lanurmi/util-linux 2014-07-22 11:58:21 +02:00
Karel Zak 87a144a502 lslogins: more robust usage of columns[]
For more details see commit dcc8dbdc8137cb3da5100158639b565565b89875.

Signed-off-by: Karel Zak <kzak@redhat.com>
2014-07-18 13:51:01 +02:00
Karel Zak fa936c9f9b sulogin: don't use uninitialized struct sigaction [coverity scan]
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-07-17 14:47:20 +02:00
Karel Zak c210324c67 sulogin: check result of the open() [coverity scan]
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-07-17 14:42:00 +02:00
Karel Zak 2e118e709b last: fix is_phantom() logic [coverity scan]
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-07-17 14:39:11 +02:00
Benno Schulenberg 1000a59543 docs: improve the formatting and wording of two man pages
Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
2014-07-17 14:00:50 +02:00