~rdoering/ubuntu/karmic/erlang/fix-535090

« back to all changes in this revision

Viewing changes to lib/inets/src/http_server/mod_auth_dets.erl

  • Committer: Bazaar Package Importer
  • Author(s): Sergei Golovan
  • Date: 2009-02-15 16:42:52 UTC
  • mfrom: (3.1.2 squeeze)
  • Revision ID: james.westby@ubuntu.com-20090215164252-q5x4rcf8a5pbesb1
Tags: 1:12.b.5-dfsg-2
Upload to unstable after lenny is released.

Show diffs side-by-side

added added

removed removed

Lines of Context:
32
32
         delete_group/2,
33
33
         remove/1]).
34
34
 
35
 
-export([store_directory_data/2]).
 
35
-export([store_directory_data/3]).
36
36
 
37
37
-include("httpd.hrl").
38
38
-include("mod_auth.hrl").
39
39
 
40
 
store_directory_data(_Directory, DirData) ->
 
40
store_directory_data(_Directory, DirData, Server_root) ->
41
41
    ?CDEBUG("store_directory_data -> ~n"
42
42
            "     Directory: ~p~n"
43
43
            "     DirData:   ~p",
44
44
            [_Directory, DirData]),
45
45
 
46
 
    PWFile = proplists:get_value(auth_user_file, DirData),
47
 
    GroupFile = proplists:get_value(auth_group_file, DirData),
 
46
    {PWFile, Absolute_pwdfile} = absolute_file_name(auth_user_file, DirData,
 
47
                                                    Server_root),
 
48
    {GroupFile, Absolute_groupfile} = absolute_file_name(auth_group_file,
 
49
                                                         DirData, Server_root),
48
50
    Addr = proplists:get_value(bind_address, DirData),
49
51
    Port = proplists:get_value(port, DirData),
50
52
 
51
53
    PWName  = httpd_util:make_name("httpd_dets_pwdb",Addr,Port),
52
 
    case dets:open_file(PWName,[{type,set},{file,PWFile},{repair,true}]) of
 
54
    case dets:open_file(PWName,[{type,set},{file,Absolute_pwdfile},{repair,true}]) of
53
55
        {ok, PWDB} ->
54
56
            GDBName = httpd_util:make_name("httpd_dets_groupdb",Addr,Port),
55
 
            case dets:open_file(GDBName,[{type,set},{file,GroupFile},{repair,true}]) of
 
57
            case dets:open_file(GDBName,[{type,set},{file,Absolute_groupfile},{repair,true}]) of
56
58
                {ok, GDB} ->
57
59
                    NDD1 = lists:keyreplace(auth_user_file, 1, DirData, 
58
60
                                            {auth_user_file, PWDB}),
228
230
    dets:close(GDB),
229
231
    dets:close(PWDB),
230
232
    ok.
 
233
 
 
234
%% absolute_file_name/2
 
235
%%
 
236
%% Return the absolute path name of File_type. 
 
237
absolute_file_name(File_type, DirData, Server_root) ->
 
238
    Path = proplists:get_value(File_type, DirData),
 
239
    Absolute_path = case filename:pathtype(Path) of
 
240
                        relative ->
 
241
                            case Server_root of
 
242
                                undefined ->
 
243
                                    {error,
 
244
                                     ?NICE(Path++
 
245
                                           " is an invalid file name because "
 
246
                                           "ServerRoot is not defined")};
 
247
                                _ ->
 
248
                                    filename:join(Server_root,Path)
 
249
                            end;
 
250
                        _ ->
 
251
                            Path
 
252
                    end,
 
253
    {Path, Absolute_path}.
 
254