From: Volker Lendecke Date: Wed, 17 Nov 2021 11:27:27 +0000 (+0100) Subject: cmdline: Make -P work in clustered mode X-Git-Tag: ldb-2.5.0~13 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=cdc0268c1987f36ab400ea01df88d55c02dccfdb;p=thirdparty%2Fsamba.git cmdline: Make -P work in clustered mode Bug: https://bugzilla.samba.org/show_bug.cgi?id=14908 Signed-off-by: Volker Lendecke Reviewed-by: Ralph Boehme Autobuild-User(master): Ralph Böhme Autobuild-Date(master): Wed Nov 17 18:29:09 UTC 2021 on sn-devel-184 --- diff --git a/lib/cmdline/cmdline_s3.c b/lib/cmdline/cmdline_s3.c index 639d403aed3..6e2c154c756 100644 --- a/lib/cmdline/cmdline_s3.c +++ b/lib/cmdline/cmdline_s3.c @@ -26,6 +26,7 @@ #include "auth/credentials/credentials.h" #include "dynconfig/dynconfig.h" #include "cmdline_private.h" +#include "source3/include/secrets.h" static bool _require_smbconf; static enum samba_cmdline_config_type _config_type; @@ -84,6 +85,31 @@ static bool _samba_cmdline_load_config_s3(void) return true; } +static NTSTATUS _samba_cmd_set_machine_account_s3( + struct cli_credentials *cred, + struct loadparm_context *lp_ctx) +{ + struct db_context *db_ctx = secrets_db_ctx(); + NTSTATUS status; + + if (db_ctx == NULL) { + DBG_WARNING("failed to open secrets.tdb to obtain our " + "trust credentials for %s\n", + lpcfg_workgroup(lp_ctx));; + return NT_STATUS_INTERNAL_ERROR; + } + + status = cli_credentials_set_machine_account_db_ctx( + cred, lp_ctx, db_ctx); + if (!NT_STATUS_IS_OK(status)) { + DBG_WARNING("cli_credentials_set_machine_account_db_ctx " + "failed: %s\n", + nt_errstr(status)); + } + + return status; +} + bool samba_cmdline_init(TALLOC_CTX *mem_ctx, enum samba_cmdline_config_type config_type, bool require_smbconf) @@ -119,6 +145,8 @@ bool samba_cmdline_init(TALLOC_CTX *mem_ctx, } samba_cmdline_set_load_config_fn(_samba_cmdline_load_config_s3); + samba_cmdline_set_machine_account_fn( + _samba_cmd_set_machine_account_s3); return true; } diff --git a/lib/cmdline/wscript b/lib/cmdline/wscript index 1e13561ddf6..01ead85e2c4 100644 --- a/lib/cmdline/wscript +++ b/lib/cmdline/wscript @@ -22,7 +22,7 @@ def build(bld): bld.SAMBA_SUBSYSTEM('CMDLINE_S3', source='cmdline_s3.c', - deps='cmdline') + deps='cmdline secrets3') bld.SAMBA_SUBSYSTEM('CMDLINE_S4', source='cmdline_s4.c', diff --git a/selftest/knownfail.d/clustered_machine_account b/selftest/knownfail.d/clustered_machine_account deleted file mode 100644 index 16abc62a51c..00000000000 --- a/selftest/knownfail.d/clustered_machine_account +++ /dev/null @@ -1 +0,0 @@ -^samba3.net_machine_account.net_ads_user\(clusteredmember\) \ No newline at end of file