Cannot open socket to MPD
Upmpdcli 1.5.12 libupnpp 0.21.0 , cannot connect to loopback mpd (127.0.0.1) nor external host.
I think this is because of user is changed before opening the socket.
Can't use setcap
, tool is not available in this system.
root@LX01:/tmp# uname -a
Linux LX01 3.4.39 #1 SMP PREEMPT Thu Jun 14 02:25:36 UTC 2018 armv7l GNU/Linux
root@LX01:/tmp# /usr/bin/upmpdcli -c /data/upmpdcli.conf
:2:src/mpdcli.cxx:114::MPDCli::openconn: mpd_connection_new failed: Permission denied
:2:src/main.cxx:640::MPD connection failed
:2:src/mpdcli.cxx:114::MPDCli::openconn: mpd_connection_new failed: Permission denied
:2:src/main.cxx:640::MPD connection failed
:2:src/mpdcli.cxx:114::MPDCli::openconn: mpd_connection_new failed: Permission denied
:2:src/main.cxx:640::MPD connection failed
strace shows the following command not working:
socket(PF_INET, SOCK_STREAM|SOCK_CLOEXEC|SOCK_NONBLOCK, IPPROTO_TCP) = -1 EACCES (Permission denied)
more context on strace:
fstat64(3, {st_mode=S_IFREG|0664, st_size=347, ...}) = 0
read(3, "root:x:0:0:root:/root:/bin/ash\nd"..., 1024) = 347
close(3) = 0
geteuid32() = 0
openat(AT_FDCWD, "/var/run/upmpdcli.pid", O_RDWR|O_CREAT|O_LARGEFILE, 0644) = 3
flock(3, LOCK_EX|LOCK_NB) = 0
ftruncate64(3, 0) = 0
ftruncate64(3, 0) = 0
getpid() = 2613
_llseek(3, 0, [0], SEEK_SET) = 0
write(3, "2613", 4) = 4
access("/var", F_OK) = 0
access("/var/cache", F_OK) = 0
access("/var/cache/upmpdcli", F_OK) = 0
access("/var/cache/upmpdcli//upmstate", F_OK) = 0
openat(AT_FDCWD, "/var/cache/upmpdcli//upmstate", O_RDWR|O_LARGEFILE) = 4
read(4, "", 8191) = 0
stat64("/var/cache/upmpdcli//upmstate", {st_mode=S_IFREG|0644, st_size=0, ...}) = 0
close(4) = 0
openat(AT_FDCWD, "/var/cache/upmpdcli//metacache", O_RDWR|O_CREAT|O_LARGEFILE, 0644) = 4
close(4) = 0
geteuid32() = 0
ftruncate64(3, 0) = 0
getpid() = 2613
_llseek(3, 0, [0], SEEK_SET) = 0
write(3, "2613", 4) = 4
chown32("/var/cache/upmpdcli", 199, -1) = 0
chown32("/var/cache/upmpdcli//upmstate", 199, -1) = 0
chown32("/var/cache/upmpdcli//metacache", 199, -1) = 0
stat64("/data/upmpdcli.conf", {st_mode=S_IFREG|0640, st_size=6474, ...}) = 0
socket(PF_LOCAL, SOCK_STREAM|SOCK_CLOEXEC|SOCK_NONBLOCK, 0) = 4
connect(4, {sa_family=AF_LOCAL, sun_path="/var/run/nscd/socket"}, 110) = -1 ENOENT (No such file or directory)
close(4) = 0
socket(PF_LOCAL, SOCK_STREAM|SOCK_CLOEXEC|SOCK_NONBLOCK, 0) = 4
connect(4, {sa_family=AF_LOCAL, sun_path="/var/run/nscd/socket"}, 110) = -1 ENOENT (No such file or directory)
close(4) = 0
openat(AT_FDCWD, "/etc/nsswitch.conf", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/etc/nsswitch.conf", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/etc/group", O_RDONLY|O_CLOEXEC) = 4
_llseek(4, 0, [0], SEEK_CUR) = 0
fstat64(4, {st_mode=S_IFREG|0664, st_size=184, ...}) = 0
read(4, "root:x:0:\ndaemon:x:1:\nadm:x:4:\nm"..., 1024) = 184
_llseek(4, 0, [184], SEEK_CUR) = 0
_llseek(4, 0, [184], SEEK_CUR) = 0
_llseek(4, 0, [184], SEEK_CUR) = 0
_llseek(4, 0, [184], SEEK_CUR) = 0
_llseek(4, 0, [184], SEEK_CUR) = 0
_llseek(4, 0, [184], SEEK_CUR) = 0
_llseek(4, 0, [184], SEEK_CUR) = 0
_llseek(4, 0, [184], SEEK_CUR) = 0
_llseek(4, 0, [184], SEEK_CUR) = 0
_llseek(4, 0, [184], SEEK_CUR) = 0
_llseek(4, 0, [184], SEEK_CUR) = 0
_llseek(4, 0, [184], SEEK_CUR) = 0
_llseek(4, 0, [184], SEEK_CUR) = 0
_llseek(4, 0, [184], SEEK_CUR) = 0
read(4, "", 1024) = 0
close(4) = 0
openat(AT_FDCWD, "/proc/sys/kernel/ngroups_max", O_RDONLY) = 4
read(4, "65536\n", 31) = 6
close(4) = 0
openat(AT_FDCWD, "/etc/group", O_RDONLY|O_CLOEXEC) = 4
_llseek(4, 0, [0], SEEK_CUR) = 0
fstat64(4, {st_mode=S_IFREG|0664, st_size=184, ...}) = 0
read(4, "root:x:0:\ndaemon:x:1:\nadm:x:4:\nm"..., 1024) = 184
_llseek(4, 0, [184], SEEK_CUR) = 0
_llseek(4, 0, [184], SEEK_CUR) = 0
_llseek(4, 0, [184], SEEK_CUR) = 0
_llseek(4, 0, [184], SEEK_CUR) = 0
_llseek(4, 0, [184], SEEK_CUR) = 0
_llseek(4, 0, [184], SEEK_CUR) = 0
_llseek(4, 0, [184], SEEK_CUR) = 0
_llseek(4, 0, [184], SEEK_CUR) = 0
_llseek(4, 0, [184], SEEK_CUR) = 0
_llseek(4, 0, [184], SEEK_CUR) = 0
_llseek(4, 0, [184], SEEK_CUR) = 0
_llseek(4, 0, [184], SEEK_CUR) = 0
_llseek(4, 0, [184], SEEK_CUR) = 0
_llseek(4, 0, [184], SEEK_CUR) = 0
read(4, "", 1024) = 0
close(4) = 0
setgroups32(1, [199]) = 0
setuid32(199) = 0
access("/usr/sbin/sc2mpd", X_OK) = -1 ENOENT (No such file or directory)
access("/usr/bin/sc2mpd", X_OK) = -1 ENOENT (No such file or directory)
access("/sbin/sc2mpd", X_OK) = -1 ENOENT (No such file or directory)
access("/bin/sc2mpd", X_OK) = -1 ENOENT (No such file or directory)
access("/usr/sbin/scmakempdsender", X_OK) = -1 ENOENT (No such file or directory)
access("/usr/bin/scmakempdsender", X_OK) = -1 ENOENT (No such file or directory)
access("/sbin/scmakempdsender", X_OK) = -1 ENOENT (No such file or directory)
access("/bin/scmakempdsender", X_OK) = -1 ENOENT (No such file or directory)
socket(PF_INET, SOCK_STREAM|SOCK_CLOEXEC|SOCK_NONBLOCK, IPPROTO_TCP) = -1 EACCES (Permission denied)
write(2, ":", 1:) = 1
write(2, "2", 12) = 1
write(2, ":", 1:) = 1
write(2, "src/mpdcli.cxx", 14src/mpdcli.cxx) = 14
write(2, ":", 1:) = 1
write(2, "114", 3114) = 3
write(2, "::", 2::) = 2
write(2, "MPDCli::openconn: mpd_connection"..., 45MPDCli::openconn: mpd_connection_new failed: ) = 45
write(2, "Permission denied", 17Permission denied) = 17
write(2, "\n", 1
) = 1
write(2, ":", 1:) = 1
write(2, "2", 12) = 1
write(2, ":", 1:) = 1
write(2, "src/main.cxx", 12src/main.cxx) = 12
write(2, ":", 1:) = 1
write(2, "640", 3640) = 3
write(2, "::", 2::) = 2
write(2, "MPD connection failed", 21MPD connection failed) = 21
write(2, "\n", 1
) = 1
nanosleep({2, 0}, 0xbea544b8) = 0
socket(PF_INET, SOCK_STREAM|SOCK_CLOEXEC|SOCK_NONBLOCK, IPPROTO_TCP) = -1 EACCES (Permission denied)
write(2, ":", 1:) = 1
write(2, "2", 12) = 1
write(2, ":", 1:) = 1
write(2, "src/mpdcli.cxx", 14src/mpdcli.cxx) = 14
write(2, ":", 1:) = 1
write(2, "114", 3114) = 3
write(2, "::", 2::) = 2
write(2, "MPDCli::openconn: mpd_connection"..., 45MPDCli::openconn: mpd_connection_new failed: ) = 45
write(2, "Permission denied", 17Permission denied) = 17
write(2, "\n", 1
) = 1