2 Unix SMB/CIFS implementation.
3 kerberos utility library
4 Copyright (C) Andrew Tridgell 2001
5 Copyright (C) Remus Koos 2001
6 Copyright (C) Nalin Dahyabhai <nalin@redhat.com> 2004.
7 Copyright (C) Jeremy Allison 2004.
8 Copyright (C) Gerald Carter 2006.
10 This program is free software; you can redistribute it and/or modify
11 it under the terms of the GNU General Public License as published by
12 the Free Software Foundation; either version 3 of the License, or
13 (at your option) any later version.
15 This program is distributed in the hope that it will be useful,
16 but WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 GNU General Public License for more details.
20 You should have received a copy of the GNU General Public License
21 along with this program. If not, see <http://www.gnu.org/licenses/>.
25 #include "libsmb/namequery.h"
26 #include "system/filesys.h"
28 #include "../librpc/gen_ndr/ndr_misc.h"
29 #include "libads/kerberos_proto.h"
30 #include "libads/cldap.h"
32 #include "../lib/tsocket/tsocket.h"
33 #include "lib/util/asn1.h"
38 we use a prompter to avoid a crash bug in the kerberos libs when
39 dealing with empty passwords
40 this prompter is just a string copy ...
42 static krb5_error_code
43 kerb_prompter(krb5_context ctx
, void *data
,
47 krb5_prompt prompts
[])
49 if (num_prompts
== 0) return 0;
50 if (num_prompts
== 2) {
52 * only heimdal has a prompt type and we need to deal with it here to
55 * removing the prompter completely is not an option as at least these
56 * versions would crash: heimdal-1.0.2 and heimdal-1.1. Later heimdal
57 * version have looping detection and return with a proper error code.
60 #if defined(HAVE_KRB5_PROMPT_TYPE) /* Heimdal */
61 if (prompts
[0].type
== KRB5_PROMPT_TYPE_NEW_PASSWORD
&&
62 prompts
[1].type
== KRB5_PROMPT_TYPE_NEW_PASSWORD_AGAIN
) {
64 * We don't want to change passwords here. We're
65 * called from heimdal when the KDC returns
66 * KRB5KDC_ERR_KEY_EXPIRED, but at this point we don't
67 * have the chance to ask the user for a new
68 * password. If we return 0 (i.e. success), we will be
69 * spinning in the endless for-loop in
70 * change_password() in
71 * third_party/heimdal/lib/krb5/init_creds_pw.c
73 return KRB5KDC_ERR_KEY_EXPIRED
;
75 #elif defined(HAVE_KRB5_GET_PROMPT_TYPES) /* MIT */
76 krb5_prompt_type
*prompt_types
= NULL
;
78 prompt_types
= krb5_get_prompt_types(ctx
);
79 if (prompt_types
!= NULL
) {
80 if (prompt_types
[0] == KRB5_PROMPT_TYPE_NEW_PASSWORD
&&
81 prompt_types
[1] == KRB5_PROMPT_TYPE_NEW_PASSWORD_AGAIN
) {
82 return KRB5KDC_ERR_KEY_EXP
;
88 memset(prompts
[0].reply
->data
, '\0', prompts
[0].reply
->length
);
89 if (prompts
[0].reply
->length
> 0) {
91 strncpy((char *)prompts
[0].reply
->data
, (const char *)data
,
92 prompts
[0].reply
->length
-1);
93 prompts
[0].reply
->length
= strlen((const char *)prompts
[0].reply
->data
);
95 prompts
[0].reply
->length
= 0;
102 simulate a kinit, putting the tgt in the given cache location. If cache_name == NULL
103 place in default cache location.
106 int kerberos_kinit_password_ext(const char *given_principal
,
107 const char *password
,
110 time_t *renew_till_time
,
111 const char *cache_name
,
113 bool add_netbios_addr
,
114 time_t renewable_time
,
116 char **_canon_principal
,
120 TALLOC_CTX
*frame
= talloc_stackframe();
121 krb5_context ctx
= NULL
;
122 krb5_error_code code
= 0;
123 krb5_ccache cc
= NULL
;
124 krb5_principal me
= NULL
;
125 krb5_principal canon_princ
= NULL
;
127 krb5_get_init_creds_opt
*opt
= NULL
;
128 smb_krb5_addresses
*addr
= NULL
;
129 char *canon_principal
= NULL
;
130 char *canon_realm
= NULL
;
132 ZERO_STRUCT(my_creds
);
134 if (cache_name
== NULL
) {
135 DBG_DEBUG("Missing ccache for [%s] and config [%s]\n",
137 getenv("KRB5_CONFIG"));
142 code
= smb_krb5_init_context_common(&ctx
);
144 DBG_ERR("kerberos init context failed (%s)\n",
145 error_message(code
));
150 if (time_offset
!= 0) {
151 krb5_set_real_time(ctx
, time(NULL
) + time_offset
, 0);
154 DBG_DEBUG("as %s using [%s] as ccache and config [%s]\n",
157 getenv("KRB5_CONFIG"));
159 if ((code
= krb5_cc_resolve(ctx
, cache_name
, &cc
))) {
163 if ((code
= smb_krb5_parse_name(ctx
, given_principal
, &me
))) {
167 if ((code
= krb5_get_init_creds_opt_alloc(ctx
, &opt
))) {
171 krb5_get_init_creds_opt_set_renew_life(opt
, renewable_time
);
172 krb5_get_init_creds_opt_set_forwardable(opt
, True
);
174 /* Turn on canonicalization for lower case realm support */
175 #ifdef SAMBA4_USES_HEIMDAL
176 krb5_get_init_creds_opt_set_win2k(ctx
, opt
, true);
177 krb5_get_init_creds_opt_set_canonicalize(ctx
, opt
, true);
179 krb5_get_init_creds_opt_set_canonicalize(opt
, true);
183 krb5_get_init_creds_opt_set_tkt_life(opt
, 60);
186 #ifdef HAVE_KRB5_GET_INIT_CREDS_OPT_SET_PAC_REQUEST
188 if ((code
= krb5_get_init_creds_opt_set_pac_request(ctx
, opt
, (krb5_boolean
)request_pac
))) {
193 if (add_netbios_addr
) {
194 if ((code
= smb_krb5_gen_netbios_krb5_address(&addr
,
195 lp_netbios_name()))) {
198 krb5_get_init_creds_opt_set_address_list(opt
, addr
->addrs
);
201 if ((code
= krb5_get_init_creds_password(ctx
, &my_creds
, me
, discard_const_p(char,password
),
202 kerb_prompter
, discard_const_p(char, password
),
207 canon_princ
= my_creds
.client
;
209 code
= smb_krb5_unparse_name(frame
,
217 DBG_DEBUG("%s mapped to %s\n", given_principal
, canon_principal
);
219 canon_realm
= smb_krb5_principal_get_realm(frame
, ctx
, canon_princ
);
220 if (canon_realm
== NULL
) {
225 if ((code
= krb5_cc_initialize(ctx
, cc
, canon_princ
))) {
229 if ((code
= krb5_cc_store_cred(ctx
, cc
, &my_creds
))) {
234 *expire_time
= (time_t) my_creds
.times
.endtime
;
237 if (renew_till_time
) {
238 *renew_till_time
= (time_t) my_creds
.times
.renew_till
;
241 if (_canon_principal
!= NULL
) {
242 *_canon_principal
= talloc_move(mem_ctx
, &canon_principal
);
244 if (_canon_realm
!= NULL
) {
245 *_canon_realm
= talloc_move(mem_ctx
, &canon_realm
);
251 *ntstatus
= NT_STATUS_OK
;
255 /* fall back to self-made-mapping */
256 *ntstatus
= krb5_to_nt_status(code
);
260 krb5_free_cred_contents(ctx
, &my_creds
);
262 krb5_free_principal(ctx
, me
);
265 smb_krb5_free_addresses(ctx
, addr
);
268 krb5_get_init_creds_opt_free(ctx
, opt
);
271 krb5_cc_close(ctx
, cc
);
274 krb5_free_context(ctx
);
280 int ads_kdestroy(const char *cc_name
)
282 krb5_error_code code
;
283 krb5_context ctx
= NULL
;
284 krb5_ccache cc
= NULL
;
286 code
= smb_krb5_init_context_common(&ctx
);
288 DBG_ERR("kerberos init context failed (%s)\n",
289 error_message(code
));
294 * This should not happen, if
295 * we need that behaviour we
296 * should add an ads_kdestroy_default()
298 SMB_ASSERT(cc_name
!= NULL
);
300 code
= krb5_cc_resolve(ctx
, cc_name
, &cc
);
302 DBG_NOTICE("krb5_cc_resolve(%s) failed: %s\n",
303 cc_name
, error_message(code
));
304 krb5_free_context(ctx
);
308 code
= krb5_cc_destroy(ctx
, cc
);
310 DBG_ERR("krb5_cc_destroy(%s) failed: %s\n",
311 cc_name
, error_message(code
));
314 krb5_free_context (ctx
);
318 int create_kerberos_key_from_string(krb5_context context
,
319 krb5_principal host_princ
,
320 krb5_principal salt_princ
,
323 krb5_enctype enctype
,
328 * Check if we've determined that the KDC is salting keys for this
329 * principal/enctype in a non-obvious way. If it is, try to match
333 KRB5_KEY_DATA(key
) = (KRB5_KEY_DATA_CAST
*)SMB_MALLOC(password
->length
);
334 if (!KRB5_KEY_DATA(key
)) {
337 memcpy(KRB5_KEY_DATA(key
), password
->data
, password
->length
);
338 KRB5_KEY_LENGTH(key
) = password
->length
;
339 KRB5_KEY_TYPE(key
) = enctype
;
342 ret
= smb_krb5_create_key_from_string(context
,
343 salt_princ
? salt_princ
: host_princ
,
351 /************************************************************************
352 ************************************************************************/
354 int kerberos_kinit_password(const char *principal
,
355 const char *password
,
357 const char *cache_name
)
359 return kerberos_kinit_password_ext(principal
,
374 /************************************************************************
375 ************************************************************************/
377 /************************************************************************
378 Create a string list of available kdc's, possibly searching by sitename.
381 If "sitename" is given, the DC's in that site are listed first.
383 ************************************************************************/
385 static void add_sockaddr_unique(struct sockaddr_storage
*addrs
, size_t *num_addrs
,
386 const struct sockaddr_storage
*addr
)
390 for (i
=0; i
<*num_addrs
; i
++) {
391 if (sockaddr_equal((const struct sockaddr
*)&addrs
[i
],
392 (const struct sockaddr
*)addr
)) {
400 /* print_canonical_sockaddr prints an ipv6 addr in the form of
401 * [ipv6.addr]. This string, when put in a generated krb5.conf file is not
402 * always properly dealt with by some older krb5 libraries. Adding the hard-coded
403 * portnumber workarounds the issue. - gd */
405 static char *print_canonical_sockaddr_with_port(TALLOC_CTX
*mem_ctx
,
406 const struct sockaddr_storage
*pss
)
410 str
= print_canonical_sockaddr(mem_ctx
, pss
);
415 if (pss
->ss_family
!= AF_INET6
) {
419 #if defined(HAVE_IPV6)
420 str
= talloc_asprintf_append(str
, ":88");
425 static char *get_kdc_ip_string(char *mem_ctx
,
427 const char *sitename
,
428 const struct sockaddr_storage
*pss
)
430 TALLOC_CTX
*frame
= talloc_stackframe();
432 struct samba_sockaddr
*ip_sa_site
= NULL
;
433 struct samba_sockaddr
*ip_sa_nonsite
= NULL
;
434 struct samba_sockaddr sa
= {0};
435 size_t count_site
= 0;
436 size_t count_nonsite
;
438 struct sockaddr_storage
*dc_addrs
= NULL
;
439 struct tsocket_address
**dc_addrs2
= NULL
;
440 const struct tsocket_address
* const *dc_addrs3
= NULL
;
442 struct netlogon_samlogon_response
**responses
= NULL
;
445 char *kdc_str
= NULL
;
446 char *canon_sockaddr
= NULL
;
448 kdc_str
= talloc_strdup(frame
, "");
451 canon_sockaddr
= print_canonical_sockaddr_with_port(frame
, pss
);
452 if (canon_sockaddr
== NULL
) {
456 talloc_asprintf_addbuf(&kdc_str
,
460 ok
= sockaddr_storage_to_samba_sockaddr(&sa
, pss
);
467 * First get the KDC's only in this site, the rest will be
472 status
= get_kdc_list(frame
,
477 if (!NT_STATUS_IS_OK(status
)) {
478 DBG_ERR("get_kdc_list fail %s\n",
482 DBG_DEBUG("got %zu addresses from site %s search\n",
489 status
= get_kdc_list(frame
,
494 if (!NT_STATUS_IS_OK(status
)) {
495 DBG_ERR("get_kdc_list (site-less) fail %s\n",
499 DBG_DEBUG("got %zu addresses from site-less search\n", count_nonsite
);
501 if (count_site
+ count_nonsite
< count_site
) {
503 DBG_ERR("get_kdc_list_talloc (site-less) fail wrap error\n");
508 dc_addrs
= talloc_array(talloc_tos(), struct sockaddr_storage
,
509 count_site
+ count_nonsite
);
510 if (dc_addrs
== NULL
) {
516 for (i
= 0; i
< count_site
; i
++) {
517 if (!sockaddr_equal(&sa
.u
.sa
, &ip_sa_site
[i
].u
.sa
)) {
518 add_sockaddr_unique(dc_addrs
, &num_dcs
,
519 &ip_sa_site
[i
].u
.ss
);
523 for (i
= 0; i
< count_nonsite
; i
++) {
524 if (!sockaddr_equal(&sa
.u
.sa
, &ip_sa_nonsite
[i
].u
.sa
)) {
525 add_sockaddr_unique(dc_addrs
, &num_dcs
,
526 &ip_sa_nonsite
[i
].u
.ss
);
530 DBG_DEBUG("%zu additional KDCs to test\n", num_dcs
);
533 * We do not have additional KDCs, but we have the one passed
534 * in via `pss`. So just use that one and leave.
536 result
= talloc_move(mem_ctx
, &kdc_str
);
540 dc_addrs2
= talloc_zero_array(talloc_tos(),
541 struct tsocket_address
*,
543 if (dc_addrs2
== NULL
) {
547 for (i
=0; i
<num_dcs
; i
++) {
548 char addr
[INET6_ADDRSTRLEN
];
551 print_sockaddr(addr
, sizeof(addr
), &dc_addrs
[i
]);
553 ret
= tsocket_address_inet_from_strings(dc_addrs2
, "ip",
557 status
= map_nt_error_from_unix(errno
);
558 DEBUG(2,("Failed to create tsocket_address for %s - %s\n",
559 addr
, nt_errstr(status
)));
564 dc_addrs3
= (const struct tsocket_address
* const *)dc_addrs2
;
566 status
= cldap_multi_netlogon(talloc_tos(),
568 realm
, lp_netbios_name(),
569 NETLOGON_NT_VERSION_5
| NETLOGON_NT_VERSION_5EX
,
570 MIN(num_dcs
, 3), timeval_current_ofs(3, 0), &responses
);
571 TALLOC_FREE(dc_addrs2
);
574 if (!NT_STATUS_IS_OK(status
)) {
575 DEBUG(10,("get_kdc_ip_string: cldap_multi_netlogon failed: "
576 "%s\n", nt_errstr(status
)));
580 for (i
=0; i
<num_dcs
; i
++) {
581 if (responses
[i
] == NULL
) {
585 /* Append to the string - inefficient but not done often. */
586 talloc_asprintf_addbuf(&kdc_str
,
588 print_canonical_sockaddr_with_port(
589 mem_ctx
, &dc_addrs
[i
]));
592 result
= talloc_move(mem_ctx
, &kdc_str
);
594 if (result
!= NULL
) {
595 DBG_DEBUG("Returning\n%s\n", result
);
597 DBG_NOTICE("Failed to get KDC ip address\n");
604 /************************************************************************
605 Create a specific krb5.conf file in the private directory pointing
606 at a specific kdc for a realm. Keyed off domain name. Sets
607 KRB5_CONFIG environment variable to point to this file. Must be
608 run as root or will fail (which is a good thing :-).
609 ************************************************************************/
611 #if !defined(SAMBA4_USES_HEIMDAL) /* MIT version */
612 static char *get_enctypes(TALLOC_CTX
*mem_ctx
)
614 char *aes_enctypes
= NULL
;
615 const char *legacy_enctypes
= "";
616 char *enctypes
= NULL
;
618 aes_enctypes
= talloc_strdup(mem_ctx
, "");
619 if (aes_enctypes
== NULL
) {
623 if (lp_kerberos_encryption_types() == KERBEROS_ETYPES_ALL
||
624 lp_kerberos_encryption_types() == KERBEROS_ETYPES_STRONG
) {
625 aes_enctypes
= talloc_asprintf_append(
626 aes_enctypes
, "%s", "aes256-cts-hmac-sha1-96 ");
627 if (aes_enctypes
== NULL
) {
630 aes_enctypes
= talloc_asprintf_append(
631 aes_enctypes
, "%s", "aes128-cts-hmac-sha1-96");
632 if (aes_enctypes
== NULL
) {
637 if (lp_weak_crypto() == SAMBA_WEAK_CRYPTO_ALLOWED
&&
638 (lp_kerberos_encryption_types() == KERBEROS_ETYPES_ALL
||
639 lp_kerberos_encryption_types() == KERBEROS_ETYPES_LEGACY
)) {
640 legacy_enctypes
= "RC4-HMAC";
644 talloc_asprintf(mem_ctx
, "\tdefault_tgs_enctypes = %s %s\n"
645 "\tdefault_tkt_enctypes = %s %s\n"
646 "\tpreferred_enctypes = %s %s\n",
647 aes_enctypes
, legacy_enctypes
, aes_enctypes
,
648 legacy_enctypes
, aes_enctypes
, legacy_enctypes
);
650 TALLOC_FREE(aes_enctypes
);
653 #else /* Heimdal version */
654 static char *get_enctypes(TALLOC_CTX
*mem_ctx
)
656 const char *aes_enctypes
= "";
657 const char *legacy_enctypes
= "";
658 char *enctypes
= NULL
;
660 if (lp_kerberos_encryption_types() == KERBEROS_ETYPES_ALL
||
661 lp_kerberos_encryption_types() == KERBEROS_ETYPES_STRONG
) {
663 "aes256-cts-hmac-sha1-96 aes128-cts-hmac-sha1-96";
666 if (lp_kerberos_encryption_types() == KERBEROS_ETYPES_ALL
||
667 lp_kerberos_encryption_types() == KERBEROS_ETYPES_LEGACY
) {
668 legacy_enctypes
= "arcfour-hmac-md5";
671 enctypes
= talloc_asprintf(mem_ctx
, "\tdefault_etypes = %s %s\n",
672 aes_enctypes
, legacy_enctypes
);
678 bool create_local_private_krb5_conf_for_domain(const char *realm
,
680 const char *sitename
,
681 const struct sockaddr_storage
*pss
)
684 char *tmpname
= NULL
;
686 char *file_contents
= NULL
;
687 char *kdc_ip_string
= NULL
;
691 char *realm_upper
= NULL
;
693 char *enctypes
= NULL
;
694 const char *include_system_krb5
= "";
697 if (!lp_create_krb5_conf()) {
702 DEBUG(0, ("No realm has been specified! Do you really want to "
703 "join an Active Directory server?\n"));
707 if (domain
== NULL
) {
711 dname
= lock_path(talloc_tos(), "smb_krb5");
715 if ((mkdir(dname
, 0755)==-1) && (errno
!= EEXIST
)) {
716 DEBUG(0,("create_local_private_krb5_conf_for_domain: "
717 "failed to create directory %s. Error was %s\n",
718 dname
, strerror(errno
) ));
722 tmpname
= lock_path(talloc_tos(), "smb_tmp_krb5.XXXXXX");
727 fname
= talloc_asprintf(dname
, "%s/krb5.conf.%s", dname
, domain
);
732 DEBUG(10,("create_local_private_krb5_conf_for_domain: fname = %s, realm = %s, domain = %s\n",
733 fname
, realm
, domain
));
735 realm_upper
= talloc_strdup(fname
, realm
);
736 if (!strupper_m(realm_upper
)) {
740 kdc_ip_string
= get_kdc_ip_string(dname
, realm
, sitename
, pss
);
741 if (!kdc_ip_string
) {
745 enctypes
= get_enctypes(fname
);
746 if (enctypes
== NULL
) {
750 #if !defined(SAMBA4_USES_HEIMDAL)
751 if (lp_include_system_krb5_conf()) {
752 include_system_krb5
= "include /etc/krb5.conf";
757 * We are setting 'dns_lookup_kdc' to true, because we want to lookup
758 * KDCs which are not configured via DNS SRV records, eg. if we do:
760 * net ads join -Uadmin@otherdomain
763 talloc_asprintf(fname
,
765 "\tdefault_realm = %s\n"
767 "\tdns_lookup_realm = false\n"
768 "\tdns_lookup_kdc = true\n\n"
769 "[realms]\n\t%s = {\n"
780 include_system_krb5
);
782 if (!file_contents
) {
786 flen
= strlen(file_contents
);
788 mask
= umask(S_IRWXO
| S_IRWXG
);
789 fd
= mkstemp(tmpname
);
792 DBG_ERR("mkstemp failed, for file %s. Errno %s\n",
798 if (fchmod(fd
, 0644)==-1) {
799 DEBUG(0,("create_local_private_krb5_conf_for_domain: fchmod failed for %s."
801 tmpname
, strerror(errno
) ));
807 ret
= write(fd
, file_contents
, flen
);
809 DEBUG(0,("create_local_private_krb5_conf_for_domain: write failed,"
810 " returned %d (should be %u). Errno %s\n",
811 (int)ret
, (unsigned int)flen
, strerror(errno
) ));
817 DEBUG(0,("create_local_private_krb5_conf_for_domain: close failed."
818 " Errno %s\n", strerror(errno
) ));
823 if (rename(tmpname
, fname
) == -1) {
824 DEBUG(0,("create_local_private_krb5_conf_for_domain: rename "
825 "of %s to %s failed. Errno %s\n",
826 tmpname
, fname
, strerror(errno
) ));
831 DBG_INFO("wrote file %s with realm %s KDC list:\n%s\n",
832 fname
, realm_upper
, kdc_ip_string
);
834 /* Set the environment variable to this file. */
835 setenv("KRB5_CONFIG", fname
, 1);
839 #if defined(OVERWRITE_SYSTEM_KRB5_CONF)
841 #define SYSTEM_KRB5_CONF_PATH "/etc/krb5.conf"
842 /* Insanity, sheer insanity..... */
844 if (strequal(realm
, lp_realm())) {
845 SMB_STRUCT_STAT sbuf
;
847 if (sys_lstat(SYSTEM_KRB5_CONF_PATH
, &sbuf
, false) == 0) {
848 if (S_ISLNK(sbuf
.st_ex_mode
) && sbuf
.st_ex_size
) {
850 size_t alloc_size
= sbuf
.st_ex_size
+ 1;
851 char *linkpath
= talloc_array(talloc_tos(), char,
856 lret
= readlink(SYSTEM_KRB5_CONF_PATH
, linkpath
,
859 TALLOC_FREE(linkpath
);
862 linkpath
[lret
] = '\0';
864 if (strcmp(linkpath
, fname
) == 0) {
865 /* Symlink already exists. */
866 TALLOC_FREE(linkpath
);
869 TALLOC_FREE(linkpath
);
873 /* Try and replace with a symlink. */
874 if (symlink(fname
, SYSTEM_KRB5_CONF_PATH
) == -1) {
875 const char *newpath
= SYSTEM_KRB5_CONF_PATH
".saved";
876 if (errno
!= EEXIST
) {
877 DEBUG(0,("create_local_private_krb5_conf_for_domain: symlink "
878 "of %s to %s failed. Errno %s\n",
879 fname
, SYSTEM_KRB5_CONF_PATH
, strerror(errno
) ));
880 goto done
; /* Not a fatal error. */
883 /* Yes, this is a race condition... too bad. */
884 if (rename(SYSTEM_KRB5_CONF_PATH
, newpath
) == -1) {
885 DEBUG(0,("create_local_private_krb5_conf_for_domain: rename "
886 "of %s to %s failed. Errno %s\n",
887 SYSTEM_KRB5_CONF_PATH
, newpath
,
889 goto done
; /* Not a fatal error. */
892 if (symlink(fname
, SYSTEM_KRB5_CONF_PATH
) == -1) {
893 DEBUG(0,("create_local_private_krb5_conf_for_domain: "
894 "forced symlink of %s to /etc/krb5.conf failed. Errno %s\n",
895 fname
, strerror(errno
) ));
896 goto done
; /* Not a fatal error. */
903 TALLOC_FREE(tmpname
);