*/
#include <gsscon.h>
+#include <assert.h>
+static int cb_print_names(gss_name_t clientName,
+ gss_buffer_t displayName,
+ void *data)
+{
+ assert(clientName != NULL);
+ assert(data == NULL);
+ printf("Gss name: %-*s\n",
+ displayName->length, displayName->value);
+ return 0;
+}
+
+
/* --------------------------------------------------------------------------- */
static int SetupListeningSocket (int inPort,
int err = 0;
OM_uint32 minorStatus;
int port = kDefaultPort;
+ long tmp;
int listenFD = -1;
gss_ctx_id_t gssContext = GSS_C_NO_CONTEXT;
int i = 0;
-
+ gss_buffer_desc nameBuffer = {0, "trustidentity"};
+
for (i = 1; (i < argc) && !err; i++) {
if ((strcmp (argv[i], "--port") == 0) && (i < (argc - 1))) {
- port = strtol (argv[++i], NULL, 0);
- if (port == 0) { err = errno; }
+ errno = 0; /* ensure this starts off at 0 */
+ tmp = strtol (argv[++i], NULL, 0);
+ if (errno)
+ err = errno;
+ else if ((tmp <= 0) || (tmp > 65535))
+ err = ERANGE;
+ else
+ port = (int) tmp;
} else if ((strcmp(argv[i], "--service") == 0) && (i < (argc - 1))) {
gServiceName = argv[++i];
} else {
int authorizationError = 0;
connectionFD = accept (listenFD, NULL, NULL);
+
if (connectionFD < 0) {
if (errno != EINTR) {
err = errno;
}
printf ("Accepting new connection...\n");
- connectionErr = gsscon_passive_authenticate (connectionFD, &gssContext);
+ connectionErr = gsscon_passive_authenticate (connectionFD, nameBuffer, &gssContext,
+ cb_print_names, NULL);
if (!connectionErr) {
connectionErr = gsscon_authorize (gssContext,