Go Back   HowtoForge Forums | HowtoForge - Linux Howtos and Tutorials > Linux Forums > HOWTO-Related Questions

Do you like HowtoForge? Please consider supporting us by becoming a subscriber.
Reply
 
Thread Tools Display Modes
  #1  
Old 6th April 2008, 05:10
asyadiqin asyadiqin is offline
Senior Member
 
Join Date: Jul 2006
Posts: 120
Thanks: 0
Thanked 1 Time in 1 Post
Default PostfixAdmin Cannot Create Maildir

Hi,

I followed the tutorial "Virtual Users With Postfix, PostfixAdmin, Courier, Mailscanner, ClamAV On CentOS" and PostfixAdmin seems to work fine.

However, there seems to be a problem when I added the scripts to add/delete the mailboxes. The script are as follows

Quote:
#!/bin/bash
set -e
mail_home="/opt/mail"
if [ ! -d $mail_home/$1 ] ; then
mkdir $mail_home/$1
chown -R vmail:vmail $mail_home/$1
chmod -R 700 $mail_home/$1
echo "$mail_home/$1 CREATED"
fi
if [ -d $mail_home/$1 ] ; then
cd "$mail_home/$1"
maildirmake $2
echo "$mail_home/$1/$2 CREATED"
maildirmake -q "$3S" $2
echo "$3S $2 QUOTA CREATED"
chown -R vmail:vmail $mail_home/$1/$2
chmod -R 700 $mail_home/$1/$2
fi
Running the script on the commandline works fine but when I run it in PostfixAdmin, no folders was created at all. This is how PostfixAdmin called the script

Quote:
system("sudo /usr/sbin/maildirmake.sh ".$fDomain." ".$fUsername. " ". $quota);
I know that the script was run as apache and I have added apache to the sudoers file, but somehow, its still not creating the mail folders. No error was return at all.

Can someone please tell me what could be the problem. I have tried all permissions, even 777 but still nothing. Can someone please help me. Thanks.
Reply With Quote
Sponsored Links
  #2  
Old 7th April 2008, 17:51
falko falko is offline
Super Moderator
 
Join Date: Apr 2005
Location: Lüneburg, Germany
Posts: 41,701
Thanks: 1,900
Thanked 2,741 Times in 2,575 Posts
Default

What happens when you run the script as the Apache user on the shell?
__________________
Falko
--
Download the ISPConfig 3 Manual! | Check out the ISPConfig 3 Billing Module!

FB: http://www.facebook.com/howtoforge

nginx-Webhosting: Timme Hosting | Follow me on:
Reply With Quote
  #3  
Old 7th April 2008, 18:46
asyadiqin asyadiqin is offline
Senior Member
 
Join Date: Jul 2006
Posts: 120
Thanks: 0
Thanked 1 Time in 1 Post
Default

I have no idea how to run the script or anything as user apache. How can I do this? I tried su apache and it gave me an error.
Reply With Quote
  #4  
Old 8th April 2008, 10:05
falko falko is offline
Super Moderator
 
Join Date: Apr 2005
Location: Lüneburg, Germany
Posts: 41,701
Thanks: 1,900
Thanked 2,741 Times in 2,575 Posts
Default

What error?
Is apache the Apache user? Take a look at your Apache configuration to find out who's the Apache user.
__________________
Falko
--
Download the ISPConfig 3 Manual! | Check out the ISPConfig 3 Billing Module!

FB: http://www.facebook.com/howtoforge

nginx-Webhosting: Timme Hosting | Follow me on:
Reply With Quote
  #5  
Old 8th April 2008, 10:14
asyadiqin asyadiqin is offline
Senior Member
 
Join Date: Jul 2006
Posts: 120
Thanks: 0
Thanked 1 Time in 1 Post
Default

Apache is running as user and group apache. I have tried testing some by creating a page and adding the following :-

Quote:
system('ls -la');
system('whoami');
Both gave me the right results. But putting the command to run the scripts are just not working and I get no errors at all. I even added apache to the sudoers file with full access to see it that works but still doesn't work.

Quote:
apache ALL=(ALL) NOPASSWD: ALL
I don't know what else could be wrong. As far as I know, the scripts work as I am able to do it in the commandline. So I'm still confused about this.
Reply With Quote
  #6  
Old 8th April 2008, 13:04
topdog topdog is offline
Senior Member
 
Join Date: Jan 2008
Location: South Africa
Posts: 1,352
Thanks: 0
Thanked 153 Times in 150 Posts
Default

Thats not very prudent. It means when you apache is compromised then the attacker can run any command on your system without requiring a password
__________________
----
http://www.topdog.za.net - Got Linux problems ? - I can help.
http://www.baruwa.org - Try it.
Reply With Quote
  #7  
Old 8th April 2008, 18:12
asyadiqin asyadiqin is offline
Senior Member
 
Join Date: Jul 2006
Posts: 120
Thanks: 0
Thanked 1 Time in 1 Post
Default

Quote:
Originally Posted by topdog
Thats not very prudent. It means when you apache is compromised then the attacker can run any command on your system without requiring a password
I know. Its merely for me to test. But still it doesn't work. I've removed that from the sudoers file as soon as I know it doesn't work.

What else could be the problem? Anyone have similar issues installing the current version of PostfixAdmin?
Reply With Quote
  #8  
Old 9th April 2008, 11:02
topdog topdog is offline
Senior Member
 
Join Date: Jan 2008
Location: South Africa
Posts: 1,352
Thanks: 0
Thanked 153 Times in 150 Posts
Default

Are you sure the variables you are passing from php are actually getting to the shell script ?

Add a debug section at the top to echo the values to a temp file and see if the shell script actually got the values.
__________________
----
http://www.topdog.za.net - Got Linux problems ? - I can help.
http://www.baruwa.org - Try it.
Reply With Quote
  #9  
Old 9th April 2008, 11:12
asyadiqin asyadiqin is offline
Senior Member
 
Join Date: Jul 2006
Posts: 120
Thanks: 0
Thanked 1 Time in 1 Post
Default

Quote:
Originally Posted by topdog
Are you sure the variables you are passing from php are actually getting to the shell script ?

Add a debug section at the top to echo the values to a temp file and see if the shell script actually got the values.
Yes. I did test it before as follows

Quote:
$command = "sudo /usr/sbin/maildirmake.sh ".$fDomain." ".$fUsername. " ". $quota;
echo $command;
system($command);
echo system(whoami);
I can see the command on the browser, and it shows that it was running as user 'apache' but the directory is still not created. Any ideas?
Reply With Quote
  #10  
Old 9th April 2008, 11:18
topdog topdog is offline
Senior Member
 
Join Date: Jan 2008
Location: South Africa
Posts: 1,352
Thanks: 0
Thanked 153 Times in 150 Posts
 
Default

Thats not what i mean am talking of the shell not php

something like

echo "$1 -> $2 -> $3" >> /tmp/shell-test

inside /usr/sbin/maildirmake.sh
__________________
----
http://www.topdog.za.net - Got Linux problems ? - I can help.
http://www.baruwa.org - Try it.
Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
debian etch courier pop3 issue docean Installation/Configuration 6 20th March 2008 15:38
www-data and maildir nzimas Installation/Configuration 3 13th September 2007 18:28
maildir delivery failed: create ... ? tom Server Operation 5 12th April 2007 16:24
Chroot SSH + ISPConfig Norman Installation/Configuration 27 26th March 2007 03:40
Chrooted SSH apps bkrausz Tips/Tricks/Mods 14 29th August 2006 23:32


All times are GMT +2. The time now is 02:05.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2014, vBulletin Solutions, Inc.