]> andersk Git - openssh.git/blobdiff - session.c
- markus@cvs.openbsd.org 2002/06/26 14:51:33
[openssh.git] / session.c
index 9abe028b06e125d226b5f7ef025122151e1fe827..747a00afae1b5996689d24d7f68898fd05255029 100644 (file)
--- a/session.c
+++ b/session.c
@@ -33,7 +33,7 @@
  */
 
 #include "includes.h"
-RCSID("$OpenBSD: session.c,v 1.140 2002/06/23 21:06:41 deraadt Exp $");
+RCSID("$OpenBSD: session.c,v 1.142 2002/06/26 13:49:26 deraadt Exp $");
 
 #include "ssh.h"
 #include "ssh1.h"
@@ -849,6 +849,9 @@ child_set_env(char ***envp, u_int *envsizep, const char *name,
        } else {
                /* New variable.  Expand if necessary. */
                if (i >= (*envsizep) - 1) {
+                       if (*envsizep >= 1000)
+                               fatal("child_set_env: too many env vars,"
+                                   " skipping: %.100s", name);
                        (*envsizep) += 50;
                        env = (*envp) = xrealloc(env, (*envsizep) * sizeof(char *));
                }
@@ -874,12 +877,15 @@ read_environment_file(char ***env, u_int *envsize,
        FILE *f;
        char buf[4096];
        char *cp, *value;
+       u_int lineno = 0;
 
        f = fopen(filename, "r");
        if (!f)
                return;
 
        while (fgets(buf, sizeof(buf), f)) {
+               if (++lineno > 1000)
+                       fatal("Too many lines in environment file %s", filename);
                for (cp = buf; *cp == ' ' || *cp == '\t'; cp++)
                        ;
                if (!*cp || *cp == '#' || *cp == '\n')
@@ -888,7 +894,8 @@ read_environment_file(char ***env, u_int *envsize,
                        *strchr(cp, '\n') = '\0';
                value = strchr(cp, '=');
                if (value == NULL) {
-                       fprintf(stderr, "Bad line in %.100s: %.200s\n", filename, buf);
+                       fprintf(stderr, "Bad line %u in %.100s\n", lineno,
+                           filename);
                        continue;
                }
                /*
@@ -1152,6 +1159,8 @@ do_nologin(struct passwd *pw)
 void
 do_setusercontext(struct passwd *pw)
 {
+       char tty='\0';
+
 #ifdef HAVE_CYGWIN
        if (is_winnt) {
 #else /* HAVE_CYGWIN */
@@ -1161,6 +1170,9 @@ do_setusercontext(struct passwd *pw)
                setpcred(pw->pw_name);
 #endif /* HAVE_SETPCRED */
 #ifdef HAVE_LOGIN_CAP
+#ifdef __bsdi__
+               setpgid(0, 0);
+#endif
                if (setusercontext(lc, pw, pw->pw_uid,
                    (LOGIN_SETALL & ~LOGIN_SETPATH)) < 0) {
                        perror("unable to set user context");
@@ -1196,6 +1208,10 @@ do_setusercontext(struct passwd *pw)
 # if defined(WITH_IRIX_PROJECT) || defined(WITH_IRIX_JOBS) || defined(WITH_IRIX_ARRAY)
                irix_setusercontext(pw);
 #  endif /* defined(WITH_IRIX_PROJECT) || defined(WITH_IRIX_JOBS) || defined(WITH_IRIX_ARRAY) */
+# ifdef _AIX
+               /* XXX: Disable tty setting.  Enabled if required later */
+               aix_usrinfo(pw, &tty, -1);
+# endif /* _AIX */
                /* Permanently switch to the desired uid. */
                permanently_set_uid(pw);
 #endif
@@ -1258,9 +1274,6 @@ do_child(Session *s, const char *command)
                        do_motd();
 #else /* HAVE_OSF_SIA */
                do_nologin(pw);
-# ifdef _AIX
-               aix_usrinfo(pw, s->tty, s->ttyfd);
-# endif /* _AIX */
                do_setusercontext(pw);
 #endif /* HAVE_OSF_SIA */
        }
This page took 0.164646 seconds and 4 git commands to generate.