1

Topic: Passwd problem with batch creating users

==== Required information ====
- iRedMail version:
- Store mail accounts in which backend (LDAP/MySQL/PGSQL):
- Linux/BSD distribution name and version:
- Related log if you're reporting an issue:
======== Required information ====
- iRedMail version: 0.8.5 - iRedAdmin-PRO-MySQL 1.7.0
- Store mail accounts in which backend (LDAP/MySQL/PGSQL): MySQL
- Linux/BSD distribution name and version: Debian 7
- Related log if you're reporting an issue:
====

Based on create_mail_user_SQL.sh script I wrote a php script to read user/pwd from a database and instert them into vmail.mailbox table

here is a part of the script :

while ($row=mysql_fetch_array($res1))
{
$username = $row["username"];
$clear = $row["passwd"];
$domaine = "domain.tld";
$mail = "$username@$domaine";
$stor = "/var/vmail";
$node = "vmail1";

//$pwd = shell_exec("/usr/bin/doveadm pw -s MD5-CRYPT -p $clear");
//$passwd = substr($pwd, 11, 34);

$pwd = shell_exec("openssl passwd -1 $clear");
$passwd = substr($pwd, 0, 34);

$date=date("Y-m-d H:i:s");

$sql3 = "INSERT INTO mailbox (username, password, name, storagebasedirectory,storagenode, maildir, quota, domain, active, local_part, created) 
    VALUES ('$mail', '$passwd', '$username', '$stor', '$node', '$domaine/$username/', '50', '$domaine', '1', '$username', '$date')";
    
$res3 = mysql_query($sql3) or die("Echec Requete SQL ajout utilisateur");
}

My problem is with the passwords ... as you can see I've tried two different ways.
They look good starting with $1$ and 34 char lengh ... but they're not working when I try to authenticate
What am I doing wrong ?

----

Spider Email Archiver: On-Premises, lightweight email archiving software developed by iRedMail team. Supports Amazon S3 compatible storage and custom branding.

2

Re: Passwd problem with batch creating users

It's getting worse (for my nerves !)
When I do it by hand on a terminal

openssl passwd -1 testing123
$1$eWLR5xSm$TCBoAJ7QLZNA8i0g53njJ0

If I copy/paste the result in the MySQL table ... tada ! it works ^_^
So I just can't understand why it's not working with my script

If anyone can help that'll be awesome !

Thank you

3

Re: Passwd problem with batch creating users

b.cherrier wrote:

$pwd = shell_exec("openssl passwd -1 $clear");
$passwd = substr($pwd, 0, 34);

Not sure whether substr() matters here.
Why not simply print it to terminal for debugging?

P.S. I'm not a PHP programmer, not sure

4

Re: Passwd problem with batch creating users

the substr() is to remove the line carriage.
The result is :

INSERT INTO mailbox (username, password, name, storagebasedirectory,storagenode, maildir, quota, domain, active, local_part, created) VALUES ('boitemail@domaine.tld', '$1$dLiMN3MS$f65K6y92AOEYR.DYD4eGN0', 'boitemail', '/var/vmail', 'vmail1', 'domaine.tld/boitemail/', '50', 'domaine.tld', '1', 'boitemail', '2013-10-30 11:08:10');

It should work ... but it doesn't sad

5

Re: Passwd problem with batch creating users

Ok my bad, the customer who gave me the login/pwd list has put a space at the end of certain enties ...
Sorry for the noise, and thanks again for your great product !!