~ius-coredev/ius/openldap24

« back to all changes in this revision

Viewing changes to SOURCES/openldap-constraint-overlay-config.patch

  • Committer: Jeffrey Ness
  • Date: 2012-08-15 18:21:06 UTC
  • Revision ID: jeffrey.ness@rackspace.com-20120815182106-fifa0yp2oe0u3tsw
first

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
constraint overlay: fix config emit
 
2
 
 
3
Author: Pierangelo Masarati <ando@OpenLDAP.org>
 
4
Upstream ITS: #6986
 
5
Upstream commit: c0b669e14f4ef5b649f86bb3c1cc4ca76a00efa8
 
6
Resolves: #722923
 
7
 
 
8
diff --git a/servers/slapd/overlays/constraint.c b/servers/slapd/overlays/constraint.c
 
9
index fcb2830..e6a9267 100644
 
10
--- a/servers/slapd/overlays/constraint.c
 
11
+++ b/servers/slapd/overlays/constraint.c
 
12
@@ -145,6 +145,8 @@ constraint_cf_gen( ConfigArgs *c )
 
13
                                char *tstr = NULL;
 
14
                                int quotes = 0;
 
15
                                int j;
 
16
+                               size_t val;
 
17
+                               char val_buf[SLAP_TEXT_BUFLEN] = { '\0' };
 
18
 
 
19
                                bv.bv_len = STRLENOF("  ");
 
20
                                for (j = 0; cp->ap[j]; j++) {
 
21
@@ -156,6 +158,7 @@ constraint_cf_gen( ConfigArgs *c )
 
22
 
 
23
                                if (cp->re) {
 
24
                                        tstr = REGEX_STR;
 
25
+                                       quotes = 1;
 
26
                                } else if (cp->lud) {
 
27
                                        tstr = URI_STR;
 
28
                                        quotes = 1;
 
29
@@ -164,8 +167,10 @@ constraint_cf_gen( ConfigArgs *c )
 
30
                                        quotes = 1;
 
31
                                } else if (cp->size) {
 
32
                                        tstr = SIZE_STR;
 
33
+                                       val = cp->size;
 
34
                                } else if (cp->count) {
 
35
                                        tstr = COUNT_STR;
 
36
+                                       val = cp->count;
 
37
                                }
 
38
 
 
39
                                bv.bv_len += strlen(tstr);
 
40
@@ -175,6 +180,15 @@ constraint_cf_gen( ConfigArgs *c )
 
41
                                        bv.bv_len += cp->restrict_val.bv_len + STRLENOF(" restrict=\"\"");
 
42
                                }
 
43
 
 
44
+                               if (cp->count || cp->size) {
 
45
+                                       int len = snprintf(val_buf, sizeof(val_buf), "%d", val);
 
46
+                                       if (len <= 0) {
 
47
+                                               /* error */
 
48
+                                               return -1;
 
49
+                                       }
 
50
+                                       bv.bv_len += len;
 
51
+                               }
 
52
+
 
53
                                s = bv.bv_val = ch_malloc(bv.bv_len + 1);
 
54
 
 
55
                                s = lutil_strncopy( s, cp->ap[0]->ad_cname.bv_val, cp->ap[0]->ad_cname.bv_len );
 
56
@@ -185,9 +199,13 @@ constraint_cf_gen( ConfigArgs *c )
 
57
                                *s++ = ' ';
 
58
                                s = lutil_strcopy( s, tstr );
 
59
                                *s++ = ' ';
 
60
-                               if ( quotes ) *s++ = '"';
 
61
-                               s = lutil_strncopy( s, cp->val.bv_val, cp->val.bv_len );
 
62
-                               if ( quotes ) *s++ = '"';
 
63
+                               if (cp->count || cp->size) {
 
64
+                                       s = lutil_strcopy( s, val_buf );
 
65
+                               } else {
 
66
+                                       if ( quotes ) *s++ = '"';
 
67
+                                       s = lutil_strncopy( s, cp->val.bv_val, cp->val.bv_len );
 
68
+                                       if ( quotes ) *s++ = '"';
 
69
+                               }
 
70
                                if (cp->restrict_lud != NULL) {
 
71
                                        s = lutil_strcopy( s, " restrict=\"" );
 
72
                                        s = lutil_strncopy( s, cp->restrict_val.bv_val, cp->restrict_val.bv_len );
 
73
@@ -471,7 +489,7 @@ constraint_cf_gen( ConfigArgs *c )
 
74
                                                        }
 
75
                                                }
 
76
 
 
77
-                                               ber_str2bv(c->argv[argidx], 0, 1, &ap.restrict_val);
 
78
+                                               ber_str2bv(c->argv[argidx] + STRLENOF("restrict="), 0, 1, &ap.restrict_val);
 
79
 
 
80
                                        } else {
 
81
                                                /* cleanup */