Merge remote-tracking branch 'jake/__directory_fix'

This commit is contained in:
Nico Schottelius 2013-02-21 22:25:18 +01:00
commit a59fa92246
4 changed files with 53 additions and 7 deletions
cdist/conf/type
__directory/explorer
__jail

View file

@ -22,7 +22,18 @@
# #
destination="/$__object_id" destination="/$__object_id"
os=$("$__explorer/os")
case "$os" in
"freebsd")
cmd="stat -f %Sg"
;;
*)
cmd="stat -c %G"
;;
esac
if [ -e "$destination" ]; then if [ -e "$destination" ]; then
stat -c "%G" "$destination" $cmd "$destination"
fi fi

View file

@ -22,7 +22,18 @@
# #
destination="/$__object_id" destination="/$__object_id"
os=$("$__explorer/os")
case "$os" in
"freebsd")
cmd="stat -f %Op"
;;
*)
cmd="stat -c %a"
;;
esac
if [ -e "$destination" ]; then if [ -e "$destination" ]; then
stat -c "%a" "$destination" $cmd "$destination"
fi fi

View file

@ -22,7 +22,18 @@
# #
destination="/$__object_id" destination="/$__object_id"
os=$("$__explorer/os")
case "$os" in
"freebsd")
cmd="stat -f %Su"
;;
*)
cmd="stat -c %U"
;;
esac
if [ -e "$destination" ]; then if [ -e "$destination" ]; then
stat -c "%U" "$destination" $cmd "$destination"
fi fi

View file

@ -92,6 +92,20 @@ fi
present="$(cat "$__object/explorer/present")" present="$(cat "$__object/explorer/present")"
status="$(cat "$__object/explorer/status")" 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() { stopJail() {
# Check $status before issuing command # Check $status before issuing command
@ -160,10 +174,10 @@ EOF
createJail() { createJail() {
# Create the jail directory # Create the jail directory
cat <<EOF cat <<EOF
umask 022
mkdir -p ${jaildir}/${name} mkdir -p ${jaildir}/${name}
if [ ! -d "${jaildir}/base" ]; then if [ ! -d "${jaildir}/base" ]; then
mkdir "${jaildir}/base" mkdir "${jaildir}/base"
chmod 755 "${jaildir}/base"
tar -xzf "${jaildir}/jailbase.tgz" -C "${jaildir}/base" tar -xzf "${jaildir}/jailbase.tgz" -C "${jaildir}/base"
if [ ! -d "${jaildir}/base/usr/local" ]; then if [ ! -d "${jaildir}/base/usr/local" ]; then
mkdir -p "${jaildir}/base/usr/local" mkdir -p "${jaildir}/base/usr/local"
@ -250,7 +264,7 @@ if [ -n "$interface" ]; then
jail_${name}_interface="${interface}" jail_${name}_interface="${interface}"
END END
EOF EOF
else elif [ "$(expr "${ip}" : ".*|.*")" -eq "0" ]; then
cat <<EOF cat <<EOF
interface=\$(ifconfig -l | cut '-d ' -f1) interface=\$(ifconfig -l | cut '-d ' -f1)
cat >>/etc/rc.conf <<END cat >>/etc/rc.conf <<END
@ -316,8 +330,7 @@ echo syslogd_flags=\"-ss\" >>"${jaildir}/rw/${name}/etc/rc.conf"
EOF EOF
# Configure SSHd's listening address # Configure SSHd's listening address
cat <<EOF cat <<EOF
ip=\$(echo "${ip}" | cut '-d ' -f1) sed -E -i '.bak' -e "s/#?ListenAddress 0.0.0.0/ListenAddress ${mgmt_ip}/" "${jaildir}/rw/${name}/etc/ssh/sshd_config"
sed -i '.bak' "s/#ListenAddress 0.0.0.0/ListenAddress \${ip}/" "${jaildir}/rw/${name}/etc/ssh/sshd_config"
EOF EOF
} }