summaryrefslogtreecommitdiff
path: root/source3/rpc_server
diff options
context:
space:
mode:
Diffstat (limited to 'source3/rpc_server')
-rw-r--r--source3/rpc_server/srv_lsa_hnd.c42
-rw-r--r--source3/rpc_server/srv_lsa_nt.c15
-rw-r--r--source3/rpc_server/srv_reg_nt.c2
-rw-r--r--source3/rpc_server/srv_samr.c2
-rw-r--r--source3/rpc_server/srv_spoolss_nt.c14
5 files changed, 32 insertions, 43 deletions
diff --git a/source3/rpc_server/srv_lsa_hnd.c b/source3/rpc_server/srv_lsa_hnd.c
index 93492f671d..10b9bef1be 100644
--- a/source3/rpc_server/srv_lsa_hnd.c
+++ b/source3/rpc_server/srv_lsa_hnd.c
@@ -58,26 +58,28 @@ static struct policy
static struct bitmap *bmap;
+static uint32 pol_hnd_low = 0;
+static uint32 pol_hnd_high = 0;
-/****************************************************************************
- create a unique policy handle
-****************************************************************************/
-static void create_pol_hnd(POLICY_HND *hnd)
-{
- static uint32 pol_hnd_low = 0;
- static uint32 pol_hnd_high = 0;
+/*******************************************************************
+ Creates a POLICY_HND structure.
+********************************************************************/
+void create_policy_handle(POLICY_HND *hnd, uint32 *hnd_low, uint32 *hnd_high)
+{
if (hnd == NULL) return;
- /* i severely doubt that pol_hnd_high will ever be non-zero... */
- pol_hnd_low++;
- if (pol_hnd_low == 0) pol_hnd_high++;
+ (*hnd_low)++;
+ if (*hnd_low == 0) (*hnd_high)++;
+
+ ZERO_STRUCTP(hnd);
- SIVAL(hnd->data, 0 , 0x0); /* first bit must be null */
- SIVAL(hnd->data, 4 , pol_hnd_low ); /* second bit is incrementing */
- SIVAL(hnd->data, 8 , pol_hnd_high); /* second bit is incrementing */
- SIVAL(hnd->data, 12, time(NULL)); /* something random */
- SIVAL(hnd->data, 16, sys_getpid()); /* something more random */
+ SIVAL(&hnd->data1, 0 , 0); /* first bit must be null */
+ SIVAL(&hnd->data2, 0 , *hnd_low ); /* second bit is incrementing */
+ SSVAL(&hnd->data3, 0 , *hnd_high); /* second bit is incrementing */
+ SSVAL(&hnd->data4, 0 , (*hnd_high>>16)); /* second bit is incrementing */
+ SIVAL(hnd->data5, 0, time(NULL)); /* something random */
+ SIVAL(hnd->data5, 4, sys_getpid()); /* something more random */
}
/****************************************************************************
@@ -117,15 +119,15 @@ BOOL open_lsa_policy_hnd(POLICY_HND *hnd)
p->open = True;
p->pnum = i;
- create_pol_hnd(hnd);
- memcpy(&p->pol_hnd, hnd, sizeof(*hnd));
+ create_policy_handle(hnd, &pol_hnd_low, &pol_hnd_high);
+ p->pol_hnd = *hnd;
bitmap_set(bmap, i);
DLIST_ADD(Policy, p);
DEBUG(4,("Opened policy hnd[%x] ", i));
- dump_data(4, (char *)hnd->data, sizeof(hnd->data));
+ dump_data(4, (char *)hnd, sizeof(hnd));
return True;
}
@@ -140,13 +142,13 @@ static struct policy *find_lsa_policy(POLICY_HND *hnd)
for (p=Policy;p;p=p->next) {
if (memcmp(&p->pol_hnd, hnd, sizeof(*hnd)) == 0) {
DEBUG(4,("Found policy hnd[%x] ", p->pnum));
- dump_data(4, (char *)hnd->data, sizeof(hnd->data));
+ dump_data(4, (char *)hnd, sizeof(hnd));
return p;
}
}
DEBUG(4,("Policy not found: "));
- dump_data(4, (char *)hnd->data, sizeof(hnd->data));
+ dump_data(4, (char *)hnd, sizeof(hnd));
return NULL;
}
diff --git a/source3/rpc_server/srv_lsa_nt.c b/source3/rpc_server/srv_lsa_nt.c
index 98910b5812..ee2f38b715 100644
--- a/source3/rpc_server/srv_lsa_nt.c
+++ b/source3/rpc_server/srv_lsa_nt.c
@@ -275,20 +275,19 @@ static void init_reply_lookup_sids(LSA_R_LOOKUP_SIDS *r_l,
r_l->status = NT_STATUS_NO_PROBLEMO;
}
+static uint32 lsa_hnd_low = 0;
+static uint32 lsa_hnd_high = 0;
+
/***************************************************************************
_lsa_open_policy2.
***************************************************************************/
uint32 _lsa_open_policy2(pipes_struct *p, LSA_Q_OPEN_POL2 *q_u, LSA_R_OPEN_POL2 *r_u)
{
- int i;
-
/* lkclXXXX having decoded it, ignore all fields in the open policy! */
/* set up the LSA QUERY INFO response */
-
- for (i = 4; i < POL_HND_SIZE; i++)
- r_u->pol.data[i] = i;
+ create_policy_handle(&r_u->pol, &lsa_hnd_low, &lsa_hnd_high);
return NT_STATUS_NOPROBLEMO;
}
@@ -299,14 +298,10 @@ uint32 _lsa_open_policy2(pipes_struct *p, LSA_Q_OPEN_POL2 *q_u, LSA_R_OPEN_POL2
uint32 _lsa_open_policy(pipes_struct *p, LSA_Q_OPEN_POL *q_u, LSA_R_OPEN_POL *r_u)
{
- int i;
-
/* lkclXXXX having decoded it, ignore all fields in the open policy! */
/* set up the LSA QUERY INFO response */
-
- for (i = 4; i < POL_HND_SIZE; i++)
- r_u->pol.data[i] = i;
+ create_policy_handle(&r_u->pol, &lsa_hnd_low, &lsa_hnd_high);
return NT_STATUS_NOPROBLEMO;
}
diff --git a/source3/rpc_server/srv_reg_nt.c b/source3/rpc_server/srv_reg_nt.c
index 4d35542fc2..4bd97abb65 100644
--- a/source3/rpc_server/srv_reg_nt.c
+++ b/source3/rpc_server/srv_reg_nt.c
@@ -37,7 +37,7 @@ extern int DEBUGLEVEL;
uint32 _reg_close(pipes_struct *p, REG_Q_CLOSE *q_u, REG_R_CLOSE *r_u)
{
/* set up the REG unknown_1 response */
- memset((char *)r_u->pol.data, '\0', POL_HND_SIZE);
+ ZERO_STRUCT(r_u->pol);
/* close the policy handle */
if (!close_lsa_policy_hnd(&q_u->pol))
diff --git a/source3/rpc_server/srv_samr.c b/source3/rpc_server/srv_samr.c
index eb24f672a9..2f4143bd6a 100644
--- a/source3/rpc_server/srv_samr.c
+++ b/source3/rpc_server/srv_samr.c
@@ -357,7 +357,7 @@ static BOOL samr_reply_close_hnd(SAMR_Q_CLOSE_HND *q_u,
SAMR_R_CLOSE_HND r_u;
/* set up the SAMR unknown_1 response */
- memset((char *)r_u.pol.data, '\0', POL_HND_SIZE);
+ ZERO_STRUCT(r_u.pol);
/* close the policy handle */
if (close_lsa_policy_hnd(&(q_u->pol)))
diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c
index 5c40052295..0fb38b84db 100644
--- a/source3/rpc_server/srv_spoolss_nt.c
+++ b/source3/rpc_server/srv_spoolss_nt.c
@@ -84,8 +84,8 @@ static ubi_dlList counter_list;
static struct cli_state cli;
static uint32 smb_connections=0;
-#define OPEN_HANDLE(pnum) ((pnum!=NULL) && (pnum->open!=False) && (IVAL(pnum->printer_hnd.data,16)==(uint32)sys_getpid()))
-#define OUR_HANDLE(pnum) ((pnum==NULL)?"NULL":(IVAL(pnum->data,16)==sys_getpid()?"OURS":"OTHER"))
+#define OPEN_HANDLE(pnum) ((pnum!=NULL) && (pnum->open!=False) && (IVAL(pnum->printer_hnd.data5,4)==(uint32)sys_getpid()))
+#define OUR_HANDLE(pnum) ((pnum==NULL)?"NULL":(IVAL(pnum->data5,4)==(uint32)sys_getpid()?"OURS":"OTHER"))
/* translate between internal status numbers and NT status numbers */
static int nt_printj_status(int v)
@@ -215,15 +215,7 @@ static void create_printer_hnd(POLICY_HND *hnd)
if (hnd == NULL) return;
- /* i severely doubt that prt_hnd_high will ever be non-zero... */
- prt_hnd_low++;
- if (prt_hnd_low == 0) prt_hnd_high++;
-
- SIVAL(hnd->data, 0 , 0x0); /* first bit must be null */
- SIVAL(hnd->data, 4 , prt_hnd_low ); /* second bit is incrementing */
- SIVAL(hnd->data, 8 , prt_hnd_high); /* second bit is incrementing */
- SIVAL(hnd->data, 12, time(NULL)); /* something random */
- SIVAL(hnd->data, 16, sys_getpid()); /* something more random */
+ create_policy_handle(hnd, &prt_hnd_low, &prt_hnd_high);
}
/****************************************************************************