]> git.sur5r.net Git - openldap/commitdiff
Add SLAP_MOD_INTERNAL flag to Modifications, allow internal ops to bypass
authorHoward Chu <hyc@openldap.org>
Sat, 4 Jun 2005 09:44:39 +0000 (09:44 +0000)
committerHoward Chu <hyc@openldap.org>
Sat, 4 Jun 2005 09:44:39 +0000 (09:44 +0000)
ACL checks when modifying user-modifiable attributes as non-root user.

14 files changed:
servers/slapd/acl.c
servers/slapd/add.c
servers/slapd/modify.c
servers/slapd/modrdn.c
servers/slapd/overlays/pcache.c
servers/slapd/overlays/ppolicy.c
servers/slapd/overlays/refint.c
servers/slapd/overlays/syncprov.c
servers/slapd/passwd.c
servers/slapd/sasl.c
servers/slapd/slap.h
servers/slapd/slapi/slapi_ops.c
servers/slapd/slapi/slapi_utils.c
servers/slapd/syncrepl.c

index e71d14fcca2ef5059df69accce86e1d2bcaa2b4a..0276f3507546f67bb2b6b23a4a2ba5400ee86685 100644 (file)
@@ -2259,6 +2259,16 @@ acl_check_modlist(
        }
 
        for ( ; mlist != NULL; mlist = mlist->sml_next ) {
+               /*
+                * Internal mods are ignored by ACL_WRITE checking
+                */
+               if ( mlist->sml_flags & SLAP_MOD_INTERNAL ) {
+                       Debug( LDAP_DEBUG_ACL, "acl: internal mod %s:"
+                               " modify access granted\n",
+                               mlist->sml_desc->ad_cname.bv_val, 0, 0 );
+                       continue;
+               }
+
                /*
                 * no-user-modification operational attributes are ignored
                 * by ACL_WRITE checking as any found here are not provided
index 39480b5c932bc3e1547531581a98860ab86b7e8e..537129fdd41b5cde0f88d91fdf21ec0ad3bc700a 100644 (file)
@@ -120,6 +120,7 @@ do_add( Operation *op, SlapReply *rs )
 
                mod  = (Modifications *) ch_malloc( sizeof(Modifications) );
                mod->sml_op = LDAP_MOD_ADD;
+               mod->sml_flags = 0;
                mod->sml_next = NULL;
                mod->sml_desc = NULL;
                mod->sml_type = tmp.sml_type;
@@ -612,6 +613,7 @@ slap_entry2mods(
                mod = (Modifications *) malloc( sizeof( Modifications ));
                
                mod->sml_op = LDAP_MOD_REPLACE;
+               mod->sml_flags = 0;
 
                mod->sml_type = a_new_desc->ad_cname;
 
index 77b0d5013a2a630dd7fc6559227788b7b3ae77dd..fe7d7aae7864b7674d5828515f65eccef34e5208 100644 (file)
@@ -104,6 +104,7 @@ do_modify(
 
                mod = (Modifications *) ch_malloc( sizeof(Modifications) );
                mod->sml_op = mop;
+               mod->sml_flags = 0;
                mod->sml_type = tmp.sml_type;
                mod->sml_values = tmp.sml_values;
                mod->sml_nvalues = NULL;
@@ -894,6 +895,7 @@ int slap_mods_opattrs(
 
                        mod = (Modifications *) ch_malloc( sizeof( Modifications ) );
                        mod->sml_op = mop;
+                       mod->sml_flags = SLAP_MOD_INTERNAL;
                        mod->sml_type.bv_val = NULL;
                        mod->sml_desc = slap_schema.si_ad_structuralObjectClass;
                        mod->sml_values =
@@ -920,6 +922,7 @@ int slap_mods_opattrs(
                
                        mod = (Modifications *) ch_malloc( sizeof( Modifications ) );
                        mod->sml_op = mop;
+                       mod->sml_flags = SLAP_MOD_INTERNAL;
                        mod->sml_type.bv_val = NULL;
                        mod->sml_desc = slap_schema.si_ad_entryUUID;
                        mod->sml_values =
@@ -942,6 +945,7 @@ int slap_mods_opattrs(
 
                        mod = (Modifications *) ch_malloc( sizeof( Modifications ) );
                        mod->sml_op = mop;
+                       mod->sml_flags = SLAP_MOD_INTERNAL;
                        mod->sml_type.bv_val = NULL;
                        mod->sml_desc = slap_schema.si_ad_creatorsName;
                        mod->sml_values =
@@ -961,6 +965,7 @@ int slap_mods_opattrs(
 
                        mod = (Modifications *) ch_malloc( sizeof( Modifications ) );
                        mod->sml_op = mop;
+                       mod->sml_flags = SLAP_MOD_INTERNAL;
                        mod->sml_type.bv_val = NULL;
                        mod->sml_desc = slap_schema.si_ad_createTimestamp;
                        mod->sml_values =
@@ -978,6 +983,7 @@ int slap_mods_opattrs(
        if ( SLAP_LASTMOD( op->o_bd )) {
                mod = (Modifications *) ch_malloc( sizeof( Modifications ) );
                mod->sml_op = mop;
+               mod->sml_flags = SLAP_MOD_INTERNAL;
                mod->sml_type.bv_val = NULL;
                mod->sml_desc = slap_schema.si_ad_entryCSN;
                mod->sml_values = (BerVarray) ch_malloc( 2 * sizeof( struct berval ) );
@@ -991,6 +997,7 @@ int slap_mods_opattrs(
 
                mod = (Modifications *) ch_malloc( sizeof( Modifications ) );
                mod->sml_op = mop;
+               mod->sml_flags = SLAP_MOD_INTERNAL;
                mod->sml_type.bv_val = NULL;
                mod->sml_desc = slap_schema.si_ad_modifiersName;
                mod->sml_values = (BerVarray) ch_malloc( 2 * sizeof( struct berval ) );
@@ -1009,6 +1016,7 @@ int slap_mods_opattrs(
 
                mod = (Modifications *) ch_malloc( sizeof( Modifications ) );
                mod->sml_op = mop;
+               mod->sml_flags = SLAP_MOD_INTERNAL;
                mod->sml_type.bv_val = NULL;
                mod->sml_desc = slap_schema.si_ad_modifyTimestamp;
                mod->sml_values = (BerVarray) ch_malloc( 2 * sizeof( struct berval ) );
index b0f8d3e0288d1df4da5271120e3851be50a40d66..c2ceab26bb8dad4db878e15be7ae7bd192fb5634 100644 (file)
@@ -480,6 +480,7 @@ slap_modrdn2mods(
                        mod_tmp->sml_nvalues = NULL;
                }
                mod_tmp->sml_op = SLAP_MOD_SOFTADD;
+               mod_tmp->sml_flags = SLAP_MOD_INTERNAL;
                mod_tmp->sml_next = mod;
                mod = mod_tmp;
        }
@@ -534,6 +535,7 @@ slap_modrdn2mods(
                                mod_tmp->sml_nvalues = NULL;
                        }
                        mod_tmp->sml_op = LDAP_MOD_DELETE;
+                       mod_tmp->sml_flags = SLAP_MOD_INTERNAL;
                        mod_tmp->sml_next = mod;
                        mod = mod_tmp;
                }
index 0e1349a18144209a21e60bde5797256144b66cce..a8d8a2c6b8305b219374a565be7cd45b72a2fc63 100644 (file)
@@ -854,6 +854,7 @@ remove_query_data (
                        vals[1].bv_val = NULL;
                        vals[1].bv_len = 0;
                        mod.sml_op = LDAP_MOD_DELETE;
+                       mod.sml_flags = 0;
                        mod.sml_desc = ad_queryid;
                        mod.sml_type = ad_queryid->ad_cname;
                        mod.sml_values = vals;
index 2937ae3cf9795fb029a66a52d88f6dec21872085..87c643aaff6afe1347b6d326a28ce6ad78e96ede 100644 (file)
@@ -238,6 +238,7 @@ account_locked( Operation *op, Entry *e,
 
                        m = ch_calloc( sizeof(Modifications), 1 );
                        m->sml_op = LDAP_MOD_DELETE;
+                       m->sml_flags = 0;
                        m->sml_type = ad_pwdAccountLockedTime->ad_cname;
                        m->sml_desc = ad_pwdAccountLockedTime;
                        m->sml_next = *mod;
@@ -713,6 +714,7 @@ ppolicy_bind_resp( Operation *op, SlapReply *rs )
 
                m = ch_calloc( sizeof(Modifications), 1 );
                m->sml_op = LDAP_MOD_ADD;
+               m->sml_flags = 0;
                m->sml_type = ad_pwdFailureTime->ad_cname;
                m->sml_desc = ad_pwdFailureTime;
                m->sml_values = ch_calloc( sizeof(struct berval), 2 );
@@ -759,6 +761,7 @@ ppolicy_bind_resp( Operation *op, SlapReply *rs )
                         */
                        m = ch_calloc( sizeof(Modifications), 1 );
                        m->sml_op = LDAP_MOD_REPLACE;
+                       m->sml_flags = 0;
                        m->sml_type = ad_pwdAccountLockedTime->ad_cname;
                        m->sml_desc = ad_pwdAccountLockedTime;
                        m->sml_values = ch_calloc( sizeof(struct berval), 2 );
@@ -774,6 +777,7 @@ ppolicy_bind_resp( Operation *op, SlapReply *rs )
                if ( attr_find( e->e_attrs, ad_pwdFailureTime )) {
                        m = ch_calloc( sizeof(Modifications), 1 );
                        m->sml_op = LDAP_MOD_DELETE;
+                       m->sml_flags = 0;
                        m->sml_type = ad_pwdFailureTime->ad_cname;
                        m->sml_desc = ad_pwdFailureTime;
                        m->sml_next = mod;
@@ -859,6 +863,7 @@ grace:
                 */
                m = ch_calloc( sizeof(Modifications), 1 );
                m->sml_op = LDAP_MOD_ADD;
+               m->sml_flags = 0;
                m->sml_type = ad_pwdGraceUseTime->ad_cname;
                m->sml_desc = ad_pwdGraceUseTime;
                m->sml_values = ch_calloc( sizeof(struct berval), 2 );
@@ -1299,6 +1304,7 @@ ppolicy_modify( Operation *op, SlapReply *rs )
        if (pp.pwdSafeModify && oldpw.bv_val ) {
                ml = (Modifications *) ch_malloc( sizeof( Modifications ) );
                ml->sml_op = LDAP_MOD_DELETE;
+               ml->sml_flags = SLAP_MOD_INTERNAL;
                ml->sml_desc = pp.ad;
                ml->sml_type = pp.ad->ad_cname;
                ml->sml_values = (BerVarray) ch_malloc( 2 * sizeof( struct berval ) );
@@ -1467,6 +1473,7 @@ do_modify:
                        mods->sml_op = LDAP_MOD_DELETE;
                        mods->sml_values = NULL;
                }
+               mods->sml_flags = SLAP_MOD_INTERNAL;
                mods->sml_nvalues = NULL;
                mods->sml_next = NULL;
                modtail->sml_next = mods;
@@ -1475,6 +1482,7 @@ do_modify:
                if (attr_find(e->e_attrs, ad_pwdGraceUseTime )) {
                        mods = (Modifications *) ch_malloc( sizeof( Modifications ) );
                        mods->sml_op = LDAP_MOD_DELETE;
+                       mods->sml_flags = SLAP_MOD_INTERNAL;
                        mods->sml_type.bv_val = NULL;
                        mods->sml_desc = ad_pwdGraceUseTime;
                        mods->sml_values = NULL;
@@ -1488,6 +1496,7 @@ do_modify:
                if ((zapReset) && (attr_find(e->e_attrs, ad_pwdReset ))) {
                        mods = (Modifications *) ch_malloc( sizeof( Modifications ) );
                        mods->sml_op = LDAP_MOD_DELETE;
+                       mods->sml_flags = SLAP_MOD_INTERNAL;
                        mods->sml_type.bv_val = NULL;
                        mods->sml_desc = ad_pwdReset;
                        mods->sml_values = NULL;
@@ -1517,6 +1526,7 @@ do_modify:
                                 */
                                mods = (Modifications *) ch_malloc( sizeof( Modifications ) );
                                mods->sml_op = LDAP_MOD_DELETE;
+                               mods->sml_flags = SLAP_MOD_INTERNAL;
                                mods->sml_type.bv_val = NULL;
                                mods->sml_desc = ad_pwdHistory;
                                mods->sml_nvalues = NULL;
@@ -1549,6 +1559,7 @@ do_modify:
                        if ((pa = attr_find( e->e_attrs, pp.ad )) != NULL) {
                                mods = (Modifications *) ch_malloc( sizeof( Modifications ) );
                                mods->sml_op = LDAP_MOD_ADD;
+                               mods->sml_flags = SLAP_MOD_INTERNAL;
                                mods->sml_type.bv_val = NULL;
                                mods->sml_desc = ad_pwdHistory;
                                mods->sml_nvalues = NULL;
index 991b82b28fb5cb02320ce77698327c8f0f41eee1..a233fec070d1f7f77449f47df535ea16861bd014 100644 (file)
@@ -291,6 +291,7 @@ refint_delete_cb(
                                mp->sml_values[1].bv_val = mp->sml_nvalues[1].bv_val = NULL;
 
                                mp->sml_op = LDAP_MOD_ADD;
+                               mp->sml_flags = 0;
                                ber_dupbv(&mp->sml_values[0],  &dd->nothing);
                                ber_dupbv(&mp->sml_nvalues[0], &dd->nnothing);
                                mp->sml_next = ma;
@@ -305,6 +306,7 @@ refint_delete_cb(
                        mp->sml_values[1].bv_len = mp->sml_nvalues[1].bv_len = 0;
                        mp->sml_values[1].bv_val = mp->sml_nvalues[1].bv_val = NULL;
                        mp->sml_op = LDAP_MOD_DELETE;
+                       mp->sml_flags = 0;
                        ber_dupbv(&mp->sml_values[0], &dd->dn);
                        ber_dupbv(&mp->sml_nvalues[0], &mp->sml_values[0]);
                        mp->sml_next = ma;
@@ -389,6 +391,7 @@ refint_modrdn_cb(
                        }
                        mp = ch_malloc(sizeof(Modifications));
                        mp->sml_op = LDAP_MOD_ADD;
+                       mp->sml_flags = 0;
                        mp->sml_desc = ia->attr;                /* XXX */
                        mp->sml_type = ia->attr->ad_cname;
                        mp->sml_values  = ch_malloc(2 * sizeof(BerValue));
@@ -401,6 +404,7 @@ refint_modrdn_cb(
                        ip->mm = mp;
                        mp = ch_malloc(sizeof(Modifications));
                        mp->sml_op = LDAP_MOD_DELETE;
+                       mp->sml_flags = 0;
                        mp->sml_desc = ia->attr;                /* XXX */
                        mp->sml_type = ia->attr->ad_cname;
                        mp->sml_values  = ch_malloc(2 * sizeof(BerValue));
index 5c51f03c2d84e9a02f50838b8c819223f0d90ce9..74d428c4bc5b21277b6c1a78b7d3c27f2bdff3f3 100644 (file)
@@ -1151,6 +1151,7 @@ syncprov_checkpoint( Operation *op, SlapReply *rs, slap_overinst *on )
        mod.sml_nvalues = NULL;
        mod.sml_desc = slap_schema.si_ad_contextCSN;
        mod.sml_op = LDAP_MOD_REPLACE;
+       mod.sml_flags = 0;
        mod.sml_next = NULL;
 
        cb.sc_response = slap_null_cb;
index 270b1148b21e920f1d56f9877d7f2d002eece78d..0917bd2273a7216ce47e897e28a874c10b467228 100644 (file)
@@ -213,6 +213,7 @@ int passwd_extop(
        ml->sml_nvalues = NULL;
        ml->sml_desc = slap_schema.si_ad_userPassword;
        ml->sml_op = LDAP_MOD_REPLACE;
+       ml->sml_flags = 0;
        ml->sml_next = qpw->rs_mods;
        qpw->rs_mods = ml;
 
index 87fce497a5e848222180adb68ecc90b43bb3a21c..10b17ca62f33e0d7d0ab3574b0c81660014ab697 100644 (file)
@@ -369,6 +369,7 @@ slap_auxprop_store(
        for (i=0; pr[i].name; i++) {
                mod = (Modifications *)ch_malloc( sizeof(Modifications) );
                mod->sml_op = LDAP_MOD_REPLACE;
+               mod->sml_flags = 0;
                ber_str2bv( pr[i].name, 0, 0, &mod->sml_type );
                mod->sml_values = (struct berval *)ch_malloc( (pr[i].nvalues + 1) *
                        sizeof(struct berval));
index b4e7e187a32fac1895021e72285ca185d78951cb..4b761747eca6923a82b72d1fba9b794a6bd44816 100644 (file)
@@ -1145,7 +1145,13 @@ typedef struct slap_entry {
  * A list of LDAPMods
  */
 typedef struct slap_mod {
-       int sm_op;
+       short sm_op;
+       short sm_flags;
+/* Set for internal mods, will bypass ACL checks. Only needed when
+ * running as non-root user, for user modifiable attributes.
+ */
+#define        SLAP_MOD_INTERNAL       0x01
+
        AttributeDescription *sm_desc;
        struct berval sm_type;
        BerVarray sm_values;
@@ -1155,6 +1161,7 @@ typedef struct slap_mod {
 typedef struct slap_mod_list {
        Modification sml_mod;
 #define sml_op         sml_mod.sm_op
+#define sml_flags      sml_mod.sm_flags
 #define sml_desc       sml_mod.sm_desc
 #define        sml_type        sml_mod.sm_type
 #define sml_values     sml_mod.sm_values
index 5a95c62fc3973a6a9a95a6297e723057dfe86bae..5e85fe80b86eb5a212720a4cc5ffb68bdea9718f 100644 (file)
@@ -406,6 +406,7 @@ slapi_int_ldapmod_to_entry(
                                mod  = (Modifications *) ch_malloc( sizeof(Modifications) );
 
                                mod->sml_op = LDAP_MOD_ADD;
+                               mod->sml_flags = 0;
                                mod->sml_next = NULL;
                                mod->sml_desc = NULL;
                                mod->sml_type = tmp.sml_type;
@@ -431,6 +432,7 @@ slapi_int_ldapmod_to_entry(
                                        mod  = (Modifications *) ch_malloc( sizeof(Modifications) );
 
                                        mod->sml_op = LDAP_MOD_ADD;
+                                       mod->sml_flags = 0;
                                        mod->sml_next = NULL;
                                        mod->sml_desc = NULL;
                                        mod->sml_type = tmp.sml_type;
@@ -965,6 +967,7 @@ slapi_modify_internal(
                        mod  = (Modifications *)ch_malloc( sizeof(Modifications) );
 
                        mod->sml_op = pMod->mod_op & LDAP_MOD_OP;
+                       mod->sml_flags = 0;
                        mod->sml_next = NULL;
                        mod->sml_desc = NULL;
                        mod->sml_type = tmp.sml_type;
@@ -982,6 +985,7 @@ slapi_modify_internal(
                        mod  = (Modifications *) ch_malloc( sizeof(Modifications) );
 
                        mod->sml_op = pMod->mod_op & LDAP_MOD_OP;
+                       mod->sml_flags = 0;
                        mod->sml_next = NULL;
                        mod->sml_desc = NULL;
                        mod->sml_type = tmp.sml_type;
index 1adeb85086284b2b9aa2744a2915492fc8f91375..ca7e8c45da3d21ad49a33879f603a739a847e0b5 100644 (file)
@@ -604,6 +604,7 @@ slapi_entry_add_values( Slapi_Entry *e, const char *type, struct berval **vals )
        char                    textbuf[SLAP_TEXT_BUFLEN];
 
        mod.sm_op = LDAP_MOD_ADD;
+       mod.sm_flags = 0;
        mod.sm_desc = NULL;
        mod.sm_type.bv_val = (char *)type;
        mod.sm_type.bv_len = strlen( type );
@@ -676,6 +677,7 @@ slapi_entry_delete_values( Slapi_Entry *e, const char *type, struct berval **val
        char                    textbuf[SLAP_TEXT_BUFLEN];
 
        mod.sm_op = LDAP_MOD_DELETE;
+       mod.sm_flags = 0;
        mod.sm_desc = NULL;
        mod.sm_type.bv_val = (char *)type;
        mod.sm_type.bv_len = strlen( type );
@@ -3524,6 +3526,7 @@ Modifications *slapi_int_ldapmods2modifications (LDAPMod **mods)
 
                mod = (Modifications *) ch_malloc( sizeof(Modifications) );
                mod->sml_op = (*modp)->mod_op & (~LDAP_MOD_BVALUES);
+               mod->sml_flags = 0;
                mod->sml_type.bv_val = (*modp)->mod_type;
                mod->sml_type.bv_len = strlen( mod->sml_type.bv_val );
                mod->sml_desc = NULL;
index ff49fc7df9d62fba37d5b98096d7533321b81da4..118e7771b53c6af08242f225324eb9e0f33bbc09 100644 (file)
@@ -1094,6 +1094,7 @@ syncrepl_message_to_entry(
                mod  = (Modifications *) ch_malloc( sizeof( Modifications ));
 
                mod->sml_op = LDAP_MOD_REPLACE;
+               mod->sml_flags = 0;
                mod->sml_next = NULL;
                mod->sml_desc = NULL;
                mod->sml_type = tmp.sml_type;
@@ -1470,6 +1471,7 @@ retry_add:;
                        for ( i = 0; i < dni.attrs; i++ ) {
                                mod = ch_malloc( sizeof( Modifications ) );
                                mod->sml_op = LDAP_MOD_DELETE;
+                               mod->sml_flags = 0;
                                mod->sml_desc = dni.ads[i];
                                mod->sml_type = mod->sml_desc->ad_cname;
                                mod->sml_values = NULL;
@@ -1496,6 +1498,7 @@ retry_add:;
 
                        mod = (Modifications *)ch_calloc(1, sizeof(Modifications));
                        mod->sml_op = LDAP_MOD_REPLACE;
+                       mod->sml_flags = 0;
                        mod->sml_desc = slap_schema.si_ad_entryUUID;
                        mod->sml_type = mod->sml_desc->ad_cname;
                        ber_dupbv( &uuid_bv, &syncUUID_strrep );
@@ -1676,6 +1679,7 @@ syncrepl_del_nonpresent(
                        if ( rs_delete.sr_err == LDAP_NOT_ALLOWED_ON_NONLEAF ) {
                                Modifications mod1, mod2;
                                mod1.sml_op = LDAP_MOD_REPLACE;
+                               mod1.sml_flags = 0;
                                mod1.sml_desc = slap_schema.si_ad_objectClass;
                                mod1.sml_type = mod1.sml_desc->ad_cname;
                                mod1.sml_values = &gcbva[0];
@@ -1683,6 +1687,7 @@ syncrepl_del_nonpresent(
                                mod1.sml_next = &mod2;
 
                                mod2.sml_op = LDAP_MOD_REPLACE;
+                               mod2.sml_flags = 0;
                                mod2.sml_desc = slap_schema.si_ad_structuralObjectClass;
                                mod2.sml_type = mod2.sml_desc->ad_cname;
                                mod2.sml_values = &gcbva[1];