1

I’ve built a debian package that is simply putting file to /etc/sensu/plugins so that my checks get distributed that way.

Now I wrote a new check, built the package and installed it everywhere but noticed I forgot to make the file +x.

So I made the file +x and built the package again but when I install it everywhere it does not overwrite the permissions on that file.

How do I force it to do so?

Rick Rackow
  • 1,490
  • 8
  • 19

1 Answers1

2

The main issue is that files in /etc are considered conffiles by dh_installdeb, that you are probably using during package build and thus are treated in a particular way by the packaging system as it is supposed that users may edit those files and that those changes should be preserved. For this reason they will not be removed with the package unless you explicitly purge it and they will preserve their permissions. I do not know any way that will let you to change the permissions of the configuration files with those of the same files in the package (e.g., --force-confnew option of dpkg does not work).

From the admin point of view, you should either purge the package (so that configuration files will be removed) and then reinstall the package or manually changing permissions.

From the packager point of view, you can fix the permissions in the postinst script, so that upgrading the package will fix the permissions. As an alternative you may also tweak the conffiles as explained here: once you install the new package, the permissions will be set to those of the files in the package.

In general you may also want to check if dh_fixperms is changing the permissions of your files during the packaging and eventually make it not act on those files (this is not the case).

Community
  • 1
  • 1
Giulio Paci
  • 303
  • 1
  • 7
  • yeah i thought of purging it but i don’t want to purge an important package on 1,5 k hosts and leave them unmonitored until i reinstalled it – Rick Rackow May 18 '16 at 06:51
  • for the post install script: it is an automated build with jenkins using a template for it and i don’t want to work on the template every time someone forgets to change permissions for a file – Rick Rackow May 18 '16 at 07:05
  • what I meant with postinst is the postinst script mentioned in https://www.debian.org/doc/debian-policy/ch-maintainerscripts.html. You can just add a chmod line there that grants proper permissions for the file. This will be executed after the installation automatically by the package manager, no human involved. – Giulio Paci May 18 '16 at 15:42
  • I just updated the answer with an explanation of the issue and another possible solution. Given your requirements and the above comments, it is very likely this new solution is the one that better fits your use case. – Giulio Paci May 18 '16 at 22:19