1753331 Members
5479 Online
108792 Solutions
New Discussion юеВ

Default umask with "rcp"

 
Miguel Angel Aliaga_1
Occasional Advisor

Default umask with "rcp"

Hello.
Where can I change the default value for the umask ?

I`m doing a rcp and the new file get the 640 permision. My /etc/profile and my .profile have umask 002.

Why ?

Regards.
10 REPLIES 10
Rodney Hills
Honored Contributor

Re: Default umask with "rcp"

The "-p" option will preserve owner/permissions onto the destination host.

HTH

-- Rod Hills
There be dragons...
Steven E. Protter
Exalted Contributor

Re: Default umask with "rcp"

You can preserve permissions with this command option

rcp -p source target

File permissions on the target are not controlled by the umask in the target system's user .profile because the .profile file is NOT sourced when you rcp.

/etc/profile is also not sourced when you use these protocols.

You need to control permissions with your script. If -p doesn't help then you might need a line right after rcp to jump back on and change permissions.

SEP
Steven E Protter
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
Pete Randall
Outstanding Contributor

Re: Default umask with "rcp"

In which direction are you copying? If you're trying to set the permissions on the remote server, the you can try rcp -p. If you're trying to set the permissions on your local server then your umask should accomplish what you seek.


Pete



Pete
Umapathy S
Honored Contributor

Re: Default umask with "rcp"

hi,
As said, rcp -p will preserve the permissions of the file in the target system. Check the man pages for more info.

HTH,
Umapathy
Arise Awake and Stop NOT till the goal is Reached!
Miguel Angel Aliaga_1
Occasional Advisor

Re: Default umask with "rcp"

Yes, with -p option I preserve the permission but, all my scritps use the rcp without -p and they worked fine until yesterday, today not.

What`s worng ?

p.e.

userX@hostA> remsh hostB -l userY "/usr/bin/umask"
02
userX@hostA> remsh hostC -l userY /usr/bin/umask
077

Why ?

/etc/profile and /home/userY/.profile are the same on hostB and hostC

Uday_S_Ankolekar
Honored Contributor

Re: Default umask with "rcp"

sbin/rc file has the default value for umask. but /etc/profile and .profile will be user specific.

if rcp -p doesnot help you then What permission you need on the files copied?
-USA..
Good Luck..
Miguel Angel Aliaga_1
Occasional Advisor

Re: Default umask with "rcp"

I can`t change all my scripts ( > 100 ) adding -p option.

The /sbin/rc file are the same on both hosts, why on hostB get a value and another value on hostC ?
Umapathy S
Honored Contributor

Re: Default umask with "rcp"

Hi,
man rcp

If the -p option is not specified, rcp preserves
the mode and owner of dest_file if it already
exists; otherwise rcp uses the mode of the source
file modified by the umask on the destination
host. Modification and access times of the
destination file are set to the time when the copy was made.


Check hostC throughly for change in umask. Its changing somewhere.

Do you have any other machine that comes into the picture and what is the behaviour for this script.

HTH,
Umapathy
Arise Awake and Stop NOT till the goal is Reached!
A. Clay Stephenson
Acclaimed Contributor

Re: Default umask with "rcp"

You could check the umask setting in /etc/profile but really rcp/remshd is doing exactly what it's supposed to be doing. It's really a lack of discipline on the programmer's part to expect the attributes to be preserved. The ONLY sure fix is to use the -p option but note that even -p does not preserve ownership/group because that is a function of the effective uid/gid of the rcp user.
If it ain't broke, I can fix that.