LCOV - code coverage report
Current view: top level - source4/auth - system_session.c (source / functions) Hit Total Coverage
Test: coverage report for vadcx-master-patch-75612 fe003de8 Lines: 260 345 75.4 %
Date: 2024-02-29 22:57:05 Functions: 8 9 88.9 %

          Line data    Source code
       1             : /* 
       2             :    Unix SMB/CIFS implementation.
       3             :    Authentication utility functions
       4             :    Copyright (C) Andrew Tridgell 1992-1998
       5             :    Copyright (C) Andrew Bartlett 2001-2010
       6             :    Copyright (C) Jeremy Allison 2000-2001
       7             :    Copyright (C) Rafal Szczesniak 2002
       8             :    Copyright (C) Stefan Metzmacher 2005
       9             : 
      10             :    This program is free software; you can redistribute it and/or modify
      11             :    it under the terms of the GNU General Public License as published by
      12             :    the Free Software Foundation; either version 3 of the License, or
      13             :    (at your option) any later version.
      14             :    
      15             :    This program is distributed in the hope that it will be useful,
      16             :    but WITHOUT ANY WARRANTY; without even the implied warranty of
      17             :    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      18             :    GNU General Public License for more details.
      19             :    
      20             :    You should have received a copy of the GNU General Public License
      21             :    along with this program.  If not, see <http://www.gnu.org/licenses/>.
      22             : */
      23             : 
      24             : #include "includes.h"
      25             : #include "libcli/security/security.h"
      26             : #include "auth/credentials/credentials.h"
      27             : #include "param/param.h"
      28             : #include "auth/auth.h" /* for auth_user_info_dc */
      29             : #include "auth/session.h"
      30             : #include "auth/system_session_proto.h"
      31             : 
      32             : #undef DBGC_CLASS
      33             : #define DBGC_CLASS DBGC_AUTH
      34             : 
      35             : /*
      36             :   prevent the static system session being freed
      37             :  */
      38           0 : static int system_session_destructor(struct auth_session_info *info)
      39             : {
      40           0 :         return -1;
      41             : }
      42             : 
      43             : /* Create a security token for a session SYSTEM (the most
      44             :  * trusted/privileged account), including the local machine account as
      45             :  * the off-host credentials
      46             :  */ 
      47      224070 : _PUBLIC_ struct auth_session_info *system_session(struct loadparm_context *lp_ctx)
      48             : {
      49        8610 :         static struct auth_session_info *static_session;
      50        8610 :         NTSTATUS nt_status;
      51             : 
      52      224070 :         if (static_session) {
      53      210375 :                 return static_session;
      54             :         }
      55             : 
      56             :         /*
      57             :          * Use NULL here, not the autofree context for this
      58             :          * static pointer. The destructor prevents freeing this
      59             :          * memory anyway.
      60             :          */
      61        5432 :         nt_status = auth_system_session_info(NULL,
      62             :                                              lp_ctx,
      63             :                                              &static_session);
      64        5432 :         if (!NT_STATUS_IS_OK(nt_status)) {
      65          26 :                 TALLOC_FREE(static_session);
      66          26 :                 return NULL;
      67             :         }
      68        5406 :         talloc_set_destructor(static_session, system_session_destructor);
      69        5406 :         return static_session;
      70             : }
      71             : 
      72        5432 : NTSTATUS auth_system_session_info(TALLOC_CTX *parent_ctx, 
      73             :                                   struct loadparm_context *lp_ctx,
      74             :                                   struct auth_session_info **_session_info) 
      75             : {
      76         347 :         NTSTATUS nt_status;
      77        5432 :         struct auth_user_info_dc *user_info_dc = NULL;
      78        5432 :         struct auth_session_info *session_info = NULL;
      79        5432 :         TALLOC_CTX *mem_ctx = NULL;
      80         347 :         bool ok;
      81             : 
      82        5432 :         mem_ctx = talloc_new(parent_ctx);
      83        5432 :         if (mem_ctx == NULL) {
      84           0 :                 return NT_STATUS_NO_MEMORY;
      85             :         }
      86             :         
      87        5432 :         nt_status = auth_system_user_info_dc(mem_ctx, lpcfg_netbios_name(lp_ctx),
      88             :                                             &user_info_dc);
      89        5432 :         if (!NT_STATUS_IS_OK(nt_status)) {
      90          26 :                 talloc_free(mem_ctx);
      91          26 :                 return nt_status;
      92             :         }
      93             : 
      94             :         /* references the user_info_dc into the session_info */
      95        5406 :         nt_status = auth_generate_session_info(parent_ctx,
      96             :                                                lp_ctx,
      97             :                                                NULL /* sam_ctx */,
      98             :                                                user_info_dc,
      99             :                                                AUTH_SESSION_INFO_SIMPLE_PRIVILEGES,
     100             :                                                &session_info);
     101        5406 :         talloc_free(mem_ctx);
     102             : 
     103        5406 :         NT_STATUS_NOT_OK_RETURN(nt_status);
     104             : 
     105        5406 :         session_info->credentials = cli_credentials_init(session_info);
     106        5406 :         if (!session_info->credentials) {
     107           0 :                 talloc_free(session_info);
     108           0 :                 return NT_STATUS_NO_MEMORY;
     109             :         }
     110             : 
     111        5406 :         ok = cli_credentials_set_conf(session_info->credentials, lp_ctx);
     112        5406 :         if (!ok) {
     113           0 :                 talloc_free(session_info);
     114           0 :                 return NT_STATUS_INTERNAL_ERROR;
     115             :         }
     116             : 
     117        5406 :         cli_credentials_set_machine_account_pending(session_info->credentials, lp_ctx);
     118        5406 :         *_session_info = session_info;
     119             : 
     120        5406 :         return NT_STATUS_OK;
     121             : }
     122             : 
     123        6625 : NTSTATUS auth_system_user_info_dc(TALLOC_CTX *mem_ctx, const char *netbios_name,
     124             :                                  struct auth_user_info_dc **_user_info_dc)
     125             : {
     126         355 :         struct auth_user_info_dc *user_info_dc;
     127         355 :         struct auth_user_info *info;
     128             : 
     129        6625 :         user_info_dc = talloc_zero(mem_ctx, struct auth_user_info_dc);
     130        6625 :         NT_STATUS_HAVE_NO_MEMORY(user_info_dc);
     131             : 
     132             :         /* This returns a pointer to a struct dom_sid, which is the
     133             :          * same as a 1 element list of struct dom_sid */
     134        6625 :         user_info_dc->num_sids = 1;
     135        6625 :         user_info_dc->sids = talloc(user_info_dc, struct auth_SidAttr);
     136        6625 :         if (user_info_dc->sids == NULL) {
     137           0 :                 talloc_free(user_info_dc);
     138           0 :                 return NT_STATUS_NO_MEMORY;
     139             :         }
     140             : 
     141        6625 :         user_info_dc->sids->sid = global_sid_System;
     142        6625 :         user_info_dc->sids->attrs = SE_GROUP_DEFAULT_FLAGS;
     143             : 
     144             :         /* annoying, but the Anonymous really does have a session key, 
     145             :            and it is all zeros! */
     146        6625 :         user_info_dc->user_session_key = data_blob_talloc(user_info_dc, NULL, 16);
     147        6625 :         if (user_info_dc->user_session_key.data == NULL) {
     148           0 :                 talloc_free(user_info_dc);
     149           0 :                 return NT_STATUS_NO_MEMORY;
     150             :         }
     151             : 
     152        6625 :         user_info_dc->lm_session_key = data_blob_talloc(user_info_dc, NULL, 16);
     153        6625 :         if (user_info_dc->lm_session_key.data == NULL) {
     154           0 :                 talloc_free(user_info_dc);
     155           0 :                 return NT_STATUS_NO_MEMORY;
     156             :         }
     157             : 
     158        6625 :         data_blob_clear(&user_info_dc->user_session_key);
     159        6625 :         data_blob_clear(&user_info_dc->lm_session_key);
     160             : 
     161        6625 :         user_info_dc->info = info = talloc_zero(user_info_dc, struct auth_user_info);
     162        6625 :         if (user_info_dc->info == NULL) {
     163           0 :                 talloc_free(user_info_dc);
     164           0 :                 return NT_STATUS_NO_MEMORY;
     165         355 :         };
     166             : 
     167        6625 :         info->account_name = talloc_strdup(info, "SYSTEM");
     168        6625 :         if (info->account_name == NULL) {
     169           0 :                 talloc_free(user_info_dc);
     170           0 :                 return NT_STATUS_NO_MEMORY;
     171         355 :         };
     172             : 
     173        6625 :         info->domain_name = talloc_strdup(info, "NT AUTHORITY");
     174        6625 :         if (info->domain_name == NULL) {
     175           0 :                 talloc_free(user_info_dc);
     176           0 :                 return NT_STATUS_NO_MEMORY;
     177         355 :         };
     178             : 
     179        6625 :         info->full_name = talloc_strdup(info, "System");
     180        6625 :         if (info->full_name == NULL) {
     181           0 :                 talloc_free(user_info_dc);
     182           0 :                 return NT_STATUS_NO_MEMORY;
     183         355 :         };
     184             : 
     185        6625 :         info->logon_script = talloc_strdup(info, "");
     186        6625 :         if (info->logon_script == NULL) {
     187           0 :                 talloc_free(user_info_dc);
     188           0 :                 return NT_STATUS_NO_MEMORY;
     189         355 :         };
     190             : 
     191        6625 :         info->profile_path = talloc_strdup(info, "");
     192        6625 :         if (info->profile_path == NULL) {
     193           0 :                 talloc_free(user_info_dc);
     194           0 :                 return NT_STATUS_NO_MEMORY;
     195         355 :         };
     196             : 
     197        6625 :         info->home_directory = talloc_strdup(info, "");
     198        6625 :         if (info->home_directory == NULL) {
     199           0 :                 talloc_free(user_info_dc);
     200           0 :                 return NT_STATUS_NO_MEMORY;
     201         355 :         };
     202             : 
     203        6625 :         info->home_drive = talloc_strdup(info, "");
     204        6625 :         if (info->home_drive == NULL) {
     205           0 :                 talloc_free(user_info_dc);
     206           0 :                 return NT_STATUS_NO_MEMORY;
     207         355 :         };
     208             : 
     209        6625 :         info->logon_server = talloc_strdup(info, netbios_name);
     210        6625 :         if (info->logon_server == NULL) {
     211          26 :                 talloc_free(user_info_dc);
     212          26 :                 return NT_STATUS_NO_MEMORY;
     213         331 :         };
     214             : 
     215        6599 :         info->last_logon = 0;
     216        6599 :         info->last_logoff = 0;
     217        6599 :         info->acct_expiry = 0;
     218        6599 :         info->last_password_change = 0;
     219        6599 :         info->allow_password_change = 0;
     220        6599 :         info->force_password_change = 0;
     221             : 
     222        6599 :         info->logon_count = 0;
     223        6599 :         info->bad_password_count = 0;
     224             : 
     225        6599 :         info->acct_flags = ACB_NORMAL;
     226             : 
     227        6599 :         info->user_flags = 0;
     228             : 
     229        6599 :         *_user_info_dc = user_info_dc;
     230             : 
     231        6599 :         return NT_STATUS_OK;
     232             : }
     233             : 
     234             : 
     235        1099 : static NTSTATUS auth_domain_admin_user_info_dc(TALLOC_CTX *mem_ctx,
     236             :                                               const char *netbios_name,
     237             :                                               const char *domain_name,
     238             :                                               struct dom_sid *domain_sid,
     239             :                                               struct auth_user_info_dc **_user_info_dc)
     240             : {
     241          80 :         struct auth_user_info_dc *user_info_dc;
     242          80 :         struct auth_user_info *info;
     243             : 
     244        1099 :         user_info_dc = talloc_zero(mem_ctx, struct auth_user_info_dc);
     245        1099 :         NT_STATUS_HAVE_NO_MEMORY(user_info_dc);
     246             : 
     247        1099 :         user_info_dc->num_sids = 8;
     248        1099 :         user_info_dc->sids = talloc_array(user_info_dc, struct auth_SidAttr, user_info_dc->num_sids);
     249             : 
     250        1099 :         user_info_dc->sids[PRIMARY_USER_SID_INDEX].sid = *domain_sid;
     251        1099 :         sid_append_rid(&user_info_dc->sids[PRIMARY_USER_SID_INDEX].sid, DOMAIN_RID_ADMINISTRATOR);
     252        1099 :         user_info_dc->sids[PRIMARY_USER_SID_INDEX].attrs = SE_GROUP_DEFAULT_FLAGS;
     253             : 
     254        1099 :         user_info_dc->sids[PRIMARY_GROUP_SID_INDEX].sid = *domain_sid;
     255        1099 :         sid_append_rid(&user_info_dc->sids[PRIMARY_GROUP_SID_INDEX].sid, DOMAIN_RID_USERS);
     256        1099 :         user_info_dc->sids[PRIMARY_GROUP_SID_INDEX].attrs = SE_GROUP_DEFAULT_FLAGS;
     257             : 
     258             :         /* Add the primary group again. */
     259        1099 :         user_info_dc->sids[2] = user_info_dc->sids[PRIMARY_GROUP_SID_INDEX];
     260             : 
     261        1099 :         user_info_dc->sids[3].sid = global_sid_Builtin_Administrators;
     262        1099 :         user_info_dc->sids[3].attrs = SE_GROUP_DEFAULT_FLAGS;
     263             : 
     264        1099 :         user_info_dc->sids[4].sid = *domain_sid;
     265        1099 :         sid_append_rid(&user_info_dc->sids[4].sid, DOMAIN_RID_ADMINS);
     266        1099 :         user_info_dc->sids[4].attrs = SE_GROUP_DEFAULT_FLAGS;
     267        1099 :         user_info_dc->sids[5].sid = *domain_sid;
     268        1099 :         sid_append_rid(&user_info_dc->sids[5].sid, DOMAIN_RID_ENTERPRISE_ADMINS);
     269        1099 :         user_info_dc->sids[5].attrs = SE_GROUP_DEFAULT_FLAGS;
     270        1099 :         user_info_dc->sids[6].sid = *domain_sid;
     271        1099 :         sid_append_rid(&user_info_dc->sids[6].sid, DOMAIN_RID_POLICY_ADMINS);
     272        1099 :         user_info_dc->sids[6].attrs = SE_GROUP_DEFAULT_FLAGS;
     273        1099 :         user_info_dc->sids[7].sid = *domain_sid;
     274        1099 :         sid_append_rid(&user_info_dc->sids[7].sid, DOMAIN_RID_SCHEMA_ADMINS);
     275        1099 :         user_info_dc->sids[7].attrs = SE_GROUP_DEFAULT_FLAGS;
     276             : 
     277             :         /* What should the session key be?*/
     278        1099 :         user_info_dc->user_session_key = data_blob_talloc(user_info_dc, NULL, 16);
     279        1099 :         if (user_info_dc->user_session_key.data == NULL) {
     280           0 :                 talloc_free(user_info_dc);
     281           0 :                 return NT_STATUS_NO_MEMORY;
     282          80 :         };
     283             : 
     284        1099 :         user_info_dc->lm_session_key = data_blob_talloc(user_info_dc, NULL, 16);
     285        1099 :         if (user_info_dc->lm_session_key.data == NULL) {
     286           0 :                 talloc_free(user_info_dc);
     287           0 :                 return NT_STATUS_NO_MEMORY;
     288          80 :         };
     289             : 
     290        1099 :         data_blob_clear(&user_info_dc->user_session_key);
     291        1099 :         data_blob_clear(&user_info_dc->lm_session_key);
     292             : 
     293        1099 :         user_info_dc->info = info = talloc_zero(user_info_dc, struct auth_user_info);
     294        1099 :         if (user_info_dc->info == NULL) {
     295           0 :                 talloc_free(user_info_dc);
     296           0 :                 return NT_STATUS_NO_MEMORY;
     297          80 :         };
     298             : 
     299        1099 :         info->account_name = talloc_strdup(info, "Administrator");
     300        1099 :         if (info->account_name == NULL) {
     301           0 :                 talloc_free(user_info_dc);
     302           0 :                 return NT_STATUS_NO_MEMORY;
     303          80 :         };
     304             : 
     305        1099 :         info->domain_name = talloc_strdup(info, domain_name);
     306        1099 :         if (info->domain_name == NULL) {
     307           0 :                 talloc_free(user_info_dc);
     308           0 :                 return NT_STATUS_NO_MEMORY;
     309          80 :         };
     310             : 
     311        1099 :         info->full_name = talloc_strdup(info, "Administrator");
     312        1099 :         if (info->full_name == NULL) {
     313           0 :                 talloc_free(user_info_dc);
     314           0 :                 return NT_STATUS_NO_MEMORY;
     315          80 :         };
     316             : 
     317        1099 :         info->logon_script = talloc_strdup(info, "");
     318        1099 :         if (info->logon_script == NULL) {
     319           0 :                 talloc_free(user_info_dc);
     320           0 :                 return NT_STATUS_NO_MEMORY;
     321          80 :         };
     322             : 
     323        1099 :         info->profile_path = talloc_strdup(info, "");
     324        1099 :         if (info->profile_path == NULL) {
     325           0 :                 talloc_free(user_info_dc);
     326           0 :                 return NT_STATUS_NO_MEMORY;
     327          80 :         };
     328             : 
     329        1099 :         info->home_directory = talloc_strdup(info, "");
     330        1099 :         if (info->home_directory == NULL) {
     331           0 :                 talloc_free(user_info_dc);
     332           0 :                 return NT_STATUS_NO_MEMORY;
     333          80 :         };
     334             : 
     335        1099 :         info->home_drive = talloc_strdup(info, "");
     336        1099 :         if (info->home_drive == NULL) {
     337           0 :                 talloc_free(user_info_dc);
     338           0 :                 return NT_STATUS_NO_MEMORY;
     339          80 :         };
     340             : 
     341        1099 :         info->logon_server = talloc_strdup(info, netbios_name);
     342        1099 :         if (info->logon_server == NULL) {
     343           0 :                 talloc_free(user_info_dc);
     344           0 :                 return NT_STATUS_NO_MEMORY;
     345          80 :         };
     346             : 
     347        1099 :         info->last_logon = 0;
     348        1099 :         info->last_logoff = 0;
     349        1099 :         info->acct_expiry = 0;
     350        1099 :         info->last_password_change = 0;
     351        1099 :         info->allow_password_change = 0;
     352        1099 :         info->force_password_change = 0;
     353             : 
     354        1099 :         info->logon_count = 0;
     355        1099 :         info->bad_password_count = 0;
     356             : 
     357        1099 :         info->acct_flags = ACB_NORMAL;
     358             : 
     359        1099 :         info->user_flags = 0;
     360             : 
     361        1099 :         *_user_info_dc = user_info_dc;
     362             : 
     363        1099 :         return NT_STATUS_OK;
     364             : }
     365             : 
     366        1099 : static NTSTATUS auth_domain_admin_session_info(TALLOC_CTX *parent_ctx,
     367             :                                                struct loadparm_context *lp_ctx,
     368             :                                                struct dom_sid *domain_sid,
     369             :                                                struct auth_session_info **session_info)
     370             : {
     371          80 :         NTSTATUS nt_status;
     372        1099 :         struct auth_user_info_dc *user_info_dc = NULL;
     373        1099 :         TALLOC_CTX *mem_ctx = talloc_new(parent_ctx);
     374             : 
     375        1099 :         NT_STATUS_HAVE_NO_MEMORY(mem_ctx);
     376             : 
     377        1099 :         nt_status = auth_domain_admin_user_info_dc(mem_ctx,
     378             :                                                    lpcfg_netbios_name(lp_ctx),
     379             :                                                    lpcfg_workgroup(lp_ctx),
     380             :                                                    domain_sid,
     381             :                                                    &user_info_dc);
     382        1099 :         if (!NT_STATUS_IS_OK(nt_status)) {
     383           0 :                 talloc_free(mem_ctx);
     384           0 :                 return nt_status;
     385             :         }
     386             : 
     387        1099 :         nt_status = auth_generate_session_info(mem_ctx,
     388             :                                                lp_ctx,
     389             :                                                NULL /* sam_ctx */,
     390             :                                                user_info_dc,
     391             :                                                AUTH_SESSION_INFO_SIMPLE_PRIVILEGES|AUTH_SESSION_INFO_AUTHENTICATED|AUTH_SESSION_INFO_DEFAULT_GROUPS,
     392             :                                                session_info);
     393             :         /* There is already a reference between the session_info and user_info_dc */
     394        1099 :         if (NT_STATUS_IS_OK(nt_status)) {
     395        1099 :                 talloc_steal(parent_ctx, *session_info);
     396             :         }
     397        1099 :         talloc_free(mem_ctx);
     398        1099 :         return nt_status;
     399             : }
     400             : 
     401        1099 : _PUBLIC_ struct auth_session_info *admin_session(TALLOC_CTX *mem_ctx, struct loadparm_context *lp_ctx, struct dom_sid *domain_sid)
     402             : {
     403          80 :         NTSTATUS nt_status;
     404        1099 :         struct auth_session_info *session_info = NULL;
     405        1099 :         nt_status = auth_domain_admin_session_info(mem_ctx,
     406             :                                                    lp_ctx,
     407             :                                                    domain_sid,
     408             :                                                    &session_info);
     409        1099 :         if (!NT_STATUS_IS_OK(nt_status)) {
     410           0 :                 return NULL;
     411             :         }
     412        1099 :         return session_info;
     413             : }
     414             : 
     415       39629 : _PUBLIC_ NTSTATUS auth_anonymous_session_info(TALLOC_CTX *parent_ctx, 
     416             :                                               struct loadparm_context *lp_ctx,
     417             :                                               struct auth_session_info **_session_info) 
     418             : {
     419         372 :         NTSTATUS nt_status;
     420       39629 :         struct auth_user_info_dc *user_info_dc = NULL;
     421       39629 :         struct auth_session_info *session_info = NULL;
     422       39629 :         TALLOC_CTX *mem_ctx = talloc_new(parent_ctx);
     423         372 :         bool ok;
     424             : 
     425       39629 :         if (mem_ctx == NULL) {
     426           0 :                 return NT_STATUS_NO_MEMORY;
     427             :         }
     428             :         
     429       39629 :         nt_status = auth_anonymous_user_info_dc(mem_ctx,
     430             :                                                 lpcfg_netbios_name(lp_ctx),
     431             :                                                 &user_info_dc);
     432       39629 :         if (!NT_STATUS_IS_OK(nt_status)) {
     433           0 :                 talloc_free(mem_ctx);
     434           0 :                 return nt_status;
     435             :         }
     436             : 
     437             :         /* references the user_info_dc into the session_info */
     438       39629 :         nt_status = auth_generate_session_info(parent_ctx,
     439             :                                                lp_ctx,
     440             :                                                NULL /* sam_ctx */,
     441             :                                                user_info_dc,
     442             :                                                AUTH_SESSION_INFO_SIMPLE_PRIVILEGES,
     443             :                                                &session_info);
     444       39629 :         talloc_free(mem_ctx);
     445             : 
     446       39629 :         NT_STATUS_NOT_OK_RETURN(nt_status);
     447             : 
     448       39629 :         session_info->credentials = cli_credentials_init(session_info);
     449       39629 :         if (!session_info->credentials) {
     450           0 :                 talloc_free(session_info);
     451           0 :                 return NT_STATUS_NO_MEMORY;
     452             :         }
     453             : 
     454       39629 :         ok = cli_credentials_set_conf(session_info->credentials, lp_ctx);
     455       39629 :         if (!ok) {
     456           0 :                 talloc_free(session_info);
     457           0 :                 return NT_STATUS_INTERNAL_ERROR;
     458             :         }
     459       39629 :         cli_credentials_set_anonymous(session_info->credentials);
     460             :         
     461       39629 :         *_session_info = session_info;
     462             : 
     463       39629 :         return NT_STATUS_OK;
     464             : }
     465             : 
     466       43310 : _PUBLIC_ NTSTATUS auth_anonymous_user_info_dc(TALLOC_CTX *mem_ctx,
     467             :                                     const char *netbios_name,
     468             :                                     struct auth_user_info_dc **_user_info_dc)
     469             : {
     470         703 :         struct auth_user_info_dc *user_info_dc;
     471         703 :         struct auth_user_info *info;
     472       43310 :         user_info_dc = talloc_zero(mem_ctx, struct auth_user_info_dc);
     473       43310 :         NT_STATUS_HAVE_NO_MEMORY(user_info_dc);
     474             : 
     475             :         /* This returns a pointer to a struct dom_sid, which is the
     476             :          * same as a 1 element list of struct dom_sid */
     477       43310 :         user_info_dc->num_sids = 1;
     478       43310 :         user_info_dc->sids = talloc(user_info_dc, struct auth_SidAttr);
     479       43310 :         if (user_info_dc->sids == NULL) {
     480           0 :                 talloc_free(user_info_dc);
     481           0 :                 return NT_STATUS_NO_MEMORY;
     482         703 :         };
     483             : 
     484       43310 :         user_info_dc->sids->sid = global_sid_Anonymous;
     485       43310 :         user_info_dc->sids->attrs = SE_GROUP_DEFAULT_FLAGS;
     486             : 
     487             :         /* annoying, but the Anonymous really does have a session key... */
     488       43310 :         user_info_dc->user_session_key = data_blob_talloc(user_info_dc, NULL, 16);
     489       43310 :         if (user_info_dc->user_session_key.data == NULL) {
     490           0 :                 talloc_free(user_info_dc);
     491           0 :                 return NT_STATUS_NO_MEMORY;
     492         703 :         };
     493             : 
     494       43310 :         user_info_dc->lm_session_key = data_blob_talloc(user_info_dc, NULL, 16);
     495       43310 :         if (user_info_dc->lm_session_key.data == NULL) {
     496           0 :                 talloc_free(user_info_dc);
     497           0 :                 return NT_STATUS_NO_MEMORY;
     498         703 :         };
     499             : 
     500             :         /*  and it is all zeros! */
     501       43310 :         data_blob_clear(&user_info_dc->user_session_key);
     502       43310 :         data_blob_clear(&user_info_dc->lm_session_key);
     503             : 
     504       43310 :         user_info_dc->info = info = talloc_zero(user_info_dc, struct auth_user_info);
     505       43310 :         if (user_info_dc->info == NULL) {
     506           0 :                 talloc_free(user_info_dc);
     507           0 :                 return NT_STATUS_NO_MEMORY;
     508         703 :         };
     509             : 
     510       43310 :         info->account_name = talloc_strdup(info, "ANONYMOUS LOGON");
     511       43310 :         if (info->account_name == NULL) {
     512           0 :                 talloc_free(user_info_dc);
     513           0 :                 return NT_STATUS_NO_MEMORY;
     514         703 :         };
     515             : 
     516       43310 :         info->domain_name = talloc_strdup(info, "NT AUTHORITY");
     517       43310 :         if (info->domain_name == NULL) {
     518           0 :                 talloc_free(user_info_dc);
     519           0 :                 return NT_STATUS_NO_MEMORY;
     520         703 :         };
     521             : 
     522       43310 :         info->full_name = talloc_strdup(info, "Anonymous Logon");
     523       43310 :         if (info->full_name == NULL) {
     524           0 :                 talloc_free(user_info_dc);
     525           0 :                 return NT_STATUS_NO_MEMORY;
     526         703 :         };
     527             : 
     528       43310 :         info->logon_script = talloc_strdup(info, "");
     529       43310 :         if (info->logon_script == NULL) {
     530           0 :                 talloc_free(user_info_dc);
     531           0 :                 return NT_STATUS_NO_MEMORY;
     532         703 :         };
     533             : 
     534       43310 :         info->profile_path = talloc_strdup(info, "");
     535       43310 :         if (info->profile_path == NULL) {
     536           0 :                 talloc_free(user_info_dc);
     537           0 :                 return NT_STATUS_NO_MEMORY;
     538         703 :         };
     539             : 
     540       43310 :         info->home_directory = talloc_strdup(info, "");
     541       43310 :         if (info->home_directory == NULL) {
     542           0 :                 talloc_free(user_info_dc);
     543           0 :                 return NT_STATUS_NO_MEMORY;
     544         703 :         };
     545             : 
     546       43310 :         info->home_drive = talloc_strdup(info, "");
     547       43310 :         if (info->home_drive == NULL) {
     548           0 :                 talloc_free(user_info_dc);
     549           0 :                 return NT_STATUS_NO_MEMORY;
     550         703 :         };
     551             : 
     552       43310 :         info->logon_server = talloc_strdup(info, netbios_name);
     553       43310 :         if (info->logon_server == NULL) {
     554           0 :                 talloc_free(user_info_dc);
     555           0 :                 return NT_STATUS_NO_MEMORY;
     556         703 :         };
     557             : 
     558       43310 :         info->last_logon = 0;
     559       43310 :         info->last_logoff = 0;
     560       43310 :         info->acct_expiry = 0;
     561       43310 :         info->last_password_change = 0;
     562       43310 :         info->allow_password_change = 0;
     563       43310 :         info->force_password_change = 0;
     564             : 
     565       43310 :         info->logon_count = 0;
     566       43310 :         info->bad_password_count = 0;
     567             : 
     568       43310 :         info->acct_flags = ACB_NORMAL;
     569             : 
     570             :         /* The user is not authenticated. */
     571       43310 :         info->user_flags = NETLOGON_GUEST;
     572             : 
     573       43310 :         *_user_info_dc = user_info_dc;
     574             : 
     575       43310 :         return NT_STATUS_OK;
     576             : }
     577             : 

Generated by: LCOV version 1.14