diff --git a/cdist/conf/type/__sensible_editor/explorer/editor_path b/cdist/conf/type/__sensible_editor/explorer/editor_path index 88952e23..a1673a52 100644 --- a/cdist/conf/type/__sensible_editor/explorer/editor_path +++ b/cdist/conf/type/__sensible_editor/explorer/editor_path @@ -1,4 +1,4 @@ -#!/bin/sh +#!/bin/sh -e # # 2019 Dennis Camera (dennis.camera at ssrq-sds-fds.ch) # diff --git a/cdist/conf/type/__sensible_editor/explorer/user_home b/cdist/conf/type/__sensible_editor/explorer/user_home index dc1725a0..b88243f7 100644 --- a/cdist/conf/type/__sensible_editor/explorer/user_home +++ b/cdist/conf/type/__sensible_editor/explorer/user_home @@ -1,4 +1,4 @@ -#!/bin/sh +#!/bin/sh -e # # 2019 Dennis Camera (dennis.camera at ssrq-sds-fds.ch) # @@ -22,5 +22,12 @@ # user=$__object_id +home=$(getent passwd "${user}" | cut -d':' -f6) -getent passwd "${user}" | cut -d':' -f6 +if ! test -d "${home}" +then + echo "Cannot find home directory of user ${user}" >&2 + exit 1 +fi + +echo "${home}" diff --git a/cdist/conf/type/__sensible_editor/man.rst b/cdist/conf/type/__sensible_editor/man.rst index 4dd20a3e..2d7682a6 100644 --- a/cdist/conf/type/__sensible_editor/man.rst +++ b/cdist/conf/type/__sensible_editor/man.rst @@ -1,5 +1,5 @@ cdist-type__sensible_editor(7) -============================ +============================== NAME ---- diff --git a/cdist/conf/type/__sensible_editor/manifest b/cdist/conf/type/__sensible_editor/manifest index 5ed97533..b02625e2 100644 --- a/cdist/conf/type/__sensible_editor/manifest +++ b/cdist/conf/type/__sensible_editor/manifest @@ -24,10 +24,6 @@ os=$(cat "${__global}/explorer/os") state=$(cat "${__object}/parameter/state") user=$__object_id -editor_path=$(cat "${__object}/explorer/editor_path") -user_home=$(cat "${__object}/explorer/user_home") -group=$(cat "${__object}/explorer/group") - case $os in debian|devuan|ubuntu) @@ -39,17 +35,9 @@ in ;; esac -if test -z "${user_home}" -then - echo "Could not find ${user}'s home directory." >&2 - exit 1 -fi - -if test -z "${editor_path}" -then - echo "Editor \"$(cat "${__object}/parameter/editor")\" is missing on the target system." >&2 - exit 1 -fi +editor_path=$(cat "${__object}/explorer/editor_path") +user_home=$(cat "${__object}/explorer/user_home") +group=$(cat "${__object}/explorer/group") __file "${user_home}/.selected_editor" --state "${state}" \ --owner "${user}" --group "${group}" --mode 0644 \