Topic: Can't install extension

I'm trying to install the "Import Multiple Journal Entries" extension. I get the error "Could not Open" after a short period of loading. I have looked at the other forum post https://frontaccounting.com/punbb/viewtopic.php?id=4431 since they are asking about the same problem there, but nothing on that post resolves the problem.

I believe that curl is setup properly for php. Here is a section from my phpinfo

cURL support     enabled
cURL Information     7.33.0
Age     3
Features
AsynchDNS     Yes
CharConv     No
Debug     No
GSS-Negotiate     No
IDN     No
IPv6     Yes
krb4     No
Largefile     Yes
libz     Yes
NTLM     Yes
NTLMWB     Yes
SPNEGO     No
SSL     Yes
SSPI     No
TLS-SRP     Yes
Protocols     dict, file, ftp, ftps, gopher, http, https, imap, imaps, pop3, pop3s, rtsp, scp, sftp, smtp, smtps, telnet, tftp
Host     x86_64-unknown-linux-gnu
SSL Version     OpenSSL/1.0.1e
ZLib Version     1.2.8
libSSH Version     libssh2/1.4.3

I tried renaming .htaccess to x.htaccess in the root folder of the install

I turned on debugging and got the following output:

    
mysql_connect(): The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead in file: /srv/http/frontaccounting/includes/db/connect_db.inc at line 27
is_dir() expects parameter 1 to be a valid path, string given in file: /srv/http/frontaccounting/includes/archive.inc at line 381
mkdir() expects parameter 1 to be a valid path, string given in file: /srv/http/frontaccounting/includes/archive.inc at line 382
gzopen(../modules/_cache/import_multijournalentries-2.3.0-4/_init/config): failed to open stream: No such file or directory in file: /srv/http/frontaccounting/includes/packages.inc at line 165
Could not open 

Any thoughts. Let me know if you need more information.

Re: Can't install extension

https://frontaccounting.com/punbb/viewtopic.php?pid=18192 seems to describe the same problem.

Re: Can't install extension

I've been trying to track down the problem and think I've made some progress but haven't figured it out completely. The import_multijournalentries-2.3.0-4.pkg file (that is the extension that I'm trying to install) is downloaded in the tmp folder but the files aren't being properly extracted. A import_multijournalentries-2.3.0-4 folder is created in modules/_cache directory but it is empty. All the errors are coming from that because it expects the files to be there.

Re: Can't install extension

The error suggests that the string passed to is_dir is not a valid path, but that doesn't make any sense. My best guess is a problem with permissions.

If it's not that, then I'd like to know what the offending string contains.

Re: Can't install extension

Thanks for your help and suggestions.

I don't think it is permissions. My server runs as user "http". The modules folder has 777 permissions, as does the _cache directory. import_multijournalentries-2.3.0-4.pkg has 644 permissions and is owned by http. The created folder import_multijournalentries-2.3.0-4 is owned by http and has write permissions.

I've increased the debugging output so you can see the parameters being passed to is_dir.

