]> andersk Git - openssh.git/blobdiff - session.c
- camield@cvs.openbsd.org 2001/08/23 17:59:31
[openssh.git] / session.c
index 818f3211bc4d193e1b5462984002802984e6ebe5..1e9e32284e0b78ae329abbca78a7a658b8104587 100644 (file)
--- a/session.c
+++ b/session.c
@@ -33,7 +33,7 @@
  */
 
 #include "includes.h"
-RCSID("$OpenBSD: session.c,v 1.97 2001/06/27 02:12:53 markus Exp $");
+RCSID("$OpenBSD: session.c,v 1.100 2001/08/16 19:18:34 jakob Exp $");
 
 #include "ssh.h"
 #include "ssh1.h"
@@ -121,20 +121,21 @@ struct Session {
 /* func */
 
 Session *session_new(void);
-void  session_set_fds(Session *, int, int, int);
-static void   session_pty_cleanup(void *);
-void  session_proctitle(Session *);
-int   session_setup_x11fwd(Session *);
-void  do_exec_pty(Session *, const char *);
-void  do_exec_no_pty(Session *, const char *);
-void  do_exec(Session *, const char *);
-void  do_login(Session *, const char *);
-void  do_child(Session *, const char *);
+void   session_set_fds(Session *, int, int, int);
+static void    session_pty_cleanup(void *);
+void   session_proctitle(Session *);
+int    session_setup_x11fwd(Session *);
+void   do_exec_pty(Session *, const char *);
+void   do_exec_no_pty(Session *, const char *);
+void   do_exec(Session *, const char *);
+void   do_login(Session *, const char *);
+void   do_child(Session *, const char *);
 void   do_motd(void);
+int    check_quietlogin(Session *, const char *);
 
 static void do_authenticated1(Authctxt *);
 static void do_authenticated2(Authctxt *);
+
 static void session_close(Session *);
 static int session_pty_req(Session *);
 
@@ -670,30 +671,6 @@ do_exec(Session *s, const char *command)
        original_command = NULL;
 }
 
-/*
- * Check for quiet login, either .hushlogin or command given.
- */
-static int
-check_quietlogin(Session *s, const char *command)
-{
-       char buf[256];
-       struct passwd *pw = s->pw;
-       struct stat st;
-
-       /* Return 1 if .hushlogin exists or a command given. */
-       if (command != NULL)
-               return 1;
-       snprintf(buf, sizeof(buf), "%.200s/.hushlogin", pw->pw_dir);
-#ifdef HAVE_LOGIN_CAP
-       if (login_getcapbool(lc, "hushlogin", 0) || stat(buf, &st) >= 0)
-               return 1;
-#else
-       if (stat(buf, &st) >= 0)
-               return 1;
-#endif
-       return 0;
-}
-
 /* administrative, login(1)-like work */
 void
 do_login(Session *s, const char *command)
@@ -792,6 +769,31 @@ do_motd(void)
        }
 }
 
+
+/*
+ * Check for quiet login, either .hushlogin or command given.
+ */
+int
+check_quietlogin(Session *s, const char *command)
+{
+       char buf[256];
+       struct passwd *pw = s->pw;
+       struct stat st;
+
+       /* Return 1 if .hushlogin exists or a command given. */
+       if (command != NULL)
+               return 1;
+       snprintf(buf, sizeof(buf), "%.200s/.hushlogin", pw->pw_dir);
+#ifdef HAVE_LOGIN_CAP
+       if (login_getcapbool(lc, "hushlogin", 0) || stat(buf, &st) >= 0)
+               return 1;
+#else
+       if (stat(buf, &st) >= 0)
+               return 1;
+#endif
+       return 0;
+}
+
 /*
  * Sets the value of the given variable in the environment.  If the variable
  * already exists, its value is overriden.
@@ -1048,7 +1050,7 @@ do_child(Session *s, const char *command)
        if (options.use_login && command != NULL)
                options.use_login = 0;
 
-#if !defined(USE_PAM) && !defined(HAVE_OSF_SIA)
+#if !defined(HAVE_OSF_SIA)
        if (!options.use_login) {
 # ifdef HAVE_LOGIN_CAP
                if (!login_getcapbool(lc, "ignorenologin", 0) && pw->pw_uid)
@@ -1066,7 +1068,7 @@ do_child(Session *s, const char *command)
                        exit(254);
                }
        }
-#endif /* USE_PAM || HAVE_OSF_SIA */
+#endif /* HAVE_OSF_SIA */
 
        /* Set login name, uid, gid, and groups. */
        /* Login(1) does this as well, and it needs uid 0 for the "-h"
@@ -1457,25 +1459,6 @@ do_child(Session *s, const char *command)
                if (!options.use_login) {
                        char buf[256];
 
-                       /*
-                        * Check for mail if we have a tty and it was enabled
-                        * in server options.
-                        */
-                       if (s->ttyfd != -1 && options.check_mail) {
-                               char *mailbox;
-                               struct stat mailstat;
-
-                               mailbox = getenv("MAIL");
-                               if (mailbox != NULL) {
-                                       if (stat(mailbox, &mailstat) != 0 ||
-                                           mailstat.st_size == 0)
-                                               printf("No mail.\n");
-                                       else if (mailstat.st_mtime < mailstat.st_atime)
-                                               printf("You have mail.\n");
-                                       else
-                                               printf("You have new mail.\n");
-                               }
-                       }
                        /* Start the shell.  Set initial character to '-'. */
                        buf[0] = '-';
                        strncpy(buf + 1, cp, sizeof(buf) - 1);
@@ -1497,7 +1480,7 @@ do_child(Session *s, const char *command)
 #ifdef LOGIN_NEEDS_TERM
                             s->term? s->term : "unknown",
 #endif
-                            "-p", "-f", "--", pw->pw_name, NULL);
+                            "-p", "-f", "--", pw->pw_name, (char *)NULL);
 
                        /* Login couldn't be executed, die. */
 
@@ -1959,6 +1942,22 @@ session_close_by_pid(pid_t pid, int status)
        session_close(s);
 }
 
+int
+session_have_children(void)
+{
+       int i;
+
+       for(i = 0; i < MAX_SESSIONS; i++) {
+               Session *s = &sessions[i];
+               if (s->used && s->pid != -1) {
+                       debug("session_have_children: id %d pid %d", i, s->pid);
+                       return 1;
+               }
+       }
+       debug("session_have_children: no more children");
+       return 0;
+}
+
 /*
  * this is called when a channel dies before
  * the session 'child' itself dies
This page took 0.095352 seconds and 4 git commands to generate.