The branch, master has been updated
       via  f7bc844 s3:rpc_client: map fault codes to NTSTATUS with 
dcerpc_fault_to_nt_status()
       via  e7cf720 s3:winbindd: let winbindd_lookup_names() use 
dcerpc_binding_handle functions
       via  7309daa s3:winbindd: let winbindd_lookup_sids() 
dcerpc_binding_handle functions
       via  c0441b1 lib/util: add RBVAL, RBVALS, RSBVAL and RSRBVALS macros
       via  5b32708 s3:includes: simplify INO_T_VAL macros
       via  d7aa2eb s3:includes: simplify BIG_UINT macros
       via  9127e55 s3:smbd/trans2: make use of BVAL() and remove ugly 
LARGE_SMB_OFF_T ifdef's
      from  fb05e82 Fix license info for talloc in manpage.

http://gitweb.samba.org/?p=samba.git;a=shortlog;h=master


- Log -----------------------------------------------------------------
commit f7bc84409a7a6736ec2cf1110dd7200a954e3b7e
Author: Stefan Metzmacher <me...@samba.org>
Date:   Sun Apr 24 00:00:40 2011 +0200

    s3:rpc_client: map fault codes to NTSTATUS with dcerpc_fault_to_nt_status()
    
    Most fault codes have a NTSTATUS representation, so use that.
    
    This brings the fault handling in common with the source4/librpc/rpc code,
    which make it possible to share more highlevel code, between source3 and
    source4 as the error checking can be the same now.
    
    metze
    
    Autobuild-User: Stefan Metzmacher <me...@samba.org>
    Autobuild-Date: Sun Apr 24 10:44:53 CEST 2011 on sn-devel-104

commit e7cf7204e60552b45952325f343ea894fda21346
Author: Stefan Metzmacher <me...@samba.org>
Date:   Sat Apr 23 23:57:19 2011 +0200

    s3:winbindd: let winbindd_lookup_names() use dcerpc_binding_handle functions
    
    metze

commit 7309daa532c9689d64ce3f33da522f23635213d6
Author: Stefan Metzmacher <me...@samba.org>
Date:   Sat Apr 23 23:56:27 2011 +0200

    s3:winbindd: let winbindd_lookup_sids() dcerpc_binding_handle functions
    
    metze

commit c0441b17e6580de65d87d28bfd9ae72d09a3508f
Author: Stefan Metzmacher <me...@samba.org>
Date:   Sat Apr 23 11:01:34 2011 +0200

    lib/util: add RBVAL, RBVALS, RSBVAL and RSRBVALS macros
    
    They pull and push [u]int64_t values in big endian.
    
    metze

commit 5b327085775f279976c66cdd5f105132fda0965a
Author: Stefan Metzmacher <me...@samba.org>
Date:   Sat Apr 23 11:15:30 2011 +0200

    s3:includes: simplify INO_T_VAL macros
    
    metze

commit d7aa2eb7b664c10551cb45c36d3b564d829e9d44
Author: Stefan Metzmacher <me...@samba.org>
Date:   Sat Apr 23 11:10:05 2011 +0200

    s3:includes: simplify BIG_UINT macros
    
    metze

commit 9127e555ab043000adc516a9177e43812e52fd4b
Author: Stefan Metzmacher <me...@samba.org>
Date:   Sat Apr 23 10:30:59 2011 +0200

    s3:smbd/trans2: make use of BVAL() and remove ugly LARGE_SMB_OFF_T ifdef's
    
    We rely on uint64_t for a long time now...
    
    metze

-----------------------------------------------------------------------

Summary of changes:
 lib/util/byteorder.h              |   17 ++++++---
 source3/include/includes.h        |   15 ++++----
 source3/lib/netapi/user.c         |    2 +-
 source3/libnet/libnet_join.c      |    2 +-
 source3/rpc_client/cli_pipe.c     |    6 +---
 source3/smbd/trans2.c             |   30 +---------------
 source3/winbindd/winbindd_cm.c    |    2 +-
 source3/winbindd/winbindd_msrpc.c |   67 +++++++++++++++++++++++-------------
 source3/winbindd/winbindd_pam.c   |   10 +++---
 9 files changed, 72 insertions(+), 79 deletions(-)


Changeset truncated at 500 lines:

