Blame SOURCES/0001-Add-os-name-and-os-version-command-line-options.patch

2c6b19
From ca6684a68d2a9887c2e06e58a7fdfa3d327c8052 Mon Sep 17 00:00:00 2001
2c6b19
From: Sumit Bose <sbose@redhat.com>
2c6b19
Date: Tue, 28 Jun 2016 18:14:09 +0200
2c6b19
Subject: [PATCH] Add os-name and os-version command line options
2c6b19
2c6b19
---
2c6b19
 dbus/realm-dbus-constants.h  |  2 ++
2c6b19
 doc/manual/realm.xml         | 12 ++++++++++++
2c6b19
 doc/manual/realmd.conf.xml   |  5 +++++
2c6b19
 service/realm-adcli-enroll.c |  4 ++--
2c6b19
 service/realm-options.c      | 18 ++++++++++++++++++
2c6b19
 service/realm-options.h      |  3 +++
2c6b19
 service/realm-samba-enroll.c |  4 ++--
2c6b19
 tools/realm-join.c           |  8 ++++++++
2c6b19
 8 files changed, 52 insertions(+), 4 deletions(-)
2c6b19
2c6b19
diff --git a/dbus/realm-dbus-constants.h b/dbus/realm-dbus-constants.h
2c6b19
index 3a67a00..9cd30ef 100644
2c6b19
--- a/dbus/realm-dbus-constants.h
2c6b19
+++ b/dbus/realm-dbus-constants.h
2c6b19
@@ -67,6 +67,8 @@ G_BEGIN_DECLS
2c6b19
 #define   REALM_DBUS_OPTION_USER_PRINCIPAL         "user-principal"
2c6b19
 #define   REALM_DBUS_OPTION_MANAGE_SYSTEM          "manage-system"
2c6b19
 #define   REALM_DBUS_OPTION_COMPUTER_NAME          "computer-name"
2c6b19
+#define   REALM_DBUS_OPTION_OS_NAME                "os-name"
2c6b19
+#define   REALM_DBUS_OPTION_OS_VERSION             "os-version"
2c6b19
 
2c6b19
 #define   REALM_DBUS_IDENTIFIER_ACTIVE_DIRECTORY   "active-directory"
2c6b19
 #define   REALM_DBUS_IDENTIFIER_WINBIND            "winbind"
2c6b19
diff --git a/doc/manual/realm.xml b/doc/manual/realm.xml
2c6b19
index baa0d8c..6724d80 100644
2c6b19
--- a/doc/manual/realm.xml
2c6b19
+++ b/doc/manual/realm.xml
2c6b19
@@ -243,6 +243,18 @@ $ realm join --user=admin --computer-ou=OU=Special domain.example.com
2c6b19
 			the value for this option, then a principal will be set
2c6b19
 			in the form of <literal>host/shortname@REALM</literal></para></listitem>
2c6b19
 		</varlistentry>
2c6b19
+		<varlistentry>
2c6b19
+			<term><option>--os-name=xxx</option></term>
2c6b19
+			<listitem><para>The name of the operation system of the
2c6b19
+			client. When joining an AD domain the value is store in
2c6b19
+			the matching AD attribute.</para></listitem>
2c6b19
+		</varlistentry>
2c6b19
+		<varlistentry>
2c6b19
+			<term><option>--os-version=xxx</option></term>
2c6b19
+			<listitem><para>The version of the operation system of the
2c6b19
+			client. When joining an AD domain the value is store in
2c6b19
+			the matching AD attribute.</para></listitem>
2c6b19
+		</varlistentry>
2c6b19
 	</variablelist>
2c6b19
 
2c6b19
 </refsect1>
2c6b19
diff --git a/doc/manual/realmd.conf.xml b/doc/manual/realmd.conf.xml
2c6b19
index f8c87b9..7853230 100644
2c6b19
--- a/doc/manual/realmd.conf.xml
2c6b19
+++ b/doc/manual/realmd.conf.xml
2c6b19
@@ -149,6 +149,11 @@ domain.example.com
2c6b19
 
2c6b19
 		<para>This is an Active Directory specific option.</para>
2c6b19
 
2c6b19
+		<para>It is also possible to use the <option>--os-name</option>
2c6b19
+		or <option>--os-version</option> argument of the
2c6b19
+		<command>realm</command> command to override the default
2c6b19
+		values.</para>
2c6b19
+
2c6b19
 		<informalexample>
2c6b19
 <programlisting language="js">
2c6b19
 [active-directory]
2c6b19
diff --git a/service/realm-adcli-enroll.c b/service/realm-adcli-enroll.c
2c6b19
index 0c506f9..05947fa 100644
2c6b19
--- a/service/realm-adcli-enroll.c
2c6b19
+++ b/service/realm-adcli-enroll.c
2c6b19
@@ -139,13 +139,13 @@ realm_adcli_enroll_join_async (RealmDisco *disco,
2c6b19
 			g_ptr_array_add (args, (gpointer)computer_ou);
2c6b19
 	}
2c6b19
 
2c6b19
-	os = realm_settings_value ("active-directory", "os-name");
2c6b19
+	os = realm_options_ad_specific (options, "os-name");
2c6b19
 	if (os != NULL && !g_str_equal (os, "")) {
2c6b19
 		g_ptr_array_add (args, "--os-name");
2c6b19
 		g_ptr_array_add (args, (gpointer)os);
2c6b19
 	}
2c6b19
 
