Hi, I'm trying to build a page "ConTeXt live" on a Apache web server with PHP. Here is the simple test ------------------------------------------------------------------------- \enableregime[utf] \setupencoding[default=t5] \usetypescript[berry][t5] \usetypescript[palatino][t5] \setupbodyfont[palatino,12pt] \starttext Hello, world! \stoptext --------------------------------------------------------------------------- This src file was saved into /tmp folder in which Apache user has full writing permission. I use PHP command: system("cd /tmp; texexec --pdf --silent test.tex"); Here is the log: ---------------------------------------------------------------------------------------------------------------------------- TeXExec 5.4.3 - ConTeXt / PRAGMA ADE 1997-2005 fixing engine variable : pdfetex executable : pdfetex format : cont-en inputfile : toto2 output : pdftex interface : en current mode : none TeX run : 1 This is pdfeTeX, Version 3.141592-1.30.4-2.2 (Web2C 7.5.5) \write18 enabled. (/usr/local/tetex/share/texmf-local/web2c/natural.tcx) entering extended mode (./toto2.tex ConTeXt ver: 2005.11.30 fmt: 2005.12.2 int: english mes: english language : language en is active system : cont-new loaded (/usr/local/tetex/share/texmf-local/tex/context/base/cont-new.tex systems : beware: some patches loaded from cont-new.tex color : palette rollover is available ) system : cont-old loaded (/usr/local/tetex/share/texmf-local/tex/context/base/cont-old.tex loading : Context Old Macros ) system : cont-fil loaded (/usr/local/tetex/share/texmf-local/tex/context/base/cont-fil.tex loading : Context File Synonyms ) system : cont-sys.rme loaded (/usr/local/tetex/share/texmf-local/tex/context/user/cont-sys.rme (/usr/local/tetex/share/texmf-local/tex/context/base/type-exa.tex) (/usr/local/tetex/share/texmf-local/tex/context/base/type-syn.tex) (/usr/local/tetex/share/texmf-local/tex/context/base/type-enc.tex) (/usr/local/tetex/share/texmf-local/tex/context/base/type-dis.tex) (/usr/local/tetex/share/texmf-local/tex/context/base/type-siz.tex) (/usr/local/tetex/share/texmf-local/tex/context/base/type-map.tex) (/usr/local/tetex/share/texmf-local/tex/context/base/type-spe.tex) (/usr/local/tetex/share/texmf-local/tex/context/base/type-akb.tex)) bodyfont : 12pt rm is loaded language : patterns nl->texnansi:texnansi->1->2:2 nl->ec:ec->2->2:2 fr-> texnansi:texnansi->3->2:2 fr->ec:ec->4->2:2 de->texnansi:texnansi->5->2:2 de->e c:ec->6->2:2 it->texnansi:texnansi->7->2:2 it->ec:ec->8->2:2 pt->texnansi:texna nsi->9->2:2 pt->ec:ec->10->2:2 hr->ec:ec->11->2:2 pl->pl0:pl0->12->2:2 pl->ec:e c->13->2:2 pl->qx:qx->14->2:2 cz->il2:il2->15->2:2 cz->ec:ec->16->2:2 sk->il2:i l2->17->2:2 sk->ec:ec->18->2:2 sl->il2:il2->19->2:2 sl->ec:ec->20->2:2 en->ec:e c->22->2:2 da->ec:ec->23->2:2 sv->ec:ec->24->2:2 af->ec:ec->25->2:2 no->ec:ec-> 26->2:2 deo->ec:ec->27->2:2 uk->ec:ec->28->2:2 us->ec:ec->29->2:2 es->ec:ec->30 ->2:2 ca->ec:ec->31->2:2 la->ec:ec->32->2:2 ro->ec:ec->33->2:2 tr->ec:ec->34->2 :2 fi->ec:ec->36->2:2 hu->ec:ec->37->2:2 loaded specials : tex,postscript,rokicki loaded system : toto2.top loaded (./toto2.top specials : loading definition file tpd (/usr/local/tetex/share/texmf-local/tex/context/base/spec-tpd.tex specials : loading definition file fdf (/usr/local/tetex/share/texmf-local/tex/context/base/spec-fdf.tex) specials : fdf loaded ) specials : fdf,tpd loaded ) ! I can't write on file `mpgraph.mp'. \initializeMPgraphicfile ...te \MPgraphicfile .mp \immediate \write \scratch... \initializeMPgraphics ...\initializeMPgraphicfile \fi \egroup ...e \checknotes \initializeMPgraphics \checkpreprocessor l.1 \enableregime[utf] Please type another output file name: ! Emergency stop. \initializeMPgraphicfile ...te \MPgraphicfile .mp \immediate \write \scratch... \initializeMPgraphics ...\initializeMPgraphicfile \fi \egroup ...e \checknotes \initializeMPgraphics \checkpreprocessor l.1 \enableregime[utf] No pages of output. Transcript written on toto2.log. return code : 256 run time : 1 seconds total run time : 2 seconds --------------------------- end of log ----------------------------------------------------------------------------------- In /tmp, I see files test.log, test.tmp, test.tui test-mpgraph.mp. I don't know where ConTeXt is trying to write the file "mpgraph.mp" ? Web server is running under apache/apache. I have no root's access in this server. I would like to hear from author of http://live.contextgarden.net specially. Thank you in advance, Regards, -- http://vnoss.org Vietnamese Open Source Software Community
VnPenguin wrote:
Hi, I'm trying to build a page "ConTeXt live" on a Apache web server with PHP. Here is the simple test ------------------------------------------------------------------------- \enableregime[utf] \setupencoding[default=t5]
\usetypescript[berry][t5] \usetypescript[palatino][t5] \setupbodyfont[palatino,12pt]
\starttext Hello, world! \stoptext ---------------------------------------------------------------------------
This src file was saved into /tmp folder in which Apache user has full writing permission. I use PHP command:
system("cd /tmp; texexec --pdf --silent test.tex");
it has to do with the tex distribution being configured as too paranoid which means no writing can you try the --notparanoid switch? Hans
On 12/2/05, Hans Hagen
it has to do with the tex distribution being configured as too paranoid which means no writing
can you try the --notparanoid switch?
Just added this option to texexec, but it does not help. The problem is still there. Thanks -- http://vnoss.org Vietnamese Open Source Software Community
VnPenguin wrote:
On 12/2/05, Hans Hagen
wrote: it has to do with the tex distribution being configured as too paranoid which means no writing
can you try the --notparanoid switch?
Just added this option to texexec, but it does not help. The problem is still there.
i remember sucn problems but forgot what the trick was; you can only sort out such things when you have access to the machine; the problem is in kpse sitting in between as patrick says, the problem is that - with immediate write 18 one can launch any program, the only way out of this is when one can only run scripts within the tree, but i don't see that happen (hard to get aggreement upon) - a more clever paranoid mode, where expanded paths are taken into account; for instance, if paranoid means that ../blabla or blabla.bla are looked at, it may mean that the period results in blocking, while actually the expanded path may still be within the tree actually, in the minimal distribution, such thinsg are taken care of: % resource paths, can be used in paranoid situations (can be env vars); there you find: TXRESOURCES=rubish MPRESOURCES=$TXRESOURCES MFRESOURCES=$MPRESOURCES % some extra paths for development trees (can be env vars) CTXDEVTXPATH=rubish CTXDEVMPPATH=rubish CTXDEVMFPATH=rubish TEXINPUTS.context = .;{$TXRESOURCES}//;{$CTXDEVTXPATH}//;$TEXMF/{pdftex,pdfetex,etex,xetex,omega,tex}/{context,plain,generic,}// MPINPUTS = .;{$MFRESOURCES}//;{$CTXDEVMPPATH}//;$TEXMF/metapost/{context,base,}// MFINPUTS = .;{$MPRESOURCES}//;{$CTXDEVMFPATH}//;$TEXMF/metafont/{context,base,}//;{$TEXMF/fonts,$VARTEXFONTS}/source// so, one can set the TXRESOURCE path (using texexec) and out of a sudden that path (which may lay outside the tree) is acceptable Hans
Hi, I have no idea what is wrong. But you can (remark on Hans' reply) set openout_any = p openin_any = p in texmf.cnf, that doesn't hurt. You should be extremly careful when interfacing TeX to the public. Patrick -- ConTeXt wiki and more: http://contextgarden.net
On 2 Dec 2005 15:21:45 +0100, Patrick Gundlach
Hi,
I have no idea what is wrong. But you can (remark on Hans' reply) set
openout_any = p
already defined in texmf.cnf
openin_any = p
in texmf.cnf, that doesn't hurt.
Changed & tried, but I have the same error.
You should be extremly careful when interfacing TeX to the public.
Thank you, -- http://vnoss.org Vietnamese Open Source Software Community
Hello,
Changed & tried, but I have the same error.
well, this was only some additional remarks. Perhaps you can use strace to find out why ConTeXt can't write mpgraph.mp? What does your cont-sys.tex look like? Do you have write18 enabled (disable it on the public webserver, of course!).
You should be extremly careful when interfacing TeX to the public.
with that I mean * use setrlimt * disable write18 * use openout=p, openin=p * hide other user's ConTeXt run by using sessions * use some kind of jail if possible * do some checking on user's input Unless you want to share your webserver with other people ;-) Patrick -- ConTeXt wiki and more: http://contextgarden.net
On 2 Dec 2005 16:17:33 +0100, Patrick Gundlach
Hello,
Changed & tried, but I have the same error.
well, this was only some additional remarks. Perhaps you can use strace to find out why ConTeXt can't write mpgraph.mp?
In my account, ConTeXt works no prob, I got a perfect PDF. My problem occurs when I run ConTeXt via web, under Apache's user of course. How to trace ConTeXt run under web server ?
What does your cont-sys.tex look like? Do you have write18 enabled (disable it on the public webserver, of course!).
No cont-sys.tex file on my ConTeXt installation. I have only texmf-local/tex/context/base/cont-sys.ori & texmf-local/tex/context/user/cont-sys.rme and they are original of distribution (exactly like http://source.contextgarden.net/tex/context/base/cont-sys.ori and http://source.contextgarden.net/tex/context/user/cont-sys.rme ) The \write18{} feature was disable on my system.
You should be extremly careful when interfacing TeX to the public.
with that I mean
* use setrlimt
Could you tell me more about this ? a TeX setting ? Apache setting ?
* disable write18
done
* use openout=p, openin=p
done
* hide other user's ConTeXt run by using sessions
yes
* use some kind of jail if possible
no, it's not possible in my case
* do some checking on user's input
Yes, you're right.
Unless you want to share your webserver with other people ;-)
No problem, but firstly I need a running ConTeXt via web :-) Thank you so much, Regards, -- http://vnoss.org Vietnamese Open Source Software Community
Hi,
In my account, ConTeXt works no prob, I got a perfect PDF. My problem occurs when I run ConTeXt via web, under Apache's user of course. How to trace ConTeXt run under web server ?
I'd guess it is pretty much impossible to trace under a webserver. Can you install the same environment on a local computer? Then you could strace any process.
No cont-sys.tex file on my ConTeXt installation. I have only texmf-local/tex/context/base/cont-sys.ori & texmf-local/tex/context/user/cont-sys.rme and they are original of distribution
As far as I know, cont-sys.ori or ...rme are used as a fallback. And the diff between the ones in the distribution and the one on live.contextgarden reveals no significant differences.
with that I mean
* use setrlimt
Could you tell me more about this ? a TeX setting ? Apache setting ?
Operating Sytem setting. You can use the setrlimit(2) system call to prevent users from using too many resources, such as disk space or cpu time or .... See manpage of setrlimit(2). This is why I have written a c-wrapper that runs texexec, so I can set those limits. I'd suggest to try to mimic the setup on a local pc and see if you can get it to work there. It saves so much trouble, because you can access every file/setting/... Perhaps this is a problem with php? Did you try running this via cgi? Patrick -- ConTeXt wiki and more: http://contextgarden.net
Patrick Gundlach wrote:
Hi,
In my account, ConTeXt works no prob, I got a perfect PDF. My problem occurs when I run ConTeXt via web, under Apache's user of course. How to trace ConTeXt run under web server ?
Reversing the order will hopefully give a clue on how to proceed: make ConTeXt create mpgraph.mp first, then the other one. If that gets you past the error (and into a similar error: test-mpgraph.mp), then it is probably a number of open files limit problem. Here is the relevant macro, with the order already adjusted : \def\initializeMPgraphics {\bgroup \ifx\bufferprefix\empty\else \let\bufferprefix\empty \initializeMPgraphicfile \fi \egroup \initializeMPgraphicfile }
I'd guess it is pretty much impossible to trace under a webserver. Can you install the same environment on a local computer? Then you could strace any process.
You can try to add --passon='-kpathsea-debug=4' in the texexec call. All the kpathsea debug output should end up in your apache error_log (the number 4 is for fopen/fclose traces).
Perhaps this is a problem with php? Did you try running this via cgi?
If you are lucky, there may be some hint in your global or local apache error file. Good luck, Taco
Patrick Gundlach wrote:
I'd guess it is pretty much impossible to trace under a webserver. Can
Why's that? Can't you just run strace -f -e open -o /tmp/mylog texexec ... instead of plain texexec? Sure, multiple runs will mean you only ever get to see the last log, but on a test system that should be exactly the one you are looking for. Oh, and I'll second Patrick's advice: Before letting unknown users run arbitrary programs on your machine (and TeX code provided by the user, even if it is just their names to be filled into some template, *does* qualify as “arbitrary programs”), make bloody sure those programs have no chance of ruining your server. Double-check the validity of all inputs, check if you can use a chroot “jail” and use the most paranoid TeX settings with which your setup/code still works. regards, Christopher
I'd guess it is pretty much impossible to trace under a webserver. Can
Why's that? Can't you just run strace -f -e open -o /tmp/mylog texexec ... instead of plain texexec?
You're right, of course. Patrick -- ConTeXt wiki and more: http://contextgarden.net
VnPenguin wrote:
On 2 Dec 2005 15:21:45 +0100, Patrick Gundlach
wrote: Hi,
I have no idea what is wrong. But you can (remark on Hans' reply) set
openout_any = p
already defined in texmf.cnf
openin_any = p
in texmf.cnf, that doesn't hurt.
Changed & tried, but I have the same error.
no, that should be 'a' and not 'p' (just for testing first) Hans
participants (5)
-
Christopher Creutzig
-
Hans Hagen
-
Patrick Gundlach
-
Taco Hoekwater
-
VnPenguin