Archive for the ‘Ubuntu’ tag
Move GNOME panels in Ubuntu 9.04
Some days ago i updated my Ubuntu Intrepid Ibex to the new Jaunty Jackalope. Besides some minor glitches everything works smoothly. One small issue however annoyed me.
I always work with a dual monitor setup. And i like to have a GNOME panel on every screen. So normally i would just create a new panel and drag it to the second screen. This doesn’t seem to work anymore. Or maybe it’s just a bug. After some playing around with the panel settings i found a small work around.
So to add an extra panel to the desktop. Just right click on the main panel and choose “New Panel”.
This will create a new panel at the bottom of the screen. When you right click this panel and ask for the properties. You can change the way the panel behaves. The expand checkbox is selected by default. So just uncheck it. And the bottom panel shrinks. The bottom panel now has two dotted areas on the left and right sight of the panel. Clicking and holding down these areas makes it possible to drag the panel across screens.
When the panel is at the right location. Just drop it and check the expand box again. Which results to the image below.
Making PHP mail work on Ubuntu through Postfix
While writing a small mail application in PHP i noticed i couldn’t send mail from my local machine. Even with telnet i couldn’t send out emails. I quickly found out that postfix and sendmail on the same system is not a good idea. Seems it was a left over from some testing i did. So after wiping sendmail and postfix from the system. And reinstalling only postfix i got an error when starting Postfix
postfix: fatal: /etc/postfix/postfix-script: No such file or directory
So let’s try and completely remove the postfix package and purge all files.
$ sudo dpkg –remove postfix
$ sudo dpkg –purge postfix
And a clean install of postfix:
$ sudo apt-get -V install postfix
Now i can telnet in and try to send some mail. And this seemed to work. The mail got delivered.
$ telnet localhost 25
Trying 127.0.0.1…
Connected to localhost.
Escape character is ‘^]’.
220 0×0 ESMTP Postfix (Ubuntu)helo test.nl
250 0×0
mail from: t...@test.nl
250 2.1.0 Ok
rcpt to: some@working.address
250 2.1.5 Ok
data
354 End data with
testing
.
250 2.0.0 Ok: queued as ED97311C412F
So now let’s make sure it also works from PHP. I tested it through a CLI script and through apache2. With the most basic mail script you can imagine.
mail('some@working.address', 'test', 'test message');
The mail however gets bounced.
Jan 7 22:31:48 0×0 postfix/pickup[10249]: 035BF11C4133: uid=1 from=
Jan 7 22:31:48 0×0 postfix/cleanup[11726]: 035BF11C4133: message-id=<20090107213148.035BF11C4133@0x0>
Jan 7 22:31:48 0×0 postfix/qmgr[10250]: 035BF11C4133: from=<dae...@internal.name>, size=303, nrcpt=1 (queue active)
Jan 7 22:31:48 0×0 postfix/smtp[11728]: 035BF11C4133: to=, relay=working.mail.server[xx.xxx.xx.xx]:25, delay=0.68, delays=0.02/0/0.48/0.18, dsn=5.0.0, status=bounced (host working.mail.server[xx.xxx.xx.xx] said: 553 sorry, your envelope sender domain must exist (#5.7.1) (in reply to MAIL FROM command))
Jan 7 22:31:48 0×0 postfix/cleanup[11726]: C5C2911C4134: message-id=<20090107213148.C5C2911C4134@0x0>
Jan 7 22:31:48 0×0 postfix/qmgr[10250]: C5C2911C4134: from=<>, size=2064, nrcpt=1 (queue active)
Jan 7 22:31:48 0×0 postfix/bounce[11729]: 035BF11C4133: sender non-delivery notification: C5C2911C4134
Jan 7 22:31:48 0×0 postfix/qmgr[10250]: 035BF11C4133: removed
Jan 7 22:31:49 0×0 postfix/smtp[11728]: C5C2911C4134: to=<dae...@internal.name>, relay=working.mail.server[xx.xxx.xx.xx]:25, delay=0.75, delays=0.01/0/0.41/0.34, dsn=2.0.0, status=sent (250 ok 1231363909 qp 10204)
Jan 7 22:31:49 0×0 postfix/qmgr[10250]: C5C2911C4134: removed
From looking at the log files i can tell it bounced because the from address is set to dae...@internal.name. And internal.name is not known by my mail server. Let’s try that again. But this time specifically set the FROM header.
$headers .= 'To: Name ' . "\n";
$headers .= 'From: test ' . "\n";
mail('some@working.address', 'test', 'test message', $headers);
The result is the same. The FROM header didn’t change at all. So although it’s possible to set the from header. The message is always send by a system user.. So after doing some research on Google about this problem it seems possible to pass an extra parameter to the mail() function. This parameter can contain a string which will be passed to the postfix binary as an extra parameter. So adding -fsome@orking.address makes the problem go away.
Jan 7 22:36:58 0×0 postfix/pickup[10249]: 687CA11C4133: uid=1 from=
Jan 7 22:36:58 0×0 postfix/cleanup[11847]: 687CA11C4133: message-id=<20090107213658.687CA11C4133@0x0>
Jan 7 22:36:58 0×0 postfix/qmgr[10250]: 687CA11C4133: from=, size=276, nrcpt=1 (queue active)
Jan 7 22:36:59 0×0 postfix/smtp[11849]: 687CA11C4133: to=, relay=working.mail.server[xx.xxx.xx.xx]:25, delay=1.4, delays=0.02/0/0.59/0.76, dsn=2.0.0, status=sent (250 ok 1231364219 qp 10582)
Jan 7 22:36:59 0×0 postfix/qmgr[10250]: 687CA11C4133: removed
But this would mean that i always have to pass the extra parameter. And if i use a third party class or function. i may not be able to do so without hacking the code. So although it solves the problem it’s not the final solution. After i bit of browsing i found out that changing the myorigin parameter in /etc/postfix/main.cf to a known mail server. I could start the send out mail. So i changed it to the domain my mail server runs under.
myorigin = mail.server
And now sending mail from PHP works.
Making permanent changes to resolv.conf under Ubuntu.
At work we have a local dev box. This box is running Ubuntu 8.04 and some tools we need for developing. Nothing special. This box get’s it’s IP address from the DHCP server that runs on the router. And this caused some problems because we are running a local DNS server for the dev box. Mainly to use internal domains for testing.
To make this work we changed the resolv.conf to use the new local DNS server. This works fine wouldn’t it be for Ubuntu changing the file back to it’s original settings on every DHCP request. So every 900 sec the file gets overwritten. To solve this the first time i simply made the file read only. This however caused some problems with the DHCP client requesting an IP address over and over again. This caused the load on the dev box to rise….
Further inspection showed that it’s the dhclient-script the overwrites the resolv.conf file. I tried commenting out parts of the dhclient-script. But this just created more problems. So i did a search on the Ubuntu package list. And found a promising program called resolvconf. This program takes over from resolv.conf. And with this program installed it’s possible to make permanent changes without creating any problems.
After installing the package and doing a search for resolvconf. I found a directory in /etc which had a resolv.conf inside. This seemed to be the template used for overwriting the original resolv.conf. After changing this file all problems were resolved.
/etc/resolvconf/run/resolv.conf
# Dynamic resolv.conf(5) file for glibc resolver(3) generated by resolvconf(8)
# DO NOT EDIT THIS FILE BY HAND — YOUR CHANGES WILL BE OVERWRITTEN
search example.com
domain example.com
nameserver xxx.xxx.x.xx
*Update
After googling some more. I think i found a better way to solve this problem. And probably the only way to solve this. No need to install any extra software. Just edit the dhclient config file.
change the following lines in /etc/dhcp3/dhclient.conf
supersede domain-name “example.com”
prepend domain-name-server xxx.xxx.xxx.1, xxx.xxx.xxx.2









