aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlex Auvolat <alex@adnab.me>2020-02-02 13:32:12 +0100
committerAlex Auvolat <alex@adnab.me>2020-02-02 13:32:12 +0100
commit4c037dcb94d2c663da9e624ba44dac0f833bc804 (patch)
tree4a110c2ccb999f0b343da98402273c67fe8cdc1f
parente9e7a4cb4bdf0a1fe0356d465f8becac49b46320 (diff)
downloadbottin-4c037dcb94d2c663da9e624ba44dac0f833bc804.tar.gz
bottin-4c037dcb94d2c663da9e624ba44dac0f833bc804.zip
Bug fix: case-insensitive value match (except for passwords)
-rw-r--r--bottin.hcl.example2
-rw-r--r--read.go2
-rw-r--r--util.go8
3 files changed, 10 insertions, 2 deletions
diff --git a/bottin.hcl.example b/bottin.hcl.example
index 8305a01..59f7c57 100644
--- a/bottin.hcl.example
+++ b/bottin.hcl.example
@@ -12,7 +12,7 @@ job "directory" {
task "server" {
driver = "docker"
config {
- image = "lxpz/bottin_amd64:4"
+ image = "lxpz/bottin_amd64:5"
readonly_rootfs = true
port_map {
ldap_port = 389
diff --git a/read.go b/read.go
index f95f5f3..0b6d345 100644
--- a/read.go
+++ b/read.go
@@ -205,7 +205,7 @@ func applyFilter(entry Entry, filter message.Filter) (bool, error) {
for entry_desc, value := range entry {
if strings.EqualFold(entry_desc, desc) {
for _, val := range value {
- if val == target {
+ if valueMatch(entry_desc, val, target) {
return true, nil
}
}
diff --git a/util.go b/util.go
index d778bc2..4add5ee 100644
--- a/util.go
+++ b/util.go
@@ -138,3 +138,11 @@ func genUuid() string {
}
return uuid.String()
}
+
+func valueMatch(attr, val1, val2 string) bool {
+ if strings.EqualFold(attr, ATTR_USERPASSWORD) {
+ return val1 == val2
+ } else {
+ return strings.EqualFold(val1, val2)
+ }
+}