mirror of
https://github.com/tihmstar/futurerestore.git
synced 2025-07-01 14:58:14 +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(){
|
void futurerestore::loadLatestBaseband(){
|
||||||
char * manifeststr = getLatestManifest();
|
char * manifeststr = getLatestManifest();
|
||||||
char *pathStr = getPathOfElementInManifest("BasebandFirmware", manifeststr);
|
char *pathStr = getPathOfElementInManifest("BasebandFirmware", manifeststr, getConnectedDeviceModel(), 0);
|
||||||
info("downloading Baseband\n\n");
|
info("downloading Baseband\n\n");
|
||||||
if (downloadPartialzip(getLatestFirmwareUrl(), pathStr, _basebandPath = BASEBAND_TMP_PATH))
|
if (downloadPartialzip(getLatestFirmwareUrl(), pathStr, _basebandPath = BASEBAND_TMP_PATH))
|
||||||
reterror(-32, "could not download baseband\n");
|
reterror(-32, "could not download baseband\n");
|
||||||
|
@ -576,7 +576,7 @@ void futurerestore::loadLatestBaseband(){
|
||||||
|
|
||||||
void futurerestore::loadLatestSep(){
|
void futurerestore::loadLatestSep(){
|
||||||
char * manifeststr = getLatestManifest();
|
char * manifeststr = getLatestManifest();
|
||||||
char *pathStr = getPathOfElementInManifest("SEP", manifeststr);
|
char *pathStr = getPathOfElementInManifest("SEP", manifeststr, getConnectedDeviceModel(), 0);
|
||||||
info("downloading SEP\n\n");
|
info("downloading SEP\n\n");
|
||||||
if (downloadPartialzip(getLatestFirmwareUrl(), pathStr, _sepPath = SEP_TMP_PATH))
|
if (downloadPartialzip(getLatestFirmwareUrl(), pathStr, _sepPath = SEP_TMP_PATH))
|
||||||
reterror(-33, "could not download SEP\n");
|
reterror(-33, "could not download SEP\n");
|
||||||
|
@ -688,20 +688,20 @@ plist_t futurerestore::loadPlistFromFile(const char *path){
|
||||||
return ret;
|
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;
|
char *pathStr = NULL;
|
||||||
ptr_smart<plist_t> buildmanifest(NULL,plist_free);
|
ptr_smart<plist_t> buildmanifest(NULL,plist_free);
|
||||||
|
|
||||||
plist_from_xml(manifeststr, (uint32_t)strlen(manifeststr), &buildmanifest);
|
plist_from_xml(manifeststr, (uint32_t)strlen(manifeststr), &buildmanifest);
|
||||||
|
|
||||||
if (plist_t buildidentities = plist_dict_get_item(buildmanifest._p, "BuildIdentities"))
|
if (plist_t identity = getBuildidentity(buildmanifest._p, model, isUpdateInstall))
|
||||||
if (plist_t firstIdentitie = plist_array_get_item(buildidentities, 0))
|
if (plist_t manifest = plist_dict_get_item(identity, "Manifest"))
|
||||||
if (plist_t manifest = plist_dict_get_item(firstIdentitie, "Manifest"))
|
if (plist_t elem = plist_dict_get_item(manifest, element))
|
||||||
if (plist_t elem = plist_dict_get_item(manifest, element))
|
if (plist_t info = plist_dict_get_item(elem, "Info"))
|
||||||
if (plist_t info = plist_dict_get_item(elem, "Info"))
|
if (plist_t path = plist_dict_get_item(info, "Path"))
|
||||||
if (plist_t path = plist_dict_get_item(info, "Path"))
|
if (plist_get_string_val(path, &pathStr), pathStr)
|
||||||
if (plist_get_string_val(path, &pathStr), pathStr)
|
goto noerror;
|
||||||
goto noerror;
|
|
||||||
reterror(-31, "could not get %s path\n",element);
|
reterror(-31, "could not get %s path\n",element);
|
||||||
noerror:
|
noerror:
|
||||||
return pathStr;
|
return pathStr;
|
||||||
|
|
|
@ -89,7 +89,7 @@ public:
|
||||||
static char *getNonceFromAPTicket(const char* apticketPath);
|
static char *getNonceFromAPTicket(const char* apticketPath);
|
||||||
static plist_t loadPlistFromFile(const char *path);
|
static plist_t loadPlistFromFile(const char *path);
|
||||||
static void saveStringToFile(const char *str, 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;
|
futurerestore client;
|
||||||
if (!client.init()) reterror(-3,"can't init, no device found\n");
|
if (!client.init()) reterror(-3,"can't init, no device found\n");
|
||||||
|
|
||||||
if (apticketPaths.size()) client.loadAPTickets(apticketPaths);
|
try {
|
||||||
|
if (apticketPaths.size()) client.loadAPTickets(apticketPaths);
|
||||||
if (!((apticketPaths.size() && ipsw)
|
|
||||||
&& ((basebandPath && basebandManifestPath) || (flags & FLAG_LATEST_BASEBAND))
|
if (!((apticketPaths.size() && ipsw)
|
||||||
&& ((sepPath && sepManifestPath) || (flags & FLAG_LATEST_SEP)))) {
|
&& ((basebandPath && basebandManifestPath) || (flags & FLAG_LATEST_BASEBAND))
|
||||||
if (!(flags & FLAG_WAIT) || ipsw){
|
&& ((sepPath && sepManifestPath) || (flags & FLAG_LATEST_SEP)))) {
|
||||||
error("missing argument\n");
|
if (!(flags & FLAG_WAIT) || ipsw){
|
||||||
cmd_help();
|
error("missing argument\n");
|
||||||
err = -2;
|
cmd_help();
|
||||||
}else{
|
err = -2;
|
||||||
client.putDeviceIntoRecovery();
|
}else{
|
||||||
client.waitForNonce();
|
client.putDeviceIntoRecovery();
|
||||||
info("done\n");
|
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;
|
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 {
|
try {
|
||||||
res = client.doRestore(ipsw, flags & FLAG_UPDATE);
|
res = client.doRestore(ipsw, flags & FLAG_UPDATE);
|
||||||
|
|
Loading…
Reference in a new issue