2 Unix SMB/CIFS implementation.
4 Samba KDB plugin for MIT Kerberos
6 Copyright (c) 2010 Simo Sorce <idra@samba.org>.
7 Copyright (c) 2014 Andreas Schneider <asn@samba.org>
9 This program is free software; you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation; either version 3 of the License, or
12 (at your option) any later version.
14 This program is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details.
19 You should have received a copy of the GNU General Public License
20 along with this program. If not, see <http://www.gnu.org/licenses/>.
25 #include "system/kerberos.h"
30 #include "kdc/mit_samba.h"
31 #include "kdb_samba.h"
33 struct mit_samba_context
*ks_get_context(krb5_context kcontext
)
38 code
= krb5_db_get_context(kcontext
, &db_ctx
);
43 return (struct mit_samba_context
*)db_ctx
;
46 bool ks_data_eq_string(krb5_data d
, const char *s
)
50 if (d
.length
!= strlen(s
) || d
.length
== 0) {
54 rc
= memcmp(d
.data
, s
, d
.length
);
62 krb5_data
ks_make_data(void *data
, unsigned int len
)
73 krb5_boolean
ks_is_kadmin(krb5_context context
,
74 krb5_const_principal princ
)
76 return krb5_princ_size(context
, princ
) >= 1 &&
77 ks_data_eq_string(princ
->data
[0], "kadmin");
80 krb5_boolean
ks_is_kadmin_history(krb5_context context
,
81 krb5_const_principal princ
)
83 return krb5_princ_size(context
, princ
) == 2 &&
84 ks_data_eq_string(princ
->data
[0], "kadmin") &&
85 ks_data_eq_string(princ
->data
[1], "history");
88 krb5_boolean
ks_is_kadmin_changepw(krb5_context context
,
89 krb5_const_principal princ
)
91 return krb5_princ_size(context
, princ
) == 2 &&
92 ks_data_eq_string(princ
->data
[0], "kadmin") &&
93 ks_data_eq_string(princ
->data
[1], "changepw");
96 krb5_boolean
ks_is_kadmin_admin(krb5_context context
,
97 krb5_const_principal princ
)
99 return krb5_princ_size(context
, princ
) == 2 &&
100 ks_data_eq_string(princ
->data
[0], "kadmin") &&
101 ks_data_eq_string(princ
->data
[1], "admin");