s3:utils: Modify default behaviour of 'net ads keytab add'
authorNoel Power <noel.power@suse.com>
Fri, 9 Feb 2018 14:03:33 +0000 (14:03 +0000)
committerAndreas Schneider <asn@cryptomilk.org>
Fri, 2 Mar 2018 13:07:15 +0000 (14:07 +0100)
This change modifies the behaviour of 'net ads keytab add' such
that only the keytab file is modified.

A new command 'net ads keytab add_update_ads' has been added that
preserves the legacy behaviour which can update the AD computer
object with Winows SPN(s) as appropriate. Alternatively the new
command 'net ads setspn add' can be used to manually add the
windows SPN(s) that previously would have been added.

Signed-off-by: Noel Power <noel.power@suse.com>
Reviewed-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
source3/utils/net_ads.c

index 352044ed068594c32134d60b2466c93d60705aa8..7ee00773d835625caa61fab23924d1115135cb65 100644 (file)
@@ -2605,7 +2605,10 @@ static int net_ads_keytab_flush(struct net_context *c, int argc, const char **ar
        return ret;
 }
 
-static int net_ads_keytab_add(struct net_context *c, int argc, const char **argv)
+static int net_ads_keytab_add(struct net_context *c,
+                             int argc,
+                             const char **argv,
+                             bool update_ads)
 {
        int i;
        int ret = 0;
@@ -2626,12 +2629,26 @@ static int net_ads_keytab_add(struct net_context *c, int argc, const char **argv
                return -1;
        }
        for (i = 0; i < argc; i++) {
-               ret |= ads_keytab_add_entry(ads, argv[i], false);
+               ret |= ads_keytab_add_entry(ads, argv[i], update_ads);
        }
        ads_destroy(&ads);
        return ret;
 }
 
+static int net_ads_keytab_add_default(struct net_context *c,
+                                     int argc,
+                                     const char **argv)
+{
+       return net_ads_keytab_add(c, argc, argv, false);
+}
+
+static int net_ads_keytab_add_update_ads(struct net_context *c,
+                                        int argc,
+                                        const char **argv)
+{
+       return net_ads_keytab_add(c, argc, argv, true);
+}
+
 static int net_ads_keytab_create(struct net_context *c, int argc, const char **argv)
 {
        ADS_STRUCT *ads;
@@ -2680,11 +2697,19 @@ int net_ads_keytab(struct net_context *c, int argc, const char **argv)
        struct functable func[] = {
                {
                        "add",
-                       net_ads_keytab_add,
+                       net_ads_keytab_add_default,
                        NET_TRANSPORT_ADS,
                        N_("Add a service principal"),
                        N_("net ads keytab add\n"
-                          "    Add a service principal")
+                          "    Add a service principal, updates keytab file only.")
+               },
+               {
+                       "add_update_ads",
+                       net_ads_keytab_add_update_ads,
+                       NET_TRANSPORT_ADS,
+                       N_("Add a service principal"),
+                       N_("net ads keytab add_update_ads\n"
+                          "    Add a service principal, depending on the param passed may update ADS computer object in addition to the keytab file.")
                },
                {
                        "create",