summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeremy Allison <jra@samba.org>1998-09-08 19:21:04 +0000
committerJeremy Allison <jra@samba.org>1998-09-08 19:21:04 +0000
commit0de01f45980c7bc261248a9cead972a8d8cbd594 (patch)
tree084034b768e200f54557d1266aea4193c90fb02f
parent46301b1d2161317f56049934a9e7b658447b2c76 (diff)
downloadsamba-0de01f45980c7bc261248a9cead972a8d8cbd594.tar.gz
Added back groupname map stuff removed by Andrew's "slash 'n' burn"
tactics :-). Protected by #ifdef until used. Fixed bug in fd_attempt_close() where a pointer to potentially free'd memory was returned. I hate that. Added "blocking locks" as a per-share option for performance testing. Changed is_mangled() so it will return true if called with a pathname and any component of the pathname was mangled (it was already attempting to do this, but not checking for a '/' as end-of-mangle). This should be a better fix for the wierd stat cache bug Andrew identified. Jeremy.
-rw-r--r--source/include/proto.h9
-rw-r--r--source/param/loadparm.c12
-rw-r--r--source/smbd/filename.c14
-rw-r--r--source/smbd/groupname.c5
-rw-r--r--source/smbd/mangle.c7
-rw-r--r--source/smbd/open.c49
-rw-r--r--source/smbd/reply.c6
7 files changed, 69 insertions, 33 deletions
diff --git a/source/include/proto.h b/source/include/proto.h
index a7581ced79a..862c11f350e 100644
--- a/source/include/proto.h
+++ b/source/include/proto.h
@@ -858,6 +858,7 @@ char *lp_passwordserver(void);
char *lp_name_resolve_order(void);
char *lp_workgroup(void);
char *lp_username_map(void);
+char *lp_groupname_map(void);
char *lp_logon_script(void);
char *lp_logon_path(void);
char *lp_logon_drive(void);
@@ -1019,6 +1020,7 @@ BOOL lp_recursive_veto_delete(int );
BOOL lp_dos_filetimes(int );
BOOL lp_dos_filetime_resolution(int );
BOOL lp_fake_dir_create_times(int );
+BOOL lp_blocking_locks(int );
int lp_create_mode(int );
int lp_force_create_mode(int );
int lp_dir_mode(int );
@@ -1742,6 +1744,11 @@ void file_chain_reset(void);
void file_chain_save(void);
void file_chain_restore(void);
+/*The following definitions come from smbd/groupname.c */
+
+void load_groupname_map(void);
+void map_gid_to_sid( gid_t gid, DOM_SID *psid);
+
/*The following definitions come from smbd/ipc.c */
int reply_trans(connection_struct *conn, char *inbuf,char *outbuf, int size, int bufsize);
@@ -1788,7 +1795,7 @@ int reply_nttrans(connection_struct *conn,
/*The following definitions come from smbd/open.c */
void fd_add_to_uid_cache(file_fd_struct *fd_ptr, uid_t u);
-int fd_attempt_close(file_fd_struct *fd_ptr);
+uint16 fd_attempt_close(file_fd_struct *fd_ptr);
void open_file_shared(files_struct *fsp,connection_struct *conn,char *fname,int share_mode,int ofun,
int mode,int oplock_request, int *Access,int *action);
int open_directory(files_struct *fsp,connection_struct *conn,
diff --git a/source/param/loadparm.c b/source/param/loadparm.c
index fe3cf2f06af..c8ab2d411bf 100644
--- a/source/param/loadparm.c
+++ b/source/param/loadparm.c
@@ -126,7 +126,9 @@ typedef struct
char *szDomainHostsallow;
char *szDomainHostsdeny;
char *szUsernameMap;
+#ifdef USING_GROUPNAME_MAP
char *szGroupnameMap;
+#endif /* USING_GROUPNAME_MAP */
char *szCharacterSet;
char *szLogonScript;
char *szLogonPath;
@@ -324,6 +326,7 @@ typedef struct
BOOL bDosFiletimes;
BOOL bDosFiletimeResolution;
BOOL bFakeDirCreateTimes;
+ BOOL bBlockingLocks;
char dummy[3]; /* for alignment */
} service;
@@ -415,6 +418,7 @@ static service sDefault =
False, /* bDosFiletimes */
False, /* bDosFiletimeResolution */
False, /* bFakeDirCreateTimes */
+ True, /* bBlockingLocks */
"" /* dummy */
};
@@ -582,6 +586,7 @@ static struct parm_struct parm_table[] =
{"time server", P_BOOL, P_GLOBAL, &Globals.bTimeServer, NULL, NULL, 0},
{"Tuning Options", P_SEP, P_SEPARATOR},
+ {"blocking locks", P_BOOL, P_LOCAL, &sDefault.bBlockingLocks, NULL, NULL, 0},
{"change notify timeout", P_INTEGER, P_GLOBAL, &Globals.change_notify_timeout, NULL, NULL, 0},
{"deadtime", P_INTEGER, P_GLOBAL, &Globals.deadtime, NULL, NULL, 0},
{"getwd cache", P_BOOL, P_GLOBAL, &use_getwd_cache, NULL, NULL, 0},
@@ -654,6 +659,9 @@ static struct parm_struct parm_table[] =
{"domain guest group",P_STRING, P_GLOBAL, &Globals.szDomainGuestGroup, NULL, NULL, 0},
{"domain admin users",P_STRING, P_GLOBAL, &Globals.szDomainAdminUsers, NULL, NULL, 0},
{"domain guest users",P_STRING, P_GLOBAL, &Globals.szDomainGuestUsers, NULL, NULL, 0},
+#ifdef USING_GROUPNAME_MAP
+ {"groupname map", P_STRING, P_GLOBAL, &Globals.szGroupnameMap, NULL, NULL, 0},
+#endif /* USING_GROUPNAME_MAP */
{"machine password timeout", P_INTEGER, P_GLOBAL, &Globals.machine_password_timeout, NULL, NULL, 0},
{"Logon Options", P_SEP, P_SEPARATOR},
@@ -1060,6 +1068,9 @@ FN_GLOBAL_STRING(lp_passwordserver,&Globals.szPasswordServer)
FN_GLOBAL_STRING(lp_name_resolve_order,&Globals.szNameResolveOrder)
FN_GLOBAL_STRING(lp_workgroup,&Globals.szWorkGroup)
FN_GLOBAL_STRING(lp_username_map,&Globals.szUsernameMap)
+#ifdef USING_GROUPNAME_MAP
+FN_GLOBAL_STRING(lp_groupname_map,&Globals.szGroupnameMap)
+#endif /* USING_GROUPNAME_MAP */
FN_GLOBAL_STRING(lp_logon_script,&Globals.szLogonScript)
FN_GLOBAL_STRING(lp_logon_path,&Globals.szLogonPath)
FN_GLOBAL_STRING(lp_logon_drive,&Globals.szLogonDrive)
@@ -1239,6 +1250,7 @@ FN_LOCAL_BOOL(lp_recursive_veto_delete,bDeleteVetoFiles)
FN_LOCAL_BOOL(lp_dos_filetimes,bDosFiletimes)
FN_LOCAL_BOOL(lp_dos_filetime_resolution,bDosFiletimeResolution)
FN_LOCAL_BOOL(lp_fake_dir_create_times,bFakeDirCreateTimes)
+FN_LOCAL_BOOL(lp_blocking_locks,bBlockingLocks)
FN_LOCAL_INTEGER(lp_create_mode,iCreate_mask)
FN_LOCAL_INTEGER(lp_force_create_mode,iCreate_force_mode)
diff --git a/source/smbd/filename.c b/source/smbd/filename.c
index a88829de9d6..0910e03ee34 100644
--- a/source/smbd/filename.c
+++ b/source/smbd/filename.c
@@ -339,7 +339,10 @@ BOOL unix_convert(char *name,connection_struct *conn,char *saved_last_component,
int saved_errno;
BOOL component_was_mangled = False;
BOOL name_has_wildcard = False;
+#if 0
+ /* Andrew's conservative code... JRA. */
extern char magic_char;
+#endif
*dirpath = 0;
*bad_path = False;
@@ -441,9 +444,20 @@ BOOL unix_convert(char *name,connection_struct *conn,char *saved_last_component,
if(strchr(start,'?') || strchr(start,'*'))
name_has_wildcard = True;
+ /*
+ * is_mangled() was changed to look at an entire pathname, not
+ * just a component. JRA.
+ */
+
+ if(is_mangled(start))
+ component_was_mangled = True;
+
+#if 0
+ /* Keep Andrew's conservative code around, just in case. JRA. */
/* this is an extremely conservative test for mangled names. */
if (strchr(start,magic_char))
component_was_mangled = True;
+#endif
/*
* Now we need to recursively match the name against the real
diff --git a/source/smbd/groupname.c b/source/smbd/groupname.c
index 75af12a47af..29236e2ca57 100644
--- a/source/smbd/groupname.c
+++ b/source/smbd/groupname.c
@@ -19,6 +19,8 @@
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
+#ifdef USING_GROUPNAME_MAP
+
#include "includes.h"
extern int DEBUGLEVEL;
extern DOM_SID global_machine_sid;
@@ -236,3 +238,6 @@ void map_gid_to_sid( gid_t gid, DOM_SID *psid)
return;
}
+#else /* USING_GROUPNAME_MAP */
+ void load_groupname_map(void) {;}
+#endif /* USING_GROUPNAME_MAP */
diff --git a/source/smbd/mangle.c b/source/smbd/mangle.c
index 0a3d3f54eb7..f0d5a9d85ca 100644
--- a/source/smbd/mangle.c
+++ b/source/smbd/mangle.c
@@ -272,7 +272,7 @@ static BOOL is_illegal_name( char *name )
/* ************************************************************************** **
* Return True if the name *could be* a mangled name.
*
- * Input: s - A file name.
+ * Input: s - A path name - in UNIX pathname format.
*
* Output: True if the name matches the pattern described below in the
* notes, else False.
@@ -281,7 +281,8 @@ static BOOL is_illegal_name( char *name )
* done separately. This function returns true if the name contains
* a magic character followed by excactly two characters from the
* basechars list (above), which in turn are followed either by the
- * nul (end of string) byte or a dot (extension).
+ * nul (end of string) byte or a dot (extension) or by a '/' (end of
+ * a directory name).
*
* ************************************************************************** **
*/
@@ -295,7 +296,7 @@ BOOL is_mangled( char *s )
magic = strchr( s, magic_char );
while( magic && magic[1] && magic[2] ) /* 3 chars, 1st is magic. */
{
- if( ('.' == magic[3] || !(magic[3])) /* Ends with '.' or nul? */
+ if( ('.' == magic[3] || '/' == magic[3] || !(magic[3])) /* Ends with '.' or nul or '/' ? */
&& isbasechar( toupper(magic[1]) ) /* is 2nd char basechar? */
&& isbasechar( toupper(magic[2]) ) ) /* is 3rd char basechar? */
return( True ); /* If all above, then true, */
diff --git a/source/smbd/open.c b/source/smbd/open.c
index e6289b1cdbc..bd1ead69218 100644
--- a/source/smbd/open.c
+++ b/source/smbd/open.c
@@ -145,40 +145,37 @@ static void fd_attempt_reopen(char *fname, int mode, file_fd_struct *fd_ptr)
fd support routines - attempt to close the file referenced by this fd.
Decrements the ref_count and returns it.
****************************************************************************/
-int fd_attempt_close(file_fd_struct *fd_ptr)
+uint16 fd_attempt_close(file_fd_struct *fd_ptr)
{
extern struct current_user current_user;
+ uint16 ret_ref = fd_ptr->ref_count;
-#ifdef LARGE_SMB_INO_T
DEBUG(3,("fd_attempt_close fd = %d, dev = %x, inode = %.0f, open_flags = %d, ref_count = %d.\n",
fd_ptr->fd, (unsigned int)fd_ptr->dev, (double)fd_ptr->inode,
fd_ptr->real_open_flags,
fd_ptr->ref_count));
-#else /* LARGE_SMB_INO_T */
- DEBUG(3,("fd_attempt_close fd = %d, dev = %x, inode = %lx, open_flags = %d, ref_count = %d.\n",
- fd_ptr->fd, (unsigned int)fd_ptr->dev, (unsigned long)fd_ptr->inode,
- fd_ptr->real_open_flags,
- fd_ptr->ref_count));
-#endif /* LARGE_SMB_INO_T */
- if(fd_ptr->ref_count > 0) {
- fd_ptr->ref_count--;
- if(fd_ptr->ref_count == 0) {
- if(fd_ptr->fd != -1)
- close(fd_ptr->fd);
- if(fd_ptr->fd_readonly != -1)
- close(fd_ptr->fd_readonly);
- if(fd_ptr->fd_writeonly != -1)
- close(fd_ptr->fd_writeonly);
- /*
- * Delete this fd_ptr.
- */
- fd_ptr_free(fd_ptr);
- } else {
- fd_remove_from_uid_cache(fd_ptr, (uid_t)current_user.uid);
- }
- }
- return fd_ptr->ref_count;
+ SMB_ASSERT(fd_ptr->ref_count != 0);
+
+ fd_ptr->ref_count--;
+ ret_ref = fd_ptr->ref_count;
+
+ if(fd_ptr->ref_count == 0) {
+ if(fd_ptr->fd != -1)
+ close(fd_ptr->fd);
+ if(fd_ptr->fd_readonly != -1)
+ close(fd_ptr->fd_readonly);
+ if(fd_ptr->fd_writeonly != -1)
+ close(fd_ptr->fd_writeonly);
+ /*
+ * Delete this fd_ptr.
+ */
+ fd_ptr_free(fd_ptr);
+ } else {
+ fd_remove_from_uid_cache(fd_ptr, (uid_t)current_user.uid);
+ }
+
+ return ret_ref;
}
/****************************************************************************
diff --git a/source/smbd/reply.c b/source/smbd/reply.c
index d7ab9970109..3d537d88681 100644
--- a/source/smbd/reply.c
+++ b/source/smbd/reply.c
@@ -1891,7 +1891,7 @@ int reply_lockread(connection_struct *conn, char *inbuf,char *outbuf, int length
data = smb_buf(outbuf) + 3;
if(!do_lock( fsp, conn, numtoread, startpos, F_RDLCK, &eclass, &ecode)) {
- if(ecode == ERRlock) {
+ if((ecode == ERRlock) && lp_blocking_locks(SNUM(conn))) {
/*
* A blocking lock was requested. Package up
* this smb into a queued request and push it
@@ -2485,7 +2485,7 @@ int reply_lock(connection_struct *conn,
fsp->fd_ptr->fd, fsp->fnum, offset, count));
if (!do_lock(fsp, conn, count, offset, F_WRLCK, &eclass, &ecode)) {
- if(ecode == ERRlock) {
+ if((ecode == ERRlock) && lp_blocking_locks(SNUM(conn))) {
/*
* A blocking lock was requested. Package up
* this smb into a queued request and push it
@@ -3618,7 +3618,7 @@ dev = %x, inode = %lx\n", fsp->fnum, (unsigned int)dev, (unsigned long)inode));
(int)offset, (int)count, fsp->fsp_name ));
if(!do_lock(fsp,conn,count,offset, ((locktype & 1) ? F_RDLCK : F_WRLCK),
&eclass, &ecode)) {
- if((ecode == ERRlock) && (lock_timeout != 0)) {
+ if((ecode == ERRlock) && (lock_timeout != 0) && lp_blocking_locks(SNUM(conn))) {
/*
* A blocking lock was requested. Package up
* this smb into a queued request and push it