Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/usr.sbin/sysinst Add (experimental) entropy input support:



details:   https://anonhg.NetBSD.org/src/rev/c7b80ffbbeb7
branches:  trunk
changeset: 956681:c7b80ffbbeb7
user:      martin <martin%NetBSD.org@localhost>
date:      Wed Nov 04 14:29:40 2020 +0000

description:
Add (experimental) entropy input support:
Early during new installs or after upgrades we check if entropy is
available. If not (no hardware random number generator available)
we inform the user and ask them to fix it.

diffstat:

 usr.sbin/sysinst/Makefile.inc              |   13 +-
 usr.sbin/sysinst/arch/atari/Makefile       |    3 +-
 usr.sbin/sysinst/arch/ews4800mips/Makefile |    3 +-
 usr.sbin/sysinst/defs.h                    |    5 +-
 usr.sbin/sysinst/install.c                 |    9 +-
 usr.sbin/sysinst/menus.entropy             |  131 +++++++++++++
 usr.sbin/sysinst/menus.mi                  |    4 +-
 usr.sbin/sysinst/msg.entropy.de            |  128 +++++++++++++
 usr.sbin/sysinst/msg.entropy.en            |  125 ++++++++++++
 usr.sbin/sysinst/msg.entropy.es            |  125 ++++++++++++
 usr.sbin/sysinst/msg.entropy.fr            |  125 ++++++++++++
 usr.sbin/sysinst/msg.entropy.pl            |  125 ++++++++++++
 usr.sbin/sysinst/msg.mi.de                 |   13 +-
 usr.sbin/sysinst/msg.mi.en                 |   14 +-
 usr.sbin/sysinst/msg.mi.es                 |   15 +-
 usr.sbin/sysinst/msg.mi.fr                 |   15 +-
 usr.sbin/sysinst/msg.mi.pl                 |   15 +-
 usr.sbin/sysinst/msg.pm.de                 |   16 +-
 usr.sbin/sysinst/msg.pm.en                 |   15 +-
 usr.sbin/sysinst/msg.pm.es                 |   15 +-
 usr.sbin/sysinst/msg.pm.fr                 |   15 +-
 usr.sbin/sysinst/msg.pm.pl                 |   15 +-
 usr.sbin/sysinst/upgrade.c                 |    3 +-
 usr.sbin/sysinst/util.c                    |  284 ++++++++++++++++++++++++++++-
 24 files changed, 1146 insertions(+), 85 deletions(-)

diffs (truncated from 1559 to 300 lines):

diff -r 3f5bd1525eb9 -r c7b80ffbbeb7 usr.sbin/sysinst/Makefile.inc
--- a/usr.sbin/sysinst/Makefile.inc     Wed Nov 04 13:46:46 2020 +0000
+++ b/usr.sbin/sysinst/Makefile.inc     Wed Nov 04 14:29:40 2020 +0000
@@ -1,4 +1,4 @@
-#      $NetBSD: Makefile.inc,v 1.36 2020/10/30 18:47:38 martin Exp $
+#      $NetBSD: Makefile.inc,v 1.37 2020/11/04 14:29:40 martin Exp $
 #
 # Makefile for sysinst
 
@@ -47,6 +47,11 @@
 CPPFLAGS+=     -DNO_CLONES
 .endif
 
+.if ${CHECK_ENTROPY:Uyes} != "no"
+MENUS_MI+=     menus.entropy
+CPPFLAGS+=     -DCHECK_ENTROPY=1
+.endif
+
 MSG_MD?=       msg.md.${SYSINSTLANG}
 MENUS_MD?=     menus.md.${SYSINSTLANG}
 
@@ -197,7 +202,11 @@
        touch ${.TARGET}
 
 .if !defined(NOPARTMAN)
-MSG_MD+=       msg.pm.${SYSINSTLANG}   
+MSG_MD+=       msg.pm.${SYSINSTLANG}
+.endif
+
+.if ${CHECK_ENTROPY:Uyes} != "no"
+MSG_MD+=       msg.entropy.${SYSINSTLANG}
 .endif
 
 msg.def: msg.mi.${SYSINSTLANG} ${MSG_MD} msgtouch
diff -r 3f5bd1525eb9 -r c7b80ffbbeb7 usr.sbin/sysinst/arch/atari/Makefile
--- a/usr.sbin/sysinst/arch/atari/Makefile      Wed Nov 04 13:46:46 2020 +0000
+++ b/usr.sbin/sysinst/arch/atari/Makefile      Wed Nov 04 14:29:40 2020 +0000
@@ -1,4 +1,4 @@
-#      $NetBSD: Makefile,v 1.4 2019/06/12 06:20:18 martin Exp $
+#      $NetBSD: Makefile,v 1.5 2020/11/04 14:29:40 martin Exp $
 #
 # Makefile for atari
 #
@@ -9,6 +9,7 @@
 CPPFLAGS+=     -DSUPPORT_8_3_SOURCE_FILESYSTEM
 
 .ifdef SMALLPROG
+CHECK_ENTROPY= no      # do not check entropy/offer adding
 NOPARTMAN=     yes
 NO_GPT=                yes
 .endif
