Bug 36447 - chown(8) manual misdescribes handling of symlinks
Summary: chown(8) manual misdescribes handling of symlinks
Status: Closed FIXED
Alias: None
Product: Documentation
Classification: Unclassified
Component: Books & Articles (show other bugs)
Version: Latest
Hardware: Any Any
: Normal Affects Only Me
Assignee: Tom Rhodes
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2002-03-29 01:30 UTC by Gary W. Swearingen
Modified: 2004-12-15 13:41 UTC (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Gary W. Swearingen 2002-03-29 01:30:01 UTC
The chown(8) manual says:

    Chown sets the user ID and/or the group ID of the specified files.

and

-h  If the file is a symbolic link, change the user ID and/or the
    group ID of the link itself rather than the file that the link
    points to.

But without the -h option, symlinks given as arguments do not have
their IDs changed (as implied by the first quote) nor are the symlinks
followed (as implied by the second quote).
================

Fix: 

It should say:

    Chown changes the user ID and/or the group ID of the specified files.
    Symbolic links named by arguments are silently left unchanged unless
    "-h" is used.  See the symlink(7) manual for the handling of
    symlinks with a trailing slash.

and

-h  If the file is a symbolic link, change the user ID and/or the
    group ID of the link itself rather than silently leaving the link
    unchanged.

Maybe the "symlink(7)" sentence should be omitted.  No other manuals
currently discuss the trailing slash feature/bug including symlink(7).
I'll file a PR on the latter soon, so I say include the sentence.

On the other hand, maybe the "-h" description SHOULD mention that it
is ignored for symlinks with a trailing slash.  But maybe not, if we
assume that people are supposed to learn in the symlink(7) manual that
a name with a trailing slash is never naming a symlink, but what it
points to.  I'm saying "not", for now.
How-To-Repeat: 
su
cd /tmp
touch jjjr
ln -s jjjr jjjl
l jjj*
chown bin.bin jjjl
l jjj*
chown -h bin.bin jjjl
l jjj*
================
Comment 1 Giorgos Keramidas freebsd_committer freebsd_triage 2002-03-29 01:35:31 UTC
True.  But one who has read the descriptionn of -H, -L and -R above already
knows that chown(1) handles symlinks specially.  No need to repeat what has
already been written above, IMHO.

- Giorgos
Comment 2 Gary W. Swearingen 2002-03-29 06:31:55 UTC
Giorgos Keramidas <keramida@freebsd.org> writes:

> True.  But one who has read the descriptionn of -H, -L and -R above already
> knows that chown(1) handles symlinks specially.  No need to repeat what has
> already been written above, IMHO.

First, those only apply when using -R.  Second, it's not enough to know
that there is special handling; something needs to describe the handling
and it shouldn't, like the -h description, describe it wrongly.  I don't
see that I've repeated anything, except the mention of -h in the program
description because the current description is not true without -h.

Does not the -h description imply that "the file that the link points
to" will be changed in the absense of -h?  In fact, that file will not
be changed (unless that dangerous trailing slash feature/bug is used).
Comment 3 Tom Rhodes freebsd_committer freebsd_triage 2002-04-02 03:50:25 UTC
Gary, how does the following patch look?  I omitted the sentence under
the description where you asked symlink(7) be mentioned.  symlink(7)
is in the see also section, I changed the description to one that I
feel is satisfactory, I also think that -h is good now.  If anything,
perhaps we should cut everything, including ``rather'' after the
-h option.  But its your PR.

--
Tom (darklogik) Rhodes


--- chown.8.old	Mon Apr  1 21:41:30 2002
+++ chown.8	Mon Apr  1 21:52:17 2002
@@ -57,7 +57,10 @@
 .Ar
 .Sh DESCRIPTION
 .Nm Chown
-sets the user ID and/or the group ID of the specified files.
+changes the user ID and/or the group ID of the specified files.
+Symbolic links named by arguments are silently left unchanged unless
+.Op Fl h
+is used.
 .Pp
 The options are as follows:
 .Bl -tag -width Ds
@@ -82,8 +85,9 @@
 Don't report any failure to change file owner or group, nor modify
 the exit status to reflect such failures.
 .It Fl h
-If the file is a symbolic link, change the user ID and/or the group ID
-of the link itself rather than the file that the link points to.
+If the file is a symbolic link, change the user ID and/or the
+group ID of the link itself rather than silently leaving the link
+unchanged.
 .It Fl v
 Cause
 .Nm
Comment 4 Tom Rhodes freebsd_committer freebsd_triage 2002-04-03 18:50:58 UTC
Gary, I have looked over the various comments on -doc, and produced
this new patch.  How does it look?

--
Tom (darklogik) Rhodes

--- chown.8.old	Wed Apr  3 11:21:57 2002
+++ chown.8	Wed Apr  3 11:22:27 2002
@@ -57,7 +57,10 @@
 .Ar
 .Sh DESCRIPTION
 .Nm Chown
-sets the user ID and/or the group ID of the specified files.
+changes the user ID and/or the group ID of the specified files.
+Symbolic links named by arguments are silently left unchanged unless
+.Op Fl h
+is used.
 .Pp
 The options are as follows:
 .Bl -tag -width Ds
@@ -82,8 +85,8 @@
 Don't report any failure to change file owner or group, nor modify
 the exit status to reflect such failures.
 .It Fl h
-If the file is a symbolic link, change the user ID and/or the group ID
-of the link itself rather than the file that the link points to.
+If the file is a symbolic link, change the user ID and/or the
+group ID of the link itself.
 .It Fl v
 Cause
 .Nm
Comment 5 Tom Rhodes freebsd_committer freebsd_triage 2002-04-03 18:58:10 UTC
Responsible Changed
From-To: freebsd-doc->trhodes

I will close this one also as the current patch is mine
Comment 6 Tom Rhodes freebsd_committer freebsd_triage 2002-04-09 21:24:48 UTC
State Changed
From-To: open->patched

Patch applied to CURRENT, I'll commit to STABLE in 3 days, thanks 
Gary
Comment 7 Tom Rhodes freebsd_committer freebsd_triage 2002-04-12 16:16:18 UTC
State Changed
From-To: patched->closed

Just committed the change to STABLE, thanks Gary!
Comment 8 Gary W. Swearingen 2003-02-13 01:49:25 UTC
Please reopen this PR; the fix added "[-f]" instead of "-f".

Also, the previously-committed change for the PR said that symlinks were
not changed, by default, but (importantly) didn't say that symlinks 
are not followed by default, either.

The patch below fixes both problems (and also the problem of
capitalizing the command name).

--- /pr/work/chown..orig.8	Wed Feb 12 17:28:53 2003
+++ /pr/work/chown.8	Wed Feb 12 17:37:50 2003
@@ -56,11 +56,10 @@
 .No : Ns Ar group
 .Ar
 .Sh DESCRIPTION
-.Nm Chown
-changes the user ID and/or the group ID of the specified files.
-Symbolic links named by arguments are silently left unchanged unless
-.Op Fl h
-is used.
+The
+.Nm
+utility changes the user ID and/or the group ID of the specified files.
+By default, symbolic links are ignored.
 .Pp
 The options are as follows:
 .Bl -tag -width Ds
Comment 9 Tom Rhodes freebsd_committer freebsd_triage 2003-02-13 19:38:09 UTC
State Changed
From-To: closed->analyzed

Switch to analyzed at Gary's request.
Comment 10 Tom Rhodes freebsd_committer freebsd_triage 2004-12-15 03:10:33 UTC
State Changed
From-To: analyzed->patched

This was fixed in current, I'll close after I see if this 
has been fixed in the other branches.
Comment 11 Tom Rhodes freebsd_committer freebsd_triage 2004-12-15 13:40:38 UTC
State Changed
From-To: patched->closed

RELENG_4 and RELENG_5 have the same information as CURRENT.