Re: Selinux and denyhosts

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

 



Jason L Tibbitts III wrote:
I maintain the denyhosts package in Fedora Extras.  Recently a user
reported that denyhosts resets the security context on /etc/hosts.deny
which breaks other services.  (The ticket is
https://bugzilla.redhat.com/212771 .)

It isn't completely clear what is happening from the report.
Denyhosts performs two operations on hosts.deny:

1) When adding new hosts, it appends (usually) two lines to the file.
2) When purging old hosts, it creates a new temporary file (currently
   named hosts.deny.purge.tmp, although there's certainly no permanent
   guarantee of this), copies over the lines not being purged, and
   then renames the new file into place.

My understanding is that the first operation won't change the security
context of the file, but the second is quite likely to.

Unfortunately the reporter hasn't provided any information about
whether my last suggestion of running

semanage fcontext -a -t etc_t /etc/hosts.deny.purge.tmp

or using a pattern helped the situation.  My understanding is that
this should fix the issue, but I am far from a selinux expert.  Might
anyone have additional advice?  Is there any way to future-proof this
in case upstream decides to use a different temporary filename?  Would
it be reasonable to create a full policy for denyhosts?

Using semanage like this is unlikely to improve the situation, as the pathname-based default file contexts that it manages are used only in a few special circumstances, such as installing packages or using "restorecon".

I think the suggestion in comment #2 of running restorecon on the new file is the safest one, as it will work if the default context of the hosts.deny file changes. Of course, this will leave a small window of time where the file has the wrong context between creation of the new file and the running of restorecon, so you might also consider doing the equivalent of "chcon -t etc_t $TMPFILE" before moving it into place.

It'd be nice if there was a way of setting the context of a file to be the same as the context of another file (somewhat like the --reference option of touch), which would be useful in cases like this.

Paul.

--
fedora-selinux-list mailing list
fedora-selinux-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/fedora-selinux-list

[Index of Archives]     [Fedora Users]     [Fedora Desktop]     [Big List of Linux Books]     [Yosemite News]     [Yosemite Campsites]     [KDE Users]     [Gnome Users]

  Powered by Linux