]> git.sur5r.net Git - openldap/blobdiff - contrib/slapd-modules/nssov/group.c
Merge remote-tracking branch 'origin/mdb.master' into OPENLDAP_REL_ENG_2_4
[openldap] / contrib / slapd-modules / nssov / group.c
index 4c13acedbadd8bdccd4143cd31745564c1252c00..f75d7503d33fa431d28a645c8583a3b57fb17678 100644 (file)
@@ -1,7 +1,9 @@
 /* group.c - group lookup routines */
 /* $OpenLDAP$ */
-/*
- * Copyright 2008 by Howard Chu, Symas Corp.
+/* This work is part of OpenLDAP Software <http://www.openldap.org/>. 
+ *
+ * Copyright 2008-2013 The OpenLDAP Foundation.
+ * Portions Copyright 2008-2009 by Howard Chu, Symas Corp.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -12,7 +14,7 @@
  * top-level directory of the distribution or, alternatively, at
  * <http://www.OpenLDAP.org/license.html>.
  */
-/*
+/* ACKNOWLEDGEMENTS:
  * This code references portions of the nss-ldapd package
  * written by Arthur de Jong. The nss-ldapd code was forked
  * from the nss-ldap library written by Luke Howard.
@@ -121,6 +123,10 @@ static int isvalidgroupname(struct berval *name)
        /* check other characters */
        for (i=1;i<name->bv_len;i++)
        {
+#ifndef STRICT_GROUPS
+               /* allow spaces too */
+               if (name->bv_val[i] == ' ') continue;
+#endif
                if ( ! ( (name->bv_val[i]>='A' && name->bv_val[i] <= 'Z') ||
                                                 (name->bv_val[i]>='a' && name->bv_val[i] <= 'z') ||
                                                 (name->bv_val[i]>='0' && name->bv_val[i] <= '9') ||
@@ -137,7 +143,7 @@ static int write_group(nssov_group_cbp *cbp,Entry *entry)
        struct berval *names,*gids,*members;
        struct berval passwd = {0};
        Attribute *a;
-       int i,j,nummembers,rc;
+       int i,j,nummembers,rc = 0;
 
        /* get group name (cn) */
        if (BER_BVISNULL(&cbp->name))
@@ -145,7 +151,7 @@ static int write_group(nssov_group_cbp *cbp,Entry *entry)
                a = attr_find(entry->e_attrs, cbp->mi->mi_attrs[CN_KEY].an_desc);
                if ( !a )
                {
-                       Debug(LDAP_DEBUG_ANY,"group entry %s does not contain %s value",
+                       Debug(LDAP_DEBUG_ANY,"group entry %s does not contain %s value\n",
                                        entry->e_name.bv_val, cbp->mi->mi_attrs[CN_KEY].an_desc->ad_cname.bv_val,0);
                        return 0;
                }
@@ -163,7 +169,7 @@ static int write_group(nssov_group_cbp *cbp,Entry *entry)
                a = attr_find(entry->e_attrs, cbp->mi->mi_attrs[GID_KEY].an_desc);
                if ( !a )
                {
-                       Debug(LDAP_DEBUG_ANY,"group entry %s does not contain %s value",
+                       Debug(LDAP_DEBUG_ANY,"group entry %s does not contain %s value\n",
                                        entry->e_name.bv_val, cbp->mi->mi_attrs[GID_KEY].an_desc->ad_cname.bv_val,0);
                        return 0;
                }
@@ -225,7 +231,7 @@ static int write_group(nssov_group_cbp *cbp,Entry *entry)
        {
                if (!isvalidgroupname(&names[i]))
                {
-                       Debug(LDAP_DEBUG_ANY,"nssov: group entry %s contains invalid group name: \"%s\"",
+                       Debug(LDAP_DEBUG_ANY,"nssov: group entry %s contains invalid group name: \"%s\"\n",
                                                                                                        entry->e_name.bv_val,names[i].bv_val,0);
                }
                else
@@ -237,12 +243,12 @@ static int write_group(nssov_group_cbp *cbp,Entry *entry)
                                gid_t gid;
                                gid = strtol(gids[j].bv_val, &tmp, 0);
                                if ( *tmp ) {
-                                       Debug(LDAP_DEBUG_ANY,"nssov: group entry %s contains non-numeric %s value: \"%s\"",
+                                       Debug(LDAP_DEBUG_ANY,"nssov: group entry %s contains non-numeric %s value: \"%s\"\n",
                                                entry->e_name.bv_val, cbp->mi->mi_attrs[GID_KEY].an_desc->ad_cname.bv_val,
                                                names[i].bv_val);
                                        continue;
                                }
-                               WRITE_INT32(cbp->fp,NSLCD_RESULT_SUCCESS);
+                               WRITE_INT32(cbp->fp,NSLCD_RESULT_BEGIN);
                                WRITE_BERVAL(cbp->fp,&names[i]);
                                WRITE_BERVAL(cbp->fp,&passwd);
                                WRITE_TYPE(cbp->fp,gid,gid_t);
@@ -271,18 +277,18 @@ NSSOV_HANDLE(
        char fbuf[1024];
        struct berval filter = {sizeof(fbuf)};
        filter.bv_val = fbuf;
-       READ_STRING_BUF2(fp,cbp.buf,sizeof(cbp.buf));
+       READ_STRING(fp,cbp.buf);
        cbp.name.bv_len = tmpint32;
        cbp.name.bv_val = cbp.buf;
        if (!isvalidgroupname(&cbp.name)) {
-               Debug(LDAP_DEBUG_ANY,"nssov_group_byname(%s): invalid group name",cbp.name.bv_val,0,0);
+               Debug(LDAP_DEBUG_ANY,"nssov_group_byname(%s): invalid group name\n",cbp.name.bv_val,0,0);
                return -1;
        }
        cbp.wantmembers = 1;
        cbp.ni = ni;
        BER_BVZERO(&cbp.gidnum);
        BER_BVZERO(&cbp.user);,
-       Debug(LDAP_DEBUG_TRACE,"nslcd_group_byname(%s)",cbp.name.bv_val,0,0);,
+       Debug(LDAP_DEBUG_TRACE,"nslcd_group_byname(%s)\n",cbp.name.bv_val,0,0);,
        NSLCD_ACTION_GROUP_BYNAME,
        nssov_filter_byname(cbp.mi,CN_KEY,&cbp.name,&filter)
 )
@@ -300,7 +306,7 @@ NSSOV_HANDLE(
        cbp.ni = ni;
        BER_BVZERO(&cbp.name);
        BER_BVZERO(&cbp.user);,
-       Debug(LDAP_DEBUG_TRACE,"nssov_group_bygid(%s)",cbp.gidnum.bv_val,0,0);,
+       Debug(LDAP_DEBUG_TRACE,"nssov_group_bygid(%s)\n",cbp.gidnum.bv_val,0,0);,
        NSLCD_ACTION_GROUP_BYGID,
        nssov_filter_byid(cbp.mi,GID_KEY,&cbp.gidnum,&filter)
 )
@@ -310,18 +316,18 @@ NSSOV_HANDLE(
        char fbuf[1024];
        struct berval filter = {sizeof(fbuf)};
        filter.bv_val = fbuf;
-       READ_STRING_BUF2(fp,cbp.buf,sizeof(cbp.buf));
+       READ_STRING(fp,cbp.buf);
        cbp.user.bv_len = tmpint32;
        cbp.user.bv_val = cbp.buf;
        if (!isvalidusername(&cbp.user)) {
-               Debug(LDAP_DEBUG_ANY,"nssov_group_bymember(%s): invalid user name",cbp.user.bv_val,0,0);
+               Debug(LDAP_DEBUG_ANY,"nssov_group_bymember(%s): invalid user name\n",cbp.user.bv_val,0,0);
                return -1;
        }
        cbp.wantmembers = 0;
        cbp.ni = ni;
        BER_BVZERO(&cbp.name);
        BER_BVZERO(&cbp.gidnum);,
-       Debug(LDAP_DEBUG_TRACE,"nssov_group_bymember(%s)",cbp.user.bv_val,0,0);,
+       Debug(LDAP_DEBUG_TRACE,"nssov_group_bymember(%s)\n",cbp.user.bv_val,0,0);,
        NSLCD_ACTION_GROUP_BYMEMBER,
        mkfilter_group_bymember(&cbp,&filter)
 )
@@ -334,7 +340,7 @@ NSSOV_HANDLE(
        cbp.ni = ni;
        BER_BVZERO(&cbp.name);
        BER_BVZERO(&cbp.gidnum);,
-       Debug(LDAP_DEBUG_TRACE,"nssov_group_all()",0,0,0);,
+       Debug(LDAP_DEBUG_TRACE,"nssov_group_all()\n",0,0,0);,
        NSLCD_ACTION_GROUP_ALL,
        (filter=cbp.mi->mi_filter,0)
 )