Operating System - HP-UX
1823063 Members
3144 Online
109645 Solutions
New Discussion юеВ

rcp file that has suid permissions set (again)

 
SOLVED
Go to solution
Dave Cassel
Occasional Contributor

rcp file that has suid permissions set (again)

I'm sumbitting a better description of my problem. I'm still unable to rcp my file that has rwsr-xr-x permissions. I am logged in as a test user running a shell script that has the rwsr-xr-x permissions set. This script runs the rcp command. The script or specifically the rcp command is run as the test user instead of root like I intend it to. I get "permission denied" when trying to rcp the file that has rwsr-xr-x persmissions set. I tried it with the -p option and it doesn't make any difference.
5 REPLIES 5
A. Clay Stephenson
Acclaimed Contributor
Solution

Re: rcp file that has suid permissions set (again)

I just tried this command as a regular user and it worked just fine and the setuid bit was preserved. My best guess is that there is an existing file on the remote host and that is your "permission denied". Note also that rcp -p will not preserve owner/group that is determined by the user issueing the rcp command.
If it ain't broke, I can fix that.
Dave Cassel
Occasional Contributor

Re: rcp file that has suid permissions set (again)

Yes, Stephen, I do have a file with the same name on the remote system with the same permissions set. I need to rcp this file back and forth when it has been changed on remote system or host. The file has rwsr-xr-x on both systems.
A. Clay Stephenson
Acclaimed Contributor

Re: rcp file that has suid permissions set (again)

Okay, assuming that the sticky bit is not set on the directory on the remotehost then
you need to:
remsh remotehost rm -f /dirname/filename
then do the rcp -p

You can copy an existing file (if you own it) but not if owned by someone else. I also assume that your uid/gid's match across the boxes.
If it ain't broke, I can fix that.
Geoff Wild
Honored Contributor

Re: rcp file that has suid permissions set (again)

Are you trying to keep a file in sync with another server?

Take a look at rdist:

rdist(1) rdist(1)

NAME
rdist - remote file distribution program

SYNOPSIS
rdist [ -bhinqvwyMR ] [ -f distfile ] [ -d var=value ] [ -m host ]
[ label... ]

rdist [ -bhinqvwyMR ] -c name... [ login@]host[:dest ]

DESCRIPTION
rdist facilitates the maintaining of identical copies of files over
multiple hosts. It preserves the owner, group, mode, and modification
time of files if possible and can update programs that are executing.


I do that for DR reasons with the home directory of one of my SAP Admins...

From cron:

# Copy vgpadm across to the DR site.
05 01 * * * /app/admin/drp/update-binaries.sh

# cat update-binaries.sh
#! /bin/sh

# Keep the DRP copy of the vgpadm up-to-date.
# Currently the files are in:
#
# /home/vgpadm
#
# See the rdist(1M) distfile for a list of exclusions.

DRPDIR=/app/admin/drp
DRPHOST=svrdrp

mount | grep /home > /dev/null 2>&1
if [ $? -eq 0 ]
then
( su - vgpadm -c "rdist -f $DRPDIR/distfile vgpadm"; ) 2>&1 |\
tee $DRPDIR/drp.log 2>&1 |\
mailx -s "VGPADM DRP rdist output" gwild@mydomain.com
fi


# cat distfile
VGPDR = ( svrdrp )

#
# File systems to be copied over to the DR host.
# Don't use -R in install - so as not to remove files on destination host
VGPADM = /home/vgpadm

vgpadm: ( ${VGPADM} ) -> ( ${VGPDR} )
install -w ;
except ${VGPADM}/logfiles;




Rgds...Geoff
Proverbs 3:5,6 Trust in the Lord with all your heart and lean not on your own understanding; in all your ways acknowledge him, and he will make all your paths straight.
Dave Cassel
Occasional Contributor

Re: rcp file that has suid permissions set (again)

I simply removed the file first and it worked! Thanks A. Clay Stephenson, you're the greatest!