summaryrefslogtreecommitdiffstats
path: root/login-utils/chfn.c
Commit message (Collapse)AuthorAgeFilesLines
* chfn: don't append extra tailing commasKarel Zak2019-08-191-1/+1
| | | | | | | | | | | | | | | | | | | # grep kzak /etc/passwd kzak:x:1000:1000::/home/kzak:/bin/bash # chfn kzak ... grep kzak /etc/passwd old version: kzak:x:1000:1000:Karel Zak,,,,:/home/kzak:/bin/bash fixed version: kzak:x:1000:1000:Karel Zak:/home/kzak:/bin/bash Reported-by: Filip Dvorak <fdvorak@redhat.com> References: f723cbf544a7eac2927634f2cb6d802437a2d519 Signed-off-by: Karel Zak <kzak@redhat.com>
* misc: consolidate version printing and close_stdout()Karel Zak2019-04-161-3/+3
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* misc: consolidate macro style USAGE_HELP_OPTIONSRuediger Meier2017-06-291-1/+1
| | | | | | | | | changed in include/c.h and applied via sed: sed -i 's/fprintf.*\(USAGE_MAN_TAIL.*\)/printf(\1/' $(git ls-files -- "*.c") sed -i 's/print_usage_help_options\(.*\);/printf(USAGE_HELP_OPTIONS\1);/' $(git ls-files -- "*.c") Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
* misc: consolidate all --help option descriptionsRuediger Meier2017-06-271-2/+2
| | | | | | | | Now we are always using the same text also for commands which had still hardcoded descriptions or where we can't use the standard print_usage_help_options macro. Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
* misc: never use usage(stderr)Ruediger Meier2017-06-261-5/+8
| | | | | | | Here we fix all cases where we have usage(FILE*) functions. Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
* chfn: disable tab completionSami Kerola2017-05-191-0/+1
| | | | | | | The default readline tab completion that offers file listing from current directory does not make any sense in this context. Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* chfn, chsh: use readline(3) to receive user inputSami Kerola2017-05-031-10/+23
| | | | | | | The readline offers editing capabilities while the user is entering the line, unlike fgets(3) and getline(3) that were used earlier. Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* misc: do not use plain 0 as NULL [smatch scan]Sami Kerola2017-02-201-7/+7
| | | | | | | | | | text-utils/tailf.c:69:21: warning: Using plain integer as NULL pointer Since many 'struct option' has used zero as NULL make them more readable in same go by reindenting, and using named argument requirements. Reference: https://lwn.net/Articles/93577/ Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* Use --help suggestion on invalid optionKarel Zak2016-12-191-1/+1
| | | | | | | | The current default is to print all usage() output. This is overkill in many case. Addresses: https://github.com/karelzak/util-linux/issues/338 Signed-off-by: Karel Zak <kzak@redhat.com>
* chfn: chsh: use selinux_check_passwd_access()Karel Zak2016-06-141-2/+3
| | | | | | | | | | | * selinux/av_permissions.h and magic constants are deprecated, the recommended solution is to use string_to_security_class() and string_to_av_perm() to get access vector * it also seems that selinux_check_passwd_access() does exactly the same as our checkAccess(), let's use it. Signed-off-by: Karel Zak <kzak@redhat.com>
* chsh, chfn, vipw: fix filenames collisionKarel Zak2015-08-241-1/+1
| | | | | | | | | | | | | | | | | | The utils when compiled WITHOUT libuser then mkostemp()ing "/etc/%s.XXXXXX" where the filename prefix is argv[0] basename. An attacker could repeatedly execute the util with modified argv[0] and after many many attempts mkostemp() may generate suffix which makes sense. The result maybe temporary file with name like rc.status ld.so.preload or krb5.keytab, etc. Note that distros usually use libuser based ch{sh,fn} or stuff from shadow-utils. It's probably very minor security bug. Addresses: CVE-2015-5224 Signed-off-by: Karel Zak <kzak@redhat.com>
* textual: add a docstring to most of the utilitiesBenno Schulenberg2015-01-061-0/+4
| | | | | | | | | 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>
* chfn, chsh: share illegal_passwd_chars() functionSami Kerola2015-01-051-11/+5Star
| | | | Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* chfn: fix compilation without libuserKarel Zak2014-12-191-1/+1
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* chfn: make command to obey login.defs CHFN_RESTRICT instructionsSami Kerola2014-12-191-7/+76
| | | | | | 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>
* chfn: remove set_changed_data() and add add_missing()Sami Kerola2014-12-191-40/+39Star
| | | | | | | | 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>
* chfn: rename prompt() to ask_new_field()Sami Kerola2014-12-191-6/+7
| | | | Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* chfn: move new and old finger structs to chfn control structSami Kerola2014-12-191-89/+76Star
| | | | | | | | 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>
* chfn: clean up parse_argv()Sami Kerola2014-12-191-30/+18Star
| | | | | | | Use switch() case ?: for all option parsing, as in most of the other source files. Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* chfn: add minimalistic struct chfn_controlSami Kerola2014-12-191-8/+13
| | | | Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* chfn: simplify parse_passwd() by using strsep()Sami Kerola2014-12-191-36/+15Star
| | | | Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* chfn: fix usage() regressionSami Kerola2014-12-191-2/+2
| | | | | | | | Commit db433bf737a5fd4e1c7cca5e3603934743eebd1c 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>
* chfn: use xasprintf() rather than bunch of strlen() and malloc() callsSami Kerola2014-12-191-6/+3Star
| | | | Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* chfn: rewrite prompt() to use strutilsSami Kerola2014-12-191-39/+20Star
| | | | | | | | | | | | | | 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>
* chfn: remove function prototypesSami Kerola2014-12-191-142/+134Star
| | | | | | Requires resuffling functions order they work without issues. Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* textual: use usage() text element macrosSami Kerola2014-10-011-2/+2
| | | | | | | 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>
* textual: fix some typos and inconsistencies in various messagesBenno Schulenberg2014-07-231-1/+1
| | | | | | | | 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>
* chfn: assigned value is never read [clang-analyzer]Sami Kerola2013-07-091-1/+0Star
| | | | Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* chsh-chfn: fix bugs, improve compilationKarel Zak2013-02-131-8/+10
| | | | | | | | | | | | | | * 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>
* chfn: Add libuser supportCody Maloney2013-02-131-4/+23
| | | | Signed-off-by: Cody Maloney <cmaloney@theoreticalchaos.com>
* chsh-chfn: Move pam auth to its own function, factoring out common codeCody Maloney2013-02-131-30/+3Star
| | | | | | | 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>
* textual: spell and encode the name of Arkadiusz Miƛkiewicz correctlyBenno Schulenberg2013-02-061-1/+1
| | | | Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
* chfn: always use return rather than exit() in mainKarel Zak2012-12-121-4/+4
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* chfn: clean up exit statusKarel Zak2012-12-121-6/+5Star
| | | | | | | | 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>
* login-utils: verify writing to streams was successfulSami Kerola2012-04-041-0/+2
| | | | Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* chfn: use pathnames.h for pathsSami Kerola2012-03-181-2/+2
| | | | Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* chfn: fix coding styleSami Kerola2011-11-291-328/+367
| | | | Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* chfn, setpwnam: let config.h be in control of extensions in useSami Kerola2011-11-291-2/+0Star
| | | | | | | 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>
* chfn, chsh: new file pamfail.h for error printingSami Kerola2011-11-291-21/+9Star
| | | | Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* chfn, chsh, setpwnam: get true/false from stdbool.hSami Kerola2011-11-231-11/+8Star
| | | | | | Requires C99, which should not be a problem. Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* chfn: use libc error printing facilitiesSami Kerola2011-11-231-39/+26Star
| | | | Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* chfn: align with howto-usage-function.txtSami Kerola2011-11-231-5/+12
| | | | Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* chfn: remove non-PAM codeKarel Zak2011-11-031-18/+2Star
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* chfn: remove non-ANSI definitions [smatch scan]Karel Zak2011-09-131-22/+8Star
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* chfn: fix compiler warnings [-Wsign-compare]Karel Zak2011-08-011-1/+1
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* build-sys: provide alternatives for err, errx, warn and warnxFabian Groffen2011-02-141-1/+1
| | | | | | | | 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>
* build-sys: improve check for cryptFabian Groffen2011-01-171-1/+4
| | | | | | | | | | | | | | | | | | | | | | | | | 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>
* chfn: Use EXIT_* and err()Marek Polacek2010-12-101-82/+45Star
| | | | | | [kzak@redhat.com: - clean usage() calls and some error messages] Signed-off-by: Marek Polacek <mmpolacek@gmail.com>
* lib: [strutils] general purpose string handling functionsDavidlohr Bueso2010-11-231-1/+1
| | | | | | | | | | | | | 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>
* chsh: don't suggest ypchshKarel Zak2010-07-291-2/+1Star
| | | | | | | | | | $ 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>