Sumit Bose 461678
From d362a0799618b576918f5c5d0625565484670ba2 Mon Sep 17 00:00:00 2001
Sumit Bose 461678
From: Sumit Bose <sbose@redhat.com>
Sumit Bose 461678
Date: Tue, 30 Jan 2018 14:46:00 +0100
Sumit Bose 461678
Subject: [PATCH 13/23] tools: add option --add-samba-data
Sumit Bose 461678
Sumit Bose 461678
https://bugs.freedesktop.org/show_bug.cgi?id=100118
Sumit Bose 461678
Sumit Bose 461678
Reviewed-by: Jakub Hrozek <jhrozek@redhat.com>
Sumit Bose 461678
---
Sumit Bose 461678
 doc/adcli.xml      | 30 ++++++++++++++++++++++++++++++
Sumit Bose 461678
 library/adenroll.h |  1 +
Sumit Bose 461678
 tools/computer.c   | 12 ++++++++++++
Sumit Bose 461678
 3 files changed, 43 insertions(+)
Sumit Bose 461678
Sumit Bose 461678
diff --git a/doc/adcli.xml b/doc/adcli.xml
Sumit Bose 461678
index c54cc1b..fbc6c63 100644
Sumit Bose 461678
--- a/doc/adcli.xml
Sumit Bose 461678
+++ b/doc/adcli.xml
Sumit Bose 461678
@@ -292,6 +292,21 @@ Password for Administrator:
Sumit Bose 461678
 			machine account password. This is output in a format that should
Sumit Bose 461678
 			be both human and machine readable.</para></listitem>
Sumit Bose 461678
 		</varlistentry>
Sumit Bose 461678
+		<varlistentry>
Sumit Bose 461678
+			<term><option>--add-samba-data</option></term>
Sumit Bose 461678
+			<listitem><para>After a successful join add the domain
Sumit Bose 461678
+			SID and the machine account password to the Samba
Sumit Bose 461678
+			specific databases by calling Samba's
Sumit Bose 461678
+			<command>net</command> utility.</para>
Sumit Bose 461678
+
Sumit Bose 461678
+			<para>Please note that Samba's <command>net</command>
Sumit Bose 461678
+			requires some settings in <filename>smb.conf</filename>
Sumit Bose 461678
+			to create the database entries correctly. Most
Sumit Bose 461678
+			important here is currently the
Sumit Bose 461678
+			<option>workgroup</option> option, see
Sumit Bose 461678
+			<citerefentry><refentrytitle>smb.conf</refentrytitle><manvolnum>5</manvolnum></citerefentry>
Sumit Bose 461678
+			for details.</para></listitem>
Sumit Bose 461678
+		</varlistentry>
Sumit Bose 461678
 	</variablelist>
Sumit Bose 461678
 
Sumit Bose 461678
 </refsect1>
Sumit Bose 461678
@@ -382,6 +397,21 @@ $ adcli update --login-ccache=/tmp/krbcc_123
Sumit Bose 461678
 			about join operation. This is output in a format that should
Sumit Bose 461678
 			be both human and machine readable.</para></listitem>
Sumit Bose 461678
 		</varlistentry>
Sumit Bose 461678
+		<varlistentry>
Sumit Bose 461678
+			<term><option>--add-samba-data</option></term>
Sumit Bose 461678
+			<listitem><para>After a successful join add the domain
Sumit Bose 461678
+			SID and the machine account password to the Samba
Sumit Bose 461678
+			specific databases by calling Samba's
Sumit Bose 461678
+			<command>net</command> utility.</para>
Sumit Bose 461678
+
Sumit Bose 461678
+			<para>Please note that Samba's <command>net</command>
Sumit Bose 461678
+			requires some settings in <filename>smb.conf</filename>
Sumit Bose 461678
+			to create the database entries correctly. Most
Sumit Bose 461678
+			important here is currently the
Sumit Bose 461678
+			<option>workgroup</option> option, see
Sumit Bose 461678
+			<citerefentry><refentrytitle>smb.conf</refentrytitle><manvolnum>5</manvolnum></citerefentry>
Sumit Bose 461678
+			for details.</para></listitem>
Sumit Bose 461678
+		</varlistentry>
Sumit Bose 461678
 	</variablelist>
Sumit Bose 461678
 
Sumit Bose 461678
 </refsect1>
Sumit Bose 461678
diff --git a/library/adenroll.h b/library/adenroll.h
Sumit Bose 461678
index 9a107ab..32c9764 100644
Sumit Bose 461678
--- a/library/adenroll.h
Sumit Bose 461678
+++ b/library/adenroll.h
Sumit Bose 461678
@@ -30,6 +30,7 @@ typedef enum {
Sumit Bose 461678
 	ADCLI_ENROLL_NO_KEYTAB = 1 << 1,
Sumit Bose 461678
 	ADCLI_ENROLL_ALLOW_OVERWRITE = 1 << 2,
Sumit Bose 461678
 	ADCLI_ENROLL_PASSWORD_VALID = 1 << 3,
Sumit Bose 461678
+	ADCLI_ENROLL_ADD_SAMBA_DATA = 1 << 3,
Sumit Bose 461678
 } adcli_enroll_flags;
