| Age | Commit message (Collapse) | Author | Files | Lines |
|
When usbmuxd isn't running, the device_monitor thread waits for the
socket to appear by select()ing on an inotify fd. In a long-lived
process with many open descriptors (e.g. KDE's kwin_wayland, which
loads libusbmuxd via Solid's iMobileDevice backend), that fd can be
>= FD_SETSIZE (1024). FD_SET() on it is undefined behaviour, and with
_FORTIFY_SOURCE glibc aborts the whole process:
*** bit out of range 0 - FD_SETSIZE on fd_set ***: terminated
#8 __fortify_fail (libc)
#9 usbmuxd_listen_inotify src/libusbmuxd.c:944
#10 device_monitor src/libusbmuxd.c:1130
Here this took down the Wayland compositor (and with it the whole
desktop session) after ~4 weeks of uptime, when typing in the Overview
search triggered a KRunner plugin that initialised Solid.
poll() has no descriptor limit. This replaces the pselect() call with
poll() on the inotify fd and the wake pipe; the pselect() fallback shim
and the <sys/select.h> include become unused and are removed.
libimobiledevice-glue's socket code already uses poll() on non-Windows
platforms for the same reason.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
|
usbmuxd reports the network address of a device as a BSD sockaddr
([sa_len][sa_family]...), even when it runs on a different OS than the
client (e.g. macOS usbmuxd reached over TCP from Linux). libusbmuxd passed
it through unchanged, so consumers casting conn_data to struct sockaddr
(like libimobiledevice) got the wrong family on Linux and Windows.
Convert the address when parsing it, so conn_data holds a native sockaddr
for the platform the library runs on. On macOS nothing changes, on the
other BSDs only the family value is adjusted.
iproxy and inetcat now use conn_data directly and require this version of
the library. The format is documented in usbmuxd.h.
|
|
|
|
Credit to @PwnToday
|
|
If usbmuxd_events_unsubscribe() is called before the device monitor
thread has connected to usbmuxd, listenfd is still -1, so there is
nothing to shut down. Where thread_cancel() is not available (Windows,
or builds without pthread_cancel) unsubscribe then relies on clearing
`running`, but device_monitor() sets `running = 1` and `cancelling = 0`
itself when it starts and overwrites that. The thread goes on to
connect, sends Listen and blocks in receive_packet() forever, so
thread_join() never returns.
This is easy to hit with ideviceinstaller on Windows with a network
device and redirected stdout: the command completes before
idevice_wait_for_command_to_complete() subscribes, so subscribe and
unsubscribe happen back to back and the tool hangs on exit.
Fix this by:
- initializing `running`/`cancelling` in usbmuxd_events_subscribe()
under listener_mutex before the monitor thread is created;
- publishing listenfd in device_monitor() under the same mutex, and only
if no cancellation was requested in the meantime (otherwise close the
new socket and exit);
- setting `cancelling`/`running` and shutting down listenfd under the
mutex in usbmuxd_events_unsubscribe(), and only if the socket exists.
|
|
The primary purpose of this change is to support NetBSD.
No functional changes intended.
|
|
|
|
|
|
|
|
|
|
|
|
Since socket_send already returns -errno, this function should pass it as is
|
|
inotify_init creates a file descriptor which by default is not makes
with CLOEXEC. If the application using libusbmuxd spawns applications
this then leaks through.
|
|
|
|
|
|
|
|
|
|
|
|
Thanks to @timgates42 for pointing this out.
|
|
|
|
|
|
|
|
[clang-tidy] Found with google-readability-casting
Signed-off-by: Rosen Penev rosenp@gmail.com
|
|
[clang-tidy] Found with readability-else-after-return
Signed-off-by: Rosen Penev <rosenp@gmail.com>
|
|
[clang-tidy] Found with readability-redundant-control-flow
Signed-off-by: Rosen Penev <rosenp@gmail.com>
|
|
[clang-tidy] Found with readability-inconsistent-declaration-parameter-name
Signed-off-by: Rosen Penev <rosenp@gmail.com>
|
|
|
|
|
|
|
|
standard recommends
|
|
|
|
usbmuxd_unsubscribe()
|
|
|
|
|
|
|
|
|
|
can be used in different threads
|
|
Fixes #63.
|
|
|
|
|
|
|
|
|
|
|
|
By using USBMUXD_SOCKET_ADDRESS environment variable, it is possible
to make libusbmuxd connect to the specified address. The value needs
to be in format ADDRESS:PORT (or UNIX:PATH on unix systems). If no port
number is specified or parsing fails, the standard socket address (or
unix domain socket file path) will be used silently.
|
|
This commit extends the interface with a new function usbmuxd_get_device()
that allows to look up USB *and* network devices, while the 'old' interface
usbmuxd_get_device_by_udid() only targets USB devices.
The usbmuxd_device_info_t structure now has new members 'conn_type' and
'conn_data' so that the returned device info allows to figure out if
a device is available via USB or network. Check the comments in
include/usbmuxd.h for more details.
|
|
|
|
compiler warning
|
|
|
|
|
|
usbmux id
|