Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/usr.bin/login don't abuse the instance variable



details:   https://anonhg.NetBSD.org/src/rev/8d1d4d3d1355
branches:  trunk
changeset: 778983:8d1d4d3d1355
user:      christos <christos%NetBSD.org@localhost>
date:      Mon Apr 23 21:09:27 2012 +0000

description:
don't abuse the instance variable

diffstat:

 usr.bin/login/login.c |  18 ++++++++----------
 1 files changed, 8 insertions(+), 10 deletions(-)

diffs (77 lines):

diff -r a4a12739dcef -r 8d1d4d3d1355 usr.bin/login/login.c
--- a/usr.bin/login/login.c     Mon Apr 23 20:57:04 2012 +0000
+++ b/usr.bin/login/login.c     Mon Apr 23 21:09:27 2012 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: login.c,v 1.101 2012/04/23 20:57:04 christos Exp $     */
+/*     $NetBSD: login.c,v 1.102 2012/04/23 21:09:27 christos Exp $     */
 
 /*-
  * Copyright (c) 1980, 1987, 1988, 1991, 1993, 1994
@@ -39,7 +39,7 @@
 #if 0
 static char sccsid[] = "@(#)login.c    8.4 (Berkeley) 4/2/94";
 #endif
-__RCSID("$NetBSD: login.c,v 1.101 2012/04/23 20:57:04 christos Exp $");
+__RCSID("$NetBSD: login.c,v 1.102 2012/04/23 21:09:27 christos Exp $");
 #endif /* not lint */
 
 /*
@@ -121,12 +121,11 @@
 int    notickets = 1;
 extern krb5_context kcontext;
 extern int     have_forward;
+static char    *instance;
 extern char    *krb5tkfile_env;
 extern int     krb5_configured;
 #endif
 
-static char    *instance;
-
 #if defined(KERBEROS5)
 #define        KERBEROS_CONFIGURED     krb5_configured
 #endif
@@ -151,6 +150,7 @@
        int login_retries = DEFAULT_RETRIES, 
            login_backoff = DEFAULT_BACKOFF;
        time_t pw_warntime = _PASSWORD_WARNDAYS * SECSPERDAY;
+       char *loginname = NULL;
 #ifdef KERBEROS5
        krb5_error_code kerror;
 #endif
@@ -243,7 +243,7 @@
        argv += optind;
 
        if (*argv) {
-               username = instance = *argv;
+               username = loginname = *argv;
                ask = 0;
        } else
                ask = 1;
@@ -309,24 +309,22 @@
 #endif /* KERBEROS5 */
 
        for (cnt = 0;; ask = 1) {
-               char *ptr;
 #if defined(KERBEROS5)
                if (login_krb5_get_tickets)
                        k5destroy();
 #endif
                if (ask) {
                        fflag = 0;
-                       instance = getloginname();
+                       loginname = getloginname();
                }
                rootlogin = 0;
-               ptr = instance;
 #ifdef KERBEROS5
-               if ((instance = strchr(instance, '/')) != NULL)
+               if ((instance = strchr(loginname, '/')) != NULL)
                        *instance++ = '\0';
                else
                        instance = __UNCONST("");
 #endif
-               username = trimloginname(ptr);
+               username = trimloginname(loginname);
                /*
                 * Note if trying multiple user names; log failures for
                 * previous user name, but don't bother logging one failure



Home | Main Index | Thread Index | Old Index