457 |
* in a remote net; look up the name and check that this |
* in a remote net; look up the name and check that this |
458 |
* address corresponds to the name. |
* address corresponds to the name. |
459 |
*/ |
*/ |
460 |
hostname = hp->h_name; |
hostname = strdup (hp->h_name); |
461 |
#ifdef KERBEROS |
#ifdef KERBEROS |
462 |
if (!use_kerberos) |
if (!use_kerberos) |
463 |
#endif |
#endif |
565 |
goto fail; |
goto fail; |
566 |
} |
} |
567 |
|
|
|
/* We'll execute the client's command in the home directory |
|
|
* of locuser. |
|
|
*/ |
|
|
if (chdir (pwd->pw_dir) < 0) |
|
|
{ |
|
|
(void) chdir ("/"); |
|
|
syslog (LOG_INFO|LOG_AUTH, "%s@%s as %s: no home directory. cmd='%.80s'", |
|
|
remuser, hostname, locuser, cmdbuf); |
|
|
error ("No remote directory.\n"); |
|
|
#ifdef notdef |
|
|
exit (1); |
|
|
#endif |
|
|
} |
|
|
|
|
568 |
#ifdef KERBEROS |
#ifdef KERBEROS |
569 |
if (use_kerberos) |
if (use_kerberos) |
570 |
{ |
{ |
847 |
#ifdef HAVE_INITGROUPS |
#ifdef HAVE_INITGROUPS |
848 |
initgroups (pwd->pw_name, pwd->pw_gid); /* BSD groups */ |
initgroups (pwd->pw_name, pwd->pw_gid); /* BSD groups */ |
849 |
#endif |
#endif |
850 |
/* It's not obvious that this is right, however, it was reported |
|
|
* as a real bug, and this conforms to what the glibc manual says |
|
|
* setuid should handle the seteuid as well. |
|
|
* seteuid ((uid_t)pwd->pw_uid); */ |
|
851 |
setuid ((uid_t)pwd->pw_uid); |
setuid ((uid_t)pwd->pw_uid); |
852 |
|
|
853 |
|
/* We'll execute the client's command in the home directory |
854 |
|
* of locuser. Note, that the chdir must be executed after |
855 |
|
* setuid(), otherwise it may fail on NFS mounted directories |
856 |
|
* (root mapped to nobody). |
857 |
|
*/ |
858 |
|
if (chdir (pwd->pw_dir) < 0) |
859 |
|
{ |
860 |
|
chdir ("/"); |
861 |
|
syslog (LOG_INFO|LOG_AUTH, "%s@%s as %s: no home directory. cmd='%.80s'", |
862 |
|
remuser, hostname, locuser, cmdbuf); |
863 |
|
error ("No remote directory.\n"); |
864 |
|
#ifdef notdef |
865 |
|
exit (1); |
866 |
|
#endif |
867 |
|
} |
868 |
|
|
869 |
/* Set up an initial environment for the shell that we exec() */ |
/* Set up an initial environment for the shell that we exec() */ |
870 |
environ = envinit; |
environ = envinit; |