diff options
author | Eric W. Biederman <ebiederm@xmission.com> | 2012-02-07 19:28:28 -0500 |
---|---|---|
committer | Eric W. Biederman <ebiederm@xmission.com> | 2013-02-13 09:15:13 -0500 |
commit | 1ac7fd8190b79c822631ed537186fb8b2d9e9b74 (patch) | |
tree | de88733bf16f6ed670e0de354dded191ae844717 /fs/ncpfs/ioctl.c | |
parent | 0f07bd3753e25c80fe24428273c791f350b3a1eb (diff) |
ncpfs: Support interacting with multiple user namespaces
ncpfs does not natively support uids and gids so this conversion was
simply a matter of updating the the type of the mounteduid, the uid
and the gid on the superblock. Fixing the ioctls that read them,
updating the mount option parser and the mount option printer.
Cc: Petr Vandrovec <petr@vandrovec.name>
Acked-by: Serge Hallyn <serge.hallyn@canonical.com>
Signed-off-by: Eric W. Biederman <ebiederm@xmission.com>
Diffstat (limited to 'fs/ncpfs/ioctl.c')
-rw-r--r-- | fs/ncpfs/ioctl.c | 25 |
1 files changed, 14 insertions, 11 deletions
diff --git a/fs/ncpfs/ioctl.c b/fs/ncpfs/ioctl.c index 6958adfaff08..d44318d27504 100644 --- a/fs/ncpfs/ioctl.c +++ b/fs/ncpfs/ioctl.c | |||
@@ -45,7 +45,7 @@ ncp_get_fs_info(struct ncp_server * server, struct inode *inode, | |||
45 | return -EINVAL; | 45 | return -EINVAL; |
46 | } | 46 | } |
47 | /* TODO: info.addr = server->m.serv_addr; */ | 47 | /* TODO: info.addr = server->m.serv_addr; */ |
48 | SET_UID(info.mounted_uid, server->m.mounted_uid); | 48 | SET_UID(info.mounted_uid, from_kuid_munged(current_user_ns(), server->m.mounted_uid)); |
49 | info.connection = server->connection; | 49 | info.connection = server->connection; |
50 | info.buffer_size = server->buffer_size; | 50 | info.buffer_size = server->buffer_size; |
51 | info.volume_number = NCP_FINFO(inode)->volNumber; | 51 | info.volume_number = NCP_FINFO(inode)->volNumber; |
@@ -69,7 +69,7 @@ ncp_get_fs_info_v2(struct ncp_server * server, struct inode *inode, | |||
69 | DPRINTK("info.version invalid: %d\n", info2.version); | 69 | DPRINTK("info.version invalid: %d\n", info2.version); |
70 | return -EINVAL; | 70 | return -EINVAL; |
71 | } | 71 | } |
72 | info2.mounted_uid = server->m.mounted_uid; | 72 | info2.mounted_uid = from_kuid_munged(current_user_ns(), server->m.mounted_uid); |
73 | info2.connection = server->connection; | 73 | info2.connection = server->connection; |
74 | info2.buffer_size = server->buffer_size; | 74 | info2.buffer_size = server->buffer_size; |
75 | info2.volume_number = NCP_FINFO(inode)->volNumber; | 75 | info2.volume_number = NCP_FINFO(inode)->volNumber; |
@@ -135,7 +135,7 @@ ncp_get_compat_fs_info_v2(struct ncp_server * server, struct inode *inode, | |||
135 | DPRINTK("info.version invalid: %d\n", info2.version); | 135 | DPRINTK("info.version invalid: %d\n", info2.version); |
136 | return -EINVAL; | 136 | return -EINVAL; |
137 | } | 137 | } |
138 | info2.mounted_uid = server->m.mounted_uid; | 138 | info2.mounted_uid = from_kuid_munged(current_user_ns(), server->m.mounted_uid); |
139 | info2.connection = server->connection; | 139 | info2.connection = server->connection; |
140 | info2.buffer_size = server->buffer_size; | 140 | info2.buffer_size = server->buffer_size; |
141 | info2.volume_number = NCP_FINFO(inode)->volNumber; | 141 | info2.volume_number = NCP_FINFO(inode)->volNumber; |
@@ -348,22 +348,25 @@ static long __ncp_ioctl(struct inode *inode, unsigned int cmd, unsigned long arg | |||
348 | { | 348 | { |
349 | u16 uid; | 349 | u16 uid; |
350 | 350 | ||
351 | SET_UID(uid, server->m.mounted_uid); | 351 | SET_UID(uid, from_kuid_munged(current_user_ns(), server->m.mounted_uid)); |
352 | if (put_user(uid, (u16 __user *)argp)) | 352 | if (put_user(uid, (u16 __user *)argp)) |
353 | return -EFAULT; | 353 | return -EFAULT; |
354 | return 0; | 354 | return 0; |
355 | } | 355 | } |
356 | case NCP_IOC_GETMOUNTUID32: | 356 | case NCP_IOC_GETMOUNTUID32: |
357 | if (put_user(server->m.mounted_uid, | 357 | { |
358 | (u32 __user *)argp)) | 358 | uid_t uid = from_kuid_munged(current_user_ns(), server->m.mounted_uid); |
359 | if (put_user(uid, (u32 __user *)argp)) | ||
359 | return -EFAULT; | 360 | return -EFAULT; |
360 | return 0; | 361 | return 0; |
362 | } | ||
361 | case NCP_IOC_GETMOUNTUID64: | 363 | case NCP_IOC_GETMOUNTUID64: |
362 | if (put_user(server->m.mounted_uid, | 364 | { |
363 | (u64 __user *)argp)) | 365 | uid_t uid = from_kuid_munged(current_user_ns(), server->m.mounted_uid); |
366 | if (put_user(uid, (u64 __user *)argp)) | ||
364 | return -EFAULT; | 367 | return -EFAULT; |
365 | return 0; | 368 | return 0; |
366 | 369 | } | |
367 | case NCP_IOC_GETROOT: | 370 | case NCP_IOC_GETROOT: |
368 | { | 371 | { |
369 | struct ncp_setroot_ioctl sr; | 372 | struct ncp_setroot_ioctl sr; |
@@ -810,7 +813,7 @@ long ncp_ioctl(struct file *filp, unsigned int cmd, unsigned long arg) | |||
810 | { | 813 | { |
811 | struct inode *inode = filp->f_dentry->d_inode; | 814 | struct inode *inode = filp->f_dentry->d_inode; |
812 | struct ncp_server *server = NCP_SERVER(inode); | 815 | struct ncp_server *server = NCP_SERVER(inode); |
813 | uid_t uid = current_uid(); | 816 | kuid_t uid = current_uid(); |
814 | int need_drop_write = 0; | 817 | int need_drop_write = 0; |
815 | long ret; | 818 | long ret; |
816 | 819 | ||
@@ -824,7 +827,7 @@ long ncp_ioctl(struct file *filp, unsigned int cmd, unsigned long arg) | |||
824 | } | 827 | } |
825 | break; | 828 | break; |
826 | } | 829 | } |
827 | if (server->m.mounted_uid != uid) { | 830 | if (!uid_eq(server->m.mounted_uid, uid)) { |
828 | switch (cmd) { | 831 | switch (cmd) { |
829 | /* | 832 | /* |
830 | * Only mount owner can issue these ioctls. Information | 833 | * Only mount owner can issue these ioctls. Information |