diff options
Diffstat (limited to 'source3/smbd')
-rw-r--r-- | source3/smbd/build_options.c | 12 | ||||
-rw-r--r-- | source3/smbd/connection.c | 2 | ||||
-rw-r--r-- | source3/smbd/dir.c | 4 | ||||
-rw-r--r-- | source3/smbd/ipc.c | 6 | ||||
-rw-r--r-- | source3/smbd/process.c | 2 | ||||
-rw-r--r-- | source3/smbd/reply.c | 45 | ||||
-rw-r--r-- | source3/smbd/server.c | 17 | ||||
-rw-r--r-- | source3/smbd/service.c | 2 | ||||
-rw-r--r-- | source3/smbd/vfs.c | 218 |
9 files changed, 112 insertions, 196 deletions
diff --git a/source3/smbd/build_options.c b/source3/smbd/build_options.c index 43335666a6..da5accebab 100644 --- a/source3/smbd/build_options.c +++ b/source3/smbd/build_options.c @@ -104,6 +104,15 @@ void build_options(BOOL screen) #ifdef WITH_PAM output(screen," WITH_PAM\n"); #endif +#ifdef WITH_TDB_SAM + output(screen," WITH_TDB_SAM\n"); +#endif +#ifdef WITH_SMBPASSWD_SAM + output(screen," WITH_SMBPASSWD_SAM\n"); +#endif +#ifdef WITH_NISPLUS_SAM + output(screen," WITH_NISPLUS_SAM\n"); +#endif #ifdef WITH_NISPLUS_HOME output(screen," WITH_NISPLUS_HOME\n"); #endif @@ -523,9 +532,6 @@ void build_options(BOOL screen) output(screen," sizeof(uint32): %d\n",sizeof(uint32)); output(screen," sizeof(short): %d\n",sizeof(short)); output(screen," sizeof(void*): %d\n",sizeof(void*)); - - output(screen,"\nBuiltin modules:\n"); - output(screen,"%s\n", STRING_STATIC_MODULES); } diff --git a/source3/smbd/connection.c b/source3/smbd/connection.c index 5547309a81..17b5be8a7b 100644 --- a/source3/smbd/connection.c +++ b/source3/smbd/connection.c @@ -172,7 +172,7 @@ BOOL claim_connection(connection_struct *conn, const char *name,int max_connecti crec.uid = conn->uid; crec.gid = conn->gid; safe_strcpy(crec.name, - lp_servicename(SNUM(conn)),sizeof(crec.name)-1); + lp_servicename(SNUM(conn)),sizeof(crec.name)-1); } crec.start = time(NULL); crec.bcast_msg_flags = msg_flags; 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..c4a12ab531 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); diff --git a/source3/smbd/process.c b/source3/smbd/process.c index de1bea493f..16ef30c46c 100644 --- a/source3/smbd/process.c +++ b/source3/smbd/process.c @@ -44,7 +44,7 @@ extern userdom_struct current_user_info; extern int smb_read_error; SIG_ATOMIC_T reload_after_sighup = 0; SIG_ATOMIC_T got_sig_term = 0; -BOOL global_machine_password_needs_changing = False; +extern BOOL global_machine_password_needs_changing; extern int max_send; /**************************************************************************** diff --git a/source3/smbd/reply.c b/source3/smbd/reply.c index bf74d997b8..77f4c6783f 100644 --- a/source3/smbd/reply.c +++ b/source3/smbd/reply.c @@ -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; @@ -204,16 +204,21 @@ int reply_tcon_and_X(connection_struct *conn, char *inbuf,char *outbuf,int lengt { fstring service; DATA_BLOB password; - fstring devicename; + + /* what the cleint thinks the device is */ + fstring client_devicetype; + /* what the server tells the client the share represents */ + const char *server_devicetype; NTSTATUS nt_status; uint16 vuid = SVAL(inbuf,smb_uid); int passlen = SVAL(inbuf,smb_vwv3); pstring path; char *p, *q; extern BOOL global_encrypted_passwords_negotiated; + START_PROFILE(SMBtconX); - *service = *devicename = 0; + *service = *client_devicetype = 0; /* we might have to close an old one */ if ((SVAL(inbuf,smb_vwv2) & 0x1) && conn) { @@ -250,11 +255,11 @@ int reply_tcon_and_X(connection_struct *conn, char *inbuf,char *outbuf,int lengt else fstrcpy(service,path); - p += srvstr_pull(inbuf, devicename, p, sizeof(devicename), 6, STR_ASCII); + p += srvstr_pull(inbuf, client_devicetype, p, sizeof(client_devicetype), 6, STR_ASCII); - DEBUG(4,("Got device type %s\n",devicename)); + DEBUG(4,("Client requested device type [%s] for share [%s]\n", client_devicetype, service)); - conn = make_connection(service,password,devicename,vuid,&nt_status); + conn = make_connection(service,password,client_devicetype,vuid,&nt_status); data_blob_clear_free(&password); @@ -263,33 +268,27 @@ int reply_tcon_and_X(connection_struct *conn, char *inbuf,char *outbuf,int lengt return ERROR_NT(nt_status); } + if ( IS_IPC(conn) ) + server_devicetype = "IPC"; + else if ( IS_PRINT(conn) ) + server_devicetype = "LPT:"; + else + server_devicetype = "A:"; + if (Protocol < PROTOCOL_NT1) { set_message(outbuf,2,0,True); p = smb_buf(outbuf); - p += srvstr_push(outbuf, p, devicename, -1, + p += srvstr_push(outbuf, p, server_devicetype, -1, STR_TERMINATE|STR_ASCII); set_message_end(outbuf,p); } else { /* NT sets the fstype of IPC$ to the null string */ const char *fsname = IS_IPC(conn) ? "" : lp_fstype(SNUM(conn)); - const char *devicetype; - + set_message(outbuf,3,0,True); - - if ( IS_IPC(conn) ) - devicetype = "IPC"; - else if ( IS_PRINT(conn) ) - devicetype = "LPT:"; - else - devicetype = "A:"; - - p = smb_buf(outbuf); - p += srvstr_push(outbuf, p, IS_IPC(conn) ? "IPC" : devicetype, -1, - STR_TERMINATE|STR_ASCII); - p += srvstr_push(outbuf, p, fsname, -1, - STR_TERMINATE); + p = smb_buf(outbuf); - p += srvstr_push(outbuf, p, IS_IPC(conn) ? "IPC" : devicename, -1, + p += srvstr_push(outbuf, p, server_devicetype, -1, STR_TERMINATE|STR_ASCII); p += srvstr_push(outbuf, p, fsname, -1, STR_TERMINATE); diff --git a/source3/smbd/server.c b/source3/smbd/server.c index 7848e71db2..4a79916efe 100644 --- a/source3/smbd/server.c +++ b/source3/smbd/server.c @@ -3,7 +3,7 @@ Main SMB server routines Copyright (C) Andrew Tridgell 1992-1998 Copyright (C) Martin Pool 2002 - Copyright (C) Jelmer Vernooij 2002-2003 + Copyright (C) Jelmer Vernooij 2002 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 @@ -669,7 +669,11 @@ static BOOL init_structs(void ) {"log-stdout", 'S', POPT_ARG_VAL, &log_stdout, True, "Log to stdout" }, {"build-options", 'b', POPT_ARG_NONE, NULL, 'b', "Print build options" }, {"port", 'p', POPT_ARG_STRING, &ports, 0, "Listen on the specified ports"}, - POPT_COMMON_SAMBA + {NULL, 0, POPT_ARG_INCLUDE_TABLE, popt_common_debug}, + {NULL, 0, POPT_ARG_INCLUDE_TABLE, popt_common_configfile}, + {NULL, 0, POPT_ARG_INCLUDE_TABLE, popt_common_socket_options}, + {NULL, 0, POPT_ARG_INCLUDE_TABLE, popt_common_log_base}, + {NULL, 0, POPT_ARG_INCLUDE_TABLE, popt_common_version}, { NULL } }; @@ -859,10 +863,6 @@ static BOOL init_structs(void ) if(!initialize_password_db(False)) exit(1); - static_init_rpc; - - init_modules(); - uni_group_cache_init(); /* Non-critical */ /* possibly reload the services file. */ @@ -891,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(); @@ -904,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 f67361e66a..a5e1ec4e93 100644 --- a/source3/smbd/service.c +++ b/source3/smbd/service.c @@ -757,7 +757,7 @@ connection_struct *make_connection(const char *service_in, DATA_BLOB password, fstring service; fstring dev; int snum = -1; - + fstrcpy(dev, pdev); /* This must ONLY BE CALLED AS ROOT. As it exits this function as root. */ diff --git a/source3/smbd/vfs.c b/source3/smbd/vfs.c index a8b350b9cd..533c64b229 100644 --- a/source3/smbd/vfs.c +++ b/source3/smbd/vfs.c @@ -27,13 +27,6 @@ #undef DBGC_CLASS #define DBGC_CLASS DBGC_VFS -struct vfs_init_function_entry { - char *name; - vfs_op_tuple *ops, *(*init)(const struct vfs_ops *, struct smb_vfs_handle_struct *); - struct vfs_init_function_entry *prev, *next; -}; - -static struct vfs_init_function_entry *backends = NULL; /* Some structures to help us initialise the vfs operations table */ @@ -135,56 +128,6 @@ static struct vfs_ops default_vfs_ops = { }; /**************************************************************************** - maintain the list of available backends -****************************************************************************/ - -struct vfs_init_function_entry *vfs_find_backend_entry(const char *name) -{ - struct vfs_init_function_entry *entry = backends; - - while(entry) { - if (strequal(entry->name, name)) return entry; - entry = entry->next; - } - - return NULL; -} - -BOOL smb_register_vfs(const char *name, vfs_op_tuple *(*init)(const struct vfs_ops *, struct smb_vfs_handle_struct *), int version) -{ - struct vfs_init_function_entry *entry = backends; - - if ((version < SMB_VFS_INTERFACE_CASCADED)) { - DEBUG(0, ("vfs_init() returned wrong interface version info (was %d, should be no less than %d)\n", - version, SMB_VFS_INTERFACE_VERSION )); - return False; - } - - if ((version < SMB_VFS_INTERFACE_VERSION)) { - DEBUG(0, ("Warning: vfs_init() states that module confirms interface version #%d, current interface version is #%d.\n\ - Proceeding in compatibility mode, new operations (since version #%d) will fallback to default ones.\n", - version, SMB_VFS_INTERFACE_VERSION, version )); - return False; - } - - while(entry) { - if (strequal(entry->name, name)) { - DEBUG(0,("VFS module %s already loaded!\n", name)); - return False; - } - entry = entry->next; - } - - entry = smb_xmalloc(sizeof(struct vfs_init_function_entry)); - entry->name = smb_xstrdup(name); - entry->init = init; - - DLIST_ADD(backends, entry); - DEBUG(5, ("Successfully added vfs backend '%s'\n", name)); - return True; -} - -/**************************************************************************** initialise default vfs hooks ****************************************************************************/ @@ -196,14 +139,18 @@ static void vfs_init_default(connection_struct *conn) conn->vfs_private = NULL; } -/*************************************************************************** - Function to load old VFS modules. Should go away after a while. - **************************************************************************/ +/**************************************************************************** + initialise custom vfs hooks +****************************************************************************/ -static BOOL vfs_load_old_plugin(connection_struct *conn, const char *vfs_object) +BOOL vfs_init_custom(connection_struct *conn, const char *vfs_object) { int vfs_version = -1; - vfs_op_tuple *ops, *(*init_fptr)(int *, const struct vfs_ops *, struct smb_vfs_handle_struct *); + vfs_op_tuple *ops, *(*init_fptr)(int *, const struct vfs_ops *, struct smb_vfs_handle_struct *); + int i; + + DEBUG(3, ("Initialising custom vfs hooks from %s\n", vfs_object)); + /* Open object file */ if ((conn->vfs_private->handle = sys_dlopen(vfs_object, RTLD_NOW)) == NULL) { @@ -222,64 +169,27 @@ static BOOL vfs_load_old_plugin(connection_struct *conn, const char *vfs_object) } /* Initialise vfs_ops structure */ - if ((ops = init_fptr(&vfs_version, &conn->vfs_ops, conn->vfs_private)) == NULL) { - DEBUG(0, ("vfs_init() function from %s failed\n", vfs_object)); - sys_dlclose(conn->vfs_private->handle); - return False; - } - if ((vfs_version < SMB_VFS_INTERFACE_CASCADED)) { - DEBUG(0, ("vfs_init() returned wrong interface version info (was %d, should be no less than %d)\n", - vfs_version, SMB_VFS_INTERFACE_VERSION )); + if ((ops = init_fptr(&vfs_version, &conn->vfs_ops, conn->vfs_private)) == NULL) { + DEBUG(0, ("vfs_init() function from %s failed\n", vfs_object)); sys_dlclose(conn->vfs_private->handle); - return False; - } - - if ((vfs_version < SMB_VFS_INTERFACE_VERSION)) { - DEBUG(0, ("Warning: vfs_init() states that module confirms interface version #%d, current interface version is #%d.\n\ - Proceeding in compatibility mode, new operations (since version #%d) will fallback to default ones.\n", - vfs_version, SMB_VFS_INTERFACE_VERSION, vfs_version )); + return False; + } + + if ((vfs_version < SMB_VFS_INTERFACE_CASCADED)) { + DEBUG(0, ("vfs_init() returned wrong interface version info (was %d, should be no less than %d)\n", + vfs_version, SMB_VFS_INTERFACE_VERSION )); sys_dlclose(conn->vfs_private->handle); - return False; - } - - return True; -} - - - -/**************************************************************************** - initialise custom vfs hooks - ****************************************************************************/ - -BOOL vfs_init_custom(connection_struct *conn, const char *vfs_object) -{ - vfs_op_tuple *ops; - int i; - struct vfs_init_function_entry *entry; - - DEBUG(3, ("Initialising custom vfs hooks from %s\n", vfs_object)); - - if(!backends) static_init_vfs; - - /* First, try to load the module with the new module system */ - if((entry = vfs_find_backend_entry(vfs_object)) || - (smb_probe_module("vfs", vfs_object) && - (entry = vfs_find_backend_entry(vfs_object)))) { - - DEBUG(0,("Successfully loaded %s with the new modules system\n", vfs_object)); - - if ((ops = entry->init(&conn->vfs_ops, conn->vfs_private)) == NULL) { - DEBUG(0, ("vfs init function from %s failed\n", vfs_object)); - return False; - } - } else { - /* If that doesn't work, fall back to the old system - * (This part should go away after a while, it's only here - * for backwards compatibility) */ - DEBUG(2, ("Can't load module with new modules system, falling back to old\n")); - if (!vfs_load_old_plugin(conn, vfs_object)) return False; - } + return False; + } + + if ((vfs_version < SMB_VFS_INTERFACE_VERSION)) { + DEBUG(0, ("Warning: vfs_init() states that module confirms interface version #%d, current interface version is #%d.\n\ +Proceeding in compatibility mode, new operations (since version #%d) will fallback to default ones.\n", + vfs_version, SMB_VFS_INTERFACE_VERSION, vfs_version )); + sys_dlclose(conn->vfs_private->handle); + return False; + } for(i=0; ops[i].op != NULL; i++) { DEBUG(3, ("Checking operation #%d (type %d, layer %d)\n", i, ops[i].type, ops[i].layer)); @@ -305,48 +215,54 @@ BOOL vfs_init_custom(connection_struct *conn, const char *vfs_object) 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; } |