/*
* WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING
*
* Openvision retains the copyright to derivative works of
* this source code. Do *NOT* create a derivative of this
* source code before consulting with your legal department.
* Do *NOT* integrate *ANY* of this source code into another
* product before consulting with your legal department.
*
* For further information, read the top-level Openvision
* copyright which is contained in the top-level MIT Kerberos
* copyright.
*
* WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING
*
*/
/*
* Copyright 1993 OpenVision Technologies, Inc., All Rights Reserved
*
* $Header$
*/
#if !defined(lint) && !defined(__CODECENTER__)
#endif
#include "server_internal.h"
#include <stdlib.h>
#include <errno.h>
/*
* Function: kadm5_create_policy
*
* Purpose: Create Policies in the policy DB.
*
* Arguments:
* entry (input) The policy entry to be written out to the DB.
* mask (input) Specifies which fields in entry are to ge written out
* and which get default values.
* <return value> 0 if successful otherwise an error code is returned.
*
* Requires:
* Entry must be a valid principal entry, and mask have a valid value.
*
* Effects:
* Verifies that mask does not specify that the refcount should
* be set as part of the creation, and calls
* kadm5_create_policy_internal. If the refcount *is*
* specified, returns KADM5_BAD_MASK.
*/
{
if (mask & KADM5_REF_COUNT)
return KADM5_BAD_MASK;
else
}
/*
* Function: kadm5_create_policy_internal
*
* Purpose: Create Policies in the policy DB.
*
* Arguments:
* entry (input) The policy entry to be written out to the DB.
* mask (input) Specifies which fields in entry are to ge written out
* and which get default values.
* <return value> 0 if successful otherwise an error code is returned.
*
* Requires:
* Entry must be a valid principal entry, and mask have a valid value.
*
* Effects:
* Writes the data to the database, and does a database sync if
* successful.
*
*/
{
int ret;
char *p;
return EINVAL;
return KADM5_BAD_POLICY;
if (!(mask & KADM5_POLICY))
return KADM5_BAD_MASK;
while(*p != '\0') {
if(*p < ' ' || *p > '~')
return KADM5_BAD_POLICY;
else
p++;
}
if (!(mask & KADM5_PW_MAX_LIFE))
pent.pw_max_life = 0;
else
if (!(mask & KADM5_PW_MIN_LIFE))
pent.pw_min_life = 0;
else {
if((mask & KADM5_PW_MAX_LIFE)) {
return KADM5_BAD_MIN_PASS_LIFE;
}
}
if (!(mask & KADM5_PW_MIN_LENGTH))
else {
return KADM5_BAD_LENGTH;
}
if (!(mask & KADM5_PW_MIN_CLASSES))
else {
return KADM5_BAD_CLASS;
}
if (!(mask & KADM5_PW_HISTORY_NUM))
else {
return KADM5_BAD_HISTORY;
else
}
if (!(mask & KADM5_REF_COUNT))
pent.policy_refcnt = 0;
else
return ret;
else
return KADM5_OK;
}
{
int ret;
return EINVAL;
return KADM5_BAD_POLICY;
return ret;
if( cnt != 1 )
return KADM5_UNK_POLICY;
if(entry->policy_refcnt != 0) {
return KADM5_POLICY_REF;
}
return ret;
else
return KADM5_OK;
}
{
if (mask & KADM5_REF_COUNT)
return KADM5_BAD_MASK;
else
}
{
int ret;
return EINVAL;
return KADM5_BAD_POLICY;
if((mask & KADM5_POLICY))
return KADM5_BAD_MASK;
return ret;
if (cnt != 1)
return KADM5_UNK_POLICY;
if ((mask & KADM5_PW_MAX_LIFE))
if ((mask & KADM5_PW_MIN_LIFE)) {
return KADM5_BAD_MIN_PASS_LIFE;
}
}
if ((mask & KADM5_PW_MIN_LENGTH)) {
return KADM5_BAD_LENGTH;
}
}
if ((mask & KADM5_PW_MIN_CLASSES)) {
return KADM5_BAD_CLASS;
}
}
if ((mask & KADM5_PW_HISTORY_NUM)) {
return KADM5_BAD_HISTORY;
}
}
if ((mask & KADM5_REF_COUNT))
return ret;
}
{
int ret;
/*
* In version 1, entry is a pointer to a kadm5_policy_ent_t that
* should be filled with allocated memory.
*/
*entry_orig = NULL;
entry = &entry_local;
}
return EINVAL;
return KADM5_BAD_POLICY;
return ret;
if( cnt != 1 )
return KADM5_UNK_POLICY;
return ENOMEM;
}
return ENOMEM;
}
*entry_orig = new;
}
return KADM5_OK;
}