Looks good to me .. of course, the only way to be sure is to actually run it :-)

 - Jamie

On 31/Oct/2008 15:02 Grant Peel wrote ..

Jamie,
 
Thanks a bunch, things appear to work now. In the module, the code was change from the commented (#) lines to the ones you suggested. Does this look right to you then?
 
 
...
#&read_file("$config{'usermin_mysql_dir'}/config", \%mconfig);
#$mconfig{'access'} .= "\t$in{'user'}: $db";
#&write_file("$config{'usermin_mysql_dir'}/config", \%mconfig);
 
&read_file("$config{'usermin_mysql_dir'}/config", \%mconfig);
 
if ($mconfig{'access'} =~ /$in{'user'}:/) {
  $mconfig{'access'} =~ s/$in{'user'}:/$in{'user'}: $db/;
  }
else {
  $mconfig{'access'} .= "\t$in{'user'}: $db";
}
 
&write_file("$config{'usermin_mysql_dir'}/config", \%mconfig);
...
 
-Grant
 
----- Original Message -----
From: Jamie Cameron
To: Grant Peel ; Webmin users list
Sent: Friday, October 31, 2008 1:55 PM
Subject: Re: [webmin-l] Database Permissions in Usermin

On 31/Oct/2008 04:04 Grant Peel wrote ..
All,
 
I have a custom Webmin mondule written that add a new musql database, sets the mysql permissions etc and it works well, except that it does not add the Usermin permissions correctly.
 
Here is the code:
 
&read_file("$config{'usermin_mysql_dir'}/config", \%mconfig);
$mconfig{'access'} .= "\t$in{'user'}: $db";
&write_file("$config{'usermin_mysql_dir'}/config", \%mconfig);
 
When I look in Usermin Configuration -> Usermin Module Configuration -> MySQL Database, the "Database Access control list is getting completely new entries put in them, when it should be appended.
 
Current:
 
user: database1 database2
 
But what I am getting is:
 
user: database1
user: database2
 
Can the above perl/regex be adjust to do it correctly?

Yes .. you should use code like :

if ($mconfig{'access'} =~ /$in{'user'}:/) {
 
$mconfig{'access'} =~ s/$in{'user'}:/$in{'user'}: $db/;
  }
else {
  $mconfig{'access'} .= "\t$in{'user'}: $db";
}

 - Jamie


 

-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/


 

-
Forwarded by the Webmin mailing list at webadmin-list@lists.sourceforge.net
To remove yourself from this list, go to
http://lists.sourceforge.net/lists/listinfo/webadmin-list