bug-coreutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: chmod 0755 behaves like chmod 755


From: Paul Eggert
Subject: Re: chmod 0755 behaves like chmod 755
Date: Thu, 04 Oct 2007 15:07:28 -0700
User-agent: Gnus/5.11 (Gnus v5.11) Emacs/22.1 (gnu/linux)

Evan Hunt <address@hidden> writes:

> the principle of least surprise calls for chmod to behave the
> same way with both files and directories.

That's true, but there are other principles involved, namely
convenience and compatibility.  There's some old history involved, so
bear with me.

Many old scripts (and new scripts written by traditionalist
programmers) use commands like "chmod 755" that worked just fine in
Unix Version 7 (where newly created files get the group of the owner),
as well as in 4.2BSD (where they get the group of the parent
directory), because in those operating systems the setgid bits of
directories didn't matter.

However, the naive implementation of "chmod 755" had undesirable
effects in SunOS 4.x (late 1980s), an operating system that used the
setgid bit to switch between V7 and 4.2BSD semantics.  That is because
"chmod 755" cleared the setgid bit on directories, which messes up
permissions of files that are later created in that directory, and
makes files harder to share.  So in SunOS 4.x Sun changed "chmod 755
dir" to leave the setgid bit alone.

The GNU project prefers to make sharing convenient, so we followed
Sun's lead.  Secondarily, it is more convenient for GNU to be
compatible with SunOS than to be incompatible with it, as SunOS is the
most-popular Unix implementation.




reply via email to

[Prev in Thread] Current Thread [Next in Thread]