summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSamba Release Account <samba-bugs@samba.org>1997-02-23 05:18:09 +0000
committerSamba Release Account <samba-bugs@samba.org>1997-02-23 05:18:09 +0000
commitdf42b0a7bcdaae96035ecb1d434a66735358fd95 (patch)
treea7d6b0e651b294a385b7524484beb54828bdf018
parentf71717efd03611459b90b6939f53410ebbacc303 (diff)
downloadsamba-df42b0a7bcdaae96035ecb1d434a66735358fd95.tar.gz
samba-df42b0a7bcdaae96035ecb1d434a66735358fd95.tar.bz2
samba-df42b0a7bcdaae96035ecb1d434a66735358fd95.zip
Makefile: Added cleandir target.
chgpasswd.c: Added patch from Roland Haag <haag@think.de> to allow password changes to be done more than once. loadparm.c: Added entries for the "directory mode/directory mask parameters". Changed default file mode to 644. proto.h: Added sys_gethostbyname. server.c: Added directory mode changes. system.c: Added sys_gethostbyname. trans2.c: Added NT_FILE_ATTRIBUTE_NORMAL patch from Roger Orr <rorr@csfp.csfb.com> trans2.h: Defined NT_FILE_ATTRIBUTE_NORMAL for above patch. util.c: Changes calls to gethostbyname to sys_gethostbyname. jra@cygnus.com (This used to be commit d8d8a7ee00971fca7a8d079bfb547af107df35a4)
-rw-r--r--source3/include/proto.h2
-rw-r--r--source3/include/trans2.h5
-rw-r--r--source3/lib/system.c42
-rw-r--r--source3/lib/util.c6
-rw-r--r--source3/param/loadparm.c7
-rw-r--r--source3/smbd/chgpasswd.c8
-rw-r--r--source3/smbd/server.c20
-rw-r--r--source3/smbd/trans2.c9
8 files changed, 81 insertions, 18 deletions
diff --git a/source3/include/proto.h b/source3/include/proto.h
index 5993e1d67b..2cd8cfe2a8 100644
--- a/source3/include/proto.h
+++ b/source3/include/proto.h
@@ -238,6 +238,7 @@ BOOL lp_map_system(int );
BOOL lp_delete_readonly(int );
BOOL lp_fake_oplocks(int );
int lp_create_mode(int );
+int lp_dir_mode(int );
int lp_max_connections(int );
int lp_defaultcase(int );
int lp_minprintspace(int );
@@ -762,6 +763,7 @@ int sys_rename(char *from, char *to);
int sys_chmod(char *fname,int mode);
int sys_chown(char *fname,int uid,int gid);
int sys_chroot(char *dname);
+struct hostent *sys_gethostbyname(char *name);
/*The following definitions come from testparm.c */
diff --git a/source3/include/trans2.h b/source3/include/trans2.h
index cc366ccaea..b99f1e6028 100644
--- a/source3/include/trans2.h
+++ b/source3/include/trans2.h
@@ -228,6 +228,11 @@ Byte offset Type name description
#define DIRLEN_GUESS (45+MAX(l1_achName,l2_achName))
+/* NT uses a FILE_ATTRIBUTE_NORMAL when no other attributes
+ are set. */
+
+#define NT_FILE_ATTRIBUTE_NORMAL 0x80
+
/* Function prototypes */
diff --git a/source3/lib/system.c b/source3/lib/system.c
index ac97449da2..86c4c28a59 100644
--- a/source3/lib/system.c
+++ b/source3/lib/system.c
@@ -146,7 +146,11 @@ 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 /* USE_WAITPID */
+ return wait4(pid, status, options, NULL);
+#endif /* USE_WAITPID */
}
/*******************************************************************
@@ -235,3 +239,41 @@ int sys_chroot(char *dname)
return(chroot(dname));
#endif
}
+
+/**************************************************************************
+A wrapper for gethostbyname() that tries avoids looking up hostnames
+in the root domain, which can cause dial-on-demand links to come up for no
+apparent reason.
+****************************************************************************/
+struct hostent *sys_gethostbyname(char *name)
+{
+ char query[256], hostname[256];
+ char *domain;
+
+ /* Does this name have any dots in it? If so, make no change */
+
+ if (strchr(name, '.'))
+ return(gethostbyname(name));
+
+ /* Get my hostname, which should have domain name
+ attached. If not, just do the gethostname on the
+ original string.
+ */
+
+ gethostname(hostname, sizeof(hostname) - 1);
+ hostname[sizeof(hostname) - 1] = 0;
+ if ((domain = strchr(hostname, '.')) == NULL)
+ return(gethostbyname(name));
+
+ /* Attach domain name to query and do modified query.
+ If names too large, just do gethostname on the
+ original string.
+ */
+
+ if((strlen(name) + strlen(domain)) >= sizeof(query))
+ return(gethostbyname(name));
+
+ sprintf(query, "%s%s", name, domain);
+ return(gethostbyname(query));
+}
+
diff --git a/source3/lib/util.c b/source3/lib/util.c
index a43de46c51..643c2fb7a5 100644
--- a/source3/lib/util.c
+++ b/source3/lib/util.c
@@ -3238,7 +3238,7 @@ struct hostent *Get_Hostbyname(char *name)
return(NULL);
}
- ret = gethostbyname(name2);
+ ret = sys_gethostbyname(name2);
if (ret != NULL)
{
free(name2);
@@ -3247,7 +3247,7 @@ struct hostent *Get_Hostbyname(char *name)
/* try with all lowercase */
strlower(name2);
- ret = gethostbyname(name2);
+ ret = sys_gethostbyname(name2);
if (ret != NULL)
{
free(name2);
@@ -3256,7 +3256,7 @@ struct hostent *Get_Hostbyname(char *name)
/* try with all uppercase */
strupper(name2);
- ret = gethostbyname(name2);
+ ret = sys_gethostbyname(name2);
if (ret != NULL)
{
free(name2);
diff --git a/source3/param/loadparm.c b/source3/param/loadparm.c
index 67e799a84d..672f1fe548 100644
--- a/source3/param/loadparm.c
+++ b/source3/param/loadparm.c
@@ -213,6 +213,7 @@ typedef struct
char *volume;
int iMinPrintSpace;
int iCreate_mode;
+ int iDir_mode;
int iMaxConnections;
int iDefaultCase;
BOOL bAlternatePerm;
@@ -286,7 +287,8 @@ static service sDefault =
NULL, /* writelist */
NULL, /* volume */
0, /* iMinPrintSpace */
- 0755, /* iCreate_mode */
+ 0644, /* iCreate_mode */
+ 0755, /* iDir_mode */
0, /* iMaxConnections */
CASE_LOWER, /* iDefaultCase */
False, /* bAlternatePerm */
@@ -479,6 +481,8 @@ struct parm_struct
{"min print space", P_INTEGER, P_LOCAL, &sDefault.iMinPrintSpace, NULL},
{"create mask", P_OCTAL, P_LOCAL, &sDefault.iCreate_mode, NULL},
{"create mode", P_OCTAL, P_LOCAL, &sDefault.iCreate_mode, NULL},
+ {"directory mask", P_OCTAL, P_LOCAL, &sDefault.iDir_mode, NULL},
+ {"directory mode", P_OCTAL, P_LOCAL, &sDefault.iDir_mode, NULL},
{"set directory", P_BOOLREV, P_LOCAL, &sDefault.bNo_set_dir, NULL},
{"status", P_BOOL, P_LOCAL, &sDefault.status, NULL},
{"hide dot files", P_BOOL, P_LOCAL, &sDefault.bHideDotFiles, NULL},
@@ -851,6 +855,7 @@ FN_LOCAL_BOOL(lp_delete_readonly,bDeleteReadonly)
FN_LOCAL_BOOL(lp_fake_oplocks,bFakeOplocks)
FN_LOCAL_INTEGER(lp_create_mode,iCreate_mode)
+FN_LOCAL_INTEGER(lp_dir_mode,iDir_mode)
FN_LOCAL_INTEGER(lp_max_connections,iMaxConnections)
FN_LOCAL_INTEGER(lp_defaultcase,iDefaultCase)
FN_LOCAL_INTEGER(lp_minprintspace,iMinPrintSpace)
diff --git a/source3/smbd/chgpasswd.c b/source3/smbd/chgpasswd.c
index 54b49edf13..883ad5214a 100644
--- a/source3/smbd/chgpasswd.c
+++ b/source3/smbd/chgpasswd.c
@@ -41,7 +41,7 @@ static int findpty(char **slave)
#ifdef SVR4
extern char *ptsname();
#else
- static char line[12] = "/dev/ptyXX";
+ static char line[12];
void *dirp;
char *dpname;
#endif
@@ -54,13 +54,17 @@ static int findpty(char **slave)
return (master);
}
#else
+ strcpy( line, "/dev/ptyXX" );
+
dirp = OpenDir("/dev");
if (!dirp) return(-1);
while ((dpname = ReadDirName(dirp)) != NULL) {
if (strncmp(dpname, "pty", 3) == 0 && strlen(dpname) == 5) {
+ DEBUG(3,("pty: try to open %s, line was %s\n", dpname, line ) );
line[8] = dpname[3];
line[9] = dpname[4];
if ((master = open(line, O_RDWR)) >= 0) {
+ DEBUG(3,("pty: opened %s\n", line ) );
line[5] = 't';
*slave = line;
CloseDir(dirp);
@@ -280,7 +284,7 @@ BOOL chat_with_program(char *passwordprogram,char *name,char *chatsequence)
kill(pid, SIGKILL); /* be sure to end this process */
return(False);
}
- if ((wpid = waitpid(pid, &wstat, 0)) < 0) {
+ if ((wpid = sys_waitpid(pid, &wstat, 0)) < 0) {
DEBUG(3,("The process is no longer waiting!\n\n"));
return(False);
}
diff --git a/source3/smbd/server.c b/source3/smbd/server.c
index 4f3ee0fd0b..09c8fccb5c 100644
--- a/source3/smbd/server.c
+++ b/source3/smbd/server.c
@@ -130,19 +130,21 @@ mode_t unix_mode(int cnum,int dosmode)
if ( !IS_DOS_READONLY(dosmode) )
result |= (S_IWUSR | S_IWGRP | S_IWOTH);
- if (IS_DOS_DIR(dosmode))
+ if (IS_DOS_DIR(dosmode)) {
result |= (S_IFDIR | S_IXUSR | S_IXGRP | S_IXOTH | S_IWUSR);
-
- if (MAP_ARCHIVE(cnum) && IS_DOS_ARCHIVE(dosmode))
- result |= S_IXUSR;
+ result &= (lp_dir_mode(SNUM(cnum)) | 0700);
+ } else {
+ if (MAP_ARCHIVE(cnum) && IS_DOS_ARCHIVE(dosmode))
+ result |= S_IXUSR;
- if (MAP_SYSTEM(cnum) && IS_DOS_SYSTEM(dosmode))
- result |= S_IXGRP;
+ if (MAP_SYSTEM(cnum) && IS_DOS_SYSTEM(dosmode))
+ result |= S_IXGRP;
- if (MAP_HIDDEN(cnum) && IS_DOS_HIDDEN(dosmode))
- result |= S_IXOTH;
+ if (MAP_HIDDEN(cnum) && IS_DOS_HIDDEN(dosmode))
+ result |= S_IXOTH;
- result &= CREATE_MODE(cnum);
+ result &= CREATE_MODE(cnum);
+ }
return(result);
}
diff --git a/source3/smbd/trans2.c b/source3/smbd/trans2.c
index d489978ab8..ab2fe88536 100644
--- a/source3/smbd/trans2.c
+++ b/source3/smbd/trans2.c
@@ -276,6 +276,7 @@ static int get_lanman2_dir_entry(int cnum,char *path_mask,int dirtype,int info_l
strequal(Connections[cnum].dirpath,".") ||
strequal(Connections[cnum].dirpath,"/"));
BOOL was_8_3;
+ int nt_extmode; /* Used for NT connections instead of mode */
*fname = 0;
*out_of_space = False;
@@ -357,6 +358,8 @@ static int get_lanman2_dir_entry(int cnum,char *path_mask,int dirtype,int info_l
name_map_mangle(fname,False,SNUM(cnum));
+ nt_extmode = mode ? mode : NT_FILE_ATTRIBUTE_NORMAL;
+
switch (info_level)
{
case 1:
@@ -440,7 +443,7 @@ static int get_lanman2_dir_entry(int cnum,char *path_mask,int dirtype,int info_l
put_long_date(p,mdate); p += 8;
SIVAL(p,0,size); p += 8;
SIVAL(p,0,size); p += 8;
- SIVAL(p,0,mode); p += 4;
+ SIVAL(p,0,nt_extmode); p += 4;
SIVAL(p,0,strlen(fname)); p += 4;
SIVAL(p,0,0); p += 4;
if (!was_8_3) {
@@ -468,7 +471,7 @@ static int get_lanman2_dir_entry(int cnum,char *path_mask,int dirtype,int info_l
put_long_date(p,mdate); p += 8;
SIVAL(p,0,size); p += 8;
SIVAL(p,0,size); p += 8;
- SIVAL(p,0,mode); p += 4;
+ SIVAL(p,0,nt_extmode); p += 4;
SIVAL(p,0,strlen(fname)); p += 4;
strcpy(p,fname);
p = pdata + len;
@@ -486,7 +489,7 @@ static int get_lanman2_dir_entry(int cnum,char *path_mask,int dirtype,int info_l
put_long_date(p,mdate); p += 8;
SIVAL(p,0,size); p += 8;
SIVAL(p,0,size); p += 8;
- SIVAL(p,0,mode); p += 4;
+ SIVAL(p,0,nt_extmode); p += 4;
SIVAL(p,0,strlen(fname)); p += 4;
SIVAL(p,0,0); p += 4;
strcpy(p,fname);