6

If you upgrade a package, yum sets the file permissions to the permissions that are set in the new version of the package.

How can I stop it doing this?

I use puppet, and by default the directory you place the puppet config in is 755 and owned by root. However I want a user other than root be able to write to that directory, so I changed the permissions. But when I run yum upgrade puppet it changes the permissions back to how they were before. I want it to leave the permissions alone for directories/files that already exist.

Edit: doing the upgrade then setting the permissions back to what I want manually is not really an option, as one of the directories is a CIFS mount that is read-only, so even root cannot change the permissions of those directories.

4
  • I don't know if this is possible. I can't find anything to indicate that it is possible. You may just have to do a chown / chmod manually after you run the yum command.
    – Baazigar
    Commented Aug 3, 2015 at 15:50
  • @Baazigar I was worried that might be the answer. In my case doing it manually isn't an option because one of the directories is a mount, so I'd have to unmount, do the upgrade, then remount, which I really don't want to have to do. I'm amazed you can't do this, seems like such a basic requirement, surely people have this problem every time they upgrade apache or any applications like that? Commented Aug 4, 2015 at 6:38
  • I think the trend is for single purpose machines. If you have a single purpose puppet machine, then why bother creating a second puppet user.
    – emory
    Commented Aug 5, 2015 at 0:14
  • Could you not create a cron job that rsyncs/git fetch/somehow gets the configs from a place your puppet user has write access to and puts it in the default puppet directory.
    – emory
    Commented Aug 5, 2015 at 0:16

1 Answer 1

1

What you want to do is disable core rpm functionality. All the files contained in an rpm are stored together with a checksum, their permissions and some additional/optional flags in a package. There is no way to disable the change of permissions, as basically you want to be able to restore the default permissions if any file in the package was touched, or e.g. for verification of all the files, permissions and checksums.

Could you maybe add the output of
rpm -q --qf '[%{filenames}: %{filemodes:perms}\t%{fileflags}\n]' puppet
and mark the directory where the config is contained, and also the output of
rpm -qf /directory for the directory containing the config?

Another approach could be to use setfacl -m to add an ACE for that directory for the user, that should not be overwritten.

A different approach could be to use rpm filetriggers, but that is pretty complex, and they are nonstandard - a short search shows that CentOS/RHEL/Fedora seemingly do not support them.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .