-/*
+/*
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) Tom Jansen (Ninja ISD) 2002
Copyright (C) Derrell Lipman 2003-2008
Copyright (C) Jeremy Allison 2007, 2008
#include "libsmbclient.h"
#include "libsmb_internal.h"
#include "secrets.h"
-
+#include "../libcli/smb/smbXcli_base.h"
/*
- * Is the logging working / configfile read ?
+ * Is the logging working / configfile read ?
*/
static bool SMBC_initialized = false;
static unsigned int initialized_ctx_count = 0;
/* Here we would open the smb.conf file if needed ... */
- lp_set_in_client(True);
-
home = getenv("HOME");
if (home) {
char *conf = NULL;
if (asprintf(&conf, "%s/.smb/smb.conf", home) > 0) {
- if (lp_load(conf, True, False, False, True)) {
+ if (lp_load_client(conf)) {
conf_loaded = True;
} else {
DEBUG(5, ("Could not load config file: %s\n",
* defaults ...
*/
- if (!lp_load(get_dyn_CONFIGFILE(), True, False, False, False)) {
+ if (!lp_load_client(get_dyn_CONFIGFILE())) {
DEBUG(5, ("Could not load config file: %s\n",
get_dyn_CONFIGFILE()));
} else if (home) {
if (asprintf(&conf,
"%s/.smb/smb.conf.append",
home) > 0) {
- if (!lp_load(conf, True, False, False, False)) {
+ if (!lp_load_client_no_reinit(conf)) {
DEBUG(10,
("Could not append config file: "
"%s\n",
static void
SMBC_module_terminate(void)
{
+ TALLOC_CTX *frame = talloc_stackframe();
secrets_shutdown();
gfree_all();
SMBC_initialized = false;
+ TALLOC_FREE(frame);
}
smbc_new_context(void)
{
SMBCCTX *context;
+ TALLOC_CTX *frame = talloc_stackframe();
/* The first call to this function should initialize the module */
SMB_THREAD_ONCE(&SMBC_initialized, SMBC_module_init, NULL);
*/
context = SMB_MALLOC_P(SMBCCTX);
if (!context) {
+ TALLOC_FREE(frame);
errno = ENOMEM;
return NULL;
}
context->internal = SMB_MALLOC_P(struct SMBC_internal_data);
if (!context->internal) {
+ TALLOC_FREE(frame);
SAFE_FREE(context);
errno = ENOMEM;
return NULL;
smbc_setDebug(context, 0);
smbc_setTimeout(context, 20000);
+ smbc_setPort(context, 0);
smbc_setOptionFullTimeNames(context, False);
smbc_setOptionOpenShareMode(context, SMBC_SHAREMODE_DENY_NONE);
smbc_setFunctionListPrintJobs(context, SMBC_list_print_jobs_ctx);
smbc_setFunctionUnlinkPrintJob(context, SMBC_unlink_print_job_ctx);
+ TALLOC_FREE(frame);
return context;
}
smbc_free_context(SMBCCTX *context,
int shutdown_ctx)
{
+ TALLOC_CTX *frame;
if (!context) {
errno = EBADF;
return 1;
}
+ frame = talloc_stackframe();
+
if (shutdown_ctx) {
SMBCFILE * f;
DEBUG(1,("Performing aggressive shutdown.\n"));
"Nice way shutdown failed.\n"));
s = context->internal->servers;
while (s) {
- DEBUG(1, ("Forced shutdown: %p (fd=%d)\n",
- s, s->cli->fd));
+ DEBUG(1, ("Forced shutdown: %p (cli=%p)\n",
+ s, s->cli));
cli_shutdown(s->cli);
smbc_getFunctionRemoveCachedServer(context)(context,
s);
DEBUG(1, ("Could not purge all servers, "
"free_context failed.\n"));
errno = EBUSY;
+ TALLOC_FREE(frame);
return 1;
}
if (context->internal->servers) {
DEBUG(1, ("Active servers in context, "
"free_context failed.\n"));
errno = EBUSY;
+ TALLOC_FREE(frame);
return 1;
}
if (context->internal->files) {
DEBUG(1, ("Active files in context, "
"free_context failed.\n"));
errno = EBUSY;
+ TALLOC_FREE(frame);
return 1;
}
}
smb_panic("error unlocking 'initialized_ctx_count'");
}
+ TALLOC_FREE(frame);
return 0;
}
const char *s;
} option_value;
+ TALLOC_CTX *frame = talloc_stackframe();
+
va_start(ap, option_name);
if (strcmp(option_name, "debug_to_stderr") == 0) {
}
va_end(ap);
+ TALLOC_FREE(frame);
}
for (s = context->internal->servers; s; s = s->next) {
num_servers++;
- if (s->cli->trans_enc_state == NULL) {
+ if (!smb1cli_conn_encryption_on(s->cli->conn)) {
return (void *)false;
}
}
smbc_init_context(SMBCCTX *context)
{
int pid;
+ TALLOC_CTX *frame;
if (!context) {
errno = EBADF;
return NULL;
}
+ frame = talloc_stackframe();
+
if ((!smbc_getFunctionAuthData(context) &&
!smbc_getFunctionAuthDataWithContext(context)) ||
smbc_getDebug(context) < 0 ||
smbc_getDebug(context) > 100) {
+ TALLOC_FREE(frame);
errno = EINVAL;
return NULL;
}
if (!user) {
+ TALLOC_FREE(frame);
errno = ENOMEM;
return NULL;
}
SAFE_FREE(user);
if (!smbc_getUser(context)) {
+ TALLOC_FREE(frame);
errno = ENOMEM;
return NULL;
}
* Hmmm, I want to get hostname as well, but I am too
* lazy for the moment
*/
- pid = sys_getpid();
+ pid = getpid();
netbios_name = (char *)SMB_MALLOC(17);
if (!netbios_name) {
+ TALLOC_FREE(frame);
errno = ENOMEM;
return NULL;
}
}
if (!netbios_name) {
+ TALLOC_FREE(frame);
errno = ENOMEM;
return NULL;
}
SAFE_FREE(netbios_name);
if (!smbc_getNetbiosName(context)) {
+ TALLOC_FREE(frame);
errno = ENOMEM;
return NULL;
}
}
if (!workgroup) {
+ TALLOC_FREE(frame);
errno = ENOMEM;
return NULL;
}
SAFE_FREE(workgroup);
if (!smbc_getWorkgroup(context)) {
+ TALLOC_FREE(frame);
errno = ENOMEM;
return NULL;
}
smb_panic("error unlocking 'initialized_ctx_count'");
}
+ TALLOC_FREE(frame);
return context;
}
smbc_bool use_kerberos = false;
const char *signing_state = "off";
struct user_auth_info *auth_info = NULL;
+ TALLOC_CTX *frame;
if (! context) {
return;
}
+ frame = talloc_stackframe();
+
if (! workgroup || ! *workgroup) {
workgroup = smbc_getWorkgroup(context);
}
if (! auth_info) {
DEBUG(0, ("smbc_set_credentials_with_fallback: allocation fail\n"));
+ TALLOC_FREE(frame);
return;
}
use_kerberos = True;
}
- if (lp_client_signing()) {
- signing_state = "on";
+ if (lp_client_signing() != SMB_SIGNING_OFF) {
+ signing_state = "if_required";
}
- if (lp_client_signing() == Required) {
- signing_state = "force";
+ if (lp_client_signing() == SMB_SIGNING_REQUIRED) {
+ signing_state = "required";
}
set_cmdline_auth_info_username(auth_info, user);
TALLOC_FREE(context->internal->auth_info);
context->internal->auth_info = auth_info;
+ TALLOC_FREE(frame);
}