/* this is used by the chaining code */
int chain_size = 0;
-int trans_num = 0;
-
static enum remote_arch_types ra_type = RA_UNKNOWN;
/***********************************************************************
gfree_names();
gfree_loadparm();
gfree_case_tables();
- gfree_debugsyms();
gfree_charcnv();
gfree_interfaces();
-
- /* release the talloc null_context memory last */
- talloc_disable_null_tracking();
+ gfree_debugsyms();
}
const char *my_netbios_names(int i)
false, /* got_pass */
false, /* use_kerberos */
Undefined, /* signing state */
- false /* smb_encrypt */
+ false, /* smb_encrypt */
+ false /* use machine account */
};
const char *get_cmdline_auth_info_username(void)
return cmdline_auth_info.signing_state;
}
+void set_cmdline_auth_info_use_kerberos(bool b)
+{
+ cmdline_auth_info.use_kerberos = b;
+}
+
bool get_cmdline_auth_info_use_kerberos(void)
{
return cmdline_auth_info.use_kerberos;
cmdline_auth_info.smb_encrypt = true;
}
+void set_cmdline_auth_info_use_machine_account(void)
+{
+ cmdline_auth_info.use_machine_account = true;
+}
+
bool get_cmdline_auth_info_got_pass(void)
{
return cmdline_auth_info.got_pass;
return cmdline_auth_info.smb_encrypt;
}
+bool get_cmdline_auth_info_use_machine_account(void)
+{
+ return cmdline_auth_info.use_machine_account;
+}
+
bool get_cmdline_auth_info_copy(struct user_auth_info *info)
{
*info = cmdline_auth_info;
return true;
}
+bool set_cmdline_auth_info_machine_account_creds(void)
+{
+ char *pass = NULL;
+ char *account = NULL;
+
+ if (!get_cmdline_auth_info_use_machine_account()) {
+ return false;
+ }
+
+ if (!secrets_init()) {
+ d_printf("ERROR: Unable to open secrets database\n");
+ return false;
+ }
+
+ if (asprintf(&account, "%s$@%s", global_myname(), lp_realm()) < 0) {
+ return false;
+ }
+
+ pass = secrets_fetch_machine_password(lp_workgroup(), NULL, NULL);
+ if (!pass) {
+ d_printf("ERROR: Unable to fetch machine password for "
+ "%s in domain %s\n",
+ account, lp_workgroup());
+ SAFE_FREE(account);
+ return false;
+ }
+
+ set_cmdline_auth_info_username(account);
+ set_cmdline_auth_info_password(pass);
+
+ SAFE_FREE(account);
+ SAFE_FREE(pass);
+
+ return true;
+}
+
/**************************************************************************n
Find a suitable temporary directory. The result should be copied immediately
as it may be overwritten by a subsequent call.
attach it to the logfile */
}
+bool reinit_after_fork(struct messaging_context *msg_ctx,
+ bool parent_longlived)
+{
+ NTSTATUS status;
+
+ /* Reset the state of the random
+ * number generation system, so
+ * children do not get the same random
+ * numbers as each other */
+ set_need_random_reseed();
+
+ /* tdb needs special fork handling */
+ if (tdb_reopen_all(parent_longlived ? 1 : 0) == -1) {
+ DEBUG(0,("tdb_reopen_all failed.\n"));
+ return false;
+ }
+
+ /*
+ * For clustering, we need to re-init our ctdbd connection after the
+ * fork
+ */
+ status = messaging_reinit(msg_ctx);
+ if (!NT_STATUS_IS_OK(status)) {
+ DEBUG(0,("messaging_reinit() failed: %s\n",
+ nt_errstr(status)));
+ return false;
+ }
+
+ return true;
+}
+
/****************************************************************************
Put up a yes/no prompt.
****************************************************************************/
if possible.
********************************************************************/
-void set_namearray(name_compare_entry **ppname_array, char *namelist)
+void set_namearray(name_compare_entry **ppname_array, const char *namelist)
{
char *name_end;
- char *nameptr = namelist;
+ const char *nameptr = namelist;
int num_entries = 0;
int i;
if ( strcmp( native_lanman, "Windows 2002 5.1" ) == 0 )
set_remote_arch( RA_WINXP );
else if ( strcmp( native_lanman, "Windows XP 5.2" ) == 0 )
- set_remote_arch( RA_WINXP );
+ set_remote_arch( RA_WINXP64 );
else if ( strcmp( native_lanman, "Windows Server 2003 5.2" ) == 0 )
set_remote_arch( RA_WIN2K3 );
}
case RA_WINXP:
remote_arch_str = "WinXP";
break;
+ case RA_WINXP64:
+ remote_arch_str = "WinXP64";
+ break;
case RA_WIN2K3:
remote_arch_str = "Win2K3";
break;
DEBUG(level,("%c", isprint(buf[i])?buf[i]:'.'));
}
-void dump_data(int level, const unsigned char *buf1,int len)
+/**
+ * Write dump of binary data to the log file.
+ *
+ * The data is only written if the log level is at least level.
+ */
+static void _dump_data(int level, const uint8_t *buf, int len,
+ bool omit_zero_bytes)
{
- const unsigned char *buf = (const unsigned char *)buf1;
int i=0;
+ const uint8_t empty[16];
+ bool skipped = false;
+
if (len<=0) return;
if (!DEBUGLVL(level)) return;
-
- DEBUGADD(level,("[%03X] ",i));
+
+ memset(&empty, '\0', 16);
+
for (i=0;i<len;) {
+
+ if (i%16 == 0) {
+ if ((omit_zero_bytes == true) &&
+ (i > 0) &&
+ (len > i+16) &&
+ (memcmp(&buf[i], &empty, 16) == 0))
+ {
+ i +=16;
+ continue;
+ }
+
+ if (i<len) {
+ DEBUGADD(level,("[%04X] ",i));
+ }
+ }
+
DEBUGADD(level,("%02X ",(int)buf[i]));
i++;
- if (i%8 == 0) DEBUGADD(level,(" "));
- if (i%16 == 0) {
+ if (i%8 == 0) DEBUGADD(level,(" "));
+ if (i%16 == 0) {
+
print_asc(level,&buf[i-16],8); DEBUGADD(level,(" "));
print_asc(level,&buf[i-8],8); DEBUGADD(level,("\n"));
- if (i<len) DEBUGADD(level,("[%03X] ",i));
+
+ if ((omit_zero_bytes == true) &&
+ (len > i+16) &&
+ (memcmp(&buf[i], &empty, 16) == 0)) {
+ if (!skipped) {
+ DEBUGADD(level,("skipping zero buffer bytes\n"));
+ skipped = true;
+ }
+ }
}
}
+
if (i%16) {
int n;
n = 16 - (i%16);
if (n>0) print_asc(level,&buf[i-n],n);
DEBUGADD(level,("\n"));
}
+
+}
+
+/**
+ * Write dump of binary data to the log file.
+ *
+ * The data is only written if the log level is at least level.
+ */
+_PUBLIC_ void dump_data(int level, const uint8_t *buf, int len)
+{
+ _dump_data(level, buf, len, false);
+}
+
+/**
+ * Write dump of binary data to the log file.
+ *
+ * The data is only written if the log level is at least level.
+ * 16 zero bytes in a row are ommited
+ */
+_PUBLIC_ void dump_data_skip_zeros(int level, const uint8_t *buf, int len)
+{
+ _dump_data(level, buf, len, true);
}
+
+
void dump_data_pw(const char *msg, const uchar * data, size_t len)
{
#ifdef DEBUG_PASSWORD
return talloc_asprintf(talloc_tos(), "%s/%s", get_dyn_LIBDIR(), name);
}
+/**
+ * @brief Returns an absolute path to a file in the Samba modules directory.
+ *
+ * @param name File to find, relative to MODULESDIR.
+ *
+ * @retval Pointer to a string containing the full path.
+ **/
+
+char *modules_path(const char *name)
+{
+ return talloc_asprintf(talloc_tos(), "%s/%s", get_dyn_MODULESDIR(), name);
+}
+
/**
* @brief Returns an absolute path to a file in the Samba data directory.
*
return NULL;
}
+/**********************************************************************
+ Append a DATA_BLOB to a talloc'ed object
+***********************************************************************/
+
+void *talloc_append_blob(TALLOC_CTX *mem_ctx, void *buf, DATA_BLOB blob)
+{
+ size_t old_size = 0;
+ char *result;
+
+ if (blob.length == 0) {
+ return buf;
+ }
+
+ if (buf != NULL) {
+ old_size = talloc_get_size(buf);
+ }
+
+ result = (char *)TALLOC_REALLOC(mem_ctx, buf, old_size + blob.length);
+ if (result == NULL) {
+ return NULL;
+ }
+
+ memcpy(result + old_size, blob.data, blob.length);
+ return result;
+}
+
uint32 map_share_mode_to_deny_mode(uint32 share_access, uint32 private_options)
{
switch (share_access & ~FILE_SHARE_DELETE) {
result.pid = pid;
}
else if (sscanf(pid_string, "%u", &pid) == 1) {
- result.vnn = NONCLUSTER_VNN;
+ result.vnn = get_my_vnn();
result.pid = pid;
}
else {
}
return NT_STATUS_OK;
}
+
+bool is_valid_policy_hnd(const POLICY_HND *hnd)
+{
+ POLICY_HND tmp;
+ ZERO_STRUCT(tmp);
+ return (memcmp(&tmp, hnd, sizeof(tmp)) != 0);
+}
+
+bool policy_hnd_equal(const struct policy_handle *hnd1,
+ const struct policy_handle *hnd2)
+{
+ if (!hnd1 || !hnd2) {
+ return false;
+ }
+
+ return (memcmp(hnd1, hnd2, sizeof(*hnd1)) == 0);
+}
+
+/****************************************************************
+ strip off leading '\\' from a hostname
+****************************************************************/
+
+const char *strip_hostname(const char *s)
+{
+ if (!s) {
+ return NULL;
+ }
+
+ if (strlen_m(s) < 3) {
+ return s;
+ }
+
+ if (s[0] == '\\') s++;
+ if (s[0] == '\\') s++;
+
+ return s;
+}