autologin from console not working on FreeBSD-11.1p2

autologin from console not working on FreeBSD-11.1p2

Dear FBSD users,

I had a machine that did not want to boot up anymore. This morning my
friend which is a computer technician started it up for me and it is
working. I setup FreeBSD 11.1 on it and installed pkgs and xorg and
have it working. However, my autologin procedures which worked before
no longer work. I have a user olivares and configured /etc/gettytab
and /etc/ttyS

Re: autologin from console not working on FreeBSD-11.1p2

On Thu, 26 Oct 2017 14:22:27 -0500, Antonio Olivares wrote:
> I had a machine that did not want to boot up anymore. This morning my
> friend which is a computer technician started it up for me and it is
> working. I setup FreeBSD 11.1 on it and installed pkgs and xorg and
> have it working. However, my autologin procedures which worked before
> no longer work. I have a user olivares and configured /etc/gettytab
> and /etc/ttyS

I did quickly review a message to you regarding the same topic
(from 2011) and would like to quickly check a few things:

Where is this entry located in the gettytab? It needs to be placed
after the "Pc" entry and should "source" it, so "tc=Pc" should be
added. On the other hand, the options "ht:np:sp#115200" aren't needed
as you are not defining a (hardware) serial terminal, and the "Pc"
profile covers this anyway.

> and when i startup system instead of logging in automagically, it asks
> for password. I have .profile configured to automatically run startx.

This point isn't even reached if a password is being asked for.
If you are using ~/.profile, make sure you are using the shell
that matches this file, i. e., the default dialog shell C shell
won't care for this file, it requires ~/.login instead.

> How do i enable passwordless logins?
> I have another working machine but i have updated from 11.0-RELEASE to
> 11.1-RELEASE-p2

Check the "initial instructions" again. Allow me to provide a
full quote:

On Mon, 26 Sep 2011 19:07:47 -0500, Antonio Olivares wrote:
> I had it working (autologin on 8.2 amd64) on two machines, but I
> wanted to test out/install nvidia driver and I used sysinstall to
> install kernel source from 8.2 dvd and then many things I had working,
> like printer, scanner were erased. Shell changed back to /bin/sh, I
> was using bash. For some reason or another, it was not working. I
> did the same thing and now it works again :)

Your autologin configuration is a little bit different from
mine. I'll share and accomodate it to your particular use.

Step 1:

In /etc/gettytab,

autologin:\
:al=olivares:tc=Pc:

is to be placed _after_ the "default:" entry. This step defines
the "getty profile" for an automated login with the username
"olivares" as associated to the "al=" parameter. Also note
the "tc=" parameter which incorporates the default "Pc"
settings (that you can encounter in the next step's working
file).

Step 2:

In /etc/ttys, the line for ttyv0 is to be changed like this:

ttyv0 "/usr/libexec/getty autologin" cons25l1 on secure

This instructs the "getty" program to use the "autologin
profile" at system startup and automatically log in the
user "olivares" (see step 1).

Attention: Maybe you need a different console configuration;
"cons25" is the system's default. In Germany, I have to use
cons25l1 for the local magic. :-)

There should not be any problem if you have "xterm" there.
Maybe just some terminal capabilities don't work in text
mode, but there should be no effect on autologin functionality.

Make sure you _don't_ have a line calling xdm here - maybe this
causes conflicts.

Step 3:

In /home/olivares (or where $HOME is located for that user),
make ~/.login end in

[ ! -f /tmp/.X0-lock ] && startx

For bash, this would go to ~/.bash_login. Other shells may
have different startup files; see "man sh", "man csh",
"man bash" and "man <yourshell>" for details.

To become independent from the actual login shell, you can
write this command into a script that is executable by the
user, e. g. "chmod +x /opt/bin/autostartx"; if you have
/opt/bin in $PATH, you just need to call "autostartx" in
the correct startup file. Then _any_ shell startup script
could contain the call that script, like this:

#!/bin/sh
[ ! -f /tmp/.X0-lock ] && startx
exec $0

You can also make this script local to your user in ~/bin,
maybe you already have that in $PATH.

Attention: This _might_ get you into an "infinite loop" if
something is _really_ wrong. :-)

You can even modify the script to _restart_ X if it should
have crashed, so you don't fall back to the console in
case of a severe error (and enter "startx" again).

Step 4 (optional):

In order to combine the use of xdm (if you want to) and the
different system shells, for your user account there can be
some additional settings.

In ~/.xsession, put

#!/bin/csh
source ~/.cshrc
exec ~/.xinitrc

This file will be executed in case xdm is used. I am using the
C shell as a dialog shell here, so this makes sure my shell
settings get incorporated. Then control will be given to the
.xinitrc file, usually executed when you run "startx", but
xdm _may_ have a different opinion.

The first line (#!) is optional. I'm not fully sure if those
files have to be +x attributes (I _have_ those settings, no idea
where they came from and why they are still here). But it works,
so I don't question it. :-)

Step 5:

Profit. :-)

> In the beta 2 machine, the /dev/ttys has xterm instead of original
> cons25. Other than that, you are correct with the rest of the
> information. It was strange that someone/some folks have changed
> cons25 to xterm.

Surprises me too, but maybe the console driver now uses
this emulation for I/O... I'm not running 9-BETA here so
I cannot check, sorry.