Sumit Bose 461678
 
Sumit Bose 461678
 typedef struct _adcli_enroll adcli_enroll;
Sumit Bose 461678
diff --git a/tools/computer.c b/tools/computer.c
Sumit Bose 461678
index a3d0f03..fc646f2 100644
Sumit Bose 461678
--- a/tools/computer.c
Sumit Bose 461678
+++ b/tools/computer.c
Sumit Bose 461678
@@ -106,6 +106,7 @@ typedef enum {
Sumit Bose 461678
 	opt_os_service_pack,
Sumit Bose 461678
 	opt_user_principal,
Sumit Bose 461678
 	opt_computer_password_lifetime,
Sumit Bose 461678
+	opt_add_samba_data,
Sumit Bose 461678
 } Option;
Sumit Bose 461678
 
Sumit Bose 461678
 static adcli_tool_desc common_usages[] = {
Sumit Bose 461678
@@ -142,6 +143,8 @@ static adcli_tool_desc common_usages[] = {
Sumit Bose 461678
 	                     "a successful join" },
Sumit Bose 461678
 	{ opt_show_password, "show computer account password after after a\n"
Sumit Bose 461678
 	                     "successful join" },
Sumit Bose 461678
+	{ opt_add_samba_data, "add domain SID and computer account password\n"
Sumit Bose 461678
+	                      "to the Samba specific configuration database" },
Sumit Bose 461678
 	{ opt_verbose, "show verbose progress and failure messages", },
Sumit Bose 461678
 	{ 0 },
Sumit Bose 461678
 };
Sumit Bose 461678
@@ -269,6 +272,7 @@ parse_option (Option opt,
Sumit Bose 461678
 	case opt_show_details:
Sumit Bose 461678
 	case opt_show_password:
Sumit Bose 461678
 	case opt_one_time_password:
Sumit Bose 461678
+	case opt_add_samba_data:
Sumit Bose 461678
 		assert (0 && "not reached");
Sumit Bose 461678
 		break;
Sumit Bose 461678
 	}
Sumit Bose 461678
@@ -326,6 +330,7 @@ adcli_tool_computer_join (adcli_conn *conn,
Sumit Bose 461678
 		{ "user-principal", optional_argument, NULL, opt_user_principal },
Sumit Bose 461678
 		{ "show-details", no_argument, NULL, opt_show_details },
Sumit Bose 461678
 		{ "show-password", no_argument, NULL, opt_show_password },
Sumit Bose 461678
+		{ "add-samba-data", no_argument, NULL, opt_add_samba_data },
Sumit Bose 461678
 		{ "verbose", no_argument, NULL, opt_verbose },
Sumit Bose 461678
 		{ "help", no_argument, NULL, 'h' },
Sumit Bose 461678
 		{ 0 },
Sumit Bose 461678
@@ -352,6 +357,9 @@ adcli_tool_computer_join (adcli_conn *conn,
Sumit Bose 461678
 		case opt_show_password:
Sumit Bose 461678
 			show_password = 1;
Sumit Bose 461678
 			break;
Sumit Bose 461678
+		case opt_add_samba_data:
Sumit Bose 461678
+			flags |= ADCLI_ENROLL_ADD_SAMBA_DATA;
Sumit Bose 461678
+			break;
Sumit Bose 461678
 		case 'h':
Sumit Bose 461678
 		case '?':
Sumit Bose 461678
 		case ':':
Sumit Bose 461678
@@ -425,6 +433,7 @@ adcli_tool_computer_update (adcli_conn *conn,
Sumit Bose 461678
 		{ "computer-password-lifetime", optional_argument, NULL, opt_computer_password_lifetime },
Sumit Bose 461678
 		{ "show-details", no_argument, NULL, opt_show_details },
Sumit Bose 461678
 		{ "show-password", no_argument, NULL, opt_show_password },
Sumit Bose 461678
+		{ "add-samba-data", no_argument, NULL, opt_add_samba_data },
Sumit Bose 461678
 		{ "verbose", no_argument, NULL, opt_verbose },
Sumit Bose 461678
 		{ "help", no_argument, NULL, 'h' },
Sumit Bose 461678
 		{ 0 },
Sumit Bose 461678
@@ -447,6 +456,9 @@ adcli_tool_computer_update (adcli_conn *conn,
Sumit Bose 461678
 		case opt_show_password:
Sumit Bose 461678
 			show_password = 1;
Sumit Bose 461678
 			break;
Sumit Bose 461678
+		case opt_add_samba_data:
Sumit Bose 461678
+			flags |= ADCLI_ENROLL_ADD_SAMBA_DATA;
Sumit Bose 461678
+			break;
Sumit Bose 461678
 		case 'h':
Sumit Bose 461678
 		case '?':
Sumit Bose 461678
 		case ':':
Sumit Bose 461678
-- 
Sumit Bose 461678
2.14.4
Sumit Bose 461678