From f517979c20159653de41b59c19e685821906c483 Mon Sep 17 00:00:00 2001 From: Simon Rettberg Date: Fri, 22 Feb 2013 18:50:26 +0100 Subject: Check if passwd/group/shadow exists when trying to add a user --- helper/useradd.inc | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'helper') diff --git a/helper/useradd.inc b/helper/useradd.inc index f8675dd5..bc139021 100644 --- a/helper/useradd.inc +++ b/helper/useradd.inc @@ -70,6 +70,9 @@ add_user() { local _PASSWD=${INIT_DIR}/etc/passwd local _GROUP=${INIT_DIR}/etc/group local _SHADOW=${INIT_DIR}/etc/shadow + [ ! -f "${_PASSWD}" ] && perror "add_user: password file does not exist in target system. (build base first)" + [ ! -f "${_GROUP}" ] && perror "add_user: group file does not exist in target system. (build base first)" + [ ! -f "${_SHADOW}" ] && perror "add_user: shadow file does not exist in target system. (build base first)" if [ "x$1" != "x" ] then local USER=$1 @@ -151,6 +154,7 @@ add_group () { local _PASSWD=${INIT_DIR}/etc/passwd local _GROUP=${INIT_DIR}/etc/group local _SHADOW=${INIT_DIR}/etc/shadow + [ ! -f "${_GROUP}" ] && perror "add_user: group file does not exist in target system. (build base first)" local GROUP=$1 local GROUPID="-" if ! [[ $GROUP =~ $NAME_REGEX ]]; then -- cgit v1.2.3-55-g7522