[freeside-commits] freeside/bin mapsecrets2access_user,NONE,1.1
Ivan,,,
ivan at wavetail.420.am
Mon Jun 19 04:57:41 PDT 2006
Update of /home/cvs/cvsroot/freeside/bin
In directory wavetail:/tmp/cvs-serv15984/bin
Added Files:
mapsecrets2access_user
Log Message:
ACL bootstrapping/upgrade
--- NEW FILE: mapsecrets2access_user ---
#!/usr/bin/perl -w
use strict;
use File::Copy "cp";
use FS::UID qw(adminsuidsetup);
use FS::AccessRight;
use FS::Record qw(qsearchs qsearch);
use FS::access_group;
use FS::access_user;
use FS::access_usergroup;
use FS::access_right;
use FS::access_groupagent;
use FS::agent;
adminsuidsetup shift;
my $supergroup = qsearchs('access_group', { 'groupname' => 'Superuser' } );
unless ( $supergroup ) {
$supergroup = new FS::access_group { 'groupname' => 'Superuser' };
my $error = $supergroup->insert;
die $error if $error;
foreach my $rightname ( FS::AccessRight->rights ) {
my $access_right = new FS::access_right {
'righttype' => 'FS::access_group',
'rightobjnum' => $supergroup->groupnum,
'rightname' => $rightname,
};
my $ar_error = $access_right->insert;
die $ar_error if $ar_error;
}
foreach my $agent ( qsearch('agent', {} ) ) {
my $access_groupagent = new FS::access_groupagent {
'groupnum' => $supergroup->groupnum,
'agentnum' => $agent->agentnum,
};
my $aga_error = $access_groupagent->insert;
die $aga_error if $aga_error;
}
}
my $supergroupnum = $supergroup->groupnum;
my $mapsecrets = '/usr/local/etc/freeside/mapsecrets';
open(MAPSECRETS, "<$mapsecrets");
while (<MAPSECRETS>) {
/([\w]+)\s+secrets\s*$/ or die "unparsable line in mapsecrets: $_";
my $username = $1;
next if qsearchs('access_user', { 'username' => $username } );
my $access_user = new FS::access_user {
'username' => $username,
'_password' => 'notyet',
'first' => 'Legacy',
'last' => 'User',
};
my $au_error = $access_user->insert;
die $au_error if $au_error;
my $access_usergroup = new FS::access_usergroup {
'usernum' => $access_user->usernum,
'groupnum' => $supergroupnum,
};
my $aug_error = $access_usergroup->insert;
die $aug_error if $aug_error;
}
# okay to clobber mapsecrets now i guess
cp $mapsecrets, "$mapsecrets.bak$$";
open(MAPSECRETS, ">$mapsecrets");
print MAPSECRETS '* secrets'. "\n";
close MAPSECRETS;
More information about the freeside-commits
mailing list