Local database settings failed to copy
-
Hi there, thanks so much for carrying on the work of IP Geo Block. This plugin is critical to a number of sites I run and has been fairly solid for me over the years. Even though there are other plugins out there that do similar things I have always been partial to IP Geo Block and now IP Location Block!
A couple things, on local database settings I am getting a ‘copy_failed_ziparchive Could not copy file.’ error on IP2Location database for both IPv4 and v6. Any thoughts? Also, I have always just used the default API selection and key settings so I only have IP2Location checked, but should I be using the other options? If so, how do I get API keys?
Thanks!
-
Thanks for your input.
But here’s another weird one. After installing it on the dev site and doing a couple of database downloads that gave no error messages, I then ftp’ed out to the folder with those .BIN files and noticed the timestamps on the BIN files don’t seem to change.
The plugin will detect if there is need to update the database. It usually prints a message that your databases are up to date, it checks the headers of the remote file and determines if the local version is the same, then no need for re-download.
Lastly, a co-admin on our prod site lives in Michigan. I’m in Florida. His ip address was locked out of our prod site yesterday. The log said his country code was “ZZ”. So I’ve de-activated the plug-in on our prod site.
Can you tell me which provider they were using? This is mostly up to the provider, but in any case ‘ZZ’ location is invalid and shouldn’t be used for validation. I will need to do some more debugging here.
@darkog are there any updates on any of this?
I did not found the problem with the unzipping, I can’t reproduce on my end and therefore I have no idea why it happens.
Other updates
I rewrote some of the code and I hope to standardize the ASN blocking, currently, it doesn’t always work, this will be done in the next 1.0.4 version.Best Regards,
Darko@wyclef – Can you verify if the disk quota is not reached and the permissions are fine?
How can I verify that for you? This is on a shared hosting plan at DreamHost.
I had the same error “copy_failed_ziparchive” today and managed to track down the underlying issue.
The error happens at
classes/class-ip-location-block-util.php
insidedownload_zip()
at the line where the zip file gets unpacked.} elseif ( 'zip' === $ext && class_exists( 'ZipArchive', false ) ) { $tmp = self::get_temp_dir(); if ( is_wp_error( $tmp ) ) { throw new Exception( sprintf( __( 'Unable to extract archive. %s', 'ip-location-block' ), $tmp->get_error_message() ) ); } $ret = $fs->unzip_file( $src, $tmp ); // @since 0.2.5 return array('ret' => $ret, 'error' => is_wp_error( $ret ), 'src' => $src, 'tmp' => $tmp); if ( is_wp_error( $ret ) ) { throw new Exception( $ret->get_error_code() . ' ' . $ret->get_error_message() ); } if ( false === ( $data = $fs->get_contents( $tmp .= basename( $filename ) ) ) ) { throw new Exception( sprintf( __( 'Unable to read <code>%s</code>. Please check the permission.', 'ip-location-block' ), $tmp ) ); } if ( false === $fs->put_contents( $filename, $data ) ) { throw new Exception( sprintf( __( 'Unable to write <code>%s</code>. Please check the permission.', 'ip-location-block' ), $filename ) ); } }
To be exact
$ret = $fs->unzip_file( $src, $tmp ); // @since 0.2.5
triggers the issue.I added following code directly after
$fs->unzip_file
for further debuggingreturn array('ret' => $ret, 'error' => is_wp_error( $ret ), 'src' => $src, 'tmp' => $tmp);
and got following json_decode’d response:
Array ( [IP2Location] => Array ( [ipv4] => Array ( [ret] => Array ( [errors] => Array ( [copy_failed_ziparchive] => Array ( [0] => The file could not be copied. ) ) [error_data] => Array ( [copy_failed_ziparchive] => LICENSE-CC-BY-SA-4.0.TXT ) ) [error] => 1 [src] => /tmp/IP2LOCATION-LITE-DB1.BIN-gusQKW.tmp [tmp] => /tmp/ ) [ipv6] => Array ( [ret] => Array ( [errors] => Array ( [copy_failed_ziparchive] => Array ( [0] => The file could not be copied. ) ) [error_data] => Array ( [copy_failed_ziparchive] => LICENSE-CC-BY-SA-4.0.TXT ) ) [error] => 1 [src] => /tmp/IP2LOCATION-LITE-DB1.IPV6_.BIN-61HRmx.tmp [tmp] => /tmp/ ) ) )
As you can see
copy_failed_ziparchive
points to aLICENSE-CC-BY-SA-4.0.TXT
.
I then checked/tmp/
and found multiple .TXT and other files inside.root@webserver:~$ ls -1 /tmp glances-root.log IP2LOCATION-LITE-DB1.BIN-gusQKW.tmp IP2LOCATION-LITE-DB1.IPV6_.BIN-61HRmx.tmp LICENSE-CC-BY-SA-4.0.TXT README_LITE.TXT snap.lxd snowscan.lock systemd-private-7c58b090b60e4cd6a197223c6bd090a5-apache2.service-nEGI0e systemd-private-7c58b090b60e4cd6a197223c6bd090a5-ModemManager.service-V5qjbg systemd-private-7c58b090b60e4cd6a197223c6bd090a5-nagios-nrpe-server.service-TmVNUe systemd-private-7c58b090b60e4cd6a197223c6bd090a5-netdata.service-KvksBg systemd-private-7c58b090b60e4cd6a197223c6bd090a5-ntp.service-8ZLPMf systemd-private-7c58b090b60e4cd6a197223c6bd090a5-redis-server.service-defW4g systemd-private-7c58b090b60e4cd6a197223c6bd090a5-systemd-logind.service-e4U2ch systemd-private-7c58b090b60e4cd6a197223c6bd090a5-systemd-resolved.service-kVaj6f
I then deleted
LICENSE-CC-BY-SA-4.0.TXT
and clicked “Download now” again. This time the filename in my debug output changed toREADME_LITE.TXT
.So it appears that for every file inside
/tmp/
$fs->unzip_file( $src, $tmp )
gets called.I think the error could be resolved if
$tmp = self::get_temp_dir();
returns a sub directory of/tmp/
instead of/tmp/
itself for ex./tmp/ip-location-block/
so only files inside/tmp/ip-location-block/
are getting unzipped.Further information on following check inside get_temp_dir() function:
if ( ! file_exists( $dir ) || ! is_writable( $dir ) ) {
We configured our
php.ini
‘sopen_basedir
the following way:
open_basedir = /www/customer8482:/usr/local/session:/usr/share/php:/tmp:/usr/bin/pdfinfo:/usr/bin/pdftotext
So
/tmp/
is withinopen_basedir
and therefore accessible and via linux default/tmp/
behaviour also writable to anyone.The check mentioned before skips his subroutine in which a path to a sub directory inside /wp-content/uploads/ folder is constructed and therefore does
return trailingslashit( $dir );
which leads to/tmp/
inside$tmp
parameter for$ret = $fs->unzip_file( $src, $tmp ); // @since 0.2.5
Please ask if you need more info about my server configuration/environment.
Currently using:
Ubuntu 20.04 LTS Server
PHP 8.0 with FPM@darkog do you need additional information for developing a bugfix?
@theonylmarkus – thank you for this and sorry i din’t noticed your replies. I will check on the debug information asap. It should be helpful. I am happy to provide a bugfix on this issue.
@theonylmarkus – I pushed a new version that should fix the issue. Feel free to check.
@darkog Thank you! I can confirm that downloading now works with /tmp/ allowed in open_basedir
Thanks for the confirmation @theonylmarkus – For the next release I am thinking to dump the default OS tmp directory (because it requires open_basedir configuration on some environments) in favor of
wp-content/uploads/ip-location-block/tmp
which is plug and play basically.- This reply was modified 2 years, 4 months ago by Darko G..
@darkog no problem. We have /tmp allowed by default on our servers. I you choose a different tmp directory it’s fine by me. Please make sure it gets cleaned regularly to prevent high disk usage over time. This is the exact reason why we prefer /tmp -> it get’s cleaned automatically on every reboot by Linux. Therefore a missing temp directory handling won’t fill up space endlessly, which is a very important thing on shared hosting servers.
- The topic ‘Local database settings failed to copy’ is closed to new replies.