From c9748e33501dcb75b3c1fa97a0dd6180666fdfaa Mon Sep 17 00:00:00 2001 From: Julio Montes Date: Fri, 15 Apr 2016 11:31:29 -0500 Subject: [PATCH] add condition to create default user account once --- src/main.c | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/src/main.c b/src/main.c index 5e76967..ff30230 100644 --- a/src/main.c +++ b/src/main.c @@ -45,6 +45,7 @@ #include #include #include +#include #include @@ -305,18 +306,20 @@ int main(int argc, char *argv[]) { } if (first_boot_setup && first_boot) { - /* default user will be used by ccmodules and datasources */ - g_snprintf(command, LINE_MAX, USERADD_PATH - " -U -d '%s' -G '%s' -f '%s' -e '%s' -s '%s' -c '%s' -p '%s' '%s'" - , DEFAULT_USER_HOME_DIR - , DEFAULT_USER_GROUPS - , DEFAULT_USER_INACTIVE - , DEFAULT_USER_EXPIREDATE - , DEFAULT_USER_SHELL - , DEFAULT_USER_GECOS - , DEFAULT_USER_PASSWORD - , DEFAULT_USER_USERNAME); - exec_task(command); + if (!getpwnam(DEFAULT_USER_USERNAME)) { + /* default user will be used by ccmodules and datasources */ + g_snprintf(command, LINE_MAX, USERADD_PATH + " -U -d '%s' -G '%s' -f '%s' -e '%s' -s '%s' -c '%s' -p '%s' '%s'" + , DEFAULT_USER_HOME_DIR + , DEFAULT_USER_GROUPS + , DEFAULT_USER_INACTIVE + , DEFAULT_USER_EXPIREDATE + , DEFAULT_USER_SHELL + , DEFAULT_USER_GECOS + , DEFAULT_USER_PASSWORD + , DEFAULT_USER_USERNAME); + exec_task(command); + } } /* process metadata from metadata service */