is_dir() expects parameter 1 to be a valid path, string given in file: /srv/http/frontaccounting/includes/archive.inc at line 381
/srv/http/frontaccounting/includes/archive.inc:381:     is_dir('_init')
/srv/http/frontaccounting/includes/packages.inc:54:     (tar_file Object)->extract_files()
/srv/http/frontaccounting/includes/packages.inc:654:     (package Object)->install()
/srv/http/frontaccounting/admin/inst_module.php:238:     install_extension('import_multijournalentries')
mkdir() expects parameter 1 to be a valid path, string given in file: /srv/http/frontaccounting/includes/archive.inc at line 382
/srv/http/frontaccounting/includes/archive.inc:382:     mkdir('_init','16877')
/srv/http/frontaccounting/includes/packages.inc:54:     (tar_file Object)->extract_files()
/srv/http/frontaccounting/includes/packages.inc:654:     (package Object)->install()
/srv/http/frontaccounting/admin/inst_module.php:238:     install_extension('import_multijournalentries')
gzopen(../modules/_cache/import_multijournalentries-2.3.0-4/_init/config): failed to open stream: No such file or directory in file: /srv/http/frontaccounting/includes/packages.inc at line 165
/srv/http/frontaccounting/includes/packages.inc:165:     gzopen('../modules/_cache/import_multijournalentries-2.3.0-4/_init/config','rb')
/srv/http/frontaccounting/includes/packages.inc:56:     get_control_file('../modules/_cache/import_multijournalentries-2.3.0-4/_init/config')
/srv/http/frontaccounting/includes/packages.inc:654:     (package Object)->install()
/srv/http/frontaccounting/admin/inst_module.php:238:     install_extension('import_multijournalentries')
Could not open
/srv/http/frontaccounting/includes/ui/ui_msgs.inc:14:     trigger_error('Could not open _init/files for writing.
This script does not support extracting this type of tar file.
Could not open file ../modules/_cache/import_multijournalentries-2.3.0-4/_data','256')
/srv/http/frontaccounting/includes/packages.inc:695:     display_error('Could not open _init/files for writing.
This script does not support extracting this type of tar file.
Could not open file ../modules/_cache/import_multijournalentries-2.3.0-4/_data')
/srv/http/frontaccounting/admin/inst_module.php:238:     install_extension('import_multijournalentries')

So it is passing "_init" to is_dir, which should be fine (I see that folder in the pkg archive when I extract it by hand) except the folder never gets extracted to the import_multijournalentries-2.3.0-4 in _cache.

I've been looking at the extract_files function in archive.inc but I don't know much php and can't quite make sense of it yet.

Re: Can't install extension

I was wondering if there could be a problem with the path. Just what is the script's current directory when it tries to create "_init"?


http://www.php.net/manual/en/function.is-dir.php
http://php.net/manual/en/function.mkdir.php

Re: Can't install extension

http://www.php.net/manual/en/function.is-dir.php says "If you have enabled safe mode, or open_basedir further restrictions may apply."

Could this be one of those restrictions?

Re: Can't install extension

You were thinking along the lines that I am.

The current directory using getcwd is /srv/http/frontaccounting/modules/_cache/import_multijournalentries-2.3.0-4. Which seems right to me.

I also checked the encoding of the string and is is ASCII according to mb_detect_encoding. I checked this because of the results on this website (http://www.opencore.eesc.usp.br/patricia/phpsource/php-5.5.3/ext/standard/tests/file/is_dir_variation4.phpt) which shows the same errors I'm getting when testing binary safe strings.

I also set the import_multijournalentries-2.3.0-4 permissions to 777, just in case there was a permissions problems.

Re: Can't install extension

I'm not running in safe mode (don't think I can since I'm using php 5.5.5), and I'm within the document root of the server which is included in the open_basedir list.

Re: Can't install extension

I got the extension to install, I just had to strip the null characters from the file names as they were being extracted. For some reason there was a good amount of padding of null characters on both sides of the file name.

The problem is now that it is installed, says it is installed, I can't seem to use it. Nothing appears in the banking and general ledger page and it isn't listed on the access setup page. I'm using just the admin account right now. Any ideas how to debug this?

Re: Can't install extension

I have no idea now how I actually installed it, but I do remember it didn't feel very straightforward...

Looking at the "Install/Activate extensions" page, there is a dropdown at the top. If you select "Activated for <company>", you should be able to activate the extensions you have installed.

Once you do, I would expect it to be available in the access setup.

Re: Can't install extension

The said extension's files are available at:
https://github.com/apmuthu/frontaccounting/tree/master/extensions/Extensions/import_multijournalentries

@kfrance: Please notify which files had the null characters in their names.

Re: Can't install extension

@apmuthu: All the files had null characters in them. I think it must have something with the setup that I have. I used archlinux so the packages tend to be ahead of most distributions. I'm using php 5.5.5, apache 2.2.25, and curl 7.32.0.

I added the following line to the function extract_files in archive.inc, right after file is set using fields from temp

$file['name'] = str_replace("\0", "", $file['name']);

I figured out how to use the extension after it was installed. I think I was just getting tired after debugging, and didn't activate it for the company.

Thanks for everyone's help.

14 (edited by apmuthu 04/13/2015 07:10:59 am)

Re: Can't install extension

It may be simpler to remove the "\0" in the filenames or use an appropriate option in the extraction program used.

All extension files in extracted form are available at my github repo.

Re: Can't install extension

I had same problem.  /account/modules/import_multijournalentries/import_multijournalentries.php could not open and gave error.

When I checked the permissions is was art 666. When I cahnged it to 644 it works fine now.

Wynand

16 (edited by apmuthu 04/13/2015 07:14:27 am)

Re: Can't install extension

644 is a subset of 666 - check if the ownerships changed.

@joe: should we introduce the leading "\0" stripping out in the core? Will it affect any End of Field character for VARCHARS for buffer overflow exploits?