There is daemon in my system, it runs inside of a screen instance and all that is done from an unpriveleged user. I’ve added myself to special sudo group allowing me to run screen from this user, but when I try to use it, e.g.
sudo -u that_user -H /usr/bin/screen -R
I get the subject of this post.
Digging around I found that this message means that screen cannot grab or do output to the pty I actually use when calling it. Common answer to this is to chmod my /dev/pts/N to be rw for the others, but I remember I somehow managed to avoid this earlier. Maybe I missed to save some environment for sudo?
In particular I’m trying to connect to rtorrent daemon running in screen from an ordinary user via sudo, OS is Gentoo amd64. Here is how screen is called from the rc-script:
start-stop-daemon \
--start \
--make-pidfile \
--pidfile /var/run/rtorrentd.pid \
--background \
--user $USER \
--env HOME="${PWHOME:-/home/$USER}" \
--name rtorrent \
--exec /usr/bin/screen -- -D -m -S rtorrentd /usr/bin/rtorrent
Finally worked the actual solution out:
alias rtorrent="urxvt -hold -e /bin/bash -c \"chmod o+rw \\\`tty\\\` && sudo -u rtorrent -H screen -r rtorrentd\""