Use FreeSWITCH to run mkdir so it inherits its own user and group permissions.
This commit is contained in:
@@ -1956,4 +1956,28 @@ function number_pad($number,$n) {
|
||||
}
|
||||
}
|
||||
|
||||
function event_socket_mkdir($dir) {
|
||||
//if the handle does not exist create it
|
||||
$fp = event_socket_create($_SESSION['event_socket_ip_address'], $_SESSION['event_socket_port'], $_SESSION['event_socket_password']);
|
||||
if (!$fp) {
|
||||
return false;
|
||||
}
|
||||
//send the mkdir command to freeswitch
|
||||
if ($fp) {
|
||||
//send the api command to check if the module exists
|
||||
$switch_cmd = "system mkdir -p '$dir'";
|
||||
$switch_result = event_socket_request($fp, 'api '.$switch_cmd);
|
||||
unset($switch_cmd);
|
||||
if (trim($switch_result) == "-ERR no reply") {
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
@@ -942,12 +942,12 @@ function save_dialplan_xml() {
|
||||
$dialplan_filename = $dialplan_order."_v_".$dialplan_name.".xml";
|
||||
if (strlen($row['dialplan_context']) > 0) {
|
||||
if (!is_dir($_SESSION['switch']['dialplan']['dir']."/".$row['dialplan_context'])) {
|
||||
mkdir($_SESSION['switch']['dialplan']['dir']."/".$row['dialplan_context'],02770,true);
|
||||
event_socket_mkdir($_SESSION['switch']['dialplan']['dir']."/".$row['dialplan_context']);
|
||||
}
|
||||
if ($row['dialplan_context'] == "public") {
|
||||
if (count($_SESSION['domains']) > 1 && strlen($row['domain_uuid']) > 0) {
|
||||
if (!is_dir($_SESSION['switch']['dialplan']['dir']."/public/".$_SESSION['domains'][$row['domain_uuid']]['domain_name'])) {
|
||||
mkdir($_SESSION['switch']['dialplan']['dir']."/public/".$_SESSION['domains'][$row['domain_uuid']]['domain_name'],02770,true);
|
||||
event_socket_mkdir($_SESSION['switch']['dialplan']['dir']."/public/".$_SESSION['domains'][$row['domain_uuid']]['domain_name']);
|
||||
}
|
||||
file_put_contents($_SESSION['switch']['dialplan']['dir']."/public/".$_SESSION['domains'][$row['domain_uuid']]['domain_name']."/".$dialplan_filename, $tmp);
|
||||
}
|
||||
@@ -957,7 +957,7 @@ function save_dialplan_xml() {
|
||||
}
|
||||
else {
|
||||
if (!is_dir($_SESSION['switch']['dialplan']['dir']."/".$row['dialplan_context'])) {
|
||||
mkdir($_SESSION['switch']['dialplan']['dir']."/".$row['dialplan_context'],02770,true);
|
||||
event_socket_mkdir($_SESSION['switch']['dialplan']['dir']."/".$row['dialplan_context']);
|
||||
}
|
||||
file_put_contents($_SESSION['switch']['dialplan']['dir']."/".$row['dialplan_context']."/".$dialplan_filename, $tmp);
|
||||
}
|
||||
@@ -1334,7 +1334,7 @@ if (!function_exists('save_sip_profile_xml')) {
|
||||
|
||||
// make profile dir if needed
|
||||
$profile_dir = $_SESSION['switch']['conf']['dir']."/sip_profiles";
|
||||
if (!is_readable($profile_dir)) { mkdir($profile_dir,02770,true); }
|
||||
if (!is_readable($profile_dir)) { event_socket_mkdir($profile_dir); }
|
||||
|
||||
//get the global variables
|
||||
global $domain_uuid;
|
||||
@@ -1399,7 +1399,7 @@ if (!function_exists('save_sip_profile_xml')) {
|
||||
}
|
||||
|
||||
//if the directory does not exist then create it
|
||||
if (!is_readable($profile_dir.'/'.$sip_profile_name)) { mkdir($profile_dir.'/'.$sip_profile_name,02770,true); }
|
||||
if (!is_readable($profile_dir.'/'.$sip_profile_name)) { event_socket_mkdir($profile_dir.'/'.$sip_profile_name); }
|
||||
|
||||
} //end foreach
|
||||
unset($sql, $result, $row_count);
|
||||
|
||||
Reference in New Issue
Block a user