Link to home
Start Free TrialLog in
Avatar of bcfd2104
bcfd2104

asked on

Calling rm and unlink from C++ on Solaris 10

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.
Avatar of arnold
arnold
Flag of United States of America image

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.
ASKER CERTIFIED SOLUTION
Avatar of bcfd2104
bcfd2104

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Daniel Vega
Daniel Vega

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.
Avatar of bcfd2104

ASKER

I really didn't get an answer.