Contents of /trunk/util-linux/patches/util-linux-2.11z-agetty-domainname-option.patch
Parent Directory | Revision Log
Revision 153 -
(show annotations)
(download)
Tue May 8 20:52:56 2007 UTC (17 years, 4 months ago) by niro
File size: 1810 byte(s)
Tue May 8 20:52:56 2007 UTC (17 years, 4 months ago) by niro
File size: 1810 byte(s)
-import
1 | --- util-linux-2.11z/login-utils/agetty.c 2002-07-29 09:36:42.000000000 +0200 |
2 | +++ util-linux-2.11z.O/login-utils/agetty-with-dns.c 2003-07-13 04:24:01.000000000 +0200 |
3 | @@ -30,6 +30,7 @@ |
4 | #include <getopt.h> |
5 | #include <time.h> |
6 | #include <sys/file.h> |
7 | +#include <netdb.h> |
8 | #include "xstrncpy.h" |
9 | #include "nls.h" |
10 | |
11 | @@ -122,6 +123,17 @@ |
12 | #define BUFSIZ 1024 |
13 | #endif |
14 | |
15 | +/* set a maximum length for the hostname, */ |
16 | +#ifdef HOST_NAME_MAX |
17 | + /* defined by POSIX */ |
18 | + #define HOSTNAME_LENGTH HOST_NAME_MAX |
19 | +#elif defined(MAXHOSTNAMELEN) |
20 | + /* implemented in current Unix-versions */ |
21 | + #define HOSTNAME_LENGTH MAXHOSTNAMELEN |
22 | +#else |
23 | + #define HOSTNAME_LENGTH 500 |
24 | +#endif |
25 | + |
26 | /* |
27 | * When multiple baud rates are specified on the command line, the first one |
28 | * we will try is the first one specified. |
29 | @@ -878,7 +890,25 @@ |
30 | printf ("%s", domainname); |
31 | } |
32 | break; |
33 | - |
34 | + |
35 | + case 'O': |
36 | + { |
37 | + char *domain = NULL; |
38 | + char host[HOSTNAME_LENGTH + 1]; |
39 | + struct hostent *hp = NULL; |
40 | + |
41 | + if (gethostname(host, HOSTNAME_LENGTH) || !(hp = gethostbyname(host))) { |
42 | + domain = " unknown_domain"; |
43 | + } else { |
44 | + /* get the substring after the first . */ |
45 | + domain = strchr(hp->h_name, '.'); |
46 | + if (domain == NULL) |
47 | + domain = ".(none)"; |
48 | + } |
49 | + printf("%s", ++domain); |
50 | + } |
51 | + break; |
52 | + |
53 | case 'd': |
54 | case 't': |
55 | { |
56 | --- util-linux-2.11z/login-utils/agetty.8 1999-11-03 00:28:11.000000000 +0100 |
57 | +++ util-linux-2.11z.O/login-utils/agetty-with-dns.8 2003-07-13 04:27:17.000000000 +0200 |
58 | @@ -217,7 +217,10 @@ |
59 | Insert the nodename of the machine, also known as the hostname. |
60 | .TP |
61 | o |
62 | -Insert the domainname of the machine. |
63 | +Insert the NIS domainname of the machine. |
64 | +.TP |
65 | +O |
66 | +Insert the DNS domainname of the machine. |
67 | .TP |
68 | r |
69 | Insert the release number of the OS, eg. 1.1.9. |