From ae7696117e81bb469fa71f9bc880f6b5aac0724e Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Thu, 3 Feb 2000 23:08:24 +0000 Subject: Put back lots of missing calls to dos_to_unix(). Thanks to aono@cc.osaka-kyoiku.ac.jp (Tomoki AONO) (This used to be commit 176c405d2702a4245561ff56c8eac3c754a0dea3) --- source3/smbd/dir.c | 12 ++++++++---- source3/smbd/dosmode.c | 2 +- source3/smbd/filename.c | 4 ++-- source3/smbd/ipc.c | 27 +++++++++++++++++---------- source3/smbd/open.c | 13 +++++++------ source3/smbd/reply.c | 41 ++++++++++++++++++++++------------------- source3/smbd/vfs.c | 4 ++-- 7 files changed, 59 insertions(+), 44 deletions(-) (limited to 'source3/smbd') diff --git a/source3/smbd/dir.c b/source3/smbd/dir.c index 32fc523541..58b0061e19 100644 --- a/source3/smbd/dir.c +++ b/source3/smbd/dir.c @@ -670,7 +670,7 @@ void *OpenDir(connection_struct *conn, char *name, BOOL use_veto) { Dir *dirp; char *n; - DIR *p = conn->vfs_ops.opendir(name); + DIR *p = conn->vfs_ops.opendir(dos_to_unix(name,False)); int used=0; if (!p) return(NULL); @@ -684,10 +684,14 @@ void *OpenDir(connection_struct *conn, char *name, BOOL use_veto) while ((n = vfs_readdirname(conn, p))) { - int l = strlen(n)+1; + int l; + pstring zn; + + pstrcpy(zn, unix_to_dos(n,True)); + l = strlen(zn)+1; /* If it's a vetoed file, pretend it doesn't even exist */ - if (use_veto && conn && IS_VETO_PATH(conn, n)) continue; + if (use_veto && conn && IS_VETO_PATH(conn, zn)) continue; if (used + l > dirp->mallocsize) { int s = MAX(used+l,used+2000); @@ -701,7 +705,7 @@ void *OpenDir(connection_struct *conn, char *name, BOOL use_veto) dirp->mallocsize = s; dirp->current = dirp->data; } - pstrcpy(dirp->data+used,n); + pstrcpy(dirp->data+used,zn); used += l; dirp->numentries++; } diff --git a/source3/smbd/dosmode.c b/source3/smbd/dosmode.c index 1ae1e7e2cb..278a4ab5e3 100644 --- a/source3/smbd/dosmode.c +++ b/source3/smbd/dosmode.c @@ -225,7 +225,7 @@ int file_chmod(connection_struct *conn,char *fname,int dosmode,SMB_STRUCT_STAT * unixmode |= (st->st_mode & (S_IWUSR|S_IWGRP|S_IWOTH)); } - return(conn->vfs_ops.chmod(fname,unixmode)); + return(conn->vfs_ops.chmod(dos_to_unix(fname,False),unixmode)); } diff --git a/source3/smbd/filename.c b/source3/smbd/filename.c index b1550e5c73..85055f676a 100644 --- a/source3/smbd/filename.c +++ b/source3/smbd/filename.c @@ -444,7 +444,7 @@ BOOL unix_convert(char *name,connection_struct *conn,char *saved_last_component, * stat the name - if it exists then we are all done! */ - if (conn->vfs_ops.stat(name,&st) == 0) { + if (conn->vfs_ops.stat(dos_to_unix(name,False),&st) == 0) { stat_cache_add(orig_path, name); DEBUG(5,("conversion finished %s -> %s\n",orig_path, name)); if(pst) @@ -511,7 +511,7 @@ BOOL unix_convert(char *name,connection_struct *conn,char *saved_last_component, * Check if the name exists up to this point. */ - if (conn->vfs_ops.stat(name, &st) == 0) { + if (conn->vfs_ops.stat(dos_to_unix(name,False), &st) == 0) { /* * It exists. it must either be a directory or this must be * the last part of the path for it to be OK. diff --git a/source3/smbd/ipc.c b/source3/smbd/ipc.c index 3e16dba4f5..b5a6e4ba90 100644 --- a/source3/smbd/ipc.c +++ b/source3/smbd/ipc.c @@ -2055,6 +2055,7 @@ static BOOL api_PrintJobInfo(connection_struct *conn,uint16 vuid,char *param,cha if (isalpha((int)*s)) { pstring name; int l = 0; + while (l<64 && *s) { if (issafe(*s)) name[l++] = *s; s++; @@ -2066,17 +2067,23 @@ static BOOL api_PrintJobInfo(connection_struct *conn,uint16 vuid,char *param,cha fsp = file_find_print(); if (fsp) { - connection_struct *fconn = fsp->conn; - unbecome_user(); - - if (!become_user(fconn,vuid) || - !become_service(fconn,True)) - break; + pstring zfrom,zto; + connection_struct *fconn = fsp->conn; + + unbecome_user(); - if (fsp->conn->vfs_ops.rename(fsp->fsp_name,name) == 0) { - string_set(&fsp->fsp_name,name); - } - break; + if (!become_user(fconn,vuid) || + !become_service(fconn,True)) + break; + + pstrcpy(zfrom, dos_to_unix(fsp->fsp_name,False)); + pstrcpy(zto, dos_to_unix(name,False)); + + if (fsp->conn->vfs_ops.rename(zfrom,zto) == 0) { + string_set(&fsp->fsp_name,name); + } + + break; } } desc.errcode=NERR_Success; diff --git a/source3/smbd/open.c b/source3/smbd/open.c index 1b4179da33..30409707d3 100644 --- a/source3/smbd/open.c +++ b/source3/smbd/open.c @@ -33,14 +33,14 @@ fd support routines - attempt to do a dos_open static int fd_attempt_open(struct connection_struct *conn, char *fname, int flags, mode_t mode) { - int fd = conn->vfs_ops.open(fname,flags,mode); + int fd = conn->vfs_ops.open(dos_to_unix(fname,False),flags,mode); /* Fix for files ending in '.' */ if((fd == -1) && (errno == ENOENT) && (strchr(fname,'.')==NULL)) { pstrcat(fname,"."); - fd = conn->vfs_ops.open(fname,flags,mode); + fd = conn->vfs_ops.open(dos_to_unix(fname,False),flags,mode); } #if (defined(ENAMETOOLONG) && defined(HAVE_PATHCONF)) @@ -71,7 +71,7 @@ static int fd_attempt_open(struct connection_struct *conn, char *fname, char tmp = p[max_len]; p[max_len] = '\0'; - if ((fd = conn->vfs_ops.open(fname,flags,mode)) == -1) + if ((fd = conn->vfs_ops.open(dos_to_unix(fname,False),flags,mode)) == -1) p[max_len] = tmp; } } @@ -494,7 +494,7 @@ static void open_file(files_struct *fsp,connection_struct *conn, pstrcpy(dname,fname); p = strrchr(dname,'/'); if (p) *p = 0; - if (conn->vfs_ops.disk_free(dname,False,&dum1,&dum2,&dum3) < + if (conn->vfs_ops.disk_free(dos_to_unix(dname,False),False,&dum1,&dum2,&dum3) < (SMB_BIG_UINT)lp_minprintspace(SNUM(conn))) { int err; if(fd_attempt_close(fsp, &err) == 0) @@ -797,7 +797,7 @@ void open_file_shared(files_struct *fsp,connection_struct *conn,char *fname,int int deny_mode = GET_DENY_MODE(share_mode); BOOL allow_share_delete = GET_ALLOW_SHARE_DELETE(share_mode); SMB_STRUCT_STAT sbuf; - BOOL file_existed = vfs_file_exist(conn, dos_to_unix(fname,False), &sbuf); + BOOL file_existed = vfs_file_exist(conn, fname, &sbuf); BOOL share_locked = False; BOOL fcbopen = False; int token = 0; @@ -1192,7 +1192,8 @@ int open_directory(files_struct *fsp,connection_struct *conn, return -1; } - if(conn->vfs_ops.mkdir(dos_to_unix(fname, False), unix_mode(conn,aDIR, fname)) < 0) { + if(conn->vfs_ops.mkdir(dos_to_unix(fname, False), + unix_mode(conn,aDIR, fname)) < 0) { DEBUG(0,("open_directory: unable to create %s. Error was %s\n", fname, strerror(errno) )); return -1; diff --git a/source3/smbd/reply.c b/source3/smbd/reply.c index f022301450..3715bd224f 100644 --- a/source3/smbd/reply.c +++ b/source3/smbd/reply.c @@ -1032,7 +1032,7 @@ int reply_chkpth(connection_struct *conn, char *inbuf,char *outbuf, int dum_size if(VALID_STAT(st)) ok = S_ISDIR(st.st_mode); else - ok = vfs_directory_exist(conn,dos_to_unix(name,False),NULL); + ok = vfs_directory_exist(conn,name,NULL); } if (!ok) @@ -1167,7 +1167,7 @@ int reply_setatr(connection_struct *conn, char *inbuf,char *outbuf, int dum_size mode = SVAL(inbuf,smb_vwv0); mtime = make_unix_date3(inbuf+smb_vwv1); - if (VALID_STAT_OF_DIR(st) || vfs_directory_exist(conn, dos_to_unix(fname,False),NULL)) + if (VALID_STAT_OF_DIR(st) || vfs_directory_exist(conn, fname, NULL)) mode |= aDIR; if (check_name(fname,conn)) ok = (file_chmod(conn,fname,mode,NULL) == 0); @@ -1918,7 +1918,7 @@ static BOOL can_delete(char *fname,connection_struct *conn, int dirtype) if (!CAN_WRITE(conn)) return(False); - if (conn->vfs_ops.lstat(fname,&sbuf) != 0) return(False); + if (conn->vfs_ops.lstat(dos_to_unix(fname,False),&sbuf) != 0) return(False); fmode = dos_mode(conn,fname,&sbuf); if (fmode & aDIR) return(False); if (!lp_delete_readonly(SNUM(conn))) { @@ -1989,7 +1989,7 @@ int reply_unlink(connection_struct *conn, char *inbuf,char *outbuf, int dum_size if (can_delete(directory,conn,dirtype) && !dos_unlink(directory)) count++; if (!count) - exists = vfs_file_exist(conn,dos_to_unix(directory,False),NULL); + exists = vfs_file_exist(conn,directory,NULL); } else { void *dirptr = NULL; char *dname; @@ -2019,7 +2019,7 @@ int reply_unlink(connection_struct *conn, char *inbuf,char *outbuf, int dum_size error = ERRnoaccess; slprintf(fname,sizeof(fname)-1, "%s/%s",directory,dname); if (!can_delete(fname,conn,dirtype)) continue; - if (!conn->vfs_ops.unlink(fname)) count++; + if (!conn->vfs_ops.unlink(dos_to_unix(fname,False))) count++; DEBUG(3,("reply_unlink : doing unlink on %s\n",fname)); } CloseDir(dirptr); @@ -2708,7 +2708,7 @@ int reply_lseek(connection_struct *conn, char *inbuf,char *outbuf, int size, int SMB_STRUCT_STAT sbuf; - if(conn->vfs_ops.fstat( fsp->fd_ptr->fd, &sbuf) == -1) + if(conn->vfs_ops.fstat(fsp->fd_ptr->fd, &sbuf) == -1) return(UNIXERROR(ERRDOS,ERRnoaccess)); current_pos += sbuf.st_size; @@ -3290,7 +3290,7 @@ static BOOL recursive_rmdir(connection_struct *conn, char *directory) pstrcat(fullname, "/"); pstrcat(fullname, dname); - if(conn->vfs_ops.lstat(fullname, &st) != 0) + if(conn->vfs_ops.lstat(dos_to_unix(fullname,False), &st) != 0) { ret = True; break; @@ -3518,7 +3518,7 @@ static BOOL can_rename(char *fname,connection_struct *conn) if (!CAN_WRITE(conn)) return(False); - if (conn->vfs_ops.lstat(fname,&sbuf) != 0) return(False); + if (conn->vfs_ops.lstat(dos_to_unix(fname,False),&sbuf) != 0) return(False); if (!check_file_sharing(conn,fname,True)) return(False); return(True); @@ -3654,7 +3654,7 @@ int rename_internals(connection_struct *conn, } else { if (resolve_wildcards(directory,newname) && can_rename(directory,conn) && - !vfs_file_exist(conn,dos_to_unix(newname,False),NULL) && + !vfs_file_exist(conn,newname,NULL) && !conn->vfs_ops.rename(dos_to_unix(directory,False), newname)) count++; @@ -3663,8 +3663,8 @@ int rename_internals(connection_struct *conn, DEBUG(3,("rename_internals: %s doing rename on %s -> %s\n",(count != 0) ? "succeeded" : "failed", directory,newname)); - if (!count) exists = vfs_file_exist(conn,dos_to_unix(directory,False),NULL); - if (!count && exists && vfs_file_exist(conn,dos_to_unix(newname,False),NULL)) { + if (!count) exists = vfs_file_exist(conn,directory,NULL); + if (!count && exists && vfs_file_exist(conn,newname,NULL)) { exists = True; error = ERRrename; } @@ -3701,17 +3701,20 @@ int rename_internals(connection_struct *conn, pstrcpy(destname,newname); if (!resolve_wildcards(fname,destname)) { - DEBUG(6,("resolve_wildcards %s %s failed\n", fname, destname)); + DEBUG(6,("resolve_wildcards %s %s failed\n", + fname, destname)); continue; } - if (!replace_if_exists && vfs_file_exist(conn,dos_to_unix(destname,False),NULL)) { + if (!replace_if_exists && + vfs_file_exist(conn,destname, NULL)) { DEBUG(6,("file_exist %s\n", destname)); error = 183; continue; } - if (!conn->vfs_ops.rename(dos_to_unix(fname,False),destname)) + if (!conn->vfs_ops.rename(dos_to_unix(fname,False), + destname)) count++; DEBUG(3,("rename_internals: doing rename on %s -> %s\n",fname,destname)); } @@ -3782,7 +3785,7 @@ static BOOL copy_file(char *src,char *dest1,connection_struct *conn, int ofun, pstrcat(dest,p); } - if (!vfs_file_exist(conn,dos_to_unix(src,False),&st)) + if (!vfs_file_exist(conn,src,&st)) return(False); fsp1 = file_new(); @@ -3882,7 +3885,7 @@ int reply_copy(connection_struct *conn, char *inbuf,char *outbuf, int dum_size, rc = unix_convert(name,conn,0,&bad_path1,NULL); unix_convert(newname,conn,0,&bad_path2,NULL); - target_is_directory = vfs_directory_exist(conn,dos_to_unix(newname,False),NULL); + target_is_directory = vfs_directory_exist(conn,False,NULL); if ((flags&1) && target_is_directory) { return(ERROR(ERRDOS,ERRbadfile)); @@ -3892,7 +3895,7 @@ int reply_copy(connection_struct *conn, char *inbuf,char *outbuf, int dum_size, return(ERROR(ERRDOS,ERRbadpath)); } - if ((flags&(1<<5)) && vfs_directory_exist(conn,dos_to_unix(name,False),NULL)) { + if ((flags&(1<<5)) && vfs_directory_exist(conn,name,NULL)) { /* wants a tree copy! XXXX */ DEBUG(3,("Rejecting tree copy\n")); return(ERROR(ERRSRV,ERRerror)); @@ -3932,7 +3935,7 @@ int reply_copy(connection_struct *conn, char *inbuf,char *outbuf, int dum_size, errno = err; return(UNIXERROR(ERRHRD,ERRgeneral)); } - if (!count) exists = vfs_file_exist(conn,dos_to_unix(directory,False),NULL); + if (!count) exists = vfs_file_exist(conn,directory,NULL); } else { void *dirptr = NULL; char *dname; @@ -4012,7 +4015,7 @@ int reply_setdir(connection_struct *conn, char *inbuf,char *outbuf, int dum_size if (strlen(newdir) == 0) { ok = True; } else { - ok = vfs_directory_exist(conn,dos_to_unix(newdir,False),NULL); + ok = vfs_directory_exist(conn,newdir,NULL); if (ok) { string_set(&conn->connectpath,newdir); } diff --git a/source3/smbd/vfs.c b/source3/smbd/vfs.c index 2f9f847188..f5c2ec3426 100644 --- a/source3/smbd/vfs.c +++ b/source3/smbd/vfs.c @@ -220,7 +220,7 @@ BOOL vfs_directory_exist(connection_struct *conn, char *dname, if (!st) st = &st2; - if (conn->vfs_ops.stat(dname,st) != 0) + if (conn->vfs_ops.stat(dos_to_unix(dname,False),st) != 0) return(False); ret = S_ISDIR(st->st_mode); @@ -238,7 +238,7 @@ BOOL vfs_file_exist(connection_struct *conn,char *fname,SMB_STRUCT_STAT *sbuf) SMB_STRUCT_STAT st; if (!sbuf) sbuf = &st; - if (conn->vfs_ops.stat(fname,sbuf) != 0) + if (conn->vfs_ops.stat(dos_to_unix(fname,False),sbuf) != 0) return(False); return(S_ISREG(sbuf->st_mode)); -- cgit