C++Talk.NET Forum Index C++Talk.NET
C++ language newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

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

 
Post new topic   Reply to topic    C++Talk.NET Forum Index -> C++ language (comp.lang.c++)
View previous topic :: View next topic  
Author Message
Constantine
Guest





PostPosted: Sun Dec 28, 2003 12:44 am    Post subject: UNIX: getuid(), geteuid(): how to copy user's file to my per Reply with quote



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.
Back to top
Jeff Schwab
Guest





PostPosted: Sun Dec 28, 2003 1:21 am    Post subject: Re: UNIX: getuid(), geteuid(): how to copy user's file to my Reply with quote



Constantine wrote:

Quote:
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


Back to top
Jeff Schwab
Guest





PostPosted: Mon Dec 29, 2003 8:46 pm    Post subject: Re: UNIX: getuid(), geteuid(): how to copy user's file to my Reply with quote



Constantine wrote:
Quote:
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

Quote:

Thank you,
Constantine.


Back to top
Constantine
Guest





PostPosted: Mon Dec 29, 2003 8:48 pm    Post subject: Re: UNIX: getuid(), geteuid(): how to copy user's file to my Reply with quote

On 2003-12-27 20:21, Jeff Schwab wrote:

Quote:
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.

Back to top
Display posts from previous:   
Post new topic   Reply to topic    C++Talk.NET Forum Index -> C++ language (comp.lang.c++) All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.