summaryrefslogtreecommitdiffstats
path: root/term-utils/agetty.c
diff options
context:
space:
mode:
authorSami Kerola2013-04-13 21:54:40 +0200
committerKarel Zak2013-04-26 13:26:06 +0200
commit1aba8336c094e26d189ce792606ecbac246209ce (patch)
tree30119881da5b6a342fa692fef31d0ac3596d0fdc /term-utils/agetty.c
parentsetpriv: check writing to a file was successful (diff)
downloadkernel-qcow2-util-linux-1aba8336c094e26d189ce792606ecbac246209ce.tar.gz
kernel-qcow2-util-linux-1aba8336c094e26d189ce792606ecbac246209ce.tar.xz
kernel-qcow2-util-linux-1aba8336c094e26d189ce792606ecbac246209ce.zip
agetty: check writing to a file was successful
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
Diffstat (limited to 'term-utils/agetty.c')
-rw-r--r--term-utils/agetty.c11
1 files changed, 10 insertions, 1 deletions
diff --git a/term-utils/agetty.c b/term-utils/agetty.c
index a23cf6dc2..dd52f700f 100644
--- a/term-utils/agetty.c
+++ b/term-utils/agetty.c
@@ -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]);