Solved

Calling rm and unlink from C++ on Solaris 10

Posted on 2011-02-22
4
748 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 78

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

Don't Cry: How Liquid Web is Ensuring Security

WannaCry is just the start. Read how Liquid Web is protecting itself and its customers against new threats.

Question has a verified solution.

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

Foreword (July, 2015) Since I first wrote this article, years ago, a great many more people have begun using the internet.  They are coming online from every part of the globe, learning, reading, shopping and spending money at an ever-increasing ra…
FreeBSD on EC2 FreeBSD (https://www.freebsd.org) is a robust Unix-like operating system that has been around for many years. FreeBSD is available on Amazon EC2 through Amazon Machine Images (AMIs) provided by FreeBSD developer and security office…
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.

696 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