|
@@ -1,28 +1,72 @@
|
|
1
|
+/*
|
|
2
|
+ * Copyright (C) 2010 Michael Brown <mbrown@fensystems.co.uk>.
|
|
3
|
+ *
|
|
4
|
+ * This program is free software; you can redistribute it and/or
|
|
5
|
+ * modify it under the terms of the GNU General Public License as
|
|
6
|
+ * published by the Free Software Foundation; either version 2 of the
|
|
7
|
+ * License, or any later version.
|
|
8
|
+ *
|
|
9
|
+ * This program is distributed in the hope that it will be useful, but
|
|
10
|
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
11
|
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
12
|
+ * General Public License for more details.
|
|
13
|
+ *
|
|
14
|
+ * You should have received a copy of the GNU General Public License
|
|
15
|
+ * along with this program; if not, write to the Free Software
|
|
16
|
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
|
17
|
+ */
|
|
18
|
+
|
1
|
19
|
#include <string.h>
|
2
|
20
|
#include <stdio.h>
|
3
|
21
|
#include <ipxe/command.h>
|
|
22
|
+#include <ipxe/parseopt.h>
|
4
|
23
|
#include <ipxe/login_ui.h>
|
5
|
24
|
|
6
|
25
|
FILE_LICENCE ( GPL2_OR_LATER );
|
7
|
26
|
|
|
27
|
+/** @file
|
|
28
|
+ *
|
|
29
|
+ * Login commands
|
|
30
|
+ *
|
|
31
|
+ */
|
|
32
|
+
|
|
33
|
+/** "login" options */
|
|
34
|
+struct login_options {};
|
|
35
|
+
|
|
36
|
+/** "login" option list */
|
|
37
|
+static struct option_descriptor login_opts[] = {};
|
|
38
|
+
|
|
39
|
+/** "login" command descriptor */
|
|
40
|
+static struct command_descriptor login_cmd =
|
|
41
|
+ COMMAND_DESC ( struct login_options, login_opts, 0, 0,
|
|
42
|
+ "", "Prompt for login credentials" );
|
|
43
|
+
|
|
44
|
+/**
|
|
45
|
+ * "login" command
|
|
46
|
+ *
|
|
47
|
+ * @v argc Argument count
|
|
48
|
+ * @v argv Argument list
|
|
49
|
+ * @ret rc Return status code
|
|
50
|
+ */
|
8
|
51
|
static int login_exec ( int argc, char **argv ) {
|
|
52
|
+ struct login_options opts;
|
9
|
53
|
int rc;
|
10
|
54
|
|
11
|
|
- if ( argc > 1 ) {
|
12
|
|
- printf ( "Usage: %s\n"
|
13
|
|
- "Prompt for login credentials\n", argv[0] );
|
14
|
|
- return 1;
|
15
|
|
- }
|
|
55
|
+ /* Parse options */
|
|
56
|
+ if ( ( rc = parse_options ( argc, argv, &login_cmd, &opts ) ) != 0 )
|
|
57
|
+ return rc;
|
16
|
58
|
|
|
59
|
+ /* Show login UI */
|
17
|
60
|
if ( ( rc = login_ui() ) != 0 ) {
|
18
|
61
|
printf ( "Could not set credentials: %s\n",
|
19
|
62
|
strerror ( rc ) );
|
20
|
|
- return 1;
|
|
63
|
+ return rc;
|
21
|
64
|
}
|
22
|
65
|
|
23
|
66
|
return 0;
|
24
|
67
|
}
|
25
|
68
|
|
|
69
|
+/** Login commands */
|
26
|
70
|
struct command login_command __command = {
|
27
|
71
|
.name = "login",
|
28
|
72
|
.exec = login_exec,
|