Skip to content

Commit 77435c1

Browse files
committed
[[ Bug 20592 ]] Add uuid field to deploy parameters
This patch adds a uuid field to the deploy parameters which can be specified with the deploy command. When specified, iOS and Mac deployments will place the specified uuid into the Mach-O UUID load command. This is required to ensure services such as fingerprint authentication works correctly.
1 parent 7fb71fd commit 77435c1

7 files changed

Lines changed: 56 additions & 5 deletions

File tree

docs/notes/bugfix-20592.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# Ensure iOS standalones are treated as unique by fingerprint scanning

engine/src/deploy.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -367,6 +367,12 @@ bool MCDeployParameters::InitWithArray(MCExecContext &ctxt, MCArrayRef p_array)
367367
kMCStringOptionCompareCaseless))
368368
banner_class = kMCLicenseClassProfessionalEvaluation;
369369

370+
371+
if (!ctxt.CopyOptElementAsString(p_array, MCNAME("uuid"), false, t_temp_string))
372+
return false;
373+
MCValueAssign(uuid, t_temp_string);
374+
MCValueRelease(t_temp_string);
375+
370376
return true;
371377
}
372378

engine/src/deploy.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,8 @@ struct MCDeployParameters
119119
// The data for the banner stackfile.
120120
MCDataRef banner_stackfile;
121121

122+
// When building for Mac/iOS, there is a UUID field which can be set.
123+
MCStringRef uuid;
122124

123125
MCDeployParameters()
124126
{
@@ -151,6 +153,8 @@ struct MCDeployParameters
151153
banner_timeout = 0;
152154
banner_stackfile = MCValueRetain(kMCEmptyData);
153155
banner_class = kMCLicenseClassNone;
156+
157+
uuid = MCValueRetain(kMCEmptyString);
154158
}
155159

156160
~MCDeployParameters()
@@ -174,6 +178,7 @@ struct MCDeployParameters
174178
MCValueRelease(library);
175179
MCMemoryDeleteArray(min_os_versions);
176180
MCValueRelease(banner_stackfile);
181+
MCValueRelease(uuid);
177182
}
178183

179184
// Creates using an array of parameters
@@ -455,6 +460,9 @@ enum MCDeployError
455460

456461
/* An error occurred with the pre-deploy step */
457462
kMCDeployErrorTrialBannerError,
463+
464+
/* The uuid field was invalid */
465+
kMCDeployErrorInvalidUuid,
458466

459467
// SIGN ERRORS
460468

engine/src/deploy_file.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -316,6 +316,9 @@ const char *MCDeployErrorToString(MCDeployError p_error)
316316

317317
case kMCDeployErrorTrialBannerError:
318318
return "could not create trial banner";
319+
320+
case kMCDeployErrorInvalidUuid:
321+
return "invalid uuid";
319322

320323
case kMCDeployErrorNoCertificate:
321324
return "could not load certificate";

engine/src/deploy_macosx.cpp

Lines changed: 31 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,11 @@ along with LiveCode. If not see <http://www.gnu.org/licenses/>. */
2121
#include "parsedef.h"
2222
#include "filedefs.h"
2323

24-
2524
#include "handler.h"
2625
#include "scriptpt.h"
2726
#include "variable.h"
2827
#include "statemnt.h"
28+
#include "uuid.h"
2929

3030
#include "deploy.h"
3131

@@ -894,6 +894,16 @@ struct version_min_command {
894894
uint32_t sdk; /* X.Y.Z is encoded in nibbles xxxx.yy.zz */
895895
};
896896

897+
/*
898+
* The uuid load command contains a single 128-bit unique random number that
899+
* identifies an object produced by the static link editor.
900+
*/
901+
struct uuid_command {
902+
uint32_t cmd; /* LC_UUID */
903+
uint32_t cmdsize; /* sizeof(struct uuid_command) */
904+
uint8_t uuid[16]; /* the 128-bit uuid */
905+
};
906+
897907
////////////////////////////////////////////////////////////////////////////////
898908

899909
struct mach_32bit
@@ -1333,7 +1343,8 @@ template<typename T> bool MCDeployToMacOSXMainBody(const MCDeployParameters& p_p
13331343
t_old_linkedit_offset = t_misc_segment -> fileoff;
13341344

13351345
// Now go through, updating the offsets for all load commands after
1336-
// and including linkedit.
1346+
// and including linkedit. We also update the uuid load command here,
1347+
// if one has been provided.
13371348
typename T::sfield t_file_delta, t_address_delta;
13381349
t_file_delta = (t_project_segment -> fileoff + t_project_size) - t_old_linkedit_offset;
13391350
t_address_delta = t_file_delta;
@@ -1369,9 +1380,25 @@ template<typename T> bool MCDeployToMacOSXMainBody(const MCDeployParameters& p_p
13691380
case LC_DATA_IN_CODE:
13701381
relocate_function_starts_command((linkedit_data_command *)t_commands[i], t_file_delta, t_address_delta);
13711382
break;
1372-
1373-
// These commands have no file offsets
1383+
1384+
// Update the uuid, if one has been provided.
13741385
case LC_UUID:
1386+
if (!MCStringIsEmpty(p_params.uuid))
1387+
{
1388+
MCAutoStringRefAsCString t_uuid_cstring;
1389+
MCUuid t_uuid;
1390+
if (t_uuid_cstring.Lock(p_params.uuid) &&
1391+
MCUuidFromCString(*t_uuid_cstring, t_uuid))
1392+
{
1393+
uuid_command *t_uuid_cmd = (uuid_command *)t_commands[i];
1394+
MCUuidToBytes(t_uuid, t_uuid_cmd->uuid);
1395+
}
1396+
else
1397+
t_success = MCDeployThrow(kMCDeployErrorInvalidUuid);
1398+
}
1399+
break;
1400+
1401+
// These commands have no file offsets
13751402
case LC_THREAD:
13761403
case LC_UNIXTHREAD:
13771404
case LC_LOAD_DYLIB:

ide-support/revsaveasiosstandalone.livecodescript

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -570,6 +570,9 @@ private command revSaveAsMobileStandaloneMain pStack, pAppBundle, pTarget, pSett
570570

571571
-- delete the last LF
572572
delete last char of tDeploy["fontmappings"]
573+
574+
-- Make sure the standalone is generated with a unique uuid
575+
put uuid() into tDeploy["uuid"]
573576

574577
try
575578
_internal deploy ios tDeploy

ide-support/revsaveasstandalone.livecodescript

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -701,6 +701,9 @@ command revSaveAsMacStandalone pStack, pRestoreFileName, pFolder
701701
put return & "revInternal__SetSmallAppIcon" && sStandaloneSettingsA["OSX,smallappicon"] after tDeployInfo["startup_script"]
702702
end if
703703

704+
-- Add a random uuid to use in the executable's uuid load command.
705+
put uuid() into tDeployInfo["uuid"]
706+
704707
revStandaloneDeployWithParams tTarget, tStackSourceFile, tDeployInfo
705708

706709
-- Make sure we finish off the bundle contents
@@ -2489,7 +2492,7 @@ command revStandaloneDeployWithParams pTarget, pStackFilePath, pDeployInfo
24892492
delete stack pStackFilePath
24902493
unlock screen
24912494
unlock messages
2492-
2495+
24932496
-- Actually do the standalone engine build - we probably need some sort of
24942497
-- error handling here :oD
24952498
revStandaloneProgress "Attaching engine..."

0 commit comments

Comments
 (0)