LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices


Reply
  Search this Thread
Old 05-22-2008, 05:07 PM   #1
tmee
LQ Newbie
 
Registered: May 2008
Posts: 2

Rep: Reputation: 0
Restrict ps to show only user own processes on Debian Etch.


Sup,

I'm about to limit ps-command output to list only user current processes.
I've created a bash-script to /bin/ps and moved original ps to ps123.
My bash-script works now well, after hours with nano & Google.
The script is a bit tricky since I wanted '/bin/sh /bin/ps' and 'sed ...'-rows out of the list.

Code:
#!/bin/sh

echo "Running processes for user $USER"
echo

procs=`/bin/ps123 -u $USER -U $USER u | (sed -e '/bin\/ps123/d' -e '/bin\/ps/d' -e '$d')`
echo "$procs" | (sed -e 's/$/\ /')

exit 1
My only problem is how to make this script unreadable but executable?
I don't want, that users can read the script above so I'm asking help here.
Tried to chmod & chgrp - with no effect. The script can only be (readable and executable) or (unreadable and unexecutable).

My advices are finished, yours ll'be appreciated!

Regards,
tme
 
Old 05-22-2008, 05:36 PM   #2
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,415
Blog Entries: 55

Rep: Reputation: 3608Reputation: 3608Reputation: 3608Reputation: 3608Reputation: 3608Reputation: 3608Reputation: 3608Reputation: 3608Reputation: 3608Reputation: 3608Reputation: 3608
If users can 0) walk /proc, 1) find ps123, 2) write scripts, 3) introduce or 4) compile binaries or 5) use other binaries that provide process listing, your scheme fails (...). So I wonder what you're trying to accomplish. If this is for an exposed machine that must stand some abuse (for example a shell account servers) I'd suggest you use the GRSecurity patch because even without using its RBAC features you get a lot of security-related improvements including compartmentalisation so an UID can only see the processes it has rights for.
 
Old 05-22-2008, 07:29 PM   #3
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Rocky 9.2
Posts: 18,430

Rep: Reputation: 2787Reputation: 2787Reputation: 2787Reputation: 2787Reputation: 2787Reputation: 2787Reputation: 2787Reputation: 2787Reputation: 2787Reputation: 2787Reputation: 2787
As per nnSpawn, and just to clarify, it is a fact that script files (bash, perl etc) must be readable as well as executable to run.
Only true binaries e.g. compiled C progs can get away with just being executable.
 
Old 05-23-2008, 02:35 AM   #4
tmee
LQ Newbie
 
Registered: May 2008
Posts: 2

Original Poster
Rep: Reputation: 0
Thank you unSpawn & chrism01!

Yes, I have couple shell-accounts on my chrooted server.
The Grsecurity-patch sound like a good plan, but I am running
kernel 2.6.18.8-xenU and I've no idea how to patch it into xen-kernel!

I found this page with Google: HOWTO: Installing Grsecurity patched kernel in debian/ubuntu

Advices?

Regards,
tme
 
Old 05-23-2008, 07:47 PM   #5
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,415
Blog Entries: 55

Rep: Reputation: 3608Reputation: 3608Reputation: 3608Reputation: 3608Reputation: 3608Reputation: 3608Reputation: 3608Reputation: 3608Reputation: 3608Reputation: 3608Reputation: 3608
See this GRSecurity.net forum thread, it shows it works. Go ahead and try I'd say.
 
Old 01-25-2011, 08:43 PM   #6
maccy44
LQ Newbie
 
Registered: Jan 2011
Posts: 1

Rep: Reputation: 0
If you dont want to mess with the kernel, then change the script like this:

#!/bin/sh

PSUSER=`/usr/bin/whoami`
now=$(date +"%R")
if [ "$PSUSER" != "root" ]
then
procs=`/bin/woot -u $USER -U $USER u | (sed -e '/bin\/woot/d' -e '/bin\/ps/d' -e '$d')`
else
procs=`/bin/woot aux`
fi
echo "$procs" | (sed -e 's/$/\ /')
echo "$USER 15231 0.0 0.0 4016 684 pts/0 S+ $now 0:00 ps"
exit 1


Then it would output all for root and the user would see current processes and ps. Since when you run ps, it is still showed at the bottom. Just a bit more convincing.
Peace;

J
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Only show own processes for regular users brianmcgee Linux - Server 1 04-08-2008 09:34 AM
show processes than don't belong to user root jianelisj Linux - Newbie 2 03-06-2008 11:31 PM
new Debian Etch user: autodetect video+monitor, how? bubazoo Debian 7 04-16-2007 03:56 PM
Show processes, not threads Martin Strand Linux - Newbie 1 06-14-2005 08:46 AM
Stunnel does not show up in processes after running it. Doctor Nick Linux - Software 9 08-07-2004 08:53 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Server

All times are GMT -5. The time now is 10:03 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration