4  * The contents of this file are subject to the terms of the
   5  * Common Development and Distribution License (the "License").
   6  * You may not use this file except in compliance with the License.
   7  *
   8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
   9  * or http://www.opensolaris.org/os/licensing.
  10  * See the License for the specific language governing permissions
  11  * and limitations under the License.
  12  *
  13  * When distributing Covered Code, include this CDDL HEADER in each
  14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  15  * If applicable, add the following below this CDDL HEADER, with the
  16  * fields enclosed by brackets "[]" replaced with your own identifying
  17  * information: Portions Copyright [yyyy] [name of copyright owner]
  18  *
  19  * CDDL HEADER END
  20  */
  21 
  22 /*
  23  * Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved.
  24  */
  25 
  26 /*
  27  * Windows Registry RPC (WINREG) server-side interface.
  28  *
  29  * The registry is a database with a hierarchical structure similar to
  30  * a file system, with keys in place of directories and values in place
  31  * of files.  The top level keys are known as root keys and each key can
  32  * contain subkeys and values.  As with directories and sub-directories,
  33  * the terms key and subkey are used interchangeably.  Values, analogous
  34  * to files, contain data.
  35  *
  36  * A specific subkey can be identifies by its fully qualified name (FQN),
  37  * which is analogous to a file system path.  In the registry, the key
  38  * separator is the '\' character, which is reserved and cannot appear
  39  * in key or value names.  Registry names are case-insensitive.
  40  *
  41  * For example:  HKEY_LOCAL_MACHINE\System\CurrentControlSet
  42  *
  43  * The HKEY_LOCAL_MACHINE root key contains a subkey called System, and
 
 
 890  *
 891  * This is a request to get the value associated with a specified name.
 892  *
 893  * Returns:
 894  *      ERROR_SUCCESS           Value returned.
 895  *      ERROR_FILE_NOT_FOUND    PrimaryModule is not supported.
 896  *      ERROR_CANTREAD          No such name or memory problem.
 897  */
 898 static int
 899 winreg_s_QueryValue(void *arg, ndr_xa_t *mxa)
 900 {
 901         struct winreg_QueryValue *param = arg;
 902         struct winreg_value *pv;
 903         char *name;
 904         char *value;
 905         DWORD slen;
 906         DWORD msize;
 907 
 908         name = (char *)param->value_name.str;
 909 
 910         if (strcasecmp(name, "PrimaryModule") == 0) {
 911                 param->status = ERROR_FILE_NOT_FOUND;
 912                 return (NDR_DRC_OK);
 913         }
 914 
 915         if ((value = winreg_lookup_value(name)) == NULL) {
 916                 param->status = ERROR_CANTREAD;
 917                 return (NDR_DRC_OK);
 918         }
 919 
 920         slen = smb_wcequiv_strlen(value) + sizeof (smb_wchar_t);
 921         msize = sizeof (struct winreg_value) + slen;
 922 
 923         param->value = (struct winreg_value *)NDR_MALLOC(mxa, msize);
 924         param->type = NDR_NEW(mxa, DWORD);
 925         param->value_size = NDR_NEW(mxa, DWORD);
 926         param->value_size_total = NDR_NEW(mxa, DWORD);
 927 
 928         if (param->value == NULL || param->type == NULL ||
 929             param->value_size == NULL || param->value_size_total == NULL) {
 930                 param->status = ERROR_CANTREAD;
 
 | 
 
 
   4  * The contents of this file are subject to the terms of the
   5  * Common Development and Distribution License (the "License").
   6  * You may not use this file except in compliance with the License.
   7  *
   8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
   9  * or http://www.opensolaris.org/os/licensing.
  10  * See the License for the specific language governing permissions
  11  * and limitations under the License.
  12  *
  13  * When distributing Covered Code, include this CDDL HEADER in each
  14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  15  * If applicable, add the following below this CDDL HEADER, with the
  16  * fields enclosed by brackets "[]" replaced with your own identifying
  17  * information: Portions Copyright [yyyy] [name of copyright owner]
  18  *
  19  * CDDL HEADER END
  20  */
  21 
  22 /*
  23  * Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved.
  24  * Copyright 2016 Nexenta Systems, Inc.  All rights reserved.
  25  */
  26 
  27 /*
  28  * Windows Registry RPC (WINREG) server-side interface.
  29  *
  30  * The registry is a database with a hierarchical structure similar to
  31  * a file system, with keys in place of directories and values in place
  32  * of files.  The top level keys are known as root keys and each key can
  33  * contain subkeys and values.  As with directories and sub-directories,
  34  * the terms key and subkey are used interchangeably.  Values, analogous
  35  * to files, contain data.
  36  *
  37  * A specific subkey can be identifies by its fully qualified name (FQN),
  38  * which is analogous to a file system path.  In the registry, the key
  39  * separator is the '\' character, which is reserved and cannot appear
  40  * in key or value names.  Registry names are case-insensitive.
  41  *
  42  * For example:  HKEY_LOCAL_MACHINE\System\CurrentControlSet
  43  *
  44  * The HKEY_LOCAL_MACHINE root key contains a subkey called System, and
 
 
 891  *
 892  * This is a request to get the value associated with a specified name.
 893  *
 894  * Returns:
 895  *      ERROR_SUCCESS           Value returned.
 896  *      ERROR_FILE_NOT_FOUND    PrimaryModule is not supported.
 897  *      ERROR_CANTREAD          No such name or memory problem.
 898  */
 899 static int
 900 winreg_s_QueryValue(void *arg, ndr_xa_t *mxa)
 901 {
 902         struct winreg_QueryValue *param = arg;
 903         struct winreg_value *pv;
 904         char *name;
 905         char *value;
 906         DWORD slen;
 907         DWORD msize;
 908 
 909         name = (char *)param->value_name.str;
 910 
 911         if (name == NULL ||
 912             strcasecmp(name, "PrimaryModule") == 0) {
 913                 param->status = ERROR_FILE_NOT_FOUND;
 914                 return (NDR_DRC_OK);
 915         }
 916 
 917         if ((value = winreg_lookup_value(name)) == NULL) {
 918                 param->status = ERROR_CANTREAD;
 919                 return (NDR_DRC_OK);
 920         }
 921 
 922         slen = smb_wcequiv_strlen(value) + sizeof (smb_wchar_t);
 923         msize = sizeof (struct winreg_value) + slen;
 924 
 925         param->value = (struct winreg_value *)NDR_MALLOC(mxa, msize);
 926         param->type = NDR_NEW(mxa, DWORD);
 927         param->value_size = NDR_NEW(mxa, DWORD);
 928         param->value_size_total = NDR_NEW(mxa, DWORD);
 929 
 930         if (param->value == NULL || param->type == NULL ||
 931             param->value_size == NULL || param->value_size_total == NULL) {
 932                 param->status = ERROR_CANTREAD;
 
 |