]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
agetty: check writing to a file was successful
authorSami Kerola <kerolasa@iki.fi>
Sat, 13 Apr 2013 19:54:40 +0000 (20:54 +0100)
committerKarel Zak <kzak@redhat.com>
Fri, 26 Apr 2013 11:26:06 +0000 (13:26 +0200)
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
term-utils/agetty.c

index a23cf6dc278b9338b68d204963721a331e6c1b6b..dd52f700ff69ebede6ca3a702d89a500ed94f4a5 100644 (file)
@@ -235,6 +235,9 @@ static void login_options_to_argv(char *argv[], int *argc, char *str, char *user
 static char *fakehost;
 
 #ifdef DEBUGGING
+#ifndef
+# define DEBUG_OUTPUT "/dev/ttyp0"
+#endif
 #define debug(s) do { fprintf(dbf,s); fflush(dbf); } while (0)
 FILE *dbf;
 #else
@@ -270,7 +273,7 @@ int main(int argc, char **argv)
        sigaction(SIGINT, &sa, &sa_int);
 
 #ifdef DEBUGGING
-       dbf = fopen("/dev/ttyp0", "w");
+       dbf = fopen(DEBUG_OUTPUT, "w");
        for (int i = 1; i < argc; i++)
                debug(argv[i]);
 #endif                         /* DEBUGGING */
@@ -420,6 +423,12 @@ int main(int argc, char **argv)
                                options.tty);
        }
 
+#ifdef DEBUGGING
+       fprintf(dbf, "read %c\n", ch);
+       if (close_stream(dbf) != 0)
+               log_err("write failed: %s", DEBUG_OUTPUT);
+#endif
+
        /* Let the login program take care of password validation. */
        execv(options.login, login_argv);
        log_err(_("%s: can't exec %s: %m"), options.tty, login_argv[0]);