Solved

Calling rm and unlink from C++ on Solaris 10

Posted on 2011-02-22
4
735 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 77

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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Attention: This article will no longer be maintained. If you have any questions, please feel free to mail me. jgh@FreeBSD.org Please see http://www.freebsd.org/doc/en_US.ISO8859-1/articles/freebsd-update-server/ for the updated article. It is avail…
Introduction This article is intended for those who are new to PHP error handling (https://www.experts-exchange.com/articles/11769/And-by-the-way-I-am-New-to-PHP.html).  It addresses one of the most common problems that plague beginning PHP develop…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

809 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