Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DietPi-WiFiDB | Enhancements #2193

Merged
merged 2 commits into from
Oct 31, 2018
Merged

DietPi-WiFiDB | Enhancements #2193

merged 2 commits into from
Oct 31, 2018

Conversation

MichaIng
Copy link
Owner

@MichaIng MichaIng commented Oct 28, 2018

Status: Testing
🈯️ Native x86_64 Stretch

  • A quick test on Jessie would be great with double quote inside SSID and/or key. Just to assure that .conf parsing did not change in between.

Reference: https://github.com/Fourdee/DietPi/pull/2177#issuecomment-433071910

Commit list/description:

  • DietPi-WiFiDB | Switch to store WiFiDB with single quotes to reduce escape effort
    • Tested it up and down on notebook with Stretch. Script internal input box and variable handling does not need any escaping. Storing strings to source-able dietpi-wifi.db requires "escaping" of single quote only, which is only possible via '\'' to close single quoted literal string, insert escaped single quote and reopen literal single quoted string till the end. Inside wpa_supplicant.conf, double quotes for SSID, key, user and password are required, but no escaping, not even of double quote, required, since the values are parsed from first till last double quote 😃, intelligent solution. Single and double quotes and backslashes within bash variable manipulation ${VAR//<old>/<new} need to be escaped by backslash. This is then how the code came out, e.g.: '${aWIFI_SSID[$i]//\'/\'\\\'\'}'
  • DietPi-WiFiDB | Do required escaping script internally, to save user from doing this and us to maintain documentation about it
  • DietPi-WiFiDB | Only ask for WiFi key, if SSID and key manager was successfully chosen, otherwise reset values of the slot and return to slot overview
    • On the long term we could also implement a completed 'manual' + slot menu where one can select SSID, key manager, key and as well EAP settings, in case chosen as key manager.
  • DietPi-WiFiDB | Set ERROR_CODE=0 as default, as currently it always exits with ERROR_CODE=1, if valid INPUT was set.
    • As said, currently exit code is always 1, only 0 if invalid input was given. I guess this should have been the other way round 😆. But at least should not break anything, since this error code is never used so far.
  • DietPi-WiFiDB | Minor wording and coding

+ DietPi-WiFiDB | Switch to store WiFiDB with single quotes to reduce escape effort
+ DietPi-WiFiDB | Do required escaping script internally, to save user from doing this and us to maintain documentation about it
+ DietPi-WiFiDB | Only ask for WiFi key, if SSID and key manager was successfully chosen, otherwise reset values of the slot and return to slot overview
+ DietPi-WiFiDB | Set ERROR_CODE=0 as default, as currently it always exits with ERROR_CODE=1, if valid INPUT was set.
+ DietPi-WiFiDB | Minor wording and coding
@MichaIng
Copy link
Owner Author

Note: dietpi-wifi.db does not need to be adjusted during patch. Since double quoted values are already escaped correctly, sourcing the db leads to correct values and will be automatically written back with single quotes including correct escaping.

dietpi/func/dietpi-wifidb Outdated Show resolved Hide resolved
+ DietPi-WiFiDB | Non-capital, renamed and pre-declared return code: https://github.com/Fourdee/DietPi/pull/2193#discussion_r229350445
@Fourdee
Copy link
Collaborator

Fourdee commented Oct 31, 2018

@MichaIng

Great work, looks good 👍 Lets merge for testing.

@Fourdee Fourdee merged commit 4efc501 into dev Oct 31, 2018
@MichaIng MichaIng deleted the wifi_db branch October 31, 2018 14:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants