parent
ec322a8b7a
commit
7192c3dc4c
5 changed files with 76 additions and 0 deletions
@ -0,0 +1 @@ |
||||
ajaxplorer |
@ -0,0 +1 @@ |
||||
ajaxplorer |
@ -0,0 +1,27 @@ |
||||
{ |
||||
my $rec = $DB->get('ajaxplorer') |
||||
|| $DB->new_record('ajaxplorer', {type => 'webapp'}); |
||||
my $pw = $rec->prop('DbPassword'); |
||||
if (not $pw or length($pw) < 57){ |
||||
use MIME::Base64 qw(encode_base64); |
||||
|
||||
$pw = "not set due to error"; |
||||
if ( open( RANDOM, "/dev/urandom" ) ){ |
||||
my $buf; |
||||
# 57 bytes is a full line of Base64 coding, and contains |
||||
# 456 bits of randomness - given a perfectly random /dev/random |
||||
if ( read( RANDOM, $buf, 57 ) != 57 ){ |
||||
warn("Short read from /dev/random: $!"); |
||||
} |
||||
else{ |
||||
$pw = encode_base64($buf); |
||||
chomp $pw; |
||||
} |
||||
close RANDOM; |
||||
} |
||||
else{ |
||||
warn "Could not open /dev/urandom: $!"; |
||||
} |
||||
$rec->set_prop('DbPassword', $pw); |
||||
} |
||||
} |
@ -0,0 +1,46 @@ |
||||
{ |
||||
my $db = ${'ajaxplorer'}{'DbName'} || 'ajaxplorer'; |
||||
my $user = ${'ajaxplorer'}{'DbUser'} || 'ajaxplorer'; |
||||
my $pass = ${'ajaxplorer'}{'DbPassword'} || 'secret'; |
||||
|
||||
my $feed = "/usr/share/ajaxplorer/plugins/feed.sql/create.sql"; |
||||
|
||||
$OUT .= <<"END"; |
||||
#! /bin/sh |
||||
if [ ! -d /var/lib/mysql/$db ]; then |
||||
/usr/bin/mysql -e 'create database $db' |
||||
/usr/bin/mysql $db < $feed |
||||
fi |
||||
|
||||
/usr/bin/mysql <<EOF |
||||
USE mysql; |
||||
|
||||
REPLACE INTO user ( |
||||
host, |
||||
user, |
||||
password) |
||||
VALUES ( |
||||
'localhost', |
||||
'$user', |
||||
PASSWORD ('$pass')); |
||||
|
||||
|
||||
REPLACE INTO db ( |
||||
host, |
||||
db, |
||||
user, |
||||
select_priv, insert_priv, update_priv, delete_priv, |
||||
create_priv, alter_priv, index_priv, drop_priv, create_tmp_table_priv, |
||||
grant_priv, lock_tables_priv, references_priv) |
||||
VALUES ( |
||||
'localhost', |
||||
'$db', |
||||
'$user', |
||||
'Y', 'Y', 'Y', 'Y', |
||||
'Y', 'Y', 'Y', 'Y', 'Y', |
||||
'N', 'Y', 'Y'); |
||||
|
||||
FLUSH PRIVILEGES; |
||||
EOF |
||||
END |
||||
} |
Loading…
Reference in new issue