summaryrefslogtreecommitdiff
path: root/source3/smbd
diff options
context:
space:
mode:
authorSamba Release Account <samba-bugs@samba.org>1997-07-06 13:48:10 +0000
committerSamba Release Account <samba-bugs@samba.org>1997-07-06 13:48:10 +0000
commit1fe89d0b716ccd9fca4abe4daf89df063b38f4b3 (patch)
treea4ed41e49fcbed2c2901b98a1ad6cfa765631b7a /source3/smbd
parentee0acbe94c203e0ec5aa7fb09fb0a5a17ef8a31c (diff)
downloadsamba-1fe89d0b716ccd9fca4abe4daf89df063b38f4b3.tar.gz
samba-1fe89d0b716ccd9fca4abe4daf89df063b38f4b3.tar.bz2
samba-1fe89d0b716ccd9fca4abe4daf89df063b38f4b3.zip
added, tested and debugged new "hide files" option.
lkcl (This used to be commit 60af320a436c3a26230fd7ac71856e67ef64e819)
Diffstat (limited to 'source3/smbd')
-rw-r--r--source3/smbd/chgpasswd.c2
-rw-r--r--source3/smbd/dir.c28
-rw-r--r--source3/smbd/reply.c14
-rw-r--r--source3/smbd/server.c21
-rw-r--r--source3/smbd/trans2.c2
5 files changed, 43 insertions, 24 deletions
diff --git a/source3/smbd/chgpasswd.c b/source3/smbd/chgpasswd.c
index e0dd7fc0ae..79ea66253d 100644
--- a/source3/smbd/chgpasswd.c
+++ b/source3/smbd/chgpasswd.c
@@ -56,7 +56,7 @@ static int findpty(char **slave)
#else
strcpy( line, "/dev/ptyXX" );
- dirp = OpenDir("/dev", True);
+ dirp = OpenDir(-1, "/dev", True);
if (!dirp) return(-1);
while ((dpname = ReadDirName(dirp)) != NULL) {
if (strncmp(dpname, "pty", 3) == 0 && strlen(dpname) == 5) {
diff --git a/source3/smbd/dir.c b/source3/smbd/dir.c
index 1d0228864c..2a219e0281 100644
--- a/source3/smbd/dir.c
+++ b/source3/smbd/dir.c
@@ -108,7 +108,7 @@ static void dptr_idleoldest(void)
/****************************************************************************
get the dir ptr for a dir index
****************************************************************************/
-static void *dptr_get(int key,uint32 lastused)
+static void *dptr_get(int snum, int key,uint32 lastused)
{
if (dirptrs[key].valid) {
if (lastused) dirptrs[key].lastused = lastused;
@@ -116,7 +116,7 @@ static void *dptr_get(int key,uint32 lastused)
if (dptrs_open >= MAXDIR)
dptr_idleoldest();
DEBUG(4,("Reopening dptr key %d\n",key));
- if ((dirptrs[key].ptr = OpenDir(dirptrs[key].path, True)))
+ if ((dirptrs[key].ptr = OpenDir(snum, dirptrs[key].path, True)))
dptrs_open++;
}
return(dirptrs[key].ptr);
@@ -259,7 +259,7 @@ static BOOL start_dir(int cnum,char *directory)
if (! *directory)
directory = ".";
- Connections[cnum].dirptr = OpenDir(directory, True);
+ Connections[cnum].dirptr = OpenDir(SNUM(cnum), directory, True);
if (Connections[cnum].dirptr) {
dptrs_open++;
string_set(&Connections[cnum].dirpath,directory);
@@ -345,10 +345,10 @@ int dptr_create(int cnum,char *path, BOOL expect_close,int pid)
/****************************************************************************
fill the 5 byte server reserved dptr field
****************************************************************************/
-BOOL dptr_fill(char *buf1,unsigned int key)
+BOOL dptr_fill(int snum, char *buf1,unsigned int key)
{
unsigned char *buf = (unsigned char *)buf1;
- void *p = dptr_get(key,0);
+ void *p = dptr_get(snum, key,0);
uint32 offset;
if (!p) {
DEBUG(1,("filling null dirptr %d\n",key));
@@ -373,10 +373,10 @@ BOOL dptr_zero(char *buf)
/****************************************************************************
fetch the dir ptr and seek it given the 5 byte server field
****************************************************************************/
-void *dptr_fetch(char *buf,int *num)
+void *dptr_fetch(int snum, char *buf,int *num)
{
unsigned int key = *(unsigned char *)buf;
- void *p = dptr_get(key,dircounter++);
+ void *p = dptr_get(snum, key,dircounter++);
uint32 offset;
if (!p) {
DEBUG(3,("fetched null dirptr %d\n",key));
@@ -393,9 +393,9 @@ void *dptr_fetch(char *buf,int *num)
/****************************************************************************
fetch the dir ptr and seek it given the lanman2 parameter block
****************************************************************************/
-void *dptr_fetch_lanman2(char *params,int dptr_num)
+void *dptr_fetch_lanman2(int snum, char *params,int dptr_num)
{
- void *p = dptr_get(dptr_num,dircounter++);
+ void *p = dptr_get(snum, 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 +520,7 @@ typedef struct
/*******************************************************************
open a directory
********************************************************************/
-void *OpenDir(char *name, BOOL use_veto)
+void *OpenDir(int snum, char *name, BOOL use_veto)
{
Dir *dirp;
char *n;
@@ -536,11 +536,13 @@ void *OpenDir(char *name, BOOL use_veto)
dirp->pos = dirp->numentries = dirp->mallocsize = 0;
dirp->data = dirp->current = NULL;
- while ((n = readdirname(p))) {
+ while ((n = readdirname(p)))
+ {
int l = strlen(n)+1;
+
/* If it's a vetoed file, pretend it doesn't even exist */
- if(use_veto && is_vetoed_name(n))
- continue;
+ if (use_veto && is_vetoed_name(snum, n)) continue;
+
if (used + l > dirp->mallocsize) {
int s = MAX(used+l,used+2000);
char *r;
diff --git a/source3/smbd/reply.c b/source3/smbd/reply.c
index 5f030d5372..af980943ca 100644
--- a/source3/smbd/reply.c
+++ b/source3/smbd/reply.c
@@ -767,7 +767,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(status+12,&dptr_num);
+ Connections[cnum].dirptr = dptr_fetch(SNUM(cnum), status+12,&dptr_num);
if (!Connections[cnum].dirptr)
goto SearchEmpty;
string_set(&Connections[cnum].dirpath,dptr_path(dptr_num));
@@ -832,7 +832,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(p+12,dptr_num);
+ dptr_fill(SNUM(cnum), p+12,dptr_num);
if (dptr_zero(p+12) && (status_len==0))
numentries = 1;
else
@@ -854,7 +854,7 @@ int reply_search(char *inbuf,char *outbuf)
{
memcpy(p,status,21);
make_dir_struct(p,mask,fname,size,mode,date);
- dptr_fill(p+12,dptr_num);
+ dptr_fill(SNUM(cnum), p+12,dptr_num);
numentries++;
}
p += DIR_STRUCT_SIZE;
@@ -937,7 +937,7 @@ int reply_fclose(char *inbuf,char *outbuf)
memcpy(status,smb_buf(inbuf) + 1 + strlen(path) + 4,21);
- if(dptr_fetch(status+12,&dptr_num)) {
+ if(dptr_fetch(SNUM(cnum), status+12,&dptr_num)) {
/* Close the dptr - we know it's gone */
dptr_close(dptr_num);
}
@@ -1326,7 +1326,7 @@ int reply_unlink(char *inbuf,char *outbuf)
char *dname;
if (check_name(directory,cnum))
- dirptr = OpenDir(directory, True);
+ dirptr = OpenDir(SNUM(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
@@ -2736,7 +2736,7 @@ int reply_mv(char *inbuf,char *outbuf)
pstring destname;
if (check_name(directory,cnum))
- dirptr = OpenDir(directory, True);
+ dirptr = OpenDir(SNUM(cnum), directory, True);
if (dirptr)
{
@@ -2927,7 +2927,7 @@ int reply_copy(char *inbuf,char *outbuf)
pstring destname;
if (check_name(directory,cnum))
- dirptr = OpenDir(directory, True);
+ dirptr = OpenDir(SNUM(cnum), directory, True);
if (dirptr)
{
diff --git a/source3/smbd/server.c b/source3/smbd/server.c
index 30d8ce3d2a..0361c5aa46 100644
--- a/source3/smbd/server.c
+++ b/source3/smbd/server.c
@@ -179,6 +179,8 @@ int dos_mode(int cnum,char *path,struct stat *sbuf)
int result = 0;
extern struct current_user current_user;
+ DEBUG(5,("dos_mode: %d %s\n", cnum, path));
+
if (CAN_WRITE(cnum) && !lp_alternate_permissions(SNUM(cnum))) {
if (!((sbuf->st_mode & S_IWOTH) ||
Connections[cnum].admin_user ||
@@ -222,6 +224,21 @@ int dos_mode(int cnum,char *path,struct stat *sbuf)
result |= aHIDDEN;
}
+ if (is_hidden_path(SNUM(cnum), path))
+ {
+ result |= aHIDDEN;
+ }
+
+ DEBUG(5,("dos_mode returning "));
+
+ if (result & aHIDDEN) DEBUG(5, ("h"));
+ if (result & aRONLY ) DEBUG(5, ("r"));
+ if (result & aSYSTEM) DEBUG(5, ("s"));
+ if (result & aDIR ) DEBUG(5, ("d"));
+ if (result & aARCH ) DEBUG(5, ("a"));
+
+ DEBUG(5,("\n"));
+
return(result);
}
@@ -361,7 +378,7 @@ static BOOL scan_directory(char *path, char *name,int snum,BOOL docache)
check_mangled_stack(name);
/* open the directory */
- if (!(cur_dir = OpenDir(path, True)))
+ if (!(cur_dir = OpenDir(snum, path, True)))
{
DEBUG(3,("scan dir didn't open dir [%s]\n",path));
return(False);
@@ -791,7 +808,7 @@ BOOL check_name(char *name,int cnum)
errno = 0;
- if( is_vetoed_path(name))
+ if( is_vetoed_name(SNUM(cnum), name))
{
DEBUG(5,("file path name %s vetoed\n",name));
return(0);
diff --git a/source3/smbd/trans2.c b/source3/smbd/trans2.c
index 1f727c4ecd..6f8fe5121a 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(params, dptr_num)))
+ if(!(Connections[cnum].dirptr = dptr_fetch_lanman2(SNUM(cnum), params, dptr_num)))
return(ERROR(ERRDOS,ERRnofiles));
string_set(&Connections[cnum].dirpath,dptr_path(dptr_num));