Page MenuHomeFreeBSD

D59144.id185092.diff
No OneTemporary

D59144.id185092.diff

diff --git a/usr.bin/xinstall/tests/install_test.sh b/usr.bin/xinstall/tests/install_test.sh
--- a/usr.bin/xinstall/tests/install_test.sh
+++ b/usr.bin/xinstall/tests/install_test.sh
@@ -567,6 +567,11 @@
atf_check install /dev/null dst/file
atf_check test -f dst/file
atf_check test ! -s dst/file
+ # what if target already exists?
+ echo "The Magic Words are Squeamish Ossifrage" >dst/file
+ atf_check test -s dst/file
+ atf_check install /dev/null dst/file
+ atf_check test ! -s dst/file
}
atf_test_case stdin
@@ -575,16 +580,21 @@
}
stdin_body() {
atf_check mkdir dst
- echo "The Magic Words are Squeamish Ossifrage" >file
- atf_check -s exit:71 -e not-empty install - dst <file
+ echo "The Magic Words are Squeamish Ossifrage" >src
+ atf_check -s exit:71 -e not-empty install - dst <src
atf_check test ! -e dst/file
- atf_check install - dst/file <file
- atf_check cmp -s file dst/file
+ atf_check install - dst/file <src
+ atf_check cmp -s dst/file src
atf_check rm dst/file
- atf_check -s exit:71 -e not-empty install /dev/stdin dst <file
+ atf_check -s exit:71 -e not-empty install /dev/stdin dst <src
atf_check test ! -e dst/file
- atf_check install /dev/stdin dst/file <file
- atf_check cmp -s file dst/file
+ atf_check install /dev/stdin dst/file <src
+ atf_check cmp -s dst/file src
+ # what if target already exists?
+ atf_check install - dst/file </dev/null
+ atf_check test ! -s dst/file
+ atf_check install /dev/stdin dst/file <src
+ atf_check cmp -s dst/file src
}
atf_init_test_cases() {
diff --git a/usr.bin/xinstall/xinstall.c b/usr.bin/xinstall/xinstall.c
--- a/usr.bin/xinstall/xinstall.c
+++ b/usr.bin/xinstall/xinstall.c
@@ -409,7 +409,7 @@
usage();
}
- if (!no_target && linkmode == 0) {
+ if (!no_target && linkmode == 0 && strcmp(*argv, "-") != 0) {
if (stat(*argv, &from_sb))
err(EX_OSERR, "%s", *argv);
if (!S_ISREG(to_sb.st_mode))
@@ -882,7 +882,7 @@
if ((to_fd = open(to_name, O_RDONLY)) < 0)
err(EX_OSERR, "%s", to_name);
if (devnull)
- files_match = to_sb.st_size == 0;
+ files_match = (to_sb.st_size == 0);
else if (ispipe)
files_match = false;
else {
@@ -972,7 +972,7 @@
if (!files_match) {
#if HAVE_STRUCT_STAT_ST_FLAGS
/* Try to turn off the immutable bits. */
- if (to_sb.st_flags & NOCHANGEBITS)
+ if (exists && (to_sb.st_flags & NOCHANGEBITS))
(void)chflags(to_name, to_sb.st_flags & ~NOCHANGEBITS);
#endif
if (exists && dobackup) {

File Metadata

Mime Type
text/plain
Expires
Sun, Sep 20, 2:51 PM (17 h, 10 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
39301228
Default Alt Text
D59144.id185092.diff (2 KB)

Event Timeline