summaryrefslogtreecommitdiffstats
path: root/login-utils/login.c
Commit message (Collapse)AuthorAgeFilesLines
* 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>
* textual: add some guiding comments for translatorsBenno Schulenberg2011-08-021-0/+1
| | | | | | These are picked up by xgettext and put in the POT file. Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
* login: fix compiler warnings [-Wunused-parameter -Wsign-compare]Karel Zak2011-08-011-4/+4
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* login: cleanup unused variablesKarel Zak2011-06-081-6/+9
| | | | | | | | login.c: In function ‘main’: login.c:389:40: warning: variable ‘errsv’ set but not used [-Wunused-but-set-variable] login.c:389:9: warning: variable ‘ask’ set but not used [-Wunused-but-set-variable] Signed-off-by: Karel Zak <kzak@redhat.com>
* login: does not ignore setgid() return code for non-rootsKarel Zak2011-02-171-1/+5
| | | | | Reported-by: Steve Grubb <sgrubb@redhat.com> 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>
* login: fix "ignoring return value" errorsKarel Zak2010-12-101-10/+26
| | | | | | | | | | | | | | | login.c:542:8: warning: ignoring return value of ‘fchown’, declared with attribute warn_unused_result login.c:1013:11: warning: ignoring return value of ‘fchown’, declared with attribute warn_unused_result login.c: In function ‘dolastlog’: login.c:1452:7: warning: ignoring return value of ‘write’, declared with attribute warn_unused_result login.c: In function ‘motd’: login.c:1391:7: warning: ignoring return value of ‘write’, declared with attribute warn_unused_result Signed-off-by: Karel Zak <kzak@redhat.com>
* login: use EXIT_* and err.h, clean up return codesMarek Polacek2010-12-101-49/+41Star
| | | | | | | | [kzak@redhat.com: - cleanup return codes - use warn()] Signed-off-by: Marek Polacek <mmpolacek@gmail.com> Signed-off-by: Karel Zak <kzak@redhat.com>
* login: use xalloc libDavidlohr Bueso2010-11-301-7/+2Star
| | | | Signed-off-by: Davidlohr Bueso <dave@gnu.org>
* 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>
* login: check that after tty reopen we still work with a terminalKarel Zak2010-01-281-9/+13
| | | | | | | | | | | | | | * the login code assumes that stdin is a terminal, it's better to check (by isatty()) that after tty reopen we still have a terminal * this patch also removes very old obscure fallback for situations where ttyname() returns nothing (then ttyn = "/dev/tty??"). I guess that the fake string was originally for utmp records or so. Currently (in last 10 years...) code requires that the tty name is a real open-able file. It means the fake tty name is completely useless. Reported-by: Yann Droneaud <yann@droneaud.fr> Signed-off-by: Karel Zak <kzak@redhat.com>
* login: use fd instead of pathname for update tty's owner and permissionsYann Droneaud2010-01-281-4/+4
| | | | | | | To avoid some nasty races, use the only true tty: the one already opened, don't use the path. Signed-off-by: Yann Droneaud <yann@droneaud.fr>
* replace bcopy,bzero,index and rindexDaniel Mierswa2009-08-171-3/+3
| | | | | | | | | 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>
* include: clean up _PATH_DEV_* macrosKarel Zak2009-06-301-2/+2
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* login: use open(2) rather then access(2) for $HOME/.hushloginKarel Zak2009-04-101-1/+16
| | | | | | | | | | As an NFS client with home directories on mounted NFS share - If the NFS server exports the share with default root squashed, login cannot access the filesystem to check for the existence of .hushlogin file. It seems better to use open(2) rather than access(2). Signed-off-by: Karel Zak <kzak@redhat.com>
* login: use "remote" as a PAM service name for "login -h"Karel Zak2009-03-171-1/+1
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* login: cleanup includesKarel Zak2008-11-261-5/+2Star
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* login: fix compiler warning (int32 time() arg)Karel Zak2008-09-291-1/+7
| | | | | | | | | | | | | | | | | login.c: In function ‘dolastlog’: login.c:1438 warning: passing argument 1 of ‘time’ from incompatible pointer type Unfortunately, on-disk lastlog format is always 32bit, bits/utmp.h: struct lastlog { #if __WORDSIZE == 64 && defined __WORDSIZE_COMPAT32 int32_t ll_time; #else __time_t ll_time; #endif Signed-off-by: Karel Zak <kzak@redhat.com>
* login: fix warning "dereferencing type-punned pointer will break ↵Karel Zak2008-09-011-4/+17
| | | | | | | | | strict-aliasing rules" This patch fix problems with odd pam_get_iten( ..., void **) API. (tested by gcc-4.1.2-42.el5.i386) Signed-off-by: Karel Zak <kzak@redhat.com>
* login: audit log injection attack via loginSteve Grubb2008-04-211-7/+3Star
| | | | | | | | | | | | | A while back I found a couple audit log injection attacks which became CVE-2007-3102. I forgot to look at login to see if its vulnerable and Mirek found that it is. To verify the problem, type: root addr=xyz.com for the account name while logging in. It will look like root logged in with an address of xyz.com. Signed-off-by: Steve Grubb <sgrubb@redhat.com>
* chfn, chsh, login: collapsing three similar messages into a single oneBenno Schulenberg2008-04-161-2/+2
| | | | Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
* login: fix a small memory leak and remove unnecessary zeroingKarel Zak2008-01-281-2/+6
| | | | | | | | | This patch fix a small memory leak (rh#251539) and also remove unnecessary pam_set_item(). We needn't to zeroing PAM_USER when the value is already NULL, it doesn't make sense. Addresses-Red-Hat-Bugzilla: #251539 Signed-off-by: Karel Zak <kzak@redhat.com>
* login: replace termio with termios interfaceSamuel Thibault2008-01-031-3/+3
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* include: cleanup pathnames.hKarel Zak2007-11-281-1/+1
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* login: login segfaults on EOF (rh#298461)Karel Zak2007-09-211-2/+2
| | | | | | | | | | | Stupid bug in audit code: $ login login: ^D login: ^D Segmentation fault Signed-off-by: Karel Zak <kzak@redhat.com>
* login: remove triiling white-spacesKarel Zak2007-03-121-92/+92
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* login: add audit supportKarel Zak2007-03-121-0/+34
| | | | | | | The login command reports AUDIT_USER_LOGIN message to audit system (depends on --with-audit). Signed-off-by: Karel Zak <kzak@redhat.com>
* login: add IPv6 supportKarel Zak2007-03-101-10/+27
| | | | | | | | | | This support includes: * non-PAM version supports IPv6 ranges in /etc/usertty * utmp records with IPv6 addresses Based on patch by: Milan Zazrivec <mzazrivec@redhat.com> Signed-off-by: Karel Zak <kzak@redhat.com>
* login: update 32bit utmp correctly on 64bit systemKarel Zak2007-03-081-2/+8
| | | | | | | | | | | On 64-bit platforms such as x86_64, glibc is usually built with 32-bit compatibility for various structures. One of them is utmp. What this means is that gettimeofday(&ut.ut_tv, NULL) on x86_64 will end up overwriting the first parts of ut_addr_v6, leading to garbage in the utmp file. Signed-off-by: Karel Zak <kzak@redhat.com>
* login: omits PAM account validation when auth is skipped (CVE-2006-7108)Karel Zak2007-03-081-6/+12
| | | | | | | | | | | | | | | | | | The login omits pam_acct_mgmt & chauth_tok when authentication is skipped. Authentication may be skipped, for example, during krlogin because Kerberos already took care of it. The problem with skipping pam_acct_mgmt is that it allows users to use the system when maybe they should not be allowed, such that if they have a Kerberos ticket, the other checks do not apply. If a user had to use password authentication, pam_acct_mgmt may reject the user for several reasons: not allowed to use the system at this time, not allowed to use this system, user's account has been disabled, etc. Why should these tests be skipped just because the user has a ticket? Same with pam_chauthtok: the user may have a valid ticket, but if their password has expired, they need to enter a new one right now. Signed-off-by: Karel Zak <kzak@redhat.com>
* login: attempt to run if it has no read/write access to its terminalKarel Zak2007-03-081-1/+2
| | | | | | | | | | | | | If you manage to exec login with a userid other than root, and its input / output directed to a terminal for which it does not have read/write access, it will attempt to proceed (and can potentially hang forever -- but this hang has been fixed in a previous commit). It's better to check if we have permissions for terminal rather than do any useless things. From: Jason Vas Dias <jvdias@redhat.com> Signed-off-by: Karel Zak <kzak@redhat.com>
* login: keep syslog useful for end of PAM session.Karel Zak2007-03-081-0/+1
| | | | | | | The PAM session modules typically write to syslog when leaving the session. The openlog() is way how define a "ident" for syslog messages. Signed-off-by: Karel Zak <kzak@redhat.com>
* login: login's timeout can failKarel Zak2007-03-081-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Login tries to set a timeout in main() by SIGALARM. If any restartable system call is entered, such system calls can block indefinitely and will NOT be interrupted by the SIGALRM. The bug appears when the login program is run for a terminal for which it doens't have read or write permission. In that case, login hung until manually killed by the administrator in its tcsetattr(...) call at login.c, line 460: /* Kill processes left on this tty */ tcsetattr(0,TCSAFLUSH,&ttt); This may possibly be a kernel bug - instead of returning EIO / EPERM, the kernel continously sends an infinite number of SIGTTOU signals to the process . An 80MB strace log file was generated, consisting of >1,000,000 repetitions of : 4964 11:00:18 ioctl(0, SNDCTL_TMR_CONTINUE or TCSETSF, {c_iflags=0x106, c_oflags=0x1805, c_cflags=0x800000be, c_lflags=0x3b, c_line=0, c_cc="\x03\x1c\x7f\x15\x04\x00\x01\x00\x11\x13\x1a\x00\x12\x0f\x17\x16\x00\x00\x00"}) = ? ERESTARTSYS (To be restarted) 4964 11:00:18 --- SIGTTOU (Stopped (tty output)) @ 0 (0) --- 4964 11:00:18 --- SIGTTOU (Stopped (tty output)) @ 0 (0) --- Login's alarm signal handler DOES get the SIGALRM after the 60 second timeout, and timedout() is called; but then timedout2 calls ioctl(0, TCSETA, &ti), which also blocks, because the ioctl(0, TCSETSF...) of tcsetattr is in progress, and the exit() call of timedout2 is never reached, and the tcsetattr call is restarted. From: Jason Vas Dias <jvdias@redhat.com> Signed-off-by: Karel Zak <kzak@redhat.com>
* login: improve work with signalsKarel Zak2007-03-081-12/+69
| | | | | | | | | | | | | | | | | | | The login cannot ignore signals, because: * SIGHUP is only way how inform session leader that controlling tty goes away. The leader has to inform others processes in same process group about the signal. * SIGHUP/SIGTERM cannot kill wait(2)-ing login, we have to wait as long as any child process exists. The PAM session has to be closed correctly. * The child process (before setsid()) has to call exit() if a controlling tty goes away. This patch is inspired by patch from Red Hat that is very well tested for last 4 years in all Red Hat distros. Signed-off-by: Karel Zak <kzak@redhat.com>
* login: close PAM session after failed pam_setcredKarel Zak2007-03-071-0/+2
| | | | | | | | If for some reason the pam set credential call fails, it does not close the pam session. pam open can mount drives, so calling pam close is important. From: Steve Grubb <sgrubb@redhat.com> Signed-off-by: Karel Zak <kzak@redhat.com>
* Imported from util-linux-2.13-pre1 tarball.Karel Zak2006-12-071-120/+29Star
|
* Imported from util-linux-2.12j tarball.Karel Zak2006-12-071-5/+16
|
* Imported from util-linux-2.12a tarball.Karel Zak2006-12-071-10/+11
|
* Imported from util-linux-2.12 tarball.Karel Zak2006-12-071-10/+28
|
* Imported from util-linux-2.11y tarball.Karel Zak2006-12-071-6/+0Star
|
* Imported from util-linux-2.11w tarball.Karel Zak2006-12-071-54/+24Star
|
* Imported from util-linux-2.11q tarball.Karel Zak2006-12-071-48/+68
|
* Imported from util-linux-2.11o tarball.Karel Zak2006-12-071-1/+1
|
* Imported from util-linux-2.11n tarball.Karel Zak2006-12-071-1/+1
|
* Imported from util-linux-2.11m tarball.Karel Zak2006-12-071-11/+54
|
* Imported from util-linux-2.11f tarball.Karel Zak2006-12-071-103/+136
|
* Imported from util-linux-2.11b tarball.Karel Zak2006-12-071-109/+51Star
|
* Imported from util-linux-2.10s tarball.Karel Zak2006-12-071-58/+47Star
|
* Imported from util-linux-2.10m tarball.Karel Zak2006-12-071-22/+31
|