tosijs-ui 1.16.26 → 1.16.27
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +20 -0
- package/bin/caddy-install.ts +49 -2
- package/deploy/Caddyfile +4 -2
- package/dist/iife.js +2 -2
- package/dist/iife.js.map +2 -2
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/llms.txt +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,25 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 1.16.27
|
|
4
|
+
|
|
5
|
+
### Deploy
|
|
6
|
+
|
|
7
|
+
- **`tosijs-caddy-install --go` installs a Caddyfile Caddy can read** (affected: 1.10.0 to
|
|
8
|
+
1.16.26). It installed the file readable by root only, so a Caddy running as its own user
|
|
9
|
+
(Debian's package does) refused the reload. Caddy kept serving the old config, the new file
|
|
10
|
+
stayed on disk, and the bin said "Nothing was installed", so the next restart would have
|
|
11
|
+
taken down every site on the box. The file is now mode `640` with the group systemd runs
|
|
12
|
+
Caddy as, or `600` when Caddy runs as root; it holds both keys, so never world-readable.
|
|
13
|
+
**If you ran `--go` with an affected version, re-run it.**
|
|
14
|
+
- **The installer starts a stopped Caddy** instead of failing to reload it, and if Caddy
|
|
15
|
+
refuses the new config it puts the previous one back and exits non-zero.
|
|
16
|
+
- **The installer refuses a `PREVIEW_TOKEN`** containing anything but letters, digits, `-` and
|
|
17
|
+
`_`. It goes into the gate's cookie regex, where a `.` loosened the match.
|
|
18
|
+
- **The preview gate matches a key cookie exactly** (affected: 1.9.0 to 1.16.26; the edit
|
|
19
|
+
cookie since 1.16.26). It matched by prefix, so `tosi_edit=<key>x` passed. That still
|
|
20
|
+
required the whole key, but the dev servers compare exactly and the gate now agrees with
|
|
21
|
+
them. Re-run the installer to pick it up.
|
|
22
|
+
|
|
3
23
|
## 1.16.26
|
|
4
24
|
|
|
5
25
|
### Tunnel
|
package/bin/caddy-install.ts
CHANGED
|
@@ -120,6 +120,12 @@ if [ ! -f /etc/caddy/preview.env ]; then
|
|
|
120
120
|
fi
|
|
121
121
|
set -a; . /etc/caddy/preview.env; set +a
|
|
122
122
|
: "\${PREVIEW_TOKEN:?set PREVIEW_TOKEN in /etc/caddy/preview.env}"
|
|
123
|
+
# It goes into a sed replacement and into the gate's cookie regex, where \`.\` would loosen the
|
|
124
|
+
# match and \`|\` would break the substitution.
|
|
125
|
+
if ! printf '%s' "$PREVIEW_TOKEN" | grep -qE '^[A-Za-z0-9_-]+$'; then
|
|
126
|
+
echo "PREVIEW_TOKEN may contain only letters, digits, - and _ — refusing to install." >&2
|
|
127
|
+
exit 1
|
|
128
|
+
fi
|
|
123
129
|
: "\${ACME_EMAIL:?set ACME_EMAIL in /etc/caddy/preview.env}"
|
|
124
130
|
: "\${PREVIEW_DOMAIN:?set PREVIEW_DOMAIN in /etc/caddy/preview.env}"
|
|
125
131
|
|
|
@@ -155,12 +161,53 @@ caddy validate --config /etc/caddy/Caddyfile.new
|
|
|
155
161
|
if [ "${go ? '1' : '0'}" = "1" ]; then
|
|
156
162
|
# Keep the outgoing config. This replaces a file that may be serving OTHER sites, and
|
|
157
163
|
# "validated" only means it parses — it does not mean it is the config you wanted.
|
|
164
|
+
had_config=0
|
|
158
165
|
if [ -f /etc/caddy/Caddyfile ]; then
|
|
159
166
|
cp -p /etc/caddy/Caddyfile /etc/caddy/Caddyfile.bak
|
|
167
|
+
had_config=1
|
|
168
|
+
fi
|
|
169
|
+
# Readable by the group Caddy runs as, and by nobody else: the file holds both keys.
|
|
170
|
+
# umask 077 left it root-only, and Debian's Caddy runs as its own user, so the reload failed
|
|
171
|
+
# reading it with the new file already in place (the maintainer's box, 1.16.26). Ask systemd
|
|
172
|
+
# who that is rather than guess; a Caddy run as root needs no group.
|
|
173
|
+
caddy_group=$(systemctl show -p Group --value caddy)
|
|
174
|
+
if [ -z "$caddy_group" ]; then
|
|
175
|
+
caddy_user=$(systemctl show -p User --value caddy)
|
|
176
|
+
if [ -n "$caddy_user" ] && [ "$caddy_user" != root ]; then
|
|
177
|
+
caddy_group=$(id -gn "$caddy_user")
|
|
178
|
+
fi
|
|
179
|
+
fi
|
|
180
|
+
if [ -n "$caddy_group" ]; then
|
|
181
|
+
chgrp "$caddy_group" /etc/caddy/Caddyfile.new
|
|
182
|
+
chmod 640 /etc/caddy/Caddyfile.new
|
|
183
|
+
else
|
|
184
|
+
chmod 600 /etc/caddy/Caddyfile.new
|
|
160
185
|
fi
|
|
161
186
|
mv /etc/caddy/Caddyfile.new /etc/caddy/Caddyfile
|
|
162
|
-
|
|
163
|
-
|
|
187
|
+
# A stopped Caddy cannot reload. Start it instead, or a box left down by the bug above could
|
|
188
|
+
# never be repaired by re-running this.
|
|
189
|
+
if systemctl is-active --quiet caddy; then
|
|
190
|
+
verb=reload
|
|
191
|
+
else
|
|
192
|
+
verb=start
|
|
193
|
+
fi
|
|
194
|
+
if ! systemctl "$verb" caddy; then
|
|
195
|
+
# A refused reload leaves Caddy serving what it had, but its next restart reads this file.
|
|
196
|
+
if [ "$had_config" = 1 ]; then
|
|
197
|
+
# Not \`cp -p\`: copying ONTO the installed file keeps its mode and group, and the
|
|
198
|
+
# previous file may be one an affected version left root-only.
|
|
199
|
+
cp /etc/caddy/Caddyfile.bak /etc/caddy/Caddyfile
|
|
200
|
+
echo "caddy refused to $verb with the new config; restored the previous /etc/caddy/Caddyfile." >&2
|
|
201
|
+
else
|
|
202
|
+
rm -f /etc/caddy/Caddyfile
|
|
203
|
+
echo "caddy refused to $verb with the new config; removed it." >&2
|
|
204
|
+
fi
|
|
205
|
+
if [ "$verb" = start ]; then
|
|
206
|
+
echo "caddy is not running. \`systemctl status caddy\` says why." >&2
|
|
207
|
+
fi
|
|
208
|
+
exit 1
|
|
209
|
+
fi
|
|
210
|
+
echo "Installed /etc/caddy/Caddyfile (caddy: $verb)."
|
|
164
211
|
echo "Previous config saved as /etc/caddy/Caddyfile.bak"
|
|
165
212
|
else
|
|
166
213
|
echo "--- would change /etc/caddy/Caddyfile (token redacted) ---"
|
package/deploy/Caddyfile
CHANGED
|
@@ -84,9 +84,11 @@
|
|
|
84
84
|
redir * / 302
|
|
85
85
|
}
|
|
86
86
|
|
|
87
|
+
# Anchored at both ends: unanchored, `tosi_edit=<key>x` matched too. That needed the key
|
|
88
|
+
# anyway, but the dev servers compare exactly, and the gate should agree with them.
|
|
87
89
|
@unauthed {
|
|
88
|
-
not header_regexp Cookie "tosi_preview=__PREVIEW_TOKEN__"
|
|
89
|
-
not header_regexp Cookie "tosi_edit=__PREVIEW_EDIT_TOKEN__"
|
|
90
|
+
not header_regexp Cookie "(^|; *)tosi_preview=__PREVIEW_TOKEN__(;|$)"
|
|
91
|
+
not header_regexp Cookie "(^|; *)tosi_edit=__PREVIEW_EDIT_TOKEN__(;|$)"
|
|
90
92
|
}
|
|
91
93
|
handle @unauthed {
|
|
92
94
|
header Content-Type "text/html; charset=utf-8"
|