ads_struct
authorStefan Metzmacher <metze@samba.org>
Tue, 6 Dec 2016 14:59:12 +0000 (15:59 +0100)
committerStefan Metzmacher <metze@samba.org>
Mon, 18 Feb 2019 12:47:20 +0000 (13:47 +0100)
12 files changed:
libgpo/gpo_fetch.c
source3/include/ads.h
source3/lib/netapi/joindomain.c
source3/libads/ads_struct.c
source3/libads/kerberos_util.c
source3/libads/ldap.c
source3/libads/ndr.c
source3/libads/sasl.c
source3/libnet/libnet_join.c
source3/printing/nt_printing_ads.c
source3/utils/net_ads.c
source3/winbindd/winbindd_ads.c

index 3740d4e4b577a249521a0f42e8007631e4de5052..08a7b2ac7d7608beac693da366ace7580fbb8739 100644 (file)
@@ -129,8 +129,8 @@ static NTSTATUS gpo_connect_server(ADS_STRUCT *ads,
                        server,
                        NULL, 0,
                        service, "A:",
-                       ads->auth.user_name, NULL,
-                       ads->auth.password,
+                       ads->auth._user_name, NULL,
+                       ads->auth._password,
                        CLI_FULL_CONNECTION_USE_KERBEROS |
                        CLI_FULL_CONNECTION_FALLBACK_AFTER_KERBEROS,
                        SMB_SIGNING_REQUIRED);
index ebc5728f3a4fccbe769271f55f7dff44a1dc2f86..3f387d17b319318f93a87bfe1475a2785b213142 100644 (file)
@@ -69,16 +69,16 @@ typedef struct ads_struct {
 
        /* info needed to authenticate */
        struct {
-               char *realm;
-               char *password;
-               char *user_name;
+               char *_realm;
+               char *_password;
+               char *_user_name;
                char *kdc_server;
                unsigned flags;
                int time_offset;
-               char *ccache_name;
+               char *_ccache_name;
                time_t tgt_expire;
                time_t tgs_expire;
-               time_t renewable;
+               time_t _renewable;
        } auth;
 
        /* info derived from the servers config */
index ff2154ba803ec20e3085d9780c738a9e04b748b6..af5dfb8e7a1ab23caa9e48ca816bafa9c7382c16 100644 (file)
@@ -416,18 +416,18 @@ WERROR NetGetJoinableOUs_l(struct libnetapi_ctx *ctx,
                return WERR_GEN_FAILURE;
        }
 
-       SAFE_FREE(ads->auth.user_name);
+       SAFE_FREE(ads->auth._user_name);
        if (r->in.account) {
-               ads->auth.user_name = SMB_STRDUP(r->in.account);
+               ads->auth._user_name = SMB_STRDUP(r->in.account);
        } else if (ctx->username) {
-               ads->auth.user_name = SMB_STRDUP(ctx->username);
+               ads->auth._user_name = SMB_STRDUP(ctx->username);
        }
 
-       SAFE_FREE(ads->auth.password);
+       SAFE_FREE(ads->auth._password);
        if (r->in.password) {
-               ads->auth.password = SMB_STRDUP(r->in.password);
+               ads->auth._password = SMB_STRDUP(r->in.password);
        } else if (ctx->password) {
-               ads->auth.password = SMB_STRDUP(ctx->password);
+               ads->auth._password = SMB_STRDUP(ctx->password);
        }
 
        ads_status = ads_connect_user_creds(ads);
index 3ab682c0e3883459bd27f309105af7fc876d39a0..1c269fbc69fe8fdf72ffd400766c3b4667b6f788 100644 (file)
@@ -191,11 +191,11 @@ void ads_destroy(ADS_STRUCT **ads)
                SAFE_FREE((*ads)->server.workgroup);
                SAFE_FREE((*ads)->server.ldap_server);
 
-               SAFE_FREE((*ads)->auth.realm);
-               SAFE_FREE((*ads)->auth.password);
-               SAFE_FREE((*ads)->auth.user_name);
+               SAFE_FREE((*ads)->auth._realm);
+               SAFE_FREE((*ads)->auth._password);
+               SAFE_FREE((*ads)->auth._user_name);
                SAFE_FREE((*ads)->auth.kdc_server);
-               SAFE_FREE((*ads)->auth.ccache_name);
+               SAFE_FREE((*ads)->auth._ccache_name);
 
                SAFE_FREE((*ads)->config.realm);
                SAFE_FREE((*ads)->config.bind_path);
index 68c0f302239b61b0ace96de836478e541bc212c2..2bbb837c52b1cdc62159c2596106b4cc1eb65e39 100644 (file)
@@ -33,12 +33,12 @@ int ads_kinit_password(ADS_STRUCT *ads)
        const char *account_name;
        fstring acct_name;
 
-       if (ads->auth.password == NULL || ads->auth.password[0] == '\0') {
+       if (ads->auth._password == NULL || ads->auth._password[0] == '\0') {
                return KRB5_LIBOS_CANTREADPWD;
        }
 
        if (ads->auth.flags & ADS_AUTH_USER_CREDS) {
-               account_name = ads->auth.user_name;
+               account_name = ads->auth._user_name;
                goto got_accountname;
        }
 
@@ -54,19 +54,19 @@ int ads_kinit_password(ADS_STRUCT *ads)
                }
                else
                        /* This looks like host/lp_netbios_name()@REA.LM */
-                       account_name = ads->auth.user_name;
+                       account_name = ads->auth._user_name;
        }
 
  got_accountname:
