mirror of
https://github.com/tihmstar/futurerestore.git
synced 2024-12-22 17:35:29 +00:00
properly selecting correct buildidentity now
This commit is contained in:
parent
74c63d725b
commit
485b0912fc
|
@ -567,7 +567,7 @@ char *futurerestore::getLatestFirmwareUrl(){
|
|||
|
||||
void futurerestore::loadLatestBaseband(){
|
||||
char * manifeststr = getLatestManifest();
|
||||
char *pathStr = getPathOfElementInManifest("BasebandFirmware", manifeststr);
|
||||
char *pathStr = getPathOfElementInManifest("BasebandFirmware", manifeststr, getConnectedDeviceModel(), 0);
|
||||
info("downloading Baseband\n\n");
|
||||
if (downloadPartialzip(getLatestFirmwareUrl(), pathStr, _basebandPath = BASEBAND_TMP_PATH))
|
||||
reterror(-32, "could not download baseband\n");
|
||||
|
@ -576,7 +576,7 @@ void futurerestore::loadLatestBaseband(){
|
|||
|
||||
void futurerestore::loadLatestSep(){
|
||||
char * manifeststr = getLatestManifest();
|
||||
char *pathStr = getPathOfElementInManifest("SEP", manifeststr);
|
||||
char *pathStr = getPathOfElementInManifest("SEP", manifeststr, getConnectedDeviceModel(), 0);
|
||||
info("downloading SEP\n\n");
|
||||
if (downloadPartialzip(getLatestFirmwareUrl(), pathStr, _sepPath = SEP_TMP_PATH))
|
||||
reterror(-33, "could not download SEP\n");
|
||||
|
@ -688,20 +688,20 @@ plist_t futurerestore::loadPlistFromFile(const char *path){
|
|||
return ret;
|
||||
}
|
||||
|
||||
char *futurerestore::getPathOfElementInManifest(const char *element, const char *manifeststr){
|
||||
char *futurerestore::getPathOfElementInManifest(const char *element, const char *manifeststr, const char *model, int isUpdateInstall){
|
||||
char *pathStr = NULL;
|
||||
ptr_smart<plist_t> buildmanifest(NULL,plist_free);
|
||||
|
||||
plist_from_xml(manifeststr, (uint32_t)strlen(manifeststr), &buildmanifest);
|
||||
|
||||
if (plist_t buildidentities = plist_dict_get_item(buildmanifest._p, "BuildIdentities"))
|
||||
if (plist_t firstIdentitie = plist_array_get_item(buildidentities, 0))
|
||||
if (plist_t manifest = plist_dict_get_item(firstIdentitie, "Manifest"))
|
||||
if (plist_t elem = plist_dict_get_item(manifest, element))
|
||||
if (plist_t info = plist_dict_get_item(elem, "Info"))
|
||||
if (plist_t path = plist_dict_get_item(info, "Path"))
|
||||
if (plist_get_string_val(path, &pathStr), pathStr)
|
||||
goto noerror;
|
||||
if (plist_t identity = getBuildidentity(buildmanifest._p, model, isUpdateInstall))
|
||||
if (plist_t manifest = plist_dict_get_item(identity, "Manifest"))
|
||||
if (plist_t elem = plist_dict_get_item(manifest, element))
|
||||
if (plist_t info = plist_dict_get_item(elem, "Info"))
|
||||
if (plist_t path = plist_dict_get_item(info, "Path"))
|
||||
if (plist_get_string_val(path, &pathStr), pathStr)
|
||||
goto noerror;
|
||||
|
||||
reterror(-31, "could not get %s path\n",element);
|
||||
noerror:
|
||||
return pathStr;
|
||||
|
|
|
@ -89,7 +89,7 @@ public:
|
|||
static char *getNonceFromAPTicket(const char* apticketPath);
|
||||
static plist_t loadPlistFromFile(const char *path);
|
||||
static void saveStringToFile(const char *str, const char *path);
|
||||
static char *getPathOfElementInManifest(const char *element, const char *manifeststr);
|
||||
static char *getPathOfElementInManifest(const char *element, const char *manifeststr, const char *model, int isUpdateInstall);
|
||||
|
||||
};
|
||||
|
||||
|
|
|
@ -130,54 +130,60 @@ int main(int argc, const char * argv[]) {
|
|||
futurerestore client;
|
||||
if (!client.init()) reterror(-3,"can't init, no device found\n");
|
||||
|
||||
if (apticketPaths.size()) client.loadAPTickets(apticketPaths);
|
||||
|
||||
if (!((apticketPaths.size() && ipsw)
|
||||
&& ((basebandPath && basebandManifestPath) || (flags & FLAG_LATEST_BASEBAND))
|
||||
&& ((sepPath && sepManifestPath) || (flags & FLAG_LATEST_SEP)))) {
|
||||
if (!(flags & FLAG_WAIT) || ipsw){
|
||||
error("missing argument\n");
|
||||
cmd_help();
|
||||
err = -2;
|
||||
}else{
|
||||
client.putDeviceIntoRecovery();
|
||||
client.waitForNonce();
|
||||
info("done\n");
|
||||
try {
|
||||
if (apticketPaths.size()) client.loadAPTickets(apticketPaths);
|
||||
|
||||
if (!((apticketPaths.size() && ipsw)
|
||||
&& ((basebandPath && basebandManifestPath) || (flags & FLAG_LATEST_BASEBAND))
|
||||
&& ((sepPath && sepManifestPath) || (flags & FLAG_LATEST_SEP)))) {
|
||||
if (!(flags & FLAG_WAIT) || ipsw){
|
||||
error("missing argument\n");
|
||||
cmd_help();
|
||||
err = -2;
|
||||
}else{
|
||||
client.putDeviceIntoRecovery();
|
||||
client.waitForNonce();
|
||||
info("done\n");
|
||||
}
|
||||
goto error;
|
||||
}
|
||||
|
||||
|
||||
if (flags & FLAG_LATEST_SEP){
|
||||
info("user specified to use latest signed sep\n");
|
||||
client.loadLatestSep();
|
||||
}else{
|
||||
client.setSepPath(sepPath);
|
||||
client.setSepManifestPath(sepManifestPath);
|
||||
}
|
||||
if (flags & FLAG_LATEST_BASEBAND){
|
||||
info("user specified to use latest signed baseband (WARNING, THIS CAN CAUSE A NON-WORKING RESTORE)\n");
|
||||
client.loadLatestBaseband();
|
||||
}else{
|
||||
client.setBasebandPath(basebandPath);
|
||||
client.setBasebandManifestPath(basebandManifestPath);
|
||||
}
|
||||
|
||||
|
||||
versVals.basebandMode = kBasebandModeWithoutBaseband;
|
||||
if (!(isSepManifestSigned = isManifestSignedForDevice(client.sepManifestPath(), NULL, &devVals, &versVals))){
|
||||
reterror(-3,"sep firmware isn't signed\n");
|
||||
}
|
||||
|
||||
versVals.basebandMode = kBasebandModeOnlyBaseband;
|
||||
if (!(isBasebandSigned = isManifestSignedForDevice(client.basebandManifestPath(), NULL, &devVals, &versVals))){
|
||||
reterror(-3,"baseband firmware isn't signed\n");
|
||||
}
|
||||
|
||||
client.putDeviceIntoRecovery();
|
||||
if (flags & FLAG_WAIT){
|
||||
client.waitForNonce();
|
||||
}
|
||||
} catch (int error) {
|
||||
err = error;
|
||||
printf("[Error] Fail code=%d\n",err);
|
||||
goto error;
|
||||
}
|
||||
|
||||
|
||||
if (flags & FLAG_LATEST_SEP){
|
||||
info("user specified to use latest signed sep\n");
|
||||
client.loadLatestSep();
|
||||
}else{
|
||||
client.setSepPath(sepPath);
|
||||
client.setSepManifestPath(sepManifestPath);
|
||||
}
|
||||
if (flags & FLAG_LATEST_BASEBAND){
|
||||
info("user specified to use latest signed baseband (WARNING, THIS CAN CAUSE A NON-WORKING RESTORE)\n");
|
||||
client.loadLatestBaseband();
|
||||
}else{
|
||||
client.setBasebandPath(basebandPath);
|
||||
client.setBasebandManifestPath(basebandManifestPath);
|
||||
}
|
||||
|
||||
|
||||
versVals.basebandMode = kBasebandModeWithoutBaseband;
|
||||
if (!(isSepManifestSigned = isManifestSignedForDevice(client.sepManifestPath(), NULL, &devVals, &versVals))){
|
||||
reterror(-3,"sep firmware isn't signed\n");
|
||||
}
|
||||
|
||||
versVals.basebandMode = kBasebandModeOnlyBaseband;
|
||||
if (!(isBasebandSigned = isManifestSignedForDevice(client.basebandManifestPath(), NULL, &devVals, &versVals))){
|
||||
reterror(-3,"baseband firmware isn't signed\n");
|
||||
}
|
||||
|
||||
client.putDeviceIntoRecovery();
|
||||
if (flags & FLAG_WAIT){
|
||||
client.waitForNonce();
|
||||
}
|
||||
|
||||
try {
|
||||
res = client.doRestore(ipsw, flags & FLAG_UPDATE);
|
||||
|
|
Loading…
Reference in a new issue