a small fix for __type/jail

1 view
Skip to first unread message

Shannon Prickett

unread,
Jun 2, 2026, 9:23:37 PMJun 2
to cdist-configura...@googlegroups.com
I imagine this is not a type which gets heavy use but I'm using it & fixed a small bug.
You're welcome to use or ignore the codet. Patch pasted below.
- Shannon

diff --git a/cdist/conf/type/__jail/manifest b/cdist/conf/type/__jail/manifest

index fad6a3a1..8f90ee4e 100755

--- a/cdist/conf/type/__jail/manifest

+++ b/cdist/conf/type/__jail/manifest

@@ -43,7 +43,7 @@ for property in *; do

        set -- "$@" "--$property" "$(cat "$property")"

 done


-if grep -q '^10\.' "$(cat "$__global/explorer/os_version")" ; then   # Version is 10.x

+if grep -q '^[[:digit:]]\{2,\}\.' "$__global/explorer/os_version" ; then # Version > 9.x

    __jail_freebsd10 "$@"

 else

    __jail_freebsd9 "$@"

Nico Schottelius

unread,
Jun 5, 2026, 6:49:05 AMJun 5
to Shannon Prickett, cdist-configura...@googlegroups.com

Hello Shannon,

I've applied it to the master branch. Probably going to create a release
based on it in the next weeks.

Thanks for your contribution.

BR,

Nico
--
Sustainable and modern Infrastructures by ungleich.ch

Shannon Prickett

unread,
Jun 14, 2026, 8:27:04 PMJun 14
to Nico Schottelius, cdist-configura...@googlegroups.com
Thank you for accepting my patch!

I don't want to delay your release process but I have a second path in the same neighborhood of cdist types as a candidate for inclusion in the next release.

The changes are in __jail_freebsd10/gencode-remote & reflect challenges I encountered using the type
on FreeBSD 15.0.

1. simplified the sed expression for locating the configuration stanza in /etc/jail.conf
2. changed cp -r operations to cp -a operations; the meaning of -r has drifted since release 10. -a for archive should behave more as desired.
3. I tucked a call to the cleanup function on the absent = absent happy path because a jail can be marked as absent while still present; this change ensures that every invocation of cdist is another opportunity to clean up any undesired jails.

Patch follows:

diff --git a/cdist/conf/type/__jail_freebsd10/gencode-remote b/cdist/conf/type/__jail_freebsd10/gencode-remote

index 4f376c25..89dafe42 100755

--- a/cdist/conf/type/__jail_freebsd10/gencode-remote

+++ b/cdist/conf/type/__jail_freebsd10/gencode-remote

@@ -137,7 +137,7 @@ EOF

    echo "rm -f \"/etc/fstab.${name}\""

 # Remove jail entry from jail.conf

    cat <<EOF

-      sed -i .bak -E -e "/^${name} {\$/,/^}\\\$/d" /etc/jail.conf

+      sed -i .bak  -e "/^${name} {$/,/^}$/d" /etc/jail.conf

binder@satyrine:~/cdist $ cat jail-fixes


+      cp -a ${jaildir}/base/var/* "${jaildir}/rw/${name}/var/"

    fi

    chmod 755 "${jaildir}/rw/${name}/var"

    chmod 755 "${jaildir}/base/var"

@@ -208,11 +208,11 @@ cat <<EOF

    fi

    mkdir "${jaildir}/rw/${name}/home"

    if [ -n "\$(ls ${jaildir}/base/usr/home)" ]; then

-      cp -r ${jaildir}/base/usr/home/* "${jaildir}/rw/${name}/home/"

+      cp -a ${jaildir}/base/usr/home/* "${jaildir}/rw/${name}/home/"

    fi

    mkdir "${jaildir}/rw/${name}/root"

    if [ -n "\$(ls -A ${jaildir}/base/root)" ]; then

-      cp -r ${jaildir}/base/root/ "${jaildir}/rw/${name}/root/"

+      cp -a ${jaildir}/base/root/ "${jaildir}/rw/${name}/root/"

    fi

 

 EOF

@@ -351,7 +351,8 @@ if [ "$present" = "EXISTS" ]; then   # The jail currently exists

       exit 0

    fi

 else   # The jail does not currently exist

-   if [ "$state" = "absent" ]; then   # The jail is not supposed to be present

+    if [ "$state" = "absent" ]; then   # The jail is not supposed to be present

+      deleteJail

       exit 0

    else   # The jail is supposed to exist

       createJail

Reply all
Reply to author
Forward
0 new messages