Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 23 Apr 1999 13:51:13 +0200 (CEST)
From:      pjlobo@euitt.upm.es
To:        FreeBSD-gnats-submit@freebsd.org
Subject:   bin/11292: login(1) needs world accessibility to the users' home directories (only to the directories, not to its contents)
Message-ID:  <199904231151.NAA00750@deneb.euitt.upm.es>

next in thread | raw e-mail | index | archive | help

>Number:         11292
>Category:       bin
>Synopsis:       login(1) needs world accessibility to the users' home directories (only to the directories, not to its contents)
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    freebsd-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Fri Apr 23 05:00:01 PDT 1999
>Closed-Date:
>Last-Modified:
>Originator:     Pedro J. Lobo
>Release:        FreeBSD 3.1-RELEASE i386
>Organization:
Universidad Politécnica de Madrid - E.U.I.T. Telecomunicación
>Environment:

Output of uname -a (splitted for readability):
FreeBSD
fobos.alumnos.euitt.upm.es
3.1-RELEASE
FreeBSD 3.1-RELEASE #1: Fri Feb 19 15:21:04 CET 1999
root@:/usr/src/sys/compile/FOBOS
i386

>Description:

The login(1) command does a seteuid(2) call before accesing the user's home
directory, but the GID of the login process is always 0. So, login can't
access the users' home directory if some other directory in the path of the
home directory grants only group access to the user's group.

Let's see an exampe. I have three user groups: admins, alumnos and pfc. A user
belonging to the group pfc has its home directory in /home/pfc/username.

ls -ld /home/pfc gives:
drwxr-x---  262 root  pfc  4608 Apr 23 10:46 /home/pfc

ls -d /home/pfc/username gives:
drwx------  2 username  pfc  512 Apr 22 15:50 /home/pfc/username

When the user logs in, login says:
No home directory.
Logging in with home = "/".

And syslog says (line splitted for readability):
Apr 23 09:52:17 fobos login: _secure_path:
cannot stat /home/pfc/prueba1/.login_conf: Permission denied

This is because that the login process calls seteuid(2) to get the user's
identity, but it remains at gid 0, so the process doesn't have read access
to /home/pfc anymore.

>How-To-Repeat:

Just set up an account the way described and try to log in.

>Fix:
	
Please apply this patch to usr.bin/login/login.c (context diff):

---------------------- snip -----------------------
*** usr.bin/login/login.c.orig	Tue Jan 19 23:59:37 1999
--- usr.bin/login/login.c	Fri Apr 23 10:00:12 1999
***************
*** 356,361 ****
--- 356,362 ----
  	/*
  	 * Establish the login class.
  	 */
+ 	(void)setegid(pwd->pw_gid);
  	(void)seteuid(rootlogin ? 0 : pwd->pw_uid);
  	lc = login_getpwclass(pwd);
  	seteuid(euid);
----------------------- snip -----------------------

It calls setegid(2) before accessing the user's home directory. I don't see
any reason to revert to the previous GID (which is wheel). In fact, I think
that login is safer this way.

Please feel free to contact me (pjlobo@euitt.upm.es) for any question.

Sincerely yours,

	Pedro J. Lobo




>Release-Note:
>Audit-Trail:
>Unformatted:


To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-bugs" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199904231151.NAA00750>