2c6b19
-	os = realm_settings_value ("active-directory", "os-version");
2c6b19
+	os = realm_options_ad_specific (options, "os-version");
2c6b19
 	if (os != NULL && !g_str_equal (os, "")) {
2c6b19
 		g_ptr_array_add (args, "--os-version");
2c6b19
 		g_ptr_array_add (args, (gpointer)os);
2c6b19
diff --git a/service/realm-options.c b/service/realm-options.c
2c6b19
index b9f59c6..bd804ea 100644
2c6b19
--- a/service/realm-options.c
2c6b19
+++ b/service/realm-options.c
2c6b19
@@ -180,3 +180,21 @@ realm_options_computer_name (GVariant *options,
2c6b19
 
2c6b19
 	return g_strdup (computer_name);
2c6b19
 }
2c6b19
+
2c6b19
+const gchar *
2c6b19
+realm_options_ad_specific (GVariant *options,
2c6b19
+                           const gchar *option_name)
2c6b19
+{
2c6b19
+	const gchar *value = NULL;
2c6b19
+
2c6b19
+	if (options) {
2c6b19
+		if (!g_variant_lookup (options, option_name, "&s", &value))
2c6b19
+			value = NULL;
2c6b19
+	}
2c6b19
+
2c6b19
+	if (!value) {
2c6b19
+		value = realm_settings_value ("active-directory", option_name);
2c6b19
+	}
2c6b19
+
2c6b19
+	return g_strdup (value);
2c6b19
+}
2c6b19
diff --git a/service/realm-options.h b/service/realm-options.h
2c6b19
index e31cddc..7a1355e 100644
2c6b19
--- a/service/realm-options.h
2c6b19
+++ b/service/realm-options.h
2c6b19
@@ -44,6 +44,9 @@ gboolean       realm_options_check_domain_name        (const gchar *domain_name)
2c6b19
 const gchar *  realm_options_computer_name           (GVariant *options,
2c6b19
                                                        const gchar *realm_name);
2c6b19
 
2c6b19
+const gchar *  realm_options_ad_specific              (GVariant *options,
2c6b19
+                                                       const gchar *option_name);
2c6b19
+
2c6b19
 G_END_DECLS
2c6b19
 
2c6b19
 #endif /* __REALM_OPTIONS_H__ */
2c6b19
diff --git a/service/realm-samba-enroll.c b/service/realm-samba-enroll.c
2c6b19
index f2392a9..c81aed2 100644
2c6b19
--- a/service/realm-samba-enroll.c
2c6b19
+++ b/service/realm-samba-enroll.c
2c6b19
@@ -335,11 +335,11 @@ begin_join (GTask *task,
2c6b19
 		}
2c6b19
 	}
2c6b19
 
2c6b19
-	os = realm_settings_value ("active-directory", "os-name");
2c6b19
+	os = realm_options_ad_specific(options, "os-name");
2c6b19
 	if (os != NULL && !g_str_equal (os, ""))
2c6b19
 		join->join_args[at++] = g_strdup_printf ("osName=%s", os);
2c6b19
 
2c6b19
-	os = realm_settings_value ("active-directory", "os-version");
2c6b19
+	os = realm_options_ad_specific(options, "os-version");
2c6b19
 	if (os != NULL && !g_str_equal (os, ""))
2c6b19
 		join->join_args[at++] = g_strdup_printf ("osVer=%s", os);
2c6b19
 
2c6b19
diff --git a/tools/realm-join.c b/tools/realm-join.c
2c6b19
index 3685bb9..8e46c20 100644
2c6b19
--- a/tools/realm-join.c
2c6b19
+++ b/tools/realm-join.c
2c6b19
@@ -169,6 +169,8 @@ typedef struct {
2c6b19
 	gchar *user;
2c6b19
 	gchar *computer_ou;
2c6b19
 	gchar *computer_name;
2c6b19
+	gchar *os_name;
2c6b19
+	gchar *os_version;
2c6b19
 	gchar *client_software;
2c6b19
 	gchar *server_software;
2c6b19
 	gchar *membership_software;
2c6b19
@@ -241,6 +243,8 @@ perform_join (RealmClient *client,
2c6b19
 
2c6b19
 	options = realm_build_options (REALM_DBUS_OPTION_COMPUTER_OU, args->computer_ou,
2c6b19
 	                               REALM_DBUS_OPTION_COMPUTER_NAME, args->computer_name,
2c6b19
+	                               REALM_DBUS_OPTION_OS_NAME, args->os_name,
2c6b19
+	                               REALM_DBUS_OPTION_OS_VERSION, args->os_version,
2c6b19
 	                               REALM_DBUS_OPTION_MEMBERSHIP_SOFTWARE, args->membership_software,
2c6b19
 	                               REALM_DBUS_OPTION_USER_PRINCIPAL, args->user_principal,
2c6b19
 	                               args->automatic_id_mapping_set ?
2c6b19
@@ -288,6 +292,10 @@ realm_join (RealmClient *client,
2c6b19
 		  N_("Computer OU DN to join"), NULL },
2c6b19
 		{ "computer-name", 0, 0, G_OPTION_ARG_STRING, &args.computer_name,
2c6b19
 			N_("Use specific computer name instead of hostname"), NULL },
2c6b19
+		{ "os-name", 0, 0, G_OPTION_ARG_STRING, &args.os_name,
2c6b19
+			N_("Use specific operation system name"), NULL },
2c6b19
+		{ "os-version", 0, 0, G_OPTION_ARG_STRING, &args.os_version,
2c6b19
+			N_("Use specific operation system version"), NULL },
2c6b19
 		{ "client-software", 0, 0, G_OPTION_ARG_STRING, &args.client_software,
2c6b19
 		  N_("Use specific client software"), NULL },
2c6b19
 		{ "server-software", 0, 0, G_OPTION_ARG_STRING, &args.server_software,
2c6b19
-- 
2c6b19
2.7.4
2c6b19