The branch, master has been updated
       via  edda534 s4-auth/kerberos: fix salting principal, make sure hostname 
is lowercase.
       via  f64e76d s3-libnet: set list of allowed krb5 encryption types in AD 
>= 2008.
       via  215b9f5 s3-net: add manpage documentation for "net ads enctypes".
       via  f872875 s3-net: add "net ads enctypes {list,set,delete}".
      from  0b08db4 Add some plumbing in our top level Makefile to make life 
easier

http://gitweb.samba.org/?p=samba.git;a=shortlog;h=master


- Log -----------------------------------------------------------------
commit edda534454b1c5a6d30f1b99baf502d3990f99dd
Author: Günther Deschner <[email protected]>
Date:   Fri Sep 26 21:06:38 2014 +0200

    s4-auth/kerberos: fix salting principal, make sure hostname is lowercase.
    
    Found at MS interop event while working on AES kerberos key support.
    
    Guenther
    
    Signed-off-by: Günther Deschner <[email protected]>
    Reviewed-by: Andrew Bartlett <[email protected]>
    
    Autobuild-User(master): Günther Deschner <[email protected]>
    Autobuild-Date(master): Fri Sep 26 23:37:09 CEST 2014 on sn-devel-104

commit f64e76dad4dbd10e07a7950ac81deeaf7332c26a
Author: Günther Deschner <[email protected]>
Date:   Fri Nov 23 12:34:27 2012 +0100

    s3-libnet: set list of allowed krb5 encryption types in AD >= 2008.
    
    Guenther
    
    Signed-off-by: Günther Deschner <[email protected]>
    Reviewed-by: Andreas Schneider <[email protected]>
    Reviewed-by: Stefan Metzmacher <[email protected]>

commit 215b9f5726db3c0e453b0da1d953ac694fce4b4f
Author: Günther Deschner <[email protected]>
Date:   Wed Sep 24 23:36:19 2014 +0200

    s3-net: add manpage documentation for "net ads enctypes".
    
    Guenther
    
    Signed-off-by: Günther Deschner <[email protected]>
    Reviewed-by: Andreas Schneider <[email protected]>
    Reviewed-by: Stefan Metzmacher <[email protected]>

commit f872875f30215c7e6ab5c79bbfb466326bd091c9
Author: Günther Deschner <[email protected]>
Date:   Wed Sep 24 22:16:20 2014 +0200

    s3-net: add "net ads enctypes {list,set,delete}".
    
    Guenther
    
    Signed-off-by: Günther Deschner <[email protected]>
    Reviewed-by: Andreas Schneider <[email protected]>
    Reviewed-by: Stefan Metzmacher <[email protected]>

-----------------------------------------------------------------------

Summary of changes:
 docs-xml/manpages/net.8.xml        |   53 ++++++
 source3/libnet/libnet_join.c       |   65 ++++++++
 source3/utils/net_ads.c            |  308 ++++++++++++++++++++++++++++++++++++
 source4/auth/kerberos/srv_keytab.c |    2 +-
 4 files changed, 427 insertions(+), 1 deletions(-)


Changeset truncated at 500 lines:

diff --git a/docs-xml/manpages/net.8.xml b/docs-xml/manpages/net.8.xml
index f39b420..9e982e3 100644
--- a/docs-xml/manpages/net.8.xml
+++ b/docs-xml/manpages/net.8.xml
@@ -1339,6 +1339,59 @@ to show in the result.
 </refsect2>
 
 <refsect2>
