Changeset 988 for vendor/current/auth
- Timestamp:
- Nov 24, 2016, 1:14:11 PM (9 years ago)
- Location:
- vendor/current/auth
- Files:
-
- 47 added
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
vendor/current/auth/auth_sam_reply.c
r740 r988 4 4 Convert a server info struct into the form for PAC and NETLOGON replies 5 5 6 Copyright (C) Andrew Bartlett <abartlet@samba.org> 2004 6 Copyright (C) Andrew Bartlett <abartlet@samba.org> 2004-2011 7 7 Copyright (C) Stefan Metzmacher <metze@samba.org> 2005 8 8 … … 60 60 info = user_info_dc->info; 61 61 62 sam->l ast_logon= info->last_logon;63 sam->l ast_logoff= info->last_logoff;64 sam-> acct_expiry= info->acct_expiry;62 sam->logon_time = info->last_logon; 63 sam->logoff_time = info->last_logoff; 64 sam->kickoff_time = info->acct_expiry; 65 65 sam->last_password_change = info->last_password_change; 66 66 sam->allow_password_change = info->allow_password_change; … … 103 103 104 104 sam->user_flags = 0; /* w2k3 uses NETLOGON_EXTRA_SIDS | NETLOGON_NTLMV2_ENABLED */ 105 if (!user_info_dc->info->authenticated) { 106 sam->user_flags |= NETLOGON_GUEST; 107 } 105 108 sam->acct_flags = user_info_dc->info->acct_flags; 106 109 sam->logon_server.string = user_info_dc->info->logon_server; 107 sam->domain.string = user_info_dc->info->domain_name; 108 109 ZERO_STRUCT(sam->unknown); 110 sam->logon_domain.string = user_info_dc->info->domain_name; 111 sam->sub_auth_status = 0; 112 sam->last_successful_logon = 0; 113 sam->last_failed_logon = 0; 114 sam->failed_logon_count = 0; 115 sam->reserved = 0; 110 116 111 117 ZERO_STRUCT(sam->key); … … 149 155 sam3->sids = talloc_array(sam, struct netr_SidAttr, 150 156 user_info_dc->num_sids); 151 NT_STATUS_HAVE_NO_MEMORY_AND_FREE(sam3->sids, sam3); 157 if (sam3->sids == NULL) { 158 TALLOC_FREE(sam3); 159 return NT_STATUS_NO_MEMORY; 160 } 152 161 153 162 /* We don't put the user and group SIDs in there */ … … 157 166 } 158 167 sam3->sids[sam3->sidcount].sid = dom_sid_dup(sam3->sids, &user_info_dc->sids[i]); 159 NT_STATUS_HAVE_NO_MEMORY_AND_FREE(sam3->sids[sam3->sidcount].sid, sam3); 168 if (sam3->sids[sam3->sidcount].sid == NULL) { 169 TALLOC_FREE(sam3); 170 return NT_STATUS_NO_MEMORY; 171 } 160 172 sam3->sids[sam3->sidcount].attributes = 161 173 SE_GROUP_MANDATORY | SE_GROUP_ENABLED_BY_DEFAULT | SE_GROUP_ENABLED; … … 169 181 *_sam3 = sam3; 170 182 183 return NT_STATUS_OK; 184 } 185 186 /** 187 * Make a user_info struct from the info3 or similar returned by a domain logon. 188 * 189 * The netr_SamInfo3 is also a key structure in the source3 auth subsystem 190 */ 191 192 NTSTATUS make_user_info_SamBaseInfo(TALLOC_CTX *mem_ctx, 193 const char *account_name, 194 struct netr_SamBaseInfo *base, 195 bool authenticated, 196 struct auth_user_info **_user_info) 197 { 198 struct auth_user_info *info; 199 200 info = talloc_zero(mem_ctx, struct auth_user_info); 201 NT_STATUS_HAVE_NO_MEMORY(info); 202 203 if (base->account_name.string) { 204 info->account_name = talloc_strdup(info, base->account_name.string); 205 } else { 206 info->account_name = talloc_strdup(info, account_name); 207 } 208 NT_STATUS_HAVE_NO_MEMORY(info->account_name); 209 210 if (base->logon_domain.string) { 211 info->domain_name = talloc_strdup(info, base->logon_domain.string); 212 NT_STATUS_HAVE_NO_MEMORY(info->domain_name); 213 } 214 215 if (base->full_name.string) { 216 info->full_name = talloc_strdup(info, base->full_name.string); 217 NT_STATUS_HAVE_NO_MEMORY(info->full_name); 218 } 219 if (base->logon_script.string) { 220 info->logon_script = talloc_strdup(info, base->logon_script.string); 221 NT_STATUS_HAVE_NO_MEMORY(info->logon_script); 222 } 223 if (base->profile_path.string) { 224 info->profile_path = talloc_strdup(info, base->profile_path.string); 225 NT_STATUS_HAVE_NO_MEMORY(info->profile_path); 226 } 227 if (base->home_directory.string) { 228 info->home_directory = talloc_strdup(info, base->home_directory.string); 229 NT_STATUS_HAVE_NO_MEMORY(info->home_directory); 230 } 231 if (base->home_drive.string) { 232 info->home_drive = talloc_strdup(info, base->home_drive.string); 233 NT_STATUS_HAVE_NO_MEMORY(info->home_drive); 234 } 235 if (base->logon_server.string) { 236 info->logon_server = talloc_strdup(info, base->logon_server.string); 237 NT_STATUS_HAVE_NO_MEMORY(info->logon_server); 238 } 239 info->last_logon = base->logon_time; 240 info->last_logoff = base->logoff_time; 241 info->acct_expiry = base->kickoff_time; 242 info->last_password_change = base->last_password_change; 243 info->allow_password_change = base->allow_password_change; 244 info->force_password_change = base->force_password_change; 245 info->logon_count = base->logon_count; 246 info->bad_password_count = base->bad_password_count; 247 info->acct_flags = base->acct_flags; 248 249 /* Only set authenticated if both NETLOGON_GUEST is not set, and authenticated is set */ 250 info->authenticated = (authenticated && (!(base->user_flags & NETLOGON_GUEST))); 251 252 *_user_info = info; 171 253 return NT_STATUS_OK; 172 254 } … … 179 261 uint16_t validation_level, 180 262 union netr_Validation *validation, 263 bool authenticated, 181 264 struct auth_user_info_dc **_user_info_dc) 182 265 { 266 NTSTATUS status; 183 267 struct auth_user_info_dc *user_info_dc; 184 struct auth_user_info *info;185 268 struct netr_SamBaseInfo *base = NULL; 186 269 uint32_t i; … … 285 368 } 286 369 287 user_info_dc->info = info = talloc_zero(user_info_dc, struct auth_user_info); 288 NT_STATUS_HAVE_NO_MEMORY(user_info_dc->info); 289 290 if (base->account_name.string) { 291 info->account_name = talloc_reference(info, base->account_name.string); 292 } else { 293 info->account_name = talloc_strdup(info, account_name); 294 NT_STATUS_HAVE_NO_MEMORY(info->account_name); 295 } 296 297 info->domain_name = talloc_reference(info, base->domain.string); 298 info->full_name = talloc_reference(info, base->full_name.string); 299 info->logon_script = talloc_reference(info, base->logon_script.string); 300 info->profile_path = talloc_reference(info, base->profile_path.string); 301 info->home_directory = talloc_reference(info, base->home_directory.string); 302 info->home_drive = talloc_reference(info, base->home_drive.string); 303 info->logon_server = talloc_reference(info, base->logon_server.string); 304 info->last_logon = base->last_logon; 305 info->last_logoff = base->last_logoff; 306 info->acct_expiry = base->acct_expiry; 307 info->last_password_change = base->last_password_change; 308 info->allow_password_change = base->allow_password_change; 309 info->force_password_change = base->force_password_change; 310 info->logon_count = base->logon_count; 311 info->bad_password_count = base->bad_password_count; 312 info->acct_flags = base->acct_flags; 313 314 info->authenticated = true; 370 status = make_user_info_SamBaseInfo(user_info_dc, account_name, base, authenticated, &user_info_dc->info); 371 if (!NT_STATUS_IS_OK(status)) { 372 return status; 373 } 315 374 316 375 /* ensure we are never given NULL session keys */ … … 348 407 validation.sam3 = &pac_logon_info->info3; 349 408 350 nt_status = make_user_info_dc_netlogon_validation(mem_ctx, "", 3, &validation, &user_info_dc); 409 nt_status = make_user_info_dc_netlogon_validation(mem_ctx, "", 3, &validation, 410 true, /* This user was authenticated */ 411 &user_info_dc); 351 412 if (!NT_STATUS_IS_OK(nt_status)) { 352 413 return nt_status; … … 375 436 user_info_dc->sids 376 437 = talloc_realloc(user_info_dc, user_info_dc->sids, struct dom_sid, sidcount); 377 NT_STATUS_HAVE_NO_MEMORY_AND_FREE(user_info_dc->sids, user_info_dc); 438 if (user_info_dc->sids == NULL) { 439 TALLOC_FREE(user_info_dc); 440 return NT_STATUS_NO_MEMORY; 441 } 378 442 379 443 for (i = 0; pac_logon_info->res_group_dom_sid && i < pac_logon_info->res_groups.count; i++) { -
vendor/current/auth/auth_sam_reply.h
r740 r988 33 33 /* The following definitions come from auth/auth_sam_reply.c */ 34 34 35 NTSTATUS make_user_info_SamBaseInfo(TALLOC_CTX *mem_ctx, 36 const char *account_name, 37 struct netr_SamBaseInfo *base, 38 bool authenticated, 39 struct auth_user_info **_user_info); 40 35 41 NTSTATUS auth_convert_user_info_dc_sambaseinfo(TALLOC_CTX *mem_ctx, 36 42 struct auth_user_info_dc *user_info_dc, … … 47 53 uint16_t validation_level, 48 54 union netr_Validation *validation, 55 bool authenticated, 49 56 struct auth_user_info_dc **_user_info_dc); 50 57 … … 55 62 struct PAC_LOGON_INFO *pac_logon_info, 56 63 struct auth_user_info_dc **_user_info_dc); 64 65 /* The following definitions come from auth/wbc_auth_util.c */ 66 67 struct wbcAuthUserInfo; 68 69 struct netr_SamInfo3 *wbcAuthUserInfo_to_netr_SamInfo3(TALLOC_CTX *mem_ctx, 70 const struct wbcAuthUserInfo *info); 71 57 72 #undef _PRINTF_ATTRIBUTE 58 73 #define _PRINTF_ATTRIBUTE(a1, a2) -
vendor/current/auth/common_auth.h
r740 r988 18 18 */ 19 19 20 #ifndef AUTH_COMMON_AUTH_H 21 #define AUTH_COMMON_AUTH_H 22 23 #include "librpc/gen_ndr/auth.h" 24 20 25 #define USER_INFO_CASE_INSENSITIVE_USERNAME 0x01 /* username may be in any case */ 21 26 #define USER_INFO_CASE_INSENSITIVE_PASSWORD 0x02 /* password may be in any case */ 22 27 #define USER_INFO_DONT_CHECK_UNIX_ACCOUNT 0x04 /* don't check unix account status */ 23 #define USER_INFO_INTERACTIVE_LOGON 0x08 /* don't check unix account status */ 28 #define USER_INFO_INTERACTIVE_LOGON 0x08 /* Interactive logon */ 29 #define USER_INFO_LOCAL_SAM_ONLY 0x10 /* Only authenticate against the local SAM, do not map missing passwords to NO_SUCH_USER */ 30 #define USER_INFO_INFO3_AND_NO_AUTHZ 0x20 /* Only fill in server_info->info3 and do not do any authorization steps */ 24 31 25 32 enum auth_password_state { … … 28 35 AUTH_PASSWORD_RESPONSE = 3 29 36 }; 37 38 #define AUTH_SESSION_INFO_DEFAULT_GROUPS 0x01 /* Add the user to the default world and network groups */ 39 #define AUTH_SESSION_INFO_AUTHENTICATED 0x02 /* Add the user to the 'authenticated users' group */ 40 #define AUTH_SESSION_INFO_SIMPLE_PRIVILEGES 0x04 /* Use a trivial map between users and privilages, rather than a DB */ 41 #define AUTH_SESSION_INFO_UNIX_TOKEN 0x08 /* The returned token must have the unix_token and unix_info elements provided */ 30 42 31 43 struct auth_usersupplied_info … … 60 72 uint32_t flags; 61 73 }; 74 75 struct auth_method_context; 76 struct tevent_context; 77 struct imessaging_context; 78 struct loadparm_context; 79 struct ldb_context; 80 struct smb_krb5_context; 81 82 #define AUTH_METHOD_LOCAL_SAM 0x01 83 84 struct auth4_context { 85 struct { 86 /* Who set this up in the first place? */ 87 const char *set_by; 88 89 DATA_BLOB data; 90 } challenge; 91 92 /* methods, in the order they should be called */ 93 struct auth_method_context *methods; 94 95 /* the event context to use for calls that can block */ 96 struct tevent_context *event_ctx; 97 98 /* the messaging context which can be used by backends */ 99 struct imessaging_context *msg_ctx; 100 101 /* loadparm context */ 102 struct loadparm_context *lp_ctx; 103 104 /* SAM database for this local machine - to fill in local groups, or to authenticate local NTLM users */ 105 struct ldb_context *sam_ctx; 106 107 /* Private data for the callbacks on this auth context */ 108 void *private_data; 109 110 NTSTATUS (*check_ntlm_password)(struct auth4_context *auth_ctx, 111 TALLOC_CTX *mem_ctx, 112 const struct auth_usersupplied_info *user_info, 113 void **server_returned_info, 114 DATA_BLOB *nt_session_key, DATA_BLOB *lm_session_key); 115 116 NTSTATUS (*get_ntlm_challenge)(struct auth4_context *auth_ctx, uint8_t chal[8]); 117 118 NTSTATUS (*set_ntlm_challenge)(struct auth4_context *auth_ctx, const uint8_t chal[8], const char *set_by); 119 120 NTSTATUS (*generate_session_info)(struct auth4_context *auth_context, 121 TALLOC_CTX *mem_ctx, 122 void *server_returned_info, 123 const char *original_user_name, 124 uint32_t session_info_flags, 125 struct auth_session_info **session_info); 126 127 NTSTATUS (*generate_session_info_pac)(struct auth4_context *auth_ctx, 128 TALLOC_CTX *mem_ctx, 129 struct smb_krb5_context *smb_krb5_context, 130 DATA_BLOB *pac_blob, 131 const char *principal_name, 132 const struct tsocket_address *remote_address, 133 uint32_t session_info_flags, 134 struct auth_session_info **session_info); 135 }; 136 137 #endif -
vendor/current/auth/wscript_build
r740 r988 1 1 #!/usr/bin/env python 2 2 3 bld.SAMBA_SUBSYSTEM('auth_sam_reply', 4 source='auth_sam_reply.c', 5 deps='talloc', 6 autoproto='auth_sam_reply.h' 7 ) 3 bld.SAMBA_LIBRARY('auth_sam_reply', 4 source='auth_sam_reply.c wbc_auth_util.c', 5 deps='talloc samba-security samba-util', 6 private_library=True 7 ) 8 9 bld.RECURSE('gensec') 10 bld.RECURSE('ntlmssp') 11 bld.RECURSE('credentials')
Note:
See TracChangeset
for help on using the changeset viewer.