Skip to content
Snippets Groups Projects

Fix SECRET_KEY autogeneration in Debian package

2 files
+ 16
0
Compare changes
  • Side-by-side
  • Inline

Files

+ 12
0
@@ -13,6 +13,18 @@ case "$1" in
@@ -13,6 +13,18 @@ case "$1" in
chown root:uffd-nginxauth /etc/uffd-nginxauth/uffd-nginxauth.cfg
chown root:uffd-nginxauth /etc/uffd-nginxauth/uffd-nginxauth.cfg
chmod 0640 /etc/uffd-nginxauth/uffd-nginxauth.cfg
chmod 0640 /etc/uffd-nginxauth/uffd-nginxauth.cfg
 
python3 <<EOF
 
import secrets
 
cfg = open('/etc/uffd-nginxauth/uffd-nginxauth.cfg', 'r').read()
 
cfg = cfg.replace('\n#SECRET_KEY=autogenerated by postinst script\n',
 
'\nSECRET_KEY="'+secrets.token_hex(128)+'"\n', 1)
 
# Prior to v0.2.1 the default config used the wrong name for SECRET_KEY
 
if '\nSECRET_KEY=' not in cfg:
 
cfg = cfg.replace('\n#SECRET=autogenerated by postinst script\n',
 
'\nSECRET_KEY="'+secrets.token_hex(128)+'"\n', 1)
 
open('/etc/uffd-nginxauth/uffd-nginxauth.cfg', 'w').write(cfg)
 
EOF
 
invoke-rc.d uwsgi restart uffd-nginxauth
invoke-rc.d uwsgi restart uffd-nginxauth
;;
;;
Loading