Commit f117962e authored by Ethan Yonker's avatar Ethan Yonker

Make it backwards compatible with 4.4

Change-Id: I668604cddc8e8afbf78709f3f872bea4e9f4aa06
parent 34ae483e
......@@ -116,12 +116,18 @@ LOCAL_SHARED_LIBRARIES :=
LOCAL_STATIC_LIBRARIES += libguitwrp
LOCAL_SHARED_LIBRARIES += libaosprecovery libz libc libcutils libstdc++ libtar libblkid libminuitwrp libminadbd libmtdutils libminzip libtwadbbu
LOCAL_SHARED_LIBRARIES += libcrecovery libbase libcrypto
LOCAL_SHARED_LIBRARIES += libcrecovery
ifeq ($(shell test $(PLATFORM_SDK_VERSION) -lt 23; echo $$?),0)
LOCAL_SHARED_LIBRARIES += libstlport
LOCAL_SHARED_LIBRARIES += libstlport libmincrypttwrp
LOCAL_C_INCLUDES += $(LOCAL_PATH)/libmincrypt/includes
LOCAL_CFLAGS += -DUSE_OLD_VERIFIER
else
LOCAL_SHARED_LIBRARIES += libc++
LOCAL_SHARED_LIBRARIES += libc++ libcrypto
endif
ifeq ($(shell test $(PLATFORM_SDK_VERSION) -ge 24; echo $$?),0)
LOCAL_SHARED_LIBRARIES += libbase
endif
ifneq ($(wildcard system/core/libsparse/Android.mk),)
......@@ -340,13 +346,15 @@ LOCAL_ADDITIONAL_DEPENDENCIES := \
mke2fs.conf \
pigz \
teamwin \
toolbox_symlinks \
twrp \
unpigz_symlink \
fsck.fat \
fatlabel \
mkfs.fat \
permissive.sh \
simg2img_twrp
simg2img_twrp \
init.recovery.service.rc
ifneq ($(TARGET_ARCH), arm64)
ifneq ($(TARGET_ARCH), x86_64)
......@@ -503,23 +511,27 @@ endif # !TW_USE_TOOLBOX
# recovery-persist (system partition dynamic executable run after /data mounts)
# ===============================
include $(CLEAR_VARS)
LOCAL_SRC_FILES := recovery-persist.cpp
LOCAL_MODULE := recovery-persist
LOCAL_SHARED_LIBRARIES := liblog libbase
LOCAL_CFLAGS := -Werror
LOCAL_INIT_RC := recovery-persist.rc
include $(BUILD_EXECUTABLE)
ifeq ($(shell test $(PLATFORM_SDK_VERSION) -ge 24; echo $$?),0)
include $(CLEAR_VARS)
LOCAL_SRC_FILES := recovery-persist.cpp
LOCAL_MODULE := recovery-persist
LOCAL_SHARED_LIBRARIES := liblog libbase
LOCAL_CFLAGS := -Werror
LOCAL_INIT_RC := recovery-persist.rc
include $(BUILD_EXECUTABLE)
endif
# recovery-refresh (system partition dynamic executable run at init)
# ===============================
include $(CLEAR_VARS)
LOCAL_SRC_FILES := recovery-refresh.cpp
LOCAL_MODULE := recovery-refresh
LOCAL_SHARED_LIBRARIES := liblog
LOCAL_CFLAGS := -Werror
LOCAL_INIT_RC := recovery-refresh.rc
include $(BUILD_EXECUTABLE)
ifeq ($(shell test $(PLATFORM_SDK_VERSION) -ge 24; echo $$?),0)
include $(CLEAR_VARS)
LOCAL_SRC_FILES := recovery-refresh.cpp
LOCAL_MODULE := recovery-refresh
LOCAL_SHARED_LIBRARIES := liblog
LOCAL_CFLAGS := -Werror
LOCAL_INIT_RC := recovery-refresh.rc
include $(BUILD_EXECUTABLE)
endif
# shared libfusesideload
# ===============================
......@@ -531,7 +543,14 @@ LOCAL_CFLAGS += -D_XOPEN_SOURCE -D_GNU_SOURCE
LOCAL_MODULE_TAGS := optional
LOCAL_MODULE := libfusesideload
LOCAL_SHARED_LIBRARIES := libcutils libc libcrypto
LOCAL_SHARED_LIBRARIES := libcutils libc
ifeq ($(shell test $(PLATFORM_SDK_VERSION) -lt 22; echo $$?),0)
LOCAL_C_INCLUDES := $(LOCAL_PATH)/libmincrypt/includes
LOCAL_SHARED_LIBRARIES += libmincrypttwrp
LOCAL_CFLAGS += -DUSE_MINCRYPT
else
LOCAL_SHARED_LIBRARIES += libcrypto
endif
include $(BUILD_SHARED_LIBRARY)
# shared libaosprecovery for Apache code
......@@ -540,8 +559,18 @@ include $(CLEAR_VARS)
LOCAL_MODULE := libaosprecovery
LOCAL_MODULE_TAGS := eng optional
LOCAL_SRC_FILES := adb_install.cpp asn1_decoder.cpp bootloader.cpp legacy_property_service.c verifier.cpp set_metadata.c tw_atomic.cpp
LOCAL_SHARED_LIBRARIES += libc liblog libcutils libmtdutils libfusesideload libselinux libcrypto
LOCAL_CFLAGS := -std=gnu++0x
LOCAL_SRC_FILES := adb_install.cpp asn1_decoder.cpp bootloader.cpp legacy_property_service.cpp set_metadata.cpp tw_atomic.cpp
LOCAL_SHARED_LIBRARIES += libc liblog libcutils libmtdutils libfusesideload libselinux
ifeq ($(shell test $(PLATFORM_SDK_VERSION) -lt 23; echo $$?),0)
LOCAL_SHARED_LIBRARIES += libstdc++ libstlport libmincrypttwrp
LOCAL_C_INCLUDES := bionic external/stlport/stlport $(LOCAL_PATH)/libmincrypt/includes
LOCAL_SRC_FILES += oldverifier/verifier.cpp
LOCAL_CFLAGS += -DUSE_OLD_VERIFIER
else
LOCAL_SHARED_LIBRARIES += libc++ libcrypto
LOCAL_SRC_FILES += verifier.cpp
endif
ifneq ($(BOARD_RECOVERY_BLDRMSG_OFFSET),)
LOCAL_CFLAGS += -DBOARD_RECOVERY_BLDRMSG_OFFSET=$(BOARD_RECOVERY_BLDRMSG_OFFSET)
......@@ -598,6 +627,7 @@ include $(commands_recovery_local_path)/injecttwrp/Android.mk \
$(commands_recovery_local_path)/libblkid/Android.mk \
$(commands_recovery_local_path)/minuitwrp/Android.mk \
$(commands_recovery_local_path)/openaes/Android.mk \
$(commands_recovery_local_path)/toolbox/Android.mk \
$(commands_recovery_local_path)/twrpTarMain/Android.mk \
$(commands_recovery_local_path)/mtp/Android.mk \
$(commands_recovery_local_path)/minzip/Android.mk \
......@@ -608,6 +638,10 @@ include $(commands_recovery_local_path)/injecttwrp/Android.mk \
$(commands_recovery_local_path)/adbbu/Android.mk \
$(commands_recovery_local_path)/libpixelflinger/Android.mk
ifeq ($(shell test $(PLATFORM_SDK_VERSION) -lt 23; echo $$?),0)
include $(commands_recovery_local_path)/libmincrypt/Android.mk
endif
ifeq ($(TW_INCLUDE_CRYPTO), true)
include $(commands_recovery_local_path)/crypto/lollipop/Android.mk
include $(commands_recovery_local_path)/crypto/scrypt/Android.mk
......
......@@ -31,7 +31,11 @@
#include "adb_install.h"
#include "minadbd/fuse_adb_provider.h"
#include "fuse_sideload.h"
#ifdef USE_OLD_VERIFIER
#include "oldverifier/verifier.h"
#else
#include "verifier.h"
#endif
static RecoveryUI* ui = NULL;
......
......@@ -32,7 +32,7 @@ extern "C" {
#include "common.h"
#include "mtdutils/mtdutils.h"
//#include "roots.h"
#include "unique_fd.h"
//#include "unique_fd.h"
// fake Volume struct that allows us to use the AOSP code easily
struct Volume
......@@ -232,33 +232,36 @@ static int get_bootloader_message_block(bootloader_message* out,
static int set_bootloader_message_block(const bootloader_message* in,
const Volume* v) {
wait_for_device(v->blk_device);
unique_fd fd(open(v->blk_device, O_WRONLY | O_SYNC));
if (fd.get() == -1) {
int fd = open(v->blk_device, O_WRONLY | O_SYNC);
if (fd == -1) {
LOGE("failed to open \"%s\": %s\n", v->blk_device, strerror(errno));
return -1;
}
#ifdef BOARD_RECOVERY_BLDRMSG_OFFSET
lseek(fd.get(), BOARD_RECOVERY_BLDRMSG_OFFSET, SEEK_SET);
lseek(fd, BOARD_RECOVERY_BLDRMSG_OFFSET, SEEK_SET);
#endif
size_t written = 0;
const uint8_t* start = reinterpret_cast<const uint8_t*>(in);
size_t total = sizeof(*in);
while (written < total) {
ssize_t wrote = TEMP_FAILURE_RETRY(write(fd.get(), start + written, total - written));
ssize_t wrote = TEMP_FAILURE_RETRY(write(fd, start + written, total - written));
if (wrote == -1) {
LOGE("failed to write %" PRId64 " bytes: %s\n",
static_cast<off64_t>(written), strerror(errno));
LOGE("failed to write some bytes: %s\n",
strerror(errno));
close(fd);
return -1;
}
written += wrote;
}
if (fsync(fd.get()) == -1) {
if (fsync(fd) == -1) {
LOGE("failed to fsync \"%s\": %s\n", v->blk_device, strerror(errno));
close(fd);
return -1;
}
close(fd);
return 0;
}
......
......@@ -31,6 +31,26 @@ include $(BUILD_PREBUILT)
endif
ifeq ($(shell test $(PLATFORM_SDK_VERSION) -ge 22; echo $$?),0)
include $(CLEAR_VARS)
LOCAL_MODULE := init.recovery.service.rc
LOCAL_MODULE_TAGS := eng
LOCAL_MODULE_CLASS := RECOVERY_EXECUTABLES
LOCAL_MODULE_PATH := $(TARGET_ROOT_OUT)
LOCAL_SRC_FILES := init.recovery.servicenew.rc
include $(BUILD_PREBUILT)
else
include $(CLEAR_VARS)
LOCAL_MODULE := init.recovery.service.rc
LOCAL_MODULE_TAGS := eng
LOCAL_MODULE_CLASS := RECOVERY_EXECUTABLES
LOCAL_MODULE_PATH := $(TARGET_ROOT_OUT)
LOCAL_SRC_FILES := init.recovery.serviceold.rc
include $(BUILD_PREBUILT)
endif
ifeq ($(TWRP_INCLUDE_LOGCAT), true)
ifeq ($(TARGET_USES_LOGD), true)
......
import /init.recovery.logd.rc
import /init.recovery.usb.rc
import /init.recovery.service.rc
import /init.recovery.${ro.hardware}.rc
on early-init
......@@ -109,9 +110,6 @@ service healthd /sbin/healthd -r
critical
seclabel u:r:healthd:s0
service recovery /sbin/recovery
seclabel u:r:recovery:s0
service adbd /sbin/adbd --root_seclabel=u:r:su:s0 --device_banner=recovery
disabled
socket adbd stream 660 system system
......
on boot
# For starting recovery on 5.0 and newer
service recovery /sbin/recovery
seclabel u:r:recovery:s0
on boot
# For starting recovery on 4.4 and older
service recovery /sbin/recovery
......@@ -61,7 +61,12 @@
#include <sys/uio.h>
#include <unistd.h>
#ifdef USE_MINCRYPT
#include "mincrypt/sha256.h"
#define SHA256_DIGEST_LENGTH SHA256_DIGEST_SIZE
#else
#include <openssl/sha.h>
#endif
#include "fuse_sideload.h"
......@@ -275,7 +280,11 @@ static int fetch_block(struct fuse_data* fd, uint32_t block) {
// - Otherwise, return -EINVAL for the read.
uint8_t hash[SHA256_DIGEST_LENGTH];
#ifdef USE_MINCRYPT
SHA256_hash(fd->block_data, fd->block_size, hash);
#else
SHA256(fd->block_data, fd->block_size, hash);
#endif
uint8_t* blockhash = fd->hashes + block * SHA256_DIGEST_LENGTH;
if (memcmp(hash, blockhash, SHA256_DIGEST_LENGTH) == 0) {
return 0;
......@@ -527,3 +536,9 @@ int run_fuse_sideload(struct provider_vtab* vtab, void* cookie,
return result;
}
extern "C" int run_old_fuse_sideload(struct provider_vtab* vtab, void* cookie,
uint64_t file_size, uint32_t block_size)
{
return run_fuse_sideload(vtab, cookie, file_size, block_size);
}
......@@ -35,4 +35,13 @@ struct provider_vtab {
int run_fuse_sideload(struct provider_vtab* vtab, void* cookie,
uint64_t file_size, uint32_t block_size);
#ifdef __cplusplus
extern "C" {
#endif
int run_old_fuse_sideload(struct provider_vtab* vtab, void* cookie,
uint64_t file_size, uint32_t block_size);
#ifdef __cplusplus
}
#endif
#endif
......@@ -50,8 +50,8 @@ extern "C" {
#include "../twinstall.h"
#include "cutils/properties.h"
#include "../adb_install.h"
#include "../set_metadata.h"
};
#include "../set_metadata.h"
#include "../minuitwrp/minui.h"
#include "rapidxml.hpp"
......
......@@ -36,6 +36,10 @@
//#include <sys/atomics.h>
#include "legacy_property_service.h"
#ifndef INT32_MAX
#define INT32_MAX (2147483647)
#endif
static int persistent_properties_loaded = 0;
static int property_area_inited = 0;
......@@ -108,9 +112,9 @@ static int init_property_area(void)
fcntl(pa_workspace.fd, F_SETFD, FD_CLOEXEC);
pa_info_array = (void*) (((char*) pa_workspace.data) + PA_INFO_START);
pa_info_array = (prop_info*) (((char*) pa_workspace.data) + PA_INFO_START);
pa = pa_workspace.data;
pa = (prop_area*)(pa_workspace.data);
memset(pa, 0, PA_SIZE);
pa->magic = PROP_AREA_MAGIC;
pa->version = PROP_AREA_VERSION;
......
......@@ -63,5 +63,5 @@ int run_adb_fuse(int sfd, uint64_t file_size, uint32_t block_size) {
vtab.read_block = read_block_adb;
vtab.close = close_adb;
return run_fuse_sideload(&vtab, &ad, file_size, block_size);
return run_old_fuse_sideload(&vtab, &ad, file_size, block_size);
}
This diff is collapsed.
/*
* Copyright (C) 2008 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef _RECOVERY_VERIFIER_H
#define _RECOVERY_VERIFIER_H
#include "mincrypt/p256.h"
#include "mincrypt/rsa.h"
#define ASSUMED_UPDATE_BINARY_NAME "META-INF/com/google/android/update-binary"
enum { INSTALL_SUCCESS, INSTALL_ERROR, INSTALL_CORRUPT };
static const float VERIFICATION_PROGRESS_FRACTION = 0.25;
typedef struct {
p256_int x;
p256_int y;
} ECPublicKey;
typedef struct {
typedef enum {
RSA,
EC,
} KeyType;
int hash_len; // SHA_DIGEST_SIZE (SHA-1) or SHA256_DIGEST_SIZE (SHA-256)
KeyType key_type;
RSAPublicKey* rsa;
ECPublicKey* ec;
} Certificate;
/* addr and length define a an update package file that has been
* loaded (or mmap'ed, or whatever) into memory. Verify that the file
* is signed and the signature matches one of the given keys. Return
* one of the constants below.
*/
int verify_file(unsigned char* addr, size_t length);
Certificate* load_keys(const char* filename, int* numKeys);
#define VERIFY_SUCCESS 0
#define VERIFY_FAILURE 1
#endif /* _RECOVERY_VERIFIER_H */
......@@ -117,8 +117,10 @@ else
RELINK_SOURCE_FILES += $(TARGET_OUT_SHARED_LIBRARIES)/libcorkscrew.so
endif
endif
#RELINK_SOURCE_FILES += $(TARGET_OUT_SHARED_LIBRARIES)/libmincrypttwrp.so
#RELINK_SOURCE_FILES += $(TARGET_RECOVERY_ROOT_OUT)/sbin/toolbox
ifeq ($(shell test $(PLATFORM_SDK_VERSION) -lt 24; echo $$?),0)
RELINK_SOURCE_FILES += $(TARGET_OUT_SHARED_LIBRARIES)/libmincrypttwrp.so
endif
RELINK_SOURCE_FILES += $(TARGET_RECOVERY_ROOT_OUT)/sbin/toolbox
ifneq ($(TW_OEM_BUILD),true)
RELINK_SOURCE_FILES += $(TARGET_RECOVERY_ROOT_OUT)/sbin/twrp
else
......
......@@ -28,18 +28,10 @@
#ifndef _RECOVERY_SET_CONTEXTS_H
#define _RECOVERY_SET_CONTEXTS_H
#ifdef __cplusplus
extern "C" {
#endif
#include <sys/stat.h>
#include "selinux/selinux.h"
int tw_get_default_metadata(const char* filename);
int tw_set_default_metadata(const char* filename);
#ifdef __cplusplus
}
#endif
#endif //_RECOVERY_SET_CONTEXTS_H
......@@ -2,9 +2,13 @@ TWRP_TOOLBOX_PATH := $(call my-dir)
LOCAL_PATH := system/core/toolbox
include $(CLEAR_VARS)
OUR_TOOLS := \
start \
stop \
OUR_TOOLS :=
ifeq ($(shell test $(PLATFORM_SDK_VERSION) -lt 24; echo $$?),0)
OUR_TOOLS := \
start \
stop
endif
ifeq ($(shell test $(PLATFORM_SDK_VERSION) -lt 23; echo $$?),0)
OUR_TOOLS += \
......@@ -227,6 +231,13 @@ ifeq ($(shell test $(PLATFORM_SDK_VERSION) -gt 22; echo $$?),0)
LOCAL_SRC_FILES += ../../../$(TWRP_TOOLBOX_PATH)/ls.c
endif
endif
ifeq ($(shell test $(PLATFORM_SDK_VERSION) -gt 23; echo $$?),0)
# Rule for making start and stop in N trees
LOCAL_SRC_FILES += \
../../../$(TWRP_TOOLBOX_PATH)/start.c \
../../../$(TWRP_TOOLBOX_PATH)/stop.c
OUR_TOOLS += start stop
endif
LOCAL_MODULE := toolbox_recovery
LOCAL_MODULE_STEM := toolbox
......
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#include <cutils/properties.h>
int start_main(int argc, char *argv[])
{
if(argc > 1) {
property_set("ctl.start", argv[1]);
} else {
/* defaults to starting the common services stopped by stop.c */
property_set("ctl.start", "netd");
property_set("ctl.start", "surfaceflinger");
property_set("ctl.start", "zygote");
property_set("ctl.start", "zygote_secondary");
}
return 0;
}
#include <stdio.h>
#include <string.h>
#include <cutils/properties.h>
int stop_main(int argc, char *argv[])
{
if(argc > 1) {
property_set("ctl.stop", argv[1]);
} else{
/* defaults to stopping the common services */
property_set("ctl.stop", "zygote_secondary");
property_set("ctl.stop", "zygote");
property_set("ctl.stop", "surfaceflinger");
property_set("ctl.stop", "netd");
}
return 0;
}
# Copyright 2012 Google Inc. All Rights Reserved.
# Prevent RecoveryLocalizer already defined errors in older trees
ifeq ($(shell test $(PLATFORM_SDK_VERSION) -ge 24; echo $$?),0)
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
......@@ -10,3 +14,5 @@ LOCAL_MODULE_TAGS := optional
LOCAL_SRC_FILES := $(call all-java-files-under, src)
include $(BUILD_PACKAGE)
endif
......@@ -32,7 +32,11 @@
#include "mtdutils/mtdutils.h"
#include "minzip/SysUtil.h"
#include "minzip/Zip.h"
#ifdef USE_OLD_VERIFIER
#include "oldverifier/verifier.h"
#else
#include "verifier.h"
#endif
#include "variables.h"
#include "data.hpp"
#include "partitions.hpp"
......@@ -40,9 +44,9 @@
#include "twrp-functions.hpp"
#include "gui/gui.hpp"
#include "gui/pages.hpp"
#include "legacy_property_service.h"
extern "C" {
#include "gui/gui.h"
#include "legacy_property_service.h"
}
static const char* properties_path = "/dev/__properties__";
......
......@@ -51,10 +51,10 @@
#ifndef TW_EXCLUDE_ENCRYPTED_BACKUPS
#include "openaes/inc/oaes_lib.h"
#endif
#include "set_metadata.h"
extern "C" {
#include "libcrecovery/common.h"
#include "set_metadata.h"
}
/* Execute a command */
......
......@@ -34,8 +34,8 @@
extern "C" {
#include "gui/gui.h"
#include "set_metadata.h"
}
#include "set_metadata.h"
#include "gui/gui.hpp"
#include "gui/pages.hpp"
#include "gui/objects.hpp"
......
......@@ -21,7 +21,6 @@ extern "C" {
#include "libtar/libtar.h"
#include "twrpTar.h"
#include "tarWrite.h"
#include "set_metadata.h"
}
#include <sys/types.h>
#include <sys/stat.h>
......@@ -51,9 +50,7 @@ extern "C" {
#ifndef BUILD_TWRPTAR_MAIN
#include "data.hpp"
#include "infomanager.hpp"
extern "C" {
#include "set_metadata.h"
}
#include "set_metadata.h"
#endif //ndef BUILD_TWRPTAR_MAIN
using namespace std;
......@@ -69,6 +66,9 @@ twrpTar::twrpTar(void) {
Total_Backup_Size = 0;
Archive_Current_Size = 0;
include_root_dir = true;
tar_type.openfunc = open;
tar_type.closefunc = close;
tar_type.readfunc = read;
}
twrpTar::~twrpTar(void) {
......@@ -961,7 +961,7 @@ int twrpTar::createTar() {
close(pipes[3]);
fd = pipes[1];
init_libtar_no_buffer(progress_pipe_fd);
tar_type = { open, close, read, write_tar_no_buffer };
tar_type.writefunc = write_tar_no_buffer;
if(tar_fdopen(&t, fd, charRootDir, &tar_type, O_WRONLY | O_CREAT | O_EXCL | O_LARGEFILE, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH, TAR_GNU | TAR_STORE_SELINUX) != 0) {
close(fd);
LOGINFO("tar_fdopen failed\n");
......@@ -1021,7 +1021,7 @@ int twrpTar::createTar() {
close(pigzfd[0]); // close parent input
fd = pigzfd[1]; // copy parent output
init_libtar_no_buffer(progress_pipe_fd);
tar_type = { open, close, read, write_tar_no_buffer };
tar_type.writefunc = write_tar_no_buffer;
if(tar_fdopen(&t, fd, charRootDir, &tar_type, O_WRONLY | O_CREAT | O_EXCL | O_LARGEFILE, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH, TAR_GNU | TAR_STORE_SELINUX) != 0) {
close(fd);
LOGINFO("tar_fdopen failed\n");
......@@ -1071,7 +1071,7 @@ int twrpTar::createTar() {
close(oaesfd[0]); // close parent input
fd = oaesfd[1]; // copy parent output
init_libtar_no_buffer(progress_pipe_fd);
tar_type = { open, close, read, write_tar_no_buffer };
tar_type.writefunc = write_tar_no_buffer;
if(tar_fdopen(&t, fd, charRootDir, &tar_type, O_WRONLY | O_CREAT | O_EXCL | O_LARGEFILE, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH, TAR_GNU | TAR_STORE_SELINUX) != 0) {
close(fd);
LOGINFO("tar_fdopen failed\n");
......@@ -1083,10 +1083,9 @@ int twrpTar::createTar() {
} else {
// Not compressed or encrypted
init_libtar_buffer(0, progress_pipe_fd);
tar_type = { open, close, read, write_tar };
if (part_settings->adbbackup) {
LOGINFO("Opening TW_ADB_BACKUP uncompressed stream\n");
tar_type = { open, close, read, write_tar_no_buffer };
tar_type.writefunc = write_tar_no_buffer;
output_fd = open(TW_ADB_BACKUP, O_WRONLY);
if(tar_fdopen(&t, output_fd, charRootDir, &tar_type, O_WRONLY | O_CREAT | O_EXCL | O_LARGEFILE, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH, TAR_GNU | TAR_STORE_SELINUX) != 0) {
close(output_fd);
......@@ -1095,6 +1094,7 @@ int twrpTar::createTar() {
}
}
else {
tar_type.writefunc = write_tar;
if (tar_open(&t, charTarFile, &tar_type, O_WRONLY | O_CREAT | O_LARGEFILE, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH, TAR_GNU | TAR_STORE_SELINUX) == -1) {
LOGERR("tar_open error opening '%s'\n", tarfn.c_str());
gui_err("backup_error=Error creating backup.");
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment