From e9df3acfb96bf8f7d6ec9f7d6fe89474c5dc36c4 Mon Sep 17 00:00:00 2001 From: John Jolly Date: Thu, 15 Jun 2017 19:31:50 -0600 Subject: [PATCH] Add --with-group= option to config.ac The powerman.service file has configuration options to run the daemon as a specific user and group. The current default for both is "daemon". Changing the user is possible through --with-user= configure option, but there is no option for changing the group. In order to allow the group value to be configured at build time, a configure option similar to the --with-user= option should be provided. This change creates the --with-group= option, setting the @RUN_AS_GROUP@ macro for autoconf files. Note from @garlick: this was submitted in 2017 as pr #26 and sat around due to maintainer inattention. Rebasing and reviving as it's a good patch! --- config/ac_runas.m4 | 17 +++++++++++++++++ configure.ac | 2 +- etc/powerman.service.in | 4 ++-- 3 files changed, 20 insertions(+), 3 deletions(-) diff --git a/config/ac_runas.m4 b/config/ac_runas.m4 index f83680b3..0af89463 100644 --- a/config/ac_runas.m4 +++ b/config/ac_runas.m4 @@ -1,6 +1,7 @@ AC_DEFUN([AC_RUNAS], [ RUN_AS_USER="daemon" + RUN_AS_GROUP="daemon" AC_MSG_CHECKING(user to run as) AC_ARG_WITH(user, AS_HELP_STRING([--with-user=username], [user for powerman daemon (daemon)]), @@ -16,4 +17,20 @@ AC_DEFUN([AC_RUNAS], [Powerman daemon user]) AC_MSG_RESULT(${RUN_AS_USER}) AC_SUBST(RUN_AS_USER) + + AC_MSG_CHECKING(group to run as) + AC_ARG_WITH(group, + AC_HELP_STRING([--with-group=groupname], [group for powerman daemon (daemon)]), + [ case "${withval}" in + yes|no) + ;; + *) + RUN_AS_GROUP="${withval}" + ;; + esac], + ) + AC_DEFINE_UNQUOTED(RUN_AS_GROUP, "${RUN_AS_GROUP}", + [Powerman daemon group]) + AC_MSG_RESULT(${RUN_AS_GROUP}) + AC_SUBST(RUN_AS_GROUP) ]) diff --git a/configure.ac b/configure.ac index 54e36ade..0b048792 100644 --- a/configure.ac +++ b/configure.ac @@ -109,7 +109,7 @@ AC_DEFINE(WITH_LSD_NOMEM_ERROR_FUNC, 1, [Define lsd_fatal_error]) # whether to install pkg-config file for API AC_PKGCONFIG -# what user to run daemon as +# what user and group to run daemon as AC_RUNAS ## diff --git a/etc/powerman.service.in b/etc/powerman.service.in index 6ecc39b9..cf6952e2 100644 --- a/etc/powerman.service.in +++ b/etc/powerman.service.in @@ -6,8 +6,8 @@ After=syslog.target network.target Environment=SHELL=/bin/sh Type=forking PrivateTmp=yes -User=daemon -Group=daemon +User=@RUN_AS_USER@ +Group=@RUN_AS_GROUP@ ExecStart=@X_SBINDIR@/powermand PIDFile=@X_RUNSTATEDIR@/powerman/powermand.pid