Skip to content

Commit

Permalink
Fix wifi config with special characters
Browse files Browse the repository at this point in the history
  • Loading branch information
foosel committed Nov 4, 2024
1 parent 7ec2407 commit 32c5916
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion fabfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -424,6 +424,13 @@ def flashhost_flash(image, target=None):
)


def encrypt_psk(ssid, psk):
from hashlib import pbkdf2_hmac
from binascii import hexlify

return hexlify(pbkdf2_hmac("sha1", str.encode(psk), str.encode(ssid), 4096, 32)).decode("utf-8")


def flashhost_provision_octopi(target, boot):
hostname = env.targets[target]["hostname"]
password = env.rpi_password
Expand Down Expand Up @@ -490,7 +497,7 @@ def flashhost_provision_firstrun(target, boot):
user=user,
passwordhash=passwordhash,
ssid=env.wifi_ssid,
psk=env.wifi_psk,
psk=encrypt_psk(env.wifi_ssid, env.wifi_psk),
country=env.wifi_country,
),
use_jinja=True,
Expand Down

0 comments on commit 32c5916

Please sign in to comment.