Bug 1544361

Summary: The add_installed_file method does not honor file permission mode
Product: [Fedora] Fedora Reporter: Jiri Konecny <jkonecny>
Component: python-rpmfluffAssignee: Jan Hutař <jhutar>
Status: CLOSED RAWHIDE QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: rawhideCC: dshea, ignatenko, jal233, jhutar
Target Milestone: ---   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2018-02-13 22:49:45 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
bug_reproducer.py none

Description Jiri Konecny 2018-02-12 09:37:07 UTC
Created attachment 1394823 [details]
bug_reproducer.py

Description of problem:
When add_permission_file method is called with parameter mode=0755 the created RPM file does not honor this file permission mode. It is possible that this is happening only for .so lib file.

Version-Release number of selected component (if applicable):
0.5.3-2.fc28

How reproducible:
Always

Steps to Reproduce:
1. Run my reproducer (where the mode="0755" parameter is used)
2. Look inside of the created RPM file to see that the .so file is not executable

Actual results:
The foo.so library inside is not executable even when the mode is set to 0755.

Expected results:
The foo.so library should be executable.


Additional info:
This is happening only on Rawhide. It is working correctly on Fedora 27 and before.

Comment 1 Jan Hutař 2018-02-13 21:02:03 UTC
Looking into test-rpmbuild-test-1.0-1/LOGS/x86_64/build.log, there is:

[...]
+ /usr/lib/rpm/redhat/brp-mangle-shebangs
*** WARNING: ./usr/lib/fun.so is executable but has empty or no shebang, removing executable bit
Processing files: test-1.0-1.x86_64
[...]

so I assume build process just become "smarter" in Rawhide. I thought t could be resolved with:

--- bz1544361.py.ORIG	2018-02-13 21:53:57.718403384 +0100
+++ bz1544361.py	2018-02-13 22:00:38.001926208 +0100
@@ -1,12 +1,12 @@
 #!/bin/python3
 
-from rpmfluff import SimpleRpmBuild, SourceFile
+from rpmfluff import SimpleRpmBuild, GeneratedSourceFile, make_elf
 
 
 p = SimpleRpmBuild("test", "1.0", "1")
 
 p.add_installed_file("/usr/lib/fun.so",
-                     SourceFile("fun.so", "Content of the library"),
+                     GeneratedSourceFile("fun.so", make_elf()),
                      mode="0755")
 
 p.make()

but looks like it still do not fool rpmbuild sufficiently...

Comment 2 Jan Hutař 2018-02-13 22:23:28 UTC
Hmm, had to improve our faked ELF file header a bit:

https://pagure.io/rpmfluff/c/d5db46219051aa32bdcd17a8e05bdedf3ec72520?branch=master

Comment 3 Jan Hutař 2018-02-13 22:49:45 UTC
Built into Rawhide:

https://koji.fedoraproject.org/koji/taskinfo?taskID=25018946