LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 07-11-2007, 06:05 PM   #1
carlosinfl
Senior Member
 
Registered: May 2004
Location: Orlando, FL
Distribution: Arch
Posts: 2,905

Rep: Reputation: 77
Understanding a Shell Script I Found


I was looking through our email server and found this bash script and am not really sure I understand it's function and was wondering if someone on here can look at this and kind of explain this to me of what they think this would be used for...

Code:
#!/bin/bash

PASSWD_MD5=$(/usr/bin/md5sum /etc/passwd | awk '{print $1}')
POSTFIX_PASSWD_MD5=$(/usr/bin/md5sum /var/spool/postfix/etc/passwd | awk '{print $1}')

if [ "$1" == "-debug" ]; then
        DEBUG=1
else
        DEBUG=0
fi

if [ ! "$PASSWD_MD5" == "$POSTFIX_PASSWD_MD5" ]; then
        /bin/cp -f /etc/passwd /var/spool/postfix/etc/passwd
        if [ $DEBUG -eq 1 ]; then
                echo "Copied /etc/passwd file for Postfix."
                echo "/etc/passwd: $PASSWD_MD5"
                echo "Postfix:     $POSTFIX_PASSWD_MD5"
        fi
else
        if [ $DEBUG -eq 1 ]; then
                echo "No need to copy /etc/passwd file to Postfix (They are already the same)."
                echo "/etc/passwd: $PASSWD_MD5"
                echo "Postfix:     $POSTFIX_PASSWD_MD5"
        fi
fi
The name of the script is "postfix-copy-passwd.sh"
 
Old 07-11-2007, 06:18 PM   #2
bigrigdriver
LQ Addict
 
Registered: Jul 2002
Location: East Centra Illinois, USA
Distribution: Debian stable
Posts: 5,908

Rep: Reputation: 356Reputation: 356Reputation: 356Reputation: 356
Rename the script, then send a test email to see if anything in Postfix breaks. That might tell you what it's intended to do.

On re-examination, the script generates an MD5 sum on /etc/passwd and /var/spool/postfix/etc/passwd. Then a test: if not equal, copy /etc/passwd to /var/spool/postfix/etc/passwd and report the copy, otherwise, report that the files are already the same.

From one point of view, it's a quick way to keep two files in sync so that as passwords change in /etc/passwd, the postfix file is updated. From a crackers point of view, it could be a quick way to hide attacks on password files.

Last edited by bigrigdriver; 07-11-2007 at 06:30 PM.
 
  


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 On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
running shell script: command not found tripat Red Hat 3 04-14-2010 01:21 PM
Can't seem to run a simple shell script error command not found each time SimonT Linux - Newbie 5 10-29-2006 06:31 AM
shell script problem, want to use shell script auto update IP~! singying304 Programming 4 11-29-2005 05:32 PM
Understanding shell foo_mulan Linux - Newbie 3 07-23-2004 02:36 PM
command not found (My shell script) Swift&Smart Linux - Software 3 05-15-2004 11:14 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

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