Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
An LD_PRELOAD fix for a really stupid spotify problem
// Save this file somewhere as spotify.preload.c
// Then build the library:
// gcc -fPIC -shared -o ~/spotify.preload.so spotify.preload.c -ldl
// When you execute spotify, you need to preload this library, which wraps the "setsockopt" function call with another function that gives spotify the results it expects:
// LD_PRELOAD=~/spotify.preload.so spotify
// To make the desktop icon work, edit: /usr/share/applications/spotify.desktop
// Change Exec=... to:
// Exec=LD_PRELOAD=~/spotify.preload.so spotify %U
#define _GNU_SOURCE
#include <dlfcn.h>
#include <sys/socket.h>
#include <netinet/in.h>
static int (*real_setsockopt)(int socket, int level, int option_name, const void *option_value, socklen_t option_len);
int setsockopt(int socket, int level, int option_name, const void *option_value, socklen_t option_len) {
real_setsockopt = dlsym(RTLD_NEXT,"setsockopt");
int ret = real_setsockopt(socket,level,option_name,option_value,option_len);
if (level == SOL_IP && option_name == IP_MULTICAST_IF) {
return 0;
}
return ret;
}
@akachida

This comment has been minimized.

Copy link

@akachida akachida commented May 3, 2018

Works on terminal but not with Desktop Shortcut.
If i run LD_PRELOAD=~/spotify.preload.so spotify %U works greate, but changing the .desktop display error

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment