From 35b765b8cb6c7d2cd5bacc220a2ffc1a346f558d Mon Sep 17 00:00:00 2001 From: Stef Walter Date: Thu, 11 Apr 2013 16:17:34 +0200 Subject: [PATCH] Add support for the os-name and os-version config options These are used to set the operatingSystem and operatingSystemVersion attributes of a computer account. https://bugs.freedesktop.org/show_bug.cgi?id=54489 --- dbus/org.freedesktop.realmd.xml | 3 +++ doc/manual/realmd-guide-configuring.xml | 24 ++++++++++++++++++++++++ service/realm-adcli-enroll.c | 13 +++++++++++++ service/realm-samba-enroll.c | 27 +++++++++++++++++++++++---- service/realmd-defaults.conf | 2 ++ 5 files changed, 65 insertions(+), 4 deletions(-) diff --git a/dbus/org.freedesktop.realmd.xml b/dbus/org.freedesktop.realmd.xml index b97b3a3..2615007 100644 --- a/dbus/org.freedesktop.realmd.xml +++ b/dbus/org.freedesktop.realmd.xml @@ -610,6 +610,9 @@ computer-ou: a string containing an LDAP DN for an organizational unit where the computer account should be created + user-principal: a string + containing an kerberos user principal name to be set on the + computer account assume-packages: a boolean which makes the join assume that all needed software packages have already been installed diff --git a/doc/manual/realmd-guide-configuring.xml b/doc/manual/realmd-guide-configuring.xml index e850e35..86ffd13 100644 --- a/doc/manual/realmd-guide-configuring.xml +++ b/doc/manual/realmd-guide-configuring.xml @@ -81,6 +81,30 @@ domain.example.com +
+ os-name + + see below +
+ +
+ os-version + + Specify the and/or + settings to control the values that + are placed in the computer account + attributes. + + + +[active-directory] +os-name = Gentoo Linux +os-version = 9.9.9.9.9 + + + +
+
diff --git a/service/realm-adcli-enroll.c b/service/realm-adcli-enroll.c index 9051058..d6d3c6e 100644 --- a/service/realm-adcli-enroll.c +++ b/service/realm-adcli-enroll.c @@ -82,6 +82,7 @@ realm_adcli_enroll_join_async (const gchar *realm, GSimpleAsyncResult *async; GBytes *input = NULL; GPtrArray *args; + const gchar *os; gchar *arg; g_return_if_fail (cred != NULL); @@ -107,6 +108,18 @@ realm_adcli_enroll_join_async (const gchar *realm, g_ptr_array_add (args, (gpointer)computer_ou); } + os = realm_settings_value ("active-directory", "os-name"); + if (os != NULL && !g_str_equal (os, "")) { + g_ptr_array_add (args, "--os-name"); + g_ptr_array_add (args, (gpointer)os); + } + + os = realm_settings_value ("active-directory", "os-version"); + if (os != NULL && !g_str_equal (os, "")) { + g_ptr_array_add (args, "--os-version"); + g_ptr_array_add (args, (gpointer)os); + } + switch (cred->type) { case REALM_CREDENTIAL_AUTOMATIC: g_ptr_array_add (args, "--login-type"); diff --git a/service/realm-samba-enroll.c b/service/realm-samba-enroll.c index 6b21364..1444f83 100644 --- a/service/realm-samba-enroll.c +++ b/service/realm-samba-enroll.c @@ -38,7 +38,7 @@ typedef struct { GDBusMethodInvocation *invocation; - gchar *create_computer_arg; + gchar *join_args[5]; gchar *realm; gchar *user_name; GBytes *password_input; @@ -51,9 +51,12 @@ static void join_closure_free (gpointer data) { JoinClosure *join = data; + int i; g_bytes_unref (join->password_input); g_free (join->user_name); + for (i = 0; G_N_ELEMENTS (join->join_args); i++) + g_free (join->join_args); g_free (join->realm); g_free (join->envvar); g_clear_object (&join->invocation); @@ -283,14 +286,18 @@ begin_config_and_join (JoinClosure *join, begin_net_process (join, join->password_input, on_join_do_keytab, g_object_ref (async), "-U", join->user_name, "ads", "join", join->realm, - join->create_computer_arg, NULL); + join->join_args[0], join->join_args[1], + join->join_args[2], join->join_args[3], + join->join_args[4], NULL); /* Do join with a ccache */ } else { begin_net_process (join, NULL, on_join_do_keytab, g_object_ref (async), "-k", "ads", "join", join->realm, - join->create_computer_arg, NULL); + join->join_args[0], join->join_args[1], + join->join_args[2], join->join_args[3], + join->join_args[4], NULL); } } @@ -411,13 +418,15 @@ begin_join (GSimpleAsyncResult *async, const gchar *computer_ou; gchar *strange_ou; GError *error = NULL; + const gchar *os; + int at = 0; computer_ou = realm_options_computer_ou (options, realm); if (computer_ou != NULL) { strange_ou = realm_samba_util_build_strange_ou (computer_ou, realm); if (strange_ou) { if (!g_str_equal (strange_ou, "")) - join->create_computer_arg = g_strdup_printf ("createcomputer=%s", strange_ou); + join->join_args[at++] = g_strdup_printf ("createcomputer=%s", strange_ou); g_free (strange_ou); } else { g_set_error (&error, G_DBUS_ERROR, G_DBUS_ERROR_INVALID_ARGS, @@ -425,6 +434,16 @@ begin_join (GSimpleAsyncResult *async, } } + os = realm_settings_value ("active-directory", "os-name"); + if (os != NULL && !g_str_equal (os, "")) + join->join_args[at++] = g_strdup_printf ("osName=%s", os); + + os = realm_settings_value ("active-directory", "os-version"); + if (os != NULL && !g_str_equal (os, "")) + join->join_args[at++] = g_strdup_printf ("osVer=%s", os); + + g_assert (at < G_N_ELEMENTS (join->join_args)); + if (error != NULL) { g_simple_async_result_take_error (async, error); g_simple_async_result_complete_in_idle (async); diff --git a/service/realmd-defaults.conf b/service/realmd-defaults.conf index e6db1a8..f020bf0 100644 --- a/service/realmd-defaults.conf +++ b/service/realmd-defaults.conf @@ -10,6 +10,8 @@ ipa-client-install = /usr/sbin/ipa-client-install [active-directory] default-client = sssd +os-name = +os-version = [providers] sssd = yes -- 1.8.1.4