2 Unix SMB/CIFS implementation.
4 Copyright (C) Jelmer Vernooij 2005
5 Copyright (C) Tim Potter 2001
6 Copyright (C) Andrew Bartlett <abartlet@samba.org> 2005
8 This program is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 2 of the License, or
11 (at your option) any later version.
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with this program; if not, write to the Free Software
20 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
24 #include "system/filesys.h"
25 #include "include/secrets.h"
26 #include "lib/ldb/include/ldb.h"
27 #include "librpc/gen_ndr/ndr_samr.h" /* for struct samrPassword */
28 #include "system/kerberos.h"
29 #include "auth/kerberos/kerberos.h"
33 * Create a new credentials structure
34 * @param mem_ctx TALLOC_CTX parent for credentials structure
36 struct cli_credentials *cli_credentials_init(TALLOC_CTX *mem_ctx)
38 struct cli_credentials *cred = talloc(mem_ctx, struct cli_credentials);
43 cred->netlogon_creds = NULL;
44 cred->machine_account_pending = False;
45 cred->workstation_obtained = CRED_UNINITIALISED;
46 cred->username_obtained = CRED_UNINITIALISED;
47 cred->password_obtained = CRED_UNINITIALISED;
48 cred->domain_obtained = CRED_UNINITIALISED;
49 cred->realm_obtained = CRED_UNINITIALISED;
50 cred->ccache_obtained = CRED_UNINITIALISED;
51 cred->principal_obtained = CRED_UNINITIALISED;
56 * Obtain the username for this credentials context.
57 * @param cred credentials context
58 * @retval The username set on this context.
59 * @note Return value will never be NULL except by programmer error.
61 const char *cli_credentials_get_username(struct cli_credentials *cred, TALLOC_CTX *mem_ctx)
63 if (cred->machine_account_pending) {
64 cli_credentials_set_machine_account(cred);
67 /* If we have a principal set on this, we want to login with "" domain and user@realm */
68 if (cred->username_obtained < cred->principal_obtained) {
69 return cli_credentials_get_principal(cred, mem_ctx);
72 if (cred->username_obtained == CRED_CALLBACK) {
73 cred->username = cred->username_cb(cred);
74 cred->username_obtained = CRED_SPECIFIED;
77 return talloc_reference(mem_ctx, cred->username);
80 BOOL cli_credentials_set_username(struct cli_credentials *cred, const char *val, enum credentials_obtained obtained)
82 if (obtained >= cred->username_obtained) {
83 cred->username = talloc_strdup(cred, val);
84 cred->username_obtained = obtained;
92 * Obtain the client principal for this credentials context.
93 * @param cred credentials context
94 * @retval The username set on this context.
95 * @note Return value will never be NULL except by programmer error.
97 const char *cli_credentials_get_principal(struct cli_credentials *cred, TALLOC_CTX *mem_ctx)
99 if (cred->machine_account_pending) {
100 cli_credentials_set_machine_account(cred);
103 if (cred->principal_obtained == CRED_CALLBACK) {
104 cred->principal = cred->principal_cb(cred);
105 cred->principal_obtained = CRED_SPECIFIED;
108 if (cred->principal_obtained < cred->username_obtained) {
109 return talloc_asprintf(mem_ctx, "%s@%s",
110 cli_credentials_get_username(cred, mem_ctx),
111 cli_credentials_get_realm(cred));
113 return talloc_reference(mem_ctx, cred->principal);
116 BOOL cli_credentials_set_principal(struct cli_credentials *cred, const char *val, enum credentials_obtained obtained)
118 if (obtained >= cred->principal_obtained) {
119 cred->principal = talloc_strdup(cred, val);
120 cred->principal_obtained = obtained;
127 BOOL cli_credentials_authentication_requested(struct cli_credentials *cred)
129 if (cred->principal_obtained >= CRED_SPECIFIED) {
132 if (cred->username_obtained >= CRED_SPECIFIED) {
139 * Obtain the password for this credentials context.
140 * @param cred credentials context
141 * @retval If set, the cleartext password, otherwise NULL
143 const char *cli_credentials_get_password(struct cli_credentials *cred)
145 if (cred->machine_account_pending) {
146 cli_credentials_set_machine_account(cred);
149 if (cred->password_obtained == CRED_CALLBACK) {
150 cred->password = cred->password_cb(cred);
151 cred->password_obtained = CRED_SPECIFIED;
154 return cred->password;
157 BOOL cli_credentials_set_password(struct cli_credentials *cred, const char *val, enum credentials_obtained obtained)
159 if (obtained >= cred->password_obtained) {
160 cred->password = talloc_strdup(cred, val);
161 cred->password_obtained = obtained;
163 cred->nt_hash = NULL;
171 * Obtain the password for this credentials context.
172 * @param cred credentials context
173 * @retval If set, the cleartext password, otherwise NULL
175 const struct samr_Password *cli_credentials_get_nt_hash(struct cli_credentials *cred,
178 const char *password = cli_credentials_get_password(cred);
181 struct samr_Password *nt_hash = talloc(mem_ctx, struct samr_Password);
186 E_md4hash(password, nt_hash->hash);
190 return cred->nt_hash;
194 BOOL cli_credentials_set_nt_hash(struct cli_credentials *cred,
195 const struct samr_Password *nt_hash,
196 enum credentials_obtained obtained)
198 if (obtained >= cred->password_obtained) {
199 cli_credentials_set_password(cred, NULL, obtained);
200 cred->nt_hash = talloc(cred, struct samr_Password);
201 *cred->nt_hash = *nt_hash;
208 int cli_credentials_set_from_ccache(struct cli_credentials *cred,
209 enum credentials_obtained obtained)
212 krb5_principal princ;
217 ret = krb5_cc_get_principal(cred->ccache->smb_krb5_context->krb5_context,
218 cred->ccache->ccache, &princ);
221 char *err_mess = smb_get_krb5_error_message(cred->ccache->smb_krb5_context->krb5_context, ret, cred);
222 DEBUG(1,("failed to get principal from ccache: %s\n",
224 talloc_free(err_mess);
228 ret = krb5_unparse_name(cred->ccache->smb_krb5_context->krb5_context, princ, &name);
230 char *err_mess = smb_get_krb5_error_message(cred->ccache->smb_krb5_context->krb5_context, ret, cred);
231 DEBUG(1,("failed to unparse principal from ccache: %s\n",
233 talloc_free(err_mess);
237 realm = krb5_princ_realm(cred->ccache->smb_krb5_context->krb5_context, princ);
239 cli_credentials_set_realm(cred, *realm, obtained);
240 cli_credentials_set_principal(cred, name, obtained);
244 krb5_free_principal(cred->ccache->smb_krb5_context->krb5_context, princ);
246 cred->ccache_obtained = obtained;
252 static int free_mccache(void *ptr) {
253 struct ccache_container *ccc = ptr;
254 krb5_cc_destroy(ccc->smb_krb5_context->krb5_context, ccc->ccache);
259 static int free_dccache(void *ptr) {
260 struct ccache_container *ccc = ptr;
261 krb5_cc_close(ccc->smb_krb5_context->krb5_context, ccc->ccache);
266 static int cli_credentials_set_ccache(struct cli_credentials *cred,
268 enum credentials_obtained obtained)
271 krb5_principal princ;
272 struct ccache_container *ccc = talloc(cred, struct ccache_container);
277 ret = smb_krb5_init_context(ccc, &ccc->smb_krb5_context);
283 ret = krb5_cc_resolve(ccc->smb_krb5_context->krb5_context, name, &ccc->ccache);
285 DEBUG(1,("failed to read krb5 ccache: %s: %s\n",
287 smb_get_krb5_error_message(ccc->smb_krb5_context->krb5_context, ret, ccc)));
292 ret = krb5_cc_default(ccc->smb_krb5_context->krb5_context, &ccc->ccache);
294 DEBUG(1,("failed to read default krb5 ccache: %s\n",
295 smb_get_krb5_error_message(ccc->smb_krb5_context->krb5_context, ret, ccc)));
301 talloc_set_destructor(ccc, free_dccache);
303 ret = krb5_cc_get_principal(ccc->smb_krb5_context->krb5_context, ccc->ccache, &princ);
306 DEBUG(1,("failed to get principal from default ccache: %s\n",
307 smb_get_krb5_error_message(ccc->smb_krb5_context->krb5_context, ret, ccc)));
312 krb5_free_principal(ccc->smb_krb5_context->krb5_context, princ);
315 talloc_steal(cred, ccc);
317 ret = cli_credentials_set_from_ccache(cred, obtained);
327 int cli_credentials_new_ccache(struct cli_credentials *cred)
331 struct ccache_container *ccc = talloc(cred, struct ccache_container);
337 rand_string = generate_random_str(NULL, 16);
343 ccache_name = talloc_asprintf(ccc, "MEMORY:%s",
345 talloc_free(rand_string);
352 ret = smb_krb5_init_context(ccc, &ccc->smb_krb5_context);
354 talloc_free(ccache_name);
359 ret = krb5_cc_resolve(ccc->smb_krb5_context->krb5_context, ccache_name, &ccc->ccache);
361 DEBUG(1,("failed to generate a new krb5 ccache (%s): %s\n",
363 smb_get_krb5_error_message(ccc->smb_krb5_context->krb5_context, ret, ccc)));
364 talloc_free(ccache_name);
369 talloc_set_destructor(ccc, free_mccache);
372 talloc_steal(cred, ccc);
373 talloc_free(ccache_name);
378 int cli_credentials_get_ccache(struct cli_credentials *cred, struct ccache_container **ccc)
382 if (cred->ccache_obtained >= (MAX(cred->principal_obtained,
383 cred->username_obtained))) {
387 if (cli_credentials_is_anonymous(cred)) {
391 ret = cli_credentials_new_ccache(cred);
395 ret = kinit_to_ccache(cred, cred, cred->ccache->smb_krb5_context, cred->ccache->ccache);
399 ret = cli_credentials_set_from_ccache(cred, cred->principal_obtained);
410 * Obtain the 'short' or 'NetBIOS' domain for this credentials context.
411 * @param cred credentials context
412 * @retval The domain set on this context.
413 * @note Return value will never be NULL except by programmer error.
415 const char *cli_credentials_get_domain(struct cli_credentials *cred)
417 if (cred->machine_account_pending) {
418 cli_credentials_set_machine_account(cred);
421 /* If we have a principal set on this, we want to login with "" domain and user@realm */
422 if (cred->domain_obtained < cred->principal_obtained) {
426 if (cred->domain_obtained == CRED_CALLBACK) {
427 cred->domain = cred->domain_cb(cred);
428 cred->domain_obtained = CRED_SPECIFIED;
435 BOOL cli_credentials_set_domain(struct cli_credentials *cred, const char *val, enum credentials_obtained obtained)
437 if (obtained >= cred->domain_obtained) {
438 cred->domain = talloc_strdup(cred, val);
439 cred->domain_obtained = obtained;
447 * Obtain the Kerberos realm for this credentials context.
448 * @param cred credentials context
449 * @retval The realm set on this context.
450 * @note Return value will never be NULL except by programmer error.
452 const char *cli_credentials_get_realm(struct cli_credentials *cred)
454 if (cred->machine_account_pending) {
455 cli_credentials_set_machine_account(cred);
458 if (cred->realm_obtained == CRED_CALLBACK) {
459 cred->realm = cred->realm_cb(cred);
460 cred->realm_obtained = CRED_SPECIFIED;
467 * Set the realm for this credentials context, and force it to
468 * uppercase for the sainity of our local kerberos libraries
470 BOOL cli_credentials_set_realm(struct cli_credentials *cred, const char *val, enum credentials_obtained obtained)
472 if (obtained >= cred->realm_obtained) {
473 cred->realm = strupper_talloc(cred, val);
474 cred->realm_obtained = obtained;
482 * Obtain the 'short' or 'NetBIOS' workstation name for this credentials context.
484 * @param cred credentials context
485 * @retval The workstation name set on this context.
486 * @note Return value will never be NULL except by programmer error.
488 const char *cli_credentials_get_workstation(struct cli_credentials *cred)
490 if (cred->workstation_obtained == CRED_CALLBACK) {
491 cred->workstation = cred->workstation_cb(cred);
492 cred->workstation_obtained = CRED_SPECIFIED;
495 return cred->workstation;
498 BOOL cli_credentials_set_workstation(struct cli_credentials *cred, const char *val, enum credentials_obtained obtained)
500 if (obtained >= cred->workstation_obtained) {
501 cred->workstation = talloc_strdup(cred, val);
502 cred->workstation_obtained = obtained;
510 * Read a file descriptor, and parse it for a password (eg from a file or stdin)
512 * @param credentials Credentials structure on which to set the password
513 * @param fd open file descriptor to read the password from
514 * @param obtained This enum describes how 'specified' this password is
517 BOOL cli_credentials_parse_password_fd(struct cli_credentials *credentials, int fd, enum credentials_obtained obtained)
522 for(p = pass, *p = '\0'; /* ensure that pass is null-terminated */
523 p && p - pass < sizeof(pass);) {
524 switch (read(fd, p, 1)) {
526 if (*p != '\n' && *p != '\0') {
527 *++p = '\0'; /* advance p, and null-terminate pass */
532 *p = '\0'; /* null-terminate it, just in case... */
533 p = NULL; /* then force the loop condition to become false */
536 fprintf(stderr, "Error reading password from file descriptor %d: %s\n", fd, "empty password\n");
541 fprintf(stderr, "Error reading password from file descriptor %d: %s\n",
542 fd, strerror(errno));
547 cli_credentials_set_password(credentials, pass, obtained);
552 * Read a named file, and parse it for a password
554 * @param credentials Credentials structure on which to set the password
555 * @param file a named file to read the password from
556 * @param obtained This enum describes how 'specified' this password is
559 BOOL cli_credentials_parse_password_file(struct cli_credentials *credentials, const char *file, enum credentials_obtained obtained)
561 int fd = open(file, O_RDONLY, 0);
565 fprintf(stderr, "Error opening PASSWD_FILE %s: %s\n",
566 file, strerror(errno));
570 ret = cli_credentials_parse_password_fd(credentials, fd, obtained);
578 * Read a named file, and parse it for username, domain, realm and password
580 * @param credentials Credentials structure on which to set the password
581 * @param file a named file to read the details from
582 * @param obtained This enum describes how 'specified' this password is
585 BOOL cli_credentials_parse_file(struct cli_credentials *cred, const char *file, enum credentials_obtained obtained)
590 char *ptr, *val, *param;
592 if ((auth=x_fopen(file, O_RDONLY, 0)) == NULL)
594 /* fail if we can't open the credentials file */
595 d_printf("ERROR: Unable to open credentials file!\n");
599 while (!x_feof(auth))
601 /* get a line from the file */
602 if (!x_fgets(buf, sizeof(buf), auth))
606 if ((len) && (buf[len-1]=='\n'))
614 /* break up the line into parameter & value.
615 * will need to eat a little whitespace possibly */
617 if (!(ptr = strchr_m (buf, '=')))
623 /* eat leading white space */
624 while ((*val!='\0') && ((*val==' ') || (*val=='\t')))
627 if (strwicmp("password", param) == 0) {
628 cli_credentials_set_password(cred, val, obtained);
629 } else if (strwicmp("username", param) == 0) {
630 cli_credentials_set_username(cred, val, obtained);
631 } else if (strwicmp("domain", param) == 0) {
632 cli_credentials_set_domain(cred, val, obtained);
633 } else if (strwicmp("realm", param) == 0) {
634 cli_credentials_set_realm(cred, val, obtained);
636 memset(buf, 0, sizeof(buf));
645 * Given a string, typically obtained from a -U argument, parse it into domain, username, realm and password fields
647 * The format accepted is [domain\\]user[%password] or user[@realm][%password]
649 * @param credentials Credentials structure on which to set the password
650 * @param data the string containing the username, password etc
651 * @param obtained This enum describes how 'specified' this password is
654 void cli_credentials_parse_string(struct cli_credentials *credentials, const char *data, enum credentials_obtained obtained)
658 if (strcmp("%",data) == 0) {
659 cli_credentials_set_anonymous(credentials);
663 uname = talloc_strdup(credentials, data);
664 if ((p = strchr_m(uname,'%'))) {
666 cli_credentials_set_password(credentials, p+1, obtained);
669 if ((p = strchr_m(uname,'@'))) {
670 cli_credentials_set_principal(credentials, uname, obtained);
672 cli_credentials_set_realm(credentials, p+1, obtained);
674 } else if ((p = strchr_m(uname,'\\')) || (p = strchr_m(uname, '/'))) {
676 cli_credentials_set_domain(credentials, uname, obtained);
679 cli_credentials_set_username(credentials, uname, obtained);
683 * Specifies default values for domain, workstation and realm
684 * from the smb.conf configuration file
686 * @param cred Credentials structure to fill in
688 void cli_credentials_set_conf(struct cli_credentials *cred)
690 cli_credentials_set_username(cred, "", CRED_UNINITIALISED);
691 cli_credentials_set_domain(cred, lp_workgroup(), CRED_UNINITIALISED);
692 cli_credentials_set_workstation(cred, lp_netbios_name(), CRED_UNINITIALISED);
693 cli_credentials_set_realm(cred, lp_realm(), CRED_UNINITIALISED);
697 * Guess defaults for credentials from environment variables,
698 * and from the configuration file
700 * @param cred Credentials structure to fill in
702 void cli_credentials_guess(struct cli_credentials *cred)
706 cli_credentials_set_conf(cred);
708 if (getenv("LOGNAME")) {
709 cli_credentials_set_username(cred, getenv("LOGNAME"), CRED_GUESS_ENV);
712 if (getenv("USER")) {
713 cli_credentials_parse_string(cred, getenv("USER"), CRED_GUESS_ENV);
714 if ((p = strchr_m(getenv("USER"),'%'))) {
715 memset(p,0,strlen(cred->password));
719 if (getenv("DOMAIN")) {
720 cli_credentials_set_domain(cred, getenv("DOMAIN"), CRED_GUESS_ENV);
723 if (getenv("PASSWD")) {
724 cli_credentials_set_password(cred, getenv("PASSWD"), CRED_GUESS_ENV);
727 if (getenv("PASSWD_FD")) {
728 cli_credentials_parse_password_fd(cred, atoi(getenv("PASSWD_FD")), CRED_GUESS_FILE);
731 if (getenv("PASSWD_FILE")) {
732 cli_credentials_parse_password_file(cred, getenv("PASSWD_FILE"), CRED_GUESS_FILE);
735 cli_credentials_set_ccache(cred, NULL, CRED_GUESS_FILE);
739 * Fill in credentials for the machine trust account, from the secrets database.
741 * @param cred Credentials structure to fill in
742 * @retval NTSTATUS error detailing any failure
744 NTSTATUS cli_credentials_set_machine_account(struct cli_credentials *cred)
748 struct ldb_context *ldb;
750 struct ldb_message **msgs;
751 const char *attrs[] = {
758 "msDS-KeyVersionNumber",
762 const char *machine_account;
763 const char *password;
766 enum netr_SchannelType sct;
768 /* ok, we are going to get it now, don't recurse back here */
769 cred->machine_account_pending = False;
771 mem_ctx = talloc_named(cred, 0, "cli_credentials fetch machine password");
772 /* Local secrets are stored in secrets.ldb */
773 ldb = secrets_db_connect(mem_ctx);
775 DEBUG(1, ("Could not open secrets.ldb\n"));
776 return NT_STATUS_CANT_ACCESS_DOMAIN_INFO;
779 /* search for the secret record */
780 ldb_ret = gendb_search(ldb,
781 mem_ctx, ldb_dn_explode(mem_ctx, SECRETS_PRIMARY_DOMAIN_DN),
783 SECRETS_PRIMARY_DOMAIN_FILTER,
784 cli_credentials_get_domain(cred));
786 DEBUG(1, ("Could not find join record to domain: %s\n",
787 cli_credentials_get_domain(cred)));
788 talloc_free(mem_ctx);
789 return NT_STATUS_CANT_ACCESS_DOMAIN_INFO;
790 } else if (ldb_ret != 1) {
791 DEBUG(1, ("Found more than one (%d) join records to domain: %s\n",
792 ldb_ret, cli_credentials_get_domain(cred)));
793 talloc_free(mem_ctx);
794 return NT_STATUS_CANT_ACCESS_DOMAIN_INFO;
797 password = ldb_msg_find_string(msgs[0], "secret", NULL);
799 machine_account = ldb_msg_find_string(msgs[0], "samAccountName", NULL);
801 if (!machine_account) {
802 DEBUG(1, ("Could not find 'samAccountName' in join record to domain: %s\n",
803 cli_credentials_get_domain(cred)));
804 talloc_free(mem_ctx);
805 return NT_STATUS_CANT_ACCESS_DOMAIN_INFO;
808 sct = ldb_msg_find_int(msgs[0], "secureChannelType", 0);
810 DEBUG(1, ("Domain join for acocunt %s did not have a secureChannelType set!\n",
812 return NT_STATUS_CANT_ACCESS_DOMAIN_INFO;
816 const struct ldb_val *nt_password_hash = ldb_msg_find_ldb_val(msgs[0], "ntPwdHash");
817 struct samr_Password hash;
819 if (nt_password_hash) {
820 memcpy(hash.hash, nt_password_hash->data,
821 MIN(nt_password_hash->length, sizeof(hash.hash)));
823 cli_credentials_set_nt_hash(cred, &hash, CRED_SPECIFIED);
826 DEBUG(1, ("Could not find 'secret' in join record to domain: %s\n",
827 cli_credentials_get_domain(cred)));
828 talloc_free(mem_ctx);
829 return NT_STATUS_CANT_ACCESS_DOMAIN_INFO;
833 cli_credentials_set_secure_channel_type(cred, sct);
835 domain = ldb_msg_find_string(msgs[0], "flatname", NULL);
837 cli_credentials_set_domain(cred, domain, CRED_SPECIFIED);
840 realm = ldb_msg_find_string(msgs[0], "realm", NULL);
842 cli_credentials_set_realm(cred, realm, CRED_SPECIFIED);
845 cli_credentials_set_username(cred, machine_account, CRED_SPECIFIED);
847 cli_credentials_set_password(cred, password, CRED_SPECIFIED);
850 cli_credentials_set_kvno(cred, ldb_msg_find_int(msgs[0], "msDS-KeyVersionNumber", 0));
852 talloc_free(mem_ctx);
858 * Ask that when required, the credentials system will be filled with
859 * machine trust account, from the secrets database.
861 * @param cred Credentials structure to fill in
862 * @note This function is used to call the above function after, rather
863 * than during, popt processing.
866 void cli_credentials_set_machine_account_pending(struct cli_credentials *cred)
868 cred->machine_account_pending = True;
872 * Attach NETLOGON credentials for use with SCHANNEL
875 void cli_credentials_set_netlogon_creds(struct cli_credentials *cred,
876 struct creds_CredentialState *netlogon_creds)
878 cred->netlogon_creds = talloc_reference(cred, netlogon_creds);
882 * Return attached NETLOGON credentials
885 struct creds_CredentialState *cli_credentials_get_netlogon_creds(struct cli_credentials *cred)
887 return cred->netlogon_creds;
891 * Set NETLOGON secure channel type
894 void cli_credentials_set_secure_channel_type(struct cli_credentials *cred,
895 enum netr_SchannelType secure_channel_type)
897 cred->secure_channel_type = secure_channel_type;
901 * Return NETLOGON secure chanel type
904 enum netr_SchannelType cli_credentials_get_secure_channel_type(struct cli_credentials *cred)
906 return cred->secure_channel_type;
913 void cli_credentials_set_kvno(struct cli_credentials *cred,
920 * Return Kerberos KVNO
923 int cli_credentials_get_kvno(struct cli_credentials *cred)
929 * Fill in a credentials structure as the anonymous user
931 void cli_credentials_set_anonymous(struct cli_credentials *cred)
933 cli_credentials_set_username(cred, "", CRED_SPECIFIED);
934 cli_credentials_set_domain(cred, "", CRED_SPECIFIED);
935 cli_credentials_set_password(cred, NULL, CRED_SPECIFIED);
939 * Describe a credentials context as anonymous or authenticated
940 * @retval True if anonymous, False if a username is specified
943 BOOL cli_credentials_is_anonymous(struct cli_credentials *cred)
945 TALLOC_CTX *tmp_ctx = talloc_new(cred);
946 const char *username = cli_credentials_get_username(cred, tmp_ctx);
948 /* Yes, it is deliberate that we die if we have a NULL pointer
949 * here - anonymous is "", not NULL, which is 'never specified,
950 * never guessed', ie programmer bug */
952 talloc_free(tmp_ctx);
956 talloc_free(tmp_ctx);