SELinux prevents generating Excel file (.xls) #360

Closed
derdeagle opened this Issue Feb 11, 2016 · 4 comments

Projects

None yet

2 participants

@derdeagle
Contributor

Hi,

I just stumbled over generatedata not generating an Excel file. Just an empty page is being displayed.
Reviewing the webserver error log (httpd/apache) I saw the following error:

[:error] [pid x] [client x:y] PHP Fatal error: Uncaught exception 'Exception' with message 'Can't open 3c7oik39jttlt3hu2n4904cj74dataFeb-11-2016.xls. It may be in use or protected.' in /usr/share/generatedata/plugins/exportTypes/Excel/PHPExcel/Shared/OLE/PPS/Root.php:93\nStack trace:\n#0 /usr/share/generatedata/plugins/exportTypes/Excel/PHPExcel/Writer/Excel5.php(234): PHPExcel_Shared_OLE_PPS_Root->save('3c7oik39jttlt3h...')\n#1 /usr/share/generatedata/plugins/exportTypes/Excel/Excel.class.php(53): PHPExcel_Writer_Excel5->save('3c7oik39jttlt3h...')\n#2 /usr/share/generatedata/resources/classes/DataGenerator.class.php(52): Excel->generate(Object(DataGenerator))\n#3 /usr/share/generatedata/generate.php(7): DataGenerator->generate()\n#4 {main}\n thrown in /usr/share/generatedata/plugins/exportTypes/Excel/PHPExcel/Shared/OLE/PPS/Root.php on line 93, referer: http://x/generatedata/

By setting the SELinux file context allowing the httpd to write to the root directory of generatedata (httpd_sys_rw_content_t) it is working like a charm.
Since doing this is not very nice, I would kindly ask you if it was possible to generate those files either in the cache/ folder or create a new one for the generated files.

@benkeen benkeen added the Export Type label Feb 11, 2016
@benkeen
Owner
benkeen commented Feb 11, 2016

Good call. To be honest, that may be a bug: I believe they should be generated in the /cache folder.

@benkeen benkeen added this to the 3.2.5 milestone Feb 12, 2016
@benkeen benkeen added the Bug label Feb 12, 2016
@benkeen
Owner
benkeen commented Feb 12, 2016

Hi @derdeagle - quick clarification. I looked over the code and are you talking about generating Excel with the zip option checked? Seems like that's the only place that an actual file is created, and you're right: it creates it in the root folder, which is awfully ugly. I just fixed it to generate all zipped up files in the ./cache subfolder.

@derdeagle derdeagle added a commit to derdeagle/generatedata that referenced this issue Feb 12, 2016
@derdeagle derdeagle Fix generated Excel file and zipped file in cache/ directory; issue #360
4f637db
@derdeagle
Contributor

By further debugging (as good as one can debug PHP) I noticed that my previously described bug did not only concern Excel files but all zipped files.

I made a pull request for this one as #362.

@derdeagle derdeagle added a commit to derdeagle/generatedata that referenced this issue Feb 12, 2016
@derdeagle derdeagle fix path for file; issue #360 2693386
@benkeen
Owner
benkeen commented Feb 13, 2016

Thanks, merged.

@benkeen benkeen closed this Feb 13, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment