Red Hat Bugzilla – Bug 488192
login: access("/nfs-home/.hushlogin", R_OK) = -1 EACCES (Permission denied)
Last modified: 2011-01-13 18:44:37 EST
Description of problem:
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 - login uses the file to determine if motd and last is shown/updated on login.
Version-Release number of selected component (if applicable):
Reported originally in util-linux-2.13-0.47.el5-x86_64 but problem exists in all versions of util-linux packages for RHEL5.
Steps to Reproduce:
1. Create a user on NFS server for example:
2. Export motdtest user's home directory:
3. service nfs start
4. Create a user on NFS client that uses mount poiny /nfs-home for home directory:
5. Create entry in /etc/fstab on NFS client
10.0.0.2:/home/motdtest /nfs-home nfs nfsvers=3,hard,intr,tcp 0 0
6. Mount the NFS export
7. login at console on NFS client and create .hushlogin file :
8. Logout and login again as motdtest user
The meesage of the day is displayed, and last is updated.
The message of the day should be shown and last should not be updated.
strace attached to mingetty tty1 shows :
getuid() = 0
getegid() = 0
setregid(4294967295, 3333) = 0
setreuid(0, 3333) = 0
access("/nfs-home/.hushlogin", R_OK) = -1 EACCES (Permission denied)
setuid(0) = 0
setreuid(0, 0) = 0
These system calls line up with the code from login.c:
uid_t ruid = getuid();
gid_t egid = getegid();
/* avoid snprintf - old systems do not have it, or worse,
have a libc in which snprintf is the same as sprintf */
if (strlen(pwd->pw_dir) + sizeof(_PATH_HUSHLOGIN) + 2 > MAXPATHLEN)
quietlog = 0;
sprintf(tmpstr, "%s/%s", pwd->pw_dir, _PATH_HUSHLOGIN);
quietlog = (access(tmpstr, R_OK) == 0);
setuid(0); /* setreuid doesn't do it alone! */
A small patch that uses setresuid and setresgid instead follows as attachement. It resolves the problem in my tests. I have not explored the consequences of using setresuid/setresgid fully, but I do think it is minimal.
Created attachment 333833 [details]
Patch to resolve motd problem
(In reply to comment #0)
> Actual results:
> The meesage of the day is displayed, and last is updated.
> Expected results:
> The message of the day should be shown and last should not be updated.
The quietlog (quiet mode) does not control last log update. This mode
enable/disable printing of the last login time and message of the day.
That's all. The user cannot control last log _update_ at all.
> Additional info:
> strace attached to mingetty tty1 shows :
> getuid() = 0
> getegid() = 0
> setregid(4294967295, 3333) = 0
> setreuid(0, 3333) = 0
> access("/nfs-home/.hushlogin", R_OK) = -1 EACCES (Permission denied)
Hmm.. you're right, the access(2) is exception, man page:
The check is done using the calling process’s real UID and GID,
rather than the effective IDs as is done when actually attempting an
operation (e.g., open(2)) on the file. This allows set-user-ID
programs to easily determine the invoking user’s authority.
Thanks, good catch!
Fixed in upstream code.
Comment #9 => VERIFIED
An advisory has been issued which should help the problem
described in this bug report. This report is therefore being
closed with a resolution of ERRATA. For more information
on therefore solution and/or where to find the updated files,
please follow the link below. You may reopen this bug report
if the solution does not work for you.