Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 120690
b: refs/heads/master
c: 4893702
h: refs/heads/master
v: v3
  • Loading branch information
David Howells authored and James Morris committed Nov 13, 2008
1 parent 6224be5 commit b45fb7b
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 48 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 922c030f260df9d256fecea3164210e7cb2ce407
refs/heads/master: 48937024c65db88abafd0fb14021db31f09cd4ec
91 changes: 44 additions & 47 deletions trunk/fs/ncpfs/ioctl.c
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,10 @@ ncp_get_fs_info(struct ncp_server * server, struct file *file,
struct inode *inode = file->f_path.dentry->d_inode;
struct ncp_fs_info info;

if ((file_permission(file, MAY_WRITE) != 0)
&& (current->uid != server->m.mounted_uid)) {
if (file_permission(file, MAY_WRITE) != 0
&& current_uid() != server->m.mounted_uid)
return -EACCES;
}

if (copy_from_user(&info, arg, sizeof(info)))
return -EFAULT;

Expand All @@ -70,10 +70,10 @@ ncp_get_fs_info_v2(struct ncp_server * server, struct file *file,
struct inode *inode = file->f_path.dentry->d_inode;
struct ncp_fs_info_v2 info2;

if ((file_permission(file, MAY_WRITE) != 0)
&& (current->uid != server->m.mounted_uid)) {
if (file_permission(file, MAY_WRITE) != 0
&& current_uid() != server->m.mounted_uid)
return -EACCES;
}

if (copy_from_user(&info2, arg, sizeof(info2)))
return -EFAULT;

Expand Down Expand Up @@ -141,10 +141,10 @@ ncp_get_compat_fs_info_v2(struct ncp_server * server, struct file *file,
struct inode *inode = file->f_path.dentry->d_inode;
struct compat_ncp_fs_info_v2 info2;

if ((file_permission(file, MAY_WRITE) != 0)
&& (current->uid != server->m.mounted_uid)) {
if (file_permission(file, MAY_WRITE) != 0
&& current_uid() != server->m.mounted_uid)
return -EACCES;
}

if (copy_from_user(&info2, arg, sizeof(info2)))
return -EFAULT;

Expand Down Expand Up @@ -270,16 +270,17 @@ static int __ncp_ioctl(struct inode *inode, struct file *filp,
struct ncp_ioctl_request request;
char* bouncebuffer;
void __user *argp = (void __user *)arg;
uid_t uid = current_uid();

switch (cmd) {
#ifdef CONFIG_COMPAT
case NCP_IOC_NCPREQUEST_32:
#endif
case NCP_IOC_NCPREQUEST:
if ((file_permission(filp, MAY_WRITE) != 0)
&& (current->uid != server->m.mounted_uid)) {
if (file_permission(filp, MAY_WRITE) != 0
&& uid != server->m.mounted_uid)
return -EACCES;
}

#ifdef CONFIG_COMPAT
if (cmd == NCP_IOC_NCPREQUEST_32) {
struct compat_ncp_ioctl_request request32;
Expand Down Expand Up @@ -356,10 +357,10 @@ static int __ncp_ioctl(struct inode *inode, struct file *filp,
case NCP_IOC_GETMOUNTUID16:
case NCP_IOC_GETMOUNTUID32:
case NCP_IOC_GETMOUNTUID64:
if ((file_permission(filp, MAY_READ) != 0)
&& (current->uid != server->m.mounted_uid)) {
if (file_permission(filp, MAY_READ) != 0
&& uid != server->m.mounted_uid)
return -EACCES;
}

if (cmd == NCP_IOC_GETMOUNTUID16) {
u16 uid;
SET_UID(uid, server->m.mounted_uid);
Expand All @@ -380,11 +381,10 @@ static int __ncp_ioctl(struct inode *inode, struct file *filp,
{
struct ncp_setroot_ioctl sr;

if ((file_permission(filp, MAY_READ) != 0)
&& (current->uid != server->m.mounted_uid))
{
if (file_permission(filp, MAY_READ) != 0
&& uid != server->m.mounted_uid)
return -EACCES;
}

if (server->m.mounted_vol[0]) {
struct dentry* dentry = inode->i_sb->s_root;

Expand All @@ -408,6 +408,7 @@ static int __ncp_ioctl(struct inode *inode, struct file *filp,
return -EFAULT;
return 0;
}

case NCP_IOC_SETROOT:
{
struct ncp_setroot_ioctl sr;
Expand Down Expand Up @@ -455,11 +456,10 @@ static int __ncp_ioctl(struct inode *inode, struct file *filp,

#ifdef CONFIG_NCPFS_PACKET_SIGNING
case NCP_IOC_SIGN_INIT:
if ((file_permission(filp, MAY_WRITE) != 0)
&& (current->uid != server->m.mounted_uid))
{
if (file_permission(filp, MAY_WRITE) != 0
&& uid != server->m.mounted_uid)
return -EACCES;
}

if (argp) {
if (server->sign_wanted)
{
Expand All @@ -478,24 +478,22 @@ static int __ncp_ioctl(struct inode *inode, struct file *filp,
return 0;

case NCP_IOC_SIGN_WANTED:
if ((file_permission(filp, MAY_READ) != 0)
&& (current->uid != server->m.mounted_uid))
{
if (file_permission(filp, MAY_READ) != 0
&& uid != server->m.mounted_uid)
return -EACCES;
}

if (put_user(server->sign_wanted, (int __user *)argp))
return -EFAULT;
return 0;

case NCP_IOC_SET_SIGN_WANTED:
{
int newstate;

if ((file_permission(filp, MAY_WRITE) != 0)
&& (current->uid != server->m.mounted_uid))
{
if (file_permission(filp, MAY_WRITE) != 0
&& uid != server->m.mounted_uid)
return -EACCES;
}

/* get only low 8 bits... */
if (get_user(newstate, (unsigned char __user *)argp))
return -EFAULT;
Expand All @@ -512,11 +510,10 @@ static int __ncp_ioctl(struct inode *inode, struct file *filp,

#ifdef CONFIG_NCPFS_IOCTL_LOCKING
case NCP_IOC_LOCKUNLOCK:
if ((file_permission(filp, MAY_WRITE) != 0)
&& (current->uid != server->m.mounted_uid))
{
if (file_permission(filp, MAY_WRITE) != 0
&& uid != server->m.mounted_uid)
return -EACCES;
}

{
struct ncp_lock_ioctl rqdata;

Expand Down Expand Up @@ -585,9 +582,8 @@ static int __ncp_ioctl(struct inode *inode, struct file *filp,

#ifdef CONFIG_COMPAT
case NCP_IOC_GETOBJECTNAME_32:
if (current->uid != server->m.mounted_uid) {
if (uid != server->m.mounted_uid)
return -EACCES;
}
{
struct compat_ncp_objectname_ioctl user;
size_t outl;
Expand All @@ -609,10 +605,10 @@ static int __ncp_ioctl(struct inode *inode, struct file *filp,
return 0;
}
#endif

case NCP_IOC_GETOBJECTNAME:
if (current->uid != server->m.mounted_uid) {
if (uid != server->m.mounted_uid)
return -EACCES;
}
{
struct ncp_objectname_ioctl user;
size_t outl;
Expand All @@ -633,13 +629,13 @@ static int __ncp_ioctl(struct inode *inode, struct file *filp,
return -EFAULT;
return 0;
}

#ifdef CONFIG_COMPAT
case NCP_IOC_SETOBJECTNAME_32:
#endif
case NCP_IOC_SETOBJECTNAME:
if (current->uid != server->m.mounted_uid) {
if (uid != server->m.mounted_uid)
return -EACCES;
}
{
struct ncp_objectname_ioctl user;
void* newname;
Expand Down Expand Up @@ -691,13 +687,13 @@ static int __ncp_ioctl(struct inode *inode, struct file *filp,
kfree(oldname);
return 0;
}

#ifdef CONFIG_COMPAT
case NCP_IOC_GETPRIVATEDATA_32:
#endif
case NCP_IOC_GETPRIVATEDATA:
if (current->uid != server->m.mounted_uid) {
if (uid != server->m.mounted_uid)
return -EACCES;
}
{
struct ncp_privatedata_ioctl user;
size_t outl;
Expand Down Expand Up @@ -736,13 +732,13 @@ static int __ncp_ioctl(struct inode *inode, struct file *filp,

return 0;
}

#ifdef CONFIG_COMPAT
case NCP_IOC_SETPRIVATEDATA_32:
#endif
case NCP_IOC_SETPRIVATEDATA:
if (current->uid != server->m.mounted_uid) {
if (uid != server->m.mounted_uid)
return -EACCES;
}
{
struct ncp_privatedata_ioctl user;
void* new;
Expand Down Expand Up @@ -794,9 +790,10 @@ static int __ncp_ioctl(struct inode *inode, struct file *filp,
#endif /* CONFIG_NCPFS_NLS */

case NCP_IOC_SETDENTRYTTL:
if ((file_permission(filp, MAY_WRITE) != 0) &&
(current->uid != server->m.mounted_uid))
if (file_permission(filp, MAY_WRITE) != 0 &&
uid != server->m.mounted_uid)
return -EACCES;

{
u_int32_t user;

Expand Down

0 comments on commit b45fb7b

Please sign in to comment.