summaryrefslogtreecommitdiffstats
path: root/ldap/admin
diff options
context:
space:
mode:
authorNoriko Hosoi <nhosoi@redhat.com>2010-02-03 14:16:29 -0800
committerNoriko Hosoi <nhosoi@redhat.com>2010-02-03 14:16:29 -0800
commit5c859f5b94527d30f6991a856840222216395b6d (patch)
tree11d1e5812c9e7b57e8236cb84e4bf92613fd8803 /ldap/admin
parent0544378b347be0aa9b5ded0abd75d841bfcfe9d3 (diff)
downloadds-5c859f5b94527d30f6991a856840222216395b6d.tar.gz
ds-5c859f5b94527d30f6991a856840222216395b6d.tar.xz
ds-5c859f5b94527d30f6991a856840222216395b6d.zip
560827 - Admin Server templates: DistinguishName validation fails
https://bugzilla.redhat.com/show_bug.cgi?id=560827 Description: adding a perl subroutine dnEscape to escape special characters and eliminate spaces around ',', which is to make the given dn compliant with RFC4514.
Diffstat (limited to 'ldap/admin')
-rw-r--r--ldap/admin/src/scripts/DSUtil.pm.in31
1 files changed, 31 insertions, 0 deletions
diff --git a/ldap/admin/src/scripts/DSUtil.pm.in b/ldap/admin/src/scripts/DSUtil.pm.in
index b92efa40..7e846d73 100644
--- a/ldap/admin/src/scripts/DSUtil.pm.in
+++ b/ldap/admin/src/scripts/DSUtil.pm.in
@@ -693,6 +693,37 @@ sub shellEscape {
return $val;
}
+# given a string, escape the special characters in the string.
+# the characters are defined in RFC 4514.
+# special = escaped / SPACE / SHARP / EQUALS
+# escaped = DQUOTE / PLUS / COMMA / SEMI / LANGLE / RANGLE
+# hex string "# HEX HEX" is unlikely appearing in the installation.
+# thus, it won't be supported for now.
+my %dnspecial = (
+ '"' => '\\"', # '\\22'
+ '\+' => '\\+', # '\\2B'
+ ',' => '\\,', # '\\2C'
+ ';' => '\\;', # '\\3B'
+ '<' => '\\<', # '\\3C'
+ '>' => '\\>', # '\\3E'
+ '=' => '\\=' # '\\3D'
+);
+
+sub dnEscape {
+ my $val = shift;
+ # first, remove spaces surrounding ',' and leading/trailing spaces
+ $val =~ s/^\s*//;
+ $val =~ s/\s*$//;
+ $val =~ s/\s*,\s*/,/g;
+ # next, replace the special characters
+ foreach my $idx (keys %dnspecial) {
+ $val =~ s/$idx/$dnspecial{$idx}/g;
+ }
+ $val =~ s/\s*,\s*/,/g;
+
+ return $val;
+}
+
sub getHashedPassword {
my $pwd = shift;
my $alg = shift;