RHEL Engineering is moving the tracking of its product development work on RHEL 6 through RHEL 9 to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "RHEL project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs in the statuses "NEW", "ASSIGNED", and "POST" are being migrated throughout September 2023. Bugs of Red Hat partners with an assigned Engineering Partner Manager (EPM) are migrated in late September as per pre-agreed dates. Bugs against components "kernel", "kernel-rt", and "kpatch" are only migrated if still in "NEW" or "ASSIGNED". If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "RHEL project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/RHEL-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.
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: CLOSED ERRATA
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: Alice Mitchell
QA Contact: Yongcheng Yang
URL:
Whiteboard:
Depends On: 1653927 1681972
Blocks:
TreeView+ depends on / blocked
 
Reported: 2019-03-11 15:42 UTC by Alice Mitchell
Modified: 2020-11-14 14:27 UTC (History)
3 users (show)

Fixed In Version: nfs-utils-2.3.3-22.el8
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2019-11-05 22:18:26 UTC
Type: Enhancement
Target Upstream Version:
Embargoed:


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


Links
System ID Private Priority Status Summary Last Updated
Red Hat Product Errata RHBA-2019:3579 0 None None None 2019-11-05 22:19:43 UTC

Internal Links: 1733887

Description Alice 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 Alice 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 Alice Mitchell 2019-03-20 16:35:52 UTC
Created attachment 1546161 [details]
Proposed patch to impliment file rewriting

Comment 4 Yongcheng Yang 2019-07-11 04:19:28 UTC
Have checked the previous permissions won't be changed after "nfsconver" now:

[root@hp-dl360g9-14 ~]# rpm -q nfs-utils
nfs-utils-2.3.3-19.el8.x86_64
[root@hp-dl360g9-14 ~]# stat /etc/nfs.conf
  File: /etc/nfs.conf
  Size: 1024            Blocks: 8          IO Block: 4096   regular file
Device: fd00h/64768d    Inode: 50366035    Links: 1
Access: (0644/-rw-r--r--)  Uid: (    0/    root)   Gid: (    0/    root)
Context: system_u:object_r:etc_t:s0
Access: 2019-07-11 00:14:13.947382375 -0400
Modify: 2019-06-12 13:40:03.000000000 -0400
Change: 2019-07-11 00:14:12.997383859 -0400
 Birth: -
[root@hp-dl360g9-14 ~]# echo 'RPCNFSDARGS="-V4"' > /etc/sysconfig/nfs
[root@hp-dl360g9-14 ~]# nfsconvert
[root@hp-dl360g9-14 ~]# ls /etc/sysconfig/nfs
ls: cannot access '/etc/sysconfig/nfs': No such file or directory
[root@hp-dl360g9-14 ~]# grep -A1 '\[nfsd\]' /etc/nfs.conf
[nfsd]
vers4 = y
[root@hp-dl360g9-14 ~]# stat /etc/nfs.conf
  File: /etc/nfs.conf
  Size: 1034            Blocks: 8          IO Block: 4096   regular file
Device: fd00h/64768d    Inode: 50366035    Links: 1
Access: (0644/-rw-r--r--)  Uid: (    0/    root)   Gid: (    0/    root)
Context: system_u:object_r:etc_t:s0
Access: 2019-07-11 00:15:43.425242596 -0400
Modify: 2019-07-11 00:15:09.433295699 -0400
Change: 2019-07-11 00:15:09.434295697 -0400
 Birth: -
[root@hp-dl360g9-14 ~]# 

Will update testcase to cover this later.

Comment 9 Yongcheng Yang 2019-09-05 08:55:06 UTC
Moving to VERIFIED based on test logs of Comment #7 now.

Comment 11 errata-xmlrpc 2019-11-05 22:18:26 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.

https://access.redhat.com/errata/RHBA-2019:3579


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