From a837797ee350c48f5163f4d0c554854f4ca8ad4f Mon Sep 17 00:00:00 2001 From: Evilham Date: Thu, 18 Jun 2020 11:39:04 +0200 Subject: [PATCH] [__git] Simplify exporters. Instead of using stat, we can rely on ls. Thanks to @ssrq for pointing that out. --- cdist/conf/type/__git/explorer/group | 7 ++++++- cdist/conf/type/__git/explorer/owner | 27 ++------------------------- 2 files changed, 8 insertions(+), 26 deletions(-) mode change 120000 => 100755 cdist/conf/type/__git/explorer/group diff --git a/cdist/conf/type/__git/explorer/group b/cdist/conf/type/__git/explorer/group deleted file mode 120000 index dcfd4bb5..00000000 --- a/cdist/conf/type/__git/explorer/group +++ /dev/null @@ -1 +0,0 @@ -owner \ No newline at end of file diff --git a/cdist/conf/type/__git/explorer/group b/cdist/conf/type/__git/explorer/group new file mode 100755 index 00000000..9803c085 --- /dev/null +++ b/cdist/conf/type/__git/explorer/group @@ -0,0 +1,6 @@ +#!/bin/sh + +destination="/$__object_id/.git" + +# See: cdist/conf/type/__file/explorer/stat +ls -ld "$destination" | awk '{ print $4 }' diff --git a/cdist/conf/type/__git/explorer/owner b/cdist/conf/type/__git/explorer/owner index 6187dd82..ea608c89 100755 --- a/cdist/conf/type/__git/explorer/owner +++ b/cdist/conf/type/__git/explorer/owner @@ -2,28 +2,5 @@ destination="/$__object_id/.git" -action="$(basename "${0}")" - -case $action in - owner) - bsd_fmt="%Su" - linux_fmt="%U" - ;; - group) - bsd_fmt="%Sg" - linux_fmt="%G" - ;; -esac - - -os="$(uname | tr '[:upper:]' '[:lower:]')" - -case $os in - *bsd) - # Checked on OpenBSD, FreeBSD and NetBSD - stat -f "${bsd_fmt}" "${destination}" 2>/dev/null || exit 0 - ;; - *) - stat --print "${linux_fmt}" "${destination}" 2>/dev/null || exit 0 - ;; -esac +# See: cdist/conf/type/__file/explorer/stat +ls -ld "$destination" | awk '{ print $3 }'