473,406 Members | 2,369 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

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

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.
Jul 22 '05 #1
3 2570
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

Jul 22 '05 #2
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.
Jul 22 '05 #3
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.


Jul 22 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: jrefactors | last post by:
when people say unix programmer, does it mean they write programs in unix environment,and those programs are run in unix platform? it is not necessary they are using unix function calls? I heard...
3
by: sfeil | last post by:
I'm writing a program in python to sort the mail in standard Unix email boxes. In my "prof of concept" example I am coping a letter to a second mailbox if the letter was send from a particular...
4
by: eight02645999 | last post by:
hi i created a login page that authenticate the user and his/her password to the unix ssystem. what modules can i used to compare the unix password with what the user typed in the cgi form? the...
3
by: Fabian Knopf | last post by:
Hi friends, i have a unix machine PC1 where a database is running ( IBM DB2 V8.1 ) . Then i have another machine PC2 i installed there also ( IBM DB2 V8.1 ). On PC2 i installed unixODBC. To...
3
by: K.S.Liang | last post by:
Hi all, 1> If there are more than one dynamic linking libraries in the file system, how do I know which one is loaded into system? Any C library or system call can tell me which *.so or *.sl is...
2
by: Johhny | last post by:
Hello, I am trying to get the user that is running the scripts uid, I have had a look at the pwd module and it does not appear to offer that functionality. Is there any way within python to get...
8
by: fabio | last post by:
hi everybody i have a weird problem with my project, look at this: **************************************************** Debian:/progetto/PROGETTO$ ls -al server -rwsr-xr-x 1 root faz 372731...
7
by: Adam | last post by:
Hello. I do most of my web dev work from a Mac (whose file system is case-insensitive.) I upload my web pages and other files onto a Unix-based host, which is case sensitive. When I look at the...
16
by: mazwolfe | last post by:
Someone recently asked about reading lines. I had this code written some time ago (part of a BASIC-style interpreter based on H. Shildts in Art of C) to read a file with the lines ended in any...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.