mirror of
https://github.com/torvalds/linux.git
synced 2024-11-22 12:11:40 +00:00
userns: Convert user specfied uids and gids in chown into kuids and kgid
Acked-by: Serge Hallyn <serge.hallyn@canonical.com> Signed-off-by: Eric W. Biederman <ebiederm@xmission.com>
This commit is contained in:
parent
8e96e3b7b8
commit
52137abe18
13
fs/open.c
13
fs/open.c
@ -506,15 +506,24 @@ static int chown_common(struct path *path, uid_t user, gid_t group)
|
||||
struct inode *inode = path->dentry->d_inode;
|
||||
int error;
|
||||
struct iattr newattrs;
|
||||
kuid_t uid;
|
||||
kgid_t gid;
|
||||
|
||||
uid = make_kuid(current_user_ns(), user);
|
||||
gid = make_kgid(current_user_ns(), group);
|
||||
|
||||
newattrs.ia_valid = ATTR_CTIME;
|
||||
if (user != (uid_t) -1) {
|
||||
if (!uid_valid(uid))
|
||||
return -EINVAL;
|
||||
newattrs.ia_valid |= ATTR_UID;
|
||||
newattrs.ia_uid = user;
|
||||
newattrs.ia_uid = uid;
|
||||
}
|
||||
if (group != (gid_t) -1) {
|
||||
if (!gid_valid(gid))
|
||||
return -EINVAL;
|
||||
newattrs.ia_valid |= ATTR_GID;
|
||||
newattrs.ia_gid = group;
|
||||
newattrs.ia_gid = gid;
|
||||
}
|
||||
if (!S_ISDIR(inode->i_mode))
|
||||
newattrs.ia_valid |=
|
||||
|
Loading…
Reference in New Issue
Block a user