+       <title>ADS ENCTYPES</title>
+
+<para>
+       List, modify or delete the value of the "msDS-SupportedEncryptionTypes" 
attribute of an account in AD.
+</para>
+
+<para>
+       This attribute allows to control which Kerberos encryption types are 
used for the generation of initial and service tickets. The value consists of 
an integer bitmask with the following values:
+</para>
+
+<para>0x00000001 DES-CBC-CRC</para>
+<para>0x00000002 DES-CBC-MD5</para>
+<para>0x00000004 RC4-HMAC</para>
+<para>0x00000008 AES128-CTS-HMAC-SHA1-96</para>
+<para>0x00000010 AES256-CTS-HMAC-SHA1-96</para>
+
+</refsect2>
+
+<refsect2>
+       <title>ADS ENCTYPES LIST 
<replaceable>&lt;ACCOUNTNAME&gt;</replaceable></title>
+
+<para>
+       List the value of the "msDS-SupportedEncryptionTypes" attribute of a 
given account.
+</para>
+
+<para>Example: <userinput>net ads enctypes list Computername</userinput></para>
+
+</refsect2>
+
+<refsect2>
+       <title>ADS ENCTYPES SET <replaceable>&lt;ACCOUNTNAME&gt;</replaceable> 
<replaceable>[enctypes]</replaceable></title>
+
+<para>
+       Set the value of the "msDS-SupportedEncryptionTypes" attribute of the 
LDAP object of ACCOUNTNAME to a given value. If the value is ommitted, the 
value is set to 31 which enables all the currently supported encryption types.
+</para>
+
+<para>Example: <userinput>net ads enctypes set Computername 
24</userinput></para>
+
+</refsect2>
+
+<refsect2>
+       <title>ADS ENCTYPES DELETE 
<replaceable>&lt;ACCOUNTNAME&gt;</replaceable></title>
+
+<para>
+       Deletes the "msDS-SupportedEncryptionTypes" attribute of the LDAP 
object of ACCOUNTNAME.
+</para>
+
+<para>Example: <userinput>net ads enctypes set Computername 
24</userinput></para>
+
+</refsect2>
+
+
+<refsect2>
 <title>SAM CREATEBUILTINGROUP &lt;NAME&gt;</title>
 
 <para>
