LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Security
User Name
Password
Linux - Security This forum is for all security related questions.
Questions, tips, system compromises, firewalls, etc. are all included here.

Notices


Reply
  Search this Thread
Old 09-12-2009, 09:57 PM   #1
abefroman
Senior Member
 
Registered: Feb 2004
Location: lost+found
Distribution: CentOS
Posts: 1,430

Rep: Reputation: 55
Is there a way to prevent users from changing or unset their HISTFILE variable?


Is there a way to prevent users from changing or 'unset'ting their HISTFILE variable?



TIA
 
Old 09-13-2009, 05:46 AM   #2
jacknelson
LQ Newbie
 
Registered: Sep 2009
Posts: 2

Rep: Reputation: 0
Users usually use the following to remove all traces of their activity

killall -9 syslogd klogd (kill loggers)
unset HISTFILE (stop .bash_history records)
I see that logs are usually stored in /var/log/messages and /var/log/secure

This doesn't mean you can't have the logs sent to another box or to a printer, etc through a background process.

So if you don't find a way to prevent users to unset their HISTFILE then I recommend you backup(dump) the HISTFILE value every now and then and if it is unset you will have the backup which you can check for more info.
 
Old 09-13-2009, 08:47 AM   #3
abefroman
Senior Member
 
Registered: Feb 2004
Location: lost+found
Distribution: CentOS
Posts: 1,430

Original Poster
Rep: Reputation: 55
Thanks, I'm talking about for an underprivileged user though.

They shouldn't be able to stop the syslogs.
 
Old 09-13-2009, 10:44 AM   #4
fpmurphy
Member
 
Registered: Jan 2009
Location: /dev/ph
Distribution: Fedora, Ubuntu, Redhat, Centos
Posts: 299

Rep: Reputation: 62
In general, there is no way of stopping users from changing their own shell variables including HISTFILE.
 
Old 09-13-2009, 10:47 AM   #5
abefroman
Senior Member
 
Registered: Feb 2004
Location: lost+found
Distribution: CentOS
Posts: 1,430

Original Poster
Rep: Reputation: 55
Would this work?
Code:
chmod 700 unset
chmod 700 set
chmod 700 export
Are there any others?
 
Old 09-13-2009, 11:09 AM   #6
catkin
LQ 5k Club
 
Registered: Dec 2008
Location: Tamil Nadu, India
Distribution: Debian
Posts: 8,578
Blog Entries: 31

Rep: Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208
Quote:
Originally Posted by abefroman View Post
Would this work?
Code:
chmod 700 unset
chmod 700 set
chmod 700 export
Are there any others?
No. chmod works on files but
Code:
c@CW8:~$ type unset set export
unset is a shell builtin
set is a shell builtin
export is a shell builtin
fpmurphy is right, even the restricted shell doesn't restrict changing HISTFILE. Bash' history mechanism is a convenience for the user. It was not designed as an audit trail and cannot be effectively used as one. If you want to track what commands your users are running, you will have more success with a tool designed for the job.
 
Old 09-13-2009, 11:23 AM   #7
abefroman
Senior Member
 
Registered: Feb 2004
Location: lost+found
Distribution: CentOS
Posts: 1,430

Original Poster
Rep: Reputation: 55
Quote:
Originally Posted by catkin View Post
No. chmod works on files but
Code:
c@CW8:~$ type unset set export
unset is a shell builtin
set is a shell builtin
export is a shell builtin
Wow, I didn't even know there were shell builtins, I always thought it was /bin/unset or something. I just double checked, and you are right.

I am assuming the shell builtin override whats in $PATH, correct?
 
Old 09-13-2009, 11:41 AM   #8
catkin
LQ 5k Club
 
Registered: Dec 2008
Location: Tamil Nadu, India
Distribution: Debian
Posts: 8,578
Blog Entries: 31

Rep: Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208
Quote:
Originally Posted by abefroman View Post
I am assuming the shell builtin override whats in $PATH, correct?
Correct. See the Gnu Bash Reference's Command Search and Execution section for the full story.
 
  


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 unset environment variable in bash suneel Linux - Newbie 7 09-14-2009 10:17 AM
unset export variable mira.mikes Linux - Desktop 4 03-17-2009 02:31 AM
how do i prevent windows users from changing the share permission? m2azer Linux - Networking 2 01-15-2007 10:22 PM
How to prevent users from --> Drogo Linux - Software 7 01-31-2004 11:03 PM
unset a readonly variable hamster Linux - General 2 05-19-2003 05:13 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Security

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