[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH] ln: use gnulib's link module, to work around Solaris 10 deficien
From: |
Jim Meyering |
Subject: |
[PATCH] ln: use gnulib's link module, to work around Solaris 10 deficiency |
Date: |
Thu, 10 Sep 2009 18:33:54 +0200 |
Jim Meyering wrote:
> Eric Blake wrote:
>> According to Jim Meyering on 9/10/2009 6:24 AM:
>>>
>>> Currently, we're at gnulib (v0.0-2549-g2c90f1a) for the submodule.
>>> None of the patches since then seemed to be essential to coreutils
>>> on non-mingw/cygwin systems. Let me know if you'd like to use
>>> a newer version.
>>
>> Updating to v0.0-2560-g7a3196b would allow working around a Solaris 10 bug
>> where link("a","b/") succeeds and creates a file "b", rather than failing
>> because the directory "b/" does not exist. This fixes behavior visible in
>> "ln -T a b/".
>
> That's tempting.
> I've confirmed the problem, and wrote a test to exercise the bug/fix.
> I'm testing this now...
Here's a complete patch.
It passes the new test on Solaris 10,
while without the gnulib update, it would fail that one.
If this passes as well on a couple more systems, I'll push it.
As I write this, I realized that a slightly more likely
scenario is also fixed:
link f no-such-file/
I'll update NEWS and the log to mention "link", too.
Comments welcome.
>From fb19a28755f62f9f89ac0ff98638c49ab942589e Mon Sep 17 00:00:00 2001
From: Jim Meyering <address@hidden>
Date: Thu, 10 Sep 2009 17:51:44 +0200
Subject: [PATCH] ln: use gnulib's link module, to work around Solaris 10
deficiency
Before this change, :>f; ln -T f no-such/ would succeed on Solaris 10.
After it, ln fails, as it should: ln: accessing `z/': Not a directory
* bootstrap.conf (gnulib_modules): Add "link".
* tests/ln/slash-decorated-nonexistent-dest: New test.
* tests/Makefile.am (TESTS): Add it.
* NEWS (Portability): Mention the improvement.
---
NEWS | 8 ++++++
bootstrap.conf | 1 +
tests/Makefile.am | 1 +
tests/ln/slash-decorated-nonexistent-dest | 34 +++++++++++++++++++++++++++++
4 files changed, 44 insertions(+), 0 deletions(-)
create mode 100755 tests/ln/slash-decorated-nonexistent-dest
diff --git a/NEWS b/NEWS
index 26dcd59..2b35719 100644
--- a/NEWS
+++ b/NEWS
@@ -45,6 +45,14 @@ GNU coreutils NEWS -*-
outline -*-
(i.e., not inotify-based) implementation.
[bug introduced in coreutils-7.5]
+** Portability
+
+ ln -T f z/; given an existing file, f, and nothing named "z", that
+ command would mistakenly create "z" as a link to "f" on Solaris 10,
+ due to the way their link syscall works. Now, even on that type
+ of system, that ln command reports the error, as it should:
+ ln: accessing `z/': Not a directory
+
** New features
cp --reflink accepts a new "auto" parameter which falls back to
diff --git a/bootstrap.conf b/bootstrap.conf
index 7ec4b3b..c2bf753 100644
--- a/bootstrap.conf
+++ b/bootstrap.conf
@@ -130,6 +130,7 @@ gnulib_modules="
lchown
lib-ignore
linebuffer
+ link
link-follow
long-options
lstat
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 1de53bf..7a20e0c 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -345,6 +345,7 @@ TESTS = \
ln/hard-backup \
ln/misc \
ln/sf-1 \
+ ln/slash-decorated-nonexistent-dest \
ln/target-1 \
ls/abmon-align \
ls/color-clear-to-eol \
diff --git a/tests/ln/slash-decorated-nonexistent-dest
b/tests/ln/slash-decorated-nonexistent-dest
new file mode 100755
index 0000000..afbbd06
--- /dev/null
+++ b/tests/ln/slash-decorated-nonexistent-dest
@@ -0,0 +1,34 @@
+#!/bin/sh
+# ensure that touch f; ln -T f no-such-file/ does not mistakenly succeed
+
+# Copyright (C) 2009 Free Software Foundation, Inc.
+
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+if test "$VERBOSE" = yes; then
+ set -x
+ ln --version
+fi
+
+. $srcdir/test-lib.sh
+
+touch f || framework_failure
+
+fail=0
+
+# Before coreutils-7.6, this would succeed on Solaris 10
+ln -T f no-such-file/ && fail=1
+test -e no-such-file && fail=1
+
+Exit $fail
--
1.6.5.rc0.164.g5f6b0