From 1f1b05a65ef3dc6597c7bc1e2a38f38ae95bf230 Mon Sep 17 00:00:00 2001 From: "kwc@citi.umich.edu" Date: Mon, 3 Jul 2006 18:34:38 -0400 Subject: [PATCH] Properly report errors in readline() function Signed-off-by: Kevin Coffman Change message priorities for errors and debug messages. --- utils/gssd/cacheio.c | 10 +++++++--- utils/gssd/svcgssd_proc.c | 2 +- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/utils/gssd/cacheio.c b/utils/gssd/cacheio.c index 07658e9..75c7a5d 100644 --- a/utils/gssd/cacheio.c +++ b/utils/gssd/cacheio.c @@ -55,6 +55,7 @@ #include #include #include +#include #include "err_util.h" void qword_add(char **bpp, int *lp, char *str) @@ -264,7 +265,8 @@ int readline(int fd, char **buf, int *lenp) } len = read(fd, *buf, *lenp); if (len <= 0) { - printerr(2, "read error in readline: %d\n", len); + printerr(0, "readline: read error: len %d errno %d (%s)\n", + len, errno, strerror(errno)); return 0; } while ((*buf)[len-1] != '\n') { @@ -280,12 +282,14 @@ int readline(int fd, char **buf, int *lenp) *buf = new; nl = read(fd, *buf +len, *lenp - len); if (nl <= 0 ) { - printerr(2, "read error in readline: %d\n", nl); + printerr(0, "readline: read error: len %d " + "errno %d (%s)\n", nl, errno, strerror(errno)); return 0; } len += nl; } (*buf)[len-1] = 0; - printerr(1, "read line with %d characters:\n%s\n", *lenp, *buf); + printerr(3, "readline: read %d chars into buffer of size %d:\n%s\n", + len, *lenp, *buf); return 1; } diff --git a/utils/gssd/svcgssd_proc.c b/utils/gssd/svcgssd_proc.c index b3a6ae8..2251d9a 100644 --- a/utils/gssd/svcgssd_proc.c +++ b/utils/gssd/svcgssd_proc.c @@ -140,7 +140,7 @@ send_response(FILE *f, gss_buffer_desc *in_handle, gss_buffer_desc *in_token, return -1; } *bp = '\0'; - printerr(1, "writing message: %s", buf); + printerr(3, "writing message: %s", buf); if (write(g, buf, bp - buf) == -1) { printerr(0, "WARNING: failed to write message\n"); close(g); -- 2.39.5