summaryrefslogtreecommitdiff
path: root/source3/smbd/reply.c
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>2000-04-10 13:05:23 +0000
committerAndrew Tridgell <tridge@samba.org>2000-04-10 13:05:23 +0000
commit689ec46450a3f373b583ebe98d124ab4a99ce3ef (patch)
tree2e86c1a862fce2da5162de7a3cd45fc8611d5a38 /source3/smbd/reply.c
parentc3043695ae507b34580dc1287418ff5704b6f625 (diff)
downloadsamba-689ec46450a3f373b583ebe98d124ab4a99ce3ef.tar.gz
samba-689ec46450a3f373b583ebe98d124ab4a99ce3ef.tar.bz2
samba-689ec46450a3f373b583ebe98d124ab4a99ce3ef.zip
the bulk of the changes to get rid of fd_ptr and move print open
handling to printing/printing.c most of this was just replacing things like fsp->fd_ptr->fd with fsp->fd the changes in open.c are quite dramatic. Most of it is removing all the functions that handled the fd multiplexing (This used to be commit d1827a3648009fd0a0d165055015d9aeda7a1037)
Diffstat (limited to 'source3/smbd/reply.c')
-rw-r--r--source3/smbd/reply.c131
1 files changed, 28 insertions, 103 deletions
diff --git a/source3/smbd/reply.c b/source3/smbd/reply.c
index 0092d6b397..81d3ef32b3 100644
--- a/source3/smbd/reply.c
+++ b/source3/smbd/reply.c
@@ -1549,17 +1549,6 @@ int reply_open(connection_struct *conn, char *inbuf,char *outbuf, int dum_size,
if (!fsp)
return(ERROR(ERRSRV,ERRnofids));
- if (!check_name(fname,conn))
- {
- if((errno == ENOENT) && bad_path)
- {
- unix_ERR_class = ERRDOS;
- unix_ERR_code = ERRbadpath;
- }
- file_free(fsp);
- return(UNIXERROR(ERRDOS,ERRnoaccess));
- }
-
unixmode = unix_mode(conn,aARCH,fname);
open_file_shared(fsp,conn,fname,share_mode,(FILE_FAIL_IF_NOT_EXIST|FILE_EXISTS_OPEN),
@@ -1576,7 +1565,7 @@ int reply_open(connection_struct *conn, char *inbuf,char *outbuf, int dum_size,
return(UNIXERROR(ERRDOS,ERRnoaccess));
}
- if (fsp->conn->vfs_ops.fstat(fsp->fd_ptr->fd,&sbuf) != 0) {
+ if (fsp->conn->vfs_ops.fstat(fsp->fd,&sbuf) != 0) {
close_file(fsp,False);
return(ERROR(ERRDOS,ERRnoaccess));
}
@@ -1654,17 +1643,6 @@ int reply_open_and_X(connection_struct *conn, char *inbuf,char *outbuf,int lengt
if (!fsp)
return(ERROR(ERRSRV,ERRnofids));
- if (!check_name(fname,conn))
- {
- if((errno == ENOENT) && bad_path)
- {
- unix_ERR_class = ERRDOS;
- unix_ERR_code = ERRbadpath;
- }
- file_free(fsp);
- return(UNIXERROR(ERRDOS,ERRnoaccess));
- }
-
unixmode = unix_mode(conn,smb_attr | aARCH, fname);
open_file_shared(fsp,conn,fname,smb_mode,smb_ofun,unixmode,
@@ -1681,7 +1659,7 @@ int reply_open_and_X(connection_struct *conn, char *inbuf,char *outbuf,int lengt
return(UNIXERROR(ERRDOS,ERRnoaccess));
}
- if (fsp->conn->vfs_ops.fstat(fsp->fd_ptr->fd,&sbuf) != 0) {
+ if (fsp->conn->vfs_ops.fstat(fsp->fd,&sbuf) != 0) {
close_file(fsp,False);
return(ERROR(ERRDOS,ERRnoaccess));
}
@@ -1798,17 +1776,6 @@ int reply_mknew(connection_struct *conn, char *inbuf,char *outbuf, int dum_size,
if (!fsp)
return(ERROR(ERRSRV,ERRnofids));
- if (!check_name(fname,conn))
- {
- if((errno == ENOENT) && bad_path)
- {
- unix_ERR_class = ERRDOS;
- unix_ERR_code = ERRbadpath;
- }
- file_free(fsp);
- return(UNIXERROR(ERRDOS,ERRnoaccess));
- }
-
if(com == SMBmknew)
{
/* We should fail if file exists. */
@@ -1847,7 +1814,7 @@ int reply_mknew(connection_struct *conn, char *inbuf,char *outbuf, int dum_size,
DEBUG( 2, ( "new file %s\n", fname ) );
DEBUG( 3, ( "mknew %s fd=%d dmode=%d umode=%o\n",
- fname, fsp->fd_ptr->fd, createmode, (int)unixmode ) );
+ fname, fsp->fd, createmode, (int)unixmode ) );
return(outsize);
}
@@ -1881,17 +1848,6 @@ int reply_ctemp(connection_struct *conn, char *inbuf,char *outbuf, int dum_size,
if (fsp)
return(ERROR(ERRSRV,ERRnofids));
- if (!check_name(fname,conn))
- {
- if((errno == ENOENT) && bad_path)
- {
- unix_ERR_class = ERRDOS;
- unix_ERR_code = ERRbadpath;
- }
- file_free(fsp);
- return(UNIXERROR(ERRDOS,ERRnoaccess));
- }
-
pstrcpy(fname2,(char *)smbd_mktemp(fname));
/* Open file in dos compatibility share mode. */
@@ -1924,7 +1880,7 @@ int reply_ctemp(connection_struct *conn, char *inbuf,char *outbuf, int dum_size,
DEBUG( 2, ( "created temp file %s\n", fname2 ) );
DEBUG( 3, ( "ctemp %s fd=%d dmode=%d umode=%o\n",
- fname2, fsp->fd_ptr->fd, createmode, (int)unixmode ) );
+ fname2, fsp->fd, createmode, (int)unixmode ) );
return(outsize);
}
@@ -2161,7 +2117,7 @@ int reply_readbraw(connection_struct *conn, char *inbuf, char *outbuf, int dum_s
if (size < sizeneeded)
{
SMB_STRUCT_STAT st;
- if (fsp->conn->vfs_ops.fstat(fsp->fd_ptr->fd,&st) == 0)
+ if (fsp->conn->vfs_ops.fstat(fsp->fd,&st) == 0)
size = st.st_size;
if (!fsp->can_write)
fsp->size = size;
@@ -2185,7 +2141,7 @@ int reply_readbraw(connection_struct *conn, char *inbuf, char *outbuf, int dum_s
#if USE_READ_PREDICTION
if (!fsp->can_write)
- predict = read_predict(fsp, fsp->fd_ptr->fd,startpos,header+4,NULL,nread);
+ predict = read_predict(fsp, fsp->fd,startpos,header+4,NULL,nread);
#endif /* USE_READ_PREDICTION */
if ((nread-predict) > 0) {
@@ -2197,7 +2153,7 @@ int reply_readbraw(connection_struct *conn, char *inbuf, char *outbuf, int dum_s
}
if(!seek_fail)
- ret = (ssize_t)vfs_transfer_file(-1, fsp->fd_ptr->fd, Client, NULL,
+ ret = (ssize_t)vfs_transfer_file(-1, fsp->fd, Client, NULL,
(SMB_OFF_T)(nread-predict),header,4+predict,
startpos+predict);
}
@@ -2480,7 +2436,7 @@ int reply_writebraw(connection_struct *conn, char *inbuf,char *outbuf, int size,
if ((lp_syncalways(SNUM(conn)) || write_through) &&
lp_strict_sync(SNUM(conn)))
- conn->vfs_ops.fsync(fsp->fd_ptr->fd);
+ conn->vfs_ops.fsync(fsp->fd);
DEBUG(3,("writebraw2 fnum=%d start=%.0f num=%d wrote=%d\n",
fsp->fnum, (double)startpos, (int)numtowrite,(int)total_written));
@@ -2528,7 +2484,7 @@ int reply_writeunlock(connection_struct *conn, char *inbuf,char *outbuf, int siz
nwritten = write_file(fsp,data,startpos,numtowrite);
if (lp_syncalways(SNUM(conn)))
- conn->vfs_ops.fsync(fsp->fd_ptr->fd);
+ conn->vfs_ops.fsync(fsp->fd);
if(((nwritten == 0) && (numtowrite != 0))||(nwritten < 0))
return(UNIXERROR(ERRDOS,ERRnoaccess));
@@ -2577,13 +2533,13 @@ int reply_write(connection_struct *conn, char *inbuf,char *outbuf,int size,int d
zero then the file size should be extended or
truncated to the size given in smb_vwv[2-3] */
if(numtowrite == 0) {
- if((nwritten = set_filelen(fsp->fd_ptr->fd, (SMB_OFF_T)startpos)) >= 0) /* tpot vfs */
+ if((nwritten = set_filelen(fsp->fd, (SMB_OFF_T)startpos)) >= 0) /* tpot vfs */
set_filelen_write_cache(fsp, startpos);
} else
nwritten = write_file(fsp,data,startpos,numtowrite);
if (lp_syncalways(SNUM(conn)))
- conn->vfs_ops.fsync(fsp->fd_ptr->fd);
+ conn->vfs_ops.fsync(fsp->fd);
if(((nwritten == 0) && (numtowrite != 0))||(nwritten < 0))
return(UNIXERROR(ERRDOS,ERRnoaccess));
@@ -2677,7 +2633,7 @@ int reply_write_and_X(connection_struct *conn, char *inbuf,char *outbuf,int leng
fsp->fnum, (int)numtowrite, (int)nwritten));
if (lp_syncalways(SNUM(conn)) || write_through)
- conn->vfs_ops.fsync(fsp->fd_ptr->fd);
+ conn->vfs_ops.fsync(fsp->fd);
return chain_reply(inbuf,outbuf,length,bufsize);
}
@@ -2711,7 +2667,7 @@ int reply_lseek(connection_struct *conn, char *inbuf,char *outbuf, int size, int
umode = SEEK_SET; break;
}
- if((res = conn->vfs_ops.lseek(fsp->fd_ptr->fd,startpos,umode)) == -1) {
+ if((res = conn->vfs_ops.lseek(fsp->fd,startpos,umode)) == -1) {
/*
* Check for the special case where a seek before the start
* of the file sets the offset to zero. Added in the CIFS spec,
@@ -2723,7 +2679,7 @@ int reply_lseek(connection_struct *conn, char *inbuf,char *outbuf, int size, int
if(umode == SEEK_CUR) {
- if((current_pos = conn->vfs_ops.lseek(fsp->fd_ptr->fd,0,SEEK_CUR)) == -1)
+ if((current_pos = conn->vfs_ops.lseek(fsp->fd,0,SEEK_CUR)) == -1)
return(UNIXERROR(ERRDOS,ERRnoaccess));
current_pos += startpos;
@@ -2732,14 +2688,14 @@ 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, &sbuf) == -1)
return(UNIXERROR(ERRDOS,ERRnoaccess));
current_pos += sbuf.st_size;
}
if(current_pos < 0)
- res = conn->vfs_ops.lseek(fsp->fd_ptr->fd,0,SEEK_SET);
+ res = conn->vfs_ops.lseek(fsp->fd,0,SEEK_SET);
}
if(res == -1)
@@ -2774,7 +2730,7 @@ int reply_flush(connection_struct *conn, char *inbuf,char *outbuf, int size, int
if (!fsp) {
file_sync_all(conn);
} else {
- conn->vfs_ops.fsync(fsp->fd_ptr->fd);
+ conn->vfs_ops.fsync(fsp->fd);
}
DEBUG(3,("flush\n"));
@@ -2855,7 +2811,7 @@ int reply_close(connection_struct *conn, char *inbuf,char *outbuf, int size,
set_filetime(conn, fsp->fsp_name,mtime);
DEBUG(3,("close fd=%d fnum=%d (numopen=%d)\n",
- fsp->fd_ptr ? fsp->fd_ptr->fd : -1, fsp->fnum,
+ fsp->fd, fsp->fnum,
conn->num_files_open));
/*
@@ -2950,7 +2906,7 @@ int reply_lock(connection_struct *conn,
offset = IVAL(inbuf,smb_vwv3);
DEBUG(3,("lock fd=%d fnum=%d offset=%.0f count=%.0f\n",
- fsp->fd_ptr->fd, fsp->fnum, (double)offset, (double)count));
+ fsp->fd, fsp->fnum, (double)offset, (double)count));
if (!do_lock(fsp, conn, count, offset, WRITE_LOCK, &eclass, &ecode)) {
if((ecode == ERRlock) && lp_blocking_locks(SNUM(conn))) {
@@ -2990,7 +2946,7 @@ int reply_unlock(connection_struct *conn, char *inbuf,char *outbuf, int size, in
return (ERROR(eclass,ecode));
DEBUG( 3, ( "unlock fd=%d fnum=%d offset=%.0f count=%.0f\n",
- fsp->fd_ptr->fd, fsp->fnum, (double)offset, (double)count ) );
+ fsp->fd, fsp->fnum, (double)offset, (double)count ) );
return(outsize);
}
@@ -3063,60 +3019,29 @@ int reply_echo(connection_struct *conn,
int reply_printopen(connection_struct *conn,
char *inbuf,char *outbuf, int dum_size, int dum_buffsize)
{
- pstring fname;
- pstring fname2;
int outsize = 0;
files_struct *fsp;
- *fname = *fname2 = 0;
-
if (!CAN_PRINT(conn))
return(ERROR(ERRDOS,ERRnoaccess));
- {
- pstring s;
- char *p;
- pstrcpy(s,smb_buf(inbuf)+1);
- p = s;
- while (*p) {
- if (!(isalnum((int)*p) || strchr("._-",*p)))
- *p = 'X';
- p++;
- }
-
- if (strlen(s) > 10) s[10] = 0;
-
- slprintf(fname,sizeof(fname)-1, "%s.XXXXXX",s);
- }
-
fsp = file_new();
if (!fsp)
return(ERROR(ERRSRV,ERRnofids));
- pstrcpy(fname2,(char *)smbd_mktemp(fname));
-
- if (!check_name(fname2,conn)) {
- file_free(fsp);
- return(ERROR(ERRDOS,ERRnoaccess));
- }
-
/* Open for exclusive use, write only. */
- open_file_shared(fsp,conn,fname2, SET_DENY_MODE(DENY_ALL)|SET_OPEN_MODE(DOS_OPEN_WRONLY),
- (FILE_CREATE_IF_NOT_EXIST|FILE_EXISTS_FAIL), unix_mode(conn,0,fname2), 0, NULL, NULL);
+ print_open_file(fsp,conn,"dos.prn");
if (!fsp->open) {
file_free(fsp);
return(UNIXERROR(ERRDOS,ERRnoaccess));
}
- /* force it to be a print file */
- fsp->print_file = True;
-
outsize = set_message(outbuf,1,0,True);
SSVAL(outbuf,smb_vwv0,fsp->fnum);
- DEBUG(3,("openprint %s fd=%d fnum=%d\n",
- fname2, fsp->fd_ptr->fd, fsp->fnum));
+ DEBUG(3,("openprint fd=%d fnum=%d\n",
+ fsp->fd, fsp->fnum));
return(outsize);
}
@@ -3139,7 +3064,7 @@ int reply_printclose(connection_struct *conn,
return(ERROR(ERRDOS,ERRnoaccess));
DEBUG(3,("printclose fd=%d fnum=%d\n",
- fsp->fd_ptr->fd,fsp->fnum));
+ fsp->fd,fsp->fnum));
close_err = close_file(fsp,True);
@@ -3851,7 +3776,7 @@ static BOOL copy_file(char *src,char *dest1,connection_struct *conn, int ofun,
}
if ((ofun&3) == 1) {
- if(conn->vfs_ops.lseek(fsp2->fd_ptr->fd,0,SEEK_END) == -1) {
+ if(conn->vfs_ops.lseek(fsp2->fd,0,SEEK_END) == -1) {
DEBUG(0,("copy_file: error - sys_lseek returned error %s\n",
strerror(errno) ));
/*
@@ -4469,7 +4394,7 @@ int reply_writebmpx(connection_struct *conn, char *inbuf,char *outbuf, int size,
nwritten = write_file(fsp,data,startpos,numtowrite);
if(lp_syncalways(SNUM(conn)) || write_through)
- conn->vfs_ops.fsync(fsp->fd_ptr->fd);
+ conn->vfs_ops.fsync(fsp->fd);
if(nwritten < (ssize_t)numtowrite)
return(UNIXERROR(ERRHRD,ERRdiskfull));
@@ -4570,7 +4495,7 @@ int reply_writebs(connection_struct *conn, char *inbuf,char *outbuf, int dum_siz
nwritten = write_file(fsp,data,startpos,numtowrite);
if(lp_syncalways(SNUM(conn)) || write_through)
- conn->vfs_ops.fsync(fsp->fd_ptr->fd);
+ conn->vfs_ops.fsync(fsp->fd);
if (nwritten < (ssize_t)numtowrite)
{
@@ -4677,7 +4602,7 @@ int reply_getattrE(connection_struct *conn, char *inbuf,char *outbuf, int size,
CHECK_ERROR(fsp);
/* Do an fstat on this file */
- if(fsp->conn->vfs_ops.fstat(fsp->fd_ptr->fd, &sbuf))
+ if(fsp->conn->vfs_ops.fstat(fsp->fd, &sbuf))
return(UNIXERROR(ERRDOS,ERRnoaccess));
mode = dos_mode(conn,fsp->fsp_name,&sbuf);