Bug 1475462

Summary: nfsdcltrack -d should log to syslog without -f/--foreground specified
Product: Red Hat Enterprise Linux 7 Reporter: ChunYu Wang <chunwang>
Component: nfs-utilsAssignee: Steve Dickson <steved>
Status: CLOSED ERRATA QA Contact: Yongcheng Yang <yoyang>
Severity: unspecified Docs Contact:
Priority: medium    
Version: 7.4CC: swhiteho, xzhou, yoyang
Target Milestone: rc   
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: nfs-utils-1.3.0-0.49.el7 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2018-04-10 18:21:01 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:

Description ChunYu Wang 2017-07-26 18:05:04 UTC
-- Description of problem:

Upstream nfs-utils has just fixed a minor error of nfsdcltrack, the original nfsdcltrack -d will not write log to the syslog but it will always choose stderr as destination.  

-- Upstream patch
commit 6b8ee0f663c44452a7568a0f2ffb038ee7ae0972
Author: Steve Dickson <steved>
Date:   Wed Jul 19 16:37:56 2017 -0400

    nfsmount: remove a warning
    
    nfsmount.c:684:8: warning: this statement may fall through [-Wimplicit-fallthrough=]
    
    Signed-off-by: Steve Dickson <steved>

-- Behaviour described in nfsdcltrack(8) manual pages
    13	       -d, --debug
    14	           Enable debug level logging.

    15	       -f, --foreground
    16	           Log to stderr instead of syslog.

Without -f/--foreground specified, the nfsdcltrack -d should log to syslog (instead of stderr).

-- Test - Current:

[chunwang@bootp utils]$ nfsdcltrack init -d
nfsdcltrack: Unable to prune capability 0 from bounding set: Operation not permitted
[chunwang@bootp x86_64]$ sudo tail -1 /var/log/messages | grep nfsdcltrack
[chunwang@bootp SOURCES]$ rpm -q nfs-utils
nfs-utils-1.3.0-0.48.el7.x86_64

-- Test - Patched:
[chunwang@bootp x86_64]$ nfsdcltrack init -d
[chunwang@bootp x86_64]$ sudo tail -1 /var/log/messages | grep nfsdcltrack
Jul 27 01:41:34 localhost nfsdcltrack[5002]: Unable to prune capability 0 from bounding set: Operation not permitted
[chunwang@bootp x86_64]$ rpm -q nfs-utils
nfs-utils-1.3.0-0.48.gitf80c998.el7.x86_64
[chunwang@bootp SOURCES]$ cat ./nfs-utils.spec |grep -i patch104
Patch104: 0010-nfsdcltrack.c-remove-a-warning.patch
%patch104 -p1

-- Version-Release number of selected component (if applicable):
nfs-utils-1.3.0-0.48.el7.x86_64

Comment 2 ChunYu Wang 2017-07-27 03:42:36 UTC
Seems I had picked up a wrong patch, the right commit is:

--
Author: Steve Dickson <steved>
Date:   Wed Jul 19 16:42:39 2017 -0400

    nfsdcltrack.c: remove a warning
    
    nfsdcltrack.c:581:4: warning: this statement may fall through [-Wimplicit-fallthrough=]
    
    Acked-by: Jeff Layton <jlayton>
    Signed-off-by: Steve Dickson <steved>

diff --git a/utils/nfsdcltrack/nfsdcltrack.c b/utils/nfsdcltrack/nfsdcltrack.c
index 124c923..0baaa3e 100644
--- a/utils/nfsdcltrack/nfsdcltrack.c
+++ b/utils/nfsdcltrack/nfsdcltrack.c
@@ -579,6 +579,7 @@ main(int argc, char **argv)
                switch (arg) {
                case 'd':
                        xlog_config(D_ALL, 1);
+                       break;
                case 'f':
                        xlog_syslog(0);
                        xlog_stderr(1);

So sorry about that.
- Chunyu

Comment 3 Yongcheng Yang 2017-09-20 07:26:22 UTC
Verified with nfs-utils-1.3.0-0.49.el7, it works as expected:

### Previously with nfs-utils-1.3.0-0.48.el7
[root ~]# rpm -q nfs-utils
nfs-utils-1.3.0-0.48.el7.x86_64
[root ~]# >/var/log/messages 
[root ~]# useradd tempUser
[root ~]# su - tempUser -c 'nfsdcltrack init -d'
nfsdcltrack: Unable to prune capability 0 from bounding set: Operation not permitted
[root ~]# echo $?
255
[root ~]# cat /var/log/messages 
Sep 20 03:16:25 localhost su: (to tempUser) root on pts/0
^^^^^^^^^^^^^ always log to foreground (not syslog) even not specified "-f"
[root ~]# 
[root ~]# >/var/log/messages 
[root ~]# su - tempUser -c 'nfsdcltrack init -f'
nfsdcltrack: Unable to prune capability 0 from bounding set: Operation not permitted
[root ~]# echo $?
255
[root ~]# cat /var/log/messages 
Sep 20 03:17:06 localhost su: (to tempUser) root on pts/0
[root ~]# 

### Updating to nfs-utils-1.3.0-0.49.el7
[root ~]# rpm -Uvh nfs-utils-1.3.0-0.49.el7.x86_64.rpm >/dev/null 
[root ~]# rpm -q nfs-utils
nfs-utils-1.3.0-0.49.el7.x86_64
[root ~]# >/var/log/messages 
[root ~]# su - tempUser -c 'nfsdcltrack init -d'
[root ~]# echo $?
255
[root ~]# cat /var/log/messages 
Sep 20 03:17:43 localhost su: (to tempUser) root on pts/0
Sep 20 03:17:44 localhost nfsdcltrack[1021]: Unable to prune capability 0 from bounding set: Operation not permitted
^^^^^^^^^^^^^^^^^^^^^^^ log to syslog (not foreground) with option "-d"
[root ~]# 
[root ~]# >/var/log/messages 
[root ~]# su - tempUser -c 'nfsdcltrack init -f'
nfsdcltrack: Unable to prune capability 0 from bounding set: Operation not permitted
[root ~]# echo $?
255
[root ~]# cat /var/log/messages 
Sep 20 03:18:02 localhost su: (to tempUser) root on pts/0
^^^^^^^^^^^^^^^^^^^^^^^ log to foreground (not syslog) with option "-f"
[root ~]#

Comment 6 Yongcheng Yang 2017-11-04 04:15:08 UTC
Moving to VERIFIED according to test logs of comment #4.

Comment 9 errata-xmlrpc 2018-04-10 18:21:01 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-2018:0981