
commit 2665a89ba8ba34f8e34bde42e9c1ff1f98940e73
Author: Kevin Coffman <kwc@citi.umich.edu>
Date:   Wed Sep 27 16:03:11 2006 -0400

    Add keyring values to stuff that is passed down for keyring pipe.
    
    Need to pass down keyring values as well as uid, etc. on the keyring
    downcall pipe.  This is so that the _gss_find_upcall function can
    find the right message.

index 30e3b7c..c098958 100644

---


diff -puN utils/gssd/gssd.h~pass_down_ring_values utils/gssd/gssd.h
--- nfs-utils-1.0.10/utils/gssd/gssd.h~pass_down_ring_values	2006-10-05 10:36:32.000000000 -0400
+++ nfs-utils-1.0.10-andros/utils/gssd/gssd.h	2006-10-05 10:36:32.000000000 -0400
@@ -112,9 +112,9 @@ void handle_spkm3_upcall(struct clnt_inf
 inline int set_user_fsuid(struct clnt_info *clp);
 inline int restore_our_fsuid(struct clnt_info *clp);
 
-int do_downcall(int fd, uid_t uid, struct authgss_private_data *pd,
+int do_downcall(int fd, struct clnt_info *clp, struct authgss_private_data *pd,
 		gss_buffer_desc *context_token);
-int do_error_downcall(int fd, uid_t uid, int err);
+int do_error_downcall(int fd, struct clnt_info *clp, int err);
 
 int create_auth_rpc_client(struct clnt_info *clp,
 			   CLIENT **clnt_return,
diff -puN utils/gssd/gssd_keyring.c~pass_down_ring_values utils/gssd/gssd_keyring.c
--- nfs-utils-1.0.10/utils/gssd/gssd_keyring.c~pass_down_ring_values	2006-10-05 10:36:32.000000000 -0400
+++ nfs-utils-1.0.10-andros/utils/gssd/gssd_keyring.c	2006-10-05 10:36:32.000000000 -0400
@@ -269,7 +269,9 @@ keyring_do_downcall(struct clnt_info *cl
         char keybuf[2048];
         int buflen;
 
-        printerr(2, "%s: called for uid %d\n", __FUNCTION__, clp->uid);
+        printerr(1, "%s: called for uid %d <%d:%d:%d>\n",
+		__FUNCTION__, clp->uid, clp->session_ring,
+		clp->process_ring, clp->thread_ring);
 
         buflen = sizeof(keybuf);
         if (serialize_ctx_key_data(keybuf, &buflen, clp, pd, context_token)) {
@@ -283,7 +285,7 @@ keyring_do_downcall(struct clnt_info *cl
                             __FUNCTION__, clp->key, key_rtn, strerror(errno));
                 goto out_err;
         }
-        do_downcall(clp->keyring_fd, clp->uid, pd, context_token);
+        do_downcall(clp->keyring_fd, clp, pd, context_token);
         return 0;
 out_err:
         return -1;
@@ -294,8 +296,9 @@ keyring_do_error_downcall(struct clnt_in
 {
         unsigned int timeout = 1;
 
-        printerr(2, "%s: called for uid %d (err %d)\n",
-                __FUNCTION__, clp->uid, err);
+        printerr(1, "%s: called for uid %d (err %d) <%d:%d:%d>\n",
+                __FUNCTION__, clp->uid, err, clp->session_ring,
+		clp->process_ring, clp->thread_ring);
 
         /* Become the user */
         if (set_user_fsuid(clp) != 0)
@@ -306,7 +309,7 @@ keyring_do_error_downcall(struct clnt_in
                             __FUNCTION__, clp->key, strerror(errno));
         }
         restore_our_fsuid(clp);
-        do_error_downcall(clp->keyring_fd, clp->uid, err);
+        do_error_downcall(clp->keyring_fd, clp, err);
 }
 
 static void
@@ -320,7 +323,7 @@ keyring_handle_krb5_upcall(struct clnt_i
         char *ccname = NULL;
         uint32_t ctx_endtime;
 
-        printerr(1, "%s: entered\n", __FUNCTION__);
+        printerr(2, "%s: entered\n", __FUNCTION__);
 
         memset(&pd, 0, sizeof(pd));
 
@@ -418,7 +421,7 @@ out_err_cleanup:
                 clnt_destroy(rpc_clnt);
         if (ccname)
                 free(ccname);
-        printerr(1, "%s: returning err = %d\n", __FUNCTION__, err);
+        printerr(2, "%s: returning err = %d\n", __FUNCTION__, err);
         if (err)
             keyring_do_error_downcall(clp, -1);
         return;
@@ -453,9 +456,6 @@ handle_keyring_upcall(struct clnt_info *
                 goto out_err;
         }
 
-        printerr(2, "handling keyring upcall to instantiate key %d "
-                 "(with authkey %d) for uid %d\n", key, authkey, uid);
-
         clp->uid = uid;
         clp->gid = gid;
         clp->key = key;
@@ -485,6 +485,11 @@ handle_keyring_upcall(struct clnt_info *
          * Call mechanism-specific routine to handle negotiating the
          * context and instantiating the key.
          */
+        printerr(1, "===> %s: handling keyring upcall to instantiate %s "
+		 "ctx key %d (with authkey %d) for uid %d <%d:%d:%d> \n",
+		 __FUNCTION__, clp->mechanism, key, authkey, uid,
+		 skey, pkey, tkey);
+
         if (strcmp(clp->mechanism, "krb5") == 0) {
                 keyring_handle_krb5_upcall(clp);
         } else if (strcmp(clp->mechanism, "spkm3") == 0) {
@@ -498,10 +503,12 @@ handle_keyring_upcall(struct clnt_info *
                          __FUNCTION__, clp->mechanism);
         }
 
-        printerr(2, "<=== %s: clp %p\n", __FUNCTION__, clp);
+        printerr(1, "<=== %s: uid %d <%d:%d:%d>\n", __FUNCTION__,
+		uid, skey, pkey, tkey);
         return;
 out_err:
-        printerr(2, "<=== %s: clp %p (err %d)\n", __FUNCTION__, clp, err);
+        printerr(1, "<=== %s: uid %d (err %d) <%d:%d:%d>\n",
+		 __FUNCTION__, uid, err, skey, pkey, tkey);
         keyring_do_error_downcall(clp, err);
 }
 
diff -puN utils/gssd/gssd_proc.c~pass_down_ring_values utils/gssd/gssd_proc.c
--- nfs-utils-1.0.10/utils/gssd/gssd_proc.c~pass_down_ring_values	2006-10-05 10:36:32.000000000 -0400
+++ nfs-utils-1.0.10-andros/utils/gssd/gssd_proc.c	2006-10-05 10:36:32.000000000 -0400
@@ -435,7 +435,7 @@ update_client_list(void)
 }
 
 int
-do_downcall(int fd, uid_t uid, struct authgss_private_data *pd,
+do_downcall(int fd, struct clnt_info *clp, struct authgss_private_data *pd,
 	    gss_buffer_desc *context_token)
 {
 	char    *buf = NULL, *p = NULL, *end = NULL;
@@ -443,13 +443,21 @@ do_downcall(int fd, uid_t uid, struct au
 	unsigned int buf_size = 0;
 
 	printerr(1, "doing downcall\n");
-	buf_size = sizeof(uid) + sizeof(timeout) + sizeof(pd->pd_seq_win) +
+	buf_size = sizeof(clp->uid) + sizeof(timeout) + sizeof(pd->pd_seq_win) +
 		sizeof(pd->pd_ctx_hndl.length) + pd->pd_ctx_hndl.length +
 		sizeof(context_token->length) + context_token->length;
+	if (fd == clp->keyring_fd)
+		buf_size += sizeof(clp->session_ring) +
+			sizeof(clp->process_ring) + sizeof(clp->thread_ring);
 	p = buf = malloc(buf_size);
 	end = buf + buf_size;
 
-	if (WRITE_BYTES(&p, end, uid)) goto out_err;
+	if (WRITE_BYTES(&p, end, clp->uid)) goto out_err;
+	if (fd == clp->keyring_fd) {
+		if (WRITE_BYTES(&p, end, clp->session_ring)) goto out_err;
+		if (WRITE_BYTES(&p, end, clp->process_ring)) goto out_err;
+		if (WRITE_BYTES(&p, end, clp->thread_ring)) goto out_err;
+	}
 	/* Not setting any timeout for now: */
 	if (WRITE_BYTES(&p, end, timeout)) goto out_err;
 	if (WRITE_BYTES(&p, end, pd->pd_seq_win)) goto out_err;
@@ -466,7 +474,7 @@ out_err:
 }
 
 int
-do_error_downcall(int fd, uid_t uid, int err)
+do_error_downcall(int fd, struct clnt_info *clp, int err)
 {
 	char	buf[1024];
 	char	*p = buf, *end = buf + 1024;
@@ -475,7 +483,12 @@ do_error_downcall(int fd, uid_t uid, int
 
 	printerr(1, "doing error downcall\n");
 
-	if (WRITE_BYTES(&p, end, uid)) goto out_err;
+	if (WRITE_BYTES(&p, end, clp->uid)) goto out_err;
+	if (fd == clp->keyring_fd) {
+		if (WRITE_BYTES(&p, end, clp->session_ring)) goto out_err;
+		if (WRITE_BYTES(&p, end, clp->process_ring)) goto out_err;
+		if (WRITE_BYTES(&p, end, clp->thread_ring)) goto out_err;
+	}
 	if (WRITE_BYTES(&p, end, timeout)) goto out_err;
 	/* use seq_win = 0 to indicate an error: */
 	if (WRITE_BYTES(&p, end, zero)) goto out_err;
@@ -811,7 +824,7 @@ handle_krb5_upcall(struct clnt_info *clp
 		goto out_return_error;
 	}
 
-	do_downcall(clp->krb5_fd, uid, &pd, &token);
+	do_downcall(clp->krb5_fd, clp, &pd, &token);
 
 out:
 	if (token.value)
@@ -825,7 +838,7 @@ out:
 	return;
 
 out_return_error:
-	do_error_downcall(clp->krb5_fd, uid, -1);
+	do_error_downcall(clp->krb5_fd, clp, -1);
 	goto out;
 }
 
@@ -873,7 +886,7 @@ handle_spkm3_upcall(struct clnt_info *cl
 		goto out_return_error;
 	}
 
-	do_downcall(clp->spkm3_fd, uid, &pd, &token);
+	do_downcall(clp->spkm3_fd, clp, &pd, &token);
 
 out:
 	if (token.value)
@@ -885,6 +898,6 @@ out:
 	return;
 
 out_return_error:
-	do_error_downcall(clp->spkm3_fd, uid, -1);
+	do_error_downcall(clp->spkm3_fd, clp, -1);
 	goto out;
 }
_
