06. Perl and PerlIS isapi dll

What is ISAPI and how does it differ from standard CGI ?

In ISAPI which is a microsoft server specific standard there is no concept of a separate executable

Instead there is a dll (in our case perlis.dll) which gets loaded into the address space of the server

So when a request comes in to interpret a perl script there is no need to spawn a new executable which is a

costly process on NT but the In-process dll does the interpretation.Sounds like a good idea,however there are minor

differences which can cause major frustrations.

What is PerlIS?

PerlIS is a high performance perl interpreter for the Microsoft Internet Information Server.

The Microsoft Internet Information Server uses an API called ISAPI.

PerlIS.dll uses this API to improve efficiency.

Microsoft IIS uses a single thread per request, so requests use less resources, and take less time.

How do I run a CGI-script using PerlIS?

The Release Version of Microsoft's Internet Information Server does support

associations. If there were no errors during the

install procedure, then all you will need to do to run a perl cgi-script,

is to reference it directly in the URL

e.g

http://www.myhost.com/cgi-bin/myscript.plx

if .plx was the extension you chose to use as the association during

installation of perlis.

What does PerlIS do with errors?

The first error PerlIS encounters after loading, causes an entry to be added

to the server's eventlog. This entry points to a text

file that will contain any further errors. Any output to stderr is also

written to this log file. This file is generally stored in the

same directory as PerlIS.dll.

What doesn't work with PerlIS?

Since Perl scripts run by PerlIS are run in the same process space as the

Internet Information Server, there are a few

process-related calls that are broken in PerlIS.

Here is the current list:

Current working directory:

The Current working directory of the perl script being executed is the

working directory of the web server. This should

NOT be changed by the perl script as this will affect all other perl

scripts running with the server. Perl scripts that

will be run with PerlIS will require absolute pathnames.

The above information has come into doubt.I'd be happy if someone could check this out.

Shell escapes:

None of the shell escape or process spawing calls will work unless the

IUSR_HOSTNAME account has all needed permissions

This includes but is not limited to:

  1. System (This can work if permissions are set correctly)
  2. Backticks
  3. NTSpawn
  4. Exec and it's entire family.

Needed permissions may include read permissions to windows and system or system32 directories.

Where are the enviroment variables ?

In order to save script execution time the ENV array is a magic hashthat is

not built at startup but rather as queries are made to it. This saves

startup time on small/medium scripts and very few scripts require the entire

ENV hash. Since the left side of the environment string array

(i.e. =) is constant during each invocation of the IIS ActiveState felt that the delayed building of the environment hash would be a fair

trade for the improved startup time of the script.

Debugging tip

If you feel that your script is not executing and permissions are not correctly set

(for Nt users only) you can use the Event Log to advantage.

Just choose to log all events in the security log options

and then check the log to see what is the cause of the permissions problem.