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 | 53 |
1 files changed, 53 insertions, 0 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 new file mode 100644 index 0000000000..9fafec4b59 --- /dev/null +++ b/meta/recipes-devtools/patchelf/patchelf/handle-read-only-files.patch | |||
@@ -0,0 +1,53 @@ | |||
1 | From 2a603acb65993698c21f1c6eb7664f93ad830d52 Mon Sep 17 00:00:00 2001 | ||
2 | From: Fabio Berton <fabio.berton@ossystems.com.br> | ||
3 | Date: Fri, 9 Sep 2016 16:00:42 -0300 | ||
4 | Subject: [PATCH] handle read-only files | ||
5 | Organization: O.S. Systems Software LTDA. | ||
6 | |||
7 | Patch from: | ||
8 | https://github.com/darealshinji/patchelf/commit/40e66392bc4b96e9b4eda496827d26348a503509 | ||
9 | |||
10 | Upstream-Status: Pending | ||
11 | |||
12 | Signed-off-by: Fabio Berton <fabio.berton@ossystems.com.br> | ||
13 | --- | ||
14 | src/patchelf.cc | 16 +++++++++++++++- | ||
15 | 1 file changed, 15 insertions(+), 1 deletion(-) | ||
16 | |||
17 | diff --git a/src/patchelf.cc b/src/patchelf.cc | ||
18 | index 136098f..aea360e 100644 | ||
19 | --- a/src/patchelf.cc | ||
20 | +++ b/src/patchelf.cc | ||
21 | @@ -388,7 +388,17 @@ void ElfFile<ElfFileParamNames>::sortShdrs() | ||
22 | |||
23 | static void writeFile(string fileName) | ||
24 | { | ||
25 | - int fd = open(fileName.c_str(), O_TRUNC | O_WRONLY); | ||
26 | + struct stat st; | ||
27 | + int fd; | ||
28 | + | ||
29 | + if (stat(fileName.c_str(), &st) != 0) | ||
30 | + error("stat"); | ||
31 | + | ||
32 | + if (chmod(fileName.c_str(), 0600) != 0) | ||
33 | + error("chmod"); | ||
34 | + | ||
35 | + fd = open(fileName.c_str(), O_TRUNC | O_WRONLY); | ||
36 | + | ||
37 | if (fd == -1) | ||
38 | error("open"); | ||
39 | |||
40 | @@ -397,6 +407,10 @@ static void writeFile(string fileName) | ||
41 | |||
42 | if (close(fd) != 0) | ||
43 | error("close"); | ||
44 | + | ||
45 | + if (chmod(fileName.c_str(), st.st_mode) != 0) | ||
46 | + error("chmod"); | ||
47 | + | ||
48 | } | ||
49 | |||
50 | |||
51 | -- | ||
52 | 2.1.4 | ||
53 | |||