cifs: Modify struct cifs_unix_set_info_args to hold a kuid_t and a kgid_t
Use INVALID_UID and INVALID_GID instead of NO_CHANGE_64 to indicate the value should not be changed. In cifs_fill_unix_set_info convert from kuids and kgids into uids and gids that will fit in FILE_UNIX_BASIC_INFO. Cc: Steve French <smfrench@gmail.com> Signed-off-by: "Eric W. Biederman" <ebiederm@xmission.com>
This commit is contained in:
parent
dbfb98af18
commit
49418b2c28
5 changed files with 28 additions and 22 deletions
|
@ -305,8 +305,8 @@ struct cifs_unix_set_info_args {
|
|||
__u64 atime;
|
||||
__u64 mtime;
|
||||
__u64 mode;
|
||||
__u64 uid;
|
||||
__u64 gid;
|
||||
kuid_t uid;
|
||||
kgid_t gid;
|
||||
dev_t device;
|
||||
};
|
||||
|
||||
|
|
|
@ -5819,8 +5819,14 @@ static void
|
|||
cifs_fill_unix_set_info(FILE_UNIX_BASIC_INFO *data_offset,
|
||||
const struct cifs_unix_set_info_args *args)
|
||||
{
|
||||
u64 uid = NO_CHANGE_64, gid = NO_CHANGE_64;
|
||||
u64 mode = args->mode;
|
||||
|
||||
if (uid_valid(args->uid))
|
||||
uid = from_kuid(&init_user_ns, args->uid);
|
||||
if (gid_valid(args->gid))
|
||||
gid = from_kgid(&init_user_ns, args->gid);
|
||||
|
||||
/*
|
||||
* Samba server ignores set of file size to zero due to bugs in some
|
||||
* older clients, but we should be precise - we use SetFileSize to
|
||||
|
@ -5833,8 +5839,8 @@ cifs_fill_unix_set_info(FILE_UNIX_BASIC_INFO *data_offset,
|
|||
data_offset->LastStatusChange = cpu_to_le64(args->ctime);
|
||||
data_offset->LastAccessTime = cpu_to_le64(args->atime);
|
||||
data_offset->LastModificationTime = cpu_to_le64(args->mtime);
|
||||
data_offset->Uid = cpu_to_le64(args->uid);
|
||||
data_offset->Gid = cpu_to_le64(args->gid);
|
||||
data_offset->Uid = cpu_to_le64(uid);
|
||||
data_offset->Gid = cpu_to_le64(gid);
|
||||
/* better to leave device as zero when it is */
|
||||
data_offset->DevMajor = cpu_to_le64(MAJOR(args->device));
|
||||
data_offset->DevMinor = cpu_to_le64(MINOR(args->device));
|
||||
|
|
|
@ -342,14 +342,14 @@ cifs_do_create(struct inode *inode, struct dentry *direntry, unsigned int xid,
|
|||
|
||||
*created |= FILE_CREATED;
|
||||
if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_SET_UID) {
|
||||
args.uid = (__u64) current_fsuid();
|
||||
args.uid = current_fsuid();
|
||||
if (inode->i_mode & S_ISGID)
|
||||
args.gid = (__u64) inode->i_gid;
|
||||
args.gid = inode->i_gid;
|
||||
else
|
||||
args.gid = (__u64) current_fsgid();
|
||||
args.gid = current_fsgid();
|
||||
} else {
|
||||
args.uid = NO_CHANGE_64;
|
||||
args.gid = NO_CHANGE_64;
|
||||
args.uid = INVALID_UID; /* no change */
|
||||
args.gid = INVALID_GID; /* no change */
|
||||
}
|
||||
CIFSSMBUnixSetFileInfo(xid, tcon, &args, fid->netfid,
|
||||
current->tgid);
|
||||
|
@ -588,11 +588,11 @@ int cifs_mknod(struct inode *inode, struct dentry *direntry, umode_t mode,
|
|||
.device = device_number,
|
||||
};
|
||||
if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_SET_UID) {
|
||||
args.uid = (__u64) current_fsuid();
|
||||
args.gid = (__u64) current_fsgid();
|
||||
args.uid = current_fsuid();
|
||||
args.gid = current_fsgid();
|
||||
} else {
|
||||
args.uid = NO_CHANGE_64;
|
||||
args.gid = NO_CHANGE_64;
|
||||
args.uid = INVALID_UID; /* no change */
|
||||
args.gid = INVALID_GID; /* no change */
|
||||
}
|
||||
rc = CIFSSMBUnixSetPathInfo(xid, pTcon, full_path, &args,
|
||||
cifs_sb->local_nls,
|
||||
|
|
|
@ -487,8 +487,8 @@ int cifs_open(struct inode *inode, struct file *file)
|
|||
*/
|
||||
struct cifs_unix_set_info_args args = {
|
||||
.mode = inode->i_mode,
|
||||
.uid = NO_CHANGE_64,
|
||||
.gid = NO_CHANGE_64,
|
||||
.uid = INVALID_UID, /* no change */
|
||||
.gid = INVALID_GID, /* no change */
|
||||
.ctime = NO_CHANGE_64,
|
||||
.atime = NO_CHANGE_64,
|
||||
.mtime = NO_CHANGE_64,
|
||||
|
|
|
@ -1249,14 +1249,14 @@ cifs_mkdir_qinfo(struct inode *parent, struct dentry *dentry, umode_t mode,
|
|||
.device = 0,
|
||||
};
|
||||
if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_SET_UID) {
|
||||
args.uid = (__u64)current_fsuid();
|
||||
args.uid = current_fsuid();
|
||||
if (parent->i_mode & S_ISGID)
|
||||
args.gid = (__u64)parent->i_gid;
|
||||
args.gid = parent->i_gid;
|
||||
else
|
||||
args.gid = (__u64)current_fsgid();
|
||||
args.gid = current_fsgid();
|
||||
} else {
|
||||
args.uid = NO_CHANGE_64;
|
||||
args.gid = NO_CHANGE_64;
|
||||
args.uid = INVALID_UID; /* no change */
|
||||
args.gid = INVALID_GID; /* no change */
|
||||
}
|
||||
CIFSSMBUnixSetPathInfo(xid, tcon, full_path, &args,
|
||||
cifs_sb->local_nls,
|
||||
|
@ -2017,12 +2017,12 @@ cifs_setattr_unix(struct dentry *direntry, struct iattr *attrs)
|
|||
if (attrs->ia_valid & ATTR_UID)
|
||||
args->uid = attrs->ia_uid;
|
||||
else
|
||||
args->uid = NO_CHANGE_64;
|
||||
args->uid = INVALID_UID; /* no change */
|
||||
|
||||
if (attrs->ia_valid & ATTR_GID)
|
||||
args->gid = attrs->ia_gid;
|
||||
else
|
||||
args->gid = NO_CHANGE_64;
|
||||
args->gid = INVALID_GID; /* no change */
|
||||
|
||||
if (attrs->ia_valid & ATTR_ATIME)
|
||||
args->atime = cifs_UnixTimeToNT(attrs->ia_atime);
|
||||
|
|
Loading…
Reference in a new issue