diff --git a/lib/util/byteorder.h b/lib/util/byteorder.h
index 59ad837..6bcf71e 100644
--- a/lib/util/byteorder.h
+++ b/lib/util/byteorder.h
@@ -201,18 +201,29 @@ static __inline__ void st_le32(uint32_t *addr, const 
uint32_t val)
 
 #endif /* not CAREFUL_ALIGNMENT */
 
+/* 64 bit macros */
+#define BVAL(p, ofs) (IVAL(p,ofs) | (((uint64_t)IVAL(p,(ofs)+4)) << 32))
+#define BVALS(p, ofs) ((int64_t)BVAL(p,ofs))
+#define SBVAL(p, ofs, v) (SIVAL(p,ofs,(v)&0xFFFFFFFF), 
SIVAL(p,(ofs)+4,((uint64_t)(v))>>32))
+#define SBVALS(p, ofs, v) (SBVAL(p,ofs,(uint64_t)v))
+
 /* now the reverse routines - these are used in nmb packets (mostly) */
 #define SREV(x) ((((x)&0xFF)<<8) | (((x)>>8)&0xFF))
 #define IREV(x) ((SREV(x)<<16) | (SREV((x)>>16)))
+#define BREV(x) ((IREV(x)<<32) | (IREV((x)>>32)))
 
 #define RSVAL(buf,pos) SREV(SVAL(buf,pos))
 #define RSVALS(buf,pos) SREV(SVALS(buf,pos))
 #define RIVAL(buf,pos) IREV(IVAL(buf,pos))
 #define RIVALS(buf,pos) IREV(IVALS(buf,pos))
+#define RBVAL(buf,pos) BREV(BVAL(buf,pos))
+#define RBVALS(buf,pos) BREV(BVALS(buf,pos))
 #define RSSVAL(buf,pos,val) SSVAL(buf,pos,SREV(val))
 #define RSSVALS(buf,pos,val) SSVALS(buf,pos,SREV(val))
 #define RSIVAL(buf,pos,val) SIVAL(buf,pos,IREV(val))
 #define RSIVALS(buf,pos,val) SIVALS(buf,pos,IREV(val))
+#define RSBVAL(buf,pos,val) SBVAL(buf,pos,BREV(val))
+#define RSBVALS(buf,pos,val) SBVALS(buf,pos,BREV(val))
 
 /* Alignment macros. */
 #define ALIGN4(p,base) ((p) + ((4 - (PTR_DIFF((p), (base)) & 3)) & 3))
@@ -222,10 +233,4 @@ static __inline__ void st_le32(uint32_t *addr, const 
uint32_t val)
 /* macros for accessing SMB protocol elements */
 #define VWV(vwv) ((vwv)*2)
 
-/* 64 bit macros */
-#define BVAL(p, ofs) (IVAL(p,ofs) | (((uint64_t)IVAL(p,(ofs)+4)) << 32))
-#define BVALS(p, ofs) ((int64_t)BVAL(p,ofs))
-#define SBVAL(p, ofs, v) (SIVAL(p,ofs,(v)&0xFFFFFFFF), 
SIVAL(p,(ofs)+4,((uint64_t)(v))>>32))
-#define SBVALS(p, ofs, v) (SBVAL(p,ofs,(uint64_t)v))
-
 #endif /* _BYTEORDER_H */
diff --git a/source3/include/includes.h b/source3/include/includes.h
index a76942f..8f220df 100644
--- a/source3/include/includes.h
+++ b/source3/include/includes.h
@@ -308,10 +308,10 @@ typedef sig_atomic_t volatile SIG_ATOMIC_T;
 #endif
 
 #ifdef LARGE_SMB_INO_T
-#define SINO_T_VAL(p, ofs, v) (SIVAL((p),(ofs),(v)&0xFFFFFFFF), 
SIVAL((p),(ofs)+4,(v)>>32))
-#define INO_T_VAL(p, ofs) ((SMB_INO_T)(((uint64_t)(IVAL(p,ofs)))| 
(((uint64_t)(IVAL(p,(ofs)+4))) << 32)))
+#define SINO_T_VAL(p, ofs, v) SBVAL(p, ofs, v)
+#define INO_T_VAL(p, ofs) ((SMB_INO_T)BVAL(p, ofs))
 #else 
