[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Setting permissions on new users in postinst



On Thu, Feb 29, 2024 at 11:12:27AM +1100, Brian May wrote:
> See bug #1064349.
> 
> I think the problem (correct me if I am wrong!) is that the postinst -
> debian/amavisd-new.postinst - does (simplified):
> 
> === cut ===
> #DEBHELPER#
> 
> case "$1" in
>     configure)
>         # configure file permissions to use new amavis user
>     ...
> esac
> === cut ===
> 
> 
> This means that #DEBHELPER# expands to the code that creates the
> users and starts the daemons.
> 
> === cut ===
[snip the expanded code added by debhelper]
> 
> [ similar for other services that are disabled by default ]
> === cut ===
> 
> I think we have a race condition, the daemon tries to start before we
> setup the file permissions correctly. Both on sysvinit and systemd, but
> seems we can get away with this more with systemd. Probably because of
> the extra checks in the initd script that systemd version doesn't have.
> 
> But I can't move the #DEBHELPER# to the bottom, because then the setting
> the file permissions would fail because we haven't added the user yet.
> 
> How do I fix this?

I haven't tested that, but my first attempt would be to add --no-start to
the invocation of dh_installsystemd in your rules file (you may need to
add an override_dh_installsystemd target to do that), and then your
postinst script would look something like that:

  #DEBHELPER#

  setup file permissions

  deb-systemd-invoke start unit1 unit2...

Hope that helps!

G'luck,
Peter

-- 
Peter Pentchev  roam@ringlet.net roam@debian.org pp@storpool.com
PGP key:        http://people.FreeBSD.org/~roam/roam.key.asc
Key fingerprint 2EE7 A7A5 17FC 124C F115  C354 651E EFB0 2527 DF13

Attachment: signature.asc
Description: PGP signature


Reply to: