From 260303dd14e44992972f47952238d0743c11eddb Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Thu, 3 Aug 2017 15:11:35 +0200 Subject: [PATCH 1/2] Fix gpasswd call in __user_groups: order incorrect From the manpage: -a, --add user Add the user to the named group. -d, --delete user Remove the user from the named group. --- cdist/conf/type/__user_groups/gencode-remote | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cdist/conf/type/__user_groups/gencode-remote b/cdist/conf/type/__user_groups/gencode-remote index 5518f333..a69d6997 100755 --- a/cdist/conf/type/__user_groups/gencode-remote +++ b/cdist/conf/type/__user_groups/gencode-remote @@ -59,8 +59,8 @@ for group in $changed_groups; do esac else case "$state_should" in - present) echo "gpasswd -a \"$group\" \"$user\"" ;; - absent) echo "gpasswd -d \"$group\" \"$user\"" ;; + present) echo "gpasswd -a \"$user\" \"$group\"" ;; + absent) echo "gpasswd -d \"$user\" \"$group\"" ;; esac fi done From ca1cc0f64ad18878a265ed7bec162a49ae63b267 Mon Sep 17 00:00:00 2001 From: Darko Poljak Date: Thu, 10 Aug 2017 19:08:44 +0200 Subject: [PATCH 2/2] object_id = '/' is invalid --- cdist/core/cdist_object.py | 12 +++++++----- cdist/test/cdist_object/__init__.py | 7 +++++++ 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/cdist/core/cdist_object.py b/cdist/core/cdist_object.py index 2d92aa41..8c7ce635 100644 --- a/cdist/core/cdist_object.py +++ b/cdist/core/cdist_object.py @@ -21,9 +21,7 @@ # # -import fnmatch import os -import collections import cdist import cdist.core @@ -142,9 +140,13 @@ class CdistObject(object): if '//' in self.object_id: raise IllegalObjectIdError( self.object_id, 'object_id may not contain //') - if self.object_id == '.': - raise IllegalObjectIdError( - self.object_id, 'object_id may not be a .') + + _invalid_object_ids = ('.', '/', ) + for ioid in _invalid_object_ids: + if self.object_id == ioid: + raise IllegalObjectIdError( + self.object_id, + 'object_id may not be a {}'.format(ioid)) # If no object_id and type is not singleton => error out if not self.object_id and not self.cdist_type.is_singleton: diff --git a/cdist/test/cdist_object/__init__.py b/cdist/test/cdist_object/__init__.py index d03c0642..a9c20cd3 100644 --- a/cdist/test/cdist_object/__init__.py +++ b/cdist/test/cdist_object/__init__.py @@ -147,6 +147,13 @@ class ObjectIdTestCase(test.CdistTestCase): core.CdistObject(cdist_type, self.object_base_path, OBJECT_MARKER_NAME, illegal_object_id) + def test_object_id_equals_slash(self): + cdist_type = core.CdistType(type_base_path, '__third') + illegal_object_id = '/' + with self.assertRaises(core.IllegalObjectIdError): + core.CdistObject(cdist_type, self.object_base_path, + OBJECT_MARKER_NAME, illegal_object_id) + def test_object_id_on_singleton_type(self): cdist_type = core.CdistType(type_base_path, '__test_singleton') illegal_object_id = 'object_id'