Manual merge of shuhaodo:master 0413d6dedb to work with iOS 11

pull/2/merge
Krista Grothoff 6 years ago
parent 01632ee738
commit b434c97804

@ -39,6 +39,11 @@
#include "mailprivacy_smime.h"
#include <string.h>
#if __APPLE__
#include <TargetConditionals.h>
#endif
#ifdef WIN32
# include "win_etpan.h"
# define WEXITSTATUS(r) (r)
@ -1542,6 +1547,12 @@ static int get_cert_from_sig(struct mailprivacy * privacy,
int r;
char command[PATH_MAX];
#if TARGET_OS_IPHONE || TARGET_IPHONE_SIMULATOR
//https://github.com/dinhviethoa/libetpan/issues/275
//get_cert_from_sig is not needed on iOS
return MAIL_ERROR_COMMAND;
#endif
if (* cert_dir == '\0')
return MAIL_ERROR_INVAL;
@ -1561,7 +1572,7 @@ static int get_cert_from_sig(struct mailprivacy * privacy,
cur = clist_begin(mime->mm_data.mm_multipart.mm_mp_list);
if (cur == NULL) {
res = MAIL_ERROR_INVAL;
goto err;
goto err;
}
signed_mime = cur->data;
@ -1602,7 +1613,13 @@ static int get_cert_from_sig(struct mailprivacy * privacy,
"openssl pkcs7 -inform DER -in '%s' -out '%s' -print_certs 2>/dev/null",
quoted_signature_filename, quoted_store_cert_filename);
r = system(command);
// N.B. This is only about compilation - we already don't execute this function with iPhone.
#if !TARGET_OS_IPHONE && !TARGET_IPHONE_SIMULATOR
//https://github.com/dinhviethoa/libetpan/issues/275
//system() is not supported on iOS 11.
r = system(command);
#endif
if (WEXITSTATUS(r) != 0) {
res = MAIL_ERROR_COMMAND;
goto unlink_signature;

@ -40,6 +40,10 @@
#include "mailprivacy_tools.h"
#include "mailprivacy_tools_private.h"
#if __APPLE__
#include <TargetConditionals.h>
#endif
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
@ -1331,6 +1335,12 @@ int mailprivacy_spawn_and_wait(char * command, char * passphrase,
char * stdoutfile, char * stderrfile,
int * bad_passphrase)
{
#if TARGET_OS_IPHONE || TARGET_IPHONE_SIMULATOR
//https://github.com/dinhviethoa/libetpan/issues/275
//mailprivacy_spawn_and_wait is not needed on iOS
return MAIL_ERROR_COMMAND;
#endif
#ifdef WIN32
int res;
SECURITY_ATTRIBUTES sec_attr;
@ -1517,11 +1527,16 @@ int mailprivacy_spawn_and_wait(char * command, char * passphrase,
Dup2(fd_err, 2);
Close(fd_err);
#if !TARGET_OS_IPHONE && !TARGET_IPHONE_SIMULATOR
//https://github.com/dinhviethoa/libetpan/issues/275
//system() is not supported on iOS 11.
// BUG: status may be -1 and errno may be EINTR if waitpid(2) was
// interrupted by a signal; to handle that properly the PID of the
// fork(2)ed child has to be determined and waitpid(2) has to be
// called again
status = system(command);
#endif
exit(WEXITSTATUS(status));
}

Loading…
Cancel
Save