xref: /netbsd-src/usr.sbin/sysinst/menus.entropy (revision 0578ab99d9607e1ea255c8c0b331c407434b2155)
1*0578ab99Smartin/*	$NetBSD: menus.entropy,v 1.3 2023/12/17 18:46:42 martin Exp $	*/
2043e812bSmartin
3043e812bSmartin/*-
4043e812bSmartin * Copyright (c) 2003 The NetBSD Foundation, Inc.
5043e812bSmartin * All rights reserved.
6043e812bSmartin *
7043e812bSmartin * This code is derived from software contributed to The NetBSD Foundation
8043e812bSmartin * by David Laight.
9043e812bSmartin *
10043e812bSmartin * Redistribution and use in source and binary forms, with or without
11043e812bSmartin * modification, are permitted provided that the following conditions
12043e812bSmartin * are met:
13043e812bSmartin * 1. Redistributions of source code must retain the above copyright
14043e812bSmartin *    notice, this list of conditions and the following disclaimer.
15043e812bSmartin * 2. Redistributions in binary form must reproduce the above copyright
16043e812bSmartin *    notice, this list of conditions and the following disclaimer in the
17043e812bSmartin *    documentation and/or other materials provided with the distribution.
18043e812bSmartin *
19043e812bSmartin * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
20043e812bSmartin * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21043e812bSmartin * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22043e812bSmartin * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
23043e812bSmartin * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24043e812bSmartin * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25043e812bSmartin * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26043e812bSmartin * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27043e812bSmartin * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28043e812bSmartin * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29043e812bSmartin * POSSIBILITY OF SUCH DAMAGE.
30043e812bSmartin */
31043e812bSmartin
32043e812bSmartin/* Menu system definitions -- entropy setup */
33043e812bSmartin
34043e812bSmartin/* arg is an int*, returning a magic value for the selected menu option */
35043e812bSmartinmenu not_enough_entropy, title MSG_not_enough_entropy, y=-1, no box, clear,
3603af0822Smartin    exit, exitstring MSG_continue_without_entropy;
37043e812bSmartin	option MSG_entropy_add_manually, exit,
38043e812bSmartin	    action { *((int*)arg) = 1; };
39043e812bSmartin	option MSG_entropy_download_seed, exit,
40043e812bSmartin	    action { *((int*)arg) = 2; };
41043e812bSmartin	option MSG_entropy_download_raw, exit,
42043e812bSmartin	    action { *((int*)arg) = 3; };
43043e812bSmartin	option MSG_entropy_retry, exit,
44043e812bSmartin	    action { *((int*)arg) = 4; };
45043e812bSmartin
46043e812bSmartin
47043e812bSmartin/* arg is an int*, returning a magic value for the selected menu option */
48043e812bSmartinmenu entropy_select_file, title MSG_entropy_select_file, y=-5, box,
49043e812bSmartin    exit, exitstring MSG_cancel;
50043e812bSmartin	option MSG_entropy_add_download_http, exit,
51043e812bSmartin	    action { *((int*)arg) = 1; };
52043e812bSmartin	option MSG_entropy_add_download_ftp, exit,
53043e812bSmartin	    action { *((int*)arg) = 2; };
54043e812bSmartin	option MSG_entropy_add_nfs, exit,
55043e812bSmartin	    action { *((int*)arg) = 3; };
56043e812bSmartin	option MSG_entropy_add_local, exit,
57043e812bSmartin	    action { *((int*)arg) = 4; };
58043e812bSmartin
59043e812bSmartin
60043e812bSmartin/* arg is an int*, set to SET_RETRY when the menu is aborted */
61043e812bSmartinmenu entropy_nfssource, y=-5, x=0, w=70, no box, no clear,
62043e812bSmartin	    exitstring MSG_load_entropy;
63043e812bSmartin	option {src_legend(menu, MSG_Host, nfs_host);},
64043e812bSmartin		action { src_prompt(MSG_Host, nfs_host, sizeof nfs_host); };
65043e812bSmartin	option {src_legend(menu, MSG_Base_dir, nfs_dir);},
66043e812bSmartin		action { src_prompt(MSG_Base_dir, nfs_dir, sizeof nfs_dir); };
67043e812bSmartin	option {src_legend(menu, MSG_entropy_file, entropy_file);},
68043e812bSmartin		action { src_prompt(MSG_set_entropy_file, entropy_file, sizeof entropy_file); };
69043e812bSmartin	option MSG_cancel, exit,
70043e812bSmartin		action { *((int*)arg) = SET_RETRY; };
71043e812bSmartin
72043e812bSmartin
73043e812bSmartin/* arg is an arg_rv*, pointing to a struct ftpinfo and a return value */
74043e812bSmartinmenu entropy_ftpsource, y=-4, x=0, w=70, no box, no clear,
75043e812bSmartin	exitstring MSG_download_entropy;
76043e812bSmartin	option {src_legend(menu, MSG_Host,
77043e812bSmartin			((struct ftpinfo*)((arg_rv*)arg)->arg)->xfer_host[
78*0578ab99Smartin			XFER_HOST(((struct ftpinfo*)
79*0578ab99Smartin			((arg_rv*)arg)->arg)->xfer)]);},
80043e812bSmartin		action { struct ftpinfo *fpi = (struct ftpinfo*)((arg_rv*)arg)->arg;
81*0578ab99Smartin			src_prompt(MSG_Host,
82*0578ab99Smartin			fpi->xfer_host[XFER_HOST(fpi->xfer)],
83*0578ab99Smartin			sizeof fpi->xfer_host[XFER_HOST(fpi->xfer)]); };
84043e812bSmartin	option {src_legend(menu, MSG_entropy_path_and_file, entropy_file);},
85043e812bSmartin		action { src_prompt(MSG_entropy_path_and_file,
86043e812bSmartin			entropy_file, sizeof entropy_file); };
87043e812bSmartin	option {src_legend(menu, MSG_User,
88043e812bSmartin			((struct ftpinfo*)((arg_rv*)arg)->arg)->user);},
89043e812bSmartin		action { struct ftpinfo *fpi = (struct ftpinfo*)((arg_rv*)arg)->arg;
90043e812bSmartin			src_prompt(MSG_User, fpi->user, sizeof fpi->user);
91043e812bSmartin			fpi->pass[0] = 0;
92043e812bSmartin		};
93043e812bSmartin	option {src_legend(menu, MSG_Password,
94043e812bSmartin		    strcmp(((struct ftpinfo*)((arg_rv*)arg)->arg)->user,
95043e812bSmartin		        "ftp") == 0 ||
96043e812bSmartin			((struct ftpinfo*)((arg_rv*)arg)->arg)->pass[0] == 0
97043e812bSmartin			? ((struct ftpinfo*)((arg_rv*)arg)->arg)->pass
98043e812bSmartin			: msg_string(MSG_hidden));},
99043e812bSmartin		action { struct ftpinfo *fpi = (struct ftpinfo*)((arg_rv*)arg)->arg;
100043e812bSmartin			if (strcmp(fpi->user, "ftp") == 0)
101043e812bSmartin			src_prompt(MSG_email, fpi->pass, sizeof fpi->pass);
102043e812bSmartin		  else {
103043e812bSmartin			msg_prompt_noecho(MSG_Password, "",
104043e812bSmartin					fpi->pass, sizeof fpi->pass);
105043e812bSmartin		  }
106043e812bSmartin		};
107043e812bSmartin	option {src_legend(menu, MSG_Proxy,
108043e812bSmartin		    ((struct ftpinfo*)((arg_rv*)arg)->arg)->proxy);},
109043e812bSmartin		action { struct ftpinfo *fpi = (struct ftpinfo*)((arg_rv*)arg)->arg;
110043e812bSmartin			src_prompt(MSG_Proxy, fpi->proxy, sizeof fpi->proxy);
111043e812bSmartin			if (strcmp(fpi->proxy, "") == 0) {
112043e812bSmartin				unsetenv("ftp_proxy");
113043e812bSmartin				unsetenv("http_proxy");
114043e812bSmartin			} else {
115043e812bSmartin				setenv("ftp_proxy", fpi->proxy, 1);
116043e812bSmartin				setenv("http_proxy", fpi->proxy, 1);
117043e812bSmartin			}
118043e812bSmartin		};
119043e812bSmartin	option MSG_cancel, exit, action { ((arg_rv*)arg)->rv = SET_RETRY; };
120043e812bSmartin
121043e812bSmartin
122043e812bSmartin/* arg is an int*, set to SET_RETRY when the menu is aborted */
123043e812bSmartinmenu entropy_localfs, y=-4, x=0, w=70, no box, no clear,
124043e812bSmartin		 exitstring MSG_load_entropy;
125043e812bSmartin	display action { msg_display(MSG_entropy_localfs); };
126043e812bSmartin	option {src_legend(menu, MSG_Device, localfs_dev);},
127043e812bSmartin		action { src_prompt(MSG_dev, localfs_dev, sizeof localfs_dev);};
128043e812bSmartin	option {src_legend(menu, MSG_File_system, localfs_fs);},
129043e812bSmartin		action { src_prompt(MSG_filesys, localfs_fs, sizeof localfs_fs); };
130043e812bSmartin	option {src_legend(menu, MSG_entropy_path_and_file, entropy_file);},
131043e812bSmartin		action { src_prompt(MSG_entropy_path_and_file, entropy_file, sizeof entropy_file);};
132043e812bSmartin	option MSG_cancel, exit, action { *((int*)arg) = SET_RETRY; };
133043e812bSmartin
134