summaryrefslogtreecommitdiffstats
path: root/source/a/shadow/shadow.login.display.short.hostname.diff
blob: 53a22f8b83a0c7b4f3b7312c54e8637dcc327c15 (about) (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
diff -u -r --new-file shadow-4.8.1.orig/libmisc/loginprompt.c shadow-4.8.1/libmisc/loginprompt.c
--- shadow-4.8.1.orig/libmisc/loginprompt.c	2019-07-23 10:26:08.000000000 -0500
+++ shadow-4.8.1/libmisc/loginprompt.c	2020-02-06 17:29:43.386954096 -0600
@@ -99,6 +99,15 @@
 			}
 		}
 		(void) gethostname (buf, sizeof buf);
+		/* Trim away everything after the first '.': */
+		i = 0;
+		while (buf[i] != '\0' && i < sizeof(buf) - 1) {
+			if (buf[i] == '.') {
+				buf[i] = '\0';
+				break;
+			}
+			i++;
+		}
 		printf (prompt, buf);
 		(void) fflush (stdout);
 	}
diff -u -r --new-file shadow-4.8.1.orig/src/login.c shadow-4.8.1/src/login.c
--- shadow-4.8.1.orig/src/login.c	2020-01-12 07:58:49.000000000 -0600
+++ shadow-4.8.1/src/login.c	2020-02-06 17:29:33.191954722 -0600
@@ -761,6 +761,15 @@
 
 		/* Make the login prompt look like we want it */
 		if (gethostname (hostn, sizeof (hostn)) == 0) {
+			/* Trim away everything after the first '.': */
+			int i = 0;
+			while (hostn[i] != '\0' && i < sizeof(hostn) - 1) {
+				if (hostn[i] == '.') {
+					hostn[i] = '\0';
+					break;
+				}
+				i++;
+			}
 			snprintf (loginprompt,
 			          sizeof (loginprompt),
 			          _("%s login: "), hostn);