LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 02-12-2010, 11:43 AM   #1
Hewson
Member
 
Registered: Feb 2007
Location: /home
Distribution: Kubuntu and CentOS
Posts: 214

Rep: Reputation: 32
How to see PPID of a sudo call?


I need to know what deamon process is using sudo.

I tried writing a quick bash wrapper:
Code:
#!/bin/bash
thedate=`date`
echo -e "$thedate\t$PPID is attempting to use sudo" >> /var/log/secure
/usr/bin/real_sudo "$@"
Code:
[root@cable ~: 09:37:42]# ls -l ./sudo_wrapper
---s--x--x 1 root root 122 Feb 12 09:27 ./sudo_wrapper*
Then setting it executable, owned by root, and turning the sticky bit on.

When I tried using this script as a normal user I just get permission denied.

Any ideas?

Last edited by Hewson; 02-12-2010 at 11:46 AM.
 
Old 02-12-2010, 12:48 PM   #2
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,415
Blog Entries: 55

Rep: Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600
Quote:
Originally Posted by Hewson View Post
echo -e "$thedate\t$PPID is attempting to use sudo" >> /var/log/secure
Do that with /var/log/secure and fsck up the syslog timestamps: use 'logger' and provide the right facility and priority instead.


Quote:
Originally Posted by Hewson View Post
setting it executable, owned by root, and turning the sticky bit on.
Setuid doesn't work with scripts.


Quote:
Originally Posted by Hewson View Post
I need to know what deamon process is using sudo.
It all boils down to this: why?


The process replaces Sudo so AFAIK there's no way searching for it afterwards: you'll have to get in right before that. A script might work if your "daemon process" runs in a single-user-per-group way, then maybe you could search the process space for that user: those processes won't share UID (obviously) but they'll share SID. Better would be to get in right before that but using syscall logging. For instance Auditd will show the PID of the resulting process and the original UID. I hope that's enough leads to try 'n play "connect the dots".
 
Old 02-12-2010, 01:52 PM   #3
Hewson
Member
 
Registered: Feb 2007
Location: /home
Distribution: Kubuntu and CentOS
Posts: 214

Original Poster
Rep: Reputation: 32
Quote:
Originally Posted by unSpawn View Post
Do that with /var/log/secure and fsck up the syslog timestamps: use 'logger' and provide the right facility and priority instead.
It was mostly a hack

Quote:
Originally Posted by unSpawn View Post
Setuid doesn't work with scripts.
ya, apparently the kernel ignores setuid for scripts for security reasons.

Quote:
Originally Posted by unSpawn View Post
It all boils down to this: why?
I'm on a dev machine and was trying to figure out what process was misbehaving.

I just replaced /usr/bin/sudo with my script, setting normal 755 permissions. This was good enough to figure out which process; Not really a working solution for anything longterm, but good enough for my needs. Thanks for the response.
 
  


Reply



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
LXer: The Ultimate Sudo FAQ — To Sudo Or Not To Sudo? LXer Syndicated Linux News 13 04-13-2013 01:36 AM
why is the ppid is 1 for a user process? venkat_k Programming 5 04-11-2009 06:47 PM
PPID from /proc file system? sanjaykhuntia Linux - Enterprise 1 10-26-2007 03:40 PM
strange pid and ppid problem asvija Linux - General 1 03-10-2005 01:53 AM
pidof -o %PPID program vanalex Linux - General 2 01-26-2004 09:35 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 11:51 PM.

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