diff options
Diffstat (limited to 'source3')
-rw-r--r-- | source3/Makefile.in | 1 | ||||
-rw-r--r-- | source3/include/libsmb_internal.h | 100 | ||||
-rw-r--r-- | source3/include/libsmbclient.h | 247 | ||||
-rw-r--r-- | source3/libsmb/libsmb_cache.c | 16 | ||||
-rw-r--r-- | source3/libsmb/libsmb_context.c | 1078 | ||||
-rw-r--r-- | source3/libsmb/libsmb_dir.c | 30 | ||||
-rw-r--r-- | source3/libsmb/libsmb_file.c | 8 | ||||
-rw-r--r-- | source3/libsmb/libsmb_path.c | 6 | ||||
-rw-r--r-- | source3/libsmb/libsmb_printjob.c | 6 | ||||
-rw-r--r-- | source3/libsmb/libsmb_server.c | 75 | ||||
-rw-r--r-- | source3/libsmb/libsmb_setget.c | 905 | ||||
-rw-r--r-- | source3/libsmb/libsmb_stat.c | 4 | ||||
-rw-r--r-- | source3/libsmb/libsmb_xattr.c | 6 |
13 files changed, 1214 insertions, 1268 deletions
diff --git a/source3/Makefile.in b/source3/Makefile.in index ddeac06dc0..44ac6622de 100644 --- a/source3/Makefile.in +++ b/source3/Makefile.in @@ -768,6 +768,7 @@ LIBSMBCLIENT_OBJ0 = \ libsmb/libsmb_server.o \ libsmb/libsmb_stat.o \ libsmb/libsmb_xattr.o \ + libsmb/libsmb_setget.o \ $(PARAM_OBJ) $(LIB_NONSMBD_OBJ) \ $(LIBSMB_OBJ) $(KRBCLIENT_OBJ) \ $(LIBMSRPC_OBJ) $(LIBMSRPC_GEN_OBJ) $(RPC_PARSE_OBJ) \ diff --git a/source3/include/libsmb_internal.h b/source3/include/libsmb_internal.h index e687e24268..6930812b29 100644 --- a/source3/include/libsmb_internal.h +++ b/source3/include/libsmb_internal.h @@ -113,23 +113,6 @@ struct SMBC_internal_data { /* True when this handle is initialized */ bool initialized; -#if 0 /* Left in libsmbclient.h for backward compatibility */ - /* Netbios name used for making connections */ - char * netbios_name; - - /* Workgroup used for making connections */ - char * workgroup; - - /* Username used for making connections */ - char * user; - - /* Debug level */ - int debug; - - /* Connection timeout value */ - int timeout; -#endif - /* dirent pointer location * * Leave room for any urlencoded filename and the comment field. @@ -192,88 +175,7 @@ struct SMBC_internal_data { */ smbc_smb_encrypt_level smb_encryption_level; -#if 0 /* Left in libsmbclient.h for backward compatibility */ - /* - * From how many local master browsers should the list of - * workgroups be retrieved? It can take up to 12 minutes or - * longer after a server becomes a local master browser, for - * it to have the entire browse list (the list of - * workgroups/domains) from an entire network. Since a client - * never knows which local master browser will be found first, - * the one which is found first and used to retrieve a browse - * list may have an incomplete or empty browse list. By - * requesting the browse list from multiple local master - * browsers, a more complete list can be generated. For small - * networks (few workgroups), it is recommended that this - * value be set to 0, causing the browse lists from all found - * local master browsers to be retrieved and merged. For - * networks with many workgroups, a suitable value for this - * variable is probably somewhere around 3. (Default: 3). - */ - int browse_max_lmb_count; - - /* - * There is a difference in the desired return strings from - * smbc_readdir() depending upon whether the filenames are to - * be displayed to the user, or whether they are to be - * appended to the path name passed to smbc_opendir() to call - * a further smbc_ function (e.g. open the file with - * smbc_open()). In the former case, the filename should be - * in "human readable" form. In the latter case, the smbc_ - * functions expect a URL which must be url-encoded. Those - * functions decode the URL. If, for example, smbc_readdir() - * returned a file name of "abc%20def.txt", passing a path - * with this file name attached to smbc_open() would cause - * smbc_open to attempt to open the file "abc def.txt" since - * the %20 is decoded into a space. - * - * Set this option to True if the names returned by - * smbc_readdir() should be url-encoded such that they can be - * passed back to another smbc_ call. Set it to False if the - * names returned by smbc_readdir() are to be presented to the - * user. - * - * For backwards compatibility, this option defaults to False. - */ - bool urlencode_readdir_entries; - - /* - * Some Windows versions appear to have a limit to the number - * of concurrent SESSIONs and/or TREE CONNECTions. In - * one-shot programs (i.e. the program runs and then quickly - * ends, thereby shutting down all connections), it is - * probably reasonable to establish a new connection for each - * share. In long-running applications, the limitation can be - * avoided by using only a single connection to each server, - * and issuing a new TREE CONNECT when the share is accessed. - */ - bool one_share_per_server; - - /* Kerberos-related flags */ - bool use_kerberos; - bool fallback_after_kerberos; - - /* Don't try to do automatic anonymous login */ - bool no_auto_anonymous_login; - - /* Server-related functions */ - struct - { - smbc_get_auth_data_fn get_auth_data_fn; - smbc_check_server_fn check_server_fn; - smbc_remove_unused_server_fn remove_unused_server_fn; - } server; - - /* Cache-related functions */ - struct - { - struct smbc_server_cache * server_cache_data; - smbc_add_cached_srv_fn add_cached_server_fn; - smbc_get_cached_srv_fn get_cached_server_fn; - smbc_remove_cached_srv_fn remove_cached_server_fn; - smbc_purge_cached_srv_fn purge_cached_server_fn; - } cache; -#endif + struct smbc_server_cache * server_cache; /* POSIX emulation functions */ struct diff --git a/source3/include/libsmbclient.h b/source3/include/libsmbclient.h index bfed71de1c..a60c05fa7f 100644 --- a/source3/include/libsmbclient.h +++ b/source3/include/libsmbclient.h @@ -25,6 +25,13 @@ #ifndef SMBCLIENT_H_INCLUDED #define SMBCLIENT_H_INCLUDED +#undef _DEPRECATED_ +#if ! defined(__LIBSMBCLIENT_INTERNAL__) && defined(__GNUC__) +# define _DEPRECATED_ __attribute__ ((deprecated)) +#else +# define _DEPRECATED_ +#endif + #ifdef __cplusplus extern "C" { #endif @@ -416,7 +423,7 @@ typedef int (*smbc_remove_cached_srv_fn)(SMBCCTX * c, SMBCSRV *srv); * @return 0 when found and removed. 1 on failure. * */ -typedef int (*smbc_purge_cached_srv_fn) (SMBCCTX * c); +typedef int (*smbc_purge_cached_fn) (SMBCCTX * c); @@ -734,14 +741,14 @@ void smbc_setFunctionRemoveCachedServer(SMBCCTX *c, * Get the function for server cache purging. This function tries to * remove all cached servers (e.g. on disconnect) */ -smbc_purge_cached_srv_fn smbc_getFunctionPurgeCachedServers(SMBCCTX *c); +smbc_purge_cached_fn smbc_getFunctionPurgeCachedServers(SMBCCTX *c); /** * Set the function for server cache purging. This function tries to * remove all cached servers (e.g. on disconnect) */ void smbc_setFunctionPurgeCachedServers(SMBCCTX *c, - smbc_purge_cached_srv_fn fn); + smbc_purge_cached_fn fn); /** Get the function to store private data of the server cache */ struct smbc_server_cache * smbc_getServerCacheData(SMBCCTX *c); @@ -1010,7 +1017,7 @@ int smbc_free_context(SMBCCTX * context, int shutdown_ctx); /**@ingroup misc * - * @DEPRECATED. Use smbc_setOption*() functions instead. + * @deprecated. Use smbc_setOption*() functions instead. */ void smbc_option_set(SMBCCTX *context, @@ -1018,7 +1025,7 @@ smbc_option_set(SMBCCTX *context, ... /* option_value */); /* - * @DEPRECATED. Use smbc_getOption*() functions instead. + * @deprecated. Use smbc_getOption*() functions instead. */ void * smbc_option_get(SMBCCTX *context, @@ -2570,7 +2577,6 @@ smbc_version(void); } #endif - /** * @ingroup structure * Structure that contains a client context information @@ -2586,137 +2592,129 @@ smbc_version(void); * directly visible to applications. This makes it much easier to maintain * ABI compatibility. */ -struct _SMBCCTX { - struct - { - /** - * debug level - * - * Manually setting/retrieving this value is deprecated. - * Use smbc_getDebug() and smbc_setDebug() - */ - int debug; +struct _SMBCCTX +{ + /** + * debug level + * + * DEPRECATED: + * Use smbc_getDebug() and smbc_setDebug() + */ + int debug _DEPRECATED_; - /** - * netbios name used for making connections - * - * Manually setting/retrieving this value is deprecated. - * Use smbc_getNetbiosName() and smbc_setNetbiosName() - */ - char * netbios_name; + /** + * netbios name used for making connections + * + * DEPRECATED: + * Use smbc_getNetbiosName() and smbc_setNetbiosName() + */ + char * netbios_name _DEPRECATED_; - /** - * workgroup name used for making connections - * - * Manually setting/retrieving this value is deprecated. - * Use smbc_getWorkgroup() and smbc_setWorkgroup() - */ - char * workgroup; + /** + * workgroup name used for making connections + * + * DEPRECATED: + * Use smbc_getWorkgroup() and smbc_setWorkgroup() + */ + char * workgroup _DEPRECATED_; - /** - * username used for making connections - * - * Manually setting/retrieving this value is deprecated. - * Use smbc_getUser() and smbc_setUser() - */ - char * user; - - /** - * timeout used for waiting on connections / response data (in - * milliseconds) - * - * Manually setting/retrieving this value is deprecated. - * Use smbc_getTimeout() and smbc_setTimeout() - */ - int timeout; - } config; + /** + * username used for making connections + * + * DEPRECATED: + * Use smbc_getUser() and smbc_setUser() + */ + char * user _DEPRECATED_; + + /** + * timeout used for waiting on connections / response data (in + * milliseconds) + * + * DEPRECATED: + * Use smbc_getTimeout() and smbc_setTimeout() + */ + int timeout _DEPRECATED_; /** * callable functions for files: * For usage and return values see the SMBC_* functions * - * Manually setting/retrieving these values is deprecated. + * DEPRECATED: * * Use smbc_getFunction*() and smbc_setFunction*(), e.g. * smbc_getFunctionOpen(), smbc_setFunctionUnlink(), etc. */ - struct - { - smbc_open_fn open_fn; - smbc_creat_fn creat_fn; - smbc_read_fn read_fn; - smbc_write_fn write_fn; - smbc_unlink_fn unlink_fn; - smbc_rename_fn rename_fn; - smbc_lseek_fn lseek_fn; - smbc_stat_fn stat_fn; - smbc_fstat_fn fstat_fn; + smbc_open_fn open _DEPRECATED_; + smbc_creat_fn creat _DEPRECATED_; + smbc_read_fn read _DEPRECATED_; + smbc_write_fn write _DEPRECATED_; + smbc_unlink_fn unlink _DEPRECATED_; + smbc_rename_fn rename _DEPRECATED_; + smbc_lseek_fn lseek _DEPRECATED_; + smbc_stat_fn stat _DEPRECATED_; + smbc_fstat_fn fstat _DEPRECATED_; #if 0 /* internal */ - smbc_ftruncate_fn ftruncate_fn; + smbc_ftruncate_fn ftruncate_fn; #endif - smbc_close_fn close_fn; - smbc_opendir_fn opendir_fn; - smbc_closedir_fn closedir_fn; - smbc_readdir_fn readdir_fn; - smbc_getdents_fn getdents_fn; - smbc_mkdir_fn mkdir_fn; - smbc_rmdir_fn rmdir_fn; - smbc_telldir_fn telldir_fn; - smbc_lseekdir_fn lseekdir_fn; - smbc_fstatdir_fn fstatdir_fn; - smbc_chmod_fn chmod_fn; - smbc_utimes_fn utimes_fn; - smbc_setxattr_fn setxattr_fn; - smbc_getxattr_fn getxattr_fn; - smbc_removexattr_fn removexattr_fn; - smbc_listxattr_fn listxattr_fn; - } posix_emu; + smbc_close_fn close_fn _DEPRECATED_; + smbc_opendir_fn opendir _DEPRECATED_; + smbc_closedir_fn closedir _DEPRECATED_; + smbc_readdir_fn readdir _DEPRECATED_; + smbc_getdents_fn getdents _DEPRECATED_; + smbc_mkdir_fn mkdir _DEPRECATED_; + smbc_rmdir_fn rmdir _DEPRECATED_; + smbc_telldir_fn telldir _DEPRECATED_; + smbc_lseekdir_fn lseekdir _DEPRECATED_; + smbc_fstatdir_fn fstatdir _DEPRECATED_; + smbc_chmod_fn chmod _DEPRECATED_; + smbc_utimes_fn utimes _DEPRECATED_; + smbc_setxattr_fn setxattr _DEPRECATED_; + smbc_getxattr_fn getxattr _DEPRECATED_; + smbc_removexattr_fn removexattr _DEPRECATED_; + smbc_listxattr_fn listxattr _DEPRECATED_; /* Printing-related functions */ - struct - { - smbc_print_file_fn print_file_fn; - smbc_open_print_job_fn open_print_job_fn; - smbc_list_print_jobs_fn list_print_jobs_fn; - smbc_unlink_print_job_fn unlink_print_job_fn; - } printing; + smbc_print_file_fn print_file _DEPRECATED_; + smbc_open_print_job_fn open_print_job _DEPRECATED_; + smbc_list_print_jobs_fn list_print_jobs _DEPRECATED_; + smbc_unlink_print_job_fn unlink_print_job _DEPRECATED_; /* ** Callbacks - * These callbacks _always_ have to be initialized because they will - * not be checked at dereference for increased speed. + * + * DEPRECATED: + * + * See the comment above each field, for the getter and setter + * functions that should now be used. */ - struct + struct _smbc_callbacks { /** * authentication function callback: called upon auth requests * - * Manually setting/retrieving this value is deprecated. + * DEPRECATED: * Use smbc_getFunctionAuthData(), smbc_setFunctionAuthData() */ - smbc_get_auth_data_fn get_auth_data_fn; + smbc_get_auth_data_fn auth_fn _DEPRECATED_; /** * check if a server is still good * - * Manually setting/retrieving this value is deprecated. + * DEPRECATED: * Use smbc_getFunctionCheckServer(), * smbc_setFunctionCheckServer() */ - smbc_check_server_fn check_server_fn; + smbc_check_server_fn check_server_fn _DEPRECATED_; /** * remove a server if unused * - * Manually setting/retrieving this value is deprecated. + * DEPRECATED: * Use smbc_getFunctionRemoveUnusedServer(), * smbc_setFunctionCheckServer() */ - smbc_remove_unused_server_fn remove_unused_server_fn; - } server; + smbc_remove_unused_server_fn remove_unused_server_fn _DEPRECATED_; - struct - { /** Cache subsystem * * For an example cache system see @@ -2728,53 +2726,53 @@ struct _SMBCCTX { /** * server cache addition * - * Manually setting/retrieving this value is deprecated. + * DEPRECATED: * Use smbc_getFunctionAddCachedServer(), * smbc_setFunctionAddCachedServer() */ - smbc_add_cached_srv_fn add_cached_server_fn; + smbc_add_cached_srv_fn add_cached_srv_fn _DEPRECATED_; /** * server cache lookup * - * Manually setting/retrieving this value is deprecated. + * DEPRECATED: * Use smbc_getFunctionGetCachedServer(), * smbc_setFunctionGetCachedServer() */ - smbc_get_cached_srv_fn get_cached_server_fn; + smbc_get_cached_srv_fn get_cached_srv_fn _DEPRECATED_; /** * server cache removal * - * Manually setting/retrieving this value is deprecated. + * DEPRECATED: * Use smbc_getFunctionRemoveCachedServer(), * smbc_setFunctionRemoveCachedServer() */ - smbc_remove_cached_srv_fn remove_cached_server_fn; + smbc_remove_cached_srv_fn remove_cached_srv_fn _DEPRECATED_; /** * server cache purging, try to remove all cached servers * (disconnect) * - * Manually setting/retrieving this value is deprecated. + * DEPRECATED: * Use smbc_getFunctionPurgeCachedServers(), * smbc_setFunctionPurgeCachedServers() */ - smbc_purge_cached_srv_fn purge_cached_servers_fn; + smbc_purge_cached_fn purge_cached_fn _DEPRECATED_; + } callbacks; - /** - * Space to store private data of the server cache. - * - * Manually setting/retrieving this value is deprecated. - * Use smbc_getServerCacheData(), smbc_setServerCacheData() - */ - struct smbc_server_cache * server_cache_data; - } cache; + /** + * Space where the private data of the server cache used to be + * + * DEPRECATED: + * Use smbc_getServerCacheData(), smbc_setServerCacheData() + */ + void * reserved; /* space where server_cache_data used to be */ /* * Very old configuration options. * - * Manually setting/retrieving this value is deprecated. + * DEPRECATED: * Use one of the following functions instead: * smbc_setOptionUseKerberos() * smbc_getOptionUseKerberos() @@ -2783,24 +2781,21 @@ struct _SMBCCTX { * smbc_setOptionNoAutoAnonymousLogin() * smbc_getOptionNoAutoAnonymousLogin() */ - struct - { - int bits; - } flags; + int flags _DEPRECATED_; - /** user options selections that apply to this session - * - * NEW CODE SHOULD NOT DIRECTLY MANIPULATE THE CONTEXT STRUCTURE. + /** + * user options selections that apply to this session * - * NEW OPTIONS ARE NOT ADDED HERE! + * NEW OPTIONS ARE NOT ADDED HERE! * - * To set and retrieve options, use the smbc_setOption*() and - * smbc_getOption*() functions. + * DEPRECATED: + * To set and retrieve options, use the smbc_setOption*() and + * smbc_getOption*() functions. */ struct _smbc_options { - int browse_max_lmb_count; - int urlencode_readdir_entries; - int one_share_per_server; + int browse_max_lmb_count _DEPRECATED_; + int urlencode_readdir_entries _DEPRECATED_; + int one_share_per_server _DEPRECATED_; } options; /** INTERNAL DATA diff --git a/source3/libsmb/libsmb_cache.c b/source3/libsmb/libsmb_cache.c index c45aba4544..bfacea368d 100644 --- a/source3/libsmb/libsmb_cache.c +++ b/source3/libsmb/libsmb_cache.c @@ -88,7 +88,7 @@ SMBC_add_cached_server(SMBCCTX * context, goto failed; } - DLIST_ADD((context->cache.server_cache_data), srvcache); + DLIST_ADD(context->internal->server_cache, srvcache); return 0; failed: @@ -118,7 +118,7 @@ SMBC_get_cached_server(SMBCCTX * context, struct smbc_server_cache * srv = NULL; /* Search the cache lines */ - for (srv = context->cache.server_cache_data; srv; srv = srv->next) { + for (srv = context->internal->server_cache; srv; srv = srv->next) { if (strcmp(server,srv->server_name) == 0 && strcmp(workgroup,srv->workgroup) == 0 && @@ -150,7 +150,7 @@ SMBC_get_cached_server(SMBCCTX * context, * a connection to the server (other than the * attribute server connection) is cool. */ - if (context->options.one_share_per_server) { + if (smbc_getOptionOneSharePerServer(context)) { /* * The currently connected share name * doesn't match the requested share, so @@ -160,7 +160,7 @@ SMBC_get_cached_server(SMBCCTX * context, /* Sigh. Couldn't disconnect. */ cli_shutdown(srv->server->cli); srv->server->cli = NULL; - context->cache.remove_cached_server_fn(context, srv->server); + smbc_getFunctionRemoveCachedServer(context)(context, srv->server); continue; } @@ -175,7 +175,7 @@ SMBC_get_cached_server(SMBCCTX * context, /* Out of memory. */ cli_shutdown(srv->server->cli); srv->server->cli = NULL; - context->cache.remove_cached_server_fn(context, srv->server); + smbc_getFunctionRemoveCachedServer(context)(context, srv->server); continue; } @@ -200,11 +200,11 @@ SMBC_remove_cached_server(SMBCCTX * context, { struct smbc_server_cache * srv = NULL; - for (srv = context->cache.server_cache_data; srv; srv = srv->next) { + for (srv = context->internal->server_cache; srv; srv = srv->next) { if (server == srv->server) { /* remove this sucker */ - DLIST_REMOVE(context->cache.server_cache_data, srv); + DLIST_REMOVE(context->internal->server_cache, srv); SAFE_FREE(srv->server_name); SAFE_FREE(srv->share_name); SAFE_FREE(srv->workgroup); @@ -229,7 +229,7 @@ SMBC_purge_cached_servers(SMBCCTX * context) struct smbc_server_cache * next; int could_not_purge_all = 0; - for (srv = context->cache.server_cache_data, + for (srv = context->internal->server_cache, next = (srv ? srv->next :NULL); srv; srv = next, diff --git a/source3/libsmb/libsmb_context.c b/source3/libsmb/libsmb_context.c index c107ab2220..c04f751696 100644 --- a/source3/libsmb/libsmb_context.c +++ b/source3/libsmb/libsmb_context.c @@ -46,11 +46,6 @@ smbc_new_context(void) * All newly added context fields should be placed in * SMBC_internal_data, not directly in SMBCCTX. */ -#undef OLD -#define OLD(field) context->field -#undef NEW -#define NEW(field) context->internal->field - context = SMB_MALLOC_P(SMBCCTX); if (!context) { errno = ENOMEM; @@ -69,61 +64,59 @@ smbc_new_context(void) /* Initialize the context and establish reasonable defaults */ ZERO_STRUCTP(context->internal); - OLD(config.debug) = 0; - OLD(config.timeout) = 20000; /* 20 seconds */ - - NEW(full_time_names) = False; - NEW(share_mode) = SMBC_SHAREMODE_DENY_NONE; - NEW(smb_encryption_level) = 0; - OLD(options.browse_max_lmb_count) = 3; /* # LMBs to query */ - OLD(options.urlencode_readdir_entries) = False; - OLD(options.one_share_per_server) = False; - - OLD(server.get_auth_data_fn) = SMBC_get_auth_data; - OLD(server.check_server_fn) = SMBC_check_server; - OLD(server.remove_unused_server_fn) = SMBC_remove_unused_server; - - OLD(cache.server_cache_data) = NULL; - OLD(cache.add_cached_server_fn) = SMBC_add_cached_server; - OLD(cache.get_cached_server_fn) = SMBC_get_cached_server; - OLD(cache.remove_cached_server_fn) = SMBC_remove_cached_server; - OLD(cache.purge_cached_servers_fn) = SMBC_purge_cached_servers; - - OLD(posix_emu.open_fn) = SMBC_open_ctx; - OLD(posix_emu.creat_fn) = SMBC_creat_ctx; - OLD(posix_emu.read_fn) = SMBC_read_ctx; - OLD(posix_emu.write_fn) = SMBC_write_ctx; - OLD(posix_emu.close_fn) = SMBC_close_ctx; - OLD(posix_emu.unlink_fn) = SMBC_unlink_ctx; - OLD(posix_emu.rename_fn) = SMBC_rename_ctx; - OLD(posix_emu.lseek_fn) = SMBC_lseek_ctx; - NEW(posix_emu.ftruncate_fn) = SMBC_ftruncate_ctx; - OLD(posix_emu.stat_fn) = SMBC_stat_ctx; - OLD(posix_emu.fstat_fn) = SMBC_fstat_ctx; - OLD(posix_emu.opendir_fn) = SMBC_opendir_ctx; - OLD(posix_emu.closedir_fn) = SMBC_closedir_ctx; - OLD(posix_emu.readdir_fn) = SMBC_readdir_ctx; - OLD(posix_emu.getdents_fn) = SMBC_getdents_ctx; - OLD(posix_emu.mkdir_fn) = SMBC_mkdir_ctx; - OLD(posix_emu.rmdir_fn) = SMBC_rmdir_ctx; - OLD(posix_emu.telldir_fn) = SMBC_telldir_ctx; - OLD(posix_emu.lseekdir_fn) = SMBC_lseekdir_ctx; - OLD(posix_emu.fstatdir_fn) = SMBC_fstatdir_ctx; - OLD(posix_emu.chmod_fn) = SMBC_chmod_ctx; - OLD(posix_emu.utimes_fn) = SMBC_utimes_ctx; - OLD(posix_emu.setxattr_fn) = SMBC_setxattr_ctx; - OLD(posix_emu.getxattr_fn) = SMBC_getxattr_ctx; - OLD(posix_emu.removexattr_fn) = SMBC_removexattr_ctx; - OLD(posix_emu.listxattr_fn) = SMBC_listxattr_ctx; - - OLD(printing.open_print_job_fn) = SMBC_open_print_job_ctx; - OLD(printing.print_file_fn) = SMBC_print_file_ctx; - OLD(printing.list_print_jobs_fn) = SMBC_list_print_jobs_ctx; - OLD(printing.unlink_print_job_fn) = SMBC_unlink_print_job_ctx; + smbc_setDebug(context, 0); + smbc_setTimeout(context, 20000); + + smbc_setOptionFullTimeNames(context, False); + smbc_setOptionOpenShareMode(context, SMBC_SHAREMODE_DENY_NONE); + smbc_setOptionSmbEncryptionLevel(context, SMBC_ENCRYPTLEVEL_NONE); + smbc_setOptionBrowseMaxLmbCount(context, 3); /* # LMBs to query */ + smbc_setOptionUrlEncodeReaddirEntries(context, False); + smbc_setOptionOneSharePerServer(context, False); + + smbc_setFunctionAuthData(context, SMBC_get_auth_data); + smbc_setFunctionCheckServer(context, SMBC_check_server); + smbc_setFunctionRemoveUnusedServer(context, SMBC_remove_unused_server); + + smbc_setOptionUserData(context, NULL); + smbc_setFunctionAddCachedServer(context, SMBC_add_cached_server); + smbc_setFunctionGetCachedServer(context, SMBC_get_cached_server); + smbc_setFunctionRemoveCachedServer(context, SMBC_remove_cached_server); + smbc_setFunctionPurgeCachedServers(context, SMBC_purge_cached_servers); + + smbc_setFunctionOpen(context, SMBC_open_ctx); + smbc_setFunctionCreat(context, SMBC_creat_ctx); + smbc_setFunctionRead(context, SMBC_read_ctx); + smbc_setFunctionWrite(context, SMBC_write_ctx); + smbc_setFunctionClose(context, SMBC_close_ctx); + smbc_setFunctionUnlink(context, SMBC_unlink_ctx); + smbc_setFunctionRename(context, SMBC_rename_ctx); + smbc_setFunctionLseek(context, SMBC_lseek_ctx); + smbc_setFunctionFtruncate(context, SMBC_ftruncate_ctx); + smbc_setFunctionStat(context, SMBC_stat_ctx); + smbc_setFunctionFstat(context, SMBC_fstat_ctx); + smbc_setFunctionOpendir(context, SMBC_opendir_ctx); + smbc_setFunctionClosedir(context, SMBC_closedir_ctx); + smbc_setFunctionReaddir(context, SMBC_readdir_ctx); + smbc_setFunctionGetdents(context, SMBC_getdents_ctx); + smbc_setFunctionMkdir(context, SMBC_mkdir_ctx); + smbc_setFunctionRmdir(context, SMBC_rmdir_ctx); + smbc_setFunctionTelldir(context, SMBC_telldir_ctx); + smbc_setFunctionLseekdir(context, SMBC_lseekdir_ctx); + smbc_setFunctionFstatdir(context, SMBC_fstatdir_ctx); + smbc_setFunctionChmod(context, SMBC_chmod_ctx); + smbc_setFunctionUtimes(context, SMBC_utimes_ctx); + smbc_setFunctionSetxattr(context, SMBC_setxattr_ctx); + smbc_setFunctionGetxattr(context, SMBC_getxattr_ctx); + smbc_setFunctionRemovexattr(context, SMBC_removexattr_ctx); + smbc_setFunctionListxattr(context, SMBC_listxattr_ctx); + + smbc_setFunctionOpenPrintJob(context, SMBC_open_print_job_ctx); + smbc_setFunctionPrintFile(context, SMBC_print_file_ctx); + smbc_setFunctionListPrintJobs(context, SMBC_list_print_jobs_ctx); + smbc_setFunctionUnlinkPrintJob(context, SMBC_unlink_print_job_ctx); return context; -#undef OLD -#undef NEW } /* @@ -148,13 +141,13 @@ smbc_free_context(SMBCCTX *context, f = context->internal->files; while (f) { - (context->posix_emu.close_fn)(context, f); + smbc_getFunctionClose(context)(context, f); f = f->next; } context->internal->files = NULL; /* First try to remove the servers the nice way. */ - if (context->cache.purge_cached_servers_fn(context)) { + if (smbc_getFunctionPurgeCachedServers(context)(context)) { SMBCSRV * s; SMBCSRV * next; DEBUG(1, ("Could not purge all servers, " @@ -164,7 +157,7 @@ smbc_free_context(SMBCCTX *context, DEBUG(1, ("Forced shutdown: %p (fd=%d)\n", s, s->cli->fd)); cli_shutdown(s->cli); - (context->cache.remove_cached_server_fn)(context, + smbc_getFunctionRemoveCachedServer(context)(context, s); next = s->next; DLIST_REMOVE(context->internal->servers, s); @@ -176,7 +169,7 @@ smbc_free_context(SMBCCTX *context, } else { /* This is the polite way */ - if ((context->cache.purge_cached_servers_fn)(context)) { + if (smbc_getFunctionPurgeCachedServers(context)(context)) { DEBUG(1, ("Could not purge all servers, " "free_context failed.\n")); errno = EBUSY; @@ -197,9 +190,14 @@ smbc_free_context(SMBCCTX *context, } /* Things we have to clean up */ - SAFE_FREE(context->config.workgroup); - SAFE_FREE(context->config.netbios_name); - SAFE_FREE(context->config.user); + free(smbc_getWorkgroup(context)); + smbc_setWorkgroup(context, NULL); + + free(smbc_getNetbiosName(context)); + smbc_setNetbiosName(context, NULL); + + free(smbc_getUser(context)); + smbc_setUser(context, NULL); DEBUG(3, ("Context %p successfully freed\n", context)); SAFE_FREE(context); @@ -298,8 +296,6 @@ void * smbc_option_get(SMBCCTX *context, char *option_name) { - int bits; - if (strcmp(option_name, "debug_stderr") == 0) { #if defined(__intptr_t_defined) || defined(HAVE_INTPTR_T) return (void *) (intptr_t) smbc_getOptionDebugToStderr(context); @@ -376,7 +372,6 @@ smbc_option_get(SMBCCTX *context, #endif } else if (strcmp(option_name, "use_kerberos") == 0) { - bits = context->flags.bits; #if defined(__intptr_t_defined) || defined(HAVE_INTPTR_T) return (void *) (intptr_t) smbc_getOptionUseKerberos(context); #else @@ -427,9 +422,9 @@ smbc_init_context(SMBCCTX *context) return NULL; } - if (!context->server.get_auth_data_fn || - context->config.debug < 0 || - context->config.debug > 100) { + if (!smbc_getFunctionAuthData(context) || + smbc_getDebug(context) < 0 || + smbc_getDebug(context) > 100) { errno = EINVAL; return NULL; @@ -444,9 +439,6 @@ smbc_init_context(SMBCCTX *context) bool conf_loaded = False; TALLOC_CTX *frame = talloc_stackframe(); - /* Set this to what the user wants */ - DEBUGLEVEL = context->config.debug; - load_case_tables(); setup_logging("libsmbclient", True); @@ -521,58 +513,84 @@ smbc_init_context(SMBCCTX *context) TALLOC_FREE(frame); } - if (!context->config.user) { + if (!smbc_getUser(context)) { /* * FIXME: Is this the best way to get the user info? */ user = getenv("USER"); /* walk around as "guest" if no username can be found */ - if (!user) context->config.user = SMB_STRDUP("guest"); - else context->config.user = SMB_STRDUP(user); + if (!user) { + user = SMB_STRDUP("guest"); + } else { + user = SMB_STRDUP(user); + } + + if (!user) { + errno = ENOMEM; + return NULL; + } + + smbc_setUser(context, user); } - if (!context->config.netbios_name) { + if (!smbc_getNetbiosName(context)) { /* * We try to get our netbios name from the config. If that * fails we fall back on constructing our netbios name from * our hostname etc */ + char *netbios_name; if (global_myname()) { - context->config.netbios_name = SMB_STRDUP(global_myname()); - } - else { + netbios_name = SMB_STRDUP(global_myname()); + } else { /* * Hmmm, I want to get hostname as well, but I am too * lazy for the moment */ pid = sys_getpid(); - context->config.netbios_name = (char *)SMB_MALLOC(17); - if (!context->config.netbios_name) { + netbios_name = (char *)SMB_MALLOC(17); + if (!netbios_name) { errno = ENOMEM; return NULL; } - slprintf(context->config.netbios_name, 16, - "smbc%s%d", context->config.user, pid); + slprintf(netbios_name, 16, + "smbc%s%d", smbc_getUser(context), pid); } + + if (!netbios_name) { + errno = ENOMEM; + return NULL; + } + + smbc_setNetbiosName(context, netbios_name); } - DEBUG(1, ("Using netbios name %s.\n", context->config.netbios_name)); + DEBUG(1, ("Using netbios name %s.\n", smbc_getNetbiosName(context))); - if (!context->config.workgroup) { + if (!smbc_getWorkgroup(context)) { + char *workgroup; + if (lp_workgroup()) { - context->config.workgroup = SMB_STRDUP(lp_workgroup()); + workgroup = SMB_STRDUP(lp_workgroup()); } else { /* TODO: Think about a decent default workgroup */ - context->config.workgroup = SMB_STRDUP("samba"); + workgroup = SMB_STRDUP("samba"); } + + if (!workgroup) { + errno = ENOMEM; + return NULL; + } + + smbc_setWorkgroup(context, workgroup); } - DEBUG(1, ("Using workgroup %s.\n", context->config.workgroup)); + DEBUG(1, ("Using workgroup %s.\n", smbc_getWorkgroup(context))); /* shortest timeout is 1 second */ - if (context->config.timeout > 0 && context->config.timeout < 1000) - context->config.timeout = 1000; + if (smbc_getTimeout(context) > 0 && smbc_getTimeout(context) < 1000) + smbc_setTimeout(context, 1000); /* * FIXME: Should we check the function pointers here? @@ -592,879 +610,3 @@ smbc_version(void) } -/** Get the netbios name used for making connections */ -char * -smbc_getNetbiosName(SMBCCTX *c) -{ - return c->config.netbios_name; -} - -/** Set the netbios name used for making connections */ -void -smbc_setNetbiosName(SMBCCTX *c, char * netbios_name) -{ - c->config.netbios_name = netbios_name; -} - -/** Get the workgroup used for making connections */ -char * -smbc_getWorkgroup(SMBCCTX *c) -{ - return c->config.workgroup; -} - -/** Set the workgroup used for making connections */ -void -smbc_setWorkgroup(SMBCCTX *c, char * workgroup) -{ - c->config.workgroup = workgroup; -} - -/** Get the username used for making connections */ -char * -smbc_getUser(SMBCCTX *c) -{ - return c->config.user; -} - -/** Set the username used for making connections */ -void -smbc_setUser(SMBCCTX *c, char * user) -{ - c->config.user = user; -} - -/** Get the debug level */ -int -smbc_getDebug(SMBCCTX *c) -{ - return c->config.debug; -} - -/** Set the debug level */ -void -smbc_setDebug(SMBCCTX *c, int debug) -{ - c->config.debug = debug; -} - -/** - * Get the timeout used for waiting on connections and response data - * (in milliseconds) - */ -int -smbc_getTimeout(SMBCCTX *c) -{ - return c->config.timeout; -} - -/** - * Set the timeout used for waiting on connections and response data - * (in milliseconds) - */ -void -smbc_setTimeout(SMBCCTX *c, int timeout) -{ - c->config.timeout = timeout; -} - -/** Get whether to log to standard error instead of standard output */ -smbc_bool -smbc_getOptionDebugToStderr(SMBCCTX *c) -{ - return c->internal->debug_stderr; -} - -/** Set whether to log to standard error instead of standard output */ -void -smbc_setOptionDebugToStderr(SMBCCTX *c, smbc_bool b) -{ - c->internal->debug_stderr = b; -} - -/** - * Get whether to use new-style time attribute names, e.g. WRITE_TIME rather - * than the old-style names such as M_TIME. This allows also setting/getting - * CREATE_TIME which was previously unimplemented. (Note that the old C_TIME - * was supposed to be CHANGE_TIME but was confused and sometimes referred to - * CREATE_TIME.) - */ -smbc_bool -smbc_getOptionFullTimeNames(SMBCCTX *c) -{ - return c->internal->full_time_names; -} - -/** - * Set whether to use new-style time attribute names, e.g. WRITE_TIME rather - * than the old-style names such as M_TIME. This allows also setting/getting - * CREATE_TIME which was previously unimplemented. (Note that the old C_TIME - * was supposed to be CHANGE_TIME but was confused and sometimes referred to - * CREATE_TIME.) - */ -void -smbc_setOptionFullTimeNames(SMBCCTX *c, smbc_bool b) -{ - c->internal->full_time_names = b; -} - -/** - * Get the share mode to use for files opened with SMBC_open_ctx(). The - * default is SMBC_SHAREMODE_DENY_NONE. - */ -smbc_share_mode -smbc_getOptionOpenShareMode(SMBCCTX *c) -{ - return c->internal->share_mode; -} - -/** - * Set the share mode to use for files opened with SMBC_open_ctx(). The - * default is SMBC_SHAREMODE_DENY_NONE. - */ -void -smbc_setOptionOpenShareMode(SMBCCTX *c, smbc_share_mode share_mode) -{ - c->internal->share_mode = share_mode; -} - -/** Retrieve a previously set user data handle */ -void * -smbc_getOptionUserData(SMBCCTX *c) -{ - return c->internal->user_data; -} - -/** Save a user data handle */ -void -smbc_setOptionUserData(SMBCCTX *c, void *user_data) -{ - c->internal->user_data = user_data; -} - -/** Get the encoded value for encryption level. */ -smbc_smb_encrypt_level -smbc_getOptionSmbEncryptionLevel(SMBCCTX *c) -{ - return c->internal->smb_encryption_level; -} - -/** Set the encoded value for encryption level. */ -void -smbc_setOptionSmbEncryptionLevel(SMBCCTX *c, smbc_smb_encrypt_level level) -{ - c->internal->smb_encryption_level = level; -} - -/** - * Get from how many local master browsers should the list of workgroups be - * retrieved. It can take up to 12 minutes or longer after a server becomes a - * local master browser, for it to have the entire browse list (the list of - * workgroups/domains) from an entire network. Since a client never knows - * which local master browser will be found first, the one which is found - * first and used to retrieve a browse list may have an incomplete or empty - * browse list. By requesting the browse list from multiple local master - * browsers, a more complete list can be generated. For small networks (few - * workgroups), it is recommended that this value be set to 0, causing the - * browse lists from all found local master browsers to be retrieved and - * merged. For networks with many workgroups, a suitable value for this - * variable is probably somewhere around 3. (Default: 3). - */ -int -smbc_getOptionBrowseMaxLmbCount(SMBCCTX *c) -{ - return c->options.browse_max_lmb_count; -} - -/** - * Set from how many local master browsers should the list of workgroups be - * retrieved. It can take up to 12 minutes or longer after a server becomes a - * local master browser, for it to have the entire browse list (the list of - * workgroups/domains) from an entire network. Since a client never knows - * which local master browser will be found first, the one which is found - * first and used to retrieve a browse list may have an incomplete or empty - * browse list. By requesting the browse list from multiple local master - * browsers, a more complete list can be generated. For small networks (few - * workgroups), it is recommended that this value be set to 0, causing the - * browse lists from all found local master browsers to be retrieved and - * merged. For networks with many workgroups, a suitable value for this - * variable is probably somewhere around 3. (Default: 3). - */ -void -smbc_setOptionBrowseMaxLmbCount(SMBCCTX *c, int count) -{ - c->options.browse_max_lmb_count = count; -} - -/** - * Get whether to url-encode readdir entries. - * - * There is a difference in the desired return strings from - * smbc_readdir() depending upon whether the filenames are to - * be displayed to the user, or whether they are to be - * appended to the path name passed to smbc_opendir() to call - * a further smbc_ function (e.g. open the file with - * smbc_open()). In the former case, the filename should be - * in "human readable" form. In the latter case, the smbc_ - * functions expect a URL which must be url-encoded. Those - * functions decode the URL. If, for example, smbc_readdir() - * returned a file name of "abc%20def.txt", passing a path - * with this file name attached to smbc_open() would cause - * smbc_open to attempt to open the file "abc def.txt" since - * the %20 is decoded into a space. - * - * Set this option to True if the names returned by - * smbc_readdir() should be url-encoded such that they can be - * passed back to another smbc_ call. Set it to False if the - * names returned by smbc_readdir() are to be presented to the - * user. - * - * For backwards compatibility, this option defaults to False. - */ -smbc_bool -smbc_getOptionUrlEncodeReaddirEntries(SMBCCTX *c) -{ - return c->options.urlencode_readdir_entries; -} - -/** - * Set whether to url-encode readdir entries. - * - * There is a difference in the desired return strings from - * smbc_readdir() depending upon whether the filenames are to - * be displayed to the user, or whether they are to be - * appended to the path name passed to smbc_opendir() to call - * a further smbc_ function (e.g. open the file with - * smbc_open()). In the former case, the filename should be - * in "human readable" form. In the latter case, the smbc_ - * functions expect a URL which must be url-encoded. Those - * functions decode the URL. If, for example, smbc_readdir() - * returned a file name of "abc%20def.txt", passing a path - * with this file name attached to smbc_open() would cause - * smbc_open to attempt to open the file "abc def.txt" since - * the %20 is decoded into a space. - * - * Set this option to True if the names returned by - * smbc_readdir() should be url-encoded such that they can be - * passed back to another smbc_ call. Set it to False if the - * names returned by smbc_readdir() are to be presented to the - * user. - * - * For backwards compatibility, this option defaults to False. - */ -void -smbc_setOptionUrlEncodeReaddirEntries(SMBCCTX *c, smbc_bool b) -{ - c->options.urlencode_readdir_entries = b; -} - -/** - * Get whether to use the same connection for all shares on a server. - * - * Some Windows versions appear to have a limit to the number - * of concurrent SESSIONs and/or TREE CONNECTions. In - * one-shot programs (i.e. the program runs and then quickly - * ends, thereby shutting down all connections), it is - * probably reasonable to establish a new connection for each - * share. In long-running applications, the limitation can be - * avoided by using only a single connection to each server, - * and issuing a new TREE CONNECT when the share is accessed. - */ -smbc_bool -smbc_getOptionOneSharePerServer(SMBCCTX *c) -{ - return c->options.one_share_per_server; -} - -/** - * Set whether to use the same connection for all shares on a server. - * - * Some Windows versions appear to have a limit to the number - * of concurrent SESSIONs and/or TREE CONNECTions. In - * one-shot programs (i.e. the program runs and then quickly - * ends, thereby shutting down all connections), it is - * probably reasonable to establish a new connection for each - * share. In long-running applications, the limitation can be - * avoided by using only a single connection to each server, - * and issuing a new TREE CONNECT when the share is accessed. - */ -void -smbc_setOptionOneSharePerServer(SMBCCTX *c, smbc_bool b) -{ - c->options.one_share_per_server = b; -} - -/** Get whether to enable use of kerberos */ -smbc_bool -smbc_getOptionUseKerberos(SMBCCTX *c) -{ - return c->flags.bits & SMB_CTX_FLAG_USE_KERBEROS ? True : False; -} - -/** Set whether to enable use of kerberos */ -void -smbc_setOptionUseKerberos(SMBCCTX *c, smbc_bool b) -{ - if (b) { - c->flags.bits |= SMB_CTX_FLAG_USE_KERBEROS; - } else { - c->flags.bits &= ~SMB_CTX_FLAG_USE_KERBEROS; - } -} - -/** Get whether to fallback after kerberos */ -smbc_bool -smbc_getOptionFallbackAfterKerberos(SMBCCTX *c) -{ - return c->flags.bits & SMB_CTX_FLAG_FALLBACK_AFTER_KERBEROS ? True : False; -} - -/** Set whether to fallback after kerberos */ -void -smbc_setOptionFallbackAfterKerberos(SMBCCTX *c, smbc_bool b) -{ - if (b) { - c->flags.bits |= SMB_CTX_FLAG_FALLBACK_AFTER_KERBEROS; - } else { - c->flags.bits &= ~SMB_CTX_FLAG_FALLBACK_AFTER_KERBEROS; - } -} - -/** Get whether to automatically select anonymous login */ -smbc_bool -smbc_getOptionNoAutoAnonymousLogin(SMBCCTX *c) -{ - return c->flags.bits & SMBCCTX_FLAG_NO_AUTO_ANONYMOUS_LOGON ? True : False; -} - -/** Set whether to automatically select anonymous login */ -void -smbc_setOptionNoAutoAnonymousLogin(SMBCCTX *c, smbc_bool b) -{ - if (b) { - c->flags.bits |= SMBCCTX_FLAG_NO_AUTO_ANONYMOUS_LOGON; - } else { - c->flags.bits &= ~SMBCCTX_FLAG_NO_AUTO_ANONYMOUS_LOGON; - } -} - -/** Get the function for obtaining authentication data */ -smbc_get_auth_data_fn -smbc_getFunctionAuthData(SMBCCTX *c) -{ - return c->server.get_auth_data_fn; -} - -/** Set the function for obtaining authentication data */ -void -smbc_setFunctionAuthData(SMBCCTX *c, smbc_get_auth_data_fn fn) -{ - c->internal->auth_fn_with_context = NULL; - c->server.get_auth_data_fn = fn; -} - -/** Get the new-style authentication function which includes the context. */ -smbc_get_auth_data_with_context_fn -smbc_getFunctionAuthDataWithContext(SMBCCTX *c) -{ - return c->internal->auth_fn_with_context; -} - -/** Set the new-style authentication function which includes the context. */ -void -smbc_setFunctionAuthDataWithContext(SMBCCTX *c, - smbc_get_auth_data_with_context_fn fn) -{ - c->server.get_auth_data_fn = NULL; - c->internal->auth_fn_with_context = fn; -} - -/** Get the function for checking if a server is still good */ -smbc_check_server_fn -smbc_getFunctionCheckServer(SMBCCTX *c) -{ - return c->server.check_server_fn; -} - -/** Set the function for checking if a server is still good */ -void -smbc_setFunctionCheckServer(SMBCCTX *c, smbc_check_server_fn fn) -{ - c->server.check_server_fn = fn; -} - -/** Get the function for removing a server if unused */ -smbc_remove_unused_server_fn -smbc_getFunctionRemoveUnusedServer(SMBCCTX *c) -{ - return c->server.remove_unused_server_fn; -} - -/** Set the function for removing a server if unused */ -void -smbc_setFunctionRemoveUnusedServer(SMBCCTX *c, - smbc_remove_unused_server_fn fn) -{ - c->server.remove_unused_server_fn = fn; -} - -/** Get the function to store private data of the server cache */ -struct -smbc_server_cache * smbc_getServerCacheData(SMBCCTX *c) -{ - return c->cache.server_cache_data; -} - -/** Set the function to store private data of the server cache */ -void -smbc_setServerCacheData(SMBCCTX *c, struct smbc_server_cache * cache) -{ - c->cache.server_cache_data = cache; -} - - -/** Get the function for adding a cached server */ -smbc_add_cached_srv_fn -smbc_getFunctionAddCachedServer(SMBCCTX *c) -{ - return c->cache.add_cached_server_fn; -} - -/** Set the function for adding a cached server */ -void -smbc_setFunctionAddCachedServer(SMBCCTX *c, smbc_add_cached_srv_fn fn) -{ - c->cache.add_cached_server_fn = fn; -} - -/** Get the function for server cache lookup */ -smbc_get_cached_srv_fn -smbc_getFunctionGetCachedServer(SMBCCTX *c) -{ - return c->cache.get_cached_server_fn; -} - -/** Set the function for server cache lookup */ -void -smbc_setFunctionGetCachedServer(SMBCCTX *c, smbc_get_cached_srv_fn fn) -{ - c->cache.get_cached_server_fn = fn; -} - -/** Get the function for server cache removal */ -smbc_remove_cached_srv_fn -smbc_getFunctionRemoveCachedServer(SMBCCTX *c) -{ - return c->cache.remove_cached_server_fn; -} - -/** Set the function for server cache removal */ -void -smbc_setFunctionRemoveCachedServer(SMBCCTX *c, - smbc_remove_cached_srv_fn fn) -{ - c->cache.remove_cached_server_fn = fn; -} - -/** - * Get the function for server cache purging. This function tries to - * remove all cached servers (e.g. on disconnect) - */ -smbc_purge_cached_srv_fn -smbc_getFunctionPurgeCachedServers(SMBCCTX *c) -{ - return c->cache.purge_cached_servers_fn; -} - -/** - * Set the function for server cache purging. This function tries to - * remove all cached servers (e.g. on disconnect) - */ -void -smbc_setFunctionPurgeCachedServers(SMBCCTX *c, smbc_purge_cached_srv_fn fn) -{ - c->cache.purge_cached_servers_fn = fn; -} - -/** - * Callable functions for files. - */ - -smbc_open_fn -smbc_getFunctionOpen(SMBCCTX *c) -{ - return c->posix_emu.open_fn; -} - -void -smbc_setFunctionOpen(SMBCCTX *c, smbc_open_fn fn) -{ - c->posix_emu.open_fn = fn; -} - -smbc_creat_fn -smbc_getFunctionCreat(SMBCCTX *c) -{ - return c->posix_emu.creat_fn; -} - -void -smbc_setFunctionCreat(SMBCCTX *c, smbc_creat_fn fn) -{ - c->posix_emu.creat_fn = fn; -} - -smbc_read_fn -smbc_getFunctionRead(SMBCCTX *c) -{ - return c->posix_emu.read_fn; -} - -void -smbc_setFunctionRead(SMBCCTX *c, smbc_read_fn fn) -{ - c->posix_emu.read_fn = fn; -} - -smbc_write_fn -smbc_getFunctionWrite(SMBCCTX *c) -{ - return c->posix_emu.write_fn; -} - -void -smbc_setFunctionWrite(SMBCCTX *c, smbc_write_fn fn) -{ - c->posix_emu.write_fn = fn; -} - -smbc_unlink_fn -smbc_getFunctionUnlink(SMBCCTX *c) -{ - return c->posix_emu.unlink_fn; -} - -void -smbc_setFunctionUnlink(SMBCCTX *c, smbc_unlink_fn fn) -{ - c->posix_emu.unlink_fn = fn; -} - -smbc_rename_fn -smbc_getFunctionRename(SMBCCTX *c) -{ - return c->posix_emu.rename_fn; -} - -void -smbc_setFunctionRename(SMBCCTX *c, smbc_rename_fn fn) -{ - c->posix_emu.rename_fn = fn; -} - -smbc_lseek_fn -smbc_getFunctionLseek(SMBCCTX *c) -{ - return c->posix_emu.lseek_fn; -} - -void -smbc_setFunctionLseek(SMBCCTX *c, smbc_lseek_fn fn) -{ - c->posix_emu.lseek_fn = fn; -} - -smbc_stat_fn -smbc_getFunctionStat(SMBCCTX *c) -{ - return c->posix_emu.stat_fn; -} - -void -smbc_setFunctionStat(SMBCCTX *c, smbc_stat_fn fn) -{ - c->posix_emu.stat_fn = fn; -} - -smbc_fstat_fn -smbc_getFunctionFstat(SMBCCTX *c) -{ - return c->posix_emu.fstat_fn; -} - -void -smbc_setFunctionFstat(SMBCCTX *c, smbc_fstat_fn fn) -{ - c->posix_emu.fstat_fn = fn; -} - -smbc_ftruncate_fn -smbc_getFunctionFtruncate(SMBCCTX *c) -{ - return c->internal->posix_emu.ftruncate_fn; -} - -void -smbc_setFunctionFtruncate(SMBCCTX *c, smbc_ftruncate_fn fn) -{ - c->internal->posix_emu.ftruncate_fn = fn; -} - -smbc_close_fn -smbc_getFunctionClose(SMBCCTX *c) -{ - return c->posix_emu.close_fn; -} - -void -smbc_setFunctionClose(SMBCCTX *c, smbc_close_fn fn) -{ - c->posix_emu.close_fn = fn; -} - - -/** - * Callable functions for directories. - */ - -smbc_opendir_fn -smbc_getFunctionOpendir(SMBCCTX *c) -{ - return c->posix_emu.opendir_fn; -} - -void -smbc_setFunctionOpendir(SMBCCTX *c, smbc_opendir_fn fn) -{ - c->posix_emu.opendir_fn = fn; -} - -smbc_closedir_fn -smbc_getFunctionClosedir(SMBCCTX *c) -{ - return c->posix_emu.closedir_fn; -} - -void -smbc_setFunctionClosedir(SMBCCTX *c, smbc_closedir_fn fn) -{ - c->posix_emu.closedir_fn = fn; -} - -smbc_readdir_fn -smbc_getFunctionReaddir(SMBCCTX *c) -{ - return c->posix_emu.readdir_fn; -} - -void -smbc_setFunctionReaddir(SMBCCTX *c, smbc_readdir_fn fn) -{ - c->posix_emu.readdir_fn = fn; -} - -smbc_getdents_fn -smbc_getFunctionGetdents(SMBCCTX *c) -{ - return c->posix_emu.getdents_fn; -} - -void -smbc_setFunctionGetdents(SMBCCTX *c, smbc_getdents_fn fn) -{ - c->posix_emu.getdents_fn = fn; -} - -smbc_mkdir_fn -smbc_getFunctionMkdir(SMBCCTX *c) -{ - return c->posix_emu.mkdir_fn; -} - -void -smbc_setFunctionMkdir(SMBCCTX *c, smbc_mkdir_fn fn) -{ - c->posix_emu.mkdir_fn = fn; -} - -smbc_rmdir_fn -smbc_getFunctionRmdir(SMBCCTX *c) -{ - return c->posix_emu.rmdir_fn; -} - -void -smbc_setFunctionRmdir(SMBCCTX *c, smbc_rmdir_fn fn) -{ - c->posix_emu.rmdir_fn = fn; -} - -smbc_telldir_fn -smbc_getFunctionTelldir(SMBCCTX *c) -{ - return c->posix_emu.telldir_fn; -} - -void -smbc_setFunctionTelldir(SMBCCTX *c, smbc_telldir_fn fn) -{ - c->posix_emu.telldir_fn = fn; -} - -smbc_lseekdir_fn -smbc_getFunctionLseekdir(SMBCCTX *c) -{ - return c->posix_emu.lseekdir_fn; -} - -void -smbc_setFunctionLseekdir(SMBCCTX *c, smbc_lseekdir_fn fn) -{ - c->posix_emu.lseekdir_fn = fn; -} - -smbc_fstatdir_fn -smbc_getFunctionFstatdir(SMBCCTX *c) -{ - return c->posix_emu.fstatdir_fn; -} - -void -smbc_setFunctionFstatdir(SMBCCTX *c, smbc_fstatdir_fn fn) -{ - c->posix_emu.fstatdir_fn = fn; -} - - -/** - * Callable functions applicable to both files and directories. - */ - -smbc_chmod_fn -smbc_getFunctionChmod(SMBCCTX *c) -{ - return c->posix_emu.chmod_fn; -} - -void -smbc_setFunctionChmod(SMBCCTX *c, smbc_chmod_fn fn) -{ - c->posix_emu.chmod_fn = fn; -} - -smbc_utimes_fn -smbc_getFunctionUtimes(SMBCCTX *c) -{ - return c->posix_emu.utimes_fn; -} - -void -smbc_setFunctionUtimes(SMBCCTX *c, smbc_utimes_fn fn) -{ - c->posix_emu.utimes_fn = fn; -} - -smbc_setxattr_fn -smbc_getFunctionSetxattr(SMBCCTX *c) -{ - return c->posix_emu.setxattr_fn; -} - -void -smbc_setFunctionSetxattr(SMBCCTX *c, smbc_setxattr_fn fn) -{ - c->posix_emu.setxattr_fn = fn; -} - -smbc_getxattr_fn -smbc_getFunctionGetxattr(SMBCCTX *c) -{ - return c->posix_emu.getxattr_fn; -} - -void -smbc_setFunctionGetxattr(SMBCCTX *c, smbc_getxattr_fn fn) -{ - c->posix_emu.getxattr_fn = fn; -} - -smbc_removexattr_fn -smbc_getFunctionRemovexattr(SMBCCTX *c) -{ - return c->posix_emu.removexattr_fn; -} - -void -smbc_setFunctionRemovexattr(SMBCCTX *c, smbc_removexattr_fn fn) -{ - c->posix_emu.removexattr_fn = fn; -} - -smbc_listxattr_fn -smbc_getFunctionListxattr(SMBCCTX *c) -{ - return c->posix_emu.listxattr_fn; -} - -void -smbc_setFunctionListxattr(SMBCCTX *c, smbc_listxattr_fn fn) -{ - c->posix_emu.listxattr_fn = fn; -} - - -/** - * Callable functions related to printing - */ - -smbc_print_file_fn -smbc_getFunctionPrintFile(SMBCCTX *c) -{ - return c->printing.print_file_fn; -} - -void -smbc_setFunctionPrintFile(SMBCCTX *c, smbc_print_file_fn fn) -{ - c->printing.print_file_fn = fn; -} - -smbc_open_print_job_fn -smbc_getFunctionOpenPrintJob(SMBCCTX *c) -{ - return c->printing.open_print_job_fn; -} - -void -smbc_setFunctionOpenPrintJob(SMBCCTX *c, - smbc_open_print_job_fn fn) -{ - c->printing.open_print_job_fn = fn; -} - -smbc_list_print_jobs_fn -smbc_getFunctionListPrintJobs(SMBCCTX *c) -{ - return c->printing.list_print_jobs_fn; -} - -void -smbc_setFunctionListPrintJobs(SMBCCTX *c, - smbc_list_print_jobs_fn fn) -{ - c->printing.list_print_jobs_fn = fn; -} - -smbc_unlink_print_job_fn -smbc_getFunctionUnlinkPrintJob(SMBCCTX *c) -{ - return c->printing.unlink_print_job_fn; -} - -void -smbc_setFunctionUnlinkPrintJob(SMBCCTX *c, - smbc_unlink_print_job_fn fn) -{ - c->printing.unlink_print_job_fn = fn; -} - diff --git a/source3/libsmb/libsmb_dir.c b/source3/libsmb/libsmb_dir.c index 2ece2ab8ed..1486097d51 100644 --- a/source3/libsmb/libsmb_dir.c +++ b/source3/libsmb/libsmb_dir.c @@ -404,7 +404,7 @@ SMBC_opendir_ctx(SMBCCTX *context, } if (!user || user[0] == (char)0) { - user = talloc_strdup(frame, context->config.user); + user = talloc_strdup(frame, smbc_getUser(context)); if (!user) { errno = ENOMEM; TALLOC_FREE(frame); @@ -450,9 +450,9 @@ SMBC_opendir_ctx(SMBCCTX *context, } /* Determine how many local master browsers to query */ - max_lmb_count = (context->options.browse_max_lmb_count == 0 + max_lmb_count = (smbc_getOptionBrowseMaxLmbCount(context) == 0 ? INT_MAX - : context->options.browse_max_lmb_count); + : smbc_getOptionBrowseMaxLmbCount(context)); memset(&u_info, '\0', sizeof(u_info)); u_info.username = talloc_strdup(frame,user); @@ -810,11 +810,11 @@ SMBC_opendir_ctx(SMBCCTX *context, * good any more... */ if (cli_is_error(targetcli) && - (context->server.check_server_fn)(context, srv)) { + smbc_getFunctionCheckServer(context)(context, srv)) { /* ... then remove it. */ - if ((context->server.remove_unused_server_fn)(context, - srv)) { + if (smbc_getFunctionRemoveUnusedServer(context)(context, + srv)) { /* * We could not remove the * server completely, remove @@ -823,7 +823,7 @@ SMBC_opendir_ctx(SMBCCTX *context, * will be removed when the * last file/dir is closed. */ - (context->cache.remove_cached_server_fn)(context, srv); + smbc_getFunctionRemoveCachedServer(context)(context, srv); } } @@ -884,7 +884,7 @@ smbc_readdir_internal(SMBCCTX * context, struct smbc_dirent *src, int max_namebuf_len) { - if (context->options.urlencode_readdir_entries) { + if (smbc_getOptionUrlEncodeReaddirEntries(context)) { /* url-encode the name. get back remaining buffer space */ max_namebuf_len = @@ -1142,7 +1142,7 @@ SMBC_mkdir_ctx(SMBCCTX *context, } if (!user || user[0] == (char)0) { - user = talloc_strdup(frame, context->config.user); + user = talloc_strdup(frame, smbc_getUser(context)); if (!user) { errno = ENOMEM; TALLOC_FREE(frame); @@ -1249,7 +1249,7 @@ SMBC_rmdir_ctx(SMBCCTX *context, } if (!user || user[0] == (char)0) { - user = talloc_strdup(frame, context->config.user); + user = talloc_strdup(frame, smbc_getUser(context)); if (!user) { errno = ENOMEM; TALLOC_FREE(frame); @@ -1531,7 +1531,7 @@ SMBC_chmod_ctx(SMBCCTX *context, } if (!user || user[0] == (char)0) { - user = talloc_strdup(frame, context->config.user); + user = talloc_strdup(frame, smbc_getUser(context)); if (!user) { errno = ENOMEM; TALLOC_FREE(frame); @@ -1637,7 +1637,7 @@ SMBC_utimes_ctx(SMBCCTX *context, } if (!user || user[0] == (char)0) { - user = talloc_strdup(frame, context->config.user); + user = talloc_strdup(frame, smbc_getUser(context)); if (!user) { errno = ENOMEM; TALLOC_FREE(frame); @@ -1713,7 +1713,7 @@ SMBC_unlink_ctx(SMBCCTX *context, } if (!user || user[0] == (char)0) { - user = talloc_strdup(frame, context->config.user); + user = talloc_strdup(frame, smbc_getUser(context)); if (!user) { errno = ENOMEM; TALLOC_FREE(frame); @@ -1848,7 +1848,7 @@ SMBC_rename_ctx(SMBCCTX *ocontext, } if (!user1 || user1[0] == (char)0) { - user1 = talloc_strdup(frame, ocontext->config.user); + user1 = talloc_strdup(frame, smbc_getUser(ocontext)); if (!user1) { errno = ENOMEM; TALLOC_FREE(frame); @@ -1872,7 +1872,7 @@ SMBC_rename_ctx(SMBCCTX *ocontext, } if (!user2 || user2[0] == (char)0) { - user2 = talloc_strdup(frame, ncontext->config.user); + user2 = talloc_strdup(frame, smbc_getUser(ncontext)); if (!user2) { errno = ENOMEM; TALLOC_FREE(frame); diff --git a/source3/libsmb/libsmb_file.c b/source3/libsmb/libsmb_file.c index 73c9b96978..423450b23e 100644 --- a/source3/libsmb/libsmb_file.c +++ b/source3/libsmb/libsmb_file.c @@ -82,7 +82,7 @@ SMBC_open_ctx(SMBCCTX *context, } if (!user || user[0] == (char)0) { - user = talloc_strdup(frame, context->config.user); + user = talloc_strdup(frame, smbc_getUser(context)); if (!user) { errno = ENOMEM; TALLOC_FREE(frame); @@ -188,7 +188,7 @@ SMBC_open_ctx(SMBCCTX *context, int eno = 0; eno = SMBC_errno(context, srv->cli); - file = (context->posix_emu.opendir_fn)(context, fname); + file = smbc_getFunctionOpendir(context)(context, fname); if (!file) errno = eno; TALLOC_FREE(frame); return file; @@ -439,7 +439,7 @@ SMBC_close_ctx(SMBCCTX *context, /* IS a dir ... */ if (!file->file) { TALLOC_FREE(frame); - return (context->posix_emu.closedir_fn)(context, file); + return smbc_getFunctionClosedir(context)(context, file); } /*d_printf(">>>close: parsing %s\n", file->fname);*/ @@ -478,7 +478,7 @@ SMBC_close_ctx(SMBCCTX *context, DLIST_REMOVE(context->internal->files, file); SAFE_FREE(file->fname); SAFE_FREE(file); - (context->server.remove_unused_server_fn)(context, srv); + smbc_getFunctionRemoveUnusedServer(context)(context, srv); TALLOC_FREE(frame); return -1; diff --git a/source3/libsmb/libsmb_path.c b/source3/libsmb/libsmb_path.c index c962f898e0..2c3a5f8866 100644 --- a/source3/libsmb/libsmb_path.c +++ b/source3/libsmb/libsmb_path.c @@ -253,7 +253,7 @@ SMBC_parse_path(TALLOC_CTX *ctx, */ if (pp_workgroup != NULL) { *pp_workgroup = - talloc_strdup(ctx, context->config.workgroup); + talloc_strdup(ctx, smbc_getWorkgroup(context)); } if (pp_options) { @@ -297,13 +297,13 @@ SMBC_parse_path(TALLOC_CTX *ctx, } if (*p == '/') { - int wl = strlen(context->config.workgroup); + int wl = strlen(smbc_getWorkgroup(context)); if (wl > 16) { wl = 16; } - *pp_server = talloc_strdup(ctx, context->config.workgroup); + *pp_server = talloc_strdup(ctx, smbc_getWorkgroup(context)); if (!*pp_server) { return -1; } diff --git a/source3/libsmb/libsmb_printjob.c b/source3/libsmb/libsmb_printjob.c index 545225cae4..c8d7ad039d 100644 --- a/source3/libsmb/libsmb_printjob.c +++ b/source3/libsmb/libsmb_printjob.c @@ -75,7 +75,7 @@ SMBC_open_print_job_ctx(SMBCCTX *context, /* What if the path is empty, or the file exists? */ TALLOC_FREE(frame); - return (context->posix_emu.open_fn)(context, fname, O_WRONLY, 666); + return smbc_getFunctionOpen(context)(context, fname, O_WRONLY, 666); } /* @@ -222,7 +222,7 @@ SMBC_list_print_jobs_ctx(SMBCCTX *context, } if (!user || user[0] == (char)0) { - user = talloc_strdup(frame, context->config.user); + user = talloc_strdup(frame, smbc_getUser(context)); if (!user) { errno = ENOMEM; TALLOC_FREE(frame); @@ -300,7 +300,7 @@ SMBC_unlink_print_job_ctx(SMBCCTX *context, } if (!user || user[0] == (char)0) { - user = talloc_strdup(frame, context->config.user); + user = talloc_strdup(frame, smbc_getUser(context)); if (!user) { errno = ENOMEM; TALLOC_FREE(frame); diff --git a/source3/libsmb/libsmb_server.c b/source3/libsmb/libsmb_server.c index 4f51388870..64eb1ea584 100644 --- a/source3/libsmb/libsmb_server.c +++ b/source3/libsmb/libsmb_server.c @@ -80,7 +80,7 @@ SMBC_remove_unused_server(SMBCCTX * context, DEBUG(3, ("smbc_remove_usused_server: %p removed.\n", srv)); - (context->cache.remove_cached_server_fn)(context, srv); + smbc_getFunctionRemoveCachedServer(context)(context, srv); SAFE_FREE(srv); return 0; @@ -106,11 +106,10 @@ SMBC_call_auth_fn(TALLOC_CTX *ctx, strlcpy(username, *pp_username, sizeof(username)); strlcpy(password, *pp_password, sizeof(password)); - (context->server.get_auth_data_fn)( - server, share, - workgroup, sizeof(workgroup), - username, sizeof(username), - password, sizeof(password)); + smbc_getFunctionAuthData(context)(server, share, + workgroup, sizeof(workgroup), + username, sizeof(username), + password, sizeof(password)); TALLOC_FREE(*pp_workgroup); TALLOC_FREE(*pp_username); @@ -147,10 +146,10 @@ SMBC_find_server(TALLOC_CTX *ctx, check_server_cache: - srv = (context->cache.get_cached_server_fn)(context, - server, share, - *pp_workgroup, - *pp_username); + srv = smbc_getFunctionGetCachedServer(context)(context, + server, share, + *pp_workgroup, + *pp_username); if (!auth_called && !srv && (!*pp_username || !(*pp_username)[0] || !*pp_password || !(*pp_password)[0])) { @@ -172,22 +171,22 @@ check_server_cache: } if (srv) { - if ((context->server.check_server_fn)(context, srv)) { + if (smbc_getFunctionCheckServer(context)(context, srv)) { /* * This server is no good anymore * Try to remove it and check for more possible * servers in the cache */ - if ((context->server.remove_unused_server_fn)(context, - srv)) { + if (smbc_getFunctionRemoveUnusedServer(context)(context, + srv)) { /* * We could not remove the server completely, * remove it from the cache so we will not get * it again. It will be removed when the last * file/dir is closed. */ - (context->cache.remove_cached_server_fn)(context, - srv); + smbc_getFunctionRemoveCachedServer(context)(context, + srv); } /* @@ -251,12 +250,14 @@ SMBC_server(TALLOC_CTX *ctx, * If we found a connection and we're only allowed one share per * server... */ - if (srv && *share != '\0' && context->options.one_share_per_server) { + if (srv && + *share != '\0' && + smbc_getOptionOneSharePerServer(context)) { /* * ... then if there's no current connection to the share, * connect to it. SMBC_find_server(), or rather the function - * pointed to by context->cache.get_cached_srv_fn which + * pointed to by context->get_cached_srv_fn which * was called by SMBC_find_server(), will have issued a tree * disconnect if the requested share is not the same as the * one that was already connected. @@ -272,8 +273,8 @@ SMBC_server(TALLOC_CTX *ctx, errno = ENOMEM; cli_shutdown(srv->cli); srv->cli = NULL; - (context->cache.remove_cached_server_fn)(context, - srv); + smbc_getFunctionRemoveCachedServer(context)(context, + srv); return NULL; } @@ -290,8 +291,8 @@ SMBC_server(TALLOC_CTX *ctx, errno = SMBC_errno(context, srv->cli); cli_shutdown(srv->cli); srv->cli = NULL; - (context->cache.remove_cached_server_fn)(context, - srv); + smbc_getFunctionRemoveCachedServer(context)(context, + srv); srv = NULL; } @@ -324,7 +325,7 @@ SMBC_server(TALLOC_CTX *ctx, return NULL; } - make_nmb_name(&calling, context->config.netbios_name, 0x0); + make_nmb_name(&calling, smbc_getNetbiosName(context), 0x0); make_nmb_name(&called , server, 0x20); DEBUG(4,("SMBC_server: server_n=[%s] server=[%s]\n", server_n, server)); @@ -341,14 +342,15 @@ again: return NULL; } - if (context->flags.bits & SMB_CTX_FLAG_USE_KERBEROS) { + if (smbc_getOptionUseKerberos(context)) { c->use_kerberos = True; } - if (context->flags.bits & SMB_CTX_FLAG_FALLBACK_AFTER_KERBEROS) { + + if (smbc_getOptionFallbackAfterKerberos(context)) { c->fallback_after_kerberos = True; } - c->timeout = context->config.timeout; + c->timeout = smbc_getTimeout(context); /* * Force use of port 139 for first try if share is $IPC, empty, or @@ -435,8 +437,7 @@ again: /* Failed. Try an anonymous login, if allowed by flags. */ username_used = ""; - if ((context->flags.bits & - SMBCCTX_FLAG_NO_AUTO_ANONYMOUS_LOGON) || + if (smbc_getOptionNoAutoAnonymousLogin(context) || !NT_STATUS_IS_OK(cli_session_setup(c, username_used, *pp_password, 1, *pp_password, 0, @@ -504,10 +505,10 @@ again: /* now add it to the cache (internal or external) */ /* Let the cache function set errno if it wants to */ errno = 0; - if ((context->cache.add_cached_server_fn)(context, srv, - server, share, - *pp_workgroup, - *pp_username)) { + if (smbc_getFunctionAddCachedServer(context)(context, srv, + server, share, + *pp_workgroup, + *pp_username)) { int saved_errno = errno; DEBUG(3, (" Failed to add server to cache\n")); errno = saved_errno; @@ -576,7 +577,7 @@ SMBC_attr_server(TALLOC_CTX *ctx, } flags = 0; - if (context->flags.bits & SMB_CTX_FLAG_USE_KERBEROS) { + if (smbc_getOptionUseKerberos(context)) { flags |= CLI_FULL_CONNECTION_USE_KERBEROS; } @@ -664,11 +665,11 @@ SMBC_attr_server(TALLOC_CTX *ctx, /* now add it to the cache (internal or external) */ errno = 0; /* let cache function set errno if it likes */ - if ((context->cache.add_cached_server_fn)(context, ipc_srv, - server, - "*IPC$", - *pp_workgroup, - *pp_username)) { + if (smbc_getFunctionAddCachedServer(context)(context, ipc_srv, + server, + "*IPC$", + *pp_workgroup, + *pp_username)) { DEBUG(3, (" Failed to add server to cache\n")); if (errno == 0) { errno = ENOMEM; diff --git a/source3/libsmb/libsmb_setget.c b/source3/libsmb/libsmb_setget.c new file mode 100644 index 0000000000..d0823bd77e --- /dev/null +++ b/source3/libsmb/libsmb_setget.c @@ -0,0 +1,905 @@ +/* + Unix SMB/Netbios implementation. + SMB client library implementation + Copyright (C) Andrew Tridgell 1998 + Copyright (C) Richard Sharpe 2000, 2002 + Copyright (C) John Terpstra 2000 + Copyright (C) Tom Jansen (Ninja ISD) 2002 + Copyright (C) Derrell Lipman 2003-2008 + Copyright (C) Jeremy Allison 2007, 2008 + + 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 3 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, see <http://www.gnu.org/licenses/>. +*/ + +#include "includes.h" +#define __LIBSMBCLIENT_INTERNAL__ +#include "libsmbclient.h" +#include "libsmb_internal.h" + + +/** Get the netbios name used for making connections */ +char * +smbc_getNetbiosName(SMBCCTX *c) +{ + return c->netbios_name; +} + +/** Set the netbios name used for making connections */ +void +smbc_setNetbiosName(SMBCCTX *c, char * netbios_name) +{ + c->netbios_name = netbios_name; +} + +/** Get the workgroup used for making connections */ +char * +smbc_getWorkgroup(SMBCCTX *c) +{ + return c->workgroup; +} + +/** Set the workgroup used for making connections */ +void +smbc_setWorkgroup(SMBCCTX *c, char * workgroup) +{ + c->workgroup = workgroup; +} + +/** Get the username used for making connections */ +char * +smbc_getUser(SMBCCTX *c) +{ + return c->user; +} + +/** Set the username used for making connections */ +void +smbc_setUser(SMBCCTX *c, char * user) +{ + c->user = user; +} + +/** Get the debug level */ +int +smbc_getDebug(SMBCCTX *c) +{ + return c->debug; +} + +/** Set the debug level */ +void +smbc_setDebug(SMBCCTX *c, int debug) +{ + c->debug = debug; + DEBUGLEVEL = debug; +} + +/** + * Get the timeout used for waiting on connections and response data + * (in milliseconds) + */ +int +smbc_getTimeout(SMBCCTX *c) +{ + return c->timeout; +} + +/** + * Set the timeout used for waiting on connections and response data + * (in milliseconds) + */ +void +smbc_setTimeout(SMBCCTX *c, int timeout) +{ + c->timeout = timeout; +} + +/** Get whether to log to standard error instead of standard output */ +smbc_bool +smbc_getOptionDebugToStderr(SMBCCTX *c) +{ + return c->internal->debug_stderr; +} + +/** Set whether to log to standard error instead of standard output */ +void +smbc_setOptionDebugToStderr(SMBCCTX *c, smbc_bool b) +{ + c->internal->debug_stderr = b; +} + +/** + * Get whether to use new-style time attribute names, e.g. WRITE_TIME rather + * than the old-style names such as M_TIME. This allows also setting/getting + * CREATE_TIME which was previously unimplemented. (Note that the old C_TIME + * was supposed to be CHANGE_TIME but was confused and sometimes referred to + * CREATE_TIME.) + */ +smbc_bool +smbc_getOptionFullTimeNames(SMBCCTX *c) +{ + return c->internal->full_time_names; +} + +/** + * Set whether to use new-style time attribute names, e.g. WRITE_TIME rather + * than the old-style names such as M_TIME. This allows also setting/getting + * CREATE_TIME which was previously unimplemented. (Note that the old C_TIME + * was supposed to be CHANGE_TIME but was confused and sometimes referred to + * CREATE_TIME.) + */ +void +smbc_setOptionFullTimeNames(SMBCCTX *c, smbc_bool b) +{ + c->internal->full_time_names = b; +} + +/** + * Get the share mode to use for files opened with SMBC_open_ctx(). The + * default is SMBC_SHAREMODE_DENY_NONE. + */ +smbc_share_mode +smbc_getOptionOpenShareMode(SMBCCTX *c) +{ + return c->internal->share_mode; +} + +/** + * Set the share mode to use for files opened with SMBC_open_ctx(). The + * default is SMBC_SHAREMODE_DENY_NONE. + */ +void +smbc_setOptionOpenShareMode(SMBCCTX *c, smbc_share_mode share_mode) +{ + c->internal->share_mode = share_mode; +} + +/** Retrieve a previously set user data handle */ +void * +smbc_getOptionUserData(SMBCCTX *c) +{ + return c->internal->user_data; +} + +/** Save a user data handle */ +void +smbc_setOptionUserData(SMBCCTX *c, void *user_data) +{ + c->internal->user_data = user_data; +} + +/** Get the encoded value for encryption level. */ +smbc_smb_encrypt_level +smbc_getOptionSmbEncryptionLevel(SMBCCTX *c) +{ + return c->internal->smb_encryption_level; +} + +/** Set the encoded value for encryption level. */ +void +smbc_setOptionSmbEncryptionLevel(SMBCCTX *c, smbc_smb_encrypt_level level) +{ + c->internal->smb_encryption_level = level; +} + +/** + * Get from how many local master browsers should the list of workgroups be + * retrieved. It can take up to 12 minutes or longer after a server becomes a + * local master browser, for it to have the entire browse list (the list of + * workgroups/domains) from an entire network. Since a client never knows + * which local master browser will be found first, the one which is found + * first and used to retrieve a browse list may have an incomplete or empty + * browse list. By requesting the browse list from multiple local master + * browsers, a more complete list can be generated. For small networks (few + * workgroups), it is recommended that this value be set to 0, causing the + * browse lists from all found local master browsers to be retrieved and + * merged. For networks with many workgroups, a suitable value for this + * variable is probably somewhere around 3. (Default: 3). + */ +int +smbc_getOptionBrowseMaxLmbCount(SMBCCTX *c) +{ + return c->options.browse_max_lmb_count; +} + +/** + * Set from how many local master browsers should the list of workgroups be + * retrieved. It can take up to 12 minutes or longer after a server becomes a + * local master browser, for it to have the entire browse list (the list of + * workgroups/domains) from an entire network. Since a client never knows + * which local master browser will be found first, the one which is found + * first and used to retrieve a browse list may have an incomplete or empty + * browse list. By requesting the browse list from multiple local master + * browsers, a more complete list can be generated. For small networks (few + * workgroups), it is recommended that this value be set to 0, causing the + * browse lists from all found local master browsers to be retrieved and + * merged. For networks with many workgroups, a suitable value for this + * variable is probably somewhere around 3. (Default: 3). + */ +void +smbc_setOptionBrowseMaxLmbCount(SMBCCTX *c, int count) +{ + c->options.browse_max_lmb_count = count; +} + +/** + * Get whether to url-encode readdir entries. + * + * There is a difference in the desired return strings from + * smbc_readdir() depending upon whether the filenames are to + * be displayed to the user, or whether they are to be + * appended to the path name passed to smbc_opendir() to call + * a further smbc_ function (e.g. open the file with + * smbc_open()). In the former case, the filename should be + * in "human readable" form. In the latter case, the smbc_ + * functions expect a URL which must be url-encoded. Those + * functions decode the URL. If, for example, smbc_readdir() + * returned a file name of "abc%20def.txt", passing a path + * with this file name attached to smbc_open() would cause + * smbc_open to attempt to open the file "abc def.txt" since + * the %20 is decoded into a space. + * + * Set this option to True if the names returned by + * smbc_readdir() should be url-encoded such that they can be + * passed back to another smbc_ call. Set it to False if the + * names returned by smbc_readdir() are to be presented to the + * user. + * + * For backwards compatibility, this option defaults to False. + */ +smbc_bool +smbc_getOptionUrlEncodeReaddirEntries(SMBCCTX *c) +{ + return c->options.urlencode_readdir_entries; +} + +/** + * Set whether to url-encode readdir entries. + * + * There is a difference in the desired return strings from + * smbc_readdir() depending upon whether the filenames are to + * be displayed to the user, or whether they are to be + * appended to the path name passed to smbc_opendir() to call + * a further smbc_ function (e.g. open the file with + * smbc_open()). In the former case, the filename should be + * in "human readable" form. In the latter case, the smbc_ + * functions expect a URL which must be url-encoded. Those + * functions decode the URL. If, for example, smbc_readdir() + * returned a file name of "abc%20def.txt", passing a path + * with this file name attached to smbc_open() would cause + * smbc_open to attempt to open the file "abc def.txt" since + * the %20 is decoded into a space. + * + * Set this option to True if the names returned by + * smbc_readdir() should be url-encoded such that they can be + * passed back to another smbc_ call. Set it to False if the + * names returned by smbc_readdir() are to be presented to the + * user. + * + * For backwards compatibility, this option defaults to False. + */ +void +smbc_setOptionUrlEncodeReaddirEntries(SMBCCTX *c, smbc_bool b) +{ + c->options.urlencode_readdir_entries = b; +} + +/** + * Get whether to use the same connection for all shares on a server. + * + * Some Windows versions appear to have a limit to the number + * of concurrent SESSIONs and/or TREE CONNECTions. In + * one-shot programs (i.e. the program runs and then quickly + * ends, thereby shutting down all connections), it is + * probably reasonable to establish a new connection for each + * share. In long-running applications, the limitation can be + * avoided by using only a single connection to each server, + * and issuing a new TREE CONNECT when the share is accessed. + */ +smbc_bool +smbc_getOptionOneSharePerServer(SMBCCTX *c) +{ + return c->options.one_share_per_server; +} + +/** + * Set whether to use the same connection for all shares on a server. + * + * Some Windows versions appear to have a limit to the number + * of concurrent SESSIONs and/or TREE CONNECTions. In + * one-shot programs (i.e. the program runs and then quickly + * ends, thereby shutting down all connections), it is + * probably reasonable to establish a new connection for each + * share. In long-running applications, the limitation can be + * avoided by using only a single connection to each server, + * and issuing a new TREE CONNECT when the share is accessed. + */ +void +smbc_setOptionOneSharePerServer(SMBCCTX *c, smbc_bool b) +{ + c->options.one_share_per_server = b; +} + +/** Get whether to enable use of kerberos */ +smbc_bool +smbc_getOptionUseKerberos(SMBCCTX *c) +{ + return c->flags & SMB_CTX_FLAG_USE_KERBEROS ? True : False; +} + +/** Set whether to enable use of kerberos */ +void +smbc_setOptionUseKerberos(SMBCCTX *c, smbc_bool b) +{ + if (b) { + c->flags |= SMB_CTX_FLAG_USE_KERBEROS; + } else { + c->flags &= ~SMB_CTX_FLAG_USE_KERBEROS; + } +} + +/** Get whether to fallback after kerberos */ +smbc_bool +smbc_getOptionFallbackAfterKerberos(SMBCCTX *c) +{ + return c->flags & SMB_CTX_FLAG_FALLBACK_AFTER_KERBEROS ? True : False; +} + +/** Set whether to fallback after kerberos */ +void +smbc_setOptionFallbackAfterKerberos(SMBCCTX *c, smbc_bool b) +{ + if (b) { + c->flags |= SMB_CTX_FLAG_FALLBACK_AFTER_KERBEROS; + } else { + c->flags &= ~SMB_CTX_FLAG_FALLBACK_AFTER_KERBEROS; + } +} + +/** Get whether to automatically select anonymous login */ +smbc_bool +smbc_getOptionNoAutoAnonymousLogin(SMBCCTX *c) +{ + return c->flags & SMBCCTX_FLAG_NO_AUTO_ANONYMOUS_LOGON ? True : False; +} + +/** Set whether to automatically select anonymous login */ +void +smbc_setOptionNoAutoAnonymousLogin(SMBCCTX *c, smbc_bool b) +{ + if (b) { + c->flags |= SMBCCTX_FLAG_NO_AUTO_ANONYMOUS_LOGON; + } else { + c->flags &= ~SMBCCTX_FLAG_NO_AUTO_ANONYMOUS_LOGON; + } +} + +/** Get the function for obtaining authentication data */ +smbc_get_auth_data_fn +smbc_getFunctionAuthData(SMBCCTX *c) +{ + return c->callbacks.auth_fn; +} + +/** Set the function for obtaining authentication data */ +void +smbc_setFunctionAuthData(SMBCCTX *c, smbc_get_auth_data_fn fn) +{ + c->internal->auth_fn_with_context = NULL; + c->callbacks.auth_fn = fn; +} + +/** Get the new-style authentication function which includes the context. */ +smbc_get_auth_data_with_context_fn +smbc_getFunctionAuthDataWithContext(SMBCCTX *c) +{ + return c->internal->auth_fn_with_context; +} + +/** Set the new-style authentication function which includes the context. */ +void +smbc_setFunctionAuthDataWithContext(SMBCCTX *c, + smbc_get_auth_data_with_context_fn fn) +{ + c->callbacks.auth_fn = NULL; + c->internal->auth_fn_with_context = fn; +} + +/** Get the function for checking if a server is still good */ +smbc_check_server_fn +smbc_getFunctionCheckServer(SMBCCTX *c) +{ + return c->callbacks.check_server_fn; +} + +/** Set the function for checking if a server is still good */ +void +smbc_setFunctionCheckServer(SMBCCTX *c, smbc_check_server_fn fn) +{ + c->callbacks.check_server_fn = fn; +} + +/** Get the function for removing a server if unused */ +smbc_remove_unused_server_fn +smbc_getFunctionRemoveUnusedServer(SMBCCTX *c) +{ + return c->callbacks.remove_unused_server_fn; +} + +/** Set the function for removing a server if unused */ +void +smbc_setFunctionRemoveUnusedServer(SMBCCTX *c, + smbc_remove_unused_server_fn fn) +{ + c->callbacks.remove_unused_server_fn = fn; +} + +/** Get the function for adding a cached server */ +smbc_add_cached_srv_fn +smbc_getFunctionAddCachedServer(SMBCCTX *c) +{ + return c->callbacks.add_cached_srv_fn; +} + +/** Set the function for adding a cached server */ +void +smbc_setFunctionAddCachedServer(SMBCCTX *c, smbc_add_cached_srv_fn fn) +{ + c->callbacks.add_cached_srv_fn = fn; +} + +/** Get the function for server cache lookup */ +smbc_get_cached_srv_fn +smbc_getFunctionGetCachedServer(SMBCCTX *c) +{ + return c->callbacks.get_cached_srv_fn; +} + +/** Set the function for server cache lookup */ +void +smbc_setFunctionGetCachedServer(SMBCCTX *c, smbc_get_cached_srv_fn fn) +{ + c->callbacks.get_cached_srv_fn = fn; +} + +/** Get the function for server cache removal */ +smbc_remove_cached_srv_fn +smbc_getFunctionRemoveCachedServer(SMBCCTX *c) +{ + return c->callbacks.remove_cached_srv_fn; +} + +/** Set the function for server cache removal */ +void +smbc_setFunctionRemoveCachedServer(SMBCCTX *c, + smbc_remove_cached_srv_fn fn) +{ + c->callbacks.remove_cached_srv_fn = fn; +} + +/** + * Get the function for server cache purging. This function tries to + * remove all cached servers (e.g. on disconnect) + */ +smbc_purge_cached_fn +smbc_getFunctionPurgeCachedServers(SMBCCTX *c) +{ + return c->callbacks.purge_cached_fn; +} + +/** Set the function to store private data of the server cache */ +void smbc_setServerCacheData(SMBCCTX *c, struct smbc_server_cache * cache) +{ + c->internal->server_cache = cache; +} + +/** Get the function to store private data of the server cache */ +struct smbc_server_cache * smbc_getServerCacheData(SMBCCTX *c) +{ + return c->internal->server_cache; +} + + +/** + * Set the function for server cache purging. This function tries to + * remove all cached servers (e.g. on disconnect) + */ +void +smbc_setFunctionPurgeCachedServers(SMBCCTX *c, smbc_purge_cached_fn fn) +{ + c->callbacks.purge_cached_fn = fn; +} + +/** + * Callable functions for files. + */ + +smbc_open_fn +smbc_getFunctionOpen(SMBCCTX *c) +{ + return c->open; +} + +void +smbc_setFunctionOpen(SMBCCTX *c, smbc_open_fn fn) +{ + c->open = fn; +} + +smbc_creat_fn +smbc_getFunctionCreat(SMBCCTX *c) +{ + return c->creat; +} + +void +smbc_setFunctionCreat(SMBCCTX *c, smbc_creat_fn fn) +{ + c->creat = fn; +} + +smbc_read_fn +smbc_getFunctionRead(SMBCCTX *c) +{ + return c->read; +} + +void +smbc_setFunctionRead(SMBCCTX *c, smbc_read_fn fn) +{ + c->read = fn; +} + +smbc_write_fn +smbc_getFunctionWrite(SMBCCTX *c) +{ + return c->write; +} + +void +smbc_setFunctionWrite(SMBCCTX *c, smbc_write_fn fn) +{ + c->write = fn; +} + +smbc_unlink_fn +smbc_getFunctionUnlink(SMBCCTX *c) +{ + return c->unlink; +} + +void +smbc_setFunctionUnlink(SMBCCTX *c, smbc_unlink_fn fn) +{ + c->unlink = fn; +} + +smbc_rename_fn +smbc_getFunctionRename(SMBCCTX *c) +{ + return c->rename; +} + +void +smbc_setFunctionRename(SMBCCTX *c, smbc_rename_fn fn) +{ + c->rename = fn; +} + +smbc_lseek_fn +smbc_getFunctionLseek(SMBCCTX *c) +{ + return c->lseek; +} + +void +smbc_setFunctionLseek(SMBCCTX *c, smbc_lseek_fn fn) +{ + c->lseek = fn; +} + +smbc_stat_fn +smbc_getFunctionStat(SMBCCTX *c) +{ + return c->stat; +} + +void +smbc_setFunctionStat(SMBCCTX *c, smbc_stat_fn fn) +{ + c->stat = fn; +} + +smbc_fstat_fn +smbc_getFunctionFstat(SMBCCTX *c) +{ + return c->fstat; +} + +void +smbc_setFunctionFstat(SMBCCTX *c, smbc_fstat_fn fn) +{ + c->fstat = fn; +} + +smbc_ftruncate_fn +smbc_getFunctionFtruncate(SMBCCTX *c) +{ + return c->internal->posix_emu.ftruncate_fn; +} + +void +smbc_setFunctionFtruncate(SMBCCTX *c, smbc_ftruncate_fn fn) +{ + c->internal->posix_emu.ftruncate_fn = fn; +} + +smbc_close_fn +smbc_getFunctionClose(SMBCCTX *c) +{ + return c->close_fn; +} + +void +smbc_setFunctionClose(SMBCCTX *c, smbc_close_fn fn) +{ + c->close_fn = fn; +} + + +/** + * Callable functions for directories. + */ + +smbc_opendir_fn +smbc_getFunctionOpendir(SMBCCTX *c) +{ + return c->opendir; +} + +void +smbc_setFunctionOpendir(SMBCCTX *c, smbc_opendir_fn fn) +{ + c->opendir = fn; +} + +smbc_closedir_fn +smbc_getFunctionClosedir(SMBCCTX *c) +{ + return c->closedir; +} + +void +smbc_setFunctionClosedir(SMBCCTX *c, smbc_closedir_fn fn) +{ + c->closedir = fn; +} + +smbc_readdir_fn +smbc_getFunctionReaddir(SMBCCTX *c) +{ + return c->readdir; +} + +void +smbc_setFunctionReaddir(SMBCCTX *c, smbc_readdir_fn fn) +{ + c->readdir = fn; +} + +smbc_getdents_fn +smbc_getFunctionGetdents(SMBCCTX *c) +{ + return c->getdents; +} + +void +smbc_setFunctionGetdents(SMBCCTX *c, smbc_getdents_fn fn) +{ + c->getdents = fn; +} + +smbc_mkdir_fn +smbc_getFunctionMkdir(SMBCCTX *c) +{ + return c->mkdir; +} + +void +smbc_setFunctionMkdir(SMBCCTX *c, smbc_mkdir_fn fn) +{ + c->mkdir = fn; +} + +smbc_rmdir_fn +smbc_getFunctionRmdir(SMBCCTX *c) +{ + return c->rmdir; +} + +void +smbc_setFunctionRmdir(SMBCCTX *c, smbc_rmdir_fn fn) +{ + c->rmdir = fn; +} + +smbc_telldir_fn +smbc_getFunctionTelldir(SMBCCTX *c) +{ + return c->telldir; +} + +void +smbc_setFunctionTelldir(SMBCCTX *c, smbc_telldir_fn fn) +{ + c->telldir = fn; +} + +smbc_lseekdir_fn +smbc_getFunctionLseekdir(SMBCCTX *c) +{ + return c->lseekdir; +} + +void +smbc_setFunctionLseekdir(SMBCCTX *c, smbc_lseekdir_fn fn) +{ + c->lseekdir = fn; +} + +smbc_fstatdir_fn +smbc_getFunctionFstatdir(SMBCCTX *c) +{ + return c->fstatdir; +} + +void +smbc_setFunctionFstatdir(SMBCCTX *c, smbc_fstatdir_fn fn) +{ + c->fstatdir = fn; +} + + +/** + * Callable functions applicable to both files and directories. + */ + +smbc_chmod_fn +smbc_getFunctionChmod(SMBCCTX *c) +{ + return c->chmod; +} + +void +smbc_setFunctionChmod(SMBCCTX *c, smbc_chmod_fn fn) +{ + c->chmod = fn; +} + +smbc_utimes_fn +smbc_getFunctionUtimes(SMBCCTX *c) +{ + return c->utimes; +} + +void +smbc_setFunctionUtimes(SMBCCTX *c, smbc_utimes_fn fn) +{ + c->utimes = fn; +} + +smbc_setxattr_fn +smbc_getFunctionSetxattr(SMBCCTX *c) +{ + return c->setxattr; +} + +void +smbc_setFunctionSetxattr(SMBCCTX *c, smbc_setxattr_fn fn) +{ + c->setxattr = fn; +} + +smbc_getxattr_fn +smbc_getFunctionGetxattr(SMBCCTX *c) +{ + return c->getxattr; +} + +void +smbc_setFunctionGetxattr(SMBCCTX *c, smbc_getxattr_fn fn) +{ + c->getxattr = fn; +} + +smbc_removexattr_fn +smbc_getFunctionRemovexattr(SMBCCTX *c) +{ + return c->removexattr; +} + +void +smbc_setFunctionRemovexattr(SMBCCTX *c, smbc_removexattr_fn fn) +{ + c->removexattr = fn; +} + +smbc_listxattr_fn +smbc_getFunctionListxattr(SMBCCTX *c) +{ + return c->listxattr; +} + +void +smbc_setFunctionListxattr(SMBCCTX *c, smbc_listxattr_fn fn) +{ + c->listxattr = fn; +} + + +/** + * Callable functions related to printing + */ + +smbc_print_file_fn +smbc_getFunctionPrintFile(SMBCCTX *c) +{ + return c->print_file; +} + +void +smbc_setFunctionPrintFile(SMBCCTX *c, smbc_print_file_fn fn) +{ + c->print_file = fn; +} + +smbc_open_print_job_fn +smbc_getFunctionOpenPrintJob(SMBCCTX *c) +{ + return c->open_print_job; +} + +void +smbc_setFunctionOpenPrintJob(SMBCCTX *c, + smbc_open_print_job_fn fn) +{ + c->open_print_job = fn; +} + +smbc_list_print_jobs_fn +smbc_getFunctionListPrintJobs(SMBCCTX *c) +{ + return c->list_print_jobs; +} + +void +smbc_setFunctionListPrintJobs(SMBCCTX *c, + smbc_list_print_jobs_fn fn) +{ + c->list_print_jobs = fn; +} + +smbc_unlink_print_job_fn +smbc_getFunctionUnlinkPrintJob(SMBCCTX *c) +{ + return c->unlink_print_job; +} + +void +smbc_setFunctionUnlinkPrintJob(SMBCCTX *c, + smbc_unlink_print_job_fn fn) +{ + c->unlink_print_job = fn; +} + diff --git a/source3/libsmb/libsmb_stat.c b/source3/libsmb/libsmb_stat.c index b733eab74f..27546f687e 100644 --- a/source3/libsmb/libsmb_stat.c +++ b/source3/libsmb/libsmb_stat.c @@ -157,7 +157,7 @@ SMBC_stat_ctx(SMBCCTX *context, } if (!user || user[0] == (char)0) { - user = talloc_strdup(frame,context->config.user); + user = talloc_strdup(frame, smbc_getUser(context)); if (!user) { errno = ENOMEM; TALLOC_FREE(frame); @@ -237,7 +237,7 @@ SMBC_fstat_ctx(SMBCCTX *context, if (!file->file) { TALLOC_FREE(frame); - return (context->posix_emu.fstatdir_fn)(context, file, st); + return smbc_getFunctionFstatdir(context)(context, file, st); } /*d_printf(">>>fstat: parsing %s\n", file->fname);*/ diff --git a/source3/libsmb/libsmb_xattr.c b/source3/libsmb/libsmb_xattr.c index 3c08412d59..e17146e611 100644 --- a/source3/libsmb/libsmb_xattr.c +++ b/source3/libsmb/libsmb_xattr.c @@ -1729,7 +1729,7 @@ SMBC_setxattr_ctx(SMBCCTX *context, } if (!user || user[0] == (char)0) { - user = talloc_strdup(frame, context->config.user); + user = talloc_strdup(frame, smbc_getUser(context)); if (!user) { errno = ENOMEM; TALLOC_FREE(frame); @@ -2023,7 +2023,7 @@ SMBC_getxattr_ctx(SMBCCTX *context, } if (!user || user[0] == (char)0) { - user = talloc_strdup(frame, context->config.user); + user = talloc_strdup(frame, smbc_getUser(context)); if (!user) { errno = ENOMEM; TALLOC_FREE(frame); @@ -2157,7 +2157,7 @@ SMBC_removexattr_ctx(SMBCCTX *context, } if (!user || user[0] == (char)0) { - user = talloc_strdup(frame, context->config.user); + user = talloc_strdup(frame, smbc_getUser(context)); if (!user) { errno = ENOMEM; TALLOC_FREE(frame); |