Is it possible to make rsync set completely new/different permissions to
a file or directory once it's copied to the destination location?
The only thing I can think of doing at the moment is a nasty:
find -type f -exec chmod 644 {} \;
find -type d -exec chmod 755 {} \;
to the destination directory.
BTW, the source and destination directories are mounted on the same machine.
Any suggestions very gratefully received.
Andy
--
Andrew Greensted Department of Electronics
Bio-Inspired Engineering University of York, UK
Tel: +44(0)1904 432379 Mailto: ajg...@ohm.york.ac.uk
Fax: +44(0)1904 433224 Web: www.bioinspired.com
]Hi All,
]Is it possible to make rsync set completely new/different permissions to
]a file or directory once it's copied to the destination location?
]The only thing I can think of doing at the moment is a nasty:
]find -type f -exec chmod 644 {} \;
]find -type d -exec chmod 755 {} \;
And that is nasty why?
By the way you had better put the starting directory in just after find or
it will not work.
Unix is built on the philosophy of "make small tools and link them together
to do big jobs".
]to the destination directory.
In alt.os.linux Bill Unruh <un...@string.physics.ubc.ca> suggested:
> Andrew Greensted <ajg...@ohm.york.ac.uk> writes:
[..]
> ]Is it possible to make rsync set completely new/different permissions to
> ]a file or directory once it's copied to the destination location?
> ]The only thing I can think of doing at the moment is a nasty:
> ]find -type f -exec chmod 644 {} \;
> ]find -type d -exec chmod 755 {} \;
> And that is nasty why?
;)
> By the way you had better put the starting directory in just after find or
> it will not work.
GNU find does assume "." if no dir is given, I'd be careful with
that, doesn't look very portable.
> Unix is built on the philosophy of "make small tools and link them together
> to do big jobs".
Yep.
;)
--
Michael Heiming (GPG-Key ID: 0xEDD27B94)
mail: echo zvp...@urvzvat.qr | perl -pe 'y/a-z/n-za-m/'
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.1 (GNU/Linux)
iD8DBQFA8saPAkPEju3Se5QRAjDNAKC915orjk3BIxL9LGz5XIrWSkrBWwCfUC5M
ped0tobNE5Vyt2ope0Uo7Vk=
=Zouz
-----END PGP SIGNATURE-----
: Is it possible to make rsync set completely new/different permissions to
: a file or directory once it's copied to the destination location?
: The only thing I can think of doing at the moment is a nasty:
: find -type f -exec chmod 644 {} \;
: find -type d -exec chmod 755 {} \;
: to the destination directory.
: BTW, the source and destination directories are mounted on the same machine.
: Any suggestions very gratefully received.
: Andy
You could try something along the lines of:
chmod -R og+r,og-w <dirname>
Notes:
* your find syntax is wrong above - you left out the directory
* You wouldn't want to chmod 644 as that would strip any executables of
the execute permissions. Also, you could things sometimes not to your
liking - you might have a file deliberately set read-only for owner, for
example. Same for the directory chmod. If all you want to do is adjust
group and other permissions to read but not write, use the different
chmod syntax as above. 'man chmod' for details.
* Unless you are doing this as root, you'll have to own everything to
change permissions ....
* If you must use find, I prefer (for example)
find <directory> | xargs chmod og+r,og-w
as it invokes 'chmod' a lot fewer times.
Don Pettengill
Bill, my reason for the 'nasty' comment is that it seems a shame to have
to grind through a whole bunch of files to set permissions if there is a
rsync option that would set them when the file is being created.
Michael, I agree that the find syntax isn't too elegant, but is was
really to demonstrate a point. Do I need to run something 'like' that,
or can rsync deal with the permissions for me.
Don, in my case is doesn't matter if I strip off any executable
permissions because the files are being created and read via samba. For
the same reason, setting all files to 644 and all directories to 755 is
fine because all files have the same owner.
Seeing as everyone focused on the 'find' part of my question I'll assume
that rsync isn't able to do what I want.
Just as a matter of interest, Don, I'm intrigued why using:
find <directory> | xargs chmod og+r,og-w
would result in chmod being invoked less.
Thanks again for your help.
Andy
In alt.os.linux Andrew Greensted <ajg...@ohm.york.ac.uk> suggested:
> Andrew Greensted wrote:
( top posting fixed )
>> Is it possible to make rsync set completely new/different permissions to
>> a file or directory once it's copied to the destination location?
[..]
> Bill, my reason for the 'nasty' comment is that it seems a shame to have
> to grind through a whole bunch of files to set permissions if there is a
[..]
No it isn't, as Bill already mentioned this is the unix
philosophy of doing things, proved in >30 years of running unix.
You can make a small script/alias/function to meet your needs.
> Michael, I agree that the find syntax isn't too elegant, but is was
> really to demonstrate a point. Do I need to run something 'like' that,
Yep.
[..]
> Seeing as everyone focused on the 'find' part of my question I'll assume
> that rsync isn't able to do what I want.
Why assume? Just look at the rsync man page. Mine has no option
like this, you could look at 'unison' which has a few more
features then rsync, don't know about that one and I can't be
bothered to look at the man page.;)
> Just as a matter of interest, Don, I'm intrigued why using:
> find <directory> | xargs chmod og+r,og-w
> would result in chmod being invoked less.
Probably as the output of find is given as one line to xargs,
while it is likely that -exec would run the command for each item
found. This might not make a big difference on a fast/idle
system, but on a slow/busy one. You can always put 'time' in
front of your commands to check, just be sure to take OS/FS
caching/buffering into account.
Good luck
--
Michael Heiming - RHCE (GPG-Key ID: 0xEDD27B94)
mail: echo zvp...@urvzvat.qr | perl -pe 'y/a-z/n-za-m/'
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.1 (GNU/Linux)
iD8DBQFA86ZaAkPEju3Se5QRAkjLAJ9uVh9V0iB3kDdcBcXxVGSKAVcxbwCgguIr
yshLiVY8v1PFG1Lx6J3ETA4=
=U2bY
-----END PGP SIGNATURE-----
: Bill, my reason for the 'nasty' comment is that it seems a shame to have
: to grind through a whole bunch of files to set permissions if there is a
: rsync option that would set them when the file is being created.
You can do this if you use find and cpio. (You can also do it with
find | tar | tar - adding a few options here and there :-)).
: Just as a matter of interest, Don, I'm intrigued why using:
: find <directory> | xargs chmod og+r,og-w
: would result in chmod being invoked less.
It's invoked once per found item (I believe) if run from 'find'. If run
from 'xargs', then only once per full line of arguments (could be
hundreds of those). 'man xargs' for details.
Perhaps you would be better off using
find <dir> -mtime <blah blah> | cpio <options>
(or find -newer <ref file>)
rather than rsync. In this case the files can come over with the
permissions of the process owner. rsync *is* convenient but it's not
always what one wants.
don
--
--
Looking for a date/hookup/sex partner?
http://accfq2.linksysnet.com:999/match/index2.htm
^^ Free dating services & Swingers Pages! ^^
-=-=-=-=-=-=-=-
Need a Loan or a Credit Card? Our loan pages are the best
http://accfq2.linksysnet.com:999/loan/index.htm
100% Guaranteed Credit Cards and Loans, EVEN IF YOU HAVE BAD CREDIT!
Also, Signature Cash advances, and debt consolidation! Check us out today.
Looking for adult Videos? DVDs? VHS? Toys? Look no further.
http://shop.sex-superstore.com/cgi-share/index.cgi?af=5971
Guaranteed BEST price anywhere.. $9.99 XXX DVD Section! Free dildo with
any order over $50! Check us out today!
"Andrew Greensted" <ajg...@ohm.york.ac.uk> wrote in message
news:ccuc5e$ap3$1...@pump1.york.ac.uk...
]Thanks all for your feedback.
]Bill, my reason for the 'nasty' comment is that it seems a shame to have
]to grind through a whole bunch of files to set permissions if there is a
]rsync option that would set them when the file is being created.
]Michael, I agree that the find syntax isn't too elegant, but is was
]really to demonstrate a point. Do I need to run something 'like' that,
]or can rsync deal with the permissions for me.
]Don, in my case is doesn't matter if I strip off any executable
]permissions because the files are being created and read via samba. For
]the same reason, setting all files to 644 and all directories to 755 is
]fine because all files have the same owner.
]Seeing as everyone focused on the 'find' part of my question I'll assume
]that rsync isn't able to do what I want.
]Just as a matter of interest, Don, I'm intrigued why using:
] find <directory> | xargs chmod og+r,og-w
]would result in chmod being invoked less.
If chmod is invoked with a whole list of arguments, it applies the
permissions to every one of those argumentsi with that one invocation.
Under the find -exec, every
time it finds a file which meets the previous criteria, chmod is invoked to
change the permissions of that particular file. This means it is invoked
up to about 1000 times as often, since xargs, bundles the arguments into
as
large a set of groups as it can. ( up to 20K characters according to man
xargs)
And as far as I know rsync is not able to do what you want.
The only arguments relevant seem to be
-p, --perms
This option causes rsync to set the destination permissions to
be the same as the source permissions. Without this option,
each new file gets its permissions
set based on the source file's permissions and the umask at
the receiving end, while all other files (including updated files)
retain their existing permissions (which is the same behavior as
other file-copy utilities, such as cp).
-o, --owner
This option causes rsync to set the owner of the destination
file to be the same as the source file. On most systems, only
the super-user can set file ownership. Note that if the remote
system is a daemon using chroot, the --numeric-ids option is
implied because the remote system cannot get access to the user-
names from /etc/passwd.
]Thanks again for your help.