Erlang/OTP Forums

Author Message

<  Yaws mailing list  ~  ScriptAlias equivalent?

Guest
Posted: Wed Nov 08, 2006 4:16 am Reply with quote
Guest
How do you guys normally handle the equivalent of ScriptAlias
directives in Apache? Can this be done with appmods and call_cgi
perhaps?

--
Cheers, L
Guest
Posted: Wed Nov 08, 2006 8:53 pm Reply with quote
Guest
Okay, I'll try a more specific question. Has anyone gotten GNU
Mailman (list manager) to run under Yaws? On my Debian system, MM
installed the cgi progs in /usr/lib/cgi-bin/mailman/. In this
directory are a number of compiled C executables, with names like
'listinfo', 'subscribe', 'admin', etc. They don't have suffixes like
".cgi" and never will because the code expects them to be named as
they are. How do I tell Yaws that these files are to be executed as
cgi?

On 11/7/06, Count L
Guest
Posted: Wed Nov 08, 2006 10:12 pm Reply with quote
Guest
Have you tried symlinks ?

~M

On Wed, Nov 08, 2006 at 01:50:45PM -0700, Count L
Guest
Posted: Wed Nov 08, 2006 10:34 pm Reply with quote
Guest
What kind of symlinks? I did try ln -s /usr/lib/cgi-bin/mailman
/www/root/lists, so that I could access http://site.com/lists/foo, but
still foo is not processed as a cgi.

Is there no way in Yaws to say "this file is a CGI, so execute it",
even if it doesn't end in .cgi, ,php, or .yaws?

On 11/8/06, Michael McDaniel <yaws@autosys.us> wrote:
> Have you tried symlinks ?
>
> ~M
>
> On Wed, Nov 08, 2006 at 01:50:45PM -0700, Count L
Guest
Posted: Wed Nov 08, 2006 10:51 pm Reply with quote
Guest
Count László de Almásy schrieb:
> Okay, I'll try a more specific question. Has anyone gotten GNU
> Mailman (list manager) to run under Yaws? On my Debian system, MM
> installed the cgi progs in /usr/lib/cgi-bin/mailman/. In this
> directory are a number of compiled C executables, with names like
> 'listinfo', 'subscribe', 'admin', etc. They don't have suffixes like
> ".cgi" and never will because the code expects them to be named as
> they are.

There is a configuration option for Mailman to have extensions on these
files. Works for me.

> How do I tell Yaws that these files are to be executed as
> cgi?
>
> On 11/7/06, Count László de Almásy <calmasy@gmail.com> wrote:
>> How do you guys normally handle the equivalent of ScriptAlias
>> directives in Apache? Can this be done with appmods and call_cgi
>> perhaps?

Something like that could also be cooked up. I even have a situation in
which I call cgis that live at a completely differnent place and I
postprocess their output.

hth

Carsten

--
Carsten Schultz (2:38, 33:47)
http://carsten.codimi.de/
PGP/GPG key on the pgp.net key servers,
fingerprint on my home page.


-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
Erlyaws-list mailing list
Erlyaws-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/erlyaws-list

Post recived from mailinglist
Guest
Posted: Wed Nov 08, 2006 11:03 pm Reply with quote
Guest
On Wed, Nov 08, 2006 at 03:32:32PM -0700, Count L
Guest
Posted: Thu Nov 09, 2006 4:08 am Reply with quote
Guest
On 11/8/06, Michael McDaniel <erlangx@autosys.us> wrote:
> Have you tried making a symlink with the the target name ending
> in .cgi ? Perhaps yaws will then treat it as an executable cgi.

That's sort of a kludgey hack though, isn't it? I'd rather not resort
to that unless it's a last option.

--
Cheers, L
Guest
Posted: Thu Nov 09, 2006 4:16 am Reply with quote
Guest
On 11/8/06, Carsten Schultz <carsten@codimi.de> wrote:

