diff options
author | Brad Bishop <bradleyb@fuzziesquirrel.com> | 2016-08-16 05:35:58 +0300 |
---|---|---|
committer | Patrick Williams <patrick@stwcx.xyz> | 2016-09-06 04:55:34 +0300 |
commit | 58700d1e5e5a168cada948fce2fb26937e95fc3e (patch) | |
tree | 05d37269ffe3c88718a7ac08ca416e08928594ac /meta-phosphor/classes/obmc-phosphor-systemd.bbclass | |
parent | 6b136a4377c420f8c6d46dca6f07a6d3bf471bae (diff) | |
download | openbmc-58700d1e5e5a168cada948fce2fb26937e95fc3e.tar.xz |
Allow package wide user specificiation
Allow the user to be specified package wide or per unit.
Change-Id: I19a56001bd2115462f132c3079690c4b2d0a5ddf
Signed-off-by: Brad Bishop <bradleyb@fuzziesquirrel.com>
Diffstat (limited to 'meta-phosphor/classes/obmc-phosphor-systemd.bbclass')
-rw-r--r-- | meta-phosphor/classes/obmc-phosphor-systemd.bbclass | 37 |
1 files changed, 21 insertions, 16 deletions
diff --git a/meta-phosphor/classes/obmc-phosphor-systemd.bbclass b/meta-phosphor/classes/obmc-phosphor-systemd.bbclass index 04b813506..2cb060cce 100644 --- a/meta-phosphor/classes/obmc-phosphor-systemd.bbclass +++ b/meta-phosphor/classes/obmc-phosphor-systemd.bbclass @@ -22,8 +22,9 @@ # where {VAR} is the format string bitbake should look for in the # unit file and VALUE is the value to substitute. # -# SYSTEMD_USER_${PN}_${PN}.service = "foo" -# The user for the unit. +# SYSTEMD_USER_${PN}.service = "foo" +# SYSTEMD_USER_${unit}.service = "foo" +# The user for the unit/package. inherit obmc-phosphor-utils @@ -87,12 +88,6 @@ python() { set_append(d, 'SYSTEMD_SUBSTITUTIONS_%s' % unit, '%s:%s' % (x, d.getVar(x, True))) - user = d.getVar( - 'SYSTEMD_USER_%s_%s' % (pkg, unit), True) - if user: - set_append(d, 'SYSTEMD_SUBSTITUTIONS_%s' % unit, - 'USER:%s' % d.getVar('SYSTEMD_USER_%s_%s' % (pkg, unit), True)) - def add_sd_user(d, unit, pkg): opts = [ @@ -103,14 +98,24 @@ python() { '--shell /sbin/nologin', '--user-group'] - user = d.getVar( - 'SYSTEMD_USER_%s_%s' % (pkg, unit), True) - if user: - set_append( - d, - 'USERADD_PARAM_%s' % pkg, - '%s' % (' '.join(opts + [user])), - ';') + var = 'SYSTEMD_USER_%s' % unit + user = listvar_to_list(d, var) + if len(user) is 0: + var = 'SYSTEMD_USER_%s' % pkg + user = listvar_to_list(d, var) + if len(user) is not 0: + if len(user) is not 1: + bb.fatal('Too many users assigned to %s: \'%s\'' % (var, ' '.join(user))) + + user = user[0] + set_append(d, 'SYSTEMD_SUBSTITUTIONS_%s' % unit, + 'USER:%s' % user) + if user not in d.getVar('USERADD_PARAM_%s' % pkg, True): + set_append( + d, + 'USERADD_PARAM_%s' % pkg, + '%s' % (' '.join(opts + [user])), + ';') if pkg not in d.getVar('USERADD_PACKAGES', True): set_append(d, 'USERADD_PACKAGES', pkg) |