|
|
4f2874 |
diff -up nfs-utils-1.3.0/utils/gssd/gssd_proc.c.orig nfs-utils-1.3.0/utils/gssd/gssd_proc.c
|
|
|
4f2874 |
--- nfs-utils-1.3.0/utils/gssd/gssd_proc.c.orig 2014-09-17 14:22:54.003055871 -0400
|
|
|
4f2874 |
+++ nfs-utils-1.3.0/utils/gssd/gssd_proc.c 2014-09-17 14:36:02.917808209 -0400
|
|
|
4f2874 |
@@ -77,6 +77,7 @@
|
|
|
4f2874 |
#include "context.h"
|
|
|
4f2874 |
#include "nfsrpc.h"
|
|
|
4f2874 |
#include "nfslib.h"
|
|
|
4f2874 |
+#include "gss_names.h"
|
|
|
4f2874 |
|
|
|
4f2874 |
/*
|
|
|
4f2874 |
* pollarray:
|
|
|
4f2874 |
@@ -681,19 +682,25 @@ parse_enctypes(char *enctypes)
|
|
|
4f2874 |
return 0;
|
|
|
4f2874 |
}
|
|
|
4f2874 |
|
|
|
4f2874 |
-static int
|
|
|
4f2874 |
+static void
|
|
|
4f2874 |
do_downcall(int k5_fd, uid_t uid, struct authgss_private_data *pd,
|
|
|
4f2874 |
- gss_buffer_desc *context_token, OM_uint32 lifetime_rec)
|
|
|
4f2874 |
+ gss_buffer_desc *context_token, OM_uint32 lifetime_rec,
|
|
|
4f2874 |
+ gss_buffer_desc *acceptor)
|
|
|
4f2874 |
{
|
|
|
4f2874 |
char *buf = NULL, *p = NULL, *end = NULL;
|
|
|
4f2874 |
unsigned int timeout = context_timeout;
|
|
|
4f2874 |
unsigned int buf_size = 0;
|
|
|
4f2874 |
|
|
|
4f2874 |
- printerr(1, "doing downcall lifetime_rec %u\n", lifetime_rec);
|
|
|
4f2874 |
+ printerr(1, "doing downcall: lifetime_rec=%u acceptor=%.*s\n",
|
|
|
4f2874 |
+ lifetime_rec, acceptor->length, acceptor->value);
|
|
|
4f2874 |
buf_size = sizeof(uid) + sizeof(timeout) + sizeof(pd->pd_seq_win) +
|
|
|
4f2874 |
sizeof(pd->pd_ctx_hndl.length) + pd->pd_ctx_hndl.length +
|
|
|
4f2874 |
- sizeof(context_token->length) + context_token->length;
|
|
|
4f2874 |
+ sizeof(context_token->length) + context_token->length +
|
|
|
4f2874 |
+ sizeof(acceptor->length) + acceptor->length;
|
|
|
4f2874 |
p = buf = malloc(buf_size);
|
|
|
4f2874 |
+ if (!buf)
|
|
|
4f2874 |
+ goto out_err;
|
|
|
4f2874 |
+
|
|
|
4f2874 |
end = buf + buf_size;
|
|
|
4f2874 |
|
|
|
4f2874 |
/* context_timeout set by -t option overrides context lifetime */
|
|
|
4f2874 |
@@ -704,14 +711,15 @@ do_downcall(int k5_fd, uid_t uid, struct
|
|
|
4f2874 |
if (WRITE_BYTES(&p, end, pd->pd_seq_win)) goto out_err;
|
|
|
4f2874 |
if (write_buffer(&p, end, &pd->pd_ctx_hndl)) goto out_err;
|
|
|
4f2874 |
if (write_buffer(&p, end, context_token)) goto out_err;
|
|
|
4f2874 |
+ if (write_buffer(&p, end, acceptor)) goto out_err;
|
|
|
4f2874 |
|
|
|
4f2874 |
if (write(k5_fd, buf, p - buf) < p - buf) goto out_err;
|
|
|
4f2874 |
- if (buf) free(buf);
|
|
|
4f2874 |
- return 0;
|
|
|
4f2874 |
+ free(buf);
|
|
|
4f2874 |
+ return;
|
|
|
4f2874 |
out_err:
|
|
|
4f2874 |
- if (buf) free(buf);
|
|
|
4f2874 |
+ free(buf);
|
|
|
4f2874 |
printerr(1, "Failed to write downcall!\n");
|
|
|
4f2874 |
- return -1;
|
|
|
4f2874 |
+ return;
|
|
|
4f2874 |
}
|
|
|
4f2874 |
|
|
|
4f2874 |
static int
|
|
|
4f2874 |
@@ -1035,6 +1043,9 @@ process_krb5_upcall(struct clnt_info *cl
|
|
|
4f2874 |
gss_cred_id_t gss_cred;
|
|
|
4f2874 |
OM_uint32 maj_stat, min_stat, lifetime_rec;
|
|
|
4f2874 |
pid_t pid;
|
|
|
4f2874 |
+ gss_name_t gacceptor = GSS_C_NO_NAME;
|
|
|
4f2874 |
+ gss_OID mech;
|
|
|
4f2874 |
+ gss_buffer_desc acceptor = {0};
|
|
|
4f2874 |
|
|
|
4f2874 |
pid = fork();
|
|
|
4f2874 |
switch(pid) {
|
|
|
4f2874 |
@@ -1175,15 +1186,24 @@ process_krb5_upcall(struct clnt_info *cl
|
|
|
4f2874 |
goto out_return_error;
|
|
|
4f2874 |
}
|
|
|
4f2874 |
|
|
|
4f2874 |
- /* Grab the context lifetime to pass to the kernel. lifetime_rec
|
|
|
4f2874 |
- * is set to zero on error */
|
|
|
4f2874 |
- maj_stat = gss_inquire_context(&min_stat, pd.pd_ctx, NULL, NULL,
|
|
|
4f2874 |
- &lifetime_rec, NULL, NULL, NULL, NULL);
|
|
|
4f2874 |
-
|
|
|
4f2874 |
- if (maj_stat)
|
|
|
4f2874 |
- printerr(1, "WARNING: Failed to inquire context for lifetme "
|
|
|
4f2874 |
- "maj_stat %u\n", maj_stat);
|
|
|
4f2874 |
+ /* Grab the context lifetime and acceptor name out of the ctx. */
|
|
|
4f2874 |
+ maj_stat = gss_inquire_context(&min_stat, pd.pd_ctx, NULL, &gacceptor,
|
|
|
4f2874 |
+ &lifetime_rec, &mech, NULL, NULL, NULL);
|
|
|
4f2874 |
+
|
|
|
4f2874 |
+ if (maj_stat != GSS_S_COMPLETE) {
|
|
|
4f2874 |
+ printerr(1, "WARNING: Failed to inquire context "
|
|
|
4f2874 |
+ "maj_stat (0x%x)\n", maj_stat);
|
|
|
4f2874 |
+ lifetime_rec = 0;
|
|
|
4f2874 |
+ } else {
|
|
|
4f2874 |
+ get_hostbased_client_buffer(gacceptor, mech, &acceptor);
|
|
|
4f2874 |
+ gss_release_name(&min_stat, &gacceptor);
|
|
|
4f2874 |
+ }
|
|
|
4f2874 |
|
|
|
4f2874 |
+ /*
|
|
|
4f2874 |
+ * The serialization can mean turning pd.pd_ctx into a lucid context. If
|
|
|
4f2874 |
+ * that happens then the pd.pd_ctx will be unusable, so we must never
|
|
|
4f2874 |
+ * try to use it after this point.
|
|
|
4f2874 |
+ */
|
|
|
4f2874 |
if (serialize_context_for_kernel(&pd.pd_ctx, &token, &krb5oid, NULL)) {
|
|
|
4f2874 |
printerr(0, "WARNING: Failed to serialize krb5 context for "
|
|
|
4f2874 |
"user with uid %d for server %s\n",
|
|
|
4f2874 |
@@ -1191,9 +1211,10 @@ process_krb5_upcall(struct clnt_info *cl
|
|
|
4f2874 |
goto out_return_error;
|
|
|
4f2874 |
}
|
|
|
4f2874 |
|
|
|
4f2874 |
- do_downcall(fd, uid, &pd, &token, lifetime_rec);
|
|
|
4f2874 |
+ do_downcall(fd, uid, &pd, &token, lifetime_rec, &acceptor);
|
|
|
4f2874 |
|
|
|
4f2874 |
out:
|
|
|
4f2874 |
+ gss_release_buffer(&min_stat, &acceptor);
|
|
|
4f2874 |
if (token.value)
|
|
|
4f2874 |
free(token.value);
|
|
|
4f2874 |
#ifdef HAVE_AUTHGSS_FREE_PRIVATE_DATA
|
|
|
4f2874 |
diff -up nfs-utils-1.3.0/utils/gssd/gss_names.c.orig nfs-utils-1.3.0/utils/gssd/gss_names.c
|
|
|
4f2874 |
--- nfs-utils-1.3.0/utils/gssd/gss_names.c.orig 2014-09-17 14:35:16.646945303 -0400
|
|
|
4f2874 |
+++ nfs-utils-1.3.0/utils/gssd/gss_names.c 2014-09-17 14:35:16.646945303 -0400
|
|
|
4f2874 |
@@ -0,0 +1,138 @@
|
|
|
4f2874 |
+/*
|
|
|
4f2874 |
+ Copyright (c) 2000 The Regents of the University of Michigan.
|
|
|
4f2874 |
+ All rights reserved.
|
|
|
4f2874 |
+
|
|
|
4f2874 |
+ Copyright (c) 2002 Bruce Fields <bfields@UMICH.EDU>
|
|
|
4f2874 |
+
|
|
|
4f2874 |
+ Redistribution and use in source and binary forms, with or without
|
|
|
4f2874 |
+ modification, are permitted provided that the following conditions
|
|
|
4f2874 |
+ are met:
|
|
|
4f2874 |
+
|
|
|
4f2874 |
+ 1. Redistributions of source code must retain the above copyright
|
|
|
4f2874 |
+ notice, this list of conditions and the following disclaimer.
|
|
|
4f2874 |
+ 2. Redistributions in binary form must reproduce the above copyright
|
|
|
4f2874 |
+ notice, this list of conditions and the following disclaimer in the
|
|
|
4f2874 |
+ documentation and/or other materials provided with the distribution.
|
|
|
4f2874 |
+ 3. Neither the name of the University nor the names of its
|
|
|
4f2874 |
+ contributors may be used to endorse or promote products derived
|
|
|
4f2874 |
+ from this software without specific prior written permission.
|
|
|
4f2874 |
+
|
|
|
4f2874 |
+ THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
|
|
4f2874 |
+ WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
|
|
4f2874 |
+ MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
|
4f2874 |
+ DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
|
|
4f2874 |
+ FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
|
|
4f2874 |
+ CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
|
|
4f2874 |
+ SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
|
|
|
4f2874 |
+ BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
|
|
4f2874 |
+ LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
|
|
4f2874 |
+ NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
|
|
4f2874 |
+ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
|
4f2874 |
+*/
|
|
|
4f2874 |
+
|
|
|
4f2874 |
+#ifdef HAVE_CONFIG_H
|
|
|
4f2874 |
+#include <config.h>
|
|
|
4f2874 |
+#endif /* HAVE_CONFIG_H */
|
|
|
4f2874 |
+
|
|
|
4f2874 |
+#include <sys/param.h>
|
|
|
4f2874 |
+#include <sys/stat.h>
|
|
|
4f2874 |
+#include <rpc/rpc.h>
|
|
|
4f2874 |
+
|
|
|
4f2874 |
+#include <pwd.h>
|
|
|
4f2874 |
+#include <stdio.h>
|
|
|
4f2874 |
+#include <unistd.h>
|
|
|
4f2874 |
+#include <ctype.h>
|
|
|
4f2874 |
+#include <string.h>
|
|
|
4f2874 |
+#include <fcntl.h>
|
|
|
4f2874 |
+#include <errno.h>
|
|
|
4f2874 |
+#include <nfsidmap.h>
|
|
|
4f2874 |
+#include <nfslib.h>
|
|
|
4f2874 |
+#include <time.h>
|
|
|
4f2874 |
+
|
|
|
4f2874 |
+#include "svcgssd.h"
|
|
|
4f2874 |
+#include "gss_util.h"
|
|
|
4f2874 |
+#include "err_util.h"
|
|
|
4f2874 |
+#include "context.h"
|
|
|
4f2874 |
+#include "misc.h"
|
|
|
4f2874 |
+#include "gss_oids.h"
|
|
|
4f2874 |
+#include "svcgssd_krb5.h"
|
|
|
4f2874 |
+
|
|
|
4f2874 |
+static int
|
|
|
4f2874 |
+get_krb5_hostbased_name(gss_buffer_desc *name, char **hostbased_name)
|
|
|
4f2874 |
+{
|
|
|
4f2874 |
+ char *p, *sname = NULL;
|
|
|
4f2874 |
+ if (strchr(name->value, '@') && strchr(name->value, '/')) {
|
|
|
4f2874 |
+ if ((sname = calloc(name->length, 1)) == NULL) {
|
|
|
4f2874 |
+ printerr(0, "ERROR: get_krb5_hostbased_name failed "
|
|
|
4f2874 |
+ "to allocate %d bytes\n", name->length);
|
|
|
4f2874 |
+ return -1;
|
|
|
4f2874 |
+ }
|
|
|
4f2874 |
+ /* read in name and instance and replace '/' with '@' */
|
|
|
4f2874 |
+ sscanf(name->value, "%[^@]", sname);
|
|
|
4f2874 |
+ p = strrchr(sname, '/');
|
|
|
4f2874 |
+ if (p == NULL) { /* The '@' preceeded the '/' */
|
|
|
4f2874 |
+ free(sname);
|
|
|
4f2874 |
+ return -1;
|
|
|
4f2874 |
+ }
|
|
|
4f2874 |
+ *p = '@';
|
|
|
4f2874 |
+ }
|
|
|
4f2874 |
+ *hostbased_name = sname;
|
|
|
4f2874 |
+ return 0;
|
|
|
4f2874 |
+}
|
|
|
4f2874 |
+
|
|
|
4f2874 |
+int
|
|
|
4f2874 |
+get_hostbased_client_name(gss_name_t client_name, gss_OID mech,
|
|
|
4f2874 |
+ char **hostbased_name)
|
|
|
4f2874 |
+{
|
|
|
4f2874 |
+ u_int32_t maj_stat, min_stat;
|
|
|
4f2874 |
+ gss_buffer_desc name;
|
|
|
4f2874 |
+ gss_OID name_type = GSS_C_NO_OID;
|
|
|
4f2874 |
+ char *cname;
|
|
|
4f2874 |
+ int res = -1;
|
|
|
4f2874 |
+
|
|
|
4f2874 |
+ *hostbased_name = NULL; /* preset in case we fail */
|
|
|
4f2874 |
+
|
|
|
4f2874 |
+ /* Get the client's gss authenticated name */
|
|
|
4f2874 |
+ maj_stat = gss_display_name(&min_stat, client_name, &name, &name_type);
|
|
|
4f2874 |
+ if (maj_stat != GSS_S_COMPLETE) {
|
|
|
4f2874 |
+ pgsserr("get_hostbased_client_name: gss_display_name",
|
|
|
4f2874 |
+ maj_stat, min_stat, mech);
|
|
|
4f2874 |
+ goto out_err;
|
|
|
4f2874 |
+ }
|
|
|
4f2874 |
+ if (name.length >= 0xffff) { /* don't overflow */
|
|
|
4f2874 |
+ printerr(0, "ERROR: get_hostbased_client_name: "
|
|
|
4f2874 |
+ "received gss_name is too long (%d bytes)\n",
|
|
|
4f2874 |
+ name.length);
|
|
|
4f2874 |
+ goto out_rel_buf;
|
|
|
4f2874 |
+ }
|
|
|
4f2874 |
+
|
|
|
4f2874 |
+ /* For Kerberos, transform the NT_KRB5_PRINCIPAL name to
|
|
|
4f2874 |
+ * an NT_HOSTBASED_SERVICE name */
|
|
|
4f2874 |
+ if (g_OID_equal(&krb5oid, mech)) {
|
|
|
4f2874 |
+ if (get_krb5_hostbased_name(&name, &cname) == 0)
|
|
|
4f2874 |
+ *hostbased_name = cname;
|
|
|
4f2874 |
+ } else {
|
|
|
4f2874 |
+ printerr(1, "WARNING: unknown/unsupport mech OID\n");
|
|
|
4f2874 |
+ }
|
|
|
4f2874 |
+
|
|
|
4f2874 |
+ res = 0;
|
|
|
4f2874 |
+out_rel_buf:
|
|
|
4f2874 |
+ gss_release_buffer(&min_stat, &name);
|
|
|
4f2874 |
+out_err:
|
|
|
4f2874 |
+ return res;
|
|
|
4f2874 |
+}
|
|
|
4f2874 |
+
|
|
|
4f2874 |
+void
|
|
|
4f2874 |
+get_hostbased_client_buffer(gss_name_t client_name, gss_OID mech,
|
|
|
4f2874 |
+ gss_buffer_t buf)
|
|
|
4f2874 |
+{
|
|
|
4f2874 |
+ char *hname;
|
|
|
4f2874 |
+
|
|
|
4f2874 |
+ if (!get_hostbased_client_name(client_name, mech, &hname)) {
|
|
|
4f2874 |
+ buf->length = strlen(hname) + 1;
|
|
|
4f2874 |
+ buf->value = hname;
|
|
|
4f2874 |
+ } else {
|
|
|
4f2874 |
+ buf->length = 0;
|
|
|
4f2874 |
+ buf->value = NULL;
|
|
|
4f2874 |
+ }
|
|
|
4f2874 |
+}
|
|
|
4f2874 |
diff -up nfs-utils-1.3.0/utils/gssd/gss_names.h.orig nfs-utils-1.3.0/utils/gssd/gss_names.h
|
|
|
4f2874 |
--- nfs-utils-1.3.0/utils/gssd/gss_names.h.orig 2014-09-17 14:35:16.646945303 -0400
|
|
|
4f2874 |
+++ nfs-utils-1.3.0/utils/gssd/gss_names.h 2014-09-17 14:35:16.646945303 -0400
|
|
|
4f2874 |
@@ -0,0 +1,36 @@
|
|
|
4f2874 |
+/*
|
|
|
4f2874 |
+ Copyright (c) 2000 The Regents of the University of Michigan.
|
|
|
4f2874 |
+ All rights reserved.
|
|
|
4f2874 |
+
|
|
|
4f2874 |
+ Copyright (c) 2002 Bruce Fields <bfields@UMICH.EDU>
|
|
|
4f2874 |
+
|
|
|
4f2874 |
+ Redistribution and use in source and binary forms, with or without
|
|
|
4f2874 |
+ modification, are permitted provided that the following conditions
|
|
|
4f2874 |
+ are met:
|
|
|
4f2874 |
+
|
|
|
4f2874 |
+ 1. Redistributions of source code must retain the above copyright
|
|
|
4f2874 |
+ notice, this list of conditions and the following disclaimer.
|
|
|
4f2874 |
+ 2. Redistributions in binary form must reproduce the above copyright
|
|
|
4f2874 |
+ notice, this list of conditions and the following disclaimer in the
|
|
|
4f2874 |
+ documentation and/or other materials provided with the distribution.
|
|
|
4f2874 |
+ 3. Neither the name of the University nor the names of its
|
|
|
4f2874 |
+ contributors may be used to endorse or promote products derived
|
|
|
4f2874 |
+ from this software without specific prior written permission.
|
|
|
4f2874 |
+
|
|
|
4f2874 |
+ THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
|
|
4f2874 |
+ WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
|
|
4f2874 |
+ MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
|
4f2874 |
+ DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
|
|
4f2874 |
+ FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
|
|
4f2874 |
+ CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
|
|
4f2874 |
+ SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
|
|
|
4f2874 |
+ BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
|
|
4f2874 |
+ LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
|
|
4f2874 |
+ NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
|
|
4f2874 |
+ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
|
4f2874 |
+*/
|
|
|
4f2874 |
+
|
|
|
4f2874 |
+extern int get_hostbased_client_name(gss_name_t client_name, gss_OID mech,
|
|
|
4f2874 |
+ char **hostbased_name);
|
|
|
4f2874 |
+extern void get_hostbased_client_buffer(gss_name_t client_name,
|
|
|
4f2874 |
+ gss_OID mech, gss_buffer_t buf);
|
|
|
4f2874 |
diff -up nfs-utils-1.3.0/utils/gssd/Makefile.am.orig nfs-utils-1.3.0/utils/gssd/Makefile.am
|
|
|
4f2874 |
--- nfs-utils-1.3.0/utils/gssd/Makefile.am.orig 2014-03-25 11:12:07.000000000 -0400
|
|
|
4f2874 |
+++ nfs-utils-1.3.0/utils/gssd/Makefile.am 2014-09-17 14:35:16.645945284 -0400
|
|
|
4f2874 |
@@ -18,11 +18,13 @@ COMMON_SRCS = \
|
|
|
4f2874 |
context_lucid.c \
|
|
|
4f2874 |
gss_util.c \
|
|
|
4f2874 |
gss_oids.c \
|
|
|
4f2874 |
+ gss_names.c \
|
|
|
4f2874 |
err_util.c \
|
|
|
4f2874 |
\
|
|
|
4f2874 |
context.h \
|
|
|
4f2874 |
err_util.h \
|
|
|
4f2874 |
gss_oids.h \
|
|
|
4f2874 |
+ gss_names.h \
|
|
|
4f2874 |
gss_util.h
|
|
|
4f2874 |
|
|
|
4f2874 |
gssd_SOURCES = \
|
|
|
4f2874 |
diff -up nfs-utils-1.3.0/utils/gssd/svcgssd_proc.c.orig nfs-utils-1.3.0/utils/gssd/svcgssd_proc.c
|
|
|
4f2874 |
--- nfs-utils-1.3.0/utils/gssd/svcgssd_proc.c.orig 2014-03-25 11:12:07.000000000 -0400
|
|
|
4f2874 |
+++ nfs-utils-1.3.0/utils/gssd/svcgssd_proc.c 2014-09-17 14:35:16.646945303 -0400
|
|
|
4f2874 |
@@ -59,6 +59,7 @@
|
|
|
4f2874 |
#include "misc.h"
|
|
|
4f2874 |
#include "gss_oids.h"
|
|
|
4f2874 |
#include "svcgssd_krb5.h"
|
|
|
4f2874 |
+#include "gss_names.h"
|
|
|
4f2874 |
|
|
|
4f2874 |
extern char * mech2file(gss_OID mech);
|
|
|
4f2874 |
#define SVCGSSD_CONTEXT_CHANNEL "/proc/net/rpc/auth.rpcsec.context/channel"
|
|
|
4f2874 |
@@ -315,71 +316,6 @@ print_hexl(const char *description, unsi
|
|
|
4f2874 |
}
|
|
|
4f2874 |
#endif
|
|
|
4f2874 |
|
|
|
4f2874 |
-static int
|
|
|
4f2874 |
-get_krb5_hostbased_name (gss_buffer_desc *name, char **hostbased_name)
|
|
|
4f2874 |
-{
|
|
|
4f2874 |
- char *p, *sname = NULL;
|
|
|
4f2874 |
- if (strchr(name->value, '@') && strchr(name->value, '/')) {
|
|
|
4f2874 |
- if ((sname = calloc(name->length, 1)) == NULL) {
|
|
|
4f2874 |
- printerr(0, "ERROR: get_krb5_hostbased_name failed "
|
|
|
4f2874 |
- "to allocate %d bytes\n", name->length);
|
|
|
4f2874 |
- return -1;
|
|
|
4f2874 |
- }
|
|
|
4f2874 |
- /* read in name and instance and replace '/' with '@' */
|
|
|
4f2874 |
- sscanf(name->value, "%[^@]", sname);
|
|
|
4f2874 |
- p = strrchr(sname, '/');
|
|
|
4f2874 |
- if (p == NULL) { /* The '@' preceeded the '/' */
|
|
|
4f2874 |
- free(sname);
|
|
|
4f2874 |
- return -1;
|
|
|
4f2874 |
- }
|
|
|
4f2874 |
- *p = '@';
|
|
|
4f2874 |
- }
|
|
|
4f2874 |
- *hostbased_name = sname;
|
|
|
4f2874 |
- return 0;
|
|
|
4f2874 |
-}
|
|
|
4f2874 |
-
|
|
|
4f2874 |
-static int
|
|
|
4f2874 |
-get_hostbased_client_name(gss_name_t client_name, gss_OID mech,
|
|
|
4f2874 |
- char **hostbased_name)
|
|
|
4f2874 |
-{
|
|
|
4f2874 |
- u_int32_t maj_stat, min_stat;
|
|
|
4f2874 |
- gss_buffer_desc name;
|
|
|
4f2874 |
- gss_OID name_type = GSS_C_NO_OID;
|
|
|
4f2874 |
- char *cname;
|
|
|
4f2874 |
- int res = -1;
|
|
|
4f2874 |
-
|
|
|
4f2874 |
- *hostbased_name = NULL; /* preset in case we fail */
|
|
|
4f2874 |
-
|
|
|
4f2874 |
- /* Get the client's gss authenticated name */
|
|
|
4f2874 |
- maj_stat = gss_display_name(&min_stat, client_name, &name, &name_type);
|
|
|
4f2874 |
- if (maj_stat != GSS_S_COMPLETE) {
|
|
|
4f2874 |
- pgsserr("get_hostbased_client_name: gss_display_name",
|
|
|
4f2874 |
- maj_stat, min_stat, mech);
|
|
|
4f2874 |
- goto out_err;
|
|
|
4f2874 |
- }
|
|
|
4f2874 |
- if (name.length >= 0xffff) { /* don't overflow */
|
|
|
4f2874 |
- printerr(0, "ERROR: get_hostbased_client_name: "
|
|
|
4f2874 |
- "received gss_name is too long (%d bytes)\n",
|
|
|
4f2874 |
- name.length);
|
|
|
4f2874 |
- goto out_rel_buf;
|
|
|
4f2874 |
- }
|
|
|
4f2874 |
-
|
|
|
4f2874 |
- /* For Kerberos, transform the NT_KRB5_PRINCIPAL name to
|
|
|
4f2874 |
- * an NT_HOSTBASED_SERVICE name */
|
|
|
4f2874 |
- if (g_OID_equal(&krb5oid, mech)) {
|
|
|
4f2874 |
- if (get_krb5_hostbased_name(&name, &cname) == 0)
|
|
|
4f2874 |
- *hostbased_name = cname;
|
|
|
4f2874 |
- } else {
|
|
|
4f2874 |
- printerr(1, "WARNING: unknown/unsupport mech OID\n");
|
|
|
4f2874 |
- }
|
|
|
4f2874 |
-
|
|
|
4f2874 |
- res = 0;
|
|
|
4f2874 |
-out_rel_buf:
|
|
|
4f2874 |
- gss_release_buffer(&min_stat, &name);
|
|
|
4f2874 |
-out_err:
|
|
|
4f2874 |
- return res;
|
|
|
4f2874 |
-}
|
|
|
4f2874 |
-
|
|
|
4f2874 |
void
|
|
|
4f2874 |
handle_nullreq(FILE *f) {
|
|
|
4f2874 |
/* XXX initialize to a random integer to reduce chances of unnecessary
|