-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy path00-updates.patch
221 lines (204 loc) · 6.74 KB
/
00-updates.patch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
Copyright (c) 2020 - 2024 Matthias Pressfreund
Permission to use, copy, modify, and distribute this software for any
purpose with or without fee is hereby granted, provided that the above
copyright notice and this permission notice appear in all copies.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
Index: usr.sbin/httpd/config.c
@@ -492,7 +492,12 @@
/* Inherit configuration from the parent */
f = SRVFLAG_INDEX|SRVFLAG_NO_INDEX;
if ((srv_conf->flags & f) == 0) {
- srv_conf->flags |= parent->flags & f;
+ /*
+ * Inherit index flags from parent server only if
+ * auto-index flag of location is not set
+ */
+ if ((srv_conf->flags & SRVFLAG_AUTO_INDEX) == 0)
+ srv_conf->flags |= parent->flags & f;
(void)strlcpy(srv_conf->index, parent->index,
sizeof(srv_conf->index));
}
Index: usr.sbin/httpd/httpd.8
@@ -1,5 +1,6 @@
.\" $OpenBSD: httpd.8,v 1.54 2022/10/24 15:02:01 jmc Exp $
.\"
+.\" Copyright (c) 2021 Matthias Pressfreund
.\" Copyright (c) 2014 Reyk Floeter <[email protected]>
.\"
.\" Permission to use, copy, modify, and distribute this software for any
@@ -41,6 +42,10 @@
.Dv SIGHUP
and reopens log files when it receives
.Dv SIGUSR1 .
+.Pp
+It is furthermore equipped with the additional functionality provided by the
+.Lk https://github.com/mpfr/httpd-plus httpd-plus
+add-on package.
.Pp
The options are as follows:
.Bl -tag -width Dssmacro=value
Index: usr.sbin/httpd/httpd.conf.5
@@ -1,5 +1,6 @@
.\" $OpenBSD: httpd.conf.5,v 1.125 2023/11/03 13:03:02 espie Exp $
.\"
+.\" Copyright (c) 2020 - 2022 Matthias Pressfreund
.\" Copyright (c) 2014, 2015 Reyk Floeter <[email protected]>
.\"
.\" Permission to use, copy, modify, and distribute this software for any
@@ -23,7 +24,10 @@
.Sh DESCRIPTION
.Nm
is the configuration file for the HTTP daemon,
-.Xr httpd 8 .
+.Xr httpd 8 ,
+which is equipped with the additional functionality provided by the
+.Lk https://github.com/mpfr/httpd-plus httpd-plus
+add-on package.
.Pp
.Nm
is divided into the following main sections:
@@ -866,6 +870,43 @@
request rewrite "/new/%1"
}
}
+.Ed
+.Pp
+The
+.Ic location not found
+option may be used to enable
+.Lk https://wordpress.org/support/article/using-permalinks/ WordPress Pretty Permalinks
+just like on an Apache web server with
+.Pa mod_rewrite
+installed.
+.Bd -literal -offset indent
+server "www.example.com" {
+ listen on * port www
+ directory index "index.php"
+
+ location not found "/*" {
+ request rewrite "/index.php"
+ }
+ location "/*.php" {
+ fastcgi socket "/run/php-fpm.sock"
+ }
+}
+.Ed
+.Pp
+WordPress, however, is unable to discover that
+.Xr httpd 8
+is now capable to perform required URL rewrites.
+This will make the
+.Lk https://wordpress.org/support/article/settings-permalinks-screen/ Permalink Settings Screen
+not behave as expected.
+Luckily, and for this case exactly, the
+.Lk https://developer.wordpress.org/reference/hooks/got_url_rewrite/ got_url_rewrite hook
+exists.
+Adding the following line of code into the current theme's
+.Pa functions.php
+file will straighten things out.
+.Bd -literal -offset indent
+add_filter('got_url_rewrite', '__return_true');
.Ed
.Sh SEE ALSO
.Xr htpasswd 1 ,
Index: usr.sbin/httpd/httpd.h
@@ -665,6 +665,9 @@
SPLAY_PROTOTYPE(client_tree, client, clt_nodes, server_client_cmp);
+#define open_server_root(srv_conf, mode) \
+ open(*(srv_conf)->root != '\0' ? (srv_conf)->root : "/", mode)
+
/* server_http.c */
void server_http_init(struct server *);
void server_http(void);
@@ -693,7 +696,6 @@
server_root_strip(const char *, int);
struct server_config *
server_getlocation(struct client *, const char *);
-int server_locationaccesstest(struct server_config *, const char *);
const char *
server_http_host(struct sockaddr_storage *, char *, size_t);
char *server_http_parsehost(char *, char *, size_t, int *);
Index: usr.sbin/httpd/server_file.c
@@ -218,10 +218,17 @@
struct server_config *srv_conf = clt->clt_srv_conf;
char path[PATH_MAX];
const char *stripped, *errstr = NULL;
- int ret = 500;
+ int ret = 500, rootfd;
if (srv_conf->flags & SRVFLAG_FCGI)
return (server_fcgi(env, clt));
+
+ /* If the server root is not accessible, we have a problem */
+ if ((rootfd = open_server_root(srv_conf, O_RDONLY)) == -1) {
+ errstr = srv_conf->root;
+ goto abort;
+ }
+ close(rootfd);
/* Request path is already canonicalized */
stripped = server_root_strip(
Index: usr.sbin/httpd/server_http.c
@@ -54,6 +54,8 @@
char *, size_t);
char *replace_var(char *, const char *, const char *);
char *read_errdoc(const char *, const char *);
+int server_locationaccesstest(struct server_config *,
+ const char *);
static struct http_method http_methods[] = HTTP_METHODS;
static struct http_error http_errors[] = HTTP_ERRORS;
@@ -1389,10 +1391,8 @@
goto fail;
/* Now search for the location */
- if ((srv_conf = server_getlocation(clt, desc->http_path)) == NULL) {
- server_abort_http(clt, 500, desc->http_path);
- return (-1);
- }
+ if ((srv_conf = server_getlocation(clt, desc->http_path)) == NULL)
+ goto rooterr;
/* Optional rewrite */
if (srv_conf->flags & SRVFLAG_PATH_REWRITE) {
@@ -1429,10 +1429,8 @@
/* Now search for the updated location */
if ((srv_conf = server_getlocation(clt,
- desc->http_path_alias)) == NULL) {
- server_abort_http(clt, 500, desc->http_path_alias);
- return (-1);
- }
+ desc->http_path_alias)) == NULL)
+ goto rooterr;
}
if (clt->clt_toread > 0 && (size_t)clt->clt_toread >
@@ -1454,6 +1452,11 @@
fail:
server_abort_http(clt, 400, "bad request");
return (-1);
+
+ rooterr: /* server root inaccessible */
+ srv_conf = clt->clt_srv_conf;
+ server_abort_http(clt, 500, srv_conf->root);
+ return (-1);
}
const char *
@@ -1524,7 +1527,8 @@
srv_conf->flags) == 0)
return (0);
- if ((rootfd = open(srv_conf->root, O_RDONLY)) == -1)
+ /* If the server root is not accessible, we have a problem */
+ if ((rootfd = open_server_root(srv_conf, O_RDONLY)) == -1)
return (-1);
path = server_root_strip(path, srv_conf->strip) + 1;
@@ -1758,8 +1762,8 @@
}
/*
- * return -1 on failure, strlen() of read file otherwise.
- * body is NULL on failure, contents of file with trailing \0 otherwise.
+ * return NULL if file does not exist or on failure,
+ * contents of file with trailing \0 otherwise.
*/
char *
read_errdoc(const char *root, const char *file)