Archive for the 'Howto' Category

How to change the DirectAdmin server IP address

#cd /usr/local/directadmin/scripts
#./ipswap.sh <oldip> <newip>

Now alle the directadmin config files are changed.
Now apache needs a restart to activate this.

No Comments »

SVN and Mac OSX hidden .DS_Store ._ .AppleDouble files

If you work on a mac (as i do) your directories get poluted with .DS_Store, ._ and .AppleDoubel files. Apple (this is THE missing Finder feature!) has no option to turn this crap off.
Now when you use svn, you will also import all these useless files.

Thank god there is a option in svn to globally ignore specific files.
Just edit the file:

~/subversion/config

Find the line global-ignores, uncomment it and make it something like this:

global-ignores = *.o *.lo *.la #*# .*.rej *.rej .*~ *~ .#* .DS_Store .AppleDouble ._*

Whoot!

No Comments »

Iptables active and passive FTP in CentOS

This is how to make sure active AND passive FTP work flawlessly with IPtables, in this case, on CentOS. In this case it was for a DirectAdmin server.
You have to look up in your ftpd config which passive FTP ports your daemon uses and use those. In my case the portrange was 35000-35999.

This is /etc/sysconfig/iptables

# Firewall configuration written by system-config-securitylevel
# Manual customization of this file is not recommended.
*filter
:INPUT ACCEPT [0:0]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [0:0]
:RH-Firewall-1-INPUT - [0:0]
-A INPUT -j RH-Firewall-1-INPUT
-A FORWARD -j RH-Firewall-1-INPUT
-A RH-Firewall-1-INPUT -i lo -j ACCEPT
-A RH-Firewall-1-INPUT -p icmp --icmp-type any -j ACCEPT
-A RH-Firewall-1-INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT

#active and passiev ftp
-A RH-Firewall-1-INPUT -p tcp --syn --dport 21 -j ACCEPT
-A RH-Firewall-1-INPUT -p tcp --syn --dport 20 -j ACCEPT
-A RH-Firewall-1-INPUT -p tcp --syn --dport 35000:35999 -j ACCEPT

#ssh only for me
-A RH-Firewall-1-INPUT -s 1.2.3.4 -m state --state NEW -m tcp -p tcp --dport 22 -j ACCEPT

#other useful ports available to the public
-A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 25 -j ACCEPT
-A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT
-A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 110 -j ACCEPT
-A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 443 -j ACCEPT
-A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 2222 -j ACCEPT
-A RH-Firewall-1-INPUT -j REJECT --reject-with icmp-host-prohibited
COMMIT

Now we have to make sure some iptables modules are loaded.
Edit /etc/sysconfig/iptables-config
Make sure this line is looking like this:

IPTABLES_MODULES="ip_conntrack_netbios_ns ip_nat_ftp ip_conntrack_ftp"

Restart your iptables and test your ftp connection. It should work as expected.

3 Comments »

Alternate PHP exec() function bypassing cmd.exe

I had a problem running executables (like identify.exe and convert.exe from ImageMagick) from php under windows using the exec() funciton. The solution provided by others was kind off stupid... Give full permisions on cmd.exe to IURS... Like you wanna do that.....
I wrote a exec() replacement function using the bypass_shell option proc_open has. It works great for me. Do your favour with it.

 
<?php
 
	function executeCommand($cmd) {
 
		if(DEBUG === true) {
			echo "Command: ".$cmd;
			echo "<br>";
			echo "Tempdir: ".TEMP_DIR;
			echo "<br>";
		}
 
		$descriptorspec = array(
		   0 => array("pipe", "r"),
		   1 => array("pipe", "w"),
		   2 => array("pipe", "w")
		);
 
		$process = proc_open(
				$cmd,
				$descriptorspec,
				$pipes,
				TEMP_DIR,
				NULL,
				array('bypass_shell' => TRUE)
		);
 
		if(!is_resource($process)) {
			return false;
		}
 
		if(!$pipes[1]) {
			if(DEBUG === true) {
				echo "No STDOUT<br>";
			}
			return false;
		}
		$output = stream_get_contents($pipes[1]);
		fclose($pipes[1]);
		$err = stream_get_contents($pipes[2]);
		fclose($pipes[2]);
 
		$x = proc_get_status($process);
 
		$return_value = proc_close($process);
 
		if($return_value == 0) {
			if(DEBUG === true) {
				echo "Return value {$return_value}<br>";
				print_r($x);
				echo "<br><br><br>";
			}
			return explode("\n", str_replace("\r", '', $output));
		} else {
			if(DEBUG === true) {
				echo "Return value {$return_value}<br>";
				print_r($x);
				echo "Output: ".$output;
				echo "Error: ".$err;
				echo "<br><br><br>";
			}
			return false;
		}
 
	}
