summaryrefslogtreecommitdiffstats
path: root/fs/ncpfs
diff options
context:
space:
mode:
Diffstat (limited to 'fs/ncpfs')
-rw-r--r--fs/ncpfs/inode.c51
-rw-r--r--fs/ncpfs/ioctl.c144
-rw-r--r--fs/ncpfs/ncplib_kernel.c6
3 files changed, 127 insertions, 74 deletions
diff --git a/fs/ncpfs/inode.c b/fs/ncpfs/inode.c
index 26bd474d2..eca5ddf15 100644
--- a/fs/ncpfs/inode.c
+++ b/fs/ncpfs/inode.c
@@ -258,7 +258,7 @@ ncp_delete_inode(struct inode *inode)
struct super_block *
ncp_read_super(struct super_block *sb, void *raw_data, int silent)
{
- struct ncp_mount_data *data = (struct ncp_mount_data *) raw_data;
+ struct ncp_mount_data_kernel data;
struct ncp_server *server;
struct file *ncp_filp;
struct inode *root_inode;
@@ -270,11 +270,50 @@ ncp_read_super(struct super_block *sb, void *raw_data, int silent)
struct ncp_entry_info finfo;
MOD_INC_USE_COUNT;
- if (data == NULL)
+ if (raw_data == NULL)
goto out_no_data;
- if (data->version != NCP_MOUNT_VERSION)
- goto out_bad_mount;
- ncp_filp = fget(data->ncp_fd);
+ switch (*(int*)raw_data) {
+ case NCP_MOUNT_VERSION:
+ {
+ struct ncp_mount_data* md = (struct ncp_mount_data*)raw_data;
+
+ data.flags = md->flags;
+ data.int_flags = NCP_IMOUNT_LOGGEDIN_POSSIBLE;
+ data.mounted_uid = md->mounted_uid;
+ data.wdog_pid = md->wdog_pid;
+ data.ncp_fd = md->ncp_fd;
+ data.time_out = md->time_out;
+ data.retry_count = md->retry_count;
+ data.uid = md->uid;
+ data.gid = md->gid;
+ data.file_mode = md->file_mode;
+ data.dir_mode = md->dir_mode;
+ memcpy(data.mounted_vol, md->mounted_vol,
+ NCP_VOLNAME_LEN+1);
+ }
+ break;
+ case NCP_MOUNT_VERSION_V4:
+ {
+ struct ncp_mount_data_v4* md = (struct ncp_mount_data_v4*)raw_data;
+
+ data.flags = md->flags;
+ data.int_flags = 0;
+ data.mounted_uid = md->mounted_uid;
+ data.wdog_pid = md->wdog_pid;
+ data.ncp_fd = md->ncp_fd;
+ data.time_out = md->time_out;
+ data.retry_count = md->retry_count;
+ data.uid = md->uid;
+ data.gid = md->gid;
+ data.file_mode = md->file_mode;
+ data.dir_mode = md->dir_mode;
+ data.mounted_vol[0] = 0;
+ }
+ break;
+ default:
+ goto out_bad_mount;
+ }
+ ncp_filp = fget(data.ncp_fd);
if (!ncp_filp)
goto out_bad_file;
if (!S_ISSOCK(ncp_filp->f_dentry->d_inode->i_mode))
@@ -310,7 +349,7 @@ ncp_read_super(struct super_block *sb, void *raw_data, int silent)
/* server->priv.len = 0; */
/* server->priv.data = NULL; */
- server->m = *data;
+ server->m = data;
/* Althought anything producing this is buggy, it happens
now because of PATH_MAX changes.. */
if (server->m.time_out < 1) {
diff --git a/fs/ncpfs/ioctl.c b/fs/ncpfs/ioctl.c
index 36063db81..6cf94831f 100644
--- a/fs/ncpfs/ioctl.c
+++ b/fs/ncpfs/ioctl.c
@@ -15,6 +15,7 @@
#include <linux/ioctl.h>
#include <linux/sched.h>
#include <linux/mm.h>
+#include <linux/highuid.h>
#include <linux/ncp_fs.h>
@@ -31,25 +32,8 @@ int ncp_ioctl(struct inode *inode, struct file *filp,
struct ncp_server *server = NCP_SERVER(inode);
int result;
struct ncp_ioctl_request request;
- struct ncp_fs_info info;
char* bouncebuffer;
-#ifdef NCP_IOC_GETMOUNTUID_INT
- /* remove after ncpfs-2.0.13/2.2.0 gets released */
- if ((NCP_IOC_GETMOUNTUID != NCP_IOC_GETMOUNTUID_INT) &&
- (cmd == NCP_IOC_GETMOUNTUID_INT)) {
- int tmp = server->m.mounted_uid;
-
- if ( (permission(inode, MAY_READ) != 0)
- && (current->uid != server->m.mounted_uid))
- {
- return -EACCES;
- }
- if (put_user(tmp, (unsigned int*) arg)) return -EFAULT;
- return 0;
- }
-#endif /* NCP_IOC_GETMOUNTUID_INT */
-
switch (cmd) {
case NCP_IOC_NCPREQUEST:
@@ -66,10 +50,6 @@ int ncp_ioctl(struct inode *inode, struct file *filp,
NCP_PACKET_SIZE - sizeof(struct ncp_request_header))) {
return -EINVAL;
}
- if ((result = verify_area(VERIFY_WRITE, (char *) request.data,
- NCP_PACKET_SIZE)) != 0) {
- return result;
- }
bouncebuffer = kmalloc(NCP_PACKET_SIZE, GFP_NFS);
if (!bouncebuffer)
return -ENOMEM;
@@ -107,48 +87,82 @@ int ncp_ioctl(struct inode *inode, struct file *filp,
&& (current->uid != server->m.mounted_uid)) {
return -EACCES;
}
- if (server->root_setuped) return -EBUSY;
+ if (!(server->m.int_flags & NCP_IMOUNT_LOGGEDIN_POSSIBLE))
+ return -EINVAL;
+ if (server->root_setuped)
+ return -EBUSY;
server->root_setuped = 1;
return ncp_conn_logged_in(inode->i_sb);
case NCP_IOC_GET_FS_INFO:
+ {
+ struct ncp_fs_info info;
- if ((permission(inode, MAY_WRITE) != 0)
- && (current->uid != server->m.mounted_uid)) {
- return -EACCES;
- }
- if ((result = verify_area(VERIFY_WRITE, (char *) arg,
- sizeof(info))) != 0) {
- return result;
- }
- copy_from_user(&info, (struct ncp_fs_info *) arg, sizeof(info));
+ if ((permission(inode, MAY_WRITE) != 0)
+ && (current->uid != server->m.mounted_uid)) {
+ return -EACCES;
+ }
+ if (copy_from_user(&info, (struct ncp_fs_info *) arg,
+ sizeof(info)))
+ return -EFAULT;
- if (info.version != NCP_GET_FS_INFO_VERSION) {
- DPRINTK("info.version invalid: %d\n", info.version);
- return -EINVAL;
+ if (info.version != NCP_GET_FS_INFO_VERSION) {
+ DPRINTK("info.version invalid: %d\n", info.version);
+ return -EINVAL;
+ }
+ /* TODO: info.addr = server->m.serv_addr; */
+ info.mounted_uid = NEW_TO_OLD_UID(server->m.mounted_uid);
+ info.connection = server->connection;
+ info.buffer_size = server->buffer_size;
+ info.volume_number = NCP_FINFO(inode)->volNumber;
+ info.directory_id = NCP_FINFO(inode)->DosDirNum;
+
+ if (copy_to_user((struct ncp_fs_info *) arg, &info,
+ sizeof(info))) return -EFAULT;
+ return 0;
}
- /* TODO: info.addr = server->m.serv_addr; */
- info.mounted_uid = server->m.mounted_uid;
- info.connection = server->connection;
- info.buffer_size = server->buffer_size;
- info.volume_number = NCP_FINFO(inode)->volNumber;
- info.directory_id = NCP_FINFO(inode)->DosDirNum;
-
- copy_to_user((struct ncp_fs_info *) arg, &info, sizeof(info));
- return 0;
- case NCP_IOC_GETMOUNTUID:
+ case NCP_IOC_GET_FS_INFO_V2:
+ {
+ struct ncp_fs_info_v2 info2;
- if ((permission(inode, MAY_READ) != 0)
- && (current->uid != server->m.mounted_uid)) {
- return -EACCES;
+ if ((permission(inode, MAY_WRITE) != 0)
+ && (current->uid != server->m.mounted_uid)) {
+ return -EACCES;
+ }
+ if (copy_from_user(&info2, (struct ncp_fs_info_v2 *) arg,
+ sizeof(info2)))
+ return -EFAULT;
+
+ if (info2.version != NCP_GET_FS_INFO_VERSION_V2) {
+ DPRINTK("info.version invalid: %d\n", info2.version);
+ return -EINVAL;
+ }
+ info2.mounted_uid = server->m.mounted_uid;
+ info2.connection = server->connection;
+ info2.buffer_size = server->buffer_size;
+ info2.volume_number = NCP_FINFO(inode)->volNumber;
+ info2.directory_id = NCP_FINFO(inode)->DosDirNum;
+ info2.dummy1 = info2.dummy2 = info2.dummy3 = 0;
+
+ if (copy_to_user((struct ncp_fs_info_v2 *) arg, &info2,
+ sizeof(info2))) return -EFAULT;
+ return 0;
}
- if ((result = verify_area(VERIFY_WRITE, (uid_t *) arg,
- sizeof(uid_t))) != 0) {
- return result;
+
+ case NCP_IOC_GETMOUNTUID2:
+ {
+ unsigned long tmp = server->m.mounted_uid;
+
+ if ( (permission(inode, MAY_READ) != 0)
+ && (current->uid != server->m.mounted_uid))
+ {
+ return -EACCES;
+ }
+ if (put_user(tmp, (unsigned long*) arg))
+ return -EFAULT;
+ return 0;
}
- put_user(server->m.mounted_uid, (uid_t *) arg);
- return 0;
#ifdef CONFIG_NCPFS_MOUNT_SUBDIR
case NCP_IOC_GETROOT:
@@ -371,11 +385,6 @@ int ncp_ioctl(struct inode *inode, struct file *filp,
struct ncp_objectname_ioctl user;
int outl;
- if ((result = verify_area(VERIFY_WRITE,
- (struct ncp_objectname_ioctl*)arg,
- sizeof(user))) != 0) {
- return result;
- }
if (copy_from_user(&user,
(struct ncp_objectname_ioctl*)arg,
sizeof(user))) return -EFAULT;
@@ -446,11 +455,6 @@ int ncp_ioctl(struct inode *inode, struct file *filp,
struct ncp_privatedata_ioctl user;
int outl;
- if ((result = verify_area(VERIFY_WRITE,
- (struct ncp_privatedata_ioctl*)arg,
- sizeof(user))) != 0) {
- return result;
- }
if (copy_from_user(&user,
(struct ncp_privatedata_ioctl*)arg,
sizeof(user))) return -EFAULT;
@@ -629,7 +633,19 @@ int ncp_ioctl(struct inode *inode, struct file *filp,
return 0;
}
- default:
- return -EINVAL;
}
+/* #ifdef CONFIG_UID16 */
+ /* NCP_IOC_GETMOUNTUID may be same as NCP_IOC_GETMOUNTUID2,
+ so we have this out of switch */
+ if (cmd == NCP_IOC_GETMOUNTUID) {
+ if ((permission(inode, MAY_READ) != 0)
+ && (current->uid != server->m.mounted_uid)) {
+ return -EACCES;
+ }
+ if (put_user(NEW_TO_OLD_UID(server->m.mounted_uid), (__kernel_uid_t *) arg))
+ return -EFAULT;
+ return 0;
+ }
+/* #endif */
+ return -EINVAL;
}
diff --git a/fs/ncpfs/ncplib_kernel.c b/fs/ncpfs/ncplib_kernel.c
index 7220e4852..73afd107a 100644
--- a/fs/ncpfs/ncplib_kernel.c
+++ b/fs/ncpfs/ncplib_kernel.c
@@ -617,10 +617,8 @@ int ncp_open_create_file_or_subdir(struct ncp_server *server,
target->server_file_handle = ncp_reply_dword(server, 0);
target->open_create_action = ncp_reply_byte(server, 4);
- if (dir != NULL) {
- /* in target there's a new finfo to fill */
- ncp_extract_file_info(ncp_reply_data(server, 6), &(target->i));
- }
+ /* in target there's a new finfo to fill */
+ ncp_extract_file_info(ncp_reply_data(server, 6), &(target->i));
ConvertToNWfromDWORD(target->server_file_handle, target->file_handle);
out: