1
0
mirror of https://git.FreeBSD.org/src.git synced 2024-12-11 09:50:12 +00:00

Julian A's fix. Do chdir as user rather than as root. Fixes a minor NFS

compatibility problem at the same time.  Some buffer made large enough
for worst case hostname.

fixes PR 2593.

Reviewed by:	Dan Cross and maybe others
This commit is contained in:
Warner Losh 1997-03-24 05:57:28 +00:00
parent 94cf2e751d
commit a51e2c9b04
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=24189

View File

@ -30,7 +30,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $Id$
* $Id: rexecd.c,v 1.13 1997/02/22 14:22:06 peter Exp $
*/
#ifndef lint
@ -66,9 +66,9 @@ static char sccsid[] = "@(#)rexecd.c 8.1 (Berkeley) 6/4/93";
/*VARARGS1*/
int error();
char username[20] = "USER=";
char homedir[64] = "HOME=";
char shell[64] = "SHELL=";
char username[MAXLOGNAME + 5 + 1] = "USER=";
char homedir[MAXPATHLEN + 5 + 1] = "HOME=";
char shell[MAXPATHLEN + 6 + 1] = "SHELL=";
char path[sizeof(_PATH_DEFPATH) + sizeof("PATH=")] = "PATH=";
char *envinit[] =
{homedir, shell, path, username, 0};
@ -213,10 +213,6 @@ doit(f, fromp)
syslog(LOG_INFO, "login from %s as %s", remote, user);
if (chdir(pwd->pw_dir) < 0) {
error("No remote directory.\n");
exit(1);
}
(void) write(2, "\0", 1);
if (port) {
(void) pipe(pv);
@ -276,6 +272,10 @@ doit(f, fromp)
cp++;
else
cp = pwd->pw_shell;
if (chdir(pwd->pw_dir) < 0) {
error("No remote directory.\n");
exit(1);
}
execl(pwd->pw_shell, cp, "-c", cmdbuf, 0);
perror(pwd->pw_shell);
exit(1);