?>
 

3 Comments »

ClamAV 0.94 not working anymore in MailScanner

I had this issue, clamav worked perfectly on command line, but within MailScanner it seemed to stop working. I could not find out why. I checked every configuration file, everything seemed normal.

Today i was upgrading ClamAV from 0.94 to 0.94.1, and suddenly i saw these lines in my maillog:


Nov 12 09:01:39 mx02 MailScanner[26358]: WARNING: Ignoring deprecated option --unzip
Nov 12 09:01:39 mx02 MailScanner[26358]: WARNING: Ignoring deprecated option --jar
Nov 12 09:01:39 mx02 MailScanner[26358]: WARNING: Ignoring deprecated option --tar
Nov 12 09:01:39 mx02 MailScanner[26358]: WARNING: Ignoring deprecated option --tgz
Nov 12 09:01:39 mx02 MailScanner[26358]: WARNING: Ignoring deprecated option --deb
Nov 12 09:01:39 mx02 MailScanner[26358]: WARNING: Ignoring deprecated option --unrar
Nov 12 09:01:39 mx02 MailScanner[26358]: WARNING: Ignoring deprecated option --arj
Nov 12 09:01:39 mx02 MailScanner[26358]: WARNING: Ignoring deprecated option --lha
Nov 12 09:01:39 mx02 MailScanner[26358]: WARNING: Ignoring deprecated option --unzoo
Nov 12 09:01:39 mx02 MailScanner[26358]: WARNING: Ignoring deprecated option --max-ratio
Nov 12 09:01:39 mx02 MailScanner[26358]: WARNING: Ignoring deprecated option --unrar

Hmmmm.. weird. I started googling and found this bug:
https://wwws.clamav.net/bugzilla/show_bug.cgi?id=1213

They did this: Instead of hardfailing, clamd will print warnings.

Glad it is resolved now..

2 Comments »

How to make a shortcut in OSX

Because i keep forgetting this crap:

Press Shift-Alt-Apple then drag the folder to somewhere to create a shortcut.
This only works on the SAME disk/partition.

No Comments »

Automatic frame redirect (cloaking) with apache and PHP

Sometimes a customer wants redirection using a frame. What you as an ISP don't want to do is make webspace and a index.html file for each customer handling this. You want this automated somehow.
This is how i did it.

First set up redirection with apache.

 
<VirtualHost *:80>
    ServerName www.whatever.com
    ServerAdmin admin@whatever.com
    DocumentRoot /usr/local/www/apache22/data
    SetEnv FRAMEREDIRECTURL "http://www.to-where-ever.com/blah/blah"
    ServerAlias *.whatever.com whatever.com
</VirtualHost>
 

As you can see we set a environment variable containing the URL you want to redirect to.
Next you will need some PHP to generate the frameset. Create this in the documentroot you specified in the virtual host.

 
<html>
<frameset rows="100%">
<frame src="<?php echo $_SERVER['FRAMEREDIRECTURL'] ?>">
</frameset>
<noframes>
<body>Please follow <a href="<?php echo $_SERVER['FRAMEREDIRECTURL'] ?>">link</a>.</body>
</noframes>
</html>
 

This is it. Use this info if you can.
Cheers

No Comments »

Stop OSX from creating irritating dot files on network drives

To stop Max OSX from creating .DS_Store files on network drives (and prevent pissing of your co-workers) just type in this on a terminal and reboot:

defaults write com.apple.desktopservices DSDontWriteNetworkStores true

4 Comments »

Display date in OSX clock

I wanted to display the date in my OSX toolbar clock without any additional software. This link will help you do this: click here

No Comments »

Use a drive letter for a directory path

This is just a reminder for myself as i just cannot seem to remeber any features of old scool DOS. *NIX is more my thing :)
Thank god i have a college named whizzrd :)

C:\>subst P: C:\Projects

Remove by:

C:\>subst P: /D

No Comments »

« Prev - Next »