summaryrefslogtreecommitdiffstats
path: root/login-utils
Commit message (Collapse)AuthorAgeFilesLines
* sulogin: Always make echo work after performing getpasswd even if root ↵Werner Fink2016-03-221-2/+1Star
| | | | | | | | | | account is locked If the root account is locked and no password was provided then the terminal line is not set back to do echo of the input. This correct a small overlook in commit 7ff1162e67164cb4ece19dd809c26272461aa254 Signed-off-by: Werner Fink <werner@suse.de>
* sulogin: ignore missing WEXITED, add warningRuediger Meier2016-03-211-0/+5
| | | | | | | | This happens on Debian kFreeBSD and probably on Hurd too since cde7699c. One should review this issue to fix it properly. CC: Werner Fink <werner@suse.de> Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
* 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>
* Merge branch 'travis-osx' of https://github.com/rudimeier/util-linuxKarel Zak2016-03-141-1/+1
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * 'travis-osx' of https://github.com/rudimeier/util-linux: travis: add OSX build travis: switch to Ubuntu 14.04 Trusty build-sys: improve uuidd and script build conditions build-sys: use AC_PROG_MKDIR_P and remove a few gnuisms build-sys: add missing "not found" strings build-sys: fix again UL_SCANF_TYPE_MODIFIER tests: don't use system's mount commands tests: improve skipping of old btrfs-tools tests: remove invalid argument in libmount/debug tests: skip old socat silently misc: fix icc/clang compiler warnings misc: fix printf i386 compiler warnings
| * 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>
* | sulogin: fix sigset_t initializationKarel Zak2016-03-141-1/+1
|/ | | | | Reported-by: Samuel Thibault <samuel.thibault@ens-lyon.org> Signed-off-by: Karel Zak <kzak@redhat.com>
* include: move sys/sysmacros.h to c.hKarel Zak2016-03-081-3/+0Star
| | | | | | | The file is no portable (#ifdef HAVE_SYS_SYSMACROS_H is necessary), but needed on many places. It seems better to keep it in c.h. Signed-off-by: Karel Zak <kzak@redhat.com>
* Revert "include sysmacros.h where used"Karel Zak2016-03-081-1/+0Star
| | | | This reverts commit 46a40c018438b7b2b25083a5e5a4a21055a0c1e9.
* include sysmacros.h where usedMike Frysinger2016-03-081-0/+1
| | | | | | | | BSD/Linux systems stick major/minor/makedev in sysmacros.h. Newer Linux libraries have been moving away from including sysmacros.h implicitly via sys/types.h, so include it directly. Signed-off-by: Mike Frysinger <vapier@gentoo.org>
* libmount: don't include libio.hRuediger Meier2016-03-071-1/+1
| | | | | | | This include was added just one month ago in 5a971329 but I don't see what it was good for. It's missing in musl libc. Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
* misc: never cast void* from malloc(3) and friendsRuediger Meier2016-03-071-1/+1
| | | | | | | | | | Such cast could hide serious compiler warnings in case we are missing includes (e.g. <stdlib.h> or "xalloc.h"). See http://stackoverflow.com/questions/605845/do-i-cast-the-result-of-malloc Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
* misc: safer (and uniform) handling of return valueYuriy M. Kaminskiy2016-03-072-2/+2
| | | | | | When `rc` is `INT_MAX`, `rc + 1` result in signed integer overflow. Signed-off-by: Karel Zak <kzak@redhat.com>
* login-utils: minor utmp cleanupRuediger Meier2016-02-292-2/+1Star
| | | | | | | - consistently use ut->ut_user instead of ut->ut_name - don't include obsolete lastlog.h BSD header Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
* newgrp: rename memset_s()Ruediger Meier2016-02-291-2/+2
| | | | | | It's already defined in OSX standard c library. Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
* build-sys: always add AM_CFLAGSRuediger Meier2016-02-231-1/+1
| | | | | | | | We were missing our nice compliler warnings for many programs and libs. See next commits how many trivial and non-trival warnings have to be fixed. Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
* build-sys: always use global LDADDRuediger Meier2016-02-231-1/+1
| | | | | | | | This was a major showstopper when building on a system where LTLIBINTL libs are needed (e.g. OSX). Maybe there are a few test programs which wouldn't need LDADD ... never mind. 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>
* include: check for sys/sysmacros.hRuediger Meier2016-02-181-0/+2
| | | | Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
* su: clean up groups initializationKarel Zak2016-02-153-34/+42
| | | | | | | | | | | | | | | | This patch does not change any su/runuser behaviour, code changes: * don't use huge groups[NGROUPS_MAX]; the array has 256k, but we need it only occasionally when -G/-g specified. * the current code uses groups[0] for -g and the rest for -G, this patch adds 'gid' to remember -g argument to avoid memmove() * add function add_supp_group() to simplify su_main() * add note about -G and -g relation to the man pages (undocumented now) Signed-off-by: Karel Zak <kzak@redhat.com>
* sulogin: keep initialization more robustKarel Zak2016-02-121-1/+1
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* sulogin: avoid shared memory area usemask but use waitid() for childsWerner Fink2016-02-122-37/+120
| | | | | | | | | This small patch improves the console detection code and also avoids not existing device nodes due strdup() which is used in canonicalize_path(). Beside this now the code for emergeny mount does work if enabled at configure time. Signed-off-by: Werner Fink <werner@suse.de>
* docs: fix typos found by codespellRuediger Meier2016-02-032-2/+2
| | | | | | Using "codespell" from https://github.com/lucasdemarchi/codespell Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
* scriptreplay/newgrp: use signed int to store return of getopt_longFilipe Brandenburger2016-01-071-1/+1
| | | | Signed-off-by: Filipe Brandenburger <filbranden@google.com>
* lslogins: fix getgrouplist() usage for 64BEKarel Zak2015-12-211-4/+8
| | | | | | | | | | | | | | on ppc64: $ lslogins kzak $ lslogins: cannot allocate 85899345920 bytes: Cannot allocate memory because (int *) len where len is pointer to size_t is bad idea... Signed-off-by: Karel Zak <kzak@redhat.com>
* login, mount: fix __SC_GETPW_R_SIZE_MAX usageKarel Zak2015-12-151-10/+2Star
| | | | | | | | | | sysconf(_SC_GETPW_R_SIZE_MAX) returns initial suggested size for pwd buffer (see getpwnam_r man page or POSIX). This is not large enough in some cases. Yes, this sysconf option is misnamed (should be _SC_GETPW_R_SIZE_MIN). Signed-off-by: Karel Zak <kzak@redhat.com>
* 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>