diff options
Diffstat (limited to 'source3/smbd')
-rw-r--r-- | source3/smbd/dir.c | 4 | ||||
-rw-r--r-- | source3/smbd/ipc.c | 8 | ||||
-rw-r--r-- | source3/smbd/negprot.c | 6 | ||||
-rw-r--r-- | source3/smbd/reply.c | 10 | ||||
-rw-r--r-- | source3/smbd/server.c | 12 | ||||
-rw-r--r-- | source3/smbd/service.c | 14 | ||||
-rw-r--r-- | source3/smbd/srvstr.c | 41 | ||||
-rw-r--r-- | source3/smbd/trans2.c | 34 | ||||
-rw-r--r-- | source3/smbd/vfs.c | 74 |
9 files changed, 121 insertions, 82 deletions
diff --git a/source3/smbd/dir.c b/source3/smbd/dir.c index 6cf56fd373..3f29ac892c 100644 --- a/source3/smbd/dir.c +++ b/source3/smbd/dir.c @@ -627,8 +627,8 @@ BOOL get_dir_entry(connection_struct *conn,char *mask,int dirtype, pstring fname see masktest for a demo */ if ((strcmp(mask,"*.*") == 0) || - mask_match(filename,mask,False) || - mangle_mask_match(conn,filename,mask)) { + mask_match(filename,mask,False) || + mangle_mask_match(conn,filename,mask)) { if (isrootdir && (strequal(filename,"..") || strequal(filename,"."))) continue; diff --git a/source3/smbd/ipc.c b/source3/smbd/ipc.c index 85e28f5d17..c8bb0c2505 100644 --- a/source3/smbd/ipc.c +++ b/source3/smbd/ipc.c @@ -138,9 +138,9 @@ void send_trans_reply(char *outbuf, set_message(outbuf,10,1+this_ldata+this_lparam+align,False); copy_trans_params_and_data(outbuf, align, - rparam, tot_param_sent, this_lparam, - rdata, tot_data_sent, this_ldata); - + rparam, tot_param_sent, this_lparam, + rdata, tot_data_sent, this_ldata); + SSVAL(outbuf,smb_vwv3,this_lparam); SSVAL(outbuf,smb_vwv4,smb_offset(smb_buf(outbuf)+1,outbuf)); SSVAL(outbuf,smb_vwv5,tot_param_sent); @@ -410,7 +410,7 @@ int reply_trans(connection_struct *conn, char *inbuf,char *outbuf, int size, int } if (suwcnt) { - unsigned int i; + int i; if((setup = (uint16 *)malloc(suwcnt*sizeof(uint16))) == NULL) { DEBUG(0,("reply_trans: setup malloc fail for %u bytes !\n", (unsigned int)(suwcnt * sizeof(uint16)))); SAFE_FREE(data); diff --git a/source3/smbd/negprot.c b/source3/smbd/negprot.c index db0694a840..c8f023514e 100644 --- a/source3/smbd/negprot.c +++ b/source3/smbd/negprot.c @@ -167,7 +167,7 @@ static int reply_lanman2(char *inbuf, char *outbuf) static int negprot_spnego(char *p) { DATA_BLOB blob; - uint8 guid[17]; + uint8 guid[16]; const char *OIDs_krb5[] = {OID_KERBEROS5, OID_KERBEROS5_OLD, OID_NTLMSSP, @@ -178,8 +178,8 @@ static int negprot_spnego(char *p) global_spnego_negotiated = True; - ZERO_STRUCT(guid); - safe_strcpy((char *)guid, global_myname(), sizeof(guid)-1); + memset(guid, 0, 16); + safe_strcpy((char *)guid, global_myname(), 16); strlower((char *)guid); #if 0 diff --git a/source3/smbd/reply.c b/source3/smbd/reply.c index 138870453d..ff1c0e5a52 100644 --- a/source3/smbd/reply.c +++ b/source3/smbd/reply.c @@ -87,8 +87,8 @@ int reply_special(char *inbuf,char *outbuf) name2[15] = 0; } - set_local_machine_name(name1, True); - set_remote_machine_name(name2, True); + set_local_machine_name(name1); + set_remote_machine_name(name2); DEBUG(2,("netbios connect: local=%s remote=%s\n", get_local_machine_name(), get_remote_machine_name() )); @@ -148,7 +148,7 @@ int reply_tcon(connection_struct *conn, const char *service; pstring service_buf; pstring password; - fstring dev; + pstring dev; int outsize = 0; uint16 vuid = SVAL(inbuf,smb_uid); int pwlen=0; @@ -161,7 +161,7 @@ int reply_tcon(connection_struct *conn, *service_buf = *password = *dev = 0; p = smb_buf(inbuf)+1; - p += srvstr_pull_buf(inbuf, service_buf, p, sizeof(service_buf), STR_TERMINATE) + 1; + p += srvstr_pull_buf(inbuf, service_buf, p, sizeof(service), STR_TERMINATE) + 1; pwlen = srvstr_pull_buf(inbuf, password, p, sizeof(password), STR_TERMINATE) + 1; p += pwlen; p += srvstr_pull_buf(inbuf, dev, p, sizeof(dev), STR_TERMINATE) + 1; @@ -204,7 +204,7 @@ int reply_tcon_and_X(connection_struct *conn, char *inbuf,char *outbuf,int lengt { fstring service; DATA_BLOB password; - fstring devicename; + pstring devicename; NTSTATUS nt_status; uint16 vuid = SVAL(inbuf,smb_uid); int passlen = SVAL(inbuf,smb_vwv3); diff --git a/source3/smbd/server.c b/source3/smbd/server.c index aff402df66..f8bfe90ea9 100644 --- a/source3/smbd/server.c +++ b/source3/smbd/server.c @@ -398,7 +398,7 @@ static BOOL open_sockets_smbd(BOOL is_daemon, BOOL interactive, const char *smb_ /* this is needed so that we get decent entries in smbstatus for port 445 connects */ - set_remote_machine_name(get_socket_addr(smbd_server_fd()), False); + set_remote_machine_name(get_socket_addr(smbd_server_fd())); /* Reset global variables in util.c so that client substitutions will be @@ -411,9 +411,6 @@ static BOOL open_sockets_smbd(BOOL is_daemon, BOOL interactive, const char *smb_ return False; } - /* Load DSO's */ - init_modules(); - return True; } /* The parent doesn't need this socket */ @@ -706,7 +703,7 @@ static BOOL init_structs(void ) load_case_tables(); - set_remote_machine_name("smbd", False); + set_remote_machine_name("smbd"); if (interactive) { Fork = False; @@ -894,10 +891,6 @@ static BOOL init_structs(void ) if (!init_change_notify()) exit(1); - /* Setup privileges database */ - if (!privilege_init()) - exit(1); - /* re-initialise the timezone */ TimeInit(); @@ -907,7 +900,6 @@ static BOOL init_structs(void ) smbd_process(); uni_group_cache_shutdown(); - namecache_shutdown(); exit_server("normal exit"); return(0); } diff --git a/source3/smbd/service.c b/source3/smbd/service.c index dc471ab87e..1c7e4017b0 100644 --- a/source3/smbd/service.c +++ b/source3/smbd/service.c @@ -218,7 +218,7 @@ int find_service(fstring service) do some basic sainity checks on the share. This function modifies dev, ecode. ****************************************************************************/ -static NTSTATUS share_sanity_checks(int snum, fstring dev) +static NTSTATUS share_sanity_checks(int snum, pstring dev) { if (!lp_snum_ok(snum) || @@ -229,13 +229,13 @@ static NTSTATUS share_sanity_checks(int snum, fstring dev) /* you can only connect to the IPC$ service as an ipc device */ if (strequal(lp_fstype(snum), "IPC")) - fstrcpy(dev,"IPC"); + pstrcpy(dev,"IPC"); if (dev[0] == '?' || !dev[0]) { if (lp_print_ok(snum)) { - fstrcpy(dev,"LPT1:"); + pstrcpy(dev,"LPT1:"); } else { - fstrcpy(dev,"A:"); + pstrcpy(dev,"A:"); } } @@ -248,7 +248,7 @@ static NTSTATUS share_sanity_checks(int snum, fstring dev) /* Behave as a printer if we are supposed to */ if (lp_print_ok(snum) && (strcmp(dev, "A:") == 0)) { - fstrcpy(dev, "LPT1:"); + pstrcpy(dev, "LPT1:"); } return NT_STATUS_OK; @@ -326,7 +326,7 @@ static void set_admin_user(connection_struct *conn, gid_t *groups, size_t n_grou static connection_struct *make_connection_snum(int snum, user_struct *vuser, DATA_BLOB password, - fstring dev, NTSTATUS *status) + char *dev, NTSTATUS *status) { struct passwd *pass = NULL; BOOL guest = False; @@ -747,7 +747,7 @@ connection_struct *make_connection_with_chdir(const char *service_in, DATA_BLOB ****************************************************************************/ connection_struct *make_connection(const char *service_in, DATA_BLOB password, - fstring dev, uint16 vuid, NTSTATUS *status) + char *dev, uint16 vuid, NTSTATUS *status) { uid_t euid; user_struct *vuser = NULL; diff --git a/source3/smbd/srvstr.c b/source3/smbd/srvstr.c new file mode 100644 index 0000000000..36fecf5bd2 --- /dev/null +++ b/source3/smbd/srvstr.c @@ -0,0 +1,41 @@ +/* + Unix SMB/CIFS implementation. + server specific string routines + Copyright (C) Andrew Tridgell 2001 + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +*/ + +#include "includes.h" + +int srvstr_push(void *base_ptr, void *dest, const char *src, int dest_len, int flags) +{ + return push_string(base_ptr, dest, src, dest_len, flags); +} + +int srvstr_pull(void *base_ptr, char *dest, const void *src, int dest_len, int src_len, + int flags) +{ + return pull_string(base_ptr, dest, src, dest_len, src_len, flags); +} + +/* pull a string from the smb_buf part of a packet. In this case the + string can either be null terminated or it can be terminated by the + end of the smbbuf area +*/ +int srvstr_pull_buf(void *inbuf, char *dest, const void *src, int dest_len, int flags) +{ + return pull_string(inbuf, dest, src, dest_len, smb_bufrem(inbuf, src), flags); +} diff --git a/source3/smbd/trans2.c b/source3/smbd/trans2.c index 4129852f77..5d85cae907 100644 --- a/source3/smbd/trans2.c +++ b/source3/smbd/trans2.c @@ -1183,25 +1183,25 @@ resume_key = %d resume name = %s continue=%d level = %d\n", SeekDir(dirptr, current_pos); dname = ReadDirName(dirptr); if (dname) { - /* - * Remember, mangle_map is called by - * get_lanman2_dir_entry(), so the resume name - * could be mangled. Ensure we do the same - * here. - */ - + /* + * Remember, mangle_map is called by + * get_lanman2_dir_entry(), so the resume name + * could be mangled. Ensure we do the same + * here. + */ + /* make sure we get a copy that mangle_map can modify */ pstrcpy(dname_pstring, dname); mangle_map( dname_pstring, False, True, SNUM(conn)); - + if(strcsequal( resume_name, dname_pstring)) { - SeekDir(dirptr, current_pos+1); - DEBUG(7,("call_trans2findnext: got match at pos %d\n", current_pos+1 )); - break; - } + SeekDir(dirptr, current_pos+1); + DEBUG(7,("call_trans2findnext: got match at pos %d\n", current_pos+1 )); + break; } } + } /* * Scan forward from start if not found going backwards. @@ -1221,15 +1221,15 @@ resume_key = %d resume name = %s continue=%d level = %d\n", if(dname) { /* make sure we get a copy that mangle_map can modify */ - + pstrcpy(dname_pstring, dname); mangle_map(dname_pstring, False, True, SNUM(conn)); if(strcsequal( resume_name, dname_pstring)) { - SeekDir(dirptr, current_pos+1); - DEBUG(7,("call_trans2findnext: got match at pos %d\n", current_pos+1 )); - break; - } + SeekDir(dirptr, current_pos+1); + DEBUG(7,("call_trans2findnext: got match at pos %d\n", current_pos+1 )); + break; + } } } /* end for */ } /* end if current_pos */ diff --git a/source3/smbd/vfs.c b/source3/smbd/vfs.c index 3bbe8a737a..533c64b229 100644 --- a/source3/smbd/vfs.c +++ b/source3/smbd/vfs.c @@ -215,48 +215,54 @@ Proceeding in compatibility mode, new operations (since version #%d) will fallba BOOL smbd_vfs_init(connection_struct *conn) { - const char **vfs_objects; - char *vfs_module, *vfs_path; - unsigned int i; - unsigned int j = 0; + char **vfs_objects, *vfsobj, *vfs_module, *vfs_path; + int nobj, i; struct smb_vfs_handle_struct *handle; /* Normal share - initialise with disk access functions */ vfs_init_default(conn); - vfs_objects = lp_vfsobj(SNUM(conn)); /* Override VFS functions if 'vfs object' was specified*/ - if (!vfs_objects) - return True; - - for(i=0; i<SMB_VFS_OP_LAST; i++) { - vfs_opaque_ops[i].op = ((void**)&default_vfs_ops)[i]; - vfs_opaque_ops[i].type = i; - vfs_opaque_ops[i].layer = SMB_VFS_LAYER_OPAQUE; - } - - vfs_path = lp_vfs_path(SNUM(conn)); - - for (j=0; vfs_objects[j]; j++) { - conn->vfs_private = NULL; - handle = (struct smb_vfs_handle_struct *) smb_xmalloc(sizeof(smb_vfs_handle_struct)); - /* Loadable object file */ - handle->handle = NULL; - DLIST_ADD(conn->vfs_private, handle); - vfs_module = NULL; - if (vfs_path) { - asprintf(&vfs_module, "%s/%s", vfs_path, vfs_objects[j]); - } else { - asprintf(&vfs_module, "%s", vfs_objects[j]); + if (*lp_vfsobj(SNUM(conn))) { + vfsobj = NULL; + for(i=0; i<SMB_VFS_OP_LAST; i++) { + vfs_opaque_ops[i].op = ((void**)&default_vfs_ops)[i]; + vfs_opaque_ops[i].type = i; + vfs_opaque_ops[i].layer = SMB_VFS_LAYER_OPAQUE; } - if (!vfs_init_custom(conn, vfs_module)) { - DEBUG(0, ("smbd_vfs_init: vfs_init_custom failed for %s\n", vfs_module)); - SAFE_FREE(vfs_module); - DLIST_REMOVE(conn->vfs_private, handle); - SAFE_FREE(handle); - return False; + if (string_set(&vfsobj, lp_vfsobj(SNUM(conn)))) { + /* Parse passed modules specification to array of modules */ + set_first_token(vfsobj); + /* We are using default separators: ' \t\r\n' */ + vfs_objects = toktocliplist(&nobj, NULL); + if (vfs_objects) { + vfs_path = lp_vfs_path(SNUM(conn)); + conn->vfs_private = NULL; + for(i=nobj-1; i>=0; i--) { + handle = (struct smb_vfs_handle_struct *) smb_xmalloc(sizeof(smb_vfs_handle_struct)); + /* Loadable object file */ + handle->handle = NULL; + DLIST_ADD(conn->vfs_private, handle) + vfs_module = NULL; + if (vfs_path) { + asprintf(&vfs_module, "%s/%s", vfs_path, vfs_objects[i]); + } else { + asprintf(&vfs_module, "%s", vfs_objects[i]); + } + if (!vfs_init_custom(conn, vfs_module)) { + DEBUG(0, ("smbd_vfs_init: vfs_init_custom failed for %s\n", vfs_module)); + string_free(&vfsobj); + SAFE_FREE(vfs_module); + DLIST_REMOVE(conn->vfs_private, handle); + SAFE_FREE(handle); + return False; + } + SAFE_FREE(vfs_module); + } + } + string_free(&vfsobj); + return True; } - SAFE_FREE(vfs_module); } return True; } |