3

I want to run a specific (perl) CGI script on my webserver. This works reasonable, but it would work immensely better if the CGI script would be running as the currently authenticated user.

Is there a way to do that, e.g. with a wrapper and sudo?

The virtualhost config is as follows:

    DocumentRoot /path/to/script
    <Directory /path/to/script>
            Options FollowSymLinks +ExecCGI
            AddHandler cgi-script .cgi

            AuthType Basic
            AuthName "Authenticate"

            # This authenticates against the local NIS
            PerlAuthenHandler Apache2::AuthenNIS
            PerlAuthzHandler Apache2::AuthzNIS
            PerlSetVar AllowAlternateAuth no

            Require valid-user
    </Directory>

1 Answer 1

1

What exactly is preventing your app from running this way?

It's possible to do what you're asking, but it might be a better use of your time to configure an environment where your app can run as the same user which owns the httpd processes.

You're just introducing more complexity to your environment which makes it more difficult to debug, secure, and manage.

Anyway, to answer your question: look into suEXEC -- http://httpd.apache.org/docs/2.0/suexec.html

Echoing the documentation, you're almost always better off not doing things this way.

2
  • I'm slightly familiar with suEXEC, but how can I use it to run as the current authenticated user?
    – dtech
    Sep 17, 2011 at 7:31
  • Marking as solved because suEXEC is probably the answer, just haven't had time for it yet.
    – dtech
    Oct 15, 2011 at 9:29

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .