0

I am using the newns script from here:

https://superuser.com/questions/983727/route-only-specific-traffic-through-vpn

... except on this system:

$ mate-about -v
MATE Desktop Environment 1.24.0

$ cat /etc/issue
Ubuntu 20.04.2 LTS \n \l

$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 20.04.2 LTS
Release:    20.04
Codename:   focal

So, the thing is, I have changed to export XTERM=/usr/bin/mate-terminal in that script, and when I run newns MYNS start right after reboot, the "namespaced" terminal runs fine; then I run newns MYNS stop, and the "namespaced" terminal is shut down - all good, all as expected.

But then, when I want to repeat the procedure - the terminal does NOT start anymore, but there is no error either?! I have eventually reduced it to this line (once the network namespace MYNS is made):

$ sudo /usr/bin/ip netns exec MYNS su -c /usr/bin/mate-terminal myusername

(mate-terminal:12410): dbind-WARNING **: 17:33:10.398: Couldn't connect to accessibility bus: Failed to connect to socket /tmp/dbus-pRWfI7rzyW: Connection refused

Every once in a while, it might run once, but 99% of the time, re-running this command results with nothing.

Here is the funny part - if I replace mate-terminal with xterm in the above command line:

sudo /usr/bin/ip netns exec MYNS su -c /usr/bin/xterm myusername

... it works every time! But I do not want to use xterm - I need a terminal with tabs ...

Just for fun, I tried running VLC here, too:

sudo /usr/bin/ip netns exec MYNS su -c /usr/bin/vlc myusername

... and at least it starts fine (though it complains "vlcpulse audio output error: PulseAudio server connection failure: Connection refused"; "dbus interface error: Failed to connect to the D-Bus session daemon: Failed to connect to socket /tmp/dbus-CRRGy7gvlN: Connection refused" etc ...)

So, finally I installed gnome-terminal and tried with it - and it will not start either, just like mate-terminal, except with different messages:

$ sudo /usr/bin/ip netns exec MYNS su -c /usr/bin/gnome-terminal myusername
# Couldn't connect to accessibility bus: Failed to connect to socket /tmp/dbus-pRWfI7rzyW: Connection refused
# Error constructing proxy for org.gnome.Terminal:/org/gnome/Terminal/Factory0: Could not connect: Connection refused

This file /tmp/dbus-pRWfI7rzyW keeps on repeating for starts of both terminals, but:

$ sudo ls -la /tmp/dbus*
ls: cannot access '/tmp/dbus*': No such file or directory

... it is most definitely not present on the system.

So, my guess is, this might have something to do with DBUS - unfortunately, I do not really know or understand dbus.

My question is - is there a workaround I could do, so mate-terminal or gnome-terminal could start in this context every time?

sdaau
  • 6,668
  • 12
  • 57
  • 69

1 Answers1

1

As you suspected, the reason the fancier terminals don't work is because they can't connect to dbus. This is because dbus uses an abstract unix socket, which isn't available in that new namespace (see this question).

There are lots of options in that referenced question, but probably the simplest is to just get a dbus session for every invocation, if you don't need a lot of shared dbus niceties (probably don't):

sudo /usr/bin/ip netns exec MYNS su -c "/usr/bin/dbus-launch /usr/bin/gnome-terminal"
  • Sorry for the late response - I get a lot of terminal dbus errors even when I start GUI programs from normal terminal sessions, and I don't really grok dbus - so I kind of ignored the messages in the OP, and did not realize the problem is actually dbus related, until I tried this answer. It works great - thank you very much! – sdaau Mar 18 '22 at 06:17