Index: distrib/utils/sysinst/Makefile.inc =================================================================== RCS file: /cvsroot/src/distrib/utils/sysinst/Makefile.inc,v retrieving revision 1.58 diff -u -r1.58 Makefile.inc --- distrib/utils/sysinst/Makefile.inc 8 Jan 2012 21:20:40 -0000 1.58 +++ distrib/utils/sysinst/Makefile.inc 23 Jan 2012 04:51:54 -0000 @@ -13,7 +13,7 @@ SRCS+= menu_defs.c msg_defs.c main.c install.c upgrade.c \ txtwalk.c run.c factor.c net.c disks.c disks_lfs.c util.c geom.c \ - label.c target.c md.c sizemultname.c + label.c target.c md.c sizemultname.c configmenu.c checkrc.c SRCS+= ${MD_OPTIONS:MAOUT2ELF:S/AOUT2ELF/aout2elf.c/} SRCS+= ${MENUS_MD:Mmenus.mbr:S/menus.mbr/mbr.c/} Index: distrib/utils/sysinst/checkrc.c =================================================================== RCS file: distrib/utils/sysinst/checkrc.c diff -N distrib/utils/sysinst/checkrc.c --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ distrib/utils/sysinst/checkrc.c 23 Jan 2012 04:51:54 -0000 @@ -0,0 +1,113 @@ +/* $NetBSD$ */ + +/*- + * Copyright (c) 2012 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Jeffrey C. Rizzo + * + * 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. + */ + +/* checkrc.c -- Create a script on the target to check the state of + * its rc.conf variables. */ + +#include +#include +#include +#include "defs.h" +#include "msg_defs.h" +#include "menu_defs.h" + +#define RC_CHECK_SCRIPT "/tmp/checkrc.sh" + +static int create_script(const char *, int); +static int check(const char *, int); + +char *rcconf = NULL; + +enum { + CHECK_CONF, + CHECK_DEFAULT +}; + +static int +create_script(const char *varname, int filetocheck) +{ + FILE *fp; + + if ((fp = fopen(target_expand(RC_CHECK_SCRIPT), "w")) == NULL) { + if (logfp) + fprintf(logfp,"Could not open %s for writing", + target_expand(RC_CHECK_SCRIPT)); + warn("Could not open %s for writing", + target_expand(RC_CHECK_SCRIPT)); + return 1; + } + + if (filetocheck == CHECK_DEFAULT) + fprintf(fp, "#!/bin/sh\n. /etc/defaults/rc.conf\n" + ". /etc/rc.subr\n"); + else + fprintf(fp, "#!/bin/sh\n. /etc/rc.conf\n. /etc/rc.subr\n"); + fprintf(fp, "if checkyesno %s\nthen\necho YES\nelse\necho NO\nfi\n", + varname); + + fclose(fp); + return 0; +} + +static int +check(const char *varname, int filetocheck) +{ + char *buf; + + create_script(varname, filetocheck); + + collect(T_OUTPUT, &buf, "chroot %s /bin/sh %s 2>&1", target_prefix(), + RC_CHECK_SCRIPT); + + unlink(target_expand(RC_CHECK_SCRIPT)); + + if (logfp) { + fprintf(logfp,"var %s is %s\n", varname, buf); + fflush(logfp); + } + + if (strncmp(buf, "YES", strlen("YES")) == 0) + return 1; + else + return 0; +} + +int +check_rcvar(const char *varname) +{ + return check(varname, CHECK_CONF); +} + +int +check_rcdefault(const char *varname) +{ + return check(varname, CHECK_DEFAULT); +} Index: distrib/utils/sysinst/configmenu.c =================================================================== RCS file: distrib/utils/sysinst/configmenu.c diff -N distrib/utils/sysinst/configmenu.c --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ distrib/utils/sysinst/configmenu.c 23 Jan 2012 04:51:54 -0000 @@ -0,0 +1,371 @@ +/* $NetBSD$ */ + +/*- + * Copyright (c) 2012 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Jeffrey C. Rizzo + * + * 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. + */ + +/* configmenu.c -- post-installation system configuration menu. */ + +#include +#include +#include "defs.h" +#include "msg_defs.h" +#include "menu_defs.h" + + +static int set_timezone_menu(struct menudesc *, void *); +static int set_root_shell(struct menudesc *, void *); +static int change_root_password(struct menudesc *, void *); +static int set_binpkg(struct menudesc *, void *); +static int set_pkgsrc(struct menudesc *, void *); +static void config_list_init(void); +static void get_rootsh(void); +static int toggle_rcvar(struct menudesc *, void *); +static void configmenu_hdr(struct menudesc *, void *); +static int check_root_password(void); + +char pkgpath[STRSIZE]; +char pkgsrcpath[STRSIZE]; + +extern const char *tz_default; + +enum { + CONFIGOPT_TZ, + CONFIGOPT_ROOTSH, + CONFIGOPT_ROOTPW, + CONFIGOPT_BINPKG, + CONFIGOPT_PKGSRC, + CONFIGOPT_SSHD, + CONFIGOPT_NTPD, + CONFIGOPT_NTPDATE, + CONFIGOPT_MDNSD, + CONFIGOPT_LAST +}; + +typedef struct configinfo { + const char *optname; + uint opt; + const char *rcvar; + int (*action)(struct menudesc *, void *); + const char *setting; +} configinfo; + + +configinfo config_list[] = { + {MSG_timezone, CONFIGOPT_TZ, NULL, set_timezone_menu, NULL}, + {MSG_Root_shell, CONFIGOPT_ROOTSH, NULL, set_root_shell, NULL}, + {MSG_change_rootpw, CONFIGOPT_ROOTPW, NULL, change_root_password, "Change It"}, + {MSG_enable_binpkg, CONFIGOPT_BINPKG, NULL, set_binpkg, "Configure"}, + {MSG_get_pkgsrc, CONFIGOPT_PKGSRC, NULL, set_pkgsrc, "Install"}, + {MSG_enable_sshd, CONFIGOPT_SSHD, "sshd", toggle_rcvar, NULL}, + {MSG_enable_ntpd, CONFIGOPT_NTPD, "ntpd", toggle_rcvar, NULL}, + {MSG_run_ntpdate, CONFIGOPT_NTPDATE, "ntpdate", toggle_rcvar, NULL}, + {MSG_enable_mdnsd, CONFIGOPT_MDNSD, "mdnsd", toggle_rcvar, NULL}, + {NULL, CONFIGOPT_LAST, NULL, NULL, NULL} +}; + +static void +config_list_init(void) +{ + int i; + + for (i=0; i < CONFIGOPT_LAST; i++) { + switch (i) { + case CONFIGOPT_TZ: + get_tz_default(); + config_list[CONFIGOPT_TZ].setting = tz_default; + break; + case CONFIGOPT_ROOTSH: + get_rootsh(); + break; + case CONFIGOPT_ROOTPW: + if (check_root_password()) + config_list[i].setting = "Password Set"; + else + config_list[i].setting = "***EMPTY***"; + break; + default: + if (config_list[i].rcvar != NULL) { + if (check_rcvar(config_list[i].rcvar)) + config_list[i].setting = "YES"; + else + config_list[i].setting = "NO"; + } + break; + } + } +} + +static void +get_rootsh(void) +{ + static char *buf = NULL; + + if (buf != NULL) + free(buf); + + collect(T_OUTPUT, &buf, + "chroot %s /usr/bin/awk -F: '$1==\"root\" { print $NF; exit }'" + " /etc/passwd",target_prefix()); + + config_list[CONFIGOPT_ROOTSH].setting = (const char *)buf; +} + +static void +set_config(menudesc *menu, int opt, void *arg) +{ + configinfo **configp = arg; + configinfo *config = configp[opt]; + const char *optname, *setting; + + optname = config->optname; + setting = config->setting; + + wprintw(menu->mw, "%-50s %-10s", msg_string(optname), setting); +} + +static int +init_config_menu(configinfo *conf, menu_ent *me, configinfo **ce) +{ + int opt; + int configopts; + + for (configopts = 0; ; conf++) { + opt = conf->opt; + if (opt == CONFIGOPT_LAST) + break; + *ce = conf; + me->opt_menu = OPT_NOMENU; + me->opt_flags = 0; + me->opt_name = NULL; /* NULL so set_config will draw */ + me->opt_action = conf->action; + configopts++; + ce++; + me++; + } + + return configopts; +} + +static int +/*ARGSUSED*/ +set_timezone_menu(struct menudesc *menu, void *arg) +{ + configinfo **confp = arg; + set_timezone(); + get_tz_default(); + confp[menu->cursel]->setting = tz_default; + return 0; +} + +static int +set_root_shell(struct menudesc *menu, void *arg) +{ + configinfo **confp = arg; + + process_menu(MENU_rootsh, &confp[menu->cursel]->setting); + run_program(RUN_PROGRESS | RUN_CHROOT, + "chpass -s %s root", confp[menu->cursel]->setting); + return 0; +} + +static int +check_root_password(void) +{ + char *buf; + int rval; + + collect(T_OUTPUT, &buf, "chroot %s getent passwd root | chroot %s cut -d: -f2", + target_prefix(), target_prefix()); + + if (logfp) + fprintf(logfp,"buf %s strlen(buf) %zu\n", buf, strlen(buf)); + + if (strlen(buf) <= 1) /* newline */ + rval = 0; + else + rval = 1; + free(buf); + return rval; +} + +static int +change_root_password(struct menudesc *menu, void *arg) +{ + configinfo **confp = arg; + + msg_display(MSG_rootpw); + process_menu(MENU_yesno, NULL); + if (yesno) + run_program(RUN_DISPLAY | RUN_PROGRESS | RUN_CHROOT, + "passwd -l root"); + confp[menu->cursel]->setting = "Password set"; + return 0; +} + +static int +set_binpkg(struct menudesc *menu, void *arg) +{ + configinfo **confp = arg; + + char pattern[STRSIZE]; + + process_menu(MENU_binpkg, NULL); + make_url(pkgpath, &pkg, pkg_dir); + run_program(RUN_DISPLAY | RUN_PROGRESS | RUN_CHROOT, + "pkg_add %s/pkgin", pkgpath); + run_program(RUN_DISPLAY | RUN_PROGRESS | RUN_CHROOT, + "/usr/pkg/bin/pkgin update"); + + /* configure pkgin to use $pkgpath as a repository */ + snprintf(pattern, STRSIZE, "s,^[^#].*$,%s,", pkgpath); + replace("/usr/pkg/etc/pkgin/repositories.conf", pattern); + msg_display(MSG_binpkg_installed); + process_menu(MENU_ok, NULL); + + confp[menu->cursel]->setting = "DONE"; + return 0; +} + +static int +set_pkgsrc(struct menudesc *menu, void *arg) +{ + configinfo **confp = arg; + distinfo dist; + + dist.name = "pkgsrc"; + dist.set = SET_PKGSRC; + dist.desc = "source for 3rd-party packages"; + dist.marker_file = NULL; + + int status = SET_RETRY; + + do { + status = get_pkgsrc(); + if (status == SET_OK) { + status = extract_file(&dist, 0); + continue; + } + process_menu(MENU_yesno, deconst(MSG_retry_pkgsrc_network)); + if (!yesno) { + confp[menu->cursel]->setting = "Abandoned"; + return 1; + } + } + while (status == SET_RETRY); + + + confp[menu->cursel]->setting = "DONE"; + return 0; +} + +/* to toggle an rc var: + * - if it's the same as the default, assume not set in /etc/rc.conf + * - if it's different than the default, replace it in /etc/rc.conf + */ +static int +toggle_rcvar(struct menudesc *menu, void *arg) +{ + configinfo **confp = arg; + int s,d; /* setting, default */ + const char *setting, *varname; + char pattern[STRSIZE]; + + varname = confp[menu->cursel]->rcvar; + + s = check_rcvar(varname); + d = check_rcdefault(varname); + + /* we're toggling, so invert the sense */ + if (s) + confp[menu->cursel]->setting = setting = "NO"; + else + confp[menu->cursel]->setting = setting = "YES"; + + if (s == d) { + add_rc_conf("%s=%s\n", varname, setting); + if (logfp) { + fprintf(logfp, "adding %s=%s\n", varname, setting); + fflush(logfp); + } + } else { + snprintf(pattern, STRSIZE, "s,%s[:space:]*=[:space:]*%s$,,", + varname, s ? "YES" : "NO"); + if (logfp) { + fprintf(logfp, "replacement pattern is %s\n", pattern); + fflush(logfp); + } + replace("/etc/rc.conf", pattern); + } + + return 0; +} + +static void +configmenu_hdr(struct menudesc *menu, void *arg) +{ + msg_display(MSG_configmenu); +} + +void +do_configmenu() +{ + int menu_no; + int opts; + menu_ent me[CONFIGOPT_LAST]; + configinfo *ce[CONFIGOPT_LAST]; + + wrefresh(curscr); + wmove(stdscr, 0, 0); + wclear(stdscr); + wrefresh(stdscr); + + /* if the target isn't mounted already, figure it out. */ + if (target_mounted() == 0) { + if (find_disks(msg_string(MSG_configure)) < 0) + return; + + if (mount_disks() != 0) + return; + } + + config_list_init(); + make_url(pkgpath, &pkg, pkg_dir); + opts = init_config_menu(config_list, me, ce); + + menu_no = new_menu(NULL, me, opts, 0, -4, 0, 70, + MC_SCROLL | MC_NOBOX | MC_DFLTEXIT, + configmenu_hdr, set_config, NULL, "XXX Help String", + MSG_doneconfig); + + process_menu(menu_no, ce); + free_menu(menu_no); + + sanity_check(); + +} Index: distrib/utils/sysinst/defs.h =================================================================== RCS file: /cvsroot/src/distrib/utils/sysinst/defs.h,v retrieving revision 1.161 diff -u -r1.161 defs.h --- distrib/utils/sysinst/defs.h 10 Jan 2012 21:02:47 -0000 1.161 +++ distrib/utils/sysinst/defs.h 23 Jan 2012 04:51:54 -0000 @@ -133,6 +133,7 @@ SET_LAST, SET_GROUP, /* Start of submenu */ SET_GROUP_END, /* End of submenu */ + SET_PKGSRC, /* pkgsrc, not counted as regular set */ }; /* Initialisers to select sets */ @@ -288,26 +289,50 @@ #define SYSINST_FTP_DIR "pub/NetBSD/NetBSD-" REL #endif +#if !defined(SYSINST_PKG_HOST) +#define SYSINST_PKG_HOST SYSINST_FTP_HOST +#endif + +#if !defined(SYSINST_PKG_DIR) +#define SYSINST_PKG_DIR "pub/pkgsrc/packages/NetBSD" +#endif + +#if !defined(SYSINST_PKGSRC_HOST) +#define SYSINST_PKGSRC_HOST SYSINST_PKG_HOST +#endif + /* Abs. path we extract binary sets from */ char ext_dir_bin[STRSIZE]; /* Abs. path we extract source sets from */ char ext_dir_src[STRSIZE]; +/* Abs. path we extract pkgsrc from */ +char ext_dir_pkgsrc[STRSIZE]; + /* Place we look for binary sets in all fs types */ char set_dir_bin[STRSIZE]; /* Place we look for source sets in all fs types */ char set_dir_src[STRSIZE]; -struct { +/* Place we look for pkgs in all fs types */ +char pkg_dir[STRSIZE]; + +/* Place we look for pkgsrc in all fs types */ +char pkgsrc_dir[STRSIZE]; + +struct ftpinfo { char host[STRSIZE]; char dir[STRSIZE] ; char user[SSTRSIZE]; char pass[STRSIZE]; char proxy[STRSIZE]; const char *xfer_type; /* "ftp" or "http" */ -} ftp; +}; + +/* use the same struct for sets ftp and to build pkgpath */ +struct ftpinfo ftp, pkg, pkgsrc; int (*fetch_fn)(const char *); char nfs_host[STRSIZE]; @@ -398,6 +423,8 @@ int get_via_nfs(void); int config_network(void); void mnt_net_config(void); +void make_url(char *, struct ftpinfo *, const char *); +int get_pkgsrc(void); /* From run.c */ int collect(int, char **, const char *, ...) __printflike(3, 4); @@ -430,8 +457,6 @@ int get_and_unpack_sets(int, msg, msg, msg); int sanity_check(void); int set_timezone(void); -int set_root_password(void); -int set_root_shell(void); void scripting_fprintf(FILE *, const char *, ...) __printflike(2, 3); void scripting_vfprintf(FILE *, const char *, va_list) __printflike(2, 0); void add_rc_conf(const char *, ...); @@ -446,6 +471,9 @@ int set_is_source(const char *); const char *set_dir_for_set(const char *); const char *ext_dir_for_set(const char *); +void replace(const char *, const char *, ...); +void get_tz_default(void); +int extract_file(distinfo *, int); /* from target.c */ #if defined(DEBUG) || defined(DEBUG_ROOT) @@ -476,6 +504,7 @@ int target_file_exists_p(const char *); int target_symlink_exists_p(const char *); void unwind_mounts(void); +int target_mounted(void); /* from bsddisklabel.c */ int make_bsd_partitions(void); @@ -495,4 +524,11 @@ #define get_kb_encoding() #define save_kb_encoding() #endif + +/* from configmenu.c */ +void do_configmenu(void); + +/* from checkrc.c */ +int check_rcvar(const char *); +int check_rcdefault(const char *); #endif /* _DEFS_H_ */ Index: distrib/utils/sysinst/install.c =================================================================== RCS file: /cvsroot/src/distrib/utils/sysinst/install.c,v retrieving revision 1.45 diff -u -r1.45 install.c --- distrib/utils/sysinst/install.c 4 Apr 2011 08:30:12 -0000 1.45 +++ distrib/utils/sysinst/install.c 23 Jan 2012 04:51:54 -0000 @@ -117,10 +117,7 @@ if (md_post_extract() != 0) return; - set_timezone(); - - set_root_password(); - set_root_shell(); + do_configmenu(); sanity_check(); Index: distrib/utils/sysinst/main.c =================================================================== RCS file: /cvsroot/src/distrib/utils/sysinst/main.c,v retrieving revision 1.63 diff -u -r1.63 main.c --- distrib/utils/sysinst/main.c 10 Jan 2012 21:02:47 -0000 1.63 +++ distrib/utils/sysinst/main.c 23 Jan 2012 04:51:54 -0000 @@ -63,9 +63,9 @@ FILE *logfp; /* log file */ FILE *script; /* script file */ -#ifdef DEBUG +//#ifdef DEBUG extern int log_flip(void); -#endif +//#endif /* String defaults and stuff for processing the -f file argument. */ @@ -99,6 +99,18 @@ {"targetroot mount", "/targetroot", targetroot_mnt, sizeof targetroot_mnt}, {"dist postfix", ".tgz", dist_postfix, sizeof dist_postfix}, {"diskname", "mydisk", bsddiskname, sizeof bsddiskname}, + {"pkg host", SYSINST_PKG_HOST, pkg.host, sizeof pkg.host}, + {"pkg dir", SYSINST_PKG_DIR, pkg.dir, sizeof pkg.dir}, + {"pkg prefix", "/" MACH "/" REL "/All", pkg_dir, sizeof pkg_dir}, + {"pkg user", "ftp", pkg.user, sizeof pkg.user}, + {"pkg pass", "", pkg.pass, sizeof pkg.pass}, + {"pkg proxy", "", pkg.proxy, sizeof pkg.proxy}, + {"pkgsrc host", SYSINST_PKGSRC_HOST, pkgsrc.host, sizeof pkgsrc.host}, + {"pkgsrc dir", "", pkgsrc.dir, sizeof pkgsrc.dir}, + {"pkgsrc prefix", "pub/pkgsrc/stable", pkgsrc_dir, sizeof pkgsrc_dir}, + {"pkgsrc user", "ftp", pkgsrc.user, sizeof pkgsrc.user}, + {"pkgsrc pass", "", pkgsrc.pass, sizeof pkgsrc.pass}, + {"pkgsrc proxy", "", pkgsrc.proxy, sizeof pkgsrc.proxy}, {NULL, NULL, NULL, 0} }; @@ -118,6 +130,7 @@ for (arg = fflagopts; arg->name != NULL; arg++) strlcpy(arg->var, arg->dflt, arg->size); + pkg.xfer_type = pkgsrc.xfer_type = "http"; } int @@ -127,9 +140,9 @@ int ch; init(); -#ifdef DEBUG +//#ifdef DEBUG log_flip(); -#endif +//#endif /* Check for TERM ... */ if (!getenv("TERM")) { (void)fprintf(stderr, Index: distrib/utils/sysinst/menus.mi =================================================================== RCS file: /cvsroot/src/distrib/utils/sysinst/menus.mi,v retrieving revision 1.44 diff -u -r1.44 menus.mi --- distrib/utils/sysinst/menus.mi 10 Jan 2012 21:02:47 -0000 1.44 +++ distrib/utils/sysinst/menus.mi 23 Jan 2012 04:51:54 -0000 @@ -162,6 +162,7 @@ option MSG_Reboot_the_computer, exit, action (endwin) { system("/sbin/reboot -q"); }; option MSG_Utility_menu, sub menu utility; + option "Config menu", action { do_configmenu(); }; menu utility, title MSG_NetBSD_VERSION_Utilities, exit, exitstring MSG_exit_utility_menu; @@ -281,6 +282,7 @@ action {process_menu(MENU_yesno, deconst(MSG_delete_xfer_file)); clean_xfer_dir = yesno; }; + menu nfssource, y=-4, x=0, w=70, no box, no clear, exitstring MSG_Continue; display action { msg_display(MSG_nfssource); }; @@ -377,7 +379,85 @@ option MSG_other, exit, action { yesno = 0; }; -menu rootsh, title MSG_Root_shell; +menu rootsh, title MSG_Root_shell, no clear; option "/bin/sh", exit, action {*(const char **)arg = "/bin/sh";}; option "/bin/ksh", exit, action {*(const char **)arg = "/bin/ksh";}; option "/bin/csh", exit, action {*(const char **)arg = "/bin/csh";}; + +menu zeroconf, title "Zeroconf", no clear; + option "run mdnsd only", exit, action {*(const char **)arg = "mdnsd";}; + option "run mdnsd and resolve local names", exit, action {*(const char **) arg = "mdnsd+nsswitch";}; + option "do not run mdnsd", exit, action {*(const char **)arg = "No";}; + +menu binpkg, y=-4, x=0, w=70, no box, no clear, + exitstring MSG_Install_pkgin; + display action { msg_display(MSG_pkgpath); }; + option {src_legend(menu, MSG_Host, pkg.host);}, + action { src_prompt(MSG_Host, pkg.host, sizeof pkg.host); }; + option {src_legend(menu, MSG_Base_dir, pkg.dir);}, + action { src_prompt(MSG_Base_dir, pkg.dir, sizeof pkg.dir); }; + option {src_legend(menu, MSG_Pkg_dir, pkg_dir);}, + action { src_prompt(MSG_Pkg_dir, pkg_dir, sizeof pkg_dir); }; + option {src_legend(menu, MSG_User, pkg.user);}, + action { src_prompt(MSG_User, pkg.user, sizeof pkg.user); + pkg.pass[0] = 0; + }; + option {src_legend(menu, MSG_Password, + strcmp(pkg.user, "ftp") == 0 || pkg.pass[0] == 0 + ? pkg.pass : msg_string(MSG_hidden));}, + action { if (strcmp(pkg.user, "ftp") == 0) + src_prompt(MSG_email, pkg.pass, sizeof pkg.pass); + else { + msg_prompt_noecho(MSG_Password, "", + pkg.pass, sizeof pkg.pass); + } + }; + option {src_legend(menu, MSG_Proxy, pkg.proxy);}, + action { src_prompt(MSG_Proxy, pkg.proxy, sizeof pkg.proxy); + if (strcmp(pkg.proxy, "") == 0) { + unsetenv("ftp_proxy"); + unsetenv("http_proxy"); + } else { + setenv("ftp_proxy", pkg.proxy, 1); + setenv("http_proxy", pkg.proxy, 1); + } + }; + +menu pkgsrc, y=-4, x=0, w=70, no box, no clear, + exitstring MSG_Install_pkgsrc; + display action { msg_display(MSG_pkgsrc); }; + option {src_legend(menu, MSG_Host, pkgsrc.host);}, + action { src_prompt(MSG_Host, pkgsrc.host, + sizeof pkgsrc.host); }; + option {src_legend(menu, MSG_Pkgsrc_dir, pkgsrc_dir);}, + action { src_prompt(MSG_Pkgsrc_dir, pkgsrc_dir, sizeof pkgsrc_dir); }; + option {src_legend(menu, MSG_User, pkgsrc.user);}, + action { src_prompt(MSG_User, pkgsrc.user, sizeof pkgsrc.user); + pkgsrc.pass[0] = 0; + }; + option {src_legend(menu, MSG_Password, + strcmp(pkgsrc.user, "ftp") == 0 || pkgsrc.pass[0] == 0 + ? pkgsrc.pass : msg_string(MSG_hidden));}, + action { if (strcmp(pkgsrc.user, "ftp") == 0) + src_prompt(MSG_email, pkgsrc.pass, sizeof pkgsrc.pass); + else { + msg_prompt_noecho(MSG_Password, "", + pkgsrc.pass, sizeof pkgsrc.pass); + } + }; + option {src_legend(menu, MSG_Proxy, pkgsrc.proxy);}, + action { src_prompt(MSG_Proxy, pkgsrc.proxy, sizeof pkgsrc.proxy); + if (strcmp(pkgsrc.proxy, "") == 0) { + unsetenv("ftp_proxy"); + unsetenv("http_proxy"); + } else { + setenv("ftp_proxy", pkgsrc.proxy, 1); + setenv("http_proxy", pkgsrc.proxy, 1); + } + }; + option {src_legend(menu, MSG_Xfer_dir, xfer_dir);}, + action { src_prompt(MSG_Xfer_dir, xfer_dir, sizeof xfer_dir); }; + option {src_legend(menu, MSG_delete_xfer_file, + clean_xfer_dir ? MSG_Yes : MSG_No);}, + action {process_menu(MENU_yesno, deconst(MSG_delete_xfer_file)); + clean_xfer_dir = yesno; }; Index: distrib/utils/sysinst/msg.mi.de =================================================================== RCS file: /cvsroot/src/distrib/utils/sysinst/msg.mi.de,v retrieving revision 1.61 diff -u -r1.61 msg.mi.de --- distrib/utils/sysinst/msg.mi.de 10 Jan 2012 21:02:47 -0000 1.61 +++ distrib/utils/sysinst/msg.mi.de 23 Jan 2012 04:51:54 -0000 @@ -1039,3 +1039,42 @@ Um den Lizenztext zu lesen, geben Sie ^Z ein, schauen den Inhalt der Datei an und kehren mit dem Befehl "fg" zu sysinst zurück.} +message binpkg +{To configure the binary package system, please choose the network location +to fetch packages from. Once your system comes up, you can use 'pkgin' +to install additional packages, or remove packages.} + +message pkgpath +{The following are the protocol, host, directory, user, and password that +will be used. If "user" is "ftp", then the password is not needed. + +} +message Pkg_dir {Package directory} +message configure {configure a prior installation of} +message timezone {Timezone} +message change_rootpw {Change root password} +message enable_binpkg {Enable installation of binary packages} +message enable_sshd {Enable sshd} +message enable_ntpd {Enable ntpd} +message run_ntpdate {Run ntpdate at boot} +message enable_mdnsd {Enable mdnsd} +message configmenu {Configure the additional items as needed.} +message doneconfig {Finished configuring} +message Install_pkgin {Install pkgin and update package summary} +message binpkg_installed +{You are now configured to use pkgin to install binary packages. To +install a package, run: + +pkgin install + +from a root shell. Read the pkgin(1) manual page for further information.} +message Install_pkgsrc {Fetch and unpack pkgsrc} +message pkgsrc +{Enabling binary packages with pkgin requires setting up the repository. +The following are the host, directory, user, and password that +will be used. If "user" is "ftp", then the password is not needed. + +} +message Pkgsrc_dir {pkgsrc directory} +message get_pkgsrc {Fetch and unpack pkgsrc for building from source} +message retry_pkgsrc_network {Network configuration failed. Retry?} Index: distrib/utils/sysinst/msg.mi.en =================================================================== RCS file: /cvsroot/src/distrib/utils/sysinst/msg.mi.en,v retrieving revision 1.169 diff -u -r1.169 msg.mi.en --- distrib/utils/sysinst/msg.mi.en 10 Jan 2012 21:02:47 -0000 1.169 +++ distrib/utils/sysinst/msg.mi.en 23 Jan 2012 04:51:54 -0000 @@ -972,3 +972,44 @@ {To use the network interface %s, you must agree to the license in file %s. To view this file now, you can type ^Z, look at the contents of the file and then type "fg" to resume.} + +message binpkg +{To configure the binary package system, please choose the network location +to fetch packages from. Once your system comes up, you can use 'pkgin' +to install additional packages, or remove packages.} + +message pkgpath +{Enabling binary packages with pkgin requires setting up the repository. +The following are the host, directory, user, and password that +will be used. If "user" is "ftp", then the password is not needed. + +} +message Pkg_dir {Package directory} +message configure {configure a prior installation of} +message timezone {Timezone} +message change_rootpw {Change root password} +message enable_binpkg {Enable installation of binary packages} +message enable_sshd {Enable sshd} +message enable_ntpd {Enable ntpd} +message run_ntpdate {Run ntpdate at boot} +message enable_mdnsd {Enable mdnsd} +message configmenu {Configure the additional items as needed.} +message doneconfig {Finished configuring} +message Install_pkgin {Install pkgin and update package summary} +message binpkg_installed +{Your system is now configured to use pkgin to install binary packages. To +install a package, run: + +pkgin install + +from a root shell. Read the pkgin(1) manual page for further information.} +message Install_pkgsrc {Fetch and unpack pkgsrc} +message pkgsrc +{Enabling binary packages with pkgin requires setting up the repository. +The following are the host, directory, user, and password that +will be used. If "user" is "ftp", then the password is not needed. + +} +message Pkgsrc_dir {pkgsrc directory} +message get_pkgsrc {Fetch and unpack pkgsrc for building from source} +message retry_pkgsrc_network {Network configuration failed. Retry?} Index: distrib/utils/sysinst/msg.mi.es =================================================================== RCS file: /cvsroot/src/distrib/utils/sysinst/msg.mi.es,v retrieving revision 1.39 diff -u -r1.39 msg.mi.es --- distrib/utils/sysinst/msg.mi.es 10 Jan 2012 21:02:47 -0000 1.39 +++ distrib/utils/sysinst/msg.mi.es 23 Jan 2012 04:51:54 -0000 @@ -1012,3 +1012,43 @@ file %s. To view this file now, you can type ^Z, look at the contents of the file and then type "fg" to resume.} + +message binpkg +{To configure the binary package system, please choose the network location +to fetch packages from. Once your system comes up, you can use 'pkgin' +to install additional packages, or remove packages.} + +message pkgpath +{The following are the protocol, host, directory, user, and password that +will be used. If "user" is "ftp", then the password is not needed. + +} +message Pkg_dir {Package directory} +message configure {configure a prior installation of} +message timezone {Timezone} +message change_rootpw {Change root password} +message enable_binpkg {Enable installation of binary packages} +message enable_sshd {Enable sshd} +message enable_ntpd {Enable ntpd} +message run_ntpdate {Run ntpdate at boot} +message enable_mdnsd {Enable mdnsd} +message configmenu {Configure the additional items as needed.} +message doneconfig {Finished configuring} +message Install_pkgin {Install pkgin and update package summary} +message binpkg_installed +{You are now configured to use pkgin to install binary packages. To +install a package, run: + +pkgin install + +from a root shell. Read the pkgin(1) manual page for further information.} +message Install_pkgsrc {Fetch and unpack pkgsrc} +message pkgsrc +{Enabling binary packages with pkgin requires setting up the repository. +The following are the host, directory, user, and password that +will be used. If "user" is "ftp", then the password is not needed. + +} +message Pkgsrc_dir {pkgsrc directory} +message get_pkgsrc {Fetch and unpack pkgsrc for building from source} +message retry_pkgsrc_network {Network configuration failed. Retry?} Index: distrib/utils/sysinst/msg.mi.fr =================================================================== RCS file: /cvsroot/src/distrib/utils/sysinst/msg.mi.fr,v retrieving revision 1.119 diff -u -r1.119 msg.mi.fr --- distrib/utils/sysinst/msg.mi.fr 10 Jan 2012 21:02:47 -0000 1.119 +++ distrib/utils/sysinst/msg.mi.fr 23 Jan 2012 04:51:54 -0000 @@ -1071,3 +1071,43 @@ {Afin d'utiliser l'interface réseau : %s, vous devez accepter la licence contenue dans le fichier %s. Pour afficher ce fichier, tapez ^Z, lisez le puis tapez "fg" pour reprendre.} + +message binpkg +{To configure the binary package system, please choose the network location +to fetch packages from. Once your system comes up, you can use 'pkgin' +to install additional packages, or remove packages.} + +message pkgpath +{The following are the protocol, host, directory, user, and password that +will be used. If "user" is "ftp", then the password is not needed. + +} +message Pkg_dir {Package directory} +message configure {configure a prior installation of} +message timezone {Timezone} +message change_rootpw {Change root password} +message enable_binpkg {Enable installation of binary packages} +message enable_sshd {Enable sshd} +message enable_ntpd {Enable ntpd} +message run_ntpdate {Run ntpdate at boot} +message enable_mdnsd {Enable mdnsd} +message configmenu {Configure the additional items as needed.} +message doneconfig {Finished configuring} +message Install_pkgin {Install pkgin and update package summary} +message binpkg_installed +{You are now configured to use pkgin to install binary packages. To +install a package, run: + +pkgin install + +from a root shell. Read the pkgin(1) manual page for further information.} +message Install_pkgsrc {Fetch and unpack pkgsrc} +message pkgsrc +{Enabling binary packages with pkgin requires setting up the repository. +The following are the host, directory, user, and password that +will be used. If "user" is "ftp", then the password is not needed. + +} +message Pkgsrc_dir {pkgsrc directory} +message get_pkgsrc {Fetch and unpack pkgsrc for building from source} +message retry_pkgsrc_network {Network configuration failed. Retry?} Index: distrib/utils/sysinst/msg.mi.pl =================================================================== RCS file: /cvsroot/src/distrib/utils/sysinst/msg.mi.pl,v retrieving revision 1.78 diff -u -r1.78 msg.mi.pl --- distrib/utils/sysinst/msg.mi.pl 10 Jan 2012 21:02:47 -0000 1.78 +++ distrib/utils/sysinst/msg.mi.pl 23 Jan 2012 04:51:55 -0000 @@ -967,3 +967,43 @@ zawarta w pliku %s. Aby obejrzec ten plik, mozesz wpisac ^Z, przejrzec jego zawartosc, a nastepnie wpisac "fg".} + +message binpkg +{To configure the binary package system, please choose the network location +to fetch packages from. Once your system comes up, you can use 'pkgin' +to install additional packages, or remove packages.} + +message pkgpath +{The following are the protocol, host, directory, user, and password that +will be used. If "user" is "ftp", then the password is not needed. + +} +message Pkg_dir {Package directory} +message configure {configure a prior installation of} +message timezone {Timezone} +message change_rootpw {Change root password} +message enable_binpkg {Enable installation of binary packages} +message enable_sshd {Enable sshd} +message enable_ntpd {Enable ntpd} +message run_ntpdate {Run ntpdate at boot} +message enable_mdnsd {Enable mdnsd} +message configmenu {Configure the additional items as needed.} +message doneconfig {Finished configuring} +message Install_pkgin {Install pkgin and update package summary} +message binpkg_installed +{You are now configured to use pkgin to install binary packages. To +install a package, run: + +pkgin install + +from a root shell. Read the pkgin(1) manual page for further information.} +message Install_pkgsrc {Fetch and unpack pkgsrc} +message pkgsrc +{Enabling binary packages with pkgin requires setting up the repository. +The following are the host, directory, user, and password that +will be used. If "user" is "ftp", then the password is not needed. + +} +message Pkgsrc_dir {pkgsrc directory} +message get_pkgsrc {Fetch and unpack pkgsrc for building from source} +message retry_pkgsrc_network {Network configuration failed. Retry?} Index: distrib/utils/sysinst/net.c =================================================================== RCS file: /cvsroot/src/distrib/utils/sysinst/net.c,v retrieving revision 1.130 diff -u -r1.130 net.c --- distrib/utils/sysinst/net.c 10 Jan 2012 21:02:47 -0000 1.130 +++ distrib/utils/sysinst/net.c 23 Jan 2012 04:51:55 -0000 @@ -939,61 +939,91 @@ return network_up; } -static int -ftp_fetch(const char *set_name) +void +make_url(char *urlbuffer, struct ftpinfo *f, const char *dir) { - const char *ftp_opt; char ftp_user_encoded[STRSIZE]; char ftp_dir_encoded[STRSIZE]; char *cp; - const char *set_dir2; - int rval; + const char *dir2; /* - * Invoke ftp to fetch the file. - * - * ftp.pass is quite likely to contain unsafe characters + * f->pass is quite likely to contain unsafe characters * that need to be encoded in the URL (for example, * "@", ":" and "/" need quoting). Let's be - * paranoid and also encode ftp.user and ftp.dir. (For - * example, ftp.dir could easily contain '~', which is + * paranoid and also encode f->user and f->dir. (For + * example, f->dir could easily contain '~', which is * unsafe by a strict reading of RFC 1738). */ - if (strcmp("ftp", ftp.user) == 0 && ftp.pass[0] == 0) { - /* do anon ftp */ - ftp_opt = "-a "; + if (strcmp("ftp", f->user) == 0 && f->pass[0] == 0) { ftp_user_encoded[0] = 0; } else { - ftp_opt = ""; - cp = url_encode(ftp_user_encoded, ftp.user, + cp = url_encode(ftp_user_encoded, f->user, ftp_user_encoded + sizeof ftp_user_encoded - 1, RFC1738_SAFE_LESS_SHELL, 0); *cp++ = ':'; - cp = url_encode(cp, ftp.pass, + cp = url_encode(cp, f->pass, ftp_user_encoded + sizeof ftp_user_encoded - 1, NULL, 0); *cp++ = '@'; *cp = 0; } - - cp = url_encode(ftp_dir_encoded, ftp.dir, + cp = url_encode(ftp_dir_encoded, f->dir, ftp_dir_encoded + sizeof ftp_dir_encoded - 1, RFC1738_SAFE_LESS_SHELL_PLUS_SLASH, 1); if (cp != ftp_dir_encoded && cp[-1] != '/') *cp++ = '/'; - set_dir2 = set_dir_for_set(set_name); - while (*set_dir2 == '/') - ++set_dir2; + dir2 = dir; + while (*dir2 == '/') + ++dir2; - url_encode(cp, set_dir2, + url_encode(cp, dir2, ftp_dir_encoded + sizeof ftp_dir_encoded, RFC1738_SAFE_LESS_SHELL_PLUS_SLASH, 0); + snprintf(urlbuffer, STRSIZE, "%s://%s%s/%s", f->xfer_type, + ftp_user_encoded, f->host, ftp_dir_encoded); +} + + +/* ftp_fetch() and pkgsrc_fetch() are essentially the same, with a different + * ftpinfo var. */ +static int do_ftp_fetch(const char *, struct ftpinfo *); + +static int +ftp_fetch(const char *set_name) +{ + return do_ftp_fetch(set_name, &ftp); +} + +static int +pkgsrc_fetch(const char *set_name) +{ + return do_ftp_fetch(set_name, &pkgsrc); +} + +static int +do_ftp_fetch(const char *set_name, struct ftpinfo *f) +{ + const char *ftp_opt; + char url[STRSIZE]; + int rval; + + /* + * Invoke ftp to fetch the file. + */ + if (strcmp("ftp", f->user) == 0 && f->pass[0] == 0) { + /* do anon ftp */ + ftp_opt = "-a "; + } else { + ftp_opt = ""; + } + + make_url(url, f, set_dir_for_set(set_name)); rval = run_program(RUN_DISPLAY | RUN_PROGRESS | RUN_XFER_DIR, - "/usr/bin/ftp %s%s://%s%s/%s/%s%s", - ftp_opt, ftp.xfer_type, ftp_user_encoded, ftp.host, - ftp_dir_encoded, set_name, dist_postfix); + "/usr/bin/ftp %s%s/%s%s", + ftp_opt, url, set_name, dist_postfix); return rval ? SET_RETRY : SET_OK; } @@ -1021,6 +1051,22 @@ } int +get_pkgsrc(void) +{ + if (!network_up) + if (do_config_network() != 0) + return SET_RETRY; + + process_menu(MENU_pkgsrc, NULL); + + fetch_fn = pkgsrc_fetch; + snprintf(ext_dir_pkgsrc, sizeof ext_dir_pkgsrc, "%s/%s", + target_prefix(), xfer_dir + (*xfer_dir == '/')); + + return SET_OK; +} + +int get_via_ftp(const char *xfer_type) { Index: distrib/utils/sysinst/target.c =================================================================== RCS file: /cvsroot/src/distrib/utils/sysinst/target.c,v retrieving revision 1.54 diff -u -r1.54 target.c --- distrib/utils/sysinst/target.c 5 Jan 2012 21:29:25 -0000 1.54 +++ distrib/utils/sysinst/target.c 23 Jan 2012 04:51:55 -0000 @@ -538,3 +538,9 @@ return (target_test_symlink(path) == 0); } + +int +target_mounted(void) +{ + return (unwind_mountlist != NULL); +} Index: distrib/utils/sysinst/util.c =================================================================== RCS file: /cvsroot/src/distrib/utils/sysinst/util.c,v retrieving revision 1.173 diff -u -r1.173 util.c --- distrib/utils/sysinst/util.c 10 Jan 2012 21:02:47 -0000 1.173 +++ distrib/utils/sysinst/util.c 23 Jan 2012 04:51:55 -0000 @@ -287,7 +287,6 @@ * * replace("/etc/some-file.conf", "s/prop1=NO/prop1=YES/;s/foo/bar/"); */ -static void replace(const char *path, const char *patterns, ...) { @@ -858,7 +857,7 @@ * full path name to the directory. */ -static int +int extract_file(distinfo *dist, int update) { char path[STRSIZE]; @@ -909,7 +908,9 @@ if (update && (dist->set == SET_ETC || dist->set == SET_X11_ETC)) { make_target_dir("/.sysinst"); target_chdir_or_die("/.sysinst"); - } else + } else if (dist->set == SET_PKGSRC) + target_chdir_or_die("/usr"); + else target_chdir_or_die("/"); /* @@ -1181,7 +1182,7 @@ static char zoneinfo_dir[STRSIZE]; static int zonerootlen; static char *tz_selected; /* timezonename (relative to share/zoneinfo */ -static const char *tz_default; /* UTC, or whatever /etc/localtime points to */ +const char *tz_default; /* UTC, or whatever /etc/localtime points to */ static char tz_env[STRSIZE]; static int save_cursel, save_topline; @@ -1332,21 +1333,13 @@ qsort(tz_menu, nfiles, sizeof *tz_menu, tz_sort); } -/* - * Choose from the files in usr/share/zoneinfo and set etc/localtime - */ -int -set_timezone(void) +void +get_tz_default(void) { char localtime_link[STRSIZE]; - char localtime_target[STRSIZE]; + static char localtime_target[STRSIZE]; int rc; - time_t t; - int menu_no; - strlcpy(zoneinfo_dir, target_expand("/usr/share/zoneinfo/"), - sizeof zoneinfo_dir - 1); - zonerootlen = strlen(zoneinfo_dir); strlcpy(localtime_link, target_expand("/etc/localtime"), sizeof localtime_link); @@ -1363,6 +1356,24 @@ localtime_target[rc] = '\0'; tz_default = strchr(strstr(localtime_target, "zoneinfo"), '/') + 1; } +} + +/* + * Choose from the files in usr/share/zoneinfo and set etc/localtime + */ +int +set_timezone(void) +{ + char localtime_link[STRSIZE]; + char localtime_target[STRSIZE]; + time_t t; + int menu_no; + + strlcpy(zoneinfo_dir, target_expand("/usr/share/zoneinfo/"), + sizeof zoneinfo_dir - 1); + zonerootlen = strlen(zoneinfo_dir); + + get_tz_default(); tz_selected = strdup(tz_default); snprintf(tz_env, sizeof(tz_env), "%s%s", zoneinfo_dir, tz_selected); @@ -1389,6 +1400,8 @@ snprintf(localtime_target, sizeof(localtime_target), "/usr/share/zoneinfo/%s", tz_selected); + strlcpy(localtime_link, target_expand("/etc/localtime"), + sizeof localtime_link); unlink(localtime_link); symlink(localtime_target, localtime_link); @@ -1396,29 +1409,6 @@ return 1; } -int -set_root_password(void) -{ - - msg_display(MSG_rootpw); - process_menu(MENU_yesno, NULL); - if (yesno) - run_program(RUN_DISPLAY | RUN_PROGRESS | RUN_CHROOT, - "passwd -l root"); - return 0; -} - -int -set_root_shell(void) -{ - const char *shellpath; - - msg_display(MSG_rootsh); - process_menu(MENU_rootsh, &shellpath); - run_program(RUN_DISPLAY | RUN_CHROOT, "chpass -s %s root", shellpath); - return 0; -} - void scripting_vfprintf(FILE *f, const char *fmt, va_list ap) { @@ -1503,11 +1493,15 @@ const char * set_dir_for_set(const char *set_name) { + if (strcmp(set_name, "pkgsrc") == 0) + return pkgsrc_dir; return set_is_source(set_name) ? set_dir_src : set_dir_bin; } const char * ext_dir_for_set(const char *set_name) { + if (strcmp(set_name, "pkgsrc") == 0) + return ext_dir_pkgsrc; return set_is_source(set_name) ? ext_dir_src : ext_dir_bin; }