mirror of
https://github.com/cmclark00/retro-imager.git
synced 2025-05-18 16:05:21 +01:00
Mac OS X: advanced options. offer to prefill system wifi PSK
Offer to prefill the wifi password of the system running Imager, like we do on Windows. Ask user first if that is desired, as it does cause OS X to generate a prompt asking for admin password.
This commit is contained in:
parent
b57da413a6
commit
e2296deb1a
2 changed files with 30 additions and 0 deletions
|
@ -438,6 +438,10 @@ Popup {
|
||||||
fieldWifiPassword.text = imageWriter.getPSK(fieldWifiSSID.text)
|
fieldWifiPassword.text = imageWriter.getPSK(fieldWifiSSID.text)
|
||||||
if (fieldWifiPassword.text.length) {
|
if (fieldWifiPassword.text.length) {
|
||||||
chkShowPassword.checked = false
|
chkShowPassword.checked = false
|
||||||
|
if (Qt.platform.os == "osx") {
|
||||||
|
/* User indicated wifi must be prefilled */
|
||||||
|
chkWifi.checked = true
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,6 +37,8 @@
|
||||||
#endif
|
#endif
|
||||||
#ifdef Q_OS_DARWIN
|
#ifdef Q_OS_DARWIN
|
||||||
#include <QtNetwork>
|
#include <QtNetwork>
|
||||||
|
#include <QMessageBox>
|
||||||
|
#include <security/security.h>
|
||||||
#else
|
#else
|
||||||
#include "openssl/evp.h"
|
#include "openssl/evp.h"
|
||||||
#include "openssl/sha.h"
|
#include "openssl/sha.h"
|
||||||
|
@ -883,10 +885,34 @@ QString ImageWriter::getPSK(const QString &ssid)
|
||||||
|
|
||||||
return psk;
|
return psk;
|
||||||
|
|
||||||
|
#else
|
||||||
|
#ifdef Q_OS_DARWIN
|
||||||
|
SecKeychainRef keychainRef;
|
||||||
|
QString psk;
|
||||||
|
QByteArray ssidAscii = ssid.toLatin1();
|
||||||
|
|
||||||
|
if (QMessageBox::question(nullptr, "",
|
||||||
|
tr("Would you like to prefill the wifi password from the system keychain?")) == QMessageBox::Yes)
|
||||||
|
{
|
||||||
|
if (SecKeychainOpen("/Library/Keychains/System.keychain", &keychainRef) == errSecSuccess)
|
||||||
|
{
|
||||||
|
UInt32 resultLen;
|
||||||
|
void *result;
|
||||||
|
if (SecKeychainFindGenericPassword(keychainRef, 0, NULL, ssidAscii.length(), ssidAscii.constData(), &resultLen, &result, NULL) == errSecSuccess)
|
||||||
|
{
|
||||||
|
psk = QByteArray((char *) result, resultLen);
|
||||||
|
SecKeychainItemFreeContent(NULL, result);
|
||||||
|
}
|
||||||
|
CFRelease(keychainRef);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return psk;
|
||||||
#else
|
#else
|
||||||
Q_UNUSED(ssid)
|
Q_UNUSED(ssid)
|
||||||
return QString();
|
return QString();
|
||||||
#endif
|
#endif
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ImageWriter::getBoolSetting(const QString &key)
|
bool ImageWriter::getBoolSetting(const QString &key)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue