[erlang-questions] inets mod_get mishandles inaccessible files (Paul Fisher)

Paul Fisher pfisher@REDACTED
Fri May 9 16:01:34 CEST 2008


On Fri, 2008-05-09 at 15:45 +0200, Ingela Anderton Andin wrote:
> Thank you for pointing this out.
> I do however not think that any non-trivial patch will be needed. This 
> should do the trick:
> 
> --- mod_get.erl@@/inets-5.0.8   2008-02-07 09:57:55.000000000 +0100
> +++ mod_get.erl 2008-05-09 15:30:54.000000000 +0200
> @@ -52,18 +52,17 @@
>      ?DEBUG("do_get -> Request URI: ~p",[Info#mod.request_uri]),
>      Path = mod_alias:path(Info#mod.data, Info#mod.config_db,
>                           Info#mod.request_uri),
> -    {FileInfo, LastModified} = get_modification_date(Path),
> -
> -    send_response(Info#mod.socket,Info#mod.socket_type, Path, Info,
> -                 FileInfo, LastModified).
> +
> +    send_response(Info#mod.socket,Info#mod.socket_type, Path, Info).
> 
> 
>  %% The common case when no range is specified
> -send_response(_Socket, _SocketType, Path, Info, FileInfo, LastModified)->
> +send_response(_Socket, _SocketType, Path, Info)->
>      %% Send the file!
>      %% Find the modification date of the file
>      case file:open(Path,[raw,binary]) of
>         {ok, FileDescriptor} ->
> +           {FileInfo, LastModified} = get_modification_date(Path),
>             ?DEBUG("do_get -> FileDescriptor: ~p",[FileDescriptor]),
>             Suffix = httpd_util:suffix(Path),
>             MimeType = httpd_util:lookup_mime_default(Info#mod.config_db,

Thanks! That makes sense and handles all of the missing and inaccessible
(permissions) cases.  A shame that the equivalent of fstat() is not
available through the file module, but I understand that not all io
devices would have sane values.


> > [08/May/2008:21:47:08 -0500], traverse exit from apply: mod_get:do => 
> > {{badmatch,{error,enoent}},
> >  [{mod_get,get_modification_date,1},
> >   {mod_get,do_get,1},
> >
> > ?Apparently mod_get:do_get/1 (and associated functions) is not prepared
> > to get {error, enoent} back from mod_alias:path/3, 
> It does not get {error, enoent} from mod_alias:path/3. The badmatch 
> occurs in the function
> get_modification_date.

Of course you are correct... must have been too late when I ran into
this and wrote the note.


-- 
paul




More information about the erlang-questions mailing list