Community Forums
Connect with us on LinkedIn
+ Reply to Thread
Results 1 to 5 of 5
  1. #1
    Member
    Join Date
    Mar 2006
    Posts
    15

    Red face Umask and rsync - help please!

    I have a dilemma... to automate deployment of a web site from our development server (Windows) to our live server (centros linux) I'm using cwrsync on the Windows side to send it over. The problem is that the permissions are all wrong. My only hope is to get rsync to recognize a umask on my server and adhere to that... but it's not happening! Can anybody tell me where I'm going wrong?

    What I need is for the directories to be chmodded to 755 and individual files to be 644 when they're created on the linux side.

    Here's what I have setup... first, here's my rsync command from Windows (censored the username and ip address):
    Code:
    "c:\program files (x86)\cwrsync\bin\rsync" -rtvz --rsh='"/cygdrive/c/program files (x86)/cwrsync/bin/ssh" -p20880' ./Mysite.com/ mysite@xx.xxx.xxx.xx:~mysite/
    I've tried adding
    Code:
    --chmod u=rwx,g=r,o=r
    to that but it can't write in the directories it creates... can create directories though. -p option hasn't helped one bit either.

    On the linux server, previously I didn't have umask set in either my /etc/bashrc or /etc/profile. It wasn't in the user's .bashrc or .bash_profile files either. So I added this to /etc/bashrc:

    Code:
    if [ $UID -gt 99 ] && [ "`id -gn`" = "`id -un`" ]; then
            umask 002
    else
            umask 022
    fi
    and restarted ssh just in case, but no luck. Tried adding this additionally to /etc/profile:

    Code:
    umask 002 # Proper functioning of rsync from windows
    ...restarted ssh (via /sbin/service sshd restart) and no luck.

    I'm really stuck here and honestly I feel like I'm missing some fundamental reason this isn't working, like I'm not restarting something correctly. Does anybody know what I'm talking about and what the problem may be? I'm happy to provide additional info if needed.

    Thank you very much in advance,
    - Mike
    Last edited by karikas; 01-04-2010 at 05:33 AM. Reason: added help please! to title - body unchanged

  2. #2
    Member
    Join Date
    Jan 2005
    Location
    Earth
    Posts
    1,050

    Default

    By default directories and files are created with 755 abd 644 permissions on a Linux server. What are the permissions of those on a Windows server and with what permissions are they created on Linux server when you rsync them?

    You haven't included the p and o option which are for permissions and ownership respectively. Use the options -vrplogDtH while syncing the files and see if it works for you.

  3. #3
    Member
    Join Date
    Mar 2006
    Posts
    15

    Default

    I've used the options you suggested but am still not getting the right results... here's what I get now when transferring a directory and file with your suggestion:

    Code:
    dr-xr-xrwx  2 mysite mysite 4096 Jan  4 18:01 .
    -r-xr-xrwx  1 mysite mysite   14 Jan  4 17:58 test_file.html
    We aren't doing anything special with the files on the Windows side... they are the 'stock' permissions you get when a regular user creates files (windows permissions make my head spin anyway).

    Here's some more information if it can help any kind souls see what the problem is...

    Here are what I want as permissions when I rsync files to Linux (755 for dirs and 644 for files):

    Code:
    drwxr-xr-x  2 mysite mysite 4096 Jan  4 18:06 .
    -rw-r--r--  1 mysite mysite    5 Jan  4 18:06 test.file
    On the linux side, when logged in as the user, when I create a directory and file manually I get these permissions instead:

    Code:
    drwxrwxr-x  2 mysite mysite 4096 Jan  4 17:58 .
    -rw-rw-r--  1 mysite mysite   10 Jan  4 17:58 test.txt
    That's just for reference - as far as I know that's not behaving as the default should be for a linux environ.

    When I rsync files over, without setting any permissions options, I get these permissions (same rsync command as op):

    Code:
    drwxr-xr-x  2 mysite mysite 4096 Jan  4 18:01 .
    -r-xr-xr-x  1 mysite mysite   14 Jan  4 17:58 test_file.html
    Setting --chmod in my rsync command sets both my directories and files to the same permissions, which is definitely not what I want.

    I know this can be solved by changing the umask or something along those lines... apparently I'm not doing it correctly or something, I spent a couple hours last night googling and working on it but with no helpful results. See my op. Does anybody know what I'm missing?

    Many thanks - Mike

  4. #4
    Member
    Join Date
    Mar 2006
    Posts
    15

    Default Solved!

    Thought I'd post my solution. Turns out it had nothing to do with my linux servers... I tried rsyncing to my other server, which had always worked before, and encountered the same problem.

    The issue turned out to be my copy of cwRsync on my Windows machine, which had recently been upgrade to Window 7 Ultimate from Vista Home Premium. The permissions became all wonky when cwRsync tried to send them over. Lots of Googling and testing later, the solution was to set this environment variable on my Windows machine:

    Code:
    set CYGWIN=nontsec
    ...and that turns off CYGWin's attempts to match up Windows permissions with the target linux machine's permissions. That was the problem... setting that environment variable fixed everything!

  5. #5
    Member
    Join Date
    Jan 2005
    Location
    Earth
    Posts
    1,050

    Default

    Wow, you really must have done quite a searching and testing... thx for sharing the solution... Mike.

Similar Threads & Tags
Similar threads

  1. Replies: 2
    Last Post: 04-28-2011, 07:36 AM
  2. suphp and umask
    By verdon in forum cPanel and WHM Discussions
    Replies: 3
    Last Post: 09-24-2008, 09:13 AM
  3. rsync://rsync.cpanel.net broken?
    By Sinewy in forum cPanel and WHM Discussions
    Replies: 7
    Last Post: 10-26-2004, 06:08 AM
  4. Replies: 0
    Last Post: 01-25-2004, 04:02 PM
  5. rsync gurus -- how to stop rsync daemon?
    By trakwebster in forum cPanel and WHM Discussions
    Replies: 2
    Last Post: 08-12-2003, 11:05 AM
Tags for this Thread
Linkedin       Facebook       Twitter       RSS       Flickr       YouTube