diff --git a/0001-Fix-crash-on-early-fail.patch b/0001-Fix-crash-on-early-fail.patch new file mode 100644 index 0000000..bab74dc --- /dev/null +++ b/0001-Fix-crash-on-early-fail.patch @@ -0,0 +1,29 @@ +From 73001792b29f080fcabc57f30d6030bedb2a24b0 Mon Sep 17 00:00:00 2001 +From: Lubomir Rintel +Date: Wed, 20 Jul 2016 21:14:10 +0200 +Subject: [PATCH] Fix crash on early fail + +Don't uninitialize libusb if it has not been initialized yet. + +https://bugzilla.redhat.com/show_bug.cgi?id=1358472 +--- + usb_modeswitch.c | 3 ++- + 1 file changed, 2 insertions(+), 1 deletion(-) + +diff --git a/usb_modeswitch.c b/usb_modeswitch.c +index cbb8c28..f9c8b2e 100644 +--- a/usb_modeswitch.c ++++ b/usb_modeswitch.c +@@ -2021,7 +2021,8 @@ void close_all() + libusb_close(devh); + // libusb_exit will crash on Raspbian 7, crude protection + #ifndef __ARMEL__ +- libusb_exit(NULL); ++ if (ctx) ++ libusb_exit(NULL); + #endif + if (sysmode) + closelog(); +-- +2.7.4 + diff --git a/0001-usb_modeswitch-fix-a-wrong-comparison.patch b/0001-usb_modeswitch-fix-a-wrong-comparison.patch new file mode 100644 index 0000000..863e880 --- /dev/null +++ b/0001-usb_modeswitch-fix-a-wrong-comparison.patch @@ -0,0 +1,26 @@ +From bcb5b8702adbf568598988fccf256586b5788fcb Mon Sep 17 00:00:00 2001 +From: Lubomir Rintel +Date: Fri, 18 Aug 2017 10:37:15 +0200 +Subject: [PATCH 1/2] usb_modeswitch: fix a wrong comparison + +The char pointer should be dereferences when checking the string is empty. +--- + usb_modeswitch.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/usb_modeswitch.c b/usb_modeswitch.c +index b2b930b..6948a84 100644 +--- a/usb_modeswitch.c ++++ b/usb_modeswitch.c +@@ -1707,7 +1707,7 @@ struct libusb_device* search_devices( int *numFound, int vendor, char* productLi + *numFound = 0; + + /* Sanity check */ +- if (!vendor || productList == '\0') ++ if (!vendor || *productList == '\0') + return NULL; + + listcopy = malloc(strlen(productList)+1); +-- +2.13.0 + diff --git a/0002-usb_modeswitch-count-the-target-devices-from-zero.patch b/0002-usb_modeswitch-count-the-target-devices-from-zero.patch new file mode 100644 index 0000000..144d93d --- /dev/null +++ b/0002-usb_modeswitch-count-the-target-devices-from-zero.patch @@ -0,0 +1,26 @@ +From 9d05fe0e0f6b049520d97a47d042d5cfad35b5d6 Mon Sep 17 00:00:00 2001 +From: Lubomir Rintel +Date: Fri, 18 Aug 2017 10:40:41 +0200 +Subject: [PATCH 2/2] usb_modeswitch: count the target devices from zero + +Most likely a typo here. +--- + usb_modeswitch.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/usb_modeswitch.c b/usb_modeswitch.c +index 6948a84..4a1fb5c 100644 +--- a/usb_modeswitch.c ++++ b/usb_modeswitch.c +@@ -1579,7 +1579,7 @@ int checkSuccess() + * Target device on the same bus with higher device number is returned, + * description is read for syslog message + */ +- for (i=i; i < CheckSuccess; i++) { ++ for (i=0; i < CheckSuccess; i++) { + SHOW_PROGRESS(output," Search for target devices ...\n"); + dev = search_devices(&newTargetCount, TargetVendor, TargetProductList, + TargetClass, 0, SEARCH_TARGET); +-- +2.13.0 + diff --git a/device_reference.txt b/device_reference.txt index d3065d9..d34ec3e 100644 --- a/device_reference.txt +++ b/device_reference.txt @@ -1,16 +1,16 @@ # # Device Reference (UTF-8 encoding used) # -# Last modified: 2017-02-05 +# Last modified: 2014-05-29 # # Collection of configurations for usb_modeswitch, a mode switching # tool for controlling flip flop (multiple mode) USB devices # # Detailed instructions and a friendly forum on the homepage: # http://www.draisberghof.de/usb_modeswitch -# -# Note that new devices are no longer added to this file. See the -# config files included with the data package for these +# +# You may want to check for a newer version of this file at: +# http://www.draisberghof.de/usb_modeswitch/device_reference.txt # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # @@ -21,10 +21,9 @@ # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # -# For a parameter reference see file REFERENCE in the data package or -# http://www.draisberghof.de/usb_modeswitch/parameter_reference.txt +# For a parameter reference see file REFERENCE in the data package # -# If you find new working codes and configurations, please report +# If you find working codes and configurations, please contribute # them! @@ -32,7 +31,6 @@ ####################################################### # Option GlobeSurfer Icon (aka "Vodafone EasyBox") -# This is the thing that started it all ... # # The MessageContent is identical for all Option devices diff --git a/rhbz948451-fix-manual-pages.patch b/rhbz948451-fix-manual-pages.patch new file mode 100644 index 0000000..32238b9 --- /dev/null +++ b/rhbz948451-fix-manual-pages.patch @@ -0,0 +1,23 @@ +diff --git a/usb_modeswitch.c b/usb_modeswitch.c +index 52598f7..cbb8c28 100644 +--- a/usb_modeswitch.c ++++ b/usb_modeswitch.c +@@ -2060,7 +2060,8 @@ void printHelp() + " -g, --device-num NUM system device number (for hard ID)\n" + " -m, --message-endpoint NUM direct the message transfer there (optional)\n" + " -M, --message-content message to send (hex number as string)\n" +- " -2 , -3 additional messages to send (-n recommended)\n" ++ " -2, --message-content2 additional messages to send (-n recommended)\n" ++ " -3, --message-content3 additional messages to send (-n recommended)\n" + " -w, --release-delay NUM wait NUM ms before releasing the interface\n" + " -n, --need-response obsolete, no effect (always on)\n" + " -r, --response-endpoint NUM read response from there (optional)\n" +@@ -2084,7 +2085,7 @@ void printHelp() + " -Q, --quiet don't show progress or error messages\n" + " -W, --verbose print all settings and debug output\n" + " -D, --sysmode specific result and syslog message\n" +- " -s, --success switching result check with timeout\n" ++ " -s, --check-success switching result check with timeout\n" + " -I, --inquire obsolete, no effect\n\n" + " -c, --config-file load long configuration from file\n\n" + " -t, --stdinput read long configuration from stdin\n\n" diff --git a/sources b/sources index 6e90156..33497be 100644 --- a/sources +++ b/sources @@ -1 +1 @@ -SHA512 (usb-modeswitch-2.6.2.tar.bz2) = adaedf89de3c5f9dc55da7bb5bb3fe8165c0424cffacb00f83876094b7abdc386ced9959e5dbdf46ab06aa1d03fbfca13df539421489ef4d2dd0f72742057f3d +SHA512 (usb-modeswitch-2.5.1.tar.bz2) = 23f1866cbb5882280369362f6d3e01d991136f322284d3f343da132520569f9e303cd9c4368a71893a3d959bae6bde2d4325f6dc175a1cb2d4dd5faa61add6ab diff --git a/usb_modeswitch-2.6.2-SIGTERM.patch b/usb_modeswitch-2.6.2-SIGTERM.patch deleted file mode 100644 index ce4352b..0000000 --- a/usb_modeswitch-2.6.2-SIGTERM.patch +++ /dev/null @@ -1,49 +0,0 @@ -From e3cf80c95a1c67d05dded68ec171bfde4686003f Mon Sep 17 00:00:00 2001 -From: Lubomir Rintel -Date: Thu, 14 Aug 2025 16:35:56 +0200 -Subject: [PATCH] service: Do not ever send SIGTERM to the unit - -Following happens when modem 03f0:a31d (HP lt4132 LTE/HSPA+ 4G Module) is -plugged: - -- systemd-udevd emits "add" action -- The "add" action triggers restart of usb_modeswitch@.service -- usb_modeswitch@.service starts usb_modeswitch -- Another udev rule renames the network interface from usb0 to enp0... -- Above causes systemd-udevd emit "change" action for the device -- The "change" action triggers another restart of usb_modeswitch@.service -- usb_modeswitch run initially gets terminated mid-air -- Device drops off the bus -- Infinite sadness - -Possible solutions: - -- The udev rule could just emit the "change" action. I have no idea why - it handles "change" actions, but it looks intentional -> No touchy - from me. -- usb_modeswitch could just trap TERM and shut down gracefully. This - involves Tcl -> No touchy. -- The systemd unit could just send an innocent signal instead of TERM - and just let usb_modeswitch end its life journey naturally. - Let's do this, because it involves least brain. - -Anybody please feel free to send this upstream. ---- - usb_modeswitch@.service | 4 ++++ - 1 file changed, 4 insertions(+) - -diff --git a/usb_modeswitch@.service b/usb_modeswitch@.service -index 22d2ea7..23d4ed0 100644 ---- a/usb_modeswitch@.service -+++ b/usb_modeswitch@.service -@@ -7,3 +7,7 @@ ExecStart=/usr/sbin/usb_modeswitch_dispatcher --switch-mode %i - # Testing - #ExecStart=/bin/echo "usb_modeswitch.service: device name is %i" - -+# Do not ever terminate violently on restart -- interrupting the switching -+# transaction will crash some modems! We'll terminate shortly anyways. -+# If we hang, FinalKillSignal (defaults to SIGKILL) will take care of that. -+KillSignal=SIGCONT --- -2.50.1 - diff --git a/usb_modeswitch.spec b/usb_modeswitch.spec index b4fa0c0..f782d8d 100644 --- a/usb_modeswitch.spec +++ b/usb_modeswitch.spec @@ -1,29 +1,33 @@ -%define source_name usb-modeswitch +%define source_name usb-modeswitch -Name: usb_modeswitch -Version: 2.6.2 -Release: 6%{?dist} -Summary: USB Modeswitch gets mobile broadband cards in operational mode -Summary(de): USB Modeswitch aktiviert UMTS-Karten -License: GPL-2.0-or-later -URL: http://www.draisberghof.de/usb_modeswitch/ +Name: usb_modeswitch +Version: 2.5.1 +Release: 1%{?dist} +Summary: USB Modeswitch gets mobile broadband cards in operational mode +Summary(de): USB Modeswitch aktiviert UMTS-Karten +Group: Applications/System +License: GPLv2+ +URL: http://www.draisberghof.de/usb_modeswitch/ -Source0: http://www.draisberghof.de/%{name}/%{source_name}-%{version}.tar.bz2 -Source1: http://www.draisberghof.de/usb_modeswitch/device_reference.txt +Source0: http://www.draisberghof.de/%{name}/%{source_name}-%{version}.tar.bz2 +Source1: http://www.draisberghof.de/usb_modeswitch/device_reference.txt +# http://www.draisberghof.de/usb_modeswitch/bb/viewtopic.php?f=2&t=2546 +Patch0: rhbz948451-fix-manual-pages.patch # Submitted upstream (2014-11-24) -Patch0: device_reference-utf8.patch -# Not submitted upstream due to lack of courage -Patch1: usb_modeswitch-2.6.2-SIGTERM.patch +Patch1: device_reference-utf8.patch +# http://www.draisberghof.de/usb_modeswitch/bb/viewtopic.php?f=2&t=2556 +Patch2: 0001-Fix-crash-on-early-fail.patch +# http://www.draisberghof.de/usb_modeswitch/bb/viewtopic.php?f=2&t=2732 +Patch3: 0001-usb_modeswitch-fix-a-wrong-comparison.patch +# http://www.draisberghof.de/usb_modeswitch/bb/viewtopic.php?f=2&t=2733 +Patch4: 0002-usb_modeswitch-count-the-target-devices-from-zero.patch -BuildRequires: make -BuildRequires: gcc -BuildRequires: libusbx-devel -# "tcl" or "jimsh"), use the light-weight installation: -#BuildRequires: jimtcl-devel -BuildRequires: systemd -Requires: usb_modeswitch-data >= 20121109 -Requires: systemd +BuildRequires: libusbx-devel +BuildRequires: jimtcl-devel +BuildRequires: systemd +Requires: usb_modeswitch-data >= 20121109 +Requires: systemd %description USB Modeswitch brings up your datacard into operational mode. When plugged @@ -32,7 +36,7 @@ installation files. This tool deactivates this cdrom-device and enables the real communication device. It supports most devices built and sold by Huawei, T-Mobile, Vodafone, Option, ZTE, Novatel. -%description -l de +%description -l de USB Modeswitch deaktiviert die CDROM-Emulation einiger UMTS-Karten. Dadurch erkennt Linux die Datenkarte und kann damit Internet- Verbindungen aufbauen. Die gängigen Karten von Huawei, T-Mobile, @@ -43,23 +47,23 @@ Vodafone, Option, ZTE und Novatell werden unterstützt. %setup -q -n %{source_name}-%{version} cp -f %{SOURCE1} device_reference.txt -%patch 0 -p0 -%patch 1 -p1 +%patch0 -p1 -b .manpage +%patch1 -p0 -b .utf8 +%patch2 -p1 -b .libusb_exit +%patch3 -p1 -b .char_deref +%patch4 -p1 -b .zero_iter %build -%{set_build_flags} -# this will require jimtcl-devel -#make_build all-with-dynlink-dispatcher -%make_build +CFLAGS="$RPM_OPT_FLAGS" make %{?_smp_mflags} %install -mkdir -p %{buildroot}%{_unitdir} -%make_install \ - SYSDIR=%{buildroot}%{_unitdir} \ - SBINDIR=%{buildroot}%{_sbindir} \ - UDEVDIR=%{buildroot}%{_prefix}/lib/udev +mkdir -p $RPM_BUILD_ROOT%{_unitdir} +make install \ + DESTDIR=$RPM_BUILD_ROOT \ + SYSDIR=$RPM_BUILD_ROOT%{_unitdir} \ + UDEVDIR=$RPM_BUILD_ROOT%{_prefix}/lib/udev %files @@ -70,102 +74,10 @@ mkdir -p %{buildroot}%{_unitdir} %{_prefix}/lib/udev/usb_modeswitch %{_unitdir}/usb_modeswitch@.service %config(noreplace) %{_sysconfdir}/usb_modeswitch.conf -%doc README ChangeLog device_reference.txt -%license COPYING +%doc COPYING README ChangeLog device_reference.txt %changelog -* Fri Jul 17 2026 Fedora Release Engineering - 2.6.2-6 -- Rebuilt for https://fedoraproject.org/wiki/Fedora_45_Mass_Rebuild - -* Sat Jan 17 2026 Fedora Release Engineering - 2.6.2-5 -- Rebuilt for https://fedoraproject.org/wiki/Fedora_44_Mass_Rebuild - -* Thu Aug 14 2025 Lubomir Rintel - 2.6.2-4 -- Do not let the unit send SIGTERM to usb_modeswitch mid-switch. - -* Fri Jul 25 2025 Fedora Release Engineering - 2.6.2-3 -- Rebuilt for https://fedoraproject.org/wiki/Fedora_43_Mass_Rebuild - -* Thu Feb 27 2025 Sérgio Basto - 2.6.2-2 -- Revert the move of usb_modeswitch to /usr/lib/udev/rules.d, usb_modeswitch is - not an rule - -* Thu Feb 20 2025 Sérgio Basto - 2.6.2-1 -- Update usb_modeswitch to 2.6.2 -- Resolves: rhbz#2346392 -- Fix build related to /usr/sbin move - -* Sun Jan 19 2025 Fedora Release Engineering - 2.6.1-12 -- Rebuilt for https://fedoraproject.org/wiki/Fedora_42_Mass_Rebuild - -* Sat Jul 20 2024 Fedora Release Engineering - 2.6.1-11 -- Rebuilt for https://fedoraproject.org/wiki/Fedora_41_Mass_Rebuild - -* Sat Jan 27 2024 Fedora Release Engineering - 2.6.1-10 -- Rebuilt for https://fedoraproject.org/wiki/Fedora_40_Mass_Rebuild - -* Thu Nov 2 2023 Íñigo Huguet - 2.6.1-9 -- Really use SPDX license specifier - -* Thu Aug 24 2023 Till Maas - 2.6.1-8 -- Cleanup spec: use %%license, use %%patch 0 -- Use spdx license specifier - -* Sat Jul 22 2023 Fedora Release Engineering - 2.6.1-7 -- Rebuilt for https://fedoraproject.org/wiki/Fedora_39_Mass_Rebuild - -* Sat Jan 21 2023 Fedora Release Engineering - 2.6.1-6 -- Rebuilt for https://fedoraproject.org/wiki/Fedora_38_Mass_Rebuild - -* Sat Jul 23 2022 Fedora Release Engineering - 2.6.1-5 -- Rebuilt for https://fedoraproject.org/wiki/Fedora_37_Mass_Rebuild - -* Sat Jan 22 2022 Fedora Release Engineering - 2.6.1-4 -- Rebuilt for https://fedoraproject.org/wiki/Fedora_36_Mass_Rebuild - -* Fri Jul 23 2021 Fedora Release Engineering - 2.6.1-3 -- Rebuilt for https://fedoraproject.org/wiki/Fedora_35_Mass_Rebuild - -* Wed Jan 27 2021 Fedora Release Engineering - 2.6.1-2 -- Rebuilt for https://fedoraproject.org/wiki/Fedora_34_Mass_Rebuild - -* Wed Nov 18 2020 Sérgio Basto - 2.6.1-1 -- Update usb_modeswitch to 2.6.1 -- Drop patch1, http://www.draisberghof.de/usb_modeswitch/bb/viewtopic.php?f=2&t=2733 -- Drop BR jimtcl-devel, if we don't install dynlink-dispatcher - -* Tue Sep 29 2020 Sérgio Basto - 2.6.0-3 -- Use make macros (https://src.fedoraproject.org/rpms/usb_modeswitch/pull-request/1) -- https://fedoraproject.org/wiki/Changes/UseMakeBuildInstallMacro - -* Wed Jul 29 2020 Fedora Release Engineering - 2.6.0-2 -- Rebuilt for https://fedoraproject.org/wiki/Fedora_33_Mass_Rebuild - -* Tue Mar 24 2020 Lubomir Rintel - 2.6.0-1 -- New 2.6.0 release - -* Fri Jan 31 2020 Fedora Release Engineering - 2.5.2-5 -- Rebuilt for https://fedoraproject.org/wiki/Fedora_32_Mass_Rebuild - -* Sat Jul 27 2019 Fedora Release Engineering - 2.5.2-4 -- Rebuilt for https://fedoraproject.org/wiki/Fedora_31_Mass_Rebuild - -* Sun Feb 03 2019 Fedora Release Engineering - 2.5.2-3 -- Rebuilt for https://fedoraproject.org/wiki/Fedora_30_Mass_Rebuild - -* Sat Jul 14 2018 Fedora Release Engineering - 2.5.2-2 -- Rebuilt for https://fedoraproject.org/wiki/Fedora_29_Mass_Rebuild - -* Wed Feb 28 2018 Lubomir Rintel - 2.5.2-1 -- New 2.5.2 release - -* Fri Feb 23 2018 Florian Weimer - 2.5.1-3 -- Use LDFLAGS from redhat-rpm-config - -* Fri Feb 09 2018 Fedora Release Engineering - 2.5.1-2 -- Rebuilt for https://fedoraproject.org/wiki/Fedora_28_Mass_Rebuild - * Fri Aug 18 2017 Lubomir Rintel - 2.5.1-1 - New 2.5.1 release