summaryrefslogtreecommitdiffstats
path: root/meta/recipes-core/coreutils/coreutils-6.9/coreutils-fix-install.patch
diff options
context:
space:
mode:
Diffstat (limited to 'meta/recipes-core/coreutils/coreutils-6.9/coreutils-fix-install.patch')
-rw-r--r--meta/recipes-core/coreutils/coreutils-6.9/coreutils-fix-install.patch99
1 files changed, 99 insertions, 0 deletions
diff --git a/meta/recipes-core/coreutils/coreutils-6.9/coreutils-fix-install.patch b/meta/recipes-core/coreutils/coreutils-6.9/coreutils-fix-install.patch
new file mode 100644
index 0000000000..1b989f5311
--- /dev/null
+++ b/meta/recipes-core/coreutils/coreutils-6.9/coreutils-fix-install.patch
@@ -0,0 +1,99 @@
1The install command doesn't over write the dangling symlink, for
2example:
3
4$ install fileA /tmp/fileA
5
6If /tmp/fileA is a dangling symlink, there would be an error:
7
8install: cannot create regular file '/tmp/fileA': File exists
9
10This is because of the following code in copy.c:
11
12 if (!new_dst)
13 {
14 if (XSTAT (x, dst_name, &dst_sb) != 0)
15 {
16 if (errno != ENOENT)
17 {
18 error (0, errno, _("cannot stat %s"), quote (dst_name));
19 return false;
20 }
21 else
22 {
23 new_dst = true;
24 }
25 }
26
27XSTAT() use stat() for dst_name(the dangling symlink /tmp/fileA) when
28install.c invokes it, and stat will set errno to ENOENT, and then
29new_dst will be set to true which means that /tmp/fileA doesn't exist,
30then we will create /tmp/fileA without remove it first, so the error
31comes.
32
33This is fixed in a way which adds the member cmd_install in
34struct cp_options to make sure my change only affected to the install
35command and use lstat to fix the problem.
36
37Signed-off-by: Robert Yang <liezhi.yang@windriver.com>
38Signed-off-by: Mark Hatle <mark.hatle@windriver.com>
39
40---
41 src/copy.c | 10 +++++++++-
42 src/copy.h | 3 +++
43 src/install.c | 1 +
44 3 files changed, 13 insertions(+), 1 deletions(-)
45
46diff --git a/src/copy.c b/src/copy.c
47--- a/src/copy.c
48+++ b/src/copy.c
49@@ -1029,6 +1029,7 @@ copy_internal (char const *src_name, char const *dst_name,
50 bool delayed_ok;
51 bool copied_as_regular = false;
52 bool preserve_metadata;
53+ int dst_stat_result;
54
55 if (x->move_mode && rename_succeeded)
56 *rename_succeeded = false;
57@@ -1069,7 +1070,14 @@ copy_internal (char const *src_name, char const *dst_name,
58
59 if (!new_dst)
60 {
61- if (XSTAT (x, dst_name, &dst_sb) != 0)
62+ if ( x->cmd_install && ( x->backup_type == no_backups))
63+ dst_stat_result = lstat (dst_name, &dst_sb);
64+ else
65+ {
66+ dst_stat_result = XSTAT (x, dst_name, &dst_sb);
67+ }
68+
69+ if (dst_stat_result != 0)
70 {
71 if (errno != ENOENT)
72 {
73diff --git a/src/copy.h b/src/copy.h
74--- a/src/copy.h
75+++ b/src/copy.h
76@@ -114,6 +114,9 @@ struct cp_options
77 If that fails, then resort to copying. */
78 bool move_mode;
79
80+ /* For the install command */
81+ bool cmd_install;
82+
83 /* Whether this process has appropriate privileges to chown a file
84 whose owner is not the effective user ID. */
85 bool chown_privileges;
86diff --git a/src/install.c b/src/install.c
87--- a/src/install.c
88+++ b/src/install.c
89@@ -149,6 +149,7 @@ cp_option_init (struct cp_options *x)
90 x->hard_link = false;
91 x->interactive = I_UNSPECIFIED;
92 x->move_mode = false;
93+ x->cmd_install = true;
94 x->chown_privileges = chown_privileges ();
95 x->one_file_system = false;
96 x->preserve_ownership = false;
97--
981.7.0.1
99