Patch 2 of 3 from Debian Samba packagers:
[Samba.git] / source / rpc_server / srv_ntsvcs_nt.c
blob16c74c5d6dc4555e890b5b5ff68395af002ea25f
1 /*
2 * Unix SMB/CIFS implementation.
3 * RPC Pipe client / server routines
5 * Copyright (C) Gerald (Jerry) Carter 2005.
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 3 of the License, or
10 * (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, see <http://www.gnu.org/licenses/>.
21 #include "includes.h"
23 #undef DBGC_CLASS
24 #define DBGC_CLASS DBGC_RPC_SRV
26 /********************************************************************
27 ********************************************************************/
29 static char* get_device_path(TALLOC_CTX *mem_ctx, const char *device )
31 return talloc_asprintf(mem_ctx, "ROOT\\Legacy_%s\\0000", device);
34 /********************************************************************
35 ********************************************************************/
37 WERROR _ntsvcs_get_version( pipes_struct *p, NTSVCS_Q_GET_VERSION *q_u, NTSVCS_R_GET_VERSION *r_u )
39 r_u->version = 0x00000400; /* no idea what this means */
41 return WERR_OK;
44 /********************************************************************
45 ********************************************************************/
47 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 )
49 fstring device;
50 char *devicepath;
52 if ( !q_u->devicename )
53 return WERR_ACCESS_DENIED;
55 rpcstr_pull(device, q_u->devicename->buffer, sizeof(device), q_u->devicename->uni_str_len*2, 0);
57 if (!(devicepath = get_device_path(p->mem_ctx, device))) {
58 return WERR_NOMEM;
61 r_u->size = strlen(devicepath) + 2;
63 TALLOC_FREE(devicepath);
65 return WERR_OK;
69 /********************************************************************
70 ********************************************************************/
72 WERROR _ntsvcs_get_device_list( pipes_struct *p, NTSVCS_Q_GET_DEVICE_LIST *q_u, NTSVCS_R_GET_DEVICE_LIST *r_u )
74 fstring device;
75 char *devicepath;
77 if ( !q_u->devicename )
78 return WERR_ACCESS_DENIED;
80 rpcstr_pull(device, q_u->devicename->buffer, sizeof(device), q_u->devicename->uni_str_len*2, 0);
82 if (!(devicepath = get_device_path(p->mem_ctx, device))) {
83 return WERR_NOMEM;
86 /* This has to be DOUBLE NULL terminated */
88 init_unistr2( &r_u->devicepath, devicepath, UNI_STR_DBLTERMINATE );
89 TALLOC_FREE(devicepath);
90 r_u->needed = r_u->devicepath.uni_str_len;
92 return WERR_OK;
95 /********************************************************************
96 ********************************************************************/
98 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 )
100 fstring devicepath;
101 char *ptr;
102 REGVAL_CTR *values;
103 REGISTRY_VALUE *val;
105 rpcstr_pull(devicepath, q_u->devicepath.buffer, sizeof(devicepath), q_u->devicepath.uni_str_len*2, 0);
107 switch( q_u->property ) {
108 case DEV_REGPROP_DESC:
109 /* just parse the service name from the device path and then
110 lookup the display name */
111 if ( !(ptr = strrchr_m( devicepath, '\\' )) )
112 return WERR_GENERAL_FAILURE;
113 *ptr = '\0';
115 if ( !(ptr = strrchr_m( devicepath, '_' )) )
116 return WERR_GENERAL_FAILURE;
117 ptr++;
119 if ( !(values = svcctl_fetch_regvalues( ptr, p->pipe_user.nt_user_token )) )
120 return WERR_GENERAL_FAILURE;
122 if ( !(val = regval_ctr_getvalue( values, "DisplayName" )) ) {
123 TALLOC_FREE( values );
124 return WERR_GENERAL_FAILURE;
127 r_u->unknown1 = 0x1; /* always 1...tested using a remove device manager connection */
128 r_u->size = reg_init_regval_buffer( &r_u->value, val );
129 r_u->needed = r_u->size;
131 TALLOC_FREE(values);
133 break;
135 default:
136 r_u->unknown1 = 0x00437c98;
137 return WERR_CM_NO_SUCH_VALUE;
140 return WERR_OK;
143 /********************************************************************
144 ********************************************************************/
146 WERROR _ntsvcs_validate_device_instance( pipes_struct *p, NTSVCS_Q_VALIDATE_DEVICE_INSTANCE *q_u, NTSVCS_R_VALIDATE_DEVICE_INSTANCE *r_u )
148 /* whatever dude */
149 return WERR_OK;
152 /********************************************************************
153 ********************************************************************/
155 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 )
157 /* steal the incoming buffer */
159 r_u->buffer_size = q_u->buffer_size;
160 r_u->buffer = q_u->buffer;
162 /* Take the 5th Ammentment */
164 return WERR_CM_NO_MORE_HW_PROFILES;
167 /********************************************************************
168 ********************************************************************/
170 WERROR _ntsvcs_hw_profile_flags( pipes_struct *p, NTSVCS_Q_HW_PROFILE_FLAGS *q_u, NTSVCS_R_HW_PROFILE_FLAGS *r_u )
172 /* just nod your head */
174 return WERR_OK;