2 * Copyright (c) 1997 - 2007 Kungliga Tekniska Högskolan
3 * (Royal Institute of Technology, Stockholm, Sweden).
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the
15 * documentation and/or other materials provided with the distribution.
17 * 3. Neither the name of the Institute nor the names of its contributors
18 * may be used to endorse or promote products derived from this software
19 * without specific prior written permission.
21 * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
22 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24 * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
25 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
27 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
34 #include "krb5_locl.h"
36 __RCSID("$Heimdal: cache.c 22127 2007-12-04 00:54:37Z lha $"
40 * Add a new ccache type with operations `ops', overwriting any
41 * existing one if `override'.
43 * @param context a Keberos context
44 * @param ops type of plugin symbol
45 * @param override flag to select if the registration is to overide
46 * an existing ops with the same name.
48 * @return Return an error code or 0.
50 * @ingroup krb5_ccache
53 krb5_error_code KRB5_LIB_FUNCTION
54 krb5_cc_register(krb5_context context
,
55 const krb5_cc_ops
*ops
,
56 krb5_boolean override
)
60 for(i
= 0; i
< context
->num_cc_ops
&& context
->cc_ops
[i
].prefix
; i
++) {
61 if(strcmp(context
->cc_ops
[i
].prefix
, ops
->prefix
) == 0) {
63 krb5_set_error_string(context
,
64 "ccache type %s already exists",
66 return KRB5_CC_TYPE_EXISTS
;
71 if(i
== context
->num_cc_ops
) {
72 krb5_cc_ops
*o
= realloc(context
->cc_ops
,
73 (context
->num_cc_ops
+ 1) *
74 sizeof(*context
->cc_ops
));
76 krb5_set_error_string(context
, "malloc: out of memory");
79 context
->num_cc_ops
++;
81 memset(context
->cc_ops
+ i
, 0,
82 (context
->num_cc_ops
- i
) * sizeof(*context
->cc_ops
));
84 memcpy(&context
->cc_ops
[i
], ops
, sizeof(context
->cc_ops
[i
]));
89 * Allocate the memory for a `id' and the that function table to
90 * `ops'. Returns 0 or and error code.
94 _krb5_cc_allocate(krb5_context context
,
95 const krb5_cc_ops
*ops
,
100 p
= malloc (sizeof(*p
));
102 krb5_set_error_string(context
, "malloc: out of memory");
103 return KRB5_CC_NOMEM
;
112 * Allocate memory for a new ccache in `id' with operations `ops'
113 * and name `residual'. Return 0 or an error code.
116 static krb5_error_code
117 allocate_ccache (krb5_context context
,
118 const krb5_cc_ops
*ops
,
119 const char *residual
,
124 ret
= _krb5_cc_allocate(context
, ops
, id
);
127 ret
= (*id
)->ops
->resolve(context
, id
, residual
);
134 * Find and allocate a ccache in `id' from the specification in `residual'.
135 * If the ccache name doesn't contain any colon, interpret it as a file name.
137 * @param context a Keberos context.
138 * @param name string name of a credential cache.
139 * @param id return pointer to a found credential cache.
141 * @return Return 0 or an error code. In case of an error, id is set
144 * @ingroup krb5_ccache
148 krb5_error_code KRB5_LIB_FUNCTION
149 krb5_cc_resolve(krb5_context context
,
157 for(i
= 0; i
< context
->num_cc_ops
&& context
->cc_ops
[i
].prefix
; i
++) {
158 size_t prefix_len
= strlen(context
->cc_ops
[i
].prefix
);
160 if(strncmp(context
->cc_ops
[i
].prefix
, name
, prefix_len
) == 0
161 && name
[prefix_len
] == ':') {
162 return allocate_ccache (context
, &context
->cc_ops
[i
],
163 name
+ prefix_len
+ 1,
167 if (strchr (name
, ':') == NULL
)
168 return allocate_ccache (context
, &krb5_fcc_ops
, name
, id
);
170 krb5_set_error_string(context
, "unknown ccache type %s", name
);
171 return KRB5_CC_UNKNOWN_TYPE
;
176 * Generate a new ccache of type `ops' in `id'.
178 * @return Return 0 or an error code.
180 * @ingroup krb5_ccache
184 krb5_error_code KRB5_LIB_FUNCTION
185 krb5_cc_gen_new(krb5_context context
,
186 const krb5_cc_ops
*ops
,
189 return krb5_cc_new_unique(context
, ops
->prefix
, NULL
, id
);
193 * Generates a new unique ccache of `type` in `id'. If `type' is NULL,
194 * the library chooses the default credential cache type. The supplied
195 * `hint' (that can be NULL) is a string that the credential cache
196 * type can use to base the name of the credential on, this is to make
197 * it easier for the user to differentiate the credentials.
199 * @return Returns 0 or an error code.
201 * @ingroup krb5_ccache
204 krb5_error_code KRB5_LIB_FUNCTION
205 krb5_cc_new_unique(krb5_context context
, const char *type
,
206 const char *hint
, krb5_ccache
*id
)
208 const krb5_cc_ops
*ops
= KRB5_DEFAULT_CCTYPE
;
212 ops
= krb5_cc_get_prefix_ops(context
, type
);
214 krb5_set_error_string(context
,
215 "Credential cache type %s is unknown", type
);
216 return KRB5_CC_UNKNOWN_TYPE
;
220 ret
= _krb5_cc_allocate(context
, ops
, id
);
223 return (*id
)->ops
->gen_new(context
, id
);
227 * Return the name of the ccache `id'
229 * @ingroup krb5_ccache
233 const char* KRB5_LIB_FUNCTION
234 krb5_cc_get_name(krb5_context context
,
237 return id
->ops
->get_name(context
, id
);
241 * Return the type of the ccache `id'.
243 * @ingroup krb5_ccache
247 const char* KRB5_LIB_FUNCTION
248 krb5_cc_get_type(krb5_context context
,
251 return id
->ops
->prefix
;
255 * Return the complete resolvable name the ccache `id' in `str´.
256 * `str` should be freed with free(3).
257 * Returns 0 or an error (and then *str is set to NULL).
259 * @ingroup krb5_ccache
263 krb5_error_code KRB5_LIB_FUNCTION
264 krb5_cc_get_full_name(krb5_context context
,
268 const char *type
, *name
;
272 type
= krb5_cc_get_type(context
, id
);
274 krb5_set_error_string(context
, "cache have no name of type");
275 return KRB5_CC_UNKNOWN_TYPE
;
278 name
= krb5_cc_get_name(context
, id
);
280 krb5_set_error_string(context
, "cache of type %s have no name", type
);
281 return KRB5_CC_BADNAME
;
284 if (asprintf(str
, "%s:%s", type
, name
) == -1) {
285 krb5_set_error_string(context
, "malloc - out of memory");
293 * Return krb5_cc_ops of a the ccache `id'.
295 * @ingroup krb5_ccache
300 krb5_cc_get_ops(krb5_context context
, krb5_ccache id
)
306 * Expand variables in `str' into `res'
310 _krb5_expand_default_cc_name(krb5_context context
, const char *str
, char **res
)
312 size_t tlen
, len
= 0;
313 char *tmp
, *tmp2
, *append
;
317 while (str
&& *str
) {
318 tmp
= strstr(str
, "%{");
319 if (tmp
&& tmp
!= str
) {
320 append
= malloc((tmp
- str
) + 1);
322 memcpy(append
, str
, tmp
- str
);
323 append
[tmp
- str
] = '\0';
327 tmp2
= strchr(tmp
, '}');
331 krb5_set_error_string(context
, "variable missing }");
332 return KRB5_CONFIG_BADFORMAT
;
334 if (strncasecmp(tmp
, "%{uid}", 6) == 0)
335 asprintf(&append
, "%u", (unsigned)getuid());
336 else if (strncasecmp(tmp
, "%{null}", 7) == 0)
341 krb5_set_error_string(context
,
342 "expand default cache unknown "
344 (int)(tmp2
- tmp
) - 2, tmp
+ 2);
345 return KRB5_CONFIG_BADFORMAT
;
349 append
= strdup(str
);
352 if (append
== NULL
) {
355 krb5_set_error_string(context
, "malloc - out of memory");
359 tlen
= strlen(append
);
360 tmp
= realloc(*res
, len
+ tlen
+ 1);
365 krb5_set_error_string(context
, "malloc - out of memory");
369 memcpy(*res
+ len
, append
, tlen
+ 1);
377 * Return non-zero if envirnoment that will determine default krb5cc
382 environment_changed(krb5_context context
)
386 /* if the cc name was set, don't change it */
387 if (context
->default_cc_name_set
)
393 e
= getenv("KRB5CCNAME");
395 if (context
->default_cc_name_env
) {
396 free(context
->default_cc_name_env
);
397 context
->default_cc_name_env
= NULL
;
401 if (context
->default_cc_name_env
== NULL
)
403 if (strcmp(e
, context
->default_cc_name_env
) != 0)
410 * Set the default cc name for `context' to `name'.
412 * @ingroup krb5_ccache
416 krb5_error_code KRB5_LIB_FUNCTION
417 krb5_cc_set_default_name(krb5_context context
, const char *name
)
419 krb5_error_code ret
= 0;
423 const char *e
= NULL
;
426 e
= getenv("KRB5CCNAME");
429 if (context
->default_cc_name_env
)
430 free(context
->default_cc_name_env
);
431 context
->default_cc_name_env
= strdup(e
);
435 e
= krb5_config_get_string(context
, NULL
, "libdefaults",
436 "default_cc_name", NULL
);
438 ret
= _krb5_expand_default_cc_name(context
, e
, &p
);
443 const krb5_cc_ops
*ops
= KRB5_DEFAULT_CCTYPE
;
444 ret
= (*ops
->default_name
)(context
, &p
);
449 context
->default_cc_name_set
= 0;
452 context
->default_cc_name_set
= 1;
456 krb5_set_error_string(context
, "malloc - out of memory");
460 if (context
->default_cc_name
)
461 free(context
->default_cc_name
);
463 context
->default_cc_name
= p
;
469 * Return a pointer to a context static string containing the default
472 * @return String to the default credential cache name.
474 * @ingroup krb5_ccache
478 const char* KRB5_LIB_FUNCTION
479 krb5_cc_default_name(krb5_context context
)
481 if (context
->default_cc_name
== NULL
|| environment_changed(context
))
482 krb5_cc_set_default_name(context
, NULL
);
484 return context
->default_cc_name
;
488 * Open the default ccache in `id'.
490 * @return Return 0 or an error code.
492 * @ingroup krb5_ccache
496 krb5_error_code KRB5_LIB_FUNCTION
497 krb5_cc_default(krb5_context context
,
500 const char *p
= krb5_cc_default_name(context
);
503 krb5_set_error_string(context
, "malloc - out of memory");
506 return krb5_cc_resolve(context
, p
, id
);
510 * Create a new ccache in `id' for `primary_principal'.
512 * @return Return 0 or an error code.
514 * @ingroup krb5_ccache
518 krb5_error_code KRB5_LIB_FUNCTION
519 krb5_cc_initialize(krb5_context context
,
521 krb5_principal primary_principal
)
523 return (*id
->ops
->init
)(context
, id
, primary_principal
);
528 * Remove the ccache `id'.
530 * @return Return 0 or an error code.
532 * @ingroup krb5_ccache
536 krb5_error_code KRB5_LIB_FUNCTION
537 krb5_cc_destroy(krb5_context context
,
542 ret
= (*id
->ops
->destroy
)(context
, id
);
543 krb5_cc_close (context
, id
);
548 * Stop using the ccache `id' and free the related resources.
550 * @return Return 0 or an error code.
552 * @ingroup krb5_ccache
556 krb5_error_code KRB5_LIB_FUNCTION
557 krb5_cc_close(krb5_context context
,
561 ret
= (*id
->ops
->close
)(context
, id
);
567 * Store `creds' in the ccache `id'.
569 * @return Return 0 or an error code.
571 * @ingroup krb5_ccache
575 krb5_error_code KRB5_LIB_FUNCTION
576 krb5_cc_store_cred(krb5_context context
,
580 return (*id
->ops
->store
)(context
, id
, creds
);
584 * Retrieve the credential identified by `mcreds' (and `whichfields')
585 * from `id' in `creds'. 'creds' must be free by the caller using
586 * krb5_free_cred_contents.
588 * @return Return 0 or an error code.
590 * @ingroup krb5_ccache
594 krb5_error_code KRB5_LIB_FUNCTION
595 krb5_cc_retrieve_cred(krb5_context context
,
597 krb5_flags whichfields
,
598 const krb5_creds
*mcreds
,
602 krb5_cc_cursor cursor
;
604 if (id
->ops
->retrieve
!= NULL
) {
605 return (*id
->ops
->retrieve
)(context
, id
, whichfields
,
609 ret
= krb5_cc_start_seq_get(context
, id
, &cursor
);
612 while((ret
= krb5_cc_next_cred(context
, id
, &cursor
, creds
)) == 0){
613 if(krb5_compare_creds(context
, whichfields
, mcreds
, creds
)){
617 krb5_free_cred_contents (context
, creds
);
619 krb5_cc_end_seq_get(context
, id
, &cursor
);
624 * Return the principal of `id' in `principal'.
626 * @return Return 0 or an error code.
628 * @ingroup krb5_ccache
632 krb5_error_code KRB5_LIB_FUNCTION
633 krb5_cc_get_principal(krb5_context context
,
635 krb5_principal
*principal
)
637 return (*id
->ops
->get_princ
)(context
, id
, principal
);
641 * Start iterating over `id', `cursor' is initialized to the
644 * @return Return 0 or an error code.
646 * @ingroup krb5_ccache
650 krb5_error_code KRB5_LIB_FUNCTION
651 krb5_cc_start_seq_get (krb5_context context
,
652 const krb5_ccache id
,
653 krb5_cc_cursor
*cursor
)
655 return (*id
->ops
->get_first
)(context
, id
, cursor
);
659 * Retrieve the next cred pointed to by (`id', `cursor') in `creds'
660 * and advance `cursor'.
662 * @return Return 0 or an error code.
664 * @ingroup krb5_ccache
668 krb5_error_code KRB5_LIB_FUNCTION
669 krb5_cc_next_cred (krb5_context context
,
670 const krb5_ccache id
,
671 krb5_cc_cursor
*cursor
,
674 return (*id
->ops
->get_next
)(context
, id
, cursor
, creds
);
678 * Like krb5_cc_next_cred, but allow for selective retrieval
680 * @ingroup krb5_ccache
684 krb5_error_code KRB5_LIB_FUNCTION
685 krb5_cc_next_cred_match(krb5_context context
,
686 const krb5_ccache id
,
687 krb5_cc_cursor
* cursor
,
689 krb5_flags whichfields
,
690 const krb5_creds
* mcreds
)
694 ret
= krb5_cc_next_cred(context
, id
, cursor
, creds
);
697 if (mcreds
== NULL
|| krb5_compare_creds(context
, whichfields
, mcreds
, creds
))
699 krb5_free_cred_contents(context
, creds
);
704 * Destroy the cursor `cursor'.
706 * @ingroup krb5_ccache
710 krb5_error_code KRB5_LIB_FUNCTION
711 krb5_cc_end_seq_get (krb5_context context
,
712 const krb5_ccache id
,
713 krb5_cc_cursor
*cursor
)
715 return (*id
->ops
->end_get
)(context
, id
, cursor
);
719 * Remove the credential identified by `cred', `which' from `id'.
721 * @ingroup krb5_ccache
725 krb5_error_code KRB5_LIB_FUNCTION
726 krb5_cc_remove_cred(krb5_context context
,
731 if(id
->ops
->remove_cred
== NULL
) {
732 krb5_set_error_string(context
,
733 "ccache %s does not support remove_cred",
735 return EACCES
; /* XXX */
737 return (*id
->ops
->remove_cred
)(context
, id
, which
, cred
);
741 * Set the flags of `id' to `flags'.
743 * @ingroup krb5_ccache
747 krb5_error_code KRB5_LIB_FUNCTION
748 krb5_cc_set_flags(krb5_context context
,
752 return (*id
->ops
->set_flags
)(context
, id
, flags
);
756 * Copy the contents of `from' to `to'.
758 * @ingroup krb5_ccache
762 krb5_error_code KRB5_LIB_FUNCTION
763 krb5_cc_copy_cache_match(krb5_context context
,
764 const krb5_ccache from
,
766 krb5_flags whichfields
,
767 const krb5_creds
* mcreds
,
768 unsigned int *matched
)
771 krb5_cc_cursor cursor
;
773 krb5_principal princ
;
775 ret
= krb5_cc_get_principal(context
, from
, &princ
);
778 ret
= krb5_cc_initialize(context
, to
, princ
);
780 krb5_free_principal(context
, princ
);
783 ret
= krb5_cc_start_seq_get(context
, from
, &cursor
);
785 krb5_free_principal(context
, princ
);
791 krb5_cc_next_cred_match(context
, from
, &cursor
, &cred
,
792 whichfields
, mcreds
) == 0) {
795 ret
= krb5_cc_store_cred(context
, to
, &cred
);
796 krb5_free_cred_contents(context
, &cred
);
798 krb5_cc_end_seq_get(context
, from
, &cursor
);
799 krb5_free_principal(context
, princ
);
804 * Just like krb5_cc_copy_cache_match, but copy everything.
806 * @ingroup krb5_ccache
810 krb5_error_code KRB5_LIB_FUNCTION
811 krb5_cc_copy_cache(krb5_context context
,
812 const krb5_ccache from
,
815 return krb5_cc_copy_cache_match(context
, from
, to
, 0, NULL
, NULL
);
819 * Return the version of `id'.
821 * @ingroup krb5_ccache
825 krb5_error_code KRB5_LIB_FUNCTION
826 krb5_cc_get_version(krb5_context context
,
827 const krb5_ccache id
)
829 if(id
->ops
->get_version
)
830 return (*id
->ops
->get_version
)(context
, id
);
836 * Clear `mcreds' so it can be used with krb5_cc_retrieve_cred
838 * @ingroup krb5_ccache
842 void KRB5_LIB_FUNCTION
843 krb5_cc_clear_mcred(krb5_creds
*mcred
)
845 memset(mcred
, 0, sizeof(*mcred
));
849 * Get the cc ops that is registered in `context' to handle the
850 * `prefix'. `prefix' can be a complete credential cache name or a
851 * prefix, the function will only use part up to the first colon (:)
853 * Returns NULL if ops not found.
855 * @ingroup krb5_ccache
860 krb5_cc_get_prefix_ops(krb5_context context
, const char *prefix
)
865 if (prefix
[0] == '/')
866 return &krb5_fcc_ops
;
870 krb5_set_error_string(context
, "malloc - out of memory");
877 for(i
= 0; i
< context
->num_cc_ops
&& context
->cc_ops
[i
].prefix
; i
++) {
878 if(strcmp(context
->cc_ops
[i
].prefix
, p
) == 0) {
880 return &context
->cc_ops
[i
];
887 struct krb5_cc_cache_cursor_data
{
888 const krb5_cc_ops
*ops
;
889 krb5_cc_cursor cursor
;
893 * Start iterating over all caches of `type'. If `type' is NULL, the
894 * default type is * used. `cursor' is initialized to the beginning.
896 * @return Return 0 or an error code.
898 * @ingroup krb5_ccache
902 krb5_error_code KRB5_LIB_FUNCTION
903 krb5_cc_cache_get_first (krb5_context context
,
905 krb5_cc_cache_cursor
*cursor
)
907 const krb5_cc_ops
*ops
;
911 type
= krb5_cc_default_name(context
);
913 ops
= krb5_cc_get_prefix_ops(context
, type
);
915 krb5_set_error_string(context
, "Unknown type \"%s\" when iterating "
916 "trying to iterate the credential caches", type
);
917 return KRB5_CC_UNKNOWN_TYPE
;
920 if (ops
->get_cache_first
== NULL
) {
921 krb5_set_error_string(context
, "Credential cache type %s doesn't support "
922 "iterations over caches", ops
->prefix
);
923 return KRB5_CC_NOSUPP
;
926 *cursor
= calloc(1, sizeof(**cursor
));
927 if (*cursor
== NULL
) {
928 krb5_set_error_string(context
, "malloc - out of memory");
932 (*cursor
)->ops
= ops
;
934 ret
= ops
->get_cache_first(context
, &(*cursor
)->cursor
);
943 * Retrieve the next cache pointed to by (`cursor') in `id'
944 * and advance `cursor'.
946 * @return Return 0 or an error code.
948 * @ingroup krb5_ccache
952 krb5_error_code KRB5_LIB_FUNCTION
953 krb5_cc_cache_next (krb5_context context
,
954 krb5_cc_cache_cursor cursor
,
957 return cursor
->ops
->get_cache_next(context
, cursor
->cursor
, id
);
961 * Destroy the cursor `cursor'.
963 * @return Return 0 or an error code.
965 * @ingroup krb5_ccache
969 krb5_error_code KRB5_LIB_FUNCTION
970 krb5_cc_cache_end_seq_get (krb5_context context
,
971 krb5_cc_cache_cursor cursor
)
974 ret
= cursor
->ops
->end_cache_get(context
, cursor
->cursor
);
981 * Search for a matching credential cache of type `type' that have the
982 * `principal' as the default principal. If NULL is used for `type',
983 * the default type is used. On success, `id' needs to be freed with
984 * krb5_cc_close or krb5_cc_destroy.
986 * @return On failure, error code is returned and `id' is set to NULL.
988 * @ingroup krb5_ccache
992 krb5_error_code KRB5_LIB_FUNCTION
993 krb5_cc_cache_match (krb5_context context
,
994 krb5_principal client
,
998 krb5_cc_cache_cursor cursor
;
1000 krb5_ccache cache
= NULL
;
1004 ret
= krb5_cc_cache_get_first (context
, type
, &cursor
);
1008 while ((ret
= krb5_cc_cache_next (context
, cursor
, &cache
)) == 0) {
1009 krb5_principal principal
;
1011 ret
= krb5_cc_get_principal(context
, cache
, &principal
);
1015 match
= krb5_principal_compare(context
, principal
, client
);
1016 krb5_free_principal(context
, principal
);
1021 krb5_cc_close(context
, cache
);
1025 krb5_cc_cache_end_seq_get(context
, cursor
);
1027 if (cache
== NULL
) {
1030 krb5_unparse_name(context
, client
, &str
);
1032 krb5_set_error_string(context
, "Principal %s not found in a "
1033 "credential cache", str
? str
: "<out of memory>");
1036 return KRB5_CC_NOTFOUND
;
1044 * Move the content from one credential cache to another. The
1045 * operation is an atomic switch.
1047 * @param context a Keberos context
1048 * @param from the credential cache to move the content from
1049 * @param to the credential cache to move the content to
1051 * @return On sucess, from is freed. On failure, error code is
1052 * returned and from and to are both still allocated.
1054 * @ingroup krb5_ccache
1058 krb5_cc_move(krb5_context context
, krb5_ccache from
, krb5_ccache to
)
1060 krb5_error_code ret
;
1062 if (strcmp(from
->ops
->prefix
, to
->ops
->prefix
) != 0) {
1063 krb5_set_error_string(context
, "Moving credentials between diffrent "
1064 "types not yet supported");
1065 return KRB5_CC_NOSUPP
;
1068 ret
= (*to
->ops
->move
)(context
, from
, to
);
1070 memset(from
, 0, sizeof(*from
));