Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fork Sync #1

Open
wants to merge 36 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
7f24e9a
Fix preflight for older devices
mexmer Sep 21, 2022
12e24e4
preflight: Assume old iOS version if retrieval of ProductVersion fails
nikias Oct 4, 2022
bccae83
autoconf: Automatically derive version number from latest git tag
nikias Oct 7, 2022
6d0183d
Support switching to different "modes" using vendor specific control …
Dec 22, 2022
9bc87cd
style
Dec 22, 2022
939595a
Factor out device_complete_initialization and call it from get_mode_cb.
Dec 22, 2022
0fdad22
- Add device to collection in usb_device_add
Dec 23, 2022
1eb5a01
Best effort for old devices (potentially not supporting mode switch) …
Dec 23, 2022
a2cbb59
Simplify finding valid configuration, interface and endpoints and ref…
Dec 23, 2022
24a0265
correct log
Dec 23, 2022
84801d8
Guess current mode based on available configurations and interfaces.
Dec 24, 2022
e55e6e7
udev: Fix freezing on OpenRC caused by a raced execution of usbmuxd
BalkanMadman Feb 22, 2023
dca3373
Fix use-after-free on get_mode_cb
Mar 1, 2023
d0cda19
Set default value for ENV_DEV_MODE
Mar 1, 2023
049877e
Update to use latest libplist code
nikias Apr 21, 2023
01c94c7
conf: Fix false plist read/write errors caused by using new libplist API
nikias May 5, 2023
61b99ab
udev: Make sure iBridge (T1) doesn't end up in an unconfigured state
nikias Jul 20, 2023
56f013b
autoconf: Fix processing of --with-preflight and --with-systemd options
nikias Sep 18, 2023
2707534
systemd: use runstatedir
williamspatrick Oct 6, 2022
b9d5e3c
autoconf: Add workaround for runstatedir for old autoconf versions
nikias Sep 18, 2023
91aa7be
[github-actions] Update build config to use checkout@v3 and upload-ar…
nikias Sep 18, 2023
c7a0dd9
usb: Set default mode to 3 to include CDC NCM, and fix a log message
nikias Sep 19, 2023
b5dfb25
usb: Make sure buffer for vendor specific request is 0-initialized
nikias Sep 29, 2023
360619c
client: Add missing include for FreeBSD
nikias Oct 11, 2023
243dedf
device: Fix crash caused by wrong variable when logging an error
gothi3 Jun 13, 2024
bc0b91c
usb: Rename usb_device struct member 'dev' to more appropriate 'handle'
nikias Jun 13, 2024
f8be60c
usb: Revert default mode back to 1
httpstorm Apr 22, 2024
a2cafe2
configure.ac: Do not use '+=' to set CFLAGS to be POSIX-compliant
BalkanMadman May 4, 2024
81a4165
configure.ac: Don't explicitly add -g to compiler flags
nikias Sep 14, 2024
a2dceac
usb: correctly display 10 Gbps USB 3.x
Forst Jul 31, 2024
df80b73
usb: add support for modes 4 and 5
Forst Jul 31, 2024
10d9eae
conf: fix false plist write error in config_set_device_record
nikias Sep 14, 2024
e9a0dce
Use more reliabe macros to print --version output
nikias Sep 14, 2024
0b1b233
Update libplist requirement to 2.6.0 and use PLIST_DICT helper for cl…
nikias Sep 15, 2024
7c0c0eb
[github-actions] Updated build workflow
nikias Dec 2, 2024
0cdf92d
Updated README
nikias Dec 2, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 11 additions & 7 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
name: build

on: [push]
on:
push:
pull_request:
schedule:
- cron: '0 0 1 * *'

