Turn the pdb_rid_algorithm into a capabilities call that returns flags
authorVolker Lendecke <vl@samba.org>
Sun, 28 Jun 2009 15:36:12 +0000 (17:36 +0200)
committerVolker Lendecke <vl@samba.org>
Sun, 28 Jun 2009 20:13:50 +0000 (22:13 +0200)
source3/include/passdb.h
source3/include/proto.h
source3/passdb/passdb.c
source3/passdb/pdb_ads.c
source3/passdb/pdb_interface.c
source3/passdb/pdb_ldap.c
source3/passdb/pdb_smbpasswd.c
source3/passdb/pdb_tdb.c
source3/utils/net_groupmap.c
source3/utils/net_sam.c

index d67c2842a6f3e294a8dff3b9ce6e8b58b5fc798b..dadb2275d3a5d5e3e9db336ed5b61744bfdc484f 100644 (file)
@@ -197,6 +197,8 @@ struct pdb_search {
        void (*search_end)(struct pdb_search *search);
 };
 
+#define PDB_CAP_STORE_RIDS     0x0001
+
 /*****************************************************************
  Functions to be implemented by the new (v2) passdb API 
 ****************************************************************/
@@ -212,6 +214,7 @@ struct pdb_search {
  * enum lsa_SidType rather than uint32.
  * Changed to 16 for access to the trusted domain passwords (obnox).
  * Changed to 17, the sampwent interface is gone.
+ * Changed to 18, pdb_rid_algorithm -> pdb_capabilities
  */
 
 #define PASSDB_INTERFACE_VERSION 17
@@ -361,7 +364,7 @@ struct pdb_methods
        bool (*sid_to_id)(struct pdb_methods *methods, const DOM_SID *sid,
                          union unid_t *id, enum lsa_SidType *type);
 
-       bool (*rid_algorithm)(struct pdb_methods *methods);
+       uint32_t (*capabilities)(struct pdb_methods *methods);
        bool (*new_rid)(struct pdb_methods *methods, uint32 *rid);
 
 
index 07a749d849e0f930f2b259186d0310b90822e91d..1a8a9a9538239e9610d3e08954a081be34c003b8 100644 (file)
@@ -4595,7 +4595,7 @@ bool pdb_uid_to_sid(uid_t uid, DOM_SID *sid);
 bool pdb_gid_to_sid(gid_t gid, DOM_SID *sid);
 bool pdb_sid_to_id(const DOM_SID *sid, union unid_t *id,
                   enum lsa_SidType *type);
-bool pdb_rid_algorithm(void);
+uint32_t pdb_capabilities(void);
 bool pdb_new_rid(uint32 *rid);
 bool initialize_password_db(bool reload, struct event_context *event_ctx);
 struct pdb_search *pdb_search_init(TALLOC_CTX *mem_ctx,
index 8efd6592dd5c08ce9ae44aa8d302d8adf9bf67de..502c3728a35906586a46074597cd4778fa774b93 100644 (file)
@@ -207,7 +207,7 @@ static NTSTATUS samu_set_unix_internal(struct samu *user, const struct passwd *p
           initialized and will fill in these fields later (such as from a 
           netr_SamInfo3 structure) */
 
-       if ( create && !pdb_rid_algorithm() ) {
+       if ( create && (pdb_capabilities() & PDB_CAP_STORE_RIDS)) {
                uint32 user_rid;
                DOM_SID user_sid;
 
index cdde30dcdcaa33e71f71e50b9133414da4efbc85..b7c42c58c9baacc13e2ca3ea171884e9c2105bee 100644 (file)
@@ -1920,9 +1920,9 @@ static bool pdb_ads_sid_to_id(struct pdb_methods *m, const DOM_SID *sid,
        return false;
 }
 
-static bool pdb_ads_rid_algorithm(struct pdb_methods *m)
+static uint32_t pdb_ads_capabilities(struct pdb_methods *m)
 {
-       return false;
+       return PDB_CAP_STORE_RIDS;
 }
 
 static bool pdb_ads_new_rid(struct pdb_methods *m, uint32 *rid)
@@ -2005,7 +2005,7 @@ static void pdb_ads_init_methods(struct pdb_methods *m)
        m->uid_to_sid = pdb_ads_uid_to_sid;
        m->gid_to_sid = pdb_ads_gid_to_sid;
        m->sid_to_id = pdb_ads_sid_to_id;
-       m->rid_algorithm = pdb_ads_rid_algorithm;
+       m->capabilities = pdb_ads_capabilities;
        m->new_rid = pdb_ads_new_rid;
        m->get_trusteddom_pw = pdb_ads_get_trusteddom_pw;
        m->set_trusteddom_pw = pdb_ads_set_trusteddom_pw;
index 6fe0979a50c75d74c8b93c7433c04870f66054d4..a72409ea4af54b43ade8651d8b8720a7c3ddc09d 100644 (file)
@@ -574,12 +574,12 @@ static NTSTATUS pdb_default_create_dom_group(struct pdb_methods *methods,
                return NT_STATUS_ACCESS_DENIED;
        }
 
-       if (pdb_rid_algorithm()) {
-               *rid = algorithmic_pdb_gid_to_group_rid( grp->gr_gid );
-       } else {
+       if (pdb_capabilities() & PDB_CAP_STORE_RIDS) {
                if (!pdb_new_rid(rid)) {
                        return NT_STATUS_ACCESS_DENIED;
                }
+       } else {
+               *rid = algorithmic_pdb_gid_to_group_rid( grp->gr_gid );
        }
 
        sid_compose(&group_sid, get_global_sam_sid(), *rid);
@@ -1043,10 +1043,10 @@ bool pdb_sid_to_id(const DOM_SID *sid, union unid_t *id,
        return pdb->sid_to_id(pdb, sid, id, type);
 }
 
-bool pdb_rid_algorithm(void)
+uint32_t pdb_capabilities(void)
 {
        struct pdb_methods *pdb = pdb_get_methods();
-       return pdb->rid_algorithm(pdb);
+       return pdb->capabilities(pdb);
 }
 
 /********************************************************************
@@ -1065,7 +1065,7 @@ bool pdb_new_rid(uint32 *rid)
        int i;
        TALLOC_CTX *ctx;
 
-       if (pdb_rid_algorithm()) {
+       if ((pdb_capabilities() & PDB_CAP_STORE_RIDS) == 0) {
                DEBUG(0, ("Trying to allocate a RID when algorithmic RIDs "
                          "are active\n"));
                return False;
index dddde75a4eab30c186b069166a626c24e18ebf82..c2230eb98291cd1dfe0a8be706ffa1b25d4b87ed 100644 (file)
@@ -4728,9 +4728,9 @@ static bool ldapsam_search_aliases(struct pdb_methods *methods,
        return ldapsam_search_grouptype(methods, search, sid, SID_NAME_ALIAS);
 }
 
-static bool ldapsam_rid_algorithm(struct pdb_methods *methods)
+static uint32_t ldapsam_capabilities(struct pdb_methods *methods)
 {
-       return False;
+       return PDB_CAP_STORE_RIDS;
 }
 
 static NTSTATUS ldapsam_get_new_rid(struct ldapsam_privates *priv,
@@ -6154,7 +6154,7 @@ static NTSTATUS pdb_init_ldapsam_common(struct pdb_methods **pdb_method, const c
 
        (*pdb_method)->get_seq_num = ldapsam_get_seq_num;
 
-       (*pdb_method)->rid_algorithm = ldapsam_rid_algorithm;
+       (*pdb_method)->capabilities = ldapsam_capabilities;
        (*pdb_method)->new_rid = ldapsam_new_rid;
 
        (*pdb_method)->get_trusteddom_pw = ldapsam_get_trusteddom_pw;
index 8074b2e3a13c19517fa71c48442b0facdcaff504..cac95c40a91e40bc80fd8e0f571bd4a1fdea6f51 100644 (file)
@@ -1520,9 +1520,9 @@ done:
        return (ret);   
 }
 
-static bool smbpasswd_rid_algorithm(struct pdb_methods *methods)
+static uint32_t smbpasswd_capabilities(struct pdb_methods *methods)
 {
-       return True;
+       return 0;
 }
 
 static void free_private_data(void **vp) 
@@ -1682,7 +1682,7 @@ static NTSTATUS pdb_init_smbpasswd( struct pdb_methods **pdb_method, const char
        (*pdb_method)->rename_sam_account = smbpasswd_rename_sam_account;
        (*pdb_method)->search_users = smbpasswd_search_users;
 
-       (*pdb_method)->rid_algorithm = smbpasswd_rid_algorithm;
+       (*pdb_method)->capabilities = smbpasswd_capabilities;
 
        /* Setup private data and free function */
 
index dd6e678c99ec1d88217579eed80927b6569e3baf..4d2a1d830a63aa78cc36c8b26698d8097eb34ee8 100644 (file)
@@ -1066,9 +1066,9 @@ static NTSTATUS tdbsam_rename_sam_account(struct pdb_methods *my_methods,
        return NT_STATUS_ACCESS_DENIED; 
 }
 
-static bool tdbsam_rid_algorithm(struct pdb_methods *methods)
+static uint32_t tdbsam_capabilities(struct pdb_methods *methods)
 {
-       return False;
+       return PDB_CAP_STORE_RIDS;
 }
 
 static bool tdbsam_new_rid(struct pdb_methods *methods, uint32 *prid)
@@ -1246,7 +1246,7 @@ static NTSTATUS pdb_init_tdbsam(struct pdb_methods **pdb_method, const char *loc
        (*pdb_method)->rename_sam_account = tdbsam_rename_sam_account;
        (*pdb_method)->search_users = tdbsam_search_users;
 
-       (*pdb_method)->rid_algorithm = tdbsam_rid_algorithm;
+       (*pdb_method)->capabilities = tdbsam_capabilities;
        (*pdb_method)->new_rid = tdbsam_new_rid;
 
        /* save the path for later */
index a00784e133b9474adc2a6aa3a53185f7f2b0ddbe..16c61876649b703165359574402de2167f901d83 100644 (file)
@@ -276,12 +276,12 @@ static int net_groupmap_add(struct net_context *c, int argc, const char **argv)
 
        if ( (rid == 0) && (string_sid[0] == '\0') ) {
                d_printf("No rid or sid specified, choosing a RID\n");
-               if (pdb_rid_algorithm()) {
-                       rid = algorithmic_pdb_gid_to_group_rid(gid);
-               } else {
+               if (pdb_capabilities() & PDB_CAP_STORE_RIDS) {
                        if (!pdb_new_rid(&rid)) {
                                d_printf("Could not get new RID\n");
                        }
+               } else {
+                       rid = algorithmic_pdb_gid_to_group_rid(gid);
                }
                d_printf("Got RID %d\n", rid);
        }
@@ -577,13 +577,13 @@ static int net_groupmap_set(struct net_context *c, int argc, const char **argv)
                map.gid = grp->gr_gid;
 
                if (c->opt_rid == 0) {
-                       if ( pdb_rid_algorithm() )
-                               c->opt_rid = algorithmic_pdb_gid_to_group_rid(map.gid);
-                       else {
+                       if ( pdb_capabilities() & PDB_CAP_STORE_RIDS ) {
                                if ( !pdb_new_rid((uint32*)&c->opt_rid) ) {
                                        d_fprintf( stderr, "Could not allocate new RID\n");
                                        return -1;
                                }
+                       } else {
+                               c->opt_rid = algorithmic_pdb_gid_to_group_rid(map.gid);
                        }
                }
 
index 787bbdd502ed40cd11fef730ad627089de8707fe..62abef000dc5757a7fc781171d9a1573d298fc51 100644 (file)
@@ -817,14 +817,14 @@ static NTSTATUS map_unix_group(const struct group *grp, GROUP_MAP *pmap)
 
        fstrcpy(map.nt_name, grpname);
 
-       if (pdb_rid_algorithm()) {
-               rid = algorithmic_pdb_gid_to_group_rid( grp->gr_gid );
-       } else {
+       if (pdb_capabilities() & PDB_CAP_STORE_RIDS) {
                if (!pdb_new_rid(&rid)) {
                        DEBUG(3, ("Could not get a new RID for %s\n",
                                  grp->gr_name));
                        return NT_STATUS_ACCESS_DENIED;
                }
+       } else {
+               rid = algorithmic_pdb_gid_to_group_rid( grp->gr_gid );
        }
 
        sid_compose(&map.sid, get_global_sam_sid(), rid);