Skip to content

Commit

Permalink
Add --with-group= option to config.ac
Browse files Browse the repository at this point in the history
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!
  • Loading branch information
John Jolly authored and garlick committed Jan 26, 2024
1 parent 4c52d4c commit e9df3ac
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 3 deletions.
17 changes: 17 additions & 0 deletions config/ac_runas.m4
Original file line number Diff line number Diff line change
@@ -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)]),
Expand All @@ -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)
])
2 changes: 1 addition & 1 deletion configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -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

##
Expand Down
4 changes: 2 additions & 2 deletions etc/powerman.service.in
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit e9df3ac

Please sign in to comment.