Commit Graph

59 Commits

Author SHA1 Message Date
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
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
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 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
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
Sami Kerola 467ca0b214 chfn: assigned value is never read [clang-analyzer]
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2013-07-09 14:25:11 +02:00
Karel Zak d86918b6eb chsh-chfn: fix bugs, improve compilation
* rename --disable-require-password to --disable-chsh-chfn-password

 * is_local() is really unnecessary when linked with libuser

 * fix set_value_libuser() returns codes

 * fix chfn.c, there is no 'pw', but oldf.pw

 * don't link with PAM when--disable-chsh-chfn-password

Signed-off-by: Karel Zak <kzak@redhat.com>
2013-02-13 13:44:34 +01:00
Cody Maloney 8c24b6aa2c chfn: Add libuser support
Signed-off-by: Cody Maloney <cmaloney@theoreticalchaos.com>
2013-02-13 09:39:12 +01:00
Cody Maloney d91ad6ab3c chsh-chfn: Move pam auth to its own function, factoring out common code
This makes it easier to add support for libuser, which needs the same PAM
authentication. Also removes duplicate code between chsh and chfn.

Signed-off-by: Cody Maloney <cmaloney@theoreticalchaos.com>
2013-02-13 09:28:33 +01:00
Benno Schulenberg b50945d4ac textual: spell and encode the name of Arkadiusz Miśkiewicz correctly
Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
2013-02-06 11:15:02 +01:00
Karel Zak 6affea028b chfn: always use return rather than exit() in main
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-12-12 10:41:44 +01:00
Karel Zak 97da60c64e chfn: clean up exit status
The old version in some cases (but not always) returns -1 (255) on
error. It seems better to cleanup the code and don't return internal
return codes by exit().

Signed-off-by: Karel Zak <kzak@redhat.com>
2012-12-12 10:36:32 +01:00
Sami Kerola 439cdf1e24 login-utils: verify writing to streams was successful
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2012-04-04 19:58:34 +02:00
Sami Kerola 8c3221890a chfn: use pathnames.h for paths
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2012-03-18 14:28:04 +01:00
Sami Kerola 3ca1029905 chfn: fix coding style
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2011-11-29 17:58:00 +01:00
Sami Kerola e55b7a8f2f chfn, setpwnam: let config.h be in control of extensions in use
The autotools will set _GNU_SOURCE which removes necessity to have
any _*_SOURCE definition in *.c files.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2011-11-29 17:58:00 +01:00
Sami Kerola 57b35f3ba7 chfn, chsh: new file pamfail.h for error printing
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2011-11-29 17:57:39 +01:00
Sami Kerola 8187b555df chfn, chsh, setpwnam: get true/false from stdbool.h
Requires C99, which should not be a problem.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2011-11-23 21:50:17 +01:00
Sami Kerola b9364124f8 chfn: use libc error printing facilities
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2011-11-23 21:35:26 +01:00
Sami Kerola 85b6104da5 chfn: align with howto-usage-function.txt
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2011-11-23 21:20:11 +01:00
Karel Zak 5c47aa72f2 chfn: remove non-PAM code
Signed-off-by: Karel Zak <kzak@redhat.com>
2011-11-03 12:32:50 +01:00
Karel Zak 5b66cfae91 chfn: remove non-ANSI definitions [smatch scan]
Signed-off-by: Karel Zak <kzak@redhat.com>
2011-09-13 11:21:47 +02:00
Karel Zak 8d48924681 chfn: fix compiler warnings [-Wsign-compare]
Signed-off-by: Karel Zak <kzak@redhat.com>
2011-08-01 16:19:54 +02:00
Fabian Groffen eb76ca98b0 build-sys: provide alternatives for err, errx, warn and warnx
Solaris lacks err, errx, warn and warnx.  This also means the err.h header
doesn't exist.  Removed err.h include from all files, and included err.h from
c.h instead if it exists, otherwise alternatives are provided.

Signed-off-by: Fabian Groffen <grobian@gentoo.org>
2011-02-14 17:45:24 +01:00
Fabian Groffen 0aeb57aca3 build-sys: improve check for crypt
Check for crypt.h existence, and use it if available over using unistd.h
for which a certain feature level has to be set to export a definition
for crypt.  On Solaris this set causes a standards conflict in the
headers, because at the time of this check C99 mode is already enabled,
which implies certain standards non-compatible with _XOPEN_SOURCE.

 92  #define _XOPEN_SOURCE
 93  #include <unistd.h>

