summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/appl/sample/sserver/ChangeLog7
-rw-r--r--src/appl/sample/sserver/sserver.M8
-rw-r--r--src/appl/sample/sserver/sserver.c60
3 files changed, 70 insertions, 5 deletions
diff --git a/src/appl/sample/sserver/ChangeLog b/src/appl/sample/sserver/ChangeLog
index 21610c2f4..14a79dab7 100644
--- a/src/appl/sample/sserver/ChangeLog
+++ b/src/appl/sample/sserver/ChangeLog
@@ -1,3 +1,10 @@
+Wed May 10 15:18:19 1995 Ezra Peisach (epeisach@kangaroo.mit.edu)
+
+ * sserver.M: Document options.
+
+ * sserver.c: (main): Add options -p port, -S keytab for use by
+ dejagnu. Cleaned up warnings in compile.
+
Wed May 03 03:30:51 1995 Chris Provenzano (proven@mit.edu)
* sserver.c: (krb5_recvauth()): No longer needs the rc_type arg.
diff --git a/src/appl/sample/sserver/sserver.M b/src/appl/sample/sserver/sserver.M
index 2c7070a4d..0debcb739 100644
--- a/src/appl/sample/sserver/sserver.M
+++ b/src/appl/sample/sserver/sserver.M
@@ -26,6 +26,10 @@ sserver \- sample Kerberos version 5 server
.SH SYNOPSIS
.B sserver
[
+.I \-p
+port ] [
+.I \-S
+keytab ] [
.I server_port
]
.br
@@ -46,6 +50,10 @@ the
program. The srvtab file is installed in whatever
directory is defined by V5Srvtabdir (usually /etc) as "v5srvtab".
.PP
+The
+.B \-S
+option allows for a different srvtab than the default.
+.PP
\fIsserver\fP is normally invoked out of
.IR inetd(8),
using a line in
diff --git a/src/appl/sample/sserver/sserver.c b/src/appl/sample/sserver/sserver.c
index 5c04937a7..d97f5febd 100644
--- a/src/appl/sample/sserver/sserver.c
+++ b/src/appl/sample/sserver/sserver.c
@@ -38,6 +38,7 @@
#include "com_err.h"
#include <stdio.h>
+#include <string.h>
#include <ctype.h>
#include <sys/types.h>
#include <sys/socket.h>
@@ -52,6 +53,13 @@ extern krb5_deltat krb5_clockskew;
#define DEBUG
void
+usage(name)
+ char *name;
+{
+ fprintf(stderr, "usage: %s [-p port] [-S keytab]\n");
+}
+
+void
main(argc, argv)
int argc;
char *argv[];
@@ -69,6 +77,14 @@ main(argc, argv)
krb5_principal server, client;
char repbuf[BUFSIZ];
char *cname;
+ short port = 0; /* If user specifies port */
+ extern int opterr, optind;
+ extern char * optarg;
+ int ch;
+ krb5_keytab keytab = NULL; /* Allow specification on command line */
+ char *progname;
+
+ progname = *argv;
krb5_init_context(&context);
krb5_init_ets(context);
@@ -84,10 +100,44 @@ main(argc, argv)
}
/*
- * If user specified a port, then listen on that port; otherwise,
- * assume we've been started out of inetd.
+ * Parse command line arguments
+ *
*/
+ opterr = 0;
+ while ((ch = getopt(argc, argv, "p:S:")) != EOF)
+ switch (ch) {
+ case 'p':
+ port = atoi(optarg);
+ break;
+ case 'S':
+ if (retval = krb5_kt_resolve(context, optarg, &keytab)) {
+ com_err(progname, retval,
+ "while resolving keytab file %s", optarg);
+ exit(2);
+ }
+ break;
+
+ case '?':
+ default:
+ usage(progname);
+ exit(1);
+ break;
+ }
+
+ argc -= optind;
+ argv += optind;
+
+ /* Backwards compatibility, allow port to be specified at end */
if (argc > 1) {
+ port = atoi(argv[1]);
+ }
+
+ /*
+ * If user specified a port, then listen on that port; otherwise,
+ * assume we've been started out of inetd.
+ */
+
+ if (port) {
int acc;
struct sockaddr_in sin;
@@ -98,8 +148,8 @@ main(argc, argv)
sin.sin_family = AF_INET;
sin.sin_addr.s_addr = 0;
- sin.sin_port = htons(atoi(argv[1]));
- if (bind(sock, &sin, sizeof(sin))) {
+ sin.sin_port = htons(port);
+ if (bind(sock, (struct sockaddr *) &sin, sizeof(sin))) {
syslog(LOG_ERR, "bind: %m");
exit(3);
}
@@ -132,7 +182,7 @@ main(argc, argv)
if (retval = krb5_recvauth(context, &auth_context, (krb5_pointer)&sock,
SAMPLE_VERSION, server,
0, /* no flags */
- NULL, /* default keytab */
+ keytab, /* default keytab is NULL */
&ticket)) {
syslog(LOG_ERR, "recvauth failed--%s", error_message(retval));
exit(1);