Bug #16964 » 16964-b.patch
| src/etc/inc/pfsense-utils.inc | ||
|---|---|---|
|
log_error(gettext("Alias archive is a .tar/tgz file which cannot be decompressed because utility is missing!"));
|
||
|
return false;
|
||
|
}
|
||
|
$temp_dir = "{$temp_filename}/aliasdata/";
|
||
|
mkdir($temp_dir);
|
||
|
rename("{$temp_filename}/aliases", "{$temp_filename}/aliases.tgz");
|
||
|
mwexec("/usr/bin/tar xzf {$temp_filename}/aliases.tgz -C {$temp_filename}/aliases/");
|
||
|
mwexec("/usr/bin/tar xzf {$temp_filename}/aliases.tgz -C {$temp_dir}");
|
||
|
unlink("{$temp_filename}/aliases.tgz");
|
||
|
$files_to_process = return_dir_as_array("{$temp_filename}/");
|
||
|
$files_to_process = return_dir_as_array($temp_dir);
|
||
|
/* foreach through all extracted files and build up aliases file */
|
||
|
$fd = @fopen("{$temp_filename}/aliases", "w");
|
||
|
if (!$fd) {
|
||
| ... | ... | |
|
return false;
|
||
|
}
|
||
|
foreach ($files_to_process as $f2p) {
|
||
|
/* Entries in this array should not have a directory path,
|
||
|
* but be safe and add the expected path to the basename. */
|
||
|
$f2p = $temp_dir . basename($f2p);
|
||
|
/* Do not process links or items which are not files */
|
||
|
if (is_link($f2p) ||
|
||
|
!is_file($f2p)) {
|
||
|
log_error(sprintf(gettext('The following entry from the archive is not a regular file: %1$s'), $f2p));
|
||
|
continue;
|
||
|
}
|
||
|
$tmpfd = @fopen($f2p, 'r');
|
||
|
if (!$tmpfd) {
|
||
|
log_error(sprintf(gettext('The following file could not be read %1$s from %2$s'), $f2p, $temp_filename));
|
||
|
continue;
|
||
|
}
|
||
|
while (($tmpbuf = fread($tmpfd, 65536)) !== FALSE) {
|
||
|
while ($tmpbuf = fgets($tmpfd)) {
|
||
|
fwrite($fd, $tmpbuf);
|
||
|
}
|
||
|
fclose($tmpfd);
|
||
|
unlink($f2p);
|
||
|
@unlink($f2p);
|
||
|
}
|
||
|
fclose($fd);
|
||
|
unset($tmpbuf);
|
||
|
@rmdir_recursive($tmp_dir);
|
||
|
return true;
|
||
|
}
|
||
- « Previous
- 1
- 2
- Next »