:: [DNG] [ASCII][PATCH] startx to a ne…
Página superior
Eliminar este mensaje
Responder a este mensaje
Autor: Dario Niedermann
Fecha:  
A: dng
Asunto: [DNG] [ASCII][PATCH] startx to a new tty
Hello! After trying Devuan ASCII, I noticed a problem with `startx' that
I never had before: the X server occupies the same tty where `startx'
was issued. It should allocate the first unused tty instead
(default: tty07).

Now, if you have no problem with that, you may disregard the rest
of this message. If it's not even happening to you, I'd be interested
in comparing notes.


=== Why it is a problem ===

Once you quit X, the tty is no longer owned by you, but by root.
If, for example, you try to reattach to a `screen' session,
that will fail. Also, losing a logged-in tty during the X11 session
can be inconvenient.


=== Origin ===

It might be that the `startx' script -- and possibly the
'Xwrapper.config' file -- were altered upstream, taking for granted
the presence of systemd.

The following patch changes these 2 files as needed, in order
for `startx' to work correctly and traditionally, without systemd.


------------------------------------------------------------------------
Vvv====P:A:T:C:H===F:O:L:L:O:W:S====**====T:H:I:S===S:I:D:E===U:P=======
========================================================================

devuan-startx-newtty patch by <dario@???> 12-Sep-2018

=== How to apply this patch ===

# cd / && patch -p1 < /path/to/devuan-startx-newtty.patch

There is no need to trim any text, before or within the patch itself:
the `patch' program knows what to skip.


=== Part 1 ===

A conditional is added to `startx' to check for the presence of systemd.
If the conditional fails, the nested block will not be executed.
On Devuan, that amounts to removing the 5 lines now encased
in the conditional.

Those lines were responsible for passing `xinit' (and in turn `Xorg')
a 'vt' option followed by the current tty number. We must avoid that,
if we want a new tty.

The added conditional was copied from another systemd-less distro
(VoidLinux, possibly it got there from somewhere upstream).
I also comment out a '-keeptty' option that was in the Devuan version
(but those lines are no longer being executed anyway).


--- /usr/bin/startx.orig        2015-10-19 03:54:32.000000000 +0200
+++ /usr/bin/startx             2018-09-11 21:18:14.812510159 +0200
@@ -104,10 +104,12 @@
     # When starting the defaultserver start X on the current tty to avoid
     # the startx session being seen as inactive:
     # "https://bugzilla.redhat.com/show_bug.cgi?id=806491"
-    tty=$(tty)
-    if expr match "$tty" '^/dev/tty[0-9]\+$' > /dev/null; then
-        tty_num=$(echo "$tty" | grep -oE '[0-9]+$')
-        vtarg="vt$tty_num -keeptty"
+    if [ -x /usr/lib/systemd/systemd -o -x /lib/systemd/systemd ]; then
+        tty=$(tty)
+        if expr match "$tty" '^/dev/tty[0-9]\+$' > /dev/null; then
+        tty_num=$(echo "$tty" | grep -oE '[0-9]+$')
+        vtarg="vt$tty_num" # -keeptty"
+        fi
     fi



=== Part 2 ===

The Devuan 'Xwrapper.config' file wasn't setting the 'needs_root_rights'
variable. So, the patched `startx' would lack permission to allocate
the first available tty, and it would fail - except when issued by root.


--- /etc/X11/Xwrapper.config.orig    2018-09-09 07:46:44.216064832 +0200
+++ /etc/X11/Xwrapper.config         2018-09-11 22:38:43.086092849 +0200
@@ -13,3 +13,4 @@
 # again, run the following command as root:
 #   dpkg-reconfigure xserver-xorg-legacy
 allowed_users=console
+needs_root_rights = yes

==================================================END==OF==PATCH=*=*=***

-- 
Dario Niedermann.                 Also on the Internet at:


gopher://darioniedermann.it/ <> https://www.darioniedermann.it/