jobs:
build-linux-ubuntu:
Expand All @@ -14,28 +18,28 @@ jobs:
run: |
echo "target_triplet=`gcc -dumpmachine`" >> $GITHUB_ENV
- name: fetch libplist
uses: dawidd6/action-download-artifact@v2
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@v2
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@v2
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@v2
uses: dawidd6/action-download-artifact@v6
with:
github_token: ${{secrets.GITHUB_TOKEN}}
workflow: build.yml
Expand All @@ -49,7 +53,7 @@ jobs:
done
sudo cp -r extract/* /
sudo ldconfig
- uses: actions/checkout@v2
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: autogen
Expand All @@ -67,7 +71,7 @@ jobs:
DESTDIR=`pwd`/dest make install
tar -C dest -cf usbmuxd.tar usr lib
- name: publish artifact
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v4
with:
name: usbmuxd-latest_${{env.target_triplet}}
path: usbmuxd.tar
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -135,8 +135,8 @@ We are still working on the guidelines so bear with us!
## Links

* Homepage: https://libimobiledevice.org/
* Repository: https://git.libimobiledevice.org/usbmuxd.git
* Repository (Mirror): https://github.com/libimobiledevice/usbmuxd.git
* Repository: https://github.com/libimobiledevice/usbmuxd.git
* Repository (Mirror): https://git.libimobiledevice.org/usbmuxd.git
* Issue Tracker: https://github.com/libimobiledevice/usbmuxd/issues
* Mailing List: https://lists.libimobiledevice.org/mailman/listinfo/libimobiledevice-devel
* Twitter: https://twitter.com/libimobiledev
Expand All @@ -156,4 +156,4 @@ iPadOS, tvOS, watchOS, and macOS are trademarks of Apple Inc.
usbmuxd is an independent software application and has not been
authorized, sponsored, or otherwise approved by Apple Inc.

README Updated on: 2022-04-04
README Updated on: 2024-12-02
24 changes: 17 additions & 7 deletions configure.ac
Original file line number Diff line number Diff line change
@@ -1,29 +1,34 @@
# -*- Autoconf -*-
# Process this file with autoconf to produce a configure script.

AC_PREREQ(2.68)
AC_INIT([usbmuxd], [1.1.2], [https://github.com/libimobiledevice/usbmuxd/issues],, [https://libimobiledevice.org])
AC_PREREQ([2.68])
AC_INIT([usbmuxd], [m4_esyscmd(./git-version-gen $RELEASE_VERSION)], [https://github.com/libimobiledevice/usbmuxd/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/])
AC_CONFIG_HEADERS([config.h])
AC_CONFIG_MACRO_DIR([m4])

# Check if we have a version defined
if test -z $PACKAGE_VERSION; then
AC_MSG_ERROR([PACKAGE_VERSION is not defined. Make sure to configure a source tree checked out from git or that .tarball-version is present.])
fi

# Checks for programs.
AC_PROG_CC
AM_PROG_CC_C_O
LT_INIT

# Checks for libraries.
PKG_CHECK_MODULES(libusb, libusb-1.0 >= 1.0.9)
PKG_CHECK_MODULES(libplist, libplist-2.0 >= 2.2.0)
PKG_CHECK_MODULES(libplist, libplist-2.0 >= 2.6.0)
PKG_CHECK_MODULES(libimobiledevice, libimobiledevice-1.0 >= 1.3.0, have_limd=yes, have_limd=no)
PKG_CHECK_MODULES(limd_glue, libimobiledevice-glue-1.0 >= 1.0.0)

AC_ARG_WITH([preflight],
[AS_HELP_STRING([--without-preflight],
[do not build with preflight worker support @<:@default=yes@:>@])],
[with_preflight=no],
[with_preflight=$withval],
[with_preflight=yes])

if test "x$have_limd" = "xyes"; then
Expand All @@ -35,7 +40,7 @@ if test "x$have_limd" = "xyes"; then
AC_SUBST(libimobiledevice_CFLAGS)
AC_SUBST(libimobiledevice_LIBS)
CACHED_CFLAGS="$CFLAGS"
CFLAGS+=" $libimobiledevice_CFLAGS"
CFLAGS="$CFLAGS $libimobiledevice_CFLAGS"
AC_CACHE_CHECK(for enum idevice_connection_type, ac_cv_enum_idevice_connection_type,
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([
#include <libimobiledevice/libimobiledevice.h>
Expand Down Expand Up @@ -70,7 +75,7 @@ fi
AC_ARG_WITH([systemd],
[AS_HELP_STRING([--without-systemd],
[do not build with systemd support @<:@default=yes@:>@])],
[],
[with_systemd=$withval],
[with_systemd=yes])

AC_ARG_WITH([systemdsystemunitdir],
Expand Down Expand Up @@ -148,11 +153,16 @@ AM_CONDITIONAL(WIN32, test x$win32 = xtrue)
AC_SUBST([UDEV_SUB])
AC_SUBST([SYSTEMD_SUB])

AS_COMPILER_FLAGS(GLOBAL_CFLAGS, "-g -Wall -Wextra -Wmissing-declarations -Wredundant-decls -Wshadow -Wpointer-arith -Wwrite-strings -Wswitch-default -Wno-unused-parameter")
AS_COMPILER_FLAGS(GLOBAL_CFLAGS, "-Wall -Wextra -Wmissing-declarations -Wredundant-decls -Wshadow -Wpointer-arith -Wwrite-strings -Wswitch-default -Wno-unused-parameter")
AC_SUBST(GLOBAL_CFLAGS)

m4_ifdef([AM_SILENT_RULES],[AM_SILENT_RULES([yes])])

# workaround for older autoconf versions
if test "x$runstatedir" == "x"; then
runstatedir=$localstatedir/run
fi

AC_CONFIG_FILES([
Makefile
src/Makefile
Expand Down
19 changes: 19 additions & 0 deletions git-version-gen
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/bin/sh
SRCDIR=`dirname $0`
if test -n "$1"; then
VER=$1
else
if test -d "${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
printf %s "$VER"
31 changes: 6 additions & 25 deletions src/client.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
#include <unistd.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <netinet/tcp.h>
#include <sys/un.h>
#include <arpa/inet.h>
Expand Down Expand Up @@ -451,10 +452,7 @@ static int send_listener_list(struct mux_client *client, uint32_t tag)
plist_dict_set_item(l, "Blacklisted", plist_new_bool(0));
n = NULL;
if (lc->info) {
n = plist_dict_get_item(lc->info, "BundleID");
}
if (n) {
plist_dict_set_item(l, "BundleID", plist_copy(n));
plist_dict_copy_item(l, lc->info, "BundleID", NULL);
}
plist_dict_set_item(l, "ConnType", plist_new_uint(0));

Expand Down Expand Up @@ -631,28 +629,11 @@ static char* plist_dict_get_string_val(plist_t dict, const char* key)

static void update_client_info(struct mux_client *client, plist_t dict)
{
plist_t node = NULL;
plist_t info = plist_new_dict();

node = plist_dict_get_item(dict, "BundleID");
if (node && (plist_get_node_type(node) == PLIST_STRING)) {
plist_dict_set_item(info, "BundleID", plist_copy(node));
}

node = plist_dict_get_item(dict, "ClientVersionString");
if (node && (plist_get_node_type(node) == PLIST_STRING)) {
plist_dict_set_item(info, "ClientVersionString", plist_copy(node));
}

node = plist_dict_get_item(dict, "ProgName");
if (node && (plist_get_node_type(node) == PLIST_STRING)) {
plist_dict_set_item(info, "ProgName", plist_copy(node));
}

node = plist_dict_get_item(dict, "kLibUSBMuxVersion");
if (node && (plist_get_node_type(node) == PLIST_UINT)) {
plist_dict_set_item(info, "kLibUSBMuxVersion", plist_copy(node));
}
plist_dict_copy_item(info, dict, "BundleID", NULL);
plist_dict_copy_item(info, dict, "ClientVersionString", NULL);
plist_dict_copy_item(info, dict, "ProgName", NULL);
plist_dict_copy_item(info, dict, "kLibUSBMuxVersion", NULL);
plist_free(client->info);
client->info = info;
}
Expand Down
11 changes: 6 additions & 5 deletions src/conf.c
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
#endif

#include <libimobiledevice-glue/utils.h>
#include <plist/plist.h>

#include "conf.h"
#include "utils.h"
Expand Down Expand Up @@ -232,7 +233,7 @@ static int internal_set_value(const char *config_file, const char *key, plist_t
/* read file into plist */
plist_t config = NULL;

