]> git.sur5r.net Git - openldap/blobdiff - servers/ldapd/modify.c
schema definitions from Active Directory.
[openldap] / servers / ldapd / modify.c
index d2197c4039916b25c36e1baccbfa6bef9ea2c85f..9e36928ca3da38d9eb579305ccc480a7b7a3ad24 100644 (file)
@@ -1,3 +1,4 @@
+/* $OpenLDAP$ */
 /*
  * Copyright (c) 1990 Regents of the University of Michigan.
  * All rights reserved.
@@ -16,6 +17,7 @@
 
 #include <ac/ctype.h>
 #include <ac/socket.h>
+#include <ac/string.h>         /* get SAFEMEMCPY */
 
 #include <quipu/commonarg.h>
 #include <quipu/attrvalue.h>
@@ -23,6 +25,7 @@
 #include <quipu/modify.h>
 #include <quipu/dap2.h>
 #include <quipu/dua.h>
+extern IFP     merge_acl;
 
 #include "lber.h"
 #include "ldap.h"
 
 static CommonArgs      common = default_common_args;
 
-extern short   ldap_photo_syntax;
-extern short   ldap_jpeg_syntax;
-extern short   ldap_jpeg_nonfile_syntax;
-extern short   ldap_audio_syntax;
-extern short   ldap_dn_syntax;
-extern short   ldap_postaladdress_syntax;
-extern short   ldap_acl_syntax;
-extern short   ldap_mtai_syntax;
-extern short   ldap_rts_cred_syntax;
-extern short   ldap_rtl_syntax;
-extern short   ldap_octetstring_syntax;
-
+static int replace_mod( struct entrymod *, Attr_Sequence, Attr_Sequence );
 
 #ifdef LDAP_COMPAT20
-extern int     ldap_compat;
 #define MODTAG (ldap_compat == 20 ? OLD_LDAP_RES_MODIFY : LDAP_RES_MODIFY)
 #else
 #define MODTAG LDAP_RES_MODIFY
@@ -61,9 +52,8 @@ do_modify(
        char                    *last;
        int                     rc;
        unsigned long           tag, len;
-       LDAPMod                 *mods, *modtail;
+       LDAPModList             *mods, *modtail;
        struct ds_read_arg      ra;
-       extern DN               ldap_str2dn();
 
        Debug( LDAP_DEBUG_TRACE, "do_modify\n", 0, 0, 0 );
 
@@ -119,17 +109,17 @@ do_modify(
        mods = modtail = NULL;
        for ( tag = ber_first_element( ber, &len, &last ); tag != LBER_DEFAULT;
            tag = ber_next_element( ber, &len, last ) ) {
-               LDAPMod *tmp;
+               LDAPModList     *tmp;
 
-               if ( (tmp = (LDAPMod *) calloc( 1, sizeof(LDAPMod) ))
+               if ( (tmp = (LDAPModList *) calloc( 1, sizeof(LDAPModList) ))
                    == NULL ) {
                        send_ldap_msgresult( clientsb, MODTAG, m,
                            LDAP_OPERATIONS_ERROR, NULL, "Malloc error" );
                        return( 0 );
                }
                        
-               if ( ber_scanf( ber, "{i{a[V]}}", &tmp->mod_op, &tmp->mod_type,
-                   &tmp->mod_bvalues ) == LBER_ERROR ) {
+               if ( ber_scanf( ber, "{i{a[V]}}", &tmp->m.mod_op,
+                   &tmp->m.mod_type, &tmp->m.mod_bvalues ) == LBER_ERROR ) {
                        send_ldap_msgresult( clientsb, MODTAG, m,
                            LDAP_PROTOCOL_ERROR, NULL, "" );
                        return( 0 );
@@ -168,7 +158,7 @@ do_modify2(
        struct ds_modifyentry_arg       ma;
        struct entrymod                 *changetail = NULLMOD;
        int                             rc;
-       LDAPMod                         *mods;
+       LDAPModList                     *mods;
 
        Debug( LDAP_DEBUG_TRACE, "do_modify2\n", 0, 0, 0 );
 
@@ -181,7 +171,7 @@ do_modify2(
        ma.mea_changes = NULLMOD;
        for ( mods = m->m_mods; mods != NULL; mods = mods->mod_next ) {
                struct entrymod *em;
-               Attr_Sequence   as, new, get_as();
+               Attr_Sequence   as, new;
 
                if ( (em = (struct entrymod *) calloc( 1,
                    sizeof(struct entrymod) )) == NULLMOD ) {
@@ -192,7 +182,7 @@ do_modify2(
                em->em_next = NULLMOD;
 
                if ( (new = get_as( clientsb, MODTAG, m,
-                   mods->mod_type, mods->mod_bvalues )) == NULLATTR )
+                   mods->m.mod_type, mods->m.mod_bvalues )) == NULLATTR )
                        return( 0 );
                em->em_what = new;
 
@@ -203,13 +193,13 @@ do_modify2(
                }
 
                if ( new->attr_value == NULLAV &&
-                   mods->mod_op != LDAP_MOD_DELETE ) {
+                   mods->m.mod_op != LDAP_MOD_DELETE ) {
                        send_ldap_msgresult( clientsb, MODTAG, m,
                            LDAP_INVALID_SYNTAX, NULL, "No values specified" );
                        return( 0 );
                }
 
-               switch ( mods->mod_op ) {
+               switch ( mods->m.mod_op ) {
                case LDAP_MOD_ADD:
                        Debug( LDAP_DEBUG_ARGS, "ADD:\n", 0, 0, 0 );
 
@@ -399,9 +389,6 @@ get_as(
                AttributeValue  av;
                int             t61str, ncomp;
                char            *sval, *s, *news, *n;
-               extern IFP      merge_acl;
-               extern AttributeValue   bv_asn2AttrV(), ldap_strdn2AttrV();
-               extern AttributeValue   ldap_str_at2AttrV(), bv_octet2AttrV();
 
                if ( syntax == ldap_jpeg_syntax ||
                    syntax == ldap_jpeg_nonfile_syntax ||
@@ -504,14 +491,15 @@ modify_result( Sockbuf *sb, struct msg *m )
 }
 
 void
-modlist_free( LDAPMod *mods )
+modlist_free( LDAPModList *mods )
 {
-       LDAPMod *next = NULL;
+       LDAPModList     *next;
 
        for ( ; mods != NULL; mods = next ) {
-               free( mods->mod_type );
-               if ( mods->mod_bvalues != NULL )
-                       ber_bvecfree( mods->mod_bvalues );
+               free( mods->m.mod_type );
+               if ( mods->m.mod_bvalues != NULL )
+                       ber_bvecfree( mods->m.mod_bvalues );
+               next = mods->mod_next;
                free( mods );
        }
 }
@@ -521,7 +509,7 @@ modlist_free( LDAPMod *mods )
  * that are not in the new set and by only adding what isn't in old set
  */
 
-int
+static int
 replace_mod(
     struct entrymod    *rem,
     Attr_Sequence      oas,