-#define SINO_T_VAL(p, ofs, v) (SIVAL(p,ofs,v),SIVAL(p,(ofs)+4,0))
+#define SINO_T_VAL(p, ofs, v) SBVAL(p, ofs, ((uint64_t)(v)) & UINT32_MAX)
 #define INO_T_VAL(p, ofs) ((SMB_INO_T)(IVAL((p),(ofs))))
 #endif
 
@@ -323,11 +323,10 @@ typedef sig_atomic_t volatile SIG_ATOMIC_T;
 #  endif
 #endif
 
-#define SBIG_UINT(p, ofs, v) (SIVAL(p,ofs,(v)&0xFFFFFFFF), 
SIVAL(p,(ofs)+4,(v)>>32))
-#define BIG_UINT(p, ofs) ((((uint64_t) IVAL(p,(ofs)+4))<<32)|IVAL(p,ofs))
-#define IVAL2_TO_SMB_BIG_UINT(buf,off) ( (((uint64_t)(IVAL((buf),(off)))) & 
((uint64_t)0xFFFFFFFF)) | \
-               (( ((uint64_t)(IVAL((buf),(off+4)))) & ((uint64_t)0xFFFFFFFF) ) 
<< 32 ) )
-
+/* TODO: remove this macros */
+#define SBIG_UINT(p, ofs, v) SBVAL(p, ofs, v)
+#define BIG_UINT(p, ofs) BVAL(p, ofs)
+#define IVAL2_TO_SMB_BIG_UINT(p, ofs) BVAL(p, ofs)
 
 /* this should really be a 64 bit type if possible */
 typedef uint64_t br_off;
diff --git a/source3/lib/netapi/user.c b/source3/lib/netapi/user.c
index 63be7ac..653ece1 100644
--- a/source3/lib/netapi/user.c
+++ b/source3/lib/netapi/user.c
@@ -322,7 +322,7 @@ static NTSTATUS set_user_info_USER_INFO_X(TALLOC_CTX *ctx,
                                                  25,
                                                  &user_info,
                                                  &result);
