1 /* -*- mode: c; c-basic-offset: 4; indent-tabs-mode: nil -*- */
5 * Copyright 1990 by the Massachusetts Institute of Technology.
7 * Export of this software from the United States of America may
8 * require a specific license from the United States Government.
9 * It is the responsibility of any person or organization contemplating
10 * export to obtain such a license before exporting.
12 * WITHIN THAT CONSTRAINT, permission to use, copy, modify, and
13 * distribute this software and its documentation for any purpose and
14 * without fee is hereby granted, provided that the above copyright
15 * notice appear in all copies and that both that copyright notice and
16 * this permission notice appear in supporting documentation, and that
17 * the name of M.I.T. not be used in advertising or publicity pertaining
18 * to distribution of the software without specific, written prior
19 * permission. Furthermore if you modify this software you must label
20 * your software as modified software and not distribute it in such a
21 * fashion that it might be confused with the original M.I.T. software.
22 * M.I.T. makes no representations about the suitability of
23 * this software for any purpose. It is provided "as is" without express
24 * or implied warranty.
27 * Policy decision routines for KDC.
30 * Copyright (c) 2006-2008, Novell, Inc.
31 * All rights reserved.
33 * Redistribution and use in source and binary forms, with or without
34 * modification, are permitted provided that the following conditions are met:
36 * * Redistributions of source code must retain the above copyright notice,
37 * this list of conditions and the following disclaimer.
38 * * Redistributions in binary form must reproduce the above copyright
39 * notice, this list of conditions and the following disclaimer in the
40 * documentation and/or other materials provided with the distribution.
41 * * The copyright holder's name is not used to endorse or promote products
42 * derived from this software without specific prior written permission.
44 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
45 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
46 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
47 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
48 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
49 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
50 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
51 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
52 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
53 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
54 * POSSIBILITY OF SUCH DAMAGE.
62 against_local_policy_as(register krb5_kdc_req *request, krb5_db_entry client,
63 krb5_db_entry server, krb5_timestamp kdc_time,
64 const char **status, krb5_data *e_data)
67 kdb_check_policy_as_req req;
68 kdb_check_policy_as_rep rep;
73 /* An AS request must include the addresses field */
74 if (request->addresses == 0) {
75 *status = "NO ADDRESS";
76 return KRB5KDC_ERR_POLICY;
80 memset(&req, 0, sizeof(req));
81 memset(&rep, 0, sizeof(rep));
83 req.request = request;
86 req.kdc_time = kdc_time;
88 req_data.data = (void *)&req;
89 req_data.length = sizeof(req);
91 rep_data.data = (void *)&rep;
92 rep_data.length = sizeof(rep);
94 code = krb5_db_invoke(kdc_context,
95 KRB5_KDB_METHOD_CHECK_POLICY_AS,
98 if (code == KRB5_KDB_DBTYPE_NOSUP)
101 *status = rep.status;
102 *e_data = rep.e_data;
105 code -= ERROR_TABLE_BASE_krb5;
106 if (code < 0 || code > 128)
107 code = KRB_ERR_GENERIC;
114 * This is where local policy restrictions for the TGS should placed.
117 against_local_policy_tgs(register krb5_kdc_req *request, krb5_db_entry server,
118 krb5_ticket *ticket, const char **status,
121 krb5_error_code code;
122 kdb_check_policy_tgs_req req;
123 kdb_check_policy_tgs_rep rep;
129 * For example, if your site wants to disallow ticket forwarding,
130 * you might do something like this:
133 if (isflagset(request->kdc_options, KDC_OPT_FORWARDED)) {
134 *status = "FORWARD POLICY";
135 return KRB5KDC_ERR_POLICY;
139 memset(&req, 0, sizeof(req));
140 memset(&rep, 0, sizeof(rep));
142 req.request = request;
143 req.server = &server;
146 req_data.data = (void *)&req;
147 req_data.length = sizeof(req);
149 rep_data.data = (void *)&rep;
150 rep_data.length = sizeof(rep);
152 code = krb5_db_invoke(kdc_context,
153 KRB5_KDB_METHOD_CHECK_POLICY_TGS,
156 if (code == KRB5_KDB_DBTYPE_NOSUP)
159 *status = rep.status;
160 *e_data = rep.e_data;
163 code -= ERROR_TABLE_BASE_krb5;
164 if (code < 0 || code > 128)
165 code = KRB_ERR_GENERIC;