The server_get_identity( ) routine sets up a new server identity.
/******
*
* server_get_identity -- Establish a new server identity with valid
* credentials. This includes setting up a key
* management thread.
*
*
* Called from main().
*
******/
void server_get_identity(
unsigned_char_p_t prin_name, /* Server principal name. */
sec_login_handle_t *login_context, /* Returns
server's login context. */
unsigned_char_p_t keytab, /* Local key file. */
unsigned32 *status)
{
pthread_t keymgr;
sec_passwd_rec_t *keydata;
sec_login_auth_src_t auth_src;
boolean32 reset_pwd;
*status = error_status_ok;
/* Spin off thread to manage key for specified principal... */
if (pthread_create(&keymgr, /*
Thread handle. */
pthread_attr_default, /* Specifies default thread */
/*
attributes. */
(pthread_startroutine_t)managekey, /* Start routine */
/* see above.
*/
(void*)prin_name)) /* Argument to pass to start */
/* routine: server
principal */
/* name. */
{
dce_svc_printf(CANNOT_MANAGE_KEYS_MSG);
return;
}
/* Create a context and get the login context...
*/
sec_login_setup_identity(prin_name,
sec_login_no_flags,
login_context,
status);
/* Get secret key from the keytab file... */
sec_key_mgmt_get_key(rpc_c_authn_dce_secret,
keytab,
prin_name,
0,
(void**)&keydata,
status);
/* Validate the login context... */
sec_login_validate_identity(*login_context,
keydata,
&reset_pwd,
&auth_src,
status);
/* Finally, set the context...
*/
sec_login_set_context(*login_context, status);
}