summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorwens <wens@63ad8ddf-47c3-0310-b6dd-a9e9d9715204>2005-09-25 22:22:47 +0800
committerwens <wens@63ad8ddf-47c3-0310-b6dd-a9e9d9715204>2005-09-25 22:22:47 +0800
commitc1689f74c8bfc6ff538264dad3335f128242fc02 (patch)
tree0665e8f484f03a8edf471ac26b8e5a92a556ce91
parent2b8f111d37842237a6044cdc874a2105048956a0 (diff)
downloadpttbbs-c1689f74c8bfc6ff538264dad3335f128242fc02.tar
pttbbs-c1689f74c8bfc6ff538264dad3335f128242fc02.tar.gz
pttbbs-c1689f74c8bfc6ff538264dad3335f128242fc02.tar.bz2
pttbbs-c1689f74c8bfc6ff538264dad3335f128242fc02.tar.lz
pttbbs-c1689f74c8bfc6ff538264dad3335f128242fc02.tar.xz
pttbbs-c1689f74c8bfc6ff538264dad3335f128242fc02.tar.zst
pttbbs-c1689f74c8bfc6ff538264dad3335f128242fc02.zip
Declare xsin only when needed.
git-svn-id: http://opensvn.csie.org/pttbbs/trunk/pttbbs@3208 63ad8ddf-47c3-0310-b6dd-a9e9d9715204
-rw-r--r--mbbsd/mbbsd.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/mbbsd/mbbsd.c b/mbbsd/mbbsd.c
index ed55c868..c556c908 100644
--- a/mbbsd/mbbsd.c
+++ b/mbbsd/mbbsd.c
@@ -34,8 +34,6 @@ static char remoteusername[40] = "?";
static unsigned char enter_uflag;
static int use_shell_login_mode = 0;
-static struct sockaddr_in xsin;
-
#ifdef USE_RFORK
#define fork() rfork(RFFDG | RFPROC | RFNOWAIT)
#endif
@@ -1037,6 +1035,7 @@ user_login(void)
strlcpy(water[0].userid, " ¥þ³¡ ", sizeof(water[0].userid));
if(getenv("SSH_CLIENT") != NULL){
+ struct sockaddr_in xsin;
char frombuf[50];
sscanf(getenv("SSH_CLIENT"), "%s", frombuf);
xsin.sin_family = AF_INET;
@@ -1372,6 +1371,7 @@ bind_port(int port)
{
int sock, on, sz;
struct linger lin;
+ struct sockaddr_in xsin;
sock = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
@@ -1387,6 +1387,8 @@ bind_port(int port)
sz = 4096;
setsockopt(sock, SOL_SOCKET, SO_SNDBUF, (void*)&sz, sizeof(sz));
+ xsin.sin_family = AF_INET;
+ xsin.sin_addr.s_addr = htonl(INADDR_ANY);
xsin.sin_port = htons(port);
if (bind(sock, (struct sockaddr *) & xsin, sizeof xsin) < 0) {
syslog(LOG_INFO, "bbsd bind_port can't bind to %d", port);
@@ -1494,6 +1496,8 @@ daemon_login(int argc, char *argv[], char *envp[])
int blockfd[OVERLOADBLOCKFDS];
int i, nblocked = 0;
#endif
+ struct sockaddr_in xsin;
+ xsin.sin_family = AF_INET;
/* setup standalone */
@@ -1510,7 +1514,6 @@ daemon_login(int argc, char *argv[], char *envp[])
snprintf(margs, sizeof(margs), "%s %d ", argv[0], listen_port);
/* port binding */
- xsin.sin_family = AF_INET;
msock = bind_port(listen_port);
if (msock < 0) {
syslog(LOG_INFO, "mbbsd bind_port failed.\n");