linux-qubasis

linux oasis port as a qubes template

git clone https://9o.is/git/linux-qubasis.git

0001-allow-getty-login-without-password.patch

(2950B)


      1 From 7ac4a56cf048fc49820b567bef223103c2b34aeb Mon Sep 17 00:00:00 2001
      2 From: Jul <jul@qh.is>
      3 Date: Wed, 17 Sep 2025 17:25:07 +0800
      4 Subject: [PATCH 1/1] allow getty login without password
      5 
      6 ---
      7  getty.8 |  7 ++++++-
      8  getty.c | 11 +++++++++--
      9  login.1 |  3 +++
     10  login.c | 18 ++++++++++++------
     11  4 files changed, 30 insertions(+), 9 deletions(-)
     12 
     13 diff --git a/getty.8 b/getty.8
     14 index f2df064..4757216 100644
     15 --- a/getty.8
     16 +++ b/getty.8
     17 @@ -6,6 +6,7 @@
     18  .Nd suckless linux getty
     19  .Sh SYNOPSIS
     20  .Nm
     21 +.Op Fl a
     22  .Op Ar tty Op Ar term Op Ar cmd Op Ar args...
     23  .Sh DESCRIPTION
     24  .Nm
     25 @@ -18,5 +19,9 @@ with
     26  The hostname is printed in the login name prompt as well. The
     27  .Ar tty
     28  should be specified using an absolute path.
     29 +.Sh OPTIONS
     30 +.Bl -tag -width Ds
     31 +.It Fl a
     32 +Automatically log in user
     33  .Sh SEE ALSO
     34 -.Xr login 1
     35 \ No newline at end of file
     36 +.Xr login 1
     37 diff --git a/getty.c b/getty.c
     38 index cef5c4e..360134a 100644
     39 --- a/getty.c
     40 +++ b/getty.c
     41 @@ -21,7 +21,7 @@ static char *defaultterm = "linux";
     42  static void
     43  usage(void)
     44  {
     45 -	eprintf("usage: %s [tty] [term] [cmd] [args...]\n", argv0);
     46 +	eprintf("usage: %s [-a] [tty] [term] [cmd] [args...]\n", argv0);
     47  }
     48  
     49  int
     50 @@ -36,8 +36,12 @@ main(int argc, char *argv[])
     51  	unsigned int i = 0;
     52  	ssize_t n;
     53  	long pos;
     54 +	int aflag = 0;
     55  
     56  	ARGBEGIN {
     57 +	case 'a':
     58 +		aflag = 1;
     59 +		break;
     60  	default:
     61  		usage();
     62  	} ARGEND;
     63 @@ -136,5 +140,8 @@ main(int argc, char *argv[])
     64  		eprintf("login name cannot start with '-'\n");
     65  	if (logname[0] == '\0')
     66  		return 1;
     67 -	return execlp("/bin/login", "login", "-p", logname, NULL);
     68 +	if (aflag)
     69 +		return execlp("/bin/login", "login", "-p", "-a", logname, NULL);
     70 +	else
     71 +		return execlp("/bin/login", "login", "-p", logname, NULL);
     72  }
     73 diff --git a/login.1 b/login.1
     74 index 61cd2d4..89d8c6c 100644
     75 --- a/login.1
     76 +++ b/login.1
     77 @@ -7,6 +7,7 @@
     78  .Sh SYNOPSIS
     79  .Nm
     80  .Op Fl p
     81 +.Op Fl a
     82  .Ar username
     83  .Sh DESCRIPTION
     84  .Nm
     85 @@ -24,4 +25,6 @@ and the
     86  .Bl -tag -width Ds
     87  .It Fl p
     88  Preserve the environment.
     89 +.It Fl a
     90 +Automatically log in the specified user
     91  .El
     92 diff --git a/login.c b/login.c
     93 index 25a59e4..064ac4c 100644
     94 --- a/login.c
     95 +++ b/login.c
     96 @@ -64,7 +64,7 @@ dologin(struct passwd *pw, int preserve)
     97  static void
     98  usage(void)
     99  {
    100 -	eprintf("usage: %s [-p] username\n", argv0);
    101 +	eprintf("usage: %s [-pa] username\n", argv0);
    102  }
    103  
    104  int
    105 @@ -76,11 +76,15 @@ main(int argc, char *argv[])
    106  	uid_t uid;
    107  	gid_t gid;
    108  	int pflag = 0;
    109 +	int aflag = 0;
    110  
    111  	ARGBEGIN {
    112  	case 'p':
    113  		pflag = 1;
    114  		break;
    115 +	case 'a':
    116 +		aflag = 1;
    117 +		break;
    118  	default:
    119  		usage();
    120  	} ARGEND;
    121 @@ -107,11 +111,13 @@ main(int argc, char *argv[])
    122  	/* Flush pending input */
    123  	ioctl(0, TCFLSH, (void *)0);
    124  
    125 -	pass = getpass("Password: ");
    126 -	if (!pass)
    127 -		eprintf("getpass:");
    128 -	if (pw_check(pw, pass) <= 0)
    129 -		exit(1);
    130 +	if (!aflag) {
    131 +		pass = getpass("Password: ");
    132 +		if (!pass)
    133 +			eprintf("getpass:");
    134 +		if (pw_check(pw, pass) <= 0)
    135 +			exit(1);
    136 +	}
    137  
    138  	tty = ttyname(0);
    139  	if (!tty)
    140 -- 
    141 2.50.1
    142