|
|
48b328 |
From c090131e4f912f6f6c4f79eb40fbe500eb31c171 Mon Sep 17 00:00:00 2001
|
|
|
48b328 |
From: Sumit Bose <sbose@redhat.com>
|
|
|
48b328 |
Date: Tue, 30 Jan 2018 18:24:15 +0100
|
|
|
48b328 |
Subject: [PATCH 14/23] tools: store Samba data if requested
|
|
|
48b328 |
|
|
|
48b328 |
Use Samba's net utility to add the machine account password and the
|
|
|
48b328 |
domain SID to the Samba configuration.
|
|
|
48b328 |
|
|
|
48b328 |
https://bugs.freedesktop.org/show_bug.cgi?id=100118
|
|
|
48b328 |
|
|
|
48b328 |
Reviewed-by: Jakub Hrozek <jhrozek@redhat.com>
|
|
|
48b328 |
---
|
|
|
48b328 |
library/adenroll.c | 39 +++++++++++++++++++++++++++++++++++++++
|
|
|
48b328 |
1 file changed, 39 insertions(+)
|
|
|
48b328 |
|
|
|
48b328 |
diff --git a/library/adenroll.c b/library/adenroll.c
|
|
|
48b328 |
index bb970d1..20731cd 100644
|
|
|
48b328 |
--- a/library/adenroll.c
|
|
|
48b328 |
+++ b/library/adenroll.c
|
|
|
48b328 |
@@ -1533,6 +1533,36 @@ update_keytab_for_principals (adcli_enroll *enroll)
|
|
|
48b328 |
return ADCLI_SUCCESS;
|
|
|
48b328 |
}
|
|
|
48b328 |
|
|
|
48b328 |
+static adcli_result
|
|
|
48b328 |
+update_samba_data (adcli_enroll *enroll)
|
|
|
48b328 |
+{
|
|
|
48b328 |
+ int ret;
|
|
|
48b328 |
+ char *argv_pw[] = { "/usr/bin/net", "changesecretpw", "-i", "-f", NULL };
|
|
|
48b328 |
+ char *argv_sid[] = { "/usr/bin/net", "setdomainsid", NULL, NULL };
|
|
|
48b328 |
+
|
|
|
48b328 |
+ _adcli_info ("Trying to set Samba secret.\n");
|
|
|
48b328 |
+ ret = _adcli_call_external_program (argv_pw[0], argv_pw,
|
|
|
48b328 |
+ enroll->computer_password, NULL, NULL);
|
|
|
48b328 |
+ if (ret != ADCLI_SUCCESS) {
|
|
|
48b328 |
+ _adcli_err ("Failed to set Samba computer account password.\n");
|
|
|
48b328 |
+ }
|
|
|
48b328 |
+
|
|
|
48b328 |
+ argv_sid[2] = (char *) adcli_conn_get_domain_sid (enroll->conn);
|
|
|
48b328 |
+ if (argv_sid[2] == NULL) {
|
|
|
48b328 |
+ _adcli_err ("Domain SID not available.\n");
|
|
|
48b328 |
+ } else {
|
|
|
48b328 |
+ _adcli_info ("Trying to set domain SID %s for Samba.\n",
|
|
|
48b328 |
+ argv_sid[2]);
|
|
|
48b328 |
+ ret = _adcli_call_external_program (argv_sid[0], argv_sid,
|
|
|
48b328 |
+ NULL, NULL, NULL);
|
|
|
48b328 |
+ if (ret != ADCLI_SUCCESS) {
|
|
|
48b328 |
+ _adcli_err ("Failed to set Samba domain SID.\n");
|
|
|
48b328 |
+ }
|
|
|
48b328 |
+ }
|
|
|
48b328 |
+
|
|
|
48b328 |
+ return ret;
|
|
|
48b328 |
+}
|
|
|
48b328 |
+
|
|
|
48b328 |
static void
|
|
|
48b328 |
enroll_clear_state (adcli_enroll *enroll)
|
|
|
48b328 |
{
|
|
|
48b328 |
@@ -1687,6 +1717,15 @@ enroll_join_or_update_tasks (adcli_enroll *enroll,
|
|
|
48b328 |
update_computer_account (enroll);
|
|
|
48b328 |
update_service_principals (enroll);
|
|
|
48b328 |
|
|
|
48b328 |
+ if ( (flags & ADCLI_ENROLL_ADD_SAMBA_DATA) && ! (flags & ADCLI_ENROLL_PASSWORD_VALID)) {
|
|
|
48b328 |
+ res = update_samba_data (enroll);
|
|
|
48b328 |
+ if (res != ADCLI_SUCCESS) {
|
|
|
48b328 |
+ _adcli_info ("Failed to add Samba specific data, smbd "
|
|
|
48b328 |
+ "or winbindd might not work as "
|
|
|
48b328 |
+ "expected.\n");
|
|
|
48b328 |
+ }
|
|
|
48b328 |
+ }
|
|
|
48b328 |
+
|
|
|
48b328 |
if (flags & ADCLI_ENROLL_NO_KEYTAB)
|
|
|
48b328 |
return ADCLI_SUCCESS;
|
|
|
48b328 |
|
|
|
48b328 |
--
|
|
|
48b328 |
2.14.4
|
|
|
48b328 |
|