Solved

Calling rm and unlink from C++ on Solaris 10

Posted on 2011-02-22
4
729 Views
Last Modified: 2013-12-27
We are having a problem consistently deleting files on a solaris 10 system. Briefly, we start a process which starts multiple other processes. These processes run as root. I'm not sure why. This is a legasy system and there is LOTS that is not clear. But I digress.

These root processes delete (using unlink) some files and then recreate them. When I do a run, SOMTIMES the user/group of these files is "nobody users" and SOMETIMES the user/group of these files is "dave users". We don't yet know why this happens.

The problem is that from run to run the files that are supposed to get deleted and then created again do not always get deleted. This is obviously because the owner is not correct.  So unlink is not doing what we need, deleting the files no matter what.

If, from a shell in the terminal window, I issue an "rm" command, I will get a y/n prompt and the file will be deleted if I say "y".

I am changing the code to do a system call to do an "rm -f", but I'm not really happy with this. Anyone have any idea what might be going on?

D. Scruggs

PS - I don't know how this ended up in the Web Development/PHP zone. It wasn't supposed to. Just ignore, if you can.
0
Comment
Question by:bcfd2104
  • 2
4 Comments
 
LVL 76

Expert Comment

by:arnold
ID: 34956618
You have to look at the C++ code to see whether the process that runs has the drop in priviledge within.

When it spawns a process it might spawn it under a different user. one has to analyze the code to see what is going on.

you could run truss -f -p parent_process and see what it is doing.
0
 

Accepted Solution

by:
bcfd2104 earned 0 total points
ID: 34956625
I'll look into that, thanks.
0
 
LVL 2

Expert Comment

by:advega
ID: 35333653
Also, check who is the owner of the main binary (executable) file that you run, and if it has some sort of setuid permission on it.
0
 

Author Closing Comment

by:bcfd2104
ID: 35422415
I really didn't get an answer.
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Using libpcap/Jpcap to capture and send packets on Solaris version (10/11) Library used: 1.      Libpcap (http://www.tcpdump.org) Version 1.2 2.      Jpcap(http://netresearch.ics.uci.edu/kfujii/Jpcap/doc/index.html) Version 0.6 Prerequisite: 1.      GCC …
Developers of all skill levels should learn to use current best practices when developing websites. However many developers, new and old, fall into the trap of using deprecated features because this is what so many tutorials and books tell them to u…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

707 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

16 Experts available now in Live!

Get 1:1 Help Now