Bug #16964 » 16964-b.patch
| src/etc/inc/pfsense-utils.inc | ||
|---|---|---|
| 2616 | 2616 |
log_error(gettext("Alias archive is a .tar/tgz file which cannot be decompressed because utility is missing!"));
|
| 2617 | 2617 |
return false; |
| 2618 | 2618 |
} |
| 2619 |
$temp_dir = "{$temp_filename}/aliasdata/";
|
|
| 2620 |
mkdir($temp_dir); |
|
| 2619 | 2621 |
rename("{$temp_filename}/aliases", "{$temp_filename}/aliases.tgz");
|
| 2620 |
mwexec("/usr/bin/tar xzf {$temp_filename}/aliases.tgz -C {$temp_filename}/aliases/");
|
|
| 2622 |
mwexec("/usr/bin/tar xzf {$temp_filename}/aliases.tgz -C {$temp_dir}");
|
|
| 2621 | 2623 |
unlink("{$temp_filename}/aliases.tgz");
|
| 2622 |
$files_to_process = return_dir_as_array("{$temp_filename}/");
|
|
| 2624 |
$files_to_process = return_dir_as_array($temp_dir);
|
|
| 2623 | 2625 |
/* foreach through all extracted files and build up aliases file */ |
| 2624 | 2626 |
$fd = @fopen("{$temp_filename}/aliases", "w");
|
| 2625 | 2627 |
if (!$fd) {
|
| ... | ... | |
| 2627 | 2629 |
return false; |
| 2628 | 2630 |
} |
| 2629 | 2631 |
foreach ($files_to_process as $f2p) {
|
| 2632 |
/* Entries in this array should not have a directory path, |
|
| 2633 |
* but be safe and add the expected path to the basename. */ |
|
| 2634 |
$f2p = $temp_dir . basename($f2p); |
|
| 2635 |
/* Do not process links or items which are not files */ |
|
| 2636 |
if (is_link($f2p) || |
|
| 2637 |
!is_file($f2p)) {
|
|
| 2638 |
log_error(sprintf(gettext('The following entry from the archive is not a regular file: %1$s'), $f2p));
|
|
| 2639 |
continue; |
|
| 2640 |
} |
|
| 2630 | 2641 |
$tmpfd = @fopen($f2p, 'r'); |
| 2631 | 2642 |
if (!$tmpfd) {
|
| 2632 | 2643 |
log_error(sprintf(gettext('The following file could not be read %1$s from %2$s'), $f2p, $temp_filename));
|
| 2633 | 2644 |
continue; |
| 2634 | 2645 |
} |
| 2635 |
while (($tmpbuf = fread($tmpfd, 65536)) !== FALSE) {
|
|
| 2646 |
while ($tmpbuf = fgets($tmpfd)) {
|
|
| 2636 | 2647 |
fwrite($fd, $tmpbuf); |
| 2637 | 2648 |
} |
| 2638 | 2649 |
fclose($tmpfd); |
| 2639 |
unlink($f2p); |
|
| 2650 |
@unlink($f2p);
|
|
| 2640 | 2651 |
} |
| 2641 | 2652 |
fclose($fd); |
| 2642 | 2653 |
unset($tmpbuf); |
| 2654 |
@rmdir_recursive($tmp_dir); |
|
| 2643 | 2655 | |
| 2644 | 2656 |
return true; |
| 2645 | 2657 |
} |
- « Previous
- 1
- 2
- Next »