diff options
Diffstat (limited to 'usr.sbin')
118 files changed, 0 insertions, 39163 deletions
diff --git a/usr.sbin/lpr/filters.ru/koi2alt/koi2alt.c b/usr.sbin/lpr/filters.ru/koi2alt/koi2alt.c deleted file mode 100644 index 928e97eced86..000000000000 --- a/usr.sbin/lpr/filters.ru/koi2alt/koi2alt.c +++ /dev/null @@ -1,101 +0,0 @@ -/* - * Copyright (C) 1993-98 by Andrey A. Chernov, Moscow, Russia. - * 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 THE AUTHOR ``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 REGENTS 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. - */ - -/* - * KOI8-R -> CP866 conversion filter (Russian character sets) - */ - -#include <sys/types.h> -#include <signal.h> -#include <stdio.h> -#include <unistd.h> - -int length = 66; -int lines; - -char *koi2alt[] = { -/* 0 1 2 3 4 5 6 7 */ -/* 8 9 A B C D E F */ -/* 8 */ "\xc4","\xb3","\xda","\xbf","\xc0","\xd9","\xc3","\xb4", - "\xc2","\xc1","\xc5","\xdf","\xdc","\xdb","\xdd","\xde", -/* 9 */ "\xb0","\xb1","\xb2","\xb3","\xfe","\xf9","\xfb","-\b~", - "<\b_",">\b_","\xff","\xb3","\xf8","2\b-","\xfa",":\b-", -/* A */ "\xcd","\xba","\xd5","\xf1","\xd6","\xc9","\xb8","\xb7", - "\xbb","\xd4","\xd3","\xc8","\xbe","\xbd","\xbc","\xc6", -/* B */ "\xc7","\xcc","\xb5","\xf0","\xb6","\xb9","\xd1","\xd2", - "\xcb","\xcf","\xd0","\xca","\xd8","\xd7","\xce","c\b_", -/* C */ "\xee","\xa0","\xa1","\xe6","\xa4","\xa5","\xe4","\xa3", - "\xe5","\xa8","\xa9","\xaa","\xab","\xac","\xad","\xae", -/* D */ "\xaf","\xef","\xe0","\xe1","\xe2","\xe3","\xa6","\xa2", - "\xec","\xeb","\xa7","\xe8","\xed","\xe9","\xe7","\xea", -/* E */ "\x9e","\x80","\x81","\x96","\x84","\x85","\x94","\x83", - "\x95","\x88","\x89","\x8a","\x8b","\x8c","\x8d","\x8e", -/* F */ "\x8f","\x9f","\x90","\x91","\x92","\x93","\x86","\x82", - "\x9c","\x9b","\x87","\x98","\x9d","\x99","\x97","\x9a" -}; - -int main(int argc, char *argv[]) -{ - int c, i; - char *cp; - - while (--argc) { - if (*(cp = *++argv) == '-') { - switch (*++cp) { - case 'l': - if ((i = atoi(++cp)) > 0) - length = i; - break; - } - } - } - - while ((c = getchar()) != EOF) { - if (c == '\031') { - if ((c = getchar()) == '\1') { - lines = 0; - fflush(stdout); - kill(getpid(), SIGSTOP); - continue; - } else { - ungetc(c, stdin); - c = '\031'; - } - } else if (c & 0x80) { - fputs(koi2alt[c & 0x7F], stdout); - continue; - } else if (c == '\n') - lines++; - else if (c == '\f') - lines = length; - putchar(c); - if (lines >= length) { - lines = 0; - fflush(stdout); - } - } - return 0; -} diff --git a/usr.sbin/mount_portalfs/Makefile b/usr.sbin/mount_portalfs/Makefile deleted file mode 100644 index 7734df49eee6..000000000000 --- a/usr.sbin/mount_portalfs/Makefile +++ /dev/null @@ -1,13 +0,0 @@ -# From: @(#)Makefile 8.3 (Berkeley) 3/27/94 -# $Id: Makefile,v 1.8 1998/01/20 10:40:04 bde Exp $ - -PROG= mount_portal -SRCS= mount_portal.c activate.c conf.c getmntopts.c pt_conf.c \ - pt_exec.c pt_file.c pt_tcp.c pt_tcplisten.c -MAN8= mount_portal.8 - -MOUNT= ${.CURDIR}/../mount -CFLAGS+= -I${.CURDIR}/../../sys -I${MOUNT} -.PATH: ${MOUNT} - -.include <bsd.prog.mk> diff --git a/usr.sbin/mount_portalfs/activate.c b/usr.sbin/mount_portalfs/activate.c deleted file mode 100644 index 6eb0c582753a..000000000000 --- a/usr.sbin/mount_portalfs/activate.c +++ /dev/null @@ -1,214 +0,0 @@ -/* - * Copyright (c) 1992, 1993 - * The Regents of the University of California. All rights reserved. - * All rights reserved. - * - * This code is derived from software donated to Berkeley by - * Jan-Simon Pendry. - * - * 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. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS 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 REGENTS 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. - * - * @(#)activate.c 8.3 (Berkeley) 4/28/95 - */ - -#ifndef lint -static const char rcsid[] = - "$Id: activate.c,v 1.5 1998/07/06 07:19:23 charnier Exp $"; -#endif /* not lint */ - -#include <errno.h> -#include <string.h> -#include <unistd.h> -#include <sys/types.h> -#include <sys/param.h> -#include <sys/socket.h> -#include <sys/syslog.h> -#include <sys/uio.h> - -#include "portald.h" - -/* - * Scan the providers list and call the - * appropriate function. - */ -static int activate_argv(pcr, key, v, so, fdp) -struct portal_cred *pcr; -char *key; -char **v; -int so; -int *fdp; -{ - provider *pr; - - for (pr = providers; pr->pr_match; pr++) - if (strcmp(v[0], pr->pr_match) == 0) - return ((*pr->pr_func)(pcr, key, v, so, fdp)); - - return (ENOENT); -} - -static int get_request(so, pcr, key, klen) -int so; -struct portal_cred *pcr; -char *key; -int klen; -{ - struct iovec iov[2]; - struct msghdr msg; - int n; - - iov[0].iov_base = (caddr_t) pcr; - iov[0].iov_len = sizeof(*pcr); - iov[1].iov_base = key; - iov[1].iov_len = klen; - - memset(&msg, 0, sizeof(msg)); - msg.msg_iov = iov; - msg.msg_iovlen = 2; - - n = recvmsg(so, &msg, 0); - if (n < 0) - return (errno); - - if (n <= sizeof(*pcr)) - return (EINVAL); - - n -= sizeof(*pcr); - key[n] = '\0'; - - return (0); -} - -static void send_reply(so, fd, error) -int so; -int fd; -int error; -{ - int n; - struct iovec iov; - struct msghdr msg; - struct { - struct cmsghdr cmsg; - int fd; - } ctl; - - /* - * Line up error code. Don't worry about byte ordering - * because we must be sending to the local machine. - */ - iov.iov_base = (caddr_t) &error; - iov.iov_len = sizeof(error); - - /* - * Build a msghdr - */ - memset(&msg, 0, sizeof(msg)); - msg.msg_iov = &iov; - msg.msg_iovlen = 1; - - /* - * If there is a file descriptor to send then - * construct a suitable rights control message. - */ - if (fd >= 0) { - ctl.fd = fd; - ctl.cmsg.cmsg_len = sizeof(ctl); - ctl.cmsg.cmsg_level = SOL_SOCKET; - ctl.cmsg.cmsg_type = SCM_RIGHTS; - msg.msg_control = (caddr_t) &ctl; - msg.msg_controllen = ctl.cmsg.cmsg_len; - } - - /* - * Send to kernel... - */ - if ((n = sendmsg(so, &msg, 0)) < 0) - syslog(LOG_ERR, "send: %s", strerror(errno)); -#ifdef DEBUG - fprintf(stderr, "sent %d bytes\n", n); -#endif - sleep(1); /*XXX*/ -#ifdef notdef - if (shutdown(so, 2) < 0) - syslog(LOG_ERR, "shutdown: %s", strerror(errno)); -#endif - /* - * Throw away the open file descriptor - */ - (void) close(fd); -} - -void activate(q, so) -qelem *q; -int so; -{ - struct portal_cred pcred; - char key[MAXPATHLEN+1]; - int error; - char **v; - int fd = -1; - - /* - * Read the key from the socket - */ - error = get_request(so, &pcred, key, sizeof(key)); - if (error) { - syslog(LOG_ERR, "activate: recvmsg: %s", strerror(error)); - goto drop; - } - -#ifdef DEBUG - fprintf(stderr, "lookup key %s\n", key); -#endif - - /* - * Find a match in the configuration file - */ - v = conf_match(q, key); - - /* - * If a match existed, then find an appropriate portal - * otherwise simply return ENOENT. - */ - if (v) { - error = activate_argv(&pcred, key, v, so, &fd); - if (error) - fd = -1; - else if (fd < 0) - error = -1; - } else { - error = ENOENT; - } - - if (error >= 0) - send_reply(so, fd, error); - -drop:; - close(so); -} diff --git a/usr.sbin/mount_portalfs/conf.c b/usr.sbin/mount_portalfs/conf.c deleted file mode 100644 index 373e62d6fb47..000000000000 --- a/usr.sbin/mount_portalfs/conf.c +++ /dev/null @@ -1,340 +0,0 @@ -/* - * Copyright (c) 1992, 1993 - * The Regents of the University of California. All rights reserved. - * All rights reserved. - * - * This code is derived from software donated to Berkeley by - * Jan-Simon Pendry. - * - * 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. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS 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 REGENTS 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. - * - * @(#)conf.c 8.2 (Berkeley) 3/27/94 - */ - -#ifndef lint -static const char rcsid[] = - "$Id: conf.c,v 1.6 1998/07/06 07:19:24 charnier Exp $"; -#endif /* not lint */ - -#include <errno.h> -#include <limits.h> -#include <stdio.h> -#include <stdlib.h> -#include <string.h> -#include <unistd.h> -#include <regex.h> -#include <sys/types.h> -#include <sys/param.h> -#include <sys/syslog.h> - -#include "portald.h" - -#define ALLOC(ty) (xmalloc(sizeof(ty))) - -typedef struct path path; -struct path { - qelem p_q; /* 2-way linked list */ - int p_lno; /* Line number of this record */ - char *p_args; /* copy of arg string (malloc) */ - char *p_key; /* Pathname to match (also p_argv[0]) */ - regex_t p_rx; /* RE to match against pathname () */ - int p_rxvalid; /* non-zero if valid regular expression */ - int p_argc; /* number of elements in arg string */ - char **p_argv; /* argv[] pointers into arg string (malloc) */ -}; - -static char *conf_file; /* XXX for regerror */ -static path *curp; /* XXX for regerror */ - -/* - * Add an element to a 2-way list, - * just after (pred) - */ -static void ins_que(elem, pred) -qelem *elem, *pred; -{ - qelem *p = pred->q_forw; - elem->q_back = pred; - elem->q_forw = p; - pred->q_forw = elem; - p->q_back = elem; -} - -/* - * Remove an element from a 2-way list - */ -static void rem_que(elem) -qelem *elem; -{ - qelem *p = elem->q_forw; - qelem *p2 = elem->q_back; - p2->q_forw = p; - p->q_back = p2; -} - -/* - * Error checking malloc - */ -static void *xmalloc(siz) -unsigned siz; -{ - void *p = malloc(siz); - if (p) - return (p); - syslog(LOG_ALERT, "malloc: failed to get %d bytes", siz); - exit(1); -} - -/* - * Insert the path in the list. - * If there is already an element with the same key then - * the *second* one is ignored (return 0). If the key is - * not found then the path is added to the end of the list - * and 1 is returned. - */ -static int pinsert(p0, q0) -path *p0; -qelem *q0; -{ - qelem *q; - - if (p0->p_argc == 0) - return (0); - - for (q = q0->q_forw; q != q0; q = q->q_forw) { - path *p = (path *) q; - if (strcmp(p->p_key, p0->p_key) == 0) - return (0); - } - ins_que(&p0->p_q, q0->q_back); - return (1); - -} - -static path *palloc(cline, lno) -char *cline; -int lno; -{ - int c; - char *s; - char *key; - path *p; - char **ap; - - /* - * Implement comment chars - */ - s = strchr(cline, '#'); - if (s) - *s = 0; - - /* - * Do a pass through the string to count the number - * of arguments - */ - c = 0; - key = strdup(cline); - for (s = key; s != NULL; ) { - char *val; - while ((val = strsep(&s, " \t\n")) != NULL && *val == '\0') - ; - if (val) - c++; - } - c++; - free(key); - - if (c <= 1) - return (0); - - /* - * Now do another pass and generate a new path structure - */ - p = ALLOC(path); - p->p_argc = 0; - p->p_argv = xmalloc(c * sizeof(char *)); - p->p_args = strdup(cline); - ap = p->p_argv; - for (s = p->p_args; s != NULL; ) { - char *val; - while ((val = strsep(&s, " \t\n")) != NULL && *val == '\0') - ; - if (val) { - *ap++ = val; - p->p_argc++; - } - } - *ap = 0; - -#ifdef DEBUG - for (c = 0; c < p->p_argc; c++) - printf("%sv[%d] = %s\n", c?"\t":"", c, p->p_argv[c]); -#endif - - p->p_key = p->p_argv[0]; - if (strpbrk(p->p_key, RE_CHARS)) { - int val; - - curp = p; /* XXX */ - val = regcomp(&p->p_rx, p->p_key, REG_EXTENDED | REG_NOSUB); - if (val) { - char errbuf[_POSIX2_LINE_MAX]; - regerror(val, &p->p_rx, errbuf, sizeof errbuf); - syslog(LOG_ERR, "%s:%d: regcomp %s: %s", - conf_file, curp->p_lno, curp->p_key, errbuf); - regfree(&p->p_rx); - p->p_rxvalid = 0; - } else { - p->p_rxvalid = 1; - } - curp = 0; /* XXX */ - } else { - p->p_rxvalid = 0; - } - p->p_lno = lno; - - return (p); -} - -/* - * Free a path structure - */ -static void pfree(p) -path *p; -{ - free(p->p_args); - if (p->p_rxvalid) { - regfree(&p->p_rx); - } - free((char *) p->p_argv); - free((char *) p); -} - -/* - * Discard all currently held path structures on q0. - * and add all the ones on xq. - */ -static void preplace(q0, xq) -qelem *q0; -qelem *xq; -{ - /* - * While the list is not empty, - * take the first element off the list - * and free it. - */ - while (q0->q_forw != q0) { - qelem *q = q0->q_forw; - rem_que(q); - pfree((path *) q); - } - while (xq->q_forw != xq) { - qelem *q = xq->q_forw; - rem_que(q); - ins_que(q, q0); - } -} - -/* - * Read the lines from the configuration file and - * add them to the list of paths. - */ -static void readfp(q0, fp) -qelem *q0; -FILE *fp; -{ - char cline[LINE_MAX]; - int nread = 0; - qelem q; - - /* - * Make a new empty list. - */ - q.q_forw = q.q_back = &q; - - /* - * Read the lines from the configuration file. - */ - while (fgets(cline, sizeof(cline), fp)) { - path *p = palloc(cline, nread+1); - if (p && !pinsert(p, &q)) - pfree(p); - nread++; - } - - /* - * If some records were read, then throw - * away the old list and replace with the - * new one. - */ - if (nread) - preplace(q0, &q); -} - -/* - * Read the configuration file (conf) and replace - * the existing path list with the new version. - * If the file is not readable, then no changes take place - */ -void conf_read(q, conf) -qelem *q; -char *conf; -{ - FILE *fp = fopen(conf, "r"); - if (fp) { - conf_file = conf; /* XXX */ - readfp(q, fp); - conf_file = 0; /* XXX */ - (void) fclose(fp); - } else { - syslog(LOG_ERR, "open config file \"%s\": %s", conf, strerror(errno)); - } -} - - -char **conf_match(q0, key) -qelem *q0; -char *key; -{ - qelem *q; - - for (q = q0->q_forw; q != q0; q = q->q_forw) { - path *p = (path *) q; - if (p->p_rxvalid) { - if (!regexec(&p->p_rx, key, 0, 0, 0)) { - return p->p_argv + 1; - } - } else { - if (strncmp(p->p_key, key, strlen(p->p_key)) == 0) - return (p->p_argv+1); - } - } - - return (0); -} diff --git a/usr.sbin/mount_portalfs/mount_portalfs.8 b/usr.sbin/mount_portalfs/mount_portalfs.8 deleted file mode 100644 index 5a5750faf19f..000000000000 --- a/usr.sbin/mount_portalfs/mount_portalfs.8 +++ /dev/null @@ -1,149 +0,0 @@ -.\" -.\" Copyright (c) 1993, 1994 -.\" The Regents of the University of California. All rights reserved. -.\" All rights reserved. -.\" -.\" This code is derived from software donated to Berkeley by -.\" Jan-Simon Pendry. -.\" -.\" 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. -.\" 3. All advertising materials mentioning features or use of this software -.\" must display the following acknowledgement: -.\" This product includes software developed by the University of -.\" California, Berkeley and its contributors. -.\" 4. Neither the name of the University nor the names of its contributors -.\" may be used to endorse or promote products derived from this software -.\" without specific prior written permission. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS 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 REGENTS 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. -.\" -.\" @(#)mount_portal.8 8.3 (Berkeley) 3/27/94 -.\" $Id: mount_portal.8,v 1.3 1998/07/06 07:19:25 charnier Exp $ -.\" -.Dd March 27, 1994 -.Dt MOUNT_PORTAL 8 -.Os BSD 4.4 -.Sh NAME -.Nm mount_portal -.Nd mount the portal daemon -.Sh SYNOPSIS -.Nm mount_portal -.Op Fl o Ar options -.Ar /etc/portal.conf -.Ar mount_point -.Sh DESCRIPTION -The -.Nm -command attaches an instance of the portal daemon -to the global filesystem namespace. -The conventional mount point is -.Pa /p . -.\" .PA /dev . -This command is normally executed by -.Xr mount 8 -at boot time. -.Pp -The options are as follows: -.Bl -tag -width indent -.It Fl o -Options are specified with a -.Fl o -flag followed by a comma separated string of options. -See the -.Xr mount 8 -man page for possible options and their meanings. -.El -.Pp -The portal daemon provides an -.Em open -service. -Objects opened under the portal mount point are -dynamically created by the portal daemon according -to rules specified in the named configuration file. -Using this mechanism allows descriptors such as sockets -to be made available in the filesystem namespace. -.Pp -The portal daemon works by being passed the full pathname -of the object being opened. -The daemon creates an appropriate descriptor according -to the rules in the configuration file, and then passes the descriptor back -to the calling process as the result of the open system call. -.Sh NAMESPACE -By convention, the portal daemon divides the namespace into sub-namespaces, -each of which handles objects of a particular type. -.Pp -The following sub-namespaces are currently implemented: -.Pa tcplisten , -.Pa tcp -and -.Pa fs . -The -.Pa tcplisten -namespace takes a slash separated hostname and port and creates a TCP/IP -socket bound to the given hostname-port pair. The hostname may be -specified as "ANY" to allow any other host to connect to the socket. A -port number of 0 will dynamically allocate a port, this can be -discovered by calling -.Xr getsockname 8 -with the returned file descriptor. Privilaged ports can only be bound to -by the super-user. -The -.Pa tcp -namespace takes a hostname and a port (slash separated) and -creates an open TCP/IP connection. -The -.Pa fs -namespace opens the named file, starting back at the root directory. -This can be used to provide a controlled escape path from -a chrooted environment. -.Sh "CONFIGURATION FILE" -The configuration file contains a list of rules. -Each rule takes one line and consists of two or more -whitespace separated fields. -A hash (``#'') character causes the remainder of a line to -be ignored. Blank lines are ignored. -.Pp -The first field is a pathname prefix to match -against the requested pathname. -If a match is found, the second field -tells the daemon what type of object to create. -Subsequent fields are passed to the creation function. -.Bd -literal -# @(#)portal.conf 5.1 (Berkeley) 7/13/92 -tcplisten/ tcplisten tcplisten/ -tcp/ tcp tcp/ -fs/ file fs/ -.Ed -.Sh FILES -.Bl -tag -width /p/* -compact -.It Pa /p/* -.El -.Sh SEE ALSO -.Xr mount 2 , -.Xr unmount 2 , -.Xr fstab 5 , -.Xr mount 8 -.Sh CAVEATS -This filesystem may not be NFS-exported. -.Sh HISTORY -The -.Nm -utility first appeared in -.Bx 4.4 . diff --git a/usr.sbin/mount_portalfs/mount_portalfs.c b/usr.sbin/mount_portalfs/mount_portalfs.c deleted file mode 100644 index 6de71ea947e7..000000000000 --- a/usr.sbin/mount_portalfs/mount_portalfs.c +++ /dev/null @@ -1,293 +0,0 @@ -/* - * Copyright (c) 1992, 1993, 1994 - * The Regents of the University of California. All rights reserved. - * - * This code is derived from software donated to Berkeley by - * Jan-Simon Pendry. - * - * 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. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS 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 REGENTS 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. - */ - -#ifndef lint -char copyright[] = -"@(#) Copyright (c) 1992, 1993, 1994\n\ - The Regents of the University of California. All rights reserved.\n"; -#endif /* not lint */ - -#ifndef lint -#if 0 -static char sccsid[] = "@(#)mount_portal.c 8.6 (Berkeley) 4/26/95"; -#endif -static const char rcsid[] = - "$Id: mount_portal.c,v 1.13 1998/07/06 07:19:25 charnier Exp $"; -#endif /* not lint */ - -#include <sys/param.h> -#include <sys/wait.h> -#include <sys/socket.h> -#include <sys/un.h> -#include <sys/stat.h> -#include <sys/syslog.h> -#include <sys/mount.h> - -#include <err.h> -#include <errno.h> -#include <stdio.h> -#include <stdlib.h> -#include <string.h> -#include <sysexits.h> -#include <unistd.h> - -#include "mntopts.h" -#include "pathnames.h" -#include "portald.h" - -struct mntopt mopts[] = { - MOPT_STDOPTS, - { NULL } -}; - -static void usage __P((void)) __dead2; - -static sig_atomic_t readcf; /* Set when SIGHUP received */ - -static void sighup(sig) -int sig; -{ - readcf ++; -} - -static void sigchld(sig) -int sig; -{ - pid_t pid; - - while ((pid = waitpid((pid_t) -1, (int *) 0, WNOHANG)) > 0) - ; - /* wrtp - waitpid _doesn't_ return 0 when no children! */ -#ifdef notdef - if (pid < 0 && errno != ECHILD) - syslog(LOG_WARNING, "waitpid: %s", strerror(errno)); -#endif -} - -int -main(argc, argv) - int argc; - char *argv[]; -{ - struct portal_args args; - struct sockaddr_un un; - char *conf; - char *mountpt; - int mntflags = 0; - char tag[32]; - struct vfsconf vfc; - mode_t um; - - qelem q; - int rc; - int so; - int error = 0; - - /* - * Crack command line args - */ - int ch; - - while ((ch = getopt(argc, argv, "o:")) != -1) { - switch (ch) { - case 'o': - getmntopts(optarg, mopts, &mntflags, 0); - break; - default: - error = 1; - break; - } - } - - if (optind != (argc - 2)) - error = 1; - - if (error) - usage(); - - /* - * Get config file and mount point - */ - conf = argv[optind]; - mountpt = argv[optind+1]; - - /* - * Construct the listening socket - */ - un.sun_family = AF_UNIX; - if (sizeof(_PATH_TMPPORTAL) >= sizeof(un.sun_path)) { - errx(EX_SOFTWARE, "portal socket name too long"); - } - strcpy(un.sun_path, _PATH_TMPPORTAL); - mktemp(un.sun_path); - un.sun_len = strlen(un.sun_path); - - so = socket(AF_UNIX, SOCK_STREAM, 0); - if (so < 0) { - err(EX_OSERR, "socket"); - } - um = umask(077); - (void) unlink(un.sun_path); - if (bind(so, (struct sockaddr *) &un, sizeof(un)) < 0) - err(1, NULL); - - (void) unlink(un.sun_path); - (void) umask(um); - - (void) listen(so, 5); - - args.pa_socket = so; - sprintf(tag, "portal:%d", getpid()); - args.pa_config = tag; - - error = getvfsbyname("portal", &vfc); - if (error && vfsisloadable("portal")) { - if (vfsload("portal")) - err(EX_OSERR, "vfsload(portal)"); - endvfsent(); - error = getvfsbyname("portal", &vfc); - } - if (error) - errx(EX_OSERR, "portal filesystem is not available"); - - rc = mount(vfc.vfc_name, mountpt, mntflags, &args); - if (rc < 0) - err(1, NULL); - - /* - * Everything is ready to go - now is a good time to fork - */ -#ifndef DEBUG - daemon(0, 0); -#endif - - /* - * Start logging (and change name) - */ - openlog("portald", LOG_CONS|LOG_PID, LOG_DAEMON); - - q.q_forw = q.q_back = &q; - readcf = 1; - - signal(SIGCHLD, sigchld); - signal(SIGHUP, sighup); - - /* - * Just loop waiting for new connections and activating them - */ - for (;;) { - struct sockaddr_un un2; - int len2 = sizeof(un2); - int so2; - pid_t pid; - fd_set fdset; - int rc; - - /* - * Check whether we need to re-read the configuration file - */ - if (readcf) { -#ifdef DEBUG - printf ("re-reading configuration file\n"); -#endif - readcf = 0; - conf_read(&q, conf); - continue; - } - - /* - * Accept a new connection - * Will get EINTR if a signal has arrived, so just - * ignore that error code - */ - FD_ZERO(&fdset); - FD_SET(so, &fdset); - rc = select(so+1, &fdset, (fd_set *) 0, (fd_set *) 0, (struct timeval *) 0); - if (rc < 0) { - if (errno == EINTR) - continue; - syslog(LOG_ERR, "select: %s", strerror(errno)); - exit(EX_OSERR); - } - if (rc == 0) - break; - so2 = accept(so, (struct sockaddr *) &un2, &len2); - if (so2 < 0) { - /* - * The unmount function does a shutdown on the socket - * which will generated ECONNABORTED on the accept. - */ - if (errno == ECONNABORTED) - break; - if (errno != EINTR) { - syslog(LOG_ERR, "accept: %s", strerror(errno)); - exit(EX_OSERR); - } - continue; - } - - /* - * Now fork a new child to deal with the connection - */ - eagain:; - switch (pid = fork()) { - case -1: - if (errno == EAGAIN) { - sleep(1); - goto eagain; - } - syslog(LOG_ERR, "fork: %s", strerror(errno)); - break; - case 0: - (void) close(so); - activate(&q, so2); - exit(0); - default: - (void) close(so2); - break; - } - } - syslog(LOG_INFO, "%s unmounted", mountpt); - exit(0); -} - -static void -usage() -{ - (void)fprintf(stderr, - "usage: mount_portal [-o options] config mount-point\n"); - exit(EX_USAGE); -} diff --git a/usr.sbin/mount_portalfs/pathnames.h b/usr.sbin/mount_portalfs/pathnames.h deleted file mode 100644 index 3203b00c1483..000000000000 --- a/usr.sbin/mount_portalfs/pathnames.h +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright (c) 1992, 1993 - * The Regents of the University of California. All rights reserved. - * All rights reserved. - * - * This code is derived from software donated to Berkeley by - * Jan-Simon Pendry. - * - * 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. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS 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 REGENTS 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. - * - * @(#)pathnames.h 8.1 (Berkeley) 6/5/93 - * - * $Id$ - */ - -#include <paths.h> - -#define _PATH_TMPPORTAL "/tmp/portalXXXXXX" /* Scratch socket name */ diff --git a/usr.sbin/mount_portalfs/portal.conf b/usr.sbin/mount_portalfs/portal.conf deleted file mode 100644 index 3a4ddf0a1a9b..000000000000 --- a/usr.sbin/mount_portalfs/portal.conf +++ /dev/null @@ -1,7 +0,0 @@ -# @(#)portal.conf 8.1 (Berkeley) 6/5/93 -# $Id$ -tcplisten/ tcplisten tcplisten/ -tcp/ tcp tcp/ -fs/ file fs/ -pipe/ pipe -foo/ exec ./bar bar baz diff --git a/usr.sbin/mount_portalfs/portald.h b/usr.sbin/mount_portalfs/portald.h deleted file mode 100644 index f01e8a88ca78..000000000000 --- a/usr.sbin/mount_portalfs/portald.h +++ /dev/null @@ -1,84 +0,0 @@ -/* - * Copyright (c) 1992, 1993 - * The Regents of the University of California. All rights reserved. - * All rights reserved. - * - * This code is derived from software donated to Berkeley by - * Jan-Simon Pendry. - * - * 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. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS 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 REGENTS 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. - * - * @(#)portald.h 8.1 (Berkeley) 6/5/93 - * - * $Id: portald.h,v 1.3 1997/02/22 14:32:55 peter Exp $ - */ - -#include <sys/cdefs.h> -#include <miscfs/portal/portal.h> - -/* - * Meta-chars in an RE. Paths in the config file containing - * any of these characters will be matched using regexec, other - * paths will be prefix-matched. - */ -#define RE_CHARS ".|()[]*+?\\^$" - -typedef struct qelem qelem; - -struct qelem { - qelem *q_forw; - qelem *q_back; -}; - -typedef struct provider provider; -struct provider { - char *pr_match; - int (*pr_func) __P((struct portal_cred *, - char *key, char **v, int so, int *fdp)); -}; -extern provider providers[]; - -/* - * Portal providers - */ -extern int portal_exec __P((struct portal_cred *, - char *key, char **v, int so, int *fdp)); -extern int portal_file __P((struct portal_cred *, - char *key, char **v, int so, int *fdp)); -extern int portal_tcp __P((struct portal_cred *, - char *key, char **v, int so, int *fdp)); -extern int portal_tcplisten __P((struct portal_cred *, - char *key, char **v, int so, int *fdp)); - -/* - * Global functions - */ -extern void activate __P((qelem *q, int so)); -extern char **conf_match __P((qelem *q, char *key)); -extern void conf_read __P((qelem *q, char *conf)); diff --git a/usr.sbin/mount_portalfs/pt_conf.c b/usr.sbin/mount_portalfs/pt_conf.c deleted file mode 100644 index 11088ea2934d..000000000000 --- a/usr.sbin/mount_portalfs/pt_conf.c +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Copyright (c) 1992, 1993 - * The Regents of the University of California. All rights reserved. - * All rights reserved. - * - * This code is derived from software donated to Berkeley by - * Jan-Simon Pendry. - * - * 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. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS 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 REGENTS 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. - * - * @(#)pt_conf.c 8.1 (Berkeley) 6/5/93 - */ - -#ifndef lint -static const char rcsid[] = - "$Id: pt_conf.c,v 1.4 1998/07/06 07:19:25 charnier Exp $"; -#endif /* not lint */ - -#include <sys/types.h> -#include <sys/param.h> -#include "portald.h" - -provider providers[] = { - { "exec", portal_exec }, - { "file", portal_file }, - { "tcp", portal_tcp }, - { "tcplisten", portal_tcplisten }, - { 0, 0 } -}; diff --git a/usr.sbin/mount_portalfs/pt_exec.c b/usr.sbin/mount_portalfs/pt_exec.c deleted file mode 100644 index 6ee326d50a00..000000000000 --- a/usr.sbin/mount_portalfs/pt_exec.c +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Copyright (c) 1992, 1993 - * The Regents of the University of California. All rights reserved. - * All rights reserved. - * - * This code is derived from software donated to Berkeley by - * Jan-Simon Pendry. - * - * 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. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS 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 REGENTS 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. - * - * @(#)pt_exec.c 8.1 (Berkeley) 6/5/93 - */ - -#ifndef lint -static const char rcsid[] = - "$Id$"; -#endif /* not lint */ - -#include <errno.h> -#include <sys/types.h> -#include <sys/param.h> - -#include "portald.h" - -int portal_exec(pcr, key, v, so, fdp) -struct portal_cred *pcr; -char *key; -char **v; -int so; -int *fdp; -{ - return (ENOEXEC); -} - diff --git a/usr.sbin/mount_portalfs/pt_file.c b/usr.sbin/mount_portalfs/pt_file.c deleted file mode 100644 index 32207f31931e..000000000000 --- a/usr.sbin/mount_portalfs/pt_file.c +++ /dev/null @@ -1,109 +0,0 @@ -/* - * Copyright (c) 1992, 1993 - * The Regents of the University of California. All rights reserved. - * All rights reserved. - * - * This code is derived from software donated to Berkeley by - * Jan-Simon Pendry. - * - * 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. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS 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 REGENTS 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. - * - * @(#)pt_file.c 8.3 (Berkeley) 7/3/94 - */ - -#ifndef lint -static const char rcsid[] = - "$Id$"; -#endif /* not lint */ - -#include <errno.h> -#include <fcntl.h> -#include <string.h> -#include <unistd.h> -#include <sys/types.h> -#include <sys/param.h> -#include <sys/syslog.h> - -#include "portald.h" - -int portal_file(pcr, key, v, so, fdp) -struct portal_cred *pcr; -char *key; -char **v; -int so; -int *fdp; -{ - int fd; - char pbuf[MAXPATHLEN]; - int error; - gid_t gidset[NGROUPS]; - int i; - - pbuf[0] = '/'; - strcpy(pbuf+1, key + (v[1] ? strlen(v[1]) : 0)); - -#ifdef DEBUG - printf("path = %s, uid = %d, gid = %d\n", pbuf, pcr->pcr_uid, pcr->pcr_groups[0]); - printf ("fflag = %x, oflag = %x\n", pcr->pcr_flag, (pcr->pcr_flag)-1); -#endif - - for (i = 0; i < pcr->pcr_ngroups; i++) - gidset[i] = pcr->pcr_groups[i]; - - if (setgroups(pcr->pcr_ngroups, gidset) < 0) - return (errno); - - if (seteuid(pcr->pcr_uid) < 0) - return (errno); - - /* dmb convert kernel flags to oflags, see <fcntl.h> */ - fd = open(pbuf, (pcr->pcr_flag)-1, 0777); - if (fd < 0) - error = errno; - else - error = 0; - - if (seteuid((uid_t) 0) < 0) { /* XXX - should reset gidset too */ - error = errno; - syslog(LOG_ERR, "setcred: %s", strerror(error)); - if (fd >= 0) { - (void) close(fd); - fd = -1; - } - } - - if (error == 0) - *fdp = fd; - -#ifdef DEBUG - fprintf(stderr, "pt_file returns *fdp = %d, error = %d\n", *fdp, error); -#endif - - return (error); -} diff --git a/usr.sbin/mount_portalfs/pt_tcp.c b/usr.sbin/mount_portalfs/pt_tcp.c deleted file mode 100644 index 954388ee03fd..000000000000 --- a/usr.sbin/mount_portalfs/pt_tcp.c +++ /dev/null @@ -1,167 +0,0 @@ -/* - * Copyright (c) 1992, 1993, 1994 - * The Regents of the University of California. All rights reserved. - * All rights reserved. - * - * This code is derived from software donated to Berkeley by - * Jan-Simon Pendry. - * - * 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. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS 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 REGENTS 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. - * - * @(#)pt_tcp.c 8.5 (Berkeley) 4/28/95 - */ - -#ifndef lint -static const char rcsid[] = - "$Id: pt_tcp.c,v 1.7 1998/07/06 07:19:27 charnier Exp $"; -#endif /* not lint */ - -#include <errno.h> -#include <stdlib.h> -#include <strings.h> -#include <unistd.h> -#include <sys/types.h> -#include <sys/param.h> -#include <sys/syslog.h> -#include <sys/socket.h> -#include <netinet/in.h> -#include <arpa/inet.h> -#include <netdb.h> - -#include "portald.h" - -/* - * Key will be tcp/host/port[/"priv"] - * Create a TCP socket connected to the - * requested host and port. - * Some trailing suffix values have special meanings. - * An unrecognized suffix is an error. - */ -int portal_tcp(pcr, key, v, kso, fdp) - struct portal_cred *pcr; - char *key; - char **v; - int kso; - int *fdp; -{ - char host[MAXHOSTNAMELEN]; - char port[MAXHOSTNAMELEN]; - char *p = key + (v[1] ? strlen(v[1]) : 0); - char *q; - struct hostent *hp; - struct servent *sp; - struct in_addr **ipp; - struct in_addr *ip[2]; - struct in_addr ina; - u_short s_port; - int priv = 0; - struct sockaddr_in sain; - - q = strchr(p, '/'); - if (q == 0 || q - p >= sizeof(host)) - return (EINVAL); - *q = '\0'; - strcpy(host, p); - p = q + 1; - - q = strchr(p, '/'); - if (q) - *q = '\0'; - if (strlen(p) >= sizeof(port)) - return (EINVAL); - strcpy(port, p); - if (q) { - p = q + 1; - if (strcmp(p, "priv") == 0) { - if (pcr->pcr_uid == 0) - priv = 1; - else - return (EPERM); - } else { - return (EINVAL); - } - } - - hp = gethostbyname(host); - if (hp != 0) { - ipp = (struct in_addr **) hp->h_addr_list; - } else { - ina.s_addr = inet_addr(host); - if (ina.s_addr == INADDR_NONE) - return (EINVAL); - ip[0] = &ina; - ip[1] = 0; - ipp = ip; - } -#ifdef DEBUG - printf ("inet address for %s is %s\n", host, inet_ntoa(*ipp[0])); -#endif - - sp = getservbyname(port, "tcp"); - if (sp != NULL) { - s_port = (u_short)sp->s_port; - } else { - s_port = strtoul(port, &p, 0); - if (s_port == 0 || *p != '\0') - return (EINVAL); - s_port = htons(s_port); - } -#ifdef DEBUG - printf ("port number for %s is %d\n", port, (int)ntohs(s_port)); -#endif - - memset(&sain, 0, sizeof(sain)); - sain.sin_len = sizeof(sain); - sain.sin_family = AF_INET; - sain.sin_port = s_port; - - while (ipp[0]) { - int so; - - if (priv) - so = rresvport((int *) 0); - else - so = socket(AF_INET, SOCK_STREAM, 0); - if (so < 0) { - syslog(LOG_ERR, "socket: %m"); - return (errno); - } - - sain.sin_addr = *ipp[0]; - if (connect(so, (struct sockaddr *) &sain, sizeof(sain)) == 0) { - *fdp = so; - return (0); - } - (void) close(so); - - ipp++; - } - - return (errno); -} diff --git a/usr.sbin/mount_portalfs/pt_tcplisten.c b/usr.sbin/mount_portalfs/pt_tcplisten.c deleted file mode 100644 index 43a20c5aa92c..000000000000 --- a/usr.sbin/mount_portalfs/pt_tcplisten.c +++ /dev/null @@ -1,206 +0,0 @@ -/* - * Copyright (c) 1992, 1993 - * The Regents of the University of California. All rights reserved. - * All rights reserved. - * - * This code is derived from software donated to Berkeley by - * Jan-Simon Pendry. - * - * Modified by Duncan Barclay. - * - * 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. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS 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 REGENTS 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. - * - * @(#)pt_tcp.c 8.3 (Berkeley) 3/27/94 - * - * pt_tcp.c,v 1.1.1.1 1994/05/26 06:34:34 rgrimes Exp - */ - -#include <stdio.h> -#include <unistd.h> -#include <stdlib.h> -#include <errno.h> -#include <strings.h> -#include <sys/types.h> -#include <sys/param.h> -#include <sys/syslog.h> -#include <sys/socket.h> -#include <netinet/in.h> -#include <arpa/inet.h> -#include <netdb.h> - -#include "portald.h" - -/* - * Key will be tcplisten/host/port - * - * Create a TCP socket bound to the requested host and port. - * If the host is "ANY" the receving address will be set to INADDR_ANY. - * If the port is 0 the caller must find out the returned port number - * using a call to getsockname. - * - * XXX! The owner of the socket will be root rather then the user. This - * may cause remote auth (identd) to return unexpected results. - * - */ -int portal_tcplisten(pcr, key, v, kso, fdp) - struct portal_cred *pcr; - char *key; - char **v; - int kso; - int *fdp; -{ - char host[MAXHOSTNAMELEN]; - char port[MAXHOSTNAMELEN]; - char *p = key + (v[1] ? strlen(v[1]) : 0); - char *q; - struct hostent *hp; - struct servent *sp; - struct in_addr **ipp; - struct in_addr *ip[2]; - struct in_addr ina; - u_short s_port; - int any = 0; - struct sockaddr_in sain; - - q = strchr(p, '/'); - if (q == 0 || q - p >= sizeof(host)) - return (EINVAL); - *q = '\0'; - snprintf(host, sizeof(host), "%s", p); - p = q + 1; - - q = strchr(p, '/'); - if (q) - *q = '\0'; - if (strlen(p) >= sizeof(port)) - return (EINVAL); - snprintf(port, sizeof(port), "%s", p); - - if (strcmp(host, "ANY") == 0) { - any = 1; - } else { - hp = gethostbyname(host); - if (hp != 0) { - ipp = (struct in_addr **) hp->h_addr_list; - } else { - ina.s_addr = inet_addr(host); - if (ina.s_addr == INADDR_NONE) - return (EINVAL); - ip[0] = &ina; - ip[1] = 0; - ipp = ip; - } - } -#ifdef DEBUG - if (any) - printf("INADDR_ANY to be used for hostname\n"); - else - printf("inet address for %s is %s\n", host, inet_ntoa(*ipp[0])); -#endif - - sp = getservbyname(port, "tcp"); - if (sp != NULL) { - s_port = (u_short) sp->s_port; - } else { - s_port = strtoul(port, &p, 0); - if (*p != '\0') - return (EINVAL); - s_port = htons(s_port); - } - if ((ntohs(s_port) != 0) && - (ntohs(s_port) <= IPPORT_RESERVED) && - (pcr->pcr_uid != 0)) - return (EPERM); -#ifdef DEBUG - printf("port number for %s is %d\n", port, ntohs(s_port)); -#endif - - memset(&sain, 0, sizeof(sain)); - sain.sin_len = sizeof(sain); - sain.sin_family = AF_INET; - sain.sin_port = s_port; - - if (any) { - int so; - int sock; - - so = socket(AF_INET, SOCK_STREAM, 0); - if (so < 0) { - syslog(LOG_ERR, "socket: %m"); - return (errno); - } - - sain.sin_addr.s_addr = INADDR_ANY; - if (bind(so, (struct sockaddr *) &sain, sizeof(sain)) == 0) { - listen(so, 1); - if ((sock = accept(so, (struct sockaddr *)0, (int *)0)) == -1) { - syslog(LOG_ERR, "accept: %m"); - (void) close(so); - return (errno); - } - *fdp = sock; - (void) close(so); - return (0); - } - syslog(LOG_ERR, "bind: %m"); - (void) close(so); - return (errno); - } - - while (ipp[0]) { - int so; - int sock; - - so = socket(AF_INET, SOCK_STREAM, 0); - if (so < 0) { - syslog(LOG_ERR, "socket: %m"); - return (errno); - } - - sain.sin_addr = *ipp[0]; - if (bind(so, (struct sockaddr *) &sain, sizeof(sain)) == 0) { - listen(so, 1); - if ((sock = accept(so, (struct sockaddr *)0, (int *)0)) == -1) { - syslog(LOG_ERR, "accept: %m"); - (void) close(so); - return (errno); - } - *fdp = sock; - (void) close(so); - return (0); - } - (void) close(so); - - ipp++; - } - - syslog(LOG_ERR, "bind: %m"); - return (errno); - -} diff --git a/usr.sbin/mountd/Makefile b/usr.sbin/mountd/Makefile deleted file mode 100644 index 6a2097a91afe..000000000000 --- a/usr.sbin/mountd/Makefile +++ /dev/null @@ -1,9 +0,0 @@ -# From: @(#)Makefile 8.3 (Berkeley) 1/25/94 -# $Id: Makefile,v 1.7 1997/03/11 12:43:42 peter Exp $ - -PROG= mountd -CFLAGS+=-DNFS -DMFS -DCD9660 -DMSDOSFS -MAN5= exports.5 netgroup.5 -MAN8= mountd.8 - -.include <bsd.prog.mk> diff --git a/usr.sbin/mountd/exports.5 b/usr.sbin/mountd/exports.5 deleted file mode 100644 index 470c7d52a2c1..000000000000 --- a/usr.sbin/mountd/exports.5 +++ /dev/null @@ -1,293 +0,0 @@ -.\" Copyright (c) 1989, 1991, 1993 -.\" The Regents of the University of California. 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. -.\" 3. All advertising materials mentioning features or use of this software -.\" must display the following acknowledgement: -.\" This product includes software developed by the University of -.\" California, Berkeley and its contributors. -.\" 4. Neither the name of the University nor the names of its contributors -.\" may be used to endorse or promote products derived from this software -.\" without specific prior written permission. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS 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 REGENTS 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. -.\" -.\" @(#)exports.5 8.3 (Berkeley) 3/29/95 -.\" $Id: exports.5,v 1.6 1997/07/16 09:27:50 dfr Exp $ -.\" -.Dd March 29, 1995 -.Dt EXPORTS 5 -.Os -.Sh NAME -.Nm exports -.Nd define remote mount points for -.Tn NFS -mount requests -.Sh SYNOPSIS -.Nm exports -.Sh DESCRIPTION -The -.Nm -file specifies remote mount points for the -.Tn NFS -mount protocol per the -.Tn NFS -server specification; see -.%T "Network File System Protocol Specification \\*(tNRFC\\*(sP 1094, Appendix A" -and -.%T "NFS: Network File System Version 3 Specification, Appendix I" . -.Pp -Each line in the file -(other than comment lines that begin with a #) -specifies the mount point(s) and export flags within one local server -filesystem for one or more hosts. -A host may be specified only once for each local filesystem on the -server and there may be only one default entry for each server -filesystem that applies to all other hosts. -The latter exports the filesystem to the ``world'' and should -be used only when the filesystem contains public information. -.Pp -In a mount entry, -the first field(s) specify the directory path(s) within a server filesystem -that can be mounted on by the corresponding client(s). -There are two forms of this specification. -The first is to list all mount points as absolute -directory paths separated by whitespace. -The second is to specify the pathname of the root of the filesystem -followed by the -.Fl alldirs -flag; -this form allows the host(s) to mount at any point within the filesystem, -including regular files if the -.Fl r -option is used on mountd. -The pathnames must not have any symbolic links in them and should not have -any "." or ".." components. -Mount points for a filesystem may appear on multiple lines each with -different sets of hosts and export options. -.Pp -The second component of a line specifies how the filesystem is to be -exported to the host set. -The option flags specify whether the filesystem -is exported read-only or read-write and how the client uid is mapped to -user credentials on the server. -.Pp -Export options are specified as follows: -.Pp -.Sm off -.Fl maproot No = Sy user -.Sm on -The credential of the specified user is used for remote access by root. -The credential includes all the groups to which the user is a member -on the local machine (see -.Xr id 1 ). -The user may be specified by name or number. -.Pp -.Sm off -.Fl maproot No = Sy user:group1:group2:... -.Sm on -The colon separated list is used to specify the precise credential -to be used for remote access by root. -The elements of the list may be either names or numbers. -Note that user: should be used to distinguish a credential containing -no groups from a complete credential for that user. -.Pp -.Sm off -.Fl mapall No = Sy user -.Sm on -or -.Sm off -.Fl mapall No = Sy user:group1:group2:... -.Sm on -specifies a mapping for all client uids (including root) -using the same semantics as -.Fl maproot . -.Pp -The option -.Fl r -is a synonym for -.Fl maproot -in an effort to be backward compatible with older export file formats. -.Pp -In the absence of -.Fl maproot -and -.Fl mapall -options, remote accesses by root will result in using a credential of -2:-2. -All other users will be mapped to their remote credential. -If a -.Fl maproot -option is given, -remote access by root will be mapped to that credential instead of -2:-2. -If a -.Fl mapall -option is given, -all users (including root) will be mapped to that credential in -place of their own. -.Pp -The -.Fl kerb -option specifies that the Kerberos authentication server should be -used to authenticate and map client credentials. -This option requires that the kernel be built with the NFSKERB option. -.Pp -The -.Fl ro -option specifies that the filesystem should be exported read-only -(default read/write). -The option -.Fl o -is a synonym for -.Fl ro -in an effort to be backward compatible with older export file formats. -.Pp -.Tn WebNFS -exports strictly according to the spec (RFC 2054 and RFC 2055) can -be done with the -.Fl public -flag. However, this flag in itself allows r/w access to all files in -the filesystem, not requiring reserved ports and not remapping uids. It -is only provided to conform to the spec, and should normally not be used. -For a -.Tn WebNFS -export, -use the -.Fl webnfs -flag, which implies -.Fl public , -.Sm off -.Fl mapall No = Sy nobody -.Sm on -and -.Fl ro . -.Pp -A -.Sm off -.Fl index No = Sy file -.Sm on -option can be used to specify a file whose handle will be returned if -a directory is looked up using the public filehandle ( -.Tn WebNFS Ns ). -This is to mimic the behavior of URLs. If no -.Fl index -option is specified, a directory filehandle will be returned as usual. -The -.Fl index -option only makes sense in combination with the -.Fl public -or -.Fl webnfs -flags. -.Pp -The third component of a line specifies the host set to which the line applies. -The set may be specified in three ways. -The first way is to list the host name(s) separated by white space. -(Standard Internet ``dot'' addresses may be used in place of names.) -The second way is to specify a ``netgroup'' as defined in the netgroup file (see -.Xr netgroup 5 ). -The third way is to specify an Internet subnetwork using a network and -network mask that is defined as the set of all hosts with addresses within -the subnetwork. -This latter approach requires less overhead within the -kernel and is recommended for cases where the export line refers to a -large number of clients within an administrative subnet. -.Pp -The first two cases are specified by simply listing the name(s) separated -by whitespace. -All names are checked to see if they are ``netgroup'' names -first and are assumed to be hostnames otherwise. -Using the full domain specification for a hostname can normally -circumvent the problem of a host that has the same name as a netgroup. -The third case is specified by the flag -.Sm off -.Fl network No = Sy netname -.Sm on -and optionally -.Sm off -.Fl mask No = Sy netmask . -.Sm on -If the mask is not specified, it will default to the mask for that network -class (A, B or C; see -.Xr inet 4 ). -.Pp -For example: -.Bd -literal -offset indent -/usr /usr/local -maproot=0:10 friends -/usr -maproot=daemon grumpy.cis.uoguelph.ca 131.104.48.16 -/usr -ro -mapall=nobody -/u -maproot=bin: -network 131.104.48 -mask 255.255.255.0 -/u2 -maproot=root friends -/u2 -alldirs -kerb -network cis-net -mask cis-mask -.Ed -.Pp -Given that -.Sy /usr , -.Sy /u -and -.Sy /u2 -are -local filesystem mount points, the above example specifies the following: -.Sy /usr -is exported to hosts -.Em friends -where friends is specified in the netgroup file -with users mapped to their remote credentials and -root mapped to uid 0 and group 10. -It is exported read-write and the hosts in ``friends'' can mount either /usr -or /usr/local. -It is exported to -.Em 131.104.48.16 -and -.Em grumpy.cis.uoguelph.ca -with users mapped to their remote credentials and -root mapped to the user and groups associated with ``daemon''; -it is exported to the rest of the world as read-only with -all users mapped to the user and groups associated with ``nobody''. -.Pp -.Sy /u -is exported to all hosts on the subnetwork -.Em 131.104.48 -with root mapped to the uid for ``bin'' and with no group access. -.Pp -.Sy /u2 -is exported to the hosts in ``friends'' with root mapped to uid and groups -associated with ``root''; -it is exported to all hosts on network ``cis-net'' allowing mounts at any -directory within /u2 and mapping all uids to credentials for the principal -that is authenticated by a Kerberos ticket. -.Sh FILES -.Bl -tag -width /etc/exports -compact -.It Pa /etc/exports -the default remote mount-point file -.El -.Sh SEE ALSO -.Xr netgroup 5 , -.Xr mountd 8 , -.Xr nfsd 8 , -.Xr showmount 8 -.Sh BUGS -The export options are tied to the local mount points in the kernel and -must be non-contradictory for any exported subdirectory of the local -server mount point. -It is recommended that all exported directories within the same server -filesystem be specified on adjacent lines going down the tree. -You cannot specify a hostname that is also the name of a netgroup. -Specifying the full domain specification for a hostname can normally -circumvent the problem. diff --git a/usr.sbin/mountd/mountd.8 b/usr.sbin/mountd/mountd.8 deleted file mode 100644 index 91404f967be3..000000000000 --- a/usr.sbin/mountd/mountd.8 +++ /dev/null @@ -1,147 +0,0 @@ -.\" Copyright (c) 1989, 1991, 1993 -.\" The Regents of the University of California. 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. -.\" 3. All advertising materials mentioning features or use of this software -.\" must display the following acknowledgement: -.\" This product includes software developed by the University of -.\" California, Berkeley and its contributors. -.\" 4. Neither the name of the University nor the names of its contributors -.\" may be used to endorse or promote products derived from this software -.\" without specific prior written permission. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS 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 REGENTS 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. -.\" -.\" @(#)mountd.8 8.4 (Berkeley) 4/28/95 -.\" $Id: mountd.8,v 1.13 1998/07/15 06:21:39 charnier Exp $ -.\" -.Dd April 28, 1995 -.Dt MOUNTD 8 -.Os -.Sh NAME -.Nm mountd -.Nd service remote -.Tn NFS -mount requests -.Sh SYNOPSIS -.Nm mountd -.Op Fl 2dlnr -.Op Ar exportsfile -.Sh DESCRIPTION -.Nm Mountd -is the server for -.Tn NFS -mount requests from other client machines. -It listens for service requests at the port indicated in the -.Tn NFS -server specification; see -.%T "Network File System Protocol Specification" , -RFC1094, Appendix A and -.%T "NFS: Network File System Version 3 Protocol Specification" , -Appendix I. -.Pp -The following options are available: -.Bl -tag -width indent -.It Fl 2 -Allow the administrator to force clients to use only the -version 2 -.Tn NFS -protocol to mount filesystems from this server. -.It Fl d -Output debugging information. -.It Fl l -Cause all succeeded -.Nm -requests to be logged. -.It Fl n -Allow non-root mount requests to be served. -This should only be specified if there are clients such as PC's, -that require it. -It will automatically clear the vfs.nfs.nfs_privport sysctl flag, which -controls if the kernel will accept NFS requests from reserved ports only. -.It Fl r -Allow mount RPCs requests for regular files to be served. -Although this seems to violate the mount protocol specification, -some diskless workstations do mount requests for -their swapfiles and expect them to be regular files. -Since a regular file cannot be specified in -.Pa /etc/exports , -the entire file system in which the swapfiles resides -will have to be exported with the -.Fl alldirs -flag. -.It Ar exportsfile -Specify an alternate location -for the exports file. -.El -.Pp -When -.Nm -is started, -it loads the export host addresses and options into the kernel -using the mount(2) system call. -After changing the exports file, -a hangup signal should be sent to the -.Nm -daemon -to get it to reload the export information. -After sending the SIGHUP -(kill \-s HUP `cat /var/run/mountd.pid`), -check the syslog output to see if -.Nm -logged any parsing -errors in the exports file. -.Pp -If -.Nm -detects that the running kernel does not include -.Tn NFS -support, it will attempt to load a loadable kernel module containing -.Tn NFS -code, using -.Xr modload 8 -by way of -.Xr vfsload 3 . -If this fails, or no -.Tn NFS -LKM was available, -.Nm -exits with an error. -.Sh FILES -.Bl -tag -width /var/run/mountd.pid -compact -.It Pa /etc/exports -the list of exported filesystems -.It Pa /var/run/mountd.pid -the pid of the currently running mountd -.It Pa /var/db/mountdtab -the current list of remote mounted filesystems -.El -.Sh SEE ALSO -.Xr nfsstat 1 , -.Xr exports 5 , -.Xr modload 8 , -.Xr nfsd 8 , -.Xr portmap 8 , -.Xr showmount 8 -.Sh HISTORY -The -.Nm -utility first appeared in -.Bx 4.4 . diff --git a/usr.sbin/mountd/mountd.c b/usr.sbin/mountd/mountd.c deleted file mode 100644 index ab9fdc7c8363..000000000000 --- a/usr.sbin/mountd/mountd.c +++ /dev/null @@ -1,2211 +0,0 @@ -/* - * Copyright (c) 1989, 1993 - * The Regents of the University of California. All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * Herb Hasler and Rick Macklem at The University of Guelph. - * - * 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. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS 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 REGENTS 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. - */ - -#ifndef lint -static const char copyright[] = -"@(#) Copyright (c) 1989, 1993\n\ - The Regents of the University of California. All rights reserved.\n"; -#endif /*not lint*/ - -#ifndef lint -#if 0 -static char sccsid[] = "@(#)mountd.c 8.15 (Berkeley) 5/1/95"; -#endif -static const char rcsid[] = - "$Id: mountd.c,v 1.33 1998/08/02 16:06:34 bde Exp $"; -#endif /*not lint*/ - -#include <sys/param.h> -#include <sys/mount.h> -#include <sys/stat.h> -#include <sys/syslog.h> -#include <sys/sysctl.h> - -#include <rpc/rpc.h> -#include <rpc/pmap_clnt.h> -#ifdef ISO -#include <netiso/iso.h> -#endif -#include <nfs/rpcv2.h> -#include <nfs/nfsproto.h> -#include <nfs/nfs.h> -#include <ufs/ufs/ufsmount.h> -#include <msdosfs/msdosfsmount.h> -#include <isofs/cd9660/cd9660_mount.h> /* XXX need isofs in include */ - -#include <arpa/inet.h> - -#include <ctype.h> -#include <err.h> -#include <errno.h> -#include <grp.h> -#include <netdb.h> -#include <pwd.h> -#include <signal.h> -#include <stdio.h> -#include <stdlib.h> -#include <string.h> -#include <unistd.h> -#include "pathnames.h" - -#ifdef DEBUG -#include <stdarg.h> -#endif - -/* - * Structures for keeping the mount list and export list - */ -struct mountlist { - struct mountlist *ml_next; - char ml_host[RPCMNT_NAMELEN+1]; - char ml_dirp[RPCMNT_PATHLEN+1]; -}; - -struct dirlist { - struct dirlist *dp_left; - struct dirlist *dp_right; - int dp_flag; - struct hostlist *dp_hosts; /* List of hosts this dir exported to */ - char dp_dirp[1]; /* Actually malloc'd to size of dir */ -}; -/* dp_flag bits */ -#define DP_DEFSET 0x1 -#define DP_HOSTSET 0x2 -#define DP_KERB 0x4 - -struct exportlist { - struct exportlist *ex_next; - struct dirlist *ex_dirl; - struct dirlist *ex_defdir; - int ex_flag; - fsid_t ex_fs; - char *ex_fsdir; - char *ex_indexfile; -}; -/* ex_flag bits */ -#define EX_LINKED 0x1 - -struct netmsk { - u_int32_t nt_net; - u_int32_t nt_mask; - char *nt_name; -}; - -union grouptypes { - struct hostent *gt_hostent; - struct netmsk gt_net; -#ifdef ISO - struct sockaddr_iso *gt_isoaddr; -#endif -}; - -struct grouplist { - int gr_type; - union grouptypes gr_ptr; - struct grouplist *gr_next; -}; -/* Group types */ -#define GT_NULL 0x0 -#define GT_HOST 0x1 -#define GT_NET 0x2 -#define GT_ISO 0x4 -#define GT_IGNORE 0x5 - -struct hostlist { - int ht_flag; /* Uses DP_xx bits */ - struct grouplist *ht_grp; - struct hostlist *ht_next; -}; - -struct fhreturn { - int fhr_flag; - int fhr_vers; - nfsfh_t fhr_fh; -}; - -/* Global defs */ -char *add_expdir __P((struct dirlist **, char *, int)); -void add_dlist __P((struct dirlist **, struct dirlist *, - struct grouplist *, int)); -void add_mlist __P((char *, char *)); -int check_dirpath __P((char *)); -int check_options __P((struct dirlist *)); -int chk_host __P((struct dirlist *, u_int32_t, int *, int *)); -void del_mlist __P((char *, char *)); -struct dirlist *dirp_search __P((struct dirlist *, char *)); -int do_mount __P((struct exportlist *, struct grouplist *, int, - struct ucred *, char *, int, struct statfs *)); -int do_opt __P((char **, char **, struct exportlist *, struct grouplist *, - int *, int *, struct ucred *)); -struct exportlist *ex_search __P((fsid_t *)); -struct exportlist *get_exp __P((void)); -void free_dir __P((struct dirlist *)); -void free_exp __P((struct exportlist *)); -void free_grp __P((struct grouplist *)); -void free_host __P((struct hostlist *)); -void get_exportlist __P((void)); -int get_host __P((char *, struct grouplist *, struct grouplist *)); -int get_num __P((char *)); -struct hostlist *get_ht __P((void)); -int get_line __P((void)); -void get_mountlist __P((void)); -int get_net __P((char *, struct netmsk *, int)); -void getexp_err __P((struct exportlist *, struct grouplist *)); -struct grouplist *get_grp __P((void)); -void hang_dirp __P((struct dirlist *, struct grouplist *, - struct exportlist *, int)); -void mntsrv __P((struct svc_req *, SVCXPRT *)); -void nextfield __P((char **, char **)); -void out_of_mem __P((void)); -void parsecred __P((char *, struct ucred *)); -int put_exlist __P((struct dirlist *, XDR *, struct dirlist *, int *)); -int scan_tree __P((struct dirlist *, u_int32_t)); -void send_umntall __P((void)); -int umntall_each __P((caddr_t, struct sockaddr_in *)); -static void usage __P((void)); -int xdr_dir __P((XDR *, char *)); -int xdr_explist __P((XDR *, caddr_t)); -int xdr_fhs __P((XDR *, caddr_t)); -int xdr_mlist __P((XDR *, caddr_t)); - -/* C library */ -int getnetgrent(); -void endnetgrent(); -void setnetgrent(); - -#ifdef ISO -struct iso_addr *iso_addr(); -#endif - -struct exportlist *exphead; -struct mountlist *mlhead; -struct grouplist *grphead; -char exname[MAXPATHLEN]; -struct ucred def_anon = { - 1, - (uid_t) -2, - 1, - { (gid_t) -2 } -}; -int force_v2 = 0; -int resvport_only = 1; -int dir_only = 1; -int log = 0; -int opt_flags; -/* Bits for above */ -#define OP_MAPROOT 0x01 -#define OP_MAPALL 0x02 -#define OP_KERB 0x04 -#define OP_MASK 0x08 -#define OP_NET 0x10 -#define OP_ISO 0x20 -#define OP_ALLDIRS 0x40 - -#ifdef DEBUG -int debug = 1; -void SYSLOG __P((int, const char *, ...)); -#define syslog SYSLOG -#else -int debug = 0; -#endif - -/* - * Mountd server for NFS mount protocol as described in: - * NFS: Network File System Protocol Specification, RFC1094, Appendix A - * The optional arguments are the exports file name - * default: _PATH_EXPORTS - * and "-n" to allow nonroot mount. - */ -int -main(argc, argv) - int argc; - char **argv; -{ - SVCXPRT *udptransp, *tcptransp; - int c, error, mib[3]; - struct vfsconf vfc; - - error = getvfsbyname("nfs", &vfc); - if (error && vfsisloadable("nfs")) { - if(vfsload("nfs")) - err(1, "vfsload(nfs)"); - endvfsent(); /* flush cache */ - error = getvfsbyname("nfs", &vfc); - } - if (error) - errx(1, "NFS support is not available in the running kernel"); - - while ((c = getopt(argc, argv, "2dlnr")) != -1) - switch (c) { - case '2': - force_v2 = 1; - break; - case 'n': - resvport_only = 0; - break; - case 'r': - dir_only = 0; - break; - case 'd': - debug = debug ? 0 : 1; - break; - case 'l': - log = 1; - break; - default: - usage(); - }; - argc -= optind; - argv += optind; - grphead = (struct grouplist *)NULL; - exphead = (struct exportlist *)NULL; - mlhead = (struct mountlist *)NULL; - if (argc == 1) { - strncpy(exname, *argv, MAXPATHLEN-1); - exname[MAXPATHLEN-1] = '\0'; - } else - strcpy(exname, _PATH_EXPORTS); - openlog("mountd", LOG_PID, LOG_DAEMON); - if (debug) - warnx("getting export list"); - get_exportlist(); - if (debug) - warnx("getting mount list"); - get_mountlist(); - if (debug) - warnx("here we go"); - if (debug == 0) { - daemon(0, 0); - signal(SIGINT, SIG_IGN); - signal(SIGQUIT, SIG_IGN); - } - signal(SIGHUP, (void (*) __P((int))) get_exportlist); - signal(SIGTERM, (void (*) __P((int))) send_umntall); - { FILE *pidfile = fopen(_PATH_MOUNTDPID, "w"); - if (pidfile != NULL) { - fprintf(pidfile, "%d\n", getpid()); - fclose(pidfile); - } - } - if (!resvport_only) { - mib[0] = CTL_VFS; - mib[1] = vfc.vfc_typenum; - mib[2] = NFS_NFSPRIVPORT; - if (sysctl(mib, 3, NULL, NULL, &resvport_only, - sizeof(resvport_only)) != 0 && errno != ENOENT) { - syslog(LOG_ERR, "sysctl: %m"); - exit(1); - } - } - if ((udptransp = svcudp_create(RPC_ANYSOCK)) == NULL || - (tcptransp = svctcp_create(RPC_ANYSOCK, 0, 0)) == NULL) { - syslog(LOG_ERR, "can't create socket"); - exit(1); - } - pmap_unset(RPCPROG_MNT, 1); - pmap_unset(RPCPROG_MNT, 3); - if (!force_v2) - if (!svc_register(udptransp, RPCPROG_MNT, 3, mntsrv, IPPROTO_UDP) || - !svc_register(tcptransp, RPCPROG_MNT, 3, mntsrv, IPPROTO_TCP)) { - syslog(LOG_ERR, "can't register mount"); - exit(1); - } - if (!svc_register(udptransp, RPCPROG_MNT, 1, mntsrv, IPPROTO_UDP) || - !svc_register(tcptransp, RPCPROG_MNT, 1, mntsrv, IPPROTO_TCP)) { - syslog(LOG_ERR, "can't register mount"); - exit(1); - } - svc_run(); - syslog(LOG_ERR, "mountd died"); - exit(1); -} - -static void -usage() -{ - fprintf(stderr, - "usage: mountd [-2] [-d] [-l] [-n] [-r] [export_file]\n"); - exit(1); -} - -/* - * The mount rpc service - */ -void -mntsrv(rqstp, transp) - struct svc_req *rqstp; - SVCXPRT *transp; -{ - struct exportlist *ep; - struct dirlist *dp; - struct fhreturn fhr; - struct stat stb; - struct statfs fsb; - struct hostent *hp; - struct in_addr saddrin; - u_int32_t saddr; - u_short sport; - char rpcpath[RPCMNT_PATHLEN + 1], dirpath[MAXPATHLEN]; - int bad = 0, defset, hostset; - sigset_t sighup_mask; - - sigemptyset(&sighup_mask); - sigaddset(&sighup_mask, SIGHUP); - saddr = transp->xp_raddr.sin_addr.s_addr; - saddrin = transp->xp_raddr.sin_addr; - sport = ntohs(transp->xp_raddr.sin_port); - hp = (struct hostent *)NULL; - switch (rqstp->rq_proc) { - case NULLPROC: - if (!svc_sendreply(transp, xdr_void, (caddr_t)NULL)) - syslog(LOG_ERR, "can't send reply"); - return; - case RPCMNT_MOUNT: - if (sport >= IPPORT_RESERVED && resvport_only) { - syslog(LOG_NOTICE, - "mount request from %s from unprivileged port", - inet_ntoa(saddrin)); - svcerr_weakauth(transp); - return; - } - if (!svc_getargs(transp, xdr_dir, rpcpath)) { - syslog(LOG_NOTICE, "undecodable mount request from %s", - inet_ntoa(saddrin)); - svcerr_decode(transp); - return; - } - - /* - * Get the real pathname and make sure it is a directory - * or a regular file if the -r option was specified - * and it exists. - */ - if (realpath(rpcpath, dirpath) == 0 || - stat(dirpath, &stb) < 0 || - (!S_ISDIR(stb.st_mode) && - (dir_only || !S_ISREG(stb.st_mode))) || - statfs(dirpath, &fsb) < 0) { - chdir("/"); /* Just in case realpath doesn't */ - syslog(LOG_NOTICE, - "mount request from %s for non existent path %s", - inet_ntoa(saddrin), dirpath); - if (debug) - warnx("stat failed on %s", dirpath); - bad = ENOENT; /* We will send error reply later */ - } - - /* Check in the exports list */ - sigprocmask(SIG_BLOCK, &sighup_mask, NULL); - ep = ex_search(&fsb.f_fsid); - hostset = defset = 0; - if (ep && (chk_host(ep->ex_defdir, saddr, &defset, &hostset) || - ((dp = dirp_search(ep->ex_dirl, dirpath)) && - chk_host(dp, saddr, &defset, &hostset)) || - (defset && scan_tree(ep->ex_defdir, saddr) == 0 && - scan_tree(ep->ex_dirl, saddr) == 0))) { - if (bad) { - if (!svc_sendreply(transp, xdr_long, - (caddr_t)&bad)) - syslog(LOG_ERR, "can't send reply"); - sigprocmask(SIG_UNBLOCK, &sighup_mask, NULL); - return; - } - if (hostset & DP_HOSTSET) - fhr.fhr_flag = hostset; - else - fhr.fhr_flag = defset; - fhr.fhr_vers = rqstp->rq_vers; - /* Get the file handle */ - memset(&fhr.fhr_fh, 0, sizeof(nfsfh_t)); - if (getfh(dirpath, (fhandle_t *)&fhr.fhr_fh) < 0) { - bad = errno; - syslog(LOG_ERR, "can't get fh for %s", dirpath); - if (!svc_sendreply(transp, xdr_long, - (caddr_t)&bad)) - syslog(LOG_ERR, "can't send reply"); - sigprocmask(SIG_UNBLOCK, &sighup_mask, NULL); - return; - } - if (!svc_sendreply(transp, xdr_fhs, (caddr_t)&fhr)) - syslog(LOG_ERR, "can't send reply"); - if (hp == NULL) - hp = gethostbyaddr((caddr_t)&saddr, - sizeof(saddr), AF_INET); - if (hp) - add_mlist(hp->h_name, dirpath); - else - add_mlist(inet_ntoa(saddrin), - dirpath); - if (debug) - warnx("mount successful"); - if (log) - syslog(LOG_NOTICE, - "mount request succeeded from %s for %s", - inet_ntoa(saddrin), dirpath); - } else { - bad = EACCES; - syslog(LOG_NOTICE, - "mount request denied from %s for %s", - inet_ntoa(saddrin), dirpath); - } - - if (bad && !svc_sendreply(transp, xdr_long, (caddr_t)&bad)) - syslog(LOG_ERR, "can't send reply"); - sigprocmask(SIG_UNBLOCK, &sighup_mask, NULL); - return; - case RPCMNT_DUMP: - if (!svc_sendreply(transp, xdr_mlist, (caddr_t)NULL)) - syslog(LOG_ERR, "can't send reply"); - else if (log) - syslog(LOG_NOTICE, - "dump request succeeded from %s", - inet_ntoa(saddrin)); - return; - case RPCMNT_UMOUNT: - if (sport >= IPPORT_RESERVED && resvport_only) { - syslog(LOG_NOTICE, - "umount request from %s from unprivileged port", - inet_ntoa(saddrin)); - svcerr_weakauth(transp); - return; - } - if (!svc_getargs(transp, xdr_dir, dirpath)) { - syslog(LOG_NOTICE, "undecodable umount request from %s", - inet_ntoa(saddrin)); - svcerr_decode(transp); - return; - } - if (!svc_sendreply(transp, xdr_void, (caddr_t)NULL)) - syslog(LOG_ERR, "can't send reply"); - hp = gethostbyaddr((caddr_t)&saddr, sizeof(saddr), AF_INET); - if (hp) - del_mlist(hp->h_name, dirpath); - del_mlist(inet_ntoa(saddrin), dirpath); - if (log) - syslog(LOG_NOTICE, - "umount request succeeded from %s for %s", - inet_ntoa(saddrin), dirpath); - return; - case RPCMNT_UMNTALL: - if (sport >= IPPORT_RESERVED && resvport_only) { - syslog(LOG_NOTICE, - "umountall request from %s from unprivileged port", - inet_ntoa(saddrin)); - svcerr_weakauth(transp); - return; - } - if (!svc_sendreply(transp, xdr_void, (caddr_t)NULL)) - syslog(LOG_ERR, "can't send reply"); - hp = gethostbyaddr((caddr_t)&saddr, sizeof(saddr), AF_INET); - if (hp) - del_mlist(hp->h_name, (char *)NULL); - del_mlist(inet_ntoa(saddrin), (char *)NULL); - if (log) - syslog(LOG_NOTICE, - "umountall request succeeded from %s", - inet_ntoa(saddrin)); - return; - case RPCMNT_EXPORT: - if (!svc_sendreply(transp, xdr_explist, (caddr_t)NULL)) - syslog(LOG_ERR, "can't send reply"); - if (log) - syslog(LOG_NOTICE, - "export request succeeded from %s", - inet_ntoa(saddrin)); - return; - default: - svcerr_noproc(transp); - return; - } -} - -/* - * Xdr conversion for a dirpath string - */ -int -xdr_dir(xdrsp, dirp) - XDR *xdrsp; - char *dirp; -{ - return (xdr_string(xdrsp, &dirp, RPCMNT_PATHLEN)); -} - -/* - * Xdr routine to generate file handle reply - */ -int -xdr_fhs(xdrsp, cp) - XDR *xdrsp; - caddr_t cp; -{ - register struct fhreturn *fhrp = (struct fhreturn *)cp; - u_long ok = 0, len, auth; - - if (!xdr_long(xdrsp, &ok)) - return (0); - switch (fhrp->fhr_vers) { - case 1: - return (xdr_opaque(xdrsp, (caddr_t)&fhrp->fhr_fh, NFSX_V2FH)); - case 3: - len = NFSX_V3FH; - if (!xdr_long(xdrsp, &len)) - return (0); - if (!xdr_opaque(xdrsp, (caddr_t)&fhrp->fhr_fh, len)) - return (0); - if (fhrp->fhr_flag & DP_KERB) - auth = RPCAUTH_KERB4; - else - auth = RPCAUTH_UNIX; - len = 1; - if (!xdr_long(xdrsp, &len)) - return (0); - return (xdr_long(xdrsp, &auth)); - }; - return (0); -} - -int -xdr_mlist(xdrsp, cp) - XDR *xdrsp; - caddr_t cp; -{ - struct mountlist *mlp; - int true = 1; - int false = 0; - char *strp; - - mlp = mlhead; - while (mlp) { - if (!xdr_bool(xdrsp, &true)) - return (0); - strp = &mlp->ml_host[0]; - if (!xdr_string(xdrsp, &strp, RPCMNT_NAMELEN)) - return (0); - strp = &mlp->ml_dirp[0]; - if (!xdr_string(xdrsp, &strp, RPCMNT_PATHLEN)) - return (0); - mlp = mlp->ml_next; - } - if (!xdr_bool(xdrsp, &false)) - return (0); - return (1); -} - -/* - * Xdr conversion for export list - */ -int -xdr_explist(xdrsp, cp) - XDR *xdrsp; - caddr_t cp; -{ - struct exportlist *ep; - int false = 0; - int putdef; - sigset_t sighup_mask; - - sigemptyset(&sighup_mask); - sigaddset(&sighup_mask, SIGHUP); - sigprocmask(SIG_BLOCK, &sighup_mask, NULL); - ep = exphead; - while (ep) { - putdef = 0; - if (put_exlist(ep->ex_dirl, xdrsp, ep->ex_defdir, &putdef)) - goto errout; - if (ep->ex_defdir && putdef == 0 && - put_exlist(ep->ex_defdir, xdrsp, (struct dirlist *)NULL, - &putdef)) - goto errout; - ep = ep->ex_next; - } - sigprocmask(SIG_UNBLOCK, &sighup_mask, NULL); - if (!xdr_bool(xdrsp, &false)) - return (0); - return (1); -errout: - sigprocmask(SIG_UNBLOCK, &sighup_mask, NULL); - return (0); -} - -/* - * Called from xdr_explist() to traverse the tree and export the - * directory paths. - */ -int -put_exlist(dp, xdrsp, adp, putdefp) - struct dirlist *dp; - XDR *xdrsp; - struct dirlist *adp; - int *putdefp; -{ - struct grouplist *grp; - struct hostlist *hp; - int true = 1; - int false = 0; - int gotalldir = 0; - char *strp; - - if (dp) { - if (put_exlist(dp->dp_left, xdrsp, adp, putdefp)) - return (1); - if (!xdr_bool(xdrsp, &true)) - return (1); - strp = dp->dp_dirp; - if (!xdr_string(xdrsp, &strp, RPCMNT_PATHLEN)) - return (1); - if (adp && !strcmp(dp->dp_dirp, adp->dp_dirp)) { - gotalldir = 1; - *putdefp = 1; - } - if ((dp->dp_flag & DP_DEFSET) == 0 && - (gotalldir == 0 || (adp->dp_flag & DP_DEFSET) == 0)) { - hp = dp->dp_hosts; - while (hp) { - grp = hp->ht_grp; - if (grp->gr_type == GT_HOST) { - if (!xdr_bool(xdrsp, &true)) - return (1); - strp = grp->gr_ptr.gt_hostent->h_name; - if (!xdr_string(xdrsp, &strp, - RPCMNT_NAMELEN)) - return (1); - } else if (grp->gr_type == GT_NET) { - if (!xdr_bool(xdrsp, &true)) - return (1); - strp = grp->gr_ptr.gt_net.nt_name; - if (!xdr_string(xdrsp, &strp, - RPCMNT_NAMELEN)) - return (1); - } - hp = hp->ht_next; - if (gotalldir && hp == (struct hostlist *)NULL) { - hp = adp->dp_hosts; - gotalldir = 0; - } - } - } - if (!xdr_bool(xdrsp, &false)) - return (1); - if (put_exlist(dp->dp_right, xdrsp, adp, putdefp)) - return (1); - } - return (0); -} - -#define LINESIZ 10240 -char line[LINESIZ]; -FILE *exp_file; - -/* - * Get the export list - */ -void -get_exportlist() -{ - struct exportlist *ep, *ep2; - struct grouplist *grp, *tgrp; - struct exportlist **epp; - struct dirlist *dirhead; - struct statfs fsb, *fsp; - struct hostent *hpe; - struct ucred anon; - char *cp, *endcp, *dirp, *hst, *usr, *dom, savedc; - int len, has_host, exflags, got_nondir, dirplen, num, i, netgrp; - - /* - * First, get rid of the old list - */ - ep = exphead; - while (ep) { - ep2 = ep; - ep = ep->ex_next; - free_exp(ep2); - } - exphead = (struct exportlist *)NULL; - - grp = grphead; - while (grp) { - tgrp = grp; - grp = grp->gr_next; - free_grp(tgrp); - } - grphead = (struct grouplist *)NULL; - - /* - * And delete exports that are in the kernel for all local - * file systems. - * XXX: Should know how to handle all local exportable file systems - * instead of just "ufs". - */ - num = getmntinfo(&fsp, MNT_NOWAIT); - for (i = 0; i < num; i++) { - union { - struct ufs_args ua; - struct iso_args ia; - struct mfs_args ma; - struct msdosfs_args da; - } targs; - - if (!strcmp(fsp->f_fstypename, "mfs") || - !strcmp(fsp->f_fstypename, "ufs") || - !strcmp(fsp->f_fstypename, "msdos") || - !strcmp(fsp->f_fstypename, "cd9660")) { - targs.ua.fspec = NULL; - targs.ua.export.ex_flags = MNT_DELEXPORT; - if (mount(fsp->f_fstypename, fsp->f_mntonname, - fsp->f_flags | MNT_UPDATE, - (caddr_t)&targs) < 0) - syslog(LOG_ERR, "can't delete exports for %s", - fsp->f_mntonname); - } - fsp++; - } - - /* - * Read in the exports file and build the list, calling - * mount() as we go along to push the export rules into the kernel. - */ - if ((exp_file = fopen(exname, "r")) == NULL) { - syslog(LOG_ERR, "can't open %s", exname); - exit(2); - } - dirhead = (struct dirlist *)NULL; - while (get_line()) { - if (debug) - warnx("got line %s", line); - cp = line; - nextfield(&cp, &endcp); - if (*cp == '#') - goto nextline; - - /* - * Set defaults. - */ - has_host = FALSE; - anon = def_anon; - exflags = MNT_EXPORTED; - got_nondir = 0; - opt_flags = 0; - ep = (struct exportlist *)NULL; - - /* - * Create new exports list entry - */ - len = endcp-cp; - tgrp = grp = get_grp(); - while (len > 0) { - if (len > RPCMNT_NAMELEN) { - getexp_err(ep, tgrp); - goto nextline; - } - if (*cp == '-') { - if (ep == (struct exportlist *)NULL) { - getexp_err(ep, tgrp); - goto nextline; - } - if (debug) - warnx("doing opt %s", cp); - got_nondir = 1; - if (do_opt(&cp, &endcp, ep, grp, &has_host, - &exflags, &anon)) { - getexp_err(ep, tgrp); - goto nextline; - } - } else if (*cp == '/') { - savedc = *endcp; - *endcp = '\0'; - if (check_dirpath(cp) && - statfs(cp, &fsb) >= 0) { - if (got_nondir) { - syslog(LOG_ERR, "dirs must be first"); - getexp_err(ep, tgrp); - goto nextline; - } - if (ep) { - if (ep->ex_fs.val[0] != fsb.f_fsid.val[0] || - ep->ex_fs.val[1] != fsb.f_fsid.val[1]) { - getexp_err(ep, tgrp); - goto nextline; - } - } else { - /* - * See if this directory is already - * in the list. - */ - ep = ex_search(&fsb.f_fsid); - if (ep == (struct exportlist *)NULL) { - ep = get_exp(); - ep->ex_fs = fsb.f_fsid; - ep->ex_fsdir = (char *) - malloc(strlen(fsb.f_mntonname) + 1); - if (ep->ex_fsdir) - strcpy(ep->ex_fsdir, - fsb.f_mntonname); - else - out_of_mem(); - if (debug) - warnx("making new ep fs=0x%x,0x%x", - fsb.f_fsid.val[0], - fsb.f_fsid.val[1]); - } else if (debug) - warnx("found ep fs=0x%x,0x%x", - fsb.f_fsid.val[0], - fsb.f_fsid.val[1]); - } - - /* - * Add dirpath to export mount point. - */ - dirp = add_expdir(&dirhead, cp, len); - dirplen = len; - } else { - getexp_err(ep, tgrp); - goto nextline; - } - *endcp = savedc; - } else { - savedc = *endcp; - *endcp = '\0'; - got_nondir = 1; - if (ep == (struct exportlist *)NULL) { - getexp_err(ep, tgrp); - goto nextline; - } - - /* - * Get the host or netgroup. - */ - setnetgrent(cp); - netgrp = getnetgrent(&hst, &usr, &dom); - do { - if (has_host) { - grp->gr_next = get_grp(); - grp = grp->gr_next; - } - if (netgrp) { - if (hst == 0) { - syslog(LOG_ERR, - "null hostname in netgroup %s, skipping", cp); - grp->gr_type = GT_IGNORE; - } else if (get_host(hst, grp, tgrp)) { - syslog(LOG_ERR, - "bad host %s in netgroup %s, skipping", hst, cp); - grp->gr_type = GT_IGNORE; - } - } else if (get_host(cp, grp, tgrp)) { - syslog(LOG_ERR, "bad host %s, skipping", cp); - grp->gr_type = GT_IGNORE; - } - has_host = TRUE; - } while (netgrp && getnetgrent(&hst, &usr, &dom)); - endnetgrent(); - *endcp = savedc; - } - cp = endcp; - nextfield(&cp, &endcp); - len = endcp - cp; - } - if (check_options(dirhead)) { - getexp_err(ep, tgrp); - goto nextline; - } - if (!has_host) { - grp->gr_type = GT_HOST; - if (debug) - warnx("adding a default entry"); - /* add a default group and make the grp list NULL */ - hpe = (struct hostent *)malloc(sizeof(struct hostent)); - if (hpe == (struct hostent *)NULL) - out_of_mem(); - hpe->h_name = strdup("Default"); - hpe->h_addrtype = AF_INET; - hpe->h_length = sizeof (u_int32_t); - hpe->h_addr_list = (char **)NULL; - grp->gr_ptr.gt_hostent = hpe; - - /* - * Don't allow a network export coincide with a list of - * host(s) on the same line. - */ - } else if ((opt_flags & OP_NET) && tgrp->gr_next) { - getexp_err(ep, tgrp); - goto nextline; - - /* - * If an export list was specified on this line, make sure - * that we have at least one valid entry, otherwise skip it. - */ - } else { - grp = tgrp; - while (grp && grp->gr_type == GT_IGNORE) - grp = grp->gr_next; - if (! grp) { - getexp_err(ep, tgrp); - goto nextline; - } - } - - /* - * Loop through hosts, pushing the exports into the kernel. - * After loop, tgrp points to the start of the list and - * grp points to the last entry in the list. - */ - grp = tgrp; - do { - if (do_mount(ep, grp, exflags, &anon, dirp, - dirplen, &fsb)) { - getexp_err(ep, tgrp); - goto nextline; - } - } while (grp->gr_next && (grp = grp->gr_next)); - - /* - * Success. Update the data structures. - */ - if (has_host) { - hang_dirp(dirhead, tgrp, ep, opt_flags); - grp->gr_next = grphead; - grphead = tgrp; - } else { - hang_dirp(dirhead, (struct grouplist *)NULL, ep, - opt_flags); - free_grp(grp); - } - dirhead = (struct dirlist *)NULL; - if ((ep->ex_flag & EX_LINKED) == 0) { - ep2 = exphead; - epp = &exphead; - - /* - * Insert in the list in alphabetical order. - */ - while (ep2 && strcmp(ep2->ex_fsdir, ep->ex_fsdir) < 0) { - epp = &ep2->ex_next; - ep2 = ep2->ex_next; - } - if (ep2) - ep->ex_next = ep2; - *epp = ep; - ep->ex_flag |= EX_LINKED; - } -nextline: - if (dirhead) { - free_dir(dirhead); - dirhead = (struct dirlist *)NULL; - } - } - fclose(exp_file); -} - -/* - * Allocate an export list element - */ -struct exportlist * -get_exp() -{ - struct exportlist *ep; - - ep = (struct exportlist *)malloc(sizeof (struct exportlist)); - if (ep == (struct exportlist *)NULL) - out_of_mem(); - memset(ep, 0, sizeof(struct exportlist)); - return (ep); -} - -/* - * Allocate a group list element - */ -struct grouplist * -get_grp() -{ - struct grouplist *gp; - - gp = (struct grouplist *)malloc(sizeof (struct grouplist)); - if (gp == (struct grouplist *)NULL) - out_of_mem(); - memset(gp, 0, sizeof(struct grouplist)); - return (gp); -} - -/* - * Clean up upon an error in get_exportlist(). - */ -void -getexp_err(ep, grp) - struct exportlist *ep; - struct grouplist *grp; -{ - struct grouplist *tgrp; - - syslog(LOG_ERR, "bad exports list line %s", line); - if (ep && (ep->ex_flag & EX_LINKED) == 0) - free_exp(ep); - while (grp) { - tgrp = grp; - grp = grp->gr_next; - free_grp(tgrp); - } -} - -/* - * Search the export list for a matching fs. - */ -struct exportlist * -ex_search(fsid) - fsid_t *fsid; -{ - struct exportlist *ep; - - ep = exphead; - while (ep) { - if (ep->ex_fs.val[0] == fsid->val[0] && - ep->ex_fs.val[1] == fsid->val[1]) - return (ep); - ep = ep->ex_next; - } - return (ep); -} - -/* - * Add a directory path to the list. - */ -char * -add_expdir(dpp, cp, len) - struct dirlist **dpp; - char *cp; - int len; -{ - struct dirlist *dp; - - dp = (struct dirlist *)malloc(sizeof (struct dirlist) + len); - if (dp == (struct dirlist *)NULL) - out_of_mem(); - dp->dp_left = *dpp; - dp->dp_right = (struct dirlist *)NULL; - dp->dp_flag = 0; - dp->dp_hosts = (struct hostlist *)NULL; - strcpy(dp->dp_dirp, cp); - *dpp = dp; - return (dp->dp_dirp); -} - -/* - * Hang the dir list element off the dirpath binary tree as required - * and update the entry for host. - */ -void -hang_dirp(dp, grp, ep, flags) - struct dirlist *dp; - struct grouplist *grp; - struct exportlist *ep; - int flags; -{ - struct hostlist *hp; - struct dirlist *dp2; - - if (flags & OP_ALLDIRS) { - if (ep->ex_defdir) - free((caddr_t)dp); - else - ep->ex_defdir = dp; - if (grp == (struct grouplist *)NULL) { - ep->ex_defdir->dp_flag |= DP_DEFSET; - if (flags & OP_KERB) - ep->ex_defdir->dp_flag |= DP_KERB; - } else while (grp) { - hp = get_ht(); - if (flags & OP_KERB) - hp->ht_flag |= DP_KERB; - hp->ht_grp = grp; - hp->ht_next = ep->ex_defdir->dp_hosts; - ep->ex_defdir->dp_hosts = hp; - grp = grp->gr_next; - } - } else { - - /* - * Loop through the directories adding them to the tree. - */ - while (dp) { - dp2 = dp->dp_left; - add_dlist(&ep->ex_dirl, dp, grp, flags); - dp = dp2; - } - } -} - -/* - * Traverse the binary tree either updating a node that is already there - * for the new directory or adding the new node. - */ -void -add_dlist(dpp, newdp, grp, flags) - struct dirlist **dpp; - struct dirlist *newdp; - struct grouplist *grp; - int flags; -{ - struct dirlist *dp; - struct hostlist *hp; - int cmp; - - dp = *dpp; - if (dp) { - cmp = strcmp(dp->dp_dirp, newdp->dp_dirp); - if (cmp > 0) { - add_dlist(&dp->dp_left, newdp, grp, flags); - return; - } else if (cmp < 0) { - add_dlist(&dp->dp_right, newdp, grp, flags); - return; - } else - free((caddr_t)newdp); - } else { - dp = newdp; - dp->dp_left = (struct dirlist *)NULL; - *dpp = dp; - } - if (grp) { - - /* - * Hang all of the host(s) off of the directory point. - */ - do { - hp = get_ht(); - if (flags & OP_KERB) - hp->ht_flag |= DP_KERB; - hp->ht_grp = grp; - hp->ht_next = dp->dp_hosts; - dp->dp_hosts = hp; - grp = grp->gr_next; - } while (grp); - } else { - dp->dp_flag |= DP_DEFSET; - if (flags & OP_KERB) - dp->dp_flag |= DP_KERB; - } -} - -/* - * Search for a dirpath on the export point. - */ -struct dirlist * -dirp_search(dp, dirpath) - struct dirlist *dp; - char *dirpath; -{ - int cmp; - - if (dp) { - cmp = strcmp(dp->dp_dirp, dirpath); - if (cmp > 0) - return (dirp_search(dp->dp_left, dirpath)); - else if (cmp < 0) - return (dirp_search(dp->dp_right, dirpath)); - else - return (dp); - } - return (dp); -} - -/* - * Scan for a host match in a directory tree. - */ -int -chk_host(dp, saddr, defsetp, hostsetp) - struct dirlist *dp; - u_int32_t saddr; - int *defsetp; - int *hostsetp; -{ - struct hostlist *hp; - struct grouplist *grp; - u_int32_t **addrp; - - if (dp) { - if (dp->dp_flag & DP_DEFSET) - *defsetp = dp->dp_flag; - hp = dp->dp_hosts; - while (hp) { - grp = hp->ht_grp; - switch (grp->gr_type) { - case GT_HOST: - addrp = (u_int32_t **) - grp->gr_ptr.gt_hostent->h_addr_list; - while (*addrp) { - if (**addrp == saddr) { - *hostsetp = (hp->ht_flag | DP_HOSTSET); - return (1); - } - addrp++; - } - break; - case GT_NET: - if ((saddr & grp->gr_ptr.gt_net.nt_mask) == - grp->gr_ptr.gt_net.nt_net) { - *hostsetp = (hp->ht_flag | DP_HOSTSET); - return (1); - } - break; - }; - hp = hp->ht_next; - } - } - return (0); -} - -/* - * Scan tree for a host that matches the address. - */ -int -scan_tree(dp, saddr) - struct dirlist *dp; - u_int32_t saddr; -{ - int defset, hostset; - - if (dp) { - if (scan_tree(dp->dp_left, saddr)) - return (1); - if (chk_host(dp, saddr, &defset, &hostset)) - return (1); - if (scan_tree(dp->dp_right, saddr)) - return (1); - } - return (0); -} - -/* - * Traverse the dirlist tree and free it up. - */ -void -free_dir(dp) - struct dirlist *dp; -{ - - if (dp) { - free_dir(dp->dp_left); - free_dir(dp->dp_right); - free_host(dp->dp_hosts); - free((caddr_t)dp); - } -} - -/* - * Parse the option string and update fields. - * Option arguments may either be -<option>=<value> or - * -<option> <value> - */ -int -do_opt(cpp, endcpp, ep, grp, has_hostp, exflagsp, cr) - char **cpp, **endcpp; - struct exportlist *ep; - struct grouplist *grp; - int *has_hostp; - int *exflagsp; - struct ucred *cr; -{ - char *cpoptarg, *cpoptend; - char *cp, *endcp, *cpopt, savedc, savedc2; - int allflag, usedarg; - - cpopt = *cpp; - cpopt++; - cp = *endcpp; - savedc = *cp; - *cp = '\0'; - while (cpopt && *cpopt) { - allflag = 1; - usedarg = -2; - if ((cpoptend = strchr(cpopt, ','))) { - *cpoptend++ = '\0'; - if ((cpoptarg = strchr(cpopt, '='))) - *cpoptarg++ = '\0'; - } else { - if ((cpoptarg = strchr(cpopt, '='))) - *cpoptarg++ = '\0'; - else { - *cp = savedc; - nextfield(&cp, &endcp); - **endcpp = '\0'; - if (endcp > cp && *cp != '-') { - cpoptarg = cp; - savedc2 = *endcp; - *endcp = '\0'; - usedarg = 0; - } - } - } - if (!strcmp(cpopt, "ro") || !strcmp(cpopt, "o")) { - *exflagsp |= MNT_EXRDONLY; - } else if (cpoptarg && (!strcmp(cpopt, "maproot") || - !(allflag = strcmp(cpopt, "mapall")) || - !strcmp(cpopt, "root") || !strcmp(cpopt, "r"))) { - usedarg++; - parsecred(cpoptarg, cr); - if (allflag == 0) { - *exflagsp |= MNT_EXPORTANON; - opt_flags |= OP_MAPALL; - } else - opt_flags |= OP_MAPROOT; - } else if (!strcmp(cpopt, "kerb") || !strcmp(cpopt, "k")) { - *exflagsp |= MNT_EXKERB; - opt_flags |= OP_KERB; - } else if (cpoptarg && (!strcmp(cpopt, "mask") || - !strcmp(cpopt, "m"))) { - if (get_net(cpoptarg, &grp->gr_ptr.gt_net, 1)) { - syslog(LOG_ERR, "bad mask: %s", cpoptarg); - return (1); - } - usedarg++; - opt_flags |= OP_MASK; - } else if (cpoptarg && (!strcmp(cpopt, "network") || - !strcmp(cpopt, "n"))) { - if (grp->gr_type != GT_NULL) { - syslog(LOG_ERR, "network/host conflict"); - return (1); - } else if (get_net(cpoptarg, &grp->gr_ptr.gt_net, 0)) { - syslog(LOG_ERR, "bad net: %s", cpoptarg); - return (1); - } - grp->gr_type = GT_NET; - *has_hostp = 1; - usedarg++; - opt_flags |= OP_NET; - } else if (!strcmp(cpopt, "alldirs")) { - opt_flags |= OP_ALLDIRS; - } else if (!strcmp(cpopt, "public")) { - *exflagsp |= MNT_EXPUBLIC; - } else if (!strcmp(cpopt, "webnfs")) { - *exflagsp |= (MNT_EXPUBLIC|MNT_EXRDONLY|MNT_EXPORTANON); - opt_flags |= OP_MAPALL; - } else if (cpoptarg && !strcmp(cpopt, "index")) { - ep->ex_indexfile = strdup(cpoptarg); -#ifdef ISO - } else if (cpoptarg && !strcmp(cpopt, "iso")) { - if (get_isoaddr(cpoptarg, grp)) { - syslog(LOG_ERR, "bad iso addr: %s", cpoptarg); - return (1); - } - *has_hostp = 1; - usedarg++; - opt_flags |= OP_ISO; -#endif /* ISO */ - } else { - syslog(LOG_ERR, "bad opt %s", cpopt); - return (1); - } - if (usedarg >= 0) { - *endcp = savedc2; - **endcpp = savedc; - if (usedarg > 0) { - *cpp = cp; - *endcpp = endcp; - } - return (0); - } - cpopt = cpoptend; - } - **endcpp = savedc; - return (0); -} - -/* - * Translate a character string to the corresponding list of network - * addresses for a hostname. - */ -int -get_host(cp, grp, tgrp) - char *cp; - struct grouplist *grp; - struct grouplist *tgrp; -{ - struct grouplist *checkgrp; - struct hostent *hp, *nhp; - char **addrp, **naddrp; - struct hostent t_host; - int i; - u_int32_t saddr; - char *aptr[2]; - - if (grp->gr_type != GT_NULL) - return (1); - if ((hp = gethostbyname(cp)) == NULL) { - if (isdigit(*cp)) { - saddr = inet_addr(cp); - if (saddr == -1) { - syslog(LOG_ERR, "inet_addr failed for %s", cp); - return (1); - } - if ((hp = gethostbyaddr((caddr_t)&saddr, sizeof (saddr), - AF_INET)) == NULL) { - hp = &t_host; - hp->h_name = cp; - hp->h_addrtype = AF_INET; - hp->h_length = sizeof (u_int32_t); - hp->h_addr_list = aptr; - aptr[0] = (char *)&saddr; - aptr[1] = (char *)NULL; - } - } else { - syslog(LOG_ERR, "gethostbyname failed for %s", cp); - return (1); - } - } - /* - * Sanity check: make sure we don't already have an entry - * for this host in the grouplist. - */ - checkgrp = tgrp; - while (checkgrp != NULL) { - if (checkgrp->gr_type == GT_HOST && - checkgrp->gr_ptr.gt_hostent != NULL && - (!strcmp(checkgrp->gr_ptr.gt_hostent->h_name, hp->h_name) - || *(u_int32_t *)checkgrp->gr_ptr.gt_hostent->h_addr == - *(u_int32_t *)hp->h_addr)) { - grp->gr_type = GT_IGNORE; - return(0); - } - checkgrp = checkgrp->gr_next; - } - - grp->gr_type = GT_HOST; - nhp = grp->gr_ptr.gt_hostent = (struct hostent *) - malloc(sizeof(struct hostent)); - if (nhp == (struct hostent *)NULL) - out_of_mem(); - memmove(nhp, hp, sizeof(struct hostent)); - i = strlen(hp->h_name)+1; - nhp->h_name = (char *)malloc(i); - if (nhp->h_name == (char *)NULL) - out_of_mem(); - memmove(nhp->h_name, hp->h_name, i); - addrp = hp->h_addr_list; - i = 1; - while (*addrp++) - i++; - naddrp = nhp->h_addr_list = (char **)malloc(i*sizeof(char *)); - if (naddrp == (char **)NULL) - out_of_mem(); - addrp = hp->h_addr_list; - while (*addrp) { - *naddrp = (char *)malloc(hp->h_length); - if (*naddrp == (char *)NULL) - out_of_mem(); - memmove(*naddrp, *addrp, hp->h_length); - addrp++; - naddrp++; - } - *naddrp = (char *)NULL; - if (debug) - warnx("got host %s", hp->h_name); - return (0); -} - -/* - * Free up an exports list component - */ -void -free_exp(ep) - struct exportlist *ep; -{ - - if (ep->ex_defdir) { - free_host(ep->ex_defdir->dp_hosts); - free((caddr_t)ep->ex_defdir); - } - if (ep->ex_fsdir) - free(ep->ex_fsdir); - if (ep->ex_indexfile) - free(ep->ex_indexfile); - free_dir(ep->ex_dirl); - free((caddr_t)ep); -} - -/* - * Free hosts. - */ -void -free_host(hp) - struct hostlist *hp; -{ - struct hostlist *hp2; - - while (hp) { - hp2 = hp; - hp = hp->ht_next; - free((caddr_t)hp2); - } -} - -struct hostlist * -get_ht() -{ - struct hostlist *hp; - - hp = (struct hostlist *)malloc(sizeof (struct hostlist)); - if (hp == (struct hostlist *)NULL) - out_of_mem(); - hp->ht_next = (struct hostlist *)NULL; - hp->ht_flag = 0; - return (hp); -} - -#ifdef ISO -/* - * Translate an iso address. - */ -get_isoaddr(cp, grp) - char *cp; - struct grouplist *grp; -{ - struct iso_addr *isop; - struct sockaddr_iso *isoaddr; - - if (grp->gr_type != GT_NULL) - return (1); - if ((isop = iso_addr(cp)) == NULL) { - syslog(LOG_ERR, "iso_addr failed, ignored"); - return (1); - } - isoaddr = (struct sockaddr_iso *)malloc(sizeof (struct sockaddr_iso)); - if (isoaddr == (struct sockaddr_iso *)NULL) - out_of_mem(); - memset(isoaddr, 0, sizeof(struct sockaddr_iso)); - memmove(&isoaddr->siso_addr, isop, sizeof(struct iso_addr)); - isoaddr->siso_len = sizeof(struct sockaddr_iso); - isoaddr->siso_family = AF_ISO; - grp->gr_type = GT_ISO; - grp->gr_ptr.gt_isoaddr = isoaddr; - return (0); -} -#endif /* ISO */ - -/* - * Out of memory, fatal - */ -void -out_of_mem() -{ - - syslog(LOG_ERR, "out of memory"); - exit(2); -} - -/* - * Do the mount syscall with the update flag to push the export info into - * the kernel. - */ -int -do_mount(ep, grp, exflags, anoncrp, dirp, dirplen, fsb) - struct exportlist *ep; - struct grouplist *grp; - int exflags; - struct ucred *anoncrp; - char *dirp; - int dirplen; - struct statfs *fsb; -{ - char *cp = (char *)NULL; - u_int32_t **addrp; - int done; - char savedc = '\0'; - struct sockaddr_in sin, imask; - union { - struct ufs_args ua; - struct iso_args ia; - struct mfs_args ma; -#ifdef __NetBSD__ - struct msdosfs_args da; -#endif - } args; - u_int32_t net; - - args.ua.fspec = 0; - args.ua.export.ex_flags = exflags; - args.ua.export.ex_anon = *anoncrp; - args.ua.export.ex_indexfile = ep->ex_indexfile; - memset(&sin, 0, sizeof(sin)); - memset(&imask, 0, sizeof(imask)); - sin.sin_family = AF_INET; - sin.sin_len = sizeof(sin); - imask.sin_family = AF_INET; - imask.sin_len = sizeof(sin); - if (grp->gr_type == GT_HOST) - addrp = (u_int32_t **)grp->gr_ptr.gt_hostent->h_addr_list; - else - addrp = (u_int32_t **)NULL; - done = FALSE; - while (!done) { - switch (grp->gr_type) { - case GT_HOST: - if (addrp) { - sin.sin_addr.s_addr = **addrp; - args.ua.export.ex_addrlen = sizeof(sin); - } else - args.ua.export.ex_addrlen = 0; - args.ua.export.ex_addr = (struct sockaddr *)&sin; - args.ua.export.ex_masklen = 0; - break; - case GT_NET: - if (grp->gr_ptr.gt_net.nt_mask) - imask.sin_addr.s_addr = grp->gr_ptr.gt_net.nt_mask; - else { - net = ntohl(grp->gr_ptr.gt_net.nt_net); - if (IN_CLASSA(net)) - imask.sin_addr.s_addr = inet_addr("255.0.0.0"); - else if (IN_CLASSB(net)) - imask.sin_addr.s_addr = - inet_addr("255.255.0.0"); - else - imask.sin_addr.s_addr = - inet_addr("255.255.255.0"); - grp->gr_ptr.gt_net.nt_mask = imask.sin_addr.s_addr; - } - sin.sin_addr.s_addr = grp->gr_ptr.gt_net.nt_net; - args.ua.export.ex_addr = (struct sockaddr *)&sin; - args.ua.export.ex_addrlen = sizeof (sin); - args.ua.export.ex_mask = (struct sockaddr *)&imask; - args.ua.export.ex_masklen = sizeof (imask); - break; -#ifdef ISO - case GT_ISO: - args.ua.export.ex_addr = - (struct sockaddr *)grp->gr_ptr.gt_isoaddr; - args.ua.export.ex_addrlen = - sizeof(struct sockaddr_iso); - args.ua.export.ex_masklen = 0; - break; -#endif /* ISO */ - case GT_IGNORE: - return(0); - break; - default: - syslog(LOG_ERR, "bad grouptype"); - if (cp) - *cp = savedc; - return (1); - }; - - /* - * XXX: - * Maybe I should just use the fsb->f_mntonname path instead - * of looping back up the dirp to the mount point?? - * Also, needs to know how to export all types of local - * exportable file systems and not just "ufs". - */ - while (mount(fsb->f_fstypename, dirp, - fsb->f_flags | MNT_UPDATE, (caddr_t)&args) < 0) { - if (cp) - *cp-- = savedc; - else - cp = dirp + dirplen - 1; - if (errno == EPERM) { - syslog(LOG_ERR, - "can't change attributes for %s", dirp); - return (1); - } - if (opt_flags & OP_ALLDIRS) { - syslog(LOG_ERR, "could not remount %s: %m", - dirp); - return (1); - } - /* back up over the last component */ - while (*cp == '/' && cp > dirp) - cp--; - while (*(cp - 1) != '/' && cp > dirp) - cp--; - if (cp == dirp) { - if (debug) - warnx("mnt unsucc"); - syslog(LOG_ERR, "can't export %s", dirp); - return (1); - } - savedc = *cp; - *cp = '\0'; - } - if (addrp) { - ++addrp; - if (*addrp == (u_int32_t *)NULL) - done = TRUE; - } else - done = TRUE; - } - if (cp) - *cp = savedc; - return (0); -} - -/* - * Translate a net address. - */ -int -get_net(cp, net, maskflg) - char *cp; - struct netmsk *net; - int maskflg; -{ - struct netent *np; - long netaddr; - struct in_addr inetaddr, inetaddr2; - char *name; - - if (isdigit(*cp) && ((netaddr = inet_network(cp)) != -1)) { - inetaddr = inet_makeaddr(netaddr, 0); - /* - * Due to arbitrary subnet masks, you don't know how many - * bits to shift the address to make it into a network, - * however you do know how to make a network address into - * a host with host == 0 and then compare them. - * (What a pest) - */ - if (!maskflg) { - setnetent(0); - while ((np = getnetent())) { - inetaddr2 = inet_makeaddr(np->n_net, 0); - if (inetaddr2.s_addr == inetaddr.s_addr) - break; - } - endnetent(); - } - } else if ((np = getnetbyname(cp)) != NULL) { - inetaddr = inet_makeaddr(np->n_net, 0); - } else - return (1); - - if (maskflg) - net->nt_mask = inetaddr.s_addr; - else { - if (np) - name = np->n_name; - else - name = inet_ntoa(inetaddr); - net->nt_name = (char *)malloc(strlen(name) + 1); - if (net->nt_name == (char *)NULL) - out_of_mem(); - strcpy(net->nt_name, name); - net->nt_net = inetaddr.s_addr; - } - return (0); -} - -/* - * Parse out the next white space separated field - */ -void -nextfield(cp, endcp) - char **cp; - char **endcp; -{ - char *p; - - p = *cp; - while (*p == ' ' || *p == '\t') - p++; - if (*p == '\n' || *p == '\0') - *cp = *endcp = p; - else { - *cp = p++; - while (*p != ' ' && *p != '\t' && *p != '\n' && *p != '\0') - p++; - *endcp = p; - } -} - -/* - * Get an exports file line. Skip over blank lines and handle line - * continuations. - */ -int -get_line() -{ - char *p, *cp; - int len; - int totlen, cont_line; - - /* - * Loop around ignoring blank lines and getting all continuation lines. - */ - p = line; - totlen = 0; - do { - if (fgets(p, LINESIZ - totlen, exp_file) == NULL) - return (0); - len = strlen(p); - cp = p + len - 1; - cont_line = 0; - while (cp >= p && - (*cp == ' ' || *cp == '\t' || *cp == '\n' || *cp == '\\')) { - if (*cp == '\\') - cont_line = 1; - cp--; - len--; - } - *++cp = '\0'; - if (len > 0) { - totlen += len; - if (totlen >= LINESIZ) { - syslog(LOG_ERR, "exports line too long"); - exit(2); - } - p = cp; - } - } while (totlen == 0 || cont_line); - return (1); -} - -/* - * Parse a description of a credential. - */ -void -parsecred(namelist, cr) - char *namelist; - struct ucred *cr; -{ - char *name; - int cnt; - char *names; - struct passwd *pw; - struct group *gr; - int ngroups, groups[NGROUPS + 1]; - - /* - * Set up the unprivileged user. - */ - cr->cr_ref = 1; - cr->cr_uid = -2; - cr->cr_groups[0] = -2; - cr->cr_ngroups = 1; - /* - * Get the user's password table entry. - */ - names = strsep(&namelist, " \t\n"); - name = strsep(&names, ":"); - if (isdigit(*name) || *name == '-') - pw = getpwuid(atoi(name)); - else - pw = getpwnam(name); - /* - * Credentials specified as those of a user. - */ - if (names == NULL) { - if (pw == NULL) { - syslog(LOG_ERR, "unknown user: %s", name); - return; - } - cr->cr_uid = pw->pw_uid; - ngroups = NGROUPS + 1; - if (getgrouplist(pw->pw_name, pw->pw_gid, groups, &ngroups)) - syslog(LOG_ERR, "too many groups"); - /* - * Convert from int's to gid_t's and compress out duplicate - */ - cr->cr_ngroups = ngroups - 1; - cr->cr_groups[0] = groups[0]; - for (cnt = 2; cnt < ngroups; cnt++) - cr->cr_groups[cnt - 1] = groups[cnt]; - return; - } - /* - * Explicit credential specified as a colon separated list: - * uid:gid:gid:... - */ - if (pw != NULL) - cr->cr_uid = pw->pw_uid; - else if (isdigit(*name) || *name == '-') - cr->cr_uid = atoi(name); - else { - syslog(LOG_ERR, "unknown user: %s", name); - return; - } - cr->cr_ngroups = 0; - while (names != NULL && *names != '\0' && cr->cr_ngroups < NGROUPS) { - name = strsep(&names, ":"); - if (isdigit(*name) || *name == '-') { - cr->cr_groups[cr->cr_ngroups++] = atoi(name); - } else { - if ((gr = getgrnam(name)) == NULL) { - syslog(LOG_ERR, "unknown group: %s", name); - continue; - } - cr->cr_groups[cr->cr_ngroups++] = gr->gr_gid; - } - } - if (names != NULL && *names != '\0' && cr->cr_ngroups == NGROUPS) - syslog(LOG_ERR, "too many groups"); -} - -#define STRSIZ (RPCMNT_NAMELEN+RPCMNT_PATHLEN+50) -/* - * Routines that maintain the remote mounttab - */ -void -get_mountlist() -{ - struct mountlist *mlp, **mlpp; - char *host, *dirp, *cp; - char str[STRSIZ]; - FILE *mlfile; - - if ((mlfile = fopen(_PATH_RMOUNTLIST, "r")) == NULL) { - syslog(LOG_ERR, "can't open %s", _PATH_RMOUNTLIST); - return; - } - mlpp = &mlhead; - while (fgets(str, STRSIZ, mlfile) != NULL) { - cp = str; - host = strsep(&cp, " \t\n"); - dirp = strsep(&cp, " \t\n"); - if (host == NULL || dirp == NULL) - continue; - mlp = (struct mountlist *)malloc(sizeof (*mlp)); - if (mlp == (struct mountlist *)NULL) - out_of_mem(); - strncpy(mlp->ml_host, host, RPCMNT_NAMELEN); - mlp->ml_host[RPCMNT_NAMELEN] = '\0'; - strncpy(mlp->ml_dirp, dirp, RPCMNT_PATHLEN); - mlp->ml_dirp[RPCMNT_PATHLEN] = '\0'; - mlp->ml_next = (struct mountlist *)NULL; - *mlpp = mlp; - mlpp = &mlp->ml_next; - } - fclose(mlfile); -} - -void -del_mlist(hostp, dirp) - char *hostp, *dirp; -{ - struct mountlist *mlp, **mlpp; - struct mountlist *mlp2; - FILE *mlfile; - int fnd = 0; - - mlpp = &mlhead; - mlp = mlhead; - while (mlp) { - if (!strcmp(mlp->ml_host, hostp) && - (!dirp || !strcmp(mlp->ml_dirp, dirp))) { - fnd = 1; - mlp2 = mlp; - *mlpp = mlp = mlp->ml_next; - free((caddr_t)mlp2); - } else { - mlpp = &mlp->ml_next; - mlp = mlp->ml_next; - } - } - if (fnd) { - if ((mlfile = fopen(_PATH_RMOUNTLIST, "w")) == NULL) { - syslog(LOG_ERR,"can't update %s", _PATH_RMOUNTLIST); - return; - } - mlp = mlhead; - while (mlp) { - fprintf(mlfile, "%s %s\n", mlp->ml_host, mlp->ml_dirp); - mlp = mlp->ml_next; - } - fclose(mlfile); - } -} - -void -add_mlist(hostp, dirp) - char *hostp, *dirp; -{ - struct mountlist *mlp, **mlpp; - FILE *mlfile; - - mlpp = &mlhead; - mlp = mlhead; - while (mlp) { - if (!strcmp(mlp->ml_host, hostp) && !strcmp(mlp->ml_dirp, dirp)) - return; - mlpp = &mlp->ml_next; - mlp = mlp->ml_next; - } - mlp = (struct mountlist *)malloc(sizeof (*mlp)); - if (mlp == (struct mountlist *)NULL) - out_of_mem(); - strncpy(mlp->ml_host, hostp, RPCMNT_NAMELEN); - mlp->ml_host[RPCMNT_NAMELEN] = '\0'; - strncpy(mlp->ml_dirp, dirp, RPCMNT_PATHLEN); - mlp->ml_dirp[RPCMNT_PATHLEN] = '\0'; - mlp->ml_next = (struct mountlist *)NULL; - *mlpp = mlp; - if ((mlfile = fopen(_PATH_RMOUNTLIST, "a")) == NULL) { - syslog(LOG_ERR, "can't update %s", _PATH_RMOUNTLIST); - return; - } - fprintf(mlfile, "%s %s\n", mlp->ml_host, mlp->ml_dirp); - fclose(mlfile); -} - -/* - * This function is called via. SIGTERM when the system is going down. - * It sends a broadcast RPCMNT_UMNTALL. - */ -void -send_umntall() -{ - (void) clnt_broadcast(RPCPROG_MNT, RPCMNT_VER1, RPCMNT_UMNTALL, - xdr_void, (caddr_t)0, xdr_void, (caddr_t)0, umntall_each); - exit(0); -} - -int -umntall_each(resultsp, raddr) - caddr_t resultsp; - struct sockaddr_in *raddr; -{ - return (1); -} - -/* - * Free up a group list. - */ -void -free_grp(grp) - struct grouplist *grp; -{ - char **addrp; - - if (grp->gr_type == GT_HOST) { - if (grp->gr_ptr.gt_hostent->h_name) { - addrp = grp->gr_ptr.gt_hostent->h_addr_list; - while (addrp && *addrp) - free(*addrp++); - free((caddr_t)grp->gr_ptr.gt_hostent->h_addr_list); - free(grp->gr_ptr.gt_hostent->h_name); - } - free((caddr_t)grp->gr_ptr.gt_hostent); - } else if (grp->gr_type == GT_NET) { - if (grp->gr_ptr.gt_net.nt_name) - free(grp->gr_ptr.gt_net.nt_name); - } -#ifdef ISO - else if (grp->gr_type == GT_ISO) - free((caddr_t)grp->gr_ptr.gt_isoaddr); -#endif - free((caddr_t)grp); -} - -#ifdef DEBUG -void -SYSLOG(int pri, const char *fmt, ...) -{ - va_list ap; - - va_start(ap, fmt); - vfprintf(stderr, fmt, ap); - va_end(ap); -} -#endif /* DEBUG */ - -/* - * Check options for consistency. - */ -int -check_options(dp) - struct dirlist *dp; -{ - - if (dp == (struct dirlist *)NULL) - return (1); - if ((opt_flags & (OP_MAPROOT | OP_MAPALL)) == (OP_MAPROOT | OP_MAPALL) || - (opt_flags & (OP_MAPROOT | OP_KERB)) == (OP_MAPROOT | OP_KERB) || - (opt_flags & (OP_MAPALL | OP_KERB)) == (OP_MAPALL | OP_KERB)) { - syslog(LOG_ERR, "-mapall, -maproot and -kerb mutually exclusive"); - return (1); - } - if ((opt_flags & OP_MASK) && (opt_flags & OP_NET) == 0) { - syslog(LOG_ERR, "-mask requires -net"); - return (1); - } - if ((opt_flags & (OP_NET | OP_ISO)) == (OP_NET | OP_ISO)) { - syslog(LOG_ERR, "-net and -iso mutually exclusive"); - return (1); - } - if ((opt_flags & OP_ALLDIRS) && dp->dp_left) { - syslog(LOG_ERR, "-alldir has multiple directories"); - return (1); - } - return (0); -} - -/* - * Check an absolute directory path for any symbolic links. Return true - * if no symbolic links are found. - */ -int -check_dirpath(dirp) - char *dirp; -{ - char *cp; - int ret = 1; - struct stat sb; - - cp = dirp + 1; - while (*cp && ret) { - if (*cp == '/') { - *cp = '\0'; - if (lstat(dirp, &sb) < 0 || !S_ISDIR(sb.st_mode)) - ret = 0; - *cp = '/'; - } - cp++; - } - if (lstat(dirp, &sb) < 0 || !S_ISDIR(sb.st_mode)) - ret = 0; - return (ret); -} - -/* - * Just translate an ascii string to an integer. - */ -int -get_num(cp) - register char *cp; -{ - register int res = 0; - - while (*cp) { - if (*cp < '0' || *cp > '9') - return (-1); - res = res * 10 + (*cp++ - '0'); - } - return (res); -} diff --git a/usr.sbin/mountd/netgroup.5 b/usr.sbin/mountd/netgroup.5 deleted file mode 100644 index 83cc9c72c1fb..000000000000 --- a/usr.sbin/mountd/netgroup.5 +++ /dev/null @@ -1,186 +0,0 @@ -.\" Copyright (c) 1992, 1993 -.\" The Regents of the University of California. 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. -.\" 3. All advertising materials mentioning features or use of this software -.\" must display the following acknowledgement: -.\" This product includes software developed by the University of -.\" California, Berkeley and its contributors. -.\" 4. Neither the name of the University nor the names of its contributors -.\" may be used to endorse or promote products derived from this software -.\" without specific prior written permission. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS 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 REGENTS 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. -.\" -.\" @(#)netgroup.5 8.2 (Berkeley) 12/11/93 -.\" -.Dd December 11, 1993 -.Dt NETGROUP 5 -.Os -.Sh NAME -.Nm netgroup -.Nd defines network groups -.Sh SYNOPSIS -.Nm netgroup -.Sh DESCRIPTION -The -.Nm -file -specifies ``netgroups'', which are sets of -.Sy (host, user, domain) -tuples that are to be given similar network access. -.Pp -Each line in the file -consists of a netgroup name followed by a list of the members of the -netgroup. -Each member can be either the name of another netgroup or a specification -of a tuple as follows: -.Bd -literal -offset indent -(host, user, domain) -.Ed -.Pp -where the -.Sy host , -.Sy user , -and -.Sy domain -are character string names for the corresponding component. -Any of the comma separated fields may be empty to specify a ``wildcard'' value -or may consist of the string ``-'' to specify ``no valid value''. -The members of the list may be separated by whitespace and/or commas; -the ``\e'' character may be used at the end of a line to specify -line continuation. Lines are limited to 1024 characters. -The functions specified in -.Xr getnetgrent 3 -should normally be used to access the -.Nm -database. -.Pp -Lines that begin with a # are treated as comments. -.Sh NIS/YP INTERACTION -On most other platforms, -.Nm Ns s -are only used in conjunction with -.Tn NIS -and local -.Pa /etc/netgroup -files are ignored. With -.Bx Free , -.Nm Ns s -can be used with either -.Tn NIS -or local files, but there are certain -caveats to consider. The existing -.Nm -system is extremely inefficient where -.Fn innetgr 3 -lookups are concerned since -.Nm -memberships are computed on the fly. By contrast, the -.Tn NIS -.Nm -database consists of three separate maps (netgroup, netgroup.byuser -and netgroup.byhost) that are keyed to allow -.Fn innetgr 3 -lookups to be done quickly. The -.Bx Free -.Nm -system can interact with the -.Tn NIS -.Nm -maps in the following ways: -.Bl -bullet -offset indent -.It -If the -.Pa /etc/netgroup -file does not exist, or it exists and is empty, or -it exists and contains only a -.Sq + , -and -.Tn NIS -is running, -.Nm -lookups will be done exclusively through -.Tn NIS , -with -.Fn innetgr 3 -taking advantage of the netgroup.byuser and -netgroup.byhost maps to speed up searches. (This -is more or less compatible with the behavior of SunOS and -similar platforms.) -.It -If the -.Pa /etc/netgroup -exists and contains only local -.Nm -information (with no -.Tn NIS -.Sq + -token), then only the local -.Nm -information will be processed (and -.Tn NIS -will be ignored). -.It -If -.Pa /etc/netgroup -exists and contains both local netgroup data -.Pa and -the -.Tn NIS -.Sq + -token, the local data and the -.Tn NIS -netgroup -map will be processed as a single combined -.Nm -database. While this configuration is the most flexible, it -is also the least efficient: in particular, -.Fn innetgr 3 -lookups will be especially slow if the -database is large. -.El -.Sh FILES -.Bl -tag -width /etc/netgroup -compact -.It Pa /etc/netgroup -the netgroup database -.El -.Sh SEE ALSO -.Xr getnetgrent 3 , -.Xr exports 5 -.Sh COMPATIBILITY -The file format is compatible with that of various vendors, however it -appears that not all vendors use an identical format. -.Sh BUGS -The interpretation of access restrictions based on the member tuples of a -netgroup is left up to the various network applications. -Also, it is not obvious how the domain specification -applies to the -.Bx -environment. -.Pp -The -.Nm -database should be stored in the form of a -hashed -.Xr db 3 -database just like the -.Xr passwd 5 -database to speed up reverse lookups. diff --git a/usr.sbin/mountd/pathnames.h b/usr.sbin/mountd/pathnames.h deleted file mode 100644 index aa1c55523103..000000000000 --- a/usr.sbin/mountd/pathnames.h +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright (c) 1989, 1993 - * The Regents of the University of California. 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. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS 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 REGENTS 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. - * - * @(#)pathnames.h 8.1 (Berkeley) 6/5/93 - */ -#include <paths.h> - -#define _PATH_EXPORTS "/etc/exports" -#define _PATH_RMOUNTLIST "/var/db/mountdtab" -#define _PATH_MOUNTDPID "/var/run/mountd.pid" diff --git a/usr.sbin/nfsd/Makefile b/usr.sbin/nfsd/Makefile deleted file mode 100644 index 12ce92e2d90a..000000000000 --- a/usr.sbin/nfsd/Makefile +++ /dev/null @@ -1,17 +0,0 @@ -# @(#)Makefile 8.1 (Berkeley) 6/5/93 - -PROG= nfsd -CFLAGS+=-DNFS -MAN8= nfsd.8 -DPADD+= ${LIBUTIL} -LDADD+= -lutil - -.if exists(${DESTDIR}/usr/lib/libkrb.a) && (defined(MAKE_KERBEROS) \ - || defined(MAKE_EBONES)) -CFLAGS+=-DKERBEROS -DPADD+= ${LIBKRB} ${LIBDES} -LDADD+= -lkrb -ldes -DISTRIBUTION= krb -.endif - -.include <bsd.prog.mk> diff --git a/usr.sbin/nfsd/nfsd.8 b/usr.sbin/nfsd/nfsd.8 deleted file mode 100644 index 5be6ff809f17..000000000000 --- a/usr.sbin/nfsd/nfsd.8 +++ /dev/null @@ -1,134 +0,0 @@ -.\" Copyright (c) 1989, 1991, 1993 -.\" The Regents of the University of California. 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. -.\" 3. All advertising materials mentioning features or use of this software -.\" must display the following acknowledgement: -.\" This product includes software developed by the University of -.\" California, Berkeley and its contributors. -.\" 4. Neither the name of the University nor the names of its contributors -.\" may be used to endorse or promote products derived from this software -.\" without specific prior written permission. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS 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 REGENTS 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. -.\" -.\" @(#)nfsd.8 8.4 (Berkeley) 3/29/95 -.\" -.Dd March 29, 1995 -.Dt NFSD 8 -.Os -.Sh NAME -.Nm nfsd -.Nd remote -.Tn NFS -server -.Sh SYNOPSIS -.Nm nfsd -.Op Fl rut -.Op Fl n Ar num_servers -.Sh DESCRIPTION -.Nm Nfsd -runs on a server machine to service -.Tn NFS -requests from client machines. -At least one -.Nm nfsd -must be running for a machine to operate as a server. -.Pp -Unless otherwise specified, four servers for -.Tn UDP -transport are started. -.Pp -The following options are available: -.Bl -tag -width Ds -.It Fl r -Register the -.Tn NFS -service with -.Xr portmap 8 -without creating any servers. -This option can be used along with the -.Fl u -or -.Fl t -options to re-register NFS if the portmap server is restarted. -.It Fl n -Specifies how many servers to create. -.It Fl t -Serve -.Tn TCP NFS -clients. -.It Fl u -Serve -.Tn UDP NFS -clients. -.El -.Pp -For example, -.Dq Li "nfsd -u -t -n 6" -serves -.Tn UDP -and -.Tn TCP -transports using six daemons. -.Pp -A server should run enough daemons to handle -the maximum level of concurrency from its clients, -typically four to six. -.Pp -.Nm Nfsd -listens for service requests at the port indicated in the -.Tn NFS -server specification; see -.%T "Network File System Protocol Specification" , -RFC1094 and -.%T "NFS: Network File System Version 3 Protocol Specification" . -.Pp -If -.Nm nfsd -detects that -.Tn NFS -is not loaded in the running kernel, it will attempt -to load a loadable kernel module containing -.Tn NFS -support using -.Xr modload 8 -by way of -.Xr vfsload 3 . -If this fails, or no -.Tn NFS -LKM is available, -.Nm nfsd -will exit with an error. -.Pp -The -.Nm nfsd -utility exits 0 on success, and >0 if an error occurs. -.Sh SEE ALSO -.Xr nfsstat 1 , -.Xr nfssvc 2 , -.Xr modload 8 , -.Xr mountd 8 , -.Xr portmap 8 -.Sh HISTORY -The -.Nm nfsd -utility first appeared in -.Bx 4.4 . diff --git a/usr.sbin/nfsd/nfsd.c b/usr.sbin/nfsd/nfsd.c deleted file mode 100644 index e1a1ffe2e54e..000000000000 --- a/usr.sbin/nfsd/nfsd.c +++ /dev/null @@ -1,673 +0,0 @@ -/* - * Copyright (c) 1989, 1993, 1994 - * The Regents of the University of California. All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * Rick Macklem at The University of Guelph. - * - * 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. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS 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 REGENTS 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. - */ - -#ifndef lint -static const char copyright[] = -"@(#) Copyright (c) 1989, 1993, 1994\n\ - The Regents of the University of California. All rights reserved.\n"; -#endif not lint - -#ifndef lint -#if 0 -static char sccsid[] = "@(#)nfsd.c 8.9 (Berkeley) 3/29/95"; -#endif -static const char rcsid[] = - "$Id$"; -#endif not lint - -#include <sys/param.h> -#include <sys/syslog.h> -#include <sys/wait.h> -#include <sys/mount.h> - -#include <rpc/rpc.h> -#include <rpc/pmap_clnt.h> - -#ifdef ISO -#include <netiso/iso.h> -#endif -#include <nfs/rpcv2.h> -#include <nfs/nfsproto.h> -#include <nfs/nfs.h> - -#ifdef NFSKERB -#include <kerberosIV/des.h> -#include <kerberosIV/krb.h> -#endif - -#include <err.h> -#include <errno.h> -#include <libutil.h> -#include <stdio.h> -#include <stdlib.h> -#include <strings.h> -#include <unistd.h> - -/* Global defs */ -#ifdef DEBUG -#define syslog(e, s) fprintf(stderr,(s)) -int debug = 1; -#else -int debug = 0; -#endif - -struct nfsd_srvargs nsd; -#ifdef OLD_SETPROCTITLE -char **Argv = NULL; /* pointer to argument vector */ -char *LastArg = NULL; /* end of argv */ -#endif - -#ifdef NFSKERB -char lnam[ANAME_SZ]; -KTEXT_ST kt; -AUTH_DAT kauth; -char inst[INST_SZ]; -struct nfsrpc_fullblock kin, kout; -struct nfsrpc_fullverf kverf; -NFSKERBKEY_T kivec; -struct timeval ktv; -NFSKERBKEYSCHED_T kerb_keysched; -#endif - -void nonfs __P((int)); -void reapchild __P((int)); -#ifdef OLD_SETPROCTITLE -#ifdef __FreeBSD__ -void setproctitle __P((char *)); -#endif -#endif -void usage __P((void)); - -/* - * Nfs server daemon mostly just a user context for nfssvc() - * - * 1 - do file descriptor and signal cleanup - * 2 - fork the nfsd(s) - * 3 - create server socket(s) - * 4 - register socket with portmap - * - * For connectionless protocols, just pass the socket into the kernel via. - * nfssvc(). - * For connection based sockets, loop doing accepts. When you get a new - * socket from accept, pass the msgsock into the kernel via. nfssvc(). - * The arguments are: - * -c - support iso cltp clients - * -r - reregister with portmapper - * -t - support tcp nfs clients - * -u - support udp nfs clients - * followed by "n" which is the number of nfsds' to fork off - */ -int -main(argc, argv, envp) - int argc; - char *argv[], *envp[]; -{ - struct nfsd_args nfsdargs; - struct sockaddr_in inetaddr, inetpeer; -#ifdef ISO - struct sockaddr_iso isoaddr, isopeer; - char *cp; -#endif - fd_set ready, sockbits; - int ch, cltpflag, connect_type_cnt, i, len, maxsock, msgsock; - int nfsdcnt, nfssvc_flag, on, reregister, sock, tcpflag, tcpsock; - int tp4cnt, tp4flag, tpipcnt, tpipflag, udpflag; -#ifdef notyet - int tp4sock, tpipsock; -#endif -#ifdef NFSKERB - struct group *grp; - struct passwd *pwd; - struct ucred *cr; - struct timeval ktv; - char **cpp; -#endif -#ifdef __FreeBSD__ - struct vfsconf vfc; - int error; - - error = getvfsbyname("nfs", &vfc); - if (error && vfsisloadable("nfs")) { - if (vfsload("nfs")) - err(1, "vfsload(nfs)"); - endvfsent(); /* flush cache */ - error = getvfsbyname("nfs", &vfc); - } - if (error) - errx(1, "NFS is not available in the running kernel"); -#endif - -#ifdef OLD_SETPROCTITLE - /* Save start and extent of argv for setproctitle. */ - Argv = argv; - if (envp == 0 || *envp == 0) - envp = argv; - while (*envp) - envp++; - LastArg = envp[-1] + strlen(envp[-1]); -#endif - -#define MAXNFSDCNT 20 -#define DEFNFSDCNT 4 - nfsdcnt = DEFNFSDCNT; - cltpflag = reregister = tcpflag = tp4cnt = tp4flag = tpipcnt = 0; - tpipflag = udpflag = 0; -#ifdef ISO -#define GETOPT "cn:rtu" -#define USAGE "[-crtu] [-n num_servers]" -#else -#define GETOPT "n:rtu" -#define USAGE "[-rtu] [-n num_servers]" -#endif - while ((ch = getopt(argc, argv, GETOPT)) != -1) - switch (ch) { - case 'n': - nfsdcnt = atoi(optarg); - if (nfsdcnt < 1 || nfsdcnt > MAXNFSDCNT) { - warnx("nfsd count %d; reset to %d", nfsdcnt, - DEFNFSDCNT); - nfsdcnt = DEFNFSDCNT; - } - break; - case 'r': - reregister = 1; - break; - case 't': - tcpflag = 1; - break; - case 'u': - udpflag = 1; - break; -#ifdef ISO - case 'c': - cltpflag = 1; - break; -#ifdef notyet - case 'i': - tp4cnt = 1; - break; - case 'p': - tpipcnt = 1; - break; -#endif /* notyet */ -#endif /* ISO */ - default: - case '?': - usage(); - }; - if (!tcpflag && !udpflag) - udpflag = 1; - argv += optind; - argc -= optind; - - /* - * XXX - * Backward compatibility, trailing number is the count of daemons. - */ - if (argc > 1) - usage(); - if (argc == 1) { - nfsdcnt = atoi(argv[0]); - if (nfsdcnt < 1 || nfsdcnt > MAXNFSDCNT) { - warnx("nfsd count %d; reset to %d", nfsdcnt, - DEFNFSDCNT); - nfsdcnt = DEFNFSDCNT; - } - } - - if (debug == 0) { - daemon(0, 0); - (void)signal(SIGHUP, SIG_IGN); - (void)signal(SIGINT, SIG_IGN); - (void)signal(SIGQUIT, SIG_IGN); - (void)signal(SIGSYS, nonfs); - (void)signal(SIGTERM, SIG_IGN); - } - (void)signal(SIGCHLD, reapchild); - - if (reregister) { - if (udpflag && - (!pmap_set(RPCPROG_NFS, 2, IPPROTO_UDP, NFS_PORT) || - !pmap_set(RPCPROG_NFS, 3, IPPROTO_UDP, NFS_PORT))) - err(1, "can't register with portmap for UDP"); - if (tcpflag && - (!pmap_set(RPCPROG_NFS, 2, IPPROTO_TCP, NFS_PORT) || - !pmap_set(RPCPROG_NFS, 3, IPPROTO_TCP, NFS_PORT))) - err(1, "can't register with portmap for TCP"); - exit(0); - } - openlog("nfsd:", LOG_PID, LOG_DAEMON); - - for (i = 0; i < nfsdcnt; i++) { - switch (fork()) { - case -1: - syslog(LOG_ERR, "fork: %m"); - exit (1); - case 0: - break; - default: - continue; - } - - setproctitle("server"); - nfssvc_flag = NFSSVC_NFSD; - nsd.nsd_nfsd = NULL; -#ifdef NFSKERB - if (sizeof (struct nfsrpc_fullverf) != RPCX_FULLVERF || - sizeof (struct nfsrpc_fullblock) != RPCX_FULLBLOCK) - syslog(LOG_ERR, "Yikes NFSKERB structs not packed!"); - nsd.nsd_authstr = (u_char *)&kt; - nsd.nsd_authlen = sizeof (kt); - nsd.nsd_verfstr = (u_char *)&kverf; - nsd.nsd_verflen = sizeof (kverf); -#endif - while (nfssvc(nfssvc_flag, &nsd) < 0) { - if (errno != ENEEDAUTH) { - syslog(LOG_ERR, "nfssvc: %m"); - exit(1); - } - nfssvc_flag = NFSSVC_NFSD | NFSSVC_AUTHINFAIL; -#ifdef NFSKERB - /* - * Get the Kerberos ticket out of the authenticator - * verify it and convert the principal name to a user - * name. The user name is then converted to a set of - * user credentials via the password and group file. - * Finally, decrypt the timestamp and validate it. - * For more info see the IETF Draft "Authentication - * in ONC RPC". - */ - kt.length = ntohl(kt.length); - if (gettimeofday(&ktv, (struct timezone *)0) == 0 && - kt.length > 0 && kt.length <= - (RPCAUTH_MAXSIZ - 3 * NFSX_UNSIGNED)) { - kin.w1 = NFS_KERBW1(kt); - kt.mbz = 0; - (void)strcpy(inst, "*"); - if (krb_rd_req(&kt, NFS_KERBSRV, - inst, nsd.nsd_haddr, &kauth, "") == RD_AP_OK && - krb_kntoln(&kauth, lnam) == KSUCCESS && - (pwd = getpwnam(lnam)) != NULL) { - cr = &nsd.nsd_cr; - cr->cr_uid = pwd->pw_uid; - cr->cr_groups[0] = pwd->pw_gid; - cr->cr_ngroups = 1; - setgrent(); - while ((grp = getgrent()) != NULL) { - if (grp->gr_gid == cr->cr_groups[0]) - continue; - for (cpp = grp->gr_mem; - *cpp != NULL; ++cpp) - if (!strcmp(*cpp, lnam)) - break; - if (*cpp == NULL) - continue; - cr->cr_groups[cr->cr_ngroups++] - = grp->gr_gid; - if (cr->cr_ngroups == NGROUPS) - break; - } - endgrent(); - - /* - * Get the timestamp verifier out of the - * authenticator and verifier strings. - */ - kin.t1 = kverf.t1; - kin.t2 = kverf.t2; - kin.w2 = kverf.w2; - bzero((caddr_t)kivec, sizeof (kivec)); - bcopy((caddr_t)kauth.session, - (caddr_t)nsd.nsd_key,sizeof(kauth.session)); - - /* - * Decrypt the timestamp verifier in CBC mode. - */ - XXX - - /* - * Validate the timestamp verifier, to - * check that the session key is ok. - */ - nsd.nsd_timestamp.tv_sec = ntohl(kout.t1); - nsd.nsd_timestamp.tv_usec = ntohl(kout.t2); - nsd.nsd_ttl = ntohl(kout.w1); - if ((nsd.nsd_ttl - 1) == ntohl(kout.w2)) - nfssvc_flag = NFSSVC_NFSD | NFSSVC_AUTHIN; - } -#endif /* NFSKERB */ - } - exit(0); - } - - /* If we are serving udp, set up the socket. */ - if (udpflag) { - if ((sock = socket(AF_INET, SOCK_DGRAM, 0)) < 0) { - syslog(LOG_ERR, "can't create udp socket"); - exit(1); - } - inetaddr.sin_family = AF_INET; - inetaddr.sin_addr.s_addr = INADDR_ANY; - inetaddr.sin_port = htons(NFS_PORT); - inetaddr.sin_len = sizeof(inetaddr); - if (bind(sock, - (struct sockaddr *)&inetaddr, sizeof(inetaddr)) < 0) { - syslog(LOG_ERR, "can't bind udp addr"); - exit(1); - } - if (!pmap_set(RPCPROG_NFS, 2, IPPROTO_UDP, NFS_PORT) || - !pmap_set(RPCPROG_NFS, 3, IPPROTO_UDP, NFS_PORT)) { - syslog(LOG_ERR, "can't register with udp portmap"); - exit(1); - } - nfsdargs.sock = sock; - nfsdargs.name = NULL; - nfsdargs.namelen = 0; - if (nfssvc(NFSSVC_ADDSOCK, &nfsdargs) < 0) { - syslog(LOG_ERR, "can't Add UDP socket"); - exit(1); - } - (void)close(sock); - } - -#ifdef ISO - /* If we are serving cltp, set up the socket. */ - if (cltpflag) { - if ((sock = socket(AF_ISO, SOCK_DGRAM, 0)) < 0) { - syslog(LOG_ERR, "can't create cltp socket"); - exit(1); - } - memset(&isoaddr, 0, sizeof(isoaddr)); - isoaddr.siso_family = AF_ISO; - isoaddr.siso_tlen = 2; - cp = TSEL(&isoaddr); - *cp++ = (NFS_PORT >> 8); - *cp = (NFS_PORT & 0xff); - isoaddr.siso_len = sizeof(isoaddr); - if (bind(sock, - (struct sockaddr *)&isoaddr, sizeof(isoaddr)) < 0) { - syslog(LOG_ERR, "can't bind cltp addr"); - exit(1); - } -#ifdef notyet - /* - * XXX - * Someday this should probably use "rpcbind", the son of - * portmap. - */ - if (!pmap_set(RPCPROG_NFS, NFS_VER2, IPPROTO_UDP, NFS_PORT)) { - syslog(LOG_ERR, "can't register with udp portmap"); - exit(1); - } -#endif /* notyet */ - nfsdargs.sock = sock; - nfsdargs.name = NULL; - nfsdargs.namelen = 0; - if (nfssvc(NFSSVC_ADDSOCK, &nfsdargs) < 0) { - syslog(LOG_ERR, "can't add UDP socket"); - exit(1); - } - close(sock); - } -#endif /* ISO */ - - /* Now set up the master server socket waiting for tcp connections. */ - on = 1; - FD_ZERO(&sockbits); - connect_type_cnt = 0; - if (tcpflag) { - if ((tcpsock = socket(AF_INET, SOCK_STREAM, 0)) < 0) { - syslog(LOG_ERR, "can't create tcp socket"); - exit(1); - } - if (setsockopt(tcpsock, - SOL_SOCKET, SO_REUSEADDR, (char *)&on, sizeof(on)) < 0) - syslog(LOG_ERR, "setsockopt SO_REUSEADDR: %m"); - inetaddr.sin_family = AF_INET; - inetaddr.sin_addr.s_addr = INADDR_ANY; - inetaddr.sin_port = htons(NFS_PORT); - inetaddr.sin_len = sizeof(inetaddr); - if (bind(tcpsock, - (struct sockaddr *)&inetaddr, sizeof (inetaddr)) < 0) { - syslog(LOG_ERR, "can't bind tcp addr"); - exit(1); - } - if (listen(tcpsock, 5) < 0) { - syslog(LOG_ERR, "listen failed"); - exit(1); - } - if (!pmap_set(RPCPROG_NFS, 2, IPPROTO_TCP, NFS_PORT) || - !pmap_set(RPCPROG_NFS, 3, IPPROTO_TCP, NFS_PORT)) { - syslog(LOG_ERR, "can't register tcp with portmap"); - exit(1); - } - FD_SET(tcpsock, &sockbits); - maxsock = tcpsock; - connect_type_cnt++; - } - -#ifdef notyet - /* Now set up the master server socket waiting for tp4 connections. */ - if (tp4flag) { - if ((tp4sock = socket(AF_ISO, SOCK_SEQPACKET, 0)) < 0) { - syslog(LOG_ERR, "can't create tp4 socket"); - exit(1); - } - if (setsockopt(tp4sock, - SOL_SOCKET, SO_REUSEADDR, (char *)&on, sizeof(on)) < 0) - syslog(LOG_ERR, "setsockopt SO_REUSEADDR: %m"); - memset(&isoaddr, 0, sizeof(isoaddr)); - isoaddr.siso_family = AF_ISO; - isoaddr.siso_tlen = 2; - cp = TSEL(&isoaddr); - *cp++ = (NFS_PORT >> 8); - *cp = (NFS_PORT & 0xff); - isoaddr.siso_len = sizeof(isoaddr); - if (bind(tp4sock, - (struct sockaddr *)&isoaddr, sizeof (isoaddr)) < 0) { - syslog(LOG_ERR, "can't bind tp4 addr"); - exit(1); - } - if (listen(tp4sock, 5) < 0) { - syslog(LOG_ERR, "listen failed"); - exit(1); - } - /* - * XXX - * Someday this should probably use "rpcbind", the son of - * portmap. - */ - if (!pmap_set(RPCPROG_NFS, NFS_VER2, IPPROTO_TCP, NFS_PORT)) { - syslog(LOG_ERR, "can't register tcp with portmap"); - exit(1); - } - FD_SET(tp4sock, &sockbits); - maxsock = tp4sock; - connect_type_cnt++; - } - - /* Now set up the master server socket waiting for tpip connections. */ - if (tpipflag) { - if ((tpipsock = socket(AF_INET, SOCK_SEQPACKET, 0)) < 0) { - syslog(LOG_ERR, "can't create tpip socket"); - exit(1); - } - if (setsockopt(tpipsock, - SOL_SOCKET, SO_REUSEADDR, (char *)&on, sizeof(on)) < 0) - syslog(LOG_ERR, "setsockopt SO_REUSEADDR: %m"); - inetaddr.sin_family = AF_INET; - inetaddr.sin_addr.s_addr = INADDR_ANY; - inetaddr.sin_port = htons(NFS_PORT); - inetaddr.sin_len = sizeof(inetaddr); - if (bind(tpipsock, - (struct sockaddr *)&inetaddr, sizeof (inetaddr)) < 0) { - syslog(LOG_ERR, "can't bind tcp addr"); - exit(1); - } - if (listen(tpipsock, 5) < 0) { - syslog(LOG_ERR, "listen failed"); - exit(1); - } - /* - * XXX - * Someday this should probably use "rpcbind", the son of - * portmap. - */ - if (!pmap_set(RPCPROG_NFS, NFS_VER2, IPPROTO_TCP, NFS_PORT)) { - syslog(LOG_ERR, "can't register tcp with portmap"); - exit(1); - } - FD_SET(tpipsock, &sockbits); - maxsock = tpipsock; - connect_type_cnt++; - } -#endif /* notyet */ - - if (connect_type_cnt == 0) - exit(0); - - setproctitle("master"); - - /* - * Loop forever accepting connections and passing the sockets - * into the kernel for the mounts. - */ - for (;;) { - ready = sockbits; - if (connect_type_cnt > 1) { - if (select(maxsock + 1, - &ready, NULL, NULL, NULL) < 1) { - syslog(LOG_ERR, "select failed: %m"); - exit(1); - } - } - if (tcpflag && FD_ISSET(tcpsock, &ready)) { - len = sizeof(inetpeer); - if ((msgsock = accept(tcpsock, - (struct sockaddr *)&inetpeer, &len)) < 0) { - syslog(LOG_ERR, "accept failed: %m"); - exit(1); - } - memset(inetpeer.sin_zero, 0, sizeof(inetpeer.sin_zero)); - if (setsockopt(msgsock, SOL_SOCKET, - SO_KEEPALIVE, (char *)&on, sizeof(on)) < 0) - syslog(LOG_ERR, - "setsockopt SO_KEEPALIVE: %m"); - nfsdargs.sock = msgsock; - nfsdargs.name = (caddr_t)&inetpeer; - nfsdargs.namelen = sizeof(inetpeer); - nfssvc(NFSSVC_ADDSOCK, &nfsdargs); - (void)close(msgsock); - } -#ifdef notyet - if (tp4flag && FD_ISSET(tp4sock, &ready)) { - len = sizeof(isopeer); - if ((msgsock = accept(tp4sock, - (struct sockaddr *)&isopeer, &len)) < 0) { - syslog(LOG_ERR, "accept failed: %m"); - exit(1); - } - if (setsockopt(msgsock, SOL_SOCKET, - SO_KEEPALIVE, (char *)&on, sizeof(on)) < 0) - syslog(LOG_ERR, - "setsockopt SO_KEEPALIVE: %m"); - nfsdargs.sock = msgsock; - nfsdargs.name = (caddr_t)&isopeer; - nfsdargs.namelen = len; - nfssvc(NFSSVC_ADDSOCK, &nfsdargs); - (void)close(msgsock); - } - if (tpipflag && FD_ISSET(tpipsock, &ready)) { - len = sizeof(inetpeer); - if ((msgsock = accept(tpipsock, - (struct sockaddr *)&inetpeer, &len)) < 0) { - syslog(LOG_ERR, "accept failed: %m"); - exit(1); - } - if (setsockopt(msgsock, SOL_SOCKET, - SO_KEEPALIVE, (char *)&on, sizeof(on)) < 0) - syslog(LOG_ERR, "setsockopt SO_KEEPALIVE: %m"); - nfsdargs.sock = msgsock; - nfsdargs.name = (caddr_t)&inetpeer; - nfsdargs.namelen = len; - nfssvc(NFSSVC_ADDSOCK, &nfsdargs); - (void)close(msgsock); - } -#endif /* notyet */ - } -} - -void -usage() -{ - (void)fprintf(stderr, "usage: nfsd %s\n", USAGE); - exit(1); -} - -void -nonfs(signo) - int signo; -{ - syslog(LOG_ERR, "missing system call: NFS not available"); -} - -void -reapchild(signo) - int signo; -{ - - while (wait3(NULL, WNOHANG, NULL) > 0); -} - -#ifdef OLD_SETPROCTITLE -#ifdef __FreeBSD__ -void -setproctitle(a) - char *a; -{ - register char *cp; - char buf[80]; - - cp = Argv[0]; - (void)snprintf(buf, sizeof(buf), "nfsd-%s", a); - (void)strncpy(cp, buf, LastArg - cp); - cp += strlen(cp); - while (cp < LastArg) - *cp++ = '\0'; - Argv[1] = NULL; -} -#endif /* __FreeBSD__ */ -#endif diff --git a/usr.sbin/nologin/Makefile b/usr.sbin/nologin/Makefile deleted file mode 100644 index e30ea0886d23..000000000000 --- a/usr.sbin/nologin/Makefile +++ /dev/null @@ -1,12 +0,0 @@ -# @(#)Makefile 8.2 (Berkeley) 4/22/94 - -MAN8= nologin.8 -MAN5= nologin.5 - -nologin depend lint tags: - -beforeinstall: - ${INSTALL} -c -o ${BINOWN} -g ${BINGRP} -m ${BINMODE} \ - ${.CURDIR}/nologin.sh ${DESTDIR}${BINDIR}/nologin - -.include <bsd.prog.mk> diff --git a/usr.sbin/nologin/nologin.5 b/usr.sbin/nologin/nologin.5 deleted file mode 100644 index 19a070df3eed..000000000000 --- a/usr.sbin/nologin/nologin.5 +++ /dev/null @@ -1,65 +0,0 @@ -.\" Copyright (c) 1993 -.\" The Regents of the University of California. 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. -.\" 3. All advertising materials mentioning features or use of this software -.\" must display the following acknowledgement: -.\" This product includes software developed by the University of -.\" California, Berkeley and its contributors. -.\" 4. Neither the name of the University nor the names of its contributors -.\" may be used to endorse or promote products derived from this software -.\" without specific prior written permission. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS 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 REGENTS 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. -.\" -.\" @(#)nologin.8 8.1 (Berkeley) 6/19/93 -.\" $Id: nologin.5,v 1.4 1998/07/15 06:37:06 charnier Exp $ -.\" -.Dd June 19, 1993 -.Dt NOLOGIN 5 -.Os FreeBSD 2.1 -.Sh NAME -.Nm nologin -.Nd disallow logins -.Sh DESCRIPTION -.Nm Nologin -disallows logins if the file -.Pa /var/run/nologin -exists. -Programs display the contents of -.Pa /var/run/nologin -to the user and exit. -.Sh SECURITY -Ignored by -.Xr login 1 -for user root. -.Sh FILES -.Bl -tag -width /var/run/nologinxxx -compact -.It Pa /var/run/nologin -The -.Nm -file resides in -.Pa /var/run . -.El -.Sh SEE ALSO -.Xr login 1 , -.Xr rlogin 1 , -.Xr telnet 1 , -.Xr shutdown 8 diff --git a/usr.sbin/nologin/nologin.8 b/usr.sbin/nologin/nologin.8 deleted file mode 100644 index 9802672007d7..000000000000 --- a/usr.sbin/nologin/nologin.8 +++ /dev/null @@ -1,55 +0,0 @@ -.\" Copyright (c) 1993 -.\" The Regents of the University of California. 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. -.\" 3. All advertising materials mentioning features or use of this software -.\" must display the following acknowledgement: -.\" This product includes software developed by the University of -.\" California, Berkeley and its contributors. -.\" 4. Neither the name of the University nor the names of its contributors -.\" may be used to endorse or promote products derived from this software -.\" without specific prior written permission. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS 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 REGENTS 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. -.\" -.\" @(#)nologin.8 8.1 (Berkeley) 6/19/93 -.\" $Id$ -.\" -.Dd June 19, 1993 -.Dt NOLOGIN 8 -.Os BSD 4.4 -.Sh NAME -.Nm nologin -.Nd politely refuse a login -.Sh SYNOPSIS -.Nm nologin -.Sh DESCRIPTION -.Nm Nologin -displays a message that an account is not available and -exits non-zero. -It is intended as a replacement shell field for accounts that -have been disabled. -.Sh SEE ALSO -.Xr login 1 -.Sh HISTORY -The -.Nm -command appeared in -.Bx 4.4 . diff --git a/usr.sbin/nologin/nologin.sh b/usr.sbin/nologin/nologin.sh deleted file mode 100644 index 346836f63918..000000000000 --- a/usr.sbin/nologin/nologin.sh +++ /dev/null @@ -1,39 +0,0 @@ -#!/bin/sh -p -# -# Copyright (c) 1992, 1993 -# The Regents of the University of California. 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. -# 3. All advertising materials mentioning features or use of this software -# must display the following acknowledgement: -# This product includes software developed by the University of -# California, Berkeley and its contributors. -# 4. Neither the name of the University nor the names of its contributors -# may be used to endorse or promote products derived from this software -# without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE REGENTS 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 REGENTS 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. -# -# @(#)nologin.sh 8.1 (Berkeley) 6/5/93 -# $Id$ -# - -echo 'This account is currently not available.' -exit 1 diff --git a/usr.sbin/ppp/README.nat b/usr.sbin/ppp/README.nat deleted file mode 100644 index 5d297738b2f4..000000000000 --- a/usr.sbin/ppp/README.nat +++ /dev/null @@ -1,352 +0,0 @@ -User PPP Packet Aliasing - - - -0. Contents - 1. Background - 2. Setup - 3. New commands in ppp - 4. Future Work - 5. Authors / Acknowledgements - 6. Revision History for Aliasing Code - - - -1. Background - -User mode ppp has embedded packet aliasing (IP masquerading) code. -Enabling this, either by the "-alias" command line option or the -"alias enable yes" command in a ppp.conf file, makes the ppp host -automatically alias IP packets forwarded from a local network, making -them appear to come from the ppp host machine. Incoming packets -from the outside world are then appropriately de-aliased. - -The process of aliasing involves both the IP address and the TCP or UDP -port numbers. ICMP echo and timestamp packets are aliased by their id -numbers. ICMP error messages can be properly directed by examining the -fragment of the offending packet which is contained in the body of the -message. - -This software was specifically meant to support users who have -unregistered, private address IP networks (e.g. 192.168.0.x or 10.0.0.x -addresses). The ppp host can act as a gateway for these networks, and -computers on the local area net will have some degree of Internet access -without the need for a registered IP address. Additionally, there will -be no need for an Internet service provider to maintain routing tables -for the local area network. - -A disadvantage of packet aliasing is that machines on the local network, -behind the ppp host, are not visible from the outside world. They can -establish TCP connections and make UDP inquiries (such as domain name -service requests) but the connections seem to come from the ppp host -itself. There is, in effect, a partial firewall. Of course, if this is -what you want, the disadvantage becomes an advantage. - -A second disadvantage is that "IP encoding" protocols, which send IP -address or port information within the data stream, are not supported -for the cases where exception code exists. This implementation has -workarounds for FTP and IRC DCC, the most well known of the IP encoding -protocols. This frees users from depending on using the ftp passive -mode and avoiding IRC DCC sends, as is sometimes the case with other -masquerading solutions. - -The implementation supports all standard, non-encoding TCP and UDP protocols. -Examples of these protocols are http, gopher and telnet. The standard UDP -mode of Real-Audio is not presently supported, but the TCP mode does work -correctly. - -The packet aliasing code also handle many ICMP messages. In particular, -ping and traceroute are supported. - - - -2. Packet Aliasing Setup - -It is recommended that users first verify correct ppp operation without -packet aliasing enabled. This will confirm that the ppp.conf file is -properly set up and that there are no ppp problems. Then start ppp with -the "-alias" option on the command line. The user should verify that -the ppp host can correctly connect to the Internet in packet aliasing -mode. Finally, check that machines on the private network can access -the Internet. - -The masquerading software aliases all packets, whether they come from -the host or another computer on the local area network. Thus, a correctly -operating ppp host indicates that the software should work properly for -other computers on the private network. - -If the ppp host can access the Internet, but other computers on the local -network cannot, check that IP forwarding is enabled on the ppp host. Also, -verify that the other computers use this machine as a gateway. Of course, -you should also verify that machines within the local area network -communicate properly. A common error is inconsistent subnet addresses -and masks. - - - -3. New commands in ppp - -In order to control aliasing behaviour in a simple manner (no need for -recompilation), a new command has been added to ppp: alias. This -is in addition to the -alias command line option. System managers and -more experienced users may prefer to use the ppp command syntax -within the ppp.conf file. The alias command also allows packet aliasing -behaviour to be more precisely specified. - -The decision to add a command instead of extending 'set' or 'option' was -to make obvious that these options only work when aliasing is enabled. - -The syntax for 'alias' is - - ppp> alias option [yes|no] - -where option is given by one of the following templates. - - - - alias enable [yes|no] (default no) - -Enable packet aliasing functionality. If disabled, no other alias -options will have any effect. You should usually enable aliasing -before routing any packets over the link; good points are in the -initial script or right before adding a route. If you do not always -want aliasing, consider using the -alias option to ppp instead of this -command. - - - - alias deny_incoming [yes|no] (default yes) - -Set to "yes" to disable all incoming connections. This just drops -connections to, for example, ftp, telnet or web servers. The aliasing -mechanism prevents these connections. Technically, this option denies -all incoming TCP and UDP requests, making the aliasing software a -fairly efficient one-way firewall. The default is no, which will allow -all incoming connections to telnetd, ftpd, etc. - - - - alias log [yes|no] - -Controls logging of alias link creation to "/var/log/alias.log" - this -is usually only useful if debugging a setup, to see if the bug is in -the PPP aliasing. The debugging information is fairly limited, listing -the number of aliasing links open for different protocols. - - - - alias same_ports [yes|no] (default yes) - -When a connection is being established going through the aliasing -routines, it will normally have its port number changed to allow the -aliasing code to track it. If same_ports is enabled, the alias -software attempts to keep the connection's source port unchanged. -This will allow rsh, RPC and other specialised protocols to work -_most of the time_, at least on the host machine. Please, do not -report this being unstable as a bug - it is a result of the way -aliasing has to work. TCP/IP was intended to have one IP address -per machine. - - - - alias use_sockets [yes|no] (default yes) - -This is a fairly obscure option. For the most part, the packet aliasing -software does not have to allocate system sockets when it chooses an -aliasing port number. Under very specific circumstances, FTP data -connections (which don't know the remote port number, though it is -usually 20) and IRC DCC send (which doesn't know either the address or -the port from which the connection will come), there can potentially be -some interference with an open server socket having the same port number -on the ppp host machine. This possibility for interference only exists -until the TCP connection has been acknowledged on both sides. The safe -option is yes, though fewer system resources are consumed by specifying -no. - - - - alias unregistered_only [yes|no] (default no) - -Packet aliasing normally remaps all packets coming from the local area -network to the ppp host machine address. Set this option to only map -addresses from the following standard ranges for private, unregistered -addresses: - - 10.0.0.0 -> 10.255.255.255 - 172.16.0.0 -> 172.31.255.255 - 192.168.0.0 -> 192.168.255.255 */ - -In the instance that there is a subnet of public addresses and another -subnet of private addresses being routed by the ppp host, then only the -packets on the private subnet will be aliased. - - -- alias port <proto> <local addr>:<port> <alias port> - -This command allows incoming traffic to <alias port> on the host -machine to be redirected to a specific machine and port on the -local area network. One example of this would be: - - alias port tcp 192.168.0.4:telnet 8066 - -All traffic to port 8066 of the ppp host would then be sent to -the telnet port (23) of machine 192.168.0.4. Port numbers -can either be designated numerically or by symbolic names -listed in /etc/services. Similarly, addresses can be either -in dotted quad notation or in /etc/hosts. - - -- alias addr <local addr> <public addr> - -This command allows traffic for a public IP address to be -redirected to a machine on the local network. This function -is known as "static NAT". An address assignment of 0 refers -to the default address of the ppp host. Normally static -NAT is useful if your ISP has allocated a small block of -IP addresses to the user, but it can even be used in the -case of a single, dynamically allocated IP address: - - alias addr 10.0.0.8 0 - -The above command would redirect all incoming traffic to -machine 10.0.0.8. - -If several address aliases specify the same public address -as follows - - alias addr 192.168.0.2 public_addr - alias addr 192.168.0.3 public_addr - alias addr 192.168.0.4 public_addr - -then incoming traffic will be directed to the last -translated local address (192.168.0.4), but outgoing -traffic to the first two addresses will still be aliased -to the specified public address. - - - -4. Future Work - -What is called packet aliasing here has been variously called masquerading, -network address translation (NAT) and transparent proxying by others. It -is an extremely useful function to many users, but it is also necessarily -imperfect. The occasional IP-encoding protocols always need workarounds -(hacks). Users who are interested in supporting new IP-encoding protocols -can follow the examples of alias_ftp.c and alias_irc.c. - -ICMP error messages are currently handled only in the incoming direction. -A handler needs to be added to correctly alias outgoing error messages. - -IRC and FTP exception handling make reasonable, though not strictly correct -assumptions, about how IP encoded messages will appear in the control -stream. Programmers may wish to consider how to make this process more -robust. - -The packet aliasing engine (alias.c, alias_db.c, alias_ftp.c, alias_irc.c -and alias_util.c) runs in user space, and is intended to be both portable -and reusable for interfaces other than ppp. To access the basic engine -only requires four simple function calls (initialisation, communication of -host address, outgoing aliasing and incoming de-aliasing). - - - -5. Authors / Acknowledgements - -Charles Mott (cmott@srv.net) <versions 1.0 - 1.8, 2.0, 2.1> -Eivind Eklund (perhaps@yes.no) <versions 1.8b - 1.9, new ppp commands> - -Listed below, in chronological order, are individuals who have provided -valuable comments and/or debugging assistance. - - Gary Roberts - Tom Torrance - Reto Burkhalter - Martin Renters - Brian Somers - Paul Traina - Ari Suutari - J. Fortes - Andrzej Bialeki - - - -6. Revision History for Aliasing Code - -Version 1.0: August 11, 1996 (cjm) - -Version 1.1: August 20, 1996 (cjm) - PPP host accepts incoming connections for ports 0 to 1023. - -Version 1.2: September 7, 1996 (cjm) - Fragment handling error in alias_db.c corrected. - -Version 1.3: September 15, 1996 (cjm) - - Generalised mechanism for handling incoming connections - (no more 0 to 1023 restriction). - - Increased ICMP support (will handle traceroute now). - - Improved TCP close connection logic. - -Version 1.4: September 16, 1996 - Can't remember (this version only lasted a day -- cjm). - -Version 1.5: September 17, 1996 (cjm) - Corrected error in handling incoming UDP packets - with zero checksum. - -Version 1.6: September 18, 1996 - Simplified ICMP data storage. Will now handle - tracert from Win95 as well as FreeBSD traceroute. - -Version 1.7: January 9, 1997 (cjm) - - Reduced malloc() activity for ICMP echo and - timestamp requests. - - Added handling for out-of-order IP fragments. - - Switched to differential checksum computation - for IP headers (TCP, UDP and ICMP checksums - were already differential). - - Accepts FTP data connections from other than - port 20. This allows one ftp connections - from two hosts which are both running packet - aliasing. - -Version 1.8: January 14, 1997 (cjm) - - Fixed data type error in function StartPoint() - in alias_db.c (this bug did not exist before v1.7) - -Version 1.8b: January 16, 1997 (Eivind Eklund <perhaps@yes.no>) - - Upgraded base PPP version to be the source code from - FreeBSD 2.1.6, with additional security patches. This - version should still be possible to run on 2.1.5, though - - I've run it with a 2.1.5 kernel without problems. - (Update done with the permission of cjm) - -Version 1.9: February 1, 1997 (Eivind Eklund <perhaps@yes.no>) - - Added support for IRC DCC (ee) - - Changed the aliasing routines to use ANSI style throughout - - minor API changes for integration with other programs than PPP (ee) - - Changed the build process, making all options switchable - from the Makefile (ee) - - Fixed minor security hole in alias_ftp.c for other applications - of the aliasing software. Hole could _not_ manifest in - PPP+pktAlias, but could potentially manifest in other - applications of the aliasing. (ee) - - Connections initiated from packet aliasing host machine will - not have their port number aliased unless it conflicts with - an aliasing port already being used. (There is an option to - disable this for debugging) (cjm) - - Sockets will be allocated in cases where there might be - port interference with the host machine. This can be disabled - in cases where the ppp host will be acting purely as a - masquerading router and not generate any traffic of its own. - (cjm) - -Version 2.0: March, 1997 (cjm) - - Incoming packets which are not recognised by the packet - aliasing engine are now completely dropped in ip.c. - - Aliasing links are cleared when a host interface address - changes (due to re-dial and dynamic address allocation). - - PacketAliasPermanentLink() API added. - - Option for only aliasing private, unregistered IP addresses - added. - - Substantial rework to the aliasing lookup engine. - -Version 2.1: May, 1997 (cjm) - - Continuing rework to the aliasing lookup engine to support - multiple incoming addresses and static NAT. - - Now supports outgoing as well as incoming ICMP error messages/ - - PPP commands to support address and port redirection. - diff --git a/usr.sbin/ppp/nat_cmd.c b/usr.sbin/ppp/nat_cmd.c deleted file mode 100644 index efe0d67bb589..000000000000 --- a/usr.sbin/ppp/nat_cmd.c +++ /dev/null @@ -1,215 +0,0 @@ -/*- - * The code in this file was written by Eivind Eklund <perhaps@yes.no>, - * who places it in the public domain without restriction. - * - * $Id: alias_cmd.c,v 1.17 1998/08/26 17:39:36 brian Exp $ - */ - -#include <sys/types.h> -#include <netinet/in.h> -#include <arpa/inet.h> -#include <netdb.h> -#include <netinet/in_systm.h> -#include <netinet/in.h> -#include <netinet/ip.h> -#include <sys/un.h> - -#include <stdio.h> -#include <stdlib.h> -#include <string.h> -#include <termios.h> - -#ifdef __OpenBSD__ -#include "alias.h" -#else -#include <alias.h> -#endif -#include "defs.h" -#include "command.h" -#include "log.h" -#include "alias_cmd.h" -#include "descriptor.h" -#include "prompt.h" -#include "timer.h" -#include "fsm.h" -#include "slcompress.h" -#include "throughput.h" -#include "iplist.h" -#include "mbuf.h" -#include "lqr.h" -#include "hdlc.h" -#include "ipcp.h" -#include "lcp.h" -#include "ccp.h" -#include "link.h" -#include "mp.h" -#include "filter.h" -#include "bundle.h" - - -static int StrToAddr(const char *, struct in_addr *); -static int StrToPort(const char *, u_short *, const char *); -static int StrToAddrAndPort(const char *, struct in_addr *, u_short *, const char *); - - -int -alias_RedirectPort(struct cmdargs const *arg) -{ - if (!arg->bundle->AliasEnabled) { - prompt_Printf(arg->prompt, "Alias not enabled\n"); - return 1; - } else if (arg->argc == arg->argn+3) { - char proto_constant; - const char *proto; - u_short local_port; - u_short alias_port; - int error; - struct in_addr local_addr; - struct in_addr null_addr; - struct alias_link *link; - - proto = arg->argv[arg->argn]; - if (strcmp(proto, "tcp") == 0) { - proto_constant = IPPROTO_TCP; - } else if (strcmp(proto, "udp") == 0) { - proto_constant = IPPROTO_UDP; - } else { - prompt_Printf(arg->prompt, "port redirect: protocol must be" - " tcp or udp\n"); - prompt_Printf(arg->prompt, "Usage: alias %s %s\n", arg->cmd->name, - arg->cmd->syntax); - return 1; - } - - error = StrToAddrAndPort(arg->argv[arg->argn+1], &local_addr, &local_port, - proto); - if (error) { - prompt_Printf(arg->prompt, "port redirect: error reading" - " local addr:port\n"); - prompt_Printf(arg->prompt, "Usage: alias %s %s\n", arg->cmd->name, - arg->cmd->syntax); - return 1; - } - error = StrToPort(arg->argv[arg->argn+2], &alias_port, proto); - if (error) { - prompt_Printf(arg->prompt, "port redirect: error reading alias port\n"); - prompt_Printf(arg->prompt, "Usage: alias %s %s\n", arg->cmd->name, - arg->cmd->syntax); - return 1; - } - null_addr.s_addr = INADDR_ANY; - - link = PacketAliasRedirectPort(local_addr, local_port, - null_addr, 0, - null_addr, alias_port, - proto_constant); - - if (link == NULL) - prompt_Printf(arg->prompt, "port redirect: error returned by packed" - " aliasing engine (code=%d)\n", error); - } else - return -1; - - return 0; -} - - -int -alias_RedirectAddr(struct cmdargs const *arg) -{ - if (!arg->bundle->AliasEnabled) { - prompt_Printf(arg->prompt, "alias not enabled\n"); - return 1; - } else if (arg->argc == arg->argn+2) { - int error; - struct in_addr local_addr; - struct in_addr alias_addr; - struct alias_link *link; - - error = StrToAddr(arg->argv[arg->argn], &local_addr); - if (error) { - prompt_Printf(arg->prompt, "address redirect: invalid local address\n"); - return 1; - } - error = StrToAddr(arg->argv[arg->argn+1], &alias_addr); - if (error) { - prompt_Printf(arg->prompt, "address redirect: invalid alias address\n"); - prompt_Printf(arg->prompt, "Usage: alias %s %s\n", arg->cmd->name, - arg->cmd->syntax); - return 1; - } - link = PacketAliasRedirectAddr(local_addr, alias_addr); - if (link == NULL) { - prompt_Printf(arg->prompt, "address redirect: packet aliasing" - " engine error\n"); - prompt_Printf(arg->prompt, "Usage: alias %s %s\n", arg->cmd->name, - arg->cmd->syntax); - } - } else - return -1; - - return 0; -} - - -static int -StrToAddr(const char *str, struct in_addr *addr) -{ - struct hostent *hp; - - if (inet_aton(str, addr)) - return 0; - - hp = gethostbyname(str); - if (!hp) { - log_Printf(LogWARN, "StrToAddr: Unknown host %s.\n", str); - return -1; - } - *addr = *((struct in_addr *) hp->h_addr); - return 0; -} - - -static int -StrToPort(const char *str, u_short *port, const char *proto) -{ - int iport; - struct servent *sp; - char *end; - - iport = strtol(str, &end, 10); - if (end != str) { - *port = htons(iport); - return 0; - } - sp = getservbyname(str, proto); - if (!sp) { - log_Printf(LogWARN, "StrToAddr: Unknown port or service %s/%s.\n", - str, proto); - return -1; - } - *port = sp->s_port; - return 0; -} - - -static int -StrToAddrAndPort(const char *str, struct in_addr *addr, u_short *port, const char *proto) -{ - char *colon; - int res; - - colon = strchr(str, ':'); - if (!colon) { - log_Printf(LogWARN, "StrToAddrAndPort: %s is missing port number.\n", str); - return -1; - } - - *colon = '\0'; /* Cheat the const-ness ! */ - res = StrToAddr(str, addr); - *colon = ':'; /* Cheat the const-ness ! */ - if (res != 0) - return -1; - - return StrToPort(colon+1, port, proto); -} diff --git a/usr.sbin/ppp/nat_cmd.h b/usr.sbin/ppp/nat_cmd.h deleted file mode 100644 index 495397c14070..000000000000 --- a/usr.sbin/ppp/nat_cmd.h +++ /dev/null @@ -1,11 +0,0 @@ -/*- - * The code in this file was written by Eivind Eklund <perhaps@yes.no>, - * who places it in the public domain without restriction. - * - * $Id: alias_cmd.h,v 1.7.2.2 1998/05/01 19:23:44 brian Exp $ - */ - -struct cmdargs; - -extern int alias_RedirectPort(struct cmdargs const *); -extern int alias_RedirectAddr(struct cmdargs const *); diff --git a/usr.sbin/ppp/ppp.8.m4 b/usr.sbin/ppp/ppp.8.m4 deleted file mode 100644 index 31d12095a8ea..000000000000 --- a/usr.sbin/ppp/ppp.8.m4 +++ /dev/null @@ -1,3857 +0,0 @@ -.\" $Id: ppp.8,v 1.141 1999/01/19 22:15:41 brian Exp $ -.Dd 20 September 1995 -.nr XX \w'\fC00' -.Os FreeBSD -.Dt PPP 8 -.Sh NAME -.Nm ppp -.Nd Point to Point Protocol (a.k.a. user-ppp) -.Sh SYNOPSIS -.Nm -.Oo -.Fl auto | -.Fl background | -.Fl ddial | -.Fl direct | -.Fl dedicated -.Oc -.Op Fl alias -.Op Ar system ... -.Sh DESCRIPTION -This is a user process -.Em PPP -software package. Normally, -.Em PPP -is implemented as a part of the kernel (e.g. as managed by -.Xr pppd 8 ) -and it's thus somewhat hard to debug and/or modify its behaviour. -However, in this implementation -.Em PPP -is done as a user process with the help of the -tunnel device driver (tun). -.Sh Major Features -.Bl -diag -.It Provides interactive user interface. -Using its command mode, the user can -easily enter commands to establish the connection with the remote end, check -the status of connection and close the connection. All functions can -also be optionally password protected for security. -.It Supports both manual and automatic dialing. -Interactive mode has a -.Dq term -command which enables you to talk to your modem directly. When your -modem is connected to the remote peer and it starts to talk -.Em PPP , -.Nm -detects it and switches to packet mode automatically. Once you have -determined the proper sequence for connecting with the remote host, you -can write a chat script to define the necessary dialing and login -procedure for later convenience. -.It Supports on-demand dialup capability. -By using -.Fl auto -mode, -.Nm -will act as a daemon and wait for a packet to be sent over the -.Em PPP -link. When this happens, the daemon automatically dials and establishes the -connection. -In almost the same manner -.Fl ddial -mode (direct-dial mode) also automatically dials and establishes the -connection. However, it differs in that it will dial the remote site -any time it detects the link is down, even if there are no packets to be -sent. This mode is useful for full-time connections where we worry less -about line charges and more about being connected full time. -A third -.Fl dedicated -mode is also available. This mode is targeted at a dedicated link -between two machines. -.Nm Ppp -will never voluntarily quit from dedicated mode - you must send it the -.Dq quit all -command via its diagnostic socket. A -.Dv SIGHUP -will force an LCP renegotiation, and a -.Dv SIGTERM -will force it to exit. -.It Supports client callback. -.Nm Ppp -can use either the standard LCP callback protocol or the Microsoft -CallBack Control Protocol (ftp://ftp.microsoft.com/developr/rfc/cbcp.txt). -.It Supports packet aliasing. -Packet aliasing (a.k.a. IP masquerading) allows computers on a -private, unregistered network to access the Internet. The -.Em PPP -host acts as a masquerading gateway. IP addresses as well as TCP and -UDP port numbers are aliased for outgoing packets and de-aliased for -returning packets. -.It Supports background PPP connections. -In background mode, if -.Nm -successfully establishes the connection, it will become a daemon. -Otherwise, it will exit with an error. This allows the setup of -scripts that wish to execute certain commands only if the connection -is successfully established. -.It Supports server-side PPP connections. -In direct mode, -.Nm -acts as server which accepts incoming -.Em PPP -connections on stdin/stdout. -.It Supports PAP and CHAP authentication. -With PAP or CHAP, it is possible to skip the Unix style -.Xr login 1 -procedure, and use the -.Em PPP -protocol for authentication instead. If the peer requests Microsoft -CHAP authentication and -.Nm -is compiled with DES support, an appropriate MD4/DES response will be -made. -.It Supports Proxy Arp. -When -.Em PPP -is set up as server, you can also configure it to do proxy arp for your -connection. -.It Supports packet filtering. -User can define four kinds of filters: the -.Em in -filter for incoming packets, the -.Em out -filter for outgoing packets, the -.Em dial -filter to define a dialing trigger packet and the -.Em alive -filter for keeping a connection alive with the trigger packet. -.It Tunnel driver supports bpf. -The user can use -.Xr tcpdump 1 -to check the packet flow over the -.Em PPP -link. -.It Supports PPP over TCP capability. -If a device name is specified as -.Em host Ns No : Ns Em port , -.Nm -will open a TCP connection for transporting data rather than using a -conventional serial device. -.It Supports IETF draft Predictor-1 and DEFLATE compression. -.Nm -supports not only VJ-compression but also Predictor-1 and DEFLATE compression. -Normally, a modem has built-in compression (e.g. v42.bis) and the system -may receive higher data rates from it as a result of such compression. -While this is generally a good thing in most other situations, this -higher speed data imposes a penalty on the system by increasing the -number of serial interrupts the system has to process in talking to the -modem and also increases latency. Unlike VJ-compression, Predictor-1 and -DEFLATE compression pre-compresses -.Em all -network traffic flowing through the link, thus reducing overheads to a -minimum. -.It Supports Microsoft's IPCP extensions. -Name Server Addresses and NetBIOS Name Server Addresses can be negotiated -with clients using the Microsoft -.Em PPP -stack (ie. Win95, WinNT) -.It Supports Multi-link PPP -It is possible to configure -.Nm -to open more than one physical connection to the peer, combining the -bandwidth of all links for better throughput. -.El -.Sh PERMISSIONS -.Nm Ppp -is installed as user -.Dv root -and group -.Dv network , -with permissions -.Dv 4554 . -By default, -.Nm -will not run if the invoking user id is not zero. This may be overridden -by using the -.Dq allow users -command in -.Pa /etc/ppp/ppp.conf . -When running as a normal user, -.Nm -switches to user id 0 in order to alter the system routing table, set up -system lock files and read the ppp configuration files. All -external commands (executed via the "shell" or "!bg" commands) are executed -as the user id that invoked -.Nm ppp . -Refer to the -.Sq ID0 -logging facility if you're interested in what exactly is done as user id -zero. -.Sh GETTING STARTED -The following command line switches are understood by -.Nm ppp : -.Bl -tag -width XXX -offset XXX -.It Fl auto -.Nm Ppp -opens the tun interface, configures it then goes into the background. -The link isn't brought up until outgoing data is detected on the tun -interface at which point -.Nm -attempts to bring up the link. Packets received (including the first one) -while -.Nm -is trying to bring the link up will remain queued for a default of -2 minutes. See the -.Dq set choked -command below. -.Pp -At least one -.Dq system -must be given on the command line (see below) and a -.Dq set ifaddr -must be done in the system profile that specifies a peer IP address to -use when configuring the interface. Something like -.Dq 10.0.0.1/0 -is usually appropriate. See the -.Dq pmdemand -system in -.Pa /etc/ppp/ppp.conf.sample -for an example. -.It Fl background -Here, -.Nm -attempts to establish a connection with the peer immediately. If it -succeeds, -.Nm -goes into the background and the parent process returns an exit code -of 0. If it fails, -.Nm -exits with a non-zero result. -.It Fl direct -This is used for receiving incoming connections. -.Nm Ppp -ignores the ``set device'' line and uses descriptor 0 as the link. -.Pp -If callback is configured, -.Nm -will use the -.Dq set device -information when dialing back. -.It Fl dedicated -This option is designed for machines connected with a dedicated -wire. -.Nm Ppp -will always keep the device open and will never use any configured -chat scripts. -.It Fl ddial -This mode is equivalent to -.Fl auto -mode except that -.Nm -will bring the link back up any time it's dropped for any reason. -.It Fl interactive -This is a no-op, and gives the same behaviour as if none of the above -flags have been specified. -.Nm Ppp -loads any systems specified on the command line then provides an -interactive prompt. -.It Fl alias -This flag doesn't control -.Nm ppp Ns No 's -mode. It does the equivalent of an -.Dq enable alias yes . -Additionally, if the -.Fl auto -flag is also specified, an implicit -.Dq enable iface-alias -is done. -See below for details. -.Pp -Enabling IP aliasing allows -.Nm ppp -to act as a NAT or masquerading engine for all machines on an internal -LAN. Refer to -.Xr libalias 3 -for details. -.El -.Pp -Additionally, one or more systems may be specified on the command line. -A -.Sq system -is a configuration entry in -.Pa /etc/ppp/ppp.conf . -.Nm Ppp -will read the -.Dq default -system from -.Pa /etc/ppp/ppp.conf -at startup, followed by each of the systems specifed on the command line. -.Pp -Only one of the -.Fl auto , -.Fl background , -.Fl ddial , -.Fl direct , -.Fl dedicated -and -.Fl interactive -switches may be specified. -.Nm Ppp Ns No 's -.Sq mode -may subsequently be changed with the -.Dq set mode -command (see below). -.Pp -For now, we'll stick to using interactive mode. -.Pp -When you first run -.Nm -you may need to deal with some initial configuration details. -.Bl -bullet -.It -Your kernel must include a tunnel device (the GENERIC kernel includes -one by default). If it doesn't, or if you require more than one tun -interface, you'll need to rebuild your kernel with the following line in -your kernel configuration file: -.Pp -.Dl pseudo-device tun N -.Pp -where -.Ar N -is the maximum number of -.Em PPP -connections you wish to support. -.It -Check your -.Pa /dev -directory for the tunnel device entries -.Pa /dev/tunN , -where -.Sq N -represents the number of the tun device, starting at zero. -If they don't exist, you can create them by running "sh ./MAKEDEV tunN". -This will create tun devices 0 through -.Ar N . -.It -Make sure that your system has a group named -.Dq network -in the -.Pa /etc/group -file and that that group contains the names of all users expected to use -.Nm ppp . -Refer to the -.Xr group 5 -manual page for details. Each of these users must also be given access -using the -.Dq allow users -command in -.Pa /etc/ppp/ppp.conf . -.It -Create a log file. -.Nm Ppp -uses -.Xr syslog 3 -to log information. A common log file name is -.Pa /var/log/ppp.log . -To make output go to this file, put the following lines in the -.Pa /etc/syslog.conf -file: -.Bd -literal -offset indent -!ppp -*.*<TAB>/var/log/ppp.log -.Ed -.Pp -Make sure you use actual TABs here. If you use spaces, the line will be -silently ignored by -.Xr syslogd 8 . -.Pp -It is possible to have more than one -.Em PPP -log file by creating a link to the -.Nm -executable: -.Pp -.Dl # cd /usr/sbin -.Dl # ln ppp ppp0 -.Pp -and using -.Bd -literal -offset indent -!ppp0 -*.*<TAB>/var/log/ppp0.log -.Ed -.Pp -in -.Pa /etc/syslog.conf . -Don't forget to send a -.Dv HUP -signal to -.Xr syslogd 8 -after altering -.Pa /etc/syslog.conf . -.It -Although not strictly relevant to -.Nm ppp Ns No s -operation, you should configure your resolver so that it works correctly. -This can be done by configuring a local DNS -.Pq using Xr named 8 -or by adding the correct -.Sq name-server -lines to the file -.Pa /etc/resolv.conf . -Refer to the -.Xr resolv.conf 5 -manual page for details. -.Pp -Alternatively, if the peer supports it, -.Nm -can be configured to ask the peer for the nameserver address(es) and to -update -.Pa /etc/resolv.conf -automatically. Refer to the -.Dq enable dns -command below for details. -.El -.Sh MANUAL DIALING -In the following examples, we assume that your machine name is -.Dv awfulhak . -when you invoke -.Nm -(see -.Em PERMISSIONS -above) with no arguments, you are presented with a prompt: -.Bd -literal -offset indent -ppp ON awfulhak> -.Ed -.Pp -The -.Sq ON -part of your prompt should always be in upper case. If it is in lower -case, it means that you must supply a password using the -.Dq passwd -command. This only ever happens if you connect to a running version of -.Nm -and have not authenticated yourself using the correct password. -.Pp -You can start by specifying the device name, speed and parity for your modem, -and whether CTS/RTS signalling should be used (CTS/RTS is used by -default). If your hardware does not provide CTS/RTS lines (as -may happen when you are connected directly to certain PPP-capable -terminal servers), -.Nm -will never send any output through the port; it waits for a signal -which never comes. Thus, if you have a direct line and can't seem -to make a connection, try turning CTS/RTS off: -.Bd -literal -offset indent -ppp ON awfulhak> set line /dev/cuaa0 -ppp ON awfulhak> set speed 38400 -ppp ON awfulhak> set parity even -ppp ON awfulhak> set ctsrts on -ppp ON awfulhak> show modem -* Modem related information is shown here * -ppp ON awfulhak> -.Ed -.Pp -The term command can now be used to talk directly with your modem: -.Bd -literal -offset indent -ppp ON awfulhak> term -at -OK -atdt123456 -CONNECT -login: ppp -Password: -Protocol: ppp -.Ed -.Pp -When the peer starts to talk in -.Em PPP , -.Nm -detects this automatically and returns to command mode. -.Bd -literal -offset indent -ppp ON awfulhak> # No link has been established -Ppp ON awfulhak> # We've connected & finished LCP -PPp ON awfulhak> # We've authenticated -PPP ON awfulhak> # We've agreed IP numbers -.Ed -.Pp -If it does not, it's possible that the peer is waiting for your end to -start negotiating or that -.Nm ppp -can't identify the incoming packets as being -.Em PPP -packets, perhaps due to your parity settings. To force -.Nm -to start sending -.Em PPP -configuration packets to the peer, use the -.Dq ~p -command to enter packet mode. -.Pp -You are now connected! Note that -.Sq PPP -in the prompt has changed to capital letters to indicate that you have -a peer connection. If only some of the three Ps go uppercase, wait 'till -either everything is uppercase or lowercase. If they revert to lowercase, -it means that -.Nm -couldn't successfully negotiate with the peer. This is probably because -your PAP or CHAP authentication name or key is incorrect. A good first step -for troubleshooting at this point would be to -.Dq set log local phase . -Refer to the -.Dq set log -command description below for further details. -.Pp -When the link is established, the show command can be used to see how -things are going: -.Bd -literal -offset indent -PPP ON awfulhak> show modem -* Modem related information is shown here * -PPP ON awfulhak> show ccp -* CCP (compression) related information is shown here * -PPP ON awfulhak> show lcp -* LCP (line control) related information is shown here * -PPP ON awfulhak> show ipcp -* IPCP (IP) related information is shown here * -PPP ON awfulhak> show link -* Link (high level) related information is shown here * -PPP ON awfulhak> show bundle -* Logical (high level) connection related information is shown here * -.Ed -.Pp -At this point, your machine has a host route to the peer. This means -that you can only make a connection with the host on the other side -of the link. If you want to add a default route entry (telling your -machine to send all packets without another routing entry to the other -side of the -.Em PPP -link), enter the following command: -.Bd -literal -offset indent -PPP ON awfulhak> add default HISADDR -.Ed -.Pp -The string -.Sq HISADDR -represents the IP address of the connected peer. -If the -.Dq add -command fails due to an existing route, you can overwrite the existing -route using -.Bd -literal -offset indent -PPP ON awfulhak> add! default HISADDR -.Ed -.Pp -You can now use your network applications (ping, telnet, ftp etc.) -in other windows on your machine. -Refer to the -.Em PPP COMMAND LIST -section for details on all available commands. -.Sh AUTOMATIC DIALING -To use automatic dialing, you must prepare some Dial and Login chat scripts. -See the example definitions in -.Pa /etc/ppp/ppp.conf.sample -(the format of -.Pa /etc/ppp/ppp.conf -is pretty simple). -Each line contains one comment, inclusion, label or command: -.Bl -bullet -.It -A line starting with a -.Pq Dq # -character is treated as a comment line. Leading whitespace are ignored -when identifying comment lines. -.It -An inclusion is a line beginning with the word -.Sq !include . -It must have one argument - the file to include. You may wish to -.Dq !include ~/.ppp.conf -for compatibility with older versions of -.Nm ppp . -.It -A label name starts in the first column and is followed by -a colon -.Pq Dq \&: . -.It -A command line must contain a space or tab in the first column. -.El -.Pp -The -.Pa /etc/ppp/ppp.conf -file should consist of at least a -.Dq default -section. This section is always executed. It should also contain -one or more sections, named according to their purpose, for example, -.Dq MyISP -would represent your ISP, and -.Dq ppp-in -would represent an incoming -.Nm -configuration. -You can now specify the destination label name when you invoke -.Nm ppp . -Commands associated with the -.Dq default -label are executed, followed by those associated with the destination -label provided. When -.Nm -is started with no arguments, the -.Dq default -section is still executed. The load command can be used to manually -load a section from the -.Pa /etc/ppp/ppp.conf -file: -.Bd -literal -offset indent -PPP ON awfulhak> load MyISP -.Ed -.Pp -Once the connection is made, the -.Sq ppp -portion of the prompt will change to -.Sq PPP : -.Bd -literal -offset indent -# ppp MyISP -\&... -ppp ON awfulhak> dial -Ppp ON awfulhak> -PPp ON awfulhak> -PPP ON awfulhak> -.Ed -.Pp -The Ppp prompt indicates that -.Nm -has entered the authentication phase. The PPp prompt indicates that -.Nm -has entered the network phase. The PPP prompt indicates that -.Nm -has successfully negotiated a network layer protocol and is in -a usable state. -.Pp -If the -.Pa /etc/ppp/ppp.linkup -file is available, its contents are executed -when the -.Em PPP -connection is established. See the provided -.Dq pmdemand -example in -.Pa /etc/ppp/ppp.conf.sample -which runs a script in the background after the connection is established -(refer to the -.Dq shell -and -.Dq bg -commands below for a description of possible substition strings). Similarly, -when a connection is closed, the contents of the -.Pa /etc/ppp/ppp.linkdown -file are executed. Both of these files have the same format as -.Pa /etc/ppp/ppp.conf . -.Pp -In previous versions of -.Nm ppp , -it was necessary to re-add routes such as the default route in the -.Pa ppp.linkup -file. -.Nm Ppp -now supports -.Sq sticky routes , -where all routes that contain the -.Dv HISADDR -or -.Dv MYADDR -literals will automatically be updated when the values of -.Dv HISADDR -and/or -.Dv MYADDR -change. -.Sh BACKGROUND DIALING -If you want to establish a connection using -.Nm -non-interactively (such as from a -.Xr crontab 5 -entry or an -.Xr at 1 -job) you should use the -.Fl background -option. -When -.Fl background -is specified, -.Nm -attempts to establish the connection immediately. If multiple phone -numbers are specified, each phone number will be tried once. If the -attempt fails, -.Nm -exits immediately with a non-zero exit code. -If it succeeds, then -.Nm -becomes a daemon, and returns an exit status of zero to its caller. -The daemon exits automatically if the connection is dropped by the -remote system, or it receives a -.Dv TERM -signal. -.Sh DIAL ON DEMAND -Demand dialing is enabled with the -.Fl auto -or -.Fl ddial -options. You must also specify the destination label in -.Pa /etc/ppp/ppp.conf -to use. It must contain the -.Dq set ifaddr -command to define the remote peers IP address. (refer to -.Pa /etc/ppp/ppp.conf.sample ) -.Bd -literal -offset indent -# ppp -auto pmdemand -.Ed -.Pp -When -.Fl auto -or -.Fl ddial -is specified, -.Nm -runs as a daemon but you can still configure or examine its -configuration by using the -.Dq set server -command in -.Pa /etc/ppp/ppp.conf , -.Pq for example, Dq set server +3000 mypasswd -and connecting to the diagnostic port as follows: -.Bd -literal -offset indent -# pppctl 3000 (assuming tun0 - see the ``set server'' description) -Password: -PPP ON awfulhak> show who -tcp (127.0.0.1:1028) * -.Ed -.Pp -The -.Dq show who -command lists users that are currently connected to -.Nm -itself. If the diagnostic socket is closed or changed to a different -socket, all connections are immediately dropped. -.Pp -In -.Fl auto -mode, when an outgoing packet is detected, -.Nm -will perform the dialing action (chat script) and try to connect -with the peer. In -.Fl ddial -mode, the dialing action is performed any time the line is found -to be down. -If the connect fails, the default behaviour is to wait 30 seconds -and then attempt to connect when another outgoing packet is detected. -This behaviour can be changed with -.Bd -literal -offset indent -set redial seconds|random[.nseconds|random] [dial_attempts] -.Ed -.Pp -.Sq Seconds -is the number of seconds to wait before attempting -to connect again. If the argument is -.Sq random , -the delay period is a random value between 0 and 30 seconds. -.Sq Nseconds -is the number of seconds to wait before attempting -to dial the next number in a list of numbers (see the -.Dq set phone -command). The default is 3 seconds. Again, if the argument is -.Sq random , -the delay period is a random value between 0 and 30 seconds. -.Sq dial_attempts -is the number of times to try to connect for each outgoing packet -that is received. The previous value is unchanged if this parameter -is omitted. If a value of zero is specified for -.Sq dial_attempts , -.Nm -will keep trying until a connection is made. -.Bd -literal -offset indent -set redial 10.3 4 -.Ed -.Pp -will attempt to connect 4 times for each outgoing packet that is -detected with a 3 second delay between each number and a 10 second -delay after all numbers have been tried. If multiple phone numbers -are specified, the total number of attempts is still 4 (it does not -attempt each number 4 times). -Modifying the dial delay is very useful when running -.Nm -in demand -dial mode on both ends of the link. If each end has the same timeout, -both ends wind up calling each other at the same time if the link -drops and both ends have packets queued. -At some locations, the serial link may not be reliable, and carrier -may be lost at inappropriate times. It is possible to have -.Nm -redial should carrier be unexpectedly lost during a session. -.Bd -literal -offset indent -set reconnect timeout ntries -.Ed -.Pp -This command tells -.Nm -to re-establish the connection -.Ar ntries -times on loss of carrier with a pause of -.Ar timeout -seconds before each try. For example, -.Bd -literal -offset indent -set reconnect 3 5 -.Ed -.Pp -tells -.Nm -that on an unexpected loss of carrier, it should wait -.Ar 3 -seconds before attempting to reconnect. This may happen up to -.Ar 5 -times before -.Nm -gives up. The default value of ntries is zero (no reconnect). Care -should be taken with this option. If the local timeout is slightly -longer than the remote timeout, the reconnect feature will always be -triggered (up to the given number of times) after the remote side -times out and hangs up. -NOTE: In this context, losing too many LQRs constitutes a loss of -carrier and will trigger a reconnect. -If the -.Fl background -flag is specified, all phone numbers are dialed at most once until -a connection is made. The next number redial period specified with -the -.Dq set redial -command is honoured, as is the reconnect tries value. If your redial -value is less than the number of phone numbers specified, not all -the specified numbers will be tried. -To terminate the program, type -.Bd -literal -offset indent -PPP ON awfulhak> close -ppp ON awfulhak> quit all -.Ed -.Pp -A simple -.Dq quit -command will terminate the -.Xr pppctl 8 -or -.Xr telnet 1 -connection but not the -.Nm -program itself. -You must use -.Dq quit all -to terminate -.Nm -as well. -.Sh RECEIVING INCOMING PPP CONNECTIONS (Method 1) -To handle an incoming -.Em PPP -connection request, follow these steps: -.Bl -enum -.It -Make sure the modem and (optionally) -.Pa /etc/rc.serial -is configured correctly. -.Bl -bullet -compact -.It -Use Hardware Handshake (CTS/RTS) for flow control. -.It -Modem should be set to NO echo back (ATE0) and NO results string (ATQ1). -.El -.Pp -.It -Edit -.Pa /etc/ttys -to enable a -.Xr getty 8 -on the port where the modem is attached. -For example: -.Pp -.Dl ttyd1 "/usr/libexec/getty std.38400" dialup on secure -.Pp -Don't forget to send a -.Dv HUP -signal to the -.Xr init 8 -process to start the -.Xr getty 8 : -.Pp -.Dl # kill -HUP 1 -.It -Create a -.Pa /usr/local/bin/ppplogin -file with the following contents: -.Bd -literal -offset indent -#! /bin/sh -exec /usr/sbin/ppp -direct incoming -.Ed -.Pp -Direct mode -.Pq Fl direct -lets -.Nm -work with stdin and stdout. You can also use -.Xr pppctl 8 -to connect to a configured diagnostic port, in the same manner as with -client-side -.Nm ppp . -.Pp -Here, the -.Ar incoming -section must be set up in -.Pa /etc/ppp/ppp.conf . -.Pp -Make sure that the -.Ar incoming -section contains the -.Dq allow users -command as appropriate. -.It -Prepare an account for the incoming user. -.Bd -literal -ppp:xxxx:66:66:PPP Login User:/home/ppp:/usr/local/bin/ppplogin -.Ed -.Pp -Refer to the manual entries for -.Xr adduser 8 -and -.Xr vipw 8 -for details. -.It -Support for IPCP Domain Name Server and NetBIOS Name Server negotiation -can be enabled using the -.Dq accept dns -and -.Dq set nbns -commands. Refer to their descriptions below. -.El -.Pp -.Sh RECEIVING INCOMING PPP CONNECTIONS (Method 2) -This method differs in that we use -.Nm ppp -to authenticate the connection rather than -.Xr login 1 : -.Bl -enum -.It -Configure your default section in -.Pa /etc/gettytab -with automatic ppp recognition by specifying the -.Dq pp -capability: -.Bd -literal -default:\\ - :pp=/usr/local/bin/ppplogin:\\ - ..... -.Ed -.It -Configure your serial device(s), enable a -.Xr getty 8 -and create -.Pa /usr/local/bin/ppplogin -as in the first three steps for method 1 above. -.It -Add either -.Dq enable chap -or -.Dq enable pap -.Pq or both -to -.Pa /etc/ppp/ppp.conf -under the -.Sq incoming -label (or whatever label -.Pa ppplogin -uses). -.It -Create an entry in -.Pa /etc/ppp/ppp.secret -for each incoming user: -.Bd -literal -Pfred<TAB>xxxx -Pgeorge<TAB>yyyy -.Ed -.El -.Pp -Now, as soon as -.Xr getty 8 -detects a ppp connection (by recognising the HDLC frame headers), it runs -.Dq /usr/local/bin/ppplogin . -.Pp -It is -.Em VITAL -that either PAP or CHAP are enabled as above. If they are not, you are -allowing anybody to establish ppp session with your machine -.Em without -a password, opening yourself up to all sorts of potential attacks. -.Sh AUTHENTICATING INCOMING CONNECTIONS -Normally, the receiver of a connection requires that the peer -authenticates itself. This may be done using -.Xr login 1 , -but alternatively, you can use PAP or CHAP. CHAP is the more secure -of the two, but some clients may not support it. Once you decide which -you wish to use, add the command -.Sq enable chap -or -.Sq enable pap -to the relevant section of -.Pa ppp.conf . -.Pp -You must then configure the -.Pa /etc/ppp/ppp.secret -file. This file contains one line per possible client, each line -containing up to four fields: -.Bd -literal -offset indent -name key [hisaddr [label]] -.Ed -.Pp -The -.Ar name -and -.Ar key -specify the client as expected. If -.Ar key -is -.Dq \&* -and PAP is being used, -.Nm -will look up the password database -.Pq Xr passwd 5 -when authenticating. If the client does not offer a suitable -response based on any -.Ar name No / Ar key -combination in -.Pa ppp.secret , -authentication fails. -.Pp -If authentication is successful, -.Ar hisaddr -.Pq if specified -is used when negotiating IP numbers. See the -.Dq set ifaddr -command for details. -.Pp -If authentication is successful and -.Ar label -is specified, the current system label is changed to match the given -.Ar label . -This will change the subsequent parsing of the -.Pa ppp.linkup -and -.Pa ppp.linkdown -files. -.Sh PPP OVER TCP (a.k.a Tunnelling) -Instead of running -.Nm -over a serial link, it is possible to -use a TCP connection instead by specifying a host and port as the -device: -.Pp -.Dl set device ui-gate:6669 -.Pp -Instead of opening a serial device, -.Nm -will open a TCP connection to the given machine on the given -socket. It should be noted however that -.Nm -doesn't use the telnet protocol and will be unable to negotiate -with a telnet server. You should set up a port for receiving this -.Em PPP -connection on the receiving machine (ui-gate). This is -done by first updating -.Pa /etc/services -to name the service: -.Pp -.Dl ppp-in 6669/tcp # Incoming PPP connections over TCP -.Pp -and updating -.Pa /etc/inetd.conf -to tell -.Xr inetd 8 -how to deal with incoming connections on that port: -.Pp -.Dl ppp-in stream tcp nowait root /usr/sbin/ppp ppp -direct ppp-in -.Pp -Don't forget to send a -.Dv HUP -signal to -.Xr inetd 8 -after you've updated -.Pa /etc/inetd.conf . -Here, we use a label named -.Dq ppp-in . -The entry in -.Pa /etc/ppp/ppp.conf -on ui-gate (the receiver) should contain the following: -.Bd -literal -offset indent -ppp-in: - set timeout 0 - set ifaddr 10.0.4.1 10.0.4.2 - add 10.0.1.0/24 10.0.4.2 -.Ed -.Pp -You may also want to enable PAP or CHAP for security. To enable PAP, add -the following line: -.Bd -literal -offset indent - enable PAP -.Ed -.Pp -You'll also need to create the following entry in -.Pa /etc/ppp/ppp.secret : -.Bd -literal -offset indent -MyAuthName MyAuthPasswd -.Ed -.Pp -If -.Ar MyAuthPasswd -is a -.Pq Dq * , -the password is looked up in the -.Xr passwd 5 -database. -.Pp -The entry in -.Pa /etc/ppp/ppp.conf -on awfulhak (the initiator) should contain the following: -.Bd -literal -offset indent -ui-gate: - set escape 0xff - set device ui-gate:ppp-in - set dial - set timeout 30 - set log Phase Chat Connect hdlc LCP IPCP CCP tun - set ifaddr 10.0.4.2 10.0.4.1 - add 10.0.2.0/24 10.0.4.1 -.Ed -.Pp -Again, if you're enabling PAP, you'll also need: -.Bd -literal -offset indent - set authname MyAuthName - set authkey MyAuthKey -.Ed -.Pp -We're assigning the address of 10.0.4.1 to ui-gate, and the address -10.0.4.2 to awfulhak. -To open the connection, just type -.Pp -.Dl awfulhak # ppp -background ui-gate -.Pp -The result will be an additional "route" on awfulhak to the -10.0.2.0/24 network via the TCP connection, and an additional -"route" on ui-gate to the 10.0.1.0/24 network. -The networks are effectively bridged - the underlying TCP -connection may be across a public network (such as the -Internet), and the -.Em PPP -traffic is conceptually encapsulated -(although not packet by packet) inside the TCP stream between -the two gateways. -The major disadvantage of this mechanism is that there are two -"guaranteed delivery" mechanisms in place - the underlying TCP -stream and whatever protocol is used over the -.Em PPP -link - probably TCP again. If packets are lost, both levels will -get in each others way trying to negotiate sending of the missing -packet. -.Sh PACKET ALIASING -The -.Fl alias -command line option enables packet aliasing. This allows the -.Nm -host to act as a masquerading gateway for other computers over -a local area network. Outgoing IP packets are aliased so that -they appear to come from the -.Nm -host, and incoming packets are de-aliased so that they are routed -to the correct machine on the local area network. -Packet aliasing allows computers on private, unregistered -subnets to have Internet access, although they are invisible -from the outside world. -In general, correct -.Nm -operation should first be verified with packet aliasing disabled. -Then, the -.Fl alias -option should be switched on, and network applications (web browser, -.Xr telnet 1 , -.Xr ftp 1 , -.Xr ping 8 , -.Xr traceroute 8 ) -should be checked on the -.Nm -host. Finally, the same or similar applications should be checked on other -computers in the LAN. -If network applications work correctly on the -.Nm -host, but not on other machines in the LAN, then the masquerading -software is working properly, but the host is either not forwarding -or possibly receiving IP packets. Check that IP forwarding is enabled in -.Pa /etc/rc.conf -and that other machines have designated the -.Nm -host as the gateway for the LAN. -.Sh PACKET FILTERING -This implementation supports packet filtering. There are four kinds of -filters; the -.Em in -filter, the -.Em out -filter, the -.Em dial -filter and the -.Em alive -filter. Here are the basics: -.Bl -bullet -.It -A filter definition has the following syntax: -.Pp -set filter -.Ar name -.Ar rule-no -.Ar action -.Op Ar src_addr Ns Op / Ns Ar width -.Op Ar dst_addr Ns Op / Ns Ar width -[ -.Ar proto -.Op src Op Ar cmp No Ar port -.Op dst Op Ar cmp No Ar port -.Op estab -.Op syn -.Op finrst -] -.Bl -enum -.It -.Ar Name -should be one of -.Sq in , -.Sq out , -.Sq dial -or -.Sq alive . -.It -.Ar Rule-no -is a numeric value between -.Sq 0 -and -.Sq 19 -specifying the rule number. Rules are specified in numeric order according to -.Ar rule-no , -but only if rule -.Sq 0 -is defined. -.It -.Ar Action -is either -.Sq permit -or -.Sq deny . -If a given packet -matches the rule, the associated action is taken immediately. -.It -.Op Ar src_addr Ns Op / Ns Ar width -and -.Op Ar dst_addr Ns Op / Ns Ar width -are the source and destination IP number specifications. If -.Op / Ns Ar width -is specified, it gives the number of relevant netmask bits, -allowing the specification of an address range. -.It -.Ar Proto -must be one of -.Sq icmp , -.Sq udp -or -.Sq tcp . -.It -.Ar Cmp -is one of -.Sq \< , -.Sq \&eq -or -.Sq \> , -meaning less-than, equal and greater-than respectively. -.Ar Port -can be specified as a numeric port or by service name from -.Pa /etc/services . -.It -The -.Sq estab , -.Sq syn , -and -.Sq finrst -flags are only allowed when -.Ar proto -is set to -.Sq tcp , -and represent the TH_ACK, TH_SYN and TH_FIN or TH_RST TCP flags respectively. -.El -.Pp -.It -Each filter can hold up to 40 rules, starting from rule 0. -The entire rule set is not effective until rule 0 is defined, -ie. the default is to allow everything through. -.It -If no rule is matched to a packet, that packet will be discarded -(blocked). -.It -Use -.Dq set filter Ar name No -1 -to flush all rules. -.El -.Pp -See -.Pa /etc/ppp/ppp.conf.sample . -.Sh SETTING THE IDLE TIMER -To check/set the idle timer, use the -.Dq show bundle -and -.Dq set timeout -commands: -.Bd -literal -offset indent -ppp ON awfulhak> set timeout 600 -.Ed -.Pp -The timeout period is measured in seconds, the default value for which -is 180 seconds -.Pq or 3 min . -To disable the idle timer function, use the command -.Bd -literal -offset indent -ppp ON awfulhak> set timeout 0 -.Ed -.Pp -In -.Fl ddial -and -.Fl dedicated -modes, the idle timeout is ignored. In -.Fl auto -mode, when the idle timeout causes the -.Em PPP -session to be -closed, the -.Nm -program itself remains running. Another trigger packet will cause it to -attempt to re-establish the link. -.Sh PREDICTOR-1 and DEFLATE COMPRESSION -.Nm Ppp -supports both Predictor type 1 and deflate compression. -By default, -.Nm -will attempt to use (or be willing to accept) both compression protocols -when the peer agrees -.Pq or requests them . -The deflate protocol is preferred by -.Nm ppp . -Refer to the -.Dq disable -and -.Dq deny -commands if you wish to disable this functionality. -.Pp -It is possible to use a different compression algorithm in each direction -by using only one of -.Dq disable deflate -and -.Dq deny deflate -.Pq assuming that the peer supports both algorithms . -.Pp -By default, when negotiating DEFLATE, -.Nm -will use a window size of 15. Refer to the -.Dq set deflate -command if you wish to change this behaviour. -.Pp -A special algorithm called DEFLATE24 is also available, and is disabled -and denied by default. This is exactly the same as DEFLATE except that -it uses CCP ID 24 to negotiate. This allows -.Nm -to successfully negotiate DEFLATE with -.Nm pppd -version 2.3.*. -.Sh CONTROLLING IP ADDRESS -.Nm -uses IPCP to negotiate IP addresses. Each side of the connection -specifies the IP address that it's willing to use, and if the requested -IP address is acceptable then -.Nm -returns ACK to the requester. Otherwise, -.Nm -returns NAK to suggest that the peer use a different IP address. When -both sides of the connection agree to accept the received request (and -send ACK), IPCP is set to the open state and a network level connection -is established. -To control this IPCP behaviour, this implementation has the -.Dq set ifaddr -command for defining the local and remote IP address: -.Bd -literal -offset indent -set ifaddr [src_addr [dst_addr [netmask [trigger_addr]]]] -.Ed -.Pp -where, -.Sq src_addr -is the IP address that the local side is willing to use, -.Sq dst_addr -is the IP address which the remote side should use and -.Sq netmask -is the netmask that should be used. -.Sq Src_addr -defaults to the current -.Xr hostname 1 , -.Sq dst_addr -defaults to 0.0.0.0, and -.Sq netmask -defaults to whatever mask is appropriate for -.Sq src_addr . -It is only possible to make -.Sq netmask -smaller than the default. The usual value is 255.255.255.255, as -most kernels ignore the netmask of a POINTOPOINT interface. -.Pp -Some incorrect -.Em PPP -implementations require that the peer negotiates a specific IP -address instead of -.Sq src_addr . -If this is the case, -.Sq trigger_addr -may be used to specify this IP number. This will not affect the -routing table unless the other side agrees with this proposed number. -.Bd -literal -offset indent -set ifaddr 192.244.177.38 192.244.177.2 255.255.255.255 0.0.0.0 -.Ed -.Pp -The above specification means: -.Pp -.Bl -bullet -compact -.It -I will first suggest that my IP address should be 0.0.0.0, but I -will only accept an address of 192.244.177.38. -.It -I strongly insist that the peer uses 192.244.177.2 as his own -address and won't permit the use of any IP address but 192.244.177.2. -When the peer requests another IP address, I will always suggest that -it uses 192.244.177.2. -.It -The routing table entry will have a netmask of 0xffffffff. -.El -.Pp -This is all fine when each side has a pre-determined IP address, however -it is often the case that one side is acting as a server which controls -all IP addresses and the other side should obey the direction from it. -In order to allow more flexible behaviour, `ifaddr' variable allows the -user to specify IP address more loosely: -.Pp -.Dl set ifaddr 192.244.177.38/24 192.244.177.2/20 -.Pp -A number followed by a slash (/) represent the number of bits significant in -the IP address. The above example signifies that: -.Pp -.Bl -bullet -compact -.It -I'd like to use 192.244.177.38 as my address if it is possible, but I'll -also accept any IP address between 192.244.177.0 and 192.244.177.255. -.It -I'd like to make him use 192.244.177.2 as his own address, but I'll also -permit him to use any IP address between 192.244.176.0 and -192.244.191.255. -.It -As you may have already noticed, 192.244.177.2 is equivalent to saying -192.244.177.2/32. -.It -As an exception, 0 is equivalent to 0.0.0.0/0, meaning that I have no -preferred IP address and will obey the remote peers selection. When -using zero, no routing table entries will be made until a connection -is established. -.It -192.244.177.2/0 means that I'll accept/permit any IP address but I'll -try to insist that 192.244.177.2 be used first. -.El -.Pp -.Sh CONNECTING WITH YOUR INTERNET SERVICE PROVIDER -The following steps should be taken when connecting to your ISP: -.Bl -enum -.It -Describe your providers phone number(s) in the dial script using the -.Dq set phone -command. This command allows you to set multiple phone numbers for -dialing and redialing separated by either a pipe (|) or a colon (:) -.Bd -literal -offset indent -set phone "111[|222]...[:333[|444]...]... -.Ed -.Pp -Numbers after the first in a pipe-separated list are only used if the -previous number was used in a failed dial or login script. Numbers -separated by a colon are used sequentially, irrespective of what happened -as a result of using the previous number. For example: -.Bd -literal -offset indent -set phone "1234567|2345678:3456789|4567890" -.Ed -.Pp -Here, the 1234567 number is attempted. If the dial or login script fails, -the 2345678 number is used next time, but *only* if the dial or login script -fails. On the dial after this, the 3456789 number is used. The 4567890 -number is only used if the dial or login script using the 3456789 fails. If -the login script of the 2345678 number fails, the next number is still the -3456789 number. As many pipes and colons can be used as are necessary -(although a given site would usually prefer to use either the pipe or the -colon, but not both). The next number redial timeout is used between all -numbers. When the end of the list is reached, the normal redial period is -used before starting at the beginning again. -The selected phone number is substituted for the \\\\T string in the -.Dq set dial -command (see below). -.It -Set up your redial requirements using -.Dq set redial . -For example, if you have a bad telephone line or your provider is -usually engaged (not so common these days), you may want to specify -the following: -.Bd -literal -offset indent -set redial 10 4 -.Ed -.Pp -This says that up to 4 phone calls should be attempted with a pause of 10 -seconds before dialing the first number again. -.It -Describe your login procedure using the -.Dq set dial -and -.Dq set login -commands. The -.Dq set dial -command is used to talk to your modem and establish a link with your -ISP, for example: -.Bd -literal -offset indent -set dial "ABORT BUSY ABORT NO\\\\sCARRIER TIMEOUT 4 \\"\\" \e - ATZ OK-ATZ-OK ATDT\\\\T TIMEOUT 60 CONNECT" -.Ed -.Pp -This modem "chat" string means: -.Bl -bullet -.It -Abort if the string "BUSY" or "NO CARRIER" are received. -.It -Set the timeout to 4 seconds. -.It -Expect nothing. -.It -Send ATZ. -.It -Expect OK. If that's not received within the 4 second timeout, send ATZ -and expect OK. -.It -Send ATDTxxxxxxx where xxxxxxx is the next number in the phone list from -above. -.It -Set the timeout to 60. -.It -Wait for the CONNECT string. -.El -.Pp -Once the connection is established, the login script is executed. This -script is written in the same style as the dial script, but care should -be taken to avoid having your password logged: -.Bd -literal -offset indent -set authkey MySecret -set login "TIMEOUT 15 login:-\\\\r-login: awfulhak \e - word: \\\\P ocol: PPP HELLO" -.Ed -.Pp -This login "chat" string means: -.Bl -bullet -.It -Set the timeout to 15 seconds. -.It -Expect "login:". If it's not received, send a carriage return and expect -"login:" again. -.It -Send "awfulhak" -.It -Expect "word:" (the tail end of a "Password:" prompt). -.It -Send whatever our current -.Ar authkey -value is set to. -.It -Expect "ocol:" (the tail end of a "Protocol:" prompt). -.It -Send "PPP". -.It -Expect "HELLO". -.El -.Pp -The -.Dq set authkey -command is logged specially (when using -.Ar command -logging) so that the actual password is not compromised -(it is logged as -.Sq ******** Ns -), and the '\\P' is logged when -.Ar chat -logging is active rather than the actual password. -.Pp -Login scripts vary greatly between ISPs. If you're setting one up -for the first time, -.Em ENABLE CHAT LOGGING -so that you can see if your script is behaving as you expect. -.It -Use -.Dq set line -and -.Dq set speed -to specify your serial line and speed, for example: -.Bd -literal -offset indent -set line /dev/cuaa0 -set speed 115200 -.Ed -.Pp -Cuaa0 is the first serial port on FreeBSD. If you're running -.Nm -on OpenBSD, cua00 is the first. A speed of 115200 should be specified -if you have a modem capable of bit rates of 28800 or more. In general, -the serial speed should be about four times the modem speed. -.It -Use the -.Dq set ifaddr -command to define the IP address. -.Bl -bullet -.It -If you know what IP address your provider uses, then use it as the remote -address (dst_addr), otherwise choose something like 10.0.0.2/0 (see below). -.It -If your provider has assigned a particular IP address to you, then use -it as your address (src_addr). -.It -If your provider assigns your address dynamically, choose a suitably -unobtrusive and unspecific IP number as your address. 10.0.0.1/0 would -be appropriate. The bit after the / specifies how many bits of the -address you consider to be important, so if you wanted to insist on -something in the class C network 1.2.3.0, you could specify 1.2.3.1/24. -.It -If you find that your ISP accepts the first IP number that you suggest, -specify third and forth arguments of -.Dq 0.0.0.0 . -This will force your ISP to assign a number. (The third argument will -be ignored as it is less restrictive than the default mask for your -.Sq src_addr . -.El -.Pp -An example for a connection where you don't know your IP number or your -ISPs IP number would be: -.Bd -literal -offset indent -set ifaddr 10.0.0.1/0 10.0.0.2/0 0.0.0.0 0.0.0.0 -.Ed -.Pp -.It -In most cases, your ISP will also be your default router. If this is -the case, add the line -.Bd -literal -offset indent -add default HISADDR -.Ed -.Pp -to -.Pa /etc/ppp/ppp.conf . -.Pp -This tells -.Nm -to add a default route to whatever the peer address is -.Pq 10.0.0.2 in this example . -This route is -.Sq sticky , -meaning that should the value of -.Dv HISADDR -change, the route will be updated accordingly. -.Pp -Previous versions of -.Nm -required a similar entry in the -.Pa /etc/ppp/ppp.linkup -file. Since the advent of -.Sq sticky routes , -this is no longer required. -.It -If your provider requests that you use PAP/CHAP authentication methods, add -the next lines to your -.Pa /etc/ppp/ppp.conf -file: -.Bd -literal -offset indent -set authname MyName -set authkey MyPassword -.Ed -.Pp -Both are accepted by default, so -.Nm -will provide whatever your ISP requires. -.Pp -It should be noted that a login script is rarely (if ever) required -when PAP or CHAP are in use. -.It -Ask your ISP to authenticate your nameserver address(es) with the line -.Bd -literal -offset indent -enable dns -.Ed -Do -.Em NOT -do this if you are running an local DNS, as -.Nm -will simply circumvent its use by entering some nameserver lines in -.Pa /etc/resolv.conf . -.El -.Pp -Please refer to -.Pa /etc/ppp/ppp.conf.sample -and -.Pa /etc/ppp/ppp.linkup.sample -for some real examples. The pmdemand label should be appropriate for most -ISPs. -.Sh LOGGING FACILITY -.Nm Ppp -is able to generate the following log info either via -.Xr syslog 3 -or directly to the screen: -.Pp -.Bl -tag -width XXXXXXXXX -offset XXX -compact -.It Li Async -Dump async level packet in hex. -.It Li CBCP -Generate CBCP (CallBack Control Protocol) logs. -.It Li CCP -Generate a CCP packet trace. -.It Li Chat -Generate -.Sq dial , -.Sq login -and -.Sq hangup -chat script trace logs. -.It Li Command -Log commands executed either from the command line or any of the configuration -files. -.It Li Connect -Log Chat lines containing the string "CONNECT". -.It Li Debug -Log debug information. -.It Li HDLC -Dump HDLC packet in hex. -.It Li ID0 -Log all function calls specifically made as user id 0. -.It Li IPCP -Generate an IPCP packet trace. -.It Li LCP -Generate an LCP packet trace. -.It Li LQM -Generate LQR reports. -.It Li Phase -Phase transition log output. -.It Li TCP/IP -Dump all TCP/IP packets. -.It Li Timer -Log timer manipulation. -.It Li TUN -Include the tun device on each log line. -.It Li Warning -Output to the terminal device. If there is currently no terminal, -output is sent to the log file using syslogs -.Dv LOG_WARNING . -.It Li Error -Output to both the terminal device -and the log file using syslogs -.Dv LOG_ERROR . -.It Li Alert -Output to the log file using -.Dv LOG_ALERT . -.El -.Pp -The -.Dq set log -command allows you to set the logging output level. Multiple levels -can be specified on a single command line. The default is equivalent to -.Dq set log Phase . -.Pp -It is also possible to log directly to the screen. The syntax is -the same except that the word -.Dq local -should immediately follow -.Dq set log . -The default is -.Dq set log local -(ie. only the un-maskable warning, error and alert output). -.Pp -If The first argument to -.Dq set log Op local -begins with a '+' or a '-' character, the current log levels are -not cleared, for example: -.Bd -literal -offset indent -PPP ON awfulhak> set log phase -PPP ON awfulhak> show log -Log: Phase Warning Error Alert -Local: Warning Error Alert -PPP ON awfulhak> set log +tcp/ip -warning -PPP ON awfulhak> set log local +command -PPP ON awfulhak> show log -Log: Phase TCP/IP Warning Error Alert -Local: Command Warning Error Alert -.Ed -.Pp -Log messages of level Warning, Error and Alert are not controllable -using -.Dq set log Op local . -.Pp -The -.Ar Warning -level is special in that it will not be logged if it can be displayed -locally. -.Sh SIGNAL HANDLING -.Nm Ppp -deals with the following signals: -.Bl -tag -width XX -.It INT -Receipt of this signal causes the termination of the current connection -(if any). This will cause -.Nm -to exit unless it is in -.Fl auto -or -.Fl ddial -mode. -.It HUP, TERM & QUIT -These signals tell -.Nm -to exit. -.It USR2 -This signal, tells -.Nm -to close any existing server socket, dropping all existing diagnostic -connections. -.El -.Pp -.Sh MULTI-LINK PPP -If you wish to use more than one physical link to connect to a -.Em PPP -peer, that peer must also understand the -.Em MULTI-LINK PPP -protocol. Refer to RFC 1990 for specification details. -.Pp -The peer is identified using a combination of his -.Dq endpoint discriminator -and his -.Dq authentication id . -Either or both of these may be specified. It is recommended that -at least one is specified, otherwise there is no way of ensuring that -all links are actually connected to the same peer program, and some -confusing lock-ups may result. Locally, these identification variables -are specified using the -.Dq set enddisc -and -.Dq set authname -commands. The -.Sq authname -.Pq and Sq authkey -must be agreed in advance with the peer. -.Pp -Multi-link capabilities are enabled using the -.Dq set mrru -command (set maximum reconstructed receive unit). Once multi-link -is enabled, -.Nm -will attempt to negotiate a multi-link connection with the peer. -.Pp -By default, only one -.Sq link -is available -.Pq called Sq deflink . -To create more links, the -.Dq clone -command is used. This command will clone existing links, where all -characteristics are the same except: -.Bl -enum -.It -The new link has its own name as specified on the -.Dq clone -command line. -.It -The new link is an -.Sq interactive -link. It's mode may subsequently be changed using the -.Dq set mode -command. -.It -The new link is in a -.Sq closed -state. -.El -.Pp -A summary of all available links can be seen using the -.Dq show links -command. -.Pp -Once a new link has been created, command usage varies. All link -specific commands must be prefixed with the -.Dq link Ar name -command, specifying on which link the command is to be applied. When -only a single link is available, -.Nm -is smart enough not to require the -.Dq link Ar name -prefix. -.Pp -Some commands can still be used without specifying a link - resulting -in an operation at the -.Sq bundle -level. For example, once two or more links are available, the command -.Dq show ccp -will show CCP configuration and statistics at the multi-link level, and -.Dq link deflink show ccp -will show the same information at the -.Dq deflink -link level. -.Pp -Armed with this information, the following configuration might be used: -.Pp -.Bd -literal -offset indent -mp: - set timeout 0 - set log phase chat - set device /dev/cuaa0 /dev/cuaa1 /dev/cuaa2 - set phone "123456789" - set dial "ABORT BUSY ABORT NO\\sCARRIER TIMEOUT 5 \\"\\" ATZ \e - OK-AT-OK \\\\dATDT\\\\T TIMEOUT 45 CONNECT" - set login - set ifaddr 10.0.0.1/0 10.0.0.2/0 - set authname ppp - set authkey ppppassword - - set mrru 1500 - clone 1,2,3 - link deflink remove -.Ed -.Pp -Note how all cloning is done at the end of the configuration. Usually, -the link will be configured first, then cloned. If you wish all links -to be up all the time, you can add the following line to the end of your -configuration. -.Pp -.Bd -literal -offset indent - link 1,2,3 set mode ddial -.Ed -.Pp -If you want the links to dial on demand, this command could be used: -.Pp -.Bd -literal -offset indent - link * set mode auto -.Ed -.Pp -Links may be tied to specific names by removing the -.Dq set device -line above, and specifying the following after the -.Dq clone -command: -.Pp -.Bd -literal -offset indent - link 1 set device /dev/cuaa0 - link 2 set device /dev/cuaa1 - link 3 set device /dev/cuaa2 -.Ed -.Pp -Use the -.Dq help -command to see which commands require context (using the -.Dq link -command), which have optional -context and which should not have any context. -.Pp -When -.Nm -has negotiated -.Em MULTI-LINK -mode with the peer, it creates a local domain socket in the -.Pa /var/run -directory. This socket is used to pass link information (including -the actual link file descriptor) between different -.Nm -invocations. This facilitates -.Nm ppp Ns No s -ability to be run from a -.Xr getty 8 -or directly from -.Pa /etc/gettydefs -(using the -.Sq pp= -capability), without needing to have initial control of the serial -line. Once -.Nm -negotiates multi-link mode, it will pass its open link to any -already running process. If there is no already running process, -.Nm -will act as the master, creating the socket and listening for new -connections. -.Sh PPP COMMAND LIST -This section lists the available commands and their effect. They are -usable either from an interactive -.Nm -session, from a configuration file or from a -.Xr pppctl 8 -or -.Xr telnet 1 -session. -.Bl -tag -width XX -.It accept|deny|enable|disable Ar option.... -These directives tell -.Nm -how to negotiate the initial connection with the peer. Each -.Dq option -has a default of either accept or deny and enable or disable. -.Dq Accept -means that the option will be ACK'd if the peer asks for it. -.Dq Deny -means that the option will be NAK'd if the peer asks for it. -.Dq Enable -means that the option will be requested by us. -.Dq Disable -means that the option will not be requested by us. -.Pp -.Dq Option -may be one of the following: -.Bl -tag -width XX -.It acfcomp -Default: Enabled and Accepted. ACFComp stands for Address and Control -Field Compression. Non LCP packets usually have very similar address -and control fields - making them easily compressible. -.It chap -Default: Disabled and Accepted. CHAP stands for Challenge Handshake -Authentication Protocol. Only one of CHAP and PAP (below) may be -negotiated. With CHAP, the authenticator sends a "challenge" message -to its peer. The peer uses a one-way hash function to encrypt the -challenge and sends the result back. The authenticator does the same, -and compares the results. The advantage of this mechanism is that no -passwords are sent across the connection. -A challenge is made when the connection is first made. Subsequent -challenges may occur. If you want to have your peer authenticate -itself, you must -.Dq enable chap . -in -.Pa /etc/ppp/ppp.conf , -and have an entry in -.Pa /etc/ppp/ppp.secret -for the peer. -.Pp -When using CHAP as the client, you need only specify -.Dq AuthName -and -.Dq AuthKey -in -.Pa /etc/ppp/ppp.conf . -CHAP is accepted by default. -Some -.Em PPP -implementations use "MS-CHAP" rather than MD5 when encrypting the -challenge. MS-CHAP is a combination of MD4 and DES. If -.Nm -was built on a machine with DES libraries available, it will respond -to MS-CHAP authentication requests, but will never request them. -.It deflate -Default: Enabled and Accepted. This option decides if deflate -compression will be used by the Compression Control Protocol (CCP). -This is the same algorithm as used by the -.Xr gzip 1 -program. -Note: There is a problem negotiating -.Ar deflate -capabilities with -.Xr pppd 8 -- a -.Em PPP -implementation available under many operating systems. -.Nm Pppd -(version 2.3.1) incorrectly attempts to negotiate -.Ar deflate -compression using type -.Em 24 -as the CCP configuration type rather than type -.Em 26 -as specified in -.Pa rfc1979 . -Type -.Ar 24 -is actually specified as -.Dq PPP Magna-link Variable Resource Compression -in -.Pa rfc1975 Ns No ! -.Nm Ppp -is capable of negotiating with -.Nm pppd , -but only if -.Dq deflate24 -is -.Ar enable Ns No d -and -.Ar accept Ns No ed . -.It deflate24 -Default: Disabled and Denied. This is a variance of the -.Ar deflate -option, allowing negotiation with the -.Xr pppd 8 -program. Refer to the -.Ar deflate -section above for details. It is disabled by default as it violates -.Pa rfc1975 . -.It dns -Default: Disabled and Denied. This option allows DNS negotiation. -.Pp -If -.Dq enable Ns No d, -.Nm -will request that the peer confirms the entries in -.Pa /etc/resolv.conf . -If the peer NAKs our request (suggesting new IP numbers), -.Pa /etc/resolv.conf -is updated and another request is sent to confirm the new entries. -.Pp -If -.Dq accept Ns No ed, -.Nm -will answer any DNS queries requested by the peer rather than rejecting -them. The answer is taken from -.Pa /etc/resolv.conf -unless the -.Dq set dns -command is used as an override. -.It lqr -Default: Disabled and Accepted. This option decides if Link Quality -Requests will be sent or accepted. LQR is a protocol that allows -.Nm -to determine that the link is down without relying on the modems -carrier detect. When LQR is enabled, -.Nm -sends the -.Em QUALPROTO -option (see -.Dq set lqrperiod -below) as part of the LCP request. If the peer agrees, both sides will -exchange LQR packets at the agreed frequency, allowing detailed link -quality monitoring by enabling LQM logging. If the peer doesn't agree, -ppp will send ECHO LQR requests instead. These packets pass no -information of interest, but they -.Em MUST -be replied to by the peer. -.Pp -Whether using LQR or ECHO LQR, -.Nm -will abruptly drop the connection if 5 unacknowledged packets have been -sent rather than sending a 6th. A message is logged at the -.Em PHASE -level, and any appropriate -.Dq reconnect -values are honoured as if the peer were responsible for dropping the -connection. -.It pap -Default: Disabled and Accepted. PAP stands for Password Authentication -Protocol. Only one of PAP and CHAP (above) may be negotiated. With -PAP, the ID and Password are sent repeatedly to the peer until -authentication is acknowledged or the connection is terminated. This -is a rather poor security mechanism. It is only performed when the -connection is first established. -If you want to have your peer authenticate itself, you must -.Dq enable pap . -in -.Pa /etc/ppp/ppp.conf , -and have an entry in -.Pa /etc/ppp/ppp.secret -for the peer (although see the -.Dq passwdauth -option below). -.Pp -When using PAP as the client, you need only specify -.Dq AuthName -and -.Dq AuthKey -in -.Pa /etc/ppp/ppp.conf . -PAP is accepted by default. -.It pred1 -Default: Enabled and Accepted. This option decides if Predictor 1 -compression will be used by the Compression Control Protocol (CCP). -.It protocomp -Default: Enabled and Accepted. This option is used to negotiate -PFC (Protocol Field Compression), a mechanism where the protocol -field number is reduced to one octet rather than two. -.It shortseq -Default: Enabled and Accepted. This option determines if -.Nm -will request and accept requests for short -.Pq 12 bit -sequence numbers when negotiating multi-link mode. This is only -applicable if our MRRU is set (thus enabling multi-link). -.It vjcomp -Default: Enabled and Accepted. This option determines if Van Jacobson -header compression will be used. -.El -.Pp -The following options are not actually negotiated with the peer. -Therefore, accepting or denying them makes no sense. -.Bl -tag -width XX -.It idcheck -Default: Enabled. When -.Nm -exchanges low-level LCP, CCP and IPCP configuration traffic, the -.Em Identifier -field of any replies is expected to be the same as that of the request. -By default, -.Nm -drops any reply packets that do not contain the expected identifier -field, reporting the fact at the respective log level. If -.Ar idcheck -is disabled, -.Nm -will ignore the identifier field. -.It loopback -Default: Enabled. When -.Ar loopback -is enabled, -.Nm -will automatically loop back packets being sent -out with a destination address equal to that of the -.Em PPP -interface. If disabled, -.Nm -will send the packet, probably resulting in an ICMP redirect from -the other end. It is convenient to have this option enabled when -the interface is also the default route as it avoids the necessity -of a loopback route. -.It passwdauth -Default: Disabled. Enabling this option will tell the PAP authentication -code to use the password database (see -.Xr passwd 5 ) -to authenticate the caller if they cannot be found in the -.Pa /etc/ppp/ppp.secret -file. -.Pa /etc/ppp/ppp.secret -is always checked first. If you wish to use passwords from -.Xr passwd 5 , -but also to specify an IP number or label for a given client, use -.Dq \&* -as the client password in -.Pa /etc/ppp/ppp.secret . -.It proxy -Default: Disabled. Enabling this option will tell -.Nm -to proxy ARP for the peer. -.It proxyall -Default: Disabled. Enabling this will tell -.Nm -to add proxy arp entries for every IP address in all class C or -smaller subnets routed via the tun interface. -.It sroutes -Default: Enabled. When the -.Dq add -command is used with the -.Dv HISADDR -or -.Dv MYADDR -values, entries are stored in the -.Sq stick route -list. Each time -.Dv HISADDR -or -.Dv MYADDR -change, this list is re-applied to the routing table. -.Pp -Disabling this option will prevent the re-application of sticky routes, -although the -.Sq stick route -list will still be maintained. -.It throughput -Default: Enabled. This option tells -.Nm -to gather throughput statistics. Input and output is sampled over -a rolling 5 second window, and current, best and total figures are -retained. This data is output when the relevant -.Em PPP -layer shuts down, and is also available using the -.Dq show -command. Throughput statistics are available at the -.Dq IPCP -and -.Dq modem -levels. -.It utmp -Default: Enabled. Normally, when a user is authenticated using PAP or -CHAP, and when -.Nm -is running in -.Fl direct -mode, an entry is made in the utmp and wtmp files for that user. Disabling -this option will tell -.Nm -not to make any utmp or wtmp entries. This is usually only necessary if -you require the user to both login and authenticate themselves. -.It iface-alias -Default: Enabled if -.Fl alias -is specified. This option simply tells -.Nm -to add new interface addresses to the interface rather than replacing them. -The option can only be enabled if IP aliasing is enabled -.Pq Dq alias enable yes . -.Pp -With this option enabled, -.Nm -will pass traffic for old interface addresses through the IP alias engine -.Pq see Xr libalias 5 , -resulting in the ability (in -.Fl auto -mode) to properly connect the process that caused the PPP link to -come up in the first place. -.Pp -Disabling IP aliasing with -.Dq alias enable off -will also disable -.Sq iface-alias . -.El -.Pp -.It add[!] Ar dest[/nn] [mask] gateway -.Ar Dest -is the destination IP address. The netmask is specified either as a -number of bits with -.Ar /nn -or as an IP number using -.Ar mask . -.Ar 0 0 -or simply -.Ar 0 -with no mask refers to the default route. It is also possible to use the -literal name -.Sq default -instead of -.Ar 0 . -.Ar Gateway -is the next hop gateway to get to the given -.Ar dest -machine/network. Refer to the -.Xr route 8 -command for further details. -.Pp -It is possible to use the symbolic names -.Sq MYADDR -or -.Sq HISADDR -as the destination, and -.Sq HISADDR -as the -.Ar gateway . -.Sq MYADDR -is replaced with the interface address and -.Sq HISADDR -is replaced with the interface destination (peer) address. -.Pp -If the -.Ar add! -command is used -.Pq note the trailing Dq \&! , -then if the route already exists, it will be updated as with the -.Sq route change -command (see -.Xr route 8 -for further details). -.Pp -Routes that contain the -.Dq HISADDR -or -.Dq MYADDR -constants are considered -.Sq sticky . -They are stored in a list (use -.Dq show ipcp -to see the list), and each time the value of -.Dv HISADDR -or -.Dv MYADDR -changes, the appropriate routing table entries are updated. This facility -may be disabled using -.Dq disable sroutes . -.It allow Ar command Op Ar args -This command controls access to -.Nm -and its configuration files. It is possible to allow user-level access, -depending on the configuration file label and on the mode that -.Nm -is being run in. For example, you may wish to configure -.Nm -so that only user -.Sq fred -may access label -.Sq fredlabel -in -.Fl background -mode. -.Pp -User id 0 is immune to these commands. -.Bl -tag -width XX -.It allow user[s] Ar logname... -By default, only user id 0 is allowed access to -.Nm ppp . -If this command is used, all of the listed users are allowed access to -the section in which the -.Dq allow users -command is found. The -.Sq default -section is always checked first (even though it is only ever automatically -loaded at startup). Each successive -.Dq allow users -command overrides the previous one, so it's possible to allow users access -to everything except a given label by specifying default users in the -.Sq default -section, and then specifying a new user list for that label. -.Pp -If user -.Sq * -is specified, access is allowed to all users. -.It allow mode[s] Ar modelist... -By default, access using any -.Nm -mode is possible. If this command is used, it restricts the access -mode allowed to load the label under which this command is specified. -Again, as with the -.Dq allow users -command, each -.Dq allow modes -command overrides the previous, and the -.Sq default -section is always checked first. -.Pp -Possible modes are: -.Sq interactive , -.Sq auto , -.Sq direct , -.Sq dedicated , -.Sq ddial , -.Sq background -and -.Sq * . -.Pp -When running in multi-link mode, a section can be loaded if it allows -.Em any -of the currently existing line modes. -.El -.Pp -.It alias Ar command Op Ar args -This command allows the control of the aliasing (or masquerading) -facilities that are built into -.Nm ppp . -If aliasing is enabled on your system (it may be omitted at compile time), -the following commands are possible: -.Bl -tag -width XX -.It alias enable [yes|no] -This command either switches aliasing on or turns it off. -The -.Fl alias -command line flag is synonymous with -.Dq alias enable yes . -.It alias port Op Ar proto targetIP:targetPORT [aliasIP:]aliasPORT -This command allows us to redirect connections arriving at -.Ar aliasPORT -for machine -.Ar aliasIP -to -.Ar targetPORT -on -.Ar targetIP . -.Ar Proto -may be either -.Sq tcp -or -.Sq udp , -and only connections of the given protocol -are matched. This option is useful if you wish to run things like -Internet phone on the machines behind your gateway. -.It alias addr Op Ar addr_local addr_alias -This command allows data for -.Ar addr_alias -to be redirected to -.Ar addr_local . -It is useful if you own a small number of real IP numbers that -you wish to map to specific machines behind your gateway. -.It alias deny_incoming [yes|no] -If set to yes, this command will refuse all incoming connections -by dropping the packets in much the same way as a firewall would. -.It alias help|? -This command gives a summary of available alias commands. -.It alias log [yes|no] -This option causes various aliasing statistics and information to -be logged to the file -.Pa /var/log/alias.log . -.It alias same_ports [yes|no] -When enabled, this command will tell the alias library attempt to -avoid changing the port number on outgoing packets. This is useful -if you want to support protocols such as RPC and LPD which require -connections to come from a well known port. -.It alias use_sockets [yes|no] -When enabled, this option tells the alias library to create a -socket so that it can guarantee a correct incoming ftp data or -IRC connection. -.It alias unregistered_only [yes|no] -Only alter outgoing packets with an unregistered source ad- -dress. According to RFC 1918, unregistered source addresses -are 10.0.0.0/8, 172.16.0.0/12 and 192.168.0.0/16. -.El -.Pp -These commands are also discussed in the file -.Pa README.alias -which comes with the source distribution. -.Pp -.It [!]bg Ar command -The given -.Ar command -is executed in the background with the following words replaced: -.Bl -tag -width PEER_ENDDISC -.It Li AUTHNAME -This is replaced with the local -.Ar authname -value. See the -.Dq set authname -command below. -.It Li ENDDISC -This is replaced with the local endpoint discriminator value. See the -.Dq set enddisc -command below. -.It Li HISADDR -This is replaced with the peers IP number. -.It Li INTERFACE -This is replaced with the name of the interface that's in use. -.It Li LABEL -This is replaced with the last label name used. A label may be specified -on the -.Nm -command line, via the -.Dq load -or -.Dq dial -commands and in the -.Pa ppp.secret -file. -.It Li MYADDR -This is replaced with the IP number assigned to the local interface. -.It Li PEER_ENDDISC -This is replaced with the value of the peers endpoint discriminator. -.It Li PROCESSID -This is replaced with the current process id. -.It Li USER -This is replaced with the username that has been authenticated with PAP or -CHAP. Normally, this variable is assigned only in -direct mode. This value -is available irrespective of whether utmp logging is enabled. -.El -.Pp -These substitutions are also done by the -.Dq set proctitle -command. -.Pp -If you wish to pause -.Nm -while the command executes, use the -.Dq shell -command instead. -.It clear modem|ipcp Op current|overall|peak... -Clear the specified throughput values at either the -.Dq modem -or -.Dq ipcp -level. If -.Dq modem -is specified, context must be given (see the -.Dq link -command below). If no second argument is given, all values are -cleared. -.It clone Ar name[,name]... -Clone the specified link, creating one or more new links according to the -.Ar name -argument(s). This command must be used from the -.Dq link -command below unless you've only got a single link (in which case that -link becomes the default). Links may be removed using the -.Dq remove -command below. -.Pp -The default link name is -.Dq deflink . -.It close Op lcp|ccp[!] -If no arguments are given, the relevant protocol layers will be brought -down and the link will be closed. If -.Dq lcp -is specified, the LCP layer is brought down, but -.Nm -will not bring the link offline. It is subsequently possible to use -.Dq term -.Pq see below -to talk to the peer machine if, for example, something like -.Dq slirp -is being used. If -.Dq ccp -is specified, only the relevant compression layer is closed. If the -.Dq \&! -is used, the compression layer will remain in the closed state, otherwise -it will re-enter the STOPPED state, waiting for the peer to initiate -further CCP negotiation. In any event, this command does not disconnect -the user from -.Nm -or exit -.Nm ppp . -See the -.Dq quit -command below. -.It delete[!] Ar dest -This command deletes the route with the given -.Ar dest -IP address. If -.Ar dest -is specified as -.Sq ALL , -all non-direct entries in the routing table for the current interface, -and all -.Sq sticky route -entries are deleted. If -.Ar dest -is specified as -.Sq default , -the default route is deleted. -.Pp -If the -.Ar delete! -command is used -.Pq note the trailing Dq \&! , -.Nm -will not complain if the route does not already exist. -.It dial|call Op Ar label -When used with no argument, this command is the same as the -.Dq open -command. When one or more -.Ar label -is specified, a -.Dq load -will be done first. -.It down Op Ar lcp|ccp -Bring the relevant layer down ungracefully, as if the underlying layer -had become unavailable. It's not considered polite to use this command on -a Finite State Machine that's in the OPEN state. If no arguments are -supplied, the entire link is closed (or if no context is given, all links -are terminated). If -.Sq lcp -is specified, the -.Em LCP -layer is terminated but the modem is not brought offline and the link -is not closed. If -.Sq ccp -is specified, only the relevant compression layer(s) are terminated. -.It help|? Op Ar command -Show a list of available commands. If -.Ar command -is specified, show the usage string for that command. -.It iface Ar command Op args -This command is used to control the interface used by -.Nm ppp . -.Ar Command -may be one of the following: -.Bl -tag -width XX -.It iface add[!] Ar addr[[/bits| mask] peer] -Add the given -.Ar addr mask peer -combination to the interface. Instead of specifying -.Ar mask , -.Ar /bits -can be used -.Pq with no space between \&it and Ar addr . -If the given address already exists, the command fails unless the -.Dq \&! -is used - in which case the previous interface address entry is overwritten -with the new one, allowing a change of netmask or peer address. -.Pp -If only -.Ar addr -is specified, -.Ar bits -defaults to -.Dq 32 -and -.Ar peer -defaults to -.Dq 255.255.255.255 . -This address (the broadcast address) is the only duplicate peer address that -.Nm -allows. -.It iface clear -If this command is used while -.Nm -is in the OPENED state or while in -.Fl auto -mode, all addresses except for the IPCP negotiated address are deleted -from the interface. If -.Nm -is not in the OPENED state and is not in -.Fl auto -mode, all interface addresses are deleted. -.Pp -.It iface delete[!]|rm[!] Ar addr -This command deletes the given -.Ar addr -from the interface. If the -.Dq \&! -is used, no error is given if the address isn't currently assigned to -the interface (and no deletion takes place). -.It iface show -Shows the current state and current addresses for the interface. It is -much the same as running -.Dq ifconfig INTERFACE . -.It iface help Op Ar sub-command -This command, when invoked without -.Ar sub-command , -will show a list of possbile -.Dq iface -sub-commands and a brief synopsis for each. When invoked with -.Ar sub-command , -only the synopsis for the given sub-command is shown. -.El -.It [data]link Ar name[,name...] command Op Ar args -This command may prefix any other command if the user wishes to -specify which link the command should affect. This is only -applicable after multiple links have been created in Multi-link -mode using the -.Dq clone -command. -.Pp -.Ar Name -specifies the name of an existing link. If -.Ar name -is a comma separated list, -.Ar command -is executed on each link. If -.Ar name -is -.Dq * , -.Ar command -is executed on all links. -.It load Op Ar label ... -Load the given -.Ar label(s) -from the -.Pa ppp.conf -file. If -.Ar label -is not given, the -.Ar default -label is used. -.It open Op lcp|ccp|ipcp -This is the opposite of the -.Dq close -command. Using -.Dq open -with no arguments is the same as using -.Dq dial -with no arguments, where all closed links are brought up (some auto -links may not come up based on the -.Dq set autoload -command) using the current configuration. -.Pp -If the -.Dq lcp -while the LCP layer is already open, LCP will be renegotiated. This -allows various LCP options to be changed, after which -.Dq open lcp -can be used to put them into effect. After renegotiating LCP, -any agreed authentication will also take place. -.Pp -If the -.Dq ccp -argument is used, the relevant compression layer is opened. Again, -if it is already open, it will be renegotiated. -.Pp -If the -.Dq ipcp -argument is used, the link will be brought up as normal, but if -IPCP is already open, it will be renegotiated and the network -interface will be reconfigured. -.Pp -It is probably not good practice to re-open the PPP state machines -like this as it's possible that the peer will not behave correctly. -It -.Em is -however useful as a way of forcing the CCP or VJ dictionaries to be reset. -.It passwd Ar pass -Specify the password required for access to the full -.Nm -command set. This password is required when connecting to the diagnostic -port (see the -.Dq set server -command). -.Ar Pass -is specified on the -.Dq set server -command line. The value of -.Ar pass -is not logged when -.Ar command -logging is active, instead, the literal string -.Sq ******** -is logged. -.It quit|bye [all] -If -.Dq quit -is executed from the controlling connection or from a command file, -ppp will exit after closing all connections. Otherwise, if the user -is connected to a diagnostic socket, the connection is simply dropped. -.Pp -If the -.Ar all -argument is given, -.Nm -will exit despite the source of the command after closing all existing -connections. -.It remove|rm -This command removes the given link. It is only really useful in -multi-link mode. A link must be -in the -.Dv CLOSED -state before it is removed. -.It rename|mv Ar name -This command renames the given link to -.Ar name . -It will fail if -.Ar name -is already used by another link. -.Pp -The default link name is -.Sq deflink . -Renaming it to -.Sq modem , -.Sq cuaa0 -or -.Sq USR -may make the log file more readable. -.It save -This option is not (yet) implemented. -.It set[up] Ar var value -This option allows the setting of any of the following variables: -.Bl -tag -width XX -.It set accmap Ar hex-value -ACCMap stands for Asynchronous Control Character Map. This is always -negotiated with the peer, and defaults to a value of 00000000 in hex. -This protocol is required to defeat hardware that depends on passing -certain characters from end to end (such as XON/XOFF etc). -.Pp -For the XON/XOFF scenario, use -.Dq set accmap 000a0000 . -.It set authkey|key Ar value -This sets the authentication key (or password) used in client mode -PAP or CHAP negotiation to the given value. It can also be used to -specify the password to be used in the dial or login scripts in place -of the '\\P' sequence, preventing the actual password from being logged. If -.Ar command -logging is in effect, -.Ar value -is logged as -.Sq ******** -for security reasons. -.It set authname Ar id -This sets the authentication id used in client mode PAP or CHAP negotiation. -.Pp -If used in -.Fl direct -mode with PAP or CHAP enabled, -.Ar id -is used in the initial authentication request and is normally set to -the local machine name. -.It set autoload Ar max-duration max-load [min-duration min-load] -These settings apply only in multi-link mode and all default to zero. -When more than one -.Ar demand-dial -.Pq also known as Fl auto -mode link is available, only the first link is made active when -.Nm -first reads data from the tun device. The next -.Ar demand-dial -link will be opened only when at least -.Ar max-load -packets have been in the send queue for -.Ar max-duration -seconds. Because both values default to zero, -.Ar demand-dial -links will simply come up one at a time by default. -.Pp -If two or more links are open, at least one of which is a -.Ar demand-dial -link, a -.Ar demand-dial -link will be closed when there is less than -.Ar min-packets -in the queue for more than -.Ar min-duration . -If -.Ar min-duration -is zero, this timer is disabled. Because both values default to zero, -.Ar demand-dial -links will stay active until the bundle idle timer expires. -.It set callback [none|auth|cbcp|E.164 *|number[,number]...]... -If no arguments are given, callback is disabled, otherwise, -.Nm -will request (or in -.Fl direct -mode, will accept) one of the given protocols. In client mode, if a -request is NAK'd -.Nm -will request another, until no options remain at which point -.Nm -will terminate negotiations. In server mode, -.Nm -will accept any of the given protocols - but the client -.Em must -request one of them. If you wish callback to be optional, you must include -.Ar none -as an option. -.Pp -The options are as follows (in this order of preference): -.Pp -.Bl -tag -.It auth -The callee is expected to decide the callback number based on -authentication. If -.Nm -is the callee, the number should be specified as the fifth field of -the peers entry in -.Pa /etc/ppp/ppp.secret . -.It cbcp -Microsofts callback control protocol is used. See -.Dq set cbcp -below. -.It E.164 *|number[,number]... -The caller specifies the -.Ar number . -If -.Nm -is the callee, -.Ar number -should be either a comma seperated list of allowable numbers or a -.Dq \&* , -meaning any number is permitted. If -.Nm -is the caller, only a single number should be specified. -.Pp -Note, this option is very unsafe when used with a -.Dq \&* -as a malicious caller can tell -.Nm -to call any (possibly international) number without first authenticating -themselves. -.It none -If the peer does not wish to do callback at all, -.Nm -will accept the fact and continue without callback rather than terminating -the connection. This is required if you wish callback to be optional. -.El -.Pp -.It set cbcp Op *|number[,number]... Op delay Op retry -If no arguments are given, CBCP (Microsofts CallBack Control Protocol) -is disabled - ie, configuring CBCP in the -.Dq set callback -command will result in -.Nm -requesting no callback in the CBCP phase. -Otherwise, -.Nm -attempts to use the given phone -.Ar number Ns No (s). -.Pp -In server mode -.Pq Fl direct , -.Nm -will insist that the client uses one of these numbers, unless -.Dq \&* -is used in which case the client is expected to specify the number. -.Pp -In client mode, -.Nm -will attempt to use one of the given numbers (whichever it finds to -be agreeable with the peer), or if -.Dq \&* -is specified, -.Nm -will expect the peer to specify the number. -.It set choked Op Ar timeout -This sets the number of seconds that -.Nm -will keep a choked output queue before dropping all pending output packets. -If -.Ar timeout -is less than or equal to zero or if -.Ar timeout -isn't specified, it is set to the default value of -.Em 120 seconds . -.Pp -A choked output queue occurs when -.Nm -has read a certain number of packets from the local network for transmission, -but cannot send the data due to link failure (the peer is busy etc.). -.Nm Ppp -will not read packets indefinitely. Instead, it reads up to -.Em 20 -packets (or -.Em 20 No + -.Em nlinks No * -.Em 2 -packets in multi-link mode), then stops reading the network interface -until either -.Ar timeout -seconds have passed or at least one packet has been sent. -.Pp -If -.Ar timeout -seconds pass, all pending output packets are dropped. -.It set ctsrts|crtscts on|off -This sets hardware flow control. Hardware flow control is -.Ar on -by default. -.It set deflate Ar out-winsize Op Ar in-winsize -This sets the DEFLATE algorithms default outgoing and incoming window -sizes. Both -.Ar out-winsize -and -.Ar in-winsize -must be values between -.Em 8 -and -.Em 15 . -If -.Ar in-winsize -is specified, -.Nm -will insist that this window size is used and will not accept any other -values from the peer. -.It set dns Op Ar primary Op Ar secondary -This command specifies DNS overrides for the -.Dq accept dns -command. Refer to the -.Dq accept -command description above for details. This command does not affect the -IP numbers requested using -.Dq enable dns . -.It set device|line Ar value[,value...] -This sets the device(s) to which -.Nm -will talk to the given -.Dq value . -All serial device names are expected to begin with -.Pa /dev/ . -If -.Dq value -does not begin with -.Pa /dev/ , -it must either begin with an exclamation mark -.Pq Dq \&! -or be of the format -.Dq host:port . -.Pp -If it begins with an exclamation mark, the rest of the device name is -treated as a program name, and that program is executed when the device -is opened. Standard input, output and error are fed back to -.Nm -and are read and written as if they were a regular device. -.Pp -If a -.Dq host:port -pair is given, -.Nm -will attempt to connect to the given -.Dq host -on the given -.Dq port . -Refer to the section on -.Em PPP OVER TCP -above for further details. -.Pp -If multiple -.Dq values -are specified, -.Nm -will attempt to open each one in turn until it succeeds or runs out of -devices. -.It set dial Ar chat-script -This specifies the chat script that will be used to dial the other -side. See also the -.Dq set login -command below. Refer to -.Xr chat 8 -and to the example configuration files for details of the chat script -format. -It is possible to specify some special -.Sq values -in your chat script as follows: -.Bd -unfilled -offset indent -.It Li \\\\\\\\\\\\\\\\c -When used as the last character in a -.Sq send -string, this indicates that a newline should not be appended. -.It Li \\\\\\\\\\\\\\\\d -When the chat script encounters this sequence, it delays two seconds. -.It Li \\\\\\\\\\\\\\\\p -When the chat script encounters this sequence, it delays for one quarter of -a second. -.It Li \\\\\\\\\\\\\\\\n -This is replaced with a newline character. -.It Li \\\\\\\\\\\\\\\\r -This is replaced with a carriage return character. -.It Li \\\\\\\\\\\\\\\\s -This is replaced with a space character. -.It Li \\\\\\\\\\\\\\\\t -This is replaced with a tab character. -.It Li \\\\\\\\\\\\\\\\T -This is replaced by the current phone number (see -.Dq set phone -below). -.It Li \\\\\\\\\\\\\\\\P -This is replaced by the current -.Ar authkey -value (see -.Dq set authkey -above). -.It Li \\\\\\\\\\\\\\\\U -This is replaced by the current -.Ar authname -value (see -.Dq set authname -above). -.Ed -.Pp -Note that two parsers will examine these escape sequences, so in order to -have the -.Sq chat parser -see the escape character, it is necessary to escape it from the -.Sq command parser . -This means that in practice you should use two escapes, for example: -.Bd -literal -offset indent -set dial "... ATDT\\\\T CONNECT" -.Ed -.Pp -It is also possible to execute external commands from the chat script. -To do this, the first character of the expect or send string is an -exclamation mark -.Pq Dq \&! . -When the command is executed, standard input and standard output are -directed to the modem device (see the -.Dq set device -command), and standard error is read by -.Nm -and substituted as the expect or send string. If -.Nm -is running in interactive mode, file descriptor 3 is attached to -.Pa /dev/tty . -.Pp -For example (wrapped for readability); -.Bd -literal -offset indent -set login "TIMEOUT 5 \\"\\" \\"\\" login:--login: ppp \e -word: ppp \\"!sh \\\\\\\\-c \\\\\\"echo \\\\\\\\-n label: >&2\\\\\\"\\" \e -\\"!/bin/echo in\\" HELLO" -.Ed -.Pp -would result in the following chat sequence (output using the -.Sq set log local chat -command before dialing): -.Bd -literal -offset indent -Dial attempt 1 of 1 -dial OK! -Chat: Expecting: -Chat: Sending: -Chat: Expecting: login:--login: -Chat: Wait for (5): login: -Chat: Sending: ppp -Chat: Expecting: word: -Chat: Wait for (5): word: -Chat: Sending: ppp -Chat: Expecting: !sh \\-c "echo \\-n label: >&2" -Chat: Exec: sh -c "echo -n label: >&2" -Chat: Wait for (5): !sh \\-c "echo \\-n label: >&2" --> label: -Chat: Exec: /bin/echo in -Chat: Sending: -Chat: Expecting: HELLO -Chat: Wait for (5): HELLO -login OK! -.Ed -.Pp -Note (again) the use of the escape character, allowing many levels of -nesting. Here, there are four parsers at work. The first parses the -original line, reading it as three arguments. The second parses the -third argument, reading it as 11 arguments. At this point, it is -important that the -.Dq \&- -signs are escaped, otherwise this parser will see them as constituting -an expect-send-expect sequence. When the -.Dq \&! -character is seen, the execution parser reads the first command as three -arguments, and then -.Xr sh 1 -itself expands the argument after the -.Fl c . -As we wish to send the output back to the modem, in the first example -we redirect our output to file descriptor 2 (stderr) so that -.Nm -itself sends and logs it, and in the second example, we just output to stdout, -which is attached directly to the modem. -.Pp -This, of course means that it is possible to execute an entirely external -.Dq chat -command rather than using the internal one. See -.Xr chat 8 -for a good alternative. -.It set enddisc Op label|IP|MAC|magic|psn value -This command sets our local endpoint discriminator. If set prior to -LCP negotiation, -.Nm -will send the information to the peer using the LCP endpoint discriminator -option. The following discriminators may be set: -.Bd -unfilled -offset indent -.It Li label -The current label is used. -.It Li IP -Our local IP number is used. As LCP is negotiated prior to IPCP, it is -possible that the IPCP layer will subsequently change this value. If -it does, the endpoint discriminator stays at the old value unless manually -reset. -.It Li MAC -This is similar to the -.Ar IP -option above, except that the MAC address associated with the local IP -number is used. If the local IP number is not resident on any Ethernet -interface, the command will fail. -.Pp -As the local IP number defaults to whatever the machine host name is, -.Dq set enddisc mac -is usually done prior to any -.Dq set ifaddr -commands. -.It Li magic -A 20 digit random number is used. -.It Li psn Ar value -The given -.Ar value -is used. -.Ar Value -should be set to an absolute public switched network number with the -country code first. -.Ed -.Pp -If no arguments are given, the endpoint discriminator is reset. -.It set escape Ar value... -This option is similar to the -.Dq set accmap -option above. It allows the user to specify a set of characters that -will be `escaped' as they travel across the link. -.It set filter dial|alive|in|out rule-no permit|deny Ar "[src_addr/width] [dst_addr/width] [proto [src [lt|eq|gt port]] [dst [lt|eq|gt port]] [estab] [syn] [finrst]]" -.Nm Ppp -supports four filter sets. The -.Em alive -filter specifies packets that keep the connection alive - reseting the -idle timer. The -.Em dial -filter specifies packets that cause -.Nm -to dial when in -.Fl auto -mode. The -.Em in -filter specifies packets that are allowed to travel -into the machine and the -.Em out -filter specifies packets that are allowed out of the machine. -.Pp -Filtering is done prior to any IP alterations that might be done by the -alias engine. By default all filter sets allow all packets to pass. -Rules are processed in order according to -.Ar rule-no . -Up to 40 rules may be given for each set. If a packet doesn't match -any of the rules in a given set, it is discarded. In the case of -.Em in -and -.Em out -filters, this means that the packet is dropped. In the case of -.Em alive -filters it means that the packet will not reset the idle timer and in -the case of -.Em dial -filters it means that the packet will not trigger a dial. A packet failing -to trigger a dial will be dropped rather than queued. Refer to the -section on PACKET FILTERING above for further details. -.It set hangup Ar chat-script -This specifies the chat script that will be used to reset the modem -before it is closed. It should not normally be necessary, but can -be used for devices that fail to reset themselves properly on close. -.It set help|? Op Ar command -This command gives a summary of available set commands, or if -.Ar command -is specified, the command usage is shown. -.It set ifaddr Ar [myaddr [hisaddr [netmask [triggeraddr]]]] -This command specifies the IP addresses that will be used during -IPCP negotiation. Addresses are specified using the format -.Pp -.Dl a.b.c.d/n -.Pp -Where -.Ar a.b.c.d -is the preferred IP, but -.Ar n -specifies how many bits of the address we will insist on. If -.Ar /n -is omitted, it defaults to -.Ar /32 -unless the IP address is 0.0.0.0 in which case it defaults to -.Ar /0 . -.Pp -.Ar Hisaddr -may also be specified as a range of IP numbers in the format -.Pp -.Dl a.b.c.d[-d.e.f.g][,h.i.j.k[-l,m,n,o]]... -.Pp -for example: -.Pp -.Dl set ifaddr 10.0.0.1 10.0.1.2-10.0.1.10,10.0.1.20 -.Pp -will only negotiate -.Ar 10.0.0.1 -as the local IP number, but may assign any of the given 10 IP -numbers to the peer. If the peer requests one of these numbers, -and that number is not already in use, -.Nm -will grant the peers request. This is useful if the peer wants -to re-establish a link using the same IP number as was previously -allocated (thus maintaining any existing tcp connections). -.Pp -If the peer requests an IP number that's either outside -of this range or is already in use, -.Nm -will suggest a random unused IP number from the range. -.Pp -If -.Ar triggeraddr -is specified, it is used in place of -.Ar myaddr -in the initial IPCP negotiation. However, only an address in the -.Ar myaddr -range will be accepted. This is useful when negotiating with some -.Dv PPP -implementations that will not assign an IP number unless their peer -requests -.Ar 0.0.0.0 . -.Pp -It should be noted that in -.Fl auto -mode, -.Nm -will configure the interface immediately upon reading the -.Dq set ifaddr -line in the config file. In any other mode, these values are just -used for IPCP negotiations, and the interface isn't configured -until the IPCP layer is up. -.Pp -Note that the -.Ar HISADDR -argument may be overridden by the third field in the -.Pa ppp.secret -file once the client has authenticated itself -.Pq if PAP or CHAP are Dq enabled . -Refer to the -.Em AUTHENTICATING INCOMING CONNECTIONS -section for details. -.Pp -In all cases, if the interface is already configured, -.Nm -will try to maintain the interface IP numbers so that any existing -bound sockets will remain valid. -.It set ccpretry Ar period -.It set chapretry Ar period -.It set ipcpretry Ar period -.It set lcpretry Ar period -.It set papretry Ar period -These commands set the number of seconds that -.Nm -will wait before resending Finite State Machine (FSM) Request packets. -The default -.Ar period -for all FSMs is 3 seconds (which should suffice in most cases). -.It set log [local] [+|-] Ns Ar value... -This command allows the adjustment of the current log level. Refer -to the Logging Facility section for further details. -.It set login Ar chat-script -This -.Ar chat-script -compliments the dial-script. If both are specified, the login -script will be executed after the dial script. Escape sequences -available in the dial script are also available here. -.It set lqrperiod Ar frequency -This command sets the -.Ar frequency -in seconds at which -.Em LQR -or -.Em ECHO LQR -packets are sent. The default is 30 seconds. You must also use the -.Dq enable lqr -command if you wish to send LQR requests to the peer. -.It set mode Ar interactive|auto|ddial|background -This command allows you to change the -.Sq mode -of the specified link. This is normally only useful in multi-link mode, -but may also be used in uni-link mode. -.Pp -It is not possible to change a link that is -.Sq direct -or -.Sq dedicated . -.Pp -Note: If you issue the command -.Dq set mode auto , -and have IP aliasing enabled, it may be useful to -.Dq enable iface-alias -afterwards. This will allow -.Nm -to do the necessary address translations to enable the process that -triggers the connection to connect once the link is up despite the -peer assigning us a new (dynamic) IP address. -.It set mrru Op Ar value -Setting this option enables Multi-link PPP negotiations, also known as -Multi-link Protocol or MP. There is no default MRRU (Maximum -Reconstructed Receive Unit) value. If no argument is given, multi-link -mode is disabled. -.It set mru Op Ar value -The default MRU (Maximum Receive Unit) is 1500. If it is increased, the -other side *may* increase its mtu. There is no point in decreasing the -MRU to below the default as the -.Em PPP -protocol *must* be able to accept packets of at least 1500 octets. If -no argument is given, 1500 is assumed. -.It set mtu Op Ar value -The default MTU is 1500. At negotiation time, -.Nm -will accept whatever MRU or MRRU that the peer wants (assuming it's -not less than 296 bytes). If the MTU is set, -.Nm -will not accept MRU/MRRU values less than -.Ar value . -When negotiations are complete, the MTU is assigned to the interface, even -if the peer requested a higher value MRU/MRRU. This can be useful for -limiting your packet size (giving better bandwidth sharing at the expense -of more header data). -.Pp -If no -.Ar value -is given, 1500, or whatever the peer asks for is used. -.It set nbns Op Ar x.x.x.x Op Ar y.y.y.y -This option allows the setting of the Microsoft NetBIOS name server -values to be returned at the peers request. If no values are given, -.Nm -will reject any such requests. -.It set openmode active|passive Op Ar delay -By default, -.Ar openmode -is always -.Ar active -with a one second -.Ar delay . -That is, -.Nm -will always initiate LCP/IPCP/CCP negotiation one second after the line -comes up. If you want to wait for the peer to initiate negotiations, you -can use the value -.Ar passive . -If you want to initiate negotiations immediately or after more than one -second, the appropriate -.Ar delay -may be specified here in seconds. -.It set parity odd|even|none|mark -This allows the line parity to be set. The default value is -.Ar none . -.It set phone Ar telno[|telno]...[:telno[|telno]...]... -This allows the specification of the phone number to be used in -place of the \\\\T string in the dial and login chat scripts. -Multiple phone numbers may be given separated by a pipe (|) or -a colon (:). Numbers after the pipe are only dialed if the dial or login -script for the previous number failed. Numbers separated by a colon are -tried sequentially, irrespective of the reason the line was dropped. -If multiple numbers are given, -.Nm -will dial them according to these rules until a connection is made, retrying -the maximum number of times specified by -.Dq set redial -below. In -.Fl background -mode, each number is attempted at most once. -.It set [proc]title Op Ar value -The current process title as displayed by -.Xr ps 1 -is changed according to -.Ar value . -If -.Ar value -is not specified, the original process title is restored. All the -word replacements done by the shell commands (see the -.Dq bg -command above) are done here too. -.Pp -Note, if USER is required in the process title, the -.Dq set proctitle -command must appear in -.Pa ppp.linkup , -as it is not known when the commands in -.Pa ppp.conf -are executed. -.It set reconnect Ar timeout ntries -Should the line drop unexpectedly (due to loss of CD or LQR -failure), a connection will be re-established after the given -.Ar timeout . -The line will be re-connected at most -.Ar ntries -times. -.Ar Ntries -defaults to zero. A value of -.Ar random -for -.Ar timeout -will result in a variable pause, somewhere between 0 and 30 seconds. -.It set recvpipe Op Ar value -This sets the routing table RECVPIPE value. The optimum value is -just over twice the MTU value. If -.Ar value -is unspecified or zero, the default kernel controlled value is used. -.It set redial Ar seconds[.nseconds] [attempts] -.Nm Ppp -can be instructed to attempt to redial -.Ar attempts -times. If more than one phone number is specified (see -.Dq set phone -above), a pause of -.Ar nseconds -is taken before dialing each number. A pause of -.Ar seconds -is taken before starting at the first number again. A value of -.Ar random -may be used here in place of -.Ar seconds -and -.Ar nseconds , -causing a random delay of between 0 and 30 seconds. -.Pp -Note, this delay will be effective, even after -.Ar attempts -has been exceeded, so an immediate manual dial may appear to have -done nothing. If an immediate dial is required, a -.Dq \&! -should immediately follow the -.Dq open -keyword. See the -.Dq open -description above for further details. -.It set sendpipe Op Ar value -This sets the routing table SENDPIPE value. The optimum value is -just over twice the MTU value. If -.Ar value -is unspecified or zero, the default kernel controlled value is used. -.It set server|socket Ar TcpPort|LocalName|none password Op Ar mask -This command tells -.Nm -to listen on the given socket or -.Sq diagnostic port -for incoming command connections. -.Pp -The word -.Ar none -instructs -.Nm -to close any existing socket. -.Pp -If you wish to specify a local domain socket, -.Ar LocalName -must be specified as an absolute file name, otherwise it is assumed -to be the name or number of a TCP port. You may specify the octal umask that -should be used with local domain sockets as a four character octal number -beginning with -.Sq 0 . -Refer to -.Xr umask 2 -for umask details. Refer to -.Xr services 5 -for details of how to translate TCP port names. -.Pp -You must also specify the password that must be entered by the client -(using the -.Dq passwd -command above) when connecting to this socket. If the password is -specified as an empty string, no password is required for connecting clients. -.Pp -When specifying a local domain socket, the first -.Dq %d -sequence found in the socket name will be replaced with the current -interface unit number. This is useful when you wish to use the same -profile for more than one connection. -.Pp -In a similar manner TCP sockets may be prefixed with the -.Dq + -character, in which case the current interface unit number is added to -the port number. -.Pp -When using -.Nm -with a server socket, the -.Xr pppctl 8 -command is the preferred mechanism of communications. Currently, -.Xr telnet 1 -can also be used, but link encryption may be implemented in the future, so -.Xr telnet 1 -should not be relied upon. -.It set speed Ar value -This sets the speed of the serial device. -.It set stopped Ar [LCPseconds [CCPseconds]] -If this option is set, -.Nm -will time out after the given FSM (Finite State Machine) has been in -the stopped state for the given number of -.Dq seconds . -This option may be useful if the peer sends a terminate request, -but never actually closes the connection despite our sending a terminate -acknowledgement. This is also useful if you wish to -.Dq set openmode passive -and time out if the peer doesn't send a Configure Request within the -given time. Use -.Dq set log +lcp +ccp -to make -.Nm -log the appropriate state transitions. -.Pp -The default value is zero, where -.Nm -doesn't time out in the stopped state. -.Pp -This value should not be set to less than the openmode delay (see -.Dq set openmode -above). -.It set timeout Ar idleseconds -This command allows the setting of the idle timer. Refer to the -section titled -.Dq SETTING THE IDLE TIMER -for further details. -.It set vj slotcomp on|off -This command tells -.Nm -whether it should attempt to negotiate VJ slot compression. By default, -slot compression is turned -.Ar on . -.It set vj slots Ar nslots -This command sets the initial number of slots that -.Nm -will try to negotiate with the peer when VJ compression is enabled (see the -.Sq enable -command above). It defaults to a value of 16. -.Ar Nslots -must be between -.Ar 4 -and -.Ar 16 -inclusive. -.El -.Pp -.It shell|! Op Ar command -If -.Ar command -is not specified a shell is invoked according to the -.Dv SHELL -environment variable. Otherwise, the given -.Ar command -is executed. Word replacement is done in the same way as for the -.Dq !bg -commanad as described above. -.Pp -Use of the ! character -requires a following space as with any of the other commands. You should -note that this command is executed in the foreground - -.Nm -will not continue running until this process has exited. Use the -.Dv bg -command if you wish processing to happen in the background. -.It show Ar var -This command allows the user to examine the following: -.Bl -tag -width XX -.It show bundle -Show the current bundle settings. -.It show ccp -Show the current CCP compression statistics. -.It show compress -Show the current VJ compression statistics. -.It show escape -Show the current escape characters. -.It show filter Op Ar name -List the current rules for the given filter. If -.Ar name -is not specified, all filters are shown. -.It show hdlc -Show the current HDLC statistics. -.It show help|? -Give a summary of available show commands. -.It show iface -Show the current interface information -.Pq the same \&as Dq iface show . -.It show ipcp -Show the current IPCP statistics. -.It show lcp -Show the current LCP statistics. -.It show [data]link -Show high level link information. -.It show links -Show a list of available logical links. -.It show log -Show the current log values. -.It show mem -Show current memory statistics. -.It show modem -Show low level link information. -.It show proto -Show current protocol totals. -.It show route -Show the current routing tables. -.It show stopped -Show the current stopped timeouts. -.It show timer -Show the active alarm timers. -.It show version -Show the current version number of -.Nm ppp . -.El -.Pp -.It term -Go into terminal mode. Characters typed at the keyboard are sent to -the modem. Characters read from the modem are displayed on the -screen. When a -.Nm -peer is detected on the other side of the modem, -.Nm -automatically enables Packet Mode and goes back into command mode. -.El -.Pp -.Sh MORE DETAILS -.Bl -bullet -.It -Read the example configuration files. They are a good source of information. -.It -Use -.Dq help , -.Dq alias ? , -.Dq enable ? , -.Dq set ? -and -.Dq show ? -to get online information about what's available. -.It -The following urls contain useful information: -.Bl -bullet -compact -.It -http://www.FreeBSD.org/FAQ/userppp.html -.It -http://www.FreeBSD.org/handbook/userppp.html -.El -.Pp -.El -.Pp -.Sh FILES -.Nm Ppp -refers to four files: -.Pa ppp.conf , -.Pa ppp.linkup , -.Pa ppp.linkdown -and -.Pa ppp.secret . -These files are placed in the -.Pa /etc/ppp -directory. -.Bl -tag -width XX -.It Pa /etc/ppp/ppp.conf -System default configuration file. -.It Pa /etc/ppp/ppp.secret -An authorisation file for each system. -.It Pa /etc/ppp/ppp.linkup -A file to check when -.Nm -establishes a network level connection. -.It Pa /etc/ppp/ppp.linkdown -A file to check when -.Nm -closes a network level connection. -.It Pa /var/log/ppp.log -Logging and debugging information file. Note, this name is specified in -.Pa /etc/syslogd.conf . -See -.Xr syslog.conf 5 -for further details. -.It Pa /var/spool/lock/LCK..* -tty port locking file. Refer to -.Xr uucplock 3 -for further details. -.It Pa /var/run/tunN.pid -The process id (pid) of the -.Nm -program connected to the tunN device, where -.Sq N -is the number of the device. -.It Pa /var/run/ttyXX.if -The tun interface used by this port. Again, this file is only created in -.Fl background , -.Fl auto -and -.Fl ddial -modes. -.It Pa /etc/services -Get port number if port number is using service name. -.It Pa /var/run/ppp-authname-class-value -In multi-link mode, local domain sockets are created using the peer -authentication name -.Pq Sq authname , -the peer endpoint discriminator class -.Pq Sq class -and the peer endpoint discriminator value -.Pq Sq value . -As the endpoint discriminator value may be a binary value, it is turned -to HEX to determine the actual file name. -.Pp -This socket is used to pass links between different instances of -.Nm ppp . -.El -.Pp -.Sh SEE ALSO -.Xr at 1 , -.Xr ftp 1 , -.Xr gzip 1 , -.Xr hostname 1 , -.Xr login 1 , -.Xr tcpdump 1 , -.Xr telnet 1 , -.Xr syslog 3 , -.Xr uucplock 3 , -.Xr crontab 5 , -.Xr group 5 , -.Xr passwd 5 , -.Xr resolv.conf 5 , -.Xr syslog.conf 5 , -.Xr adduser 8 , -.Xr chat 8 , -.Xr getty 8 , -.Xr inetd 8 , -.Xr init 8 , -.Xr named 8 , -.Xr ping 8 , -.Xr pppctl 8 , -.Xr pppd 8 , -.Xr route 8 , -.Xr syslogd 8 , -.Xr traceroute 8 , -.Xr vipw 8 -.Sh HISTORY -This program was originally written by Toshiharu OHNO (tony-o@iij.ad.jp), -and was submitted to FreeBSD-2.0.5 by Atsushi Murai (amurai@spec.co.jp). -.Pp -It was substantially modified during 1997 by Brian Somers -(brian@Awfulhak.org), and was ported to OpenBSD in November that year -(just after the 2.2 release). -.Pp -Most of the code was rewritten by Brian Somers in early 1998 when -multi-link ppp support was added. diff --git a/usr.sbin/sade/Makefile b/usr.sbin/sade/Makefile deleted file mode 100644 index 10e0d6aab066..000000000000 --- a/usr.sbin/sade/Makefile +++ /dev/null @@ -1,83 +0,0 @@ -PROG= sysinstall -MAN8= sysinstall.8 - -BINDIR=/stand -NOSHARED=YES - -CLEANFILES+= makedevs.c rtermcap rtermcap.tmp dumpnlist -CLEANFILES+= keymap.tmp keymap.h - -.PATH: ${.CURDIR}/../disklabel ${.CURDIR}/../../usr.bin/cksum - -SRCS= anonFTP.c cdrom.c command.c config.c devices.c kget.c \ - disks.c dispatch.c dist.c dmenu.c doc.c dos.c floppy.c \ - ftp.c globals.c index.c install.c installUpgrade.c keymap.c \ - label.c lndir.c main.c makedevs.c media.c menus.c misc.c mouse.c \ - msg.c network.c nfs.c options.c package.c register.c system.c \ - tape.c tcpip.c termcap.c ufs.c user.c variable.c wizard.c \ - keymap.h - -CFLAGS+= -Wall -I${.CURDIR}/../../gnu/lib/libdialog -I${.OBJDIR} -CFLAGS+= -I${.CURDIR}/../../sys -CFLAGS+= -DUC_PRIVATE -DKERN_NO_SYMBOLS - -DPADD= ${LIBDIALOG} ${LIBNCURSES} ${LIBMYTINFO} ${LIBUTIL} ${LIBDISK} ${LIBFTPIO} -LDADD= -ldialog -lncurses -lmytinfo -lutil -ldisk -lftpio - -makedevs.c: Makefile rtermcap keymap.h - rm -f makedevs.tmp - echo '#include <sys/types.h>' > makedevs.tmp - ./rtermcap ansi | \ - file2c 'const char termcap_ansi[] = {' ',0};' \ - >> makedevs.tmp - ./rtermcap cons25 | \ - file2c 'const char termcap_cons25[] = {' ',0};' \ - >> makedevs.tmp - ./rtermcap cons25-m | \ - file2c 'const char termcap_cons25_m[] = {' ',0};' \ - >> makedevs.tmp - ./rtermcap cons25r | \ - file2c 'const char termcap_cons25r[] = {' ',0};' \ - >> makedevs.tmp - ./rtermcap cons25r-m | \ - file2c 'const char termcap_cons25r_m[] = {' ',0};' \ - >> makedevs.tmp - ./rtermcap cons25l1 | \ - file2c 'const char termcap_cons25l1[] = {' ',0};' \ - >> makedevs.tmp - ./rtermcap cons25l1-m | \ - file2c 'const char termcap_cons25l1_m[] = {' ',0};' \ - >> makedevs.tmp - ./rtermcap vt100 | \ - file2c 'const char termcap_vt100[] = {' ',0};' \ - >> makedevs.tmp -.if ${MACHINE_ARCH} != "alpha" - file2c 'u_char boot0[] = {' '};' < /boot/boot0 >> makedevs.tmp -.endif - mv makedevs.tmp makedevs.c - -rtermcap: ${.CURDIR}/rtermcap.c - ${CC} -o rtermcap ${.CURDIR}/rtermcap.c -ltermcap - - -KEYMAPS= be.iso br275.iso danish.iso fr.iso german.iso it.iso \ - icelandic.iso jp.106 norwegian.iso ru.koi8-r si.iso spanish.iso \ - swedish.iso swissgerman.iso uk.iso us.dvorak us.iso - - -keymap.h: - rm -f keymap.tmp - for map in ${KEYMAPS} ; do \ - kbdcontrol -L $$map | \ - sed -e '/^static accentmap_t/,$$d' >> keymap.tmp ; \ - done - echo "static struct keymapInfo keymapInfos[] = {" >> keymap.tmp - for map in ${KEYMAPS} ; do \ - echo -n ' { "'$$map'", ' >> keymap.tmp ; \ - echo "&keymap_$$map }," | tr '[-.]' '_' >> keymap.tmp ; \ - done - ( echo " { 0 }"; echo "};" ; echo "" ) >> keymap.tmp - mv keymap.tmp keymap.h - - -.include <bsd.prog.mk> diff --git a/usr.sbin/sade/command.c b/usr.sbin/sade/command.c deleted file mode 100644 index b14f913d706b..000000000000 --- a/usr.sbin/sade/command.c +++ /dev/null @@ -1,179 +0,0 @@ -/* - * The new sysinstall program. - * - * This is probably the last program in the `sysinstall' line - the next - * generation being essentially a complete rewrite. - * - * $Id$ - * - * Copyright (c) 1995 - * Jordan Hubbard. 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, - * verbatim and that no modifications are made prior to this - * point in the file. - * 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 JORDAN HUBBARD ``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 JORDAN HUBBARD OR HIS PETS 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, LIFE 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. - * - */ - -#include "sysinstall.h" - -#define MAX_NUM_COMMANDS 10 - -typedef struct { - char key[FILENAME_MAX]; - struct { - enum { CMD_SHELL, CMD_FUNCTION } type; - void *ptr, *data; - } cmds[MAX_NUM_COMMANDS]; - int ncmds; -} Command; - -#define MAX_CMDS 200 -static Command *commandStack[MAX_CMDS]; -int numCommands; - -/* Nuke the command stack */ -void -command_clear(void) -{ - int i, j; - - for (i = 0; i < numCommands; i++) - for (j = 0; j < commandStack[i]->ncmds; j++) - if (commandStack[i]->cmds[j].type == CMD_SHELL) - free(commandStack[i]->cmds[j].ptr); - free(commandStack[i]); - numCommands = 0; -} - -static void -addit(char *key, int type, void *cmd, void *data) -{ - int i; - - /* First, look for the key already present and add a command to it if found */ - for (i = 0; i < numCommands; i++) { - if (!strcmp(commandStack[i]->key, key)) { - if (commandStack[i]->ncmds == MAX_NUM_COMMANDS) - msgFatal("More than %d commands stacked up behind %s??", MAX_NUM_COMMANDS, key); - commandStack[i]->cmds[commandStack[i]->ncmds].type = type; - commandStack[i]->cmds[commandStack[i]->ncmds].ptr = cmd; - commandStack[i]->cmds[commandStack[i]->ncmds].data = data; - ++(commandStack[i]->ncmds); - return; - } - } - if (numCommands == MAX_CMDS) - msgFatal("More than %d commands accumulated??", MAX_CMDS); - - /* If we fell to here, it's a new key */ - commandStack[numCommands] = safe_malloc(sizeof(Command)); - strcpy(commandStack[numCommands]->key, key); - commandStack[numCommands]->ncmds = 1; - commandStack[numCommands]->cmds[0].type = type; - commandStack[numCommands]->cmds[0].ptr = cmd; - commandStack[numCommands]->cmds[0].data = data; - ++numCommands; -} - -/* Add a shell command under a given key */ -void -command_shell_add(char *key, char *fmt, ...) -{ - va_list args; - char *cmd; - - cmd = (char *)safe_malloc(256); - va_start(args, fmt); - vsnprintf(cmd, 256, fmt, args); - va_end(args); - - addit(key, CMD_SHELL, cmd, NULL); -} - -/* Add a shell command under a given key */ -void -command_func_add(char *key, commandFunc func, void *data) -{ - addit(key, CMD_FUNCTION, func, data); -} - -static int -sort_compare(Command *p1, Command *p2) -{ - if (!p1 && !p2) - return 0; - else if (!p1 && p2) /* NULL has a "greater" value for commands */ - return 1; - else if (p1 && !p2) - return -1; - else - return strcmp(p1->key, p2->key); -} - -void -command_sort(void) -{ - int i, j; - - commandStack[numCommands] = NULL; - /* Just do a crude bubble sort since the list is small */ - for (i = 0; i < numCommands; i++) { - for (j = 0; j < numCommands; j++) { - if (sort_compare(commandStack[j], commandStack[j + 1]) > 0) { - Command *tmp = commandStack[j]; - - commandStack[j] = commandStack[j + 1]; - commandStack[j + 1] = tmp; - } - } - } -} - -/* Run all accumulated commands in sorted order */ -void -command_execute(void) -{ - int i, j, ret; - commandFunc func; - - for (i = 0; i < numCommands; i++) { - for (j = 0; j < commandStack[i]->ncmds; j++) { - /* If it's a shell command, run system on it */ - if (commandStack[i]->cmds[j].type == CMD_SHELL) { - msgNotify("Doing %s", commandStack[i]->cmds[j].ptr); - ret = vsystem((char *)commandStack[i]->cmds[j].ptr); - if (isDebug()) - msgDebug("Command `%s' returns status %d\n", commandStack[i]->cmds[j].ptr, ret); - } - else { - /* It's a function pointer - call it with the key and the data */ - func = (commandFunc)commandStack[i]->cmds[j].ptr; - if (isDebug()) - msgDebug("%x: Execute(%s, %s)", func, commandStack[i]->key, commandStack[i]->cmds[j].data); - ret = (*func)(commandStack[i]->key, commandStack[i]->cmds[j].data); - if (isDebug()) - msgDebug("Function @ %x returns status %d\n", commandStack[i]->cmds[j].ptr, ret); - } - } - } -} diff --git a/usr.sbin/sade/config.c b/usr.sbin/sade/config.c deleted file mode 100644 index 878a2324b2a7..000000000000 --- a/usr.sbin/sade/config.c +++ /dev/null @@ -1,780 +0,0 @@ -/* - * The new sysinstall program. - * - * This is probably the last program in the `sysinstall' line - the next - * generation being essentially a complete rewrite. - * - * $Id: config.c,v 1.114 1998/10/14 01:04:44 jkh Exp $ - * - * Copyright (c) 1995 - * Jordan Hubbard. 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, - * verbatim and that no modifications are made prior to this - * point in the file. - * 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 JORDAN HUBBARD ``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 JORDAN HUBBARD OR HIS PETS 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, LIFE 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. - * - */ - -#include "sysinstall.h" -#include <sys/disklabel.h> -#include <sys/wait.h> -#include <sys/errno.h> -#include <sys/ioctl.h> -#include <sys/fcntl.h> -#include <sys/param.h> -#include <sys/stat.h> -#include <unistd.h> -#include <sys/mount.h> - -static Chunk *chunk_list[MAX_CHUNKS]; -static int nchunks; -static int rootdev_is_od; - -/* arg to sort */ -static int -chunk_compare(Chunk *c1, Chunk *c2) -{ - if (!c1 && !c2) - return 0; - else if (!c1 && c2) - return 1; - else if (c1 && !c2) - return -1; - else if (!c1->private_data && !c2->private_data) - return 0; - else if (c1->private_data && !c2->private_data) - return 1; - else if (!c1->private_data && c2->private_data) - return -1; - else - return strcmp(((PartInfo *)(c1->private_data))->mountpoint, ((PartInfo *)(c2->private_data))->mountpoint); -} - -static void -chunk_sort(void) -{ - int i, j; - - for (i = 0; i < nchunks; i++) { - for (j = 0; j < nchunks; j++) { - if (chunk_compare(chunk_list[j], chunk_list[j + 1]) > 0) { - Chunk *tmp = chunk_list[j]; - - chunk_list[j] = chunk_list[j + 1]; - chunk_list[j + 1] = tmp; - } - } - } -} - -static void -check_rootdev(Chunk **list, int n) -{ - int i; - Chunk *c; - - rootdev_is_od = 0; - for (i = 0; i < n; i++) { - c = *list++; - if (c->type == part && (c->flags & CHUNK_IS_ROOT) - && strncmp(c->disk->name, "od", 2) == 0) - rootdev_is_od = 1; - } -} - -static char * -name_of(Chunk *c1) -{ - return c1->name; -} - -static char * -mount_point(Chunk *c1) -{ - if (c1->type == part && c1->subtype == FS_SWAP) - return "none"; - else if (c1->type == part || c1->type == fat) - return ((PartInfo *)c1->private_data)->mountpoint; - return "/bogus"; -} - -static char * -fstype(Chunk *c1) -{ - if (c1->type == fat) - return "msdos"; - else if (c1->type == part) { - if (c1->subtype != FS_SWAP) - return "ufs"; - else - return "swap"; - } - return "bogus"; -} - -static char * -fstype_short(Chunk *c1) -{ - if (c1->type == part) { - if (c1->subtype != FS_SWAP) { - if (rootdev_is_od == 0 && strncmp(c1->name, "od", 2) == 0) - return "rw,noauto"; - else - return "rw"; - } - else - return "sw"; - } - else if (c1->type == fat) { - if (strncmp(c1->name, "od", 2) == 0) - return "ro,noauto"; - else - return "ro"; - } - return "bog"; -} - -static int -seq_num(Chunk *c1) -{ - if (c1->type == part && c1->subtype != FS_SWAP) { - if (rootdev_is_od == 0 && strncmp(c1->name, "od", 2) == 0) - return 0; - else if (c1->flags & CHUNK_IS_ROOT) - return 1; - else - return 2; - } - return 0; -} - -int -configFstab(dialogMenuItem *self) -{ - Device **devs; - Disk *disk; - FILE *fstab; - int i, cnt; - Chunk *c1, *c2; - - if (!RunningAsInit) { - if (file_readable("/etc/fstab")) - return DITEM_SUCCESS; - else { - msgConfirm("Attempting to rebuild your /etc/fstab file. Warning: If you had\n" - "any CD devices in use before running sysinstall then they may NOT\n" - "be found by this run!"); - } - } - - devs = deviceFind(NULL, DEVICE_TYPE_DISK); - if (!devs) { - msgConfirm("No disks found!"); - return DITEM_FAILURE; - } - - /* Record all the chunks */ - nchunks = 0; - for (i = 0; devs[i]; i++) { - if (!devs[i]->enabled) - continue; - disk = (Disk *)devs[i]->private; - if (!disk->chunks) - msgFatal("No chunk list found for %s!", disk->name); - for (c1 = disk->chunks->part; c1; c1 = c1->next) { - if (c1->type == freebsd) { - for (c2 = c1->part; c2; c2 = c2->next) { - if (c2->type == part && (c2->subtype == FS_SWAP || c2->private_data)) - chunk_list[nchunks++] = c2; - } - } - else if (c1->type == fat && c1->private_data) - chunk_list[nchunks++] = c1; - } - } - chunk_list[nchunks] = 0; - chunk_sort(); - - fstab = fopen("/etc/fstab", "w"); - if (!fstab) { - msgConfirm("Unable to create a new /etc/fstab file! Manual intervention\n" - "will be required."); - return DITEM_FAILURE; - } - - check_rootdev(chunk_list, nchunks); - - /* Go for the burn */ - msgDebug("Generating /etc/fstab file\n"); - fprintf(fstab, "# Device\t\tMountpoint\tFStype\tOptions\t\tDump\tPass#\n"); - for (i = 0; i < nchunks; i++) - fprintf(fstab, "/dev/%s\t\t%s\t\t%s\t%s\t\t%d\t%d\n", name_of(chunk_list[i]), mount_point(chunk_list[i]), - fstype(chunk_list[i]), fstype_short(chunk_list[i]), seq_num(chunk_list[i]), seq_num(chunk_list[i])); - - /* Now look for the CDROMs */ - devs = deviceFind(NULL, DEVICE_TYPE_CDROM); - cnt = deviceCount(devs); - - /* Write out the CDROM entries */ - for (i = 0; i < cnt; i++) { - char cdname[10]; - - sprintf(cdname, "/cdrom%s", i ? itoa(i) : ""); - if (Mkdir(cdname)) - msgConfirm("Unable to make mount point for: %s", cdname); - else - fprintf(fstab, "/dev/%s\t\t%s\tcd9660\tro,noauto\t0\t0\n", devs[i]->name, cdname); - } - - /* And finally, a /proc. */ - fprintf(fstab, "proc\t\t\t/proc\t\tprocfs\trw\t\t0\t0\n"); - Mkdir("/proc"); - - fclose(fstab); - if (isDebug()) - msgDebug("Wrote out /etc/fstab file\n"); - return DITEM_SUCCESS; -} - -/* Do the work of sucking in a config file. - * config is the filename to read in. - * lines is a fixed (max) sized array of char* - * returns number of lines read. line contents - * are malloc'd and must be freed by the caller. - */ -int -readConfig(char *config, char **lines, int max) -{ - FILE *fp; - char line[256]; - int i, nlines; - - fp = fopen(config, "r"); - if (!fp) - return -1; - - nlines = 0; - /* Read in the entire file */ - for (i = 0; i < max; i++) { - if (!fgets(line, sizeof line, fp)) - break; - lines[nlines++] = strdup(line); - } - fclose(fp); - if (isDebug()) - msgDebug("readConfig: Read %d lines from %s.\n", nlines, config); - return nlines; -} - -#define MAX_LINES 2000 /* Some big number we're not likely to ever reach - I'm being really lazy here, I know */ - -/* Load the environment from an rc.conf file */ -void -configEnvironmentRC_conf(char *config) -{ - char *lines[MAX_LINES], *cp, *cp2; - int i, nlines; - - nlines = readConfig(config, lines, MAX_LINES); - if (nlines == -1) - return; - - for (i = 0; i < nlines; i++) { - /* Skip the comments & non-variable settings */ - if (lines[i][0] == '#' || !(cp = index(lines[i], '='))) { - free(lines[i]); - continue; - } - *cp++ = '\0'; - /* Find quotes */ - if ((cp2 = index(cp, '"')) || (cp2 = index(cp, '\047'))) { - cp = cp2 + 1; - cp2 = index(cp, *cp2); - } - /* If valid quotes, use it */ - if (cp2) { - *cp2 = '\0'; - /* If we have a legit value and it's not already set, set it */ - if (strlen(cp) && !variable_get(lines[i])) - variable_set2(lines[i], cp); - } - free(lines[i]); - } -} - -/* Load the environment from a resolv.conf file */ -void -configEnvironmentResolv(char *config) -{ - char *lines[MAX_LINES]; - int i, nlines; - - nlines = readConfig(config, lines, MAX_LINES); - if (nlines == -1) - return; - for (i = 0; i < nlines; i++) { - Boolean name_set = (Boolean)variable_get(VAR_NAMESERVER); - - if (!strncmp(lines[i], "domain", 6) && !variable_get(VAR_DOMAINNAME)) - variable_set2(VAR_DOMAINNAME, string_skipwhite(string_prune(lines[i] + 6))); - else if (!name_set && !strncmp(lines[i], "nameserver", 10)) { - /* Only take the first nameserver setting - we're lame */ - variable_set2(VAR_NAMESERVER, string_skipwhite(string_prune(lines[i] + 10))); - } - free(lines[i]); - } -} - -/* Version of below for dispatch routines */ -int -configRC(dialogMenuItem *unused) -{ - configRC_conf("/etc/rc.conf"); - return DITEM_SUCCESS; -} - -/* - * This sucks in /etc/rc.conf, substitutes anything needing substitution, then - * writes it all back out. It's pretty gross and needs re-writing at some point. - */ -void -configRC_conf(char *config) -{ - FILE *fp; - char *lines[MAX_LINES], *cp; - Variable *v; - int i, nlines, len; - - nlines = readConfig(config, lines, MAX_LINES); - if (nlines == -1) - return; - - /* Now do variable substitutions */ - for (v = VarHead; v; v = v->next) { - for (i = 0; i < nlines; i++) { - /* Skip the comments & non-variable settings */ - if (lines[i][0] == '#' || !(cp = index(lines[i], '='))) - continue; - len = strlen(v->name); - if (!strncmp(lines[i], v->name, cp - lines[i]) && (cp - lines[i]) == len) { - char *cp2, *comment = NULL; - - /* If trailing comment, try and preserve it */ - if ((index(lines[i], '#')) != NULL) { - /* Find quotes */ - if ((cp2 = index(cp, '"')) || (cp2 = index(cp, '\047'))) - cp2 = index(cp2 + 1, *cp2); - if (cp2 && strlen(cp2 + 1)) { - comment = alloca(strlen(cp2)); - strcpy(comment, cp2 + 1); - } - } - free(lines[i]); - lines[i] = (char *)malloc(strlen(v->name) + strlen(v->value) + (comment ? strlen(comment) : 0) + 10); - if (comment) - sprintf(lines[i], "%s=\"%s\"%s", v->name, v->value, comment); - else - sprintf(lines[i], "%s=\"%s\"\n", v->name, v->value); - } - } - } - - /* Now write it all back out again */ - if (isDebug()) - msgDebug("Writing configuration changes to %s file..", config); - if (Fake) - fp = fdopen(DebugFD, "w"); - else { - (void)vsystem("cp %s %s.previous", config, config); - fp = fopen(config, "w"); - } - for (i = 0; i < nlines; i++) { - fprintf(fp, lines[i]); - /* Stand by for bogus special case handling - we try to dump the interface specs here */ - if (!strncmp(lines[i], VAR_INTERFACES, strlen(VAR_INTERFACES))) { - Device **devp; - int j, cnt; - - devp = deviceFind(NULL, DEVICE_TYPE_NETWORK); - cnt = deviceCount(devp); - for (j = 0; j < cnt; j++) { - char iname[255], toadd[512]; - int k, addit = TRUE; - - if (!strncmp(devp[j]->name, "ppp", 3) || !strncmp(devp[j]->name, "tun", 3)) - continue; - - snprintf(iname, 255, "%s%s", VAR_IFCONFIG, devp[j]->name); - if ((cp = variable_get(iname))) { - snprintf(toadd, sizeof toadd, "%s=\"%s\"\n", iname, cp); - for (k = 0; k < nlines; k++) { - if (!strcmp(lines[k], toadd)) { - addit = FALSE; - break; - } - } - if (addit) - fprintf(fp, toadd); - } - } - } - free(lines[i]); - } - fclose(fp); -} - -int -configSaver(dialogMenuItem *self) -{ - variable_set((char *)self->data); - if (!variable_get(VAR_BLANKTIME)) - variable_set2(VAR_BLANKTIME, "300"); - return DITEM_SUCCESS; -} - -int -configSaverTimeout(dialogMenuItem *self) -{ - return (variable_get_value(VAR_BLANKTIME, - "Enter time-out period in seconds for screen saver") ? - DITEM_SUCCESS : DITEM_FAILURE) | DITEM_RESTORE; -} - -int -configRegister(dialogMenuItem *self) -{ - return DITEM_STATUS(registerOpenDialog()) | DITEM_RESTORE; -} - -int -configNTP(dialogMenuItem *self) -{ - int status; - - status = variable_get_value(VAR_NTPDATE_FLAGS, - "Enter the name of an NTP server") - ? DITEM_SUCCESS : DITEM_FAILURE; - if (status == DITEM_SUCCESS) { - static char tmp[255]; - - snprintf(tmp, sizeof(tmp), "ntpdate_enable=YES,ntpdate_flags=%s", - variable_get(VAR_NTPDATE_FLAGS)); - self->data = tmp; - dmenuSetVariables(self); - } - return status | DITEM_RESTORE; -} - -int -configUsers(dialogMenuItem *self) -{ - dialog_clear_norefresh(); - dmenuOpenSimple(&MenuUsermgmt, FALSE); - dialog_clear(); - return DITEM_SUCCESS | DITEM_RESTORE; -} - -int -configXEnvironment(dialogMenuItem *self) -{ - char *config, *execfile; - char *moused; - -tryagain: - dialog_clear_norefresh(); - if (!dmenuOpenSimple(&MenuXF86Config, FALSE)) - return DITEM_FAILURE | DITEM_RESTORE; - if (file_readable("/var/run/ld.so.hints")) - systemExecute("/sbin/ldconfig -m /usr/lib /usr/X11R6/lib /usr/local/lib /usr/lib/compat"); - else - systemExecute("/sbin/ldconfig /usr/lib /usr/X11R6/lib /usr/local/lib /usr/lib/compat"); - config = variable_get(VAR_XF86_CONFIG); - if (!config) - return DITEM_FAILURE | DITEM_RESTORE; - execfile = string_concat("/usr/X11R6/bin/", config); - if (file_executable(execfile)) { - dialog_clear_norefresh(); - moused = variable_get(VAR_MOUSED); - while (!moused || strcmp(moused, "YES")) { - if (msgYesNo("The X server may access the mouse in two ways: direct access\n" - "or indirect access via the mouse daemon. You have not\n" - "configured the mouse daemon. Would you like to configure it\n" - "now? If you intend to let the X server access the mouse\n" - "directly, choose \"No\" at this time.")) - break; - dmenuOpenSimple(&MenuMouse, FALSE); - dialog_clear(); - moused = variable_get(VAR_MOUSED); - } - if (moused && !strcmp(moused, "YES")) - msgConfirm("You have configured and are now running the mouse daemon.\n" - "Choose \"/dev/sysmouse\" as the mouse port and \"SysMouse\" or\n" - "\"MouseSystems\" as the mouse protocol in the X configuration\n" - "utility."); - dialog_clear(); - systemExecute(execfile); - if (!file_readable("/etc/XF86Config") && !msgYesNo("The XFree86 configuration process seems to have\nfailed. Would you like to try again?")) - goto tryagain; - return DITEM_SUCCESS | DITEM_RESTORE; - } - else { - dialog_clear_norefresh(); - msgConfirm("The XFree86 setup utility you chose does not appear to be installed!\n" - "Please install this before attempting to configure XFree86."); - return DITEM_FAILURE | DITEM_RESTORE; - } -} - -int -configResolv(dialogMenuItem *ditem) -{ - FILE *fp; - char *cp, *dp, *hp; - - cp = variable_get(VAR_NAMESERVER); - if (!cp || !*cp) - goto skip; - Mkdir("/etc"); - fp = fopen("/etc/resolv.conf", "w"); - if (!fp) - return DITEM_FAILURE; - if (variable_get(VAR_DOMAINNAME)) - fprintf(fp, "domain\t%s\n", variable_get(VAR_DOMAINNAME)); - fprintf(fp, "nameserver\t%s\n", cp); - fclose(fp); - if (isDebug()) - msgDebug("Wrote out /etc/resolv.conf\n"); - -skip: - dp = variable_get(VAR_DOMAINNAME); - cp = variable_get(VAR_IPADDR); - hp = variable_get(VAR_HOSTNAME); - /* Tack ourselves into /etc/hosts */ - fp = fopen("/etc/hosts", "w"); - if (!fp) - return DITEM_FAILURE; - /* Add an entry for localhost */ - if (dp) - fprintf(fp, "127.0.0.1\t\tlocalhost.%s localhost\n", dp); - else - fprintf(fp, "127.0.0.1\t\tlocalhost\n"); - /* Now the host entries, if applicable */ - if (cp && cp[0] != '0' && hp) { - char cp2[255]; - - if (!index(hp, '.')) - cp2[0] = '\0'; - else { - SAFE_STRCPY(cp2, hp); - *(index(cp2, '.')) = '\0'; - } - fprintf(fp, "%s\t\t%s %s\n", cp, hp, cp2); - fprintf(fp, "%s\t\t%s.\n", cp, hp); - } - fclose(fp); - if (isDebug()) - msgDebug("Wrote out /etc/hosts\n"); - return DITEM_SUCCESS; -} - -int -configRouter(dialogMenuItem *self) -{ - int ret; - - ret = variable_get_value(VAR_ROUTER, - "Please specify the router you wish to use. Routed is\n" - "provided with the stock system and gated is provided\n" - "as an optional package which this installation system\n" - "will attempt to load if you select gated. Any other\n" - "choice of routing daemon will be assumed to be something\n" - "the user intends to install themselves before rebooting\n" - "the system. If you don't want any routing daemon, choose NO") - ? DITEM_SUCCESS : DITEM_FAILURE; - - if (ret == DITEM_SUCCESS) { - char *cp = variable_get(VAR_ROUTER); - - if (cp && strcmp(cp, "NO")) { - variable_set2(VAR_ROUTER_ENABLE, "YES"); - if (!strcmp(cp, "gated")) { - if (package_add(variable_get(VAR_GATED_PKG)) != DITEM_SUCCESS) { - msgConfirm("Unable to load gated package. Falling back to no router."); - variable_unset(VAR_ROUTER); - variable_unset(VAR_ROUTERFLAGS); - variable_set2(VAR_ROUTER_ENABLE, "NO"); - cp = NULL; - } - } - if (cp) { - /* Now get the flags, if they chose a router */ - ret = variable_get_value(VAR_ROUTERFLAGS, - "Please Specify the routing daemon flags; if you're running routed\n" - "then -q is the right choice for nodes and -s for gateway hosts.\n") - ? DITEM_SUCCESS : DITEM_FAILURE; - if (ret != DITEM_SUCCESS) - variable_unset(VAR_ROUTERFLAGS); - } - } - else { - /* No router case */ - variable_set2(VAR_ROUTER_ENABLE, "NO"); - variable_unset(VAR_ROUTERFLAGS); - variable_unset(VAR_ROUTER); - } - } - return ret | DITEM_RESTORE; -} - -int -configPackages(dialogMenuItem *self) -{ - static PkgNode top, plist; - static Boolean index_initted = FALSE; - PkgNodePtr tmp; - FILE *fp; - - if (!mediaVerify()) - return DITEM_FAILURE; - - if (!mediaDevice->init(mediaDevice)) - return DITEM_FAILURE; - - if (!index_initted) { - msgNotify("Attempting to fetch packages/INDEX file from selected media."); - fp = mediaDevice->get(mediaDevice, "packages/INDEX", TRUE); - if (!fp) { - dialog_clear_norefresh(); - msgConfirm("Unable to get packages/INDEX file from selected media.\n" - "This may be because the packages collection is not available at\n" - "on the distribution media you've chosen (most likely an FTP site\n" - "without the packages collection mirrored). Please verify media\n" - "(or path to media) and try again. If your local site does not\n" - "carry the packages collection, then we recommend either a CD\n" - "distribution or the master distribution on ftp.freebsd.org."); - mediaDevice->shutdown(mediaDevice); - return DITEM_FAILURE | DITEM_RESTORE; - } - msgNotify("Located INDEX, now reading package data from it..."); - index_init(&top, &plist); - if (index_read(fp, &top)) { - msgConfirm("I/O or format error on packages/INDEX file.\n" - "Please verify media (or path to media) and try again."); - fclose(fp); - return DITEM_FAILURE | DITEM_RESTORE; - } - fclose(fp); - index_sort(&top); - index_initted = TRUE; - } - while (1) { - int ret, pos, scroll; - - /* Bring up the packages menu */ - pos = scroll = 0; - index_menu(&top, &plist, &pos, &scroll); - - if (plist.kids && plist.kids->name) { - /* Now show the packing list menu */ - pos = scroll = 0; - ret = index_menu(&plist, NULL, &pos, &scroll); - if (ret & DITEM_LEAVE_MENU) - break; - else if (DITEM_STATUS(ret) != DITEM_FAILURE) { - index_extract(mediaDevice, &top, &plist); - break; - } - } - else { - dialog_clear_norefresh(); - msgConfirm("No packages were selected for extraction."); - break; - } - } - tmp = plist.kids; - while (tmp) { - PkgNodePtr tmp2 = tmp->next; - - safe_free(tmp); - tmp = tmp2; - } - index_init(NULL, &plist); - return DITEM_SUCCESS | DITEM_RESTORE; -} - -/* Load pcnfsd package */ -int -configPCNFSD(dialogMenuItem *self) -{ - int ret = DITEM_SUCCESS; - - if (variable_get(VAR_PCNFSD)) - variable_unset(VAR_PCNFSD); - else { - ret = package_add(variable_get(VAR_PCNFSD_PKG)); - if (DITEM_STATUS(ret) == DITEM_SUCCESS) { - variable_set2(VAR_PCNFSD, "YES"); - variable_set2("mountd_flags", "-n"); - } - } - return ret; -} - -int -configNFSServer(dialogMenuItem *self) -{ - char cmd[256]; - - /* If we're an NFS server, we need an exports file */ - if (!file_readable("/etc/exports")) { - WINDOW *w = savescr(); - - if (file_readable("/etc/exports.disabled")) - vsystem("mv /etc/exports.disabled /etc/exports"); - else { - dialog_clear_norefresh(); - msgConfirm("Operating as an NFS server means that you must first configure\n" - "an /etc/exports file to indicate which hosts are allowed certain\n" - "kinds of access to your local file systems.\n" - "Press [ENTER] now to invoke an editor on /etc/exports\n"); - vsystem("echo '#The following examples export /usr to 3 machines named after ducks,' > /etc/exports"); - vsystem("echo '#/home and all directories under it to machines named after dead rock stars' >> /etc/exports"); - vsystem("echo '#and, finally, /a to 2 privileged machines allowed to write on it as root.' >> /etc/exports"); - vsystem("echo '#/usr huey louie dewie' >> /etc/exports"); - vsystem("echo '#/home -alldirs janice jimmy frank' >> /etc/exports"); - vsystem("echo '#/a -maproot=0 bill albert' >> /etc/exports"); - vsystem("echo '#' >> /etc/exports"); - vsystem("echo '# You should replace these lines with your actual exported filesystems.' >> /etc/exports"); - vsystem("echo >> /etc/exports"); - sprintf(cmd, "%s /etc/exports", variable_get(VAR_EDITOR)); - dialog_clear(); - systemExecute(cmd); - restorescr(w); - } - variable_set2(VAR_NFS_SERVER, "YES"); - } - else if (variable_get(VAR_NFS_SERVER)) { /* We want to turn it off again? */ - vsystem("mv -f /etc/exports /etc/exports.disabled"); - variable_unset(VAR_NFS_SERVER); - } - return DITEM_SUCCESS; -} diff --git a/usr.sbin/sade/devices.c b/usr.sbin/sade/devices.c deleted file mode 100644 index 7b7261d23b43..000000000000 --- a/usr.sbin/sade/devices.c +++ /dev/null @@ -1,503 +0,0 @@ -/* - * The new sysinstall program. - * - * This is probably the last program in the `sysinstall' line - the next - * generation being essentially a complete rewrite. - * - * $Id: devices.c,v 1.87 1998/12/04 18:01:10 wpaul Exp $ - * - * Copyright (c) 1995 - * Jordan Hubbard. 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, - * verbatim and that no modifications are made prior to this - * point in the file. - * 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 JORDAN HUBBARD ``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 JORDAN HUBBARD OR HIS PETS 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, LIFE 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. - * - */ - -#include "sysinstall.h" -#include <sys/fcntl.h> -#include <sys/param.h> -#include <sys/socket.h> -#include <sys/ioctl.h> -#include <sys/errno.h> -#include <sys/time.h> -#include <net/if.h> -#include <net/if_var.h> -#include <net/if_dl.h> -#include <netinet/in.h> -#include <netinet/in_var.h> -#include <arpa/inet.h> -#include <ctype.h> - -/* how much to bias minor number for a given /dev/<ct#><un#>s<s#> slice */ -#define SLICE_DELTA (0x10000) - -static Device *Devices[DEV_MAX]; -static int numDevs; - -static struct _devname { - DeviceType type; - char *name; - char *description; - int major, minor, delta, max; - char dev_type; -} device_names[] = { - { DEVICE_TYPE_CDROM, "cd%dc", "SCSI CDROM drive", 6, 2, 8, 4, 'b' }, - { DEVICE_TYPE_CDROM, "mcd%da", "Mitsumi (old model) CDROM drive", 7, 0, 8, 4, 'b' }, - { DEVICE_TYPE_CDROM, "scd%da", "Sony CDROM drive - CDU31/33A type", 16, 0, 8, 4, 'b' }, - { DEVICE_TYPE_CDROM, "matcd%da", "Matsushita CDROM ('sound blaster' type)", 17, 0, 8, 4, 'b' }, - { DEVICE_TYPE_CDROM, "wcd%dc", "ATAPI IDE CDROM", 19, 2, 8, 4, 'b' }, - { DEVICE_TYPE_TAPE, "rsa%d", "SCSI tape drive", 14, 0, 16, 4, 'c' }, - { DEVICE_TYPE_TAPE, "rwt%d", "Wangtek tape drive", 10, 0, 1, 4, 'c' }, - { DEVICE_TYPE_DISK, "da%d", "SCSI disk device", 4, 65538, 8, 16, 'b' }, - { DEVICE_TYPE_DISK, "rda%d", "SCSI disk device", 13, 65538, 8, 16, 'c' }, - { DEVICE_TYPE_DISK, "wd%d", "IDE/ESDI/MFM/ST506 disk device", 0, 65538, 8, 16, 'b' }, - { DEVICE_TYPE_DISK, "rwd%d", "IDE/ESDI/MFM/ST506 disk device", 3, 65538, 8, 16, 'c' }, - { DEVICE_TYPE_DISK, "fla%d", "DiskOnChip2000 Flash device", 28, 65538, 8, 16, 'b' }, - { DEVICE_TYPE_DISK, "rfla%d", "DiskOnChip2000 Flash devicee", 101, 65538, 8, 16, 'c' }, - { DEVICE_TYPE_DISK, "wfd%d", "ATAPI floppy device", 1, 65538, 8, 4, 'b' }, - { DEVICE_TYPE_DISK, "rwfd%d", "ATAPI floppy device", 87, 65538, 8, 4, 'c' }, - { DEVICE_TYPE_FLOPPY, "fd%d", "floppy drive unit A", 2, 0, 64, 4, 'b' }, - { DEVICE_TYPE_FLOPPY, "wfd%d", "ATAPI floppy drive unit A", 1, 0, 8, 4, 'b' }, - { DEVICE_TYPE_FLOPPY, "worm%d", "SCSI optical disk / CDR", 23, 0, 1, 4, 'b' }, - { DEVICE_TYPE_NETWORK, "ax", "ASIX AX88140A PCI ethernet card" }, - { DEVICE_TYPE_NETWORK, "fpa", "DEC DEFPA PCI FDDI card" }, - { DEVICE_TYPE_NETWORK, "sr", "SDL T1/E1 sync serial PCI card" }, - { DEVICE_TYPE_NETWORK, "cc3i", "SDL HSSI sync serial PCI card" }, - { DEVICE_TYPE_NETWORK, "en", "Efficient Networks ATM PCI card" }, - { DEVICE_TYPE_NETWORK, "de", "DEC DE435 PCI NIC or other DC21040-AA based card" }, - { DEVICE_TYPE_NETWORK, "fxp", "Intel EtherExpress Pro/100B PCI Fast Ethernet card" }, - { DEVICE_TYPE_NETWORK, "ed", "WD/SMC 80xx; Novell NE1000/2000; 3Com 3C503 card" }, - { DEVICE_TYPE_NETWORK, "ep", "3Com 3C509 ethernet card" }, - { DEVICE_TYPE_NETWORK, "el", "3Com 3C501 ethernet card" }, - { DEVICE_TYPE_NETWORK, "ex", "Intel EtherExpress Pro/10 ethernet card" }, - { DEVICE_TYPE_NETWORK, "fe", "Fujitsu MB86960A/MB86965A ethernet card" }, - { DEVICE_TYPE_NETWORK, "ie", "AT&T StarLAN 10 and EN100; 3Com 3C507; NI5210" }, - { DEVICE_TYPE_NETWORK, "ix", "Intel Etherexpress ethernet card" }, - { DEVICE_TYPE_NETWORK, "le", "DEC EtherWorks 2 or 3 ethernet card" }, - { DEVICE_TYPE_NETWORK, "lnc", "Lance/PCnet (Isolan/Novell NE2100/NE32-VL) ethernet" }, - { DEVICE_TYPE_NETWORK, "mx", "Macronix 98713/98715/98725 PCI ethernet card" }, - { DEVICE_TYPE_NETWORK, "pn", "Lite-On 82168/82169 PNIC PCI ethernet card" }, - { DEVICE_TYPE_NETWORK, "rl", "RealTek 8129/8139 PCI ethernet card" }, - { DEVICE_TYPE_NETWORK, "tx", "SMC 9432TX ethernet card" }, - { DEVICE_TYPE_NETWORK, "tl", "Texas Instruments ThunderLAN PCI ethernet card" }, - { DEVICE_TYPE_NETWORK, "vr", "VIA VT3043/VT86C100A Rhine PCI ethernet card" }, - { DEVICE_TYPE_NETWORK, "vx", "3COM 3c590 / 3c595 ethernet card" }, - { DEVICE_TYPE_NETWORK, "wb", "Winbond W89C840F PCI ethernet card" }, - { DEVICE_TYPE_NETWORK, "xl", "3COM 3c90x / 3c90xB PCI ethernet card" }, - { DEVICE_TYPE_NETWORK, "ze", "IBM/National Semiconductor PCMCIA ethernet card" }, - { DEVICE_TYPE_NETWORK, "zp", "3Com Etherlink III PCMCIA ethernet card" }, - { DEVICE_TYPE_NETWORK, "cuaa%d", "%s on device %s (COM%d)", 28, 128, 1, 16, 'c' }, - { DEVICE_TYPE_NETWORK, "lp", "Parallel Port IP (PLIP) peer connection" }, - { DEVICE_TYPE_NETWORK, "lo", "Loop-back (local) network interface" }, - { 0 }, -}; - -Device * -new_device(char *name) -{ - Device *dev; - - dev = safe_malloc(sizeof(Device)); - bzero(dev, sizeof(Device)); - if (name) - SAFE_STRCPY(dev->name, name); - return dev; -} - -/* Stubs for unimplemented strategy routines */ -Boolean -dummyInit(Device *dev) -{ - return TRUE; -} - -FILE * -dummyGet(Device *dev, char *dist, Boolean probe) -{ - return NULL; -} - -void -dummyShutdown(Device *dev) -{ - return; -} - -static int -deviceTry(struct _devname dev, char *try, int i) -{ - int fd; - char unit[80]; - mode_t m; - dev_t d; - int fail; - - snprintf(unit, sizeof unit, dev.name, i); - snprintf(try, FILENAME_MAX, "/dev/%s", unit); - fd = open(try, O_RDONLY); - if (fd >= 0) - return fd; - m = 0640; - if (dev.dev_type == 'c') - m |= S_IFCHR; - else - m |= S_IFBLK; - d = makedev(dev.major, dev.minor + (i * dev.delta)); - fail = mknod(try, m, d); - fd = open(try, O_RDONLY); - if (fd >= 0) - return fd; - else if (!fail) - (void)unlink(try); - /* Don't try a "make-under" here since we're using a fixit floppy in this case */ - snprintf(try, FILENAME_MAX, "/mnt/dev/%s", unit); - fd = open(try, O_RDONLY); - return fd; -} - -/* Register a new device in the devices array */ -Device * -deviceRegister(char *name, char *desc, char *devname, DeviceType type, Boolean enabled, - Boolean (*init)(Device *), FILE * (*get)(Device *, char *, Boolean), - void (*shutdown)(Device *), void *private) -{ - Device *newdev = NULL; - - if (numDevs == DEV_MAX) - msgFatal("Too many devices found!"); - else { - newdev = new_device(name); - newdev->description = desc; - newdev->devname = devname; - newdev->type = type; - newdev->enabled = enabled; - newdev->init = init ? init : dummyInit; - newdev->get = get ? get : dummyGet; - newdev->shutdown = shutdown ? shutdown : dummyShutdown; - newdev->private = private; - Devices[numDevs] = newdev; - Devices[++numDevs] = NULL; - } - return newdev; -} - -/* Get all device information for devices we have attached */ -void -deviceGetAll(void) -{ - int i, j, fd, s; - struct ifconf ifc; - struct ifreq *ifptr, *end; - int ifflags; - char buffer[INTERFACE_MAX * sizeof(struct ifreq)]; - char **names; - - msgNotify("Probing devices, please wait (this can take a while)..."); - /* First go for the network interfaces. Stolen shamelessly from ifconfig! */ - ifc.ifc_len = sizeof(buffer); - ifc.ifc_buf = buffer; - - s = socket(AF_INET, SOCK_DGRAM, 0); - if (s < 0) { - msgConfirm("ifconfig: socket"); - goto skipif; /* Jump over network iface probing */ - } - if (ioctl(s, SIOCGIFCONF, (char *) &ifc) < 0) { - msgConfirm("ifconfig (SIOCGIFCONF)"); - goto skipif; /* Jump over network iface probing */ - } - ifflags = ifc.ifc_req->ifr_flags; - end = (struct ifreq *) (ifc.ifc_buf + ifc.ifc_len); - for (ifptr = ifc.ifc_req; ifptr < end; ifptr++) { - char *descr; - - /* If it's not a link entry, forget it */ - if (ifptr->ifr_ifru.ifru_addr.sa_family != AF_LINK) - continue; - - /* Eliminate network devices that don't make sense */ - if (!strncmp(ifptr->ifr_name, "lo", 2)) - continue; - - /* If we have a slip device, don't register it */ - if (!strncmp(ifptr->ifr_name, "sl", 2)) { - continue; - } - /* And the same for ppp */ - if (!strncmp(ifptr->ifr_name, "tun", 3) || !strncmp(ifptr->ifr_name, "ppp", 3)) { - continue; - } - /* Try and find its description */ - for (i = 0, descr = NULL; device_names[i].name; i++) { - int len = strlen(device_names[i].name); - - if (!ifptr->ifr_name || !ifptr->ifr_name[0]) - continue; - else if (!strncmp(ifptr->ifr_name, device_names[i].name, len)) { - descr = device_names[i].description; - break; - } - } - if (!descr) - descr = "<unknown network interface type>"; - - deviceRegister(ifptr->ifr_name, descr, strdup(ifptr->ifr_name), DEVICE_TYPE_NETWORK, TRUE, - mediaInitNetwork, NULL, mediaShutdownNetwork, NULL); - msgDebug("Found a network device named %s\n", ifptr->ifr_name); - close(s); - if ((s = socket(AF_INET, SOCK_DGRAM, 0)) < 0) { - msgConfirm("ifconfig: socket"); - continue; - } - if (ifptr->ifr_addr.sa_len) /* I'm not sure why this is here - it's inherited */ - ifptr = (struct ifreq *)((caddr_t)ifptr + ifptr->ifr_addr.sa_len - sizeof(struct sockaddr)); - } - -skipif: - /* Next, try to find all the types of devices one might need - * during the second stage of the installation. - */ - for (i = 0; device_names[i].name; i++) { - for (j = 0; j < device_names[i].max; j++) { - char try[FILENAME_MAX]; - - switch(device_names[i].type) { - case DEVICE_TYPE_CDROM: - fd = deviceTry(device_names[i], try, j); - if (fd >= 0 || errno == EBUSY) { /* EBUSY if already mounted */ - char n[BUFSIZ]; - - if (fd >= 0) close(fd); - snprintf(n, sizeof n, device_names[i].name, j); - deviceRegister(strdup(n), device_names[i].description, strdup(try), - DEVICE_TYPE_CDROM, TRUE, mediaInitCDROM, mediaGetCDROM, - mediaShutdownCDROM, NULL); - msgDebug("Found a CDROM device for %s\n", try); - } - break; - - case DEVICE_TYPE_TAPE: - fd = deviceTry(device_names[i], try, j); - if (fd >= 0) { - char n[BUFSIZ]; - - close(fd); - snprintf(n, sizeof n, device_names[i].name, j); - deviceRegister(strdup(n), device_names[i].description, strdup(try), - DEVICE_TYPE_TAPE, TRUE, mediaInitTape, mediaGetTape, mediaShutdownTape, NULL); - msgDebug("Found a TAPE device for %s\n", try); - } - break; - - case DEVICE_TYPE_DISK: - fd = deviceTry(device_names[i], try, j); - if (fd >= 0 && RunningAsInit) { - dev_t d; - mode_t m; - int s, fail; - char unit[80], slice[80]; - - close(fd); - /* Make associated slice entries */ - for (s = 1; s < 8; s++) { - snprintf(unit, sizeof unit, device_names[i].name, j); - snprintf(slice, sizeof slice, "/dev/%ss%d", unit, s); - d = makedev(device_names[i].major, device_names[i].minor + - (j * device_names[i].delta) + (s * SLICE_DELTA)); - m = 0640; - if (device_names[i].dev_type == 'c') - m |= S_IFCHR; - else - m |= S_IFBLK; - fail = mknod(slice, m, d); - fd = open(slice, O_RDONLY); - if (fd >= 0) - close(fd); - else if (!fail) - (void)unlink(slice); - } - } - break; - - case DEVICE_TYPE_FLOPPY: - fd = deviceTry(device_names[i], try, j); - if (fd >= 0) { - char n[BUFSIZ]; - - close(fd); - snprintf(n, sizeof n, device_names[i].name, j); - deviceRegister(strdup(n), device_names[i].description, strdup(try), - DEVICE_TYPE_FLOPPY, TRUE, mediaInitFloppy, mediaGetFloppy, - mediaShutdownFloppy, NULL); - msgDebug("Found a floppy device for %s\n", try); - } - break; - - case DEVICE_TYPE_NETWORK: - fd = deviceTry(device_names[i], try, j); - /* The only network devices that you can open this way are serial ones */ - if (fd >= 0) { - char *newdesc, *cp; - - close(fd); - cp = device_names[i].description; - /* Serial devices get a slip and ppp device each, if supported */ - newdesc = safe_malloc(strlen(cp) + 40); - sprintf(newdesc, cp, "SLIP interface", try, j + 1); - deviceRegister("sl0", newdesc, strdup(try), DEVICE_TYPE_NETWORK, TRUE, mediaInitNetwork, - NULL, mediaShutdownNetwork, NULL); - msgDebug("Add mapping for %s to sl0\n", try); - newdesc = safe_malloc(strlen(cp) + 50); - sprintf(newdesc, cp, "PPP interface", try, j + 1); - deviceRegister("ppp0", newdesc, strdup(try), DEVICE_TYPE_NETWORK, TRUE, mediaInitNetwork, - NULL, mediaShutdownNetwork, NULL); - msgDebug("Add mapping for %s to ppp0\n", try); - } - break; - - default: - break; - } - } - } - - /* Finally, go get the disks and look for DOS partitions to register */ - if ((names = Disk_Names()) != NULL) { - int i; - - for (i = 0; names[i]; i++) { - Chunk *c1; - Disk *d; - - d = Open_Disk(names[i]); - if (!d) - msgFatal("Unable to open disk %s", names[i]); - - deviceRegister(names[i], names[i], d->name, DEVICE_TYPE_DISK, FALSE, - dummyInit, dummyGet, dummyShutdown, d); - msgDebug("Found a disk device named %s\n", names[i]); - - /* Look for existing DOS partitions to register as "DOS media devices" */ - for (c1 = d->chunks->part; c1; c1 = c1->next) { - if (c1->type == fat || c1->type == extended) { - Device *dev; - char devname[80]; - - /* Got one! */ - snprintf(devname, sizeof devname, "/dev/%s", c1->name); - dev = deviceRegister(c1->name, c1->name, strdup(devname), DEVICE_TYPE_DOS, TRUE, - mediaInitDOS, mediaGetDOS, mediaShutdownDOS, NULL); - dev->private = c1; - msgDebug("Found a DOS partition %s on drive %s\n", c1->name, d->name); - } - } - } - free(names); - } -} - -/* - * Find all devices that match the criteria, allowing "wildcarding" as well - * by allowing NULL or ANY values to match all. The array returned is static - * and may be used until the next invocation of deviceFind(). - */ -Device ** -deviceFind(char *name, DeviceType class) -{ - static Device *found[DEV_MAX]; - int i, j; - - j = 0; - for (i = 0; i < numDevs; i++) { - if ((!name || !strcmp(Devices[i]->name, name)) - && (class == DEVICE_TYPE_ANY || class == Devices[i]->type)) - found[j++] = Devices[i]; - } - found[j] = NULL; - return j ? found : NULL; -} - -Device ** -deviceFindDescr(char *name, char *desc, DeviceType class) -{ - static Device *found[DEV_MAX]; - int i, j; - - j = 0; - for (i = 0; i < numDevs; i++) { - if ((!name || !strcmp(Devices[i]->name, name)) && - (!desc || !strcmp(Devices[i]->description, desc)) && - (class == DEVICE_TYPE_ANY || class == Devices[i]->type)) - found[j++] = Devices[i]; - } - found[j] = NULL; - return j ? found : NULL; -} - -int -deviceCount(Device **devs) -{ - int i; - - if (!devs) - return 0; - for (i = 0; devs[i]; i++); - return i; -} - -/* - * Create a menu listing all the devices of a certain type in the system. - * The passed-in menu is expected to be a "prototype" from which the new - * menu is cloned. - */ -DMenu * -deviceCreateMenu(DMenu *menu, DeviceType type, int (*hook)(dialogMenuItem *d), int (*check)(dialogMenuItem *d)) -{ - Device **devs; - int numdevs; - DMenu *tmp = NULL; - int i, j; - - devs = deviceFind(NULL, type); - numdevs = deviceCount(devs); - if (!numdevs) - return NULL; - tmp = (DMenu *)safe_malloc(sizeof(DMenu) + (sizeof(dialogMenuItem) * (numdevs + 1))); - bcopy(menu, tmp, sizeof(DMenu)); - for (i = 0; devs[i]; i++) { - tmp->items[i].prompt = devs[i]->name; - for (j = 0; j < numDevs; j++) { - if (devs[i] == Devices[j]) { - tmp->items[i].title = Devices[j]->description; - break; - } - } - if (j == numDevs) - tmp->items[i].title = "<unknown device type>"; - tmp->items[i].fire = hook; - tmp->items[i].checked = check; - } - tmp->items[i].title = NULL; - return tmp; -} diff --git a/usr.sbin/sade/disks.c b/usr.sbin/sade/disks.c deleted file mode 100644 index 6c6b5019a9c7..000000000000 --- a/usr.sbin/sade/disks.c +++ /dev/null @@ -1,814 +0,0 @@ -/* - * The new sysinstall program. - * - * This is probably the last program in the `sysinstall' line - the next - * generation being essentially a complete rewrite. - * - * $Id: disks.c,v 1.107 1999/01/02 07:23:37 jkh Exp $ - * - * Copyright (c) 1995 - * Jordan Hubbard. 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, - * verbatim and that no modifications are made prior to this - * point in the file. - * 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 JORDAN HUBBARD ``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 JORDAN HUBBARD OR HIS PETS 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, LIFE 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. - * - */ - -#include "sysinstall.h" -#include <ctype.h> -#include <fcntl.h> -#include <sys/stat.h> -#include <sys/disklabel.h> - -/* Where we start displaying chunk information on the screen */ -#define CHUNK_START_ROW 5 - -/* Where we keep track of MBR chunks */ -static struct chunk *chunk_info[16]; -static int current_chunk; - -static void diskPartitionNonInteractive(Device *dev); - -static void -record_chunks(Disk *d) -{ - struct chunk *c1 = NULL; - int i = 0; - int last_free = 0; - - if (!d->chunks) - msgFatal("No chunk list found for %s!", d->name); - - for (c1 = d->chunks->part; c1; c1 = c1->next) { - if (c1->type == unused && c1->size > last_free) { - last_free = c1->size; - current_chunk = i; - } - chunk_info[i++] = c1; - } - chunk_info[i] = NULL; - if (current_chunk >= i) - current_chunk = i - 1; -} - -static int Total; - -static void -print_chunks(Disk *d) -{ - int row; - int i; - - for (i = Total = 0; chunk_info[i]; i++) - Total += chunk_info[i]->size; - if (d->bios_cyl > 65536 || d->bios_hd > 256 || d->bios_sect >= 64) { - dialog_clear_norefresh(); - msgConfirm("WARNING: A geometry of %d/%d/%d for %s is incorrect. Using\n" - "a more likely geometry. If this geometry is incorrect or you\n" - "are unsure as to whether or not it's correct, please consult\n" - "the Hardware Guide in the Documentation submenu or use the\n" - "(G)eometry command to change it now.\n\n" - "Remember: you need to enter whatever your BIOS thinks the\n" - "geometry is! For IDE, it's what you were told in the BIOS\n" - "setup. For SCSI, it's the translation mode your controller is\n" - "using. Do NOT use a ``physical geometry''.", - d->bios_cyl, d->bios_hd, d->bios_sect, d->name); - Sanitize_Bios_Geom(d); - } - attrset(A_NORMAL); - mvaddstr(0, 0, "Disk name:\t"); - clrtobot(); - attrset(A_REVERSE); addstr(d->name); attrset(A_NORMAL); - attrset(A_REVERSE); mvaddstr(0, 55, "FDISK Partition Editor"); attrset(A_NORMAL); - mvprintw(1, 0, - "DISK Geometry:\t%lu cyls/%lu heads/%lu sectors = %lu sectors", - d->bios_cyl, d->bios_hd, d->bios_sect, - d->bios_cyl * d->bios_hd * d->bios_sect); - mvprintw(3, 0, "%10s %10s %10s %8s %6s %10s %8s %8s", - "Offset", "Size", "End", "Name", "PType", "Desc", - "Subtype", "Flags"); - for (i = 0, row = CHUNK_START_ROW; chunk_info[i]; i++, row++) { - if (i == current_chunk) - attrset(ATTR_SELECTED); - mvprintw(row, 0, "%10ld %10lu %10lu %8s %6d %10s %8d\t%-6s", - chunk_info[i]->offset, chunk_info[i]->size, - chunk_info[i]->end, chunk_info[i]->name, - chunk_info[i]->type, - slice_type_name(chunk_info[i]->type, chunk_info[i]->subtype), - chunk_info[i]->subtype, ShowChunkFlags(chunk_info[i])); - if (i == current_chunk) - attrset(A_NORMAL); - } -} - -static void -print_command_summary() -{ - mvprintw(14, 0, "The following commands are supported (in upper or lower case):"); - mvprintw(16, 0, "A = Use Entire Disk B = Bad Block Scan C = Create Slice"); - mvprintw(17, 0, "D = Delete Slice G = Set Drive Geometry S = Set Bootable"); - mvprintw(18, 0, "T = Change Type U = Undo All Changes Q = Finish"); - if (!RunningAsInit) - mvprintw(18, 48, "W = Write Changes"); - mvprintw(21, 0, "Use F1 or ? to get more help, arrow keys to select."); - move(0, 0); -} - -static u_char * -getBootMgr(char *dname) -{ -#ifndef __alpha__ /* only meaningful on x86 */ - extern u_char mbr[], boot0[]; - char str[80]; - char *cp; - int i = 0; - - cp = variable_get(VAR_BOOTMGR); - if (!cp) { - /* Figure out what kind of MBR the user wants */ - sprintf(str, "Install Boot Manager for drive %s?", dname); - MenuMBRType.title = str; - i = dmenuOpenSimple(&MenuMBRType, FALSE); - } - else { - if (!strncmp(cp, "boot", 4)) - BootMgr = 0; - else if (!strcmp(cp, "standard")) - BootMgr = 1; - else - BootMgr = 2; - } - if (cp || i) { - switch (BootMgr) { - case 0: - return boot0; - - case 1: - return mbr; - - case 2: - default: - break; - } - } -#endif - return NULL; -} - -int -diskGetSelectCount(Device ***devs) -{ - int i, cnt, enabled; - char *cp; - Device **dp; - - cp = variable_get(VAR_DISK); - dp = *devs = deviceFind(cp, DEVICE_TYPE_DISK); - cnt = deviceCount(dp); - if (!cnt) - return -1; - for (i = 0, enabled = 0; i < cnt; i++) { - if (dp[i]->enabled) - ++enabled; - } - return enabled; -} - -void -diskPartition(Device *dev) -{ - char *cp, *p; - int rv, key = 0; - Boolean chunking; - char *msg = NULL; - u_char *mbrContents; - WINDOW *w = savescr(); - Disk *d = (Disk *)dev->private; - - chunking = TRUE; - keypad(stdscr, TRUE); - - /* Flush both the dialog and curses library views of the screen - since we don't always know who called us */ - dialog_clear_norefresh(), clear(); - current_chunk = 0; - - /* Set up the chunk array */ - record_chunks(d); - - while (chunking) { - char *val, geometry[80]; - - /* Now print our overall state */ - if (d) - print_chunks(d); - print_command_summary(); - if (msg) { - attrset(title_attr); mvprintw(23, 0, msg); attrset(A_NORMAL); - beep(); - msg = NULL; - } - else { - move(23, 0); - clrtoeol(); - } - - /* Get command character */ - key = getch(); - switch (toupper(key)) { - case '\014': /* ^L (redraw) */ - clear(); - msg = NULL; - break; - - case '\020': /* ^P */ - case KEY_UP: - case '-': - if (current_chunk != 0) - --current_chunk; - break; - - case '\016': /* ^N */ - case KEY_DOWN: - case '+': - case '\r': - case '\n': - if (chunk_info[current_chunk + 1]) - ++current_chunk; - break; - - case KEY_HOME: - current_chunk = 0; - break; - - case KEY_END: - while (chunk_info[current_chunk + 1]) - ++current_chunk; - break; - - case KEY_F(1): - case '?': - systemDisplayHelp("slice"); - clear(); - break; - - case 'A': -#ifdef __alpha__ - rv = 1; -#else /* The rest is only relevant on x86 */ - cp = variable_get(VAR_DEDICATE_DISK); - if (cp && !strcasecmp(cp, "always")) - rv = 1; - else { - rv = msgYesNo("Do you want to do this with a true partition entry\n" - "so as to remain cooperative with any future possible\n" - "operating systems on the drive(s)?\n" - "(See also the section about ``dangerously dedicated''\n" - "disks in the FreeBSD FAQ.)"); - if (rv == -1) - rv = 0; - } -#endif - All_FreeBSD(d, rv); - variable_set2(DISK_PARTITIONED, "yes"); - record_chunks(d); - clear(); - break; - - case 'B': - if (chunk_info[current_chunk]->type != freebsd) - msg = "Can only scan for bad blocks in FreeBSD slice."; - else if (strncmp(d->name, "sd", 2) || - strncmp(d->name, "da", 2) || - !msgYesNo("This typically makes sense only for ESDI, IDE or MFM drives.\n" - "Are you sure you want to do this on a SCSI disk?")) { - if (chunk_info[current_chunk]->flags & CHUNK_BAD144) - chunk_info[current_chunk]->flags &= ~CHUNK_BAD144; - else - chunk_info[current_chunk]->flags |= CHUNK_BAD144; - } - clear(); - break; - - case 'C': - if (chunk_info[current_chunk]->type != unused) - msg = "Slice in use, delete it first or move to an unused one."; - else { - char *val, tmp[20], *cp; - int size, subtype; - chunk_e partitiontype; - - snprintf(tmp, 20, "%lu", chunk_info[current_chunk]->size); - val = msgGetInput(tmp, "Please specify the size for new FreeBSD slice in blocks\n" - "or append a trailing `M' for megabytes (e.g. 20M)."); - if (val && (size = strtol(val, &cp, 0)) > 0) { - if (*cp && toupper(*cp) == 'M') - size *= ONE_MEG; - strcpy(tmp, "165"); - val = msgGetInput(tmp, "Enter type of partition to create:\n\n" - "Pressing Enter will choose the default, a native FreeBSD\n" - "slice (type 165). You can choose other types, 6 for a\n" - "DOS partition or 131 for a Linux partition, for example.\n\n" - "Note: If you choose a non-FreeBSD partition type, it will not\n" - "be formatted or otherwise prepared, it will simply reserve space\n" - "for you to use another tool, such as DOS FORMAT, to later format\n" - "and use the partition."); - if (val && (subtype = strtol(val, NULL, 0)) > 0) { - if (subtype == 165) - partitiontype = freebsd; - else if (subtype == 6) - partitiontype = fat; - else - partitiontype = unknown; -#ifdef __alpha__ - if (partitiontype == freebsd && size == chunk_info[current_chunk]->size) - All_FreeBSD(d, 1); - else -#endif - Create_Chunk(d, chunk_info[current_chunk]->offset, size, partitiontype, subtype, - (chunk_info[current_chunk]->flags & CHUNK_ALIGN)); - variable_set2(DISK_PARTITIONED, "yes"); - record_chunks(d); - } - } - clear(); - } - break; - - case KEY_DC: - case 'D': - if (chunk_info[current_chunk]->type == unused) - msg = "Slice is already unused!"; - else { - Delete_Chunk(d, chunk_info[current_chunk]); - variable_set2(DISK_PARTITIONED, "yes"); - record_chunks(d); - } - break; - - case 'T': - if (chunk_info[current_chunk]->type == unused) - msg = "Slice is currently unused (use create instead)"; - else { - char *val, tmp[20]; - int subtype; - chunk_e partitiontype; - WINDOW *save = savescr(); - - strcpy(tmp, "165"); - val = msgGetInput(tmp, "New partition type:\n\n" - "Pressing Enter will choose the default, a native FreeBSD\n" - "slice (type 165). Other popular values are 6 for\n" - "DOS FAT partition, 131 for a Linux ext2fs partition or\n" - "130 for a Linux swap partition.\n\n" - "Note: If you choose a non-FreeBSD partition type, it will not\n" - "be formatted or otherwise prepared, it will simply reserve space\n" - "for you to use another tool, such as DOS format, to later format\n" - "and actually use the partition."); - if (val && (subtype = strtol(val, NULL, 0)) > 0) { - if (subtype == 165) - partitiontype = freebsd; - else if (subtype == 6) - partitiontype = fat; - else - partitiontype = unknown; - chunk_info[current_chunk]->type = partitiontype; - chunk_info[current_chunk]->subtype = subtype; - } - restorescr(save); - } - break; - - case 'G': - snprintf(geometry, 80, "%lu/%lu/%lu", d->bios_cyl, d->bios_hd, d->bios_sect); - val = msgGetInput(geometry, "Please specify the new geometry in cyl/hd/sect format.\n" - "Don't forget to use the two slash (/) separator characters!\n" - "It's not possible to parse the field without them."); - if (val) { - long nc, nh, ns; - nc = strtol(val, &val, 0); - nh = strtol(val + 1, &val, 0); - ns = strtol(val + 1, 0, 0); - Set_Bios_Geom(d, nc, nh, ns); - } - clear(); - break; - - case 'S': - /* Set Bootable */ - chunk_info[current_chunk]->flags |= CHUNK_ACTIVE; - break; - - case 'U': - if ((cp = variable_get(DISK_LABELLED)) && !strcmp(cp, "written")) { - msgConfirm("You've already written this information out - you\n" - "can't undo it."); - } - else if (!msgYesNo("Are you SURE you want to Undo everything?")) { - char cp[BUFSIZ]; - - sstrncpy(cp, d->name, sizeof cp); - Free_Disk(dev->private); - d = Open_Disk(cp); - if (!d) - msgConfirm("Can't reopen disk %s! Internal state is probably corrupted", cp); - dev->private = d; - variable_unset(DISK_PARTITIONED); - variable_unset(DISK_LABELLED); - if (d) - record_chunks(d); - } - clear(); - break; - - case 'W': - if (!msgYesNo("WARNING: This should only be used when modifying an EXISTING\n" - "installation. If you are installing FreeBSD for the first time\n" - "then you should simply type Q when you're finished here and your\n" - "changes will be committed in one batch automatically at the end of\n" - "these questions. If you're adding a disk, you should NOT write\n" - "from this screen, you should do it from the label editor.\n\n" - "Are you absolutely sure you want to do this now?")) { - variable_set2(DISK_PARTITIONED, "yes"); - - /* Don't trash the MBR if the first (and therefore only) chunk is marked for a truly dedicated - * disk (i.e., the disklabel starts at sector 0), even in cases where the user has requested - * booteasy or a "standard" MBR -- both would be fatal in this case. - */ -#if 0 - if ((d->chunks->part->flags & CHUNK_FORCE_ALL) != CHUNK_FORCE_ALL - && (mbrContents = getBootMgr(d->name)) != NULL) - Set_Boot_Mgr(d, mbrContents); -#else - /* - * Don't offer to update the MBR on this disk if the first "real" chunk looks like - * a FreeBSD "all disk" partition, or the disk is entirely FreeBSD. - */ - if (((d->chunks->part->type != freebsd) || (d->chunks->part->offset > 1)) && - (mbrContents = getBootMgr(d->name)) != NULL) - Set_Boot_Mgr(d, mbrContents); -#endif - - if (DITEM_STATUS(diskPartitionWrite(NULL)) != DITEM_SUCCESS) - msgConfirm("Disk partition write returned an error status!"); - else - msgConfirm("Wrote FDISK partition information out successfully."); - } - clear(); - break; - - case '|': - if (!msgYesNo("Are you SURE you want to go into Wizard mode?\n" - "No seat belts whatsoever are provided!")) { - clear(); - refresh(); - slice_wizard(d); - variable_set2(DISK_PARTITIONED, "yes"); - record_chunks(d); - } - else - msg = "Wise choice!"; - clear(); - break; - - case '\033': /* ESC */ - case 'Q': - chunking = FALSE; - /* Don't trash the MBR if the first (and therefore only) chunk is marked for a truly dedicated - * disk (i.e., the disklabel starts at sector 0), even in cases where the user has requested - * booteasy or a "standard" MBR -- both would be fatal in this case. - */ -#if 0 - if ((d->chunks->part->flags & CHUNK_FORCE_ALL) != CHUNK_FORCE_ALL - && (mbrContents = getBootMgr(d->name)) != NULL) - Set_Boot_Mgr(d, mbrContents); -#else - /* - * Don't offer to update the MBR on this disk if the first "real" chunk looks like - * a FreeBSD "all disk" partition, or the disk is entirely FreeBSD. - */ - if (((d->chunks->part->type != freebsd) || (d->chunks->part->offset > 1)) && - (mbrContents = getBootMgr(d->name)) != NULL) - Set_Boot_Mgr(d, mbrContents); -#endif - break; - - default: - beep(); - msg = "Type F1 or ? for help"; - break; - } - } - p = CheckRules(d); - if (p) { - char buf[FILENAME_MAX]; - - dialog_clear_norefresh(); - use_helpline("Press F1 to read more about disk slices."); - use_helpfile(systemHelpFile("partition", buf)); - if (!variable_get(VAR_NO_WARN)) - dialog_mesgbox("Disk slicing warning:", p, -1, -1); - free(p); - } - restorescr(w); -} - -static u_char * -bootalloc(char *name) -{ - char buf[FILENAME_MAX]; - struct stat sb; - - snprintf(buf, sizeof buf, "/boot/%s", name); - if (stat(buf, &sb) != -1) { - int fd; - - fd = open(buf, O_RDONLY); - if (fd != -1) { - u_char *cp; - - cp = malloc(sb.st_size); - if (read(fd, cp, sb.st_size) != sb.st_size) { - free(cp); - close(fd); - msgDebug("bootalloc: couldn't read %d bytes from %s\n", sb.st_size, buf); - return NULL; - } - close(fd); - return cp; - } - msgDebug("bootalloc: couldn't open %s\n", buf); - } - else - msgDebug("bootalloc: can't stat %s\n", buf); - return NULL; -} - -static int -partitionHook(dialogMenuItem *selected) -{ - Device **devs = NULL; - - devs = deviceFind(selected->prompt, DEVICE_TYPE_DISK); - if (!devs) { - msgConfirm("Unable to find disk %s!", selected->prompt); - return DITEM_FAILURE; - } - /* Toggle enabled status? */ - if (!devs[0]->enabled) { - devs[0]->enabled = TRUE; - diskPartition(devs[0]); - } - else - devs[0]->enabled = FALSE; - return DITEM_SUCCESS | DITEM_RESTORE; -} - -static int -partitionCheck(dialogMenuItem *selected) -{ - Device **devs = NULL; - - devs = deviceFind(selected->prompt, DEVICE_TYPE_DISK); - if (!devs || devs[0]->enabled == FALSE) - return FALSE; - return TRUE; -} - -int -diskPartitionEditor(dialogMenuItem *self) -{ - DMenu *menu; - Device **devs; - int i, cnt, devcnt; - - cnt = diskGetSelectCount(&devs); - devcnt = deviceCount(devs); - if (cnt == -1) { - msgConfirm("No disks found! Please verify that your disk controller is being\n" - "properly probed at boot time. See the Hardware Guide on the\n" - "Documentation menu for clues on diagnosing this type of problem."); - return DITEM_FAILURE; - } - else if (cnt) { - /* Some are already selected */ - for (i = 0; i < devcnt; i++) { - if (devs[i]->enabled) { - if (variable_get(VAR_NONINTERACTIVE)) - diskPartitionNonInteractive(devs[i]); - else - diskPartition(devs[i]); - } - } - } - else { - /* No disks are selected, fall-back case now */ - if (devcnt == 1) { - devs[0]->enabled = TRUE; - if (variable_get(VAR_NONINTERACTIVE)) - diskPartitionNonInteractive(devs[0]); - else - diskPartition(devs[0]); - return DITEM_SUCCESS; - } - else { - menu = deviceCreateMenu(&MenuDiskDevices, DEVICE_TYPE_DISK, partitionHook, partitionCheck); - if (!menu) { - msgConfirm("No devices suitable for installation found!\n\n" - "Please verify that your disk controller (and attached drives)\n" - "were detected properly. This can be done by pressing the\n" - "[Scroll Lock] key and using the Arrow keys to move back to\n" - "the boot messages. Press [Scroll Lock] again to return."); - return DITEM_FAILURE; - } - else { - i = dmenuOpenSimple(menu, FALSE) ? DITEM_SUCCESS : DITEM_FAILURE; - free(menu); - } - return i | DITEM_RESTORE; - } - } - return DITEM_SUCCESS; -} - -int -diskPartitionWrite(dialogMenuItem *self) -{ - Device **devs; - int i; - char *cp; - - devs = deviceFind(NULL, DEVICE_TYPE_DISK); - if (!devs) { - msgConfirm("Unable to find any disks to write to??"); - return DITEM_FAILURE; - } - if (isDebug()) - msgDebug("diskPartitionWrite: Examining %d devices\n", deviceCount(devs)); - cp = variable_get(DISK_PARTITIONED); - if (cp && !strcmp(cp, "written")) - return DITEM_SUCCESS; - - for (i = 0; devs[i]; i++) { - Chunk *c1; - Disk *d = (Disk *)devs[i]->private; - static u_char *boot1; -#ifndef __alpha__ - static u_char *boot2; -#endif - - if (!devs[i]->enabled) - continue; - -#ifdef __alpha__ - if (!boot1) boot1 = bootalloc("boot1"); - Set_Boot_Blocks(d, boot1, NULL); -#else - if (!boot1) boot1 = bootalloc("boot1"); - if (!boot2) boot2 = bootalloc("boot2"); - Set_Boot_Blocks(d, boot1, boot2); -#endif - - msgNotify("Writing partition information to drive %s", d->name); - if (!Fake && Write_Disk(d)) { - msgConfirm("ERROR: Unable to write data to disk %s!", d->name); - return DITEM_FAILURE; - } - - /* If we've been through here before, we don't need to do the rest */ - if (cp && !strcmp(cp, "written")) - return DITEM_SUCCESS; - - /* Now scan for bad blocks, if necessary */ - for (c1 = d->chunks->part; c1; c1 = c1->next) { - if (c1->flags & CHUNK_BAD144) { - int ret; - - msgNotify("Running bad block scan on slice %s", c1->name); - if (!Fake) { - ret = vsystem("bad144 -v /dev/r%s 1234", c1->name); - if (ret) - msgConfirm("Bad144 init on %s returned status of %d!", c1->name, ret); - ret = vsystem("bad144 -v -s /dev/r%s", c1->name); - if (ret) - msgConfirm("Bad144 scan on %s returned status of %d!", c1->name, ret); - } - } - } - } - /* Now it's not "yes", but "written" */ - variable_set2(DISK_PARTITIONED, "written"); - return DITEM_SUCCESS; -} - -/* Partition a disk based wholly on which variables are set */ -static void -diskPartitionNonInteractive(Device *dev) -{ - char *cp; - int i, sz, all_disk = 0; - u_char *mbrContents; - Disk *d = (Disk *)dev->private; - - record_chunks(d); - cp = variable_get(VAR_GEOMETRY); - if (cp) { - msgDebug("Setting geometry from script to: %s\n", cp); - d->bios_cyl = strtol(cp, &cp, 0); - d->bios_hd = strtol(cp + 1, &cp, 0); - d->bios_sect = strtol(cp + 1, 0, 0); - } - - cp = variable_get(VAR_PARTITION); - if (cp) { - if (!strcmp(cp, "free")) { - /* Do free disk space case */ - for (i = 0; chunk_info[i]; i++) { - /* If a chunk is at least 10MB in size, use it. */ - if (chunk_info[i]->type == unused && chunk_info[i]->size > (10 * ONE_MEG)) { - Create_Chunk(d, chunk_info[i]->offset, chunk_info[i]->size, freebsd, 3, - (chunk_info[i]->flags & CHUNK_ALIGN)); - variable_set2(DISK_PARTITIONED, "yes"); - break; - } - } - if (!chunk_info[i]) { - dialog_clear(); - msgConfirm("Unable to find any free space on this disk!"); - return; - } - } - else if (!strcmp(cp, "all")) { - /* Do all disk space case */ - msgDebug("Warning: Devoting all of disk %s to FreeBSD.\n", d->name); - - All_FreeBSD(d, FALSE); - } - else if (!strcmp(cp, "exclusive")) { - /* Do really-all-the-disk-space case */ - msgDebug("Warning: Devoting all of disk %s to FreeBSD.\n", d->name); - - All_FreeBSD(d, all_disk = TRUE); - } - else if ((sz = strtol(cp, &cp, 0))) { - /* Look for sz bytes free */ - if (*cp && toupper(*cp) == 'M') - sz *= ONE_MEG; - for (i = 0; chunk_info[i]; i++) { - /* If a chunk is at least sz MB, use it. */ - if (chunk_info[i]->type == unused && chunk_info[i]->size >= sz) { - Create_Chunk(d, chunk_info[i]->offset, sz, freebsd, 3, (chunk_info[i]->flags & CHUNK_ALIGN)); - variable_set2(DISK_PARTITIONED, "yes"); - break; - } - } - if (!chunk_info[i]) { - dialog_clear(); - msgConfirm("Unable to find %d free blocks on this disk!", sz); - return; - } - } - else if (!strcmp(cp, "existing")) { - /* Do existing FreeBSD case */ - for (i = 0; chunk_info[i]; i++) { - if (chunk_info[i]->type == freebsd) - break; - } - if (!chunk_info[i]) { - dialog_clear(); - msgConfirm("Unable to find any existing FreeBSD partitions on this disk!"); - return; - } - } - else { - dialog_clear(); - msgConfirm("`%s' is an invalid value for %s - is config file valid?", cp, VAR_PARTITION); - return; - } - if (!all_disk) { - mbrContents = getBootMgr(d->name); - Set_Boot_Mgr(d, mbrContents); - } - variable_set2(DISK_PARTITIONED, "yes"); - } -} diff --git a/usr.sbin/sade/dispatch.c b/usr.sbin/sade/dispatch.c deleted file mode 100644 index 5e1668a3da78..000000000000 --- a/usr.sbin/sade/dispatch.c +++ /dev/null @@ -1,436 +0,0 @@ -/* - * The new sysinstall program. - * - * This is probably the last program in the `sysinstall' line - the next - * generation being essentially a complete rewrite. - * - * $Id: dispatch.c,v 1.25 1998/07/18 09:41:58 jkh Exp $ - * - * Copyright (c) 1995 - * Jordan Hubbard. 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, - * verbatim and that no modifications are made prior to this - * point in the file. - * 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 JORDAN HUBBARD ``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 JORDAN HUBBARD OR HIS PETS 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, LIFE 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. - * - */ - -#include "sysinstall.h" -#include <ctype.h> -#include <errno.h> -#include <sys/signal.h> -#include <sys/fcntl.h> - -#include "list.h" - -static int dispatch_shutdown(dialogMenuItem *unused); -static int dispatch_systemExecute(dialogMenuItem *unused); -static int dispatch_msgConfirm(dialogMenuItem *unused); - -static struct _word { - char *name; - int (*handler)(dialogMenuItem *self); -} resWords[] = { - { "configAnonFTP", configAnonFTP }, - { "configRouter", configRouter }, - { "configNFSServer", configNFSServer }, - { "configNTP", configNTP }, - { "configPCNFSD", configPCNFSD }, - { "configPackages", configPackages }, - { "configRegister", configRegister }, - { "configUsers", configUsers }, - { "configXEnvironment", configXEnvironment }, - { "diskPartitionEditor", diskPartitionEditor }, - { "diskPartitionWrite", diskPartitionWrite }, - { "diskLabelEditor", diskLabelEditor }, - { "diskLabelCommit", diskLabelCommit }, - { "distReset", distReset }, - { "distSetCustom", distSetCustom }, - { "distSetDeveloper", distSetDeveloper }, - { "distSetXDeveloper", distSetXDeveloper }, - { "distSetKernDeveloper", distSetKernDeveloper }, - { "distSetUser", distSetUser }, - { "distSetXUser", distSetXUser }, - { "distSetMinimum", distSetMinimum }, - { "distSetEverything", distSetEverything }, - { "distSetDES", distSetDES }, - { "distSetSrc", distSetSrc }, - { "distSetXF86", distSetXF86 }, - { "distExtractAll", distExtractAll }, - { "docBrowser", docBrowser }, - { "docShowDocument", docShowDocument }, - { "installCommit", installCommit }, - { "installExpress", installExpress }, - { "installNovice", installNovice }, - { "installUpgrade", installUpgrade }, - { "installFixupBin", installFixupBin }, - { "installFixupXFree", installFixupXFree }, - { "installFixitHoloShell", installFixitHoloShell }, - { "installFixitCDROM", installFixitCDROM }, - { "installFixitFloppy", installFixitFloppy }, - { "installFilesystems", installFilesystems }, - { "installVarDefaults", installVarDefaults }, - { "loadConfig", dispatch_load_file }, - { "loadFloppyConfig", dispatch_load_floppy }, - { "mediaSetCDROM", mediaSetCDROM }, - { "mediaSetFloppy", mediaSetFloppy }, - { "mediaSetDOS", mediaSetDOS }, - { "mediaSetTape", mediaSetTape }, - { "mediaSetFTP", mediaSetFTP }, - { "mediaSetFTPActive", mediaSetFTPActive }, - { "mediaSetFTPPassive", mediaSetFTPPassive }, - { "mediaSetUFS", mediaSetUFS }, - { "mediaSetNFS", mediaSetNFS }, - { "mediaSetFTPUserPass", mediaSetFTPUserPass }, - { "mediaSetCPIOVerbosity", mediaSetCPIOVerbosity }, - { "mediaGetType", mediaGetType }, - { "msgConfirm", dispatch_msgConfirm }, - { "optionsEditor", optionsEditor }, - { "register", configRegister }, /* Alias */ - { "packageAdd", packageAdd }, - { "addGroup", userAddGroup }, - { "addUser", userAddUser }, - { "shutdown", dispatch_shutdown }, - { "system", dispatch_systemExecute }, - { "dumpVariables", dump_variables }, - { "tcpMenuSelect", tcpMenuSelect }, - { NULL, NULL }, -}; - -/* - * Helper routines for buffering data. - * - * We read an entire configuration into memory before executing it - * so that we are truely standalone and can do things like nuke the - * file or disk we're working on. - */ - -typedef struct command_buffer_ { - qelement queue; - char * string; -} command_buffer; - -static void -dispatch_free_command(command_buffer *item) -{ - REMQUE(item); - free(item->string); - free(item); -} - -static void -dispatch_free_all(qelement *head) -{ - command_buffer *item; - - while (!EMPTYQUE(*head)) { - item = (command_buffer *) head->q_forw; - dispatch_free_command(item); - } -} - -static command_buffer * -dispatch_add_command(qelement *head, char *string) -{ - command_buffer *new; - - new = malloc(sizeof(command_buffer)); - - if (!new) - return NULL; - - new->string = strdup(string); - INSQUEUE(new, head->q_back); - - return new; -} - -/* - * Command processing - */ - -/* Just convenience */ -static int -dispatch_shutdown(dialogMenuItem *unused) -{ - systemShutdown(0); - return DITEM_FAILURE; -} - -static int -dispatch_systemExecute(dialogMenuItem *unused) -{ - char *cmd = variable_get(VAR_COMMAND); - - if (cmd) - return systemExecute(cmd) ? DITEM_FAILURE : DITEM_SUCCESS; - else - msgDebug("_systemExecute: No command passed in `command' variable.\n"); - return DITEM_FAILURE; -} - -static int -dispatch_msgConfirm(dialogMenuItem *unused) -{ - char *msg = variable_get(VAR_COMMAND); - - if (msg) { - msgConfirm(msg); - return DITEM_SUCCESS; - } - - msgDebug("_msgConfirm: No message passed in `command' variable.\n"); - return DITEM_FAILURE; -} - -static int -call_possible_resword(char *name, dialogMenuItem *value, int *status) -{ - int i, rval; - - rval = 0; - for (i = 0; resWords[i].name; i++) { - if (!strcmp(name, resWords[i].name)) { - *status = resWords[i].handler(value); - rval = 1; - break; - } - } - return rval; -} - -/* For a given string, call it or spit out an undefined command diagnostic */ -int -dispatchCommand(char *str) -{ - int i; - char *cp; - - if (!str || !*str) { - msgConfirm("Null or zero-length string passed to dispatchCommand"); - return DITEM_FAILURE; - } - /* If it's got a newline, trim it */ - if ((cp = index(str, '\n')) != NULL) - *cp = '\0'; - - /* If it's got a `=' sign in there, assume it's a variable setting */ - if (index(str, '=')) { - if (isDebug()) - msgDebug("dispatch: setting variable `%s'\n", str); - variable_set(str); - i = DITEM_SUCCESS; - } - else { - /* A command might be a pathname if it's encoded in argv[0], which - we also support */ - if ((cp = rindex(str, '/')) != NULL) - str = cp + 1; - if (isDebug()) - msgDebug("dispatch: calling resword `%s'\n", str); - if (!call_possible_resword(str, NULL, &i)) { - msgNotify("Warning: No such command ``%s''", str); - i = DITEM_FAILURE; - } - } - return i; -} - - -/* - * File processing - */ - -static qelement * -dispatch_load_fp(FILE *fp) -{ - qelement *head; - char buf[BUFSIZ], *cp; - - head = malloc(sizeof(qelement)); - - if (!head) - return NULL; - - INITQUE(*head); - - while (fgets(buf, sizeof buf, fp)) { - - if ((cp = strchr(buf, '\n')) != NULL) - *cp = '\0'; - if (*buf == '\0' || *buf == '#') - continue; - - if (!dispatch_add_command(head, buf)) - return NULL; - } - - return head; -} - -static int -dispatch_execute(qelement *head) -{ - int result = DITEM_SUCCESS; - command_buffer *item; - char *old_interactive; - - if (!head) - return result | DITEM_FAILURE; - - old_interactive = variable_get(VAR_NONINTERACTIVE); - if (old_interactive) - old_interactive = strdup(old_interactive); /* save copy */ - - /* Hint to others that we're running from a script, should they care */ - variable_set2(VAR_NONINTERACTIVE, "yes"); - - while (!EMPTYQUE(*head)) { - item = (command_buffer *) head->q_forw; - - if (DITEM_STATUS(dispatchCommand(item->string)) != DITEM_SUCCESS) { - /* - * Allow a user to prefix a command with "noError" to cause - * us to ignore any errors for that one command. - */ - if (variable_get(VAR_NO_ERROR)) - variable_unset(VAR_NO_ERROR); - else { - msgConfirm("Command `%s' failed - rest of script aborted.\n", - item->string); - result |= DITEM_FAILURE; - break; - } - } - dispatch_free_command(item); - } - - dispatch_free_all(head); - - if (!old_interactive) - variable_unset(VAR_NONINTERACTIVE); - else { - variable_set2(VAR_NONINTERACTIVE, old_interactive); - free(old_interactive); - } - - return result; -} - -int -dispatch_load_file_int(int quiet) -{ - FILE *fp; - char *cp; - int i; - qelement *list; - - static const char *names[] = { - "install.cfg", - "/stand/install.cfg", - "/tmp/install.cfg", - NULL - }; - - fp = NULL; - cp = variable_get(VAR_CONFIG_FILE); - if (!cp) { - for (i = 0; names[i]; i++) - if ((fp = fopen(names[i], "r")) != NULL) - break; - } else - fp = fopen(cp, "r"); - - if (!fp) { - if (!quiet) - msgConfirm("Unable to open %s: %s", cp, strerror(errno)); - return DITEM_FAILURE; - } - - list = dispatch_load_fp(fp); - fclose(fp); - - return dispatch_execute(list); -} - -int -dispatch_load_file(dialogMenuItem *self) -{ - return dispatch_load_file_int(FALSE); -} - -int -dispatch_load_floppy(dialogMenuItem *self) -{ - int what = DITEM_RESTORE | DITEM_SUCCESS; - extern char *distWanted; - char *cp; - FILE *fp; - qelement *list; - - mediaClose(); - dialog_clear_norefresh(); - - cp = variable_get_value(VAR_INSTALL_CFG, - "Specify the name of a configuration file\n" - "residing on a MSDOS or UFS floppy."); - if (!cp || !*cp) { - variable_unset(VAR_INSTALL_CFG); - what |= DITEM_FAILURE; - return what; - } - - distWanted = cp; - /* Try to open the floppy drive */ - if (DITEM_STATUS(mediaSetFloppy(NULL)) == DITEM_FAILURE) { - msgConfirm("Unable to set media device to floppy."); - what |= DITEM_FAILURE; - mediaClose(); - return what; - } - - if (!mediaDevice->init(mediaDevice)) { - msgConfirm("Unable to mount floppy filesystem."); - what |= DITEM_FAILURE; - mediaClose(); - return what; - } - - fp = mediaDevice->get(mediaDevice, cp, TRUE); - if (fp) { - list = dispatch_load_fp(fp); - fclose(fp); - mediaClose(); - - what |= dispatch_execute(list); - } - else { - if (!variable_get(VAR_NO_ERROR)) - msgConfirm("Configuration file '%s' not found.", cp); - variable_unset(VAR_INSTALL_CFG); - what |= DITEM_FAILURE; - mediaClose(); - } - - return what; -} - diff --git a/usr.sbin/sade/dmenu.c b/usr.sbin/sade/dmenu.c deleted file mode 100644 index 11c369bdbdfa..000000000000 --- a/usr.sbin/sade/dmenu.c +++ /dev/null @@ -1,308 +0,0 @@ -/* - * The new sysinstall program. - * - * This is probably the last attempt in the `sysinstall' line, the next - * generation being slated for what's essentially a complete rewrite. - * - * $Id: dmenu.c,v 1.36 1998/03/10 17:24:07 jkh Exp $ - * - * Copyright (c) 1995 - * Jordan Hubbard. 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, - * verbatim and that no modifications are made prior to this - * point in the file. - * 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 JORDAN HUBBARD ``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 JORDAN HUBBARD OR HIS PETS 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, LIFE 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. - * - */ - -#include "sysinstall.h" -#include <errno.h> - -#define MAX_MENU 15 - -static Boolean exited; - -int -dmenuDisplayFile(dialogMenuItem *tmp) -{ - systemDisplayHelp((char *)tmp->data); - return DITEM_SUCCESS | DITEM_RESTORE; -} - -int -dmenuSubmenu(dialogMenuItem *tmp) -{ - return (dmenuOpenSimple((DMenu *)(tmp->data), FALSE) ? DITEM_SUCCESS : DITEM_FAILURE) | - DITEM_RESTORE; -} - -int -dmenuSystemCommand(dialogMenuItem *self) -{ - WINDOW *w = NULL; /* Keep lint happy */ - - /* If aux is set, the command is known not to produce any screen-spoiling output */ - if (!self->aux) - w = savescr(); - systemExecute((char *)self->data); - if (!self->aux) - restorescr(w); - return DITEM_SUCCESS; -} - -int -dmenuSystemCommandBox(dialogMenuItem *tmp) -{ - use_helpfile(NULL); - use_helpline("Select OK to dismiss this dialog"); - dialog_prgbox(tmp->title, (char *)tmp->data, 22, 76, 1, 1); - return DITEM_SUCCESS | DITEM_RESTORE; -} - -int -dmenuExit(dialogMenuItem *tmp) -{ - exited = TRUE; - return DITEM_LEAVE_MENU; -} - -int -dmenuSetVariable(dialogMenuItem *tmp) -{ - variable_set((char *)tmp->data); - return DITEM_SUCCESS; -} - -int -dmenuSetVariables(dialogMenuItem *tmp) -{ - char *cp1, *cp2; - char *copy = strdup((char *)tmp->data); - - for (cp1 = copy; cp1 != NULL;) { - cp2 = index(cp1, ','); - if (cp2 != NULL) *cp2++ = '\0'; - variable_set(cp1); - cp1 = cp2; - } - free(copy); - return DITEM_SUCCESS; -} - -int -dmenuSetKmapVariable(dialogMenuItem *tmp) -{ - char *lang; - int err; - - variable_set((char *)tmp->data); - lang = variable_get(VAR_KEYMAP); - if (lang != NULL) - { - err = loadKeymap(lang); - if (err == -1) - msgConfirm("No appropriate keyboard map found, sorry."); - else if (err == -2) - msgConfirm("Error installing keyboard map, errno = %d.", errno); - } - return DITEM_SUCCESS; -} - -int -dmenuToggleVariable(dialogMenuItem *tmp) -{ - char *var; - - if (!(var = (char *)tmp->data)) { - msgConfirm("Incorrect data field for `%s'!", tmp->title); - return DITEM_FAILURE; - } - if (!variable_check(var)) - variable_set(var); - else - variable_unset(var); - return DITEM_SUCCESS; -} - -int -dmenuISetVariable(dialogMenuItem *tmp) -{ - char *ans, *var; - WINDOW *w = NULL; /* Keep lint happy */ - - if (!(var = (char *)tmp->data)) { - msgConfirm("Incorrect data field for `%s'!", tmp->title); - return DITEM_FAILURE; - } - w = savescr(); - ans = msgGetInput(variable_get(var), tmp->title); - restorescr(w); - if (!ans) - return DITEM_FAILURE; - else if (!*ans) - variable_unset(var); - else - variable_set2(var, ans); - return DITEM_SUCCESS; -} - -int -dmenuSetFlag(dialogMenuItem *tmp) -{ - if (*((unsigned int *)tmp->data) & tmp->aux) - *((unsigned int *)tmp->data) &= ~tmp->aux; - else - *((unsigned int *)tmp->data) |= tmp->aux; - return DITEM_SUCCESS; -} - -int -dmenuSetValue(dialogMenuItem *tmp) -{ - *((unsigned int *)tmp->data) = tmp->aux; - return DITEM_SUCCESS; -} - -/* Traverse menu but give user no control over positioning */ -Boolean -dmenuOpenSimple(DMenu *menu, Boolean buttons) -{ - int choice, scroll, curr, max; - - choice = scroll = curr = max = 0; - return dmenuOpen(menu, &choice, &scroll, &curr, &max, buttons); -} - -/* Work functions for the state hook */ -int -dmenuFlagCheck(dialogMenuItem *item) -{ - return (*((unsigned int *)item->data) & item->aux); -} - -int -dmenuVarCheck(dialogMenuItem *item) -{ - char *w; - - w = (char *)item->aux; - if (!w) - w = (char *)item->data; - return variable_check(w); -} - -int -dmenuVarsCheck(dialogMenuItem *item) -{ - int res, init; - char *w, *cp1, *cp2; - char *copy; - - w = (char *)item->aux; - if (!w) - w = (char *)item->data; - if (!w) - return FALSE; - - copy = strdup(w); - res = TRUE; - init = FALSE; - for (cp1 = copy; cp1 != NULL;) { - init = TRUE; - cp2 = index(cp1, ','); - if (cp2 != NULL) - *cp2++ = '\0'; - res = res && variable_check(cp1); - cp1 = cp2; - } - free(copy); - return res && init; -} - -int -dmenuRadioCheck(dialogMenuItem *item) -{ - return (*((unsigned int *)item->data) == item->aux); -} - -static int -menu_height(DMenu *menu, int n) -{ - int max; - char *t; - - max = MAX_MENU; - if (StatusLine > 24) - max += StatusLine - 24; - for (t = menu->prompt; *t; t++) { - if (*t == '\n') - --max; - } - return n > max ? max : n; -} - -/* Traverse over an internal menu */ -Boolean -dmenuOpen(DMenu *menu, int *choice, int *scroll, int *curr, int *max, Boolean buttons) -{ - int n, rval = 0; - dialogMenuItem *items; - - items = menu->items; - if (buttons) - items += 2; - /* Count up all the items */ - for (n = 0; items[n].title; n++); - - while (1) { - char buf[FILENAME_MAX]; - - /* Any helpful hints, put 'em up! */ - use_helpline(menu->helpline); - use_helpfile(systemHelpFile(menu->helpfile, buf)); - - /* Pop up that dialog! */ - dialog_clear_norefresh(); - if (menu->type & DMENU_NORMAL_TYPE) - rval = dialog_menu((u_char *)menu->title, (u_char *)menu->prompt, -1, -1, - menu_height(menu, n), -n, items, (char *)buttons, choice, scroll); - - else if (menu->type & DMENU_RADIO_TYPE) - rval = dialog_radiolist((u_char *)menu->title, (u_char *)menu->prompt, -1, -1, - menu_height(menu, n), -n, items, (char *)buttons); - - else if (menu->type & DMENU_CHECKLIST_TYPE) - rval = dialog_checklist((u_char *)menu->title, (u_char *)menu->prompt, -1, -1, - menu_height(menu, n), -n, items, (char *)buttons); - else - msgFatal("Menu: `%s' is of an unknown type\n", menu->title); - clearok(stdscr, TRUE); - if (exited) { - exited = FALSE; - return TRUE; - } - else if (rval) - return FALSE; - else if (menu->type & DMENU_SELECTION_RETURNS) - return TRUE; - } -} diff --git a/usr.sbin/sade/globals.c b/usr.sbin/sade/globals.c deleted file mode 100644 index 72aecb1c88e3..000000000000 --- a/usr.sbin/sade/globals.c +++ /dev/null @@ -1,71 +0,0 @@ -/* - * The new sysinstall program. - * - * This is probably the last program in the `sysinstall' line - the next - * generation being essentially a complete rewrite. - * - * $Id: globals.c,v 1.18 1997/02/22 14:11:43 peter Exp $ - * - * Copyright (c) 1995 - * Jordan Hubbard. 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, - * verbatim and that no modifications are made prior to this - * point in the file. - * 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 JORDAN HUBBARD ``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 JORDAN HUBBARD OR HIS PETS 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, LIFE 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. - * - */ - -#include "sysinstall.h" - -/* - * Various global variables and an initialization hook to set them to - * whatever values we feel are appropriate. - */ - -int DebugFD; /* Where diagnostic output goes */ -Boolean Fake; /* Only pretend to be useful */ -Boolean RunningAsInit; /* Are we running as init? */ -Boolean DialogActive; /* Is libdialog initialized? */ -Boolean ColorDisplay; /* Are we on a color display? */ -Boolean OnVTY; /* Are we on a VTY? */ -Variable *VarHead; /* The head of the variable chain */ -Device *mediaDevice; /* Where we're installing from */ -int BootMgr; /* Which boot manager we're using */ -int StatusLine; /* Where to stick our status messages */ -jmp_buf BailOut; /* Beam me up, scotty! The natives are pissed! */ - -/* - * Yes, I know some of these are already automatically initialized as - * globals. I simply find it clearer to set everything explicitly. - */ -void -globalsInit(void) -{ - DebugFD = -1; - ColorDisplay = FALSE; - Fake = FALSE; - OnVTY = FALSE; - DialogActive = FALSE; - VarHead = NULL; - mediaDevice = NULL; - RunningAsInit = FALSE; -} diff --git a/usr.sbin/sade/help/partition.hlp b/usr.sbin/sade/help/partition.hlp deleted file mode 100644 index 37520bfbaefe..000000000000 --- a/usr.sbin/sade/help/partition.hlp +++ /dev/null @@ -1,144 +0,0 @@ -This is the FreeBSD DiskLabel Editor. - -NOTE: If you're entering this editor from the update procedure then -you probably shouldn't (C)reate anything at all but rather use only -the (M)ount command to check and mount existing partitions for -upgrading. - -If you would like the label editor to do most of the following for -you, simply type `A' for automatic partitioning of the disk. - -If you wish to create partitions manually you may do so by moving the -highlighted selection bar with the arrow keys over the FreeBSD -partition(s) displayed at the top of the screen. Typing (C)reate -while a partition with available free space is selected will allow you -to create a BSD partition inside of it using some or all of its -available space. - -Typing (M)ount over an existing partition entry (displayed in the -middle of the screen) will allow you to set a mount point for it -without initializing it. If you want it initialized, use the (T)oggle -command to flip the Newfs flag. When Newfs is set to "Y", the -filesystem in question will be ERASED and rebuilt from scratch! - - -You should use this editor to create at least the following -filesystems: - - Name Purpose Min Size? Optional? - ---- ------- --------- --------- - / Root filesystem 20MB No - swap Swap space 2 * MEM No - /usr System & user files 80MB or more Yes - -Note: If you do not create a /usr filesystem then your / filesystem -will need to be bigger - at least 100MB. This is not recommended as -any media errors that may occur during disk I/O to user files will -corrupt the filesystem containing vital system files as well. It is -for this reason that / is generally kept on its own filesystem, where -it should be considered essentially "read only" in your administration -of it. - -Swap space is a little tricker, and the rule of "2 * MEM" is simply a -best-guess approximation and not necessarily accurate for your -intended usage of the system. If you intend to use the system heavily -in a server or multi-user application, you may be well advised to -increase this size. You may also create swap space on multiple drives -for a larger "total" swap and this is, in fact, recommended if you -have multiple, fast drives for which such load-balancing can only help -overall I/O performance. - -The /usr filesystem should be sized according to what kind of -distributions you're trying to load and how many packages you intend -to install in locations like /usr/local. You can also make /usr/local -a separate filesystem if you don't want to risk filling up your /usr -by mistake. - -Another useful filesystem to create is /var, which contains mail, news -printer spool files and other temporary items. It is a popular -candidate for a separate partition and should be sized according to -your estimates of the amount of mail, news or spooled print jobs that -may be stored there. - -WARNING: If you do not create a separate filesystem for /var, space -for such files will be allocated out of the root (/) filesystem -instead. You may therefore wish to make the / partition bigger if you -expect a lot of mail or news and do not want to make /var its own -partition. - -If you're new to this installation, you might also want to read the -following explanation of how FreeBSD's new "slice" paradigm for -looking at disk storage works: - - -In FreeBSD's new system, a device name can be broken up into up to 3 -parts. Take a typical name like ``/dev/da0s1a'': - - The first three characters represent the drive name. If we had - a system with two SCSI drives on it then we'd see /dev/da0 and - /dev/da1 as the device entries representing the entire drives. - - Next you have the "slice" (or "FDISK Partition") number, - as seen in the Partition Editor. Assuming that our da0 - contained two slices, a FreeBSD slice and a DOS slice, that - would give us /dev/da0s1 and /dev/da0s2 as device entries pointing - to the entire slices. - - Next, if a slice is a FreeBSD slice, you can have a number of - (confusingly named) "partitions" inside of it. - - These partitions are where various filesystems or swap areas live, - and using our hypothetical two-SCSI-disk machine again, we might - have something like the following layout on da0: - - Name Mountpoint - ---- ---------- - da0s1a / - da0s1b <swap space> - da0s1e /usr - - Because of historical convention, there is also a short-cut, - or "compatibility slice", that is maintained for easy access - to the *first* FreeBSD slice on a disk. This gives some - backwards compatibility to utilities that still may not know - how to deal with the new slice scheme. - - The compatibility slice names for our filesystem above would - also look like: - - Name Mountpoint - ---- ---------- - da0a / - da0b <swap space> - da0e /usr - - Again, let it be noted: FreeBSD automatically maps the - compatibility slice to the first FreeBSD slice it finds - (in this case, da0s1). You may have multiple FreeBSD slices on a - drive, but only the first one will be mapped to the compatibility - slice! - - The compatibility slice has essentially been phased out, but - it's important to be aware of when looking at or upgrading - older systems. - -Once you understand all this, then the purpose of the label editor -becomes fairly clear: You're carving up the FreeBSD slices displayed -at the top of the screen into smaller pieces, which are displayed in -the middle of the screen, and then assigning FreeBSD file system names -(mount points) to them. - -You can also use the label editor to mount existing partitions/slices -into your filesystem hierarchy, as is frequently done for DOS FAT -slices. For FreeBSD partitions, you can also toggle the "newfs" state -so that the partitions are either (re)created from scratch or simply -checked and mounted (the contents are preserved). - -When you're done, type `Q' to exit. - -No actual changes will be made to the disk until you (C)ommit from the -Install menu or (W)rite directly from this one. You're working with -what is essentially a copy of the disk label(s), both here and in the -FDISK Partition Editor, and the actual on-disk labels won't be -affected by any changes you make until you explicitly say so. - diff --git a/usr.sbin/sade/help/slice.hlp b/usr.sbin/sade/help/slice.hlp deleted file mode 100644 index 33280a4349b9..000000000000 --- a/usr.sbin/sade/help/slice.hlp +++ /dev/null @@ -1,59 +0,0 @@ -This is the Main Slice (``FDISK'' or PC-style Partition) Editor. - -Possible commands are printed at the bottom and the Master Boot Record -contents are shown at the top. You can move up and down with the -arrow keys and (C)reate a new slice whenever the highlighted -selection bar is over a slice whose type is marked as "unused." - -You are expected to leave this screen with at least one slice -marked "FreeBSD." Note that unlike Linux, you don't need to create -multiple FreeBSD FDISK partition entries for different things like -swap, file systems, etc. The usual convention is to create ONE -FreeBSD slice (FDISK partition) per drive and then subsection this slice -into swap and file systems with the Label editor. - -No actual changes will be made to the disk until you (C)ommit from the -Install menu or use the (W)rite option here! You're working with what -is essentially a copy of the disk label(s), both here and in the Label -Editor. - -If you want to use the entire disk for FreeBSD, type `A'. You'll be -asked whether or not you wish to keep the disk (potentially) compatible -with other operating systems, i.e. the information in the FDISK table -should be kept valid. If you select the default of `Yes', slices will be -aligned to fictitious cylinder boundaries and space will be reserved -in front of the FreeBSD slice for a [future] possible boot manager. - -For the truly dedicated disk case, you can select `No' at the -compatibility prompt. In that case, all BIOS geometry considerations -will no longer be in effect and you can safely ignore any -``The detected geometry is invalid'' warning messages you may later -see. It is also not necessary in this case to set a slice bootable -or install an MBR boot manager as both things are then irrelevant. - -The FreeBSD slice will start at absolute sector 0 of the disk (so that -FreeBSD's disk label is identical to the Master Boot Record) and -extend to the very last sector of the disk medium. Needless to say, -such a disk cannot have any sort of a boot manager, `disk manager', -or anything else that has to interact with the BIOS. This option is -therefore only considered safe for SCSI disks and most IDE disks and -is primarily intended for people who are going to set up a dedicated -FreeBSD server or workstation, not a typical `home PC'. - -The flags field has the following legend: - - '=' -- This slice is properly aligned. - '>' -- This slice doesn't end before cylinder 1024 - 'R' -- This slice contains the root (/) filesystem - 'B' -- Slice employs BAD144 bad-spot handling - 'C' -- This is the FreeBSD 2.0-compatibility slice (default) - 'A' -- This slice is marked active. - -If you select a slice for Bad144 handling, it will be scanned -for bad blocks before any new filesystems are made on it. - -If no slice is marked Active, you will need to either install -a Boot Manager (the option for which will be presented later in the -installation) or set one Active before leaving this screen. - -To leave the slice editor, type `Q'. diff --git a/usr.sbin/sade/install.c b/usr.sbin/sade/install.c deleted file mode 100644 index fc1f42ede8f4..000000000000 --- a/usr.sbin/sade/install.c +++ /dev/null @@ -1,1119 +0,0 @@ -/* - * The new sysinstall program. - * - * This is probably the last program in the `sysinstall' line - the next - * generation being essentially a complete rewrite. - * - * $Id: install.c,v 1.222 1999/01/20 11:56:39 jkh Exp $ - * - * Copyright (c) 1995 - * Jordan Hubbard. 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, - * verbatim and that no modifications are made prior to this - * point in the file. - * 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 JORDAN HUBBARD ``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 JORDAN HUBBARD OR HIS PETS 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, LIFE 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. - * - */ - -#include "sysinstall.h" -#include <ctype.h> -#include <sys/disklabel.h> -#include <sys/errno.h> -#include <sys/ioctl.h> -#include <sys/fcntl.h> -#include <sys/wait.h> -#include <sys/param.h> -#define MSDOSFS -#include <sys/mount.h> -#include <ufs/ufs/ufsmount.h> -#include <msdosfs/msdosfsmount.h> -#undef MSDOSFS -#include <sys/stat.h> -#include <sys/sysctl.h> -#include <unistd.h> - -static void create_termcap(void); -static void fixit_common(void); - -#define TERMCAP_FILE "/usr/share/misc/termcap" - -static void installConfigure(void); - -Boolean -checkLabels(Boolean whinge, Chunk **rdev, Chunk **sdev, Chunk **udev, Chunk **vdev) -{ - Device **devs; - Boolean status; - Disk *disk; - Chunk *c1, *c2, *rootdev, *swapdev, *usrdev, *vardev; - int i; - - /* Don't allow whinging if noWarn is set */ - if (variable_get(VAR_NO_WARN)) - whinge = FALSE; - - status = TRUE; - *rdev = *sdev = *udev = *vdev = rootdev = swapdev = usrdev = vardev = NULL; - - /* We don't need to worry about root/usr/swap if we're already multiuser */ - if (!RunningAsInit) - return status; - - devs = deviceFind(NULL, DEVICE_TYPE_DISK); - /* First verify that we have a root device */ - for (i = 0; devs[i]; i++) { - if (!devs[i]->enabled) - continue; - disk = (Disk *)devs[i]->private; - msgDebug("Scanning disk %s for root filesystem\n", disk->name); - if (!disk->chunks) - msgFatal("No chunk list found for %s!", disk->name); - for (c1 = disk->chunks->part; c1; c1 = c1->next) { - if (c1->type == freebsd) { - for (c2 = c1->part; c2; c2 = c2->next) { - if (c2->type == part && c2->subtype != FS_SWAP && c2->private_data) { - if (!strcmp(((PartInfo *)c2->private_data)->mountpoint, "/")) { - if (rootdev) { - if (whinge) - msgConfirm("WARNING: You have more than one root device set?!\n" - "Using the first one found."); - continue; - } - else { - rootdev = c2; - if (isDebug()) - msgDebug("Found rootdev at %s!\n", rootdev->name); - } - } - else if (!strcmp(((PartInfo *)c2->private_data)->mountpoint, "/usr")) { - if (usrdev) { - if (whinge) - msgConfirm("WARNING: You have more than one /usr filesystem.\n" - "Using the first one found."); - continue; - } - else { - usrdev = c2; - if (isDebug()) - msgDebug("Found usrdev at %s!\n", usrdev->name); - } - } - else if (!strcmp(((PartInfo *)c2->private_data)->mountpoint, "/var")) { - if (vardev) { - if (whinge) - msgConfirm("WARNING: You have more than one /var filesystem.\n" - "Using the first one found."); - continue; - } - else { - vardev = c2; - if (isDebug()) - msgDebug("Found vardev at %s!\n", vardev->name); - } - } - } - } - } - } - } - - /* Now check for swap devices */ - for (i = 0; devs[i]; i++) { - if (!devs[i]->enabled) - continue; - disk = (Disk *)devs[i]->private; - msgDebug("Scanning disk %s for swap partitions\n", disk->name); - if (!disk->chunks) - msgFatal("No chunk list found for %s!", disk->name); - for (c1 = disk->chunks->part; c1; c1 = c1->next) { - if (c1->type == freebsd) { - for (c2 = c1->part; c2; c2 = c2->next) { - if (c2->type == part && c2->subtype == FS_SWAP && !swapdev) { - swapdev = c2; - if (isDebug()) - msgDebug("Found swapdev at %s!\n", swapdev->name); - break; - } - } - } - } - } - - /* Copy our values over */ - *rdev = rootdev; - *sdev = swapdev; - *udev = usrdev; - *vdev = vardev; - - if (!rootdev && whinge) { - msgConfirm("No root device found - you must label a partition as /\n" - "in the label editor."); - status = FALSE; - } - if (!swapdev && whinge) { - msgConfirm("No swap devices found - you must create at least one\n" - "swap partition."); - status = FALSE; - } - if (!usrdev && whinge && !variable_get(VAR_NO_USR)) { - msgConfirm("WARNING: No /usr filesystem found. This is not technically\n" - "an error if your root filesystem is big enough (or you later\n" - "intend to mount your /usr filesystem over NFS), but it may otherwise\n" - "cause you trouble if you're not exactly sure what you are doing!"); - } - if (!vardev && whinge && variable_cmp(SYSTEM_STATE, "upgrade")) { - msgConfirm("WARNING: No /var filesystem found. This is not technically\n" - "an error if your root filesystem is big enough (or you later\n" - "intend to link /var to someplace else), but it may otherwise\n" - "cause your root filesystem to fill up if you receive lots of mail\n" - "or edit large temporary files."); - } - return status; -} - -static int -installInitial(void) -{ - static Boolean alreadyDone = FALSE; - int status = DITEM_SUCCESS; - - if (alreadyDone) - return DITEM_SUCCESS; - - if (!variable_get(DISK_LABELLED)) { - msgConfirm("You need to assign disk labels before you can proceed with\n" - "the installation."); - return DITEM_FAILURE; - } - /* If it's labelled, assume it's also partitioned */ - if (!variable_get(DISK_PARTITIONED)) - variable_set2(DISK_PARTITIONED, "yes"); - - /* If we refuse to proceed, bail. */ - dialog_clear_norefresh(); - if (!variable_get(VAR_NO_WARN)) - if (msgYesNo( - "Last Chance! Are you SURE you want continue the installation?\n\n" - "If you're running this on a disk with data you wish to save\n" - "then WE STRONGLY ENCOURAGE YOU TO MAKE PROPER BACKUPS before\n" - "proceeding!\n\n" - "We can take no responsibility for lost disk contents!") != 0) - return DITEM_FAILURE | DITEM_RESTORE; - - if (DITEM_STATUS(diskLabelCommit(NULL)) != DITEM_SUCCESS) { - msgConfirm("Couldn't make filesystems properly. Aborting."); - return DITEM_FAILURE; - } - - if (!copySelf()) { - msgConfirm("installInitial: Couldn't clone the boot floppy onto the\n" - "root file system. Aborting!"); - return DITEM_FAILURE; - } - - if (chroot("/mnt") == -1) { - msgConfirm("installInitial: Unable to chroot to %s - this is bad!", - "/mnt"); - return DITEM_FAILURE; - } - - chdir("/"); - variable_set2(RUNNING_ON_ROOT, "yes"); - - /* Configure various files in /etc */ - if (DITEM_STATUS(configResolv(NULL)) == DITEM_FAILURE) - status = DITEM_FAILURE; - if (DITEM_STATUS(configFstab(NULL)) == DITEM_FAILURE) - status = DITEM_FAILURE; - - /* stick a helpful shell over on the 4th VTY */ - systemCreateHoloshell(); - - alreadyDone = TRUE; - return status; -} - -int -installFixitHoloShell(dialogMenuItem *self) -{ - systemCreateHoloshell(); - return DITEM_SUCCESS; -} - -int -installFixitCDROM(dialogMenuItem *self) -{ - struct stat sb; - - if (!RunningAsInit) - return DITEM_SUCCESS; - - variable_set2(SYSTEM_STATE, "fixit"); - (void)unlink("/mnt2"); - (void)rmdir("/mnt2"); - - while (1) { - msgConfirm("Please insert the second FreeBSD CDROM and press return"); - if (DITEM_STATUS(mediaSetCDROM(NULL)) != DITEM_SUCCESS || !mediaDevice || !mediaDevice->init(mediaDevice)) { - /* If we can't initialize it, it's probably not a FreeBSD CDROM so punt on it */ - if (mediaDevice) { - mediaDevice->shutdown(mediaDevice); - mediaDevice = NULL; - } - if (msgYesNo("Unable to mount the CDROM - do you want to try again?") != 0) - return DITEM_FAILURE; - } - else - break; - } - - /* Since the fixit code expects everything to be in /mnt2, and the CDROM mounting stuff /dist, do - * a little kludge dance here.. - */ - if (symlink("/dist", "/mnt2")) { - msgConfirm("Unable to symlink /mnt2 to the CDROM mount point. Please report this\n" - "unexpected failure to freebsd-bugs@FreeBSD.org."); - return DITEM_FAILURE; - } - - /* - * If /tmp points to /mnt2/tmp from a previous fixit floppy session, it's - * not very good for us if we point it to the CDROM now. Rather make it - * a directory in the root MFS then. Experienced admins will still be - * able to mount their disk's /tmp over this if they need. - */ - if (lstat("/tmp", &sb) == 0 && (sb.st_mode & S_IFMT) == S_IFLNK) - (void)unlink("/tmp"); - Mkdir("/tmp"); - - /* - * Since setuid binaries ignore LD_LIBRARY_PATH, we indeed need the - * ld.so.hints file. Fortunately, it's fairly small (~ 3 KB). - */ - if (!file_readable("/var/run/ld.so.hints")) { - Mkdir("/var/run"); - if (vsystem("/mnt2/sbin/ldconfig -s /mnt2/usr/lib")) { - msgConfirm("Warning: ldconfig could not create the ld.so hints file.\n" - "Dynamic executables from the CDROM likely won't work."); - } - } - - /* Yet another iggly hardcoded pathname. */ - if (!file_readable("/usr/libexec/ld.so")) { - Mkdir("/usr/libexec"); - if (symlink("/mnt2/usr/libexec/ld.so", "/usr/libexec/ld.so")) { - msgConfirm("Warning: could not create the symlink for ld.so.\n" - "Dynamic executables from the CDROM likely won't work."); - } - } - - fixit_common(); - - mediaDevice->shutdown(mediaDevice); - msgConfirm("Please remove the FreeBSD CDROM now."); - return DITEM_SUCCESS; -} - -int -installFixitFloppy(dialogMenuItem *self) -{ - struct ufs_args args; - - if (!RunningAsInit) - return DITEM_SUCCESS; - - variable_set2(SYSTEM_STATE, "fixit"); - Mkdir("/mnt2"); - - /* Try to open the floppy drive */ - if (DITEM_STATUS(mediaSetFloppy(NULL)) == DITEM_FAILURE) { - msgConfirm("Unable to set media device to floppy."); - mediaClose(); - return DITEM_FAILURE; - } - - memset(&args, 0, sizeof(args)); - args.fspec = mediaDevice->devname; - - while (1) { - msgConfirm("Please insert a writable fixit floppy and press return"); - mediaDevice->private = "/mnt2"; - if (!mediaDevice->init(mediaDevice)) { - if (msgYesNo("The attempt to mount the fixit floppy failed, bad floppy\n" - "or unclean filesystem. Do you want to try again?")) - return DITEM_FAILURE; - } - else - break; - } - if (!directory_exists("/tmp")) - (void)symlink("/mnt2/tmp", "/tmp"); - fixit_common(); - mediaDevice->shutdown(mediaDevice); - mediaDevice = NULL; - msgConfirm("Please remove the fixit floppy now."); - return DITEM_SUCCESS; -} - -/* - * The common code for both fixit variants. - */ -static void -fixit_common(void) -{ - pid_t child; - int waitstatus; - - if (!directory_exists("/var/tmp/vi.recover")) { - if (DITEM_STATUS(Mkdir("/var/tmp/vi.recover")) != DITEM_SUCCESS) { - msgConfirm("Warning: Was unable to create a /var/tmp/vi.recover directory.\n" - "vi will kvetch and moan about it as a result but should still\n" - "be essentially usable."); - } - } - if (!directory_exists("/bin")) - (void)Mkdir("/bin"); - (void)symlink("/stand/sh", "/bin/sh"); - /* Link the /etc/ files */ - if (DITEM_STATUS(Mkdir("/etc")) != DITEM_SUCCESS) - msgConfirm("Unable to create an /etc directory! Things are weird on this floppy.."); - else if ((symlink("/mnt2/etc/spwd.db", "/etc/spwd.db") == -1 && errno != EEXIST) || - (symlink("/mnt2/etc/protocols", "/etc/protocols") == -1 && errno != EEXIST) || - (symlink("/mnt2/etc/services", "/etc/services") == -1 && errno != EEXIST)) - msgConfirm("Couldn't symlink the /etc/ files! I'm not sure I like this.."); - if (!file_readable(TERMCAP_FILE)) - create_termcap(); - if (!(child = fork())) { - int i, fd; - struct termios foo; - extern int login_tty(int); - - ioctl(0, TIOCNOTTY, NULL); - for (i = getdtablesize(); i >= 0; --i) - close(i); - fd = open("/dev/ttyv3", O_RDWR); - ioctl(0, TIOCSCTTY, &fd); - dup2(0, 1); - dup2(0, 2); - DebugFD = 2; - if (login_tty(fd) == -1) - msgDebug("fixit: I can't set the controlling terminal.\n"); - - signal(SIGTTOU, SIG_IGN); - if (tcgetattr(0, &foo) != -1) { - foo.c_cc[VERASE] = '\010'; - if (tcsetattr(0, TCSANOW, &foo) == -1) - msgDebug("fixit shell: Unable to set erase character.\n"); - } - else - msgDebug("fixit shell: Unable to get terminal attributes!\n"); - setenv("PATH", "/bin:/sbin:/usr/bin:/usr/sbin:/stand:" - "/mnt2/stand:/mnt2/bin:/mnt2/sbin:/mnt2/usr/bin:/mnt2/usr/sbin", 1); - /* use the .profile from the fixit medium */ - setenv("HOME", "/mnt2", 1); - chdir("/mnt2"); - execlp("sh", "-sh", 0); - msgDebug("fixit shell: Failed to execute shell!\n"); - _exit(1);; - } - else { - msgNotify("Waiting for fixit shell to exit. Go to VTY4 now by\n" - "typing ALT-F4. When you are done, type ``exit'' to exit\n" - "the fixit shell and be returned here."); - (void)waitpid(child, &waitstatus, 0); - } - dialog_clear(); -} - - -int -installExpress(dialogMenuItem *self) -{ - int i; - - variable_set2(SYSTEM_STATE, "express"); -#ifndef __alpha__ - if (DITEM_STATUS((i = diskPartitionEditor(self))) == DITEM_FAILURE) - return i; -#endif - - if (DITEM_STATUS((i = diskLabelEditor(self))) == DITEM_FAILURE) - return i; - - dialog_clear_norefresh(); - if (DITEM_STATUS((i = installCommit(self))) == DITEM_SUCCESS) { - i |= DITEM_LEAVE_MENU; - /* Give user the option of one last configuration spree */ - installConfigure(); - } - return i | DITEM_RESTORE; -} - -/* Novice mode installation */ -int -installNovice(dialogMenuItem *self) -{ - int i, tries = 0; - Device **devs; - - variable_set2(SYSTEM_STATE, "novice"); -#ifndef __alpha__ - dialog_clear_norefresh(); - msgConfirm("In the next menu, you will need to set up a DOS-style (\"fdisk\") partitioning\n" - "scheme for your hard disk. If you simply wish to devote all disk space\n" - "to FreeBSD (overwriting anything else that might be on the disk(s) selected)\n" - "then use the (A)ll command to select the default partitioning scheme followed\n" - "by a (Q)uit. If you wish to allocate only free space to FreeBSD, move to a\n" - "partition marked \"unused\" and use the (C)reate command."); - -nodisks: - if (DITEM_STATUS(diskPartitionEditor(self)) == DITEM_FAILURE) - return DITEM_FAILURE; - - if (diskGetSelectCount(&devs) <= 0 && tries < 3) { - msgConfirm("You need to select some disks to operate on! Be sure to use SPACE\n" - "instead of RETURN in the disk selection menu when selecting a disk."); - ++tries; - goto nodisks; - } -#endif - - dialog_clear_norefresh(); -#ifdef __alpha__ - msgConfirm("First, you need to create BSD partitions on the disk which you are\n" - "installing to. If you have a reasonable amount of disk space (200MB or more)\n" - "and don't have any special requirements, simply use the (A)uto command to\n" - "allocate space automatically. If you have more specific needs or just don't\n" - "care for the layout chosen by (A)uto, press F1 for more information on\n" - "manual layout."); -#else - msgConfirm("First, you need to create BSD partitions inside of the fdisk partition(s)\n" - "just created. If you have a reasonable amount of disk space (200MB or more)\n" - "and don't have any special requirements, simply use the (A)uto command to\n" - "allocate space automatically. If you have more specific needs or just don't\n" - "care for the layout chosen by (A)uto, press F1 for more information on\n" - "manual layout."); -#endif - - if (DITEM_STATUS(diskLabelEditor(self)) == DITEM_FAILURE) - return DITEM_FAILURE; - - dialog_clear_norefresh(); - if (DITEM_STATUS((i = installCommit(self))) == DITEM_FAILURE) { - dialog_clear_norefresh(); - msgConfirm("Installation completed with some errors. You may wish to\n" - "scroll through the debugging messages on VTY1 with the\n" - "scroll-lock feature. You can also chose \"No\" at the next\n" - "prompt and go back into the installation menus to try and retry\n" - "whichever operations have failed."); - return i | DITEM_RESTORE; - - } - else { - dialog_clear_norefresh(); - msgConfirm("Congratulations! You now have FreeBSD installed on your system.\n\n" - "We will now move on to the final configuration questions.\n" - "For any option you do not wish to configure, simply select\n" - "No.\n\n" - "If you wish to re-enter this utility after the system is up, you\n" - "may do so by typing: /stand/sysinstall."); - } - if (mediaDevice->type != DEVICE_TYPE_FTP && mediaDevice->type != DEVICE_TYPE_NFS) { - if (!msgYesNo("Would you like to configure any Ethernet or SLIP/PPP network devices?")) { - Device *tmp; - - dialog_clear_norefresh(); - tmp = tcpDeviceSelect(); - dialog_clear_norefresh(); - if (tmp && !msgYesNo("Would you like to bring the %s interface up right now?", tmp->name)) - if (!tmp->init(tmp)) - msgConfirm("Initialization of %s device failed.", tmp->name); - } - } - - dialog_clear_norefresh(); - if (!msgYesNo("Will this machine be an IP gateway (e.g. will it forward packets\n" - "between interfaces)?")) - variable_set2("gateway_enable", "YES"); - - dialog_clear_norefresh(); - if (!msgYesNo("Do you want to allow anonymous FTP connections to this machine?")) - configAnonFTP(self); - - dialog_clear_norefresh(); - if (!msgYesNo("Do you want to configure this machine as an NFS server?")) - configNFSServer(self); - - dialog_clear_norefresh(); - if (!msgYesNo("Do you want to configure this machine as an NFS client?")) - variable_set2("nfs_client_enable", "YES"); - - dialog_clear_norefresh(); - if (!msgYesNo("Would you like to customize your system console settings?")) { - WINDOW *w = savescr(); - - dmenuOpenSimple(&MenuSyscons, FALSE); - restorescr(w); - } - - dialog_clear_norefresh(); - if (!msgYesNo("Would you like to set this machine's time zone now?")) { - WINDOW *w = savescr(); - - dialog_clear(); - systemExecute("tzsetup"); - restorescr(w); - } - - dialog_clear_norefresh(); - if (!msgYesNo("Does this system have a mouse attached to it?")) { - WINDOW *w = savescr(); - - dmenuOpenSimple(&MenuMouse, FALSE); - restorescr(w); - } - - /* Now would be a good time to checkpoint the configuration data */ - configRC_conf("/etc/rc.conf"); - sync(); - - if (directory_exists("/usr/X11R6")) { - dialog_clear_norefresh(); - if (!msgYesNo("Would you like to configure your X server at this time?")) - configXEnvironment(self); - } - - dialog_clear_norefresh(); - if (!msgYesNo("The FreeBSD package collection is a collection of hundreds of ready-to-run\n" - "applications, from text editors to games to WEB servers and more. Would you\n" - "like to browse the collection now?")) - configPackages(self); - - dialog_clear_norefresh(); - if (!msgYesNo("Would you like to add any initial user accounts to the system?\n" - "Adding at least one account for yourself at this stage is suggested\n" - "since working as the \"root\" user is dangerous (it is easy to do\n" - "things which adversely affect the entire system).")) - configUsers(self); - - dialog_clear_norefresh(); - msgConfirm("Now you must set the system manager's password.\n" - "This is the password you'll use to log in as \"root\"."); - { - WINDOW *w = savescr(); - - if (!systemExecute("passwd root")) - variable_set2("root_password", "YES"); - restorescr(w); - } - - dialog_clear_norefresh(); - if (!msgYesNo("Would you like to register your FreeBSD system at this time?\n\n" - "PLEASE, take just 5 minutes to do this. If we're ever to get any\n" - "significant base of commercial software for FreeBSD, we need to\n" - "be able to provide more information about the size of our user community.\n" - "This is where your registration can really help us, and you can also\n" - "sign up for the new FreeBSD newsletter (its free!) at the same time.\n")) - configRegister(NULL); - else { - dialog_clear_norefresh(); - msgConfirm("OK, but if you should change your mind then you always can register\n" - "later by typing ``/stand/sysinstall register'' or by simply visiting our\n" - "web site at http://www.freebsd.org/register.html"); - - } - /* XXX Put whatever other nice configuration questions you'd like to ask the user here XXX */ - - /* Give user the option of one last configuration spree */ - dialog_clear_norefresh(); - installConfigure(); - - return DITEM_LEAVE_MENU | DITEM_RESTORE; -} - -/* The version of commit we call from the Install Custom menu */ -int -installCustomCommit(dialogMenuItem *self) -{ - int i; - - dialog_clear_norefresh(); - i = installCommit(self); - if (DITEM_STATUS(i) == DITEM_SUCCESS) { - /* Give user the option of one last configuration spree */ - installConfigure(); - return i; - } - else - msgConfirm("The commit operation completed with errors. Not\n" - "updating /etc files."); - return i; -} - -/* - * What happens when we finally decide to going ahead with the installation. - * - * This is broken into multiple stages so that the user can do a full - * installation but come back here again to load more distributions, - * perhaps from a different media type. This would allow, for - * example, the user to load the majority of the system from CDROM and - * then use ftp to load just the DES dist. - */ -int -installCommit(dialogMenuItem *self) -{ - int i; - char *str; - - if (!Dists) - distConfig(NULL); - - if (!Dists) - if (!dmenuOpenSimple(&MenuDistributions, FALSE) && !Dists) - return DITEM_FAILURE | DITEM_RESTORE; - - if (!mediaVerify()) - return DITEM_FAILURE | DITEM_RESTORE; - - str = variable_get(SYSTEM_STATE); - if (isDebug()) - msgDebug("installCommit: System state is `%s'\n", str); - - /* Installation stuff we wouldn't do to a running system */ - if (RunningAsInit && DITEM_STATUS((i = installInitial())) == DITEM_FAILURE) - return i; - -try_media: - if (!mediaDevice->init(mediaDevice)) { - if (!msgYesNo("Unable to initialize selected media. Would you like to\n" - "adjust your media configuration and try again?")) { - mediaDevice = NULL; - if (!mediaVerify()) - return DITEM_FAILURE | DITEM_RESTORE; - else - goto try_media; - } - else - return DITEM_FAILURE | DITEM_RESTORE; - } - - /* Now go get it all */ - i = distExtractAll(self); - - /* When running as init, *now* it's safe to grab the rc.foo vars */ - installEnvironment(); - - variable_set2(SYSTEM_STATE, DITEM_STATUS(i) == DITEM_FAILURE ? "error-install" : "full-install"); - - return i | DITEM_RESTORE; -} - -static void -installConfigure(void) -{ - /* Final menu of last resort */ - dialog_clear_norefresh(); - if (!msgYesNo("Visit the general configuration menu for a chance to set\n" - "any last options?")) { - WINDOW *w = savescr(); - - dmenuOpenSimple(&MenuConfigure, FALSE); - restorescr(w); - } - configRC_conf("/etc/rc.conf"); - sync(); -} - -int -installFixupBin(dialogMenuItem *self) -{ - Device **devs; - int i; - - /* All of this is done only as init, just to be safe */ - if (RunningAsInit) { - /* Fix up kernel first */ - if (!file_readable("/kernel")) { - if (file_readable("/kernel.GENERIC")) { - if (vsystem("cp -p /kernel.GENERIC /kernel")) { - msgConfirm("Unable to copy /kernel into place!"); - return DITEM_FAILURE; - } - /* Snapshot any boot -c changes back to the new kernel */ - if (kget("/kernel.config")) { - msgConfirm("Kernel copied OK, but unable to save boot -c changes\n" - "to it. See the debug screen (ALT-F2) for details."); - } - } - else { - msgConfirm("Can't find a kernel image to link to on the root file system!\n" - "You're going to have a hard time getting this system to\n" - "boot from the hard disk, I'm afraid!"); - return DITEM_FAILURE; - } - } - - /* BOGON #1: Resurrect /dev after bin distribution screws it up */ - msgNotify("Remaking all devices.. Please wait!"); - if (vsystem("cd /dev; sh MAKEDEV all")) { - msgConfirm("MAKEDEV returned non-zero status"); - return DITEM_FAILURE; - } - - msgNotify("Resurrecting /dev entries for slices.."); - devs = deviceFind(NULL, DEVICE_TYPE_DISK); - if (!devs) - msgFatal("Couldn't get a disk device list!"); - - /* Resurrect the slices that the former clobbered */ - for (i = 0; devs[i]; i++) { - Disk *disk = (Disk *)devs[i]->private; - Chunk *c1; - - if (!devs[i]->enabled) - continue; - if (!disk->chunks) - msgFatal("No chunk list found for %s!", disk->name); - for (c1 = disk->chunks->part; c1; c1 = c1->next) { - if (c1->type == freebsd) { - msgNotify("Making slice entries for %s", c1->name); - if (vsystem("cd /dev; sh MAKEDEV %sh", c1->name)) { - msgConfirm("Unable to make slice entries for %s!", c1->name); - return DITEM_FAILURE; - } - } - } - } - - /* BOGON #2: We leave /etc in a bad state */ - chmod("/etc", 0755); - - /* BOGON #3: No /var/db/mountdtab complains */ - Mkdir("/var/db"); - creat("/var/db/mountdtab", 0644); - - /* BOGON #4: /compat created by default in root fs */ - Mkdir("/usr/compat"); - vsystem("ln -s /usr/compat /compat"); - - /* BOGON #5: aliases database not build for bin */ - vsystem("newaliases"); - - /* BOGON #6: deal with new boot files */ - vsystem("touch /kernel.config"); - vsystem("touch /boot.config"); - if (file_readable("/stand/boot.help") && !file_readable("/boot.help")) - vsystem("mv /stand/boot.help /"); - - /* Now run all the mtree stuff to fix things up */ - vsystem("mtree -deU -f /etc/mtree/BSD.root.dist -p /"); - vsystem("mtree -deU -f /etc/mtree/BSD.var.dist -p /var"); - vsystem("mtree -deU -f /etc/mtree/BSD.usr.dist -p /usr"); - - /* Do all the last ugly work-arounds here */ - } - return DITEM_SUCCESS; -} - -/* Fix side-effects from the the XFree86 installation */ -int -installFixupXFree(dialogMenuItem *self) -{ - /* BOGON #1: XFree86 requires various specialized fixups */ - if (directory_exists("/usr/X11R6")) { - msgNotify("Fixing permissions in XFree86 tree.."); - vsystem("chmod -R a+r /usr/X11R6"); - vsystem("find /usr/X11R6 -type d | xargs chmod a+x"); - - /* Also do bogus minimal package registration so ports don't whine */ - if (file_readable("/usr/X11R6/lib/X11/pkgreg.tar.gz")) { - msgNotify("Installing package metainfo.."); - vsystem("tar xpzf /usr/X11R6/lib/X11/pkgreg.tar.gz -C / && rm /usr/X11R6/lib/X11/pkgreg.tar.gz"); - } - } - return DITEM_SUCCESS; -} - -/* Go newfs and/or mount all the filesystems we've been asked to */ -int -installFilesystems(dialogMenuItem *self) -{ - int i; - Disk *disk; - Chunk *c1, *c2, *rootdev, *swapdev, *usrdev, *vardev; - Device **devs; - PartInfo *root; - char dname[80]; - extern int MakeDevChunk(Chunk *c, char *n); - Boolean upgrade = FALSE; - - /* If we've already done this, bail out */ - if (!variable_cmp(DISK_LABELLED, "written")) - return DITEM_SUCCESS; - - upgrade = !variable_cmp(SYSTEM_STATE, "upgrade"); - if (!checkLabels(TRUE, &rootdev, &swapdev, &usrdev, &vardev)) - return DITEM_FAILURE; - - if (rootdev) - root = (PartInfo *)rootdev->private_data; - else - root = NULL; - - command_clear(); - if (swapdev && RunningAsInit) { - /* As the very first thing, try to get ourselves some swap space */ - sprintf(dname, "/dev/%s", swapdev->name); - if (!Fake && (!MakeDevChunk(swapdev, "/dev") || !file_readable(dname))) { - msgConfirm("Unable to make device node for %s in /dev!\n" - "The creation of filesystems will be aborted.", dname); - return DITEM_FAILURE; - } - - if (!Fake) { - if (!swapon(dname)) - msgNotify("Added %s as initial swap device", dname); - else - msgConfirm("WARNING! Unable to swap to %s: %s\n" - "This may cause the installation to fail at some point\n" - "if you don't have a lot of memory.", dname, strerror(errno)); - } - } - - if (rootdev && RunningAsInit) { - /* Next, create and/or mount the root device */ - sprintf(dname, "/dev/r%s", rootdev->name); - if (!Fake && (!MakeDevChunk(rootdev, "/dev") || !file_readable(dname))) { - msgConfirm("Unable to make device node for %s in /dev!\n" - "The creation of filesystems will be aborted.", dname); - return DITEM_FAILURE; - } - if (strcmp(root->mountpoint, "/")) - msgConfirm("Warning: %s is marked as a root partition but is mounted on %s", rootdev->name, root->mountpoint); - - if (root->newfs && (!upgrade || !msgYesNo("You are upgrading - are you SURE you want to newfs the root partition?"))) { - int i; - - msgNotify("Making a new root filesystem on %s", dname); - i = vsystem("%s %s", root->newfs_cmd, dname); - if (i) { - msgConfirm("Unable to make new root filesystem on %s!\n" - "Command returned status %d", dname, i); - return DITEM_FAILURE; - } - } - else { - if (!upgrade) { - msgConfirm("Warning: Using existing root partition. It will be assumed\n" - "that you have the appropriate device entries already in /dev."); - } - msgNotify("Checking integrity of existing %s filesystem.", dname); - i = vsystem("fsck -y %s", dname); - if (i) - msgConfirm("Warning: fsck returned status of %d for %s.\n" - "This partition may be unsafe to use.", i, dname); - } - - /* Switch to block device */ - sprintf(dname, "/dev/%s", rootdev->name); - if (Mount("/mnt", dname)) { - msgConfirm("Unable to mount the root file system on %s! Giving up.", dname); - return DITEM_FAILURE; - } - } - - /* Now buzz through the rest of the partitions and mount them too */ - devs = deviceFind(NULL, DEVICE_TYPE_DISK); - for (i = 0; devs[i]; i++) { - if (!devs[i]->enabled) - continue; - - disk = (Disk *)devs[i]->private; - if (!disk->chunks) { - msgConfirm("No chunk list found for %s!", disk->name); - return DITEM_FAILURE; - } - if (RunningAsInit && root && (root->newfs || upgrade)) { - Mkdir("/mnt/dev"); - if (!Fake) - MakeDevDisk(disk, "/mnt/dev"); - } - else if (!RunningAsInit && !Fake) - MakeDevDisk(disk, "/dev"); - - for (c1 = disk->chunks->part; c1; c1 = c1->next) { - if (c1->type == freebsd) { - for (c2 = c1->part; c2; c2 = c2->next) { - if (c2->type == part && c2->subtype != FS_SWAP && c2->private_data) { - PartInfo *tmp = (PartInfo *)c2->private_data; - - /* Already did root */ - if (c2 == rootdev) - continue; - - if (tmp->newfs && (!upgrade || !msgYesNo("You are upgrading - are you SURE you want to newfs /dev/%s?", c2->name))) - command_shell_add(tmp->mountpoint, "%s %s/dev/r%s", tmp->newfs_cmd, RunningAsInit ? "/mnt" : "", c2->name); - else - command_shell_add(tmp->mountpoint, "fsck -y %s/dev/r%s", RunningAsInit ? "/mnt" : "", c2->name); - command_func_add(tmp->mountpoint, Mount, c2->name); - } - else if (c2->type == part && c2->subtype == FS_SWAP) { - char fname[80]; - int i; - - if (c2 == swapdev) - continue; - sprintf(fname, "%s/dev/%s", RunningAsInit ? "/mnt" : "", c2->name); - i = (Fake || swapon(fname)); - if (!i) - msgNotify("Added %s as an additional swap device", fname); - else - msgConfirm("Unable to add %s as a swap device: %s", fname, strerror(errno)); - } - } - } - else if (c1->type == fat && c1->private_data && (root->newfs || upgrade)) { - char name[FILENAME_MAX]; - - sprintf(name, "%s/%s", RunningAsInit ? "/mnt" : "", ((PartInfo *)c1->private_data)->mountpoint); - Mkdir(name); - } - } - } - - if (RunningAsInit) { - msgNotify("Copying initial device files.."); - /* Copy the boot floppy's dev files */ - if ((root->newfs || upgrade) && vsystem("find -x /dev | cpio %s -pdum /mnt", cpioVerbosity())) { - msgConfirm("Couldn't clone the /dev files!"); - return DITEM_FAILURE; - } - } - - command_sort(); - command_execute(); - return DITEM_SUCCESS; -} - -static char * -getRelname(void) -{ - static char buf[64]; - int sz = (sizeof buf) - 1; - - if (sysctlbyname("kern.osrelease", buf, &sz, NULL, 0) != -1) { - buf[sz] = '\0'; - return buf; - } - else - return "<unknown>"; -} - -/* Initialize various user-settable values to their defaults */ -int -installVarDefaults(dialogMenuItem *self) -{ - char *cp; - - /* Set default startup options */ - variable_set2(VAR_RELNAME, getRelname()); - variable_set2(VAR_CPIO_VERBOSITY, "high"); - variable_set2(VAR_TAPE_BLOCKSIZE, DEFAULT_TAPE_BLOCKSIZE); - variable_set2(VAR_INSTALL_ROOT, "/"); - variable_set2(VAR_INSTALL_CFG, "install.cfg"); - cp = getenv("EDITOR"); - if (!cp) - cp = "/usr/bin/ee"; - variable_set2(VAR_EDITOR, cp); - variable_set2(VAR_FTP_USER, "ftp"); - variable_set2(VAR_BROWSER_PACKAGE, "lynx"); - variable_set2(VAR_BROWSER_BINARY, "/usr/local/bin/lynx"); - variable_set2(VAR_FTP_STATE, "passive"); - variable_set2(VAR_NFS_SECURE, "YES"); - variable_set2(VAR_PKG_TMPDIR, "/usr/tmp"); - variable_set2(VAR_GATED_PKG, "gated"); - variable_set2(VAR_PCNFSD_PKG, "pcnfsd"); - variable_set2(VAR_MEDIA_TIMEOUT, itoa(MEDIA_TIMEOUT)); - if (getpid() != 1) - variable_set2(SYSTEM_STATE, "update"); - else - variable_set2(SYSTEM_STATE, "init"); - return DITEM_SUCCESS; -} - -/* Load the environment up from various system configuration files */ -void -installEnvironment(void) -{ - if (file_readable("/etc/rc.conf")) - configEnvironmentRC_conf("/etc/rc.conf"); - if (file_readable("/etc/resolv.conf")) - configEnvironmentResolv("/etc/resolv.conf"); -} - -/* Copy the boot floppy contents into /stand */ -Boolean -copySelf(void) -{ - int i; - - if (file_readable("/boot.help")) - vsystem("cp /boot.help /mnt"); - msgWeHaveOutput("Copying the boot floppy to /stand on root filesystem"); - i = vsystem("find -x /stand | cpio %s -pdum /mnt", cpioVerbosity()); - if (i) { - msgConfirm("Copy returned error status of %d!", i); - return FALSE; - } - - /* Copy the /etc files into their rightful place */ - if (vsystem("cd /mnt/stand; find etc | cpio %s -pdum /mnt", cpioVerbosity())) { - msgConfirm("Couldn't copy up the /etc files!"); - return TRUE; - } - return TRUE; -} - -static void -create_termcap(void) -{ - FILE *fp; - - const char *caps[] = { - termcap_vt100, termcap_cons25, termcap_cons25_m, termcap_cons25r, - termcap_cons25r_m, termcap_cons25l1, termcap_cons25l1_m, NULL, - }; - const char **cp; - - if (!file_readable(TERMCAP_FILE)) { - Mkdir("/usr/share/misc"); - fp = fopen(TERMCAP_FILE, "w"); - if (!fp) { - msgConfirm("Unable to initialize termcap file. Some screen-oriented\nutilities may not work."); - return; - } - cp = caps; - while (*cp) - fprintf(fp, "%s\n", *(cp++)); - fclose(fp); - } -} diff --git a/usr.sbin/sade/keymap.c b/usr.sbin/sade/keymap.c deleted file mode 100644 index 459f4cbe2860..000000000000 --- a/usr.sbin/sade/keymap.c +++ /dev/null @@ -1,95 +0,0 @@ -/* - * Copyright (c) 1996 Joerg Wunsch - * - * 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 DEVELOPERS ``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 DEVELOPERS 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. - * - * $Id$ - * - */ - -#include "sysinstall.h" -#include <errno.h> -#include <stdlib.h> -#include <string.h> -#include <unistd.h> -#include <machine/console.h> - -struct keymapInfo { - const char *name; - const struct keymap *map; -}; - -#include "keymap.h" - -/* - * keymap.h is being automatically generated by the Makefile. It - * contains definitions for all desired keymaps. Note that since we - * don't support font loading nor screen mapping during installation, - * we simply don't care for any other keys than the ASCII subset. - * - * Therefore, if no keymap with the exact name has been found in the - * first pass, we make a second pass over the table looking just for - * the language name only. - */ - -/* - * Return values: - * - * 0: OK - * -1: no appropriate keymap found - * -2: error installing map (other than ENXIO which means we're not on syscons) - */ - -int -loadKeymap(const char *lang) -{ - int passno, err; - char *llang; - size_t l; - struct keymapInfo *kip; - - llang = strdup(lang); - if (llang == NULL) - abort(); - - for (passno = 0; passno < 2; passno++) - { - if (passno > 0) - { - /* make the match more fuzzy */ - l = strspn(llang, "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"); - llang[l] = '\0'; - } - - l = strlen(llang); - - for (kip = keymapInfos; kip->name; kip++) - if (strncmp(kip->name, llang, l) == 0) - { - /* Yep, got it! */ - err = ioctl(0, PIO_KEYMAP, kip->map); - free(llang); - return (err == -1 && errno != ENOTTY)? -2: 0; - } - } - free(llang); - return -1; -} diff --git a/usr.sbin/sade/label.c b/usr.sbin/sade/label.c deleted file mode 100644 index ea49bbe0a169..000000000000 --- a/usr.sbin/sade/label.c +++ /dev/null @@ -1,1268 +0,0 @@ -/* - * The new sysinstall program. - * - * This is probably the last program in the `sysinstall' line - the next - * generation being essentially a complete rewrite. - * - * $Id: label.c,v 1.83 1998/07/18 09:42:01 jkh Exp $ - * - * Copyright (c) 1995 - * Jordan Hubbard. 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, - * verbatim and that no modifications are made prior to this - * point in the file. - * 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 JORDAN HUBBARD ``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 JORDAN HUBBARD OR HIS PETS 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, LIFE 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. - * - */ - -#include "sysinstall.h" -#include <ctype.h> -#include <sys/disklabel.h> -#include <sys/param.h> -#include <sys/sysctl.h> - -/* - * Everything to do with editing the contents of disk labels. - */ - -/* A nice message we use a lot in the disklabel editor */ -#define MSG_NOT_APPLICABLE "That option is not applicable here" - -/* Where to start printing the freebsd slices */ -#define CHUNK_SLICE_START_ROW 2 -#define CHUNK_PART_START_ROW 11 - -/* The smallest filesystem we're willing to create */ -#define FS_MIN_SIZE ONE_MEG - -/* The smallest root filesystem we're willing to create */ -#define ROOT_MIN_SIZE 20 - -/* The smallest swap partition we want to create by default */ -#define SWAP_MIN_SIZE 16 - -/* The smallest /usr partition we're willing to create by default */ -#define USR_MIN_SIZE 80 - -/* The smallest /var partition we're willing to create by default */ -#define VAR_MIN_SIZE 30 - -/* The bottom-most row we're allowed to scribble on */ -#define CHUNK_ROW_MAX 16 - - -/* All the chunks currently displayed on the screen */ -static struct { - struct chunk *c; - PartType type; -} label_chunk_info[MAX_CHUNKS + 1]; -static int here; - -/*** with this value we try to track the most recently added label ***/ -static int label_focus = 0, pslice_focus = 0; - -static int diskLabel(Device *dev); -static int diskLabelNonInteractive(Device *dev); - -static int -labelHook(dialogMenuItem *selected) -{ - Device **devs = NULL; - - devs = deviceFind(selected->prompt, DEVICE_TYPE_DISK); - if (!devs) { - msgConfirm("Unable to find disk %s!", selected->prompt); - return DITEM_FAILURE; - } - /* Toggle enabled status? */ - if (!devs[0]->enabled) { - devs[0]->enabled = TRUE; - diskLabel(devs[0]); - } - else - devs[0]->enabled = FALSE; - return DITEM_SUCCESS | DITEM_RESTORE; -} - -static int -labelCheck(dialogMenuItem *selected) -{ - Device **devs = NULL; - - devs = deviceFind(selected->prompt, DEVICE_TYPE_DISK); - if (!devs || devs[0]->enabled == FALSE) - return FALSE; - return TRUE; -} - -int -diskLabelEditor(dialogMenuItem *self) -{ - DMenu *menu; - Device **devs; - int i, cnt; - - i = 0; - cnt = diskGetSelectCount(&devs); - if (cnt == -1) { - msgConfirm("No disks found! Please verify that your disk controller is being\n" - "properly probed at boot time. See the Hardware Guide on the\n" - "Documentation menu for clues on diagnosing this type of problem."); - return DITEM_FAILURE; - } - else if (cnt) { - /* Some are already selected */ - if (variable_get(VAR_NONINTERACTIVE)) - i = diskLabelNonInteractive(NULL); - else - i = diskLabel(NULL); - } - else { - /* No disks are selected, fall-back case now */ - cnt = deviceCount(devs); - if (cnt == 1) { - devs[0]->enabled = TRUE; - if (variable_get(VAR_NONINTERACTIVE)) - i = diskLabelNonInteractive(devs[0]); - else - i = diskLabel(devs[0]); - } - else { - menu = deviceCreateMenu(&MenuDiskDevices, DEVICE_TYPE_DISK, labelHook, labelCheck); - if (!menu) { - msgConfirm("No devices suitable for installation found!\n\n" - "Please verify that your disk controller (and attached drives)\n" - "were detected properly. This can be done by pressing the\n" - "[Scroll Lock] key and using the Arrow keys to move back to\n" - "the boot messages. Press [Scroll Lock] again to return."); - i = DITEM_FAILURE; - } - else { - i = dmenuOpenSimple(menu, FALSE) ? DITEM_SUCCESS : DITEM_FAILURE; - free(menu); - } - i |= DITEM_RESTORE; - } - } - if (DITEM_STATUS(i) != DITEM_FAILURE) { - char *cp; - - if (((cp = variable_get(DISK_LABELLED)) == NULL) || (strcmp(cp, "written"))) - variable_set2(DISK_LABELLED, "yes"); - } - return i; -} - -int -diskLabelCommit(dialogMenuItem *self) -{ - char *cp; - int i; - - /* Already done? */ - if ((cp = variable_get(DISK_LABELLED)) && strcmp(cp, "yes")) - i = DITEM_SUCCESS; - else if (!cp) { - msgConfirm("You must assign disk labels before this option can be used."); - i = DITEM_FAILURE; - } - /* The routine will guard against redundant writes, just as this one does */ - else if (DITEM_STATUS(diskPartitionWrite(self)) != DITEM_SUCCESS) - i = DITEM_FAILURE; - else if (DITEM_STATUS(installFilesystems(self)) != DITEM_SUCCESS) - i = DITEM_FAILURE; - else { - msgInfo("All filesystem information written successfully."); - variable_set2(DISK_LABELLED, "written"); - i = DITEM_SUCCESS; - } - return i; -} - -/* See if we're already using a desired partition name */ -static Boolean -check_conflict(char *name) -{ - int i; - - for (i = 0; label_chunk_info[i].c; i++) - if ((label_chunk_info[i].type == PART_FILESYSTEM || label_chunk_info[i].type == PART_FAT) - && label_chunk_info[i].c->private_data - && !strcmp(((PartInfo *)label_chunk_info[i].c->private_data)->mountpoint, name)) - return TRUE; - return FALSE; -} - -/* How much space is in this FreeBSD slice? */ -static int -space_free(struct chunk *c) -{ - struct chunk *c1; - int sz = c->size; - - for (c1 = c->part; c1; c1 = c1->next) { - if (c1->type != unused) - sz -= c1->size; - } - if (sz < 0) - msgFatal("Partitions are larger than actual chunk??"); - return sz; -} - -/* Snapshot the current situation into the displayed chunks structure */ -static void -record_label_chunks(Device **devs, Device *dev) -{ - int i, j, p; - struct chunk *c1, *c2; - Disk *d; - - j = p = 0; - /* First buzz through and pick up the FreeBSD slices */ - for (i = 0; devs[i]; i++) { - if ((dev && devs[i] != dev) || !devs[i]->enabled) - continue; - d = (Disk *)devs[i]->private; - if (!d->chunks) - msgFatal("No chunk list found for %s!", d->name); - - /* Put the slice entries first */ - for (c1 = d->chunks->part; c1; c1 = c1->next) { - if (c1->type == freebsd) { - label_chunk_info[j].type = PART_SLICE; - label_chunk_info[j].c = c1; - ++j; - } - } - } - - /* Now run through again and get the FreeBSD partition entries */ - for (i = 0; devs[i]; i++) { - if (!devs[i]->enabled) - continue; - d = (Disk *)devs[i]->private; - /* Then buzz through and pick up the partitions */ - for (c1 = d->chunks->part; c1; c1 = c1->next) { - if (c1->type == freebsd) { - for (c2 = c1->part; c2; c2 = c2->next) { - if (c2->type == part) { - if (c2->subtype == FS_SWAP) - label_chunk_info[j].type = PART_SWAP; - else - label_chunk_info[j].type = PART_FILESYSTEM; - label_chunk_info[j].c = c2; - ++j; - } - } - } - else if (c1->type == fat) { - label_chunk_info[j].type = PART_FAT; - label_chunk_info[j].c = c1; - ++j; - } - } - } - label_chunk_info[j].c = NULL; - if (here >= j) { - here = j ? j - 1 : 0; - } -} - -/* A new partition entry */ -static PartInfo * -new_part(char *mpoint, Boolean newfs, u_long size) -{ - PartInfo *ret; - - if (!mpoint) - mpoint = "/change_me"; - - ret = (PartInfo *)safe_malloc(sizeof(PartInfo)); - sstrncpy(ret->mountpoint, mpoint, FILENAME_MAX); - strcpy(ret->newfs_cmd, "newfs -b 8192 -f 1024"); - ret->newfs = newfs; - if (!size) - return ret; - return ret; -} - -/* Get the mountpoint for a partition and save it away */ -static PartInfo * -get_mountpoint(struct chunk *old) -{ - char *val; - PartInfo *tmp; - - if (old && old->private_data) - tmp = old->private_data; - else - tmp = NULL; - if (!old) { - DialogX = 14; - DialogY = 16; - } - val = msgGetInput(tmp ? tmp->mountpoint : NULL, "Please specify a mount point for the partition"); - DialogX = DialogY = 0; - if (!val || !*val) { - if (!old) - return NULL; - else { - free(old->private_data); - old->private_data = NULL; - } - return NULL; - } - - /* Is it just the same value? */ - if (tmp && !strcmp(tmp->mountpoint, val)) - return NULL; - - /* Did we use it already? */ - if (check_conflict(val)) { - msgConfirm("You already have a mount point for %s assigned!", val); - return NULL; - } - - /* Is it bogus? */ - if (*val != '/') { - msgConfirm("Mount point must start with a / character"); - return NULL; - } - - /* Is it going to be mounted on root? */ - if (!strcmp(val, "/")) { - if (old) - old->flags |= CHUNK_IS_ROOT; - } - else if (old) - old->flags &= ~CHUNK_IS_ROOT; - - safe_free(tmp); - tmp = new_part(val, TRUE, 0); - if (old) { - old->private_data = tmp; - old->private_free = safe_free; - } - return tmp; -} - -/* Get the type of the new partiton */ -static PartType -get_partition_type(void) -{ - char selection[20]; - int i; - - static unsigned char *fs_types[] = { - "FS", - "A file system", - "Swap", - "A swap partition.", - }; - DialogX = 7; - DialogY = 8; - i = dialog_menu("Please choose a partition type", - "If you want to use this partition for swap space, select Swap.\n" - "If you want to put a filesystem on it, choose FS.", - -1, -1, 2, 2, fs_types, selection, NULL, NULL); - DialogX = DialogY = 0; - if (!i) { - if (!strcmp(selection, "FS")) - return PART_FILESYSTEM; - else if (!strcmp(selection, "Swap")) - return PART_SWAP; - } - return PART_NONE; -} - -/* If the user wants a special newfs command for this, set it */ -static void -getNewfsCmd(PartInfo *p) -{ - char *val; - - val = msgGetInput(p->newfs_cmd, - "Please enter the newfs command and options you'd like to use in\n" - "creating this file system."); - if (val) - sstrncpy(p->newfs_cmd, val, NEWFS_CMD_MAX); -} - -#define MAX_MOUNT_NAME 12 - -#define PART_PART_COL 0 -#define PART_MOUNT_COL 8 -#define PART_SIZE_COL (PART_MOUNT_COL + MAX_MOUNT_NAME + 3) -#define PART_NEWFS_COL (PART_SIZE_COL + 7) -#define PART_OFF 38 - -#define TOTAL_AVAIL_LINES (10) -#define PSLICE_SHOWABLE (4) - - -/* stick this all up on the screen */ -static void -print_label_chunks(void) -{ - int i, j, srow, prow, pcol; - int sz; - char clrmsg[80]; - int ChunkPartStartRow; - WINDOW *ChunkWin; - - /********************************************************/ - /*** These values are for controling screen resources ***/ - /*** Each label line holds up to 2 labels, so beware! ***/ - /*** strategy will be to try to always make sure the ***/ - /*** highlighted label is in the active display area. ***/ - /********************************************************/ - int pslice_max, label_max; - int pslice_count, label_count, label_focus_found, pslice_focus_found; - - attrset(A_REVERSE); - mvaddstr(0, 25, "FreeBSD Disklabel Editor"); - attrset(A_NORMAL); - - /*** Count the number of parition slices ***/ - pslice_count = 0; - for (i = 0; label_chunk_info[i].c ; i++) { - if (label_chunk_info[i].type == PART_SLICE) - ++pslice_count; - } - pslice_max = pslice_count; - - /*** 4 line max for partition slices ***/ - if (pslice_max > PSLICE_SHOWABLE) { - pslice_max = PSLICE_SHOWABLE; - } - ChunkPartStartRow = CHUNK_SLICE_START_ROW + 3 + pslice_max; - - /*** View partition slices modulo pslice_max ***/ - label_max = TOTAL_AVAIL_LINES - pslice_max; - - for (i = 0; i < 2; i++) { - mvaddstr(ChunkPartStartRow - 2, PART_PART_COL + (i * PART_OFF), "Part"); - mvaddstr(ChunkPartStartRow - 1, PART_PART_COL + (i * PART_OFF), "----"); - - mvaddstr(ChunkPartStartRow - 2, PART_MOUNT_COL + (i * PART_OFF), "Mount"); - mvaddstr(ChunkPartStartRow - 1, PART_MOUNT_COL + (i * PART_OFF), "-----"); - - mvaddstr(ChunkPartStartRow - 2, PART_SIZE_COL + (i * PART_OFF) + 2, "Size"); - mvaddstr(ChunkPartStartRow - 1, PART_SIZE_COL + (i * PART_OFF) + 2, "----"); - - mvaddstr(ChunkPartStartRow - 2, PART_NEWFS_COL + (i * PART_OFF), "Newfs"); - mvaddstr(ChunkPartStartRow - 1, PART_NEWFS_COL + (i * PART_OFF), "-----"); - } - srow = CHUNK_SLICE_START_ROW; - prow = 0; - pcol = 0; - - /*** these variables indicate that the focused item is shown currently ***/ - label_focus_found = 0; - pslice_focus_found = 0; - - label_count = 0; - pslice_count = 0; - mvprintw(CHUNK_SLICE_START_ROW - 1, 0, " "); - mvprintw(CHUNK_SLICE_START_ROW + pslice_max, 0, " "); - - ChunkWin = newwin(CHUNK_ROW_MAX - ChunkPartStartRow, 76, ChunkPartStartRow, 0); - - wclear(ChunkWin); - /*** wrefresh(ChunkWin); ***/ - - for (i = 0; label_chunk_info[i].c; i++) { - /* Is it a slice entry displayed at the top? */ - if (label_chunk_info[i].type == PART_SLICE) { - /*** This causes the new pslice to replace the previous display ***/ - /*** focus must remain on the most recently active pslice ***/ - if (pslice_count == pslice_max) { - if (pslice_focus_found) { - /*** This is where we can mark the more following ***/ - attrset(A_BOLD); - mvprintw(CHUNK_SLICE_START_ROW + pslice_max, 0, "***MORE***"); - attrset(A_NORMAL); - continue; - } - else { - /*** this is where we set the more previous ***/ - attrset(A_BOLD); - mvprintw(CHUNK_SLICE_START_ROW - 1, 0, "***MORE***"); - attrset(A_NORMAL); - pslice_count = 0; - srow = CHUNK_SLICE_START_ROW; - } - } - - sz = space_free(label_chunk_info[i].c); - if (i == here) - attrset(ATTR_SELECTED); - if (i == pslice_focus) - pslice_focus_found = -1; - - mvprintw(srow++, 0, - "Disk: %s\tPartition name: %s\tFree: %d blocks (%dMB)", - label_chunk_info[i].c->disk->name, label_chunk_info[i].c->name, - sz, (sz / ONE_MEG)); - attrset(A_NORMAL); - clrtoeol(); - move(0, 0); - /*** refresh(); ***/ - ++pslice_count; - } - /* Otherwise it's a DOS, swap or filesystem entry in the Chunk window */ - else { - char onestr[PART_OFF], num[10], *mountpoint, *newfs; - - /* - * We copy this into a blank-padded string so that it looks like - * a solid bar in reverse-video - */ - memset(onestr, ' ', PART_OFF - 1); - onestr[PART_OFF - 1] = '\0'; - - /*** Track how many labels have been displayed ***/ - if (label_count == ((label_max - 1 ) * 2)) { - if (label_focus_found) { - continue; - } - else { - label_count = 0; - prow = 0; - pcol = 0; - } - } - - /* Go for two columns if we've written one full columns worth */ - /*** if (prow == (CHUNK_ROW_MAX - ChunkPartStartRow)) ***/ - if (label_count == label_max - 1) { - pcol = PART_OFF; - prow = 0; - } - memcpy(onestr + PART_PART_COL, label_chunk_info[i].c->name, strlen(label_chunk_info[i].c->name)); - /* If it's a filesystem, display the mountpoint */ - if (label_chunk_info[i].c->private_data - && (label_chunk_info[i].type == PART_FILESYSTEM || label_chunk_info[i].type == PART_FAT)) - mountpoint = ((PartInfo *)label_chunk_info[i].c->private_data)->mountpoint; - else if (label_chunk_info[i].type == PART_SWAP) - mountpoint = "swap"; - else - mountpoint = "<none>"; - - /* Now display the newfs field */ - if (label_chunk_info[i].type == PART_FAT) - newfs = "DOS"; - else if (label_chunk_info[i].c->private_data && label_chunk_info[i].type == PART_FILESYSTEM) - newfs = ((PartInfo *)label_chunk_info[i].c->private_data)->newfs ? "UFS Y" : "UFS N"; - else if (label_chunk_info[i].type == PART_SWAP) - newfs = "SWAP"; - else - newfs = "*"; - for (j = 0; j < MAX_MOUNT_NAME && mountpoint[j]; j++) - onestr[PART_MOUNT_COL + j] = mountpoint[j]; - snprintf(num, 10, "%4ldMB", label_chunk_info[i].c->size ? label_chunk_info[i].c->size / ONE_MEG : 0); - memcpy(onestr + PART_SIZE_COL, num, strlen(num)); - memcpy(onestr + PART_NEWFS_COL, newfs, strlen(newfs)); - onestr[PART_NEWFS_COL + strlen(newfs)] = '\0'; - if (i == label_focus) { - label_focus_found = -1; - wattrset(ChunkWin, A_BOLD); - } - if (i == here) - wattrset(ChunkWin, ATTR_SELECTED); - - /*** lazy man's way of padding this string ***/ - while (strlen( onestr ) < 37) - strcat(onestr, " "); - - mvwaddstr(ChunkWin, prow, pcol, onestr); - wattrset(ChunkWin, A_NORMAL); - move(0, 0); - ++prow; - ++label_count; - } - } - - /*** this will erase all the extra stuff ***/ - memset(clrmsg, ' ', 37); - clrmsg[37] = '\0'; - - while (pslice_count < pslice_max) { - mvprintw(srow++, 0, clrmsg); - clrtoeol(); - ++pslice_count; - } - while (label_count < (2 * (label_max - 1))) { - mvwaddstr(ChunkWin, prow++, pcol, clrmsg); - ++label_count; - if (prow == (label_max - 1)) { - prow = 0; - pcol = PART_OFF; - } - } - refresh(); - wrefresh(ChunkWin); -} - -static void -print_command_summary(void) -{ - mvprintw(17, 0, "The following commands are valid here (upper or lower case):"); - mvprintw(18, 0, "C = Create D = Delete M = Mount pt."); - if (!RunningAsInit) - mvprintw(18, 49, "W = Write"); - mvprintw(19, 0, "N = Newfs Opts T = Newfs Toggle U = Undo Q = Finish"); - mvprintw(20, 0, "A = Auto Defaults for all!"); - mvprintw(22, 0, "Use F1 or ? to get more help, arrow keys to select."); - move(0, 0); -} - -static void -clear_wins(void) -{ - extern void print_label_chunks(); - clear(); - print_label_chunks(); -} - -static int -diskLabel(Device *dev) -{ - int sz, key = 0; - Boolean labeling; - char *msg = NULL; - PartInfo *p, *oldp; - PartType type; - Device **devs; -#ifdef __alpha__ - int i; -#endif - - label_focus = 0; - pslice_focus = 0; - here = 0; - - devs = deviceFind(NULL, DEVICE_TYPE_DISK); - if (!devs) { - msgConfirm("No disks found!"); - return DITEM_FAILURE; - } - labeling = TRUE; - keypad(stdscr, TRUE); -#ifdef __alpha__ - for (i = 0; devs[i]; i++) { - All_FreeBSD((Disk*) devs[i]->private, 1); - } -#endif - record_label_chunks(devs, dev); - - clear(); - while (labeling) { - char *cp; - - print_label_chunks(); - print_command_summary(); - if (msg) { - attrset(title_attr); mvprintw(23, 0, msg); attrset(A_NORMAL); - clrtoeol(); - beep(); - msg = NULL; - } - else { - move(23, 0); - clrtoeol(); - } - - refresh(); - key = getch(); - switch (toupper(key)) { - int i; - static char _msg[40]; - - case '\014': /* ^L */ - clear_wins(); - break; - - case '\020': /* ^P */ - case KEY_UP: - case '-': - if (here != 0) - --here; - else - while (label_chunk_info[here + 1].c) - ++here; - break; - - case '\016': /* ^N */ - case KEY_DOWN: - case '+': - case '\r': - case '\n': - if (label_chunk_info[here + 1].c) - ++here; - else - here = 0; - break; - - case KEY_HOME: - here = 0; - break; - - case KEY_END: - while (label_chunk_info[here + 1].c) - ++here; - break; - - case KEY_F(1): - case '?': - systemDisplayHelp("partition"); - clear_wins(); - break; - - case 'A': - if (label_chunk_info[here].type != PART_SLICE) { - msg = "You can only do this in a disk slice (at top of screen)"; - break; - } - sz = space_free(label_chunk_info[here].c); - if (sz <= FS_MIN_SIZE) - msg = "Not enough free space to create a new partition in the slice"; - else { - struct chunk *tmp; - int mib[2]; - int physmem; - size_t size, swsize; - char *cp; - Chunk *rootdev, *swapdev, *usrdev, *vardev; - - (void)checkLabels(FALSE, &rootdev, &swapdev, &usrdev, &vardev); - if (!rootdev) { - cp = variable_get(VAR_ROOT_SIZE); - tmp = Create_Chunk_DWIM(label_chunk_info[here].c->disk, label_chunk_info[here].c, - (cp ? atoi(cp) : 32) * ONE_MEG, part, FS_BSDFFS, CHUNK_IS_ROOT); - if (!tmp) { - msgConfirm("Unable to create the root partition. Too big?"); - clear_wins(); - break; - } - tmp->private_data = new_part("/", TRUE, tmp->size); - tmp->private_free = safe_free; - record_label_chunks(devs, dev); - } - - if (!swapdev) { - cp = variable_get(VAR_SWAP_SIZE); - if (cp) - swsize = atoi(cp) * ONE_MEG; - else { - mib[0] = CTL_HW; - mib[1] = HW_PHYSMEM; - size = sizeof physmem; - sysctl(mib, 2, &physmem, &size, (void *)0, (size_t)0); - swsize = 16 * ONE_MEG + (physmem * 2 / 512); - } - tmp = Create_Chunk_DWIM(label_chunk_info[here].c->disk, label_chunk_info[here].c, - swsize, part, FS_SWAP, 0); - if (!tmp) { - msgConfirm("Unable to create the swap partition. Too big?"); - clear_wins(); - break; - } - tmp->private_data = 0; - tmp->private_free = safe_free; - record_label_chunks(devs, dev); - } - - if (!vardev) { - cp = variable_get(VAR_VAR_SIZE); - if (cp) - sz = atoi(cp) * ONE_MEG; - else - sz = variable_get(VAR_NO_USR) - ? space_free(label_chunk_info[here].c) - : VAR_MIN_SIZE * ONE_MEG; - - tmp = Create_Chunk_DWIM(label_chunk_info[here].c->disk, label_chunk_info[here].c, - sz, part, FS_BSDFFS, 0); - if (!tmp) { - msgConfirm("Less than %dMB free for /var - you will need to\n" - "partition your disk manually with a custom install!", - (cp ? atoi(cp) : VAR_MIN_SIZE)); - clear_wins(); - break; - } - tmp->private_data = new_part("/var", TRUE, tmp->size); - tmp->private_free = safe_free; - record_label_chunks(devs, dev); - } - - if (!usrdev && !variable_get(VAR_NO_USR)) { - cp = variable_get(VAR_USR_SIZE); - if (cp) - sz = atoi(cp) * ONE_MEG; - else - sz = space_free(label_chunk_info[here].c); - if (sz) { - if (sz < (USR_MIN_SIZE * ONE_MEG)) { - msgConfirm("Less than %dMB free for /usr - you will need to\n" - "partition your disk manually with a custom install!", USR_MIN_SIZE); - clear_wins(); - break; - } - - tmp = Create_Chunk_DWIM(label_chunk_info[here].c->disk, - label_chunk_info[here].c, - sz, part, FS_BSDFFS, 0); - if (!tmp) { - msgConfirm("Unable to create the /usr partition. Not enough space?\n" - "You will need to partition your disk manually with a custom install!"); - clear_wins(); - break; - } - tmp->private_data = new_part("/usr", TRUE, tmp->size); - tmp->private_free = safe_free; - record_label_chunks(devs, dev); - } - } - - /* At this point, we're reasonably "labelled" */ - if (((cp = variable_get(DISK_LABELLED)) == NULL) || (strcmp(cp, "written"))) - variable_set2(DISK_LABELLED, "yes"); - } - break; - - case 'C': - if (label_chunk_info[here].type != PART_SLICE) { - msg = "You can only do this in a master partition (see top of screen)"; - break; - } - sz = space_free(label_chunk_info[here].c); - if (sz <= FS_MIN_SIZE) { - msg = "Not enough space to create an additional FreeBSD partition"; - break; - } - else { - char *val; - int size; - struct chunk *tmp; - char osize[80]; - u_long flags = 0; - - sprintf(osize, "%d", sz); - DialogX = 3; - DialogY = 2; - val = msgGetInput(osize, - "Please specify the partition size in blocks or append a trailing M for\n" - "megabytes or C for cylinders. %d blocks (%dMB) are free.", - sz, sz / ONE_MEG); - DialogX = DialogY = 0; - if (!val || (size = strtol(val, &cp, 0)) <= 0) { - clear_wins(); - break; - } - - if (*cp) { - if (toupper(*cp) == 'M') - size *= ONE_MEG; - else if (toupper(*cp) == 'C') - size *= (label_chunk_info[here].c->disk->bios_hd * label_chunk_info[here].c->disk->bios_sect); - } - if (size <= FS_MIN_SIZE) { - msgConfirm("The minimum filesystem size is %dMB", FS_MIN_SIZE / ONE_MEG); - clear_wins(); - break; - } - type = get_partition_type(); - if (type == PART_NONE) { - clear_wins(); - beep(); - break; - } - - if (type == PART_FILESYSTEM) { - if ((p = get_mountpoint(NULL)) == NULL) { - clear_wins(); - beep(); - break; - } - else if (!strcmp(p->mountpoint, "/")) - flags |= CHUNK_IS_ROOT; - else - flags &= ~CHUNK_IS_ROOT; - } - else - p = NULL; - - if ((flags & CHUNK_IS_ROOT)) { - if (!(label_chunk_info[here].c->flags & CHUNK_BSD_COMPAT)) { - msgConfirm("This region cannot be used for your root partition as the\n" - "FreeBSD boot code cannot deal with a root partition created\n" - "in that location. Please choose another location or smaller\n" - "size for your root partition and try again!"); - clear_wins(); - break; - } - if (size < (ROOT_MIN_SIZE * ONE_MEG)) { - msgConfirm("Warning: This is smaller than the recommended size for a\n" - "root partition. For a variety of reasons, root\n" - "partitions should usually be at least %dMB in size", ROOT_MIN_SIZE); - } - } - tmp = Create_Chunk_DWIM(label_chunk_info[here].c->disk, - label_chunk_info[here].c, - size, part, - (type == PART_SWAP) ? FS_SWAP : FS_BSDFFS, - flags); - if (!tmp) { - msgConfirm("Unable to create the partition. Too big?"); - clear_wins(); - break; - } - if ((flags & CHUNK_IS_ROOT) && (tmp->flags & CHUNK_PAST_1024)) { - msgConfirm("This region cannot be used for your root partition as it starts\n" - "or extends past the 1024'th cylinder mark and is thus a\n" - "poor location to boot from. Please choose another\n" - "location (or smaller size) for your root partition and try again!"); - Delete_Chunk(label_chunk_info[here].c->disk, tmp); - clear_wins(); - break; - } - if (type != PART_SWAP) { - /* This is needed to tell the newfs -u about the size */ - tmp->private_data = new_part(p->mountpoint, p->newfs, tmp->size); - safe_free(p); - } - else - tmp->private_data = p; - tmp->private_free = safe_free; - if (((cp = variable_get(DISK_LABELLED)) == NULL) || (strcmp(cp, "written"))) - variable_set2(DISK_LABELLED, "yes"); - record_label_chunks(devs, dev); - clear_wins(); - /*** This is where we assign focus to new label so it shows ***/ - { - int i; - label_focus = -1; - for (i = 0; label_chunk_info[i].c; ++i) { - if (label_chunk_info[i].c == tmp) { - label_focus = i; - break; - } - } - if (label_focus == -1) - label_focus = i - 1; - } - } - break; - - case KEY_DC: - case 'D': /* delete */ - if (label_chunk_info[here].type == PART_SLICE) { - msg = MSG_NOT_APPLICABLE; - break; - } - else if (label_chunk_info[here].type == PART_FAT) { - msg = "Use the Disk Partition Editor to delete DOS partitions"; - break; - } - Delete_Chunk(label_chunk_info[here].c->disk, label_chunk_info[here].c); - if (((cp = variable_get(DISK_LABELLED)) == NULL) || (strcmp(cp, "written"))) - variable_set2(DISK_LABELLED, "yes"); - record_label_chunks(devs, dev); - break; - - case 'M': /* mount */ - switch(label_chunk_info[here].type) { - case PART_SLICE: - msg = MSG_NOT_APPLICABLE; - break; - - case PART_SWAP: - msg = "You don't need to specify a mountpoint for a swap partition."; - break; - - case PART_FAT: - case PART_FILESYSTEM: - oldp = label_chunk_info[here].c->private_data; - p = get_mountpoint(label_chunk_info[here].c); - if (p) { - if (!oldp) - p->newfs = FALSE; - if (label_chunk_info[here].type == PART_FAT - && (!strcmp(p->mountpoint, "/") || !strcmp(p->mountpoint, "/usr") - || !strcmp(p->mountpoint, "/var"))) { - msgConfirm("%s is an invalid mount point for a DOS partition!", p->mountpoint); - strcpy(p->mountpoint, "/bogus"); - } - } - if (((cp = variable_get(DISK_LABELLED)) == NULL) || (strcmp(cp, "written"))) - variable_set2(DISK_LABELLED, "yes"); - record_label_chunks(devs, dev); - clear_wins(); - break; - - default: - msgFatal("Bogus partition under cursor???"); - break; - } - break; - - case 'N': /* Set newfs options */ - if (label_chunk_info[here].c->private_data && - ((PartInfo *)label_chunk_info[here].c->private_data)->newfs) - getNewfsCmd(label_chunk_info[here].c->private_data); - else - msg = MSG_NOT_APPLICABLE; - clear_wins(); - break; - - case 'T': /* Toggle newfs state */ - if (label_chunk_info[here].type == PART_FILESYSTEM) { - PartInfo *pi = ((PartInfo *)label_chunk_info[here].c->private_data); - label_chunk_info[here].c->private_data = - new_part(pi ? pi->mountpoint : NULL, pi ? !pi->newfs : TRUE, label_chunk_info[here].c->size); - safe_free(pi); - label_chunk_info[here].c->private_free = safe_free; - if (((cp = variable_get(DISK_LABELLED)) == NULL) || (strcmp(cp, "written"))) - variable_set2(DISK_LABELLED, "yes"); - } - else - msg = MSG_NOT_APPLICABLE; - break; - - case 'U': - clear(); - if ((cp = variable_get(DISK_LABELLED)) && !strcmp(cp, "written")) { - msgConfirm("You've already written out your changes -\n" - "it's too late to undo!"); - } - else if (!msgYesNo("Are you SURE you want to Undo everything?")) { - variable_unset(DISK_PARTITIONED); - variable_unset(DISK_LABELLED); - for (i = 0; devs[i]; i++) { - Disk *d; - - if (!devs[i]->enabled) - continue; - else if ((d = Open_Disk(devs[i]->name)) != NULL) { - Free_Disk(devs[i]->private); - devs[i]->private = d; - diskPartition(devs[i]); - } - } - record_label_chunks(devs, dev); - } - clear_wins(); - break; - - case 'W': - if ((cp = variable_get(DISK_LABELLED)) && !strcmp(cp, "written")) { - msgConfirm("You've already written out your changes - if you\n" - "wish to overwrite them, you'll have to start this\n" - "procedure again from the beginning."); - } - else if (!msgYesNo("WARNING: This should only be used when modifying an EXISTING\n" - "installation. If you are installing FreeBSD for the first time\n" - "then you should simply type Q when you're finished here and your\n" - "changes will be committed in one batch automatically at the end of\n" - "these questions.\n\n" - "Are you absolutely sure you want to do this now?")) { - variable_set2(DISK_LABELLED, "yes"); - diskLabelCommit(NULL); - } - clear_wins(); - break; - - case '|': - if (!msgYesNo("Are you sure you want to go into Wizard mode?\n\n" - "This is an entirely undocumented feature which you are not\n" - "expected to understand!")) { - int i; - Device **devs; - - dialog_clear(); - end_dialog(); - DialogActive = FALSE; - devs = deviceFind(NULL, DEVICE_TYPE_DISK); - if (!devs) { - msgConfirm("Can't find any disk devices!"); - break; - } - for (i = 0; devs[i] && ((Disk *)devs[i]->private); i++) { - if (devs[i]->enabled) - slice_wizard(((Disk *)devs[i]->private)); - } - if (((cp = variable_get(DISK_LABELLED)) == NULL) || (strcmp(cp, "written"))) - variable_set2(DISK_LABELLED, "yes"); - DialogActive = TRUE; - record_label_chunks(devs, dev); - clear_wins(); - } - else - msg = "A most prudent choice!"; - break; - - case '\033': /* ESC */ - case 'Q': - labeling = FALSE; - break; - - default: - beep(); - sprintf(_msg, "Invalid key %d - Type F1 or ? for help", key); - msg = _msg; - break; - } - if (label_chunk_info[here].type == PART_SLICE) - pslice_focus = here; - else - label_focus = here; - } - return DITEM_SUCCESS | DITEM_RESTORE; -} - -static int -diskLabelNonInteractive(Device *dev) -{ - char *cp; - PartType type; - PartInfo *p; - u_long flags = 0; - int i, status; - Device **devs; - Disk *d; - - status = DITEM_SUCCESS; - - cp = variable_get(VAR_DISK); - if (!cp) { - dialog_clear(); - msgConfirm("diskLabel: No disk selected - can't label automatically."); - return DITEM_FAILURE; - } - devs = deviceFind(cp, DEVICE_TYPE_DISK); - if (!devs) { - msgConfirm("diskLabel: No disk device %s found!", cp); - return DITEM_FAILURE; - } - if (dev) - d = dev->private; - else - d = devs[0]->private; -#ifdef __alpha__ - All_FreeBSD(d, 1); -#endif - record_label_chunks(devs, dev); - for (i = 0; label_chunk_info[i].c; i++) { - Chunk *c1 = label_chunk_info[i].c; - - if (label_chunk_info[i].type == PART_SLICE) { - char name[512]; - int entries = 1; - - while (entries) { - snprintf(name, sizeof name, "%s-%d", c1->name, entries); - if ((cp = variable_get(name)) != NULL) { - int sz; - char typ[10], mpoint[50]; - - if (sscanf(cp, "%s %d %s", typ, &sz, mpoint) != 3) { - msgConfirm("For slice entry %s, got an invalid detail entry of: %s", c1->name, cp); - status = DITEM_FAILURE; - continue; - } - else { - Chunk *tmp; - - if (!strcmp(typ, "swap")) { - type = PART_SWAP; - strcpy(mpoint, "SWAP"); - } - else { - type = PART_FILESYSTEM; - if (!strcmp(mpoint, "/")) - flags |= CHUNK_IS_ROOT; - else - flags &= ~CHUNK_IS_ROOT; - } - if (!sz) - sz = space_free(c1); - if (sz > space_free(c1)) { - msgConfirm("Not enough free space to create partition: %s", mpoint); - status = DITEM_FAILURE; - continue; - } - if (!(tmp = Create_Chunk_DWIM(d, c1, sz, part, - (type == PART_SWAP) ? FS_SWAP : FS_BSDFFS, flags))) { - msgConfirm("Unable to create from partition spec: %s. Too big?", cp); - status = DITEM_FAILURE; - break; - } - else { - tmp->private_data = new_part(mpoint, TRUE, sz); - tmp->private_free = safe_free; - status = DITEM_SUCCESS; - } - } - entries++; - } - else { - /* No more matches, leave the loop */ - entries = 0; - } - } - } - else { - /* Must be something we can set a mountpoint for */ - cp = variable_get(c1->name); - if (cp) { - char mpoint[50], do_newfs[8]; - Boolean newfs = FALSE; - - do_newfs[0] = '\0'; - if (sscanf(cp, "%s %s", mpoint, do_newfs) != 2) { - dialog_clear(); - msgConfirm("For slice entry %s, got an invalid detail entry of: %s", c1->name, cp); - status = DITEM_FAILURE; - continue; - } - newfs = toupper(do_newfs[0]) == 'Y' ? TRUE : FALSE; - if (c1->private_data) { - p = c1->private_data; - p->newfs = newfs; - strcpy(p->mountpoint, mpoint); - } - else { - c1->private_data = new_part(mpoint, newfs, 0); - c1->private_free = safe_free; - } - if (!strcmp(mpoint, "/")) - c1->flags |= CHUNK_IS_ROOT; - else - c1->flags &= ~CHUNK_IS_ROOT; - } - } - } - if (status == DITEM_SUCCESS) - variable_set2(DISK_LABELLED, "yes"); - return status; -} diff --git a/usr.sbin/sade/list.h b/usr.sbin/sade/list.h deleted file mode 100644 index 05a9fd56b78d..000000000000 --- a/usr.sbin/sade/list.h +++ /dev/null @@ -1,60 +0,0 @@ -/* - * The new sysinstall program. - * - * This is probably the last attempt in the `sysinstall' line, the next - * generation being slated for what's essentially a complete rewrite. - * - * $Id: list.h,v 1.1 1997/09/16 17:03:58 pst Exp $ - * - * Copyright (c) 1997 FreeBSD, 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, - * verbatim and that no modifications are made prior to this - * point in the file. - * 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 PAUL TRAINA ``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 PAUL TRAINA OR HIS KILLER RATS 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, LIFE 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. - * - */ - -/* The structure */ -typedef struct _qelement { - struct _qelement *q_forw; - struct _qelement *q_back; -} qelement; - -#define INITQUE(Xhead) { \ - (Xhead).q_forw = &(Xhead); \ - (Xhead).q_back = &(Xhead); \ -} - -#define EMPTYQUE(Xhead) \ - ((Xhead).q_forw == &(Xhead)) - -#define INSQUEUE(elem, pred) { \ - register qelement *Xe = (qelement *) (elem); \ - register qelement *Xp = (qelement *) (pred); \ - Xp->q_forw = (Xe->q_forw = (Xe->q_back = Xp)->q_forw)->q_back = Xe; \ -} - -#define REMQUE(elem) { \ - register qelement *Xe = (qelement *) (elem); \ - (Xe->q_back->q_forw = Xe->q_forw)->q_back = Xe->q_back; \ -} diff --git a/usr.sbin/sade/main.c b/usr.sbin/sade/main.c deleted file mode 100644 index 5840896154f2..000000000000 --- a/usr.sbin/sade/main.c +++ /dev/null @@ -1,141 +0,0 @@ -/* - * The new sysinstall program. - * - * This is probably the last attempt in the `sysinstall' line, the next - * generation being slated for what's essentially a complete rewrite. - * - * $Id: main.c,v 1.49 1998/03/10 13:42:02 jkh Exp $ - * - * Copyright (c) 1995 - * Jordan Hubbard. 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, - * verbatim and that no modifications are made prior to this - * point in the file. - * 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 JORDAN HUBBARD ``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 JORDAN HUBBARD OR HIS PETS 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, LIFE 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. - * - */ - -#include "sysinstall.h" -#include <sys/signal.h> -#include <sys/fcntl.h> - -static void -screech(int sig) -{ - msgDebug("\007Signal %d caught! That's bad!\n", sig); - longjmp(BailOut, sig); -} - -int -main(int argc, char **argv) -{ - int choice, scroll, curr, max, status; - - /* Catch fatal signals and complain about them if running as init */ - if (getpid() == 1) { - signal(SIGBUS, screech); - signal(SIGSEGV, screech); - } - - /* We don't work too well when running as non-root anymore */ - if (geteuid() != 0) { - fprintf(stderr, "Error: This utility should only be run as root.\n"); - return 1; - } - - /* Set up whatever things need setting up */ - systemInitialize(argc, argv); - - /* Set default flag and variable values */ - installVarDefaults(NULL); - /* only when multi-user is it reasonable to do this here */ - if (!RunningAsInit) - installEnvironment(); - - if (argc > 1 && !strcmp(argv[1], "-fake")) { - variable_set2(VAR_DEBUG, "YES"); - Fake = TRUE; - msgConfirm("I'll be just faking it from here on out, OK?"); - } - - /* Try to preserve our scroll-back buffer */ - if (OnVTY) { - for (curr = 0; curr < 25; curr++) - putchar('\n'); - } - /* Move stderr aside */ - if (DebugFD) - dup2(DebugFD, 2); - - /* Probe for all relevant devices on the system */ - deviceGetAll(); - - /* First, see if we have any arguments to process (and argv[0] counts if it's not "sysinstall") */ - if (!RunningAsInit) { - int i, start_arg; - - if (!strstr(argv[0], "sysinstall")) - start_arg = 0; - else if (Fake) - start_arg = 2; - else - start_arg = 1; - for (i = start_arg; i < argc; i++) { - if (DITEM_STATUS(dispatchCommand(argv[i])) != DITEM_SUCCESS) - systemShutdown(1); - } - if (argc > start_arg) - systemShutdown(0); - } - else - dispatch_load_file_int(TRUE); - - status = setjmp(BailOut); - if (status) { - msgConfirm("A signal %d was caught - I'm saving what I can and shutting\n" - "If you can reproduce the problem, please turn Debug on in\n" - "the Options menu for the extra information it provides in\n" - "debugging problems like this.", status); - systemShutdown(status); - } - - /* Begin user dialog at outer menu */ - dialog_clear(); - while (1) { - choice = scroll = curr = max = 0; - dmenuOpen(&MenuInitial, &choice, &scroll, &curr, &max, TRUE); - if (getpid() != 1 -#ifdef __alpha__ - || !msgYesNo("Are you sure you wish to exit? The system will halt.") -#else - || !msgYesNo("Are you sure you wish to exit? The system will reboot\n" - "(be sure to remove any floppies from the drives).") -#endif - ) - break; - } - - /* Say goodnight, Gracie */ - systemShutdown(0); - - return 0; /* We should never get here */ -} diff --git a/usr.sbin/sade/menus.c b/usr.sbin/sade/menus.c deleted file mode 100644 index d5da830734f8..000000000000 --- a/usr.sbin/sade/menus.c +++ /dev/null @@ -1,1488 +0,0 @@ -/* - * The new sysinstall program. - * - * This is probably the last program in the `sysinstall' line - the next - * generation being essentially a complete rewrite. - * - * $Id: menus.c,v 1.179 1999/01/06 13:55:12 peter Exp $ - * - * Copyright (c) 1995 - * Jordan Hubbard. 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, - * verbatim and that no modifications are made prior to this - * point in the file. - * 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 JORDAN HUBBARD ``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 JORDAN HUBBARD OR HIS PETS 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, LIFE 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. - * - */ - -#include "sysinstall.h" - -/* Miscellaneous work routines for menus */ -static int -setSrc(dialogMenuItem *self) -{ - Dists |= DIST_SRC; - SrcDists = DIST_SRC_ALL | DIST_SRC_SMAILCF; - return DITEM_SUCCESS | DITEM_REDRAW; -} - -static int -clearSrc(dialogMenuItem *self) -{ - Dists &= ~DIST_SRC; - SrcDists = 0; - return DITEM_SUCCESS | DITEM_REDRAW; -} - -static int -setX11All(dialogMenuItem *self) -{ - XF86Dists = DIST_XF86_ALL; - XF86ServerDists = DIST_XF86_SERVER_ALL; - XF86FontDists = DIST_XF86_FONTS_ALL; - Dists |= DIST_XF86; - return DITEM_SUCCESS | DITEM_REDRAW; -} - -static int -clearX11All(dialogMenuItem *self) -{ - XF86Dists = 0; - XF86ServerDists = 0; - XF86FontDists = 0; - Dists &= ~DIST_XF86; - return DITEM_SUCCESS | DITEM_REDRAW; -} - -static int -setX11Misc(dialogMenuItem *self) -{ - XF86Dists |= DIST_XF86_MISC_ALL; - Dists |= DIST_XF86; - return DITEM_SUCCESS | DITEM_REDRAW; -} - -static int -clearX11Misc(dialogMenuItem *self) -{ - XF86Dists &= ~DIST_XF86_MISC_ALL; - if (!XF86ServerDists && !XF86FontDists) - Dists &= ~DIST_XF86; - return DITEM_SUCCESS | DITEM_REDRAW; -} - -static int -setX11Servers(dialogMenuItem *self) -{ - XF86Dists |= DIST_XF86_SERVER; - XF86ServerDists = DIST_XF86_SERVER_ALL; - return DITEM_SUCCESS | DITEM_REDRAW; -} - -static int -clearX11Servers(dialogMenuItem *self) -{ - XF86Dists &= ~DIST_XF86_SERVER; - XF86ServerDists = 0; - return DITEM_SUCCESS | DITEM_REDRAW; -} - -static int -setX11Fonts(dialogMenuItem *self) -{ - XF86Dists |= DIST_XF86_FONTS; - XF86FontDists = DIST_XF86_FONTS_ALL; - return DITEM_SUCCESS | DITEM_REDRAW; -} - -static int -clearX11Fonts(dialogMenuItem *self) -{ - XF86Dists &= ~DIST_XF86_FONTS; - XF86FontDists = 0; - return DITEM_SUCCESS | DITEM_REDRAW; -} - -#define _IS_SET(dist, set) (((dist) & (set)) == (set)) - -#define IS_DEVELOPER(dist, extra) (_IS_SET(dist, _DIST_DEVELOPER | extra) || \ - _IS_SET(dist, _DIST_DEVELOPER | DIST_DES | extra)) - -#define IS_USER(dist, extra) (_IS_SET(dist, _DIST_USER | extra) || \ - _IS_SET(dist, _DIST_USER | DIST_DES | extra)) - -static int -checkDistDeveloper(dialogMenuItem *self) -{ - return IS_DEVELOPER(Dists, 0) && _IS_SET(SrcDists, DIST_SRC_ALL); -} - -static int -checkDistXDeveloper(dialogMenuItem *self) -{ - return IS_DEVELOPER(Dists, DIST_XF86) && _IS_SET(SrcDists, DIST_SRC_ALL); -} - -static int -checkDistKernDeveloper(dialogMenuItem *self) -{ - return IS_DEVELOPER(Dists, 0) && _IS_SET(SrcDists, DIST_SRC_SYS); -} - -static int -checkDistUser(dialogMenuItem *self) -{ - return IS_USER(Dists, 0); -} - -static int -checkDistXUser(dialogMenuItem *self) -{ - return IS_USER(Dists, DIST_XF86); -} - -static int -checkDistMinimum(dialogMenuItem *self) -{ - return Dists == DIST_BIN; -} - -static int -checkDistEverything(dialogMenuItem *self) -{ - return Dists == DIST_ALL && _IS_SET(SrcDists, DIST_SRC_ALL) && \ - _IS_SET(XF86Dists, DIST_XF86_ALL) && \ - _IS_SET(XF86ServerDists, DIST_XF86_SERVER_ALL) && \ - _IS_SET(XF86FontDists, DIST_XF86_FONTS_ALL); -} - -static int -DESFlagCheck(dialogMenuItem *item) -{ - return DESDists; -} - -static int -srcFlagCheck(dialogMenuItem *item) -{ - return SrcDists; -} - -static int -x11FlagCheck(dialogMenuItem *item) -{ - return Dists & DIST_XF86; -} - -static int -checkTrue(dialogMenuItem *item) -{ - return TRUE; -} - -/* All the system menus go here. - * - * Hardcoded things like version number strings will disappear from - * these menus just as soon as I add the code for doing inline variable - * expansion. - */ - -DMenu MenuIndex = { - DMENU_NORMAL_TYPE, - "Glossary of functions", - "This menu contains an alphabetized index of the top level functions in\n" - "this program (sysinstall). Invoke an option by pressing [ENTER].\n" - "Leave the index page by selecting Cancel [TAB-ENTER].", - "Use PageUp or PageDown to move through this menu faster!", - NULL, - { { "Anon FTP", "Configure anonymous FTP logins.", dmenuVarCheck, configAnonFTP, NULL, "anon_ftp" }, - { "Commit", "Commit any pending actions (dangerous!)", NULL, installCustomCommit }, - { "Console settings", "Customize system console behavior.", NULL, dmenuSubmenu, NULL, &MenuSyscons }, - { "Configure", "The system configuration menu.", NULL, dmenuSubmenu, NULL, &MenuConfigure }, - { "Defaults, Load", "Load default settings.", NULL, dispatch_load_floppy }, - { "Device, Mouse", "The mouse configuration menu.", NULL, dmenuSubmenu, NULL, &MenuMouse }, - { "Disklabel", "The disk Label editor", NULL, diskLabelEditor }, - { "Dists, All", "Root of the distribution tree.", NULL, dmenuSubmenu, NULL, &MenuDistributions }, - { "Dists, Basic", "Basic FreeBSD distribution menu.", NULL, dmenuSubmenu, NULL, &MenuSubDistributions }, - { "Dists, DES", "DES distribution menu.", NULL, dmenuSubmenu, NULL, &MenuDESDistributions }, - { "Dists, Developer", "Select developer's distribution.", checkDistDeveloper, distSetDeveloper }, - { "Dists, Src", "Src distribution menu.", NULL, dmenuSubmenu, NULL, &MenuSrcDistributions }, - { "Dists, X Developer", "Select X developer's distribution.", checkDistXDeveloper, distSetXDeveloper }, - { "Dists, Kern Developer", "Select kernel developer's distribution.", checkDistKernDeveloper, distSetKernDeveloper }, - { "Dists, User", "Select average user distribution.", checkDistUser, distSetUser }, - { "Dists, X User", "Select average X user distribution.", checkDistXUser, distSetXUser }, - { "Distributions, Adding", "Installing additional distribution sets", NULL, distExtractAll }, - { "Distributions, XFree86","XFree86 distribution menu.", NULL, distSetXF86 }, - { "Documentation", "Installation instructions, README, etc.", NULL, dmenuSubmenu, NULL, &MenuDocumentation }, - { "Doc, README", "The distribution README file.", NULL, dmenuDisplayFile, NULL, "README" }, - { "Doc, Hardware", "The distribution hardware guide.", NULL, dmenuDisplayFile, NULL, "HARDWARE" }, - { "Doc, Install", "The distribution installation guide.", NULL, dmenuDisplayFile, NULL, "INSTALL" }, - { "Doc, Copyright", "The distribution copyright notices.", NULL, dmenuDisplayFile, NULL, "COPYRIGHT" }, - { "Doc, Release", "The distribution release notes.", NULL, dmenuDisplayFile, NULL, "RELNOTES" }, - { "Doc, HTML", "The HTML documentation menu.", NULL, docBrowser }, - { "Emergency shell", "Start an Emergency Holographic shell.", NULL, installFixitHoloShell }, - { "Fdisk", "The disk Partition Editor", NULL, diskPartitionEditor }, - { "Fixit", "Repair mode with CDROM or fixit floppy.", NULL, dmenuSubmenu, NULL, &MenuFixit }, - { "FTP sites", "The FTP mirror site listing.", NULL, dmenuSubmenu, NULL, &MenuMediaFTP }, - { "Gateway", "Set flag to route packets between interfaces.", dmenuVarCheck, dmenuToggleVariable, NULL, "gateway=YES" }, - { "HTML Docs", "The HTML documentation menu", NULL, docBrowser }, - { "Install, Novice", "A novice system installation.", NULL, installNovice }, - { "Install, Express", "An express system installation.", NULL, installExpress }, - { "Install, Custom", "The custom installation menu", NULL, dmenuSubmenu, NULL, &MenuInstallCustom }, - { "Label", "The disk Label editor", NULL, diskLabelEditor }, - { "Media", "Top level media selection menu.", NULL, dmenuSubmenu, NULL, &MenuMedia }, - { "Media, Tape", "Select tape installation media.", NULL, mediaSetTape }, - { "Media, NFS", "Select NFS installation media.", NULL, mediaSetNFS }, - { "Media, Floppy", "Select floppy installation media.", NULL, mediaSetFloppy }, - { "Media, CDROM", "Select CDROM installation media.", NULL, mediaSetCDROM }, - { "Media, DOS", "Select DOS installation media.", NULL, mediaSetDOS }, - { "Media, UFS", "Select UFS installation media.", NULL, mediaSetUFS }, - { "Media, FTP", "Select FTP installation media.", NULL, mediaSetFTP }, - { "Media, FTP Passive", "Select passive FTP installation media.", NULL, mediaSetFTPPassive }, - { "Network Interfaces", "Configure network interfaces", NULL, tcpMenuSelect }, - { "Networking Services", "The network services menu.", NULL, dmenuSubmenu, NULL, &MenuNetworking }, - { "NFS, client", "Set NFS client flag.", dmenuVarCheck, dmenuToggleVariable, NULL, "nfs_client_enable=YES" }, - { "NFS, server", "Set NFS server flag.", dmenuVarCheck, configNFSServer, NULL, "nfs_server_enable=YES" }, - { "NTP Menu", "The NTP configuration menu.", NULL, dmenuSubmenu, NULL, &MenuNTP }, - { "Options", "The options editor.", NULL, optionsEditor }, - { "Packages", "The packages collection", NULL, configPackages }, - { "Partition", "The disk Slice (PC-style partition) Editor", NULL, diskPartitionEditor }, - { "PCNFSD", "Run authentication server for PC-NFS.", dmenuVarCheck, configPCNFSD, NULL, "pcnfsd" }, - { "Register", "Register yourself or company as a FreeBSD user.", dmenuVarCheck, configRegister, NULL, "registered" }, - { "Root Password", "Set the system manager's password.", NULL, dmenuSystemCommand, NULL, "passwd root" }, - { "Root Password", "Set the system manager's password.", NULL, dmenuSystemCommand, NULL, "passwd root" }, - { "Router", "Select routing daemon (default: routed)", NULL, configRouter, NULL, "router" }, - { "Syscons", "The system console configuration menu.", NULL, dmenuSubmenu, NULL, &MenuSyscons }, - { "Syscons, Font", "The console screen font.", NULL, dmenuSubmenu, NULL, &MenuSysconsFont }, - { "Syscons, Keymap", "The console keymap configuration menu.", NULL, dmenuSubmenu, NULL, &MenuSysconsKeymap }, - { "Syscons, Keyrate", "The console key rate configuration menu.", NULL, dmenuSubmenu, NULL, &MenuSysconsKeyrate }, - { "Syscons, Saver", "The console screen saver configuration menu.", NULL, dmenuSubmenu, NULL, &MenuSysconsSaver }, - { "Syscons, Screenmap", "The console screenmap configuration menu.", NULL, dmenuSubmenu, NULL, &MenuSysconsScrnmap }, - { "Time Zone", "Set the system's time zone.", NULL, dmenuSystemCommand, NULL, "tzsetup" }, - { "Upgrade", "Upgrade an existing system.", NULL, installUpgrade }, - { "Usage", "Quick start - How to use this menu system.", NULL, dmenuDisplayFile, NULL, "usage" }, - { "User Management", "Add user and group information.", NULL, dmenuSubmenu, NULL, &MenuUsermgmt }, - { "XFree86, Fonts", "XFree86 Font selection menu.", NULL, dmenuSubmenu, NULL, &MenuXF86SelectFonts }, - { "XFree86, Server", "XFree86 Server selection menu.", NULL, dmenuSubmenu, NULL, &MenuXF86SelectServer }, - { "XFree86, PC98 Server", "XFree86 PC98 Server selection menu.", NULL, dmenuSubmenu, NULL, &MenuXF86SelectPC98Server }, - { NULL } }, -}; - -/* The initial installation menu */ -DMenu MenuInitial = { - DMENU_NORMAL_TYPE, - "/stand/sysinstall Main Menu", /* title */ - "Welcome to the FreeBSD installation and configuration tool. Please\n" /* prompt */ - "select one of the options below by using the arrow keys or typing the\n" - "first character of the option name you're interested in. Invoke an\n" - "option by pressing [ENTER] or [TAB-ENTER] to exit the installation.", - "Press F1 for Installation Guide", /* help line */ - "install", /* help file */ - { { "Select" }, - { "Exit Install", NULL, NULL, dmenuExit }, - { "1 Usage", "Quick start - How to use this menu system", NULL, dmenuDisplayFile, NULL, "usage" }, - { "2 Doc", "Installation instructions, README, etc.", NULL, dmenuSubmenu, NULL, &MenuDocumentation }, - { "3 Keymap", "Select keyboard type", NULL, dmenuSubmenu, NULL, &MenuSysconsKeymap }, - { "4 Options", "View/Set various installation options", NULL, optionsEditor }, - { "5 Configure", "Do post-install configuration of FreeBSD", NULL, dmenuSubmenu, NULL, &MenuConfigure }, - { "6 Novice", "Begin a novice installation (for beginners)", NULL, installNovice }, - { "7 Express", "Begin a quick installation (for the impatient)", NULL, installExpress }, - { "8 Custom", "Begin a custom installation (for experts)", NULL, dmenuSubmenu, NULL, &MenuInstallCustom }, - { "9 Fixit", "Enter repair mode with CDROM/floppy or start shell", NULL, dmenuSubmenu, NULL, &MenuFixit }, - { "U Upgrade", "Upgrade an existing system", NULL, installUpgrade }, - { "L Load Config","Load default install configuration", NULL, dispatch_load_floppy }, - { "0 Index", "Glossary of functions", NULL, dmenuSubmenu, NULL, &MenuIndex }, - { NULL } }, -}; - -/* The main documentation menu */ -DMenu MenuDocumentation = { - DMENU_NORMAL_TYPE, - "FreeBSD Documentation Menu", - "If you are at all unsure about the configuration of your hardware\n" - "or are looking to build a system specifically for FreeBSD, read the\n" - "Hardware guide! New users should also read the Install document for\n" - "a step-by-step tutorial on installing FreeBSD. For general information,\n" - "consult the README file.", - "Confused? Press F1 for help.", - "usage", - { { "1 README", "A general description of FreeBSD. Read this!", NULL, dmenuDisplayFile, NULL, "README" }, - { "2 Hardware", "The FreeBSD survival guide for PC hardware.", NULL, dmenuDisplayFile, NULL, "HARDWARE" }, - { "3 Install", "A step-by-step guide to installing FreeBSD.", NULL, dmenuDisplayFile, NULL, "INSTALL" }, - { "4 Copyright", "The FreeBSD Copyright notices.", NULL, dmenuDisplayFile, NULL, "COPYRIGHT" }, - { "5 Release" ,"The release notes for this version of FreeBSD.", NULL, dmenuDisplayFile, NULL, "RELNOTES" }, - { "6 Shortcuts", "Creating shortcuts to sysinstall.", NULL, dmenuDisplayFile, NULL, "shortcuts" }, - { "7 HTML Docs", "Go to the HTML documentation menu (post-install).", NULL, docBrowser }, - { "0 Exit", "Exit this menu (returning to previous)", NULL, dmenuExit }, - { NULL } }, -}; - -DMenu MenuMouseType = { - DMENU_RADIO_TYPE | DMENU_SELECTION_RETURNS, - "Select a protocol type for your mouse", - "If you are not sure, choose \"Auto\". It should always work for bus\n" - "and PS/2 style mice. It may not work for the serial mouse if the mouse\n" - "does not support the PnP standard. But, it won't hurt. Many 2-button\n" - "serial mice are compatible with \"Microsoft\" or \"MouseMan\". 3-button\n" - "serial mice may be compatible with \"MouseSystems\" or \"MouseMan\". If\n" - "the mouse has a wheel, it may be compatible with \"IntelliMouse\".", - NULL, - NULL, - { { "Auto", "Bus mouse, PS/2 style mouse or PnP serial mouse", - dmenuVarCheck, dmenuSetVariable, NULL, VAR_MOUSED_TYPE "=auto" }, - { "GlidePoint", "ALPS GlidePoint pad (serial)", - dmenuVarCheck, dmenuSetVariable, NULL, VAR_MOUSED_TYPE "=glidepoint" }, - { "Hitachi","Hitachi tablet (serial)", - dmenuVarCheck, dmenuSetVariable, NULL, VAR_MOUSED_TYPE "=mmhittab" }, - { "IntelliMouse", "Microsoft IntelliMouse (serial)", - dmenuVarCheck, dmenuSetVariable, NULL, VAR_MOUSED_TYPE "=intellimouse" }, - { "Logitech", "Logitech protocol (old models) (serial)", - dmenuVarCheck, dmenuSetVariable, NULL, VAR_MOUSED_TYPE "=logitech" }, - { "Microsoft", "Microsoft protocol (serial)", - dmenuVarCheck, dmenuSetVariable, NULL, VAR_MOUSED_TYPE "=microsoft" }, - { "MM Series","MM Series protocol (serial)", - dmenuVarCheck, dmenuSetVariable, NULL, VAR_MOUSED_TYPE "=mmseries" }, - { "MouseMan", "Logitech MouseMan/TrackMan models (serial)", - dmenuVarCheck, dmenuSetVariable, NULL, VAR_MOUSED_TYPE "=mouseman" }, - { "MouseSystems", "MouseSystems protocol (serial)", - dmenuVarCheck, dmenuSetVariable, NULL, VAR_MOUSED_TYPE "=mousesystems" }, - { "ThinkingMouse","Kensington ThinkingMouse (serial)", - dmenuVarCheck, dmenuSetVariable, NULL, VAR_MOUSED_TYPE "=thinkingmouse" }, - { NULL } }, -}; - -DMenu MenuMousePort = { - DMENU_RADIO_TYPE | DMENU_SELECTION_RETURNS, - "Select your mouse port from the following menu", - "The built-in pointing device of laptop/notebook computers is usually\n" - "a PS/2 style device.", - NULL, - NULL, - { { "COM1", "Serial mouse on COM1 (/dev/cuaa0)", - dmenuVarCheck, dmenuSetVariable, NULL, VAR_MOUSED_PORT "=/dev/cuaa0" }, - { "COM2", "Serial mouse on COM2 (/dev/cuaa1)", - dmenuVarCheck, dmenuSetVariable, NULL, VAR_MOUSED_PORT "=/dev/cuaa1" }, - { "COM3", "Serial mouse on COM3 (/dev/cuaa2)", - dmenuVarCheck, dmenuSetVariable, NULL, VAR_MOUSED_PORT "=/dev/cuaa2" }, - { "COM4", "Serial mouse on COM4 (/dev/cuaa3)", - dmenuVarCheck, dmenuSetVariable, NULL, VAR_MOUSED_PORT "=/dev/cuaa3" }, - { "BusMouse", "Logitech, ATI or MS bus mouse (/dev/mse0)", - dmenuVarCheck, dmenuSetVariable, NULL, VAR_MOUSED_PORT "=/dev/mse0" }, - { "PS/2", "PS/2 style mouse (/dev/psm0)", - dmenuVarCheck, dmenuSetVariable, NULL, VAR_MOUSED_PORT "=/dev/psm0" }, - { NULL } }, -}; - -DMenu MenuMouse = { - DMENU_NORMAL_TYPE, - "Please configure your mouse", - "You can cut and paste text in the text console by running the mouse\n" - "daemon. Specify a port and a protocol type of your mouse and enable\n" - "the mouse daemon. If you don't want this feature, select 4 to disable\n" - "the daemon.\n" - "Once you've enabled the mouse daemon, you can specify \"/dev/sysmouse\"\n" - "as your mouse device and \"SysMouse\" or \"MouseSystems\" as mouse\n" - "protocol when running the X configuration utility (see Configuration\n" - "menu).", - NULL, - NULL, - { { "1 Type", "Select mouse protocol type", NULL, dmenuSubmenu, NULL, &MenuMouseType }, - { "2 Port", "Select mouse port", NULL, dmenuSubmenu, NULL, &MenuMousePort }, - { "3 Enable", "Test and run the mouse daemon", NULL, mousedTest, NULL, NULL }, - { "4 Disable", "Disable the mouse daemon", NULL, mousedDisable, NULL, NULL }, - { "0 Exit", "Exit this menu (returning to previous)", NULL, dmenuExit }, - { NULL } }, -}; - -DMenu MenuXF86Config = { - DMENU_NORMAL_TYPE | DMENU_SELECTION_RETURNS, - "Please select the XFree86 configuration tool you want to use.", - "The first tool, XF86Setup, is fully graphical and requires the\n" - "VGA16 server in order to work (should have been selected by\n" - "default, but if you de-selected it then you won't be able to\n" - "use this fancy setup tool). The second tool, xf86config, is\n" - "a more simplistic shell-script based tool and less friendly to\n" - "new users, but it may work in situations where the fancier one\n" - "does not.", - "Press F1 to read the XFree86 release notes for FreeBSD", - "XF86", - { { "XF86Setup", "Fully graphical XFree86 configuration tool.", - NULL, dmenuSetVariable, NULL, VAR_XF86_CONFIG "=XF86Setup" }, - { "xf86config", "Shell-script based XFree86 configuration tool.", - NULL, dmenuSetVariable, NULL, VAR_XF86_CONFIG "=xf86config" }, - { "XF98Setup", "Fully graphical XFree86 configuration tool (PC98).", - NULL, dmenuSetVariable, NULL, VAR_XF86_CONFIG "=XF98Setup" }, - { NULL } }, -}; - -DMenu MenuMediaCDROM = { - DMENU_NORMAL_TYPE | DMENU_SELECTION_RETURNS, - "Choose a CDROM type", - "FreeBSD can be installed directly from a CDROM containing a valid\n" - "FreeBSD distribution. If you are seeing this menu it is because\n" - "more than one CDROM drive was found on your system. Please select one\n" - "of the following CDROM drives as your installation drive.", - "Press F1 to read the installation guide", - "install", - { { NULL } }, -}; - -DMenu MenuMediaFloppy = { - DMENU_NORMAL_TYPE | DMENU_SELECTION_RETURNS, - "Choose a Floppy drive", - "You have more than one floppy drive. Please chose which drive\n" - "you would like to use.", - NULL, - NULL, - { { NULL } }, -}; - -DMenu MenuMediaDOS = { - DMENU_NORMAL_TYPE | DMENU_SELECTION_RETURNS, - "Choose a DOS partition", - "FreeBSD can be installed directly from a DOS partition\n" - "assuming, of course, that you have copied the relevant\n" - "distributions into your DOS partition before starting this\n" - "installation. If this is not the case then you should reboot\n" - "DOS at this time and copy the distributions you wish to install\n" - "into a \"FREEBSD\" subdirectory on one of your DOS partitions.\n" - "Otherwise, please select the DOS partition containing the FreeBSD\n" - "distribution files.", - "Press F1 to read the installation guide", - "install", - { { NULL } }, -}; - -DMenu MenuMediaFTP = { - DMENU_NORMAL_TYPE | DMENU_SELECTION_RETURNS, - "Please select a FreeBSD FTP distribution site", - "Please select the site closest to you or \"other\" if you'd like to\n" - "specify a different choice. Also note that not every site listed here\n" - "carries more than the base distribution kits. Only the Primary site is\n" - "guaranteed to carry the full range of possible distributions.", - "Select a site that's close!", - "install", - { { "Primary Site", "ftp.freebsd.org", NULL, dmenuSetVariable, NULL, - VAR_FTP_PATH "=ftp://ftp.freebsd.org/pub/FreeBSD/" }, - { "URL", "Specify some other ftp site by URL", NULL, dmenuSetVariable, NULL, - VAR_FTP_PATH "=other" }, - { "3.0 SNAP Server", "current.freebsd.org", NULL, dmenuSetVariable, NULL, - VAR_FTP_PATH "=ftp://current.freebsd.org/pub/FreeBSD/" }, - { "2.2 SNAP Server", "releng22.freebsd.org", NULL, dmenuSetVariable, NULL, - VAR_FTP_PATH "=ftp://releng22.freebsd.org/pub/FreeBSD/" }, - { "Argentina", "ftp.ar.freebsd.org", NULL, dmenuSetVariable, NULL, - VAR_FTP_PATH "=ftp://ftp.ar.freebsd.org/pub/FreeBSD/" }, - { "Australia", "ftp.au.freebsd.org", NULL, dmenuSetVariable, NULL, - VAR_FTP_PATH "=ftp://ftp.au.freebsd.org/pub/FreeBSD/" }, - { "Australia #2", "ftp2.au.freebsd.org", NULL, dmenuSetVariable, NULL, - VAR_FTP_PATH "=ftp://ftp2.au.freebsd.org/pub/FreeBSD/" }, - { "Australia #3", "ftp3.au.freebsd.org", NULL, dmenuSetVariable, NULL, - VAR_FTP_PATH "=ftp://ftp3.au.freebsd.org/pub/FreeBSD/" }, - { "Australia #4", "ftp4.au.freebsd.org", NULL, dmenuSetVariable, NULL, - VAR_FTP_PATH "=ftp://ftp4.au.freebsd.org/pub/FreeBSD/" }, - { "Australia #5", "ftp5.au.freebsd.org", NULL, dmenuSetVariable, NULL, - VAR_FTP_PATH "=ftp://ftp5.au.freebsd.org/pub/FreeBSD/" }, - { "Brazil", "ftp.br.freebsd.org", NULL, dmenuSetVariable, NULL, - VAR_FTP_PATH "=ftp://ftp.br.freebsd.org/pub/FreeBSD/" }, - { "Brazil #2", "ftp2.br.freebsd.org", NULL, dmenuSetVariable, NULL, - VAR_FTP_PATH "=ftp://ftp2.br.freebsd.org/pub/FreeBSD/" }, - { "Brazil #3", "ftp3.br.freebsd.org", NULL, dmenuSetVariable, NULL, - VAR_FTP_PATH "=ftp://ftp3.br.freebsd.org/pub/FreeBSD/" }, - { "Brazil #4", "ftp4.br.freebsd.org", NULL, dmenuSetVariable, NULL, - VAR_FTP_PATH "=ftp://ftp4.br.freebsd.org/pub/FreeBSD/" }, - { "Brazil #5", "ftp5.br.freebsd.org", NULL, dmenuSetVariable, NULL, - VAR_FTP_PATH "=ftp://ftp5.br.freebsd.org/pub/FreeBSD/" }, - { "Brazil #6", "ftp6.br.freebsd.org", NULL, dmenuSetVariable, NULL, - VAR_FTP_PATH "=ftp://ftp6.br.freebsd.org/pub/FreeBSD/" }, - { "Brazil #7", "ftp7.br.freebsd.org", NULL, dmenuSetVariable, NULL, - VAR_FTP_PATH "=ftp://ftp7.br.freebsd.org/pub/FreeBSD/" }, - { "Canada", "ftp.ca.freebsd.org", NULL, dmenuSetVariable, NULL, - VAR_FTP_PATH "=ftp://ftp.ca.freebsd.org/pub/FreeBSD/" }, - { "Czech Republic", "ftp.cz.freebsd.org", NULL, dmenuSetVariable, NULL, - VAR_FTP_PATH "=ftp://ftp.cz.freebsd.org/pub/FreeBSD/" }, - { "Denmark", "ftp.dk.freebsd.org", NULL, dmenuSetVariable, NULL, - VAR_FTP_PATH "=ftp://ftp.dk.freebsd.org/pub/FreeBSD/" }, - { "Denmark #2", "ftp2.dk.freebsd.org", NULL, dmenuSetVariable, NULL, - VAR_FTP_PATH "=ftp://ftp2.dk.freebsd.org/pub/FreeBSD/" }, - { "Estonia", "ftp.ee.freebsd.org", NULL, dmenuSetVariable, NULL, - VAR_FTP_PATH "=ftp://ftp.ee.freebsd.org/pub/FreeBSD/" }, - { "Finland", "ftp.fi.freebsd.org", NULL, dmenuSetVariable, NULL, - VAR_FTP_PATH "=ftp://ftp.fi.freebsd.org/pub/FreeBSD/" }, - { "France", "ftp.fr.freebsd.org", NULL, dmenuSetVariable, NULL, - VAR_FTP_PATH "=ftp://ftp.fr.freebsd.org/pub/FreeBSD/" }, - { "France #2", "ftp2.fr.freebsd.org", NULL, dmenuSetVariable, NULL, - VAR_FTP_PATH "=ftp://ftp2.fr.freebsd.org/pub/FreeBSD/" }, - { "Germany", "ftp.de.freebsd.org", NULL, dmenuSetVariable, NULL, - VAR_FTP_PATH "=ftp://ftp.de.freebsd.org/pub/FreeBSD/" }, - { "Germany #2", "ftp2.de.freebsd.org", NULL, dmenuSetVariable, NULL, - VAR_FTP_PATH "=ftp://ftp2.de.freebsd.org/pub/FreeBSD/" }, - { "Germany #3", "ftp3.de.freebsd.org", NULL, dmenuSetVariable, NULL, - VAR_FTP_PATH "=ftp://ftp3.de.freebsd.org/pub/FreeBSD/" }, - { "Germany #4", "ftp4.de.freebsd.org", NULL, dmenuSetVariable, NULL, - VAR_FTP_PATH "=ftp://ftp4.de.freebsd.org/pub/FreeBSD/" }, - { "Germany #5", "ftp5.de.freebsd.org", NULL, dmenuSetVariable, NULL, - VAR_FTP_PATH "=ftp://ftp5.de.freebsd.org/pub/FreeBSD/" }, - { "Germany #6", "ftp6.de.freebsd.org", NULL, dmenuSetVariable, NULL, - VAR_FTP_PATH "=ftp://ftp6.de.freebsd.org/pub/FreeBSD/" }, - { "Germany #7", "ftp7.de.freebsd.org", NULL, dmenuSetVariable, NULL, - VAR_FTP_PATH "=ftp://ftp7.de.freebsd.org/pub/FreeBSD/" }, - { "Holland", "ftp.nl.freebsd.org", NULL, dmenuSetVariable, NULL, - VAR_FTP_PATH "=ftp://ftp.nl.freebsd.org/pub/FreeBSD/" }, - { "Hong Kong", "ftp.hk.super.net", NULL, dmenuSetVariable, NULL, - VAR_FTP_PATH "=ftp://ftp.hk.super.net/pub/FreeBSD/" }, - { "Iceland", "ftp.is.freebsd.org", NULL, dmenuSetVariable, NULL, - VAR_FTP_PATH "=ftp://ftp.is.freebsd.org/pub/FreeBSD/" }, - { "Ireland", "ftp.ie.freebsd.org", NULL, dmenuSetVariable, NULL, - VAR_FTP_PATH "=ftp://ftp.ie.freebsd.org/pub/FreeBSD/" }, - { "Israel", "ftp.il.freebsd.org", NULL, dmenuSetVariable, NULL, - VAR_FTP_PATH "=ftp://ftp.il.freebsd.org/pub/FreeBSD/" }, - { "Israel #2", "ftp2.il.freebsd.org", NULL, dmenuSetVariable, NULL, - VAR_FTP_PATH "=ftp://ftp2.il.freebsd.org/pub/FreeBSD/" }, - { "Japan", "ftp.jp.freebsd.org", NULL, dmenuSetVariable, NULL, - VAR_FTP_PATH "=ftp://ftp.jp.freebsd.org/pub/FreeBSD/" }, - { "Japan #2", "ftp2.jp.freebsd.org", NULL, dmenuSetVariable, NULL, - VAR_FTP_PATH "=ftp://ftp2.jp.freebsd.org/pub/FreeBSD/" }, - { "Japan #3", "ftp3.jp.freebsd.org", NULL, dmenuSetVariable, NULL, - VAR_FTP_PATH "=ftp://ftp3.jp.freebsd.org/pub/FreeBSD/" }, - { "Japan #4", "ftp4.jp.freebsd.org", NULL, dmenuSetVariable, NULL, - VAR_FTP_PATH "=ftp://ftp4.jp.freebsd.org/pub/FreeBSD/" }, - { "Japan #5", "ftp5.jp.freebsd.org", NULL, dmenuSetVariable, NULL, - VAR_FTP_PATH "=ftp://ftp5.jp.freebsd.org/pub/FreeBSD/" }, - { "Japan #6", "ftp6.jp.freebsd.org", NULL, dmenuSetVariable, NULL, - VAR_FTP_PATH "=ftp://ftp6.jp.freebsd.org/pub/FreeBSD/" }, - { "Korea", "ftp.kr.freebsd.org", NULL, dmenuSetVariable, NULL, - VAR_FTP_PATH "=ftp://ftp.kr.freebsd.org/pub/FreeBSD/" }, - { "Korea #2", "ftp2.kr.freebsd.org", NULL, dmenuSetVariable, NULL, - VAR_FTP_PATH "=ftp://ftp2.kr.freebsd.org/pub/FreeBSD/" }, - { "Korea #3", "ftp3.kr.freebsd.org", NULL, dmenuSetVariable, NULL, - VAR_FTP_PATH "=ftp://ftp3.kr.freebsd.org/pub/FreeBSD/" }, - { "Korea #4", "ftp4.kr.freebsd.org", NULL, dmenuSetVariable, NULL, - VAR_FTP_PATH "=ftp://ftp4.kr.freebsd.org/pub/FreeBSD/" }, - { "Korea #5", "ftp5.kr.freebsd.org", NULL, dmenuSetVariable, NULL, - VAR_FTP_PATH "=ftp://ftp5.kr.freebsd.org/pub/FreeBSD/" }, - { "Poland", "ftp.pl.freebsd.org", NULL, dmenuSetVariable, NULL, - VAR_FTP_PATH "=ftp://ftp.pl.freebsd.org/pub/FreeBSD/" }, - { "Portugal", "ftp.pt.freebsd.org", NULL, dmenuSetVariable, NULL, - VAR_FTP_PATH "=ftp://ftp.pt.freebsd.org/pub/misc/FreeBSD/" }, - { "Portugal #2", "ftp2.pt.freebsd.org", NULL, dmenuSetVariable, NULL, - VAR_FTP_PATH "=ftp://ftp2.pt.freebsd.org/pub/FreeBSD/" }, - { "Russia", "ftp.ru.freebsd.org", NULL, dmenuSetVariable, NULL, - VAR_FTP_PATH "=ftp://ftp.ru.freebsd.org/pub/FreeBSD/" }, - { "Russia #2", "ftp2.ru.freebsd.org", NULL, dmenuSetVariable, NULL, - VAR_FTP_PATH "=ftp://ftp2.ru.freebsd.org/pub/FreeBSD/" }, - { "Russia #3", "ftp3.ru.freebsd.org", NULL, dmenuSetVariable, NULL, - VAR_FTP_PATH "=ftp://ftp3.ru.freebsd.org/pub/FreeBSD/" }, - { "Russia #4", "ftp4.ru.freebsd.org", NULL, dmenuSetVariable, NULL, - VAR_FTP_PATH "=ftp://ftp4.ru.freebsd.org/pub/FreeBSD/" }, - { "South Africa", "ftp.za.freebsd.org", NULL, dmenuSetVariable, NULL, - VAR_FTP_PATH "=ftp://ftp.za.freebsd.org/pub/FreeBSD/" }, - { "South Africa #2", "ftp2.za.freebsd.org", NULL, dmenuSetVariable, NULL, - VAR_FTP_PATH "=ftp://ftp2.za.freebsd.org/pub/FreeBSD/" }, - { "South Africa #3", "ftp3.za.freebsd.org", NULL, dmenuSetVariable, NULL, - VAR_FTP_PATH "=ftp://ftp3.za.freebsd.org/pub/FreeBSD/" }, - { "South Africa #4", "ftp4.za.freebsd.org", NULL, dmenuSetVariable, NULL, - VAR_FTP_PATH "=ftp://ftp4.za.freebsd.org/pub/FreeBSD/" }, - { "Sweden", "ftp.se.freebsd.org", NULL, dmenuSetVariable, NULL, - VAR_FTP_PATH "=ftp://ftp.se.freebsd.org/pub/FreeBSD/" }, - { "Sweden #2", "ftp2.se.freebsd.org", NULL, dmenuSetVariable, NULL, - VAR_FTP_PATH "=ftp://ftp2.se.freebsd.org/pub/FreeBSD/" }, - { "Sweden #3", "ftp3.se.freebsd.org", NULL, dmenuSetVariable, NULL, - VAR_FTP_PATH "=ftp://ftp3.se.freebsd.org/pub/FreeBSD/" }, - { "Taiwan", "ftp.tw.freebsd.org", NULL, dmenuSetVariable, NULL, - VAR_FTP_PATH "=ftp://ftp.tw.freebsd.org/pub/FreeBSD" }, - { "Taiwan #2", "ftp2.tw.freebsd.org", NULL, dmenuSetVariable, NULL, - VAR_FTP_PATH "=ftp://ftp2.tw.freebsd.org/pub/FreeBSD" }, - { "Taiwan #3", "ftp3.tw.freebsd.org", NULL, dmenuSetVariable, NULL, - VAR_FTP_PATH "=ftp://ftp3.tw.freebsd.org/pub/FreeBSD/" }, - { "Thailand", "ftp.nectec.or.th", NULL, dmenuSetVariable, NULL, - VAR_FTP_PATH "=ftp://ftp.nectec.or.th/pub/mirrors/FreeBSD/" }, - { "UK", "ftp.uk.freebsd.org", NULL, dmenuSetVariable, NULL, - VAR_FTP_PATH "=ftp://ftp.uk.freebsd.org/pub/FreeBSD/" }, - { "UK #2", "ftp2.uk.freebsd.org", NULL, dmenuSetVariable, NULL, - VAR_FTP_PATH "=ftp://ftp2.uk.freebsd.org/pub/FreeBSD/" }, - { "UK #3", "ftp3.uk.freebsd.org", NULL, dmenuSetVariable, NULL, - VAR_FTP_PATH "=ftp://ftp3.uk.freebsd.org/pub/FreeBSD/" }, - { "UK #4", "ftp4.uk.freebsd.org", NULL, dmenuSetVariable, NULL, - VAR_FTP_PATH "=ftp://ftp4.uk.freebsd.org/pub/FreeBSD/" }, - { "USA", "ftp.freebsd.org", NULL, dmenuSetVariable, NULL, - VAR_FTP_PATH "=ftp://ftp.freebsd.org/pub/FreeBSD/" }, - { "USA #2", "ftp2.freebsd.org", NULL, dmenuSetVariable, NULL, - VAR_FTP_PATH "=ftp://ftp2.freebsd.org/pub/FreeBSD/" }, - { "USA #3", "ftp3.freebsd.org", NULL, dmenuSetVariable, NULL, - VAR_FTP_PATH "=ftp://ftp3.freebsd.org/pub/FreeBSD/" }, - { "USA #4", "ftp4.freebsd.org", NULL, dmenuSetVariable, NULL, - VAR_FTP_PATH "=ftp://ftp4.freebsd.org/pub/FreeBSD/" }, - { "USA #5", "ftp5.freebsd.org", NULL, dmenuSetVariable, NULL, - VAR_FTP_PATH "=ftp://ftp5.freebsd.org/pub/FreeBSD/" }, - { "USA #6", "ftp6.freebsd.org", NULL, dmenuSetVariable, NULL, - VAR_FTP_PATH "=ftp://ftp6.freebsd.org/pub/FreeBSD/" }, - { NULL } } -}; - -DMenu MenuMediaTape = { - DMENU_NORMAL_TYPE | DMENU_SELECTION_RETURNS, - "Choose a tape drive type", - "FreeBSD can be installed from tape drive, though this installation\n" - "method requires a certain amount of temporary storage in addition\n" - "to the space required by the distribution itself (tape drives make\n" - "poor random-access devices, so we extract _everything_ on the tape\n" - "in one pass). If you have sufficient space for this, then you should\n" - "select one of the following tape devices detected on your system.", - "Press F1 to read the installation guide", - "install", - { { NULL } }, -}; - -DMenu MenuNetworkDevice = { - DMENU_NORMAL_TYPE | DMENU_SELECTION_RETURNS, - "Network interface information required", - "If you are using PPP over a serial device, as opposed to a direct\n" - "ethernet connection, then you may first need to dial your Internet\n" - "Service Provider using the ppp utility we provide for that purpose.\n" - "If you're using SLIP over a serial device then the expectation is\n" - "that you have a HARDWIRED connection.\n\n" - "You can also install over a parallel port using a special \"laplink\"\n" - "cable to another machine running a fairly recent (2.0R or later)\n" - "version of FreeBSD.", - "Press F1 to read network configuration manual", - "network_device", - { { NULL } }, -}; - -/* The media selection menu */ -DMenu MenuMedia = { - DMENU_NORMAL_TYPE | DMENU_SELECTION_RETURNS, - "Choose Installation Media", - "FreeBSD can be installed from a variety of different installation\n" - "media, ranging from floppies to an Internet FTP server. If you're\n" - "installing FreeBSD from a supported CDROM drive then this is generally\n" - "the best media to use if you have no overriding reason for using other\n" - "media.", - "Press F1 for more information on the various media types", - "media", - { { "1 CDROM", "Install from a FreeBSD CDROM", NULL, mediaSetCDROM }, - { "2 FTP", "Install from an FTP server", NULL, mediaSetFTPActive }, - { "3 FTP Passive", "Install from an FTP server through a firewall", NULL, mediaSetFTPPassive }, - { "4 DOS", "Install from a DOS partition", NULL, mediaSetDOS }, - { "5 NFS", "Install over NFS", NULL, mediaSetNFS }, - { "6 File System", "Install from an existing filesystem", NULL, mediaSetUFS }, - { "7 Floppy", "Install from a floppy disk set", NULL, mediaSetFloppy }, - { "8 Tape", "Install from SCSI or QIC tape", NULL, mediaSetTape }, - { "9 Options", "Go to the Options screen", NULL, optionsEditor }, - { NULL } }, -}; - -/* The distributions menu */ -DMenu MenuDistributions = { - DMENU_CHECKLIST_TYPE | DMENU_SELECTION_RETURNS, - "Choose Distributions", - "As a convenience, we provide several \"canned\" distribution sets.\n" - "These select what we consider to be the most reasonable defaults for the\n" - "type of system in question. If you would prefer to pick and choose the\n" - "list of distributions yourself, simply select \"Custom\". You can also\n" - "pick a canned distribution set and then fine-tune it with the Custom item.\n\n" - "Choose an item by pressing [SPACE]. When you are finished, chose the Exit\n" - "item or press [ENTER].", - "Press F1 for more information on these options.", - "distributions", - { { "1 Developer", "Full sources, binaries and doc but no games", - checkDistDeveloper, distSetDeveloper }, - { "2 X-Developer", "Same as above, but includes the X Window System", - checkDistXDeveloper, distSetXDeveloper }, - { "3 Kern-Developer", "Full binaries and doc, kernel sources only", - checkDistKernDeveloper, distSetKernDeveloper }, - { "4 User", "Average user - binaries and doc only", - checkDistUser, distSetUser }, - { "5 X-User", "Same as above, but includes the X Window System", - checkDistXUser, distSetXUser }, - { "6 Minimal", "The smallest configuration possible", - checkDistMinimum, distSetMinimum }, - { "7 Custom", "Specify your own distribution set", - NULL, dmenuSubmenu, NULL, &MenuSubDistributions, '>', '>', '>' }, - { "8 All", "All sources and binaries (incl X Window System)", - checkDistEverything, distSetEverything }, - { "9 Clear", "Reset selected distribution list to nothing", - NULL, distReset, NULL, NULL, ' ', ' ', ' ' }, - { "0 Exit", "Exit this menu (returning to previous)", - checkTrue, dmenuExit, NULL, NULL, '<', '<', '<' }, - { NULL } }, -}; - -DMenu MenuSubDistributions = { - DMENU_CHECKLIST_TYPE | DMENU_SELECTION_RETURNS, - "Select the distributions you wish to install.", - "Please check off the distributions you wish to install. At the\n" - "very minimum, this should be \"bin\". WARNING: Do not export the\n" - "DES distribution out of the U.S.! It is for U.S. customers only.", - NULL, - NULL, - { { "bin", "Binary base distribution (required)", - dmenuFlagCheck, dmenuSetFlag, NULL, &Dists, '[', 'X', ']', DIST_BIN }, - { "compat1x", "FreeBSD 1.x binary compatibility", - dmenuFlagCheck, dmenuSetFlag, NULL, &Dists, '[', 'X', ']', DIST_COMPAT1X }, - { "compat20", "FreeBSD 2.0 binary compatibility", - dmenuFlagCheck, dmenuSetFlag, NULL, &Dists, '[', 'X', ']', DIST_COMPAT20 }, - { "compat21", "FreeBSD 2.1 binary compatibility", - dmenuFlagCheck, dmenuSetFlag, NULL, &Dists, '[', 'X', ']', DIST_COMPAT21 }, - { "DES", "DES encryption code - NOT FOR EXPORT!", - DESFlagCheck, distSetDES }, - { "dict", "Spelling checker dictionary files", - dmenuFlagCheck, dmenuSetFlag, NULL, &Dists, '[', 'X', ']', DIST_DICT }, - { "doc", "Miscellaneous FreeBSD online docs", - dmenuFlagCheck, dmenuSetFlag, NULL, &Dists, '[', 'X', ']', DIST_DOC }, - { "games", "Games (non-commercial)", - dmenuFlagCheck, dmenuSetFlag, NULL, &Dists, '[', 'X', ']', DIST_GAMES }, - { "info", "GNU info files", - dmenuFlagCheck, dmenuSetFlag, NULL, &Dists, '[', 'X', ']', DIST_INFO }, - { "man", "System manual pages - recommended", - dmenuFlagCheck, dmenuSetFlag, NULL, &Dists, '[', 'X', ']', DIST_MANPAGES }, - { "catman", "Preformatted system manual pages", - dmenuFlagCheck, dmenuSetFlag, NULL, &Dists, '[', 'X', ']', DIST_CATPAGES }, - { "proflibs", "Profiled versions of the libraries", - dmenuFlagCheck, dmenuSetFlag, NULL, &Dists, '[', 'X', ']', DIST_PROFLIBS }, - { "src", "Sources for everything but DES", - srcFlagCheck, distSetSrc }, - { "ports", "The FreeBSD Ports collection", - dmenuFlagCheck, dmenuSetFlag, NULL, &Dists, '[', 'X', ']', DIST_PORTS }, - { "XFree86", "The XFree86 3.3.3 distribution", - x11FlagCheck, distSetXF86 }, - { "All", "All sources, binaries and X Window System binaries", - NULL, distSetEverything, NULL, NULL, ' ', ' ', ' ' }, - { "Clear", "Reset all of the above", - NULL, distReset, NULL, NULL, ' ', ' ', ' ' }, - { "Exit", "Exit this menu (returning to previous)", - checkTrue, dmenuExit, NULL, NULL, '<', '<', '<' }, - { NULL } }, -}; - -DMenu MenuDESDistributions = { - DMENU_CHECKLIST_TYPE | DMENU_SELECTION_RETURNS, - "Select the encryption facilities you wish to install.", - "Please check off any special DES-based encryption distributions\n" - "you would like to install. Please note that these services are NOT FOR\n" - "EXPORT from the United States. For information on non-U.S. FTP\n" - "distributions of this software, please consult the release notes.", - NULL, - NULL, - { { "des", "Basic DES encryption services", - dmenuFlagCheck, dmenuSetFlag, NULL, &DESDists, '[', 'X', ']', DIST_DES_DES, }, - { "krb", "Kerberos encryption services", - dmenuFlagCheck, dmenuSetFlag, NULL, &DESDists, '[', 'X', ']', DIST_DES_KERBEROS }, - { "skerbero", "Sources for Kerberos IV", - dmenuFlagCheck, dmenuSetFlag, NULL, &DESDists, '[', 'X', ']', DIST_DES_SKERBEROS }, - { "ssecure", "Sources for DES", - dmenuFlagCheck, dmenuSetFlag, NULL, &DESDists, '[', 'X', ']', DIST_DES_SSECURE }, - { "scrypto", "Export controlled crypto sources", - dmenuFlagCheck, dmenuSetFlag, NULL, &DESDists, '[', 'X', ']', DIST_DES_SCRYPTO }, - { "Exit", "Exit this menu (returning to previous)", - checkTrue, dmenuExit, NULL, NULL, '<', '<', '<' }, - { NULL } }, -}; - -DMenu MenuSrcDistributions = { - DMENU_CHECKLIST_TYPE | DMENU_SELECTION_RETURNS , - "Select the sub-components of src you wish to install.", - "Please check off those portions of the FreeBSD source tree\n" - "you wish to install.", - NULL, - NULL, - { { "base", "top-level files in /usr/src", - dmenuFlagCheck, dmenuSetFlag, NULL, &SrcDists, '[', 'X', ']', DIST_SRC_BASE }, - { "contrib", "/usr/src/contrib (contributed software)", - dmenuFlagCheck, dmenuSetFlag, NULL, &SrcDists, '[', 'X', ']', DIST_SRC_CONTRIB }, - { "gnu", "/usr/src/gnu (software from the GNU Project)", - dmenuFlagCheck, dmenuSetFlag, NULL, &SrcDists, '[', 'X', ']', DIST_SRC_GNU }, - { "etc", "/usr/src/etc (miscellaneous system files)", - dmenuFlagCheck, dmenuSetFlag, NULL, &SrcDists, '[', 'X', ']', DIST_SRC_ETC }, - { "games", "/usr/src/games (the obvious!)", - dmenuFlagCheck, dmenuSetFlag, NULL, &SrcDists, '[', 'X', ']', DIST_SRC_GAMES }, - { "include", "/usr/src/include (header files)", - dmenuFlagCheck, dmenuSetFlag, NULL, &SrcDists, '[', 'X', ']', DIST_SRC_INCLUDE }, - { "lib", "/usr/src/lib (system libraries)", - dmenuFlagCheck, dmenuSetFlag, NULL, &SrcDists, '[', 'X', ']', DIST_SRC_LIB }, - { "libexec", "/usr/src/libexec (system programs)", - dmenuFlagCheck, dmenuSetFlag, NULL, &SrcDists, '[', 'X', ']', DIST_SRC_LIBEXEC }, - { "release", "/usr/src/release (release-generation tools)", - dmenuFlagCheck, dmenuSetFlag, NULL, &SrcDists, '[', 'X', ']', DIST_SRC_RELEASE }, - { "bin", "/usr/src/bin (system binaries)", - dmenuFlagCheck, dmenuSetFlag, NULL, &SrcDists, '[', 'X', ']', DIST_SRC_BIN }, - { "sbin", "/usr/src/sbin (system binaries)", - dmenuFlagCheck, dmenuSetFlag, NULL, &SrcDists, '[', 'X', ']', DIST_SRC_SBIN }, - { "share", "/usr/src/share (documents and shared files)", - dmenuFlagCheck, dmenuSetFlag, NULL, &SrcDists, '[', 'X', ']', DIST_SRC_SHARE }, - { "sys", "/usr/src/sys (FreeBSD kernel)", - dmenuFlagCheck, dmenuSetFlag, NULL, &SrcDists, '[', 'X', ']', DIST_SRC_SYS }, - { "ubin", "/usr/src/usr.bin (user binaries)", - dmenuFlagCheck, dmenuSetFlag, NULL, &SrcDists, '[', 'X', ']', DIST_SRC_UBIN }, - { "usbin", "/usr/src/usr.sbin (aux system binaries)", - dmenuFlagCheck, dmenuSetFlag, NULL, &SrcDists, '[', 'X', ']', DIST_SRC_USBIN }, - { "smailcf", "/usr/src/usr.sbin (sendmail config macros)", - dmenuFlagCheck, dmenuSetFlag, NULL, &SrcDists, '[', 'X', ']', DIST_SRC_SMAILCF }, - { "All", "Select all of the above", - NULL, setSrc, NULL, NULL, ' ', ' ', ' ' }, - { "Clear", "Reset all of the above", - NULL, clearSrc, NULL, NULL, ' ', ' ', ' ' }, - { "Exit", "Exit this menu (returning to previous)", - checkTrue, dmenuExit, NULL, NULL, '<', '<', '<' }, - { NULL } }, -}; - -DMenu MenuXF86Select = { - DMENU_NORMAL_TYPE, - "XFree86 3.3.3 Distribution", - "Please select the components you need from the XFree86 3.3.3\n" - "distribution sets.", - "Press F1 to read the XFree86 release notes for FreeBSD", - "XF86", - { { "Basic", "Basic component menu (required)", NULL, dmenuSubmenu, NULL, &MenuXF86SelectCore }, - { "Server", "X server menu", NULL, dmenuSubmenu, NULL, &MenuXF86SelectServer }, - { "Fonts", "Font set menu", NULL, dmenuSubmenu, NULL, &MenuXF86SelectFonts }, - { "All", "Select all XFree86 distribution sets", NULL, setX11All }, - { "Clear", "Reset XFree86 distribution list", NULL, clearX11All }, - { "Exit", "Exit this menu (returning to previous)", checkTrue, dmenuExit, NULL, NULL, '<', '<', '<' }, - { NULL } }, -}; - -DMenu MenuXF86SelectCore = { - DMENU_CHECKLIST_TYPE | DMENU_SELECTION_RETURNS, - "XFree86 3.3.3 base distribution types", - "Please check off the basic XFree86 components you wish to install.\n" - "Bin, lib, and set are recommended for a minimum installaion.", - "Press F1 to read the XFree86 release notes for FreeBSD", - "XF86", - { { "bin", "Client applications and shared libs", - dmenuFlagCheck, dmenuSetFlag, NULL, &XF86Dists, '[', 'X', ']', DIST_XF86_BIN }, - { "cfg", "Configuration files", - dmenuFlagCheck, dmenuSetFlag, NULL, &XF86Dists, '[', 'X', ']', DIST_XF86_CFG }, - { "doc", "READMEs and release notes", - dmenuFlagCheck, dmenuSetFlag, NULL, &XF86Dists, '[', 'X', ']', DIST_XF86_DOC }, - { "html", "HTML documentation files", - dmenuFlagCheck, dmenuSetFlag, NULL, &XF86Dists, '[', 'X', ']', DIST_XF86_HTML }, - { "lib", "Data files needed at runtime", - dmenuFlagCheck, dmenuSetFlag, NULL, &XF86Dists, '[', 'X', ']', DIST_XF86_LIB }, - { "lk98", "Server link kit for PC98 machines", - dmenuFlagCheck, dmenuSetFlag, NULL, &XF86Dists, '[', 'X', ']', DIST_XF86_LKIT98 }, - { "lkit", "Server link kit for all other machines", - dmenuFlagCheck, dmenuSetFlag, NULL, &XF86Dists, '[', 'X', ']', DIST_XF86_LKIT }, - { "man", "Manual pages", - dmenuFlagCheck, dmenuSetFlag, NULL, &XF86Dists, '[', 'X', ']', DIST_XF86_MAN }, - { "prog", "Programmer's header and library files", - dmenuFlagCheck, dmenuSetFlag, NULL, &XF86Dists, '[', 'X', ']', DIST_XF86_PROG }, - { "set", "XFree86 Setup Utility", - dmenuFlagCheck, dmenuSetFlag, NULL, &XF86Dists, '[', 'X', ']', DIST_XF86_SET }, - { "9set", "XFree86 Setup Utility for PC98 machines", - dmenuFlagCheck, dmenuSetFlag, NULL, &XF86Dists, '[', 'X', ']', DIST_XF86_9SET }, - { "sources", "XFree86 3.3.3 standard sources", - dmenuFlagCheck, dmenuSetFlag, NULL, &XF86Dists, '[', 'X', ']', DIST_XF86_SRC }, - { "csources", "XFree86 3.3.3 contrib sources", - dmenuFlagCheck, dmenuSetFlag, NULL, &XF86Dists, '[', 'X', ']', DIST_XF86_CSRC }, - { "All", "Select all of the above", - NULL, setX11Misc, NULL, NULL, ' ', ' ', ' ' }, - { "Clear", "Reset all of the above", - NULL, clearX11Misc, NULL, NULL, ' ', ' ', ' ' }, - { "Exit", "Exit this menu (returning to previous)", - checkTrue, dmenuExit, NULL, NULL, '<', '<', '<' }, - { NULL } }, -}; - -DMenu MenuXF86SelectFonts = { - DMENU_CHECKLIST_TYPE | DMENU_SELECTION_RETURNS , - "Font distribution selection.", - "Please check off the individual font distributions you wish to\n\ -install. At the minimum, you should install the standard\n\ -75 DPI and misc fonts if you're also installing a server\n\ -(these are selected by default).", - "Press F1 to read the XFree86 release notes for FreeBSD", - "XF86", - { { "fnts", "Standard 75 DPI and miscellaneous fonts", - dmenuFlagCheck, dmenuSetFlag, NULL, &XF86FontDists, '[', 'X', ']', DIST_XF86_FONTS_MISC }, - { "f100", "100 DPI fonts", - dmenuFlagCheck, dmenuSetFlag, NULL, &XF86FontDists, '[', 'X', ']', DIST_XF86_FONTS_100 }, - { "fcyr", "Cyrillic Fonts", - dmenuFlagCheck, dmenuSetFlag, NULL, &XF86FontDists, '[', 'X', ']', DIST_XF86_FONTS_CYR }, - { "fscl", "Speedo and Type scalable fonts", - dmenuFlagCheck, dmenuSetFlag, NULL, &XF86FontDists, '[', 'X', ']', DIST_XF86_FONTS_SCALE }, - { "non", "Japanese, Chinese and other non-english fonts", - dmenuFlagCheck, dmenuSetFlag, NULL, &XF86FontDists, '[', 'X', ']', DIST_XF86_FONTS_NON }, - { "server", "Font server", - dmenuFlagCheck, dmenuSetFlag, NULL, &XF86FontDists, '[', 'X', ']', DIST_XF86_FONTS_SERVER }, - { "All", "All fonts", - NULL, setX11Fonts, NULL, NULL, ' ', ' ', ' ' }, - { "Clear", "Reset font selections", - NULL, clearX11Fonts, NULL, NULL, ' ', ' ', ' ' }, - { "Exit", "Exit this menu (returning to previous)", - checkTrue, dmenuExit, NULL, NULL, '<', '<', '<' }, - { NULL } }, -}; - -DMenu MenuXF86SelectServer = { - DMENU_CHECKLIST_TYPE | DMENU_SELECTION_RETURNS, - "X Server selection.", - "Please check off the types of X servers you wish to install.\n" - "If you are unsure as to which server will work for your graphics card,\n" - "it is recommended that try the SVGA or VGA16 servers or, for PC98\n" - "machines, the 9EGC or 9840 servers.", - "Press F1 to read the XFree86 release notes for FreeBSD", - "XF86", - { { "SVGA", "Standard VGA or Super VGA card", - dmenuFlagCheck, dmenuSetFlag, NULL, &XF86ServerDists, '[', 'X', ']', DIST_XF86_SERVER_SVGA }, - { "VGA16", "Standard 16 color VGA card", - dmenuFlagCheck, dmenuSetFlag, NULL, &XF86ServerDists, '[', 'X', ']', DIST_XF86_SERVER_VGA16 }, - { "Mono", "Standard Monochrome card", - dmenuFlagCheck, dmenuSetFlag, NULL, &XF86ServerDists, '[', 'X', ']', DIST_XF86_SERVER_MONO }, - { "8514", "8-bit (256 color) IBM 8514 or compatible card", - dmenuFlagCheck, dmenuSetFlag, NULL, &XF86ServerDists, '[', 'X', ']', DIST_XF86_SERVER_8514 }, - { "AGX", "8-bit AGX card", - dmenuFlagCheck, dmenuSetFlag, NULL, &XF86ServerDists, '[', 'X', ']', DIST_XF86_SERVER_AGX }, - { "I128", "8, 16 and 24-bit #9 Imagine I128 card", - dmenuFlagCheck, dmenuSetFlag, NULL, &XF86ServerDists, '[', 'X', ']', DIST_XF86_SERVER_I128 }, - { "Ma8", "8-bit ATI Mach8 card", - dmenuFlagCheck, dmenuSetFlag, NULL, &XF86ServerDists, '[', 'X', ']', DIST_XF86_SERVER_MACH8 }, - { "Ma32", "8 and 16-bit (65K color) ATI Mach32 card", - dmenuFlagCheck, dmenuSetFlag, NULL, &XF86ServerDists, '[', 'X', ']', DIST_XF86_SERVER_MACH32 }, - { "Ma64", "8 and 16-bit (65K color) ATI Mach64 card", - dmenuFlagCheck, dmenuSetFlag, NULL, &XF86ServerDists, '[', 'X', ']', DIST_XF86_SERVER_MACH64 }, - { "P9K", "8, 16, and 24-bit color Weitek P9000 based boards", - dmenuFlagCheck, dmenuSetFlag, NULL, &XF86ServerDists, '[', 'X', ']', DIST_XF86_SERVER_P9000 }, - { "S3", "8, 16 and 24-bit color S3 based boards", - dmenuFlagCheck, dmenuSetFlag, NULL, &XF86ServerDists, '[', 'X', ']', DIST_XF86_SERVER_S3 }, - { "S3V", "8, 16 and 24-bit color S3 Virge based boards", - dmenuFlagCheck, dmenuSetFlag, NULL, &XF86ServerDists, '[', 'X', ']', DIST_XF86_SERVER_S3V }, - { "W32", "8-bit ET4000/W32, /W32i and /W32p cards", - dmenuFlagCheck, dmenuSetFlag, NULL, &XF86ServerDists, '[', 'X', ']', DIST_XF86_SERVER_W32 }, - { "nest", "A nested server for testing purposes", - dmenuFlagCheck, dmenuSetFlag, NULL, &XF86ServerDists, '[', 'X', ']', DIST_XF86_SERVER_NEST }, - { "PC98", "Select an X server for a NEC PC98 [Submenu]", - NULL, dmenuSubmenu, NULL, &MenuXF86SelectPC98Server, '>', ' ', '>', 0 }, - { "All", "Select all of the above", - NULL, setX11Servers, NULL, NULL, ' ', ' ', ' ' }, - { "Clear", "Reset all of the above", - NULL, clearX11Servers, NULL, NULL, ' ', ' ', ' ' }, - { "Exit", "Exit this menu (returning to previous)", - checkTrue, dmenuExit, NULL, NULL, '<', '<', '<' }, - { NULL } }, -}; - -DMenu MenuXF86SelectPC98Server = { - DMENU_CHECKLIST_TYPE | DMENU_SELECTION_RETURNS, - "PC98 X Server selection.", - "Please check off the types of NEC PC98 X servers you wish to install.\n\ -If you are unsure as to which server will work for your graphics card,\n\ -it is recommended that try the SVGA or VGA16 servers (the VGA16 and\n\ -Mono servers are particularly well-suited to most LCD displays).", - "Press F1 to read the XFree86 release notes for FreeBSD", - "XF86", - { { "9480", "PC98 8-bit (256 color) PEGC-480 card", - dmenuFlagCheck, dmenuSetFlag, NULL, &XF86ServerDists, '[', 'X', ']', DIST_XF86_SERVER_9480 }, - { "9EGC", "PC98 4-bit (16 color) EGC card", - dmenuFlagCheck, dmenuSetFlag, NULL, &XF86ServerDists, '[', 'X', ']', DIST_XF86_SERVER_9EGC }, - { "9GA9", "PC98 GA-968V4/PCI (S3 968) card", - dmenuFlagCheck, dmenuSetFlag, NULL, &XF86ServerDists, '[', 'X', ']', DIST_XF86_SERVER_9GA9 }, - { "9GAN", "PC98 GANB-WAP (cirrus) card", - dmenuFlagCheck, dmenuSetFlag, NULL, &XF86ServerDists, '[', 'X', ']', DIST_XF86_SERVER_9GAN }, - { "9LPW", "PC98 PowerWindowLB (S3) card", - dmenuFlagCheck, dmenuSetFlag, NULL, &XF86ServerDists, '[', 'X', ']', DIST_XF86_SERVER_9LPW }, - { "9MGA", "PC98 MGA (Matrox) card", - dmenuFlagCheck, dmenuSetFlag, NULL, &XF86ServerDists, '[', 'X', ']', DIST_XF86_SERVER_9MGA }, - { "9NKV", "PC98 NKV-NEC (cirrus) card", - dmenuFlagCheck, dmenuSetFlag, NULL, &XF86ServerDists, '[', 'X', ']', DIST_XF86_SERVER_9NKV }, - { "9NS3", "PC98 NEC (S3) card", - dmenuFlagCheck, dmenuSetFlag, NULL, &XF86ServerDists, '[', 'X', ']', DIST_XF86_SERVER_9NS3 }, - { "9SPW", "PC98 SKB-PowerWindow (S3) card", - dmenuFlagCheck, dmenuSetFlag, NULL, &XF86ServerDists, '[', 'X', ']', DIST_XF86_SERVER_9SPW }, - { "9SVG", "PC98 generic SVGA card", - dmenuFlagCheck, dmenuSetFlag, NULL, &XF86ServerDists, '[', 'X', ']', DIST_XF86_SERVER_9SVG }, - { "9TGU", "PC98 Cyber9320 and TGUI9680 cards", - dmenuFlagCheck, dmenuSetFlag, NULL, &XF86ServerDists, '[', 'X', ']', DIST_XF86_SERVER_9TGU }, - { "9WEP", "PC98 WAB-EP (cirrus) card", - dmenuFlagCheck, dmenuSetFlag, NULL, &XF86ServerDists, '[', 'X', ']', DIST_XF86_SERVER_9WEP }, - { "9WS", "PC98 WABS (cirrus) card", - dmenuFlagCheck, dmenuSetFlag, NULL, &XF86ServerDists, '[', 'X', ']', DIST_XF86_SERVER_9WS }, - { "9WSN", "PC98 WSN-A2F (cirrus) card", - dmenuFlagCheck, dmenuSetFlag, NULL, &XF86ServerDists, '[', 'X', ']', DIST_XF86_SERVER_9WSN }, - { "Exit", "Exit this menu (returning to previous)", - checkTrue, dmenuExit, NULL, NULL, '<', '<', '<' }, - { NULL } } -}; - -DMenu MenuDiskDevices = { - DMENU_CHECKLIST_TYPE | DMENU_SELECTION_RETURNS, - "Select Drive(s)", - "Please select the drive, or drives, on which you wish to perform\n" - "this operation. If you are attempting to install a boot partition\n" - "on a drive other than the first one or have multiple operating\n" - "systems on your machine, you will have the option to install a boot\n" - "manager later. To select a drive, use the arrow keys to move to it\n" - "and press [SPACE]. To de-select it, press [SPACE] again.\n\n" - "Select OK or Cancel to leave this menu.", - "Press F1 for important information regarding disk geometry!", - "drives", - { { NULL } }, -}; - -DMenu MenuHTMLDoc = { - DMENU_NORMAL_TYPE, - "Select HTML Documentation pointer", - "Please select the body of documentation you're interested in, the main\n" - "ones right now being the FAQ and the Handbook. You can also chose \"other\"\n" - "to enter an arbitrary URL for browsing.", - "Press F1 for more help on what you see here.", - "html", - { { "Handbook", "The FreeBSD Handbook.", NULL, docShowDocument }, - { "FAQ", "The Frequently Asked Questions guide.", NULL, docShowDocument }, - { "Home", "The Home Pages for the FreeBSD Project (requires net)", NULL, docShowDocument }, - { "Other", "Enter a URL.", NULL, docShowDocument }, - { NULL } }, -}; - -/* The main installation menu */ -DMenu MenuInstallCustom = { - DMENU_NORMAL_TYPE, - "Choose Custom Installation Options", - "This is the custom installation menu. You may use this menu to specify\n" - "details on the type of distribution you wish to have, where you wish\n" - "to install it from and how you wish to allocate disk storage to FreeBSD.", - "Press F1 to read the installation guide", - "install", - { { "1 Options", "View/Set various installation options", NULL, optionsEditor }, -#ifdef __alpha__ - { "2 Label", "Label disk partitions", NULL, diskLabelEditor }, - { "3 Distributions", "Select distribution(s) to extract", NULL, dmenuSubmenu, NULL, &MenuDistributions }, - { "4 Media", "Choose the installation media type", NULL, dmenuSubmenu, NULL, &MenuMedia }, - { "5 Commit", "Perform any pending Partition/Label/Extract actions", NULL, installCustomCommit }, -#else - { "2 Partition", "Allocate disk space for FreeBSD", NULL, diskPartitionEditor }, - { "3 Label", "Label allocated disk partitions", NULL, diskLabelEditor }, - { "4 Distributions", "Select distribution(s) to extract", NULL, dmenuSubmenu, NULL, &MenuDistributions }, - { "5 Media", "Choose the installation media type", NULL, dmenuSubmenu, NULL, &MenuMedia }, - { "6 Commit", "Perform any pending Partition/Label/Extract actions", NULL, installCustomCommit }, -#endif - { "0 Exit", "Exit this menu (returning to previous)", NULL, dmenuExit }, - { NULL } }, -}; - -/* MBR type menu */ -DMenu MenuMBRType = { - DMENU_RADIO_TYPE | DMENU_SELECTION_RETURNS, - "overwrite me", /* will be disk specific label */ - "FreeBSD comes with a boot selector that allows you to easily\n" - "select between FreeBSD and any other operating systems on your machine\n" - "at boot time. If you have more than one drive and want to boot\n" - "from the second one, the boot selector will also make it possible\n" - "to do so (limitations in the PC BIOS usually prevent this otherwise).\n" - "If you do not want a boot selector, or wish to replace an existing\n" - "one, select \"standard\". If you would prefer your Master Boot\n" - "Record to remain untouched then select \"None\".\n\n" - " NOTE: PC-DOS users will almost certainly require \"None\"!", - "Press F1 to read about drive setup", - "drives", - { { "BootMgr", "Install the FreeBSD Boot Manager", - dmenuRadioCheck, dmenuSetValue, NULL, &BootMgr }, - { "Standard", "Install a standard MBR (no boot manager)", - dmenuRadioCheck, dmenuSetValue, NULL, &BootMgr, '(', '*', ')', 1 }, - { "None", "Leave the Master Boot Record untouched", - dmenuRadioCheck, dmenuSetValue, NULL, &BootMgr, '(', '*', ')', 2 }, - { NULL } }, -}; - -/* Final configuration menu */ -DMenu MenuConfigure = { - DMENU_NORMAL_TYPE, - "FreeBSD Configuration Menu", /* title */ - "If you've already installed FreeBSD, you may use this menu to customize\n" - "it somewhat to suit your particular configuration. Most importantly,\n" - "you can use the Packages utility to load extra \"3rd party\"\n" - "software not provided in the base distributions.", - "Press F1 for more information on these options", - "configure", - { { "1 User Management", "Add user and group information", - NULL, dmenuSubmenu, NULL, &MenuUsermgmt }, - { "2 Console", "Customize system console behavior", - NULL, dmenuSubmenu, NULL, &MenuSyscons }, - { "3 Time Zone", "Set which time zone you're in", - NULL, dmenuSystemCommand, NULL, "tzsetup" }, - { "4 Media", "Change the installation media type", - NULL, dmenuSubmenu, NULL, &MenuMedia }, - { "5 Mouse", "Configure your mouse", - NULL, dmenuSubmenu, NULL, &MenuMouse, NULL }, - { "6 Networking", "Configure additional network services", - NULL, dmenuSubmenu, NULL, &MenuNetworking }, - { "7 Startup", "Configure system startup options", - NULL, dmenuSubmenu, NULL, &MenuStartup }, - { "8 Options", "View/Set various installation options", - NULL, optionsEditor }, - { "9 Distributions", "Install additional distribution sets", - NULL, distExtractAll }, - { "P Packages", "Install pre-packaged software for FreeBSD", - NULL, configPackages }, - { "R Root Password", "Set the system manager's password", - NULL, dmenuSystemCommand, NULL, "passwd root" }, - { "D HTML Docs", "Go to the HTML documentation menu (post-install)", - NULL, docBrowser }, - { "X XFree86", "Configure XFree86", - NULL, configXEnvironment }, - { "L Label", "The disk Label editor", - NULL, diskLabelEditor }, - { "F Fdisk", "The disk Slice (PC-style partition) Editor", - NULL, diskPartitionEditor }, - { "U Register", "Register yourself or company as a FreeBSD user.", NULL, configRegister }, - { "E Exit", "Exit this menu (returning to previous)", - NULL, dmenuExit }, - { NULL } }, -}; - -DMenu MenuStartup = { - DMENU_CHECKLIST_TYPE | DMENU_SELECTION_RETURNS, - "Startup Services Menu", - "This menu allows you to configure various aspects of your system's\n" - "startup configuration. Remember to use SPACE to select items! The\n" - "RETURN key will leave this menu (as with all checkbox menus).", - NULL, - NULL, - { { "APM", "Auto-power management services (typically laptops)", - dmenuVarCheck, dmenuToggleVariable, NULL, "apm_enable=YES" }, - { "pccard", "Enable PCCARD (AKA PCMCIA) services (also laptops)", - dmenuVarCheck, dmenuToggleVariable, NULL, "pccard_enable=YES" }, - { "pccard mem", "Set PCCARD memory address (if enabled)", - dmenuVarCheck, dmenuISetVariable, NULL, "pccard_mem" }, - { "pccard ifconfig", "List of PCCARD ethernet devices to configure", - dmenuVarCheck, dmenuISetVariable, NULL, "pccard_ifconfig" }, - { " ", " -- ", NULL, NULL, NULL, NULL, ' ', ' ', ' ' }, - { "startup dirs", "Set the list of dirs to look for startup scripts", - dmenuVarCheck, dmenuISetVariable, NULL, "local_startup" }, - { "named", "Run a local name server on this host", - dmenuVarCheck, dmenuToggleVariable, NULL, "named_enable=YES" }, - { "named flags", "Set default flags to named (if enabled)", - dmenuVarCheck, dmenuISetVariable, NULL, "named_flags" }, - { "nis client", "This host wishes to be an NIS client.", - dmenuVarCheck, dmenuToggleVariable, NULL, "nis_client_enable=YES" }, - { "nis server", "This host wishes to be an NIS server.", - dmenuVarCheck, dmenuToggleVariable, NULL, "nis_server_enable=YES" }, - { " ", " -- ", NULL, NULL, NULL, NULL, ' ', ' ', ' ' }, - { "accounting", "This host wishes to run process accounting.", - dmenuVarCheck, dmenuToggleVariable, NULL, "accounting_enable=YES" }, - { "lpd", "This host has a printer and wants to run lpd.", - dmenuVarCheck, dmenuToggleVariable, NULL, "lpd_enable=YES" }, - { "linux", "This host wants to be able to run linux binaries.", - dmenuVarCheck, dmenuToggleVariable, NULL, "linux_enable=YES" }, - { "quotas", "This host wishes to check quotas on startup.", - dmenuVarCheck, dmenuToggleVariable, NULL, "check_quotas=YES" }, - { "SCO", "This host wants to be able to run IBCS2 binaries.", - dmenuVarCheck, dmenuToggleVariable, NULL, "ibcs2_enable=YES" }, - { "Exit", "Exit this menu (returning to previous)", - checkTrue, dmenuExit, NULL, NULL, '<', '<', '<' }, - { NULL } }, -}; - -DMenu MenuNetworking = { - DMENU_CHECKLIST_TYPE | DMENU_SELECTION_RETURNS, - "Network Services Menu", - "You may have already configured one network device (and the other\n" - "various hostname/gateway/name server parameters) in the process\n" - "of installing FreeBSD. This menu allows you to configure other\n" - "aspects of your system's network configuration.", - NULL, - NULL, - { { "Interfaces", "Configure additional network interfaces", - NULL, tcpMenuSelect }, - { "NFS client", "This machine will be an NFS client", - dmenuVarCheck, dmenuToggleVariable, NULL, "nfs_client_enable=YES" }, - { "NFS server", "This machine will be an NFS server", - dmenuVarCheck, configNFSServer, NULL, "nfs_server_enable=YES" }, - { "AMD", "This machine wants to run the auto-mounter service", - dmenuVarCheck, dmenuToggleVariable, NULL, "amd_enable=YES" }, - { "AMD Flags", "Set flags to AMD service (if enabled)", - dmenuVarCheck, dmenuISetVariable, NULL, "amd_flags" }, - { "TCP Extensions", "Allow RFC1323 and RFC1644 TCP extensions?", - dmenuVarCheck, dmenuToggleVariable, NULL, "tcp_extensions=YES" }, - { "Gateway", "This machine will route packets between interfaces", - dmenuVarCheck, dmenuToggleVariable, NULL, "gateway_enable=YES" }, - { "Ntpdate", "Select a clock-synchronization server", - dmenuVarCheck, dmenuSubmenu, NULL, &MenuNTP, '[', 'X', ']', "ntpdate_enable=YES" }, - { "router", "Select routing daemon (default: routed)", - dmenuVarCheck, configRouter, NULL, "router" }, - { "Rwhod", "This machine wants to run the rwho daemon", - dmenuVarCheck, dmenuToggleVariable, NULL, "rwhod_enable=YES" }, - { "Anon FTP", "This machine wishes to allow anonymous FTP.", - dmenuVarCheck, configAnonFTP, NULL, "anon_ftp" }, - { "PCNFSD", "Run authentication server for clients with PC-NFS.", - dmenuVarCheck, configPCNFSD, NULL, "pcnfsd" }, - { "Exit", "Exit this menu (returning to previous)", - checkTrue, dmenuExit, NULL, NULL, '<', '<', '<' }, - { NULL } }, -}; - -DMenu MenuNTP = { - DMENU_RADIO_TYPE | DMENU_SELECTION_RETURNS, - "NTPDATE Server Selection", - "There are a number of time synchronization servers available\n" - "for public use around the Internet. Please select one reasonably\n" - "close to you to have your system time synchronized accordingly.", - "These are the primary open-access NTP servers", - NULL, - { { "None", "No ntp server", - dmenuVarsCheck, dmenuSetVariables, NULL, - "ntpdate_enable=NO,ntpdate_flags=none" }, - { "Other", "Select a site not on this list", - dmenuVarsCheck, configNTP, NULL, NULL }, - { "Australia", "ntp.syd.dms.csiro.au (HP 5061 Cesium Beam)", - dmenuVarsCheck, dmenuSetVariables, NULL, - "ntpdate_enable=YES,ntpdate_flags=ntp.syd.dms.csiro.au" }, - { "Canada", "tick.usask.ca (GOES clock)", - dmenuVarsCheck, dmenuSetVariables, NULL, - "ntpdate_enable=YES,ntpdate_flags=tick.usask.ca" }, - { "France", "canon.inria.fr (TDF clock)", - dmenuVarsCheck, dmenuSetVariables, NULL, - "ntpdate_enable=YES,ntpdate_flags=canon.inria.fr" }, - { "Germany", "ntps1-{0,1,2}.uni-erlangen.de (GPS)", - dmenuVarsCheck, dmenuSetVariables, NULL, - "ntpdate_enable=YES,ntpdate_flags=ntps1-0.uni-erlangen.de" }, - { "Germany #2", "ntps1-0.cs.tu-berlin.de (GPS)", - dmenuVarsCheck, dmenuSetVariables, NULL, - "ntpdate_enable=YES,ntpdate_flags=ntps1-0.cs.tu-berlin.de" }, - { "Japan", "clock.nc.fukuoka-u.ac.jp (GPS clock)", - dmenuVarsCheck, dmenuSetVariables, NULL, - "ntpdate_enable=YES,ntpdate_flags=clock.nc.fukuoka-u.ac.jp" }, - { "Japan #2", "clock.tl.fukuoka-u.ac.jp (GPS clock)", - dmenuVarsCheck, dmenuSetVariables, NULL, - "ntpdate_enable=YES,ntpdate_flags=clock.tl.fukuoka-u.ac.jp" }, - { "Netherlands", "ntp0.nl.net (GPS clock)", - dmenuVarsCheck, dmenuSetVariables, NULL, - "ntpdate_enable=YES,ntpdate_flags=ntp0.nl.net" }, - { "Norway", "timer.unik.no (NTP clock)", - dmenuVarsCheck, dmenuSetVariables, NULL, - "ntpdate_enable=YES,ntpdate_flags=timer.unik.no" }, - { "Sweden", "Time1.Stupi.SE (Cesium/GPS)", - dmenuVarsCheck, dmenuSetVariables, NULL, - "ntpdate_enable=YES,ntpdate_flags=Time1.Stupi.SE" }, - { "Switzerland", "swisstime.ethz.ch (DCF77 clock)", - dmenuVarsCheck, dmenuSetVariables, NULL, - "ntpdate_enable=YES,ntpdate_flags=swisstime.ethz.ch" }, - { "U.S. East Coast", "bitsy.mit.edu (WWV clock)", - dmenuVarsCheck, dmenuSetVariables, NULL, - "ntpdate_enable=YES,ntpdate_flags=bitsy.mit.edu" }, - { "U.S. East Coast #2", "otc1.psu.edu (WWV clock)", - dmenuVarsCheck, dmenuSetVariables, NULL, - "ntpdate_enable=YES,ntpdate_flags=otc1.psu.edu" }, - { "U.S. West Coast", "apple.com (WWV clock)", - dmenuVarsCheck, dmenuSetVariables, NULL, - "ntpdate_enable=YES,ntpdate_flags=apple.com" }, - { "U.S. West Coast #2", "clepsydra.dec.com (GOES clock)", - dmenuVarsCheck, dmenuSetVariables, NULL, - "ntpdate_enable=YES,ntpdate_flags=clepsydra.dec.com" }, - { "U.S. West Coast #3", "clock.llnl.gov (WWVB clock)", - dmenuVarsCheck, dmenuSetVariables, NULL, - "ntpdate_enable=YES,ntpdate_flags=clock.llnl.gov" }, - { "U.S. Midwest", "ncar.ucar.edu (WWVB clock)", - dmenuVarsCheck, dmenuSetVariables, NULL, - "ntpdate_enable=YES,ntpdate_flags=ncar.ucar.edu" }, - { "U.S. Pacific", "chantry.hawaii.net (WWV/H clock)", - dmenuVarsCheck, dmenuSetVariables, NULL, - "ntpdate_enable=YES,ntpdate_flags=chantry.hawaii.net" }, - { "U.S. Southwest", "shorty.chpc.utexas.edu (WWV clock)", - dmenuVarsCheck, dmenuSetVariables, NULL, - "ntpdate_enable=YES,ntpdate_flags=shorty.chpc.utexas.edu" }, - { NULL } }, -}; - -DMenu MenuSyscons = { - DMENU_NORMAL_TYPE, - "System Console Configuration", - "The default system console driver for FreeBSD (syscons) has a\n" - "number of configuration options which may be set according to\n" - "your preference.\n\n" - "When you are done setting configuration options, select Cancel.", - "Configure your system console settings", - NULL, - { { "Font", "Choose an alternate screen font", NULL, dmenuSubmenu, NULL, &MenuSysconsFont }, - { "Keymap", "Choose an alternate keyboard map", NULL, dmenuSubmenu, NULL, &MenuSysconsKeymap }, - { "Repeat", "Set the rate at which keys repeat", NULL, dmenuSubmenu, NULL, &MenuSysconsKeyrate }, - { "Saver", "Configure the screen saver", NULL, dmenuSubmenu, NULL, &MenuSysconsSaver }, - { "Screenmap", "Choose an alternate screenmap", NULL, dmenuSubmenu, NULL, &MenuSysconsScrnmap }, - { "Exit", "Exit this menu (returning to previous)", NULL, dmenuExit }, - { NULL } }, -}; - -DMenu MenuSysconsKeymap = { - DMENU_RADIO_TYPE | DMENU_SELECTION_RETURNS, - "System Console Keymap", - "The default system console driver for FreeBSD (syscons) defaults\n" - "to a standard \"American\" keyboard map. Users in other countries\n" - "(or with different keyboard preferences) may wish to choose one of\n" - "the other keymaps below.\n" - "Note that sysinstall itself only uses the part of the keyboard map\n" - "which is required to generate the ANSI character subset, but your\n" - "choice of keymap will also be saved for later (fuller) use.", - "Choose a keyboard map", - NULL, - { { "Belgian", "Belgian ISO keymap", dmenuVarCheck, dmenuSetKmapVariable, NULL, "keymap=be.iso" }, - { "Brazil CP850", "Brazil CP850 keymap", dmenuVarCheck, dmenuSetKmapVariable, NULL, "keymap=br275.cp850" }, - { "Brazil ISO (accent)", "Brazil ISO keymap (accent keys)", dmenuVarCheck, dmenuSetKmapVariable, NULL, "keymap=br275.iso.acc" }, - { "Brazil ISO", "Brazil ISO keymap", dmenuVarCheck, dmenuSetKmapVariable, NULL, "keymap=br275.iso" }, - { "Danish CP865", "Danish Code Page 865 keymap", dmenuVarCheck, dmenuSetKmapVariable, NULL, "keymap=danish.cp865" }, - { "Danish ISO", "Danish ISO keymap", dmenuVarCheck, dmenuSetKmapVariable, NULL, "keymap=danish.iso" }, - { "French ISO (accent)", "French ISO keymap (accent keys)", dmenuVarCheck, dmenuSetKmapVariable, NULL, "keymap=fr.iso.acc" }, - { "French ISO", "French ISO keymap", dmenuVarCheck, dmenuSetKmapVariable, NULL, "keymap=fr.iso" }, - { "German CP850", "German Code Page 850 keymap", dmenuVarCheck, dmenuSetKmapVariable, NULL, "keymap=german.cp850" }, - { "German ISO", "German ISO keymap", dmenuVarCheck, dmenuSetKmapVariable, NULL, "keymap=german.iso" }, - { "Icelandic (accent)", "Icelandic ISO keymap (accent keys)", dmenuVarCheck, dmenuSetKmapVariable, NULL, "keymap=icelandic.iso.acc" }, - { "Icelandic", "Icelandic ISO keymap", dmenuVarCheck, dmenuSetKmapVariable, NULL, "keymap=icelandic.iso" }, - { "Italian", "Italian ISO keymap", dmenuVarCheck, dmenuSetKmapVariable, NULL, "keymap=it.iso" }, - { "Latin American", "Latin American ISO keymap", dmenuVarCheck, dmenuSetKmapVariable, NULL, "keymap=lat-amer" }, - { "Japanese 106", "Japanese 106 keymap", dmenuVarCheck, dmenuSetKmapVariable, NULL, "keymap=jp.106" }, - { "Norway ISO", "Norwegian ISO keymap", dmenuVarCheck, dmenuSetKmapVariable, NULL, "keymap=norwegian.iso" }, - { "Russia CP866", "Russian CP866 keymap", dmenuVarCheck, dmenuSetKmapVariable, NULL, "keymap=ru.cp866" }, - { "Russia KOI8-R", "Russian KOI8-R keymap", dmenuVarCheck, dmenuSetKmapVariable, NULL, "keymap=ru.koi8-r" }, - { "Slovenian", "Slovenian ISO keymap", dmenuVarCheck, dmenuSetKmapVariable, NULL, "keymap=si.iso.acc" }, - { "Spanish (accent)", "Spanish ISO keymap (accent keys)", dmenuVarCheck, dmenuSetKmapVariable, NULL, "keymap=spanish.iso.acc" }, - { "Spanish", "Spanish ISO keymap", dmenuVarCheck, dmenuSetKmapVariable, NULL, "keymap=spanish.iso" }, - { "Swedish CP850", "Swedish Code Page 850 keymap", dmenuVarCheck, dmenuSetKmapVariable, NULL, "keymap=swedish.cp850" }, - { "Swedish ISO", "Swedish ISO keymap", dmenuVarCheck, dmenuSetKmapVariable, NULL, "keymap=swedish.iso" }, - { "Swiss German", "Swiss German ISO keymap", dmenuVarCheck, dmenuSetKmapVariable, NULL, "keymap=swissgerman.iso" }, - { "U.K. CP850", "United Kingdom Code Page 850 keymap", dmenuVarCheck, dmenuSetKmapVariable, NULL, "keymap=uk.cp850" }, - { "U.K. ISO", "United Kingdom ISO keymap", dmenuVarCheck, dmenuSetKmapVariable, NULL, "keymap=uk.iso" }, - { "U.S. Dvorak", "United States Dvorak keymap", dmenuVarCheck, dmenuSetKmapVariable, NULL, "keymap=us.dvorak" }, - { "U.S. ISO", "United States ISO keymap", dmenuVarCheck, dmenuSetKmapVariable, NULL, "keymap=us.iso" }, - { NULL } }, -}; - -DMenu MenuSysconsKeyrate = { - DMENU_RADIO_TYPE | DMENU_SELECTION_RETURNS, - "System Console Keyboard Repeat Rate", - "This menu allows you to set the speed at which keys repeat\n" - "when held down.", - "Choose a keyboard repeat rate", - NULL, - { { "Slow", "Slow keyboard repeat rate", dmenuVarCheck, dmenuSetVariable, NULL, "keyrate=slow" }, - { "Normal", "\"Normal\" keyboard repeat rate", dmenuVarCheck, dmenuSetVariable, NULL, "keyrate=normal" }, - { "Fast", "Fast keyboard repeat rate", dmenuVarCheck, dmenuSetVariable, NULL, "keyrate=fast" }, - { "Default", "Use default keyboard repeat rate", dmenuVarCheck, dmenuSetVariable, NULL, "keyrate=NO" }, - { NULL } }, -}; - -DMenu MenuSysconsSaver = { - DMENU_RADIO_TYPE | DMENU_SELECTION_RETURNS, - "System Console Screen Saver", - "By default, the console driver will not attempt to do anything\n" - "special with your screen when it's idle. If you expect to leave your\n" - "monitor switched on and idle for long periods of time then you should\n" - "probably enable one of these screen savers to prevent phosphor burn-in.", - "Choose a nifty-looking screen saver", - NULL, - { { "blank", "Simply blank the screen", - dmenuVarCheck, configSaver, NULL, "saver=blank" }, - { "Daemon", "\"BSD Daemon\" animated screen saver", - dmenuVarCheck, configSaver, NULL, "saver=daemon" }, - { "Green", "\"Green\" power saving mode (if supported by monitor)", - dmenuVarCheck, configSaver, NULL, "saver=green" }, - { "Snake", "Draw a FreeBSD \"snake\" on your screen", - dmenuVarCheck, configSaver, NULL, "saver=snake" }, - { "Star", "A \"twinkling stars\" effect", - dmenuVarCheck, configSaver, NULL, "saver=star" }, - { "Timeout", "Set the screen saver timeout interval", - NULL, configSaverTimeout, NULL, NULL, ' ', ' ', ' ' }, - { NULL } }, -}; - -DMenu MenuSysconsScrnmap = { - DMENU_RADIO_TYPE | DMENU_SELECTION_RETURNS, - "System Console Screenmap", - "Unless you load a specific font, most PC hardware defaults to\n" - "displaying characters in the IBM 437 character set. However,\n" - "in the Unix world, this character set is very rarely used. Most\n" - "Western European countries, for example, prefer ISO 8859-1.\n" - "American users won't notice the difference since the bottom half\n" - "of all these character sets is ANSI anyway.\n" - "If your hardware is capable of downloading a new display font,\n" - "you should probably choose that option. However, for hardware\n" - "where this is not possible (e.g. monochrome adapters), a screen\n" - "map will give you the best approximation that your hardware can\n" - "display at all.", - "Choose a screen map", - NULL, - { { "None", "No screenmap, use default font", dmenuVarCheck, dmenuSetVariable, NULL, "scrnmap=NO" }, - { "KOI8-R to IBM866", "Russian KOI8-R to IBM 866 screenmap", dmenuVarCheck, dmenuSetVariable, NULL, "scrnmap=koi8-r2cp866" }, - { "ISO 8859-1 to IBM437", "W-Europe ISO 8859-1 to IBM 437 screenmap", dmenuVarCheck, dmenuSetVariable, NULL, "scrnmap=iso-8859-1_to_cp437" }, - { NULL } }, -}; - -DMenu MenuSysconsFont = { - DMENU_RADIO_TYPE | DMENU_SELECTION_RETURNS, - "System Console Font", - "Most PC hardware defaults to displaying characters in the\n" - "IBM 437 character set. However, in the Unix world, this\n" - "character set is very rarely used. Most Western European\n" - "countries, for example, prefer ISO 8859-1.\n" - "American users won't notice the difference since the bottom half\n" - "of all these charactersets is ANSI anyway. However, they might\n" - "want to load a font anyway to use the 30- or 50-line displays.\n" - "If your hardware is capable of downloading a new display font,\n" - "you can select the appropriate font below.", - "Choose a font", - NULL, - { { "None", "Use default font", dmenuVarCheck, dmenuSetVariables, NULL, - "font8x8=NO,font8x14=NO,font8x16=NO" }, - { "IBM 437", "English", dmenuVarCheck, dmenuSetVariables, NULL, - "font8x8=cp437-8x8,font8x14=cp437-8x14,font8x16=cp437-8x16" }, - { "IBM 850", "Western Europe, IBM encoding", dmenuVarCheck, dmenuSetVariables, NULL, - "font8x8=cp850-8x8,font8x14=cp850-8x14,font8x16=cp850-8x16" }, - { "IBM 865", "Norwegian, IBM encoding", dmenuVarCheck, dmenuSetVariables, NULL, - "font8x8=cp865-8x8,font8x14=cp865-8x14,font8x16=cp865-8x16" }, - { "IBM 866", "Russian, IBM encoding", dmenuVarCheck, dmenuSetVariables, NULL, - "font8x8=cp866-8x8,font8x14=cp866-8x14,font8x16=cp866-8x16" }, - { "ISO 8859-1", "Western Europe, ISO encoding", dmenuVarCheck, dmenuSetVariables, NULL, - "font8x8=iso-8x8,font8x14=iso-8x14,font8x16=iso-8x16" }, - { "KOI8-R", "Russian, KOI8-R encoding", dmenuVarCheck, dmenuSetVariables, NULL, - "font8x8=koi8-r-8x8,font8x14=koi8-r-8x14,font8x16=koi8-r-8x16" }, - { NULL } }, -}; - -DMenu MenuUsermgmt = { - DMENU_NORMAL_TYPE, - "User and group management", - "The submenus here allow to manipulate user groups and\n" - "login accounts.\n", - "Configure your user groups and users", - NULL, - { { "Add user", "Add a new user to the system.", NULL, userAddUser }, - { "Add group", "Add a new user group to the system.", NULL, userAddGroup }, - { "Exit", "Exit this menu (returning to previous)", NULL, dmenuExit }, - { NULL } }, -}; - -DMenu MenuFixit = { - DMENU_NORMAL_TYPE, - "Please choose a fixit option", - "There are three ways of going into \"fixit\" mode:\n" - "- you can use the 2nd FreeBSD CDROM, in which case there will be\n" - " full access to the complete set of FreeBSD commands and utilities,\n" - "- you can use the more limited (but perhaps customized) fixit floppy,\n" - "- or you can start an Emergency Holographic Shell now, which is\n" - " limited to the subset of commands that is already available right now.", - "Press F1 for more detailed repair instructions", - "fixit", -{ { "1 CDROM", "Use the 2nd \"live\" CDROM from the distribution", NULL, installFixitCDROM }, - { "2 Floppy", "Use a floppy generated from the fixit image", NULL, installFixitFloppy }, - { "3 Shell", "Start an Emergency Holographic Shell", NULL, installFixitHoloShell }, - { NULL } }, -}; - diff --git a/usr.sbin/sade/misc.c b/usr.sbin/sade/misc.c deleted file mode 100644 index bb00639028d3..000000000000 --- a/usr.sbin/sade/misc.c +++ /dev/null @@ -1,485 +0,0 @@ -/* - * Miscellaneous support routines.. - * - * $Id: misc.c,v 1.37 1998/01/16 15:07:55 jkh Exp $ - * - * Copyright (c) 1995 - * Jordan Hubbard. 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, - * verbatim and that no modifications are made prior to this - * point in the file. - * 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 JORDAN HUBBARD ``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 JORDAN HUBBARD OR HIS PETS 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, LIFE 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. - * - */ - -#include "sysinstall.h" -#include <ctype.h> -#include <unistd.h> -#include <sys/stat.h> -#include <sys/errno.h> -#include <sys/file.h> -#include <sys/types.h> -#include <dirent.h> -#include <sys/wait.h> -#include <sys/param.h> -#include <sys/mount.h> -#include <ufs/ufs/ufsmount.h> -#include <sys/reboot.h> -#include <sys/dkbad.h> -#include <sys/disklabel.h> - -/* Quick check to see if a file is readable */ -Boolean -file_readable(char *fname) -{ - if (!access(fname, F_OK)) - return TRUE; - return FALSE; -} - -/* Quick check to see if a file is executable */ -Boolean -file_executable(char *fname) -{ - if (!access(fname, X_OK)) - return TRUE; - return FALSE; -} - -/* Concatenate two strings into static storage */ -char * -string_concat(char *one, char *two) -{ - static char tmp[FILENAME_MAX]; - - /* Yes, we're deliberately cavalier about not checking for overflow */ - strcpy(tmp, one); - strcat(tmp, two); - return tmp; -} - -/* sane strncpy() function */ -char * -sstrncpy(char *dst, const char *src, int size) -{ - dst[size] = '\0'; - return strncpy(dst, src, size); -} - -/* Concatenate three strings into static storage */ -char * -string_concat3(char *one, char *two, char *three) -{ - static char tmp[FILENAME_MAX]; - - /* Yes, we're deliberately cavalier about not checking for overflow */ - strcpy(tmp, one); - strcat(tmp, two); - strcat(tmp, three); - return tmp; -} - -/* Clip the whitespace off the end of a string */ -char * -string_prune(char *str) -{ - int len = str ? strlen(str) : 0; - - while (len && isspace(str[len - 1])) - str[--len] = '\0'; - return str; -} - -/* run the whitespace off the front of a string */ -char * -string_skipwhite(char *str) -{ - while (*str && isspace(*str)) - ++str; - return str; -} - -/* copy optionally and allow second arg to be null */ -char * -string_copy(char *s1, char *s2) -{ - if (!s1) - return NULL; - if (!s2) - s1[0] = '\0'; - else - strcpy(s1, s2); - return s1; -} - -/* convert an integer to a string, using a static buffer */ -char * -itoa(int value) -{ - static char buf[13]; - - snprintf(buf, 12, "%d", value); - return buf; -} - -Boolean -directory_exists(const char *dirname) -{ - DIR *tptr; - - if (!dirname) - return FALSE; - if (!strlen(dirname)) - return FALSE; - - tptr = opendir(dirname); - if (!tptr) - return (FALSE); - - closedir(tptr); - return (TRUE); -} - -char * -pathBaseName(const char *path) -{ - char *pt; - char *ret = (char *)path; - - pt = strrchr(path,(int)'/'); - - if (pt != 0) /* if there is a slash */ - { - ret = ++pt; /* start the file after it */ - } - - return(ret); -} - -/* A free guaranteed to take NULL ptrs */ -void -safe_free(void *ptr) -{ - if (ptr) - free(ptr); -} - -/* A malloc that checks errors */ -void * -safe_malloc(size_t size) -{ - void *ptr; - - if (size <= 0) - msgFatal("Invalid malloc size of %d!", size); - ptr = malloc(size); - if (!ptr) - msgFatal("Out of memory!"); - bzero(ptr, size); - return ptr; -} - -/* A realloc that checks errors */ -void * -safe_realloc(void *orig, size_t size) -{ - void *ptr; - - if (size <= 0) - msgFatal("Invalid realloc size of %d!", size); - ptr = realloc(orig, size); - if (!ptr) - msgFatal("Out of memory!"); - return ptr; -} - -/* Create a path biased from the VAR_INSTALL_ROOT variable (if not /) */ -char * -root_bias(char *path) -{ - static char tmp[FILENAME_MAX]; - char *cp = variable_get(VAR_INSTALL_ROOT); - - if (!strcmp(cp, "/")) - return path; - strcpy(tmp, variable_get(VAR_INSTALL_ROOT)); - strcat(tmp, path); - return tmp; -} - -/* - * These next routines are kind of specialized just for building item lists - * for dialog_menu(). - */ - -/* Add an item to an item list */ -dialogMenuItem * -item_add(dialogMenuItem *list, char *prompt, char *title, - int (*checked)(dialogMenuItem *self), - int (*fire)(dialogMenuItem *self), - void (*selected)(dialogMenuItem *self, int is_selected), - void *data, int aux, int *curr, int *max) -{ - dialogMenuItem *d; - - if (*curr == *max) { - *max += 20; - list = (dialogMenuItem *)realloc(list, sizeof(dialogMenuItem) * *max); - } - d = &list[(*curr)++]; - bzero(d, sizeof(*d)); - d->prompt = prompt ? strdup(prompt) : NULL; - d->title = title ? strdup(title) : NULL; - d->checked = checked; - d->fire = fire; - d->selected = selected; - d->data = data; - d->aux = aux; - return list; -} - -/* Toss the items out */ -void -items_free(dialogMenuItem *list, int *curr, int *max) -{ - int i; - - for (i = 0; list[i].prompt; i++) { - safe_free(list[i].prompt); - safe_free(list[i].title); - } - safe_free(list); - *curr = *max = 0; -} - -int -Mkdir(char *ipath) -{ - struct stat sb; - int final; - char *p, *path; - - if (file_readable(ipath) || Fake) - return DITEM_SUCCESS; - - path = strcpy(alloca(strlen(ipath) + 1), ipath); - if (isDebug()) - msgDebug("mkdir(%s)\n", path); - p = path; - if (p[0] == '/') /* Skip leading '/'. */ - ++p; - for (final = FALSE; !final; ++p) { - if (p[0] == '\0' || (p[0] == '/' && p[1] == '\0')) - final = TRUE; - else if (p[0] != '/') - continue; - *p = '\0'; - if (stat(path, &sb)) { - if (errno != ENOENT) { - msgConfirm("Couldn't stat directory %s: %s", path, strerror(errno)); - return DITEM_FAILURE; - } - if (isDebug()) - msgDebug("mkdir(%s..)\n", path); - if (mkdir(path, S_IRWXU | S_IRWXG | S_IRWXO) < 0) { - msgConfirm("Couldn't create directory %s: %s", path,strerror(errno)); - return DITEM_FAILURE; - } - } - *p = '/'; - } - return DITEM_SUCCESS; -} - -int -Mount(char *mountp, void *dev) -{ - struct ufs_args ufsargs; - char device[80]; - char mountpoint[FILENAME_MAX]; - - if (Fake) - return DITEM_SUCCESS; - - if (*((char *)dev) != '/') { - sprintf(device, "%s/dev/%s", RunningAsInit ? "/mnt" : "", (char *)dev); - sprintf(mountpoint, "%s%s", RunningAsInit ? "/mnt" : "", mountp); - } - else { - strcpy(device, dev); - strcpy(mountpoint, mountp); - } - memset(&ufsargs,0,sizeof ufsargs); - - if (Mkdir(mountpoint)) { - msgConfirm("Unable to make directory mountpoint for %s!", mountpoint); - return DITEM_FAILURE; - } - if (isDebug()) - msgDebug("mount %s %s\n", device, mountpoint); - - ufsargs.fspec = device; - if (mount("ufs", mountpoint, RunningAsInit ? MNT_ASYNC | MNT_NOATIME : 0, - (caddr_t)&ufsargs) == -1) { - msgConfirm("Error mounting %s on %s : %s", device, mountpoint, strerror(errno)); - return DITEM_FAILURE; - } - return DITEM_SUCCESS; -} - -WINDOW * -openLayoutDialog(char *helpfile, char *title, int x, int y, int width, int height) -{ - WINDOW *win; - static char help[FILENAME_MAX]; - - /* We need a curses window */ - win = newwin(LINES, COLS, 0, 0); - if (win) { - /* Say where our help comes from */ - if (helpfile) { - use_helpline("Press F1 for more information on this screen."); - use_helpfile(systemHelpFile(helpfile, help)); - } - /* Setup a nice screen for us to splat stuff onto */ - draw_box(win, y, x, height, width, dialog_attr, border_attr); - wattrset(win, dialog_attr); - mvwaddstr(win, y, x + (COLS - strlen(title)) / 2, title); - } - return win; -} - -ComposeObj * -initLayoutDialog(WINDOW *win, Layout *layout, int x, int y, int *max) -{ - ComposeObj *obj = NULL, *first; - int n; - - /* Loop over the layout list, create the objects, and add them - onto the chain of objects that dialog uses for traversal*/ - - n = 0; - while (layout[n].help != NULL) { - int t = TYPE_OF_OBJ(layout[n].type); - - switch (t) { - case STRINGOBJ: - layout[n].obj = NewStringObj(win, layout[n].prompt, layout[n].var, - layout[n].y + y, layout[n].x + x, layout[n].len, layout[n].maxlen); - ((StringObj *)layout[n].obj)->attr_mask = ATTR_OF_OBJ(layout[n].type); - break; - - case BUTTONOBJ: - layout[n].obj = NewButtonObj(win, layout[n].prompt, layout[n].var, layout[n].y + y, layout[n].x + x); - break; - - default: - msgFatal("Don't support this object yet!"); - } - AddObj(&obj, t, (void *) layout[n].obj); - n++; - } - *max = n - 1; - /* Find the first object in the list */ - for (first = obj; first->prev; first = first->prev); - return first; -} - -int -layoutDialogLoop(WINDOW *win, Layout *layout, ComposeObj **obj, int *n, int max, int *cbutton, int *cancel) -{ - char help_line[80]; - int ret, i, len = strlen(layout[*n].help); - - /* Display the help line at the bottom of the screen */ - for (i = 0; i < 79; i++) - help_line[i] = (i < len) ? layout[*n].help[i] : ' '; - help_line[i] = '\0'; - use_helpline(help_line); - display_helpline(win, LINES - 1, COLS - 1); - wrefresh(win); - - /* Ask for libdialog to do its stuff */ - ret = PollObj(obj); - /* Handle special case stuff that libdialog misses. Sigh */ - switch (ret) { - case SEL_ESC: /* Bail out */ - *cancel = TRUE; - return FALSE; - - /* This doesn't work for list dialogs. Oh well. Perhaps - should special case the move from the OK button ``up'' - to make it go to the interface list, but then it gets - awkward for the user to go back and correct screw up's - in the per-interface section */ - case KEY_DOWN: - case SEL_CR: - case SEL_TAB: - if (*n < max) - ++*n; - else - *n = 0; - break; - - /* The user has pressed enter over a button object */ - case SEL_BUTTON: - if (cbutton && *cbutton) - *cancel = TRUE; - else - *cancel = FALSE; - return FALSE; - - case KEY_UP: - case SEL_BACKTAB: - if (*n) - --*n; - else - *n = max; - break; - - case KEY_F(1): - display_helpfile(); - - /* They tried some key combination we don't support - tootle them forcefully! */ - default: - beep(); - } - return TRUE; -} - -WINDOW * -savescr(void) -{ - WINDOW *w; - - w = dupwin(newscr); - return w; -} - -void -restorescr(WINDOW *w) -{ - touchwin(w); - wrefresh(w); - delwin(w); -} - diff --git a/usr.sbin/sade/msg.c b/usr.sbin/sade/msg.c deleted file mode 100644 index e61b7679d241..000000000000 --- a/usr.sbin/sade/msg.c +++ /dev/null @@ -1,320 +0,0 @@ -/* - * The new sysinstall program. - * - * This is probably the last program in the `sysinstall' line - the next - * generation being essentially a complete rewrite. - * - * $Id: msg.c,v 1.46 1997/09/09 16:27:50 jkh Exp $ - * - * Copyright (c) 1995 - * Jordan Hubbard. 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, - * verbatim and that no modifications are made prior to this - * point in the file. - * 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 JORDAN HUBBARD ``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 JORDAN HUBBARD OR HIS PETS 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, LIFE 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. - * - */ - -#include "sysinstall.h" -#include <stdarg.h> -#include <sys/ioctl.h> -#include <machine/console.h> - -Boolean -isDebug(void) -{ - char *cp; - - return (cp = variable_get(VAR_DEBUG)) && strcmp(cp, "no"); -} - -/* Whack up an informational message on the status line, in stand-out */ -void -msgYap(char *fmt, ...) -{ - va_list args; - char *errstr; - int attrs; - - errstr = (char *)alloca(FILENAME_MAX); - va_start(args, fmt); - vsnprintf(errstr, FILENAME_MAX, fmt, args); - va_end(args); - attrs = getattrs(stdscr); - attrset(A_REVERSE); - mvaddstr(StatusLine, 0, errstr); - attrset(attrs); - refresh(); -} - -/* Whack up an informational message on the status line */ -void -msgInfo(char *fmt, ...) -{ - va_list args; - char *errstr; - int i, attrs; - char line[81]; - - attrs = getattrs(stdscr); - /* NULL is a special convention meaning "erase the old stuff" */ - if (!fmt) { - move(StatusLine, 0); - clrtoeol(); - return; - } - errstr = (char *)alloca(FILENAME_MAX); - va_start(args, fmt); - vsnprintf(errstr, FILENAME_MAX, fmt, args); - va_end(args); - memset(line, ' ', 80); - for (i = 0; i < 80; i++) { - if (errstr[i]) - line[i] = errstr[i]; - else - break; - } - line[80] = '\0'; - attrset(ATTR_TITLE); - mvaddstr(StatusLine, 0, line); - attrset(attrs); - move(StatusLine, 79); - refresh(); -} - -/* Whack up a warning on the status line */ -void -msgWarn(char *fmt, ...) -{ - va_list args; - char *errstr; - int attrs; - - errstr = (char *)alloca(FILENAME_MAX); - strcpy(errstr, "Warning: "); - va_start(args, fmt); - vsnprintf((char *)(errstr + strlen(errstr)), FILENAME_MAX, fmt, args); - va_end(args); - attrs = getattrs(stdscr); - beep(); - attrset(ATTR_TITLE); - mvaddstr(StatusLine, 0, errstr); - attrset(attrs); - refresh(); - if (OnVTY && isDebug()) - msgDebug("Warning message `%s'\n", errstr); -} - -/* Whack up an error on the status line */ -void -msgError(char *fmt, ...) -{ - va_list args; - char *errstr; - int attrs; - - errstr = (char *)alloca(FILENAME_MAX); - strcpy(errstr, "Error: "); - va_start(args, fmt); - vsnprintf((char *)(errstr + strlen(errstr)), FILENAME_MAX, fmt, args); - va_end(args); - beep(); - attrs = getattrs(stdscr); - attrset(ATTR_TITLE); - mvaddstr(StatusLine, 0, errstr); - attrset(attrs); - refresh(); - if (OnVTY && isDebug()) - msgDebug("Error message `%s'\n", errstr); -} - -/* Whack up a fatal error on the status line */ -void -msgFatal(char *fmt, ...) -{ - va_list args; - char *errstr; - int attrs; - - errstr = (char *)alloca(FILENAME_MAX); - strcpy(errstr, "Fatal Error: "); - va_start(args, fmt); - vsnprintf((char *)(errstr + strlen(errstr)), FILENAME_MAX, fmt, args); - va_end(args); - beep(); - attrs = getattrs(stdscr); - attrset(ATTR_TITLE); - mvaddstr(StatusLine, 0, errstr); - addstr(" - "); - addstr("PRESS ANY KEY TO "); - if (getpid() == 1) - addstr("REBOOT"); - else - addstr("QUIT"); - attrset(attrs); - refresh(); - if (OnVTY) - msgDebug("Fatal error `%s'!\n", errstr); - getch(); - systemShutdown(1); -} - -/* Put up a message in a popup confirmation box */ -void -msgConfirm(char *fmt, ...) -{ - va_list args; - char *errstr; - - errstr = (char *)alloca(FILENAME_MAX); - va_start(args, fmt); - vsnprintf(errstr, FILENAME_MAX, fmt, args); - va_end(args); - use_helpline(NULL); - use_helpfile(NULL); - if (OnVTY) { - ioctl(0, VT_ACTIVATE, 1); - msgInfo(NULL); - } - dialog_notify(errstr); -} - -/* Put up a message in a popup information box */ -void -msgNotify(char *fmt, ...) -{ - va_list args; - char *errstr; - - errstr = (char *)alloca(FILENAME_MAX); - va_start(args, fmt); - vsnprintf(errstr, FILENAME_MAX, fmt, args); - va_end(args); - use_helpline(NULL); - use_helpfile(NULL); - if (isDebug()) - msgDebug("Notify: %s\n", errstr); - dialog_clear_norefresh(); - dialog_msgbox(NULL, errstr, -1, -1, 0); -} - -/* Put up a message in a popup yes/no box and return 1 for YES, 0 for NO */ -int -msgYesNo(char *fmt, ...) -{ - va_list args; - char *errstr; - int ret; - - errstr = (char *)alloca(FILENAME_MAX); - va_start(args, fmt); - vsnprintf(errstr, FILENAME_MAX, fmt, args); - va_end(args); - use_helpline(NULL); - use_helpfile(NULL); - if (OnVTY) { - ioctl(0, VT_ACTIVATE, 1); /* Switch back */ - msgInfo(NULL); - } - ret = dialog_yesno("User Confirmation Requested", errstr, -1, -1); - return ret; -} - -/* Put up a message in an input box and return the value */ -char * -msgGetInput(char *buf, char *fmt, ...) -{ - va_list args; - char *errstr; - static char input_buffer[256]; - int rval; - - errstr = (char *)alloca(FILENAME_MAX); - va_start(args, fmt); - vsnprintf(errstr, FILENAME_MAX, fmt, args); - va_end(args); - use_helpline(NULL); - use_helpfile(NULL); - if (buf) - SAFE_STRCPY(input_buffer, buf); - else - input_buffer[0] = '\0'; - if (OnVTY) { - ioctl(0, VT_ACTIVATE, 1); /* Switch back */ - msgInfo(NULL); - } - rval = dialog_inputbox("Value Required", errstr, -1, -1, input_buffer); - if (!rval) - return input_buffer; - else - return NULL; -} - -/* Write something to the debugging port */ -void -msgDebug(char *fmt, ...) -{ - va_list args; - char *dbg; - - if (DebugFD == -1) - return; - dbg = (char *)alloca(FILENAME_MAX); - strcpy(dbg, "DEBUG: "); - va_start(args, fmt); - vsnprintf((char *)(dbg + strlen(dbg)), FILENAME_MAX, fmt, args); - va_end(args); - write(DebugFD, dbg, strlen(dbg)); -} - -/* Tell the user there's some output to go look at */ -void -msgWeHaveOutput(char *fmt, ...) -{ - va_list args; - char *errstr; - - errstr = (char *)alloca(FILENAME_MAX); - va_start(args, fmt); - vsnprintf(errstr, FILENAME_MAX, fmt, args); - va_end(args); - use_helpline(NULL); - use_helpfile(NULL); - msgDebug("Notify: %s\n", errstr); - dialog_clear_norefresh(); - dialog_msgbox(NULL, errstr, -1, -1, 0); -} - -/* Simple versions of msgConfirm() and msgNotify() for calling from scripts */ -int -msgSimpleConfirm(char *str) -{ - msgConfirm(str); - return DITEM_SUCCESS; -} - -int -msgSimpleNotify(char *str) -{ - msgNotify(str); - return DITEM_SUCCESS; -} diff --git a/usr.sbin/sade/rtermcap.c b/usr.sbin/sade/rtermcap.c deleted file mode 100644 index 84b3feb49ead..000000000000 --- a/usr.sbin/sade/rtermcap.c +++ /dev/null @@ -1,15 +0,0 @@ -#include <stdio.h> -#include <termcap.h> - -int -main(int argc, char **argv) -{ - char buf[4096]; - int i; - - if (argc < 2) - return 1; - i = tgetent(buf, argv[1]); - printf("%s",buf); - return 0; -} diff --git a/usr.sbin/sade/sade.8 b/usr.sbin/sade/sade.8 deleted file mode 100644 index 2be7509309bb..000000000000 --- a/usr.sbin/sade/sade.8 +++ /dev/null @@ -1,802 +0,0 @@ -.\" Copyright (c) 1997 -.\" Jordan Hubbard <jkh@freebsd.org>. 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 Jordan Hubbard 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 Jordan Hubbard 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. -.\" -.\" $Id: sysinstall.8,v 1.13 1998/12/02 03:27:37 jkh Exp $ -.\" -.Dd August 9, 1997 -.Dt SYSINSTALL 8 -.Os -.Sh NAME -.Nm sysinstall -.Nd system installation and configuration tool -.Sh SYNOPSIS -.Nm -.Op Ar var=value -.Op Ar function -.Op Ar ... -.Sh DESCRIPTION -.Nm -is a utility for installing and configuring FreeBSD systems. -It is the first utility invoked by the FreeBSD installation boot -floppy and is also copied into -.Pa /stand/sysinstall -on newly installed FreeBSD systems for use in later configuring the system. -.Pp -The -.Nm -program is generally invoked without arguments for the default -behavior, where the main installation/configuration menu is presented. - -On those occasions where it is deemed necessary to invoke a subsystem -of sysinstall directly, however, it is also possible to do so by -naming the appropriate function entry points on the command line. -Since this action is essentially identical to running an installation -script, each command-line argument corresponding to a line of script, -the reader is encouraged to read the section on scripting for more -information on this feature. -.Pp -.Sh NOTES -.Nm -is essentially nothing more than a monolithic C program with -the ability to write MBRs and disk labels (through the services -of the -.Xr libdisk 3 -library) and install distributions or packages onto new and -existing FreeBSD systems. It also contains some extra intelligence -for running as a replacement for -.Xr init 8 -when it's invoked by the FreeBSD installation boot procedure. It -assumes very little in the way of additional utility support and -performs most file system operations by calling the relevant syscalls -(such as -.Xr mount 2 ) -directly. -.Pp -.Nm -currently uses the -.Xr libdialog 3 -library to do user interaction with simple ANSI line graphics, color -support for which is enabled by either running on a syscons VTY or some -other color-capable terminal emulator (newer versions of xterm will support -color when using the ``xterm-color'' termcap entry). -.Pp -This product is currently at the end of its life cycle and will -be replaced in FreeBSD 3.1 (hopefully) by the -.Xr setup 1 -utility. -.Sh RUNNING SCRIPTS -.Nm -may be either driven interactively through its various internal menus -or run in batch mode, driven by an external script. Such a script may -be loaded and executed in one of 3 ways: - -.Bl -tag -width Ds -compact -.It Sy "LOAD_CONFIG_FILE" -If -.Nm -is compiled with LOAD_CONFIG_FILE set in the environment -(or in the Makefile) to some value, then that value will -be used as the filename to automatically look for and load -when -.Nm -starts up and with no user interaction required. -This option is aimed primarily at large sites who wish to create a -single prototype install for multiple machines with largely identical -configurations and/or installation options. - -.It Sy "MAIN MENU" -If -.Nm -is run interactively, that is to say in the default manner, it will -bring up a main menu which contains a "load config file" option. -Selecting this option will prompt for the name of a script file which -it then will attempt to load from a DOS or UFS formatted floppy. - -.It Sy "COMMAND LINE" -Each command line argument is treated as a script directive -when -.Nm -is run in multi-user mode. Execution ends either by explicit request -(e.g. calling the -.Ar shutdown -directive), upon reaching the end of the argument list or on error. -.Pp -For example: -.nf - -/stand/sysinstall ftp=ftp:/ziggy/pub/ mediaSetFTP configPackages - -.fi -Would initialize -.Nm -for FTP installation media (using the server `ziggy') and then -bring up the package installation editor, exiting when finished. -.El -.Pp -.Sh SCRIPT SYNTAX -A script is a list of one or more directives, each directive taking -the form of: - -.Ar var=value -.Pp -.Ar function -.Pp -or -.Ar #somecomment - -Where -.Ar var=value -is the assignment of some internal -.Nm -variable, e.g. "ftpPass=FuNkYChiKn", and -.Ar function -is the name of an internal -.Nm -function, e.g. "mediaSetFTP", and -.Ar #comment -is a single-line comment for documentation purposes (ignored by -sysinstall). Each directive must be by itself on a single line, -functions taking their arguments by examining known variable names. -This requires that you be sure to assign the relevant variables before -calling a function which requires them. When and where a function -depends on the settings of one or more variables will be noted in the -following table: - -.Pp -\fBFunction Glossary:\fR -.Pp -.Bl -tag -width indent -.It configAnonFTP -Invoke the Anonymous FTP configuration menu. -.Pp -\fBVariables:\fR None -.It configRouter -Select which routing daemon you wish to use, potentially -loading any required 3rd-party routing daemons as necessary. -.Pp -\fBVariables:\fR -.Bl -tag -width indent -.It router -can be set to the name of the desired routing daemon, -e.g. ``routed'' or ``gated'', otherwise it is prompted for. -.El -.It configNFSServer -Configure host as an NFS server. -.Pp -\fBVariables:\fR None -.It configNTP -Configure host as a user of the Network Time Protocol. -.Pp -\fBVariables:\fR -.Bl -tag -width indent -.It ntpdate_flags -The flags to -.Xr ntpdate 8 , -that is to say the name of the server to sync from. -.El -.It configPCNFSD -Configure host to support PC NFS. -.Pp -\fBVariables:\fR -.Bl -tag -width indent -.It pcnfsd_pkg -The name of the PCNFSD package to load if necessary (defaults to hard coded -version). -.El -.It configPackages -Bring up the interactive package management menu. -.Pp -\fBVariables:\fR None -.It configRegister -Register the user with the FreeBSD counter. -.Pp -\fBVariables:\fR None -.It configUsers -Add users and/or groups to the system. -.Pp -\fBVariables:\fR None -.It configXEnvironment -Configure the X display subsystem. -.Pp -\fBVariables:\fR None -.It diskPartitionEditor -Invokes the disk partition (MBR) editor. -.Pp -\fBVariables:\fR -.Bl -tag -width findx -.It geometry -The disk geometry, as a cyls/heads/sectors formatted string. Default: no -change to geometry. -.It partition -Set to disk partitioning type or size, its value being -.Ar free -in order to use only remaining free space for FreeBSD, -.Ar all -to use the entire disk for FreeBSD but maintain a proper partition -table, -.Ar existing -to use an existing FreeBSD partition (first found), -.Ar exclusive -to use the disk in ``dangerously dedicated'' mode or, finally, -.Ar somenumber -to allocate -.Ar somenumber -blocks of available free space to a new FreeBSD partition. -Default: Interactive mode. -.It bootManager -is set to one of -.Ar boot -to signify the installation of a boot manager, -.Ar standard -to signify installation of a "standard" non-boot MGR DOS -MBR or -.Ar none -to indicate that no change to the boot manager is desired. -Default: none. -.El -.Pp -Note: Nothing is actually written to disk by this function, a explicit call to -.Ar diskPartitionWrite -being required for that to happen. -.It diskPartitionWrite -Causes any pending MBR changes (typically from the -.Ar diskPartitionEditor -function) to be written out. -.Pp -\fBVariables:\fR None -.It diskLabelEditor -Invokes the disk label editor. This is a bit trickier from a script -since you need to essentially label everything inside each FreeBSD -(type 0xA5) partition created by the -.Ar diskPartitionEditor -function, and that requires knowing a few rules about how things are -laid out. When creating a script to automatically allocate disk space -and partition it up, it is suggested that you first perform the -installation interactively at least once and take careful notes as to -what the slice names will be, then and only then hardwiring them into -the script. -.Pp -For example, let's say you have a SCSI disk on which you've created a new -FreeBSD partition in slice 2 (your DOS partition residing in slice 1). -The slice name would be -.Ar da0s2 -for the whole FreeBSD partition ( -.Ar da0s1 -being your DOS primary -partition). Now let's further assume that you have 500MB in this -partition and you want to sub-partition that space into root, swap, -var and usr file systems for FreeBSD. Your invocation of the -.Ar diskLabelEditor -function might involve setting the following variables: -.Bl -tag -width findx -.It Li "da0s2-1=ufs 40960 /" -A 20MB root file system (all sizes are in 512 byte blocks). -.It Li "da0s2-2=swap 131072 /" -A 64MB swap partition. -.It Li "da0s2-3=ufs 204800 /var" -A 100MB /var file system. -.It Li "da0s2-4=ufs 0 /usr" -With the balance of free space (around 316MB) going to the /usr -file system. -.El - -One can also use the -.Ar diskLabelEditor -for mounting or erasing existing partitions as well as creating new -ones. Using the previous example again, let's say that we also wanted -to mount our DOS partition and make sure that an -.Pa /etc/fstab -entry is created for it in the new installation. Before calling the -.Ar diskLabelEditor -function, we simply add an additional line: -.nf - da0s1=/dos_c N - -.fi -before the call. This tells the label editor that you want to mount -the first slice on -.Pa /dos_c -and not to attempt to newfs it (not that -.Nm -would attempt this for a DOS partition in any case, but it could just -as easily be an existing UFS partition being named here and the 2nd -field is non-optional). -.Pp -Note: No file system data is actually written to disk until an -explicit call to -.Ar diskLabelCommit -is made. -.It diskLabelCommit -Writes out all pending disklabel information and creates and/or mounts any -file systems which have requests pending from the -.Ar diskLabelEditor -function. -.Pp -\fBVariables:\fR None -.It distReset -Resets all selected distributions to the empty set (no distributions selected). -.Pp -\fBVariables:\fR None -.It distSetCustom -Allows the selection of a custom distribution set (e.g. not just on of the -existing "canned" sets) with no user interaction. -\fBVariables:\fR -.Bl -tag -width indent -.It dists -List of distributions to load. Possible distribution values are: -.Bl -tag -width indent -.It Li bin -The base binary distribution. -.It Li doc -Miscellaneous documentation -.It Li games -Games -.It Li manpages -Manual pages (unformatted) -.It Li catpages -Pre-formatted manual pages -.It Li proflibs -Profiled libraries for developers. -.It Li dict -Dictionary information (for tools like spell). -.It Li info -GNU info files and other extra docs. -.It Li des -DES encryption binaries and libraries. -.It Li compat1x -Compatibility with FreeBSD 1.x -.It Li compat20 -Compatibility with FreeBSD 2.0 -.It Li compat21 -Compatibility with FreeBSD 2.1 -.It Li ports -The ports collection. -.It Li krb -Kerberos binaries. -.It Li ssecure -/usr/src/secure -.It Li sebones -/usr/src/eBones -.It Li sbase -/usr/src/[top level files] -.It Li scontrib -/usr/src/contrib -.It Li sgnu -/usr/src/gnu -.It Li setc -/usr/src/etc -.It Li sgames -/usr/src/games -.It Li sinclude -/usr/src/include -.It Li slib -/usr/src/lib -.It Li slibexec -/usr/src/libexec -.It Li srelease -/usr/src/release -.It Li sbin -/usr/src/bin -.It Li ssbin -/usr/src/sbin -.It Li sshare -/usr/src/share -.It Li ssys -/usr/src/sys -.It Li subin -/usr/src/usr.bin -.It Li susbin -/usr/src/usr.sbin -.It Li ssmailcf -/usr/src/usr.sbin/sendmail/cf -.It Li XF86-xc -XFree86 official sources. -.It Li XF86-co -XFree86 contributed sources. -.It Li Xbin -XFree86 3.3.3 binaries. -.It Li Xcfg -XFree86 3.3.3 configuration files. -.It Li Xdoc -XFree86 3.3.3 documentation. -.It Li Xhtml -XFree86 3.3.3 HTML documentation. -.It Li Xlib -XFree86 3.3.3 libraries. -.It Li Xlk98 -XFree86 3.3.3 server link-kit for PC98 machines. -.It Li Xlkit -XFree86 3.3.3 server link-kit for standard machines. -.It Li Xman -XFree86 3.3.3 manual pages. -.It Li Xprog -XFree86 3.3.3 programmer's distribution. -.It Li Xps -XFree86 3.3.3 postscript documentation. -.It Li Xset -XFree86 3.3.3 graphical setup tool. -.It Li X8514 -XFree86 3.3.3 8514 server. -.It Li X9480 -XFree86 3.3.3 PC98 8-bit (256 color) PEGC-480 server. -.It Li X9EGC -XFree86 3.3.3 PC98 4-bit (16 color) EGC server. -.It Li X9GA9 -XFree86 3.3.3 PC98 GA-968V4/PCI (S3 968) server. -.It Li X9GAN -XFree86 3.3.3 PC98 GANB-WAP (cirrus) server. -.It Li X9LPW -XFree86 3.3.3 PC98 PowerWindowLB (S3) server. -.It Li X9NKV -XFree86 3.3.3 PC98 NKV-NEC (cirrus) server. -.It Li X9NS3 -XFree86 3.3.3 PC98 NEC (S3) server. -.It Li X9SPW -XFree86 3.3.3 PC98 SKB-PowerWindow (S3) server. -.It Li X9TGU -XFree86 3.3.3 PC98 Cyber9320 and TGUI9680 server. -.It Li X9WEP -XFree86 3.3.3 PC98 WAB-EP (cirrus) server. -.It Li X9WS -XFree86 3.3.3 PC98 WABS (cirrus) server. -.It Li X9WSN -XFree86 3.3.3 PC98 WSN-A2F (cirrus) server. -.It Li XAGX -XFree86 3.3.3 8 bit AGX server. -.It Li XI128 -XFree86 3.3.3 #9 Imagine I128 server. -.It Li XMa8 -XFree86 3.3.3 ATI Mach8 server. -.It Li XMa32 -XFree86 3.3.3 ATI Mach32 server. -.It Li XMa64 -XFree86 3.3.3 ATI Mach64 server. -.It Li XMono -XFree86 3.3.3 monochrome server. -.It Li XP9K -XFree86 3.3.3 P9000 server. -.It Li XS3 -XFree86 3.3.3 S3 server. -.It Li XS3V -XFree86 3.3.3 S3 Virge server. -.It Li XSVGA -XFree86 3.3.3 SVGA server. -.It Li XVG16 -XFree86 3.3.3 VGA16 server. -.It Li XW32 -XFree86 3.3.3 ET4000/W32, /W32i and /W32p server. -.It Li Xnest -XFree86 3.3.3 nested X server. -.It Li Xvfb -XFree86 3.3.3 virtual frame-buffer X server. -.It Li Xfnts -XFree86 3.3.3 base font set. -.It Li Xf100 -XFree86 3.3.3 100DPI font set. -.It Li Xfcyr -XFree86 3.3.3 Cyrillic font set. -.It Li Xfscl -XFree86 3.3.3 scalable font set. -.It Li Xfnon -XFree86 3.3.3 non-english font set. -.It Li Xfsrv -XFree86 3.3.3 font server. -.El -.It distSetDeveloper -Selects the standard Developer's distribution set. -.Pp -\fBVariables:\fR None -.It distSetXDeveloper -Selects the standard X Developer's distribution set. -.Pp -\fBVariables:\fR None -.It distSetKernDeveloper -Selects the standard kernel Developer's distribution set. -.Pp -\fBVariables:\fR None -.It distSetUser -Selects the standard user distribution set. -.Pp -\fBVariables:\fR None -.It distSetXUser -Selects the standard X user's distribution set. -.Pp -\fBVariables:\fR None -.It distSetMinimum -Selects the very minimum distribution set. -.Pp -\fBVariables:\fR None -.It distSetEverything -Selects the full whack - all available distributions. -.Pp -\fBVariables:\fR None -.It distSetDES -Interactively select DES subcomponents. -.Pp -\fBVariables:\fR None -.It distSetSrc -Interactively select source subcomponents. -.Pp -\fBVariables:\fR None -.It distSetXF86 -Interactively select XFree86 3.3.3 subcomponents. -.Pp -\fBVariables:\fR None -.It distExtractAll -Install all currently selected distributions (requires that -media device also be selected). -.Pp -\fBVariables:\fR None -.It docBrowser -Install (if necessary) an HTML documentation browser and go to the -HTML documentation submenu. -.Pp -\fBVariables:\fR -.Bl -tag -width indent -.It browserPackage -The name of the browser package to try and install as necessary. -Defaults to latest lynx package. -.It browserBinary -The name of the browser binary itself (if overriding the -.Ar browserPackage -variable). Defaults to lynx. -.El -.It installCommit -.Pp -Commit any and all pending changes to disk. This function -is essentially shorthand for a number of more granular "commit" -functions. -\fBVariables:\fR None -.It installExpress -Start an "express" installation, asking few questions of -the user. -.Pp -\fBVariables:\fR None -.It installNovice -Start a "novice" installation, the most user-friendly -installation type available. -.Pp -\fBVariables:\fR None -.It installUpgrade -Start an upgrade installation. -.Pp -\fBVariables:\fR None -.It installFixitHoloShell -Start up the "emergency holographic shell" over on VTY4 -if running as init. -.Pp -\fBVariables:\fR None -.It installFixitCDROM -Go into "fixit" mode, assuming a live file system CDROM -currently in the drive. -.Pp -\fBVariables:\fR None -.It installFixitFloppy -Go into "fixit" mode, assuming an available fixit floppy -disk (user will be prompted for it). -.Pp -\fBVariables:\fR None -.It installFilesystems -Do just the file system initialization part of an install. -.Pp -\fBVariables:\fR None -.It installVarDefaults -Initialize all variables to their defaults, overriding any -previous settings. -.Pp -\fBVariables:\fR None -.It loadConfig -Sort of like an #include statement, it allows you to load one -configuration file from another. -.Pp -\fBVariables:\fR -.Bl -tag -width indent -.It file -The fully pathname of the file to load. -.El -.It mediaSetCDROM -Select a FreeBSD CDROM as the installation media. -.Pp -\fBVariables:\fR None -.It mediaSetFloppy -Select a pre-made floppy installation set as the installation media. -.Pp -\fBVariables:\fR None -.It mediaSetDOS -Select an existing DOS primary partition as the installation media. -The first primary partition found is used (e.g. C:). -.Pp -\fBVariables:\fR None -.It mediaSetTape -Select a tape device as the installation media. -.Pp -\fBVariables:\fR None -.It mediaSetFTP -Select an FTP site as the installation media. -.Pp -\fBVariables:\fR -.Bl -tag -width indent -.It hostname -The name of the host being installed (non-optional). -.It domainname -The domain name of the host being installed (optional). -.It defaultrouter -The default router for this host (non-optional). -.It netDev -Which host interface to use ( -.Ar ed0 -or -.Ar ep0 , -for example. Non-optional). -.It netInteractive -If set, bring up the interactive network setup form even -if all relevant configuration variables are already set (optional). -.It ipaddr -The IP address for the selected host interface (non-optional). -.It netmask -The netmask for the selected host interface (non-optional). -.It ftp -The fully qualified URL of the FTP site containing the FreeBSD -distribution you're interested in, e.g. -.Ar ftp://ftp.freebsd.org/pub/FreeBSD/ . -.El -.It mediaSetFTPActive -Alias for -.Ar mediaSetFTP -using "active" FTP transfer mode. -.Pp -\fBVariables:\fR Same as for -.Ar mediaSetFTP . -.It mediaSetFTPPassive -Alias for -.Ar mediaSetFTP -using "passive" FTP transfer mode. -.Pp -\fBVariables:\fR Same as for -.Ar mediaSetFTP . -.It mediaSetUFS -Select an existing UFS partition (mounted with the label editor) as -the installation media. -.Pp -\fBVariables:\fR -.Bl -tag -width indent -.It ufs -full /path to directory containing the FreeBSD distribution you're -interested in. -.El -.It mediaSetNFS -.Pp -\fBVariables:\fR -.Bl -tag -width indent -.It hostname -The name of the host being installed (non-optional). -.It domainname -The domain name of the host being installed (optional). -.It defaultrouter -The default router for this host (non-optional). -.It netDev -Which host interface to use ( -.Ar ed0 -or -.Ar ep0 , -for example. Non-optional). -.It netInteractive -If set, bring up the interactive network setup form even -if all relevant configuration variables are already set (optional). -.It ipaddr -The IP address for the selected host interface (non-optional). -.It netmask -The netmask for the selected host interface (non-optional). -.It nfs -full hostname:/path specification for directory containing -the FreeBSD distribution you're interested in. -.El -.It mediaSetFTPUserPass -.Pp -\fBVariables:\fR -.Bl -tag -width indent -.It ftpUser -The username to log in as on the ftp server site. -Default: ftp -.It ftpPass -The password to use for this username on the ftp -server site. -Default: user@host -.El -.It mediaSetCPIOVerbosity -.Pp -\fBVariables:\fR -.Bl -tag -width indent -.It cpioVerbose -Can be used to set the verbosity of cpio extractions to low, medium or -high. -.El -.It mediaGetType -Interactively get the user to specify some type of media. -.Pp -\fBVariables:\fR None -.It optionsEditor -Invoke the interactive options editor. -.Pp -\fBVariables:\fR None -.It register -Bring up the FreeBSD registration form. -.Pp -\fBVariables:\fR None -.It packageAdd -Try to fetch and add a package to the system (requires -that a media type be set), -.Pp -\fBVariables:\fR -.Bl -tag -width indent -.It package -The name of the package to add, e.g. bash-1.14.7 or ncftp-2.4.2. -.El -.It addGroup -Invoke the interactive group editor. -.Pp -\fBVariables:\fR None -.It addUser -Invoke the interactive user editor. -.Pp -\fBVariables:\fR None -.It shutdown -Stop the script and terminate sysinstall. -.Pp -\fBVariables:\fR None -.It system -Execute an arbitrary command with -.Xr system 3 -.Pp -\fBVariables:\fR -.Bl -tag -width indent -.It command -The name of the command to execute. When running -from a boot floppy, very minimal expectations should -be made as to what's available until/unless a relatively -full system installation has just been done. -.El -.El -.Sh FILES -This utility may edit the contents of -.Pa /etc/rc.conf , -.Pa /etc/hosts , -and -.Pa /etc/resolv.conf -as necessary to reflect changes in the network configuration. -.Sh SEE ALSO -If you have a reasonably complete source tree online, take -a look at -.Pa /usr/src/release/sysinstall/install.cfg -for a sample installation script. -.Sh BUGS -This utility is a prototype which lasted approximately 3 years past -its expiration date and is greatly in need of death. -.Sh AUTHOR -Jordan K. Hubbard <jkh@FreeBSD.org> -.Sh HISTORY -This version of -.Nm -first appeared in -.Fx 2.0 . diff --git a/usr.sbin/sade/sade.h b/usr.sbin/sade/sade.h deleted file mode 100644 index a50eb3ee4050..000000000000 --- a/usr.sbin/sade/sade.h +++ /dev/null @@ -1,716 +0,0 @@ -/* - * The new sysinstall program. - * - * This is probably the last attempt in the `sysinstall' line, the next - * generation being slated to essentially a complete rewrite. - * - * $Id: sysinstall.h,v 1.152 1998/12/22 12:31:25 jkh Exp $ - * - * Copyright (c) 1995 - * Jordan Hubbard. 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, - * verbatim and that no modifications are made prior to this - * point in the file. - * 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 JORDAN HUBBARD ``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 JORDAN HUBBARD OR HIS PETS 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, LIFE 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. - * - */ - -#ifndef _SYSINSTALL_H_INCLUDE -#define _SYSINSTALL_H_INCLUDE - -#include <sys/types.h> -#include <sys/wait.h> -#include <errno.h> -#include <setjmp.h> -#include <stdio.h> -#include <stdlib.h> -#include <string.h> -#include <unistd.h> -#include <dialog.h> -#include "ui_objects.h" -#include "dir.h" -#include "colors.h" -#include "libdisk.h" -#include "dist.h" - -/*** Defines ***/ - -/* device limits */ -#define DEV_NAME_MAX 64 /* The maximum length of a device name */ -#define DEV_MAX 100 /* The maximum number of devices we'll deal with */ -#define INTERFACE_MAX 50 /* Maximum number of network interfaces we'll deal with */ -#define IO_ERROR -2 /* Status code for I/O error rather than normal EOF */ - -/* Number of seconds to wait for data to come off even the slowest media */ -#define MEDIA_TIMEOUT 300 - -/* - * I make some pretty gross assumptions about having a max of 50 chunks - * total - 8 slices and 42 partitions. I can't easily display many more - * than that on the screen at once! - * - * For 2.1 I'll revisit this and try to make it more dynamic, but since - * this will catch 99.99% of all possible cases, I'm not too worried. - */ -#define MAX_CHUNKS 40 - -/* Internal environment variable names */ -#define DISK_PARTITIONED "_diskPartitioned" -#define DISK_LABELLED "_diskLabelled" -#define DISK_SELECTED "_diskSelected" -#define SYSTEM_STATE "_systemState" -#define RUNNING_ON_ROOT "_runningOnRoot" -#define TCP_CONFIGURED "_tcpConfigured" - -/* Ones that can be tweaked from config files */ -#define VAR_BLANKTIME "blanktime" -#define VAR_BOOTMGR "bootManager" -#define VAR_BROWSER_BINARY "browserBinary" -#define VAR_BROWSER_PACKAGE "browserPackage" -#define VAR_CPIO_VERBOSITY "cpioVerbose" -#define VAR_DEBUG "debug" -#define VAR_DISK "disk" -#define VAR_DISTS "dists" -#define VAR_DIST_MAIN "distMain" -#define VAR_DIST_DES "distDES" -#define VAR_DIST_SRC "distSRC" -#define VAR_DIST_X11 "distX11" -#define VAR_DIST_XSERVER "distXserver" -#define VAR_DIST_XFONTS "distXfonts" -#define VAR_DEDICATE_DISK "dedicateDisk" -#define VAR_DOMAINNAME "domainname" -#define VAR_EDITOR "editor" -#define VAR_EXTRAS "ifconfig_" -#define VAR_COMMAND "command" -#define VAR_CONFIG_FILE "configFile" -#define VAR_FTP_DIR "ftpDirectory" -#define VAR_FTP_PASS "ftpPass" -#define VAR_FTP_PATH "ftp" -#define VAR_FTP_PORT "ftpPort" -#define VAR_FTP_STATE "ftpState" -#define VAR_FTP_USER "ftpUser" -#define VAR_FTP_HOST "ftpHost" -#define VAR_GATED_PKG "gated_pkg" -#define VAR_GATEWAY "defaultrouter" -#define VAR_GEOMETRY "geometry" -#define VAR_HOSTNAME "hostname" -#define VAR_IFCONFIG "ifconfig_" -#define VAR_INTERFACES "network_interfaces" -#define VAR_INSTALL_CFG "installConfig" -#define VAR_INSTALL_ROOT "installRoot" -#define VAR_IPADDR "ipaddr" -#define VAR_KEYMAP "keymap" -#define VAR_LABEL "label" -#define VAR_LABEL_COUNT "labelCount" -#define VAR_MEDIA_TYPE "mediaType" -#define VAR_MEDIA_TIMEOUT "MEDIA_TIMEOUT" -#define VAR_MOUSED "moused_enable" -#define VAR_MOUSED_PORT "moused_port" -#define VAR_MOUSED_TYPE "moused_type" -#define VAR_NAMESERVER "nameserver" -#define VAR_NETINTERACTIVE "netInteractive" -#define VAR_NETMASK "netmask" -#define VAR_NETWORK_DEVICE "netDev" -#define VAR_NFS_PATH "nfs" -#define VAR_NFS_HOST "nfsHost" -#define VAR_NFS_SECURE "nfsSecure" -#define VAR_NFS_SERVER "nfs_server_enable" -#define VAR_NO_CONFIRM "noConfirm" -#define VAR_NO_ERROR "noError" -#define VAR_NO_WARN "noWarn" -#define VAR_NO_USR "noUsr" -#define VAR_NONINTERACTIVE "nonInteractive" -#define VAR_NOVELL "novell" -#define VAR_NTPDATE_FLAGS "ntpdate_flags" -#define VAR_PACKAGE "package" -#define VAR_PARTITION "partition" -#define VAR_PCNFSD "pcnfsd" -#define VAR_PCNFSD_PKG "pcnfsd_pkg" -#define VAR_PKG_TMPDIR "PKG_TMPDIR" -#define VAR_PORTS_PATH "ports" -#define VAR_RELNAME "releaseName" -#define VAR_ROOT_SIZE "rootSize" -#define VAR_ROUTER "router" -#define VAR_ROUTER_ENABLE "router_enable" -#define VAR_ROUTERFLAGS "routerflags" -#define VAR_SERIAL_SPEED "serialSpeed" -#define VAR_SLOW_ETHER "slowEthernetCard" -#define VAR_SWAP_SIZE "swapSize" -#define VAR_TAPE_BLOCKSIZE "tapeBlocksize" -#define VAR_UFS_PATH "ufs" -#define VAR_USR_SIZE "usrSize" -#define VAR_VAR_SIZE "varSize" -#define VAR_XF86_CONFIG "xf86config" - -#define DEFAULT_TAPE_BLOCKSIZE "20" - -/* One MB worth of blocks */ -#define ONE_MEG 2048 - -/* Which selection attributes to use */ -#define ATTR_SELECTED (ColorDisplay ? item_selected_attr : item_attr) -#define ATTR_TITLE button_active_attr - -/* Handy strncpy() macro */ -#define SAFE_STRCPY(to, from) sstrncpy((to), (from), sizeof (to) - 1) - -/*** Types ***/ -typedef unsigned int Boolean; -typedef struct disk Disk; -typedef struct chunk Chunk; - -/* Bitfields for menu options */ -#define DMENU_NORMAL_TYPE 0x1 /* Normal dialog menu */ -#define DMENU_RADIO_TYPE 0x2 /* Radio dialog menu */ -#define DMENU_CHECKLIST_TYPE 0x4 /* Multiple choice menu */ -#define DMENU_SELECTION_RETURNS 0x8 /* Immediate return on item selection */ - -typedef struct _dmenu { - int type; /* What sort of menu we are */ - char *title; /* Our title */ - char *prompt; /* Our prompt */ - char *helpline; /* Line of help at bottom */ - char *helpfile; /* Help file for "F1" */ - dialogMenuItem items[0]; /* Array of menu items */ -} DMenu; - -/* An rc.conf variable */ -typedef struct _variable { - struct _variable *next; - char *name; - char *value; -} Variable; - -#define NO_ECHO_OBJ(type) ((type) | (DITEM_NO_ECHO << 16)) -#define TYPE_OF_OBJ(type) ((type) & 0xff) -#define ATTR_OF_OBJ(type) ((type) >> 16) - -/* A screen layout structure */ -typedef struct _layout { - int y; /* x & Y co-ordinates */ - int x; - int len; /* The size of the dialog on the screen */ - int maxlen; /* How much the user can type in ... */ - char *prompt; /* The string for the prompt */ - char *help; /* The display for the help line */ - void *var; /* The var to set when this changes */ - int type; /* The type of the dialog to create */ - void *obj; /* The obj pointer returned by libdialog */ -} Layout; - -typedef enum { - DEVICE_TYPE_NONE, - DEVICE_TYPE_DISK, - DEVICE_TYPE_FLOPPY, - DEVICE_TYPE_FTP, - DEVICE_TYPE_NETWORK, - DEVICE_TYPE_CDROM, - DEVICE_TYPE_TAPE, - DEVICE_TYPE_DOS, - DEVICE_TYPE_UFS, - DEVICE_TYPE_NFS, - DEVICE_TYPE_ANY, -} DeviceType; - -/* CDROM mount codes */ -#define CD_UNMOUNTED 0 -#define CD_ALREADY_MOUNTED 1 -#define CD_WE_MOUNTED_IT 2 - -/* A "device" from sysinstall's point of view */ -typedef struct _device { - char name[DEV_NAME_MAX]; - char *description; - char *devname; - DeviceType type; - Boolean enabled; - Boolean (*init)(struct _device *dev); - FILE * (*get)(struct _device *dev, char *file, Boolean probe); - void (*shutdown)(struct _device *dev); - void *private; - unsigned int flags; -} Device; - -/* Some internal representations of partitions */ -typedef enum { - PART_NONE, - PART_SLICE, - PART_SWAP, - PART_FILESYSTEM, - PART_FAT, -} PartType; - -/* The longest newfs command we'll hand to system() */ -#define NEWFS_CMD_MAX 256 - -typedef struct _part_info { - Boolean newfs; - char mountpoint[FILENAME_MAX]; - char newfs_cmd[NEWFS_CMD_MAX]; -} PartInfo; - -/* An option */ -typedef struct _opt { - char *name; - char *desc; - enum { OPT_IS_STRING, OPT_IS_INT, OPT_IS_FUNC, OPT_IS_VAR } type; - void *data; - void *aux; - char *(*check)(); -} Option; - -/* Weird index nodey things we use for keeping track of package information */ -typedef enum { PACKAGE, PLACE } node_type; /* Types of nodes */ - -typedef struct _pkgnode { /* A node in the reconstructed hierarchy */ - struct _pkgnode *next; /* My next sibling */ - node_type type; /* What am I? */ - char *name; /* My name */ - char *desc; /* My description (Hook) */ - struct _pkgnode *kids; /* My little children */ - void *data; /* A place to hang my data */ -} PkgNode; -typedef PkgNode *PkgNodePtr; - -/* A single package */ -typedef struct _indexEntry { /* A single entry in an INDEX file */ - char *name; /* name */ - char *path; /* full path to port */ - char *prefix; /* port prefix */ - char *comment; /* one line description */ - char *descrfile; /* path to description file */ - char *deps; /* packages this depends on */ - char *maintainer; /* maintainer */ -} IndexEntry; -typedef IndexEntry *IndexEntryPtr; - -typedef int (*commandFunc)(char *key, void *data); - -#define HOSTNAME_FIELD_LEN 128 -#define IPADDR_FIELD_LEN 16 -#define EXTRAS_FIELD_LEN 128 - -/* This is the structure that Network devices carry around in their private, erm, structures */ -typedef struct _devPriv { - char ipaddr[IPADDR_FIELD_LEN]; - char netmask[IPADDR_FIELD_LEN]; - char extras[EXTRAS_FIELD_LEN]; -} DevInfo; - - -/*** Externs ***/ -extern jmp_buf BailOut; /* Used to get the heck out */ -extern int DebugFD; /* Where diagnostic output goes */ -extern Boolean Fake; /* Don't actually modify anything - testing */ -extern Boolean SystemWasInstalled; /* Did we install it? */ -extern Boolean RunningAsInit; /* Are we running stand-alone? */ -extern Boolean DialogActive; /* Is the dialog() stuff up? */ -extern Boolean ColorDisplay; /* Are we on a color display? */ -extern Boolean OnVTY; /* On a syscons VTY? */ -extern Variable *VarHead; /* The head of the variable chain */ -extern Device *mediaDevice; /* Where we're getting our distribution from */ -extern unsigned int Dists; /* Which distributions we want */ -extern unsigned int DESDists; /* Which naughty distributions we want */ -extern unsigned int SrcDists; /* Which src distributions we want */ -extern unsigned int XF86Dists; /* Which XFree86 dists we want */ -extern unsigned int XF86ServerDists; /* The XFree86 servers we want */ -extern unsigned int XF86FontDists; /* The XFree86 fonts we want */ -extern int BootMgr; /* Which boot manager to use */ -extern int StatusLine; /* Where to print our status messages */ -extern DMenu MenuInitial; /* Initial installation menu */ -extern DMenu MenuFixit; /* Fixit repair menu */ -extern DMenu MenuMBRType; /* Type of MBR to write on the disk */ -extern DMenu MenuConfigure; /* Final configuration menu */ -extern DMenu MenuDocumentation; /* Documentation menu */ -extern DMenu MenuFTPOptions; /* FTP Installation options */ -extern DMenu MenuIndex; /* Index menu */ -extern DMenu MenuOptions; /* Installation options */ -extern DMenu MenuOptionsLanguage; /* Language options menu */ -extern DMenu MenuMedia; /* Media type menu */ -extern DMenu MenuMouse; /* Mouse type menu */ -extern DMenu MenuMediaCDROM; /* CDROM media menu */ -extern DMenu MenuMediaDOS; /* DOS media menu */ -extern DMenu MenuMediaFloppy; /* Floppy media menu */ -extern DMenu MenuMediaFTP; /* FTP media menu */ -extern DMenu MenuMediaTape; /* Tape media menu */ -extern DMenu MenuNetworkDevice; /* Network device menu */ -extern DMenu MenuNTP; /* NTP time server menu */ -extern DMenu MenuStartup; /* Startup services menu */ -extern DMenu MenuSyscons; /* System console configuration menu */ -extern DMenu MenuSysconsFont; /* System console font configuration menu */ -extern DMenu MenuSysconsKeymap; /* System console keymap configuration menu */ -extern DMenu MenuSysconsKeyrate; /* System console keyrate configuration menu */ -extern DMenu MenuSysconsSaver; /* System console saver configuration menu */ -extern DMenu MenuSysconsScrnmap; /* System console screenmap configuration menu */ -extern DMenu MenuNetworking; /* Network configuration menu */ -extern DMenu MenuInstallCustom; /* Custom Installation menu */ -extern DMenu MenuDistributions; /* Distribution menu */ -extern DMenu MenuSubDistributions; /* Custom distribution menu */ -extern DMenu MenuDESDistributions; /* DES distribution menu */ -extern DMenu MenuSrcDistributions; /* Source distribution menu */ -extern DMenu MenuXF86; /* XFree86 main menu */ -extern DMenu MenuXF86Select; /* XFree86 distribution selection menu */ -extern DMenu MenuXF86SelectCore; /* XFree86 core distribution menu */ -extern DMenu MenuXF86SelectServer; /* XFree86 server distribution menu */ -extern DMenu MenuXF86SelectPC98Server; /* XFree86 server distribution menu */ -extern DMenu MenuXF86SelectFonts; /* XFree86 font selection menu */ -extern DMenu MenuDiskDevices; /* Disk devices menu */ -extern DMenu MenuHTMLDoc; /* HTML Documentation menu */ -extern DMenu MenuUsermgmt; /* User management menu */ -extern DMenu MenuFixit; /* Fixit floppy/CDROM/shell menu */ -extern DMenu MenuXF86Config; /* Select XFree86 configuration type */ - -/* Stuff from libdialog which isn't properly declared outside */ -extern void display_helpfile(void); -extern void display_helpline(WINDOW *w, int y, int width); - -/*** Prototypes ***/ - -/* anonFTP.c */ -extern int configAnonFTP(dialogMenuItem *self); - -/* cdrom.c */ -extern Boolean mediaInitCDROM(Device *dev); -extern FILE *mediaGetCDROM(Device *dev, char *file, Boolean probe); -extern void mediaShutdownCDROM(Device *dev); - -/* command.c */ -extern void command_clear(void); -extern void command_sort(void); -extern void command_execute(void); -extern void command_shell_add(char *key, char *fmt, ...); -extern void command_func_add(char *key, commandFunc func, void *data); - -/* config.c */ -extern void configEnvironmentRC_conf(char *config); -extern void configEnvironmentResolv(char *config); -extern void configRC_conf(char *config); -extern int configFstab(dialogMenuItem *self); -extern int configRC(dialogMenuItem *self); -extern int configRegister(dialogMenuItem *self); -extern int configResolv(dialogMenuItem *self); -extern int configPackages(dialogMenuItem *self); -extern int configSaver(dialogMenuItem *self); -extern int configSaverTimeout(dialogMenuItem *self); -extern int configNTP(dialogMenuItem *self); -extern int configUsers(dialogMenuItem *self); -extern int configXEnvironment(dialogMenuItem *self); -extern int configRouter(dialogMenuItem *self); -extern int configPCNFSD(dialogMenuItem *self); -extern int configNFSServer(dialogMenuItem *self); -extern int configWriteRC_conf(dialogMenuItem *self); - -/* crc.c */ -extern int crc(int, unsigned long *, unsigned long *); - -/* devices.c */ -extern DMenu *deviceCreateMenu(DMenu *menu, DeviceType type, int (*hook)(dialogMenuItem *d), - int (*check)(dialogMenuItem *d)); -extern void deviceGetAll(void); -extern Device **deviceFind(char *name, DeviceType type); -extern Device **deviceFindDescr(char *name, char *desc, DeviceType class); -extern int deviceCount(Device **devs); -extern Device *new_device(char *name); -extern Device *deviceRegister(char *name, char *desc, char *devname, DeviceType type, Boolean enabled, - Boolean (*init)(Device *mediadev), - FILE * (*get)(Device *dev, char *file, Boolean probe), - void (*shutDown)(Device *mediadev), - void *private); -extern Boolean dummyInit(Device *dev); -extern FILE *dummyGet(Device *dev, char *dist, Boolean probe); -extern void dummyShutdown(Device *dev); - -/* disks.c */ -extern int diskPartitionEditor(dialogMenuItem *self); -extern int diskPartitionWrite(dialogMenuItem *self); -extern int diskGetSelectCount(Device ***devs); -extern void diskPartition(Device *dev); - -/* dispatch.c */ -extern int dispatchCommand(char *command); -extern int dispatch_load_floppy(dialogMenuItem *self); -extern int dispatch_load_file_int(int); -extern int dispatch_load_file(dialogMenuItem *self); - - -/* dist.c */ -extern int distReset(dialogMenuItem *self); -extern int distConfig(dialogMenuItem *self); -extern int distSetCustom(dialogMenuItem *self); -extern int distSetDeveloper(dialogMenuItem *self); -extern int distSetXDeveloper(dialogMenuItem *self); -extern int distSetKernDeveloper(dialogMenuItem *self); -extern int distSetUser(dialogMenuItem *self); -extern int distSetXUser(dialogMenuItem *self); -extern int distSetMinimum(dialogMenuItem *self); -extern int distSetEverything(dialogMenuItem *self); -extern int distSetDES(dialogMenuItem *self); -extern int distSetSrc(dialogMenuItem *self); -extern int distSetXF86(dialogMenuItem *self); -extern int distExtractAll(dialogMenuItem *self); - -/* dmenu.c */ -extern int dmenuDisplayFile(dialogMenuItem *tmp); -extern int dmenuSubmenu(dialogMenuItem *tmp); -extern int dmenuSystemCommand(dialogMenuItem *tmp); -extern int dmenuSystemCommandBox(dialogMenuItem *tmp); -extern int dmenuExit(dialogMenuItem *tmp); -extern int dmenuISetVariable(dialogMenuItem *tmp); -extern int dmenuSetVariable(dialogMenuItem *tmp); -extern int dmenuSetKmapVariable(dialogMenuItem *tmp); -extern int dmenuSetVariables(dialogMenuItem *tmp); -extern int dmenuToggleVariable(dialogMenuItem *tmp); -extern int dmenuSetFlag(dialogMenuItem *tmp); -extern int dmenuSetValue(dialogMenuItem *tmp); -extern Boolean dmenuOpen(DMenu *menu, int *choice, int *scroll, int *curr, int *max, Boolean buttons); -extern Boolean dmenuOpenSimple(DMenu *menu, Boolean buttons); -extern int dmenuVarCheck(dialogMenuItem *item); -extern int dmenuVarsCheck(dialogMenuItem *item); -extern int dmenuFlagCheck(dialogMenuItem *item); -extern int dmenuRadioCheck(dialogMenuItem *item); - -/* doc.c */ -extern int docBrowser(dialogMenuItem *self); -extern int docShowDocument(dialogMenuItem *self); - -/* dos.c */ -extern Boolean mediaCloseDOS(Device *dev, FILE *fp); -extern Boolean mediaInitDOS(Device *dev); -extern FILE *mediaGetDOS(Device *dev, char *file, Boolean probe); -extern void mediaShutdownDOS(Device *dev); - -/* floppy.c */ -extern int getRootFloppy(void); -extern Boolean mediaInitFloppy(Device *dev); -extern FILE *mediaGetFloppy(Device *dev, char *file, Boolean probe); -extern void mediaShutdownFloppy(Device *dev); - -/* ftp_strat.c */ -extern Boolean mediaCloseFTP(Device *dev, FILE *fp); -extern Boolean mediaInitFTP(Device *dev); -extern FILE *mediaGetFTP(Device *dev, char *file, Boolean probe); -extern void mediaShutdownFTP(Device *dev); - -/* globals.c */ -extern void globalsInit(void); - -/* index.c */ -int index_read(FILE *fp, PkgNodePtr papa); -int index_menu(PkgNodePtr top, PkgNodePtr plist, int *pos, int *scroll); -void index_init(PkgNodePtr top, PkgNodePtr plist); -void index_node_free(PkgNodePtr top, PkgNodePtr plist); -void index_sort(PkgNodePtr top); -void index_print(PkgNodePtr top, int level); -int index_extract(Device *dev, PkgNodePtr top, PkgNodePtr plist); - -/* install.c */ -extern Boolean checkLabels(Boolean whinge, Chunk **rdev, Chunk **sdev, Chunk **udev, Chunk **vdev); -extern int installCommit(dialogMenuItem *self); -extern int installCustomCommit(dialogMenuItem *self); -extern int installExpress(dialogMenuItem *self); -extern int installNovice(dialogMenuItem *self); -extern int installFixitHoloShell(dialogMenuItem *self); -extern int installFixitCDROM(dialogMenuItem *self); -extern int installFixitFloppy(dialogMenuItem *self); -extern int installFixupBin(dialogMenuItem *self); -extern int installFixupXFree(dialogMenuItem *self); -extern int installUpgrade(dialogMenuItem *self); -extern int installFilesystems(dialogMenuItem *self); -extern int installVarDefaults(dialogMenuItem *self); -extern void installEnvironment(void); -extern Boolean copySelf(void); - -/* kget.c */ -extern int kget(char *out); - -/* keymap.c */ -extern int loadKeymap(const char *lang); - -/* label.c */ -extern int diskLabelEditor(dialogMenuItem *self); -extern int diskLabelCommit(dialogMenuItem *self); - -/* lndir.c */ -extern int lndir(char *from, char *to); - -/* makedevs.c (auto-generated) */ -extern const char termcap_ansi[]; -extern const char termcap_vt100[]; -extern const char termcap_cons25[]; -extern const char termcap_cons25_m[]; -extern const char termcap_cons25r[]; -extern const char termcap_cons25r_m[]; -extern const char termcap_cons25l1[]; -extern const char termcap_cons25l1_m[]; -extern const u_char font_iso_8x16[]; -extern const u_char font_cp850_8x16[]; -extern const u_char font_cp866_8x16[]; -extern const u_char koi8_r2cp866[]; -extern u_char default_scrnmap[]; - -/* media.c */ -extern char *cpioVerbosity(void); -extern void mediaClose(void); -extern int mediaTimeout(void); -extern int mediaSetCDROM(dialogMenuItem *self); -extern int mediaSetFloppy(dialogMenuItem *self); -extern int mediaSetDOS(dialogMenuItem *self); -extern int mediaSetTape(dialogMenuItem *self); -extern int mediaSetFTP(dialogMenuItem *self); -extern int mediaSetFTPActive(dialogMenuItem *self); -extern int mediaSetFTPPassive(dialogMenuItem *self); -extern int mediaSetUFS(dialogMenuItem *self); -extern int mediaSetNFS(dialogMenuItem *self); -extern int mediaSetFTPUserPass(dialogMenuItem *self); -extern int mediaSetCPIOVerbosity(dialogMenuItem *self); -extern int mediaGetType(dialogMenuItem *self); -extern Boolean mediaExtractDist(char *dir, char *dist, FILE *fp); -extern Boolean mediaExtractDistBegin(char *dir, int *fd, int *zpid, int *cpic); -extern Boolean mediaExtractDistEnd(int zpid, int cpid); -extern Boolean mediaVerify(void); -extern FILE *mediaGenericGet(char *base, const char *file); - -/* misc.c */ -extern Boolean file_readable(char *fname); -extern Boolean file_executable(char *fname); -extern Boolean directory_exists(const char *dirname); -extern char *root_bias(char *path); -extern char *itoa(int value); -extern char *string_concat(char *p1, char *p2); -extern char *string_concat3(char *p1, char *p2, char *p3); -extern char *string_prune(char *str); -extern char *string_skipwhite(char *str); -extern char *string_copy(char *s1, char *s2); -extern char *pathBaseName(const char *path); -extern void safe_free(void *ptr); -extern void *safe_malloc(size_t size); -extern void *safe_realloc(void *orig, size_t size); -extern dialogMenuItem *item_add(dialogMenuItem *list, char *prompt, char *title, - int (*checked)(dialogMenuItem *self), - int (*fire)(dialogMenuItem *self), - void (*selected)(dialogMenuItem *self, int is_selected), - void *data, int aux, int *curr, int *max); -extern void items_free(dialogMenuItem *list, int *curr, int *max); -extern int Mkdir(char *); -extern int Mount(char *, void *data); -extern WINDOW *openLayoutDialog(char *helpfile, char *title, int x, int y, int width, int height); -extern ComposeObj *initLayoutDialog(WINDOW *win, Layout *layout, int x, int y, int *max); -extern int layoutDialogLoop(WINDOW *win, Layout *layout, ComposeObj **obj, - int *n, int max, int *cbutton, int *cancel); - -extern WINDOW *savescr(void); -extern void restorescr(WINDOW *w); -extern char *sstrncpy(char *dst, const char *src, int size); - -/* mouse.c */ -extern int mousedTest(dialogMenuItem *self); -extern int mousedDisable(dialogMenuItem *self); - -/* msg.c */ -extern Boolean isDebug(void); -extern void msgInfo(char *fmt, ...); -extern void msgYap(char *fmt, ...); -extern void msgWarn(char *fmt, ...); -extern void msgDebug(char *fmt, ...); -extern void msgError(char *fmt, ...); -extern void msgFatal(char *fmt, ...); -extern void msgConfirm(char *fmt, ...); -extern void msgNotify(char *fmt, ...); -extern void msgWeHaveOutput(char *fmt, ...); -extern int msgYesNo(char *fmt, ...); -extern char *msgGetInput(char *buf, char *fmt, ...); -extern int msgSimpleConfirm(char *); -extern int msgSimpleNotify(char *); - -/* network.c */ -extern Boolean mediaInitNetwork(Device *dev); -extern void mediaShutdownNetwork(Device *dev); - -/* nfs.c */ -extern Boolean mediaInitNFS(Device *dev); -extern FILE *mediaGetNFS(Device *dev, char *file, Boolean probe); -extern void mediaShutdownNFS(Device *dev); - -/* options.c */ -extern int optionsEditor(dialogMenuItem *self); - -/* package.c */ -extern int packageAdd(dialogMenuItem *self); -extern int package_add(char *name); -extern int package_extract(Device *dev, char *name, Boolean depended); -extern Boolean package_exists(char *name); - -/* register.c */ -extern int registerOpenDialog(void); - -/* system.c */ -extern void systemInitialize(int argc, char **argv); -extern void systemShutdown(int status); -extern int execExecute(char *cmd, char *name); -extern int systemExecute(char *cmd); -extern int systemDisplayHelp(char *file); -extern char *systemHelpFile(char *file, char *buf); -extern void systemChangeFont(const u_char font[]); -extern void systemChangeLang(char *lang); -extern void systemChangeTerminal(char *color, const u_char c_termcap[], char *mono, const u_char m_termcap[]); -extern void systemChangeScreenmap(const u_char newmap[]); -extern void systemCreateHoloshell(void); -extern int vsystem(char *fmt, ...); - -/* tape.c */ -extern char *mediaTapeBlocksize(void); -extern Boolean mediaInitTape(Device *dev); -extern FILE *mediaGetTape(Device *dev, char *file, Boolean probe); -extern void mediaShutdownTape(Device *dev); - -/* tcpip.c */ -extern int tcpOpenDialog(Device *dev); -extern int tcpMenuSelect(dialogMenuItem *self); -extern Device *tcpDeviceSelect(void); - -/* termcap.c */ -extern int set_termcap(void); - -/* ufs.c */ -extern void mediaShutdownUFS(Device *dev); -extern Boolean mediaInitUFS(Device *dev); -extern FILE *mediaGetUFS(Device *dev, char *file, Boolean probe); - -/* user.c */ -extern int userAddGroup(dialogMenuItem *self); -extern int userAddUser(dialogMenuItem *self); - -/* variable.c */ -extern void variable_set(char *var); -extern void variable_set2(char *name, char *value); -extern char *variable_get(char *var); -extern int variable_cmp(char *var, char *value); -extern void variable_unset(char *var); -extern char *variable_get_value(char *var, char *prompt); -extern int variable_check(char *data); -extern int dump_variables(dialogMenuItem *self); - -/* wizard.c */ -extern void slice_wizard(Disk *d); - -#endif -/* _SYSINSTALL_H_INCLUDE */ diff --git a/usr.sbin/sade/system.c b/usr.sbin/sade/system.c deleted file mode 100644 index 97b7d57008a4..000000000000 --- a/usr.sbin/sade/system.c +++ /dev/null @@ -1,396 +0,0 @@ -/* - * The new sysinstall program. - * - * This is probably the last program in the `sysinstall' line - the next - * generation being essentially a complete rewrite. - * - * $Id: system.c,v 1.86 1999/01/08 00:14:22 jkh Exp $ - * - * Jordan Hubbard - * - * My contributions are in the public domain. - * - * Parts of this file are also blatently stolen from Poul-Henning Kamp's - * previous version of sysinstall, and as such fall under his "BEERWARE license" - * so buy him a beer if you like it! Buy him a beer for me, too! - * Heck, get him completely drunk and send me pictures! :-) - */ - -#include "sysinstall.h" -#include <signal.h> -#include <sys/reboot.h> -#include <machine/console.h> -#include <sys/fcntl.h> -#include <sys/ioctl.h> -#include <sys/stat.h> - - -/* Where we stick our temporary expanded doc file */ -#define DOC_TMP_DIR "/tmp/.doc" -#define DOC_TMP_FILE "/tmp/.doc/doc.tmp" - -static pid_t ehs_pid; - -/* - * Handle interrupt signals - this probably won't work in all cases - * due to our having bogotified the internal state of dialog or curses, - * but we'll give it a try. - */ -static void -handle_intr(int sig) -{ - WINDOW *save = savescr(); - - if (!msgYesNo("Are you sure you want to abort the installation?")) - systemShutdown(-1); - else - restorescr(save); -} - -/* Expand a file into a convenient location, nuking it each time */ -static char * -expand(char *fname) -{ - char *gunzip = RunningAsInit ? "/stand/gunzip" : "/usr/bin/gunzip"; - - if (!directory_exists(DOC_TMP_DIR)) { - Mkdir(DOC_TMP_DIR); - if (chown(DOC_TMP_DIR, 0, 0) < 0) - return NULL; - if (chmod(DOC_TMP_DIR, S_IRWXU) < 0) - return NULL; - } - else - unlink(DOC_TMP_FILE); - if (!file_readable(fname) || vsystem("%s < %s > %s", gunzip, fname, DOC_TMP_FILE)) - return NULL; - return DOC_TMP_FILE; -} - -/* Initialize system defaults */ -void -systemInitialize(int argc, char **argv) -{ - int i; - - signal(SIGINT, SIG_IGN); - globalsInit(); - - /* Are we running as init? */ - if (getpid() == 1) { - int fd, type; - - RunningAsInit = 1; - setsid(); - close(0); - fd = open("/dev/ttyv0", O_RDWR); - if (fd == -1) - fd = open("/dev/console", O_RDWR); /* fallback */ - else - OnVTY = TRUE; - /* - * To make _sure_ we're on a VTY and don't have /dev/console switched - * away to a serial port or something, attempt to set the cursor appearance. - */ - type = 0; /* normal */ - if (OnVTY) { - int fd2; - - if ((fd2 = open("/dev/console", O_RDWR)) != -1) { - if (ioctl(fd2, CONS_CURSORTYPE, &type) == -1) { - OnVTY = FALSE; - close(fd); close(fd2); - open("/dev/console", O_RDWR); - } - else - close(fd2); - } - } - close(1); dup(0); - close(2); dup(0); - printf("%s running as init on %s\n", argv[0], OnVTY ? "vty0" : "serial console"); - i = ioctl(0, TIOCSCTTY, (char *)NULL); - setlogin("root"); - setenv("PATH", "/stand:/bin:/sbin:/usr/sbin:/usr/bin:/mnt/bin:/mnt/sbin:/mnt/usr/sbin:/mnt/usr/bin:/usr/X11R6/bin", 1); - setbuf(stdin, 0); - setbuf(stderr, 0); - } - else { - char hname[256]; - - /* Initalize various things for a multi-user environment */ - if (!gethostname(hname, sizeof hname)) - variable_set2(VAR_HOSTNAME, hname); - } - - if (set_termcap() == -1) { - printf("Can't find terminal entry\n"); - exit(-1); - } - - /* XXX - libdialog has particularly bad return value checking */ - init_dialog(); - - /* If we haven't crashed I guess dialog is running ! */ - DialogActive = TRUE; - - /* Make sure HOME is set for those utilities that need it */ - if (!getenv("HOME")) - setenv("HOME", "/", 1); - signal(SIGINT, handle_intr); - (void)vsystem("rm -rf %s", DOC_TMP_DIR); -} - -/* Close down and prepare to exit */ -void -systemShutdown(int status) -{ - /* If some media is open, close it down */ - if (status >=0 && mediaDevice) - mediaDevice->shutdown(mediaDevice); - - /* write out any changes to rc.conf .. */ - configRC_conf("/etc/rc.conf"); - - /* Shut down the dialog library */ - if (DialogActive) { - end_dialog(); - DialogActive = FALSE; - } - - /* Shut down curses */ - endwin(); - - /* If we have a temporary doc dir lying around, nuke it */ - (void)vsystem("rm -rf %s", DOC_TMP_DIR); - - /* REALLY exit! */ - if (RunningAsInit) { - /* Put the console back */ - ioctl(0, VT_ACTIVATE, 2); -#ifdef __alpha__ - reboot(RB_HALT); -#else - reboot(0); -#endif - } - else - exit(status); -} - -/* Run some general command */ -int -systemExecute(char *command) -{ - int status; - struct termios foo; - - dialog_update(); - end_dialog(); - DialogActive = FALSE; - if (tcgetattr(0, &foo) != -1) { - foo.c_cc[VERASE] = '\010'; - tcsetattr(0, TCSANOW, &foo); - } - if (!Fake) - status = system(command); - else { - status = 0; - msgDebug("systemExecute: Faked execution of `%s'\n", command); - } - DialogActive = TRUE; - return status; -} - -/* Display a help file in a filebox */ -int -systemDisplayHelp(char *file) -{ - char *fname = NULL; - char buf[FILENAME_MAX]; - int ret = 0; - - fname = systemHelpFile(file, buf); - if (!fname) { - snprintf(buf, FILENAME_MAX, "The %s file is not provided on this particular floppy image.", file); - use_helpfile(NULL); - use_helpline(NULL); - dialog_mesgbox("Sorry!", buf, -1, -1); - ret = 1; - } - else { - use_helpfile(NULL); - use_helpline(NULL); - dialog_textbox(file, fname, LINES, COLS); - } - return ret; -} - -char * -systemHelpFile(char *file, char *buf) -{ - if (!file) - return NULL; - - snprintf(buf, FILENAME_MAX, "/stand/help/%s.hlp.gz", file); - if (file_readable(buf)) - return expand(buf); - snprintf(buf, FILENAME_MAX, "/stand/help/%s.TXT.gz", file); - if (file_readable(buf)) - return expand(buf); - snprintf(buf, FILENAME_MAX, "/usr/src/release/sysinstall/help/%s.hlp", file); - if (file_readable(buf)) - return buf; - snprintf(buf, FILENAME_MAX, "/usr/src/release/sysinstall/help/%s.TXT", file); - if (file_readable(buf)) - return buf; - return NULL; -} - -void -systemChangeTerminal(char *color, const u_char c_term[], - char *mono, const u_char m_term[]) -{ - extern void init_acs(void); - - if (OnVTY) { - if (ColorDisplay) { - setenv("TERM", color, 1); - setenv("TERMCAP", c_term, 1); - reset_shell_mode(); - setterm(color); - init_acs(); - cbreak(); noecho(); - } - else { - setenv("TERM", mono, 1); - setenv("TERMCAP", m_term, 1); - reset_shell_mode(); - setterm(mono); - init_acs(); - cbreak(); noecho(); - } - } - clear(); - refresh(); - dialog_clear(); -} - -int -vsystem(char *fmt, ...) -{ - va_list args; - int pstat; - pid_t pid; - int omask; - sig_t intsave, quitsave; - char *cmd; - int i; - - cmd = (char *)alloca(FILENAME_MAX); - cmd[0] = '\0'; - va_start(args, fmt); - vsnprintf(cmd, FILENAME_MAX, fmt, args); - va_end(args); - - omask = sigblock(sigmask(SIGCHLD)); - if (Fake) { - msgDebug("vsystem: Faked execution of `%s'\n", cmd); - return 0; - } - if (isDebug()) - msgDebug("Executing command `%s'\n", cmd); - pid = fork(); - if (pid == -1) { - (void)sigsetmask(omask); - i = 127; - } - else if (!pid) { /* Junior */ - (void)sigsetmask(omask); - if (DebugFD != -1) { - dup2(DebugFD, 0); - dup2(DebugFD, 1); - dup2(DebugFD, 2); - } - else { - close(1); open("/dev/null", O_WRONLY); - dup2(1, 2); - } - if (!RunningAsInit) - execl("/bin/sh", "/bin/sh", "-c", cmd, (char *)NULL); - else - execl("/stand/sh", "/stand/sh", "-c", cmd, (char *)NULL); - exit(1); - } - else { - intsave = signal(SIGINT, SIG_IGN); - quitsave = signal(SIGQUIT, SIG_IGN); - pid = waitpid(pid, &pstat, 0); - (void)sigsetmask(omask); - (void)signal(SIGINT, intsave); - (void)signal(SIGQUIT, quitsave); - i = (pid == -1) ? -1 : WEXITSTATUS(pstat); - if (isDebug()) - msgDebug("Command `%s' returns status of %d\n", cmd, i); - } - return i; -} - -void -systemCreateHoloshell(void) -{ - if (OnVTY && RunningAsInit) { - - if (ehs_pid != 0) { - int pstat; - - if (kill(ehs_pid, 0) == 0) { - - if (msgYesNo("There seems to be an emergency holographic shell\n" - "already running von VTY 4.\n" - "Kill it and start a new one?")) - return; - - /* try cleaning up as much as possible */ - (void) kill(ehs_pid, SIGHUP); - sleep(1); - (void) kill(ehs_pid, SIGKILL); - } - - /* avoid too many zombies */ - (void) waitpid(ehs_pid, &pstat, WNOHANG); - } - - if ((ehs_pid = fork()) == 0) { - int i, fd; - struct termios foo; - extern int login_tty(int); - - ioctl(0, TIOCNOTTY, NULL); - for (i = getdtablesize(); i >= 0; --i) - close(i); - fd = open("/dev/ttyv3", O_RDWR); - ioctl(0, TIOCSCTTY, &fd); - dup2(0, 1); - dup2(0, 2); - DebugFD = 2; - if (login_tty(fd) == -1) - msgDebug("Doctor: I can't set the controlling terminal.\n"); - signal(SIGTTOU, SIG_IGN); - if (tcgetattr(fd, &foo) != -1) { - foo.c_cc[VERASE] = '\010'; - if (tcsetattr(fd, TCSANOW, &foo) == -1) - msgDebug("Doctor: I'm unable to set the erase character.\n"); - } - else - msgDebug("Doctor: I'm unable to get the terminal attributes!\n"); - execlp("sh", "-sh", 0); - msgDebug("Was unable to execute sh for Holographic shell!\n"); - exit(1); - } - else { - msgNotify("Starting an emergency holographic shell on VTY4"); - sleep(2); - } - } -} diff --git a/usr.sbin/sade/termcap.c b/usr.sbin/sade/termcap.c deleted file mode 100644 index 15694790c91d..000000000000 --- a/usr.sbin/sade/termcap.c +++ /dev/null @@ -1,135 +0,0 @@ -/* - * Copyright (c) 1994, Paul Richards. - * - * All rights reserved. - * - * This software may be used, modified, copied, distributed, and sold, in both - * source and binary form provided that the above copyright and these terms - * are retained, verbatim, as the first lines of this file. Under no - * circumstances is the author responsible for the proper functioning of this - * software, nor does the author assume any responsibility for damages - * incurred with its use. - */ - -#include "sysinstall.h" -#include <stdarg.h> -#include <fcntl.h> -#include <sys/errno.h> -#include <sys/ioctl.h> -#include <machine/console.h> - -#define VTY_STATUS_LINE 24 -#define TTY_STATUS_LINE 23 - -static void -prompt_term(char **termp, char **termcapp) -{ - char str[80]; - static struct { - const char *term, *termcap; - } lookup[] = { { "ansi", termcap_ansi }, - { "vt100", termcap_vt100 }, - { "cons25", termcap_cons25 }, - { "cons25-m", termcap_cons25_m } }; - - if (RunningAsInit) { - while (1) { - int i; - - printf("\nThese are the predefined terminal types available to\n"); - printf("sysinstall when running stand-alone. Please choose the\n"); - printf("closest match for your particular terminal.\n\n"); - printf("1 ...................... Standard ANSI terminal.\n"); - printf("2 ...................... VT100 or compatible terminal.\n"); - printf("3 ...................... FreeBSD system console (color).\n"); - printf("4 ...................... FreeBSD system console (monochrome).\n\n"); - printf("Your choice: (1-4) "); - fflush(stdout); - fgets(str, 80, stdin); - i = str[0] - '0'; - if (i > 0 && i < 5) { - *termp = (char *)lookup[i - 1].term; - *termcapp = (char *)lookup[i - 1].termcap; - break; - } - else - printf("\007Invalid choice, please try again.\n\n"); - } - } - else { - printf("\nPlease set your TERM variable before running this program.\n"); - printf("Defaulting to an ANSI compatible terminal - please press RETURN\n"); - fgets(str, 80, stdin); /* Just to make it interactive */ - *termp = (char *)"ansi"; - *termcapp = (char *)termcap_ansi; - } -} - -int -set_termcap(void) -{ - char *term; - int stat; - struct ttysize ts; - - term = getenv("TERM"); - stat = ioctl(STDERR_FILENO, GIO_COLOR, &ColorDisplay); - - if (!RunningAsInit) { - if (getenv("SYSINSTALL_DEBUG")) - DebugFD = open("sysinstall.debug", O_WRONLY|O_CREAT|O_TRUNC, 0644); - else - DebugFD = -1; - if (DebugFD < 0) - DebugFD = open("/dev/null", O_RDWR, 0); - } - - if (!OnVTY || (stat < 0)) { - if (!term) { - char *term, *termcap; - - prompt_term(&term, &termcap); - if (setenv("TERM", term, 1) < 0) - return -1; - if (setenv("TERMCAP", termcap, 1) < 0) - return -1; - } - if (DebugFD < 0) - DebugFD = open("/dev/null", O_RDWR, 0); - } - else { - int i, on; - - if (getpid() == 1) { - DebugFD = open("/dev/ttyv1", O_WRONLY); - if (DebugFD != -1) { - on = 1; - i = ioctl(DebugFD, TIOCCONS, (char *)&on); - msgDebug("ioctl(%d, TIOCCONS, NULL) = %d (%s)\n", - DebugFD, i, !i ? "success" : strerror(errno)); - } - } - if (ColorDisplay) { - if (!term) { - if (setenv("TERM", "cons25", 1) < 0) - return -1; - if (setenv("TERMCAP", termcap_cons25, 1) < 0) - return -1; - } - } - else { - if (!term) { - if (setenv("TERM", "cons25-m", 1) < 0) - return -1; - if (setenv("TERMCAP", termcap_cons25_m, 1) < 0) - return -1; - } - } - } - if (ioctl(0, TIOCGSIZE, &ts) == -1) { - msgDebug("Unable to get terminal size - errno %d\n", errno); - ts.ts_lines = 0; - } - StatusLine = ts.ts_lines ? ts.ts_lines - 1: (OnVTY ? VTY_STATUS_LINE : TTY_STATUS_LINE); - return 0; -} diff --git a/usr.sbin/sade/variable.c b/usr.sbin/sade/variable.c deleted file mode 100644 index 2dc227af619b..000000000000 --- a/usr.sbin/sade/variable.c +++ /dev/null @@ -1,224 +0,0 @@ -/* - * The new sysinstall program. - * - * This is probably the last program in the `sysinstall' line - the next - * generation being essentially a complete rewrite. - * - * $Id: variable.c,v 1.23 1998/03/15 17:10:17 jkh Exp $ - * - * Copyright (c) 1995 - * Jordan Hubbard. 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, - * verbatim and that no modifications are made prior to this - * point in the file. - * 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 JORDAN HUBBARD ``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 JORDAN HUBBARD OR HIS PETS 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, LIFE 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. - * - */ - -#include "sysinstall.h" - -/* Routines for dealing with variable lists */ - -static void -make_variable(char *var, char *value) -{ - Variable *vp; - - /* Trim leading and trailing whitespace */ - var = string_skipwhite(string_prune(var)); - - if (!var || !*var) - return; - - /* Put it in the environment in any case */ - setenv(var, value, 1); - - /* Now search to see if it's already in the list */ - for (vp = VarHead; vp; vp = vp->next) { - if (!strcmp(vp->name, var)) { - if (isDebug()) - msgDebug("variable %s was %s, now %s\n", vp->name, vp->value, value); - free(vp->value); - vp->value = strdup(value); - return; - } - } - - /* No? Create a new one */ - vp = (Variable *)safe_malloc(sizeof(Variable)); - vp->name = strdup(var); - vp->value = strdup(value); - vp->next = VarHead; - VarHead = vp; - if (isDebug()) - msgDebug("Setting variable %s to %s\n", vp->name, vp->value); -} - -void -variable_set(char *var) -{ - char tmp[1024], *cp; - - if (!var) - msgFatal("NULL variable name & value passed."); - else if (!*var) - msgDebug("Warning: Zero length name & value passed to variable_set()\n"); - SAFE_STRCPY(tmp, var); - if ((cp = index(tmp, '=')) == NULL) - msgFatal("Invalid variable format: %s", var); - *(cp++) = '\0'; - make_variable(tmp, string_skipwhite(cp)); -} - -void -variable_set2(char *var, char *value) -{ - if (!var || !value) - msgFatal("Null name or value passed to set_variable2!"); - else if (!*var || !*value) - msgDebug("Warning: Zero length name or value passed to variable_set2()\n"); - make_variable(var, value); -} - -char * -variable_get(char *var) -{ - return getenv(var); -} - -int -variable_cmp(char *var, char *value) -{ - char *val; - - if ((val = variable_get(var))) - return strcmp(val, value); - return -1; -} - -void -variable_unset(char *var) -{ - Variable *vp; - char name[512], *cp; - - if ((cp = index(var, '=')) != NULL) - sstrncpy(name, var, cp - var); - else - SAFE_STRCPY(name, var); - unsetenv(name); - /* Now search to see if it's in our list, if we have one.. */ - if (!VarHead) - return; - else if (!VarHead->next && !strcmp(VarHead->name, name)) { - safe_free(VarHead->name); - safe_free(VarHead->value); - free(VarHead); - VarHead = NULL; - } - else { - for (vp = VarHead; vp; vp = vp->next) { - if (!strcmp(vp->name, name)) { - Variable *save = vp->next; - - safe_free(vp->name); - safe_free(vp->value); - *vp = *save; - safe_free(save); - break; - } - } - } -} - -/* Prompt user for the name of a variable */ -char * -variable_get_value(char *var, char *prompt) -{ - char *cp; - - cp = variable_get(var); - if (cp && variable_get(VAR_NONINTERACTIVE)) - return cp; - else if ((cp = msgGetInput(cp, prompt)) != NULL) - variable_set2(var, cp); - else - cp = NULL; - return cp; -} - -/* Check if value passed in data (in the form "variable=value") is equal to value of - variable stored in env */ -int -variable_check(char *data) -{ - char *cp, *cp2, *cp3, tmp[256]; - - if (!data) - return FALSE; - SAFE_STRCPY(tmp, data); - if ((cp = index(tmp, '=')) != NULL) { - *(cp++) = '\0'; - if (*cp == '"') { /* smash quotes if present */ - ++cp; - if ((cp3 = index(cp, '"')) != NULL) - *cp3 = '\0'; - } - else if ((cp3 = index(cp, ',')) != NULL) - *cp3 = '\0'; - cp2 = getenv(tmp); - if (cp2) { - if (!*cp) - return TRUE; - else - return !strcmp(cp, cp2); - } - else - return FALSE; - } - else - return getenv(tmp) ? TRUE : FALSE; -} - -int -dump_variables(dialogMenuItem *unused) -{ - FILE *fp; - Variable *vp; - - if (isDebug()) - msgDebug("Writing sysinstall variables to file.."); - - fp = fopen("/etc/sysinstall.vars", "w"); - if (!fp) { - msgConfirm("Unable to write to /etc/sysinstall.vars: %s", - strerror(errno)); - return DITEM_FAILURE; - } - - for (vp = VarHead; vp; vp = vp->next) - fprintf(fp, "%s=\"%s\"\n", vp->name, vp->value); - - fclose(fp); - - return DITEM_SUCCESS; -} diff --git a/usr.sbin/sade/wizard.c b/usr.sbin/sade/wizard.c deleted file mode 100644 index 000966616993..000000000000 --- a/usr.sbin/sade/wizard.c +++ /dev/null @@ -1,206 +0,0 @@ -/* - * ---------------------------------------------------------------------------- - * "THE BEER-WARE LICENSE" (Revision 42): - * <phk@login.dknet.dk> wrote this file. As long as you retain this notice you - * can do whatever you want with this stuff. If we meet some day, and you think - * this stuff is worth it, you can buy me a beer in return. Poul-Henning Kamp - * ---------------------------------------------------------------------------- - * - * $Id: wizard.c,v 1.12 1998/09/08 10:46:40 jkh Exp $ - * - */ - -#include "sysinstall.h" -#include <fcntl.h> -#include <err.h> - -u_char mbr[] = { - 250,51,192,142,208,188,0,124,139,244,80,7,80,31,251,252,191,0,6,185,0,1, - 242,165,234,29,6,0,0,190,190,7,179,4,128,60,128,116,14,128,60,0,117,28, - 131,198,16,254,203,117,239,205,24,139,20,139,76,2,139,238,131,198,16,254, - 203,116,26,128,60,0,116,244,190,139,6,172,60,0,116,11,86,187,7,0,180,14, - 205,16,94,235,240,235,254,191,5,0,187,0,124,184,1,2,87,205,19,95,115,12, - 51,192,205,19,79,117,237,190,163,6,235,211,190,194,6,191,254,125,129,61, - 85,170,117,199,139,245,234,0,124,0,0,73,110,118,97,108,105,100,32,112,97, - 114,116,105,116,105,111,110,32,116,97,98,108,101,0,69,114,114,111,114,32, - 108,111,97,100,105,110,103,32,111,112,101,114,97,116,105,110,103,32,115, - 121,115,116,101,109,0,77,105,115,115,105,110,103,32,111,112,101,114,97, - 116,105,110,103,32,115,121,115,116,101,109,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,128, - 1,1,0,4,15,63,60,63,0,0,0,241,239,0,0,0,0,1,61,5,15,63,243,48,240,0,0,144, - 208,2,0,0,0,1,244,165,15,63,170,192,192,3,0,144,208,2,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,85,170 -}; - -int -scan_block(int fd, daddr_t block) -{ - u_char foo[512]; - - if (-1 == lseek(fd,block * 512,SEEK_SET)) - err(1,"lseek"); - if (512 != read(fd,foo, 512)) - return 1; - return 0; -} - -void -Scan_Disk(Disk *d) -{ - char device[64]; - u_long l; - int i,j,fd; - - strcpy(device,"/dev/r"); - strcat(device,d->name); - - fd = open(device,O_RDWR); - if (fd < 0) { - msgWarn("open(%s) failed", device); - return; - } - for(i=-1,l=0;;l++) { - j = scan_block(fd,l); - if (j != i) { - if (i == -1) { - printf("%c: %lu.",j ? 'B' : 'G', l); - fflush(stdout); - } else if (i == 0) { - printf(".%lu\nB: %lu.",l-1,l); - fflush(stdout); - } else { - printf(".%lu\nG: %lu.",l-1,l); - fflush(stdout); - } - i = j; - } - } - close(fd); -} - -void -slice_wizard(Disk *d) -{ - Disk *db; - char myprompt[BUFSIZ]; - char input[BUFSIZ]; - char *p,*q=0; - char **cp,*cmds[200]; - int ncmd,i; - - sprintf(myprompt,"%s> ", d->name); - while(1) { - printf("--==##==--\n"); - Debug_Disk(d); - p = CheckRules(d); - if (p) { - printf("%s",p); - free(p); - } - printf(myprompt); - fflush(stdout); - q = p = fgets(input,sizeof(input),stdin); - if(!p) - break; - for(cp = cmds; (*cp = strsep(&p, " \t\n")) != NULL;) - if (**cp != '\0') - cp++; - ncmd = cp - cmds; - if(!ncmd) - continue; - if (!strcasecmp(*cmds,"quit")) { break; } - if (!strcasecmp(*cmds,"exit")) { break; } - if (!strcasecmp(*cmds,"q")) { break; } - if (!strcasecmp(*cmds,"x")) { break; } - if (!strcasecmp(*cmds,"delete") && ncmd == 2) { - printf("delete = %d\n", - Delete_Chunk(d, - (struct chunk *)strtol(cmds[1],0,0))); - continue; - } - if (!strcasecmp(*cmds,"allfreebsd")) { - All_FreeBSD(d, 0); - continue; - } - if (!strcasecmp(*cmds,"dedicate")) { - All_FreeBSD(d, 1); - continue; - } - if (!strcasecmp(*cmds,"bios") && ncmd == 4) { - Set_Bios_Geom(d, - strtol(cmds[1],0,0), - strtol(cmds[2],0,0), - strtol(cmds[3],0,0)); - continue; - } - if (!strcasecmp(*cmds,"list")) { - cp = Disk_Names(); - printf("Disks:"); - for(i=0;cp[i];i++) { - printf(" %s",cp[i]); - free(cp[i]); - } - free(cp); - continue; - } - if (!strcasecmp(*cmds,"create") && ncmd == 6) { - - printf("Create=%d\n", - Create_Chunk(d, - strtol(cmds[1],0,0), - strtol(cmds[2],0,0), - strtol(cmds[3],0,0), - strtol(cmds[4],0,0), - strtol(cmds[5],0,0))); - continue; - } - if (!strcasecmp(*cmds,"read")) { - db = d; - if (ncmd > 1) - d = Open_Disk(cmds[1]); - else - d = Open_Disk(d->name); - if (d) - Free_Disk(db); - else - d = db; - continue; - } - if (!strcasecmp(*cmds,"scan")) { - Scan_Disk(d); - continue; - } - if (!strcasecmp(*cmds,"write")) { - printf("Write=%d\n", - Fake ? 0 : Write_Disk(d)); - Free_Disk(d); - d = Open_Disk(d->name); - continue; - } - if (strcasecmp(*cmds,"help")) - printf("\007ERROR\n"); - printf("CMDS:\n"); - printf("allfreebsd\t\t"); - printf("dedicate\t\t"); - printf("bios cyl hd sect\n"); - printf("collapse [pointer]\t\t"); - printf("create offset size enum subtype flags\n"); - printf("subtype(part): swap=1, ffs=7\t\t"); - printf("delete pointer\n"); - printf("list\t\t"); - printf("quit\n"); - printf("read [disk]\t\t"); - printf("scan\n"); - printf("write\t\t"); - printf("ENUM:\n\t"); - for(i=0;chunk_n[i];i++) - printf("%d = %s%s",i,chunk_n[i],i == 4 ? "\n\t" : " "); - printf("\n"); - - } -} diff --git a/usr.sbin/sysinstall/Makefile b/usr.sbin/sysinstall/Makefile deleted file mode 100644 index 10e0d6aab066..000000000000 --- a/usr.sbin/sysinstall/Makefile +++ /dev/null @@ -1,83 +0,0 @@ -PROG= sysinstall -MAN8= sysinstall.8 - -BINDIR=/stand -NOSHARED=YES - -CLEANFILES+= makedevs.c rtermcap rtermcap.tmp dumpnlist -CLEANFILES+= keymap.tmp keymap.h - -.PATH: ${.CURDIR}/../disklabel ${.CURDIR}/../../usr.bin/cksum - -SRCS= anonFTP.c cdrom.c command.c config.c devices.c kget.c \ - disks.c dispatch.c dist.c dmenu.c doc.c dos.c floppy.c \ - ftp.c globals.c index.c install.c installUpgrade.c keymap.c \ - label.c lndir.c main.c makedevs.c media.c menus.c misc.c mouse.c \ - msg.c network.c nfs.c options.c package.c register.c system.c \ - tape.c tcpip.c termcap.c ufs.c user.c variable.c wizard.c \ - keymap.h - -CFLAGS+= -Wall -I${.CURDIR}/../../gnu/lib/libdialog -I${.OBJDIR} -CFLAGS+= -I${.CURDIR}/../../sys -CFLAGS+= -DUC_PRIVATE -DKERN_NO_SYMBOLS - -DPADD= ${LIBDIALOG} ${LIBNCURSES} ${LIBMYTINFO} ${LIBUTIL} ${LIBDISK} ${LIBFTPIO} -LDADD= -ldialog -lncurses -lmytinfo -lutil -ldisk -lftpio - -makedevs.c: Makefile rtermcap keymap.h - rm -f makedevs.tmp - echo '#include <sys/types.h>' > makedevs.tmp - ./rtermcap ansi | \ - file2c 'const char termcap_ansi[] = {' ',0};' \ - >> makedevs.tmp - ./rtermcap cons25 | \ - file2c 'const char termcap_cons25[] = {' ',0};' \ - >> makedevs.tmp - ./rtermcap cons25-m | \ - file2c 'const char termcap_cons25_m[] = {' ',0};' \ - >> makedevs.tmp - ./rtermcap cons25r | \ - file2c 'const char termcap_cons25r[] = {' ',0};' \ - >> makedevs.tmp - ./rtermcap cons25r-m | \ - file2c 'const char termcap_cons25r_m[] = {' ',0};' \ - >> makedevs.tmp - ./rtermcap cons25l1 | \ - file2c 'const char termcap_cons25l1[] = {' ',0};' \ - >> makedevs.tmp - ./rtermcap cons25l1-m | \ - file2c 'const char termcap_cons25l1_m[] = {' ',0};' \ - >> makedevs.tmp - ./rtermcap vt100 | \ - file2c 'const char termcap_vt100[] = {' ',0};' \ - >> makedevs.tmp -.if ${MACHINE_ARCH} != "alpha" - file2c 'u_char boot0[] = {' '};' < /boot/boot0 >> makedevs.tmp -.endif - mv makedevs.tmp makedevs.c - -rtermcap: ${.CURDIR}/rtermcap.c - ${CC} -o rtermcap ${.CURDIR}/rtermcap.c -ltermcap - - -KEYMAPS= be.iso br275.iso danish.iso fr.iso german.iso it.iso \ - icelandic.iso jp.106 norwegian.iso ru.koi8-r si.iso spanish.iso \ - swedish.iso swissgerman.iso uk.iso us.dvorak us.iso - - -keymap.h: - rm -f keymap.tmp - for map in ${KEYMAPS} ; do \ - kbdcontrol -L $$map | \ - sed -e '/^static accentmap_t/,$$d' >> keymap.tmp ; \ - done - echo "static struct keymapInfo keymapInfos[] = {" >> keymap.tmp - for map in ${KEYMAPS} ; do \ - echo -n ' { "'$$map'", ' >> keymap.tmp ; \ - echo "&keymap_$$map }," | tr '[-.]' '_' >> keymap.tmp ; \ - done - ( echo " { 0 }"; echo "};" ; echo "" ) >> keymap.tmp - mv keymap.tmp keymap.h - - -.include <bsd.prog.mk> diff --git a/usr.sbin/sysinstall/anonFTP.c b/usr.sbin/sysinstall/anonFTP.c deleted file mode 100644 index 45edf71e8601..000000000000 --- a/usr.sbin/sysinstall/anonFTP.c +++ /dev/null @@ -1,316 +0,0 @@ -/* - * The new sysinstall program. - * - * This is probably the last program in the `sysinstall' line - the next - * generation being essentially a complete rewrite. - * - * $Id: anonFTP.c,v 1.22 1997/03/09 22:25:38 jkh Exp $ - * - * Copyright (c) 1995 - * Coranth Gryphon. All rights reserved. - * Copyright (c) 1996 - * Jordan K. Hubbard. 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, - * verbatim and that no modifications are made prior to this - * point in the file. - * 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 AUTHORS ``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 AUTHORS OR THEIR PETS 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, LIFE 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. - * - */ - -#include "sysinstall.h" -#include <sys/param.h> -#include <pwd.h> -#include <grp.h> - -/* This doesn't change until FTP itself changes */ - -#define FTP_NAME "ftp" -#define MOTD_FILE "ftpmotd" - -/* These change if we want to use different defaults */ - -#define FTP_UID 14 -#define FTP_GID 5 -#define FTP_GROUP "operator" -#define FTP_UPLOAD "incoming" -#define FTP_COMMENT "Anonymous FTP Admin" -#define FTP_HOMEDIR "/var/ftp" - -#define ANONFTP_HELPFILE "anonftp" - -/* Set up the structure to hold configuration information */ -/* Note that this is only what we could fit onto the one screen */ - -typedef struct -{ - char homedir[64]; /* Home Dir for Anon FTP */ - char group[32]; /* Group */ - char uid[8]; /* UID */ - char comment[64]; /* PWD Comment */ - char upload[32]; /* Upload Dir */ -} FTPConf; - -static FTPConf tconf; - -#define ANONFTP_HOMEDIR_LEN 64 -#define ANONFTP_COMMENT_LEN 64 -#define ANONFTP_UPLOAD_LEN 32 -#define ANONFTP_GROUP_LEN 32 -#define ANONFTP_UID_LEN 8 - -static int okbutton, cancelbutton; - -/* What the screen size is meant to be */ -#define ANONFTP_DIALOG_Y 0 -#define ANONFTP_DIALOG_X 8 -#define ANONFTP_DIALOG_WIDTH COLS - 16 -#define ANONFTP_DIALOG_HEIGHT LINES - 2 - -static Layout layout[] = { -#define LAYOUT_UID 0 - { 2, 3, 8, ANONFTP_UID_LEN - 1, - "UID:", "What user ID to assign to FTP Admin", - tconf.uid, STRINGOBJ, NULL }, -#define LAYOUT_GROUP 1 - { 2, 15, 15, ANONFTP_GROUP_LEN - 1, - "Group:", "Group name that ftp process belongs to", - tconf.group, STRINGOBJ, NULL }, -#define LAYOUT_COMMENT 2 - { 2, 35, 24, ANONFTP_COMMENT_LEN - 1, - "Comment:", "Password file comment for FTP Admin", - tconf.comment, STRINGOBJ, NULL }, -#define LAYOUT_HOMEDIR 3 - { 9, 10, 43, ANONFTP_HOMEDIR_LEN - 1, - "FTP Root Directory:", - "The top directory to chroot to when doing anonymous ftp", - tconf.homedir, STRINGOBJ, NULL }, -#define LAYOUT_UPLOAD 4 - { 14, 20, 22, ANONFTP_UPLOAD_LEN - 1, - "Upload Subdirectory:", "Designated sub-directory that holds uploads", - tconf.upload, STRINGOBJ, NULL }, -#define LAYOUT_OKBUTTON 5 - { 19, 15, 0, 0, - "OK", "Select this if you are happy with these settings", - &okbutton, BUTTONOBJ, NULL }, -#define LAYOUT_CANCELBUTTON 6 - { 19, 35, 0, 0, - "CANCEL", "Select this if you wish to cancel this screen", - &cancelbutton, BUTTONOBJ, NULL }, - { NULL }, -}; - -int -createFtpUser(void) -{ - struct passwd *tpw; - struct group *tgrp; - char pwline[256]; - char *tptr; - int gid; - FILE *fptr; - - if ((gid = atoi(tconf.group)) <= 0) { - if (!(tgrp = getgrnam(tconf.group))) { - /* group does not exist, create it by name */ - - tptr = msgGetInput("14", "What group ID to use for group %s ?", tconf.group); - if (tptr && *tptr && ((gid = atoi(tptr)) > 0)) { - if ((fptr = fopen(_PATH_GROUP,"a"))) { - fprintf(fptr,"%s:*:%d:%s\n",tconf.group,gid,FTP_NAME); - fclose(fptr); - } - } - else - gid = FTP_GID; - } - else - gid = tgrp->gr_gid; - } - else if (!getgrgid(gid)) { - /* group does not exist, create it by number */ - - tptr = msgGetInput("14", "What group name to use for gid %d ?", gid); - if (tptr && *tptr) { - SAFE_STRCPY(tconf.group, tptr); - if ((tgrp = getgrnam(tconf.group))) { - gid = tgrp->gr_gid; - } - else if ((fptr = fopen(_PATH_GROUP,"a"))) { - fprintf(fptr,"%s:*:%d:%s\n",tconf.group,gid,FTP_NAME); - fclose(fptr); - } - } - } - - if ((tpw = getpwnam(FTP_NAME))) { - if (tpw->pw_uid != FTP_UID) - msgConfirm("FTP user already exists with a different uid."); - - return DITEM_SUCCESS; /* succeeds if already exists */ - } - - sprintf(pwline, "%s:*:%s:%d::0:0:%s:%s:/nonexistent\n", FTP_NAME, tconf.uid, gid, tconf.comment, tconf.homedir); - - fptr = fopen(_PATH_MASTERPASSWD,"a"); - if (! fptr) { - msgConfirm("Could not open master password file."); - return DITEM_FAILURE; - } - fprintf(fptr, pwline); - fclose(fptr); - msgNotify("Remaking password file: %s", _PATH_MASTERPASSWD); - vsystem("pwd_mkdb -p %s", _PATH_MASTERPASSWD); - return DITEM_SUCCESS; -} - -/* This is it - how to get the setup values */ -static int -anonftpOpenDialog(void) -{ - WINDOW *ds_win; - ComposeObj *obj = NULL; - int n = 0, cancel = FALSE; - int max; - char title[80]; - - /* We need a curses window */ - if (!(ds_win = openLayoutDialog(ANONFTP_HELPFILE, " Anonymous FTP Configuration ", - ANONFTP_DIALOG_X, ANONFTP_DIALOG_Y, ANONFTP_DIALOG_WIDTH, ANONFTP_DIALOG_HEIGHT))) { - beep(); - msgConfirm("Cannot open anonymous ftp dialog window!!"); - return DITEM_FAILURE; - } - - /* Draw a sub-box for the path configuration */ - draw_box(ds_win, ANONFTP_DIALOG_Y + 7, ANONFTP_DIALOG_X + 8, - ANONFTP_DIALOG_HEIGHT - 11, ANONFTP_DIALOG_WIDTH - 17, - dialog_attr, border_attr); - wattrset(ds_win, dialog_attr); - sprintf(title, " Path Configuration "); - mvwaddstr(ds_win, ANONFTP_DIALOG_Y + 7, ANONFTP_DIALOG_X + 22, title); - - /** Initialize the config Data Structure **/ - bzero(&tconf, sizeof(tconf)); - - SAFE_STRCPY(tconf.group, FTP_GROUP); - SAFE_STRCPY(tconf.upload, FTP_UPLOAD); - SAFE_STRCPY(tconf.comment, FTP_COMMENT); - SAFE_STRCPY(tconf.homedir, FTP_HOMEDIR); - sprintf(tconf.uid, "%d", FTP_UID); - - /* Some more initialisation before we go into the main input loop */ - obj = initLayoutDialog(ds_win, layout, ANONFTP_DIALOG_X, ANONFTP_DIALOG_Y, &max); - - cancelbutton = okbutton = 0; - while (layoutDialogLoop(ds_win, layout, &obj, &n, max, &cancelbutton, &cancel)); - - /* Clear this crap off the screen */ - delwin(ds_win); - dialog_clear_norefresh(); - use_helpfile(NULL); - - if (cancel) - return DITEM_FAILURE; - return DITEM_SUCCESS; -} - -int -configAnonFTP(dialogMenuItem *self) -{ - int i; - - /* Be optimistic */ - i = DITEM_SUCCESS; - - dialog_clear_norefresh(); - i = anonftpOpenDialog(); - if (DITEM_STATUS(i) != DITEM_SUCCESS) { - msgConfirm("Configuration of Anonymous FTP cancelled per user request."); - return i | DITEM_RESTORE; - } - - /*** Use defaults for any invalid values ***/ - if (atoi(tconf.uid) <= 0) - sprintf(tconf.uid, "%d", FTP_UID); - - if (!tconf.group[0]) - SAFE_STRCPY(tconf.group, FTP_GROUP); - - if (!tconf.upload[0]) - SAFE_STRCPY(tconf.upload, FTP_UPLOAD); - - /*** If the user did not specify a directory, use default ***/ - - if (tconf.homedir[strlen(tconf.homedir) - 1] == '/') - tconf.homedir[strlen(tconf.homedir) - 1] = '\0'; - - if (!tconf.homedir[0]) - SAFE_STRCPY(tconf.homedir, FTP_HOMEDIR); - - /*** If HomeDir does not exist, create it ***/ - - if (!directory_exists(tconf.homedir)) - vsystem("mkdir -p %s", tconf.homedir); - - if (directory_exists(tconf.homedir)) { - msgNotify("Configuring %s for use by anon FTP.", tconf.homedir); - vsystem("chmod 555 %s && chown root.%s %s", tconf.homedir, tconf.group, tconf.homedir); - vsystem("mkdir %s/bin && chmod 555 %s/bin", tconf.homedir, tconf.homedir); - vsystem("cp /bin/ls %s/bin && chmod 111 %s/bin/ls", tconf.homedir, tconf.homedir); - vsystem("cp /bin/date %s/bin && chmod 111 %s/bin/date", tconf.homedir, tconf.homedir); - vsystem("mkdir %s/etc && chmod 555 %s/etc", tconf.homedir, tconf.homedir); - vsystem("mkdir -p %s/pub", tconf.homedir); - vsystem("mkdir -p %s/%s", tconf.homedir, tconf.upload); - vsystem("chmod 1777 %s/%s", tconf.homedir, tconf.upload); - - if (DITEM_STATUS(createFtpUser()) == DITEM_SUCCESS) { - msgNotify("Copying password information for anon FTP."); - vsystem("cp /etc/pwd.db %s/etc && chmod 444 %s/etc/pwd.db", tconf.homedir, tconf.homedir); - vsystem("cp /etc/passwd %s/etc && chmod 444 %s/etc/passwd", tconf.homedir, tconf.homedir); - vsystem("cp /etc/group %s/etc && chmod 444 %s/etc/group", tconf.homedir, tconf.homedir); - vsystem("chown -R root.%s %s/pub", tconf.group, tconf.homedir); - } - else { - msgConfirm("Unable to create FTP user! Anonymous FTP setup failed."); - i = DITEM_FAILURE; - } - - if (!msgYesNo("Create a welcome message file for anonymous FTP users?")) { - char cmd[256]; - dialog_clear(); - vsystem("echo Your welcome message here. > %s/etc/%s", tconf.homedir, MOTD_FILE); - sprintf(cmd, "%s %s/etc/%s", variable_get(VAR_EDITOR), tconf.homedir, MOTD_FILE); - if (!systemExecute(cmd)) - i = DITEM_SUCCESS; - else - i = DITEM_FAILURE; - } - } - else { - msgConfirm("Invalid Directory: %s\n" - "Anonymous FTP will not be set up.", tconf.homedir); - i = DITEM_FAILURE; - } - if (DITEM_STATUS(i) == DITEM_SUCCESS) - variable_set2("anon_ftp", "YES"); - return i | DITEM_RESTORE; -} diff --git a/usr.sbin/sysinstall/cdrom.c b/usr.sbin/sysinstall/cdrom.c deleted file mode 100644 index 011520211dbf..000000000000 --- a/usr.sbin/sysinstall/cdrom.c +++ /dev/null @@ -1,164 +0,0 @@ -/* - * The new sysinstall program. - * - * This is probably the last attempt in the `sysinstall' line, the next - * generation being slated to essentially a complete rewrite. - * - * $Id: cdrom.c,v 1.44 1998/12/22 12:31:24 jkh Exp $ - * - * Copyright (c) 1995 - * Jordan Hubbard. All rights reserved. - * Copyright (c) 1995 - * Gary J Palmer. 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, - * verbatim and that no modifications are made prior to this - * point in the file. - * 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 JORDAN HUBBARD ``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 JORDAN HUBBARD OR HIS PETS 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, LIFE 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. - * - */ - -/* These routines deal with getting things off of CDROM media */ - -#include "sysinstall.h" -#include <sys/stat.h> -#include <sys/errno.h> -#include <sys/param.h> -#include <sys/wait.h> -#include <unistd.h> -#include <grp.h> -#include <fcntl.h> -#include <libutil.h> - -#define CD9660 -#include <sys/mount.h> -#include <isofs/cd9660/cd9660_mount.h> -#undef CD9660 - -static Boolean cdromMounted; -static char mountpoint[] = "/dist"; - -static properties -read_props(char *name) -{ - int fd; - properties n; - - fd = open(name, O_RDONLY); - if (fd == -1) - return NULL; - n = properties_read(fd); - close(fd); - return n; -} - -Boolean -mediaInitCDROM(Device *dev) -{ - struct iso_args args; - properties cd_attr = NULL; - char *cp = NULL; - Boolean readInfo = TRUE; - static Boolean bogusCDOK = FALSE; - - if (cdromMounted) - return TRUE; - - Mkdir(mountpoint); - bzero(&args, sizeof(args)); - args.fspec = dev->devname; - args.flags = 0; - if (mount("cd9660", mountpoint, MNT_RDONLY, (caddr_t) &args) == -1) { - if (errno == EINVAL) { - msgConfirm("The CD in your drive looks more like an Audio CD than a FreeBSD release."); - return FALSE; - } - else if (errno != EBUSY) { - msgConfirm("Error mounting %s on %s: %s (%u)", dev->devname, mountpoint, strerror(errno), errno); - return FALSE; - } - } - cdromMounted = TRUE; - - if (!file_readable(string_concat(mountpoint, "/cdrom.inf")) && !bogusCDOK) { - if (msgYesNo("Warning: The CD currently in the drive is either not a FreeBSD\n" - "CD or it is an older (pre 2.1.5) FreeBSD CD which does not\n" - "have a version number on it. Do you wish to use this CD anyway?") != 0) { - unmount(mountpoint, MNT_FORCE); - cdromMounted = FALSE; - return FALSE; - } - else { - readInfo = FALSE; - bogusCDOK = TRUE; - } - } - - if (readInfo && - (!(cd_attr = read_props(string_concat(mountpoint, "/cdrom.inf"))) || - !(cp = property_find(cd_attr, "CD_VERSION")) || (strcmp(cp, variable_get(VAR_RELNAME)) && strcmp("none", variable_get(VAR_RELNAME))))) { - if (!cp) { - msgConfirm("Unable to find a %s/cdrom.inf file.\n" - "Either this is not a FreeBSD CDROM, there is a problem with\n" - "the CDROM driver or something is wrong with your hardware.\n" - "Please fix this problem (check the console logs on VTY2) and\n" - "try again.", mountpoint); - } - else if (!bogusCDOK) { - msgConfirm("Warning: The version of the FreeBSD CD currently in the drive\n" - "(%s) does not match the version of the boot floppy\n" - "(%s).\n\n" - "If this is intentional, to avoid this message in the future\n" - "please visit the Options editor to set the boot floppy version\n" - "string to match that of the CD before selecting it as your\n" - "installation media.", cp, variable_get(VAR_RELNAME)); - - if (msgYesNo("Would you like to try and use this CDROM anyway?") != 0) { - unmount(mountpoint, MNT_FORCE); - cdromMounted = FALSE; - properties_free(cd_attr); - return FALSE; - } - else - bogusCDOK = TRUE; - } - } - properties_free(cd_attr); - return TRUE; -} - -FILE * -mediaGetCDROM(Device *dev, char *file, Boolean probe) -{ - return mediaGenericGet(mountpoint, file); -} - -void -mediaShutdownCDROM(Device *dev) -{ - if (!cdromMounted) - return; - - if (unmount(mountpoint, MNT_FORCE) != 0) - msgConfirm("Could not unmount the CDROM from %s: %s", mountpoint, strerror(errno)); - else - cdromMounted = FALSE; -} diff --git a/usr.sbin/sysinstall/command.c b/usr.sbin/sysinstall/command.c deleted file mode 100644 index b14f913d706b..000000000000 --- a/usr.sbin/sysinstall/command.c +++ /dev/null @@ -1,179 +0,0 @@ -/* - * The new sysinstall program. - * - * This is probably the last program in the `sysinstall' line - the next - * generation being essentially a complete rewrite. - * - * $Id$ - * - * Copyright (c) 1995 - * Jordan Hubbard. 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, - * verbatim and that no modifications are made prior to this - * point in the file. - * 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 JORDAN HUBBARD ``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 JORDAN HUBBARD OR HIS PETS 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, LIFE 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. - * - */ - -#include "sysinstall.h" - -#define MAX_NUM_COMMANDS 10 - -typedef struct { - char key[FILENAME_MAX]; - struct { - enum { CMD_SHELL, CMD_FUNCTION } type; - void *ptr, *data; - } cmds[MAX_NUM_COMMANDS]; - int ncmds; -} Command; - -#define MAX_CMDS 200 -static Command *commandStack[MAX_CMDS]; -int numCommands; - -/* Nuke the command stack */ -void -command_clear(void) -{ - int i, j; - - for (i = 0; i < numCommands; i++) - for (j = 0; j < commandStack[i]->ncmds; j++) - if (commandStack[i]->cmds[j].type == CMD_SHELL) - free(commandStack[i]->cmds[j].ptr); - free(commandStack[i]); - numCommands = 0; -} - -static void -addit(char *key, int type, void *cmd, void *data) -{ - int i; - - /* First, look for the key already present and add a command to it if found */ - for (i = 0; i < numCommands; i++) { - if (!strcmp(commandStack[i]->key, key)) { - if (commandStack[i]->ncmds == MAX_NUM_COMMANDS) - msgFatal("More than %d commands stacked up behind %s??", MAX_NUM_COMMANDS, key); - commandStack[i]->cmds[commandStack[i]->ncmds].type = type; - commandStack[i]->cmds[commandStack[i]->ncmds].ptr = cmd; - commandStack[i]->cmds[commandStack[i]->ncmds].data = data; - ++(commandStack[i]->ncmds); - return; - } - } - if (numCommands == MAX_CMDS) - msgFatal("More than %d commands accumulated??", MAX_CMDS); - - /* If we fell to here, it's a new key */ - commandStack[numCommands] = safe_malloc(sizeof(Command)); - strcpy(commandStack[numCommands]->key, key); - commandStack[numCommands]->ncmds = 1; - commandStack[numCommands]->cmds[0].type = type; - commandStack[numCommands]->cmds[0].ptr = cmd; - commandStack[numCommands]->cmds[0].data = data; - ++numCommands; -} - -/* Add a shell command under a given key */ -void -command_shell_add(char *key, char *fmt, ...) -{ - va_list args; - char *cmd; - - cmd = (char *)safe_malloc(256); - va_start(args, fmt); - vsnprintf(cmd, 256, fmt, args); - va_end(args); - - addit(key, CMD_SHELL, cmd, NULL); -} - -/* Add a shell command under a given key */ -void -command_func_add(char *key, commandFunc func, void *data) -{ - addit(key, CMD_FUNCTION, func, data); -} - -static int -sort_compare(Command *p1, Command *p2) -{ - if (!p1 && !p2) - return 0; - else if (!p1 && p2) /* NULL has a "greater" value for commands */ - return 1; - else if (p1 && !p2) - return -1; - else - return strcmp(p1->key, p2->key); -} - -void -command_sort(void) -{ - int i, j; - - commandStack[numCommands] = NULL; - /* Just do a crude bubble sort since the list is small */ - for (i = 0; i < numCommands; i++) { - for (j = 0; j < numCommands; j++) { - if (sort_compare(commandStack[j], commandStack[j + 1]) > 0) { - Command *tmp = commandStack[j]; - - commandStack[j] = commandStack[j + 1]; - commandStack[j + 1] = tmp; - } - } - } -} - -/* Run all accumulated commands in sorted order */ -void -command_execute(void) -{ - int i, j, ret; - commandFunc func; - - for (i = 0; i < numCommands; i++) { - for (j = 0; j < commandStack[i]->ncmds; j++) { - /* If it's a shell command, run system on it */ - if (commandStack[i]->cmds[j].type == CMD_SHELL) { - msgNotify("Doing %s", commandStack[i]->cmds[j].ptr); - ret = vsystem((char *)commandStack[i]->cmds[j].ptr); - if (isDebug()) - msgDebug("Command `%s' returns status %d\n", commandStack[i]->cmds[j].ptr, ret); - } - else { - /* It's a function pointer - call it with the key and the data */ - func = (commandFunc)commandStack[i]->cmds[j].ptr; - if (isDebug()) - msgDebug("%x: Execute(%s, %s)", func, commandStack[i]->key, commandStack[i]->cmds[j].data); - ret = (*func)(commandStack[i]->key, commandStack[i]->cmds[j].data); - if (isDebug()) - msgDebug("Function @ %x returns status %d\n", commandStack[i]->cmds[j].ptr, ret); - } - } - } -} diff --git a/usr.sbin/sysinstall/config.c b/usr.sbin/sysinstall/config.c deleted file mode 100644 index 878a2324b2a7..000000000000 --- a/usr.sbin/sysinstall/config.c +++ /dev/null @@ -1,780 +0,0 @@ -/* - * The new sysinstall program. - * - * This is probably the last program in the `sysinstall' line - the next - * generation being essentially a complete rewrite. - * - * $Id: config.c,v 1.114 1998/10/14 01:04:44 jkh Exp $ - * - * Copyright (c) 1995 - * Jordan Hubbard. 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, - * verbatim and that no modifications are made prior to this - * point in the file. - * 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 JORDAN HUBBARD ``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 JORDAN HUBBARD OR HIS PETS 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, LIFE 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. - * - */ - -#include "sysinstall.h" -#include <sys/disklabel.h> -#include <sys/wait.h> -#include <sys/errno.h> -#include <sys/ioctl.h> -#include <sys/fcntl.h> -#include <sys/param.h> -#include <sys/stat.h> -#include <unistd.h> -#include <sys/mount.h> - -static Chunk *chunk_list[MAX_CHUNKS]; -static int nchunks; -static int rootdev_is_od; - -/* arg to sort */ -static int -chunk_compare(Chunk *c1, Chunk *c2) -{ - if (!c1 && !c2) - return 0; - else if (!c1 && c2) - return 1; - else if (c1 && !c2) - return -1; - else if (!c1->private_data && !c2->private_data) - return 0; - else if (c1->private_data && !c2->private_data) - return 1; - else if (!c1->private_data && c2->private_data) - return -1; - else - return strcmp(((PartInfo *)(c1->private_data))->mountpoint, ((PartInfo *)(c2->private_data))->mountpoint); -} - -static void -chunk_sort(void) -{ - int i, j; - - for (i = 0; i < nchunks; i++) { - for (j = 0; j < nchunks; j++) { - if (chunk_compare(chunk_list[j], chunk_list[j + 1]) > 0) { - Chunk *tmp = chunk_list[j]; - - chunk_list[j] = chunk_list[j + 1]; - chunk_list[j + 1] = tmp; - } - } - } -} - -static void -check_rootdev(Chunk **list, int n) -{ - int i; - Chunk *c; - - rootdev_is_od = 0; - for (i = 0; i < n; i++) { - c = *list++; - if (c->type == part && (c->flags & CHUNK_IS_ROOT) - && strncmp(c->disk->name, "od", 2) == 0) - rootdev_is_od = 1; - } -} - -static char * -name_of(Chunk *c1) -{ - return c1->name; -} - -static char * -mount_point(Chunk *c1) -{ - if (c1->type == part && c1->subtype == FS_SWAP) - return "none"; - else if (c1->type == part || c1->type == fat) - return ((PartInfo *)c1->private_data)->mountpoint; - return "/bogus"; -} - -static char * -fstype(Chunk *c1) -{ - if (c1->type == fat) - return "msdos"; - else if (c1->type == part) { - if (c1->subtype != FS_SWAP) - return "ufs"; - else - return "swap"; - } - return "bogus"; -} - -static char * -fstype_short(Chunk *c1) -{ - if (c1->type == part) { - if (c1->subtype != FS_SWAP) { - if (rootdev_is_od == 0 && strncmp(c1->name, "od", 2) == 0) - return "rw,noauto"; - else - return "rw"; - } - else - return "sw"; - } - else if (c1->type == fat) { - if (strncmp(c1->name, "od", 2) == 0) - return "ro,noauto"; - else - return "ro"; - } - return "bog"; -} - -static int -seq_num(Chunk *c1) -{ - if (c1->type == part && c1->subtype != FS_SWAP) { - if (rootdev_is_od == 0 && strncmp(c1->name, "od", 2) == 0) - return 0; - else if (c1->flags & CHUNK_IS_ROOT) - return 1; - else - return 2; - } - return 0; -} - -int -configFstab(dialogMenuItem *self) -{ - Device **devs; - Disk *disk; - FILE *fstab; - int i, cnt; - Chunk *c1, *c2; - - if (!RunningAsInit) { - if (file_readable("/etc/fstab")) - return DITEM_SUCCESS; - else { - msgConfirm("Attempting to rebuild your /etc/fstab file. Warning: If you had\n" - "any CD devices in use before running sysinstall then they may NOT\n" - "be found by this run!"); - } - } - - devs = deviceFind(NULL, DEVICE_TYPE_DISK); - if (!devs) { - msgConfirm("No disks found!"); - return DITEM_FAILURE; - } - - /* Record all the chunks */ - nchunks = 0; - for (i = 0; devs[i]; i++) { - if (!devs[i]->enabled) - continue; - disk = (Disk *)devs[i]->private; - if (!disk->chunks) - msgFatal("No chunk list found for %s!", disk->name); - for (c1 = disk->chunks->part; c1; c1 = c1->next) { - if (c1->type == freebsd) { - for (c2 = c1->part; c2; c2 = c2->next) { - if (c2->type == part && (c2->subtype == FS_SWAP || c2->private_data)) - chunk_list[nchunks++] = c2; - } - } - else if (c1->type == fat && c1->private_data) - chunk_list[nchunks++] = c1; - } - } - chunk_list[nchunks] = 0; - chunk_sort(); - - fstab = fopen("/etc/fstab", "w"); - if (!fstab) { - msgConfirm("Unable to create a new /etc/fstab file! Manual intervention\n" - "will be required."); - return DITEM_FAILURE; - } - - check_rootdev(chunk_list, nchunks); - - /* Go for the burn */ - msgDebug("Generating /etc/fstab file\n"); - fprintf(fstab, "# Device\t\tMountpoint\tFStype\tOptions\t\tDump\tPass#\n"); - for (i = 0; i < nchunks; i++) - fprintf(fstab, "/dev/%s\t\t%s\t\t%s\t%s\t\t%d\t%d\n", name_of(chunk_list[i]), mount_point(chunk_list[i]), - fstype(chunk_list[i]), fstype_short(chunk_list[i]), seq_num(chunk_list[i]), seq_num(chunk_list[i])); - - /* Now look for the CDROMs */ - devs = deviceFind(NULL, DEVICE_TYPE_CDROM); - cnt = deviceCount(devs); - - /* Write out the CDROM entries */ - for (i = 0; i < cnt; i++) { - char cdname[10]; - - sprintf(cdname, "/cdrom%s", i ? itoa(i) : ""); - if (Mkdir(cdname)) - msgConfirm("Unable to make mount point for: %s", cdname); - else - fprintf(fstab, "/dev/%s\t\t%s\tcd9660\tro,noauto\t0\t0\n", devs[i]->name, cdname); - } - - /* And finally, a /proc. */ - fprintf(fstab, "proc\t\t\t/proc\t\tprocfs\trw\t\t0\t0\n"); - Mkdir("/proc"); - - fclose(fstab); - if (isDebug()) - msgDebug("Wrote out /etc/fstab file\n"); - return DITEM_SUCCESS; -} - -/* Do the work of sucking in a config file. - * config is the filename to read in. - * lines is a fixed (max) sized array of char* - * returns number of lines read. line contents - * are malloc'd and must be freed by the caller. - */ -int -readConfig(char *config, char **lines, int max) -{ - FILE *fp; - char line[256]; - int i, nlines; - - fp = fopen(config, "r"); - if (!fp) - return -1; - - nlines = 0; - /* Read in the entire file */ - for (i = 0; i < max; i++) { - if (!fgets(line, sizeof line, fp)) - break; - lines[nlines++] = strdup(line); - } - fclose(fp); - if (isDebug()) - msgDebug("readConfig: Read %d lines from %s.\n", nlines, config); - return nlines; -} - -#define MAX_LINES 2000 /* Some big number we're not likely to ever reach - I'm being really lazy here, I know */ - -/* Load the environment from an rc.conf file */ -void -configEnvironmentRC_conf(char *config) -{ - char *lines[MAX_LINES], *cp, *cp2; - int i, nlines; - - nlines = readConfig(config, lines, MAX_LINES); - if (nlines == -1) - return; - - for (i = 0; i < nlines; i++) { - /* Skip the comments & non-variable settings */ - if (lines[i][0] == '#' || !(cp = index(lines[i], '='))) { - free(lines[i]); - continue; - } - *cp++ = '\0'; - /* Find quotes */ - if ((cp2 = index(cp, '"')) || (cp2 = index(cp, '\047'))) { - cp = cp2 + 1; - cp2 = index(cp, *cp2); - } - /* If valid quotes, use it */ - if (cp2) { - *cp2 = '\0'; - /* If we have a legit value and it's not already set, set it */ - if (strlen(cp) && !variable_get(lines[i])) - variable_set2(lines[i], cp); - } - free(lines[i]); - } -} - -/* Load the environment from a resolv.conf file */ -void -configEnvironmentResolv(char *config) -{ - char *lines[MAX_LINES]; - int i, nlines; - - nlines = readConfig(config, lines, MAX_LINES); - if (nlines == -1) - return; - for (i = 0; i < nlines; i++) { - Boolean name_set = (Boolean)variable_get(VAR_NAMESERVER); - - if (!strncmp(lines[i], "domain", 6) && !variable_get(VAR_DOMAINNAME)) - variable_set2(VAR_DOMAINNAME, string_skipwhite(string_prune(lines[i] + 6))); - else if (!name_set && !strncmp(lines[i], "nameserver", 10)) { - /* Only take the first nameserver setting - we're lame */ - variable_set2(VAR_NAMESERVER, string_skipwhite(string_prune(lines[i] + 10))); - } - free(lines[i]); - } -} - -/* Version of below for dispatch routines */ -int -configRC(dialogMenuItem *unused) -{ - configRC_conf("/etc/rc.conf"); - return DITEM_SUCCESS; -} - -/* - * This sucks in /etc/rc.conf, substitutes anything needing substitution, then - * writes it all back out. It's pretty gross and needs re-writing at some point. - */ -void -configRC_conf(char *config) -{ - FILE *fp; - char *lines[MAX_LINES], *cp; - Variable *v; - int i, nlines, len; - - nlines = readConfig(config, lines, MAX_LINES); - if (nlines == -1) - return; - - /* Now do variable substitutions */ - for (v = VarHead; v; v = v->next) { - for (i = 0; i < nlines; i++) { - /* Skip the comments & non-variable settings */ - if (lines[i][0] == '#' || !(cp = index(lines[i], '='))) - continue; - len = strlen(v->name); - if (!strncmp(lines[i], v->name, cp - lines[i]) && (cp - lines[i]) == len) { - char *cp2, *comment = NULL; - - /* If trailing comment, try and preserve it */ - if ((index(lines[i], '#')) != NULL) { - /* Find quotes */ - if ((cp2 = index(cp, '"')) || (cp2 = index(cp, '\047'))) - cp2 = index(cp2 + 1, *cp2); - if (cp2 && strlen(cp2 + 1)) { - comment = alloca(strlen(cp2)); - strcpy(comment, cp2 + 1); - } - } - free(lines[i]); - lines[i] = (char *)malloc(strlen(v->name) + strlen(v->value) + (comment ? strlen(comment) : 0) + 10); - if (comment) - sprintf(lines[i], "%s=\"%s\"%s", v->name, v->value, comment); - else - sprintf(lines[i], "%s=\"%s\"\n", v->name, v->value); - } - } - } - - /* Now write it all back out again */ - if (isDebug()) - msgDebug("Writing configuration changes to %s file..", config); - if (Fake) - fp = fdopen(DebugFD, "w"); - else { - (void)vsystem("cp %s %s.previous", config, config); - fp = fopen(config, "w"); - } - for (i = 0; i < nlines; i++) { - fprintf(fp, lines[i]); - /* Stand by for bogus special case handling - we try to dump the interface specs here */ - if (!strncmp(lines[i], VAR_INTERFACES, strlen(VAR_INTERFACES))) { - Device **devp; - int j, cnt; - - devp = deviceFind(NULL, DEVICE_TYPE_NETWORK); - cnt = deviceCount(devp); - for (j = 0; j < cnt; j++) { - char iname[255], toadd[512]; - int k, addit = TRUE; - - if (!strncmp(devp[j]->name, "ppp", 3) || !strncmp(devp[j]->name, "tun", 3)) - continue; - - snprintf(iname, 255, "%s%s", VAR_IFCONFIG, devp[j]->name); - if ((cp = variable_get(iname))) { - snprintf(toadd, sizeof toadd, "%s=\"%s\"\n", iname, cp); - for (k = 0; k < nlines; k++) { - if (!strcmp(lines[k], toadd)) { - addit = FALSE; - break; - } - } - if (addit) - fprintf(fp, toadd); - } - } - } - free(lines[i]); - } - fclose(fp); -} - -int -configSaver(dialogMenuItem *self) -{ - variable_set((char *)self->data); - if (!variable_get(VAR_BLANKTIME)) - variable_set2(VAR_BLANKTIME, "300"); - return DITEM_SUCCESS; -} - -int -configSaverTimeout(dialogMenuItem *self) -{ - return (variable_get_value(VAR_BLANKTIME, - "Enter time-out period in seconds for screen saver") ? - DITEM_SUCCESS : DITEM_FAILURE) | DITEM_RESTORE; -} - -int -configRegister(dialogMenuItem *self) -{ - return DITEM_STATUS(registerOpenDialog()) | DITEM_RESTORE; -} - -int -configNTP(dialogMenuItem *self) -{ - int status; - - status = variable_get_value(VAR_NTPDATE_FLAGS, - "Enter the name of an NTP server") - ? DITEM_SUCCESS : DITEM_FAILURE; - if (status == DITEM_SUCCESS) { - static char tmp[255]; - - snprintf(tmp, sizeof(tmp), "ntpdate_enable=YES,ntpdate_flags=%s", - variable_get(VAR_NTPDATE_FLAGS)); - self->data = tmp; - dmenuSetVariables(self); - } - return status | DITEM_RESTORE; -} - -int -configUsers(dialogMenuItem *self) -{ - dialog_clear_norefresh(); - dmenuOpenSimple(&MenuUsermgmt, FALSE); - dialog_clear(); - return DITEM_SUCCESS | DITEM_RESTORE; -} - -int -configXEnvironment(dialogMenuItem *self) -{ - char *config, *execfile; - char *moused; - -tryagain: - dialog_clear_norefresh(); - if (!dmenuOpenSimple(&MenuXF86Config, FALSE)) - return DITEM_FAILURE | DITEM_RESTORE; - if (file_readable("/var/run/ld.so.hints")) - systemExecute("/sbin/ldconfig -m /usr/lib /usr/X11R6/lib /usr/local/lib /usr/lib/compat"); - else - systemExecute("/sbin/ldconfig /usr/lib /usr/X11R6/lib /usr/local/lib /usr/lib/compat"); - config = variable_get(VAR_XF86_CONFIG); - if (!config) - return DITEM_FAILURE | DITEM_RESTORE; - execfile = string_concat("/usr/X11R6/bin/", config); - if (file_executable(execfile)) { - dialog_clear_norefresh(); - moused = variable_get(VAR_MOUSED); - while (!moused || strcmp(moused, "YES")) { - if (msgYesNo("The X server may access the mouse in two ways: direct access\n" - "or indirect access via the mouse daemon. You have not\n" - "configured the mouse daemon. Would you like to configure it\n" - "now? If you intend to let the X server access the mouse\n" - "directly, choose \"No\" at this time.")) - break; - dmenuOpenSimple(&MenuMouse, FALSE); - dialog_clear(); - moused = variable_get(VAR_MOUSED); - } - if (moused && !strcmp(moused, "YES")) - msgConfirm("You have configured and are now running the mouse daemon.\n" - "Choose \"/dev/sysmouse\" as the mouse port and \"SysMouse\" or\n" - "\"MouseSystems\" as the mouse protocol in the X configuration\n" - "utility."); - dialog_clear(); - systemExecute(execfile); - if (!file_readable("/etc/XF86Config") && !msgYesNo("The XFree86 configuration process seems to have\nfailed. Would you like to try again?")) - goto tryagain; - return DITEM_SUCCESS | DITEM_RESTORE; - } - else { - dialog_clear_norefresh(); - msgConfirm("The XFree86 setup utility you chose does not appear to be installed!\n" - "Please install this before attempting to configure XFree86."); - return DITEM_FAILURE | DITEM_RESTORE; - } -} - -int -configResolv(dialogMenuItem *ditem) -{ - FILE *fp; - char *cp, *dp, *hp; - - cp = variable_get(VAR_NAMESERVER); - if (!cp || !*cp) - goto skip; - Mkdir("/etc"); - fp = fopen("/etc/resolv.conf", "w"); - if (!fp) - return DITEM_FAILURE; - if (variable_get(VAR_DOMAINNAME)) - fprintf(fp, "domain\t%s\n", variable_get(VAR_DOMAINNAME)); - fprintf(fp, "nameserver\t%s\n", cp); - fclose(fp); - if (isDebug()) - msgDebug("Wrote out /etc/resolv.conf\n"); - -skip: - dp = variable_get(VAR_DOMAINNAME); - cp = variable_get(VAR_IPADDR); - hp = variable_get(VAR_HOSTNAME); - /* Tack ourselves into /etc/hosts */ - fp = fopen("/etc/hosts", "w"); - if (!fp) - return DITEM_FAILURE; - /* Add an entry for localhost */ - if (dp) - fprintf(fp, "127.0.0.1\t\tlocalhost.%s localhost\n", dp); - else - fprintf(fp, "127.0.0.1\t\tlocalhost\n"); - /* Now the host entries, if applicable */ - if (cp && cp[0] != '0' && hp) { - char cp2[255]; - - if (!index(hp, '.')) - cp2[0] = '\0'; - else { - SAFE_STRCPY(cp2, hp); - *(index(cp2, '.')) = '\0'; - } - fprintf(fp, "%s\t\t%s %s\n", cp, hp, cp2); - fprintf(fp, "%s\t\t%s.\n", cp, hp); - } - fclose(fp); - if (isDebug()) - msgDebug("Wrote out /etc/hosts\n"); - return DITEM_SUCCESS; -} - -int -configRouter(dialogMenuItem *self) -{ - int ret; - - ret = variable_get_value(VAR_ROUTER, - "Please specify the router you wish to use. Routed is\n" - "provided with the stock system and gated is provided\n" - "as an optional package which this installation system\n" - "will attempt to load if you select gated. Any other\n" - "choice of routing daemon will be assumed to be something\n" - "the user intends to install themselves before rebooting\n" - "the system. If you don't want any routing daemon, choose NO") - ? DITEM_SUCCESS : DITEM_FAILURE; - - if (ret == DITEM_SUCCESS) { - char *cp = variable_get(VAR_ROUTER); - - if (cp && strcmp(cp, "NO")) { - variable_set2(VAR_ROUTER_ENABLE, "YES"); - if (!strcmp(cp, "gated")) { - if (package_add(variable_get(VAR_GATED_PKG)) != DITEM_SUCCESS) { - msgConfirm("Unable to load gated package. Falling back to no router."); - variable_unset(VAR_ROUTER); - variable_unset(VAR_ROUTERFLAGS); - variable_set2(VAR_ROUTER_ENABLE, "NO"); - cp = NULL; - } - } - if (cp) { - /* Now get the flags, if they chose a router */ - ret = variable_get_value(VAR_ROUTERFLAGS, - "Please Specify the routing daemon flags; if you're running routed\n" - "then -q is the right choice for nodes and -s for gateway hosts.\n") - ? DITEM_SUCCESS : DITEM_FAILURE; - if (ret != DITEM_SUCCESS) - variable_unset(VAR_ROUTERFLAGS); - } - } - else { - /* No router case */ - variable_set2(VAR_ROUTER_ENABLE, "NO"); - variable_unset(VAR_ROUTERFLAGS); - variable_unset(VAR_ROUTER); - } - } - return ret | DITEM_RESTORE; -} - -int -configPackages(dialogMenuItem *self) -{ - static PkgNode top, plist; - static Boolean index_initted = FALSE; - PkgNodePtr tmp; - FILE *fp; - - if (!mediaVerify()) - return DITEM_FAILURE; - - if (!mediaDevice->init(mediaDevice)) - return DITEM_FAILURE; - - if (!index_initted) { - msgNotify("Attempting to fetch packages/INDEX file from selected media."); - fp = mediaDevice->get(mediaDevice, "packages/INDEX", TRUE); - if (!fp) { - dialog_clear_norefresh(); - msgConfirm("Unable to get packages/INDEX file from selected media.\n" - "This may be because the packages collection is not available at\n" - "on the distribution media you've chosen (most likely an FTP site\n" - "without the packages collection mirrored). Please verify media\n" - "(or path to media) and try again. If your local site does not\n" - "carry the packages collection, then we recommend either a CD\n" - "distribution or the master distribution on ftp.freebsd.org."); - mediaDevice->shutdown(mediaDevice); - return DITEM_FAILURE | DITEM_RESTORE; - } - msgNotify("Located INDEX, now reading package data from it..."); - index_init(&top, &plist); - if (index_read(fp, &top)) { - msgConfirm("I/O or format error on packages/INDEX file.\n" - "Please verify media (or path to media) and try again."); - fclose(fp); - return DITEM_FAILURE | DITEM_RESTORE; - } - fclose(fp); - index_sort(&top); - index_initted = TRUE; - } - while (1) { - int ret, pos, scroll; - - /* Bring up the packages menu */ - pos = scroll = 0; - index_menu(&top, &plist, &pos, &scroll); - - if (plist.kids && plist.kids->name) { - /* Now show the packing list menu */ - pos = scroll = 0; - ret = index_menu(&plist, NULL, &pos, &scroll); - if (ret & DITEM_LEAVE_MENU) - break; - else if (DITEM_STATUS(ret) != DITEM_FAILURE) { - index_extract(mediaDevice, &top, &plist); - break; - } - } - else { - dialog_clear_norefresh(); - msgConfirm("No packages were selected for extraction."); - break; - } - } - tmp = plist.kids; - while (tmp) { - PkgNodePtr tmp2 = tmp->next; - - safe_free(tmp); - tmp = tmp2; - } - index_init(NULL, &plist); - return DITEM_SUCCESS | DITEM_RESTORE; -} - -/* Load pcnfsd package */ -int -configPCNFSD(dialogMenuItem *self) -{ - int ret = DITEM_SUCCESS; - - if (variable_get(VAR_PCNFSD)) - variable_unset(VAR_PCNFSD); - else { - ret = package_add(variable_get(VAR_PCNFSD_PKG)); - if (DITEM_STATUS(ret) == DITEM_SUCCESS) { - variable_set2(VAR_PCNFSD, "YES"); - variable_set2("mountd_flags", "-n"); - } - } - return ret; -} - -int -configNFSServer(dialogMenuItem *self) -{ - char cmd[256]; - - /* If we're an NFS server, we need an exports file */ - if (!file_readable("/etc/exports")) { - WINDOW *w = savescr(); - - if (file_readable("/etc/exports.disabled")) - vsystem("mv /etc/exports.disabled /etc/exports"); - else { - dialog_clear_norefresh(); - msgConfirm("Operating as an NFS server means that you must first configure\n" - "an /etc/exports file to indicate which hosts are allowed certain\n" - "kinds of access to your local file systems.\n" - "Press [ENTER] now to invoke an editor on /etc/exports\n"); - vsystem("echo '#The following examples export /usr to 3 machines named after ducks,' > /etc/exports"); - vsystem("echo '#/home and all directories under it to machines named after dead rock stars' >> /etc/exports"); - vsystem("echo '#and, finally, /a to 2 privileged machines allowed to write on it as root.' >> /etc/exports"); - vsystem("echo '#/usr huey louie dewie' >> /etc/exports"); - vsystem("echo '#/home -alldirs janice jimmy frank' >> /etc/exports"); - vsystem("echo '#/a -maproot=0 bill albert' >> /etc/exports"); - vsystem("echo '#' >> /etc/exports"); - vsystem("echo '# You should replace these lines with your actual exported filesystems.' >> /etc/exports"); - vsystem("echo >> /etc/exports"); - sprintf(cmd, "%s /etc/exports", variable_get(VAR_EDITOR)); - dialog_clear(); - systemExecute(cmd); - restorescr(w); - } - variable_set2(VAR_NFS_SERVER, "YES"); - } - else if (variable_get(VAR_NFS_SERVER)) { /* We want to turn it off again? */ - vsystem("mv -f /etc/exports /etc/exports.disabled"); - variable_unset(VAR_NFS_SERVER); - } - return DITEM_SUCCESS; -} diff --git a/usr.sbin/sysinstall/dev2c.sh b/usr.sbin/sysinstall/dev2c.sh deleted file mode 100644 index 929e9e773e12..000000000000 --- a/usr.sbin/sysinstall/dev2c.sh +++ /dev/null @@ -1,80 +0,0 @@ -: -# -# ---------------------------------------------------------------------------- -# "THE BEER-WARE LICENSE" (Revision 42): -# <phk@login.dknet.dk> wrote this file. As long as you retain this notice you -# can do whatever you want with this stuff. If we meet some day, and you think -# this stuff is worth it, you can buy me a beer in return. Poul-Henning Kamp -# ---------------------------------------------------------------------------- -# -# $Id$ -# -# During installation, we suffer badly of we have to run MAKEDEV. MAKEDEV -# need sh, ln, chown, mknod, awk, rm, test and probably emacs too when -# we come down to it. So instead this script will make a C-procedure which -# makes all the B & C nodes of a specified directory. -# -# Poul-Henning - -(cd $1; ls -li ) | sed 's/,//' | awk ' -BEGIN { - while (getline < "/etc/passwd") { - split($0,a,":") - uid[a[1]] = a[3] - } - while (getline < "/etc/group") { - split($0,a,":") - gid[a[1]] = a[3] - } - printf("/*\n"); - printf(" * This file is generated from the contents of /dev\n"); - printf(" */\n"); - printf("#define CHK(foo) {i = foo;}\n"); - printf("#include <unistd.h>\n"); - printf("#include <sys/types.h>\n"); - printf("#include <sys/stat.h>\n"); - printf("int makedevs()\n{\n\tint i=0;\n"); - } - { - printf ("/* %s */\n",$0) - $4 = uid[$4] - $5 = gid[$5] - if (substr($2,1,1) == "b") { - k="S_IFBLK" - } else if (substr($2,1,1) == "c") { - k="S_IFCHR" - } else if (substr($2,1,1) == "d") { - next - } else if (substr($2,1,1) == "-") { - next - } else { - next - } - m = 0; - if (substr($2,2,1) == "r") m += 400; - if (substr($2,3,1) == "w") m += 200; - if (substr($2,4,1) == "x") m += 100; - if (substr($2,5,1) == "r") m += 40; - if (substr($2,6,1) == "w") m += 20; - if (substr($2,7,1) == "x") m += 10; - if (substr($2,8,1) == "r") m += 4; - if (substr($2,9,1) == "w") m += 2; - if (substr($2,10,1) == "x") m += 1; - - if (a[$1] != 0) { - printf ("\tCHK(link(\"%s\",\"%s\"));\n", \ - a[$1],$11) - } else { - printf ("\tCHK(mknod(\"%s\",%s,makedev(%d,%d)));\n", \ - $11, k, $6, $7) - printf ("\tCHK(chmod(\"%s\",0%d));\n", \ - $11, m) - printf ("\tCHK(chown(\"%s\",%d,%d));\n", \ - $11, $4,$5) - a[$1] = $11 - } - } -END { - printf("\treturn i;\n}\n"); - } -' diff --git a/usr.sbin/sysinstall/devices.c b/usr.sbin/sysinstall/devices.c deleted file mode 100644 index 7b7261d23b43..000000000000 --- a/usr.sbin/sysinstall/devices.c +++ /dev/null @@ -1,503 +0,0 @@ -/* - * The new sysinstall program. - * - * This is probably the last program in the `sysinstall' line - the next - * generation being essentially a complete rewrite. - * - * $Id: devices.c,v 1.87 1998/12/04 18:01:10 wpaul Exp $ - * - * Copyright (c) 1995 - * Jordan Hubbard. 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, - * verbatim and that no modifications are made prior to this - * point in the file. - * 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 JORDAN HUBBARD ``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 JORDAN HUBBARD OR HIS PETS 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, LIFE 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. - * - */ - -#include "sysinstall.h" -#include <sys/fcntl.h> -#include <sys/param.h> -#include <sys/socket.h> -#include <sys/ioctl.h> -#include <sys/errno.h> -#include <sys/time.h> -#include <net/if.h> -#include <net/if_var.h> -#include <net/if_dl.h> -#include <netinet/in.h> -#include <netinet/in_var.h> -#include <arpa/inet.h> -#include <ctype.h> - -/* how much to bias minor number for a given /dev/<ct#><un#>s<s#> slice */ -#define SLICE_DELTA (0x10000) - -static Device *Devices[DEV_MAX]; -static int numDevs; - -static struct _devname { - DeviceType type; - char *name; - char *description; - int major, minor, delta, max; - char dev_type; -} device_names[] = { - { DEVICE_TYPE_CDROM, "cd%dc", "SCSI CDROM drive", 6, 2, 8, 4, 'b' }, - { DEVICE_TYPE_CDROM, "mcd%da", "Mitsumi (old model) CDROM drive", 7, 0, 8, 4, 'b' }, - { DEVICE_TYPE_CDROM, "scd%da", "Sony CDROM drive - CDU31/33A type", 16, 0, 8, 4, 'b' }, - { DEVICE_TYPE_CDROM, "matcd%da", "Matsushita CDROM ('sound blaster' type)", 17, 0, 8, 4, 'b' }, - { DEVICE_TYPE_CDROM, "wcd%dc", "ATAPI IDE CDROM", 19, 2, 8, 4, 'b' }, - { DEVICE_TYPE_TAPE, "rsa%d", "SCSI tape drive", 14, 0, 16, 4, 'c' }, - { DEVICE_TYPE_TAPE, "rwt%d", "Wangtek tape drive", 10, 0, 1, 4, 'c' }, - { DEVICE_TYPE_DISK, "da%d", "SCSI disk device", 4, 65538, 8, 16, 'b' }, - { DEVICE_TYPE_DISK, "rda%d", "SCSI disk device", 13, 65538, 8, 16, 'c' }, - { DEVICE_TYPE_DISK, "wd%d", "IDE/ESDI/MFM/ST506 disk device", 0, 65538, 8, 16, 'b' }, - { DEVICE_TYPE_DISK, "rwd%d", "IDE/ESDI/MFM/ST506 disk device", 3, 65538, 8, 16, 'c' }, - { DEVICE_TYPE_DISK, "fla%d", "DiskOnChip2000 Flash device", 28, 65538, 8, 16, 'b' }, - { DEVICE_TYPE_DISK, "rfla%d", "DiskOnChip2000 Flash devicee", 101, 65538, 8, 16, 'c' }, - { DEVICE_TYPE_DISK, "wfd%d", "ATAPI floppy device", 1, 65538, 8, 4, 'b' }, - { DEVICE_TYPE_DISK, "rwfd%d", "ATAPI floppy device", 87, 65538, 8, 4, 'c' }, - { DEVICE_TYPE_FLOPPY, "fd%d", "floppy drive unit A", 2, 0, 64, 4, 'b' }, - { DEVICE_TYPE_FLOPPY, "wfd%d", "ATAPI floppy drive unit A", 1, 0, 8, 4, 'b' }, - { DEVICE_TYPE_FLOPPY, "worm%d", "SCSI optical disk / CDR", 23, 0, 1, 4, 'b' }, - { DEVICE_TYPE_NETWORK, "ax", "ASIX AX88140A PCI ethernet card" }, - { DEVICE_TYPE_NETWORK, "fpa", "DEC DEFPA PCI FDDI card" }, - { DEVICE_TYPE_NETWORK, "sr", "SDL T1/E1 sync serial PCI card" }, - { DEVICE_TYPE_NETWORK, "cc3i", "SDL HSSI sync serial PCI card" }, - { DEVICE_TYPE_NETWORK, "en", "Efficient Networks ATM PCI card" }, - { DEVICE_TYPE_NETWORK, "de", "DEC DE435 PCI NIC or other DC21040-AA based card" }, - { DEVICE_TYPE_NETWORK, "fxp", "Intel EtherExpress Pro/100B PCI Fast Ethernet card" }, - { DEVICE_TYPE_NETWORK, "ed", "WD/SMC 80xx; Novell NE1000/2000; 3Com 3C503 card" }, - { DEVICE_TYPE_NETWORK, "ep", "3Com 3C509 ethernet card" }, - { DEVICE_TYPE_NETWORK, "el", "3Com 3C501 ethernet card" }, - { DEVICE_TYPE_NETWORK, "ex", "Intel EtherExpress Pro/10 ethernet card" }, - { DEVICE_TYPE_NETWORK, "fe", "Fujitsu MB86960A/MB86965A ethernet card" }, - { DEVICE_TYPE_NETWORK, "ie", "AT&T StarLAN 10 and EN100; 3Com 3C507; NI5210" }, - { DEVICE_TYPE_NETWORK, "ix", "Intel Etherexpress ethernet card" }, - { DEVICE_TYPE_NETWORK, "le", "DEC EtherWorks 2 or 3 ethernet card" }, - { DEVICE_TYPE_NETWORK, "lnc", "Lance/PCnet (Isolan/Novell NE2100/NE32-VL) ethernet" }, - { DEVICE_TYPE_NETWORK, "mx", "Macronix 98713/98715/98725 PCI ethernet card" }, - { DEVICE_TYPE_NETWORK, "pn", "Lite-On 82168/82169 PNIC PCI ethernet card" }, - { DEVICE_TYPE_NETWORK, "rl", "RealTek 8129/8139 PCI ethernet card" }, - { DEVICE_TYPE_NETWORK, "tx", "SMC 9432TX ethernet card" }, - { DEVICE_TYPE_NETWORK, "tl", "Texas Instruments ThunderLAN PCI ethernet card" }, - { DEVICE_TYPE_NETWORK, "vr", "VIA VT3043/VT86C100A Rhine PCI ethernet card" }, - { DEVICE_TYPE_NETWORK, "vx", "3COM 3c590 / 3c595 ethernet card" }, - { DEVICE_TYPE_NETWORK, "wb", "Winbond W89C840F PCI ethernet card" }, - { DEVICE_TYPE_NETWORK, "xl", "3COM 3c90x / 3c90xB PCI ethernet card" }, - { DEVICE_TYPE_NETWORK, "ze", "IBM/National Semiconductor PCMCIA ethernet card" }, - { DEVICE_TYPE_NETWORK, "zp", "3Com Etherlink III PCMCIA ethernet card" }, - { DEVICE_TYPE_NETWORK, "cuaa%d", "%s on device %s (COM%d)", 28, 128, 1, 16, 'c' }, - { DEVICE_TYPE_NETWORK, "lp", "Parallel Port IP (PLIP) peer connection" }, - { DEVICE_TYPE_NETWORK, "lo", "Loop-back (local) network interface" }, - { 0 }, -}; - -Device * -new_device(char *name) -{ - Device *dev; - - dev = safe_malloc(sizeof(Device)); - bzero(dev, sizeof(Device)); - if (name) - SAFE_STRCPY(dev->name, name); - return dev; -} - -/* Stubs for unimplemented strategy routines */ -Boolean -dummyInit(Device *dev) -{ - return TRUE; -} - -FILE * -dummyGet(Device *dev, char *dist, Boolean probe) -{ - return NULL; -} - -void -dummyShutdown(Device *dev) -{ - return; -} - -static int -deviceTry(struct _devname dev, char *try, int i) -{ - int fd; - char unit[80]; - mode_t m; - dev_t d; - int fail; - - snprintf(unit, sizeof unit, dev.name, i); - snprintf(try, FILENAME_MAX, "/dev/%s", unit); - fd = open(try, O_RDONLY); - if (fd >= 0) - return fd; - m = 0640; - if (dev.dev_type == 'c') - m |= S_IFCHR; - else - m |= S_IFBLK; - d = makedev(dev.major, dev.minor + (i * dev.delta)); - fail = mknod(try, m, d); - fd = open(try, O_RDONLY); - if (fd >= 0) - return fd; - else if (!fail) - (void)unlink(try); - /* Don't try a "make-under" here since we're using a fixit floppy in this case */ - snprintf(try, FILENAME_MAX, "/mnt/dev/%s", unit); - fd = open(try, O_RDONLY); - return fd; -} - -/* Register a new device in the devices array */ -Device * -deviceRegister(char *name, char *desc, char *devname, DeviceType type, Boolean enabled, - Boolean (*init)(Device *), FILE * (*get)(Device *, char *, Boolean), - void (*shutdown)(Device *), void *private) -{ - Device *newdev = NULL; - - if (numDevs == DEV_MAX) - msgFatal("Too many devices found!"); - else { - newdev = new_device(name); - newdev->description = desc; - newdev->devname = devname; - newdev->type = type; - newdev->enabled = enabled; - newdev->init = init ? init : dummyInit; - newdev->get = get ? get : dummyGet; - newdev->shutdown = shutdown ? shutdown : dummyShutdown; - newdev->private = private; - Devices[numDevs] = newdev; - Devices[++numDevs] = NULL; - } - return newdev; -} - -/* Get all device information for devices we have attached */ -void -deviceGetAll(void) -{ - int i, j, fd, s; - struct ifconf ifc; - struct ifreq *ifptr, *end; - int ifflags; - char buffer[INTERFACE_MAX * sizeof(struct ifreq)]; - char **names; - - msgNotify("Probing devices, please wait (this can take a while)..."); - /* First go for the network interfaces. Stolen shamelessly from ifconfig! */ - ifc.ifc_len = sizeof(buffer); - ifc.ifc_buf = buffer; - - s = socket(AF_INET, SOCK_DGRAM, 0); - if (s < 0) { - msgConfirm("ifconfig: socket"); - goto skipif; /* Jump over network iface probing */ - } - if (ioctl(s, SIOCGIFCONF, (char *) &ifc) < 0) { - msgConfirm("ifconfig (SIOCGIFCONF)"); - goto skipif; /* Jump over network iface probing */ - } - ifflags = ifc.ifc_req->ifr_flags; - end = (struct ifreq *) (ifc.ifc_buf + ifc.ifc_len); - for (ifptr = ifc.ifc_req; ifptr < end; ifptr++) { - char *descr; - - /* If it's not a link entry, forget it */ - if (ifptr->ifr_ifru.ifru_addr.sa_family != AF_LINK) - continue; - - /* Eliminate network devices that don't make sense */ - if (!strncmp(ifptr->ifr_name, "lo", 2)) - continue; - - /* If we have a slip device, don't register it */ - if (!strncmp(ifptr->ifr_name, "sl", 2)) { - continue; - } - /* And the same for ppp */ - if (!strncmp(ifptr->ifr_name, "tun", 3) || !strncmp(ifptr->ifr_name, "ppp", 3)) { - continue; - } - /* Try and find its description */ - for (i = 0, descr = NULL; device_names[i].name; i++) { - int len = strlen(device_names[i].name); - - if (!ifptr->ifr_name || !ifptr->ifr_name[0]) - continue; - else if (!strncmp(ifptr->ifr_name, device_names[i].name, len)) { - descr = device_names[i].description; - break; - } - } - if (!descr) - descr = "<unknown network interface type>"; - - deviceRegister(ifptr->ifr_name, descr, strdup(ifptr->ifr_name), DEVICE_TYPE_NETWORK, TRUE, - mediaInitNetwork, NULL, mediaShutdownNetwork, NULL); - msgDebug("Found a network device named %s\n", ifptr->ifr_name); - close(s); - if ((s = socket(AF_INET, SOCK_DGRAM, 0)) < 0) { - msgConfirm("ifconfig: socket"); - continue; - } - if (ifptr->ifr_addr.sa_len) /* I'm not sure why this is here - it's inherited */ - ifptr = (struct ifreq *)((caddr_t)ifptr + ifptr->ifr_addr.sa_len - sizeof(struct sockaddr)); - } - -skipif: - /* Next, try to find all the types of devices one might need - * during the second stage of the installation. - */ - for (i = 0; device_names[i].name; i++) { - for (j = 0; j < device_names[i].max; j++) { - char try[FILENAME_MAX]; - - switch(device_names[i].type) { - case DEVICE_TYPE_CDROM: - fd = deviceTry(device_names[i], try, j); - if (fd >= 0 || errno == EBUSY) { /* EBUSY if already mounted */ - char n[BUFSIZ]; - - if (fd >= 0) close(fd); - snprintf(n, sizeof n, device_names[i].name, j); - deviceRegister(strdup(n), device_names[i].description, strdup(try), - DEVICE_TYPE_CDROM, TRUE, mediaInitCDROM, mediaGetCDROM, - mediaShutdownCDROM, NULL); - msgDebug("Found a CDROM device for %s\n", try); - } - break; - - case DEVICE_TYPE_TAPE: - fd = deviceTry(device_names[i], try, j); - if (fd >= 0) { - char n[BUFSIZ]; - - close(fd); - snprintf(n, sizeof n, device_names[i].name, j); - deviceRegister(strdup(n), device_names[i].description, strdup(try), - DEVICE_TYPE_TAPE, TRUE, mediaInitTape, mediaGetTape, mediaShutdownTape, NULL); - msgDebug("Found a TAPE device for %s\n", try); - } - break; - - case DEVICE_TYPE_DISK: - fd = deviceTry(device_names[i], try, j); - if (fd >= 0 && RunningAsInit) { - dev_t d; - mode_t m; - int s, fail; - char unit[80], slice[80]; - - close(fd); - /* Make associated slice entries */ - for (s = 1; s < 8; s++) { - snprintf(unit, sizeof unit, device_names[i].name, j); - snprintf(slice, sizeof slice, "/dev/%ss%d", unit, s); - d = makedev(device_names[i].major, device_names[i].minor + - (j * device_names[i].delta) + (s * SLICE_DELTA)); - m = 0640; - if (device_names[i].dev_type == 'c') - m |= S_IFCHR; - else - m |= S_IFBLK; - fail = mknod(slice, m, d); - fd = open(slice, O_RDONLY); - if (fd >= 0) - close(fd); - else if (!fail) - (void)unlink(slice); - } - } - break; - - case DEVICE_TYPE_FLOPPY: - fd = deviceTry(device_names[i], try, j); - if (fd >= 0) { - char n[BUFSIZ]; - - close(fd); - snprintf(n, sizeof n, device_names[i].name, j); - deviceRegister(strdup(n), device_names[i].description, strdup(try), - DEVICE_TYPE_FLOPPY, TRUE, mediaInitFloppy, mediaGetFloppy, - mediaShutdownFloppy, NULL); - msgDebug("Found a floppy device for %s\n", try); - } - break; - - case DEVICE_TYPE_NETWORK: - fd = deviceTry(device_names[i], try, j); - /* The only network devices that you can open this way are serial ones */ - if (fd >= 0) { - char *newdesc, *cp; - - close(fd); - cp = device_names[i].description; - /* Serial devices get a slip and ppp device each, if supported */ - newdesc = safe_malloc(strlen(cp) + 40); - sprintf(newdesc, cp, "SLIP interface", try, j + 1); - deviceRegister("sl0", newdesc, strdup(try), DEVICE_TYPE_NETWORK, TRUE, mediaInitNetwork, - NULL, mediaShutdownNetwork, NULL); - msgDebug("Add mapping for %s to sl0\n", try); - newdesc = safe_malloc(strlen(cp) + 50); - sprintf(newdesc, cp, "PPP interface", try, j + 1); - deviceRegister("ppp0", newdesc, strdup(try), DEVICE_TYPE_NETWORK, TRUE, mediaInitNetwork, - NULL, mediaShutdownNetwork, NULL); - msgDebug("Add mapping for %s to ppp0\n", try); - } - break; - - default: - break; - } - } - } - - /* Finally, go get the disks and look for DOS partitions to register */ - if ((names = Disk_Names()) != NULL) { - int i; - - for (i = 0; names[i]; i++) { - Chunk *c1; - Disk *d; - - d = Open_Disk(names[i]); - if (!d) - msgFatal("Unable to open disk %s", names[i]); - - deviceRegister(names[i], names[i], d->name, DEVICE_TYPE_DISK, FALSE, - dummyInit, dummyGet, dummyShutdown, d); - msgDebug("Found a disk device named %s\n", names[i]); - - /* Look for existing DOS partitions to register as "DOS media devices" */ - for (c1 = d->chunks->part; c1; c1 = c1->next) { - if (c1->type == fat || c1->type == extended) { - Device *dev; - char devname[80]; - - /* Got one! */ - snprintf(devname, sizeof devname, "/dev/%s", c1->name); - dev = deviceRegister(c1->name, c1->name, strdup(devname), DEVICE_TYPE_DOS, TRUE, - mediaInitDOS, mediaGetDOS, mediaShutdownDOS, NULL); - dev->private = c1; - msgDebug("Found a DOS partition %s on drive %s\n", c1->name, d->name); - } - } - } - free(names); - } -} - -/* - * Find all devices that match the criteria, allowing "wildcarding" as well - * by allowing NULL or ANY values to match all. The array returned is static - * and may be used until the next invocation of deviceFind(). - */ -Device ** -deviceFind(char *name, DeviceType class) -{ - static Device *found[DEV_MAX]; - int i, j; - - j = 0; - for (i = 0; i < numDevs; i++) { - if ((!name || !strcmp(Devices[i]->name, name)) - && (class == DEVICE_TYPE_ANY || class == Devices[i]->type)) - found[j++] = Devices[i]; - } - found[j] = NULL; - return j ? found : NULL; -} - -Device ** -deviceFindDescr(char *name, char *desc, DeviceType class) -{ - static Device *found[DEV_MAX]; - int i, j; - - j = 0; - for (i = 0; i < numDevs; i++) { - if ((!name || !strcmp(Devices[i]->name, name)) && - (!desc || !strcmp(Devices[i]->description, desc)) && - (class == DEVICE_TYPE_ANY || class == Devices[i]->type)) - found[j++] = Devices[i]; - } - found[j] = NULL; - return j ? found : NULL; -} - -int -deviceCount(Device **devs) -{ - int i; - - if (!devs) - return 0; - for (i = 0; devs[i]; i++); - return i; -} - -/* - * Create a menu listing all the devices of a certain type in the system. - * The passed-in menu is expected to be a "prototype" from which the new - * menu is cloned. - */ -DMenu * -deviceCreateMenu(DMenu *menu, DeviceType type, int (*hook)(dialogMenuItem *d), int (*check)(dialogMenuItem *d)) -{ - Device **devs; - int numdevs; - DMenu *tmp = NULL; - int i, j; - - devs = deviceFind(NULL, type); - numdevs = deviceCount(devs); - if (!numdevs) - return NULL; - tmp = (DMenu *)safe_malloc(sizeof(DMenu) + (sizeof(dialogMenuItem) * (numdevs + 1))); - bcopy(menu, tmp, sizeof(DMenu)); - for (i = 0; devs[i]; i++) { - tmp->items[i].prompt = devs[i]->name; - for (j = 0; j < numDevs; j++) { - if (devs[i] == Devices[j]) { - tmp->items[i].title = Devices[j]->description; - break; - } - } - if (j == numDevs) - tmp->items[i].title = "<unknown device type>"; - tmp->items[i].fire = hook; - tmp->items[i].checked = check; - } - tmp->items[i].title = NULL; - return tmp; -} diff --git a/usr.sbin/sysinstall/disks.c b/usr.sbin/sysinstall/disks.c deleted file mode 100644 index 6c6b5019a9c7..000000000000 --- a/usr.sbin/sysinstall/disks.c +++ /dev/null @@ -1,814 +0,0 @@ -/* - * The new sysinstall program. - * - * This is probably the last program in the `sysinstall' line - the next - * generation being essentially a complete rewrite. - * - * $Id: disks.c,v 1.107 1999/01/02 07:23:37 jkh Exp $ - * - * Copyright (c) 1995 - * Jordan Hubbard. 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, - * verbatim and that no modifications are made prior to this - * point in the file. - * 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 JORDAN HUBBARD ``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 JORDAN HUBBARD OR HIS PETS 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, LIFE 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. - * - */ - -#include "sysinstall.h" -#include <ctype.h> -#include <fcntl.h> -#include <sys/stat.h> -#include <sys/disklabel.h> - -/* Where we start displaying chunk information on the screen */ -#define CHUNK_START_ROW 5 - -/* Where we keep track of MBR chunks */ -static struct chunk *chunk_info[16]; -static int current_chunk; - -static void diskPartitionNonInteractive(Device *dev); - -static void -record_chunks(Disk *d) -{ - struct chunk *c1 = NULL; - int i = 0; - int last_free = 0; - - if (!d->chunks) - msgFatal("No chunk list found for %s!", d->name); - - for (c1 = d->chunks->part; c1; c1 = c1->next) { - if (c1->type == unused && c1->size > last_free) { - last_free = c1->size; - current_chunk = i; - } - chunk_info[i++] = c1; - } - chunk_info[i] = NULL; - if (current_chunk >= i) - current_chunk = i - 1; -} - -static int Total; - -static void -print_chunks(Disk *d) -{ - int row; - int i; - - for (i = Total = 0; chunk_info[i]; i++) - Total += chunk_info[i]->size; - if (d->bios_cyl > 65536 || d->bios_hd > 256 || d->bios_sect >= 64) { - dialog_clear_norefresh(); - msgConfirm("WARNING: A geometry of %d/%d/%d for %s is incorrect. Using\n" - "a more likely geometry. If this geometry is incorrect or you\n" - "are unsure as to whether or not it's correct, please consult\n" - "the Hardware Guide in the Documentation submenu or use the\n" - "(G)eometry command to change it now.\n\n" - "Remember: you need to enter whatever your BIOS thinks the\n" - "geometry is! For IDE, it's what you were told in the BIOS\n" - "setup. For SCSI, it's the translation mode your controller is\n" - "using. Do NOT use a ``physical geometry''.", - d->bios_cyl, d->bios_hd, d->bios_sect, d->name); - Sanitize_Bios_Geom(d); - } - attrset(A_NORMAL); - mvaddstr(0, 0, "Disk name:\t"); - clrtobot(); - attrset(A_REVERSE); addstr(d->name); attrset(A_NORMAL); - attrset(A_REVERSE); mvaddstr(0, 55, "FDISK Partition Editor"); attrset(A_NORMAL); - mvprintw(1, 0, - "DISK Geometry:\t%lu cyls/%lu heads/%lu sectors = %lu sectors", - d->bios_cyl, d->bios_hd, d->bios_sect, - d->bios_cyl * d->bios_hd * d->bios_sect); - mvprintw(3, 0, "%10s %10s %10s %8s %6s %10s %8s %8s", - "Offset", "Size", "End", "Name", "PType", "Desc", - "Subtype", "Flags"); - for (i = 0, row = CHUNK_START_ROW; chunk_info[i]; i++, row++) { - if (i == current_chunk) - attrset(ATTR_SELECTED); - mvprintw(row, 0, "%10ld %10lu %10lu %8s %6d %10s %8d\t%-6s", - chunk_info[i]->offset, chunk_info[i]->size, - chunk_info[i]->end, chunk_info[i]->name, - chunk_info[i]->type, - slice_type_name(chunk_info[i]->type, chunk_info[i]->subtype), - chunk_info[i]->subtype, ShowChunkFlags(chunk_info[i])); - if (i == current_chunk) - attrset(A_NORMAL); - } -} - -static void -print_command_summary() -{ - mvprintw(14, 0, "The following commands are supported (in upper or lower case):"); - mvprintw(16, 0, "A = Use Entire Disk B = Bad Block Scan C = Create Slice"); - mvprintw(17, 0, "D = Delete Slice G = Set Drive Geometry S = Set Bootable"); - mvprintw(18, 0, "T = Change Type U = Undo All Changes Q = Finish"); - if (!RunningAsInit) - mvprintw(18, 48, "W = Write Changes"); - mvprintw(21, 0, "Use F1 or ? to get more help, arrow keys to select."); - move(0, 0); -} - -static u_char * -getBootMgr(char *dname) -{ -#ifndef __alpha__ /* only meaningful on x86 */ - extern u_char mbr[], boot0[]; - char str[80]; - char *cp; - int i = 0; - - cp = variable_get(VAR_BOOTMGR); - if (!cp) { - /* Figure out what kind of MBR the user wants */ - sprintf(str, "Install Boot Manager for drive %s?", dname); - MenuMBRType.title = str; - i = dmenuOpenSimple(&MenuMBRType, FALSE); - } - else { - if (!strncmp(cp, "boot", 4)) - BootMgr = 0; - else if (!strcmp(cp, "standard")) - BootMgr = 1; - else - BootMgr = 2; - } - if (cp || i) { - switch (BootMgr) { - case 0: - return boot0; - - case 1: - return mbr; - - case 2: - default: - break; - } - } -#endif - return NULL; -} - -int -diskGetSelectCount(Device ***devs) -{ - int i, cnt, enabled; - char *cp; - Device **dp; - - cp = variable_get(VAR_DISK); - dp = *devs = deviceFind(cp, DEVICE_TYPE_DISK); - cnt = deviceCount(dp); - if (!cnt) - return -1; - for (i = 0, enabled = 0; i < cnt; i++) { - if (dp[i]->enabled) - ++enabled; - } - return enabled; -} - -void -diskPartition(Device *dev) -{ - char *cp, *p; - int rv, key = 0; - Boolean chunking; - char *msg = NULL; - u_char *mbrContents; - WINDOW *w = savescr(); - Disk *d = (Disk *)dev->private; - - chunking = TRUE; - keypad(stdscr, TRUE); - - /* Flush both the dialog and curses library views of the screen - since we don't always know who called us */ - dialog_clear_norefresh(), clear(); - current_chunk = 0; - - /* Set up the chunk array */ - record_chunks(d); - - while (chunking) { - char *val, geometry[80]; - - /* Now print our overall state */ - if (d) - print_chunks(d); - print_command_summary(); - if (msg) { - attrset(title_attr); mvprintw(23, 0, msg); attrset(A_NORMAL); - beep(); - msg = NULL; - } - else { - move(23, 0); - clrtoeol(); - } - - /* Get command character */ - key = getch(); - switch (toupper(key)) { - case '\014': /* ^L (redraw) */ - clear(); - msg = NULL; - break; - - case '\020': /* ^P */ - case KEY_UP: - case '-': - if (current_chunk != 0) - --current_chunk; - break; - - case '\016': /* ^N */ - case KEY_DOWN: - case '+': - case '\r': - case '\n': - if (chunk_info[current_chunk + 1]) - ++current_chunk; - break; - - case KEY_HOME: - current_chunk = 0; - break; - - case KEY_END: - while (chunk_info[current_chunk + 1]) - ++current_chunk; - break; - - case KEY_F(1): - case '?': - systemDisplayHelp("slice"); - clear(); - break; - - case 'A': -#ifdef __alpha__ - rv = 1; -#else /* The rest is only relevant on x86 */ - cp = variable_get(VAR_DEDICATE_DISK); - if (cp && !strcasecmp(cp, "always")) - rv = 1; - else { - rv = msgYesNo("Do you want to do this with a true partition entry\n" - "so as to remain cooperative with any future possible\n" - "operating systems on the drive(s)?\n" - "(See also the section about ``dangerously dedicated''\n" - "disks in the FreeBSD FAQ.)"); - if (rv == -1) - rv = 0; - } -#endif - All_FreeBSD(d, rv); - variable_set2(DISK_PARTITIONED, "yes"); - record_chunks(d); - clear(); - break; - - case 'B': - if (chunk_info[current_chunk]->type != freebsd) - msg = "Can only scan for bad blocks in FreeBSD slice."; - else if (strncmp(d->name, "sd", 2) || - strncmp(d->name, "da", 2) || - !msgYesNo("This typically makes sense only for ESDI, IDE or MFM drives.\n" - "Are you sure you want to do this on a SCSI disk?")) { - if (chunk_info[current_chunk]->flags & CHUNK_BAD144) - chunk_info[current_chunk]->flags &= ~CHUNK_BAD144; - else - chunk_info[current_chunk]->flags |= CHUNK_BAD144; - } - clear(); - break; - - case 'C': - if (chunk_info[current_chunk]->type != unused) - msg = "Slice in use, delete it first or move to an unused one."; - else { - char *val, tmp[20], *cp; - int size, subtype; - chunk_e partitiontype; - - snprintf(tmp, 20, "%lu", chunk_info[current_chunk]->size); - val = msgGetInput(tmp, "Please specify the size for new FreeBSD slice in blocks\n" - "or append a trailing `M' for megabytes (e.g. 20M)."); - if (val && (size = strtol(val, &cp, 0)) > 0) { - if (*cp && toupper(*cp) == 'M') - size *= ONE_MEG; - strcpy(tmp, "165"); - val = msgGetInput(tmp, "Enter type of partition to create:\n\n" - "Pressing Enter will choose the default, a native FreeBSD\n" - "slice (type 165). You can choose other types, 6 for a\n" - "DOS partition or 131 for a Linux partition, for example.\n\n" - "Note: If you choose a non-FreeBSD partition type, it will not\n" - "be formatted or otherwise prepared, it will simply reserve space\n" - "for you to use another tool, such as DOS FORMAT, to later format\n" - "and use the partition."); - if (val && (subtype = strtol(val, NULL, 0)) > 0) { - if (subtype == 165) - partitiontype = freebsd; - else if (subtype == 6) - partitiontype = fat; - else - partitiontype = unknown; -#ifdef __alpha__ - if (partitiontype == freebsd && size == chunk_info[current_chunk]->size) - All_FreeBSD(d, 1); - else -#endif - Create_Chunk(d, chunk_info[current_chunk]->offset, size, partitiontype, subtype, - (chunk_info[current_chunk]->flags & CHUNK_ALIGN)); - variable_set2(DISK_PARTITIONED, "yes"); - record_chunks(d); - } - } - clear(); - } - break; - - case KEY_DC: - case 'D': - if (chunk_info[current_chunk]->type == unused) - msg = "Slice is already unused!"; - else { - Delete_Chunk(d, chunk_info[current_chunk]); - variable_set2(DISK_PARTITIONED, "yes"); - record_chunks(d); - } - break; - - case 'T': - if (chunk_info[current_chunk]->type == unused) - msg = "Slice is currently unused (use create instead)"; - else { - char *val, tmp[20]; - int subtype; - chunk_e partitiontype; - WINDOW *save = savescr(); - - strcpy(tmp, "165"); - val = msgGetInput(tmp, "New partition type:\n\n" - "Pressing Enter will choose the default, a native FreeBSD\n" - "slice (type 165). Other popular values are 6 for\n" - "DOS FAT partition, 131 for a Linux ext2fs partition or\n" - "130 for a Linux swap partition.\n\n" - "Note: If you choose a non-FreeBSD partition type, it will not\n" - "be formatted or otherwise prepared, it will simply reserve space\n" - "for you to use another tool, such as DOS format, to later format\n" - "and actually use the partition."); - if (val && (subtype = strtol(val, NULL, 0)) > 0) { - if (subtype == 165) - partitiontype = freebsd; - else if (subtype == 6) - partitiontype = fat; - else - partitiontype = unknown; - chunk_info[current_chunk]->type = partitiontype; - chunk_info[current_chunk]->subtype = subtype; - } - restorescr(save); - } - break; - - case 'G': - snprintf(geometry, 80, "%lu/%lu/%lu", d->bios_cyl, d->bios_hd, d->bios_sect); - val = msgGetInput(geometry, "Please specify the new geometry in cyl/hd/sect format.\n" - "Don't forget to use the two slash (/) separator characters!\n" - "It's not possible to parse the field without them."); - if (val) { - long nc, nh, ns; - nc = strtol(val, &val, 0); - nh = strtol(val + 1, &val, 0); - ns = strtol(val + 1, 0, 0); - Set_Bios_Geom(d, nc, nh, ns); - } - clear(); - break; - - case 'S': - /* Set Bootable */ - chunk_info[current_chunk]->flags |= CHUNK_ACTIVE; - break; - - case 'U': - if ((cp = variable_get(DISK_LABELLED)) && !strcmp(cp, "written")) { - msgConfirm("You've already written this information out - you\n" - "can't undo it."); - } - else if (!msgYesNo("Are you SURE you want to Undo everything?")) { - char cp[BUFSIZ]; - - sstrncpy(cp, d->name, sizeof cp); - Free_Disk(dev->private); - d = Open_Disk(cp); - if (!d) - msgConfirm("Can't reopen disk %s! Internal state is probably corrupted", cp); - dev->private = d; - variable_unset(DISK_PARTITIONED); - variable_unset(DISK_LABELLED); - if (d) - record_chunks(d); - } - clear(); - break; - - case 'W': - if (!msgYesNo("WARNING: This should only be used when modifying an EXISTING\n" - "installation. If you are installing FreeBSD for the first time\n" - "then you should simply type Q when you're finished here and your\n" - "changes will be committed in one batch automatically at the end of\n" - "these questions. If you're adding a disk, you should NOT write\n" - "from this screen, you should do it from the label editor.\n\n" - "Are you absolutely sure you want to do this now?")) { - variable_set2(DISK_PARTITIONED, "yes"); - - /* Don't trash the MBR if the first (and therefore only) chunk is marked for a truly dedicated - * disk (i.e., the disklabel starts at sector 0), even in cases where the user has requested - * booteasy or a "standard" MBR -- both would be fatal in this case. - */ -#if 0 - if ((d->chunks->part->flags & CHUNK_FORCE_ALL) != CHUNK_FORCE_ALL - && (mbrContents = getBootMgr(d->name)) != NULL) - Set_Boot_Mgr(d, mbrContents); -#else - /* - * Don't offer to update the MBR on this disk if the first "real" chunk looks like - * a FreeBSD "all disk" partition, or the disk is entirely FreeBSD. - */ - if (((d->chunks->part->type != freebsd) || (d->chunks->part->offset > 1)) && - (mbrContents = getBootMgr(d->name)) != NULL) - Set_Boot_Mgr(d, mbrContents); -#endif - - if (DITEM_STATUS(diskPartitionWrite(NULL)) != DITEM_SUCCESS) - msgConfirm("Disk partition write returned an error status!"); - else - msgConfirm("Wrote FDISK partition information out successfully."); - } - clear(); - break; - - case '|': - if (!msgYesNo("Are you SURE you want to go into Wizard mode?\n" - "No seat belts whatsoever are provided!")) { - clear(); - refresh(); - slice_wizard(d); - variable_set2(DISK_PARTITIONED, "yes"); - record_chunks(d); - } - else - msg = "Wise choice!"; - clear(); - break; - - case '\033': /* ESC */ - case 'Q': - chunking = FALSE; - /* Don't trash the MBR if the first (and therefore only) chunk is marked for a truly dedicated - * disk (i.e., the disklabel starts at sector 0), even in cases where the user has requested - * booteasy or a "standard" MBR -- both would be fatal in this case. - */ -#if 0 - if ((d->chunks->part->flags & CHUNK_FORCE_ALL) != CHUNK_FORCE_ALL - && (mbrContents = getBootMgr(d->name)) != NULL) - Set_Boot_Mgr(d, mbrContents); -#else - /* - * Don't offer to update the MBR on this disk if the first "real" chunk looks like - * a FreeBSD "all disk" partition, or the disk is entirely FreeBSD. - */ - if (((d->chunks->part->type != freebsd) || (d->chunks->part->offset > 1)) && - (mbrContents = getBootMgr(d->name)) != NULL) - Set_Boot_Mgr(d, mbrContents); -#endif - break; - - default: - beep(); - msg = "Type F1 or ? for help"; - break; - } - } - p = CheckRules(d); - if (p) { - char buf[FILENAME_MAX]; - - dialog_clear_norefresh(); - use_helpline("Press F1 to read more about disk slices."); - use_helpfile(systemHelpFile("partition", buf)); - if (!variable_get(VAR_NO_WARN)) - dialog_mesgbox("Disk slicing warning:", p, -1, -1); - free(p); - } - restorescr(w); -} - -static u_char * -bootalloc(char *name) -{ - char buf[FILENAME_MAX]; - struct stat sb; - - snprintf(buf, sizeof buf, "/boot/%s", name); - if (stat(buf, &sb) != -1) { - int fd; - - fd = open(buf, O_RDONLY); - if (fd != -1) { - u_char *cp; - - cp = malloc(sb.st_size); - if (read(fd, cp, sb.st_size) != sb.st_size) { - free(cp); - close(fd); - msgDebug("bootalloc: couldn't read %d bytes from %s\n", sb.st_size, buf); - return NULL; - } - close(fd); - return cp; - } - msgDebug("bootalloc: couldn't open %s\n", buf); - } - else - msgDebug("bootalloc: can't stat %s\n", buf); - return NULL; -} - -static int -partitionHook(dialogMenuItem *selected) -{ - Device **devs = NULL; - - devs = deviceFind(selected->prompt, DEVICE_TYPE_DISK); - if (!devs) { - msgConfirm("Unable to find disk %s!", selected->prompt); - return DITEM_FAILURE; - } - /* Toggle enabled status? */ - if (!devs[0]->enabled) { - devs[0]->enabled = TRUE; - diskPartition(devs[0]); - } - else - devs[0]->enabled = FALSE; - return DITEM_SUCCESS | DITEM_RESTORE; -} - -static int -partitionCheck(dialogMenuItem *selected) -{ - Device **devs = NULL; - - devs = deviceFind(selected->prompt, DEVICE_TYPE_DISK); - if (!devs || devs[0]->enabled == FALSE) - return FALSE; - return TRUE; -} - -int -diskPartitionEditor(dialogMenuItem *self) -{ - DMenu *menu; - Device **devs; - int i, cnt, devcnt; - - cnt = diskGetSelectCount(&devs); - devcnt = deviceCount(devs); - if (cnt == -1) { - msgConfirm("No disks found! Please verify that your disk controller is being\n" - "properly probed at boot time. See the Hardware Guide on the\n" - "Documentation menu for clues on diagnosing this type of problem."); - return DITEM_FAILURE; - } - else if (cnt) { - /* Some are already selected */ - for (i = 0; i < devcnt; i++) { - if (devs[i]->enabled) { - if (variable_get(VAR_NONINTERACTIVE)) - diskPartitionNonInteractive(devs[i]); - else - diskPartition(devs[i]); - } - } - } - else { - /* No disks are selected, fall-back case now */ - if (devcnt == 1) { - devs[0]->enabled = TRUE; - if (variable_get(VAR_NONINTERACTIVE)) - diskPartitionNonInteractive(devs[0]); - else - diskPartition(devs[0]); - return DITEM_SUCCESS; - } - else { - menu = deviceCreateMenu(&MenuDiskDevices, DEVICE_TYPE_DISK, partitionHook, partitionCheck); - if (!menu) { - msgConfirm("No devices suitable for installation found!\n\n" - "Please verify that your disk controller (and attached drives)\n" - "were detected properly. This can be done by pressing the\n" - "[Scroll Lock] key and using the Arrow keys to move back to\n" - "the boot messages. Press [Scroll Lock] again to return."); - return DITEM_FAILURE; - } - else { - i = dmenuOpenSimple(menu, FALSE) ? DITEM_SUCCESS : DITEM_FAILURE; - free(menu); - } - return i | DITEM_RESTORE; - } - } - return DITEM_SUCCESS; -} - -int -diskPartitionWrite(dialogMenuItem *self) -{ - Device **devs; - int i; - char *cp; - - devs = deviceFind(NULL, DEVICE_TYPE_DISK); - if (!devs) { - msgConfirm("Unable to find any disks to write to??"); - return DITEM_FAILURE; - } - if (isDebug()) - msgDebug("diskPartitionWrite: Examining %d devices\n", deviceCount(devs)); - cp = variable_get(DISK_PARTITIONED); - if (cp && !strcmp(cp, "written")) - return DITEM_SUCCESS; - - for (i = 0; devs[i]; i++) { - Chunk *c1; - Disk *d = (Disk *)devs[i]->private; - static u_char *boot1; -#ifndef __alpha__ - static u_char *boot2; -#endif - - if (!devs[i]->enabled) - continue; - -#ifdef __alpha__ - if (!boot1) boot1 = bootalloc("boot1"); - Set_Boot_Blocks(d, boot1, NULL); -#else - if (!boot1) boot1 = bootalloc("boot1"); - if (!boot2) boot2 = bootalloc("boot2"); - Set_Boot_Blocks(d, boot1, boot2); -#endif - - msgNotify("Writing partition information to drive %s", d->name); - if (!Fake && Write_Disk(d)) { - msgConfirm("ERROR: Unable to write data to disk %s!", d->name); - return DITEM_FAILURE; - } - - /* If we've been through here before, we don't need to do the rest */ - if (cp && !strcmp(cp, "written")) - return DITEM_SUCCESS; - - /* Now scan for bad blocks, if necessary */ - for (c1 = d->chunks->part; c1; c1 = c1->next) { - if (c1->flags & CHUNK_BAD144) { - int ret; - - msgNotify("Running bad block scan on slice %s", c1->name); - if (!Fake) { - ret = vsystem("bad144 -v /dev/r%s 1234", c1->name); - if (ret) - msgConfirm("Bad144 init on %s returned status of %d!", c1->name, ret); - ret = vsystem("bad144 -v -s /dev/r%s", c1->name); - if (ret) - msgConfirm("Bad144 scan on %s returned status of %d!", c1->name, ret); - } - } - } - } - /* Now it's not "yes", but "written" */ - variable_set2(DISK_PARTITIONED, "written"); - return DITEM_SUCCESS; -} - -/* Partition a disk based wholly on which variables are set */ -static void -diskPartitionNonInteractive(Device *dev) -{ - char *cp; - int i, sz, all_disk = 0; - u_char *mbrContents; - Disk *d = (Disk *)dev->private; - - record_chunks(d); - cp = variable_get(VAR_GEOMETRY); - if (cp) { - msgDebug("Setting geometry from script to: %s\n", cp); - d->bios_cyl = strtol(cp, &cp, 0); - d->bios_hd = strtol(cp + 1, &cp, 0); - d->bios_sect = strtol(cp + 1, 0, 0); - } - - cp = variable_get(VAR_PARTITION); - if (cp) { - if (!strcmp(cp, "free")) { - /* Do free disk space case */ - for (i = 0; chunk_info[i]; i++) { - /* If a chunk is at least 10MB in size, use it. */ - if (chunk_info[i]->type == unused && chunk_info[i]->size > (10 * ONE_MEG)) { - Create_Chunk(d, chunk_info[i]->offset, chunk_info[i]->size, freebsd, 3, - (chunk_info[i]->flags & CHUNK_ALIGN)); - variable_set2(DISK_PARTITIONED, "yes"); - break; - } - } - if (!chunk_info[i]) { - dialog_clear(); - msgConfirm("Unable to find any free space on this disk!"); - return; - } - } - else if (!strcmp(cp, "all")) { - /* Do all disk space case */ - msgDebug("Warning: Devoting all of disk %s to FreeBSD.\n", d->name); - - All_FreeBSD(d, FALSE); - } - else if (!strcmp(cp, "exclusive")) { - /* Do really-all-the-disk-space case */ - msgDebug("Warning: Devoting all of disk %s to FreeBSD.\n", d->name); - - All_FreeBSD(d, all_disk = TRUE); - } - else if ((sz = strtol(cp, &cp, 0))) { - /* Look for sz bytes free */ - if (*cp && toupper(*cp) == 'M') - sz *= ONE_MEG; - for (i = 0; chunk_info[i]; i++) { - /* If a chunk is at least sz MB, use it. */ - if (chunk_info[i]->type == unused && chunk_info[i]->size >= sz) { - Create_Chunk(d, chunk_info[i]->offset, sz, freebsd, 3, (chunk_info[i]->flags & CHUNK_ALIGN)); - variable_set2(DISK_PARTITIONED, "yes"); - break; - } - } - if (!chunk_info[i]) { - dialog_clear(); - msgConfirm("Unable to find %d free blocks on this disk!", sz); - return; - } - } - else if (!strcmp(cp, "existing")) { - /* Do existing FreeBSD case */ - for (i = 0; chunk_info[i]; i++) { - if (chunk_info[i]->type == freebsd) - break; - } - if (!chunk_info[i]) { - dialog_clear(); - msgConfirm("Unable to find any existing FreeBSD partitions on this disk!"); - return; - } - } - else { - dialog_clear(); - msgConfirm("`%s' is an invalid value for %s - is config file valid?", cp, VAR_PARTITION); - return; - } - if (!all_disk) { - mbrContents = getBootMgr(d->name); - Set_Boot_Mgr(d, mbrContents); - } - variable_set2(DISK_PARTITIONED, "yes"); - } -} diff --git a/usr.sbin/sysinstall/dispatch.c b/usr.sbin/sysinstall/dispatch.c deleted file mode 100644 index 5e1668a3da78..000000000000 --- a/usr.sbin/sysinstall/dispatch.c +++ /dev/null @@ -1,436 +0,0 @@ -/* - * The new sysinstall program. - * - * This is probably the last program in the `sysinstall' line - the next - * generation being essentially a complete rewrite. - * - * $Id: dispatch.c,v 1.25 1998/07/18 09:41:58 jkh Exp $ - * - * Copyright (c) 1995 - * Jordan Hubbard. 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, - * verbatim and that no modifications are made prior to this - * point in the file. - * 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 JORDAN HUBBARD ``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 JORDAN HUBBARD OR HIS PETS 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, LIFE 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. - * - */ - -#include "sysinstall.h" -#include <ctype.h> -#include <errno.h> -#include <sys/signal.h> -#include <sys/fcntl.h> - -#include "list.h" - -static int dispatch_shutdown(dialogMenuItem *unused); -static int dispatch_systemExecute(dialogMenuItem *unused); -static int dispatch_msgConfirm(dialogMenuItem *unused); - -static struct _word { - char *name; - int (*handler)(dialogMenuItem *self); -} resWords[] = { - { "configAnonFTP", configAnonFTP }, - { "configRouter", configRouter }, - { "configNFSServer", configNFSServer }, - { "configNTP", configNTP }, - { "configPCNFSD", configPCNFSD }, - { "configPackages", configPackages }, - { "configRegister", configRegister }, - { "configUsers", configUsers }, - { "configXEnvironment", configXEnvironment }, - { "diskPartitionEditor", diskPartitionEditor }, - { "diskPartitionWrite", diskPartitionWrite }, - { "diskLabelEditor", diskLabelEditor }, - { "diskLabelCommit", diskLabelCommit }, - { "distReset", distReset }, - { "distSetCustom", distSetCustom }, - { "distSetDeveloper", distSetDeveloper }, - { "distSetXDeveloper", distSetXDeveloper }, - { "distSetKernDeveloper", distSetKernDeveloper }, - { "distSetUser", distSetUser }, - { "distSetXUser", distSetXUser }, - { "distSetMinimum", distSetMinimum }, - { "distSetEverything", distSetEverything }, - { "distSetDES", distSetDES }, - { "distSetSrc", distSetSrc }, - { "distSetXF86", distSetXF86 }, - { "distExtractAll", distExtractAll }, - { "docBrowser", docBrowser }, - { "docShowDocument", docShowDocument }, - { "installCommit", installCommit }, - { "installExpress", installExpress }, - { "installNovice", installNovice }, - { "installUpgrade", installUpgrade }, - { "installFixupBin", installFixupBin }, - { "installFixupXFree", installFixupXFree }, - { "installFixitHoloShell", installFixitHoloShell }, - { "installFixitCDROM", installFixitCDROM }, - { "installFixitFloppy", installFixitFloppy }, - { "installFilesystems", installFilesystems }, - { "installVarDefaults", installVarDefaults }, - { "loadConfig", dispatch_load_file }, - { "loadFloppyConfig", dispatch_load_floppy }, - { "mediaSetCDROM", mediaSetCDROM }, - { "mediaSetFloppy", mediaSetFloppy }, - { "mediaSetDOS", mediaSetDOS }, - { "mediaSetTape", mediaSetTape }, - { "mediaSetFTP", mediaSetFTP }, - { "mediaSetFTPActive", mediaSetFTPActive }, - { "mediaSetFTPPassive", mediaSetFTPPassive }, - { "mediaSetUFS", mediaSetUFS }, - { "mediaSetNFS", mediaSetNFS }, - { "mediaSetFTPUserPass", mediaSetFTPUserPass }, - { "mediaSetCPIOVerbosity", mediaSetCPIOVerbosity }, - { "mediaGetType", mediaGetType }, - { "msgConfirm", dispatch_msgConfirm }, - { "optionsEditor", optionsEditor }, - { "register", configRegister }, /* Alias */ - { "packageAdd", packageAdd }, - { "addGroup", userAddGroup }, - { "addUser", userAddUser }, - { "shutdown", dispatch_shutdown }, - { "system", dispatch_systemExecute }, - { "dumpVariables", dump_variables }, - { "tcpMenuSelect", tcpMenuSelect }, - { NULL, NULL }, -}; - -/* - * Helper routines for buffering data. - * - * We read an entire configuration into memory before executing it - * so that we are truely standalone and can do things like nuke the - * file or disk we're working on. - */ - -typedef struct command_buffer_ { - qelement queue; - char * string; -} command_buffer; - -static void -dispatch_free_command(command_buffer *item) -{ - REMQUE(item); - free(item->string); - free(item); -} - -static void -dispatch_free_all(qelement *head) -{ - command_buffer *item; - - while (!EMPTYQUE(*head)) { - item = (command_buffer *) head->q_forw; - dispatch_free_command(item); - } -} - -static command_buffer * -dispatch_add_command(qelement *head, char *string) -{ - command_buffer *new; - - new = malloc(sizeof(command_buffer)); - - if (!new) - return NULL; - - new->string = strdup(string); - INSQUEUE(new, head->q_back); - - return new; -} - -/* - * Command processing - */ - -/* Just convenience */ -static int -dispatch_shutdown(dialogMenuItem *unused) -{ - systemShutdown(0); - return DITEM_FAILURE; -} - -static int -dispatch_systemExecute(dialogMenuItem *unused) -{ - char *cmd = variable_get(VAR_COMMAND); - - if (cmd) - return systemExecute(cmd) ? DITEM_FAILURE : DITEM_SUCCESS; - else - msgDebug("_systemExecute: No command passed in `command' variable.\n"); - return DITEM_FAILURE; -} - -static int -dispatch_msgConfirm(dialogMenuItem *unused) -{ - char *msg = variable_get(VAR_COMMAND); - - if (msg) { - msgConfirm(msg); - return DITEM_SUCCESS; - } - - msgDebug("_msgConfirm: No message passed in `command' variable.\n"); - return DITEM_FAILURE; -} - -static int -call_possible_resword(char *name, dialogMenuItem *value, int *status) -{ - int i, rval; - - rval = 0; - for (i = 0; resWords[i].name; i++) { - if (!strcmp(name, resWords[i].name)) { - *status = resWords[i].handler(value); - rval = 1; - break; - } - } - return rval; -} - -/* For a given string, call it or spit out an undefined command diagnostic */ -int -dispatchCommand(char *str) -{ - int i; - char *cp; - - if (!str || !*str) { - msgConfirm("Null or zero-length string passed to dispatchCommand"); - return DITEM_FAILURE; - } - /* If it's got a newline, trim it */ - if ((cp = index(str, '\n')) != NULL) - *cp = '\0'; - - /* If it's got a `=' sign in there, assume it's a variable setting */ - if (index(str, '=')) { - if (isDebug()) - msgDebug("dispatch: setting variable `%s'\n", str); - variable_set(str); - i = DITEM_SUCCESS; - } - else { - /* A command might be a pathname if it's encoded in argv[0], which - we also support */ - if ((cp = rindex(str, '/')) != NULL) - str = cp + 1; - if (isDebug()) - msgDebug("dispatch: calling resword `%s'\n", str); - if (!call_possible_resword(str, NULL, &i)) { - msgNotify("Warning: No such command ``%s''", str); - i = DITEM_FAILURE; - } - } - return i; -} - - -/* - * File processing - */ - -static qelement * -dispatch_load_fp(FILE *fp) -{ - qelement *head; - char buf[BUFSIZ], *cp; - - head = malloc(sizeof(qelement)); - - if (!head) - return NULL; - - INITQUE(*head); - - while (fgets(buf, sizeof buf, fp)) { - - if ((cp = strchr(buf, '\n')) != NULL) - *cp = '\0'; - if (*buf == '\0' || *buf == '#') - continue; - - if (!dispatch_add_command(head, buf)) - return NULL; - } - - return head; -} - -static int -dispatch_execute(qelement *head) -{ - int result = DITEM_SUCCESS; - command_buffer *item; - char *old_interactive; - - if (!head) - return result | DITEM_FAILURE; - - old_interactive = variable_get(VAR_NONINTERACTIVE); - if (old_interactive) - old_interactive = strdup(old_interactive); /* save copy */ - - /* Hint to others that we're running from a script, should they care */ - variable_set2(VAR_NONINTERACTIVE, "yes"); - - while (!EMPTYQUE(*head)) { - item = (command_buffer *) head->q_forw; - - if (DITEM_STATUS(dispatchCommand(item->string)) != DITEM_SUCCESS) { - /* - * Allow a user to prefix a command with "noError" to cause - * us to ignore any errors for that one command. - */ - if (variable_get(VAR_NO_ERROR)) - variable_unset(VAR_NO_ERROR); - else { - msgConfirm("Command `%s' failed - rest of script aborted.\n", - item->string); - result |= DITEM_FAILURE; - break; - } - } - dispatch_free_command(item); - } - - dispatch_free_all(head); - - if (!old_interactive) - variable_unset(VAR_NONINTERACTIVE); - else { - variable_set2(VAR_NONINTERACTIVE, old_interactive); - free(old_interactive); - } - - return result; -} - -int -dispatch_load_file_int(int quiet) -{ - FILE *fp; - char *cp; - int i; - qelement *list; - - static const char *names[] = { - "install.cfg", - "/stand/install.cfg", - "/tmp/install.cfg", - NULL - }; - - fp = NULL; - cp = variable_get(VAR_CONFIG_FILE); - if (!cp) { - for (i = 0; names[i]; i++) - if ((fp = fopen(names[i], "r")) != NULL) - break; - } else - fp = fopen(cp, "r"); - - if (!fp) { - if (!quiet) - msgConfirm("Unable to open %s: %s", cp, strerror(errno)); - return DITEM_FAILURE; - } - - list = dispatch_load_fp(fp); - fclose(fp); - - return dispatch_execute(list); -} - -int -dispatch_load_file(dialogMenuItem *self) -{ - return dispatch_load_file_int(FALSE); -} - -int -dispatch_load_floppy(dialogMenuItem *self) -{ - int what = DITEM_RESTORE | DITEM_SUCCESS; - extern char *distWanted; - char *cp; - FILE *fp; - qelement *list; - - mediaClose(); - dialog_clear_norefresh(); - - cp = variable_get_value(VAR_INSTALL_CFG, - "Specify the name of a configuration file\n" - "residing on a MSDOS or UFS floppy."); - if (!cp || !*cp) { - variable_unset(VAR_INSTALL_CFG); - what |= DITEM_FAILURE; - return what; - } - - distWanted = cp; - /* Try to open the floppy drive */ - if (DITEM_STATUS(mediaSetFloppy(NULL)) == DITEM_FAILURE) { - msgConfirm("Unable to set media device to floppy."); - what |= DITEM_FAILURE; - mediaClose(); - return what; - } - - if (!mediaDevice->init(mediaDevice)) { - msgConfirm("Unable to mount floppy filesystem."); - what |= DITEM_FAILURE; - mediaClose(); - return what; - } - - fp = mediaDevice->get(mediaDevice, cp, TRUE); - if (fp) { - list = dispatch_load_fp(fp); - fclose(fp); - mediaClose(); - - what |= dispatch_execute(list); - } - else { - if (!variable_get(VAR_NO_ERROR)) - msgConfirm("Configuration file '%s' not found.", cp); - variable_unset(VAR_INSTALL_CFG); - what |= DITEM_FAILURE; - mediaClose(); - } - - return what; -} - diff --git a/usr.sbin/sysinstall/dist.c b/usr.sbin/sysinstall/dist.c deleted file mode 100644 index d84c6ef5331a..000000000000 --- a/usr.sbin/sysinstall/dist.c +++ /dev/null @@ -1,806 +0,0 @@ -/* - * The new sysinstall program. - * - * This is probably the last program in the `sysinstall' line - the next - * generation being essentially a complete rewrite. - * - * $Id: dist.c,v 1.131 1998/11/27 00:30:10 jkh Exp $ - * - * Copyright (c) 1995 - * Jordan Hubbard. 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, - * verbatim and that no modifications are made prior to this - * point in the file. - * 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 JORDAN HUBBARD ``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 JORDAN HUBBARD OR HIS PETS 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, LIFE 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. - * - */ - -#include "sysinstall.h" -#include <sys/time.h> -#include <signal.h> -#include <libutil.h> - -unsigned int Dists; -unsigned int DESDists; -unsigned int SrcDists; -unsigned int XF86Dists; -unsigned int XF86ServerDists; -unsigned int XF86FontDists; - -typedef struct _dist { - char *my_name; - char *my_dir; - unsigned int *my_mask; - unsigned int my_bit; - struct _dist *my_dist; -} Distribution; - -extern Distribution DistTable[]; -extern Distribution DESDistTable[]; -extern Distribution SrcDistTable[]; -extern Distribution XF86DistTable[]; -extern Distribution XF86FontDistTable[]; -extern Distribution XF86ServerDistTable[]; - -/* The top-level distribution categories */ -static Distribution DistTable[] = { -{ "bin", "/", &Dists, DIST_BIN, NULL }, -{ "doc", "/", &Dists, DIST_DOC, NULL }, -{ "games", "/", &Dists, DIST_GAMES, NULL }, -{ "manpages", "/", &Dists, DIST_MANPAGES, NULL }, -{ "catpages", "/", &Dists, DIST_CATPAGES, NULL }, -{ "proflibs", "/", &Dists, DIST_PROFLIBS, NULL }, -{ "dict", "/", &Dists, DIST_DICT, NULL }, -{ "info", "/", &Dists, DIST_INFO, NULL }, -{ "src", "/", &Dists, DIST_SRC, SrcDistTable }, -{ "des", "/", &Dists, DIST_DES, DESDistTable }, -{ "compat1x", "/", &Dists, DIST_COMPAT1X, NULL }, -{ "compat20", "/", &Dists, DIST_COMPAT20, NULL }, -{ "compat21", "/", &Dists, DIST_COMPAT21, NULL }, -{ "ports", "/usr", &Dists, DIST_PORTS, NULL }, -{ "XF86333", "/usr", &Dists, DIST_XF86, XF86DistTable }, -{ NULL }, -}; - -/* The DES distribution (not for export!) */ -static Distribution DESDistTable[] = { -{ "des", "/", &DESDists, DIST_DES_DES, NULL }, -{ "krb", "/", &DESDists, DIST_DES_KERBEROS, NULL }, -{ "ssecure", "/usr/src", &DESDists, DIST_DES_SSECURE, NULL }, -{ "scrypto", "/usr/src", &DESDists, DIST_DES_SCRYPTO, NULL }, -{ "skerbero", "/usr/src", &DESDists, DIST_DES_SKERBEROS, NULL }, -{ NULL }, -}; - -/* The /usr/src distribution */ -static Distribution SrcDistTable[] = { -{ "sbase", "/usr/src", &SrcDists, DIST_SRC_BASE, NULL }, -{ "scontrib", "/usr/src", &SrcDists, DIST_SRC_CONTRIB, NULL }, -{ "sgnu", "/usr/src", &SrcDists, DIST_SRC_GNU, NULL }, -{ "setc", "/usr/src", &SrcDists, DIST_SRC_ETC, NULL }, -{ "sgames", "/usr/src", &SrcDists, DIST_SRC_GAMES, NULL }, -{ "sinclude", "/usr/src", &SrcDists, DIST_SRC_INCLUDE, NULL }, -{ "slib", "/usr/src", &SrcDists, DIST_SRC_LIB, NULL }, -{ "slibexec", "/usr/src", &SrcDists, DIST_SRC_LIBEXEC, NULL }, -{ "srelease", "/usr/src", &SrcDists, DIST_SRC_RELEASE, NULL }, -{ "sbin", "/usr/src", &SrcDists, DIST_SRC_BIN, NULL }, -{ "ssbin", "/usr/src", &SrcDists, DIST_SRC_SBIN, NULL }, -{ "sshare", "/usr/src", &SrcDists, DIST_SRC_SHARE, NULL }, -{ "ssys", "/usr/src", &SrcDists, DIST_SRC_SYS, NULL }, -{ "subin", "/usr/src", &SrcDists, DIST_SRC_UBIN, NULL }, -{ "susbin", "/usr/src", &SrcDists, DIST_SRC_USBIN, NULL }, -{ "ssmailcf", "/usr/src", &SrcDists, DIST_SRC_SMAILCF, NULL }, -{ NULL }, -}; - -/* The XFree86 distribution */ -static Distribution XF86DistTable[] = { -{ "XF86333", "/usr/X11R6", &XF86Dists, DIST_XF86_FONTS, XF86FontDistTable }, -{ "XF86333", "/usr/X11R6", &XF86Dists, DIST_XF86_SERVER, XF86ServerDistTable }, -{ "Xsrc1", "/usr/X11R6/src", &XF86Dists, DIST_XF86_SRC, NULL }, -{ "Xsrcctrb", "/usr/X11R6/src", &XF86Dists, DIST_XF86_CSRC, NULL }, -{ "Xbin", "/usr/X11R6", &XF86Dists, DIST_XF86_BIN, NULL }, -{ "Xcfg", "/usr/X11R6", &XF86Dists, DIST_XF86_CFG, NULL }, -{ "Xdoc", "/usr/X11R6", &XF86Dists, DIST_XF86_DOC, NULL }, -{ "Xhtml", "/usr/X11R6", &XF86Dists, DIST_XF86_HTML, NULL }, -{ "Xlib", "/usr/X11R6", &XF86Dists, DIST_XF86_LIB, NULL }, -{ "Xlk98", "/usr/X11R6", &XF86Dists, DIST_XF86_LKIT98, NULL }, -{ "Xlkit", "/usr/X11R6", &XF86Dists, DIST_XF86_LKIT, NULL }, -{ "Xman", "/usr/X11R6", &XF86Dists, DIST_XF86_MAN, NULL }, -{ "Xprog", "/usr/X11R6", &XF86Dists, DIST_XF86_PROG, NULL }, -{ "Xps", "/usr/X11R6", &XF86Dists, DIST_XF86_PS, NULL }, -{ "Xset", "/usr/X11R6", &XF86Dists, DIST_XF86_SET, NULL }, -{ "X9set", "/usr/X11R6", &XF86Dists, DIST_XF86_9SET, NULL }, -{ NULL }, -}; - -/* The XFree86 server distribution */ -static Distribution XF86ServerDistTable[] = { -{ "PC98-Servers/X9480", "/usr/X11R6", &XF86ServerDists, DIST_XF86_SERVER_9480, NULL }, -{ "PC98-Servers/X9EGC", "/usr/X11R6", &XF86ServerDists, DIST_XF86_SERVER_9EGC, NULL }, -{ "PC98-Servers/X9GA9", "/usr/X11R6", &XF86ServerDists, DIST_XF86_SERVER_9GA9, NULL }, -{ "PC98-Servers/X9GAN", "/usr/X11R6", &XF86ServerDists, DIST_XF86_SERVER_9GAN, NULL }, -{ "PC98-Servers/X9LPW", "/usr/X11R6", &XF86ServerDists, DIST_XF86_SERVER_9LPW, NULL }, -{ "PC98-Servers/X9MGA", "/usr/X11R6", &XF86ServerDists, DIST_XF86_SERVER_9MGA, NULL }, -{ "PC98-Servers/X9NKV", "/usr/X11R6", &XF86ServerDists, DIST_XF86_SERVER_9NKV, NULL }, -{ "PC98-Servers/X9NS3", "/usr/X11R6", &XF86ServerDists, DIST_XF86_SERVER_9NS3, NULL }, -{ "PC98-Servers/X9SPW", "/usr/X11R6", &XF86ServerDists, DIST_XF86_SERVER_9SPW, NULL }, -{ "PC98-Servers/X9SVG", "/usr/X11R6", &XF86ServerDists, DIST_XF86_SERVER_9SVG, NULL }, -{ "PC98-Servers/X9TGU", "/usr/X11R6", &XF86ServerDists, DIST_XF86_SERVER_9TGU, NULL }, -{ "PC98-Servers/X9WEP", "/usr/X11R6", &XF86ServerDists, DIST_XF86_SERVER_9WEP, NULL }, -{ "PC98-Servers/X9WS", "/usr/X11R6", &XF86ServerDists, DIST_XF86_SERVER_9WS, NULL }, -{ "PC98-Servers/X9WSN", "/usr/X11R6", &XF86ServerDists, DIST_XF86_SERVER_9WSN, NULL }, -{ "Servers/X8514", "/usr/X11R6", &XF86ServerDists, DIST_XF86_SERVER_8514, NULL }, -{ "Servers/XAGX", "/usr/X11R6", &XF86ServerDists, DIST_XF86_SERVER_AGX, NULL }, -{ "Servers/XI128", "/usr/X11R6", &XF86ServerDists, DIST_XF86_SERVER_I128, NULL }, -{ "Servers/XMa8", "/usr/X11R6", &XF86ServerDists, DIST_XF86_SERVER_MACH8, NULL }, -{ "Servers/XMa32", "/usr/X11R6", &XF86ServerDists, DIST_XF86_SERVER_MACH32,NULL }, -{ "Servers/XMa64", "/usr/X11R6", &XF86ServerDists, DIST_XF86_SERVER_MACH64,NULL }, -{ "Servers/XMono", "/usr/X11R6", &XF86ServerDists, DIST_XF86_SERVER_MONO, NULL }, -{ "Servers/XP9K", "/usr/X11R6", &XF86ServerDists, DIST_XF86_SERVER_P9000, NULL }, -{ "Servers/XS3", "/usr/X11R6", &XF86ServerDists, DIST_XF86_SERVER_S3, NULL }, -{ "Servers/XS3V", "/usr/X11R6", &XF86ServerDists, DIST_XF86_SERVER_S3V, NULL }, -{ "Servers/XSVGA", "/usr/X11R6", &XF86ServerDists, DIST_XF86_SERVER_SVGA, NULL }, -{ "Servers/XVG16", "/usr/X11R6", &XF86ServerDists, DIST_XF86_SERVER_VGA16, NULL }, -{ "Servers/XW32", "/usr/X11R6", &XF86ServerDists, DIST_XF86_SERVER_W32, NULL }, -{ "Xnest", "/usr/X11R6", &XF86ServerDists, DIST_XF86_SERVER_NEST, NULL }, -{ NULL }, -}; - -/* The XFree86 font distribution */ -static Distribution XF86FontDistTable[] = { -{ "Xfnts", "/usr/X11R6", &XF86FontDists, DIST_XF86_FONTS_MISC, NULL }, -{ "Xf100", "/usr/X11R6", &XF86FontDists, DIST_XF86_FONTS_100, NULL }, -{ "Xfcyr", "/usr/X11R6", &XF86FontDists, DIST_XF86_FONTS_CYR, NULL }, -{ "Xfscl", "/usr/X11R6", &XF86FontDists, DIST_XF86_FONTS_SCALE, NULL }, -{ "Xfnon", "/usr/X11R6", &XF86FontDists, DIST_XF86_FONTS_NON, NULL }, -{ "Xfsrv", "/usr/X11R6", &XF86FontDists, DIST_XF86_FONTS_SERVER, NULL }, -{ NULL }, -}; - -static int distMaybeSetDES(dialogMenuItem *self); -static int distMaybeSetPorts(dialogMenuItem *self); - - -static void -distVerifyFlags(void) -{ - if (SrcDists) - Dists |= DIST_SRC; - if (DESDists) { - if (DESDists & DIST_DES_KERBEROS) - DESDists |= DIST_DES_DES; - Dists |= DIST_DES; - } - if (XF86Dists & DIST_XF86_SET) - XF86ServerDists |= DIST_XF86_SERVER_VGA16; - if (XF86ServerDists) - XF86Dists |= DIST_XF86_SERVER; - if (XF86FontDists) - XF86Dists |= DIST_XF86_FONTS; - if (XF86Dists || XF86ServerDists || XF86FontDists) - Dists |= DIST_XF86; - if (isDebug()) - msgDebug("Dist Masks: Dists: %0x, DES: %0x, Srcs: %0x\nXServer: %0x, XFonts: %0x, XDists: %0x\n", - Dists, DESDists, SrcDists, XF86ServerDists, XF86FontDists, XF86Dists); -} - -int -distReset(dialogMenuItem *self) -{ - Dists = 0; - DESDists = 0; - SrcDists = 0; - XF86Dists = 0; - XF86ServerDists = 0; - XF86FontDists = 0; - return DITEM_SUCCESS | DITEM_REDRAW; -} - -int -distConfig(dialogMenuItem *self) -{ - char *cp; - - distReset(NULL); - - if ((cp = variable_get(VAR_DIST_MAIN)) != NULL) - Dists = atoi(cp); - - if ((cp = variable_get(VAR_DIST_DES)) != NULL) - DESDists = atoi(cp); - - if ((cp = variable_get(VAR_DIST_SRC)) != NULL) - SrcDists = atoi(cp); - - if ((cp = variable_get(VAR_DIST_X11)) != NULL) - XF86Dists = atoi(cp); - - if ((cp = variable_get(VAR_DIST_XSERVER)) != NULL) - XF86ServerDists = atoi(cp); - - if ((cp = variable_get(VAR_DIST_XFONTS)) != NULL) - XF86FontDists = atoi(cp); - distVerifyFlags(); - return DITEM_SUCCESS | DITEM_REDRAW; -} - -int -distSetDeveloper(dialogMenuItem *self) -{ - int i; - - distReset(NULL); - Dists = _DIST_DEVELOPER; - SrcDists = DIST_SRC_ALL; - i = distMaybeSetDES(self) | distMaybeSetPorts(self); - distVerifyFlags(); - return i; -} - -int -distSetXDeveloper(dialogMenuItem *self) -{ - int i; - - i = distSetDeveloper(self); - Dists |= DIST_XF86; - XF86Dists = DIST_XF86_BIN | DIST_XF86_SET | DIST_XF86_CFG | DIST_XF86_LIB | DIST_XF86_PROG | DIST_XF86_MAN | DIST_XF86_SERVER | DIST_XF86_FONTS; - XF86ServerDists = DIST_XF86_SERVER_SVGA | DIST_XF86_SERVER_VGA16; - XF86FontDists = DIST_XF86_FONTS_MISC; - i |= distSetXF86(NULL); - distVerifyFlags(); - return i; -} - -int -distSetKernDeveloper(dialogMenuItem *self) -{ - int i; - - distReset(NULL); - Dists = _DIST_DEVELOPER; - SrcDists = DIST_SRC_SYS; - i = distMaybeSetDES(self) | distMaybeSetPorts(self); - distVerifyFlags(); - return i; -} - -int -distSetUser(dialogMenuItem *self) -{ - int i; - - distReset(NULL); - Dists = _DIST_USER; - i = distMaybeSetDES(self) | distMaybeSetPorts(self); - distVerifyFlags(); - return i; -} - -int -distSetXUser(dialogMenuItem *self) -{ - int i; - - i = distSetUser(self); - Dists |= DIST_XF86; - XF86ServerDists = DIST_XF86_SERVER_SVGA | DIST_XF86_SERVER_VGA16; - XF86Dists = DIST_XF86_BIN | DIST_XF86_SET | DIST_XF86_CFG | DIST_XF86_LIB | DIST_XF86_MAN | DIST_XF86_SERVER | DIST_XF86_FONTS; - XF86FontDists = DIST_XF86_FONTS_MISC; - i |= distSetXF86(NULL); - distVerifyFlags(); - return i; -} - -int -distSetMinimum(dialogMenuItem *self) -{ - distReset(NULL); - Dists = DIST_BIN; - return DITEM_SUCCESS | DITEM_REDRAW; -} - -int -distSetEverything(dialogMenuItem *self) -{ - int i; - - Dists = DIST_ALL | DIST_XF86; - SrcDists = DIST_SRC_ALL; - XF86Dists = DIST_XF86_ALL; - XF86ServerDists = DIST_XF86_SERVER_ALL; - XF86FontDists = DIST_XF86_FONTS_ALL; - i = distMaybeSetDES(self) | distMaybeSetPorts(self); - distVerifyFlags(); - return i; -} - -int -distSetDES(dialogMenuItem *self) -{ - int i; - - if (!dmenuOpenSimple(&MenuDESDistributions, FALSE)) - i = DITEM_FAILURE; - else - i = DITEM_SUCCESS; - distVerifyFlags(); - return i | DITEM_RESTORE; -} - -static int -distMaybeSetDES(dialogMenuItem *self) -{ - int i = DITEM_SUCCESS; - - dialog_clear_norefresh(); - if (!msgYesNo("Do wish to install DES cryptographic software?\n\n" - "If you choose No, FreeBSD will use an MD5 based password scheme which,\n" - "while perhaps more secure, is not interoperable with the traditional\n" - "UNIX DES passwords on other non-FreeBSD systems.\n\n" - "Please do NOT choose Yes at this point if you are outside the\n" - "United States and Canada yet are installing from a U.S. FTP server.\n" - "This will violate U.S. export restrictions and possibly get the\n" - "server site into trouble! In such cases, install everything but the\n" - "DES distribution from the U.S. server then switch your media type to\n" - "point to an international FTP server, using the Custom installation\n" - "option to select and extract the DES distribution in a second pass.")) { - if (!dmenuOpenSimple(&MenuDESDistributions, FALSE)) - i = DITEM_FAILURE; - } - distVerifyFlags(); - return i | DITEM_RESTORE; -} - -static int -distMaybeSetPorts(dialogMenuItem *self) -{ - dialog_clear_norefresh(); - if (!msgYesNo("Would you like to install the FreeBSD ports collection?\n\n" - "This will give you ready access to over 1000 ported software packages,\n" - "though at a cost of around 35MB of disk space when \"clean\" and possibly\n" - "much more than that if a lot of the distribution tarballs are loaded\n" - "(unless you have the 4th CD from a FreeBSD CDROM distribution available\n" - "and can mount it on /cdrom, in which case this is far less of a problem).\n\n" - "The ports collection is a very valuable resource and, if you have at least\n" - "100MB to spare in your /usr partition, well worth having around.\n\n" - "For more information on the ports collection & the latest ports, visit:\n" - " http://www.freebsd.org/ports\n")) - Dists |= DIST_PORTS; - else - Dists &= ~DIST_PORTS; - return DITEM_SUCCESS | DITEM_RESTORE; -} - -static Boolean -distSetByName(Distribution *dist, char *name) -{ - int i, status = FALSE; - - /* Loop through current set */ - for (i = 0; dist[i].my_name; i++) { - /* This is shorthand for "dist currently disabled" */ - if (!dist[i].my_dir) - continue; - if (!strcmp(dist[i].my_name, name)) { - *(dist[i].my_mask) |= dist[i].my_bit; - status = TRUE; - } - if (dist[i].my_dist) { - if (distSetByName(dist[i].my_dist, name)) { - status = TRUE; - } - } - } - distVerifyFlags(); - return status; -} - -/* Just for the dispatch stuff */ -int -distSetCustom(dialogMenuItem *self) -{ - char *cp, *cp2, *tmp; - - if (!(tmp = variable_get(VAR_DISTS))) { - msgDebug("distSetCustom() called without %s variable set.\n", VAR_DISTS); - return DITEM_FAILURE; - } - - cp = alloca(strlen(tmp) + 1); - if (!cp) - msgFatal("Couldn't alloca() %d bytes!\n", strlen(tmp) + 1); - strcpy(cp, tmp); - while (cp) { - if ((cp2 = index(cp, ' ')) != NULL) - *(cp2++) = '\0'; - if (!distSetByName(DistTable, cp)) - msgDebug("distSetCustom: Warning, no such release \"%s\"\n", cp); - cp = cp2; - } - distVerifyFlags(); - return DITEM_SUCCESS; -} - -int -distSetSrc(dialogMenuItem *self) -{ - int i; - - if (!dmenuOpenSimple(&MenuSrcDistributions, FALSE)) - i = DITEM_FAILURE; - else - i = DITEM_SUCCESS; - distVerifyFlags(); - return i | DITEM_RESTORE; -} - -int -distSetXF86(dialogMenuItem *self) -{ - int i = DITEM_SUCCESS; - - if (!dmenuOpenSimple(&MenuXF86Select, FALSE)) - i = DITEM_FAILURE; - distVerifyFlags(); - return i | DITEM_RESTORE; -} - -static Boolean got_intr = FALSE; - -/* timeout handler */ -static void -handle_intr(int sig) -{ - msgDebug("User generated interrupt.\n"); - got_intr = TRUE; -} - -static int -check_for_interrupt(void) -{ - if (got_intr) { - got_intr = FALSE; - return TRUE; - } - return FALSE; -} - -static Boolean -distExtract(char *parent, Distribution *me) -{ - int i, status, total, intr; - int cpid, zpid, fd2, chunk, numchunks; - char *path, *dist, buf[BUFSIZ]; - const char *tmp; - FILE *fp; - WINDOW *w = savescr(); - struct timeval start, stop; - struct sigaction old, new; - - status = TRUE; - dialog_clear_norefresh(); - if (isDebug()) - msgDebug("distExtract: parent: %s, me: %s\n", parent ? parent : "(none)", me->my_name); - - /* Make ^C fake a sudden timeout */ - new.sa_handler = handle_intr; - new.sa_flags = 0; - new.sa_mask = 0; - sigaction(SIGINT, &new, &old); - - /* Loop through to see if we're in our parent's plans */ - for (i = 0; me[i].my_name; i++) { - dist = me[i].my_name; - path = parent ? parent : dist; - - /* If our bit isn't set, go to the next */ - if (!(me[i].my_bit & *(me[i].my_mask))) - continue; - - /* This is shorthand for "dist currently disabled" */ - if (!me[i].my_dir) { - *(me[i].my_mask) &= ~(me[i].my_bit); - continue; - } - - /* Recurse if we actually have a sub-distribution */ - if (me[i].my_dist) { - if ((status = distExtract(dist, me[i].my_dist)) == TRUE) - *(me[i].my_mask) &= ~(me[i].my_bit); - goto done; - } - - /* - * Try to get distribution as multiple pieces, locating and parsing an - * info file which tells us how many we need for this distribution. - */ - numchunks = 0; - snprintf(buf, sizeof buf, "%s/%s.inf", path, dist); - - getinfo: - fp = mediaDevice->get(mediaDevice, buf, TRUE); - intr = check_for_interrupt(); - if (fp == (FILE *)IO_ERROR || intr) { /* Hard error, can't continue */ - if (!msgYesNo("Unable to open %s: %s.\nReinitialize media?", - buf, !intr ? "I/O error." : "User interrupt.")) { - mediaDevice->shutdown(mediaDevice); - if (!mediaDevice->init(mediaDevice)) { - status = FALSE; - goto done; - } - else - goto getinfo; - } - else { - status = FALSE; - goto done; - } - } - else if (fp > 0) { - properties dist_attr; - - if (isDebug()) - msgDebug("Parsing attributes file for distribution %s\n", dist); - - dist_attr = properties_read(fileno(fp)); - intr = check_for_interrupt(); - if (intr || !dist_attr) { - msgConfirm("Cannot parse information file for the %s distribution: %s\n" - "Please verify that your media is valid and try again.", - dist, !intr ? "I/O error" : "User interrupt"); - } - else { - tmp = property_find(dist_attr, "Pieces"); - if (tmp) - numchunks = strtol(tmp, 0, 0); - } - fclose(fp); - properties_free(dist_attr); - if (!numchunks) - continue; - } - else { - /* Try to get the distribution as a single file */ - snprintf(buf, sizeof buf, "%s/%s.tgz", path, dist); - /* - * Passing TRUE as 3rd parm to get routine makes this a "probing" get, for which errors - * are not considered too significant. - */ - getsingle: - fp = mediaDevice->get(mediaDevice, buf, TRUE); - intr = check_for_interrupt(); - if (fp == (FILE *)IO_ERROR || intr) { /* Hard error, can't continue */ - if (intr) /* result of an interrupt */ - msgConfirm("Unable to open %s: User interrupt", buf); - else - msgConfirm("Unable to open %s: I/O error", buf); - mediaDevice->shutdown(mediaDevice); - if (!mediaDevice->init(mediaDevice)) { - status = FALSE; - goto done; - } - else - goto getsingle; - } - else if (fp > 0) { - char *dir = root_bias(me[i].my_dir); - - msgNotify("Extracting %s into %s directory...", dist, dir); - status = mediaExtractDist(dir, dist, fp); - fclose(fp); - goto done; - } - else - numchunks = 0; - } - - /* Fall through from "we got the attribute file, now get the pieces" step */ - if (!numchunks) - continue; - - if (isDebug()) - msgDebug("Attempting to extract distribution from %u chunks.\n", numchunks); - - total = 0; - (void)gettimeofday(&start, (struct timezone *)0); - - /* We have one or more chunks, initialize unpackers... */ - mediaExtractDistBegin(root_bias(me[i].my_dir), &fd2, &zpid, &cpid); - - /* And go for all the chunks */ - for (chunk = 0; chunk < numchunks; chunk++) { - int n, retval, last_msg; - char prompt[80]; - - last_msg = 0; - - getchunk: - snprintf(buf, sizeof buf, "%s/%s.%c%c", path, dist, (chunk / 26) + 'a', (chunk % 26) + 'a'); - if (isDebug()) - msgDebug("trying for piece %d of %d: %s\n", chunk + 1, numchunks, buf); - fp = mediaDevice->get(mediaDevice, buf, FALSE); - intr = check_for_interrupt(); - if (fp <= (FILE *)0 || intr) { - if (fp == (FILE *)0) - msgConfirm("Failed to find %s on this media. Reinitializing media.", buf); - else - msgConfirm("failed to retreive piece file %s.\n" - "%s: Reinitializing media.", buf, !intr ? "I/O error" : "User interrupt"); - mediaDevice->shutdown(mediaDevice); - if (!mediaDevice->init(mediaDevice)) - goto punt; - else - goto getchunk; - } - - snprintf(prompt, sizeof prompt, "Extracting %s into %s directory...", dist, root_bias(me[i].my_dir)); - dialog_gauge("Progress", prompt, 8, 15, 6, 50, (int)((float)(chunk + 1) / numchunks * 100)); - - while (1) { - int seconds; - - n = fread(buf, 1, BUFSIZ, fp); - if (check_for_interrupt()) { - msgConfirm("Media read error: User interrupt."); - fclose(fp); - goto punt; - } - else if (n <= 0) - break; - total += n; - - /* Print statistics about how we're doing */ - (void) gettimeofday(&stop, (struct timezone *)0); - stop.tv_sec = stop.tv_sec - start.tv_sec; - stop.tv_usec = stop.tv_usec - start.tv_usec; - if (stop.tv_usec < 0) - stop.tv_sec--, stop.tv_usec += 1000000; - seconds = stop.tv_sec + (stop.tv_usec / 1000000.0); - if (!seconds) - seconds = 1; - - if (seconds != last_msg) { - last_msg = seconds; - msgInfo("%10d bytes read from %s dist, chunk %2d of %2d @ %.1f KB/sec.", - total, dist, chunk + 1, numchunks, (total / seconds) / 1024.0); - } - retval = write(fd2, buf, n); - if (retval != n) { - fclose(fp); - dialog_clear_norefresh(); - msgConfirm("Write failure on transfer! (wrote %d bytes of %d bytes)", retval, n); - goto punt; - } - } - fclose(fp); - } - close(fd2); - status = mediaExtractDistEnd(zpid, cpid); - goto done; - - punt: - close(fd2); - mediaExtractDistEnd(zpid, cpid); - status = FALSE; - - done: - if (!status) { - if (me[i].my_dist) { - msgConfirm("Unable to transfer all components of the %s distribution.\n" - "If this is a CDROM install, it may be because export restrictions prohibit\n" - "DES code from being shipped from the U.S. Try to get this code from a\n" - "local FTP site instead!", me[i].my_name); - } - else { - status = msgYesNo("Unable to transfer the %s distribution from\n%s.\n\n" - "Do you want to try to retrieve it again?", - me[i].my_name, mediaDevice->name); - if (!status) - --i; - dialog_clear(); - } - } - /* If extract was successful, remove ourselves from further consideration */ - if (status) - *(me[i].my_mask) &= ~(me[i].my_bit); - else - continue; - } - sigaction(SIGINT, &old, NULL); /* Restore signal handler */ - restorescr(w); - return status; -} - -static void -printSelected(char *buf, int selected, Distribution *me, int *col) -{ - int i; - - /* Loop through to see if we're in our parent's plans */ - for (i = 0; me[i].my_name; i++) { - - /* If our bit isn't set, go to the next */ - if (!(me[i].my_bit & selected)) - continue; - - /* This is shorthand for "dist currently disabled" */ - if (!me[i].my_dir) - continue; - - *col += strlen(me[i].my_name); - if (*col > 50) { - *col = 0; - strcat(buf, "\n"); - } - sprintf(&buf[strlen(buf)], " %s", me[i].my_name); - /* Recurse if have a sub-distribution */ - if (me[i].my_dist) - printSelected(buf, *(me[i].my_mask), me[i].my_dist, col); - } -} - -int -distExtractAll(dialogMenuItem *self) -{ - int old_dists, retries = 0, status = DITEM_SUCCESS; - char buf[512]; - - /* paranoia */ - if (!Dists) { - if (!dmenuOpenSimple(&MenuSubDistributions, FALSE) || !Dists) - return DITEM_FAILURE | DITEM_RESTORE; - } - - if (!mediaVerify() || !mediaDevice->init(mediaDevice)) - return DITEM_FAILURE; - - old_dists = Dists; - distVerifyFlags(); - - dialog_clear_norefresh(); - msgNotify("Attempting to install all selected distributions.."); - - /* Try for 3 times around the loop, then give up. */ - while (Dists && ++retries < 3) - distExtract(NULL, DistTable); - - /* Only do bin fixup if bin dist was successfully extracted */ - if ((old_dists & DIST_BIN) && !(Dists & DIST_BIN)) - status |= installFixupBin(self); - if (old_dists & DIST_XF86) - status |= installFixupXFree(self); - - if (Dists) { - int col = 0; - - buf[0] = '\0'; - printSelected(buf, Dists, DistTable, &col); - dialog_clear_norefresh(); - msgConfirm("Couldn't extract the following distributions. This may\n" - "be because they were not available on the installation\n" - "media you've chosen:\n\n\t%s", buf); - status |= DITEM_RESTORE; - } - return status; -} diff --git a/usr.sbin/sysinstall/dist.h b/usr.sbin/sysinstall/dist.h deleted file mode 100644 index 19efb223faec..000000000000 --- a/usr.sbin/sysinstall/dist.h +++ /dev/null @@ -1,113 +0,0 @@ -#ifndef _DIST_H_INCLUDE -#define _DIST_H_INCLUDE - -/* Bitfields for distributions - hope we never have more than 32! :-) */ -#define DIST_BIN 0x0001 -#define DIST_GAMES 0x0002 -#define DIST_MANPAGES 0x0004 -#define DIST_PROFLIBS 0x0008 -#define DIST_DICT 0x0010 -#define DIST_SRC 0x0020 -#define DIST_DOC 0x0040 -#define DIST_INFO 0x0080 -#define DIST_COMPAT1X 0x0100 -#define DIST_COMPAT20 0x0200 -#define DIST_COMPAT21 0x0400 -#define DIST_XF86 0x0800 -#define DIST_DES 0x1000 -#define DIST_CATPAGES 0x2000 -#define DIST_PORTS 0x4000 -#define DIST_USR1 0x8000 -#define DIST_ALL 0x7FFF - -/* Canned distribution sets */ -#define _DIST_DEVELOPER \ - (DIST_BIN | DIST_DOC | DIST_MANPAGES | DIST_DICT | DIST_PROFLIBS | DIST_INFO | DIST_SRC) - -#define _DIST_USER \ - (DIST_BIN | DIST_DOC | DIST_MANPAGES | DIST_DICT) - -/* Subtypes for DES distribution */ -#define DIST_DES_DES 0x0001 -#define DIST_DES_SCRYPTO 0x0002 -#define DIST_DES_SSECURE 0x0004 -#define DIST_DES_KERBEROS 0x0008 -#define DIST_DES_SKERBEROS 0x0010 - -/* Subtypes for SRC distribution */ -#define DIST_SRC_BASE 0x00001 -#define DIST_SRC_CONTRIB 0x00002 -#define DIST_SRC_GNU 0x00004 -#define DIST_SRC_ETC 0x00008 -#define DIST_SRC_GAMES 0x00010 -#define DIST_SRC_INCLUDE 0x00020 -#define DIST_SRC_LIB 0x00040 -#define DIST_SRC_LIBEXEC 0x00080 -/* 0x00100 */ -#define DIST_SRC_RELEASE 0x00200 -#define DIST_SRC_SBIN 0x00400 -#define DIST_SRC_SHARE 0x00800 -#define DIST_SRC_SYS 0x01000 -#define DIST_SRC_UBIN 0x02000 -#define DIST_SRC_USBIN 0x04000 -#define DIST_SRC_BIN 0x08000 -#define DIST_SRC_SMAILCF 0x10000 -#define DIST_SRC_ALL 0xFFFF /* no SMAILCF, it's part of USBIN */ - -/* Subtypes for XFree86 distribution */ -#define DIST_XF86_BIN 0x0001 -#define DIST_XF86_CFG 0x0002 -#define DIST_XF86_DOC 0x0004 -#define DIST_XF86_HTML 0x0008 -#define DIST_XF86_LIB 0x0010 -#define DIST_XF86_LKIT98 0x0020 -#define DIST_XF86_LKIT 0x0040 -#define DIST_XF86_MAN 0x0080 -#define DIST_XF86_PROG 0x0100 -#define DIST_XF86_PS 0x0200 -#define DIST_XF86_SET 0x0400 -#define DIST_XF86_9SET 0x0800 -#define DIST_XF86_SRC 0x1000 -#define DIST_XF86_CSRC 0x2000 -#define DIST_XF86_MISC_ALL 0x3FFF -#define DIST_XF86_SERVER 0x8000 -#define DIST_XF86_SERVER_9MGA 0x0000001 -#define DIST_XF86_SERVER_9480 0x0000002 -#define DIST_XF86_SERVER_9EGC 0x0000004 -#define DIST_XF86_SERVER_9GA9 0x0000008 -#define DIST_XF86_SERVER_9GAN 0x0000010 -#define DIST_XF86_SERVER_9LPW 0x0000020 -#define DIST_XF86_SERVER_9NKV 0x0000040 -#define DIST_XF86_SERVER_9NS3 0x0000080 -#define DIST_XF86_SERVER_9SVG 0x0000100 -#define DIST_XF86_SERVER_9SPW 0x0000200 -#define DIST_XF86_SERVER_9TGU 0x0000400 -#define DIST_XF86_SERVER_9WEP 0x0000800 -#define DIST_XF86_SERVER_9WS 0x0001000 -#define DIST_XF86_SERVER_9WSN 0x0002000 -#define DIST_XF86_SERVER_8514 0x0004000 -#define DIST_XF86_SERVER_AGX 0x0008000 -#define DIST_XF86_SERVER_I128 0x0010000 -#define DIST_XF86_SERVER_MACH8 0x0020000 -#define DIST_XF86_SERVER_MACH32 0x0040000 -#define DIST_XF86_SERVER_MACH64 0x0080000 -#define DIST_XF86_SERVER_MONO 0x0100000 -#define DIST_XF86_SERVER_P9000 0x0200000 -#define DIST_XF86_SERVER_S3 0x0400000 -#define DIST_XF86_SERVER_S3V 0x0800000 -#define DIST_XF86_SERVER_SVGA 0x1000000 -#define DIST_XF86_SERVER_VGA16 0x2000000 -#define DIST_XF86_SERVER_W32 0x4000000 -#define DIST_XF86_SERVER_NEST 0x8000000 -#define DIST_XF86_SERVER_ALL 0xFFFFFFF -#define DIST_XF86_FONTS 0x10000 -#define DIST_XF86_FONTS_MISC 0x0001 -#define DIST_XF86_FONTS_100 0x0002 -#define DIST_XF86_FONTS_CYR 0x0004 -#define DIST_XF86_FONTS_SCALE 0x0008 -#define DIST_XF86_FONTS_NON 0x0010 -#define DIST_XF86_FONTS_SERVER 0x0020 -#define DIST_XF86_FONTS_ALL 0x003F -#define DIST_XF86_ALL 0x1FFFF - -#endif /* _DIST_H_INCLUDE */ diff --git a/usr.sbin/sysinstall/dmenu.c b/usr.sbin/sysinstall/dmenu.c deleted file mode 100644 index 11c369bdbdfa..000000000000 --- a/usr.sbin/sysinstall/dmenu.c +++ /dev/null @@ -1,308 +0,0 @@ -/* - * The new sysinstall program. - * - * This is probably the last attempt in the `sysinstall' line, the next - * generation being slated for what's essentially a complete rewrite. - * - * $Id: dmenu.c,v 1.36 1998/03/10 17:24:07 jkh Exp $ - * - * Copyright (c) 1995 - * Jordan Hubbard. 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, - * verbatim and that no modifications are made prior to this - * point in the file. - * 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 JORDAN HUBBARD ``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 JORDAN HUBBARD OR HIS PETS 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, LIFE 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. - * - */ - -#include "sysinstall.h" -#include <errno.h> - -#define MAX_MENU 15 - -static Boolean exited; - -int -dmenuDisplayFile(dialogMenuItem *tmp) -{ - systemDisplayHelp((char *)tmp->data); - return DITEM_SUCCESS | DITEM_RESTORE; -} - -int -dmenuSubmenu(dialogMenuItem *tmp) -{ - return (dmenuOpenSimple((DMenu *)(tmp->data), FALSE) ? DITEM_SUCCESS : DITEM_FAILURE) | - DITEM_RESTORE; -} - -int -dmenuSystemCommand(dialogMenuItem *self) -{ - WINDOW *w = NULL; /* Keep lint happy */ - - /* If aux is set, the command is known not to produce any screen-spoiling output */ - if (!self->aux) - w = savescr(); - systemExecute((char *)self->data); - if (!self->aux) - restorescr(w); - return DITEM_SUCCESS; -} - -int -dmenuSystemCommandBox(dialogMenuItem *tmp) -{ - use_helpfile(NULL); - use_helpline("Select OK to dismiss this dialog"); - dialog_prgbox(tmp->title, (char *)tmp->data, 22, 76, 1, 1); - return DITEM_SUCCESS | DITEM_RESTORE; -} - -int -dmenuExit(dialogMenuItem *tmp) -{ - exited = TRUE; - return DITEM_LEAVE_MENU; -} - -int -dmenuSetVariable(dialogMenuItem *tmp) -{ - variable_set((char *)tmp->data); - return DITEM_SUCCESS; -} - -int -dmenuSetVariables(dialogMenuItem *tmp) -{ - char *cp1, *cp2; - char *copy = strdup((char *)tmp->data); - - for (cp1 = copy; cp1 != NULL;) { - cp2 = index(cp1, ','); - if (cp2 != NULL) *cp2++ = '\0'; - variable_set(cp1); - cp1 = cp2; - } - free(copy); - return DITEM_SUCCESS; -} - -int -dmenuSetKmapVariable(dialogMenuItem *tmp) -{ - char *lang; - int err; - - variable_set((char *)tmp->data); - lang = variable_get(VAR_KEYMAP); - if (lang != NULL) - { - err = loadKeymap(lang); - if (err == -1) - msgConfirm("No appropriate keyboard map found, sorry."); - else if (err == -2) - msgConfirm("Error installing keyboard map, errno = %d.", errno); - } - return DITEM_SUCCESS; -} - -int -dmenuToggleVariable(dialogMenuItem *tmp) -{ - char *var; - - if (!(var = (char *)tmp->data)) { - msgConfirm("Incorrect data field for `%s'!", tmp->title); - return DITEM_FAILURE; - } - if (!variable_check(var)) - variable_set(var); - else - variable_unset(var); - return DITEM_SUCCESS; -} - -int -dmenuISetVariable(dialogMenuItem *tmp) -{ - char *ans, *var; - WINDOW *w = NULL; /* Keep lint happy */ - - if (!(var = (char *)tmp->data)) { - msgConfirm("Incorrect data field for `%s'!", tmp->title); - return DITEM_FAILURE; - } - w = savescr(); - ans = msgGetInput(variable_get(var), tmp->title); - restorescr(w); - if (!ans) - return DITEM_FAILURE; - else if (!*ans) - variable_unset(var); - else - variable_set2(var, ans); - return DITEM_SUCCESS; -} - -int -dmenuSetFlag(dialogMenuItem *tmp) -{ - if (*((unsigned int *)tmp->data) & tmp->aux) - *((unsigned int *)tmp->data) &= ~tmp->aux; - else - *((unsigned int *)tmp->data) |= tmp->aux; - return DITEM_SUCCESS; -} - -int -dmenuSetValue(dialogMenuItem *tmp) -{ - *((unsigned int *)tmp->data) = tmp->aux; - return DITEM_SUCCESS; -} - -/* Traverse menu but give user no control over positioning */ -Boolean -dmenuOpenSimple(DMenu *menu, Boolean buttons) -{ - int choice, scroll, curr, max; - - choice = scroll = curr = max = 0; - return dmenuOpen(menu, &choice, &scroll, &curr, &max, buttons); -} - -/* Work functions for the state hook */ -int -dmenuFlagCheck(dialogMenuItem *item) -{ - return (*((unsigned int *)item->data) & item->aux); -} - -int -dmenuVarCheck(dialogMenuItem *item) -{ - char *w; - - w = (char *)item->aux; - if (!w) - w = (char *)item->data; - return variable_check(w); -} - -int -dmenuVarsCheck(dialogMenuItem *item) -{ - int res, init; - char *w, *cp1, *cp2; - char *copy; - - w = (char *)item->aux; - if (!w) - w = (char *)item->data; - if (!w) - return FALSE; - - copy = strdup(w); - res = TRUE; - init = FALSE; - for (cp1 = copy; cp1 != NULL;) { - init = TRUE; - cp2 = index(cp1, ','); - if (cp2 != NULL) - *cp2++ = '\0'; - res = res && variable_check(cp1); - cp1 = cp2; - } - free(copy); - return res && init; -} - -int -dmenuRadioCheck(dialogMenuItem *item) -{ - return (*((unsigned int *)item->data) == item->aux); -} - -static int -menu_height(DMenu *menu, int n) -{ - int max; - char *t; - - max = MAX_MENU; - if (StatusLine > 24) - max += StatusLine - 24; - for (t = menu->prompt; *t; t++) { - if (*t == '\n') - --max; - } - return n > max ? max : n; -} - -/* Traverse over an internal menu */ -Boolean -dmenuOpen(DMenu *menu, int *choice, int *scroll, int *curr, int *max, Boolean buttons) -{ - int n, rval = 0; - dialogMenuItem *items; - - items = menu->items; - if (buttons) - items += 2; - /* Count up all the items */ - for (n = 0; items[n].title; n++); - - while (1) { - char buf[FILENAME_MAX]; - - /* Any helpful hints, put 'em up! */ - use_helpline(menu->helpline); - use_helpfile(systemHelpFile(menu->helpfile, buf)); - - /* Pop up that dialog! */ - dialog_clear_norefresh(); - if (menu->type & DMENU_NORMAL_TYPE) - rval = dialog_menu((u_char *)menu->title, (u_char *)menu->prompt, -1, -1, - menu_height(menu, n), -n, items, (char *)buttons, choice, scroll); - - else if (menu->type & DMENU_RADIO_TYPE) - rval = dialog_radiolist((u_char *)menu->title, (u_char *)menu->prompt, -1, -1, - menu_height(menu, n), -n, items, (char *)buttons); - - else if (menu->type & DMENU_CHECKLIST_TYPE) - rval = dialog_checklist((u_char *)menu->title, (u_char *)menu->prompt, -1, -1, - menu_height(menu, n), -n, items, (char *)buttons); - else - msgFatal("Menu: `%s' is of an unknown type\n", menu->title); - clearok(stdscr, TRUE); - if (exited) { - exited = FALSE; - return TRUE; - } - else if (rval) - return FALSE; - else if (menu->type & DMENU_SELECTION_RETURNS) - return TRUE; - } -} diff --git a/usr.sbin/sysinstall/doc.c b/usr.sbin/sysinstall/doc.c deleted file mode 100644 index 9d82f262863a..000000000000 --- a/usr.sbin/sysinstall/doc.c +++ /dev/null @@ -1,126 +0,0 @@ -/* - * The new sysinstall program. - * - * This is probably the last attempt in the `sysinstall' line, the next - * generation being slated for what's essentially a complete rewrite. - * - * $Id: doc.c,v 1.22 1997/02/07 04:25:53 jkh Exp $ - * - * Copyright (c) 1995 - * Jordan Hubbard. 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, - * verbatim and that no modifications are made prior to this - * point in the file. - * 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 JORDAN HUBBARD ``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 JORDAN HUBBARD OR HIS PETS 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, LIFE 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. - - * - */ - -#include "sysinstall.h" - -/* - * This is called from the main menu. Try to find a copy of Lynx from somewhere - * and fire it up on the first copy of the handbook we can find. - */ -int -docBrowser(dialogMenuItem *self) -{ - int ret; - char *browser = variable_get(VAR_BROWSER_PACKAGE); - - if (RunningAsInit && !strstr(variable_get(SYSTEM_STATE), "install")) { - msgConfirm("This option may only be used after the system is installed, sorry!"); - return DITEM_FAILURE; - } - - /* First, make sure we have whatever browser we've chosen is here */ - if (!package_exists(browser)) { - ret = package_add(browser); - if (DITEM_STATUS(ret) != DITEM_SUCCESS) { - msgConfirm("Unable to install the %s HTML browser package. You may\n" - "wish to verify that your media is configured correctly and\n" - "try again.", browser); - return ret; - } - } - - if (!file_executable(variable_get(VAR_BROWSER_BINARY))) { - if (!msgYesNo("Hmmm. The %s package claims to have installed, but I can't\n" - "find its binary in %s! You may wish to try a different\n" - "location to load the package from (go to Media menu) and see if that\n" - "makes a difference.\n\n" - "I suggest that we remove the version that was extracted since it does\n" - "not appear to be correct. Would you like me to do that now?", - browser, variable_get(VAR_BROWSER_BINARY))) - vsystem("pkg_delete %s %s", !strcmp(variable_get(VAR_CPIO_VERBOSITY), "high") ? "-v" : "", browser); - return DITEM_FAILURE | DITEM_RESTORE; - } - - /* Run browser on the appropriate doc */ - if (dmenuOpenSimple(&MenuHTMLDoc, FALSE)) - return DITEM_SUCCESS | DITEM_RESTORE; - else - return DITEM_FAILURE | DITEM_RESTORE; -} - -/* Try to show one of the documents requested from the HTML doc menu */ -int -docShowDocument(dialogMenuItem *self) -{ - char tmp[512], target[512]; - char *where = NULL; - char *browser = variable_get(VAR_BROWSER_BINARY); - char *str = self->prompt; - - if (!file_executable(browser)) { - msgConfirm("Can't find the browser in %s! Please ensure that it's\n" - "properly set in the Options editor.", browser); - return DITEM_FAILURE; - } - if (!strcmp(str, "Home")) - where = "http://www.freebsd.org"; - else if (!strcmp(str, "Other")) - where = msgGetInput("http://www.freebsd.org", "Please enter the URL of the location you wish to visit."); - else if (!strcmp(str, "FAQ")) { - strcpy(target, "/usr/share/doc/FAQ/FAQ.html"); - if (!file_readable(target)) - strcpy(target, "http://www.freebsd.org/FAQ"); - where = target; - } - else if (!strcmp(str, "Handbook")) { - strcpy(target, "/usr/share/doc/handbook/handbook.html"); - if (!file_readable(target)) - strcpy(target, "http://www.freebsd.org/handbook"); - where = target; - } - if (where) { - sprintf(tmp, "%s %s", browser, where); - dialog_clear(); - systemExecute(tmp); - return DITEM_SUCCESS | DITEM_RESTORE; - } - else { - msgConfirm("Hmmmmm! I can't seem to access the documentation you selected!\n" - "Have you loaded the bin distribution? Is your network connected?"); - return DITEM_FAILURE; - } -} diff --git a/usr.sbin/sysinstall/dos.c b/usr.sbin/sysinstall/dos.c deleted file mode 100644 index a11122ab811d..000000000000 --- a/usr.sbin/sysinstall/dos.c +++ /dev/null @@ -1,94 +0,0 @@ -/* - * The new sysinstall program. - * - * This is probably the last attempt in the `sysinstall' line, the next - * generation being slated to essentially a complete rewrite. - * - * $Id: dos.c,v 1.21 1998/10/28 02:18:08 jkh Exp $ - * - * Copyright (c) 1995 - * Jordan Hubbard. All rights reserved. - * Copyright (c) 1995 - * Gary J Palmer. 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, - * verbatim and that no modifications are made prior to this - * point in the file. - * 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 JORDAN HUBBARD ``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 JORDAN HUBBARD OR HIS PETS 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, LIFE 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. - * - */ - -#include "sysinstall.h" -#include <sys/stat.h> -#include <sys/errno.h> -#include <sys/param.h> -#include <sys/wait.h> -#include <unistd.h> -#include <fcntl.h> -#include <grp.h> -#define MSDOSFS -#include <sys/mount.h> -#include <msdosfs/msdosfsmount.h> -#undef MSDOSFS - -static Boolean DOSMounted; -static char mountpoint[] = "/dist"; - -Boolean -mediaInitDOS(Device *dev) -{ - struct msdosfs_args args; - - if (DOSMounted) - return TRUE; - - Mkdir(mountpoint); - memset(&args, 0, sizeof(args)); - args.fspec = dev->devname; - args.uid = args.gid = 0; - args.mask = 0777; - - if (mount("msdos", mountpoint, MNT_RDONLY, (caddr_t)&args) == -1) { - msgConfirm("Error mounting %s on %s: %s (%u)", args.fspec, mountpoint, strerror(errno), errno); - return FALSE; - } - DOSMounted = TRUE; - return TRUE; -} - -FILE * -mediaGetDOS(Device *dev, char *file, Boolean probe) -{ - return mediaGenericGet(mountpoint, file); -} - -void -mediaShutdownDOS(Device *dev) -{ - if (!DOSMounted) - return; - if (unmount(mountpoint, MNT_FORCE) != 0) - msgConfirm("Could not unmount the DOS partition from %s: %s", - mountpoint, strerror(errno)); - else - DOSMounted = FALSE; - return; -} diff --git a/usr.sbin/sysinstall/floppy.c b/usr.sbin/sysinstall/floppy.c deleted file mode 100644 index 6c1ab402abe4..000000000000 --- a/usr.sbin/sysinstall/floppy.c +++ /dev/null @@ -1,150 +0,0 @@ -/* - * The new sysinstall program. - * - * This is probably the last attempt in the `sysinstall' line, the next - * generation being slated to essentially a complete rewrite. - * - * $Id: floppy.c,v 1.30 1998/10/12 23:45:06 jkh Exp $ - * - * Copyright (c) 1995 - * Jordan Hubbard. All rights reserved. - * Copyright (c) 1995 - * Gary J Palmer. 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, - * verbatim and that no modifications are made prior to this - * point in the file. - * 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 JORDAN HUBBARD ``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 JORDAN HUBBARD OR HIS PETS 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, LIFE 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. - * - */ - -/* These routines deal with getting things off of floppy media */ - -#include "sysinstall.h" -#include <sys/fcntl.h> -#include <sys/stat.h> -#include <sys/errno.h> -#include <sys/param.h> -#include <sys/wait.h> -#include <unistd.h> -#include <grp.h> - -#define MSDOSFS -#include <sys/mount.h> -#include <msdosfs/msdosfsmount.h> -#undef MSDOSFS - -#include <ufs/ufs/ufsmount.h> -static Boolean floppyMounted; - -char *distWanted; -static char mountpoint[] = "/dist"; - -Boolean -mediaInitFloppy(Device *dev) -{ - struct msdosfs_args dosargs; - struct ufs_args u_args; - - if (floppyMounted) - return TRUE; - - if (Mkdir(mountpoint)) { - msgConfirm("Unable to make %s directory mountpoint for %s!", mountpoint, dev->devname); - return FALSE; - } - - msgDebug("Init floppy called for %s distribution.\n", distWanted ? distWanted : "some"); - - if (!variable_get(VAR_NONINTERACTIVE)) { - if (!distWanted) - msgConfirm("Please insert floppy in %s", dev->description); - else - msgConfirm("Please insert floppy containing %s in %s", - distWanted, dev->description); - } - - memset(&dosargs, 0, sizeof dosargs); - dosargs.fspec = dev->devname; - dosargs.uid = dosargs.gid = 0; - dosargs.mask = 0777; - - memset(&u_args, 0, sizeof(u_args)); - u_args.fspec = dev->devname; - - if (mount("msdos", mountpoint, MNT_RDONLY, (caddr_t)&dosargs) == -1) { - if (mount("ufs", mountpoint, MNT_RDONLY, (caddr_t)&u_args) == -1) { - msgConfirm("Error mounting floppy %s (%s) on %s : %s", - dev->name, dev->devname, mountpoint, strerror(errno)); - return FALSE; - } - } - floppyMounted = TRUE; - distWanted = NULL; - return TRUE; -} - -FILE * -mediaGetFloppy(Device *dev, char *file, Boolean probe) -{ - char buf[PATH_MAX]; - FILE *fp; - int nretries = 5; - - /* - * floppies don't use mediaGenericGet() because it's too expensive - * to speculatively open files on a floppy disk. Make user get it - * right or give up with floppies. - */ - snprintf(buf, PATH_MAX, "%s/%s", mountpoint, file); - if (!file_readable(buf)) { - if (probe) - return NULL; - else { - while (!file_readable(buf)) { - if (!--nretries) { - msgConfirm("GetFloppy: Failed to get %s after retries;\ngiving up.", buf); - return NULL; - } - distWanted = buf; - mediaShutdownFloppy(dev); - if (!mediaInitFloppy(dev)) - return NULL; - } - } - } - fp = fopen(buf, "r"); - return fp; -} - -void -mediaShutdownFloppy(Device *dev) -{ - if (floppyMounted) { - if (unmount(mountpoint, MNT_FORCE) != 0) - msgDebug("Umount of floppy on %s failed: %s (%d)\n", mountpoint, strerror(errno), errno); - else { - floppyMounted = FALSE; - if (!variable_get(VAR_NONINTERACTIVE)) - msgConfirm("You may remove the floppy from %s", dev->description); - } - } -} diff --git a/usr.sbin/sysinstall/ftp.c b/usr.sbin/sysinstall/ftp.c deleted file mode 100644 index 4f1e542e86b1..000000000000 --- a/usr.sbin/sysinstall/ftp.c +++ /dev/null @@ -1,253 +0,0 @@ -/* - * The new sysinstall program. - * - * This is probably the last attempt in the `sysinstall' line, the next - * generation being slated to essentially a complete rewrite. - * - * $Id: ftp.c,v 1.35 1998/01/28 04:42:38 jkh Exp $ - * - * Copyright (c) 1995 - * Jordan Hubbard. 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, - * verbatim and that no modifications are made prior to this - * point in the file. - * 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 JORDAN HUBBARD ``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 JORDAN HUBBARD OR HIS PETS 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, LIFE 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. - * - */ - -#include "sysinstall.h" -#include <sys/socket.h> -#include <netinet/in.h> -#include <arpa/inet.h> -#include <sys/param.h> -#include <sys/wait.h> -#include <netdb.h> -#include <pwd.h> -#include <ftpio.h> - -Boolean ftpInitted = FALSE; -static FILE *OpenConn; -int FtpPort; - -/* Brings up attached network device, if any - takes FTP device as arg */ -static Boolean -netUp(Device *dev) -{ - Device *netdev = (Device *)dev->private; - - if (netdev) - return netdev->init(netdev); - else - return TRUE; /* No net == happy net */ -} - -/* Brings down attached network device, if any - takes FTP device as arg */ -static void -netDown(Device *dev) -{ - Device *netdev = (Device *)dev->private; - - if (netdev) - netdev->shutdown(netdev); -} - -Boolean -mediaInitFTP(Device *dev) -{ - int i, code; - char *cp, *rel, *hostname, *dir; - char *user, *login_name, password[80]; - - if (ftpInitted) - return TRUE; - - if (OpenConn) { - fclose(OpenConn); - OpenConn = NULL; - } - - /* If we can't initialize the network, bag it! */ - if (!netUp(dev)) - return FALSE; - -try: - cp = variable_get(VAR_FTP_PATH); - if (!cp) { - if (DITEM_STATUS(mediaSetFTP(NULL)) == DITEM_FAILURE || (cp = variable_get(VAR_FTP_PATH)) == NULL) { - msgConfirm("Unable to get proper FTP path. FTP media not initialized."); - netDown(dev); - return FALSE; - } - } - - hostname = variable_get(VAR_FTP_HOST); - dir = variable_get(VAR_FTP_DIR); - if (!hostname || !dir) { - msgConfirm("Missing FTP host or directory specification. FTP media not initialized,"); - netDown(dev); - return FALSE; - } - user = variable_get(VAR_FTP_USER); - login_name = (!user || !*user) ? "anonymous" : user; - - if (variable_get(VAR_FTP_PASS)) - SAFE_STRCPY(password, variable_get(VAR_FTP_PASS)); - else if (RunningAsInit) - sprintf(password, "installer@%s", variable_get(VAR_HOSTNAME)); - else { - struct passwd *pw; - char *user; - - pw = getpwuid(getuid()); - user = pw ? pw->pw_name : "ftp"; - sprintf(password, "%s@%s", user, variable_get(VAR_HOSTNAME)); - } - msgNotify("Logging in to %s@%s..", login_name, hostname); - if ((OpenConn = ftpLogin(hostname, login_name, password, FtpPort, isDebug(), &code)) == NULL) { - msgConfirm("Couldn't open FTP connection to %s:\n %s.", hostname, ftpErrString(code)); - goto punt; - } - - ftpPassive(OpenConn, !strcmp(variable_get(VAR_FTP_STATE), "passive")); - ftpBinary(OpenConn); - if (dir && *dir != '\0') { - if ((i = ftpChdir(OpenConn, dir)) != 0) { - if (i == 550) - msgConfirm("No such directory ftp://%s/%s\n" - "please check your URL and try again.", hostname, dir); - else - msgConfirm("FTP chdir to ftp://%s/%s returned error status:\n %s.", hostname, dir, ftpErrString(i)); - goto punt; - } - } - - /* Give it a shot - can't hurt to try and zoom in if we can, unless the release is set to - __RELEASE or "none" which signifies that it's not set */ - rel = variable_get(VAR_RELNAME); - if (strcmp(rel, "__RELEASE") && strcmp(rel, "none")) - i = ftpChdir(OpenConn, rel); - else - i = 0; - if (i) { - if (!msgYesNo("Warning: Can't CD to `%s' distribution on this\n" - "FTP server. You may need to visit a different server for\n" - "the release you're trying to fetch or go to the Options\n" - "menu and to set the release name to explicitly match what's\n" - "available on %s (or set to \"none\").\n\n" - "Would you like to select another FTP server?", - rel, hostname)) { - variable_unset(VAR_FTP_PATH); - if (DITEM_STATUS(mediaSetFTP(NULL)) == DITEM_FAILURE) - goto punt; - else - goto try; - } - else - goto punt; - } - ftpInitted = TRUE; - return TRUE; - -punt: - ftpInitted = FALSE; - if (OpenConn != NULL) { - fclose(OpenConn); - OpenConn = NULL; - } - netDown(dev); - variable_unset(VAR_FTP_PATH); - return FALSE; -} - -FILE * -mediaGetFTP(Device *dev, char *file, Boolean probe) -{ - int nretries = 1; - FILE *fp; - char *try, buf[PATH_MAX]; - - if (!OpenConn) { - msgDebug("No FTP connection open, can't get file %s\n", file); - return NULL; - } - - try = file; - while ((fp = ftpGet(OpenConn, try, 0)) == NULL) { - int ftperr = ftpErrno(OpenConn); - - /* If a hard fail, try to "bounce" the ftp server to clear it */ - if (ftperr != 550) { - if (ftperr != 421) /* Timeout? */ - variable_unset(VAR_FTP_PATH); - /* If we can't re-initialize, just forget it */ - dev->shutdown(dev); - if (!dev->init(dev)) { - netDown(dev); - if (OpenConn) { - fclose(OpenConn); - OpenConn = NULL; - } - variable_unset(VAR_FTP_PATH); - return NULL; - } - } - else if (probe) - return NULL; - else { - /* Try some alternatives */ - switch (nretries++) { - case 1: - sprintf(buf, "releases/%s", file); - try = buf; - break; - - case 2: - sprintf(buf, "%s/%s", variable_get(VAR_RELNAME), file); - try = buf; - break; - - case 3: - sprintf(buf, "%s/releases/%s", variable_get(VAR_RELNAME), file); - try = buf; - break; - - case 4: - try = file; - break; - } - } - } - return fp; -} - -void -mediaShutdownFTP(Device *dev) -{ - if (!ftpInitted) - return; - - if (OpenConn != NULL) { - fclose(OpenConn); - OpenConn = NULL; - } - ftpInitted = FALSE; -} diff --git a/usr.sbin/sysinstall/globals.c b/usr.sbin/sysinstall/globals.c deleted file mode 100644 index 72aecb1c88e3..000000000000 --- a/usr.sbin/sysinstall/globals.c +++ /dev/null @@ -1,71 +0,0 @@ -/* - * The new sysinstall program. - * - * This is probably the last program in the `sysinstall' line - the next - * generation being essentially a complete rewrite. - * - * $Id: globals.c,v 1.18 1997/02/22 14:11:43 peter Exp $ - * - * Copyright (c) 1995 - * Jordan Hubbard. 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, - * verbatim and that no modifications are made prior to this - * point in the file. - * 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 JORDAN HUBBARD ``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 JORDAN HUBBARD OR HIS PETS 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, LIFE 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. - * - */ - -#include "sysinstall.h" - -/* - * Various global variables and an initialization hook to set them to - * whatever values we feel are appropriate. - */ - -int DebugFD; /* Where diagnostic output goes */ -Boolean Fake; /* Only pretend to be useful */ -Boolean RunningAsInit; /* Are we running as init? */ -Boolean DialogActive; /* Is libdialog initialized? */ -Boolean ColorDisplay; /* Are we on a color display? */ -Boolean OnVTY; /* Are we on a VTY? */ -Variable *VarHead; /* The head of the variable chain */ -Device *mediaDevice; /* Where we're installing from */ -int BootMgr; /* Which boot manager we're using */ -int StatusLine; /* Where to stick our status messages */ -jmp_buf BailOut; /* Beam me up, scotty! The natives are pissed! */ - -/* - * Yes, I know some of these are already automatically initialized as - * globals. I simply find it clearer to set everything explicitly. - */ -void -globalsInit(void) -{ - DebugFD = -1; - ColorDisplay = FALSE; - Fake = FALSE; - OnVTY = FALSE; - DialogActive = FALSE; - VarHead = NULL; - mediaDevice = NULL; - RunningAsInit = FALSE; -} diff --git a/usr.sbin/sysinstall/help/anonftp.hlp b/usr.sbin/sysinstall/help/anonftp.hlp deleted file mode 100644 index e90985e235fe..000000000000 --- a/usr.sbin/sysinstall/help/anonftp.hlp +++ /dev/null @@ -1,19 +0,0 @@ -This screen allows you to configure the anonymous FTP user. - -The following configuration values are editable: - -UID: The user ID you wish to assign to the anonymous FTP user. - All files uploaded will be owned by this ID. - -Group: Which group you wish the anonymous FTP user to be in. - -Comment: String describing this user in /etc/passwd - - -FTP Root Directory: - - Where files available for anonymous FTP will be kept. - -Upload subdirectory: - - Where files uploaded by anonymous FTP users will go. diff --git a/usr.sbin/sysinstall/help/configure.hlp b/usr.sbin/sysinstall/help/configure.hlp deleted file mode 100644 index 915172dae2ee..000000000000 --- a/usr.sbin/sysinstall/help/configure.hlp +++ /dev/null @@ -1,10 +0,0 @@ -This menu allows you to configure your system after the installation -process is complete. At the minimum, you should probably set the -system manager's password and the system time zone. - -For extra goodies like bash, emacs, Pascal, etc., you should look at -the Packages item in this menu. - -For setting the timezone after the system is installed, type -``tzsetup''. For more information on the overall general system -configuration, see the ``/etc/rc.conf'' file. diff --git a/usr.sbin/sysinstall/help/distributions.hlp b/usr.sbin/sysinstall/help/distributions.hlp deleted file mode 100644 index 1448f2c38e51..000000000000 --- a/usr.sbin/sysinstall/help/distributions.hlp +++ /dev/null @@ -1,62 +0,0 @@ -DISTRIBUTION INFORMATION ------------------------- - -An ``X-'' prefixed before a distribution set means that the XFree86 -3.3.2.3 base distribution, libraries, manual pages, SVGA server and a -set of default fonts will be selected in addition to the set itself. -If you select such a set, you will also be presented with a set of -menus for customizing the selections to your desired X Window System -setup. - -Any distribution may be further customized by selecting the `Custom' -item before leaving the menu. - -N.B. All references in this document to `complete source' mean the -complete source tree minus any legally encumbered cryptography code. - -The current "canned" installations are provided: - -Developer: Base ("bin") distribution, man pages, dictionary - files, profiling libraries and the complete source tree. - -Kern-Developer: As above, but with only kernel sources instead of - the complete source tree. - -User: The base distribution, man pages, dictionary files and - the FreeBSD 1.x, 2.0 and 2.1.x compatibility sets. - -Minimal: Only the base distribution. - -Everything: The base distribution, man pages, dictionary files, - profiling libraries, the FreeBSD 1.x and the FreeBSD 2.0 - compatibility libraries, the complete source tree, - games and your choice of XFree86 distribution components. - Note that the cryptography source code is NOT included - in this collection. You will need to select that by - hand if you're inside the United States. - -Custom: Allows you to create or modify your distribution set on - a piece-by-piece basis. - -Reset: Clear all currently selected distributions. - ---- - -ENCRYPTION SOFTWARE: --------------------- -You may notice that certain distributions, like "des" and "krb", -are marked "NOT FOR EXPORT!" This is because it's illegal to export -them from the United States (or any other country which considers -encryption technology to be on its restricted export list). Since -breaking this law only gets the _originating_ site (US!) in trouble, -please do not load these distributions from U.S. servers! We don't -like these restrictions any more than you do, but can't do much about -it (write your U.S. congress person!). - -A number of "foreign" servers do exist for the benefit of -non-U.S. sites, the official site being: - - ftp://ftp.internat.freebsd.org/pub/FreeBSD - -Please get all such export restricted software from there -if you are outside the U.S., thanks! diff --git a/usr.sbin/sysinstall/help/drives.hlp b/usr.sbin/sysinstall/help/drives.hlp deleted file mode 100644 index 946a1b211b7f..000000000000 --- a/usr.sbin/sysinstall/help/drives.hlp +++ /dev/null @@ -1,92 +0,0 @@ -Boot Manager Selection: ------------------------ - -If you wish to switch between multiple operating systems on your -machine, or if you are trying to install FreeBSD on a drive other than -your 1st drive, then you must install a boot manager. In the case -where you wish to boot off an alternate drive, it should also be noted -that you still need to install a boot manager on the FIRST drive! -Even if you do not intend to create a FreeBSD partition on that drive -(e.g. it's being wholly used by something else), the boot manager -still needs to reside on the first disk in order to function as a -"redirector" for the boot process. - -To do this, simply select your 1st drive in the drive selection menu -and when the partition editor comes up, don't make any changes - just -(Q)uit. At the boot manager menu which follows, select the first -option (install a boot manager) and then proceed to setup the other -drive(s) for FreeBSD as normal. - -It should also be noted that "operating systems" such as Windows 95 -will completely overwrite your boot manager without so much as a -polite "may I please destroy your boot manager?" prompt if you make -the mistake of installing them second. If this happens to you after -FreeBSD is already installed, all is not lost! Simply revisit your -FreeBSD distribution directory and look for a tools/ subdirectory, in -which you'll find "bootinst.exe" and "boot.bin". To reinstall, simply -say "bootinst boot.bin" while in the tools/ subdirectory. - - -If you see the boot manager displaying ``F?'' when you try to come up -for the first time and it refuses to change, no matter how often you -whap on the function key assigned to FreeBSD, then you have a geometry -mismatch problem and you should read the next section for important -information on how to prevent that exact problem from happening! - - -Geometry Translation / Sharing the disk(s) with another OS: ----------------------------------------------------------- - -If you are going to actually install some portion of FreeBSD on a -drive then PLEASE BE VERY CERTAIN that the Geometry reported in the -Partition Editor is the correct one for your drive and controller -combination! - -IDE drives often have a certain geometry set during the PC BIOS setup, -or (in the case of larger IDE drives) have their geometry "translated" -by either the IDE controller or a special boot-sector translation -utility such as that by OnTrack Systems. In these cases, knowing the -correct geometry gets even more complicated as it's not something you -can easily tell by looking at the drive or the PC BIOS setup. The -best way of verifying that your geometry is being correctly calculated -in such situations is to boot DOS (from the hard disk, not a floppy!) -and run the ``pfdisk'' utility provided in the tools/ subdirectory of -the FreeBSD CDROM or FTP site. It will report the geometry that DOS -sees, which is generally the correct one. - -If you have no DOS partition sharing the disk at all, then you may -find that you have better luck with Geometry detection if you create a -very small DOS partition first, before installing FreeBSD. Once -FreeBSD is installed you can always delete it again if you need the -space. - -It's actually not a bad idea (believe it or not) to have a small -bootable DOS partition on your FreeBSD machine anyway: Should the -machine become unstable or exhibit strange behavior at some point in -the future (which is not uncommon behavior for PC hardware!) you can -then at least use DOS for installing and running one of the -commercially available system diagnostic utilities. - -IMPORTANT NOTE: - -Any root partition you try to boot from must also reside below the -1024th cylinder. If you're using a translated geometry then this is -probably not a problem, but if you are using a native disk geometry -which exceeds 1024 cylinders then you could have a failure to boot if -you end up installing a root partition (or even just the kernel file -in a root partition) out past cylinder 1024. If you are trying to -share your first disk with FreeBSD and another OS which was installed -previously, you are particularly susceptible to this problem and should -check your disk addresses very carefully. - -If you find that you have insufficient space below cylinder 1024 to -make a root partition for FreeBSD (and again, this ONLY applies to the -root partition - once FreeBSD's kernel is loaded, it doesn't care -about the geometry issues) then you will probably need to install on a -completely different disk (see the boot manager section above) or -resize your existing partitions so that both operating systems can -have boot partitions below cylinder 1024. - -You may blame IBM for the limitations of a 10 bit cylinder address. -"No one will have a disk with more than 1024 cylinders." I'm sure -someone said. diff --git a/usr.sbin/sysinstall/help/fixit.hlp b/usr.sbin/sysinstall/help/fixit.hlp deleted file mode 100644 index e47394ecb08c..000000000000 --- a/usr.sbin/sysinstall/help/fixit.hlp +++ /dev/null @@ -1,7 +0,0 @@ -A special shell will be launched by this option with a fixit floppy -(or 2nd CDROM) mounted as /mnt2. This provides access to extra -commands under /mnt2 as well as a more complete set of device files in -/mnt2/dev. Some device operations, like fsck and disklabel, may -therefore require you to go to /mnt2/dev and use the entries there -rather than assuming that they will be present in the default /dev -(which came from the boot floppy and is very minimal). diff --git a/usr.sbin/sysinstall/help/html.hlp b/usr.sbin/sysinstall/help/html.hlp deleted file mode 100644 index f63dd30ed071..000000000000 --- a/usr.sbin/sysinstall/help/html.hlp +++ /dev/null @@ -1,19 +0,0 @@ -In this screen, you can jump to remote or local HTML -resources such as the FreeBSD Handbook & FreeBSD FAQ -(Frequently Asked Questions) documents located in: - - file:/usr/share/doc/ - -If you've loaded the doc distribution. - -The default browser package used is lynx (a text based -browser), which will be automatically loaded from the -installation media if it is available. You may change -the selection of browser & browser package to auto-load -by visiting the Options editor. - -In order to visit remote URLs, you naturally must have -some sort of working Internet connection. If you have not -yet brought up any network interfaces, please visit -the ``Networking'' item in the Configuration menu -before attempting to reference any http://.. style URLs. diff --git a/usr.sbin/sysinstall/help/media.hlp b/usr.sbin/sysinstall/help/media.hlp deleted file mode 100644 index 7fccd8ef2be9..000000000000 --- a/usr.sbin/sysinstall/help/media.hlp +++ /dev/null @@ -1,53 +0,0 @@ -You can install from the following types of media: - - CDROM requires one of the following supported CDROM drives: - Sony CDU 31/33A - Matushita/Panasonic "Sound Blaster" CDROM. - Mitsumi FX-001{A-D} (older non-IDE drives). - IDE CDROM - SCSI - Any standard SCSI CDROM drive hooked to - a supported controller (see Hardware Guide). - - - DOS A DOS primary partition with the required FreeBSD - distribution files copied onto it (e.g. C:\FREEBSD\) - - - FS Assuming a disk or partition with an existing - FreeBSD file system and distribution set on it, - get the distribution files from there. - - - Floppy Get distribution files from one or more DOS or UFS - formatted floppies. Such floppies are assumed to - contain the appropriate distribution pieces - see - ABOUT.TXT for more information about making floppy - distribution media. - - - FTP Get the distribution files from an anonymous ftp server - (you will be presented with a list). Please note that - there are also two ways of invoking FTP in either - "Active" and "Passive" mode. - - Active mode is the standard way of fetching files and - Passive mode is for use when you're behind a firewall or - some other security mechanism that blocks active FTP - connections. If you chose "other" in the FTP menu, please - also note that all paths are *relative* to the home - directory of the user being logged in as. By default, this - is the user "ftp" (anonymous ftp) but you may change this - in the Options screen. - - - NFS Get the distribution files from an NFS server somewhere - (make sure that permissions on the server allow this!). - If this install method hangs on you or refuses to work - properly, you may need to set some special options for - your NFS server. See the Options screen for more details. - - - Tape Extract distribution files from tape into a temporary - directory and install from there. If the tape was created - with blocksize other than 20, you may wish to change this - in the Options screen. diff --git a/usr.sbin/sysinstall/help/network_device.hlp b/usr.sbin/sysinstall/help/network_device.hlp deleted file mode 100644 index 3519c0ff80b2..000000000000 --- a/usr.sbin/sysinstall/help/network_device.hlp +++ /dev/null @@ -1,56 +0,0 @@ -You can do network installations over 3 types of communications links: - - Serial port: SLIP / PPP - Parallel port: PLIP (laplink cable) - Ethernet: A standard Ethernet controller (includes some - PCMCIA networking cards). - -SLIP support is rather primitive and limited primarily to directly -connected links, such as a serial cable running between a laptop -computer and another PC. The link must be hard-wired as the SLIP -installation doesn't currently offer a dialing capability (that -facility is offered by the PPP utility, which should be used in -preference to SLIP whenever possible). When you choose the SLIP -option, you'll be given the option of later editing the slattach -command before it's run on the serial line. It is expected that -you'll run slattach (or some equivalent command) on the other end of -the link at that time and bring up the line. FreeBSD will then -install itself at serial speeds of up to 115.2K/baud (the recommended -speed for a hardwired cable). - -If you're using a modem then PPP is almost certainly your only choice. -Make sure that you have your service provider's information handy as -you'll need to know it fairly early in the installation process. You -will need to know, at the minimum, your service provider's IP address -and possibly your own (though you can also leave it blank and allow -PPP to negotiate it with your ISP if your ISP supports such dynamic -negotiation). You will also need to know how to use the various "AT -commands" to dial the ISP with your particular brand of modem as the -PPP dialer provides only a very simple terminal emulator and has no -"modem capabilities database". - -If a hard-wired connection to another FreeBSD (2.0R or later) machine -is available, you might also consider installing over a "laplink" -parallel port cable. The data rate over the parallel port is much -higher than what is typically possible over a serial line, and speeds -of over 50KB/sec are not uncommon. - -Finally, for the fastest possible network installation, an Ethernet -adaptor is always a good choice! FreeBSD supports most common PC -Ethernet cards, a table of which is provided in the FreeBSD Hardware -Guide (see the Documentation menu on the boot floppy). If you are -using one of the supported PCMCIA Ethernet cards, also be sure that -it's plugged in _before_ the laptop is powered on! FreeBSD does not, -unfortunately, currently support "hot insertion" of PCMCIA cards. - -You will also need to know your IP address on the network, the -"netmask" value for your address class, and the name of your machine. -Your system administrator can tell you which values to use for your -particular network setup. If you will be referring to other hosts by -name rather than IP address, you'll also need a name server and -possibly the address of a gateway (if you're using PPP, it's your -provider's IP address) to use in talking to it. If you do not know -the answers to all or most of these questions then you should really -probably talk to your system administrator _first_ before trying this -type of installation! Choosing the wrong IP address on a busy network -will NOT make you popular with your systems administrator! :-) diff --git a/usr.sbin/sysinstall/help/options.hlp b/usr.sbin/sysinstall/help/options.hlp deleted file mode 100644 index dced21657b05..000000000000 --- a/usr.sbin/sysinstall/help/options.hlp +++ /dev/null @@ -1,124 +0,0 @@ -The following options may be set from this screen. Use the SPACE key -to toggle an option's value, Q to leave when you're done. - -NFS Secure: NFS server talks only on a secure port - - This is most commonly used when talking to Sun workstations, which - will not talk NFS over "non privileged" ports. - - -NFS Slow: User is using a slow PC or Ethernet card - - Use this option if you have a slow PC (386) or an Ethernet card - with poor performance being "fed" by NFS on a higher-performance - workstation. This will throttle the workstation back to prevent - the PC from becoming swamped with data. - - -Debugging: Turn on the extra debugging flag - - This turns on a lot of extra noise over on the second screen - (ALT-F2 to see it, ALT-F1 to switch back). If your installation - should fail for any reason, PLEASE turn this flag on when - attempting to reproduce the problem. It will provide a lot of - extra debugging at the failure point and may be very helpful to - the developers in tracking such problems down! - - -Yes To All: Assume "Yes" answers to all non-critical dialogs - - This flag should be used with caution. It will essentially - decide NOT to ask the user about any "boundary" conditions that - might not constitute actual errors but may be warnings indicative - of other problems. It's most useful to those who are doing unattended - installs. - - -FTP username: Specify username and password instead of anonymous. - - By default, the installation attempts to log in as the - anonymous user. If you wish to log in as someone else, - specify the username and password with this option. - - -Install Root: Specify some directory other than / as your "root". - - This should be left as / unless you have a really good reason to - change it. One good reason might be if you were installing to a - disk other than your own, as might happen if you needed to prepare a - disk for another machine which couldn't load FreeBSD directly - for some reason. - - Note: If you set this option, you will only be able to install - packages if the bin distribution is also installed (usually - the case anyway) since /usr/sbin/pkg_add will otherwise not be - found after the chroot() call. - - -Editor: Specify which screen editor to use. - - At various points during the installation it may be necessary - to customize some text file, at which point the user will be - thrown unceremoniously into a screen editor. A relatively - simplistic editor which shows its command set on-screen is - selected by default, but UNIX purists may wish to change this - setting to /usr/bin/vi - - -Tape Blocksize: Specify block size in 512 byte blocks of tape. - - This defaults to 20 blocks, which should work with most - tape drive + tar combinations. It may not allow your particular - drive to win any records for speed, however, and the more - adventurous among you might try experimenting with larger sizes. - - -Extract Detail: How to show filenames on debug screen as they're extracted. - - While a distribution is being extracted, the default detail level - of "high" will show the full file names as they're extracted. - If you would prefer a more terse form for this, namely dots, select - the "medium" detail level. If you want nothing to be printed - on the debugging screen during extraction, select "low". - - -Release Name: Which release to attempt to load from installation media. - - You should only change this option if you're really sure you know - what you are doing! This will change the release name used by - sysinstall when fetching components of any distributions, and - is a useful way of using a more recent installation boot floppy - with an older release (say, on CDROM). - - -Browser Package: Which package to load for an HTML browser. - - By default, this is set to lynx but may also be set to any other - text capable HTML browser for which a package exists. If you set this - to an X based browser, you will not be able to use it if you're running - in text mode! :) - - -Browser Exec: Which binary to run for the HTML browser. - - The full pathname to the main executable in Browser Package - - -Media Type: Which media type is being used. - - This is mostly informational and indicates which media type (if any) - was last selected in the Media menu. It's also a convenient short-cut - to the media menu itself. - - -Package Temp: Where package temporary files should go - - Some packages, like emacs, can use a LOT of temporary space - up to - 20 or 30MB. If you are going to configure a small / directory (and - hence a small /tmp) then you may wish to set this to point at another - location (say, /usr/tmp). - - -Use Defaults: Use default values. - - Reset all options back to their default values. diff --git a/usr.sbin/sysinstall/help/partition.hlp b/usr.sbin/sysinstall/help/partition.hlp deleted file mode 100644 index 37520bfbaefe..000000000000 --- a/usr.sbin/sysinstall/help/partition.hlp +++ /dev/null @@ -1,144 +0,0 @@ -This is the FreeBSD DiskLabel Editor. - -NOTE: If you're entering this editor from the update procedure then -you probably shouldn't (C)reate anything at all but rather use only -the (M)ount command to check and mount existing partitions for -upgrading. - -If you would like the label editor to do most of the following for -you, simply type `A' for automatic partitioning of the disk. - -If you wish to create partitions manually you may do so by moving the -highlighted selection bar with the arrow keys over the FreeBSD -partition(s) displayed at the top of the screen. Typing (C)reate -while a partition with available free space is selected will allow you -to create a BSD partition inside of it using some or all of its -available space. - -Typing (M)ount over an existing partition entry (displayed in the -middle of the screen) will allow you to set a mount point for it -without initializing it. If you want it initialized, use the (T)oggle -command to flip the Newfs flag. When Newfs is set to "Y", the -filesystem in question will be ERASED and rebuilt from scratch! - - -You should use this editor to create at least the following -filesystems: - - Name Purpose Min Size? Optional? - ---- ------- --------- --------- - / Root filesystem 20MB No - swap Swap space 2 * MEM No - /usr System & user files 80MB or more Yes - -Note: If you do not create a /usr filesystem then your / filesystem -will need to be bigger - at least 100MB. This is not recommended as -any media errors that may occur during disk I/O to user files will -corrupt the filesystem containing vital system files as well. It is -for this reason that / is generally kept on its own filesystem, where -it should be considered essentially "read only" in your administration -of it. - -Swap space is a little tricker, and the rule of "2 * MEM" is simply a -best-guess approximation and not necessarily accurate for your -intended usage of the system. If you intend to use the system heavily -in a server or multi-user application, you may be well advised to -increase this size. You may also create swap space on multiple drives -for a larger "total" swap and this is, in fact, recommended if you -have multiple, fast drives for which such load-balancing can only help -overall I/O performance. - -The /usr filesystem should be sized according to what kind of -distributions you're trying to load and how many packages you intend -to install in locations like /usr/local. You can also make /usr/local -a separate filesystem if you don't want to risk filling up your /usr -by mistake. - -Another useful filesystem to create is /var, which contains mail, news -printer spool files and other temporary items. It is a popular -candidate for a separate partition and should be sized according to -your estimates of the amount of mail, news or spooled print jobs that -may be stored there. - -WARNING: If you do not create a separate filesystem for /var, space -for such files will be allocated out of the root (/) filesystem -instead. You may therefore wish to make the / partition bigger if you -expect a lot of mail or news and do not want to make /var its own -partition. - -If you're new to this installation, you might also want to read the -following explanation of how FreeBSD's new "slice" paradigm for -looking at disk storage works: - - -In FreeBSD's new system, a device name can be broken up into up to 3 -parts. Take a typical name like ``/dev/da0s1a'': - - The first three characters represent the drive name. If we had - a system with two SCSI drives on it then we'd see /dev/da0 and - /dev/da1 as the device entries representing the entire drives. - - Next you have the "slice" (or "FDISK Partition") number, - as seen in the Partition Editor. Assuming that our da0 - contained two slices, a FreeBSD slice and a DOS slice, that - would give us /dev/da0s1 and /dev/da0s2 as device entries pointing - to the entire slices. - - Next, if a slice is a FreeBSD slice, you can have a number of - (confusingly named) "partitions" inside of it. - - These partitions are where various filesystems or swap areas live, - and using our hypothetical two-SCSI-disk machine again, we might - have something like the following layout on da0: - - Name Mountpoint - ---- ---------- - da0s1a / - da0s1b <swap space> - da0s1e /usr - - Because of historical convention, there is also a short-cut, - or "compatibility slice", that is maintained for easy access - to the *first* FreeBSD slice on a disk. This gives some - backwards compatibility to utilities that still may not know - how to deal with the new slice scheme. - - The compatibility slice names for our filesystem above would - also look like: - - Name Mountpoint - ---- ---------- - da0a / - da0b <swap space> - da0e /usr - - Again, let it be noted: FreeBSD automatically maps the - compatibility slice to the first FreeBSD slice it finds - (in this case, da0s1). You may have multiple FreeBSD slices on a - drive, but only the first one will be mapped to the compatibility - slice! - - The compatibility slice has essentially been phased out, but - it's important to be aware of when looking at or upgrading - older systems. - -Once you understand all this, then the purpose of the label editor -becomes fairly clear: You're carving up the FreeBSD slices displayed -at the top of the screen into smaller pieces, which are displayed in -the middle of the screen, and then assigning FreeBSD file system names -(mount points) to them. - -You can also use the label editor to mount existing partitions/slices -into your filesystem hierarchy, as is frequently done for DOS FAT -slices. For FreeBSD partitions, you can also toggle the "newfs" state -so that the partitions are either (re)created from scratch or simply -checked and mounted (the contents are preserved). - -When you're done, type `Q' to exit. - -No actual changes will be made to the disk until you (C)ommit from the -Install menu or (W)rite directly from this one. You're working with -what is essentially a copy of the disk label(s), both here and in the -FDISK Partition Editor, and the actual on-disk labels won't be -affected by any changes you make until you explicitly say so. - diff --git a/usr.sbin/sysinstall/help/register.hlp b/usr.sbin/sysinstall/help/register.hlp deleted file mode 100644 index 3f360c3254ea..000000000000 --- a/usr.sbin/sysinstall/help/register.hlp +++ /dev/null @@ -1,76 +0,0 @@ -This screen allows you to register yourself with the FreeBSD Project's -user counter & statistics database. - -** IT IS VERY IMPORTANT THAT YOU DO THIS! ** - -Believe me, I hate filling out forms as much as anyone, and most -people's understandable reaction to a registration form is to say "Eh, -what's this? They want to send me junk mail and then on top of that -they expect me to go to *extra* trouble in order to make it easy for -them?! Forget it!" - -This is not that kind of registration, and I strongly urge you to take -just a few minutes to read this and find out how much the simple act -of registering can help both you and FreeBSD. - -1. It is very much in your best interest, as a FreeBSD user, to stand - up and be counted so that various software vendors will begin to - take you and your operating system seriously. There are numerous - ISVs (Independent Software Vendors) who would be only too happy - to port the kinds of applications that many FreeBSD users are - currently screaming for (everything from spreadsheets and word - processing packages to games) if they only had some idea that it - might be worth the trouble. The only way to convince the ISVs that - FreeBSD is worth their trouble is to show them how many users - we have, and to do that we need your registration! At this time - we literally do not know how many users FreeBSD has, and that's - hardly helpful when you're trying to convince someone to port - software to it. - - -2. We will not send you *anything* you do not ask for. Some people - are genuinely interested in new product announcements for FreeBSD - or want to hear about security issues & other important advisories - as they come up, and for such people we've added registration - options for selecting various types of additional material they - might be interested in receiving as a side-effect of registration. - - The default behavior is to NOT put the user on any special mailing - lists or provide their names in mailing list data sent to - (carefully screened) FreeBSD product advertisers - all of that must - be specifically requested during the registration. - -Most fields in the form are fairly self-explanatory. At the minimum, -you should enter your first and last name as well as your email -address so that we can weed obvious duplicates from the counter. You -will NOT be sent any mail at this address unless you also sign up for -one of the additional notification services, and it's only used to -provide us with a way of differentiating "John Smith <smith@foo.org>" -from "John Smith <jsm@bar.com>" in the simple, no-frills registration -case. If you do not have an email address, some sort of postal -address will serve the same purpose. - -If you also wish to receive the FreeBSD Newsletter, published and -distributed free of charge by Walnut Creek CDROM in printed form, -then you must specify some sort of postal address. Likewise, if you -elect to receive notification on the email version then you should -specify a valid Email address. Back-issues of the FreeBSD newsletter -are available at http://ftp.freebsd.org/pub/FreeBSD/newsletter/ - -Should you wish to unsubscribe to the FreeBSD Newsletter or otherwise -de-register yourself at a later time, you can simply send mail to -register-request@freebsd.org. If you subscribe to the announce -mailing list (and it's a good idea) then you can modify your -subscription at any time by sending mail to majordomo@freebsd.org - - -Your cooperation with this new registration service is greatly -appreciated, and by taking just 5 minutes to fill this out now you -will be helping us to gather data which will greatly assist FreeBSD in -firmly establishing a position as a serious UN*X operating system -contender. - -Regards, - - Jordan Hubbard, - FreeBSD PR Officer diff --git a/usr.sbin/sysinstall/help/shortcuts.hlp b/usr.sbin/sysinstall/help/shortcuts.hlp deleted file mode 100644 index 503a2a770cbc..000000000000 --- a/usr.sbin/sysinstall/help/shortcuts.hlp +++ /dev/null @@ -1,116 +0,0 @@ -/stand/sysinstall now supports command-line "shortcuts" which can -often replace outdated commands, like pkg_manage. Multiple commands -can be invoked in sequence, and variables may be set on-the-fly to -customize the installation program's behavior in various ways. - -Syntax: - -/stand/sysinstall [var=value ..] [command ..] - -Where "var" can be one or more of: - -blanktime Screen blank time setting in seconds -bootManager Select boot manager: booteasy, standard or none -browserBinary Which doc browser to use (default: lynx) -browserPackage Which package to get browser from (default: lynx) -cpioVerbose How verbose to be with cpio: high, medium or low -debug Extra debugging? -disk Which disk to operate on (wd0, da0, etc). -domainname Domain name -editor Which screen editor to use -ifconfig_<iface> For each <iface> in network_devices -ftpDirectory Root of the FreeBSD distribution tree on FTP server -ftpOnError Set to retry or abort -ftpPass Which password to use when logging into FTP server -ftp Which FTP site/dir to use (URL ftp://site/dir/..) -ftpPort Which FTP port to use (default: 21) -ftpRetryCount How many times to retry a fetch operation -ftpUser Which username to use when logging into FTP server -ftpHost Which FTP hostname to use (overrides ftp variable) -gated Use gated instead of routed -defaultrouter IP address of default route -geometry Geometry to use for selected disk ("cyl/hd/sec") -hostname Fully qualified domain name for host. -network_interfaces Which network interfaces to configure -ipaddr IP address for this host's primary interface -nameserver IP address of name server -netmask Netmask for this host's primary interface -nfs Full host:/path/ specification to NFS media -nfsHost Host portion of nfs path -nfsSecure Use NFS secure mount (-P flag) -nfs_server Configure this machine as an NFS server -noConfirm Don't ask for confirmation on non-fatal errors -ntpDate Which ntp clock synchronization server to use -pcnfsd Install the PCNFSD package -ports Path to the ports collection -releaseName Which FreeBSD release to install -rootSize Size of the root partition to create for Auto -routedflags Which flags to pass to routed, if enabled -serialSpeed How fast to run a SLIP/PPP connection -slowEthernetCard PC ethernet card is uncommonly slow -swapSize Size of the swap partition to create for Auto -tapeBlocksize Tape size in blocks -ufs Full path to UFS media directory -usrSize Size of the /usr partition to create for Auto -varSize Size of the /var partition to create for Auto - -And "command" can be one or more of: - -addUser Add a new user to the system -addGroup Add a new group to the system -configAnonFTP Configure system for anonymous FTP -configApache Configure and install the Apache WEB server -configGated Configure and install gated -configNFSServer Configure host as an NFS server -configSamba Configure and install Samba -configPackages Browse / install packages -diskPartitionEditor Partition a new or existing disk -diskPartitionWrite Write out any changed partition information -diskLabelEditor Label/Newfs/Mount new or existing filesystems -diskLabelCommit Write out any changed label information -distReset Reset distribution information -distSetDeveloper Select developer distribution -distSetXDeveloper Select X developer distribution -distSetKernDeveloper Select kernel developer distribution -distSetUser Select user distribution -distSetXUser Select X user distribution -distSetMinimum Select minimal distribution -distSetEverything Select all distributions -distSetDES Select DES sub-distributions -distSetSrc Select source sub-distributions -distSetXF86 Select XFree86 sub-distributions -distExtractAll Extract all selected distributions -docBrowser Browse documentation -installCommit Commit any pending installation operations -installExpress Express installation -installUpgrade Upgrade installation -installFixup Go into "fixit" mode -mediaSetCDROM Select CDROM media -mediaSetFloppy Select floppy media -mediaSetDOS Select DOS media -mediaSetTape Select tape media -mediaSetFTP Select FTP media -mediaSetFTPPassive Select FTP media in passive mode -mediaSetUFS Select UFS media -mediaSetNFS Select NFS media -mediaSetFtpUserPass Prompt for FTP username and password -mediaSetCPIOVerbosity Prompt for CPIO verbosity -mediaGetType Prompt for media type -optionsEditor Go to options editor -register Go to registration editor. - -Examples: - -/stand/sysinstall mediaSetFTP configPackages - -Selects an FTP site and then goes to the package configuration menu. - - -/stand/sysinstall disk=da0 diskPartitionEditor - -Invokes the disk partition editor on disk da0. - - -If /stand/sysinstall is linked to another filename, say -`/usr/local/bin/configPackages', then the basename will be used -as an implicit command name. diff --git a/usr.sbin/sysinstall/help/slice.hlp b/usr.sbin/sysinstall/help/slice.hlp deleted file mode 100644 index 33280a4349b9..000000000000 --- a/usr.sbin/sysinstall/help/slice.hlp +++ /dev/null @@ -1,59 +0,0 @@ -This is the Main Slice (``FDISK'' or PC-style Partition) Editor. - -Possible commands are printed at the bottom and the Master Boot Record -contents are shown at the top. You can move up and down with the -arrow keys and (C)reate a new slice whenever the highlighted -selection bar is over a slice whose type is marked as "unused." - -You are expected to leave this screen with at least one slice -marked "FreeBSD." Note that unlike Linux, you don't need to create -multiple FreeBSD FDISK partition entries for different things like -swap, file systems, etc. The usual convention is to create ONE -FreeBSD slice (FDISK partition) per drive and then subsection this slice -into swap and file systems with the Label editor. - -No actual changes will be made to the disk until you (C)ommit from the -Install menu or use the (W)rite option here! You're working with what -is essentially a copy of the disk label(s), both here and in the Label -Editor. - -If you want to use the entire disk for FreeBSD, type `A'. You'll be -asked whether or not you wish to keep the disk (potentially) compatible -with other operating systems, i.e. the information in the FDISK table -should be kept valid. If you select the default of `Yes', slices will be -aligned to fictitious cylinder boundaries and space will be reserved -in front of the FreeBSD slice for a [future] possible boot manager. - -For the truly dedicated disk case, you can select `No' at the -compatibility prompt. In that case, all BIOS geometry considerations -will no longer be in effect and you can safely ignore any -``The detected geometry is invalid'' warning messages you may later -see. It is also not necessary in this case to set a slice bootable -or install an MBR boot manager as both things are then irrelevant. - -The FreeBSD slice will start at absolute sector 0 of the disk (so that -FreeBSD's disk label is identical to the Master Boot Record) and -extend to the very last sector of the disk medium. Needless to say, -such a disk cannot have any sort of a boot manager, `disk manager', -or anything else that has to interact with the BIOS. This option is -therefore only considered safe for SCSI disks and most IDE disks and -is primarily intended for people who are going to set up a dedicated -FreeBSD server or workstation, not a typical `home PC'. - -The flags field has the following legend: - - '=' -- This slice is properly aligned. - '>' -- This slice doesn't end before cylinder 1024 - 'R' -- This slice contains the root (/) filesystem - 'B' -- Slice employs BAD144 bad-spot handling - 'C' -- This is the FreeBSD 2.0-compatibility slice (default) - 'A' -- This slice is marked active. - -If you select a slice for Bad144 handling, it will be scanned -for bad blocks before any new filesystems are made on it. - -If no slice is marked Active, you will need to either install -a Boot Manager (the option for which will be presented later in the -installation) or set one Active before leaving this screen. - -To leave the slice editor, type `Q'. diff --git a/usr.sbin/sysinstall/help/tcp.hlp b/usr.sbin/sysinstall/help/tcp.hlp deleted file mode 100644 index d79cf2732bc1..000000000000 --- a/usr.sbin/sysinstall/help/tcp.hlp +++ /dev/null @@ -1,34 +0,0 @@ -This screen allows you to set up your general network parameters -(hostname, domain name, DNS server, etc) as well as the settings for a -given interface (which was selected from the menu before this screen). - -PLIP/SLIP users - please read through to the end of this doc! - -You can move through the fields with the TAB, BACK-TAB and ENTER -keys. To edit a field, use DELETE or BACKSPACE. You may also use ^A -(control-A) to go to the beginning of the line, ^E (control-E) to go -to the end, ^F (control-F) to go forward a character, ^B (control-B) -to go backward one character, ^D (control-D) to delete the character -under the cursor and ^K (control-K) to delete to the end of the line. -Basically, the standard EMACS motion sequences. - -The "Extra options to ifconfig" field is kind of special (read: a -hack :-): - -If you're running SLIP or PLIP, you also need to use it for specifying -the remote end of the link (simply type the foreign IP address in). -In the specific case where you're running PLIP with a Linux host peer -rather than a FreeBSD one, you also must add the "-link0" flag after the -foreign address. - - -If you're dealing with an ethernet adaptor with multiple media -connectors (e.g. AUI, 10BT, 10B2, etc), you can use this field to -specify which one to use. The following strings are recognized: - - "media 10base5/AUI" - Select the AUI port. - "media 10baseT/UTP" - Select the twisted pair port. - "media 10base2/BNC" - Select the BNC connector. - "media 100baseTX" - Select 100BaseT on a 100/10 dual adaptor. - -When you're done with this form, select OK. diff --git a/usr.sbin/sysinstall/help/usage.hlp b/usr.sbin/sysinstall/help/usage.hlp deleted file mode 100644 index 4d9452031e0a..000000000000 --- a/usr.sbin/sysinstall/help/usage.hlp +++ /dev/null @@ -1,68 +0,0 @@ -HOW TO USE THIS SYSTEM -====================== - -[press the PageDown key to go to the next screen when you finish - reading this one] - -The following keys are recognized in most of the dialogs you'll -encounter during this installation: - -KEY ACTION ---- ------ -SPACE Select or toggle the current item. -ENTER Finish with a menu or item. -UP ARROW Move to previous item (or up, in a text display box). -DOWN ARROW Move to next item (or down, in a text display box). -TAB Move to next item or group. -RIGHT ARROW Move to next item or group (same as TAB). -SHIFT-TAB Move to previous item or group. -LEFT ARROW Move to previous item or group (same as SHIFT-TAB). -PAGE UP In text display boxes, scrolls up one page. -PAGE DOWN In text display boxes, scrolls down one page. -F1 Display associated help text. - -If you see small "^(-)" or "v(+)" symbols at the edges of a menu, it -means that there are more items above or below the current one that -aren't being shown (due to insufficient screen space). In text -display boxes, the amount of text above the current point will be -displayed as a percentage in the lower right corner. Using the -Up/Down arrow keys will cause the object to scroll by line. The -PageUp and PageDown keys will scroll by entire screens. - -Selecting OK in a menu will confirm whatever action it's controlling. -Selecting Cancel will cancel the operation and generally return you to -the previous menu. Note also that "checkbox" menus use SPACE to select -their items, not ENTER! Pressing ENTER will leave the menu with either -an OK or Cancel status, depending on which button at the bottom is -selected, and is probably not what you wanted to do if still selecting -options. Remember the spacebar! - -Most screens obey the Help key (F1) - USE IT! It generally offers useful -context-specific hints on what to do at each stage of the installation, -and if you're at all unsure about what to do at a given stage in the -installation, hit F1! - - -SPECIAL FEATURES: -================= - -It is possible to select a menu item by typing the first character of -its name, if unique. This will generally be an item number. - -The console driver contains a scroll-back buffer for reviewing things -that may have scrolled off the screen. To use scroll-back, press the -"Scroll Lock" key on your keyboard and use the arrow or Page Up/Page -Down keys to move through the saved text. To leave scroll-back mode, -press the Scroll Lock key again. This feature is most useful for -reading back through your boot messages (go ahead, try it now!) though -it's also useful when dealing with sub-shells or other "wizard modes" -that don't use menus and tend to scroll their output off the top of -the screen. - -FreeBSD also supports multiple "virtual consoles" which you can use to -in order to have several active sessions at once. Use ALT-F<n> to -switch between screens, where `F<n>' is the function key corresponding -to the screen you wish to see. By default, the system comes with 3 -virtual consoles enabled - you can enable more by editing the -/etc/ttys file and turning the "off" field to "on" in the relevant vty -entries (up to 12). diff --git a/usr.sbin/sysinstall/help/usermgmt.hlp b/usr.sbin/sysinstall/help/usermgmt.hlp deleted file mode 100644 index 8a2664dccd05..000000000000 --- a/usr.sbin/sysinstall/help/usermgmt.hlp +++ /dev/null @@ -1,89 +0,0 @@ -These screens allow you to add groups and users to your system. - -You can move through the fields with the TAB, BACK-TAB and ENTER -keys. To edit a field, use DELETE or BACKSPACE. You may also use ^A -(control-A) to go to the beginning of the line, ^E (control-E) to go -to the end, ^F (control-F) to go forward a character, ^B (control-B) -to go backward one character, ^D (control-D) to delete the character -under the cursor and ^K (control-K) to delete to the end of the line. -Basically, the standard EMACS motion sequences. - -When you're done with this form, select OK. - -Many of the settings get reasonable defaults if you leave them blank. -The first time you have entered the name of the new group or user, the -system will show you what it would chose for most of these fields. -You are free to change them, of course. - - -User groups -=========== - -It's certainly almost generally a good idea to first create a new -group for your users. Common names for such a group are "users", or -even simply "other". Group names are used to control file access -permissions for users that belong to the same group. Several group -names are already used for system files. - -The numerical user or group IDs are often nothing you want to care for -explicitly. If you don't fill in these fields, the system will chose -reasonable defaults. However, these numbers (rather than the -associated names) are what the operating system actually uses to -distinguish users and groups -- hence they should normally be unique -to each person or group, respectively. - -(The initial membership list for a new group is currently -unimplemented, sorry.) - - -Users -===== - -The user's login ID is a short (8 characters) alphanumeric ID the user -must enter when logging into the system. It's often the initial -letters of the user's name, and commonly used in lower case. It's -also the local mail name for this user (though it's possible to also -setup more descriptive mail alias names later). - -The user's login group determines which group access rights the user -will initially get when logging in. If an additional list of groups is -provided where the user will become a member of, (s)he will also be -able to access files of those groups later without providing any -additional password etc. Except for the "wheel" case mentioned below, -the additional group membership list should normally not contain the -login group again. - -The user's password can also be set here, and should be chosen with -care - 6 or more characters, intermixing punctuation and numerics, and -*not* a word from the dictionary or related to the username is a good -password choice. - -Some of the system's groups have a special meaning. In particular, -members of group "wheel" are the only people who are later allowed to -become superuser using the command su(1). So if you're going to add a -new user who should later perform administrative tasks, don't forget -to add him to this group! (Well, ``he'' will most likely be yourself -in the very first place. :) - -Also, members of group "operator" will by default get permissions for -minor administrative operations, like performing system backups, or -shutting down the system -- without first becoming superuser! So, -take care with adding people to this group. - -The ``full name'' field serves as a comment only. It is also used by -mail front ends to determine the real name of the user, hence you -should actually fill in the first and last name of this user. By -convention, this field can be divided into comma-separated subfields, -where the office location, the work phone number, and the home phone -number follow the full name of the user. - -The home directory is the directory in the filesystem where the user -is being logged into, and where his personalized setup files (``dot -files'', since they usually begin with a `.' and are not displayed by -the ls(1) command by default) will be looked up. It is often created -under /usr/home/ or /home/. - -Finally, the shell is the user's initial command interpreter. The -default shell is /bin/sh, some users prefer the more historic -/bin/csh. Other, often more user-friendly and comfortable shells can -be found in the ports and packages collection. diff --git a/usr.sbin/sysinstall/index.c b/usr.sbin/sysinstall/index.c deleted file mode 100644 index 5ff2ceb7b348..000000000000 --- a/usr.sbin/sysinstall/index.c +++ /dev/null @@ -1,618 +0,0 @@ -/* - * The new sysinstall program. - * - * This is probably the last program in the `sysinstall' line - the next - * generation being essentially a complete rewrite. - * - * $Id: index.c,v 1.59 1998/12/22 12:31:25 jkh Exp $ - * - * Copyright (c) 1995 - * Jordan Hubbard. 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, - * verbatim and that no modifications are made prior to this - * point in the file. - * 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 JORDAN HUBBARD ``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 JORDAN HUBBARD OR HIS PETS 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, LIFE 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. - * - */ - -#include <fcntl.h> -#include <stdio.h> -#include <string.h> -#include <stdlib.h> -#include <ncurses.h> -#include <dialog.h> -#include "sysinstall.h" - -/* Macros and magic values */ -#define MAX_MENU 12 -#define _MAX_DESC 55 - -static int index_extract_one(Device *dev, PkgNodePtr top, PkgNodePtr who, Boolean depended); - -/* Smarter strdup */ -inline char * -_strdup(char *ptr) -{ - return ptr ? strdup(ptr) : NULL; -} - -static char *descrs[] = { - "Package Selection", "To mark a package, move to it and press SPACE. If the package is\n" - "already marked, it will be unmarked or deleted (if installed).\n" - "To search for a package by name, press ESC. To select a category,\n" - "press RETURN. NOTE: The All category selection creates a very large\n" - "submenu. If you select it, please be patient while it comes up.", - "Package Targets", "These are the packages you've selected for extraction.\n\n" - "If you're sure of these choices, select OK.\n" - "If not, select Cancel to go back to the package selection menu.\n", - "All", "All available packages in all categories.", - "afterstep", "Ports to support the AfterStep window manager.", - "applications", "User application software.", - "astro", "Applications related to astronomy.", - "archivers", "Utilities for archiving and unarchiving data.", - "audio", "Audio utilities - most require a supported sound card.", - "biology", "Software related to biology.", - "benchmarks", "Utilities for measuring system performance.", - "cad", "Computer Aided Design utilities.", - "chinese", "Ported software for the Chinese market.", - "comms", "Communications utilities.", - "converters", "Format conversion utilities.", - "databases", "Database software.", - "devel", "Software development utilities and libraries.", - "deskutils", "Various Desktop utilities.", - "documentation", "Document preparation utilities.", - "editors", "Common text editors.", - "elisp", "Things related to Emacs Lisp.", - "elisp", "Emacs lisp ports.", - "emulators", "Utilities for emulating other OS types.", - "games", "Various and sundry amusements.", - "german", "Ported software for Germanic countries.", - "graphics", "Graphics libraries and utilities.", - "japanese", "Ported software for the Japanese market.", - "kde", "Software for the K Desktop Environment.", - "korean", "Ported software for the Korean market.", - "lang", "Computer languages.", - "languages", "Computer languages.", - "libraries", "Software development libraries.", - "mail", "Electronic mail packages and utilities.", - "math", "Mathematical computation software.", - "mbone", "Applications and utilities for the MBONE.", - "misc", "Miscellaneous utilities.", - "net", "Networking utilities.", - "news", "USENET News support software.", - "numeric", "Mathematical computation software.", - "offix", "An office automation suite of sorts.", - "orphans", "Packages without a home elsewhere.", - "palm", "Software support for the 3Com Palm(tm) series.", - "perl5", "Utilities/modules for the PERL5 language.", - "plan9", "Software from the Plan9 operating system.", - "print", "Utilities for dealing with printing.", - "printing", "Utilities for dealing with printing.", - "programming", "Software development utilities and libraries.", - "python", "Software related to the Python language.", - "russian", "Ported software for the Russian market.", - "security", "System security software.", - "shells", "Various shells (tcsh, bash, etc).", - "sysutils", "Various system utilities.", - "textproc", "Text processing/search utilities.", - "tcl75", "TCL v7.5 and packages that depend on it.", - "tcl76", "TCL v7.6 and packages that depend on it.", - "tcl80", "TCL v8.0 and packages that depend on it.", - "tcl81", "TCL v8.1 and packages that depend on it.", - "tk41", "Tk4.1 and packages that depend on it.", - "tk42", "Tk4.2 and packages that depend on it.", - "tk80", "Tk8.0 and packages that depend on it.", - "tk81", "Tk8.1 and packages that depend on it.", - "troff", "TROFF text formatting utilities.", - "vietnamese", "Ported software for the Vietnamese market.", - "windowmaker", "Ports to support the WindowMaker window manager.", - "www", "WEB utilities (browers, HTTP servers, etc).", - "x11", "X Window System based utilities.", - "x11-clocks", "X Window System based clocks.", - "x11-fm", "X Window System based file managers.", - "x11-fonts", "X Window System fonts and font utilities.", - "x11-toolkits", "X Window System based development toolkits.", - "x11-wm", "X Window System window managers.", - NULL, NULL, -}; - -static char * -fetch_desc(char *name) -{ - int i; - - for (i = 0; descrs[i]; i += 2) { - if (!strcmp(descrs[i], name)) - return descrs[i + 1]; - } - return "No description provided"; -} - -static PkgNodePtr -new_pkg_node(char *name, node_type type) -{ - PkgNodePtr tmp = safe_malloc(sizeof(PkgNode)); - - tmp->name = _strdup(name); - tmp->type = type; - return tmp; -} - -static char * -strip(char *buf) -{ - int i; - - for (i = 0; buf[i]; i++) - if (buf[i] == '\t' || buf[i] == '\n') - buf[i] = ' '; - return buf; -} - -static IndexEntryPtr -new_index(char *name, char *pathto, char *prefix, char *comment, char *descr, char *maint, char *deps) -{ - IndexEntryPtr tmp = safe_malloc(sizeof(IndexEntry)); - - tmp->name = _strdup(name); - tmp->path = _strdup(pathto); - tmp->prefix = _strdup(prefix); - tmp->comment = _strdup(comment); - tmp->descrfile = strip(_strdup(descr)); - tmp->maintainer = _strdup(maint); - tmp->deps = _strdup(deps); - return tmp; -} - -static void -index_register(PkgNodePtr top, char *where, IndexEntryPtr ptr) -{ - PkgNodePtr p, q; - - for (q = NULL, p = top->kids; p; p = p->next) { - if (!strcmp(p->name, where)) { - q = p; - break; - } - } - if (!p) { - /* Add new category */ - q = new_pkg_node(where, PLACE); - q->desc = fetch_desc(where); - q->next = top->kids; - top->kids = q; - } - p = new_pkg_node(ptr->name, PACKAGE); - p->desc = ptr->comment; - p->data = ptr; - p->next = q->kids; - q->kids = p; -} - -static int -copy_to_sep(char *to, char *from, int sep) -{ - char *tok; - - tok = strchr(from, sep); - if (!tok) { - *to = '\0'; - return 0; - } - *tok = '\0'; - strcpy(to, from); - return tok + 1 - from; -} - -static int -readline(FILE *fp, char *buf, int max) -{ - int rv, i = 0; - char ch; - - while ((rv = fread(&ch, 1, 1, fp)) == 1 && ch != '\n' && i < max) - buf[i++] = ch; - if (i < max) - buf[i] = '\0'; - return rv; -} - -int -index_parse(FILE *fp, char *name, char *pathto, char *prefix, char *comment, char *descr, char *maint, char *cats, char *rdeps) -{ - char line[1024]; - char junk[256]; - char *cp; - int i; - - i = readline(fp, line, 1024); - if (i <= 0) - return EOF; - cp = line; - cp += copy_to_sep(name, cp, '|'); - cp += copy_to_sep(pathto, cp, '|'); - cp += copy_to_sep(prefix, cp, '|'); - cp += copy_to_sep(comment, cp, '|'); - cp += copy_to_sep(descr, cp, '|'); - cp += copy_to_sep(maint, cp, '|'); - cp += copy_to_sep(cats, cp, '|'); - cp += copy_to_sep(junk, cp, '|'); /* build deps - not used */ - if (index(cp, '|')) - copy_to_sep(rdeps, cp, '|'); - else - strncpy(rdeps, cp, 510); - return 0; -} - -int -index_read(FILE *fp, PkgNodePtr papa) -{ - char name[127], pathto[255], prefix[255], comment[255], descr[127], maint[127], cats[511], deps[511]; - - while (index_parse(fp, name, pathto, prefix, comment, descr, maint, cats, deps) != EOF) { - char *cp, *cp2, tmp[511]; - IndexEntryPtr idx; - - idx = new_index(name, pathto, prefix, comment, descr, maint, deps); - /* For now, we only add things to menus if they're in categories. Keywords are ignored */ - for (cp = strcpy(tmp, cats); (cp2 = strchr(cp, ' ')) != NULL; cp = cp2 + 1) { - *cp2 = '\0'; - index_register(papa, cp, idx); - } - index_register(papa, cp, idx); - - /* Add to special "All" category */ - index_register(papa, "All", idx); - } - return 0; -} - -void -index_init(PkgNodePtr top, PkgNodePtr plist) -{ - if (top) { - top->next = top->kids = NULL; - top->name = "Package Selection"; - top->type = PLACE; - top->desc = fetch_desc(top->name); - top->data = NULL; - } - if (plist) { - plist->next = plist->kids = NULL; - plist->name = "Package Targets"; - plist->type = PLACE; - plist->desc = fetch_desc(plist->name); - plist->data = NULL; - } -} - -void -index_print(PkgNodePtr top, int level) -{ - int i; - - while (top) { - for (i = 0; i < level; i++) putchar('\t'); - printf("name [%s]: %s\n", top->type == PLACE ? "place" : "package", top->name); - for (i = 0; i < level; i++) putchar('\t'); - printf("desc: %s\n", top->desc); - if (top->kids) - index_print(top->kids, level + 1); - top = top->next; - } -} - -/* Swap one node for another */ -static void -swap_nodes(PkgNodePtr a, PkgNodePtr b) -{ - PkgNode tmp; - - tmp = *a; - *a = *b; - a->next = tmp.next; - tmp.next = b->next; - *b = tmp; -} - -/* Use a disgustingly simplistic bubble sort to put our lists in order */ -void -index_sort(PkgNodePtr top) -{ - PkgNodePtr p, q; - - /* Sort everything at the top level */ - for (p = top->kids; p; p = p->next) { - for (q = top->kids; q; q = q->next) { - if (q->next && strcmp(q->name, q->next->name) > 0) - swap_nodes(q, q->next); - } - } - - /* Now sub-sort everything n levels down */ - - for (p = top->kids; p; p = p->next) { - if (p->kids) - index_sort(p); - } -} - -/* Delete an entry out of the list it's in (only the plist, at present) */ -void -index_delete(PkgNodePtr n) -{ - if (n->next) { - PkgNodePtr p = n->next; - - *n = *(n->next); - safe_free(p); - } - else /* Kludgy end sentinal */ - n->name = NULL; -} - -/* - * Search for a given node by name, returning the category in if - * tp is non-NULL. - */ -PkgNodePtr -index_search(PkgNodePtr top, char *str, PkgNodePtr *tp) -{ - PkgNodePtr p, sp; - - for (p = top->kids; p && p->name; p = p->next) { - /* Subtract out the All category from searches */ - if (!strcmp(p->name, "All")) - continue; - - /* If tp == NULL, we're looking for an exact package match */ - if (!tp && !strncmp(p->name, str, strlen(str))) - return p; - - /* If tp, we're looking for both a package and a pointer to the place it's in */ - if (tp && !strncmp(p->name, str, strlen(str))) { - *tp = top; - return p; - } - - /* The usual recursion-out-of-laziness ploy */ - if (p->kids) - if ((sp = index_search(p, str, tp)) != NULL) - return sp; - } - if (p && !p->name) - p = NULL; - return p; -} - -int -pkg_checked(dialogMenuItem *self) -{ - PkgNodePtr kp = self->data, plist = (PkgNodePtr)self->aux; - int i; - - i = index_search(plist, kp->name, NULL) ? TRUE : FALSE; - if (kp->type == PACKAGE && plist) - return i || package_exists(kp->name); - else - return FALSE; -} - -int -pkg_fire(dialogMenuItem *self) -{ - int ret; - PkgNodePtr sp, kp = self->data, plist = (PkgNodePtr)self->aux; - - if (!plist) - ret = DITEM_FAILURE; - else if (kp->type == PACKAGE) { - sp = index_search(plist, kp->name, NULL); - /* Not already selected? */ - if (!sp) { - if (!package_exists(kp->name)) { - PkgNodePtr np = (PkgNodePtr)safe_malloc(sizeof(PkgNode)); - - *np = *kp; - np->next = plist->kids; - plist->kids = np; - msgInfo("Added %s to selection list", kp->name); - } - else { - WINDOW *save = savescr(); - - if (!msgYesNo("Do you really want to delete %s from the system?", kp->name)) - if (vsystem("pkg_delete %s %s", isDebug() ? "-v" : "", kp->name)) - msgConfirm("Warning: pkg_delete of %s failed.\n Check debug output for details.", kp->name); - restorescr(save); - } - } - else { - msgInfo("Removed %s from selection list", kp->name); - index_delete(sp); - } - ret = DITEM_SUCCESS; - } - else { /* Not a package, must be a directory */ - int p, s; - - p = s = 0; - index_menu(kp, plist, &p, &s); - ret = DITEM_SUCCESS | DITEM_CONTINUE; - } - return ret; -} - -void -pkg_selected(dialogMenuItem *self, int is_selected) -{ - PkgNodePtr kp = self->data; - - if (!is_selected || kp->type != PACKAGE) - return; - msgInfo(kp->desc); -} - -int -index_menu(PkgNodePtr top, PkgNodePtr plist, int *pos, int *scroll) -{ - int n, rval, maxname; - int curr, max; - PkgNodePtr kp; - dialogMenuItem *nitems; - Boolean hasPackages; - WINDOW *w; - - hasPackages = FALSE; - nitems = NULL; - - w = savescr(); - n = maxname = 0; - /* Figure out if this menu is full of "leaves" or "branches" */ - for (kp = top->kids; kp && kp->name; kp = kp->next) { - int len; - - ++n; - if (kp->type == PACKAGE && plist) { - hasPackages = TRUE; - if ((len = strlen(kp->name)) > maxname) - maxname = len; - } - } - if (!n && plist) { - msgConfirm("The %s menu is empty.", top->name); - restorescr(w); - return DITEM_LEAVE_MENU; - } - - while (1) { - n = 0; - curr = max = 0; - use_helpline(NULL); - use_helpfile(NULL); - kp = top->kids; - if (!hasPackages && plist) { - nitems = item_add(nitems, "OK", NULL, NULL, NULL, NULL, NULL, 0, &curr, &max); - nitems = item_add(nitems, "Install", NULL, NULL, NULL, NULL, NULL, 0, &curr, &max); - } - while (kp && kp->name) { - char buf[256]; - IndexEntryPtr ie = kp->data; - - /* Brutally adjust description to fit in menu */ - if (kp->type == PACKAGE) - snprintf(buf, sizeof buf, "[%s]", ie->path ? ie->path : "External vendor"); - else - SAFE_STRCPY(buf, kp->desc); - if (strlen(buf) > (_MAX_DESC - maxname)) - buf[_MAX_DESC - maxname] = '\0'; - nitems = item_add(nitems, kp->name, buf, pkg_checked, pkg_fire, pkg_selected, kp, (int)plist, &curr, &max); - ++n; - kp = kp->next; - } - /* NULL delimiter so item_free() knows when to stop later */ - nitems = item_add(nitems, NULL, NULL, NULL, NULL, NULL, NULL, 0, &curr, &max); - -recycle: - dialog_clear_norefresh(); - if (hasPackages) - rval = dialog_checklist(top->name, top->desc, -1, -1, n > MAX_MENU ? MAX_MENU : n, -n, nitems, NULL); - else - rval = dialog_menu(top->name, top->desc, -1, -1, n > MAX_MENU ? MAX_MENU : n, -n, nitems + (plist ? 2 : 0), (char *)plist, pos, scroll); - if (rval == -1 && plist) { - static char *cp; - PkgNodePtr menu; - - /* Search */ - if ((cp = msgGetInput(cp, "Search by package name. Please enter search string:")) != NULL) { - PkgNodePtr p = index_search(top, cp, &menu); - - if (p) { - int pos, scroll; - - /* These need to be set to point at the found item, actually. Hmmm! */ - pos = scroll = 0; - index_menu(menu, plist, &pos, &scroll); - } - else - msgConfirm("Search string: %s yielded no hits.", cp); - } - goto recycle; - } - items_free(nitems, &curr, &max); - restorescr(w); - return rval ? DITEM_FAILURE : DITEM_SUCCESS; - } -} - -int -index_extract(Device *dev, PkgNodePtr top, PkgNodePtr plist) -{ - PkgNodePtr tmp; - int status = DITEM_SUCCESS; - - for (tmp = plist->kids; tmp && tmp->name; tmp = tmp->next) - status = index_extract_one(dev, top, tmp, FALSE); - return status; -} - -static int -index_extract_one(Device *dev, PkgNodePtr top, PkgNodePtr who, Boolean depended) -{ - int status = DITEM_SUCCESS; - PkgNodePtr tmp2; - IndexEntryPtr id = who->data; - - if (id && id->deps && strlen(id->deps)) { - char t[1024], *cp, *cp2; - - SAFE_STRCPY(t, id->deps); - cp = t; - while (cp && DITEM_STATUS(status) == DITEM_SUCCESS) { - if ((cp2 = index(cp, ' ')) != NULL) - *cp2 = '\0'; - if ((tmp2 = index_search(top, cp, NULL)) != NULL) { - status = index_extract_one(dev, top, tmp2, TRUE); - if (DITEM_STATUS(status) != DITEM_SUCCESS) { - if (variable_get(VAR_NO_CONFIRM)) - msgNotify("Loading of dependant package %s failed", cp); - else - msgConfirm("Loading of dependant package %s failed", cp); - } - } - else if (!package_exists(cp)) { - if (variable_get(VAR_NO_CONFIRM)) - msgNotify("Warning: %s is a required package but was not found.", cp); - else - msgConfirm("Warning: %s is a required package but was not found.", cp); - } - if (cp2) - cp = cp2 + 1; - else - cp = NULL; - } - } - /* Done with the deps? Load the real m'coy */ - if (DITEM_STATUS(status) == DITEM_SUCCESS) - status = package_extract(dev, who->name, depended); - return status; -} diff --git a/usr.sbin/sysinstall/install.c b/usr.sbin/sysinstall/install.c deleted file mode 100644 index fc1f42ede8f4..000000000000 --- a/usr.sbin/sysinstall/install.c +++ /dev/null @@ -1,1119 +0,0 @@ -/* - * The new sysinstall program. - * - * This is probably the last program in the `sysinstall' line - the next - * generation being essentially a complete rewrite. - * - * $Id: install.c,v 1.222 1999/01/20 11:56:39 jkh Exp $ - * - * Copyright (c) 1995 - * Jordan Hubbard. 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, - * verbatim and that no modifications are made prior to this - * point in the file. - * 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 JORDAN HUBBARD ``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 JORDAN HUBBARD OR HIS PETS 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, LIFE 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. - * - */ - -#include "sysinstall.h" -#include <ctype.h> -#include <sys/disklabel.h> -#include <sys/errno.h> -#include <sys/ioctl.h> -#include <sys/fcntl.h> -#include <sys/wait.h> -#include <sys/param.h> -#define MSDOSFS -#include <sys/mount.h> -#include <ufs/ufs/ufsmount.h> -#include <msdosfs/msdosfsmount.h> -#undef MSDOSFS -#include <sys/stat.h> -#include <sys/sysctl.h> -#include <unistd.h> - -static void create_termcap(void); -static void fixit_common(void); - -#define TERMCAP_FILE "/usr/share/misc/termcap" - -static void installConfigure(void); - -Boolean -checkLabels(Boolean whinge, Chunk **rdev, Chunk **sdev, Chunk **udev, Chunk **vdev) -{ - Device **devs; - Boolean status; - Disk *disk; - Chunk *c1, *c2, *rootdev, *swapdev, *usrdev, *vardev; - int i; - - /* Don't allow whinging if noWarn is set */ - if (variable_get(VAR_NO_WARN)) - whinge = FALSE; - - status = TRUE; - *rdev = *sdev = *udev = *vdev = rootdev = swapdev = usrdev = vardev = NULL; - - /* We don't need to worry about root/usr/swap if we're already multiuser */ - if (!RunningAsInit) - return status; - - devs = deviceFind(NULL, DEVICE_TYPE_DISK); - /* First verify that we have a root device */ - for (i = 0; devs[i]; i++) { - if (!devs[i]->enabled) - continue; - disk = (Disk *)devs[i]->private; - msgDebug("Scanning disk %s for root filesystem\n", disk->name); - if (!disk->chunks) - msgFatal("No chunk list found for %s!", disk->name); - for (c1 = disk->chunks->part; c1; c1 = c1->next) { - if (c1->type == freebsd) { - for (c2 = c1->part; c2; c2 = c2->next) { - if (c2->type == part && c2->subtype != FS_SWAP && c2->private_data) { - if (!strcmp(((PartInfo *)c2->private_data)->mountpoint, "/")) { - if (rootdev) { - if (whinge) - msgConfirm("WARNING: You have more than one root device set?!\n" - "Using the first one found."); - continue; - } - else { - rootdev = c2; - if (isDebug()) - msgDebug("Found rootdev at %s!\n", rootdev->name); - } - } - else if (!strcmp(((PartInfo *)c2->private_data)->mountpoint, "/usr")) { - if (usrdev) { - if (whinge) - msgConfirm("WARNING: You have more than one /usr filesystem.\n" - "Using the first one found."); - continue; - } - else { - usrdev = c2; - if (isDebug()) - msgDebug("Found usrdev at %s!\n", usrdev->name); - } - } - else if (!strcmp(((PartInfo *)c2->private_data)->mountpoint, "/var")) { - if (vardev) { - if (whinge) - msgConfirm("WARNING: You have more than one /var filesystem.\n" - "Using the first one found."); - continue; - } - else { - vardev = c2; - if (isDebug()) - msgDebug("Found vardev at %s!\n", vardev->name); - } - } - } - } - } - } - } - - /* Now check for swap devices */ - for (i = 0; devs[i]; i++) { - if (!devs[i]->enabled) - continue; - disk = (Disk *)devs[i]->private; - msgDebug("Scanning disk %s for swap partitions\n", disk->name); - if (!disk->chunks) - msgFatal("No chunk list found for %s!", disk->name); - for (c1 = disk->chunks->part; c1; c1 = c1->next) { - if (c1->type == freebsd) { - for (c2 = c1->part; c2; c2 = c2->next) { - if (c2->type == part && c2->subtype == FS_SWAP && !swapdev) { - swapdev = c2; - if (isDebug()) - msgDebug("Found swapdev at %s!\n", swapdev->name); - break; - } - } - } - } - } - - /* Copy our values over */ - *rdev = rootdev; - *sdev = swapdev; - *udev = usrdev; - *vdev = vardev; - - if (!rootdev && whinge) { - msgConfirm("No root device found - you must label a partition as /\n" - "in the label editor."); - status = FALSE; - } - if (!swapdev && whinge) { - msgConfirm("No swap devices found - you must create at least one\n" - "swap partition."); - status = FALSE; - } - if (!usrdev && whinge && !variable_get(VAR_NO_USR)) { - msgConfirm("WARNING: No /usr filesystem found. This is not technically\n" - "an error if your root filesystem is big enough (or you later\n" - "intend to mount your /usr filesystem over NFS), but it may otherwise\n" - "cause you trouble if you're not exactly sure what you are doing!"); - } - if (!vardev && whinge && variable_cmp(SYSTEM_STATE, "upgrade")) { - msgConfirm("WARNING: No /var filesystem found. This is not technically\n" - "an error if your root filesystem is big enough (or you later\n" - "intend to link /var to someplace else), but it may otherwise\n" - "cause your root filesystem to fill up if you receive lots of mail\n" - "or edit large temporary files."); - } - return status; -} - -static int -installInitial(void) -{ - static Boolean alreadyDone = FALSE; - int status = DITEM_SUCCESS; - - if (alreadyDone) - return DITEM_SUCCESS; - - if (!variable_get(DISK_LABELLED)) { - msgConfirm("You need to assign disk labels before you can proceed with\n" - "the installation."); - return DITEM_FAILURE; - } - /* If it's labelled, assume it's also partitioned */ - if (!variable_get(DISK_PARTITIONED)) - variable_set2(DISK_PARTITIONED, "yes"); - - /* If we refuse to proceed, bail. */ - dialog_clear_norefresh(); - if (!variable_get(VAR_NO_WARN)) - if (msgYesNo( - "Last Chance! Are you SURE you want continue the installation?\n\n" - "If you're running this on a disk with data you wish to save\n" - "then WE STRONGLY ENCOURAGE YOU TO MAKE PROPER BACKUPS before\n" - "proceeding!\n\n" - "We can take no responsibility for lost disk contents!") != 0) - return DITEM_FAILURE | DITEM_RESTORE; - - if (DITEM_STATUS(diskLabelCommit(NULL)) != DITEM_SUCCESS) { - msgConfirm("Couldn't make filesystems properly. Aborting."); - return DITEM_FAILURE; - } - - if (!copySelf()) { - msgConfirm("installInitial: Couldn't clone the boot floppy onto the\n" - "root file system. Aborting!"); - return DITEM_FAILURE; - } - - if (chroot("/mnt") == -1) { - msgConfirm("installInitial: Unable to chroot to %s - this is bad!", - "/mnt"); - return DITEM_FAILURE; - } - - chdir("/"); - variable_set2(RUNNING_ON_ROOT, "yes"); - - /* Configure various files in /etc */ - if (DITEM_STATUS(configResolv(NULL)) == DITEM_FAILURE) - status = DITEM_FAILURE; - if (DITEM_STATUS(configFstab(NULL)) == DITEM_FAILURE) - status = DITEM_FAILURE; - - /* stick a helpful shell over on the 4th VTY */ - systemCreateHoloshell(); - - alreadyDone = TRUE; - return status; -} - -int -installFixitHoloShell(dialogMenuItem *self) -{ - systemCreateHoloshell(); - return DITEM_SUCCESS; -} - -int -installFixitCDROM(dialogMenuItem *self) -{ - struct stat sb; - - if (!RunningAsInit) - return DITEM_SUCCESS; - - variable_set2(SYSTEM_STATE, "fixit"); - (void)unlink("/mnt2"); - (void)rmdir("/mnt2"); - - while (1) { - msgConfirm("Please insert the second FreeBSD CDROM and press return"); - if (DITEM_STATUS(mediaSetCDROM(NULL)) != DITEM_SUCCESS || !mediaDevice || !mediaDevice->init(mediaDevice)) { - /* If we can't initialize it, it's probably not a FreeBSD CDROM so punt on it */ - if (mediaDevice) { - mediaDevice->shutdown(mediaDevice); - mediaDevice = NULL; - } - if (msgYesNo("Unable to mount the CDROM - do you want to try again?") != 0) - return DITEM_FAILURE; - } - else - break; - } - - /* Since the fixit code expects everything to be in /mnt2, and the CDROM mounting stuff /dist, do - * a little kludge dance here.. - */ - if (symlink("/dist", "/mnt2")) { - msgConfirm("Unable to symlink /mnt2 to the CDROM mount point. Please report this\n" - "unexpected failure to freebsd-bugs@FreeBSD.org."); - return DITEM_FAILURE; - } - - /* - * If /tmp points to /mnt2/tmp from a previous fixit floppy session, it's - * not very good for us if we point it to the CDROM now. Rather make it - * a directory in the root MFS then. Experienced admins will still be - * able to mount their disk's /tmp over this if they need. - */ - if (lstat("/tmp", &sb) == 0 && (sb.st_mode & S_IFMT) == S_IFLNK) - (void)unlink("/tmp"); - Mkdir("/tmp"); - - /* - * Since setuid binaries ignore LD_LIBRARY_PATH, we indeed need the - * ld.so.hints file. Fortunately, it's fairly small (~ 3 KB). - */ - if (!file_readable("/var/run/ld.so.hints")) { - Mkdir("/var/run"); - if (vsystem("/mnt2/sbin/ldconfig -s /mnt2/usr/lib")) { - msgConfirm("Warning: ldconfig could not create the ld.so hints file.\n" - "Dynamic executables from the CDROM likely won't work."); - } - } - - /* Yet another iggly hardcoded pathname. */ - if (!file_readable("/usr/libexec/ld.so")) { - Mkdir("/usr/libexec"); - if (symlink("/mnt2/usr/libexec/ld.so", "/usr/libexec/ld.so")) { - msgConfirm("Warning: could not create the symlink for ld.so.\n" - "Dynamic executables from the CDROM likely won't work."); - } - } - - fixit_common(); - - mediaDevice->shutdown(mediaDevice); - msgConfirm("Please remove the FreeBSD CDROM now."); - return DITEM_SUCCESS; -} - -int -installFixitFloppy(dialogMenuItem *self) -{ - struct ufs_args args; - - if (!RunningAsInit) - return DITEM_SUCCESS; - - variable_set2(SYSTEM_STATE, "fixit"); - Mkdir("/mnt2"); - - /* Try to open the floppy drive */ - if (DITEM_STATUS(mediaSetFloppy(NULL)) == DITEM_FAILURE) { - msgConfirm("Unable to set media device to floppy."); - mediaClose(); - return DITEM_FAILURE; - } - - memset(&args, 0, sizeof(args)); - args.fspec = mediaDevice->devname; - - while (1) { - msgConfirm("Please insert a writable fixit floppy and press return"); - mediaDevice->private = "/mnt2"; - if (!mediaDevice->init(mediaDevice)) { - if (msgYesNo("The attempt to mount the fixit floppy failed, bad floppy\n" - "or unclean filesystem. Do you want to try again?")) - return DITEM_FAILURE; - } - else - break; - } - if (!directory_exists("/tmp")) - (void)symlink("/mnt2/tmp", "/tmp"); - fixit_common(); - mediaDevice->shutdown(mediaDevice); - mediaDevice = NULL; - msgConfirm("Please remove the fixit floppy now."); - return DITEM_SUCCESS; -} - -/* - * The common code for both fixit variants. - */ -static void -fixit_common(void) -{ - pid_t child; - int waitstatus; - - if (!directory_exists("/var/tmp/vi.recover")) { - if (DITEM_STATUS(Mkdir("/var/tmp/vi.recover")) != DITEM_SUCCESS) { - msgConfirm("Warning: Was unable to create a /var/tmp/vi.recover directory.\n" - "vi will kvetch and moan about it as a result but should still\n" - "be essentially usable."); - } - } - if (!directory_exists("/bin")) - (void)Mkdir("/bin"); - (void)symlink("/stand/sh", "/bin/sh"); - /* Link the /etc/ files */ - if (DITEM_STATUS(Mkdir("/etc")) != DITEM_SUCCESS) - msgConfirm("Unable to create an /etc directory! Things are weird on this floppy.."); - else if ((symlink("/mnt2/etc/spwd.db", "/etc/spwd.db") == -1 && errno != EEXIST) || - (symlink("/mnt2/etc/protocols", "/etc/protocols") == -1 && errno != EEXIST) || - (symlink("/mnt2/etc/services", "/etc/services") == -1 && errno != EEXIST)) - msgConfirm("Couldn't symlink the /etc/ files! I'm not sure I like this.."); - if (!file_readable(TERMCAP_FILE)) - create_termcap(); - if (!(child = fork())) { - int i, fd; - struct termios foo; - extern int login_tty(int); - - ioctl(0, TIOCNOTTY, NULL); - for (i = getdtablesize(); i >= 0; --i) - close(i); - fd = open("/dev/ttyv3", O_RDWR); - ioctl(0, TIOCSCTTY, &fd); - dup2(0, 1); - dup2(0, 2); - DebugFD = 2; - if (login_tty(fd) == -1) - msgDebug("fixit: I can't set the controlling terminal.\n"); - - signal(SIGTTOU, SIG_IGN); - if (tcgetattr(0, &foo) != -1) { - foo.c_cc[VERASE] = '\010'; - if (tcsetattr(0, TCSANOW, &foo) == -1) - msgDebug("fixit shell: Unable to set erase character.\n"); - } - else - msgDebug("fixit shell: Unable to get terminal attributes!\n"); - setenv("PATH", "/bin:/sbin:/usr/bin:/usr/sbin:/stand:" - "/mnt2/stand:/mnt2/bin:/mnt2/sbin:/mnt2/usr/bin:/mnt2/usr/sbin", 1); - /* use the .profile from the fixit medium */ - setenv("HOME", "/mnt2", 1); - chdir("/mnt2"); - execlp("sh", "-sh", 0); - msgDebug("fixit shell: Failed to execute shell!\n"); - _exit(1);; - } - else { - msgNotify("Waiting for fixit shell to exit. Go to VTY4 now by\n" - "typing ALT-F4. When you are done, type ``exit'' to exit\n" - "the fixit shell and be returned here."); - (void)waitpid(child, &waitstatus, 0); - } - dialog_clear(); -} - - -int -installExpress(dialogMenuItem *self) -{ - int i; - - variable_set2(SYSTEM_STATE, "express"); -#ifndef __alpha__ - if (DITEM_STATUS((i = diskPartitionEditor(self))) == DITEM_FAILURE) - return i; -#endif - - if (DITEM_STATUS((i = diskLabelEditor(self))) == DITEM_FAILURE) - return i; - - dialog_clear_norefresh(); - if (DITEM_STATUS((i = installCommit(self))) == DITEM_SUCCESS) { - i |= DITEM_LEAVE_MENU; - /* Give user the option of one last configuration spree */ - installConfigure(); - } - return i | DITEM_RESTORE; -} - -/* Novice mode installation */ -int -installNovice(dialogMenuItem *self) -{ - int i, tries = 0; - Device **devs; - - variable_set2(SYSTEM_STATE, "novice"); -#ifndef __alpha__ - dialog_clear_norefresh(); - msgConfirm("In the next menu, you will need to set up a DOS-style (\"fdisk\") partitioning\n" - "scheme for your hard disk. If you simply wish to devote all disk space\n" - "to FreeBSD (overwriting anything else that might be on the disk(s) selected)\n" - "then use the (A)ll command to select the default partitioning scheme followed\n" - "by a (Q)uit. If you wish to allocate only free space to FreeBSD, move to a\n" - "partition marked \"unused\" and use the (C)reate command."); - -nodisks: - if (DITEM_STATUS(diskPartitionEditor(self)) == DITEM_FAILURE) - return DITEM_FAILURE; - - if (diskGetSelectCount(&devs) <= 0 && tries < 3) { - msgConfirm("You need to select some disks to operate on! Be sure to use SPACE\n" - "instead of RETURN in the disk selection menu when selecting a disk."); - ++tries; - goto nodisks; - } -#endif - - dialog_clear_norefresh(); -#ifdef __alpha__ - msgConfirm("First, you need to create BSD partitions on the disk which you are\n" - "installing to. If you have a reasonable amount of disk space (200MB or more)\n" - "and don't have any special requirements, simply use the (A)uto command to\n" - "allocate space automatically. If you have more specific needs or just don't\n" - "care for the layout chosen by (A)uto, press F1 for more information on\n" - "manual layout."); -#else - msgConfirm("First, you need to create BSD partitions inside of the fdisk partition(s)\n" - "just created. If you have a reasonable amount of disk space (200MB or more)\n" - "and don't have any special requirements, simply use the (A)uto command to\n" - "allocate space automatically. If you have more specific needs or just don't\n" - "care for the layout chosen by (A)uto, press F1 for more information on\n" - "manual layout."); -#endif - - if (DITEM_STATUS(diskLabelEditor(self)) == DITEM_FAILURE) - return DITEM_FAILURE; - - dialog_clear_norefresh(); - if (DITEM_STATUS((i = installCommit(self))) == DITEM_FAILURE) { - dialog_clear_norefresh(); - msgConfirm("Installation completed with some errors. You may wish to\n" - "scroll through the debugging messages on VTY1 with the\n" - "scroll-lock feature. You can also chose \"No\" at the next\n" - "prompt and go back into the installation menus to try and retry\n" - "whichever operations have failed."); - return i | DITEM_RESTORE; - - } - else { - dialog_clear_norefresh(); - msgConfirm("Congratulations! You now have FreeBSD installed on your system.\n\n" - "We will now move on to the final configuration questions.\n" - "For any option you do not wish to configure, simply select\n" - "No.\n\n" - "If you wish to re-enter this utility after the system is up, you\n" - "may do so by typing: /stand/sysinstall."); - } - if (mediaDevice->type != DEVICE_TYPE_FTP && mediaDevice->type != DEVICE_TYPE_NFS) { - if (!msgYesNo("Would you like to configure any Ethernet or SLIP/PPP network devices?")) { - Device *tmp; - - dialog_clear_norefresh(); - tmp = tcpDeviceSelect(); - dialog_clear_norefresh(); - if (tmp && !msgYesNo("Would you like to bring the %s interface up right now?", tmp->name)) - if (!tmp->init(tmp)) - msgConfirm("Initialization of %s device failed.", tmp->name); - } - } - - dialog_clear_norefresh(); - if (!msgYesNo("Will this machine be an IP gateway (e.g. will it forward packets\n" - "between interfaces)?")) - variable_set2("gateway_enable", "YES"); - - dialog_clear_norefresh(); - if (!msgYesNo("Do you want to allow anonymous FTP connections to this machine?")) - configAnonFTP(self); - - dialog_clear_norefresh(); - if (!msgYesNo("Do you want to configure this machine as an NFS server?")) - configNFSServer(self); - - dialog_clear_norefresh(); - if (!msgYesNo("Do you want to configure this machine as an NFS client?")) - variable_set2("nfs_client_enable", "YES"); - - dialog_clear_norefresh(); - if (!msgYesNo("Would you like to customize your system console settings?")) { - WINDOW *w = savescr(); - - dmenuOpenSimple(&MenuSyscons, FALSE); - restorescr(w); - } - - dialog_clear_norefresh(); - if (!msgYesNo("Would you like to set this machine's time zone now?")) { - WINDOW *w = savescr(); - - dialog_clear(); - systemExecute("tzsetup"); - restorescr(w); - } - - dialog_clear_norefresh(); - if (!msgYesNo("Does this system have a mouse attached to it?")) { - WINDOW *w = savescr(); - - dmenuOpenSimple(&MenuMouse, FALSE); - restorescr(w); - } - - /* Now would be a good time to checkpoint the configuration data */ - configRC_conf("/etc/rc.conf"); - sync(); - - if (directory_exists("/usr/X11R6")) { - dialog_clear_norefresh(); - if (!msgYesNo("Would you like to configure your X server at this time?")) - configXEnvironment(self); - } - - dialog_clear_norefresh(); - if (!msgYesNo("The FreeBSD package collection is a collection of hundreds of ready-to-run\n" - "applications, from text editors to games to WEB servers and more. Would you\n" - "like to browse the collection now?")) - configPackages(self); - - dialog_clear_norefresh(); - if (!msgYesNo("Would you like to add any initial user accounts to the system?\n" - "Adding at least one account for yourself at this stage is suggested\n" - "since working as the \"root\" user is dangerous (it is easy to do\n" - "things which adversely affect the entire system).")) - configUsers(self); - - dialog_clear_norefresh(); - msgConfirm("Now you must set the system manager's password.\n" - "This is the password you'll use to log in as \"root\"."); - { - WINDOW *w = savescr(); - - if (!systemExecute("passwd root")) - variable_set2("root_password", "YES"); - restorescr(w); - } - - dialog_clear_norefresh(); - if (!msgYesNo("Would you like to register your FreeBSD system at this time?\n\n" - "PLEASE, take just 5 minutes to do this. If we're ever to get any\n" - "significant base of commercial software for FreeBSD, we need to\n" - "be able to provide more information about the size of our user community.\n" - "This is where your registration can really help us, and you can also\n" - "sign up for the new FreeBSD newsletter (its free!) at the same time.\n")) - configRegister(NULL); - else { - dialog_clear_norefresh(); - msgConfirm("OK, but if you should change your mind then you always can register\n" - "later by typing ``/stand/sysinstall register'' or by simply visiting our\n" - "web site at http://www.freebsd.org/register.html"); - - } - /* XXX Put whatever other nice configuration questions you'd like to ask the user here XXX */ - - /* Give user the option of one last configuration spree */ - dialog_clear_norefresh(); - installConfigure(); - - return DITEM_LEAVE_MENU | DITEM_RESTORE; -} - -/* The version of commit we call from the Install Custom menu */ -int -installCustomCommit(dialogMenuItem *self) -{ - int i; - - dialog_clear_norefresh(); - i = installCommit(self); - if (DITEM_STATUS(i) == DITEM_SUCCESS) { - /* Give user the option of one last configuration spree */ - installConfigure(); - return i; - } - else - msgConfirm("The commit operation completed with errors. Not\n" - "updating /etc files."); - return i; -} - -/* - * What happens when we finally decide to going ahead with the installation. - * - * This is broken into multiple stages so that the user can do a full - * installation but come back here again to load more distributions, - * perhaps from a different media type. This would allow, for - * example, the user to load the majority of the system from CDROM and - * then use ftp to load just the DES dist. - */ -int -installCommit(dialogMenuItem *self) -{ - int i; - char *str; - - if (!Dists) - distConfig(NULL); - - if (!Dists) - if (!dmenuOpenSimple(&MenuDistributions, FALSE) && !Dists) - return DITEM_FAILURE | DITEM_RESTORE; - - if (!mediaVerify()) - return DITEM_FAILURE | DITEM_RESTORE; - - str = variable_get(SYSTEM_STATE); - if (isDebug()) - msgDebug("installCommit: System state is `%s'\n", str); - - /* Installation stuff we wouldn't do to a running system */ - if (RunningAsInit && DITEM_STATUS((i = installInitial())) == DITEM_FAILURE) - return i; - -try_media: - if (!mediaDevice->init(mediaDevice)) { - if (!msgYesNo("Unable to initialize selected media. Would you like to\n" - "adjust your media configuration and try again?")) { - mediaDevice = NULL; - if (!mediaVerify()) - return DITEM_FAILURE | DITEM_RESTORE; - else - goto try_media; - } - else - return DITEM_FAILURE | DITEM_RESTORE; - } - - /* Now go get it all */ - i = distExtractAll(self); - - /* When running as init, *now* it's safe to grab the rc.foo vars */ - installEnvironment(); - - variable_set2(SYSTEM_STATE, DITEM_STATUS(i) == DITEM_FAILURE ? "error-install" : "full-install"); - - return i | DITEM_RESTORE; -} - -static void -installConfigure(void) -{ - /* Final menu of last resort */ - dialog_clear_norefresh(); - if (!msgYesNo("Visit the general configuration menu for a chance to set\n" - "any last options?")) { - WINDOW *w = savescr(); - - dmenuOpenSimple(&MenuConfigure, FALSE); - restorescr(w); - } - configRC_conf("/etc/rc.conf"); - sync(); -} - -int -installFixupBin(dialogMenuItem *self) -{ - Device **devs; - int i; - - /* All of this is done only as init, just to be safe */ - if (RunningAsInit) { - /* Fix up kernel first */ - if (!file_readable("/kernel")) { - if (file_readable("/kernel.GENERIC")) { - if (vsystem("cp -p /kernel.GENERIC /kernel")) { - msgConfirm("Unable to copy /kernel into place!"); - return DITEM_FAILURE; - } - /* Snapshot any boot -c changes back to the new kernel */ - if (kget("/kernel.config")) { - msgConfirm("Kernel copied OK, but unable to save boot -c changes\n" - "to it. See the debug screen (ALT-F2) for details."); - } - } - else { - msgConfirm("Can't find a kernel image to link to on the root file system!\n" - "You're going to have a hard time getting this system to\n" - "boot from the hard disk, I'm afraid!"); - return DITEM_FAILURE; - } - } - - /* BOGON #1: Resurrect /dev after bin distribution screws it up */ - msgNotify("Remaking all devices.. Please wait!"); - if (vsystem("cd /dev; sh MAKEDEV all")) { - msgConfirm("MAKEDEV returned non-zero status"); - return DITEM_FAILURE; - } - - msgNotify("Resurrecting /dev entries for slices.."); - devs = deviceFind(NULL, DEVICE_TYPE_DISK); - if (!devs) - msgFatal("Couldn't get a disk device list!"); - - /* Resurrect the slices that the former clobbered */ - for (i = 0; devs[i]; i++) { - Disk *disk = (Disk *)devs[i]->private; - Chunk *c1; - - if (!devs[i]->enabled) - continue; - if (!disk->chunks) - msgFatal("No chunk list found for %s!", disk->name); - for (c1 = disk->chunks->part; c1; c1 = c1->next) { - if (c1->type == freebsd) { - msgNotify("Making slice entries for %s", c1->name); - if (vsystem("cd /dev; sh MAKEDEV %sh", c1->name)) { - msgConfirm("Unable to make slice entries for %s!", c1->name); - return DITEM_FAILURE; - } - } - } - } - - /* BOGON #2: We leave /etc in a bad state */ - chmod("/etc", 0755); - - /* BOGON #3: No /var/db/mountdtab complains */ - Mkdir("/var/db"); - creat("/var/db/mountdtab", 0644); - - /* BOGON #4: /compat created by default in root fs */ - Mkdir("/usr/compat"); - vsystem("ln -s /usr/compat /compat"); - - /* BOGON #5: aliases database not build for bin */ - vsystem("newaliases"); - - /* BOGON #6: deal with new boot files */ - vsystem("touch /kernel.config"); - vsystem("touch /boot.config"); - if (file_readable("/stand/boot.help") && !file_readable("/boot.help")) - vsystem("mv /stand/boot.help /"); - - /* Now run all the mtree stuff to fix things up */ - vsystem("mtree -deU -f /etc/mtree/BSD.root.dist -p /"); - vsystem("mtree -deU -f /etc/mtree/BSD.var.dist -p /var"); - vsystem("mtree -deU -f /etc/mtree/BSD.usr.dist -p /usr"); - - /* Do all the last ugly work-arounds here */ - } - return DITEM_SUCCESS; -} - -/* Fix side-effects from the the XFree86 installation */ -int -installFixupXFree(dialogMenuItem *self) -{ - /* BOGON #1: XFree86 requires various specialized fixups */ - if (directory_exists("/usr/X11R6")) { - msgNotify("Fixing permissions in XFree86 tree.."); - vsystem("chmod -R a+r /usr/X11R6"); - vsystem("find /usr/X11R6 -type d | xargs chmod a+x"); - - /* Also do bogus minimal package registration so ports don't whine */ - if (file_readable("/usr/X11R6/lib/X11/pkgreg.tar.gz")) { - msgNotify("Installing package metainfo.."); - vsystem("tar xpzf /usr/X11R6/lib/X11/pkgreg.tar.gz -C / && rm /usr/X11R6/lib/X11/pkgreg.tar.gz"); - } - } - return DITEM_SUCCESS; -} - -/* Go newfs and/or mount all the filesystems we've been asked to */ -int -installFilesystems(dialogMenuItem *self) -{ - int i; - Disk *disk; - Chunk *c1, *c2, *rootdev, *swapdev, *usrdev, *vardev; - Device **devs; - PartInfo *root; - char dname[80]; - extern int MakeDevChunk(Chunk *c, char *n); - Boolean upgrade = FALSE; - - /* If we've already done this, bail out */ - if (!variable_cmp(DISK_LABELLED, "written")) - return DITEM_SUCCESS; - - upgrade = !variable_cmp(SYSTEM_STATE, "upgrade"); - if (!checkLabels(TRUE, &rootdev, &swapdev, &usrdev, &vardev)) - return DITEM_FAILURE; - - if (rootdev) - root = (PartInfo *)rootdev->private_data; - else - root = NULL; - - command_clear(); - if (swapdev && RunningAsInit) { - /* As the very first thing, try to get ourselves some swap space */ - sprintf(dname, "/dev/%s", swapdev->name); - if (!Fake && (!MakeDevChunk(swapdev, "/dev") || !file_readable(dname))) { - msgConfirm("Unable to make device node for %s in /dev!\n" - "The creation of filesystems will be aborted.", dname); - return DITEM_FAILURE; - } - - if (!Fake) { - if (!swapon(dname)) - msgNotify("Added %s as initial swap device", dname); - else - msgConfirm("WARNING! Unable to swap to %s: %s\n" - "This may cause the installation to fail at some point\n" - "if you don't have a lot of memory.", dname, strerror(errno)); - } - } - - if (rootdev && RunningAsInit) { - /* Next, create and/or mount the root device */ - sprintf(dname, "/dev/r%s", rootdev->name); - if (!Fake && (!MakeDevChunk(rootdev, "/dev") || !file_readable(dname))) { - msgConfirm("Unable to make device node for %s in /dev!\n" - "The creation of filesystems will be aborted.", dname); - return DITEM_FAILURE; - } - if (strcmp(root->mountpoint, "/")) - msgConfirm("Warning: %s is marked as a root partition but is mounted on %s", rootdev->name, root->mountpoint); - - if (root->newfs && (!upgrade || !msgYesNo("You are upgrading - are you SURE you want to newfs the root partition?"))) { - int i; - - msgNotify("Making a new root filesystem on %s", dname); - i = vsystem("%s %s", root->newfs_cmd, dname); - if (i) { - msgConfirm("Unable to make new root filesystem on %s!\n" - "Command returned status %d", dname, i); - return DITEM_FAILURE; - } - } - else { - if (!upgrade) { - msgConfirm("Warning: Using existing root partition. It will be assumed\n" - "that you have the appropriate device entries already in /dev."); - } - msgNotify("Checking integrity of existing %s filesystem.", dname); - i = vsystem("fsck -y %s", dname); - if (i) - msgConfirm("Warning: fsck returned status of %d for %s.\n" - "This partition may be unsafe to use.", i, dname); - } - - /* Switch to block device */ - sprintf(dname, "/dev/%s", rootdev->name); - if (Mount("/mnt", dname)) { - msgConfirm("Unable to mount the root file system on %s! Giving up.", dname); - return DITEM_FAILURE; - } - } - - /* Now buzz through the rest of the partitions and mount them too */ - devs = deviceFind(NULL, DEVICE_TYPE_DISK); - for (i = 0; devs[i]; i++) { - if (!devs[i]->enabled) - continue; - - disk = (Disk *)devs[i]->private; - if (!disk->chunks) { - msgConfirm("No chunk list found for %s!", disk->name); - return DITEM_FAILURE; - } - if (RunningAsInit && root && (root->newfs || upgrade)) { - Mkdir("/mnt/dev"); - if (!Fake) - MakeDevDisk(disk, "/mnt/dev"); - } - else if (!RunningAsInit && !Fake) - MakeDevDisk(disk, "/dev"); - - for (c1 = disk->chunks->part; c1; c1 = c1->next) { - if (c1->type == freebsd) { - for (c2 = c1->part; c2; c2 = c2->next) { - if (c2->type == part && c2->subtype != FS_SWAP && c2->private_data) { - PartInfo *tmp = (PartInfo *)c2->private_data; - - /* Already did root */ - if (c2 == rootdev) - continue; - - if (tmp->newfs && (!upgrade || !msgYesNo("You are upgrading - are you SURE you want to newfs /dev/%s?", c2->name))) - command_shell_add(tmp->mountpoint, "%s %s/dev/r%s", tmp->newfs_cmd, RunningAsInit ? "/mnt" : "", c2->name); - else - command_shell_add(tmp->mountpoint, "fsck -y %s/dev/r%s", RunningAsInit ? "/mnt" : "", c2->name); - command_func_add(tmp->mountpoint, Mount, c2->name); - } - else if (c2->type == part && c2->subtype == FS_SWAP) { - char fname[80]; - int i; - - if (c2 == swapdev) - continue; - sprintf(fname, "%s/dev/%s", RunningAsInit ? "/mnt" : "", c2->name); - i = (Fake || swapon(fname)); - if (!i) - msgNotify("Added %s as an additional swap device", fname); - else - msgConfirm("Unable to add %s as a swap device: %s", fname, strerror(errno)); - } - } - } - else if (c1->type == fat && c1->private_data && (root->newfs || upgrade)) { - char name[FILENAME_MAX]; - - sprintf(name, "%s/%s", RunningAsInit ? "/mnt" : "", ((PartInfo *)c1->private_data)->mountpoint); - Mkdir(name); - } - } - } - - if (RunningAsInit) { - msgNotify("Copying initial device files.."); - /* Copy the boot floppy's dev files */ - if ((root->newfs || upgrade) && vsystem("find -x /dev | cpio %s -pdum /mnt", cpioVerbosity())) { - msgConfirm("Couldn't clone the /dev files!"); - return DITEM_FAILURE; - } - } - - command_sort(); - command_execute(); - return DITEM_SUCCESS; -} - -static char * -getRelname(void) -{ - static char buf[64]; - int sz = (sizeof buf) - 1; - - if (sysctlbyname("kern.osrelease", buf, &sz, NULL, 0) != -1) { - buf[sz] = '\0'; - return buf; - } - else - return "<unknown>"; -} - -/* Initialize various user-settable values to their defaults */ -int -installVarDefaults(dialogMenuItem *self) -{ - char *cp; - - /* Set default startup options */ - variable_set2(VAR_RELNAME, getRelname()); - variable_set2(VAR_CPIO_VERBOSITY, "high"); - variable_set2(VAR_TAPE_BLOCKSIZE, DEFAULT_TAPE_BLOCKSIZE); - variable_set2(VAR_INSTALL_ROOT, "/"); - variable_set2(VAR_INSTALL_CFG, "install.cfg"); - cp = getenv("EDITOR"); - if (!cp) - cp = "/usr/bin/ee"; - variable_set2(VAR_EDITOR, cp); - variable_set2(VAR_FTP_USER, "ftp"); - variable_set2(VAR_BROWSER_PACKAGE, "lynx"); - variable_set2(VAR_BROWSER_BINARY, "/usr/local/bin/lynx"); - variable_set2(VAR_FTP_STATE, "passive"); - variable_set2(VAR_NFS_SECURE, "YES"); - variable_set2(VAR_PKG_TMPDIR, "/usr/tmp"); - variable_set2(VAR_GATED_PKG, "gated"); - variable_set2(VAR_PCNFSD_PKG, "pcnfsd"); - variable_set2(VAR_MEDIA_TIMEOUT, itoa(MEDIA_TIMEOUT)); - if (getpid() != 1) - variable_set2(SYSTEM_STATE, "update"); - else - variable_set2(SYSTEM_STATE, "init"); - return DITEM_SUCCESS; -} - -/* Load the environment up from various system configuration files */ -void -installEnvironment(void) -{ - if (file_readable("/etc/rc.conf")) - configEnvironmentRC_conf("/etc/rc.conf"); - if (file_readable("/etc/resolv.conf")) - configEnvironmentResolv("/etc/resolv.conf"); -} - -/* Copy the boot floppy contents into /stand */ -Boolean -copySelf(void) -{ - int i; - - if (file_readable("/boot.help")) - vsystem("cp /boot.help /mnt"); - msgWeHaveOutput("Copying the boot floppy to /stand on root filesystem"); - i = vsystem("find -x /stand | cpio %s -pdum /mnt", cpioVerbosity()); - if (i) { - msgConfirm("Copy returned error status of %d!", i); - return FALSE; - } - - /* Copy the /etc files into their rightful place */ - if (vsystem("cd /mnt/stand; find etc | cpio %s -pdum /mnt", cpioVerbosity())) { - msgConfirm("Couldn't copy up the /etc files!"); - return TRUE; - } - return TRUE; -} - -static void -create_termcap(void) -{ - FILE *fp; - - const char *caps[] = { - termcap_vt100, termcap_cons25, termcap_cons25_m, termcap_cons25r, - termcap_cons25r_m, termcap_cons25l1, termcap_cons25l1_m, NULL, - }; - const char **cp; - - if (!file_readable(TERMCAP_FILE)) { - Mkdir("/usr/share/misc"); - fp = fopen(TERMCAP_FILE, "w"); - if (!fp) { - msgConfirm("Unable to initialize termcap file. Some screen-oriented\nutilities may not work."); - return; - } - cp = caps; - while (*cp) - fprintf(fp, "%s\n", *(cp++)); - fclose(fp); - } -} diff --git a/usr.sbin/sysinstall/install.cfg b/usr.sbin/sysinstall/install.cfg deleted file mode 100644 index cade7a27ed5f..000000000000 --- a/usr.sbin/sysinstall/install.cfg +++ /dev/null @@ -1,96 +0,0 @@ -# This is the installation configuration file for my test machine, -# crate.cdrom.com. -# It is included here merely as a sort-of-documented example. - -# Turn on extra debugging. -debug=yes - -################################ -# My host specific data -hostname=crate.cdrom.com -domainname=cdrom.com -nameserver=204.216.27.3 -defaultrouter=204.216.27.228 -ipaddr=204.216.27.230 -netmask=255.255.255.240 -################################ - -################################ -# Which installation device to use - ftp is pointed directly at my local -# machine and the installation device is my WD8013 ethernet interface. -ftp=ftp://time.cdrom.com/pub -netDev=ed0 -mediaSetFTP -################################ - -################################ -# Select which distributions we want. -dists=bin doc manpages info compat21 des src sbase ssys -distSetCustom -################################ - -################################ -# Now set the parameters for the partition editor on wd0. Set to use the -# disk exclusively (could also be "all" to use the whole disk but -# respecting the MBR or "free" to use only unallocated space for FreeBSD). -disk=wd0 -partition=exclusive -diskPartitionEditor - -# Uncomment this instead to use only the free space and install boot manager. -#partition=free -#bootManager=booteasy -#diskPartitionEditor -################################ - -################################ - -# This assumes that slice 1 is a DOS partition and mounts it as /dos, -# which is the case on my laptop. -# -# All sizes are expressed in 512 byte blocks! - -# A 20MB root partition -wd0s1-1=ufs 40960 / -# And a 20MB swap partition -wd0s1-2=swap 40960 none -# Followed by a /usr partition using all remaining space (size 0 = free space) -wd0s1-3=ufs 0 /usr -# Let's do it! -diskLabelEditor - -################################ - -################################ -# Now partition the 2nd disk. -disk=wd1 -partition=exclusive -diskPartitionEditor - -wd1s1-1=ufs 40960 /var -wd1s1-2=ufs 0 /usr/src -diskLabelEditor -################################ - -################################ -# And the 3rd. -disk=da0 -partition=exclusive -diskPartitionEditor - -da0s1-1=swap 40960 none -da0s1-2=ufs 0 /tmp -diskLabelEditor -################################ - - -# OK, everything is set. Do it! -installCommit - -# Install some packages at the end. -package=bash-1.14.7 -packageAdd -package=ncftp-2.4.2 -packageAdd -package=tcsh-6.07.02 -packageAdd diff --git a/usr.sbin/sysinstall/installUpgrade.c b/usr.sbin/sysinstall/installUpgrade.c deleted file mode 100644 index 3cc4c2742214..000000000000 --- a/usr.sbin/sysinstall/installUpgrade.c +++ /dev/null @@ -1,481 +0,0 @@ -/* - * The new sysinstall program. - * - * This is probably the last program in the `sysinstall' line - the next - * generation being essentially a complete rewrite. - * - * $Id: installUpgrade.c,v 1.60 1998/11/03 03:38:55 jkh Exp $ - * - * Copyright (c) 1995 - * Jordan Hubbard. 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, - * verbatim and that no modifications are made prior to this - * point in the file. - * 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 JORDAN HUBBARD ``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 JORDAN HUBBARD OR HIS PETS 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, LIFE 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. - * - */ - -#include "sysinstall.h" -#include <sys/disklabel.h> -#include <sys/errno.h> -#include <sys/ioctl.h> -#include <sys/fcntl.h> -#include <sys/wait.h> -#include <sys/param.h> -#include <sys/stat.h> -#include <unistd.h> -#include <sys/mount.h> - -static int installUpgradeNonInteractive(dialogMenuItem *self); - -typedef struct _hitList { - enum { JUST_COPY, CALL_HANDLER } action ; - char *name; - Boolean optional; - void (*handler)(struct _hitList *self); -} HitList; - -/* These are the only meaningful files I know about */ -static HitList etc_files [] = { - { JUST_COPY, "Xaccel.ini", TRUE, NULL }, - { JUST_COPY, "adduser.conf", TRUE, NULL }, - { JUST_COPY, "aliases", TRUE, NULL }, - { JUST_COPY, "aliases.db", TRUE, NULL }, - { JUST_COPY, "amd.map", TRUE, NULL }, - { JUST_COPY, "crontab", TRUE, NULL }, - { JUST_COPY, "csh.cshrc", TRUE, NULL }, - { JUST_COPY, "csh.login", TRUE, NULL }, - { JUST_COPY, "csh.logout", TRUE, NULL }, - { JUST_COPY, "daily", TRUE, NULL }, - { JUST_COPY, "disktab", TRUE, NULL }, - { JUST_COPY, "dm.conf", TRUE, NULL }, - { JUST_COPY, "exports", TRUE, NULL }, - { JUST_COPY, "fbtab", TRUE, NULL }, - { JUST_COPY, "fstab", FALSE, NULL }, - { JUST_COPY, "ftpusers", TRUE, NULL }, - { JUST_COPY, "gettytab", TRUE, NULL }, - { JUST_COPY, "gnats", TRUE, NULL }, - { JUST_COPY, "group", FALSE, NULL }, - { JUST_COPY, "host.conf", TRUE, NULL }, - { JUST_COPY, "hosts", TRUE, NULL }, - { JUST_COPY, "hosts.equiv", TRUE, NULL }, - { JUST_COPY, "hosts.lpd", TRUE, NULL }, - { JUST_COPY, "inetd.conf", TRUE, NULL }, - { JUST_COPY, "kerberosIV", TRUE, NULL }, - { JUST_COPY, "localtime", TRUE, NULL }, - { JUST_COPY, "login.access", TRUE, NULL }, - { JUST_COPY, "mail.rc", TRUE, NULL }, - { JUST_COPY, "make.conf", TRUE, NULL }, - { JUST_COPY, "manpath.config", TRUE, NULL }, - { JUST_COPY, "master.passwd", TRUE, NULL }, - { JUST_COPY, "mib.txt", TRUE, NULL }, - { JUST_COPY, "modems", TRUE, NULL }, - { JUST_COPY, "monthly", TRUE, NULL }, - { JUST_COPY, "motd", TRUE, NULL }, - { JUST_COPY, "namedb", TRUE, NULL }, - { JUST_COPY, "networks", TRUE, NULL }, - { JUST_COPY, "newsyslog.conf", TRUE, NULL }, - { JUST_COPY, "passwd", FALSE, NULL }, - { JUST_COPY, "phones", TRUE, NULL }, - { JUST_COPY, "ppp", TRUE, NULL }, - { JUST_COPY, "printcap", TRUE, NULL }, - { JUST_COPY, "profile", TRUE, NULL }, - { JUST_COPY, "protocols", TRUE, NULL }, - { JUST_COPY, "pwd.db", TRUE, NULL }, - { JUST_COPY, "rc", TRUE, NULL }, - { JUST_COPY, "rc.firewall", TRUE, NULL }, - { JUST_COPY, "rc.i386", TRUE, NULL }, - { JUST_COPY, "rc.local", TRUE, NULL }, - { JUST_COPY, "rc.network", TRUE, NULL }, - { JUST_COPY, "rc.conf", FALSE, NULL }, - { JUST_COPY, "remote", TRUE, NULL }, - { JUST_COPY, "resolv.conf", TRUE, NULL }, - { JUST_COPY, "rmt", TRUE, NULL }, - { JUST_COPY, "security", TRUE, NULL }, - { JUST_COPY, "sendmail.cf", TRUE, NULL }, - { JUST_COPY, "services", TRUE, NULL }, - { JUST_COPY, "shells", TRUE, NULL }, - { JUST_COPY, "skeykeys", TRUE, NULL }, - { JUST_COPY, "spwd.db", TRUE, NULL }, - { JUST_COPY, "supfile", TRUE, NULL }, - { JUST_COPY, "syslog.conf", TRUE, NULL }, - { JUST_COPY, "termcap", TRUE, NULL }, - { JUST_COPY, "ttys", TRUE, NULL }, - { JUST_COPY, "uucp", TRUE, NULL }, - { JUST_COPY, "weekly", TRUE, NULL }, - { 0 }, -}; - -void -traverseHitlist(HitList *h) -{ - system("rm -rf /etc/upgrade"); - Mkdir("/etc/upgrade"); - while (h->name) { - if (!file_readable(h->name)) { - if (!h->optional) - msgConfirm("Unable to find an old /etc/%s file! That is decidedly non-standard and\n" - "your upgraded system may function a little strangely as a result.", h->name); - } - else { - if (h->action == JUST_COPY) { - /* Move the just-loaded copy aside */ - vsystem("mv /etc/%s /etc/upgrade/%s", h->name, h->name); - - /* Copy the old one into its place */ - msgNotify("Resurrecting %s..", h->name); - /* Do this with tar so that symlinks and such are preserved */ - if (vsystem("tar cf - %s | tar xpf - -C /etc", h->name)) - msgConfirm("Unable to resurrect your old /etc/%s! Hmmmm.", h->name); - } - else /* call handler */ - h->handler(h); - } - ++h; - } -} - -int -installUpgrade(dialogMenuItem *self) -{ - char saved_etc[FILENAME_MAX]; - Boolean extractingBin = TRUE; - - if (variable_get(VAR_NONINTERACTIVE)) - return installUpgradeNonInteractive(self); - - variable_set2(SYSTEM_STATE, "upgrade"); - systemDisplayHelp("UPGRADE"); - - dialog_clear_norefresh(); - if (msgYesNo("Given all that scary stuff you just read, are you sure you want to\n" - "risk it all and proceed with this upgrade?") != 0) - return DITEM_FAILURE | DITEM_RESTORE; - - if (!Dists) { - msgConfirm("First, you must select some distribution components. The upgrade procedure\n" - "will only upgrade the distributions you select in the next set of menus."); - if (!dmenuOpenSimple(&MenuDistributions, FALSE) || !Dists) - return DITEM_FAILURE | DITEM_RESTORE; - dialog_clear_norefresh(); - } - else if (!(Dists & DIST_BIN)) { /* No bin selected? Not much of an upgrade.. */ - if (msgYesNo("You didn't select the bin distribution as one of the distributons to load.\n" - "This one is pretty vital to a successful upgrade. Are you SURE you don't\n" - "want to select the bin distribution? Chose No to bring up the Distributions\n" - "menu again.") != 0) { - if (!dmenuOpenSimple(&MenuDistributions, FALSE)) - return DITEM_FAILURE | DITEM_RESTORE; - dialog_clear_norefresh(); - } - } - - /* Still?! OK! They must know what they're doing.. */ - if (!(Dists & DIST_BIN)) - extractingBin = FALSE; - - if (RunningAsInit) { - Device **devs; - int i, cnt; - char *cp; - - cp = variable_get(VAR_DISK); - devs = deviceFind(cp, DEVICE_TYPE_DISK); - cnt = deviceCount(devs); - if (!cnt) { - msgConfirm("No disks found! Please verify that your disk controller is being\n" - "properly probed at boot time. See the Hardware Guide on the\n" - "Documentation menu for clues on diagnosing this type of problem."); - return DITEM_FAILURE; - } - else { - /* Enable all the drives before we start */ - for (i = 0; i < cnt; i++) - devs[i]->enabled = TRUE; - } - - msgConfirm("OK. First, we're going to go to the disk label editor. In this editor\n" - "you will be expected to Mount any partitions you're interested in\n" - "upgrading. DO NOT set the Newfs flag to Y on anything in the label editor\n" - "unless you're absolutely sure you know what you're doing! In this\n" - "instance, you'll be using the label editor as little more than a fancy\n" - "screen-oriented partition mounting tool.\n\n" - "Once you're done in the label editor, press Q to return here for the next\n" - "step."); - - if (DITEM_STATUS(diskLabelEditor(self)) == DITEM_FAILURE) { - msgConfirm("The disk label editor returned an error status. Upgrade operation\n" - "aborted."); - return DITEM_FAILURE | DITEM_RESTORE; - } - - /* Don't write out MBR info */ - variable_set2(DISK_PARTITIONED, "written"); - if (DITEM_STATUS(diskLabelCommit(self)) == DITEM_FAILURE) { - msgConfirm("Not all file systems were properly mounted. Upgrade operation\n" - "aborted."); - variable_unset(DISK_PARTITIONED); - return DITEM_FAILURE | DITEM_RESTORE; - } - - msgNotify("Updating /stand on root filesystem"); - (void)vsystem("find -x /stand | cpio %s -pdum /mnt", cpioVerbosity()); - - if (DITEM_STATUS(chroot("/mnt")) == DITEM_FAILURE) { - msgConfirm("Unable to chroot to /mnt - something is wrong with the\n" - "root partition or the way it's mounted if this doesn't work."); - variable_unset(DISK_PARTITIONED); - return DITEM_FAILURE | DITEM_RESTORE; - } - chdir("/"); - installEnvironment(); - systemCreateHoloshell(); - } - - saved_etc[0] = '\0'; - if (extractingBin) { - while (!*saved_etc) { - char *cp = msgGetInput("/usr/tmp/etc", "Under which directory do you wish to save your current /etc?"); - - if (!cp || !*cp || Mkdir(cp)) { - if (msgYesNo("Directory was not specified, was invalid or user selected Cancel.\n\n" - "Doing an upgrade without first backing up your /etc directory is a very\n" - "bad idea! Do you want to go back and specify the save directory again?") != 0) - break; - } - else { - SAFE_STRCPY(saved_etc, cp); - } - } - - if (saved_etc[0]) { - msgNotify("Preserving /etc directory.."); - if (vsystem("tar -cBpf - -C /etc . | tar --unlink -xBpf - -C %s", saved_etc)) - if (msgYesNo("Unable to backup your /etc into %s.\n" - "Do you want to continue anyway?", saved_etc) != 0) - return DITEM_FAILURE | DITEM_RESTORE; - } - - msgNotify("chflags'ing old binaries - please wait."); - (void)vsystem("chflags -R noschg /bin /sbin /usr/sbin /usr/bin /usr/lib /kernel*"); - - if (file_readable("/kernel")) { - msgNotify("Moving old kernel to /kernel.prev"); - if (system("mv /kernel /kernel.prev")) { - if (!msgYesNo("Hmmm! I couldn't move the old kernel over! Do you want to\n" - "treat this as a big problem and abort the upgrade? Due to the\n" - "way that this upgrade process works, you will have to reboot\n" - "and start over from the beginning. Select Yes to reboot now")) - systemShutdown(1); - } - else - msgConfirm("NOTICE: Your old kernel is in /kernel.prev should this upgrade\n" - "fail for any reason and you need to boot your old kernel"); - } - } - -media: - /* We do this very late, but we unfortunately need to back up /etc first */ - if (!mediaVerify()) - return DITEM_FAILURE | DITEM_RESTORE; - - if (!mediaDevice->init(mediaDevice)) { - if (!msgYesNo("Couldn't initialize the media. Would you like\n" - "to adjust your media selection and try again?")) { - mediaDevice = NULL; - goto media; - } - else - return DITEM_FAILURE | DITEM_REDRAW; - } - - msgNotify("Beginning extraction of distributions.."); - if (DITEM_STATUS(distExtractAll(self)) == DITEM_FAILURE) { - msgConfirm("Hmmmm. We couldn't even extract the bin distribution. This upgrade\n" - "should be considered a failure and started from the beginning, sorry!\n" - "The system will reboot now."); - dialog_clear(); - systemShutdown(1); - } - else if (Dists) { - if (!extractingBin || !(Dists & DIST_BIN)) { - msgNotify("The extraction process seems to have had some problems, but we got most\n" - "of the essentials. We'll treat this as a warning since it may have been\n" - "only non-essential distributions which failed to load."); - } - else { - msgConfirm("Hmmmm. We couldn't even extract the bin distribution. This upgrade\n" - "should be considered a failure and started from the beginning, sorry!\n" - "The system will reboot now."); - dialog_clear(); - systemShutdown(1); - } - } - - msgNotify("First stage of upgrade completed successfully!\n\n" - "Next comes stage 2, where we attempt to resurrect your /etc\n" - "directory!"); - - if (saved_etc && chdir(saved_etc)) { - msgConfirm("Unable to go to your saved /etc directory in %s?! Argh!\n" - "Something went seriously wrong! It's quite possible that\n" - "your former /etc is toast. I hope you didn't have any\n" - "important customizations you wanted to keep in there.. :(", saved_etc); - } - else { - /* Now try to resurrect the /etc files */ - traverseHitlist(etc_files); - } - - msgConfirm("Upgrade completed! All of your old /etc files have been restored.\n" - "For your reference, the new /etc files are in /etc/upgrade/ in case\n" - "you wish to upgrade these files by hand (though that should not be\n" - "strictly necessary). If your root partition is specified in /etc/fstab\n" - "using the old \"compatibility\" slice, you may also wish to update it to\n" - "use a fully qualified slice name in order to avoid warnings on startup.\n\n" - "When you're ready to reboot into the new system, simply exit the installation."); - return DITEM_SUCCESS | DITEM_REDRAW; -} - -static int -installUpgradeNonInteractive(dialogMenuItem *self) -{ - char *saved_etc; - Boolean extractingBin = TRUE; - - variable_set2(SYSTEM_STATE, "upgrade"); - - /* Make sure at least BIN is selected */ - Dists |= DIST_BIN; - - if (RunningAsInit) { - Device **devs; - int i, cnt; - char *cp; - - cp = variable_get(VAR_DISK); - devs = deviceFind(cp, DEVICE_TYPE_DISK); - cnt = deviceCount(devs); - if (!cnt) { - msgConfirm("No disks found! Please verify that your disk controller is being\n" - "properly probed at boot time. See the Hardware Guide on the\n" - "Documentation menu for clues on diagnosing this type of problem."); - return DITEM_FAILURE; - } - else { - /* Enable all the drives befor we start */ - for (i = 0; i < cnt; i++) - devs[i]->enabled = TRUE; - } - - msgConfirm("OK. First, we're going to go to the disk label editor. In this editor\n" - "you will be expected to Mount any partitions you're interested in\n" - "upgrading. DO NOT set the Newfs flag to Y on anything in the label editor\n" - "unless you're absolutely sure you know what you're doing! In this\n" - "instance, you'll be using the label editor as little more than a fancy\n" - "screen-oriented partition mounting tool.\n\n" - "Once you're done in the label editor, press Q to return here for the next\n" - "step."); - - if (DITEM_STATUS(diskLabelEditor(self)) == DITEM_FAILURE) { - msgConfirm("The disk label editor returned an error status. Upgrade operation\n" - "aborted."); - return DITEM_FAILURE | DITEM_RESTORE; - } - - /* Don't write out MBR info */ - variable_set2(DISK_PARTITIONED, "written"); - if (DITEM_STATUS(diskLabelCommit(self)) == DITEM_FAILURE) { - msgConfirm("Not all file systems were properly mounted. Upgrade operation\n" - "aborted."); - variable_unset(DISK_PARTITIONED); - return DITEM_FAILURE | DITEM_RESTORE; - } - - if (extractingBin) { - msgNotify("chflags'ing old binaries - please wait."); - (void)vsystem("chflags -R noschg /mnt/"); - } - msgNotify("Updating /stand on root filesystem"); - (void)vsystem("find -x /stand | cpio %s -pdum /mnt", cpioVerbosity()); - - if (DITEM_STATUS(chroot("/mnt")) == DITEM_FAILURE) { - msgConfirm("Unable to chroot to /mnt - something is wrong with the\n" - "root partition or the way it's mounted if this doesn't work."); - variable_unset(DISK_PARTITIONED); - return DITEM_FAILURE | DITEM_RESTORE; - } - chdir("/"); - systemCreateHoloshell(); - } - - if (!mediaVerify() || !mediaDevice->init(mediaDevice)) { - msgNotify("Upgrade: Couldn't initialize media."); - return DITEM_FAILURE | DITEM_RESTORE; - } - - saved_etc = "/usr/tmp/etc"; - Mkdir(saved_etc); - msgNotify("Preserving /etc directory.."); - if (vsystem("tar -cpBf - -C /etc . | tar -xpBf - -C %s", saved_etc)) { - msgNotify("Unable to backup your /etc into %s.", saved_etc); - return DITEM_FAILURE | DITEM_RESTORE; - } - - if (file_readable("/kernel")) { - msgNotify("Moving old kernel to /kernel.prev"); - if (!system("chflags noschg /kernel && mv /kernel /kernel.prev")) { - /* Give us a working kernel in case we crash and reboot */ - system("cp /kernel.prev /kernel"); - } - } - - msgNotify("Beginning extraction of distributions.."); - if (DITEM_STATUS(distExtractAll(self)) == DITEM_FAILURE) { - msgConfirm("Hmmmm. We couldn't even extract the bin distribution. This upgrade\n" - "should be considered a failure and started from the beginning, sorry!\n" - "The system will reboot now."); - dialog_clear(); - systemShutdown(1); - } - else if (Dists) { - if (!(Dists & DIST_BIN)) { - msgNotify("The extraction process seems to have had some problems, but we got most\n" - "of the essentials. We'll treat this as a warning since it may have been\n" - "only non-essential distributions which failed to upgrade."); - } - else { - msgConfirm("Hmmmm. We couldn't even extract the bin distribution. This upgrade\n" - "should be considered a failure and started from the beginning, sorry!\n" - "The system will reboot now."); - dialog_clear(); - systemShutdown(1); - } - } - - msgNotify("First stage of upgrade completed successfully."); - if (vsystem("tar -cpBf - -C %s . | tar --unlink -xpBf - -C /etc", saved_etc)) { - msgNotify("Unable to resurrect your old /etc!"); - return DITEM_FAILURE | DITEM_RESTORE; - } - return DITEM_SUCCESS | DITEM_REDRAW; -} diff --git a/usr.sbin/sysinstall/keymap.c b/usr.sbin/sysinstall/keymap.c deleted file mode 100644 index 459f4cbe2860..000000000000 --- a/usr.sbin/sysinstall/keymap.c +++ /dev/null @@ -1,95 +0,0 @@ -/* - * Copyright (c) 1996 Joerg Wunsch - * - * 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 DEVELOPERS ``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 DEVELOPERS 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. - * - * $Id$ - * - */ - -#include "sysinstall.h" -#include <errno.h> -#include <stdlib.h> -#include <string.h> -#include <unistd.h> -#include <machine/console.h> - -struct keymapInfo { - const char *name; - const struct keymap *map; -}; - -#include "keymap.h" - -/* - * keymap.h is being automatically generated by the Makefile. It - * contains definitions for all desired keymaps. Note that since we - * don't support font loading nor screen mapping during installation, - * we simply don't care for any other keys than the ASCII subset. - * - * Therefore, if no keymap with the exact name has been found in the - * first pass, we make a second pass over the table looking just for - * the language name only. - */ - -/* - * Return values: - * - * 0: OK - * -1: no appropriate keymap found - * -2: error installing map (other than ENXIO which means we're not on syscons) - */ - -int -loadKeymap(const char *lang) -{ - int passno, err; - char *llang; - size_t l; - struct keymapInfo *kip; - - llang = strdup(lang); - if (llang == NULL) - abort(); - - for (passno = 0; passno < 2; passno++) - { - if (passno > 0) - { - /* make the match more fuzzy */ - l = strspn(llang, "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"); - llang[l] = '\0'; - } - - l = strlen(llang); - - for (kip = keymapInfos; kip->name; kip++) - if (strncmp(kip->name, llang, l) == 0) - { - /* Yep, got it! */ - err = ioctl(0, PIO_KEYMAP, kip->map); - free(llang); - return (err == -1 && errno != ENOTTY)? -2: 0; - } - } - free(llang); - return -1; -} diff --git a/usr.sbin/sysinstall/kget.c b/usr.sbin/sysinstall/kget.c deleted file mode 100644 index a71a25e025b7..000000000000 --- a/usr.sbin/sysinstall/kget.c +++ /dev/null @@ -1,104 +0,0 @@ -/*- - * Copyright (c) 1999 Andrzej Bialecki <abial@freebsd.org> - * 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 THE AUTHOR 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 AUTHOR 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. - * - * $Id: kget.c,v 1.2 1999/01/19 23:15:56 abial Exp $ - */ - -#include "sysinstall.h" -#include "i386/isa/isa_device.h" -#include <sys/sysctl.h> - -int -kget(char *out) -{ - int len, i, bytes_written = 0; - char *buf; - char *mib = "machdep.uc_devlist"; - char name[9]; - FILE *fout; - struct isa_device *id; - char *p; - - fout = fopen(out, "w"); - if (fout == NULL) { - msgDebug("kget: Unable to open %s for writing.\n", out); - return -1; - } - - /* We use sysctlbyname, because the oid is unknown (OID_AUTO) */ - /* get the buffer size */ - i = sysctlbyname(mib, NULL, &len, NULL, NULL); - if (i) { - msgDebug("kget: error buffer sizing\n"); - return -1; - } - buf = (char *)malloc(len * sizeof(char)); - i = sysctlbyname(mib, buf, &len, NULL, NULL); - if (i) { - msgDebug("kget: error retrieving data\n"); - return -1; - } - i = 0; - while (i < len) { - id = (struct isa_device *)(buf + i); - p = (buf + i + sizeof(struct isa_device)); - strncpy(name, p, 8); - if (!id->id_enabled) { - bytes_written += fprintf(fout, "di %s%d\n", name, id->id_unit); - } else { - bytes_written += fprintf(fout, "en %s%d\n", name, id->id_unit); - if (id->id_iobase > 0) { - bytes_written += fprintf(fout, "po %s%d %#x\n", - name, id->id_unit, id->id_iobase); - } - if (id->id_irq > 0) { - bytes_written += fprintf(fout, "ir %s%d %d\n", name, - id->id_unit, ffs(id->id_irq) - 1); - } - if (id->id_drq > 0) { - bytes_written += fprintf(fout, "dr %s%d %d\n", name, - id->id_unit, id->id_drq); - } - if (id->id_maddr > 0) { - bytes_written += fprintf(fout, "iom %s%d %#x\n", name, - id->id_unit, (u_int)id->id_maddr); - } - if (id->id_msize > 0) { - bytes_written += fprintf(fout, "ios %s%d %d\n", name, - id->id_unit, id->id_msize); - } - bytes_written += fprintf(fout, "f %s%d %#x\n", name, - id->id_unit, id->id_flags); - } - i += sizeof(struct isa_device) + 8; - } - if (bytes_written) - fprintf(fout, "q\n"); - else - unlink(out); - fclose(fout); - free(buf); - return 0; -} diff --git a/usr.sbin/sysinstall/label.c b/usr.sbin/sysinstall/label.c deleted file mode 100644 index ea49bbe0a169..000000000000 --- a/usr.sbin/sysinstall/label.c +++ /dev/null @@ -1,1268 +0,0 @@ -/* - * The new sysinstall program. - * - * This is probably the last program in the `sysinstall' line - the next - * generation being essentially a complete rewrite. - * - * $Id: label.c,v 1.83 1998/07/18 09:42:01 jkh Exp $ - * - * Copyright (c) 1995 - * Jordan Hubbard. 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, - * verbatim and that no modifications are made prior to this - * point in the file. - * 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 JORDAN HUBBARD ``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 JORDAN HUBBARD OR HIS PETS 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, LIFE 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. - * - */ - -#include "sysinstall.h" -#include <ctype.h> -#include <sys/disklabel.h> -#include <sys/param.h> -#include <sys/sysctl.h> - -/* - * Everything to do with editing the contents of disk labels. - */ - -/* A nice message we use a lot in the disklabel editor */ -#define MSG_NOT_APPLICABLE "That option is not applicable here" - -/* Where to start printing the freebsd slices */ -#define CHUNK_SLICE_START_ROW 2 -#define CHUNK_PART_START_ROW 11 - -/* The smallest filesystem we're willing to create */ -#define FS_MIN_SIZE ONE_MEG - -/* The smallest root filesystem we're willing to create */ -#define ROOT_MIN_SIZE 20 - -/* The smallest swap partition we want to create by default */ -#define SWAP_MIN_SIZE 16 - -/* The smallest /usr partition we're willing to create by default */ -#define USR_MIN_SIZE 80 - -/* The smallest /var partition we're willing to create by default */ -#define VAR_MIN_SIZE 30 - -/* The bottom-most row we're allowed to scribble on */ -#define CHUNK_ROW_MAX 16 - - -/* All the chunks currently displayed on the screen */ -static struct { - struct chunk *c; - PartType type; -} label_chunk_info[MAX_CHUNKS + 1]; -static int here; - -/*** with this value we try to track the most recently added label ***/ -static int label_focus = 0, pslice_focus = 0; - -static int diskLabel(Device *dev); -static int diskLabelNonInteractive(Device *dev); - -static int -labelHook(dialogMenuItem *selected) -{ - Device **devs = NULL; - - devs = deviceFind(selected->prompt, DEVICE_TYPE_DISK); - if (!devs) { - msgConfirm("Unable to find disk %s!", selected->prompt); - return DITEM_FAILURE; - } - /* Toggle enabled status? */ - if (!devs[0]->enabled) { - devs[0]->enabled = TRUE; - diskLabel(devs[0]); - } - else - devs[0]->enabled = FALSE; - return DITEM_SUCCESS | DITEM_RESTORE; -} - -static int -labelCheck(dialogMenuItem *selected) -{ - Device **devs = NULL; - - devs = deviceFind(selected->prompt, DEVICE_TYPE_DISK); - if (!devs || devs[0]->enabled == FALSE) - return FALSE; - return TRUE; -} - -int -diskLabelEditor(dialogMenuItem *self) -{ - DMenu *menu; - Device **devs; - int i, cnt; - - i = 0; - cnt = diskGetSelectCount(&devs); - if (cnt == -1) { - msgConfirm("No disks found! Please verify that your disk controller is being\n" - "properly probed at boot time. See the Hardware Guide on the\n" - "Documentation menu for clues on diagnosing this type of problem."); - return DITEM_FAILURE; - } - else if (cnt) { - /* Some are already selected */ - if (variable_get(VAR_NONINTERACTIVE)) - i = diskLabelNonInteractive(NULL); - else - i = diskLabel(NULL); - } - else { - /* No disks are selected, fall-back case now */ - cnt = deviceCount(devs); - if (cnt == 1) { - devs[0]->enabled = TRUE; - if (variable_get(VAR_NONINTERACTIVE)) - i = diskLabelNonInteractive(devs[0]); - else - i = diskLabel(devs[0]); - } - else { - menu = deviceCreateMenu(&MenuDiskDevices, DEVICE_TYPE_DISK, labelHook, labelCheck); - if (!menu) { - msgConfirm("No devices suitable for installation found!\n\n" - "Please verify that your disk controller (and attached drives)\n" - "were detected properly. This can be done by pressing the\n" - "[Scroll Lock] key and using the Arrow keys to move back to\n" - "the boot messages. Press [Scroll Lock] again to return."); - i = DITEM_FAILURE; - } - else { - i = dmenuOpenSimple(menu, FALSE) ? DITEM_SUCCESS : DITEM_FAILURE; - free(menu); - } - i |= DITEM_RESTORE; - } - } - if (DITEM_STATUS(i) != DITEM_FAILURE) { - char *cp; - - if (((cp = variable_get(DISK_LABELLED)) == NULL) || (strcmp(cp, "written"))) - variable_set2(DISK_LABELLED, "yes"); - } - return i; -} - -int -diskLabelCommit(dialogMenuItem *self) -{ - char *cp; - int i; - - /* Already done? */ - if ((cp = variable_get(DISK_LABELLED)) && strcmp(cp, "yes")) - i = DITEM_SUCCESS; - else if (!cp) { - msgConfirm("You must assign disk labels before this option can be used."); - i = DITEM_FAILURE; - } - /* The routine will guard against redundant writes, just as this one does */ - else if (DITEM_STATUS(diskPartitionWrite(self)) != DITEM_SUCCESS) - i = DITEM_FAILURE; - else if (DITEM_STATUS(installFilesystems(self)) != DITEM_SUCCESS) - i = DITEM_FAILURE; - else { - msgInfo("All filesystem information written successfully."); - variable_set2(DISK_LABELLED, "written"); - i = DITEM_SUCCESS; - } - return i; -} - -/* See if we're already using a desired partition name */ -static Boolean -check_conflict(char *name) -{ - int i; - - for (i = 0; label_chunk_info[i].c; i++) - if ((label_chunk_info[i].type == PART_FILESYSTEM || label_chunk_info[i].type == PART_FAT) - && label_chunk_info[i].c->private_data - && !strcmp(((PartInfo *)label_chunk_info[i].c->private_data)->mountpoint, name)) - return TRUE; - return FALSE; -} - -/* How much space is in this FreeBSD slice? */ -static int -space_free(struct chunk *c) -{ - struct chunk *c1; - int sz = c->size; - - for (c1 = c->part; c1; c1 = c1->next) { - if (c1->type != unused) - sz -= c1->size; - } - if (sz < 0) - msgFatal("Partitions are larger than actual chunk??"); - return sz; -} - -/* Snapshot the current situation into the displayed chunks structure */ -static void -record_label_chunks(Device **devs, Device *dev) -{ - int i, j, p; - struct chunk *c1, *c2; - Disk *d; - - j = p = 0; - /* First buzz through and pick up the FreeBSD slices */ - for (i = 0; devs[i]; i++) { - if ((dev && devs[i] != dev) || !devs[i]->enabled) - continue; - d = (Disk *)devs[i]->private; - if (!d->chunks) - msgFatal("No chunk list found for %s!", d->name); - - /* Put the slice entries first */ - for (c1 = d->chunks->part; c1; c1 = c1->next) { - if (c1->type == freebsd) { - label_chunk_info[j].type = PART_SLICE; - label_chunk_info[j].c = c1; - ++j; - } - } - } - - /* Now run through again and get the FreeBSD partition entries */ - for (i = 0; devs[i]; i++) { - if (!devs[i]->enabled) - continue; - d = (Disk *)devs[i]->private; - /* Then buzz through and pick up the partitions */ - for (c1 = d->chunks->part; c1; c1 = c1->next) { - if (c1->type == freebsd) { - for (c2 = c1->part; c2; c2 = c2->next) { - if (c2->type == part) { - if (c2->subtype == FS_SWAP) - label_chunk_info[j].type = PART_SWAP; - else - label_chunk_info[j].type = PART_FILESYSTEM; - label_chunk_info[j].c = c2; - ++j; - } - } - } - else if (c1->type == fat) { - label_chunk_info[j].type = PART_FAT; - label_chunk_info[j].c = c1; - ++j; - } - } - } - label_chunk_info[j].c = NULL; - if (here >= j) { - here = j ? j - 1 : 0; - } -} - -/* A new partition entry */ -static PartInfo * -new_part(char *mpoint, Boolean newfs, u_long size) -{ - PartInfo *ret; - - if (!mpoint) - mpoint = "/change_me"; - - ret = (PartInfo *)safe_malloc(sizeof(PartInfo)); - sstrncpy(ret->mountpoint, mpoint, FILENAME_MAX); - strcpy(ret->newfs_cmd, "newfs -b 8192 -f 1024"); - ret->newfs = newfs; - if (!size) - return ret; - return ret; -} - -/* Get the mountpoint for a partition and save it away */ -static PartInfo * -get_mountpoint(struct chunk *old) -{ - char *val; - PartInfo *tmp; - - if (old && old->private_data) - tmp = old->private_data; - else - tmp = NULL; - if (!old) { - DialogX = 14; - DialogY = 16; - } - val = msgGetInput(tmp ? tmp->mountpoint : NULL, "Please specify a mount point for the partition"); - DialogX = DialogY = 0; - if (!val || !*val) { - if (!old) - return NULL; - else { - free(old->private_data); - old->private_data = NULL; - } - return NULL; - } - - /* Is it just the same value? */ - if (tmp && !strcmp(tmp->mountpoint, val)) - return NULL; - - /* Did we use it already? */ - if (check_conflict(val)) { - msgConfirm("You already have a mount point for %s assigned!", val); - return NULL; - } - - /* Is it bogus? */ - if (*val != '/') { - msgConfirm("Mount point must start with a / character"); - return NULL; - } - - /* Is it going to be mounted on root? */ - if (!strcmp(val, "/")) { - if (old) - old->flags |= CHUNK_IS_ROOT; - } - else if (old) - old->flags &= ~CHUNK_IS_ROOT; - - safe_free(tmp); - tmp = new_part(val, TRUE, 0); - if (old) { - old->private_data = tmp; - old->private_free = safe_free; - } - return tmp; -} - -/* Get the type of the new partiton */ -static PartType -get_partition_type(void) -{ - char selection[20]; - int i; - - static unsigned char *fs_types[] = { - "FS", - "A file system", - "Swap", - "A swap partition.", - }; - DialogX = 7; - DialogY = 8; - i = dialog_menu("Please choose a partition type", - "If you want to use this partition for swap space, select Swap.\n" - "If you want to put a filesystem on it, choose FS.", - -1, -1, 2, 2, fs_types, selection, NULL, NULL); - DialogX = DialogY = 0; - if (!i) { - if (!strcmp(selection, "FS")) - return PART_FILESYSTEM; - else if (!strcmp(selection, "Swap")) - return PART_SWAP; - } - return PART_NONE; -} - -/* If the user wants a special newfs command for this, set it */ -static void -getNewfsCmd(PartInfo *p) -{ - char *val; - - val = msgGetInput(p->newfs_cmd, - "Please enter the newfs command and options you'd like to use in\n" - "creating this file system."); - if (val) - sstrncpy(p->newfs_cmd, val, NEWFS_CMD_MAX); -} - -#define MAX_MOUNT_NAME 12 - -#define PART_PART_COL 0 -#define PART_MOUNT_COL 8 -#define PART_SIZE_COL (PART_MOUNT_COL + MAX_MOUNT_NAME + 3) -#define PART_NEWFS_COL (PART_SIZE_COL + 7) -#define PART_OFF 38 - -#define TOTAL_AVAIL_LINES (10) -#define PSLICE_SHOWABLE (4) - - -/* stick this all up on the screen */ -static void -print_label_chunks(void) -{ - int i, j, srow, prow, pcol; - int sz; - char clrmsg[80]; - int ChunkPartStartRow; - WINDOW *ChunkWin; - - /********************************************************/ - /*** These values are for controling screen resources ***/ - /*** Each label line holds up to 2 labels, so beware! ***/ - /*** strategy will be to try to always make sure the ***/ - /*** highlighted label is in the active display area. ***/ - /********************************************************/ - int pslice_max, label_max; - int pslice_count, label_count, label_focus_found, pslice_focus_found; - - attrset(A_REVERSE); - mvaddstr(0, 25, "FreeBSD Disklabel Editor"); - attrset(A_NORMAL); - - /*** Count the number of parition slices ***/ - pslice_count = 0; - for (i = 0; label_chunk_info[i].c ; i++) { - if (label_chunk_info[i].type == PART_SLICE) - ++pslice_count; - } - pslice_max = pslice_count; - - /*** 4 line max for partition slices ***/ - if (pslice_max > PSLICE_SHOWABLE) { - pslice_max = PSLICE_SHOWABLE; - } - ChunkPartStartRow = CHUNK_SLICE_START_ROW + 3 + pslice_max; - - /*** View partition slices modulo pslice_max ***/ - label_max = TOTAL_AVAIL_LINES - pslice_max; - - for (i = 0; i < 2; i++) { - mvaddstr(ChunkPartStartRow - 2, PART_PART_COL + (i * PART_OFF), "Part"); - mvaddstr(ChunkPartStartRow - 1, PART_PART_COL + (i * PART_OFF), "----"); - - mvaddstr(ChunkPartStartRow - 2, PART_MOUNT_COL + (i * PART_OFF), "Mount"); - mvaddstr(ChunkPartStartRow - 1, PART_MOUNT_COL + (i * PART_OFF), "-----"); - - mvaddstr(ChunkPartStartRow - 2, PART_SIZE_COL + (i * PART_OFF) + 2, "Size"); - mvaddstr(ChunkPartStartRow - 1, PART_SIZE_COL + (i * PART_OFF) + 2, "----"); - - mvaddstr(ChunkPartStartRow - 2, PART_NEWFS_COL + (i * PART_OFF), "Newfs"); - mvaddstr(ChunkPartStartRow - 1, PART_NEWFS_COL + (i * PART_OFF), "-----"); - } - srow = CHUNK_SLICE_START_ROW; - prow = 0; - pcol = 0; - - /*** these variables indicate that the focused item is shown currently ***/ - label_focus_found = 0; - pslice_focus_found = 0; - - label_count = 0; - pslice_count = 0; - mvprintw(CHUNK_SLICE_START_ROW - 1, 0, " "); - mvprintw(CHUNK_SLICE_START_ROW + pslice_max, 0, " "); - - ChunkWin = newwin(CHUNK_ROW_MAX - ChunkPartStartRow, 76, ChunkPartStartRow, 0); - - wclear(ChunkWin); - /*** wrefresh(ChunkWin); ***/ - - for (i = 0; label_chunk_info[i].c; i++) { - /* Is it a slice entry displayed at the top? */ - if (label_chunk_info[i].type == PART_SLICE) { - /*** This causes the new pslice to replace the previous display ***/ - /*** focus must remain on the most recently active pslice ***/ - if (pslice_count == pslice_max) { - if (pslice_focus_found) { - /*** This is where we can mark the more following ***/ - attrset(A_BOLD); - mvprintw(CHUNK_SLICE_START_ROW + pslice_max, 0, "***MORE***"); - attrset(A_NORMAL); - continue; - } - else { - /*** this is where we set the more previous ***/ - attrset(A_BOLD); - mvprintw(CHUNK_SLICE_START_ROW - 1, 0, "***MORE***"); - attrset(A_NORMAL); - pslice_count = 0; - srow = CHUNK_SLICE_START_ROW; - } - } - - sz = space_free(label_chunk_info[i].c); - if (i == here) - attrset(ATTR_SELECTED); - if (i == pslice_focus) - pslice_focus_found = -1; - - mvprintw(srow++, 0, - "Disk: %s\tPartition name: %s\tFree: %d blocks (%dMB)", - label_chunk_info[i].c->disk->name, label_chunk_info[i].c->name, - sz, (sz / ONE_MEG)); - attrset(A_NORMAL); - clrtoeol(); - move(0, 0); - /*** refresh(); ***/ - ++pslice_count; - } - /* Otherwise it's a DOS, swap or filesystem entry in the Chunk window */ - else { - char onestr[PART_OFF], num[10], *mountpoint, *newfs; - - /* - * We copy this into a blank-padded string so that it looks like - * a solid bar in reverse-video - */ - memset(onestr, ' ', PART_OFF - 1); - onestr[PART_OFF - 1] = '\0'; - - /*** Track how many labels have been displayed ***/ - if (label_count == ((label_max - 1 ) * 2)) { - if (label_focus_found) { - continue; - } - else { - label_count = 0; - prow = 0; - pcol = 0; - } - } - - /* Go for two columns if we've written one full columns worth */ - /*** if (prow == (CHUNK_ROW_MAX - ChunkPartStartRow)) ***/ - if (label_count == label_max - 1) { - pcol = PART_OFF; - prow = 0; - } - memcpy(onestr + PART_PART_COL, label_chunk_info[i].c->name, strlen(label_chunk_info[i].c->name)); - /* If it's a filesystem, display the mountpoint */ - if (label_chunk_info[i].c->private_data - && (label_chunk_info[i].type == PART_FILESYSTEM || label_chunk_info[i].type == PART_FAT)) - mountpoint = ((PartInfo *)label_chunk_info[i].c->private_data)->mountpoint; - else if (label_chunk_info[i].type == PART_SWAP) - mountpoint = "swap"; - else - mountpoint = "<none>"; - - /* Now display the newfs field */ - if (label_chunk_info[i].type == PART_FAT) - newfs = "DOS"; - else if (label_chunk_info[i].c->private_data && label_chunk_info[i].type == PART_FILESYSTEM) - newfs = ((PartInfo *)label_chunk_info[i].c->private_data)->newfs ? "UFS Y" : "UFS N"; - else if (label_chunk_info[i].type == PART_SWAP) - newfs = "SWAP"; - else - newfs = "*"; - for (j = 0; j < MAX_MOUNT_NAME && mountpoint[j]; j++) - onestr[PART_MOUNT_COL + j] = mountpoint[j]; - snprintf(num, 10, "%4ldMB", label_chunk_info[i].c->size ? label_chunk_info[i].c->size / ONE_MEG : 0); - memcpy(onestr + PART_SIZE_COL, num, strlen(num)); - memcpy(onestr + PART_NEWFS_COL, newfs, strlen(newfs)); - onestr[PART_NEWFS_COL + strlen(newfs)] = '\0'; - if (i == label_focus) { - label_focus_found = -1; - wattrset(ChunkWin, A_BOLD); - } - if (i == here) - wattrset(ChunkWin, ATTR_SELECTED); - - /*** lazy man's way of padding this string ***/ - while (strlen( onestr ) < 37) - strcat(onestr, " "); - - mvwaddstr(ChunkWin, prow, pcol, onestr); - wattrset(ChunkWin, A_NORMAL); - move(0, 0); - ++prow; - ++label_count; - } - } - - /*** this will erase all the extra stuff ***/ - memset(clrmsg, ' ', 37); - clrmsg[37] = '\0'; - - while (pslice_count < pslice_max) { - mvprintw(srow++, 0, clrmsg); - clrtoeol(); - ++pslice_count; - } - while (label_count < (2 * (label_max - 1))) { - mvwaddstr(ChunkWin, prow++, pcol, clrmsg); - ++label_count; - if (prow == (label_max - 1)) { - prow = 0; - pcol = PART_OFF; - } - } - refresh(); - wrefresh(ChunkWin); -} - -static void -print_command_summary(void) -{ - mvprintw(17, 0, "The following commands are valid here (upper or lower case):"); - mvprintw(18, 0, "C = Create D = Delete M = Mount pt."); - if (!RunningAsInit) - mvprintw(18, 49, "W = Write"); - mvprintw(19, 0, "N = Newfs Opts T = Newfs Toggle U = Undo Q = Finish"); - mvprintw(20, 0, "A = Auto Defaults for all!"); - mvprintw(22, 0, "Use F1 or ? to get more help, arrow keys to select."); - move(0, 0); -} - -static void -clear_wins(void) -{ - extern void print_label_chunks(); - clear(); - print_label_chunks(); -} - -static int -diskLabel(Device *dev) -{ - int sz, key = 0; - Boolean labeling; - char *msg = NULL; - PartInfo *p, *oldp; - PartType type; - Device **devs; -#ifdef __alpha__ - int i; -#endif - - label_focus = 0; - pslice_focus = 0; - here = 0; - - devs = deviceFind(NULL, DEVICE_TYPE_DISK); - if (!devs) { - msgConfirm("No disks found!"); - return DITEM_FAILURE; - } - labeling = TRUE; - keypad(stdscr, TRUE); -#ifdef __alpha__ - for (i = 0; devs[i]; i++) { - All_FreeBSD((Disk*) devs[i]->private, 1); - } -#endif - record_label_chunks(devs, dev); - - clear(); - while (labeling) { - char *cp; - - print_label_chunks(); - print_command_summary(); - if (msg) { - attrset(title_attr); mvprintw(23, 0, msg); attrset(A_NORMAL); - clrtoeol(); - beep(); - msg = NULL; - } - else { - move(23, 0); - clrtoeol(); - } - - refresh(); - key = getch(); - switch (toupper(key)) { - int i; - static char _msg[40]; - - case '\014': /* ^L */ - clear_wins(); - break; - - case '\020': /* ^P */ - case KEY_UP: - case '-': - if (here != 0) - --here; - else - while (label_chunk_info[here + 1].c) - ++here; - break; - - case '\016': /* ^N */ - case KEY_DOWN: - case '+': - case '\r': - case '\n': - if (label_chunk_info[here + 1].c) - ++here; - else - here = 0; - break; - - case KEY_HOME: - here = 0; - break; - - case KEY_END: - while (label_chunk_info[here + 1].c) - ++here; - break; - - case KEY_F(1): - case '?': - systemDisplayHelp("partition"); - clear_wins(); - break; - - case 'A': - if (label_chunk_info[here].type != PART_SLICE) { - msg = "You can only do this in a disk slice (at top of screen)"; - break; - } - sz = space_free(label_chunk_info[here].c); - if (sz <= FS_MIN_SIZE) - msg = "Not enough free space to create a new partition in the slice"; - else { - struct chunk *tmp; - int mib[2]; - int physmem; - size_t size, swsize; - char *cp; - Chunk *rootdev, *swapdev, *usrdev, *vardev; - - (void)checkLabels(FALSE, &rootdev, &swapdev, &usrdev, &vardev); - if (!rootdev) { - cp = variable_get(VAR_ROOT_SIZE); - tmp = Create_Chunk_DWIM(label_chunk_info[here].c->disk, label_chunk_info[here].c, - (cp ? atoi(cp) : 32) * ONE_MEG, part, FS_BSDFFS, CHUNK_IS_ROOT); - if (!tmp) { - msgConfirm("Unable to create the root partition. Too big?"); - clear_wins(); - break; - } - tmp->private_data = new_part("/", TRUE, tmp->size); - tmp->private_free = safe_free; - record_label_chunks(devs, dev); - } - - if (!swapdev) { - cp = variable_get(VAR_SWAP_SIZE); - if (cp) - swsize = atoi(cp) * ONE_MEG; - else { - mib[0] = CTL_HW; - mib[1] = HW_PHYSMEM; - size = sizeof physmem; - sysctl(mib, 2, &physmem, &size, (void *)0, (size_t)0); - swsize = 16 * ONE_MEG + (physmem * 2 / 512); - } - tmp = Create_Chunk_DWIM(label_chunk_info[here].c->disk, label_chunk_info[here].c, - swsize, part, FS_SWAP, 0); - if (!tmp) { - msgConfirm("Unable to create the swap partition. Too big?"); - clear_wins(); - break; - } - tmp->private_data = 0; - tmp->private_free = safe_free; - record_label_chunks(devs, dev); - } - - if (!vardev) { - cp = variable_get(VAR_VAR_SIZE); - if (cp) - sz = atoi(cp) * ONE_MEG; - else - sz = variable_get(VAR_NO_USR) - ? space_free(label_chunk_info[here].c) - : VAR_MIN_SIZE * ONE_MEG; - - tmp = Create_Chunk_DWIM(label_chunk_info[here].c->disk, label_chunk_info[here].c, - sz, part, FS_BSDFFS, 0); - if (!tmp) { - msgConfirm("Less than %dMB free for /var - you will need to\n" - "partition your disk manually with a custom install!", - (cp ? atoi(cp) : VAR_MIN_SIZE)); - clear_wins(); - break; - } - tmp->private_data = new_part("/var", TRUE, tmp->size); - tmp->private_free = safe_free; - record_label_chunks(devs, dev); - } - - if (!usrdev && !variable_get(VAR_NO_USR)) { - cp = variable_get(VAR_USR_SIZE); - if (cp) - sz = atoi(cp) * ONE_MEG; - else - sz = space_free(label_chunk_info[here].c); - if (sz) { - if (sz < (USR_MIN_SIZE * ONE_MEG)) { - msgConfirm("Less than %dMB free for /usr - you will need to\n" - "partition your disk manually with a custom install!", USR_MIN_SIZE); - clear_wins(); - break; - } - - tmp = Create_Chunk_DWIM(label_chunk_info[here].c->disk, - label_chunk_info[here].c, - sz, part, FS_BSDFFS, 0); - if (!tmp) { - msgConfirm("Unable to create the /usr partition. Not enough space?\n" - "You will need to partition your disk manually with a custom install!"); - clear_wins(); - break; - } - tmp->private_data = new_part("/usr", TRUE, tmp->size); - tmp->private_free = safe_free; - record_label_chunks(devs, dev); - } - } - - /* At this point, we're reasonably "labelled" */ - if (((cp = variable_get(DISK_LABELLED)) == NULL) || (strcmp(cp, "written"))) - variable_set2(DISK_LABELLED, "yes"); - } - break; - - case 'C': - if (label_chunk_info[here].type != PART_SLICE) { - msg = "You can only do this in a master partition (see top of screen)"; - break; - } - sz = space_free(label_chunk_info[here].c); - if (sz <= FS_MIN_SIZE) { - msg = "Not enough space to create an additional FreeBSD partition"; - break; - } - else { - char *val; - int size; - struct chunk *tmp; - char osize[80]; - u_long flags = 0; - - sprintf(osize, "%d", sz); - DialogX = 3; - DialogY = 2; - val = msgGetInput(osize, - "Please specify the partition size in blocks or append a trailing M for\n" - "megabytes or C for cylinders. %d blocks (%dMB) are free.", - sz, sz / ONE_MEG); - DialogX = DialogY = 0; - if (!val || (size = strtol(val, &cp, 0)) <= 0) { - clear_wins(); - break; - } - - if (*cp) { - if (toupper(*cp) == 'M') - size *= ONE_MEG; - else if (toupper(*cp) == 'C') - size *= (label_chunk_info[here].c->disk->bios_hd * label_chunk_info[here].c->disk->bios_sect); - } - if (size <= FS_MIN_SIZE) { - msgConfirm("The minimum filesystem size is %dMB", FS_MIN_SIZE / ONE_MEG); - clear_wins(); - break; - } - type = get_partition_type(); - if (type == PART_NONE) { - clear_wins(); - beep(); - break; - } - - if (type == PART_FILESYSTEM) { - if ((p = get_mountpoint(NULL)) == NULL) { - clear_wins(); - beep(); - break; - } - else if (!strcmp(p->mountpoint, "/")) - flags |= CHUNK_IS_ROOT; - else - flags &= ~CHUNK_IS_ROOT; - } - else - p = NULL; - - if ((flags & CHUNK_IS_ROOT)) { - if (!(label_chunk_info[here].c->flags & CHUNK_BSD_COMPAT)) { - msgConfirm("This region cannot be used for your root partition as the\n" - "FreeBSD boot code cannot deal with a root partition created\n" - "in that location. Please choose another location or smaller\n" - "size for your root partition and try again!"); - clear_wins(); - break; - } - if (size < (ROOT_MIN_SIZE * ONE_MEG)) { - msgConfirm("Warning: This is smaller than the recommended size for a\n" - "root partition. For a variety of reasons, root\n" - "partitions should usually be at least %dMB in size", ROOT_MIN_SIZE); - } - } - tmp = Create_Chunk_DWIM(label_chunk_info[here].c->disk, - label_chunk_info[here].c, - size, part, - (type == PART_SWAP) ? FS_SWAP : FS_BSDFFS, - flags); - if (!tmp) { - msgConfirm("Unable to create the partition. Too big?"); - clear_wins(); - break; - } - if ((flags & CHUNK_IS_ROOT) && (tmp->flags & CHUNK_PAST_1024)) { - msgConfirm("This region cannot be used for your root partition as it starts\n" - "or extends past the 1024'th cylinder mark and is thus a\n" - "poor location to boot from. Please choose another\n" - "location (or smaller size) for your root partition and try again!"); - Delete_Chunk(label_chunk_info[here].c->disk, tmp); - clear_wins(); - break; - } - if (type != PART_SWAP) { - /* This is needed to tell the newfs -u about the size */ - tmp->private_data = new_part(p->mountpoint, p->newfs, tmp->size); - safe_free(p); - } - else - tmp->private_data = p; - tmp->private_free = safe_free; - if (((cp = variable_get(DISK_LABELLED)) == NULL) || (strcmp(cp, "written"))) - variable_set2(DISK_LABELLED, "yes"); - record_label_chunks(devs, dev); - clear_wins(); - /*** This is where we assign focus to new label so it shows ***/ - { - int i; - label_focus = -1; - for (i = 0; label_chunk_info[i].c; ++i) { - if (label_chunk_info[i].c == tmp) { - label_focus = i; - break; - } - } - if (label_focus == -1) - label_focus = i - 1; - } - } - break; - - case KEY_DC: - case 'D': /* delete */ - if (label_chunk_info[here].type == PART_SLICE) { - msg = MSG_NOT_APPLICABLE; - break; - } - else if (label_chunk_info[here].type == PART_FAT) { - msg = "Use the Disk Partition Editor to delete DOS partitions"; - break; - } - Delete_Chunk(label_chunk_info[here].c->disk, label_chunk_info[here].c); - if (((cp = variable_get(DISK_LABELLED)) == NULL) || (strcmp(cp, "written"))) - variable_set2(DISK_LABELLED, "yes"); - record_label_chunks(devs, dev); - break; - - case 'M': /* mount */ - switch(label_chunk_info[here].type) { - case PART_SLICE: - msg = MSG_NOT_APPLICABLE; - break; - - case PART_SWAP: - msg = "You don't need to specify a mountpoint for a swap partition."; - break; - - case PART_FAT: - case PART_FILESYSTEM: - oldp = label_chunk_info[here].c->private_data; - p = get_mountpoint(label_chunk_info[here].c); - if (p) { - if (!oldp) - p->newfs = FALSE; - if (label_chunk_info[here].type == PART_FAT - && (!strcmp(p->mountpoint, "/") || !strcmp(p->mountpoint, "/usr") - || !strcmp(p->mountpoint, "/var"))) { - msgConfirm("%s is an invalid mount point for a DOS partition!", p->mountpoint); - strcpy(p->mountpoint, "/bogus"); - } - } - if (((cp = variable_get(DISK_LABELLED)) == NULL) || (strcmp(cp, "written"))) - variable_set2(DISK_LABELLED, "yes"); - record_label_chunks(devs, dev); - clear_wins(); - break; - - default: - msgFatal("Bogus partition under cursor???"); - break; - } - break; - - case 'N': /* Set newfs options */ - if (label_chunk_info[here].c->private_data && - ((PartInfo *)label_chunk_info[here].c->private_data)->newfs) - getNewfsCmd(label_chunk_info[here].c->private_data); - else - msg = MSG_NOT_APPLICABLE; - clear_wins(); - break; - - case 'T': /* Toggle newfs state */ - if (label_chunk_info[here].type == PART_FILESYSTEM) { - PartInfo *pi = ((PartInfo *)label_chunk_info[here].c->private_data); - label_chunk_info[here].c->private_data = - new_part(pi ? pi->mountpoint : NULL, pi ? !pi->newfs : TRUE, label_chunk_info[here].c->size); - safe_free(pi); - label_chunk_info[here].c->private_free = safe_free; - if (((cp = variable_get(DISK_LABELLED)) == NULL) || (strcmp(cp, "written"))) - variable_set2(DISK_LABELLED, "yes"); - } - else - msg = MSG_NOT_APPLICABLE; - break; - - case 'U': - clear(); - if ((cp = variable_get(DISK_LABELLED)) && !strcmp(cp, "written")) { - msgConfirm("You've already written out your changes -\n" - "it's too late to undo!"); - } - else if (!msgYesNo("Are you SURE you want to Undo everything?")) { - variable_unset(DISK_PARTITIONED); - variable_unset(DISK_LABELLED); - for (i = 0; devs[i]; i++) { - Disk *d; - - if (!devs[i]->enabled) - continue; - else if ((d = Open_Disk(devs[i]->name)) != NULL) { - Free_Disk(devs[i]->private); - devs[i]->private = d; - diskPartition(devs[i]); - } - } - record_label_chunks(devs, dev); - } - clear_wins(); - break; - - case 'W': - if ((cp = variable_get(DISK_LABELLED)) && !strcmp(cp, "written")) { - msgConfirm("You've already written out your changes - if you\n" - "wish to overwrite them, you'll have to start this\n" - "procedure again from the beginning."); - } - else if (!msgYesNo("WARNING: This should only be used when modifying an EXISTING\n" - "installation. If you are installing FreeBSD for the first time\n" - "then you should simply type Q when you're finished here and your\n" - "changes will be committed in one batch automatically at the end of\n" - "these questions.\n\n" - "Are you absolutely sure you want to do this now?")) { - variable_set2(DISK_LABELLED, "yes"); - diskLabelCommit(NULL); - } - clear_wins(); - break; - - case '|': - if (!msgYesNo("Are you sure you want to go into Wizard mode?\n\n" - "This is an entirely undocumented feature which you are not\n" - "expected to understand!")) { - int i; - Device **devs; - - dialog_clear(); - end_dialog(); - DialogActive = FALSE; - devs = deviceFind(NULL, DEVICE_TYPE_DISK); - if (!devs) { - msgConfirm("Can't find any disk devices!"); - break; - } - for (i = 0; devs[i] && ((Disk *)devs[i]->private); i++) { - if (devs[i]->enabled) - slice_wizard(((Disk *)devs[i]->private)); - } - if (((cp = variable_get(DISK_LABELLED)) == NULL) || (strcmp(cp, "written"))) - variable_set2(DISK_LABELLED, "yes"); - DialogActive = TRUE; - record_label_chunks(devs, dev); - clear_wins(); - } - else - msg = "A most prudent choice!"; - break; - - case '\033': /* ESC */ - case 'Q': - labeling = FALSE; - break; - - default: - beep(); - sprintf(_msg, "Invalid key %d - Type F1 or ? for help", key); - msg = _msg; - break; - } - if (label_chunk_info[here].type == PART_SLICE) - pslice_focus = here; - else - label_focus = here; - } - return DITEM_SUCCESS | DITEM_RESTORE; -} - -static int -diskLabelNonInteractive(Device *dev) -{ - char *cp; - PartType type; - PartInfo *p; - u_long flags = 0; - int i, status; - Device **devs; - Disk *d; - - status = DITEM_SUCCESS; - - cp = variable_get(VAR_DISK); - if (!cp) { - dialog_clear(); - msgConfirm("diskLabel: No disk selected - can't label automatically."); - return DITEM_FAILURE; - } - devs = deviceFind(cp, DEVICE_TYPE_DISK); - if (!devs) { - msgConfirm("diskLabel: No disk device %s found!", cp); - return DITEM_FAILURE; - } - if (dev) - d = dev->private; - else - d = devs[0]->private; -#ifdef __alpha__ - All_FreeBSD(d, 1); -#endif - record_label_chunks(devs, dev); - for (i = 0; label_chunk_info[i].c; i++) { - Chunk *c1 = label_chunk_info[i].c; - - if (label_chunk_info[i].type == PART_SLICE) { - char name[512]; - int entries = 1; - - while (entries) { - snprintf(name, sizeof name, "%s-%d", c1->name, entries); - if ((cp = variable_get(name)) != NULL) { - int sz; - char typ[10], mpoint[50]; - - if (sscanf(cp, "%s %d %s", typ, &sz, mpoint) != 3) { - msgConfirm("For slice entry %s, got an invalid detail entry of: %s", c1->name, cp); - status = DITEM_FAILURE; - continue; - } - else { - Chunk *tmp; - - if (!strcmp(typ, "swap")) { - type = PART_SWAP; - strcpy(mpoint, "SWAP"); - } - else { - type = PART_FILESYSTEM; - if (!strcmp(mpoint, "/")) - flags |= CHUNK_IS_ROOT; - else - flags &= ~CHUNK_IS_ROOT; - } - if (!sz) - sz = space_free(c1); - if (sz > space_free(c1)) { - msgConfirm("Not enough free space to create partition: %s", mpoint); - status = DITEM_FAILURE; - continue; - } - if (!(tmp = Create_Chunk_DWIM(d, c1, sz, part, - (type == PART_SWAP) ? FS_SWAP : FS_BSDFFS, flags))) { - msgConfirm("Unable to create from partition spec: %s. Too big?", cp); - status = DITEM_FAILURE; - break; - } - else { - tmp->private_data = new_part(mpoint, TRUE, sz); - tmp->private_free = safe_free; - status = DITEM_SUCCESS; - } - } - entries++; - } - else { - /* No more matches, leave the loop */ - entries = 0; - } - } - } - else { - /* Must be something we can set a mountpoint for */ - cp = variable_get(c1->name); - if (cp) { - char mpoint[50], do_newfs[8]; - Boolean newfs = FALSE; - - do_newfs[0] = '\0'; - if (sscanf(cp, "%s %s", mpoint, do_newfs) != 2) { - dialog_clear(); - msgConfirm("For slice entry %s, got an invalid detail entry of: %s", c1->name, cp); - status = DITEM_FAILURE; - continue; - } - newfs = toupper(do_newfs[0]) == 'Y' ? TRUE : FALSE; - if (c1->private_data) { - p = c1->private_data; - p->newfs = newfs; - strcpy(p->mountpoint, mpoint); - } - else { - c1->private_data = new_part(mpoint, newfs, 0); - c1->private_free = safe_free; - } - if (!strcmp(mpoint, "/")) - c1->flags |= CHUNK_IS_ROOT; - else - c1->flags &= ~CHUNK_IS_ROOT; - } - } - } - if (status == DITEM_SUCCESS) - variable_set2(DISK_LABELLED, "yes"); - return status; -} diff --git a/usr.sbin/sysinstall/list.h b/usr.sbin/sysinstall/list.h deleted file mode 100644 index 05a9fd56b78d..000000000000 --- a/usr.sbin/sysinstall/list.h +++ /dev/null @@ -1,60 +0,0 @@ -/* - * The new sysinstall program. - * - * This is probably the last attempt in the `sysinstall' line, the next - * generation being slated for what's essentially a complete rewrite. - * - * $Id: list.h,v 1.1 1997/09/16 17:03:58 pst Exp $ - * - * Copyright (c) 1997 FreeBSD, 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, - * verbatim and that no modifications are made prior to this - * point in the file. - * 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 PAUL TRAINA ``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 PAUL TRAINA OR HIS KILLER RATS 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, LIFE 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. - * - */ - -/* The structure */ -typedef struct _qelement { - struct _qelement *q_forw; - struct _qelement *q_back; -} qelement; - -#define INITQUE(Xhead) { \ - (Xhead).q_forw = &(Xhead); \ - (Xhead).q_back = &(Xhead); \ -} - -#define EMPTYQUE(Xhead) \ - ((Xhead).q_forw == &(Xhead)) - -#define INSQUEUE(elem, pred) { \ - register qelement *Xe = (qelement *) (elem); \ - register qelement *Xp = (qelement *) (pred); \ - Xp->q_forw = (Xe->q_forw = (Xe->q_back = Xp)->q_forw)->q_back = Xe; \ -} - -#define REMQUE(elem) { \ - register qelement *Xe = (qelement *) (elem); \ - (Xe->q_back->q_forw = Xe->q_forw)->q_back = Xe->q_back; \ -} diff --git a/usr.sbin/sysinstall/main.c b/usr.sbin/sysinstall/main.c deleted file mode 100644 index 5840896154f2..000000000000 --- a/usr.sbin/sysinstall/main.c +++ /dev/null @@ -1,141 +0,0 @@ -/* - * The new sysinstall program. - * - * This is probably the last attempt in the `sysinstall' line, the next - * generation being slated for what's essentially a complete rewrite. - * - * $Id: main.c,v 1.49 1998/03/10 13:42:02 jkh Exp $ - * - * Copyright (c) 1995 - * Jordan Hubbard. 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, - * verbatim and that no modifications are made prior to this - * point in the file. - * 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 JORDAN HUBBARD ``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 JORDAN HUBBARD OR HIS PETS 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, LIFE 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. - * - */ - -#include "sysinstall.h" -#include <sys/signal.h> -#include <sys/fcntl.h> - -static void -screech(int sig) -{ - msgDebug("\007Signal %d caught! That's bad!\n", sig); - longjmp(BailOut, sig); -} - -int -main(int argc, char **argv) -{ - int choice, scroll, curr, max, status; - - /* Catch fatal signals and complain about them if running as init */ - if (getpid() == 1) { - signal(SIGBUS, screech); - signal(SIGSEGV, screech); - } - - /* We don't work too well when running as non-root anymore */ - if (geteuid() != 0) { - fprintf(stderr, "Error: This utility should only be run as root.\n"); - return 1; - } - - /* Set up whatever things need setting up */ - systemInitialize(argc, argv); - - /* Set default flag and variable values */ - installVarDefaults(NULL); - /* only when multi-user is it reasonable to do this here */ - if (!RunningAsInit) - installEnvironment(); - - if (argc > 1 && !strcmp(argv[1], "-fake")) { - variable_set2(VAR_DEBUG, "YES"); - Fake = TRUE; - msgConfirm("I'll be just faking it from here on out, OK?"); - } - - /* Try to preserve our scroll-back buffer */ - if (OnVTY) { - for (curr = 0; curr < 25; curr++) - putchar('\n'); - } - /* Move stderr aside */ - if (DebugFD) - dup2(DebugFD, 2); - - /* Probe for all relevant devices on the system */ - deviceGetAll(); - - /* First, see if we have any arguments to process (and argv[0] counts if it's not "sysinstall") */ - if (!RunningAsInit) { - int i, start_arg; - - if (!strstr(argv[0], "sysinstall")) - start_arg = 0; - else if (Fake) - start_arg = 2; - else - start_arg = 1; - for (i = start_arg; i < argc; i++) { - if (DITEM_STATUS(dispatchCommand(argv[i])) != DITEM_SUCCESS) - systemShutdown(1); - } - if (argc > start_arg) - systemShutdown(0); - } - else - dispatch_load_file_int(TRUE); - - status = setjmp(BailOut); - if (status) { - msgConfirm("A signal %d was caught - I'm saving what I can and shutting\n" - "If you can reproduce the problem, please turn Debug on in\n" - "the Options menu for the extra information it provides in\n" - "debugging problems like this.", status); - systemShutdown(status); - } - - /* Begin user dialog at outer menu */ - dialog_clear(); - while (1) { - choice = scroll = curr = max = 0; - dmenuOpen(&MenuInitial, &choice, &scroll, &curr, &max, TRUE); - if (getpid() != 1 -#ifdef __alpha__ - || !msgYesNo("Are you sure you wish to exit? The system will halt.") -#else - || !msgYesNo("Are you sure you wish to exit? The system will reboot\n" - "(be sure to remove any floppies from the drives).") -#endif - ) - break; - } - - /* Say goodnight, Gracie */ - systemShutdown(0); - - return 0; /* We should never get here */ -} diff --git a/usr.sbin/sysinstall/media.c b/usr.sbin/sysinstall/media.c deleted file mode 100644 index 87f63f4a986f..000000000000 --- a/usr.sbin/sysinstall/media.c +++ /dev/null @@ -1,784 +0,0 @@ -/* - * The new sysinstall program. - * - * This is probably the last attempt in the `sysinstall' line, the next - * generation being slated to essentially a complete rewrite. - * - * $Id: media.c,v 1.93 1998/12/02 03:27:37 jkh Exp $ - * - * Copyright (c) 1995 - * Jordan Hubbard. 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, - * verbatim and that no modifications are made prior to this - * point in the file. - * 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 JORDAN HUBBARD ``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 JORDAN HUBBARD OR HIS PETS 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, LIFE 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. - * - */ - -#include "sysinstall.h" -#include <signal.h> -#include <netdb.h> -#include <sys/socket.h> -#include <sys/param.h> -#include <sys/errno.h> -#include <sys/fcntl.h> -#include <sys/stat.h> -#include <sys/mman.h> -#include <sys/wait.h> -#include <netinet/in.h> -#include <arpa/inet.h> -#include <resolv.h> - -static Boolean got_intr = FALSE; - -/* timeout handler */ -static void -handle_intr(int sig) -{ - msgDebug("User generated interrupt.\n"); - got_intr = TRUE; -} - -static int -check_for_interrupt(void) -{ - if (got_intr) { - got_intr = FALSE; - return TRUE; - } - return FALSE; -} - -static int -genericHook(dialogMenuItem *self, DeviceType type) -{ - Device **devs; - - devs = deviceFind(self->prompt, type); - if (devs) - mediaDevice = devs[0]; - return (devs ? DITEM_LEAVE_MENU : DITEM_FAILURE); -} - -static int -cdromHook(dialogMenuItem *self) -{ - return genericHook(self, DEVICE_TYPE_CDROM); -} - -static void -kickstart_dns(void) -{ - static Boolean initted = FALSE; - int time; - char *cp; - - cp = variable_get(VAR_MEDIA_TIMEOUT); - if (!cp) - time = MEDIA_TIMEOUT; - else - time = atoi(cp); - if (!time) - time = 100; - if (!initted) { - res_init(); - _res.retry = 2; /* 2 times seems a reasonable number to me */ - _res.retrans = time / 2; /* so spend half our alloted time on each try */ - initted = TRUE; - } -} - -char * -cpioVerbosity() -{ - char *cp = variable_get(VAR_CPIO_VERBOSITY); - - if (cp && !strcmp(cp, "high")) - return "-v"; - else if (cp && !strcmp(cp, "medium")) - return "-V"; - return ""; -} - -void -mediaClose(void) -{ - if (mediaDevice) - mediaDevice->shutdown(mediaDevice); - mediaDevice = NULL; -} - -/* - * Return 1 if we successfully found and set the installation type to - * be a CD. - */ -int -mediaSetCDROM(dialogMenuItem *self) -{ - Device **devs; - int cnt; - - mediaClose(); - devs = deviceFind(NULL, DEVICE_TYPE_CDROM); - cnt = deviceCount(devs); - if (!cnt) { - if (self) /* Interactive? */ - msgConfirm("No CDROM devices found! Please check that your system's\n" - "configuration is correct and that the CDROM drive is of a supported\n" - "type. For more information, consult the hardware guide\n" - "in the Doc menu."); - return DITEM_FAILURE | DITEM_CONTINUE; - } - else if (cnt > 1) { - DMenu *menu; - int status; - - menu = deviceCreateMenu(&MenuMediaCDROM, DEVICE_TYPE_CDROM, cdromHook, NULL); - if (!menu) - msgFatal("Unable to create CDROM menu! Something is seriously wrong."); - status = dmenuOpenSimple(menu, FALSE); - free(menu); - if (!status) - return DITEM_FAILURE | DITEM_RESTORE; - } - else - mediaDevice = devs[0]; - return (mediaDevice ? DITEM_SUCCESS | DITEM_LEAVE_MENU : DITEM_FAILURE) | DITEM_RESTORE; -} - -static int -floppyHook(dialogMenuItem *self) -{ - return genericHook(self, DEVICE_TYPE_FLOPPY); -} - -/* - * Return 1 if we successfully found and set the installation type to - * be a floppy - */ -int -mediaSetFloppy(dialogMenuItem *self) -{ - Device **devs; - int cnt; - - mediaClose(); - devs = deviceFind(NULL, DEVICE_TYPE_FLOPPY); - cnt = deviceCount(devs); - if (!cnt) { - msgConfirm("No floppy devices found! Please check that your system's configuration\n" - "is correct. For more information, consult the hardware guide in the Doc\n" - "menu."); - return DITEM_FAILURE | DITEM_CONTINUE; - } - else if (cnt > 1) { - DMenu *menu; - int status; - - menu = deviceCreateMenu(&MenuMediaFloppy, DEVICE_TYPE_FLOPPY, floppyHook, NULL); - if (!menu) - msgFatal("Unable to create Floppy menu! Something is seriously wrong."); - status = dmenuOpenSimple(menu, FALSE); - free(menu); - if (!status) - return DITEM_FAILURE | DITEM_RESTORE; - } - else - mediaDevice = devs[0]; - return (mediaDevice ? DITEM_LEAVE_MENU : DITEM_FAILURE) | DITEM_RESTORE; -} - -static int -DOSHook(dialogMenuItem *self) -{ - return genericHook(self, DEVICE_TYPE_DOS); -} - -/* - * Return 1 if we successfully found and set the installation type to - * be a DOS partition. - */ -int -mediaSetDOS(dialogMenuItem *self) -{ - Device **devs; - int cnt; - - mediaClose(); - devs = deviceFind(NULL, DEVICE_TYPE_DOS); - cnt = deviceCount(devs); - if (!cnt) { - msgConfirm("No DOS primary partitions found! This installation method is unavailable"); - return DITEM_FAILURE | DITEM_CONTINUE; - } - else if (cnt > 1) { - DMenu *menu; - int status; - - menu = deviceCreateMenu(&MenuMediaDOS, DEVICE_TYPE_DOS, DOSHook, NULL); - if (!menu) - msgFatal("Unable to create DOS menu! Something is seriously wrong."); - status = dmenuOpenSimple(menu, FALSE); - free(menu); - if (!status) - return DITEM_FAILURE | DITEM_RESTORE; - } - else - mediaDevice = devs[0]; - return (mediaDevice ? DITEM_LEAVE_MENU : DITEM_FAILURE) | DITEM_RESTORE; -} - -static int -tapeHook(dialogMenuItem *self) -{ - return genericHook(self, DEVICE_TYPE_TAPE); -} - -/* - * Return 1 if we successfully found and set the installation type to - * be a tape drive. - */ -int -mediaSetTape(dialogMenuItem *self) -{ - Device **devs; - int cnt; - - mediaClose(); - devs = deviceFind(NULL, DEVICE_TYPE_TAPE); - cnt = deviceCount(devs); - if (!cnt) { - msgConfirm("No tape drive devices found! Please check that your system's configuration\n" - "is correct. For more information, consult the hardware guide in the Doc\n" - "menu."); - return DITEM_FAILURE | DITEM_CONTINUE; - } - else if (cnt > 1) { - DMenu *menu; - int status; - - menu = deviceCreateMenu(&MenuMediaTape, DEVICE_TYPE_TAPE, tapeHook, NULL); - if (!menu) - msgFatal("Unable to create tape drive menu! Something is seriously wrong."); - status = dmenuOpenSimple(menu, FALSE); - free(menu); - if (!status) - return DITEM_FAILURE | DITEM_RESTORE; - } - else - mediaDevice = devs[0]; - if (mediaDevice) { - char *val; - - val = msgGetInput("/usr/tmp", "Please enter the name of a temporary directory containing\n" - "sufficient space for holding the contents of this tape (or\n" - "tapes). The contents of this directory will be removed\n" - "after installation, so be sure to specify a directory that\n" - "can be erased afterwards!\n"); - if (!val) - mediaDevice = NULL; - else - mediaDevice->private = strdup(val); - } - return (mediaDevice ? DITEM_LEAVE_MENU : DITEM_FAILURE) | DITEM_RESTORE; -} - -/* - * Return 0 if we successfully found and set the installation type to - * be an ftp server - */ -int -mediaSetFTP(dialogMenuItem *self) -{ - static Device ftpDevice; - char *cp, hostname[MAXHOSTNAMELEN], *dir; - extern int FtpPort; - static Device *networkDev = NULL; - int what = DITEM_RESTORE; - - mediaClose(); - cp = variable_get(VAR_FTP_PATH); - /* If we've been through here before ... */ - if (!variable_get(VAR_NONINTERACTIVE)) - if (networkDev && cp && msgYesNo("Re-use old FTP site selection values?")) - cp = NULL; - - if (!cp) { - dialog_clear_norefresh(); - if (!dmenuOpenSimple(&MenuMediaFTP, FALSE)) - return DITEM_FAILURE | DITEM_RESTORE; - else - cp = variable_get(VAR_FTP_PATH); - what = DITEM_RESTORE; - } - if (!cp) - return DITEM_FAILURE | what; - else if (!strcmp(cp, "other")) { - variable_set2(VAR_FTP_PATH, "ftp://"); - dialog_clear_norefresh(); - cp = variable_get_value(VAR_FTP_PATH, "Please specify the URL of a FreeBSD distribution on a\n" - "remote ftp site. This site must accept either anonymous\n" - "ftp or you should have set an ftp username and password\n" - "in the Options screen.\n\n" - "A URL looks like this: ftp://<hostname>/<path>\n" - "Where <path> is relative to the anonymous ftp directory or the\n" - "home directory of the user being logged in as."); - if (!cp || !*cp || !strcmp(cp, "ftp://")) { - variable_unset(VAR_FTP_PATH); - return DITEM_FAILURE | what; - } - } - if (strncmp("ftp://", cp, 6)) { - msgConfirm("Sorry, %s is an invalid URL!", cp); - variable_unset(VAR_FTP_PATH); - return DITEM_FAILURE | what; - } - SAFE_STRCPY(ftpDevice.name, cp); - SAFE_STRCPY(hostname, cp + 6); - - dialog_clear_norefresh(); - if (!networkDev || msgYesNo("You've already done the network configuration once,\n" - "would you like to skip over it now?") != 0) { - if (networkDev) - networkDev->shutdown(networkDev); - if (!(networkDev = tcpDeviceSelect())) { - variable_unset(VAR_FTP_PATH); - return DITEM_FAILURE | what; - } - } - if (!networkDev->init(networkDev)) { - if (isDebug()) - msgDebug("mediaSetFTP: Net device init failed.\n"); - variable_unset(VAR_FTP_PATH); - return DITEM_FAILURE | what; - } - if ((cp = index(hostname, ':')) != NULL) { - *(cp++) = '\0'; - FtpPort = strtol(cp, 0, 0); - } - else - FtpPort = 21; - if ((dir = index(cp ? cp : hostname, '/')) != NULL) - *(dir++) = '\0'; - if (isDebug()) { - msgDebug("hostname = `%s'\n", hostname); - msgDebug("dir = `%s'\n", dir ? dir : "/"); - msgDebug("port # = `%d'\n", FtpPort); - } - if (variable_get(VAR_NAMESERVER)) { - msgNotify("Looking up host %s.", hostname); - if (isDebug()) - msgDebug("Starting DNS.\n"); - kickstart_dns(); - if (isDebug()) - msgDebug("Looking up hostname, %s, using inet_addr().\n", hostname); - if (inet_addr(hostname) == INADDR_NONE) { - if (isDebug()) - msgDebug("Looking up hostname, %s, using gethostbyname().\n", - hostname); - if (gethostbyname(hostname) == NULL) { - msgConfirm("Cannot resolve hostname `%s'! Are you sure that" - " your\nname server, gateway and network interface are" - " correctly configured?", hostname); - if (networkDev) - networkDev->shutdown(networkDev); - networkDev = NULL; - variable_unset(VAR_FTP_PATH); - return DITEM_FAILURE | what; - } - } - msgDebug("Found DNS entry for %s successfully..\n", hostname); - } - variable_set2(VAR_FTP_HOST, hostname); - variable_set2(VAR_FTP_DIR, dir ? dir : "/"); - variable_set2(VAR_FTP_PORT, itoa(FtpPort)); - ftpDevice.type = DEVICE_TYPE_FTP; - ftpDevice.init = mediaInitFTP; - ftpDevice.get = mediaGetFTP; - ftpDevice.shutdown = mediaShutdownFTP; - ftpDevice.private = networkDev; - mediaDevice = &ftpDevice; - return DITEM_SUCCESS | DITEM_LEAVE_MENU | what; -} - -int -mediaSetFTPActive(dialogMenuItem *self) -{ - variable_set2(VAR_FTP_STATE, "active"); - return mediaSetFTP(self); -} - -int -mediaSetFTPPassive(dialogMenuItem *self) -{ - variable_set2(VAR_FTP_STATE, "passive"); - return mediaSetFTP(self); -} - -int -mediaSetUFS(dialogMenuItem *self) -{ - static Device ufsDevice; - char *cp; - - mediaClose(); - dialog_clear_norefresh(); - cp = variable_get_value(VAR_UFS_PATH, "Enter a fully qualified pathname for the directory\n" - "containing the FreeBSD distribution files:"); - if (!cp) - return DITEM_FAILURE; - strcpy(ufsDevice.name, "ufs"); - ufsDevice.type = DEVICE_TYPE_UFS; - ufsDevice.init = dummyInit; - ufsDevice.get = mediaGetUFS; - ufsDevice.shutdown = dummyShutdown; - ufsDevice.private = strdup(cp); - mediaDevice = &ufsDevice; - return DITEM_LEAVE_MENU; -} - -int -mediaSetNFS(dialogMenuItem *self) -{ - static Device nfsDevice; - static Device *networkDev = NULL; - char *cp, *idx; - char hostname[MAXPATHLEN]; - mediaClose(); - dialog_clear_norefresh(); - cp = variable_get_value(VAR_NFS_PATH, "Please enter the full NFS file specification for the remote\n" - "host and directory containing the FreeBSD distribution files.\n" - "This should be in the format: hostname:/some/freebsd/dir"); - if (!cp) - return DITEM_FAILURE; - SAFE_STRCPY(hostname, cp); - if (!(idx = index(hostname, ':'))) { - msgConfirm("Invalid NFS path specification. Must be of the form:\n" - "host:/full/pathname/to/FreeBSD/distdir"); - return DITEM_FAILURE; - } - SAFE_STRCPY(nfsDevice.name, hostname); - *idx = '\0'; - if (!networkDev || msgYesNo("You've already done the network configuration once,\n" - "would you like to skip over it now?") != 0) { - if (networkDev) - networkDev->shutdown(networkDev); - if (!(networkDev = tcpDeviceSelect())) - return DITEM_FAILURE; - } - if (!networkDev->init(networkDev)) { - if (isDebug()) - msgDebug("mediaSetNFS: Net device init failed\n"); - } - if (variable_get(VAR_NAMESERVER)) { - kickstart_dns(); - if ((inet_addr(hostname) == INADDR_NONE) && (gethostbyname(hostname) == NULL)) { - msgConfirm("Cannot resolve hostname `%s'! Are you sure that your\n" - "name server, gateway and network interface are correctly configured?", hostname); - if (networkDev) - networkDev->shutdown(networkDev); - networkDev = NULL; - variable_unset(VAR_NFS_PATH); - return DITEM_FAILURE; - } - else - msgDebug("Found DNS entry for %s successfully..", hostname); - } - variable_set2(VAR_NFS_HOST, hostname); - nfsDevice.type = DEVICE_TYPE_NFS; - nfsDevice.init = mediaInitNFS; - nfsDevice.get = mediaGetNFS; - nfsDevice.shutdown = mediaShutdownNFS; - nfsDevice.private = networkDev; - mediaDevice = &nfsDevice; - return DITEM_LEAVE_MENU; -} - -Boolean -mediaExtractDistBegin(char *dir, int *fd, int *zpid, int *cpid) -{ - int i, pfd[2],qfd[2]; - - if (!dir) - dir = "/"; - Mkdir(dir); - chdir(dir); - pipe(pfd); - pipe(qfd); - *zpid = fork(); - if (!*zpid) { - char *gunzip = RunningAsInit ? "/stand/gunzip" : "/usr/bin/gunzip"; - - dup2(qfd[0], 0); close(qfd[0]); - dup2(pfd[1], 1); close(pfd[1]); - if (DebugFD != -1) - dup2(DebugFD, 2); - else { - close(2); - open("/dev/null", O_WRONLY); - } - close(qfd[1]); - close(pfd[0]); - i = execl(gunzip, gunzip, 0); - if (isDebug()) - msgDebug("%s command returns %d status\n", gunzip, i); - exit(i); - } - *fd = qfd[1]; - close(qfd[0]); - *cpid = fork(); - if (!*cpid) { - char *cpio = RunningAsInit ? "/stand/cpio" : "/usr/bin/cpio"; - - dup2(pfd[0], 0); close(pfd[0]); - close(pfd[1]); - close(qfd[1]); - if (DebugFD != -1) { - dup2(DebugFD, 1); - dup2(DebugFD, 2); - } - else { - close(1); open("/dev/null", O_WRONLY); - dup2(1, 2); - } - if (strlen(cpioVerbosity())) - i = execl(cpio, cpio, "-idum", cpioVerbosity(), "--block-size", mediaTapeBlocksize(), 0); - else - i = execl(cpio, cpio, "-idum", "--block-size", mediaTapeBlocksize(), 0); - if (isDebug()) - msgDebug("%s command returns %d status\n", cpio, i); - exit(i); - } - close(pfd[0]); - close(pfd[1]); - return TRUE; -} - -Boolean -mediaExtractDistEnd(int zpid, int cpid) -{ - int i,j; - - i = waitpid(zpid, &j, 0); - /* Don't check exit status - gunzip seems to return a bogus one! */ - if (i < 0) { - if (isDebug()) - msgDebug("wait for gunzip returned status of %d!\n", i); - return FALSE; - } - i = waitpid(cpid, &j, 0); - if (i < 0 || WEXITSTATUS(j)) { - if (isDebug()) - msgDebug("cpio returned error status of %d!\n", WEXITSTATUS(j)); - return FALSE; - } - return TRUE; -} - -Boolean -mediaExtractDist(char *dir, char *dist, FILE *fp) -{ - int i, j, total, seconds, zpid, cpid, pfd[2], qfd[2]; - char buf[BUFSIZ]; - struct timeval start, stop; - struct sigaction new, old; - - if (!dir) - dir = "/"; - - Mkdir(dir); - chdir(dir); - pipe(pfd); /* read end */ - pipe(qfd); /* write end */ - zpid = fork(); - if (!zpid) { - char *gunzip = RunningAsInit ? "/stand/gunzip" : "/usr/bin/gunzip"; - - fclose(fp); - close(qfd[1]); - dup2(qfd[0], 0); close(qfd[0]); - - close(pfd[0]); - dup2(pfd[1], 1); close(pfd[1]); - - if (DebugFD != -1) - dup2(DebugFD, 2); - else { - close(2); - open("/dev/null", O_WRONLY); - } - i = execl(gunzip, gunzip, 0); - if (isDebug()) - msgDebug("%s command returns %d status\n", gunzip, i); - exit(i); - } - cpid = fork(); - if (!cpid) { - char *cpio = RunningAsInit ? "/stand/cpio" : "/usr/bin/cpio"; - - close(pfd[1]); - dup2(pfd[0], 0); close(pfd[0]); - close (qfd[0]); close(qfd[1]); - fclose(fp); - if (DebugFD != -1) { - dup2(DebugFD, 1); - dup2(DebugFD, 2); - } - else { - dup2(open("/dev/null", O_WRONLY), 1); - dup2(1, 2); - } - if (strlen(cpioVerbosity())) - i = execl(cpio, cpio, "-idum", cpioVerbosity(), "--block-size", mediaTapeBlocksize(), 0); - else - i = execl(cpio, cpio, "-idum", "--block-size", mediaTapeBlocksize(), 0); - if (isDebug()) - msgDebug("%s command returns %d status\n", cpio, i); - exit(i); - } - close(pfd[0]); close(pfd[1]); - close(qfd[0]); - - total = 0; - (void)gettimeofday(&start, (struct timezone *)0); - - /* Make ^C abort the current transfer rather than the whole show */ - new.sa_handler = handle_intr; - new.sa_flags = 0; - new.sa_mask = 0; - sigaction(SIGINT, &new, &old); - - while ((i = fread(buf, 1, BUFSIZ, fp)) > 0) { - if (check_for_interrupt()) { - msgConfirm("Failure to read from media: User interrupt."); - break; - } - if (write(qfd[1], buf, i) != i) { - msgConfirm("Write error on transfer to cpio process, try of %d bytes.", i); - break; - } - else { - (void)gettimeofday(&stop, (struct timezone *)0); - stop.tv_sec = stop.tv_sec - start.tv_sec; - stop.tv_usec = stop.tv_usec - start.tv_usec; - if (stop.tv_usec < 0) - stop.tv_sec--, stop.tv_usec += 1000000; - seconds = stop.tv_sec + (stop.tv_usec / 1000000.0); - if (!seconds) - seconds = 1; - total += i; - msgInfo("%10d bytes read from %s dist @ %.1f KB/sec.", - total, dist, (total / seconds) / 1024.0); - } - } - sigaction(SIGINT, &old, NULL); /* restore sigint */ - close(qfd[1]); - - i = waitpid(zpid, &j, 0); - /* Don't check exit status - gunzip seems to return a bogus one! */ - if (i < 0) { - if (isDebug()) - msgDebug("wait for gunzip returned status of %d!\n", i); - return FALSE; - } - i = waitpid(cpid, &j, 0); - if (i < 0 || WEXITSTATUS(j)) { - if (isDebug()) - msgDebug("cpio returned error status of %d!\n", WEXITSTATUS(j)); - return FALSE; - } - return TRUE; -} - -int -mediaGetType(dialogMenuItem *self) -{ - return ((dmenuOpenSimple(&MenuMedia, FALSE) && mediaDevice) ? DITEM_SUCCESS : DITEM_FAILURE) | DITEM_RESTORE; -} - -/* Return TRUE if all the media variables are set up correctly */ -Boolean -mediaVerify(void) -{ - if (!mediaDevice) - return (DITEM_STATUS(mediaGetType(NULL)) == DITEM_SUCCESS); - return TRUE; -} - -/* Set the FTP username and password fields */ -int -mediaSetFTPUserPass(dialogMenuItem *self) -{ - char *pass; - - dialog_clear_norefresh(); - if (variable_get_value(VAR_FTP_USER, "Please enter the username you wish to login as:")) { - dialog_clear_norefresh(); - DialogInputAttrs |= DITEM_NO_ECHO; - pass = variable_get_value(VAR_FTP_PASS, "Please enter the password for this user:"); - DialogInputAttrs &= ~DITEM_NO_ECHO; - } - else - pass = NULL; - return (pass ? DITEM_SUCCESS : DITEM_FAILURE) | DITEM_RESTORE; -} - -/* Set CPIO verbosity level */ -int -mediaSetCPIOVerbosity(dialogMenuItem *self) -{ - char *cp = variable_get(VAR_CPIO_VERBOSITY); - - if (!cp) { - msgConfirm("CPIO Verbosity is not set to anything!"); - return DITEM_FAILURE; - } - else { - if (!strcmp(cp, "low")) - variable_set2(VAR_CPIO_VERBOSITY, "medium"); - else if (!strcmp(cp, "medium")) - variable_set2(VAR_CPIO_VERBOSITY, "high"); - else /* must be "high" - wrap around */ - variable_set2(VAR_CPIO_VERBOSITY, "low"); - } - return DITEM_SUCCESS; -} - -/* A generic open which follows a well-known "path" of places to look */ -FILE * -mediaGenericGet(char *base, const char *file) -{ - char buf[PATH_MAX]; - - snprintf(buf, PATH_MAX, "%s/%s", base, file); - if (file_readable(buf)) - return fopen(buf, "r"); - snprintf(buf, PATH_MAX, "%s/releases/%s", base, file); - if (file_readable(buf)) - return fopen(buf, "r"); - snprintf(buf, PATH_MAX, "%s/%s/%s", base, variable_get(VAR_RELNAME), file); - if (file_readable(buf)) - return fopen(buf, "r"); - snprintf(buf, PATH_MAX, "%s/releases/%s/%s", base, variable_get(VAR_RELNAME), file); - return fopen(buf, "r"); -} - diff --git a/usr.sbin/sysinstall/menus.c b/usr.sbin/sysinstall/menus.c deleted file mode 100644 index d5da830734f8..000000000000 --- a/usr.sbin/sysinstall/menus.c +++ /dev/null @@ -1,1488 +0,0 @@ -/* - * The new sysinstall program. - * - * This is probably the last program in the `sysinstall' line - the next - * generation being essentially a complete rewrite. - * - * $Id: menus.c,v 1.179 1999/01/06 13:55:12 peter Exp $ - * - * Copyright (c) 1995 - * Jordan Hubbard. 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, - * verbatim and that no modifications are made prior to this - * point in the file. - * 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 JORDAN HUBBARD ``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 JORDAN HUBBARD OR HIS PETS 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, LIFE 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. - * - */ - -#include "sysinstall.h" - -/* Miscellaneous work routines for menus */ -static int -setSrc(dialogMenuItem *self) -{ - Dists |= DIST_SRC; - SrcDists = DIST_SRC_ALL | DIST_SRC_SMAILCF; - return DITEM_SUCCESS | DITEM_REDRAW; -} - -static int -clearSrc(dialogMenuItem *self) -{ - Dists &= ~DIST_SRC; - SrcDists = 0; - return DITEM_SUCCESS | DITEM_REDRAW; -} - -static int -setX11All(dialogMenuItem *self) -{ - XF86Dists = DIST_XF86_ALL; - XF86ServerDists = DIST_XF86_SERVER_ALL; - XF86FontDists = DIST_XF86_FONTS_ALL; - Dists |= DIST_XF86; - return DITEM_SUCCESS | DITEM_REDRAW; -} - -static int -clearX11All(dialogMenuItem *self) -{ - XF86Dists = 0; - XF86ServerDists = 0; - XF86FontDists = 0; - Dists &= ~DIST_XF86; - return DITEM_SUCCESS | DITEM_REDRAW; -} - -static int -setX11Misc(dialogMenuItem *self) -{ - XF86Dists |= DIST_XF86_MISC_ALL; - Dists |= DIST_XF86; - return DITEM_SUCCESS | DITEM_REDRAW; -} - -static int -clearX11Misc(dialogMenuItem *self) -{ - XF86Dists &= ~DIST_XF86_MISC_ALL; - if (!XF86ServerDists && !XF86FontDists) - Dists &= ~DIST_XF86; - return DITEM_SUCCESS | DITEM_REDRAW; -} - -static int -setX11Servers(dialogMenuItem *self) -{ - XF86Dists |= DIST_XF86_SERVER; - XF86ServerDists = DIST_XF86_SERVER_ALL; - return DITEM_SUCCESS | DITEM_REDRAW; -} - -static int -clearX11Servers(dialogMenuItem *self) -{ - XF86Dists &= ~DIST_XF86_SERVER; - XF86ServerDists = 0; - return DITEM_SUCCESS | DITEM_REDRAW; -} - -static int -setX11Fonts(dialogMenuItem *self) -{ - XF86Dists |= DIST_XF86_FONTS; - XF86FontDists = DIST_XF86_FONTS_ALL; - return DITEM_SUCCESS | DITEM_REDRAW; -} - -static int -clearX11Fonts(dialogMenuItem *self) -{ - XF86Dists &= ~DIST_XF86_FONTS; - XF86FontDists = 0; - return DITEM_SUCCESS | DITEM_REDRAW; -} - -#define _IS_SET(dist, set) (((dist) & (set)) == (set)) - -#define IS_DEVELOPER(dist, extra) (_IS_SET(dist, _DIST_DEVELOPER | extra) || \ - _IS_SET(dist, _DIST_DEVELOPER | DIST_DES | extra)) - -#define IS_USER(dist, extra) (_IS_SET(dist, _DIST_USER | extra) || \ - _IS_SET(dist, _DIST_USER | DIST_DES | extra)) - -static int -checkDistDeveloper(dialogMenuItem *self) -{ - return IS_DEVELOPER(Dists, 0) && _IS_SET(SrcDists, DIST_SRC_ALL); -} - -static int -checkDistXDeveloper(dialogMenuItem *self) -{ - return IS_DEVELOPER(Dists, DIST_XF86) && _IS_SET(SrcDists, DIST_SRC_ALL); -} - -static int -checkDistKernDeveloper(dialogMenuItem *self) -{ - return IS_DEVELOPER(Dists, 0) && _IS_SET(SrcDists, DIST_SRC_SYS); -} - -static int -checkDistUser(dialogMenuItem *self) -{ - return IS_USER(Dists, 0); -} - -static int -checkDistXUser(dialogMenuItem *self) -{ - return IS_USER(Dists, DIST_XF86); -} - -static int -checkDistMinimum(dialogMenuItem *self) -{ - return Dists == DIST_BIN; -} - -static int -checkDistEverything(dialogMenuItem *self) -{ - return Dists == DIST_ALL && _IS_SET(SrcDists, DIST_SRC_ALL) && \ - _IS_SET(XF86Dists, DIST_XF86_ALL) && \ - _IS_SET(XF86ServerDists, DIST_XF86_SERVER_ALL) && \ - _IS_SET(XF86FontDists, DIST_XF86_FONTS_ALL); -} - -static int -DESFlagCheck(dialogMenuItem *item) -{ - return DESDists; -} - -static int -srcFlagCheck(dialogMenuItem *item) -{ - return SrcDists; -} - -static int -x11FlagCheck(dialogMenuItem *item) -{ - return Dists & DIST_XF86; -} - -static int -checkTrue(dialogMenuItem *item) -{ - return TRUE; -} - -/* All the system menus go here. - * - * Hardcoded things like version number strings will disappear from - * these menus just as soon as I add the code for doing inline variable - * expansion. - */ - -DMenu MenuIndex = { - DMENU_NORMAL_TYPE, - "Glossary of functions", - "This menu contains an alphabetized index of the top level functions in\n" - "this program (sysinstall). Invoke an option by pressing [ENTER].\n" - "Leave the index page by selecting Cancel [TAB-ENTER].", - "Use PageUp or PageDown to move through this menu faster!", - NULL, - { { "Anon FTP", "Configure anonymous FTP logins.", dmenuVarCheck, configAnonFTP, NULL, "anon_ftp" }, - { "Commit", "Commit any pending actions (dangerous!)", NULL, installCustomCommit }, - { "Console settings", "Customize system console behavior.", NULL, dmenuSubmenu, NULL, &MenuSyscons }, - { "Configure", "The system configuration menu.", NULL, dmenuSubmenu, NULL, &MenuConfigure }, - { "Defaults, Load", "Load default settings.", NULL, dispatch_load_floppy }, - { "Device, Mouse", "The mouse configuration menu.", NULL, dmenuSubmenu, NULL, &MenuMouse }, - { "Disklabel", "The disk Label editor", NULL, diskLabelEditor }, - { "Dists, All", "Root of the distribution tree.", NULL, dmenuSubmenu, NULL, &MenuDistributions }, - { "Dists, Basic", "Basic FreeBSD distribution menu.", NULL, dmenuSubmenu, NULL, &MenuSubDistributions }, - { "Dists, DES", "DES distribution menu.", NULL, dmenuSubmenu, NULL, &MenuDESDistributions }, - { "Dists, Developer", "Select developer's distribution.", checkDistDeveloper, distSetDeveloper }, - { "Dists, Src", "Src distribution menu.", NULL, dmenuSubmenu, NULL, &MenuSrcDistributions }, - { "Dists, X Developer", "Select X developer's distribution.", checkDistXDeveloper, distSetXDeveloper }, - { "Dists, Kern Developer", "Select kernel developer's distribution.", checkDistKernDeveloper, distSetKernDeveloper }, - { "Dists, User", "Select average user distribution.", checkDistUser, distSetUser }, - { "Dists, X User", "Select average X user distribution.", checkDistXUser, distSetXUser }, - { "Distributions, Adding", "Installing additional distribution sets", NULL, distExtractAll }, - { "Distributions, XFree86","XFree86 distribution menu.", NULL, distSetXF86 }, - { "Documentation", "Installation instructions, README, etc.", NULL, dmenuSubmenu, NULL, &MenuDocumentation }, - { "Doc, README", "The distribution README file.", NULL, dmenuDisplayFile, NULL, "README" }, - { "Doc, Hardware", "The distribution hardware guide.", NULL, dmenuDisplayFile, NULL, "HARDWARE" }, - { "Doc, Install", "The distribution installation guide.", NULL, dmenuDisplayFile, NULL, "INSTALL" }, - { "Doc, Copyright", "The distribution copyright notices.", NULL, dmenuDisplayFile, NULL, "COPYRIGHT" }, - { "Doc, Release", "The distribution release notes.", NULL, dmenuDisplayFile, NULL, "RELNOTES" }, - { "Doc, HTML", "The HTML documentation menu.", NULL, docBrowser }, - { "Emergency shell", "Start an Emergency Holographic shell.", NULL, installFixitHoloShell }, - { "Fdisk", "The disk Partition Editor", NULL, diskPartitionEditor }, - { "Fixit", "Repair mode with CDROM or fixit floppy.", NULL, dmenuSubmenu, NULL, &MenuFixit }, - { "FTP sites", "The FTP mirror site listing.", NULL, dmenuSubmenu, NULL, &MenuMediaFTP }, - { "Gateway", "Set flag to route packets between interfaces.", dmenuVarCheck, dmenuToggleVariable, NULL, "gateway=YES" }, - { "HTML Docs", "The HTML documentation menu", NULL, docBrowser }, - { "Install, Novice", "A novice system installation.", NULL, installNovice }, - { "Install, Express", "An express system installation.", NULL, installExpress }, - { "Install, Custom", "The custom installation menu", NULL, dmenuSubmenu, NULL, &MenuInstallCustom }, - { "Label", "The disk Label editor", NULL, diskLabelEditor }, - { "Media", "Top level media selection menu.", NULL, dmenuSubmenu, NULL, &MenuMedia }, - { "Media, Tape", "Select tape installation media.", NULL, mediaSetTape }, - { "Media, NFS", "Select NFS installation media.", NULL, mediaSetNFS }, - { "Media, Floppy", "Select floppy installation media.", NULL, mediaSetFloppy }, - { "Media, CDROM", "Select CDROM installation media.", NULL, mediaSetCDROM }, - { "Media, DOS", "Select DOS installation media.", NULL, mediaSetDOS }, - { "Media, UFS", "Select UFS installation media.", NULL, mediaSetUFS }, - { "Media, FTP", "Select FTP installation media.", NULL, mediaSetFTP }, - { "Media, FTP Passive", "Select passive FTP installation media.", NULL, mediaSetFTPPassive }, - { "Network Interfaces", "Configure network interfaces", NULL, tcpMenuSelect }, - { "Networking Services", "The network services menu.", NULL, dmenuSubmenu, NULL, &MenuNetworking }, - { "NFS, client", "Set NFS client flag.", dmenuVarCheck, dmenuToggleVariable, NULL, "nfs_client_enable=YES" }, - { "NFS, server", "Set NFS server flag.", dmenuVarCheck, configNFSServer, NULL, "nfs_server_enable=YES" }, - { "NTP Menu", "The NTP configuration menu.", NULL, dmenuSubmenu, NULL, &MenuNTP }, - { "Options", "The options editor.", NULL, optionsEditor }, - { "Packages", "The packages collection", NULL, configPackages }, - { "Partition", "The disk Slice (PC-style partition) Editor", NULL, diskPartitionEditor }, - { "PCNFSD", "Run authentication server for PC-NFS.", dmenuVarCheck, configPCNFSD, NULL, "pcnfsd" }, - { "Register", "Register yourself or company as a FreeBSD user.", dmenuVarCheck, configRegister, NULL, "registered" }, - { "Root Password", "Set the system manager's password.", NULL, dmenuSystemCommand, NULL, "passwd root" }, - { "Root Password", "Set the system manager's password.", NULL, dmenuSystemCommand, NULL, "passwd root" }, - { "Router", "Select routing daemon (default: routed)", NULL, configRouter, NULL, "router" }, - { "Syscons", "The system console configuration menu.", NULL, dmenuSubmenu, NULL, &MenuSyscons }, - { "Syscons, Font", "The console screen font.", NULL, dmenuSubmenu, NULL, &MenuSysconsFont }, - { "Syscons, Keymap", "The console keymap configuration menu.", NULL, dmenuSubmenu, NULL, &MenuSysconsKeymap }, - { "Syscons, Keyrate", "The console key rate configuration menu.", NULL, dmenuSubmenu, NULL, &MenuSysconsKeyrate }, - { "Syscons, Saver", "The console screen saver configuration menu.", NULL, dmenuSubmenu, NULL, &MenuSysconsSaver }, - { "Syscons, Screenmap", "The console screenmap configuration menu.", NULL, dmenuSubmenu, NULL, &MenuSysconsScrnmap }, - { "Time Zone", "Set the system's time zone.", NULL, dmenuSystemCommand, NULL, "tzsetup" }, - { "Upgrade", "Upgrade an existing system.", NULL, installUpgrade }, - { "Usage", "Quick start - How to use this menu system.", NULL, dmenuDisplayFile, NULL, "usage" }, - { "User Management", "Add user and group information.", NULL, dmenuSubmenu, NULL, &MenuUsermgmt }, - { "XFree86, Fonts", "XFree86 Font selection menu.", NULL, dmenuSubmenu, NULL, &MenuXF86SelectFonts }, - { "XFree86, Server", "XFree86 Server selection menu.", NULL, dmenuSubmenu, NULL, &MenuXF86SelectServer }, - { "XFree86, PC98 Server", "XFree86 PC98 Server selection menu.", NULL, dmenuSubmenu, NULL, &MenuXF86SelectPC98Server }, - { NULL } }, -}; - -/* The initial installation menu */ -DMenu MenuInitial = { - DMENU_NORMAL_TYPE, - "/stand/sysinstall Main Menu", /* title */ - "Welcome to the FreeBSD installation and configuration tool. Please\n" /* prompt */ - "select one of the options below by using the arrow keys or typing the\n" - "first character of the option name you're interested in. Invoke an\n" - "option by pressing [ENTER] or [TAB-ENTER] to exit the installation.", - "Press F1 for Installation Guide", /* help line */ - "install", /* help file */ - { { "Select" }, - { "Exit Install", NULL, NULL, dmenuExit }, - { "1 Usage", "Quick start - How to use this menu system", NULL, dmenuDisplayFile, NULL, "usage" }, - { "2 Doc", "Installation instructions, README, etc.", NULL, dmenuSubmenu, NULL, &MenuDocumentation }, - { "3 Keymap", "Select keyboard type", NULL, dmenuSubmenu, NULL, &MenuSysconsKeymap }, - { "4 Options", "View/Set various installation options", NULL, optionsEditor }, - { "5 Configure", "Do post-install configuration of FreeBSD", NULL, dmenuSubmenu, NULL, &MenuConfigure }, - { "6 Novice", "Begin a novice installation (for beginners)", NULL, installNovice }, - { "7 Express", "Begin a quick installation (for the impatient)", NULL, installExpress }, - { "8 Custom", "Begin a custom installation (for experts)", NULL, dmenuSubmenu, NULL, &MenuInstallCustom }, - { "9 Fixit", "Enter repair mode with CDROM/floppy or start shell", NULL, dmenuSubmenu, NULL, &MenuFixit }, - { "U Upgrade", "Upgrade an existing system", NULL, installUpgrade }, - { "L Load Config","Load default install configuration", NULL, dispatch_load_floppy }, - { "0 Index", "Glossary of functions", NULL, dmenuSubmenu, NULL, &MenuIndex }, - { NULL } }, -}; - -/* The main documentation menu */ -DMenu MenuDocumentation = { - DMENU_NORMAL_TYPE, - "FreeBSD Documentation Menu", - "If you are at all unsure about the configuration of your hardware\n" - "or are looking to build a system specifically for FreeBSD, read the\n" - "Hardware guide! New users should also read the Install document for\n" - "a step-by-step tutorial on installing FreeBSD. For general information,\n" - "consult the README file.", - "Confused? Press F1 for help.", - "usage", - { { "1 README", "A general description of FreeBSD. Read this!", NULL, dmenuDisplayFile, NULL, "README" }, - { "2 Hardware", "The FreeBSD survival guide for PC hardware.", NULL, dmenuDisplayFile, NULL, "HARDWARE" }, - { "3 Install", "A step-by-step guide to installing FreeBSD.", NULL, dmenuDisplayFile, NULL, "INSTALL" }, - { "4 Copyright", "The FreeBSD Copyright notices.", NULL, dmenuDisplayFile, NULL, "COPYRIGHT" }, - { "5 Release" ,"The release notes for this version of FreeBSD.", NULL, dmenuDisplayFile, NULL, "RELNOTES" }, - { "6 Shortcuts", "Creating shortcuts to sysinstall.", NULL, dmenuDisplayFile, NULL, "shortcuts" }, - { "7 HTML Docs", "Go to the HTML documentation menu (post-install).", NULL, docBrowser }, - { "0 Exit", "Exit this menu (returning to previous)", NULL, dmenuExit }, - { NULL } }, -}; - -DMenu MenuMouseType = { - DMENU_RADIO_TYPE | DMENU_SELECTION_RETURNS, - "Select a protocol type for your mouse", - "If you are not sure, choose \"Auto\". It should always work for bus\n" - "and PS/2 style mice. It may not work for the serial mouse if the mouse\n" - "does not support the PnP standard. But, it won't hurt. Many 2-button\n" - "serial mice are compatible with \"Microsoft\" or \"MouseMan\". 3-button\n" - "serial mice may be compatible with \"MouseSystems\" or \"MouseMan\". If\n" - "the mouse has a wheel, it may be compatible with \"IntelliMouse\".", - NULL, - NULL, - { { "Auto", "Bus mouse, PS/2 style mouse or PnP serial mouse", - dmenuVarCheck, dmenuSetVariable, NULL, VAR_MOUSED_TYPE "=auto" }, - { "GlidePoint", "ALPS GlidePoint pad (serial)", - dmenuVarCheck, dmenuSetVariable, NULL, VAR_MOUSED_TYPE "=glidepoint" }, - { "Hitachi","Hitachi tablet (serial)", - dmenuVarCheck, dmenuSetVariable, NULL, VAR_MOUSED_TYPE "=mmhittab" }, - { "IntelliMouse", "Microsoft IntelliMouse (serial)", - dmenuVarCheck, dmenuSetVariable, NULL, VAR_MOUSED_TYPE "=intellimouse" }, - { "Logitech", "Logitech protocol (old models) (serial)", - dmenuVarCheck, dmenuSetVariable, NULL, VAR_MOUSED_TYPE "=logitech" }, - { "Microsoft", "Microsoft protocol (serial)", - dmenuVarCheck, dmenuSetVariable, NULL, VAR_MOUSED_TYPE "=microsoft" }, - { "MM Series","MM Series protocol (serial)", - dmenuVarCheck, dmenuSetVariable, NULL, VAR_MOUSED_TYPE "=mmseries" }, - { "MouseMan", "Logitech MouseMan/TrackMan models (serial)", - dmenuVarCheck, dmenuSetVariable, NULL, VAR_MOUSED_TYPE "=mouseman" }, - { "MouseSystems", "MouseSystems protocol (serial)", - dmenuVarCheck, dmenuSetVariable, NULL, VAR_MOUSED_TYPE "=mousesystems" }, - { "ThinkingMouse","Kensington ThinkingMouse (serial)", - dmenuVarCheck, dmenuSetVariable, NULL, VAR_MOUSED_TYPE "=thinkingmouse" }, - { NULL } }, -}; - -DMenu MenuMousePort = { - DMENU_RADIO_TYPE | DMENU_SELECTION_RETURNS, - "Select your mouse port from the following menu", - "The built-in pointing device of laptop/notebook computers is usually\n" - "a PS/2 style device.", - NULL, - NULL, - { { "COM1", "Serial mouse on COM1 (/dev/cuaa0)", - dmenuVarCheck, dmenuSetVariable, NULL, VAR_MOUSED_PORT "=/dev/cuaa0" }, - { "COM2", "Serial mouse on COM2 (/dev/cuaa1)", - dmenuVarCheck, dmenuSetVariable, NULL, VAR_MOUSED_PORT "=/dev/cuaa1" }, - { "COM3", "Serial mouse on COM3 (/dev/cuaa2)", - dmenuVarCheck, dmenuSetVariable, NULL, VAR_MOUSED_PORT "=/dev/cuaa2" }, - { "COM4", "Serial mouse on COM4 (/dev/cuaa3)", - dmenuVarCheck, dmenuSetVariable, NULL, VAR_MOUSED_PORT "=/dev/cuaa3" }, - { "BusMouse", "Logitech, ATI or MS bus mouse (/dev/mse0)", - dmenuVarCheck, dmenuSetVariable, NULL, VAR_MOUSED_PORT "=/dev/mse0" }, - { "PS/2", "PS/2 style mouse (/dev/psm0)", - dmenuVarCheck, dmenuSetVariable, NULL, VAR_MOUSED_PORT "=/dev/psm0" }, - { NULL } }, -}; - -DMenu MenuMouse = { - DMENU_NORMAL_TYPE, - "Please configure your mouse", - "You can cut and paste text in the text console by running the mouse\n" - "daemon. Specify a port and a protocol type of your mouse and enable\n" - "the mouse daemon. If you don't want this feature, select 4 to disable\n" - "the daemon.\n" - "Once you've enabled the mouse daemon, you can specify \"/dev/sysmouse\"\n" - "as your mouse device and \"SysMouse\" or \"MouseSystems\" as mouse\n" - "protocol when running the X configuration utility (see Configuration\n" - "menu).", - NULL, - NULL, - { { "1 Type", "Select mouse protocol type", NULL, dmenuSubmenu, NULL, &MenuMouseType }, - { "2 Port", "Select mouse port", NULL, dmenuSubmenu, NULL, &MenuMousePort }, - { "3 Enable", "Test and run the mouse daemon", NULL, mousedTest, NULL, NULL }, - { "4 Disable", "Disable the mouse daemon", NULL, mousedDisable, NULL, NULL }, - { "0 Exit", "Exit this menu (returning to previous)", NULL, dmenuExit }, - { NULL } }, -}; - -DMenu MenuXF86Config = { - DMENU_NORMAL_TYPE | DMENU_SELECTION_RETURNS, - "Please select the XFree86 configuration tool you want to use.", - "The first tool, XF86Setup, is fully graphical and requires the\n" - "VGA16 server in order to work (should have been selected by\n" - "default, but if you de-selected it then you won't be able to\n" - "use this fancy setup tool). The second tool, xf86config, is\n" - "a more simplistic shell-script based tool and less friendly to\n" - "new users, but it may work in situations where the fancier one\n" - "does not.", - "Press F1 to read the XFree86 release notes for FreeBSD", - "XF86", - { { "XF86Setup", "Fully graphical XFree86 configuration tool.", - NULL, dmenuSetVariable, NULL, VAR_XF86_CONFIG "=XF86Setup" }, - { "xf86config", "Shell-script based XFree86 configuration tool.", - NULL, dmenuSetVariable, NULL, VAR_XF86_CONFIG "=xf86config" }, - { "XF98Setup", "Fully graphical XFree86 configuration tool (PC98).", - NULL, dmenuSetVariable, NULL, VAR_XF86_CONFIG "=XF98Setup" }, - { NULL } }, -}; - -DMenu MenuMediaCDROM = { - DMENU_NORMAL_TYPE | DMENU_SELECTION_RETURNS, - "Choose a CDROM type", - "FreeBSD can be installed directly from a CDROM containing a valid\n" - "FreeBSD distribution. If you are seeing this menu it is because\n" - "more than one CDROM drive was found on your system. Please select one\n" - "of the following CDROM drives as your installation drive.", - "Press F1 to read the installation guide", - "install", - { { NULL } }, -}; - -DMenu MenuMediaFloppy = { - DMENU_NORMAL_TYPE | DMENU_SELECTION_RETURNS, - "Choose a Floppy drive", - "You have more than one floppy drive. Please chose which drive\n" - "you would like to use.", - NULL, - NULL, - { { NULL } }, -}; - -DMenu MenuMediaDOS = { - DMENU_NORMAL_TYPE | DMENU_SELECTION_RETURNS, - "Choose a DOS partition", - "FreeBSD can be installed directly from a DOS partition\n" - "assuming, of course, that you have copied the relevant\n" - "distributions into your DOS partition before starting this\n" - "installation. If this is not the case then you should reboot\n" - "DOS at this time and copy the distributions you wish to install\n" - "into a \"FREEBSD\" subdirectory on one of your DOS partitions.\n" - "Otherwise, please select the DOS partition containing the FreeBSD\n" - "distribution files.", - "Press F1 to read the installation guide", - "install", - { { NULL } }, -}; - -DMenu MenuMediaFTP = { - DMENU_NORMAL_TYPE | DMENU_SELECTION_RETURNS, - "Please select a FreeBSD FTP distribution site", - "Please select the site closest to you or \"other\" if you'd like to\n" - "specify a different choice. Also note that not every site listed here\n" - "carries more than the base distribution kits. Only the Primary site is\n" - "guaranteed to carry the full range of possible distributions.", - "Select a site that's close!", - "install", - { { "Primary Site", "ftp.freebsd.org", NULL, dmenuSetVariable, NULL, - VAR_FTP_PATH "=ftp://ftp.freebsd.org/pub/FreeBSD/" }, - { "URL", "Specify some other ftp site by URL", NULL, dmenuSetVariable, NULL, - VAR_FTP_PATH "=other" }, - { "3.0 SNAP Server", "current.freebsd.org", NULL, dmenuSetVariable, NULL, - VAR_FTP_PATH "=ftp://current.freebsd.org/pub/FreeBSD/" }, - { "2.2 SNAP Server", "releng22.freebsd.org", NULL, dmenuSetVariable, NULL, - VAR_FTP_PATH "=ftp://releng22.freebsd.org/pub/FreeBSD/" }, - { "Argentina", "ftp.ar.freebsd.org", NULL, dmenuSetVariable, NULL, - VAR_FTP_PATH "=ftp://ftp.ar.freebsd.org/pub/FreeBSD/" }, - { "Australia", "ftp.au.freebsd.org", NULL, dmenuSetVariable, NULL, - VAR_FTP_PATH "=ftp://ftp.au.freebsd.org/pub/FreeBSD/" }, - { "Australia #2", "ftp2.au.freebsd.org", NULL, dmenuSetVariable, NULL, - VAR_FTP_PATH "=ftp://ftp2.au.freebsd.org/pub/FreeBSD/" }, - { "Australia #3", "ftp3.au.freebsd.org", NULL, dmenuSetVariable, NULL, - VAR_FTP_PATH "=ftp://ftp3.au.freebsd.org/pub/FreeBSD/" }, - { "Australia #4", "ftp4.au.freebsd.org", NULL, dmenuSetVariable, NULL, - VAR_FTP_PATH "=ftp://ftp4.au.freebsd.org/pub/FreeBSD/" }, - { "Australia #5", "ftp5.au.freebsd.org", NULL, dmenuSetVariable, NULL, - VAR_FTP_PATH "=ftp://ftp5.au.freebsd.org/pub/FreeBSD/" }, - { "Brazil", "ftp.br.freebsd.org", NULL, dmenuSetVariable, NULL, - VAR_FTP_PATH "=ftp://ftp.br.freebsd.org/pub/FreeBSD/" }, - { "Brazil #2", "ftp2.br.freebsd.org", NULL, dmenuSetVariable, NULL, - VAR_FTP_PATH "=ftp://ftp2.br.freebsd.org/pub/FreeBSD/" }, - { "Brazil #3", "ftp3.br.freebsd.org", NULL, dmenuSetVariable, NULL, - VAR_FTP_PATH "=ftp://ftp3.br.freebsd.org/pub/FreeBSD/" }, - { "Brazil #4", "ftp4.br.freebsd.org", NULL, dmenuSetVariable, NULL, - VAR_FTP_PATH "=ftp://ftp4.br.freebsd.org/pub/FreeBSD/" }, - { "Brazil #5", "ftp5.br.freebsd.org", NULL, dmenuSetVariable, NULL, - VAR_FTP_PATH "=ftp://ftp5.br.freebsd.org/pub/FreeBSD/" }, - { "Brazil #6", "ftp6.br.freebsd.org", NULL, dmenuSetVariable, NULL, - VAR_FTP_PATH "=ftp://ftp6.br.freebsd.org/pub/FreeBSD/" }, - { "Brazil #7", "ftp7.br.freebsd.org", NULL, dmenuSetVariable, NULL, - VAR_FTP_PATH "=ftp://ftp7.br.freebsd.org/pub/FreeBSD/" }, - { "Canada", "ftp.ca.freebsd.org", NULL, dmenuSetVariable, NULL, - VAR_FTP_PATH "=ftp://ftp.ca.freebsd.org/pub/FreeBSD/" }, - { "Czech Republic", "ftp.cz.freebsd.org", NULL, dmenuSetVariable, NULL, - VAR_FTP_PATH "=ftp://ftp.cz.freebsd.org/pub/FreeBSD/" }, - { "Denmark", "ftp.dk.freebsd.org", NULL, dmenuSetVariable, NULL, - VAR_FTP_PATH "=ftp://ftp.dk.freebsd.org/pub/FreeBSD/" }, - { "Denmark #2", "ftp2.dk.freebsd.org", NULL, dmenuSetVariable, NULL, - VAR_FTP_PATH "=ftp://ftp2.dk.freebsd.org/pub/FreeBSD/" }, - { "Estonia", "ftp.ee.freebsd.org", NULL, dmenuSetVariable, NULL, - VAR_FTP_PATH "=ftp://ftp.ee.freebsd.org/pub/FreeBSD/" }, - { "Finland", "ftp.fi.freebsd.org", NULL, dmenuSetVariable, NULL, - VAR_FTP_PATH "=ftp://ftp.fi.freebsd.org/pub/FreeBSD/" }, - { "France", "ftp.fr.freebsd.org", NULL, dmenuSetVariable, NULL, - VAR_FTP_PATH "=ftp://ftp.fr.freebsd.org/pub/FreeBSD/" }, - { "France #2", "ftp2.fr.freebsd.org", NULL, dmenuSetVariable, NULL, - VAR_FTP_PATH "=ftp://ftp2.fr.freebsd.org/pub/FreeBSD/" }, - { "Germany", "ftp.de.freebsd.org", NULL, dmenuSetVariable, NULL, - VAR_FTP_PATH "=ftp://ftp.de.freebsd.org/pub/FreeBSD/" }, - { "Germany #2", "ftp2.de.freebsd.org", NULL, dmenuSetVariable, NULL, - VAR_FTP_PATH "=ftp://ftp2.de.freebsd.org/pub/FreeBSD/" }, - { "Germany #3", "ftp3.de.freebsd.org", NULL, dmenuSetVariable, NULL, - VAR_FTP_PATH "=ftp://ftp3.de.freebsd.org/pub/FreeBSD/" }, - { "Germany #4", "ftp4.de.freebsd.org", NULL, dmenuSetVariable, NULL, - VAR_FTP_PATH "=ftp://ftp4.de.freebsd.org/pub/FreeBSD/" }, - { "Germany #5", "ftp5.de.freebsd.org", NULL, dmenuSetVariable, NULL, - VAR_FTP_PATH "=ftp://ftp5.de.freebsd.org/pub/FreeBSD/" }, - { "Germany #6", "ftp6.de.freebsd.org", NULL, dmenuSetVariable, NULL, - VAR_FTP_PATH "=ftp://ftp6.de.freebsd.org/pub/FreeBSD/" }, - { "Germany #7", "ftp7.de.freebsd.org", NULL, dmenuSetVariable, NULL, - VAR_FTP_PATH "=ftp://ftp7.de.freebsd.org/pub/FreeBSD/" }, - { "Holland", "ftp.nl.freebsd.org", NULL, dmenuSetVariable, NULL, - VAR_FTP_PATH "=ftp://ftp.nl.freebsd.org/pub/FreeBSD/" }, - { "Hong Kong", "ftp.hk.super.net", NULL, dmenuSetVariable, NULL, - VAR_FTP_PATH "=ftp://ftp.hk.super.net/pub/FreeBSD/" }, - { "Iceland", "ftp.is.freebsd.org", NULL, dmenuSetVariable, NULL, - VAR_FTP_PATH "=ftp://ftp.is.freebsd.org/pub/FreeBSD/" }, - { "Ireland", "ftp.ie.freebsd.org", NULL, dmenuSetVariable, NULL, - VAR_FTP_PATH "=ftp://ftp.ie.freebsd.org/pub/FreeBSD/" }, - { "Israel", "ftp.il.freebsd.org", NULL, dmenuSetVariable, NULL, - VAR_FTP_PATH "=ftp://ftp.il.freebsd.org/pub/FreeBSD/" }, - { "Israel #2", "ftp2.il.freebsd.org", NULL, dmenuSetVariable, NULL, - VAR_FTP_PATH "=ftp://ftp2.il.freebsd.org/pub/FreeBSD/" }, - { "Japan", "ftp.jp.freebsd.org", NULL, dmenuSetVariable, NULL, - VAR_FTP_PATH "=ftp://ftp.jp.freebsd.org/pub/FreeBSD/" }, - { "Japan #2", "ftp2.jp.freebsd.org", NULL, dmenuSetVariable, NULL, - VAR_FTP_PATH "=ftp://ftp2.jp.freebsd.org/pub/FreeBSD/" }, - { "Japan #3", "ftp3.jp.freebsd.org", NULL, dmenuSetVariable, NULL, - VAR_FTP_PATH "=ftp://ftp3.jp.freebsd.org/pub/FreeBSD/" }, - { "Japan #4", "ftp4.jp.freebsd.org", NULL, dmenuSetVariable, NULL, - VAR_FTP_PATH "=ftp://ftp4.jp.freebsd.org/pub/FreeBSD/" }, - { "Japan #5", "ftp5.jp.freebsd.org", NULL, dmenuSetVariable, NULL, - VAR_FTP_PATH "=ftp://ftp5.jp.freebsd.org/pub/FreeBSD/" }, - { "Japan #6", "ftp6.jp.freebsd.org", NULL, dmenuSetVariable, NULL, - VAR_FTP_PATH "=ftp://ftp6.jp.freebsd.org/pub/FreeBSD/" }, - { "Korea", "ftp.kr.freebsd.org", NULL, dmenuSetVariable, NULL, - VAR_FTP_PATH "=ftp://ftp.kr.freebsd.org/pub/FreeBSD/" }, - { "Korea #2", "ftp2.kr.freebsd.org", NULL, dmenuSetVariable, NULL, - VAR_FTP_PATH "=ftp://ftp2.kr.freebsd.org/pub/FreeBSD/" }, - { "Korea #3", "ftp3.kr.freebsd.org", NULL, dmenuSetVariable, NULL, - VAR_FTP_PATH "=ftp://ftp3.kr.freebsd.org/pub/FreeBSD/" }, - { "Korea #4", "ftp4.kr.freebsd.org", NULL, dmenuSetVariable, NULL, - VAR_FTP_PATH "=ftp://ftp4.kr.freebsd.org/pub/FreeBSD/" }, - { "Korea #5", "ftp5.kr.freebsd.org", NULL, dmenuSetVariable, NULL, - VAR_FTP_PATH "=ftp://ftp5.kr.freebsd.org/pub/FreeBSD/" }, - { "Poland", "ftp.pl.freebsd.org", NULL, dmenuSetVariable, NULL, - VAR_FTP_PATH "=ftp://ftp.pl.freebsd.org/pub/FreeBSD/" }, - { "Portugal", "ftp.pt.freebsd.org", NULL, dmenuSetVariable, NULL, - VAR_FTP_PATH "=ftp://ftp.pt.freebsd.org/pub/misc/FreeBSD/" }, - { "Portugal #2", "ftp2.pt.freebsd.org", NULL, dmenuSetVariable, NULL, - VAR_FTP_PATH "=ftp://ftp2.pt.freebsd.org/pub/FreeBSD/" }, - { "Russia", "ftp.ru.freebsd.org", NULL, dmenuSetVariable, NULL, - VAR_FTP_PATH "=ftp://ftp.ru.freebsd.org/pub/FreeBSD/" }, - { "Russia #2", "ftp2.ru.freebsd.org", NULL, dmenuSetVariable, NULL, - VAR_FTP_PATH "=ftp://ftp2.ru.freebsd.org/pub/FreeBSD/" }, - { "Russia #3", "ftp3.ru.freebsd.org", NULL, dmenuSetVariable, NULL, - VAR_FTP_PATH "=ftp://ftp3.ru.freebsd.org/pub/FreeBSD/" }, - { "Russia #4", "ftp4.ru.freebsd.org", NULL, dmenuSetVariable, NULL, - VAR_FTP_PATH "=ftp://ftp4.ru.freebsd.org/pub/FreeBSD/" }, - { "South Africa", "ftp.za.freebsd.org", NULL, dmenuSetVariable, NULL, - VAR_FTP_PATH "=ftp://ftp.za.freebsd.org/pub/FreeBSD/" }, - { "South Africa #2", "ftp2.za.freebsd.org", NULL, dmenuSetVariable, NULL, - VAR_FTP_PATH "=ftp://ftp2.za.freebsd.org/pub/FreeBSD/" }, - { "South Africa #3", "ftp3.za.freebsd.org", NULL, dmenuSetVariable, NULL, - VAR_FTP_PATH "=ftp://ftp3.za.freebsd.org/pub/FreeBSD/" }, - { "South Africa #4", "ftp4.za.freebsd.org", NULL, dmenuSetVariable, NULL, - VAR_FTP_PATH "=ftp://ftp4.za.freebsd.org/pub/FreeBSD/" }, - { "Sweden", "ftp.se.freebsd.org", NULL, dmenuSetVariable, NULL, - VAR_FTP_PATH "=ftp://ftp.se.freebsd.org/pub/FreeBSD/" }, - { "Sweden #2", "ftp2.se.freebsd.org", NULL, dmenuSetVariable, NULL, - VAR_FTP_PATH "=ftp://ftp2.se.freebsd.org/pub/FreeBSD/" }, - { "Sweden #3", "ftp3.se.freebsd.org", NULL, dmenuSetVariable, NULL, - VAR_FTP_PATH "=ftp://ftp3.se.freebsd.org/pub/FreeBSD/" }, - { "Taiwan", "ftp.tw.freebsd.org", NULL, dmenuSetVariable, NULL, - VAR_FTP_PATH "=ftp://ftp.tw.freebsd.org/pub/FreeBSD" }, - { "Taiwan #2", "ftp2.tw.freebsd.org", NULL, dmenuSetVariable, NULL, - VAR_FTP_PATH "=ftp://ftp2.tw.freebsd.org/pub/FreeBSD" }, - { "Taiwan #3", "ftp3.tw.freebsd.org", NULL, dmenuSetVariable, NULL, - VAR_FTP_PATH "=ftp://ftp3.tw.freebsd.org/pub/FreeBSD/" }, - { "Thailand", "ftp.nectec.or.th", NULL, dmenuSetVariable, NULL, - VAR_FTP_PATH "=ftp://ftp.nectec.or.th/pub/mirrors/FreeBSD/" }, - { "UK", "ftp.uk.freebsd.org", NULL, dmenuSetVariable, NULL, - VAR_FTP_PATH "=ftp://ftp.uk.freebsd.org/pub/FreeBSD/" }, - { "UK #2", "ftp2.uk.freebsd.org", NULL, dmenuSetVariable, NULL, - VAR_FTP_PATH "=ftp://ftp2.uk.freebsd.org/pub/FreeBSD/" }, - { "UK #3", "ftp3.uk.freebsd.org", NULL, dmenuSetVariable, NULL, - VAR_FTP_PATH "=ftp://ftp3.uk.freebsd.org/pub/FreeBSD/" }, - { "UK #4", "ftp4.uk.freebsd.org", NULL, dmenuSetVariable, NULL, - VAR_FTP_PATH "=ftp://ftp4.uk.freebsd.org/pub/FreeBSD/" }, - { "USA", "ftp.freebsd.org", NULL, dmenuSetVariable, NULL, - VAR_FTP_PATH "=ftp://ftp.freebsd.org/pub/FreeBSD/" }, - { "USA #2", "ftp2.freebsd.org", NULL, dmenuSetVariable, NULL, - VAR_FTP_PATH "=ftp://ftp2.freebsd.org/pub/FreeBSD/" }, - { "USA #3", "ftp3.freebsd.org", NULL, dmenuSetVariable, NULL, - VAR_FTP_PATH "=ftp://ftp3.freebsd.org/pub/FreeBSD/" }, - { "USA #4", "ftp4.freebsd.org", NULL, dmenuSetVariable, NULL, - VAR_FTP_PATH "=ftp://ftp4.freebsd.org/pub/FreeBSD/" }, - { "USA #5", "ftp5.freebsd.org", NULL, dmenuSetVariable, NULL, - VAR_FTP_PATH "=ftp://ftp5.freebsd.org/pub/FreeBSD/" }, - { "USA #6", "ftp6.freebsd.org", NULL, dmenuSetVariable, NULL, - VAR_FTP_PATH "=ftp://ftp6.freebsd.org/pub/FreeBSD/" }, - { NULL } } -}; - -DMenu MenuMediaTape = { - DMENU_NORMAL_TYPE | DMENU_SELECTION_RETURNS, - "Choose a tape drive type", - "FreeBSD can be installed from tape drive, though this installation\n" - "method requires a certain amount of temporary storage in addition\n" - "to the space required by the distribution itself (tape drives make\n" - "poor random-access devices, so we extract _everything_ on the tape\n" - "in one pass). If you have sufficient space for this, then you should\n" - "select one of the following tape devices detected on your system.", - "Press F1 to read the installation guide", - "install", - { { NULL } }, -}; - -DMenu MenuNetworkDevice = { - DMENU_NORMAL_TYPE | DMENU_SELECTION_RETURNS, - "Network interface information required", - "If you are using PPP over a serial device, as opposed to a direct\n" - "ethernet connection, then you may first need to dial your Internet\n" - "Service Provider using the ppp utility we provide for that purpose.\n" - "If you're using SLIP over a serial device then the expectation is\n" - "that you have a HARDWIRED connection.\n\n" - "You can also install over a parallel port using a special \"laplink\"\n" - "cable to another machine running a fairly recent (2.0R or later)\n" - "version of FreeBSD.", - "Press F1 to read network configuration manual", - "network_device", - { { NULL } }, -}; - -/* The media selection menu */ -DMenu MenuMedia = { - DMENU_NORMAL_TYPE | DMENU_SELECTION_RETURNS, - "Choose Installation Media", - "FreeBSD can be installed from a variety of different installation\n" - "media, ranging from floppies to an Internet FTP server. If you're\n" - "installing FreeBSD from a supported CDROM drive then this is generally\n" - "the best media to use if you have no overriding reason for using other\n" - "media.", - "Press F1 for more information on the various media types", - "media", - { { "1 CDROM", "Install from a FreeBSD CDROM", NULL, mediaSetCDROM }, - { "2 FTP", "Install from an FTP server", NULL, mediaSetFTPActive }, - { "3 FTP Passive", "Install from an FTP server through a firewall", NULL, mediaSetFTPPassive }, - { "4 DOS", "Install from a DOS partition", NULL, mediaSetDOS }, - { "5 NFS", "Install over NFS", NULL, mediaSetNFS }, - { "6 File System", "Install from an existing filesystem", NULL, mediaSetUFS }, - { "7 Floppy", "Install from a floppy disk set", NULL, mediaSetFloppy }, - { "8 Tape", "Install from SCSI or QIC tape", NULL, mediaSetTape }, - { "9 Options", "Go to the Options screen", NULL, optionsEditor }, - { NULL } }, -}; - -/* The distributions menu */ -DMenu MenuDistributions = { - DMENU_CHECKLIST_TYPE | DMENU_SELECTION_RETURNS, - "Choose Distributions", - "As a convenience, we provide several \"canned\" distribution sets.\n" - "These select what we consider to be the most reasonable defaults for the\n" - "type of system in question. If you would prefer to pick and choose the\n" - "list of distributions yourself, simply select \"Custom\". You can also\n" - "pick a canned distribution set and then fine-tune it with the Custom item.\n\n" - "Choose an item by pressing [SPACE]. When you are finished, chose the Exit\n" - "item or press [ENTER].", - "Press F1 for more information on these options.", - "distributions", - { { "1 Developer", "Full sources, binaries and doc but no games", - checkDistDeveloper, distSetDeveloper }, - { "2 X-Developer", "Same as above, but includes the X Window System", - checkDistXDeveloper, distSetXDeveloper }, - { "3 Kern-Developer", "Full binaries and doc, kernel sources only", - checkDistKernDeveloper, distSetKernDeveloper }, - { "4 User", "Average user - binaries and doc only", - checkDistUser, distSetUser }, - { "5 X-User", "Same as above, but includes the X Window System", - checkDistXUser, distSetXUser }, - { "6 Minimal", "The smallest configuration possible", - checkDistMinimum, distSetMinimum }, - { "7 Custom", "Specify your own distribution set", - NULL, dmenuSubmenu, NULL, &MenuSubDistributions, '>', '>', '>' }, - { "8 All", "All sources and binaries (incl X Window System)", - checkDistEverything, distSetEverything }, - { "9 Clear", "Reset selected distribution list to nothing", - NULL, distReset, NULL, NULL, ' ', ' ', ' ' }, - { "0 Exit", "Exit this menu (returning to previous)", - checkTrue, dmenuExit, NULL, NULL, '<', '<', '<' }, - { NULL } }, -}; - -DMenu MenuSubDistributions = { - DMENU_CHECKLIST_TYPE | DMENU_SELECTION_RETURNS, - "Select the distributions you wish to install.", - "Please check off the distributions you wish to install. At the\n" - "very minimum, this should be \"bin\". WARNING: Do not export the\n" - "DES distribution out of the U.S.! It is for U.S. customers only.", - NULL, - NULL, - { { "bin", "Binary base distribution (required)", - dmenuFlagCheck, dmenuSetFlag, NULL, &Dists, '[', 'X', ']', DIST_BIN }, - { "compat1x", "FreeBSD 1.x binary compatibility", - dmenuFlagCheck, dmenuSetFlag, NULL, &Dists, '[', 'X', ']', DIST_COMPAT1X }, - { "compat20", "FreeBSD 2.0 binary compatibility", - dmenuFlagCheck, dmenuSetFlag, NULL, &Dists, '[', 'X', ']', DIST_COMPAT20 }, - { "compat21", "FreeBSD 2.1 binary compatibility", - dmenuFlagCheck, dmenuSetFlag, NULL, &Dists, '[', 'X', ']', DIST_COMPAT21 }, - { "DES", "DES encryption code - NOT FOR EXPORT!", - DESFlagCheck, distSetDES }, - { "dict", "Spelling checker dictionary files", - dmenuFlagCheck, dmenuSetFlag, NULL, &Dists, '[', 'X', ']', DIST_DICT }, - { "doc", "Miscellaneous FreeBSD online docs", - dmenuFlagCheck, dmenuSetFlag, NULL, &Dists, '[', 'X', ']', DIST_DOC }, - { "games", "Games (non-commercial)", - dmenuFlagCheck, dmenuSetFlag, NULL, &Dists, '[', 'X', ']', DIST_GAMES }, - { "info", "GNU info files", - dmenuFlagCheck, dmenuSetFlag, NULL, &Dists, '[', 'X', ']', DIST_INFO }, - { "man", "System manual pages - recommended", - dmenuFlagCheck, dmenuSetFlag, NULL, &Dists, '[', 'X', ']', DIST_MANPAGES }, - { "catman", "Preformatted system manual pages", - dmenuFlagCheck, dmenuSetFlag, NULL, &Dists, '[', 'X', ']', DIST_CATPAGES }, - { "proflibs", "Profiled versions of the libraries", - dmenuFlagCheck, dmenuSetFlag, NULL, &Dists, '[', 'X', ']', DIST_PROFLIBS }, - { "src", "Sources for everything but DES", - srcFlagCheck, distSetSrc }, - { "ports", "The FreeBSD Ports collection", - dmenuFlagCheck, dmenuSetFlag, NULL, &Dists, '[', 'X', ']', DIST_PORTS }, - { "XFree86", "The XFree86 3.3.3 distribution", - x11FlagCheck, distSetXF86 }, - { "All", "All sources, binaries and X Window System binaries", - NULL, distSetEverything, NULL, NULL, ' ', ' ', ' ' }, - { "Clear", "Reset all of the above", - NULL, distReset, NULL, NULL, ' ', ' ', ' ' }, - { "Exit", "Exit this menu (returning to previous)", - checkTrue, dmenuExit, NULL, NULL, '<', '<', '<' }, - { NULL } }, -}; - -DMenu MenuDESDistributions = { - DMENU_CHECKLIST_TYPE | DMENU_SELECTION_RETURNS, - "Select the encryption facilities you wish to install.", - "Please check off any special DES-based encryption distributions\n" - "you would like to install. Please note that these services are NOT FOR\n" - "EXPORT from the United States. For information on non-U.S. FTP\n" - "distributions of this software, please consult the release notes.", - NULL, - NULL, - { { "des", "Basic DES encryption services", - dmenuFlagCheck, dmenuSetFlag, NULL, &DESDists, '[', 'X', ']', DIST_DES_DES, }, - { "krb", "Kerberos encryption services", - dmenuFlagCheck, dmenuSetFlag, NULL, &DESDists, '[', 'X', ']', DIST_DES_KERBEROS }, - { "skerbero", "Sources for Kerberos IV", - dmenuFlagCheck, dmenuSetFlag, NULL, &DESDists, '[', 'X', ']', DIST_DES_SKERBEROS }, - { "ssecure", "Sources for DES", - dmenuFlagCheck, dmenuSetFlag, NULL, &DESDists, '[', 'X', ']', DIST_DES_SSECURE }, - { "scrypto", "Export controlled crypto sources", - dmenuFlagCheck, dmenuSetFlag, NULL, &DESDists, '[', 'X', ']', DIST_DES_SCRYPTO }, - { "Exit", "Exit this menu (returning to previous)", - checkTrue, dmenuExit, NULL, NULL, '<', '<', '<' }, - { NULL } }, -}; - -DMenu MenuSrcDistributions = { - DMENU_CHECKLIST_TYPE | DMENU_SELECTION_RETURNS , - "Select the sub-components of src you wish to install.", - "Please check off those portions of the FreeBSD source tree\n" - "you wish to install.", - NULL, - NULL, - { { "base", "top-level files in /usr/src", - dmenuFlagCheck, dmenuSetFlag, NULL, &SrcDists, '[', 'X', ']', DIST_SRC_BASE }, - { "contrib", "/usr/src/contrib (contributed software)", - dmenuFlagCheck, dmenuSetFlag, NULL, &SrcDists, '[', 'X', ']', DIST_SRC_CONTRIB }, - { "gnu", "/usr/src/gnu (software from the GNU Project)", - dmenuFlagCheck, dmenuSetFlag, NULL, &SrcDists, '[', 'X', ']', DIST_SRC_GNU }, - { "etc", "/usr/src/etc (miscellaneous system files)", - dmenuFlagCheck, dmenuSetFlag, NULL, &SrcDists, '[', 'X', ']', DIST_SRC_ETC }, - { "games", "/usr/src/games (the obvious!)", - dmenuFlagCheck, dmenuSetFlag, NULL, &SrcDists, '[', 'X', ']', DIST_SRC_GAMES }, - { "include", "/usr/src/include (header files)", - dmenuFlagCheck, dmenuSetFlag, NULL, &SrcDists, '[', 'X', ']', DIST_SRC_INCLUDE }, - { "lib", "/usr/src/lib (system libraries)", - dmenuFlagCheck, dmenuSetFlag, NULL, &SrcDists, '[', 'X', ']', DIST_SRC_LIB }, - { "libexec", "/usr/src/libexec (system programs)", - dmenuFlagCheck, dmenuSetFlag, NULL, &SrcDists, '[', 'X', ']', DIST_SRC_LIBEXEC }, - { "release", "/usr/src/release (release-generation tools)", - dmenuFlagCheck, dmenuSetFlag, NULL, &SrcDists, '[', 'X', ']', DIST_SRC_RELEASE }, - { "bin", "/usr/src/bin (system binaries)", - dmenuFlagCheck, dmenuSetFlag, NULL, &SrcDists, '[', 'X', ']', DIST_SRC_BIN }, - { "sbin", "/usr/src/sbin (system binaries)", - dmenuFlagCheck, dmenuSetFlag, NULL, &SrcDists, '[', 'X', ']', DIST_SRC_SBIN }, - { "share", "/usr/src/share (documents and shared files)", - dmenuFlagCheck, dmenuSetFlag, NULL, &SrcDists, '[', 'X', ']', DIST_SRC_SHARE }, - { "sys", "/usr/src/sys (FreeBSD kernel)", - dmenuFlagCheck, dmenuSetFlag, NULL, &SrcDists, '[', 'X', ']', DIST_SRC_SYS }, - { "ubin", "/usr/src/usr.bin (user binaries)", - dmenuFlagCheck, dmenuSetFlag, NULL, &SrcDists, '[', 'X', ']', DIST_SRC_UBIN }, - { "usbin", "/usr/src/usr.sbin (aux system binaries)", - dmenuFlagCheck, dmenuSetFlag, NULL, &SrcDists, '[', 'X', ']', DIST_SRC_USBIN }, - { "smailcf", "/usr/src/usr.sbin (sendmail config macros)", - dmenuFlagCheck, dmenuSetFlag, NULL, &SrcDists, '[', 'X', ']', DIST_SRC_SMAILCF }, - { "All", "Select all of the above", - NULL, setSrc, NULL, NULL, ' ', ' ', ' ' }, - { "Clear", "Reset all of the above", - NULL, clearSrc, NULL, NULL, ' ', ' ', ' ' }, - { "Exit", "Exit this menu (returning to previous)", - checkTrue, dmenuExit, NULL, NULL, '<', '<', '<' }, - { NULL } }, -}; - -DMenu MenuXF86Select = { - DMENU_NORMAL_TYPE, - "XFree86 3.3.3 Distribution", - "Please select the components you need from the XFree86 3.3.3\n" - "distribution sets.", - "Press F1 to read the XFree86 release notes for FreeBSD", - "XF86", - { { "Basic", "Basic component menu (required)", NULL, dmenuSubmenu, NULL, &MenuXF86SelectCore }, - { "Server", "X server menu", NULL, dmenuSubmenu, NULL, &MenuXF86SelectServer }, - { "Fonts", "Font set menu", NULL, dmenuSubmenu, NULL, &MenuXF86SelectFonts }, - { "All", "Select all XFree86 distribution sets", NULL, setX11All }, - { "Clear", "Reset XFree86 distribution list", NULL, clearX11All }, - { "Exit", "Exit this menu (returning to previous)", checkTrue, dmenuExit, NULL, NULL, '<', '<', '<' }, - { NULL } }, -}; - -DMenu MenuXF86SelectCore = { - DMENU_CHECKLIST_TYPE | DMENU_SELECTION_RETURNS, - "XFree86 3.3.3 base distribution types", - "Please check off the basic XFree86 components you wish to install.\n" - "Bin, lib, and set are recommended for a minimum installaion.", - "Press F1 to read the XFree86 release notes for FreeBSD", - "XF86", - { { "bin", "Client applications and shared libs", - dmenuFlagCheck, dmenuSetFlag, NULL, &XF86Dists, '[', 'X', ']', DIST_XF86_BIN }, - { "cfg", "Configuration files", - dmenuFlagCheck, dmenuSetFlag, NULL, &XF86Dists, '[', 'X', ']', DIST_XF86_CFG }, - { "doc", "READMEs and release notes", - dmenuFlagCheck, dmenuSetFlag, NULL, &XF86Dists, '[', 'X', ']', DIST_XF86_DOC }, - { "html", "HTML documentation files", - dmenuFlagCheck, dmenuSetFlag, NULL, &XF86Dists, '[', 'X', ']', DIST_XF86_HTML }, - { "lib", "Data files needed at runtime", - dmenuFlagCheck, dmenuSetFlag, NULL, &XF86Dists, '[', 'X', ']', DIST_XF86_LIB }, - { "lk98", "Server link kit for PC98 machines", - dmenuFlagCheck, dmenuSetFlag, NULL, &XF86Dists, '[', 'X', ']', DIST_XF86_LKIT98 }, - { "lkit", "Server link kit for all other machines", - dmenuFlagCheck, dmenuSetFlag, NULL, &XF86Dists, '[', 'X', ']', DIST_XF86_LKIT }, - { "man", "Manual pages", - dmenuFlagCheck, dmenuSetFlag, NULL, &XF86Dists, '[', 'X', ']', DIST_XF86_MAN }, - { "prog", "Programmer's header and library files", - dmenuFlagCheck, dmenuSetFlag, NULL, &XF86Dists, '[', 'X', ']', DIST_XF86_PROG }, - { "set", "XFree86 Setup Utility", - dmenuFlagCheck, dmenuSetFlag, NULL, &XF86Dists, '[', 'X', ']', DIST_XF86_SET }, - { "9set", "XFree86 Setup Utility for PC98 machines", - dmenuFlagCheck, dmenuSetFlag, NULL, &XF86Dists, '[', 'X', ']', DIST_XF86_9SET }, - { "sources", "XFree86 3.3.3 standard sources", - dmenuFlagCheck, dmenuSetFlag, NULL, &XF86Dists, '[', 'X', ']', DIST_XF86_SRC }, - { "csources", "XFree86 3.3.3 contrib sources", - dmenuFlagCheck, dmenuSetFlag, NULL, &XF86Dists, '[', 'X', ']', DIST_XF86_CSRC }, - { "All", "Select all of the above", - NULL, setX11Misc, NULL, NULL, ' ', ' ', ' ' }, - { "Clear", "Reset all of the above", - NULL, clearX11Misc, NULL, NULL, ' ', ' ', ' ' }, - { "Exit", "Exit this menu (returning to previous)", - checkTrue, dmenuExit, NULL, NULL, '<', '<', '<' }, - { NULL } }, -}; - -DMenu MenuXF86SelectFonts = { - DMENU_CHECKLIST_TYPE | DMENU_SELECTION_RETURNS , - "Font distribution selection.", - "Please check off the individual font distributions you wish to\n\ -install. At the minimum, you should install the standard\n\ -75 DPI and misc fonts if you're also installing a server\n\ -(these are selected by default).", - "Press F1 to read the XFree86 release notes for FreeBSD", - "XF86", - { { "fnts", "Standard 75 DPI and miscellaneous fonts", - dmenuFlagCheck, dmenuSetFlag, NULL, &XF86FontDists, '[', 'X', ']', DIST_XF86_FONTS_MISC }, - { "f100", "100 DPI fonts", - dmenuFlagCheck, dmenuSetFlag, NULL, &XF86FontDists, '[', 'X', ']', DIST_XF86_FONTS_100 }, - { "fcyr", "Cyrillic Fonts", - dmenuFlagCheck, dmenuSetFlag, NULL, &XF86FontDists, '[', 'X', ']', DIST_XF86_FONTS_CYR }, - { "fscl", "Speedo and Type scalable fonts", - dmenuFlagCheck, dmenuSetFlag, NULL, &XF86FontDists, '[', 'X', ']', DIST_XF86_FONTS_SCALE }, - { "non", "Japanese, Chinese and other non-english fonts", - dmenuFlagCheck, dmenuSetFlag, NULL, &XF86FontDists, '[', 'X', ']', DIST_XF86_FONTS_NON }, - { "server", "Font server", - dmenuFlagCheck, dmenuSetFlag, NULL, &XF86FontDists, '[', 'X', ']', DIST_XF86_FONTS_SERVER }, - { "All", "All fonts", - NULL, setX11Fonts, NULL, NULL, ' ', ' ', ' ' }, - { "Clear", "Reset font selections", - NULL, clearX11Fonts, NULL, NULL, ' ', ' ', ' ' }, - { "Exit", "Exit this menu (returning to previous)", - checkTrue, dmenuExit, NULL, NULL, '<', '<', '<' }, - { NULL } }, -}; - -DMenu MenuXF86SelectServer = { - DMENU_CHECKLIST_TYPE | DMENU_SELECTION_RETURNS, - "X Server selection.", - "Please check off the types of X servers you wish to install.\n" - "If you are unsure as to which server will work for your graphics card,\n" - "it is recommended that try the SVGA or VGA16 servers or, for PC98\n" - "machines, the 9EGC or 9840 servers.", - "Press F1 to read the XFree86 release notes for FreeBSD", - "XF86", - { { "SVGA", "Standard VGA or Super VGA card", - dmenuFlagCheck, dmenuSetFlag, NULL, &XF86ServerDists, '[', 'X', ']', DIST_XF86_SERVER_SVGA }, - { "VGA16", "Standard 16 color VGA card", - dmenuFlagCheck, dmenuSetFlag, NULL, &XF86ServerDists, '[', 'X', ']', DIST_XF86_SERVER_VGA16 }, - { "Mono", "Standard Monochrome card", - dmenuFlagCheck, dmenuSetFlag, NULL, &XF86ServerDists, '[', 'X', ']', DIST_XF86_SERVER_MONO }, - { "8514", "8-bit (256 color) IBM 8514 or compatible card", - dmenuFlagCheck, dmenuSetFlag, NULL, &XF86ServerDists, '[', 'X', ']', DIST_XF86_SERVER_8514 }, - { "AGX", "8-bit AGX card", - dmenuFlagCheck, dmenuSetFlag, NULL, &XF86ServerDists, '[', 'X', ']', DIST_XF86_SERVER_AGX }, - { "I128", "8, 16 and 24-bit #9 Imagine I128 card", - dmenuFlagCheck, dmenuSetFlag, NULL, &XF86ServerDists, '[', 'X', ']', DIST_XF86_SERVER_I128 }, - { "Ma8", "8-bit ATI Mach8 card", - dmenuFlagCheck, dmenuSetFlag, NULL, &XF86ServerDists, '[', 'X', ']', DIST_XF86_SERVER_MACH8 }, - { "Ma32", "8 and 16-bit (65K color) ATI Mach32 card", - dmenuFlagCheck, dmenuSetFlag, NULL, &XF86ServerDists, '[', 'X', ']', DIST_XF86_SERVER_MACH32 }, - { "Ma64", "8 and 16-bit (65K color) ATI Mach64 card", - dmenuFlagCheck, dmenuSetFlag, NULL, &XF86ServerDists, '[', 'X', ']', DIST_XF86_SERVER_MACH64 }, - { "P9K", "8, 16, and 24-bit color Weitek P9000 based boards", - dmenuFlagCheck, dmenuSetFlag, NULL, &XF86ServerDists, '[', 'X', ']', DIST_XF86_SERVER_P9000 }, - { "S3", "8, 16 and 24-bit color S3 based boards", - dmenuFlagCheck, dmenuSetFlag, NULL, &XF86ServerDists, '[', 'X', ']', DIST_XF86_SERVER_S3 }, - { "S3V", "8, 16 and 24-bit color S3 Virge based boards", - dmenuFlagCheck, dmenuSetFlag, NULL, &XF86ServerDists, '[', 'X', ']', DIST_XF86_SERVER_S3V }, - { "W32", "8-bit ET4000/W32, /W32i and /W32p cards", - dmenuFlagCheck, dmenuSetFlag, NULL, &XF86ServerDists, '[', 'X', ']', DIST_XF86_SERVER_W32 }, - { "nest", "A nested server for testing purposes", - dmenuFlagCheck, dmenuSetFlag, NULL, &XF86ServerDists, '[', 'X', ']', DIST_XF86_SERVER_NEST }, - { "PC98", "Select an X server for a NEC PC98 [Submenu]", - NULL, dmenuSubmenu, NULL, &MenuXF86SelectPC98Server, '>', ' ', '>', 0 }, - { "All", "Select all of the above", - NULL, setX11Servers, NULL, NULL, ' ', ' ', ' ' }, - { "Clear", "Reset all of the above", - NULL, clearX11Servers, NULL, NULL, ' ', ' ', ' ' }, - { "Exit", "Exit this menu (returning to previous)", - checkTrue, dmenuExit, NULL, NULL, '<', '<', '<' }, - { NULL } }, -}; - -DMenu MenuXF86SelectPC98Server = { - DMENU_CHECKLIST_TYPE | DMENU_SELECTION_RETURNS, - "PC98 X Server selection.", - "Please check off the types of NEC PC98 X servers you wish to install.\n\ -If you are unsure as to which server will work for your graphics card,\n\ -it is recommended that try the SVGA or VGA16 servers (the VGA16 and\n\ -Mono servers are particularly well-suited to most LCD displays).", - "Press F1 to read the XFree86 release notes for FreeBSD", - "XF86", - { { "9480", "PC98 8-bit (256 color) PEGC-480 card", - dmenuFlagCheck, dmenuSetFlag, NULL, &XF86ServerDists, '[', 'X', ']', DIST_XF86_SERVER_9480 }, - { "9EGC", "PC98 4-bit (16 color) EGC card", - dmenuFlagCheck, dmenuSetFlag, NULL, &XF86ServerDists, '[', 'X', ']', DIST_XF86_SERVER_9EGC }, - { "9GA9", "PC98 GA-968V4/PCI (S3 968) card", - dmenuFlagCheck, dmenuSetFlag, NULL, &XF86ServerDists, '[', 'X', ']', DIST_XF86_SERVER_9GA9 }, - { "9GAN", "PC98 GANB-WAP (cirrus) card", - dmenuFlagCheck, dmenuSetFlag, NULL, &XF86ServerDists, '[', 'X', ']', DIST_XF86_SERVER_9GAN }, - { "9LPW", "PC98 PowerWindowLB (S3) card", - dmenuFlagCheck, dmenuSetFlag, NULL, &XF86ServerDists, '[', 'X', ']', DIST_XF86_SERVER_9LPW }, - { "9MGA", "PC98 MGA (Matrox) card", - dmenuFlagCheck, dmenuSetFlag, NULL, &XF86ServerDists, '[', 'X', ']', DIST_XF86_SERVER_9MGA }, - { "9NKV", "PC98 NKV-NEC (cirrus) card", - dmenuFlagCheck, dmenuSetFlag, NULL, &XF86ServerDists, '[', 'X', ']', DIST_XF86_SERVER_9NKV }, - { "9NS3", "PC98 NEC (S3) card", - dmenuFlagCheck, dmenuSetFlag, NULL, &XF86ServerDists, '[', 'X', ']', DIST_XF86_SERVER_9NS3 }, - { "9SPW", "PC98 SKB-PowerWindow (S3) card", - dmenuFlagCheck, dmenuSetFlag, NULL, &XF86ServerDists, '[', 'X', ']', DIST_XF86_SERVER_9SPW }, - { "9SVG", "PC98 generic SVGA card", - dmenuFlagCheck, dmenuSetFlag, NULL, &XF86ServerDists, '[', 'X', ']', DIST_XF86_SERVER_9SVG }, - { "9TGU", "PC98 Cyber9320 and TGUI9680 cards", - dmenuFlagCheck, dmenuSetFlag, NULL, &XF86ServerDists, '[', 'X', ']', DIST_XF86_SERVER_9TGU }, - { "9WEP", "PC98 WAB-EP (cirrus) card", - dmenuFlagCheck, dmenuSetFlag, NULL, &XF86ServerDists, '[', 'X', ']', DIST_XF86_SERVER_9WEP }, - { "9WS", "PC98 WABS (cirrus) card", - dmenuFlagCheck, dmenuSetFlag, NULL, &XF86ServerDists, '[', 'X', ']', DIST_XF86_SERVER_9WS }, - { "9WSN", "PC98 WSN-A2F (cirrus) card", - dmenuFlagCheck, dmenuSetFlag, NULL, &XF86ServerDists, '[', 'X', ']', DIST_XF86_SERVER_9WSN }, - { "Exit", "Exit this menu (returning to previous)", - checkTrue, dmenuExit, NULL, NULL, '<', '<', '<' }, - { NULL } } -}; - -DMenu MenuDiskDevices = { - DMENU_CHECKLIST_TYPE | DMENU_SELECTION_RETURNS, - "Select Drive(s)", - "Please select the drive, or drives, on which you wish to perform\n" - "this operation. If you are attempting to install a boot partition\n" - "on a drive other than the first one or have multiple operating\n" - "systems on your machine, you will have the option to install a boot\n" - "manager later. To select a drive, use the arrow keys to move to it\n" - "and press [SPACE]. To de-select it, press [SPACE] again.\n\n" - "Select OK or Cancel to leave this menu.", - "Press F1 for important information regarding disk geometry!", - "drives", - { { NULL } }, -}; - -DMenu MenuHTMLDoc = { - DMENU_NORMAL_TYPE, - "Select HTML Documentation pointer", - "Please select the body of documentation you're interested in, the main\n" - "ones right now being the FAQ and the Handbook. You can also chose \"other\"\n" - "to enter an arbitrary URL for browsing.", - "Press F1 for more help on what you see here.", - "html", - { { "Handbook", "The FreeBSD Handbook.", NULL, docShowDocument }, - { "FAQ", "The Frequently Asked Questions guide.", NULL, docShowDocument }, - { "Home", "The Home Pages for the FreeBSD Project (requires net)", NULL, docShowDocument }, - { "Other", "Enter a URL.", NULL, docShowDocument }, - { NULL } }, -}; - -/* The main installation menu */ -DMenu MenuInstallCustom = { - DMENU_NORMAL_TYPE, - "Choose Custom Installation Options", - "This is the custom installation menu. You may use this menu to specify\n" - "details on the type of distribution you wish to have, where you wish\n" - "to install it from and how you wish to allocate disk storage to FreeBSD.", - "Press F1 to read the installation guide", - "install", - { { "1 Options", "View/Set various installation options", NULL, optionsEditor }, -#ifdef __alpha__ - { "2 Label", "Label disk partitions", NULL, diskLabelEditor }, - { "3 Distributions", "Select distribution(s) to extract", NULL, dmenuSubmenu, NULL, &MenuDistributions }, - { "4 Media", "Choose the installation media type", NULL, dmenuSubmenu, NULL, &MenuMedia }, - { "5 Commit", "Perform any pending Partition/Label/Extract actions", NULL, installCustomCommit }, -#else - { "2 Partition", "Allocate disk space for FreeBSD", NULL, diskPartitionEditor }, - { "3 Label", "Label allocated disk partitions", NULL, diskLabelEditor }, - { "4 Distributions", "Select distribution(s) to extract", NULL, dmenuSubmenu, NULL, &MenuDistributions }, - { "5 Media", "Choose the installation media type", NULL, dmenuSubmenu, NULL, &MenuMedia }, - { "6 Commit", "Perform any pending Partition/Label/Extract actions", NULL, installCustomCommit }, -#endif - { "0 Exit", "Exit this menu (returning to previous)", NULL, dmenuExit }, - { NULL } }, -}; - -/* MBR type menu */ -DMenu MenuMBRType = { - DMENU_RADIO_TYPE | DMENU_SELECTION_RETURNS, - "overwrite me", /* will be disk specific label */ - "FreeBSD comes with a boot selector that allows you to easily\n" - "select between FreeBSD and any other operating systems on your machine\n" - "at boot time. If you have more than one drive and want to boot\n" - "from the second one, the boot selector will also make it possible\n" - "to do so (limitations in the PC BIOS usually prevent this otherwise).\n" - "If you do not want a boot selector, or wish to replace an existing\n" - "one, select \"standard\". If you would prefer your Master Boot\n" - "Record to remain untouched then select \"None\".\n\n" - " NOTE: PC-DOS users will almost certainly require \"None\"!", - "Press F1 to read about drive setup", - "drives", - { { "BootMgr", "Install the FreeBSD Boot Manager", - dmenuRadioCheck, dmenuSetValue, NULL, &BootMgr }, - { "Standard", "Install a standard MBR (no boot manager)", - dmenuRadioCheck, dmenuSetValue, NULL, &BootMgr, '(', '*', ')', 1 }, - { "None", "Leave the Master Boot Record untouched", - dmenuRadioCheck, dmenuSetValue, NULL, &BootMgr, '(', '*', ')', 2 }, - { NULL } }, -}; - -/* Final configuration menu */ -DMenu MenuConfigure = { - DMENU_NORMAL_TYPE, - "FreeBSD Configuration Menu", /* title */ - "If you've already installed FreeBSD, you may use this menu to customize\n" - "it somewhat to suit your particular configuration. Most importantly,\n" - "you can use the Packages utility to load extra \"3rd party\"\n" - "software not provided in the base distributions.", - "Press F1 for more information on these options", - "configure", - { { "1 User Management", "Add user and group information", - NULL, dmenuSubmenu, NULL, &MenuUsermgmt }, - { "2 Console", "Customize system console behavior", - NULL, dmenuSubmenu, NULL, &MenuSyscons }, - { "3 Time Zone", "Set which time zone you're in", - NULL, dmenuSystemCommand, NULL, "tzsetup" }, - { "4 Media", "Change the installation media type", - NULL, dmenuSubmenu, NULL, &MenuMedia }, - { "5 Mouse", "Configure your mouse", - NULL, dmenuSubmenu, NULL, &MenuMouse, NULL }, - { "6 Networking", "Configure additional network services", - NULL, dmenuSubmenu, NULL, &MenuNetworking }, - { "7 Startup", "Configure system startup options", - NULL, dmenuSubmenu, NULL, &MenuStartup }, - { "8 Options", "View/Set various installation options", - NULL, optionsEditor }, - { "9 Distributions", "Install additional distribution sets", - NULL, distExtractAll }, - { "P Packages", "Install pre-packaged software for FreeBSD", - NULL, configPackages }, - { "R Root Password", "Set the system manager's password", - NULL, dmenuSystemCommand, NULL, "passwd root" }, - { "D HTML Docs", "Go to the HTML documentation menu (post-install)", - NULL, docBrowser }, - { "X XFree86", "Configure XFree86", - NULL, configXEnvironment }, - { "L Label", "The disk Label editor", - NULL, diskLabelEditor }, - { "F Fdisk", "The disk Slice (PC-style partition) Editor", - NULL, diskPartitionEditor }, - { "U Register", "Register yourself or company as a FreeBSD user.", NULL, configRegister }, - { "E Exit", "Exit this menu (returning to previous)", - NULL, dmenuExit }, - { NULL } }, -}; - -DMenu MenuStartup = { - DMENU_CHECKLIST_TYPE | DMENU_SELECTION_RETURNS, - "Startup Services Menu", - "This menu allows you to configure various aspects of your system's\n" - "startup configuration. Remember to use SPACE to select items! The\n" - "RETURN key will leave this menu (as with all checkbox menus).", - NULL, - NULL, - { { "APM", "Auto-power management services (typically laptops)", - dmenuVarCheck, dmenuToggleVariable, NULL, "apm_enable=YES" }, - { "pccard", "Enable PCCARD (AKA PCMCIA) services (also laptops)", - dmenuVarCheck, dmenuToggleVariable, NULL, "pccard_enable=YES" }, - { "pccard mem", "Set PCCARD memory address (if enabled)", - dmenuVarCheck, dmenuISetVariable, NULL, "pccard_mem" }, - { "pccard ifconfig", "List of PCCARD ethernet devices to configure", - dmenuVarCheck, dmenuISetVariable, NULL, "pccard_ifconfig" }, - { " ", " -- ", NULL, NULL, NULL, NULL, ' ', ' ', ' ' }, - { "startup dirs", "Set the list of dirs to look for startup scripts", - dmenuVarCheck, dmenuISetVariable, NULL, "local_startup" }, - { "named", "Run a local name server on this host", - dmenuVarCheck, dmenuToggleVariable, NULL, "named_enable=YES" }, - { "named flags", "Set default flags to named (if enabled)", - dmenuVarCheck, dmenuISetVariable, NULL, "named_flags" }, - { "nis client", "This host wishes to be an NIS client.", - dmenuVarCheck, dmenuToggleVariable, NULL, "nis_client_enable=YES" }, - { "nis server", "This host wishes to be an NIS server.", - dmenuVarCheck, dmenuToggleVariable, NULL, "nis_server_enable=YES" }, - { " ", " -- ", NULL, NULL, NULL, NULL, ' ', ' ', ' ' }, - { "accounting", "This host wishes to run process accounting.", - dmenuVarCheck, dmenuToggleVariable, NULL, "accounting_enable=YES" }, - { "lpd", "This host has a printer and wants to run lpd.", - dmenuVarCheck, dmenuToggleVariable, NULL, "lpd_enable=YES" }, - { "linux", "This host wants to be able to run linux binaries.", - dmenuVarCheck, dmenuToggleVariable, NULL, "linux_enable=YES" }, - { "quotas", "This host wishes to check quotas on startup.", - dmenuVarCheck, dmenuToggleVariable, NULL, "check_quotas=YES" }, - { "SCO", "This host wants to be able to run IBCS2 binaries.", - dmenuVarCheck, dmenuToggleVariable, NULL, "ibcs2_enable=YES" }, - { "Exit", "Exit this menu (returning to previous)", - checkTrue, dmenuExit, NULL, NULL, '<', '<', '<' }, - { NULL } }, -}; - -DMenu MenuNetworking = { - DMENU_CHECKLIST_TYPE | DMENU_SELECTION_RETURNS, - "Network Services Menu", - "You may have already configured one network device (and the other\n" - "various hostname/gateway/name server parameters) in the process\n" - "of installing FreeBSD. This menu allows you to configure other\n" - "aspects of your system's network configuration.", - NULL, - NULL, - { { "Interfaces", "Configure additional network interfaces", - NULL, tcpMenuSelect }, - { "NFS client", "This machine will be an NFS client", - dmenuVarCheck, dmenuToggleVariable, NULL, "nfs_client_enable=YES" }, - { "NFS server", "This machine will be an NFS server", - dmenuVarCheck, configNFSServer, NULL, "nfs_server_enable=YES" }, - { "AMD", "This machine wants to run the auto-mounter service", - dmenuVarCheck, dmenuToggleVariable, NULL, "amd_enable=YES" }, - { "AMD Flags", "Set flags to AMD service (if enabled)", - dmenuVarCheck, dmenuISetVariable, NULL, "amd_flags" }, - { "TCP Extensions", "Allow RFC1323 and RFC1644 TCP extensions?", - dmenuVarCheck, dmenuToggleVariable, NULL, "tcp_extensions=YES" }, - { "Gateway", "This machine will route packets between interfaces", - dmenuVarCheck, dmenuToggleVariable, NULL, "gateway_enable=YES" }, - { "Ntpdate", "Select a clock-synchronization server", - dmenuVarCheck, dmenuSubmenu, NULL, &MenuNTP, '[', 'X', ']', "ntpdate_enable=YES" }, - { "router", "Select routing daemon (default: routed)", - dmenuVarCheck, configRouter, NULL, "router" }, - { "Rwhod", "This machine wants to run the rwho daemon", - dmenuVarCheck, dmenuToggleVariable, NULL, "rwhod_enable=YES" }, - { "Anon FTP", "This machine wishes to allow anonymous FTP.", - dmenuVarCheck, configAnonFTP, NULL, "anon_ftp" }, - { "PCNFSD", "Run authentication server for clients with PC-NFS.", - dmenuVarCheck, configPCNFSD, NULL, "pcnfsd" }, - { "Exit", "Exit this menu (returning to previous)", - checkTrue, dmenuExit, NULL, NULL, '<', '<', '<' }, - { NULL } }, -}; - -DMenu MenuNTP = { - DMENU_RADIO_TYPE | DMENU_SELECTION_RETURNS, - "NTPDATE Server Selection", - "There are a number of time synchronization servers available\n" - "for public use around the Internet. Please select one reasonably\n" - "close to you to have your system time synchronized accordingly.", - "These are the primary open-access NTP servers", - NULL, - { { "None", "No ntp server", - dmenuVarsCheck, dmenuSetVariables, NULL, - "ntpdate_enable=NO,ntpdate_flags=none" }, - { "Other", "Select a site not on this list", - dmenuVarsCheck, configNTP, NULL, NULL }, - { "Australia", "ntp.syd.dms.csiro.au (HP 5061 Cesium Beam)", - dmenuVarsCheck, dmenuSetVariables, NULL, - "ntpdate_enable=YES,ntpdate_flags=ntp.syd.dms.csiro.au" }, - { "Canada", "tick.usask.ca (GOES clock)", - dmenuVarsCheck, dmenuSetVariables, NULL, - "ntpdate_enable=YES,ntpdate_flags=tick.usask.ca" }, - { "France", "canon.inria.fr (TDF clock)", - dmenuVarsCheck, dmenuSetVariables, NULL, - "ntpdate_enable=YES,ntpdate_flags=canon.inria.fr" }, - { "Germany", "ntps1-{0,1,2}.uni-erlangen.de (GPS)", - dmenuVarsCheck, dmenuSetVariables, NULL, - "ntpdate_enable=YES,ntpdate_flags=ntps1-0.uni-erlangen.de" }, - { "Germany #2", "ntps1-0.cs.tu-berlin.de (GPS)", - dmenuVarsCheck, dmenuSetVariables, NULL, - "ntpdate_enable=YES,ntpdate_flags=ntps1-0.cs.tu-berlin.de" }, - { "Japan", "clock.nc.fukuoka-u.ac.jp (GPS clock)", - dmenuVarsCheck, dmenuSetVariables, NULL, - "ntpdate_enable=YES,ntpdate_flags=clock.nc.fukuoka-u.ac.jp" }, - { "Japan #2", "clock.tl.fukuoka-u.ac.jp (GPS clock)", - dmenuVarsCheck, dmenuSetVariables, NULL, - "ntpdate_enable=YES,ntpdate_flags=clock.tl.fukuoka-u.ac.jp" }, - { "Netherlands", "ntp0.nl.net (GPS clock)", - dmenuVarsCheck, dmenuSetVariables, NULL, - "ntpdate_enable=YES,ntpdate_flags=ntp0.nl.net" }, - { "Norway", "timer.unik.no (NTP clock)", - dmenuVarsCheck, dmenuSetVariables, NULL, - "ntpdate_enable=YES,ntpdate_flags=timer.unik.no" }, - { "Sweden", "Time1.Stupi.SE (Cesium/GPS)", - dmenuVarsCheck, dmenuSetVariables, NULL, - "ntpdate_enable=YES,ntpdate_flags=Time1.Stupi.SE" }, - { "Switzerland", "swisstime.ethz.ch (DCF77 clock)", - dmenuVarsCheck, dmenuSetVariables, NULL, - "ntpdate_enable=YES,ntpdate_flags=swisstime.ethz.ch" }, - { "U.S. East Coast", "bitsy.mit.edu (WWV clock)", - dmenuVarsCheck, dmenuSetVariables, NULL, - "ntpdate_enable=YES,ntpdate_flags=bitsy.mit.edu" }, - { "U.S. East Coast #2", "otc1.psu.edu (WWV clock)", - dmenuVarsCheck, dmenuSetVariables, NULL, - "ntpdate_enable=YES,ntpdate_flags=otc1.psu.edu" }, - { "U.S. West Coast", "apple.com (WWV clock)", - dmenuVarsCheck, dmenuSetVariables, NULL, - "ntpdate_enable=YES,ntpdate_flags=apple.com" }, - { "U.S. West Coast #2", "clepsydra.dec.com (GOES clock)", - dmenuVarsCheck, dmenuSetVariables, NULL, - "ntpdate_enable=YES,ntpdate_flags=clepsydra.dec.com" }, - { "U.S. West Coast #3", "clock.llnl.gov (WWVB clock)", - dmenuVarsCheck, dmenuSetVariables, NULL, - "ntpdate_enable=YES,ntpdate_flags=clock.llnl.gov" }, - { "U.S. Midwest", "ncar.ucar.edu (WWVB clock)", - dmenuVarsCheck, dmenuSetVariables, NULL, - "ntpdate_enable=YES,ntpdate_flags=ncar.ucar.edu" }, - { "U.S. Pacific", "chantry.hawaii.net (WWV/H clock)", - dmenuVarsCheck, dmenuSetVariables, NULL, - "ntpdate_enable=YES,ntpdate_flags=chantry.hawaii.net" }, - { "U.S. Southwest", "shorty.chpc.utexas.edu (WWV clock)", - dmenuVarsCheck, dmenuSetVariables, NULL, - "ntpdate_enable=YES,ntpdate_flags=shorty.chpc.utexas.edu" }, - { NULL } }, -}; - -DMenu MenuSyscons = { - DMENU_NORMAL_TYPE, - "System Console Configuration", - "The default system console driver for FreeBSD (syscons) has a\n" - "number of configuration options which may be set according to\n" - "your preference.\n\n" - "When you are done setting configuration options, select Cancel.", - "Configure your system console settings", - NULL, - { { "Font", "Choose an alternate screen font", NULL, dmenuSubmenu, NULL, &MenuSysconsFont }, - { "Keymap", "Choose an alternate keyboard map", NULL, dmenuSubmenu, NULL, &MenuSysconsKeymap }, - { "Repeat", "Set the rate at which keys repeat", NULL, dmenuSubmenu, NULL, &MenuSysconsKeyrate }, - { "Saver", "Configure the screen saver", NULL, dmenuSubmenu, NULL, &MenuSysconsSaver }, - { "Screenmap", "Choose an alternate screenmap", NULL, dmenuSubmenu, NULL, &MenuSysconsScrnmap }, - { "Exit", "Exit this menu (returning to previous)", NULL, dmenuExit }, - { NULL } }, -}; - -DMenu MenuSysconsKeymap = { - DMENU_RADIO_TYPE | DMENU_SELECTION_RETURNS, - "System Console Keymap", - "The default system console driver for FreeBSD (syscons) defaults\n" - "to a standard \"American\" keyboard map. Users in other countries\n" - "(or with different keyboard preferences) may wish to choose one of\n" - "the other keymaps below.\n" - "Note that sysinstall itself only uses the part of the keyboard map\n" - "which is required to generate the ANSI character subset, but your\n" - "choice of keymap will also be saved for later (fuller) use.", - "Choose a keyboard map", - NULL, - { { "Belgian", "Belgian ISO keymap", dmenuVarCheck, dmenuSetKmapVariable, NULL, "keymap=be.iso" }, - { "Brazil CP850", "Brazil CP850 keymap", dmenuVarCheck, dmenuSetKmapVariable, NULL, "keymap=br275.cp850" }, - { "Brazil ISO (accent)", "Brazil ISO keymap (accent keys)", dmenuVarCheck, dmenuSetKmapVariable, NULL, "keymap=br275.iso.acc" }, - { "Brazil ISO", "Brazil ISO keymap", dmenuVarCheck, dmenuSetKmapVariable, NULL, "keymap=br275.iso" }, - { "Danish CP865", "Danish Code Page 865 keymap", dmenuVarCheck, dmenuSetKmapVariable, NULL, "keymap=danish.cp865" }, - { "Danish ISO", "Danish ISO keymap", dmenuVarCheck, dmenuSetKmapVariable, NULL, "keymap=danish.iso" }, - { "French ISO (accent)", "French ISO keymap (accent keys)", dmenuVarCheck, dmenuSetKmapVariable, NULL, "keymap=fr.iso.acc" }, - { "French ISO", "French ISO keymap", dmenuVarCheck, dmenuSetKmapVariable, NULL, "keymap=fr.iso" }, - { "German CP850", "German Code Page 850 keymap", dmenuVarCheck, dmenuSetKmapVariable, NULL, "keymap=german.cp850" }, - { "German ISO", "German ISO keymap", dmenuVarCheck, dmenuSetKmapVariable, NULL, "keymap=german.iso" }, - { "Icelandic (accent)", "Icelandic ISO keymap (accent keys)", dmenuVarCheck, dmenuSetKmapVariable, NULL, "keymap=icelandic.iso.acc" }, - { "Icelandic", "Icelandic ISO keymap", dmenuVarCheck, dmenuSetKmapVariable, NULL, "keymap=icelandic.iso" }, - { "Italian", "Italian ISO keymap", dmenuVarCheck, dmenuSetKmapVariable, NULL, "keymap=it.iso" }, - { "Latin American", "Latin American ISO keymap", dmenuVarCheck, dmenuSetKmapVariable, NULL, "keymap=lat-amer" }, - { "Japanese 106", "Japanese 106 keymap", dmenuVarCheck, dmenuSetKmapVariable, NULL, "keymap=jp.106" }, - { "Norway ISO", "Norwegian ISO keymap", dmenuVarCheck, dmenuSetKmapVariable, NULL, "keymap=norwegian.iso" }, - { "Russia CP866", "Russian CP866 keymap", dmenuVarCheck, dmenuSetKmapVariable, NULL, "keymap=ru.cp866" }, - { "Russia KOI8-R", "Russian KOI8-R keymap", dmenuVarCheck, dmenuSetKmapVariable, NULL, "keymap=ru.koi8-r" }, - { "Slovenian", "Slovenian ISO keymap", dmenuVarCheck, dmenuSetKmapVariable, NULL, "keymap=si.iso.acc" }, - { "Spanish (accent)", "Spanish ISO keymap (accent keys)", dmenuVarCheck, dmenuSetKmapVariable, NULL, "keymap=spanish.iso.acc" }, - { "Spanish", "Spanish ISO keymap", dmenuVarCheck, dmenuSetKmapVariable, NULL, "keymap=spanish.iso" }, - { "Swedish CP850", "Swedish Code Page 850 keymap", dmenuVarCheck, dmenuSetKmapVariable, NULL, "keymap=swedish.cp850" }, - { "Swedish ISO", "Swedish ISO keymap", dmenuVarCheck, dmenuSetKmapVariable, NULL, "keymap=swedish.iso" }, - { "Swiss German", "Swiss German ISO keymap", dmenuVarCheck, dmenuSetKmapVariable, NULL, "keymap=swissgerman.iso" }, - { "U.K. CP850", "United Kingdom Code Page 850 keymap", dmenuVarCheck, dmenuSetKmapVariable, NULL, "keymap=uk.cp850" }, - { "U.K. ISO", "United Kingdom ISO keymap", dmenuVarCheck, dmenuSetKmapVariable, NULL, "keymap=uk.iso" }, - { "U.S. Dvorak", "United States Dvorak keymap", dmenuVarCheck, dmenuSetKmapVariable, NULL, "keymap=us.dvorak" }, - { "U.S. ISO", "United States ISO keymap", dmenuVarCheck, dmenuSetKmapVariable, NULL, "keymap=us.iso" }, - { NULL } }, -}; - -DMenu MenuSysconsKeyrate = { - DMENU_RADIO_TYPE | DMENU_SELECTION_RETURNS, - "System Console Keyboard Repeat Rate", - "This menu allows you to set the speed at which keys repeat\n" - "when held down.", - "Choose a keyboard repeat rate", - NULL, - { { "Slow", "Slow keyboard repeat rate", dmenuVarCheck, dmenuSetVariable, NULL, "keyrate=slow" }, - { "Normal", "\"Normal\" keyboard repeat rate", dmenuVarCheck, dmenuSetVariable, NULL, "keyrate=normal" }, - { "Fast", "Fast keyboard repeat rate", dmenuVarCheck, dmenuSetVariable, NULL, "keyrate=fast" }, - { "Default", "Use default keyboard repeat rate", dmenuVarCheck, dmenuSetVariable, NULL, "keyrate=NO" }, - { NULL } }, -}; - -DMenu MenuSysconsSaver = { - DMENU_RADIO_TYPE | DMENU_SELECTION_RETURNS, - "System Console Screen Saver", - "By default, the console driver will not attempt to do anything\n" - "special with your screen when it's idle. If you expect to leave your\n" - "monitor switched on and idle for long periods of time then you should\n" - "probably enable one of these screen savers to prevent phosphor burn-in.", - "Choose a nifty-looking screen saver", - NULL, - { { "blank", "Simply blank the screen", - dmenuVarCheck, configSaver, NULL, "saver=blank" }, - { "Daemon", "\"BSD Daemon\" animated screen saver", - dmenuVarCheck, configSaver, NULL, "saver=daemon" }, - { "Green", "\"Green\" power saving mode (if supported by monitor)", - dmenuVarCheck, configSaver, NULL, "saver=green" }, - { "Snake", "Draw a FreeBSD \"snake\" on your screen", - dmenuVarCheck, configSaver, NULL, "saver=snake" }, - { "Star", "A \"twinkling stars\" effect", - dmenuVarCheck, configSaver, NULL, "saver=star" }, - { "Timeout", "Set the screen saver timeout interval", - NULL, configSaverTimeout, NULL, NULL, ' ', ' ', ' ' }, - { NULL } }, -}; - -DMenu MenuSysconsScrnmap = { - DMENU_RADIO_TYPE | DMENU_SELECTION_RETURNS, - "System Console Screenmap", - "Unless you load a specific font, most PC hardware defaults to\n" - "displaying characters in the IBM 437 character set. However,\n" - "in the Unix world, this character set is very rarely used. Most\n" - "Western European countries, for example, prefer ISO 8859-1.\n" - "American users won't notice the difference since the bottom half\n" - "of all these character sets is ANSI anyway.\n" - "If your hardware is capable of downloading a new display font,\n" - "you should probably choose that option. However, for hardware\n" - "where this is not possible (e.g. monochrome adapters), a screen\n" - "map will give you the best approximation that your hardware can\n" - "display at all.", - "Choose a screen map", - NULL, - { { "None", "No screenmap, use default font", dmenuVarCheck, dmenuSetVariable, NULL, "scrnmap=NO" }, - { "KOI8-R to IBM866", "Russian KOI8-R to IBM 866 screenmap", dmenuVarCheck, dmenuSetVariable, NULL, "scrnmap=koi8-r2cp866" }, - { "ISO 8859-1 to IBM437", "W-Europe ISO 8859-1 to IBM 437 screenmap", dmenuVarCheck, dmenuSetVariable, NULL, "scrnmap=iso-8859-1_to_cp437" }, - { NULL } }, -}; - -DMenu MenuSysconsFont = { - DMENU_RADIO_TYPE | DMENU_SELECTION_RETURNS, - "System Console Font", - "Most PC hardware defaults to displaying characters in the\n" - "IBM 437 character set. However, in the Unix world, this\n" - "character set is very rarely used. Most Western European\n" - "countries, for example, prefer ISO 8859-1.\n" - "American users won't notice the difference since the bottom half\n" - "of all these charactersets is ANSI anyway. However, they might\n" - "want to load a font anyway to use the 30- or 50-line displays.\n" - "If your hardware is capable of downloading a new display font,\n" - "you can select the appropriate font below.", - "Choose a font", - NULL, - { { "None", "Use default font", dmenuVarCheck, dmenuSetVariables, NULL, - "font8x8=NO,font8x14=NO,font8x16=NO" }, - { "IBM 437", "English", dmenuVarCheck, dmenuSetVariables, NULL, - "font8x8=cp437-8x8,font8x14=cp437-8x14,font8x16=cp437-8x16" }, - { "IBM 850", "Western Europe, IBM encoding", dmenuVarCheck, dmenuSetVariables, NULL, - "font8x8=cp850-8x8,font8x14=cp850-8x14,font8x16=cp850-8x16" }, - { "IBM 865", "Norwegian, IBM encoding", dmenuVarCheck, dmenuSetVariables, NULL, - "font8x8=cp865-8x8,font8x14=cp865-8x14,font8x16=cp865-8x16" }, - { "IBM 866", "Russian, IBM encoding", dmenuVarCheck, dmenuSetVariables, NULL, - "font8x8=cp866-8x8,font8x14=cp866-8x14,font8x16=cp866-8x16" }, - { "ISO 8859-1", "Western Europe, ISO encoding", dmenuVarCheck, dmenuSetVariables, NULL, - "font8x8=iso-8x8,font8x14=iso-8x14,font8x16=iso-8x16" }, - { "KOI8-R", "Russian, KOI8-R encoding", dmenuVarCheck, dmenuSetVariables, NULL, - "font8x8=koi8-r-8x8,font8x14=koi8-r-8x14,font8x16=koi8-r-8x16" }, - { NULL } }, -}; - -DMenu MenuUsermgmt = { - DMENU_NORMAL_TYPE, - "User and group management", - "The submenus here allow to manipulate user groups and\n" - "login accounts.\n", - "Configure your user groups and users", - NULL, - { { "Add user", "Add a new user to the system.", NULL, userAddUser }, - { "Add group", "Add a new user group to the system.", NULL, userAddGroup }, - { "Exit", "Exit this menu (returning to previous)", NULL, dmenuExit }, - { NULL } }, -}; - -DMenu MenuFixit = { - DMENU_NORMAL_TYPE, - "Please choose a fixit option", - "There are three ways of going into \"fixit\" mode:\n" - "- you can use the 2nd FreeBSD CDROM, in which case there will be\n" - " full access to the complete set of FreeBSD commands and utilities,\n" - "- you can use the more limited (but perhaps customized) fixit floppy,\n" - "- or you can start an Emergency Holographic Shell now, which is\n" - " limited to the subset of commands that is already available right now.", - "Press F1 for more detailed repair instructions", - "fixit", -{ { "1 CDROM", "Use the 2nd \"live\" CDROM from the distribution", NULL, installFixitCDROM }, - { "2 Floppy", "Use a floppy generated from the fixit image", NULL, installFixitFloppy }, - { "3 Shell", "Start an Emergency Holographic Shell", NULL, installFixitHoloShell }, - { NULL } }, -}; - diff --git a/usr.sbin/sysinstall/misc.c b/usr.sbin/sysinstall/misc.c deleted file mode 100644 index bb00639028d3..000000000000 --- a/usr.sbin/sysinstall/misc.c +++ /dev/null @@ -1,485 +0,0 @@ -/* - * Miscellaneous support routines.. - * - * $Id: misc.c,v 1.37 1998/01/16 15:07:55 jkh Exp $ - * - * Copyright (c) 1995 - * Jordan Hubbard. 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, - * verbatim and that no modifications are made prior to this - * point in the file. - * 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 JORDAN HUBBARD ``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 JORDAN HUBBARD OR HIS PETS 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, LIFE 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. - * - */ - -#include "sysinstall.h" -#include <ctype.h> -#include <unistd.h> -#include <sys/stat.h> -#include <sys/errno.h> -#include <sys/file.h> -#include <sys/types.h> -#include <dirent.h> -#include <sys/wait.h> -#include <sys/param.h> -#include <sys/mount.h> -#include <ufs/ufs/ufsmount.h> -#include <sys/reboot.h> -#include <sys/dkbad.h> -#include <sys/disklabel.h> - -/* Quick check to see if a file is readable */ -Boolean -file_readable(char *fname) -{ - if (!access(fname, F_OK)) - return TRUE; - return FALSE; -} - -/* Quick check to see if a file is executable */ -Boolean -file_executable(char *fname) -{ - if (!access(fname, X_OK)) - return TRUE; - return FALSE; -} - -/* Concatenate two strings into static storage */ -char * -string_concat(char *one, char *two) -{ - static char tmp[FILENAME_MAX]; - - /* Yes, we're deliberately cavalier about not checking for overflow */ - strcpy(tmp, one); - strcat(tmp, two); - return tmp; -} - -/* sane strncpy() function */ -char * -sstrncpy(char *dst, const char *src, int size) -{ - dst[size] = '\0'; - return strncpy(dst, src, size); -} - -/* Concatenate three strings into static storage */ -char * -string_concat3(char *one, char *two, char *three) -{ - static char tmp[FILENAME_MAX]; - - /* Yes, we're deliberately cavalier about not checking for overflow */ - strcpy(tmp, one); - strcat(tmp, two); - strcat(tmp, three); - return tmp; -} - -/* Clip the whitespace off the end of a string */ -char * -string_prune(char *str) -{ - int len = str ? strlen(str) : 0; - - while (len && isspace(str[len - 1])) - str[--len] = '\0'; - return str; -} - -/* run the whitespace off the front of a string */ -char * -string_skipwhite(char *str) -{ - while (*str && isspace(*str)) - ++str; - return str; -} - -/* copy optionally and allow second arg to be null */ -char * -string_copy(char *s1, char *s2) -{ - if (!s1) - return NULL; - if (!s2) - s1[0] = '\0'; - else - strcpy(s1, s2); - return s1; -} - -/* convert an integer to a string, using a static buffer */ -char * -itoa(int value) -{ - static char buf[13]; - - snprintf(buf, 12, "%d", value); - return buf; -} - -Boolean -directory_exists(const char *dirname) -{ - DIR *tptr; - - if (!dirname) - return FALSE; - if (!strlen(dirname)) - return FALSE; - - tptr = opendir(dirname); - if (!tptr) - return (FALSE); - - closedir(tptr); - return (TRUE); -} - -char * -pathBaseName(const char *path) -{ - char *pt; - char *ret = (char *)path; - - pt = strrchr(path,(int)'/'); - - if (pt != 0) /* if there is a slash */ - { - ret = ++pt; /* start the file after it */ - } - - return(ret); -} - -/* A free guaranteed to take NULL ptrs */ -void -safe_free(void *ptr) -{ - if (ptr) - free(ptr); -} - -/* A malloc that checks errors */ -void * -safe_malloc(size_t size) -{ - void *ptr; - - if (size <= 0) - msgFatal("Invalid malloc size of %d!", size); - ptr = malloc(size); - if (!ptr) - msgFatal("Out of memory!"); - bzero(ptr, size); - return ptr; -} - -/* A realloc that checks errors */ -void * -safe_realloc(void *orig, size_t size) -{ - void *ptr; - - if (size <= 0) - msgFatal("Invalid realloc size of %d!", size); - ptr = realloc(orig, size); - if (!ptr) - msgFatal("Out of memory!"); - return ptr; -} - -/* Create a path biased from the VAR_INSTALL_ROOT variable (if not /) */ -char * -root_bias(char *path) -{ - static char tmp[FILENAME_MAX]; - char *cp = variable_get(VAR_INSTALL_ROOT); - - if (!strcmp(cp, "/")) - return path; - strcpy(tmp, variable_get(VAR_INSTALL_ROOT)); - strcat(tmp, path); - return tmp; -} - -/* - * These next routines are kind of specialized just for building item lists - * for dialog_menu(). - */ - -/* Add an item to an item list */ -dialogMenuItem * -item_add(dialogMenuItem *list, char *prompt, char *title, - int (*checked)(dialogMenuItem *self), - int (*fire)(dialogMenuItem *self), - void (*selected)(dialogMenuItem *self, int is_selected), - void *data, int aux, int *curr, int *max) -{ - dialogMenuItem *d; - - if (*curr == *max) { - *max += 20; - list = (dialogMenuItem *)realloc(list, sizeof(dialogMenuItem) * *max); - } - d = &list[(*curr)++]; - bzero(d, sizeof(*d)); - d->prompt = prompt ? strdup(prompt) : NULL; - d->title = title ? strdup(title) : NULL; - d->checked = checked; - d->fire = fire; - d->selected = selected; - d->data = data; - d->aux = aux; - return list; -} - -/* Toss the items out */ -void -items_free(dialogMenuItem *list, int *curr, int *max) -{ - int i; - - for (i = 0; list[i].prompt; i++) { - safe_free(list[i].prompt); - safe_free(list[i].title); - } - safe_free(list); - *curr = *max = 0; -} - -int -Mkdir(char *ipath) -{ - struct stat sb; - int final; - char *p, *path; - - if (file_readable(ipath) || Fake) - return DITEM_SUCCESS; - - path = strcpy(alloca(strlen(ipath) + 1), ipath); - if (isDebug()) - msgDebug("mkdir(%s)\n", path); - p = path; - if (p[0] == '/') /* Skip leading '/'. */ - ++p; - for (final = FALSE; !final; ++p) { - if (p[0] == '\0' || (p[0] == '/' && p[1] == '\0')) - final = TRUE; - else if (p[0] != '/') - continue; - *p = '\0'; - if (stat(path, &sb)) { - if (errno != ENOENT) { - msgConfirm("Couldn't stat directory %s: %s", path, strerror(errno)); - return DITEM_FAILURE; - } - if (isDebug()) - msgDebug("mkdir(%s..)\n", path); - if (mkdir(path, S_IRWXU | S_IRWXG | S_IRWXO) < 0) { - msgConfirm("Couldn't create directory %s: %s", path,strerror(errno)); - return DITEM_FAILURE; - } - } - *p = '/'; - } - return DITEM_SUCCESS; -} - -int -Mount(char *mountp, void *dev) -{ - struct ufs_args ufsargs; - char device[80]; - char mountpoint[FILENAME_MAX]; - - if (Fake) - return DITEM_SUCCESS; - - if (*((char *)dev) != '/') { - sprintf(device, "%s/dev/%s", RunningAsInit ? "/mnt" : "", (char *)dev); - sprintf(mountpoint, "%s%s", RunningAsInit ? "/mnt" : "", mountp); - } - else { - strcpy(device, dev); - strcpy(mountpoint, mountp); - } - memset(&ufsargs,0,sizeof ufsargs); - - if (Mkdir(mountpoint)) { - msgConfirm("Unable to make directory mountpoint for %s!", mountpoint); - return DITEM_FAILURE; - } - if (isDebug()) - msgDebug("mount %s %s\n", device, mountpoint); - - ufsargs.fspec = device; - if (mount("ufs", mountpoint, RunningAsInit ? MNT_ASYNC | MNT_NOATIME : 0, - (caddr_t)&ufsargs) == -1) { - msgConfirm("Error mounting %s on %s : %s", device, mountpoint, strerror(errno)); - return DITEM_FAILURE; - } - return DITEM_SUCCESS; -} - -WINDOW * -openLayoutDialog(char *helpfile, char *title, int x, int y, int width, int height) -{ - WINDOW *win; - static char help[FILENAME_MAX]; - - /* We need a curses window */ - win = newwin(LINES, COLS, 0, 0); - if (win) { - /* Say where our help comes from */ - if (helpfile) { - use_helpline("Press F1 for more information on this screen."); - use_helpfile(systemHelpFile(helpfile, help)); - } - /* Setup a nice screen for us to splat stuff onto */ - draw_box(win, y, x, height, width, dialog_attr, border_attr); - wattrset(win, dialog_attr); - mvwaddstr(win, y, x + (COLS - strlen(title)) / 2, title); - } - return win; -} - -ComposeObj * -initLayoutDialog(WINDOW *win, Layout *layout, int x, int y, int *max) -{ - ComposeObj *obj = NULL, *first; - int n; - - /* Loop over the layout list, create the objects, and add them - onto the chain of objects that dialog uses for traversal*/ - - n = 0; - while (layout[n].help != NULL) { - int t = TYPE_OF_OBJ(layout[n].type); - - switch (t) { - case STRINGOBJ: - layout[n].obj = NewStringObj(win, layout[n].prompt, layout[n].var, - layout[n].y + y, layout[n].x + x, layout[n].len, layout[n].maxlen); - ((StringObj *)layout[n].obj)->attr_mask = ATTR_OF_OBJ(layout[n].type); - break; - - case BUTTONOBJ: - layout[n].obj = NewButtonObj(win, layout[n].prompt, layout[n].var, layout[n].y + y, layout[n].x + x); - break; - - default: - msgFatal("Don't support this object yet!"); - } - AddObj(&obj, t, (void *) layout[n].obj); - n++; - } - *max = n - 1; - /* Find the first object in the list */ - for (first = obj; first->prev; first = first->prev); - return first; -} - -int -layoutDialogLoop(WINDOW *win, Layout *layout, ComposeObj **obj, int *n, int max, int *cbutton, int *cancel) -{ - char help_line[80]; - int ret, i, len = strlen(layout[*n].help); - - /* Display the help line at the bottom of the screen */ - for (i = 0; i < 79; i++) - help_line[i] = (i < len) ? layout[*n].help[i] : ' '; - help_line[i] = '\0'; - use_helpline(help_line); - display_helpline(win, LINES - 1, COLS - 1); - wrefresh(win); - - /* Ask for libdialog to do its stuff */ - ret = PollObj(obj); - /* Handle special case stuff that libdialog misses. Sigh */ - switch (ret) { - case SEL_ESC: /* Bail out */ - *cancel = TRUE; - return FALSE; - - /* This doesn't work for list dialogs. Oh well. Perhaps - should special case the move from the OK button ``up'' - to make it go to the interface list, but then it gets - awkward for the user to go back and correct screw up's - in the per-interface section */ - case KEY_DOWN: - case SEL_CR: - case SEL_TAB: - if (*n < max) - ++*n; - else - *n = 0; - break; - - /* The user has pressed enter over a button object */ - case SEL_BUTTON: - if (cbutton && *cbutton) - *cancel = TRUE; - else - *cancel = FALSE; - return FALSE; - - case KEY_UP: - case SEL_BACKTAB: - if (*n) - --*n; - else - *n = max; - break; - - case KEY_F(1): - display_helpfile(); - - /* They tried some key combination we don't support - tootle them forcefully! */ - default: - beep(); - } - return TRUE; -} - -WINDOW * -savescr(void) -{ - WINDOW *w; - - w = dupwin(newscr); - return w; -} - -void -restorescr(WINDOW *w) -{ - touchwin(w); - wrefresh(w); - delwin(w); -} - diff --git a/usr.sbin/sysinstall/mouse.c b/usr.sbin/sysinstall/mouse.c deleted file mode 100644 index f02dcf995c50..000000000000 --- a/usr.sbin/sysinstall/mouse.c +++ /dev/null @@ -1,83 +0,0 @@ -/*- - * Copyright (c) 1998 Kazutaka YOKOTA (yokota@zodiac.mech.utsunomiya-u.ac.jp) - * 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. - * 3. The name of the author may not be used to endorse or promote - * products derived from this software without specific prior written - * permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHRO 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 AUTHRO 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. - * - * $Id: mouse.c,v 1.3 1998/03/23 05:59:18 jkh Exp $ - */ - -#include "sysinstall.h" -#include <string.h> - -int -mousedTest(dialogMenuItem *self) -{ - char *type; - char *port; - int ret; - - type = variable_get(VAR_MOUSED_TYPE); - port = variable_get(VAR_MOUSED_PORT); - if ((type == NULL) || (port == NULL) - || (strlen(type) <= 0) || (strlen(port) <= 0) - || (strcmp(type, "NO") == 0)) { - msgConfirm("Please select a mouse protocol and a port first."); - return DITEM_FAILURE; - } - - msgNotify("Trying to start the mouse daemon..."); - if (file_readable("/var/run/moused.pid")) - vsystem("kill `cat /var/run/moused.pid`"); - systemExecute("vidcontrol -m on"); - vsystem("moused -t %s -p %s", type, port); - - ret = msgYesNo("Now move the mouse and see if it works.\n" - "(Note that buttons don't have any effect for now.)\n\n" - " Is the mouse cursor moving?\n"); - systemExecute("vidcontrol -m off"); - if (ret) { - if (file_readable("/var/run/moused.pid")) - vsystem("kill `cat /var/run/moused.pid`"); - variable_set2(VAR_MOUSED, "NO"); - } else { - variable_set2(VAR_MOUSED, "YES"); - vsystem("ln -fs /dev/sysmouse /dev/mouse"); /* backwards compat */ - } - - return DITEM_SUCCESS; -} - -int -mousedDisable(dialogMenuItem *self) -{ - if (file_readable("/var/run/moused.pid")) - vsystem("kill `cat /var/run/moused.pid`"); - variable_set2(VAR_MOUSED, "NO"); - variable_set2(VAR_MOUSED_TYPE, "NO"); - variable_unset(VAR_MOUSED_PORT); - msgConfirm("The mouse daemon is disabled."); - return DITEM_SUCCESS; -} diff --git a/usr.sbin/sysinstall/msg.c b/usr.sbin/sysinstall/msg.c deleted file mode 100644 index e61b7679d241..000000000000 --- a/usr.sbin/sysinstall/msg.c +++ /dev/null @@ -1,320 +0,0 @@ -/* - * The new sysinstall program. - * - * This is probably the last program in the `sysinstall' line - the next - * generation being essentially a complete rewrite. - * - * $Id: msg.c,v 1.46 1997/09/09 16:27:50 jkh Exp $ - * - * Copyright (c) 1995 - * Jordan Hubbard. 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, - * verbatim and that no modifications are made prior to this - * point in the file. - * 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 JORDAN HUBBARD ``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 JORDAN HUBBARD OR HIS PETS 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, LIFE 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. - * - */ - -#include "sysinstall.h" -#include <stdarg.h> -#include <sys/ioctl.h> -#include <machine/console.h> - -Boolean -isDebug(void) -{ - char *cp; - - return (cp = variable_get(VAR_DEBUG)) && strcmp(cp, "no"); -} - -/* Whack up an informational message on the status line, in stand-out */ -void -msgYap(char *fmt, ...) -{ - va_list args; - char *errstr; - int attrs; - - errstr = (char *)alloca(FILENAME_MAX); - va_start(args, fmt); - vsnprintf(errstr, FILENAME_MAX, fmt, args); - va_end(args); - attrs = getattrs(stdscr); - attrset(A_REVERSE); - mvaddstr(StatusLine, 0, errstr); - attrset(attrs); - refresh(); -} - -/* Whack up an informational message on the status line */ -void -msgInfo(char *fmt, ...) -{ - va_list args; - char *errstr; - int i, attrs; - char line[81]; - - attrs = getattrs(stdscr); - /* NULL is a special convention meaning "erase the old stuff" */ - if (!fmt) { - move(StatusLine, 0); - clrtoeol(); - return; - } - errstr = (char *)alloca(FILENAME_MAX); - va_start(args, fmt); - vsnprintf(errstr, FILENAME_MAX, fmt, args); - va_end(args); - memset(line, ' ', 80); - for (i = 0; i < 80; i++) { - if (errstr[i]) - line[i] = errstr[i]; - else - break; - } - line[80] = '\0'; - attrset(ATTR_TITLE); - mvaddstr(StatusLine, 0, line); - attrset(attrs); - move(StatusLine, 79); - refresh(); -} - -/* Whack up a warning on the status line */ -void -msgWarn(char *fmt, ...) -{ - va_list args; - char *errstr; - int attrs; - - errstr = (char *)alloca(FILENAME_MAX); - strcpy(errstr, "Warning: "); - va_start(args, fmt); - vsnprintf((char *)(errstr + strlen(errstr)), FILENAME_MAX, fmt, args); - va_end(args); - attrs = getattrs(stdscr); - beep(); - attrset(ATTR_TITLE); - mvaddstr(StatusLine, 0, errstr); - attrset(attrs); - refresh(); - if (OnVTY && isDebug()) - msgDebug("Warning message `%s'\n", errstr); -} - -/* Whack up an error on the status line */ -void -msgError(char *fmt, ...) -{ - va_list args; - char *errstr; - int attrs; - - errstr = (char *)alloca(FILENAME_MAX); - strcpy(errstr, "Error: "); - va_start(args, fmt); - vsnprintf((char *)(errstr + strlen(errstr)), FILENAME_MAX, fmt, args); - va_end(args); - beep(); - attrs = getattrs(stdscr); - attrset(ATTR_TITLE); - mvaddstr(StatusLine, 0, errstr); - attrset(attrs); - refresh(); - if (OnVTY && isDebug()) - msgDebug("Error message `%s'\n", errstr); -} - -/* Whack up a fatal error on the status line */ -void -msgFatal(char *fmt, ...) -{ - va_list args; - char *errstr; - int attrs; - - errstr = (char *)alloca(FILENAME_MAX); - strcpy(errstr, "Fatal Error: "); - va_start(args, fmt); - vsnprintf((char *)(errstr + strlen(errstr)), FILENAME_MAX, fmt, args); - va_end(args); - beep(); - attrs = getattrs(stdscr); - attrset(ATTR_TITLE); - mvaddstr(StatusLine, 0, errstr); - addstr(" - "); - addstr("PRESS ANY KEY TO "); - if (getpid() == 1) - addstr("REBOOT"); - else - addstr("QUIT"); - attrset(attrs); - refresh(); - if (OnVTY) - msgDebug("Fatal error `%s'!\n", errstr); - getch(); - systemShutdown(1); -} - -/* Put up a message in a popup confirmation box */ -void -msgConfirm(char *fmt, ...) -{ - va_list args; - char *errstr; - - errstr = (char *)alloca(FILENAME_MAX); - va_start(args, fmt); - vsnprintf(errstr, FILENAME_MAX, fmt, args); - va_end(args); - use_helpline(NULL); - use_helpfile(NULL); - if (OnVTY) { - ioctl(0, VT_ACTIVATE, 1); - msgInfo(NULL); - } - dialog_notify(errstr); -} - -/* Put up a message in a popup information box */ -void -msgNotify(char *fmt, ...) -{ - va_list args; - char *errstr; - - errstr = (char *)alloca(FILENAME_MAX); - va_start(args, fmt); - vsnprintf(errstr, FILENAME_MAX, fmt, args); - va_end(args); - use_helpline(NULL); - use_helpfile(NULL); - if (isDebug()) - msgDebug("Notify: %s\n", errstr); - dialog_clear_norefresh(); - dialog_msgbox(NULL, errstr, -1, -1, 0); -} - -/* Put up a message in a popup yes/no box and return 1 for YES, 0 for NO */ -int -msgYesNo(char *fmt, ...) -{ - va_list args; - char *errstr; - int ret; - - errstr = (char *)alloca(FILENAME_MAX); - va_start(args, fmt); - vsnprintf(errstr, FILENAME_MAX, fmt, args); - va_end(args); - use_helpline(NULL); - use_helpfile(NULL); - if (OnVTY) { - ioctl(0, VT_ACTIVATE, 1); /* Switch back */ - msgInfo(NULL); - } - ret = dialog_yesno("User Confirmation Requested", errstr, -1, -1); - return ret; -} - -/* Put up a message in an input box and return the value */ -char * -msgGetInput(char *buf, char *fmt, ...) -{ - va_list args; - char *errstr; - static char input_buffer[256]; - int rval; - - errstr = (char *)alloca(FILENAME_MAX); - va_start(args, fmt); - vsnprintf(errstr, FILENAME_MAX, fmt, args); - va_end(args); - use_helpline(NULL); - use_helpfile(NULL); - if (buf) - SAFE_STRCPY(input_buffer, buf); - else - input_buffer[0] = '\0'; - if (OnVTY) { - ioctl(0, VT_ACTIVATE, 1); /* Switch back */ - msgInfo(NULL); - } - rval = dialog_inputbox("Value Required", errstr, -1, -1, input_buffer); - if (!rval) - return input_buffer; - else - return NULL; -} - -/* Write something to the debugging port */ -void -msgDebug(char *fmt, ...) -{ - va_list args; - char *dbg; - - if (DebugFD == -1) - return; - dbg = (char *)alloca(FILENAME_MAX); - strcpy(dbg, "DEBUG: "); - va_start(args, fmt); - vsnprintf((char *)(dbg + strlen(dbg)), FILENAME_MAX, fmt, args); - va_end(args); - write(DebugFD, dbg, strlen(dbg)); -} - -/* Tell the user there's some output to go look at */ -void -msgWeHaveOutput(char *fmt, ...) -{ - va_list args; - char *errstr; - - errstr = (char *)alloca(FILENAME_MAX); - va_start(args, fmt); - vsnprintf(errstr, FILENAME_MAX, fmt, args); - va_end(args); - use_helpline(NULL); - use_helpfile(NULL); - msgDebug("Notify: %s\n", errstr); - dialog_clear_norefresh(); - dialog_msgbox(NULL, errstr, -1, -1, 0); -} - -/* Simple versions of msgConfirm() and msgNotify() for calling from scripts */ -int -msgSimpleConfirm(char *str) -{ - msgConfirm(str); - return DITEM_SUCCESS; -} - -int -msgSimpleNotify(char *str) -{ - msgNotify(str); - return DITEM_SUCCESS; -} diff --git a/usr.sbin/sysinstall/network.c b/usr.sbin/sysinstall/network.c deleted file mode 100644 index a20e5614ab2c..000000000000 --- a/usr.sbin/sysinstall/network.c +++ /dev/null @@ -1,309 +0,0 @@ -/* - * The new sysinstall program. - * - * This is probably the last attempt in the `sysinstall' line, the next - * generation being slated to essentially a complete rewrite. - * - * $Id: network.c,v 1.32 1998/10/01 19:26:02 msmith Exp $ - * - * Copyright (c) 1995 - * Jordan Hubbard. 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, - * verbatim and that no modifications are made prior to this - * point in the file. - * - * 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 JORDAN HUBBARD ``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 JORDAN HUBBARD OR HIS PETS 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, LIFE 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. - * - */ - -/* These routines deal with getting things off of network media */ - -#include "sysinstall.h" -#include <signal.h> -#include <sys/fcntl.h> -#include <sys/ioctl.h> -#include <sys/stat.h> - -static Boolean networkInitialized; -static pid_t startPPP(Device *devp); - -static pid_t pppPID; - -Boolean -mediaInitNetwork(Device *dev) -{ - int i; - char *rp; - char *cp, ifconfig[255]; - - if (!RunningAsInit || networkInitialized) - return TRUE; - - if (isDebug()) - msgDebug("Init routine called for network device %s.\n", dev->name); - - if (!file_readable("/etc/resolv.conf")) { - if (DITEM_STATUS(configResolv(NULL)) == DITEM_FAILURE) { - msgConfirm("Can't seem to write out /etc/resolv.conf. Net cannot be used."); - return FALSE; - } - } - - /* Old PPP process lying around? */ - if (pppPID) { - msgNotify("Killing previous PPP process %d.", pppPID); - kill(pppPID, SIGTERM); - pppPID = 0; - } - if (!strncmp("ppp", dev->name, 3)) { /* PPP? */ - if (!(pppPID = startPPP(dev))) { - msgConfirm("Unable to start PPP! This installation method cannot be used."); - return FALSE; - } - networkInitialized = TRUE; - return TRUE; - } - else if (!strncmp("sl", dev->name, 2)) { /* SLIP? */ - char *val; - char attach[256]; - - dialog_clear_norefresh(); - /* Cheesy slip attach */ - snprintf(attach, 256, "slattach -a -h -l -s 9600 %s", dev->devname); - val = msgGetInput(attach, - "Warning: SLIP is rather poorly supported in this revision\n" - "of the installation due to the lack of a dialing utility.\n" - "If you can use PPP for this instead then you're much better\n" - "off doing so, otherwise SLIP works fairly well for *hardwired*\n" - "links. Please edit the following slattach command for\n" - "correctness (default here is: VJ compression, Hardware flow-\n" - "control, ignore carrier and 9600 baud data rate). When you're\n" - "ready, press [ENTER] to execute it."); - if (!val) { - msgConfirm("slattach command was empty. Try again!"); - return FALSE; - } - else - SAFE_STRCPY(attach, val); - /* - * Doing this with vsystem() is actually bogus since we should be storing the pid of slattach - * for later killing. It's just too convenient to call vsystem(), however, rather than - * constructing a proper argument for exec() so we punt on doing slip right for now. - */ - if (vsystem(attach)) { - msgConfirm("slattach returned a bad status! Please verify that\n" - "the command is correct and try this operation again."); - return FALSE; - } - } - - snprintf(ifconfig, 255, "%s%s", VAR_IFCONFIG, dev->name); - cp = variable_get(ifconfig); - if (!cp) { - msgConfirm("The %s device is not configured. You will need to do so\n" - "in the Networking configuration menu before proceeding.", dev->name); - return FALSE; - } - msgNotify("ifconfig %s %s", dev->name, cp); - i = vsystem("ifconfig %s %s", dev->name, cp); - if (i) { - msgConfirm("Unable to configure the %s interface!\n" - "This installation method cannot be used.", dev->name); - return FALSE; - } - - rp = variable_get(VAR_GATEWAY); - if (!rp || *rp == '0') { - msgConfirm("No gateway has been set. You may be unable to access hosts\n" - "not on your local network"); - } - else { - msgNotify("Adding default route to %s.", rp); - vsystem("route -n add default %s", rp); - } - if (isDebug()) - msgDebug("Network initialized successfully.\n"); - networkInitialized = TRUE; - return TRUE; -} - -void -mediaShutdownNetwork(Device *dev) -{ - char *cp; - - if (!RunningAsInit || !networkInitialized) - return; - - msgDebug("Shutdown called for network device %s\n", dev->name); - /* Not a serial device? */ - if (strncmp("sl", dev->name, 2) && strncmp("ppp", dev->name, 3)) { - int i; - char ifconfig[255]; - - snprintf(ifconfig, 255, "%s%s", VAR_IFCONFIG, dev->name); - cp = variable_get(ifconfig); - if (!cp) - return; - msgNotify("ifconfig %s down", dev->name); - i = vsystem("ifconfig %s down", dev->name); - if (i) - msgConfirm("Warning: Unable to down the %s interface properly", dev->name); - cp = variable_get(VAR_GATEWAY); - if (cp) { - msgNotify("Deleting default route."); - vsystem("route -n delete default"); - } - } - else if (pppPID) { - msgNotify("Killing previous PPP process %d.", pppPID); - kill(pppPID, SIGTERM); - pppPID = 0; - } - networkInitialized = FALSE; -} - -/* Start PPP on the 3rd screen */ -static pid_t -startPPP(Device *devp) -{ - int fd2; - FILE *fp; - char *val; - pid_t pid = 0; - char myaddr[16], provider[16], speed[16]; - - /* These are needed to make ppp work */ - Mkdir("/var/log"); - Mkdir("/var/run"); - Mkdir("/var/spool/lock"); - Mkdir("/etc/ppp"); - - dialog_clear_norefresh(); - if (!variable_get(VAR_SERIAL_SPEED)) - variable_set2(VAR_SERIAL_SPEED, "115200"); - /* Get any important user values */ - val = variable_get_value(VAR_SERIAL_SPEED, - "Enter the baud rate for your modem - this can be higher than the actual\n" - "maximum data rate since most modems can talk at one speed to the\n" - "computer and at another speed to the remote end.\n\n" - "If you're not sure what to put here, just select the default."); - SAFE_STRCPY(speed, (val && *val) ? val : "115200"); - - val = variable_get(VAR_GATEWAY); - SAFE_STRCPY(provider, (val && *val) ? val : "0"); - - dialog_clear_norefresh(); - val = msgGetInput(provider, "Enter the IP address of your service provider or 0 if you\n" - "don't know it and would prefer to negotiate it dynamically."); - SAFE_STRCPY(provider, (val && *val) ? val : "0"); - - if (devp->private && ((DevInfo *)devp->private)->ipaddr[0]) - SAFE_STRCPY(myaddr, ((DevInfo *)devp->private)->ipaddr); - else - strcpy(myaddr, "0"); - - if (!Fake) - fp = fopen("/etc/ppp/ppp.linkup", "w"); - else - fp = fopen("/dev/stderr", "w"); - if (fp != NULL) { - fprintf(fp, "MYADDR:\n"); - fprintf(fp, " delete ALL\n"); - fprintf(fp, " add 0 0 HISADDR\n"); - fchmod(fileno(fp), 0755); - fclose(fp); - } - if (!Fake) - fd2 = open("/etc/ppp/ppp.secret", O_CREAT); - else - fd2 = -1; - if (fd2 != -1) { - fchmod(fd2, 0700); - close(fd2); - } - if (!Fake) - fp = fopen("/etc/ppp/ppp.conf", "w"); - else - fp = fopen("/dev/stderr", "w"); - if (!fp) { - msgConfirm("Couldn't open /etc/ppp/ppp.conf file! This isn't going to work"); - return 0; - } - fprintf(fp, "default:\n"); - fprintf(fp, " set speed %s\n", speed); - fprintf(fp, " set device %s\n", devp->devname); - fprintf(fp, " set ifaddr %s %s\n", myaddr, provider); - fprintf(fp, " set timeout 0\n"); - fprintf(fp, " enable dns\n"); - fprintf(fp, " set log local phase\n"); - fclose(fp); - - if (!Fake && !file_readable("/dev/tun0") && mknod("/dev/tun0", 0600 | S_IFCHR, makedev(52, 0))) { - msgConfirm("Warning: No /dev/tun0 device. PPP will not work!"); - return 0; - } - - if (isDebug()) - msgDebug("About to start PPP on device %s @ %s baud. Provider = %s\n", devp->devname, speed, provider); - - if (!Fake && !(pid = fork())) { - int i, fd; - struct termios foo; - extern int login_tty(int); - - for (i = getdtablesize(); i >= 0; i--) - close(i); - - /* We're going over to VTY2 */ - fd = open("/dev/ttyv2", O_RDWR); - ioctl(0, TIOCSCTTY, &fd); - dup2(0, 1); - dup2(0, 2); - DebugFD = 2; - if (login_tty(fd) == -1) - msgDebug("ppp: Can't set the controlling terminal.\n"); - signal(SIGTTOU, SIG_IGN); - if (tcgetattr(fd, &foo) != -1) { - foo.c_cc[VERASE] = '\010'; - if (tcsetattr(fd, TCSANOW, &foo) == -1) - msgDebug("ppp: Unable to set the erase character.\n"); - } - else - msgDebug("ppp: Unable to get the terminal attributes!\n"); - execlp("ppp", "ppp", (char *)NULL); - msgDebug("PPP process failed to exec!\n"); - exit(1); - } - else { - dialog_clear_norefresh(); - msgConfirm("NOTICE: The PPP command is now started on VTY3 (type ALT-F3 to\n" - "interact with it, ALT-F1 to switch back here). The only command\n" - "you'll probably want or need to use is the \"term\" command\n" - "which starts a terminal emulator you can use to talk to your\n" - "modem and dial the service provider. Once you're connected,\n" - "come back to this screen and press return.\n\n" - "DO NOT PRESS [ENTER] HERE UNTIL THE CONNECTION IS FULLY\n" - "ESTABLISHED!"); - } - return pid; -} diff --git a/usr.sbin/sysinstall/nfs.c b/usr.sbin/sysinstall/nfs.c deleted file mode 100644 index aeb1dc0fc584..000000000000 --- a/usr.sbin/sysinstall/nfs.c +++ /dev/null @@ -1,93 +0,0 @@ -/* - * The new sysinstall program. - * - * This is probably the last attempt in the `sysinstall' line, the next - * generation being slated to essentially a complete rewrite. - * - * $Id: nfs.c,v 1.18 1997/02/22 14:12:14 peter Exp $ - * - * Copyright (c) 1995 - * Jordan Hubbard. 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, - * verbatim and that no modifications are made prior to this - * point in the file. - * 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 JORDAN HUBBARD ``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 JORDAN HUBBARD OR HIS PETS 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, LIFE 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. - * - */ - -#include "sysinstall.h" -#include <sys/errno.h> -#include <sys/fcntl.h> -#include <sys/syslimits.h> -#include <sys/param.h> -#include <sys/mount.h> - -Boolean NFSMounted; -static char mountpoint[] = "/dist"; - -Boolean -mediaInitNFS(Device *dev) -{ - Device *netDevice = (Device *)dev->private; - - if (NFSMounted) - return TRUE; - - if (netDevice && !netDevice->init(netDevice)) - return FALSE; - - if (Mkdir(mountpoint)) - return FALSE; - - msgNotify("Mounting %s over NFS on %s", dev->name, mountpoint); - if (vsystem("mount_nfs %s %s %s %s", - variable_get(VAR_SLOW_ETHER) ? "-r 1024 -w 1024" : "", - variable_get(VAR_NFS_SECURE) ? "-P" : "", dev->name, mountpoint)) { - msgConfirm("Error mounting %s on %s: %s.", dev->name, mountpoint, strerror(errno)); - if (netDevice) - netDevice->shutdown(netDevice); - return FALSE; - } - NFSMounted = TRUE; - if (isDebug()) - msgDebug("Mounted NFS device %s onto %s\n", dev->name, mountpoint); - return TRUE; -} - -FILE * -mediaGetNFS(Device *dev, char *file, Boolean probe) -{ - return mediaGenericGet(mountpoint, file); -} - -void -mediaShutdownNFS(Device *dev) -{ - if (!NFSMounted) - return; - - msgNotify("Unmounting NFS partition on %s", mountpoint); - if (unmount(mountpoint, MNT_FORCE) != 0) - msgConfirm("Could not unmount the NFS partition: %s", strerror(errno)); - NFSMounted = FALSE; - return; -} diff --git a/usr.sbin/sysinstall/options.c b/usr.sbin/sysinstall/options.c deleted file mode 100644 index b4b724d47c97..000000000000 --- a/usr.sbin/sysinstall/options.c +++ /dev/null @@ -1,304 +0,0 @@ -/* - * The new sysinstall program. - * - * This is probably the last attempt in the `sysinstall' line, the next - * generation being slated for what's essentially a complete rewrite. - * - * $Id: options.c,v 1.55 1997/06/18 05:11:37 jkh Exp $ - * - * Copyright (c) 1995 - * Jordan Hubbard. 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, - * verbatim and that no modifications are made prior to this - * point in the file. - * 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 JORDAN HUBBARD ``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 JORDAN HUBBARD OR HIS PETS 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, LIFE 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. - * - */ - -#include "sysinstall.h" -#include <ctype.h> - -static char * -varCheck(Option opt) -{ - char *cp = NULL; - - if (opt.aux) - cp = variable_get((char *)opt.aux); - if (!cp) - return "NO"; - return cp; -} - -/* Show our little logo */ -static char * -resetLogo(char *str) -{ - return "[RESET!]"; -} - -static char * -mediaCheck(Option opt) -{ - if (mediaDevice) { - switch(mediaDevice->type) { - case DEVICE_TYPE_UFS: - case DEVICE_TYPE_DISK: - return "File system"; - - case DEVICE_TYPE_FLOPPY: - return "Floppy"; - - case DEVICE_TYPE_FTP: - return "FTP"; - - case DEVICE_TYPE_CDROM: - return "CDROM"; - - case DEVICE_TYPE_TAPE: - return "Tape"; - - case DEVICE_TYPE_DOS: - return "DOS"; - - case DEVICE_TYPE_NFS: - return "NFS"; - - case DEVICE_TYPE_NONE: - case DEVICE_TYPE_NETWORK: - case DEVICE_TYPE_ANY: - default: - return "<unknown>"; - } - } - return "<not yet set>"; -} - -#define TAPE_PROMPT "Please enter the tape block size in 512 byte blocks:" -#define RELNAME_PROMPT "Please specify the release you wish to load or\n\"none\" for a generic release install:" -#define BPKG_PROMPT "Please specify the name of the HTML browser package:" -#define BBIN_PROMPT "Please specify a full pathname to the HTML browser binary:" -#define EDITOR_PROMPT "Please specify the name of the text editor you wish to use:" -#define PKG_PROMPT "Please specify a temporary directory with lots of free space:" -#define INSTROOT_PROMPT "Please specify a root directory if installing somewhere other than /" -#define TIMEOUT_PROMPT "Please specify the number of seconds to wait for slow media:" -#define GATED_PKG_PROMPT "Please specify the package name for the gated software:" -#define PCNFSD_PKG_PROMPT "Please specify the package name for the PCNFSD server:" - -static Option Options[] = { -{ "NFS Secure", "NFS server talks only on a secure port", - OPT_IS_VAR, NULL, VAR_NFS_SECURE, varCheck }, -{ "NFS Slow", "User is using a slow PC or ethernet card", - OPT_IS_VAR, NULL, VAR_SLOW_ETHER, varCheck }, -{ "Debugging", "Emit extra debugging output on VTY2 (ALT-F2)", - OPT_IS_VAR, NULL, VAR_DEBUG, varCheck }, -{ "No Warnings", "Don't Warn the user when a setting seems incorrect", - OPT_IS_VAR, NULL, VAR_NO_WARN, varCheck }, -{ "Yes to All", "Assume \"Yes\" answers to all non-critical dialogs", - OPT_IS_VAR, NULL, VAR_NO_CONFIRM, varCheck }, -{ "FTP username", "Username and password to use instead of anonymous", - OPT_IS_FUNC, mediaSetFTPUserPass, VAR_FTP_USER, varCheck }, -{ "Editor", "Which text editor to use during installation", - OPT_IS_VAR, EDITOR_PROMPT, VAR_EDITOR, varCheck }, -{ "Tape Blocksize", "Tape media block size in 512 byte blocks", - OPT_IS_VAR, TAPE_PROMPT, VAR_TAPE_BLOCKSIZE, varCheck }, -{ "Extract Detail", "How verbosely to display file name information during extractions", - OPT_IS_FUNC, mediaSetCPIOVerbosity, VAR_CPIO_VERBOSITY, varCheck }, -{ "Release Name", "Which release to attempt to load from installation media", - OPT_IS_VAR, RELNAME_PROMPT, VAR_RELNAME, varCheck }, -{ "Install Root", "Which directory to unpack distributions or packages relative to", - OPT_IS_VAR, INSTROOT_PROMPT, VAR_INSTALL_ROOT, varCheck }, -{ "Browser package", "This is the browser package that will be used for viewing HTML docs", - OPT_IS_VAR, BPKG_PROMPT, VAR_BROWSER_PACKAGE, varCheck }, -{ "Browser Exec", "This is the path to the main binary of the browser package", - OPT_IS_VAR, BBIN_PROMPT, VAR_BROWSER_BINARY, varCheck }, -{ "Media Type", "The current installation media type.", - OPT_IS_FUNC, mediaGetType, VAR_MEDIA_TYPE, mediaCheck }, -{ "Media Timeout", "Timeout value in seconds for slow media.", - OPT_IS_VAR, TIMEOUT_PROMPT, VAR_MEDIA_TIMEOUT, varCheck }, -{ "Package Temp", "The directory where package temporary files should go", - OPT_IS_VAR, PKG_PROMPT, VAR_PKG_TMPDIR, varCheck }, -{ "Gated package", "The name of the gated package to install if requested", - OPT_IS_VAR, GATED_PKG_PROMPT, VAR_GATED_PKG, varCheck }, -{ "PCNFSD package", "The name of the PCNFSD package to install if requested", - OPT_IS_VAR, PCNFSD_PKG_PROMPT, VAR_PCNFSD_PKG, varCheck }, -{ "Use Defaults", "Reset all values to startup defaults", - OPT_IS_FUNC, installVarDefaults, 0, resetLogo }, -{ NULL }, -}; - -#define OPT_START_ROW 4 -#define OPT_END_ROW 19 -#define OPT_NAME_COL 0 -#define OPT_VALUE_COL 16 -#define GROUP_OFFSET 40 - -static char * -value_of(Option opt) -{ - static char ival[40]; - - switch (opt.type) { - case OPT_IS_STRING: - return (char *)opt.data; - - case OPT_IS_INT: - sprintf(ival, "%d", (int)opt.data); - return ival; - - case OPT_IS_FUNC: - case OPT_IS_VAR: - if (opt.check) - return opt.check(opt); - else - return "<*>"; - } - return "<unknown>"; -} - -static int -fire(Option opt) -{ - int status = 0; - - if (opt.type == OPT_IS_FUNC) { - int (*cp)(char *) = opt.data, rcode; - - rcode = cp(NULL); - if (rcode & (DITEM_RECREATE | DITEM_RESTORE)) - status = 1; - } - else if (opt.type == OPT_IS_VAR) { - if (opt.data) { - (void)variable_get_value(opt.aux, opt.data); - status = 1; - } - else if (variable_get(opt.aux)) - variable_unset(opt.aux); - else - variable_set2(opt.aux, "YES"); - } - if (opt.check) - opt.check(opt); - refresh(); - return status; -} - -int -optionsEditor(dialogMenuItem *self) -{ - int i, optcol, optrow, key; - static int currOpt = 0; - - dialog_clear_norefresh(); - clear(); - - while (1) { - /* Whap up the header */ - attrset(A_REVERSE); mvaddstr(0, 0, "Options Editor"); attrset(A_NORMAL); - for (i = 0; i < 2; i++) { - mvaddstr(OPT_START_ROW - 2, OPT_NAME_COL + (i * GROUP_OFFSET), "Name"); - mvaddstr(OPT_START_ROW - 1, OPT_NAME_COL + (i * GROUP_OFFSET), "----"); - - mvaddstr(OPT_START_ROW - 2, OPT_VALUE_COL + (i * GROUP_OFFSET), "Value"); - mvaddstr(OPT_START_ROW - 1, OPT_VALUE_COL + (i * GROUP_OFFSET), "-----"); - } - /* And the footer */ - mvprintw(OPT_END_ROW + 1, 0, "Use SPACE to select/toggle an option, arrow keys to move,"); - mvprintw(OPT_END_ROW + 2, 0, "? or F1 for more help. When you're done, type Q to Quit."); - - optrow = OPT_START_ROW; - optcol = OPT_NAME_COL; - for (i = 0; Options[i].name; i++) { - /* Names are painted somewhat gratuitously each time, but it's easier this way */ - mvprintw(optrow, OPT_NAME_COL + optcol, Options[i].name); - if (currOpt == i) - attrset(ATTR_SELECTED); - mvprintw(optrow++, OPT_VALUE_COL + optcol, value_of(Options[i])); - if (currOpt == i) - attrset(A_NORMAL); - if (optrow == OPT_END_ROW) { - optrow = OPT_START_ROW; - optcol += GROUP_OFFSET; - } - clrtoeol(); - } - attrset(ATTR_TITLE); - mvaddstr(OPT_END_ROW + 4, 0, Options[currOpt].desc); - attrset(A_NORMAL); - clrtoeol(); - move(0, 14); - refresh(); - - /* Start the edit loop */ - key = toupper(getch()); - switch (key) { - case KEY_F(1): - case '?': - systemDisplayHelp("options"); - clear(); - break; - - case '\020': /* ^P */ - case KEY_UP: - if (currOpt) - --currOpt; - else - for (currOpt = 0; Options[currOpt + 1].name; currOpt++); - continue; - - case '\016': /* ^N */ - case KEY_DOWN: - if (Options[currOpt + 1].name) - ++currOpt; - else - currOpt = 0; - continue; - - case KEY_HOME: - currOpt = 0; - continue; - - case KEY_END: - while (Options[currOpt + 1].name) - ++currOpt; - continue; - - case ' ': - if (fire(Options[currOpt])) - clear(); - continue; - - case '\033': /* ESC */ - case 'Q': - clear(); - dialog_clear(); - return DITEM_SUCCESS | DITEM_RESTORE; - - default: - beep(); - } - } - /* NOTREACHED */ - return DITEM_SUCCESS | DITEM_RESTORE; -} - diff --git a/usr.sbin/sysinstall/package.c b/usr.sbin/sysinstall/package.c deleted file mode 100644 index da1ec9c4a9c7..000000000000 --- a/usr.sbin/sysinstall/package.c +++ /dev/null @@ -1,219 +0,0 @@ -/* - * The new sysinstall program. - * - * This is probably the last program in the `sysinstall' line - the next - * generation being essentially a complete rewrite. - * - * $Id: package.c,v 1.64 1997/09/17 16:18:16 pst Exp $ - * - * Copyright (c) 1995 - * Jordan Hubbard. 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, - * verbatim and that no modifications are made prior to this - * point in the file. - * 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 JORDAN HUBBARD ``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 JORDAN HUBBARD OR HIS PETS 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, LIFE 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. - * - */ - -#include "sysinstall.h" -#include <sys/errno.h> -#include <sys/time.h> -#include <sys/param.h> -#include <sys/mount.h> -#include <sys/stat.h> - -static Boolean sigpipe_caught = FALSE; - -static void -catch_pipe(int sig) -{ - sigpipe_caught = TRUE; -} - -/* Like package_extract, but assumes current media device */ -int -package_add(char *name) -{ - if (!mediaVerify()) - return DITEM_FAILURE; - return package_extract(mediaDevice, name, FALSE); -} - -/* For use by dispatch */ -int -packageAdd(dialogMenuItem *self) -{ - char *cp; - - cp = variable_get(VAR_PACKAGE); - if (!cp) { - msgDebug("packageAdd: No package name passed in package variable\n"); - return DITEM_FAILURE; - } - else - return package_add(cp); -} - -Boolean -package_exists(char *name) -{ - char fname[FILENAME_MAX]; - int status /* = vsystem("pkg_info -e %s", name) */; - - /* XXX KLUDGE ALERT! This makes evil assumptions about how XXX - * packages register themselves and should *really be done with - * `pkg_info -e <name>' except that this it's too slow for an - * item check routine.. :-( - */ - snprintf(fname, FILENAME_MAX, "/var/db/pkg/%s", name); - status = access(fname, R_OK); - if (isDebug()) - msgDebug("package check for %s returns %s.\n", name, status ? "failure" : "success"); - return !status; -} - -/* Extract a package based on a namespec and a media device */ -int -package_extract(Device *dev, char *name, Boolean depended) -{ - char path[511]; - int ret, last_msg = 0; - FILE *fp; - - /* Check to make sure it's not already there */ - if (package_exists(name)) - return DITEM_SUCCESS; - - /* If necessary, initialize the ldconfig hints */ - if (!file_readable("/var/run/ld.so.hints")) - vsystem("ldconfig /usr/lib /usr/local/lib /usr/X11R6/lib"); - - if (!dev->init(dev)) { - msgConfirm("Unable to initialize media type for package extract."); - return DITEM_FAILURE; - } - - /* Be initially optimistic */ - ret = DITEM_SUCCESS | DITEM_RESTORE; - /* Make a couple of paranoid locations for temp files to live if user specified none */ - if (!variable_get(VAR_PKG_TMPDIR)) { - /* Set it to a location with as much space as possible */ - variable_set2(VAR_PKG_TMPDIR, "/usr/tmp"); - } - Mkdir(variable_get(VAR_PKG_TMPDIR)); - vsystem("chmod 1777 %s", variable_get(VAR_PKG_TMPDIR)); - - if (!index(name, '/')) - sprintf(path, "packages/All/%s%s", name, strstr(name, ".tgz") ? "" : ".tgz"); - else - sprintf(path, "%s%s", name, strstr(name, ".tgz") ? "" : ".tgz"); - fp = dev->get(dev, path, TRUE); - if (fp) { - int i = 0, tot, pfd[2]; - pid_t pid; - - signal(SIGPIPE, catch_pipe); - msgNotify("Adding %s%s\nfrom %s", path, depended ? " (as a dependency)" : "", dev->name); - pipe(pfd); - pid = fork(); - if (!pid) { - dup2(pfd[0], 0); close(pfd[0]); - dup2(DebugFD, 1); - close(2); - close(pfd[1]); - i = execl("/usr/sbin/pkg_add", "/usr/sbin/pkg_add", "-", 0); - if (isDebug()) - msgDebug("pkg_add returns %d status\n", i); - } - else { - char buf[BUFSIZ]; - WINDOW *w = savescr(); - struct timeval start, stop; - - close(pfd[0]); - tot = 0; - (void)gettimeofday(&start, (struct timezone *)0); - - while (!sigpipe_caught && (i = fread(buf, 1, BUFSIZ, fp)) > 0) { - int seconds; - - tot += i; - /* Print statistics about how we're doing */ - (void) gettimeofday(&stop, (struct timezone *)0); - stop.tv_sec = stop.tv_sec - start.tv_sec; - stop.tv_usec = stop.tv_usec - start.tv_usec; - if (stop.tv_usec < 0) - stop.tv_sec--, stop.tv_usec += 1000000; - seconds = stop.tv_sec + (stop.tv_usec / 1000000.0); - if (!seconds) - seconds = 1; - if (seconds != last_msg) { - last_msg = seconds; - msgInfo("%10d bytes read from package %s @ %4.1f KBytes/second", tot, name, (tot / seconds) / 1024.0); - } - /* Write it out */ - if (sigpipe_caught || write(pfd[1], buf, i) != i) { - msgInfo("Write failure to pkg_add! Package may be corrupt."); - break; - } - } - close(pfd[1]); - fclose(fp); - if (sigpipe_caught) - msgInfo("pkg_add(1) apparently did not like the %s package.", name); - else if (i == -1) - msgInfo("I/O error while reading in the %s package.", name); - else - msgInfo("Package %s read successfully - waiting for pkg_add(1)", name); - refresh(); - i = waitpid(pid, &tot, 0); - if (sigpipe_caught || i < 0 || WEXITSTATUS(tot)) { - if (variable_get(VAR_NO_CONFIRM)) - msgNotify("Add of package %s aborted, error code %d -\n" - "Please check the debug screen for more info.", name, WEXITSTATUS(tot)); - else - msgConfirm("Add of package %s aborted, error code %d -\n" - "Please check the debug screen for more info.", name, WEXITSTATUS(tot)); - } - else - msgNotify("Package %s was added successfully", name); - - /* Now catch any stragglers */ - while (wait3(&tot, WNOHANG, NULL) > 0); - - sleep(1); - restorescr(w); - sigpipe_caught = FALSE; - } - } - else { - dialog_clear_norefresh(); - if (variable_get(VAR_NO_CONFIRM)) - msgNotify("Unable to fetch package %s from selected media.\n" - "No package add will be done.", name); - else - msgConfirm("Unable to fetch package %s from selected media.\n" - "No package add will be done.", name); - ret = DITEM_FAILURE | DITEM_RESTORE; - } - return ret; -} diff --git a/usr.sbin/sysinstall/rtermcap.c b/usr.sbin/sysinstall/rtermcap.c deleted file mode 100644 index 84b3feb49ead..000000000000 --- a/usr.sbin/sysinstall/rtermcap.c +++ /dev/null @@ -1,15 +0,0 @@ -#include <stdio.h> -#include <termcap.h> - -int -main(int argc, char **argv) -{ - char buf[4096]; - int i; - - if (argc < 2) - return 1; - i = tgetent(buf, argv[1]); - printf("%s",buf); - return 0; -} diff --git a/usr.sbin/sysinstall/sysinstall.8 b/usr.sbin/sysinstall/sysinstall.8 deleted file mode 100644 index 2be7509309bb..000000000000 --- a/usr.sbin/sysinstall/sysinstall.8 +++ /dev/null @@ -1,802 +0,0 @@ -.\" Copyright (c) 1997 -.\" Jordan Hubbard <jkh@freebsd.org>. 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 Jordan Hubbard 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 Jordan Hubbard 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. -.\" -.\" $Id: sysinstall.8,v 1.13 1998/12/02 03:27:37 jkh Exp $ -.\" -.Dd August 9, 1997 -.Dt SYSINSTALL 8 -.Os -.Sh NAME -.Nm sysinstall -.Nd system installation and configuration tool -.Sh SYNOPSIS -.Nm -.Op Ar var=value -.Op Ar function -.Op Ar ... -.Sh DESCRIPTION -.Nm -is a utility for installing and configuring FreeBSD systems. -It is the first utility invoked by the FreeBSD installation boot -floppy and is also copied into -.Pa /stand/sysinstall -on newly installed FreeBSD systems for use in later configuring the system. -.Pp -The -.Nm -program is generally invoked without arguments for the default -behavior, where the main installation/configuration menu is presented. - -On those occasions where it is deemed necessary to invoke a subsystem -of sysinstall directly, however, it is also possible to do so by -naming the appropriate function entry points on the command line. -Since this action is essentially identical to running an installation -script, each command-line argument corresponding to a line of script, -the reader is encouraged to read the section on scripting for more -information on this feature. -.Pp -.Sh NOTES -.Nm -is essentially nothing more than a monolithic C program with -the ability to write MBRs and disk labels (through the services -of the -.Xr libdisk 3 -library) and install distributions or packages onto new and -existing FreeBSD systems. It also contains some extra intelligence -for running as a replacement for -.Xr init 8 -when it's invoked by the FreeBSD installation boot procedure. It -assumes very little in the way of additional utility support and -performs most file system operations by calling the relevant syscalls -(such as -.Xr mount 2 ) -directly. -.Pp -.Nm -currently uses the -.Xr libdialog 3 -library to do user interaction with simple ANSI line graphics, color -support for which is enabled by either running on a syscons VTY or some -other color-capable terminal emulator (newer versions of xterm will support -color when using the ``xterm-color'' termcap entry). -.Pp -This product is currently at the end of its life cycle and will -be replaced in FreeBSD 3.1 (hopefully) by the -.Xr setup 1 -utility. -.Sh RUNNING SCRIPTS -.Nm -may be either driven interactively through its various internal menus -or run in batch mode, driven by an external script. Such a script may -be loaded and executed in one of 3 ways: - -.Bl -tag -width Ds -compact -.It Sy "LOAD_CONFIG_FILE" -If -.Nm -is compiled with LOAD_CONFIG_FILE set in the environment -(or in the Makefile) to some value, then that value will -be used as the filename to automatically look for and load -when -.Nm -starts up and with no user interaction required. -This option is aimed primarily at large sites who wish to create a -single prototype install for multiple machines with largely identical -configurations and/or installation options. - -.It Sy "MAIN MENU" -If -.Nm -is run interactively, that is to say in the default manner, it will -bring up a main menu which contains a "load config file" option. -Selecting this option will prompt for the name of a script file which -it then will attempt to load from a DOS or UFS formatted floppy. - -.It Sy "COMMAND LINE" -Each command line argument is treated as a script directive -when -.Nm -is run in multi-user mode. Execution ends either by explicit request -(e.g. calling the -.Ar shutdown -directive), upon reaching the end of the argument list or on error. -.Pp -For example: -.nf - -/stand/sysinstall ftp=ftp:/ziggy/pub/ mediaSetFTP configPackages - -.fi -Would initialize -.Nm -for FTP installation media (using the server `ziggy') and then -bring up the package installation editor, exiting when finished. -.El -.Pp -.Sh SCRIPT SYNTAX -A script is a list of one or more directives, each directive taking -the form of: - -.Ar var=value -.Pp -.Ar function -.Pp -or -.Ar #somecomment - -Where -.Ar var=value -is the assignment of some internal -.Nm -variable, e.g. "ftpPass=FuNkYChiKn", and -.Ar function -is the name of an internal -.Nm -function, e.g. "mediaSetFTP", and -.Ar #comment -is a single-line comment for documentation purposes (ignored by -sysinstall). Each directive must be by itself on a single line, -functions taking their arguments by examining known variable names. -This requires that you be sure to assign the relevant variables before -calling a function which requires them. When and where a function -depends on the settings of one or more variables will be noted in the -following table: - -.Pp -\fBFunction Glossary:\fR -.Pp -.Bl -tag -width indent -.It configAnonFTP -Invoke the Anonymous FTP configuration menu. -.Pp -\fBVariables:\fR None -.It configRouter -Select which routing daemon you wish to use, potentially -loading any required 3rd-party routing daemons as necessary. -.Pp -\fBVariables:\fR -.Bl -tag -width indent -.It router -can be set to the name of the desired routing daemon, -e.g. ``routed'' or ``gated'', otherwise it is prompted for. -.El -.It configNFSServer -Configure host as an NFS server. -.Pp -\fBVariables:\fR None -.It configNTP -Configure host as a user of the Network Time Protocol. -.Pp -\fBVariables:\fR -.Bl -tag -width indent -.It ntpdate_flags -The flags to -.Xr ntpdate 8 , -that is to say the name of the server to sync from. -.El -.It configPCNFSD -Configure host to support PC NFS. -.Pp -\fBVariables:\fR -.Bl -tag -width indent -.It pcnfsd_pkg -The name of the PCNFSD package to load if necessary (defaults to hard coded -version). -.El -.It configPackages -Bring up the interactive package management menu. -.Pp -\fBVariables:\fR None -.It configRegister -Register the user with the FreeBSD counter. -.Pp -\fBVariables:\fR None -.It configUsers -Add users and/or groups to the system. -.Pp -\fBVariables:\fR None -.It configXEnvironment -Configure the X display subsystem. -.Pp -\fBVariables:\fR None -.It diskPartitionEditor -Invokes the disk partition (MBR) editor. -.Pp -\fBVariables:\fR -.Bl -tag -width findx -.It geometry -The disk geometry, as a cyls/heads/sectors formatted string. Default: no -change to geometry. -.It partition -Set to disk partitioning type or size, its value being -.Ar free -in order to use only remaining free space for FreeBSD, -.Ar all -to use the entire disk for FreeBSD but maintain a proper partition -table, -.Ar existing -to use an existing FreeBSD partition (first found), -.Ar exclusive -to use the disk in ``dangerously dedicated'' mode or, finally, -.Ar somenumber -to allocate -.Ar somenumber -blocks of available free space to a new FreeBSD partition. -Default: Interactive mode. -.It bootManager -is set to one of -.Ar boot -to signify the installation of a boot manager, -.Ar standard -to signify installation of a "standard" non-boot MGR DOS -MBR or -.Ar none -to indicate that no change to the boot manager is desired. -Default: none. -.El -.Pp -Note: Nothing is actually written to disk by this function, a explicit call to -.Ar diskPartitionWrite -being required for that to happen. -.It diskPartitionWrite -Causes any pending MBR changes (typically from the -.Ar diskPartitionEditor -function) to be written out. -.Pp -\fBVariables:\fR None -.It diskLabelEditor -Invokes the disk label editor. This is a bit trickier from a script -since you need to essentially label everything inside each FreeBSD -(type 0xA5) partition created by the -.Ar diskPartitionEditor -function, and that requires knowing a few rules about how things are -laid out. When creating a script to automatically allocate disk space -and partition it up, it is suggested that you first perform the -installation interactively at least once and take careful notes as to -what the slice names will be, then and only then hardwiring them into -the script. -.Pp -For example, let's say you have a SCSI disk on which you've created a new -FreeBSD partition in slice 2 (your DOS partition residing in slice 1). -The slice name would be -.Ar da0s2 -for the whole FreeBSD partition ( -.Ar da0s1 -being your DOS primary -partition). Now let's further assume that you have 500MB in this -partition and you want to sub-partition that space into root, swap, -var and usr file systems for FreeBSD. Your invocation of the -.Ar diskLabelEditor -function might involve setting the following variables: -.Bl -tag -width findx -.It Li "da0s2-1=ufs 40960 /" -A 20MB root file system (all sizes are in 512 byte blocks). -.It Li "da0s2-2=swap 131072 /" -A 64MB swap partition. -.It Li "da0s2-3=ufs 204800 /var" -A 100MB /var file system. -.It Li "da0s2-4=ufs 0 /usr" -With the balance of free space (around 316MB) going to the /usr -file system. -.El - -One can also use the -.Ar diskLabelEditor -for mounting or erasing existing partitions as well as creating new -ones. Using the previous example again, let's say that we also wanted -to mount our DOS partition and make sure that an -.Pa /etc/fstab -entry is created for it in the new installation. Before calling the -.Ar diskLabelEditor -function, we simply add an additional line: -.nf - da0s1=/dos_c N - -.fi -before the call. This tells the label editor that you want to mount -the first slice on -.Pa /dos_c -and not to attempt to newfs it (not that -.Nm -would attempt this for a DOS partition in any case, but it could just -as easily be an existing UFS partition being named here and the 2nd -field is non-optional). -.Pp -Note: No file system data is actually written to disk until an -explicit call to -.Ar diskLabelCommit -is made. -.It diskLabelCommit -Writes out all pending disklabel information and creates and/or mounts any -file systems which have requests pending from the -.Ar diskLabelEditor -function. -.Pp -\fBVariables:\fR None -.It distReset -Resets all selected distributions to the empty set (no distributions selected). -.Pp -\fBVariables:\fR None -.It distSetCustom -Allows the selection of a custom distribution set (e.g. not just on of the -existing "canned" sets) with no user interaction. -\fBVariables:\fR -.Bl -tag -width indent -.It dists -List of distributions to load. Possible distribution values are: -.Bl -tag -width indent -.It Li bin -The base binary distribution. -.It Li doc -Miscellaneous documentation -.It Li games -Games -.It Li manpages -Manual pages (unformatted) -.It Li catpages -Pre-formatted manual pages -.It Li proflibs -Profiled libraries for developers. -.It Li dict -Dictionary information (for tools like spell). -.It Li info -GNU info files and other extra docs. -.It Li des -DES encryption binaries and libraries. -.It Li compat1x -Compatibility with FreeBSD 1.x -.It Li compat20 -Compatibility with FreeBSD 2.0 -.It Li compat21 -Compatibility with FreeBSD 2.1 -.It Li ports -The ports collection. -.It Li krb -Kerberos binaries. -.It Li ssecure -/usr/src/secure -.It Li sebones -/usr/src/eBones -.It Li sbase -/usr/src/[top level files] -.It Li scontrib -/usr/src/contrib -.It Li sgnu -/usr/src/gnu -.It Li setc -/usr/src/etc -.It Li sgames -/usr/src/games -.It Li sinclude -/usr/src/include -.It Li slib -/usr/src/lib -.It Li slibexec -/usr/src/libexec -.It Li srelease -/usr/src/release -.It Li sbin -/usr/src/bin -.It Li ssbin -/usr/src/sbin -.It Li sshare -/usr/src/share -.It Li ssys -/usr/src/sys -.It Li subin -/usr/src/usr.bin -.It Li susbin -/usr/src/usr.sbin -.It Li ssmailcf -/usr/src/usr.sbin/sendmail/cf -.It Li XF86-xc -XFree86 official sources. -.It Li XF86-co -XFree86 contributed sources. -.It Li Xbin -XFree86 3.3.3 binaries. -.It Li Xcfg -XFree86 3.3.3 configuration files. -.It Li Xdoc -XFree86 3.3.3 documentation. -.It Li Xhtml -XFree86 3.3.3 HTML documentation. -.It Li Xlib -XFree86 3.3.3 libraries. -.It Li Xlk98 -XFree86 3.3.3 server link-kit for PC98 machines. -.It Li Xlkit -XFree86 3.3.3 server link-kit for standard machines. -.It Li Xman -XFree86 3.3.3 manual pages. -.It Li Xprog -XFree86 3.3.3 programmer's distribution. -.It Li Xps -XFree86 3.3.3 postscript documentation. -.It Li Xset -XFree86 3.3.3 graphical setup tool. -.It Li X8514 -XFree86 3.3.3 8514 server. -.It Li X9480 -XFree86 3.3.3 PC98 8-bit (256 color) PEGC-480 server. -.It Li X9EGC -XFree86 3.3.3 PC98 4-bit (16 color) EGC server. -.It Li X9GA9 -XFree86 3.3.3 PC98 GA-968V4/PCI (S3 968) server. -.It Li X9GAN -XFree86 3.3.3 PC98 GANB-WAP (cirrus) server. -.It Li X9LPW -XFree86 3.3.3 PC98 PowerWindowLB (S3) server. -.It Li X9NKV -XFree86 3.3.3 PC98 NKV-NEC (cirrus) server. -.It Li X9NS3 -XFree86 3.3.3 PC98 NEC (S3) server. -.It Li X9SPW -XFree86 3.3.3 PC98 SKB-PowerWindow (S3) server. -.It Li X9TGU -XFree86 3.3.3 PC98 Cyber9320 and TGUI9680 server. -.It Li X9WEP -XFree86 3.3.3 PC98 WAB-EP (cirrus) server. -.It Li X9WS -XFree86 3.3.3 PC98 WABS (cirrus) server. -.It Li X9WSN -XFree86 3.3.3 PC98 WSN-A2F (cirrus) server. -.It Li XAGX -XFree86 3.3.3 8 bit AGX server. -.It Li XI128 -XFree86 3.3.3 #9 Imagine I128 server. -.It Li XMa8 -XFree86 3.3.3 ATI Mach8 server. -.It Li XMa32 -XFree86 3.3.3 ATI Mach32 server. -.It Li XMa64 -XFree86 3.3.3 ATI Mach64 server. -.It Li XMono -XFree86 3.3.3 monochrome server. -.It Li XP9K -XFree86 3.3.3 P9000 server. -.It Li XS3 -XFree86 3.3.3 S3 server. -.It Li XS3V -XFree86 3.3.3 S3 Virge server. -.It Li XSVGA -XFree86 3.3.3 SVGA server. -.It Li XVG16 -XFree86 3.3.3 VGA16 server. -.It Li XW32 -XFree86 3.3.3 ET4000/W32, /W32i and /W32p server. -.It Li Xnest -XFree86 3.3.3 nested X server. -.It Li Xvfb -XFree86 3.3.3 virtual frame-buffer X server. -.It Li Xfnts -XFree86 3.3.3 base font set. -.It Li Xf100 -XFree86 3.3.3 100DPI font set. -.It Li Xfcyr -XFree86 3.3.3 Cyrillic font set. -.It Li Xfscl -XFree86 3.3.3 scalable font set. -.It Li Xfnon -XFree86 3.3.3 non-english font set. -.It Li Xfsrv -XFree86 3.3.3 font server. -.El -.It distSetDeveloper -Selects the standard Developer's distribution set. -.Pp -\fBVariables:\fR None -.It distSetXDeveloper -Selects the standard X Developer's distribution set. -.Pp -\fBVariables:\fR None -.It distSetKernDeveloper -Selects the standard kernel Developer's distribution set. -.Pp -\fBVariables:\fR None -.It distSetUser -Selects the standard user distribution set. -.Pp -\fBVariables:\fR None -.It distSetXUser -Selects the standard X user's distribution set. -.Pp -\fBVariables:\fR None -.It distSetMinimum -Selects the very minimum distribution set. -.Pp -\fBVariables:\fR None -.It distSetEverything -Selects the full whack - all available distributions. -.Pp -\fBVariables:\fR None -.It distSetDES -Interactively select DES subcomponents. -.Pp -\fBVariables:\fR None -.It distSetSrc -Interactively select source subcomponents. -.Pp -\fBVariables:\fR None -.It distSetXF86 -Interactively select XFree86 3.3.3 subcomponents. -.Pp -\fBVariables:\fR None -.It distExtractAll -Install all currently selected distributions (requires that -media device also be selected). -.Pp -\fBVariables:\fR None -.It docBrowser -Install (if necessary) an HTML documentation browser and go to the -HTML documentation submenu. -.Pp -\fBVariables:\fR -.Bl -tag -width indent -.It browserPackage -The name of the browser package to try and install as necessary. -Defaults to latest lynx package. -.It browserBinary -The name of the browser binary itself (if overriding the -.Ar browserPackage -variable). Defaults to lynx. -.El -.It installCommit -.Pp -Commit any and all pending changes to disk. This function -is essentially shorthand for a number of more granular "commit" -functions. -\fBVariables:\fR None -.It installExpress -Start an "express" installation, asking few questions of -the user. -.Pp -\fBVariables:\fR None -.It installNovice -Start a "novice" installation, the most user-friendly -installation type available. -.Pp -\fBVariables:\fR None -.It installUpgrade -Start an upgrade installation. -.Pp -\fBVariables:\fR None -.It installFixitHoloShell -Start up the "emergency holographic shell" over on VTY4 -if running as init. -.Pp -\fBVariables:\fR None -.It installFixitCDROM -Go into "fixit" mode, assuming a live file system CDROM -currently in the drive. -.Pp -\fBVariables:\fR None -.It installFixitFloppy -Go into "fixit" mode, assuming an available fixit floppy -disk (user will be prompted for it). -.Pp -\fBVariables:\fR None -.It installFilesystems -Do just the file system initialization part of an install. -.Pp -\fBVariables:\fR None -.It installVarDefaults -Initialize all variables to their defaults, overriding any -previous settings. -.Pp -\fBVariables:\fR None -.It loadConfig -Sort of like an #include statement, it allows you to load one -configuration file from another. -.Pp -\fBVariables:\fR -.Bl -tag -width indent -.It file -The fully pathname of the file to load. -.El -.It mediaSetCDROM -Select a FreeBSD CDROM as the installation media. -.Pp -\fBVariables:\fR None -.It mediaSetFloppy -Select a pre-made floppy installation set as the installation media. -.Pp -\fBVariables:\fR None -.It mediaSetDOS -Select an existing DOS primary partition as the installation media. -The first primary partition found is used (e.g. C:). -.Pp -\fBVariables:\fR None -.It mediaSetTape -Select a tape device as the installation media. -.Pp -\fBVariables:\fR None -.It mediaSetFTP -Select an FTP site as the installation media. -.Pp -\fBVariables:\fR -.Bl -tag -width indent -.It hostname -The name of the host being installed (non-optional). -.It domainname -The domain name of the host being installed (optional). -.It defaultrouter -The default router for this host (non-optional). -.It netDev -Which host interface to use ( -.Ar ed0 -or -.Ar ep0 , -for example. Non-optional). -.It netInteractive -If set, bring up the interactive network setup form even -if all relevant configuration variables are already set (optional). -.It ipaddr -The IP address for the selected host interface (non-optional). -.It netmask -The netmask for the selected host interface (non-optional). -.It ftp -The fully qualified URL of the FTP site containing the FreeBSD -distribution you're interested in, e.g. -.Ar ftp://ftp.freebsd.org/pub/FreeBSD/ . -.El -.It mediaSetFTPActive -Alias for -.Ar mediaSetFTP -using "active" FTP transfer mode. -.Pp -\fBVariables:\fR Same as for -.Ar mediaSetFTP . -.It mediaSetFTPPassive -Alias for -.Ar mediaSetFTP -using "passive" FTP transfer mode. -.Pp -\fBVariables:\fR Same as for -.Ar mediaSetFTP . -.It mediaSetUFS -Select an existing UFS partition (mounted with the label editor) as -the installation media. -.Pp -\fBVariables:\fR -.Bl -tag -width indent -.It ufs -full /path to directory containing the FreeBSD distribution you're -interested in. -.El -.It mediaSetNFS -.Pp -\fBVariables:\fR -.Bl -tag -width indent -.It hostname -The name of the host being installed (non-optional). -.It domainname -The domain name of the host being installed (optional). -.It defaultrouter -The default router for this host (non-optional). -.It netDev -Which host interface to use ( -.Ar ed0 -or -.Ar ep0 , -for example. Non-optional). -.It netInteractive -If set, bring up the interactive network setup form even -if all relevant configuration variables are already set (optional). -.It ipaddr -The IP address for the selected host interface (non-optional). -.It netmask -The netmask for the selected host interface (non-optional). -.It nfs -full hostname:/path specification for directory containing -the FreeBSD distribution you're interested in. -.El -.It mediaSetFTPUserPass -.Pp -\fBVariables:\fR -.Bl -tag -width indent -.It ftpUser -The username to log in as on the ftp server site. -Default: ftp -.It ftpPass -The password to use for this username on the ftp -server site. -Default: user@host -.El -.It mediaSetCPIOVerbosity -.Pp -\fBVariables:\fR -.Bl -tag -width indent -.It cpioVerbose -Can be used to set the verbosity of cpio extractions to low, medium or -high. -.El -.It mediaGetType -Interactively get the user to specify some type of media. -.Pp -\fBVariables:\fR None -.It optionsEditor -Invoke the interactive options editor. -.Pp -\fBVariables:\fR None -.It register -Bring up the FreeBSD registration form. -.Pp -\fBVariables:\fR None -.It packageAdd -Try to fetch and add a package to the system (requires -that a media type be set), -.Pp -\fBVariables:\fR -.Bl -tag -width indent -.It package -The name of the package to add, e.g. bash-1.14.7 or ncftp-2.4.2. -.El -.It addGroup -Invoke the interactive group editor. -.Pp -\fBVariables:\fR None -.It addUser -Invoke the interactive user editor. -.Pp -\fBVariables:\fR None -.It shutdown -Stop the script and terminate sysinstall. -.Pp -\fBVariables:\fR None -.It system -Execute an arbitrary command with -.Xr system 3 -.Pp -\fBVariables:\fR -.Bl -tag -width indent -.It command -The name of the command to execute. When running -from a boot floppy, very minimal expectations should -be made as to what's available until/unless a relatively -full system installation has just been done. -.El -.El -.Sh FILES -This utility may edit the contents of -.Pa /etc/rc.conf , -.Pa /etc/hosts , -and -.Pa /etc/resolv.conf -as necessary to reflect changes in the network configuration. -.Sh SEE ALSO -If you have a reasonably complete source tree online, take -a look at -.Pa /usr/src/release/sysinstall/install.cfg -for a sample installation script. -.Sh BUGS -This utility is a prototype which lasted approximately 3 years past -its expiration date and is greatly in need of death. -.Sh AUTHOR -Jordan K. Hubbard <jkh@FreeBSD.org> -.Sh HISTORY -This version of -.Nm -first appeared in -.Fx 2.0 . diff --git a/usr.sbin/sysinstall/sysinstall.h b/usr.sbin/sysinstall/sysinstall.h deleted file mode 100644 index a50eb3ee4050..000000000000 --- a/usr.sbin/sysinstall/sysinstall.h +++ /dev/null @@ -1,716 +0,0 @@ -/* - * The new sysinstall program. - * - * This is probably the last attempt in the `sysinstall' line, the next - * generation being slated to essentially a complete rewrite. - * - * $Id: sysinstall.h,v 1.152 1998/12/22 12:31:25 jkh Exp $ - * - * Copyright (c) 1995 - * Jordan Hubbard. 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, - * verbatim and that no modifications are made prior to this - * point in the file. - * 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 JORDAN HUBBARD ``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 JORDAN HUBBARD OR HIS PETS 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, LIFE 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. - * - */ - -#ifndef _SYSINSTALL_H_INCLUDE -#define _SYSINSTALL_H_INCLUDE - -#include <sys/types.h> -#include <sys/wait.h> -#include <errno.h> -#include <setjmp.h> -#include <stdio.h> -#include <stdlib.h> -#include <string.h> -#include <unistd.h> -#include <dialog.h> -#include "ui_objects.h" -#include "dir.h" -#include "colors.h" -#include "libdisk.h" -#include "dist.h" - -/*** Defines ***/ - -/* device limits */ -#define DEV_NAME_MAX 64 /* The maximum length of a device name */ -#define DEV_MAX 100 /* The maximum number of devices we'll deal with */ -#define INTERFACE_MAX 50 /* Maximum number of network interfaces we'll deal with */ -#define IO_ERROR -2 /* Status code for I/O error rather than normal EOF */ - -/* Number of seconds to wait for data to come off even the slowest media */ -#define MEDIA_TIMEOUT 300 - -/* - * I make some pretty gross assumptions about having a max of 50 chunks - * total - 8 slices and 42 partitions. I can't easily display many more - * than that on the screen at once! - * - * For 2.1 I'll revisit this and try to make it more dynamic, but since - * this will catch 99.99% of all possible cases, I'm not too worried. - */ -#define MAX_CHUNKS 40 - -/* Internal environment variable names */ -#define DISK_PARTITIONED "_diskPartitioned" -#define DISK_LABELLED "_diskLabelled" -#define DISK_SELECTED "_diskSelected" -#define SYSTEM_STATE "_systemState" -#define RUNNING_ON_ROOT "_runningOnRoot" -#define TCP_CONFIGURED "_tcpConfigured" - -/* Ones that can be tweaked from config files */ -#define VAR_BLANKTIME "blanktime" -#define VAR_BOOTMGR "bootManager" -#define VAR_BROWSER_BINARY "browserBinary" -#define VAR_BROWSER_PACKAGE "browserPackage" -#define VAR_CPIO_VERBOSITY "cpioVerbose" -#define VAR_DEBUG "debug" -#define VAR_DISK "disk" -#define VAR_DISTS "dists" -#define VAR_DIST_MAIN "distMain" -#define VAR_DIST_DES "distDES" -#define VAR_DIST_SRC "distSRC" -#define VAR_DIST_X11 "distX11" -#define VAR_DIST_XSERVER "distXserver" -#define VAR_DIST_XFONTS "distXfonts" -#define VAR_DEDICATE_DISK "dedicateDisk" -#define VAR_DOMAINNAME "domainname" -#define VAR_EDITOR "editor" -#define VAR_EXTRAS "ifconfig_" -#define VAR_COMMAND "command" -#define VAR_CONFIG_FILE "configFile" -#define VAR_FTP_DIR "ftpDirectory" -#define VAR_FTP_PASS "ftpPass" -#define VAR_FTP_PATH "ftp" -#define VAR_FTP_PORT "ftpPort" -#define VAR_FTP_STATE "ftpState" -#define VAR_FTP_USER "ftpUser" -#define VAR_FTP_HOST "ftpHost" -#define VAR_GATED_PKG "gated_pkg" -#define VAR_GATEWAY "defaultrouter" -#define VAR_GEOMETRY "geometry" -#define VAR_HOSTNAME "hostname" -#define VAR_IFCONFIG "ifconfig_" -#define VAR_INTERFACES "network_interfaces" -#define VAR_INSTALL_CFG "installConfig" -#define VAR_INSTALL_ROOT "installRoot" -#define VAR_IPADDR "ipaddr" -#define VAR_KEYMAP "keymap" -#define VAR_LABEL "label" -#define VAR_LABEL_COUNT "labelCount" -#define VAR_MEDIA_TYPE "mediaType" -#define VAR_MEDIA_TIMEOUT "MEDIA_TIMEOUT" -#define VAR_MOUSED "moused_enable" -#define VAR_MOUSED_PORT "moused_port" -#define VAR_MOUSED_TYPE "moused_type" -#define VAR_NAMESERVER "nameserver" -#define VAR_NETINTERACTIVE "netInteractive" -#define VAR_NETMASK "netmask" -#define VAR_NETWORK_DEVICE "netDev" -#define VAR_NFS_PATH "nfs" -#define VAR_NFS_HOST "nfsHost" -#define VAR_NFS_SECURE "nfsSecure" -#define VAR_NFS_SERVER "nfs_server_enable" -#define VAR_NO_CONFIRM "noConfirm" -#define VAR_NO_ERROR "noError" -#define VAR_NO_WARN "noWarn" -#define VAR_NO_USR "noUsr" -#define VAR_NONINTERACTIVE "nonInteractive" -#define VAR_NOVELL "novell" -#define VAR_NTPDATE_FLAGS "ntpdate_flags" -#define VAR_PACKAGE "package" -#define VAR_PARTITION "partition" -#define VAR_PCNFSD "pcnfsd" -#define VAR_PCNFSD_PKG "pcnfsd_pkg" -#define VAR_PKG_TMPDIR "PKG_TMPDIR" -#define VAR_PORTS_PATH "ports" -#define VAR_RELNAME "releaseName" -#define VAR_ROOT_SIZE "rootSize" -#define VAR_ROUTER "router" -#define VAR_ROUTER_ENABLE "router_enable" -#define VAR_ROUTERFLAGS "routerflags" -#define VAR_SERIAL_SPEED "serialSpeed" -#define VAR_SLOW_ETHER "slowEthernetCard" -#define VAR_SWAP_SIZE "swapSize" -#define VAR_TAPE_BLOCKSIZE "tapeBlocksize" -#define VAR_UFS_PATH "ufs" -#define VAR_USR_SIZE "usrSize" -#define VAR_VAR_SIZE "varSize" -#define VAR_XF86_CONFIG "xf86config" - -#define DEFAULT_TAPE_BLOCKSIZE "20" - -/* One MB worth of blocks */ -#define ONE_MEG 2048 - -/* Which selection attributes to use */ -#define ATTR_SELECTED (ColorDisplay ? item_selected_attr : item_attr) -#define ATTR_TITLE button_active_attr - -/* Handy strncpy() macro */ -#define SAFE_STRCPY(to, from) sstrncpy((to), (from), sizeof (to) - 1) - -/*** Types ***/ -typedef unsigned int Boolean; -typedef struct disk Disk; -typedef struct chunk Chunk; - -/* Bitfields for menu options */ -#define DMENU_NORMAL_TYPE 0x1 /* Normal dialog menu */ -#define DMENU_RADIO_TYPE 0x2 /* Radio dialog menu */ -#define DMENU_CHECKLIST_TYPE 0x4 /* Multiple choice menu */ -#define DMENU_SELECTION_RETURNS 0x8 /* Immediate return on item selection */ - -typedef struct _dmenu { - int type; /* What sort of menu we are */ - char *title; /* Our title */ - char *prompt; /* Our prompt */ - char *helpline; /* Line of help at bottom */ - char *helpfile; /* Help file for "F1" */ - dialogMenuItem items[0]; /* Array of menu items */ -} DMenu; - -/* An rc.conf variable */ -typedef struct _variable { - struct _variable *next; - char *name; - char *value; -} Variable; - -#define NO_ECHO_OBJ(type) ((type) | (DITEM_NO_ECHO << 16)) -#define TYPE_OF_OBJ(type) ((type) & 0xff) -#define ATTR_OF_OBJ(type) ((type) >> 16) - -/* A screen layout structure */ -typedef struct _layout { - int y; /* x & Y co-ordinates */ - int x; - int len; /* The size of the dialog on the screen */ - int maxlen; /* How much the user can type in ... */ - char *prompt; /* The string for the prompt */ - char *help; /* The display for the help line */ - void *var; /* The var to set when this changes */ - int type; /* The type of the dialog to create */ - void *obj; /* The obj pointer returned by libdialog */ -} Layout; - -typedef enum { - DEVICE_TYPE_NONE, - DEVICE_TYPE_DISK, - DEVICE_TYPE_FLOPPY, - DEVICE_TYPE_FTP, - DEVICE_TYPE_NETWORK, - DEVICE_TYPE_CDROM, - DEVICE_TYPE_TAPE, - DEVICE_TYPE_DOS, - DEVICE_TYPE_UFS, - DEVICE_TYPE_NFS, - DEVICE_TYPE_ANY, -} DeviceType; - -/* CDROM mount codes */ -#define CD_UNMOUNTED 0 -#define CD_ALREADY_MOUNTED 1 -#define CD_WE_MOUNTED_IT 2 - -/* A "device" from sysinstall's point of view */ -typedef struct _device { - char name[DEV_NAME_MAX]; - char *description; - char *devname; - DeviceType type; - Boolean enabled; - Boolean (*init)(struct _device *dev); - FILE * (*get)(struct _device *dev, char *file, Boolean probe); - void (*shutdown)(struct _device *dev); - void *private; - unsigned int flags; -} Device; - -/* Some internal representations of partitions */ -typedef enum { - PART_NONE, - PART_SLICE, - PART_SWAP, - PART_FILESYSTEM, - PART_FAT, -} PartType; - -/* The longest newfs command we'll hand to system() */ -#define NEWFS_CMD_MAX 256 - -typedef struct _part_info { - Boolean newfs; - char mountpoint[FILENAME_MAX]; - char newfs_cmd[NEWFS_CMD_MAX]; -} PartInfo; - -/* An option */ -typedef struct _opt { - char *name; - char *desc; - enum { OPT_IS_STRING, OPT_IS_INT, OPT_IS_FUNC, OPT_IS_VAR } type; - void *data; - void *aux; - char *(*check)(); -} Option; - -/* Weird index nodey things we use for keeping track of package information */ -typedef enum { PACKAGE, PLACE } node_type; /* Types of nodes */ - -typedef struct _pkgnode { /* A node in the reconstructed hierarchy */ - struct _pkgnode *next; /* My next sibling */ - node_type type; /* What am I? */ - char *name; /* My name */ - char *desc; /* My description (Hook) */ - struct _pkgnode *kids; /* My little children */ - void *data; /* A place to hang my data */ -} PkgNode; -typedef PkgNode *PkgNodePtr; - -/* A single package */ -typedef struct _indexEntry { /* A single entry in an INDEX file */ - char *name; /* name */ - char *path; /* full path to port */ - char *prefix; /* port prefix */ - char *comment; /* one line description */ - char *descrfile; /* path to description file */ - char *deps; /* packages this depends on */ - char *maintainer; /* maintainer */ -} IndexEntry; -typedef IndexEntry *IndexEntryPtr; - -typedef int (*commandFunc)(char *key, void *data); - -#define HOSTNAME_FIELD_LEN 128 -#define IPADDR_FIELD_LEN 16 -#define EXTRAS_FIELD_LEN 128 - -/* This is the structure that Network devices carry around in their private, erm, structures */ -typedef struct _devPriv { - char ipaddr[IPADDR_FIELD_LEN]; - char netmask[IPADDR_FIELD_LEN]; - char extras[EXTRAS_FIELD_LEN]; -} DevInfo; - - -/*** Externs ***/ -extern jmp_buf BailOut; /* Used to get the heck out */ -extern int DebugFD; /* Where diagnostic output goes */ -extern Boolean Fake; /* Don't actually modify anything - testing */ -extern Boolean SystemWasInstalled; /* Did we install it? */ -extern Boolean RunningAsInit; /* Are we running stand-alone? */ -extern Boolean DialogActive; /* Is the dialog() stuff up? */ -extern Boolean ColorDisplay; /* Are we on a color display? */ -extern Boolean OnVTY; /* On a syscons VTY? */ -extern Variable *VarHead; /* The head of the variable chain */ -extern Device *mediaDevice; /* Where we're getting our distribution from */ -extern unsigned int Dists; /* Which distributions we want */ -extern unsigned int DESDists; /* Which naughty distributions we want */ -extern unsigned int SrcDists; /* Which src distributions we want */ -extern unsigned int XF86Dists; /* Which XFree86 dists we want */ -extern unsigned int XF86ServerDists; /* The XFree86 servers we want */ -extern unsigned int XF86FontDists; /* The XFree86 fonts we want */ -extern int BootMgr; /* Which boot manager to use */ -extern int StatusLine; /* Where to print our status messages */ -extern DMenu MenuInitial; /* Initial installation menu */ -extern DMenu MenuFixit; /* Fixit repair menu */ -extern DMenu MenuMBRType; /* Type of MBR to write on the disk */ -extern DMenu MenuConfigure; /* Final configuration menu */ -extern DMenu MenuDocumentation; /* Documentation menu */ -extern DMenu MenuFTPOptions; /* FTP Installation options */ -extern DMenu MenuIndex; /* Index menu */ -extern DMenu MenuOptions; /* Installation options */ -extern DMenu MenuOptionsLanguage; /* Language options menu */ -extern DMenu MenuMedia; /* Media type menu */ -extern DMenu MenuMouse; /* Mouse type menu */ -extern DMenu MenuMediaCDROM; /* CDROM media menu */ -extern DMenu MenuMediaDOS; /* DOS media menu */ -extern DMenu MenuMediaFloppy; /* Floppy media menu */ -extern DMenu MenuMediaFTP; /* FTP media menu */ -extern DMenu MenuMediaTape; /* Tape media menu */ -extern DMenu MenuNetworkDevice; /* Network device menu */ -extern DMenu MenuNTP; /* NTP time server menu */ -extern DMenu MenuStartup; /* Startup services menu */ -extern DMenu MenuSyscons; /* System console configuration menu */ -extern DMenu MenuSysconsFont; /* System console font configuration menu */ -extern DMenu MenuSysconsKeymap; /* System console keymap configuration menu */ -extern DMenu MenuSysconsKeyrate; /* System console keyrate configuration menu */ -extern DMenu MenuSysconsSaver; /* System console saver configuration menu */ -extern DMenu MenuSysconsScrnmap; /* System console screenmap configuration menu */ -extern DMenu MenuNetworking; /* Network configuration menu */ -extern DMenu MenuInstallCustom; /* Custom Installation menu */ -extern DMenu MenuDistributions; /* Distribution menu */ -extern DMenu MenuSubDistributions; /* Custom distribution menu */ -extern DMenu MenuDESDistributions; /* DES distribution menu */ -extern DMenu MenuSrcDistributions; /* Source distribution menu */ -extern DMenu MenuXF86; /* XFree86 main menu */ -extern DMenu MenuXF86Select; /* XFree86 distribution selection menu */ -extern DMenu MenuXF86SelectCore; /* XFree86 core distribution menu */ -extern DMenu MenuXF86SelectServer; /* XFree86 server distribution menu */ -extern DMenu MenuXF86SelectPC98Server; /* XFree86 server distribution menu */ -extern DMenu MenuXF86SelectFonts; /* XFree86 font selection menu */ -extern DMenu MenuDiskDevices; /* Disk devices menu */ -extern DMenu MenuHTMLDoc; /* HTML Documentation menu */ -extern DMenu MenuUsermgmt; /* User management menu */ -extern DMenu MenuFixit; /* Fixit floppy/CDROM/shell menu */ -extern DMenu MenuXF86Config; /* Select XFree86 configuration type */ - -/* Stuff from libdialog which isn't properly declared outside */ -extern void display_helpfile(void); -extern void display_helpline(WINDOW *w, int y, int width); - -/*** Prototypes ***/ - -/* anonFTP.c */ -extern int configAnonFTP(dialogMenuItem *self); - -/* cdrom.c */ -extern Boolean mediaInitCDROM(Device *dev); -extern FILE *mediaGetCDROM(Device *dev, char *file, Boolean probe); -extern void mediaShutdownCDROM(Device *dev); - -/* command.c */ -extern void command_clear(void); -extern void command_sort(void); -extern void command_execute(void); -extern void command_shell_add(char *key, char *fmt, ...); -extern void command_func_add(char *key, commandFunc func, void *data); - -/* config.c */ -extern void configEnvironmentRC_conf(char *config); -extern void configEnvironmentResolv(char *config); -extern void configRC_conf(char *config); -extern int configFstab(dialogMenuItem *self); -extern int configRC(dialogMenuItem *self); -extern int configRegister(dialogMenuItem *self); -extern int configResolv(dialogMenuItem *self); -extern int configPackages(dialogMenuItem *self); -extern int configSaver(dialogMenuItem *self); -extern int configSaverTimeout(dialogMenuItem *self); -extern int configNTP(dialogMenuItem *self); -extern int configUsers(dialogMenuItem *self); -extern int configXEnvironment(dialogMenuItem *self); -extern int configRouter(dialogMenuItem *self); -extern int configPCNFSD(dialogMenuItem *self); -extern int configNFSServer(dialogMenuItem *self); -extern int configWriteRC_conf(dialogMenuItem *self); - -/* crc.c */ -extern int crc(int, unsigned long *, unsigned long *); - -/* devices.c */ -extern DMenu *deviceCreateMenu(DMenu *menu, DeviceType type, int (*hook)(dialogMenuItem *d), - int (*check)(dialogMenuItem *d)); -extern void deviceGetAll(void); -extern Device **deviceFind(char *name, DeviceType type); -extern Device **deviceFindDescr(char *name, char *desc, DeviceType class); -extern int deviceCount(Device **devs); -extern Device *new_device(char *name); -extern Device *deviceRegister(char *name, char *desc, char *devname, DeviceType type, Boolean enabled, - Boolean (*init)(Device *mediadev), - FILE * (*get)(Device *dev, char *file, Boolean probe), - void (*shutDown)(Device *mediadev), - void *private); -extern Boolean dummyInit(Device *dev); -extern FILE *dummyGet(Device *dev, char *dist, Boolean probe); -extern void dummyShutdown(Device *dev); - -/* disks.c */ -extern int diskPartitionEditor(dialogMenuItem *self); -extern int diskPartitionWrite(dialogMenuItem *self); -extern int diskGetSelectCount(Device ***devs); -extern void diskPartition(Device *dev); - -/* dispatch.c */ -extern int dispatchCommand(char *command); -extern int dispatch_load_floppy(dialogMenuItem *self); -extern int dispatch_load_file_int(int); -extern int dispatch_load_file(dialogMenuItem *self); - - -/* dist.c */ -extern int distReset(dialogMenuItem *self); -extern int distConfig(dialogMenuItem *self); -extern int distSetCustom(dialogMenuItem *self); -extern int distSetDeveloper(dialogMenuItem *self); -extern int distSetXDeveloper(dialogMenuItem *self); -extern int distSetKernDeveloper(dialogMenuItem *self); -extern int distSetUser(dialogMenuItem *self); -extern int distSetXUser(dialogMenuItem *self); -extern int distSetMinimum(dialogMenuItem *self); -extern int distSetEverything(dialogMenuItem *self); -extern int distSetDES(dialogMenuItem *self); -extern int distSetSrc(dialogMenuItem *self); -extern int distSetXF86(dialogMenuItem *self); -extern int distExtractAll(dialogMenuItem *self); - -/* dmenu.c */ -extern int dmenuDisplayFile(dialogMenuItem *tmp); -extern int dmenuSubmenu(dialogMenuItem *tmp); -extern int dmenuSystemCommand(dialogMenuItem *tmp); -extern int dmenuSystemCommandBox(dialogMenuItem *tmp); -extern int dmenuExit(dialogMenuItem *tmp); -extern int dmenuISetVariable(dialogMenuItem *tmp); -extern int dmenuSetVariable(dialogMenuItem *tmp); -extern int dmenuSetKmapVariable(dialogMenuItem *tmp); -extern int dmenuSetVariables(dialogMenuItem *tmp); -extern int dmenuToggleVariable(dialogMenuItem *tmp); -extern int dmenuSetFlag(dialogMenuItem *tmp); -extern int dmenuSetValue(dialogMenuItem *tmp); -extern Boolean dmenuOpen(DMenu *menu, int *choice, int *scroll, int *curr, int *max, Boolean buttons); -extern Boolean dmenuOpenSimple(DMenu *menu, Boolean buttons); -extern int dmenuVarCheck(dialogMenuItem *item); -extern int dmenuVarsCheck(dialogMenuItem *item); -extern int dmenuFlagCheck(dialogMenuItem *item); -extern int dmenuRadioCheck(dialogMenuItem *item); - -/* doc.c */ -extern int docBrowser(dialogMenuItem *self); -extern int docShowDocument(dialogMenuItem *self); - -/* dos.c */ -extern Boolean mediaCloseDOS(Device *dev, FILE *fp); -extern Boolean mediaInitDOS(Device *dev); -extern FILE *mediaGetDOS(Device *dev, char *file, Boolean probe); -extern void mediaShutdownDOS(Device *dev); - -/* floppy.c */ -extern int getRootFloppy(void); -extern Boolean mediaInitFloppy(Device *dev); -extern FILE *mediaGetFloppy(Device *dev, char *file, Boolean probe); -extern void mediaShutdownFloppy(Device *dev); - -/* ftp_strat.c */ -extern Boolean mediaCloseFTP(Device *dev, FILE *fp); -extern Boolean mediaInitFTP(Device *dev); -extern FILE *mediaGetFTP(Device *dev, char *file, Boolean probe); -extern void mediaShutdownFTP(Device *dev); - -/* globals.c */ -extern void globalsInit(void); - -/* index.c */ -int index_read(FILE *fp, PkgNodePtr papa); -int index_menu(PkgNodePtr top, PkgNodePtr plist, int *pos, int *scroll); -void index_init(PkgNodePtr top, PkgNodePtr plist); -void index_node_free(PkgNodePtr top, PkgNodePtr plist); -void index_sort(PkgNodePtr top); -void index_print(PkgNodePtr top, int level); -int index_extract(Device *dev, PkgNodePtr top, PkgNodePtr plist); - -/* install.c */ -extern Boolean checkLabels(Boolean whinge, Chunk **rdev, Chunk **sdev, Chunk **udev, Chunk **vdev); -extern int installCommit(dialogMenuItem *self); -extern int installCustomCommit(dialogMenuItem *self); -extern int installExpress(dialogMenuItem *self); -extern int installNovice(dialogMenuItem *self); -extern int installFixitHoloShell(dialogMenuItem *self); -extern int installFixitCDROM(dialogMenuItem *self); -extern int installFixitFloppy(dialogMenuItem *self); -extern int installFixupBin(dialogMenuItem *self); -extern int installFixupXFree(dialogMenuItem *self); -extern int installUpgrade(dialogMenuItem *self); -extern int installFilesystems(dialogMenuItem *self); -extern int installVarDefaults(dialogMenuItem *self); -extern void installEnvironment(void); -extern Boolean copySelf(void); - -/* kget.c */ -extern int kget(char *out); - -/* keymap.c */ -extern int loadKeymap(const char *lang); - -/* label.c */ -extern int diskLabelEditor(dialogMenuItem *self); -extern int diskLabelCommit(dialogMenuItem *self); - -/* lndir.c */ -extern int lndir(char *from, char *to); - -/* makedevs.c (auto-generated) */ -extern const char termcap_ansi[]; -extern const char termcap_vt100[]; -extern const char termcap_cons25[]; -extern const char termcap_cons25_m[]; -extern const char termcap_cons25r[]; -extern const char termcap_cons25r_m[]; -extern const char termcap_cons25l1[]; -extern const char termcap_cons25l1_m[]; -extern const u_char font_iso_8x16[]; -extern const u_char font_cp850_8x16[]; -extern const u_char font_cp866_8x16[]; -extern const u_char koi8_r2cp866[]; -extern u_char default_scrnmap[]; - -/* media.c */ -extern char *cpioVerbosity(void); -extern void mediaClose(void); -extern int mediaTimeout(void); -extern int mediaSetCDROM(dialogMenuItem *self); -extern int mediaSetFloppy(dialogMenuItem *self); -extern int mediaSetDOS(dialogMenuItem *self); -extern int mediaSetTape(dialogMenuItem *self); -extern int mediaSetFTP(dialogMenuItem *self); -extern int mediaSetFTPActive(dialogMenuItem *self); -extern int mediaSetFTPPassive(dialogMenuItem *self); -extern int mediaSetUFS(dialogMenuItem *self); -extern int mediaSetNFS(dialogMenuItem *self); -extern int mediaSetFTPUserPass(dialogMenuItem *self); -extern int mediaSetCPIOVerbosity(dialogMenuItem *self); -extern int mediaGetType(dialogMenuItem *self); -extern Boolean mediaExtractDist(char *dir, char *dist, FILE *fp); -extern Boolean mediaExtractDistBegin(char *dir, int *fd, int *zpid, int *cpic); -extern Boolean mediaExtractDistEnd(int zpid, int cpid); -extern Boolean mediaVerify(void); -extern FILE *mediaGenericGet(char *base, const char *file); - -/* misc.c */ -extern Boolean file_readable(char *fname); -extern Boolean file_executable(char *fname); -extern Boolean directory_exists(const char *dirname); -extern char *root_bias(char *path); -extern char *itoa(int value); -extern char *string_concat(char *p1, char *p2); -extern char *string_concat3(char *p1, char *p2, char *p3); -extern char *string_prune(char *str); -extern char *string_skipwhite(char *str); -extern char *string_copy(char *s1, char *s2); -extern char *pathBaseName(const char *path); -extern void safe_free(void *ptr); -extern void *safe_malloc(size_t size); -extern void *safe_realloc(void *orig, size_t size); -extern dialogMenuItem *item_add(dialogMenuItem *list, char *prompt, char *title, - int (*checked)(dialogMenuItem *self), - int (*fire)(dialogMenuItem *self), - void (*selected)(dialogMenuItem *self, int is_selected), - void *data, int aux, int *curr, int *max); -extern void items_free(dialogMenuItem *list, int *curr, int *max); -extern int Mkdir(char *); -extern int Mount(char *, void *data); -extern WINDOW *openLayoutDialog(char *helpfile, char *title, int x, int y, int width, int height); -extern ComposeObj *initLayoutDialog(WINDOW *win, Layout *layout, int x, int y, int *max); -extern int layoutDialogLoop(WINDOW *win, Layout *layout, ComposeObj **obj, - int *n, int max, int *cbutton, int *cancel); - -extern WINDOW *savescr(void); -extern void restorescr(WINDOW *w); -extern char *sstrncpy(char *dst, const char *src, int size); - -/* mouse.c */ -extern int mousedTest(dialogMenuItem *self); -extern int mousedDisable(dialogMenuItem *self); - -/* msg.c */ -extern Boolean isDebug(void); -extern void msgInfo(char *fmt, ...); -extern void msgYap(char *fmt, ...); -extern void msgWarn(char *fmt, ...); -extern void msgDebug(char *fmt, ...); -extern void msgError(char *fmt, ...); -extern void msgFatal(char *fmt, ...); -extern void msgConfirm(char *fmt, ...); -extern void msgNotify(char *fmt, ...); -extern void msgWeHaveOutput(char *fmt, ...); -extern int msgYesNo(char *fmt, ...); -extern char *msgGetInput(char *buf, char *fmt, ...); -extern int msgSimpleConfirm(char *); -extern int msgSimpleNotify(char *); - -/* network.c */ -extern Boolean mediaInitNetwork(Device *dev); -extern void mediaShutdownNetwork(Device *dev); - -/* nfs.c */ -extern Boolean mediaInitNFS(Device *dev); -extern FILE *mediaGetNFS(Device *dev, char *file, Boolean probe); -extern void mediaShutdownNFS(Device *dev); - -/* options.c */ -extern int optionsEditor(dialogMenuItem *self); - -/* package.c */ -extern int packageAdd(dialogMenuItem *self); -extern int package_add(char *name); -extern int package_extract(Device *dev, char *name, Boolean depended); -extern Boolean package_exists(char *name); - -/* register.c */ -extern int registerOpenDialog(void); - -/* system.c */ -extern void systemInitialize(int argc, char **argv); -extern void systemShutdown(int status); -extern int execExecute(char *cmd, char *name); -extern int systemExecute(char *cmd); -extern int systemDisplayHelp(char *file); -extern char *systemHelpFile(char *file, char *buf); -extern void systemChangeFont(const u_char font[]); -extern void systemChangeLang(char *lang); -extern void systemChangeTerminal(char *color, const u_char c_termcap[], char *mono, const u_char m_termcap[]); -extern void systemChangeScreenmap(const u_char newmap[]); -extern void systemCreateHoloshell(void); -extern int vsystem(char *fmt, ...); - -/* tape.c */ -extern char *mediaTapeBlocksize(void); -extern Boolean mediaInitTape(Device *dev); -extern FILE *mediaGetTape(Device *dev, char *file, Boolean probe); -extern void mediaShutdownTape(Device *dev); - -/* tcpip.c */ -extern int tcpOpenDialog(Device *dev); -extern int tcpMenuSelect(dialogMenuItem *self); -extern Device *tcpDeviceSelect(void); - -/* termcap.c */ -extern int set_termcap(void); - -/* ufs.c */ -extern void mediaShutdownUFS(Device *dev); -extern Boolean mediaInitUFS(Device *dev); -extern FILE *mediaGetUFS(Device *dev, char *file, Boolean probe); - -/* user.c */ -extern int userAddGroup(dialogMenuItem *self); -extern int userAddUser(dialogMenuItem *self); - -/* variable.c */ -extern void variable_set(char *var); -extern void variable_set2(char *name, char *value); -extern char *variable_get(char *var); -extern int variable_cmp(char *var, char *value); -extern void variable_unset(char *var); -extern char *variable_get_value(char *var, char *prompt); -extern int variable_check(char *data); -extern int dump_variables(dialogMenuItem *self); - -/* wizard.c */ -extern void slice_wizard(Disk *d); - -#endif -/* _SYSINSTALL_H_INCLUDE */ diff --git a/usr.sbin/sysinstall/system.c b/usr.sbin/sysinstall/system.c deleted file mode 100644 index 97b7d57008a4..000000000000 --- a/usr.sbin/sysinstall/system.c +++ /dev/null @@ -1,396 +0,0 @@ -/* - * The new sysinstall program. - * - * This is probably the last program in the `sysinstall' line - the next - * generation being essentially a complete rewrite. - * - * $Id: system.c,v 1.86 1999/01/08 00:14:22 jkh Exp $ - * - * Jordan Hubbard - * - * My contributions are in the public domain. - * - * Parts of this file are also blatently stolen from Poul-Henning Kamp's - * previous version of sysinstall, and as such fall under his "BEERWARE license" - * so buy him a beer if you like it! Buy him a beer for me, too! - * Heck, get him completely drunk and send me pictures! :-) - */ - -#include "sysinstall.h" -#include <signal.h> -#include <sys/reboot.h> -#include <machine/console.h> -#include <sys/fcntl.h> -#include <sys/ioctl.h> -#include <sys/stat.h> - - -/* Where we stick our temporary expanded doc file */ -#define DOC_TMP_DIR "/tmp/.doc" -#define DOC_TMP_FILE "/tmp/.doc/doc.tmp" - -static pid_t ehs_pid; - -/* - * Handle interrupt signals - this probably won't work in all cases - * due to our having bogotified the internal state of dialog or curses, - * but we'll give it a try. - */ -static void -handle_intr(int sig) -{ - WINDOW *save = savescr(); - - if (!msgYesNo("Are you sure you want to abort the installation?")) - systemShutdown(-1); - else - restorescr(save); -} - -/* Expand a file into a convenient location, nuking it each time */ -static char * -expand(char *fname) -{ - char *gunzip = RunningAsInit ? "/stand/gunzip" : "/usr/bin/gunzip"; - - if (!directory_exists(DOC_TMP_DIR)) { - Mkdir(DOC_TMP_DIR); - if (chown(DOC_TMP_DIR, 0, 0) < 0) - return NULL; - if (chmod(DOC_TMP_DIR, S_IRWXU) < 0) - return NULL; - } - else - unlink(DOC_TMP_FILE); - if (!file_readable(fname) || vsystem("%s < %s > %s", gunzip, fname, DOC_TMP_FILE)) - return NULL; - return DOC_TMP_FILE; -} - -/* Initialize system defaults */ -void -systemInitialize(int argc, char **argv) -{ - int i; - - signal(SIGINT, SIG_IGN); - globalsInit(); - - /* Are we running as init? */ - if (getpid() == 1) { - int fd, type; - - RunningAsInit = 1; - setsid(); - close(0); - fd = open("/dev/ttyv0", O_RDWR); - if (fd == -1) - fd = open("/dev/console", O_RDWR); /* fallback */ - else - OnVTY = TRUE; - /* - * To make _sure_ we're on a VTY and don't have /dev/console switched - * away to a serial port or something, attempt to set the cursor appearance. - */ - type = 0; /* normal */ - if (OnVTY) { - int fd2; - - if ((fd2 = open("/dev/console", O_RDWR)) != -1) { - if (ioctl(fd2, CONS_CURSORTYPE, &type) == -1) { - OnVTY = FALSE; - close(fd); close(fd2); - open("/dev/console", O_RDWR); - } - else - close(fd2); - } - } - close(1); dup(0); - close(2); dup(0); - printf("%s running as init on %s\n", argv[0], OnVTY ? "vty0" : "serial console"); - i = ioctl(0, TIOCSCTTY, (char *)NULL); - setlogin("root"); - setenv("PATH", "/stand:/bin:/sbin:/usr/sbin:/usr/bin:/mnt/bin:/mnt/sbin:/mnt/usr/sbin:/mnt/usr/bin:/usr/X11R6/bin", 1); - setbuf(stdin, 0); - setbuf(stderr, 0); - } - else { - char hname[256]; - - /* Initalize various things for a multi-user environment */ - if (!gethostname(hname, sizeof hname)) - variable_set2(VAR_HOSTNAME, hname); - } - - if (set_termcap() == -1) { - printf("Can't find terminal entry\n"); - exit(-1); - } - - /* XXX - libdialog has particularly bad return value checking */ - init_dialog(); - - /* If we haven't crashed I guess dialog is running ! */ - DialogActive = TRUE; - - /* Make sure HOME is set for those utilities that need it */ - if (!getenv("HOME")) - setenv("HOME", "/", 1); - signal(SIGINT, handle_intr); - (void)vsystem("rm -rf %s", DOC_TMP_DIR); -} - -/* Close down and prepare to exit */ -void -systemShutdown(int status) -{ - /* If some media is open, close it down */ - if (status >=0 && mediaDevice) - mediaDevice->shutdown(mediaDevice); - - /* write out any changes to rc.conf .. */ - configRC_conf("/etc/rc.conf"); - - /* Shut down the dialog library */ - if (DialogActive) { - end_dialog(); - DialogActive = FALSE; - } - - /* Shut down curses */ - endwin(); - - /* If we have a temporary doc dir lying around, nuke it */ - (void)vsystem("rm -rf %s", DOC_TMP_DIR); - - /* REALLY exit! */ - if (RunningAsInit) { - /* Put the console back */ - ioctl(0, VT_ACTIVATE, 2); -#ifdef __alpha__ - reboot(RB_HALT); -#else - reboot(0); -#endif - } - else - exit(status); -} - -/* Run some general command */ -int -systemExecute(char *command) -{ - int status; - struct termios foo; - - dialog_update(); - end_dialog(); - DialogActive = FALSE; - if (tcgetattr(0, &foo) != -1) { - foo.c_cc[VERASE] = '\010'; - tcsetattr(0, TCSANOW, &foo); - } - if (!Fake) - status = system(command); - else { - status = 0; - msgDebug("systemExecute: Faked execution of `%s'\n", command); - } - DialogActive = TRUE; - return status; -} - -/* Display a help file in a filebox */ -int -systemDisplayHelp(char *file) -{ - char *fname = NULL; - char buf[FILENAME_MAX]; - int ret = 0; - - fname = systemHelpFile(file, buf); - if (!fname) { - snprintf(buf, FILENAME_MAX, "The %s file is not provided on this particular floppy image.", file); - use_helpfile(NULL); - use_helpline(NULL); - dialog_mesgbox("Sorry!", buf, -1, -1); - ret = 1; - } - else { - use_helpfile(NULL); - use_helpline(NULL); - dialog_textbox(file, fname, LINES, COLS); - } - return ret; -} - -char * -systemHelpFile(char *file, char *buf) -{ - if (!file) - return NULL; - - snprintf(buf, FILENAME_MAX, "/stand/help/%s.hlp.gz", file); - if (file_readable(buf)) - return expand(buf); - snprintf(buf, FILENAME_MAX, "/stand/help/%s.TXT.gz", file); - if (file_readable(buf)) - return expand(buf); - snprintf(buf, FILENAME_MAX, "/usr/src/release/sysinstall/help/%s.hlp", file); - if (file_readable(buf)) - return buf; - snprintf(buf, FILENAME_MAX, "/usr/src/release/sysinstall/help/%s.TXT", file); - if (file_readable(buf)) - return buf; - return NULL; -} - -void -systemChangeTerminal(char *color, const u_char c_term[], - char *mono, const u_char m_term[]) -{ - extern void init_acs(void); - - if (OnVTY) { - if (ColorDisplay) { - setenv("TERM", color, 1); - setenv("TERMCAP", c_term, 1); - reset_shell_mode(); - setterm(color); - init_acs(); - cbreak(); noecho(); - } - else { - setenv("TERM", mono, 1); - setenv("TERMCAP", m_term, 1); - reset_shell_mode(); - setterm(mono); - init_acs(); - cbreak(); noecho(); - } - } - clear(); - refresh(); - dialog_clear(); -} - -int -vsystem(char *fmt, ...) -{ - va_list args; - int pstat; - pid_t pid; - int omask; - sig_t intsave, quitsave; - char *cmd; - int i; - - cmd = (char *)alloca(FILENAME_MAX); - cmd[0] = '\0'; - va_start(args, fmt); - vsnprintf(cmd, FILENAME_MAX, fmt, args); - va_end(args); - - omask = sigblock(sigmask(SIGCHLD)); - if (Fake) { - msgDebug("vsystem: Faked execution of `%s'\n", cmd); - return 0; - } - if (isDebug()) - msgDebug("Executing command `%s'\n", cmd); - pid = fork(); - if (pid == -1) { - (void)sigsetmask(omask); - i = 127; - } - else if (!pid) { /* Junior */ - (void)sigsetmask(omask); - if (DebugFD != -1) { - dup2(DebugFD, 0); - dup2(DebugFD, 1); - dup2(DebugFD, 2); - } - else { - close(1); open("/dev/null", O_WRONLY); - dup2(1, 2); - } - if (!RunningAsInit) - execl("/bin/sh", "/bin/sh", "-c", cmd, (char *)NULL); - else - execl("/stand/sh", "/stand/sh", "-c", cmd, (char *)NULL); - exit(1); - } - else { - intsave = signal(SIGINT, SIG_IGN); - quitsave = signal(SIGQUIT, SIG_IGN); - pid = waitpid(pid, &pstat, 0); - (void)sigsetmask(omask); - (void)signal(SIGINT, intsave); - (void)signal(SIGQUIT, quitsave); - i = (pid == -1) ? -1 : WEXITSTATUS(pstat); - if (isDebug()) - msgDebug("Command `%s' returns status of %d\n", cmd, i); - } - return i; -} - -void -systemCreateHoloshell(void) -{ - if (OnVTY && RunningAsInit) { - - if (ehs_pid != 0) { - int pstat; - - if (kill(ehs_pid, 0) == 0) { - - if (msgYesNo("There seems to be an emergency holographic shell\n" - "already running von VTY 4.\n" - "Kill it and start a new one?")) - return; - - /* try cleaning up as much as possible */ - (void) kill(ehs_pid, SIGHUP); - sleep(1); - (void) kill(ehs_pid, SIGKILL); - } - - /* avoid too many zombies */ - (void) waitpid(ehs_pid, &pstat, WNOHANG); - } - - if ((ehs_pid = fork()) == 0) { - int i, fd; - struct termios foo; - extern int login_tty(int); - - ioctl(0, TIOCNOTTY, NULL); - for (i = getdtablesize(); i >= 0; --i) - close(i); - fd = open("/dev/ttyv3", O_RDWR); - ioctl(0, TIOCSCTTY, &fd); - dup2(0, 1); - dup2(0, 2); - DebugFD = 2; - if (login_tty(fd) == -1) - msgDebug("Doctor: I can't set the controlling terminal.\n"); - signal(SIGTTOU, SIG_IGN); - if (tcgetattr(fd, &foo) != -1) { - foo.c_cc[VERASE] = '\010'; - if (tcsetattr(fd, TCSANOW, &foo) == -1) - msgDebug("Doctor: I'm unable to set the erase character.\n"); - } - else - msgDebug("Doctor: I'm unable to get the terminal attributes!\n"); - execlp("sh", "-sh", 0); - msgDebug("Was unable to execute sh for Holographic shell!\n"); - exit(1); - } - else { - msgNotify("Starting an emergency holographic shell on VTY4"); - sleep(2); - } - } -} diff --git a/usr.sbin/sysinstall/tape.c b/usr.sbin/sysinstall/tape.c deleted file mode 100644 index 995a0fe0d154..000000000000 --- a/usr.sbin/sysinstall/tape.c +++ /dev/null @@ -1,121 +0,0 @@ -/* - * The new sysinstall program. - * - * This is probably the last attempt in the `sysinstall' line, the next - * generation being slated to essentially a complete rewrite. - * - * $Id: tape.c,v 1.19 1997/02/22 14:12:21 peter Exp $ - * - * Copyright (c) 1995 - * Jordan Hubbard. 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, - * verbatim and that no modifications are made prior to this - * point in the file. - * 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 JORDAN HUBBARD ``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 JORDAN HUBBARD OR HIS PETS 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, LIFE 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. - * - */ - -/* These routines deal with getting things off of tape media */ - -#include "sysinstall.h" -#include <sys/fcntl.h> -#include <sys/param.h> - -static Boolean tapeInitted; - -char * -mediaTapeBlocksize(void) -{ - char *cp = variable_get(VAR_TAPE_BLOCKSIZE); - - return cp ? cp : DEFAULT_TAPE_BLOCKSIZE; -} - -Boolean -mediaInitTape(Device *dev) -{ - /* This is REALLY gross, but we need to do the init later in get due to the fact - * that media is initialized BEFORE a filesystem is mounted now. - */ - return TRUE; -} - -FILE * -mediaGetTape(Device *dev, char *file, Boolean probe) -{ - char buf[PATH_MAX]; - FILE *fp; - - int i; - - if (!tapeInitted) { - msgDebug("Tape init routine called for %s (private dir is %s)\n", dev->name, dev->private); - Mkdir(dev->private); - if (chdir(dev->private)) { - msgConfirm("Unable to CD to %s before extracting tape!\n" - "Tape media is not selected and thus cannot be installed from.", dev->private); - return (FILE *)IO_ERROR; - } - /* We know the tape is already in the drive, so go for it */ - msgNotify("First extracting distributions from %s...", dev->description); - if (!strcmp(dev->name, "rft0")) - i = vsystem("ft | cpio -idum %s --block-size %s", cpioVerbosity(), mediaTapeBlocksize()); - else - i = vsystem("cpio -idum %s --block-size %s -I %s", cpioVerbosity(), mediaTapeBlocksize(), dev->devname); - if (!i) { - tapeInitted = TRUE; - msgDebug("Tape initialized successfully.\n"); - } - else { - msgConfirm("Tape extract command failed with status %d!\n" - "Unable to use tape media.", i); - return (FILE *)IO_ERROR; - } - } - - sprintf(buf, "%s/%s", (char *)dev->private, file); - if (isDebug()) - msgDebug("Request for %s from tape (looking in %s)\n", file, buf); - if (file_readable(buf)) - fp = fopen(buf, "r"); - else { - sprintf(buf, "%s/releases/%s", (char *)dev->private, file); - fp = fopen(buf, "r"); - } - /* Nuke the files behind us to save space */ - if (fp) - unlink(buf); - return fp; -} - -void -mediaShutdownTape(Device *dev) -{ - if (!tapeInitted) - return; - if (file_readable((char *)dev->private)) { - msgNotify("Cleaning up results of tape extract in %s..", - (char *)dev->private); - (void)vsystem("rm -rf %s", (char *)dev->private); - } - tapeInitted = FALSE; -} diff --git a/usr.sbin/sysinstall/tcpip.c b/usr.sbin/sysinstall/tcpip.c deleted file mode 100644 index 7ef6358d2eb4..000000000000 --- a/usr.sbin/sysinstall/tcpip.c +++ /dev/null @@ -1,397 +0,0 @@ -/* - * $Id: tcpip.c,v 1.73 1998/08/31 09:02:03 jkh Exp $ - * - * Copyright (c) 1995 - * Gary J Palmer. All rights reserved. - * Copyright (c) 1996 - * Jordan K. Hubbard. 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, - * verbatim and that no modifications are made prior to this - * point in the file. - * 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 AUTHORS ``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 AUTHORS 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, LIFE 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. - * - */ - -/* - * All kinds of hacking also performed by jkh on this code. Don't - * blame Gary for every bogosity you see here.. :-) - * - * -jkh - */ - -#include "sysinstall.h" -#include <sys/param.h> - -/* The help file for the TCP/IP setup screen */ -#define TCP_HELPFILE "tcp" - -/* These are nasty, but they make the layout structure a lot easier ... */ - -static char hostname[HOSTNAME_FIELD_LEN], domainname[HOSTNAME_FIELD_LEN], - gateway[IPADDR_FIELD_LEN], nameserver[IPADDR_FIELD_LEN]; -static int okbutton, cancelbutton; -static char ipaddr[IPADDR_FIELD_LEN], netmask[IPADDR_FIELD_LEN], extras[EXTRAS_FIELD_LEN]; - -/* What the screen size is meant to be */ -#define TCP_DIALOG_Y 0 -#define TCP_DIALOG_X 8 -#define TCP_DIALOG_WIDTH COLS - 16 -#define TCP_DIALOG_HEIGHT LINES - 2 - -static Layout layout[] = { -#define LAYOUT_HOSTNAME 0 - { 1, 2, 25, HOSTNAME_FIELD_LEN - 1, - "Host:", "Your fully-qualified hostname, e.g. foo.bar.com", - hostname, STRINGOBJ, NULL }, -#define LAYOUT_DOMAINNAME 1 - { 1, 35, 20, HOSTNAME_FIELD_LEN - 1, - "Domain:", - "The name of the domain that your machine is in, e.g. bar.com", - domainname, STRINGOBJ, NULL }, -#define LAYOUT_GATEWAY 2 - { 5, 2, 18, IPADDR_FIELD_LEN - 1, - "Gateway:", - "IP address of host forwarding packets to non-local destinations", - gateway, STRINGOBJ, NULL }, -#define LAYOUT_NAMESERVER 3 - { 5, 35, 18, IPADDR_FIELD_LEN - 1, - "Name server:", "IP address of your local DNS server", - nameserver, STRINGOBJ, NULL }, -#define LAYOUT_IPADDR 4 - { 10, 10, 18, IPADDR_FIELD_LEN - 1, - "IP Address:", - "The IP address to be used for this interface", - ipaddr, STRINGOBJ, NULL }, -#define LAYOUT_NETMASK 5 - { 10, 35, 18, IPADDR_FIELD_LEN - 1, - "Netmask:", - "The netmask for this interface, e.g. 0xffffff00 for a class C network", - netmask, STRINGOBJ, NULL }, -#define LAYOUT_EXTRAS 6 - { 14, 10, 37, HOSTNAME_FIELD_LEN - 1, - "Extra options to ifconfig:", - "Any interface-specific options to ifconfig you would like to add", - extras, STRINGOBJ, NULL }, -#define LAYOUT_OKBUTTON 7 - { 19, 15, 0, 0, - "OK", "Select this if you are happy with these settings", - &okbutton, BUTTONOBJ, NULL }, -#define LAYOUT_CANCELBUTTON 8 - { 19, 35, 0, 0, - "CANCEL", "Select this if you wish to cancel this screen", - &cancelbutton, BUTTONOBJ, NULL }, - { NULL }, -}; - -#define _validByte(b) ((b) >= 0 && (b) <= 255) - -/* whine */ -static void -feepout(char *msg) -{ - beep(); - msgConfirm(msg); -} - -/* Very basic IP address integrity check - could be drastically improved */ -static int -verifyIP(char *ip) -{ - int a, b, c, d; - - if (ip && sscanf(ip, "%d.%d.%d.%d", &a, &b, &c, &d) == 4 && - _validByte(a) && _validByte(b) && _validByte(c) && - _validByte(d) && (d != 255)) - return 1; - else - return 0; -} - -/* Check for the settings on the screen - the per-interface stuff is - moved to the main handling code now to do it on the fly - sigh */ -static int -verifySettings(void) -{ - if (!hostname[0]) - feepout("Must specify a host name of some sort!"); - else if (gateway[0] && strcmp(gateway, "NO") && !verifyIP(gateway)) - feepout("Invalid gateway IP address specified"); - else if (nameserver[0] && !verifyIP(nameserver)) - feepout("Invalid name server IP address specified"); - else if (netmask[0] && (netmask[0] < '0' && netmask[0] > '3')) - feepout("Invalid netmask value"); - else if (ipaddr[0] && !verifyIP(ipaddr)) - feepout("Invalid IP address"); - else - return 1; - return 0; -} - -/* This is it - how to get TCP setup values */ -int -tcpOpenDialog(Device *devp) -{ - WINDOW *ds_win, *save = NULL; - ComposeObj *obj = NULL; - int n = 0, cancel = FALSE; - int max, ret = DITEM_SUCCESS; - char *tmp; - char title[80]; - - /* Initialise vars from previous device values */ - if (devp->private) { - DevInfo *di = (DevInfo *)devp->private; - - SAFE_STRCPY(ipaddr, di->ipaddr); - SAFE_STRCPY(netmask, di->netmask); - SAFE_STRCPY(extras, di->extras); - } - else { /* See if there are any defaults */ - char *cp; - - if (!ipaddr[0]) { - if ((cp = variable_get(VAR_IPADDR)) != NULL) - SAFE_STRCPY(ipaddr, cp); - else if ((cp = variable_get(string_concat3(devp->name, "_", VAR_IPADDR))) != NULL) - SAFE_STRCPY(ipaddr, cp); - } - if (!netmask[0]) { - if ((cp = variable_get(VAR_NETMASK)) != NULL) - SAFE_STRCPY(netmask, cp); - else if ((cp = variable_get(string_concat3(devp->name, "_", VAR_NETMASK))) != NULL) - SAFE_STRCPY(netmask, cp); - } - if (!extras[0]) { - if ((cp = variable_get(VAR_EXTRAS)) != NULL) - SAFE_STRCPY(extras, cp); - else if ((cp = variable_get(string_concat3(devp->name, "_", VAR_EXTRAS))) != NULL) - SAFE_STRCPY(extras, cp); - } - } - - /* Look up values already recorded with the system, or blank the string variables ready to accept some new data */ - tmp = variable_get(VAR_HOSTNAME); - if (tmp) - SAFE_STRCPY(hostname, tmp); - else - bzero(hostname, sizeof(hostname)); - tmp = variable_get(VAR_DOMAINNAME); - if (tmp) - SAFE_STRCPY(domainname, tmp); - else - bzero(domainname, sizeof(domainname)); - tmp = variable_get(VAR_GATEWAY); - if (tmp) - SAFE_STRCPY(gateway, tmp); - else - bzero(gateway, sizeof(gateway)); - tmp = variable_get(VAR_NAMESERVER); - if (tmp) - SAFE_STRCPY(nameserver, tmp); - else - bzero(nameserver, sizeof(nameserver)); - - save = savescr(); - /* If non-interactive, jump straight over the dialog crap and into config section */ - if (variable_get(VAR_NONINTERACTIVE) && - !variable_get(VAR_NETINTERACTIVE)) { - if (!hostname[0]) - msgConfirm("WARNING: hostname variable not set and is a non-optional\n" - "parameter. Please add this to your installation script\n" - "or set the netInteractive variable (see sysinstall man page)"); - else - goto netconfig; - } - - /* Now do all the screen I/O */ - dialog_clear_norefresh(); - - /* We need a curses window */ - if (!(ds_win = openLayoutDialog(TCP_HELPFILE, " Network Configuration ", - TCP_DIALOG_X, TCP_DIALOG_Y, TCP_DIALOG_WIDTH, TCP_DIALOG_HEIGHT))) { - beep(); - msgConfirm("Cannot open TCP/IP dialog window!!"); - restorescr(save); - return DITEM_FAILURE; - } - - /* Draw interface configuration box */ - draw_box(ds_win, TCP_DIALOG_Y + 9, TCP_DIALOG_X + 8, TCP_DIALOG_HEIGHT - 13, TCP_DIALOG_WIDTH - 17, - dialog_attr, border_attr); - wattrset(ds_win, dialog_attr); - sprintf(title, " Configuration for Interface %s ", devp->name); - mvwaddstr(ds_win, TCP_DIALOG_Y + 9, TCP_DIALOG_X + 14, title); - - /* Some more initialisation before we go into the main input loop */ - obj = initLayoutDialog(ds_win, layout, TCP_DIALOG_X, TCP_DIALOG_Y, &max); - -reenter: - cancelbutton = okbutton = 0; - while (layoutDialogLoop(ds_win, layout, &obj, &n, max, &cancelbutton, &cancel)) { - /* Insert a default value for the netmask, 0xffffff00 is - the most appropriate one (entire class C, or subnetted - class A/B network). */ - if (netmask[0] == '\0') { - strcpy(netmask, "255.255.255.0"); - RefreshStringObj(layout[LAYOUT_NETMASK].obj); - } - if (!index(hostname, '.') && domainname[0]) { - strcat(hostname, "."); - strcat(hostname, domainname); - RefreshStringObj(layout[LAYOUT_HOSTNAME].obj); - } - else if (((tmp = index(hostname, '.')) != NULL) && !domainname[0]) { - SAFE_STRCPY(domainname, tmp + 1); - RefreshStringObj(layout[LAYOUT_DOMAINNAME].obj); - } - } - - if (!cancel && !verifySettings()) - goto reenter; - - /* Clear this crap off the screen */ - delwin(ds_win); - dialog_clear_norefresh(); - use_helpfile(NULL); - - /* We actually need to inform the rest of sysinstall about this - data now if the user hasn't selected cancel. Save the stuff - out to the environment via the variable_set() mechanism */ - -netconfig: - if (!cancel) { - DevInfo *di; - char temp[512], ifn[255]; - char *ifaces; - - variable_set2(VAR_HOSTNAME, hostname); - sethostname(hostname, strlen(hostname)); - if (domainname[0]) - variable_set2(VAR_DOMAINNAME, domainname); - if (gateway[0]) - variable_set2(VAR_GATEWAY, gateway); - if (nameserver[0]) - variable_set2(VAR_NAMESERVER, nameserver); - - if (!devp->private) - devp->private = (DevInfo *)safe_malloc(sizeof(DevInfo)); - di = devp->private; - SAFE_STRCPY(di->ipaddr, ipaddr); - SAFE_STRCPY(di->netmask, netmask); - SAFE_STRCPY(di->extras, extras); - - sprintf(temp, "inet %s %s netmask %s", ipaddr, extras, netmask); - sprintf(ifn, "%s%s", VAR_IFCONFIG, devp->name); - variable_set2(ifn, temp); - ifaces = variable_get(VAR_INTERFACES); - if (!ifaces) - variable_set2(VAR_INTERFACES, ifaces = "lo0"); - /* Only add it if it's not there already */ - if (!strstr(ifaces, devp->name)) { - sprintf(ifn, "%s %s", devp->name, ifaces); - variable_set2(VAR_INTERFACES, ifn); - } - if (ipaddr[0]) - variable_set2(VAR_IPADDR, ipaddr); - configResolv(NULL); /* XXX this will do it on the MFS copy XXX */ - ret = DITEM_SUCCESS; - } - else - ret = DITEM_FAILURE; - restorescr(save); - return ret; -} - -static Device *NetDev; - -static int -netHook(dialogMenuItem *self) -{ - Device **devs; - - devs = deviceFindDescr(self->prompt, self->title, DEVICE_TYPE_NETWORK); - if (devs) { - if (DITEM_STATUS(tcpOpenDialog(devs[0])) != DITEM_FAILURE) - NetDev = devs[0]; - else - NetDev = NULL; - } - return devs ? DITEM_LEAVE_MENU : DITEM_FAILURE; -} - -/* Get a network device */ -Device * -tcpDeviceSelect(void) -{ - DMenu *menu; - Device **devs, *rval; - int cnt; - - devs = deviceFind(NULL, DEVICE_TYPE_NETWORK); - cnt = deviceCount(devs); - rval = NULL; - - if (!cnt) { - msgConfirm("No network devices available!"); - return NULL; - } - else if (!RunningAsInit) { - if (!msgYesNo("Running multi-user, assume that the network is already configured?")) - return devs[0]; - } - if (cnt == 1) { - if (DITEM_STATUS(tcpOpenDialog(devs[0]) == DITEM_SUCCESS)) - rval = devs[0]; - } - else if (variable_get(VAR_NONINTERACTIVE) && variable_get(VAR_NETWORK_DEVICE)) { - devs = deviceFind(variable_get(VAR_NETWORK_DEVICE), DEVICE_TYPE_NETWORK); - cnt = deviceCount(devs); - if (cnt) { - if (DITEM_STATUS(tcpOpenDialog(devs[0]) == DITEM_SUCCESS)) - rval = devs[0]; - } - } - else { - int status; - - menu = deviceCreateMenu(&MenuNetworkDevice, DEVICE_TYPE_NETWORK, netHook, NULL); - if (!menu) - msgFatal("Unable to create network device menu! Argh!"); - status = dmenuOpenSimple(menu, FALSE); - free(menu); - if (status) - rval = NetDev; - } - return rval; -} - -/* Do it from a menu that doesn't care about status */ -int -tcpMenuSelect(dialogMenuItem *self) -{ - Device *tmp; - - tmp = tcpDeviceSelect(); - if (tmp && !msgYesNo("Would you like to bring the %s interface up right now?", tmp->name)) - if (!tmp->init(tmp)) - msgConfirm("Initialization of %s device failed.", tmp->name); - return DITEM_SUCCESS | DITEM_RESTORE; -} diff --git a/usr.sbin/sysinstall/termcap.c b/usr.sbin/sysinstall/termcap.c deleted file mode 100644 index 15694790c91d..000000000000 --- a/usr.sbin/sysinstall/termcap.c +++ /dev/null @@ -1,135 +0,0 @@ -/* - * Copyright (c) 1994, Paul Richards. - * - * All rights reserved. - * - * This software may be used, modified, copied, distributed, and sold, in both - * source and binary form provided that the above copyright and these terms - * are retained, verbatim, as the first lines of this file. Under no - * circumstances is the author responsible for the proper functioning of this - * software, nor does the author assume any responsibility for damages - * incurred with its use. - */ - -#include "sysinstall.h" -#include <stdarg.h> -#include <fcntl.h> -#include <sys/errno.h> -#include <sys/ioctl.h> -#include <machine/console.h> - -#define VTY_STATUS_LINE 24 -#define TTY_STATUS_LINE 23 - -static void -prompt_term(char **termp, char **termcapp) -{ - char str[80]; - static struct { - const char *term, *termcap; - } lookup[] = { { "ansi", termcap_ansi }, - { "vt100", termcap_vt100 }, - { "cons25", termcap_cons25 }, - { "cons25-m", termcap_cons25_m } }; - - if (RunningAsInit) { - while (1) { - int i; - - printf("\nThese are the predefined terminal types available to\n"); - printf("sysinstall when running stand-alone. Please choose the\n"); - printf("closest match for your particular terminal.\n\n"); - printf("1 ...................... Standard ANSI terminal.\n"); - printf("2 ...................... VT100 or compatible terminal.\n"); - printf("3 ...................... FreeBSD system console (color).\n"); - printf("4 ...................... FreeBSD system console (monochrome).\n\n"); - printf("Your choice: (1-4) "); - fflush(stdout); - fgets(str, 80, stdin); - i = str[0] - '0'; - if (i > 0 && i < 5) { - *termp = (char *)lookup[i - 1].term; - *termcapp = (char *)lookup[i - 1].termcap; - break; - } - else - printf("\007Invalid choice, please try again.\n\n"); - } - } - else { - printf("\nPlease set your TERM variable before running this program.\n"); - printf("Defaulting to an ANSI compatible terminal - please press RETURN\n"); - fgets(str, 80, stdin); /* Just to make it interactive */ - *termp = (char *)"ansi"; - *termcapp = (char *)termcap_ansi; - } -} - -int -set_termcap(void) -{ - char *term; - int stat; - struct ttysize ts; - - term = getenv("TERM"); - stat = ioctl(STDERR_FILENO, GIO_COLOR, &ColorDisplay); - - if (!RunningAsInit) { - if (getenv("SYSINSTALL_DEBUG")) - DebugFD = open("sysinstall.debug", O_WRONLY|O_CREAT|O_TRUNC, 0644); - else - DebugFD = -1; - if (DebugFD < 0) - DebugFD = open("/dev/null", O_RDWR, 0); - } - - if (!OnVTY || (stat < 0)) { - if (!term) { - char *term, *termcap; - - prompt_term(&term, &termcap); - if (setenv("TERM", term, 1) < 0) - return -1; - if (setenv("TERMCAP", termcap, 1) < 0) - return -1; - } - if (DebugFD < 0) - DebugFD = open("/dev/null", O_RDWR, 0); - } - else { - int i, on; - - if (getpid() == 1) { - DebugFD = open("/dev/ttyv1", O_WRONLY); - if (DebugFD != -1) { - on = 1; - i = ioctl(DebugFD, TIOCCONS, (char *)&on); - msgDebug("ioctl(%d, TIOCCONS, NULL) = %d (%s)\n", - DebugFD, i, !i ? "success" : strerror(errno)); - } - } - if (ColorDisplay) { - if (!term) { - if (setenv("TERM", "cons25", 1) < 0) - return -1; - if (setenv("TERMCAP", termcap_cons25, 1) < 0) - return -1; - } - } - else { - if (!term) { - if (setenv("TERM", "cons25-m", 1) < 0) - return -1; - if (setenv("TERMCAP", termcap_cons25_m, 1) < 0) - return -1; - } - } - } - if (ioctl(0, TIOCGSIZE, &ts) == -1) { - msgDebug("Unable to get terminal size - errno %d\n", errno); - ts.ts_lines = 0; - } - StatusLine = ts.ts_lines ? ts.ts_lines - 1: (OnVTY ? VTY_STATUS_LINE : TTY_STATUS_LINE); - return 0; -} diff --git a/usr.sbin/sysinstall/ufs.c b/usr.sbin/sysinstall/ufs.c deleted file mode 100644 index 73c06676d6ce..000000000000 --- a/usr.sbin/sysinstall/ufs.c +++ /dev/null @@ -1,49 +0,0 @@ -/* - * The new sysinstall program. - * - * This is probably the last attempt in the `sysinstall' line, the next - * generation being slated to essentially a complete rewrite. - * - * $Id: ufs.c,v 1.13 1998/09/14 19:14:11 jkh Exp $ - * - * Copyright (c) 1995 - * Jordan Hubbard. All rights reserved. - * Copyright (c) 1995 - * Gary J Palmer. 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, - * verbatim and that no modifications are made prior to this - * point in the file. - * 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 JORDAN HUBBARD ``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 JORDAN HUBBARD OR HIS PETS 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, LIFE 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. - * - */ - -#include "sysinstall.h" -#include <sys/fcntl.h> -#include <sys/param.h> - -/* No init or shutdown routines necessary - all done in mediaSetUFS() */ - -FILE * -mediaGetUFS(Device *dev, char *file, Boolean probe) -{ - return mediaGenericGet((char *)dev->private, file); -} diff --git a/usr.sbin/sysinstall/user.c b/usr.sbin/sysinstall/user.c deleted file mode 100644 index 680a5430c87c..000000000000 --- a/usr.sbin/sysinstall/user.c +++ /dev/null @@ -1,727 +0,0 @@ -/* - * $Id: user.c,v 1.13 1997/02/22 14:12:36 peter Exp $ - * - * Copyright (c) 1996 - * Jörg Wunsch. All rights reserved. - * - * The basic structure has been taken from tcpip.c, which is: - * - * Copyright (c) 1995 - * Gary J Palmer. All rights reserved. - * Jordan K Hubbard. 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, - * verbatim and that no modifications are made prior to this - * point in the file. - * 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 AUTHORS ``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 AUTHORS 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, LIFE 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. - * - */ - -#include "sysinstall.h" -#include <utmp.h> -#include <ctype.h> -#include <sys/param.h> -#include <sysexits.h> - -/* The help file for the user mgmt screen */ -#define USER_HELPFILE "usermgmt" - -/* XXX should they be moved out to sysinstall.h? */ -#define GNAME_FIELD_LEN 32 -#define GID_FIELD_LEN 10 -#define GMEMB_FIELD_LEN 64 - -#define UID_FIELD_LEN 10 -#define UGROUP_FIELD_LEN GNAME_FIELD_LEN -#define GECOS_FIELD_LEN 64 -#define UMEMB_FIELD_LEN GMEMB_FIELD_LEN -#define HOMEDIR_FIELD_LEN 48 -#define SHELL_FIELD_LEN 48 -#define PASSWD_FIELD_LEN 32 - -/* These are nasty, but they make the layout structure a lot easier ... */ - -static char gname[GNAME_FIELD_LEN], - gid[GID_FIELD_LEN], - gmemb[GMEMB_FIELD_LEN], - uname[UT_NAMESIZE + 1], - passwd[PASSWD_FIELD_LEN], - uid[UID_FIELD_LEN], - ugroup[UGROUP_FIELD_LEN], - gecos[GECOS_FIELD_LEN], - umemb[UMEMB_FIELD_LEN], - homedir[HOMEDIR_FIELD_LEN], - shell[SHELL_FIELD_LEN]; -#define CLEAR(v) memset(v, 0, sizeof v) - -static int okbutton, cancelbutton; - - -/* What the screen size is meant to be */ -#define USER_DIALOG_Y 0 -#define USER_DIALOG_X 8 -#define USER_DIALOG_WIDTH COLS - 16 -#define USER_DIALOG_HEIGHT LINES - 2 - -/* The group configuration menu. */ -static Layout groupLayout[] = { -#define LAYOUT_GNAME 0 - { 4, 10, 20, GNAME_FIELD_LEN - 1, - "Group name:", "The alphanumeric name of the new group (mandatory)", - gname, STRINGOBJ, NULL }, -#define LAYOUT_GID 1 - { 4, 38, 10, GID_FIELD_LEN - 1, - "GID:", "The numerical ID for this group (leave blank for automatic choice)", - gid, STRINGOBJ, NULL }, -#define LAYOUT_GMEMB 2 - { 11, 10, 40, GMEMB_FIELD_LEN - 1, - "Group members:", "Who belongs to this group (i.e., gets access rights for it)", - gmemb, STRINGOBJ, NULL }, -#define LAYOUT_OKBUTTON 3 - { 18, 15, 0, 0, - "OK", "Select this if you are happy with these settings", - &okbutton, BUTTONOBJ, NULL }, -#define LAYOUT_CANCELBUTTON 4 - { 18, 35, 0, 0, - "CANCEL", "Select this if you wish to cancel this screen", - &cancelbutton, BUTTONOBJ, NULL }, - { NULL }, -}; - -/* The user configuration menu. */ -static Layout userLayout[] = { -#define LAYOUT_UNAME 0 - { 3, 6, UT_NAMESIZE, UT_NAMESIZE + 1, - "Login ID:", "The login name of the new user (mandatory)", - uname, STRINGOBJ, NULL }, -#define LAYOUT_UID 1 - { 3, 23, 8, UID_FIELD_LEN - 1, - "UID:", "The numerical ID for this user (leave blank for automatic choice)", - uid, STRINGOBJ, NULL }, -#define LAYOUT_UGROUP 2 - { 3, 33, 8, UGROUP_FIELD_LEN - 1, - "Group:", "The login group name for this user (leave blank for automatic choice)", - ugroup, STRINGOBJ, NULL }, -#define LAYOUT_PASSWD 3 - { 3, 43, 15, PASSWD_FIELD_LEN - 1, - "Password:", "The password for this user (enter this field with care!)", - passwd, NO_ECHO_OBJ(STRINGOBJ), NULL }, -#define LAYOUT_GECOS 4 - { 8, 6, 33, GECOS_FIELD_LEN - 1, - "Full name:", "The user's full name (comment)", - gecos, STRINGOBJ, NULL }, -#define LAYOUT_UMEMB 5 - { 8, 43, 15, UMEMB_FIELD_LEN - 1, - "Member groups:", "The groups this user belongs to (i.e. gets access rights for)", - umemb, STRINGOBJ, NULL }, -#define LAYOUT_HOMEDIR 6 - { 13, 6, 20, HOMEDIR_FIELD_LEN - 1, - "Home directory:", "The user's home directory (leave blank for default)", - homedir, STRINGOBJ, NULL }, -#define LAYOUT_SHELL 7 - { 13, 29, 29, SHELL_FIELD_LEN - 1, - "Login shell:", "The user's login shell (leave blank for default)", - shell, STRINGOBJ, NULL }, -#define LAYOUT_U_OKBUTTON 8 - { 18, 15, 0, 0, - "OK", "Select this if you are happy with these settings", - &okbutton, BUTTONOBJ, NULL }, -#define LAYOUT_U_CANCELBUTTON 9 - { 18, 35, 0, 0, - "CANCEL", "Select this if you wish to cancel this screen", - &cancelbutton, BUTTONOBJ, NULL }, - { NULL }, -}; - -/* whine */ -static void -feepout(char *msg) -{ - beep(); - dialog_notify(msg); -} - -/* Check for the settings on the screen. */ - -static int -verifyGroupSettings(void) -{ - char tmp[256], *cp; - long lgid; - - if (strlen(gname) == 0) { - feepout("The group name field must not be empty!"); - return 0; - } - snprintf(tmp, 256, "pw group show -q -n %s > /dev/null", gname); - if (vsystem(tmp) == 0) { - feepout("This group name is already in use."); - return 0; - } - if (strlen(gid) > 0) { - lgid = strtol(gid, &cp, 10); - if (lgid < 0 || lgid >= 65536 || (*cp != '\0' && !isspace(*cp))) { - feepout("The GID must be a number between 1 and 65535."); - return 0; - } - } - if (strlen(gmemb) > 0) { - if (strpbrk(gmemb, " \t") != NULL) { - feepout("The group member list must not contain any whitespace;\n" - "use commas to separate the names."); - return 0; - } -#ifndef notyet /* XXX */ - feepout("Sorry, the group member list feature\n" - "is currently not yet implemented."); - return 0; -#endif - } - - return 1; -} - -/* - * Ask pw(8) to fill in the blanks for us. - * Works solely on the global variables. - */ - -static void -completeGroup(void) -{ - int pfd[2], i; - char tmp[256], *cp; - ssize_t l; - size_t amnt; - pid_t pid; - char *vec[4] = - { - "pw", "group", "next", 0 - }; - - pipe (pfd); - if ((pid = fork()) == 0) - { - /* The kiddy. */ - dup2(pfd[1], 1); - dup2(pfd[1], 2); - for (i = getdtablesize(); i > 2; i--) - close(i); - - execv("/usr/sbin/pw", vec); - msgDebug("Cannot execv() /usr/sbin/pw.\n"); - _exit(99); - } - else - { - /* The oldie. */ - close(pfd[1]); - amnt = sizeof tmp; - i = 0; - while((l = read(pfd[0], &tmp[i], amnt)) > 0) - { - amnt -= l; - i += l; - if (amnt == 0) - { - close(pfd[0]); - break; - } - } - close(pfd[0]); - tmp[i] = '\0'; - waitpid(pid, &i, 0); - if (WIFSIGNALED(i) || WEXITSTATUS(i) != 0) - /* ignore by now */ - return; - if ((cp = strchr(tmp, '\n')) != NULL) - *cp = '\0'; - strncpy(gid, tmp, sizeof gid); - } -} - -static void -addGroup(WINDOW *ds_win) -{ - char tmp[256]; - int pfd[2], i; - ssize_t l; - size_t amnt; - pid_t pid; - char *vec[8] = - { - "pw", "group", "add", "-n", 0, "-g", 0, 0 - }; -#define VEC_GNAME 4 -#define VEC_GID 6 - - msgNotify("Adding group \"%s\"...", gname); - - pipe (pfd); - if ((pid = fork()) == 0) - { - /* The kiddy. */ - dup2(pfd[1], 1); - dup2(pfd[1], 2); - for (i = getdtablesize(); i > 2; i--) - close(i); - - vec[VEC_GNAME] = gname; - - if (strlen(gid) > 0) - vec[VEC_GID] = gid; - else - vec[VEC_GID - 1] = 0; - - execv("/usr/sbin/pw", vec); - msgDebug("Cannot execv() /usr/sbin/pw.\n"); - _exit(99); - } - else - { - /* The oldie. */ - close(pfd[1]); - amnt = sizeof tmp; - i = 0; - while((l = read(pfd[0], &tmp[i], amnt)) > 0) - { - amnt -= l; - i += l; - if (amnt == 0) - { - close(pfd[0]); - break; - } - } - close(pfd[0]); - tmp[i] = '\0'; - waitpid(pid, &i, 0); - if (WIFSIGNALED(i)) - msgDebug("pw(8) exited with signal %d.\n", WTERMSIG(i)); - else if(WEXITSTATUS(i)) - { - i = 0; - if(strncmp(tmp, "pw: ", 4) == 0) - i = 4; - tmp[sizeof tmp - 1] = '\0'; /* sanity */ - msgConfirm("The `pw' command exited with an error status.\n" - "Its error message was:\n\n%s", - &tmp[i]); - } - } -#undef VEC_GNAME -#undef VEC_GID -} - -int -userAddGroup(dialogMenuItem *self) -{ - WINDOW *ds_win, *save; - ComposeObj *obj = NULL; - int n = 0, cancel = FALSE, ret; - int max, firsttime = TRUE; - - if (RunningAsInit && !strstr(variable_get(SYSTEM_STATE), "install")) { - msgConfirm("This option may only be used after the system is installed, sorry!"); - return DITEM_FAILURE; - } - - save = savescr(); - dialog_clear_norefresh(); - /* We need a curses window */ - if (!(ds_win = openLayoutDialog(USER_HELPFILE, " User and Group Management ", - USER_DIALOG_X, USER_DIALOG_Y, USER_DIALOG_WIDTH, USER_DIALOG_HEIGHT))) { - beep(); - msgConfirm("Cannot open addgroup dialog window!!"); - return(DITEM_FAILURE); - } - - /* Draw a group entry box */ - draw_box(ds_win, USER_DIALOG_Y + 2, USER_DIALOG_X + 8, USER_DIALOG_HEIGHT - 8, - USER_DIALOG_WIDTH - 17, dialog_attr, border_attr); - wattrset(ds_win, dialog_attr); - mvwaddstr(ds_win, USER_DIALOG_Y + 2, USER_DIALOG_X + 22, " Add a new group "); - - CLEAR(gname); - CLEAR(gid); - CLEAR(gmemb); - - /* Some more initialisation before we go into the main input loop */ - obj = initLayoutDialog(ds_win, groupLayout, USER_DIALOG_X, USER_DIALOG_Y, &max); - -reenter: - cancelbutton = okbutton = 0; - if (firsttime) { - /* fill in the blanks, well, just the GID */ - completeGroup(); - RefreshStringObj(groupLayout[LAYOUT_GID].obj); - firsttime = FALSE; - } - - while (layoutDialogLoop(ds_win, groupLayout, &obj, &n, max, &cancelbutton, &cancel)); - - if (!cancel && !verifyGroupSettings()) - goto reenter; - - /* Clear this crap off the screen */ - delwin(ds_win); - dialog_clear_norefresh(); - use_helpfile(NULL); - - if (!cancel) { - addGroup(ds_win); - ret = DITEM_SUCCESS; - } - else - ret = DITEM_FAILURE; - restorescr(save); - return ret; -} - -/* Check for the settings on the screen. */ - -static int -verifyUserSettings(WINDOW *ds_win) -{ - char tmp[256], *cp; - long luid; - WINDOW *save; - int rv; - - if (strlen(uname) == 0) { - feepout("The user name field must not be empty!"); - return 0; - } - snprintf(tmp, 256, "pw user show -q -n %s > /dev/null", uname); - if (vsystem(tmp) == 0) { - feepout("This user name is already in use."); - return 0; - } - if (strlen(uid) > 0) { - luid = strtol(uid, &cp, 10); - if (luid < 0 || luid >= 65536 || (*cp != '\0' && !isspace(*cp))) { - feepout("The UID must be a number between 1 and 65535."); - return 0; - } - } - if (strlen(shell) > 0) { - while((cp = getusershell()) != NULL) - if (strcmp(cp, shell) == 0) - break; - endusershell(); - if (cp == NULL) { - save = savescr(); - rv = msgYesNo("Warning:\n\n" - "The requested shell \"%s\" is not\n" - "a valid user shell.\n\n" - "Use it anyway?\n", shell); - restorescr(save); - wrefresh(ds_win); - if (rv != DITEM_SUCCESS) - return 0; - } - - } - - if (strlen(umemb) > 0) { - if (strpbrk(umemb, " \t") != NULL) { - feepout("The member groups list must not contain any whitespace;\n" - "use commas to separate the names."); - return 0; - } - } - - return 1; -} - -/* - * Ask pw(8) to fill in the blanks for us. - * Works solely on the global variables. - */ - -static void -completeUser(void) -{ - int pfd[2], i; - char tmp[256], *cp, *cp2; - ssize_t l; - size_t amnt; - pid_t pid; - char *vec[7] = - { - "pw", "user", "add", "-N", "-n", 0, 0 - }; -#define VEC_UNAME 5 - - pipe (pfd); - if ((pid = fork()) == 0) - { - /* The kiddy. */ - dup2(pfd[1], 1); - dup2(pfd[1], 2); - for (i = getdtablesize(); i > 2; i--) - close(i); - - vec[VEC_UNAME] = uname; - - execv("/usr/sbin/pw", vec); - msgDebug("Cannot execv() /usr/sbin/pw.\n"); - _exit(99); - } - else - { - /* The oldie. */ - close(pfd[1]); - amnt = sizeof tmp; - i = 0; - while((l = read(pfd[0], &tmp[i], amnt)) > 0) - { - amnt -= l; - i += l; - if (amnt == 0) - { - close(pfd[0]); - break; - } - } - close(pfd[0]); - tmp[i] = '\0'; - waitpid(pid, &i, 0); - if (WIFSIGNALED(i) || WEXITSTATUS(i) != 0) - /* ignore by now */ - return; - if ((cp = strchr(tmp, '\n')) != NULL) - *cp = '\0'; - if ((cp = strchr(tmp, ':')) == NULL || (cp = strchr(++cp, ':')) == NULL) - return; - cp++; - if ((cp2 = strchr(cp, ':')) == NULL) - return; - *cp2++ = '\0'; - strncpy(uid, cp, sizeof uid); - cp = cp2; - if ((cp2 = strchr(cp, ':')) == NULL) - return; - *cp2++ = '\0'; -#ifdef notyet /* XXX pw user add -g doesn't accept a numerical GID */ - strncpy(ugroup, cp, sizeof ugroup); -#endif - cp = cp2; - if ((cp2 = strchr(cp, ':')) == NULL || (cp2 = strchr(++cp2, ':')) == NULL || - (cp = cp2 = strchr(++cp2, ':')) == NULL || (cp2 = strchr(++cp2, ':')) == NULL) - return; - *cp2++ = '\0'; - cp++; - strncpy(gecos, cp, sizeof gecos); - cp = cp2; - if ((cp2 = strchr(cp, ':')) == NULL) - return; - *cp2++ = '\0'; - if (*cp2) - strncpy(shell, cp2, sizeof shell); - } -#undef VEC_UNAME -} - -static void -addUser(WINDOW *ds_win) -{ - char tmp[256], *msg; - int pfd[2], ipfd[2], i, j; - ssize_t l; - size_t amnt; - pid_t pid; - /* - * Maximal list: - * pw user add -m -n uname -g grp -u uid -c comment -d homedir -s shell -G grplist -h 0 - */ - char *vec[21] = - { - "pw", "user", "add", "-m", "-n", /* ... */ - }; -#define VEC_UNAME 5 - - msgNotify("Adding user \"%s\"...", uname); - - pipe (pfd); - pipe (ipfd); - if ((pid = fork()) == 0) - { - /* The kiddy. */ - dup2(ipfd[0], 0); - dup2(pfd[1], 1); - dup2(pfd[1], 2); - for (i = getdtablesize(); i > 2; i--) - close(i); - - vec[i = VEC_UNAME] = uname; - i++; -#define ADDVEC(var, option) do { if (strlen(var) > 0) { vec[i++] = option; vec[i++] = var; } } while (0) - ADDVEC(ugroup, "-g"); - ADDVEC(uid, "-u"); - ADDVEC(gecos, "-c"); - ADDVEC(homedir, "-d"); - ADDVEC(shell, "-s"); - ADDVEC(umemb, "-G"); - if (passwd[0]) { - vec[i++] = "-h"; - vec[i++] = "0"; - } - vec[i] = 0; - - execv("/usr/sbin/pw", vec); - msgDebug("Cannot execv() /usr/sbin/pw.\n"); - _exit(99); - } - else - { - /* The oldie. */ - close(pfd[1]); - close(ipfd[0]); - - if (passwd[0]) - write(ipfd[1], passwd, strlen(passwd)); - close(ipfd[1]); - amnt = sizeof tmp; - i = 0; - while((l = read(pfd[0], &tmp[i], amnt)) > 0) - { - amnt -= l; - i += l; - if (amnt == 0) - { - close(pfd[0]); - break; - } - } - close(pfd[0]); - tmp[i] = '\0'; - waitpid(pid, &i, 0); - if (WIFSIGNALED(i)) - { - j = WTERMSIG(i); - msg = "The `pw' command exited with signal %d.\n"; - goto sysfail; - } - else if((j = WEXITSTATUS(i))) - { - i = 0; - if(strncmp(tmp, "pw: ", 4) == 0) - i = 4; - tmp[sizeof tmp - 1] = '\0'; /* sanity */ - if (j == EX_DATAERR || j == EX_NOUSER || j == EX_SOFTWARE) - msgConfirm("The `pw' command exited with an error status.\n" - "Its error message was:\n\n%s", - &tmp[i]); - else - { - msg = "The `pw' command exited with unexpected status %d.\n"; - sysfail: - msgDebug(msg, j); - msgDebug("Command stdout and stderr was:\n\n%s", tmp); - msgConfirm(msg, j); - } - } - else if (!passwd[0]) - msgConfirm("You will need to enter a password for this user\n" - "later, using the passwd(1) command from the shell.\n\n" - "The account for `%s' is currently still disabled.", - uname); - } -#undef VEC_UNAME -#undef ADDVEC -} - -int -userAddUser(dialogMenuItem *self) -{ - WINDOW *ds_win, *save; - ComposeObj *obj = NULL; - int n = 0, cancel = FALSE, ret; - int max, firsttime = TRUE; - - if (RunningAsInit && !strstr(variable_get(SYSTEM_STATE), "install")) { - msgConfirm("This option may only be used after the system is installed, sorry!"); - return DITEM_FAILURE; - } - - save = savescr(); - dialog_clear_norefresh(); - - /* We need a curses window */ - if (!(ds_win = openLayoutDialog(USER_HELPFILE, " User and Group Management ", - USER_DIALOG_X, USER_DIALOG_Y, USER_DIALOG_WIDTH, USER_DIALOG_HEIGHT))) { - beep(); - msgConfirm("Cannot open adduser dialog window!!"); - return(DITEM_FAILURE); - } - - /* Draw a user entry box */ - draw_box(ds_win, USER_DIALOG_Y + 1, USER_DIALOG_X + 3, USER_DIALOG_HEIGHT - 6, - USER_DIALOG_WIDTH - 6, dialog_attr, border_attr); - wattrset(ds_win, dialog_attr); - mvwaddstr(ds_win, USER_DIALOG_Y + 1, USER_DIALOG_X + 22, " Add a new user "); - - CLEAR(uname); - CLEAR(uid); - CLEAR(ugroup); - CLEAR(gecos); - CLEAR(passwd); - CLEAR(umemb); - CLEAR(homedir); - CLEAR(shell); - - /* Some more initialisation before we go into the main input loop */ - obj = initLayoutDialog(ds_win, userLayout, USER_DIALOG_X, USER_DIALOG_Y, &max); - -reenter: - cancelbutton = okbutton = 0; - if (firsttime) { - /* fill in the blanks, well, just the GID */ - completeUser(); - RefreshStringObj(userLayout[LAYOUT_UID].obj); - RefreshStringObj(userLayout[LAYOUT_UGROUP].obj); - RefreshStringObj(userLayout[LAYOUT_GECOS].obj); - RefreshStringObj(userLayout[LAYOUT_UMEMB].obj); - RefreshStringObj(userLayout[LAYOUT_HOMEDIR].obj); - RefreshStringObj(userLayout[LAYOUT_SHELL].obj); - firsttime = FALSE; - } - - while (layoutDialogLoop(ds_win, userLayout, &obj, &n, max, &cancelbutton, &cancel)); - - if (!cancel && !verifyUserSettings(ds_win)) - goto reenter; - - /* Clear this crap off the screen */ - delwin(ds_win); - dialog_clear_norefresh(); - use_helpfile(NULL); - - if (!cancel) { - addUser(ds_win); - ret = DITEM_SUCCESS; - } - else - ret = DITEM_FAILURE; - restorescr(save); - return ret; -} - diff --git a/usr.sbin/sysinstall/variable.c b/usr.sbin/sysinstall/variable.c deleted file mode 100644 index 2dc227af619b..000000000000 --- a/usr.sbin/sysinstall/variable.c +++ /dev/null @@ -1,224 +0,0 @@ -/* - * The new sysinstall program. - * - * This is probably the last program in the `sysinstall' line - the next - * generation being essentially a complete rewrite. - * - * $Id: variable.c,v 1.23 1998/03/15 17:10:17 jkh Exp $ - * - * Copyright (c) 1995 - * Jordan Hubbard. 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, - * verbatim and that no modifications are made prior to this - * point in the file. - * 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 JORDAN HUBBARD ``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 JORDAN HUBBARD OR HIS PETS 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, LIFE 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. - * - */ - -#include "sysinstall.h" - -/* Routines for dealing with variable lists */ - -static void -make_variable(char *var, char *value) -{ - Variable *vp; - - /* Trim leading and trailing whitespace */ - var = string_skipwhite(string_prune(var)); - - if (!var || !*var) - return; - - /* Put it in the environment in any case */ - setenv(var, value, 1); - - /* Now search to see if it's already in the list */ - for (vp = VarHead; vp; vp = vp->next) { - if (!strcmp(vp->name, var)) { - if (isDebug()) - msgDebug("variable %s was %s, now %s\n", vp->name, vp->value, value); - free(vp->value); - vp->value = strdup(value); - return; - } - } - - /* No? Create a new one */ - vp = (Variable *)safe_malloc(sizeof(Variable)); - vp->name = strdup(var); - vp->value = strdup(value); - vp->next = VarHead; - VarHead = vp; - if (isDebug()) - msgDebug("Setting variable %s to %s\n", vp->name, vp->value); -} - -void -variable_set(char *var) -{ - char tmp[1024], *cp; - - if (!var) - msgFatal("NULL variable name & value passed."); - else if (!*var) - msgDebug("Warning: Zero length name & value passed to variable_set()\n"); - SAFE_STRCPY(tmp, var); - if ((cp = index(tmp, '=')) == NULL) - msgFatal("Invalid variable format: %s", var); - *(cp++) = '\0'; - make_variable(tmp, string_skipwhite(cp)); -} - -void -variable_set2(char *var, char *value) -{ - if (!var || !value) - msgFatal("Null name or value passed to set_variable2!"); - else if (!*var || !*value) - msgDebug("Warning: Zero length name or value passed to variable_set2()\n"); - make_variable(var, value); -} - -char * -variable_get(char *var) -{ - return getenv(var); -} - -int -variable_cmp(char *var, char *value) -{ - char *val; - - if ((val = variable_get(var))) - return strcmp(val, value); - return -1; -} - -void -variable_unset(char *var) -{ - Variable *vp; - char name[512], *cp; - - if ((cp = index(var, '=')) != NULL) - sstrncpy(name, var, cp - var); - else - SAFE_STRCPY(name, var); - unsetenv(name); - /* Now search to see if it's in our list, if we have one.. */ - if (!VarHead) - return; - else if (!VarHead->next && !strcmp(VarHead->name, name)) { - safe_free(VarHead->name); - safe_free(VarHead->value); - free(VarHead); - VarHead = NULL; - } - else { - for (vp = VarHead; vp; vp = vp->next) { - if (!strcmp(vp->name, name)) { - Variable *save = vp->next; - - safe_free(vp->name); - safe_free(vp->value); - *vp = *save; - safe_free(save); - break; - } - } - } -} - -/* Prompt user for the name of a variable */ -char * -variable_get_value(char *var, char *prompt) -{ - char *cp; - - cp = variable_get(var); - if (cp && variable_get(VAR_NONINTERACTIVE)) - return cp; - else if ((cp = msgGetInput(cp, prompt)) != NULL) - variable_set2(var, cp); - else - cp = NULL; - return cp; -} - -/* Check if value passed in data (in the form "variable=value") is equal to value of - variable stored in env */ -int -variable_check(char *data) -{ - char *cp, *cp2, *cp3, tmp[256]; - - if (!data) - return FALSE; - SAFE_STRCPY(tmp, data); - if ((cp = index(tmp, '=')) != NULL) { - *(cp++) = '\0'; - if (*cp == '"') { /* smash quotes if present */ - ++cp; - if ((cp3 = index(cp, '"')) != NULL) - *cp3 = '\0'; - } - else if ((cp3 = index(cp, ',')) != NULL) - *cp3 = '\0'; - cp2 = getenv(tmp); - if (cp2) { - if (!*cp) - return TRUE; - else - return !strcmp(cp, cp2); - } - else - return FALSE; - } - else - return getenv(tmp) ? TRUE : FALSE; -} - -int -dump_variables(dialogMenuItem *unused) -{ - FILE *fp; - Variable *vp; - - if (isDebug()) - msgDebug("Writing sysinstall variables to file.."); - - fp = fopen("/etc/sysinstall.vars", "w"); - if (!fp) { - msgConfirm("Unable to write to /etc/sysinstall.vars: %s", - strerror(errno)); - return DITEM_FAILURE; - } - - for (vp = VarHead; vp; vp = vp->next) - fprintf(fp, "%s=\"%s\"\n", vp->name, vp->value); - - fclose(fp); - - return DITEM_SUCCESS; -} diff --git a/usr.sbin/sysinstall/wizard.c b/usr.sbin/sysinstall/wizard.c deleted file mode 100644 index 000966616993..000000000000 --- a/usr.sbin/sysinstall/wizard.c +++ /dev/null @@ -1,206 +0,0 @@ -/* - * ---------------------------------------------------------------------------- - * "THE BEER-WARE LICENSE" (Revision 42): - * <phk@login.dknet.dk> wrote this file. As long as you retain this notice you - * can do whatever you want with this stuff. If we meet some day, and you think - * this stuff is worth it, you can buy me a beer in return. Poul-Henning Kamp - * ---------------------------------------------------------------------------- - * - * $Id: wizard.c,v 1.12 1998/09/08 10:46:40 jkh Exp $ - * - */ - -#include "sysinstall.h" -#include <fcntl.h> -#include <err.h> - -u_char mbr[] = { - 250,51,192,142,208,188,0,124,139,244,80,7,80,31,251,252,191,0,6,185,0,1, - 242,165,234,29,6,0,0,190,190,7,179,4,128,60,128,116,14,128,60,0,117,28, - 131,198,16,254,203,117,239,205,24,139,20,139,76,2,139,238,131,198,16,254, - 203,116,26,128,60,0,116,244,190,139,6,172,60,0,116,11,86,187,7,0,180,14, - 205,16,94,235,240,235,254,191,5,0,187,0,124,184,1,2,87,205,19,95,115,12, - 51,192,205,19,79,117,237,190,163,6,235,211,190,194,6,191,254,125,129,61, - 85,170,117,199,139,245,234,0,124,0,0,73,110,118,97,108,105,100,32,112,97, - 114,116,105,116,105,111,110,32,116,97,98,108,101,0,69,114,114,111,114,32, - 108,111,97,100,105,110,103,32,111,112,101,114,97,116,105,110,103,32,115, - 121,115,116,101,109,0,77,105,115,115,105,110,103,32,111,112,101,114,97, - 116,105,110,103,32,115,121,115,116,101,109,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,128, - 1,1,0,4,15,63,60,63,0,0,0,241,239,0,0,0,0,1,61,5,15,63,243,48,240,0,0,144, - 208,2,0,0,0,1,244,165,15,63,170,192,192,3,0,144,208,2,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,85,170 -}; - -int -scan_block(int fd, daddr_t block) -{ - u_char foo[512]; - - if (-1 == lseek(fd,block * 512,SEEK_SET)) - err(1,"lseek"); - if (512 != read(fd,foo, 512)) - return 1; - return 0; -} - -void -Scan_Disk(Disk *d) -{ - char device[64]; - u_long l; - int i,j,fd; - - strcpy(device,"/dev/r"); - strcat(device,d->name); - - fd = open(device,O_RDWR); - if (fd < 0) { - msgWarn("open(%s) failed", device); - return; - } - for(i=-1,l=0;;l++) { - j = scan_block(fd,l); - if (j != i) { - if (i == -1) { - printf("%c: %lu.",j ? 'B' : 'G', l); - fflush(stdout); - } else if (i == 0) { - printf(".%lu\nB: %lu.",l-1,l); - fflush(stdout); - } else { - printf(".%lu\nG: %lu.",l-1,l); - fflush(stdout); - } - i = j; - } - } - close(fd); -} - -void -slice_wizard(Disk *d) -{ - Disk *db; - char myprompt[BUFSIZ]; - char input[BUFSIZ]; - char *p,*q=0; - char **cp,*cmds[200]; - int ncmd,i; - - sprintf(myprompt,"%s> ", d->name); - while(1) { - printf("--==##==--\n"); - Debug_Disk(d); - p = CheckRules(d); - if (p) { - printf("%s",p); - free(p); - } - printf(myprompt); - fflush(stdout); - q = p = fgets(input,sizeof(input),stdin); - if(!p) - break; - for(cp = cmds; (*cp = strsep(&p, " \t\n")) != NULL;) - if (**cp != '\0') - cp++; - ncmd = cp - cmds; - if(!ncmd) - continue; - if (!strcasecmp(*cmds,"quit")) { break; } - if (!strcasecmp(*cmds,"exit")) { break; } - if (!strcasecmp(*cmds,"q")) { break; } - if (!strcasecmp(*cmds,"x")) { break; } - if (!strcasecmp(*cmds,"delete") && ncmd == 2) { - printf("delete = %d\n", - Delete_Chunk(d, - (struct chunk *)strtol(cmds[1],0,0))); - continue; - } - if (!strcasecmp(*cmds,"allfreebsd")) { - All_FreeBSD(d, 0); - continue; - } - if (!strcasecmp(*cmds,"dedicate")) { - All_FreeBSD(d, 1); - continue; - } - if (!strcasecmp(*cmds,"bios") && ncmd == 4) { - Set_Bios_Geom(d, - strtol(cmds[1],0,0), - strtol(cmds[2],0,0), - strtol(cmds[3],0,0)); - continue; - } - if (!strcasecmp(*cmds,"list")) { - cp = Disk_Names(); - printf("Disks:"); - for(i=0;cp[i];i++) { - printf(" %s",cp[i]); - free(cp[i]); - } - free(cp); - continue; - } - if (!strcasecmp(*cmds,"create") && ncmd == 6) { - - printf("Create=%d\n", - Create_Chunk(d, - strtol(cmds[1],0,0), - strtol(cmds[2],0,0), - strtol(cmds[3],0,0), - strtol(cmds[4],0,0), - strtol(cmds[5],0,0))); - continue; - } - if (!strcasecmp(*cmds,"read")) { - db = d; - if (ncmd > 1) - d = Open_Disk(cmds[1]); - else - d = Open_Disk(d->name); - if (d) - Free_Disk(db); - else - d = db; - continue; - } - if (!strcasecmp(*cmds,"scan")) { - Scan_Disk(d); - continue; - } - if (!strcasecmp(*cmds,"write")) { - printf("Write=%d\n", - Fake ? 0 : Write_Disk(d)); - Free_Disk(d); - d = Open_Disk(d->name); - continue; - } - if (strcasecmp(*cmds,"help")) - printf("\007ERROR\n"); - printf("CMDS:\n"); - printf("allfreebsd\t\t"); - printf("dedicate\t\t"); - printf("bios cyl hd sect\n"); - printf("collapse [pointer]\t\t"); - printf("create offset size enum subtype flags\n"); - printf("subtype(part): swap=1, ffs=7\t\t"); - printf("delete pointer\n"); - printf("list\t\t"); - printf("quit\n"); - printf("read [disk]\t\t"); - printf("scan\n"); - printf("write\t\t"); - printf("ENUM:\n\t"); - for(i=0;chunk_n[i];i++) - printf("%d = %s%s",i,chunk_n[i],i == 4 ? "\n\t" : " "); - printf("\n"); - - } -} |