From 005c94556e80e1eecc4db15c46d9bee4c2fa71a2 Mon Sep 17 00:00:00 2001 From: Jake Guffey Date: Tue, 19 Feb 2013 15:23:52 -0500 Subject: [PATCH 1/4] Fix to support FreeBSD's stat(1) Added check for OS type Added FreeBSD syntax in case of $os=freebsd --- cdist/conf/type/__directory/explorer/group | 14 +++++++++++++- cdist/conf/type/__directory/explorer/mode | 14 +++++++++++++- cdist/conf/type/__directory/explorer/owner | 14 +++++++++++++- 3 files changed, 39 insertions(+), 3 deletions(-) diff --git a/cdist/conf/type/__directory/explorer/group b/cdist/conf/type/__directory/explorer/group index b14794e3..4da5b45d 100644 --- a/cdist/conf/type/__directory/explorer/group +++ b/cdist/conf/type/__directory/explorer/group @@ -22,7 +22,19 @@ # destination="/$__object_id" +# Since $__global isn't available, use uname directly, uname and tr are both part of POSIX +os="$(uname -s | tr '[:upper:]' '[:lower:]')" + +case "$os" in + "freebsd") + cmd="stat -f %Sg" + ;; + *) + cmd="stat -c %G" + ;; +esac if [ -e "$destination" ]; then - stat -c "%G" "$destination" + $cmd "$destination" fi + diff --git a/cdist/conf/type/__directory/explorer/mode b/cdist/conf/type/__directory/explorer/mode index 3ffa497e..1d40c795 100644 --- a/cdist/conf/type/__directory/explorer/mode +++ b/cdist/conf/type/__directory/explorer/mode @@ -22,7 +22,19 @@ # destination="/$__object_id" +# Since $__global isn't available, use uname directly, uname and tr are both part of POSIX +os="$(uname -s | tr '[:upper:]' '[:lower:]')" + +case "$os" in + "freebsd") + cmd="stat -f %Op" + ;; + *) + cmd="stat -c %a" + ;; +esac if [ -e "$destination" ]; then - stat -c "%a" "$destination" + $cmd "$destination" fi + diff --git a/cdist/conf/type/__directory/explorer/owner b/cdist/conf/type/__directory/explorer/owner index a691ac1b..452dc672 100644 --- a/cdist/conf/type/__directory/explorer/owner +++ b/cdist/conf/type/__directory/explorer/owner @@ -22,7 +22,19 @@ # destination="/$__object_id" +# Since $__global isn't available, use uname directly, uname and tr are both part of POSIX +os="$(uname -s | tr '[:upper:]' '[:lower:]')" + +case "$os" in + "freebsd") + cmd="stat -f %Su" + ;; + *) + cmd="stat -c %U" + ;; +esac if [ -e "$destination" ]; then - stat -c "%U" "$destination" + $cmd "$destination" fi + From 52fdf15a4b82dd238579e41aab862ad15522f484 Mon Sep 17 00:00:00 2001 From: Jake Guffey Date: Tue, 19 Feb 2013 15:28:03 -0500 Subject: [PATCH 2/4] Add umask Some directories were being created 700 and causing problems, added umask 022 to fix this --- cdist/conf/type/__jail/gencode-remote | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cdist/conf/type/__jail/gencode-remote b/cdist/conf/type/__jail/gencode-remote index 7491754c..5223bc46 100755 --- a/cdist/conf/type/__jail/gencode-remote +++ b/cdist/conf/type/__jail/gencode-remote @@ -160,10 +160,10 @@ EOF createJail() { # Create the jail directory cat < Date: Tue, 19 Feb 2013 16:24:22 -0500 Subject: [PATCH 3/4] Added support for multiple IP addresses FreeBSD jails support jail_${name}_ip="iface1|addr1, iface2|addr2" format for specifying multiple IP addresses --- cdist/conf/type/__jail/gencode-remote | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/cdist/conf/type/__jail/gencode-remote b/cdist/conf/type/__jail/gencode-remote index 5223bc46..b044e4b0 100755 --- a/cdist/conf/type/__jail/gencode-remote +++ b/cdist/conf/type/__jail/gencode-remote @@ -92,6 +92,20 @@ fi present="$(cat "$__object/explorer/present")" status="$(cat "$__object/explorer/status")" +# Handle ip="iface|addr, iface|addr" format +if [ $(expr "${ip}" : ".*|.*") -gt "0" ]; then + # If we have multiple IPs defined, $interface doesn't make sense because ip="iface|addr, iface|addr" implies it + interface="" + SAVE_IFS="$IFS" + IFS=", " + for cur_ip in ${ip}; do + # Just get the last IP address for SSH to listen on + mgmt_ip=$(echo "${ip}" | sed -E -e 's/^.*\|(.*)\/[0-9]+$/\1/') + done + IFS="$SAVE_IFS" +else + mgmt_ip=$(echo "${ip}" | cut '-d ' -f1) +fi stopJail() { # Check $status before issuing command @@ -250,7 +264,7 @@ if [ -n "$interface" ]; then jail_${name}_interface="${interface}" END EOF -else +elif [ "$(expr "${ip}" : ".*|.*")" -eq "0" ]; then cat <>/etc/rc.conf <>"${jaildir}/rw/${name}/etc/rc.conf" EOF # Configure SSHd's listening address cat < Date: Tue, 19 Feb 2013 16:31:06 -0500 Subject: [PATCH 4/4] Use $__explorer to get os type --- cdist/conf/type/__directory/explorer/group | 3 +-- cdist/conf/type/__directory/explorer/mode | 3 +-- cdist/conf/type/__directory/explorer/owner | 3 +-- 3 files changed, 3 insertions(+), 6 deletions(-) diff --git a/cdist/conf/type/__directory/explorer/group b/cdist/conf/type/__directory/explorer/group index 4da5b45d..e5be37da 100644 --- a/cdist/conf/type/__directory/explorer/group +++ b/cdist/conf/type/__directory/explorer/group @@ -22,8 +22,7 @@ # destination="/$__object_id" -# Since $__global isn't available, use uname directly, uname and tr are both part of POSIX -os="$(uname -s | tr '[:upper:]' '[:lower:]')" +os=$("$__explorer/os") case "$os" in "freebsd") diff --git a/cdist/conf/type/__directory/explorer/mode b/cdist/conf/type/__directory/explorer/mode index 1d40c795..f75b282b 100644 --- a/cdist/conf/type/__directory/explorer/mode +++ b/cdist/conf/type/__directory/explorer/mode @@ -22,8 +22,7 @@ # destination="/$__object_id" -# Since $__global isn't available, use uname directly, uname and tr are both part of POSIX -os="$(uname -s | tr '[:upper:]' '[:lower:]')" +os=$("$__explorer/os") case "$os" in "freebsd") diff --git a/cdist/conf/type/__directory/explorer/owner b/cdist/conf/type/__directory/explorer/owner index 452dc672..cebd199b 100644 --- a/cdist/conf/type/__directory/explorer/owner +++ b/cdist/conf/type/__directory/explorer/owner @@ -22,8 +22,7 @@ # destination="/$__object_id" -# Since $__global isn't available, use uname directly, uname and tr are both part of POSIX -os="$(uname -s | tr '[:upper:]' '[:lower:]')" +os=$("$__explorer/os") case "$os" in "freebsd")