mirror of
https://github.com/YunoHost/yunohost.git
synced 2024-09-03 20:06:10 +02:00
Delete the key if subscribing failed, to avoid confusion later trying to detect registered domains
This commit is contained in:
parent
283e01db8f
commit
3f8f328fae
1 changed files with 6 additions and 1 deletions
|
@ -144,7 +144,8 @@ def dyndns_subscribe(operation_logger, subscribe_host="dyndns.yunohost.org", dom
|
||||||
'dnssec-keygen -a hmac-sha512 -b 512 -r /dev/urandom -n USER %s' % domain)
|
'dnssec-keygen -a hmac-sha512 -b 512 -r /dev/urandom -n USER %s' % domain)
|
||||||
os.system('chmod 600 /etc/yunohost/dyndns/*.key /etc/yunohost/dyndns/*.private')
|
os.system('chmod 600 /etc/yunohost/dyndns/*.key /etc/yunohost/dyndns/*.private')
|
||||||
|
|
||||||
key_file = glob.glob('/etc/yunohost/dyndns/*.key')[0]
|
private_file = glob.glob('/etc/yunohost/dyndns/*%s*.private' % domain)[0]
|
||||||
|
key_file = glob.glob('/etc/yunohost/dyndns/*%s*.key' % domain)[0]
|
||||||
with open(key_file) as f:
|
with open(key_file) as f:
|
||||||
key = f.readline().strip().split(' ', 6)[-1]
|
key = f.readline().strip().split(' ', 6)[-1]
|
||||||
|
|
||||||
|
@ -153,8 +154,12 @@ def dyndns_subscribe(operation_logger, subscribe_host="dyndns.yunohost.org", dom
|
||||||
try:
|
try:
|
||||||
r = requests.post('https://%s/key/%s?key_algo=hmac-sha512' % (subscribe_host, base64.b64encode(key)), data={'subdomain': domain}, timeout=30)
|
r = requests.post('https://%s/key/%s?key_algo=hmac-sha512' % (subscribe_host, base64.b64encode(key)), data={'subdomain': domain}, timeout=30)
|
||||||
except requests.ConnectionError:
|
except requests.ConnectionError:
|
||||||
|
os.system("rm %s" % private_file)
|
||||||
|
os.system("rm %s" % key_file)
|
||||||
raise YunohostError('no_internet_connection')
|
raise YunohostError('no_internet_connection')
|
||||||
if r.status_code != 201:
|
if r.status_code != 201:
|
||||||
|
os.system("rm %s" % private_file)
|
||||||
|
os.system("rm %s" % key_file)
|
||||||
try:
|
try:
|
||||||
error = json.loads(r.text)['error']
|
error = json.loads(r.text)['error']
|
||||||
except:
|
except:
|
||||||
|
|
Loading…
Add table
Reference in a new issue