configure:16259: gcc -std=gnu99 -c -g -O2  conftest.c >&5
In file included from /usr/include/unistd.h:18,
                 from conftest.c:93:
/prefix/gentoo/usr/lib/gcc/i386-pc-solaris2.10/4.4.5/include-fixed/sys/feature_tests.h:341:2: error: #error "Compiler or options invalid for pre-UNIX 03 X/Open applications and pre-2001 POSIX applications"

configure.ac: improve crypt check
login-utils/my_crypt.h: replace old GNU_LIBRARY check with autoconf
define for crypt.h

[kzak@redhat.com: - remove my_crypt.h]

Signed-off-by: Fabian Groffen <grobian@gentoo.org>
Signed-off-by: Karel Zak <kzak@redhat.com>
2011-01-17 16:32:39 +01:00
Marek Polacek 39941b4e38 chfn: Use EXIT_* and err()
[kzak@redhat.com: - clean usage() calls and some error messages]

Signed-off-by: Marek Polacek <mmpolacek@gmail.com>
2010-12-10 16:41:15 +01:00
Davidlohr Bueso 8abcf29002 lib: [strutils] general purpose string handling functions
This patch replaces a few functions used throughout the source:
* Renames getnum (from schedutils) to strtol_or_err
* Moves strtosize (from lib/strtosize.c)
* Moves xstrncpy (from include/xstrncpy.h)
* Adds strnlen, strnchr and strndup if not available (remove it from libmount utils)

A few Makefile.am files were modified to compile accordingly along with trivial renaming
in schedutils source code.

Signed-off-by: Davidlohr Bueso <dave@gnu.org>
2010-11-23 21:06:49 +01:00
Karel Zak ae7054723b chsh: don't suggest ypchsh
$ chsh
  chsh: can only change local entries; use ypchsh instead.

The 'ypchsh' is an external util that does not have to be installed.

Addresses: http://bugzilla.redhat.com/show_bug.cgi?id=497329
Signed-off-by: Karel Zak <kzak@redhat.com>
2010-07-29 16:08:20 +02:00
Karel Zak 26fb9222c4 chfn: several strings without gettext calls
Signed-off-by: Karel Zak <kzak@redhat.com>
2008-12-12 14:44:04 +01:00
Karel Zak ad067f1625 Revert "login-utils: several strings without gettext calls"
This reverts commit 64fefaf5bf.

It does not make sense to localize config options (wdays in
checktty.c) and debug messages (main() in checktty.c.
2008-12-12 14:33:29 +01:00
Pedro Ribeiro 64fefaf5bf login-utils: several strings without gettext calls
Signed-off-by: Pedro Ribeiro <p.m42.ribeiro@gmail.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
2008-10-03 09:13:20 +02:00
Karel Zak 4ba66edf82 selinux: is_selinux_enabled() returns 0, 1 and -1
Unfortunately, the current libselinux implementation of
is_selinux_enabled() returns -1 on error. This behavior is
undocumented.

The proper solution is to use "if (is_selinux_enabled() > 0)".

Signed-off-by: Karel Zak <kzak@redhat.com>
2008-07-01 14:32:53 +02:00
Benno Schulenberg 265095a2fe chfn, chsh, login: collapsing three similar messages into a single one
Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
2008-04-16 00:29:30 +02:00
Karel Zak 4a6964c839 chfn: add pam_end() call and cleanup PAM code
Signed-off-by: Karel Zak <kzak@redhat.com>
2007-10-04 00:22:36 +02:00
Karel Zak 48d7b13a1e Imported from util-linux-2.13-pre1 tarball. 2006-12-07 00:26:54 +01:00
Karel Zak 0b0bb92085 Imported from util-linux-2.12i tarball. 2006-12-07 00:26:22 +01:00
Karel Zak d03dd60840 Imported from util-linux-2.12a tarball. 2006-12-07 00:26:14 +01:00
Karel Zak ffc4374869 Imported from util-linux-2.11o tarball. 2006-12-07 00:25:53 +01:00
Karel Zak c07ebfa1e0 Imported from util-linux-2.11b tarball. 2006-12-07 00:25:46 +01:00