FAQforge provides answers for frequently asked questions for the Linux-, MAC and Windows operating systems.

Blocking .exe attachments with postfix or amavisd-new and ISPConfig 3

Wednesday, September 2, 2009 - posted by admin

If you use postfix and / or amavisd-new on the mail server, you can use the following recipes to block emails with executable (exe, bat, scr) attachments.

Block the attachments with a postfix header filter

In ISPConfig, click on “Email in the upper menu, then on “Content filter” in the left menu and click on the “Add new content filter” button. Enter the following details:

Filter:

MIME-Header Filter

Regexp. Pattern:

/^Content-(Disposition|Type).*name\s*=\s*”?(.*\.(bat|exe|scr))(\?=)?”?\s*(;|$)/x

Data:

File extension is blacklisted on this server

Action:

DISCARD

Use amavisd-new to block the emails with executable attachments.

Edit the amavisd configuration file (/etc/amavisd.conf or /etc/amavisd/amavisd.conf)

vi /etc/amavisd/amavisd.conf

and add the following lines:

$banned_filename_re = new_RE(
qr’.\.(bat|exe|scr)$’i,
qr’^\.(exe|zip|lha|tnef)$’i,
);

then restart amavisd-new:

/etc/init.d/amavis restart

How to access a namebased website without a DNS record

Monday, August 31, 2009 - posted by admin

If you want to access a namebased website that you created e.g. in ISPConfig before the DNS records are setup, edit the hosts file on your workstation computer and add a line like this:

192.168.0.100        www.mydomain.com

Replace the IP address with the IP of your server and www.mydomain.com with the domain name of the website.

The hosts file on linux and MAC systems is /etc/hosts, on Windows systems the hosts file is C:\Windows\system32\drivers\etc\hosts

The above trick also works if you want to run a website in your internal network (intranet) without having a DNS server availalble for local dns resolving.

A copy of a incoming email can be sent to a second email address by adding a cc command to the “Custom Rules” field of the mailbox in ISPConfig.

ISPConfig supports sieve as well as maildrop filter rules. The rule language depends on the LDA / POP3 / IMAP-Daemon that you use on your server. If you use courier, then the filter language is maildrop. When dovecot is installed, then the filter language is ieve.

Example in maildrop syntax:

To send a copy to the email address info@example.tld, add the following code at the beginning of the custom rules field.

cc '!info@example.tld'

Example in sieve syntax:

redirect 'info@example.tld';
keep;

If you get the following error message in Ubuntu when you use PHP based shell scripts:

PHP Warning: PHP Startup: Unable to load dynamic library ‘/usr/lib/php5/20060613+lfs/htscanner.so’ – /usr/lib/php5/20060613+lfs/htscanner.so: cannot open shared object file: No such file or directory in Unknown on line 0

Then edit the file /etc/php5/cli/php.ini:

vi /etc/php5/cli/php.ini

and remove the lines:

[htscanner]
Extension = “htscanner.so”
config_file = “.htaccess”
default_docroot = “/var/www”

As the htscanner module works only for scripts within webservers but not for commandline scripts.

ISPConfig 2: External mailserver setting does not work

Friday, August 21, 2009 - posted by admin

Problem: I have set the website to external mailserver in ISPConfig but emails get still delivered to the local server.

Solution: Set all co-domains of this website to external mailserver too. You find the external mailserver setting on the options tab of every co-domain.

Postfix: “queue file write error”

Friday, August 21, 2009 - posted by admin

If you get an error like:

Aug 21 12:41:03 webb4 postfix/sendmail[11234]: fatal: web1_user(12967): queue file write error

in your mail log, then the vale for message_size_limit in postfix main.cf is too low. Edit postfix main.cf:

vi /etc/postfix/main.cf

and set the message size limit to a higher value. E.g.

mesage_size_limit = 900000000

and restart postfix:

/etc/init.d/postfix restart

If there is no message_size_limit set in main.cf, just add the line.

Set stricter PHP settings to secure joomla and wordpress installations

Wednesday, August 19, 2009 - posted by admin

If you run a joomla or wordpress installation with mod_php, the following settings in the vhost configuration file or the “Apache directives” field in ISPConfig can be used to set stricter securitypolicys. This helps limit the impact of a possible hack to this websiteand protect the other sites on the server.

php_admin_value disable_functions “show_source system shell_exec passthru exec phpinfo popen proc_open”
php_admin_flag allow_url_fopen Off
php_admin_value session.save_path “/var/www/webXXX/phptmp/”
php_admin_value open_basedir “/var/www/webXXX/:/tmp”

Explanation

disable_functions disables functions that have a potential security impact e.g. because they allow the execution of external applications.

allow_url_fopen disables the ablity to open files via an URL.

session.save_path sets the path were php stores its session files. For ISPConfig 2, the path is e.g. “/var/www/webXXX/phptmp/” and for ISPConfig 3 the path is like “/var/www/clients/client1/web1/tmp/” If you dont use ISPConfig, set this path to a directory which is writable for the webserver user. the directory should be unique for every website.

open_basedir sets the path were php scripts are allowed to open files. For ISPConfig 2, the path is like  “/var/www/webXXX/” and for ISPConfig 3 the path is like “/var/www/clients/client1/web1/” If you dont use ISPConfig, set this path to a the root directory of this vhost. With :/tmp we allow php scripts to use also the /tmp directory of the server.

How to eject a CD on a MAC mini with PC keyboard and mouse

Tuesday, August 18, 2009 - posted by admin

There are several options to eject a CD or DVD when the mac mini fails to boot, but most of them dont work if you do not have a mac keayboard at hand. The following options work with a PC keayboard and mouse:

Press the left mouse key while you restart the mac or as alternative press [F12] while the mac is restarted. You have to keep the key pressed until the CD is ejected.

Fail2ban uses iptables by default to block incoming connections when they exceed the max.  login retrys. The iptables rules used by fail2ban might conflict with the firewall rules, so it might be nescessary to reconfigure fail2ban to use the route command for blocking incoming connections.

To reconfigure fail2ban for using the route command instead of iptables, edit or create the route.conf file:

vi /etc/fail2ban/action.d/route.conf

And insert the following lines:

# Fail2Ban configuration file

[Definition]
actionban = ip route add unreachable <ip>
actionunban = ip route del unreachable <ip>

Then add or change the banaction in the jail.local file in the [DEFAULT] section to “route”:

vi /etc/fail2ban/jail.local

And add or edit these lines:

# Fail2Ban configuration file

[DEFAULT]

banaction = route

Webalizer stats only showing 1 or 2 days?

Monday, August 17, 2009 - posted by admin

If webalizer statistics of your website are only showing the last 1 or two days instead of all days since the website has been created, you have to activate incremental processing in the webalizer configuration file (/etc/webalizer.conf or /etc/webalizer/webalizer.conf depending on the Linux distribution).

vi /etc/webalizer/webalizer.conf

Change the line:

# Incremental     yes

to:

Incremental     yes