From d59e2c64400f77875a39c5b119852723966b9a35 Mon Sep 17 00:00:00 2001 From: Evilham Date: Wed, 17 Jun 2020 22:17:27 +0200 Subject: [PATCH] [__git]: Fix explorers on *BSD stat's implementation differs between BSD and GNU/Linux Operating Systems. Tested on FreeBSD, manual-compatibility was asserted for OpenBSD and NetBSD. --- cdist/conf/type/__git/explorer/group | 12 +++++++++++- cdist/conf/type/__git/explorer/owner | 12 +++++++++++- 2 files changed, 22 insertions(+), 2 deletions(-) mode change 100644 => 100755 cdist/conf/type/__git/explorer/group mode change 100644 => 100755 cdist/conf/type/__git/explorer/owner diff --git a/cdist/conf/type/__git/explorer/group b/cdist/conf/type/__git/explorer/group old mode 100644 new mode 100755 index 3ddf9656..938f61d3 --- a/cdist/conf/type/__git/explorer/group +++ b/cdist/conf/type/__git/explorer/group @@ -2,4 +2,14 @@ destination="/$__object_id/.git" -stat --print "%G" "${destination}" 2>/dev/null || exit 0 +os="$(cat "$__global/explorer/os")" + +case $os in + *bsd) + # Checked on OpenBSD, FreeBSD and NetBSD + stat -f "%Sg" "${destination}" 2>/dev/null || exit 0 + ;; + *) + stat --print "%G" "${destination}" 2>/dev/null || exit 0 + ;; +esac diff --git a/cdist/conf/type/__git/explorer/owner b/cdist/conf/type/__git/explorer/owner old mode 100644 new mode 100755 index 4c3cd431..0442b11a --- a/cdist/conf/type/__git/explorer/owner +++ b/cdist/conf/type/__git/explorer/owner @@ -2,4 +2,14 @@ destination="/$__object_id/.git" -stat --print "%U" "${destination}" 2>/dev/null || exit 0 +os="$(cat "$__global/explorer/os")" + +case $os in + *bsd) + # Checked on OpenBSD, FreeBSD and NetBSD + stat -f "%Su" "${destination}" 2>/dev/null || exit 0 + ;; + *) + stat --print "%U" "${destination}" 2>/dev/null || exit 0 + ;; +esac