Bug 812630

Summary: set-file-selinux-context fails when the filesystem doesn't support contexts
Product: [Fedora] Fedora Reporter: Göran Uddeborg <goeran>
Component: emacsAssignee: Karel Klíč <kklic>
Status: CLOSED ERRATA QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 17CC: jonathan.underwood, kklic, rvokal
Target Milestone: ---   
Target Release: ---   
Hardware: x86_64   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2012-06-17 22:24:46 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:

Description Göran Uddeborg 2012-04-15 14:58:51 UTC
I have reported this upstreams (http://debbugs.gnu.org/cgi/bugreport.cgi?bug=11245), but I submit this report too in case you wish to apply a patch until a fix from upstreams is available.  (Or as a tracker in case you wish to wait for an upstreams fix.)

Description of problem:
After upgrading to the Fedora 17 version of emacs, I started to get messages about emacs failing to write backup files.  It says it is writing a %backup%~ file instead.  Checking in the file system, emacs has successfully made the backup file.  After a bit of investigation, I believe it has to do with emacs trying to set SELinux context on a file system which doesn't support it.  In my case, my home directory is mounted via NFS.

Version-Release number of selected component (if applicable):
emacs-24.0.95-1.fc17.x86_64

How reproducible:
Every time

Steps to Reproduce:
1. Go to a writeable directory in an NFS-mounted file system
2. touch apa
3. emacs
4. In emacs: set backup-by-copying to true (M-x s e t - v a r <tab> <return> b a c k u <tab> b y <tab> <return> t <return>)
5. In emacs: visit the file touched (C-x C-f a p a <return>)
6. In emacs: modify the file: (a p a)
7. In emacs: save the file: (C-x C-s)

Actual results:
I get the error message: Cannot write backup file; backing up in ~/.emacs.d/%backup%~

Expected results:
No error message

Additional info:
My understanding is that the root cause is the function set-file-selinux-context in fileio.c failing with a "file error" when the lsetfilecon() call fails.  But it is not really an error if it fails with errno set to ENOTSUP.  A system which does support SELinux may very well have some parts of the file tree where you can't modify the context.  Such as an NFS home directory.

It seems to me that this case should be handled in the same way as if when SELinux isn't enabled.  I.e. just return without any error.  Only if lsetfilecon() fails with errno set to something ELSE than ENOTSUP, only then should set-file-selinux-context report an error.

Comment 1 Fedora Update System 2012-05-21 14:33:37 UTC
emacs-24.0.97-1.fc17 has been submitted as an update for Fedora 17.
https://admin.fedoraproject.org/updates/emacs-24.0.97-1.fc17

Comment 2 Fedora Update System 2012-06-09 00:06:49 UTC
Package emacs-24.0.97-1.fc17:
* should fix your issue,
* was pushed to the Fedora 17 testing repository,
* should be available at your local mirror within two days.
Update it with:
# su -c 'yum update --enablerepo=updates-testing emacs-24.0.97-1.fc17'
as soon as you are able to.
Please go to the following url:
https://admin.fedoraproject.org/updates/FEDORA-2012-9148/emacs-24.0.97-1.fc17
then log in and leave karma (feedback).

Comment 3 Fedora Update System 2012-06-17 22:24:46 UTC
emacs-24.0.97-1.fc17 has been pushed to the Fedora 17 stable repository.  If problems still persist, please make note of it in this bug report.