-/*
+/*
* Unix SMB/CIFS implementation.
* RPC Pipe client / server routines
*
* Copyright (C) Gerald (Jerry) Carter 2005.
- *
+ * Copyright (C) Guenther Deschner 2008,2009.
+ *
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
- *
+ *
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with this program; if not, see <http://www.gnu.org/licenses/>.
*/
/********************************************************************
********************************************************************/
-WERROR _ntsvcs_get_device_list_size( pipes_struct *p, NTSVCS_Q_GET_DEVICE_LIST_SIZE *q_u, NTSVCS_R_GET_DEVICE_LIST_SIZE *r_u )
+WERROR _PNP_GetDeviceListSize(pipes_struct *p,
+ struct PNP_GetDeviceListSize *r)
{
- fstring device;
char *devicepath;
- if ( !q_u->devicename )
- return WERR_ACCESS_DENIED;
-
- rpcstr_pull(device, q_u->devicename->buffer, sizeof(device), q_u->devicename->uni_str_len*2, 0);
+ if ((r->in.flags & CM_GETIDLIST_FILTER_SERVICE) &&
+ (!r->in.devicename)) {
+ return WERR_CM_INVALID_POINTER;
+ }
- if (!(devicepath = get_device_path(p->mem_ctx, device))) {
+ if (!(devicepath = get_device_path(p->mem_ctx, r->in.devicename))) {
return WERR_NOMEM;
}
- r_u->size = strlen(devicepath) + 2;
+ *r->out.size = strlen(devicepath) + 2;
TALLOC_FREE(devicepath);
return WERR_OK;
}
+/****************************************************************
+ _PNP_GetDeviceList
+****************************************************************/
-/********************************************************************
-********************************************************************/
-
-WERROR _ntsvcs_get_device_list( pipes_struct *p, NTSVCS_Q_GET_DEVICE_LIST *q_u, NTSVCS_R_GET_DEVICE_LIST *r_u )
+WERROR _PNP_GetDeviceList(pipes_struct *p,
+ struct PNP_GetDeviceList *r)
{
- fstring device;
char *devicepath;
+ uint32_t size = 0;
+ const char **multi_sz = NULL;
+ DATA_BLOB blob;
+
+ if ((r->in.flags & CM_GETIDLIST_FILTER_SERVICE) &&
+ (!r->in.filter)) {
+ return WERR_CM_INVALID_POINTER;
+ }
+
+ if (!(devicepath = get_device_path(p->mem_ctx, r->in.filter))) {
+ return WERR_NOMEM;
+ }
- if ( !q_u->devicename )
- return WERR_ACCESS_DENIED;
+ size = strlen(devicepath) + 2;
- rpcstr_pull(device, q_u->devicename->buffer, sizeof(device), q_u->devicename->uni_str_len*2, 0);
+ if (*r->in.length < size) {
+ return WERR_CM_BUFFER_SMALL;
+ }
- if (!(devicepath = get_device_path(p->mem_ctx, device))) {
+ multi_sz = talloc_zero_array(p->mem_ctx, const char *, 2);
+ if (!multi_sz) {
return WERR_NOMEM;
}
- /* This has to be DOUBLE NULL terminated */
+ multi_sz[0] = devicepath;
- init_unistr2( &r_u->devicepath, devicepath, UNI_STR_DBLTERMINATE );
- TALLOC_FREE(devicepath);
- r_u->needed = r_u->devicepath.uni_str_len;
+ if (!push_reg_multi_sz(multi_sz, &blob, multi_sz)) {
+ return WERR_NOMEM;
+ }
+
+ if (*r->in.length < blob.length/2) {
+ return WERR_CM_BUFFER_SMALL;
+ }
+
+ memcpy(r->out.buffer, blob.data, blob.length);
return WERR_OK;
}
/********************************************************************
+_PNP_GetDeviceRegProp
********************************************************************/
-WERROR _ntsvcs_get_device_reg_property( pipes_struct *p, NTSVCS_Q_GET_DEVICE_REG_PROPERTY *q_u, NTSVCS_R_GET_DEVICE_REG_PROPERTY *r_u )
+WERROR _PNP_GetDeviceRegProp(pipes_struct *p,
+ struct PNP_GetDeviceRegProp *r)
{
- fstring devicepath;
char *ptr;
- REGVAL_CTR *values;
- REGISTRY_VALUE *val;
+ struct regval_ctr *values;
+ struct regval_blob *val;
- rpcstr_pull(devicepath, q_u->devicepath.buffer, sizeof(devicepath), q_u->devicepath.uni_str_len*2, 0);
-
- switch( q_u->property ) {
+ switch( r->in.property ) {
case DEV_REGPROP_DESC:
- /* just parse the service name from the device path and then
+
+ /* just parse the service name from the device path and then
lookup the display name */
- if ( !(ptr = strrchr_m( devicepath, '\\' )) )
- return WERR_GENERAL_FAILURE;
+ if ( !(ptr = strrchr_m( r->in.devicepath, '\\' )) )
+ return WERR_GENERAL_FAILURE;
*ptr = '\0';
-
- if ( !(ptr = strrchr_m( devicepath, '_' )) )
- return WERR_GENERAL_FAILURE;
+
+ if ( !(ptr = strrchr_m( r->in.devicepath, '_' )) )
+ return WERR_GENERAL_FAILURE;
ptr++;
-
- if ( !(values = svcctl_fetch_regvalues( ptr, p->pipe_user.nt_user_token )) )
- return WERR_GENERAL_FAILURE;
-
+
+ if ( !(values = svcctl_fetch_regvalues(
+ ptr, p->server_info->ptok)))
+ return WERR_GENERAL_FAILURE;
+
if ( !(val = regval_ctr_getvalue( values, "DisplayName" )) ) {
TALLOC_FREE( values );
return WERR_GENERAL_FAILURE;
}
-
- r_u->unknown1 = 0x1; /* always 1...tested using a remove device manager connection */
- r_u->size = reg_init_regval_buffer( &r_u->value, val );
- r_u->needed = r_u->size;
+ if (*r->in.buffer_size < val->size) {
+ *r->out.needed = val->size;
+ *r->out.buffer_size = 0;
+ TALLOC_FREE( values );
+ return WERR_CM_BUFFER_SMALL;
+ }
+
+ r->out.buffer = (uint8_t *)talloc_memdup(p->mem_ctx, val->data_p, val->size);
TALLOC_FREE(values);
+ if (!r->out.buffer) {
+ return WERR_NOMEM;
+ }
+
+ *r->out.reg_data_type = REG_SZ; /* always 1...tested using a remove device manager connection */
+ *r->out.buffer_size = val->size;
+ *r->out.needed = val->size;
break;
-
+
default:
- r_u->unknown1 = 0x00437c98;
+ *r->out.reg_data_type = 0x00437c98; /* ??? */
return WERR_CM_NO_SUCH_VALUE;
}
/********************************************************************
********************************************************************/
-WERROR _ntsvcs_get_hw_profile_info( pipes_struct *p, NTSVCS_Q_GET_HW_PROFILE_INFO *q_u, NTSVCS_R_GET_HW_PROFILE_INFO *r_u )
+WERROR _PNP_GetHwProfInfo(pipes_struct *p,
+ struct PNP_GetHwProfInfo *r)
{
/* steal the incoming buffer */
- r_u->buffer_size = q_u->buffer_size;
- r_u->buffer = q_u->buffer;
+ r->out.info = r->in.info;
/* Take the 5th Ammentment */
/********************************************************************
********************************************************************/
-WERROR _ntsvcs_hw_profile_flags( pipes_struct *p, NTSVCS_Q_HW_PROFILE_FLAGS *q_u, NTSVCS_R_HW_PROFILE_FLAGS *r_u )
-{
+WERROR _PNP_HwProfFlags(pipes_struct *p,
+ struct PNP_HwProfFlags *r)
+{
/* just nod your head */
-
+
return WERR_OK;
}
/****************************************************************
****************************************************************/
-WERROR _PNP_GetDeviceList(pipes_struct *p,
- struct PNP_GetDeviceList *r)
-{
- p->rng_fault_state = true;
- return WERR_NOT_SUPPORTED;
-}
-
-/****************************************************************
-****************************************************************/
-
-WERROR _PNP_GetDeviceListSize(pipes_struct *p,
- struct PNP_GetDeviceListSize *r)
-{
- p->rng_fault_state = true;
- return WERR_NOT_SUPPORTED;
-}
-
-/****************************************************************
-****************************************************************/
-
WERROR _PNP_GetDepth(pipes_struct *p,
struct PNP_GetDepth *r)
{
/****************************************************************
****************************************************************/
-WERROR _PNP_GetDeviceRegProp(pipes_struct *p,
- struct PNP_GetDeviceRegProp *r)
-{
- p->rng_fault_state = true;
- return WERR_NOT_SUPPORTED;
-}
-
-/****************************************************************
-****************************************************************/
-
WERROR _PNP_SetDeviceRegProp(pipes_struct *p,
struct PNP_SetDeviceRegProp *r)
{
/****************************************************************
****************************************************************/
-WERROR _PNP_HwProfFlags(pipes_struct *p,
- struct PNP_HwProfFlags *r)
-{
- p->rng_fault_state = true;
- return WERR_NOT_SUPPORTED;
-}
-
-/****************************************************************
-****************************************************************/
-
-WERROR _PNP_GetHwProfInfo(pipes_struct *p,
- struct PNP_GetHwProfInfo *r)
-{
- p->rng_fault_state = true;
- return WERR_NOT_SUPPORTED;
-}
-
-/****************************************************************
-****************************************************************/
-
WERROR _PNP_AddEmptyLogConf(pipes_struct *p,
struct PNP_AddEmptyLogConf *r)
{