You are not logged in.

#1 2022-05-06 04:31:25

thinkanish
Member
Registered: 2012-08-12
Posts: 39

[RESOLVED] Return to tty after exiting dwm

Hello,

I am running dwm as window manager.
I usually execute dwm through .xinitrc and start x manually by giving the command "startx".

However, I tried to startx automatically by adding the lines described in archwiki to ~/.bash_profile and it works fine (as soon as login id and password is given, dwm is launched)

But when I quit dwm (using alt+shift+q), it does not return to tty as before (before configuring X to start automatically), instead it goes back to the login prompt.
How can I make it to return to the terminal (tty) after exiting dwm?

Thanks,

Last edited by thinkanish (2022-05-16 15:42:51)

Offline

#2 2022-05-06 05:03:33

jasonwryan
Anarchist
From: .nz
Registered: 2009-05-09
Posts: 30,426
Website

Re: [RESOLVED] Return to tty after exiting dwm

That's a security hole; are you sure you are comfortable with that? If so, see: https://wiki.archlinux.org/title/Getty# … al_console


Arch + dwm   •   Mercurial repos  •   Surfraw

Registered Linux User #482438

Offline

#3 2022-05-06 07:07:24

thinkanish
Member
Registered: 2012-08-12
Posts: 39

Re: [RESOLVED] Return to tty after exiting dwm

Hi,
Thanks for your reply.
Can you please explain how it is a security hole?

Because, usually, when I use startx to start dwm, when I quit dwm using shift+alt+q, it returns to the tty.
How is this different? I mean I just only automated the first part (startx)

Offline

#4 2022-05-06 07:12:15

jasonwryan
Anarchist
From: .nz
Registered: 2009-05-09
Posts: 30,426
Website

Re: [RESOLVED] Return to tty after exiting dwm

It means if X crashes (or is killed), you have an authenticated prompt. That may be fine; I don't know what your risk profile looks like, but for me that is a no-go.


Arch + dwm   •   Mercurial repos  •   Surfraw

Registered Linux User #482438

Offline

#5 2022-05-06 07:20:19

seth
Member
From: Won't reply 2 private help req
Registered: 2012-09-03
Posts: 76,654

Re: [RESOLVED] Return to tty after exiting dwm

The difference is that you probably now "exec startx" which replaces the login shell - so you can't return to it.

If you don't, you do not even have to killcrash or zap X11, you can just ctrl+alt+f1 yourself from a  locked X11 session into an open shell, so make sure to at least re-use the VT, https://wiki.archlinux.org/title/Xinit#xserverrc

Offline

#6 2022-05-06 07:55:47

thinkanish
Member
Registered: 2012-08-12
Posts: 39

Re: [RESOLVED] Return to tty after exiting dwm

Hi Seth,

It makes a bit of sense now. Yes. In the .bash_profile I added "exec startx"

But when normally starting X, we just run "startx" - so in this case, the login shell is not replaced? the login shell is treated as a parent and the X window is spawned from it?

Offline

#7 2022-05-06 07:57:13

seth
Member
From: Won't reply 2 private help req
Registered: 2012-09-03
Posts: 76,654

Offline

#8 2022-05-06 08:17:18

thinkanish
Member
Registered: 2012-08-12
Posts: 39

Re: [RESOLVED] Return to tty after exiting dwm

Thanks.

If command is specified, exec shall not return to the shell; 
rather, the exit status of the process shall be the exit status of the program implementing command, which overlaid the shell.

That explain it pretty well.

thanks again guys for your time and comments.

Offline

#9 2022-05-16 04:58:46

thinkanish
Member
Registered: 2012-08-12
Posts: 39

Re: [RESOLVED] Return to tty after exiting dwm

Hello,

After trying different commands, I have few more doubts :
When I use exec command in .bash_profile as,

exec startx

dwm automatically starts after the login (since dwm is started in .xinitrc). And when I quit from dwm using (ctrl+alt+q), it comes back to login screen (logs out the user).
But when i just use the command

startx

in .bash_profile, then it starts dwm and upon using (ctrl+alt+q), it returns to the tty (which is logged in to current user).
I understand that this is due to the exec command used as mentioned by seth.

My question is,
In what way the second method, using startx without "exec" is dangerous? (as Jason mentioned that there is a security hole)

Thanks.

Offline

#10 2022-05-16 05:11:05

seth
Member
From: Won't reply 2 private help req
Registered: 2012-09-03
Posts: 76,654

Re: [RESOLVED] Return to tty after exiting dwm

seth wrote:

If you don't, you do not even have to killcrash or zap X11, you can just ctrl+alt+f1 yourself from a  locked X11 session into an open shell, so make sure to at least re-use the VT, https://wiki.archlinux.org/title/Xinit#xserverrc

Offline

#11 2022-05-16 06:56:02

thinkanish
Member
Registered: 2012-08-12
Posts: 39

Re: [RESOLVED] Return to tty after exiting dwm

Okay. So, if I understand properly, If I don't use exec, then even when the display is locked, another tty can be used to login to the screen.

Now, If I use exec, it replaces the tty and jumps to the WM and when I quit the WM, it comes back to the login shell - here I have a problem of not able to shutdown the machine. So, I should use some method from inside the WM itself to shutdown the machine is it?
Like running the shutdown terminal inside a terminal inside the WM? Or is there another way to shutdown the system?

Offline

#12 2022-05-16 11:49:54

seth
Member
From: Won't reply 2 private help req
Registered: 2012-09-03
Posts: 76,654

Re: [RESOLVED] Return to tty after exiting dwm

If I don't use exec, then even when the display is locked, another tty can be used to login to the screen.

No. That's always the case and not a threat.
Edit: the point is the risk that there is an open shell already that is then accessible despite the GUI session being locked.

If I use exec, it replaces the tty and jumps to the WM and when I quit the WM, it comes back to the login shell

Yes.

here I have a problem of not able to shutdown the machine

What? Your xinitrc is likely broken, see the notes in the last link below.
You can shutdown directly from the GUI session, terminating that just to get to a console login just to be able to shutdown is madness.

I should use some method from inside the WM itself to shutdown the machine is it?

Yes.

Or is there another way to shutdown the system?

"systemctl poweroff" or "systemctl reboot"
In a properly setup (active) session, you can run that from any terminal or a shortcut or a fancy panel button or a context menu entry.

Last edited by seth (2022-05-16 11:50:44)

Offline

#13 2022-05-16 15:43:14

thinkanish
Member
Registered: 2012-08-12
Posts: 39

Re: [RESOLVED] Return to tty after exiting dwm

Thanks much for your inputs!
I understand it better now.

Offline

Board footer

Powered by FluxBB