summaryrefslogtreecommitdiffstats
path: root/source3/rpc_client
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>1999-12-13 13:35:20 +0000
committerAndrew Tridgell <tridge@samba.org>1999-12-13 13:35:20 +0000
commit32a965e09ce4befe971855e11e1fb5ceb51a9ed1 (patch)
tree157f164263a56d7e3f2ca1fe9a05a9df24f25234 /source3/rpc_client
parent3db52feb1f3b2c07ce0b06ad4a7099fa6efe3fc7 (diff)
downloadsamba-32a965e09ce4befe971855e11e1fb5ceb51a9ed1.tar.gz
samba-32a965e09ce4befe971855e11e1fb5ceb51a9ed1.tar.xz
samba-32a965e09ce4befe971855e11e1fb5ceb51a9ed1.zip
2nd phase of head branch sync with SAMBA_2_0 - this delets all the files that were in the head branch but weren't in SAMBA_2_0
(This used to be commit d7b208786590b5a28618590172b8d523627dda09)
Diffstat (limited to 'source3/rpc_client')
-rw-r--r--source3/rpc_client/cli_atsvc.c277
-rw-r--r--source3/rpc_client/cli_brs.c97
-rw-r--r--source3/rpc_client/cli_connect.c427
-rw-r--r--source3/rpc_client/cli_eventlog.c212
-rw-r--r--source3/rpc_client/cli_netlogon_sync.c104
-rw-r--r--source3/rpc_client/cli_spoolss.c329
-rw-r--r--source3/rpc_client/cli_svcctl.c604
-rw-r--r--source3/rpc_client/cli_use.c418
-rw-r--r--source3/rpc_client/msrpc_lsarpc.c65
-rw-r--r--source3/rpc_client/msrpc_samr.c1593
10 files changed, 0 insertions, 4126 deletions
diff --git a/source3/rpc_client/cli_atsvc.c b/source3/rpc_client/cli_atsvc.c
deleted file mode 100644
index 9ba87e6e4a..0000000000
--- a/source3/rpc_client/cli_atsvc.c
+++ /dev/null
@@ -1,277 +0,0 @@
-/*
- * Unix SMB/Netbios implementation.
- * Version 2.1.
- * RPC client routines: scheduler service
- * Copyright (C) Matthew Chapman 1999,
- * Copyright (C) Luke Kenneth Casson Leighton 1996-1999,
- * Copyright (C) Andrew Tridgell 1992-1999.
- *
- * 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 2 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, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- */
-
-#include "includes.h"
-
-extern int DEBUGLEVEL;
-
-/****************************************************************************
-add a job to the scheduler
-****************************************************************************/
-BOOL at_add_job(
- char *srv_name, AT_JOB_INFO *info, char *command,
- uint32 *jobid)
-{
- prs_struct rbuf;
- prs_struct buf;
- AT_Q_ADD_JOB q_a;
- BOOL p = False;
-
- struct cli_connection *con = NULL;
-
- if (!cli_connection_init(srv_name, PIPE_ATSVC, &con))
- {
- return False;
- }
-
- prs_init(&buf , 1024, 4, SAFETY_MARGIN, False);
- prs_init(&rbuf, 0 , 4, SAFETY_MARGIN, True );
-
- /* create and send a MSRPC command with api AT_ADD_JOB */
-
- DEBUG(4,("Scheduler Add Job\n"));
-
- /* store the parameters */
- make_at_q_add_job(&q_a, srv_name, info, command);
-
- /* turn parameters into data stream */
- at_io_q_add_job("", &q_a, &buf, 0);
-
- /* send the data on \PIPE\ */
- if (rpc_con_pipe_req(con, AT_ADD_JOB, &buf, &rbuf))
- {
- AT_R_ADD_JOB r_a;
-
- at_io_r_add_job("", &r_a, &rbuf, 0);
- p = rbuf.offset != 0;
-
- if (p && r_a.status != 0)
- {
- /* report error code */
- DEBUG(0,("AT_R_ADD_JOB: %s\n", get_nt_error_msg(r_a.status)));
- p = False;
- }
-
- if (p)
- {
- *jobid = r_a.jobid;
- }
- }
-
- prs_mem_free(&rbuf);
- prs_mem_free(&buf );
-
- cli_connection_unlink(con);
-
- return p;
-}
-
-/****************************************************************************
-dequeue a job
-****************************************************************************/
-BOOL at_del_job( char *srv_name, uint32 min_jobid, uint32 max_jobid)
-{
- prs_struct rbuf;
- prs_struct buf;
- AT_Q_DEL_JOB q_d;
- BOOL p = False;
-
- struct cli_connection *con = NULL;
-
- if (!cli_connection_init(srv_name, PIPE_ATSVC, &con))
- {
- return False;
- }
-
- prs_init(&buf , 1024, 4, SAFETY_MARGIN, False);
- prs_init(&rbuf, 0 , 4, SAFETY_MARGIN, True );
-
- /* create and send a MSRPC command with api AT_DEL_JOB */
-
- DEBUG(4,("Scheduler Delete Job\n"));
-
- /* store the parameters */
- make_at_q_del_job(&q_d, srv_name, min_jobid, max_jobid);
-
- /* turn parameters into data stream */
- at_io_q_del_job("", &q_d, &buf, 0);
-
- /* send the data on \PIPE\ */
- if (rpc_con_pipe_req(con, AT_DEL_JOB, &buf, &rbuf))
- {
- AT_R_DEL_JOB r_d;
-
- at_io_r_del_job("", &r_d, &rbuf, 0);
- p = rbuf.offset != 0;
-
- if (p && r_d.status != 0)
- {
- /* report error code */
- DEBUG(0,("AT_R_DEL_JOB: %s\n", get_nt_error_msg(r_d.status)));
- p = False;
- }
- }
-
- prs_mem_free(&rbuf);
- prs_mem_free(&buf );
-
- cli_connection_unlink(con);
-
- return p;
-}
-
-/****************************************************************************
-enumerate scheduled jobs
-****************************************************************************/
-BOOL at_enum_jobs( char *srv_name, uint32 *num_jobs,
- AT_ENUM_INFO *jobs, char ***commands)
-{
- prs_struct rbuf;
- prs_struct buf;
- AT_Q_ENUM_JOBS q_e;
- BOOL p = False;
-
- struct cli_connection *con = NULL;
-
- if (!cli_connection_init(srv_name, PIPE_ATSVC, &con))
- {
- return False;
- }
-
- prs_init(&buf , 1024, 4, SAFETY_MARGIN, False);
- prs_init(&rbuf, 0 , 4, SAFETY_MARGIN, True );
-
- /* create and send a MSRPC command with api AT_DEL_JOB */
-
- DEBUG(4,("Scheduler Enumerate Jobs\n"));
-
- /* store the parameters */
- make_at_q_enum_jobs(&q_e, srv_name);
-
- /* turn parameters into data stream */
- at_io_q_enum_jobs("", &q_e, &buf, 0);
-
- /* send the data on \PIPE\ */
- if (rpc_con_pipe_req(con, AT_ENUM_JOBS, &buf, &rbuf))
- {
- AT_R_ENUM_JOBS r_e;
-
- at_io_r_enum_jobs("", &r_e, &rbuf, 0);
- p = rbuf.offset != 0;
-
- if (p && r_e.status != 0)
- {
- /* report error code */
- DEBUG(0,("AT_R_ENUM_JOBS: %s\n", get_nt_error_msg(r_e.status)));
- p = False;
- }
-
- if (p)
- {
- int i;
-
- *num_jobs = 0;
- memcpy(jobs, &r_e.info, r_e.num_entries * sizeof(AT_ENUM_INFO));
-
- for (i = 0; i < r_e.num_entries; i++)
- {
- fstring cmd;
- unistr2_to_ascii(cmd, &r_e.command[i], sizeof(cmd));
- add_chars_to_array(num_jobs, commands, cmd);
- }
- if ((*num_jobs) != r_e.num_entries)
- {
- p = False;
- }
- }
- }
-
- prs_mem_free(&rbuf);
- prs_mem_free(&buf );
-
- cli_connection_unlink(con);
-
- return p;
-}
-
-/****************************************************************************
-query job information
-****************************************************************************/
-BOOL at_query_job(char *srv_name,
- uint32 jobid, AT_JOB_INFO *job, fstring command)
-{
- prs_struct rbuf;
- prs_struct buf;
- AT_Q_QUERY_JOB q_q;
- BOOL p = False;
-
- struct cli_connection *con = NULL;
-
- if (!cli_connection_init(srv_name, PIPE_ATSVC, &con))
- {
- return False;
- }
-
- prs_init(&buf , 1024, 4, SAFETY_MARGIN, False);
- prs_init(&rbuf, 0 , 4, SAFETY_MARGIN, True );
-
- /* create and send a MSRPC command with api AT_QUERY_JOB */
-
- DEBUG(4,("Scheduler Query Job\n"));
-
- /* store the parameters */
- make_at_q_query_job(&q_q, srv_name, jobid);
-
- /* turn parameters into data stream */
- at_io_q_query_job("", &q_q, &buf, 0);
-
- /* send the data on \PIPE\ */
- if (rpc_con_pipe_req(con, AT_QUERY_JOB, &buf, &rbuf))
- {
- AT_R_QUERY_JOB r_q;
-
- at_io_r_query_job("", &r_q, &rbuf, 0);
- p = rbuf.offset != 0;
-
- if (p && r_q.status != 0)
- {
- /* report error code */
- DEBUG(0,("AT_R_QUERY_JOB: %s\n", get_nt_error_msg(r_q.status)));
- p = False;
- }
-
- if (p)
- {
- memcpy(job, &r_q.info, sizeof(AT_JOB_INFO));
- unistr2_to_ascii(command, &r_q.command,
- sizeof(fstring)-1);
- }
- }
-
- prs_mem_free(&rbuf);
- prs_mem_free(&buf );
-
- cli_connection_unlink(con);
-
- return p;
-}
diff --git a/source3/rpc_client/cli_brs.c b/source3/rpc_client/cli_brs.c
deleted file mode 100644
index f4e055f394..0000000000
--- a/source3/rpc_client/cli_brs.c
+++ /dev/null
@@ -1,97 +0,0 @@
-
-/*
- * Unix SMB/Netbios implementation.
- * Version 1.9.
- * RPC Pipe client / server routines
- * Copyright (C) Andrew Tridgell 1992-1999,
- * Copyright (C) Luke Kenneth Casson Leighton 1996-1999,
- *
- * 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 2 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, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- */
-
-
-#ifdef SYSLOG
-#undef SYSLOG
-#endif
-
-#include "includes.h"
-
-extern int DEBUGLEVEL;
-
-/****************************************************************************
-do a BRS Query
-****************************************************************************/
-BOOL brs_query_info( const char *srv_name, uint32 switch_value,
- void *id)
-{
- prs_struct rbuf;
- prs_struct buf;
- BRS_Q_QUERY_INFO q_o;
- BOOL valid_info = False;
-
- struct cli_connection *con = NULL;
-
- if (!cli_connection_init(srv_name, PIPE_BROWSER, &con))
- {
- return False;
- }
-
- if (id == NULL) return False;
-
- prs_init(&buf , 1024, 4, SAFETY_MARGIN, False);
- prs_init(&rbuf, 0 , 4, SAFETY_MARGIN, True );
-
- /* create and send a MSRPC command with api BRS_QUERY_INFO */
-
- DEBUG(4,("BRS Query Info\n"));
-
- /* store the parameters */
- make_brs_q_query_info(&q_o, srv_name, switch_value);
-
- /* turn parameters into data stream */
- brs_io_q_query_info("", &q_o, &buf, 0);
-
- /* send the data on \PIPE\ */
- if (rpc_con_pipe_req(con, BRS_QUERY_INFO, &buf, &rbuf))
- {
- BRS_R_QUERY_INFO r_o;
- BOOL p;
-
- r_o.info.id = id;
-
- brs_io_r_query_info("", &r_o, &rbuf, 0);
- p = rbuf.offset != 0;
-
- if (p && r_o.status != 0)
- {
- /* report error code */
- DEBUG(0,("BRS_R_QUERY_INFO: %s\n", get_nt_error_msg(r_o.status)));
- p = False;
- }
-
- if (p)
- {
- valid_info = True;
- }
- }
-
- prs_mem_free(&rbuf);
- prs_mem_free(&buf );
-
- cli_connection_unlink(con);
-
- return valid_info;
-}
-
diff --git a/source3/rpc_client/cli_connect.c b/source3/rpc_client/cli_connect.c
deleted file mode 100644
index f935b53044..0000000000
--- a/source3/rpc_client/cli_connect.c
+++ /dev/null
@@ -1,427 +0,0 @@
-/*
- Unix SMB/Netbios implementation.
- Version 1.9.
- SMB client generic functions
- Copyright (C) Andrew Tridgell 1994-1999
- Copyright (C) Luke Kenneth Casson Leighton 1996-1999
-
- 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 2 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, write to the Free Software
- Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-*/
-
-#define NO_SYSLOG
-
-#include "includes.h"
-
-struct ntuser_creds *usr_creds = NULL;
-
-extern int DEBUGLEVEL;
-extern pstring scope;
-extern pstring global_myname;
-
-struct cli_connection
-{
- uint32 num_connections;
- char *srv_name;
- char *pipe_name;
- struct ntuser_creds usr_creds;
- struct cli_state *cli;
- uint16 fnum;
-};
-
-static struct cli_connection **con_list = NULL;
-uint32 num_cons = 0;
-
-void init_connections(void)
-{
- con_list = NULL;
- num_cons = 0;
-
- init_cli_use();
-}
-
-static void free_con_array(uint32 num_entries, struct cli_connection **entries)
-{
- void(*fn)(void*) = (void(*)(void*))&cli_connection_free;
- free_void_array(num_entries, (void**)entries, *fn);
-}
-
-static struct cli_connection* add_con_to_array(uint32 *len,
- struct cli_connection ***array,
- struct cli_connection *con)
-{
- return (struct cli_connection*)add_item_to_array(len,
- (void***)array, (void*)con);
-
-}
-void free_connections(void)
-{
- free_con_array(num_cons, con_list);
- free_cli_use();
-
- init_connections();
-}
-
-static struct cli_connection *cli_con_get(const char* srv_name,
- const char* pipe_name, BOOL reuse)
-{
- struct cli_connection *con = NULL;
-
- con = (struct cli_connection*)malloc(sizeof(*con));
-
- if (con == NULL)
- {
- return NULL;
- }
-
- memset(con, 0, sizeof(*con));
-
- if (srv_name != NULL)
- {
- con->srv_name = strdup(srv_name);
- }
- if (pipe_name != NULL)
- {
- con->pipe_name = strdup(pipe_name);
- }
-
- con->cli = cli_net_use_add(srv_name, usr_creds, True, reuse);
-
- if (con->cli == NULL)
- {
- cli_connection_free(con);
- return NULL;
- }
- add_con_to_array(&num_cons, &con_list, con);
- return con;
-}
-
-/****************************************************************************
-terminate client connection
-****************************************************************************/
-void cli_connection_free(struct cli_connection *con)
-{
- BOOL closed;
- int i;
-
- if (con->cli != NULL)
- {
- cli_nt_session_close(con->cli, con->fnum);
- cli_net_use_del(con->srv_name, &con->usr_creds, False, &closed);
- }
-
- if (closed)
- {
- for (i = 0; i < num_cons; i++)
- {
- if (con_list[i] != NULL &&
- con != con_list[i] &&
- con_list[i]->cli == con->cli)
- {
- /* WHOOPS! fnum already open: too bad!!! */
- con_list[i]->cli = NULL;
- con_list[i]->fnum = 0xffff;
- }
- }
- }
-
- con->cli = NULL;
-
- if (con->srv_name != NULL)
- {
- free(con->srv_name);
- con->srv_name = NULL;
- }
- if (con->pipe_name != NULL)
- {
- free(con->pipe_name);
- con->pipe_name = NULL;
- }
-
- memset(&con->usr_creds, 0, sizeof(con->usr_creds));
-
- for (i = 0; i < num_cons; i++)
- {
- if (con == con_list[i])
- {
- con_list[i] = NULL;
- }
- }
-
- free(con);
-}
-
-/****************************************************************************
-terminate client state
-****************************************************************************/
-void cli_connection_unlink(struct cli_connection *con)
-{
- if (con != NULL)
- {
- cli_connection_free(con);
- }
- return;
-}
-
-/****************************************************************************
-init client state
-****************************************************************************/
-BOOL cli_connection_init(const char* srv_name, const char* pipe_name,
- struct cli_connection **con)
-{
- BOOL res = True;
- BOOL reuse = False;
-
- /*
- * allocate
- */
-
- *con = cli_con_get(srv_name, pipe_name, reuse);
-
- if ((*con) == NULL)
- {
- return False;
- }
-
- res = res ? cli_nt_session_open((*con)->cli, pipe_name,
- &(*con)->fnum) : False;
-
- return res;
-}
-
-/****************************************************************************
-obtain client state
-****************************************************************************/
-BOOL cli_connection_getsrv(const char* srv_name, const char* pipe_name,
- struct cli_connection **con)
-{
- int i;
- if (con_list == NULL || num_cons == 0)
- {
- return False;
- }
-
- for (i = 0; i < num_cons; i++)
- {
- if (con_list[i] != NULL &&
- strequal(con_list[i]->srv_name , srv_name ) &&
- strequal(con_list[i]->pipe_name, pipe_name))
- {
- (*con) = con_list[i];
- return True;
- }
- }
- return False;
-}
-
-/****************************************************************************
-obtain client state
-****************************************************************************/
-BOOL cli_connection_get(const POLICY_HND *pol, struct cli_connection **con)
-{
- return get_policy_con(pol, con);
-}
-
-/****************************************************************************
-link a child policy handle to a parent one
-****************************************************************************/
-BOOL cli_pol_link(POLICY_HND *to, const POLICY_HND *from)
-{
- struct cli_connection *con = NULL;
-
- if (!cli_connection_get(from, &con))
- {
- return False;
- }
-
- return register_policy_hnd(to) && set_policy_con(to, con, NULL);
-}
-
-/****************************************************************************
-get a user session key associated with a connection associated with a
-policy handle.
-****************************************************************************/
-BOOL cli_get_con_usr_sesskey(struct cli_connection *con, uchar usr_sess_key[16])
-{
- if (con == NULL)
- {
- return False;
- }
- memcpy(usr_sess_key, con->cli->usr.pwd.sess_key, 16);
-
- return True;
-}
-
-/****************************************************************************
-get a user session key associated with a connection associated with a
-policy handle.
-****************************************************************************/
-BOOL cli_get_con_sesskey(struct cli_connection *con, uchar sess_key[16])
-{
- if (con == NULL)
- {
- return False;
- }
- memcpy(sess_key, con->cli->sess_key, sizeof(con->cli->sess_key));
-
- return True;
-}
-
-/****************************************************************************
-get a user session key associated with a connection associated with a
-policy handle.
-****************************************************************************/
-BOOL cli_con_get_srvname(struct cli_connection *con, char *srv_name)
-{
- if (con == NULL)
- {
- return False;
- }
-
- if (strnequal("\\\\", con->cli->desthost, 2))
- {
- fstrcpy(srv_name, con->cli->desthost);
- }
- else
- {
- fstrcpy(srv_name, "\\\\");
- fstrcat(srv_name, con->cli->desthost);
- }
-
- return True;
-}
-
-/****************************************************************************
-get a user session key associated with a connection associated with a
-policy handle.
-****************************************************************************/
-BOOL cli_get_usr_sesskey(const POLICY_HND *pol, uchar usr_sess_key[16])
-{
- struct cli_connection *con = NULL;
-
- if (!cli_connection_get(pol, &con))
- {
- return False;
- }
-
- return cli_get_con_usr_sesskey(con, usr_sess_key);
-}
-
-/****************************************************************************
-get a user session key associated with a connection associated with a
-policy handle.
-****************************************************************************/
-BOOL cli_get_sesskey(const POLICY_HND *pol, uchar sess_key[16])
-{
- struct cli_connection *con = NULL;
-
- if (!cli_connection_get(pol, &con))
- {
- return False;
- }
-
- return cli_get_con_sesskey(con, sess_key);
-}
-
-/****************************************************************************
-get a user session key associated with a connection associated with a
-policy handle.
-****************************************************************************/
-BOOL cli_get_sesskey_srv(const char* srv_name, uchar sess_key[16])
-{
- struct cli_connection *con = NULL;
-
- if (!cli_connection_getsrv(srv_name, PIPE_NETLOGON, &con))
- {
- return False;
- }
-
- return cli_get_con_sesskey(con, sess_key);
-}
-
-/****************************************************************************
-get a user session key associated with a connection associated with a
-policy handle.
-****************************************************************************/
-void cli_con_gen_next_creds(struct cli_connection *con,
- DOM_CRED *new_clnt_cred)
-{
- gen_next_creds(con->cli, new_clnt_cred);
-}
-
-/****************************************************************************
-get a user session key associated with a connection associated with a
-policy handle.
-****************************************************************************/
-void cli_con_get_cli_cred(struct cli_connection *con,
- DOM_CRED *clnt_cred)
-{
- memcpy(clnt_cred, &con->cli->clnt_cred, sizeof(*clnt_cred));
-}
-
-/****************************************************************************
-get a user session key associated with a connection associated with a
-policy handle.
-****************************************************************************/
-BOOL cli_con_deal_with_creds(struct cli_connection *con,
- DOM_CRED *rcv_srv_cred)
-{
- return clnt_deal_with_creds(con->cli->sess_key, &con->cli->clnt_cred,
- rcv_srv_cred);
-}
-
-/****************************************************************************
-get a user session key associated with a connection associated with a
-policy handle.
-****************************************************************************/
-BOOL cli_con_set_creds(const char* srv_name, const uchar sess_key[16],
- DOM_CRED *cred)
-{
- struct cli_connection *con = NULL;
-
- if (!cli_connection_getsrv(srv_name, PIPE_NETLOGON, &con))
- {
- return False;
- }
-
- memcpy(con->cli->sess_key, sess_key, 16);
- memcpy(&con->cli->clnt_cred, cred, sizeof(*cred));
-
- return True;
-}
-
-/****************************************************************************
- send a request on an rpc pipe.
- ****************************************************************************/
-BOOL rpc_hnd_pipe_req(const POLICY_HND *hnd, uint8 op_num,
- prs_struct *data, prs_struct *rdata)
-{
- struct cli_connection *con = NULL;
-
- if (!cli_connection_get(hnd, &con))
- {
- return False;
- }
-
- return rpc_con_pipe_req(con, op_num, data, rdata);
-}
-
-/****************************************************************************
- send a request on an rpc pipe.
- ****************************************************************************/
-BOOL rpc_con_pipe_req(struct cli_connection *con, uint8 op_num,
- prs_struct *data, prs_struct *rdata)
-{
- return rpc_api_pipe_req(con->cli, con->fnum, op_num, data, rdata);
-}
diff --git a/source3/rpc_client/cli_eventlog.c b/source3/rpc_client/cli_eventlog.c
deleted file mode 100644
index 85ba302294..0000000000
--- a/source3/rpc_client/cli_eventlog.c
+++ /dev/null
@@ -1,212 +0,0 @@
-/*
- * Unix SMB/Netbios implementation.
- * Version 2.1.
- * RPC client routines: scheduler service
- * Copyright (C) Jean Francois Micouleau 1998-1999,
- * Copyright (C) Luke Kenneth Casson Leighton 1996-1999,
- * Copyright (C) Andrew Tridgell 1992-1999.
- *
- * 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 2 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, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- */
-
-#include "includes.h"
-
-extern int DEBUGLEVEL;
-
-/****************************************************************************
-****************************************************************************/
-BOOL event_open(const char* srv_name, const char *log, POLICY_HND *hnd)
-{
- prs_struct rbuf;
- prs_struct buf;
- EVENTLOG_Q_OPEN q;
- BOOL p = False;
- BOOL valid_pol = False;
-
- struct cli_connection *con = NULL;
-
- if (!cli_connection_init(srv_name, PIPE_EVENTLOG, &con))
- {
- return False;
- }
-
- prs_init(&buf , 1024, 4, SAFETY_MARGIN, False);
- prs_init(&rbuf, 0 , 4, SAFETY_MARGIN, True );
-
- /* store the parameters */
- make_eventlog_q_open(&q, log, NULL);
-
- /* turn parameters into data stream */
- eventlog_io_q_open("", &q, &buf, 0);
-
- /* send the data on \PIPE\ */
- if (rpc_con_pipe_req(con, EVENTLOG_OPEN, &buf, &rbuf))
- {
- EVENTLOG_R_OPEN r;
-
- eventlog_io_r_open("", &r, &rbuf, 0);
- p = rbuf.offset != 0;
-
- if (p && r.status != 0)
- {
- /* report error code */
- DEBUG(0,("event_open: %s\n", get_nt_error_msg(r.status)));
- p = False;
- }
-
- if (p)
- {
- /*copy handle */
- memcpy(hnd->data, r.pol.data, sizeof(hnd->data));
- valid_pol = register_policy_hnd(hnd) &&
- set_policy_con(hnd, con,
- cli_connection_unlink);
- }
- }
-
- prs_mem_free(&rbuf);
- prs_mem_free(&buf );
-
- return p;
-}
-
-/****************************************************************************
-****************************************************************************/
-BOOL event_close( POLICY_HND *hnd)
-{
- prs_struct rbuf;
- prs_struct buf;
- EVENTLOG_Q_CLOSE q;
- BOOL p = False;
-
- prs_init(&buf , 1024, 4, SAFETY_MARGIN, False);
- prs_init(&rbuf, 0 , 4, SAFETY_MARGIN, True );
-
- /* store the parameters */
- make_eventlog_q_close(&q, hnd);
-
- /* turn parameters into data stream */
- eventlog_io_q_close("", &q, &buf, 0);
-
- /* send the data on \PIPE\ */
- if (rpc_hnd_pipe_req(hnd, EVENTLOG_CLOSE, &buf, &rbuf))
- {
- EVENTLOG_R_CLOSE r;
-
- eventlog_io_r_close("", &r, &rbuf, 0);
- p = rbuf.offset != 0;
-
- if (p && r.status != 0)
- {
- /* report error code */
- DEBUG(0,("event_close: %s\n", get_nt_error_msg(r.status)));
- p = False;
- }
-
- }
-
- prs_mem_free(&rbuf);
- prs_mem_free(&buf );
-
- close_policy_hnd(hnd);
-
- return p;
-}
-
-/****************************************************************************
-****************************************************************************/
-BOOL event_numofeventlogrec( POLICY_HND *hnd, uint32 *number)
-{
- prs_struct rbuf;
- prs_struct buf;
- EVENTLOG_Q_NUMOFEVENTLOGREC q;
- BOOL p = False;
-
- prs_init(&buf , 1024, 4, SAFETY_MARGIN, False);
- prs_init(&rbuf, 0 , 4, SAFETY_MARGIN, True );
-
- /* store the parameters */
- make_eventlog_q_numofeventlogrec(&q, hnd);
-
- /* turn parameters into data stream */
- eventlog_io_q_numofeventlogrec("", &q, &buf, 0);
-
- /* send the data on \PIPE\ */
- if (rpc_hnd_pipe_req(hnd, EVENTLOG_NUMOFEVENTLOGRECORDS, &buf, &rbuf))
- {
- EVENTLOG_R_NUMOFEVENTLOGREC r;
-
- eventlog_io_r_numofeventlogrec("", &r, &rbuf, 0);
- p = rbuf.offset != 0;
-
- if (p && r.status != 0)
- {
- /* report error code */
- DEBUG(0,("event_close: %s\n", get_nt_error_msg(r.status)));
- p = False;
- }
-
- if (p)
- {
- *number=r.number;
- }
- }
-
- prs_mem_free(&rbuf);
- prs_mem_free(&buf );
-
- return p;
-}
-
-/****************************************************************************
-****************************************************************************/
-BOOL event_readeventlog(POLICY_HND *hnd,
- uint32 number, uint32 flags, uint32 offset,
- uint32 *number_of_bytes, EVENTLOGRECORD *ev)
-{
- prs_struct rbuf;
- prs_struct buf;
- EVENTLOG_Q_READEVENTLOG q;
- EVENTLOG_R_READEVENTLOG r;
- BOOL p = False;
-
- prs_init(&buf , 1024, 4, SAFETY_MARGIN, False);
- prs_init(&rbuf, 0 , 4, SAFETY_MARGIN, True );
-
- /* store the parameters */
- make_eventlog_q_readeventlog(&q, hnd, flags, offset, *number_of_bytes);
-
- /* turn parameters into data stream */
- eventlog_io_q_readeventlog("", &q, &buf, 0);
-
- /* send the data on \PIPE\ */
- if (rpc_hnd_pipe_req(hnd, EVENTLOG_READEVENTLOG, &buf, &rbuf))
- {
- r.event=ev;
- eventlog_io_r_readeventlog("", &r, &rbuf, 0);
- p = rbuf.offset != 0;
-
- if (p)
- {
- *number_of_bytes=r.real_size;
- }
- }
-
- prs_mem_free(&rbuf);
- prs_mem_free(&buf );
-
- return p;
-}
-
diff --git a/source3/rpc_client/cli_netlogon_sync.c b/source3/rpc_client/cli_netlogon_sync.c
deleted file mode 100644
index a56e37a8ed..0000000000
--- a/source3/rpc_client/cli_netlogon_sync.c
+++ /dev/null
@@ -1,104 +0,0 @@
-/*
- * Unix SMB/Netbios implementation.
- * Version 1.9.
- * RPC Pipe client / server routines
- * Copyright (C) Andrew Tridgell 1992-1999,
- * Copyright (C) Luke Kenneth Casson Leighton 1996-1999,
- * Copyright (C) Matthew Chapman 1999,
- *
- * 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 2 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, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- */
-
-
-#ifdef SYSLOG
-#undef SYSLOG
-#endif
-
-#include "includes.h"
-
-extern int DEBUGLEVEL;
-extern pstring global_myname;
-
-BOOL synchronise_passdb(void)
-{
- SAM_DELTA_HDR hdr_deltas[MAX_SAM_DELTAS];
- SAM_DELTA_CTR deltas[MAX_SAM_DELTAS];
- uint32 num;
-
- SAM_ACCOUNT_INFO *acc;
- struct smb_passwd pwd;
- fstring nt_name;
- unsigned char smb_passwd[16];
- unsigned char smb_nt_passwd[16];
- uchar trust_passwd[16];
- fstring trust_acct;
-
- char *mode;
- BOOL success;
- BOOL ret;
- int i;
-
- fstrcpy(trust_acct, global_myname);
- fstrcat(trust_acct, "$");
-
- if (!trust_get_passwd(trust_passwd, lp_workgroup(), global_myname))
- {
- return False;
- }
-
- ret = net_sam_sync(lp_passwordserver(), global_myname, trust_acct,
- trust_passwd,
- hdr_deltas, deltas, &num);
-
- if (ret)
- {
- for (i = 0; i < num; i++)
- {
- /* Currently only interested in accounts */
- if (hdr_deltas[i].type != 5)
- {
- continue;
- }
-
- acc = &deltas[i].account_info;
- pwdb_init_smb(&pwd);
-
- pwd.user_rid = acc->user_rid;
- unistr2_to_ascii(nt_name, &(acc->uni_acct_name), sizeof(fstring)-1);
- pwd.nt_name = nt_name;
- pwd.acct_ctrl = acc->acb_info;
- pwd.pass_last_set_time = nt_time_to_unix(&(acc->pwd_last_set_time));
-
- sam_pwd_hash(acc->user_rid, smb_passwd, acc->pass.buf_lm_pwd, 0);
- sam_pwd_hash(acc->user_rid, smb_nt_passwd, acc->pass.buf_nt_pwd, 0);
- pwd.smb_passwd = smb_passwd;
- pwd.smb_nt_passwd = smb_nt_passwd;
-
- mode = "modify";
- success = mod_smbpwd_entry(&pwd, True);
-
- if (!success)
- {
- mode = "add";
- success = add_smbpwd_entry(&pwd);
- }
-
- DEBUG(0, ("Attempted to %s account for %s: %s\n", mode,
- nt_name, success ? "OK" : "FAILED"));
- }
- }
-
- return ret;
-}
diff --git a/source3/rpc_client/cli_spoolss.c b/source3/rpc_client/cli_spoolss.c
deleted file mode 100644
index 7ddbb9dbe4..0000000000
--- a/source3/rpc_client/cli_spoolss.c
+++ /dev/null
@@ -1,329 +0,0 @@
-
-/*
- * Unix SMB/Netbios implementation.
- * Version 1.9.
- * RPC Pipe client / server routines
- * Copyright (C) Andrew Tridgell 1992-1997,
- * Copyright (C) Luke Kenneth Casson Leighton 1996-1997,
- * Copyright (C) Paul Ashton 1997.
- *
- * 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 2 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, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- */
-
-
-#ifdef SYSLOG
-#undef SYSLOG
-#endif
-
-#include "includes.h"
-
-extern int DEBUGLEVEL;
-
-
-/****************************************************************************
-do a SPOOLSS Enum Printers
-****************************************************************************/
-BOOL spoolss_enum_printers(uint32 flags, const char *srv_name,
- uint32 level,
- uint32 *count,
- void ***printers)
-{
- prs_struct rbuf;
- prs_struct buf;
- SPOOL_Q_ENUMPRINTERS q_o;
- BOOL valid_pol = False;
-
- struct cli_connection *con = NULL;
-
- if (!cli_connection_init(srv_name, PIPE_SPOOLSS, &con))
- {
- return False;
- }
-
- if (count == NULL || printers == NULL) return False;
-
- prs_init(&buf , 1024, 4, SAFETY_MARGIN, False);
- prs_init(&rbuf, 0 , 4, SAFETY_MARGIN, True );
-
- /* create and send a MSRPC command with api SPOOLSS_ENUM_PRINTERS */
-
- DEBUG(5,("SPOOLSS Enum Printers (Server: %s level: %d)\n",
- srv_name, level));
-
- make_spoolss_q_enumprinters(&q_o, flags, srv_name, level, 0x200);
-
- /* turn parameters into data stream */
- spoolss_io_q_enumprinters("", &q_o, &buf, 0);
-
- /* send the data on \PIPE\ */
- if (rpc_con_pipe_req(con, SPOOLSS_ENUMPRINTERS, &buf, &rbuf))
- {
- SPOOL_R_ENUMPRINTERS r_o;
- BOOL p;
-
- ZERO_STRUCT(r_o);
-
- r_o.level = level; /* i can't believe you have to this */
-
- spoolss_io_r_enumprinters("", &r_o, &rbuf, 0);
- p = rbuf.offset != 0;
-
- if (p && r_o.status != 0)
- {
- /* report error code */
- DEBUG(5,("SPOOLSS_ENUM_PRINTERS: %s\n", get_nt_error_msg(r_o.status)));
- p = False;
- }
-
- if (p)
- {
- /* ok, at last: we're happy. return the policy handle */
- (*count) = r_o.returned;
- (*printers) = r_o.printer.info;
- valid_pol = True;
- }
- }
-
- prs_mem_free(&rbuf);
- prs_mem_free(&buf );
-
- cli_connection_unlink(con);
-
- return valid_pol;
-}
-
-/****************************************************************************
-do a SPOOLSS Enum Jobs
-****************************************************************************/
-uint32 spoolss_enum_jobs( const POLICY_HND *hnd,
- uint32 firstjob,
- uint32 numofjobs,
- uint32 level,
- uint32 *buf_size,
- uint32 *count,
- void ***jobs)
-{
- prs_struct rbuf;
- prs_struct buf;
- SPOOL_Q_ENUMJOBS q_o;
- uint32 status = 0x0;
-
- if (hnd == NULL || count == NULL || jobs == NULL)
- {
- return NT_STATUS_INVALID_PARAMETER;
- }
-
- prs_init(&buf , 1024, 4, SAFETY_MARGIN, False);
- prs_init(&rbuf, 0 , 4, SAFETY_MARGIN, True );
-
- /* create and send a MSRPC command with api SPOOLSS_ENUMJOBS */
-
- DEBUG(5,("SPOOLSS Enum Jobs level: %d)\n", level));
-
- make_spoolss_q_enumjobs(&q_o, hnd,
- firstjob, numofjobs,
- level, *buf_size);
-
- /* turn parameters into data stream */
- spoolss_io_q_enumjobs("", &q_o, &buf, 0);
-
- /* send the data on \PIPE\ */
- if (rpc_hnd_pipe_req(hnd, SPOOLSS_ENUMJOBS, &buf, &rbuf))
- {
- SPOOL_R_ENUMJOBS r_o;
- BOOL p;
-
- ZERO_STRUCT(r_o);
-
- r_o.level = level; /* i can't believe you have to this */
-
- spoolss_io_r_enumjobs("", &r_o, &rbuf, 0);
- p = rbuf.offset != 0;
-
- status = r_o.status;
-
- if (p && r_o.status != 0)
- {
- /* report error code */
- DEBUG(5,("SPOOLSS_ENUM_JOBS: %s\n", get_nt_error_msg(r_o.status)));
- p = status = ERROR_INSUFFICIENT_BUFFER;
- }
-
- if (p)
- {
- /* ok, at last: we're happy. return the policy handle */
- (*count) = r_o.numofjobs;
- (*jobs) = r_o.job.info;
- (*buf_size) = r_o.offered;
- }
- }
-
- prs_mem_free(&rbuf);
- prs_mem_free(&buf );
-
- return status;
-}
-
-/****************************************************************************
-do a SPOOLSS Open Printer Ex
-****************************************************************************/
-BOOL spoolss_open_printer_ex( const char *printername,
- uint32 cbbuf, uint32 devmod, uint32 des_access,
- const char *station, const char *username,
- POLICY_HND *hnd)
-{
- prs_struct rbuf;
- prs_struct buf;
- SPOOL_Q_OPEN_PRINTER_EX q_o;
- BOOL valid_pol = False;
- fstring srv_name;
- char *s;
-
- struct cli_connection *con = NULL;
-
- memset(srv_name, 0, sizeof(srv_name));
- fstrcpy(srv_name, printername);
-
- s = strchr(&srv_name[2], '\\');
-
- if (s != NULL)
- {
- *s = 0;
- }
-
- if (!cli_connection_init(srv_name, PIPE_SPOOLSS, &con))
- {
- return False;
- }
-
- if (hnd == NULL) return False;
-
- prs_init(&buf , 1024, 4, SAFETY_MARGIN, False);
- prs_init(&rbuf, 0 , 4, SAFETY_MARGIN, True );
-
- /* create and send a MSRPC command with api SPOOLSS_OPENPRINTEREX */
-
- DEBUG(5,("SPOOLSS Open Printer Ex\n"));
-
- make_spoolss_q_open_printer_ex(&q_o, printername,
- cbbuf, devmod, des_access,
- station, username);
-
- /* turn parameters into data stream */
- spoolss_io_q_open_printer_ex("", &q_o, &buf, 0);
-
- /* send the data on \PIPE\ */
- if (rpc_con_pipe_req(con, SPOOLSS_OPENPRINTEREX, &buf, &rbuf))
- {
- SPOOL_R_OPEN_PRINTER_EX r_o;
- BOOL p;
-
- spoolss_io_r_open_printer_ex("", &r_o, &rbuf, 0);
- p = rbuf.offset != 0;
-
- if (p && r_o.status != 0)
- {
- /* report error code */
- DEBUG(5,("SPOOLSS_OPENPRINTEREX: %s\n", get_nt_error_msg(r_o.status)));
- p = False;
- }
-
- if (p)
- {
- /* ok, at last: we're happy. return the policy handle */
- memcpy(hnd, r_o.handle.data, sizeof(hnd->data));
-
- valid_pol = register_policy_hnd(hnd) &&
- set_policy_con(hnd, con,
- cli_connection_unlink);
- }
- }
-
- prs_mem_free(&rbuf);
- prs_mem_free(&buf );
-
- return valid_pol;
-}
-
-/****************************************************************************
-do a SPOOL Close
-****************************************************************************/
-BOOL spoolss_closeprinter(POLICY_HND *hnd)
-{
- prs_struct rbuf;
- prs_struct buf;
- SPOOL_Q_CLOSEPRINTER q_c;
- BOOL valid_close = False;
-
- if (hnd == NULL) return False;
-
- /* create and send a MSRPC command with api SPOOLSS_CLOSEPRINTER */
-
- prs_init(&buf , 1024, 4, SAFETY_MARGIN, False);
- prs_init(&rbuf, 0 , 4, SAFETY_MARGIN, True );
-
- DEBUG(4,("SPOOL Close Printer\n"));
-
- /* store the parameters */
- make_spoolss_q_closeprinter(&q_c, hnd);
-
- /* turn parameters into data stream */
- spoolss_io_q_closeprinter("", &q_c, &buf, 0);
-
- /* send the data on \PIPE\ */
- if (rpc_hnd_pipe_req(hnd, SPOOLSS_CLOSEPRINTER, &buf, &rbuf))
- {
- SPOOL_R_CLOSEPRINTER r_c;
- BOOL p;
-
- spoolss_io_r_closeprinter("", &r_c, &rbuf, 0);
- p = rbuf.offset != 0;
-
- if (p && r_c.status != 0)
- {
- /* report error code */
- DEBUG(0,("SPOOL_CLOSEPRINTER: %s\n", get_nt_error_msg(r_c.status)));
- p = False;
- }
-
- if (p)
- {
- /* check that the returned policy handle is all zeros */
- uint32 i;
- valid_close = True;
-
- for (i = 0; i < sizeof(r_c.handle.data); i++)
- {
- if (r_c.handle.data[i] != 0)
- {
- valid_close = False;
- break;
- }
- }
- if (!valid_close)
- {
- DEBUG(0,("SPOOL_CLOSEPRINTER: non-zero handle returned\n"));
- }
- }
- }
-
- prs_mem_free(&rbuf);
- prs_mem_free(&buf );
-
- close_policy_hnd(hnd);
-
- return valid_close;
-}
-
diff --git a/source3/rpc_client/cli_svcctl.c b/source3/rpc_client/cli_svcctl.c
deleted file mode 100644
index b284b2661e..0000000000
--- a/source3/rpc_client/cli_svcctl.c
+++ /dev/null
@@ -1,604 +0,0 @@
-
-/*
- * Unix SMB/Netbios implementation.
- * Version 1.9.
- * RPC Pipe client / server routines
- * Copyright (C) Andrew Tridgell 1992-1998,
- * Copyright (C) Luke Kenneth Casson Leighton 1996-1998,
- * Copyright (C) Paul Ashton 1997-1998.
- *
- * 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 2 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, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- */
-
-
-#ifdef SYSLOG
-#undef SYSLOG
-#endif
-
-#include "includes.h"
-
-extern int DEBUGLEVEL;
-
-/****************************************************************************
-do a SVC Open Policy
-****************************************************************************/
-BOOL svc_open_sc_man( const char *srv_name, char *db_name,
- uint32 des_access,
- POLICY_HND *hnd)
-{
- prs_struct rbuf;
- prs_struct buf;
- SVC_Q_OPEN_SC_MAN q_o;
- BOOL valid_pol = False;
-
- struct cli_connection *con = NULL;
-
- if (!cli_connection_init(srv_name, PIPE_SVCCTL, &con))
- {
- return False;
- }
-
- if (hnd == NULL) return False;
-
- prs_init(&buf , 1024, 4, SAFETY_MARGIN, False);
- prs_init(&rbuf, 0 , 4, SAFETY_MARGIN, True );
-
- /* create and send a MSRPC command with api SVC_OPEN_SC_MAN */
-
- DEBUG(4,("SVC Open SC_MAN\n"));
-
- make_svc_q_open_sc_man(&q_o, srv_name, db_name, des_access);
-
- /* turn parameters into data stream */
- svc_io_q_open_sc_man("", &q_o, &buf, 0);
-
- /* send the data on \PIPE\ */
- if (rpc_con_pipe_req(con, SVC_OPEN_SC_MAN, &buf, &rbuf))
- {
- SVC_R_OPEN_SC_MAN r_o;
- BOOL p;
-
- ZERO_STRUCT(r_o);
-
- svc_io_r_open_sc_man("", &r_o, &rbuf, 0);
- p = rbuf.offset != 0;
-
- if (p && r_o.status != 0)
- {
- /* report error code */
- DEBUG(1,("SVC_OPEN_SC_MAN: %s\n", get_nt_error_msg(r_o.status)));
- p = False;
- }
-
- if (p)
- {
- /* ok, at last: we're happy. return the policy handle */
- memcpy(hnd, r_o.pol.data, sizeof(hnd->data));
- valid_pol = True;
- valid_pol = register_policy_hnd(hnd) &&
- set_policy_con(hnd, con,
- cli_connection_unlink);
- }
- }
-
- prs_mem_free(&rbuf);
- prs_mem_free(&buf );
-
- return valid_pol;
-}
-
-
-/****************************************************************************
-do a SVC Open Service
-****************************************************************************/
-BOOL svc_open_service( POLICY_HND *scm_hnd,
- const char *srv_name,
- uint32 des_access,
- POLICY_HND *hnd)
-{
- prs_struct rbuf;
- prs_struct buf;
- SVC_Q_OPEN_SERVICE q_o;
- BOOL valid_pol = False;
-
- struct cli_connection *con = NULL;
-
- if (!cli_connection_get(scm_hnd, &con))
- {
- return False;
- }
-
- if (hnd == NULL || scm_hnd == NULL) return False;
-
- prs_init(&buf , 1024, 4, SAFETY_MARGIN, False);
- prs_init(&rbuf, 0 , 4, SAFETY_MARGIN, True );
-
- /* create and send a MSRPC command with api SVC_OPEN_SERVICE */
-
- DEBUG(4,("SVC Open Service\n"));
-
- make_svc_q_open_service(&q_o, scm_hnd, srv_name, des_access);
-
- /* turn parameters into data stream */
- svc_io_q_open_service("", &q_o, &buf, 0);
-
- /* send the data on \PIPE\ */
- if (rpc_con_pipe_req(con, SVC_OPEN_SERVICE, &buf, &rbuf))
- {
- SVC_R_OPEN_SERVICE r_o;
- BOOL p;
-
- ZERO_STRUCT(r_o);
-
- svc_io_r_open_service("", &r_o, &rbuf, 0);
- p = rbuf.offset != 0;
-
- if (p && r_o.status != 0)
- {
- /* report error code */
- DEBUG(1,("SVC_OPEN_SC_MAN: %s\n", get_nt_error_msg(r_o.status)));
- p = False;
- }
-
- if (p)
- {
- /* ok, at last: we're happy. return the policy handle */
- memcpy(hnd, r_o.pol.data, sizeof(hnd->data));
- valid_pol = register_policy_hnd(hnd) &&
- set_policy_con(hnd, con, NULL);
- }
- }
-
- prs_mem_free(&rbuf);
- prs_mem_free(&buf );
-
- return valid_pol;
-}
-
-
-/****************************************************************************
-do a SVC Enumerate Services
-****************************************************************************/
-BOOL svc_enum_svcs( POLICY_HND *hnd,
- uint32 services_type, uint32 services_state,
- uint32 *buf_size, uint32 *resume_hnd,
- uint32 *dos_error,
- ENUM_SRVC_STATUS **svcs, uint32 *num_svcs)
-{
- prs_struct rbuf;
- prs_struct buf;
- SVC_Q_ENUM_SVCS_STATUS q_o;
- BOOL valid_pol = False;
-
- struct cli_connection *con = NULL;
-
- if (!cli_connection_get(hnd, &con))
- {
- return False;
- }
-
- if (hnd == NULL || buf_size == NULL || dos_error == NULL || num_svcs == NULL)
- {
- return False;
- }
-
- prs_init(&buf , 1024, 4, SAFETY_MARGIN, False);
- prs_init(&rbuf, 0 , 4, SAFETY_MARGIN, True );
-
- /* create and send a MSRPC command with api SVC_ENUM_SVCS_STATUS */
-
- DEBUG(4,("SVC Enum Services Status\n"));
-
- make_svc_q_enum_svcs_status(&q_o, hnd,
- services_type, services_state,
- *buf_size, *resume_hnd);
-
- /* turn parameters into data stream */
- svc_io_q_enum_svcs_status("", &q_o, &buf, 0);
-
- /* send the data on \PIPE\ */
- if (rpc_con_pipe_req(con, SVC_ENUM_SVCS_STATUS, &buf, &rbuf))
- {
- SVC_R_ENUM_SVCS_STATUS r_o;
- BOOL p;
-
- ZERO_STRUCT(r_o);
-
- svc_io_r_enum_svcs_status("", &r_o, &rbuf, 0);
- p = rbuf.offset != 0;
-
- if (p && r_o.dos_status != 0)
- {
- fstring errmsg;
-
- if (r_o.dos_status != ERRmoredata)
- {
- smb_safe_err_msg(ERRDOS, r_o.dos_status,
- errmsg, sizeof(errmsg));
- /* report error code */
- DEBUG(1,("SVC_ENUM_SVCS_STATUS: %s\n", errmsg));
- }
- p = r_o.dos_status == ERRmoredata;
- }
-
- if (p)
- {
- (*svcs) = r_o.svcs;
- (*num_svcs) = r_o.num_svcs;
- (*resume_hnd) = get_enum_hnd(&r_o.resume_hnd);
- (*buf_size) = r_o.more_buf_size;
- (*dos_error) = r_o.dos_status;
- valid_pol = True;
- }
- }
-
- prs_mem_free(&rbuf);
- prs_mem_free(&buf );
-
- return valid_pol;
-}
-
-
-/****************************************************************************
-do a SVC Stop Service
-****************************************************************************/
-BOOL svc_stop_service( POLICY_HND *hnd,
- uint32 unknown)
-{
- prs_struct rbuf;
- prs_struct buf;
- SVC_Q_STOP_SERVICE q_c;
- BOOL valid_cfg = False;
-
- struct cli_connection *con = NULL;
-
- if (!cli_connection_get(hnd, &con))
- {
- return False;
- }
-
- if (hnd == NULL) return False;
-
- /* create and send a MSRPC command with api SVC_STOP_SERVICE */
-
- prs_init(&buf , 1024, 4, SAFETY_MARGIN, False);
- prs_init(&rbuf, 0 , 4, SAFETY_MARGIN, True );
-
- DEBUG(4,("SVC Stop Service\n"));
-
- /* store the parameters */
- make_svc_q_stop_service(&q_c, hnd, unknown);
-
- /* turn parameters into data stream */
- svc_io_q_stop_service("", &q_c, &buf, 0);
-
- /* send the data on \PIPE\ */
- if (rpc_con_pipe_req(con, SVC_STOP_SERVICE, &buf, &rbuf))
- {
- SVC_R_STOP_SERVICE r_c;
- BOOL p;
-
- ZERO_STRUCT (r_c);
-
- svc_io_r_stop_service("", &r_c, &rbuf, 0);
- p = rbuf.offset != 0;
-
- if (p && r_c.status != 0)
- {
- /* report error code */
- DEBUG(1,("SVC_START_SERVICE: %s\n", get_nt_error_msg(r_c.status)));
- p = False;
- }
-
- if (p)
- {
- valid_cfg = True;
- }
- }
-
- prs_mem_free(&rbuf);
- prs_mem_free(&buf );
-
- return valid_cfg;
-}
-
-
-/****************************************************************************
-do a SVC Start Service
-****************************************************************************/
-BOOL svc_start_service( POLICY_HND *hnd,
- uint32 argc,
- char **argv)
-{
- prs_struct rbuf;
- prs_struct buf;
- SVC_Q_START_SERVICE q_c;
- BOOL valid_cfg = False;
-
- struct cli_connection *con = NULL;
-
- if (!cli_connection_get(hnd, &con))
- {
- return False;
- }
-
- if (hnd == NULL) return False;
-
- /* create and send a MSRPC command with api SVC_START_SERVICE */
-
- prs_init(&buf , 1024, 4, SAFETY_MARGIN, False);
- prs_init(&rbuf, 0 , 4, SAFETY_MARGIN, True );
-
- DEBUG(4,("SVC Start Service\n"));
-
- /* store the parameters */
- make_svc_q_start_service(&q_c, hnd, argc, argv);
-
- /* turn parameters into data stream */
- svc_io_q_start_service("", &q_c, &buf, 0);
-
- /* send the data on \PIPE\ */
- if (rpc_con_pipe_req(con, SVC_START_SERVICE, &buf, &rbuf))
- {
- SVC_R_START_SERVICE r_c;
- BOOL p;
-
- ZERO_STRUCT (r_c);
-
- svc_io_r_start_service("", &r_c, &rbuf, 0);
- p = rbuf.offset != 0;
-
- if (p && r_c.status != 0)
- {
- /* report error code */
- DEBUG(1,("SVC_START_SERVICE: %s\n", get_nt_error_msg(r_c.status)));
- p = False;
- }
-
- if (p)
- {
- valid_cfg = True;
- }
- }
-
- prs_mem_free(&rbuf);
- prs_mem_free(&buf );
-
- return valid_cfg;
-}
-
-
-/****************************************************************************
-do a SVC Query Service Config
-****************************************************************************/
-BOOL svc_query_svc_cfg( POLICY_HND *hnd,
- QUERY_SERVICE_CONFIG *cfg,
- uint32 *buf_size)
-{
- prs_struct rbuf;
- prs_struct buf;
- SVC_Q_QUERY_SVC_CONFIG q_c;
- BOOL valid_cfg = False;
-
- struct cli_connection *con = NULL;
-
- if (!cli_connection_get(hnd, &con))
- {
- return False;
- }
-
- if (hnd == NULL || buf_size == NULL) return False;
-
- /* create and send a MSRPC command with api SVC_QUERY_SVC_CONFIG */
-
- prs_init(&buf , 1024, 4, SAFETY_MARGIN, False);
- prs_init(&rbuf, 0 , 4, SAFETY_MARGIN, True );
-
- DEBUG(4,("SVC Query Service Config\n"));
-
- /* store the parameters */
- make_svc_q_query_svc_config(&q_c, hnd, *buf_size);
-
- /* turn parameters into data stream */
- svc_io_q_query_svc_config("", &q_c, &buf, 0);
-
- /* send the data on \PIPE\ */
- if (rpc_con_pipe_req(con, SVC_QUERY_SVC_CONFIG, &buf, &rbuf))
- {
- SVC_R_QUERY_SVC_CONFIG r_c;
- BOOL p;
-
- ZERO_STRUCT (r_c);
- ZERO_STRUCTP(cfg);
-
- r_c.cfg = cfg;
-
- svc_io_r_query_svc_config("", &r_c, &rbuf, 0);
- p = rbuf.offset != 0;
-
- if (p && r_c.status != 0)
- {
- /* report error code */
- DEBUG(1,("SVC_QUERY_SVC_CONFIG: %s\n", get_nt_error_msg(r_c.status)));
- p = False;
- }
-
- if (p)
- {
- valid_cfg = r_c.buf_size != 0;
- }
- }
-
- prs_mem_free(&rbuf);
- prs_mem_free(&buf );
-
- return valid_cfg;
-}
-
-
-/****************************************************************************
-do a SVC Close
-****************************************************************************/
-BOOL svc_close(POLICY_HND *hnd)
-{
- prs_struct rbuf;
- prs_struct buf;
- SVC_Q_CLOSE q_c;
- BOOL valid_close = False;
-
- struct cli_connection *con = NULL;
-
- if (!cli_connection_get(hnd, &con))
- {
- return False;
- }
-
- if (hnd == NULL) return False;
-
- /* create and send a MSRPC command with api SVC_CLOSE */
-
- prs_init(&buf , 1024, 4, SAFETY_MARGIN, False);
- prs_init(&rbuf, 0 , 4, SAFETY_MARGIN, True );
-
- DEBUG(4,("SVC Close\n"));
-
- /* store the parameters */
- make_svc_q_close(&q_c, hnd);
-
- /* turn parameters into data stream */
- svc_io_q_close("", &q_c, &buf, 0);
-
- /* send the data on \PIPE\ */
- if (rpc_con_pipe_req(con, SVC_CLOSE, &buf, &rbuf))
- {
- SVC_R_CLOSE r_c;
- BOOL p;
-
- ZERO_STRUCT(r_c);
-
- svc_io_r_close("", &r_c, &rbuf, 0);
- p = rbuf.offset != 0;
-
- if (p && r_c.status != 0)
- {
- /* report error code */
- DEBUG(1,("SVC_CLOSE: %s\n", get_nt_error_msg(r_c.status)));
- p = False;
- }
-
- if (p)
- {
- /* check that the returned policy handle is all zeros */
- uint32 i;
- valid_close = True;
-
- for (i = 0; i < sizeof(r_c.pol.data); i++)
- {
- if (r_c.pol.data[i] != 0)
- {
- valid_close = False;
- break;
- }
- }
- if (!valid_close)
- {
- DEBUG(1,("SVC_CLOSE: non-zero handle returned\n"));
- }
- }
- }
-
- close_policy_hnd(hnd);
-
- prs_mem_free(&rbuf);
- prs_mem_free(&buf );
-
- return valid_close;
-}
-
-/****************************************************************************
-do a SVC Change Service Config
-****************************************************************************/
-BOOL svc_change_svc_cfg( POLICY_HND *hnd,
- uint32 service_type, uint32 start_type,
- uint32 unknown_0,
- uint32 error_control,
- char* bin_path_name, char* load_order_grp,
- uint32 tag_id,
- char* dependencies, char* service_start_name,
- char* password,
- char* disp_name)
-{
- prs_struct rbuf;
- prs_struct buf;
- SVC_Q_CHANGE_SVC_CONFIG q_c;
- BOOL valid_cfg = False;
-
- struct cli_connection *con = NULL;
-
- if (!cli_connection_get(hnd, &con))
- {
- return False;
- }
-
- if (hnd == NULL) return False;
-
- /* create and send a MSRPC command with api SVC_CHANGE_SVC_CONFIG */
-
- prs_init(&buf , 1024, 4, SAFETY_MARGIN, False);
- prs_init(&rbuf, 0 , 4, SAFETY_MARGIN, True );
-
- DEBUG(4,("SVC Change Service Config\n"));
-
- /* store the parameters */
- make_svc_q_change_svc_config(&q_c, hnd,
- service_type, start_type,
- unknown_0, error_control,
- bin_path_name, load_order_grp,
- tag_id,
- dependencies, service_start_name,
- password, disp_name);
-
- /* turn parameters into data stream */
- svc_io_q_change_svc_config("", &q_c, &buf, 0);
-
- /* send the data on \PIPE\ */
- if (rpc_con_pipe_req(con, SVC_CHANGE_SVC_CONFIG, &buf, &rbuf))
- {
- SVC_R_CHANGE_SVC_CONFIG r_c;
- BOOL p;
-
- ZERO_STRUCT (r_c);
-
- svc_io_r_change_svc_config("", &r_c, &rbuf, 0);
- p = rbuf.offset != 0;
-
- if (p && r_c.status != 0)
- {
- /* report error code */
- DEBUG(1,("SVC_CHANGE_SVC_CONFIG: %s\n", get_nt_error_msg(r_c.status)));
- p = False;
- }
-
- if (p)
- {
- valid_cfg = True;
- }
- }
-
- prs_mem_free(&rbuf);
- prs_mem_free(&buf );
-
- return valid_cfg;
-}
diff --git a/source3/rpc_client/cli_use.c b/source3/rpc_client/cli_use.c
deleted file mode 100644
index 96122c307d..0000000000
--- a/source3/rpc_client/cli_use.c
+++ /dev/null
@@ -1,418 +0,0 @@
-/*
- Unix SMB/Netbios implementation.
- Version 1.9.
- SMB client generic functions
- Copyright (C) Andrew Tridgell 1994-1999
- Copyright (C) Luke Kenneth Casson Leighton 1996-1999
-
- 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 2 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, write to the Free Software
- Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-*/
-
-#define NO_SYSLOG
-
-#include "includes.h"
-#include "trans2.h"
-
-extern int DEBUGLEVEL;
-extern pstring scope;
-extern pstring global_myname;
-
-struct cli_use
-{
- struct cli_state *cli;
- uint32 num_users;
-};
-
-static struct cli_use **clis = NULL;
-uint32 num_clis = 0;
-
-/****************************************************************************
-terminate client connection
-****************************************************************************/
-static void cli_use_free(struct cli_use *cli)
-{
- if (cli->cli != NULL)
- {
- if (cli->cli->initialised)
- {
- cli_ulogoff(cli->cli);
- cli_shutdown(cli->cli);
- }
- free(cli->cli);
- }
-
- free(cli);
-}
-
-/****************************************************************************
-free a client array
-****************************************************************************/
-static void free_cli_array(uint32 num_entries, struct cli_use **entries)
-{
- void(*fn)(void*) = (void(*)(void*))&cli_use_free;
- free_void_array(num_entries, (void**)entries, *fn);
-}
-
-/****************************************************************************
-add a client state to the array
-****************************************************************************/
-static struct cli_use* add_cli_to_array(uint32 *len,
- struct cli_use ***array,
- struct cli_use *cli)
-{
- int i;
- for (i = 0; i < num_clis; i++)
- {
- if (clis[i] == NULL)
- {
- clis[i] = cli;
- return cli;
- }
- }
-
- return (struct cli_use*)add_item_to_array(len,
- (void***)array, (void*)cli);
-
-}
-
-/****************************************************************************
-initiate client array
-****************************************************************************/
-void init_cli_use(void)
-{
- clis = NULL;
- num_clis = 0;
-}
-
-/****************************************************************************
-terminate client array
-****************************************************************************/
-void free_cli_use(void)
-{
- free_cli_array(num_clis, clis);
- init_cli_use();
-}
-
-/****************************************************************************
-find client state. server name, user name, domain name and password must all
-match.
-****************************************************************************/
-static struct cli_use *cli_find(const char* srv_name,
- const struct ntuser_creds *usr_creds,
- BOOL reuse)
-{
- int i;
- const char *sv_name = srv_name;
- struct ntuser_creds null_usr;
-
- copy_nt_creds(&null_usr, usr_creds);
- usr_creds = &null_usr;
-
- if (strnequal("\\\\", sv_name, 2))
- {
- sv_name = &sv_name[2];
- }
-
- DEBUG(10,("cli_find: %s %s %s\n",
- srv_name,
- usr_creds->user_name,
- usr_creds->domain));
-
- for (i = 0; i < num_clis; i++)
- {
- char *cli_name = NULL;
- struct cli_use *c = clis[i];
-
- if (c == NULL) continue;
-
- cli_name = c->cli->desthost;
-
- DEBUG(10,("cli_find[%d]: %s %s %s\n",
- i, cli_name,
- c->cli->usr.user_name,
- c->cli->usr.domain));
-
- if (strnequal("\\\\", cli_name, 2))
- {
- cli_name = &cli_name[2];
- }
-
- if (!strequal(cli_name, sv_name))
- {
- continue;
- }
- if (!strequal(usr_creds->user_name, c->cli->usr.user_name))
- {
- continue;
- }
- if (!reuse &&
- !pwd_compare(&usr_creds->pwd, &c->cli->usr.pwd))
- {
- DEBUG(100,("password doesn't match\n"));
- continue;
- }
- if (usr_creds->domain[0] == 0)
- {
- return c;
- }
- if (strequal(usr_creds->domain, c->cli->usr.domain))
- {
- return c;
- }
- }
-
- return NULL;
-}
-
-/****************************************************************************
-create a new client state from user credentials
-****************************************************************************/
-static struct cli_use *cli_use_get(const char* srv_name,
- const struct ntuser_creds *usr_creds)
-{
- struct cli_use *cli = (struct cli_use*)malloc(sizeof(*cli));
-
- if (cli == NULL)
- {
- return NULL;
- }
-
- memset(cli, 0, sizeof(*cli));
-
- cli->cli = cli_initialise(NULL);
-
- if (cli->cli == NULL)
- {
- return NULL;
- }
-
- cli_init_creds(cli->cli, usr_creds);
-
- return cli;
-}
-
-/****************************************************************************
-init client state
-****************************************************************************/
-struct cli_state *cli_net_use_add(const char* srv_name,
- const struct ntuser_creds *usr_creds,
- BOOL redir,
- BOOL reuse)
-{
- struct nmb_name calling;
- struct nmb_name called;
- struct in_addr *dest_ip = NULL;
- fstring dest_host;
- struct in_addr ip;
-
- struct cli_use *cli = cli_find(srv_name, usr_creds, reuse);
-
- if (cli != NULL)
- {
- cli->num_users++;
- return cli->cli;
- }
-
- /* reuse an existing connection requested, and one was not found */
- if (usr_creds != NULL && reuse && !redir)
- {
- return False;
- }
-
- /*
- * allocate
- */
-
- cli = cli_use_get(srv_name, usr_creds);
- cli->cli->redirect = redir;
-
- if (resolve_srv_name(srv_name, dest_host, &ip))
- {
- dest_ip = &ip;
- }
- else
- {
- cli_use_free(cli);
- return NULL;
- }
-
- make_nmb_name(&called , dns_to_netbios_name(dest_host ), 32, scope);
- make_nmb_name(&calling, dns_to_netbios_name(global_myname), 0, scope);
-
- /*
- * connect
- */
-
- if (!cli_establish_connection(cli->cli,
- dest_host, dest_ip,
- &calling, &called,
- "IPC$", "IPC",
- False, True))
- {
- DEBUG(0,("cli_net_use_add: connection failed\n"));
- cli->cli = NULL;
- cli_use_free(cli);
- return NULL;
- }
-
- cli->cli->ntlmssp_cli_flgs = 0x0;
-
- add_cli_to_array(&num_clis, &clis, cli);
- cli->num_users++;
-
- return cli->cli;
-}
-
-/****************************************************************************
-delete a client state
-****************************************************************************/
-BOOL cli_net_use_del(const char* srv_name,
- const struct ntuser_creds *usr_creds,
- BOOL force_close,
- BOOL *connection_closed)
-{
- int i;
- const char *sv_name = srv_name;
-
- DEBUG(10,("cli_net_use_del: %s. force close: %s\n",
- srv_name, BOOLSTR(force_close)));
-
- if (strnequal("\\\\", sv_name, 2))
- {
- sv_name = &sv_name[2];
- }
-
- if (connection_closed != NULL)
- {
- *connection_closed = False;
- }
-
- for (i = 0; i < num_clis; i++)
- {
- char *cli_name = NULL;
-
- if (clis[i] == NULL) continue;
- if (clis[i]->cli == NULL) continue;
-
- cli_name = clis[i]->cli->desthost;
- if (strnequal("\\\\", cli_name, 2))
- {
- cli_name = &cli_name[2];
- }
-
- if (!strequal(cli_name, sv_name)) continue;
-
- if (strequal(usr_creds->user_name,
- clis[i]->cli->usr.user_name) &&
- strequal(usr_creds->domain,
- clis[i]->cli->usr.domain))
- {
- /* decrement number of users */
- clis[i]->num_users--;
-
- DEBUG(10,("idx: %i num_users now: %d\n",
- i, clis[i]->num_users));
-
- if (force_close || clis[i]->num_users == 0)
- {
- cli_use_free(clis[i]);
- clis[i] = NULL;
- if (connection_closed != NULL)
- {
- *connection_closed = True;
- }
- }
- return True;
- }
- }
-
- return False;
-}
-
-/****************************************************************************
-enumerate client states
-****************************************************************************/
-void cli_net_use_enum(uint32 *num_cons, struct use_info ***use)
-{
- int i;
-
- *num_cons = 0;
- *use = NULL;
-
- for (i = 0; i < num_clis; i++)
- {
- struct use_info item;
-
- ZERO_STRUCT(item);
-
- if (clis[i] == NULL) continue;
-
- item.connected = clis[i]->cli != NULL ? True : False;
-
- if (item.connected)
- {
- item.srv_name = clis[i]->cli->desthost;
- item.user_name = clis[i]->cli->usr.user_name;
- item.domain = clis[i]->cli->usr.domain;
- }
-
- add_use_info_to_array(num_cons, use, &item);
- }
-}
-
-
-/****************************************************************************
-wait for keyboard activity, swallowing network packets on all client states.
-****************************************************************************/
-void cli_use_wait_keyboard(void)
-{
- fd_set fds;
- struct timeval timeout;
-
- while (1)
- {
- int i;
- int maxfd = fileno(stdin);
- FD_ZERO(&fds);
- FD_SET(fileno(stdin),&fds);
- for (i = 0; i < num_clis; i++)
- {
- if (clis[i] != NULL && clis[i]->cli != NULL)
- {
- int fd = clis[i]->cli->fd;
- FD_SET(fd,&fds);
- maxfd = MAX(fd, maxfd);
- }
- }
-
- timeout.tv_sec = 20;
- timeout.tv_usec = 0;
- sys_select(maxfd+1,NULL, &fds,&timeout);
-
- if (FD_ISSET(fileno(stdin),&fds))
- return;
-
- /* We deliberately use receive_smb instead of
- client_receive_smb as we want to receive
- session keepalives and then drop them here.
- */
- for (i = 0; i < num_clis; i++)
- {
- int fd = clis[i]->cli->fd;
- if (FD_ISSET(fd,&fds))
- receive_smb(fd,clis[i]->cli->inbuf,0);
- }
- }
-}
diff --git a/source3/rpc_client/msrpc_lsarpc.c b/source3/rpc_client/msrpc_lsarpc.c
deleted file mode 100644
index 83ecc94197..0000000000
--- a/source3/rpc_client/msrpc_lsarpc.c
+++ /dev/null
@@ -1,65 +0,0 @@
-/*
- Unix SMB/Netbios implementation.
- Version 1.9.
- NT Domain Authentication SMB / MSRPC client
- Copyright (C) Andrew Tridgell 1994-1999
- Copyright (C) Luke Kenneth Casson Leighton 1996-1999
-
- 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 2 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, write to the Free Software
- Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-*/
-
-
-#ifdef SYSLOG
-#undef SYSLOG
-#endif
-
-#include "includes.h"
-#include "nterr.h"
-
-extern int DEBUGLEVEL;
-
-#define DEBUG_TESTING
-
-/****************************************************************************
-nt lsa query secret
-****************************************************************************/
-BOOL msrpc_lsa_query_secret(const char* srv_name,
- const char* secret_name,
- STRING2 *secret,
- NTTIME *last_update)
-{
- BOOL res = True;
- BOOL res1;
- BOOL res2;
-
- POLICY_HND pol_sec;
- POLICY_HND lsa_pol;
-
- /* lookup domain controller; receive a policy handle */
- res = res ? lsa_open_policy2( srv_name,
- &lsa_pol, False) : False;
-
- /* lookup domain controller; receive a policy handle */
- res1 = res ? lsa_open_secret( &lsa_pol,
- secret_name, 0x02000000, &pol_sec) : False;
-
- res2 = res1 ? lsa_query_secret(&pol_sec, secret, last_update) : False;
-
- res1 = res1 ? lsa_close(&pol_sec) : False;
-
- res = res ? lsa_close(&lsa_pol) : False;
-
- return res2;
-}
diff --git a/source3/rpc_client/msrpc_samr.c b/source3/rpc_client/msrpc_samr.c
deleted file mode 100644
index 621b218ad6..0000000000
--- a/source3/rpc_client/msrpc_samr.c
+++ /dev/null
@@ -1,1593 +0,0 @@
-/*
- Unix SMB/Netbios implementation.
- Version 1.9.
- NT Domain Authentication SMB / MSRPC client
- Copyright (C) Andrew Tridgell 1994-1999
- Copyright (C) Luke Kenneth Casson Leighton 1996-1999
-
- 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 2 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, write to the Free Software
- Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-*/
-
-
-
-#ifdef SYSLOG
-#undef SYSLOG
-#endif
-
-#include "includes.h"
-#include "nterr.h"
-
-extern int DEBUGLEVEL;
-
-#define DEBUG_TESTING
-
-BOOL req_user_info( const POLICY_HND *pol_dom,
- const char *domain,
- const DOM_SID *sid,
- uint32 user_rid,
- USER_INFO_FN(usr_inf))
-{
- SAM_USER_INFO_21 usr;
- /* send user info query, level 0x15 */
- if (get_samr_query_userinfo(
- pol_dom,
- 0x15, user_rid, &usr))
- {
- if (usr_inf != NULL)
- {
- usr_inf(domain, sid, user_rid, &usr);
- }
- return True;
- }
- return False;
-}
-
-/****************************************************************************
-SAM Query User Groups.
-****************************************************************************/
-uint32 sam_query_usergroups(
- const POLICY_HND *pol_dom,
- const char *domain,
- const DOM_SID *sid,
- uint32 user_rid,
- const char *user_name,
- uint32 *num_groups,
- DOM_GID **gid,
- char ***name,
- uint32 **type,
- USER_MEM_FN(usr_mem))
-{
- uint32 num_names = 0;
- (*gid) = NULL;
- /* send user group query */
- if (get_samr_query_usergroups(
- pol_dom,
- user_rid, num_groups, gid) &&
- gid != NULL)
- {
- uint32 i;
- uint32 *rid_mem;
-
- rid_mem = (uint32*)malloc((*num_groups) * sizeof(rid_mem[0]));
-
- if (rid_mem == NULL)
- {
- free(*gid);
- (*gid) = NULL;
- return 0;
- }
-
- for (i = 0; i < (*num_groups); i++)
- {
- rid_mem[i] = (*gid)[i].g_rid;
- }
-
- if (samr_query_lookup_rids(
- pol_dom, 0x3e8,
- (*num_groups), rid_mem,
- &num_names, name, type))
- {
- usr_mem(domain, sid,
- user_rid, user_name,
- num_names, rid_mem, *name, *type);
- }
- }
-
- return num_names;
-}
-
-static uint32 req_group_info(
- const POLICY_HND *pol_dom,
- const char *domain, const DOM_SID *sid,
- uint32 user_rid, const char *user_name,
- USER_MEM_FN(usr_mem))
-{
- uint32 num_groups;
- uint32 num_names;
- DOM_GID *gid = NULL;
- char **name = NULL;
- uint32 *type = NULL;
-
- num_names = sam_query_usergroups( pol_dom,
- domain, sid,
- user_rid, user_name,
- &num_groups, &gid,
- &name, &type, usr_mem);
-
- free_char_array(num_names, name);
- if (type != NULL)
- {
- free(type);
- }
-
- if (gid != NULL)
- {
- free(gid);
- }
-
- return num_names;
-}
-
-static void req_alias_info(
- const POLICY_HND *pol_dom,
- const char *domain,
- const DOM_SID *sid1, uint32 user_rid,
- const char *user_name,
- USER_MEM_FN(usr_mem))
-{
- uint32 num_aliases;
- uint32 *rid_mem = NULL;
- uint32 *ptr_sid;
- DOM_SID2 *als_sid;
-
- if (pol_dom == NULL)
- {
- return;
- }
-
- ptr_sid = (uint32*) malloc(sizeof(ptr_sid[0]) * 1);
- als_sid = (DOM_SID2*)malloc(sizeof(als_sid[0]) * 1);
-
- sid_copy(&als_sid[0].sid, sid1);
- sid_append_rid(&als_sid[0].sid, user_rid);
- als_sid[0].num_auths = als_sid[0].sid.num_auths;
-
- ptr_sid[0] = 1;
-
- /* send user alias query */
- if (samr_query_useraliases(
- pol_dom,
- ptr_sid, als_sid, &num_aliases, &rid_mem))
- {
- uint32 num_names;
- char **name = NULL;
- uint32 *type = NULL;
-
- uint32 *rid_copy = (uint32*)malloc(num_aliases * sizeof(*rid_copy));
-
- if (rid_copy != NULL)
- {
- uint32 i;
- for (i = 0; i < num_aliases; i++)
- {
- rid_copy[i] = rid_mem[i];
- }
- if (samr_query_lookup_rids(
- pol_dom, 0x3e8,
- num_aliases, rid_copy,
- &num_names, &name, &type))
- {
- usr_mem(domain, sid1,
- user_rid, user_name,
- num_names, rid_mem, name, type);
- }
- }
-
- free_char_array(num_names, name);
- if (type != NULL)
- {
- free(type);
- }
- }
-
- if (rid_mem != NULL)
- {
- free(rid_mem);
- rid_mem = NULL;
- }
-
- if (ptr_sid != NULL)
- {
- free(ptr_sid);
- ptr_sid = NULL;
- }
- if (als_sid != NULL)
- {
- free(als_sid);
- als_sid = NULL;
- }
-}
-
-/****************************************************************************
-experimental SAM user display info.
-****************************************************************************/
-void msrpc_sam_user( const POLICY_HND *pol_dom, const POLICY_HND *pol_blt,
- const char* domain,
- const DOM_SID *sid1,
- const DOM_SID *blt_sid1,
- uint32 user_rid,
- char *user_name,
- USER_FN(usr_fn),
- USER_INFO_FN(usr_inf_fn),
- USER_MEM_FN(usr_grp_fn),
- USER_MEM_FN(usr_als_fn))
-{
- if (usr_fn != NULL)
- {
- usr_fn(domain, sid1, user_rid, user_name);
- }
-
- if (usr_inf_fn != NULL)
- {
- req_user_info(pol_dom,
- domain, sid1,
- user_rid,
- usr_inf_fn);
- }
-
- if (usr_grp_fn != NULL)
- {
- req_group_info(pol_dom,
- domain, sid1,
- user_rid, user_name,
- usr_grp_fn);
- }
-
- if (usr_als_fn != NULL)
- {
- req_alias_info(pol_dom,
- domain, sid1,
- user_rid, user_name,
- usr_als_fn);
- req_alias_info(pol_blt,
- domain, blt_sid1,
- user_rid, user_name,
- usr_als_fn);
- }
-}
-
-/****************************************************************************
-experimental SAM user query.
-****************************************************************************/
-BOOL msrpc_sam_query_user( const char* srv_name,
- const char* domain,
- const DOM_SID *sid,
- char *user_name,
- USER_FN(usr_fn),
- USER_INFO_FN(usr_inf_fn),
- USER_MEM_FN(usr_grp_fn),
- USER_MEM_FN(usr_als_fn))
-{
- BOOL res = True;
- BOOL res1 = True;
-
- char *names[1];
- uint32 num_rids;
- uint32 rid[MAX_LOOKUP_SIDS];
- uint32 type[MAX_LOOKUP_SIDS];
- POLICY_HND sam_pol;
- POLICY_HND pol_dom;
-
- /* establish a connection. */
- res = res ? samr_connect( srv_name, 0x02000000, &sam_pol) : False;
-
- /* connect to the domain */
- res = res ? samr_open_domain( &sam_pol, 0x304, sid, &pol_dom) : False;
-
- /* look up user rid */
- names[0] = user_name;
- res1 = res ? samr_query_lookup_names( &pol_dom, 0x3e8,
- 1, names,
- &num_rids, rid, type) : False;
-
- /* send user info query */
- if (res1 && num_rids == 1)
- {
- msrpc_sam_user( &pol_dom, NULL,
- domain,
- sid, NULL,
- rid[0],
- names[0],
- usr_fn, usr_inf_fn,
- usr_grp_fn, usr_als_fn);
- }
- else
- {
- res1 = False;
- }
-
- res = res ? samr_close( &sam_pol) : False;
- res = res ? samr_close( &pol_dom) : False;
-
- return res1;
-}
-
-/****************************************************************************
-experimental SAM users enum.
-****************************************************************************/
-int msrpc_sam_enum_users( const char* srv_name,
- const char* domain,
- const DOM_SID *sid1,
- struct acct_info **sam,
- uint32 *num_sam_entries,
- USER_FN(usr_fn),
- USER_INFO_FN(usr_inf_fn),
- USER_MEM_FN(usr_grp_fn),
- USER_MEM_FN(usr_als_fn))
-{
- DOM_SID sid_1_5_20;
- uint32 user_idx;
- BOOL res = True;
- BOOL res1 = True;
- BOOL res2 = True;
- uint32 start_idx = 0x0;
- uint16 unk_0 = 0x0;
- uint16 acb_mask = 0;
- uint16 unk_1 = 0x0;
- uint32 ace_perms = 0x304; /* access control permissions */
- uint32 status;
- POLICY_HND sam_pol;
- POLICY_HND pol_dom;
- POLICY_HND pol_blt;
-
- (*sam) = NULL;
- (*num_sam_entries) = 0;
-
- string_to_sid(&sid_1_5_20, "S-1-5-32");
-
- DEBUG(5,("Number of entries:%d unk_0:%04x acb_mask:%04x unk_1:%04x\n",
- start_idx, unk_0, acb_mask, unk_1));
-
- /* establish a connection. */
- res = res ? samr_connect( srv_name, 0x02000000,
- &sam_pol) : False;
-
- /* connect to the domain */
- res1 = res ? samr_open_domain( &sam_pol, ace_perms, sid1,
- &pol_dom) : False;
-
- /* connect to the S-1-5-20 domain */
- res2 = res ? samr_open_domain( &sam_pol, ace_perms, &sid_1_5_20,
- &pol_blt) : False;
-
- if (res1)
- {
- /* read some users */
- do
- {
- status = samr_enum_dom_users(
- &pol_dom,
- &start_idx, acb_mask, unk_1, 0x100000,
- sam, num_sam_entries);
-
- } while (status == STATUS_MORE_ENTRIES);
-
-#if 0
- if ((*num_sam_entries) == 0)
- {
- report(out_hnd, "No users\n");
- }
-#endif
-
- /* query all the users */
- for (user_idx = 0; res && user_idx <
- (*num_sam_entries); user_idx++)
- {
- uint32 user_rid = (*sam)[user_idx].rid;
- char *user_name = (*sam)[user_idx].acct_name;
-
- msrpc_sam_user( &pol_dom, &pol_blt,
- domain,
- sid1, &sid_1_5_20,
- user_rid, user_name,
- usr_fn, usr_inf_fn,
- usr_grp_fn, usr_als_fn);
- }
- }
-
- res2 = res2 ? samr_close( &pol_blt) : False;
- res1 = res1 ? samr_close( &pol_dom) : False;
- res = res ? samr_close( &sam_pol) : False;
-
- if (res)
- {
- DEBUG(5,("msrpc_sam_enum_users: succeeded\n"));
- }
- else
- {
- DEBUG(5,("msrpc_sam_enum_users: failed\n"));
- }
-
- return (*num_sam_entries);
-}
-
-
-/****************************************************************************
-experimental SAM domain info query.
-****************************************************************************/
-BOOL sam_query_dominfo(const char* srv_name,
- const DOM_SID *sid1,
- uint32 switch_value, SAM_UNK_CTR *ctr)
-{
- BOOL res = True;
- BOOL res1 = True;
- BOOL res2 = True;
- uint32 ace_perms = 0x02000000; /* absolutely no idea. */
- POLICY_HND sam_pol;
- POLICY_HND pol_dom;
-
- /* establish a connection. */
- res = res ? samr_connect(
- srv_name, 0x02000000,
- &sam_pol) : False;
-
- /* connect to the domain */
- res1 = res ? samr_open_domain( &sam_pol, ace_perms, sid1,
- &pol_dom) : False;
-
- /* send a samr 0x8 command */
- res2 = res ? samr_query_dom_info(
- &pol_dom, switch_value, ctr) : False;
-
- res1 = res1 ? samr_close( &sam_pol) : False;
-
- res = res ? samr_close( &pol_dom) : False;
-
- if (res2)
- {
- DEBUG(5,("sam_query_dominfo: succeeded\n"));
- }
- else
- {
- DEBUG(5,("sam_query_dominfo: failed\n"));
- }
-
- return res2;
-}
-
-
-BOOL query_aliasinfo(
- const POLICY_HND *pol_dom,
- const char *domain,
- const DOM_SID *sid,
- uint32 alias_rid,
- ALIAS_INFO_FN(grp_inf))
-{
- ALIAS_INFO_CTR ctr;
-
- /* send alias info query */
- if (get_samr_query_aliasinfo(
- pol_dom,
- 3, /* info level */
- alias_rid, &ctr))
- {
- if (grp_inf != NULL)
- {
- grp_inf(domain, sid, alias_rid, &ctr);
- }
- return True;
- }
- return False;
-}
-
-BOOL sam_query_aliasmem(const char *srv_name,
- const POLICY_HND *pol_dom,
- uint32 alias_rid,
- uint32 *num_names,
- DOM_SID ***sids,
- char ***name,
- uint8 **type)
-{
- BOOL res3 = True;
- BOOL res4 = True;
- DOM_SID2 sid_mem[MAX_LOOKUP_SIDS];
- uint32 num_aliases = 0;
-
- *sids = NULL;
- *num_names = 0;
- *name = NULL;
- *type = NULL;
-
- /* get alias members */
- res3 = get_samr_query_aliasmem(
- pol_dom,
- alias_rid, &num_aliases, sid_mem);
-
- if (res3 && num_aliases != 0)
- {
- POLICY_HND lsa_pol;
-
- uint32 i;
- uint32 numsids = 0;
-
- for (i = 0; i < num_aliases; i++)
- {
- add_sid_to_array(&numsids, sids, &sid_mem[i].sid);
- }
-
- /* lookup domain controller; receive a policy handle */
- res3 = res3 ? lsa_open_policy( srv_name,
- &lsa_pol, True) : False;
-
- /* send lsa lookup sids call */
- res4 = res3 ? lsa_lookup_sids( &lsa_pol,
- num_aliases, *sids,
- name, type, num_names) : False;
-
- res3 = res3 ? lsa_close(&lsa_pol) : False;
- }
-
- if (!res4)
- {
- free_char_array(*num_names, *name);
- if ((*type) != NULL)
- {
- free(*type);
- }
- if ((*sids) != NULL)
- {
- free_sid_array(num_aliases, *sids);
- }
- *num_names = 0;
- *name = NULL;
- *type = NULL;
- *sids = NULL;
- }
-
- return res4;
-}
-
-BOOL req_aliasmem_info(const char* srv_name,
- const POLICY_HND *pol_dom,
- const char *domain,
- const DOM_SID *sid,
- uint32 alias_rid,
- const char *alias_name,
- ALIAS_MEM_FN(als_mem))
-{
- uint32 num_names = 0;
- char **name = NULL;
- uint8 *type = NULL;
- DOM_SID **sids = NULL;
-
- if (sam_query_aliasmem( srv_name, pol_dom, alias_rid,
- &num_names, &sids,
- &name, &type))
- {
- als_mem(domain, sid,
- alias_rid, alias_name,
- num_names, sids, name, type);
-
- free_char_array(num_names, name);
- if (type != NULL)
- {
- free(type);
- }
- if (sids != NULL)
- {
- free_sid_array(num_names, sids);
- }
- return True;
- }
- return False;
-}
-
-BOOL sam_query_groupmem(
- const POLICY_HND *pol_dom,
- uint32 group_rid,
- uint32 *num_names,
- uint32 **rid_mem,
- char ***name,
- uint32 **type)
-{
- uint32 num_mem;
- uint32 *attr_mem = NULL;
- BOOL res3;
-
- *rid_mem = NULL;
- *num_names = 0;
- *name = NULL;
- *type = NULL;
-
- /* get group members */
- res3 = get_samr_query_groupmem(
- pol_dom,
- group_rid, &num_mem, rid_mem, &attr_mem);
-
- if (res3 && num_mem != 0)
- {
- uint32 *rid_copy = (uint32*)malloc(num_mem *
- sizeof(rid_copy[0]));
-
- if (rid_copy != NULL)
- {
- uint32 i;
- for (i = 0; i < num_mem; i++)
- {
- rid_copy[i] = (*rid_mem)[i];
- }
- /* resolve names */
- res3 = samr_query_lookup_rids(
- pol_dom, 1000,
- num_mem, rid_copy, num_names, name, type);
- }
- }
- else
- {
- if (attr_mem != NULL)
- {
- free(attr_mem);
- }
- if ((*rid_mem) != NULL)
- {
- free(*rid_mem);
- }
- attr_mem = NULL;
- *rid_mem = NULL;
- }
-
- if (!res3)
- {
- free_char_array(*num_names, *name);
- if ((*type) != NULL)
- {
- free(*type);
- }
- *num_names = 0;
- *name = NULL;
- *type = NULL;
- }
-
- if (attr_mem != NULL)
- {
- free(attr_mem);
- }
-
- return res3;
-}
-
-BOOL query_groupinfo( const POLICY_HND *pol_dom,
- const char *domain,
- const DOM_SID *sid,
- uint32 group_rid,
- GROUP_INFO_FN(grp_inf))
-{
- GROUP_INFO_CTR ctr;
-
- /* send group info query */
- if (get_samr_query_groupinfo(
- pol_dom,
- 1, /* info level */
- group_rid, &ctr))
- {
- if (grp_inf != NULL)
- {
- grp_inf(domain, sid, group_rid, &ctr);
- }
- return True;
- }
- return False;
-}
-
-BOOL req_groupmem_info( const POLICY_HND *pol_dom,
- const char *domain,
- const DOM_SID *sid,
- uint32 group_rid,
- const char *group_name,
- GROUP_MEM_FN(grp_mem))
-{
- uint32 num_names = 0;
- char **name = NULL;
- uint32 *type = NULL;
- uint32 *rid_mem = NULL;
-
- if (sam_query_groupmem(pol_dom, group_rid,
- &num_names, &rid_mem, &name, &type))
- {
- grp_mem(domain, sid,
- group_rid, group_name,
- num_names, rid_mem, name, type);
-
- free_char_array(num_names, name);
- if (type != NULL)
- {
- free(type);
- }
- if (rid_mem != NULL)
- {
- free(rid_mem);
- }
- return True;
- }
- return False;
-}
-
-/****************************************************************************
-SAM Domains query.
- DOMAIN_INFO_FN(dom_inf_fn),
- DOMAIN_MEM_FN(dom_mem_fn))
-****************************************************************************/
-uint32 msrpc_sam_enum_domains( const char* srv_name,
- struct acct_info **sam,
- uint32 *num_sam_entries,
- DOMAIN_FN(dom_fn),
- DOMAIN_INFO_FN(dom_inf_fn))
-{
- BOOL res = True;
- uint32 ace_perms = 0x02000000; /* access control permissions. */
- POLICY_HND sam_pol;
- uint32 status;
-
- /* establish a connection. */
- res = res ? samr_connect( srv_name, ace_perms,
- &sam_pol) : False;
-
- (*sam) = NULL;
- (*num_sam_entries) = 0;
-
- if (res)
- {
- uint32 domain_idx;
- uint32 start_idx = 0;
- /* read some domains */
- do
- {
- status = samr_enum_domains( &sam_pol,
- &start_idx, 0x10000,
- sam, num_sam_entries);
-
- } while (status == STATUS_MORE_ENTRIES);
-
-#if 0
- if ((*num_sam_entries) == 0)
- {
- report(out_hnd, "No domains\n");
- }
-#endif
-
- for (domain_idx = 0; domain_idx < (*num_sam_entries); domain_idx++)
- {
- char *domain_name = (*sam)[domain_idx].acct_name;
-
- if (dom_fn != NULL)
- {
- dom_fn(domain_name);
- }
-
- if (dom_inf_fn != NULL)
- {
- uint32 switch_value = 2;
- SAM_UNK_CTR ctr;
- DOM_SID dom_sid;
- /* connect to the domain */
- if (samr_query_lookup_domain( &sam_pol,
- domain_name,
- &dom_sid) &&
- sam_query_dominfo(srv_name, &dom_sid,
- switch_value, &ctr))
- {
- dom_inf_fn(domain_name, &dom_sid,
- switch_value, &ctr);
- }
- }
- }
- }
-
- res = res ? samr_close(&sam_pol) : False;
-
- if (res)
- {
- DEBUG(5,("msrpc_sam_enum_domains: succeeded\n"));
- }
- else
- {
- DEBUG(5,("msrpc_sam_enum_domains: failed\n"));
- }
- return (*num_sam_entries);
-}
-
-/****************************************************************************
-SAM groups query.
-****************************************************************************/
-uint32 msrpc_sam_enum_groups( const char* srv_name,
- const char* domain,
- const DOM_SID *sid1,
- struct acct_info **sam,
- uint32 *num_sam_entries,
- GROUP_FN(grp_fn),
- GROUP_INFO_FN(grp_inf_fn),
- GROUP_MEM_FN(grp_mem_fn))
-{
- BOOL res = True;
- uint32 ace_perms = 0x02000000; /* access control permissions. */
- POLICY_HND sam_pol;
- POLICY_HND pol_dom;
- uint32 status;
-
- /* establish a connection. */
- res = res ? samr_connect( srv_name, 0x02000000,
- &sam_pol) : False;
-
- /* connect to the domain */
- res = res ? samr_open_domain( &sam_pol, ace_perms, sid1,
- &pol_dom) : False;
-
- (*sam) = NULL;
- (*num_sam_entries) = 0;
-
- if (res)
- {
- uint32 group_idx;
- uint32 start_idx = 0;
- /* read some groups */
- do
- {
- status = samr_enum_dom_groups(
- &pol_dom,
- &start_idx, 0x100000,
- sam, num_sam_entries);
-
- } while (status == STATUS_MORE_ENTRIES);
-
-#if 0
- if ((*num_sam_entries) == 0)
- {
- report(out_hnd, "No groups\n");
- }
-#endif
-
- for (group_idx = 0; group_idx < (*num_sam_entries); group_idx++)
- {
- uint32 group_rid = (*sam)[group_idx].rid;
- char *group_name = (*sam)[group_idx].acct_name;
-
- if (grp_fn != NULL)
- {
- grp_fn(domain, sid1, group_rid, group_name);
- }
-
- if (grp_inf_fn != NULL)
- {
- query_groupinfo(&pol_dom,
- domain, sid1,
- group_rid,
- grp_inf_fn);
- }
- if (grp_mem_fn != NULL)
- {
- req_groupmem_info(&pol_dom,
- domain, sid1,
- group_rid, group_name,
- grp_mem_fn);
- }
- }
- }
-
- res = res ? samr_close(&pol_dom) : False;
- res = res ? samr_close(&sam_pol) : False;
-
- if (res)
- {
- DEBUG(5,("msrpc_sam_enum_groups: succeeded\n"));
- }
- else
- {
- DEBUG(5,("msrpc_sam_enum_groups: failed\n"));
- }
- return (*num_sam_entries);
-}
-
-/****************************************************************************
-SAM aliases query.
-****************************************************************************/
-uint32 msrpc_sam_enum_aliases( const char* srv_name,
- const char* domain,
- const DOM_SID *sid1,
- struct acct_info **sam,
- uint32 *num_sam_entries,
- ALIAS_FN(als_fn),
- ALIAS_INFO_FN(als_inf_fn),
- ALIAS_MEM_FN(als_mem_fn))
-{
- BOOL res = True;
- uint32 ace_perms = 0x02000000; /* access control permissions */
- POLICY_HND sam_pol;
- POLICY_HND pol_dom;
- uint32 status = 0x0;
-
- /* establish a connection. */
- res = res ? samr_connect( srv_name, 0x02000000,
- &sam_pol) : False;
-
- /* connect to the domain */
- res = res ? samr_open_domain(
- &sam_pol, ace_perms, sid1,
- &pol_dom) : False;
-
- (*sam) = NULL;
- (*num_sam_entries) = 0;
-
- if (res)
- {
- uint32 alias_idx;
- uint32 start_idx = 0;
- /* read some groups */
- do
- {
- status = samr_enum_dom_aliases(
- &pol_dom,
- &start_idx, 0x100000,
- sam, num_sam_entries);
-
- } while (status == STATUS_MORE_ENTRIES);
-
-#if 0
- if ((*num_sam_entries) == 0)
- {
- report(out_hnd, "No aliases\n");
- }
-#endif
-
- for (alias_idx = 0; alias_idx < (*num_sam_entries); alias_idx++)
- {
- uint32 alias_rid = (*sam)[alias_idx].rid;
- char *alias_name = (*sam)[alias_idx].acct_name;
-
- if (als_fn != NULL)
- {
- als_fn(domain, sid1, alias_rid, alias_name);
- }
-
- if (als_inf_fn != NULL)
- {
- query_aliasinfo(&pol_dom,
- domain, sid1,
- alias_rid,
- als_inf_fn);
- }
- if (als_mem_fn != NULL)
- {
- req_aliasmem_info(srv_name, &pol_dom,
- domain, sid1,
- alias_rid, alias_name,
- als_mem_fn);
- }
- }
- }
-
- res = res ? samr_close(&sam_pol) : False;
- res = res ? samr_close(&pol_dom) : False;
-
- if (res)
- {
- DEBUG(5,("msrpc_sam_enum_aliases: succeeded\n"));
- }
- else
- {
- DEBUG(5,("msrpc_sam_enum_aliases: failed\n"));
- }
-
- return (*num_sam_entries);
-}
-
-/****************************************************************************
-do a SAMR create domain user
-****************************************************************************/
-BOOL create_samr_domain_user( POLICY_HND *pol_dom,
- char *acct_name, uint16 acb_info,
- const char* password, int plen,
- uint32 *rid)
-{
- POLICY_HND pol_open_user;
- BOOL ret = True;
- BOOL res1 = True;
- char pwbuf[516];
- SAM_USER_INFO_24 *p24;
- SAM_USER_INFO_16 *p16;
- SAM_USER_INFO_16 usr16;
-
- if (pol_dom == NULL || acct_name == NULL) return False;
-
- /* send create user */
- ret = samr_create_dom_user( pol_dom,
- acct_name, acb_info, 0xe005000b,
- &pol_open_user, rid);
-
- if (ret == 0x0)
- {
- samr_close(&pol_open_user);
- }
-
- if (ret != 0 && ret != (NT_STATUS_USER_EXISTS | 0xC0000000))
- {
- return False;
- }
-
- if (ret == (NT_STATUS_USER_EXISTS | 0xC0000000))
- {
- uint32 num_rids;
- char *names[1];
- uint32 type[1];
-
- names[0] = acct_name;
- res1 = samr_query_lookup_names( pol_dom, 0x3e8,
- 1, names,
- &num_rids, rid, type);
- if (res1 == False || type[0] != SID_NAME_USER)
- {
- return False;
- }
- }
-
- DEBUG(5,("create_samr_domain_user: name: %s rid 0x%x\n",
- acct_name, *rid));
-
- if (IS_BITS_SET_SOME(acb_info, ACB_NORMAL | ACB_DOMTRUST) &&
- password == NULL)
- {
- return True;
- }
-
- encode_pw_buffer(pwbuf, password, plen, False);
-
- p24 = (SAM_USER_INFO_24*)malloc(sizeof(SAM_USER_INFO_24));
- if (p24 == NULL)
- {
- return False;
- }
-
- make_sam_user_info24(p24, pwbuf, plen);
-
- res1 = set_samr_set_userinfo( pol_dom, 0x18, *rid, (void*)p24);
-
- if (res1 == False)
- {
- return False;
- }
-
- /* send set user info */
- res1 = get_samr_query_userinfo( pol_dom, 0x10, *rid, (void*)&usr16);
-
- if (res1 == False)
- {
- return False;
- }
-
- if (usr16.acb_info != acb_info)
- {
- p16 = (SAM_USER_INFO_16 *) malloc(sizeof(SAM_USER_INFO_16));
- if (p16 == NULL)
- {
- return False;
- }
- p16->acb_info = usr16.acb_info;
-
- res1 = set_samr_set_userinfo2( pol_dom, 0x10, *rid, (void*)p16);
- }
-
- return res1;
-}
-
-/****************************************************************************
-do a SAMR create domain alias
-****************************************************************************/
-BOOL create_samr_domain_alias( POLICY_HND *pol_open_domain,
- const char *acct_name, const char *acct_desc,
- uint32 *rid)
-{
- POLICY_HND pol_open_alias;
- ALIAS_INFO_CTR ctr;
- BOOL ret = True;
-
- if (pol_open_domain == NULL || acct_name == NULL || acct_desc == NULL) return False;
-
- /* send create alias */
- if (!samr_create_dom_alias(
- pol_open_domain,
- acct_name,
- &pol_open_alias, rid))
- {
- return False;
- }
-
- DEBUG(5,("create_samr_domain_alias: name: %s rid 0x%x\n",
- acct_name, *rid));
-
- ctr.switch_value1 = 3;
- make_samr_alias_info3(&ctr.alias.info3, acct_desc);
-
- /* send set alias info */
- if (!samr_set_aliasinfo(
- &pol_open_alias,
- &ctr))
- {
- DEBUG(5,("create_samr_domain_alias: error in samr_set_aliasinfo\n"));
- ret = False;
- }
-
- return samr_close(&pol_open_alias) && ret;
-}
-
-/****************************************************************************
-do a SAMR create domain group
-****************************************************************************/
-BOOL create_samr_domain_group(
- POLICY_HND *pol_open_domain,
- const char *acct_name, const char *acct_desc,
- uint32 *rid)
-{
- POLICY_HND pol_open_group;
- GROUP_INFO_CTR ctr;
- BOOL ret = True;
-
- if (pol_open_domain == NULL || acct_name == NULL || acct_desc == NULL) return False;
-
- /* send create group*/
- if (!samr_create_dom_group(
- pol_open_domain,
- acct_name,
- &pol_open_group, rid))
- {
- return False;
- }
-
- DEBUG(5,("create_samr_domain_group: name: %s rid 0x%x\n",
- acct_name, *rid));
-
- ctr.switch_value1 = 4;
- ctr.switch_value2 = 4;
- make_samr_group_info4(&ctr.group.info4, acct_desc);
-
- /* send user groups query */
- if (!samr_set_groupinfo(
- &pol_open_group,
- &ctr))
- {
- DEBUG(5,("create_samr_domain_group: error in samr_set_groupinfo\n"));
- ret = False;
- }
-
- return samr_close(&pol_open_group) && ret;
-}
-
-/****************************************************************************
-do a SAMR query user groups
-****************************************************************************/
-BOOL get_samr_query_usergroups( const POLICY_HND *pol_open_domain,
- uint32 user_rid,
- uint32 *num_groups, DOM_GID **gid)
-{
- POLICY_HND pol_open_user;
- BOOL ret = True;
-
- if (pol_open_domain == NULL || num_groups == NULL || gid == NULL) return False;
-
- /* send open domain (on user sid) */
- if (!samr_open_user(
- pol_open_domain,
- 0x02011b, user_rid,
- &pol_open_user))
- {
- return False;
- }
-
- /* send user groups query */
- if (!samr_query_usergroups(
- &pol_open_user,
- num_groups, gid))
- {
- DEBUG(5,("samr_query_usergroups: error in query user groups\n"));
- ret = False;
- }
-
- return samr_close(&pol_open_user) && ret;
-}
-
-/****************************************************************************
-do a SAMR delete group
-****************************************************************************/
-BOOL delete_samr_dom_group(
- POLICY_HND *pol_open_domain,
- uint32 group_rid)
-{
- POLICY_HND pol_open_group;
-
- if (pol_open_domain == NULL) return False;
-
- /* send open domain (on group rid) */
- if (!samr_open_group(pol_open_domain,
- 0x00000010, group_rid,
- &pol_open_group))
- {
- return False;
- }
-
- /* send group delete */
- if (!samr_delete_dom_group(&pol_open_group))
-
- {
- DEBUG(5,("delete_samr_dom_group: error in delete domain group\n"));
- samr_close(&pol_open_group);
- return False;
- }
-
- return True;
-}
-
-
-/****************************************************************************
-do a SAMR query group members
-****************************************************************************/
-BOOL get_samr_query_groupmem(
- const POLICY_HND *pol_open_domain,
- uint32 group_rid, uint32 *num_mem,
- uint32 **rid, uint32 **attr)
-{
- POLICY_HND pol_open_group;
- BOOL ret = True;
-
- if (pol_open_domain == NULL || num_mem == NULL || rid == NULL || attr == NULL) return False;
-
- /* send open domain (on group sid) */
- if (!samr_open_group( pol_open_domain,
- 0x00000010, group_rid,
- &pol_open_group))
- {
- return False;
- }
-
- /* send group info query */
- if (!samr_query_groupmem(&pol_open_group, num_mem, rid, attr))
-
- {
- DEBUG(5,("samr_query_group: error in query group members\n"));
- ret = False;
- }
-
- return samr_close(&pol_open_group) && ret;
-}
-
-/****************************************************************************
-do a SAMR delete alias
-****************************************************************************/
-BOOL delete_samr_dom_alias(
- POLICY_HND *pol_open_domain,
- uint32 alias_rid)
-{
- POLICY_HND pol_open_alias;
-
- if (pol_open_domain == NULL) return False;
-
- /* send open domain (on alias rid) */
- if (!samr_open_alias(pol_open_domain,
- 0x000f001f, alias_rid, &pol_open_alias))
- {
- return False;
- }
-
- /* send alias delete */
- if (!samr_delete_dom_alias(&pol_open_alias))
-
- {
- DEBUG(5,("delete_samr_dom_alias: error in delete domain alias\n"));
- samr_close(&pol_open_alias);
- return False;
- }
-
- return True;
-}
-
-
-/****************************************************************************
-do a SAMR query alias members
-****************************************************************************/
-BOOL get_samr_query_aliasmem(
- const POLICY_HND *pol_open_domain,
- uint32 alias_rid, uint32 *num_mem, DOM_SID2 *sid)
-{
- POLICY_HND pol_open_alias;
- BOOL ret = True;
-
- if (pol_open_domain == NULL || num_mem == NULL || sid == NULL) return False;
-
- /* send open domain (on alias sid) */
- if (!samr_open_alias( pol_open_domain,
- 0x000f001f, alias_rid,
- &pol_open_alias))
- {
- return False;
- }
-
- /* send alias info query */
- if (!samr_query_aliasmem( &pol_open_alias, num_mem, sid))
-
- {
- DEBUG(5,("samr_query_alias: error in query alias members\n"));
- ret = False;
- }
-
- return samr_close(&pol_open_alias) && ret;
-}
-
-/****************************************************************************
-do a SAMR set user info
-****************************************************************************/
-BOOL set_samr_set_userinfo2(
- POLICY_HND *pol_open_domain,
- uint32 info_level,
- uint32 user_rid, void *usr)
-{
- POLICY_HND pol_open_user;
- BOOL ret = True;
-
- if (pol_open_domain == NULL || usr == NULL) return False;
-
- /* send open domain (on user sid) */
- if (!samr_open_user(
- pol_open_domain,
- 0x000601b4, user_rid,
- &pol_open_user))
- {
- return False;
- }
-
- /* send user info query */
- if (!samr_set_userinfo2(
- &pol_open_user,
- info_level, usr))
- {
- DEBUG(5,("samr_set_userinfo: error in query user info, level 0x%x\n",
- info_level));
- ret = False;
- }
-
- return samr_close(&pol_open_user) && ret;
-}
-
-/****************************************************************************
-do a SAMR set user info
-****************************************************************************/
-BOOL set_samr_set_userinfo(
- POLICY_HND *pol_open_domain,
- uint32 info_level,
- uint32 user_rid, void *usr)
-{
- POLICY_HND pol_open_user;
- BOOL ret = True;
-
- if (pol_open_domain == NULL || usr == NULL) return False;
-
- /* send open domain (on user sid) */
- if (!samr_open_user(
- pol_open_domain,
- 0x000601b4, user_rid,
- &pol_open_user))
- {
- return False;
- }
-
- /* send user info query */
- if (!samr_set_userinfo(
- &pol_open_user,
- info_level, usr))
- {
- DEBUG(5,("samr_set_userinfo: error in query user info, level 0x%x\n",
- info_level));
- ret = False;
- }
-
- return samr_close(&pol_open_user) && ret;
-}
-
-/****************************************************************************
-do a SAMR query user info
-****************************************************************************/
-BOOL get_samr_query_userinfo(
- const POLICY_HND *pol_open_domain,
- uint32 info_level,
- uint32 user_rid, void *usr)
-{
- POLICY_HND pol_open_user;
- BOOL ret = True;
-
- if (pol_open_domain == NULL || usr == NULL) return False;
-
- /* send open domain (on user sid) */
- if (!samr_open_user(
- pol_open_domain,
- 0x02011b, user_rid,
- &pol_open_user))
- {
- return False;
- }
-
- /* send user info query */
- if (!samr_query_userinfo(
- &pol_open_user,
- info_level, usr))
- {
- DEBUG(5,("samr_query_userinfo: error in query user info, level 0x%x\n",
- info_level));
- ret = False;
- }
-
- return samr_close(&pol_open_user) && ret;
-}
-
-/****************************************************************************
-do a SAMR query group info
-****************************************************************************/
-BOOL get_samr_query_groupinfo(
- const POLICY_HND *pol_open_domain,
- uint32 info_level,
- uint32 group_rid, GROUP_INFO_CTR *ctr)
-{
- POLICY_HND pol_open_group;
- BOOL ret = True;
-
- if (pol_open_domain == NULL || ctr == NULL) return False;
-
- bzero(ctr, sizeof(*ctr));
-
- /* send open domain (on group sid) */
- if (!samr_open_group(
- pol_open_domain,
- 0x02000000, group_rid, &pol_open_group))
- {
- return False;
- }
-
- /* send group info query */
- if (!samr_query_groupinfo(
- &pol_open_group,
- info_level, ctr))
- {
- DEBUG(5,("samr_query_groupinfo: error in query group info, level 0x%x\n",
- info_level));
- ret = False;
- }
-
- return samr_close(&pol_open_group) && ret;
-}
-
-/****************************************************************************
-do a SAMR query alias info
-****************************************************************************/
-BOOL get_samr_query_aliasinfo(
- const POLICY_HND *pol_open_domain,
- uint32 info_level,
- uint32 alias_rid, ALIAS_INFO_CTR *ctr)
-{
- POLICY_HND pol_open_alias;
- BOOL ret = True;
-
- if (pol_open_domain == NULL || ctr == NULL) return False;
-
- bzero(ctr, sizeof(*ctr));
-
- /* send open domain (on alias sid) */
- if (!samr_open_alias(
- pol_open_domain,
- 0x02000000, alias_rid, &pol_open_alias))
- {
- return False;
- }
-
- /* send alias info query */
- if (!samr_query_aliasinfo(
- &pol_open_alias,
- info_level, ctr))
- {
- DEBUG(5,("samr_query_aliasinfo: error in query alias info, level 0x%x\n",
- info_level));
- ret = False;
- }
-
- return samr_close(&pol_open_alias) && ret;
-}
-
-/****************************************************************************
-SAM create domain user.
-****************************************************************************/
-BOOL msrpc_sam_create_dom_user(const char* srv_name, DOM_SID *sid1,
- char *acct_name, uint16 acb_info,
- const char *password, int plen,
- uint32 *rid)
-{
- BOOL res = True;
- BOOL res1 = True;
- BOOL res2 = True;
- uint32 ace_perms = 0x02000000; /* absolutely no idea. */
- uint32 user_rid;
- POLICY_HND sam_pol;
- POLICY_HND pol_dom;
-
- /* establish a connection. */
- res = res ? samr_connect(
- srv_name, 0x02000000,
- &sam_pol) : False;
-
- /* connect to the domain */
- res1 = res ? samr_open_domain(
- &sam_pol, ace_perms, sid1,
- &pol_dom) : False;
-
- /* create a domain user */
- res2 = res1 ? create_samr_domain_user( &pol_dom,
- acct_name,
- acb_info, password, plen, &user_rid) : False;
-
- res1 = res1 ? samr_close( &pol_dom) : False;
- res = res ? samr_close( &sam_pol) : False;
-
- if (res2)
- {
- DEBUG(5,("msrpc_sam_create_dom_user: succeeded\n"));
- }
- else
- {
- DEBUG(5,("msrpc_sam_create_dom_user: failed\n"));
- }
-
- return res2;
-}
-
-/****************************************************************************
-experimental SAM query display info.
-****************************************************************************/
-BOOL msrpc_sam_query_dispinfo(const char* srv_name, const char* domain,
- DOM_SID *sid1,
- uint16 switch_value,
- uint32 *num_entries, SAM_DISPINFO_CTR *ctr,
- DISP_FN(disp_fn))
-{
- BOOL res = True;
- BOOL res1 = True;
- uint32 ace_perms = 0x304; /* absolutely no idea. */
- POLICY_HND sam_pol;
- POLICY_HND pol_dom;
-
- /* establish a connection. */
- res = res ? samr_connect( srv_name, 0x02000000, &sam_pol) : False;
-
- /* connect to the domain */
- res = res ? samr_open_domain( &sam_pol, ace_perms, sid1,
- &pol_dom) : False;
-
- /* send a samr query_disp_info command */
- res1 = res ? samr_query_dispinfo( &pol_dom, switch_value,
- num_entries, ctr) : False;
-
- res = res ? samr_close(&sam_pol) : False;
- res = res ? samr_close(&pol_dom) : False;
-
- if (res1 && disp_fn != NULL)
- {
- disp_fn(domain, sid1, switch_value, *num_entries, ctr);
- }
-
- return res1;
-}
-