SDRausty / TermuxArch

You can use setupTermuxArch.bash 📲 to install Arch Linux in Amazon, Android, Chromebook and Windows. https://sdrausty.github.io/TermuxArch/docs/install
https://sdrausty.github.io/TermuxArch/
Other
1.42k stars 162 forks source link

vncserver from tigervnc package will only run as root #205

Closed sudomain closed 4 years ago

sudomain commented 4 years ago

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 commented 4 years ago

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[bot] commented 4 years ago

Stale issue message

petkar commented 4 years ago

I had the same issue bothering me for a while. You can see https://github.com/SDRausty/TermuxArch/issues/228#issuecomment-660830867 and https://github.com/SDRausty/TermuxArch/issues/240#issuecomment-663886610 for details. This should be resolved with https://github.com/TermuxArch/TermuxArch/commit/db638048352c8220e01a05ebe85e18fdc11eaf1f 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 commented 4 years ago

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 https://github.com/TermuxArch/TermuxArch/commit/8980bb164460f6139a061d956f3105e73e951066 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 https://github.com/TermuxArch/TermuxArch/commit/8980bb164460f6139a061d956f3105e73e951066 commit addresses some of the issues, but not all. Can sudo and makepkg be retested with this new configuration please?

SDRausty commented 4 years ago

noticed a new error with setupTermuxArch re

resolved with https://github.com/TermuxArch/TermuxArch/commit/7dcb973a21bec8f23ec621d31a6441c7b701b20c

petkar commented 4 years ago

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 https://github.com/TermuxArch/TermuxArch/commit/8980bb164460f6139a061d956f3105e73e951066 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 https://github.com/TermuxArch/TermuxArch/commit/fe280911593e7e407c6e10a857ea746ee5275ab0 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 commented 4 years ago

Another thing that changed is that TermuxKeys runs twice (be it in refresh or manual)

SDRausty commented 4 years ago

Another thing that changed is that TermuxKeys runs twice (be it in refresh or manual)

This should not be necessary with refresh (feature to be implemented). Running keys twice was not needed upon install before, but currently it appears necessary.

petkar commented 4 years ago

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 commented 4 years ago

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 https://github.com/TermuxArch/TermuxArch/commit/92c254c0b34eb149ba362c4bbc14e6ac70f11cc7 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 commented 4 years ago

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 commented 4 years ago

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

Sure, please list all the steps you took.

petkar commented 4 years ago
petkar commented 4 years ago

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

petkar commented 4 years ago

And for the issue with not being able to build from aur, when I posted this https://github.com/SDRausty/TermuxArch/issues/228#issuecomment-660830867 , 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 commented 4 years ago

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 commented 4 years ago
[user23:59yay]$ yay --version
yay v10.0.3 - libalpm v12.0.2

This https://github.com/TermuxArch/TermuxArch/commit/2c0f56dd6c6b7e9d9243dd22a92df07ef92fe234 commit adds wheel support to addauser, and let's continue this makepkg topic https://github.com/TermuxArch/TermuxArch/issues/14 here as it is unrelated to this issue.