Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > UNIX: getuid(), geteuid(): how to copy user's file to my personalspace

Reply
Thread Tools

UNIX: getuid(), geteuid(): how to copy user's file to my personalspace

 
 
Constantine
Guest
Posts: n/a
 
      12-28-2003
Hello,

What is the best way to copy a file? I need to copy a file that belongs
to the user who ran my programme to my own directory. suid is set on the
binary file that is to perform the job. Any details would be appreciated.

Thank you,
Constantine.
 
Reply With Quote
 
 
 
 
Jeff Schwab
Guest
Posts: n/a
 
      12-28-2003
Constantine wrote:

> What is the best way to copy a file? I need to copy a file that belongs
> to the user who ran my programme to my own directory. suid is set on the
> binary file that is to perform the job. Any details would be appreciated.


This is a newsgroup for discussion of the C++ programming language. Did
you have a question or comment about that? If not, please try posting
your question in a newsgroup dedicated to your OS.

The usual approach is just to call system( "/bin/cp source destination"
) from your program. If you prefer not to do this, you can use the
read() and write() system calls. Your system also may provide a special
function for copying files; try man unlink, and look under SEE ALSO. If
you're having trouble making the program write to your directory when
it's called by a user, make sure geteuid returns your uid. If not, your
filesystem may have been mounted "nosuid" (a common practice among
superstitious admin's). In that case, consider using a separate
directory for these files, with group write permission and the SETGID
bit high. Then, all files in the directory will be owned collectively
by the same group that owns the directory. You may have to get your
admin to create a special group.

Good luck,
Jeff

 
Reply With Quote
 
 
 
 
Jeff Schwab
Guest
Posts: n/a
 
      12-29-2003
Constantine wrote:
> On 2003-12-27 20:21, Jeff Schwab wrote:
>
>> Constantine wrote:
>>
>>> What is the best way to copy a file? I need to copy a file that
>>> belongs to the user who ran my programme to my own directory. suid is
>>> set on the binary file that is to perform the job. Any details would
>>> be appreciated.

>>
>>
>> The usual approach is just to call system( "/bin/cp source
>> destination" ) from your program. If you prefer not to do this, you
>> can use the read() and write() system calls. Your system also may
>> provide a special function for copying files; try man unlink, and look
>> under SEE ALSO. If

>
>
> Will cp utility have access to both users' directories, if run from the
> programme with suid? If so, how could I get the summary of what files
> were copied? Each time, there will be around 2 to 5 files to be copied,
> and I need to know which ones were copied successfully.


That depends on your system. Try posting in an appropriate newsgroup.

-Jeff

>
> Thank you,
> Constantine.


 
Reply With Quote
 
Constantine
Guest
Posts: n/a
 
      12-29-2003
On 2003-12-27 20:21, Jeff Schwab wrote:

> Constantine wrote:
>
>> What is the best way to copy a file? I need to copy a file that
>> belongs to the user who ran my programme to my own directory. suid is
>> set on the binary file that is to perform the job. Any details would
>> be appreciated.

>
> The usual approach is just to call system( "/bin/cp source destination"
> ) from your program. If you prefer not to do this, you can use the
> read() and write() system calls. Your system also may provide a special
> function for copying files; try man unlink, and look under SEE ALSO. If


Will cp utility have access to both users' directories, if run from the
programme with suid? If so, how could I get the summary of what files
were copied? Each time, there will be around 2 to 5 files to be copied,
and I need to know which ones were copied successfully.

Thank you,
Constantine.
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: How include a large array? Edward A. Falk C Programming 1 04-04-2013 08:07 PM
File::Copy::copy With File Handles MaggotChild Perl Misc 2 10-22-2011 12:15 AM
what is Deep Copy, shallow copy and bitwises copy.? saxenavaibhav17@gmail.com C++ 26 09-01-2006 09:37 PM
is dict.copy() a deep copy or a shallow copy Alex Python 2 09-05-2005 07:01 AM
using File.Copy to copy files to shared hosting site Steve Richter ASP .Net 4 04-18-2005 03:06 PM



Advertisments