HDFS-13322 fuse dfs - uid persists when switching between ticket caches. Contributed by Istvan Fajth.

This commit is contained in:
Aaron Fabbri 2018-07-31 15:21:38 -07:00
parent c835fc08ad
commit 40f9b0c5c1
No known key found for this signature in database
GPG Key ID: B2EEFA9E78118A29

View File

@ -192,7 +192,7 @@ int fuseConnectInit(const char *nnUri, int port)
} }
/** /**
* Compare two libhdfs connections by username * Compare two libhdfs connections by username and Kerberos ticket cache path
* *
* @param a The first libhdfs connection * @param a The first libhdfs connection
* @param b The second libhdfs connection * @param b The second libhdfs connection
@ -201,22 +201,26 @@ int fuseConnectInit(const char *nnUri, int port)
*/ */
static int hdfsConnCompare(const struct hdfsConn *a, const struct hdfsConn *b) static int hdfsConnCompare(const struct hdfsConn *a, const struct hdfsConn *b)
{ {
return strcmp(a->usrname, b->usrname); int rc = strcmp(a->usrname, b->usrname);
if (rc) return rc;
return gHdfsAuthConf == AUTH_CONF_KERBEROS && strcmp(a->kpath, b->kpath);
} }
/** /**
* Find a libhdfs connection by username * Find a libhdfs connection by username
* *
* @param usrname The username to look up * @param usrname The username to look up
* @param kpath The Kerberos ticket cache file path
* *
* @return The connection, or NULL if none could be found * @return The connection, or NULL if none could be found
*/ */
static struct hdfsConn* hdfsConnFind(const char *usrname) static struct hdfsConn* hdfsConnFind(const char *usrname, const char *kpath)
{ {
struct hdfsConn exemplar; struct hdfsConn exemplar;
memset(&exemplar, 0, sizeof(exemplar)); memset(&exemplar, 0, sizeof(exemplar));
exemplar.usrname = (char*)usrname; exemplar.usrname = (char*)usrname;
exemplar.kpath = (char*)kpath;
return RB_FIND(hdfsConnTree, &gConnTree, &exemplar); return RB_FIND(hdfsConnTree, &gConnTree, &exemplar);
} }
@ -542,8 +546,13 @@ static int fuseConnect(const char *usrname, struct fuse_context *ctx,
int ret; int ret;
struct hdfsConn* conn; struct hdfsConn* conn;
char kpath[PATH_MAX] = { 0 };
if (gHdfsAuthConf == AUTH_CONF_KERBEROS) {
findKerbTicketCachePath(ctx, kpath, sizeof(kpath));
}
pthread_mutex_lock(&gConnMutex); pthread_mutex_lock(&gConnMutex);
conn = hdfsConnFind(usrname); conn = hdfsConnFind(usrname, kpath);
if (!conn) { if (!conn) {
ret = fuseNewConnect(usrname, ctx, &conn); ret = fuseNewConnect(usrname, ctx, &conn);
if (ret) { if (ret) {