diff options
Diffstat (limited to 'source3/smbd')
-rw-r--r-- | source3/smbd/chgpasswd.c | 10 | ||||
-rw-r--r-- | source3/smbd/close.c | 2 | ||||
-rw-r--r-- | source3/smbd/connection.c | 2 | ||||
-rw-r--r-- | source3/smbd/dfree.c | 8 | ||||
-rw-r--r-- | source3/smbd/dir.c | 7 | ||||
-rw-r--r-- | source3/smbd/dosmode.c | 4 | ||||
-rw-r--r-- | source3/smbd/filename.c | 2 | ||||
-rw-r--r-- | source3/smbd/ipc.c | 2 | ||||
-rw-r--r-- | source3/smbd/lanman.c | 38 | ||||
-rw-r--r-- | source3/smbd/mangle.c | 70 | ||||
-rw-r--r-- | source3/smbd/message.c | 9 | ||||
-rw-r--r-- | source3/smbd/negprot.c | 2 | ||||
-rw-r--r-- | source3/smbd/noquotas.c | 2 | ||||
-rw-r--r-- | source3/smbd/notify_kernel.c | 2 | ||||
-rw-r--r-- | source3/smbd/nttrans.c | 18 | ||||
-rw-r--r-- | source3/smbd/open.c | 26 | ||||
-rw-r--r-- | source3/smbd/password.c | 2 | ||||
-rw-r--r-- | source3/smbd/posix_acls.c | 12 | ||||
-rw-r--r-- | source3/smbd/reply.c | 99 | ||||
-rw-r--r-- | source3/smbd/server.c | 4 | ||||
-rw-r--r-- | source3/smbd/service.c | 3 | ||||
-rw-r--r-- | source3/smbd/srvstr.c | 145 | ||||
-rw-r--r-- | source3/smbd/trans2.c | 52 | ||||
-rw-r--r-- | source3/smbd/vfs-wrap.c | 36 | ||||
-rw-r--r-- | source3/smbd/vfs.c | 202 |
25 files changed, 186 insertions, 573 deletions
diff --git a/source3/smbd/chgpasswd.c b/source3/smbd/chgpasswd.c index c6f6eca0ba..12e38f2a65 100644 --- a/source3/smbd/chgpasswd.c +++ b/source3/smbd/chgpasswd.c @@ -793,14 +793,12 @@ BOOL check_oem_password(char *user, /* * nt passwords are in unicode */ - int uni_pw_len = new_pw_len; - char *pw; - new_pw_len /= 2; - pw = dos_unistrn2((uint16 *)(&lmdata[512 - uni_pw_len]),new_pw_len); - memcpy(new_passwd, pw, new_pw_len + 1); + pull_ucs2(NULL, new_passwd, + (const smb_ucs2_t *)&lmdata[512 - new_pw_len], + new_passwd_size, new_pw_len, 0); } else { memcpy(new_passwd, &lmdata[512 - new_pw_len], new_pw_len); - new_passwd[new_pw_len] = '\0'; + new_passwd[new_pw_len] = 0; } /* diff --git a/source3/smbd/close.c b/source3/smbd/close.c index 217c81228f..dfbc2272e6 100644 --- a/source3/smbd/close.c +++ b/source3/smbd/close.c @@ -172,7 +172,7 @@ static int close_normal_file(files_struct *fsp, BOOL normal_close) if (normal_close && delete_on_close) { DEBUG(5,("close_file: file %s. Delete on close was set - deleting file.\n", fsp->fsp_name)); - if(fsp->conn->vfs_ops.unlink(conn,dos_to_unix(fsp->fsp_name, False)) != 0) { + if(fsp->conn->vfs_ops.unlink(conn,fsp->fsp_name) != 0) { /* * This call can potentially fail as another smbd may have * had the file open with delete on close set and deleted diff --git a/source3/smbd/connection.c b/source3/smbd/connection.c index 796a54e77d..a6c37c7aba 100644 --- a/source3/smbd/connection.c +++ b/source3/smbd/connection.c @@ -53,7 +53,6 @@ BOOL yield_connection(connection_struct *conn,char *name,int max_connections) key.pid = sys_getpid(); key.cnum = conn?conn->cnum:-1; fstrcpy(key.name, name); - dos_to_unix(key.name, True); /* Convert key to unix-codepage */ kbuf.dptr = (char *)&key; kbuf.dsize = sizeof(key); @@ -174,7 +173,6 @@ BOOL claim_connection(connection_struct *conn,char *name,int max_connections,BOO key.pid = sys_getpid(); key.cnum = conn?conn->cnum:-1; fstrcpy(key.name, name); - dos_to_unix(key.name, True); /* Convert key to unix-codepage */ kbuf.dptr = (char *)&key; kbuf.dsize = sizeof(key); diff --git a/source3/smbd/dfree.c b/source3/smbd/dfree.c index 64c6182cd8..7848309a5e 100644 --- a/source3/smbd/dfree.c +++ b/source3/smbd/dfree.c @@ -66,7 +66,7 @@ static void disk_norm(BOOL small_query, SMB_BIG_UINT *bsize,SMB_BIG_UINT *dfree, return number of 1K blocks available on a path and total number ****************************************************************************/ -static SMB_BIG_UINT disk_free(char *path, BOOL small_query, +static SMB_BIG_UINT disk_free(const char *path, BOOL small_query, SMB_BIG_UINT *bsize,SMB_BIG_UINT *dfree,SMB_BIG_UINT *dsize) { int dfree_retval; @@ -91,7 +91,7 @@ static SMB_BIG_UINT disk_free(char *path, BOOL small_query, slprintf(syscmd, sizeof(syscmd)-1, "%s %s", dfree_command, path); DEBUG (3, ("disk_free: Running command %s\n", syscmd)); - lines = file_lines_pload(syscmd, NULL, True); + lines = file_lines_pload(syscmd, NULL); if (lines) { char *line = lines[0]; @@ -161,8 +161,8 @@ static SMB_BIG_UINT disk_free(char *path, BOOL small_query, /**************************************************************************** wrap it to get filenames right ****************************************************************************/ -SMB_BIG_UINT sys_disk_free(char *path, BOOL small_query, +SMB_BIG_UINT sys_disk_free(const char *path, BOOL small_query, SMB_BIG_UINT *bsize,SMB_BIG_UINT *dfree,SMB_BIG_UINT *dsize) { - return(disk_free(dos_to_unix(path,False),small_query, bsize,dfree,dsize)); + return disk_free(path,small_query, bsize,dfree,dsize); } diff --git a/source3/smbd/dir.c b/source3/smbd/dir.c index fa9cbdc4a2..9a9c745944 100644 --- a/source3/smbd/dir.c +++ b/source3/smbd/dir.c @@ -625,7 +625,7 @@ BOOL get_dir_entry(connection_struct *conn,char *mask,int dirtype,char *fname, pstrcpy(pathreal,path); pstrcat(path,fname); pstrcat(pathreal,dname); - if (conn->vfs_ops.stat(conn,dos_to_unix(pathreal, False), &sbuf) != 0) + if (conn->vfs_ops.stat(conn, pathreal, &sbuf) != 0) { DEBUG(5,("Couldn't stat 1 [%s]. Error = %s\n",path, strerror(errno) )); continue; @@ -701,7 +701,7 @@ void *OpenDir(connection_struct *conn, char *name, BOOL use_veto) { Dir *dirp; char *n; - DIR *p = conn->vfs_ops.opendir(conn,dos_to_unix(name,False)); + DIR *p = conn->vfs_ops.opendir(conn,name); int used=0; if (!p) return(NULL); @@ -720,9 +720,6 @@ void *OpenDir(connection_struct *conn, char *name, BOOL use_veto) l = strlen(n)+1; - /* Return value of vfs_readdirname has already gone through - unix_to_dos() */ - /* If it's a vetoed file, pretend it doesn't even exist */ if (use_veto && conn && IS_VETO_PATH(conn, n)) continue; diff --git a/source3/smbd/dosmode.c b/source3/smbd/dosmode.c index 9ec1fa2606..89e5b1586c 100644 --- a/source3/smbd/dosmode.c +++ b/source3/smbd/dosmode.c @@ -282,7 +282,7 @@ int file_utime(connection_struct *conn, char *fname, struct utimbuf *times) errno = 0; - if(conn->vfs_ops.utime(conn,dos_to_unix(fname, False), times) == 0) + if(conn->vfs_ops.utime(conn,fname, times) == 0) return 0; if((errno != EPERM) && (errno != EACCES)) @@ -310,7 +310,7 @@ int file_utime(connection_struct *conn, char *fname, struct utimbuf *times) current_user.ngroups,current_user.groups)))) { /* We are allowed to become root and change the filetime. */ become_root(); - ret = conn->vfs_ops.utime(conn,dos_to_unix(fname, False), times); + ret = conn->vfs_ops.utime(conn,fname, times); unbecome_root(); } } diff --git a/source3/smbd/filename.c b/source3/smbd/filename.c index bdbcd81b64..9b76d63dc6 100644 --- a/source3/smbd/filename.c +++ b/source3/smbd/filename.c @@ -436,7 +436,7 @@ BOOL check_name(char *name,connection_struct *conn) #ifdef S_ISLNK if (!lp_symlinks(SNUM(conn))) { SMB_STRUCT_STAT statbuf; - if ( (conn->vfs_ops.lstat(conn,dos_to_unix(name,False),&statbuf) != -1) && + if ( (conn->vfs_ops.lstat(conn,name,&statbuf) != -1) && (S_ISLNK(statbuf.st_mode)) ) { DEBUG(3,("check_name: denied: file path name %s is a symlink\n",name)); ret=0; diff --git a/source3/smbd/ipc.c b/source3/smbd/ipc.c index eb6ccb4fce..e853112bfe 100644 --- a/source3/smbd/ipc.c +++ b/source3/smbd/ipc.c @@ -385,7 +385,7 @@ int reply_trans(connection_struct *conn, char *inbuf,char *outbuf, int size, int START_PROFILE(SMBtrans); memset(name, '\0',sizeof(name)); - srvstr_pull(inbuf, name, smb_buf(inbuf), sizeof(name), -1, STR_TERMINATE|STR_CONVERT); + srvstr_pull(inbuf, name, smb_buf(inbuf), sizeof(name), -1, STR_TERMINATE); if (dscnt > tdscnt || pscnt > tpscnt) { exit_server("invalid trans parameters\n"); diff --git a/source3/smbd/lanman.c b/source3/smbd/lanman.c index 69a0fa5ac3..2b71770b2e 100644 --- a/source3/smbd/lanman.c +++ b/source3/smbd/lanman.c @@ -75,8 +75,7 @@ static int CopyExpanded(connection_struct *conn, StrnCpy(buf,src,sizeof(buf)/2); pstring_sub(buf,"%S",lp_servicename(snum)); standard_sub_conn(conn,buf); - StrnCpy(*dst,buf,*n-1); - l = strlen(*dst) + 1; + l = push_ascii(*dst,buf,*n-1, STR_TERMINATE); (*dst) += l; (*n) -= l; return l; @@ -86,8 +85,7 @@ static int CopyAndAdvance(char** dst, char* src, int* n) { int l; if (!src || !dst || !n || !(*dst)) return(0); - StrnCpy(*dst,src,*n-1); - l = strlen(*dst) + 1; + l = push_ascii(*dst,src,*n-1, STR_TERMINATE); (*dst) += l; (*n) -= l; return l; @@ -356,7 +354,7 @@ static void PackDriverData(struct pack_desc* desc) SIVAL(drivdata,0,sizeof drivdata); /* cb */ SIVAL(drivdata,4,1000); /* lVersion */ memset(drivdata+8,0,32); /* szDeviceName */ - srvstr_push_ascii(drivdata+8,"NULL",-1); + push_ascii(drivdata+8,"NULL",-1, STR_TERMINATE); PACKl(desc,"l",drivdata,sizeof drivdata); /* pDriverData */ } @@ -563,7 +561,7 @@ static void fill_printq_info_52(connection_struct *conn, int snum, int uLevel, DEBUG(10,("snum: %d\nprinterdriver: [%s]\nlp_driverfile: [%s]\n", snum, drivername, lp_driverfile(snum))); - lines = file_lines_load(lp_driverfile(snum),NULL, False); + lines = file_lines_load(lp_driverfile(snum),NULL); if (!lines) { DEBUG(3,("Can't open %s - %s\n", lp_driverfile(snum), @@ -795,7 +793,7 @@ static int get_printerdrivernumber(int snum) DEBUG(10,("snum: %d\nprinterdriver: [%s]\nlp_driverfile: [%s]\n", snum, drivername, lp_driverfile(snum))); - lines = file_lines_load(lp_driverfile(snum), NULL, False); + lines = file_lines_load(lp_driverfile(snum), NULL); if (!lines) { DEBUG(3,("Can't open %s - %s\n", lp_driverfile(snum),strerror(errno))); @@ -1110,7 +1108,7 @@ static int get_server_info(uint32 servertype, BOOL local_list_only; int i; - lines = file_lines_load(lock_path(SERVER_LIST), NULL, False); + lines = file_lines_load(lock_path(SERVER_LIST), NULL); if (!lines) { DEBUG(4,("Can't open %s - %s\n",lock_path(SERVER_LIST),strerror(errno))); return(0); @@ -1255,15 +1253,15 @@ static int fill_srv_info(struct srv_info_struct *service, switch (uLevel) { case 0: - srvstr_push_ascii(p,service->name,15); - break; + push_ascii(p,service->name, 15, STR_TERMINATE); + break; case 1: - srvstr_push_ascii(p,service->name,15); - SIVAL(p,18,service->type); - SIVAL(p,22,PTR_DIFF(p2,baseaddr)); - len += CopyAndAdvance(&p2,service->comment,&l2); - break; + push_ascii(p,service->name,15, STR_TERMINATE); + SIVAL(p,18,service->type); + SIVAL(p,22,PTR_DIFF(p2,baseaddr)); + len += CopyAndAdvance(&p2,service->comment,&l2); + break; } if (stringbuf) @@ -1340,7 +1338,7 @@ static BOOL api_RNetServerEnum(connection_struct *conn, uint16 vuid, char *param DEBUG(4, ("local_only:%s\n", BOOLSTR(local_request))); if (strcmp(str1, "WrLehDz") == 0) { - srvstr_pull_ascii(domain, p, sizeof(fstring)); + pull_ascii_fstring(domain, p); } else { fstrcpy(domain, global_myworkgroup); } @@ -1515,7 +1513,7 @@ static int fill_share_info(connection_struct *conn, int snum, int uLevel, } if (!baseaddr) baseaddr = p; - srvstr_push_ascii(p,lp_servicename(snum),13); + push_ascii(p,lp_servicename(snum),13, STR_TERMINATE); if (uLevel > 0) { @@ -1727,7 +1725,7 @@ static BOOL api_SetUserPassword(connection_struct *conn,uint16 vuid, char *param fstring user; fstring pass1,pass2; - srvstr_pull_ascii(user,p,sizeof(user)); + pull_ascii_fstring(user,p); p = skip_string(p,1); @@ -1868,7 +1866,7 @@ static BOOL api_SamOEMChangePassword(connection_struct *conn,uint16 vuid, char * } p = skip_string(p,1); - p += srvstr_pull_ascii(user,p,sizeof(user)); + p += pull_ascii_fstring(user,p); DEBUG(3,("api_SamOEMChangePassword: Change password for <%s>\n",user)); @@ -2138,7 +2136,7 @@ static BOOL api_RNetServerGetInfo(connection_struct *conn,uint16 vuid, char *par p2 = p + struct_len; if (uLevel != 20) { srvstr_push(NULL, p,local_machine,16, - STR_ASCII|STR_UPPER|STR_TERMINATE|STR_CONVERT); + STR_ASCII|STR_UPPER|STR_TERMINATE); } p += 16; if (uLevel > 0) diff --git a/source3/smbd/mangle.c b/source3/smbd/mangle.c index 61af1f7ded..8df71d4557 100644 --- a/source3/smbd/mangle.c +++ b/source3/smbd/mangle.c @@ -244,7 +244,6 @@ static BOOL is_reserved_msdos( char *fname ) static BOOL is_illegal_name( char *name ) { unsigned char *s; - int skip; if( !name ) return( True ); @@ -255,18 +254,10 @@ static BOOL is_illegal_name( char *name ) s = (unsigned char *)name; while( *s ) { - skip = get_character_len( *s ); - if( skip != 0 ) - { - s += skip; - } - else - { - if( isillegal( *s ) ) + if( *s>0x7F && isillegal( *s ) ) return( True ); else s++; - } } return( False ); @@ -325,7 +316,6 @@ BOOL is_8_3( char *fname, BOOL check_case ) { int len; int l; - int skip; char *p; char *dot_pos; char *slash_pos = strrchr( fname, '/' ); @@ -374,17 +364,12 @@ BOOL is_8_3( char *fname, BOOL check_case ) dot_pos = NULL; while( *p ) { - if( (skip = get_character_len( *p )) != 0 ) - p += skip; - else - { if( *p == '.' && !dot_pos ) dot_pos = (char *)p; - else + /*else if( !isdoschar( *p ) ) - return( False ); + return( False );*/ p++; - } } /* no dot and less than 9 means OK */ @@ -844,7 +829,6 @@ void mangle_name_83( char *s) char base[9]; int baselen = 0; int extlen = 0; - int skip; extension[0] = 0; base[0] = 0; @@ -879,31 +863,9 @@ void mangle_name_83( char *s) *p++ = 0; while( *p && extlen < 3 ) { - skip = get_character_len( *p ); - switch( skip ) - { - case 2: - if( extlen < 2 ) - { + if( /*isdoschar (*p) &&*/ *p != '.' ) extension[extlen++] = p[0]; - extension[extlen++] = p[1]; - } - else - { - extension[extlen++] = mangle( (unsigned char)*p ); - } - p += 2; - break; - case 1: - extension[extlen++] = p[0]; p++; - break; - default: - if( isdoschar (*p) && *p != '.' ) - extension[extlen++] = p[0]; - p++; - break; - } } extension[extlen] = 0; } @@ -913,31 +875,9 @@ void mangle_name_83( char *s) while( *p && baselen < 5 ) { - skip = get_character_len(*p); - switch( skip ) - { - case 2: - if( baselen < 4 ) - { + if( /*isdoschar( *p ) &&*/ *p != '.' ) base[baselen++] = p[0]; - base[baselen++] = p[1]; - } - else - { - base[baselen++] = mangle( (unsigned char)*p ); - } - p += 2; - break; - case 1: - base[baselen++] = p[0]; p++; - break; - default: - if( isdoschar( *p ) && *p != '.' ) - base[baselen++] = p[0]; - p++; - break; - } } base[baselen] = 0; diff --git a/source3/smbd/message.c b/source3/smbd/message.c index bae9f6c906..a5726d44f8 100644 --- a/source3/smbd/message.c +++ b/source3/smbd/message.c @@ -66,7 +66,6 @@ static void msg_deliver(void) if(msgpos > 0) { msgbuf[msgpos] = '\0'; /* Ensure null terminated. */ - pstrcpy(msgbuf,dos_to_unix(msgbuf,False)); } for (i=0;i<msgpos;) { @@ -121,8 +120,8 @@ int reply_sends(connection_struct *conn, outsize = set_message(outbuf,0,0,True); p = smb_buf(inbuf)+1; - p += srvstr_pull(inbuf, msgfrom, p, sizeof(msgfrom), -1, STR_TERMINATE|STR_CONVERT) + 1; - p += srvstr_pull(inbuf, msgto, p, sizeof(msgto), -1, STR_TERMINATE|STR_CONVERT) + 1; + p += srvstr_pull(inbuf, msgfrom, p, sizeof(msgfrom), -1, STR_TERMINATE) + 1; + p += srvstr_pull(inbuf, msgto, p, sizeof(msgto), -1, STR_TERMINATE) + 1; msg = p; @@ -163,8 +162,8 @@ int reply_sendstrt(connection_struct *conn, msgpos = 0; p = smb_buf(inbuf)+1; - p += srvstr_pull(inbuf, msgfrom, p, sizeof(msgfrom), -1, STR_TERMINATE|STR_CONVERT) + 1; - p += srvstr_pull(inbuf, msgto, p, sizeof(msgto), -1, STR_TERMINATE|STR_CONVERT) + 1; + p += srvstr_pull(inbuf, msgfrom, p, sizeof(msgfrom), -1, STR_TERMINATE) + 1; + p += srvstr_pull(inbuf, msgto, p, sizeof(msgto), -1, STR_TERMINATE) + 1; DEBUG( 3, ( "SMBsendstrt (from %s to %s)\n", msgfrom, msgto ) ); diff --git a/source3/smbd/negprot.c b/source3/smbd/negprot.c index 11400af710..de6f5d789f 100644 --- a/source3/smbd/negprot.c +++ b/source3/smbd/negprot.c @@ -235,7 +235,7 @@ static int reply_nt1(char *outbuf) if (doencrypt) memcpy(p, cryptkey, 8); p += 8; p += srvstr_push(outbuf, p, global_myworkgroup, -1, - STR_UNICODE|STR_CONVERT|STR_TERMINATE|STR_NOALIGN); + STR_UNICODE|STR_TERMINATE|STR_NOALIGN); SSVAL(outbuf,smb_vwv17, p - q); /* length of challenge+domain strings */ set_message_end(outbuf, p); diff --git a/source3/smbd/noquotas.c b/source3/smbd/noquotas.c index 5c55bb47c8..a6951d97fc 100644 --- a/source3/smbd/noquotas.c +++ b/source3/smbd/noquotas.c @@ -25,7 +25,7 @@ * Needed for auto generation of proto.h. */ -BOOL disk_quotas(char *path,SMB_BIG_UINT *bsize,SMB_BIG_UINT *dfree,SMB_BIG_UINT *dsize) +BOOL disk_quotas(const char *path,SMB_BIG_UINT *bsize,SMB_BIG_UINT *dfree,SMB_BIG_UINT *dsize) { (*bsize) = 512; /* This value should be ignored */ diff --git a/source3/smbd/notify_kernel.c b/source3/smbd/notify_kernel.c index d7408c06b5..11a5592458 100644 --- a/source3/smbd/notify_kernel.c +++ b/source3/smbd/notify_kernel.c @@ -125,7 +125,7 @@ static void *kernel_register_notify(connection_struct *conn, char *path, uint32 int fd; unsigned long kernel_flags; - fd = dos_open(path, O_RDONLY, 0); + fd = conn->vfs_ops.open(conn, path, O_RDONLY, 0); if (fd == -1) { DEBUG(3,("Failed to open directory %s for change notify\n", path)); diff --git a/source3/smbd/nttrans.c b/source3/smbd/nttrans.c index f2b6ba7a80..ea37b14e5e 100644 --- a/source3/smbd/nttrans.c +++ b/source3/smbd/nttrans.c @@ -574,7 +574,7 @@ static int do_ntcreate_pipe_open(connection_struct *conn, int pnum = -1; char *p = NULL; - srvstr_pull(inbuf, fname, smb_buf(inbuf), sizeof(fname), -1, STR_TERMINATE|STR_CONVERT); + srvstr_pull(inbuf, fname, smb_buf(inbuf), sizeof(fname), -1, STR_TERMINATE); if ((ret = nt_open_pipe(fname, conn, inbuf, outbuf, &pnum)) != 0) return ret; @@ -682,7 +682,7 @@ int reply_ntcreate_and_X(connection_struct *conn, * Check to see if this is a mac fork of some kind. */ - srvstr_pull(inbuf, fname, smb_buf(inbuf), sizeof(fname), -1, STR_TERMINATE|STR_CONVERT); + srvstr_pull(inbuf, fname, smb_buf(inbuf), sizeof(fname), -1, STR_TERMINATE); if( strchr(fname, ':')) { SSVAL(outbuf, smb_flg2, SVAL(outbuf,smb_flg2) | FLAGS2_32_BIT_ERROR_CODES); @@ -710,10 +710,10 @@ int reply_ntcreate_and_X(connection_struct *conn, } srvstr_pull(inbuf, &fname[dir_name_len], smb_buf(inbuf), sizeof(fname)-dir_name_len, - -1, STR_TERMINATE|STR_CONVERT); + -1, STR_TERMINATE); } else { srvstr_pull(inbuf, fname, smb_buf(inbuf), sizeof(fname), - -1, STR_TERMINATE|STR_CONVERT); + -1, STR_TERMINATE); } /* @@ -971,7 +971,7 @@ static int do_nt_transact_create_pipe( connection_struct *conn, return(ERROR(ERRDOS,ERRbadaccess)); } - srvstr_pull(inbuf, fname, params+53, sizeof(fname), -1, STR_TERMINATE|STR_CONVERT); + srvstr_pull(inbuf, fname, params+53, sizeof(fname), -1, STR_TERMINATE); if ((ret = nt_open_pipe(fname, conn, inbuf, outbuf, &pnum)) != 0) return ret; @@ -1188,7 +1188,7 @@ static int call_nt_transact_create(connection_struct *conn, * Check to see if this is a mac fork of some kind. */ - srvstr_pull(inbuf, fname, params+53, sizeof(fname), -1, STR_TERMINATE|STR_CONVERT); + srvstr_pull(inbuf, fname, params+53, sizeof(fname), -1, STR_TERMINATE); if( strchr(fname, ':')) { SSVAL(outbuf, smb_flg2, SVAL(outbuf,smb_flg2) | FLAGS2_32_BIT_ERROR_CODES); @@ -1215,9 +1215,9 @@ static int call_nt_transact_create(connection_struct *conn, } srvstr_pull(inbuf, &fname[dir_name_len], params+53, sizeof(fname)-dir_name_len, - -1, STR_TERMINATE|STR_CONVERT); + -1, STR_TERMINATE); } else { - srvstr_pull(inbuf, fname, params+53, sizeof(fname), -1, STR_TERMINATE|STR_CONVERT); + srvstr_pull(inbuf, fname, params+53, sizeof(fname), -1, STR_TERMINATE); } /* @@ -1511,7 +1511,7 @@ static int call_nt_transact_rename(connection_struct *conn, int outsize = 0; CHECK_FSP(fsp, conn); - srvstr_pull(inbuf, new_name, params+4, sizeof(new_name), -1, STR_TERMINATE|STR_CONVERT); + srvstr_pull(inbuf, new_name, params+4, sizeof(new_name), -1, STR_TERMINATE); outsize = rename_internals(conn, inbuf, outbuf, fsp->fsp_name, new_name, replace_if_exists); diff --git a/source3/smbd/open.c b/source3/smbd/open.c index 8bfddd4c71..7c48e28138 100644 --- a/source3/smbd/open.c +++ b/source3/smbd/open.c @@ -38,14 +38,13 @@ static int fd_open(struct connection_struct *conn, char *fname, #ifdef O_NONBLOCK flags |= O_NONBLOCK; #endif - - fd = conn->vfs_ops.open(conn,dos_to_unix(fname,False),flags,mode); + fd = conn->vfs_ops.open(conn,fname,flags,mode); /* Fix for files ending in '.' */ if((fd == -1) && (errno == ENOENT) && (strchr(fname,'.')==NULL)) { pstrcat(fname,"."); - fd = conn->vfs_ops.open(conn,dos_to_unix(fname,False),flags,mode); + fd = conn->vfs_ops.open(conn,fname,flags,mode); } DEBUG(10,("fd_open: name %s, flags = 0%o mode = 0%o, fd = %d. %s\n", fname, @@ -199,13 +198,6 @@ static BOOL open_file(files_struct *fsp,connection_struct *conn, fsp->stat_open = False; fsp->directory_delete_on_close = False; fsp->conn = conn; - /* - * Note that the file name here is the *untranslated* name - * ie. it is still in the DOS codepage sent from the client. - * All use of this filename will pass though the sys_xxxx - * functions which will do the dos_to_unix translation before - * mapping into a UNIX filename. JRA. - */ string_set(&fsp->fsp_name,fname); fsp->wbmpx_ptr = NULL; fsp->wcp = NULL; /* Write cache pointer. */ @@ -923,13 +915,6 @@ files_struct *open_file_stat(connection_struct *conn, char *fname, fsp->stat_open = True; fsp->directory_delete_on_close = False; fsp->conn = conn; - /* - * Note that the file name here is the *untranslated* name - * ie. it is still in the DOS codepage sent from the client. - * All use of this filename will pass though the sys_xxxx - * functions which will do the dos_to_unix translation before - * mapping into a UNIX filename. JRA. - */ string_set(&fsp->fsp_name,fname); fsp->wbmpx_ptr = NULL; fsp->wcp = NULL; /* Write cache pointer. */ @@ -1094,13 +1079,6 @@ files_struct *open_directory(connection_struct *conn, char *fname, fsp->is_directory = True; fsp->directory_delete_on_close = False; fsp->conn = conn; - /* - * Note that the file name here is the *untranslated* name - * ie. it is still in the DOS codepage sent from the client. - * All use of this filename will pass though the sys_xxxx - * functions which will do the dos_to_unix translation before - * mapping into a UNIX filename. JRA. - */ string_set(&fsp->fsp_name,fname); fsp->wbmpx_ptr = NULL; diff --git a/source3/smbd/password.c b/source3/smbd/password.c index 0c720b6a29..8bcd17d326 100644 --- a/source3/smbd/password.c +++ b/source3/smbd/password.c @@ -946,7 +946,7 @@ static BOOL check_user_equiv(char *user, char *remote, char *equiv_file) int plus_allowed = 1; char *file_host; char *file_user; - char **lines = file_lines_load(equiv_file, NULL, False); + char **lines = file_lines_load(equiv_file, NULL); int i; DEBUG(5, ("check_user_equiv %s %s %s\n", user, remote, equiv_file)); diff --git a/source3/smbd/posix_acls.c b/source3/smbd/posix_acls.c index 4832184df7..db7e594a9e 100644 --- a/source3/smbd/posix_acls.c +++ b/source3/smbd/posix_acls.c @@ -1704,7 +1704,7 @@ static BOOL set_canon_ace_list(files_struct *fsp, canon_ace *the_ace, BOOL defau */ if(default_ace || fsp->is_directory || fsp->fd == -1) { - if (sys_acl_set_file(dos_to_unix(fsp->fsp_name,False), the_acl_type, the_acl) == -1) { + if (sys_acl_set_file(fsp->fsp_name, the_acl_type, the_acl) == -1) { DEBUG(0,("set_canon_ace_list: sys_acl_set_file type %s failed for file %s (%s).\n", the_acl_type == SMB_ACL_TYPE_DEFAULT ? "directory default" : "file", fsp->fsp_name, strerror(errno) )); @@ -1850,14 +1850,14 @@ size_t get_nt_acl(files_struct *fsp, SEC_DESC **ppdesc) * Get the ACL from the path. */ - posix_acl = sys_acl_get_file( dos_to_unix(fsp->fsp_name, False), SMB_ACL_TYPE_ACCESS); + posix_acl = sys_acl_get_file(fsp->fsp_name, SMB_ACL_TYPE_ACCESS); /* * If it's a directory get the default POSIX ACL. */ if(fsp->is_directory) - dir_acl = sys_acl_get_file( dos_to_unix(fsp->fsp_name, False), SMB_ACL_TYPE_DEFAULT); + dir_acl = sys_acl_get_file(fsp->fsp_name, SMB_ACL_TYPE_DEFAULT); } else { @@ -2115,7 +2115,7 @@ BOOL set_nt_acl(files_struct *fsp, uint32 security_info_sent, SEC_DESC *psd) * No default ACL - delete one if it exists. */ - if (sys_acl_delete_def_file(dos_to_unix(fsp->fsp_name,False)) == -1) { + if (sys_acl_delete_def_file(fsp->fsp_name) == -1) { DEBUG(3,("set_nt_acl: sys_acl_delete_def_file failed (%s)\n", strerror(errno))); free_canon_ace_list(file_ace_list); return False; @@ -2143,7 +2143,7 @@ BOOL set_nt_acl(files_struct *fsp, uint32 security_info_sent, SEC_DESC *psd) DEBUG(3,("set_nt_acl: chmod %s. perms = 0%o.\n", fsp->fsp_name, (unsigned int)posix_perms )); - if(conn->vfs_ops.chmod(conn,dos_to_unix(fsp->fsp_name, False), posix_perms) == -1) { + if(conn->vfs_ops.chmod(conn,fsp->fsp_name, posix_perms) == -1) { DEBUG(3,("set_nt_acl: chmod %s, 0%o failed. Error = %s.\n", fsp->fsp_name, (unsigned int)posix_perms, strerror(errno) )); free_canon_ace_list(file_ace_list); @@ -2229,7 +2229,7 @@ static int chmod_acl_internals( SMB_ACL_T posix_acl, mode_t mode) Note that name is in UNIX character set. ****************************************************************************/ -int chmod_acl(char *name, mode_t mode) +int chmod_acl(const char *name, mode_t mode) { SMB_ACL_T posix_acl = NULL; int ret = -1; diff --git a/source3/smbd/reply.c b/source3/smbd/reply.c index edcc3f4838..fe0f2862c6 100644 --- a/source3/smbd/reply.c +++ b/source3/smbd/reply.c @@ -178,7 +178,6 @@ static int connection_error(char *inbuf,char *outbuf,int ecode) int reply_tcon(connection_struct *conn, char *inbuf,char *outbuf, int dum_size, int dum_buffsize) { - BOOL doencrypt = SMBENCRYPT(); pstring service; pstring user; pstring password; @@ -194,9 +193,9 @@ int reply_tcon(connection_struct *conn, *service = *user = *password = *dev = 0; p = smb_buf(inbuf)+1; - p += srvstr_pull(inbuf, service, p, sizeof(service), -1, STR_TERMINATE|STR_CONVERT) + 1; - p += srvstr_pull(inbuf, password, p, sizeof(password), -1, STR_TERMINATE|STR_CONVERT) + 1; - p += srvstr_pull(inbuf, dev, p, sizeof(dev), -1, STR_TERMINATE|STR_CONVERT) + 1; + p += srvstr_pull(inbuf, service, p, sizeof(service), -1, STR_TERMINATE) + 1; + p += srvstr_pull(inbuf, password, p, sizeof(password), -1, STR_TERMINATE) + 1; + p += srvstr_pull(inbuf, dev, p, sizeof(dev), -1, STR_TERMINATE) + 1; *user = 0; p = strchr(service,'%'); @@ -219,14 +218,6 @@ int reply_tcon(connection_struct *conn, } /* - * Ensure the user and password names are in UNIX codepage format. - */ - - pstrcpy(user,dos_to_unix(user,False)); - if (!doencrypt) - pstrcpy(password,dos_to_unix(password,False)); - - /* * Pass the user through the NT -> unix user mapping * function. */ @@ -289,7 +280,7 @@ int reply_tcon_and_X(connection_struct *conn, char *inbuf,char *outbuf,int lengt memcpy(password,smb_buf(inbuf),passlen); password[passlen]=0; p = smb_buf(inbuf) + passlen; - p += srvstr_pull(inbuf, path, p, sizeof(path), -1, STR_TERMINATE|STR_CONVERT); + p += srvstr_pull(inbuf, path, p, sizeof(path), -1, STR_TERMINATE); if (passlen != 24) { if (strequal(password," ")) @@ -308,7 +299,7 @@ int reply_tcon_and_X(connection_struct *conn, char *inbuf,char *outbuf,int lengt *q++ = 0; fstrcpy(user,q); } - p += srvstr_pull(inbuf, devicename, p, sizeof(devicename), 6, STR_CONVERT|STR_ASCII); + p += srvstr_pull(inbuf, devicename, p, sizeof(devicename), 6, STR_ASCII); DEBUG(4,("Got device type %s\n",devicename)); @@ -343,7 +334,7 @@ int reply_tcon_and_X(connection_struct *conn, char *inbuf,char *outbuf,int lengt set_message(outbuf,2,0,True); p = smb_buf(outbuf); p += srvstr_push(outbuf, p, devicename, -1, - STR_CONVERT|STR_TERMINATE|STR_ASCII); + STR_TERMINATE|STR_ASCII); set_message_end(outbuf,p); } else { /* NT sets the fstype of IPC$ to the null string */ @@ -353,9 +344,9 @@ int reply_tcon_and_X(connection_struct *conn, char *inbuf,char *outbuf,int lengt p = smb_buf(outbuf); p += srvstr_push(outbuf, p, devicename, -1, - STR_CONVERT|STR_TERMINATE|STR_ASCII); + STR_TERMINATE|STR_ASCII); p += srvstr_push(outbuf, p, fsname, -1, - STR_CONVERT|STR_TERMINATE); + STR_TERMINATE); set_message_end(outbuf,p); @@ -430,8 +421,8 @@ int reply_ioctl(connection_struct *conn, { case IOCTL_QUERY_JOB_INFO: SSVAL(p,0,fsp->print_jobid); /* Job number */ - srvstr_push(outbuf, p+2, global_myname, 15, STR_TERMINATE|STR_CONVERT|STR_ASCII); - srvstr_push(outbuf, p+18, lp_servicename(SNUM(conn)), 13, STR_TERMINATE|STR_CONVERT|STR_ASCII); + srvstr_push(outbuf, p+2, global_myname, 15, STR_TERMINATE|STR_ASCII); + srvstr_push(outbuf, p+18, lp_servicename(SNUM(conn)), 13, STR_TERMINATE|STR_ASCII); break; } @@ -731,9 +722,8 @@ int reply_sesssetup_and_X(connection_struct *conn, char *inbuf,char *outbuf,int return(ERROR(ERRDOS,ERRbuftoosmall)); } - memcpy(smb_apasswd,smb_buf(inbuf),smb_apasslen); - smb_apasswd[smb_apasslen] = 0; - srvstr_pull(inbuf, user, smb_buf(inbuf)+smb_apasslen, sizeof(user), -1, STR_TERMINATE|STR_CONVERT); + srvstr_pull(inbuf, smb_apasswd, smb_buf(inbuf), sizeof(smb_apasswd), smb_apasslen, 0); + srvstr_pull(inbuf, user, smb_buf(inbuf)+smb_apasslen, sizeof(user), -1, STR_TERMINATE); if (!doencrypt && (lp_security() != SEC_SERVER)) { smb_apasslen = strlen(smb_apasswd); @@ -814,23 +804,10 @@ int reply_sesssetup_and_X(connection_struct *conn, char *inbuf,char *outbuf,int smb_ntpasslen = passlen2; memcpy(smb_ntpasswd,p+passlen1,smb_ntpasslen); smb_ntpasswd[smb_ntpasslen] = 0; - - /* - * Ensure the plaintext passwords are in UNIX format. - */ - if(!doencrypt) { - pstrcpy(smb_apasswd,dos_to_unix(smb_apasswd,False)); - pstrcpy(smb_ntpasswd,dos_to_unix(smb_ntpasswd,False)); - } - } else { /* we use the first password that they gave */ smb_apasslen = passlen1; StrnCpy(smb_apasswd,p,smb_apasslen); - /* - * Ensure the plaintext password is in UNIX format. - */ - pstrcpy(smb_apasswd,dos_to_unix(smb_apasswd,False)); /* trim the password */ smb_apasslen = strlen(smb_apasswd); @@ -843,20 +820,27 @@ int reply_sesssetup_and_X(connection_struct *conn, char *inbuf,char *outbuf,int } p += passlen1 + passlen2; - p += srvstr_pull(inbuf, user, p, sizeof(user), -1, STR_CONVERT|STR_TERMINATE); + p += srvstr_pull(inbuf, user, p, sizeof(user), -1, + STR_TERMINATE); /* * Incoming user and domain are in DOS codepage format. Convert * to UNIX. */ p += srvstr_pull(inbuf, domain, p, sizeof(domain), - -1, STR_CONVERT|STR_TERMINATE); + -1, STR_TERMINATE); p += srvstr_pull(inbuf, native_os, p, sizeof(native_os), - -1, STR_CONVERT|STR_TERMINATE); + -1, STR_TERMINATE); p += srvstr_pull(inbuf, native_lanman, p, sizeof(native_lanman), - -1, STR_CONVERT|STR_TERMINATE); + -1, STR_TERMINATE); DEBUG(3,("Domain=[%s] NativeOS=[%s] NativeLanMan=[%s]\n", domain,native_os,native_lanman)); } + + /* don't allow for weird usernames */ + alpha_strcpy(user, user, ". _-", sizeof(user)); + if (strstr(user, "..")) { + return bad_password_error(inbuf, outbuf); + } /* don't allow for weird usernames */ alpha_strcpy(user, user, ". _-", sizeof(user)); @@ -923,7 +907,7 @@ int reply_sesssetup_and_X(connection_struct *conn, char *inbuf,char *outbuf,int /* Work out who's who */ slprintf(dom_user, sizeof(dom_user) - 1,"%s%s%s", - dos_to_unix(domain, False), lp_winbind_separator(), user); + domain, lp_winbind_separator(), user); if (sys_getpwnam(dom_user) != NULL) { pstrcpy(user, dom_user); @@ -1050,9 +1034,9 @@ int reply_sesssetup_and_X(connection_struct *conn, char *inbuf,char *outbuf,int char *p; set_message(outbuf,3,0,True); p = smb_buf(outbuf); - p += srvstr_push(outbuf, p, "Unix", -1, STR_TERMINATE|STR_CONVERT); - p += srvstr_push(outbuf, p, "Samba", -1, STR_TERMINATE|STR_CONVERT); - p += srvstr_push(outbuf, p, global_myworkgroup, -1, STR_TERMINATE|STR_CONVERT); + p += srvstr_push(outbuf, p, "Unix", -1, STR_TERMINATE); + p += srvstr_push(outbuf, p, "Samba", -1, STR_TERMINATE); + p += srvstr_push(outbuf, p, global_myworkgroup, -1, STR_TERMINATE); set_message_end(outbuf,p); /* perhaps grab OS version here?? */ } @@ -1544,7 +1528,7 @@ int reply_fclose(connection_struct *conn, char *inbuf,char *outbuf, int dum_size outsize = set_message(outbuf,1,0,True); p = smb_buf(inbuf) + 1; - p += srvstr_pull(inbuf, path, p, sizeof(path), -1, STR_TERMINATE|STR_CONVERT); + p += srvstr_pull(inbuf, path, p, sizeof(path), -1, STR_TERMINATE); p++; status_len = SVAL(p,0); p += 2; @@ -1886,7 +1870,7 @@ int reply_ctemp(connection_struct *conn, char *inbuf,char *outbuf, int dum_size, START_PROFILE(SMBctemp); createmode = SVAL(inbuf,smb_vwv0); - srvstr_pull(inbuf, fname, smb_buf(inbuf)+1, sizeof(fname), -1, STR_TERMINATE|STR_CONVERT); + srvstr_pull(inbuf, fname, smb_buf(inbuf)+1, sizeof(fname), -1, STR_TERMINATE); pstrcat(fname,"/TMXXXXXX"); RESOLVE_DFSPATH(fname, conn, inbuf, outbuf); @@ -1928,7 +1912,7 @@ int reply_ctemp(connection_struct *conn, char *inbuf,char *outbuf, int dum_size, SSVAL(outbuf,smb_vwv0,fsp->fnum); CVAL(smb_buf(outbuf),0) = 4; p = smb_buf(outbuf) + 1; - p += srvstr_push(outbuf, p, fname2, -1, STR_TERMINATE|STR_CONVERT); + p += srvstr_push(outbuf, p, fname2, -1, STR_TERMINATE); set_message_end(outbuf, p); if (oplock_request && lp_fake_oplocks(SNUM(conn))) { @@ -1957,7 +1941,7 @@ static BOOL can_delete(char *fname,connection_struct *conn, int dirtype) if (!CAN_WRITE(conn)) return(False); - if (conn->vfs_ops.lstat(conn,dos_to_unix(fname,False),&sbuf) != 0) return(False); + if (conn->vfs_ops.lstat(conn,fname,&sbuf) != 0) return(False); fmode = dos_mode(conn,fname,&sbuf); if (fmode & aDIR) return(False); if (!lp_delete_readonly(SNUM(conn))) { @@ -3333,7 +3317,7 @@ int reply_printqueue(connection_struct *conn, SSVAL(p,5, queue[i].job); SIVAL(p,7,queue[i].size); CVAL(p,11) = 0; - srvstr_push(outbuf, p+12, queue[i].user, 16, STR_CONVERT|STR_ASCII); + srvstr_push(outbuf, p+12, queue[i].user, 16, STR_ASCII); p += 28; } @@ -3472,7 +3456,7 @@ static BOOL recursive_rmdir(connection_struct *conn, char *directory) pstrcat(fullname, "/"); pstrcat(fullname, dname); - if(conn->vfs_ops.lstat(conn,dos_to_unix(fullname,False), &st) != 0) + if(conn->vfs_ops.lstat(conn,fullname, &st) != 0) { ret = True; break; @@ -3556,7 +3540,7 @@ BOOL rmdir_internals(connection_struct *conn, char *directory) pstrcat(fullname, "/"); pstrcat(fullname, dname); - if(conn->vfs_ops.lstat(conn,dos_to_unix(fullname, False), &st) != 0) + if(conn->vfs_ops.lstat(conn,fullname, &st) != 0) break; if(st.st_mode & S_IFDIR) { @@ -3707,7 +3691,7 @@ static BOOL can_rename(char *fname,connection_struct *conn) if (!CAN_WRITE(conn)) return(False); - if (conn->vfs_ops.lstat(conn,dos_to_unix(fname,False),&sbuf) != 0) return(False); + if (conn->vfs_ops.lstat(conn,fname,&sbuf) != 0) return(False); if (!check_file_sharing(conn,fname,True)) return(False); return(True); } @@ -3732,7 +3716,6 @@ int rename_internals(connection_struct *conn, BOOL exists=False; BOOL rc = True; SMB_STRUCT_STAT sbuf1, sbuf2; - pstring zdirectory; *directory = *mask = 0; @@ -3830,7 +3813,6 @@ int rename_internals(connection_struct *conn, } } - pstrcpy(zdirectory, dos_to_unix(directory, False)); if(replace_if_exists) { /* * NT SMB specific flag - rename can overwrite @@ -3840,15 +3822,13 @@ int rename_internals(connection_struct *conn, if(resolve_wildcards(directory,newname) && can_rename(directory,conn) && - !conn->vfs_ops.rename(conn,zdirectory, - dos_to_unix(newname,False))) + !conn->vfs_ops.rename(conn,directory,newname)) count++; } else { if (resolve_wildcards(directory,newname) && can_rename(directory,conn) && !vfs_file_exist(conn,newname,NULL) && - !conn->vfs_ops.rename(conn,zdirectory, - dos_to_unix(newname,False))) + !conn->vfs_ops.rename(conn,directory,newname)) count++; } @@ -3906,8 +3886,7 @@ int rename_internals(connection_struct *conn, continue; } - if (!conn->vfs_ops.rename(conn,dos_to_unix(fname,False), - dos_to_unix(destname,False))) + if (!conn->vfs_ops.rename(conn,fname,destname)) count++; DEBUG(3,("rename_internals: doing rename on %s -> %s\n",fname,destname)); } @@ -4228,7 +4207,7 @@ int reply_setdir(connection_struct *conn, char *inbuf,char *outbuf, int dum_size return(ERROR(ERRDOS,ERRnoaccess)); } - srvstr_pull(inbuf, newdir, smb_buf(inbuf) + 1, sizeof(newdir), -1, STR_TERMINATE|STR_CONVERT); + srvstr_pull(inbuf, newdir, smb_buf(inbuf) + 1, sizeof(newdir), -1, STR_TERMINATE); if (strlen(newdir) == 0) { ok = True; diff --git a/source3/smbd/server.c b/source3/smbd/server.c index 1dcf861a17..8d115d954c 100644 --- a/source3/smbd/server.c +++ b/source3/smbd/server.c @@ -635,8 +635,6 @@ static void usage(char *pname) setup_logging(argv[0],False); - charset_initialise(); - /* we want to re-seed early to prevent time delays causing client problems at a later date. (tridge) */ generate_random_buffer(NULL, 0, False); @@ -712,8 +710,6 @@ static void usage(char *pname) } #endif /* WITH_SSL */ - codepage_initialise(lp_client_code_page()); - fstrcpy(global_myworkgroup, lp_workgroup()); CatchSignal(SIGHUP,SIGNAL_CAST sig_hup); diff --git a/source3/smbd/service.c b/source3/smbd/service.c index 0e2c0ff7a1..836ef30f80 100644 --- a/source3/smbd/service.c +++ b/source3/smbd/service.c @@ -245,7 +245,6 @@ connection_struct *make_connection(char *service,char *user,char *password, int if (*user && Get_Pwnam(user,True)) { fstring dos_username; fstrcpy(dos_username, user); - unix_to_dos(dos_username, True); return(make_connection(dos_username,user,password, pwlen,dev,vuid,ecode)); } @@ -255,7 +254,6 @@ connection_struct *make_connection(char *service,char *user,char *password, int fstring dos_username; fstrcpy(user,validated_username(vuid)); fstrcpy(dos_username, user); - unix_to_dos(dos_username, True); return(make_connection(dos_username,user,password,pwlen,dev,vuid,ecode)); } } else { @@ -265,7 +263,6 @@ connection_struct *make_connection(char *service,char *user,char *password, int fstring dos_username; fstrcpy(user,current_user_info.smb_name); fstrcpy(dos_username, user); - unix_to_dos(dos_username, True); return(make_connection(dos_username,user,password,pwlen,dev,vuid,ecode)); } } diff --git a/source3/smbd/srvstr.c b/source3/smbd/srvstr.c index 0651fb725b..3c452653f2 100644 --- a/source3/smbd/srvstr.c +++ b/source3/smbd/srvstr.c @@ -19,150 +19,15 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ -#define NO_SYSLOG - #include "includes.h" -#define UNICODE_FLAG(buf, flags) (!(flags & STR_ASCII) && \ - ((flags & STR_UNICODE || \ - (SVAL(buf, smb_flg2) & FLAGS2_UNICODE_STRINGS)))) - -/**************************************************************************** -return an alignment of either 0 or 1 -if unicode is not negotiated then return 0 -otherwise return 1 if offset is off -****************************************************************************/ -static int srvstr_align(void *inbuf, int offset, int flags) -{ - if ((flags & STR_NOALIGN) || !UNICODE_FLAG(inbuf, flags)) return 0; - return offset & 1; -} - -/**************************************************************************** -copy a string from a char* src to a unicode or ascii -dos code page destination choosing unicode or ascii based on the -FLAGS2_UNICODE_STRINGS bit in inbuf -return the number of bytes occupied by the string in the destination -flags can have: - STR_TERMINATE means include the null termination - STR_CONVERT means convert from unix to dos codepage - STR_UPPER means uppercase in the destination - STR_ASCII use ascii even with unicode servers - STR_UNICODE means to force as unicode - STR_NOALIGN means don't do alignment -dest_len is the maximum length allowed in the destination. If dest_len -is -1 then no maxiumum is used -****************************************************************************/ -int srvstr_push(void *outbuf, void *dest, const char *src, int dest_len, int flags) -{ - int len=0; - - /* treat a pstring as "unlimited" length */ - if (dest_len == -1) { - dest_len = sizeof(pstring); - } - - if (srvstr_align(outbuf, PTR_DIFF(dest, outbuf), flags)) { - *(char *)dest = 0; - dest = (void *)((char *)dest + 1); - dest_len--; - len++; - } - - if (!UNICODE_FLAG(outbuf, flags)) { - /* the client doesn't want unicode */ - safe_strcpy(dest, src, dest_len); - len = strlen(dest); - if (flags & STR_TERMINATE) len++; - if (flags & STR_CONVERT) unix_to_dos(dest,True); - if (flags & STR_UPPER) strupper(dest); - return len; - } - - /* the server likes unicode. give it the works */ - if (flags & STR_CONVERT) { - dos_PutUniCode(dest, src, dest_len, flags & STR_TERMINATE); - } else { - ascii_to_unistr(dest, src, dest_len); - } - if (flags & STR_UPPER) { - strupper_w(dest); - } - len += strlen(src)*2; - if (flags & STR_TERMINATE) len += 2; - return len; -} - -/**************************************************************************** -copy a string from a unicode or ascii source (depending on flg2) -to a char* destination -flags can have: - STR_CONVERT means convert from dos to unix codepage - STR_TERMINATE means the string in src is null terminated - STR_UNICODE means to force as unicode - STR_NOALIGN means don't do alignment -if STR_TERMINATE is set then src_len is ignored -src_len is the length of the source area in bytes -return the number of bytes occupied by the string in src -****************************************************************************/ -int srvstr_pull(void *inbuf, char *dest, const void *src, int dest_len, int src_len, int flags) -{ - int len; - - if (dest_len == -1) { - dest_len = sizeof(pstring); - } - - if (srvstr_align(inbuf, PTR_DIFF(src, inbuf), flags)) { - src = (void *)((char *)src + 1); - if (src_len > 0) src_len--; - } - - if (!UNICODE_FLAG(inbuf, flags)) { - /* the server doesn't want unicode */ - if (flags & STR_TERMINATE) { - safe_strcpy(dest, src, dest_len); - len = strlen(src)+1; - } else { - if (src_len > dest_len) src_len = dest_len; - len = src_len; - memcpy(dest, src, len); - dest[len] = 0; - } - if (flags & STR_CONVERT) dos_to_unix(dest,True); - return len; - } - - if (flags & STR_TERMINATE) { - unistr_to_ascii(dest, src, dest_len); - len = strlen(dest)*2 + 2; - } else { - int i, c; - if (dest_len*2 < src_len) src_len = 2*dest_len; - for (i=0; i < src_len; i += 2) { - c = SVAL(src, i); - *dest++ = c; - } - *dest++ = 0; - len = src_len; - } - if (flags & STR_CONVERT) dos_to_unix(dest,True); - return len; -} - -/**************************************************************************** -these are useful for replacing all those StrnCpy() ops for copying data -to/from the wire -****************************************************************************/ - -int srvstr_push_ascii(void *dest, const char *src, int dest_len) +int srvstr_push(void *base_ptr, void *dest, const char *src, int dest_len, int flags) { - return srvstr_push(NULL, dest, src, dest_len, - STR_ASCII|STR_CONVERT|STR_TERMINATE); + return push_string(base_ptr, dest, src, dest_len, flags); } -int srvstr_pull_ascii(char *dest, const void *src, int dest_len) +int srvstr_pull(void *base_ptr, char *dest, const void *src, int dest_len, int src_len, + int flags) { - return srvstr_pull(NULL, dest, src, dest_len, -1, - STR_ASCII|STR_CONVERT|STR_TERMINATE); + return pull_string(base_ptr, dest, src, dest_len, src_len, flags); } diff --git a/source3/smbd/trans2.c b/source3/smbd/trans2.c index f94b24f595..f768a72c6d 100644 --- a/source3/smbd/trans2.c +++ b/source3/smbd/trans2.c @@ -471,8 +471,7 @@ static BOOL get_lanman2_dir_entry(connection_struct *conn, SSVAL(p,l1_attrFile,mode); p += l1_achName; nameptr = p; - len = srvstr_push(outbuf, p, fname, -1, - STR_TERMINATE|STR_CONVERT); + len = srvstr_push(outbuf, p, fname, -1, STR_TERMINATE); SCVAL(p, -1, len); p += len; break; @@ -493,7 +492,7 @@ static BOOL get_lanman2_dir_entry(connection_struct *conn, p += l2_achName; nameptr = p; len = srvstr_push(outbuf, p, fname, -1, - STR_TERMINATE|STR_CONVERT); + STR_TERMINATE); SCVAL(p, -1, len); p += len; break; @@ -509,8 +508,7 @@ static BOOL get_lanman2_dir_entry(connection_struct *conn, SIVAL(p,26,4); p += 31; nameptr = p; - len = srvstr_push(outbuf, p, fname, -1, - STR_TERMINATE|STR_CONVERT); + len = srvstr_push(outbuf, p, fname, -1, STR_TERMINATE); SCVAL(p, -1, len); p += len; break; @@ -529,8 +527,7 @@ static BOOL get_lanman2_dir_entry(connection_struct *conn, SSVAL(p,24,mode); p += 33; nameptr = p; - len = srvstr_push(outbuf, p, fname, -1, - STR_TERMINATE|STR_CONVERT); + len = srvstr_push(outbuf, p, fname, -1, STR_TERMINATE); SCVAL(p, -1, len); p += len; SIVAL(q,4,PTR_DIFF(p, q)); @@ -556,16 +553,14 @@ static BOOL get_lanman2_dir_entry(connection_struct *conn, pstrcpy(mangled_name, fname); name_map_mangle(mangled_name,True,True,SNUM(conn)); mangled_name[12] = 0; - len = srvstr_push(outbuf, p+2, mangled_name, 24, - STR_CONVERT|STR_UPPER); + len = srvstr_push(outbuf, p+2, mangled_name, 24, STR_UPPER); SSVAL(p, 0, len); } else { SSVAL(p,0,0); *(p+2) = 0; } p += 2 + 24; - len = srvstr_push(outbuf, p, fname, -1, - STR_TERMINATE|STR_CONVERT); + len = srvstr_push(outbuf, p, fname, -1, STR_TERMINATE); SIVAL(q,0,len); p += len; len = PTR_DIFF(p, pdata); @@ -586,8 +581,7 @@ static BOOL get_lanman2_dir_entry(connection_struct *conn, p += 16; SIVAL(p,0,nt_extmode); p += 4; p += 4; - len = srvstr_push(outbuf, p, fname, -1, - STR_TERMINATE|STR_CONVERT); + len = srvstr_push(outbuf, p, fname, -1, STR_TERMINATE); SIVAL(p, -4, len); p += len; len = PTR_DIFF(p, pdata); @@ -611,8 +605,7 @@ static BOOL get_lanman2_dir_entry(connection_struct *conn, p += 4; SIVAL(p,0,0); p += 4; - len = srvstr_push(outbuf, p, fname, -1, - STR_TERMINATE|STR_CONVERT); + len = srvstr_push(outbuf, p, fname, -1, STR_TERMINATE); SIVAL(p, -4, len); p += len; @@ -626,8 +619,7 @@ static BOOL get_lanman2_dir_entry(connection_struct *conn, p += 4; SIVAL(p,0,reskey); p += 4; p += 4; - len = srvstr_push(outbuf, p, fname, -1, - STR_TERMINATE|STR_CONVERT); + len = srvstr_push(outbuf, p, fname, -1, STR_TERMINATE); SIVAL(p, -4, len); p += len; len = PTR_DIFF(p, pdata); @@ -923,7 +915,7 @@ static int call_trans2findnext(connection_struct *conn, *mask = *directory = *resume_name = 0; - srvstr_pull(inbuf, resume_name, params+12, sizeof(resume_name), -1, STR_TERMINATE|STR_CONVERT); + srvstr_pull(inbuf, resume_name, params+12, sizeof(resume_name), -1, STR_TERMINATE); DEBUG(3,("call_trans2findnext: dirhandle = %d, max_data_bytes = %d, maxentries = %d, \ close_after_request=%d, close_if_end = %d requires_resume_key = %d \ @@ -1194,7 +1186,7 @@ static int call_trans2qfsinfo(connection_struct *conn, */ SIVAL(pdata,0,str_checksum(lp_servicename(snum)) ^ (str_checksum(local_machine)<<16) ); len = srvstr_push(outbuf, pdata+l2_vol_szVolLabel, vname, -1, - STR_TERMINATE|STR_CONVERT); + STR_TERMINATE); SCVAL(pdata,l2_vol_cch,len); data_len = l2_vol_szVolLabel + len; DEBUG(5,("call_trans2qfsinfo : time = %x, namelen = %d, name = %s\n", @@ -1206,13 +1198,13 @@ static int call_trans2qfsinfo(connection_struct *conn, FILE_DEVICE_IS_MOUNTED| (lp_nt_acl_support() ? FILE_PERSISTENT_ACLS : 0)); /* FS ATTRIBUTES */ SIVAL(pdata,4,255); /* Max filename component length */ - len = srvstr_push(outbuf, pdata+12, fstype, -1, STR_TERMINATE|STR_CONVERT); + len = srvstr_push(outbuf, pdata+12, fstype, -1, STR_TERMINATE); SIVAL(pdata,8,len); data_len = 12 + len; break; case SMB_QUERY_FS_LABEL_INFO: - len = srvstr_push(outbuf, pdata+4, vname, -1, STR_TERMINATE|STR_CONVERT); + len = srvstr_push(outbuf, pdata+4, vname, -1, STR_TERMINATE); data_len = 4 + len; SIVAL(pdata,0,len); break; @@ -1224,7 +1216,7 @@ static int call_trans2qfsinfo(connection_struct *conn, SIVAL(pdata,8,str_checksum(lp_servicename(snum)) ^ (str_checksum(local_machine)<<16)); - len = srvstr_push(outbuf, pdata+18, vname, -1, STR_TERMINATE|STR_CONVERT); + len = srvstr_push(outbuf, pdata+18, vname, -1, STR_TERMINATE); SIVAL(pdata,12,len); data_len = 18+len; DEBUG(5,("call_trans2qfsinfo : SMB_QUERY_FS_VOLUME_INFO namelen = %d, vol=%s serv=%s\n", @@ -1517,7 +1509,7 @@ static int call_trans2qfilepathinfo(connection_struct *conn, *short_name = '\0'; } len = srvstr_push(outbuf, pdata+4, short_name, -1, - STR_TERMINATE|STR_CONVERT|STR_UPPER); + STR_TERMINATE|STR_UPPER); data_size = 4 + len; SIVAL(pdata,0,len); } @@ -1531,9 +1523,9 @@ static int call_trans2qfilepathinfo(connection_struct *conn, * you like hearing about me suffering.... :-). JRA. */ if(strequal(".", fname)) { - len = srvstr_push(outbuf, pdata+4, "\\", -1, STR_TERMINATE|STR_CONVERT); + len = srvstr_push(outbuf, pdata+4, "\\", -1, STR_TERMINATE); } else { - len = srvstr_push(outbuf, pdata+4, fname, -1, STR_TERMINATE|STR_CONVERT); + len = srvstr_push(outbuf, pdata+4, fname, -1, STR_TERMINATE); } data_size = 4 + len; SIVAL(pdata,0,len); @@ -1571,7 +1563,7 @@ static int call_trans2qfilepathinfo(connection_struct *conn, SIVAL(pdata,0,mode); /* is this the right sort of mode info? */ pdata += 4; pdata += 4; /* alignment */ - len = srvstr_push(outbuf, pdata+4, fname, -1, STR_TERMINATE|STR_CONVERT); + len = srvstr_push(outbuf, pdata+4, fname, -1, STR_TERMINATE); SIVAL(pdata,0,len); pdata += 4 + len; data_size = PTR_DIFF(pdata,(*ppdata)); @@ -1722,7 +1714,7 @@ static int call_trans2qfilepathinfo(connection_struct *conn, SIVAL(pdata,0,pos); SIVAL(pdata,4,size); SIVAL(pdata,12,size); - len = srvstr_push(outbuf, pdata+24, fname, -1, STR_TERMINATE|STR_CONVERT); + len = srvstr_push(outbuf, pdata+24, fname, -1, STR_TERMINATE); SIVAL(pdata,20,len); data_size = 24 + len; break; @@ -2294,7 +2286,7 @@ static int call_trans2getdfsreferral(connection_struct *conn, char* inbuf, if(!lp_host_msdfs()) return(ERROR(ERRDOS,ERRbadfunc)); - srvstr_pull(inbuf, pathname, ¶ms[2], sizeof(pathname), -1, STR_TERMINATE|STR_CONVERT); + srvstr_pull(inbuf, pathname, ¶ms[2], sizeof(pathname), -1, STR_TERMINATE); if((reply_size = setup_dfs_referral(pathname,max_referral_level,ppdata)) < 0) return(ERROR(ERRDOS,ERRbadfile)); @@ -2331,8 +2323,8 @@ static int call_trans2ioctl(connection_struct *conn, char* inbuf, CAN ACCEPT THIS IN UNICODE. JRA. */ SSVAL(pdata,0,fsp->print_jobid); /* Job number */ - srvstr_push( outbuf, pdata + 2, global_myname, 15, STR_CONVERT|STR_ASCII|STR_TERMINATE); /* Our NetBIOS name */ - srvstr_push( outbuf, pdata+18, lp_servicename(SNUM(conn)), 13, STR_CONVERT|STR_ASCII|STR_TERMINATE); /* Service name */ + srvstr_push( outbuf, pdata + 2, global_myname, 15, STR_ASCII|STR_TERMINATE); /* Our NetBIOS name */ + srvstr_push( outbuf, pdata+18, lp_servicename(SNUM(conn)), 13, STR_ASCII|STR_TERMINATE); /* Service name */ send_trans2_replies(outbuf,bufsize,*pparams,0,*ppdata,32); return(-1); } else { diff --git a/source3/smbd/vfs-wrap.c b/source3/smbd/vfs-wrap.c index a0b4966c59..241216e9d7 100644 --- a/source3/smbd/vfs-wrap.c +++ b/source3/smbd/vfs-wrap.c @@ -29,7 +29,7 @@ is sure to try and execute them. These stubs are used to prevent this possibility. */ -int vfswrap_dummy_connect(connection_struct *conn, char *service, char *user) +int vfswrap_dummy_connect(connection_struct *conn, const char *service, const char *user) { return 0; /* Return >= 0 for success */ } @@ -40,7 +40,7 @@ void vfswrap_dummy_disconnect(connection_struct *conn) /* Disk operations */ -SMB_BIG_UINT vfswrap_disk_free(connection_struct *conn, char *path, BOOL small_query, SMB_BIG_UINT *bsize, +SMB_BIG_UINT vfswrap_disk_free(connection_struct *conn, const char *path, BOOL small_query, SMB_BIG_UINT *bsize, SMB_BIG_UINT *dfree, SMB_BIG_UINT *dsize) { SMB_BIG_UINT result; @@ -59,7 +59,7 @@ SMB_BIG_UINT vfswrap_disk_free(connection_struct *conn, char *path, BOOL small_q /* Directory operations */ -DIR *vfswrap_opendir(connection_struct *conn, char *fname) +DIR *vfswrap_opendir(connection_struct *conn, const char *fname) { DIR *result; @@ -93,7 +93,7 @@ struct dirent *vfswrap_readdir(connection_struct *conn, DIR *dirp) return result; } -int vfswrap_mkdir(connection_struct *conn, char *path, mode_t mode) +int vfswrap_mkdir(connection_struct *conn, const char *path, mode_t mode) { int result; @@ -126,7 +126,7 @@ int vfswrap_mkdir(connection_struct *conn, char *path, mode_t mode) return result; } -int vfswrap_rmdir(connection_struct *conn, char *path) +int vfswrap_rmdir(connection_struct *conn, const char *path) { int result; @@ -162,7 +162,7 @@ int vfswrap_closedir(connection_struct *conn, DIR *dirp) /* File operations */ -int vfswrap_open(connection_struct *conn, char *fname, int flags, mode_t mode) +int vfswrap_open(connection_struct *conn, const char *fname, int flags, mode_t mode) { int result; @@ -207,7 +207,7 @@ ssize_t vfswrap_read(files_struct *fsp, int fd, char *data, size_t n) return result; } -ssize_t vfswrap_write(files_struct *fsp, int fd, char *data, size_t n) +ssize_t vfswrap_write(files_struct *fsp, int fd, const char *data, size_t n) { ssize_t result; @@ -235,7 +235,7 @@ SMB_OFF_T vfswrap_lseek(files_struct *fsp, int filedes, SMB_OFF_T offset, int wh return result; } -int vfswrap_rename(connection_struct *conn, char *old, char *new) +int vfswrap_rename(connection_struct *conn, const char *old, const char *new) { int result; @@ -267,7 +267,7 @@ int vfswrap_fsync(files_struct *fsp, int fd) #endif } -int vfswrap_stat(connection_struct *conn, char *fname, SMB_STRUCT_STAT *sbuf) +int vfswrap_stat(connection_struct *conn, const char *fname, SMB_STRUCT_STAT *sbuf) { int result; @@ -301,7 +301,7 @@ int vfswrap_fstat(files_struct *fsp, int fd, SMB_STRUCT_STAT *sbuf) return result; } -int vfswrap_lstat(connection_struct *conn, char *path, SMB_STRUCT_STAT *sbuf) +int vfswrap_lstat(connection_struct *conn, const char *path, SMB_STRUCT_STAT *sbuf) { int result; @@ -318,7 +318,7 @@ int vfswrap_lstat(connection_struct *conn, char *path, SMB_STRUCT_STAT *sbuf) return result; } -int vfswrap_unlink(connection_struct *conn, char *path) +int vfswrap_unlink(connection_struct *conn, const char *path) { int result; @@ -335,7 +335,7 @@ int vfswrap_unlink(connection_struct *conn, char *path) return result; } -int vfswrap_chmod(connection_struct *conn, char *path, mode_t mode) +int vfswrap_chmod(connection_struct *conn, const char *path, mode_t mode) { int result; @@ -397,7 +397,7 @@ int vfswrap_fchmod(files_struct *fsp, int fd, mode_t mode) return result; } -int vfswrap_chown(connection_struct *conn, char *path, uid_t uid, gid_t gid) +int vfswrap_chown(connection_struct *conn, const char *path, uid_t uid, gid_t gid) { int result; @@ -425,7 +425,7 @@ int vfswrap_fchown(files_struct *fsp, int fd, uid_t uid, gid_t gid) return result; } -int vfswrap_chdir(connection_struct *conn, char *path) +int vfswrap_chdir(connection_struct *conn, const char *path) { int result; @@ -459,7 +459,7 @@ char *vfswrap_getwd(connection_struct *conn, char *path) return result; } -int vfswrap_utime(connection_struct *conn, char *path, struct utimbuf *times) +int vfswrap_utime(connection_struct *conn, const char *path, struct utimbuf *times) { int result; @@ -595,7 +595,7 @@ size_t vfswrap_fget_nt_acl(files_struct *fsp, int fd, SEC_DESC **ppdesc) return get_nt_acl(fsp, ppdesc); } -size_t vfswrap_get_nt_acl(files_struct *fsp, char *name, SEC_DESC **ppdesc) +size_t vfswrap_get_nt_acl(files_struct *fsp, const char *name, SEC_DESC **ppdesc) { return get_nt_acl(fsp, ppdesc); } @@ -605,12 +605,12 @@ BOOL vfswrap_fset_nt_acl(files_struct *fsp, int fd, uint32 security_info_sent, S return set_nt_acl(fsp, security_info_sent, psd); } -BOOL vfswrap_set_nt_acl(files_struct *fsp, char *name, uint32 security_info_sent, SEC_DESC *psd) +BOOL vfswrap_set_nt_acl(files_struct *fsp, const char *name, uint32 security_info_sent, SEC_DESC *psd) { return set_nt_acl(fsp, security_info_sent, psd); } -int vfswrap_chmod_acl(connection_struct *conn, char *name, mode_t mode) +int vfswrap_chmod_acl(connection_struct *conn, const char *name, mode_t mode) { return chmod_acl(name, mode); } diff --git a/source3/smbd/vfs.c b/source3/smbd/vfs.c index ac00d00e9e..747d393386 100644 --- a/source3/smbd/vfs.c +++ b/source3/smbd/vfs.c @@ -1,6 +1,6 @@ /* Unix SMB/Netbios implementation. - Version 1.9. + Version 3.0 VFS initialisation and support functions Copyright (C) Tim Potter 1999 @@ -109,156 +109,46 @@ static BOOL vfs_init_default(connection_struct *conn) static BOOL vfs_init_custom(connection_struct *conn) { int vfs_version = -1; - struct vfs_ops *ops, *(*init_fptr)(int *); + struct vfs_ops *ops, *(*init_fptr)(int *, struct vfs_ops *); - DEBUG(3, ("Initialising custom vfs hooks from %s\n", - lp_vfsobj(SNUM(conn)))); - - /* Open object file */ + DEBUG(3, ("Initialising custom vfs hooks from %s\n", + lp_vfsobj(SNUM(conn)))); - if ((conn->dl_handle = sys_dlopen(lp_vfsobj(SNUM(conn)), RTLD_NOW | RTLD_GLOBAL)) == NULL) { + /* Open object file */ + if ((conn->dl_handle = sys_dlopen(lp_vfsobj(SNUM(conn)), + RTLD_NOW | RTLD_GLOBAL)) == NULL) { DEBUG(0, ("Error opening %s: %s\n", lp_vfsobj(SNUM(conn)), dlerror())); return False; - } - - /* Get handle on vfs_init() symbol */ + } - init_fptr = (struct vfs_ops *(*)(int *))sys_dlsym(conn->dl_handle, "vfs_init"); + /* Get handle on vfs_init() symbol */ + init_fptr = (struct vfs_ops *(*)(int *, struct vfs_ops *))sys_dlsym(conn->dl_handle, "vfs_init"); - if (init_fptr == NULL) { + if (init_fptr == NULL) { DEBUG(0, ("No vfs_init() symbol found in %s\n", - lp_vfsobj(SNUM(conn)))); + lp_vfsobj(SNUM(conn)))); return False; - } + } - /* Initialise vfs_ops structure */ + /* Initialise vfs_ops structure */ + conn->vfs_ops = default_vfs_ops; - if ((ops = init_fptr(&vfs_version)) == NULL) { - DEBUG(0, ("vfs_init function from %s failed\n", lp_vfsobj(SNUM(conn)))); + if ((ops = init_fptr(&vfs_version, &conn->vfs_ops)) == NULL) { + DEBUG(0, ("vfs_init function from %s failed\n", lp_vfsobj(SNUM(conn)))); return False; - } - + } + if (vfs_version != SMB_VFS_INTERFACE_VERSION) { DEBUG(0, ("vfs_init returned wrong interface version info (was %d, should be %d)\n", - vfs_version, SMB_VFS_INTERFACE_VERSION )); + vfs_version, SMB_VFS_INTERFACE_VERSION )); return False; } + + if (ops != &conn->vfs_ops) { + memcpy(&conn->vfs_ops, ops, sizeof(struct vfs_ops)); + } - /* Fill in unused operations with default (disk based) ones. - There's probably a neater way to do this then a whole bunch of - if statements. */ - - memcpy(&conn->vfs_ops, ops, sizeof(struct vfs_ops)); - - if (conn->vfs_ops.connect == NULL) - conn->vfs_ops.connect = default_vfs_ops.connect; - - if (conn->vfs_ops.disconnect == NULL) - conn->vfs_ops.disconnect = default_vfs_ops.disconnect; - - if (conn->vfs_ops.disk_free == NULL) - conn->vfs_ops.disk_free = default_vfs_ops.disk_free; - - if (conn->vfs_ops.opendir == NULL) - conn->vfs_ops.opendir = default_vfs_ops.opendir; - - if (conn->vfs_ops.readdir == NULL) - conn->vfs_ops.readdir = default_vfs_ops.readdir; - - if (conn->vfs_ops.mkdir == NULL) - conn->vfs_ops.mkdir = default_vfs_ops.mkdir; - - if (conn->vfs_ops.rmdir == NULL) - conn->vfs_ops.rmdir = default_vfs_ops.rmdir; - - if (conn->vfs_ops.closedir == NULL) - conn->vfs_ops.closedir = default_vfs_ops.closedir; - - if (conn->vfs_ops.open == NULL) - conn->vfs_ops.open = default_vfs_ops.open; - - if (conn->vfs_ops.close == NULL) - conn->vfs_ops.close = default_vfs_ops.close; - - if (conn->vfs_ops.read == NULL) - conn->vfs_ops.read = default_vfs_ops.read; - - if (conn->vfs_ops.write == NULL) - conn->vfs_ops.write = default_vfs_ops.write; - - if (conn->vfs_ops.lseek == NULL) - conn->vfs_ops.lseek = default_vfs_ops.lseek; - - if (conn->vfs_ops.rename == NULL) - conn->vfs_ops.rename = default_vfs_ops.rename; - - if (conn->vfs_ops.fsync == NULL) - conn->vfs_ops.fsync = default_vfs_ops.fsync; - - if (conn->vfs_ops.stat == NULL) - conn->vfs_ops.stat = default_vfs_ops.stat; - - if (conn->vfs_ops.fstat == NULL) - conn->vfs_ops.fstat = default_vfs_ops.fstat; - - if (conn->vfs_ops.lstat == NULL) - conn->vfs_ops.lstat = default_vfs_ops.lstat; - - if (conn->vfs_ops.unlink == NULL) - conn->vfs_ops.unlink = default_vfs_ops.unlink; - - if (conn->vfs_ops.chmod == NULL) - conn->vfs_ops.chmod = default_vfs_ops.chmod; - - if (conn->vfs_ops.fchmod == NULL) - conn->vfs_ops.fchmod = default_vfs_ops.fchmod; - - if (conn->vfs_ops.chown == NULL) - conn->vfs_ops.chown = default_vfs_ops.chown; - - if (conn->vfs_ops.fchown == NULL) - conn->vfs_ops.fchown = default_vfs_ops.fchown; - - if (conn->vfs_ops.chdir == NULL) - conn->vfs_ops.chdir = default_vfs_ops.chdir; - - if (conn->vfs_ops.getwd == NULL) - conn->vfs_ops.getwd = default_vfs_ops.getwd; - - if (conn->vfs_ops.utime == NULL) - conn->vfs_ops.utime = default_vfs_ops.utime; - - if (conn->vfs_ops.ftruncate == NULL) - conn->vfs_ops.ftruncate = default_vfs_ops.ftruncate; - - if (conn->vfs_ops.lock == NULL) - conn->vfs_ops.lock = default_vfs_ops.lock; - - if (conn->vfs_ops.symlink == NULL) - conn->vfs_ops.symlink = default_vfs_ops.symlink; - - if (conn->vfs_ops.readlink == NULL) - conn->vfs_ops.readlink = default_vfs_ops.readlink; - - if (conn->vfs_ops.fget_nt_acl == NULL) - conn->vfs_ops.fget_nt_acl = default_vfs_ops.fget_nt_acl; - - if (conn->vfs_ops.get_nt_acl == NULL) - conn->vfs_ops.get_nt_acl = default_vfs_ops.get_nt_acl; - - if (conn->vfs_ops.fset_nt_acl == NULL) - conn->vfs_ops.fset_nt_acl = default_vfs_ops.fset_nt_acl; - - if (conn->vfs_ops.set_nt_acl == NULL) - conn->vfs_ops.set_nt_acl = default_vfs_ops.set_nt_acl; - - if (conn->vfs_ops.chmod_acl == NULL) - conn->vfs_ops.chmod_acl = default_vfs_ops.chmod_acl; - - if (conn->vfs_ops.fchmod_acl == NULL) - conn->vfs_ops.fchmod_acl = default_vfs_ops.fchmod_acl; - - return True; + return True; } #endif @@ -294,7 +184,7 @@ BOOL vfs_init(connection_struct *conn) Check if directory exists. ********************************************************************/ -BOOL vfs_directory_exist(connection_struct *conn, char *dname, SMB_STRUCT_STAT *st) +BOOL vfs_directory_exist(connection_struct *conn, const char *dname, SMB_STRUCT_STAT *st) { SMB_STRUCT_STAT st2; BOOL ret; @@ -309,20 +199,26 @@ BOOL vfs_directory_exist(connection_struct *conn, char *dname, SMB_STRUCT_STAT * if(!ret) errno = ENOTDIR; - return ret; + return ret; } /******************************************************************* - vfs mkdir wrapper that calls dos_to_unix. + vfs getwd wrapper ********************************************************************/ +char *vfs_getwd(connection_struct *conn, char *path) +{ + return conn->vfs_ops.getwd(conn,path); +} -int vfs_mkdir(connection_struct *conn, char *fname, mode_t mode) +/******************************************************************* + vfs mkdir wrapper +********************************************************************/ + +int vfs_mkdir(connection_struct *conn, const char *name, mode_t mode) { int ret; - pstring name; SMB_STRUCT_STAT sbuf; - pstrcpy(name,dos_to_unix(fname,False)); /* paranoia copy */ if(!(ret=conn->vfs_ops.mkdir(conn,name,mode))) { /* * Check if high bits should have been set, @@ -337,23 +233,10 @@ int vfs_mkdir(connection_struct *conn, char *fname, mode_t mode) } /******************************************************************* - vfs getwd wrapper that calls dos_to_unix. -********************************************************************/ - -char *vfs_getwd(connection_struct *conn, char *unix_path) -{ - char *wd; - wd = conn->vfs_ops.getwd(conn,unix_path); - if (wd) - unix_to_dos(wd, True); - return wd; -} - -/******************************************************************* Check if a vfs file exists. ********************************************************************/ -BOOL vfs_file_exist(connection_struct *conn,char *fname,SMB_STRUCT_STAT *sbuf) +BOOL vfs_file_exist(connection_struct *conn,const char *fname,SMB_STRUCT_STAT *sbuf) { SMB_STRUCT_STAT st; @@ -397,7 +280,7 @@ ssize_t vfs_read_data(files_struct *fsp, char *buf, size_t byte_count) Write data to a fd on the vfs. ****************************************************************************/ -ssize_t vfs_write_data(files_struct *fsp,char *buffer,size_t N) +ssize_t vfs_write_data(files_struct *fsp,const char *buffer,size_t N) { size_t total=0; ssize_t ret; @@ -549,13 +432,6 @@ char *vfs_readdirname(connection_struct *conn, void *p) dname = dname - 2; #endif - { - static pstring buf; - memcpy(buf, dname, NAMLEN(ptr)+1); - unix_to_dos(buf, True); - dname = buf; - } - return(dname); } |