From 38087ccb4071bfff29801026e2bf5c47565305b4 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Sat, 5 Oct 1996 02:54:37 +0000 Subject: - use workgroup from smb.conf in smbclient - change debug level on clitar stuff - define MAP_FILE if not defined - ensure we never set authoritative on queries in nmbd - fake a positive response to SMBioctl, apparently this is needed for some WfWg printer drivers - deny file access for non-fcbopen queries when (access_allowed == AREAD && flags == O_RDWR) - add sys_waitpid() (This used to be commit 61e3116e573637d6b5a878eeb8db72831e3c5bd1) --- source3/client/client.c | 5 ++++- source3/client/clitar.c | 8 ++++---- source3/include/includes.h | 6 ++++++ source3/include/proto.h | 1 + source3/lib/system.c | 12 ++++++++++++ source3/libsmb/nmblib.c | 5 +++-- source3/smbd/reply.c | 7 ++++++- source3/smbd/server.c | 3 ++- source3/smbd/uid.c | 2 +- 9 files changed, 39 insertions(+), 10 deletions(-) (limited to 'source3') diff --git a/source3/client/client.c b/source3/client/client.c index 596d6a9677..b8b63207d7 100644 --- a/source3/client/client.c +++ b/source3/client/client.c @@ -36,7 +36,7 @@ pstring desthost=""; extern pstring myname; pstring password = ""; pstring username=""; -pstring workgroup=WORKGROUP; +pstring workgroup=""; char *cmdstr=""; BOOL got_pass = False; BOOL connect_as_printer = False; @@ -4503,6 +4503,9 @@ static void usage(char *pname) return (-1); } + if (*workgroup == 0) + strcpy(workgroup,lp_workgroup()); + load_interfaces(); get_myname(*myname?NULL:myname,NULL); strupper(myname); diff --git a/source3/client/clitar.c b/source3/client/clitar.c index 13df5fef9a..191e0e4dab 100644 --- a/source3/client/clitar.c +++ b/source3/client/clitar.c @@ -823,7 +823,7 @@ static void do_atar(char *rname,char *lname,file_info *finfo1) datalen = 0; } - DEBUG(2,("getting file %s of size %d bytes as a tar file %s", + DEBUG(1,("getting file %s of size %d bytes as a tar file %s", finfo.name, finfo.size, lname)); @@ -1079,7 +1079,7 @@ static void do_atar(char *rname,char *lname,file_info *finfo1) get_total_size += finfo.size; /* Thanks to Carel-Jan Engel (ease@mail.wirehub.nl) for this one */ - DEBUG(2,("(%g kb/s) (average %g kb/s)\n", + DEBUG(1,("(%g kb/s) (average %g kb/s)\n", finfo.size / MAX(0.001, (1.024*this_time)), get_total_size / MAX(0.001, (1.024*get_total_time_ms)))); } @@ -1406,7 +1406,7 @@ void cmd_block(void) } blocksize=block; - DEBUG(2,("blocksize is now %d\n", blocksize)); + DEBUG(1,("blocksize is now %d\n", blocksize)); } /**************************************************************************** @@ -1483,7 +1483,7 @@ void cmd_setmode(void) return; } - DEBUG(2, ("\nperm set %d %d\n", attra[ATTRSET], attra[ATTRRESET])); + DEBUG(1, ("\nperm set %d %d\n", attra[ATTRSET], attra[ATTRRESET])); (void) do_setrattr(fname, attra[ATTRSET], ATTRSET); (void) do_setrattr(fname, attra[ATTRRESET], ATTRRESET); } diff --git a/source3/include/includes.h b/source3/include/includes.h index 5d5fd7fd55..90358ce49a 100644 --- a/source3/include/includes.h +++ b/source3/include/includes.h @@ -220,6 +220,7 @@ Here come some platform specific sections #define HAVE_BZERO #define HAVE_MEMMOVE #define USE_SIGPROCMASK +#define USE_WAITPID #if 0 /* SETFS disabled until we can check on some bug reports */ #if _LINUX_C_LIB_VERSION_MAJOR >= 5 @@ -258,6 +259,7 @@ typedef unsigned short mode_t; #define REPLACE_GETPASS #define BSD_TERMIO #define USE_SIGPROCMASK +#define USE_WAITPID #endif @@ -1080,6 +1082,10 @@ it works and getting lots of bug reports */ #define SIGCLD SIGCHLD #endif +#ifndef MAP_FILE +#define MAP_FILE 0 +#endif + #ifndef HAVE_FCNTL_LOCK #define HAVE_FCNTL_LOCK 1 #endif diff --git a/source3/include/proto.h b/source3/include/proto.h index 8b26aa062f..779f6bd87e 100644 --- a/source3/include/proto.h +++ b/source3/include/proto.h @@ -754,6 +754,7 @@ int sys_unlink(char *fname); int sys_open(char *fname,int flags,int mode); DIR *sys_opendir(char *dname); int sys_stat(char *fname,struct stat *sbuf); +int sys_waitpid(pid_t pid,int *status,int options); int sys_lstat(char *fname,struct stat *sbuf); int sys_mkdir(char *dname,int mode); int sys_rmdir(char *dname); diff --git a/source3/lib/system.c b/source3/lib/system.c index 81e9a6679a..5ece0ca024 100644 --- a/source3/lib/system.c +++ b/source3/lib/system.c @@ -141,6 +141,18 @@ int sys_stat(char *fname,struct stat *sbuf) return(stat(dos_to_unix(fname,False),sbuf)); } +/******************************************************************* +The wait() calls vary between systems +********************************************************************/ +int sys_waitpid(pid_t pid,int *status,int options) +{ +#ifdef USE_WAITPID + return waitpid(pid,status,options); +#else + return wait4(pid,status,options,NULL); +#endif +} + /******************************************************************* don't forget lstat() ********************************************************************/ diff --git a/source3/libsmb/nmblib.c b/source3/libsmb/nmblib.c index 4113b34cab..c70311f997 100644 --- a/source3/libsmb/nmblib.c +++ b/source3/libsmb/nmblib.c @@ -395,7 +395,7 @@ static BOOL parse_nmb(char *inbuf,int length,struct nmb_packet *nmb) nmb->header.nm_flags.recursion_available = (nm_flags&8)?True:False; nmb->header.nm_flags.recursion_desired = (nm_flags&0x10)?True:False; nmb->header.nm_flags.trunc = (nm_flags&0x20)?True:False; - nmb->header.nm_flags.authoritative = (nm_flags&0x40)?True:False; + nmb->header.nm_flags.authoritative = (nm_flags&0x40)?True:False; nmb->header.rcode = CVAL(inbuf,3) & 0xF; nmb->header.qdcount = RSVAL(inbuf,4); nmb->header.ancount = RSVAL(inbuf,6); @@ -606,7 +606,8 @@ static int build_nmb(char *buf,struct packet_struct *p) RSSVAL(ubuf,offset,nmb->header.name_trn_id); ubuf[offset+2] = (nmb->header.opcode & 0xF) << 3; if (nmb->header.response) ubuf[offset+2] |= (1<<7); - if (nmb->header.nm_flags.authoritative) ubuf[offset+2] |= 0x4; + if (nmb->header.nm_flags.authoritative && + nmb->header.response) ubuf[offset+2] |= 0x4; if (nmb->header.nm_flags.trunc) ubuf[offset+2] |= 0x2; if (nmb->header.nm_flags.recursion_desired) ubuf[offset+2] |= 0x1; if (nmb->header.nm_flags.recursion_available && diff --git a/source3/smbd/reply.c b/source3/smbd/reply.c index 6cf1b031e8..63c0a7027e 100644 --- a/source3/smbd/reply.c +++ b/source3/smbd/reply.c @@ -294,8 +294,13 @@ int reply_unknown(char *inbuf,char *outbuf) int reply_ioctl(char *inbuf,char *outbuf) { DEBUG(3,("ignoring ioctl\n")); - +#if 1 + /* we just say it succeeds and hope its all OK. + some day it would be nice to interpret them individually */ + return set_message(outbuf,1,0,True); +#else return(ERROR(ERRSRV,ERRnosupport)); +#endif } diff --git a/source3/smbd/server.c b/source3/smbd/server.c index a710aef69b..9ad7840465 100644 --- a/source3/smbd/server.c +++ b/source3/smbd/server.c @@ -1158,6 +1158,7 @@ void open_file_shared(int fnum,int cnum,char *fname,int share_mode,int ofun, share_pid,fname); if ((access_allowed == AFAIL) || + (!fcbopen && (access_allowed == AREAD && flags == O_RDWR)) || (access_allowed == AREAD && flags == O_WRONLY) || (access_allowed == AWRITE && flags == O_RDONLY)) { DEBUG(2,("Share violation on file (%d,%d,%d,%d,%s) = %d\n", @@ -1586,7 +1587,7 @@ static int sig_cld() DEBUG(5,("got SIGCLD\n")); #ifdef USE_WAITPID - while (waitpid((pid_t)-1,(int *)NULL, WNOHANG) > 0); + while (sys_waitpid((pid_t)-1,(int *)NULL, WNOHANG) > 0); #endif /* Stop zombies */ diff --git a/source3/smbd/uid.c b/source3/smbd/uid.c index 7274c18478..9312a447a0 100644 --- a/source3/smbd/uid.c +++ b/source3/smbd/uid.c @@ -415,7 +415,7 @@ int smbrun(char *cmd,char *outfile,BOOL shared) if ((pid=fork())) { int status=0; /* the parent just waits for the child to exit */ - if (waitpid(pid,&status,0) != pid) { + if (sys_waitpid(pid,&status,0) != pid) { DEBUG(2,("waitpid(%d) : %s\n",pid,strerror(errno))); return -1; } -- cgit