diff options
author | Alex Auvolat <alex@adnab.me> | 2020-02-02 13:51:47 +0100 |
---|---|---|
committer | Alex Auvolat <alex@adnab.me> | 2020-02-02 13:53:29 +0100 |
commit | 0c801e02d5b9804c5444d4e923babc34ee05b61c (patch) | |
tree | cb1bcfe3b792614dd9b28ed0c30ae3de1b1d5f72 /util.go | |
parent | 4c037dcb94d2c663da9e624ba44dac0f833bc804 (diff) | |
download | bottin-0c801e02d5b9804c5444d4e923babc34ee05b61c.tar.gz bottin-0c801e02d5b9804c5444d4e923babc34ee05b61c.zip |
Remove spaces between dn components, use warnings when necessary
Diffstat (limited to 'util.go')
-rw-r--r-- | util.go | 20 |
1 files changed, 18 insertions, 2 deletions
@@ -98,13 +98,29 @@ func parseDN(dn string) ([]DNComponent, error) { return nil, fmt.Errorf("Wrong DN component: %s (expected type=value)", rdn) } ret = append(ret, DNComponent{ - Type: splits[0], - Value: splits[1], + Type: strings.TrimSpace(splits[0]), + Value: strings.TrimSpace(splits[1]), }) } return ret, nil } +func canonicalDN(dn string) (string, error) { + path, err := parseDN(dn) + if err != nil { + return "", err + } + + ret := "" + for _, c := range path { + if ret != "" { + ret = ret + "," + } + ret = ret + c.Type + "=" + c.Value + } + return ret, nil +} + func checkRestrictedAttr(attr string) error { RESTRICTED_ATTRS := []string{ ATTR_MEMBEROF, |