Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

vncserver from tigervnc package will only run as root #205

Closed
sudomain opened this issue Jan 9, 2020 · 17 comments
Closed

vncserver from tigervnc package will only run as root #205

sudomain opened this issue Jan 9, 2020 · 17 comments

Comments

@sudomain
Copy link

sudomain commented Jan 9, 2020

Apologies for originally opening this issue in the wrong GH repo.. The command vncserver :1 -localhost will only work under two conditions:

  1. When run as root
  2. When switching to a user using su user from the root user

Trying to run vncserver :1 -localhost as the non-root user via
startarch u[ser]|l[ogin] user
or
startarch s[u] user cmd

will result in this error:

`[user11:27~]$ vncserver :1 -localhost
xauth: error in locking authority file /home/user/.Xauthority
Could not start Xvnc.

(EE)
Fatal server error:
(EE) Can't read lock file /tmp/.X1-lock
(EE)`

My goal is to create a script that will launch the vnc server as the non-root user (since there is a gui program that wont run as root), but it seems the above startarch syntaxes don't allow this?

@lypanov
Copy link

lypanov commented Mar 14, 2020

Playing around with this locally I have found out how to run commands as a normal non-root user. By using the root account to cp over the /root/.Xauthority command over to the users account homedir the user is able to access the X instance created by root.

The alternative is to using something like xdm to allow you to do log in after X starts up, but while I have had some luck getting xdm to appear over VNC I have hit a wall with getting past the PAM related authentication errors I see when trying to log in.

@github-actions
Copy link

Stale issue message

@petkar
Copy link

petkar commented Aug 2, 2020

I had the same issue bothering me for a while. You can see #228 (comment) and #240 (comment) for details. This should be resolved with TermuxArch/TermuxArch@db63804
However it still may not work on the user account right off the bat. To get it fully working, you have to edit the startarch file in /data/data/com.termux/files/usr/bin. After adding the --link2symlink option on the 90th and 109th line (i.e enable link2symlink for user accounts), xauth didn't give any errors and VNC started successfully.
Edit : The cause for this error was running setupTermuxArch refresh

@SDRausty
Copy link
Owner

SDRausty commented Aug 3, 2020

adding the --link2symlink option on the 90th and 109th line (i.e enable link2symlink for user accounts),

This is now automated.

link2symlink

> Variable substitution in TermuxArch resolves sudo. Variable assignment PROOTSTMNTU="${PROOTSTMNT//--link2symlink }" drops --link2symlink from the user login proot statement. The option is necessary for root user to function properly.

The code might be archaic by now. Depreciated for testing with TermuxArch/TermuxArch@8980bb1 commit. How is sudo?

cause for this error was running setupTermuxArch refresh

I do not see errors running setupTermuxArch refresh. I have noticed a new error with setupTermuxArch re:

option purpose
setupTermuxArch.bash r quick root user refresh
setupTermuxArch.bash re quick root and users refresh with locale-gen
setupTermuxArch.bash refresh full root and users refresh with locale-gen and keys

This TermuxArch/TermuxArch@8980bb1 commit addresses some of the issues, but not all. Can sudo and makepkg be retested with this new configuration please?

@SDRausty SDRausty reopened this Aug 3, 2020
@SDRausty
Copy link
Owner

SDRausty commented Aug 3, 2020

noticed a new error with setupTermuxArch re

resolved with TermuxArch/TermuxArch@7dcb973

@SDRausty SDRausty closed this as completed Aug 3, 2020
@petkar
Copy link

petkar commented Aug 3, 2020

This is now automated.

Can confirm. X11 works on all three refresh options correctly now.

How is sudo?

sudo seems to be working perfectly on my device even after refreshing using all three methods. So does downloading and installing packages from pacman as a user (and root). Makepkg stopped working and fails at either build() or with fakeroot error. I tested this on my device and with a fresh install (on another device of the same model) only to obtain the same results. Does this commit TermuxArch/TermuxArch@8980bb1 somehow affect makepkg? Besides being unable to build aur packages, the installation of programs like gcc and python is smooth on user when done using sudo (good news).

I have noticed a new error with setupTermuxArch re:

As for this issue, it happens to be that files ownership is either current user or root only. Proot doesn't track any chown call and file attribute states. This may lead to breakage of some tools relying on setuid/setgid.
Please remove the additions from TermuxArch/TermuxArch@fe28091 because I believe that --link2symlink should suffice along with doing chmod u+rwX /home/USER (from logging in as USER). The commit should be reverted because it was a custom fix and I lack data on the scope of the issue and how many devices and people are affected by xorg not starting due to r re or refresh.
@SDRausty Did you run xfce4/lxde on (xorg-server;tigervnc) and face any issues starting it as a user eariler?

To conclude, makepkg seems to be failing.
Edit : Note :

   		startarch c "usermod -u $UID $USER 2>/dev/null"
   			startarch c "groupmod -g $GID $USER 2>/dev/null"

These two lines must be run only once and not every time refresh is run. I guess that's a bad implementation from my side. Please correct it.

And as for startarch c "chown -R $USER:$USER /home/$USER" it should be run as the user and not root. Please edit it to execute as user.

@petkar

This comment has been minimized.

@SDRausty

This comment has been minimized.

@petkar
Copy link

