Selecting auto-create maildirs produces error: Could not make user maildir
gabrielinux - January 3, 2009 - 06:15
| Project: | cryptpw |
| Version: | 6.x-2.x-dev |
| Component: | Miscellaneous |
| Category: | support request |
| Priority: | normal |
| Assigned: | pillarsdotnet |
| Status: | active |
Jump to:
Description
I am using PHP5 and Drupal 6. I configured the module with all the defaults (UID=99, GUID=99, etc.). Although my maildir has rwx permissions for owner, group and other, this module can't create the maildir files for each user. It can create the folder with the user's ID with no problems (e.g., 1) but then it doesn't have permissions to create directories inside. I think the problem is that the module is creating directories with only user rwx permissions, but since the UID is 99 (nobody), it can't touch it after that.
Help?

#1
After reading the documentation for the mkdir() function, it seems servers with safe_mode on need a tweak around the mkdir() call. Before callking mkdir(), you need to temporarily set umask to zero using umask(0). I revised the code of the _cryptpw_maildirmake() function as follows, and it fixed the problem:
function _cryptpw_maildirmake($maildir) {foreach(array('cur','new','tmp') as $d) {
$old_umask = umask(0);
if (!mkdir("$maildir/$d",0700,TRUE)) {
drupal_set_message(
t('Could not create directory %d.',
array('%d'=>"$maildir/$d")
)
);
umask($oldumask);
return FALSE;
}
}
}
You might want to include this in the next release....
Regards,
Gabriel Monge-Franco
Security+ Certified Professional
http://gabriel.mongefranco.com
#2
Thanks. I'll be releasing an updated version shortly.
#3