From: Noel Power Date: Fri, 9 Feb 2018 14:03:33 +0000 (+0000) Subject: s3:utils: Modify default behaviour of 'net ads keytab add' X-Git-Tag: talloc-2.1.12~289 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=5adb29f242dde67865017ec8d45852a1fa290ebf;p=thirdparty%2Fsamba.git s3:utils: Modify default behaviour of 'net ads keytab add' 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 Reviewed-by: Jeremy Allison Reviewed-by: Andreas Schneider --- diff --git a/source3/utils/net_ads.c b/source3/utils/net_ads.c index 352044ed068..7ee00773d83 100644 --- a/source3/utils/net_ads.c +++ b/source3/utils/net_ads.c @@ -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",