From f6bd5290b31da84cd374b00dfc5198167f6ef770 Mon Sep 17 00:00:00 2001 From: Jake Guffey Date: Wed, 20 Jun 2012 17:14:47 -0400 Subject: [PATCH 1/3] Add FreeBSD support Modified explorer/gshadow to do nothing on FreeBSD (unsupported command) Modified gencode-remote to use short options (--long not supported in FreeBSD) --- conf/type/__group/explorer/gshadow | 6 +++++ conf/type/__group/gencode-remote | 42 ++++++++++++++++++++++++++---- 2 files changed, 43 insertions(+), 5 deletions(-) diff --git a/conf/type/__group/explorer/gshadow b/conf/type/__group/explorer/gshadow index e3c2dd6c..5ab4ed80 100755 --- a/conf/type/__group/explorer/gshadow +++ b/conf/type/__group/explorer/gshadow @@ -23,6 +23,12 @@ name=$__object_id os_version="$($__explorer/os_version)" +os="$($__explorer/os)" + +if [ "$os" = "freebsd" ]; then + echo "FreeBSD does not have getent gshadow" + exit 0 +fi case "$os_version" in "Red Hat Enterprise Linux Server release "[45]*|"CentOS release "[45]*) diff --git a/conf/type/__group/gencode-remote b/conf/type/__group/gencode-remote index 2b4774ab..d2bdb6fb 100755 --- a/conf/type/__group/gencode-remote +++ b/conf/type/__group/gencode-remote @@ -24,6 +24,7 @@ name="$__object_id" os_version="$(cat "$__global/explorer/os_version")" +os="$(cat "$__global/explorer/os")" cd "$__object/parameter" if grep -q "^${name}:" "$__object/explorer/group"; then @@ -36,6 +37,10 @@ if grep -q "^${name}:" "$__object/explorer/group"; then case "$property" in password) current_value="$(awk -F: '{ print $2 }' < "$__object/explorer/gshadow")" + if [ "$os" = "freebsd" ]; then + echo "group/$name: FreeBSD doesn't support password modification" >&2 + exit 1 + fi case "$os_version" in "Red Hat Enterprise Linux Server release "[45]*|"CentOS release "[45]*) # TODO: Use gpasswd? Need to fix gshadow explorer first. @@ -57,15 +62,42 @@ if grep -q "^${name}:" "$__object/explorer/group"; then done if [ $# -gt 0 ]; then - echo groupmod "$@" "$name" - else - true + case $os in + freebsd) + echo pw group mod "$@" "$name" + ;; + *) + echo groupmod "$@" "$name" + ;; + esac fi else for property in $(ls .); do new_value="$(cat "$property")" - set -- "$@" "--$property" \"$new_value\" + if [ "$os" = "freebsd" ]; then + case $property in + gid) + proparg="-g" + ;; + *) + echo "Unknown property: $property" >&2 + exit 1 + ;; + esac + else + proparg="--$property" + fi + + set -- "$@" "$proparg" \"$new_value\" done - echo groupadd "$@" "$name" + case $os in + freebsd) + echo pw group add "$@" "$name" + ;; + *) + echo groupadd "$@" "$name" + ;; + esac fi + From 946d2b9d43b9336783809c0c28e5b72b0a43c988 Mon Sep 17 00:00:00 2001 From: Jake Guffey Date: Mon, 25 Jun 2012 13:19:19 -0400 Subject: [PATCH 2/3] Change order of checks per telmich's suggestion in https://github.com/telmich/cdist/pull/82/files#r1043875 --- conf/type/__group/gencode-remote | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/conf/type/__group/gencode-remote b/conf/type/__group/gencode-remote index d2bdb6fb..f42e8524 100755 --- a/conf/type/__group/gencode-remote +++ b/conf/type/__group/gencode-remote @@ -36,7 +36,6 @@ if grep -q "^${name}:" "$__object/explorer/group"; then case "$property" in password) - current_value="$(awk -F: '{ print $2 }' < "$__object/explorer/gshadow")" if [ "$os" = "freebsd" ]; then echo "group/$name: FreeBSD doesn't support password modification" >&2 exit 1 @@ -48,6 +47,7 @@ if grep -q "^${name}:" "$__object/explorer/group"; then exit 1 ;; esac + current_value="$(awk -F: '{ print $2 }' < "$__object/explorer/gshadow")" ;; gid) # set to -g to support older redhat/centos From fbdbbddf3bfd22808219bf15e94aea38b95c536b Mon Sep 17 00:00:00 2001 From: Jake Guffey Date: Mon, 25 Jun 2012 13:29:10 -0400 Subject: [PATCH 3/3] Align messages for "password" parameter Use same general message if the "password" parameter is given for a FreeBSD target host whether the group exists yet or not Make language clearer surrounding the default case --- conf/type/__group/gencode-remote | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/conf/type/__group/gencode-remote b/conf/type/__group/gencode-remote index f42e8524..bb6797c2 100755 --- a/conf/type/__group/gencode-remote +++ b/conf/type/__group/gencode-remote @@ -79,8 +79,14 @@ else gid) proparg="-g" ;; + password) + echo "group/$name: FreeBSD doesn't support password setting" >&2 + exit 1 + ;; *) - echo "Unknown property: $property" >&2 + # The type has been updated to support more properties than it knows how to handle for FreeBSD + # tell the user about this. + echo "Currently unknown property: $property" >&2 exit 1 ;; esac