summaryrefslogtreecommitdiff
path: root/source3/smbd
diff options
context:
space:
mode:
authorSamba Release Account <samba-bugs@samba.org>1997-07-24 17:25:11 +0000
committerSamba Release Account <samba-bugs@samba.org>1997-07-24 17:25:11 +0000
commit15ae50ca5203bc4c04567e400ba041a4d1757b2b (patch)
treeed7d0fcf569f9a793db2d37dd8b40b55d2c845d7 /source3/smbd
parent7020afbd03402f68113dfd60ec078b2a68b5be6f (diff)
downloadsamba-15ae50ca5203bc4c04567e400ba041a4d1757b2b.tar.gz
samba-15ae50ca5203bc4c04567e400ba041a4d1757b2b.tar.bz2
samba-15ae50ca5203bc4c04567e400ba041a4d1757b2b.zip
Makefile: Added UNIXWARE 2.x with shadow passwords from fja@extratech.com
client.c: Made prompt appear at debug level 0. Fixed strcasecmp redefinition. Caused client to use set_blocking rather than making fcntl calls itself. dir.c: Removed redundent snum parameters. includes.h: Added SCO fixes. loadparm.c: Made default 'files to hide' a null string. nmbd.c: Removed O_NONBLOCK from pid file open for platforms that dont have it. proto.h: Changed snum to cnum where needed. Changed is_xx_path to is_in_path (now called via MACRO). quotas.c: Swapped setuid/seteuid calls when restoring uid. reply.c: Removed redundent snum parameters. server.c: Changed snum to cnum where needed. Setup new veto_list, hide_list namelists. Added standard_sub changes from Stefaan A Eeckels <Stefaan.Eeckels@ecc.lu> and Paul Rippin <pr3245@nopc.eurostat.cec.be> shmem.c: Changed cast for sizeof to be int before negating. smb.h: Added new veto_list, hide_list entries to connections. Added IS_PRINT, IS_HIDDEN_PATH, IS_VETO_PATH macros. trans2.c: Removed redundent snum parameters. util.c: Added standard_sub_basic changes from Stefaan A Eeckels <Stefaan.Eeckels@ecc.lu> and Paul Rippin <pr3245@nopc.eurostat.cec.be> Fixed up veto/hidden path processing so the paths are pres-parsed and checked for wildcards (for speed). Jeremy (jallison@whistle.com) (This used to be commit 9afa36f7874cfd527aa6ef1e7965c1d35d46ab1f)
Diffstat (limited to 'source3/smbd')
-rw-r--r--source3/smbd/dir.c32
-rw-r--r--source3/smbd/quotas.c4
-rw-r--r--source3/smbd/reply.c20
-rw-r--r--source3/smbd/server.c65
-rw-r--r--source3/smbd/trans2.c2
5 files changed, 73 insertions, 50 deletions
diff --git a/source3/smbd/dir.c b/source3/smbd/dir.c
index 2a219e0281..5bd5b1d573 100644
--- a/source3/smbd/dir.c
+++ b/source3/smbd/dir.c
@@ -108,18 +108,20 @@ static void dptr_idleoldest(void)
/****************************************************************************
get the dir ptr for a dir index
****************************************************************************/
-static void *dptr_get(int snum, int key,uint32 lastused)
+static void *dptr_get(int key,uint32 lastused)
{
- if (dirptrs[key].valid) {
- if (lastused) dirptrs[key].lastused = lastused;
- if (!dirptrs[key].ptr) {
+ struct dptr_struct *dp = &dirptrs[key];
+
+ if (dp->valid) {
+ if (lastused) dp->lastused = lastused;
+ if (!dp->ptr) {
if (dptrs_open >= MAXDIR)
dptr_idleoldest();
DEBUG(4,("Reopening dptr key %d\n",key));
- if ((dirptrs[key].ptr = OpenDir(snum, dirptrs[key].path, True)))
+ if ((dp->ptr = OpenDir(dp->cnum, dp->path, True)))
dptrs_open++;
}
- return(dirptrs[key].ptr);
+ return(dp->ptr);
}
return(NULL);
}
@@ -259,7 +261,7 @@ static BOOL start_dir(int cnum,char *directory)
if (! *directory)
directory = ".";
- Connections[cnum].dirptr = OpenDir(SNUM(cnum), directory, True);
+ Connections[cnum].dirptr = OpenDir(cnum, directory, True);
if (Connections[cnum].dirptr) {
dptrs_open++;
string_set(&Connections[cnum].dirpath,directory);
@@ -345,10 +347,10 @@ int dptr_create(int cnum,char *path, BOOL expect_close,int pid)
/****************************************************************************
fill the 5 byte server reserved dptr field
****************************************************************************/
-BOOL dptr_fill(int snum, char *buf1,unsigned int key)
+BOOL dptr_fill(char *buf1,unsigned int key)
{
unsigned char *buf = (unsigned char *)buf1;
- void *p = dptr_get(snum, key,0);
+ void *p = dptr_get(key,0);
uint32 offset;
if (!p) {
DEBUG(1,("filling null dirptr %d\n",key));
@@ -373,10 +375,10 @@ BOOL dptr_zero(char *buf)
/****************************************************************************
fetch the dir ptr and seek it given the 5 byte server field
****************************************************************************/
-void *dptr_fetch(int snum, char *buf,int *num)
+void *dptr_fetch(char *buf,int *num)
{
unsigned int key = *(unsigned char *)buf;
- void *p = dptr_get(snum, key,dircounter++);
+ void *p = dptr_get(key,dircounter++);
uint32 offset;
if (!p) {
DEBUG(3,("fetched null dirptr %d\n",key));
@@ -393,9 +395,9 @@ void *dptr_fetch(int snum, char *buf,int *num)
/****************************************************************************
fetch the dir ptr and seek it given the lanman2 parameter block
****************************************************************************/
-void *dptr_fetch_lanman2(int snum, char *params,int dptr_num)
+void *dptr_fetch_lanman2(char *params,int dptr_num)
{
- void *p = dptr_get(snum, dptr_num,dircounter++);
+ void *p = dptr_get(dptr_num,dircounter++);
uint32 resume_key = SVAL(params,6);
BOOL uses_resume_key = BITSETW(params+10,2);
BOOL continue_bit = BITSETW(params+10,3);
@@ -520,7 +522,7 @@ typedef struct
/*******************************************************************
open a directory
********************************************************************/
-void *OpenDir(int snum, char *name, BOOL use_veto)
+void *OpenDir(int cnum, char *name, BOOL use_veto)
{
Dir *dirp;
char *n;
@@ -541,7 +543,7 @@ void *OpenDir(int snum, char *name, BOOL use_veto)
int l = strlen(n)+1;
/* If it's a vetoed file, pretend it doesn't even exist */
- if (use_veto && is_vetoed_name(snum, n)) continue;
+ if (use_veto && IS_VETO_PATH(cnum, n)) continue;
if (used + l > dirp->mallocsize) {
int s = MAX(used+l,used+2000);
diff --git a/source3/smbd/quotas.c b/source3/smbd/quotas.c
index 8cbe46d9e1..883c2c050d 100644
--- a/source3/smbd/quotas.c
+++ b/source3/smbd/quotas.c
@@ -331,8 +331,8 @@ BOOL disk_quotas(char *path, int *bsize, int *dfree, int *dsize)
ret = quotactl(Q_GETQUOTA, name, euser_id, &D);
#endif
- setuid(user_id); /* Restore the original UID status */
- seteuid(euser_id);
+ seteuid(euser_id); /* Restore the original uid status. */
+ setuid(user_id);
if (ret < 0) {
DEBUG(2,("disk_quotas ioctl (Solaris) failed\n"));
diff --git a/source3/smbd/reply.c b/source3/smbd/reply.c
index 5869588664..374a01b665 100644
--- a/source3/smbd/reply.c
+++ b/source3/smbd/reply.c
@@ -771,7 +771,7 @@ int reply_search(char *inbuf,char *outbuf)
memcpy(mask,status+1,11);
mask[11] = 0;
dirtype = CVAL(status,0) & 0x1F;
- Connections[cnum].dirptr = dptr_fetch(SNUM(cnum), status+12,&dptr_num);
+ Connections[cnum].dirptr = dptr_fetch(status+12,&dptr_num);
if (!Connections[cnum].dirptr)
goto SearchEmpty;
string_set(&Connections[cnum].dirpath,dptr_path(dptr_num));
@@ -836,7 +836,7 @@ int reply_search(char *inbuf,char *outbuf)
{
memcpy(p,status,21);
make_dir_struct(p,"???????????",volume_label(SNUM(cnum)),0,aVOLID,0);
- dptr_fill(SNUM(cnum), p+12,dptr_num);
+ dptr_fill(p+12,dptr_num);
if (dptr_zero(p+12) && (status_len==0))
numentries = 1;
else
@@ -858,7 +858,7 @@ int reply_search(char *inbuf,char *outbuf)
{
memcpy(p,status,21);
make_dir_struct(p,mask,fname,size,mode,date);
- dptr_fill(SNUM(cnum), p+12,dptr_num);
+ dptr_fill(p+12,dptr_num);
numentries++;
}
p += DIR_STRUCT_SIZE;
@@ -941,7 +941,7 @@ int reply_fclose(char *inbuf,char *outbuf)
memcpy(status,smb_buf(inbuf) + 1 + strlen(path) + 4,21);
- if(dptr_fetch(SNUM(cnum), status+12,&dptr_num)) {
+ if(dptr_fetch(status+12,&dptr_num)) {
/* Close the dptr - we know it's gone */
dptr_close(dptr_num);
}
@@ -1323,7 +1323,7 @@ int reply_unlink(char *inbuf,char *outbuf)
char *dname;
if (check_name(directory,cnum))
- dirptr = OpenDir(SNUM(cnum), directory, True);
+ dirptr = OpenDir(cnum, directory, True);
/* XXXX the CIFS spec says that if bit0 of the flags2 field is set then
the pattern matches against the long name, otherwise the short name
@@ -2457,7 +2457,7 @@ int reply_rmdir(char *inbuf,char *outbuf)
do a recursive delete) then fail the rmdir. */
BOOL all_veto_files = True;
char *dname;
- void *dirptr = OpenDir(SNUM(cnum), directory, False);
+ void *dirptr = OpenDir(cnum, directory, False);
if(dirptr != NULL)
{
@@ -2466,7 +2466,7 @@ int reply_rmdir(char *inbuf,char *outbuf)
{
if((strcmp(dname, ".") == 0) || (strcmp(dname, "..")==0))
continue;
- if(!is_vetoed_name(SNUM(cnum), dname))
+ if(!IS_VETO_PATH(cnum, dname))
{
all_veto_files = False;
break;
@@ -2733,7 +2733,7 @@ int reply_mv(char *inbuf,char *outbuf)
pstring destname;
if (check_name(directory,cnum))
- dirptr = OpenDir(SNUM(cnum), directory, True);
+ dirptr = OpenDir(cnum, directory, True);
if (dirptr)
{
@@ -2924,7 +2924,7 @@ int reply_copy(char *inbuf,char *outbuf)
pstring destname;
if (check_name(directory,cnum))
- dirptr = OpenDir(SNUM(cnum), directory, True);
+ dirptr = OpenDir(cnum, directory, True);
if (dirptr)
{
@@ -3105,7 +3105,7 @@ int reply_readbmpx(char *inbuf,char *outbuf,int length,int bufsize)
mincount = SVAL(inbuf,smb_vwv4);
data = smb_buf(outbuf);
- pad = ((int)data)%4;
+ pad = ((long)data)%4;
if (pad) pad = 4 - pad;
data += pad;
diff --git a/source3/smbd/server.c b/source3/smbd/server.c
index 3c5cd6bea7..30a3027de9 100644
--- a/source3/smbd/server.c
+++ b/source3/smbd/server.c
@@ -226,7 +226,7 @@ int dos_mode(int cnum,char *path,struct stat *sbuf)
/* Optimization : Only call is_hidden_path if it's not already
hidden. */
- if (!(result & aHIDDEN) && is_hidden_path(SNUM(cnum), path))
+ if (!(result & aHIDDEN) && IS_HIDDEN_PATH(cnum,path))
{
result |= aHIDDEN;
}
@@ -358,7 +358,7 @@ scan a directory to find a filename, matching without case sensitivity
If the name looks like a mangled name then try via the mangling functions
****************************************************************************/
-static BOOL scan_directory(char *path, char *name,int snum,BOOL docache)
+static BOOL scan_directory(char *path, char *name,int cnum,BOOL docache)
{
void *cur_dir;
char *dname;
@@ -371,7 +371,7 @@ static BOOL scan_directory(char *path, char *name,int snum,BOOL docache)
if (*path == 0)
path = ".";
- if (docache && (dname = DirCacheCheck(path,name,snum))) {
+ if (docache && (dname = DirCacheCheck(path,name,SNUM(cnum)))) {
strcpy(name, dname);
return(True);
}
@@ -380,7 +380,7 @@ static BOOL scan_directory(char *path, char *name,int snum,BOOL docache)
check_mangled_stack(name);
/* open the directory */
- if (!(cur_dir = OpenDir(snum, path, True)))
+ if (!(cur_dir = OpenDir(cnum, path, True)))
{
DEBUG(3,("scan dir didn't open dir [%s]\n",path));
return(False);
@@ -394,13 +394,13 @@ static BOOL scan_directory(char *path, char *name,int snum,BOOL docache)
continue;
strcpy(name2,dname);
- if (!name_map_mangle(name2,False,snum)) continue;
+ if (!name_map_mangle(name2,False,SNUM(cnum))) continue;
if ((mangled && mangled_equal(name,name2))
|| fname_equal(name, dname))
{
/* we've found the file, change it's name and return */
- if (docache) DirCacheAdd(path,name,dname,snum);
+ if (docache) DirCacheAdd(path,name,dname,SNUM(cnum));
strcpy(name, dname);
CloseDir(cur_dir);
return(True);
@@ -533,7 +533,7 @@ BOOL unix_convert(char *name,int cnum,pstring saved_last_component)
/* try to find this part of the path in the directory */
if (strchr(start,'?') || strchr(start,'*') ||
- !scan_directory(dirpath, start, SNUM(cnum), end?True:False))
+ !scan_directory(dirpath, start, cnum, end?True:False))
{
if (end)
{
@@ -810,7 +810,7 @@ BOOL check_name(char *name,int cnum)
errno = 0;
- if( is_vetoed_name(SNUM(cnum), name))
+ if( IS_VETO_PATH(cnum, name))
{
DEBUG(5,("file path name %s vetoed\n",name));
return(0);
@@ -2485,6 +2485,8 @@ int make_connection(char *service,char *user,char *password, int pwlen, char *de
pcon->printer = (strncmp(dev,"LPT",3) == 0);
pcon->ipc = (strncmp(dev,"IPC",3) == 0);
pcon->dirptr = NULL;
+ pcon->veto_list = NULL;
+ pcon->hide_list = NULL;
string_set(&pcon->dirpath,"");
string_set(&pcon->user,user);
@@ -2627,6 +2629,13 @@ int make_connection(char *service,char *user,char *password, int pwlen, char *de
/* we've finished with the sensitive stuff */
unbecome_user();
+ /* Add veto/hide lists */
+ if (!IS_IPC(cnum) && !IS_PRINT(cnum))
+ {
+ set_namearray( &pcon->veto_list, lp_veto_files(SNUM(cnum)));
+ set_namearray( &pcon->hide_list, lp_hide_files(SNUM(cnum)));
+ }
+
{
DEBUG(IS_IPC(cnum)?3:1,("%s %s (%s) connect to service %s as user %s (uid=%d,gid=%d) (pid %d)\n",
timestring(),
@@ -3176,6 +3185,9 @@ void close_cnum(int cnum, uint16 vuid)
Connections[cnum].ngroups = 0;
}
+ free_namearray(Connections[cnum].veto_list);
+ free_namearray(Connections[cnum].hide_list);
+
string_set(&Connections[cnum].user,"");
string_set(&Connections[cnum].dirpath,"");
string_set(&Connections[cnum].connectpath,"");
@@ -3440,22 +3452,28 @@ void exit_server(char *reason)
/****************************************************************************
do some standard substitutions in a string
****************************************************************************/
-void standard_sub(int cnum,char *s)
+void standard_sub(int cnum,char *string)
{
- if (!strchr(s,'%')) return;
-
- if (VALID_CNUM(cnum))
- {
- string_sub(s,"%S",lp_servicename(Connections[cnum].service));
- string_sub(s,"%P",Connections[cnum].connectpath);
- string_sub(s,"%u",Connections[cnum].user);
- if (strstr(s,"%H")) {
- char *home = get_home_dir(Connections[cnum].user);
- if (home) string_sub(s,"%H",home);
+ if (VALID_CNUM(cnum)) {
+ char *p, *s, *home;
+
+ for ( s=string ; (p=strchr(s, '%')) != NULL ; s=p ) {
+ switch (*(p+1)) {
+ case 'H' : if ((home = get_home_dir(Connections[cnum].user))!=NULL)
+ string_sub(p,"%H",home);
+ else
+ p += 2;
+ break;
+ case 'P' : string_sub(p,"%P",Connections[cnum].connectpath); break;
+ case 'S' : string_sub(p,"%S",lp_servicename(Connections[cnum].service)); break;
+ case 'g' : string_sub(p,"%g",gidtoname(Connections[cnum].gid)); break;
+ case 'u' : string_sub(p,"%u",Connections[cnum].user); break;
+ case '\0' : p++; break; /* don't run off the end of the string */
+ default : p+=2; break;
}
- string_sub(s,"%g",gidtoname(Connections[cnum].gid));
}
- standard_sub_basic(s);
+ }
+ standard_sub_basic(string);
}
/*
@@ -4267,7 +4285,10 @@ static void usage(char *pname)
char buf[20];
if ((fd = open(pidFile,
- O_NONBLOCK | O_CREAT | O_WRONLY | O_TRUNC, 0644)) < 0)
+#ifdef O_NONBLOCK
+ O_NONBLOCK |
+#endif
+ O_CREAT | O_WRONLY | O_TRUNC, 0644)) < 0)
{
DEBUG(0,("ERROR: can't open %s: %s\n", pidFile, strerror(errno)));
exit(1);
diff --git a/source3/smbd/trans2.c b/source3/smbd/trans2.c
index 1b199f01ba..11a2a50ffe 100644
--- a/source3/smbd/trans2.c
+++ b/source3/smbd/trans2.c
@@ -782,7 +782,7 @@ static int call_trans2findnext(char *inbuf, char *outbuf, int length, int bufsiz
return(ERROR(ERRDOS,ERRnomem));
/* Check that the dptr is valid */
- if(!(Connections[cnum].dirptr = dptr_fetch_lanman2(SNUM(cnum), params, dptr_num)))
+ if(!(Connections[cnum].dirptr = dptr_fetch_lanman2(params, dptr_num)))
return(ERROR(ERRDOS,ERRnofiles));
string_set(&Connections[cnum].dirpath,dptr_path(dptr_num));