LinuxQuestions.org
Review your favorite Linux distribution.
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 10-01-2012, 09:06 AM   #1
pingu
Senior Member
 
Registered: Jul 2004
Location: Skuttunge SWEDEN
Distribution: Debian preferably
Posts: 1,350

Rep: Reputation: 127Reputation: 127
tcsh: Log all commands to syslog


On a server requirements are that all commands issued by root or using sudo must be sent to syslog, with real user's name (PCI requirement).
For the standard shell (bash) this is not a problem, simply added this line to /root/.bashrc:
Code:
PROMPT_COMMAND='history -a >(tee -a ~/.bash_history | logger -t "$USER[$$] $SUDO_USER[$$] $SSH_CONNECTION")'
But the server also has tcsh, how do I configure it there?
I've tried to use 'precmd' in /root/.cshrc but it fails to log anything. The closest I got is
Code:
alias precmd tee -a ~/.history | logger -t "$USER[$$] $SUDO_USER[$$]"
This doesn't output any error message when switching shell to tcsh, but still nothing is logged.
Putting single quote around the command almost works - when logging in it's like command waiting to finish, if I press <enter> I get a line in /var/log/messages - so it obviously logs to syslog! (And I've tried all 3 single quotes).
But then, the prompt just hangs, like with a not completed command.
Setting the command between parenteses I get "Badly placed ()'s"

And tcsh cannot be removed (required by subversion and some other apps we simply must have).
Server is running OpenSuse 12.1.

Any ideas?
 
Old 10-01-2012, 10:33 AM   #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 pingu View Post
On a server requirements are that all commands issued by root or using sudo must be sent to syslog, with real user's name (PCI requirement).
For the standard shell (bash) this is not a problem, simply added this line to /root/.bashrc:
Code:
PROMPT_COMMAND='history -a >(tee -a ~/.bash_history | logger -t "$USER[$$] $SUDO_USER[$$] $SSH_CONNECTION")'
While that's certainly creative (and let's forego talking about protecting variables) it relies on the user land process itself to perform logging and I hope you can see what uncertainties (at least) that causes wrt the integrity of what's being logged (and how will you find out if nothing was logged BTW? ;-p).


Quote:
Originally Posted by pingu View Post
Any ideas?
We've actually got quite a few "I want to log everything"-like threads at LQ. If you search for my handle in combination with search terms like audit, rootsh, sudosh you should find some to read.
 
  


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
How to change Debian log rotation of syslog and daemon.log onmountain Linux - Newbie 2 07-31-2008 02:27 AM
I need help getting syslog to log remotely, this is just the regular syslog. abefroman Linux - Software 2 06-05-2008 11:36 AM
syslog client to log to syslog-ng and itself noir911 Linux - Server 1 02-08-2008 09:51 AM
Alias commands in tcsh (Suse 9.0) m15a4 Linux - General 5 11-26-2003 03:46 PM
tcsh history log twantrd Linux - General 3 06-25-2003 06:57 AM

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

All times are GMT -5. The time now is 12:31 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