ser_ktf.c revision 7c478bd95313f5f23a4c958a745db2134aa03244
/*
* Copyright 2005 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
/*
*
* Copyright 1995 by the Massachusetts Institute of Technology.
* All Rights Reserved.
*
* Export of this software from the United States of America may
* require a specific license from the United States Government.
* It is the responsibility of any person or organization contemplating
* export to obtain such a license before exporting.
*
* WITHIN THAT CONSTRAINT, permission to use, copy, modify, and
* distribute this software and its documentation for any purpose and
* without fee is hereby granted, provided that the above copyright
* notice appear in all copies and that both that copyright notice and
* this permission notice appear in supporting documentation, and that
* the name of M.I.T. not be used in advertising or publicity pertaining
* to distribution of the software without specific, written prior
* permission. Furthermore if you modify this software you must label
* your software as modified software and not distribute it in such a
* fashion that it might be confused with the original M.I.T. software.
* M.I.T. makes no representations about the suitability of
* this software for any purpose. It is provided "as is" without express
* or implied warranty.
*
*/
/*
* ser_ktf.c - Serialize keytab file context for subsequent reopen.
*/
#include <k5-int.h>
#include "ktfile.h"
static const char ktfile_def_name[] = ".";
/*
* Routines to deal with externalizing krb5_keytab for [WR]FILE: variants.
* krb5_ktf_keytab_size();
* krb5_ktf_keytab_externalize();
* krb5_ktf_keytab_internalize();
*/
/*
* Serialization entry for this type.
*/
const krb5_ser_entry krb5_ktfile_ser_entry = {
KV5M_KEYTAB, /* Type */
krb5_ktf_keytab_size, /* Sizer routine */
krb5_ktf_keytab_externalize, /* Externalize routine */
krb5_ktf_keytab_internalize /* Internalize routine */
};
/*
* krb5_ktf_keytab_size() - Determine the size required to externalize
* this krb5_keytab variant.
*/
/*ARGSUSED*/
static krb5_error_code
{
/*
* Saving FILE: variants of krb5_keytab requires at minimum:
* krb5_int32 for KV5M_KEYTAB
* krb5_int32 for length of keytab name.
* krb5_int32 for file status.
* krb5_int32 for file position.
* krb5_int32 for file position.
* krb5_int32 for version.
* krb5_int32 for KV5M_KEYTAB
*/
/*
* The keytab name is formed as follows:
* <prefix>:<name>
* If there's no name, we use a default name so that we have something
* to call krb5_keytab_resolve with.
*/
kret = 0;
if (!kret)
}
return(kret);
}
/*
* krb5_ktf_keytab_externalize() - Externalize the krb5_keytab.
*/
static krb5_error_code
krb5_octet **buffer;
{
krb5_octet *bp;
char *ktname;
char *fnamep;
required = 0;
/* Our identifier */
file_is_open = 0;
file_pos[0] = 0;
file_pos[1] = 0;
/* Calculate the length of the name */
else
fnamep = (char *) ktfile_def_name;
/* Format the keytab name. */
else
/* Fill in the file-specific keytab information. */
if (ktdata) {
long fpos;
int fflags = 0;
file_is_open = 1;
#if 0
if (fflags > 0)
#else
file_is_open = 0;
#endif
#else
#endif
#if SIZEOF_LONG == 4
#else /* SIZEOF_LONG == 4 */
#endif /* SIZEOF_LONG == 4 */
}
}
/* Put the length of the file name */
/* Put the name */
/* Put the file open flag */
/* Put the file position */
/* Put the version */
/* Put the trailer */
kret = 0;
}
}
}
return(kret);
}
/*
* krb5_ktf_keytab_internalize() - Internalize the krb5_ktf_keytab.
*/
static krb5_error_code
krb5_octet **buffer;
{
krb5_octet *bp;
char *ktname;
/* Read our magic number */
ibuf = 0;
if (ibuf == KV5M_KEYTAB) {
/* Get the length of the keytab name */
if (!kret &&
if (!kret) {
if (!ktdata) {
/* XXX */
else
}
if (ktdata) {
(void) krb5_ser_unpack_int32(&file_is_open,
(void) krb5_ser_unpack_int32(&foffbuf[0],
if (ibuf == KV5M_KEYTAB) {
if (file_is_open) {
int fmode;
long fpos;
#else
fmode = 0;
#endif
if (fmode)
keytab);
else
keytab);
if (!kret) {
#if SIZEOF_LONG == 4
#else /* SIZEOF_LONG == 4 */
#endif /* SIZEOF_LONG == 4 */
}
}
kret = 0;
}
else
}
}
if (kret) {
if (KTFILENAME(keytab))
}
}
else {
}
}
}
}
return(kret);
}