LCOV - code coverage report
Current view: top level - source4/rpc_server/winreg - rpc_winreg.c (source / functions) Hit Total Coverage
Test: coverage report for v4-17-test 1498b464 Lines: 193 273 70.7 %
Date: 2024-06-13 04:01:37 Functions: 18 37 48.6 %

          Line data    Source code
       1             : /*
       2             :    Unix SMB/CIFS implementation.
       3             : 
       4             :    endpoint server for the winreg pipe
       5             : 
       6             :    Copyright (C) 2004 Jelmer Vernooij, jelmer@samba.org
       7             :    Copyright (C) 2008 Matthias Dieter Wallnöfer, mwallnoefer@yahoo.de
       8             : 
       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.
      13             : 
      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.
      18             : 
      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/>.
      21             : */
      22             : 
      23             : #include "includes.h"
      24             : #include "rpc_server/dcerpc_server.h"
      25             : #include "lib/registry/registry.h"
      26             : #include "librpc/gen_ndr/ndr_winreg.h"
      27             : #include "librpc/gen_ndr/ndr_security.h"
      28             : #include "libcli/security/session.h"
      29             : 
      30             : enum handle_types { HTYPE_REGVAL, HTYPE_REGKEY };
      31             : 
      32         323 : static WERROR dcesrv_winreg_openhive(struct dcesrv_call_state *dce_call,
      33             :                                      TALLOC_CTX *mem_ctx, uint32_t hkey,
      34             :                                      struct policy_handle **outh)
      35             : {
      36         163 :         struct auth_session_info *session_info =
      37         160 :                 dcesrv_call_session_info(dce_call);
      38         323 :         struct registry_context *ctx = NULL;
      39             :         struct dcesrv_handle *h;
      40             :         WERROR result;
      41             : 
      42         323 :         h = dcesrv_handle_create(dce_call, HTYPE_REGKEY);
      43         323 :         W_ERROR_HAVE_NO_MEMORY(h);
      44             : 
      45         323 :         result = reg_open_samba(h, &ctx,
      46             :                                 dce_call->event_ctx,
      47         323 :                                 dce_call->conn->dce_ctx->lp_ctx,
      48             :                                 session_info,
      49             :                                 NULL);
      50         323 :         if (!W_ERROR_IS_OK(result)) {
      51           0 :                 DEBUG(0, ("Error opening registry: %s\n", win_errstr(result)));
      52           0 :                 return result;
      53             :         }
      54             : 
      55         323 :         result = reg_get_predefined_key(ctx, hkey,
      56         323 :                                        (struct registry_key **)&h->data);
      57         323 :         if (!W_ERROR_IS_OK(result)) {
      58           0 :                 return result;
      59             :         }
      60         323 :         *outh = &h->wire_handle;
      61             : 
      62         323 :         return result;
      63             : }
      64             : 
      65             : #define func_winreg_OpenHive(k,n) static WERROR dcesrv_winreg_Open ## k (struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx, struct winreg_Open ## k *r) \
      66             : { \
      67             :         return dcesrv_winreg_openhive (dce_call, mem_ctx, n, &r->out.handle);\
      68             : }
      69             : 
      70          80 : func_winreg_OpenHive(HKCR,HKEY_CLASSES_ROOT)
      71          80 : func_winreg_OpenHive(HKCU,HKEY_CURRENT_USER)
      72          83 : func_winreg_OpenHive(HKLM,HKEY_LOCAL_MACHINE)
      73           0 : func_winreg_OpenHive(HKPD,HKEY_PERFORMANCE_DATA)
      74          80 : func_winreg_OpenHive(HKU,HKEY_USERS)
      75           0 : func_winreg_OpenHive(HKCC,HKEY_CURRENT_CONFIG)
      76           0 : func_winreg_OpenHive(HKDD,HKEY_DYN_DATA)
      77           0 : func_winreg_OpenHive(HKPT,HKEY_PERFORMANCE_TEXT)
      78           0 : func_winreg_OpenHive(HKPN,HKEY_PERFORMANCE_NLSTEXT)
      79             : 
      80             : /*
      81             :   winreg_CloseKey
      82             : */
      83         643 : static WERROR dcesrv_winreg_CloseKey(struct dcesrv_call_state *dce_call,
      84             :                                      TALLOC_CTX *mem_ctx,
      85             :                                      struct winreg_CloseKey *r)
      86             : {
      87             :         struct dcesrv_handle *h;
      88             : 
      89         643 :         DCESRV_PULL_HANDLE_FAULT(h, r->in.handle, HTYPE_REGKEY);
      90             : 
      91         643 :         talloc_unlink(dce_call->context, h);
      92             : 
      93         643 :         ZERO_STRUCTP(r->out.handle);
      94             : 
      95         643 :         return WERR_OK;
      96             : }
      97             : 
      98             : /*
      99             :   winreg_CreateKey
     100             : */
     101        1680 : static WERROR dcesrv_winreg_CreateKey(struct dcesrv_call_state *dce_call,
     102             :                                       TALLOC_CTX *mem_ctx,
     103             :                                       struct winreg_CreateKey *r)
     104             : {
     105         840 :         struct auth_session_info *session_info =
     106         840 :                 dcesrv_call_session_info(dce_call);
     107             :         struct dcesrv_handle *h, *newh;
     108             :         struct security_descriptor sd;
     109             :         struct registry_key *key;
     110             :         WERROR result;
     111             : 
     112        1680 :         DCESRV_PULL_HANDLE_FAULT(h, r->in.handle, HTYPE_REGKEY);
     113        1680 :         key = h->data;
     114             : 
     115        1680 :         newh = dcesrv_handle_create(dce_call, HTYPE_REGKEY);
     116             : 
     117        1680 :         switch (security_session_user_level(session_info, NULL))
     118             :         {
     119        1680 :         case SECURITY_SYSTEM:
     120             :         case SECURITY_ADMINISTRATOR:
     121             :                 /* we support only non volatile keys */
     122        1680 :                 if (r->in.options != REG_OPTION_NON_VOLATILE) {
     123           0 :                         return WERR_NOT_SUPPORTED;
     124             :                 }
     125             : 
     126             :                 /* the security descriptor is optional */
     127        1680 :                 if (r->in.secdesc != NULL) {
     128             :                         DATA_BLOB sdblob;
     129             :                         enum ndr_err_code ndr_err;
     130           0 :                         sdblob.data = r->in.secdesc->sd.data;
     131           0 :                         sdblob.length = r->in.secdesc->sd.len;
     132           0 :                         if (sdblob.data == NULL) {
     133           0 :                                 return WERR_INVALID_PARAMETER;
     134             :                         }
     135           0 :                         ndr_err = ndr_pull_struct_blob_all(&sdblob, mem_ctx, &sd,
     136             :                                                            (ndr_pull_flags_fn_t)ndr_pull_security_descriptor);
     137           0 :                         if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
     138           0 :                                 return WERR_INVALID_PARAMETER;
     139             :                         }
     140             :                 }
     141             :                 
     142        1680 :                 result = reg_key_add_name(newh, key, r->in.name.name, NULL,
     143        1680 :                         r->in.secdesc?&sd:NULL, (struct registry_key **)&newh->data);
     144             : 
     145        1680 :                 r->out.action_taken = talloc(mem_ctx, enum winreg_CreateAction);
     146        1680 :                 if (r->out.action_taken == NULL) {
     147           0 :                         talloc_free(newh);
     148           0 :                         return WERR_NOT_ENOUGH_MEMORY;
     149             :                 }
     150        1680 :                 *r->out.action_taken = REG_ACTION_NONE;
     151             : 
     152        1680 :                 if (W_ERROR_IS_OK(result)) {
     153        1680 :                         r->out.new_handle = &newh->wire_handle;
     154        1680 :                         *r->out.action_taken = REG_CREATED_NEW_KEY;
     155             :                 } else {
     156           0 :                         talloc_free(newh);
     157             :                 }
     158             : 
     159        1680 :                 return result;
     160           0 :         default:
     161           0 :                 return WERR_ACCESS_DENIED;
     162             :         }
     163             : }
     164             : 
     165             : 
     166             : /*
     167             :   winreg_DeleteKey
     168             : */
     169        2560 : static WERROR dcesrv_winreg_DeleteKey(struct dcesrv_call_state *dce_call,
     170             :                                       TALLOC_CTX *mem_ctx,
     171             :                                       struct winreg_DeleteKey *r)
     172             : {
     173        1280 :         struct auth_session_info *session_info =
     174        1280 :                 dcesrv_call_session_info(dce_call);
     175             :         struct dcesrv_handle *h;
     176             :         struct registry_key *key;
     177             :         WERROR result;
     178             : 
     179        2560 :         DCESRV_PULL_HANDLE_FAULT(h, r->in.handle, HTYPE_REGKEY);
     180        2560 :         key = h->data;
     181             : 
     182        2560 :         switch (security_session_user_level(session_info, NULL))
     183             :         {
     184        2560 :         case SECURITY_SYSTEM:
     185             :         case SECURITY_ADMINISTRATOR:
     186        2560 :                 result = reg_key_del(mem_ctx, key, r->in.key.name);
     187        2560 :                 talloc_unlink(dce_call->context, h);
     188             : 
     189        2560 :                 return result;
     190           0 :         default:
     191           0 :                 return WERR_ACCESS_DENIED;
     192             :         }
     193             : }
     194             : 
     195             : 
     196             : /*
     197             :   winreg_DeleteValue
     198             : */
     199        1440 : static WERROR dcesrv_winreg_DeleteValue(struct dcesrv_call_state *dce_call,
     200             :                                         TALLOC_CTX *mem_ctx,
     201             :                                         struct winreg_DeleteValue *r)
     202             : {
     203         720 :         struct auth_session_info *session_info =
     204         720 :                 dcesrv_call_session_info(dce_call);
     205             :         struct dcesrv_handle *h;
     206             :         struct registry_key *key;
     207             : 
     208        1440 :         DCESRV_PULL_HANDLE_FAULT(h, r->in.handle, HTYPE_REGKEY);
     209        1440 :         key = h->data;
     210             : 
     211        1440 :         switch (security_session_user_level(session_info, NULL))
     212             :         {
     213        1440 :         case SECURITY_SYSTEM:
     214             :         case SECURITY_ADMINISTRATOR:
     215        1440 :                 return reg_del_value(mem_ctx, key, r->in.value.name);
     216           0 :         default:
     217           0 :                 return WERR_ACCESS_DENIED;
     218             :         }
     219             : }
     220             : 
     221             : 
     222             : /*
     223             :   winreg_EnumKey
     224             : */
     225         240 : static WERROR dcesrv_winreg_EnumKey(struct dcesrv_call_state *dce_call,
     226             :                                     TALLOC_CTX *mem_ctx,
     227             :                                     struct winreg_EnumKey *r)
     228             : {
     229             :         struct dcesrv_handle *h;
     230             :         struct registry_key *key;
     231             :         const char *name, *classname;
     232             :         NTTIME last_mod;
     233             :         WERROR result;
     234             : 
     235         240 :         DCESRV_PULL_HANDLE_FAULT(h, r->in.handle, HTYPE_REGKEY);
     236         240 :         key = h->data;
     237             : 
     238         240 :         result = reg_key_get_subkey_by_index(mem_ctx, 
     239             :                 key, r->in.enum_index, &name, &classname, &last_mod);
     240             : 
     241         240 :         if (2*strlen_m_term(name) > r->in.name->size) {
     242           0 :                 return WERR_MORE_DATA;
     243             :         }
     244             : 
     245         240 :         if (name != NULL) {
     246           0 :                 r->out.name->name = name;
     247           0 :                 r->out.name->length = 2*strlen_m_term(name);
     248             :         } else {
     249         240 :                 r->out.name->name = r->in.name->name;
     250         240 :                 r->out.name->length = r->in.name->length;
     251             :         }
     252         240 :         r->out.name->size = r->in.name->size;
     253             : 
     254         240 :         r->out.keyclass = r->in.keyclass;
     255         240 :         if (classname != NULL) {
     256           0 :                 r->out.keyclass->name = classname;
     257           0 :                 r->out.keyclass->length = 2*strlen_m_term(classname);
     258             :         } else {
     259         240 :                 r->out.keyclass->name = r->in.keyclass->name;
     260         240 :                 r->out.keyclass->length = r->in.keyclass->length;
     261             :         }
     262         240 :         r->out.keyclass->size = r->in.keyclass->size;
     263             : 
     264         240 :         if (r->in.last_changed_time != NULL)
     265         240 :                 r->out.last_changed_time = &last_mod;
     266             : 
     267         240 :         return result;
     268             : }
     269             : 
     270             : 
     271             : /*
     272             :   winreg_EnumValue
     273             : */
     274         480 : static WERROR dcesrv_winreg_EnumValue(struct dcesrv_call_state *dce_call,
     275             :                                       TALLOC_CTX *mem_ctx,
     276             :                                       struct winreg_EnumValue *r)
     277             : {
     278             :         struct dcesrv_handle *h;
     279             :         struct registry_key *key;
     280             :         const char *data_name;
     281             :         uint32_t data_type;
     282             :         DATA_BLOB data;
     283             :         WERROR result;
     284             : 
     285         480 :         DCESRV_PULL_HANDLE_FAULT(h, r->in.handle, HTYPE_REGKEY);
     286         480 :         key = h->data;
     287             : 
     288         480 :         result = reg_key_get_value_by_index(mem_ctx, key,
     289             :                 r->in.enum_index, &data_name, &data_type, &data);
     290             : 
     291         480 :         if (!W_ERROR_IS_OK(result)) {
     292             :                 /* if the lookup wasn't successful, send client query back */
     293         480 :                 data_name = r->in.name->name;
     294         480 :                 data_type = *r->in.type;
     295         480 :                 data.data = r->in.value;
     296         480 :                 data.length = *r->in.length;
     297             :         }
     298             : 
     299             :         /* "data_name" is NULL when we query the default attribute */
     300         480 :         if (data_name != NULL) {
     301         480 :                 r->out.name->name = data_name;
     302         480 :                 r->out.name->length = 2*strlen_m_term(data_name);
     303             :         } else {
     304           0 :                 r->out.name->name = r->in.name->name;
     305           0 :                 r->out.name->length = r->in.name->length;
     306             :         }
     307         480 :         r->out.name->size = r->in.name->size;
     308             : 
     309         480 :         r->out.type = talloc(mem_ctx, enum winreg_Type);
     310         480 :         if (!r->out.type) {
     311           0 :                 return WERR_NOT_ENOUGH_MEMORY;
     312             :         }
     313         480 :         *r->out.type = (enum winreg_Type) data_type;
     314             : 
     315             :         /* check the client has enough room for the value */
     316         600 :         if (r->in.value != NULL &&
     317         360 :             r->in.size != NULL &&
     318         240 :             data.length > *r->in.size) {
     319           0 :                 return WERR_MORE_DATA;
     320             :         }
     321             : 
     322         480 :         if (r->in.value != NULL) {
     323         240 :                 r->out.value = data.data;
     324             :         }
     325             : 
     326         480 :         if (r->in.size != NULL) {
     327         480 :                 r->out.size = talloc(mem_ctx, uint32_t);
     328         480 :                 *r->out.size = data.length;
     329         480 :                 r->out.length = r->out.size;
     330             :         }
     331             : 
     332         480 :         return result;
     333             : }
     334             : 
     335             : 
     336             : /*
     337             :   winreg_FlushKey
     338             : */
     339         640 : static WERROR dcesrv_winreg_FlushKey(struct dcesrv_call_state *dce_call,
     340             :                                      TALLOC_CTX *mem_ctx,
     341             :                                      struct winreg_FlushKey *r)
     342             : {
     343         320 :         struct auth_session_info *session_info =
     344         320 :                 dcesrv_call_session_info(dce_call);
     345             :         struct dcesrv_handle *h;
     346             :         struct registry_key *key;
     347             : 
     348         640 :         DCESRV_PULL_HANDLE_FAULT(h, r->in.handle, HTYPE_REGKEY);
     349         640 :         key = h->data;
     350             : 
     351         640 :         switch (security_session_user_level(session_info, NULL))
     352             :         {
     353         640 :         case SECURITY_SYSTEM:
     354             :         case SECURITY_ADMINISTRATOR:
     355         640 :                 return reg_key_flush(key);
     356           0 :         default:
     357           0 :                 return WERR_ACCESS_DENIED;
     358             :         }
     359             : }
     360             : 
     361             : 
     362             : /*
     363             :   winreg_GetKeySecurity
     364             : */
     365           0 : static WERROR dcesrv_winreg_GetKeySecurity(struct dcesrv_call_state *dce_call,
     366             :                                            TALLOC_CTX *mem_ctx,
     367             :                                            struct winreg_GetKeySecurity *r)
     368             : {
     369             :         struct dcesrv_handle *h;
     370             : 
     371           0 :         DCESRV_PULL_HANDLE_FAULT(h, r->in.handle, HTYPE_REGKEY);
     372             : 
     373           0 :         return WERR_NOT_SUPPORTED;
     374             : }
     375             : 
     376             : 
     377             : /*
     378             :   winreg_LoadKey
     379             : */
     380           0 : static WERROR dcesrv_winreg_LoadKey(struct dcesrv_call_state *dce_call,
     381             :                                     TALLOC_CTX *mem_ctx,
     382             :                                     struct winreg_LoadKey *r)
     383             : {
     384           0 :         return WERR_NOT_SUPPORTED;
     385             : }
     386             : 
     387             : 
     388             : /*
     389             :   winreg_NotifyChangeKeyValue
     390             : */
     391         240 : static WERROR dcesrv_winreg_NotifyChangeKeyValue(struct dcesrv_call_state *dce_call,
     392             :                                                  TALLOC_CTX *mem_ctx,
     393             :                                                  struct winreg_NotifyChangeKeyValue *r)
     394             : {
     395         240 :         return WERR_NOT_SUPPORTED;
     396             : }
     397             : 
     398             : 
     399             : /*
     400             :   winreg_OpenKey
     401             : */
     402         720 : static WERROR dcesrv_winreg_OpenKey(struct dcesrv_call_state *dce_call,
     403             :                                     TALLOC_CTX *mem_ctx,
     404             :                                     struct winreg_OpenKey *r)
     405             : {
     406         360 :         struct auth_session_info *session_info =
     407         360 :                 dcesrv_call_session_info(dce_call);
     408             :         struct dcesrv_handle *h, *newh;
     409             :         struct registry_key *key;
     410             :         WERROR result;
     411             : 
     412         720 :         DCESRV_PULL_HANDLE_FAULT(h, r->in.parent_handle, HTYPE_REGKEY);
     413         720 :         key = h->data;
     414             : 
     415         720 :         switch (security_session_user_level(session_info, NULL))
     416             :         {
     417         720 :         case SECURITY_SYSTEM:
     418             :         case SECURITY_ADMINISTRATOR:
     419             :         case SECURITY_USER:
     420         720 :                 if (r->in.keyname.name && strcmp(r->in.keyname.name, "") == 0) {
     421           0 :                         newh = talloc_reference(dce_call->context, h);
     422           0 :                         result = WERR_OK;
     423             :                 } else {
     424         720 :                         newh = dcesrv_handle_create(dce_call, HTYPE_REGKEY);
     425         720 :                         result = reg_open_key(newh, key, r->in.keyname.name,
     426         720 :                                 (struct registry_key **)&newh->data);
     427             :                 }
     428             :                 
     429         720 :                 if (W_ERROR_IS_OK(result)) {
     430         400 :                         r->out.handle = &newh->wire_handle;
     431             :                 } else {
     432         320 :                         talloc_free(newh);
     433             :                 }
     434         720 :                 return result;
     435           0 :         default:
     436           0 :                 return WERR_ACCESS_DENIED;
     437             :         }
     438             : }
     439             : 
     440             : 
     441             : /*
     442             :   winreg_QueryInfoKey
     443             : */
     444         241 : static WERROR dcesrv_winreg_QueryInfoKey(struct dcesrv_call_state *dce_call,
     445             :                                          TALLOC_CTX *mem_ctx,
     446             :                                          struct winreg_QueryInfoKey *r)
     447             : {
     448         121 :         struct auth_session_info *session_info =
     449         120 :                 dcesrv_call_session_info(dce_call);
     450             :         struct dcesrv_handle *h;
     451             :         struct registry_key *key;
     452         241 :         const char *classname = NULL;
     453             :         WERROR result;
     454             : 
     455         241 :         DCESRV_PULL_HANDLE_FAULT(h, r->in.handle, HTYPE_REGKEY);
     456         241 :         key = h->data;
     457             : 
     458         241 :         switch (security_session_user_level(session_info, NULL))
     459             :         {
     460         241 :         case SECURITY_SYSTEM:
     461             :         case SECURITY_ADMINISTRATOR:
     462             :         case SECURITY_USER:
     463         241 :                 result = reg_key_get_info(mem_ctx, key, &classname,
     464             :                         r->out.num_subkeys, r->out.num_values,
     465             :                         r->out.last_changed_time, r->out.max_subkeylen,
     466             :                         r->out.max_valnamelen, r->out.max_valbufsize);
     467             : 
     468         241 :                 if (r->out.max_subkeylen != NULL) {
     469             :                         /* for UTF16 encoding */
     470         241 :                         *r->out.max_subkeylen *= 2;
     471             :                 }
     472         241 :                 if (r->out.max_valnamelen != NULL) {
     473             :                         /* for UTF16 encoding */
     474         241 :                         *r->out.max_valnamelen *= 2;
     475             :                 }
     476             : 
     477         241 :                 if (classname != NULL) {
     478           0 :                         r->out.classname->name = classname;
     479           0 :                         r->out.classname->name_len = 2*strlen_m_term(classname);
     480             :                 } else {
     481         241 :                         r->out.classname->name = r->in.classname->name;
     482         241 :                         r->out.classname->name_len = r->in.classname->name_len;
     483             :                 }
     484         241 :                 r->out.classname->name_size = r->in.classname->name_size;
     485             : 
     486         241 :                 return result;
     487           0 :         default:
     488           0 :                 return WERR_ACCESS_DENIED;
     489             :         }
     490             : }
     491             : 
     492             : 
     493             : /*
     494             :   winreg_QueryValue
     495             : */
     496       15200 : static WERROR dcesrv_winreg_QueryValue(struct dcesrv_call_state *dce_call,
     497             :                                        TALLOC_CTX *mem_ctx,
     498             :                                        struct winreg_QueryValue *r)
     499             : {
     500        7600 :         struct auth_session_info *session_info =
     501        7600 :                 dcesrv_call_session_info(dce_call);
     502             :         struct dcesrv_handle *h;
     503             :         struct registry_key *key;
     504             :         uint32_t value_type;
     505             :         DATA_BLOB value_data;
     506             :         WERROR result;
     507             : 
     508       15200 :         DCESRV_PULL_HANDLE_FAULT(h, r->in.handle, HTYPE_REGKEY);
     509       15200 :         key = h->data;
     510             : 
     511       15200 :         switch (security_session_user_level(session_info, NULL))
     512             :         {
     513       15200 :         case SECURITY_SYSTEM:
     514             :         case SECURITY_ADMINISTRATOR:
     515             :         case SECURITY_USER:
     516       20160 :                 if ((r->in.type == NULL) || (r->in.data_length == NULL) ||
     517        9920 :                     (r->in.data_size == NULL)) {
     518        7040 :                         return WERR_INVALID_PARAMETER;
     519             :                 }
     520             : 
     521        8160 :                 result = reg_key_get_value_by_name(mem_ctx, key, 
     522        8160 :                          r->in.value_name->name, &value_type, &value_data);
     523             :                 
     524        8160 :                 if (!W_ERROR_IS_OK(result)) {
     525             :                         /* if the lookup wasn't successful, send client query back */
     526         720 :                         value_type = *r->in.type;
     527         720 :                         value_data.data = r->in.data;
     528         720 :                         value_data.length = *r->in.data_length;
     529             :                 } else {
     530        7440 :                         if ((r->in.data != NULL)
     531        5920 :                             && (*r->in.data_size < value_data.length)) {
     532        2960 :                                 result = WERR_MORE_DATA;
     533             :                         }
     534             :                 }
     535             : 
     536        8160 :                 r->out.type = talloc(mem_ctx, enum winreg_Type);
     537        8160 :                 if (!r->out.type) {
     538           0 :                         return WERR_NOT_ENOUGH_MEMORY;
     539             :                 }
     540        8160 :                 *r->out.type = (enum winreg_Type) value_type;
     541        8160 :                 r->out.data_length = talloc(mem_ctx, uint32_t);
     542        8160 :                 if (!r->out.data_length) {
     543           0 :                         return WERR_NOT_ENOUGH_MEMORY;
     544             :                 }
     545        8160 :                 *r->out.data_length = value_data.length;
     546        8160 :                 r->out.data_size = talloc(mem_ctx, uint32_t);
     547        8160 :                 if (!r->out.data_size) {
     548           0 :                         return WERR_NOT_ENOUGH_MEMORY;
     549             :                 }
     550        8160 :                 *r->out.data_size = value_data.length;
     551        8160 :                 r->out.data = value_data.data;
     552             : 
     553        8160 :                 return result;
     554           0 :         default:
     555           0 :                 return WERR_ACCESS_DENIED;
     556             :         }
     557             : }
     558             : 
     559             : 
     560             : /*
     561             :   winreg_ReplaceKey
     562             : */
     563           0 : static WERROR dcesrv_winreg_ReplaceKey(struct dcesrv_call_state *dce_call,
     564             :                                        TALLOC_CTX *mem_ctx,
     565             :                                        struct winreg_ReplaceKey *r)
     566             : {
     567           0 :         return WERR_NOT_SUPPORTED;
     568             : }
     569             : 
     570             : 
     571             : /*
     572             :   winreg_RestoreKey
     573             : */
     574           0 : static WERROR dcesrv_winreg_RestoreKey(struct dcesrv_call_state *dce_call,
     575             :                                        TALLOC_CTX *mem_ctx,
     576             :                                        struct winreg_RestoreKey *r)
     577             : {
     578           0 :         return WERR_NOT_SUPPORTED;
     579             : }
     580             : 
     581             : 
     582             : /*
     583             :   winreg_SaveKey
     584             : */
     585           0 : static WERROR dcesrv_winreg_SaveKey(struct dcesrv_call_state *dce_call,
     586             :                                     TALLOC_CTX *mem_ctx,
     587             :                                     struct winreg_SaveKey *r)
     588             : {
     589           0 :         return WERR_NOT_SUPPORTED;
     590             : }
     591             : 
     592             : 
     593             : /*
     594             :   winreg_SetKeySecurity
     595             : */
     596           0 : static WERROR dcesrv_winreg_SetKeySecurity(struct dcesrv_call_state *dce_call,
     597             :                                            TALLOC_CTX *mem_ctx,
     598             :                                            struct winreg_SetKeySecurity *r)
     599             : {
     600           0 :         return WERR_NOT_SUPPORTED;
     601             : }
     602             : 
     603             : 
     604             : /*
     605             :   winreg_SetValue
     606             : */
     607        1440 : static WERROR dcesrv_winreg_SetValue(struct dcesrv_call_state *dce_call,
     608             :                                      TALLOC_CTX *mem_ctx,
     609             :                                      struct winreg_SetValue *r)
     610             : {
     611         720 :         struct auth_session_info *session_info =
     612         720 :                 dcesrv_call_session_info(dce_call);
     613             :         struct dcesrv_handle *h;
     614             :         struct registry_key *key;
     615             :         DATA_BLOB data;
     616             :         WERROR result;
     617             : 
     618        1440 :         DCESRV_PULL_HANDLE_FAULT(h, r->in.handle, HTYPE_REGKEY);
     619        1440 :         key = h->data;
     620             : 
     621        1440 :         switch (security_session_user_level(session_info, NULL))
     622             :         {
     623        1440 :         case SECURITY_SYSTEM:
     624             :         case SECURITY_ADMINISTRATOR:
     625        1440 :                 data.data = r->in.data;
     626        1440 :                 data.length = r->in.size;
     627        1440 :                 result = reg_val_set(key, r->in.name.name, r->in.type, data);
     628        1440 :                 return result;
     629           0 :         default:
     630           0 :                 return WERR_ACCESS_DENIED;
     631             :         }
     632             : }
     633             : 
     634             : 
     635             : /*
     636             :   winreg_UnLoadKey
     637             : */
     638           0 : static WERROR dcesrv_winreg_UnLoadKey(struct dcesrv_call_state *dce_call,
     639             :                                       TALLOC_CTX *mem_ctx,
     640             :                                       struct winreg_UnLoadKey *r)
     641             : {
     642           0 :         return WERR_NOT_SUPPORTED;
     643             : }
     644             : 
     645             : 
     646             : /*
     647             :   winreg_InitiateSystemShutdown
     648             : */
     649           0 : static WERROR dcesrv_winreg_InitiateSystemShutdown(struct dcesrv_call_state *dce_call,
     650             :                                                    TALLOC_CTX *mem_ctx,
     651             :                                                    struct winreg_InitiateSystemShutdown *r)
     652             : {
     653           0 :         return WERR_NOT_SUPPORTED;
     654             : }
     655             : 
     656             : 
     657             : /*
     658             :   winreg_AbortSystemShutdown
     659             : */
     660           0 : static WERROR dcesrv_winreg_AbortSystemShutdown(struct dcesrv_call_state *dce_call,
     661             :                                                 TALLOC_CTX *mem_ctx,
     662             :                                                 struct winreg_AbortSystemShutdown *r)
     663             : {
     664           0 :         return WERR_NOT_SUPPORTED;
     665             : }
     666             : 
     667             : 
     668             : /*
     669             :   winreg_GetVersion
     670             : */
     671         321 : static WERROR dcesrv_winreg_GetVersion(struct dcesrv_call_state *dce_call,
     672             :                                        TALLOC_CTX *mem_ctx,
     673             :                                        struct winreg_GetVersion *r)
     674             : {
     675             :         struct dcesrv_handle *h;
     676             : 
     677         321 :         DCESRV_PULL_HANDLE_FAULT(h, r->in.handle, HTYPE_REGKEY);
     678             : 
     679         321 :         r->out.version = talloc(mem_ctx, uint32_t);
     680         321 :         W_ERROR_HAVE_NO_MEMORY(r->out.version);
     681             : 
     682         321 :         *r->out.version = 5;
     683             : 
     684         321 :         return WERR_OK;
     685             : }
     686             : 
     687             : 
     688             : /*
     689             :   winreg_QueryMultipleValues
     690             : */
     691           0 : static WERROR dcesrv_winreg_QueryMultipleValues(struct dcesrv_call_state *dce_call,
     692             :                                                 TALLOC_CTX *mem_ctx,
     693             :                                                 struct winreg_QueryMultipleValues *r)
     694             : {
     695           0 :         return WERR_NOT_SUPPORTED;
     696             : }
     697             : 
     698             : 
     699             : /*
     700             :   winreg_InitiateSystemShutdownEx
     701             : */
     702           0 : static WERROR dcesrv_winreg_InitiateSystemShutdownEx(struct dcesrv_call_state *dce_call,
     703             :                                                      TALLOC_CTX *mem_ctx,
     704             :                                                      struct winreg_InitiateSystemShutdownEx *r)
     705             : {
     706           0 :         return WERR_NOT_SUPPORTED;
     707             : }
     708             : 
     709             : 
     710             : /*
     711             :   winreg_SaveKeyEx
     712             : */
     713           0 : static WERROR dcesrv_winreg_SaveKeyEx(struct dcesrv_call_state *dce_call,
     714             :                                       TALLOC_CTX *mem_ctx,
     715             :                                       struct winreg_SaveKeyEx *r)
     716             : {
     717           0 :         return WERR_NOT_SUPPORTED;
     718             : }
     719             : 
     720             : 
     721             : /*
     722             :   winreg_QueryMultipleValues2
     723             : */
     724           0 : static WERROR dcesrv_winreg_QueryMultipleValues2(struct dcesrv_call_state *dce_call,
     725             :                                                  TALLOC_CTX *mem_ctx,
     726             :                                                  struct winreg_QueryMultipleValues2 *r)
     727             : {
     728           0 :         return WERR_NOT_SUPPORTED;
     729             : }
     730             : 
     731             : /*
     732             :   winreg_DeleteKeyEx
     733             : */
     734           0 : static WERROR dcesrv_winreg_DeleteKeyEx(struct dcesrv_call_state *dce_call,
     735             :                                         TALLOC_CTX *mem_ctx,
     736             :                                         struct winreg_DeleteKeyEx *r)
     737             : {
     738           0 :         return WERR_NOT_SUPPORTED;
     739             : }
     740             : 
     741             : /* include the generated boilerplate */
     742             : #include "librpc/gen_ndr/ndr_winreg_s.c"

Generated by: LCOV version 1.13