Bug 11027 - Sticky bit not set when using --chmod=D+t alone, without --perms
Summary: Sticky bit not set when using --chmod=D+t alone, without --perms
Status: NEW
Alias: None
Product: rsync
Classification: Unclassified
Component: core (show other bugs)
Version: 3.0.9
Hardware: All All
: P5 normal (vote)
Target Milestone: ---
Assignee: Wayne Davison
QA Contact: Rsync QA Contact
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-12-31 04:22 UTC by Michal Galdzicki
Modified: 2014-12-31 04:22 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 Michal Galdzicki 2014-12-31 04:22:32 UTC
Another way to phrase, sticky bit on directories gets ignored when not using --perms, -p.
Suggestion: At the very least a strong mention in the docs/ man page under the --chmod entry.

First, I point out one situation where I had it work, then I go on to describe the failing case. Finally, I show a combination which makes it work. (rsync Kung fu)

*Sticky bit ON, on source dir
drwxr-sr-t. 2 redleader rebels 32 Dec 30 18:32 new_data

Use --perms, include trailing slash on source dir
rsync -r -p  new_data/ destination
Result: works, sticky bit ON, on destination dir
drwxr-sr-t. 3 redleader rebels 47 Dec 30 19:15 destination


*Sticky bit OFF, on source dir
drwxr-sr-x. 2 redleader rebels 32 Dec 30 18:32 new_data

Attempt to chmod Sticky bit set on directories
rsync -r --chmod=D+t  new_data/ destination
Result: fail, Sticky bit OFF on dest dir
drwxr-sr-x. 2 redleader rebels 32 Dec 30 19:36 destination

*Want to force the setting of the Sticky Bit on all dirs

Starting with a mix of permissions
$ ls -l new_data .
.:
drwxr-sr-x. 4 redleader rebels 39 Dec 30 19:38 new_data
new_data:
drwxrwsr-x. 2 redleader rebels 6 Dec 30 19:38 sticky_off
drwxrwsr-t. 2 redleader rebels 6 Dec 30 19:38 sticky_on

$ rsync -rp --chmod=D+t  new_data/ destination
Note: use -p [or --perms] and include the trailing slash on source_dir/

Result: All dirs have the sticky bit set
$ ls -l destination .
.:
total 0
drwxr-sr-t. 4 redleader rebels 39 Dec 30 19:42 destination
drwxr-sr-t. 4 redleader rebels 39 Dec 30 19:38 new_data
destination:
total 0
drwxrwsr-t. 2 redleader rebels 6 Dec 30 19:42 sticky_off
drwxrwsr-t. 2 redleader rebels 6 Dec 30 19:42 sticky_on


*Related point for anyone that is confused by the behavior of --chmod:

Condition A: Sticky bit ON, on source dir
drwxr-sr-t. 2 redleader rebels 32 Dec 30 18:32 new_data

Use --perms, do not include slash on source dir
rsync -r --perms  new_data destination

Result: ?, sticky bit OFF, on destination dir, but sticky ON new_data (now a subdir)
drwxr-sr-x. 2 redleader rebels 32 Dec 30 19:25 destination
destination/:
drwxr-sr-t. 4 redleader rebels 39 Dec 30 19:52 new_data
[Note: I found this behavior unintuitive, as chmod is being done on destination dir; I expected destination to have the permissions set as I specify in the rsync command, same behavior with other --chmod directives rsync -rp --chmod=Dg-w new_data destination. This follows expectations based on using the chmod command itself in a shell]