diff --git a/source3/libnet/libnet_join.c b/source3/libnet/libnet_join.c
index 381a59c..e70e11a 100644
--- a/source3/libnet/libnet_join.c
+++ b/source3/libnet/libnet_join.c
@@ -605,6 +605,52 @@ static ADS_STATUS libnet_join_set_os_attributes(TALLOC_CTX 
*mem_ctx,
 /****************************************************************
 ****************************************************************/
 
+static ADS_STATUS libnet_join_set_etypes(TALLOC_CTX *mem_ctx,
+                                        struct libnet_JoinCtx *r)
+{
+       ADS_STATUS status;
+       ADS_MODLIST mods;
+       uint32_t etype_list = ENC_CRC32 | ENC_RSA_MD5 | ENC_RC4_HMAC_MD5;
+       const char *etype_list_str;
+
+#ifdef HAVE_ENCTYPE_AES128_CTS_HMAC_SHA1_96
+       etype_list |= ENC_HMAC_SHA1_96_AES128;
+#endif
+#ifdef HAVE_ENCTYPE_AES256_CTS_HMAC_SHA1_96
+       etype_list |= ENC_HMAC_SHA1_96_AES256;
+#endif
+
+       etype_list_str = talloc_asprintf(mem_ctx, "%d", etype_list);
+       if (!etype_list_str) {
+               return ADS_ERROR(LDAP_NO_MEMORY);
+       }
+
+       /* Find our DN */
+
+       status = libnet_join_find_machine_acct(mem_ctx, r);
+       if (!ADS_ERR_OK(status)) {
+               return status;
+       }
+
+       /* now do the mods */
+
+       mods = ads_init_mods(mem_ctx);
+       if (!mods) {
+               return ADS_ERROR(LDAP_NO_MEMORY);
+       }
+
+       status = ads_mod_str(mem_ctx, &mods, "msDS-SupportedEncryptionTypes",
+                            etype_list_str);
+       if (!ADS_ERR_OK(status)) {
+               return status;
+       }
+
+       return ads_gen_mod(r->in.ads, r->out.dn, mods);
+}
+
+/****************************************************************
+****************************************************************/
+
 static bool libnet_join_create_keytab(TALLOC_CTX *mem_ctx,
                                      struct libnet_JoinCtx *r)
 {
@@ -679,6 +725,7 @@ static ADS_STATUS 
libnet_join_post_processing_ads(TALLOC_CTX *mem_ctx,
                                                  struct libnet_JoinCtx *r)
 {
        ADS_STATUS status;
+       uint32_t func_level = 0;
 
        if (!r->in.ads) {
                status = libnet_join_connect_ads(mem_ctx, r);
@@ -713,6 +760,24 @@ static ADS_STATUS 
libnet_join_post_processing_ads(TALLOC_CTX *mem_ctx,
                return status;
        }
 
+       status = ads_domain_func_level(r->in.ads, &func_level);
+       if (!ADS_ERR_OK(status)) {
+               libnet_join_set_error_string(mem_ctx, r,
+                       "failed to query domain controller functional level: 
%s",
+                       ads_errstr(status));
+               return status;
+       }
+
+       if (func_level >= DS_DOMAIN_FUNCTION_2008) {
+               status = libnet_join_set_etypes(mem_ctx, r);
+               if (!ADS_ERR_OK(status)) {
+                       libnet_join_set_error_string(mem_ctx, r,
+                               "failed to set machine kerberos encryption 
types: %s",
+                               ads_errstr(status));
+                       return status;
+               }
+       }
+
        if (!libnet_join_derive_salting_principal(mem_ctx, r)) {
                return ADS_ERROR_NT(NT_STATUS_UNSUCCESSFUL);
        }
diff --git a/source3/utils/net_ads.c b/source3/utils/net_ads.c
index 8b8e719..5f18bf4 100644
--- a/source3/utils/net_ads.c
+++ b/source3/utils/net_ads.c
@@ -2860,6 +2860,306 @@ int net_ads_kerberos(struct net_context *c, int argc, 
const char **argv)
        return net_run_function(c, argc, argv, "net ads kerberos", func);
 }
 
+static int net_ads_enctype_lookup_account(struct net_context *c,
+                                         ADS_STRUCT *ads,
+                                         const char *account,
+                                         LDAPMessage **res,
+                                         const char **enctype_str)
+{
+       const char *filter;
+       const char *attrs[] = {
+               "msDS-SupportedEncryptionTypes",
+               NULL
+       };
+       int count;
+       int ret = -1;
+       ADS_STATUS status;
+
+       filter = talloc_asprintf(c, "(&(objectclass=user)(sAMAccountName=%s))",
+                                account);
+       if (filter == NULL) {
+               goto done;
+       }
+
+       status = ads_search(ads, res, filter, attrs);
+       if (!ADS_ERR_OK(status)) {
+               d_printf(_("no account found with filter: %s\n"), filter);
+               goto done;
+       }
+
+       count = ads_count_replies(ads, *res);
+       switch (count) {
+       case 1:
+               break;
+       case 0:
+               d_printf(_("no account found with filter: %s\n"), filter);
+               goto done;
+       default:
+               d_printf(_("multiple accounts found with filter: %s\n"), 
filter);
+               goto done;
+       }
+
+       if (enctype_str) {
+               *enctype_str = ads_pull_string(ads, c, *res,
+                                              "msDS-SupportedEncryptionTypes");
+               if (*enctype_str == NULL) {
+                       d_printf(_("no msDS-SupportedEncryptionTypes attribute 
found\n"));
+                       goto done;
+               }
+       }
+
+       ret = 0;
+ done:
+       return ret;
+}
+
+static void net_ads_enctype_dump_enctypes(const char *username,
+                                         const char *enctype_str)
+{
+       int enctypes;
+
+       d_printf(_("'%s' uses \"msDS-SupportedEncryptionTypes\":\n"), username);
+
+       enctypes = atoi(enctype_str);
+
+       printf("[%s] 0x%08x DES-CBC-CRC\n",
+               enctypes & ENC_CRC32 ? "X" : " ",
+               ENC_CRC32);
+       printf("[%s] 0x%08x DES-CBC-MD5\n",
+               enctypes & ENC_RSA_MD5 ? "X" : " ",
+               ENC_RSA_MD5);
+       printf("[%s] 0x%08x RC4-HMAC\n",
+               enctypes & ENC_RC4_HMAC_MD5 ? "X" : " ",
+               ENC_RC4_HMAC_MD5);
+       printf("[%s] 0x%08x AES128-CTS-HMAC-SHA1-96\n",
+               enctypes & ENC_HMAC_SHA1_96_AES128 ? "X" : " ",
+               ENC_HMAC_SHA1_96_AES128);
+       printf("[%s] 0x%08x AES256-CTS-HMAC-SHA1-96\n",
+               enctypes & ENC_HMAC_SHA1_96_AES256 ? "X" : " ",
+               ENC_HMAC_SHA1_96_AES256);
+}
+
+static int net_ads_enctypes_list(struct net_context *c, int argc, const char 
**argv)
+{
+       int ret = -1;
+       ADS_STATUS status;
+       ADS_STRUCT *ads = NULL;
+       LDAPMessage *res = NULL;
+       const char *str = NULL;
+
+       if (c->display_usage || (argc < 1)) {
+               d_printf(  "%s\n"
+                          "net ads enctypes list\n"
+                          "    %s\n",
+                        _("Usage:"),
+                        _("List supported enctypes"));
+               return 0;
+       }
+
+       status = ads_startup(c, false, &ads);
+       if (!ADS_ERR_OK(status)) {
+               printf("startup failed\n");
+               return ret;
+       }
+
+       ret = net_ads_enctype_lookup_account(c, ads, argv[0], &res, &str);
+       if (ret) {
+               goto done;
+       }
+
+       net_ads_enctype_dump_enctypes(argv[0], str);
+
+       ret = 0;
+ done:
+       ads_msgfree(ads, res);
+       ads_destroy(&ads);
+
+       return ret;
+}
+
+static int net_ads_enctypes_set(struct net_context *c, int argc, const char 
**argv)
+{
+       int ret = -1;
+       ADS_STATUS status;
+       ADS_STRUCT *ads;
+       LDAPMessage *res = NULL;
+       const char *etype_list_str;
+       const char *dn;
+       ADS_MODLIST mods;
+       uint32_t etype_list;
+       const char *str;
+
+       if (c->display_usage || argc < 1) {
+               d_printf(  "%s\n"
+                          "net ads enctypes set <sAMAccountName> [enctypes]\n"
+                          "    %s\n",
+                        _("Usage:"),
+                        _("Set supported enctypes"));
+               return 0;
+       }
+
+       status = ads_startup(c, false, &ads);
+       if (!ADS_ERR_OK(status)) {
+               printf("startup failed\n");
+               return ret;
+       }
+
+       ret = net_ads_enctype_lookup_account(c, ads, argv[0], &res, NULL);
+       if (ret) {
+               goto done;
+       }
+
+       dn = ads_get_dn(ads, c, res);
+       if (dn == NULL) {
+               goto done;
+       }
+
+       etype_list = ENC_CRC32 | ENC_RSA_MD5 | ENC_RC4_HMAC_MD5;
+#ifdef HAVE_ENCTYPE_AES128_CTS_HMAC_SHA1_96
+       etype_list |= ENC_HMAC_SHA1_96_AES128;
+#endif
+#ifdef HAVE_ENCTYPE_AES256_CTS_HMAC_SHA1_96
+       etype_list |= ENC_HMAC_SHA1_96_AES256;
+#endif
+
+       if (argv[1] != NULL) {
+               sscanf(argv[1], "%i", &etype_list);
+       }
+
+       etype_list_str = talloc_asprintf(c, "%d", etype_list);
+       if (!etype_list_str) {
+               goto done;
+       }
+
+       mods = ads_init_mods(c);
+       if (!mods) {
+               goto done;
+       }
+
+       status = ads_mod_str(c, &mods, "msDS-SupportedEncryptionTypes",
+                            etype_list_str);
+       if (!ADS_ERR_OK(status)) {
+               goto done;
+       }
+
+       status = ads_gen_mod(ads, dn, mods);
+       if (!ADS_ERR_OK(status)) {
+               d_printf(_("failed to add msDS-SupportedEncryptionTypes: %s\n"),
+                       ads_errstr(status));
+               goto done;
+       }
+
+       ads_msgfree(ads, res);
+
+       ret = net_ads_enctype_lookup_account(c, ads, argv[0], &res, &str);
+       if (ret) {
+               goto done;
+       }
+
+       net_ads_enctype_dump_enctypes(argv[0], str);
+
+       ret = 0;
+ done:
+       ads_msgfree(ads, res);
+       ads_destroy(&ads);
+
+       return ret;
+}
+
+static int net_ads_enctypes_delete(struct net_context *c, int argc, const char 
**argv)
+{
+       int ret = -1;
+       ADS_STATUS status;
+       ADS_STRUCT *ads;
+       LDAPMessage *res = NULL;
+       const char *dn;
+       ADS_MODLIST mods;
+
+       if (c->display_usage || argc < 1) {
+               d_printf(  "%s\n"
+                          "net ads enctypes delete <sAMAccountName>\n"
+                          "    %s\n",
+                        _("Usage:"),
+                        _("Delete supported enctypes"));
+               return 0;
+       }
+
+       status = ads_startup(c, false, &ads);
+       if (!ADS_ERR_OK(status)) {
+               printf("startup failed\n");
+               return ret;
+       }
+
+       ret = net_ads_enctype_lookup_account(c, ads, argv[0], &res, NULL);
+       if (ret) {
+               goto done;
+       }
+
+       dn = ads_get_dn(ads, c, res);
+       if (dn == NULL) {
+               goto done;
+       }
+
+       mods = ads_init_mods(c);
+       if (!mods) {
+               goto done;
+       }
+
+       status = ads_mod_str(c, &mods, "msDS-SupportedEncryptionTypes", NULL);
+       if (!ADS_ERR_OK(status)) {
+               goto done;
+       }
+
+       status = ads_gen_mod(ads, dn, mods);
+       if (!ADS_ERR_OK(status)) {
+               d_printf(_("failed to remove msDS-SupportedEncryptionTypes: 
%s\n"),
+                       ads_errstr(status));
+               goto done;
+       }
+
+       ret = 0;
+
+ done:
+       ads_msgfree(ads, res);
+       ads_destroy(&ads);
+       return ret;
+}
+
+static int net_ads_enctypes(struct net_context *c, int argc, const char **argv)
+{
+       struct functable func[] = {
+               {
+                       "list",
+                       net_ads_enctypes_list,
+                       NET_TRANSPORT_ADS,
+                       N_("List the supported encryption types"),
+                       N_("net ads enctypes list\n"
+                          "    List the supported encryption types")
+               },
+               {
+                       "set",
+                       net_ads_enctypes_set,
+                       NET_TRANSPORT_ADS,
+                       N_("Set the supported encryption types"),
+                       N_("net ads enctypes set\n"
+                          "    Set the supported encryption types")
+               },
+               {
+                       "delete",
+                       net_ads_enctypes_delete,
+                       NET_TRANSPORT_ADS,
+                       N_("Delete the supported encryption types"),
+                       N_("net ads enctypes delete\n"
+                          "    Delete the supported encryption types")
+               },
+
+               {NULL, NULL, 0, NULL, NULL}
+       };
+
+       return net_run_function(c, argc, argv, "net ads enctypes", func);
+}
+
+
 int net_ads(struct net_context *c, int argc, const char **argv)
 {
        struct functable func[] = {
@@ -3015,6 +3315,14 @@ int net_ads(struct net_context *c, int argc, const char 
**argv)
                        N_("net ads kerberos\n"
                           "    Manage kerberos keytab")
                },
+               {
+                       "enctypes",
+                       net_ads_enctypes,
+                       NET_TRANSPORT_ADS,
+                       N_("List/modify supported encryption types"),
+                       N_("net ads enctypes\n"
+                          "    List/modify enctypes")
+               },
                {NULL, NULL, 0, NULL, NULL}
        };
 
diff --git a/source4/auth/kerberos/srv_keytab.c 
b/source4/auth/kerberos/srv_keytab.c
index d81e27d..3baba14 100644
--- a/source4/auth/kerberos/srv_keytab.c
+++ b/source4/auth/kerberos/srv_keytab.c
@@ -143,7 +143,7 @@ static krb5_error_code salt_principal(TALLOC_CTX 
*parent_ctx,
                return ENOMEM;
        }
 
-       machine_username = talloc_strdup(tmp_ctx, samAccountName);
+       machine_username = strlower_talloc(tmp_ctx, samAccountName);
        if (!machine_username) {
                *error_string = "Cannot duplicate samAccountName";
                talloc_free(tmp_ctx);


-- 
Samba Shared Repository

Reply via email to