diff -r 3f5bd1525eb9 -r c7b80ffbbeb7 usr.sbin/sysinst/arch/ews4800mips/Makefile
--- a/usr.sbin/sysinst/arch/ews4800mips/Makefile        Wed Nov 04 13:46:46 2020 +0000
+++ b/usr.sbin/sysinst/arch/ews4800mips/Makefile        Wed Nov 04 14:29:40 2020 +0000
@@ -1,4 +1,4 @@
-#      $NetBSD: Makefile,v 1.3 2019/11/13 18:58:09 martin Exp $
+#      $NetBSD: Makefile,v 1.4 2020/11/04 14:29:40 martin Exp $
 #
 # Makefile for ews4800mips
 #
@@ -6,6 +6,7 @@
 LANGUAGES=     # no translations
 
 .ifdef SMALLPROG
+CHECK_ENTROPY= no      # do not check entropy/offer adding
 NOPARTMAN=     yes
 NO_GPT=                yes
 NO_MBR=                yes
diff -r 3f5bd1525eb9 -r c7b80ffbbeb7 usr.sbin/sysinst/defs.h
--- a/usr.sbin/sysinst/defs.h   Wed Nov 04 13:46:46 2020 +0000
+++ b/usr.sbin/sysinst/defs.h   Wed Nov 04 14:29:40 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: defs.h,v 1.68 2020/10/30 18:47:38 martin Exp $ */
+/*     $NetBSD: defs.h,v 1.69 2020/11/04 14:29:40 martin Exp $ */
 
 /*
  * Copyright 1997 Piermont Information Systems Inc.
@@ -41,6 +41,7 @@
 #include <sys/queue.h>
 #include <sys/types.h>
 #include <sys/disk.h>
+#include <limits.h>
 #include <uuid.h>
 
 const char *getfslabelname(uint, uint);
@@ -604,6 +605,7 @@
 extern int (*fetch_fn)(const char *);
 extern char nfs_host[STRSIZE];
 extern char nfs_dir[STRSIZE];
+extern char entropy_file[PATH_MAX];
 
 extern char cdrom_dev[SSTRSIZE];               /* Typically "cd0a" */
 extern char fd_dev[SSTRSIZE];                  /* Typically "/dev/fd0a" */
@@ -888,6 +890,7 @@
            struct disk_partitions*);
 void   free_install_desc(struct install_partition_desc*);
 bool   may_swap_if_not_sdmmc(const char*);
+bool   do_check_entropy(void);
 
 /* from target.c */
 #if defined(DEBUG)  || defined(DEBUG_ROOT)
diff -r 3f5bd1525eb9 -r c7b80ffbbeb7 usr.sbin/sysinst/install.c
--- a/usr.sbin/sysinst/install.c        Wed Nov 04 13:46:46 2020 +0000
+++ b/usr.sbin/sysinst/install.c        Wed Nov 04 14:29:40 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: install.c,v 1.19 2020/10/14 13:20:27 martin Exp $      */
+/*     $NetBSD: install.c,v 1.20 2020/11/04 14:29:40 martin Exp $      */
 
 /*
  * Copyright 1997 Piermont Information Systems Inc.
@@ -168,6 +168,13 @@
                return;
 #endif
 
+#ifdef CHECK_ENTROPY
+       if (!do_check_entropy()) {
+               hit_enter_to_continue(MSG_abort_installation, NULL);
+               return;
+       }
+#endif
+
        memset(&install, 0, sizeof install);
 
        /* Create and mount partitions */
diff -r 3f5bd1525eb9 -r c7b80ffbbeb7 usr.sbin/sysinst/menus.entropy
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/usr.sbin/sysinst/menus.entropy    Wed Nov 04 14:29:40 2020 +0000
@@ -0,0 +1,131 @@
+/*     $NetBSD: menus.entropy,v 1.1 2020/11/04 14:29:40 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_abort_installation;
+       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; };
+
diff -r 3f5bd1525eb9 -r c7b80ffbbeb7 usr.sbin/sysinst/menus.mi
--- a/usr.sbin/sysinst/menus.mi Wed Nov 04 13:46:46 2020 +0000
+++ b/usr.sbin/sysinst/menus.mi Wed Nov 04 14:29:40 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: menus.mi,v 1.23 2020/10/27 15:28:01 martin Exp $       */
+/*     $NetBSD: menus.mi,v 1.24 2020/11/04 14:29:40 martin Exp $       */
 
 /*-
  * Copyright (c) 2003 The NetBSD Foundation, Inc.
@@ -661,5 +661,3 @@
            action  {((arg_rep_int*)arg)->rv = 2;};
        option MSG_abort_installation,       exit,
            action  {((arg_rep_int*)arg)->rv = 0;};
-
-
diff -r 3f5bd1525eb9 -r c7b80ffbbeb7 usr.sbin/sysinst/msg.entropy.de
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/usr.sbin/sysinst/msg.entropy.de   Wed Nov 04 14:29:40 2020 +0000
@@ -0,0 +1,128 @@
+/*      $NetBSD: msg.entropy.de,v 1.1 2020/11/04 14:29:40 martin Exp $  */
+
+/*
+ * Copyright 2018 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * 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 PIERMONT INFORMATION SYSTEMS INC. ``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 PIERMONT INFORMATION SYSTEMS INC. 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



Home | Main Index | Thread Index | Old Index