-               if (NT_STATUS_EQUAL(status, 
NT_STATUS(DCERPC_FAULT_INVALID_TAG))) {
+               if (NT_STATUS_EQUAL(status, 
NT_STATUS_RPC_ENUM_VALUE_OUT_OF_RANGE)) {
 
                        user_info.info23.info = info21;
 
diff --git a/source3/libnet/libnet_join.c b/source3/libnet/libnet_join.c
index 1e866c3..c3693a8 100644
--- a/source3/libnet/libnet_join.c
+++ b/source3/libnet/libnet_join.c
@@ -1074,7 +1074,7 @@ static NTSTATUS libnet_join_joindomain_rpc(TALLOC_CTX 
*mem_ctx,
                                          &user_info,
                                          &result);
 
-       if (NT_STATUS_EQUAL(status, NT_STATUS(DCERPC_FAULT_INVALID_TAG))) {
+       if (NT_STATUS_EQUAL(status, NT_STATUS_RPC_ENUM_VALUE_OUT_OF_RANGE)) {
 
                /* retry with level 24 */
 
diff --git a/source3/rpc_client/cli_pipe.c b/source3/rpc_client/cli_pipe.c
index d7f990a..55cc5f8 100644
--- a/source3/rpc_client/cli_pipe.c
+++ b/source3/rpc_client/cli_pipe.c
@@ -469,11 +469,7 @@ static NTSTATUS cli_pipe_validate_current_pdu(TALLOC_CTX 
*mem_ctx,
                          pkt->u.fault.status),
                          rpccli_pipe_txt(talloc_tos(), cli)));
 
-               if (NT_STATUS_IS_OK(NT_STATUS(pkt->u.fault.status))) {
-                       return NT_STATUS_UNSUCCESSFUL;
-               } else {
-                       return NT_STATUS(pkt->u.fault.status);
-               }
+               return dcerpc_fault_to_nt_status(pkt->u.fault.status);
 
        default:
                DEBUG(0, (__location__ "Unknown packet type %u received "
diff --git a/source3/smbd/trans2.c b/source3/smbd/trans2.c
index 507ae9b..830504c 100644
--- a/source3/smbd/trans2.c
+++ b/source3/smbd/trans2.c
@@ -3733,36 +3733,10 @@ cap_low = 0x%x, cap_high = 0x%x\n",
                                /* unknown_1 24 NULL bytes in pdata*/
 
                                /* the soft quotas 8 bytes (uint64_t)*/
-                               quotas.softlim = (uint64_t)IVAL(pdata,24);
-#ifdef LARGE_SMB_OFF_T
-                               quotas.softlim |= (((uint64_t)IVAL(pdata,28)) 
<< 32);
-#else /* LARGE_SMB_OFF_T */
-                               if ((IVAL(pdata,28) != 0)&&
-                                       ((quotas.softlim != 0xFFFFFFFF)||
-                                       (IVAL(pdata,28)!=0xFFFFFFFF))) {
-                                       /* more than 32 bits? */
-                                       reply_nterror(
-                                               req,
-                                               NT_STATUS_INVALID_PARAMETER);
-                                       return;
-                               }
-#endif /* LARGE_SMB_OFF_T */
+                               quotas.softlim = BVAL(pdata,24);
 
                                /* the hard quotas 8 bytes (uint64_t)*/
-                               quotas.hardlim = (uint64_t)IVAL(pdata,32);
-#ifdef LARGE_SMB_OFF_T
-                               quotas.hardlim |= (((uint64_t)IVAL(pdata,36)) 
<< 32);
-#else /* LARGE_SMB_OFF_T */
-                               if ((IVAL(pdata,36) != 0)&&
-                                       ((quotas.hardlim != 0xFFFFFFFF)||
-                                       (IVAL(pdata,36)!=0xFFFFFFFF))) {
-                                       /* more than 32 bits? */
-                                       reply_nterror(
-                                               req,
-                                               NT_STATUS_INVALID_PARAMETER);
-                                       return;
-                               }
-#endif /* LARGE_SMB_OFF_T */
+                               quotas.hardlim = BVAL(pdata,32);
 
                                /* quota_flags 2 bytes **/
                                quotas.qflags = SVAL(pdata,40);
diff --git a/source3/winbindd/winbindd_cm.c b/source3/winbindd/winbindd_cm.c
index 1473d33..3a701b9 100644
--- a/source3/winbindd/winbindd_cm.c
+++ b/source3/winbindd/winbindd_cm.c
@@ -1985,7 +1985,7 @@ static void set_dc_type_and_flags_connect( struct 
winbindd_domain *domain )
                 * no_dssetup mode here as well to get domain->initialized
                 * set - gd */
 
-               if (NT_STATUS_V(status) == DCERPC_FAULT_OP_RNG_ERROR) {
+               if (NT_STATUS_EQUAL(status, 
NT_STATUS_RPC_PROCNUM_OUT_OF_RANGE)) {
                        goto no_dssetup;
                }
 
diff --git a/source3/winbindd/winbindd_msrpc.c 
b/source3/winbindd/winbindd_msrpc.c
index 8986598..921cdb5 100644
--- a/source3/winbindd/winbindd_msrpc.c
+++ b/source3/winbindd/winbindd_msrpc.c
@@ -1057,14 +1057,15 @@ static NTSTATUS msrpc_password_policy(struct 
winbindd_domain *domain,
        return status;
 }
 
-typedef NTSTATUS (*lookup_sids_fn_t)(struct rpc_pipe_client *cli,
+typedef NTSTATUS (*lookup_sids_fn_t)(struct dcerpc_binding_handle *h,
                                     TALLOC_CTX *mem_ctx,
                                     struct policy_handle *pol,
                                     int num_sids,
                                     const struct dom_sid *sids,
                                     char ***pdomains,
                                     char ***pnames,
-                                    enum lsa_SidType **ptypes);
+                                    enum lsa_SidType **ptypes,
+                                    NTSTATUS *result);
 
 NTSTATUS winbindd_lookup_sids(TALLOC_CTX *mem_ctx,
                              struct winbindd_domain *domain,
@@ -1075,15 +1076,17 @@ NTSTATUS winbindd_lookup_sids(TALLOC_CTX *mem_ctx,
                              enum lsa_SidType **types)
 {
        NTSTATUS status;
+       NTSTATUS result;
        struct rpc_pipe_client *cli = NULL;
+       struct dcerpc_binding_handle *b = NULL;
        struct policy_handle lsa_policy;
        unsigned int orig_timeout;
-       lookup_sids_fn_t lookup_sids_fn = rpccli_lsa_lookup_sids;
+       lookup_sids_fn_t lookup_sids_fn = dcerpc_lsa_lookup_sids;
 
        if (domain->can_do_ncacn_ip_tcp) {
                status = cm_connect_lsa_tcp(domain, mem_ctx, &cli);
                if (NT_STATUS_IS_OK(status)) {
-                       lookup_sids_fn = rpccli_lsa_lookup_sids3;
+                       lookup_sids_fn = dcerpc_lsa_lookup_sids3;
                        goto lookup;
                }
                domain->can_do_ncacn_ip_tcp = false;
@@ -1095,27 +1098,30 @@ NTSTATUS winbindd_lookup_sids(TALLOC_CTX *mem_ctx,
        }
 
  lookup:
+       b = cli->binding_handle;
+
        /*
         * This call can take a long time
         * allow the server to time out.
         * 35 seconds should do it.
         */
-       orig_timeout = rpccli_set_timeout(cli, 35000);
+       orig_timeout = dcerpc_binding_handle_set_timeout(b, 35000);
 
-       status = lookup_sids_fn(cli,
+       status = lookup_sids_fn(b,
                                mem_ctx,
                                &lsa_policy,
                                num_sids,
                                sids,
                                domains,
                                names,
-                               types);
+                               types,
+                               &result);
 
        /* And restore our original timeout. */
-       rpccli_set_timeout(cli, orig_timeout);
+       dcerpc_binding_handle_set_timeout(b, orig_timeout);
 
-       if (NT_STATUS_V(status) == DCERPC_FAULT_ACCESS_DENIED ||
-           NT_STATUS_V(status) == DCERPC_FAULT_SEC_PKG_ERROR) {
+       if (NT_STATUS_EQUAL(status, NT_STATUS_ACCESS_DENIED) ||
+           NT_STATUS_EQUAL(status, NT_STATUS_RPC_SEC_PKG_ERROR)) {
                /*
                 * This can happen if the schannel key is not
                 * valid anymore, we need to invalidate the
@@ -1130,18 +1136,23 @@ NTSTATUS winbindd_lookup_sids(TALLOC_CTX *mem_ctx,
                return status;
        }
 
-       return status;
+       if (!NT_STATUS_IS_OK(result)) {
+               return result;
+       }
+
+       return NT_STATUS_OK;
 }
 
-typedef NTSTATUS (*lookup_names_fn_t)(struct rpc_pipe_client *cli,
+typedef NTSTATUS (*lookup_names_fn_t)(struct dcerpc_binding_handle *h,
                                      TALLOC_CTX *mem_ctx,
                                      struct policy_handle *pol,
-                                     int num_names,
+                                     uint32_t num_names,
                                      const char **names,
                                      const char ***dom_names,
-                                     int level,
+                                     enum lsa_LookupNamesLevel level,
                                      struct dom_sid **sids,
-                                     enum lsa_SidType **types);
+                                     enum lsa_SidType **types,
+                                     NTSTATUS *result);
 
 NTSTATUS winbindd_lookup_names(TALLOC_CTX *mem_ctx,
                               struct winbindd_domain *domain,
@@ -1152,15 +1163,17 @@ NTSTATUS winbindd_lookup_names(TALLOC_CTX *mem_ctx,
                               enum lsa_SidType **types)
 {
        NTSTATUS status;
+       NTSTATUS result;
        struct rpc_pipe_client *cli = NULL;
+       struct dcerpc_binding_handle *b = NULL;
        struct policy_handle lsa_policy;
        unsigned int orig_timeout = 0;
-       lookup_names_fn_t lookup_names_fn = rpccli_lsa_lookup_names;
+       lookup_names_fn_t lookup_names_fn = dcerpc_lsa_lookup_names;
 
        if (domain->can_do_ncacn_ip_tcp) {
                status = cm_connect_lsa_tcp(domain, mem_ctx, &cli);
                if (NT_STATUS_IS_OK(status)) {
-                       lookup_names_fn = rpccli_lsa_lookup_names4;
+                       lookup_names_fn = dcerpc_lsa_lookup_names4;
                        goto lookup;
                }
                domain->can_do_ncacn_ip_tcp = false;
@@ -1172,15 +1185,16 @@ NTSTATUS winbindd_lookup_names(TALLOC_CTX *mem_ctx,
        }
 
  lookup:
+       b = cli->binding_handle;
 
        /*
         * This call can take a long time
         * allow the server to time out.
         * 35 seconds should do it.
         */
-       orig_timeout = rpccli_set_timeout(cli, 35000);
+       orig_timeout = dcerpc_binding_handle_set_timeout(b, 35000);
 
-       status = lookup_names_fn(cli,
+       status = lookup_names_fn(b,
                                 mem_ctx,
                                 &lsa_policy,
                                 num_names,
@@ -1188,13 +1202,14 @@ NTSTATUS winbindd_lookup_names(TALLOC_CTX *mem_ctx,
                                 domains,
                                 1,
                                 sids,
-                                types);
+                                types,
+                                &result);
 
        /* And restore our original timeout. */
-       rpccli_set_timeout(cli, orig_timeout);
+       dcerpc_binding_handle_set_timeout(b, orig_timeout);
 
-       if (NT_STATUS_V(status) == DCERPC_FAULT_ACCESS_DENIED ||
-           NT_STATUS_V(status) == DCERPC_FAULT_SEC_PKG_ERROR) {
+       if (NT_STATUS_EQUAL(status, NT_STATUS_ACCESS_DENIED) ||
+           NT_STATUS_EQUAL(status, NT_STATUS_RPC_SEC_PKG_ERROR)) {
                /*
                 * This can happen if the schannel key is not
                 * valid anymore, we need to invalidate the
@@ -1209,7 +1224,11 @@ NTSTATUS winbindd_lookup_names(TALLOC_CTX *mem_ctx,
                return status;
        }
 
-       return status;
+       if (!NT_STATUS_IS_OK(result)) {
+               return result;
+       }
+
+       return NT_STATUS_OK;
 }
 
 /* the rpc backend methods are exposed via this structure */
diff --git a/source3/winbindd/winbindd_pam.c b/source3/winbindd/winbindd_pam.c
index 76e06d3..6b086c8 100644
--- a/source3/winbindd/winbindd_pam.c
+++ b/source3/winbindd/winbindd_pam.c
@@ -1248,7 +1248,7 @@ static NTSTATUS winbind_samlogon_retry_loop(struct 
winbindd_domain *domain,
                                        info3);
                }
 
-               if ((NT_STATUS_V(result) == DCERPC_FAULT_OP_RNG_ERROR)
+               if (NT_STATUS_EQUAL(result, NT_STATUS_RPC_PROCNUM_OUT_OF_RANGE)
                    && domain->can_do_samlogon_ex) {
                        DEBUG(3, ("Got a DC that can not do NetSamLogonEx, "
                                  "retrying with NetSamLogon\n"));
@@ -1938,10 +1938,10 @@ enum winbindd_result winbindd_dual_pam_chauthtok(struct 
winbindd_domain *contact
         * short to comply with the samr_ChangePasswordUser3 idl - gd */
 
        /* only fallback when the chgpasswd_user3 call is not supported */
-       if ((NT_STATUS_EQUAL(result, NT_STATUS(DCERPC_FAULT_OP_RNG_ERROR))) ||
-                  (NT_STATUS_EQUAL(result, NT_STATUS_NOT_SUPPORTED)) ||
-                  (NT_STATUS_EQUAL(result, NT_STATUS_BUFFER_TOO_SMALL)) ||
-                  (NT_STATUS_EQUAL(result, NT_STATUS_NOT_IMPLEMENTED))) {
+       if (NT_STATUS_EQUAL(result, NT_STATUS_RPC_PROCNUM_OUT_OF_RANGE) ||
+           NT_STATUS_EQUAL(result, NT_STATUS_NOT_SUPPORTED) ||
+           NT_STATUS_EQUAL(result, NT_STATUS_BUFFER_TOO_SMALL) ||
+           NT_STATUS_EQUAL(result, NT_STATUS_NOT_IMPLEMENTED)) {
 
                DEBUG(10,("Password change with chgpasswd_user3 failed with: 
%s, retrying chgpasswd_user2\n",
                        nt_errstr(result)));


-- 
Samba Shared Repository

Reply via email to