Tcl Source Code

View Ticket
Login
Ticket UUID: 219158
Title: Test fCmd-9.4 relies on buggy rename implementation
Type: Bug Created on: 2000-10-26 05:02:25
Submitter: nobody Assigned to: jan.nijtmans
Subsystem: 37. File System Severity: Minor
Priority: 1 Zero Last modified: 2026-11-11 10:59:38
Status: Closed Closed by: jan.nijtmans
Resolution: Fixed Closed on: 2026-11-11 10:59:38
Version: obsolete: 8.0.3
Description:
OriginalBugID: 1399 Bug
Version: 8.0.3
SubmitDate: '1999-03-02'
LastModified: '2000-04-03'
Severity: LOW
Status: Assigned
Submitter: pat
ChangedBy: hobbs
OS: Linux-SuSE
OSVersion: + NCR Unix + Siemens Reliant Unix
Machine: Other
FixedDate: '2000-10-25'
ClosedDate: '2000-10-25'


Name:
Ulrich Schöbel

ReproducibleScript:
Test fCmd-9.4 works on Linux and NCR, but fails on Siemens (Reliant 5.43).

ObservedBehavior:
file rename uses the rename syscall. According to the man page and an ancient
AT&T spec "rename" should fail with EACCES when moving a 555 directory to a new
destination. fCmd-9.4 expects a buggy implementation of "rename".

DesiredBehavior:
Thus, Tcls "file rename" should fail, too.




The solaris docs seem to say the same thing, but it does indeed
work without error on Solaris (as well as Linux and HP)... 
-- 04/03/2000 hobbs
User Comments:
vincentdarley added on 2002-04-05 00:55:34:
Logged In: YES 
user_id=32170

This is not something I am qualified to look into.

dgp added on 2002-07-06 03:53:45:
Logged In: YES 
user_id=80530

should this be closed as really being "bugs"
in the operating system(s) ?

smallm added on 2008-02-11 10:14:20:
Logged In: YES 
user_id=691174
Originator: NO

OpenBSD 4.2-current also fails on this test when using Tcl 8.5.1.

According to this page below, an implementation has the option to fail 
when the source directory to rename lacks write permission:

http://www.opengroup.org/onlinepubs/009695399/functions/rename.html

"Write access permission is required for the directory containing
old and the directory containing new. If the old argument points
to the pathname of a directory, write access permission may be
required for the directory named by old, and, if it exists, the
directory named by new."

dgp added on 2013-03-24 22:10:11:
What's the story on BSD systems now?

smallm added on 2013-05-07 10:02:36:
Using 8.6.0, it still fails for me on openbsd-current dated May 3,
2013 on macppc:

fCmd.test


==== fCmd-9.4.b file rename: comprehensive: dir to new name FAILED
==== Contents of test case:

    file mkdir td1 td2
    testchmod 555 td2
    file rename td1 td3
    file rename td2 td4
    list [lsort [glob td*]] [file writable td3] [file writable td4]

---- Test generated error; Return code was: 1
---- Return code should have been one of: 0 2
---- errorInfo: error renaming "td2" to "td4": permission denied
    while executing
"file rename td2 td4"
    ("uplevel" body line 5)
    invoked from within
"uplevel 1 $script"
---- errorCode: POSIX EACCES {permission denied}
==== fCmd-9.4.b FAILED

I tried NetBSD 6.0.1 and DragonFlyBSD 3.3 and it passed in both of those.

Now that I read my comment below, I'm not sure how I thought that
quote applied here. Maybe I missed the word _containing_? Sorry about
that. I wear glasses now.

smallm added on 2013-05-08 08:58:43:
I was hasty with the last paragraph of this new comment. Of course it was the second sentence of the quote, with the words "write access permission may be required for the directory named by old" that applies here. The younger me wasn't as blind as I thought.

smallm added on 2013-05-18 09:57:27:
One more thing, this is intentional behaviour on the part of OpenBSD, as recently clarified in their rename(2) man page: http://www.openbsd.org/cgi-bin/cvsweb/src/lib/libc/sys/rename.2.diff?r1=1.18;r2=1.19

http://marc.info/?l=openbsd-misc&m=136802986314774&w=2

serhiy.storchaka added on 2026-10-12 11:18:59:

POSIX allows rename() to require write permission for a directory being renamed, and OpenBSD and macOS 10.5 do. Proposed fix in branch fCmd-test-constraints: fCmd-9.4 is split into a test for a writable directory, which runs everywhere, and tests for a read-only directory which expect success or "permission denied" depending on the new constraint renameNeedsDirWrite (OpenBSD, macOS 10.5).

The branch also restores the definition of notWine, see [300724b80c].


jan.nijtmans added on 2026-11-11 10:59:38:

Fixed in [f9dfe7796a|trunk] and core-9-0-branch.

Had to add an additional notOSX constraint on fCmd-9.4.2, that's all.