File tree Expand file tree Collapse file tree 4 files changed +40
-5
lines changed Expand file tree Collapse file tree 4 files changed +40
-5
lines changed Original file line number Diff line number Diff line change @@ -1104,6 +1104,11 @@ public String getPath() {
11041104 return path ;
11051105 }
11061106
1107+ public boolean isUnreadable () {
1108+ File f = new File (getSourceRootPath (), getPath ());
1109+ return f .exists () && !f .canRead ();
1110+ }
1111+
11071112 /**
11081113 * Get the on disk file for the given path.
11091114 *
Original file line number Diff line number Diff line change 268268 <error-code >404</error-code >
269269 <location >/enoent</location >
270270 </error-page >
271+ <error-page >
272+ <error-code >403</error-code >
273+ <location >/eforbidden</location >
274+ </error-page >
271275 <error-page >
272276 <error-code >500</error-code >
273277 <location >/error</location >
Original file line number Diff line number Diff line change @@ -16,17 +16,37 @@ information: Portions Copyright [yyyy] [name of copyright owner]
1616
1717CDDL HEADER END
1818
19- Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
19+ Copyright (c) 2017, 2021, Oracle and/or its affiliates. All rights reserved.
2020Portions Copyright (c) 2018, Chris Fraire <[email protected] >. 2121--%>
22- <%@page session =" false" import =" org.opengrok.web.PageConfig" %>
22+ <%@page contentType =" text/html; charset=UTF-8" pageEncoding =" UTF-8" %>
23+ <%@page session =" false" import =" org.opengrok.web.PageConfig" %>
24+ <%@ page import =" jakarta.servlet.http.HttpServletResponse" %>
2325<%
24- /* ---------------------- eforbidden.jspf start --------------------- */
26+ /* ---------------------- eforbidden.jsp start --------------------- */
2527{
2628 response. setStatus(HttpServletResponse . SC_FORBIDDEN );
27- % >
29+ % ><% @
30+
31+ include file= " httpheader.jspf"
32+
33+ % > <body >
34+ <div id =" page" >
35+ <div id =" whole_header" >
36+ <div id =" header" ><% @
37+
38+ include file= " pageheader.jspf"
39+
40+ % > </div >
41+ </div >
42+ <h3 class =" error" >Error: access forbidden</h3 >
43+ <p >The request was forbidden. This can be either file/directory permissions problem or insufficient authorization.</p >
2844<%= PageConfig . get(request). getEnv(). getIncludeFiles(). getForbiddenIncludeFileContent(false ) % >
2945<%
3046}
31- /* ---------------------- eforbidden.jspf end --------------------- */
47+ /* ---------------------- eforbidden.jsp end --------------------- */
48+ % ><% @
49+
50+ include file= " foot.jspf"
51+
3252% >
Original file line number Diff line number Diff line change @@ -34,10 +34,16 @@ org.opengrok.web.PageConfig,
3434org.opengrok.indexer.web.Prefix,
3535org.opengrok.indexer.web.Util"%>
3636<%@ page import =" org.opengrok.indexer.web.messages.MessagesUtils" %>
37+ <%@ page import =" jakarta.servlet.http.HttpServletResponse" %>
3738<%
3839/* ---------------------- mast.jsp start --------------------- */
3940{
4041 PageConfig cfg = PageConfig . get(request);
42+ if (cfg. isUnreadable()) {
43+ response. sendError(HttpServletResponse . SC_FORBIDDEN );
44+ return ;
45+ }
46+
4147 String redir = cfg. canProcess();
4248 if (redir == null || redir. length() > 0 ) {
4349 if (redir == null ) {
You can’t perform that action at this time.
0 commit comments