From 7f79bbed5b777c701afb47dfa79b43ff953c2b8a Mon Sep 17 00:00:00 2001 From: imp Date: Mon, 24 Mar 1997 05:57:28 +0000 Subject: 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 --- libexec/rexecd/rexecd.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'libexec/rexecd') diff --git a/libexec/rexecd/rexecd.c b/libexec/rexecd/rexecd.c index a54a5af..119551e 100644 --- a/libexec/rexecd/rexecd.c +++ b/libexec/rexecd/rexecd.c @@ -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); -- cgit v1.1