]> granicus.if.org Git - shadow/commitdiff
* libmisc/console.c (console): Remove the leading /dev/ from the
authornekral-guest <nekral-guest@5a98b0ae-9ef6-0310-add3-de5d479b70d7>
Sat, 16 May 2009 18:19:24 +0000 (18:19 +0000)
committernekral-guest <nekral-guest@5a98b0ae-9ef6-0310-add3-de5d479b70d7>
Sat, 16 May 2009 18:19:24 +0000 (18:19 +0000)
tty before comparing with the lines specified by CONSOLE.
* src/su.c: Do not remove the /dev/ prefix since it is done by
console().

ChangeLog
libmisc/console.c
src/su.c

index 301d08d8784cbf6fe83501879b99a22797de6947..4847e133d0571524c5ec4d5fd313900e8e849a8b 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2009-05-16  Nicolas François  <nicolas.francois@centraliens.net>
+
+       * libmisc/console.c (console): Remove the leading /dev/ from the
+       tty before comparing with the lines specified by CONSOLE.
+       * src/su.c: Do not remove the /dev/ prefix since it is done by
+       console().
+
 2009-05-16  Nicolas François  <nicolas.francois@centraliens.net>
 
        * man/login.defs.d/CONSOLE.xml: Document the format of the CONSOLE
index 458aaf2e8031dc2a734d5b4f6826da7bae7bf50e..20fbd7f5eb333d16a3e694aa3392466566f414b2 100644 (file)
@@ -121,6 +121,10 @@ static bool is_listed (const char *cfgin, const char *tty, bool def)
 
 bool console (const char *tty)
 {
+       if (strncmp (tty, "/dev/", 5) == 0) {
+               tty += 5;
+       }
+
        return is_listed ("CONSOLE", tty, true);
 }
 
index 57df663a597ed291e77571dbd261e05111f8c948..80f8667d5bbaa1524b5f721a7d0f1725cb6f711c 100644 (file)
--- a/src/su.c
+++ b/src/su.c
@@ -425,13 +425,8 @@ int main (int argc, char **argv)
         * Get the tty name. Entries will be logged indicating that the user
         * tried to change to the named new user from the current terminal.
         */
-       cp = ttyname (0);
-       if ((isatty (0) != 0) && (NULL != cp)) {
-               if (strncmp (cp, "/dev/", 5) == 0) {
-                       tty = cp + 5;
-               } else {
-                       tty = cp;
-               }
+       tty = ttyname (0);
+       if ((isatty (0) != 0) && (NULL != tty)) {
 #ifndef USE_PAM
                is_console = console (tty);
 #endif