本文整理汇总了PHP中FreePBX::GPG方法的典型用法代码示例。如果您正苦于以下问题:PHP FreePBX::GPG方法的具体用法?PHP FreePBX::GPG怎么用?PHP FreePBX::GPG使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FreePBX
的用法示例。
在下文中一共展示了FreePBX::GPG方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: updateSignature
/**
* Update gpg Signature check for a single module
* @param {string} $modulename Raw Module Name
*/
public function updateSignature($modulename)
{
try {
$mod = FreePBX::GPG()->verifyModule($modulename);
$revoked = $mod['status'] & GPG::STATE_REVOKED;
//if revoked then disable
if ($revoked) {
$this->disable($modulename);
}
$sql = "UPDATE `modules` SET signature = ? WHERE modulename = ?";
$sth = FreePBX::Database()->prepare($sql);
$sth->execute(array(json_encode($mod), $modulename));
} catch (\Exception $e) {
$mod = null;
}
return $mod;
}
示例2: refreshsignatures
private function refreshsignatures()
{
\FreePBX::GPG();
$fpbxmodules = \FreePBX::Modules();
$list = $fpbxmodules->getActiveModules();
$this->writeln(_("Getting Data from Online Server..."));
$modules_online = $this->mf->getonlinexml();
if (empty($modules_online)) {
$this->writeln(_('Cant Reach Online Server'));
exit(1);
} else {
$this->writeln(_("Done"));
}
$this->writeln(_("Checking Signatures of Modules..."));
foreach ($list as $m) {
//Check signature status, then if its online then if its signed online then redownload (through force)
$this->writeln(sprintf(_("Checking %s..."), $m['rawname']));
if (isset($m['signature']['status']) && ~$m['signature']['status'] & \FreePBX\GPG::STATE_GOOD) {
$this->writeln(_("Signature Invalid"));
if (isset($modules_online[$m['rawname']]) && isset($modules_online[$m['rawname']]['signed'])) {
$this->writeln("\t" . sprintf(_("Refreshing %s"), $m['rawname']));
$modulename = $m['rawname'];
$modules = $fpbxmodules->getinfo($modulename);
$this->doUpgrade($modulename, true);
$this->writeln("\t" . _("Verifying GPG..."));
$this->mf->updateSignature($modulename);
$this->writeln(_("Done"));
} else {
$this->writeln("\t" . _("Could not find signed module on remote server!"), "error", false);
}
} else {
$this->writeln(_("Good"));
}
}
$this->writeln(_("Done"));
}
示例3: switch
break;
case MODULE_STATUS_DISABLED:
$headerclass .= ' disabled';
break;
case MODULE_STATUS_ENABLED:
$headerclass .= ' enabled';
break;
case MODULE_STATUS_NEEDUPGRADE:
$headerclass .= ' needupgrade';
break;
case MODULE_STATUS_BROKEN:
$headerclass .= ' broken';
break;
}
if (FreePBX::Config()->get('SIGNATURECHECK')) {
FreePBX::GPG();
if (!empty($modules[$name]['signature']) && is_int($modules[$name]['signature']['status']) && ~$modules[$name]['signature']['status'] & \FreePBX\GPG::STATE_GOOD) {
switch (true) {
case $modules[$name]['signature']['status'] & \FreePBX\GPG::STATE_TAMPERED:
$headerclass .= " tampered";
$module_display[$category]['data'][$name]['signature']['message'] = _("Module has been tampered. Please redownload");
break;
case $modules[$name]['signature']['status'] & \FreePBX\GPG::STATE_UNSIGNED:
$headerclass .= " unsigned";
$module_display[$category]['data'][$name]['signature']['message'] = _("Module is Unsigned");
break;
case $modules[$name]['signature']['status'] & \FreePBX\GPG::STATE_INVALID:
$headerclass .= " invalid";
$module_display[$category]['data'][$name]['signature']['message'] = _("Module has been signed with an invalid key");
break;
case $modules[$name]['signature']['status'] & \FreePBX\GPG::STATE_REVOKED:
示例4: execute
//.........这里部分代码省略.........
foreach ($matches[1] as $include) {
if (!file_exists($amp_conf['ASTETCDIR'] . "/" . $include)) {
touch($amp_conf['ASTETCDIR'] . "/" . $include);
}
}
}
}
}
$output->writeln("Done");
//File variable replacement
$rfiles = array($amp_conf['ASTETCDIR'] . "/manager.conf", $amp_conf['ASTETCDIR'] . "/cdr_adaptive_odbc.conf", ODBC_INI);
$output->write("Running variable replacement...");
foreach ($rfiles as $file) {
if (!file_exists($file) || !is_writable($file)) {
continue;
}
$conf = file_get_contents($file);
$replace = array('AMPMGRUSER' => $amp_conf['AMPMGRUSER'], 'AMPMGRPASS' => $amp_conf['AMPMGRPASS'], 'CDRDBNAME' => $amp_conf['CDRDBNAME'], 'AMPDBUSER' => $amp_conf['AMPDBUSER'], 'AMPDBPASS' => $amp_conf['AMPDBPASS']);
$conf = str_replace(array_keys($replace), array_values($replace), $conf);
file_put_contents($file, $conf);
}
$output->writeln("Done");
//setup and get manager working
$output->write("Setting up Asterisk Manager Connection...");
exec("sudo -u " . $answers['user'] . " asterisk -rx 'module reload manager'", $o, $r);
if ($r !== 0) {
$output->writeln("<error>Unable to reload Asterisk Manager</error>");
exit(127);
}
//TODO: we should check to make sure manager worked at this stage..
$output->writeln("Done");
$output->writeln("Running through upgrades...");
// Upgrade framework (upgrades/ dir)
$installer->install_upgrades($version);
$output->writeln("Finished upgrades");
$fwxml = simplexml_load_file($this->rootPath . '/module.xml');
//setversion to whatever is in framework.xml forever for here on out.
$fwver = (string) $fwxml->version;
$output->write("Setting FreePBX version to " . $fwver . "...");
$installer->set_version($fwver);
$output->writeln("Done");
$output->write("Writing out " . AMP_CONF . "...");
if (!file_put_contents(AMP_CONF, $freepbx_conf->amportal_generate(true))) {
$output->writeln("<error>Error!</error>");
$output->writeln("<error>Unable to write to file</error>");
exit(1);
}
$output->writeln("Done");
if ($newinstall) {
/* Write freepbx.conf */
$conf = "<?php\n\$amp_conf['AMPDBUSER'] = '{$amp_conf['AMPDBUSER']}';\n\$amp_conf['AMPDBPASS'] = '{$amp_conf['AMPDBPASS']}';\n\$amp_conf['AMPDBHOST'] = '{$amp_conf['AMPDBHOST']}';\n\$amp_conf['AMPDBNAME'] = '{$amp_conf['AMPDBNAME']}';\n\$amp_conf['AMPDBENGINE'] = '{$amp_conf['AMPDBENGINE']}';\n\$amp_conf['datasource'] = ''; //for sqlite3\n\nrequire_once('{$amp_conf['AMPWEBROOT']}/admin/bootstrap.php');\n";
$output->write("Writing out " . FREEPBX_CONF . "...");
if (!file_put_contents(FREEPBX_CONF, $conf)) {
$output->writeln("<error>Error!</error>");
$output->writeln("<error>Unable to write to file</error>");
exit(1);
}
$output->writeln("Done");
}
//run this here so that we make sure everything is square for asterisk
passthru($amp_conf['AMPSBIN'] . "/fwconsole chown");
if (!$answers['dev-links']) {
// install_modules()
$included_modules = array();
/* read modules list from MODULE_DIR */
if (file_exists(MODULE_DIR)) {
$dir = opendir(MODULE_DIR);
while ($file = readdir($dir)) {
if ($file[0] != "." && $file[0] != "_" && is_dir(MODULE_DIR . "/" . $file)) {
$included_modules[] = $file;
}
}
closedir($dir);
$output->write("Installing all modules...");
$this->install_modules($included_modules);
$output->writeln("Done installing modules");
}
}
// module_admin install framework
$output->writeln("Installing framework...");
$this->install_modules(array('framework'));
$output->writeln("Done");
// generate_configs();
$output->writeln("Generating default configurations...");
passthru("sudo -u " . $amp_conf['AMPASTERISKUSER'] . " " . $amp_conf["AMPBIN"] . "/retrieve_conf --skip-registry-checks");
$output->writeln("Finished generating default configurations");
// GPG setup - trustFreePBX();
$output->write("Trusting FreePBX...");
try {
\FreePBX::GPG()->trustFreePBX();
} catch (\Exception $e) {
$output->writeln("<error>Error!</error>");
$output->writeln("<error>Error while trusting FreePBX: " . $e->getMessage() . "</error>");
exit(1);
}
$output->writeln("Trusted");
//run this here so that we make sure everything is square for asterisk
passthru($amp_conf['AMPSBIN'] . "/fwconsole chown");
$output->writeln("<info>You have successfully installed FreePBX</info>");
}
示例5: testLocalValidation
public function testLocalValidation()
{
$gpg = \FreePBX::GPG();
$modulexml = base64_decode("PG1vZHVsZT4KCTxyYXduYW1lPmdwZ3Rlc3Q8L3Jhd25hbWU+Cgk8bmFtZT5Vbml0IFRlc3QgTW9kdWxlPC9uYW1lPgoJPHZlcnNpb24+MTMuMC4xPC92ZXJzaW9uPgoJPHB1Ymxpc2hlcj5TYW5nb21hIFRlY2hub2xvZ2llcyBDb3Jwb3JhdGlvbjwvcHVibGlzaGVyPgoJPGxpY2Vuc2U+QUdQTHYzKzwvbGljZW5zZT4KCTxsaWNlbnNlbGluaz5odHRwOi8vd3d3LmdudS5vcmcvbGljZW5zZXMvYWdwbC0zLjAudHh0PC9saWNlbnNlbGluaz4KCTxkZXNjcmlwdGlvbj5Vc2VkIG9ubHkgZm9yIFVuaXQgVGVzdGluZzwvZGVzY3JpcHRpb24+Cgk8Y2hhbmdlbG9nPioxMy4wLjEqIFJlbGVhc2U8L2NoYW5nZWxvZz4KCTxtZW51aXRlbXM+PGdwZ3Rlc3Q+RmlyZXdhbGw8L2dwZ3Rlc3Q+PC9tZW51aXRlbXM+Cgk8c3VwcG9ydGVkPjx2ZXJzaW9uPjEzLjA8L3ZlcnNpb24+PC9zdXBwb3J0ZWQ+CjwvbW9kdWxlPgo=");
$finc = base64_decode("PD9waHAKLy8gdGhpcyBmaWxlIGRvZXMgbm90aGluZwpyZXR1cm4gZmFsc2U7Cg==");
$root = "/var/www/html/admin/modules/gpgtest";
`rm -rf {$root}`;
@unlink("/etc/freepbx.secure/gpgtest.sig");
mkdir($root);
file_put_contents("{$root}/module.xml", $modulexml);
file_put_contents("{$root}/functions.inc.php", $finc);
// Various module.sig files
$unsigned = gzuncompress(base64_decode("eJydUk1z2jAQvetXKJNLOy3ENvJXOj44YBsIeOwYktBMDpIlG8VGBn+Aya+vCXR6aC/NXqTV7tu3+7S9Xmd3jjfxYeAFMJp4vjOCcyeKbM85xXpgjKv1LYzGtgzAj+v/tA4BL+aWjAV3z3Be0CZnMOKpwHVTMujyzv1t15/jGBVQFDXEec1KWK8ZjAtRM1FXsEg6n1cw6ViuIJwkZ44/j7A7a7zZspJReOD1+vtHgc25zQPP8wsiwTyHe5xzimteCIgFhaRLxGXWIXEFufiIXn12DvDSdZ3w9BXsWVl1FJYC1p36VrXGiqqBqpOM0VOLFpJUw1A0TTds3XSH6BIjR+t06W/XW1CybWFtsGhwDkp8EHjDrHSb1qyqQX3cMmvbkJzH4OVEwapXkDQiPg1WneDQgmqMsWnGipwQrOIBlSRGVUKoyQxTxgM16XxkyirRJJ3pxJBkZCBNi3VNkk2iUnCWsN9u8q7agCWIUZ0SwyBU1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cE+dxA3qb/Lo57E/3tgsraPGdatq+Gi14WwfqdnaP8zSbwNQSOSeT+VBMm4X4VHymkheFV6zTb2A7lz/zp748W5tl/WuQZMHZRJy7ljLvvMetvrg3dkAun4eNe1qHuyz+2Vv2D7NFiYwe/rj7qyP7d3+S51f1s75KA=="));
// Now put them in place and check their status.
file_put_contents("{$root}/module.sig", $unsigned);
$check = $gpg->verifyModule("gpgtest");
$this->assertTrue(($check['status'] & FreePBX\GPG::STATE_TAMPERED) == FreePBX\GPG::STATE_TAMPERED, "Not Tampered");
file_put_contents("{$root}/module.sig", $signed);
$check = $gpg->verifyModule("gpgtest");
$good = FreePBX\GPG::STATE_GOOD | FreePBX\GPG::STATE_TRUSTED;
$this->assertTrue($check['status'] === $good, "Not trusted");
file_put_contents("{$root}/module.sig", $modsecure);
try {
$check = $gpg->verifyModule("gpgtest", true);
$this->assertFalse($check['status'] === $good, "Local shouldn't be trusted, but it is");
$this->fail("This shouldn't have been reached");
} catch (\Exception $e) {
// Passed
$this->assertTrue(true, "threw when it should have");
}
file_put_contents("/etc/freepbx.secure/gpgtest.sig", $localsecure);
$check = $gpg->verifyModule("gpgtest");
$this->assertTrue($check['status'] === $good, "Local Not trusted when it should be");
// Check tampered status
file_put_contents("{$root}/functions.inc.php", "{$finc}\n\n");
$check = $gpg->verifyModule("gpgtest", true);
$this->assertTrue(($check['status'] & FreePBX\GPG::STATE_TAMPERED) == FreePBX\GPG::STATE_TAMPERED, "Not Tampered");
file_put_contents("{$root}/module.sig", $signed);
$check = $gpg->verifyModule("gpgtest");
$this->assertTrue(($check['status'] & FreePBX\GPG::STATE_TAMPERED) == FreePBX\GPG::STATE_TAMPERED, "Not Tampered");
unlink("/etc/freepbx.secure/gpgtest.sig");
}
示例6: execute
protected function execute(InputInterface $input, OutputInterface $output, $quiet = false)
{
if (posix_geteuid() != 0) {
$output->writeln("<error>" . _("You need to be root to run this command") . "</error>");
exit(1);
}
$this->quiet = $quiet;
if (!$this->quiet) {
$output->writeln(_("Setting Permissions") . "...");
}
$freepbx_conf = \freepbx_conf::create();
$conf = $freepbx_conf->get_conf_settings();
foreach ($conf as $key => $val) {
${$key} = $val['value'];
}
/*
* These are files Framework is responsible for This list can be
* reduced by moving responsibility to other modules as a hook
* where appropriate.
*
* Types:
* file: Set permissions/ownership on a single item
* dir: Set permissions/ownership on a single directory
* rdir: Set permissions/ownership on a single directory then recursively on
* files within less the execute bit. If the dir is 755, child files will be 644,
* child directories will be set the same as the parent.
* execdir: Same as rdir but the execute bit is not stripped.
*/
$sessdir = session_save_path();
$sessdir = !empty($session) ? $session : '/var/lib/php/session';
$args = array();
if ($input) {
$args = $input->getArgument('args');
$this->moduleName = !empty($this->moduleName) ? $this->moduleName : strtolower($args[0]);
}
// Always update hooks before running a Chown
\FreePBX::Hooks()->updateBMOHooks();
if (!empty($this->moduleName) && $this->moduleName != 'framework') {
$mod = $this->moduleName;
$this->modfiles[$mod][] = array('type' => 'rdir', 'path' => $AMPWEBROOT . '/admin/modules/' . $mod, 'perms' => 0755);
$hooks = $this->fwcChownFiles();
$current = isset($hooks[ucfirst($mod)]) ? $hooks[ucfirst($mod)] : false;
if (is_array($current)) {
$this->modfiles[$mod] = array_merge_recursive($this->modfiles[$mod], $current);
}
} else {
$webuser = \FreePBX::Freepbx_conf()->get('AMPASTERISKWEBUSER');
$web = posix_getpwnam($webuser);
if (!$web) {
throw new \Exception(sprintf(_("I tried to find out about %s, but the system doesn't think that user exists"), $webuser));
}
$home = trim($web['dir']);
if (is_dir($home)) {
$this->modfiles['framework'][] = array('type' => 'rdir', 'path' => $home, 'perms' => 0755);
// SSH folder needs non-world-readable permissions (otherwise ssh complains, and refuses to work)
$this->modfiles['framework'][] = array('type' => 'rdir', 'path' => "{$home}/.ssh", 'perms' => 0700);
}
$this->modfiles['framework'][] = array('type' => 'rdir', 'path' => $sessdir, 'perms' => 0744);
$this->modfiles['framework'][] = array('type' => 'file', 'path' => '/etc/amportal.conf', 'perms' => 0640);
$this->modfiles['framework'][] = array('type' => 'file', 'path' => '/etc/freepbx.conf', 'perms' => 0640);
$this->modfiles['framework'][] = array('type' => 'dir', 'path' => $ASTRUNDIR, 'perms' => 0755);
$this->modfiles['framework'][] = array('type' => 'rdir', 'path' => \FreePBX::GPG()->getGpgLocation(), 'perms' => 0755);
//we may wish to declare these manually or through some automated fashion
$this->modfiles['framework'][] = array('type' => 'rdir', 'path' => $ASTETCDIR, 'perms' => 0750);
$this->modfiles['framework'][] = array('type' => 'file', 'path' => $ASTVARLIBDIR . '/.ssh/id_rsa', 'perms' => 0600);
$this->modfiles['framework'][] = array('type' => 'rdir', 'path' => $ASTLOGDIR, 'perms' => 0755);
$this->modfiles['framework'][] = array('type' => 'rdir', 'path' => $ASTSPOOLDIR, 'perms' => 0755);
//I have added these below individually,
$this->modfiles['framework'][] = array('type' => 'file', 'path' => $FPBXDBUGFILE, 'perms' => 0644);
$this->modfiles['framework'][] = array('type' => 'file', 'path' => $FPBX_LOG_FILE, 'perms' => 0644);
//We may wish to declare files individually rather than touching everything
$this->modfiles['framework'][] = array('type' => 'rdir', 'path' => $ASTVARLIBDIR . '/' . $MOHDIR, 'perms' => 0755);
$this->modfiles['framework'][] = array('type' => 'rdir', 'path' => $ASTVARLIBDIR . '/sounds', 'perms' => 0755);
$this->modfiles['framework'][] = array('type' => 'file', 'path' => '/etc/obdc.ini', 'perms' => 0644);
//we were doing a recursive on this which I think is not needed.
//Changed to just be the directory
//^ Needs to be the whole shebang, doesnt work otherwise
$this->modfiles['framework'][] = array('type' => 'rdir', 'path' => $AMPWEBROOT, 'perms' => 0755);
//Anything in bin and agi-bin should be exec'd
//Should be after everything except but before hooks
//So that we dont get overwritten by ampwebroot
$this->modfiles['framework'][] = array('type' => 'execdir', 'path' => $AMPBIN, 'perms' => 0755);
$this->modfiles['framework'][] = array('type' => 'execdir', 'path' => $ASTAGIDIR, 'perms' => 0755);
//Merge static files and hook files, then act on them as a single unit
$fwcCF = $this->fwcChownFiles();
if (!empty($this->modfiles) && !empty($fwcCF)) {
$this->modfiles = array_merge_recursive($this->modfiles, $fwcCF);
}
}
$ampowner = $AMPASTERISKWEBUSER;
/* Address concerns carried over from amportal in FREEPBX-8268. If the apache user is different
* than the Asterisk user we provide permissions that allow both.
*/
$ampgroup = $AMPASTERISKWEBUSER != $AMPASTERISKUSER ? $AMPASTERISKGROUP : $AMPASTERISKWEBGROUP;
foreach ($this->modfiles as $moduleName => $modfilelist) {
foreach ($modfilelist as $file) {
if (!isset($file['path']) || !isset($file['perms']) || !file_exists($file['path'])) {
continue;
}
//Handle custom ownership (optional)
//.........这里部分代码省略.........
示例7: execute
protected function execute(InputInterface $input, OutputInterface $output, $quiet = false)
{
$this->output = $output;
if (posix_geteuid() != 0) {
$output->writeln("<error>" . _("You need to be root to run this command") . "</error>");
exit(1);
}
$this->quiet = $quiet;
$etcdir = \FreePBX::Config()->get('ASTETCDIR');
if (!$this->quiet) {
if (!file_exists($etcdir . '/freepbx_chown.conf')) {
$output->writeln("<info>" . sprintf(_("Taking too long? Customize the chown command, See %s"), "http://wiki.freepbx.org/display/FOP/FreePBX+Chown+Conf") . "</info>");
}
$output->writeln(_("Setting Permissions") . "...");
}
$freepbx_conf = \freepbx_conf::create();
$conf = $freepbx_conf->get_conf_settings();
foreach ($conf as $key => $val) {
${$key} = $val['value'];
}
/*
* These are files Framework is responsible for This list can be
* reduced by moving responsibility to other modules as a hook
* where appropriate.
*
* Types:
* file: Set permissions/ownership on a single item
* dir: Set permissions/ownership on a single directory
* rdir: Set permissions/ownership on a single directory then recursively on
* files within less the execute bit. If the dir is 755, child files will be 644,
* child directories will be set the same as the parent.
* execdir: Same as rdir but the execute bit is not stripped.
*/
$sessdir = session_save_path();
$sessdir = !empty($sessdir) ? $sessdir : '/var/lib/php/session';
$args = array();
if ($input) {
$args = $input->getArgument('args');
$mname = isset($args[0]) ? $args[0] : '';
$this->moduleName = !empty($this->moduleName) ? $this->moduleName : strtolower($mname);
}
// Always update hooks before running a Chown
\FreePBX::Hooks()->updateBMOHooks();
if (!empty($this->moduleName) && $this->moduleName != 'framework') {
$mod = $this->moduleName;
$this->modfiles[$mod][] = array('type' => 'rdir', 'path' => $AMPWEBROOT . '/admin/modules/' . $mod, 'perms' => 0755);
$hooks = $this->fwcChownFiles();
$current = isset($hooks[ucfirst($mod)]) ? $hooks[ucfirst($mod)] : false;
if (is_array($current)) {
$this->modfiles[$mod] = array_merge_recursive($this->modfiles[$mod], $current);
}
} else {
$webuser = \FreePBX::Freepbx_conf()->get('AMPASTERISKWEBUSER');
$web = posix_getpwnam($webuser);
if (!$web) {
throw new \Exception(sprintf(_("I tried to find out about %s, but the system doesn't think that user exists"), $webuser));
}
$home = trim($web['dir']);
if (is_dir($home)) {
$this->modfiles['framework'][] = array('type' => 'rdir', 'path' => $home, 'perms' => 0755);
// SSH folder needs non-world-readable permissions (otherwise ssh complains, and refuses to work)
$this->modfiles['framework'][] = array('type' => 'rdir', 'path' => "{$home}/.ssh", 'perms' => 0700);
}
$this->modfiles['framework'][] = array('type' => 'rdir', 'path' => $sessdir, 'perms' => 0744, 'always' => true);
$this->modfiles['framework'][] = array('type' => 'file', 'path' => '/etc/amportal.conf', 'perms' => 0640, 'always' => true);
$this->modfiles['framework'][] = array('type' => 'file', 'path' => '/etc/freepbx.conf', 'perms' => 0640, 'always' => true);
$this->modfiles['framework'][] = array('type' => 'dir', 'path' => $ASTRUNDIR, 'perms' => 0755, 'always' => true);
$this->modfiles['framework'][] = array('type' => 'rdir', 'path' => \FreePBX::GPG()->getGpgLocation(), 'perms' => 0755, 'always' => true);
//we may wish to declare these manually or through some automated fashion
$this->modfiles['framework'][] = array('type' => 'rdir', 'path' => $ASTETCDIR, 'perms' => 0750, 'always' => true);
$this->modfiles['framework'][] = array('type' => 'file', 'path' => $ASTVARLIBDIR . '/.ssh/id_rsa', 'perms' => 0600);
$this->modfiles['framework'][] = array('type' => 'rdir', 'path' => $ASTLOGDIR, 'perms' => 0755, 'always' => true);
$this->modfiles['framework'][] = array('type' => 'rdir', 'path' => $ASTSPOOLDIR, 'perms' => 0755);
//I have added these below individually,
$this->modfiles['framework'][] = array('type' => 'file', 'path' => $FPBXDBUGFILE, 'perms' => 0644);
$this->modfiles['framework'][] = array('type' => 'file', 'path' => $FPBX_LOG_FILE, 'perms' => 0644);
//We may wish to declare files individually rather than touching everything
$this->modfiles['framework'][] = array('type' => 'rdir', 'path' => $ASTVARLIBDIR . '/' . $MOHDIR, 'perms' => 0755);
$this->modfiles['framework'][] = array('type' => 'rdir', 'path' => $ASTVARLIBDIR . '/sounds', 'perms' => 0755);
$this->modfiles['framework'][] = array('type' => 'file', 'path' => '/etc/obdc.ini', 'perms' => 0644);
//we were doing a recursive on this which I think is not needed.
//Changed to just be the directory
//^ Needs to be the whole shebang, doesnt work otherwise
$this->modfiles['framework'][] = array('type' => 'rdir', 'path' => $AMPWEBROOT, 'perms' => 0755);
//Anything in bin and agi-bin should be exec'd
//Should be after everything except but before hooks
//So that we dont get overwritten by ampwebroot
$this->modfiles['framework'][] = array('type' => 'execdir', 'path' => $AMPBIN, 'perms' => 0755, 'always' => true);
$this->modfiles['framework'][] = array('type' => 'execdir', 'path' => $ASTAGIDIR, 'perms' => 0755, 'always' => true);
$this->modfiles['framework'][] = array('type' => 'execdir', 'path' => $ASTVARLIBDIR . "/bin", 'perms' => 0755, 'always' => true);
//Merge static files and hook files, then act on them as a single unit
$fwcCF = $this->fwcChownFiles();
if (!empty($this->modfiles) && !empty($fwcCF)) {
foreach ($fwcCF as $key => $value) {
$this->modfiles[$key] = $value;
}
//$this->modfiles = array_merge_recursive($this->modfiles,$fwcCF);
}
}
//Let's move the custom array to the end so it happens last
//.........这里部分代码省略.........
示例8: out
out(_('Version from Framework was empty, cant continue'));
return false;
}
//sbin is not set correctly starting in 2.9, this is a stop-gap till we fix the installer in 13
exec('export PATH=/usr/local/sbin:$PATH && which -a amportal', $output, $return_var);
$file = null;
foreach ($output as $f) {
if (!is_link($f)) {
$file = $f;
break;
}
}
if (!empty($file)) {
$sbin = dirname($file);
if (is_dir($sbin) && $amp_conf['AMPSBIN'] !== $sbin) {
$freepbx_conf =& freepbx_conf::create();
out(sprintf(_("Setting sbin to the correct location of: %s"), $sbin));
$freepbx_conf->set_conf_values(array("AMPSBIN" => $sbin), true, true);
}
}
exec($amp_conf['AMPBIN'] . '/retrieve_conf 2>&1', $ret);
//need to invalidate module_xml at this point
if (function_exists("sql")) {
sql("DELETE FROM module_xml WHERE id = 'modules'");
}
// Make sure our GPG keys are up to date
try {
\FreePBX::GPG()->refreshKeys();
} catch (\Exception $e) {
out(sprintf(_("Error updating GPG Keys: %s"), $e->getMessage()));
}