How do I setup OpenBSD to login automatically and lauch minicom?

View: New views
5 Messages — Rating Filter:   Alert me  

How do I setup OpenBSD to login automatically and lauch minicom?

by Theodore Wynnychenko :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hello

I am trying to figure out how to modify the boot process to automatically
spawn a minicom session. (I know I have many other options for what I am
trying to do, but I thaught this would be a good way to learn someghing
about OpenBSD.)
Basically, I have an old laptop, and (partially as a way to learn something
about OpenBSD) I want to set it up as a serial console to use with other
systems.  Thus, I am not at all concerned about the security of the login
process (this laptop, once configured) will not connect to a network, and
will have (pretty much) all services disabled.  I was also going to convert
the filesystems to read-only, so, a hard shutdown won't disrupt the
filesystems.
In any case, here is my question(s).  I have been reading the man pages, and
(in summary) I see that that boot loads the kernel (bsd), pass control to
init which parses through rc, and then spawns the process getty (as defined
by ttys).  This results in the login prompt, which, when a username is
entered, calls login which authenticates (using login_passwd), and then sets
several enviormental variables, before spawning a shell.  I think this is
right?
So, I think the place for me to modify this process is by changing the
variable to execute getty in /etc/ttys to instead launch minicom?   I tried
this, but (i guess, obviously) it did not work.
I assume that I have to set enviormental variables before minicom is
started?  Do I need getty and login to spawn a shell before starting
minicom?  If I need to go through getty and login, is there a way to
automatically login without password (or any other authentication)?  Would a
simple script that sets the enviornemt variables and runs minicom work?
I noticed a statement in one of the entries on this mailing list that
indicated there was a way to do something like this (login automatically /
start a program automatically on login), and that this information was in
the FAQ's, however, I can't seem to find it.
Any help would be really appreciated.
thanks


Re: How do I setup OpenBSD to login automatically and lauch minicom?

by David Schulz-5 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi,

i would want to do something similar, but have not found the best way to
have a user autologin to a certain console.

What i did was i added a user "autologin" with some password. Then i
added "su autologin" to /etc/rc.local. That takes care of logging the
user in. Then i added my actions ( i wanted to start vmstat) to the
.login file. Im sure i will get scolded, but this way does login a user
and executes the program i wanted automatically at boot. I guess the
proper way to login a user would be to change stuff in /etc/ttys and
gettytab , but i didnt know how to do it and didnt have time to investigate.

Bye,
David

Theodore Wynnychenko wrote:

> Hello
>
> I am trying to figure out how to modify the boot process to automatically
> spawn a minicom session. (I know I have many other options for what I am
> trying to do, but I thaught this would be a good way to learn someghing
> about OpenBSD.)
> Basically, I have an old laptop, and (partially as a way to learn something
> about OpenBSD) I want to set it up as a serial console to use with other
> systems.  Thus, I am not at all concerned about the security of the login
> process (this laptop, once configured) will not connect to a network, and
> will have (pretty much) all services disabled.  I was also going to convert
> the filesystems to read-only, so, a hard shutdown won't disrupt the
> filesystems.
> In any case, here is my question(s).  I have been reading the man pages, and
> (in summary) I see that that boot loads the kernel (bsd), pass control to
> init which parses through rc, and then spawns the process getty (as defined
> by ttys).  This results in the login prompt, which, when a username is
> entered, calls login which authenticates (using login_passwd), and then sets
> several enviormental variables, before spawning a shell.  I think this is
> right?
> So, I think the place for me to modify this process is by changing the
> variable to execute getty in /etc/ttys to instead launch minicom?   I tried
> this, but (i guess, obviously) it did not work.
> I assume that I have to set enviormental variables before minicom is
> started?  Do I need getty and login to spawn a shell before starting
> minicom?  If I need to go through getty and login, is there a way to
> automatically login without password (or any other authentication)?  Would a
> simple script that sets the enviornemt variables and runs minicom work?
> I noticed a statement in one of the entries on this mailing list that
> indicated there was a way to do something like this (login automatically /
> start a program automatically on login), and that this information was in
> the FAQ's, however, I can't seem to find it.
> Any help would be really appreciated.
> thanks
>
>
> !DSPAM:485f113a205001296011478!


Re: How do I setup OpenBSD to login automatically and lauch minicom?

by Stuart Henderson :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On 2008-06-23, Theodore Wynnychenko <t-wynnychenko@...> wrote:
> So, I think the place for me to modify this process is by changing the
> variable to execute getty in /etc/ttys to instead launch minicom?   I tried
> this, but (i guess, obviously) it did not work.

getty takes care of setting up the terminal on the port that
init(8) gives it on the command line. If you want to run other
software you'll need to do that yourself. And as you assume,
you must also set environment variables if your software
needs them.

