login.krb5 (login.c) patch

Grant, Martin Martin.Grant at fmr.com
Mon Oct 30 10:17:16 EST 2006


ALL,

	How do I submit changes to get a proposed bug fix into the tree?
Or does anyone have any comment on whether what is below is a valid bug
fix?

-Martin Grant
_____________________________________________
From: Grant, Martin 
Sent: Thursday, October 26, 2006 10:38 AM
To: 'kerberos at mit.edu'
Subject: login.krb5

ALL,

	I seem to be having a problem with login.krb5.  When a user has
a home directory that gives no permission to root on the local server
they are logging into (e.g. mounted or auto-mounted file system that was
exported without the -root option to the local server and said directory
does not have other permissions - 700), the user gets an error when they
login that their home directory does not exist even though it does.

Connected to testserver.domainname.com.
Escape character is '^]'.
login: angryuser
Password for angryuser: 
No directory /home/angryuser!
Logging in with home = "/".
/ $ cd /home/angryuser
/home/angryuser $ ls -dal
drwx------   10 angryuser  users        4096 Oct 26 08:53 .

	However this error does not occur if the directory is 755, or if
the file system is NFS mounted with -root:

Connected to testserver.domainname.com.
Escape character is '^]'.
login: angryuser
Password for angryuser: 
/home/angryuser $ ls -dal
drwxr-xr-x   10 angryuser  users        4096 Oct 26 08:53 .

	Looking at login.c I noticed the following lines (1450-1456):

    if (chdir(pwd->pw_dir) < 0) {
        printf("No directory %s!\n", pwd->pw_dir);
        if (chdir("/"))
            exit(0);
        pwd->pw_dir = "/";
        printf("Logging in with home = \"/\".\n");
    }

	are significantly before the user's setuid (1639-1661):

#ifdef  HAVE_SETLUID
        /*
         * If we're on a system which keeps track of login uids, then
         * set the login uid. If this fails this opens up a problem on
DEC OSF
         * with C2 enabled.
         */
        if (setluid((uid_t) pwd->pw_uid) < 0) {
            perror("setuid");
            sleepexit(1);
        }
#endif  /* HAVE_SETLUID */
#ifdef _IBMR2
    if (setuidx(ID_LOGIN, pwd->pw_uid) < 0) {
        perror("setuidx");
        sleepexit(1);
    };
#endif

    /* This call MUST succeed */
    if (setuid((uid_t) pwd->pw_uid) < 0) {
        perror("setuid");
        sleepexit(1);
    }


	When I move the chdir down past setuid and recompile my errors
above go away.  Is there a reason for the existing ordering (i.e. a good
reason why I shouldn't make this change to login.krb5 in my
environment)?  It seems to me the login process should not chdir to the
user's home directory until after setuid is done.

Thank You,
-Martin Grant








More information about the krbdev mailing list