Bug 814427

Summary: Unexpected /sbin/securetty failure with read-only root file system
Product: Red Hat Enterprise Linux 6 Reporter: Rick Mohr <rfmohr>
Component: initscriptsAssignee: Lukáš Nykrýn <lnykryn>
Status: CLOSED ERRATA QA Contact: qe-baseos-daemons
Severity: low Docs Contact:
Priority: low    
Version: 6.2CC: azelinka, bugzilla, jrieden, jscotka, notting, vpavlin
Target Milestone: rc   
Target Release: ---   
Hardware: x86_64   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Cause: Securetty always tries to open file /etc/securetty read/write mode Consequence: On readonly root filesystem this leads to failure even if the tty already exists, thus file won't be changed Fix: Check if the file really needs to be edited, if not, just exit correctly. Result: Securetty should now work correctly with readonly root.
Story Points: ---
Clone Of: Environment:
Last Closed: 2013-11-21 22:09:51 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:
Embargoed:
Attachments:
Description Flags
lightly tested patch
none
better patch none

Description Rick Mohr 2012-04-19 20:38:59 UTC
Description of problem:

During startup, a host with a read-only NFS root file system triggers /etc/init/serial.conf which attempts to run "/sbin/securetty ttyS0".  Even though "ttyS0" already exists in the /etc/securetty file, the command fails with the following error:

securetty: Couldn't open /etc/securetty: Permission denied

The permissions are correct, and the root user can successfully run "cat /etc/securetty".


Version-Release number of selected component (if applicable):

initscripts-9.03.27-1.el6

How reproducible:
Always

Steps to Reproduce:
1. Boot system with read-only root file system
2. Run "/sbin/securetty $DEV" where $DEV is a device name that already exists in /etc/securetty.
  
Actual results:

Command failure (rc=1)

Expected results:

Command should succeed. Because the device already exists in /etc/securetty, the file does not need to be modified.

Additional info:

Looking at the source code, it appears that /sbin/securetty attempts to open /etc/securetty in read-write mode before even checking if the file needs to be modified.  If the root file system is mounted read-only, the results in a failure.  A better approach would be to check if the file needs to be modified, and if not, exit with rc=0.

Comment 2 Bill Nottingham 2012-04-19 21:05:17 UTC
Created attachment 578786 [details]
lightly tested patch

Here's a lightly tested patch to do just that.

Comment 3 Bill Nottingham 2012-04-19 21:09:45 UTC
Created attachment 578789 [details]
better patch

And a better one that removes the now-obsolete check in rewrite_securetty.

Comment 5 RHEL Program Management 2012-07-10 08:35:54 UTC
This request was not resolved in time for the current release.
Red Hat invites you to ask your support representative to
propose this request, if still desired, for consideration in
the next release of Red Hat Enterprise Linux.

Comment 6 RHEL Program Management 2012-07-10 23:25:59 UTC
This request was erroneously removed from consideration in Red Hat Enterprise Linux 6.4, which is currently under development.  This request will be evaluated for inclusion in Red Hat Enterprise Linux 6.4.

Comment 14 David Mansfield 2013-09-10 20:08:59 UTC
this never made 6.4 as far as I can tell. I have the exact same problem.

Comment 15 Lukáš Nykrýn 2013-09-11 06:26:47 UTC
No, this will be fixed in 6.5.

Comment 17 errata-xmlrpc 2013-11-21 22:09:51 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory, and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

http://rhn.redhat.com/errata/RHBA-2013-1679.html