aboutsummaryrefslogtreecommitdiffstats
path: root/package
diff options
context:
space:
mode:
authorFelix Fietkau <nbd@openwrt.org>2015-03-15 10:32:10 +0000
committerFelix Fietkau <nbd@openwrt.org>2015-03-15 10:32:10 +0000
commitde3c3ab44d3134866967db2e5203e698083238ff (patch)
treefab3b727690e0067f97f87e234e2a7bf63f97fbd /package
parentfc9676671c3f789d18b8daee95733a12a33bce7b (diff)
downloadmaster-187ad058-de3c3ab44d3134866967db2e5203e698083238ff.tar.gz
master-187ad058-de3c3ab44d3134866967db2e5203e698083238ff.tar.bz2
master-187ad058-de3c3ab44d3134866967db2e5203e698083238ff.zip
uhttpd: make generating SSL keys more reliable against interrupted boots
Signed-off-by: Felix Fietkau <nbd@openwrt.org> git-svn-id: svn://svn.openwrt.org/openwrt/trunk@44772 3c298f89-4303-0410-b956-a3cf2f4a3e73
Diffstat (limited to 'package')
-rwxr-xr-xpackage/network/services/uhttpd/files/uhttpd.init7
1 files changed, 5 insertions, 2 deletions
diff --git a/package/network/services/uhttpd/files/uhttpd.init b/package/network/services/uhttpd/files/uhttpd.init
index 59f7d80e77..c493aafe42 100755
--- a/package/network/services/uhttpd/files/uhttpd.init
+++ b/package/network/services/uhttpd/files/uhttpd.init
@@ -45,8 +45,11 @@ generate_keys() {
[ -x "$PX5G_BIN" ] && {
$PX5G_BIN selfsigned -der \
- -days ${days:-730} -newkey rsa:${bits:-1024} -keyout "$UHTTPD_KEY" -out "$UHTTPD_CERT" \
+ -days ${days:-730} -newkey rsa:${bits:-1024} -keyout "${UHTTPD_KEY}.new" -out "${UHTTPD_CERT}.new" \
-subj /C="${country:-DE}"/ST="${state:-Saxony}"/L="${location:-Leipzig}"/CN="${commonname:-OpenWrt}"
+ sync
+ mv "${UHTTPD_KEY}.new" "${UHTTPD_KEY}"
+ mv "${UHTTPD_CERT}.new" "${UHTTPD_CERT}"
}
}
@@ -111,7 +114,7 @@ start_instance()
config_get UHTTPD_CERT "$cfg" cert /etc/uhttpd.crt
[ -f /lib/libustream-ssl.so ] && [ -n "$https" ] && {
- [ -f "$UHTTPD_CERT" -a -f "$UHTTPD_KEY" ] || {
+ [ -s "$UHTTPD_CERT" -a -s "$UHTTPD_KEY" ] || {
config_foreach generate_keys cert
}