From f3750c9f043966e87cc2b3ae4cbd4c9fddcb381b Mon Sep 17 00:00:00 2001 From: Assar Westerlund Date: Sun, 1 Jun 1997 03:14:38 +0000 Subject: [PATCH] clean-up git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@1790 ec53bebd-3082-4978-b11e-865c3cabbd6b --- appl/login/utmpx_login.c | 5 +++-- appl/telnet/telnet/commands.c | 17 ++++++----------- appl/telnet/telnetd/sys_term.c | 17 ++++++++++------- 3 files changed, 19 insertions(+), 20 deletions(-) diff --git a/appl/login/utmpx_login.c b/appl/login/utmpx_login.c index 1c01ea3c0..e68040494 100644 --- a/appl/login/utmpx_login.c +++ b/appl/login/utmpx_login.c @@ -14,10 +14,11 @@ static void utmpx_update(struct utmpx *ut, char *line, char *user, char *host) { struct timeval tmp; + char *clean_tty = clean_ttyname(line); - strncpy(ut->ut_line, clean_ttyname(line), sizeof(ut->ut_line)); + strncpy(ut->ut_line, clean_tty, sizeof(ut->ut_line)); #ifdef HAVE_UT_ID - strncpy(ut->ut_id, make_id(ut->ut_line), sizeof(ut->ut_id)); + strncpy(ut->ut_id, make_id(clean_tty), sizeof(ut->ut_id)); #endif strncpy(ut->ut_user, user, sizeof(ut->ut_user)); strncpy(ut->ut_host, host, sizeof(ut->ut_host)); diff --git a/appl/telnet/telnet/commands.c b/appl/telnet/telnet/commands.c index f84f5be11..b31c829fe 100644 --- a/appl/telnet/telnet/commands.c +++ b/appl/telnet/telnet/commands.c @@ -1944,14 +1944,12 @@ ayt_status(void) } #endif -static char *rcname = 0; -static char rcbuf[128]; - static Command *getcmd(char *name); static void cmdrc(char *m1, char *m2) { + static char rcname[128]; Command *c; FILE *rcfile; int gotmachine = 0; @@ -1965,14 +1963,11 @@ cmdrc(char *m1, char *m2) strcpy(m1save, m1); m1 = m1save; - if (rcname == 0) { - rcname = getenv("HOME"); - if (rcname) - strcpy(rcbuf, rcname); - else - rcbuf[0] = '\0'; - strcat(rcbuf, "/.telnetrc"); - rcname = rcbuf; + if (rcname[0] == 0) { + char *home = getenv("HOME"); + + snprintf (rcname, sizeof(rcname), "%s/.telnetrc", + home ? home : ""); } if ((rcfile = fopen(rcname, "r")) == 0) { diff --git a/appl/telnet/telnetd/sys_term.c b/appl/telnet/telnetd/sys_term.c index 57fa633f8..6253abc02 100644 --- a/appl/telnet/telnetd/sys_term.c +++ b/appl/telnet/telnetd/sys_term.c @@ -1251,17 +1251,18 @@ void start_login(char *host, int autologin, char *name) int pid = getpid(); struct utmpx utmpx; struct timeval tmp; + char *clean_tty; /* * Create utmp entry for child */ + clean_tty = clean_ttyname(line); memset(&utmpx, 0, sizeof(utmpx)); strncpy(utmpx.ut_user, ".telnet", sizeof(utmpx.ut_user)); - - strncpy(utmpx.ut_line, clean_ttyname(line), sizeof(utmpx.ut_line)); + strncpy(utmpx.ut_line, clean_tty, sizeof(utmpx.ut_line)); #ifdef HAVE_UT_ID - strncpy(utmpx.ut_id, make_id(utmpx.ut_line), sizeof(utmpx.ut_id)); + strncpy(utmpx.ut_id, make_id(clean_tty), sizeof(utmpx.ut_id)); #endif utmpx.ut_pid = pid; @@ -1379,6 +1380,7 @@ rmut(void) struct stat statbf; struct timeval tmp; struct utmpx *utxp, utmpx; + char *clean_tty = clean_ttyname(line); /* * This updates the utmpx and utmp entries and make a wtmp/x entry @@ -1386,7 +1388,7 @@ rmut(void) setutxent(); memset(&utmpx, 0, sizeof(utmpx)); - strncpy(utmpx.ut_line, clean_ttyname(line), sizeof(utmpx.ut_line)); + strncpy(utmpx.ut_line, clean_tty, sizeof(utmpx.ut_line)); utmpx.ut_type = LOGIN_PROCESS; utxp = getutxline(&utmpx); if (utxp) { @@ -1412,7 +1414,7 @@ rmut(void) int f = open(wtmpf, O_WRONLY|O_APPEND); struct utmp wtmp; if (f >= 0) { - strncpy(wtmp.ut_line, clean_ttyname(line), sizeof(wtmp.ut_line)); + strncpy(wtmp.ut_line, clean_tty, sizeof(wtmp.ut_line)); strncpy(wtmp.ut_name, "", sizeof(wtmp.ut_name)); #ifdef HAVE_UT_HOST strncpy(wtmp.ut_host, "", sizeof(wtmp.ut_host)); @@ -1439,6 +1441,7 @@ rmut(void) struct utmp *u, *utmp; int nutmp; struct stat statbf; + char *clean_tty = clean_ttyname(line); f = open(utmpf, O_RDWR); if (f >= 0) { @@ -1452,7 +1455,7 @@ rmut(void) for (u = utmp ; u < &utmp[nutmp] ; u++) { if (strncmp(u->ut_line, - clean_ttyname(line), + clean_tty, sizeof(u->ut_line)) || u->ut_name[0]==0) continue; @@ -1471,7 +1474,7 @@ rmut(void) if (found) { f = open(wtmpf, O_WRONLY|O_APPEND); if (f >= 0) { - strncpy(wtmp.ut_line, clean_ttyname(line), sizeof(wtmp.ut_line)); + strncpy(wtmp.ut_line, clean_tty, sizeof(wtmp.ut_line)); strncpy(wtmp.ut_name, "", sizeof(wtmp.ut_name)); #ifdef HAVE_UT_HOST strncpy(wtmp.ut_host, "", sizeof(wtmp.ut_host));