summaryrefslogtreecommitdiffstats
path: root/login-utils
Commit message (Collapse)AuthorAgeFilesLines
* Revert "su,runuser: add libseccomp based workaround for TIOCSTI ioctl"Karel Zak2016-10-032-24/+3Star
| | | | | | This reverts commit 8e4925016875c6a4f2ab4f833ba66f0fc57396a2. Stupid hack...
* su,runuser: add libseccomp based workaround for TIOCSTI ioctlKarel Zak2016-09-292-3/+24
| | | | | | | | | | | This patch add libseccomp based syscalls filter to disable TIOCSTI ioctl in su/runuser children. IMHO it is not elegant solution due to dependence on libseccomp (--without-seccomp if hate it)... but there is nothing better for now. Addresses: CVE-2016-2779 Signed-off-by: Karel Zak <kzak@redhat.com>
* su, runuser, setpriv: create links between man pagesKarel Zak2016-08-182-1/+17
| | | | | | | .. and add notes about differences between the utuils. Reported-by: Lennart Poettering <lennart@poettering.net> Signed-off-by: Karel Zak <kzak@redhat.com>
* include/env: minor fixes and clean upsKarel Zak2016-08-161-3/+4
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* misc: always check setenv(3) return valueSami Kerola2016-08-123-19/+23
| | | | | | At least glibc setenv(3) can fail when system runs out of memory. Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* misc: fix declarations shadowing variables in the global scope [oclint]Sami Kerola2016-07-212-6/+6
| | | | | | Fixes multiple occurences of 'optarg' overwrites. Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* lslogins: simplify if clause and move definition and comments [oclint]Sami Kerola2016-07-211-11/+9Star
| | | | | | | | The if clause change is pretty trivial. Moving the macro near to where it is used makes sense to people who want to read the code. And finally the comment about user list was at wrong spot. Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* misc: simplify if clauses [oclint]Sami Kerola2016-07-213-11/+7Star
| | | | Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* Merge branch 'write-improvements' of git://github.com/kerolasa/lelux-utiliteetitKarel Zak2016-07-142-3/+3
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * 'write-improvements' of git://github.com/kerolasa/lelux-utiliteetit: lib: try to find tty in get_terminal_name() write: stop removing and adding /dev/ in front of tty string write: tell when effective gid and tty path group mismatch write: improve coding style write: remove PUTC macro write: make timestamp to be obviously just a clock time write: remove unnecessary utmp variables write: improve function and variable names write: add control structure to clarify what is going on write: run atexit() checks at the end of execution write: use xstrncpy() from strutils.h write: set atime value in term_chk() only when needed write: remove pointless fileno(3) calls write: get rid of function prototypes write: remove unused variable
| * lib: try to find tty in get_terminal_name()Sami Kerola2016-07-042-3/+3
| | | | | | | | | | | | | | | | Try all standard terminal input/output file descriptors when finding tty name in get_germinal_name(). This should make all invocations of the function as robust as they can get. Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* | sulogin: remove __nonnull__ function attributeSami Kerola2016-07-141-1/+1
|/ | | | | | | | | | | | | This change fixes compiler option -Werror=nonnull option warning: login-utils/sulogin-consoles.c: In function 'append_console': login-utils/sulogin-consoles.c:324:14: warning: nonnull argument 'consoles' compared to NULL [-Wnonnull-compare] The NULL check done with list_empty() looks valid, so it is best to remove the function attribute that allows compiler to optimize the check away. Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* docs: add file format note to utmpdump manual pageSami Kerola2016-06-271-0/+12
| | | | | | | | Tell that the old textual format that does not use full utmp time precision, and has issues with timezones. Warn also that the textual format may become incompatible, although there are no plans in foreseeable future to do so. Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* utmpdump: use iso-8601 timestamp format with subsecond accuracySami Kerola2016-06-262-26/+38
| | | | | | | | | | Newer 'struct utmp' is using 'struct timeval' to represent login and logout times, so include the maximum accuracy to textual utmp format. Notice that this change does not remove support of converting earlier textual formats back to binary. But conversions from binary to former format will no longer be available. Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* utmpdump: use always UTC-0 timezone in textual outputSami Kerola2016-06-261-3/+3
| | | | | | | | | | | | | | | Converting a time structure from text format that has timezone markup is practically impossible. See reference links for more information. This leads to situation where multiple utmpdump(1) conversions from binary to text and back make timestamps to shift amount of timezone offset to UTC-0. The easiest way to make multiple conversions to work without timeshifts is to always use UTC-0 timezone. Downside of this approach is that the textual format is less human readable than local timestamps would be. Reference: http://www.catb.org/esr/time-programming/#_strptime_3_and_getdate_3 Reference: http://man7.org/linux/man-pages/man3/strptime.3.html Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* chfn: chsh: use selinux_check_passwd_access()Karel Zak2016-06-144-31/+16Star
| | | | | | | | | | | * 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>
* misc: Fix various typosSebastian Rasmussen2016-05-316-9/+9
| | | | | | | Fix various typos in error messages, warnings, debug strings, comments and names of static functions. Signed-off-by: Sebastian Rasmussen <sebras@gmail.com>
* docs: Fix various typosSebastian Rasmussen2016-05-311-1/+1
| | | | Signed-off-by: Sebastian Rasmussen <sebras@gmail.com>
* build-sys: add --disable-plymouth-supportKarel Zak2016-05-261-4/+5
| | | | | | | | The plymouth support depends on Linux specific SOCK_* flags and all the feature is probably unnecessary in some cases (non-plymouth distros, etc.) Signed-off-by: Karel Zak <kzak@redhat.com>
* last: fix logout timeKarel Zak2016-05-241-4/+5
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* lslogins: use strtime_short()Karel Zak2016-05-241-31/+19Star
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* lslogins: use strtm_iso()Karel Zak2016-05-241-1/+5
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* last: cleanup time formatting codeKarel Zak2016-05-241-48/+66
| | | | | | | | | | - describe difference between login and logout time formats in struct last_timefmt - use strtime_iso() - rename LAST_TIMEFTM_SHORT_CTIME to LAST_TIMEFTM_SHORT - rename LAST_TIMEFTM_FULL_CTIME to LAST_TIMEFTM_CTIME - add LAST_TIMEFTM_HHMM for internal purpose (logout format for "--time-format short") Signed-off-by: Karel Zak <kzak@redhat.com>
* sulogin: agetty: use the plymouth local protocol instead the plymouth binaryWerner Fink2016-05-201-40/+4Star
| | | | | | | | | | | | | for stopping plymouthd. That do not depend on the existence of the plymouth binary if it e.g. becomes uninstalled or an other service is providing plymouthd facilities. [kzak@redhat.com: - fix compiler warnings [-Wpointer-sign] - use sizeof() for write_all() - cast to char* for read_all] Signed-off-by: Werner Fink <werner@suse.de> Signed-off-by: Karel Zak <kzak@redhat.com>
* setpwnam: fix memory leakSami Kerola2016-04-191-0/+1
| | | | | | Found with scan-build. Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* sulogin: make fopen O_CLOEXEC specifier usage portableSami Kerola2016-04-171-2/+2
| | | | | | | | The close at exit specifier "e" is glibc extension, so use it only if when the extension is available. Proposed-by: Ruediger Meier <sweet_f_a@gmx.de> 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>
* 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>