From b0a3e6ddab96766b1efd05a94c1999aacdf8a20d Mon Sep 17 00:00:00 2001 From: Martin Szulecki Date: Mon, 15 Jun 2020 22:14:31 +0200 Subject: [PATCH 01/25] Post release version bump to 1.1.2 --- configure.ac | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configure.ac b/configure.ac index 95b29c2..9747ff6 100644 --- a/configure.ac +++ b/configure.ac @@ -2,7 +2,7 @@ # Process this file with autoconf to produce a configure script. AC_PREREQ(2.64) -AC_INIT([libideviceactivation], [1.1.1], [https://github.com/libimobiledevice/libideviceactivation/issues],, [https://libimobiledevice.org]) +AC_INIT([libideviceactivation], [1.1.2], [https://github.com/libimobiledevice/libideviceactivation/issues],, [https://libimobiledevice.org]) AM_INIT_AUTOMAKE([dist-bzip2 no-dist-gzip check-news]) m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES]) AC_CONFIG_SRCDIR([src/]) From b2d7536e612b8c98d669df7d92520c107104efa0 Mon Sep 17 00:00:00 2001 From: Nikias Bassen Date: Wed, 30 Jun 2021 02:37:10 +0200 Subject: [PATCH 02/25] README: Fix typo --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 12bd0a1..786f657 100644 --- a/README.md +++ b/README.md @@ -81,7 +81,7 @@ ticket first to discuss the idea upfront to ensure less effort for everyone. Please make sure your contribution adheres to: * Try to follow the code style of the project -* Commit messages should describe the change well without being to short +* Commit messages should describe the change well without being too short * Try to split larger changes into individual commits of a common domain * Use your real name and a valid email address for your commits From 156fa95b0cc02f40060e3635edee6ef500f89964 Mon Sep 17 00:00:00 2001 From: Nikias Bassen Date: Mon, 20 Sep 2021 01:03:11 +0200 Subject: [PATCH 03/25] Update deprecated autoconf macros and update m4 files --- configure.ac | 18 +-- m4/as-compiler-flag.m4 | 4 +- m4/ax_pthread.m4 | 255 +++++++++++++++++++++++------------------ 3 files changed, 157 insertions(+), 120 deletions(-) diff --git a/configure.ac b/configure.ac index 9747ff6..328919b 100644 --- a/configure.ac +++ b/configure.ac @@ -1,7 +1,7 @@ # -*- Autoconf -*- # Process this file with autoconf to produce a configure script. -AC_PREREQ(2.64) +AC_PREREQ(2.68) AC_INIT([libideviceactivation], [1.1.2], [https://github.com/libimobiledevice/libideviceactivation/issues],, [https://libimobiledevice.org]) AM_INIT_AUTOMAKE([dist-bzip2 no-dist-gzip check-news]) m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES]) @@ -31,9 +31,9 @@ AC_SUBST(LIBXML2_VERSION) # Checks for programs. AC_PROG_CC -AC_PROG_CXX +#AC_PROG_CXX AM_PROG_CC_C_O -AC_PROG_LIBTOOL +LT_INIT # Checks for libraries. PKG_CHECK_MODULES(libimobiledevice, libimobiledevice-1.0 >= $LIBIMOBILEDEVICE_VERSION) @@ -42,7 +42,6 @@ PKG_CHECK_MODULES(libcurl, libcurl >= $LIBCURL_VERSION) PKG_CHECK_MODULES(libxml2, libxml-2.0 >= $LIBXML2_VERSION) # Checks for header files. -AC_HEADER_STDC AC_CHECK_HEADERS([stdint.h stdlib.h string.h sys/socket.h]) # Checks for typedefs, structures, and compiler characteristics. @@ -57,17 +56,17 @@ AC_TYPE_UINT8_T AC_CHECK_FUNCS([strcasecmp strdup strerror strndup]) # Check for operating system -AC_MSG_CHECKING([wether we need platform-specific build settings for ${host_os}]) +AC_MSG_CHECKING([for platform-specific build settings]) case ${host_os} in *mingw32*|*cygwin*) - AC_MSG_RESULT([yes]) + AC_MSG_RESULT([${host_os}]) win32=true ;; darwin*|*android*) - AC_MSG_RESULT([no]) + AC_MSG_RESULT([${host_os}]) ;; *) - AC_MSG_RESULT([yes]) + AC_MSG_RESULT([${host_os}]) AX_PTHREAD([], [AC_MSG_ERROR([pthread is required to build ${PACKAGE}])]) AC_CHECK_LIB(pthread, [pthread_once], [], [AC_MSG_ERROR([pthread with pthread_once required to build ${PACKAGE}])]) ;; @@ -84,7 +83,7 @@ esac m4_ifdef([AM_SILENT_RULES],[AM_SILENT_RULES([yes])]) -AC_OUTPUT([ +AC_CONFIG_FILES([ Makefile src/Makefile src/libideviceactivation-1.0.pc @@ -92,6 +91,7 @@ include/Makefile tools/Makefile man/Makefile ]) +AC_OUTPUT echo " Configuration for $PACKAGE $VERSION: diff --git a/m4/as-compiler-flag.m4 b/m4/as-compiler-flag.m4 index 0f660cf..baab5d9 100644 --- a/m4/as-compiler-flag.m4 +++ b/m4/as-compiler-flag.m4 @@ -18,7 +18,7 @@ AC_DEFUN([AS_COMPILER_FLAG], save_CFLAGS="$CFLAGS" CFLAGS="$CFLAGS $1" - AC_TRY_COMPILE([ ], [], [flag_ok=yes], [flag_ok=no]) + AC_COMPILE_IFELSE([AC_LANG_PROGRAM([],[])], [flag_ok=yes], [flag_ok=no]) CFLAGS="$save_CFLAGS" if test "X$flag_ok" = Xyes ; then @@ -44,7 +44,7 @@ AC_DEFUN([AS_COMPILER_FLAGS], do save_CFLAGS="$CFLAGS" CFLAGS="$CFLAGS $each" - AC_TRY_COMPILE([ ], [], [flag_ok=yes], [flag_ok=no]) + AC_COMPILE_IFELSE([AC_LANG_PROGRAM([],[])], [flag_ok=yes], [flag_ok=no]) CFLAGS="$save_CFLAGS" if test "X$flag_ok" = Xyes ; then diff --git a/m4/ax_pthread.m4 b/m4/ax_pthread.m4 index 4c4051e..9f35d13 100644 --- a/m4/ax_pthread.m4 +++ b/m4/ax_pthread.m4 @@ -1,5 +1,5 @@ # =========================================================================== -# http://www.gnu.org/software/autoconf-archive/ax_pthread.html +# https://www.gnu.org/software/autoconf-archive/ax_pthread.html # =========================================================================== # # SYNOPSIS @@ -14,20 +14,24 @@ # flags that are needed. (The user can also force certain compiler # flags/libs to be tested by setting these environment variables.) # -# Also sets PTHREAD_CC to any special C compiler that is needed for -# multi-threaded programs (defaults to the value of CC otherwise). (This -# is necessary on AIX to use the special cc_r compiler alias.) +# Also sets PTHREAD_CC and PTHREAD_CXX to any special C compiler that is +# needed for multi-threaded programs (defaults to the value of CC +# respectively CXX otherwise). (This is necessary on e.g. AIX to use the +# special cc_r/CC_r compiler alias.) # # NOTE: You are assumed to not only compile your program with these flags, # but also to link with them as well. For example, you might link with # $PTHREAD_CC $CFLAGS $PTHREAD_CFLAGS $LDFLAGS ... $PTHREAD_LIBS $LIBS +# $PTHREAD_CXX $CXXFLAGS $PTHREAD_CFLAGS $LDFLAGS ... $PTHREAD_LIBS $LIBS # # If you are only building threaded programs, you may wish to use these # variables in your default LIBS, CFLAGS, and CC: # # LIBS="$PTHREAD_LIBS $LIBS" # CFLAGS="$CFLAGS $PTHREAD_CFLAGS" +# CXXFLAGS="$CXXFLAGS $PTHREAD_CFLAGS" # CC="$PTHREAD_CC" +# CXX="$PTHREAD_CXX" # # In addition, if the PTHREAD_CREATE_JOINABLE thread-attribute constant # has a nonstandard name, this macro defines PTHREAD_CREATE_JOINABLE to @@ -55,6 +59,7 @@ # # Copyright (c) 2008 Steven G. Johnson # Copyright (c) 2011 Daniel Richard G. +# Copyright (c) 2019 Marc Stevens # # This program is free software: you can redistribute it and/or modify it # under the terms of the GNU General Public License as published by the @@ -67,7 +72,7 @@ # Public License for more details. # # You should have received a copy of the GNU General Public License along -# with this program. If not, see . +# with this program. If not, see . # # As a special exception, the respective Autoconf Macro's copyright owner # gives unlimited permission to copy, distribute and modify the configure @@ -82,7 +87,7 @@ # modified version of the Autoconf Macro, you may extend this special # exception to the GPL to apply to your modified version as well. -#serial 23 +#serial 31 AU_ALIAS([ACX_PTHREAD], [AX_PTHREAD]) AC_DEFUN([AX_PTHREAD], [ @@ -104,6 +109,7 @@ if test "x$PTHREAD_CFLAGS$PTHREAD_LIBS" != "x"; then ax_pthread_save_CFLAGS="$CFLAGS" ax_pthread_save_LIBS="$LIBS" AS_IF([test "x$PTHREAD_CC" != "x"], [CC="$PTHREAD_CC"]) + AS_IF([test "x$PTHREAD_CXX" != "x"], [CXX="$PTHREAD_CXX"]) CFLAGS="$CFLAGS $PTHREAD_CFLAGS" LIBS="$PTHREAD_LIBS $LIBS" AC_MSG_CHECKING([for pthread_join using $CC $PTHREAD_CFLAGS $PTHREAD_LIBS]) @@ -123,10 +129,12 @@ fi # (e.g. DEC) have both -lpthread and -lpthreads, where one of the # libraries is broken (non-POSIX). -# Create a list of thread flags to try. Items starting with a "-" are -# C compiler flags, and other items are library names, except for "none" -# which indicates that we try without any flags at all, and "pthread-config" -# which is a program returning the flags for the Pth emulation library. +# Create a list of thread flags to try. Items with a "," contain both +# C compiler flags (before ",") and linker flags (after ","). Other items +# starting with a "-" are C compiler flags, and remaining items are +# library names, except for "none" which indicates that we try without +# any flags at all, and "pthread-config" which is a program returning +# the flags for the Pth emulation library. ax_pthread_flags="pthreads none -Kthread -pthread -pthreads -mthreads pthread --thread-safe -mt pthread-config" @@ -194,14 +202,47 @@ case $host_os in # that too in a future libc.) So we'll check first for the # standard Solaris way of linking pthreads (-mt -lpthread). - ax_pthread_flags="-mt,pthread pthread $ax_pthread_flags" + ax_pthread_flags="-mt,-lpthread pthread $ax_pthread_flags" ;; esac +# Are we compiling with Clang? + +AC_CACHE_CHECK([whether $CC is Clang], + [ax_cv_PTHREAD_CLANG], + [ax_cv_PTHREAD_CLANG=no + # Note that Autoconf sets GCC=yes for Clang as well as GCC + if test "x$GCC" = "xyes"; then + AC_EGREP_CPP([AX_PTHREAD_CC_IS_CLANG], + [/* Note: Clang 2.7 lacks __clang_[a-z]+__ */ +# if defined(__clang__) && defined(__llvm__) + AX_PTHREAD_CC_IS_CLANG +# endif + ], + [ax_cv_PTHREAD_CLANG=yes]) + fi + ]) +ax_pthread_clang="$ax_cv_PTHREAD_CLANG" + + # GCC generally uses -pthread, or -pthreads on some platforms (e.g. SPARC) +# Note that for GCC and Clang -pthread generally implies -lpthread, +# except when -nostdlib is passed. +# This is problematic using libtool to build C++ shared libraries with pthread: +# [1] https://gcc.gnu.org/bugzilla/show_bug.cgi?id=25460 +# [2] https://bugzilla.redhat.com/show_bug.cgi?id=661333 +# [3] https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=468555 +# To solve this, first try -pthread together with -lpthread for GCC + AS_IF([test "x$GCC" = "xyes"], - [ax_pthread_flags="-pthread -pthreads $ax_pthread_flags"]) + [ax_pthread_flags="-pthread,-lpthread -pthread -pthreads $ax_pthread_flags"]) + +# Clang takes -pthread (never supported any other flag), but we'll try with -lpthread first + +AS_IF([test "x$ax_pthread_clang" = "xyes"], + [ax_pthread_flags="-pthread,-lpthread -pthread"]) + # The presence of a feature test macro requesting re-entrant function # definitions is, on some systems, a strong hint that pthreads support is @@ -224,25 +265,86 @@ AS_IF([test "x$ax_pthread_check_macro" = "x--"], [ax_pthread_check_cond=0], [ax_pthread_check_cond="!defined($ax_pthread_check_macro)"]) -# Are we compiling with Clang? -AC_CACHE_CHECK([whether $CC is Clang], - [ax_cv_PTHREAD_CLANG], - [ax_cv_PTHREAD_CLANG=no - # Note that Autoconf sets GCC=yes for Clang as well as GCC - if test "x$GCC" = "xyes"; then - AC_EGREP_CPP([AX_PTHREAD_CC_IS_CLANG], - [/* Note: Clang 2.7 lacks __clang_[a-z]+__ */ -# if defined(__clang__) && defined(__llvm__) - AX_PTHREAD_CC_IS_CLANG -# endif - ], - [ax_cv_PTHREAD_CLANG=yes]) - fi - ]) -ax_pthread_clang="$ax_cv_PTHREAD_CLANG" +if test "x$ax_pthread_ok" = "xno"; then +for ax_pthread_try_flag in $ax_pthread_flags; do + + case $ax_pthread_try_flag in + none) + AC_MSG_CHECKING([whether pthreads work without any flags]) + ;; + + *,*) + PTHREAD_CFLAGS=`echo $ax_pthread_try_flag | sed "s/^\(.*\),\(.*\)$/\1/"` + PTHREAD_LIBS=`echo $ax_pthread_try_flag | sed "s/^\(.*\),\(.*\)$/\2/"` + AC_MSG_CHECKING([whether pthreads work with "$PTHREAD_CFLAGS" and "$PTHREAD_LIBS"]) + ;; + + -*) + AC_MSG_CHECKING([whether pthreads work with $ax_pthread_try_flag]) + PTHREAD_CFLAGS="$ax_pthread_try_flag" + ;; + + pthread-config) + AC_CHECK_PROG([ax_pthread_config], [pthread-config], [yes], [no]) + AS_IF([test "x$ax_pthread_config" = "xno"], [continue]) + PTHREAD_CFLAGS="`pthread-config --cflags`" + PTHREAD_LIBS="`pthread-config --ldflags` `pthread-config --libs`" + ;; + + *) + AC_MSG_CHECKING([for the pthreads library -l$ax_pthread_try_flag]) + PTHREAD_LIBS="-l$ax_pthread_try_flag" + ;; + esac + + ax_pthread_save_CFLAGS="$CFLAGS" + ax_pthread_save_LIBS="$LIBS" + CFLAGS="$CFLAGS $PTHREAD_CFLAGS" + LIBS="$PTHREAD_LIBS $LIBS" + + # Check for various functions. We must include pthread.h, + # since some functions may be macros. (On the Sequent, we + # need a special flag -Kthread to make this header compile.) + # We check for pthread_join because it is in -lpthread on IRIX + # while pthread_create is in libc. We check for pthread_attr_init + # due to DEC craziness with -lpthreads. We check for + # pthread_cleanup_push because it is one of the few pthread + # functions on Solaris that doesn't have a non-functional libc stub. + # We try pthread_create on general principles. + + AC_LINK_IFELSE([AC_LANG_PROGRAM([#include +# if $ax_pthread_check_cond +# error "$ax_pthread_check_macro must be defined" +# endif + static void *some_global = NULL; + static void routine(void *a) + { + /* To avoid any unused-parameter or + unused-but-set-parameter warning. */ + some_global = a; + } + static void *start_routine(void *a) { return a; }], + [pthread_t th; pthread_attr_t attr; + pthread_create(&th, 0, start_routine, 0); + pthread_join(th, 0); + pthread_attr_init(&attr); + pthread_cleanup_push(routine, 0); + pthread_cleanup_pop(0) /* ; */])], + [ax_pthread_ok=yes], + []) + + CFLAGS="$ax_pthread_save_CFLAGS" + LIBS="$ax_pthread_save_LIBS" + + AC_MSG_RESULT([$ax_pthread_ok]) + AS_IF([test "x$ax_pthread_ok" = "xyes"], [break]) + + PTHREAD_LIBS="" + PTHREAD_CFLAGS="" +done +fi -ax_pthread_clang_warning=no # Clang needs special handling, because older versions handle the -pthread # option in a rather... idiosyncratic way @@ -261,11 +363,6 @@ if test "x$ax_pthread_clang" = "xyes"; then # -pthread does define _REENTRANT, and while the Darwin headers # ignore this macro, third-party headers might not.) - PTHREAD_CFLAGS="-pthread" - PTHREAD_LIBS= - - ax_pthread_ok=yes - # However, older versions of Clang make a point of warning the user # that, in an invocation where only linking and no compilation is # taking place, the -pthread option has no effect ("argument unused @@ -294,7 +391,7 @@ if test "x$ax_pthread_clang" = "xyes"; then # step ax_pthread_save_ac_link="$ac_link" ax_pthread_sed='s/conftest\.\$ac_ext/conftest.$ac_objext/g' - ax_pthread_link_step=`$as_echo "$ac_link" | sed "$ax_pthread_sed"` + ax_pthread_link_step=`AS_ECHO(["$ac_link"]) | sed "$ax_pthread_sed"` ax_pthread_2step_ac_link="($ac_compile) && (echo ==== >&5) && ($ax_pthread_link_step)" ax_pthread_save_CFLAGS="$CFLAGS" for ax_pthread_try in '' -Qunused-arguments -Wno-unused-command-line-argument unknown; do @@ -320,78 +417,7 @@ if test "x$ax_pthread_clang" = "xyes"; then fi # $ax_pthread_clang = yes -if test "x$ax_pthread_ok" = "xno"; then -for ax_pthread_try_flag in $ax_pthread_flags; do - - case $ax_pthread_try_flag in - none) - AC_MSG_CHECKING([whether pthreads work without any flags]) - ;; - - -mt,pthread) - AC_MSG_CHECKING([whether pthreads work with -mt -lpthread]) - PTHREAD_CFLAGS="-mt" - PTHREAD_LIBS="-lpthread" - ;; - - -*) - AC_MSG_CHECKING([whether pthreads work with $ax_pthread_try_flag]) - PTHREAD_CFLAGS="$ax_pthread_try_flag" - ;; - pthread-config) - AC_CHECK_PROG([ax_pthread_config], [pthread-config], [yes], [no]) - AS_IF([test "x$ax_pthread_config" = "xno"], [continue]) - PTHREAD_CFLAGS="`pthread-config --cflags`" - PTHREAD_LIBS="`pthread-config --ldflags` `pthread-config --libs`" - ;; - - *) - AC_MSG_CHECKING([for the pthreads library -l$ax_pthread_try_flag]) - PTHREAD_LIBS="-l$ax_pthread_try_flag" - ;; - esac - - ax_pthread_save_CFLAGS="$CFLAGS" - ax_pthread_save_LIBS="$LIBS" - CFLAGS="$CFLAGS $PTHREAD_CFLAGS" - LIBS="$PTHREAD_LIBS $LIBS" - - # Check for various functions. We must include pthread.h, - # since some functions may be macros. (On the Sequent, we - # need a special flag -Kthread to make this header compile.) - # We check for pthread_join because it is in -lpthread on IRIX - # while pthread_create is in libc. We check for pthread_attr_init - # due to DEC craziness with -lpthreads. We check for - # pthread_cleanup_push because it is one of the few pthread - # functions on Solaris that doesn't have a non-functional libc stub. - # We try pthread_create on general principles. - - AC_LINK_IFELSE([AC_LANG_PROGRAM([#include -# if $ax_pthread_check_cond -# error "$ax_pthread_check_macro must be defined" -# endif - static void routine(void *a) { a = 0; } - static void *start_routine(void *a) { return a; }], - [pthread_t th; pthread_attr_t attr; - pthread_create(&th, 0, start_routine, 0); - pthread_join(th, 0); - pthread_attr_init(&attr); - pthread_cleanup_push(routine, 0); - pthread_cleanup_pop(0) /* ; */])], - [ax_pthread_ok=yes], - []) - - CFLAGS="$ax_pthread_save_CFLAGS" - LIBS="$ax_pthread_save_LIBS" - - AC_MSG_RESULT([$ax_pthread_ok]) - AS_IF([test "x$ax_pthread_ok" = "xyes"], [break]) - - PTHREAD_LIBS="" - PTHREAD_CFLAGS="" -done -fi # Various other checks: if test "x$ax_pthread_ok" = "xyes"; then @@ -438,7 +464,8 @@ if test "x$ax_pthread_ok" = "xyes"; then AC_CACHE_CHECK([for PTHREAD_PRIO_INHERIT], [ax_cv_PTHREAD_PRIO_INHERIT], [AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include ]], - [[int i = PTHREAD_PRIO_INHERIT;]])], + [[int i = PTHREAD_PRIO_INHERIT; + return i;]])], [ax_cv_PTHREAD_PRIO_INHERIT=yes], [ax_cv_PTHREAD_PRIO_INHERIT=no]) ]) @@ -460,18 +487,28 @@ if test "x$ax_pthread_ok" = "xyes"; then [#handle absolute path differently from PATH based program lookup AS_CASE(["x$CC"], [x/*], - [AS_IF([AS_EXECUTABLE_P([${CC}_r])],[PTHREAD_CC="${CC}_r"])], - [AC_CHECK_PROGS([PTHREAD_CC],[${CC}_r],[$CC])])]) + [ + AS_IF([AS_EXECUTABLE_P([${CC}_r])],[PTHREAD_CC="${CC}_r"]) + AS_IF([test "x${CXX}" != "x"], [AS_IF([AS_EXECUTABLE_P([${CXX}_r])],[PTHREAD_CXX="${CXX}_r"])]) + ], + [ + AC_CHECK_PROGS([PTHREAD_CC],[${CC}_r],[$CC]) + AS_IF([test "x${CXX}" != "x"], [AC_CHECK_PROGS([PTHREAD_CXX],[${CXX}_r],[$CXX])]) + ] + ) + ]) ;; esac fi fi test -n "$PTHREAD_CC" || PTHREAD_CC="$CC" +test -n "$PTHREAD_CXX" || PTHREAD_CXX="$CXX" AC_SUBST([PTHREAD_LIBS]) AC_SUBST([PTHREAD_CFLAGS]) AC_SUBST([PTHREAD_CC]) +AC_SUBST([PTHREAD_CXX]) # Finally, execute ACTION-IF-FOUND/ACTION-IF-NOT-FOUND: if test "x$ax_pthread_ok" = "xyes"; then From 6cc8d697ad95ae3878051e9d81fe072ce047ddf5 Mon Sep 17 00:00:00 2001 From: Nikias Bassen Date: Mon, 20 Sep 2021 01:06:27 +0200 Subject: [PATCH 04/25] Check availability of constructor attribute and use it on Windows in favor of DllMain --- configure.ac | 18 ++++++++++++++++++ src/activation.c | 40 +++++++++++++++++++++++----------------- 2 files changed, 41 insertions(+), 17 deletions(-) diff --git a/configure.ac b/configure.ac index 328919b..f1ee6f0 100644 --- a/configure.ac +++ b/configure.ac @@ -73,6 +73,24 @@ case ${host_os} in esac AM_CONDITIONAL(WIN32, test x$win32 = xtrue) +# Check if the C compiler supports __attribute__((constructor)) +AC_CACHE_CHECK([wether the C compiler supports constructor/destructor attributes], + ac_cv_attribute_constructor, [ + ac_cv_attribute_constructor=no + AC_COMPILE_IFELSE([AC_LANG_PROGRAM( + [[ + static void __attribute__((constructor)) test_constructor(void) { + } + static void __attribute__((destructor)) test_destructor(void) { + } + ]], [])], + [ac_cv_attribute_constructor=yes] + )] +) +if test "$ac_cv_attribute_constructor" = "yes"; then + AC_DEFINE(HAVE_ATTRIBUTE_CONSTRUCTOR, 1, [Define if the C compiler supports constructor/destructor attributes]) +fi + AS_COMPILER_FLAGS(GLOBAL_CFLAGS, "-Wall -Wextra -Wmissing-declarations -Wredundant-decls -Wshadow -Wpointer-arith -Wwrite-strings -Wswitch-default -Wno-unused-parameter -fsigned-char -fvisibility=hidden") AC_SUBST(GLOBAL_CFLAGS) diff --git a/src/activation.c b/src/activation.c index ab1c204..ff71ef2 100644 --- a/src/activation.c +++ b/src/activation.c @@ -101,7 +101,6 @@ static void internal_libideviceactivation_deinit(void) } #ifdef WIN32 - typedef volatile struct { LONG lock; int state; @@ -121,7 +120,29 @@ static void thread_once(thread_once_t *once_control, void (*init_routine)(void)) } InterlockedExchange(&(once_control->lock), 0); } +#else +static pthread_once_t init_once = PTHREAD_ONCE_INIT; +static pthread_once_t deinit_once = PTHREAD_ONCE_INIT; +#define thread_once pthread_once +#endif + +#ifndef HAVE_ATTRIBUTE_CONSTRUCTOR + #if defined(__llvm__) || defined(__GNUC__) + #define HAVE_ATTRIBUTE_CONSTRUCTOR + #endif +#endif + +#ifdef HAVE_ATTRIBUTE_CONSTRUCTOR +static void __attribute__((constructor)) libideviceactivation_initialize(void) +{ + thread_once(&init_once, internal_libideviceactivation_init); +} +static void __attribute__((destructor)) libideviceactivation_deinitialize(void) +{ + thread_once(&deinit_once, internal_libideviceactivation_deinit); +} +#elif defined(WIN32) BOOL WINAPI DllMain(HINSTANCE hModule, DWORD dwReason, LPVOID lpReserved) { switch (dwReason) { @@ -136,25 +157,10 @@ BOOL WINAPI DllMain(HINSTANCE hModule, DWORD dwReason, LPVOID lpReserved) } return 1; } - #else - -static pthread_once_t init_once = PTHREAD_ONCE_INIT; -static pthread_once_t deinit_once = PTHREAD_ONCE_INIT; - -static void __attribute__((constructor)) libideviceactivation_initialize(void) -{ - pthread_once(&init_once, internal_libideviceactivation_init); -} - -static void __attribute__((destructor)) libideviceactivation_deinitialize(void) -{ - pthread_once(&deinit_once, internal_libideviceactivation_deinit); -} - +#warning No compiler support for constructor/destructor attributes, some features might not be available. #endif - static int debug_level = 0; IDEVICE_ACTIVATION_API void idevice_activation_set_debug_level(int level) { From d5749b1babcf6ae20badec305b550c46cffde8fa Mon Sep 17 00:00:00 2001 From: Nikias Bassen Date: Mon, 20 Sep 2021 01:30:35 +0200 Subject: [PATCH 05/25] [github-actions] Add build workflow --- .github/workflows/build.yml | 240 ++++++++++++++++++++++++++++++++++++ README.md | 2 + 2 files changed, 242 insertions(+) create mode 100644 .github/workflows/build.yml diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..2302f63 --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,240 @@ +name: build + +on: [push] + +jobs: + build-linux-ubuntu: + runs-on: ubuntu-latest + steps: + - name: install dependencies + run: | + sudo apt-get update + sudo apt-get install libcurl4-openssl-dev libxml2-dev + - name: prepare environment + run: | + echo "target_triplet=`gcc -dumpmachine`" >> $GITHUB_ENV + - name: fetch libplist + uses: dawidd6/action-download-artifact@v2 + with: + github_token: ${{secrets.GITHUB_TOKEN}} + workflow: build.yml + name: libplist-latest_${{env.target_triplet}} + repo: libimobiledevice/libplist + - name: fetch libusbmuxd + uses: dawidd6/action-download-artifact@v2 + with: + github_token: ${{secrets.GITHUB_TOKEN}} + workflow: build.yml + name: libusbmuxd-latest_${{env.target_triplet}} + repo: libimobiledevice/libusbmuxd + - name: fetch libimobiledevice-glue + uses: dawidd6/action-download-artifact@v2 + with: + github_token: ${{secrets.GITHUB_TOKEN}} + workflow: build.yml + name: libimobiledevice-glue-latest_${{env.target_triplet}} + repo: libimobiledevice/libimobiledevice-glue + - name: fetch libimobiledevice + uses: dawidd6/action-download-artifact@v2 + with: + github_token: ${{secrets.GITHUB_TOKEN}} + workflow: build.yml + name: libimobiledevice-latest_${{env.target_triplet}} + repo: libimobiledevice/libimobiledevice + - name: install external dependencies + run: | + mkdir extract + for I in *.tar; do + tar -C extract -xvf $I + done + rm -rf extract/lib + sudo cp -r extract/* / + sudo ldconfig + - uses: actions/checkout@v2 + with: + fetch-depth: 0 + - name: autogen + run: ./autogen.sh PKG_CONFIG_PATH=/usr/local/lib/pkgconfig + - name: make + run: make + - name: make install + run: sudo make install + - name: prepare artifact + run: | + mkdir -p dest + DESTDIR=`pwd`/dest make install + tar -C dest -cf libideviceactivation.tar usr + - name: publish artifact + uses: actions/upload-artifact@v2 + with: + name: libideviceactivation-latest_${{env.target_triplet}} + path: libideviceactivation.tar + build-macOS: + runs-on: macOS-latest + steps: + - name: install dependencies + run: | + if test -x "`which port`"; then + sudo port install libtool autoconf automake pkgconfig + else + brew install libtool autoconf automake pkgconfig + fi + shell: bash + - name: fetch libplist + uses: dawidd6/action-download-artifact@v2 + with: + github_token: ${{secrets.GITHUB_TOKEN}} + workflow: build.yml + name: libplist-latest_macOS + repo: libimobiledevice/libplist + - name: fetch libusbmuxd + uses: dawidd6/action-download-artifact@v2 + with: + github_token: ${{secrets.GITHUB_TOKEN}} + workflow: build.yml + name: libusbmuxd-latest_macOS + repo: libimobiledevice/libusbmuxd + - name: fetch libimobiledevice-glue + uses: dawidd6/action-download-artifact@v2 + with: + github_token: ${{secrets.GITHUB_TOKEN}} + workflow: build.yml + name: libimobiledevice-glue-latest_macOS + repo: libimobiledevice/libimobiledevice-glue + - name: fetch libimobiledevice + uses: dawidd6/action-download-artifact@v2 + with: + github_token: ${{secrets.GITHUB_TOKEN}} + workflow: build.yml + name: libimobiledevice-latest_macOS + repo: libimobiledevice/libimobiledevice + - name: install external dependencies + run: | + mkdir extract + for I in *.tar; do + tar -C extract -xvf $I + done + sudo cp -r extract/* / + - uses: actions/checkout@v2 + - name: install additional requirements + run: | + SDKDIR=`xcrun --sdk macosx --show-sdk-path 2>/dev/null` + echo "SDKDIR=$SDKDIR" >> $GITHUB_ENV + TESTARCHS="arm64 x86_64" + USEARCHS= + for ARCH in $TESTARCHS; do + if echo "int main(int argc, char **argv) { return 0; }" |clang -arch $ARCH -o /dev/null -isysroot $SDKDIR -x c - 2>/dev/null; then + USEARCHS="$USEARCHS -arch $ARCH" + fi + done + export CFLAGS="$USEARCHS -isysroot $SDKDIR" + echo "Using CFLAGS: $CFLAGS" + echo "BUILD_CFLAGS=$CFLAGS" >> $GITHUB_ENV + - name: autogen + run: | + export CFLAGS="${{env.BUILD_CFLAGS}} -Wno-nullability-completeness -Wno-expansion-to-defined" + echo "Using CFLAGS: $CFLAGS" + ./autogen.sh PKG_CONFIG_PATH=/usr/local/lib/pkgconfig \ + libcurl_CFLAGS="-I${{env.SDKDIR}}/usr/include" libcurl_LIBS="-lcurl" \ + libxml2_CFLAGS="-I${{env.SDKDIR}}/usr/include" libxml2_LIBS="-lxml2" \ + libimobiledevice_CFLAGS="-I/usr/local/include" libimobiledevice_LIBS="-L/usr/local/lib -limobiledevice-1.0" + - name: make + run: make + - name: make install + run: sudo make install + - name: prepare artifact + run: | + mkdir -p dest + DESTDIR=`pwd`/dest make install + tar -C dest -cf libideviceactivation.tar usr + - name: publish artifact + uses: actions/upload-artifact@v2 + with: + name: libideviceactivation-latest_macOS + path: libideviceactivation.tar + build-windows: + runs-on: windows-latest + defaults: + run: + shell: msys2 {0} + strategy: + fail-fast: false + matrix: + include: [ + { msystem: MINGW64, arch: x86_64 }, + { msystem: MINGW32, arch: i686 } + ] + steps: + - uses: msys2/setup-msys2@v2 + with: + msystem: ${{ matrix.msystem }} + release: false + update: false + install: >- + base-devel + git + mingw-w64-${{ matrix.arch }}-gcc + make + libtool + autoconf + automake-wrapper + - name: prepare environment + run: | + dest=`echo ${{ matrix.msystem }} |tr [:upper:] [:lower:]` + echo "dest=$dest" >> $GITHUB_ENV + echo "target_triplet=`gcc -dumpmachine`" >> $GITHUB_ENV + - name: fetch libplist + uses: dawidd6/action-download-artifact@v2 + with: + github_token: ${{secrets.GITHUB_TOKEN}} + workflow: build.yml + name: libplist-latest_${{ matrix.arch }}-${{ env.dest }} + repo: libimobiledevice/libplist + - name: fetch libusbmuxd + uses: dawidd6/action-download-artifact@v2 + with: + github_token: ${{secrets.GITHUB_TOKEN}} + workflow: build.yml + name: libusbmuxd-latest_${{ matrix.arch }}-${{ env.dest }} + repo: libimobiledevice/libusbmuxd + - name: fetch libimobiledevice-glue + uses: dawidd6/action-download-artifact@v2 + with: + github_token: ${{secrets.GITHUB_TOKEN}} + workflow: build.yml + name: libimobiledevice-glue-latest_${{ matrix.arch }}-${{ env.dest }} + repo: libimobiledevice/libimobiledevice-glue + - name: fetch libimobiledevice + uses: dawidd6/action-download-artifact@v2 + with: + github_token: ${{secrets.GITHUB_TOKEN}} + workflow: build.yml + name: libimobiledevice-latest_${{ matrix.arch }}-${{ env.dest }} + repo: libimobiledevice/libimobiledevice + - name: install external dependencies + run: | + mkdir extract + for I in *.tar; do + tar -C extract -xvf $I + done + cp -r extract/* / + - uses: actions/checkout@v2 + - name: install additional requirements + run: | + # + - name: autogen + run: ./autogen.sh CC=gcc CXX=g++ + - name: make + run: make + - name: make install + run: make install + - name: prepare artifact + run: | + mkdir -p dest + DESTDIR=`pwd`/dest make install + tar -C dest -cf libideviceactivation.tar ${{ env.dest }} + - name: publish artifact + uses: actions/upload-artifact@v2 + with: + name: libideviceactivation-latest_${{ matrix.arch }}-${{ env.dest }} + path: libideviceactivation.tar diff --git a/README.md b/README.md index 786f657..c463fcf 100644 --- a/README.md +++ b/README.md @@ -2,6 +2,8 @@ *A library to manage the activation process of Apple iOS devices.* +![](https://github.com/libimobiledevice/libideviceactivation/actions/workflows/build.yml/badge.svg) + ## Features This project provides an interface to activate and deactivate iOS devices by From 89bd4655d0739c33854e35ca903201f44eeee373 Mon Sep 17 00:00:00 2001 From: Jacek Roszkowski Date: Mon, 7 Dec 2020 01:58:02 +0100 Subject: [PATCH 06/25] Header field names are case-insensitive. https://tools.ietf.org/html/rfc7230#section-3.2 --- src/activation.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/activation.c b/src/activation.c index ff71ef2..9e7115a 100644 --- a/src/activation.c +++ b/src/activation.c @@ -602,7 +602,7 @@ static size_t idevice_activation_header_callback(void *data, size_t size, size_t } } if (value) { - if (strcmp(header, "Content-Type") == 0) { + if (strncasecmp(header, "Content-Type", 12) == 0) { if (strcmp(value, "text/xml") == 0) { response->content_type = IDEVICE_ACTIVATION_CONTENT_TYPE_PLIST; } else if (strcmp(value, "application/xml") == 0) { From 8b692d697f4be5cd90b8a7c00505938d3dae2dcd Mon Sep 17 00:00:00 2001 From: Jacek Roszkowski Date: Mon, 7 Dec 2020 01:59:19 +0100 Subject: [PATCH 07/25] The type, subtype, and parameter name tokens of Content-Type header are case-insensitive. https://tools.ietf.org/html/rfc7231#section-3.1.1.1 --- src/activation.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/activation.c b/src/activation.c index 9e7115a..d66f7ee 100644 --- a/src/activation.c +++ b/src/activation.c @@ -603,13 +603,13 @@ static size_t idevice_activation_header_callback(void *data, size_t size, size_t } if (value) { if (strncasecmp(header, "Content-Type", 12) == 0) { - if (strcmp(value, "text/xml") == 0) { + if (strncasecmp(value, "text/xml", 8) == 0) { response->content_type = IDEVICE_ACTIVATION_CONTENT_TYPE_PLIST; - } else if (strcmp(value, "application/xml") == 0) { + } else if (strncasecmp(value, "application/xml", 15) == 0) { response->content_type = IDEVICE_ACTIVATION_CONTENT_TYPE_PLIST; - } else if (strcmp(value, "application/x-buddyml") == 0) { + } else if (strncasecmp(value, "application/x-buddyml", 21) == 0) { response->content_type = IDEVICE_ACTIVATION_CONTENT_TYPE_BUDDYML; - } else if (strcmp(value, "text/html") == 0) { + } else if (strncasecmp(value, "text/html", 9) == 0) { response->content_type = IDEVICE_ACTIVATION_CONTENT_TYPE_HTML; } } From 8ba05c3dd6de818a13f5becc86eebf1e5111fa29 Mon Sep 17 00:00:00 2001 From: Jacek Roszkowski Date: Mon, 7 Dec 2020 02:00:40 +0100 Subject: [PATCH 08/25] Define strncasecmp function as _strnicmp on Windows. --- src/activation.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/activation.c b/src/activation.c index d66f7ee..96db41a 100644 --- a/src/activation.c +++ b/src/activation.c @@ -44,6 +44,7 @@ #ifdef WIN32 #include +#define strncasecmp _strnicmp #else #include #endif From e362173c72fc2a221a3e67cc4031fbaeb2e99613 Mon Sep 17 00:00:00 2001 From: Nikias Bassen Date: Mon, 4 Apr 2022 08:53:00 +0200 Subject: [PATCH 09/25] Updated README with pkg-config requirement --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index c463fcf..ca2946d 100644 --- a/README.md +++ b/README.md @@ -26,6 +26,7 @@ First install all required dependencies and build tools: ```shell sudo apt-get install \ build-essential \ + pkg-config \ checkinstall \ git \ autoconf \ @@ -117,4 +118,4 @@ iPadOS, tvOS, watchOS, and macOS are trademarks of Apple Inc. This project is an independent software library and has not been authorized, sponsored, or otherwise approved by Apple Inc. -README Updated on: 2020-06-13 +README Updated on: 2022-04-04 From bd061e8ce015d493fcec059c90a4aff752b63e10 Mon Sep 17 00:00:00 2001 From: Nikias Bassen Date: Tue, 5 Apr 2022 01:19:57 +0200 Subject: [PATCH 10/25] ideviceactivation: Bail out if drmHandshake request fails --- tools/ideviceactivation.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/tools/ideviceactivation.c b/tools/ideviceactivation.c index 1df73ff..33e6be7 100644 --- a/tools/ideviceactivation.c +++ b/tools/ideviceactivation.c @@ -336,7 +336,11 @@ int main(int argc, char *argv[]) plist_free(blob); /* send request to server and get response */ - idevice_activation_send_request(request, &response); + if (idevice_activation_send_request(request, &response) != IDEVICE_ACTIVATION_E_SUCCESS) { + fprintf(stderr, "Failed to get drmHandshake result from activation server.\n"); + result = EXIT_FAILURE; + goto cleanup; + } plist_t handshake_response = NULL; idevice_activation_response_get_fields(response, &handshake_response); idevice_activation_response_free(response); From f6635f14de1c79e7557867aae470a01b3f70e1c5 Mon Sep 17 00:00:00 2001 From: Nikias Bassen Date: Tue, 5 Apr 2022 01:24:18 +0200 Subject: [PATCH 11/25] [github-actions] Use windows-2019 instead of windows-latest for now --- .github/workflows/build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 2302f63..381fe0e 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -153,7 +153,7 @@ jobs: name: libideviceactivation-latest_macOS path: libideviceactivation.tar build-windows: - runs-on: windows-latest + runs-on: windows-2019 defaults: run: shell: msys2 {0} From 75505b75816691e1ff651fb55bfc6aaa7170ba3f Mon Sep 17 00:00:00 2001 From: Nikias Bassen Date: Tue, 5 Apr 2022 01:25:18 +0200 Subject: [PATCH 12/25] Update UserAgent string to use a more recent MobileActivation version --- src/activation.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/activation.c b/src/activation.c index 96db41a..4260c20 100644 --- a/src/activation.c +++ b/src/activation.c @@ -51,7 +51,7 @@ #include -#define IDEVICE_ACTIVATION_USER_AGENT_IOS "iOS Device Activator (MobileActivation-20 built on Jan 15 2012 at 19:07:28)" +#define IDEVICE_ACTIVATION_USER_AGENT_IOS "iOS Device Activator (MobileActivation-592.103.2)" #define IDEVICE_ACTIVATION_USER_AGENT_ITUNES "iTunes/11.1.4 (Macintosh; OS X 10.9.1) AppleWebKit/537.73.11" #define IDEVICE_ACTIVATION_DEFAULT_URL "https://albert.apple.com/deviceservices/deviceActivation" #define IDEVICE_ACTIVATION_DRM_HANDSHAKE_DEFAULT_URL "https://albert.apple.com/deviceservices/drmHandshake" From be6ffe8788cbb633bff0526f4e7a69625f0cdad6 Mon Sep 17 00:00:00 2001 From: Nikias Bassen Date: Wed, 24 Aug 2022 16:49:05 +0200 Subject: [PATCH 13/25] [github-actions] Add a scheduled build every 1st of the month so we always have an artifact --- .github/workflows/build.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 381fe0e..c5ecca4 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -1,6 +1,9 @@ name: build -on: [push] +on: + push: + schedule: + - cron: '0 0 1 * *' jobs: build-linux-ubuntu: From 1be78391da2ce39fbf3971226ef643042b75fffd Mon Sep 17 00:00:00 2001 From: Nikias Bassen Date: Fri, 21 Apr 2023 17:28:01 +0200 Subject: [PATCH 14/25] Use custom signing service URL for drmHandshake request too --- tools/ideviceactivation.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tools/ideviceactivation.c b/tools/ideviceactivation.c index 33e6be7..757c54e 100644 --- a/tools/ideviceactivation.c +++ b/tools/ideviceactivation.c @@ -335,6 +335,10 @@ int main(int argc, char *argv[]) idevice_activation_request_set_fields(request, blob); plist_free(blob); + if (signing_service_url) { + idevice_activation_request_set_url(request, signing_service_url); + } + /* send request to server and get response */ if (idevice_activation_send_request(request, &response) != IDEVICE_ACTIVATION_E_SUCCESS) { fprintf(stderr, "Failed to get drmHandshake result from activation server.\n"); From 067c439e0b18d6f1c8a37dde791f9d91191a922e Mon Sep 17 00:00:00 2001 From: Nikias Bassen Date: Sun, 30 Apr 2023 21:02:06 +0200 Subject: [PATCH 15/25] autoconf: Automatically derive version number from latest git tag --- Makefile.am | 6 +++++- configure.ac | 4 ++-- git-version-gen | 20 ++++++++++++++++++++ 3 files changed, 27 insertions(+), 3 deletions(-) create mode 100755 git-version-gen diff --git a/Makefile.am b/Makefile.am index 206c0d8..c4ed95a 100644 --- a/Makefile.am +++ b/Makefile.am @@ -3,9 +3,13 @@ ACLOCAL_AMFLAGS = -I m4 SUBDIRS = src include tools man EXTRA_DIST = \ - README.md + README.md \ + git-version-gen DISTCHECK_CONFIGURE_FLAGS = +dist-hook: + echo $(VERSION) > $(distdir)/.tarball-version + indent: indent -kr -ut -ts4 -l120 src/*.c src/*.h dev/*.c diff --git a/configure.ac b/configure.ac index f1ee6f0..2f93895 100644 --- a/configure.ac +++ b/configure.ac @@ -1,8 +1,8 @@ # -*- Autoconf -*- # Process this file with autoconf to produce a configure script. -AC_PREREQ(2.68) -AC_INIT([libideviceactivation], [1.1.2], [https://github.com/libimobiledevice/libideviceactivation/issues],, [https://libimobiledevice.org]) +AC_PREREQ([2.68]) +AC_INIT([libideviceactivation], [m4_esyscmd(./git-version-gen $RELEASE_VERSION)], [https://github.com/libimobiledevice/libideviceactivation/issues], [], [https://libimobiledevice.org]) AM_INIT_AUTOMAKE([dist-bzip2 no-dist-gzip check-news]) m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES]) AC_CONFIG_SRCDIR([src/]) diff --git a/git-version-gen b/git-version-gen new file mode 100755 index 0000000..d868952 --- /dev/null +++ b/git-version-gen @@ -0,0 +1,20 @@ +#!/bin/sh +SRCDIR=`dirname $0` +if test -n "$1"; then + VER=$1 +else + if test -r "${SRCDIR}/.git" && test -x "`which git`" ; then + git update-index -q --refresh + if ! VER=`git describe --tags --dirty 2>/dev/null`; then + COMMIT=`git rev-parse --short HEAD` + DIRTY=`git diff --quiet HEAD || echo "-dirty"` + VER=`sed -n '1,/RE/s/Version \(.*\)/\1/p' ${SRCDIR}/NEWS`-git-${COMMIT}${DIRTY} + fi + else + if test -f "${SRCDIR}/.tarball-version"; then + VER=`cat "${SRCDIR}/.tarball-version"` + fi + fi +fi +VER=`printf %s "$VER" | head -n1` +printf %s "$VER" From 6925d58ef7994168fb9585aa6f48421149982329 Mon Sep 17 00:00:00 2001 From: Nikias Bassen Date: Tue, 16 Apr 2024 16:43:52 +0200 Subject: [PATCH 16/25] automake: Prevent `dist` or `distcheck` when uncommitted changes are present --- Makefile.am | 1 + 1 file changed, 1 insertion(+) diff --git a/Makefile.am b/Makefile.am index c4ed95a..2c15230 100644 --- a/Makefile.am +++ b/Makefile.am @@ -9,6 +9,7 @@ EXTRA_DIST = \ DISTCHECK_CONFIGURE_FLAGS = dist-hook: + @if ! git diff --quiet; then echo "Uncommitted changes present; not releasing"; exit 1; fi echo $(VERSION) > $(distdir)/.tarball-version indent: From ecc10ef8048c6591b936c5ca1b0971157087e6b2 Mon Sep 17 00:00:00 2001 From: Nikias Bassen Date: Wed, 29 May 2024 18:00:03 +0200 Subject: [PATCH 17/25] Fix typo in README. Thanks to @Kreyren for pointing this out. --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index ca2946d..f11d071 100644 --- a/README.md +++ b/README.md @@ -54,9 +54,9 @@ sudo make install ## Usage -To query the activation status of a device use: +To query the activation state of a device use: ```shell -ideviceactivation status +ideviceactivation state ``` To activate a device use: @@ -118,4 +118,4 @@ iPadOS, tvOS, watchOS, and macOS are trademarks of Apple Inc. This project is an independent software library and has not been authorized, sponsored, or otherwise approved by Apple Inc. -README Updated on: 2022-04-04 +README Updated on: 2024-05-29 From 4e97dac5292890c8102df2e981fe416b1889c0e0 Mon Sep 17 00:00:00 2001 From: Nikias Bassen Date: Tue, 22 Oct 2024 19:40:05 +0200 Subject: [PATCH 18/25] Updated README --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index f11d071..ee5e905 100644 --- a/README.md +++ b/README.md @@ -93,8 +93,8 @@ We are still working on the guidelines so bear with us! ## Links * Homepage: https://libimobiledevice.org/ -* Repository: https://git.libimobiledevice.org/libideviceactivation.git -* Repository (Mirror): https://github.com/libimobiledevice/libideviceactivation.git +* Repository: https://github.com/libimobiledevice/libideviceactivation.git +* Repository (Mirror): https://git.libimobiledevice.org/libideviceactivation.git * Issue Tracker: https://github.com/libimobiledevice/libideviceactivation/issues * Mailing List: https://lists.libimobiledevice.org/mailman/listinfo/libimobiledevice-devel * Twitter: https://twitter.com/libimobiledev @@ -118,4 +118,4 @@ iPadOS, tvOS, watchOS, and macOS are trademarks of Apple Inc. This project is an independent software library and has not been authorized, sponsored, or otherwise approved by Apple Inc. -README Updated on: 2024-05-29 +README Updated on: 2024-10-22 From 5f437eece203feb75202db21951d4bcebd87acd4 Mon Sep 17 00:00:00 2001 From: Nikias Bassen Date: Tue, 22 Oct 2024 19:45:04 +0200 Subject: [PATCH 19/25] [github-actions] Updated build workflow --- .github/workflows/build.yml | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index c5ecca4..5005e7c 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -17,28 +17,28 @@ jobs: run: | echo "target_triplet=`gcc -dumpmachine`" >> $GITHUB_ENV - name: fetch libplist - uses: dawidd6/action-download-artifact@v2 + uses: dawidd6/action-download-artifact@v3 with: github_token: ${{secrets.GITHUB_TOKEN}} workflow: build.yml name: libplist-latest_${{env.target_triplet}} repo: libimobiledevice/libplist - name: fetch libusbmuxd - uses: dawidd6/action-download-artifact@v2 + uses: dawidd6/action-download-artifact@v3 with: github_token: ${{secrets.GITHUB_TOKEN}} workflow: build.yml name: libusbmuxd-latest_${{env.target_triplet}} repo: libimobiledevice/libusbmuxd - name: fetch libimobiledevice-glue - uses: dawidd6/action-download-artifact@v2 + uses: dawidd6/action-download-artifact@v3 with: github_token: ${{secrets.GITHUB_TOKEN}} workflow: build.yml name: libimobiledevice-glue-latest_${{env.target_triplet}} repo: libimobiledevice/libimobiledevice-glue - name: fetch libimobiledevice - uses: dawidd6/action-download-artifact@v2 + uses: dawidd6/action-download-artifact@v3 with: github_token: ${{secrets.GITHUB_TOKEN}} workflow: build.yml @@ -53,7 +53,7 @@ jobs: rm -rf extract/lib sudo cp -r extract/* / sudo ldconfig - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 with: fetch-depth: 0 - name: autogen @@ -68,7 +68,7 @@ jobs: DESTDIR=`pwd`/dest make install tar -C dest -cf libideviceactivation.tar usr - name: publish artifact - uses: actions/upload-artifact@v2 + uses: actions/upload-artifact@v4 with: name: libideviceactivation-latest_${{env.target_triplet}} path: libideviceactivation.tar @@ -84,28 +84,28 @@ jobs: fi shell: bash - name: fetch libplist - uses: dawidd6/action-download-artifact@v2 + uses: dawidd6/action-download-artifact@v3 with: github_token: ${{secrets.GITHUB_TOKEN}} workflow: build.yml name: libplist-latest_macOS repo: libimobiledevice/libplist - name: fetch libusbmuxd - uses: dawidd6/action-download-artifact@v2 + uses: dawidd6/action-download-artifact@v3 with: github_token: ${{secrets.GITHUB_TOKEN}} workflow: build.yml name: libusbmuxd-latest_macOS repo: libimobiledevice/libusbmuxd - name: fetch libimobiledevice-glue - uses: dawidd6/action-download-artifact@v2 + uses: dawidd6/action-download-artifact@v3 with: github_token: ${{secrets.GITHUB_TOKEN}} workflow: build.yml name: libimobiledevice-glue-latest_macOS repo: libimobiledevice/libimobiledevice-glue - name: fetch libimobiledevice - uses: dawidd6/action-download-artifact@v2 + uses: dawidd6/action-download-artifact@v3 with: github_token: ${{secrets.GITHUB_TOKEN}} workflow: build.yml @@ -118,7 +118,7 @@ jobs: tar -C extract -xvf $I done sudo cp -r extract/* / - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 - name: install additional requirements run: | SDKDIR=`xcrun --sdk macosx --show-sdk-path 2>/dev/null` @@ -151,7 +151,7 @@ jobs: DESTDIR=`pwd`/dest make install tar -C dest -cf libideviceactivation.tar usr - name: publish artifact - uses: actions/upload-artifact@v2 + uses: actions/upload-artifact@v4 with: name: libideviceactivation-latest_macOS path: libideviceactivation.tar @@ -187,28 +187,28 @@ jobs: echo "dest=$dest" >> $GITHUB_ENV echo "target_triplet=`gcc -dumpmachine`" >> $GITHUB_ENV - name: fetch libplist - uses: dawidd6/action-download-artifact@v2 + uses: dawidd6/action-download-artifact@v3 with: github_token: ${{secrets.GITHUB_TOKEN}} workflow: build.yml name: libplist-latest_${{ matrix.arch }}-${{ env.dest }} repo: libimobiledevice/libplist - name: fetch libusbmuxd - uses: dawidd6/action-download-artifact@v2 + uses: dawidd6/action-download-artifact@v3 with: github_token: ${{secrets.GITHUB_TOKEN}} workflow: build.yml name: libusbmuxd-latest_${{ matrix.arch }}-${{ env.dest }} repo: libimobiledevice/libusbmuxd - name: fetch libimobiledevice-glue - uses: dawidd6/action-download-artifact@v2 + uses: dawidd6/action-download-artifact@v3 with: github_token: ${{secrets.GITHUB_TOKEN}} workflow: build.yml name: libimobiledevice-glue-latest_${{ matrix.arch }}-${{ env.dest }} repo: libimobiledevice/libimobiledevice-glue - name: fetch libimobiledevice - uses: dawidd6/action-download-artifact@v2 + uses: dawidd6/action-download-artifact@v3 with: github_token: ${{secrets.GITHUB_TOKEN}} workflow: build.yml @@ -221,7 +221,7 @@ jobs: tar -C extract -xvf $I done cp -r extract/* / - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 - name: install additional requirements run: | # @@ -237,7 +237,7 @@ jobs: DESTDIR=`pwd`/dest make install tar -C dest -cf libideviceactivation.tar ${{ env.dest }} - name: publish artifact - uses: actions/upload-artifact@v2 + uses: actions/upload-artifact@v4 with: name: libideviceactivation-latest_${{ matrix.arch }}-${{ env.dest }} path: libideviceactivation.tar From c28aef0902f4b94492905bd642393de15855323a Mon Sep 17 00:00:00 2001 From: Nikias Bassen Date: Tue, 29 Oct 2024 15:49:01 +0100 Subject: [PATCH 20/25] configure: Fine-tuning for MinGW/msys build --- configure.ac | 1 + 1 file changed, 1 insertion(+) diff --git a/configure.ac b/configure.ac index 2f93895..a7ae3e7 100644 --- a/configure.ac +++ b/configure.ac @@ -61,6 +61,7 @@ case ${host_os} in *mingw32*|*cygwin*) AC_MSG_RESULT([${host_os}]) win32=true + deplibs_check_method='pass_all' ;; darwin*|*android*) AC_MSG_RESULT([${host_os}]) From 51c313dda2887d4e5c9290a3eee397511bbaaf85 Mon Sep 17 00:00:00 2001 From: Nikias Bassen Date: Mon, 2 Dec 2024 06:18:15 +0100 Subject: [PATCH 21/25] Switch to better initializer strategy --- configure.ac | 20 ---------- src/activation.c | 96 +++++++++++++++--------------------------------- 2 files changed, 30 insertions(+), 86 deletions(-) diff --git a/configure.ac b/configure.ac index a7ae3e7..c84c6de 100644 --- a/configure.ac +++ b/configure.ac @@ -68,30 +68,10 @@ case ${host_os} in ;; *) AC_MSG_RESULT([${host_os}]) - AX_PTHREAD([], [AC_MSG_ERROR([pthread is required to build ${PACKAGE}])]) - AC_CHECK_LIB(pthread, [pthread_once], [], [AC_MSG_ERROR([pthread with pthread_once required to build ${PACKAGE}])]) ;; esac AM_CONDITIONAL(WIN32, test x$win32 = xtrue) -# Check if the C compiler supports __attribute__((constructor)) -AC_CACHE_CHECK([wether the C compiler supports constructor/destructor attributes], - ac_cv_attribute_constructor, [ - ac_cv_attribute_constructor=no - AC_COMPILE_IFELSE([AC_LANG_PROGRAM( - [[ - static void __attribute__((constructor)) test_constructor(void) { - } - static void __attribute__((destructor)) test_destructor(void) { - } - ]], [])], - [ac_cv_attribute_constructor=yes] - )] -) -if test "$ac_cv_attribute_constructor" = "yes"; then - AC_DEFINE(HAVE_ATTRIBUTE_CONSTRUCTOR, 1, [Define if the C compiler supports constructor/destructor attributes]) -fi - AS_COMPILER_FLAGS(GLOBAL_CFLAGS, "-Wall -Wextra -Wmissing-declarations -Wredundant-decls -Wshadow -Wpointer-arith -Wwrite-strings -Wswitch-default -Wno-unused-parameter -fsigned-char -fvisibility=hidden") AC_SUBST(GLOBAL_CFLAGS) diff --git a/src/activation.c b/src/activation.c index 4260c20..c60d669 100644 --- a/src/activation.c +++ b/src/activation.c @@ -45,12 +45,37 @@ #ifdef WIN32 #include #define strncasecmp _strnicmp -#else -#include #endif #include +// Reference: https://stackoverflow.com/a/2390626/1806760 +// Initializer/finalizer sample for MSVC and GCC/Clang. +// 2010-2016 Joe Lowe. Released into the public domain. + +#ifdef __cplusplus + #define INITIALIZER(f) \ + static void f(void); \ + struct f##_t_ { f##_t_(void) { f(); } }; static f##_t_ f##_; \ + static void f(void) +#elif defined(_MSC_VER) + #pragma section(".CRT$XCU",read) + #define INITIALIZER2_(f,p) \ + static void f(void); \ + __declspec(allocate(".CRT$XCU")) void (*f##_)(void) = f; \ + __pragma(comment(linker,"/include:" p #f "_")) \ + static void f(void) + #ifdef _WIN64 + #define INITIALIZER(f) INITIALIZER2_(f,"") + #else + #define INITIALIZER(f) INITIALIZER2_(f,"_") + #endif +#else + #define INITIALIZER(f) \ + static void f(void) __attribute__((__constructor__)); \ + static void f(void) +#endif + #define IDEVICE_ACTIVATION_USER_AGENT_IOS "iOS Device Activator (MobileActivation-592.103.2)" #define IDEVICE_ACTIVATION_USER_AGENT_ITUNES "iTunes/11.1.4 (Macintosh; OS X 10.9.1) AppleWebKit/537.73.11" #define IDEVICE_ACTIVATION_DEFAULT_URL "https://albert.apple.com/deviceservices/deviceActivation" @@ -90,77 +115,16 @@ struct idevice_activation_response_private { int has_errors; }; - -static void internal_libideviceactivation_init(void) -{ - curl_global_init(CURL_GLOBAL_ALL); -} - static void internal_libideviceactivation_deinit(void) { curl_global_cleanup(); } -#ifdef WIN32 -typedef volatile struct { - LONG lock; - int state; -} thread_once_t; - -static thread_once_t init_once = {0, 0}; -static thread_once_t deinit_once = {0, 0}; - -static void thread_once(thread_once_t *once_control, void (*init_routine)(void)) +INITIALIZER(internal_libideviceactivation_init) { - while (InterlockedExchange(&(once_control->lock), 1) != 0) { - Sleep(1); - } - if (!once_control->state) { - once_control->state = 1; - init_routine(); - } - InterlockedExchange(&(once_control->lock), 0); -} -#else -static pthread_once_t init_once = PTHREAD_ONCE_INIT; -static pthread_once_t deinit_once = PTHREAD_ONCE_INIT; -#define thread_once pthread_once -#endif - -#ifndef HAVE_ATTRIBUTE_CONSTRUCTOR - #if defined(__llvm__) || defined(__GNUC__) - #define HAVE_ATTRIBUTE_CONSTRUCTOR - #endif -#endif - -#ifdef HAVE_ATTRIBUTE_CONSTRUCTOR -static void __attribute__((constructor)) libideviceactivation_initialize(void) -{ - thread_once(&init_once, internal_libideviceactivation_init); -} - -static void __attribute__((destructor)) libideviceactivation_deinitialize(void) -{ - thread_once(&deinit_once, internal_libideviceactivation_deinit); -} -#elif defined(WIN32) -BOOL WINAPI DllMain(HINSTANCE hModule, DWORD dwReason, LPVOID lpReserved) -{ - switch (dwReason) { - case DLL_PROCESS_ATTACH: - thread_once(&init_once, internal_libideviceactivation_init); - break; - case DLL_PROCESS_DETACH: - thread_once(&deinit_once, internal_libideviceactivation_deinit); - break; - default: - break; - } - return 1; + curl_global_init(CURL_GLOBAL_ALL); + atexit(internal_libideviceactivation_deinit); } -#else -#warning No compiler support for constructor/destructor attributes, some features might not be available. -#endif static int debug_level = 0; From 5235448cead2b6e6c9e891f9a95e89373669402f Mon Sep 17 00:00:00 2001 From: Nikias Bassen Date: Mon, 2 Dec 2024 06:25:35 +0100 Subject: [PATCH 22/25] Change WIN32 to _WIN32 to check if running on Windows --- src/activation.c | 4 ++-- tools/ideviceactivation.c | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/activation.c b/src/activation.c index c60d669..8cf6c0a 100644 --- a/src/activation.c +++ b/src/activation.c @@ -32,7 +32,7 @@ #include #include -#ifdef WIN32 +#ifdef _WIN32 #define IDEVICE_ACTIVATION_API __declspec( dllexport ) #else #ifdef HAVE_FVISIBILITY @@ -42,7 +42,7 @@ #endif #endif -#ifdef WIN32 +#ifdef _WIN32 #include #define strncasecmp _strnicmp #endif diff --git a/tools/ideviceactivation.c b/tools/ideviceactivation.c index 757c54e..ef16ca0 100644 --- a/tools/ideviceactivation.c +++ b/tools/ideviceactivation.c @@ -30,7 +30,7 @@ #include #include #include -#ifndef WIN32 +#ifndef _WIN32 #include #endif @@ -40,7 +40,7 @@ #include #include -#ifdef WIN32 +#ifdef _WIN32 #include #include #else @@ -74,7 +74,7 @@ static void print_usage(int argc, char **argv) printf("Bug Reports: <" PACKAGE_BUGREPORT ">\n"); } -#ifdef WIN32 +#ifdef _WIN32 #define BS_CC '\b' #define my_getch getch #else @@ -146,7 +146,7 @@ int main(int argc, char *argv[]) } op_t; op_t op = OP_NONE; -#ifndef WIN32 +#ifndef _WIN32 signal(SIGPIPE, SIG_IGN); #endif /* parse cmdline args */ From 82c858ed25fe0629dec3a6b8ec1b217efd7f65ff Mon Sep 17 00:00:00 2001 From: Nikias Bassen Date: Mon, 2 Dec 2024 06:36:29 +0100 Subject: [PATCH 23/25] Move IDEVICE_ACTIVATION_API to public header --- configure.ac | 10 ++--- include/libideviceactivation.h | 70 +++++++++++++++++-------------- src/activation.c | 76 +++++++++++++++++----------------- 3 files changed, 84 insertions(+), 72 deletions(-) diff --git a/configure.ac b/configure.ac index c84c6de..d4e1d79 100644 --- a/configure.ac +++ b/configure.ac @@ -73,12 +73,12 @@ esac AM_CONDITIONAL(WIN32, test x$win32 = xtrue) AS_COMPILER_FLAGS(GLOBAL_CFLAGS, "-Wall -Wextra -Wmissing-declarations -Wredundant-decls -Wshadow -Wpointer-arith -Wwrite-strings -Wswitch-default -Wno-unused-parameter -fsigned-char -fvisibility=hidden") -AC_SUBST(GLOBAL_CFLAGS) -case "$GLOBAL_CFLAGS" in - *-fvisibility=hidden*) - AC_DEFINE([HAVE_FVISIBILITY], [1], [Define if compiled with -fvisibility=hidden]) -esac +if test "x$enable_static" = "xyes" -a "x$enable_shared" = "xno"; then + GLOBAL_CFLAGS+=" -DIDEVICE_ACTIVATION_STATIC" +fi + +AC_SUBST(GLOBAL_CFLAGS) m4_ifdef([AM_SILENT_RULES],[AM_SILENT_RULES([yes])]) diff --git a/include/libideviceactivation.h b/include/libideviceactivation.h index 9b78c20..dbee85b 100644 --- a/include/libideviceactivation.h +++ b/include/libideviceactivation.h @@ -31,6 +31,16 @@ extern "C" { #include #include +#ifndef IDEVICE_ACTIVATION_API + #ifdef IDEVICE_ACTIVATION_STATIC + #define IDEVICE_ACTIVATION_API + #elif defined(_WIN32) + #define IDEVICE_ACTIVATION_API __declspec(dllimport) + #else + #define IDEVICE_ACTIVATION_API + #endif +#endif + typedef enum { IDEVICE_ACTIVATION_E_SUCCESS = 0, IDEVICE_ACTIVATION_E_INCOMPLETE_INFO = -1, @@ -55,44 +65,44 @@ typedef idevice_activation_response* idevice_activation_response_t; /* Interface */ -void idevice_activation_set_debug_level(int level); +IDEVICE_ACTIVATION_API void idevice_activation_set_debug_level(int level); -idevice_activation_error_t idevice_activation_request_new(idevice_activation_client_type_t activation_type, idevice_activation_request_t* request); -idevice_activation_error_t idevice_activation_request_new_from_lockdownd(idevice_activation_client_type_t activation_type, lockdownd_client_t lockdown, idevice_activation_request_t* request); -idevice_activation_error_t idevice_activation_drm_handshake_request_new(idevice_activation_client_type_t client_type, idevice_activation_request_t* request); -void idevice_activation_request_free(idevice_activation_request_t request); +IDEVICE_ACTIVATION_API idevice_activation_error_t idevice_activation_request_new(idevice_activation_client_type_t activation_type, idevice_activation_request_t* request); +IDEVICE_ACTIVATION_API idevice_activation_error_t idevice_activation_request_new_from_lockdownd(idevice_activation_client_type_t activation_type, lockdownd_client_t lockdown, idevice_activation_request_t* request); +IDEVICE_ACTIVATION_API idevice_activation_error_t idevice_activation_drm_handshake_request_new(idevice_activation_client_type_t client_type, idevice_activation_request_t* request); +IDEVICE_ACTIVATION_API void idevice_activation_request_free(idevice_activation_request_t request); -void idevice_activation_request_get_fields(idevice_activation_request_t request, plist_t* fields); -void idevice_activation_request_set_fields(idevice_activation_request_t request, plist_t fields); -void idevice_activation_request_set_fields_from_response(idevice_activation_request_t request, const idevice_activation_response_t response); -void idevice_activation_request_set_field(idevice_activation_request_t request, const char* key, const char* value); -void idevice_activation_request_get_field(idevice_activation_request_t request, const char* key, char** value); +IDEVICE_ACTIVATION_API void idevice_activation_request_get_fields(idevice_activation_request_t request, plist_t* fields); +IDEVICE_ACTIVATION_API void idevice_activation_request_set_fields(idevice_activation_request_t request, plist_t fields); +IDEVICE_ACTIVATION_API void idevice_activation_request_set_fields_from_response(idevice_activation_request_t request, const idevice_activation_response_t response); +IDEVICE_ACTIVATION_API void idevice_activation_request_set_field(idevice_activation_request_t request, const char* key, const char* value); +IDEVICE_ACTIVATION_API void idevice_activation_request_get_field(idevice_activation_request_t request, const char* key, char** value); -void idevice_activation_request_get_url(idevice_activation_request_t request, const char** url); -void idevice_activation_request_set_url(idevice_activation_request_t request, const char* url); +IDEVICE_ACTIVATION_API void idevice_activation_request_get_url(idevice_activation_request_t request, const char** url); +IDEVICE_ACTIVATION_API void idevice_activation_request_set_url(idevice_activation_request_t request, const char* url); -idevice_activation_error_t idevice_activation_response_new(idevice_activation_response_t* response); -idevice_activation_error_t idevice_activation_response_new_from_html(const char* content, idevice_activation_response_t* response); -idevice_activation_error_t idevice_activation_response_to_buffer(idevice_activation_response_t response, char** buffer, size_t* size); -void idevice_activation_response_free(idevice_activation_response_t response); +IDEVICE_ACTIVATION_API idevice_activation_error_t idevice_activation_response_new(idevice_activation_response_t* response); +IDEVICE_ACTIVATION_API idevice_activation_error_t idevice_activation_response_new_from_html(const char* content, idevice_activation_response_t* response); +IDEVICE_ACTIVATION_API idevice_activation_error_t idevice_activation_response_to_buffer(idevice_activation_response_t response, char** buffer, size_t* size); +IDEVICE_ACTIVATION_API void idevice_activation_response_free(idevice_activation_response_t response); -void idevice_activation_response_get_field(idevice_activation_response_t response, const char* key, char** value); -void idevice_activation_response_get_fields(idevice_activation_response_t response, plist_t* fields); -void idevice_activation_response_get_label(idevice_activation_response_t response, const char* key, char** value); -void idevice_activation_response_get_placeholder(idevice_activation_response_t response, const char* key, char **value); +IDEVICE_ACTIVATION_API void idevice_activation_response_get_field(idevice_activation_response_t response, const char* key, char** value); +IDEVICE_ACTIVATION_API void idevice_activation_response_get_fields(idevice_activation_response_t response, plist_t* fields); +IDEVICE_ACTIVATION_API void idevice_activation_response_get_label(idevice_activation_response_t response, const char* key, char** value); +IDEVICE_ACTIVATION_API void idevice_activation_response_get_placeholder(idevice_activation_response_t response, const char* key, char **value); -void idevice_activation_response_get_title(idevice_activation_response_t response, const char** title); -void idevice_activation_response_get_description(idevice_activation_response_t response, const char** description); -void idevice_activation_response_get_activation_record(idevice_activation_response_t response, plist_t* activation_record); -void idevice_activation_response_get_headers(idevice_activation_response_t response, plist_t* headers); +IDEVICE_ACTIVATION_API void idevice_activation_response_get_title(idevice_activation_response_t response, const char** title); +IDEVICE_ACTIVATION_API void idevice_activation_response_get_description(idevice_activation_response_t response, const char** description); +IDEVICE_ACTIVATION_API void idevice_activation_response_get_activation_record(idevice_activation_response_t response, plist_t* activation_record); +IDEVICE_ACTIVATION_API void idevice_activation_response_get_headers(idevice_activation_response_t response, plist_t* headers); -int idevice_activation_response_is_activation_acknowledged(idevice_activation_response_t response); -int idevice_activation_response_is_authentication_required(idevice_activation_response_t response); -int idevice_activation_response_field_requires_input(idevice_activation_response_t response, const char* key); -int idevice_activation_response_field_secure_input(idevice_activation_response_t response, const char* key); -int idevice_activation_response_has_errors(idevice_activation_response_t response); +IDEVICE_ACTIVATION_API int idevice_activation_response_is_activation_acknowledged(idevice_activation_response_t response); +IDEVICE_ACTIVATION_API int idevice_activation_response_is_authentication_required(idevice_activation_response_t response); +IDEVICE_ACTIVATION_API int idevice_activation_response_field_requires_input(idevice_activation_response_t response, const char* key); +IDEVICE_ACTIVATION_API int idevice_activation_response_field_secure_input(idevice_activation_response_t response, const char* key); +IDEVICE_ACTIVATION_API int idevice_activation_response_has_errors(idevice_activation_response_t response); -idevice_activation_error_t idevice_activation_send_request(idevice_activation_request_t request, idevice_activation_response_t* response); +IDEVICE_ACTIVATION_API idevice_activation_error_t idevice_activation_send_request(idevice_activation_request_t request, idevice_activation_response_t* response); #ifdef __cplusplus } diff --git a/src/activation.c b/src/activation.c index 8cf6c0a..2b329ce 100644 --- a/src/activation.c +++ b/src/activation.c @@ -32,14 +32,16 @@ #include #include -#ifdef _WIN32 -#define IDEVICE_ACTIVATION_API __declspec( dllexport ) -#else -#ifdef HAVE_FVISIBILITY -#define IDEVICE_ACTIVATION_API __attribute__((visibility("default"))) +#ifdef IDEVICE_ACTIVATION_STATIC + #define IDEVICE_ACTIVATION_API +#elif defined(_WIN32) + #define IDEVICE_ACTIVATION_API __declspec( dllexport ) #else -#define IDEVICE_ACTIVATION_API -#endif + #if __GNUC__ >= 4 + #define IDEVICE_ACTIVATION_API __attribute__((visibility("default"))) + #else + #define IDEVICE_ACTIVATION_API + #endif #endif #ifdef _WIN32 @@ -128,7 +130,7 @@ INITIALIZER(internal_libideviceactivation_init) static int debug_level = 0; -IDEVICE_ACTIVATION_API void idevice_activation_set_debug_level(int level) { +void idevice_activation_set_debug_level(int level) { debug_level = level; } @@ -685,7 +687,7 @@ static int idevice_activation_curl_debug_callback(CURL *handle, curl_infotype ty return 0; } -IDEVICE_ACTIVATION_API idevice_activation_error_t idevice_activation_request_new(idevice_activation_client_type_t client_type, idevice_activation_request_t* request) +idevice_activation_error_t idevice_activation_request_new(idevice_activation_client_type_t client_type, idevice_activation_request_t* request) { if (!request) return IDEVICE_ACTIVATION_E_INTERNAL_ERROR; @@ -705,7 +707,7 @@ IDEVICE_ACTIVATION_API idevice_activation_error_t idevice_activation_request_new return IDEVICE_ACTIVATION_E_SUCCESS; } -IDEVICE_ACTIVATION_API idevice_activation_error_t idevice_activation_request_new_from_lockdownd(idevice_activation_client_type_t client_type, lockdownd_client_t lockdown, idevice_activation_request** request) +idevice_activation_error_t idevice_activation_request_new_from_lockdownd(idevice_activation_client_type_t client_type, lockdownd_client_t lockdown, idevice_activation_request** request) { if (!lockdown || !request) { return IDEVICE_ACTIVATION_E_INTERNAL_ERROR; @@ -828,7 +830,7 @@ IDEVICE_ACTIVATION_API idevice_activation_error_t idevice_activation_request_new return IDEVICE_ACTIVATION_E_SUCCESS; } -IDEVICE_ACTIVATION_API idevice_activation_error_t idevice_activation_drm_handshake_request_new(idevice_activation_client_type_t client_type, idevice_activation_request_t* request) +idevice_activation_error_t idevice_activation_drm_handshake_request_new(idevice_activation_client_type_t client_type, idevice_activation_request_t* request) { if (!request) return IDEVICE_ACTIVATION_E_INTERNAL_ERROR; @@ -848,7 +850,7 @@ IDEVICE_ACTIVATION_API idevice_activation_error_t idevice_activation_drm_handsha return IDEVICE_ACTIVATION_E_SUCCESS; } -IDEVICE_ACTIVATION_API void idevice_activation_request_free(idevice_activation_request_t request) +void idevice_activation_request_free(idevice_activation_request_t request) { if (!request) return; @@ -857,7 +859,7 @@ IDEVICE_ACTIVATION_API void idevice_activation_request_free(idevice_activation_r free(request); } -IDEVICE_ACTIVATION_API void idevice_activation_request_get_fields(idevice_activation_request_t request, plist_t* fields) +void idevice_activation_request_get_fields(idevice_activation_request_t request, plist_t* fields) { if (!request || !fields) return; @@ -865,7 +867,7 @@ IDEVICE_ACTIVATION_API void idevice_activation_request_get_fields(idevice_activa *fields = plist_copy(request->fields); } -IDEVICE_ACTIVATION_API void idevice_activation_request_set_fields(idevice_activation_request_t request, plist_t fields) +void idevice_activation_request_set_fields(idevice_activation_request_t request, plist_t fields) { if (!request || !fields) return; @@ -887,7 +889,7 @@ IDEVICE_ACTIVATION_API void idevice_activation_request_set_fields(idevice_activa plist_dict_merge(&request->fields, fields); } -IDEVICE_ACTIVATION_API void idevice_activation_request_set_fields_from_response(idevice_activation_request_t request, const idevice_activation_response_t response) +void idevice_activation_request_set_fields_from_response(idevice_activation_request_t request, const idevice_activation_response_t response) { if (!request || !response) return; @@ -900,7 +902,7 @@ IDEVICE_ACTIVATION_API void idevice_activation_request_set_fields_from_response( } } -IDEVICE_ACTIVATION_API void idevice_activation_request_set_field(idevice_activation_request_t request, const char* key, const char* value) +void idevice_activation_request_set_field(idevice_activation_request_t request, const char* key, const char* value) { if (!request || !key || !value) return; @@ -908,7 +910,7 @@ IDEVICE_ACTIVATION_API void idevice_activation_request_set_field(idevice_activat plist_dict_set_item(request->fields, key, plist_new_string(value)); } -IDEVICE_ACTIVATION_API void idevice_activation_request_get_field(idevice_activation_request_t request, const char* key, char** value) +void idevice_activation_request_get_field(idevice_activation_request_t request, const char* key, char** value) { if (!request || !key || !value) return; @@ -928,7 +930,7 @@ IDEVICE_ACTIVATION_API void idevice_activation_request_get_field(idevice_activat *value = tmp_value; } -IDEVICE_ACTIVATION_API void idevice_activation_request_get_url(idevice_activation_request_t request, const char** url) +void idevice_activation_request_get_url(idevice_activation_request_t request, const char** url) { if (!request || !url) return; @@ -936,7 +938,7 @@ IDEVICE_ACTIVATION_API void idevice_activation_request_get_url(idevice_activatio *url = request->url; } -IDEVICE_ACTIVATION_API void idevice_activation_request_set_url(idevice_activation_request_t request, const char* url) +void idevice_activation_request_set_url(idevice_activation_request_t request, const char* url) { if (!request || !url) return; @@ -945,7 +947,7 @@ IDEVICE_ACTIVATION_API void idevice_activation_request_set_url(idevice_activatio request->url = strdup(url); } -IDEVICE_ACTIVATION_API idevice_activation_error_t idevice_activation_response_new(idevice_activation_response_t* response) +idevice_activation_error_t idevice_activation_response_new(idevice_activation_response_t* response) { if (!response) return IDEVICE_ACTIVATION_E_INTERNAL_ERROR; @@ -976,7 +978,7 @@ IDEVICE_ACTIVATION_API idevice_activation_error_t idevice_activation_response_ne return IDEVICE_ACTIVATION_E_SUCCESS; } -IDEVICE_ACTIVATION_API idevice_activation_error_t idevice_activation_response_new_from_html(const char* content, idevice_activation_response_t* response) +idevice_activation_error_t idevice_activation_response_new_from_html(const char* content, idevice_activation_response_t* response) { if (!content || !response) return IDEVICE_ACTIVATION_E_INTERNAL_ERROR; @@ -1014,7 +1016,7 @@ IDEVICE_ACTIVATION_API idevice_activation_error_t idevice_activation_response_ne return result; } -IDEVICE_ACTIVATION_API idevice_activation_error_t idevice_activation_response_to_buffer(idevice_activation_response_t response, char** buffer, size_t* size) +idevice_activation_error_t idevice_activation_response_to_buffer(idevice_activation_response_t response, char** buffer, size_t* size) { if (!response || !buffer || !size) return IDEVICE_ACTIVATION_E_INTERNAL_ERROR; @@ -1032,7 +1034,7 @@ IDEVICE_ACTIVATION_API idevice_activation_error_t idevice_activation_response_to return IDEVICE_ACTIVATION_E_SUCCESS; } -IDEVICE_ACTIVATION_API void idevice_activation_response_free(idevice_activation_response_t response) +void idevice_activation_response_free(idevice_activation_response_t response) { if (!response) return; @@ -1050,7 +1052,7 @@ IDEVICE_ACTIVATION_API void idevice_activation_response_free(idevice_activation_ free(response); } -IDEVICE_ACTIVATION_API void idevice_activation_response_get_field(idevice_activation_response_t response, const char* key, char** value) +void idevice_activation_response_get_field(idevice_activation_response_t response, const char* key, char** value) { if (!response || !key || !value) return; @@ -1063,14 +1065,14 @@ IDEVICE_ACTIVATION_API void idevice_activation_response_get_field(idevice_activa } } -IDEVICE_ACTIVATION_API void idevice_activation_response_get_fields(idevice_activation_response_t response, plist_t* fields) +void idevice_activation_response_get_fields(idevice_activation_response_t response, plist_t* fields) { if (response && response->fields && fields) { *fields = plist_copy(response->fields); } } -IDEVICE_ACTIVATION_API void idevice_activation_response_get_label(idevice_activation_response_t response, const char* key, char** value) +void idevice_activation_response_get_label(idevice_activation_response_t response, const char* key, char** value) { if (!response || !key || !value) return; @@ -1082,7 +1084,7 @@ IDEVICE_ACTIVATION_API void idevice_activation_response_get_label(idevice_activa } } -IDEVICE_ACTIVATION_API void idevice_activation_response_get_placeholder(idevice_activation_response_t response, const char* key, char** value) +void idevice_activation_response_get_placeholder(idevice_activation_response_t response, const char* key, char** value) { if (!response || !key || !value) return; @@ -1094,7 +1096,7 @@ IDEVICE_ACTIVATION_API void idevice_activation_response_get_placeholder(idevice_ } } -IDEVICE_ACTIVATION_API void idevice_activation_response_get_title(idevice_activation_response_t response, const char** title) +void idevice_activation_response_get_title(idevice_activation_response_t response, const char** title) { if (!response || !title) return; @@ -1102,7 +1104,7 @@ IDEVICE_ACTIVATION_API void idevice_activation_response_get_title(idevice_activa *title = response->title; } -IDEVICE_ACTIVATION_API void idevice_activation_response_get_description(idevice_activation_response_t response, const char** description) +void idevice_activation_response_get_description(idevice_activation_response_t response, const char** description) { if (!response || !description) return; @@ -1110,7 +1112,7 @@ IDEVICE_ACTIVATION_API void idevice_activation_response_get_description(idevice_ *description = response->description; } -IDEVICE_ACTIVATION_API void idevice_activation_response_get_activation_record(idevice_activation_response_t response, plist_t* activation_record) +void idevice_activation_response_get_activation_record(idevice_activation_response_t response, plist_t* activation_record) { if (!response || !activation_record) return; @@ -1122,7 +1124,7 @@ IDEVICE_ACTIVATION_API void idevice_activation_response_get_activation_record(id } } -IDEVICE_ACTIVATION_API void idevice_activation_response_get_headers(idevice_activation_response_t response, plist_t* headers) +void idevice_activation_response_get_headers(idevice_activation_response_t response, plist_t* headers) { if (!response || !headers) return; @@ -1130,7 +1132,7 @@ IDEVICE_ACTIVATION_API void idevice_activation_response_get_headers(idevice_acti *headers = plist_copy(response->headers); } -IDEVICE_ACTIVATION_API int idevice_activation_response_is_activation_acknowledged(idevice_activation_response_t response) +int idevice_activation_response_is_activation_acknowledged(idevice_activation_response_t response) { if (!response) return 0; @@ -1138,7 +1140,7 @@ IDEVICE_ACTIVATION_API int idevice_activation_response_is_activation_acknowledge return response->is_activation_ack; } -IDEVICE_ACTIVATION_API int idevice_activation_response_is_authentication_required(idevice_activation_response_t response) +int idevice_activation_response_is_authentication_required(idevice_activation_response_t response) { if (!response) return 0; @@ -1146,7 +1148,7 @@ IDEVICE_ACTIVATION_API int idevice_activation_response_is_authentication_require return response->is_auth_required; } -IDEVICE_ACTIVATION_API int idevice_activation_response_field_requires_input(idevice_activation_response_t response, const char* key) +int idevice_activation_response_field_requires_input(idevice_activation_response_t response, const char* key) { if (!response || !key) return 0; @@ -1154,7 +1156,7 @@ IDEVICE_ACTIVATION_API int idevice_activation_response_field_requires_input(idev return (plist_dict_get_item(response->fields_require_input, key) ? 1 : 0); } -IDEVICE_ACTIVATION_API int idevice_activation_response_field_secure_input(idevice_activation_response_t response, const char* key) +int idevice_activation_response_field_secure_input(idevice_activation_response_t response, const char* key) { if (!response || !key) return 0; @@ -1162,7 +1164,7 @@ IDEVICE_ACTIVATION_API int idevice_activation_response_field_secure_input(idevic return (plist_dict_get_item(response->fields_secure_input, key) ? 1 : 0); } -IDEVICE_ACTIVATION_API int idevice_activation_response_has_errors(idevice_activation_response_t response) +int idevice_activation_response_has_errors(idevice_activation_response_t response) { if (!response) return 0; @@ -1170,7 +1172,7 @@ IDEVICE_ACTIVATION_API int idevice_activation_response_has_errors(idevice_activa return response->has_errors; } -IDEVICE_ACTIVATION_API idevice_activation_error_t idevice_activation_send_request(idevice_activation_request_t request, idevice_activation_response_t* response) +idevice_activation_error_t idevice_activation_send_request(idevice_activation_request_t request, idevice_activation_response_t* response) { idevice_activation_error_t result = IDEVICE_ACTIVATION_E_SUCCESS; From 863224106001246112b5609ce696e5efc94a69c7 Mon Sep 17 00:00:00 2001 From: Nikias Bassen Date: Mon, 2 Dec 2024 06:37:59 +0100 Subject: [PATCH 24/25] [github-actions] Bump dawidd6/action-download-artifact from 3 to 6 --- .github/workflows/build.yml | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 5005e7c..8b868a4 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -17,28 +17,28 @@ jobs: run: | echo "target_triplet=`gcc -dumpmachine`" >> $GITHUB_ENV - name: fetch libplist - uses: dawidd6/action-download-artifact@v3 + uses: dawidd6/action-download-artifact@v6 with: github_token: ${{secrets.GITHUB_TOKEN}} workflow: build.yml name: libplist-latest_${{env.target_triplet}} repo: libimobiledevice/libplist - name: fetch libusbmuxd - uses: dawidd6/action-download-artifact@v3 + uses: dawidd6/action-download-artifact@v6 with: github_token: ${{secrets.GITHUB_TOKEN}} workflow: build.yml name: libusbmuxd-latest_${{env.target_triplet}} repo: libimobiledevice/libusbmuxd - name: fetch libimobiledevice-glue - uses: dawidd6/action-download-artifact@v3 + uses: dawidd6/action-download-artifact@v6 with: github_token: ${{secrets.GITHUB_TOKEN}} workflow: build.yml name: libimobiledevice-glue-latest_${{env.target_triplet}} repo: libimobiledevice/libimobiledevice-glue - name: fetch libimobiledevice - uses: dawidd6/action-download-artifact@v3 + uses: dawidd6/action-download-artifact@v6 with: github_token: ${{secrets.GITHUB_TOKEN}} workflow: build.yml @@ -84,28 +84,28 @@ jobs: fi shell: bash - name: fetch libplist - uses: dawidd6/action-download-artifact@v3 + uses: dawidd6/action-download-artifact@v6 with: github_token: ${{secrets.GITHUB_TOKEN}} workflow: build.yml name: libplist-latest_macOS repo: libimobiledevice/libplist - name: fetch libusbmuxd - uses: dawidd6/action-download-artifact@v3 + uses: dawidd6/action-download-artifact@v6 with: github_token: ${{secrets.GITHUB_TOKEN}} workflow: build.yml name: libusbmuxd-latest_macOS repo: libimobiledevice/libusbmuxd - name: fetch libimobiledevice-glue - uses: dawidd6/action-download-artifact@v3 + uses: dawidd6/action-download-artifact@v6 with: github_token: ${{secrets.GITHUB_TOKEN}} workflow: build.yml name: libimobiledevice-glue-latest_macOS repo: libimobiledevice/libimobiledevice-glue - name: fetch libimobiledevice - uses: dawidd6/action-download-artifact@v3 + uses: dawidd6/action-download-artifact@v6 with: github_token: ${{secrets.GITHUB_TOKEN}} workflow: build.yml @@ -187,28 +187,28 @@ jobs: echo "dest=$dest" >> $GITHUB_ENV echo "target_triplet=`gcc -dumpmachine`" >> $GITHUB_ENV - name: fetch libplist - uses: dawidd6/action-download-artifact@v3 + uses: dawidd6/action-download-artifact@v6 with: github_token: ${{secrets.GITHUB_TOKEN}} workflow: build.yml name: libplist-latest_${{ matrix.arch }}-${{ env.dest }} repo: libimobiledevice/libplist - name: fetch libusbmuxd - uses: dawidd6/action-download-artifact@v3 + uses: dawidd6/action-download-artifact@v6 with: github_token: ${{secrets.GITHUB_TOKEN}} workflow: build.yml name: libusbmuxd-latest_${{ matrix.arch }}-${{ env.dest }} repo: libimobiledevice/libusbmuxd - name: fetch libimobiledevice-glue - uses: dawidd6/action-download-artifact@v3 + uses: dawidd6/action-download-artifact@v6 with: github_token: ${{secrets.GITHUB_TOKEN}} workflow: build.yml name: libimobiledevice-glue-latest_${{ matrix.arch }}-${{ env.dest }} repo: libimobiledevice/libimobiledevice-glue - name: fetch libimobiledevice - uses: dawidd6/action-download-artifact@v3 + uses: dawidd6/action-download-artifact@v6 with: github_token: ${{secrets.GITHUB_TOKEN}} workflow: build.yml From 46212d366b93a7c681540fd931161197350e93ca Mon Sep 17 00:00:00 2001 From: Nikias Bassen Date: Mon, 2 Dec 2024 06:49:28 +0100 Subject: [PATCH 25/25] [github-actions] Add build on pull_request --- .github/workflows/build.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 8b868a4..70847e0 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -2,6 +2,7 @@ name: build on: push: + pull_request: schedule: - cron: '0 0 1 * *'