summaryrefslogtreecommitdiffstats
path: root/source3/rpc_server
diff options
context:
space:
mode:
Diffstat (limited to 'source3/rpc_server')
-rw-r--r--source3/rpc_server/dcesrv_gssapi.c71
-rw-r--r--source3/rpc_server/dfs/srv_dfs_nt.c38
-rw-r--r--source3/rpc_server/dssetup/srv_dssetup_nt.c4
-rw-r--r--source3/rpc_server/echo/srv_echo_nt.c6
-rw-r--r--source3/rpc_server/epmapper/srv_epmapper.c3
-rw-r--r--source3/rpc_server/epmd.c6
-rw-r--r--source3/rpc_server/eventlog/srv_eventlog_nt.c6
-rw-r--r--source3/rpc_server/initshutdown/srv_initshutdown_nt.c2
-rw-r--r--source3/rpc_server/lsa/srv_lsa_nt.c58
-rw-r--r--source3/rpc_server/netlogon/srv_netlog_nt.c20
-rw-r--r--source3/rpc_server/ntsvcs/srv_ntsvcs_nt.c2
-rw-r--r--source3/rpc_server/rpc_contexts.c40
-rw-r--r--source3/rpc_server/rpc_contexts.h28
-rw-r--r--source3/rpc_server/rpc_ep_setup.c89
-rw-r--r--source3/rpc_server/rpc_ep_setup.h2
-rw-r--r--source3/rpc_server/rpc_handles.c51
-rw-r--r--source3/rpc_server/rpc_ncacn_np.c98
-rw-r--r--source3/rpc_server/rpc_ncacn_np.h15
-rw-r--r--source3/rpc_server/rpc_server.c59
-rw-r--r--source3/rpc_server/rpc_server.h4
-rw-r--r--source3/rpc_server/samr/srv_samr_nt.c69
-rw-r--r--source3/rpc_server/samr/srv_samr_util.c11
-rw-r--r--source3/rpc_server/spoolss/srv_spoolss_nt.c147
-rw-r--r--source3/rpc_server/spoolss/srv_spoolss_nt.h40
-rw-r--r--source3/rpc_server/spoolss/srv_spoolss_util.c21
-rw-r--r--source3/rpc_server/srv_access_check.h34
-rw-r--r--source3/rpc_server/srv_pipe.c174
-rw-r--r--source3/rpc_server/srv_pipe.h33
-rw-r--r--source3/rpc_server/srv_pipe_hnd.c32
-rw-r--r--source3/rpc_server/srv_pipe_hnd.h51
-rw-r--r--source3/rpc_server/srv_pipe_register.c3
-rw-r--r--source3/rpc_server/srv_pipe_register.h39
-rw-r--r--source3/rpc_server/srvsvc/srv_srvsvc_nt.c139
-rw-r--r--source3/rpc_server/svcctl/srv_svcctl_nt.c33
-rw-r--r--source3/rpc_server/svcctl/srv_svcctl_nt.h33
-rw-r--r--source3/rpc_server/winreg/srv_winreg_nt.c5
-rw-r--r--source3/rpc_server/wkssvc/srv_wkssvc_nt.c24
-rw-r--r--source3/rpc_server/wscript_build32
38 files changed, 892 insertions, 630 deletions
diff --git a/source3/rpc_server/dcesrv_gssapi.c b/source3/rpc_server/dcesrv_gssapi.c
index ec024596332..534e8a41896 100644
--- a/source3/rpc_server/dcesrv_gssapi.c
+++ b/source3/rpc_server/dcesrv_gssapi.c
@@ -23,7 +23,9 @@
#include "../librpc/gen_ndr/ndr_krb5pac.h"
#include "librpc/crypto/gse.h"
#include "auth.h"
-
+#ifdef HAVE_KRB5
+#include "libcli/auth/krb5_wrap.h"
+#endif
NTSTATUS gssapi_server_auth_start(TALLOC_CTX *mem_ctx,
bool do_sign,
bool do_seal,
@@ -105,14 +107,9 @@ NTSTATUS gssapi_server_get_user_info(struct gse_context *gse_ctx,
struct auth_serversupplied_info **server_info)
{
TALLOC_CTX *tmp_ctx;
- DATA_BLOB auth_data;
- time_t tgs_authtime;
- NTTIME tgs_authtime_nttime;
- DATA_BLOB pac;
- struct PAC_DATA *pac_data;
- struct PAC_LOGON_NAME *logon_name = NULL;
+ DATA_BLOB pac_blob;
+ struct PAC_DATA *pac_data = NULL;
struct PAC_LOGON_INFO *logon_info = NULL;
- enum ndr_err_code ndr_err;
unsigned int i;
bool is_mapped;
bool is_guest;
@@ -122,14 +119,13 @@ NTSTATUS gssapi_server_get_user_info(struct gse_context *gse_ctx,
char *username;
struct passwd *pw;
NTSTATUS status;
- bool bret;
tmp_ctx = talloc_new(mem_ctx);
if (!tmp_ctx) {
return NT_STATUS_NO_MEMORY;
}
- status = gse_get_authz_data(gse_ctx, tmp_ctx, &auth_data);
+ status = gse_get_pac_blob(gse_ctx, tmp_ctx, &pac_blob);
if (NT_STATUS_EQUAL(status, NT_STATUS_NOT_FOUND)) {
/* TODO: Fetch user by principal name ? */
status = NT_STATUS_ACCESS_DENIED;
@@ -139,37 +135,22 @@ NTSTATUS gssapi_server_get_user_info(struct gse_context *gse_ctx,
goto done;
}
- bret = unwrap_pac(tmp_ctx, &auth_data, &pac);
- if (!bret) {
- DEBUG(1, ("Failed to unwrap PAC\n"));
- status = NT_STATUS_ACCESS_DENIED;
- goto done;
- }
-
- status = gse_get_client_name(gse_ctx, tmp_ctx, &princ_name);
+#ifdef HAVE_KRB5
+ status = kerberos_decode_pac(tmp_ctx,
+ pac_blob,
+ NULL, NULL, NULL, NULL, 0, &pac_data);
+#else
+ status = NT_STATUS_ACCESS_DENIED;
+#endif
+ data_blob_free(&pac_blob);
if (!NT_STATUS_IS_OK(status)) {
goto done;
}
- status = gse_get_authtime(gse_ctx, &tgs_authtime);
+ status = gse_get_client_name(gse_ctx, tmp_ctx, &princ_name);
if (!NT_STATUS_IS_OK(status)) {
goto done;
}
- unix_to_nt_time(&tgs_authtime_nttime, tgs_authtime);
-
- pac_data = talloc_zero(tmp_ctx, struct PAC_DATA);
- if (!pac_data) {
- status = NT_STATUS_NO_MEMORY;
- goto done;
- }
-
- ndr_err = ndr_pull_struct_blob(&pac, pac_data, pac_data,
- (ndr_pull_flags_fn_t)ndr_pull_PAC_DATA);
- if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
- DEBUG(1, ("Failed to parse the PAC for %s\n", princ_name));
- status = ndr_map_error2ntstatus(ndr_err);
- goto done;
- }
/* get logon name and logon info */
for (i = 0; i < pac_data->num_buffers; i++) {
@@ -182,9 +163,6 @@ NTSTATUS gssapi_server_get_user_info(struct gse_context *gse_ctx,
}
logon_info = data_buf->info->logon_info.info;
break;
- case PAC_TYPE_LOGON_NAME:
- logon_name = &data_buf->info->logon_name;
- break;
default:
break;
}
@@ -194,25 +172,6 @@ NTSTATUS gssapi_server_get_user_info(struct gse_context *gse_ctx,
status = NT_STATUS_NOT_FOUND;
goto done;
}
- if (!logon_name) {
- DEBUG(1, ("Invalid PAC data, missing logon info!\n"));
- status = NT_STATUS_NOT_FOUND;
- goto done;
- }
-
- /* check time */
- if (tgs_authtime_nttime != logon_name->logon_time) {
- DEBUG(1, ("Logon time mismatch between ticket and PAC!\n"
- "PAC Time = %s | Ticket Time = %s\n",
- nt_time_string(tmp_ctx, logon_name->logon_time),
- nt_time_string(tmp_ctx, tgs_authtime_nttime)));
- status = NT_STATUS_ACCESS_DENIED;
- goto done;
- }
-
- /* TODO: Should we check princ_name against account_name in
- * logon_name ? Are they supposed to be identical, or can an
- * account_name be different from the UPN ? */
status = get_user_from_kerberos_info(tmp_ctx, client_id->name,
princ_name, logon_info,
diff --git a/source3/rpc_server/dfs/srv_dfs_nt.c b/source3/rpc_server/dfs/srv_dfs_nt.c
index 45e9d9a6ff3..5b4e423393c 100644
--- a/source3/rpc_server/dfs/srv_dfs_nt.c
+++ b/source3/rpc_server/dfs/srv_dfs_nt.c
@@ -22,11 +22,12 @@
/* This is the implementation of the dfs pipe. */
#include "includes.h"
+#include "ntdomain.h"
#include "../librpc/gen_ndr/srv_dfs.h"
#include "msdfs.h"
#include "smbd/smbd.h"
+#include "smbd/globals.h"
#include "auth.h"
-#include "ntdomain.h"
#undef DBGC_CLASS
#define DBGC_CLASS DBGC_MSDFS
@@ -58,7 +59,7 @@ WERROR _dfs_Add(struct pipes_struct *p, struct dfs_Add *r)
return WERR_ACCESS_DENIED;
}
- jn = TALLOC_ZERO_P(ctx, struct junction_map);
+ jn = talloc_zero(ctx, struct junction_map);
if (!jn) {
return WERR_NOMEM;
}
@@ -87,7 +88,7 @@ WERROR _dfs_Add(struct pipes_struct *p, struct dfs_Add *r)
return WERR_NOMEM;
}
- jn->referral_list = TALLOC_ARRAY(ctx, struct referral, jn->referral_count);
+ jn->referral_list = talloc_array(ctx, struct referral, jn->referral_count);
if(jn->referral_list == NULL) {
DEBUG(0,("init_reply_dfs_add: talloc failed for referral list!\n"));
return WERR_DFS_INTERNAL_ERROR;
@@ -123,7 +124,7 @@ WERROR _dfs_Remove(struct pipes_struct *p, struct dfs_Remove *r)
return WERR_ACCESS_DENIED;
}
- jn = TALLOC_ZERO_P(ctx, struct junction_map);
+ jn = talloc_zero(ctx, struct junction_map);
if (!jn) {
return WERR_NOMEM;
}
@@ -192,7 +193,7 @@ WERROR _dfs_Remove(struct pipes_struct *p, struct dfs_Remove *r)
static bool init_reply_dfs_info_1(TALLOC_CTX *mem_ctx, struct junction_map* j,struct dfs_Info1* dfs1)
{
dfs1->path = talloc_asprintf(mem_ctx,
- "\\\\%s\\%s\\%s", global_myname(),
+ "\\\\%s\\%s\\%s", lp_netbios_name(),
j->service_name, j->volume_name);
if (dfs1->path == NULL)
return False;
@@ -204,7 +205,7 @@ static bool init_reply_dfs_info_1(TALLOC_CTX *mem_ctx, struct junction_map* j,st
static bool init_reply_dfs_info_2(TALLOC_CTX *mem_ctx, struct junction_map* j, struct dfs_Info2* dfs2)
{
dfs2->path = talloc_asprintf(mem_ctx,
- "\\\\%s\\%s\\%s", global_myname(), j->service_name, j->volume_name);
+ "\\\\%s\\%s\\%s", lp_netbios_name(), j->service_name, j->volume_name);
if (dfs2->path == NULL)
return False;
dfs2->comment = talloc_strdup(mem_ctx, j->comment);
@@ -218,9 +219,9 @@ static bool init_reply_dfs_info_3(TALLOC_CTX *mem_ctx, struct junction_map* j, s
int ii;
if (j->volume_name[0] == '\0')
dfs3->path = talloc_asprintf(mem_ctx, "\\\\%s\\%s",
- global_myname(), j->service_name);
+ lp_netbios_name(), j->service_name);
else
- dfs3->path = talloc_asprintf(mem_ctx, "\\\\%s\\%s\\%s", global_myname(),
+ dfs3->path = talloc_asprintf(mem_ctx, "\\\\%s\\%s\\%s", lp_netbios_name(),
j->service_name, j->volume_name);
if (dfs3->path == NULL)
@@ -232,7 +233,7 @@ static bool init_reply_dfs_info_3(TALLOC_CTX *mem_ctx, struct junction_map* j, s
/* also enumerate the stores */
if (j->referral_count) {
- dfs3->stores = TALLOC_ARRAY(mem_ctx, struct dfs_StorageInfo, j->referral_count);
+ dfs3->stores = talloc_array(mem_ctx, struct dfs_StorageInfo, j->referral_count);
if (!dfs3->stores)
return False;
memset(dfs3->stores, '\0', j->referral_count * sizeof(struct dfs_StorageInfo));
@@ -278,7 +279,8 @@ WERROR _dfs_Enum(struct pipes_struct *p, struct dfs_Enum *r)
size_t i;
TALLOC_CTX *ctx = talloc_tos();
- jn = enum_msdfs_links(ctx, &num_jn);
+ jn = enum_msdfs_links(msg_ctx_to_sconn(p->msg_ctx),
+ ctx, &num_jn);
if (!jn || num_jn == 0) {
num_jn = 0;
jn = NULL;
@@ -293,7 +295,7 @@ WERROR _dfs_Enum(struct pipes_struct *p, struct dfs_Enum *r)
switch (r->in.level) {
case 1:
if (num_jn) {
- if ((r->out.info->e.info1->s = TALLOC_ARRAY(ctx, struct dfs_Info1, num_jn)) == NULL) {
+ if ((r->out.info->e.info1->s = talloc_array(ctx, struct dfs_Info1, num_jn)) == NULL) {
return WERR_NOMEM;
}
} else {
@@ -303,7 +305,7 @@ WERROR _dfs_Enum(struct pipes_struct *p, struct dfs_Enum *r)
break;
case 2:
if (num_jn) {
- if ((r->out.info->e.info2->s = TALLOC_ARRAY(ctx, struct dfs_Info2, num_jn)) == NULL) {
+ if ((r->out.info->e.info2->s = talloc_array(ctx, struct dfs_Info2, num_jn)) == NULL) {
return WERR_NOMEM;
}
} else {
@@ -313,7 +315,7 @@ WERROR _dfs_Enum(struct pipes_struct *p, struct dfs_Enum *r)
break;
case 3:
if (num_jn) {
- if ((r->out.info->e.info3->s = TALLOC_ARRAY(ctx, struct dfs_Info3, num_jn)) == NULL) {
+ if ((r->out.info->e.info3->s = talloc_array(ctx, struct dfs_Info3, num_jn)) == NULL) {
return WERR_NOMEM;
}
} else {
@@ -352,7 +354,7 @@ WERROR _dfs_GetInfo(struct pipes_struct *p, struct dfs_GetInfo *r)
TALLOC_CTX *ctx = talloc_tos();
bool ret;
- jn = TALLOC_ZERO_P(ctx, struct junction_map);
+ jn = talloc_zero(ctx, struct junction_map);
if (!jn) {
return WERR_NOMEM;
}
@@ -370,28 +372,28 @@ WERROR _dfs_GetInfo(struct pipes_struct *p, struct dfs_GetInfo *r)
switch (r->in.level) {
case 1:
- r->out.info->info1 = TALLOC_ZERO_P(ctx,struct dfs_Info1);
+ r->out.info->info1 = talloc_zero(ctx,struct dfs_Info1);
if (!r->out.info->info1) {
return WERR_NOMEM;
}
ret = init_reply_dfs_info_1(ctx, jn, r->out.info->info1);
break;
case 2:
- r->out.info->info2 = TALLOC_ZERO_P(ctx,struct dfs_Info2);
+ r->out.info->info2 = talloc_zero(ctx,struct dfs_Info2);
if (!r->out.info->info2) {
return WERR_NOMEM;
}
ret = init_reply_dfs_info_2(ctx, jn, r->out.info->info2);
break;
case 3:
- r->out.info->info3 = TALLOC_ZERO_P(ctx,struct dfs_Info3);
+ r->out.info->info3 = talloc_zero(ctx,struct dfs_Info3);
if (!r->out.info->info3) {
return WERR_NOMEM;
}
ret = init_reply_dfs_info_3(ctx, jn, r->out.info->info3);
break;
case 100:
- r->out.info->info100 = TALLOC_ZERO_P(ctx,struct dfs_Info100);
+ r->out.info->info100 = talloc_zero(ctx,struct dfs_Info100);
if (!r->out.info->info100) {
return WERR_NOMEM;
}
diff --git a/source3/rpc_server/dssetup/srv_dssetup_nt.c b/source3/rpc_server/dssetup/srv_dssetup_nt.c
index 73617df99f1..1cf4ab80746 100644
--- a/source3/rpc_server/dssetup/srv_dssetup_nt.c
+++ b/source3/rpc_server/dssetup/srv_dssetup_nt.c
@@ -23,9 +23,9 @@
*/
#include "includes.h"
+#include "ntdomain.h"
#include "../librpc/gen_ndr/srv_dssetup.h"
#include "secrets.h"
-#include "ntdomain.h"
#undef DBGC_CLASS
#define DBGC_CLASS DBGC_RPC_SRV
@@ -42,7 +42,7 @@ static WERROR fill_dsrole_dominfo_basic(TALLOC_CTX *ctx,
DEBUG(10,("fill_dsrole_dominfo_basic: enter\n"));
- basic = TALLOC_ZERO_P(ctx, struct dssetup_DsRolePrimaryDomInfoBasic);
+ basic = talloc_zero(ctx, struct dssetup_DsRolePrimaryDomInfoBasic);
if (!basic) {
DEBUG(0,("fill_dsrole_dominfo_basic: out of memory\n"));
return WERR_NOMEM;
diff --git a/source3/rpc_server/echo/srv_echo_nt.c b/source3/rpc_server/echo/srv_echo_nt.c
index 7f27984b8bd..7c8ae19b82b 100644
--- a/source3/rpc_server/echo/srv_echo_nt.c
+++ b/source3/rpc_server/echo/srv_echo_nt.c
@@ -22,8 +22,8 @@
/* This is the interface to the rpcecho pipe. */
#include "includes.h"
-#include "../librpc/gen_ndr/srv_echo.h"
#include "ntdomain.h"
+#include "../librpc/gen_ndr/srv_echo.h"
#undef DBGC_CLASS
#define DBGC_CLASS DBGC_RPC_SRV
@@ -48,7 +48,7 @@ void _echo_EchoData(struct pipes_struct *p, struct echo_EchoData *r)
return;
}
- r->out.out_data = TALLOC_ARRAY(p->mem_ctx, uint8, r->in.len);
+ r->out.out_data = talloc_array(p->mem_ctx, uint8, r->in.len);
memcpy( r->out.out_data, r->in.in_data, r->in.len );
return;
}
@@ -76,7 +76,7 @@ void _echo_SourceData(struct pipes_struct *p, struct echo_SourceData *r)
return;
}
- r->out.data = TALLOC_ARRAY(p->mem_ctx, uint8, r->in.len );
+ r->out.data = talloc_array(p->mem_ctx, uint8, r->in.len );
for (i = 0; i < r->in.len; i++ ) {
r->out.data[i] = i & 0xff;
diff --git a/source3/rpc_server/epmapper/srv_epmapper.c b/source3/rpc_server/epmapper/srv_epmapper.c
index d96fd1e929f..70f665dadf6 100644
--- a/source3/rpc_server/epmapper/srv_epmapper.c
+++ b/source3/rpc_server/epmapper/srv_epmapper.c
@@ -20,12 +20,11 @@
*/
#include "includes.h"
+#include "ntdomain.h"
#include "../libcli/security/security.h"
-#include "librpc/gen_ndr/ndr_epmapper.h"
#include "librpc/gen_ndr/srv_epmapper.h"
#include "srv_epmapper.h"
#include "auth.h"
-#include "ntdomain.h"
typedef uint32_t error_status_t;
diff --git a/source3/rpc_server/epmd.c b/source3/rpc_server/epmd.c
index 5e82b276fd2..bb241ff2c1f 100644
--- a/source3/rpc_server/epmd.c
+++ b/source3/rpc_server/epmd.c
@@ -22,6 +22,7 @@
#include "includes.h"
#include "serverid.h"
+#include "ntdomain.h"
#include "../librpc/gen_ndr/srv_epmapper.h"
#include "rpc_server/rpc_server.h"
#include "rpc_server/epmapper/srv_epmapper.h"
@@ -53,7 +54,6 @@ static bool epmd_open_sockets(struct tevent_context *ev_ctx,
port = setup_dcerpc_ncacn_tcpip_socket(ev_ctx,
msg_ctx,
- ndr_table_epmapper.syntax_id,
ifss,
135);
if (port == 0) {
@@ -68,7 +68,7 @@ static bool epmd_open_sockets(struct tevent_context *ev_ctx,
if (strequal(sock_addr, "0.0.0.0") ||
strequal(sock_addr, "::")) {
#if HAVE_IPV6
- sock_addr = "::";
+ sock_addr = "::,0.0.0.0";
#else
sock_addr = "0.0.0.0";
#endif
@@ -88,7 +88,6 @@ static bool epmd_open_sockets(struct tevent_context *ev_ctx,
port = setup_dcerpc_ncacn_tcpip_socket(ev_ctx,
msg_ctx,
- ndr_table_epmapper.syntax_id,
&ss,
135);
if (port == 0) {
@@ -262,7 +261,6 @@ void start_epmd(struct tevent_context *ev_ctx,
ok = setup_dcerpc_ncalrpc_socket(ev_ctx,
msg_ctx,
- ndr_table_epmapper.syntax_id,
"EPMAPPER",
srv_epmapper_delete_endpoints);
if (!ok) {
diff --git a/source3/rpc_server/eventlog/srv_eventlog_nt.c b/source3/rpc_server/eventlog/srv_eventlog_nt.c
index 2e1c1faa8c5..16a0c974881 100644
--- a/source3/rpc_server/eventlog/srv_eventlog_nt.c
+++ b/source3/rpc_server/eventlog/srv_eventlog_nt.c
@@ -21,16 +21,16 @@
*/
#include "includes.h"
+#include "ntdomain.h"
#include "../librpc/gen_ndr/srv_eventlog.h"
#include "lib/eventlog/eventlog.h"
-#include "registry.h"
#include "../libcli/security/security.h"
#include "../librpc/gen_ndr/ndr_winreg_c.h"
#include "rpc_client/cli_winreg_int.h"
#include "rpc_client/cli_winreg.h"
#include "smbd/smbd.h"
#include "auth.h"
-#include "ntdomain.h"
+#include "util_tdb.h"
#undef DBGC_CLASS
#define DBGC_CLASS DBGC_RPC_SRV
@@ -212,7 +212,7 @@ static NTSTATUS elog_open( struct pipes_struct * p, const char *logname, struct
if ( !elog_validate_logname( logname ) )
return NT_STATUS_OBJECT_PATH_INVALID;
- if ( !(elog = TALLOC_ZERO_P( NULL, EVENTLOG_INFO )) )
+ if ( !(elog = talloc_zero( NULL, EVENTLOG_INFO )) )
return NT_STATUS_NO_MEMORY;
talloc_set_destructor(elog, eventlog_info_destructor);
diff --git a/source3/rpc_server/initshutdown/srv_initshutdown_nt.c b/source3/rpc_server/initshutdown/srv_initshutdown_nt.c
index 8644d95e7d0..9b16d806096 100644
--- a/source3/rpc_server/initshutdown/srv_initshutdown_nt.c
+++ b/source3/rpc_server/initshutdown/srv_initshutdown_nt.c
@@ -21,9 +21,9 @@
/* Implementation of registry functions. */
#include "includes.h"
+#include "ntdomain.h"
#include "../librpc/gen_ndr/srv_initshutdown.h"
#include "../librpc/gen_ndr/srv_winreg.h"
-#include "ntdomain.h"
#undef DBGC_CLASS
#define DBGC_CLASS DBGC_RPC_SRV
diff --git a/source3/rpc_server/lsa/srv_lsa_nt.c b/source3/rpc_server/lsa/srv_lsa_nt.c
index 9ea872b0276..c6f45eaad0f 100644
--- a/source3/rpc_server/lsa/srv_lsa_nt.c
+++ b/source3/rpc_server/lsa/srv_lsa_nt.c
@@ -30,6 +30,7 @@
/* This is the implementation of the lsa server code. */
#include "includes.h"
+#include "ntdomain.h"
#include "../librpc/gen_ndr/srv_lsa.h"
#include "secrets.h"
#include "../librpc/gen_ndr/netlogon.h"
@@ -43,7 +44,6 @@
#include "../librpc/gen_ndr/ndr_security.h"
#include "passdb.h"
#include "auth.h"
-#include "ntdomain.h"
#include "lib/privileges.h"
#include "rpc_server/srv_access_check.h"
@@ -122,7 +122,7 @@ static int init_lsa_ref_domain_list(TALLOC_CTX *mem_ctx,
ref->count = num + 1;
ref->max_size = LSA_REF_DOMAIN_LIST_MULTIPLIER;
- ref->domains = TALLOC_REALLOC_ARRAY(mem_ctx, ref->domains,
+ ref->domains = talloc_realloc(mem_ctx, ref->domains,
struct lsa_DomainInfo, ref->count);
if (!ref->domains) {
return -1;
@@ -520,7 +520,7 @@ NTSTATUS _lsa_EnumTrustDom(struct pipes_struct *p,
return nt_status;
}
- entries = TALLOC_ZERO_ARRAY(p->mem_ctx, struct lsa_DomainInfo, count);
+ entries = talloc_zero_array(p->mem_ctx, struct lsa_DomainInfo, count);
if (!entries) {
return NT_STATUS_NO_MEMORY;
}
@@ -628,7 +628,7 @@ NTSTATUS _lsa_QueryInfoPolicy(struct pipes_struct *p,
/* return NT_STATUS_ACCESS_DENIED; */
}
- info = TALLOC_ZERO_P(p->mem_ctx, union lsa_PolicyInformation);
+ info = talloc_zero(p->mem_ctx, union lsa_PolicyInformation);
if (!info) {
return NT_STATUS_NO_MEMORY;
}
@@ -681,7 +681,7 @@ NTSTATUS _lsa_QueryInfoPolicy(struct pipes_struct *p,
info->audit_events.auditing_mode = true;
info->audit_events.count = LSA_AUDIT_NUM_CATEGORIES;
- info->audit_events.settings = TALLOC_ZERO_ARRAY(p->mem_ctx,
+ info->audit_events.settings = talloc_zero_array(p->mem_ctx,
enum lsa_PolicyAuditPolicy,
info->audit_events.count);
if (!info->audit_events.settings) {
@@ -858,8 +858,8 @@ static NTSTATUS _lsa_lookup_sids_internal(struct pipes_struct *p,
return NT_STATUS_OK;
}
- sids = TALLOC_ARRAY(p->mem_ctx, const struct dom_sid *, num_sids);
- ref = TALLOC_ZERO_P(p->mem_ctx, struct lsa_RefDomainList);
+ sids = talloc_array(p->mem_ctx, const struct dom_sid *, num_sids);
+ ref = talloc_zero(p->mem_ctx, struct lsa_RefDomainList);
if (sids == NULL || ref == NULL) {
return NT_STATUS_NO_MEMORY;
@@ -876,7 +876,7 @@ static NTSTATUS _lsa_lookup_sids_internal(struct pipes_struct *p,
return status;
}
- names = TALLOC_ARRAY(p->mem_ctx, struct lsa_TranslatedName2, num_sids);
+ names = talloc_array(p->mem_ctx, struct lsa_TranslatedName2, num_sids);
if (names == NULL) {
return NT_STATUS_NO_MEMORY;
}
@@ -998,7 +998,7 @@ NTSTATUS _lsa_LookupSids(struct pipes_struct *p,
}
/* Convert from lsa_TranslatedName2 to lsa_TranslatedName */
- names_out = TALLOC_ARRAY(p->mem_ctx, struct lsa_TranslatedName,
+ names_out = talloc_array(p->mem_ctx, struct lsa_TranslatedName,
num_sids);
if (!names_out) {
return NT_STATUS_NO_MEMORY;
@@ -1168,13 +1168,13 @@ NTSTATUS _lsa_LookupNames(struct pipes_struct *p,
flags = lsa_lookup_level_to_flags(r->in.level);
- domains = TALLOC_ZERO_P(p->mem_ctx, struct lsa_RefDomainList);
+ domains = talloc_zero(p->mem_ctx, struct lsa_RefDomainList);
if (!domains) {
return NT_STATUS_NO_MEMORY;
}
if (num_entries) {
- rids = TALLOC_ZERO_ARRAY(p->mem_ctx, struct lsa_TranslatedSid,
+ rids = talloc_zero_array(p->mem_ctx, struct lsa_TranslatedSid,
num_entries);
if (!rids) {
return NT_STATUS_NO_MEMORY;
@@ -1235,7 +1235,7 @@ NTSTATUS _lsa_LookupNames2(struct pipes_struct *p,
struct lsa_TransSidArray *sid_array = NULL;
uint32_t i;
- sid_array = TALLOC_ZERO_P(p->mem_ctx, struct lsa_TransSidArray);
+ sid_array = talloc_zero(p->mem_ctx, struct lsa_TransSidArray);
if (!sid_array) {
return NT_STATUS_NO_MEMORY;
}
@@ -1257,7 +1257,7 @@ NTSTATUS _lsa_LookupNames2(struct pipes_struct *p,
status = _lsa_LookupNames(p, &q);
sid_array2->count = sid_array->count;
- sid_array2->sids = TALLOC_ARRAY(p->mem_ctx, struct lsa_TranslatedSid2, sid_array->count);
+ sid_array2->sids = talloc_array(p->mem_ctx, struct lsa_TranslatedSid2, sid_array->count);
if (!sid_array2->sids) {
return NT_STATUS_NO_MEMORY;
}
@@ -1310,13 +1310,13 @@ NTSTATUS _lsa_LookupNames3(struct pipes_struct *p,
flags = LOOKUP_NAME_ALL;
}
- domains = TALLOC_ZERO_P(p->mem_ctx, struct lsa_RefDomainList);
+ domains = talloc_zero(p->mem_ctx, struct lsa_RefDomainList);
if (!domains) {
return NT_STATUS_NO_MEMORY;
}
if (num_entries) {
- trans_sids = TALLOC_ZERO_ARRAY(p->mem_ctx, struct lsa_TranslatedSid3,
+ trans_sids = talloc_zero_array(p->mem_ctx, struct lsa_TranslatedSid3,
num_entries);
if (!trans_sids) {
return NT_STATUS_NO_MEMORY;
@@ -2012,7 +2012,7 @@ NTSTATUS _lsa_QueryTrustedDomainInfo(struct pipes_struct *p,
return status;
}
- info = TALLOC_ZERO_P(p->mem_ctx, union lsa_TrustedDomainInfo);
+ info = talloc_zero(p->mem_ctx, union lsa_TrustedDomainInfo);
if (!info) {
return NT_STATUS_NO_MEMORY;
}
@@ -2230,7 +2230,7 @@ NTSTATUS _lsa_EnumPrivs(struct pipes_struct *p,
return NT_STATUS_ACCESS_DENIED;
if (num_privs) {
- entries = TALLOC_ZERO_ARRAY(p->mem_ctx, struct lsa_PrivEntry, num_privs);
+ entries = talloc_zero_array(p->mem_ctx, struct lsa_PrivEntry, num_privs);
if (!entries) {
return NT_STATUS_NO_MEMORY;
}
@@ -2299,7 +2299,7 @@ NTSTATUS _lsa_LookupPrivDisplayName(struct pipes_struct *p,
DEBUG(10,("_lsa_LookupPrivDisplayName: display name = %s\n", description));
- lsa_name = TALLOC_ZERO_P(p->mem_ctx, struct lsa_StringLarge);
+ lsa_name = talloc_zero(p->mem_ctx, struct lsa_StringLarge);
if (!lsa_name) {
return NT_STATUS_NO_MEMORY;
}
@@ -2351,7 +2351,7 @@ NTSTATUS _lsa_EnumAccounts(struct pipes_struct *p,
}
if (num_entries - *r->in.resume_handle) {
- sids = TALLOC_ZERO_ARRAY(p->mem_ctx, struct lsa_SidPtr,
+ sids = talloc_zero_array(p->mem_ctx, struct lsa_SidPtr,
num_entries - *r->in.resume_handle);
if (!sids) {
talloc_free(sid_list);
@@ -2412,14 +2412,14 @@ NTSTATUS _lsa_GetUserName(struct pipes_struct *p,
domname = p->session_info->info3->base.domain.string;
}
- account_name = TALLOC_P(p->mem_ctx, struct lsa_String);
+ account_name = talloc(p->mem_ctx, struct lsa_String);
if (!account_name) {
return NT_STATUS_NO_MEMORY;
}
init_lsa_String(account_name, username);
if (r->out.authority_name) {
- authority_name = TALLOC_P(p->mem_ctx, struct lsa_String);
+ authority_name = talloc(p->mem_ctx, struct lsa_String);
if (!authority_name) {
return NT_STATUS_NO_MEMORY;
}
@@ -2597,7 +2597,7 @@ NTSTATUS _lsa_EnumPrivsAccount(struct pipes_struct *p,
return status;
}
- *r->out.privs = priv_set = TALLOC_ZERO_P(p->mem_ctx, struct lsa_PrivilegeSet);
+ *r->out.privs = priv_set = talloc_zero(p->mem_ctx, struct lsa_PrivilegeSet);
if (!priv_set) {
return NT_STATUS_NO_MEMORY;
}
@@ -2801,7 +2801,7 @@ NTSTATUS _lsa_LookupPrivName(struct pipes_struct *p,
return NT_STATUS_NO_SUCH_PRIVILEGE;
}
- lsa_name = TALLOC_ZERO_P(p->mem_ctx, struct lsa_StringLarge);
+ lsa_name = talloc_zero(p->mem_ctx, struct lsa_StringLarge);
if (!lsa_name) {
return NT_STATUS_NO_MEMORY;
}
@@ -3030,7 +3030,7 @@ static NTSTATUS init_lsa_right_set(TALLOC_CTX *mem_ctx,
if (num_priv) {
- r->names = TALLOC_ZERO_ARRAY(mem_ctx, struct lsa_StringLarge,
+ r->names = talloc_zero_array(mem_ctx, struct lsa_StringLarge,
num_priv);
if (!r->names) {
return NT_STATUS_NO_MEMORY;
@@ -3323,7 +3323,7 @@ NTSTATUS _lsa_EnumTrustedDomainsEx(struct pipes_struct *p,
return nt_status;
}
- entries = TALLOC_ZERO_ARRAY(p->mem_ctx, struct lsa_TrustDomainInfoInfoEx,
+ entries = talloc_zero_array(p->mem_ctx, struct lsa_TrustDomainInfoInfoEx,
count);
if (!entries) {
return NT_STATUS_NO_MEMORY;
@@ -3488,7 +3488,7 @@ static int dns_cmp(const char *s1, size_t l1,
int cret;
if (l1 == l2) {
- if (StrCaseCmp(s1, s2) == 0) {
+ if (strcasecmp_m(s1, s2) == 0) {
return DNS_CMP_MATCH;
}
return DNS_CMP_NO_MATCH;
@@ -3512,7 +3512,7 @@ static int dns_cmp(const char *s1, size_t l1,
return DNS_CMP_NO_MATCH;
}
- if (StrCaseCmp(&p1[t1 - t2], p2) == 0) {
+ if (strcasecmp_m(&p1[t1 - t2], p2) == 0) {
return cret;
}
@@ -3701,7 +3701,7 @@ static NTSTATUS check_ft_info(TALLOC_CTX *mem_ctx,
sid_conflict = true;
}
if (!(trec->flags & LSA_NB_DISABLED_ADMIN) &&
- StrCaseCmp(trec->data.info.netbios_name.string,
+ strcasecmp_m(trec->data.info.netbios_name.string,
nb_name) == 0) {
nb_conflict = true;
}
@@ -3876,7 +3876,7 @@ NTSTATUS _lsa_lsaRSetForestTrustInformation(struct pipes_struct *p,
if (domains[i]->domain_name == NULL) {
return NT_STATUS_INVALID_DOMAIN_STATE;
}
- if (StrCaseCmp(domains[i]->domain_name,
+ if (strcasecmp_m(domains[i]->domain_name,
r->in.trusted_domain_name->string) == 0) {
break;
}
diff --git a/source3/rpc_server/netlogon/srv_netlog_nt.c b/source3/rpc_server/netlogon/srv_netlog_nt.c
index f0535c72953..03897d77a47 100644
--- a/source3/rpc_server/netlogon/srv_netlog_nt.c
+++ b/source3/rpc_server/netlogon/srv_netlog_nt.c
@@ -25,10 +25,9 @@
/* This is the implementation of the netlogon pipe. */
#include "includes.h"
+#include "ntdomain.h"
#include "../libcli/auth/schannel.h"
#include "../librpc/gen_ndr/srv_netlogon.h"
-#include "../librpc/gen_ndr/srv_samr.h"
-#include "../librpc/gen_ndr/srv_lsa.h"
#include "../librpc/gen_ndr/ndr_samr_c.h"
#include "../librpc/gen_ndr/ndr_lsa_c.h"
#include "rpc_client/cli_lsarpc.h"
@@ -45,7 +44,6 @@
#include "passdb.h"
#include "auth.h"
#include "messages.h"
-#include "ntdomain.h"
extern userdom_struct current_user_info;
@@ -348,7 +346,7 @@ WERROR _netr_LogonControl2Ex(struct pipes_struct *p,
switch (r->in.level) {
case 1:
- info1 = TALLOC_ZERO_P(p->mem_ctx, struct netr_NETLOGON_INFO_1);
+ info1 = talloc_zero(p->mem_ctx, struct netr_NETLOGON_INFO_1);
W_ERROR_HAVE_NO_MEMORY(info1);
info1->flags = flags;
@@ -357,7 +355,7 @@ WERROR _netr_LogonControl2Ex(struct pipes_struct *p,
r->out.query->info1 = info1;
break;
case 2:
- info2 = TALLOC_ZERO_P(p->mem_ctx, struct netr_NETLOGON_INFO_2);
+ info2 = talloc_zero(p->mem_ctx, struct netr_NETLOGON_INFO_2);
W_ERROR_HAVE_NO_MEMORY(info2);
info2->flags = flags;
@@ -368,7 +366,7 @@ WERROR _netr_LogonControl2Ex(struct pipes_struct *p,
r->out.query->info2 = info2;
break;
case 3:
- info3 = TALLOC_ZERO_P(p->mem_ctx, struct netr_NETLOGON_INFO_3);
+ info3 = talloc_zero(p->mem_ctx, struct netr_NETLOGON_INFO_3);
W_ERROR_HAVE_NO_MEMORY(info3);
info3->flags = flags;
@@ -377,7 +375,7 @@ WERROR _netr_LogonControl2Ex(struct pipes_struct *p,
r->out.query->info3 = info3;
break;
case 4:
- info4 = TALLOC_ZERO_P(p->mem_ctx, struct netr_NETLOGON_INFO_4);
+ info4 = talloc_zero(p->mem_ctx, struct netr_NETLOGON_INFO_4);
W_ERROR_HAVE_NO_MEMORY(info4);
info4->trusted_dc_name = dc_name;
@@ -524,7 +522,7 @@ static NTSTATUS samr_find_machine_account(TALLOC_CTX *mem_ctx,
uint32_t rid;
status = dcerpc_samr_Connect2(b, mem_ctx,
- global_myname(),
+ lp_netbios_name(),
SAMR_ACCESS_CONNECT_TO_SERVER |
SAMR_ACCESS_ENUM_DOMAINS |
SAMR_ACCESS_LOOKUP_DOMAIN,
@@ -1423,19 +1421,19 @@ static NTSTATUS _netr_LogonSamLogon_base(struct pipes_struct *p,
switch (r->in.validation_level) {
case 2:
- r->out.validation->sam2 = TALLOC_ZERO_P(p->mem_ctx, struct netr_SamInfo2);
+ r->out.validation->sam2 = talloc_zero(p->mem_ctx, struct netr_SamInfo2);
if (!r->out.validation->sam2) {
return NT_STATUS_NO_MEMORY;
}
break;
case 3:
- r->out.validation->sam3 = TALLOC_ZERO_P(p->mem_ctx, struct netr_SamInfo3);
+ r->out.validation->sam3 = talloc_zero(p->mem_ctx, struct netr_SamInfo3);
if (!r->out.validation->sam3) {
return NT_STATUS_NO_MEMORY;
}
break;
case 6:
- r->out.validation->sam6 = TALLOC_ZERO_P(p->mem_ctx, struct netr_SamInfo6);
+ r->out.validation->sam6 = talloc_zero(p->mem_ctx, struct netr_SamInfo6);
if (!r->out.validation->sam6) {
return NT_STATUS_NO_MEMORY;
}
diff --git a/source3/rpc_server/ntsvcs/srv_ntsvcs_nt.c b/source3/rpc_server/ntsvcs/srv_ntsvcs_nt.c
index af80254a0b2..0a00e000255 100644
--- a/source3/rpc_server/ntsvcs/srv_ntsvcs_nt.c
+++ b/source3/rpc_server/ntsvcs/srv_ntsvcs_nt.c
@@ -20,10 +20,10 @@
*/
#include "includes.h"
+#include "ntdomain.h"
#include "../librpc/gen_ndr/srv_ntsvcs.h"
#include "services/svc_winreg_glue.h"
#include "../libcli/registry/util_reg.h"
-#include "ntdomain.h"
#undef DBGC_CLASS
#define DBGC_CLASS DBGC_RPC_SRV
diff --git a/source3/rpc_server/rpc_contexts.c b/source3/rpc_server/rpc_contexts.c
new file mode 100644
index 00000000000..bb5c0eaf6cd
--- /dev/null
+++ b/source3/rpc_server/rpc_contexts.c
@@ -0,0 +1,40 @@
+/*
+ * Unix SMB/CIFS implementation.
+ * RPC Pipe client / server routines
+ * Almost completely rewritten by (C) Jeremy Allison 2005 - 2010
+ *
+ * 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/>.
+ */
+
+#include "includes.h"
+#include "ntdomain.h"
+
+#include "rpc_contexts.h"
+
+struct pipe_rpc_fns *find_pipe_fns_by_context(struct pipe_rpc_fns *list,
+ uint32_t context_id)
+{
+ struct pipe_rpc_fns *fns = NULL;
+
+ if ( !list ) {
+ DEBUG(0,("find_pipe_fns_by_context: ERROR! No context list for pipe!\n"));
+ return NULL;
+ }
+
+ for (fns=list; fns; fns=fns->next ) {
+ if ( fns->context_id == context_id )
+ return fns;
+ }
+ return NULL;
+}
diff --git a/source3/rpc_server/rpc_contexts.h b/source3/rpc_server/rpc_contexts.h
new file mode 100644
index 00000000000..8463414bbb3
--- /dev/null
+++ b/source3/rpc_server/rpc_contexts.h
@@ -0,0 +1,28 @@
+/*
+ * Unix SMB/CIFS implementation.
+ * RPC Pipe client / server routines
+ * Almost completely rewritten by (C) Jeremy Allison 2005 - 2010
+ *
+ * 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/>.
+ */
+
+#ifndef _RPC_SERVER_RPC_CONTEXTS_H_
+#define _RPC_SERVER_RPC_CONTEXTS_H_
+
+struct pipe_rpc_fns;
+
+struct pipe_rpc_fns *find_pipe_fns_by_context(struct pipe_rpc_fns *list,
+ uint32_t context_id);
+
+#endif /* _RPC_SERVER_RPC_CONTEXTS_H_*/
diff --git a/source3/rpc_server/rpc_ep_setup.c b/source3/rpc_server/rpc_ep_setup.c
index d517bb88516..e5059dae807 100644
--- a/source3/rpc_server/rpc_ep_setup.c
+++ b/source3/rpc_server/rpc_ep_setup.c
@@ -20,6 +20,7 @@
*/
#include "includes.h"
+#include "ntdomain.h"
#include "../librpc/gen_ndr/ndr_epmapper_c.h"
#include "../librpc/gen_ndr/srv_epmapper.h"
@@ -41,6 +42,8 @@
#include "printing/nt_printing_migrate.h"
#include "rpc_server/eventlog/srv_eventlog_reg.h"
#include "rpc_server/svcctl/srv_svcctl_reg.h"
+#include "rpc_server/spoolss/srv_spoolss_nt.h"
+#include "rpc_server/svcctl/srv_svcctl_nt.h"
#include "librpc/rpc/dcerpc_ep.h"
@@ -76,7 +79,6 @@ static uint16_t _open_sockets(struct tevent_context *ev_ctx,
p = setup_dcerpc_ncacn_tcpip_socket(ev_ctx,
msg_ctx,
- syntax_id,
ifss,
port);
if (p == 0) {
@@ -92,7 +94,7 @@ static uint16_t _open_sockets(struct tevent_context *ev_ctx,
if (strequal(sock_addr, "0.0.0.0") ||
strequal(sock_addr, "::")) {
#if HAVE_IPV6
- sock_addr = "::";
+ sock_addr = "::,0.0.0.0";
#else
sock_addr = "0.0.0.0";
#endif
@@ -112,7 +114,6 @@ static uint16_t _open_sockets(struct tevent_context *ev_ctx,
p = setup_dcerpc_ncacn_tcpip_socket(ev_ctx,
msg_ctx,
- syntax_id,
&ss,
port);
if (p == 0) {
@@ -130,7 +131,7 @@ static NTSTATUS rpc_ep_setup_try_register(TALLOC_CTX *mem_ctx,
struct tevent_context *ev_ctx,
struct messaging_context *msg_ctx,
const struct ndr_interface_table *iface,
- const char *name,
+ const char *ncalrpc,
uint16_t port,
struct dcerpc_binding_handle **pbh);
@@ -253,7 +254,7 @@ static NTSTATUS rpc_ep_setup_try_register(TALLOC_CTX *mem_ctx,
struct tevent_context *ev_ctx,
struct messaging_context *msg_ctx,
const struct ndr_interface_table *iface,
- const char *name,
+ const char *ncalrpc,
uint16_t port,
struct dcerpc_binding_handle **pbh)
{
@@ -263,7 +264,7 @@ static NTSTATUS rpc_ep_setup_try_register(TALLOC_CTX *mem_ctx,
status = dcerpc_binding_vector_create(mem_ctx,
iface,
port,
- name,
+ ncalrpc,
&v);
if (!NT_STATUS_IS_OK(status)) {
return status;
@@ -273,7 +274,7 @@ static NTSTATUS rpc_ep_setup_try_register(TALLOC_CTX *mem_ctx,
iface,
v,
&iface->syntax_id.uuid,
- name,
+ iface->name,
pbh);
talloc_free(v);
if (!NT_STATUS_IS_OK(status)) {
@@ -420,14 +421,13 @@ static bool winreg_init_cb(void *ptr)
"epmapper",
"none");
- if (StrCaseCmp(rpcsrv_type, "embedded") == 0 ||
- StrCaseCmp(rpcsrv_type, "daemon") == 0) {
+ if (strcasecmp_m(rpcsrv_type, "embedded") == 0 ||
+ strcasecmp_m(rpcsrv_type, "daemon") == 0) {
NTSTATUS status;
bool ok;
ok = setup_dcerpc_ncalrpc_socket(ep_ctx->ev_ctx,
ep_ctx->msg_ctx,
- abstract_syntax,
pipe_name,
NULL);
if (!ok) {
@@ -468,14 +468,13 @@ static bool srvsvc_init_cb(void *ptr)
"epmapper",
"none");
- if (StrCaseCmp(rpcsrv_type, "embedded") == 0 ||
- StrCaseCmp(rpcsrv_type, "daemon") == 0) {
+ if (strcasecmp_m(rpcsrv_type, "embedded") == 0 ||
+ strcasecmp_m(rpcsrv_type, "daemon") == 0) {
NTSTATUS status;
bool ok;
ok = setup_dcerpc_ncalrpc_socket(ep_ctx->ev_ctx,
ep_ctx->msg_ctx,
- abstract_syntax,
pipe_name,
NULL);
if (!ok) {
@@ -517,14 +516,13 @@ static bool lsarpc_init_cb(void *ptr)
"epmapper",
"none");
- if (StrCaseCmp(rpcsrv_type, "embedded") == 0 ||
- StrCaseCmp(rpcsrv_type, "daemon") == 0) {
+ if (strcasecmp_m(rpcsrv_type, "embedded") == 0 ||
+ strcasecmp_m(rpcsrv_type, "daemon") == 0) {
NTSTATUS status;
bool ok;
ok = setup_dcerpc_ncalrpc_socket(ep_ctx->ev_ctx,
ep_ctx->msg_ctx,
- abstract_syntax,
pipe_name,
NULL);
if (!ok) {
@@ -566,14 +564,13 @@ static bool samr_init_cb(void *ptr)
"epmapper",
"none");
- if (StrCaseCmp(rpcsrv_type, "embedded") == 0 ||
- StrCaseCmp(rpcsrv_type, "daemon") == 0) {
+ if (strcasecmp_m(rpcsrv_type, "embedded") == 0 ||
+ strcasecmp_m(rpcsrv_type, "daemon") == 0) {
NTSTATUS status;
bool ok;
ok = setup_dcerpc_ncalrpc_socket(ep_ctx->ev_ctx,
ep_ctx->msg_ctx,
- abstract_syntax,
pipe_name,
NULL);
if (!ok) {
@@ -615,14 +612,13 @@ static bool netlogon_init_cb(void *ptr)
"epmapper",
"none");
- if (StrCaseCmp(rpcsrv_type, "embedded") == 0 ||
- StrCaseCmp(rpcsrv_type, "daemon") == 0) {
+ if (strcasecmp_m(rpcsrv_type, "embedded") == 0 ||
+ strcasecmp_m(rpcsrv_type, "daemon") == 0) {
NTSTATUS status;
bool ok;
ok = setup_dcerpc_ncalrpc_socket(ep_ctx->ev_ctx,
ep_ctx->msg_ctx,
- abstract_syntax,
pipe_name,
NULL);
if (!ok) {
@@ -670,8 +666,8 @@ static bool spoolss_init_cb(void *ptr)
return false;
}
- if (StrCaseCmp(rpcsrv_type, "embedded") == 0 ||
- StrCaseCmp(rpcsrv_type, "daemon") == 0) {
+ if (strcasecmp_m(rpcsrv_type, "embedded") == 0 ||
+ strcasecmp_m(rpcsrv_type, "daemon") == 0) {
NTSTATUS status;
status =rpc_ep_setup_register(ep_ctx->ev_ctx,
@@ -714,8 +710,8 @@ static bool svcctl_init_cb(void *ptr)
/* initialize the control hooks */
init_service_op_table();
- if (StrCaseCmp(rpcsrv_type, "embedded") == 0 ||
- StrCaseCmp(rpcsrv_type, "daemon") == 0) {
+ if (strcasecmp_m(rpcsrv_type, "embedded") == 0 ||
+ strcasecmp_m(rpcsrv_type, "daemon") == 0) {
NTSTATUS status;
status = rpc_ep_setup_register(ep_ctx->ev_ctx,
@@ -749,8 +745,8 @@ static bool ntsvcs_init_cb(void *ptr)
"epmapper",
"none");
- if (StrCaseCmp(rpcsrv_type, "embedded") == 0 ||
- StrCaseCmp(rpcsrv_type, "daemon") == 0) {
+ if (strcasecmp_m(rpcsrv_type, "embedded") == 0 ||
+ strcasecmp_m(rpcsrv_type, "daemon") == 0) {
NTSTATUS status;
status = rpc_ep_setup_register(ep_ctx->ev_ctx,
@@ -783,8 +779,8 @@ static bool eventlog_init_cb(void *ptr)
return false;
}
- if (StrCaseCmp(rpcsrv_type, "embedded") == 0 ||
- StrCaseCmp(rpcsrv_type, "daemon") == 0) {
+ if (strcasecmp_m(rpcsrv_type, "embedded") == 0 ||
+ strcasecmp_m(rpcsrv_type, "daemon") == 0) {
NTSTATUS status;
status =rpc_ep_setup_register(ep_ctx->ev_ctx,
@@ -811,8 +807,8 @@ static bool initshutdown_init_cb(void *ptr)
"epmapper",
"none");
- if (StrCaseCmp(rpcsrv_type, "embedded") == 0 ||
- StrCaseCmp(rpcsrv_type, "daemon") == 0) {
+ if (strcasecmp_m(rpcsrv_type, "embedded") == 0 ||
+ strcasecmp_m(rpcsrv_type, "daemon") == 0) {
NTSTATUS status;
status = rpc_ep_setup_register(ep_ctx->ev_ctx,
@@ -840,8 +836,8 @@ static bool rpcecho_init_cb(void *ptr) {
"epmapper",
"none");
- if (StrCaseCmp(rpcsrv_type, "embedded") == 0 ||
- StrCaseCmp(rpcsrv_type, "daemon") == 0) {
+ if (strcasecmp_m(rpcsrv_type, "embedded") == 0 ||
+ strcasecmp_m(rpcsrv_type, "daemon") == 0) {
NTSTATUS status;
port = _open_sockets(ep_ctx->ev_ctx,
@@ -880,14 +876,13 @@ static bool netdfs_init_cb(void *ptr)
"rpc_server",
"epmapper",
"none");
- if (StrCaseCmp(rpcsrv_type, "embedded") == 0 ||
- StrCaseCmp(rpcsrv_type, "daemon") == 0) {
+ if (strcasecmp_m(rpcsrv_type, "embedded") == 0 ||
+ strcasecmp_m(rpcsrv_type, "daemon") == 0) {
NTSTATUS status;
bool ok;
ok = setup_dcerpc_ncalrpc_socket(ep_ctx->ev_ctx,
ep_ctx->msg_ctx,
- abstract_syntax,
pipe_name,
NULL);
if (!ok) {
@@ -929,14 +924,13 @@ static bool dssetup_init_cb(void *ptr)
"epmapper",
"none");
- if (StrCaseCmp(rpcsrv_type, "embedded") == 0 ||
- StrCaseCmp(rpcsrv_type, "daemon") == 0) {
+ if (strcasecmp_m(rpcsrv_type, "embedded") == 0 ||
+ strcasecmp_m(rpcsrv_type, "daemon") == 0) {
NTSTATUS status;
bool ok;
ok = setup_dcerpc_ncalrpc_socket(ep_ctx->ev_ctx,
ep_ctx->msg_ctx,
- abstract_syntax,
pipe_name,
NULL);
if (!ok) {
@@ -977,14 +971,13 @@ static bool wkssvc_init_cb(void *ptr)
"rpc_server",
"epmapper",
"none");
- if (StrCaseCmp(rpcsrv_type, "embedded") == 0 ||
- StrCaseCmp(rpcsrv_type, "daemon") == 0) {
+ if (strcasecmp_m(rpcsrv_type, "embedded") == 0 ||
+ strcasecmp_m(rpcsrv_type, "daemon") == 0) {
NTSTATUS status;
bool ok;
ok = setup_dcerpc_ncalrpc_socket(ep_ctx->ev_ctx,
ep_ctx->msg_ctx,
- abstract_syntax,
pipe_name,
NULL);
if (!ok) {
@@ -1053,7 +1046,7 @@ bool dcesrv_ep_setup(struct tevent_context *ev_ctx,
"rpc_server",
"epmapper",
"none");
- if (StrCaseCmp(rpcsrv_type, "embedded") == 0) {
+ if (strcasecmp_m(rpcsrv_type, "embedded") == 0) {
epmapper_cb.init = epmapper_init_cb;
epmapper_cb.shutdown = epmapper_shutdown_cb;
epmapper_cb.private_data = ep_ctx;
@@ -1061,7 +1054,7 @@ bool dcesrv_ep_setup(struct tevent_context *ev_ctx,
if (!NT_STATUS_IS_OK(rpc_epmapper_init(&epmapper_cb))) {
return false;
}
- } else if (StrCaseCmp(rpcsrv_type, "daemon") == 0) {
+ } else if (strcasecmp_m(rpcsrv_type, "daemon") == 0) {
if (!NT_STATUS_IS_OK(rpc_epmapper_init(NULL))) {
return false;
}
@@ -1107,15 +1100,15 @@ bool dcesrv_ep_setup(struct tevent_context *ev_ctx,
"rpc_server",
"spoolss",
"embedded");
- if (StrCaseCmp(rpcsrv_type, "embedded") == 0) {
+ if (strcasecmp_m(rpcsrv_type, "embedded") == 0) {
spoolss_cb.init = spoolss_init_cb;
spoolss_cb.shutdown = spoolss_shutdown_cb;
spoolss_cb.private_data = ep_ctx;
if (!NT_STATUS_IS_OK(rpc_spoolss_init(&spoolss_cb))) {
return false;
}
- } else if (StrCaseCmp(rpcsrv_type, "daemon") == 0 ||
- StrCaseCmp(rpcsrv_type, "external") == 0) {
+ } else if (strcasecmp_m(rpcsrv_type, "daemon") == 0 ||
+ strcasecmp_m(rpcsrv_type, "external") == 0) {
if (!NT_STATUS_IS_OK(rpc_spoolss_init(NULL))) {
return false;
}
diff --git a/source3/rpc_server/rpc_ep_setup.h b/source3/rpc_server/rpc_ep_setup.h
index b96de36b16e..57b06abb39f 100644
--- a/source3/rpc_server/rpc_ep_setup.h
+++ b/source3/rpc_server/rpc_ep_setup.h
@@ -22,6 +22,8 @@
#ifndef _SMBD_RPC_CALLBACKS_H
#define _SMBD_RPC_CALLBACKS_H
+struct ndr_interface_table;
+
/**
* @brief Register an endpoint at the endpoint mapper.
*
diff --git a/source3/rpc_server/rpc_handles.c b/source3/rpc_server/rpc_handles.c
index 889e87e9b5a..7fa59b6b117 100644
--- a/source3/rpc_server/rpc_handles.c
+++ b/source3/rpc_server/rpc_handles.c
@@ -24,6 +24,7 @@
#include "../librpc/gen_ndr/ndr_samr.h"
#include "auth.h"
#include "ntdomain.h"
+#include "rpc_server/rpc_ncacn_np.h"
#undef DBGC_CLASS
#define DBGC_CLASS DBGC_RPC_SRV
@@ -83,15 +84,28 @@ bool init_pipe_handles(struct pipes_struct *p, const struct ndr_syntax_id *synta
for (plist = get_first_internal_pipe();
plist;
plist = get_next_internal_pipe(plist)) {
- if (ndr_syntax_id_equal(syntax, &plist->syntax)) {
- break;
+ struct pipe_rpc_fns *p_ctx;
+ bool stop = false;
+
+ for (p_ctx = plist->contexts;
+ p_ctx != NULL;
+ p_ctx = p_ctx->next) {
+ if (ndr_syntax_id_equal(syntax, &p_ctx->syntax)) {
+ stop = true;
+ break;
+ }
+ if (is_samr_lsa_pipe(&p_ctx->syntax)
+ && is_samr_lsa_pipe(syntax)) {
+ /*
+ * samr and lsa share a handle space (same process
+ * under Windows?)
+ */
+ stop = true;
+ break;
+ }
}
- if (is_samr_lsa_pipe(&plist->syntax)
- && is_samr_lsa_pipe(syntax)) {
- /*
- * samr and lsa share a handle space (same process
- * under Windows?)
- */
+
+ if (stop) {
break;
}
}
@@ -229,7 +243,7 @@ static struct dcesrv_handle *find_policy_by_hnd_internal(struct pipes_struct *p,
for (h = p->pipe_handles->handles; h != NULL; h = h->next) {
if (memcmp(&h->wire_handle, hnd, sizeof(*hnd)) == 0) {
DEBUG(4,("Found policy hnd[%u] ", count));
- dump_data(4, (uint8 *)hnd, sizeof(*hnd));
+ dump_data(4, (const uint8 *)hnd, sizeof(*hnd));
if (data_p) {
*data_p = h->data;
}
@@ -239,7 +253,7 @@ static struct dcesrv_handle *find_policy_by_hnd_internal(struct pipes_struct *p,
}
DEBUG(4,("Policy not found: "));
- dump_data(4, (uint8_t *)hnd, sizeof(*hnd));
+ dump_data(4, (const uint8_t *)hnd, sizeof(*hnd));
p->bad_handle_fault_state = true;
@@ -293,6 +307,10 @@ bool close_policy_hnd(struct pipes_struct *p, struct policy_handle *hnd)
void close_policy_by_pipe(struct pipes_struct *p)
{
+ if (p->pipe_handles == NULL) {
+ return;
+ }
+
p->pipe_handles->pipe_ref_count--;
if (p->pipe_handles->pipe_ref_count == 0) {
@@ -301,9 +319,9 @@ void close_policy_by_pipe(struct pipes_struct *p)
*/
TALLOC_FREE(p->pipe_handles);
- DEBUG(10,("close_policy_by_pipe: deleted handle list for "
- "pipe %s\n",
- get_pipe_name_from_syntax(talloc_tos(), &p->syntax)));
+ DEBUG(10,("Deleted handle list for RPC connection %s\n",
+ get_pipe_name_from_syntax(talloc_tos(),
+ &p->contexts->syntax)));
}
}
@@ -344,9 +362,10 @@ void *_policy_handle_create(struct pipes_struct *p, struct policy_handle *hnd,
void *data;
if (p->pipe_handles->count > MAX_OPEN_POLS) {
- DEBUG(0, ("policy_handle_create: ERROR: too many handles (%d) "
- "on pipe %s.\n", (int)p->pipe_handles->count,
- get_pipe_name_from_syntax(talloc_tos(), &p->syntax)));
+ DEBUG(0, ("ERROR: Too many handles (%d) for RPC connection %s\n",
+ (int) p->pipe_handles->count,
+ get_pipe_name_from_syntax(talloc_tos(),
+ &p->contexts->syntax)));
*pstatus = NT_STATUS_INSUFFICIENT_RESOURCES;
return NULL;
}
diff --git a/source3/rpc_server/rpc_ncacn_np.c b/source3/rpc_server/rpc_ncacn_np.c
index e89a366f9e9..f14aae540d3 100644
--- a/source3/rpc_server/rpc_ncacn_np.c
+++ b/source3/rpc_server/rpc_ncacn_np.c
@@ -31,12 +31,13 @@
#include "../auth/auth_sam_reply.h"
#include "auth.h"
#include "ntdomain.h"
+#include "../lib/tsocket/tsocket.h"
+#include "../lib/util/tevent_ntstatus.h"
+#include "rpc_contexts.h"
#undef DBGC_CLASS
#define DBGC_CLASS DBGC_RPC_SRV
-static int pipes_open;
-
static struct pipes_struct *InternalPipes;
/* TODO
@@ -102,11 +103,11 @@ int close_internal_rpc_pipe_hnd(struct pipes_struct *p)
TALLOC_FREE(p->auth.auth_ctx);
- free_pipe_rpc_context_internal( p->contexts );
-
/* Free the handles database. */
close_policy_by_pipe(p);
+ free_pipe_rpc_context_internal( p->contexts );
+
DLIST_REMOVE(InternalPipes, p);
ZERO_STRUCTP(p);
@@ -125,11 +126,12 @@ struct pipes_struct *make_internal_rpc_pipe_p(TALLOC_CTX *mem_ctx,
struct messaging_context *msg_ctx)
{
struct pipes_struct *p;
+ struct pipe_rpc_fns *context_fns;
DEBUG(4,("Create pipe requested %s\n",
get_pipe_name_from_syntax(talloc_tos(), syntax)));
- p = TALLOC_ZERO_P(mem_ctx, struct pipes_struct);
+ p = talloc_zero(mem_ctx, struct pipes_struct);
if (!p) {
DEBUG(0,("ERROR! no memory for pipes_struct!\n"));
@@ -167,11 +169,25 @@ struct pipes_struct *make_internal_rpc_pipe_p(TALLOC_CTX *mem_ctx,
p->endian = RPC_LITTLE_ENDIAN;
- p->syntax = *syntax;
p->transport = NCALRPC;
- DEBUG(4,("Created internal pipe %s (pipes_open=%d)\n",
- get_pipe_name_from_syntax(talloc_tos(), syntax), pipes_open));
+ context_fns = SMB_MALLOC_P(struct pipe_rpc_fns);
+ if (context_fns == NULL) {
+ DEBUG(0,("malloc() failed!\n"));
+ return False;
+ }
+
+ context_fns->next = context_fns->prev = NULL;
+ context_fns->n_cmds = rpc_srv_get_pipe_num_cmds(syntax);
+ context_fns->cmds = rpc_srv_get_pipe_cmds(syntax);
+ context_fns->context_id = 0;
+ context_fns->syntax = *syntax;
+
+ /* add to the list of open contexts */
+ DLIST_ADD(p->contexts, context_fns);
+
+ DEBUG(4,("Created internal pipe %s\n",
+ get_pipe_name_from_syntax(talloc_tos(), syntax)));
talloc_set_destructor(p, close_internal_rpc_pipe_hnd);
@@ -184,8 +200,9 @@ static NTSTATUS rpcint_dispatch(struct pipes_struct *p,
const DATA_BLOB *in_data,
DATA_BLOB *out_data)
{
- uint32_t num_cmds = rpc_srv_get_pipe_num_cmds(&p->syntax);
- const struct api_struct *cmds = rpc_srv_get_pipe_cmds(&p->syntax);
+ struct pipe_rpc_fns *fns = find_pipe_fns_by_context(p->contexts, 0);
+ uint32_t num_cmds = fns->n_cmds;
+ const struct api_struct *cmds = fns->cmds;
uint32_t i;
bool ok;
@@ -517,7 +534,8 @@ NTSTATUS rpcint_binding_handle(TALLOC_CTX *mem_ctx,
* @brief Create a new RPC client context which uses a local transport.
*
* This creates a local transport. It is a shortcut to directly call the server
- * functions and avoid marschalling.
+ * functions and avoid marshalling.
+ * NOTE: this function should be used only by rpc_pipe_open_interface()
*
* @param[in] mem_ctx The memory context to use.
*
@@ -534,19 +552,8 @@ NTSTATUS rpcint_binding_handle(TALLOC_CTX *mem_ctx,
*
* @return NT_STATUS_OK on success, a corresponding NT status if an
* error occured.
- *
- * @code
- * struct rpc_pipe_client *winreg_pipe;
- * NTSTATUS status;
- *
- * status = rpc_pipe_open_internal(tmp_ctx,
- * &ndr_table_winreg.syntax_id,
- * p->session_info,
- * client_id,
- * &winreg_pipe);
- * @endcode
*/
-NTSTATUS rpc_pipe_open_internal(TALLOC_CTX *mem_ctx,
+static NTSTATUS rpc_pipe_open_internal(TALLOC_CTX *mem_ctx,
const struct ndr_syntax_id *abstract_syntax,
const struct auth_serversupplied_info *serversupplied_info,
struct client_address *client_id,
@@ -556,7 +563,7 @@ NTSTATUS rpc_pipe_open_internal(TALLOC_CTX *mem_ctx,
struct rpc_pipe_client *result;
NTSTATUS status;
- result = TALLOC_ZERO_P(mem_ctx, struct rpc_pipe_client);
+ result = talloc_zero(mem_ctx, struct rpc_pipe_client);
if (result == NULL) {
return NT_STATUS_NO_MEMORY;
}
@@ -831,17 +838,36 @@ done:
}
/**
- * @brief Create a new RPC client context which uses a local dispatch function.
+ * @brief Create a new RPC client context which uses a local dispatch function
+ * or a remote transport, depending on rpc_server configuration for the
+ * specific service.
+ *
+ * @param[in] mem_ctx The memory context to use.
+ *
+ * @param[in] abstract_syntax Normally the syntax_id of the autogenerated
+ * ndr_table_<name>.
+ *
+ * @param[in] serversupplied_info The server supplied authentication function.
*
- * @param mem_ctx The memory context on which thje pipe will ultimately
- * be allocated
- * @param name The pipe name to connect to.
- * @param session_info Credentials to use for the connection.
- * @param pipe [in|out] Checks if a pipe is connected, and connects it
- * if not
+ * @param[in] client_id The client address information.
*
- * @return NT_STATUS_OK on success, a corresponding NT status if
- * an error occured.
+ * @param[in] msg_ctx The messaging context to use.
+ *
+ * @param[out] presult A pointer to store the connected rpc client pipe.
+ *
+ * @return NT_STATUS_OK on success, a corresponding NT status if an
+ * error occured.
+ *
+ * @code
+ * struct rpc_pipe_client *winreg_pipe;
+ * NTSTATUS status;
+ *
+ * status = rpc_pipe_open_interface(tmp_ctx,
+ * &ndr_table_winreg.syntax_id,
+ * p->session_info,
+ * client_id,
+ * &winreg_pipe);
+ * @endcode
*/
NTSTATUS rpc_pipe_open_interface(TALLOC_CTX *mem_ctx,
@@ -884,7 +910,7 @@ NTSTATUS rpc_pipe_open_interface(TALLOC_CTX *mem_ctx,
"rpc_server", pipe_name,
"embedded");
- if (StrCaseCmp(server_type, "embedded") == 0) {
+ if (strcasecmp_m(server_type, "embedded") == 0) {
status = rpc_pipe_open_internal(tmp_ctx,
syntax, session_info,
client_id, msg_ctx,
@@ -892,8 +918,8 @@ NTSTATUS rpc_pipe_open_interface(TALLOC_CTX *mem_ctx,
if (!NT_STATUS_IS_OK(status)) {
goto done;
}
- } else if (StrCaseCmp(server_type, "daemon") == 0 ||
- StrCaseCmp(server_type, "external") == 0) {
+ } else if (strcasecmp_m(server_type, "daemon") == 0 ||
+ strcasecmp_m(server_type, "external") == 0) {
/* It would be nice to just use rpc_pipe_open_ncalrpc() but
* for now we need to use the special proxy setup to connect
* to spoolssd. */
diff --git a/source3/rpc_server/rpc_ncacn_np.h b/source3/rpc_server/rpc_ncacn_np.h
index 7c8619b46db..3d9a170cdc9 100644
--- a/source3/rpc_server/rpc_ncacn_np.h
+++ b/source3/rpc_server/rpc_ncacn_np.h
@@ -20,6 +20,10 @@
#ifndef _RPC_NCACN_NP_H_
#define _RPC_NCACN_NP_H_
+struct dcerpc_binding_handle;
+struct ndr_interface_table;
+struct tsocket_address;
+
struct np_proxy_state {
uint16_t file_type;
uint16_t device_state;
@@ -45,12 +49,6 @@ NTSTATUS rpcint_binding_handle(TALLOC_CTX *mem_ctx,
const struct auth_serversupplied_info *session_info,
struct messaging_context *msg_ctx,
struct dcerpc_binding_handle **binding_handle);
-NTSTATUS rpc_pipe_open_internal(TALLOC_CTX *mem_ctx,
- const struct ndr_syntax_id *abstract_syntax,
- const struct auth_serversupplied_info *serversupplied_info,
- struct client_address *client_id,
- struct messaging_context *msg_ctx,
- struct rpc_pipe_client **presult);
NTSTATUS rpc_pipe_open_interface(TALLOC_CTX *mem_ctx,
const struct ndr_syntax_id *syntax,
const struct auth_serversupplied_info *session_info,
@@ -58,4 +56,9 @@ NTSTATUS rpc_pipe_open_interface(TALLOC_CTX *mem_ctx,
struct messaging_context *msg_ctx,
struct rpc_pipe_client **cli_pipe);
+struct pipes_struct *get_first_internal_pipe(void);
+struct pipes_struct *get_next_internal_pipe(struct pipes_struct *p);
+bool check_open_pipes(void);
+int close_internal_rpc_pipe_hnd(struct pipes_struct *p);
+
#endif /* _RPC_NCACN_NP_H_ */
diff --git a/source3/rpc_server/rpc_server.c b/source3/rpc_server/rpc_server.c
index c7c77f03757..44c1b104c0b 100644
--- a/source3/rpc_server/rpc_server.c
+++ b/source3/rpc_server/rpc_server.c
@@ -18,6 +18,7 @@
*/
#include "includes.h"
+#include "ntdomain.h"
#include "rpc_server/rpc_server.h"
#include "rpc_dce.h"
#include "librpc/gen_ndr/netlogon.h"
@@ -26,7 +27,9 @@
#include "libcli/named_pipe_auth/npa_tstream.h"
#include "../auth/auth_sam_reply.h"
#include "auth.h"
-#include "ntdomain.h"
+#include "rpc_server/rpc_ncacn_np.h"
+#include "rpc_server/srv_pipe_hnd.h"
+#include "rpc_server/srv_pipe.h"
#define SERVER_TCP_LOW_PORT 1024
#define SERVER_TCP_HIGH_PORT 1300
@@ -76,7 +79,6 @@ static NTSTATUS auth_anonymous_session_info(TALLOC_CTX *mem_ctx,
* sent from the client */
static int make_server_pipes_struct(TALLOC_CTX *mem_ctx,
const char *pipe_name,
- const struct ndr_syntax_id id,
enum dcerpc_transport_t transport,
bool ncalrpc_as_system,
const char *client_address,
@@ -90,14 +92,13 @@ static int make_server_pipes_struct(TALLOC_CTX *mem_ctx,
struct pipes_struct *p;
struct auth_serversupplied_info *server_info;
NTSTATUS status;
- bool ok;
p = talloc_zero(mem_ctx, struct pipes_struct);
if (!p) {
*perrno = ENOMEM;
return -1;
}
- p->syntax = id;
+
p->transport = transport;
p->ncalrpc_as_system = ncalrpc_as_system;
@@ -108,15 +109,6 @@ static int make_server_pipes_struct(TALLOC_CTX *mem_ctx,
return -1;
}
- ok = init_pipe_handles(p, &id);
- if (!ok) {
- DEBUG(1, ("Failed to init handles\n"));
- TALLOC_FREE(p);
- *perrno = EINVAL;
- return -1;
- }
-
-
data_blob_free(&p->in_data.data);
data_blob_free(&p->in_data.pdu);
@@ -258,6 +250,17 @@ bool setup_named_pipe_socket(const char *pipe_name,
}
state->fd = -1;
+ /*
+ * As lp_ncalrpc_dir() should have 0755, but
+ * lp_ncalrpc_dir()/np should have 0700, we need to
+ * create lp_ncalrpc_dir() first.
+ */
+ if (!directory_create_or_exist(lp_ncalrpc_dir(), geteuid(), 0755)) {
+ DEBUG(0, ("Failed to create pipe directory %s - %s\n",
+ lp_ncalrpc_dir(), strerror(errno)));
+ goto out;
+ }
+
np_dir = talloc_asprintf(state, "%s/np", lp_ncalrpc_dir());
if (!np_dir) {
DEBUG(0, ("Out of memory\n"));
@@ -340,7 +343,6 @@ static void named_pipe_listener(struct tevent_context *ev,
struct named_pipe_client {
const char *pipe_name;
- struct ndr_syntax_id pipe_id;
struct tevent_context *ev;
struct messaging_context *msg_ctx;
@@ -369,20 +371,11 @@ static void named_pipe_accept_done(struct tevent_req *subreq);
static void named_pipe_accept_function(const char *pipe_name, int fd)
{
- struct ndr_syntax_id syntax;
struct named_pipe_client *npc;
struct tstream_context *plain;
struct tevent_req *subreq;
- bool ok;
int ret;
- ok = is_known_pipename(pipe_name, &syntax);
- if (!ok) {
- DEBUG(1, ("Unknown pipe [%s]\n", pipe_name));
- close(fd);
- return;
- }
-
npc = talloc_zero(NULL, struct named_pipe_client);
if (!npc) {
DEBUG(0, ("Out of memory!\n"));
@@ -390,7 +383,6 @@ static void named_pipe_accept_function(const char *pipe_name, int fd)
return;
}
npc->pipe_name = pipe_name;
- npc->pipe_id = syntax;
npc->ev = server_event_context();
npc->msg_ctx = server_messaging_context();
@@ -470,7 +462,7 @@ static void named_pipe_accept_done(struct tevent_req *subreq)
}
ret = make_server_pipes_struct(npc,
- npc->pipe_name, npc->pipe_id, NCACN_NP,
+ npc->pipe_name, NCACN_NP,
false, cli_addr, NULL, npc->session_info,
&npc->p, &error);
if (ret != 0) {
@@ -679,7 +671,6 @@ fail:
static void dcerpc_ncacn_accept(struct tevent_context *ev_ctx,
struct messaging_context *msg_ctx,
- struct ndr_syntax_id syntax_id,
enum dcerpc_transport_t transport,
const char *name,
uint16_t port,
@@ -699,7 +690,6 @@ static void dcerpc_ncacn_tcpip_listener(struct tevent_context *ev,
uint16_t setup_dcerpc_ncacn_tcpip_socket(struct tevent_context *ev_ctx,
struct messaging_context *msg_ctx,
- struct ndr_syntax_id syntax_id,
const struct sockaddr_storage *ifss,
uint16_t port)
{
@@ -713,7 +703,6 @@ uint16_t setup_dcerpc_ncacn_tcpip_socket(struct tevent_context *ev_ctx,
return 0;
}
- state->syntax_id = syntax_id;
state->fd = -1;
state->ep.port = port;
state->disconnect_fn = NULL;
@@ -839,7 +828,6 @@ static void dcerpc_ncacn_tcpip_listener(struct tevent_context *ev,
dcerpc_ncacn_accept(state->ev_ctx,
state->msg_ctx,
- state->syntax_id,
NCACN_IP_TCP,
NULL,
state->ep.port,
@@ -860,7 +848,6 @@ static void dcerpc_ncalrpc_listener(struct tevent_context *ev,
bool setup_dcerpc_ncalrpc_socket(struct tevent_context *ev_ctx,
struct messaging_context *msg_ctx,
- struct ndr_syntax_id syntax_id,
const char *name,
dcerpc_ncacn_disconnect_fn fn)
{
@@ -873,7 +860,6 @@ bool setup_dcerpc_ncalrpc_socket(struct tevent_context *ev_ctx,
return false;
}
- state->syntax_id = syntax_id;
state->fd = -1;
state->disconnect_fn = fn;
@@ -888,13 +874,13 @@ bool setup_dcerpc_ncalrpc_socket(struct tevent_context *ev_ctx,
return false;
}
- if (!directory_create_or_exist(lp_ncalrpc_dir(), geteuid(), 0700)) {
+ if (!directory_create_or_exist(lp_ncalrpc_dir(), geteuid(), 0755)) {
DEBUG(0, ("Failed to create pipe directory %s - %s\n",
lp_ncalrpc_dir(), strerror(errno)));
goto out;
}
- state->fd = create_pipe_sock(lp_ncalrpc_dir(), name, 0700);
+ state->fd = create_pipe_sock(lp_ncalrpc_dir(), name, 0755);
if (state->fd == -1) {
DEBUG(0, ("Failed to create pipe socket! [%s/%s]\n",
lp_ncalrpc_dir(), name));
@@ -969,15 +955,13 @@ static void dcerpc_ncalrpc_listener(struct tevent_context *ev,
dcerpc_ncacn_accept(state->ev_ctx,
state->msg_ctx,
- state->syntax_id, NCALRPC,
+ NCALRPC,
state->ep.name, 0,
cli_addr, NULL, sd,
state->disconnect_fn);
}
struct dcerpc_ncacn_conn {
- struct ndr_syntax_id syntax_id;
-
enum dcerpc_transport_t transport;
union {
@@ -1011,7 +995,6 @@ static void dcerpc_ncacn_packet_done(struct tevent_req *subreq);
static void dcerpc_ncacn_accept(struct tevent_context *ev_ctx,
struct messaging_context *msg_ctx,
- struct ndr_syntax_id syntax_id,
enum dcerpc_transport_t transport,
const char *name,
uint16_t port,
@@ -1040,7 +1023,6 @@ static void dcerpc_ncacn_accept(struct tevent_context *ev_ctx,
}
ncacn_conn->transport = transport;
- ncacn_conn->syntax_id = syntax_id;
ncacn_conn->ev_ctx = ev_ctx;
ncacn_conn->msg_ctx = msg_ctx;
ncacn_conn->sock = s;
@@ -1171,7 +1153,6 @@ static void dcerpc_ncacn_accept(struct tevent_context *ev_ctx,
rc = make_server_pipes_struct(ncacn_conn,
pipe_name,
- ncacn_conn->syntax_id,
ncacn_conn->transport,
system_user,
cli_str,
diff --git a/source3/rpc_server/rpc_server.h b/source3/rpc_server/rpc_server.h
index 3791589bb64..aafc96238a5 100644
--- a/source3/rpc_server/rpc_server.h
+++ b/source3/rpc_server/rpc_server.h
@@ -20,6 +20,8 @@
#ifndef _RPC_SERVER_H_
#define _RPC_SERVER_H_
+struct pipes_struct;
+
typedef bool (*dcerpc_ncacn_disconnect_fn)(struct pipes_struct *p);
void set_incoming_fault(struct pipes_struct *p);
@@ -29,13 +31,11 @@ bool setup_named_pipe_socket(const char *pipe_name,
uint16_t setup_dcerpc_ncacn_tcpip_socket(struct tevent_context *ev_ctx,
struct messaging_context *msg_ctx,
- struct ndr_syntax_id syntax_id,
const struct sockaddr_storage *ifss,
uint16_t port);
bool setup_dcerpc_ncalrpc_socket(struct tevent_context *ev_ctx,
struct messaging_context *msg_ctx,
- struct ndr_syntax_id syntax_id,
const char *name,
dcerpc_ncacn_disconnect_fn fn);
diff --git a/source3/rpc_server/samr/srv_samr_nt.c b/source3/rpc_server/samr/srv_samr_nt.c
index 99dd3f4d585..a253f307ac6 100644
--- a/source3/rpc_server/samr/srv_samr_nt.c
+++ b/source3/rpc_server/samr/srv_samr_nt.c
@@ -33,8 +33,8 @@
#include "includes.h"
#include "system/passwd.h"
-#include "smbd/globals.h"
#include "../libcli/auth/libcli_auth.h"
+#include "ntdomain.h"
#include "../librpc/gen_ndr/srv_samr.h"
#include "rpc_server/samr/srv_samr_util.h"
#include "../lib/crypto/arcfour.h"
@@ -43,7 +43,6 @@
#include "../libcli/security/security.h"
#include "passdb.h"
#include "auth.h"
-#include "ntdomain.h"
#include "rpc_server/srv_access_check.h"
#undef DBGC_CLASS
@@ -785,7 +784,7 @@ static NTSTATUS make_user_sam_entry_list(TALLOC_CTX *ctx,
return NT_STATUS_OK;
}
- sam = TALLOC_ZERO_ARRAY(ctx, struct samr_SamEntry, num_entries);
+ sam = talloc_zero_array(ctx, struct samr_SamEntry, num_entries);
if (sam == NULL) {
DEBUG(0, ("make_user_sam_entry_list: TALLOC_ZERO failed!\n"));
return NT_STATUS_NO_MEMORY;
@@ -843,7 +842,7 @@ NTSTATUS _samr_EnumDomainUsers(struct pipes_struct *p,
return status;
}
- samr_array = TALLOC_ZERO_P(p->mem_ctx, struct samr_SamArray);
+ samr_array = talloc_zero(p->mem_ctx, struct samr_SamArray);
if (!samr_array) {
return NT_STATUS_NO_MEMORY;
}
@@ -939,7 +938,7 @@ static void make_group_sam_entry_list(TALLOC_CTX *ctx,
return;
}
- sam = TALLOC_ZERO_ARRAY(ctx, struct samr_SamEntry, num_sam_entries);
+ sam = talloc_zero_array(ctx, struct samr_SamEntry, num_sam_entries);
if (sam == NULL) {
return;
}
@@ -978,7 +977,7 @@ NTSTATUS _samr_EnumDomainGroups(struct pipes_struct *p,
DEBUG(5,("_samr_EnumDomainGroups: %d\n", __LINE__));
- samr_array = TALLOC_ZERO_P(p->mem_ctx, struct samr_SamArray);
+ samr_array = talloc_zero(p->mem_ctx, struct samr_SamArray);
if (!samr_array) {
return NT_STATUS_NO_MEMORY;
}
@@ -1056,7 +1055,7 @@ NTSTATUS _samr_EnumDomainAliases(struct pipes_struct *p,
DEBUG(5,("_samr_EnumDomainAliases: sid %s\n",
sid_string_dbg(&dinfo->sid)));
- samr_array = TALLOC_ZERO_P(p->mem_ctx, struct samr_SamArray);
+ samr_array = talloc_zero(p->mem_ctx, struct samr_SamArray);
if (!samr_array) {
return NT_STATUS_NO_MEMORY;
}
@@ -1121,7 +1120,7 @@ static NTSTATUS init_samr_dispinfo_1(TALLOC_CTX *ctx,
r->count = num_entries;
- r->entries = TALLOC_ZERO_ARRAY(ctx, struct samr_DispEntryGeneral, num_entries);
+ r->entries = talloc_zero_array(ctx, struct samr_DispEntryGeneral, num_entries);
if (!r->entries) {
return NT_STATUS_NO_MEMORY;
}
@@ -1165,7 +1164,7 @@ static NTSTATUS init_samr_dispinfo_2(TALLOC_CTX *ctx,
r->count = num_entries;
- r->entries = TALLOC_ZERO_ARRAY(ctx, struct samr_DispEntryFull, num_entries);
+ r->entries = talloc_zero_array(ctx, struct samr_DispEntryFull, num_entries);
if (!r->entries) {
return NT_STATUS_NO_MEMORY;
}
@@ -1206,7 +1205,7 @@ static NTSTATUS init_samr_dispinfo_3(TALLOC_CTX *ctx,
r->count = num_entries;
- r->entries = TALLOC_ZERO_ARRAY(ctx, struct samr_DispEntryFullGroup, num_entries);
+ r->entries = talloc_zero_array(ctx, struct samr_DispEntryFullGroup, num_entries);
if (!r->entries) {
return NT_STATUS_NO_MEMORY;
}
@@ -1247,7 +1246,7 @@ static NTSTATUS init_samr_dispinfo_4(TALLOC_CTX *ctx,
r->count = num_entries;
- r->entries = TALLOC_ZERO_ARRAY(ctx, struct samr_DispEntryAscii, num_entries);
+ r->entries = talloc_zero_array(ctx, struct samr_DispEntryAscii, num_entries);
if (!r->entries) {
return NT_STATUS_NO_MEMORY;
}
@@ -1283,7 +1282,7 @@ static NTSTATUS init_samr_dispinfo_5(TALLOC_CTX *ctx,
r->count = num_entries;
- r->entries = TALLOC_ZERO_ARRAY(ctx, struct samr_DispEntryAscii, num_entries);
+ r->entries = talloc_zero_array(ctx, struct samr_DispEntryAscii, num_entries);
if (!r->entries) {
return NT_STATUS_NO_MEMORY;
}
@@ -1579,7 +1578,7 @@ NTSTATUS _samr_QueryAliasInfo(struct pipes_struct *p,
return status;
}
- alias_info = TALLOC_ZERO_P(p->mem_ctx, union samr_AliasInfo);
+ alias_info = talloc_zero(p->mem_ctx, union samr_AliasInfo);
if (!alias_info) {
return NT_STATUS_NO_MEMORY;
}
@@ -1985,12 +1984,12 @@ NTSTATUS _samr_ChangePasswordUser3(struct pipes_struct *p,
time_t u_expire, u_min_age;
uint32 account_policy_temp;
- dominfo = TALLOC_ZERO_P(p->mem_ctx, struct samr_DomInfo1);
+ dominfo = talloc_zero(p->mem_ctx, struct samr_DomInfo1);
if (!dominfo) {
return NT_STATUS_NO_MEMORY;
}
- reject = TALLOC_ZERO_P(p->mem_ctx,
+ reject = talloc_zero(p->mem_ctx,
struct userPwdChangeFailureInformation);
if (!reject) {
return NT_STATUS_NO_MEMORY;
@@ -2051,7 +2050,7 @@ static bool make_samr_lookup_rids(TALLOC_CTX *ctx, uint32 num_names,
*lsa_name_array_p = NULL;
if (num_names != 0) {
- lsa_name_array = TALLOC_ZERO_ARRAY(ctx, struct lsa_String, num_names);
+ lsa_name_array = talloc_zero_array(ctx, struct lsa_String, num_names);
if (!lsa_name_array) {
return false;
}
@@ -2101,9 +2100,9 @@ NTSTATUS _samr_LookupRids(struct pipes_struct *p,
}
if (num_rids) {
- names = TALLOC_ZERO_ARRAY(p->mem_ctx, const char *, num_rids);
- attrs = TALLOC_ZERO_ARRAY(p->mem_ctx, enum lsa_SidType, num_rids);
- wire_attrs = TALLOC_ZERO_ARRAY(p->mem_ctx, uint32, num_rids);
+ names = talloc_zero_array(p->mem_ctx, const char *, num_rids);
+ attrs = talloc_zero_array(p->mem_ctx, enum lsa_SidType, num_rids);
+ wire_attrs = talloc_zero_array(p->mem_ctx, uint32, num_rids);
if ((names == NULL) || (attrs == NULL) || (wire_attrs==NULL))
return NT_STATUS_NO_MEMORY;
@@ -2289,12 +2288,12 @@ static NTSTATUS init_samr_parameters_string(TALLOC_CTX *mem_ctx,
return NT_STATUS_INVALID_PARAMETER;
}
- r = TALLOC_ZERO_P(mem_ctx, struct lsa_BinaryString);
+ r = talloc_zero(mem_ctx, struct lsa_BinaryString);
if (!r) {
return NT_STATUS_NO_MEMORY;
}
- r->array = TALLOC_ZERO_ARRAY(mem_ctx, uint16_t, blob->length/2);
+ r->array = talloc_zero_array(mem_ctx, uint16_t, blob->length/2);
if (!r->array) {
return NT_STATUS_NO_MEMORY;
}
@@ -2988,7 +2987,7 @@ NTSTATUS _samr_QueryUserInfo(struct pipes_struct *p,
DEBUG(5,("_samr_QueryUserInfo: sid:%s\n",
sid_string_dbg(&uinfo->sid)));
- user_info = TALLOC_ZERO_P(p->mem_ctx, union samr_UserInfo);
+ user_info = talloc_zero(p->mem_ctx, union samr_UserInfo);
if (!user_info) {
return NT_STATUS_NO_MEMORY;
}
@@ -3150,7 +3149,7 @@ NTSTATUS _samr_GetGroupsForUser(struct pipes_struct *p,
return result;
}
- rids = TALLOC_ZERO_P(p->mem_ctx, struct samr_RidWithAttributeArray);
+ rids = talloc_zero(p->mem_ctx, struct samr_RidWithAttributeArray);
if (!rids) {
return NT_STATUS_NO_MEMORY;
}
@@ -3324,7 +3323,7 @@ static NTSTATUS query_dom_info_2(TALLOC_CTX *mem_ctx,
r->oem_information.string = lp_serverstring();
r->domain_name.string = lp_workgroup();
- r->primary.string = global_myname();
+ r->primary.string = lp_netbios_name();
r->sequence_num = seq_num;
r->domain_server_state = DOMAIN_SERVER_ENABLED;
r->role = (enum samr_Role) samr_get_server_role();
@@ -3391,7 +3390,7 @@ static NTSTATUS query_dom_info_6(TALLOC_CTX *mem_ctx,
/* NT returns its own name when a PDC. win2k and later
* only the name of the PDC if itself is a BDC (samba4
* idl) */
- r->primary.string = global_myname();
+ r->primary.string = lp_netbios_name();
return NT_STATUS_OK;
}
@@ -3599,7 +3598,7 @@ NTSTATUS _samr_QueryDomainInfo(struct pipes_struct *p,
return status;
}
- dom_info = TALLOC_ZERO_P(p->mem_ctx, union samr_DomainInfo);
+ dom_info = talloc_zero(p->mem_ctx, union samr_DomainInfo);
if (!dom_info) {
return NT_STATUS_NO_MEMORY;
}
@@ -4055,7 +4054,7 @@ NTSTATUS _samr_LookupDomain(struct pipes_struct *p,
return NT_STATUS_INVALID_PARAMETER;
}
- sid = TALLOC_ZERO_P(p->mem_ctx, struct dom_sid2);
+ sid = talloc_zero(p->mem_ctx, struct dom_sid2);
if (!sid) {
return NT_STATUS_NO_MEMORY;
}
@@ -4096,12 +4095,12 @@ NTSTATUS _samr_EnumDomains(struct pipes_struct *p,
return status;
}
- sam = TALLOC_ZERO_P(p->mem_ctx, struct samr_SamArray);
+ sam = talloc_zero(p->mem_ctx, struct samr_SamArray);
if (!sam) {
return NT_STATUS_NO_MEMORY;
}
- entry_array = TALLOC_ZERO_ARRAY(p->mem_ctx,
+ entry_array = talloc_zero_array(p->mem_ctx,
struct samr_SamEntry,
num_entries);
if (!entry_array) {
@@ -5299,7 +5298,7 @@ NTSTATUS _samr_GetAliasMembership(struct pipes_struct *p,
return NT_STATUS_OBJECT_TYPE_MISMATCH;
if (r->in.sids->num_sids) {
- members = TALLOC_ARRAY(p->mem_ctx, struct dom_sid, r->in.sids->num_sids);
+ members = talloc_array(p->mem_ctx, struct dom_sid, r->in.sids->num_sids);
if (members == NULL)
return NT_STATUS_NO_MEMORY;
@@ -5370,7 +5369,7 @@ NTSTATUS _samr_GetMembersInAlias(struct pipes_struct *p,
}
if (num_sids) {
- sids = TALLOC_ZERO_ARRAY(p->mem_ctx, struct lsa_SidPtr, num_sids);
+ sids = talloc_zero_array(p->mem_ctx, struct lsa_SidPtr, num_sids);
if (sids == NULL) {
TALLOC_FREE(pdb_sids);
return NT_STATUS_NO_MEMORY;
@@ -5416,7 +5415,7 @@ NTSTATUS _samr_QueryGroupMember(struct pipes_struct *p,
return status;
}
- rids = TALLOC_ZERO_P(p->mem_ctx, struct samr_RidAttrArray);
+ rids = talloc_zero(p->mem_ctx, struct samr_RidAttrArray);
if (!rids) {
return NT_STATUS_NO_MEMORY;
}
@@ -5440,7 +5439,7 @@ NTSTATUS _samr_QueryGroupMember(struct pipes_struct *p,
return status;
if (num_members) {
- attr=TALLOC_ZERO_ARRAY(p->mem_ctx, uint32, num_members);
+ attr=talloc_zero_array(p->mem_ctx, uint32, num_members);
if (attr == NULL) {
return NT_STATUS_NO_MEMORY;
}
@@ -5955,7 +5954,7 @@ NTSTATUS _samr_QueryGroupInfo(struct pipes_struct *p,
group_name = talloc_strdup(r, map.nt_name);
group_description = talloc_strdup(r, map.comment);
- info = TALLOC_ZERO_P(p->mem_ctx, union samr_GroupInfo);
+ info = talloc_zero(p->mem_ctx, union samr_GroupInfo);
if (!info) {
return NT_STATUS_NO_MEMORY;
}
@@ -6133,7 +6132,7 @@ NTSTATUS _samr_SetAliasInfo(struct pipes_struct *p,
/* make sure the name doesn't already exist as a user
or local group */
- fstr_sprintf( group_name, "%s\\%s", global_myname(), info.acct_name );
+ fstr_sprintf( group_name, "%s\\%s", lp_netbios_name(), info.acct_name );
status = can_create( p->mem_ctx, group_name );
if ( !NT_STATUS_IS_OK( status ) )
return status;
diff --git a/source3/rpc_server/samr/srv_samr_util.c b/source3/rpc_server/samr/srv_samr_util.c
index 29123321f86..d052846b2e5 100644
--- a/source3/rpc_server/samr/srv_samr_util.c
+++ b/source3/rpc_server/samr/srv_samr_util.c
@@ -612,7 +612,16 @@ void copy_id21_to_sam_passwd(const char *log_prefix,
DEBUG(10,("%s SAMR_FIELD_EXPIRED_FLAG: %02X\n", l,
from->password_expired));
if (from->password_expired != 0) {
- pdb_set_pass_last_set_time(to, 0, PDB_CHANGED);
+ /* Only allow the set_time to zero (which means
+ "User Must Change Password on Next Login"
+ if the user object allows password change. */
+ if (pdb_get_pass_can_change(to)) {
+ pdb_set_pass_last_set_time(to, 0, PDB_CHANGED);
+ } else {
+ DEBUG(10,("%s Disallowing set of 'User Must "
+ "Change Password on Next Login' as "
+ "user object disallows this.\n", l));
+ }
} else {
/* A subtlety here: some windows commands will
clear the expired flag even though it's not
diff --git a/source3/rpc_server/spoolss/srv_spoolss_nt.c b/source3/rpc_server/spoolss/srv_spoolss_nt.c
index 312f50965b7..8216388905f 100644
--- a/source3/rpc_server/spoolss/srv_spoolss_nt.c
+++ b/source3/rpc_server/spoolss/srv_spoolss_nt.c
@@ -28,6 +28,7 @@
up, all the errors returned are DOS errors, not NT status codes. */
#include "includes.h"
+#include "ntdomain.h"
#include "nt_printing.h"
#include "srv_spoolss_util.h"
#include "../librpc/gen_ndr/srv_spoolss.h"
@@ -46,9 +47,13 @@
#include "serverid.h"
#include "../libcli/registry/util_reg.h"
#include "smbd/smbd.h"
+#include "smbd/globals.h"
#include "auth.h"
#include "messages.h"
-#include "ntdomain.h"
+#include "rpc_server/spoolss/srv_spoolss_nt.h"
+#include "util_tdb.h"
+#include "libsmb/libsmb.h"
+#include "printing/printer_list.h"
/* macros stolen from s4 spoolss server */
#define SPOOLSS_BUFFER_UNION(fn,info,level) \
@@ -574,7 +579,7 @@ static WERROR set_printer_hnd_name(TALLOC_CTX *mem_ctx,
DEBUG(4,("Setting printer name=%s (len=%lu)\n", handlename,
(unsigned long)strlen(handlename)));
- aprinter = CONST_DISCARD(char *, handlename);
+ aprinter = discard_const_p(char, handlename);
if ( *handlename == '\\' ) {
servername = canon_servername(handlename);
if ( (aprinter = strchr_m( servername, '\\' )) != NULL ) {
@@ -726,7 +731,7 @@ static WERROR set_printer_hnd_name(TALLOC_CTX *mem_ctx,
DEBUGADD(4,("set_printer_hnd_name: Printer found: %s -> %s\n", aprinter, sname));
- fstrcpy(Printer->sharename, sname);
+ strlcpy(Printer->sharename, sname, sizeof(Printer->sharename));
return WERR_OK;
}
@@ -1089,7 +1094,7 @@ static int notify_msg_ctr_addmsg( SPOOLSS_NOTIFY_MSG_CTR *ctr, SPOOLSS_NOTIFY_MS
if ( i == ctr->num_groups ) {
ctr->num_groups++;
- if ( !(groups = TALLOC_REALLOC_ARRAY( ctr->ctx, ctr->msg_groups, SPOOLSS_NOTIFY_MSG_GROUP, ctr->num_groups)) ) {
+ if ( !(groups = talloc_realloc( ctr->ctx, ctr->msg_groups, SPOOLSS_NOTIFY_MSG_GROUP, ctr->num_groups)) ) {
DEBUG(0,("notify_msg_ctr_addmsg: talloc_realloc() failed!\n"));
return 0;
}
@@ -1107,7 +1112,7 @@ static int notify_msg_ctr_addmsg( SPOOLSS_NOTIFY_MSG_CTR *ctr, SPOOLSS_NOTIFY_MS
msg_grp->num_msgs++;
- if ( !(msg_list = TALLOC_REALLOC_ARRAY( ctr->ctx, msg_grp->msgs, SPOOLSS_NOTIFY_MSG, msg_grp->num_msgs )) ) {
+ if ( !(msg_list = talloc_realloc( ctr->ctx, msg_grp->msgs, SPOOLSS_NOTIFY_MSG, msg_grp->num_msgs )) ) {
DEBUG(0,("notify_msg_ctr_addmsg: talloc_realloc() failed for new message [%d]!\n", msg_grp->num_msgs));
return 0;
}
@@ -1120,7 +1125,7 @@ static int notify_msg_ctr_addmsg( SPOOLSS_NOTIFY_MSG_CTR *ctr, SPOOLSS_NOTIFY_MS
if ( msg->len != 0 )
msg_grp->msgs[new_slot].notify.data = (char *)
- TALLOC_MEMDUP( ctr->ctx, msg->notify.data, msg->len );
+ talloc_memdup( ctr->ctx, msg->notify.data, msg->len );
return ctr->num_groups;
}
@@ -1500,7 +1505,7 @@ static bool srv_spoolss_drv_upgrade_printer(const char *drivername,
messaging_send_buf(msg_ctx, messaging_server_id(msg_ctx),
MSG_PRINTER_DRVUPGRADE,
- (uint8_t *)drivername, len+1);
+ (const uint8_t *)drivername, len+1);
return true;
}
@@ -2335,32 +2340,32 @@ static WERROR getprinterdata_printer_server(TALLOC_CTX *mem_ctx,
{
DEBUG(8,("getprinterdata_printer_server:%s\n", value));
- if (!StrCaseCmp(value, "W3SvcInstalled")) {
+ if (!strcasecmp_m(value, "W3SvcInstalled")) {
*type = REG_DWORD;
data->value = 0x00;
return WERR_OK;
}
- if (!StrCaseCmp(value, "BeepEnabled")) {
+ if (!strcasecmp_m(value, "BeepEnabled")) {
*type = REG_DWORD;
data->value = 0x00;
return WERR_OK;
}
- if (!StrCaseCmp(value, "EventLog")) {
+ if (!strcasecmp_m(value, "EventLog")) {
*type = REG_DWORD;
/* formally was 0x1b */
data->value = 0x00;
return WERR_OK;
}
- if (!StrCaseCmp(value, "NetPopup")) {
+ if (!strcasecmp_m(value, "NetPopup")) {
*type = REG_DWORD;
data->value = 0x00;
return WERR_OK;
}
- if (!StrCaseCmp(value, "MajorVersion")) {
+ if (!strcasecmp_m(value, "MajorVersion")) {
*type = REG_DWORD;
/* Windows NT 4.0 seems to not allow uploading of drivers
@@ -2377,7 +2382,7 @@ static WERROR getprinterdata_printer_server(TALLOC_CTX *mem_ctx,
return WERR_OK;
}
- if (!StrCaseCmp(value, "MinorVersion")) {
+ if (!strcasecmp_m(value, "MinorVersion")) {
*type = REG_DWORD;
data->value = 0x00;
return WERR_OK;
@@ -2390,7 +2395,7 @@ static WERROR getprinterdata_printer_server(TALLOC_CTX *mem_ctx,
* uint32_t build = [2195|2600]
* extra unicode string = e.g. "Service Pack 3"
*/
- if (!StrCaseCmp(value, "OSVersion")) {
+ if (!strcasecmp_m(value, "OSVersion")) {
DATA_BLOB blob;
enum ndr_err_code ndr_err;
struct spoolss_OSVersion os;
@@ -2413,7 +2418,7 @@ static WERROR getprinterdata_printer_server(TALLOC_CTX *mem_ctx,
}
- if (!StrCaseCmp(value, "DefaultSpoolDirectory")) {
+ if (!strcasecmp_m(value, "DefaultSpoolDirectory")) {
*type = REG_SZ;
data->string = talloc_strdup(mem_ctx, "C:\\PRINTERS");
@@ -2422,7 +2427,7 @@ static WERROR getprinterdata_printer_server(TALLOC_CTX *mem_ctx,
return WERR_OK;
}
- if (!StrCaseCmp(value, "Architecture")) {
+ if (!strcasecmp_m(value, "Architecture")) {
*type = REG_SZ;
data->string = talloc_strdup(mem_ctx,
lp_parm_const_string(GLOBAL_SECTION_SNUM, "spoolss", "architecture", SPOOLSS_ARCHITECTURE_NT_X86));
@@ -2431,7 +2436,7 @@ static WERROR getprinterdata_printer_server(TALLOC_CTX *mem_ctx,
return WERR_OK;
}
- if (!StrCaseCmp(value, "DsPresent")) {
+ if (!strcasecmp_m(value, "DsPresent")) {
*type = REG_DWORD;
/* only show the publish check box if we are a
@@ -2445,7 +2450,7 @@ static WERROR getprinterdata_printer_server(TALLOC_CTX *mem_ctx,
return WERR_OK;
}
- if (!StrCaseCmp(value, "DNSMachineName")) {
+ if (!strcasecmp_m(value, "DNSMachineName")) {
const char *hostname = get_mydnsfullname();
if (!hostname) {
@@ -2518,7 +2523,7 @@ static bool spoolss_connect_to_client(struct rpc_pipe_client **pp_pipe,
}
/* setup the connection */
- ret = cli_full_connection( &the_cli, global_myname(), remote_machine,
+ ret = cli_full_connection( &the_cli, lp_netbios_name(), remote_machine,
&rm_addr, 0, "IPC$", "IPC",
"", /* username */
"", /* domain */
@@ -2876,7 +2881,21 @@ static void spoolss_notify_location(struct messaging_context *msg_ctx,
struct spoolss_PrinterInfo2 *pinfo2,
TALLOC_CTX *mem_ctx)
{
- SETUP_SPOOLSS_NOTIFY_DATA_STRING(data, pinfo2->location);
+ const char *loc = pinfo2->location;
+ NTSTATUS status;
+
+ status = printer_list_get_printer(mem_ctx,
+ pinfo2->sharename,
+ NULL,
+ &loc,
+ NULL);
+ if (NT_STATUS_IS_OK(status)) {
+ if (loc == NULL) {
+ loc = pinfo2->location;
+ }
+ }
+
+ SETUP_SPOOLSS_NOTIFY_DATA_STRING(data, loc);
}
/*******************************************************************
@@ -3404,7 +3423,6 @@ static bool construct_notify_printer_info(struct messaging_context *msg_ctx,
uint16_t field;
struct spoolss_Notify *current_data;
- print_queue_struct *queue=NULL;
type = option_type->type;
@@ -3420,7 +3438,7 @@ static bool construct_notify_printer_info(struct messaging_context *msg_ctx,
if (!search_notify(type, field, &j) )
continue;
- info->notifies = TALLOC_REALLOC_ARRAY(info, info->notifies,
+ info->notifies = talloc_realloc(info, info->notifies,
struct spoolss_Notify,
info->count + 1);
if (info->notifies == NULL) {
@@ -3438,7 +3456,7 @@ static bool construct_notify_printer_info(struct messaging_context *msg_ctx,
pinfo2->printername));
notify_info_data_table[j].fn(msg_ctx, snum, current_data,
- queue, pinfo2, mem_ctx);
+ NULL, pinfo2, mem_ctx);
info->count++;
}
@@ -3480,7 +3498,7 @@ static bool construct_notify_jobs_info(struct messaging_context *msg_ctx,
if (!search_notify(type, field, &j) )
continue;
- info->notifies = TALLOC_REALLOC_ARRAY(info, info->notifies,
+ info->notifies = talloc_realloc(info, info->notifies,
struct spoolss_Notify,
info->count + 1);
if (info->notifies == NULL) {
@@ -4009,8 +4027,24 @@ static WERROR construct_printer_info2(TALLOC_CTX *mem_ctx,
}
W_ERROR_HAVE_NO_MEMORY(r->comment);
- r->location = talloc_strdup(mem_ctx, info2->location);
+ r->location = talloc_strdup(mem_ctx, info2->location);
+ if (info2->location[0] == '\0') {
+ const char *loc = NULL;
+ NTSTATUS nt_status;
+
+ nt_status = printer_list_get_printer(mem_ctx,
+ info2->sharename,
+ NULL,
+ &loc,
+ NULL);
+ if (NT_STATUS_IS_OK(nt_status)) {
+ if (loc != NULL) {
+ r->location = talloc_strdup(mem_ctx, loc);
+ }
+ }
+ }
W_ERROR_HAVE_NO_MEMORY(r->location);
+
r->sepfile = talloc_strdup(mem_ctx, info2->sepfile);
W_ERROR_HAVE_NO_MEMORY(r->sepfile);
r->printprocessor = talloc_strdup(mem_ctx, info2->printprocessor);
@@ -4145,10 +4179,9 @@ static WERROR construct_printer_info6(TALLOC_CTX *mem_ctx,
struct spoolss_PrinterInfo6 *r,
int snum)
{
- int count;
print_status_struct status;
- count = print_queue_length(msg_ctx, snum, &status);
+ print_queue_length(msg_ctx, snum, &status);
r->status = nt_printq_status(status.status);
@@ -4274,7 +4307,7 @@ static WERROR enum_all_printers_info_level(TALLOC_CTX *mem_ctx,
goto out;
}
- info = TALLOC_REALLOC_ARRAY(mem_ctx, info,
+ info = talloc_realloc(mem_ctx, info,
union spoolss_PrinterInfo,
count + 1);
if (!info) {
@@ -5314,7 +5347,7 @@ static WERROR spoolss_DriverFileInfo_from_driver(TALLOC_CTX *mem_ctx,
*count_p = 0;
if (strlen(driver->driver_path)) {
- info = TALLOC_REALLOC_ARRAY(mem_ctx, info,
+ info = talloc_realloc(mem_ctx, info,
struct spoolss_DriverFileInfo,
count + 1);
W_ERROR_HAVE_NO_MEMORY(info);
@@ -5329,7 +5362,7 @@ static WERROR spoolss_DriverFileInfo_from_driver(TALLOC_CTX *mem_ctx,
}
if (strlen(driver->config_file)) {
- info = TALLOC_REALLOC_ARRAY(mem_ctx, info,
+ info = talloc_realloc(mem_ctx, info,
struct spoolss_DriverFileInfo,
count + 1);
W_ERROR_HAVE_NO_MEMORY(info);
@@ -5344,7 +5377,7 @@ static WERROR spoolss_DriverFileInfo_from_driver(TALLOC_CTX *mem_ctx,
}
if (strlen(driver->data_file)) {
- info = TALLOC_REALLOC_ARRAY(mem_ctx, info,
+ info = talloc_realloc(mem_ctx, info,
struct spoolss_DriverFileInfo,
count + 1);
W_ERROR_HAVE_NO_MEMORY(info);
@@ -5359,7 +5392,7 @@ static WERROR spoolss_DriverFileInfo_from_driver(TALLOC_CTX *mem_ctx,
}
if (strlen(driver->help_file)) {
- info = TALLOC_REALLOC_ARRAY(mem_ctx, info,
+ info = talloc_realloc(mem_ctx, info,
struct spoolss_DriverFileInfo,
count + 1);
W_ERROR_HAVE_NO_MEMORY(info);
@@ -5374,7 +5407,7 @@ static WERROR spoolss_DriverFileInfo_from_driver(TALLOC_CTX *mem_ctx,
}
for (i=0; driver->dependent_files[i] && driver->dependent_files[i][0] != '\0'; i++) {
- info = TALLOC_REALLOC_ARRAY(mem_ctx, info,
+ info = talloc_realloc(mem_ctx, info,
struct spoolss_DriverFileInfo,
count + 1);
W_ERROR_HAVE_NO_MEMORY(info);
@@ -6004,7 +6037,7 @@ static bool check_printer_ok(TALLOC_CTX *mem_ctx,
info2->location));
/* we force some elements to "correct" values */
- info2->servername = talloc_asprintf(mem_ctx, "\\\\%s", global_myname());
+ info2->servername = talloc_asprintf(mem_ctx, "\\\\%s", lp_netbios_name());
if (info2->servername == NULL) {
return false;
}
@@ -6016,7 +6049,7 @@ static bool check_printer_ok(TALLOC_CTX *mem_ctx,
/* check to see if we allow printername != sharename */
if (lp_force_printername(snum)) {
info2->printername = talloc_asprintf(mem_ctx, "\\\\%s\\%s",
- global_myname(), info2->sharename);
+ lp_netbios_name(), info2->sharename);
} else {
/* make sure printername is in \\server\printername format */
fstrcpy(printername, info2->printername);
@@ -6027,7 +6060,7 @@ static bool check_printer_ok(TALLOC_CTX *mem_ctx,
}
info2->printername = talloc_asprintf(mem_ctx, "\\\\%s\\%s",
- global_myname(), p);
+ lp_netbios_name(), p);
}
if (info2->printername == NULL) {
return false;
@@ -6413,7 +6446,7 @@ static WERROR update_dsspooler(TALLOC_CTX *mem_ctx,
buffer.length);
}
- push_reg_sz(mem_ctx, &buffer, global_myname());
+ push_reg_sz(mem_ctx, &buffer, lp_netbios_name());
winreg_set_printer_dataex(mem_ctx,
session_info,
msg_ctx,
@@ -6428,7 +6461,7 @@ static WERROR update_dsspooler(TALLOC_CTX *mem_ctx,
if (dnsdomname != NULL && dnsdomname[0] != '\0') {
longname = talloc_strdup(mem_ctx, dnsdomname);
} else {
- longname = talloc_strdup(mem_ctx, global_myname());
+ longname = talloc_strdup(mem_ctx, lp_netbios_name());
}
if (longname == NULL) {
result = WERR_NOMEM;
@@ -6447,7 +6480,7 @@ static WERROR update_dsspooler(TALLOC_CTX *mem_ctx,
buffer.length);
uncname = talloc_asprintf(mem_ctx, "\\\\%s\\%s",
- global_myname(), printer->sharename);
+ lp_netbios_name(), printer->sharename);
push_reg_sz(mem_ctx, &buffer, uncname);
winreg_set_printer_dataex(mem_ctx,
session_info,
@@ -6891,7 +6924,7 @@ static WERROR enumjobs_level1(TALLOC_CTX *mem_ctx,
int i;
WERROR result = WERR_OK;
- info = TALLOC_ARRAY(mem_ctx, union spoolss_JobInfo, num_queues);
+ info = talloc_array(mem_ctx, union spoolss_JobInfo, num_queues);
W_ERROR_HAVE_NO_MEMORY(info);
*count = num_queues;
@@ -6935,7 +6968,7 @@ static WERROR enumjobs_level2(TALLOC_CTX *mem_ctx,
int i;
WERROR result = WERR_OK;
- info = TALLOC_ARRAY(mem_ctx, union spoolss_JobInfo, num_queues);
+ info = talloc_array(mem_ctx, union spoolss_JobInfo, num_queues);
W_ERROR_HAVE_NO_MEMORY(info);
*count = num_queues;
@@ -6990,7 +7023,7 @@ static WERROR enumjobs_level3(TALLOC_CTX *mem_ctx,
int i;
WERROR result = WERR_OK;
- info = TALLOC_ARRAY(mem_ctx, union spoolss_JobInfo, num_queues);
+ info = talloc_array(mem_ctx, union spoolss_JobInfo, num_queues);
W_ERROR_HAVE_NO_MEMORY(info);
*count = num_queues;
@@ -7259,7 +7292,7 @@ static WERROR enumprinterdrivers_level_by_architecture(TALLOC_CTX *mem_ctx,
num_drivers, architecture, version));
if (num_drivers != 0) {
- info = TALLOC_REALLOC_ARRAY(mem_ctx, info,
+ info = talloc_realloc(mem_ctx, info,
union spoolss_DriverInfo,
count + num_drivers);
if (!info) {
@@ -7599,7 +7632,7 @@ static WERROR enumports_hook(TALLOC_CTX *ctx, int *count, char ***lines)
/* if no hook then just fill in the default port */
if ( !*cmd ) {
- if (!(qlines = TALLOC_ARRAY( NULL, char*, 2 ))) {
+ if (!(qlines = talloc_array( NULL, char*, 2 ))) {
return WERR_NOMEM;
}
if (!(qlines[0] = talloc_strdup(qlines, SAMBA_PRINTER_PORT_NAME ))) {
@@ -7660,7 +7693,7 @@ static WERROR enumports_level_1(TALLOC_CTX *mem_ctx,
}
if (numlines) {
- info = TALLOC_ARRAY(mem_ctx, union spoolss_PortInfo, numlines);
+ info = talloc_array(mem_ctx, union spoolss_PortInfo, numlines);
if (!info) {
DEBUG(10,("Returning WERR_NOMEM\n"));
result = WERR_NOMEM;
@@ -7712,7 +7745,7 @@ static WERROR enumports_level_2(TALLOC_CTX *mem_ctx,
}
if (numlines) {
- info = TALLOC_ARRAY(mem_ctx, union spoolss_PortInfo, numlines);
+ info = talloc_array(mem_ctx, union spoolss_PortInfo, numlines);
if (!info) {
DEBUG(10,("Returning WERR_NOMEM\n"));
result = WERR_NOMEM;
@@ -8011,12 +8044,12 @@ WERROR _spoolss_AddPrinterDriverEx(struct pipes_struct *p,
}
DEBUG(5,("Cleaning driver's information\n"));
- err = clean_up_driver_struct(p->mem_ctx, p, r->in.info_ctr);
+ err = clean_up_driver_struct(p->mem_ctx, p->session_info, r->in.info_ctr);
if (!W_ERROR_IS_OK(err))
goto done;
DEBUG(5,("Moving driver to final destination\n"));
- err = move_driver_to_download_area(p, r->in.info_ctr);
+ err = move_driver_to_download_area(p->session_info, r->in.info_ctr);
if (!W_ERROR_IS_OK(err)) {
goto done;
}
@@ -8639,7 +8672,7 @@ static WERROR enumprintprocessors_level_1(TALLOC_CTX *mem_ctx,
union spoolss_PrintProcessorInfo *info;
WERROR result;
- info = TALLOC_ARRAY(mem_ctx, union spoolss_PrintProcessorInfo, 1);
+ info = talloc_array(mem_ctx, union spoolss_PrintProcessorInfo, 1);
W_ERROR_HAVE_NO_MEMORY(info);
*count = 1;
@@ -8741,7 +8774,7 @@ static WERROR enumprintprocdatatypes_level_1(TALLOC_CTX *mem_ctx,
WERROR result;
union spoolss_PrintProcDataTypesInfo *info;
- info = TALLOC_ARRAY(mem_ctx, union spoolss_PrintProcDataTypesInfo, 1);
+ info = talloc_array(mem_ctx, union spoolss_PrintProcDataTypesInfo, 1);
W_ERROR_HAVE_NO_MEMORY(info);
*count = 1;
@@ -8798,6 +8831,10 @@ WERROR _spoolss_EnumPrintProcDataTypes(struct pipes_struct *p,
return WERR_UNKNOWN_LEVEL;
}
+ if (!W_ERROR_IS_OK(result)) {
+ return result;
+ }
+
*r->out.needed = SPOOLSS_BUFFER_UNION_ARRAY(p->mem_ctx,
spoolss_EnumPrintProcDataTypes,
*r->out.info, r->in.level,
@@ -8853,7 +8890,7 @@ static WERROR enumprintmonitors_level_1(TALLOC_CTX *mem_ctx,
union spoolss_MonitorInfo *info;
WERROR result = WERR_OK;
- info = TALLOC_ARRAY(mem_ctx, union spoolss_MonitorInfo, 2);
+ info = talloc_array(mem_ctx, union spoolss_MonitorInfo, 2);
W_ERROR_HAVE_NO_MEMORY(info);
*count = 2;
@@ -8893,7 +8930,7 @@ static WERROR enumprintmonitors_level_2(TALLOC_CTX *mem_ctx,
union spoolss_MonitorInfo *info;
WERROR result = WERR_OK;
- info = TALLOC_ARRAY(mem_ctx, union spoolss_MonitorInfo, 2);
+ info = talloc_array(mem_ctx, union spoolss_MonitorInfo, 2);
W_ERROR_HAVE_NO_MEMORY(info);
*count = 2;
@@ -9154,9 +9191,9 @@ WERROR _spoolss_GetPrinterDataEx(struct pipes_struct *p,
int snum = 0;
WERROR result = WERR_OK;
DATA_BLOB blob;
- enum winreg_Type val_type;
- uint8_t *val_data;
- uint32_t val_size;
+ enum winreg_Type val_type = REG_NONE;
+ uint8_t *val_data = NULL;
+ uint32_t val_size = 0;
DEBUG(4,("_spoolss_GetPrinterDataEx\n"));
diff --git a/source3/rpc_server/spoolss/srv_spoolss_nt.h b/source3/rpc_server/spoolss/srv_spoolss_nt.h
new file mode 100644
index 00000000000..d6d141a5e8f
--- /dev/null
+++ b/source3/rpc_server/spoolss/srv_spoolss_nt.h
@@ -0,0 +1,40 @@
+/*
+ * Unix SMB/CIFS implementation.
+ * RPC Pipe client / server routines
+ * Copyright (C) Andrew Tridgell 1992-2000,
+ * Copyright (C) Luke Kenneth Casson Leighton 1996-2000,
+ * Copyright (C) Jean François Micouleau 1998-2000,
+ * Copyright (C) Jeremy Allison 2001-2002,
+ * Copyright (C) Gerald Carter 2000-2004,
+ * Copyright (C) Tim Potter 2001-2002.
+ * Copyright (C) Guenther Deschner 2009-2010.
+ * Copyright (C) Andreas Schneider 2010.
+ *
+ * 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/>.
+ */
+
+#ifndef _RPC_SERVER_SPOOLSS_SRV_SPOOLSS_NT_H_
+#define _RPC_SERVER_SPOOLSS_SRV_SPOOLSS_NT_H_
+
+/* The following definitions come from rpc_server/srv_spoolss_nt.c */
+void srv_spoolss_cleanup(void);
+
+void do_drv_upgrade_printer(struct messaging_context *msg,
+ void *private_data,
+ uint32_t msg_type,
+ struct server_id server_id,
+ DATA_BLOB *data);
+void update_monitored_printq_cache(struct messaging_context *msg_ctx);
+
+#endif /* _RPC_SERVER_SPOOLSS_SRV_SPOOLSS_NT_H_ */
diff --git a/source3/rpc_server/spoolss/srv_spoolss_util.c b/source3/rpc_server/spoolss/srv_spoolss_util.c
index 9e9e253dd71..5201571a372 100644
--- a/source3/rpc_server/spoolss/srv_spoolss_util.c
+++ b/source3/rpc_server/spoolss/srv_spoolss_util.c
@@ -23,7 +23,6 @@
#include "nt_printing.h"
#include "srv_spoolss_util.h"
#include "../librpc/gen_ndr/ndr_spoolss.h"
-#include "../librpc/gen_ndr/srv_winreg.h"
#include "../librpc/gen_ndr/ndr_winreg_c.h"
#include "../librpc/gen_ndr/ndr_security.h"
#include "secrets.h"
@@ -450,7 +449,7 @@ static WERROR winreg_printer_enumvalues(TALLOC_CTX *mem_ctx,
return WERR_OK;
}
- enum_values = TALLOC_ARRAY(tmp_ctx, struct spoolss_PrinterEnumValues, num_values);
+ enum_values = talloc_array(tmp_ctx, struct spoolss_PrinterEnumValues, num_values);
if (enum_values == NULL) {
result = WERR_NOMEM;
goto error;
@@ -472,7 +471,7 @@ static WERROR winreg_printer_enumvalues(TALLOC_CTX *mem_ctx,
data_size = max_valbufsize;
data = NULL;
if (data_size) {
- data = (uint8_t *) TALLOC(tmp_ctx, data_size);
+ data = (uint8_t *) talloc_zero_size(tmp_ctx, data_size);
}
length = 0;
@@ -1048,7 +1047,7 @@ WERROR winreg_create_printer(TALLOC_CTX *mem_ctx,
winreg_handle,
&key_hnd,
SPOOL_REG_SHORTSERVERNAME,
- global_myname(),
+ lp_netbios_name(),
&result);
if (!NT_STATUS_IS_OK(status)) {
result = ntstatus_to_werror(status);
@@ -1063,9 +1062,9 @@ WERROR winreg_create_printer(TALLOC_CTX *mem_ctx,
*/
dnssuffix = get_mydnsdomname(tmp_ctx);
if (dnssuffix != NULL && dnssuffix[0] != '\0') {
- longname = talloc_asprintf(tmp_ctx, "%s.%s", global_myname(), dnssuffix);
+ longname = talloc_asprintf(tmp_ctx, "%s.%s", lp_netbios_name(), dnssuffix);
} else {
- longname = talloc_strdup(tmp_ctx, global_myname());
+ longname = talloc_strdup(tmp_ctx, lp_netbios_name());
}
if (longname == NULL) {
result = WERR_NOMEM;
@@ -2316,9 +2315,9 @@ WERROR winreg_get_printer_dataex(TALLOC_CTX *mem_ctx,
struct dcerpc_binding_handle *winreg_handle = NULL;
struct policy_handle hive_hnd, key_hnd;
struct winreg_String wvalue;
- enum winreg_Type type_in;
+ enum winreg_Type type_in = REG_NONE;
char *path;
- uint8_t *data_in;
+ uint8_t *data_in = NULL;
uint32_t data_in_size = 0;
uint32_t value_len = 0;
WERROR result = WERR_OK;
@@ -3085,7 +3084,7 @@ WERROR winreg_printer_enumforms1(TALLOC_CTX *mem_ctx,
goto done;
}
- info = TALLOC_ARRAY(tmp_ctx, union spoolss_FormInfo, num_builtin + num_values);
+ info = talloc_array(tmp_ctx, union spoolss_FormInfo, num_builtin + num_values);
if (info == NULL) {
result = WERR_NOMEM;
goto done;
@@ -3338,8 +3337,8 @@ WERROR winreg_printer_getform1(TALLOC_CTX *mem_ctx,
struct dcerpc_binding_handle *winreg_handle = NULL;
struct policy_handle hive_hnd, key_hnd;
struct winreg_String wvalue;
- enum winreg_Type type_in;
- uint8_t *data_in;
+ enum winreg_Type type_in = REG_NONE;
+ uint8_t *data_in = NULL;
uint32_t data_in_size = 0;
uint32_t value_len = 0;
uint32_t num_builtin = ARRAY_SIZE(builtin_forms1);
diff --git a/source3/rpc_server/srv_access_check.h b/source3/rpc_server/srv_access_check.h
index 27a09bd0074..72ce539568e 100644
--- a/source3/rpc_server/srv_access_check.h
+++ b/source3/rpc_server/srv_access_check.h
@@ -1,3 +1,35 @@
+/*
+ * Unix SMB/CIFS implementation.
+ * RPC Pipe client / server routines
+ * Copyright (C) Andrew Tridgell 1992-1997,
+ * Copyright (C) Luke Kenneth Casson Leighton 1996-1997,
+ * Copyright (C) Paul Ashton 1997,
+ * Copyright (C) Marc Jacobsen 1999,
+ * Copyright (C) Jeremy Allison 2001-2008,
+ * Copyright (C) Jean François Micouleau 1998-2001,
+ * Copyright (C) Jim McDonough <jmcd@us.ibm.com> 2002,
+ * Copyright (C) Gerald (Jerry) Carter 2003-2004,
+ * Copyright (C) Simo Sorce 2003.
+ * Copyright (C) Volker Lendecke 2005.
+ * Copyright (C) Guenther Deschner 2008.
+ *
+ * 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/>.
+ */
+
+#ifndef _RPC_SERVER_SRV_ACCESS_CHECK_H_
+#define _RPC_SERVER_SRV_ACCESS_CHECK_H_
+
/* The following definitions come from rpc_server/srv_access_check.c */
NTSTATUS access_check_object( struct security_descriptor *psd, struct security_token *token,
@@ -8,3 +40,5 @@ NTSTATUS access_check_object( struct security_descriptor *psd, struct security_t
void map_max_allowed_access(const struct security_token *nt_token,
const struct security_unix_token *unix_token,
uint32_t *pacc_requested);
+
+#endif /* _RPC_SERVER_SRV_ACCESS_CHECK_H_ */
diff --git a/source3/rpc_server/srv_pipe.c b/source3/rpc_server/srv_pipe.c
index 27a7aaeaf47..fc08d56b1e9 100644
--- a/source3/rpc_server/srv_pipe.c
+++ b/source3/rpc_server/srv_pipe.c
@@ -41,6 +41,8 @@
#include "smbd/smbd.h"
#include "auth.h"
#include "ntdomain.h"
+#include "rpc_server/srv_pipe.h"
+#include "rpc_server/rpc_contexts.h"
#undef DBGC_CLASS
#define DBGC_CLASS DBGC_RPC_SRV
@@ -330,23 +332,30 @@ bool setup_fault_pdu(struct pipes_struct *p, NTSTATUS fault_status)
static bool check_bind_req(struct pipes_struct *p,
struct ndr_syntax_id* abstract,
struct ndr_syntax_id* transfer,
- uint32 context_id)
+ uint32_t context_id)
{
struct pipe_rpc_fns *context_fns;
+ bool ok;
DEBUG(3,("check_bind_req for %s\n",
- get_pipe_name_from_syntax(talloc_tos(), &p->syntax)));
+ get_pipe_name_from_syntax(talloc_tos(), abstract)));
/* we have to check all now since win2k introduced a new UUID on the lsaprpc pipe */
if (rpc_srv_pipe_exists_by_id(abstract) &&
ndr_syntax_id_equal(transfer, &ndr_transfer_syntax)) {
- DEBUG(3, ("check_bind_req: \\PIPE\\%s -> \\PIPE\\%s\n",
- rpc_srv_get_pipe_cli_name(abstract),
- rpc_srv_get_pipe_srv_name(abstract)));
+ DEBUG(3, ("check_bind_req: %s -> %s rpc service\n",
+ rpc_srv_get_pipe_cli_name(abstract),
+ rpc_srv_get_pipe_srv_name(abstract)));
} else {
return false;
}
+ ok = init_pipe_handles(p, abstract);
+ if (!ok) {
+ DEBUG(1, ("Failed to init pipe handles!\n"));
+ return false;
+ }
+
context_fns = SMB_MALLOC_P(struct pipe_rpc_fns);
if (context_fns == NULL) {
DEBUG(0,("check_bind_req: malloc() failed!\n"));
@@ -357,6 +366,7 @@ static bool check_bind_req(struct pipes_struct *p,
context_fns->n_cmds = rpc_srv_get_pipe_num_cmds(abstract);
context_fns->cmds = rpc_srv_get_pipe_cmds(abstract);
context_fns->context_id = context_id;
+ context_fns->syntax = *abstract;
/* add to the list of open contexts */
@@ -615,14 +625,12 @@ static bool pipe_ntlmssp_verify_final(TALLOC_CTX *mem_ctx,
struct auth_ntlmssp_state *ntlmssp_ctx,
enum dcerpc_AuthLevel auth_level,
struct client_address *client_id,
- struct ndr_syntax_id *syntax,
struct auth_serversupplied_info **session_info)
{
NTSTATUS status;
bool ret;
- DEBUG(5, (__location__ ": pipe %s checking user details\n",
- get_pipe_name_from_syntax(talloc_tos(), syntax)));
+ DEBUG(5, (__location__ ": checking user details\n"));
/* Finally - if the pipe negotiated integrity (sign) or privacy (seal)
ensure the underlying NTLMSSP flags are also set. If not we should
@@ -635,8 +643,7 @@ static bool pipe_ntlmssp_verify_final(TALLOC_CTX *mem_ctx,
DCERPC_AUTH_LEVEL_PRIVACY));
if (!NT_STATUS_IS_OK(status)) {
DEBUG(0, (__location__ ": Client failed to negotatie proper "
- "security for pipe %s\n",
- get_pipe_name_from_syntax(talloc_tos(), syntax)));
+ "security for rpc connection\n"));
return false;
}
@@ -767,7 +774,7 @@ static NTSTATUS pipe_auth_verify_final(struct pipes_struct *p)
struct auth_ntlmssp_state);
if (!pipe_ntlmssp_verify_final(p, ntlmssp_ctx,
p->auth.auth_level,
- p->client_id, &p->syntax,
+ p->client_id,
&p->session_info)) {
return NT_STATUS_ACCESS_DENIED;
}
@@ -813,7 +820,6 @@ static NTSTATUS pipe_auth_verify_final(struct pipes_struct *p)
if (!pipe_ntlmssp_verify_final(p, ntlmssp_ctx,
p->auth.auth_level,
p->client_id,
- &p->syntax,
&p->session_info)) {
return NT_STATUS_ACCESS_DENIED;
}
@@ -854,9 +860,7 @@ static bool api_pipe_bind_req(struct pipes_struct *p,
/* No rebinds on a bound pipe - use alter context. */
if (p->pipe_bound) {
- DEBUG(2,("api_pipe_bind_req: rejecting bind request on bound "
- "pipe %s.\n",
- get_pipe_name_from_syntax(talloc_tos(), &p->syntax)));
+ DEBUG(2,("Rejecting bind request on bound rpc connection\n"));
return setup_bind_nak(p, pkt);
}
@@ -871,38 +875,35 @@ static bool api_pipe_bind_req(struct pipes_struct *p,
*/
id = pkt->u.bind.ctx_list[0].abstract_syntax;
if (rpc_srv_pipe_exists_by_id(&id)) {
- DEBUG(3, ("api_pipe_bind_req: \\PIPE\\%s -> \\PIPE\\%s\n",
- rpc_srv_get_pipe_cli_name(&id),
- rpc_srv_get_pipe_srv_name(&id)));
+ DEBUG(3, ("api_pipe_bind_req: %s -> %s rpc service\n",
+ rpc_srv_get_pipe_cli_name(&id),
+ rpc_srv_get_pipe_srv_name(&id)));
} else {
status = smb_probe_module(
"rpc", get_pipe_name_from_syntax(
talloc_tos(),
- &pkt->u.bind.ctx_list[0].abstract_syntax));
+ &id));
if (NT_STATUS_IS_ERR(status)) {
- DEBUG(3,("api_pipe_bind_req: Unknown pipe name %s in bind request.\n",
- get_pipe_name_from_syntax(
- talloc_tos(),
- &pkt->u.bind.ctx_list[0].abstract_syntax)));
+ DEBUG(3,("api_pipe_bind_req: Unknown rpc service name "
+ "%s in bind request.\n",
+ get_pipe_name_from_syntax(talloc_tos(), &id)));
return setup_bind_nak(p, pkt);
}
if (rpc_srv_get_pipe_interface_by_cli_name(
get_pipe_name_from_syntax(talloc_tos(),
- &p->syntax),
+ &id),
&id)) {
- DEBUG(3, ("api_pipe_bind_req: \\PIPE\\%s -> \\PIPE\\%s\n",
- rpc_srv_get_pipe_cli_name(&id),
- rpc_srv_get_pipe_srv_name(&id)));
+ DEBUG(3, ("api_pipe_bind_req: %s -> %s rpc service\n",
+ rpc_srv_get_pipe_cli_name(&id),
+ rpc_srv_get_pipe_srv_name(&id)));
} else {
DEBUG(0, ("module %s doesn't provide functions for "
"pipe %s!\n",
- get_pipe_name_from_syntax(talloc_tos(),
- &p->syntax),
- get_pipe_name_from_syntax(talloc_tos(),
- &p->syntax)));
+ get_pipe_name_from_syntax(talloc_tos(), &id),
+ get_pipe_name_from_syntax(talloc_tos(), &id)));
return setup_bind_nak(p, pkt);
}
}
@@ -1507,28 +1508,9 @@ static bool api_pipe_alter_context(struct pipes_struct *p,
return setup_bind_nak(p, pkt);
}
-/****************************************************************************
- Find the set of RPC functions associated with this context_id
-****************************************************************************/
-
-static PIPE_RPC_FNS* find_pipe_fns_by_context( PIPE_RPC_FNS *list, uint32 context_id )
-{
- PIPE_RPC_FNS *fns = NULL;
-
- if ( !list ) {
- DEBUG(0,("find_pipe_fns_by_context: ERROR! No context list for pipe!\n"));
- return NULL;
- }
-
- for (fns=list; fns; fns=fns->next ) {
- if ( fns->context_id == context_id )
- return fns;
- }
- return NULL;
-}
-
static bool api_rpcTNP(struct pipes_struct *p, struct ncacn_packet *pkt,
- const struct api_struct *api_rpc_cmds, int n_cmds);
+ const struct api_struct *api_rpc_cmds, int n_cmds,
+ const struct ndr_syntax_id *syntax);
/****************************************************************************
Find the correct RPC function to call for this request.
@@ -1547,16 +1529,13 @@ static bool api_pipe_request(struct pipes_struct *p,
((p->auth.auth_type == DCERPC_AUTH_TYPE_NTLMSSP) ||
(p->auth.auth_type == DCERPC_AUTH_TYPE_KRB5) ||
(p->auth.auth_type == DCERPC_AUTH_TYPE_SPNEGO))) {
- if(!become_authenticated_pipe_user(p)) {
+ if(!become_authenticated_pipe_user(p->session_info)) {
data_blob_free(&p->out_data.rdata);
return False;
}
changed_user = True;
}
- DEBUG(5, ("Requested \\PIPE\\%s\n",
- get_pipe_name_from_syntax(talloc_tos(), &p->syntax)));
-
/* get the set of RPC functions for this context */
pipe_fns = find_pipe_fns_by_context(p->contexts,
@@ -1564,15 +1543,19 @@ static bool api_pipe_request(struct pipes_struct *p,
if ( pipe_fns ) {
TALLOC_CTX *frame = talloc_stackframe();
- ret = api_rpcTNP(p, pkt, pipe_fns->cmds, pipe_fns->n_cmds);
+
+ DEBUG(5, ("Requested %s rpc service\n",
+ get_pipe_name_from_syntax(talloc_tos(), &pipe_fns->syntax)));
+
+ ret = api_rpcTNP(p, pkt, pipe_fns->cmds, pipe_fns->n_cmds,
+ &pipe_fns->syntax);
+
TALLOC_FREE(frame);
}
else {
DEBUG(0, ("No rpc function table associated with context "
- "[%d] on pipe [%s]\n",
- pkt->u.request.context_id,
- get_pipe_name_from_syntax(talloc_tos(),
- &p->syntax)));
+ "[%d]\n",
+ pkt->u.request.context_id));
}
if (changed_user) {
@@ -1587,20 +1570,21 @@ static bool api_pipe_request(struct pipes_struct *p,
********************************************************************/
static bool api_rpcTNP(struct pipes_struct *p, struct ncacn_packet *pkt,
- const struct api_struct *api_rpc_cmds, int n_cmds)
+ const struct api_struct *api_rpc_cmds, int n_cmds,
+ const struct ndr_syntax_id *syntax)
{
int fn_num;
uint32_t offset1;
/* interpret the command */
DEBUG(4,("api_rpcTNP: %s op 0x%x - ",
- get_pipe_name_from_syntax(talloc_tos(), &p->syntax),
+ get_pipe_name_from_syntax(talloc_tos(), syntax),
pkt->u.request.opnum));
if (DEBUGLEVEL >= 50) {
fstring name;
slprintf(name, sizeof(name)-1, "in_%s",
- get_pipe_name_from_syntax(talloc_tos(), &p->syntax));
+ get_pipe_name_from_syntax(talloc_tos(), syntax));
dump_pdu_region(name, pkt->u.request.opnum,
&p->in_data.data, 0,
p->in_data.data.length);
@@ -1633,7 +1617,7 @@ static bool api_rpcTNP(struct pipes_struct *p, struct ncacn_packet *pkt,
/* do the actual command */
if(!api_rpc_cmds[fn_num].fn(p)) {
DEBUG(0,("api_rpcTNP: %s: %s failed.\n",
- get_pipe_name_from_syntax(talloc_tos(), &p->syntax),
+ get_pipe_name_from_syntax(talloc_tos(), syntax),
api_rpc_cmds[fn_num].name));
data_blob_free(&p->out_data.rdata);
return False;
@@ -1656,14 +1640,14 @@ static bool api_rpcTNP(struct pipes_struct *p, struct ncacn_packet *pkt,
if (DEBUGLEVEL >= 50) {
fstring name;
slprintf(name, sizeof(name)-1, "out_%s",
- get_pipe_name_from_syntax(talloc_tos(), &p->syntax));
+ get_pipe_name_from_syntax(talloc_tos(), syntax));
dump_pdu_region(name, pkt->u.request.opnum,
&p->out_data.rdata, offset1,
p->out_data.rdata.length);
}
DEBUG(5,("api_rpcTNP: called %s successfully\n",
- get_pipe_name_from_syntax(talloc_tos(), &p->syntax)));
+ get_pipe_name_from_syntax(talloc_tos(), syntax)));
/* Check for buffer underflow in rpc parsing */
if ((DEBUGLEVEL >= 10) &&
@@ -1706,8 +1690,8 @@ void set_incoming_fault(struct pipes_struct *p)
p->in_data.pdu_needed_len = 0;
p->in_data.pdu.length = 0;
p->fault_state = True;
- DEBUG(10, ("set_incoming_fault: Setting fault state on pipe %s\n",
- get_pipe_name_from_syntax(talloc_tos(), &p->syntax)));
+
+ DEBUG(10, ("Setting fault state\n"));
}
static NTSTATUS dcesrv_auth_request(struct pipe_auth_data *auth,
@@ -1841,8 +1825,7 @@ void process_complete_pdu(struct pipes_struct *p)
bool reply = False;
if(p->fault_state) {
- DEBUG(10,("process_complete_pdu: pipe %s in fault state.\n",
- get_pipe_name_from_syntax(talloc_tos(), &p->syntax)));
+ DEBUG(10,("RPC connection in fault state.\n"));
goto done;
}
@@ -1874,7 +1857,7 @@ void process_complete_pdu(struct pipes_struct *p)
/* Store the call_id */
p->call_id = pkt->call_id;
- DEBUG(10, ("Processing packet type %d\n", (int)pkt->ptype));
+ DEBUG(10, ("Processing packet type %u\n", (unsigned int)pkt->ptype));
switch (pkt->ptype) {
case DCERPC_PKT_REQUEST:
@@ -1882,19 +1865,12 @@ void process_complete_pdu(struct pipes_struct *p)
break;
case DCERPC_PKT_PING: /* CL request - ignore... */
- DEBUG(0, ("process_complete_pdu: Error. "
- "Connectionless packet type %d received on "
- "pipe %s.\n", (int)pkt->ptype,
- get_pipe_name_from_syntax(talloc_tos(),
- &p->syntax)));
+ DEBUG(0, ("Error - Connectionless packet type %u received\n",
+ (unsigned int)pkt->ptype));
break;
case DCERPC_PKT_RESPONSE: /* No responses here. */
- DEBUG(0, ("process_complete_pdu: Error. "
- "DCERPC_PKT_RESPONSE received from client "
- "on pipe %s.\n",
- get_pipe_name_from_syntax(talloc_tos(),
- &p->syntax)));
+ DEBUG(0, ("Error - DCERPC_PKT_RESPONSE received from client"));
break;
case DCERPC_PKT_FAULT:
@@ -1907,11 +1883,8 @@ void process_complete_pdu(struct pipes_struct *p)
case DCERPC_PKT_CL_CANCEL:
case DCERPC_PKT_FACK:
case DCERPC_PKT_CANCEL_ACK:
- DEBUG(0, ("process_complete_pdu: Error. "
- "Connectionless packet type %u received on "
- "pipe %s.\n", (unsigned int)pkt->ptype,
- get_pipe_name_from_syntax(talloc_tos(),
- &p->syntax)));
+ DEBUG(0, ("Error - Connectionless packet type %u received\n",
+ (unsigned int)pkt->ptype));
break;
case DCERPC_PKT_BIND:
@@ -1925,12 +1898,9 @@ void process_complete_pdu(struct pipes_struct *p)
case DCERPC_PKT_BIND_ACK:
case DCERPC_PKT_BIND_NAK:
- DEBUG(0, ("process_complete_pdu: Error. "
- "DCERPC_PKT_BINDACK/DCERPC_PKT_BINDNACK "
- "packet type %u received on pipe %s.\n",
- (unsigned int)pkt->ptype,
- get_pipe_name_from_syntax(talloc_tos(),
- &p->syntax)));
+ DEBUG(0, ("Error - DCERPC_PKT_BINDACK/DCERPC_PKT_BINDNACK "
+ "packet type %u received.\n",
+ (unsigned int)pkt->ptype));
break;
@@ -1944,11 +1914,8 @@ void process_complete_pdu(struct pipes_struct *p)
break;
case DCERPC_PKT_ALTER_RESP:
- DEBUG(0, ("process_complete_pdu: Error. "
- "DCERPC_PKT_ALTER_RESP on pipe %s: "
- "Should only be server -> client.\n",
- get_pipe_name_from_syntax(talloc_tos(),
- &p->syntax)));
+ DEBUG(0, ("Error - DCERPC_PKT_ALTER_RESP received: "
+ "Should only be server -> client.\n"));
break;
case DCERPC_PKT_AUTH3:
@@ -1961,11 +1928,8 @@ void process_complete_pdu(struct pipes_struct *p)
break;
case DCERPC_PKT_SHUTDOWN:
- DEBUG(0, ("process_complete_pdu: Error. "
- "DCERPC_PKT_SHUTDOWN on pipe %s: "
- "Should only be server -> client.\n",
- get_pipe_name_from_syntax(talloc_tos(),
- &p->syntax)));
+ DEBUG(0, ("Error - DCERPC_PKT_SHUTDOWN received: "
+ "Should only be server -> client.\n"));
break;
case DCERPC_PKT_CO_CANCEL:
@@ -2010,9 +1974,7 @@ void process_complete_pdu(struct pipes_struct *p)
done:
if (!reply) {
- DEBUG(3,("process_complete_pdu: DCE/RPC fault sent on "
- "pipe %s\n", get_pipe_name_from_syntax(talloc_tos(),
- &p->syntax)));
+ DEBUG(3,("DCE/RPC fault sent!"));
set_incoming_fault(p);
setup_fault_pdu(p, NT_STATUS(DCERPC_FAULT_OP_RNG_ERROR));
TALLOC_FREE(pkt);
diff --git a/source3/rpc_server/srv_pipe.h b/source3/rpc_server/srv_pipe.h
new file mode 100644
index 00000000000..453cca18d91
--- /dev/null
+++ b/source3/rpc_server/srv_pipe.h
@@ -0,0 +1,33 @@
+/*
+ * Unix SMB/CIFS implementation.
+ * RPC Pipe client / server routines
+ * Almost completely rewritten by (C) Jeremy Allison 2005 - 2010
+ *
+ * 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/>.
+ */
+
+#ifndef _RPC_SERVER_SRV_PIPE_H_
+#define _RPC_SERVER_SRV_PIPE_H_
+
+struct ncacn_packet;
+struct pipes_struct;
+
+/* The following definitions come from rpc_server/srv_pipe.c */
+
+bool create_next_pdu(struct pipes_struct *p);
+bool api_pipe_bind_auth3(struct pipes_struct *p, struct ncacn_packet *pkt);
+bool setup_fault_pdu(struct pipes_struct *p, NTSTATUS status);
+bool is_known_pipename(const char *cli_filename, struct ndr_syntax_id *syntax);
+
+#endif /* _RPC_SERVER_SRV_PIPE_H_ */
diff --git a/source3/rpc_server/srv_pipe_hnd.c b/source3/rpc_server/srv_pipe_hnd.c
index 52525987269..501bb1efc77 100644
--- a/source3/rpc_server/srv_pipe_hnd.c
+++ b/source3/rpc_server/srv_pipe_hnd.c
@@ -20,15 +20,15 @@
*/
#include "includes.h"
-#include "../librpc/gen_ndr/srv_spoolss.h"
-#include "librpc/gen_ndr/ndr_named_pipe_auth.h"
-#include "../libcli/named_pipe_auth/npa_tstream.h"
#include "rpc_server.h"
-#include "smbd/globals.h"
#include "fake_file.h"
#include "rpc_dce.h"
-#include "rpc_server/rpc_ncacn_np.h"
#include "ntdomain.h"
+#include "rpc_server/rpc_ncacn_np.h"
+#include "rpc_server/srv_pipe_hnd.h"
+#include "rpc_server/srv_pipe.h"
+#include "../lib/tsocket/tsocket.h"
+#include "../lib/util/tevent_ntstatus.h"
#undef DBGC_CLASS
#define DBGC_CLASS DBGC_RPC_SRV
@@ -37,7 +37,7 @@
Ensures we have at least RPC_HEADER_LEN amount of data in the incoming buffer.
****************************************************************************/
-static ssize_t fill_rpc_header(struct pipes_struct *p, char *data, size_t data_to_copy)
+static ssize_t fill_rpc_header(struct pipes_struct *p, const char *data, size_t data_to_copy)
{
size_t len_needed_to_complete_hdr =
MIN(data_to_copy, RPC_HEADER_LEN - p->in_data.pdu.length);
@@ -126,7 +126,7 @@ static void free_pipe_context(struct pipes_struct *p)
Accepts incoming data on an rpc pipe. Processes the data in pdu sized units.
****************************************************************************/
-ssize_t process_incoming_data(struct pipes_struct *p, char *data, size_t n)
+ssize_t process_incoming_data(struct pipes_struct *p, const char *data, size_t n)
{
size_t data_to_copy = MIN(n, RPC_MAX_PDU_FRAG_LEN
- p->in_data.pdu.length);
@@ -231,7 +231,7 @@ ssize_t process_incoming_data(struct pipes_struct *p, char *data, size_t n)
Accepts incoming data on an internal rpc pipe.
****************************************************************************/
-static ssize_t write_to_internal_pipe(struct pipes_struct *p, char *data, size_t n)
+static ssize_t write_to_internal_pipe(struct pipes_struct *p, const char *data, size_t n)
{
size_t data_left = n;
@@ -280,7 +280,7 @@ static ssize_t read_from_internal_pipe(struct pipes_struct *p, char *data,
}
DEBUG(6,(" name: %s len: %u\n",
- get_pipe_name_from_syntax(talloc_tos(), &p->syntax),
+ get_pipe_name_from_syntax(talloc_tos(), &p->contexts->syntax),
(unsigned int)n));
/*
@@ -298,7 +298,7 @@ static ssize_t read_from_internal_pipe(struct pipes_struct *p, char *data,
DEBUG(5,("read_from_pipe: too large read (%u) requested on "
"pipe %s. We can only service %d sized reads.\n",
(unsigned int)n,
- get_pipe_name_from_syntax(talloc_tos(), &p->syntax),
+ get_pipe_name_from_syntax(talloc_tos(), &p->contexts->syntax),
RPC_MAX_PDU_FRAG_LEN ));
n = RPC_MAX_PDU_FRAG_LEN;
}
@@ -319,7 +319,7 @@ static ssize_t read_from_internal_pipe(struct pipes_struct *p, char *data,
DEBUG(10,("read_from_pipe: %s: current_pdu_len = %u, "
"current_pdu_sent = %u returning %d bytes.\n",
- get_pipe_name_from_syntax(talloc_tos(), &p->syntax),
+ get_pipe_name_from_syntax(talloc_tos(), &p->contexts->syntax),
(unsigned int)p->out_data.frag.length,
(unsigned int)p->out_data.current_pdu_sent,
(int)data_returned));
@@ -340,7 +340,7 @@ static ssize_t read_from_internal_pipe(struct pipes_struct *p, char *data,
DEBUG(10,("read_from_pipe: %s: fault_state = %d : data_sent_length "
"= %u, p->out_data.rdata.length = %u.\n",
- get_pipe_name_from_syntax(talloc_tos(), &p->syntax),
+ get_pipe_name_from_syntax(talloc_tos(), &p->contexts->syntax),
(int)p->fault_state,
(unsigned int)p->out_data.data_sent_length,
(unsigned int)p->out_data.rdata.length));
@@ -362,7 +362,7 @@ static ssize_t read_from_internal_pipe(struct pipes_struct *p, char *data,
if(!create_next_pdu(p)) {
DEBUG(0,("read_from_pipe: %s: create_next_pdu failed.\n",
- get_pipe_name_from_syntax(talloc_tos(), &p->syntax)));
+ get_pipe_name_from_syntax(talloc_tos(), &p->contexts->syntax)));
return -1;
}
@@ -433,7 +433,7 @@ NTSTATUS np_open(TALLOC_CTX *mem_ctx, const char *name,
rpcsrv_type = lp_parm_const_string(GLOBAL_SECTION_SNUM,
"rpc_server", name,
"embedded");
- if (StrCaseCmp(rpcsrv_type, "embedded") != 0) {
+ if (strcasecmp_m(rpcsrv_type, "embedded") != 0) {
external = true;
}
@@ -535,7 +535,7 @@ struct tevent_req *np_write_send(TALLOC_CTX *mem_ctx, struct event_context *ev,
struct pipes_struct *p = talloc_get_type_abort(
handle->private_data, struct pipes_struct);
- state->nwritten = write_to_internal_pipe(p, (char *)data, len);
+ state->nwritten = write_to_internal_pipe(p, (const char *)data, len);
status = (state->nwritten >= 0)
? NT_STATUS_OK : NT_STATUS_UNEXPECTED_IO_ERROR;
@@ -549,7 +549,7 @@ struct tevent_req *np_write_send(TALLOC_CTX *mem_ctx, struct event_context *ev,
state->ev = ev;
state->p = p;
- state->iov.iov_base = CONST_DISCARD(void *, data);
+ state->iov.iov_base = discard_const_p(void, data);
state->iov.iov_len = len;
subreq = tstream_writev_queue_send(state, ev,
diff --git a/source3/rpc_server/srv_pipe_hnd.h b/source3/rpc_server/srv_pipe_hnd.h
new file mode 100644
index 00000000000..680add469b0
--- /dev/null
+++ b/source3/rpc_server/srv_pipe_hnd.h
@@ -0,0 +1,51 @@
+/*
+ * Unix SMB/CIFS implementation.
+ * RPC Pipe client / server routines
+ * Copyright (C) Andrew Tridgell 1992-1998,
+ * Largely re-written : 2005
+ * Copyright (C) Jeremy Allison 1998 - 2005
+ *
+ * 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/>.
+ */
+
+#ifndef _RPC_SERVER_SRV_PIPE_HND_H_
+#define _RPC_SERVER_SRV_PIPE_HND_H_
+
+struct tsocket_address;
+struct pipes_struct;
+
+/* The following definitions come from rpc_server/srv_pipe_hnd.c */
+
+bool fsp_is_np(struct files_struct *fsp);
+NTSTATUS np_open(TALLOC_CTX *mem_ctx, const char *name,
+ const struct tsocket_address *local_address,
+ const struct tsocket_address *remote_address,
+ struct client_address *client_id,
+ struct auth_serversupplied_info *session_info,
+ struct messaging_context *msg_ctx,
+ struct fake_file_handle **phandle);
+bool np_read_in_progress(struct fake_file_handle *handle);
+struct tevent_req *np_write_send(TALLOC_CTX *mem_ctx, struct event_context *ev,
+ struct fake_file_handle *handle,
+ const uint8_t *data, size_t len);
+NTSTATUS np_write_recv(struct tevent_req *req, ssize_t *pnwritten);
+struct tevent_req *np_read_send(TALLOC_CTX *mem_ctx, struct event_context *ev,
+ struct fake_file_handle *handle,
+ uint8_t *data, size_t len);
+NTSTATUS np_read_recv(struct tevent_req *req, ssize_t *nread,
+ bool *is_data_outstanding);
+
+ssize_t process_incoming_data(struct pipes_struct *p, const char *data, size_t n);
+
+#endif /* _RPC_SERVER_SRV_PIPE_HND_H_ */
diff --git a/source3/rpc_server/srv_pipe_register.c b/source3/rpc_server/srv_pipe_register.c
index a6d654277ed..c3500c97be6 100644
--- a/source3/rpc_server/srv_pipe_register.c
+++ b/source3/rpc_server/srv_pipe_register.c
@@ -20,6 +20,7 @@
#include "includes.h"
#include "librpc/rpc/dcerpc.h"
#include "srv_pipe_internal.h"
+#include "rpc_server/srv_pipe_register.h"
#undef DBGC_CLASS
#define DBGC_CLASS DBGC_RPC_SRV
@@ -197,7 +198,7 @@ NTSTATUS rpc_srv_register(int version, const char *clnt, const char *srv,
rpc_entry = SMB_REALLOC_ARRAY_KEEP_OLD_ON_ERROR(rpc_lookup, struct rpc_table, rpc_lookup_size);
if (NULL == rpc_entry) {
rpc_lookup_size--;
- DEBUG(0, ("rpc_pipe_register_commands: memory allocation failed\n"));
+ DEBUG(0, ("rpc_srv_register: memory allocation failed\n"));
return NT_STATUS_NO_MEMORY;
} else {
rpc_lookup = rpc_entry;
diff --git a/source3/rpc_server/srv_pipe_register.h b/source3/rpc_server/srv_pipe_register.h
new file mode 100644
index 00000000000..b1b454e0bd5
--- /dev/null
+++ b/source3/rpc_server/srv_pipe_register.h
@@ -0,0 +1,39 @@
+/*
+ * Unix SMB/CIFS implementation.
+ * RPC Pipe client / server routines
+ * Almost completely rewritten by (C) Jeremy Allison 2005 - 2010
+ *
+ * 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/>.
+ */
+
+#ifndef _RPC_SERVER_SRV_PIPE_REGISTER_H_
+#define _RPC_SERVER_SRV_PIPE_REGISTER_H_
+
+struct rpc_srv_callbacks {
+ bool (*init)(void *private_data);
+ bool (*shutdown)(void *private_data);
+ void *private_data;
+};
+
+/* The following definitions come from rpc_server/srv_rpc_register.c */
+
+NTSTATUS rpc_srv_register(int version, const char *clnt,
+ const char *srv,
+ const struct ndr_interface_table *iface,
+ const struct api_struct *cmds, int size,
+ const struct rpc_srv_callbacks *rpc_srv_cb);
+
+NTSTATUS rpc_srv_unregister(const struct ndr_interface_table *iface);
+
+#endif /* _RPC_SERVER_SRV_PIPE_REGISTER_H_ */
diff --git a/source3/rpc_server/srvsvc/srv_srvsvc_nt.c b/source3/rpc_server/srvsvc/srv_srvsvc_nt.c
index e51fee89c61..752b8576676 100644
--- a/source3/rpc_server/srvsvc/srv_srvsvc_nt.c
+++ b/source3/rpc_server/srvsvc/srv_srvsvc_nt.c
@@ -25,6 +25,7 @@
#include "includes.h"
#include "system/passwd.h"
+#include "ntdomain.h"
#include "../librpc/gen_ndr/srv_srvsvc.h"
#include "../libcli/security/security.h"
#include "../librpc/gen_ndr/ndr_security.h"
@@ -32,9 +33,9 @@
#include "session.h"
#include "../lib/util/util_pw.h"
#include "smbd/smbd.h"
+#include "smbd/globals.h"
#include "auth.h"
#include "messages.h"
-#include "ntdomain.h"
extern const struct generic_mapping file_generic_mapping;
@@ -100,7 +101,7 @@ static int pipe_enum_fn( struct db_record *rec, void *p)
return 1;
}
- f = TALLOC_REALLOC_ARRAY(fenum->ctx, fenum->ctr3->array,
+ f = talloc_realloc(fenum->ctx, fenum->ctr3->array,
struct srvsvc_NetFileInfo3, i+1);
if ( !f ) {
DEBUG(0,("conn_enum_fn: realloc failed for %d items\n", i+1));
@@ -135,7 +136,7 @@ static WERROR net_enum_pipes(TALLOC_CTX *ctx,
fenum.username = username;
fenum.ctr3 = *ctr3;
- if (connections_traverse(pipe_enum_fn, &fenum) == -1) {
+ if (connections_traverse(pipe_enum_fn, &fenum) < 0) {
DEBUG(0,("net_enum_pipes: traverse of connections.tdb "
"failed\n"));
return WERR_NOMEM;
@@ -178,7 +179,7 @@ static void enum_file_fn( const struct share_mode_entry *e,
return;
}
- f = TALLOC_REALLOC_ARRAY(fenum->ctx, fenum->ctr3->array,
+ f = talloc_realloc(fenum->ctx, fenum->ctr3->array,
struct srvsvc_NetFileInfo3, i+1);
if ( !f ) {
DEBUG(0,("conn_enum_fn: realloc failed for %d items\n", i+1));
@@ -568,12 +569,12 @@ static WERROR init_srv_share_info_ctr(struct pipes_struct *p,
/* Ensure all the usershares are loaded. */
become_root();
- load_usershare_shares();
+ load_usershare_shares(msg_ctx_to_sconn(p->msg_ctx));
load_registry_shares();
num_services = lp_numservices();
unbecome_root();
- allowed = TALLOC_ZERO_ARRAY(ctx, bool, num_services);
+ allowed = talloc_zero_array(ctx, bool, num_services);
W_ERROR_HAVE_NO_MEMORY(allowed);
/* Count the number of entries. */
@@ -599,11 +600,11 @@ static WERROR init_srv_share_info_ctr(struct pipes_struct *p,
alloc_entries = num_entries - resume_handle;
switch (info_ctr->level) {
case 0:
- ctr.ctr0 = TALLOC_ZERO_P(ctx, struct srvsvc_NetShareCtr0);
+ ctr.ctr0 = talloc_zero(ctx, struct srvsvc_NetShareCtr0);
W_ERROR_HAVE_NO_MEMORY(ctr.ctr0);
ctr.ctr0->count = alloc_entries;
- ctr.ctr0->array = TALLOC_ZERO_ARRAY(ctx, struct srvsvc_NetShareInfo0, alloc_entries);
+ ctr.ctr0->array = talloc_zero_array(ctx, struct srvsvc_NetShareInfo0, alloc_entries);
W_ERROR_HAVE_NO_MEMORY(ctr.ctr0->array);
for (snum = 0; snum < num_services; snum++) {
@@ -616,11 +617,11 @@ static WERROR init_srv_share_info_ctr(struct pipes_struct *p,
break;
case 1:
- ctr.ctr1 = TALLOC_ZERO_P(ctx, struct srvsvc_NetShareCtr1);
+ ctr.ctr1 = talloc_zero(ctx, struct srvsvc_NetShareCtr1);
W_ERROR_HAVE_NO_MEMORY(ctr.ctr1);
ctr.ctr1->count = alloc_entries;
- ctr.ctr1->array = TALLOC_ZERO_ARRAY(ctx, struct srvsvc_NetShareInfo1, alloc_entries);
+ ctr.ctr1->array = talloc_zero_array(ctx, struct srvsvc_NetShareInfo1, alloc_entries);
W_ERROR_HAVE_NO_MEMORY(ctr.ctr1->array);
for (snum = 0; snum < num_services; snum++) {
@@ -633,11 +634,11 @@ static WERROR init_srv_share_info_ctr(struct pipes_struct *p,
break;
case 2:
- ctr.ctr2 = TALLOC_ZERO_P(ctx, struct srvsvc_NetShareCtr2);
+ ctr.ctr2 = talloc_zero(ctx, struct srvsvc_NetShareCtr2);
W_ERROR_HAVE_NO_MEMORY(ctr.ctr2);
ctr.ctr2->count = alloc_entries;
- ctr.ctr2->array = TALLOC_ZERO_ARRAY(ctx, struct srvsvc_NetShareInfo2, alloc_entries);
+ ctr.ctr2->array = talloc_zero_array(ctx, struct srvsvc_NetShareInfo2, alloc_entries);
W_ERROR_HAVE_NO_MEMORY(ctr.ctr2->array);
for (snum = 0; snum < num_services; snum++) {
@@ -650,11 +651,11 @@ static WERROR init_srv_share_info_ctr(struct pipes_struct *p,
break;
case 501:
- ctr.ctr501 = TALLOC_ZERO_P(ctx, struct srvsvc_NetShareCtr501);
+ ctr.ctr501 = talloc_zero(ctx, struct srvsvc_NetShareCtr501);
W_ERROR_HAVE_NO_MEMORY(ctr.ctr501);
ctr.ctr501->count = alloc_entries;
- ctr.ctr501->array = TALLOC_ZERO_ARRAY(ctx, struct srvsvc_NetShareInfo501, alloc_entries);
+ ctr.ctr501->array = talloc_zero_array(ctx, struct srvsvc_NetShareInfo501, alloc_entries);
W_ERROR_HAVE_NO_MEMORY(ctr.ctr501->array);
for (snum = 0; snum < num_services; snum++) {
@@ -667,11 +668,11 @@ static WERROR init_srv_share_info_ctr(struct pipes_struct *p,
break;
case 502:
- ctr.ctr502 = TALLOC_ZERO_P(ctx, struct srvsvc_NetShareCtr502);
+ ctr.ctr502 = talloc_zero(ctx, struct srvsvc_NetShareCtr502);
W_ERROR_HAVE_NO_MEMORY(ctr.ctr502);
ctr.ctr502->count = alloc_entries;
- ctr.ctr502->array = TALLOC_ZERO_ARRAY(ctx, struct srvsvc_NetShareInfo502, alloc_entries);
+ ctr.ctr502->array = talloc_zero_array(ctx, struct srvsvc_NetShareInfo502, alloc_entries);
W_ERROR_HAVE_NO_MEMORY(ctr.ctr502->array);
for (snum = 0; snum < num_services; snum++) {
@@ -684,11 +685,11 @@ static WERROR init_srv_share_info_ctr(struct pipes_struct *p,
break;
case 1004:
- ctr.ctr1004 = TALLOC_ZERO_P(ctx, struct srvsvc_NetShareCtr1004);
+ ctr.ctr1004 = talloc_zero(ctx, struct srvsvc_NetShareCtr1004);
W_ERROR_HAVE_NO_MEMORY(ctr.ctr1004);
ctr.ctr1004->count = alloc_entries;
- ctr.ctr1004->array = TALLOC_ZERO_ARRAY(ctx, struct srvsvc_NetShareInfo1004, alloc_entries);
+ ctr.ctr1004->array = talloc_zero_array(ctx, struct srvsvc_NetShareInfo1004, alloc_entries);
W_ERROR_HAVE_NO_MEMORY(ctr.ctr1004->array);
for (snum = 0; snum < num_services; snum++) {
@@ -701,11 +702,11 @@ static WERROR init_srv_share_info_ctr(struct pipes_struct *p,
break;
case 1005:
- ctr.ctr1005 = TALLOC_ZERO_P(ctx, struct srvsvc_NetShareCtr1005);
+ ctr.ctr1005 = talloc_zero(ctx, struct srvsvc_NetShareCtr1005);
W_ERROR_HAVE_NO_MEMORY(ctr.ctr1005);
ctr.ctr1005->count = alloc_entries;
- ctr.ctr1005->array = TALLOC_ZERO_ARRAY(ctx, struct srvsvc_NetShareInfo1005, alloc_entries);
+ ctr.ctr1005->array = talloc_zero_array(ctx, struct srvsvc_NetShareInfo1005, alloc_entries);
W_ERROR_HAVE_NO_MEMORY(ctr.ctr1005->array);
for (snum = 0; snum < num_services; snum++) {
@@ -718,11 +719,11 @@ static WERROR init_srv_share_info_ctr(struct pipes_struct *p,
break;
case 1006:
- ctr.ctr1006 = TALLOC_ZERO_P(ctx, struct srvsvc_NetShareCtr1006);
+ ctr.ctr1006 = talloc_zero(ctx, struct srvsvc_NetShareCtr1006);
W_ERROR_HAVE_NO_MEMORY(ctr.ctr1006);
ctr.ctr1006->count = alloc_entries;
- ctr.ctr1006->array = TALLOC_ZERO_ARRAY(ctx, struct srvsvc_NetShareInfo1006, alloc_entries);
+ ctr.ctr1006->array = talloc_zero_array(ctx, struct srvsvc_NetShareInfo1006, alloc_entries);
W_ERROR_HAVE_NO_MEMORY(ctr.ctr1006->array);
for (snum = 0; snum < num_services; snum++) {
@@ -735,11 +736,11 @@ static WERROR init_srv_share_info_ctr(struct pipes_struct *p,
break;
case 1007:
- ctr.ctr1007 = TALLOC_ZERO_P(ctx, struct srvsvc_NetShareCtr1007);
+ ctr.ctr1007 = talloc_zero(ctx, struct srvsvc_NetShareCtr1007);
W_ERROR_HAVE_NO_MEMORY(ctr.ctr1007);
ctr.ctr1007->count = alloc_entries;
- ctr.ctr1007->array = TALLOC_ZERO_ARRAY(ctx, struct srvsvc_NetShareInfo1007, alloc_entries);
+ ctr.ctr1007->array = talloc_zero_array(ctx, struct srvsvc_NetShareInfo1007, alloc_entries);
W_ERROR_HAVE_NO_MEMORY(ctr.ctr1007->array);
for (snum = 0; snum < num_services; snum++) {
@@ -752,11 +753,11 @@ static WERROR init_srv_share_info_ctr(struct pipes_struct *p,
break;
case 1501:
- ctr.ctr1501 = TALLOC_ZERO_P(ctx, struct srvsvc_NetShareCtr1501);
+ ctr.ctr1501 = talloc_zero(ctx, struct srvsvc_NetShareCtr1501);
W_ERROR_HAVE_NO_MEMORY(ctr.ctr1501);
ctr.ctr1501->count = alloc_entries;
- ctr.ctr1501->array = TALLOC_ZERO_ARRAY(ctx, struct sec_desc_buf, alloc_entries);
+ ctr.ctr1501->array = talloc_zero_array(ctx, struct sec_desc_buf, alloc_entries);
W_ERROR_HAVE_NO_MEMORY(ctr.ctr1501->array);
for (snum = 0; snum < num_services; snum++) {
@@ -815,7 +816,7 @@ static WERROR init_srv_sess_info_0(struct pipes_struct *p,
for (; resume_handle < *total_entries; resume_handle++) {
- ctr0->array = TALLOC_REALLOC_ARRAY(p->mem_ctx,
+ ctr0->array = talloc_realloc(p->mem_ctx,
ctr0->array,
struct srvsvc_NetSessInfo0,
num_entries+1);
@@ -913,7 +914,7 @@ static WERROR init_srv_sess_info_1(struct pipes_struct *p,
num_files = net_count_files(pw->pw_uid, session_list[resume_handle].pid);
guest = strequal( session_list[resume_handle].username, lp_guestaccount() );
- ctr1->array = TALLOC_REALLOC_ARRAY(p->mem_ctx,
+ ctr1->array = talloc_realloc(p->mem_ctx,
ctr1->array,
struct srvsvc_NetSessInfo1,
num_entries+1);
@@ -968,7 +969,7 @@ static WERROR init_srv_conn_info_0(struct srvsvc_NetConnCtr0 *ctr0,
for (; resume_handle < *total_entries; resume_handle++) {
- ctr0->array = TALLOC_REALLOC_ARRAY(talloc_tos(),
+ ctr0->array = talloc_realloc(talloc_tos(),
ctr0->array,
struct srvsvc_NetConnInfo0,
num_entries+1);
@@ -1022,7 +1023,7 @@ static WERROR init_srv_conn_info_1(struct srvsvc_NetConnCtr1 *ctr1,
for (; resume_handle < *total_entries; resume_handle++) {
- ctr1->array = TALLOC_REALLOC_ARRAY(talloc_tos(),
+ ctr1->array = talloc_realloc(talloc_tos(),
ctr1->array,
struct srvsvc_NetConnInfo1,
num_entries+1);
@@ -1138,15 +1139,15 @@ WERROR _srvsvc_NetSrvGetInfo(struct pipes_struct *p,
case 102: {
struct srvsvc_NetSrvInfo102 *info102;
- info102 = TALLOC_P(p->mem_ctx, struct srvsvc_NetSrvInfo102);
+ info102 = talloc(p->mem_ctx, struct srvsvc_NetSrvInfo102);
if (!info102) {
return WERR_NOMEM;
}
info102->platform_id = PLATFORM_ID_NT;
- info102->server_name = global_myname();
- info102->version_major = lp_major_announce_version();
- info102->version_minor = lp_minor_announce_version();
+ info102->server_name = lp_netbios_name();
+ info102->version_major = SAMBA_MAJOR_NBT_ANNOUNCE_VERSION;
+ info102->version_minor = SAMBA_MINOR_NBT_ANNOUNCE_VERSION;
info102->server_type = lp_default_server_announce();
info102->comment = string_truncate(lp_serverstring(),
MAX_SERVER_STRING_LENGTH);
@@ -1164,15 +1165,15 @@ WERROR _srvsvc_NetSrvGetInfo(struct pipes_struct *p,
case 101: {
struct srvsvc_NetSrvInfo101 *info101;
- info101 = TALLOC_P(p->mem_ctx, struct srvsvc_NetSrvInfo101);
+ info101 = talloc(p->mem_ctx, struct srvsvc_NetSrvInfo101);
if (!info101) {
return WERR_NOMEM;
}
info101->platform_id = PLATFORM_ID_NT;
- info101->server_name = global_myname();
- info101->version_major = lp_major_announce_version();
- info101->version_minor = lp_minor_announce_version();
+ info101->server_name = lp_netbios_name();
+ info101->version_major = SAMBA_MAJOR_NBT_ANNOUNCE_VERSION;
+ info101->version_minor = SAMBA_MINOR_NBT_ANNOUNCE_VERSION;
info101->server_type = lp_default_server_announce();
info101->comment = string_truncate(lp_serverstring(),
MAX_SERVER_STRING_LENGTH);
@@ -1183,13 +1184,13 @@ WERROR _srvsvc_NetSrvGetInfo(struct pipes_struct *p,
case 100: {
struct srvsvc_NetSrvInfo100 *info100;
- info100 = TALLOC_P(p->mem_ctx, struct srvsvc_NetSrvInfo100);
+ info100 = talloc(p->mem_ctx, struct srvsvc_NetSrvInfo100);
if (!info100) {
return WERR_NOMEM;
}
info100->platform_id = PLATFORM_ID_NT;
- info100->server_name = global_myname();
+ info100->server_name = lp_netbios_name();
r->out.info->info100 = info100;
@@ -1453,47 +1454,47 @@ WERROR _srvsvc_NetShareGetInfo(struct pipes_struct *p,
switch (r->in.level) {
case 0:
- info->info0 = TALLOC_P(p->mem_ctx, struct srvsvc_NetShareInfo0);
+ info->info0 = talloc(p->mem_ctx, struct srvsvc_NetShareInfo0);
W_ERROR_HAVE_NO_MEMORY(info->info0);
init_srv_share_info_0(p, info->info0, snum);
break;
case 1:
- info->info1 = TALLOC_P(p->mem_ctx, struct srvsvc_NetShareInfo1);
+ info->info1 = talloc(p->mem_ctx, struct srvsvc_NetShareInfo1);
W_ERROR_HAVE_NO_MEMORY(info->info1);
init_srv_share_info_1(p, info->info1, snum);
break;
case 2:
- info->info2 = TALLOC_P(p->mem_ctx, struct srvsvc_NetShareInfo2);
+ info->info2 = talloc(p->mem_ctx, struct srvsvc_NetShareInfo2);
W_ERROR_HAVE_NO_MEMORY(info->info2);
init_srv_share_info_2(p, info->info2, snum);
break;
case 501:
- info->info501 = TALLOC_P(p->mem_ctx, struct srvsvc_NetShareInfo501);
+ info->info501 = talloc(p->mem_ctx, struct srvsvc_NetShareInfo501);
W_ERROR_HAVE_NO_MEMORY(info->info501);
init_srv_share_info_501(p, info->info501, snum);
break;
case 502:
- info->info502 = TALLOC_P(p->mem_ctx, struct srvsvc_NetShareInfo502);
+ info->info502 = talloc(p->mem_ctx, struct srvsvc_NetShareInfo502);
W_ERROR_HAVE_NO_MEMORY(info->info502);
init_srv_share_info_502(p, info->info502, snum);
break;
case 1004:
- info->info1004 = TALLOC_P(p->mem_ctx, struct srvsvc_NetShareInfo1004);
+ info->info1004 = talloc(p->mem_ctx, struct srvsvc_NetShareInfo1004);
W_ERROR_HAVE_NO_MEMORY(info->info1004);
init_srv_share_info_1004(p, info->info1004, snum);
break;
case 1005:
- info->info1005 = TALLOC_P(p->mem_ctx, struct srvsvc_NetShareInfo1005);
+ info->info1005 = talloc(p->mem_ctx, struct srvsvc_NetShareInfo1005);
W_ERROR_HAVE_NO_MEMORY(info->info1005);
init_srv_share_info_1005(p, info->info1005, snum);
break;
case 1006:
- info->info1006 = TALLOC_P(p->mem_ctx, struct srvsvc_NetShareInfo1006);
+ info->info1006 = talloc(p->mem_ctx, struct srvsvc_NetShareInfo1006);
W_ERROR_HAVE_NO_MEMORY(info->info1006);
init_srv_share_info_1006(p, info->info1006, snum);
break;
case 1007:
- info->info1007 = TALLOC_P(p->mem_ctx, struct srvsvc_NetShareInfo1007);
+ info->info1007 = talloc(p->mem_ctx, struct srvsvc_NetShareInfo1007);
W_ERROR_HAVE_NO_MEMORY(info->info1007);
init_srv_share_info_1007(p, info->info1007, snum);
break;
@@ -1513,40 +1514,6 @@ WERROR _srvsvc_NetShareGetInfo(struct pipes_struct *p,
}
/*******************************************************************
- Check a given DOS pathname is valid for a share.
-********************************************************************/
-
-char *valid_share_pathname(TALLOC_CTX *ctx, const char *dos_pathname)
-{
- char *ptr = NULL;
-
- if (!dos_pathname) {
- return NULL;
- }
-
- ptr = talloc_strdup(ctx, dos_pathname);
- if (!ptr) {
- return NULL;
- }
- /* Convert any '\' paths to '/' */
- unix_format(ptr);
- ptr = unix_clean_name(ctx, ptr);
- if (!ptr) {
- return NULL;
- }
-
- /* NT is braindead - it wants a C: prefix to a pathname ! So strip it. */
- if (strlen(ptr) > 2 && ptr[1] == ':' && ptr[0] != '/')
- ptr += 2;
-
- /* Only absolute paths allowed. */
- if (*ptr != '/')
- return NULL;
-
- return ptr;
-}
-
-/*******************************************************************
_srvsvc_NetShareSetInfo. Modify share details.
********************************************************************/
@@ -2095,7 +2062,7 @@ WERROR _srvsvc_NetRemoteTOD(struct pipes_struct *p,
DEBUG(5,("_srvsvc_NetRemoteTOD: %d\n", __LINE__));
- if ( !(tod = TALLOC_ZERO_P(p->mem_ctx, struct srvsvc_NetRemoteTODInfo)) )
+ if ( !(tod = talloc_zero(p->mem_ctx, struct srvsvc_NetRemoteTODInfo)) )
return WERR_NOMEM;
*r->out.info = tod;
@@ -2222,7 +2189,7 @@ WERROR _srvsvc_NetGetFileSecurity(struct pipes_struct *p,
sd_size = ndr_size_security_descriptor(psd, 0);
- sd_buf = TALLOC_ZERO_P(p->mem_ctx, struct sec_desc_buf);
+ sd_buf = talloc_zero(p->mem_ctx, struct sec_desc_buf);
if (!sd_buf) {
werr = WERR_NOMEM;
goto error_exit;
@@ -2471,7 +2438,7 @@ WERROR _srvsvc_NetDiskEnum(struct pipes_struct *p,
*r->out.totalentries = init_server_disk_enum(&resume);
- r->out.info->disks = TALLOC_ZERO_ARRAY(ctx, struct srvsvc_NetDiskInfo0,
+ r->out.info->disks = talloc_zero_array(ctx, struct srvsvc_NetDiskInfo0,
MAX_SERVER_DISK_ENTRIES);
W_ERROR_HAVE_NO_MEMORY(r->out.info->disks);
diff --git a/source3/rpc_server/svcctl/srv_svcctl_nt.c b/source3/rpc_server/svcctl/srv_svcctl_nt.c
index a4eb282de7c..f515906339f 100644
--- a/source3/rpc_server/svcctl/srv_svcctl_nt.c
+++ b/source3/rpc_server/svcctl/srv_svcctl_nt.c
@@ -23,13 +23,14 @@
*/
#include "includes.h"
+#include "ntdomain.h"
#include "../librpc/gen_ndr/srv_svcctl.h"
#include "../libcli/security/security.h"
#include "../librpc/gen_ndr/ndr_security.h"
#include "services/services.h"
#include "services/svc_winreg_glue.h"
#include "auth.h"
-#include "ntdomain.h"
+#include "rpc_server/svcctl/srv_svcctl_nt.h"
#undef DBGC_CLASS
#define DBGC_CLASS DBGC_RPC_SRV
@@ -70,7 +71,7 @@ bool init_service_op_table( void )
int num_services = SVCCTL_NUM_INTERNAL_SERVICES + str_list_length( service_list );
int i;
- if ( !(svcctl_ops = TALLOC_ARRAY( NULL, struct service_control_op, num_services+1)) ) {
+ if ( !(svcctl_ops = talloc_array( NULL, struct service_control_op, num_services+1)) ) {
DEBUG(0,("init_service_op_table: talloc() failed!\n"));
return False;
}
@@ -208,7 +209,7 @@ static WERROR create_open_service_handle(struct pipes_struct *p,
WERROR result = WERR_OK;
struct service_control_op *s_op;
- if ( !(info = TALLOC_ZERO_P( NULL, SERVICE_INFO )) )
+ if ( !(info = talloc_zero( NULL, SERVICE_INFO )) )
return WERR_NOMEM;
/* the Service Manager has a NULL name */
@@ -420,7 +421,7 @@ static int enumerate_status(TALLOC_CTX *ctx,
while ( svcctl_ops[num_services].name )
num_services++;
- if ( !(st = TALLOC_ARRAY( ctx, struct ENUM_SERVICE_STATUSW, num_services )) ) {
+ if ( !(st = talloc_array( ctx, struct ENUM_SERVICE_STATUSW, num_services )) ) {
DEBUG(0,("enumerate_status: talloc() failed!\n"));
return -1;
}
@@ -667,17 +668,18 @@ WERROR _svcctl_QueryServiceStatusEx(struct pipes_struct *p,
/********************************************************************
********************************************************************/
-static WERROR fill_svc_config(TALLOC_CTX *ctx,
+static WERROR fill_svc_config(TALLOC_CTX *mem_ctx,
struct messaging_context *msg_ctx,
struct auth_serversupplied_info *session_info,
const char *name,
struct QUERY_SERVICE_CONFIG *config)
{
- TALLOC_CTX *mem_ctx = talloc_stackframe();
const char *result = NULL;
/* now fill in the individual values */
+ ZERO_STRUCTP(config);
+
config->displayname = svcctl_lookup_dispname(mem_ctx,
msg_ctx,
session_info,
@@ -719,9 +721,6 @@ static WERROR fill_svc_config(TALLOC_CTX *ctx,
else
config->start_type = SVCCTL_DEMAND_START;
-
- talloc_free(mem_ctx);
-
return WERR_OK;
}
@@ -776,7 +775,8 @@ WERROR _svcctl_QueryServiceConfig2W(struct pipes_struct *p,
struct svcctl_QueryServiceConfig2W *r)
{
SERVICE_INFO *info = find_service_info_by_hnd( p, r->in.handle );
- uint32 buffer_size;
+ uint32_t buffer_size;
+ DATA_BLOB blob = data_blob_null;
/* perform access checks */
@@ -796,7 +796,6 @@ WERROR _svcctl_QueryServiceConfig2W(struct pipes_struct *p,
struct SERVICE_DESCRIPTION desc_buf;
const char *description;
enum ndr_err_code ndr_err;
- DATA_BLOB blob;
description = svcctl_lookup_description(p->mem_ctx,
p->msg_ctx,
@@ -811,9 +810,6 @@ WERROR _svcctl_QueryServiceConfig2W(struct pipes_struct *p,
return WERR_INVALID_PARAM;
}
- buffer_size = ndr_size_SERVICE_DESCRIPTION(&desc_buf, 0);
- r->out.buffer = blob.data;
-
break;
}
break;
@@ -821,7 +817,6 @@ WERROR _svcctl_QueryServiceConfig2W(struct pipes_struct *p,
{
struct SERVICE_FAILURE_ACTIONS actions;
enum ndr_err_code ndr_err;
- DATA_BLOB blob;
/* nothing to say...just service the request */
@@ -833,9 +828,6 @@ WERROR _svcctl_QueryServiceConfig2W(struct pipes_struct *p,
return WERR_INVALID_PARAM;
}
- buffer_size = ndr_size_SERVICE_FAILURE_ACTIONS(&actions, 0);
- r->out.buffer = blob.data;
-
break;
}
break;
@@ -844,12 +836,15 @@ WERROR _svcctl_QueryServiceConfig2W(struct pipes_struct *p,
return WERR_UNKNOWN_LEVEL;
}
+ buffer_size = blob.length;
buffer_size += buffer_size % 4;
*r->out.needed = (buffer_size > r->in.offered) ? buffer_size : r->in.offered;
if (buffer_size > r->in.offered)
return WERR_INSUFFICIENT_BUFFER;
+ memcpy(r->out.buffer, blob.data, blob.length);
+
return WERR_OK;
}
@@ -941,7 +936,7 @@ WERROR _svcctl_QueryServiceObjectSecurity(struct pipes_struct *p,
}
*r->out.needed = len;
- r->out.buffer = buffer;
+ memcpy(r->out.buffer, buffer, len);
return WERR_OK;
}
diff --git a/source3/rpc_server/svcctl/srv_svcctl_nt.h b/source3/rpc_server/svcctl/srv_svcctl_nt.h
new file mode 100644
index 00000000000..dd049272882
--- /dev/null
+++ b/source3/rpc_server/svcctl/srv_svcctl_nt.h
@@ -0,0 +1,33 @@
+/*
+ * Unix SMB/CIFS implementation.
+ * RPC Pipe client / server routines
+ *
+ * Copyright (C) Marcin Krzysztof Porwit 2005.
+ *
+ * Largely Rewritten (Again) by:
+ * 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/>.
+ */
+
+#ifndef _RPC_SERVER_SVCCTL_SRV_SVCCTL_NT_H_
+#define _RPC_SERVER_SVCCTL_SRV_SVCCTL_NT_H_
+
+/* The following definitions come from rpc_server/srv_svcctl_nt.c */
+
+bool init_service_op_table( void );
+bool shutdown_service_op_table(void);
+
+#endif /* _RPC_SERVER_SVCCTL_SRV_SVCCTL_NT_H_ */
diff --git a/source3/rpc_server/winreg/srv_winreg_nt.c b/source3/rpc_server/winreg/srv_winreg_nt.c
index fedb665a30b..6fee5b6acd9 100644
--- a/source3/rpc_server/winreg/srv_winreg_nt.c
+++ b/source3/rpc_server/winreg/srv_winreg_nt.c
@@ -21,6 +21,7 @@
/* Implementation of registry functions. */
#include "includes.h"
+#include "ntdomain.h"
#include "../librpc/gen_ndr/srv_winreg.h"
#include "registry.h"
#include "registry/reg_api.h"
@@ -28,8 +29,8 @@
#include "registry/reg_perfcount.h"
#include "rpc_misc.h"
#include "auth.h"
-#include "ntdomain.h"
#include "lib/privileges.h"
+#include "libcli/security/secdesc.h"
#undef DBGC_CLASS
#define DBGC_CLASS DBGC_RPC_SRV
@@ -541,7 +542,7 @@ WERROR _winreg_InitiateSystemShutdownEx(struct pipes_struct *p,
if ( (msg = talloc_strdup(p->mem_ctx, r->in.message->string )) == NULL ) {
return WERR_NOMEM;
}
- chkmsg = TALLOC_ARRAY(p->mem_ctx, char, strlen(msg)+1);
+ chkmsg = talloc_array(p->mem_ctx, char, strlen(msg)+1);
if (!chkmsg) {
return WERR_NOMEM;
}
diff --git a/source3/rpc_server/wkssvc/srv_wkssvc_nt.c b/source3/rpc_server/wkssvc/srv_wkssvc_nt.c
index d44414f7767..49c71b8d6eb 100644
--- a/source3/rpc_server/wkssvc/srv_wkssvc_nt.c
+++ b/source3/rpc_server/wkssvc/srv_wkssvc_nt.c
@@ -23,6 +23,7 @@
/* This is the implementation of the wks interface. */
#include "includes.h"
+#include "ntdomain.h"
#include "librpc/gen_ndr/libnet_join.h"
#include "libnet/libnet_join.h"
#include "../libcli/auth/libcli_auth.h"
@@ -31,7 +32,6 @@
#include "session.h"
#include "smbd/smbd.h"
#include "auth.h"
-#include "ntdomain.h"
#undef DBGC_CLASS
#define DBGC_CLASS DBGC_RPC_SRV
@@ -196,7 +196,7 @@ static struct dom_usr *get_domain_userlist(TALLOC_CTX *mem_ctx)
DEBUG(10, ("talloc_asprintf failed\n"));
continue;
}
- if (strcmp(machine_name, global_myname()) == 0) {
+ if (strcmp(machine_name, lp_netbios_name()) == 0) {
p = session_list[i].username;
nm = strstr(p, sep);
if (nm) {
@@ -260,11 +260,11 @@ static struct wkssvc_NetWkstaInfo100 *create_wks_info_100(TALLOC_CTX *mem_ctx)
}
info100->platform_id = PLATFORM_ID_NT; /* unknown */
- info100->version_major = lp_major_announce_version();
- info100->version_minor = lp_minor_announce_version();
+ info100->version_major = SAMBA_MAJOR_NBT_ANNOUNCE_VERSION;
+ info100->version_minor = SAMBA_MINOR_NBT_ANNOUNCE_VERSION;
info100->server_name = talloc_asprintf_strupper_m(
- info100, "%s", global_myname());
+ info100, "%s", lp_netbios_name());
info100->domain_name = talloc_asprintf_strupper_m(
info100, "%s", lp_workgroup());
@@ -289,11 +289,11 @@ static struct wkssvc_NetWkstaInfo101 *create_wks_info_101(TALLOC_CTX *mem_ctx)
}
info101->platform_id = PLATFORM_ID_NT; /* unknown */
- info101->version_major = lp_major_announce_version();
- info101->version_minor = lp_minor_announce_version();
+ info101->version_major = SAMBA_MAJOR_NBT_ANNOUNCE_VERSION;
+ info101->version_minor = SAMBA_MINOR_NBT_ANNOUNCE_VERSION;
info101->server_name = talloc_asprintf_strupper_m(
- info101, "%s", global_myname());
+ info101, "%s", lp_netbios_name());
info101->domain_name = talloc_asprintf_strupper_m(
info101, "%s", lp_workgroup());
info101->lan_root = "";
@@ -320,11 +320,11 @@ static struct wkssvc_NetWkstaInfo102 *create_wks_info_102(TALLOC_CTX *mem_ctx)
}
info102->platform_id = PLATFORM_ID_NT; /* unknown */
- info102->version_major = lp_major_announce_version();
- info102->version_minor = lp_minor_announce_version();
+ info102->version_major = SAMBA_MAJOR_NBT_ANNOUNCE_VERSION;
+ info102->version_minor = SAMBA_MINOR_NBT_ANNOUNCE_VERSION;
info102->server_name = talloc_asprintf_strupper_m(
- info102, "%s", global_myname());
+ info102, "%s", lp_netbios_name());
info102->domain_name = talloc_asprintf_strupper_m(
info102, "%s", lp_workgroup());
info102->lan_root = "";
@@ -528,7 +528,7 @@ static struct wkssvc_NetWkstaEnumUsersCtr1 *create_enum_users1(
/* For a local user the domain name and logon server are
* both returned as the local machine's NetBIOS name */
ctr1->user1[i].logon_domain = ctr1->user1[i].logon_server =
- talloc_asprintf_strupper_m(ctr1->user1, "%s", global_myname());
+ talloc_asprintf_strupper_m(ctr1->user1, "%s", lp_netbios_name());
ctr1->user1[i].other_domains = NULL; /* Maybe in future? */
}
diff --git a/source3/rpc_server/wscript_build b/source3/rpc_server/wscript_build
index 346d770385e..5d21d5e3408 100644
--- a/source3/rpc_server/wscript_build
+++ b/source3/rpc_server/wscript_build
@@ -26,26 +26,32 @@ bld.SAMBA3_SUBSYSTEM('rpc',
vars=locals())
bld.SAMBA3_SUBSYSTEM('RPC_NCACN_NP',
- source='rpc_ncacn_np.c rpc_handles.c',
- deps='auth_sam_reply')
+ source='rpc_ncacn_np.c rpc_handles.c rpc_contexts.c',
+ deps='auth_sam_reply RPC_PIPE_REGISTER AUTH_COMMON npa_tstream')
bld.SAMBA3_SUBSYSTEM('RPC_SERVICE',
- source='rpc_server.c')
+ source='rpc_server.c',
+ deps='samba-util')
bld.SAMBA3_SUBSYSTEM('RPC_CRYPTO',
- source='dcesrv_ntlmssp.c dcesrv_gssapi.c dcesrv_spnego.c')
+ source='dcesrv_ntlmssp.c dcesrv_gssapi.c dcesrv_spnego.c',
+ deps = 'KRB5_PAC')
bld.SAMBA3_SUBSYSTEM('RPC_PIPE_REGISTER',
- source='srv_pipe_register.c')
+ source='srv_pipe_register.c',
+ deps='samba-util')
bld.SAMBA3_SUBSYSTEM('RPC_SERVER_REGISTER',
- source='rpc_ep_setup.c ../librpc/rpc/dcerpc_ep.c')
+ source='rpc_ep_setup.c ../librpc/rpc/dcerpc_ep.c',
+ deps='samba-util')
bld.SAMBA3_SUBSYSTEM('EPMD',
- source='epmd.c')
+ source='epmd.c',
+ deps='samba-util')
bld.SAMBA3_SUBSYSTEM('SRV_ACCESS_CHECK',
- source='srv_access_check.c')
+ source='srv_access_check.c',
+ deps='samba-util')
bld.SAMBA3_SUBSYSTEM('RPC_SAMR',
source=RPC_SAMR_SRC,
@@ -64,10 +70,12 @@ bld.SAMBA3_SUBSYSTEM('RPC_WINREG',
bld.SAMBA3_SUBSYSTEM('RPC_INITSHUTDOWN',
source=RPC_INITSHUTDOWN_SRC,
+ deps='samba-util',
vars=locals())
bld.SAMBA3_SUBSYSTEM('RPC_DSSETUP',
source=RPC_DSSETUP_SRC,
+ deps='samba-util',
vars=locals())
bld.SAMBA3_SUBSYSTEM('RPC_WKSSVC',
@@ -82,23 +90,27 @@ bld.SAMBA3_SUBSYSTEM('RPC_SVCCTL',
bld.SAMBA3_SUBSYSTEM('RPC_NTSVCS',
source=RPC_NTSVCS_SRC,
+ deps='samba-util',
vars=locals())
bld.SAMBA3_SUBSYSTEM('RPC_NETLOGON',
source=RPC_NETLOGON_SRC,
+ deps='RPC_NCACN_NP',
vars=locals())
bld.SAMBA3_SUBSYSTEM('RPC_NETDFS',
source=RPC_NETDFS_SRC,
+ deps='samba-util',
vars=locals())
bld.SAMBA3_SUBSYSTEM('RPC_SRVSVC',
source=RPC_SRVSVC_SRC,
+ deps='samba-util',
vars=locals())
bld.SAMBA3_SUBSYSTEM('RPC_SPOOLSS',
source=RPC_SPOOLSS_SRC,
- deps='cups PRINTING PRINTBACKEND LIBCLI_WINREG',
+ deps='cups PRINTING PRINTBACKEND LIBCLI_WINREG RPC_NCACN_NP',
vars=locals())
bld.SAMBA3_SUBSYSTEM('RPC_EVENTLOG',
@@ -108,10 +120,12 @@ bld.SAMBA3_SUBSYSTEM('RPC_EVENTLOG',
bld.SAMBA3_SUBSYSTEM('RPC_RPCECHO',
source=RPC_RPCECHO_SRC,
+ deps='samba-util',
vars=locals())
bld.SAMBA3_SUBSYSTEM('RPC_EPMAPPER',
source=RPC_EPMAPPER_SRC,
+ deps='samba-util',
vars=locals())
bld.SAMBA3_SUBSYSTEM('RPC_SERVER',