Solved

How to copy an only executalbe file

Posted on 1997-12-14
4
235 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
ID: 2008301
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
ID: 2008302
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
ID: 2008303
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
ID: 2008304
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

Best Practices: Disaster Recovery Testing

Besides backup, any IT division should have a disaster recovery plan. You will find a few tips below relating to the development of such a plan and to what issues one should pay special attention in the course of backup planning.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
pauing printer deamon in AIX 10 59
Problem Imaging Computers With Clonezilla 2 90
Solaris 4.1.3 cloning and booting 13 78
add some character at the end of line in vi 7 79
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…
Installing FreeBSD… FreeBSD is a darling of an operating system. The stability and usability make it a clear choice for servers and desktops (for the cunning). Savvy?  The Ports collection makes available every popular FOSS application and packag…
Learn how to get help with Linux/Unix bash shell commands. Use help to read help documents for built in bash shell commands.: Use man to interface with the online reference manuals for shell commands.: Use man to search man pages for unknown command…
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.

777 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