LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Security (https://www.linuxquestions.org/questions/linux-security-4/)
-   -   Rsync changing owner of dirs (https://www.linuxquestions.org/questions/linux-security-4/rsync-changing-owner-of-dirs-541888/)

Harlin 03-30-2007 08:08 AM

Rsync changing owner of dirs
 
Not sure if this is an rsync issue or a weird Redhat security issue. I have 2 groups. GroupA and GroupB. I have a file structure like this... /GroupADir and /GroupADir/GroupBDir... /GroupADir is owned by groupa:groupa. The /GroupADir/GroupBDir is owned by groupb:groupb. GroupA is a member of GroupB. When I run rsync I am using the groupa account as my ssh account when i do this. When running rsync, GroupA gets all of the files with no problems from both directories. However, after finishing rsync, the /GroupADir/GroupBDir is now mysteriously and recursively owned by groupa:groupa instead of the original groupb:groupb. Is there any way to keep this from happening after rsync is run?

Rsync looks like this...
cmd = 'rsync --verbose --progress --stats --compress --rsh=/usr/bin/ssh --recursive --times --perms --links --delete $hostName:'+sys.argv[1]+' '+sys.argv[2]

Thanks,

Harlin Seritt

MensaWater 03-30-2007 01:11 PM

rsync does have flags that deal with ownership and permissions.

However the most obvious possibility would be that you have different UIDs for groupa/groupb on the two boxes. The files are actually stored with the UID (User Identity = Numeric) as opposed to the User name (Alpha). When you use commands such as ls to list files it does a lookup in /etc/passwd to convert the UID to the name.

So if on hosta you had groupa with UID 500 but on hostb you groupa with UID 501 and groupb with UID 500 then the files that ls would find as NAME groupa on hosta would be NAME groupb on hostb but would be UID 500 on both.

You can determine UID by doing a grep for the user name from /etc/passwd:
e.g.:
grep jlightne /etc/passwd
jlightne:x:515:500:Jeff Lightner:/home/jlightne:/bin/ksh

The 3rd field is the UID which is 515 for the example. (The fourth field is the GID [Group ID]).


All times are GMT -5. The time now is 01:40 PM.