diff options
author | John Kohl <jtkohl@mit.edu> | 1990-03-27 11:54:33 +0000 |
---|---|---|
committer | John Kohl <jtkohl@mit.edu> | 1990-03-27 11:54:33 +0000 |
commit | 2a180e32203e16c7e12d86c457d2df52e9151d2c (patch) | |
tree | 8389c16e6993022120034708eb881391b085b390 /src | |
parent | 517f024834778e4f6010522fe584ae0d2f8fb905 (diff) | |
download | krb5-2a180e32203e16c7e12d86c457d2df52e9151d2c.tar.gz krb5-2a180e32203e16c7e12d86c457d2df52e9151d2c.tar.xz krb5-2a180e32203e16c7e12d86c457d2df52e9151d2c.zip |
*** empty log message ***
git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@423 dc483132-0cff-0310-8789-dd5450dbe970
Diffstat (limited to 'src')
-rw-r--r-- | src/lib/krb5/krb/copy_creds.c | 74 | ||||
-rw-r--r-- | src/lib/krb5/krb/copy_data.c | 43 | ||||
-rw-r--r-- | src/lib/krb5/krb/copy_princ.c | 49 |
3 files changed, 166 insertions, 0 deletions
diff --git a/src/lib/krb5/krb/copy_creds.c b/src/lib/krb5/krb/copy_creds.c new file mode 100644 index 0000000000..46e9a1c376 --- /dev/null +++ b/src/lib/krb5/krb/copy_creds.c @@ -0,0 +1,74 @@ +/* + * $Source$ + * $Author$ + * + * Copyright 1990 by the Massachusetts Institute of Technology. + * + * For copying and distribution information, please see the file + * <krb5/mit-copyright.h>. + * + * krb5_copy_cred() + */ + +#if !defined(lint) && !defined(SABER) +static char rcsid_copy_cred_c [] = +"$Id$"; +#endif /* !lint & !SABER */ + +#include <krb5/copyright.h> + +#include <krb5/krb5.h> + +#include <krb5/ext-proto.h> + +#include <errno.h> + + +/* + * Copy credentials, allocating fresh storage where needed. + */ + +krb5_error_code +krb5_copy_cred(incred, outcred) +krb5_creds *incred, **outcred; +{ + krb5_creds *tempcred; + krb5_error_code retval; + krb5_data *scratch; + + if (!(tempcred = (krb5_creds *)malloc(sizeof(*tempcred)))) + return ENOMEM; + + *tempcred = *incred; /* copy everything quickly */ + if (retval = krb5_copy_principal(incred->client, &tempcred->client)) + goto cleanlast; + if (retval = krb5_copy_principal(incred->server, &tempcred->server)) + goto cleanclient; + if (retval = krb5_copy_keyblock(&incred->keyblock, &tempcred->keyblock)) + goto cleanserver; + if (retval = krb5_copy_data(&incred->ticket, &scratch)) + goto cleanblock; + tempcred->ticket = *scratch; + free((char *)scratch); + if (retval = krb5_copy_data(&incred->second_ticket, + &scratch)) + goto cleanticket; + + tempcred->second_ticket = *scratch; + free((char *)scratch); + + *outcred = tempcred; + return 0; + + cleanticket: + free(tempcred->ticket.data); + cleanblock: + free((char *)tempcred->keyblock.contents); + cleanserver: + krb5_free_principal(tempcred->server); + cleanclient: + krb5_free_principal(tempcred->client); + cleanlast: + free((char *)tempcred); + return retval; +} diff --git a/src/lib/krb5/krb/copy_data.c b/src/lib/krb5/krb/copy_data.c new file mode 100644 index 0000000000..7a84e5f8cf --- /dev/null +++ b/src/lib/krb5/krb/copy_data.c @@ -0,0 +1,43 @@ +/* + * $Source$ + * $Author$ + * + * Copyright 1990 by the Massachusetts Institute of Technology. + * + * For copying and distribution information, please see the file + * <krb5/mit-copyright.h>. + * + * krb5_copy_data() + */ + +#if !defined(lint) && !defined(SABER) +static char rcsid_copy_data_c[] = +"$Id$"; +#endif /* !lint & !SABER */ + +#include <krb5/copyright.h> +#include <krb5/krb5.h> +#include <errno.h> +#include <krb5/ext-proto.h> + +/* + * Copy a data structure, with fresh allocation. + */ +krb5_error_code +krb5_copy_data(indata, outdata) +krb5_data *indata, **outdata; +{ + krb5_data *tempdata; + + if (!(tempdata = (krb5_data *)malloc(sizeof(*tempdata)))) + return ENOMEM; + + *tempdata = *indata; + if (!(tempdata->data = malloc(tempdata->length))) { + free((char *)tempdata); + return ENOMEM; + } + bcopy((char *)indata->data, (char *)tempdata->data, tempdata->length); + *outdata = tempdata; + return 0; +} diff --git a/src/lib/krb5/krb/copy_princ.c b/src/lib/krb5/krb/copy_princ.c new file mode 100644 index 0000000000..c450b90cc8 --- /dev/null +++ b/src/lib/krb5/krb/copy_princ.c @@ -0,0 +1,49 @@ +/* + * $Source$ + * $Author$ + * + * Copyright 1990 by the Massachusetts Institute of Technology. + * + * For copying and distribution information, please see the file + * <krb5/mit-copyright.h>. + * + * krb5_copy_principal() + */ + +#if !defined(lint) && !defined(SABER) +static char rcsid_copy_princ_c[] = +"$Id$"; +#endif /* !lint & !SABER */ + +#include <krb5/copyright.h> +#include <krb5/krb5.h> +#include <errno.h> + +#include <krb5/ext-proto.h> + +/* + * Copy a principal structure, with fresh allocation. + */ +krb5_error_code +krb5_copy_principal(inprinc, outprinc) +krb5_principal inprinc, *outprinc; +{ + krb5_error_code retval; + krb5_principal tempprinc; + register int nelems; + + for (nelems = 0; inprinc[nelems]; nelems++); + + /* one more for a null terminated list */ + if (!(tempprinc = (krb5_principal) calloc(nelems+1, sizeof(krb5_data *)))) + return ENOMEM; + + for (nelems = 0; inprinc[nelems]; nelems++) + if (retval = krb5_copy_data(inprinc[nelems], &tempprinc[nelems])) { + krb5_free_principal(tempprinc); + return ENOMEM; + } + + *outprinc = tempprinc; + return 0; +} |