summaryrefslogtreecommitdiffstats
path: root/login-utils/vipw.c
Commit message (Collapse)AuthorAgeFilesLines
* vipw: use xstrncpy()Karel Zak2019-05-201-6/+6
| | | | | | It's already used by vipw, so use it everywhere. Signed-off-by: Karel Zak <kzak@redhat.com>
* misc: consolidate version printing and close_stdout()Karel Zak2019-04-161-3/+2Star
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* vipw: use errexec()Karel Zak2018-02-011-2/+1Star
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* vipw: do not let editor to inherit open file descriptorsSami Kerola2017-12-041-2/+2
| | | | Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* vipw: use explicit_bzero() to clear buffer after copySami Kerola2017-08-051-0/+3
| | | | | | | | | | This should make leaking end of /etc/shadow file more unlikely. Notice that there is now way to tell to editors they should ensure none it does not leak any buffers, drop cores, and so on, when editing sensitive data. In short this change is addressing the issue only partially. Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* misc: consolidate macro style USAGE_HELP_OPTIONSRuediger Meier2017-06-291-2/+2
| | | | | | | | | 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: introduce print_usage_help_options()Ruediger Meier2017-06-271-2/+1Star
| | | | | | | | | | | | Consolidate --help and --version descriptions. We are now able to align them to the other options. We changed include/c.h. The rest of this patch was generated by sed, plus manually setting the right alignment numbers. We do not change anything but white spaces in the --help output. Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
* misc: cosmetics, remove argument from usage(FILE*)Ruediger Meier2017-06-261-3/+4
| | | | | | | | | | | | | | This patch is trivial and changes nothing, because we were always using usage(stdout) Now all our usage() functions look very similar. If wanted we could auto-generate another big cosmetical patch to remove all the useless "FILE *out" constants and use printf and puts rather than their f* friends. Such patch could be automatically synchronized with the translation project (newlines!) to not make the translators sick. Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
* vipw: use getopt_long() to parse optionsSami Kerola2017-05-101-7/+16
| | | | Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* misc: add static keyword to where needed [smatch scan]Sami Kerola2017-02-201-3/+3
| | | | | | | text-utils/rev.c:68:9: warning: symbol 'buf' was not declared. Should it be static? Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* misc: simplify if clauses [oclint]Sami Kerola2016-07-211-4/+3Star
| | | | Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* vipw: make tmp_file usage more robust [clang analyze]Karel Zak2016-03-291-2/+5
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* vipw: print only one new line when asking about shadow fileSami Kerola2016-03-151-2/+2
| | | | | | | | | Commit 11b86e1733 changed printf() to puts() in favour of more simple function, but forgot that puts() adds a new line to end of string. That new line is neither needed, or expected, so use fputs() that is both a simple printing function and comes without new line side effect. Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* vipw: use puts() when formatting unnecessaryKarel Zak2016-03-141-1/+2
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* misc: fix icc/clang compiler warningsRuediger Meier2016-03-131-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | clang warning: libmount/src/tab.c:1833:6: warning: variable 'rc' is used uninitialized whenever 'if' condition is true [-Wsometimes-uninitialized] if (!mpc) ^~~~ icc printf warnings: libmount/src/monitor.c(348): warning #2279: printf/scanf format not a string literal and no format arguments DBG(MONITOR, ul_debugobj(mn, status == 1 ? " success" : " nothing")); ^ login-utils/vipw.c(348): warning #2279: printf/scanf format not a string literal and no format arguments : _("You are using shadow passwords on this system.\n")); ^ icc enum warnings: disk-utils/fdisk-menu.c(150): warning #188: enumerated type mixed with another type .exclude = FDISK_DISKLABEL_GPT | FDISK_DISKLABEL_BSD, ^ libsmartcols/src/table_print.c(750): warning #188: enumerated type mixed with another type &width, align, ^ Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
* vipw: Remove pre-ANSI compiler supportRomain Naour2016-02-221-1/+1
| | | | | | | | | | | | | __P() is used for compatibility with old K&R C compilers. With ANSI C this macro has no effect. This fixes a compilation error with musl libc because of undeclared __P. Ref: https://lists.samba.org/archive/samba-technical/2015-June/108042.html Signed-off-by: Romain Naour <romain.naour@gmail.com>
* chsh, chfn, vipw: fix filenames collisionKarel Zak2015-08-241-2/+1Star
| | | | | | | | | | | | | | | | | | 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>
* rpmatch: use symbolic value when evaluation return codesSami Kerola2015-02-241-1/+1
| | | | Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* 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>
* docs: update deprecation bannersSami Kerola2014-10-011-9/+0Star
| | | | Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* vipw: add usage() functionSami Kerola2013-04-051-4/+19
| | | | Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* add missing rpmatch.h everywhere it needs to beWilliam Pitcock2013-02-201-0/+1
| | | | | Signed-off-by: William Pitcock <nenolod@dereferenced.org> Signed-off-by: Karel Zak <kzak@redhat.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>
* vipw: remove unused set{uid,gid} callsKarel Zak2012-12-041-6/+2Star
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* vipw: make vim writebackup mode workSami Kerola2012-08-061-0/+12
| | | | | | | | | | | | Some editors, such as Vim with 'writebackup' mode enabled, use "atomic save" in which the old file is deleted and a new one with the same name created in its place. The vipw tries to detect if such happen by looking hard temporary file link count, when it is zero reopen temporary file by using it's path. Reported-by: Mantas Mikulėnas <grawity@gmail.com> References: http://www.spinics.net/lists/util-linux-ng/msg06666.html Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* vipw: add noreturn function attributeSami Kerola2012-07-261-1/+2
| | | | Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* translation: unify file open error messagesSami Kerola2012-07-161-1/+1
| | | | Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* fileutils: xmkstemp() interface changeDave Reisner2012-06-021-1/+2
| | | | | | | | | | | We can not let the user control where TMPDIR is for this tempfile. This will be where we write the updated passwd file, and must be capable of being moved atomically with rename(2). Therefore, it cannot be on a different device, or setpwnam() and vipw/vigr programs will invariably fail with EXDEV. Signed-off-by: Dave Reisner <dreisner@archlinux.org> Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* login-utils: add missing header, fix setpwnam.c fclose logicKarel Zak2012-04-111-0/+1
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* login-utils: verify writing to streams was successfulSami Kerola2012-04-041-2/+4
| | | | Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* fileutils: differentiate xmkstemp and xfmkstempSami Kerola2012-03-181-1/+1
| | | | | | | | | | | | Let developer to choose, case by case, what sort of return value is best in her code. The xmkstemp() is for users who want file descriptor as return value of the function, xfmkstemp() will return FILE pointer. Proposed-By: Karel Zak <kzak@redhat.com> CC: Davidlohr Bueso <dave@gnu.org> Reference: http://marc.info/?l=util-linux-ng&m=133129570124003&w=2 Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* vipw: use xmkstemp() and lckpwdf()Sami Kerola2012-03-181-62/+38Star
| | | | | | Get rid private locking schema and use libc instead. Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* vipw: use rpmatch to yes/no questionSami Kerola2012-03-181-2/+3
| | | | Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* docs: add deprecation commentsSami Kerola2012-03-181-0/+9
| | | | | | | Markup deprecation to command header to avoid people wasting time in fixing these utilities. Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* vipw: use xalloc.hKarel Zak2012-02-061-1/+4
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* vipw: don't modify environment, check strtok() return valueKarel Zak2012-02-011-4/+6
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* vipw: fix coding styleSami Kerola2011-11-291-84/+83Star
| | | | Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* vipw: stop printing non-sense version stringSami Kerola2011-11-231-3/+1Star
| | | | Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* vipw: use libc error printing facilitiesSami Kerola2011-11-231-32/+17Star
| | | | Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* misc: use %m in format string instead of %s and strerror(errno)Petr Uzel2011-09-271-2/+1Star
| | | | Signed-off-by: Petr Uzel <petr.uzel@suse.cz>
* 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>
* vipw: fix warn_unused_result gcc warningKarel Zak2010-12-101-1/+3
| | | | | | | vipw.c:194:6: warning: ignoring return value of ‘link’, declared with attribute warn_unused_result Signed-off-by: Karel Zak <kzak@redhat.com>
* vipw: use EXIT_* and err()Marek Polacek2010-12-101-22/+22
| | | | | | | [kzak@redhat.com: - fix one error message] Signed-off-by: Marek Polacek <mmpolacek@gmail.com> Signed-off-by: Karel Zak <kzak@redhat.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>
* replace bcopy,bzero,index and rindexDaniel Mierswa2009-08-171-2/+2
| | | | | | | | | Those 4 functions are marked as LEGACY in POSIX.1-2001 and removed in POSIX.1-2008. Replaced with memmove,memset,strchr and strrchr. Signed-off-by: Daniel Mierswa <impulze@impulze.org>
* selinux: is_selinux_enabled() returns 0, 1 and -1Karel Zak2008-07-011-1/+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>
* vipw: fix permissions (600->400) for edited /etc/[g]shodow filesKarel Zak2007-02-151-3/+1Star
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* Imported from util-linux-2.13-pre1 tarball.Karel Zak2006-12-071-2/+2
|
* Imported from util-linux-2.12a tarball.Karel Zak2006-12-071-0/+24
|
* Imported from util-linux-2.11m tarball.Karel Zak2006-12-071-82/+87
|