Skip to content

Commit

Permalink
Merge pull request sipcapture#128 from dancapper/master
Browse files Browse the repository at this point in the history
Allow Unix Socket to be configured for MySQL in maintenance scripts, and use by default. Also replace split() with explode() in LDAP.php for PHP7.0 compatibility.
  • Loading branch information
adubovikov authored Oct 19, 2016
2 parents 1b9e759 + 7f22b6f commit 5c610ed
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 19 deletions.
9 changes: 2 additions & 7 deletions api/Authentication/LDAP.php
Original file line number Diff line number Diff line change
Expand Up @@ -112,13 +112,10 @@ function logIn($param) {
$_SESSION['username'] = $user['username'];
$_SESSION['gid'] = $user['gid'];
$_SESSION['grp'] = "users";

$_SESSION['data'] = $user;



// Assigne Admin Privs, should be read from the LDAP Directory in the future
$ADMIN_USER = split(",", LDAP_ADMIN_USER);
// Assign Admin Privs, should be read from the LDAP Directory in the future
$ADMIN_USER = explode(",", LDAP_ADMIN_USER);
foreach($ADMIN_USER as &$value) {

if ($value == $param['username']) {
Expand All @@ -132,7 +129,6 @@ function logIn($param) {
}
}
}

return array();
}

Expand Down Expand Up @@ -176,7 +172,6 @@ function getUser() {
return $_SESSION['data'];
}


//create random password with 8 alphanumerical characters

function createPassword() {
Expand Down
15 changes: 10 additions & 5 deletions scripts/homer_mysql_remove_partitions.pl
Original file line number Diff line number Diff line change
Expand Up @@ -158,10 +158,15 @@ sub read_config {
}

sub db_connect {
my $CONFIG = shift;
my $db_name = shift;

my $db = DBI->connect("DBI:mysql:".$CONFIG->{"MYSQL"}{$db_name}.":".$CONFIG->{"MYSQL"}{"host"}.":".$CONFIG->{"MYSQL"}{"port"}, $CONFIG->{"MYSQL"}{"user"}, $CONFIG->{"MYSQL"}{"password"});
return $db;
my $CONFIG = shift;
my $db_name = shift;
my $dbistring = "";
if($CONFIG->{"MYSQL"}{"usesocket"}) {
$dbistring = "DBI:mysql:database=".$CONFIG->{"MYSQL"}{$db_name}.";mysql_socket=".$CONFIG->{"MYSQL"}{"socket"}
} else {
$dbistring = "DBI:mysql:".$CONFIG->{"MYSQL"}{$db_name}.":".$CONFIG->{"MYSQL"}{"host"}.":".$CONFIG->{"MYSQL"}{"port"}
}
my $db = DBI->connect($dbistring, $CONFIG->{"MYSQL"}{"user"}, $CONFIG->{"MYSQL"}{"password"});
return $db;
}

10 changes: 7 additions & 3 deletions scripts/homer_mysql_rotate.pl
Original file line number Diff line number Diff line change
Expand Up @@ -207,10 +207,14 @@ END
sub db_connect {
my $CONFIG = shift;
my $db_name = shift;

my $db = DBI->connect("DBI:mysql:".$CONFIG->{"MYSQL"}{$db_name}.":".$CONFIG->{"MYSQL"}{"host"}.":".$CONFIG->{"MYSQL"}{"port"}, $CONFIG->{"MYSQL"}{"user"}, $CONFIG->{"MYSQL"}{"password"});
my $dbistring = "";
if($CONFIG->{"MYSQL"}{"usesocket"}) {
$dbistring = "DBI:mysql:database=".$CONFIG->{"MYSQL"}{$db_name}.";mysql_socket=".$CONFIG->{"MYSQL"}{"socket"}
} else {
$dbistring = "DBI:mysql:".$CONFIG->{"MYSQL"}{$db_name}.":".$CONFIG->{"MYSQL"}{"host"}.":".$CONFIG->{"MYSQL"}{"port"}
}
my $db = DBI->connect($dbistring, $CONFIG->{"MYSQL"}{"user"}, $CONFIG->{"MYSQL"}{"password"});
return $db;

}

sub calculate_gmt_offset {
Expand Down
10 changes: 6 additions & 4 deletions scripts/rotation.ini
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
#Rotation parameters

[MYSQL]
user=homer_user
password=homer_password
host=localhost
port=3306
user = homer_user
password = homer_password
host = localhost
port = 3306
usesocket = 1
socket = /var/run/mysqld/mysqld.sock
db_data = homer_data
db_stats = homer_statistic
# Extra param
Expand Down

0 comments on commit 5c610ed

Please sign in to comment.