Bug 1748685

Summary: compress/uncompress file shows "chown error (ignored) file: Operation not permitted"
Product: Red Hat Enterprise Linux 7 Reporter: yangfei <feyang>
Component: ncompressAssignee: Petr Kubat <pkubat>
Status: CLOSED CURRENTRELEASE QA Contact: RHEL CS Apps Subsystem QE <rhel-cs-apps-subsystem-qe>
Severity: medium Docs Contact:
Priority: urgent    
Version: 7.6CC: databases-maint, fkrska, hhorak, jhuo, odubaj, panovotn, pkubat, praiskup, rmetrich, vdanek
Target Milestone: rcKeywords: ZStream
Target Release: ---   
Hardware: Unspecified   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: No Doc Update
Doc Text:
Story Points: ---
Clone Of:
: 1823668 1830869 (view as bug list) Environment:
Last Closed: 2020-10-21 09:36:44 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:
Bug Depends On:    
Bug Blocks: 1823668, 1830869    

Description yangfei 2019-09-04 01:58:23 UTC
Description of problem:


compress/uncompress report error on nfs share directory.

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

$ diff -u ncompress-4.2.4/compress42.c ncompress-4.2.4.4/compress42.c
--- ncompress-4.2.4/compress42.c        2019-08-30 10:08:13.114575607 +0100            <=== RHEL6
+++ ncompress-4.2.4.4/compress42.c      2019-08-30 10:08:25.478744353 +0100            <=== RHEL7
...
@@ -1222,7 +1252,12 @@
                                                exit_code = 1;
                                        }
 #ifndef        DOS
-                                       chown(ofname, infstat.st_uid, infstat.st_gid);  /* Copy ownership */
+                                       if (chown(ofname, infstat.st_uid, infstat.st_gid))      /* Copy ownership */
+                                       {
+                                               fprintf(stderr, "\nchown error (ignored) ");
+                                               perror(ofname);
+                                               exit_code = 1;
+                                       }
 #endif
 #endif


How reproducible:

rhel7/ kernel-3.10.0-862.el7.x86_64

x.x.x.x:/test /test1 nfs4 rw,relatime,vers=4.0,rsize=262144,wsize=262144,namlen=255,hard,proto=tcp,port=0,timeo=600,retrans=2,sec=sys,clientaddr=10.72.37.x,local_lock=none,addr=10.72.37.x 0 0

# compress t2 

chown error (ignored) t2.Z: Operation not permitted
[root@mytest test1]# ll
total 5980084
-rw-r--r-- 1 nobody nobody 6123565056 May 17  2018 file
-rw-r--r-- 1 nobody nobody      34563 Aug 29 17:00 t2.Z
-rw-r--r-- 1 nobody nobody          0 Jul  9 13:01 testing


rhel6/kernel-2.6.32-754.12.1.el6.x86_64

x.x.x.x:/test/ /test nfs4 rw,relatime,vers=4,rsize=262144,wsize=262144,namlen=255,hard,proto=tcp,port=0,timeo=600,retrans=2,sec=sys,clientaddr=10.72.37.x,minorversion=0,local_lock=none,addr=10.72.37.x 0 0

# compress t2 
[root@myldap test]# ll
total 5980084
-rw-r--r-- 1 nobody nobody 6123565056 May 17  2018 file
-rw-r--r-- 1 nobody nobody      34563 Aug 29 17:00 t2.Z
-rw-r--r-- 1 nobody nobody          0 Jul  9 13:01 testing

From strace result,we can see rhel6 report "exited with 0"but rhel7 "exited with 1",  ?

rhel6:

utime("t2.Z", [2019/08/30-10:37:34, 2019/08/29-17:00:07]) = 0
chmod("t2.Z", 0644)                     = 0
chown("t2.Z", 99, 99)                   = -1 EPERM (Operation not permitted)
unlink("t2")                            = 0
exit_group(0)                           = ?
+++ exited with 0 +++


# rhel7 as following

utime("t2.Z", [2019/08/30-10:37:34, 2019/08/29-17:00:07]) = 0
chmod("t2.Z", 0644)                     = 0
chown("t2.Z", 99, 99)                   = -1 EPERM (Operation not permitted)
write(2, "\nchown error (ignored) ", 23
chown error (ignored) ) = 23
write(2, "t2.Z: Operation not permitted\n", 30t2.Z: Operation not permitted
) = 30
unlink("t2")                            = 0
exit_group(1)                           = ?
+++ exited with 1 +++


Expected results:

Why rhel6 report "exited with 0"but rhel7 "exited with 1",  ?

Comment 2 Petr Kubat 2019-09-04 05:42:03 UTC
Hi yangfei,

thanks for the report, though I am not sure I understand it correctly. It seems like you are asking why there a warning that the return value of chown got ignored in RHEL7, but there is none on RHEL6?
The reason for this is that RHEL6 has slightly older ncompress version (4.2.4), while RHEL7 carries a slightly newer one (4.2.4.4). As far as I can see the chown check got added in 4.2.4.3 [1] so it makes sense it is not present in rhel6.

[1] https://github.com/vapier/ncompress/commit/c3f07e983f80be6d48c5c4380247cb34a4bfa1f2

Comment 3 yangfei 2019-09-04 05:52:31 UTC
Hello Petr,

Thanks for your replying!

the point cu focused is about the return code, because their application will check the return code, so cu confused why rhel6 and rhel7 are different. 

Is this a bug in rhel6 and rhel7 fixes it ?

Comment 4 Petr Kubat 2019-09-04 06:08:27 UTC
Ah yes, thanks for restating!

It does look like a bugfix that happened in 4.2.4.3, though I do not have any details about it as it is pretty old.
Looking at the code, the other branches that ignore return values of calls to chmod, utime and unlink also set the exit code to 1 so I would say it is expected to happen with the call to chown as well:

https://github.com/vapier/ncompress/blob/ncompress-4.2.4/compress42.c#L1188

I can raise a question to upstream to provide more details about the exit code value if you want me to.

Comment 5 yangfei 2019-09-04 06:22:54 UTC
cool, much appreciated for raising the question to upstream, customer would like to know the result  : )

Comment 6 Petr Kubat 2019-09-04 10:43:41 UTC
Question raised overe here: https://github.com/vapier/ncompress/issues/22

Comment 7 Petr Kubat 2019-10-23 07:30:04 UTC
Fixed upstream via: https://github.com/vapier/ncompress/pull/25