Note: This is a beta release of Red Hat Bugzilla 5.0. The data contained within is a snapshot of the live data so any changes you make will not be reflected in the production Bugzilla. Also email is disabled so feel free to test any aspect of the site that you want. File any problems you find or give feedback here.
Bug 1687496 - nfsconf: update nfs.conf inplace instead of replacing the file
Summary: nfsconf: update nfs.conf inplace instead of replacing the file
Keywords:
Status: NEW
Alias: None
Product: Red Hat Enterprise Linux 8
Classification: Red Hat
Component: nfs-utils
Version: 8.0
Hardware: All
OS: Linux
unspecified
unspecified
Target Milestone: rc
: 8.1
Assignee: Justin Mitchell
QA Contact: Yongcheng Yang
URL:
Whiteboard:
Depends On: 1653927 1681972
Blocks:
TreeView+ depends on / blocked
 
Reported: 2019-03-11 15:42 UTC by Justin Mitchell
Modified: 2019-04-03 14:00 UTC (History)
3 users (show)

Fixed In Version:
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed:
Type: Enhancement
Target Upstream Version:


Attachments (Terms of Use)
Modify nfs.conf in-place (deleted)
2019-03-20 10:27 UTC, Justin Mitchell
no flags Details | Diff
Proposed patch to impliment file rewriting (deleted)
2019-03-20 16:35 UTC, Justin Mitchell
no flags Details | Diff

Description Justin Mitchell 2019-03-11 15:42:59 UTC
Description of problem:

When nfsconf tool is used to update the contents of nfs.conf it replaces the file rather than changing the contents, and in the process loses any special permissions or modes the previous version of the file held.

As can be seen in bug 1655880

Version-Release number of selected component (if applicable):
since nfs-utils-2.3.3

How reproducible:
always

Steps to Reproduce:
1. Use nfsconf or any tool that uses it e.g nfsconvert

Actual results:
#  ls -al /etc/nfs.conf
-rw-------. 1 root root 1090 Mar 11 10:25 /etc/nfs.conf

Expected results:
#  ls -al /etc/nfs.conf
-rw-r--r--. 1 root root 1090 Mar 11 10:25 /etc/nfs.conf


Additional info:
The affected functionality exists in conffile.c within the nfs-utils main code and not just within the nfsconf cli, the code should be changed to rewrite the contents of the existing file instead of replacing the old version with a newly written replacement, this does however leave a larger window of opportunity for race conditions if some method other than nfsconf attempts to alter the same file simultaneously.

Comment 1 Justin Mitchell 2019-03-20 10:27:57 UTC
Created attachment 1545998 [details]
Modify nfs.conf in-place

Proposed patch to modify the file contents and guard it with an flock

Comment 2 Justin Mitchell 2019-03-20 16:35:52 UTC
Created attachment 1546161 [details]
Proposed patch to impliment file rewriting


Note You need to log in before you can comment on or make changes to this bug.