samba-tool domain kds: add root key sub-command
[samba.git] / source3 / include / secrets.h
blob47cf40432f0c34d2052726eaa4bc9fde21a80306
1 /*
2 * Unix SMB/CIFS implementation.
3 * secrets.tdb file format info
4 * Copyright (C) Andrew Tridgell 2000
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License as published by the
8 * Free Software Foundation; either version 3 of the License, or (at your
9 * option) any later version.
11 * This program is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
14 * more details.
16 * You should have received a copy of the GNU General Public License along with
17 * this program; if not, see <http://www.gnu.org/licenses/>.
20 #ifndef _SECRETS_H
21 #define _SECRETS_H
23 #include "replace.h"
24 #include "librpc/gen_ndr/security.h"
26 /* the first one is for the hashed password (NT4 style) the latter
27 for plaintext (ADS)
29 #define SECRETS_MACHINE_ACCT_PASS "SECRETS/$MACHINE.ACC"
30 #define SECRETS_MACHINE_PASSWORD "SECRETS/MACHINE_PASSWORD"
31 #define SECRETS_MACHINE_PASSWORD_PREV "SECRETS/MACHINE_PASSWORD.PREV"
32 #define SECRETS_MACHINE_LAST_CHANGE_TIME "SECRETS/MACHINE_LAST_CHANGE_TIME"
33 #define SECRETS_MACHINE_SEC_CHANNEL_TYPE "SECRETS/MACHINE_SEC_CHANNEL_TYPE"
34 #define SECRETS_MACHINE_TRUST_ACCOUNT_NAME "SECRETS/SECRETS_MACHINE_TRUST_ACCOUNT_NAME"
35 #define SECRETS_MACHINE_DOMAIN_INFO "SECRETS/MACHINE_DOMAIN_INFO"
36 /* this one is for storing trusted domain account password */
37 #define SECRETS_DOMTRUST_ACCT_PASS "SECRETS/$DOMTRUST.ACC"
39 /* Store the principal name used for Kerberos DES key salt under this key name. */
40 #define SECRETS_SALTING_PRINCIPAL "SECRETS/SALTING_PRINCIPAL"
42 /* The domain sid and our sid are stored here even though they aren't
43 really secret. */
44 #define SECRETS_DOMAIN_SID "SECRETS/SID"
45 #define SECRETS_SAM_SID "SAM/SID"
46 #define SECRETS_PROTECT_IDS "SECRETS/PROTECT/IDS"
48 /* The domain GUID and server GUID (NOT the same) are also not secret */
49 #define SECRETS_DOMAIN_GUID "SECRETS/DOMGUID"
50 #define SECRETS_SERVER_GUID "SECRETS/GUID"
52 #define SECRETS_LDAP_BIND_PW "SECRETS/LDAP_BIND_PW"
54 #define SECRETS_LOCAL_SCHANNEL_KEY "SECRETS/LOCAL_SCHANNEL_KEY"
56 /* Authenticated user info is stored in secrets.tdb under these keys */
58 #define SECRETS_AUTH_USER "SECRETS/AUTH_USER"
59 #define SECRETS_AUTH_DOMAIN "SECRETS/AUTH_DOMAIN"
60 #define SECRETS_AUTH_PASSWORD "SECRETS/AUTH_PASSWORD"
62 struct cli_credentials;
64 /* structure for storing machine account password
65 (ie. when samba server is member of a domain */
66 struct machine_acct_pass {
67 uint8_t hash[16];
68 time_t mod_time;
72 * Format of an OpenAFS keyfile
75 #define SECRETS_AFS_MAXKEYS 8
77 struct afs_key {
78 uint32_t kvno;
79 char key[8];
82 struct afs_keyfile {
83 uint32_t nkeys;
84 struct afs_key entry[SECRETS_AFS_MAXKEYS];
87 #define SECRETS_AFS_KEYFILE "SECRETS/AFS_KEYFILE"
89 /* The following definitions come from passdb/secrets.c */
91 bool secrets_init_path(const char *private_dir);
92 bool secrets_init(void);
93 struct db_context *secrets_db_ctx(void);
94 void secrets_shutdown(void);
95 void *secrets_fetch(const char *key, size_t *size);
96 bool secrets_store(const char *key, const void *data, size_t size);
97 bool secrets_store_creds(struct cli_credentials *creds);
98 bool secrets_delete_entry(const char *key);
99 bool secrets_delete(const char *key);
101 /* The following definitions come from passdb/machine_account_secrets.c */
102 bool secrets_mark_domain_protected(const char *domain);
103 bool secrets_clear_domain_protection(const char *domain);
104 bool secrets_store_domain_sid(const char *domain, const struct dom_sid *sid);
105 bool secrets_fetch_domain_sid(const char *domain, struct dom_sid *sid);
106 bool secrets_store_domain_guid(const char *domain, const struct GUID *guid);
107 bool secrets_fetch_domain_guid(const char *domain, struct GUID *guid);
108 enum netr_SchannelType get_default_sec_channel(void);
109 bool secrets_fetch_trust_account_password_legacy(const char *domain,
110 uint8_t ret_pwd[16],
111 time_t *pass_last_set_time,
112 enum netr_SchannelType *channel);
113 bool secrets_fetch_trusted_domain_password(const char *domain, char** pwd,
114 struct dom_sid *sid, time_t *pass_last_set_time);
115 bool secrets_store_trusted_domain_password(const char* domain, const char* pwd,
116 const struct dom_sid *sid);
117 struct libnet_JoinCtx;
118 NTSTATUS secrets_store_JoinCtx(const struct libnet_JoinCtx *r);
119 struct secrets_domain_info1;
120 struct secrets_domain_info1_change;
121 void secrets_debug_domain_info(int lvl, const struct secrets_domain_info1 *info,
122 const char *name);
123 char *secrets_domain_info_string(TALLOC_CTX *mem_ctx, const struct secrets_domain_info1 *info1,
124 const char *name, bool include_secrets);
125 NTSTATUS secrets_fetch_or_upgrade_domain_info(const char *domain,
126 TALLOC_CTX *mem_ctx,
127 struct secrets_domain_info1 **pinfo);
128 NTSTATUS secrets_prepare_password_change(const char *domain, const char *dcname,
129 const char *cleartext_unix,
130 TALLOC_CTX *mem_ctx,
131 struct secrets_domain_info1 **pinfo,
132 struct secrets_domain_info1_change **pprev);
133 NTSTATUS secrets_failed_password_change(const char *change_server,
134 NTSTATUS local_status,
135 NTSTATUS remote_status,
136 const struct secrets_domain_info1 *info);
137 NTSTATUS secrets_defer_password_change(const char *change_server,
138 NTSTATUS local_status,
139 NTSTATUS remote_status,
140 const struct secrets_domain_info1 *info);
141 NTSTATUS secrets_finish_password_change(const char *change_server,
142 NTTIME change_time,
143 const struct secrets_domain_info1 *info);
144 bool secrets_delete_machine_password_ex(const char *domain, const char *realm);
145 bool secrets_delete_domain_sid(const char *domain);
146 char *secrets_fetch_prev_machine_password(const char *domain);
147 time_t secrets_fetch_pass_last_set_time(const char *domain);
148 char *secrets_fetch_machine_password(const char *domain,
149 time_t *pass_last_set_time,
150 enum netr_SchannelType *channel);
151 bool trusted_domain_password_delete(const char *domain);
152 bool secrets_store_ldap_pw(const char* dn, char* pw);
153 bool fetch_ldap_pw(char **dn, char** pw);
154 bool secrets_store_afs_keyfile(const char *cell, const struct afs_keyfile *keyfile);
155 bool secrets_fetch_afs_key(const char *cell, struct afs_key *result);
156 void secrets_fetch_ipc_userpass(char **username, char **domain, char **password);
157 bool secrets_store_generic(const char *owner, const char *key, const char *secret);
158 char *secrets_fetch_generic(const char *owner, const char *key);
160 bool secrets_store_machine_pw_sync(const char *pass, const char *oldpass, const char *domain,
161 const char *realm,
162 const char *salting_principal, uint32_t supported_enc_types,
163 const struct dom_sid *domain_sid, uint32_t last_change_time,
164 uint32_t secure_channel,
165 bool delete_join);
167 char* kerberos_standard_des_salt( void );
168 bool kerberos_secrets_store_des_salt( const char* salt );
169 char *kerberos_secrets_fetch_salt_princ(void);
171 /* The following definitions come from passdb/secrets_lsa.c */
172 NTSTATUS lsa_secret_get(TALLOC_CTX *mem_ctx,
173 const char *secret_name,
174 DATA_BLOB *secret_current,
175 NTTIME *secret_current_lastchange,
176 DATA_BLOB *secret_old,
177 NTTIME *secret_old_lastchange,
178 struct security_descriptor **sd);
179 NTSTATUS lsa_secret_set(const char *secret_name,
180 DATA_BLOB *secret_current,
181 DATA_BLOB *secret_old,
182 struct security_descriptor *sd);
183 NTSTATUS lsa_secret_delete(const char *secret_name);
185 #endif /* _SECRETS_H */