diff --git a/launchers/darwin/CMakeLists.txt b/launchers/darwin/CMakeLists.txt index 499fc0440e..745ceec8fc 100644 --- a/launchers/darwin/CMakeLists.txt +++ b/launchers/darwin/CMakeLists.txt @@ -53,9 +53,20 @@ set_target_properties(${this_target} PROPERTIES set(MACOSX_BUNDLE_ICON_FILE "interface.icns") +function(set_from_env _RESULT_NAME _ENV_VAR_NAME _DEFAULT_VALUE) + if (NOT DEFINED ${_RESULT_NAME}) + if ("$ENV{${_ENV_VAR_NAME}}" STREQUAL "") + set (${_RESULT_NAME} ${_DEFAULT_VALUE} PARENT_SCOPE) + else() + set (${_RESULT_NAME} $ENV{${_ENV_VAR_NAME}} PARENT_SCOPE) + endif() + endif() +endfunction() + add_executable(${PROJECT_NAME} MACOSX_BUNDLE ${src_files}) set_target_properties(${PROJECT_NAME} PROPERTIES OUTPUT_NAME ${APP_NAME}) - +set_from_env(LAUNCHER_HMAC_SECRET LAUNCHER_HMAC_SECRET "") +target_compile_definitions(${PROJECT_NAME} PRIVATE LAUNCHER_HMAC_SECRET="${LAUNCHER_HMAC_SECRET}") file(GLOB NIB_FILES "nib/*.xib") diff --git a/launchers/darwin/src/OrganizationRequest.m b/launchers/darwin/src/OrganizationRequest.m index b51de8a19e..23d3c2e1cf 100644 --- a/launchers/darwin/src/OrganizationRequest.m +++ b/launchers/darwin/src/OrganizationRequest.m @@ -6,15 +6,12 @@ static NSString* const organizationURL = @"https://s3.amazonaws.com/hifi-public/huffman/organizations/"; -#define str(s) #s -#define LAUNCHER_HMAC_SECRET_STRING str(LAUNCHER_HMAC_SECRET) - @implementation OrganizationRequest - (void) confirmOrganization:(NSString*)aOrganization :(NSString*)aUsername { self.username = aUsername; - const char *cKey = LAUNCHER_HMAC_SECRET_STRING; + const char *cKey = LAUNCHER_HMAC_SECRET; const char *cData = [aOrganization cStringUsingEncoding:NSASCIIStringEncoding]; unsigned char cHMAC[CC_SHA256_DIGEST_LENGTH]; CCHmac(kCCHmacAlgSHA256, cKey, strlen(cKey), cData, strlen(cData), cHMAC); diff --git a/launchers/win32/CMakeLists.txt b/launchers/win32/CMakeLists.txt index 4d2618c9bf..8417831312 100644 --- a/launchers/win32/CMakeLists.txt +++ b/launchers/win32/CMakeLists.txt @@ -39,7 +39,19 @@ add_executable(HQLauncher targetver.h ) -target_compile_definitions(HQLauncher PRIVATE LAUNCHER_HMAC_SECRET=$ENV{LAUNCHER_HMAC_SECRET}) +function(set_from_env _RESULT_NAME _ENV_VAR_NAME _DEFAULT_VALUE) + if (NOT DEFINED ${_RESULT_NAME}) + if ("$ENV{${_ENV_VAR_NAME}}" STREQUAL "") + set (${_RESULT_NAME} ${_DEFAULT_VALUE} PARENT_SCOPE) + else() + set (${_RESULT_NAME} $ENV{${_ENV_VAR_NAME}} PARENT_SCOPE) + endif() + endif() +endfunction() + +set_from_env(LAUNCHER_HMAC_SECRET LAUNCHER_HMAC_SECRET "") +target_compile_definitions(${PROJECT_NAME} PRIVATE LAUNCHER_HMAC_SECRET="${LAUNCHER_HMAC_SECRET}") + # Preprocessor definitions target_compile_definitions(HQLauncher PRIVATE diff --git a/launchers/win32/LauncherDlg.cpp b/launchers/win32/LauncherDlg.cpp index f6acbce014..07fb57ddcd 100644 --- a/launchers/win32/LauncherDlg.cpp +++ b/launchers/win32/LauncherDlg.cpp @@ -170,12 +170,9 @@ void CLauncherDlg::startProcess() { } } -#define str(s) #s -#define LAUNCHER_HMAC_SECRET_STRING str(LAUNCHER_HMAC_SECRET) - BOOL CLauncherDlg::getHQInfo(const CString& orgname) { CString hash; - LauncherUtils::hMac256(orgname, LAUNCHER_HMAC_SECRET_STRING, hash); + LauncherUtils::hMac256(orgname, LAUNCHER_HMAC_SECRET, hash); return theApp._manager.readOrganizationJSON(hash) == LauncherUtils::ResponseError::NoError; }