l_good_lic_key(
LM_HANDLE * job,
CONFIG * conf,
VENDORCODE * key)
{
VENDORCODE vc;
int ok = 0;
char * code = NULL;
int str_res = 0;
char * sdate = NULL;
L_KEY_FILTER *kf = 0;
if ((!job->flags & LM_FLAG_SLOW_VERIFY)
&& (conf->L_CONF_FLAGS & L_CONF_FL_VERIFIED))
{
return 1;
}
memcpy(&vc, key, sizeof(vc));
if (! (job->flags & LM_FLAG_CLEAR_VKEYS))
l_xorname(job->vendor, &vc);
l_sg(job, job->vendor, &vc);
#if 1
if ((job->L_SIGN_LEVEL) && !conf->lc_keylist)
{
char context[50];
char num[2];
num[1] = 0; /* null terminator */
#ifdef MONTAVISTA
num[0] = (char)((char)job->L_SIGN_LEVEL + '0');
#else
num[0] = (char)((char)job->L_SIGN_LEVEL + '0');
#endif /* MONTAVISTA */
sprintf(context, "SIGN%s=", num);
LM_SET_ERROR(job, LM_SIGN_REQ, 582, 0, context, LM_ERRMASK_ALL);
goto exit_good_lic_key;
}
#endif
if (conf->lc_keylist && job->L_SIGN_LEVEL)
{
LM_KEYLIST *kl;
for (kf = (L_KEY_FILTER *)job->key_filters;
kf && (kf->sign_level != (int)job->L_SIGN_LEVEL);
kf = kf->next)
;
/*
* Find the last KEY_FILTER for this job
*/
if (kf)
{
int foundkl = 0;
for (kl = conf->lc_keylist; kl; kl = kl->next)
{
char * stdate = NULL;
if ((kf->sign_level != kl->sign_level))
continue;
foundkl = 1;
job->lc_this_keylist = kl;
code = l_crypt_private(job, conf, stdate, &vc);
job->lc_this_keylist = 0;
if (code && *code)
{
ok = 1;
break;
}
}
if (!ok)
{
if (!kl && !foundkl)
{
char context[50] = {'\0'};
char num[2] = {'\0'};
num[1] = 0; /* null terminator */
num[0] = kf->sign_level > 1 ?
kf->sign_level + '0': 0;
sprintf(context, "SIGN%s=", num);
LM_SET_ERROR(job, LM_SIGN_REQ, 526, 0,
context, LM_ERRMASK_ALL);
}
else
{
LM_SET_ERRNO(job, LM_BADCODE, 523, 0);
}
}
}
#if 0
else
ok = 1;
#endif
}
if (!kf)
{
if (!(conf->lc_keylist && job->L_SIGN_LEVEL))
{
job->flags |= LM_FLAG_MAKE_OLD_KEY;
}
sdate = l_extract_date(job, conf->code);
code = l_crypt_private(job, conf, sdate, &vc);
if (!(conf->lc_keylist && job->L_SIGN_LEVEL))
{
job->flags &= ~LM_FLAG_MAKE_OLD_KEY;
}
if (job->user_crypt_filter)
{
if (!code || !*code)
str_res = 1;
}
else
{
if (conf->lc_keylist && job->L_SIGN_LEVEL)
{
if (!code || !*code || !*conf->code) /*P5552 */
str_res = 1;
else
STRNCMP(code, conf->lc_sign, MAX_CRYPT_LEN,
str_res);
}
else
{
if (!code || !*code || !*conf->code) /*P5552 */
str_res = 1;
else
STRNCMP(code, conf->code, MAX_CRYPT_LEN,
str_res);
}
}
if (str_res)
{
/*
* If user has set alternate encryption seeds,
* try those also.
*/
if (job->options->alt_vendorcode.data[0] ||
job->options->alt_vendorcode.data[1])
{
VENDORCODE altvc;
VENDORCODE *v = &job->options->alt_vendorcode;
memcpy((char *)&altvc, (char *)v, sizeof(altvc));
l_sg(job, job->vendor, &altvc);
code = l_crypt_private(job, conf, sdate, &altvc);
ok = 1; /* assume success */
if (!code || !*code || !*conf->code) /*P5552*/
ok = 0;
else
{
STRNCMP(code, conf->code, MAX_CRYPT_LEN, str_res);
if (str_res)
ok = 0; /* failed */
}
}
if (!ok)
{
if (l_keyword_eq(job, job->vendor, conf->daemon))
{
LM_SET_ERRNO(job, LM_BADCODE, 130, 0);
}
}
}
else
ok = 1;
}
exit_good_lic_key:
if (!ok && conf->lc_future_minor)
LM_SET_ERRNO(job, LM_FUTURE_FILE, conf->lc_future_minor, 0);
if (ok)
conf->L_CONF_FLAGS |= L_CONF_FL_VERIFIED;
else
conf->L_CONF_FLAGS |= L_CONF_FL_REJECT;
return ok;
}
所以KeyFilter是干什么的