/[inetutils]/inetutils/rshd/rshd.c
ViewVC logotype

Diff of /inetutils/rshd/rshd.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.25 by jbailey, Mon Sep 2 14:27:11 2002 UTC revision 1.26 by gray, Mon Sep 9 09:31:55 2002 UTC
# Line 457  doit (int sockfd, struct sockaddr_in *fr Line 457  doit (int sockfd, struct sockaddr_in *fr
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
# Line 565  doit (int sockfd, struct sockaddr_in *fr Line 565  doit (int sockfd, struct sockaddr_in *fr
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      {      {
# Line 861  doit (int sockfd, struct sockaddr_in *fr Line 847  doit (int sockfd, struct sockaddr_in *fr
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;

Legend:
Removed from v.1.25  
changed lines
  Added in v.1.26

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26