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