4

I'm running CentOS 6.8, I had changed /etc/rc.d/init.d/sendmail (something I couldn't do in /etc/sysconfig/sendmail) but yum overwrote the file when updating sendmail. Is there a way to configure yum not to update certain files, and instead warn me of the change (and stash the new version somewhere, so I can merge my changes with the updates)?

  • You could always copy the script to /etc/rc.d/init.d/sendmail-custom and start that service instead. Yum will update /etc/rc.d/init.d/sendmail but not the copied version. – Michael Daffin Sep 15 '16 at 0:12
  • Since /etc/sysconfig/sendmail is probably sourced (with .) early on before any args are parsed you could add exec /...mysendmail "$@" to it and so run your overriding script. – meuh Sep 15 '16 at 9:38
3

You really can't. yum (or more strictly rpm) depends on the %config inside the RPM to decide that a file is a configuration file, i.e. a file marked with %config(noreplace) will be saved as .rpmnew when an updated file happens to be in the newer RPM.

You have two options:

  • Download the RPM (not update with you) and repackage it with %config(noreplace) for /etc/rc.d/init.d/sendmail and then install with yum.
  • Download the RPM and use rpm --excludepath to install the package. I like this option more, it is hacky but not as hacky as editing the RPM everytime it gets updated. See below:

First exclude sendmail from being updated with yum update, in /etc/yum.conf place

exclude=sendmail*

This will make yum never updated the sendmail package but it will still list it with yum check-update so you will know a new sendmail RPM is available. You can then download it with:

yum install -downloadonly --installroot=. sendmail-<version>

Then use rpm with --excludepath to not update the file in /etc/rc.d:

rpm --excludepath /etc/rc.d/init.d/sendmail sendmail-<version>.rpm

Reference on the %config:

| improve this answer | |
  • You probably don't want to stop getting software updates for sendmail. Turning off yum updates will make your system less secure. It'd probably be better to just manage your own service file while leaving the existing RPM intact, as described in the comments. – jsbillings Sep 21 '16 at 12:56
  • @jsbillings - I guess you're right if OP uses something like yum-cron. Otherwise he can just script the things together yum update && yum check-update | grep sendmail && yum install --downloadonly ... && rpm --excludepath <sendmail> (not tested). And it will pick the update. – grochmal Sep 22 '16 at 2:15
  • Uhmm, when you exclude sendmail from being updated via yum, why fiddle with rpm --excludepath when sendmail will not be updated anymore? – doktor5000 Sep 22 '16 at 19:49
  • @doktor5000 - Ekhm... because you want sendmail to receive security updates? yum is a system tool that takes RPMs as they are, whilst using rpm you can fiddle with the installation (don't ask me why it was designed that way, it just was). Therefore, if you want to fiddle with the sendmail updates you need to (1) prevent yum from updating it and overwriting files (2) use yum to download the update but not install/update it (3) use rpm to install it the way you want it installed. – grochmal Sep 22 '16 at 23:44
  • @grochmal Nope, sorry that approach is much to messy if you still want to be able to receive normal updates. I'd go another approach, don't disable exclude anything in yum config and don't fiddle with weird rpm options. Put the changes that need to be applied to /etc/rc.d/init.d/sendmail in a small scriptlet, then put that in your own empty rpm in a %triggerin section which triggers on sendmail rpm updates, as explained in rpm.org/api/4.4.2.2/triggers.html and then you can receive updates, and the changes to sendmail config will be redone each time. – doktor5000 Sep 23 '16 at 15:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.