Skip to content

Commit 5c3c546

Browse files
faalClaes Wikstrom
authored andcommitted
Yaws patch
Hi! Here is the patch, as promised. Not sure this solution is optimal but it should work. To be honest I've only done basic testing (bit tired by now..) so would be good if you could give it a run before you put it out. I checked out the 1.82 tag from github so that's the version you should apply the patch to. // Fabian From 4636b0d096a061a0af6c2034446926bdba4259ed Mon Sep 17 00:00:00 2001 From: Fabian Alenius <faal@faal.(none)> Date: Fri, 19 Jun 2009 01:17:44 +0200 Subject: [PATCH] Fixed backwards compatibility
1 parent 385ae07 commit 5c3c546

File tree

3 files changed

+36
-4
lines changed

3 files changed

+36
-4
lines changed

src/authmod_gssapi.erl

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,8 @@
8080
start/1,
8181
stop/0,
8282
auth/2,
83-
get_header/0
83+
get_header/0,
84+
out/1
8485
]).
8586

8687
-include("yaws.hrl").
@@ -124,6 +125,8 @@ stop() ->
124125
supervisor:terminate_child(?SUPERVISOR, ?SERVER),
125126
supervisor:delete_child(?SUPERVISOR, ?SERVER).
126127

128+
out(Arg) ->
129+
yaws_outmod:out(Arg).
127130

128131
auth(Arg, Auth) when is_record(Arg, arg),
129132
is_record(Auth, auth) ->

src/yaws_outmod.erl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
-export([out404/3,
1616
out404/1,
17-
out401/1,
17+
out/1,
1818
crashmsg/3]).
1919

2020

@@ -43,7 +43,7 @@ out404(Arg, GC, SC) ->
4343
%% a special page on 401's (it doesn't even have to be a 401)
4444

4545

46-
out401(_Arg) ->
46+
out(_Arg) ->
4747
{ehtml,
4848
[{html,[],
4949
[

src/yaws_server.erl

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1656,6 +1656,33 @@ is_redirect_map(Path, [E={Prefix, _URL, _AppendMode}|Tail]) ->
16561656
is_redirect_map(Path, Tail)
16571657
end.
16581658

1659+
%% Find out what which module to call when urltype is unauthorized
1660+
%% Precedence is:
1661+
%% 1. SC#errormod401 if it's not default
1662+
%% 2. First authdir which prefix the requested dir and has an authmod set
1663+
%% 3. yaws_outmod
1664+
1665+
get_unauthorized_outmod(_Req_dir, _Auth_dirs, Errormod401)
1666+
when Errormod401 /= yaws_outmod ->
1667+
Errormod401;
1668+
1669+
get_unauthorized_outmod(_Req_dir, [], Errormod401) ->
1670+
Errormod401;
1671+
1672+
get_unauthorized_outmod(Req_dir, [{Auth_dir, Auth}|T], Errormod401) ->
1673+
case lists:prefix(Auth_dir, Req_dir) of
1674+
true ->
1675+
case Auth#auth.mod /= [] of
1676+
true ->
1677+
Auth#auth.mod;
1678+
false ->
1679+
get_unauthorized_outmod(Req_dir, T, Errormod401)
1680+
end;
1681+
false ->
1682+
get_unauthorized_outmod(Req_dir, T, Errormod401)
1683+
end.
1684+
1685+
16591686

16601687
%% Return values:
16611688
%% continue, done, {page, Page}
@@ -1668,13 +1695,15 @@ handle_ut(CliSock, ARG, UT = #urltype{type = unauthorized}, N) ->
16681695
%% outh_set_dyn headers sets status to 200 by default
16691696
%% so we need to set it 401
16701697
yaws:outh_set_status_code(401),
1698+
Outmod = get_unauthorized_outmod(UT#urltype.path, SC#sconf.authdirs, SC#sconf.errormod_401),
1699+
16711700
deliver_dyn_part(CliSock,
16721701
0,
16731702
"appmod",
16741703
N,
16751704
ARG,
16761705
UT,
1677-
fun(A)->(SC#sconf.errormod_401):out401(A)
1706+
fun(A)->Outmod:out(A)
16781707
end,
16791708
fun(A)->finish_up_dyn_file(A, CliSock)
16801709
end);

0 commit comments

Comments
 (0)