diff options
author | wens <wens@63ad8ddf-47c3-0310-b6dd-a9e9d9715204> | 2005-01-20 02:10:25 +0800 |
---|---|---|
committer | wens <wens@63ad8ddf-47c3-0310-b6dd-a9e9d9715204> | 2005-01-20 02:10:25 +0800 |
commit | ccac6983bd25c68d046c82f9168be448d12da721 (patch) | |
tree | b173d4fb13eebc0a887fa063848fccd9087094e0 | |
parent | bb629566335ef1ea90859bd467028d52e67e0f81 (diff) | |
download | pttbbs-ccac6983bd25c68d046c82f9168be448d12da721.tar pttbbs-ccac6983bd25c68d046c82f9168be448d12da721.tar.gz pttbbs-ccac6983bd25c68d046c82f9168be448d12da721.tar.bz2 pttbbs-ccac6983bd25c68d046c82f9168be448d12da721.tar.lz pttbbs-ccac6983bd25c68d046c82f9168be448d12da721.tar.xz pttbbs-ccac6983bd25c68d046c82f9168be448d12da721.tar.zst pttbbs-ccac6983bd25c68d046c82f9168be448d12da721.zip |
generic support for ssh hostname via SSH_CLIENT env (with support for ipv6 like IPs)
fix shell mode proctitle
git-svn-id: http://opensvn.csie.org/pttbbs/trunk/pttbbs@2414 63ad8ddf-47c3-0310-b6dd-a9e9d9715204
-rw-r--r-- | mbbsd/mbbsd.c | 6 | ||||
-rw-r--r-- | util/bbsrf.c | 39 |
2 files changed, 15 insertions, 30 deletions
diff --git a/mbbsd/mbbsd.c b/mbbsd/mbbsd.c index 96981179..1237a8db 100644 --- a/mbbsd/mbbsd.c +++ b/mbbsd/mbbsd.c @@ -919,7 +919,10 @@ user_login() sscanf(getenv("SSH_CLIENT"), "%s", frombuf); xsin.sin_family = AF_INET; xsin.sin_port = htons(23); - inet_pton(AF_INET, frombuf, &xsin.sin_addr); + if (strrchr(frombuf, ':')) + inet_pton(AF_INET, strrchr(frombuf, ':') + 1, &xsin.sin_addr); + else + inet_pton(AF_INET, frombuf, &xsin.sin_addr); getremotename(&xsin, fromhost, remoteusername); /* FC931 */ } @@ -1299,6 +1302,7 @@ shell_login(int argc, char *argv[], char *envp[]) use_shell_login_mode = 1; initsetproctitle(argc, argv, envp); + snprintf(margs, sizeof(margs), "%s ssh ", argv[0]); /* * copy fromindent: Standard input:1138: Error:Unexpected end of file the * original "bbs" diff --git a/util/bbsrf.c b/util/bbsrf.c index c3bf44a9..4999f993 100644 --- a/util/bbsrf.c +++ b/util/bbsrf.c @@ -39,36 +39,17 @@ /* fill the hid with from hostname */ void gethid(char *hid, char *tty) { - int fd; - char *tp; -#ifdef Solaris - struct utmpx data; -#else - struct utmp data; -#endif + char frombuf[100]; - gethostname(hid, MAX_HOMENAME_LEN); - hid[MAX_HOMENAME_LEN] = '\0'; - tp = strrchr(tty, '/') + 1; - if (tp && strlen(tp) == 5) - { - fd = open(U_FILE, O_RDONLY); - if (fd < 0) - syslog(LOG_ERR, "%s: %m", U_FILE); - else - { - while (read(fd, &data, sizeof(data)) == sizeof(data)) - if (strcmp(data.ut_line, tp) == 0) - { - if (data.ut_host[0]) { - strncpy(hid, data.ut_host, MAX_HOMENAME_LEN); - hid[MAX_HOMENAME_LEN] = '\0'; - } - break; - } - close(fd); - } - } + if (getenv("SSH_CLIENT")) + sscanf(getenv("SSH_CLIENT"), "%s", frombuf); + else + strcpy(frombuf, "127.0.0.1"); + + if (strrchr(frombuf, ':')) + strncpy(hid, strrchr(frombuf, ':') + 1, MAX_HOMENAME_LEN); + else + strncpy(hid, frombuf, MAX_HOMENAME_LEN); } /* |