summaryrefslogtreecommitdiffstats
path: root/login-utils
Commit message (Collapse)AuthorAgeFilesLines
* chfn: improve formatting and wording of the manpageBenno Schulenberg2015-11-091-11/+10Star
| | | | Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
* login: fix stat(2) raceSami Kerola2015-11-091-4/+2Star
| | | | Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* nologin: require /etc/nologin.txt to be fileSami Kerola2015-10-181-1/+4
| | | | | | | This makes silly practical jokes impossible, like for example symlinking /dev/null or dev/random to /etc/nologin.txt Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* last: display input file in usage() according to command nameSami Kerola2015-10-181-9/+8Star
| | | | | | | Default depends on whether the executable is called 'lastb' or something else. Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* sulogin: Use fallback method on the Hurd for detecting consolesJames Clarke2015-10-161-0/+8
| | | | Signed-off-by: James Clarke <jrtc27@jrtc27.com>
* login: replace siginterrupt with sigactionChen Qi2015-08-311-1/+4
| | | | | | [kzak@redhat.com: - POSIX.1-2008 marks siginterrupt() as obsolete] Signed-off-by: Chen Qi <Qi.Chen@windriver.com>
* chfn: document CHFN_RESTRICT /etc/login.defsKarel Zak2015-08-241-0/+26
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* chsh, chfn, vipw: fix filenames collisionKarel Zak2015-08-245-8/+10
| | | | | | | | | | | | | | | | | | 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>
* lslogins: remove duplicate [make checkincludes]Karel Zak2015-07-291-1/+0Star
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* lslogins: merge read_utmp() codeKarel Zak2015-07-161-2/+32
| | | | | | | The code is used only in lslogins, so it does not make sense to maintain it in libcommon. Signed-off-by: Karel Zak <kzak@redhat.com>
* lslogins: fix --user-accs and --system-accs docsKarel Zak2015-07-151-8/+8
| | | | | Reported-by: Mantas Mikulėnas <grawity@gmail.com> Signed-off-by: Karel Zak <kzak@redhat.com>
* Merge branch 'sulogin'Karel Zak2015-06-302-16/+40
|\
| * sulogin: improve support for locked root accountKarel Zak2015-06-252-16/+40
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Some installations and distributions don't use a root account password for security reasons and use sudo instead. In that case, asking for the password makes no sense, and it is not even considered as valid as it's just "*" or "!". In these cases --force is required to just start a root shell and no ask for password. I don't think it's a good idea to automatically start root shell when locked account is detected. It's possible that the machine is on public place and for example Ubuntu uses root account disabled by default (and also Fedora when installed by yum/dnf without anaconda). The --force option forces admins to think about it... The distro maintainers can also use --force in their initscripts or systemd emergency.service if they believe that promiscuous setting is the right thing for the distro. Addresses: https://bugs.debian.org/326678 Signed-off-by: Karel Zak <kzak@redhat.com>
* | last-deprecated: remove from source treeSami Kerola2015-06-293-552/+0Star
|/ | | | | | | | | The last/lastb(1) from sysvinit has been around for about two years, and the better implementation is already part of releases 2.24 to 2.26. It should be safe to remove the unused last code from the source tree. Reference: ce60272039ea11952b15fefb653892dd0da02217 Signed-off-by: Sami Kerola <sami.kerola@lastminute.com>
* sulogin: Use read instead of allocated size from getline()Guillem Jover2015-06-081-2/+4
| | | | | | | | The getline function distinguishes between the allocated and read lenghts, and we should not mix them up, as we might end up processing junk. Signed-off-by: Guillem Jover <guillem@hadrons.org>
* sulogin: don't use strcpy(), enlarge pwd line bufferKarel Zak2015-05-251-7/+7
| | | | | | | | | * according to "man getpwnam" 16384 bytes is enough to store one passwd entry (let's use 2*BUFSIZE to avoid magic numbers in code) * don't use strcpy() to set empty password Signed-off-by: Karel Zak <kzak@redhat.com>
* last, fix race when comparing time stampsRuediger Meier2015-03-251-4/+4
| | | | | | | | | | | | | It is just luck if two time() calls happen within the same second. Introduced in 31d28e09. Actually I don't like adding another global variable but this way we avoid bigger refactoring. IMO it's questionable why lastdate, lastdown, etc. are initialized with current time() at all. It looks unsafe to print "still running" always when logout_time = now. Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
* last: fix first (current) runlevel lineRuediger Meier2015-03-251-1/+1
| | | | | | | | | | | | | | | | Since 744c7fec lastrch was not set to current time anymore, but we need it. # broken: $ ./last -x | grep -m 2 runlevel runlevel (to lvl 5) 3.11.10-25-deskt Wed Feb 18 13:11 - 01:00 (-16484+-12:-11) runlevel (to lvl 5) 3.11.10-25-deskt Thu Jan 22 16:50 - 13:11 (26+20:21) # fixed: $ ./last -x | grep -m 2 runlevel runlevel (to lvl 5) 3.11.10-25-deskt Wed Feb 18 13:11 still running runlevel (to lvl 5) 3.11.10-25-deskt Thu Jan 22 16:50 - 13:11 (26+20:21) Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
* last: keep array of files in main()Karel Zak2015-03-131-32/+22Star
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* last: fix utmplist usageKarel Zak2015-03-131-16/+21
| | | | | | | | | | | | | last(1) uses a global list of entries, this is unnecessary and it's also mistake because the pointer to the list is not set to NULL when last(1) opens another utmp file. For example: last -f /var/log/wtmp -f /var/log/wtmp-20150220 ends with unexpected free() call or sometimes with never ending loop. Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=1201033 Signed-off-by: Karel Zak <kzak@redhat.com>
* build-sys: cleanup realtime lib usageKarel Zak2015-03-061-1/+1
| | | | | | | | * check for timer_create() * define dependence on timer_create() for flock * rename CLOCKGETTIME_LIBS to REALTIME_LIBS Signed-off-by: Karel Zak <kzak@redhat.com>
* docs: fix some spelling errors and typos in man pagesBill Pemberton2015-02-273-3/+3
| | | | | | | | | | | | | runuser.1: fix spelling implemenation -> implementation scriptreplay.1: fix spelling overide -> override unshare.1: fix spelling permamently -> permanently last.1: fix spelling preferrable -> preferable lslogins.1: fix spelling priviliges -> privileges hwclock.8.in: fix spelling transfered -> transferred prlimit.1: fix typo umlimited -> unlimited agetty.8: fix typo unnsupported -> unsupported Signed-off-by: Bill Pemberton <wfp5p@worldbroken.com>
* rpmatch: use symbolic value when evaluation return codesSami Kerola2015-02-241-1/+1
| | | | Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* sulogin, hwclock: use xusleep() instead of usleep()Sami Kerola2015-02-101-1/+1
| | | | | | | As said in include/c.h the usleep() is marked as obsolete, so do the same that most of the other util-linux calls do with this interface. Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* textual: grammarize and harmonize the stat error messageBenno Schulenberg2015-02-022-2/+2
| | | | | | | | | 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>
* utmpdump: don't pass parameter of type "struct utmp" by value [coverity scan]Karel Zak2015-01-291-15/+15
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* sulogin: make sure that fallback FD is valid [coverity scan]Karel Zak2015-01-291-1/+1
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* su: fix mem leak in modify_environ() [coverity scan]Karel Zak2015-01-291-2/+4
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* login: fix mem leak in init_environ() [coverity scan]Karel Zak2015-01-291-3/+5
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* docs: restore minus symbols in long optsJ William Piggott2015-01-215-12/+12
| | | | Signed-off-by: J William Piggott <elseifthen@gmx.com>
* docs: fix-up man-pages flaged by checkmans.shJ William Piggott2015-01-131-1/+0Star
| | | | | | | | | 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>
* docs: remove obsolete and unneeded comments from man-page filesBenno Schulenberg2015-01-122-3/+2Star
| | | | | | | 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>
* maint: fix shadow declarationSami Kerola2015-01-071-16/+16
| | | | | | | | | | | | | | | | 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>
* textual: add a docstring to most of the utilitiesBenno Schulenberg2015-01-0610-1/+33
| | | | | | | | | 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>
* chsh: keep struct options in .rodataKarel Zak2015-01-061-1/+1
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* chsh: simplify get_shell_list()Karel Zak2015-01-061-8/+5Star
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* newgrp: set function arguments read-only when possibleSami Kerola2015-01-051-3/+3
| | | | Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* newgrp: move shell determination closer where it is usedSami Kerola2015-01-051-5/+3Star
| | | | Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* newgrp: simplify if else clausesSami Kerola2015-01-051-7/+4Star
| | | | | | | | 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>
* chsh: fail get_shell_list() check when /etc/shells cannot be openedSami Kerola2015-01-051-5/+3Star
| | | | | | And get rid of stdbool.h true/false usage. Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* chsh: simplify check_shell()Sami Kerola2015-01-051-33/+16Star
| | | | | | | | | | | 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>
* chsh: rewrite function interacting with user to get path to new shellSami Kerola2015-01-051-24/+19Star
| | | | | | | | 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>
* chsh: clean up parse_argv()Sami Kerola2015-01-051-8/+3Star
| | | | Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* chsh: allow user to set shell to /bin/sh if none is setSami Kerola2015-01-051-2/+5
| | | | | | | 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>
* chsh: set few variables read-only and rename one of themSami Kerola2015-01-051-19/+13Star
| | | | | | This change also improves couple variable initializations. Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* chsh: use getline() to support arbitrarily long linesSami Kerola2015-01-051-7/+8
| | | | | | | | 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>
* chfn, chsh: share illegal_passwd_chars() functionSami Kerola2015-01-055-25/+53
| | | | Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* chsh: remove function prototypesSami Kerola2015-01-051-147/+143Star
| | | | 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-192-8/+81
| | | | | | 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>