/etc/hosts.allow(deny)

 

ACCESS CONTROL FILES


The access control software consults two files. The search stops at the first match:

*
Access will be granted when a (daemon,client) pair matches an entry in the/etc/hosts.allow file.
*
Otherwise, access will be denied when a (daemon,client) pair matches an entry in the/etc/hosts.deny file.
*
Otherwise, access will be granted.

A non-existing access control file is treated as if it were an empty file. Thus, access control can be turned off by providing no access control files.

ACCESS CONTROL RULES

Read more...

Bash IFS variable

Print PDF

 

Using the Bash IFS variable to make for loops split with non whitespace characters

 

A basic for loop

The Bash for loop splits using a whitespace (space, tab or newline). This allows you to easily iterate over a glob of values, as follows (this particular example uses a glob of filenames, taken from a backup script that requires a list of files to exclude from the backup):

Script:

#!/bin/bash
vals='/mnt /dev /proc /sys /tmp /usr/portage /var/tmp'
for i in $vals; do echo $i; done

Output:

/mnt
/dev
/proc
/sys
/tmp
/usr/portage
/var/tmp

The problem

A problem arises when one of the values in the glob needs to contain a space. Take the following example:

#!/bin/bash
vals='/mnt /var/lib/vmware/Virtual Machines /dev /proc /sys /tmp /usr/portage /var/tmp'
for i in $vals; do echo $i; done

Output:

/mnt
/var/lib/vmware/Virtual
Machines
/dev
/proc
/sys
/tmp
/usr/portage
/var/tmp

"/var/lib/vmware/Virtual Machines" is split because it contains a space, which would obviously be a major problem if you were attempting to do something with each file location rather than just echoing it.

The IFS internal variable

One way around this problem is to change Bash's internal IFS (Internal Field Separator) variable so that it splits fields by something other than the default whitespace (space, tab, newline), in this case, a comma.

#!/bin/bash
IFS=$','
vals='/mnt,/var/lib/vmware/Virtual Machines,/dev,/proc,/sys,/tmp,/usr/portage,/var/tmp'
for i in $vals; do echo $i; done
unset IFS

Output:

/mnt
/var/lib/vmware/Virtual Machines
/dev
/proc
/sys
/tmp
/usr/portage
/var/tmp

It's best to unset IFS after you've done your work, with unset IFS, so that it returns to its default value. This will avoid any potential problems that could arise in the rest of your script.

 

source:

http://mindspill.net/computing/linux-notes/using-the-bash-ifs-variable-to-make-for-loops-split-with-non-whitespace-characters.html

 

What is your Linux Desktop OS?











Who's Online+

  • [Bot]
Now online:
  • 1 guest
  • 1 robot
Total members: 0

Who's Online

We have 3 guests online

Statistics

Content View Hits : 15602