Sync up handle creation with 2.2 branch. We can now join AS/U domains and
authorJeremy Allison <jra@samba.org>
Wed, 7 Mar 2001 23:59:13 +0000 (23:59 +0000)
committerJeremy Allison <jra@samba.org>
Wed, 7 Mar 2001 23:59:13 +0000 (23:59 +0000)
authenticate against them. Big/little endian issues fixed.
Jeremy.
(This used to be commit 0e6a34510ed598eaec7fe71a9c91fda528a4675c)

13 files changed:
source3/include/proto.h
source3/include/rpc_misc.h
source3/include/rpc_spoolss.h
source3/lib/util_list.c
source3/rpc_client/cli_lsarpc.c
source3/rpc_client/cli_reg.c
source3/rpc_client/cli_samr.c
source3/rpc_parse/parse_misc.c
source3/rpc_server/srv_lsa_hnd.c
source3/rpc_server/srv_lsa_nt.c
source3/rpc_server/srv_reg_nt.c
source3/rpc_server/srv_samr.c
source3/rpc_server/srv_spoolss_nt.c

index d9154cca6fe0a9ee33e484d59c7027bcd3477657..a119390d0d380c718738d7856388ea7ae64159b0 100644 (file)
@@ -3311,6 +3311,7 @@ BOOL api_ntlsa_rpc(pipes_struct *p);
 /*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);
index 1fbf87f134fe0918052b94852174a5c7344a7e90..5152df8e0f4e0053cbcbaa6ee4f1b8b826c9b4d7 100644 (file)
@@ -288,16 +288,16 @@ typedef struct gid_info
 
 } 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...
index 82719b6bc9bda53cd63c917a135bdcf1088a2474..798b32bb7ec82705b3c38c5fa16dc120ea4a60ff 100755 (executable)
 #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
index ea262b5db52a1e49144da4f26a36d414a7c1c896..19354c878431ea45c1b8ac230bf62c64aee7948b 100644 (file)
@@ -193,8 +193,6 @@ static void* generic_list_locate (GENERIC_LIST *l, void *search,
  *************************************************************/
 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;
@@ -205,14 +203,11 @@ BOOL copy_policy_hnd (POLICY_HND *dest, const POLICY_HND *src)
        {
                /* 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;
 }
 
@@ -240,7 +235,7 @@ BOOL compare_rpc_hnd_node(const RPC_HND_NODE *x,
        /* 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);
 }
 
 /***************************************************************
index 03a5cad709331c91b3cbeb3817078292f7d1a762..9ba13552bc52b9448e0c8cb7ee81fe8ac27708ac 100644 (file)
@@ -87,7 +87,7 @@ BOOL do_lsa_open_policy(struct cli_state *cli,
                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);
@@ -207,7 +207,6 @@ BOOL do_lsa_close(struct cli_state *cli, POLICY_HND *hnd)
        prs_struct buf; 
        LSA_Q_CLOSE q_c;
        LSA_R_CLOSE r_c;
-       int i;
 
        if (hnd == NULL)
                return False;
@@ -252,12 +251,11 @@ BOOL do_lsa_close(struct cli_state *cli, POLICY_HND *hnd)
 
        /* 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);
index 96e27c5ce66ece28b69e62e26551d99cc6ead8d0..32439e9b5d4d70b091c5b7e39af928f0db3f7d11 100644 (file)
@@ -126,7 +126,7 @@ BOOL do_reg_open_hklm(struct cli_state *cli, uint16 unknown_0, uint32 level,
        }
 
        /* 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);
 
@@ -187,7 +187,7 @@ BOOL do_reg_open_hku(struct cli_state *cli, uint16 unknown_0, uint32 level,
        }
 
        /* 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);
 
@@ -755,7 +755,7 @@ BOOL do_reg_create_key(struct cli_state *cli, POLICY_HND *hnd,
                return False;
        }
 
-       memcpy(key, r_o.key_pol.data, sizeof(key->data));
+       *key = r_o.key_pol;
 
        prs_mem_free(&rbuf);
 
@@ -1003,7 +1003,7 @@ BOOL do_reg_open_entry(struct cli_state *cli, POLICY_HND *hnd,
                return False;
        }
 
-       memcpy(key_hnd, r_o.pol.data, sizeof(key_hnd->data));
+       *key_hnd = r_o.pol;
 
        prs_mem_free(&rbuf);
 
@@ -1019,7 +1019,6 @@ BOOL do_reg_close(struct cli_state *cli, POLICY_HND *hnd)
        prs_struct buf; 
        REG_Q_CLOSE q_c;
        REG_R_CLOSE r_c;
-       int i;
 
        if (hnd == NULL)
                return False;
@@ -1066,12 +1065,11 @@ BOOL do_reg_close(struct cli_state *cli, POLICY_HND *hnd)
 
        /* 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);
index dbc10f7682c5ca2a5b23102d85292d1c7bdfacf3..f8c10abae1165e364cd89de79777ce96939a7888 100644 (file)
@@ -765,7 +765,6 @@ BOOL do_samr_close(struct cli_state *cli, POLICY_HND *hnd)
        prs_struct rdata;
        SAMR_Q_CLOSE_HND q_c;
        SAMR_R_CLOSE_HND r_c;
-       int i;
 
        if (hnd == NULL)
                return False;
@@ -810,12 +809,11 @@ BOOL do_samr_close(struct cli_state *cli, POLICY_HND *hnd)
 
        /* 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);
index 0a65c09493a8444e17e23b29012f15c62b32c2ac..81602a1dc407f43259b202e2d660f606b5b4420b 100644 (file)
@@ -1438,8 +1438,19 @@ BOOL smb_io_pol_hnd(char *desc, POLICY_HND *pol, prs_struct *ps, int depth)
 
        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;
index 93492f671d3574cc99bac774bdad8f7b23119442..10b9bef1be1a7ac117d8e059b2c505260dc81536 100644 (file)
@@ -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;
 }
index 98910b58125eebaf5a57cc2f820f7ded49c8a983..ee2f38b7152e20c9e19426fa5b84c56c5e64cc48 100644 (file)
@@ -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;
 }
index 4d35542fc26cf442350ee9a4bab90380d45e10e3..4bd97abb6589e0e220ff84ee98b3ddadd3ebff14 100644 (file)
@@ -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))
index eb24f672a991cd554bbe2f6d0259675961ab30e5..2f4143bd6afc8dccf0436bafa6427d7350c538c3 100644 (file)
@@ -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)))
index 5c400522951a255f519ba296ed5d2f5d8ca0b2cc..0fb38b84db24a81696ecae9051b407a7d755c621 100644 (file)
@@ -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);
 }
 
 /****************************************************************************