0

I'm trying to install a shared MikTex on a Windows server 2012, so my web application (Perl CGI / IIS 8) can generate PDF files on the fly through pdflatex, and send them to the user.

I managed to install MikTex 2.9.6637 (x64) on the server through full download on another machine and transferring the files (the server has no web access), and it does work from the command line.

However I have trouble when I try to run my command from a Perl / CGI script from the webserver, when I configure IIS to use anonymous authentication through the windows account Network Service: access denied. When I use IIS windows authentication, and the script runs with my own windows account (admin), it runs fine. Definitely an access management problem.

I used the options found on this page

http://docs.miktex.org/2.9/manual/setupwiz.html

in order to configure all folders in a simple D:\miktex_local on which i can grant all privileges to this network service, instead of the default / folders. The only folder I did not manage to configure myself is the log directory that stays in: C:\ProgramData\MiKTeX\2.9\miktex\log But I granted privileges on this one, and it does not seem to be used even when I manage to generate the pdf.

My test script can write in these folders and logs are generated. I also test from the script that the user has r/w privileges on my in and out folders.

This is the log from a success run (admin user):

2018-03-29 14:14:48,797+0200 INFO  pdflatex - starting with command line: D:\miktex\miktex\bin\x64\pdflatex -output-directory=D:\test\out D:\test\in\token.tex
2018-03-29 14:14:48,797+0200 WARN  pdflatex - running with administrator privileges
2018-03-29 14:14:48,813+0200 INFO  pdflatex - allowing known shell commands
2018-03-29 14:14:48,813+0200 INFO  pdflatex - enabling input (output) from (to) processes
2018-03-29 14:14:48,813+0200 INFO  pdflatex - setting output directory: D:\test\out
2018-03-29 14:14:48,813+0200 INFO  pdflatex - setting aux directory: D:\test\out
2018-03-29 14:14:49,610+0200 INFO  pdflatex - finishing with exit code 0

This the log from a failed run (network service user):

2018-03-29 14:14:19,478+0200 INFO  pdflatex - starting with command line: D:\miktex\miktex\bin\x64\pdflatex -output-directory=D:\test\out D:\test\in\token.tex
2018-03-29 14:14:19,478+0200 INFO  pdflatex - allowing known shell commands
2018-03-29 14:14:19,478+0200 INFO  pdflatex - enabling input (output) from (to) processes
2018-03-29 14:14:19,478+0200 INFO  pdflatex - setting output directory: D:\test\out
2018-03-29 14:14:19,478+0200 INFO  pdflatex - setting aux directory: D:\test\out
2018-03-29 14:14:19,509+0200 FATAL pdflatex - Windows API error 5: Access is denied.
2018-03-29 14:14:19,509+0200 FATAL pdflatex - Info: path="D:\test\in\token.tex"
2018-03-29 14:14:19,509+0200 FATAL pdflatex - Source: Libraries\MiKTeX\Core\PathName\PathName.cpp
2018-03-29 14:14:19,509+0200 FATAL pdflatex - Line: 156
2018-03-29 14:14:19,509+0200 INFO  pdflatex - finishing with exit code 1

There seems to be an acces problem on some resource, but I can't figure out which. My test script running the command is allowed to read the content of the input .tex file, write in the output directory and the log directory, and pdflatex -help gives me no error.

I have already faced a very similar issue with TexLive, working fine when run under administrator account, but giving me a cryptic "fatal: Can't get long name for D:\texlive" when run under Network Service.

Any advice or pointers would be welcome, thanks in advance.

  • ask at the miktex issue tracker on github. – Ulrike Fischer Mar 29 '18 at 12:40
1

I got it. I believe the error to originate from the same issue as texlive, from this line:

DWORD len = GetLongPathNameW(this->ToWideCharString().c_str(), longPathName, _MAX_PATH);

Turns out I have to give relative paths to my pdflatex command, for some reason it does not support absolute paths when ran from this network service account. I moved my test/in and test/out in the wwwroot and it works after this small change: D:\miktex\miktex\bin\x64\pdflatex -output-directory=tex\out tex\in\token.tex

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.