Commit c0f54d3e authored by Ian Kent's avatar Ian Kent Committed by Linus Torvalds

autofs4: track uid and gid of last mount requester

Track the uid and gid of the last process to request a mount for on an
autofs dentry.

[akpm@linux-foundation.org: fix tpyo in comment]
Signed-off-by: default avatarIan Kent <raven@themaw.net>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent bb979d7f
...@@ -63,6 +63,9 @@ struct autofs_info { ...@@ -63,6 +63,9 @@ struct autofs_info {
unsigned long last_used; unsigned long last_used;
atomic_t count; atomic_t count;
uid_t uid;
gid_t gid;
mode_t mode; mode_t mode;
size_t size; size_t size;
......
...@@ -53,6 +53,8 @@ struct autofs_info *autofs4_init_ino(struct autofs_info *ino, ...@@ -53,6 +53,8 @@ struct autofs_info *autofs4_init_ino(struct autofs_info *ino,
atomic_set(&ino->count, 0); atomic_set(&ino->count, 0);
} }
ino->uid = 0;
ino->gid = 0;
ino->mode = mode; ino->mode = mode;
ino->last_used = jiffies; ino->last_used = jiffies;
......
...@@ -457,6 +457,40 @@ int autofs4_wait(struct autofs_sb_info *sbi, struct dentry *dentry, ...@@ -457,6 +457,40 @@ int autofs4_wait(struct autofs_sb_info *sbi, struct dentry *dentry,
status = wq->status; status = wq->status;
/*
* For direct and offset mounts we need to track the requester's
* uid and gid in the dentry info struct. This is so it can be
* supplied, on request, by the misc device ioctl interface.
* This is needed during daemon resatart when reconnecting
* to existing, active, autofs mounts. The uid and gid (and
* related string values) may be used for macro substitution
* in autofs mount maps.
*/
if (!status) {
struct autofs_info *ino;
struct dentry *de = NULL;
/* direct mount or browsable map */
ino = autofs4_dentry_ino(dentry);
if (!ino) {
/* If not lookup actual dentry used */
de = d_lookup(dentry->d_parent, &dentry->d_name);
if (de)
ino = autofs4_dentry_ino(de);
}
/* Set mount requester */
if (ino) {
spin_lock(&sbi->fs_lock);
ino->uid = wq->uid;
ino->gid = wq->gid;
spin_unlock(&sbi->fs_lock);
}
if (de)
dput(de);
}
/* Are we the last process to need status? */ /* Are we the last process to need status? */
mutex_lock(&sbi->wq_mutex); mutex_lock(&sbi->wq_mutex);
if (!--wq->wait_ctr) if (!--wq->wait_ctr)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment