Solved

How to copy an only executalbe file

Posted on 1997-12-14
4
215 Views
Last Modified: 2010-04-21
Hi there,

I'd like to copy a file which is protected for writing as well as for reading. The only thing I can do is to execute it. Is it possible to copy a file like this to anywhere else? And if YES: How can I do it?

Thanks for your help
scotty

0
Comment
Question by:gageli
  • 2
4 Comments
 
LVL 3

Expert Comment

by:rickyr
Comment Utility
Hiya...

As a normal user you can't copy something if you aint got read permission, Unless of course you are root. If a file you want to copy is owned by you then read on.

add read permission to the file...
$ chmod u+r filetocopy
copy the file...
$ cp filetocopy copiedfile
take away read permission from the copied file...
$ chmod u-r copiedfile
take read permission away from the filetocopy...
$ chmod u-r filetocopy

or to automate this you could write a script...

launch vi...

$ vi

type the following....

#!/bin/sh
if [ $# -ne 2 ] ; then
echo usage mycp [ fromfile tofile ]
exit
fi
chmod u+r $1
cp $1 $2
chmod u-r $2
chmod u-r $1

type...

:w mycp

type...

Hold shift and type ZZ

then make your file executable...

$chmod u+x mycp

now type....

$ mycp filetocopy newfilename

What I have suggested is just a work around, This is why I have only supplied a comment and not an answer. the real answer to your question is "it cant be done unles your root"
I hope I helped
0
 
LVL 5

Expert Comment

by:n0thing
Comment Utility
I agree with rickyr. You cannot copy an excutable only file.
You'll have be root or hacked root.

0
 
LVL 10

Accepted Solution

by:
rbr earned 50 total points
Comment Utility
For copying the file you have to get read access. If the file isn't yours only the owner of the file or root can change the access. chmod a+r filename
0
 
LVL 3

Expert Comment

by:rickyr
Comment Utility
Hi
You do not need to get the owner of the file to do this for you.
You can do this yourself if you know the password of the owner of
the file. then....

$> su file_owner
$> password: file_owner_passwd

This is of course a security risk (knowledge of others passwords), but the su utility is for switching users, whether you are super-user or a normal user.

$> su - file_owner

to get the new users environment, no hyphen to retain your environment.

The script I have mentioned above could be owned by the file_to_copy owner and given SUID access...
$> chmod u+s mycp
Then whoever runs it, it will be run as the owner of the file
file_to_copy. Beware of the security risks aswell. chmod a+r
will give read access to the world.

Okay gageli....
Whos been the most help here?
Maybe I should have supplied the above as an answer, but I believe "It cant be done, but heres a sloppy work around" is just not good enough for an answer, Go and get your points back.
regards
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

This tech tip describes how to install the Solaris Operating System from a tape backup that was created using the Solaris flash archive utility. I have used this procedure on the Solaris 8 and 9 OS, and it shoudl also work well on the Solaris 10 rel…
Introduction Regular patching is part of a system administrator's tasks. However, many patches require that the system be in single-user mode before they can be installed. A cluster patch in particular can take quite a while to apply if the machine…
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.
In a previous video, we went over how to export a DynamoDB table into Amazon S3.  In this video, we show how to load the export from S3 into a DynamoDB table.

728 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now