diff options
-rw-r--r-- | .SRCINFO | 2 | ||||
-rw-r--r-- | PKGBUILD | 4 | ||||
-rw-r--r-- | fix_flatpak.rs | 22 |
3 files changed, 15 insertions, 13 deletions
@@ -1,7 +1,7 @@ pkgbase = shortwave-bin-hack pkgdesc = Find and listen to internet radio stations. This pkg uses a fork and some hacks to make it work, checkout (https://aur.archlinux.org/packages/shortwave-bin-hack/) for more infos. pkgver = 1673135 - pkgrel = 2 + pkgrel = 3 url = https://gitlab.gnome.org/World/Shortwave/ arch = any license = GPL @@ -2,7 +2,7 @@ pkgname=shortwave-bin-hack pkgver=1673135 -pkgrel=2 +pkgrel=3 pkgdesc="Find and listen to internet radio stations. This pkg uses a fork and some hacks to make it work, checkout (https://aur.archlinux.org/packages/shortwave-bin-hack/) for more infos." arch=(any) @@ -16,7 +16,7 @@ depends=('gst-plugins-bad' 'libadwaita' 'libsoup') source=("https://gitlab.gnome.org/sigmaSd/Shortwave/-/jobs/$pkgver/artifacts/download" "fix_flatpak.rs" "shortwave") sha256sums=('c5a02e584f9152d0735d38174e0fa8c1e5a58d4a8f6517b20c846a95740c4c15' - '7fabb61c7bf97396ced87e1e45064c38cdf8fde2f3f1f52030706293132f6843' + 'be5ebc6f13a7ac2558ca80c8dcaa89f7a1118e9eb7b68515d2fdec80b90f1818' '58f061f909b6a8eff030ba1058a3c70c3ca3680ed13b865a118671388a3f3a9d') diff --git a/fix_flatpak.rs b/fix_flatpak.rs index 58147c879423..210127449468 100644 --- a/fix_flatpak.rs +++ b/fix_flatpak.rs @@ -10,41 +10,43 @@ extern "C" { #[no_mangle] #[allow(clippy::missing_safety_doc)] -pub unsafe extern "C" fn open64(path: *const c_char, oflag: c_int) -> c_int { +pub unsafe extern "C" fn open64(c_path: *const c_char, oflag: c_int) -> c_int { let original_open64: extern "C" fn(*const c_char, c_int) -> c_int = { let f = dlsym(RTLD_NEXT, "open64\0".as_ptr() as _); transmute(f) }; - let p = { - let p = CString::from_raw(path as _); + let c_string_path = { + let p = CString::from_raw(c_path as _); let p2 = p.clone(); + // Forget the original path, so we don't drop it before shortwave uses it std::mem::forget(p); p2 }; - if p == CString::new("/app/share/shortwave/de.haeckerfelix.Shortwave.gresource").unwrap() { + let str_path = c_string_path.to_str().unwrap(); // can fail if the path is not utf-8 + if str_path == "/app/share/shortwave/de.haeckerfelix.Shortwave.gresource" { original_open64( CString::new("/usr/share/shortwave/de.haeckerfelix.Shortwave.gresource") .unwrap() .into_raw(), oflag, ) - } else if p.to_str().unwrap().contains("favicon") || p.to_str().unwrap().contains("recording") { + } else if str_path.contains("favicon") || str_path.contains("recording") { // For some reason favicons/recording permission changes sometimes to 000 // This is probably due to how flatpak sandbox works. - // This blocks worksaround it. - let result = original_open64(p.clone().into_raw(), oflag); + // This blocks works-around it. + let result = original_open64(c_string_path.clone().into_raw(), oflag); // c_path should not be used here or it will be consumed if result == -1 { std::process::Command::new("chmod") .arg("+rw") - .arg(p.to_str().unwrap()) + .arg(str_path) .status() .unwrap(); - original_open64(path, oflag) + original_open64(c_path, oflag) } else { result } } else { - original_open64(path, oflag) + original_open64(c_path, oflag) } } |