Roundcube Community Forum

 

virtuser_file issues

Started by bigmeow, January 20, 2007, 08:04:28 AM

Previous topic - Next topic

bigmeow

I just started playing with roundcube tonight. Very slick.

We make extensive use of virtusertable. So here is what I found. I'm using 0.1-beta2 that is posted. I'm running it on really old stuff. mysql5, but old php and apache.

1) Doesn't work in php safe mode. This probably should be noted in the config. Any site that needs to use virtuser_file probably should also be using safe mode. I'm making a copy for it to use.

2) user2email identities is only done when creating a new user.
It should be done at every login. If virtuser_file is enabled, it should override or at least be synced with what is in identities.

3) user2email pattern catches Xpattern. It needs a boundary in the front.

4) user2email only finds the first email and discards the rest. Need
them all and create identities for them all.

5) In our situation, and others may have this also, the entry in virtusertable is an fqdn hostname - but we want only the domain name in the identity. For example, virtusertable lists "[email protected] joe." When joe is created, we want the identity to be "[email protected]" not "[email protected]."

What follows is a diff between the distribution programs/include/main.inc (identified as 429) and my changes to address numbers 3,4,5 above for my testing puposes. Note the addition of virtuser_nohost config.

184d183
<
550c549
< $user_email = '';
---
> $user_email = array();
554a554,556
>
> if ($user_email[0]=='')
>  $user_email[0] = &quot;$user@$host&quot;;
561c563
<       $user_email,
---
>       $user_email[0],
575c577
<  if ($user_email=='')
---
>  if ($user_email[0]=='')
578c580
<  $user_name = $user!=$user_email ? $user : '';
---
>  $user_name = $user!=$user_email[0] ? $user : '';
585c587
<    $user_email = $sql_arr[0];
---
>    $user_email = $sql_arr;
589c591
<  $DB->query(&quot;INSERT INTO &quot;.get_table_name('identities').&quot;
---
>   $DB->query(&quot;INSERT INTO &quot;.get_table_name('identities').&quot;
594,595c596,603
<        $user_email);
<
---
>        $user_email[0]);
>   for ($i=1; $i<count($user_email); $i++)
>     $DB->query(&quot;INSERT INTO &quot;.get_table_name('identities').&quot;
>        (user_id, del, standard, name, email)
>        VALUES (?, 0, 0, ?, ?)&quot;,
>        $user_id,
>        $user_name,
>        $user_email[$i]);
641a650
>   {
642a652
>   }
673,675c683,687
< $email = &quot;&quot;;
< $r = rcmail_findinvirtual(&quot;$user$&quot;);
<
---
> global $CONFIG;
> $email = array();
> $r = rcmail_findinvirtual(&quot;[[:space:]]$user$&quot;);
> if (isset($CONFIG['virtuser_nohost']))
>  $h = $CONFIG['virtuser_nohost'];
681,684c693,699
<   {
<   $email = trim($arr[0]);
<   break;
<   }
---
>   if (isset($CONFIG['virtuser_nohost']))
>    for ($n=0; $n<count($h); $n++)
>     {
>     $pat = &quot;@$h[$n]\.&quot;;
>     $arr[0] = ereg_replace($pat,'@',$arr[0]);
>     }
>   $email&#91;] = trim($arr[0]);