524739d401
XXXtgetent from original PR fixed PR: 12279 Submitted by: Issei Suzuki <issei@issei.org>
116 lines
3.1 KiB
Plaintext
116 lines
3.1 KiB
Plaintext
--- apps/ssh/sshchsession.c.orig Fri May 7 20:02:03 1999
|
|
+++ apps/ssh/sshchsession.c Sat Jun 19 03:51:31 1999
|
|
@@ -81,6 +81,11 @@
|
|
#include <ulimit.h>
|
|
#endif /* ULIMIT_H */
|
|
|
|
+#ifdef HAVE_LOGIN_CAP_H
|
|
+#include <login_cap.h>
|
|
+extern char **environ;
|
|
+#endif
|
|
+
|
|
#define SSH_DEBUG_MODULE "Ssh2ChannelSession"
|
|
|
|
#define SSH_SESSION_INTERACTIVE_WINDOW 10000
|
|
@@ -406,6 +411,67 @@
|
|
if (getenv("TZ"))
|
|
ssh_child_set_env(envp, envsizep, "TZ", getenv("TZ"));
|
|
|
|
+#ifdef HAVE_LOGIN_CAP_H
|
|
+ {
|
|
+ char *p, *s, **tmpenv;
|
|
+ struct passwd *pwd;
|
|
+
|
|
+ pwd = getpwnam(user_name);
|
|
+ if (!pwd)
|
|
+ {
|
|
+ ssh_warning("Can't getpwnam %s: %s", user_name, strerror(errno));
|
|
+ }
|
|
+ else
|
|
+ {
|
|
+ /* Save previous environment array
|
|
+ */
|
|
+ tmpenv = environ;
|
|
+ environ = *envp;
|
|
+
|
|
+ /* Set the user's login environment
|
|
+ */
|
|
+ if (setusercontext(NULL, pwd,
|
|
+ ssh_user_uid(session->common->user_data),
|
|
+ LOGIN_SETPATH|LOGIN_SETENV) == 0)
|
|
+ {
|
|
+ p = getenv("PATH");
|
|
+ s = ssh_xmalloc((p != NULL ? strlen(p) + 1 : 0)
|
|
+ + sizeof(SSH_BINDIR));
|
|
+ *s = '\0';
|
|
+ if (p != NULL)
|
|
+ {
|
|
+ strcat(s, p);
|
|
+ strcat(s, ":");
|
|
+ }
|
|
+ strcat(s, SSH_BINDIR);
|
|
+
|
|
+ /* copy enviroment variables to (*envp) */
|
|
+ for (i = 0; environ[i] != NULL; i++)
|
|
+ ;
|
|
+ (*envp) = ssh_xmalloc((i + 51) * sizeof(char *));
|
|
+ (*envsizep) = i + 50;
|
|
+
|
|
+ for (i = 0; environ[i] != NULL; ++i) {
|
|
+ (*envp)[i] = ssh_xmalloc((strlen(environ[i]) + 1) * sizeof(char));
|
|
+ strcpy((*envp)[i], environ[i]);
|
|
+ }
|
|
+ (*envp)[i] = NULL;
|
|
+
|
|
+ environ = tmpenv; /* Restore parent environment */
|
|
+ ssh_child_set_env(envp, envsizep, "PATH", s);
|
|
+ ssh_xfree(s);
|
|
+ }
|
|
+ else
|
|
+ {
|
|
+ *envp = environ;
|
|
+ environ = tmpenv; /* Restore parent environment */
|
|
+ ssh_warning("Can't setusercontext env. variables: %s", strerror(errno));
|
|
+ }
|
|
+ }
|
|
+ endpwent();
|
|
+ }
|
|
+#endif /* HAVE_LOGIN_CAP_H */
|
|
+
|
|
/* Set SSH_CLIENT. */
|
|
snprintf(buf, sizeof(buf), "%s %s %s %s",
|
|
session->common->remote_ip, session->common->remote_port,
|
|
@@ -633,12 +699,20 @@
|
|
char buff[100], *time_string;
|
|
|
|
/* Check /etc/nologin. */
|
|
+#ifdef __FreeBSD__
|
|
+ f = fopen("/var/run/nologin", "r");
|
|
+#else
|
|
f = fopen("/etc/nologin", "r");
|
|
+#endif
|
|
if (f)
|
|
{ /* /etc/nologin exists. Print its contents and exit. */
|
|
/* Print a message about /etc/nologin existing; I am getting
|
|
questions because of this every week. */
|
|
+#ifdef __FreeBSD__
|
|
+ ssh_warning("Logins are currently denied by /var/run/nologin:");
|
|
+#else
|
|
ssh_warning("Logins are currently denied by /etc/nologin:");
|
|
+#endif
|
|
while (fgets(buf, sizeof(buf), f))
|
|
fputs(buf, stderr);
|
|
fclose(f);
|
|
@@ -789,7 +863,11 @@
|
|
{
|
|
struct stat mailbuf;
|
|
if (stat(mailbox, &mailbuf) == -1 || mailbuf.st_size == 0)
|
|
+#ifndef __FreeBSD__
|
|
printf("No mail.\n");
|
|
+#else
|
|
+ ;
|
|
+#endif
|
|
else if (mailbuf.st_atime > mailbuf.st_mtime)
|
|
printf("You have mail.\n");
|
|
else
|