diff options
Diffstat (limited to 'meta/recipes-devtools/patchelf/patchelf/handle-read-only-files.patch')
-rw-r--r-- | meta/recipes-devtools/patchelf/patchelf/handle-read-only-files.patch | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/meta/recipes-devtools/patchelf/patchelf/handle-read-only-files.patch b/meta/recipes-devtools/patchelf/patchelf/handle-read-only-files.patch index 03b0d18a89..bf721c1af8 100644 --- a/meta/recipes-devtools/patchelf/patchelf/handle-read-only-files.patch +++ b/meta/recipes-devtools/patchelf/patchelf/handle-read-only-files.patch | |||
@@ -14,30 +14,32 @@ Signed-off-by: Fabio Berton <fabio.berton@ossystems.com.br> | |||
14 | src/patchelf.cc | 16 +++++++++++++++- | 14 | src/patchelf.cc | 16 +++++++++++++++- |
15 | 1 file changed, 15 insertions(+), 1 deletion(-) | 15 | 1 file changed, 15 insertions(+), 1 deletion(-) |
16 | 16 | ||
17 | diff --git a/src/patchelf.cc b/src/patchelf.cc | 17 | Index: git/src/patchelf.cc |
18 | index 0b4965adff83..b5db2aef0e8a 100644 | 18 | =================================================================== |
19 | --- a/src/patchelf.cc | 19 | --- git.orig/src/patchelf.cc |
20 | +++ b/src/patchelf.cc | 20 | +++ git/src/patchelf.cc |
21 | @@ -497,7 +497,17 @@ void ElfFile<ElfFileParamNames>::sortShdrs() | 21 | @@ -499,9 +499,19 @@ void ElfFile<ElfFileParamNames>::sortShd |
22 | 22 | ||
23 | static void writeFile(std::string fileName, FileContents contents) | 23 | static void writeFile(std::string fileName, FileContents contents) |
24 | { | 24 | { |
25 | - int fd = open(fileName.c_str(), O_TRUNC | O_WRONLY); | ||
26 | + struct stat st; | 25 | + struct stat st; |
27 | + int fd; | 26 | + int fd; |
28 | + | 27 | + |
28 | debug("writing %s\n", fileName.c_str()); | ||
29 | |||
30 | - int fd = open(fileName.c_str(), O_CREAT | O_TRUNC | O_WRONLY, 0777); | ||
29 | + if (stat(fileName.c_str(), &st) != 0) | 31 | + if (stat(fileName.c_str(), &st) != 0) |
30 | + error("stat"); | 32 | + error("stat"); |
31 | + | 33 | + |
32 | + if (chmod(fileName.c_str(), 0600) != 0) | 34 | + if (chmod(fileName.c_str(), 0600) != 0) |
33 | + error("chmod"); | 35 | + error("chmod"); |
34 | + | 36 | + |
35 | + fd = open(fileName.c_str(), O_TRUNC | O_WRONLY); | 37 | + fd = open(fileName.c_str(), O_CREAT | O_TRUNC | O_WRONLY, 0777); |
36 | + | 38 | + |
37 | if (fd == -1) | 39 | if (fd == -1) |
38 | error("open"); | 40 | error("open"); |
39 | 41 | ||
40 | @@ -511,6 +521,10 @@ static void writeFile(std::string fileName, FileContents contents) | 42 | @@ -515,6 +525,10 @@ static void writeFile(std::string fileNa |
41 | 43 | ||
42 | if (close(fd) != 0) | 44 | if (close(fd) != 0) |
43 | error("close"); | 45 | error("close"); |