- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- need help with a script to check if /etc/mail/alia...
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Discussions
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-01-2009 02:37 AM
10-01-2009 02:37 AM
i need help with a script to check if
/etc/mail/aliases file has 600 permission
if it has 600 permission then it will echo OK
Or else if its not there then it will echo NOK
Solved! Go to Solution.
- Tags:
- Permission
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-01-2009 02:52 AM
10-01-2009 02:52 AM
Re: need help with a script to check if /etc/mail/aliases file has 600 permission
Why not just look at at it? "ll /etc/mail/aliases"
If you really must do it in a script then use the ll command and parse the output. Or use the find command with the -name and -perm options.
Pete
Pete
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-01-2009 03:01 AM
10-01-2009 03:01 AM
Re: need help with a script to check if /etc/mail/aliases file has 600 permission
am not kidding!!
i know u just have to do ll... but u cn use it in the script if possible . this is to keep a track .. then later may be cron be implemented to get the periodic output of the changes..
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-01-2009 03:14 AM
10-01-2009 03:14 AM
Re: need help with a script to check if /etc/mail/aliases file has 600 permission
ll /etc/mail/aliases >> /var/tmp/aliases_perm.log
Pete
Pete
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-01-2009 03:28 AM
10-01-2009 03:28 AM
Re: need help with a script to check if /etc/mail/aliases file has 600 permission
but this is not what i want
ur solution is directing to logs..
but i want to keep a track in real time...
my aim is to create a script to check
if /etc/mail/aliases has the file permission has 600 permission(The aliases file is owned by root programs executed & aliases file entry should be owned by root & resides in a directory that is owned by root)
if its any thing other than 600 then it will give an output of Error . that will be done by a GUI tool which will be triggered by cron messeges.
but before that we need a script in place to this check. when the script is run it will give an error which in return give an error in the tool thruogh cron
i hope you understand.. btw thanx fr ur effort
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-01-2009 04:09 AM
10-01-2009 04:09 AM
SolutionDo you know that sendmail (newaliases) will refuse to process the /etc/mail/aliases file if it does NOT have the right ownership and permission. (although the file can still be readable and the directory can be traversed).
What are you going to do if the directory itself /etc/mail changes permissions?
What about /etc/mail/aliases.db? This file is worth more than /etc/mail/aliases
Anyway this ought to do it. Even if the file does not exist it will echo NOK.
/usr/bin/sh
if [ -f /etc/mail/aliases ]
then
aliasesmode=`ll /etc/mail/aliases | cut -c 1-10`
[ "$aliasesmode" = "-rw-------" ] && echo OK || echo NOK
else
echo NOK #file does not exist
fi
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-01-2009 04:23 AM
10-01-2009 04:23 AM
Re: need help with a script to check if /etc/mail/aliases file has 600 permission
I'm sorry to say that I agree with Pete.
Your questions have great similarity insofar as you want to perform simple queries of files or command output and print "OK" or "NOT_OK". I gave you an example yesterday in your thread:
http://forums.itrc.hp.com/service/forums/questionanswer.do?threadId=1375254
You should re-read my comments there and learn to do a bit of very basic scripting.
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-01-2009 05:18 AM
10-01-2009 05:18 AM
Re: need help with a script to check if /etc/mail/aliases file has 600 permission
yes you are rite it is part of security check
i Totally agrre to your ponts u mentioned for aliases file
the script is still fine wit me
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-02-2009 01:24 AM
10-02-2009 01:24 AM