> There is a configuration option for Mailman to have extensions on these
> files. Works for me.

Yes, except that users expect the URLs to not have extensions on them.
They have subscription notices saved with paths that I'd rather not
break. Of course I could do extensions and then rewrites from the old
URLs, but why should I have to?

> Something like that could also be cooked up. I even have a situation in
> which I call cgis that live at a completely differnent place and I
> postprocess their output.

Keep in mind that I'm still very new to Yaws, but it seems like there
should be an appmods solution to mimic what ScriptAlias does. Like in
my case, I might have in my yaws.conf:

appmods = </lists , scriptalias>

And then scriptalias.erl would possibly be able to mark the files in
/usr/lib/cgi-bin/mailman/* as cgi programs. Then when a users
requests http://site.com/lists/listinfo, things are handled correctly.
I do see mention of a "call_cgi" in the yaws_api man page:

call_cgi(Arg, Scriptfilename)
Calls an executable CGI script, given by its full path. Used to
make `.yaws' wrappers for CGI programs. This function usually
returns streamcontent.

Though it's not clear to me how exactly this can/should be used.

--
Cheers, L
Guest
Posted: Thu Nov 09, 2006 6:49 am Reply with quote
Guest
Count László de Almásy schrieb:
> On 11/8/06, Carsten Schultz <carsten@codimi.de> wrote:
>
>> There is a configuration option for Mailman to have extensions on these
>> files. Works for me.
>
> Yes, except that users expect the URLs to not have extensions on them.
> They have subscription notices saved with paths that I'd rather not
> break. Of course I could do extensions and then rewrites from the old
> URLs, but why should I have to?

Everyone has their own priorities Smile

>> Something like that could also be cooked up. I even have a situation in
>> which I call cgis that live at a completely differnent place and I
>> postprocess their output.
>
> Keep in mind that I'm still very new to Yaws, but it seems like there
> should be an appmods solution to mimic what ScriptAlias does.

I attach an old appmod that I have found on my hard drive. Iirc, I used
it even before cgi support was fully integrated into yaws. I do not
know if it works with a current version of yaws, you will have to use it
as an example.

It implements a directory in which everything with a certain extension
(which can be empty) is called as a cgi script. It is configured via
variables in yaws.conf, these are `cgidir' and `cgiext'.

> Like in
> my case, I might have in my yaws.conf:
>
> appmods = </lists , scriptalias>
>
> And then scriptalias.erl would possibly be able to mark the files in
> /usr/lib/cgi-bin/mailman/* as cgi programs. Then when a users
> requests http://site.com/lists/listinfo, things are handled correctly.
> I do see mention of a "call_cgi" in the yaws_api man page:
>
> call_cgi(Arg, Scriptfilename)
> Calls an executable CGI script, given by its full path. Used to
> make `.yaws' wrappers for CGI programs. This function usually
> returns streamcontent.
>
> Though it's not clear to me how exactly this can/should be used.

Is the example sufficiently clear?

Carsten

--
Carsten Schultz (2:38, 33:47)
http://carsten.codimi.de/
PGP/GPG key on the pgp.net key servers,
fingerprint on my home page.


Post recived from mailinglist
Guest
Posted: Thu Nov 09, 2006 9:18 pm Reply with quote
Guest
Veddy interesting --

http://www.erlang.org/doc/doc-5.5.2/lib/inets-4.7.6/doc/html/mod_alias.html

--
Cheers, L
noss
Posted: Thu Nov 09, 2006 9:35 pm Reply with quote
User Joined: 09 Oct 2005 Posts: 290
Notice that it is not yaws. It is another web server that comes with erlang/otp.

On 11/9/06, Count László de Almásy <calmasy@gmail.com> wrote:
> Veddy interesting --
>
> http://www.erlang.org/doc/doc-5.5.2/lib/inets-4.7.6/doc/html/mod_alias.html
-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
Erlyaws-list mailing list
Erlyaws-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/erlyaws-list

Post recived from mailinglist
View user's profile Send private message
Guest
Posted: Fri Nov 10, 2006 8:03 am Reply with quote
Guest
Yeah, I see that, but perhaps Yaws could borrow this idea/code in
order to support alias/scriptalias.

On 11/9/06, Christian S <chsu79@gmail.com> wrote:
> Notice that it is not yaws. It is another web server that comes with erlang/otp.
>
> On 11/9/06, Count L
Guest
Posted: Sat Nov 11, 2006 6:31 am Reply with quote
Guest
On 11/8/06, Carsten Schultz <carsten@codimi.de> wrote:
> I attach an old appmod that I have found on my hard drive. Iirc, I used
> it even before cgi support was fully integrated into yaws. I do not
> know if it works with a current version of yaws, you will have to use it
> as an example.
>
> It implements a directory in which everything with a certain extension
> (which can be empty) is called as a cgi script. It is configured via
> variables in yaws.conf, these are `cgidir' and `cgiext'.

[...]

> Is the example sufficiently clear?

Not completely no, but that's only becauase I'm stilll learning
Erlang. Before I saw this message I had written a simple module to
attempt to handle Mailman's cgi-bin programs.

In yaws.conf:

appmods = </lists, mailman>

Which I expect to handle URLs like:

http://site.com/lists/listinfo
http://site.com/lists/listinfo/foobar-dev
http://site.com/lists/options/foobar-dev/calmasy%40gmail.com
etc..

Only the first part of the path after 'lists' is the cgi-bin
executable. In the above cases, 'listinfo' is
/usr/lib/cgi-bin/mailman/listinfo and 'options' is
/usr/lib/cgi-bin/mailman/options. The parts of the URL following
those are just arguments to the CGI I guess (sorry, not that familiar
with how CGI works).

So I wrote a simple mailman.erl:

-module(mailman).
-include("../include/yaws_api.hrl").
-compile(export_all).

out(Arg) ->
Req = Arg#arg.req,
{abs_path, Path} = Req#http_request.path,
Script = Arg#arg.appmoddata,
yaws_cgi:call_cgi(Arg, "/usr/lib/cgi-bin/mailman/" ++ Script).

This correctly handles the first example URL above (lists/listinfo)
but not the others. I guess I'm not understanding how to pass
arguments to the CGI ('foobar-dev' and
'foobar-dev/calmasy%40gmail.com' in the above examples), because
doesn't call_cgi just accept Arg and the full path to the executable?
How do I pass on the remainer of the URL?

--
Cheers, L
Guest
Posted: Sat Nov 11, 2006 7:49 am Reply with quote
Guest
Hi!

Count László de Almásy schrieb:
> On 11/8/06, Carsten Schultz <carsten@codimi.de> wrote:
>> I attach an old appmod that I have found on my hard drive. Iirc, I used
>> it even before cgi support was fully integrated into yaws. I do not
>> know if it works with a current version of yaws, you will have to use it
>> as an example.
>>
>> It implements a directory in which everything with a certain extension
>> (which can be empty) is called as a cgi script. It is configured via
>> variables in yaws.conf, these are `cgidir' and `cgiext'.
>
> [...]
>
>> Is the example sufficiently clear?
>
> Not completely no, but that's only becauase I'm stilll learning
> Erlang. Before I saw this message I had written a simple module to
> attempt to handle Mailman's cgi-bin programs.
>
> In yaws.conf:
>
> appmods = </lists, mailman>
>
> Which I expect to handle URLs like:
>
> http://site.com/lists/listinfo
> http://site.com/lists/listinfo/foobar-dev
> http://site.com/lists/options/foobar-dev/calmasy%40gmail.com
> etc..
>
> Only the first part of the path after 'lists' is the cgi-bin
> executable. In the above cases, 'listinfo' is
> /usr/lib/cgi-bin/mailman/listinfo and 'options' is
> /usr/lib/cgi-bin/mailman/options. The parts of the URL following
> those are just arguments to the CGI I guess (sorry, not that familiar
> with how CGI works).

Ah, I know the feeling of learning several things at once :-)

The term for this argument is `pathinfo'.

> So I wrote a simple mailman.erl:
>
> -module(mailman).
> -include("../include/yaws_api.hrl").
> -compile(export_all).
>
> out(Arg) ->
> Req = Arg#arg.req,
> {abs_path, Path} = Req#http_request.path,
> Script = Arg#arg.appmoddata,
> yaws_cgi:call_cgi(Arg, "/usr/lib/cgi-bin/mailman/" ++ Script).
>
> This correctly handles the first example URL above (lists/listinfo)
> but not the others. I guess I'm not understanding how to pass
> arguments to the CGI ('foobar-dev' and
> 'foobar-dev/calmasy%40gmail.com' in the above examples), because
> doesn't call_cgi just accept Arg and the full path to the executable?
> How do I pass on the remainer of the URL?
>

If I am reading the source correctly, you want to call eg

yaws_cgi:call_cgi(Arg,
undefined,
"/usr/lib/cgi-bin/mailman/listinfo",
"/foobar-dev")

Since the easy example worked, this will hopefully also work, although I
am not sure if all variables will be set correctly.

Best,

Carsten

--
Carsten Schultz (2:38, 33:47)
http://carsten.codimi.de/
PGP/GPG key on the pgp.net key servers,
fingerprint on my home page.


-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
Erlyaws-list mailing list
Erlyaws-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/erlyaws-list

Post recived from mailinglist
Guest
Posted: Sat Nov 11, 2006 9:30 pm Reply with quote
Guest
On 11/11/06, Carsten Schultz <carsten@codimi.de> wrote:
> If I am reading the source correctly, you want to call eg
>
> yaws_cgi:call_cgi(Arg,
> undefined,
> "/usr/lib/cgi-bin/mailman/listinfo",
> "/foobar-dev")
>
> Since the easy example worked, this will hopefully also work, although I
> am not sure if all variables will be set correctly.

Thanks for your help. I rewrote mailman.erl as follows and it seems
to work! What does 'undefined' mean btw?

-include("../include/yaws_api.hrl").
-compile(export_all).

out(Arg) ->
Req = Arg#arg.req,
{abs_path, Path} = Req#http_request.path,
{Cgi, Cgiarg} = splitpath(Path),

case {Cgi, Cgiarg} of
{nocgi, nocgiarg} ->
{redirect_local, "/lists/listinfo"};
{Cgi, nocgiarg} ->
yaws_cgi:call_cgi(Arg,
undefined,
"/usr/lib/cgi-bin/mailman/" ++ Cgi);
{Cgi, Cgiarg} ->
yaws_cgi:call_cgi(Arg,
undefined,
"/usr/lib/cgi-bin/mailman/" ++ Cgi,
"/" ++ Cgiarg)
end.


splitpath(Path) ->
match(regexp:split(Path, "\/")).

match({ok, [[], _]}) ->
{nocgi, nocgiarg};
match({ok, [[], _, []]}) ->
{nocgi, nocgiarg};
match({ok, [[], _, Cgi]}) ->
{Cgi, nocgiarg};
match({ok, [[], _, Cgi, []]}) ->
{Cgi, nocgiarg};
match({ok, [[], _, Cgi, Cgiarg]}) ->
{Cgi, Cgiarg};
match({ok, [[], _, Cgi, Cgiarg, []]}) ->
{Cgi, Cgiarg};
match({ok, [[], _, Cgi|Cgiarg]}) ->
{Cgi, filename:join(Cgiarg)}.

--
Cheers, L

Display posts from previous:  

All times are GMT
Page 1 of 2
Goto page 1, 2  Next
This forum is locked: you cannot post, reply to, or edit topics.

Jump to:  

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum