]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
agetty: pass hostname to login(1)
authorKarel Zak <kzak@redhat.com>
Fri, 5 Aug 2011 11:47:22 +0000 (13:47 +0200)
committerKarel Zak <kzak@redhat.com>
Wed, 26 Oct 2011 21:17:15 +0000 (23:17 +0200)
Signed-off-by: Karel Zak <kzak@redhat.com>
term-utils/agetty.8
term-utils/agetty.c

index c7fd172f4ac41596fdd45cc1996414b935ac7a23..ebfdb961b18734476d1192c3867917e3d9b0c8ff 100644 (file)
@@ -97,6 +97,10 @@ option is added to the login command line.
 Don't reset terminal cflags (control modes). See \fItermios(3)\fP for more
 details.
 .TP
+\-E, \-\-remote
+If \-H \fIfakehost\fP option is given then \-r \fIfakehost\fP options is
+added to the the \fB/bin/login\fP command line.
+.TP
 \-f, \-\-issue\-file \fIissue_file\fP
 Display the contents of \fIissue_file\fP instead of \fI/etc/issue\fP.
 This allows custom messages to be displayed on different terminals.
index 75c2b1453b9433aa07a1ee91578cd297b6207f90..041e1f7a6d04149cd8e1e2ab065bc7a5c9c82d96 100644 (file)
@@ -175,6 +175,7 @@ struct options {
 #define F_NOHOSTNAME   (1<<18) /* Do not show the hostname */
 #define F_LONGHNAME    (1<<19) /* Show Full qualified hostname */
 #define F_NOHINTS      (1<<20) /* Don't print hints */
+#define F_REMOTE       (1<<21) /* Add '-h fakehost' to login(1) command line */
 
 #define serial_tty_option(opt, flag)   \
        (((opt)->flags & (F_VCONSOLE|(flag))) == (flag))
@@ -420,12 +421,18 @@ int main(int argc, char **argv)
                 */
                login_options_to_argv(login_argv, &login_argc,
                                      options.logopt, username);
-       } else if (username) {
-               if (options.autolog)
-                       login_argv[login_argc++] = "-f";
-               else
-                       login_argv[login_argc++] = "--";
-               login_argv[login_argc++] = username;
+       } else {
+               if (fakehost && (options.flags & F_REMOTE)) {
+                       login_argv[login_argc++] = "-h";
+                       login_argv[login_argc++] = fakehost;
+               }
+               if (username) {
+                       if (options.autolog)
+                               login_argv[login_argc++] = "-f";
+                       else
+                               login_argv[login_argc++] = "--";
+                       login_argv[login_argc++] = username;
+               }
        }
 
        login_argv[login_argc] = NULL;  /* last login argv */
@@ -550,6 +557,7 @@ static void parse_args(int argc, char **argv, struct options *op)
                {  "noreset",        no_argument,        0,  'c'  },
                {  "chdir",          required_argument,  0,  'C'  },
                {  "delay",          required_argument,  0,  'd'  },
+               {  "remote",         no_argument,        0,  'E'  },
                {  "issue-file",     required_argument,  0,  'f'  },
                {  "flow-control",   no_argument,        0,  'h'  },
                {  "host",           required_argument,  0,  'H'  },
@@ -579,7 +587,7 @@ static void parse_args(int argc, char **argv, struct options *op)
        };
 
        while ((c = getopt_long(argc, argv,
-                          "8a:cC:d:f:hH:iI:Jl:LmnNo:pP:r:Rst:Uw", longopts,
+                          "8a:cC:d:Ef:hH:iI:Jl:LmnNo:pP:r:Rst:Uw", longopts,
                            NULL)) != -1) {
                switch (c) {
                case '8':
@@ -597,6 +605,9 @@ static void parse_args(int argc, char **argv, struct options *op)
                case 'd':
                        op->delay = atoi(optarg);
                        break;
+               case 'E':
+                       op->flags |= F_REMOTE;
+                       break;
                case 'f':
                        op->flags |= F_CUSTISSUE;
                        op->issue = optarg;