3 * Unix SMB/Netbios implementation.
5 * RPC Pipe client / server routines
6 * Copyright (C) Andrew Tridgell 1992-1997,
7 * Copyright (C) Luke Kenneth Casson Leighton 1996-1997,
8 * Copyright (C) Paul Ashton 1997.
9 * Copyright (C) Hewlett-Packard Company 1999.
10 * Copyright (C) Jeremy Allison 2001.
12 * This program is free software; you can redistribute it and/or modify
13 * it under the terms of the GNU General Public License as published by
14 * the Free Software Foundation; either version 2 of the License, or
15 * (at your option) any later version.
17 * This program is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details.
22 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, write to the Free Software
24 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
27 /* Implementation of registry functions. */
31 extern int DEBUGLEVEL;
33 /*******************************************************************
35 ********************************************************************/
37 uint32 _reg_close(pipes_struct *p, REG_Q_CLOSE *q_u, REG_R_CLOSE *r_u)
39 /* set up the REG unknown_1 response */
40 ZERO_STRUCT(r_u->pol);
42 /* close the policy handle */
43 if (!close_lsa_policy_hnd(&q_u->pol))
44 return NT_STATUS_OBJECT_NAME_INVALID;
46 return NT_STATUS_NOPROBLEMO;
49 /*******************************************************************
51 ********************************************************************/
53 uint32 _reg_open(pipes_struct *p, REG_Q_OPEN_HKLM *q_u, REG_R_OPEN_HKLM *r_u)
55 if (!open_lsa_policy_hnd(&r_u->pol))
56 return NT_STATUS_OBJECT_NAME_NOT_FOUND;
58 return NT_STATUS_NOPROBLEMO;
61 /*******************************************************************
63 ********************************************************************/
65 uint32 _reg_open_entry(pipes_struct *p, REG_Q_OPEN_ENTRY *q_u, REG_R_OPEN_ENTRY *r_u)
70 DEBUG(5,("reg_open_entry: %d\n", __LINE__));
72 if (find_lsa_policy_by_hnd(&q_u->pol) == -1)
73 return NT_STATUS_INVALID_HANDLE;
75 if (!open_lsa_policy_hnd(&pol))
76 return NT_STATUS_TOO_MANY_SECRETS; /* ha ha very droll */
78 fstrcpy(name, dos_unistrn2(q_u->uni_name.buffer, q_u->uni_name.uni_str_len));
80 DEBUG(5,("reg_open_entry: %s\n", name));
82 /* lkcl XXXX do a check on the name, here */
83 if (!strequal(name, "SYSTEM\\CurrentControlSet\\Control\\ProductOptions") &&
84 !strequal(name, "System\\CurrentControlSet\\services\\Netlogon\\parameters\\"))
85 return NT_STATUS_ACCESS_DENIED;
87 if (!set_lsa_policy_reg_name(&pol, name))
88 return NT_STATUS_TOO_MANY_SECRETS; /* ha ha very droll */
90 init_reg_r_open_entry(r_u, &pol, NT_STATUS_NOPROBLEMO);
92 DEBUG(5,("reg_open_entry: %d\n", __LINE__));
97 /*******************************************************************
99 ********************************************************************/
101 uint32 _reg_info(pipes_struct *p, REG_Q_INFO *q_u, REG_R_INFO *r_u)
103 uint32 status = NT_STATUS_NOPROBLEMO;
105 uint32 type=0x1; /* key type: REG_SZ */
107 UNISTR2 *uni_key = NULL;
111 DEBUG(5,("_reg_info: %d\n", __LINE__));
113 if (find_lsa_policy_by_hnd(&q_u->pol) == -1)
114 return NT_STATUS_INVALID_HANDLE;
116 fstrcpy(name, dos_unistrn2(q_u->uni_type.buffer, q_u->uni_type.uni_str_len));
118 DEBUG(5,("reg_info: checking key: %s\n", name));
120 uni_key = (UNISTR2 *)talloc_zero(p->mem_ctx, sizeof(UNISTR2));
121 buf = (BUFFER2 *)talloc_zero(p->mem_ctx, sizeof(BUFFER2));
123 if (!uni_key || !buf)
124 return NT_STATUS_NO_MEMORY;
126 if ( strequal(name, "RefusePasswordChange") ) {
129 init_unistr2(uni_key, "", 0);
130 init_buffer2(buf, (uint8*) uni_key->buffer, uni_key->uni_str_len*2);
137 switch (lp_server_role()) {
138 case ROLE_DOMAIN_PDC:
139 case ROLE_DOMAIN_BDC:
142 case ROLE_STANDALONE:
145 case ROLE_DOMAIN_MEMBER:
150 /* This makes the server look like a member server to clients */
151 /* which tells clients that we have our own local user and */
152 /* group databases and helps with ACL support. */
154 init_unistr2(uni_key, key, strlen(key)+1);
155 init_buffer2(buf, (uint8*)uni_key->buffer, uni_key->uni_str_len*2);
158 init_reg_r_info(q_u->ptr_buf, r_u, buf, type, status);
160 DEBUG(5,("reg_open_entry: %d\n", __LINE__));