Accessing www-data when logged in as another user

I want to describe what is my problem :slight_smile:

I would like to open a specific program with the www-data user via Putty with X11 Forwarding. With the “pi” user it worked after I set the entry “X11Forwarding” to yes in sshd.conf. So when I log in to my Raspberry via Putty and user pi (with X11 forwarding setting), start a GUI program from there it works fine.

With this program I want to access ncdata, which unfortunately is not possible because this directory belongs to the www-data account.

Therefore I tried to execute this command with the following command (after logging into my Raspberry with the pi user (and X11 forwarding):
pi@nextcloudpi:~ $ sudo runuser -l www-data -c fslint-gui

ERROR:
/usr/lib/python2.7/dist-packages/gtk-2.0/gtk/ init .py:57: GtkWarning: could not open display
warnings.warn(str(e), _gtk.Warning)
/usr/bin/fslint-gui:268: Warning: invalid (NULL) pointer instance
self.widgets = gtk.glade.XML(Filename, WindowName, gettext.textdomain())
/usr/bin/fslint-gui:268: Warning: g_signal_connect_data: assertion ‘G_TYPE_CHECK_INSTANCE (instance)’ failed

That works with the pi user, but in the above Command I use the www-data for the call and then the GTK error message appears, which probably has something to do with X11, since the www-data user has a “nologin” flag and no bash.

That’s why I’m now trying to fix this error - which is actually a Linux-relevant topic, as JimmyKater has already mentioned.

Big thanks to JimmyKater !!!

1 Like

Login and shell are disabled by default for very good security reasons for www-data.

I would strongly advise against it for that reason. It would create a vulnerability.
Would you please clarify; why you want or need to access ncdata in Gui program (and which one), you already have the webinterface for that.What function(s) are you missing there.

what about login with your standard user and then :
sudo -u www-data

How are you going to sudo -u in a GUI or plan to run a terminal inside of it? :rofl:

yeaaa in GUI it will not work … :grinning:

How about adding your pi user to the www-data group allowing him to read all Nextcloud files

sudo adduser pi www-data