Skip to content

Commit f8cf01b

Browse files
committed
Embed pairing file in info.plist
1 parent 11a0fe7 commit f8cf01b

File tree

3 files changed

+69
-29
lines changed

3 files changed

+69
-29
lines changed

AltServer/Devices/ALTDeviceManager+Installation.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -852,6 +852,7 @@ private extension ALTDeviceManager
852852
// There is an ALTDeviceID entry, so assume the app is using AltKit and replace it with the device's UDID.
853853
additionalValues[Bundle.Info.deviceID] = device.identifier
854854
additionalValues[Bundle.Info.serverID] = UserDefaults.standard.serverID
855+
additionalValues[Bundle.Info.devicePairingString] = ALTDeviceManager.shared.getPairingPlistString(device.identifier)
855856
}
856857

857858
try prepare(appBundle, additionalInfoDictionaryValues: additionalValues)

AltServer/Devices/ALTDeviceManager.mm

Lines changed: 50 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,8 @@
2828
#include <libimobiledevice/misagent.h>
2929
#include <libimobiledevice/mobile_image_mounter.h>
3030
#include <common/userpref.h>
31-
#include <libimobiledevice/service.h>
31+
#include "userpref.h"
32+
#include <usbmuxd.h>
3233

3334
void ALTDeviceManagerUpdateStatus(plist_t command, plist_t status, void *udid);
3435
void ALTDeviceManagerUpdateAppDeletionStatus(plist_t command, plist_t status, void *uuid);
@@ -394,32 +395,62 @@ - (NSString *)getPairingPlistString:(NSString*)udid{
394395
uint32_t length;
395396
char* temp_udid = (char *)udid.UTF8String;
396397
userpref_read_pair_record(temp_udid, &pair_record);
398+
// const char *test = userpref_get_config_dir();
397399
plist_dict_set_item(pair_record, "UDID", plist_new_string(temp_udid));
398400
plist_to_xml(pair_record, &buffer, &length);
401+
//printf("PLIST STRING");
402+
// printf(buffer);
399403
return [NSString stringWithUTF8String:(buffer)];
400404
}
401-
402-
static void print_error_message(lockdownd_error_t err, const char *udid)
405+
userpref_error_t userpref_read_pair_record(const char *udid, plist_t *pair_record)
403406
{
404-
switch (err) {
405-
case LOCKDOWN_E_PASSWORD_PROTECTED:
406-
fprintf(stderr, "ERROR: Could not validate with device %s because a passcode is set. Please enter the passcode on the device and retry.\n", udid);
407-
break;
408-
case LOCKDOWN_E_INVALID_CONF:
409-
case LOCKDOWN_E_INVALID_HOST_ID:
410-
fprintf(stderr, "ERROR: Device %s is not paired with this host\n", udid);
411-
break;
412-
case LOCKDOWN_E_PAIRING_DIALOG_RESPONSE_PENDING:
413-
fprintf(stderr, "ERROR: Please accept the trust dialog on the screen of device %s, then attempt to pair again.\n", udid);
414-
break;
415-
case LOCKDOWN_E_USER_DENIED_PAIRING:
416-
fprintf(stderr, "ERROR: Device %s said that the user denied the trust dialog.\n", udid);
417-
break;
407+
char* record_data = NULL;
408+
uint32_t record_size = 0;
409+
410+
int res = usbmuxd_read_pair_record(udid, &record_data, &record_size);
411+
if (res < 0) {
412+
free(record_data);
413+
switch (-res) {
414+
case ENOENT:
415+
return USERPREF_E_UNKNOWN_ERROR;
416+
case ETIMEDOUT:
417+
return USERPREF_E_READ_ERROR;
418418
default:
419-
fprintf(stderr, "ERROR: Device %s returned unhandled error code %d\n", udid, err);
420-
break;
419+
return USERPREF_E_INVALID_CONF;
420+
}
421+
}
422+
423+
*pair_record = NULL;
424+
plist_from_memory(record_data, record_size, pair_record);
425+
free(record_data);
426+
427+
if (!*pair_record) {
428+
printf("Failed to parse pairing record");
429+
return USERPREF_E_INVALID_CONF;
421430
}
431+
return USERPREF_E_SUCCESS;
422432
}
433+
//static void print_error_message(lockdownd_error_t err, const char *udid)
434+
//{
435+
// switch (err) {
436+
// case LOCKDOWN_E_PASSWORD_PROTECTED:
437+
// fprintf(stderr, "ERROR: Could not validate with device %s because a passcode is set. Please enter the passcode on the device and retry.\n", udid);
438+
// break;
439+
// case LOCKDOWN_E_INVALID_CONF:
440+
// case LOCKDOWN_E_INVALID_HOST_ID:
441+
// fprintf(stderr, "ERROR: Device %s is not paired with this host\n", udid);
442+
// break;
443+
// case LOCKDOWN_E_PAIRING_DIALOG_RESPONSE_PENDING:
444+
// fprintf(stderr, "ERROR: Please accept the trust dialog on the screen of device %s, then attempt to pair again.\n", udid);
445+
// break;
446+
// case LOCKDOWN_E_USER_DENIED_PAIRING:
447+
// fprintf(stderr, "ERROR: Device %s said that the user denied the trust dialog.\n", udid);
448+
// break;
449+
// default:
450+
// fprintf(stderr, "ERROR: Device %s returned unhandled error code %d\n", udid, err);
451+
// break;
452+
// }
453+
//}
423454

424455
- (BOOL)writeDirectory:(NSURL *)directoryURL toDestinationURL:(NSURL *)destinationURL client:(afc_client_t)afc progress:(NSProgress *)progress error:(NSError **)error
425456
{

AltStore.xcodeproj/project.pbxproj

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@
77
objects = {
88

99
/* Begin PBXBuildFile section */
10+
0380808828C6E03800C653E1 /* userpref.c in Sources */ = {isa = PBXBuildFile; fileRef = 0380808728C6E03800C653E1 /* userpref.c */; };
11+
0380808A28C6E10300C653E1 /* libimobiledevice.a in Frameworks */ = {isa = PBXBuildFile; fileRef = BF45872B2298D31600BD7491 /* libimobiledevice.a */; };
12+
03C6DA9828C6E2AC002B2779 /* userpref.h in Headers */ = {isa = PBXBuildFile; fileRef = 0380808928C6E03900C653E1 /* userpref.h */; };
1013
B3C395FC284F3B2400DA9E2F /* Sparkle in Frameworks */ = {isa = PBXBuildFile; productRef = B3C395FB284F3B2400DA9E2F /* Sparkle */; };
1114
B3C395FF284F3C0900DA9E2F /* STPrivilegedTask in Frameworks */ = {isa = PBXBuildFile; productRef = B3C395FE284F3C0900DA9E2F /* STPrivilegedTask */; };
1215
BF0241AA22F29CCD00129732 /* UserDefaults+AltServer.swift in Sources */ = {isa = PBXBuildFile; fileRef = BF0241A922F29CCD00129732 /* UserDefaults+AltServer.swift */; };
@@ -81,7 +84,6 @@
8184
BF4588402298D3F800BD7491 /* collection.h in Headers */ = {isa = PBXBuildFile; fileRef = BF45883E2298D3F800BD7491 /* collection.h */; };
8285
BF4588412298D3F800BD7491 /* collection.c in Sources */ = {isa = PBXBuildFile; fileRef = BF45883F2298D3F800BD7491 /* collection.c */; };
8386
BF4588432298D40000BD7491 /* libusbmuxd.c in Sources */ = {isa = PBXBuildFile; fileRef = BF4588422298D40000BD7491 /* libusbmuxd.c */; };
84-
BF4588472298D4B000BD7491 /* libimobiledevice.a in Frameworks */ = {isa = PBXBuildFile; fileRef = BF45872B2298D31600BD7491 /* libimobiledevice.a */; };
8587
BF45884A2298D55000BD7491 /* thread.c in Sources */ = {isa = PBXBuildFile; fileRef = BF4588482298D55000BD7491 /* thread.c */; };
8688
BF45884B2298D55000BD7491 /* thread.h in Headers */ = {isa = PBXBuildFile; fileRef = BF4588492298D55000BD7491 /* thread.h */; };
8789
BF541C0B25E5A5FA00CD46B2 /* FileManager+URLs.swift in Sources */ = {isa = PBXBuildFile; fileRef = BF541C0A25E5A5FA00CD46B2 /* FileManager+URLs.swift */; };
@@ -151,7 +153,7 @@
151153
/* End PBXBuildFile section */
152154

153155
/* Begin PBXContainerItemProxy section */
154-
BF4588442298D48B00BD7491 /* PBXContainerItemProxy */ = {
156+
0380808B28C6E10300C653E1 /* PBXContainerItemProxy */ = {
155157
isa = PBXContainerItemProxy;
156158
containerPortal = BFD247622284B9A500981D42 /* Project object */;
157159
proxyType = 1;
@@ -203,6 +205,8 @@
203205
/* End PBXCopyFilesBuildPhase section */
204206

205207
/* Begin PBXFileReference section */
208+
0380808728C6E03800C653E1 /* userpref.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; path = userpref.c; sourceTree = SOURCE_ROOT; };
209+
0380808928C6E03900C653E1 /* userpref.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = userpref.h; sourceTree = SOURCE_ROOT; };
206210
B3146EC5284F57EF00BBC3FD /* AltSign */ = {isa = PBXFileReference; lastKnownFileType = wrapper; name = AltSign; path = Dependencies/AltSign; sourceTree = "<group>"; };
207211
B3C39606284F4C8400DA9E2F /* CodeSigning.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = CodeSigning.xcconfig; sourceTree = "<group>"; };
208212
B3C39607284F4C8400DA9E2F /* Build.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = Build.xcconfig; sourceTree = "<group>"; };
@@ -387,8 +391,8 @@
387391
D58D5F2E26DFE68E00E55E38 /* LaunchAtLogin in Frameworks */,
388392
B3C395FF284F3C0900DA9E2F /* STPrivilegedTask in Frameworks */,
389393
BF088D382501A833008082D9 /* OpenSSL.xcframework in Frameworks */,
394+
0380808A28C6E10300C653E1 /* libimobiledevice.a in Frameworks */,
390395
B3C395FC284F3B2400DA9E2F /* Sparkle in Frameworks */,
391-
BF4588472298D4B000BD7491 /* libimobiledevice.a in Frameworks */,
392396
BF088D362501A821008082D9 /* AltSign-Dynamic in Frameworks */,
393397
);
394398
runOnlyForDeploymentPostprocessing = 0;
@@ -485,6 +489,8 @@
485489
children = (
486490
BF4588282298D3B400BD7491 /* common */,
487491
BF4587D72298D3A800BD7491 /* afc.c */,
492+
0380808728C6E03800C653E1 /* userpref.c */,
493+
0380808928C6E03900C653E1 /* userpref.h */,
488494
BF4587EC2298D3AA00BD7491 /* afc.h */,
489495
BF4587DF2298D3A900BD7491 /* debugserver.c */,
490496
BF4587DE2298D3A900BD7491 /* debugserver.h */,
@@ -791,6 +797,7 @@
791797
buildActionMask = 2147483647;
792798
files = (
793799
BF4588112298D3AB00BD7491 /* misagent.h in Headers */,
800+
03C6DA9828C6E2AC002B2779 /* userpref.h in Headers */,
794801
BF4588042298D3AB00BD7491 /* lockdown.h in Headers */,
795802
BF4588402298D3F800BD7491 /* collection.h in Headers */,
796803
BF45880B2298D3AB00BD7491 /* mobilesync.h in Headers */,
@@ -849,8 +856,8 @@
849856
buildRules = (
850857
);
851858
dependencies = (
852-
BF4588452298D48B00BD7491 /* PBXTargetDependency */,
853859
BFF7C90E257844C900E55F36 /* PBXTargetDependency */,
860+
0380808C28C6E10300C653E1 /* PBXTargetDependency */,
854861
);
855862
name = AltServer;
856863
packageProductDependencies = (
@@ -1113,6 +1120,7 @@
11131120
BFD52C1722A1A9CB000B7ED1 /* Key.cpp in Sources */,
11141121
BF45880D2298D3AB00BD7491 /* mobilebackup.c in Sources */,
11151122
BFD52C0C22A1A9CB000B7ED1 /* Date.cpp in Sources */,
1123+
0380808828C6E03800C653E1 /* userpref.c in Sources */,
11161124
BFD52C0A22A1A9CB000B7ED1 /* plist.c in Sources */,
11171125
BFD52C1322A1A9CB000B7ED1 /* Data.cpp in Sources */,
11181126
BF45883A2298D3C100BD7491 /* debug.c in Sources */,
@@ -1168,10 +1176,10 @@
11681176
/* End PBXSourcesBuildPhase section */
11691177

11701178
/* Begin PBXTargetDependency section */
1171-
BF4588452298D48B00BD7491 /* PBXTargetDependency */ = {
1179+
0380808C28C6E10300C653E1 /* PBXTargetDependency */ = {
11721180
isa = PBXTargetDependency;
11731181
target = BF45872A2298D31600BD7491 /* libimobiledevice */;
1174-
targetProxy = BF4588442298D48B00BD7491 /* PBXContainerItemProxy */;
1182+
targetProxy = 0380808B28C6E10300C653E1 /* PBXContainerItemProxy */;
11751183
};
11761184
BFF7C90E257844C900E55F36 /* PBXTargetDependency */ = {
11771185
isa = PBXTargetDependency;
@@ -1203,7 +1211,7 @@
12031211
CODE_SIGN_STYLE = Automatic;
12041212
COMBINE_HIDPI_IMAGES = YES;
12051213
CURRENT_PROJECT_VERSION = 66;
1206-
DEVELOPMENT_TEAM = "$(DEVELOPMENT_TEAM)";
1214+
DEVELOPMENT_TEAM = A72ZC8AJ5X;
12071215
ENABLE_HARDENED_RUNTIME = YES;
12081216
FRAMEWORK_SEARCH_PATHS = (
12091217
"$(inherited)",
@@ -1257,7 +1265,7 @@
12571265
CODE_SIGN_STYLE = Automatic;
12581266
COMBINE_HIDPI_IMAGES = YES;
12591267
CURRENT_PROJECT_VERSION = 66;
1260-
DEVELOPMENT_TEAM = "$(DEVELOPMENT_TEAM)";
1268+
DEVELOPMENT_TEAM = A72ZC8AJ5X;
12611269
ENABLE_HARDENED_RUNTIME = YES;
12621270
FRAMEWORK_SEARCH_PATHS = (
12631271
"$(inherited)",
@@ -1578,7 +1586,7 @@
15781586
CODE_SIGN_STYLE = Automatic;
15791587
COMBINE_HIDPI_IMAGES = YES;
15801588
DEBUG_INFORMATION_FORMAT = dwarf;
1581-
DEVELOPMENT_TEAM = "$(DEVELOPMENT_TEAM)";
1589+
DEVELOPMENT_TEAM = A72ZC8AJ5X;
15821590
ENABLE_HARDENED_RUNTIME = YES;
15831591
INFOPLIST_FILE = AltXPC/Info.plist;
15841592
LD_RUNPATH_SEARCH_PATHS = (
@@ -1608,7 +1616,7 @@
16081616
CODE_SIGN_IDENTITY = "Mac Developer";
16091617
CODE_SIGN_STYLE = Automatic;
16101618
COMBINE_HIDPI_IMAGES = YES;
1611-
DEVELOPMENT_TEAM = "$(DEVELOPMENT_TEAM)";
1619+
DEVELOPMENT_TEAM = A72ZC8AJ5X;
16121620
ENABLE_HARDENED_RUNTIME = YES;
16131621
INFOPLIST_FILE = AltXPC/Info.plist;
16141622
LD_RUNPATH_SEARCH_PATHS = (

0 commit comments

Comments
 (0)