petkar commented Aug 3, 2020

A new error I'm getting is open terminal failed: not a terminal when I open tmux in addition to the makepkg not working.
Edit : Ususally running sudo keys fixed it but now it doesn't.
Edit : This is hilarious but running keys four times fixed it.

@SDRausty
Copy link
Owner

SDRausty commented Aug 3, 2020

running keys four times fixed it.
Running keys twice was not needed upon install before

I will take a closer look at this again. If you take a closer look at keys; startarch c 'grep pacman ~/bin/keys|wc -l' pacman is called 10 times. This was necessary to make keys work at all.

For now it appears we might have something better than we had with this revert TermuxArch/TermuxArch@92c254c commit. Can you check if startarch c "chown -R $USER:$USER /home/$USER" which is now $STARTBIN c "chown -R $USER:$USER $INSTALLDIR/home/$USER" wants more work please.

@petkar
Copy link

petkar commented Aug 3, 2020

Just tested makepkg and was able to build yay on both my device and and a test device of the same model. It seems that fakeroot-tcp doesn't build and returns the error :

/home/realzink/fakeroot-tcp/PKGBUILD: line 41: po4a: command not found
==> ERROR: A failure occurred in build().
    Aborting...
[realzink02:09fakeroot-tcp]$ 

The po4a binary seems to be missing even though I reinstalled it.
whereis po4a returns:

[realzink02:09fakeroot-tcp]$ whereis po4a
po4a: /usr/share/man/man7/po4a.7.gz /usr/share/man/man1/po4a.1p.gz

Could you test this out after a full pacman -Syu upgrade?

@SDRausty
Copy link
Owner

SDRausty commented Aug 3, 2020

Could you test this out after a full pacman -Syu upgrade?

Sure, please list all the steps you took.

@petkar
Copy link

petkar commented Aug 3, 2020

  • Refresh from the latest commit. Run keys as root. Restart termux and log in as user. Do sudo pacman -Syu
  • Run sudo pacman -Rncs fakeroot-tcp if it exists (It used to build directly with fakeroot and patched makepkg but I wanted to retest building fakeroot-tcp using fakeroot which used to work earlier)
  • Optionally run sudo pacman -S fakeroot cd ~ git clone https://aur.archlinux.org/yay.git cd yay && makepkg -si. Check if it builds with fakeroot
  • Run cd ~ && git clone https://aur.archlinux.org/fakeroot-tcp.git && cd fakeroot-tcp && makepkg -si --noprepare.
    Does it build successfully? Does the po4a binary exist? I'm not sure if an update caused this or a regression due to a commit.

@petkar
Copy link

petkar commented Aug 4, 2020

Please do report the status of the build from the above instructions when time permits.

@petkar
Copy link

petkar commented Aug 4, 2020

And for the issue with not being able to build from aur, when I posted this #228 (comment) , I was able to download packages straight after cloning and running makepkg -si. Even the installation of fakeroot-tcp wasn't required.

It only affected the standard user (Also, I'm able to install aur packages right after copying makepkg.diff because fakeroot was working. Great work!).

It was about 15 days ago and you could build from aur without even the need to switch to fakeroot tcp. But this stopped after the subsequent refresh and I'm not sure which commit caused this regression.
In fact, I build yay and menulibre from yay without even needing to use fakeroot tcp then, but I can't do the same now.
And the frequency of the error open terminal failed: not a terminal increased greatly. For some reason I have to run keys every time I start a new session to fix this now.

@SDRausty
Copy link
Owner

SDRausty commented Aug 6, 2020

Check if it builds with fakeroot

sudo pacman -S fakeroot ; cd ; git clone https://aur.archlinux.org/yay.git ; cd yay && makepkg -si

==> Entering fakeroot environment...
fakeroot, while creating message channels: Function not implemented
This may be due to a lack of SYSV IPC support.
fakeroot: error while starting the `faked' daemon.

Does it build successfully? Does the po4a binary exist?

cd && git clone https://aur.archlinux.org/fakeroot-tcp.git && cd fakeroot-tcp && makepkg -si --noprepare

/home/user/fakeroot-tcp/PKGBUILD: line 41: po4a: command not found
==> ERROR: A failure occurred in build().
    Aborting...
[user22:51fakeroot-tcp]$ which po4a
which: no po4a in (/home/user/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/data/data/com.termux/files/home/bin:/data/data/com.termux/files/usr/bin:/data/data/com.termux/files/usr/bin/applets)
[user22:52fakeroot-tcp]$ pcss po4a
community/po4a 0.59.1-2 [installed]
    Tools for helping translation of documentation
[user22:52fakeroot-tcp]$ uname -m
armv7l

After patching with patch -n -i makepkg.diff -o makepkg /bin/makepkg

==> Installing package yay with pacman -U...
Password:
su: Authentication failure
==> WARNING: Failed to install built package(s).
[user23:13yay]$

po4a: command not found

@SDRausty
Copy link
Owner

SDRausty commented Aug 6, 2020

[user23:59yay]$ yay --version
yay v10.0.3 - libalpm v12.0.2

This TermuxArch/TermuxArch@2c0f56d commit adds wheel support to addauser, and let's continue this makepkg topic TermuxArch/TermuxArch#14 here as it is unrelated to this issue.

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

No branches or pull requests

4 participants