-       if (asprintf(&s, "%s@%s", account_name, ads->auth.realm) == -1) {
+       if (asprintf(&s, "%s@%s", account_name, ads->auth._realm) == -1) {
                return KRB5_CC_NOMEM;
        }
 
-       ret = kerberos_kinit_password_ext(s, ads->auth.password,
+       ret = kerberos_kinit_password_ext(s, ads->auth._password,
                                          ads->auth.time_offset,
                                          &ads->auth.tgt_expire, NULL,
-                                         ads->auth.ccache_name, false, false,
-                                         ads->auth.renewable, NULL);
+                                         ads->auth._ccache_name, false, false,
+                                         ads->auth._renewable, NULL);
 
        if (ret) {
                DEBUG(0,("kerberos_kinit_password %s failed: %s\n",
index 6b5f271272acbdb94ee5c31cfd2b326a142dc07e..a2632355d65e15a9966de1a2108eba2e426b6748 100644 (file)
@@ -635,18 +635,18 @@ got_connection:
        print_sockaddr(addr, sizeof(addr), &ads->ldap.ss);
        DEBUG(3,("Successfully contacted LDAP server %s\n", addr));
 
-       if (!ads->auth.user_name) {
+       if (!ads->auth._user_name) {
                /* Must use the userPrincipalName value here or sAMAccountName
                   and not servicePrincipalName; found by Guenther Deschner */
 
-               if (asprintf(&ads->auth.user_name, "%s$", lp_netbios_name() ) == -1) {
+               if (asprintf(&ads->auth._user_name, "%s$", lp_netbios_name() ) == -1) {
                        DEBUG(0,("ads_connect: asprintf fail.\n"));
-                       ads->auth.user_name = NULL;
+                       ads->auth._user_name = NULL;
                }
        }
 
-       if (!ads->auth.realm) {
-               ads->auth.realm = SMB_STRDUP(ads->config.realm);
+       if (!ads->auth._realm) {
+               ads->auth._realm = SMB_STRDUP(ads->config.realm);
        }
 
        if (!ads->auth.kdc_server) {
@@ -708,7 +708,7 @@ got_connection:
        }
 
        if (ads->auth.flags & ADS_AUTH_SIMPLE_BIND) {
-               status = ADS_ERROR(ldap_simple_bind_s(ads->ldap.ld, ads->auth.user_name, ads->auth.password));
+               status = ADS_ERROR(ldap_simple_bind_s(ads->ldap.ld, ads->auth._user_name, ads->auth._password));
                goto out;
        }
 
index 1b586c342821e20c65f6d23bfe9f41e84113eae6..12fcff06de931695b01035cb5ddc53f20af120e2 100644 (file)
@@ -54,19 +54,19 @@ void ndr_print_ads_struct(struct ndr_print *ndr, const char *name, const struct
        ndr->depth--;
        ndr_print_struct(ndr, name, "auth");
        ndr->depth++;
-       ndr_print_string(ndr, "realm", r->auth.realm);
+       ndr_print_string(ndr, "realm", r->auth._realm);
 #ifdef DEBUG_PASSWORD
-       ndr_print_string(ndr, "password", r->auth.password);
+       ndr_print_string(ndr, "password", r->auth._password);
 #else
        ndr_print_string(ndr, "password", "(PASSWORD omitted)");
 #endif
-       ndr_print_string(ndr, "user_name", r->auth.user_name);
+       ndr_print_string(ndr, "user_name", r->auth._user_name);
        ndr_print_string(ndr, "kdc_server", r->auth.kdc_server);
        ndr_print_ads_auth_flags(ndr, "flags", r->auth.flags);
        ndr_print_uint32(ndr, "time_offset", r->auth.time_offset);
        ndr_print_time_t(ndr, "tgt_expire", r->auth.tgt_expire);
        ndr_print_time_t(ndr, "tgs_expire", r->auth.tgs_expire);
-       ndr_print_time_t(ndr, "renewable", r->auth.renewable);
+       ndr_print_time_t(ndr, "renewable", r->auth._renewable);
        ndr->depth--;
        ndr_print_struct(ndr, name, "config");
        ndr->depth++;
index 841f24c6487106e4de33620309c8ec3d86a89a6f..92ae5eaa71834bddc4f5057e922fefdc29fba321 100644 (file)
@@ -610,10 +610,10 @@ static ADS_STATUS ads_sasl_spnego_bind(ADS_STRUCT *ads)
        }
 
        creds = ads_sasl_creds_init(frame,
-                                   ads->auth.user_name,
-                                   ads->auth.password,
-                                   ads->auth.realm,
-                                   ads->auth.realm,
+                                   ads->auth._user_name,
+                                   ads->auth._password,
+                                   ads->auth._realm,
+                                   ads->auth._realm,
                                    krb5_state);
        if (creds == NULL) {
                status = ADS_ERROR_SYSTEM(ENOMEM);
@@ -656,10 +656,10 @@ static ADS_STATUS ads_sasl_gssapi_bind(ADS_STRUCT *ads)
        }
 
        creds = ads_sasl_creds_init(frame,
-                                   ads->auth.user_name,
-                                   ads->auth.password,
-                                   ads->auth.realm,
-                                   ads->auth.realm,
+                                   ads->auth._user_name,
+                                   ads->auth._password,
+                                   ads->auth._realm,
+                                   ads->auth._realm,
                                    CRED_MUST_USE_KERBEROS);
        if (creds == NULL) {
                status = ADS_ERROR_SYSTEM(ENOMEM);
index 27fc5135442cf47bb36ad7e64bc8e24cc3b6acf9..c3918a1d8e09297f8bfc97732f6193b4deaf8712 100644 (file)
@@ -146,13 +146,13 @@ static ADS_STATUS libnet_connect_ads(const char *dns_domain_name,
        }
 
        if (user_name) {
-               SAFE_FREE(my_ads->auth.user_name);
-               my_ads->auth.user_name = SMB_STRDUP(user_name);
-               if ((cp = strchr_m(my_ads->auth.user_name, '@'))!=0) {
+               SAFE_FREE(my_ads->auth._user_name);
+               my_ads->auth._user_name = SMB_STRDUP(user_name);
+               if ((cp = strchr_m(my_ads->auth._user_name, '@'))!=0) {
                        *cp++ = '\0';
-                       SAFE_FREE(my_ads->auth.realm);
-                       my_ads->auth.realm = smb_xstrdup(cp);
-                       if (!strupper_m(my_ads->auth.realm)) {
+                       SAFE_FREE(my_ads->auth._realm);
+                       my_ads->auth._realm = smb_xstrdup(cp);
+                       if (!strupper_m(my_ads->auth._realm)) {
                                ads_destroy(&my_ads);
                                return ADS_ERROR_LDAP(LDAP_NO_MEMORY);
                        }
@@ -160,14 +160,14 @@ static ADS_STATUS libnet_connect_ads(const char *dns_domain_name,
        }
 
        if (password) {
-               SAFE_FREE(my_ads->auth.password);
-               my_ads->auth.password = SMB_STRDUP(password);
+               SAFE_FREE(my_ads->auth._password);
+               my_ads->auth._password = SMB_STRDUP(password);
        }
 
        if (ccname != NULL) {
-               SAFE_FREE(my_ads->auth.ccache_name);
-               my_ads->auth.ccache_name = SMB_STRDUP(ccname);
-               setenv(KRB5_ENV_CCNAME, my_ads->auth.ccache_name, 1);
+               SAFE_FREE(my_ads->auth._ccache_name);
+               my_ads->auth._ccache_name = SMB_STRDUP(ccname);
+               setenv(KRB5_ENV_CCNAME, my_ads->auth._ccache_name, 1);
        }
 
        status = ads_connect_user_creds(my_ads);
@@ -939,8 +939,8 @@ static ADS_STATUS libnet_join_post_processing_ads_modify(TALLOC_CTX *mem_ctx,
                 * to update msDS-SupportedEncryptionTypes reliable
                 */
 
-               if (r->in.ads->auth.ccache_name != NULL) {
-                       ads_kdestroy(r->in.ads->auth.ccache_name);
+               if (r->in.ads->auth._ccache_name != NULL) {
+                       ads_kdestroy(r->in.ads->auth._ccache_name);
                }
 
                ads_destroy(&r->in.ads);
index 2588e1de7e778e0be0926dd165cbf03315490b1d..2ed529037ee607217915b51047c47860124bff10 100644 (file)
@@ -235,8 +235,8 @@ WERROR nt_printer_guid_retrieve(TALLOC_CTX *mem_ctx, const char *printer,
 
        old_krb5ccname = getenv(KRB5_ENV_CCNAME);
        setenv(KRB5_ENV_CCNAME, "MEMORY:prtpub_cache", 1);
-       SAFE_FREE(ads->auth.password);
-       ads->auth.password = secrets_fetch_machine_password(lp_workgroup(),
+       SAFE_FREE(ads->auth._password);
+       ads->auth._password = secrets_fetch_machine_password(lp_workgroup(),
                                                            NULL, NULL);
 
        ads_status = ads_connect(ads);
@@ -585,8 +585,8 @@ WERROR nt_printer_publish(TALLOC_CTX *mem_ctx,
        }
        old_krb5ccname = getenv(KRB5_ENV_CCNAME);
        setenv(KRB5_ENV_CCNAME, "MEMORY:prtpub_cache", 1);
-       SAFE_FREE(ads->auth.password);
-       ads->auth.password = secrets_fetch_machine_password(lp_workgroup(),
+       SAFE_FREE(ads->auth._password);
+       ads->auth._password = secrets_fetch_machine_password(lp_workgroup(),
                NULL, NULL);
 
        /* ads_connect() will find the DC for us */
@@ -640,8 +640,8 @@ WERROR check_published_printers(struct messaging_context *msg_ctx)
        }
        old_krb5ccname = getenv(KRB5_ENV_CCNAME);
        setenv(KRB5_ENV_CCNAME, "MEMORY:prtpub_cache", 1);
-       SAFE_FREE(ads->auth.password);
-       ads->auth.password = secrets_fetch_machine_password(lp_workgroup(),
+       SAFE_FREE(ads->auth._password);
+       ads->auth._password = secrets_fetch_machine_password(lp_workgroup(),
                NULL, NULL);
 
        /* ads_connect() will find the DC for us */
index 1f055507ad723950b47b035304cecac115997dc6..56a1c1a6f38e8778b1aeeb3276bdb0478f174795 100644 (file)
@@ -641,24 +641,24 @@ retry:
 
        if (c->opt_password) {
                use_in_memory_ccache();
-               SAFE_FREE(ads->auth.password);
-               ads->auth.password = smb_xstrdup(c->opt_password);
+               SAFE_FREE(ads->auth._password);
+               ads->auth._password = smb_xstrdup(c->opt_password);
        }
 
        ads->auth.flags |= auth_flags;
-       SAFE_FREE(ads->auth.user_name);
-       ads->auth.user_name = smb_xstrdup(c->opt_user_name);
+       SAFE_FREE(ads->auth._user_name);
+       ads->auth._user_name = smb_xstrdup(c->opt_user_name);
 
        /*
         * If the username is of the form "name@realm",
         * extract the realm and convert to upper case.
         * This is only used to establish the connection.
         */
-       if ((cp = strchr_m(ads->auth.user_name, '@'))!=0) {
+       if ((cp = strchr_m(ads->auth._user_name, '@'))!=0) {
                *cp++ = '\0';
-               SAFE_FREE(ads->auth.realm);
-               ads->auth.realm = smb_xstrdup(cp);
-               if (!strupper_m(ads->auth.realm)) {
+               SAFE_FREE(ads->auth._realm);
+               ads->auth._realm = smb_xstrdup(cp);
+               if (!strupper_m(ads->auth._realm)) {
                        ads_destroy(&ads);
                        return ADS_ERROR(LDAP_NO_MEMORY);
                }
@@ -1773,27 +1773,27 @@ static void _net_ads_join_dns_updates(struct net_context *c, TALLOC_CTX *ctx, st
 
        use_in_memory_ccache();
 
-       ret = asprintf(&ads_dns->auth.user_name, "%s$", lp_netbios_name());
+       ret = asprintf(&ads_dns->auth._user_name, "%s$", lp_netbios_name());
        if (ret == -1) {
                d_fprintf(stderr, _("DNS update failed: out of memory\n"));
                goto done;
        }
 
-       ads_dns->auth.password = secrets_fetch_machine_password(
+       ads_dns->auth._password = secrets_fetch_machine_password(
                r->out.netbios_domain_name, NULL, NULL);
-       if (ads_dns->auth.password == NULL) {
+       if (ads_dns->auth._password == NULL) {
                d_fprintf(stderr, _("DNS update failed: out of memory\n"));
                goto done;
        }
 
-       ads_dns->auth.realm = SMB_STRDUP(r->out.dns_domain_name);
-       if (ads_dns->auth.realm == NULL) {
+       ads_dns->auth._realm = SMB_STRDUP(r->out.dns_domain_name);
+       if (ads_dns->auth._realm == NULL) {
                d_fprintf(stderr, _("DNS update failed: out of memory\n"));
                goto done;
        }
 
-       if (!strupper_m(ads_dns->auth.realm)) {
-               d_fprintf(stderr, _("strupper_m %s failed\n"), ads_dns->auth.realm);
+       if (!strupper_m(ads_dns->auth._realm)) {
+               d_fprintf(stderr, _("strupper_m %s failed\n"), ads_dns->auth._realm);
                goto done;
        }
 
index 4076f8227cbf1c04a50f14534510eda8575b9188..04f8c9d8f5254ce30ee384a5bd6fbe0d6e504b75 100644 (file)
@@ -116,16 +116,16 @@ static ADS_STATUS ads_cached_connection_connect(ADS_STRUCT **adsp,
                return ADS_ERROR(LDAP_NO_MEMORY);
        }
 
-       SAFE_FREE(ads->auth.password);
-       SAFE_FREE(ads->auth.realm);
+       SAFE_FREE(ads->auth._password);
+       SAFE_FREE(ads->auth._realm);
 
-       ads->auth.renewable = renewable;
-       ads->auth.password = password;
+       ads->auth._renewable = renewable;
+       ads->auth._password = password;
 
        ads->auth.flags |= ADS_AUTH_ALLOW_NTLMSSP;
 
-       ads->auth.realm = SMB_STRDUP(auth_realm);
-       if (!strupper_m(ads->auth.realm)) {
+       ads->auth._realm = SMB_STRDUP(auth_realm);
+       if (!strupper_m(ads->auth._realm)) {
                ads_destroy(&ads);
                return ADS_ERROR_NT(NT_STATUS_INTERNAL_ERROR);
        }