-
Notifications
You must be signed in to change notification settings - Fork 373
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
unoconv not running with apache, but runs fine with root #87
Comments
From the exception you can see it tries to open /root/.ure/types.rdb. So the first question is why ? |
I have no clue. From a grep, the one giving the error is /opt/libreoffice3.6/program/libpyuno.so This is with RHEL6 and libreoffice3.6, though it also happens with 3.5. Maybe it's some environment variable? |
Please see this error report: http://code.google.com/p/archivematica/issues/detail?id=961 Is it possible you have more than one instance running ? Can you use |
Just one office running. Just one soffice binary in the entire HD. Thanks for the help, by the way, I appreciate it. I'm messing around with paths now and see if I can get something to stick. |
Another google result: http://ask.libreoffice.org/question/5812/running-via-web-server/ |
And possibly more relevant: https://bugs.freedesktop.org/show_bug.cgi?id=50123 Might be an installation problem. What distribution or version ? Are you using the latest unoconv v0.6 ? |
Using 0.6, but same thing happens with 0.5. Checking the link for ideas, thanks again! Also, using RHEL 6 with libreoffice from the libreoffice rpms. |
Ok, this is the same environment as me. I am looking into it by doing:
If I force a specific LibreOffice 3.6, I get:
|
Doing the same with a real user, it does work:
The difference in environment is: [root@moria Downloads]# diff <(sudo -E -H -u apache env) <(sudo -E -H -u dag env)
8c8
< USER=apache
---
> USER=dag
19,20c19,20
< HOME=/var/www
< LOGNAME=apache
---
> HOME=/home/dag
> LOGNAME=dag
28c28
< USERNAME=apache
---
> USERNAME=dag |
For me, it works with the apache user: UNO_PATH=/opt/libreoffice3.6 sudo -E -u apache unoconv -vvvv -f pdf -o "/var/www/tmp/test2" "/var/www/tmp/test1" The problem is when running it from -inside- apache. |
In fact, it's a problem with either the PHP or Apache I compiled. I couldn't use the RHEL6 version because the SOAP lib doesn't work properly and had to roll out my own version. The distro installed version actually works (have it running on a separate port), so what I'm going to do is make the original version do the unoconv processing, while the custom one I built does the rest. Stop gap until I can figure this specific problem out. |
Aaaaand... somehow it fixed itself. I don't know what I did, but somehow it just started working. |
I noticed that I had to modify the apache user's shell to something different than |
I wish I could shed some light on it, but the truth is that I don't know what I did. The samba user still has the The last things I remember doing were:
I was in the process of looking through the links you gave me to check when someone else told me "it works" But I might have done more, IDK. Oh, one thing I did which _MIGHT_ have to do something with it is change /etc/environment |
(Continued from above, hit the comment button by accident) In /etc/environment I added this line at some point soon before the thing started working:
|
It -may- also have to do with having a |
@noego These are all good suggestions for the next person to test. Over time I am confident we will find it. The |
BTW Thanks for sharing your insights ! |
Hi don't know if this might help, but we are also using (a patched) unoconv to run Open/Libreoffice on SLC5/6 triggered from Apache (mod_wsgi). Additionally we are running unoconv (and that's why we patched it) as user nobody in a dedicated home directory, so that LibreOffice can't possibly mess up with Apache files. We found that we need to explicitly set a HOME environment variable to unoconv->libreoffice, pointing to a directory where LibreOffice has the rights to write (in our case the user nobody). Without this HOME variable getting through the chain of sudo calls, unoconv and libreoffice, we were also experiencing the original error message your mentioning. |
@kaplun I'd like to hear any recommendations you have for making this part of unoconv. In what way did you patch this, and is there something we can improve to accommodate this kind of use. I would expect setting |
Hi @dagwieers! What we are trying to achieve is to be able to run unoconv from Apache, but with the privileges of the "nobody" user, manipulating files in a restricted dedicated directory. It's a sort of sandboxed execution (e.g. to prevent malicious macros etc.). For this reason we advise our users to setup the sudoers file to allow Apache user to run our customized unoconv as the user nobody. In the unoconv script we enforce a given directory as the $HOME directory for LibreOffice with rights only to the user nobody. This happens in line inveniosoftware/invenio@86fae6f#L0R275 but is also replicated at: in order to be sure that in every condition LibreOffice receives the correct HOME environment variable. I am not sure if setting HOME in both places is actually needed, but since we started doing it we are no longer experiencing the above mentioned error. Additionally our customization includes a way to kill a libreoffice listener, but we are not enough satisfied yet with the current implementation to propose it for pulling. |
Looking at your patch I wonder:
Anticipating your reply, sincerely ;-) |
Hi Dag, In data venerdì 28 settembre 2012 10:19:57, Dag Wieers ha scritto:
Well, that would be awesome.
In our case we really would like to control HOME, because, since we are
Simply to enforce PDF/A. Our software aims at being used to implement digital
Well, I wasn't sure about it. Indeed this should be the preferred way. I will
Unfortunately I believe not.
Ouch. Kind of difficult to reproduce for me (also I basically test often in Thanks a lot for all your time in creating and maintaining this precious piece
Samuele Kaplun |
Hi, I've put something together over in s0600204@8bb1e9a that might be of interest - an attempt to add the option to specify HOME within the passed arguments. I've tested this on CentOS 64-bit, with LibreOffice 3.4.5 and 3.6.1.2, and it works - kind of. With both versions of LibreOffice, the provided folder is used as HOME without problems - as long as it has a LibreOffice profile folder within it. If it doesn't, LibreOffice (both versions) creates the profile folder and then exits, returning code 81. If I understand the flow of this bug report: https://bugs.freedesktop.org/show_bug.cgi?id=43989, this not only appears to be expected behaviour, but happens whenever LibreOffice is freshly installed on a computer. However, normally soffice.bin is called from within something else (soffice.exe on windows, soffice on linux) that catches it and restarts LibreOffice automatically. As unoconv calls soffice.bin directly, perhaps unoconv needs to start parsing the exit code so that should it receive this one, it knows to restart LibreOffice. Thoughts? It should also be noted that the different versions of LibreOffice take different times to create the profile folder and exit. On my test system, version 3.4.5 takes only a second or two, whilst version 3.6 takes over 8 seconds, causing unoconv to timeout unless a longer value is set. |
Just in case this saves someone's day. After spending hours trying to fix this, we realized that $HOME env value inside apache/php was /root. Adding this line (or another useful path for your case) will make the difference: putenv('HOME=/home/apache/'); |
rucomes, The reason why Apache is using /root as its HOME env value is quite possibly because Apache is running as root (or attempting to do so) on your system. I'm no expert but, if I were you, I'd seriously look into this. |
Please any help in this regard? Also I have installed unoconv using apt-get. |
Anything interesting in the unoconv log files?
|
@sockmonk Which log files you are talking about? Listener is running fine, The problem I just can't connect to it. If you see above I have set verbosity level to 4. Is there any other log files which unoconv maintain internally? |
I'm talking about the log files whose paths are in the supervisor conf file
|
@sockmonk the log files are empty. And I was wondering the log files for unoconv in supervisor is for the listener. So how that can be populated if something wrong is happening while connecting with the listener. |
The command |
Had the same problem under Ubuntu Trusty+Apache2.4+PHP5.5. |
First of all, I don't know if we fixed this issue with commit d9810b7 (issue #224). If it isn't fixed, what would be the best solution for unoconv ?
I can see advantages and disadvantages in each.
A combination of 1-2 or 2-3 are possible as well. |
Also, [temporary?] options are:
|
I just ran a couple of tests locally (and repeated them to be sure): If memory serves, LibreOffice used to attempt to create Anyhow, I changed the folder permissions for the webserver's I then erased the My conclusion is that this is not yet fixed, but we are very close now. Options 2+3 combined sound good. Should work out of the box, with flexibility if needed. (LibreOffice 4.3.3, Lighttpd 1.4.35 and Python 2.7.9 on Debian 8, by the way) |
@pataquets You mean something like this: |
Minor readme addition about HOME directory (#87)
Hi, |
Having had the same problems and studying these discussions I decided trying to hardcode HOME to /tmp at about line 1216 in /usr/bin/unoconv: ### Main entrance
...
os.environ['HOME'] = '/tmp' which made everything work instantly (calling unoconv with apache user via moodle 3.1). |
The workaround from @hermannkm also works for me (after experiencing this error from the master version), but I think a simpler solution (albeit a bit clunky) is to delete the That worked for me, but I haven't able to replicate why. |
centos 7.3 nginx with php via php-fpm, the env in php is cleaned by php-fpm u can use putenv to set evn["PATH"] in php code, examples
or u can set env use one line shell cmd
or u can change php-fpm.d/www.conf to pass the env to php, add this line
and the restart php-fpm
|
The command /usr/bin/unoconv --debug -vvvv -f pdf /tmp/document-example.odt was a success with a common user but failed with user www-data (user of apache). |
Is it not feasible to set $HOME to something writeable for the script that calls unoconv? I'm not sure unoconv is the place to fix this, it's really a configuration error. But if we need to have unoconv work around this, making a temporary home seems the only solution. That seems both the wrong place and the wrong way to solve this, as we need to start and stop listeners and delete those directories a lot. A check that $HOME exists and is writeable and an error message if it isn't would make sense though. |
Hi, I resolve with Unotools. I hope that you helps others: https://pypi.python.org/pypi/unotools |
Hi,
So my problem was coming from JRE and www-data user. (I'm sorry if i haven't posted this in the right thread, but the issue was the same I think) |
When Open/LibreOffice runs, it looks for a folder containing user-specific configuration in the invoking user's home directory. If it cannot find it, Open/LibreOffice attempts to create it. For users running `unoconv` manually, this isn't a problem. For users attempting to run this on a webserver, the invoking user is the http daemon (e.g. `apache`, `nginx`, `lighttpd`), and the home folder is typically the webserver's root directory (e.g. `/srv/http`, `/var/www`). Unfortunately, there appear to be some scenarios where this folder is read-only, even for the daemon (see unoconv#87, unoconv#449). This leads to errors, as Open/LibreOffice is unable to create its configuration folder. (It is assumed that if the configuration folder already exists, it must be usable, else how would it have been created?) This commit solves the issue by detecting this, emitting a warning message, and using a temporary folder as a temporary "Home".
I traced the error to this bit of the code:
When running as root I get this:
Then running the same root through a webpage with apache, I get this:
So basically the try bit fails with apache but works as root. I suppose it might be a permissions issue, or something in the environment, but I haven't been able to find any info.
Thanks for your attention!
unoconv: Cannot find a suitable office installation on your system.
ERROR: Please locate your office installation and send your feedback to:
http://github.com/dagwieers/unoconv/issue
The text was updated successfully, but these errors were encountered: