diff options
author | Jeremy Allison <jra@samba.org> | 1998-09-08 19:21:04 +0000 |
---|---|---|
committer | Jeremy Allison <jra@samba.org> | 1998-09-08 19:21:04 +0000 |
commit | 6e0c276ec8b918165a19b3dfc86bc7bef6d1f706 (patch) | |
tree | fb8c41b2af435269dbe4f5019d121b6572ad07d5 /source3/smbd | |
parent | 519a6d5f0ed0d81cf739394c1c8c305f8ae43c87 (diff) | |
download | samba-6e0c276ec8b918165a19b3dfc86bc7bef6d1f706.tar.gz samba-6e0c276ec8b918165a19b3dfc86bc7bef6d1f706.tar.bz2 samba-6e0c276ec8b918165a19b3dfc86bc7bef6d1f706.zip |
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.
(This used to be commit 0de01f45980c7bc261248a9cead972a8d8cbd594)
Diffstat (limited to 'source3/smbd')
-rw-r--r-- | source3/smbd/filename.c | 14 | ||||
-rw-r--r-- | source3/smbd/groupname.c | 5 | ||||
-rw-r--r-- | source3/smbd/mangle.c | 7 | ||||
-rw-r--r-- | source3/smbd/open.c | 49 | ||||
-rw-r--r-- | source3/smbd/reply.c | 6 |
5 files changed, 49 insertions, 32 deletions
diff --git a/source3/smbd/filename.c b/source3/smbd/filename.c index a88829de9d..0910e03ee3 100644 --- a/source3/smbd/filename.c +++ b/source3/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/source3/smbd/groupname.c b/source3/smbd/groupname.c index 75af12a47a..29236e2ca5 100644 --- a/source3/smbd/groupname.c +++ b/source3/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/source3/smbd/mangle.c b/source3/smbd/mangle.c index 0a3d3f54eb..f0d5a9d85c 100644 --- a/source3/smbd/mangle.c +++ b/source3/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/source3/smbd/open.c b/source3/smbd/open.c index e6289b1cdb..bd1ead6921 100644 --- a/source3/smbd/open.c +++ b/source3/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/source3/smbd/reply.c b/source3/smbd/reply.c index d7ab997010..3d537d8868 100644 --- a/source3/smbd/reply.c +++ b/source3/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 |