/*The following definitions come from rpc_server/srv_lsa_hnd.c */
#if OLD_NTDOMAIN
+void create_policy_handle(POLICY_HND *hnd, uint32 *hnd_low, uint32 *hnd_high);
void init_lsa_policy_hnd(void);
BOOL open_lsa_policy_hnd(POLICY_HND *hnd);
int find_lsa_policy_by_hnd(POLICY_HND *hnd);
} DOM_GID;
-#define POL_HND_SIZE 20
-
/* POLICY_HND */
typedef struct lsa_policy_info
{
- uint8 data[POL_HND_SIZE]; /* policy handle */
-
+ uint32 data1;
+ uint32 data2;
+ uint16 data3;
+ uint16 data4;
+ uint8 data5[8];
} POLICY_HND;
-
/*
* A client connection's state, pipe name,
* user credentials, etc...
#define JOB_WRITE STANDARD_RIGHTS_WRITE_ACCESS|JOB_ACCESS_ADMINISTER
#define JOB_EXECUTE STANDARD_RIGHTS_EXECUTE_ACCESS|JOB_ACCESS_ADMINISTER
-#define POLICY_HND_SIZE 20
-
#define ONE_VALUE 01
#define TWO_VALUE 02
#define POINTER 03
*************************************************************/
BOOL copy_policy_hnd (POLICY_HND *dest, const POLICY_HND *src)
{
- int i;
-
/* if we have no destination, return an error */
if (dest == NULL)
return False;
{
/* if POLICY_HND internals ever changes,
this will need to be fixed */
- memset (dest->data, 0, POLICY_HND_SIZE);
+ ZERO_STRUCTP(dest);
return True;
}
- /* copy the src handle to the dest */
- for (i=0; i<POLICY_HND_SIZE; i++)
- dest->data[i] = src->data[i];
-
+ *dest = *src;
return True;
}
/* if the POLICY_HND field(s) are ever changed, this
will need to be updated. Probably should be a set of
support function for dealing with POLICY_HND */
- return (memcmp(x->hnd.data, y->hnd.data, POLICY_HND_SIZE) == 0);
+ return (memcmp(&x->hnd, &y->hnd, sizeof(POLICY_HND)) == 0);
}
/***************************************************************
return False;
} else {
/* ok, at last: we're happy. return the policy handle */
- memcpy(hnd, r_o.pol.data, sizeof(hnd->data));
+ *hnd = r_o.pol;
}
prs_mem_free(&rbuf);
prs_struct buf;
LSA_Q_CLOSE q_c;
LSA_R_CLOSE r_c;
- int i;
if (hnd == NULL)
return False;
/* check that the returned policy handle is all zeros */
- for (i = 0; i < sizeof(r_c.pol.data); i++) {
- if (r_c.pol.data[i] != 0) {
- DEBUG(0,("LSA_CLOSE: non-zero handle returned\n"));
- prs_mem_free(&rbuf);
- return False;
- }
+ if (IVAL(&r_c.pol.data1,0) || IVAL(&r_c.pol.data2,0) || SVAL(&r_c.pol.data3,0) ||
+ SVAL(&r_c.pol.data4,0) || IVAL(r_c.pol.data5,0) || IVAL(r_c.pol.data5,4) ) {
+ DEBUG(0,("LSA_CLOSE: non-zero handle returned\n"));
+ prs_mem_free(&rbuf);
+ return False;
}
prs_mem_free(&rbuf);
}
/* ok, at last: we're happy. return the policy handle */
- memcpy(hnd, r_o.pol.data, sizeof(hnd->data));
+ *hnd = r_o.pol;
prs_mem_free(&rbuf);
}
/* ok, at last: we're happy. return the policy handle */
- memcpy(hnd, r_o.pol.data, sizeof(hnd->data));
+ *hnd = r_o.pol;
prs_mem_free(&rbuf);
return False;
}
- memcpy(key, r_o.key_pol.data, sizeof(key->data));
+ *key = r_o.key_pol;
prs_mem_free(&rbuf);
return False;
}
- memcpy(key_hnd, r_o.pol.data, sizeof(key_hnd->data));
+ *key_hnd = r_o.pol;
prs_mem_free(&rbuf);
prs_struct buf;
REG_Q_CLOSE q_c;
REG_R_CLOSE r_c;
- int i;
if (hnd == NULL)
return False;
/* check that the returned policy handle is all zeros */
- for (i = 0; i < sizeof(r_c.pol.data); i++) {
- if (r_c.pol.data[i] != 0) {
+ if (IVAL(&r_c.pol.data1,0) || IVAL(&r_c.pol.data2,0) || SVAL(&r_c.pol.data3,0) ||
+ SVAL(&r_c.pol.data4,0) || IVAL(r_c.pol.data5,0) || IVAL(r_c.pol.data5,4) ) {
prs_mem_free(&rbuf);
DEBUG(0,("REG_CLOSE: non-zero handle returned\n"));
return False;
- }
}
prs_mem_free(&rbuf);
prs_struct rdata;
SAMR_Q_CLOSE_HND q_c;
SAMR_R_CLOSE_HND r_c;
- int i;
if (hnd == NULL)
return False;
/* check that the returned policy handle is all zeros */
- for (i = 0; i < sizeof(r_c.pol.data); i++) {
- if (r_c.pol.data[i] != 0) {
+ if (IVAL(&r_c.pol.data1,0) || IVAL(&r_c.pol.data2,0) || SVAL(&r_c.pol.data3,0) ||
+ SVAL(&r_c.pol.data4,0) || IVAL(r_c.pol.data5,0) || IVAL(r_c.pol.data5,4) ) {
DEBUG(0,("SAMR_CLOSE_HND: non-zero handle returned\n"));
prs_mem_free(&rdata);
return False;
- }
}
prs_mem_free(&rdata);
if(!prs_align(ps))
return False;
+
+ if(UNMARSHALLING(ps))
+ ZERO_STRUCTP(pol);
- if(!prs_uint8s (False, "data", ps, depth, pol->data, POL_HND_SIZE))
+ if (!prs_uint32("data1", ps, depth, &pol->data1))
+ return False;
+ if (!prs_uint32("data2", ps, depth, &pol->data2))
+ return False;
+ if (!prs_uint16("data3", ps, depth, &pol->data3))
+ return False;
+ if (!prs_uint16("data4", ps, depth, &pol->data4))
+ return False;
+ if(!prs_uint8s (False, "data5", ps, depth, pol->data5, sizeof(pol->data5)))
return False;
return True;
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 */
}
/****************************************************************************
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;
}
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;
}
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;
}
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;
}
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))
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)))
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)
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);
}
/****************************************************************************