Find the answer to your Linux question:
Results 1 to 4 of 4
I picked up a script from a hardening procedure, but it doesn't say what it is. Before I go and do something stupid, is this a valid Bash script? And ...
  1. #1
    Just Joined! Mistoffeles's Avatar
    Join Date
    Jul 2006
    Location
    Northern BC, Canada
    Posts
    54

    [SOLVED] Valid Bash script?

    I picked up a script from a hardening procedure, but it doesn't say what it is. Before I go and do something stupid, is this a valid Bash script? And is there any reason (i.e.: totally break the system) why these services should be disabled? (yes, I intend for the system not to ever print, so cups is included)

    for SERVICE in \
    chargen \
    chargen-udp \
    cups \
    cups-lpd \
    daytime \
    daytime-udp \
    echo-udp \
    eklogin \
    ekrb5-telnet \
    finger \
    gssftp \
    klogin \
    krb5-telnet \
    kshell \
    ktalk \
    ntalk \
    rexec \
    rlogin \
    rsh \
    talk \
    tcpmux-server \
    telnet \
    tftp \
    time-dgram \
    time-stream \
    uucp;
    do
    if [ -e /etc/xinetd.d/$SERVICE ]; then
    echo "Disabling SERVICE($SERVICE) - `ls -la /etc/xinetd.d/$SERVICE`."
    chkconfig ${SERVICE} off
    else
    echo "OK. SERVICE doesn't exist on this system ($SERVICE)."
    fi
    done

    Sorry for the lack of whitespace, the forum software (grr) keeps deleting it, leading tabs, leading spaces, whatever

  2. #2
    Linux Guru Rubberman's Avatar
    Join Date
    Apr 2009
    Location
    I can be found either 40 miles west of Chicago, or in a galaxy far, far away.
    Posts
    8,974
    You can keep the whitespaces if you enclose your code inside a code block. IE:
    Code:
    for SERVICE in \
    chargen \
    chargen-udp \
    cups \
    cups-lpd \
    daytime \
    daytime-udp \
    echo-udp \
    eklogin \
    ekrb5-telnet \
    finger \
    gssftp \
    klogin \
    krb5-telnet \
    kshell \
    ktalk \
    ntalk \
    rexec \
    rlogin \
    rsh \
    talk \
    tcpmux-server \
    telnet \
    tftp \
    time-dgram \
    time-stream \
    uucp;
    do
    if [ -e /etc/xinetd.d/$SERVICE ]; then
        echo "Disabling SERVICE($SERVICE) - `ls -la /etc/xinetd.d/$SERVICE`."
        chkconfig ${SERVICE} off
    else
        echo "OK. SERVICE doesn't exist on this system ($SERVICE)."
    fi
    done
    Anyway, without running it, it looks ok to me.
    Sometimes, real fast is almost as good as real time.
    Just remember, Semper Gumbi - always be flexible!

  3. #3
    Linux Guru
    Join Date
    Nov 2004
    Posts
    6,110
    Just to second Rubberman, from a quick glance it looks good to me, it's simply disabling the list of services provided. The backslash is just a carriage return/escape to allow the list to be more readable.

  4. #4
    Just Joined! Mistoffeles's Avatar
    Join Date
    Jul 2006
    Location
    Northern BC, Canada
    Posts
    54
    Seems to have worked with no adverse effects, thanks for the help.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
...