summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--source3/include/libsmb_internal.h16
-rw-r--r--source3/include/libsmbclient.h282
-rw-r--r--source3/libsmb/libsmb_cache.c2
-rw-r--r--source3/libsmb/libsmb_context.c305
-rw-r--r--source3/libsmb/libsmb_dir.c70
-rw-r--r--source3/libsmb/libsmb_file.c36
-rw-r--r--source3/libsmb/libsmb_path.c7
-rw-r--r--source3/libsmb/libsmb_printjob.c14
-rw-r--r--source3/libsmb/libsmb_server.c33
-rw-r--r--source3/libsmb/libsmb_stat.c10
-rw-r--r--source3/libsmb/libsmb_xattr.c22
11 files changed, 566 insertions, 231 deletions
diff --git a/source3/include/libsmb_internal.h b/source3/include/libsmb_internal.h
index 353575dce8..555b6ac138 100644
--- a/source3/include/libsmb_internal.h
+++ b/source3/include/libsmb_internal.h
@@ -108,11 +108,12 @@ struct _SMBCFILE {
/*
* Context structure
*/
-struct _SMBCCTX {
+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;
@@ -127,6 +128,7 @@ struct _SMBCCTX {
/* Connection timeout value */
int timeout;
+#endif
/* dirent pointer location
*
@@ -240,6 +242,7 @@ struct _SMBCCTX {
*/
bool one_share_per_server;
+#if 0 /* Left in libsmbclient.h (flags) for backward compatibility */
/* Kerberos-related flags */
bool use_kerberos;
bool fallback_after_kerberos;
@@ -264,10 +267,12 @@ struct _SMBCCTX {
smbc_remove_cached_srv_fn remove_cached_server_fn;
smbc_purge_cached_srv_fn purge_cached_server_fn;
} cache;
+#endif
/* POSIX emulation functions */
struct
{
+#if 0 /* Left in libsmbclient.h for backward compatibility */
smbc_open_fn open_fn;
smbc_creat_fn creat_fn;
smbc_read_fn read_fn;
@@ -275,9 +280,11 @@ struct _SMBCCTX {
smbc_unlink_fn unlink_fn;
smbc_rename_fn rename_fn;
smbc_lseek_fn lseek_fn;
- smbc_ftruncate_fn ftruncate_fn;
smbc_stat_fn stat_fn;
smbc_fstat_fn fstat_fn;
+#endif
+ smbc_ftruncate_fn ftruncate_fn;
+#if 0 /* Left in libsmbclient.h for backward compatibility */
smbc_close_fn close_fn;
smbc_opendir_fn opendir_fn;
smbc_closedir_fn closedir_fn;
@@ -294,8 +301,10 @@ struct _SMBCCTX {
smbc_getxattr_fn getxattr_fn;
smbc_removexattr_fn removexattr_fn;
smbc_listxattr_fn listxattr_fn;
+#endif
} posix_emu;
+#if 0 /* Left in libsmbclient.h for backward compatibility */
/* Printing-related functions */
struct
{
@@ -304,8 +313,9 @@ struct _SMBCCTX {
smbc_list_print_jobs_fn list_print_jobs_fn;
smbc_unlink_print_job_fn unlink_print_job_fn;
} printing;
+#endif
-#if 0 /* not yet */
+#if 0 /* None available yet */
/* SMB high-level functions */
struct
{
diff --git a/source3/include/libsmbclient.h b/source3/include/libsmbclient.h
index a998bcee69..4d78bb2568 100644
--- a/source3/include/libsmbclient.h
+++ b/source3/include/libsmbclient.h
@@ -5,7 +5,7 @@
Copyright (C) Richard Sharpe 2000
Copyright (C) John Terpsra 2000
Copyright (C) Tom Jansen (Ninja ISD) 2002
- Copyright (C) Derrell Lipman 2003
+ Copyright (C) Derrell Lipman 2003-2008
This program is free software; you can redistribute it and/or modify
@@ -213,6 +213,15 @@ typedef struct _SMBCFILE SMBCFILE;
typedef struct _SMBCCTX SMBCCTX;
+/*
+ * NEW CODE SHOULD NOT DIRECTLY MANIPULATE THE CONTEXT STRUCTURE.
+ * For these options, use smbc_option_set() and smbc_option_get().
+ */
+
+/* Flags for SMBCCTX->flags */
+# define SMB_CTX_FLAG_USE_KERBEROS (1 << 0)
+# define SMB_CTX_FLAG_FALLBACK_AFTER_KERBEROS (1 << 1)
+# define SMBCCTX_FLAG_NO_AUTO_ANONYMOUS_LOGON (1 << 2)
@@ -2311,4 +2320,275 @@ smbc_version(void);
#endif
+/**
+ * @ingroup structure
+ * Structure that contains a client context information
+ * This structure is known as SMBCCTX
+ *
+ * DO NOT DIRECTLY MANIPULATE THE CONTEXT STRUCTURE! The data in the context
+ * structure should all be considered private to the library. It remains here
+ * only for backward compatibility.
+ *
+ * See the comments herein for use of the setter and getter functions which
+ * should now be used for manipulating these values. New features, functions,
+ * etc., are not added here but rather in _internal where they are not
+ * directly visible to applications. This makes it much easier to maintain
+ * ABI compatibility.
+ */
+struct _SMBCCTX {
+ struct
+ {
+ /**
+ * debug level
+ *
+ * Use smbc_getDebug() and smbc_setDebug()
+ */
+ int debug;
+
+ /**
+ * netbios name used for making connections
+ *
+ * Use smbc_getNetbiosName() and smbc_setNetbiosName()
+ */
+ char * netbios_name;
+
+ /**
+ * workgroup name used for making connections
+ *
+ * Use smbc_getWorkgroup() and smbc_setWorkgroup()
+ */
+ char * workgroup;
+
+ /**
+ * username used for making connections
+ *
+ * Use smbc_getUser() and smbc_setUser()
+ */
+ char * user;
+
+ /**
+ * timeout used for waiting on connections / response data (in
+ * milliseconds)
+ *
+ * Use smbc_getTimeout() and smbc_setTimeout()
+ */
+ int timeout;
+ } config;
+
+ /**
+ * callable functions for files:
+ * For usage and return values see the SMBC_* functions
+ *
+ * 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;
+#if 0 /* internal */
+ 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;
+
+ /* 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;
+
+ /*
+ ** Callbacks
+ * These callbacks _always_ have to be initialized because they will
+ * not be checked at dereference for increased speed.
+ */
+ struct
+ {
+ /**
+ * authentication function callback: called upon auth requests
+ *
+ * Use smbc_getFunctionAuthData(), smbc_setFunctionAuthData()
+ */
+ smbc_get_auth_data_fn get_auth_data_fn;
+
+ /**
+ * check if a server is still good
+ *
+ * Use smbc_getFunctionCheckServer(),
+ * smbc_setFunctionCheckServer()
+ */
+ smbc_check_server_fn check_server_fn;
+
+ /**
+ * remove a server if unused
+ *
+ * Use smbc_getFunctionRemoveUnusedServer(),
+ * smbc_setFunctionCheckServer()
+ */
+ smbc_remove_unused_server_fn remove_unused_server_fn;
+ } server;
+
+ struct
+ {
+ /** Cache subsystem
+ *
+ * For an example cache system see
+ * samba/source/libsmb/libsmb_cache.c
+ *
+ * Cache subsystem * functions follow.
+ */
+
+ /**
+ * server cache addition
+ *
+ * Use smbc_getFunctionAddCachedServer(),
+ * smbc_setFunctionAddCachedServer()
+ */
+ smbc_add_cached_srv_fn add_cached_server_fn;
+
+ /**
+ * server cache lookup
+ *
+ * Use smbc_getFunctionGetCachedServer(),
+ * smbc_setFunctionGetCachedServer()
+ */
+ smbc_get_cached_srv_fn get_cached_server_fn;
+
+ /**
+ * server cache removal
+ *
+ * Use smbc_getFunctionRemoveCachedServer(),
+ * smbc_setFunctionRemoveCachedServer()
+ */
+ smbc_remove_cached_srv_fn remove_cached_server_fn;
+
+ /**
+ * server cache purging, try to remove all cached servers
+ * (disconnect)
+ *
+ * Use smbc_getFunctionPurgeCachedServers(),
+ * smbc_setFunctionPurgeCachedServers()
+ */
+ smbc_purge_cached_srv_fn purge_cached_servers_fn;
+
+ /**
+ * Space to store private data of the server cache.
+ *
+ * Use smbc_getServerCacheData(), smbc_setServerCacheData()
+ */
+ struct smbc_server_cache * server_cache_data;
+ } cache;
+
+ /*
+ * Very old configuration options.
+ *
+ * Use smbc_option_set() and smbc_option_get() instead.
+ */
+ struct
+ {
+ int bits;
+ } flags;
+
+ /** user options selections that apply to this session
+ *
+ * NEW CODE SHOULD NOT DIRECTLY MANIPULATE THE CONTEXT STRUCTURE.
+ *
+ * NEW OPTIONS ARE NOT ADDED HERE!
+ *
+ * We must maintain ABI backward compatibility. We now use
+ * smbc_option_set() and smbc_option_get() for all newly added
+ * options.
+ */
+ struct _smbc_options {
+
+ /*
+ * 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.
+ */
+ int 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.
+ */
+ int one_share_per_server;
+ } options;
+
+ /** INTERNAL DATA
+ * do _NOT_ touch this from your program !
+ */
+ struct SMBC_internal_data * internal;
+};
+
+
#endif /* SMBCLIENT_H_INCLUDED */
diff --git a/source3/libsmb/libsmb_cache.c b/source3/libsmb/libsmb_cache.c
index e0571fa9fe..7ff92f1b4e 100644
--- a/source3/libsmb/libsmb_cache.c
+++ b/source3/libsmb/libsmb_cache.c
@@ -151,7 +151,7 @@ SMBC_get_cached_server(SMBCCTX * context,
* a connection to the server (other than the
* attribute server connection) is cool.
*/
- if (context->one_share_per_server) {
+ if (context->options.one_share_per_server) {
/*
* The currently connected share name
* doesn't match the requested share, so
diff --git a/source3/libsmb/libsmb_context.c b/source3/libsmb/libsmb_context.c
index 1505d50a43..6b7a19e1e4 100644
--- a/source3/libsmb/libsmb_context.c
+++ b/source3/libsmb/libsmb_context.c
@@ -41,6 +41,15 @@ SMBCCTX *
smbc_new_context(void)
{
SMBCCTX *context;
+
+ /*
+ * 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) {
@@ -48,66 +57,73 @@ smbc_new_context(void)
return NULL;
}
-
- /* Initialize the context and establish reasonable defaults */
ZERO_STRUCTP(context);
+
+ context->internal = SMB_MALLOC_P(struct SMBC_internal_data);
+ if (!context->internal) {
+ SAFE_FREE(context);
+ errno = ENOMEM;
+ return NULL;
+ }
+
+ /* Initialize the context and establish reasonable defaults */
+ ZERO_STRUCTP(context->internal);
- context->debug = 0;
- context->timeout = 20000; /* 20 seconds */
+ OLD(config.debug) = 0;
+ OLD(config.timeout) = 20000; /* 20 seconds */
- context->full_time_names = False;
- context->share_mode = SMBC_SHAREMODE_DENY_NONE;
- context->smb_encryption_level = 0;
- context->browse_max_lmb_count = 3; /* # LMBs to query */
- context->urlencode_readdir_entries = False;
- context->one_share_per_server = False;
- context->use_kerberos = False;
- context->fallback_after_kerberos = False;
- context->no_auto_anonymous_login = False;
+ NEW(full_time_names) = False;
+ NEW(share_mode) = SMBC_SHAREMODE_DENY_NONE;
+ NEW(smb_encryption_level) = 0;
+ NEW(browse_max_lmb_count) = 3; /* # LMBs to query */
+ NEW(urlencode_readdir_entries) = False;
+ NEW(one_share_per_server) = False;
- context->server.get_auth_data_fn = SMBC_get_auth_data;
- context->server.check_server_fn = SMBC_check_server;
- context->server.remove_unused_server_fn = SMBC_remove_unused_server;
+ 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;
- context->cache.server_cache_data = NULL;
- context->cache.add_cached_server_fn = SMBC_add_cached_server;
- context->cache.get_cached_server_fn = SMBC_get_cached_server;
- context->cache.remove_cached_server_fn = SMBC_remove_cached_server;
- context->cache.purge_cached_server_fn = SMBC_purge_cached_servers;
+ 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;
- context->posix_emu.open_fn = SMBC_open_ctx;
- context->posix_emu.creat_fn = SMBC_creat_ctx;
- context->posix_emu.read_fn = SMBC_read_ctx;
- context->posix_emu.write_fn = SMBC_write_ctx;
- context->posix_emu.close_fn = SMBC_close_ctx;
- context->posix_emu.unlink_fn = SMBC_unlink_ctx;
- context->posix_emu.rename_fn = SMBC_rename_ctx;
- context->posix_emu.lseek_fn = SMBC_lseek_ctx;
- context->posix_emu.ftruncate_fn = SMBC_ftruncate_ctx;
- context->posix_emu.stat_fn = SMBC_stat_ctx;
- context->posix_emu.fstat_fn = SMBC_fstat_ctx;
- context->posix_emu.opendir_fn = SMBC_opendir_ctx;
- context->posix_emu.closedir_fn = SMBC_closedir_ctx;
- context->posix_emu.readdir_fn = SMBC_readdir_ctx;
- context->posix_emu.getdents_fn = SMBC_getdents_ctx;
- context->posix_emu.mkdir_fn = SMBC_mkdir_ctx;
- context->posix_emu.rmdir_fn = SMBC_rmdir_ctx;
- context->posix_emu.telldir_fn = SMBC_telldir_ctx;
- context->posix_emu.lseekdir_fn = SMBC_lseekdir_ctx;
- context->posix_emu.fstatdir_fn = SMBC_fstatdir_ctx;
- context->posix_emu.chmod_fn = SMBC_chmod_ctx;
- context->posix_emu.utimes_fn = SMBC_utimes_ctx;
- context->posix_emu.setxattr_fn = SMBC_setxattr_ctx;
- context->posix_emu.getxattr_fn = SMBC_getxattr_ctx;
- context->posix_emu.removexattr_fn = SMBC_removexattr_ctx;
- context->posix_emu.listxattr_fn = SMBC_listxattr_ctx;
+ 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;
- context->printing.open_print_job_fn = SMBC_open_print_job_ctx;
- context->printing.print_file_fn = SMBC_print_file_ctx;
- context->printing.list_print_jobs_fn = SMBC_list_print_jobs_ctx;
- context->printing.unlink_print_job_fn = SMBC_unlink_print_job_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;
return context;
+#undef OLD
+#undef NEW
}
/*
@@ -130,20 +146,20 @@ smbc_free_context(SMBCCTX *context,
SMBCFILE * f;
DEBUG(1,("Performing aggressive shutdown.\n"));
- f = context->files;
+ f = context->internal->files;
while (f) {
(context->posix_emu.close_fn)(context, f);
f = f->next;
}
- context->files = NULL;
+ context->internal->files = NULL;
/* First try to remove the servers the nice way. */
- if (context->cache.purge_cached_server_fn(context)) {
+ if (context->cache.purge_cached_servers_fn(context)) {
SMBCSRV * s;
SMBCSRV * next;
DEBUG(1, ("Could not purge all servers, "
"Nice way shutdown failed.\n"));
- s = context->servers;
+ s = context->internal->servers;
while (s) {
DEBUG(1, ("Forced shutdown: %p (fd=%d)\n",
s, s->cli->fd));
@@ -151,28 +167,28 @@ smbc_free_context(SMBCCTX *context,
(context->cache.remove_cached_server_fn)(context,
s);
next = s->next;
- DLIST_REMOVE(context->servers, s);
+ DLIST_REMOVE(context->internal->servers, s);
SAFE_FREE(s);
s = next;
}
- context->servers = NULL;
+ context->internal->servers = NULL;
}
}
else {
/* This is the polite way */
- if ((context->cache.purge_cached_server_fn)(context)) {
+ if ((context->cache.purge_cached_servers_fn)(context)) {
DEBUG(1, ("Could not purge all servers, "
"free_context failed.\n"));
errno = EBUSY;
return 1;
}
- if (context->servers) {
+ if (context->internal->servers) {
DEBUG(1, ("Active servers in context, "
"free_context failed.\n"));
errno = EBUSY;
return 1;
}
- if (context->files) {
+ if (context->internal->files) {
DEBUG(1, ("Active files in context, "
"free_context failed.\n"));
errno = EBUSY;
@@ -181,9 +197,9 @@ smbc_free_context(SMBCCTX *context,
}
/* Things we have to clean up */
- SAFE_FREE(context->workgroup);
- SAFE_FREE(context->netbios_name);
- SAFE_FREE(context->user);
+ SAFE_FREE(context->config.workgroup);
+ SAFE_FREE(context->config.netbios_name);
+ SAFE_FREE(context->config.user);
DEBUG(3, ("Context %p successfully freed\n", context));
SAFE_FREE(context);
@@ -219,7 +235,7 @@ smbc_option_set(SMBCCTX *context,
* Log to standard error instead of standard output.
*/
option_value.b = (bool) va_arg(ap, int);
- context->debug_stderr = option_value.b;
+ context->internal->debug_stderr = option_value.b;
} else if (strcmp(option_name, "full_time_names") == 0) {
/*
@@ -231,7 +247,7 @@ smbc_option_set(SMBCCTX *context,
* CREATE_TIME.)
*/
option_value.b = (bool) va_arg(ap, int);
- context->full_time_names = option_value.b;
+ context->internal->full_time_names = option_value.b;
} else if (strcmp(option_name, "open_share_mode") == 0) {
/*
@@ -239,7 +255,7 @@ smbc_option_set(SMBCCTX *context,
* SMBC_open_ctx(). The default is SMBC_SHAREMODE_DENY_NONE.
*/
option_value.i = va_arg(ap, int);
- context->share_mode = (smbc_share_mode) option_value.i;
+ context->internal->share_mode = (smbc_share_mode) option_value.i;
} else if (strcmp(option_name, "user_data") == 0) {
/*
@@ -247,7 +263,7 @@ smbc_option_set(SMBCCTX *context,
* with smbc_option_get()
*/
option_value.v = va_arg(ap, void *);
- context->user_data = option_value.v;
+ context->internal->user_data = option_value.v;
} else if (strcmp(option_name, "smb_encrypt_level") == 0) {
/*
* Save an encoded value for encryption level.
@@ -255,11 +271,11 @@ smbc_option_set(SMBCCTX *context,
*/
option_value.s = va_arg(ap, const char *);
if (strcmp(option_value.s, "none") == 0) {
- context->smb_encryption_level = 0;
+ context->internal->smb_encryption_level = 0;
} else if (strcmp(option_value.s, "request") == 0) {
- context->smb_encryption_level = 1;
+ context->internal->smb_encryption_level = 1;
} else if (strcmp(option_value.s, "require") == 0) {
- context->smb_encryption_level = 2;
+ context->internal->smb_encryption_level = 2;
}
} else if (strcmp(option_name, "browse_max_lmb_count") == 0) {
/*
@@ -280,7 +296,7 @@ smbc_option_set(SMBCCTX *context,
* variable is probably somewhere around 3. (Default: 3).
*/
option_value.i = va_arg(ap, int);
- context->browse_max_lmb_count = option_value.i;
+ context->internal->browse_max_lmb_count = option_value.i;
} else if (strcmp(option_name, "urlencode_readdir_entries") == 0) {
/*
@@ -307,7 +323,7 @@ smbc_option_set(SMBCCTX *context,
* For backwards compatibility, this option defaults to False.
*/
option_value.b = (bool) va_arg(ap, int);
- context->urlencode_readdir_entries = option_value.b;
+ context->internal->urlencode_readdir_entries = option_value.b;
} else if (strcmp(option_name, "one_share_per_server") == 0) {
/*
@@ -321,19 +337,31 @@ smbc_option_set(SMBCCTX *context,
* and issuing a new TREE CONNECT when the share is accessed.
*/
option_value.b = (bool) va_arg(ap, int);
- context->one_share_per_server = option_value.b;
+ context->options.one_share_per_server = option_value.b;
} else if (strcmp(option_name, "use_kerberos") == 0) {
option_value.b = (bool) va_arg(ap, int);
- context->use_kerberos = option_value.b;
+ if (option_value.b) {
+ context->flags.bits |= SMB_CTX_FLAG_USE_KERBEROS;
+ } else {
+ context->flags.bits &= ~SMB_CTX_FLAG_USE_KERBEROS;
+ }
} else if (strcmp(option_name, "fallback_after_kerberos") == 0) {
option_value.b = (bool) va_arg(ap, int);
- context->fallback_after_kerberos = option_value.b;
+ if (option_value.b) {
+ context->flags.bits |= SMB_CTX_FLAG_FALLBACK_AFTER_KERBEROS;
+ } else {
+ context->flags.bits &= ~SMB_CTX_FLAG_FALLBACK_AFTER_KERBEROS;
+ }
} else if (strcmp(option_name, "no_auto_anonymous_login") == 0) {
option_value.b = (bool) va_arg(ap, int);
- context->no_auto_anonymous_login = option_value.b;
+ if (option_value.b) {
+ context->flags.bits |= SMBCCTX_FLAG_NO_AUTO_ANONYMOUS_LOGON;
+ } else {
+ context->flags.bits &= ~SMBCCTX_FLAG_NO_AUTO_ANONYMOUS_LOGON;
+ }
}
va_end(ap);
@@ -347,14 +375,16 @@ void *
smbc_option_get(SMBCCTX *context,
char *option_name)
{
+ int bits;
+
if (strcmp(option_name, "debug_stderr") == 0) {
/*
* Log to standard error instead of standard output.
*/
#if defined(__intptr_t_defined) || defined(HAVE_INTPTR_T)
- return (void *) (intptr_t) context->debug_stderr;
+ return (void *) (intptr_t) context->internal->debug_stderr;
#else
- return (void *) context->debug_stderr;
+ return (void *) context->internal->debug_stderr;
#endif
} else if (strcmp(option_name, "full_time_names") == 0) {
@@ -367,9 +397,9 @@ smbc_option_get(SMBCCTX *context,
* CREATE_TIME.)
*/
#if defined(__intptr_t_defined) || defined(HAVE_INTPTR_T)
- return (void *) (intptr_t) context->full_time_names;
+ return (void *) (intptr_t) context->internal->full_time_names;
#else
- return (void *) context->full_time_names;
+ return (void *) context->internal->full_time_names;
#endif
} else if (strcmp(option_name, "user_data") == 0) {
@@ -377,13 +407,13 @@ smbc_option_get(SMBCCTX *context,
* Return the user data handle which was saved by the user
* with smbc_option_set()
*/
- return context->user_data;
+ return context->internal->user_data;
} else if (strcmp(option_name, "smb_encrypt_level") == 0) {
/*
* Return the current smb encrypt negotiate option as a string.
*/
- switch (context->smb_encryption_level) {
+ switch (context->internal->smb_encryption_level) {
case 0:
return (void *) "none";
case 1:
@@ -402,7 +432,7 @@ smbc_option_get(SMBCCTX *context,
SMBCSRV *s;
unsigned int num_servers = 0;
- for (s = context->servers; s; s = s->next) {
+ for (s = context->internal->servers; s; s = s->next) {
num_servers++;
if (s->cli->trans_enc_state == NULL) {
return (void *)false;
@@ -433,9 +463,9 @@ smbc_option_get(SMBCCTX *context,
* variable is probably somewhere around 3. (Default: 3).
*/
#if defined(__intptr_t_defined) || defined(HAVE_INTPTR_T)
- return (void *) (intptr_t) context->browse_max_lmb_count;
+ return (void *) (intptr_t) context->internal->browse_max_lmb_count;
#else
- return (void *) context->browse_max_lmb_count;
+ return (void *) context->internal->browse_max_lmb_count;
#endif
} else if (strcmp(option_name, "urlencode_readdir_entries") == 0) {
@@ -463,9 +493,9 @@ smbc_option_get(SMBCCTX *context,
* For backwards compatibility, this option defaults to False.
*/
#if defined(__intptr_t_defined) || defined(HAVE_INTPTR_T)
- return (void *) (intptr_t) context->urlencode_readdir_entries;
+ return (void *)(intptr_t) context->internal->urlencode_readdir_entries;
#else
- return (void *) (bool) context->urlencode_readdir_entries;
+ return (void *) (bool) context->internal->urlencode_readdir_entries;
#endif
} else if (strcmp(option_name, "one_share_per_server") == 0) {
@@ -480,30 +510,43 @@ smbc_option_get(SMBCCTX *context,
* and issuing a new TREE CONNECT when the share is accessed.
*/
#if defined(__intptr_t_defined) || defined(HAVE_INTPTR_T)
- return (void *) (intptr_t) context->one_share_per_server;
+ return (void *) (intptr_t) context->internal->one_share_per_server;
#else
- return (void *) (bool) context->one_share_per_server;
+ return (void *) (bool) context->internal->one_share_per_server;
#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) context->use_kerberos;
+ return (context->flags.bits & SMB_CTX_FLAG_USE_KERBEROS
+ ? (void *) (intptr_t) 1
+ : (void *) (intptr_t) 0);
#else
- return (void *) (bool) context->use_kerberos;
+ return (context->flags.bits & SMB_CTX_FLAG_USE_KERBEROS
+ ? (void *) (bool) 1
+ : (void *) (bool) 0);
#endif
} else if (strcmp(option_name, "fallback_after_kerberos") == 0) {
#if defined(__intptr_t_defined) || defined(HAVE_INTPTR_T)
- return (void *) (intptr_t) context->fallback_after_kerberos;
+ return (context->flags.bits & SMB_CTX_FLAG_FALLBACK_AFTER_KERBEROS
+ ? (void *) (intptr_t) 1
+ : (void *) (intptr_t) 0);
#else
- return (void *) (bool) context->fallback_after_kerberos;
+ return (context->flags.bits & SMB_CTX_FLAG_FALLBACK_AFTER_KERBEROS
+ ? (void *) (bool) 1
+ : (void *) (bool) 0);
#endif
} else if (strcmp(option_name, "no_auto_anonymous_login") == 0) {
#if defined(__intptr_t_defined) || defined(HAVE_INTPTR_T)
- return (void *) (intptr_t) context->no_auto_anonymous_login;
+ return (context->flags.bits & SMBCCTX_FLAG_NO_AUTO_ANONYMOUS_LOGON
+ ? (void *) (intptr_t) 1
+ : (void *) (intptr_t) 0);
#else
- return (void *) (bool) context->no_auto_anonymous_login;
+ return (context->flags.bits & SMBCCTX_FLAG_NO_AUTO_ANONYMOUS_LOGON
+ ? (void *) (bool) 1
+ : (void *) (bool) 0);
#endif
}
@@ -532,13 +575,13 @@ smbc_init_context(SMBCCTX *context)
}
/* Do not initialise the same client twice */
- if (context->initialized) {
+ if (context->internal->initialized) {
return 0;
}
if (!context->server.get_auth_data_fn ||
- context->debug < 0 ||
- context->debug > 100) {
+ context->config.debug < 0 ||
+ context->config.debug > 100) {
errno = EINVAL;
return NULL;
@@ -554,12 +597,12 @@ smbc_init_context(SMBCCTX *context)
TALLOC_CTX *frame = talloc_stackframe();
/* Set this to what the user wants */
- DEBUGLEVEL = context->debug;
+ DEBUGLEVEL = context->config.debug;
load_case_tables();
setup_logging("libsmbclient", True);
- if (context->debug_stderr) {
+ if (context->internal->debug_stderr) {
dbf = x_stderr;
x_setbuf(x_stderr, NULL);
}
@@ -630,24 +673,24 @@ smbc_init_context(SMBCCTX *context)
TALLOC_FREE(frame);
}
- if (!context->user) {
+ if (!context->config.user) {
/*
* 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->user = SMB_STRDUP("guest");
- else context->user = SMB_STRDUP(user);
+ if (!user) context->config.user = SMB_STRDUP("guest");
+ else context->config.user = SMB_STRDUP(user);
}
- if (!context->netbios_name) {
+ if (!context->config.netbios_name) {
/*
* 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
*/
if (global_myname()) {
- context->netbios_name = SMB_STRDUP(global_myname());
+ context->config.netbios_name = SMB_STRDUP(global_myname());
}
else {
/*
@@ -655,39 +698,39 @@ smbc_init_context(SMBCCTX *context)
* lazy for the moment
*/
pid = sys_getpid();
- context->netbios_name = (char *)SMB_MALLOC(17);
- if (!context->netbios_name) {
+ context->config.netbios_name = (char *)SMB_MALLOC(17);
+ if (!context->config.netbios_name) {
errno = ENOMEM;
return NULL;
}
- slprintf(context->netbios_name, 16,
- "smbc%s%d", context->user, pid);
+ slprintf(context->config.netbios_name, 16,
+ "smbc%s%d", context->config.user, pid);
}
}
- DEBUG(1, ("Using netbios name %s.\n", context->netbios_name));
+ DEBUG(1, ("Using netbios name %s.\n", context->config.netbios_name));
- if (!context->workgroup) {
+ if (!context->config.workgroup) {
if (lp_workgroup()) {
- context->workgroup = SMB_STRDUP(lp_workgroup());
+ context->config.workgroup = SMB_STRDUP(lp_workgroup());
}
else {
/* TODO: Think about a decent default workgroup */
- context->workgroup = SMB_STRDUP("samba");
+ context->config.workgroup = SMB_STRDUP("samba");
}
}
- DEBUG(1, ("Using workgroup %s.\n", context->workgroup));
+ DEBUG(1, ("Using workgroup %s.\n", context->config.workgroup));
/* shortest timeout is 1 second */
- if (context->timeout > 0 && context->timeout < 1000)
- context->timeout = 1000;
+ if (context->config.timeout > 0 && context->config.timeout < 1000)
+ context->config.timeout = 1000;
/*
* FIXME: Should we check the function pointers here?
*/
- context->initialized = True;
+ context->internal->initialized = True;
return context;
}
@@ -705,56 +748,56 @@ smbc_version(void)
char *
smbc_getNetbiosName(SMBCCTX *c)
{
- return c->netbios_name;
+ return c->config.netbios_name;
}
/** Set the netbios name used for making connections */
void
smbc_setNetbiosName(SMBCCTX *c, char * netbios_name)
{
- c->netbios_name = netbios_name;
+ c->config.netbios_name = netbios_name;
}
/** Get the workgroup used for making connections */
char *
smbc_getWorkgroup(SMBCCTX *c)
{
- return c->workgroup;
+ return c->config.workgroup;
}
/** Set the workgroup used for making connections */
void
smbc_setWorkgroup(SMBCCTX *c, char * workgroup)
{
- c->workgroup = workgroup;
+ c->config.workgroup = workgroup;
}
/** Get the username used for making connections */
char *
smbc_getUser(SMBCCTX *c)
{
- return c->user;
+ return c->config.user;
}
/** Set the username used for making connections */
void
smbc_setUser(SMBCCTX *c, char * user)
{
- c->user = user;
+ c->config.user = user;
}
/** Get the debug level */
int
smbc_getDebug(SMBCCTX *c)
{
- return c->debug;
+ return c->config.debug;
}
/** Set the debug level */
void
smbc_setDebug(SMBCCTX *c, int debug)
{
- c->debug = debug;
+ c->config.debug = debug;
}
/**
@@ -764,7 +807,7 @@ smbc_setDebug(SMBCCTX *c, int debug)
int
smbc_getTimeout(SMBCCTX *c)
{
- return c->timeout;
+ return c->config.timeout;
}
/**
@@ -774,7 +817,7 @@ smbc_getTimeout(SMBCCTX *c)
void
smbc_setTimeout(SMBCCTX *c, int timeout)
{
- c->timeout = timeout;
+ c->config.timeout = timeout;
}
/** Get the function for obtaining authentication data */
@@ -886,7 +929,7 @@ smbc_setFunctionRemoveCachedServer(SMBCCTX *c,
smbc_purge_cached_srv_fn
smbc_getFunctionPurgeCachedServers(SMBCCTX *c)
{
- return c->cache.purge_cached_server_fn;
+ return c->cache.purge_cached_servers_fn;
}
/**
@@ -896,7 +939,7 @@ smbc_getFunctionPurgeCachedServers(SMBCCTX *c)
void
smbc_setFunctionPurgeCachedServers(SMBCCTX *c, smbc_purge_cached_srv_fn fn)
{
- c->cache.purge_cached_server_fn = fn;
+ c->cache.purge_cached_servers_fn = fn;
}
/**
@@ -1014,13 +1057,13 @@ smbc_setFunctionFstat(SMBCCTX *c, smbc_fstat_fn fn)
smbc_ftruncate_fn
smbc_getFunctionFtruncate(SMBCCTX *c)
{
- return c->posix_emu.ftruncate_fn;
+ return c->internal->posix_emu.ftruncate_fn;
}
void
smbc_setFunctionFtruncate(SMBCCTX *c, smbc_ftruncate_fn fn)
{
- c->posix_emu.ftruncate_fn = fn;
+ c->internal->posix_emu.ftruncate_fn = fn;
}
smbc_close_fn
diff --git a/source3/libsmb/libsmb_dir.c b/source3/libsmb/libsmb_dir.c
index 9cb3351433..25020762a2 100644
--- a/source3/libsmb/libsmb_dir.c
+++ b/source3/libsmb/libsmb_dir.c
@@ -356,7 +356,7 @@ SMBC_opendir_ctx(SMBCCTX *context,
struct sockaddr_storage rem_ss;
TALLOC_CTX *frame = talloc_stackframe();
- if (!context || !context->initialized) {
+ if (!context || !context->internal->initialized) {
DEBUG(4, ("no valid context\n"));
errno = EINVAL + 8192;
TALLOC_FREE(frame);
@@ -400,7 +400,7 @@ SMBC_opendir_ctx(SMBCCTX *context,
}
if (!user || user[0] == (char)0) {
- user = talloc_strdup(frame, context->user);
+ user = talloc_strdup(frame, context->config.user);
if (!user) {
errno = ENOMEM;
TALLOC_FREE(frame);
@@ -446,9 +446,9 @@ SMBC_opendir_ctx(SMBCCTX *context,
}
/* Determine how many local master browsers to query */
- max_lmb_count = (context->browse_max_lmb_count == 0
+ max_lmb_count = (context->internal->browse_max_lmb_count == 0
? INT_MAX
- : context->browse_max_lmb_count);
+ : context->internal->browse_max_lmb_count);
memset(&u_info, '\0', sizeof(u_info));
u_info.username = talloc_strdup(frame,user);
@@ -826,7 +826,7 @@ SMBC_opendir_ctx(SMBCCTX *context,
}
- DLIST_ADD(context->files, dir);
+ DLIST_ADD(context->internal->files, dir);
TALLOC_FREE(frame);
return dir;
@@ -842,13 +842,13 @@ SMBC_closedir_ctx(SMBCCTX *context,
{
TALLOC_CTX *frame = talloc_stackframe();
- if (!context || !context->initialized) {
+ if (!context || !context->internal->initialized) {
errno = EINVAL;
TALLOC_FREE(frame);
return -1;
}
- if (!dir || !SMBC_dlist_contains(context->files, dir)) {
+ if (!dir || !SMBC_dlist_contains(context->internal->files, dir)) {
errno = EBADF;
TALLOC_FREE(frame);
return -1;
@@ -856,7 +856,7 @@ SMBC_closedir_ctx(SMBCCTX *context,
remove_dir(dir); /* Clean it up */
- DLIST_REMOVE(context->files, dir);
+ DLIST_REMOVE(context->internal->files, dir);
if (dir) {
@@ -875,7 +875,7 @@ smbc_readdir_internal(SMBCCTX * context,
struct smbc_dirent *src,
int max_namebuf_len)
{
- if (context->urlencode_readdir_entries) {
+ if (context->internal->urlencode_readdir_entries) {
/* url-encode the name. get back remaining buffer space */
max_namebuf_len =
@@ -919,7 +919,7 @@ SMBC_readdir_ctx(SMBCCTX *context,
/* Check that all is ok first ... */
- if (!context || !context->initialized) {
+ if (!context || !context->internal->initialized) {
errno = EINVAL;
DEBUG(0, ("Invalid context in SMBC_readdir_ctx()\n"));
@@ -928,7 +928,7 @@ SMBC_readdir_ctx(SMBCCTX *context,
}
- if (!dir || !SMBC_dlist_contains(context->files, dir)) {
+ if (!dir || !SMBC_dlist_contains(context->internal->files, dir)) {
errno = EBADF;
DEBUG(0, ("Invalid dir in SMBC_readdir_ctx()\n"));
@@ -960,8 +960,8 @@ SMBC_readdir_ctx(SMBCCTX *context,
}
- dirp = (struct smbc_dirent *)context->dirent;
- maxlen = (sizeof(context->dirent) -
+ dirp = (struct smbc_dirent *)context->internal->dirent;
+ maxlen = (sizeof(context->internal->dirent) -
sizeof(struct smbc_dirent));
smbc_readdir_internal(context, dirp, dirent, maxlen);
@@ -991,7 +991,7 @@ SMBC_getdents_ctx(SMBCCTX *context,
/* Check that all is ok first ... */
- if (!context || !context->initialized) {
+ if (!context || !context->internal->initialized) {
errno = EINVAL;
TALLOC_FREE(frame);
@@ -999,7 +999,7 @@ SMBC_getdents_ctx(SMBCCTX *context,
}
- if (!dir || !SMBC_dlist_contains(context->files, dir)) {
+ if (!dir || !SMBC_dlist_contains(context->internal->files, dir)) {
errno = EBADF;
TALLOC_FREE(frame);
@@ -1033,8 +1033,8 @@ SMBC_getdents_ctx(SMBCCTX *context,
}
/* Do urlencoding of next entry, if so selected */
- dirent = (struct smbc_dirent *)context->dirent;
- maxlen = (sizeof(context->dirent) -
+ dirent = (struct smbc_dirent *)context->internal->dirent;
+ maxlen = (sizeof(context->internal->dirent) -
sizeof(struct smbc_dirent));
smbc_readdir_internal(context, dirent, dirlist->dirent, maxlen);
@@ -1102,7 +1102,7 @@ SMBC_mkdir_ctx(SMBCCTX *context,
struct cli_state *targetcli = NULL;
TALLOC_CTX *frame = talloc_stackframe();
- if (!context || !context->initialized) {
+ if (!context || !context->internal->initialized) {
errno = EINVAL;
TALLOC_FREE(frame);
return -1;
@@ -1132,7 +1132,7 @@ SMBC_mkdir_ctx(SMBCCTX *context,
}
if (!user || user[0] == (char)0) {
- user = talloc_strdup(frame, context->user);
+ user = talloc_strdup(frame, context->config.user);
if (!user) {
errno = ENOMEM;
TALLOC_FREE(frame);
@@ -1209,7 +1209,7 @@ SMBC_rmdir_ctx(SMBCCTX *context,
struct cli_state *targetcli = NULL;
TALLOC_CTX *frame = talloc_stackframe();
- if (!context || !context->initialized) {
+ if (!context || !context->internal->initialized) {
errno = EINVAL;
TALLOC_FREE(frame);
return -1;
@@ -1239,7 +1239,7 @@ SMBC_rmdir_ctx(SMBCCTX *context,
}
if (!user || user[0] == (char)0) {
- user = talloc_strdup(frame, context->user);
+ user = talloc_strdup(frame, context->config.user);
if (!user) {
errno = ENOMEM;
TALLOC_FREE(frame);
@@ -1325,7 +1325,7 @@ SMBC_telldir_ctx(SMBCCTX *context,
{
TALLOC_CTX *frame = talloc_stackframe();
- if (!context || !context->initialized) {
+ if (!context || !context->internal->initialized) {
errno = EINVAL;
TALLOC_FREE(frame);
@@ -1333,7 +1333,7 @@ SMBC_telldir_ctx(SMBCCTX *context,
}
- if (!dir || !SMBC_dlist_contains(context->files, dir)) {
+ if (!dir || !SMBC_dlist_contains(context->internal->files, dir)) {
errno = EBADF;
TALLOC_FREE(frame);
@@ -1408,7 +1408,7 @@ SMBC_lseekdir_ctx(SMBCCTX *context,
struct smbc_dir_list *list_ent = (struct smbc_dir_list *)NULL;
TALLOC_CTX *frame = talloc_stackframe();
- if (!context || !context->initialized) {
+ if (!context || !context->internal->initialized) {
errno = EINVAL;
TALLOC_FREE(frame);
@@ -1465,7 +1465,7 @@ SMBC_fstatdir_ctx(SMBCCTX *context,
struct stat *st)
{
- if (!context || !context->initialized) {
+ if (!context || !context->internal->initialized) {
errno = EINVAL;
return -1;
@@ -1490,7 +1490,7 @@ SMBC_chmod_ctx(SMBCCTX *context,
uint16 mode;
TALLOC_CTX *frame = talloc_stackframe();
- if (!context || !context->initialized) {
+ if (!context || !context->internal->initialized) {
errno = EINVAL; /* Best I can think of ... */
TALLOC_FREE(frame);
@@ -1521,7 +1521,7 @@ SMBC_chmod_ctx(SMBCCTX *context,
}
if (!user || user[0] == (char)0) {
- user = talloc_strdup(frame, context->user);
+ user = talloc_strdup(frame, context->config.user);
if (!user) {
errno = ENOMEM;
TALLOC_FREE(frame);
@@ -1570,7 +1570,7 @@ SMBC_utimes_ctx(SMBCCTX *context,
time_t write_time;
TALLOC_CTX *frame = talloc_stackframe();
- if (!context || !context->initialized) {
+ if (!context || !context->internal->initialized) {
errno = EINVAL; /* Best I can think of ... */
TALLOC_FREE(frame);
@@ -1627,7 +1627,7 @@ SMBC_utimes_ctx(SMBCCTX *context,
}
if (!user || user[0] == (char)0) {
- user = talloc_strdup(frame, context->user);
+ user = talloc_strdup(frame, context->config.user);
if (!user) {
errno = ENOMEM;
TALLOC_FREE(frame);
@@ -1668,7 +1668,7 @@ SMBC_unlink_ctx(SMBCCTX *context,
SMBCSRV *srv = NULL;
TALLOC_CTX *frame = talloc_stackframe();
- if (!context || !context->initialized) {
+ if (!context || !context->internal->initialized) {
errno = EINVAL; /* Best I can think of ... */
TALLOC_FREE(frame);
@@ -1699,7 +1699,7 @@ SMBC_unlink_ctx(SMBCCTX *context,
}
if (!user || user[0] == (char)0) {
- user = talloc_strdup(frame, context->user);
+ user = talloc_strdup(frame, context->config.user);
if (!user) {
errno = ENOMEM;
TALLOC_FREE(frame);
@@ -1802,8 +1802,8 @@ SMBC_rename_ctx(SMBCCTX *ocontext,
TALLOC_CTX *frame = talloc_stackframe();
if (!ocontext || !ncontext ||
- !ocontext->initialized ||
- !ncontext->initialized) {
+ !ocontext->internal->initialized ||
+ !ncontext->internal->initialized) {
errno = EINVAL; /* Best I can think of ... */
TALLOC_FREE(frame);
@@ -1834,7 +1834,7 @@ SMBC_rename_ctx(SMBCCTX *ocontext,
}
if (!user1 || user1[0] == (char)0) {
- user1 = talloc_strdup(frame, ocontext->user);
+ user1 = talloc_strdup(frame, ocontext->config.user);
if (!user1) {
errno = ENOMEM;
TALLOC_FREE(frame);
@@ -1858,7 +1858,7 @@ SMBC_rename_ctx(SMBCCTX *ocontext,
}
if (!user2 || user2[0] == (char)0) {
- user2 = talloc_strdup(frame, ncontext->user);
+ user2 = talloc_strdup(frame, ncontext->config.user);
if (!user2) {
errno = ENOMEM;
TALLOC_FREE(frame);
diff --git a/source3/libsmb/libsmb_file.c b/source3/libsmb/libsmb_file.c
index 619176697b..62b990ed00 100644
--- a/source3/libsmb/libsmb_file.c
+++ b/source3/libsmb/libsmb_file.c
@@ -46,7 +46,7 @@ SMBC_open_ctx(SMBCCTX *context,
int fd;
TALLOC_CTX *frame = talloc_stackframe();
- if (!context || !context->initialized) {
+ if (!context || !context->internal->initialized) {
errno = EINVAL; /* Best I can think of ... */
TALLOC_FREE(frame);
@@ -78,7 +78,7 @@ SMBC_open_ctx(SMBCCTX *context,
}
if (!user || user[0] == (char)0) {
- user = talloc_strdup(frame, context->user);
+ user = talloc_strdup(frame, context->config.user);
if (!user) {
errno = ENOMEM;
TALLOC_FREE(frame);
@@ -120,7 +120,7 @@ SMBC_open_ctx(SMBCCTX *context,
/*d_printf(">>>open: resolved %s as %s\n", path, targetpath);*/
if ((fd = cli_open(targetcli, targetpath, flags,
- context->share_mode)) < 0) {
+ context->internal->share_mode)) < 0) {
/* Handle the error ... */
@@ -139,7 +139,7 @@ SMBC_open_ctx(SMBCCTX *context,
file->offset = 0;
file->file = True;
- DLIST_ADD(context->files, file);
+ DLIST_ADD(context->internal->files, file);
/*
* If the file was opened in O_APPEND mode, all write
@@ -208,7 +208,7 @@ SMBC_creat_ctx(SMBCCTX *context,
mode_t mode)
{
- if (!context || !context->initialized) {
+ if (!context || !context->internal->initialized) {
errno = EINVAL;
return NULL;
@@ -246,7 +246,7 @@ SMBC_read_ctx(SMBCCTX *context,
*/
off_t offset;
- if (!context || !context->initialized) {
+ if (!context || !context->internal->initialized) {
errno = EINVAL;
TALLOC_FREE(frame);
@@ -256,7 +256,7 @@ SMBC_read_ctx(SMBCCTX *context,
DEBUG(4, ("smbc_read(%p, %d)\n", file, (int)count));
- if (!file || !SMBC_dlist_contains(context->files, file)) {
+ if (!file || !SMBC_dlist_contains(context->internal->files, file)) {
errno = EBADF;
TALLOC_FREE(frame);
return -1;
@@ -338,7 +338,7 @@ SMBC_write_ctx(SMBCCTX *context,
/* First check all pointers before dereferencing them */
- if (!context || !context->initialized) {
+ if (!context || !context->internal->initialized) {
errno = EINVAL;
TALLOC_FREE(frame);
@@ -346,7 +346,7 @@ SMBC_write_ctx(SMBCCTX *context,
}
- if (!file || !SMBC_dlist_contains(context->files, file)) {
+ if (!file || !SMBC_dlist_contains(context->internal->files, file)) {
errno = EBADF;
TALLOC_FREE(frame);
return -1;
@@ -418,14 +418,14 @@ SMBC_close_ctx(SMBCCTX *context,
struct cli_state *targetcli = NULL;
TALLOC_CTX *frame = talloc_stackframe();
- if (!context || !context->initialized) {
+ if (!context || !context->internal->initialized) {
errno = EINVAL;
TALLOC_FREE(frame);
return -1;
}
- if (!file || !SMBC_dlist_contains(context->files, file)) {
+ if (!file || !SMBC_dlist_contains(context->internal->files, file)) {
errno = EBADF;
TALLOC_FREE(frame);
return -1;
@@ -470,7 +470,7 @@ SMBC_close_ctx(SMBCCTX *context,
* from the server cache if unused */
errno = SMBC_errno(context, targetcli);
srv = file->srv;
- DLIST_REMOVE(context->files, file);
+ DLIST_REMOVE(context->internal->files, file);
SAFE_FREE(file->fname);
SAFE_FREE(file);
(context->server.remove_unused_server_fn)(context, srv);
@@ -479,7 +479,7 @@ SMBC_close_ctx(SMBCCTX *context,
}
- DLIST_REMOVE(context->files, file);
+ DLIST_REMOVE(context->internal->files, file);
SAFE_FREE(file->fname);
SAFE_FREE(file);
TALLOC_FREE(frame);
@@ -509,7 +509,7 @@ SMBC_getatr(SMBCCTX * context,
time_t write_time;
TALLOC_CTX *frame = talloc_stackframe();
- if (!context || !context->initialized) {
+ if (!context || !context->internal->initialized) {
errno = EINVAL;
TALLOC_FREE(frame);
@@ -698,14 +698,14 @@ SMBC_lseek_ctx(SMBCCTX *context,
struct cli_state *targetcli = NULL;
TALLOC_CTX *frame = talloc_stackframe();
- if (!context || !context->initialized) {
+ if (!context || !context->internal->initialized) {
errno = EINVAL;
TALLOC_FREE(frame);
return -1;
}
- if (!file || !SMBC_dlist_contains(context->files, file)) {
+ if (!file || !SMBC_dlist_contains(context->internal->files, file)) {
errno = EBADF;
TALLOC_FREE(frame);
@@ -803,14 +803,14 @@ SMBC_ftruncate_ctx(SMBCCTX *context,
struct cli_state *targetcli = NULL;
TALLOC_CTX *frame = talloc_stackframe();
- if (!context || !context->initialized) {
+ if (!context || !context->internal->initialized) {
errno = EINVAL;
TALLOC_FREE(frame);
return -1;
}
- if (!file || !SMBC_dlist_contains(context->files, file)) {
+ if (!file || !SMBC_dlist_contains(context->internal->files, file)) {
errno = EBADF;
TALLOC_FREE(frame);
return -1;
diff --git a/source3/libsmb/libsmb_path.c b/source3/libsmb/libsmb_path.c
index 2533f536c3..6706a59ba8 100644
--- a/source3/libsmb/libsmb_path.c
+++ b/source3/libsmb/libsmb_path.c
@@ -252,7 +252,8 @@ SMBC_parse_path(TALLOC_CTX *ctx,
* to the workgroup in the provided context.
*/
if (pp_workgroup != NULL) {
- *pp_workgroup = talloc_strdup(ctx, context->workgroup);
+ *pp_workgroup =
+ talloc_strdup(ctx, context->config.workgroup);
}
if (pp_options) {
@@ -296,13 +297,13 @@ SMBC_parse_path(TALLOC_CTX *ctx,
}
if (*p == '/') {
- int wl = strlen(context->workgroup);
+ int wl = strlen(context->config.workgroup);
if (wl > 16) {
wl = 16;
}
- *pp_server = talloc_strdup(ctx, context->workgroup);
+ *pp_server = talloc_strdup(ctx, context->config.workgroup);
if (!*pp_server) {
return -1;
}
diff --git a/source3/libsmb/libsmb_printjob.c b/source3/libsmb/libsmb_printjob.c
index f106080b6f..a03c15e024 100644
--- a/source3/libsmb/libsmb_printjob.c
+++ b/source3/libsmb/libsmb_printjob.c
@@ -42,7 +42,7 @@ SMBC_open_print_job_ctx(SMBCCTX *context,
char *path = NULL;
TALLOC_CTX *frame = talloc_stackframe();
- if (!context || !context->initialized) {
+ if (!context || !context->internal->initialized) {
errno = EINVAL;
TALLOC_FREE(frame);
@@ -99,8 +99,8 @@ SMBC_print_file_ctx(SMBCCTX *c_file,
char buf[4096];
TALLOC_CTX *frame = talloc_stackframe();
- if (!c_file || !c_file->initialized ||
- !c_print || !c_print->initialized) {
+ if (!c_file || !c_file->internal->initialized ||
+ !c_print || !c_print->internal->initialized) {
errno = EINVAL;
TALLOC_FREE(frame);
@@ -189,7 +189,7 @@ SMBC_list_print_jobs_ctx(SMBCCTX *context,
char *path = NULL;
TALLOC_CTX *frame = talloc_stackframe();
- if (!context || !context->initialized) {
+ if (!context || !context->internal->initialized) {
errno = EINVAL;
TALLOC_FREE(frame);
@@ -220,7 +220,7 @@ SMBC_list_print_jobs_ctx(SMBCCTX *context,
}
if (!user || user[0] == (char)0) {
- user = talloc_strdup(frame, context->user);
+ user = talloc_strdup(frame, context->config.user);
if (!user) {
errno = ENOMEM;
TALLOC_FREE(frame);
@@ -267,7 +267,7 @@ SMBC_unlink_print_job_ctx(SMBCCTX *context,
int err;
TALLOC_CTX *frame = talloc_stackframe();
- if (!context || !context->initialized) {
+ if (!context || !context->internal->initialized) {
errno = EINVAL;
TALLOC_FREE(frame);
@@ -298,7 +298,7 @@ SMBC_unlink_print_job_ctx(SMBCCTX *context,
}
if (!user || user[0] == (char)0) {
- user = talloc_strdup(frame, context->user);
+ user = talloc_strdup(frame, context->config.user);
if (!user) {
errno = ENOMEM;
TALLOC_FREE(frame);
diff --git a/source3/libsmb/libsmb_server.c b/source3/libsmb/libsmb_server.c
index 978a843d30..70e0d57273 100644
--- a/source3/libsmb/libsmb_server.c
+++ b/source3/libsmb/libsmb_server.c
@@ -58,12 +58,12 @@ SMBC_remove_unused_server(SMBCCTX * context,
SMBCFILE * file;
/* are we being fooled ? */
- if (!context || !context->initialized || !srv) {
+ if (!context || !context->internal->initialized || !srv) {
return 1;
}
/* Check all open files/directories for a relation with this server */
- for (file = context->files; file; file = file->next) {
+ for (file = context->internal->files; file; file = file->next) {
if (file->srv == srv) {
/* Still used */
DEBUG(3, ("smbc_remove_usused_server: "
@@ -73,7 +73,7 @@ SMBC_remove_unused_server(SMBCCTX * context,
}
}
- DLIST_REMOVE(context->servers, srv);
+ DLIST_REMOVE(context->internal->servers, srv);
cli_shutdown(srv->cli);
srv->cli = NULL;
@@ -251,7 +251,7 @@ SMBC_server(TALLOC_CTX *ctx,
* If we found a connection and we're only allowed one share per
* server...
*/
- if (srv && *share != '\0' && context->one_share_per_server) {
+ if (srv && *share != '\0' && context->internal->one_share_per_server) {
/*
* ... then if there's no current connection to the share,
@@ -322,7 +322,7 @@ SMBC_server(TALLOC_CTX *ctx,
return NULL;
}
- make_nmb_name(&calling, context->netbios_name, 0x0);
+ make_nmb_name(&calling, context->config.netbios_name, 0x0);
make_nmb_name(&called , server, 0x20);
DEBUG(4,("SMBC_server: server_n=[%s] server=[%s]\n", server_n, server));
@@ -339,14 +339,14 @@ SMBC_server(TALLOC_CTX *ctx,
return NULL;
}
- if (context->use_kerberos) {
+ if (context->flags.bits & SMB_CTX_FLAG_USE_KERBEROS) {
c->use_kerberos = True;
}
- if (context->fallback_after_kerberos) {
+ if (context->flags.bits & SMB_CTX_FLAG_FALLBACK_AFTER_KERBEROS) {
c->fallback_after_kerberos = True;
}
- c->timeout = context->timeout;
+ c->timeout = context->config.timeout;
/*
* Force use of port 139 for first try if share is $IPC, empty, or
@@ -428,7 +428,8 @@ SMBC_server(TALLOC_CTX *ctx,
/* Failed. Try an anonymous login, if allowed by flags. */
username_used = "";
- if (context->no_auto_anonymous_login ||
+ if ((context->flags.bits &
+ SMBCCTX_FLAG_NO_AUTO_ANONYMOUS_LOGON) ||
!NT_STATUS_IS_OK(cli_session_setup(c, username_used,
*pp_password, 1,
*pp_password, 0,
@@ -451,7 +452,7 @@ SMBC_server(TALLOC_CTX *ctx,
DEBUG(4,(" tconx ok\n"));
- if (context->smb_encryption_level) {
+ if (context->internal->smb_encryption_level) {
/* Attempt UNIX smb encryption. */
if (!NT_STATUS_IS_OK(cli_force_encryption(c,
username_used,
@@ -466,7 +467,7 @@ SMBC_server(TALLOC_CTX *ctx,
DEBUG(4,(" SMB encrypt failed\n"));
- if (context->smb_encryption_level == 2) {
+ if (context->internal->smb_encryption_level == 2) {
cli_shutdown(c);
errno = EPERM;
return NULL;
@@ -512,7 +513,7 @@ SMBC_server(TALLOC_CTX *ctx,
DEBUG(2, ("Server connect ok: //%s/%s: %p\n",
server, share, srv));
- DLIST_ADD(context->servers, srv);
+ DLIST_ADD(context->internal->servers, srv);
return srv;
failed:
@@ -566,7 +567,7 @@ SMBC_attr_server(TALLOC_CTX *ctx,
}
flags = 0;
- if (context->use_kerberos) {
+ if (context->flags.bits & SMB_CTX_FLAG_USE_KERBEROS) {
flags |= CLI_FULL_CONNECTION_USE_KERBEROS;
}
@@ -586,7 +587,7 @@ SMBC_attr_server(TALLOC_CTX *ctx,
return NULL;
}
- if (context->smb_encryption_level) {
+ if (context->internal->smb_encryption_level) {
/* Attempt UNIX smb encryption. */
if (!NT_STATUS_IS_OK(cli_force_encryption(ipc_cli,
*pp_username,
@@ -602,7 +603,7 @@ SMBC_attr_server(TALLOC_CTX *ctx,
DEBUG(4,(" SMB encrypt failed on IPC$\n"));
- if (context->smb_encryption_level == 2) {
+ if (context->internal->smb_encryption_level == 2) {
cli_shutdown(ipc_cli);
errno = EPERM;
return NULL;
@@ -668,7 +669,7 @@ SMBC_attr_server(TALLOC_CTX *ctx,
return NULL;
}
- DLIST_ADD(context->servers, ipc_srv);
+ DLIST_ADD(context->internal->servers, ipc_srv);
}
return ipc_srv;
diff --git a/source3/libsmb/libsmb_stat.c b/source3/libsmb/libsmb_stat.c
index 06238863b7..6072547e08 100644
--- a/source3/libsmb/libsmb_stat.c
+++ b/source3/libsmb/libsmb_stat.c
@@ -35,7 +35,7 @@ static ino_t
generate_inode(SMBCCTX *context,
const char *name)
{
- if (!context || !context->initialized) {
+ if (!context || !context->internal->initialized) {
errno = EINVAL;
return -1;
@@ -126,7 +126,7 @@ SMBC_stat_ctx(SMBCCTX *context,
SMB_INO_T ino = 0;
TALLOC_CTX *frame = talloc_stackframe();
- if (!context || !context->initialized) {
+ if (!context || !context->internal->initialized) {
errno = EINVAL; /* Best I can think of ... */
TALLOC_FREE(frame);
@@ -157,7 +157,7 @@ SMBC_stat_ctx(SMBCCTX *context,
}
if (!user || user[0] == (char)0) {
- user = talloc_strdup(frame,context->user);
+ user = talloc_strdup(frame,context->config.user);
if (!user) {
errno = ENOMEM;
TALLOC_FREE(frame);
@@ -222,14 +222,14 @@ SMBC_fstat_ctx(SMBCCTX *context,
SMB_INO_T ino = 0;
TALLOC_CTX *frame = talloc_stackframe();
- if (!context || !context->initialized) {
+ if (!context || !context->internal->initialized) {
errno = EINVAL;
TALLOC_FREE(frame);
return -1;
}
- if (!file || !SMBC_dlist_contains(context->files, file)) {
+ if (!file || !SMBC_dlist_contains(context->internal->files, file)) {
errno = EBADF;
TALLOC_FREE(frame);
return -1;
diff --git a/source3/libsmb/libsmb_xattr.c b/source3/libsmb/libsmb_xattr.c
index 93ca0706b2..a420299341 100644
--- a/source3/libsmb/libsmb_xattr.c
+++ b/source3/libsmb/libsmb_xattr.c
@@ -609,7 +609,7 @@ dos_attr_parse(SMBCCTX *context,
} attr_strings;
/* Determine whether to use old-style or new-style attribute names */
- if (context->full_time_names) {
+ if (context->internal->full_time_names) {
/* new-style names */
attr_strings.create_time_attr = "CREATE_TIME";
attr_strings.access_time_attr = "ACCESS_TIME";
@@ -759,7 +759,7 @@ cacl_get(SMBCCTX *context,
} excl_attr_strings;
/* Determine whether to use old-style or new-style attribute names */
- if (context->full_time_names) {
+ if (context->internal->full_time_names) {
/* new-style names */
attr_strings.create_time_attr = "CREATE_TIME";
attr_strings.access_time_attr = "ACCESS_TIME";
@@ -1689,7 +1689,7 @@ SMBC_setxattr_ctx(SMBCCTX *context,
} attr_strings;
TALLOC_CTX *frame = talloc_stackframe();
- if (!context || !context->initialized) {
+ if (!context || !context->internal->initialized) {
errno = EINVAL; /* Best I can think of ... */
TALLOC_FREE(frame);
@@ -1721,7 +1721,7 @@ SMBC_setxattr_ctx(SMBCCTX *context,
}
if (!user || user[0] == (char)0) {
- user = talloc_strdup(frame, context->user);
+ user = talloc_strdup(frame, context->config.user);
if (!user) {
errno = ENOMEM;
TALLOC_FREE(frame);
@@ -1893,7 +1893,7 @@ SMBC_setxattr_ctx(SMBCCTX *context,
}
/* Determine whether to use old-style or new-style attribute names */
- if (context->full_time_names) {
+ if (context->internal->full_time_names) {
/* new-style names */
attr_strings.create_time_attr = "system.dos_attr.CREATE_TIME";
attr_strings.access_time_attr = "system.dos_attr.ACCESS_TIME";
@@ -1984,7 +1984,7 @@ SMBC_getxattr_ctx(SMBCCTX *context,
} attr_strings;
TALLOC_CTX *frame = talloc_stackframe();
- if (!context || !context->initialized) {
+ if (!context || !context->internal->initialized) {
errno = EINVAL; /* Best I can think of ... */
TALLOC_FREE(frame);
@@ -2015,7 +2015,7 @@ SMBC_getxattr_ctx(SMBCCTX *context,
}
if (!user || user[0] == (char)0) {
- user = talloc_strdup(frame, context->user);
+ user = talloc_strdup(frame, context->config.user);
if (!user) {
errno = ENOMEM;
TALLOC_FREE(frame);
@@ -2041,7 +2041,7 @@ SMBC_getxattr_ctx(SMBCCTX *context,
}
/* Determine whether to use old-style or new-style attribute names */
- if (context->full_time_names) {
+ if (context->internal->full_time_names) {
/* new-style names */
attr_strings.create_time_attr = "system.dos_attr.CREATE_TIME";
attr_strings.access_time_attr = "system.dos_attr.ACCESS_TIME";
@@ -2118,7 +2118,7 @@ SMBC_removexattr_ctx(SMBCCTX *context,
char *path = NULL;
TALLOC_CTX *frame = talloc_stackframe();
- if (!context || !context->initialized) {
+ if (!context || !context->internal->initialized) {
errno = EINVAL; /* Best I can think of ... */
TALLOC_FREE(frame);
@@ -2149,7 +2149,7 @@ SMBC_removexattr_ctx(SMBCCTX *context,
}
if (!user || user[0] == (char)0) {
- user = talloc_strdup(frame, context->user);
+ user = talloc_strdup(frame, context->config.user);
if (!user) {
errno = ENOMEM;
TALLOC_FREE(frame);
@@ -2270,7 +2270,7 @@ SMBC_listxattr_ctx(SMBCCTX *context,
;
const char * supported;
- if (context->full_time_names) {
+ if (context->internal->full_time_names) {
supported = supported_new;
retsize = sizeof(supported_new);
} else {