Here's a simple example of a script that just displays systat
on a terminal that you could run in place of a getty:

#!/bin/sh
TERM=vt220 /usr/bin/sudo -u nobody /usr/bin/systat vmstat < /dev/$1 > /dev/$1

You can't do this straight in /etc/ttys since init(8) doesn't
pass the command to a shell, it exec()'s it directly. (If you run
this on ttyC0, note that it will hide syslog messages that would
be displayed there, so someone thinking of using it to obscure
the login prompt from casual users should consider the downside).

If you have problems, look at /var/log/authlog, if you see "getty
repeating too quickly" message, the program exited straight away
for some reason. In that case you might obtain clues by redirecting
stdout/stderr to a file and looking for error messages.


Re: How do I setup OpenBSD to login automatically and lauch minicom?

by cschaus :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Why not launch minicom inside a "screen" session from rc.local?  You can
run it as the user you want, if you don't want it running as root.

Cam

Theodore Wynnychenko wrote:

> Hello
>
> I am trying to figure out how to modify the boot process to automatically
> spawn a minicom session. (I know I have many other options for what I am
> trying to do, but I thaught this would be a good way to learn someghing
> about OpenBSD.)
> Basically, I have an old laptop, and (partially as a way to learn something
> about OpenBSD) I want to set it up as a serial console to use with other
> systems.  Thus, I am not at all concerned about the security of the login
> process (this laptop, once configured) will not connect to a network, and
> will have (pretty much) all services disabled.  I was also going to convert
> the filesystems to read-only, so, a hard shutdown won't disrupt the
> filesystems.
> In any case, here is my question(s).  I have been reading the man pages, and
> (in summary) I see that that boot loads the kernel (bsd), pass control to
> init which parses through rc, and then spawns the process getty (as defined
> by ttys).  This results in the login prompt, which, when a username is
> entered, calls login which authenticates (using login_passwd), and then sets
> several enviormental variables, before spawning a shell.  I think this is
> right?
> So, I think the place for me to modify this process is by changing the
> variable to execute getty in /etc/ttys to instead launch minicom?   I tried
> this, but (i guess, obviously) it did not work.
> I assume that I have to set enviormental variables before minicom is
> started?  Do I need getty and login to spawn a shell before starting
> minicom?  If I need to go through getty and login, is there a way to
> automatically login without password (or any other authentication)?  Would a
> simple script that sets the enviornemt variables and runs minicom work?
> I noticed a statement in one of the entries on this mailing list that
> indicated there was a way to do something like this (login automatically /
> start a program automatically on login), and that this information was in
> the FAQ's, however, I can't seem to find it.
> Any help would be really appreciated.
> thanks


Re: How do I setup OpenBSD to login automatically and lauch minicom?

by Theodore Wynnychenko :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

>Here's a simple example of a script that just displays systat
>on a terminal that you could run in place of a getty:

>#!/bin/sh
>TERM=vt220 /usr/bin/sudo -u nobody /usr/bin/systat vmstat < /dev/$1 >
/dev/$1
....
>If you have problems, look at /var/log/authlog, if you see "getty
>repeating too quickly" message, the program exited straight away
>for some reason. In that case you might obtain clues by redirecting
>stdout/stderr to a file and looking for error messages.


Hello
Thanks for the suggestions.
As it turns out, I have gotten this to work (almost perfectly).
I wrote a small script:

#!/bin/sh
TERM=vt220 /usr/local/bin/minicom < /dev/ttyC0 > /dev/ttyC0

that I point to in /etc/ttys for the terminal ttyC0.

Now, even though it works, I have two questions.
First, when I was trying to make this work, at first, I got no output, but
also, I did not get any errors (when I redirected errors to a file), and,
even thought the terminal was "blank," I saw a running minicom process on
the system.  Not until I specifically added the input and output redirection
to ttyCO did the minicom session appear and work.  (and it works just like I
would expect - if I try to exit minicom, it is immediately restarted).  But,
any idea why I had to specify the input/output explicitly to get this to
work?
Second, the system will not shut down cleanly with the minicom terminal
running.  If I try to shut the system down, it seems to "hang" at the
"syncing disks" stage.  Eventually, if I power the system off and on, the
root file system is not clean.  I notice that during the shutdown, the
minicom "terminal" dose get a signal 15, and starts to close, but seems to
hang at "Reseting modem."  However, when I ran minicom directly in a
"standard" shell, it would shut down fine. I have now made the filesystems
read-only, and now turn the system off but hitting the power button, but it
bothers me that all is not "perfect."  Any ideas why the minicom session
won't close cleanly when launched via /etc/ttys?

Thanks again for the help.  The above 2 questions are more for
understanding, rather than actual practical need.

bye - ted