Changing fname in /proc filesystem


 
Thread Tools Search this Thread
Top Forums Programming Changing fname in /proc filesystem
# 1  
Old 11-17-2006
Changing fname in /proc filesystem

I wrote a wrapper (call it prog1) around another program (call it prog2) for security purposes. When prog1 launches prog2 it sets the argv[0] value to be "prog1" so that "prog2" does not show up when you use the "ps" command. Howerver, if you use the option "-o fname" with "ps" then the file name for prog2 still shows up (also when running "sdtprocess", this being Solaris). I'd like to stop this from happening, but the file name is apparently being pulled from the /proc file system and I don't think prog1 is going to have permission to change any values in prog2's state. So I have 2 questions:

1) Is it even possible to change the filename values in prog2's /proc entries through any method?

2) Is there any way to do this from within prog1? (I don't have access to prog2's source code or I wouldn't have needed a wrapper to begin with)

Thanks or any help.
# 2  
Old 11-17-2006
1. You can't rename them because they are creations of the kernel.

2. I just tried this - you can create a symlink to the file with ln -s to a directory in /proc, and it works correctly.

??
3. Your first program could read the /proc/whatever/file into a local file then give that file name to prog2
# 3  
Old 11-17-2006
Quote:
Originally Posted by jim mcnamara
1. You can't rename them because they are creations of the kernel.

2. I just tried this - you can create a symlink to the file with ln -s to a directory in /proc, and it works correctly.

??
3. Your first program could read the /proc/whatever/file into a local file then give that file name to prog2
I'm not sure I understand your answers. I think we might be talking past each other so let me see if I can be a little more specific in what I'm doing.

prog2 is just a standard Xwindows application that knows nothing about what I'm trying to do. prog1 is a "wrapper" around it that I wrote. prog2 has been moved out of it's standard location and put somewhere else in the file system. prog1 has taken it's place. It's job is to check the user id and the command line being passed to prog2 to see if it is allowed, and if it is then execute prog2 with that command line. However, I don't want "prog2" showing up in a "ps" listing, so before executing the execv command I change argv[0] to "prog1". So if you just run "ps" prog2 never shows up since the default for ps is to show only the command line, not the actual file name. But if you pass "-o fname" (or use "sdtprocess") then the actual filename shows up, which is bad because the command line says "prog1" and the actual filename says "prog2".

I'm using Solaris 8 if that makes a difference. I've looked at the /proc directory and it's all pid values for directories and each directory has a standard layout. The only place I've found the filenames I'm looking for is in the file "psinfo", which makes sense since there is a "psinfo" structure in the "procfs.h" header with an "fname" field. So I assumed the way to change the value of fname for "prog2" was to find it's pid (no problem there), read in the psinfo file, change the fname field and write it back out. Assuming this can be done, which I suspected could not be, and your comments in 1) above reinforces that.

In your other comments you mention creating a smylink between a directory in /proc and something else (prog2?) or copying a file from the /proc directory and giving that name to prog2. I don't know what you are saying here. Could you explain this further?

Thank you for your reply.
# 4  
Old 11-17-2006
What I think your problem is: being able to view the name of the file in the /proc directory in ps. What my solution is: make the file look like another one completely -disguise the actual name of the file - since you wanted to "rename" a /proc file entry, this renames the entry as far as ps is concerned. But not as far as the prog2 is concerned.

Code:
ln -s /proc/directory/somefile ./somelink
prog2 ./somelink

The ps display will show ./somelink not /proc.....
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. AIX

Mount Filesystem in AIX Unable to read /etc/filesystem

Dear all, We are facing prolem when we are going to mount AIX filesystem, the system returned the following error 0506-307The AFopen call failed : A file or directory in the path name does not exist. But when we ls filesystems in the /etc/ directory it show -rw-r--r-- 0 root ... (2 Replies)
Discussion started by: m_raheelahmed
2 Replies

2. Solaris

Solaris Filesystem vs. Windows FileSystem

Hi guys! Could you tell me what's the difference of filesystem of Solaris to filesystem of Windows? I need to compare both. I have read some over the net but it's so much technical. Could you explain it in a more simpler term? I am new to Solaris. Hope you help me guys. Thanks! (4 Replies)
Discussion started by: arah
4 Replies

3. UNIX for Dummies Questions & Answers

hwo to find shared filesystem and local filesystem in AIX

Hi, I wanted to find out that in my database server which filesystems are shared storage and which filesystems are local. Like when I use df -k, it shows "filesystem" and "mounted on" but I want to know which one is shared and which one is local. Please tell me the commands which I can run... (2 Replies)
Discussion started by: kamranjalal
2 Replies

4. Linux

Tripwire Nightware on Linux (proc filesystem)

Hello, I am having a nightmare with Tripwire on Linux..... I cannot get it to ignore the /proc filesystem, which I want to completely ignore for now Has anyone here successfully configured Tripwire on Linux and completed ignored the /proc filesystem ? If so, please reply and tell me how... (0 Replies)
Discussion started by: Neo
0 Replies

5. Solaris

Filesystem - error when extend the filesystem

Hi all, currently , my root filesystem already reach 90 ++% I already add more cylinder in the root partition as below Part Tag Flag Cylinders Size Blocks 0 root wm 67 - 5086 38.46GB (5020/0/0) 80646300 1 swap wu 1 - ... (11 Replies)
Discussion started by: SmartAntz
11 Replies

6. Solaris

Solaris 10 /proc making filesystem full

Hi all, I have a solaris 10 box on which /proc is a part of / The problem is that my / partition is getting full mainly due to /proc getting a lot of files. My question is : Can I delete files/directories in /proc directory. If not what could be the other way round to clean up /proc so... (18 Replies)
Discussion started by: run_time_error
18 Replies

7. UNIX for Dummies Questions & Answers

_/proc/stat vs /proc/uptime

Hi, I am trying to calculate the CPU Usage by getting the difference between the idle time reported by /proc/stat at 2 different intervals. Now the 4th entry in the first line of /proc/stat will give me the 'idle time'. But I also came across /proc/uptime that gives me 2 entries : 1st one as the... (0 Replies)
Discussion started by: coderd
0 Replies

8. Shell Programming and Scripting

Changing userID and Changing group and GID

Hello, I want to write a ksh script about changing UID and changing group with GID. There are multiple servers i want to perform that job. linux1 linux2 linux3 linux4 linux5 ...... . . . . . 1.) How can i enter "password" in script rather asking me? I was trying this... ssh... (2 Replies)
Discussion started by: deal732
2 Replies

9. Filesystems, Disks and Memory

Changing Filesystem size.

Hi there, can i change the size of filesystem afterwards. i want give some more space to my /export/home and want take some space from /opt. is it possible in solaris ? Any help will be appriciated. Abid (2 Replies)
Discussion started by: abidmalik
2 Replies

10. UNIX for Dummies Questions & Answers

about /proc

hi, we all know /proc is about the information of active process, I have just read an artical which said you can use /proc/cpuinfo, /proc/net./proc/meminfo etc. to know about some hardware information .But I want to know how to use with command line? (1 Reply)
Discussion started by: fuqiang1976
1 Replies
Login or Register to Ask a Question