]> andersk Git - openssh.git/commitdiff
- djm@cvs.openbsd.org 2001/04/16 08:19:31
authordjm <djm>
Mon, 16 Apr 2001 08:29:15 +0000 (08:29 +0000)
committerdjm <djm>
Mon, 16 Apr 2001 08:29:15 +0000 (08:29 +0000)
     [session.c]
     Split motd and hushlogin checks into seperate functions, helps for
     portable. From Chris Adams <cmadams@hiwaay.net>; ok markus@

ChangeLog
session.c

index 3085994b033eab2fc4cd65817c6bcfaa8ddd56fa..977a8a2b36efe32cf095636f760a01ea41ba5cfd 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
    - deraadt@cvs.openbsd.org 2001/04/16 08:05:34
      [xmalloc.c]
      xrealloc dealing with ptr == nULL; mouring
+   - djm@cvs.openbsd.org 2001/04/16 08:19:31
+     [session.c]
+     Split motd and hushlogin checks into seperate functions, helps for 
+     portable. From Chris Adams <cmadams@hiwaay.net>; ok markus@
 
 20010415
  - OpenBSD CVS Sync
index ebefd91c4f57fcee120955d43f9e7e67ee125c5f..77e11987e3ca757ea49c963d55641f6e5dc372f0 100644 (file)
--- a/session.c
+++ b/session.c
@@ -33,7 +33,7 @@
  */
 
 #include "includes.h"
-RCSID("$OpenBSD: session.c,v 1.72 2001/04/14 16:33:20 stevesk Exp $");
+RCSID("$OpenBSD: session.c,v 1.73 2001/04/16 08:19:31 djm Exp $");
 
 #include "ssh.h"
 #include "ssh1.h"
@@ -128,6 +128,8 @@ void        do_exec_pty(Session *s, const char *command);
 void   do_exec_no_pty(Session *s, const char *command);
 void   do_login(Session *s, const char *command);
 void   do_child(Session *s, const char *command);
+void   do_motd(void);
+int    check_quietlogin(Session *s, const char *command);
 
 void   do_authenticated1(Authctxt *authctxt);
 void   do_authenticated2(Authctxt *authctxt);
@@ -681,13 +683,10 @@ do_exec_pty(Session *s, const char *command)
 void
 do_login(Session *s, const char *command)
 {
-       FILE *f;
        char *time_string;
-       char buf[256];
        char hostname[MAXHOSTNAMELEN];
        socklen_t fromlen;
        struct sockaddr_storage from;
-       struct stat st;
        time_t last_login_time;
        struct passwd * pw = s->pw;
        pid_t pid = getpid();
@@ -729,15 +728,7 @@ do_login(Session *s, const char *command)
        }
 #endif
 
-       /* Done if .hushlogin exists or a command given. */
-       if (command != NULL)
-               return;
-       snprintf(buf, sizeof(buf), "%.200s/.hushlogin", pw->pw_dir);
-#ifdef HAVE_LOGIN_CAP
-       if (login_getcapbool(lc, "hushlogin", 0) || stat(buf, &st) >= 0)
-#else
-       if (stat(buf, &st) >= 0)
-#endif
+       if (check_quietlogin(s, command))
                return;
 
 #ifdef USE_PAM
@@ -758,6 +749,19 @@ do_login(Session *s, const char *command)
                else
                        printf("Last login: %s from %s\r\n", time_string, hostname);
        }
+
+       do_motd();
+}
+
+/*
+ * Display the message of the day.
+ */
+void
+do_motd(void)
+{
+       FILE *f;
+       char buf[256];
+
        if (options.print_motd) {
 #ifdef HAVE_LOGIN_CAP
                f = fopen(login_getcapstr(lc, "welcome", "/etc/motd",
@@ -773,6 +777,31 @@ do_login(Session *s, const char *command)
        }
 }
 
+
+/*
+ * 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.
This page took 0.053018 seconds and 5 git commands to generate.