diff mbox series

[1/1] libtirpc: gss-api: expose gss major/minor error in authgss_refresh()

Message ID 20230829201902.63036-2-olga.kornievskaia@gmail.com (mailing list archive)
State New, archived
Headers show
Series [1/1] libtirpc: gss-api: expose gss major/minor error in authgss_refresh() | expand

Commit Message

Olga Kornievskaia Aug. 29, 2023, 8:18 p.m. UTC
From: Olga Kornievskaia <kolga@netapp.com>

When the client calls into the libtirpc to establish security
context, the errors that occurred are squashed. Instead, extend
authgss_refresh to propagate back the gss major/minor error
codes to the caller.

Signed-off-by: Olga Kornievskaia <kolga@netapp.com>
---
 src/auth_gss.c       | 17 +++++++++--------
 tirpc/rpc/auth_gss.h |  2 ++
 2 files changed, 11 insertions(+), 8 deletions(-)
diff mbox series

Patch

diff --git a/src/auth_gss.c b/src/auth_gss.c
index e317664..fa96acd 100644
--- a/src/auth_gss.c
+++ b/src/auth_gss.c
@@ -54,7 +54,7 @@ 
 
 static void	authgss_nextverf(AUTH *);
 static bool_t	authgss_marshal(AUTH *, XDR *);
-static bool_t	authgss_refresh(AUTH *, void *);
+static bool_t	authgss_refresh(AUTH *, rpc_gss_options_ret_t *);
 static bool_t	authgss_validate(AUTH *, struct opaque_auth *);
 static void	authgss_destroy(AUTH *);
 static void	authgss_destroy_context(AUTH *);
@@ -184,6 +184,7 @@  authgss_create(CLIENT *clnt, gss_name_t name, struct rpc_gss_sec *sec)
 	AUTH			*auth, *save_auth;
 	struct rpc_gss_data	*gd;
 	OM_uint32		min_stat = 0;
+	rpc_gss_options_ret_t	ret;
 
 	gss_log_debug("in authgss_create()");
 
@@ -229,8 +230,12 @@  authgss_create(CLIENT *clnt, gss_name_t name, struct rpc_gss_sec *sec)
 	save_auth = clnt->cl_auth;
 	clnt->cl_auth = auth;
 
-	if (!authgss_refresh(auth, NULL))
+	memset(&ret, 0, sizeof(rpc_gss_options_ret_t));
+	if (!authgss_refresh(auth, &ret)) {
 		auth = NULL;
+		sec->major_status = ret.major_status;
+		sec->minor_status = ret.minor_status;
+	}
 	else
 		authgss_auth_get(auth); /* Reference for caller */
 
@@ -265,7 +270,6 @@  authgss_create_default(CLIENT *clnt, char *service, struct rpc_gss_sec *sec)
 	}
 
 	auth = authgss_create(clnt, name, sec);
-
 	if (name != GSS_C_NO_NAME) {
 		LIBTIRPC_DEBUG(3, ("authgss_create_default: freeing name %p", name));
  		gss_release_name(&min_stat, &name);
@@ -619,12 +623,9 @@  _rpc_gss_refresh(AUTH *auth, rpc_gss_options_ret_t *options_ret)
 }
 
 static bool_t
-authgss_refresh(AUTH *auth, void *dummy)
+authgss_refresh(AUTH *auth, rpc_gss_options_ret_t *ret)
 {
-	rpc_gss_options_ret_t ret;
-
-	memset(&ret, 0, sizeof(ret));
-	return _rpc_gss_refresh(auth, &ret);
+	return _rpc_gss_refresh(auth, ret);
 }
 
 bool_t
diff --git a/tirpc/rpc/auth_gss.h b/tirpc/rpc/auth_gss.h
index f2af6e9..a530d42 100644
--- a/tirpc/rpc/auth_gss.h
+++ b/tirpc/rpc/auth_gss.h
@@ -64,6 +64,8 @@  struct rpc_gss_sec {
 	rpc_gss_svc_t	svc;		/* service */
 	gss_cred_id_t	cred;		/* cred handle */
 	u_int		req_flags;	/* req flags for init_sec_context */
+	int		major_status;
+	int		minor_status;
 };
 
 /* Private data required for kernel implementation */