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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
|
/* $NetBSD: menus.entropy,v 1.2 2021/10/08 15:59:55 martin Exp $ */
/*-
* Copyright (c) 2003 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by David Laight.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
/* Menu system definitions -- entropy setup */
/* arg is an int*, returning a magic value for the selected menu option */
menu not_enough_entropy, title MSG_not_enough_entropy, y=-1, no box, clear,
exit, exitstring MSG_continue_without_entropy;
option MSG_entropy_add_manually, exit,
action { *((int*)arg) = 1; };
option MSG_entropy_download_seed, exit,
action { *((int*)arg) = 2; };
option MSG_entropy_download_raw, exit,
action { *((int*)arg) = 3; };
option MSG_entropy_retry, exit,
action { *((int*)arg) = 4; };
/* arg is an int*, returning a magic value for the selected menu option */
menu entropy_select_file, title MSG_entropy_select_file, y=-5, box,
exit, exitstring MSG_cancel;
option MSG_entropy_add_download_http, exit,
action { *((int*)arg) = 1; };
option MSG_entropy_add_download_ftp, exit,
action { *((int*)arg) = 2; };
option MSG_entropy_add_nfs, exit,
action { *((int*)arg) = 3; };
option MSG_entropy_add_local, exit,
action { *((int*)arg) = 4; };
/* arg is an int*, set to SET_RETRY when the menu is aborted */
menu entropy_nfssource, y=-5, x=0, w=70, no box, no clear,
exitstring MSG_load_entropy;
option {src_legend(menu, MSG_Host, nfs_host);},
action { src_prompt(MSG_Host, nfs_host, sizeof nfs_host); };
option {src_legend(menu, MSG_Base_dir, nfs_dir);},
action { src_prompt(MSG_Base_dir, nfs_dir, sizeof nfs_dir); };
option {src_legend(menu, MSG_entropy_file, entropy_file);},
action { src_prompt(MSG_set_entropy_file, entropy_file, sizeof entropy_file); };
option MSG_cancel, exit,
action { *((int*)arg) = SET_RETRY; };
/* arg is an arg_rv*, pointing to a struct ftpinfo and a return value */
menu entropy_ftpsource, y=-4, x=0, w=70, no box, no clear,
exitstring MSG_download_entropy;
option {src_legend(menu, MSG_Host,
((struct ftpinfo*)((arg_rv*)arg)->arg)->xfer_host[
((struct ftpinfo*)((arg_rv*)arg)->arg)->xfer]);},
action { struct ftpinfo *fpi = (struct ftpinfo*)((arg_rv*)arg)->arg;
src_prompt(MSG_Host, fpi->xfer_host[fpi->xfer],
sizeof fpi->xfer_host[fpi->xfer]); };
option {src_legend(menu, MSG_entropy_path_and_file, entropy_file);},
action { src_prompt(MSG_entropy_path_and_file,
entropy_file, sizeof entropy_file); };
option {src_legend(menu, MSG_User,
((struct ftpinfo*)((arg_rv*)arg)->arg)->user);},
action { struct ftpinfo *fpi = (struct ftpinfo*)((arg_rv*)arg)->arg;
src_prompt(MSG_User, fpi->user, sizeof fpi->user);
fpi->pass[0] = 0;
};
option {src_legend(menu, MSG_Password,
strcmp(((struct ftpinfo*)((arg_rv*)arg)->arg)->user,
"ftp") == 0 ||
((struct ftpinfo*)((arg_rv*)arg)->arg)->pass[0] == 0
? ((struct ftpinfo*)((arg_rv*)arg)->arg)->pass
: msg_string(MSG_hidden));},
action { struct ftpinfo *fpi = (struct ftpinfo*)((arg_rv*)arg)->arg;
if (strcmp(fpi->user, "ftp") == 0)
src_prompt(MSG_email, fpi->pass, sizeof fpi->pass);
else {
msg_prompt_noecho(MSG_Password, "",
fpi->pass, sizeof fpi->pass);
}
};
option {src_legend(menu, MSG_Proxy,
((struct ftpinfo*)((arg_rv*)arg)->arg)->proxy);},
action { struct ftpinfo *fpi = (struct ftpinfo*)((arg_rv*)arg)->arg;
src_prompt(MSG_Proxy, fpi->proxy, sizeof fpi->proxy);
if (strcmp(fpi->proxy, "") == 0) {
unsetenv("ftp_proxy");
unsetenv("http_proxy");
} else {
setenv("ftp_proxy", fpi->proxy, 1);
setenv("http_proxy", fpi->proxy, 1);
}
};
option MSG_cancel, exit, action { ((arg_rv*)arg)->rv = SET_RETRY; };
/* arg is an int*, set to SET_RETRY when the menu is aborted */
menu entropy_localfs, y=-4, x=0, w=70, no box, no clear,
exitstring MSG_load_entropy;
display action { msg_display(MSG_entropy_localfs); };
option {src_legend(menu, MSG_Device, localfs_dev);},
action { src_prompt(MSG_dev, localfs_dev, sizeof localfs_dev);};
option {src_legend(menu, MSG_File_system, localfs_fs);},
action { src_prompt(MSG_filesys, localfs_fs, sizeof localfs_fs); };
option {src_legend(menu, MSG_entropy_path_and_file, entropy_file);},
action { src_prompt(MSG_entropy_path_and_file, entropy_file, sizeof entropy_file);};
option MSG_cancel, exit, action { *((int*)arg) = SET_RETRY; };
|