[arch-commits] Commit in util-linux/trunk (2 files)

Christian Hesse eworm at gemini.archlinux.org
Thu Jan 6 11:12:57 UTC 2022


    Date: Thursday, January 6, 2022 @ 11:12:57
  Author: eworm
Revision: 433485

upgpkg: util-linux 2.37.2-5: agetty: resolve tty name

Added:
  util-linux/trunk/0001-agetty-resolve-tty-name-even-if-stdin-is-specified.patch
Modified:
  util-linux/trunk/PKGBUILD

---------------------------------------------------------------+
 0001-agetty-resolve-tty-name-even-if-stdin-is-specified.patch |  104 ++++++++++
 PKGBUILD                                                      |   10 
 2 files changed, 113 insertions(+), 1 deletion(-)

Added: 0001-agetty-resolve-tty-name-even-if-stdin-is-specified.patch
===================================================================
--- 0001-agetty-resolve-tty-name-even-if-stdin-is-specified.patch	                        (rev 0)
+++ 0001-agetty-resolve-tty-name-even-if-stdin-is-specified.patch	2022-01-06 11:12:57 UTC (rev 433485)
@@ -0,0 +1,104 @@
+From 47831cc02ac0d71c335caecef1753f4c8861277c Mon Sep 17 00:00:00 2001
+From: tamz <totemz at protonmail.com>
+Date: Thu, 6 Jan 2022 11:56:58 +0100
+Subject: [PATCH 1/1] agetty: resolve tty name even if stdin is specified
+
+[kzak at redhat.com: - use "const" for options->tty (and friends)
+                    as expected by get_terminal_name()]
+
+Addresses: https://github.com/util-linux/util-linux/issues/1546
+Signed-off-by: tamz <totemz at protonmail.com>
+Signed-off-by: Karel Zak <kzak at redhat.com>
+---
+ term-utils/agetty.c | 26 ++++++++++++++++++--------
+ 1 file changed, 18 insertions(+), 8 deletions(-)
+
+diff --git a/term-utils/agetty.c b/term-utils/agetty.c
+index 55d373461..22850786d 100644
+--- a/term-utils/agetty.c
++++ b/term-utils/agetty.c
+@@ -190,8 +190,8 @@ struct options {
+ 	char *chroot;			/* Chroot before the login */
+ 	char *login;			/* login program */
+ 	char *logopt;			/* options for login program */
+-	char *tty;			/* name of tty */
+-	char *vcline;			/* line of virtual console */
++	const char *tty;		/* name of tty */
++	const char *vcline;		/* line of virtual console */
+ 	char *term;			/* terminal type */
+ 	char *initstring;		/* modem init string */
+ 	char *issue;			/* alternative issue file or directory */
+@@ -203,6 +203,7 @@ struct options {
+ 	int numspeed;			/* number of baud rates to try */
+ 	int clocal;			/* CLOCAL_MODE_* */
+ 	int kbmode;			/* Keyboard mode if virtual console */
++	int tty_is_stdin;		/* is the tty the standard input stream */
+ 	speed_t speeds[MAX_SPEED];	/* baud rates to be tried */
+ };
+ 
+@@ -319,7 +320,7 @@ static void init_special_char(char* arg, struct options *op);
+ static void parse_args(int argc, char **argv, struct options *op);
+ static void parse_speeds(struct options *op, char *arg);
+ static void update_utmp(struct options *op);
+-static void open_tty(char *tty, struct termios *tp, struct options *op);
++static void open_tty(const char *tty, struct termios *tp, struct options *op);
+ static void termio_init(struct options *op, struct termios *tp);
+ static void reset_vc(const struct options *op, struct termios *tp, int canon);
+ static void auto_baud(struct termios *tp);
+@@ -922,6 +923,15 @@ static void parse_args(int argc, char **argv, struct options *op)
+ 		}
+ 	}
+ 
++	/* resolve the tty path in case it was provided as stdin */
++	if (strcmp(op->tty, "-") == 0) {
++		op->tty_is_stdin = 1;
++		int fd = get_terminal_name(NULL, &op->tty, NULL);
++		if (fd < 0) {
++			log_warn(_("could not get terminal name: %d"), fd);
++		}
++	}
++
+ 	/* On virtual console remember the line which is used for */
+ 	if (strncmp(op->tty, "tty", 3) == 0 &&
+ 	    strspn(op->tty + 3, "0123456789") == strlen(op->tty+3))
+@@ -962,8 +972,8 @@ static void update_utmp(struct options *op)
+ 	time_t t;
+ 	pid_t pid = getpid();
+ 	pid_t sid = getsid(0);
+-	char *vcline = op->vcline;
+-	char *line   = op->tty;
++	const char *vcline = op->vcline;
++	const char *line = op->tty;
+ 	struct utmpx *utp;
+ 
+ 	/*
+@@ -1002,7 +1012,7 @@ static void update_utmp(struct options *op)
+ 			str2memcpy(ut.ut_id, vcline, sizeof(ut.ut_id));
+ 		else {
+ 			size_t len = strlen(line);
+-			char * ptr;
++			const char * ptr;
+ 			if (len >= sizeof(ut.ut_id))
+ 				ptr = line + len - sizeof(ut.ut_id);
+ 			else
+@@ -1030,7 +1040,7 @@ static void update_utmp(struct options *op)
+ #endif				/* SYSV_STYLE */
+ 
+ /* Set up tty as stdin, stdout & stderr. */
+-static void open_tty(char *tty, struct termios *tp, struct options *op)
++static void open_tty(const char *tty, struct termios *tp, struct options *op)
+ {
+ 	const pid_t pid = getpid();
+ 	int closed = 0;
+@@ -1040,7 +1050,7 @@ static void open_tty(char *tty, struct termios *tp, struct options *op)
+ 
+ 	/* Set up new standard input, unless we are given an already opened port. */
+ 
+-	if (strcmp(tty, "-") != 0) {
++	if (!op->tty_is_stdin) {
+ 		char buf[PATH_MAX+1];
+ 		struct group *gr = NULL;
+ 		struct stat st;
+-- 
+2.34.1
+

Modified: PKGBUILD
===================================================================
--- PKGBUILD	2022-01-06 11:12:53 UTC (rev 433484)
+++ PKGBUILD	2022-01-06 11:12:57 UTC (rev 433485)
@@ -7,7 +7,7 @@
 _pkgmajor=2.37
 _realver=${_pkgmajor}.2
 pkgver=${_realver/-/}
-pkgrel=4
+pkgrel=5
 pkgdesc='Miscellaneous system utilities for Linux'
 url='https://github.com/karelzak/util-linux'
 arch=('x86_64')
@@ -16,6 +16,7 @@
 options=('strip')
 validpgpkeys=('B0C64D14301CC6EFAEDF60E4E4B71D5EEC39C284')  # Karel Zak
 source=("https://www.kernel.org/pub/linux/utils/util-linux/v${_pkgmajor}/${pkgbase}-${_realver}.tar."{xz,sign}
+        '0001-agetty-resolve-tty-name-even-if-stdin-is-specified.patch'
         pam-{login,common,runuser,su}
         'util-linux.sysusers'
         '60-rfkill.rules'
@@ -23,6 +24,7 @@
         'rfkill-block_.service')
 sha256sums=('6a0764c1aae7fb607ef8a6dd2c0f6c47d5e5fd27aa08820abaad9ec14e28e9d9'
             'SKIP'
+            '53395b7e434b32e6fee25f1b6fa59330ab72c1a2f99a17c3d3fd92473379fd9a'
             '99cd77f21ee44a0c5e57b0f3670f711a00496f198fc5704d7e44f5d817c81a0f'
             '57e057758944f4557762c6def939410c04ca5803cbdd2bfa2153ce47ffe7a4af'
             '48d6fba767631e3dd3620cf02a71a74c5d65a525d4c4ce4b5a0b7d9f41ebfea1'
@@ -32,6 +34,12 @@
             '8ccec10a22523f6b9d55e0d6cbf91905a39881446710aa083e935e8073323376'
             'a22e0a037e702170c7d88460cc9c9c2ab1d3e5c54a6985cd4a164ea7beff1b36')
 
+prepare() {
+  cd "${pkgbase}-${_realver}"
+
+  patch -Np1 < ../0001-agetty-resolve-tty-name-even-if-stdin-is-specified.patch
+}
+
 build() {
   cd "${pkgbase}-${_realver}"
 



More information about the arch-commits mailing list