diff -urN linux-2.1.90-1.dist/fs/ncpfs/Config.in linux/fs/ncpfs/Config.in --- linux-2.1.90-1.dist/fs/ncpfs/Config.in Fri Mar 6 19:03:04 1998 +++ linux/fs/ncpfs/Config.in Wed Mar 11 11:49:49 1998 @@ -1,10 +1,10 @@ # # NCP Filesystem configuration # -# bool ' Packet singatures' CONFIG_NCPFS_PACKET_SIGNING +bool ' Packet singatures' CONFIG_NCPFS_PACKET_SIGNING bool ' Proprietary file locking' CONFIG_NCPFS_IOCTL_LOCKING bool ' Clear remove/delete inhibit when needed' CONFIG_NCPFS_STRONG bool ' Use NFS namespace if available' CONFIG_NCPFS_NFS_NS bool ' Use LONG (OS/2) namespace if available' CONFIG_NCPFS_OS2_NS bool ' Allow mounting of volume subdirectories' CONFIG_NCPFS_MOUNT_SUBDIR -# bool ' NDS interserver authentication support' CONFIG_NCPFS_NDS_DOMAINS +bool ' NDS interserver authentication support' CONFIG_NCPFS_NDS_DOMAINS diff -urN linux-2.1.90-1.dist/fs/ncpfs/Makefile linux/fs/ncpfs/Makefile --- linux-2.1.90-1.dist/fs/ncpfs/Makefile Mon Jan 5 10:41:01 1998 +++ linux/fs/ncpfs/Makefile Wed Mar 11 11:49:49 1998 @@ -8,7 +8,8 @@ # Note 2! The CFLAGS definitions are now in the main makefile... O_TARGET := ncpfs.o -O_OBJS := dir.o file.o inode.o ioctl.o mmap.o ncplib_kernel.o sock.o +O_OBJS := dir.o file.o inode.o ioctl.o mmap.o ncplib_kernel.o sock.o \ + ncpsign_kernel.o M_OBJS := $(O_TARGET) # If you want debugging output, please uncomment the following line diff -urN linux-2.1.90-1.dist/fs/ncpfs/inode.c linux/fs/ncpfs/inode.c --- linux-2.1.90-1.dist/fs/ncpfs/inode.c Wed Mar 11 11:12:55 1998 +++ linux/fs/ncpfs/inode.c Wed Mar 11 12:36:28 1998 @@ -284,6 +284,7 @@ server->buffer_size = 0; server->conn_status = 0; server->root_dentry = NULL; + server->root_setuped = 0; #ifdef CONFIG_NCPFS_PACKET_SIGNING server->sign_wanted = 0; server->sign_active = 0; diff -urN linux-2.1.90-1.dist/fs/ncpfs/ioctl.c linux/fs/ncpfs/ioctl.c --- linux-2.1.90-1.dist/fs/ncpfs/ioctl.c Fri Mar 6 19:03:04 1998 +++ linux/fs/ncpfs/ioctl.c Wed Mar 11 16:34:27 1998 @@ -32,6 +32,22 @@ struct ncp_ioctl_request request; struct ncp_fs_info info; +#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: @@ -80,6 +96,8 @@ && (current->uid != server->m.mounted_uid)) { return -EACCES; } + if (server->root_setuped) return -EBUSY; + server->root_setuped = 1; return ncp_conn_logged_in(server); case NCP_IOC_GET_FS_INFO: @@ -121,19 +139,6 @@ put_user(server->m.mounted_uid, (uid_t *) arg); return 0; - case NCP_IOC_GETMOUNTUID_INT: - if ( (permission(inode, MAY_READ) != 0) - && (current->uid != server->m.mounted_uid)) - { - return -EACCES; - } - - { - unsigned int tmp=server->m.mounted_uid; - if (put_user(tmp, (unsigned long*) arg)) return -EFAULT; - } - return 0; - #ifdef CONFIG_NCPFS_MOUNT_SUBDIR case NCP_IOC_GETROOT: { @@ -168,6 +173,7 @@ { return -EACCES; } + if (server->root_setuped) return -EBUSY; if (copy_from_user(&sr, (struct ncp_setroot_ioctl*)arg, sizeof(sr))) return -EFAULT; @@ -184,6 +190,7 @@ } } dentry = server->root_dentry; + server->root_setuped = 1; if (dentry) { struct inode* inode = dentry->d_inode; diff -urN linux-2.1.90-1.dist/fs/ncpfs/ncpsign_kernel.c linux/fs/ncpfs/ncpsign_kernel.c --- linux-2.1.90-1.dist/fs/ncpfs/ncpsign_kernel.c Thu Jan 1 01:00:00 1970 +++ linux/fs/ncpfs/ncpsign_kernel.c Wed Mar 11 11:49:52 1998 @@ -0,0 +1,125 @@ +/* + * ncpsign_kernel.c + * + * Arne de Bruijn (arne@knoware.nl), 1997 + * + */ + +#include + +#ifdef CONFIG_NCPFS_PACKET_SIGNING + +#if 0 +#ifdef MODULE +#include +#include +#endif +#endif + +#include +#include +#if 0 +#include +#include +#endif +#include "ncpsign_kernel.h" + +#define rol32(i,c) (((((i)&0xffffffff)<>(32-c))) +/* i386: 32-bit, little endian, handles mis-alignment */ +#ifdef __i386__ +#define GET_LE32(p) (*(int *)(p)) +#define PUT_LE32(p,v) { *(int *)(p)=v; } +#else +/* from include/ncplib.h */ +#define BVAL(buf,pos) (((__u8 *)(buf))[pos]) +#define PVAL(buf,pos) ((unsigned)BVAL(buf,pos)) +#define BSET(buf,pos,val) (BVAL(buf,pos) = (val)) + +static inline word +WVAL_LH(__u8 * buf, int pos) +{ + return PVAL(buf, pos) | PVAL(buf, pos + 1) << 8; +} +static inline dword +DVAL_LH(__u8 * buf, int pos) +{ + return WVAL_LH(buf, pos) | WVAL_LH(buf, pos + 2) << 16; +} +static inline void +WSET_LH(__u8 * buf, int pos, word val) +{ + BSET(buf, pos, val & 0xff); + BSET(buf, pos + 1, val >> 8); +} +static inline void +DSET_LH(__u8 * buf, int pos, dword val) +{ + WSET_LH(buf, pos, val & 0xffff); + WSET_LH(buf, pos + 2, val >> 16); +} + +#define GET_LE32(p) DVAL_LH(p,0) +#define PUT_LE32(p,v) DSET_LH(p,0,v) +#endif + +#define min(a,b) ((a)<(b)?(a):(b)) + +static void nwsign(char *r_data1, char *r_data2, char *outdata) { + int i; + unsigned int w0,w1,w2,w3; + static int rbit[4]={0, 2, 1, 3}; +#ifdef __i386__ + unsigned int *data2=(int *)r_data2; +#else + unsigned int data2[16]; + for (i=0;i<16;i++) + data2[i]=GET_LE32(r_data2+(i<<2)); +#endif + w0=GET_LE32(r_data1); + w1=GET_LE32(r_data1+4); + w2=GET_LE32(r_data1+8); + w3=GET_LE32(r_data1+12); + for (i=0;i<16;i+=4) { + w0=rol32(w0 + ((w1 & w2) | ((~w1) & w3)) + data2[i+0],3); + w3=rol32(w3 + ((w0 & w1) | ((~w0) & w2)) + data2[i+1],7); + w2=rol32(w2 + ((w3 & w0) | ((~w3) & w1)) + data2[i+2],11); + w1=rol32(w1 + ((w2 & w3) | ((~w2) & w0)) + data2[i+3],19); + } + for (i=0;i<4;i++) { + w0=rol32(w0 + (((w2 | w3) & w1) | (w2 & w3)) + 0x5a827999 + data2[i+0],3); + w3=rol32(w3 + (((w1 | w2) & w0) | (w1 & w2)) + 0x5a827999 + data2[i+4],5); + w2=rol32(w2 + (((w0 | w1) & w3) | (w0 & w1)) + 0x5a827999 + data2[i+8],9); + w1=rol32(w1 + (((w3 | w0) & w2) | (w3 & w0)) + 0x5a827999 + data2[i+12],13); + } + for (i=0;i<4;i++) { + w0=rol32(w0 + ((w1 ^ w2) ^ w3) + 0x6ed9eba1 + data2[rbit[i]+0],3); + w3=rol32(w3 + ((w0 ^ w1) ^ w2) + 0x6ed9eba1 + data2[rbit[i]+8],9); + w2=rol32(w2 + ((w3 ^ w0) ^ w1) + 0x6ed9eba1 + data2[rbit[i]+4],11); + w1=rol32(w1 + ((w2 ^ w3) ^ w0) + 0x6ed9eba1 + data2[rbit[i]+12],15); + } + PUT_LE32(outdata,(w0+GET_LE32(r_data1)) & 0xffffffff); + PUT_LE32(outdata+4,(w1+GET_LE32(r_data1+4)) & 0xffffffff); + PUT_LE32(outdata+8,(w2+GET_LE32(r_data1+8)) & 0xffffffff); + PUT_LE32(outdata+12,(w3+GET_LE32(r_data1+12)) & 0xffffffff); +} + +/* Make a signature for the current packet and add it at the end of the */ +/* packet. */ +void sign_packet(struct ncp_server *server, int *size) { + char data[64]; + + memset(data,0,64); + memcpy(data,server->sign_root,8); + PUT_LE32(data+8,(*size)); + memcpy(data+12,server->packet+sizeof(struct ncp_request_header)-1, + min((*size)-sizeof(struct ncp_request_header)+1,52)); + + nwsign(server->sign_last,data,server->sign_last); + + memcpy(server->packet+(*size),server->sign_last,8); + (*size)+=8; +} + +#endif /* CONFIG_NCPFS_PACKET_SIGNING */ + diff -urN linux-2.1.90-1.dist/fs/ncpfs/ncpsign_kernel.h linux/fs/ncpfs/ncpsign_kernel.h --- linux-2.1.90-1.dist/fs/ncpfs/ncpsign_kernel.h Thu Jan 1 01:00:00 1970 +++ linux/fs/ncpfs/ncpsign_kernel.h Wed Mar 11 15:41:35 1998 @@ -0,0 +1,16 @@ +/* + * ncpsign_kernel.h + * + * Arne de Bruijn (arne@knoware.nl), 1997 + * + */ + +#ifndef _NCPSIGN_KERNEL_H +#define _NCPSIGN_KERNEL_H + +#include +#include + +void sign_packet(struct ncp_server *server, int *size); + +#endif diff -urN linux-2.1.90-1.dist/include/linux/ncp_fs.h linux/include/linux/ncp_fs.h --- linux-2.1.90-1.dist/include/linux/ncp_fs.h Sat Mar 7 06:05:21 1998 +++ linux/include/linux/ncp_fs.h Wed Mar 11 16:52:09 1998 @@ -83,8 +83,15 @@ }; #define NCP_IOC_NCPREQUEST _IOR('n', 1, struct ncp_ioctl_request) -#define NCP_IOC_GETMOUNTUID _IOW('n', 2, uid_t) -#define NCP_IOC_GETMOUNTUID_INT _IOW('n', 2, unsigned int) +#define NCP_IOC_GETMOUNTUID _IOW('n', 2, __kernel_uid_t) + +#if 1 +#ifdef __KERNEL__ +/* remove after ncpfs-2.0.13/2.2.0 gets released */ +#define NCP_IOC_GETMOUNTUID_INT _IOW('n', 2, unsigned int) +#endif +#endif + #define NCP_IOC_CONN_LOGGED_IN _IO('n', 3) #define NCP_GET_FS_INFO_VERSION (1) diff -urN linux-2.1.90-1.dist/include/linux/ncp_fs_sb.h linux/include/linux/ncp_fs_sb.h --- linux-2.1.90-1.dist/include/linux/ncp_fs_sb.h Sat Mar 7 06:05:21 1998 +++ linux/include/linux/ncp_fs_sb.h Wed Mar 11 15:25:14 1998 @@ -51,11 +51,9 @@ int ncp_reply_size; struct ncp_inode_info root; -#if 0 - char root_path; /* '\0' */ -#else struct dentry* root_dentry; -#endif + + int root_setuped; /* info for packet signing */ int sign_wanted; /* 1=Server needs signed packets */ diff -urN linux-2.1.89.dist/fs/ncpfs/dir.c linux/fs/ncpfs/dir.c --- linux-2.1.89.dist/fs/ncpfs/dir.c Fri Mar 6 19:03:04 1998 +++ linux/fs/ncpfs/dir.c Mon Mar 9 10:47:20 1998 @@ -112,7 +112,7 @@ static int ncp_compare_dentry (struct dentry *, struct qstr *, struct qstr *); static void ncp_delete_dentry(struct dentry *); -static struct dentry_operations ncp_dentry_operations = +struct dentry_operations ncp_dentry_operations = { ncp_lookup_validate, /* d_validate(struct dentry *) */ ncp_hash_dentry, /* d_hash */