GSS_S_PROMPTING_NEEDED support
[cyrus-sasl.git] / sample / server.c
index 3731e02..0fc478c 100644 (file)
@@ -83,7 +83,9 @@
 
 #include <sasl.h>
 #include <gssapi/gssapi.h>
+#ifndef KRB5_HEIMDAL
 #include <gssapi/gssapi_ext.h>
+#endif
 
 #include "common.h"
 
@@ -185,7 +187,7 @@ int *listensock(const char *port, const int af)
 
 void usage(void)
 {
-    fprintf(stderr, "usage: server [-c] [-h hostname] [-p port] [-s service] [-m mech]\n");
+    fprintf(stderr, "usage: server [-C] [-h hostname] [-p port] [-s service] [-m mech]\n");
     exit(EX_USAGE);
 }
 
@@ -325,10 +327,14 @@ int main(int argc, char *argv[])
     sasl_conn_t *conn;
     int cb_flag = 0;
 
-    while ((c = getopt(argc, argv, "ch:p:s:m:")) != EOF) {
+    while ((c = getopt(argc, argv, "Cch:p:s:m:")) != EOF) {
        switch(c) {
+       case 'C':
+           cb_flag = 2;        /* channel bindings are critical */
+           break;
+
        case 'c':
-           cb_flag = 1;
+           cb_flag = 1;        /* channel bindings are present */
            break;
 
        case 'h':
@@ -454,11 +460,12 @@ int main(int argc, char *argv[])
        if (r != SASL_OK) saslfail(r, "allocating connection state");
 
        cb.name = "sasl-sample";
-       cb.critical = cb_flag;
+       cb.critical = cb_flag > 1;
        cb.data = "this is a test of channel binding";
        cb.len = strlen(cb.data);
 
-       sasl_setprop(conn, SASL_CHANNEL_BINDING, &cb);
+       if (cb_flag)
+           sasl_setprop(conn, SASL_CHANNEL_BINDING, &cb);
 
        /* set external properties here
           sasl_setprop(conn, SASL_SSF_EXTERNAL, &extprops); */
@@ -594,7 +601,9 @@ enumerateAttributes(OM_uint32 *minor,
             dumpAttribute(minor, name, &attrs->elements[i], noisy);
     }
 
+#ifndef KRB5_HEIMDAL
     gss_release_oid(&tmp, &mech);
+#endif
     gss_release_buffer_set(&tmp, &attrs);
 
     return major;