X-Git-Url: https://git.whamcloud.com/?p=fs%2Flustre-release.git;a=blobdiff_plain;f=lustre%2Futils%2Fgss%2Flgss_keyring.c;h=f34981cc1b089ff166ab92bcb3ff2c1f5029a9f4;hp=93fd94c9930ea45445167c60b66e3638e3e05957;hb=7dfbc71350;hpb=9d347ae1d6aa642a86b710452b1978ea303dea09 diff --git a/lustre/utils/gss/lgss_keyring.c b/lustre/utils/gss/lgss_keyring.c index 93fd94c..f34981c 100644 --- a/lustre/utils/gss/lgss_keyring.c +++ b/lustre/utils/gss/lgss_keyring.c @@ -27,7 +27,6 @@ */ /* * This file is part of Lustre, http://www.lustre.org/ - * Lustre is a trademark of Sun Microsystems, Inc. * * lustre/utils/gss/lgss_keyring.c * @@ -53,6 +52,7 @@ #include #include +#include #include "lsupport.h" #include "lgss_utils.h" #include "write_bytes.h" @@ -261,7 +261,7 @@ int do_nego_rpc(struct lgss_nego_data *lnd, 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; } @@ -1059,16 +1059,23 @@ int main(int argc, char *argv[]) cred->lc_self_nid = uparam.kup_selfnid; /* Is caller in different namespace? */ - 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)) + /* 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 if (caller_ns.st_ino != parent_ns.st_ino) - other_ns = 1; + } 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; + } } /* @@ -1076,7 +1083,7 @@ int main(int argc, char *argv[]) * 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) { @@ -1222,7 +1229,10 @@ out_pipe: 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)