diff options
| author | Ken Raeburn <raeburn@mit.edu> | 2006-06-24 02:39:52 +0000 |
|---|---|---|
| committer | Ken Raeburn <raeburn@mit.edu> | 2006-06-24 02:39:52 +0000 |
| commit | f9b6c2de5c160844e2fb5cb8ea7c6ef4292ee4c4 (patch) | |
| tree | e8b1cc02464414e5d5fc15807e030b5570f4e115 /src/util/profile | |
| parent | 036d40a6c10d88b9d6b8507ae1319790d9d8d61b (diff) | |
| download | krb5-f9b6c2de5c160844e2fb5cb8ea7c6ef4292ee4c4.tar.gz krb5-f9b6c2de5c160844e2fb5cb8ea7c6ef4292ee4c4.tar.xz krb5-f9b6c2de5c160844e2fb5cb8ea7c6ef4292ee4c4.zip | |
Fix krb5_get_profile to create a new profile duplicating the list of
files from the one in the provided context, instead of constructing
and checking the file list from scratch. Uses a new function in the
profile library, not put into the public API yet.
* util/profile/prof_init.c (profile_copy): New function.
* util/profile/prof_int.h (profile_copy): Declare it.
* lib/krb5/os/Makefile.in (LOCALINCLUDES): Look in the profile source dir.
* lib/krb5/os/init_os_ctx.c (krb5_get_profile): Replace all the previous code
with a call to profile_copy.
ticket: 3925
git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@18209 dc483132-0cff-0310-8789-dd5450dbe970
Diffstat (limited to 'src/util/profile')
| -rw-r--r-- | src/util/profile/prof_init.c | 33 | ||||
| -rw-r--r-- | src/util/profile/prof_int.h | 2 |
2 files changed, 35 insertions, 0 deletions
diff --git a/src/util/profile/prof_init.c b/src/util/profile/prof_init.c index 888d46d0a6..e5c6f9c8c5 100644 --- a/src/util/profile/prof_init.c +++ b/src/util/profile/prof_init.c @@ -66,6 +66,39 @@ profile_init(const_profile_filespec_t *files, profile_t *ret_profile) return 0; } +#define COUNT_LINKED_LIST(COUNT, PTYPE, START, FIELD) \ + { \ + int cll_counter = 0; \ + PTYPE cll_ptr = (START); \ + while (cll_ptr != NULL) { \ + cll_counter++; \ + cll_ptr = cll_ptr->FIELD; \ + } \ + (COUNT) = cll_counter; \ + } + +errcode_t KRB5_CALLCONV +profile_copy(profile_t old_profile, profile_t *new_profile) +{ + size_t size, i; + const_profile_filespec_t *files; + prf_file_t file; + errcode_t err; + + /* The fields we care about are read-only after creation, so + no locking is needed. */ + COUNT_LINKED_LIST (size, prf_file_t, old_profile->first_file, next); + files = malloc ((size+1) * sizeof(*files)); + if (files == NULL) + return errno; + for (i = 0, file = old_profile->first_file; i < size; i++, file = file->next) + files[i] = file->data->filespec; + files[size] = NULL; + err = profile_init (files, new_profile); + free (files); + return err; +} + errcode_t KRB5_CALLCONV profile_init_path(const_profile_filespec_list_t filepath, profile_t *ret_profile) diff --git a/src/util/profile/prof_int.h b/src/util/profile/prof_int.h index 70a8dd9208..d6349afd72 100644 --- a/src/util/profile/prof_int.h +++ b/src/util/profile/prof_int.h @@ -192,6 +192,8 @@ errcode_t profile_rename_node /* prof_file.c */ +errcode_t KRB5_CALLCONV profile_copy (profile_t, profile_t *); + errcode_t profile_open_file (const_profile_filespec_t file, prf_file_t *ret_prof); |