plist_read_from_filename(&config, config_file);
plist_read_from_file(config_file, &config, NULL);
if (!config) {
config = plist_new_dict();
plist_dict_set_item(config, key, value);
Expand All @@ -256,7 +257,7 @@ static int internal_set_value(const char *config_file, const char *key, plist_t
usbmuxd_log(LL_DEBUG, "Setting key %s in config file %s", key, config_file);
}

int res = plist_write_to_filename(config, config_file, PLIST_FORMAT_XML);
int res = (plist_write_to_file(config, config_file, PLIST_FORMAT_XML, 0) == PLIST_ERR_SUCCESS);

plist_free(config);

Expand All @@ -276,7 +277,7 @@ static int config_set_value(const char *key, plist_t value)

int result = internal_set_value(config_file, key, value);
if (!result) {
usbmuxd_log(LL_ERROR, "ERROR: Failed to write to '%s': %s", config_file, strerror(errno));
usbmuxd_log(LL_ERROR, "ERROR: Failed to write to '%s'", config_file);
}

free(config_file);
Expand All @@ -290,7 +291,7 @@ static int internal_get_value(const char* config_file, const char *key, plist_t

/* now parse file to get the SystemBUID */
plist_t config = NULL;
if (plist_read_from_filename(&config, config_file)) {
if (plist_read_from_file(config_file, &config, NULL) == PLIST_ERR_SUCCESS) {
usbmuxd_log(LL_DEBUG, "Reading key %s from config file %s", key, config_file);
plist_t n = plist_dict_get_item(config, key);
if (n) {
Expand Down Expand Up @@ -430,7 +431,7 @@ int config_set_device_record(const char *udid, char* record_data, uint64_t recor
remove(device_record_file);

/* store file */
if (!plist_write_to_filename(plist, device_record_file, PLIST_FORMAT_XML)) {
if (plist_write_to_file(plist, device_record_file, PLIST_FORMAT_XML, 0) != PLIST_ERR_SUCCESS) {
usbmuxd_log(LL_DEBUG, "Could not open '%s' for writing: %s", device_record_file, strerror(errno));
res = -ENOENT;
}
Expand Down
2 changes: 1 addition & 1 deletion src/device.c
Original file line number Diff line number Diff line change
Expand Up @@ -661,7 +661,7 @@ static void device_tcp_input(struct mux_device *dev, struct tcphdr *th, unsigned
if(!(th->th_flags & TH_RST)) {
usbmuxd_log(LL_INFO, "No connection for device %d incoming packet %d->%d", dev->id, dport, sport);
if(send_anon_rst(dev, sport, dport, ntohl(th->th_seq)) < 0)
usbmuxd_log(LL_ERROR, "Error sending TCP RST to device %d (%d->%d)", conn->dev->id, sport, dport);
usbmuxd_log(LL_ERROR, "Error sending TCP RST to device %d (%d->%d)", dev->id, sport, dport);
}
return;
}
Expand Down
2 changes: 1 addition & 1 deletion src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -584,7 +584,7 @@ static void parse_opts(int argc, char **argv)
++verbose;
break;
case 'V':
printf("%s\n", PACKAGE_STRING);
printf("%s %s\n", PACKAGE_NAME, PACKAGE_VERSION);
exit(0);
case 'U':
drop_privileges = 1;
Expand Down
45 changes: 23 additions & 22 deletions src/preflight.c
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ static void* preflight_worker_handle_device_add(void* userdata)

plist_t value = NULL;
char* version_str = NULL;
char* platform_str = NULL;
char* deviceclass_str = NULL;

usbmuxd_log(LL_INFO, "%s: Starting preflight on device %s...", __func__, _dev->udid);

Expand Down Expand Up @@ -214,42 +214,43 @@ static void* preflight_worker_handle_device_add(void* userdata)

lerr = lockdownd_get_value(lockdown, NULL, "ProductVersion", &value);
if (lerr != LOCKDOWN_E_SUCCESS) {
usbmuxd_log(LL_ERROR, "%s: ERROR: Could not get ProductVersion from device %s, lockdown error %d", __func__, _dev->udid, lerr);
goto leave;
}

if (value && plist_get_node_type(value) == PLIST_STRING) {
plist_get_string_val(value, &version_str);
}
plist_free(value);
usbmuxd_log(LL_WARNING, "%s: Could not get ProductVersion from device %s, lockdown error %d", __func__, _dev->udid, lerr);
/* assume old iOS version */
version_str = strdup("1.0");
} else {
if (value && plist_get_node_type(value) == PLIST_STRING) {
plist_get_string_val(value, &version_str);
}
plist_free(value);

if (!version_str) {
usbmuxd_log(LL_ERROR, "%s: Could not get ProductVersion string from device %s handle %d", __func__, _dev->udid, (int)(long)_dev->conn_data);
goto leave;
if (!version_str) {
usbmuxd_log(LL_ERROR, "%s: Could not get ProductVersion string from device %s handle %d", __func__, _dev->udid, (int)(long)_dev->conn_data);
goto leave;
}
}

lerr = lockdownd_get_value(lockdown, NULL, "ProductName", &value);
lerr = lockdownd_get_value(lockdown, NULL, "DeviceClass", &value);
if (lerr != LOCKDOWN_E_SUCCESS) {
usbmuxd_log(LL_ERROR, "%s: ERROR: Could not get ProductName from device %s, lockdown error %d", __func__, _dev->udid, lerr);
usbmuxd_log(LL_ERROR, "%s: ERROR: Could not get DeviceClass from device %s, lockdown error %d", __func__, _dev->udid, lerr);
goto leave;
}
if (value && plist_get_node_type(value) == PLIST_STRING) {
plist_get_string_val(value, &platform_str);
plist_get_string_val(value, &deviceclass_str);
}
plist_free(value);

if (!platform_str) {
usbmuxd_log(LL_ERROR, "%s: Could not get ProductName string from device %s handle %d", __func__, _dev->udid, (int)(long)_dev->conn_data);
if (!deviceclass_str) {
usbmuxd_log(LL_ERROR, "%s: Could not get DeviceClass string from device %s handle %d", __func__, _dev->udid, (int)(long)_dev->conn_data);
goto leave;
}

int version_major = strtol(version_str, NULL, 10);
if ((!strcmp(platform_str, "iPhone OS") && version_major >= 7)
|| ((!strcmp(platform_str, "watchOS") || !strcmp(platform_str, "Watch OS")) && version_major >= 2)
|| (!strcmp(platform_str, "Apple TVOS") && version_major >= 9)
if (((!strcmp(deviceclass_str, "iPhone") || !strcmp(deviceclass_str, "iPad")) && version_major >= 7)
|| (!strcmp(deviceclass_str, "Watch") && version_major >= 2)
|| (!strcmp(deviceclass_str, "AppleTV") && version_major >= 9)
) {
/* iOS 7.0 / watchOS 2.0 / tvOS 9.0 and later */
usbmuxd_log(LL_INFO, "%s: Found %s %s device %s", __func__, platform_str, version_str, _dev->udid);
usbmuxd_log(LL_INFO, "%s: Found %s %s device %s", __func__, deviceclass_str, version_str, _dev->udid);

lockdownd_set_untrusted_host_buid(lockdown);

Expand Down Expand Up @@ -356,7 +357,7 @@ static void* preflight_worker_handle_device_add(void* userdata)
}

leave:
free(platform_str);
free(deviceclass_str);
free(version_str);
if (lockdown)
lockdownd_client_free(lockdown);
Expand Down
Loading