*/
/*
* This file is part of Lustre, http://www.lustre.org/
- * Lustre is a trademark of Sun Microsystems, Inc.
*
* lustre/utils/gss/lgss_keyring.c
*
#include <libcfs/util/param.h>
#include <libcfs/util/string.h>
+#include <uapi/linux/lustre/lgss.h>
#include "lsupport.h"
#include "lgss_utils.h"
#include "write_bytes.h"
logmsg(LL_TRACE, "do_nego_rpc: to parse reply\n");
if (param.status) {
logmsg(LL_ERR, "status: %ld (%s)\n",
- param.status, strerror((int)(-param.status)));
+ (long int)param.status, strerror((int)(-param.status)));
return param.status;
}
static int associate_with_ns(char *path)
{
-#ifdef HAVE_SETNS
int fd, rc = -1;
fd = open(path, O_RDONLY);
}
return rc;
-#else
- return -1;
-#endif /* HAVE_SETNS */
}
static int prepare_and_instantiate(struct lgss_cred *cred, key_serial_t keyid,
char path[PATH_MAX] = "";
int other_ns = 0;
int rc = 0;
-#ifdef HAVE_SETNS
struct stat parent_ns = { .st_ino = 0 };
struct stat caller_ns = { .st_ino = 0 };
-#endif
set_log_level();
cred->lc_svc_type = uparam.kup_svc_type;
cred->lc_self_nid = uparam.kup_selfnid;
-#ifdef HAVE_SETNS
/* Is caller in different namespace? */
- snprintf(path, sizeof(path), "/proc/%d/ns/mnt", getpid());
- if (stat(path, &parent_ns))
- logmsg(LL_ERR, "cannot stat %s: %s\n", path, strerror(errno));
- snprintf(path, sizeof(path), "/proc/%d/ns/mnt", uparam.kup_pid);
- if (stat(path, &caller_ns))
- logmsg(LL_ERR, "cannot stat %s: %s\n", path, strerror(errno));
- if (caller_ns.st_ino != parent_ns.st_ino) {
- other_ns = 1;
+ /* If passed caller's pid is 0, it means we have to stick
+ * with current namespace.
+ */
+ if (uparam.kup_pid) {
+ snprintf(path, sizeof(path), "/proc/%d/ns/mnt", getpid());
+ if (stat(path, &parent_ns)) {
+ logmsg(LL_DEBUG, "cannot stat %s: %s\n",
+ path, strerror(errno));
+ } else {
+ snprintf(path, sizeof(path), "/proc/%d/ns/mnt",
+ uparam.kup_pid);
+ if (stat(path, &caller_ns))
+ logmsg(LL_DEBUG, "cannot stat %s: %s\n",
+ path, strerror(errno));
+ else if (caller_ns.st_ino != parent_ns.st_ino)
+ other_ns = 1;
+ }
}
-#endif /* HAVE_SETNS */
/*
* if caller's namespace is different, fork a child and associate it
* with caller's namespace to do credentials preparation
*/
if (other_ns) {
- logmsg(LL_TRACE, "caller's namespace is diffent\n");
+ logmsg(LL_TRACE, "caller's namespace is different\n");
/* use pipes to pass info between child and parent processes */
if (pipe(req_fd) == -1) {
close(reply_fd[1]);
return rc;
} else {
- logmsg(LL_TRACE, "caller's namespace is the same\n");
+ if (uparam.kup_pid)
+ logmsg(LL_TRACE, "caller's namespace is the same\n");
+ else
+ logmsg(LL_TRACE, "stick with current namespace\n");
rc = prepare_and_instantiate(cred, keyid, uparam.kup_uid);
if (rc != 0)