You are not logged in.

#1 2016-11-25 16:45:26

rearden
Member
Registered: 2016-08-24
Posts: 10

[SOLVED] Require login before X session

I was wondering if there is a way to require a login before the system initiates the X windows session?  Either textual or graphical is fine with me.  Do I have to install SLiM or something?  I'm using the Open-RC version of AB, but fully updated otherwise.

Last edited by rearden (2016-11-27 17:40:46)

Offline

#2 2016-11-25 18:11:44

oliver
Administrator
Registered: 2010-11-04
Posts: 2,209

Re: [SOLVED] Require login before X session

Easiest way, IMO, is to remove any kind of login manager so you're presented with a regular text based login when booting up.  Then add the following to your .bashrc

[[ -z $DISPLAY && $XDG_VTNR -eq 1 ]] && exec startx

You may have to adjust the VTNR number if OpenRC doesn't default to tty1 (but I think it does)

Obviously, X will only work with your login (but you could add it to /etc/profile.d/whatever.sh and I don't see why it wouldn't work for all)

Offline

#3 2016-11-26 01:17:19

eric
Member
Registered: 2015-07-10
Posts: 240
Website

Re: [SOLVED] Require login before X session

a tricks :

[[ -z $DISPLAY && $XDG_VTNR -le 3 ]] && exec startx

with this, you can log on from the first 3 tty. if you change the number 3 by 10, you can log on from the ten first tty and so on


Obarun : free to control your system

Offline

#4 2016-11-26 01:30:51

rearden
Member
Registered: 2016-08-24
Posts: 10

Re: [SOLVED] Require login before X session

Ok, I'd like to give those a shot, but I'm honestly not even sure how to disable the the graphical environment startup.  I commented out the line in my ~/.xinitrc that starts openbox, however, when I do that, the system flashes through respawning the TTY too man times until it eventually disables TTY7 and stops.  I also don't see any of the processes in update-rc that should start X.  What's the proper place to disable starting up X in Archbang with OpenRC?

Offline

#5 2016-11-26 07:54:06

oliver
Administrator
Registered: 2010-11-04
Posts: 2,209

Re: [SOLVED] Require login before X session

eric wrote:

a tricks :

[[ -z $DISPLAY && $XDG_VTNR -le 3 ]] && exec startx

with this, you can log on from the first 3 tty. if you change the number 3 by 10, you can log on from the ten first tty and so on

Nice - much better.  Thanks!

rearden - I'm not sure if mrgreen is doing some magic behind the scenes but it's probably being automatically logged in via /etc/inittab

Edit that file (as root) and look for the TERMINALS section.  One entry will be modified (with the original hashed out) - you'll need to flip that (so the line with the username gets hashed out and the original line that matches the others is restored)
Once you've edited (and if you're unsure, make a copy) reboot.  The bash profile entries might already be there depending on how you set the account up.  It should at least stop the automatic login.

Technically, you don't need to reboot, you could just drop to runlevel2 and then back up to runlevel3 but you probably want to test it properly.

Word of warning - messing up inittab can render the O/S unusable without an alternate way to boot up and mount the hard drive... nothing that can't be recovered but bear it in mind.

Offline

#6 2016-11-26 08:57:44

Mr Green
Administrator
Registered: 2010-11-07
Posts: 6,920

Re: [SOLVED] Require login before X session

Openrc version is slightly different to systemd....

Inittab is set to autologin for given user and then starts X (.bash_profile)

# TERMINALS
c1:12345:respawn:/usr/bin/agetty 38400 tty1 linux
c2:2345:respawn:/usr/bin/agetty 38400 tty2 linux
c3:2345:respawn:/usr/bin/agetty 38400 tty3 linux
c4:2345:respawn:/usr/bin/agetty 38400 tty4 linux
c5:2345:respawn:/usr/bin/agetty 38400 tty5 linux
#c6:2345:respawn:/usr/bin/agetty 38400 tty6 linux
c6:2345:respawn:/usr/bin/agetty -a mrgreen -8 -s 38400 tty6 linux

.bash_profile you need to comment out lines I have marked with '<---' that will autologin but to a command prompt.

[mrgreen@arch ~]$ more .bash_profile 
# System settings before starting X
#. $HOME/.bashrc

PATH=$PATH:$HOME/bin

# set up alsa
#/usr/bin/amixer sset Master Mono 90% unmute  &> /dev/null
#/usr/bin/amixer sset Master 90% unmute  &> /dev/null
#/usr/bin/amixer sset PCM 90% unmute &> /dev/null


#[[ -z $DISPLAY && $XDG_VTNR -eq 1 ]] && exec startx

[[ -f ~/.bashrc ]] && . ~/.bashrc

# start x on login
if [[ -z $DISPLAY && ! -e /tmp/.X11-unix/X0 ]]; then <---
  exec xinit -- /usr/bin/X -nolisten tcp vt7 <---
fi <--

No magic involved wink


Comments, suggestions please feel free to contact me mrgreen(at)archbang(dot)org

Offline

#7 2016-11-27 17:38:17

rearden
Member
Registered: 2016-08-24
Posts: 10

Re: [SOLVED] Require login before X session

Thanks for the help guys.  I ended up just editing inittab to stop the autologin and leaving .bash_profile alone.  Now I have to log in with a password before the X session continues.  I don't mind having it start automatically once I log in.

Offline

#8 2016-11-28 00:57:16

Mr Green
Administrator
Registered: 2010-11-07
Posts: 6,920

Re: [SOLVED] Require login before X session

Not checked but I am sure it would not be difficult to add a log in manager (such as lxdm).


Comments, suggestions please feel free to contact me mrgreen(at)archbang(dot)org

Offline

#9 2016-11-28 23:04:55

rearden
Member
Registered: 2016-08-24
Posts: 10

Re: [SOLVED] Require login before X session

Mr Green, probably, but I like to keep it as simple as possible, so I'm fine with it this way.  I just wanted to require a login is all.

Offline

#10 2016-11-29 01:25:16

Mr Green
Administrator
Registered: 2010-11-07
Posts: 6,920

Re: [SOLVED] Require login before X session

Maybe change /etc/issue to make it a little more friendly when you log in...

https://www.cyberciti.biz/faq/howto-cha … n-message/

Post login

https://en.wikipedia.org/wiki/Motd_(Unix)


Comments, suggestions please feel free to contact me mrgreen(at)archbang(dot)org

Offline

Board footer

Powered by FluxBB