On Mon, Jul 06, 2026 at 11:50:46PM +0300, Veraellyunjie wrote:
> Hi folks
>
> I want OpenBSD to boot directly into an application, on tty,
> without Xenocara.
>
> I searched and found it is not supported,
> and the closest you can do is
> run your stuff directly from /etc/rc.local or /etc/ttys
im using the diff below to have my user automatically log on. i have
this in gettytab:
al.dlg:\
:sp#115200:ht:al=dlg
and then this in /etc/ttys on ttyC0:
ttyC0 "/usr/libexec/getty al.dlg" vt220 on secure
and then this in my .profile to start the thing i want to run on the
console:
TTY=$(tty)
if [[ "$TTY" = "/dev/ttyC0" ]]; then
cd trees/wslv
exec sh run
fi
it's supposed to work like "al" in freebsd getty. i havent shared this
diff before because it seemed like a very niche problem that only i had.
> But an application run the stated way is crippled in various ways.
>
> No better answer on the mailing list
> and on a couple of 3rd-party resources, over many years.
>
> So I asked an AI. This time a hallucinating machine
> seems to have fared better than humans.
>
> So here I present a perl script for your review. See attachment.
> It works on my amd64 7.9, both bare metal and VM.
>
> There actually are 2 scripts.
> The `autologin-tty-exec` is mostly what AI told me, with my adjustments.
> I don't completely understand this tty setup part,
> so please pay closer attention there.
>
> But that script requires you to edit /etc/ttys manually,
> which may be fine but is also error-prone,
> then I thought a setter would be nice.
>
> Thus, `autologin-tty` is born.
> It can help you with configuration: set, get, revert;
> and it does setting tty up and runs a custom command on boot.
> It also includes a usage message with examples,
> so just run it with --help to see how to use it.
>
> Again, `autologin-tty` is `autologin-tty-exec` plus helpers
> or vice versa: `autologin-tty-exec` is a bare-bones `autologin-tty`.
>
> Their exec part is compatible, in /etc/ttys you can
> replace a space with a dash and
> instead of running the bigger script exec subcommand,
> you run the smaller script:
> `autologin-tty exec`
> `autologin-tty-exec`
>
> Both scripts have a dependency, please install IO::Tty with one of:
> pkg_add p5-IO-Tty
> cpan IO::Tty
>
> I'd like to hear from you before publishing on CPAN, perhaps as
> App::OpenBSD::autologin-tty
> or I'm open to name suggestions.
>
> Script correction suggestions are welcome!
> Specifically, it seems to work in VM console, but it doesn't set baud
> speed as per /etc/gettytab so dunno about real COM port.
>
> Peace
Index: getty/gettytab.5
===================================================================
RCS file: /cvs/src/libexec/getty/gettytab.5,v
diff -u -p -r1.28 gettytab.5
--- getty/gettytab.5 27 May 2017 09:31:13 -0000 1.28
+++ getty/gettytab.5 7 Jul 2026 12:50:59 -0000
@@ -71,6 +71,7 @@ table.
.Bl -column "Name" "Type" "Default" "Description"
.It Sy Name Ta Sy Type Ta Sy Default Ta Sy Description
.It ap Ta bool Ta false Ta "Terminal uses any parity."
+.It al Ta str Ta unused Ta "Auto-login as user instead of prompting."
.It bk Ta str Ta 0377 Ta "Alternative end-of-line character (input break)."
.It c0 Ta num Ta unused Ta "TTY control flags to write messages."
.It c1 Ta num Ta unused Ta "TTY control flags to read login name."
Index: getty/gettytab.h
===================================================================
RCS file: /cvs/src/libexec/getty/gettytab.h,v
diff -u -p -r1.9 gettytab.h
--- getty/gettytab.h 19 May 2024 10:30:43 -0000 1.9
+++ getty/gettytab.h 7 Jul 2026 12:50:59 -0000
@@ -82,6 +82,7 @@ struct gettyflags {
#define FL gettystrs[21].value
#define WE gettystrs[22].value
#define LN gettystrs[23].value
+#define AL gettystrs[24].value
/*
* Numeric definitions.
Index: getty/init.c
===================================================================
RCS file: /cvs/src/libexec/getty/init.c,v
diff -u -p -r1.10 init.c
--- getty/init.c 6 Nov 2015 16:42:30 -0000 1.10
+++ getty/init.c 7 Jul 2026 12:50:59 -0000
@@ -66,6 +66,7 @@ struct gettystrs gettystrs[] = {
{ "fl", &tmode.c_cc[VDISCARD] },/* flush output */
{ "we", &tmode.c_cc[VWERASE] }, /* word erase */
{ "ln", &tmode.c_cc[VLNEXT] }, /* literal next */
+ { "al" }, /* user to auto-login */
{ 0 }
};
Index: getty/main.c
===================================================================
RCS file: /cvs/src/libexec/getty/main.c,v
diff -u -p -r1.56 main.c
--- getty/main.c 19 Jul 2024 15:28:51 -0000 1.56
+++ getty/main.c 7 Jul 2026 12:50:59 -0000
@@ -347,7 +347,8 @@ main(int argc, char *argv[])
limit.rlim_max = RLIM_INFINITY;
limit.rlim_cur = RLIM_INFINITY;
(void)setrlimit(RLIMIT_CPU, &limit);
- execle(LO, "login", "-p", "--", name, NULL, env);
+ execle(LO, "login", AL ? "-fp" : "-p",
+ "--", name, NULL, env);
syslog(LOG_ERR, "%s: %m", LO);
exit(1);
}
@@ -365,6 +366,28 @@ getname(void)
unsigned char cs;
int c, r;
char *np;
+
+ if (AL) { /* auto-login */
+ size_t l, i;
+
+ l = strlcpy(name, AL, sizeof(name));
+ if (l >= sizeof(name)) {
+ xputs("al username is too long");
+ return (0);
+ }
+
+ for (i = 0; i < l; i++) {
+ int ch = name[i];
+ if (isupper(ch))
+ upper = 1;
+ else if (islower(ch))
+ lower = 1;
+ else if (isdigit(ch))
+ digit++;
+ }
+
+ return (1);
+ }
/*
* Interrupt may happen if we use CBREAK mode