|
Packit |
fd8b60 |
/* -*- mode: c; c-basic-offset: 4; indent-tabs-mode: nil -*- */
|
|
Packit |
fd8b60 |
/* lib/kadm5/srv/pwqual_princ.c */
|
|
Packit |
fd8b60 |
/*
|
|
Packit |
fd8b60 |
* Copyright (C) 2010 by the Massachusetts Institute of Technology.
|
|
Packit |
fd8b60 |
* All rights reserved.
|
|
Packit |
fd8b60 |
*
|
|
Packit |
fd8b60 |
* Export of this software from the United States of America may
|
|
Packit |
fd8b60 |
* require a specific license from the United States Government.
|
|
Packit |
fd8b60 |
* It is the responsibility of any person or organization contemplating
|
|
Packit |
fd8b60 |
* export to obtain such a license before exporting.
|
|
Packit |
fd8b60 |
*
|
|
Packit |
fd8b60 |
* WITHIN THAT CONSTRAINT, permission to use, copy, modify, and
|
|
Packit |
fd8b60 |
* distribute this software and its documentation for any purpose and
|
|
Packit |
fd8b60 |
* without fee is hereby granted, provided that the above copyright
|
|
Packit |
fd8b60 |
* notice appear in all copies and that both that copyright notice and
|
|
Packit |
fd8b60 |
* this permission notice appear in supporting documentation, and that
|
|
Packit |
fd8b60 |
* the name of M.I.T. not be used in advertising or publicity pertaining
|
|
Packit |
fd8b60 |
* to distribution of the software without specific, written prior
|
|
Packit |
fd8b60 |
* permission. Furthermore if you modify this software you must label
|
|
Packit |
fd8b60 |
* your software as modified software and not distribute it in such a
|
|
Packit |
fd8b60 |
* fashion that it might be confused with the original M.I.T. software.
|
|
Packit |
fd8b60 |
* M.I.T. makes no representations about the suitability of
|
|
Packit |
fd8b60 |
* this software for any purpose. It is provided "as is" without express
|
|
Packit |
fd8b60 |
* or implied warranty.
|
|
Packit |
fd8b60 |
*/
|
|
Packit |
fd8b60 |
|
|
Packit |
fd8b60 |
/* Password quality module to check passwords against principal components */
|
|
Packit |
fd8b60 |
|
|
Packit |
fd8b60 |
#include "k5-int.h"
|
|
Packit |
fd8b60 |
#include <krb5/pwqual_plugin.h>
|
|
Packit |
fd8b60 |
#include "server_internal.h"
|
|
Packit |
fd8b60 |
|
|
Packit |
fd8b60 |
static krb5_error_code
|
|
Packit |
fd8b60 |
princ_check(krb5_context context, krb5_pwqual_moddata data,
|
|
Packit |
fd8b60 |
const char *password, const char *policy_name,
|
|
Packit |
fd8b60 |
krb5_principal princ, const char **languages)
|
|
Packit |
fd8b60 |
{
|
|
Packit |
fd8b60 |
int i, n;
|
|
Packit |
fd8b60 |
char *cp;
|
|
Packit |
fd8b60 |
|
|
Packit |
fd8b60 |
/* Don't check for principals with no password policy. */
|
|
Packit |
fd8b60 |
if (policy_name == NULL)
|
|
Packit |
fd8b60 |
return 0;
|
|
Packit |
fd8b60 |
|
|
Packit |
fd8b60 |
/* Check against components of the principal. */
|
|
Packit |
fd8b60 |
n = krb5_princ_size(handle->context, princ);
|
|
Packit |
fd8b60 |
cp = krb5_princ_realm(handle->context, princ)->data;
|
|
Packit |
fd8b60 |
if (strcasecmp(cp, password) == 0)
|
|
Packit |
fd8b60 |
return KADM5_PASS_Q_DICT;
|
|
Packit |
fd8b60 |
for (i = 0; i < n; i++) {
|
|
Packit |
fd8b60 |
cp = krb5_princ_component(handle->context, princ, i)->data;
|
|
Packit |
fd8b60 |
if (strcasecmp(cp, password) == 0) {
|
|
Packit |
fd8b60 |
k5_setmsg(context, KADM5_PASS_Q_DICT,
|
|
Packit |
fd8b60 |
_("Password may not match principal name"));
|
|
Packit |
fd8b60 |
return KADM5_PASS_Q_DICT;
|
|
Packit |
fd8b60 |
}
|
|
Packit |
fd8b60 |
}
|
|
Packit |
fd8b60 |
|
|
Packit |
fd8b60 |
return 0;
|
|
Packit |
fd8b60 |
}
|
|
Packit |
fd8b60 |
|
|
Packit |
fd8b60 |
krb5_error_code
|
|
Packit |
fd8b60 |
pwqual_princ_initvt(krb5_context context, int maj_ver, int min_ver,
|
|
Packit |
fd8b60 |
krb5_plugin_vtable vtable)
|
|
Packit |
fd8b60 |
{
|
|
Packit |
fd8b60 |
krb5_pwqual_vtable vt;
|
|
Packit |
fd8b60 |
|
|
Packit |
fd8b60 |
if (maj_ver != 1)
|
|
Packit |
fd8b60 |
return KRB5_PLUGIN_VER_NOTSUPP;
|
|
Packit |
fd8b60 |
vt = (krb5_pwqual_vtable)vtable;
|
|
Packit |
fd8b60 |
vt->name = "princ";
|
|
Packit |
fd8b60 |
vt->check = princ_check;
|
|
Packit |
fd8b60 |
return 0;
|
|
Packit |
fd8b60 |
}
|