From 12f5f252104f45a047aa111ee0aa5c5244030cc7 Mon Sep 17 00:00:00 2001 From: Theodore Tso Date: Fri, 29 Sep 1995 05:53:14 +0000 Subject: [PATCH] gss-client.c (main): Set display_file to be stdout gss-server.c (main): Set display_file to 0 if using inetd; otherwise, set it to be stdout. gss-misc.c (send_token, recv_token, display_status): If display_file is null, don't set it to stderr; just don't print the log message instead. Needed for inetd operation. git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@6892 dc483132-0cff-0310-8789-dd5450dbe970 --- src/appl/gss-sample/ChangeLog | 11 ++++++++ src/appl/gss-sample/gss-client.c | 4 +++ src/appl/gss-sample/gss-misc.c | 44 +++++++++++++++----------------- src/appl/gss-sample/gss-server.c | 2 ++ 4 files changed, 37 insertions(+), 24 deletions(-) diff --git a/src/appl/gss-sample/ChangeLog b/src/appl/gss-sample/ChangeLog index 494a0d859..ad0b68425 100644 --- a/src/appl/gss-sample/ChangeLog +++ b/src/appl/gss-sample/ChangeLog @@ -1,3 +1,14 @@ +Wed Sep 27 18:36:06 1995 Theodore Y. Ts'o + + * gss-client.c (main): Set display_file to be stdout. + + * gss-server.c (main): Set display_file to 0 if using inetd; + otherwise, set it to be stdout. + + * gss-misc.c (send_token, recv_token, display_status): If + display_file is null, don't set it to stderr; just don't + print the log message instead. Needed for inetd operation. + Sat Sep 16 03:34:59 1995 Theodore Y. Ts'o * gss-server.c (sign_server): Only try using gss_export_context diff --git a/src/appl/gss-sample/gss-client.c b/src/appl/gss-sample/gss-client.c index e8205a6bb..56e07c2d6 100644 --- a/src/appl/gss-sample/gss-client.c +++ b/src/appl/gss-sample/gss-client.c @@ -43,6 +43,8 @@ int send_token(); int recv_token(); void display_status(); +extern FILE *display_file; + usage() { fprintf(stderr, "Usage: gss-client [-port port] [-v2] host service msg\n"); @@ -57,6 +59,8 @@ main(argc, argv) u_short port = 4444; int v2 = 0; + display_file = stdout; + /* Parse arguments. */ argc--; argv++; while (argc) { diff --git a/src/appl/gss-sample/gss-misc.c b/src/appl/gss-sample/gss-misc.c index 4ad6824ca..8abf90f7b 100644 --- a/src/appl/gss-sample/gss-misc.c +++ b/src/appl/gss-sample/gss-misc.c @@ -64,9 +64,6 @@ int send_token(s, tok) { int len, ret; - if (display_file == 0) - display_file = stderr; - len = htonl(tok->length); ret = write(s, (char *) &len, 4); @@ -74,9 +71,10 @@ int send_token(s, tok) perror("sending token length"); return -1; } else if (ret != 4) { - fprintf(display_file, - "sending token length: %d of %d bytes written\n", - ret, 4); + if (display_file) + fprintf(display_file, + "sending token length: %d of %d bytes written\n", + ret, 4); return -1; } @@ -85,10 +83,11 @@ int send_token(s, tok) perror("sending token data"); return -1; } else if (ret != tok->length) { - fprintf(display_file, - "sending token data: %d of %d bytes written\n", - ret, tok->length); - return -1; + if (display_file) + fprintf(display_file, + "sending token data: %d of %d bytes written\n", + ret, tok->length); + return -1; } return 0; @@ -122,25 +121,24 @@ int recv_token(s, tok) int ret; int readsofar = 0; - if (display_file == 0) - display_file = stderr; - ret = read(s, (char *) &tok->length, 4); if (ret < 0) { perror("reading token length"); return -1; } else if (ret != 4) { - fprintf(display_file, - "reading token length: %d of %d bytes read\n", - ret, 4); - return -1; + if (display_file) + fprintf(display_file, + "reading token length: %d of %d bytes read\n", + ret, 4); + return -1; } tok->length = ntohl(tok->length); tok->value = (char *) malloc(tok->length); if (tok->value == NULL) { - fprintf(display_file, - "Out of memory allocating token data\n"); + if (display_file) + fprintf(display_file, + "Out of memory allocating token data\n"); return -1; } @@ -196,16 +194,14 @@ static void display_status_1(m, code, type) int msg_ctx; #endif /* GSSAPI_V2 */ - if (display_file == 0) - display_file = stderr; - msg_ctx = 0; while (1) { maj_stat = gss_display_status(&min_stat, code, type, GSS_C_NULL_OID, &msg_ctx, &msg); - fprintf(display_file, "GSS-API error %s: %s\n", m, - (char *)msg.value); + if (display_file) + fprintf(display_file, "GSS-API error %s: %s\n", m, + (char *)msg.value); (void) gss_release_buffer(&min_stat, &msg); if (!msg_ctx) diff --git a/src/appl/gss-sample/gss-server.c b/src/appl/gss-sample/gss-server.c index 1f871f794..4d0a03c85 100644 --- a/src/appl/gss-sample/gss-server.c +++ b/src/appl/gss-sample/gss-server.c @@ -69,6 +69,7 @@ main(argc, argv) int once = 0; log = stdout; + display_file = stdout; argc--; argv++; while (argc) { if (strcmp(*argv, "-port") == 0) { @@ -77,6 +78,7 @@ main(argc, argv) port = atoi(*argv); } else if (strcmp(*argv, "-inetd") == 0) { do_inetd = 1; + display_file = 0; } else if (strcmp(*argv, "-v2") == 0) { dov2 = 1; } else if (strcmp(*argv, "-once") == 0) { -- 2.26.2