diff --git a/usr.sbin/Makefile b/usr.sbin/Makefile index 0743562a4f6..79f4d560103 100644 --- a/usr.sbin/Makefile +++ b/usr.sbin/Makefile @@ -14,8 +14,6 @@ SUBDIR= adduser \ clear_locks \ crashinfo \ cron \ - ctladm \ - ctld \ daemon \ dconschat \ devctl \ @@ -114,7 +112,6 @@ SUBDIR= adduser \ SUBDIR.${MK_ACCT}+= accton SUBDIR.${MK_ACCT}+= sa -SUBDIR.${MK_AMD}+= amd SUBDIR.${MK_AUDIT}+= audit SUBDIR.${MK_AUDIT}+= auditd .if ${MK_OPENSSL} != "no" @@ -133,7 +130,6 @@ SUBDIR.${MK_BSNMP}+= bsnmpd .if ${MK_CAROOT} != "no" SUBDIR.${MK_OPENSSL}+= certctl .endif -SUBDIR.${MK_CTM}+= ctm SUBDIR.${MK_CXGBETOOL}+= cxgbetool SUBDIR.${MK_DIALOG}+= bsdconfig SUBDIR.${MK_EFI}+= efivar efidp efibootmgr @@ -159,7 +155,7 @@ SUBDIR.${MK_INET6}+= rtsold SUBDIR.${MK_INET6}+= traceroute6 SUBDIR.${MK_INETD}+= inetd SUBDIR.${MK_IPFW}+= ipfwpcap -SUBDIR.${MK_ISCSI}+= iscsid +SUBDIR.${MK_ISCSI}+= ctladm ctld iscsid SUBDIR.${MK_JAIL}+= jail SUBDIR.${MK_JAIL}+= jexec SUBDIR.${MK_JAIL}+= jls @@ -168,16 +164,12 @@ SUBDIR.${MK_LEGACY_CONSOLE}+= kbdcontrol SUBDIR.${MK_LEGACY_CONSOLE}+= kbdmap SUBDIR.${MK_LEGACY_CONSOLE}+= moused SUBDIR.${MK_LEGACY_CONSOLE}+= vidcontrol -.if ${MK_LIBTHR} != "no" || ${MK_LIBPTHREAD} != "no" SUBDIR.${MK_PPP}+= pppctl SUBDIR.${MK_NS_CACHING}+= nscd -.endif SUBDIR.${MK_LPR}+= lpr SUBDIR.${MK_MAN_UTILS}+= manctl SUBDIR.${MK_MIDNIGHTBSD_UPDATE}+= midnightbsd-update SUBDIR.${MK_MLX5TOOL}+= mlx5tool -SUBDIR.${MK_NAND}+= nandsim -SUBDIR.${MK_NAND}+= nandtool SUBDIR.${MK_NETGRAPH}+= flowctl SUBDIR.${MK_NETGRAPH}+= ngctl SUBDIR.${MK_NETGRAPH}+= nghook @@ -193,12 +185,10 @@ SUBDIR.${MK_NIS}+= ypserv SUBDIR.${MK_NIS}+= ypset SUBDIR.${MK_NTP}+= ntpd SUBDIR.${MK_OPENSSL}+= keyserv -SUBDIR.${MK_PC_SYSINSTALL}+= pc-sysinstall +SUBDIR.${MK_OPENSSL_KTLS}+= rpc.tlsclntd +SUBDIR.${MK_OPENSSL_KTLS}+= rpc.tlsservd SUBDIR.${MK_PF}+= ftp-proxy -.if ${COMPILER_FEATURES:Mc++11} -SUBDIR.${MK_PMC}+= pmc -.endif -SUBDIR.${MK_PMC}+= pmcannotate pmccontrol pmcstat pmcstudy +SUBDIR.${MK_PMC}+= pmc pmcannotate pmccontrol pmcstat pmcstudy SUBDIR.${MK_PORTSNAP}+= portsnap SUBDIR.${MK_PPP}+= ppp SUBDIR.${MK_QUOTAS}+= edquota @@ -211,7 +201,6 @@ SUBDIR.${MK_SENDMAIL}+= praliases SUBDIR.${MK_SENDMAIL}+= sendmail SUBDIR.${MK_TCP_WRAPPERS}+= tcpdchk SUBDIR.${MK_TCP_WRAPPERS}+= tcpdmatch -SUBDIR.${MK_TIMED}+= timed SUBDIR.${MK_TOOLCHAIN}+= config SUBDIR.${MK_TOOLCHAIN}+= crunch SUBDIR.${MK_UNBOUND}+= unbound diff --git a/usr.sbin/amd/Makefile b/usr.sbin/amd/Makefile deleted file mode 100644 index d88c7447ee2..00000000000 --- a/usr.sbin/amd/Makefile +++ /dev/null @@ -1,12 +0,0 @@ -# ex:ts=8 -# -# Makefile for amd -# This file is under a "BSD" copyright (c) by David O'Brien 1998 -# - -SUBDIR= include libamu .WAIT \ - amd amq fixmount fsinfo hlfsd mk-amd-map pawd \ - scripts wire-test -SUBDIR_PARALLEL= - -.include diff --git a/usr.sbin/amd/Makefile.inc b/usr.sbin/amd/Makefile.inc deleted file mode 100644 index f8de8ba1ecb..00000000000 --- a/usr.sbin/amd/Makefile.inc +++ /dev/null @@ -1,41 +0,0 @@ -# ex:ts=8 -# -# -# Makefile for amd -# This file is under a "BSD" copyright (c) by David O'Brien 1998. -# Portions derived from -# $NetBSD: Makefile.inc,v 1.10 1998/08/08 22:33:27 christos Exp $ -# Portions derived from amd/libamu/Makefile -# $NetBSD: Makefile,v 1.8 1998/08/08 22:33:37 christos Exp $ - -.include - -PACKAGE= amd - -CFLAGS+= -I. -I${.CURDIR} -CFLAGS+= -I${.CURDIR:H}/include -.if exists(${.OBJDIR:H}/include) -CFLAGS+= -I${.OBJDIR:H}/include -.endif -CFLAGS+= -I${SRCTOP}/contrib/amd/include -CFLAGS+= -I${SRCTOP}/contrib/amd -CFLAGS+= -DHAVE_CONFIG_H -.if ${MK_NIS} == "no" -CFLAGS+= -DHAVE_LOCALCONFIG_H -.endif - -.if ${MK_HESIOD} != "no" -CFLAGS+= -DYES_HESIOD -.endif - -CFLAGS+= -DHOST_CPU=\"${MACHINE_CPUARCH}\" -DHOST_ARCH=\"${MACHINE_ARCH}\" - -RPCCOM= RPCGEN_CPP=${CPP:Q} rpcgen -MOUNT_X= ${SRCTOP}/include/rpcsvc/mount.x -NFS_PROT_X= ${SRCTOP}/include/rpcsvc/nfs_prot.x - -WARNS?= 1 - -.if exists(${.CURDIR:H:H}/Makefile.inc) -.include "${.CURDIR:H:H}/Makefile.inc" -.endif diff --git a/usr.sbin/amd/NOTES b/usr.sbin/amd/NOTES deleted file mode 100644 index b04244bfb66..00000000000 --- a/usr.sbin/amd/NOTES +++ /dev/null @@ -1,3 +0,0 @@ -amd/amd supports HESIOD, LDAP, and NIS+ which we don't presently. -If they are added to FreeBSD, add info_hesiod.c, info_ldap.c, info_nisplus.c -to amd/amd's Makefile. diff --git a/usr.sbin/amd/amd/Makefile b/usr.sbin/amd/amd/Makefile deleted file mode 100644 index f59b64cc609..00000000000 --- a/usr.sbin/amd/amd/Makefile +++ /dev/null @@ -1,81 +0,0 @@ -# ex:ts=8 -# -# Makefile for amd -# This file is under a "BSD" copyright (c) by David O'Brien 1998 -# -# - -.include - -.PATH: ${SRCTOP}/contrib/amd/amd - -CONFS= amd.map -PROG= amd -MAN= amd.8 -SRCS= am_ops.c amd.c amfs_auto.c amfs_direct.c amfs_error.c amfs_generic.c -SRCS+= amfs_host.c amfs_link.c amfs_linkx.c amfs_nfsl.c -SRCS+= amfs_nfsx.c amfs_program.c amfs_root.c amfs_toplvl.c -SRCS+= amfs_union.c amq_subr.c amq_svc.c autil.c clock.c conf.c -SRCS+= get_args.c info_exec.c info_file.c info_ndbm.c info_passwd.c -SRCS+= info_sun.c -SRCS+= info_union.c map.c mapc.c mntfs.c nfs_prot_svc.c nfs_start.c -SRCS+= nfs_subr.c ops_cdfs.c ops_lustre.c ops_mfs.c ops_nfs.c -SRCS+= ops_nfs3.c ops_nfs4.c -SRCS+= ops_nullfs.c ops_pcfs.c ops_tfs.c ops_tmpfs.c ops_udf.c ops_ufs.c -SRCS+= ops_umapfs.c -SRCS+= ops_unionfs.c opts.c readdir.c restart.c rpc_fwd.c sched.c -SRCS+= srvr_amfs_auto.c srvr_nfs.c sun_map.c - -CFLAGS+= -I${SRCTOP}/contrib/amd/amd \ - -I${SRCTOP}/contrib/amd/include \ - -I${OBJTOP}/include/rpcsvc - -LIBADD= amu - -SRCS+= conf_parse.c conf_parse.h conf_tok.c -SRCS+= sun_map_parse.c sun_map_parse.h sun_map_tok.c -CLEANFILES+= conf_parse.c conf_parse.h conf_tok.c -CLEANFILES+= sun_map_parse.c sun_map_parse.h sun_map_tok.c - -conf_tok.c: conf_tok.l - ${LEX} ${LFLAGS} -Pconf_ -o${.TARGET} ${.ALLSRC} - -.ORDER: conf_parse.c conf_parse.h -conf_parse.h: .NOMETA -conf_parse.c conf_parse.h: conf_parse.y - ${YACC} ${YFLAGS} -pconf_ -oconf_parse.c ${.ALLSRC} - -sun_map_tok.c: sun_map_tok.l - ${LEX} ${LFLAGS} -Psun_map_ -o${.TARGET} ${.ALLSRC} - -.ORDER: sun_map_parse.c sun_map_parse.h -sun_map_parse.h: .NOMETA -sun_map_parse.c sun_map_parse.h: sun_map_parse.y - ${YACC} ${YFLAGS} -psun_map_ -osun_map_parse.c ${.ALLSRC} - -conf_tok.o: conf_parse.h - -sun_map_tok.o: sun_map_parse.h - -# These are generated at compile time -SRCS+= mount_xdr.c -CLEANFILES+= mount_xdr.c - -mount_xdr.c: ${MOUNT_X} - ${RPCCOM} -c -DWANT_NFS3 ${.ALLSRC} -o ${.TARGET} - -.if ${MK_HESIOD} != "no" -SRCS+= info_hesiod.c -CFLAGS+= -DHAVE_MAP_HESIOD -.endif - -.if ${MK_NIS} != "no" -SRCS+= info_nis.c -.endif - -.if ${MK_TCP_WRAPPERS} != "no" -CFLAGS+= -DHAVE_LIBWRAP -DHAVE_TCPD_H -LIBADD+= wrap -.endif - -.include diff --git a/usr.sbin/amd/amd/Makefile.depend b/usr.sbin/amd/amd/Makefile.depend deleted file mode 100644 index 545268a9328..00000000000 --- a/usr.sbin/amd/amd/Makefile.depend +++ /dev/null @@ -1,21 +0,0 @@ -# Autogenerated - do NOT edit! - -DIRDEPS = \ - include \ - include/arpa \ - include/rpc \ - include/rpcsvc \ - include/xlocale \ - lib/${CSU_DIR} \ - lib/libc \ - lib/libcompiler_rt \ - usr.bin/yacc.host \ - usr.sbin/amd/include \ - usr.sbin/amd/libamu \ - - -.include - -.if ${DEP_RELDIR} == ${_DEP_RELDIR} -# local dependencies - needed for -jN in clean tree -.endif diff --git a/usr.sbin/amd/amd/Makefile.depend.options b/usr.sbin/amd/amd/Makefile.depend.options deleted file mode 100644 index fbc21670804..00000000000 --- a/usr.sbin/amd/amd/Makefile.depend.options +++ /dev/null @@ -1,5 +0,0 @@ -# This file is not autogenerated - take care! - -DIRDEPS_OPTIONS= TCP_WRAPPERS - -.include diff --git a/usr.sbin/amd/amd/amd.map b/usr.sbin/amd/amd/amd.map deleted file mode 100644 index 1ab0582b673..00000000000 --- a/usr.sbin/amd/amd/amd.map +++ /dev/null @@ -1,3 +0,0 @@ -# -/defaults type:=host;fs:=${autodir}/${rhost}/host;rhost:=${key} -* opts:=rw,grpid,resvport,vers=3,proto=tcp,nosuid,nodev diff --git a/usr.sbin/amd/amq/Makefile b/usr.sbin/amd/amq/Makefile deleted file mode 100644 index 2b3b4533a76..00000000000 --- a/usr.sbin/amd/amq/Makefile +++ /dev/null @@ -1,18 +0,0 @@ -# ex:ts=8 -# -# Makefile for amd -# This file is under a "BSD" copyright (c) by David O'Brien 1998 -# -# - -.PATH: ${SRCTOP}/contrib/amd/amq - -PROG= amq -MAN= amq.8 -SRCS= amq.c amq_clnt.c amq_xdr.c - -CFLAGS+= -I${SRCTOP}/contrib/amd/amq - -LIBADD= amu - -.include diff --git a/usr.sbin/amd/amq/Makefile.depend b/usr.sbin/amd/amq/Makefile.depend deleted file mode 100644 index bcad3fbca4b..00000000000 --- a/usr.sbin/amd/amq/Makefile.depend +++ /dev/null @@ -1,21 +0,0 @@ -# Autogenerated - do NOT edit! - -DIRDEPS = \ - gnu/lib/csu \ - include \ - include/arpa \ - include/rpc \ - include/rpcsvc \ - include/xlocale \ - lib/${CSU_DIR} \ - lib/libc \ - lib/libcompiler_rt \ - usr.sbin/amd/include \ - usr.sbin/amd/libamu \ - - -.include - -.if ${DEP_RELDIR} == ${_DEP_RELDIR} -# local dependencies - needed for -jN in clean tree -.endif diff --git a/usr.sbin/amd/fixmount/Makefile b/usr.sbin/amd/fixmount/Makefile deleted file mode 100644 index 08091233f63..00000000000 --- a/usr.sbin/amd/fixmount/Makefile +++ /dev/null @@ -1,19 +0,0 @@ -# ex:ts=8 -# -# Makefile for amd -# This file is under a "BSD" copyright (c) by David O'Brien 1998 -# - -.PATH: ${SRCTOP}/contrib/amd/fixmount \ - ${SRCTOP}/contrib/amd/conf/checkmount - -PROG= fixmount -MAN= fixmount.8 -SRCS= fixmount.c - -# These would be links created by the GNU-style configure -SRCS+= checkmount_bsd44.c - -LIBADD+= amu rpcsvc - -.include diff --git a/usr.sbin/amd/fixmount/Makefile.depend b/usr.sbin/amd/fixmount/Makefile.depend deleted file mode 100644 index 17c10bdd0d3..00000000000 --- a/usr.sbin/amd/fixmount/Makefile.depend +++ /dev/null @@ -1,22 +0,0 @@ -# Autogenerated - do NOT edit! - -DIRDEPS = \ - gnu/lib/csu \ - include \ - include/arpa \ - include/rpc \ - include/rpcsvc \ - include/xlocale \ - lib/${CSU_DIR} \ - lib/libc \ - lib/libcompiler_rt \ - lib/librpcsvc \ - usr.sbin/amd/include \ - usr.sbin/amd/libamu \ - - -.include - -.if ${DEP_RELDIR} == ${_DEP_RELDIR} -# local dependencies - needed for -jN in clean tree -.endif diff --git a/usr.sbin/amd/fsinfo/Makefile b/usr.sbin/amd/fsinfo/Makefile deleted file mode 100644 index e5215d4f245..00000000000 --- a/usr.sbin/amd/fsinfo/Makefile +++ /dev/null @@ -1,44 +0,0 @@ -# ex:ts=8 -# -# Makefile for amd -# This file is under a "BSD" copyright (c) by David O'Brien 1998 -# - -.PATH: ${SRCTOP}/contrib/amd/fsinfo - -PROG= fsinfo -MAN= fsinfo.8 -SRCS= fsi_analyze.c fsi_dict.c fsi_util.c fsinfo.c -SRCS+= wr_atab.c wr_bparam.c wr_dumpset.c wr_exportfs.c wr_fstab.c - -CFLAGS+= -I${SRCTOP}/contrib/amd/fsinfo \ - -I${SRCTOP}/contrib/amd/inculde - -LIBADD= amu - -SRCS+= fsi_gram.c fsi_gram.h fsi_lex.c -SRCS+= null_gram.c null_gram.h null_lex.c -CLEANFILES+= fsi_gram.c fsi_gram.h fsi_lex.c -CLEANFILES+= null_gram.c null_gram.h null_lex.c - -fsi_lex.c: fsi_lex.l - ${LEX} ${LFLAGS} -Pfsi_ -o${.TARGET} ${.ALLSRC} - -.ORDER: fsi_gram.c fsi_gram.h -fsi_gram.h: .NOMETA -fsi_gram.c fsi_gram.h: fsi_gram.y - ${YACC} ${YFLAGS} -pfsi_ -ofsi_gram.c ${.ALLSRC} - -null_lex.c: null_lex.l - ${LEX} ${LFLAGS} -Pnull_ -o${.TARGET} ${.ALLSRC} - -.ORDER: null_gram.c null_gram.h -null_gram.h: .NOMETA -null_gram.c null_gram.h: null_gram.y - ${YACC} ${YFLAGS} -pnull_ -onull_gram.c ${.ALLSRC} - -fsi_lex.o: fsi_gram.h - -null_gram.o: null_gram.h - -.include diff --git a/usr.sbin/amd/fsinfo/Makefile.depend b/usr.sbin/amd/fsinfo/Makefile.depend deleted file mode 100644 index 9a9a5566f55..00000000000 --- a/usr.sbin/amd/fsinfo/Makefile.depend +++ /dev/null @@ -1,22 +0,0 @@ -# Autogenerated - do NOT edit! - -DIRDEPS = \ - gnu/lib/csu \ - include \ - include/arpa \ - include/rpc \ - include/rpcsvc \ - include/xlocale \ - lib/${CSU_DIR} \ - lib/libc \ - lib/libcompiler_rt \ - usr.bin/yacc.host \ - usr.sbin/amd/include \ - usr.sbin/amd/libamu \ - - -.include - -.if ${DEP_RELDIR} == ${_DEP_RELDIR} -# local dependencies - needed for -jN in clean tree -.endif diff --git a/usr.sbin/amd/hlfsd/Makefile b/usr.sbin/amd/hlfsd/Makefile deleted file mode 100644 index 47d8d2fce23..00000000000 --- a/usr.sbin/amd/hlfsd/Makefile +++ /dev/null @@ -1,17 +0,0 @@ -# ex:ts=8 -# -# Makefile for amd -# This file is under a "BSD" copyright (c) by David O'Brien 1998 -# - -.PATH: ${SRCTOP}/contrib/amd/hlfsd - -PROG= hlfsd -MAN= hlfsd.8 -SRCS= hlfsd.c homedir.c nfs_prot_svc.c stubs.c - -CFLAGS+= -I${SRCTOP}/contrib/amd/hlfsd - -LIBADD= amu - -.include diff --git a/usr.sbin/amd/hlfsd/Makefile.depend b/usr.sbin/amd/hlfsd/Makefile.depend deleted file mode 100644 index bcad3fbca4b..00000000000 --- a/usr.sbin/amd/hlfsd/Makefile.depend +++ /dev/null @@ -1,21 +0,0 @@ -# Autogenerated - do NOT edit! - -DIRDEPS = \ - gnu/lib/csu \ - include \ - include/arpa \ - include/rpc \ - include/rpcsvc \ - include/xlocale \ - lib/${CSU_DIR} \ - lib/libc \ - lib/libcompiler_rt \ - usr.sbin/amd/include \ - usr.sbin/amd/libamu \ - - -.include - -.if ${DEP_RELDIR} == ${_DEP_RELDIR} -# local dependencies - needed for -jN in clean tree -.endif diff --git a/usr.sbin/amd/include/Makefile b/usr.sbin/amd/include/Makefile deleted file mode 100644 index a7ffe2f6889..00000000000 --- a/usr.sbin/amd/include/Makefile +++ /dev/null @@ -1,28 +0,0 @@ -# ex:ts=8 -# -# -# Makefile for amd -# This file is under a "BSD" copyright (c) by David O'Brien 1998. -# Portions derived from amd/libamu/Makefile -# $NetBSD: Makefile,v 1.8 1998/08/08 22:33:37 christos Exp $ - -.include - -SRCS= config_local.h -.if ${MK_NIS} == "no" -SRCS+= localconfig.h -.endif -CLEANFILES= ${SRCS} - -all depend: ${SRCS} - -config_local.h: newvers.sh ${SRCTOP}/sys/conf/newvers.sh - @rm -f ${.TARGET} - sh ${.ALLSRC} > ${.TARGET} - -localconfig.h: - @rm -f ${.TARGET} - @echo "/* NIS disabled by WITHOUT_NIS src.conf option */" >> ${.TARGET} - @echo "#undef HAVE_MAP_NIS" >> ${.TARGET} - -.include diff --git a/usr.sbin/amd/include/Makefile.depend b/usr.sbin/amd/include/Makefile.depend deleted file mode 100644 index 11aba52f82c..00000000000 --- a/usr.sbin/amd/include/Makefile.depend +++ /dev/null @@ -1,10 +0,0 @@ -# Autogenerated - do NOT edit! - -DIRDEPS = \ - - -.include - -.if ${DEP_RELDIR} == ${_DEP_RELDIR} -# local dependencies - needed for -jN in clean tree -.endif diff --git a/usr.sbin/amd/include/amu_autofs_prot.h b/usr.sbin/amd/include/amu_autofs_prot.h deleted file mode 100644 index 2f6faa5e613..00000000000 --- a/usr.sbin/amd/include/amu_autofs_prot.h +++ /dev/null @@ -1,7 +0,0 @@ - -/* Adjust once we have some form of Autofs support. */ - -#if 0 -#include "conf/autofs/autofs_default.h" -#endif - diff --git a/usr.sbin/amd/include/amu_nfs_prot.h b/usr.sbin/amd/include/amu_nfs_prot.h deleted file mode 100644 index 8e8856ff5c0..00000000000 --- a/usr.sbin/amd/include/amu_nfs_prot.h +++ /dev/null @@ -1 +0,0 @@ -#include "conf/nfs_prot/nfs_prot_freebsd3.h" diff --git a/usr.sbin/amd/include/aux_conf.h b/usr.sbin/amd/include/aux_conf.h deleted file mode 100644 index dc9494c0bd6..00000000000 --- a/usr.sbin/amd/include/aux_conf.h +++ /dev/null @@ -1,71 +0,0 @@ - -/* - * aux_conf.h: - * This file gets "filled in" for each architecture. - * aux_conf.h. Generated from aux_conf.h.in by configure. - */ - -#ifndef _AUX_CONF_H -#define _AUX_CONF_H - -/* - * The next line is a literal inclusion of a file which includes a - * definition for the MOUNT_TRAP macro for a particular architecture. - * If it defines the wrong entry, check the AC_CHECK_MOUNT_TRAP m4 macro - * in $srcdir/m4/macros. - */ - -/* $srcdir/conf/trap/trap_default.h */ -#define MOUNT_TRAP(type, mnt, flags, mnt_data) mount(type, mnt->mnt_dir, flags, mnt_data) -/* End of included MOUNT_TRAP macro definition file */ - -/* - * The next line is a literal replacement of a variable which defines the - * the UNMOUNT_TRAP macro for a particular architecture. - * If it defines the wrong entry, check the AC_CHECK_UNMOUNT_CALL m4 macro - * in $srcdir/aclocal.m4. If the arguments are being defined wrong, check - * the macro AC_CHECK_UNMOUNT_ARGS in $srcdir/m4/macros. - */ -#define UNMOUNT_TRAP(mnt) unmount(mnt->mnt_dir) -/* End of replaced UNMOUNT_TRAP macro definition */ -/* umount(8) executable path, for type:=program */ -#define UNMOUNT_PROGRAM "/sbin/umount" - -/* - * The next line is a literal inclusion of a file which includes a - * definition for the NFS_FH_DREF macro for a particular architecture. - * If it defines the wrong entry, check the AC_CHECK_NFS_FH_DREF m4 macro - * in $srcdir/m4/macros. - */ - -/* $srcdir/conf/fh_dref/fh_dref_freebsd22.h */ -#define NFS_FH_DREF(dst, src) (dst) = (u_char *) (src) -/* End of included NFS_FH_DREF macro definition file */ - -/* - * The next line is a literal inclusion of a file which includes a - * definition for the NFS_SA_DREF macro for a particular architecture. - * If it defines the wrong entry, check the AC_CHECK_NFS_SA_DREF m4 macro - * in $srcdir/m4/macros. - */ - -/* $srcdir/conf/sa_dref/sa_dref_bsd44.h */ -#define NFS_SA_DREF(dst, src) { \ - (dst)->addr = (struct sockaddr *) (src); \ - (dst)->addrlen = sizeof(*src); \ - } -#define NFS_ARGS_T_ADDR_IS_POINTER 1 -/* End of included NFS_SA_DREF macro definition file */ - -/* - * The next line is a literal inclusion of a file which includes a - * definition for the NFS_HN_DREF macro for a particular architecture. - * If it defines the wrong entry, check the AC_CHECK_NFS_HN_DREF m4 macro - * in $srcdir/m4/macros. - */ - -/* $srcdir/conf/hn_dref/hn_dref_default.h */ -#define NFS_HN_DREF(dst, src) (dst) = (src) -/* End of included NFS_HN_DREF macro definition file */ - -#endif /* not _AUX_CONF_H */ diff --git a/usr.sbin/amd/include/build_version.h b/usr.sbin/amd/include/build_version.h deleted file mode 100644 index 804d0db234f..00000000000 --- a/usr.sbin/amd/include/build_version.h +++ /dev/null @@ -1,7 +0,0 @@ - -#include -/*#define AMU_BUILD_VERSION 1 */ -#define AMU_BUILD_VERSION __FreeBSD_version -#define USER_NAME "David O'Brien " -#define CONFIG_DATE "4-December-2007 PST" diff --git a/usr.sbin/amd/include/config.h b/usr.sbin/amd/include/config.h deleted file mode 100644 index 48b05fe0d9d..00000000000 --- a/usr.sbin/amd/include/config.h +++ /dev/null @@ -1,2442 +0,0 @@ -/* - * - * portions derived from - * $NetBSD: config.h,v 1.11 1998/08/08 22:33:37 christos Exp $ - * - * Additional portions derived from ports/sysutils/am-utils r416941 - * make configure config.h output. - */ - -#ifndef _CONFIG_H -#define _CONFIG_H - -/* We [FREEBSD-NATIVE] pick some parameters from our local config file */ -#include "config_local.h" - -/* Define if building universal (internal helper macro) */ -/* #undef AC_APPLE_UNIVERSAL_BUILD */ - -/* define name of am-utils' NFS protocol header */ -#define AMU_NFS_PROTOCOL_HEADER "./conf/nfs_prot/nfs_prot_freebsd3.h" - -/* Type of the 5rd argument to authunix_create() */ -#define AUTH_CREATE_GIDLIST_TYPE gid_t - -/* Define configuration date */ -/* #define CONFIG_DATE "Mon Oct 3 21:58:39 PDT 2016" */ - -/* Turn off general debugging by default */ -/* #undef DEBUG */ - -/* Turn off memory debugging by default */ -/* #undef DEBUG_MEM */ - -/* Define name of host OS's distribution name (eg. debian, redhat, suse, etc.) - */ -#define DISTRO_NAME "The FreeBSD Project" - -/* Define to the type of elements in the array set by `getgroups'. Usually - this is either `int' or `gid_t'. */ -#define GETGROUPS_T gid_t - -/* Define to 1 if the `getpgrp' function requires zero arguments. */ -#define GETPGRP_VOID 1 - -/* Define if have automount filesystem */ -#define HAVE_AMU_FS_AUTO 1 - -/* Define if have direct automount filesystem */ -#define HAVE_AMU_FS_DIRECT 1 - -/* Define if have error filesystem */ -#define HAVE_AMU_FS_ERROR 1 - -/* Define if have NFS host-tree filesystem */ -#define HAVE_AMU_FS_HOST 1 - -/* Define if have symbolic-link filesystem */ -#define HAVE_AMU_FS_LINK 1 - -/* Define if have symlink with existence check filesystem */ -#define HAVE_AMU_FS_LINKX 1 - -/* Define if have nfsl (NFS with local link check) filesystem */ -#define HAVE_AMU_FS_NFSL 1 - -/* Define if have multi-NFS filesystem */ -#define HAVE_AMU_FS_NFSX 1 - -/* Define if have program filesystem */ -#define HAVE_AMU_FS_PROGRAM 1 - -/* Define if have "top-level" filesystem */ -#define HAVE_AMU_FS_TOPLVL 1 - -/* Define if have union filesystem */ -#define HAVE_AMU_FS_UNION 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_ARPA_INET_H 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_ARPA_NAMESER_H 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_ASSERT_H 1 - -/* Define to 1 if `addr' is member of `autofs_args_t'. */ -/* #undef HAVE_AUTOFS_ARGS_T_ADDR */ - -/* define if have a bad version of hasmntopt() */ -/* #undef HAVE_BAD_HASMNTOPT */ - -/* define if have a bad version of memcmp() */ -/* #undef HAVE_BAD_MEMCMP */ - -/* define if have a bad version of yp_all() */ -/* #undef HAVE_BAD_YP_ALL */ - -/* Define to 1 if you have the `bcmp' function. */ -#define HAVE_BCMP 1 - -/* Define to 1 if you have the `bcopy' function. */ -#define HAVE_BCOPY 1 - -/* Define to 1 if you have the header file. */ -/* #undef HAVE_BSD_RPC_RPC_H */ - -/* Define to 1 if you have the `bzero' function. */ -#define HAVE_BZERO 1 - -/* System supports C99-style variable-length argument macros */ -#define HAVE_C99_VARARGS_MACROS 1 - -/* Define to 1 if `flags' is member of `cdfs_args_t'. */ -#define HAVE_CDFS_ARGS_T_FLAGS 1 - -/* Define to 1 if `fspec' is member of `cdfs_args_t'. */ -#define HAVE_CDFS_ARGS_T_FSPEC 1 - -/* Define to 1 if `iso_flags' is member of `cdfs_args_t'. */ -/* #undef HAVE_CDFS_ARGS_T_ISO_FLAGS */ - -/* Define to 1 if `iso_pgthresh' is member of `cdfs_args_t'. */ -/* #undef HAVE_CDFS_ARGS_T_ISO_PGTHRESH */ - -/* Define to 1 if `norrip' is member of `cdfs_args_t'. */ -/* #undef HAVE_CDFS_ARGS_T_NORRIP */ - -/* Define to 1 if `ssector' is member of `cdfs_args_t'. */ -#define HAVE_CDFS_ARGS_T_SSECTOR 1 - -/* Define to 1 if you have the header file. */ -/* #undef HAVE_CDFS_CDFSMOUNT_H */ - -/* Define to 1 if you have the header file. */ -/* #undef HAVE_CDFS_CDFS_MOUNT_H */ - -/* Define to 1 if you have the `clnt_create' function. */ -#define HAVE_CLNT_CREATE 1 - -/* Define to 1 if you have the `clnt_create_vers' function. */ -#define HAVE_CLNT_CREATE_VERS 1 - -/* Define to 1 if you have the `clnt_create_vers_timed' function. */ -#define HAVE_CLNT_CREATE_VERS_TIMED 1 - -/* Define to 1 if you have the `clnt_spcreateerror' function. */ -#define HAVE_CLNT_SPCREATEERROR 1 - -/* Define to 1 if you have the `clnt_sperrno' function. */ -#define HAVE_CLNT_SPERRNO 1 - -/* Define to 1 if you have the `clock_gettime' function. */ -#define HAVE_CLOCK_GETTIME 1 - -/* Define to 1 if you have the header file. */ -/* #undef HAVE_CLUSTER_H */ - -/* Define to 1 if you have the `cnodeid' function. */ -/* #undef HAVE_CNODEID */ - -/* Define to 1 if you have the header file. */ -#define HAVE_CTYPE_H 1 - -/* Define to 1 if you have the header file. */ -/* #undef HAVE_DB1_NDBM_H */ - -/* Define to 1 if you have the `dbm_open' function. */ -#define HAVE_DBM_OPEN 1 - -/* Define to 1 if you have the `dg_mount' function. */ -/* #undef HAVE_DG_MOUNT */ - -/* Define to 1 if you have the header file, and it defines `DIR'. - */ -#define HAVE_DIRENT_H 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_DLFCN_H 1 - -/* Define to 1 if `flags' is member of `efs_args_t'. */ -/* #undef HAVE_EFS_ARGS_T_FLAGS */ - -/* Define to 1 if `version' is member of `efs_args_t'. */ -/* #undef HAVE_EFS_ARGS_T_VERSION */ - -/* Define to 1 if `fspec' is member of `efs_args_t'. */ -/* #undef HAVE_EFS_ARGS_T_FSPEC */ - -/* Define to 1 if `version' is member of `efs_args_t'. */ -/* #undef HAVE_EFS_ARGS_T_VERSION */ - -/* Define to 1 if you have the header file. */ -#define HAVE_ERRNO_H 1 - -/* does extern definition for clnt_spcreateerror() exist? */ -#define HAVE_EXTERN_CLNT_SPCREATEERROR 1 - -/* does extern definition for clnt_sperrno() exist? */ -#define HAVE_EXTERN_CLNT_SPERRNO 1 - -/* does extern definition for free() exist? */ -#define HAVE_EXTERN_FREE 1 - -/* does extern definition for getccent() (hpux) exist? */ -/* #undef HAVE_EXTERN_GETCCENT */ - -/* does extern definition for getdomainname() exist? */ -#define HAVE_EXTERN_GETDOMAINNAME 1 - -/* does extern definition for getdtablesize() exist? */ -#define HAVE_EXTERN_GETDTABLESIZE 1 - -/* does extern definition for gethostname() exist? */ -#define HAVE_EXTERN_GETHOSTNAME 1 - -/* does extern definition for getlogin() exist? */ -#define HAVE_EXTERN_GETLOGIN 1 - -/* does extern definition for getpagesize() exist? */ -#define HAVE_EXTERN_GETPAGESIZE 1 - -/* does extern definition for gettablesize() exist? */ -/* #undef HAVE_EXTERN_GETTABLESIZE */ - -/* does extern definition for getwd() exist? */ -#define HAVE_EXTERN_GETWD 1 - -/* does extern definition for get_myaddress() exist? */ -#define HAVE_EXTERN_GET_MYADDRESS 1 - -/* does extern definition for hosts_ctl() exist? */ -/* #undef HAVE_EXTERN_HOSTS_CTL */ - -/* does extern definition for innetgr() exist? */ -#define HAVE_EXTERN_INNETGR 1 - -/* does extern definition for ldap_enable_cache() exist? */ -/* #undef HAVE_EXTERN_LDAP_ENABLE_CACHE */ - -/* does extern definition for mkstemp() exist? */ -#define HAVE_EXTERN_MKSTEMP 1 - -/* does extern definition for mntctl() exist? */ -/* #undef HAVE_EXTERN_MNTCTL */ - -/* does extern definition for optarg exist? */ -#define HAVE_EXTERN_OPTARG 1 - -/* does extern definition for sbrk() exist? */ -#define HAVE_EXTERN_SBRK 1 - -/* does extern definition for seteuid() exist? */ -#define HAVE_EXTERN_SETEUID 1 - -/* does extern definition for setitimer() exist? */ -#define HAVE_EXTERN_SETITIMER 1 - -/* does extern definition for sleep() exist? */ -#define HAVE_EXTERN_SLEEP 1 - -/* does extern definition for strcasecmp() exist? */ -#define HAVE_EXTERN_STRCASECMP 1 - -/* does extern definition for strdup() exist? */ -#define HAVE_EXTERN_STRDUP 1 - -/* does extern definition for strlcat() exist? */ -#define HAVE_EXTERN_STRLCAT 1 - -/* does extern definition for strlcpy() exist? */ -#define HAVE_EXTERN_STRLCPY 1 - -/* does extern definition for strstr() exist? */ -#define HAVE_EXTERN_STRSTR 1 - -/* does extern definition for sys_errlist[] exist? */ -#define HAVE_EXTERN_SYS_ERRLIST 1 - -/* does extern definition for ualarm() exist? */ -#define HAVE_EXTERN_UALARM 1 - -/* does extern definition for usleep() exist? */ -#define HAVE_EXTERN_USLEEP 1 - -/* does extern definition for vsnprintf() exist? */ -#define HAVE_EXTERN_VSNPRINTF 1 - -/* does extern definition for wait3() exist? */ -#define HAVE_EXTERN_WAIT3 1 - -/* does extern definition for xdr_callmsg() exist? */ -#define HAVE_EXTERN_XDR_CALLMSG 1 - -/* does extern definition for xdr_opaque_auth() exist? */ -#define HAVE_EXTERN_XDR_OPAQUE_AUTH 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_FCNTL_H 1 - -/* Define to 1 if `fds_bits' is member of `fd_set'. */ -#define HAVE_FD_SET_FDS_BITS 1 - -/* Define to 1 if you have the `fgets' function. */ -#define HAVE_FGETS 1 - -/* Define if plain fhandle type exists */ -#define HAVE_FHANDLE 1 - -/* Define to 1 if you have the `flock' function. */ -#define HAVE_FLOCK 1 - -/* Define to 1 if you have the `fork' function. */ -#define HAVE_FORK 1 - -/* Define to 1 if you have the `fsmount' function. */ -/* #undef HAVE_FSMOUNT */ - -/* Define if have AUTOFS filesystem */ -/* #undef HAVE_FS_AUTOFS */ - -/* Define if have CACHEFS filesystem */ -/* #undef HAVE_FS_CACHEFS */ - -/* Define if have CDFS filesystem */ -#define HAVE_FS_CDFS 1 - -/* Define if have CFS (crypto) filesystem */ -/* #undef HAVE_FS_CFS */ - -/* Define if have EFS filesystem (irix) */ -/* #undef HAVE_FS_EFS */ - -/* Define to 1 if you have the header file. */ -/* #undef HAVE_FS_EFS_EFS_MOUNT_H */ - -/* Define if have EXT{2,3,4} filesystem (linux) */ -/* #undef HAVE_FS_EXT */ - -/* Define if have FFS filesystem */ -/* #undef HAVE_FS_FFS */ - -/* Define if have HSFS filesystem */ -/* #undef HAVE_FS_HSFS */ - -/* Define if have LOFS filesystem */ -/* #undef HAVE_FS_LOFS */ - -/* Define if have LUSTRE filesystem */ -/* #undef HAVE_FS_LUSTRE */ - -/* Define if have MFS filesystem */ -#define HAVE_FS_MFS 1 - -/* Define to 1 if you have the header file. */ -/* #undef HAVE_FS_MSDOSFS_MSDOSFSMOUNT_H */ - -/* Define if have NFS filesystem */ -#define HAVE_FS_NFS 1 - -/* Define if have NFS3 filesystem */ -#define HAVE_FS_NFS3 1 - -/* Define if have NFS4 filesystem */ -/* #undef HAVE_FS_NFS4 */ - -/* Define if have NULLFS (loopback on bsd44) filesystem */ -#define HAVE_FS_NULLFS 1 - -/* Define if have PCFS filesystem */ -#define HAVE_FS_PCFS 1 - -/* Define if have TFS filesystem */ -/* #undef HAVE_FS_TFS */ - -/* Define if have TMPFS filesystem */ -#define HAVE_FS_TMPFS 1 - -/* Define to 1 if you have the header file. */ -/* #undef HAVE_FS_TMPFS_TMPFS_ARGS_H */ - -/* Define if have UDF filesystem */ -#define HAVE_FS_UDF 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_FS_UDF_UDF_MOUNT_H 1 - -/* Define if have UFS filesystem */ -#define HAVE_FS_UFS 1 - -/* Define if have UMAPFS (uid/gid mapping) filesystem */ -/* #undef HAVE_FS_UMAPFS */ - -/* Define if have UNIONFS filesystem */ -#define HAVE_FS_UNIONFS 1 - -/* Define if have XFS filesystem (irix) */ -/* #undef HAVE_FS_XFS */ - -/* System supports GCC-style variable-length argument macros */ -/* #undef HAVE_GCC_VARARGS_MACROS */ - -/* Define to 1 if you have the header file. */ -/* #undef HAVE_GDBM_NDBM_H */ - -/* Define to 1 if you have the `getccent' function. */ -/* #undef HAVE_GETCCENT */ - -/* Define to 1 if you have the `getcwd' function. */ -#define HAVE_GETCWD 1 - -/* Define to 1 if you have the `getdomainname' function. */ -#define HAVE_GETDOMAINNAME 1 - -/* Define to 1 if you have the `getdtablesize' function. */ -#define HAVE_GETDTABLESIZE 1 - -/* Define to 1 if you have the `gethostname' function. */ -#define HAVE_GETHOSTNAME 1 - -/* Define to 1 if you have the `getifaddrs' function. */ -#define HAVE_GETIFADDRS 1 - -/* Define to 1 if you have the `getmntinfo' function. */ -#define HAVE_GETMNTINFO 1 - -/* Define to 1 if you have the `getmountent' function. */ -/* #undef HAVE_GETMOUNTENT */ - -/* Define to 1 if you have the `getpagesize' function. */ -#define HAVE_GETPAGESIZE 1 - -/* Define to 1 if you have the `getpwnam' function. */ -#define HAVE_GETPWNAM 1 - -/* Define to 1 if you have the `gettimeofday' function. */ -#define HAVE_GETTIMEOFDAY 1 - -/* Define to 1 if you have the `get_myaddress' function. */ -#define HAVE_GET_MYADDRESS 1 - -/* define if your system's getopt() is GNU getopt() (are you using glibc) */ -/* #undef HAVE_GNU_GETOPT */ - -/* Define to 1 if you have the header file. */ -#define HAVE_GRP_H 1 - -/* Define to 1 if you have the `hasmntopt' function. */ -/* #undef HAVE_HASMNTOPT */ - -#ifdef YES_HESIOD -/* Define to 1 if you have the header file. */ -#define HAVE_HESIOD_H 1 - -/* Define to 1 if you have the `hesiod_init' function. */ -#define HAVE_HESIOD_INIT 1 - -/* Define to 1 if you have the `hesiod_reload' function. */ -/* #undef HAVE_HESIOD_RELOAD */ - -/* Define to 1 if you have the `hesiod_to_bind' function. */ -#define HAVE_HESIOD_TO_BIND 1 - -/* Define to 1 if you have the `hes_init' function. */ -#define HAVE_HES_INIT 1 -#else -#undef HAVE_HESIOD_H -#undef HAVE_HESIOD_INIT -#undef HAVE_HESIOD_RELOAD -#undef HAVE_HESIOD_TO_BIND -#undef HAVE_HES_INIT -#endif - -/* Define to 1 if you have the header file. */ -/* #undef HAVE_HSFS_HSFS_H */ - -/* Define to 1 if you have the `hstrerror' function. */ -#define HAVE_HSTRERROR 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_IFADDRS_H 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_INTTYPES_H 1 - -/* Define to 1 if you have the header file. */ -/* #undef HAVE_IRS_H */ - -/* Define to 1 if you have the header file. */ -#define HAVE_ISOFS_CD9660_CD9660_MOUNT_H 1 - -/* Define to 1 if you have the header file. */ -/* #undef HAVE_LBER_H */ - -/* Define to 1 if you have the `ldap_enable_cache' function. */ -/* #undef HAVE_LDAP_ENABLE_CACHE */ - -/* Define to 1 if you have the header file. */ -/* #undef HAVE_LDAP_H */ - -/* Define to 1 if you have the `ldap_open' function. */ -/* #undef HAVE_LDAP_OPEN */ - -/* Define to 1 if you have the header file. */ -#define HAVE_LIBGEN_H 1 - -/* Define to 1 if you have the `malloc' library (-lmalloc). */ -/* #undef HAVE_LIBMALLOC */ - -/* Define to 1 if you have the `mapmalloc' library (-lmapmalloc). */ -/* #undef HAVE_LIBMAPMALLOC */ - -/* Define to 1 if you have the `nsl' library (-lnsl). */ -/* #undef HAVE_LIBNSL */ - -/* Define to 1 if you have the `posix4' library (-lposix4). */ -/* #undef HAVE_LIBPOSIX4 */ - -/* Define to 1 if you have the `resolv' library (-lresolv). */ -/* #undef HAVE_LIBRESOLV */ - -/* Define to 1 if you have the `rpc' library (-lrpc). */ -/* #undef HAVE_LIBRPC */ - -/* Define to 1 if you have the `rpcsvc' library (-lrpcsvc). */ -#define HAVE_LIBRPCSVC 1 - -/* Define to 1 if you have the `rt' library (-lrt). */ -/* #undef HAVE_LIBRT */ - -/* does libwrap exist? */ -/* #undef HAVE_LIBWRAP */ - -/* Define to 1 if you have the header file. */ -#define HAVE_LIMITS_H 1 - -/* Define to 1 if you have the header file. */ -/* #undef HAVE_LINUX_AUTO_FS4_H */ - -/* Define to 1 if you have the header file. */ -/* #undef HAVE_LINUX_AUTO_FS_H */ - -/* Define to 1 if you have the header file. */ -/* #undef HAVE_LINUX_FS_H */ - -/* Define to 1 if you have the header file. */ -/* #undef HAVE_LINUX_KDEV_T_H */ - -/* Define to 1 if you have the header file. */ -/* #undef HAVE_LINUX_LIST_H */ - -/* Define to 1 if you have the header file. */ -/* #undef HAVE_LINUX_LOOP_H */ - -/* Define to 1 if you have the header file. */ -/* #undef HAVE_LINUX_NFS2_H */ - -/* Define to 1 if you have the header file. */ -/* #undef HAVE_LINUX_NFS4_H */ - -/* Define to 1 if you have the header file. */ -/* #undef HAVE_LINUX_NFS_H */ - -/* Define to 1 if you have the header file. */ -/* #undef HAVE_LINUX_NFS_MOUNT_H */ - -/* Define to 1 if you have the header file. */ -/* #undef HAVE_LINUX_POSIX_TYPES_H */ - -/* Define to 1 if you have the header file. */ -/* #undef HAVE_LINUX_SOCKET_H */ - -/* Define to 1 if you support file names longer than 14 characters. */ -#define HAVE_LONG_FILE_NAMES 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_MACHINE_ENDIAN_H 1 - -/* Define to 1 if you have the `madvise' function. */ -#define HAVE_MADVISE 1 - -/* Define to 1 if you have the header file. */ -/* #undef HAVE_MALLOC_H */ - -/* Define if have DBM maps */ -/* #undef HAVE_MAP_DBM */ - -/* Define if have executable maps */ -#define HAVE_MAP_EXEC 1 - -/* Define if have file maps (everyone should have it!) */ -#define HAVE_MAP_FILE 1 - -#ifdef YES_HESIOD -/* Define if have HESIOD maps */ -#define HAVE_MAP_HESIOD 1 -#else -#undef HAVE_MAP_HESIOD -#endif - -/* Define if have LDAP maps */ -/* #undef HAVE_MAP_LDAP */ - -/* Define if have NDBM maps */ -#define HAVE_MAP_NDBM 1 - -/* Define if have NIS maps */ -#define HAVE_MAP_NIS 1 - -/* Define if have NIS+ maps */ -/* #undef HAVE_MAP_NISPLUS */ - -/* Define if have PASSWD maps */ -#define HAVE_MAP_PASSWD 1 - -/* Define if have Sun-syntax maps */ -#define HAVE_MAP_SUN 1 - -/* Define if have UNION maps */ -#define HAVE_MAP_UNION 1 - -/* Define to 1 if you have the `memcmp' function. */ -#define HAVE_MEMCMP 1 - -/* Define to 1 if you have the `memcpy' function. */ -#define HAVE_MEMCPY 1 - -/* Define to 1 if you have the `memmove' function. */ -#define HAVE_MEMMOVE 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_MEMORY_H 1 - -/* Define to 1 if you have the `memset' function. */ -#define HAVE_MEMSET 1 - -/* Define to 1 if you have the `mkdir' function. */ -#define HAVE_MKDIR 1 - -/* Define to 1 if you have the `mkstemp' function. */ -#define HAVE_MKSTEMP 1 - -/* Define to 1 if you have the `mlockall' function. */ -#define HAVE_MLOCKALL 1 - -/* Define to 1 if you have the `mntctl' function. */ -/* #undef HAVE_MNTCTL */ - -/* Define to 1 if you have the header file. */ -/* #undef HAVE_MNTENT_H */ - -/* Define to 1 if `mnt_cnode' is member of `mntent_t'. */ -/* #undef HAVE_MNTENT_T_MNT_CNODE */ - -/* Define to 1 if `mnt_ro' is member of `mntent_t'. */ -/* #undef HAVE_MNTENT_T_MNT_RO */ - -/* Define to 1 if `mnt_time' is member of `mntent_t'. */ -/* #undef HAVE_MNTENT_T_MNT_TIME */ - -/* does mntent_t have mnt_time field and is of type "char *" ? */ -/* #undef HAVE_MNTENT_T_MNT_TIME_STRING */ - -/* Define to 1 if you have the header file. */ -/* #undef HAVE_MNTTAB_H */ - -/* Define to 1 if you have the `mount' function. */ -#define HAVE_MOUNT 1 - -/* Define to 1 if `optptr' is member of `mounta'. */ -/* #undef HAVE_MOUNTA_OPTPTR */ - -/* Define to 1 if you have the `mountsyscall' function. */ -/* #undef HAVE_MOUNTSYSCALL */ - -/* Define to 1 if you have the header file. */ -/* #undef HAVE_MOUNT_H */ - -/* Define to 1 if you have the header file. */ -/* #undef HAVE_MSDOSFS_MSDOSFSMOUNT_H */ - -/* Define to 1 if you have the header file. */ -#define HAVE_FS_MSDOSFS_MSDOSFSMOUNT_H 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_NDBM_H 1 - -/* Define to 1 if you have the header file. */ -/* #undef HAVE_NDIR_H */ - -/* Define to 1 if you have the header file. */ -#define HAVE_NETCONFIG_H 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_NETDB_H 1 - -/* Define to 1 if you have the header file. */ -/* #undef HAVE_NETDIR_H */ - -/* Define to 1 if you have the header file. */ -#define HAVE_NETINET_IF_ETHER_H 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_NETINET_IN_H 1 - -/* Define to 1 if you have the header file. */ -/* #undef HAVE_NET_ERRNO_H */ - -/* Define to 1 if you have the header file. */ -#define HAVE_NET_IF_H 1 - -/* Define to 1 if you have the header file. */ -/* #undef HAVE_NET_IF_VAR_H */ - -/* Define to 1 if you have the header file. */ -#define HAVE_NET_ROUTE_H 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_NFSCLIENT_NFSARGS_H 1 - -/* Define to 1 if `acdirmax' is member of `nfs_args_t'. */ -#define HAVE_NFS_ARGS_T_ACDIRMAX 1 - -/* Define to 1 if `acdirmin' is member of `nfs_args_t'. */ -#define HAVE_NFS_ARGS_T_ACDIRMIN 1 - -/* Define to 1 if `acregmax' is member of `nfs_args_t'. */ -#define HAVE_NFS_ARGS_T_ACREGMAX 1 - -/* Define to 1 if `acregmin' is member of `nfs_args_t'. */ -#define HAVE_NFS_ARGS_T_ACREGMIN 1 - -/* Define to 1 if `addrlen' is member of `nfs_args_t'. */ -#define HAVE_NFS_ARGS_T_ADDRLEN 1 - -/* Define to 1 if `bsize' is member of `nfs_args_t'. */ -/* #undef HAVE_NFS_ARGS_T_BSIZE */ - -/* Define to 1 if `context' is member of `nfs_args_t'. */ -/* #undef HAVE_NFS_ARGS_T_CONTEXT */ - -/* Define to 1 if `fhsize' is member of `nfs_args_t'. */ -#define HAVE_NFS_ARGS_T_FHSIZE 1 - -/* Define to 1 if `fh_len' is member of `nfs_args_t'. */ -/* #undef HAVE_NFS_ARGS_T_FH_LEN */ - -/* Define to 1 if `gfs_flags' is member of `nfs_args_t'. */ -/* #undef HAVE_NFS_ARGS_T_GFS_FLAGS */ - -/* Define to 1 if `namlen' is member of `nfs_args_t'. */ -/* #undef HAVE_NFS_ARGS_T_NAMLEN */ - -/* Define to 1 if `optstr' is member of `nfs_args_t'. */ -/* #undef HAVE_NFS_ARGS_T_OPTSTR */ - -/* Define to 1 if `pathconf' is member of `nfs_args_t'. */ -/* #undef HAVE_NFS_ARGS_T_PATHCONF */ - -/* Define to 1 if `proto' is member of `nfs_args_t'. */ -#define HAVE_NFS_ARGS_T_PROTO 1 - -/* Define to 1 if `pseudoflavor' is member of `nfs_args_t'. */ -/* #undef HAVE_NFS_ARGS_T_PSEUDOFLAVOR */ - -/* Define to 1 if `sotype' is member of `nfs_args_t'. */ -#define HAVE_NFS_ARGS_T_SOTYPE 1 - -/* Define to 1 if `version' is member of `nfs_args_t'. */ -#define HAVE_NFS_ARGS_T_VERSION 1 - -/* Define to 1 if you have the header file. */ -/* #undef HAVE_NFS_EXPORT_H */ - -/* Define to 1 if you have the header file. */ -/* #undef HAVE_NFS_MOUNT_H */ - -/* Define to 1 if you have the header file. */ -/* #undef HAVE_NFS_NFSMOUNT_H */ - -/* Define to 1 if you have the header file. */ -#define HAVE_NFS_NFSPROTO_H 1 - -/* Define to 1 if you have the header file. */ -/* #undef HAVE_NFS_NFSV2_H */ - -/* Define to 1 if you have the header file. */ -/* #undef HAVE_NFS_NFS_CLNT_H */ - -/* Define to 1 if you have the header file. */ -/* #undef HAVE_NFS_NFS_GFS_H */ - -/* Define to 1 if you have the header file. */ -/* #undef HAVE_NFS_NFS_H */ - -/* Define to 1 if you have the header file. */ -/* #undef HAVE_NFS_NFS_MOUNT_H */ - -/* Define to 1 if you have the header file. */ -/* #undef HAVE_NFS_PATHCONF_H */ - -/* define if the host has NFS protocol headers in system headers */ -/* #undef HAVE_NFS_PROT_HEADERS */ - -/* Define to 1 if you have the header file. */ -/* #define HAVE_NFS_RPCV2_H 1 */ - -/* Define to 1 if you have the `nis_domain_of' function. */ -/* #undef HAVE_NIS_DOMAIN_OF */ - -/* Define to 1 if you have the header file. */ -#define HAVE_NSSWITCH_H 1 - -/* Define to 1 if you have the `opendir' function. */ -#define HAVE_OPENDIR 1 - -/* Define to 1 if `dsttime' is member of `pcfs_args_t'. */ -/* #undef HAVE_PCFS_ARGS_T_DSTTIME */ - -/* Define to 1 if `fspec' is member of `pcfs_args_t'. */ -#define HAVE_PCFS_ARGS_T_FSPEC 1 - -/* Define to 1 if `gid' is member of `pcfs_args_t'. */ -#define HAVE_PCFS_ARGS_T_GID 1 - -/* Define to 1 if `mask' is member of `pcfs_args_t'. */ -#define HAVE_PCFS_ARGS_T_MASK 1 - -/* Define to 1 if `dirmask' is member of `pcfs_args_t'. */ -#define HAVE_PCFS_ARGS_T_DIRMASK 1 - -/* Define to 1 if `secondswest' is member of `pcfs_args_t'. */ -/* #undef HAVE_PCFS_ARGS_T_SECONDSWEST */ - -/* Define to 1 if `uid' is member of `pcfs_args_t'. */ -#define HAVE_PCFS_ARGS_T_UID 1 - -/* Define to 1 if you have the `plock' function. */ -/* #undef HAVE_PLOCK */ - -/* Define to 1 if you have the header file. */ -#define HAVE_PWD_H 1 - -/* Define to 1 if you have the `regcomp' function. */ -#define HAVE_REGCOMP 1 - -/* Define to 1 if you have the `regexec' function. */ -#define HAVE_REGEXEC 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_REGEX_H 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_RESOLV_H 1 - -/* Define to 1 if system calls automatically restart after interruption by a - signal. */ -#define HAVE_RESTARTABLE_SYSCALLS 1 - -/* Define to 1 if you have the `rmdir' function. */ -#define HAVE_RMDIR 1 - -/* Define to 1 if you have the header file. */ -/* #undef HAVE_RPCSVC_AUTOFS_PROT_H */ - -/* Define to 1 if you have the header file. */ -/* #undef HAVE_RPCSVC_MOUNTV3_H */ - -/* Define to 1 if you have the header file. */ -#define HAVE_RPCSVC_MOUNT_H 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_RPCSVC_NFS_PROT_H 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_RPCSVC_NIS_H 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_RPCSVC_YPCLNT_H 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_RPCSVC_YP_PROT_H 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_RPC_AUTH_DES_H 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_RPC_AUTH_H 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_RPC_PMAP_CLNT_H 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_RPC_PMAP_PROT_H 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_RPC_RPC_H 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_RPC_TYPES_H 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_RPC_XDR_H 1 - -/* Define to 1 if you have the `select' function. */ -#define HAVE_SELECT 1 - -/* Define to 1 if you have the `seteuid' function. */ -#define HAVE_SETEUID 1 - -/* Define to 1 if you have the `setitimer' function. */ -#define HAVE_SETITIMER 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_SETJMP_H 1 - -/* Define to 1 if you have the `setresuid' function. */ -#define HAVE_SETRESUID 1 - -/* Define to 1 if you have the `setsid' function. */ -#define HAVE_SETSID 1 - -/* Define to 1 if you have the `sigaction' function. */ -#define HAVE_SIGACTION 1 - -/* Define to 1 if you have the `signal' function. */ -#define HAVE_SIGNAL 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_SIGNAL_H 1 - -/* Define to 1 if you have the `sigsuspend' function. */ -#define HAVE_SIGSUSPEND 1 - -/* Define to 1 if you have the `socket' function. */ -#define HAVE_SOCKET 1 - -/* Define to 1 if you have the header file. */ -/* #undef HAVE_SOCKETBITS_H */ - -/* Define to 1 if you have the header file. */ -/* #undef HAVE_STATBUF_H */ - -/* Define to 1 if you have the `statfs' function. */ -#define HAVE_STATFS 1 - -/* Define to 1 if you have the `statvfs' function. */ -#define HAVE_STATVFS 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_STDARG_H 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_STDINT_H 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_STDIO_H 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_STDLIB_H 1 - -/* Define to 1 if you have the `strcasecmp' function. */ -#define HAVE_STRCASECMP 1 - -/* Define to 1 if you have the `strchr' function. */ -#define HAVE_STRCHR 1 - -/* Define to 1 if you have the `strcspn' function. */ -#define HAVE_STRCSPN 1 - -/* Define to 1 if you have the `strdup' function. */ -#define HAVE_STRDUP 1 - -/* Define to 1 if you have the `strerror' function. */ -#define HAVE_STRERROR 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_STRINGS_H 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_STRING_H 1 - -/* Define to 1 if you have the `strlcat' function. */ -#define HAVE_STRLCAT 1 - -/* Define to 1 if you have the `strlcpy' function. */ -#define HAVE_STRLCPY 1 - -/* Define to 1 if you have the `strspn' function. */ -#define HAVE_STRSPN 1 - -/* Define to 1 if you have the `strstr' function. */ -#define HAVE_STRSTR 1 - -/* Define to 1 if `fhs_fh' is member of `struct fhstatus'. */ -/* #undef HAVE_STRUCT_FHSTATUS_FHS_FH */ - -/* Define to 1 if `ifa_next' is member of `struct ifaddrs'. */ -#define HAVE_STRUCT_IFADDRS_IFA_NEXT 1 - -/* Define to 1 if `ifr_addr' is member of `struct ifreq'. */ -#define HAVE_STRUCT_IFREQ_IFR_ADDR 1 - -/* Define if have struct mntent in one of the standard headers */ -/* #undef HAVE_STRUCT_MNTENT */ - -/* Define if have struct mnttab in one of the standard headers */ -/* #undef HAVE_STRUCT_MNTTAB */ - -/* Define if have struct nfs_args in one of the standard nfs headers */ -#define HAVE_STRUCT_NFS_ARGS 1 - -/* Define if have struct nfs_gfs_mount in one of the standard nfs headers */ -/* #undef HAVE_STRUCT_NFS_GFS_MOUNT */ - -/* Define to 1 if `sa_len' is member of `struct sockaddr'. */ -#define HAVE_STRUCT_SOCKADDR_SA_LEN 1 - -/* Define to 1 if `f_fstypename' is member of `struct statfs'. */ -#define HAVE_STRUCT_STATFS_F_FSTYPENAME 1 - -/* Define to 1 if `devid' is member of `struct umntrequest'. */ -/* #undef HAVE_STRUCT_UMNTREQUEST_DEVID */ - -/* Define to 1 if you have the `svc_getreq' function. */ -#define HAVE_SVC_GETREQ 1 - -/* Define to 1 if you have the `svc_getreqset' function. */ -#define HAVE_SVC_GETREQSET 1 - -/* Define to 1 if you have the `sysfs' function. */ -/* #undef HAVE_SYSFS */ - -/* Define to 1 if you have the `syslog' function. */ -#define HAVE_SYSLOG 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_SYSLOG_H 1 - -/* Define to 1 if you have the header file. */ -/* #undef HAVE_SYS_CONFIG_H */ - -/* Define to 1 if you have the header file. */ -/* #undef HAVE_SYS_DG_MOUNT_H */ - -/* Define to 1 if you have the header file. */ -#define HAVE_SYS_DIR_H 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_SYS_ERRNO_H 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_SYS_FILE_H 1 - -/* Define to 1 if you have the header file. */ -/* #undef HAVE_SYS_FSID_H */ - -/* Define to 1 if you have the header file. */ -/* #undef HAVE_SYS_FSTYP_H */ - -/* Define to 1 if you have the header file. */ -/* #undef HAVE_SYS_FS_AUTOFS_H */ - -/* Define to 1 if you have the header file. */ -/* #undef HAVE_SYS_FS_AUTOFS_PROT_H */ - -/* Define to 1 if you have the header file. */ -/* #undef HAVE_SYS_FS_CACHEFS_FS_H */ - -/* Define to 1 if you have the header file. */ -/* #undef HAVE_SYS_FS_EFS_CLNT_H */ - -/* Define to 1 if you have the header file. */ -/* #undef HAVE_SYS_FS_NFS_CLNT_H */ - -/* Define to 1 if you have the header file. */ -/* #undef HAVE_SYS_FS_NFS_H */ - -/* Define to 1 if you have the header file. */ -/* #undef HAVE_SYS_FS_NFS_MOUNT_H */ - -/* Define to 1 if you have the header file. */ -/* #undef HAVE_SYS_FS_NFS_NFS_CLNT_H */ - -/* Define to 1 if you have the header file. */ -/* #undef HAVE_SYS_FS_PC_FS_H */ - -/* Define to 1 if you have the header file. */ -/* #undef HAVE_SYS_FS_TMP_H */ - -/* Define to 1 if you have the header file. */ -/* #undef HAVE_SYS_FS_TYPES_H */ - -/* Define to 1 if you have the header file. */ -/* #undef HAVE_SYS_FS_UFS_MOUNT_H */ - -/* Define to 1 if you have the header file. */ -/* #undef HAVE_SYS_FS_XFS_CLNT_H */ - -/* Define to 1 if you have the header file. */ -/* #undef HAVE_SYS_IMMU_H */ - -/* Define to 1 if you have the header file. */ -#define HAVE_SYS_IOCTL_H 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_SYS_LOCK_H 1 - -/* Define to 1 if you have the header file. */ -/* #undef HAVE_SYS_MACHINE_H */ - -/* Define to 1 if you have the header file. */ -#define HAVE_SYS_MBUF_H 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_SYS_MMAN_H 1 - -/* Define to 1 if you have the header file. */ -/* #undef HAVE_SYS_MNTCTL_H */ - -/* Define to 1 if you have the header file. */ -/* #undef HAVE_SYS_MNTENT_H */ - -/* Define to 1 if you have the header file. */ -/* #undef HAVE_SYS_MNTTAB_H */ - -/* Define to 1 if you have the header file. */ -#define HAVE_SYS_MOUNT_H 1 - -/* Define to 1 if you have the header file. */ -/* #undef HAVE_SYS_NDIR_H */ - -/* Define to 1 if you have the header file. */ -/* #undef HAVE_SYS_NETCONFIG_H */ - -/* Define to 1 if you have the header file. */ -#define HAVE_SYS_PARAM_H 1 - -/* Define to 1 if you have the header file. */ -/* #undef HAVE_SYS_PATHCONF_H */ - -/* Define to 1 if you have the header file. */ -#define HAVE_SYS_PROC_H 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_SYS_RESOURCE_H 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_SYS_SEMA_H 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_SYS_SIGNAL_H 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_SYS_SOCKET_H 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_SYS_SOCKIO_H 1 - -/* Define to 1 if you have the header file. */ -/* #undef HAVE_SYS_STATFS_H */ - -/* Define to 1 if you have the header file. */ -#define HAVE_SYS_STATVFS_H 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_SYS_STAT_H 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_SYS_SYSCALL_H 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_SYS_SYSLIMITS_H 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_SYS_SYSLOG_H 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_SYS_TIME_H 1 - -/* Define to 1 if you have the header file. */ -/* #undef HAVE_SYS_TIUSER_H */ - -/* Define to 1 if you have the header file. */ -#define HAVE_SYS_TYPES_H 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_SYS_UCRED_H 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_SYS_UIO_H 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_SYS_UTSNAME_H 1 - -/* Define to 1 if you have the header file. */ -/* #undef HAVE_SYS_VFS_H */ - -/* Define to 1 if you have the header file. */ -/* #undef HAVE_SYS_VMOUNT_H */ - -/* Define to 1 if you have the header file. */ -#define HAVE_SYS_VNODE_H 1 - -/* Define to 1 if you have that is POSIX.1 compatible. */ -#define HAVE_SYS_WAIT_H 1 - -/* Define to 1 if you have the header file. */ -/* #undef HAVE_TCPD_H */ - -/* Define to 1 if you have the header file. */ -#define HAVE_TIME_H 1 - -/* Define to 1 if you have the header file. */ -/* #undef HAVE_TIUSER_H */ - -/* Define to 1 if `ta_nodes_max' is member of `tmpfs_args_t'. */ -/* #undef HAVE_TMPFS_ARGS_T_TA_NODES_MAX */ - -/* Define to 1 if `ta_root_gid' is member of `tmpfs_args_t'. */ -/* #undef HAVE_TMPFS_ARGS_T_TA_ROOT_GID */ - -/* Define to 1 if `ta_root_mode' is member of `tmpfs_args_t'. */ -/* #undef HAVE_TMPFS_ARGS_T_TA_ROOT_MODE */ - -/* Define to 1 if `ta_root_uid' is member of `tmpfs_args_t'. */ -/* #undef HAVE_TMPFS_ARGS_T_TA_ROOT_UID */ - -/* Define to 1 if `ta_size_max' is member of `tmpfs_args_t'. */ -/* #undef HAVE_TMPFS_ARGS_T_TA_SIZE_MAX */ - -/* Define to 1 if `ta_version' is member of `tmpfs_args_t'. */ -/* #undef HAVE_TMPFS_ARGS_T_TA_VERSION */ - -/* Define to 1 if you have the header file. */ -/* #undef HAVE_TMPFS_TMP_H */ - -/* what type of network transport type is in use? TLI or sockets? */ -/* #undef HAVE_TRANSPORT_TYPE_TLI */ - -/* Define to 1 if you have the `ualarm' function. */ -#define HAVE_UALARM 1 - -/* Define to 1 if `anon_gid' is member of `udf_args_t'. */ -/* #undef HAVE_UDF_ARGS_T_ANON_GID */ - -/* Define to 1 if `anon_uid' is member of `udf_args_t'. */ -/* #undef HAVE_UDF_ARGS_T_ANON_UID */ - -/* Define to 1 if `fspec' is member of `udf_args_t'. */ -/* #undef HAVE_UDF_ARGS_T_FSPEC */ - -/* Define to 1 if `gmtoff' is member of `udf_args_t'. */ -/* #undef HAVE_UDF_ARGS_T_GMTOFF */ - -/* Define to 1 if `nobody_gid' is member of `udf_args_t'. */ -/* #undef HAVE_UDF_ARGS_T_NOBODY_GID */ - -/* Define to 1 if `nobody_uid' is member of `udf_args_t'. */ -/* #undef HAVE_UDF_ARGS_T_NOBODY_UID */ - -/* Define to 1 if `sector_size' is member of `udf_args_t'. */ -/* #undef HAVE_UDF_ARGS_T_SECTOR_SIZE */ - -/* Define to 1 if `sessionnr' is member of `udf_args_t'. */ -/* #undef HAVE_UDF_ARGS_T_SESSIONNR */ - -/* Define to 1 if `udfmflags' is member of `udf_args_t'. */ -/* #undef HAVE_UDF_ARGS_T_UDFMFLAGS */ - -/* Define to 1 if `version' is member of `udf_args_t'. */ -/* #undef HAVE_UDF_ARGS_T_VERSION */ - -/* Define to 1 if `flags' is member of `ufs_args_t'. */ -/* #undef HAVE_UFS_ARGS_T_FLAGS */ - -/* Define to 1 if `fspec' is member of `ufs_args_t'. */ -#define HAVE_UFS_ARGS_T_FSPEC 1 - -/* Define to 1 if `ufs_flags' is member of `ufs_args_t'. */ -/* #undef HAVE_UFS_ARGS_T_UFS_FLAGS */ - -/* Define to 1 if `ufs_pgthresh' is member of `ufs_args_t'. */ -/* #undef HAVE_UFS_ARGS_T_UFS_PGTHRESH */ - -/* Define to 1 if you have the header file. */ -#define HAVE_UFS_UFS_EXTATTR_H 1 - -/* Define to 1 if you have the header file. */ -/* #undef HAVE_UFS_UFS_MOUNT_H */ - -/* Define to 1 if you have the header file. */ -#define HAVE_UFS_UFS_UFSMOUNT_H 1 - -/* Define to 1 if you have the `umount' function. */ -/* #undef HAVE_UMOUNT */ - -/* Define to 1 if you have the `umount2' function. */ -/* #undef HAVE_UMOUNT2 */ - -/* Define to 1 if you have the `uname' function. */ -#define HAVE_UNAME 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_UNISTD_H 1 - -/* Define to 1 if you have the `unmount' function. */ -#define HAVE_UNMOUNT 1 - -/* Define to 1 if you have the `uvmount' function. */ -/* #undef HAVE_UVMOUNT */ - -/* Define to 1 if you have the header file. */ -/* #undef HAVE_VARARGS_H */ - -/* Define to 1 if you have the `vfork' function. */ -#define HAVE_VFORK 1 - -/* Define to 1 if you have the header file. */ -/* #undef HAVE_VFORK_H */ - -/* Define to 1 if you have the `vfsmount' function. */ -/* #undef HAVE_VFSMOUNT */ - -/* Define to 1 if you have the `vmount' function. */ -/* #undef HAVE_VMOUNT */ - -/* Define to 1 if you have the `vsnprintf' function. */ -#define HAVE_VSNPRINTF 1 - -/* Define to 1 if you have the `wait3' function. */ -#define HAVE_WAIT3 1 - -/* Define to 1 if you have the `waitpid' function. */ -#define HAVE_WAITPID 1 - -/* Define to 1 if `fork' works. */ -#define HAVE_WORKING_FORK 1 - -/* Define to 1 if `vfork' works. */ -#define HAVE_WORKING_VFORK 1 - -/* Define to 1 if you have the `xdr_attrstat' function. */ -#define HAVE_XDR_ATTRSTAT 1 - -/* Define to 1 if you have the `xdr_createargs' function. */ -#define HAVE_XDR_CREATEARGS 1 - -/* Define to 1 if you have the `xdr_dirlist' function. */ -#define HAVE_XDR_DIRLIST 1 - -/* Define to 1 if you have the `xdr_diropargs' function. */ -#define HAVE_XDR_DIROPARGS 1 - -/* Define to 1 if you have the `xdr_diropokres' function. */ -#define HAVE_XDR_DIROPOKRES 1 - -/* Define to 1 if you have the `xdr_diropres' function. */ -#define HAVE_XDR_DIROPRES 1 - -/* Define to 1 if you have the `xdr_dirpath' function. */ -#define HAVE_XDR_DIRPATH 1 - -/* Define to 1 if you have the `xdr_entry' function. */ -#define HAVE_XDR_ENTRY 1 - -/* Define to 1 if you have the `xdr_exportnode' function. */ -#define HAVE_XDR_EXPORTNODE 1 - -/* Define to 1 if you have the `xdr_exports' function. */ -#define HAVE_XDR_EXPORTS 1 - -/* Define to 1 if you have the `xdr_fattr' function. */ -#define HAVE_XDR_FATTR 1 - -/* Define to 1 if you have the `xdr_fhandle' function. */ -#define HAVE_XDR_FHANDLE 1 - -/* Define to 1 if you have the `xdr_fhstatus' function. */ -#define HAVE_XDR_FHSTATUS 1 - -/* Define to 1 if you have the `xdr_filename' function. */ -#define HAVE_XDR_FILENAME 1 - -/* Define to 1 if you have the `xdr_ftype' function. */ -#define HAVE_XDR_FTYPE 1 - -/* Define to 1 if you have the `xdr_groupnode' function. */ -#define HAVE_XDR_GROUPNODE 1 - -/* Define to 1 if you have the `xdr_groups' function. */ -#define HAVE_XDR_GROUPS 1 - -/* Define to 1 if you have the `xdr_linkargs' function. */ -#define HAVE_XDR_LINKARGS 1 - -/* Define to 1 if you have the `xdr_mountbody' function. */ -#define HAVE_XDR_MOUNTBODY 1 - -/* Define to 1 if you have the `xdr_mountlist' function. */ -#define HAVE_XDR_MOUNTLIST 1 - -/* Define to 1 if you have the `xdr_name' function. */ -#define HAVE_XDR_NAME 1 - -/* Define to 1 if you have the `xdr_nfscookie' function. */ -#define HAVE_XDR_NFSCOOKIE 1 - -/* Define to 1 if you have the `xdr_nfspath' function. */ -#define HAVE_XDR_NFSPATH 1 - -/* Define to 1 if you have the `xdr_nfsstat' function. */ -#define HAVE_XDR_NFSSTAT 1 - -/* Define to 1 if you have the `xdr_nfstime' function. */ -#define HAVE_XDR_NFSTIME 1 - -/* Define to 1 if you have the `xdr_nfs_fh' function. */ -#define HAVE_XDR_NFS_FH 1 - -/* Define to 1 if you have the `xdr_pointer' function. */ -#define HAVE_XDR_POINTER 1 - -/* Define to 1 if you have the `xdr_readargs' function. */ -#define HAVE_XDR_READARGS 1 - -/* Define to 1 if you have the `xdr_readdirargs' function. */ -#define HAVE_XDR_READDIRARGS 1 - -/* Define to 1 if you have the `xdr_readdirres' function. */ -#define HAVE_XDR_READDIRRES 1 - -/* Define to 1 if you have the `xdr_readlinkres' function. */ -#define HAVE_XDR_READLINKRES 1 - -/* Define to 1 if you have the `xdr_readokres' function. */ -#define HAVE_XDR_READOKRES 1 - -/* Define to 1 if you have the `xdr_readres' function. */ -#define HAVE_XDR_READRES 1 - -/* Define to 1 if you have the `xdr_renameargs' function. */ -#define HAVE_XDR_RENAMEARGS 1 - -/* Define to 1 if you have the `xdr_sattr' function. */ -#define HAVE_XDR_SATTR 1 - -/* Define to 1 if you have the `xdr_sattrargs' function. */ -#define HAVE_XDR_SATTRARGS 1 - -/* Define to 1 if you have the `xdr_statfsokres' function. */ -#define HAVE_XDR_STATFSOKRES 1 - -/* Define to 1 if you have the `xdr_statfsres' function. */ -#define HAVE_XDR_STATFSRES 1 - -/* Define to 1 if you have the `xdr_symlinkargs' function. */ -#define HAVE_XDR_SYMLINKARGS 1 - -/* Define to 1 if you have the `xdr_u_int64_t' function. */ -#define HAVE_XDR_U_INT64_T 1 - -/* Define to 1 if you have the `xdr_writeargs' function. */ -#define HAVE_XDR_WRITEARGS 1 - -/* Define to 1 if `flags' is member of `xfs_args_t'. */ -/* #undef HAVE_XFS_ARGS_T_FLAGS */ - -/* Define to 1 if `fspec' is member of `xfs_args_t'. */ -/* #undef HAVE_XFS_ARGS_T_FSPEC */ - -/* Define to 1 if you have the `yp_all' function. */ -/* #undef HAVE_YP_ALL */ - -/* Define to 1 if you have the `yp_get_default_domain' function. */ -#define HAVE_YP_GET_DEFAULT_DOMAIN 1 - -/* Define to 1 if you have the `_seterr_reply' function. */ -#define HAVE__SETERR_REPLY 1 - -/* Define to 1 if you have the `__rpc_get_local_uid' function. */ -#define HAVE___RPC_GET_LOCAL_UID 1 - -/* Define to 1 if you have the `__seterr_reply' function. */ -/* #undef HAVE___SETERR_REPLY */ - -/* Name of mount type to hide amd mount from df(1) */ -#define HIDE_MOUNT_TYPE "nfs" - -/* Define name of host machine's architecture (eg. sun4) */ -/* #define HOST_ARCH "i386" */ - -/* Define name of host machine's cpu (eg. sparc) */ -/* #define HOST_CPU "i386" */ - -/* Define the header version of (linux) hosts (eg. 2.2.10) */ -// #undef define HOST_HEADER_VERSION */ - -/* Define name of host */ -/* #define HOST_NAME "trang.nuxi.org" */ - -/* Define name and version of host machine (eg. solaris2.5.1) */ -/* #define HOST_OS "freebsd12.0" */ - -/* Define only name of host machine OS (eg. solaris2) */ -/* #define HOST_OS_NAME "freebsd12" */ - -/* Define only version of host machine (eg. 2.5.1) */ -/* #define HOST_OS_VERSION "12.0" */ - -/* Define name of host machine's vendor (eg. sun) */ -#define HOST_VENDOR "undermydesk" - -/* Define to the sub-directory in which libtool stores uninstalled libraries. - */ -#define LT_OBJDIR ".libs/" - -/* Ignore permission bits */ -/* #undef MNT2_CDFS_OPT_DEFPERM */ - -/* Enable external attributes */ -#define MNT2_CDFS_OPT_EXTATT 0x4 - -/* Show file generations */ -#define MNT2_CDFS_OPT_GENS 0x2 - -/* Disable filename case translation */ -/* #undef MNT2_CDFS_OPT_NOCASETRANS */ - -/* Use on-disk permission bits */ -/* #undef MNT2_CDFS_OPT_NODEFPERM */ - -/* Disable Joliet extensions */ -#define MNT2_CDFS_OPT_NOJOLIET 0x8 - -/* Disable Rock Ridge Interchange Protocol (RRIP) extensions */ -#define MNT2_CDFS_OPT_NORRIP 0x1 - -/* Strip off extension from version string */ -/* #undef MNT2_CDFS_OPT_NOVERSION */ - -/* Enable Rock Ridge Interchange Protocol (RRIP) case insensitive filename - extensions */ -/* #undef MNT2_CDFS_OPT_RRCASEINS */ - -/* Use Rock Ridge Interchange Protocol (RRIP) extensions */ -/* #undef MNT2_CDFS_OPT_RRIP */ - -/* asynchronous filesystem access */ -#define MNT2_GEN_OPT_ASYNC 0x40 - -/* automounter filesystem (ignore) flag, used in bsdi-4.1 */ -/* #undef MNT2_GEN_OPT_AUTOMNTFS */ - -/* automounter filesystem flag, used in Mac OS X / Darwin */ -/* #undef MNT2_GEN_OPT_AUTOMOUNTED */ - -/* directory hardlink */ -/* #undef MNT2_GEN_OPT_BIND */ - -/* cache (what?) */ -/* #undef MNT2_GEN_OPT_CACHE */ - -/* 6-argument mount */ -/* #undef MNT2_GEN_OPT_DATA */ - -/* Use a lazy unmount (detach) */ -/* #undef MNT2_GEN_OPT_DETACH */ - -/* Use a forced unmount */ -#define MNT2_GEN_OPT_FORCE 0x80000 - -/* old (4-argument) mount (compatibility) */ -/* #undef MNT2_GEN_OPT_FSS */ - -/* old BSD group-id on create */ -/* #undef MNT2_GEN_OPT_GRPID */ - -/* ignore mount entry in df output */ -#define MNT2_GEN_OPT_IGNORE 0x800000 - -/* journaling filesystem (AIX's UFS/FFS) */ -/* #undef MNT2_GEN_OPT_JFS */ - -/* honor mandatory locking requests */ -/* #undef MNT2_GEN_OPT_MANDLOCK */ - -/* do multi-component lookup on files */ -/* #undef MNT2_GEN_OPT_MULTI */ - -/* use type string instead of int */ -/* #undef MNT2_GEN_OPT_NEWTYPE */ - -/* NFS mount */ -/* #undef MNT2_GEN_OPT_NFS */ - -/* don't update access times */ -#define MNT2_GEN_OPT_NOATIME 0x10000000 - -/* nocache (what?) */ -/* #undef MNT2_GEN_OPT_NOCACHE */ - -/* do not interpret special device files */ -#define MNT2_GEN_OPT_NODEV 0x0 - -/* don't update directory access times */ -/* #undef MNT2_GEN_OPT_NODIRATIME */ - -/* no exec calls allowed */ -#define MNT2_GEN_OPT_NOEXEC 0x4 - -/* do not interpret special device files */ -/* #undef MNT2_GEN_OPT_NONDEV */ - -/* Disallow mounts beneath this mount */ -/* #undef MNT2_GEN_OPT_NOSUB */ - -/* Setuid programs disallowed */ -#define MNT2_GEN_OPT_NOSUID 0x8 - -/* Return ENAMETOOLONG for long filenames */ -/* #undef MNT2_GEN_OPT_NOTRUNC */ - -/* Pass mount option string to kernel */ -/* #undef MNT2_GEN_OPT_OPTIONSTR */ - -/* allow overlay mounts */ -/* #undef MNT2_GEN_OPT_OVERLAY */ - -/* check quotas */ -#define MNT2_GEN_OPT_QUOTA 0x2000 - -/* Read-only */ -#define MNT2_GEN_OPT_RDONLY 0x1 - -/* change options on an existing mount */ -/* #undef MNT2_GEN_OPT_REMOUNT */ - -/* read only */ -/* #undef MNT2_GEN_OPT_RONLY */ - -/* synchronize data immediately to filesystem */ -/* #undef MNT2_GEN_OPT_SYNC */ - -/* synchronous filesystem access (same as SYNC) */ -#define MNT2_GEN_OPT_SYNCHRONOUS 0x2 - -/* Mount with Sys 5-specific semantics */ -/* #undef MNT2_GEN_OPT_SYS5 */ - -/* Union mount */ -#define MNT2_GEN_OPT_UNION 0x20 - -/* set max secs for dir attr cache */ -#define MNT2_NFS_OPT_ACDIRMAX 0x200000 - -/* set min secs for dir attr cache */ -#define MNT2_NFS_OPT_ACDIRMIN 0x100000 - -/* set max secs for file attr cache */ -#define MNT2_NFS_OPT_ACREGMAX 0x80000 - -/* set min secs for file attr cache */ -#define MNT2_NFS_OPT_ACREGMIN 0x40000 - -/* Authentication error */ -/* #undef MNT2_NFS_OPT_AUTHERR */ - -/* hide mount type from df(1) */ -/* #undef MNT2_NFS_OPT_AUTO */ - -/* Linux broken setuid */ -/* #undef MNT2_NFS_OPT_BROKEN_SUID */ - -/* set dead server retry thresh */ -#define MNT2_NFS_OPT_DEADTHRESH 0x4000 - -/* Dismount in progress */ -/* #undef MNT2_NFS_OPT_DISMINPROG */ - -/* Dismounted */ -/* #undef MNT2_NFS_OPT_DISMNT */ - -/* Don't estimate rtt dynamically */ -#define MNT2_NFS_OPT_DUMBTIMR 0x800 - -/* provide name of server's fs to system */ -/* #undef MNT2_NFS_OPT_FSNAME */ - -/* System V-style gid inheritance */ -/* #undef MNT2_NFS_OPT_GRPID */ - -/* Has authenticator */ -/* #undef MNT2_NFS_OPT_HASAUTH */ - -/* set hostname for error printf */ -/* #undef MNT2_NFS_OPT_HOSTNAME */ - -/* ignore mount point */ -/* #undef MNT2_NFS_OPT_IGNORE */ - -/* allow interrupts on hard mount */ -#define MNT2_NFS_OPT_INT 0x40 - -/* Bits set internally */ -/* #undef MNT2_NFS_OPT_INTERNAL */ - -/* allow interrupts on hard mount */ -/* #undef MNT2_NFS_OPT_INTR */ - -/* Use Kerberos authentication */ -/* #undef MNT2_NFS_OPT_KERB */ - -/* use kerberos credentials */ -/* #undef MNT2_NFS_OPT_KERBEROS */ - -/* transport's knetconfig structure */ -/* #undef MNT2_NFS_OPT_KNCONF */ - -/* set lease term (nqnfs) */ -/* #undef MNT2_NFS_OPT_LEASETERM */ - -/* Local locking (no lock manager) */ -/* #undef MNT2_NFS_OPT_LLOCK */ - -/* set maximum grouplist size */ -#define MNT2_NFS_OPT_MAXGRPS 0x20 - -/* Mnt server for mnt point */ -/* #undef MNT2_NFS_OPT_MNTD */ - -/* Assume writes were mine */ -/* #undef MNT2_NFS_OPT_MYWRITE */ - -/* mount NFS Version 3 */ -#define MNT2_NFS_OPT_NFSV3 0x200 - -/* don't cache attributes */ -/* #undef MNT2_NFS_OPT_NOAC */ - -/* does not support Access Control Lists */ -/* #undef MNT2_NFS_OPT_NOACL */ - -/* Don't Connect the socket */ -#define MNT2_NFS_OPT_NOCONN 0x80 - -/* no close-to-open consistency */ -#define MNT2_NFS_OPT_NOCTO 0x20000000 - -/* disallow interrupts on hard mounts */ -/* #undef MNT2_NFS_OPT_NOINT */ - -/* Don't use locking */ -/* #undef MNT2_NFS_OPT_NONLM */ - -/* does not support readdir+ */ -/* #undef MNT2_NFS_OPT_NORDIRPLUS */ - -/* Get lease for lookup */ -/* #undef MNT2_NFS_OPT_NQLOOKLEASE */ - -/* Use Nqnfs protocol */ -/* #undef MNT2_NFS_OPT_NQNFS */ - -/* paging threshold */ -/* #undef MNT2_NFS_OPT_PGTHRESH */ - -/* static pathconf kludge info */ -/* #undef MNT2_NFS_OPT_POSIX */ - -/* Use local locking */ -/* #undef MNT2_NFS_OPT_PRIVATE */ - -/* allow property list operations (ACLs over NFS) */ -/* #undef MNT2_NFS_OPT_PROPLIST */ - -/* Rcv socket lock */ -/* #undef MNT2_NFS_OPT_RCVLOCK */ - -/* Do lookup with readdir (nqnfs) */ -/* #undef MNT2_NFS_OPT_RDIRALOOK */ - -/* Use Readdirplus for NFSv3 */ -#define MNT2_NFS_OPT_RDIRPLUS 0x10000 - -/* set read ahead */ -#define MNT2_NFS_OPT_READAHEAD 0x2000 - -/* Set readdir size */ -#define MNT2_NFS_OPT_READDIRSIZE 0x20000 - -/* Allocate a reserved port */ -#define MNT2_NFS_OPT_RESVPORT 0x8000 - -/* set number of request retries */ -#define MNT2_NFS_OPT_RETRANS 0x10 - -/* read only */ -/* #undef MNT2_NFS_OPT_RONLY */ - -/* use RPC to do secure NFS time sync */ -/* #undef MNT2_NFS_OPT_RPCTIMESYNC */ - -/* set read size */ -#define MNT2_NFS_OPT_RSIZE 0x4 - -/* secure mount */ -/* #undef MNT2_NFS_OPT_SECURE */ - -/* Send socket lock */ -/* #undef MNT2_NFS_OPT_SNDLOCK */ - -/* soft mount (hard is default) */ -#define MNT2_NFS_OPT_SOFT 0x1 - -/* spongy mount */ -/* #undef MNT2_NFS_OPT_SPONGY */ - -/* Reserved for nfsv4 */ -/* #undef MNT2_NFS_OPT_STRICTLOCK */ - -/* set symlink cache time-to-live */ -/* #undef MNT2_NFS_OPT_SYMTTL */ - -/* use TCP for mounts */ -/* #undef MNT2_NFS_OPT_TCP */ - -/* set initial timeout */ -#define MNT2_NFS_OPT_TIMEO 0x8 - -/* do not use shared cache for all mountpoints */ -/* #undef MNT2_NFS_OPT_UNSHARED */ - -/* linux NFSv3 */ -/* #undef MNT2_NFS_OPT_VER3 */ - -/* Wait for authentication */ -/* #undef MNT2_NFS_OPT_WAITAUTH */ - -/* Wants an authenticator */ -/* #undef MNT2_NFS_OPT_WANTAUTH */ - -/* Want receive socket lock */ -/* #undef MNT2_NFS_OPT_WANTRCV */ - -/* Want send socket lock */ -/* #undef MNT2_NFS_OPT_WANTSND */ - -/* set write size */ -#define MNT2_NFS_OPT_WSIZE 0x2 - -/* 32<->64 dir cookie translation */ -/* #undef MNT2_NFS_OPT_XLATECOOKIE */ - -/* Force Win95 long names */ -#define MNT2_PCFS_OPT_LONGNAME 0x2 - -/* Completely ignore Win95 entries */ -#define MNT2_PCFS_OPT_NOWIN95 0x4 - -/* Force old DOS short names only */ -#define MNT2_PCFS_OPT_SHORTNAME 0x1 - -/* Name of mount table file name */ -/* #undef MNTTAB_FILE_NAME */ - -/* Mount Table option string: Max attr cache timeout (dirs) */ -/* #undef MNTTAB_OPT_ACDIRMAX */ - -/* Mount Table option string: Min attr cache timeout (dirs) */ -/* #undef MNTTAB_OPT_ACDIRMIN */ - -/* Mount Table option string: Max attr cache timeout (files) */ -/* #undef MNTTAB_OPT_ACREGMAX */ - -/* Mount Table option string: Min attr cache timeout (files) */ -/* #undef MNTTAB_OPT_ACREGMIN */ - -/* Mount Table option string: Attr cache timeout (sec) */ -/* #undef MNTTAB_OPT_ACTIMEO */ - -/* Mount Table option string: Do mount retries in background */ -/* #undef MNTTAB_OPT_BG */ - -/* Mount Table option string: compress */ -/* #undef MNTTAB_OPT_COMPRESS */ - -/* Mount Table option string: Device id of mounted fs */ -/* #undef MNTTAB_OPT_DEV */ - -/* Mount Table option string: Automount direct map mount */ -/* #undef MNTTAB_OPT_DIRECT */ - -/* Mount Table option string: Do mount retries in foreground */ -/* #undef MNTTAB_OPT_FG */ - -/* Mount Table option string: Filesystem id of mounted fs */ -/* #undef MNTTAB_OPT_FSID */ - -/* Mount Table option string: SysV-compatible gid on create */ -/* #undef MNTTAB_OPT_GRPID */ - -/* Mount Table option string: Hard mount */ -/* #undef MNTTAB_OPT_HARD */ - -/* Mount Table option string: Ignore this entry */ -/* #undef MNTTAB_OPT_IGNORE */ - -/* Mount Table option string: Automount indirect map mount */ -/* #undef MNTTAB_OPT_INDIRECT */ - -/* Mount Table option string: Allow NFS ops to be interrupted */ -/* #undef MNTTAB_OPT_INTR */ - -/* Mount Table option string: Secure (AUTH_Kerb) mounting */ -/* #undef MNTTAB_OPT_KERB */ - -/* Mount Table option string: Local locking (no lock manager) */ -/* #undef MNTTAB_OPT_LLOCK */ - -/* Force Win95 long names */ -/* #undef MNTTAB_OPT_LONGNAME */ - -/* Mount Table option string: Automount map */ -/* #undef MNTTAB_OPT_MAP */ - -/* Mount Table option string: max groups */ -/* #undef MNTTAB_OPT_MAXGROUPS */ - -/* Mount Table option string: Do multi-component lookup */ -/* #undef MNTTAB_OPT_MULTI */ - -/* Mount Table option string: Don't cache attributes at all */ -/* #undef MNTTAB_OPT_NOAC */ - -/* Access Control Lists are not supported */ -/* #undef MNTTAB_OPT_NOACL */ - -/* Mount Table option string: No auto (what?) */ -/* #undef MNTTAB_OPT_NOAUTO */ - -/* Mount Table option string: No connection */ -/* #undef MNTTAB_OPT_NOCONN */ - -/* Mount Table option string: No close-to-open consistency */ -/* #undef MNTTAB_OPT_NOCTO */ - -/* Mount Table option string: Don't allow interrupted ops */ -/* #undef MNTTAB_OPT_NOINTR */ - -/* Mount Table option string: Don't check quotas */ -/* #undef MNTTAB_OPT_NOQUOTA */ - -/* Mount Table option string: Do no allow setting sec attrs */ -/* #undef MNTTAB_OPT_NOSETSEC */ - -/* Mount Table option string: Disallow mounts on subdirs */ -/* #undef MNTTAB_OPT_NOSUB */ - -/* Mount Table option string: Set uid not allowed */ -/* #undef MNTTAB_OPT_NOSUID */ - -/* Completely ignore Win95 entries */ -/* #undef MNTTAB_OPT_NOWIN95 */ - -/* Mount Table option string: action to taken on error */ -/* #undef MNTTAB_OPT_ONERROR */ - -/* Mount Table option string: paging threshold */ -/* #undef MNTTAB_OPT_PGTHRESH */ - -/* Mount Table option string: NFS server IP port number */ -/* #undef MNTTAB_OPT_PORT */ - -/* Mount Table option string: Get static pathconf for mount */ -/* #undef MNTTAB_OPT_POSIX */ - -/* Mount Table option string: Use local locking */ -/* #undef MNTTAB_OPT_PRIVATE */ - -/* Mount Table option string: support property lists (ACLs) */ -/* #undef MNTTAB_OPT_PROPLIST */ - -/* Mount Table option string: protocol network_id indicator */ -/* #undef MNTTAB_OPT_PROTO */ - -/* Mount Table option string: Check quotas */ -/* #undef MNTTAB_OPT_QUOTA */ - -/* Mount Table option string: Change mount options */ -/* #undef MNTTAB_OPT_REMOUNT */ - -/* Mount Table option string: Max retransmissions (soft mnts) */ -/* #undef MNTTAB_OPT_RETRANS */ - -/* Mount Table option string: Number of mount retries */ -/* #undef MNTTAB_OPT_RETRY */ - -/* Mount Table option string: Read only */ -/* #undef MNTTAB_OPT_RO */ - -/* Mount Table option string: Read/write with quotas */ -/* #undef MNTTAB_OPT_RQ */ - -/* Mount Table option string: Max NFS read size (bytes) */ -/* #undef MNTTAB_OPT_RSIZE */ - -/* Mount Table option string: Read/write */ -/* #undef MNTTAB_OPT_RW */ - -/* Mount Table option string: Secure (AUTH_DES) mounting */ -/* #undef MNTTAB_OPT_SECURE */ - -/* Force old DOS short names only */ -/* #undef MNTTAB_OPT_SHORTNAME */ - -/* Mount Table option string: Soft mount */ -/* #undef MNTTAB_OPT_SOFT */ - -/* Mount Table option string: spongy mount */ -/* #undef MNTTAB_OPT_SPONGY */ - -/* Mount Table option string: Set uid allowed */ -/* #undef MNTTAB_OPT_SUID */ - -/* Mount Table option string: set symlink cache time-to-live */ -/* #undef MNTTAB_OPT_SYMTTL */ - -/* Mount Table option string: Synchronous local directory ops */ -/* #undef MNTTAB_OPT_SYNCDIR */ - -/* Mount Table option string: NFS timeout (1/10 sec) */ -/* #undef MNTTAB_OPT_TIMEO */ - -/* Mount Table option string: min. time between inconsistencies */ -/* #undef MNTTAB_OPT_TOOSOON */ - -/* Mount Table option string: protocol version number indicator */ -/* #undef MNTTAB_OPT_VERS */ - -/* Mount Table option string: Max NFS write size (bytes) */ -/* #undef MNTTAB_OPT_WSIZE */ - -/* Mount-table entry name for AUTOFS filesystem */ -/* #undef MNTTAB_TYPE_AUTOFS */ - -/* Mount-table entry name for CACHEFS filesystem */ -/* #undef MNTTAB_TYPE_CACHEFS */ - -/* Mount-table entry name for CDFS filesystem */ -#define MNTTAB_TYPE_CDFS "cd9660" - -/* Mount-table entry name for CFS (crypto) filesystem */ -/* #undef MNTTAB_TYPE_CFS */ - -/* Mount-table entry name for EFS filesystem (irix) */ -/* #undef MNTTAB_TYPE_EFS */ - -/* Mount-table entry name for EXT2 filesystem (linux) */ -/* #undef MNTTAB_TYPE_EXT2 */ - -/* Mount-table entry name for EXT3 filesystem (linux) */ -/* #undef MNTTAB_TYPE_EXT3 */ - -/* Mount-table entry name for EXT4 filesystem (linux) */ -/* #undef MNTTAB_TYPE_EXT4 */ - -/* Mount-table entry name for FFS filesystem */ -/* #undef MNTTAB_TYPE_FFS */ - -/* Mount-table entry name for LOFS filesystem */ -/* #undef MNTTAB_TYPE_LOFS */ - -/* Mount-table entry name for LUSTRE filesystem */ -/* #undef MNTTAB_TYPE_LUSTRE */ - -/* Mount-table entry name for MFS filesystem */ -#define MNTTAB_TYPE_MFS "mfs" - -/* Mount-table entry name for NFS filesystem */ -#define MNTTAB_TYPE_NFS "nfs" - -/* Mount-table entry name for NFS3 filesystem */ -#define MNTTAB_TYPE_NFS3 "nfs" - -/* Mount-table entry name for NFS4 filesystem */ -#define MNTTAB_TYPE_NFS4 "nfs" - -/* Mount-table entry name for NULLFS (loopback on bsd44) filesystem */ -#define MNTTAB_TYPE_NULLFS "nullfs" - -/* Mount-table entry name for PCFS filesystem */ -#define MNTTAB_TYPE_PCFS "msdosfs" - -/* Mount-table entry name for TFS filesystem */ -/* #undef MNTTAB_TYPE_TFS */ - -/* Mount(2) type/name for TMPFS filesystem */ -#define MNTTAB_TYPE_TMPFS "tmpfs" - -/* Mount(2) type/name for UDF filesystem */ -#define MNTTAB_TYPE_UDF "udf" - -/* Mount-table entry name for UFS filesystem */ -#define MNTTAB_TYPE_UFS "ufs" - -/* Mount-table entry name for UMAPFS (uid/gid mapping) filesystem */ -/* #undef MNTTAB_TYPE_UMAPFS */ - -/* Mount-table entry name for UNIONFS filesystem */ -#define MNTTAB_TYPE_UNIONFS "unionfs" - -/* Mount-table entry name for XFS filesystem (irix) */ -/* #undef MNTTAB_TYPE_XFS */ - -/* Define if mount table is on file, undefine if in kernel */ -/* #undef MOUNT_TABLE_ON_FILE */ - -/* Mount(2) type/name for AUTOFS filesystem */ -/* #undef MOUNT_TYPE_AUTOFS */ - -/* Mount(2) type/name for CACHEFS filesystem */ -/* #undef MOUNT_TYPE_CACHEFS */ - -/* Mount(2) type/name for CDFS filesystem */ -#define MOUNT_TYPE_CDFS "cd9660" - -/* Mount(2) type/name for CFS (crypto) filesystem */ -/* #undef MOUNT_TYPE_CFS */ - -/* Mount(2) type/name for EFS filesystem (irix) */ -/* #undef MOUNT_TYPE_EFS */ - -/* Mount(2) type/name for EXT2 filesystem (linux) */ -/* #undef MOUNT_TYPE_EXT2 */ - -/* Mount(2) type/name for EXT3 filesystem (linux) */ -/* #undef MOUNT_TYPE_EXT3 */ - -/* Mount(2) type/name for EXT4 filesystem (linux) */ -/* #undef MOUNT_TYPE_EXT4 */ - -/* Mount(2) type/name for FFS filesystem */ -/* #undef MOUNT_TYPE_FFS */ - -/* Mount(2) type/name for IGNORE filesystem (not real just ignore for df) */ -#define MOUNT_TYPE_IGNORE MNT_IGNORE - -/* Mount(2) type/name for LOFS filesystem */ -/* #undef MOUNT_TYPE_LOFS */ - -/* Mount(2) type/name for MFS filesystem */ -#define MOUNT_TYPE_MFS "mfs" - -/* Mount(2) type/name for NFS filesystem */ -#define MOUNT_TYPE_NFS "nfs" - -/* Mount(2) type/name for NFS3 filesystem */ -#define MOUNT_TYPE_NFS3 MOUNT_NFS3 - -/* Mount(2) type/name for NFS4 filesystem */ -/* #undef MOUNT_TYPE_NFS4 */ - -/* Mount(2) type/name for NULLFS (loopback on bsd44) filesystem */ -#define MOUNT_TYPE_NULLFS "nullfs" - -/* Mount(2) type/name for PCFS filesystem. XXX: conf/trap/trap_hpux.h may - override this definition for HPUX 9.0 */ -#define MOUNT_TYPE_PCFS "msdosfs" - -/* Mount(2) type/name for TFS filesystem */ -#define MOUNT_TYPE_TMPFS "tmpfs" - -/* Mount(2) type/name for UDF filesystem */ -#define MOUNT_TYPE_UDF "udf" - -/* Mount(2) type/name for TMPFS filesystem */ -/* #undef MOUNT_TYPE_TMPFS */ - -/* Mount(2) type/name for UFS filesystem */ -#define MOUNT_TYPE_UFS "ufs" - -/* Mount(2) type/name for UMAPFS (uid/gid mapping) filesystem */ -/* #undef MOUNT_TYPE_UMAPFS */ - -/* Mount(2) type/name for UNIONFS filesystem */ -#define MOUNT_TYPE_UNIONFS MNT_UNION - -/* Mount(2) type/name for XFS filesystem (irix) */ -/* #undef MOUNT_TYPE_XFS */ - -/* The string used in printf to print the mount-type field of mount(2) */ -#define MTYPE_PRINTF_TYPE "%s" - -/* Type of the mount-type field in the mount() system call */ -#define MTYPE_TYPE char * - -/* does libwrap expect caller to define the variables allow_severity and - deny_severity */ -/* #undef NEED_LIBWRAP_SEVERITY_VARIABLES */ - -/* Defined to the header file containing ndbm-compatible definitions */ -#define NEW_DBM_H - -/* Define the field name for the filehandle within nfs_args_t */ -#define NFS_FH_FIELD fh - -/* Define to 1 if your C compiler doesn't accept -c and -o together. */ -/* #undef NO_MINUS_C_MINUS_O */ - -/* Name of package */ -#define PACKAGE "am-utils" - -/* Define to the address where bug reports for this package should be sent. */ -#define PACKAGE_BUGREPORT "https://bugzilla.am-utils.org/ or am-utils@am-utils.org" - -/* Define to the full name of this package. */ -#define PACKAGE_NAME "am-utils" - -/* Define to the full name and version of this package. */ -#define PACKAGE_STRING "am-utils 6.2" - -/* Define to the one symbol short name of this package. */ -#define PACKAGE_TARNAME "am-utils" - -/* Define to the home page for this package. */ -#define PACKAGE_URL "" - -/* Define to the version of this package. */ -#define PACKAGE_VERSION "6.2" - -/* Type of the 6th argument to recvfrom() */ -#define RECVFROM_FROMLEN_TYPE socklen_t - -/* should signal handlers be reinstalled? */ -/* #undef REINSTALL_SIGNAL_HANDLER */ - -/* Define as the return type of signal handlers (`int' or `void'). */ -#define RETSIGTYPE void - -/* Define to 1 if the `setpgrp' function takes no argument. */ -/* #undef SETPGRP_VOID */ - -/* Define to 1 if the `S_IS*' macros in do not work properly. */ -/* #undef STAT_MACROS_BROKEN */ - -/* Define to 1 if you have the ANSI C header files. */ -#define STDC_HEADERS 1 - -/* Define the type of the 3rd argument ('in') to svc_getargs() */ -#define SVC_IN_ARG_TYPE caddr_t - -/* Define to 1 if you can safely include both and . */ -#define TIME_WITH_SYS_TIME 1 - -/* Define to 1 if your declares `struct tm'. */ -/* #undef TM_IN_SYS_TIME */ - -/* Define user name */ -/* #define USER_NAME "cy" */ - -/* define if must NOT use NFS "noconn" option */ -#define USE_CONNECTED_NFS_SOCKETS 1 - -/* Enable extensions on AIX 3, Interix. */ -#ifndef _ALL_SOURCE -# define _ALL_SOURCE 1 -#endif -/* Enable GNU extensions on systems that have them. */ -#ifndef _GNU_SOURCE -# define _GNU_SOURCE 1 -#endif -/* Enable threading extensions on Solaris. */ -#ifndef _POSIX_PTHREAD_SEMANTICS -# define _POSIX_PTHREAD_SEMANTICS 1 -#endif -/* Enable extensions on HP NonStop. */ -#ifndef _TANDEM_SOURCE -# define _TANDEM_SOURCE 1 -#endif -/* Enable general extensions on Solaris. */ -#ifndef __EXTENSIONS__ -# define __EXTENSIONS__ 1 -#endif - -/* define if must use NFS "noconn" option */ -/* #undef USE_UNCONNECTED_NFS_SOCKETS */ - -/* Version number of package */ -#define VERSION "6.2" - -/* Define WORDS_BIGENDIAN to 1 if your processor stores words with the most - significant byte first (like Motorola and SPARC, unlike Intel). */ -#if defined AC_APPLE_UNIVERSAL_BUILD -# if defined __BIG_ENDIAN__ -# define WORDS_BIGENDIAN 1 -# endif -#else -# ifndef WORDS_BIGENDIAN -/* # undef WORDS_BIGENDIAN */ -# endif -#endif - -/* Define to the type of xdr procedure type */ -#define XDRPROC_T_TYPE xdrproc_t - -/* Type of the 3rd argument to yp_order() */ -#define YP_ORDER_OUTORDER_TYPE int - -/* Define to 1 if `lex' declares `yytext' as a `char *' by default, not a - `char[]'. */ -#define YYTEXT_POINTER 1 - -/* Enable large inode numbers on Mac OS X 10.5. */ -#ifndef _DARWIN_USE_64_BIT_INODE -# define _DARWIN_USE_64_BIT_INODE 1 -#endif - -/* Number of bits in a file offset, on hosts where this is settable. */ -/* #undef _FILE_OFFSET_BITS */ - -/* Define for large files, on AIX-style hosts. */ -/* #undef _LARGE_FILES */ - -/* Define to 1 if on MINIX. */ -/* #undef _MINIX */ - -/* Define to 2 if the system does not provide POSIX.1 features except with - this defined. */ -/* #undef _POSIX_1_SOURCE */ - -/* Define to 1 if you need to in order for `stat' and other things to work. */ -/* #undef _POSIX_SOURCE */ - -/* Define a type/structure for an NFS V2 filehandle */ -#define am_nfs_fh nfs_fh - -/* Define a type/structure for an NFS V3 filehandle */ -#define am_nfs_fh3 nfs_fh3_freebsd3 - -/* Define a type for the autofs_args structure */ -/* #undef autofs_args_t */ - -/* Define a type for the cachefs_args structure */ -/* #undef cachefs_args_t */ - -/* Define a type for the cdfs_args structure */ -#define cdfs_args_t struct iso_args - -/* Define to empty if `const' does not conform to ANSI C. */ -/* #undef const */ - -/* Define a type for the efs_args structure */ -/* #undef efs_args_t */ - -/* Define to `int' if doesn't define. */ -/* #undef gid_t */ - -/* Define to `__inline__' or `__inline' if that's what the C compiler - calls it, or to nothing if 'inline' is not supported under any name. */ -#ifndef __cplusplus -/* #undef inline */ -#endif - -/* Define a type for the lofs_args structure */ -/* #undef lofs_args_t */ - -/* Define a type for the mfs_args structure */ -/* #undef mfs_args_t */ - -/* Define to `int' if does not define. */ -/* #undef mode_t */ - -/* Define a type for the nfs_args structure */ -#define nfs_args_t struct nfs_args - -/* Define a type for the pcfs_args structure */ -#define pcfs_args_t struct msdosfs_args - -/* Define to `int' if does not define. */ -/* #undef pid_t */ - -/* Check if pte_t is defined in */ -/* #undef pte_t */ - -/* Define a type for the rfs_args structure */ -/* #undef rfs_args_t */ - -/* Check if rpcvers_t is defined in */ -/* #undef rpcvers_t */ - -/* Define to `unsigned int' if does not define. */ -/* #undef size_t */ - -/* Define to `long' if does not define. */ -/* #undef time_t */ - -/* Define a type for the tmpfs_args structure */ -/* #undef tmpfs_args_t */ - -/* Define a type for the udf_args structure */ -/* #undef udf_args_t */ - -/* Define a type for the ufs_args structure */ -#define ufs_args_t struct ufs_args - -/* Define to `int' if doesn't define. */ -/* #undef uid_t */ - -/* Define as `fork' if `vfork' does not work. */ -/* #undef vfork */ - -/* Define to "void *" if compiler can handle, otherwise "char *" */ -#define voidp void * - -/* Define to empty if the keyword `volatile' does not work. Warning: valid - code using `volatile' can become incorrect without. Disable with care. */ -/* #undef volatile */ - -/* Define a type for the xfs_args structure */ -/* #undef xfs_args_t */ - - -/****************************************************************************/ -/*** INCLUDE localconfig.h if it exists, to allow users to make some ***/ -/*** compile time configuration changes. ***/ -/****************************************************************************/ -/* does a local configuration file exist? */ -/* #undef HAVE_LOCALCONFIG_H */ -#ifdef HAVE_LOCALCONFIG_H -# include -#endif /* HAVE_LOCALCONFIG_H */ - -#endif /* not _CONFIG_H */ - -/* - * Local Variables: - * mode: c - * End: - */ - -/* End of am-utils-6.x config.h file */ diff --git a/usr.sbin/amd/include/newvers.sh b/usr.sbin/amd/include/newvers.sh deleted file mode 100644 index b561615a458..00000000000 --- a/usr.sbin/amd/include/newvers.sh +++ /dev/null @@ -1,33 +0,0 @@ -# $NetBSD: mkconf,v 1.1.1.1 1997/07/24 21:20:12 christos Exp $ -# mkconf -# Generate local configuration parameters for amd -# - -if [ -e $1 ]; then - eval `LC_ALL=C egrep '^[A-Z]+=' $1 | grep -v COPYRIGHT` - OS=`echo ${TYPE} | LC_ALL=C tr 'A-Z' 'a-z'` - echo '/* Define name and version of host machine (eg. solaris2.5.1) */' - echo "#define HOST_OS \"${OS}${REVISION}\"" - echo '/* Define only name of host machine OS (eg. solaris2) */' - echo "#define HOST_OS_NAME \"${OS}${REVISION}\"" \ - | sed -e 's/\.[-._0-9]*//' - echo '/* Define only version of host machine (eg. 2.5.1) */' - echo "#define HOST_OS_VERSION \"${REVISION}\"" -else -cat << __NO_newvers_sh - -/* Define name and version of host machine (eg. solaris2.5.1) */ -#define HOST_OS "`uname -s | LC_ALL=C tr 'A-Z' 'a-z'``uname -r`" - -/* Define only name of host machine OS (eg. solaris2) */ -#define HOST_OS_NAME "`uname -s | LC_ALL=C tr 'A-Z' 'a-z'``uname -r | sed -e 's/\..*$//'`" - -/* Define only version of host machine (eg. 2.5.1) */ -#define HOST_OS_VERSION "`uname -r | sed -e 's/[-([:alpha:]].*//'`" - -__NO_newvers_sh -fi - -cat << __EOF - -__EOF diff --git a/usr.sbin/amd/libamu/Makefile b/usr.sbin/amd/libamu/Makefile deleted file mode 100644 index 96acb0fed9d..00000000000 --- a/usr.sbin/amd/libamu/Makefile +++ /dev/null @@ -1,37 +0,0 @@ -# ex:ts=8 -# -# Makefile for amd -# This file is under a "BSD" copyright (c) by David O'Brien 1998 -# - -.include - -.PATH: ${SRCTOP}/contrib/amd/libamu \ - ${SRCTOP}/contrib/amd/conf/transp \ - ${SRCTOP}/contrib/amd/conf/mtab \ - ${SRCTOP}/contrib/amd/conf/umount - -LIB= amu -INTERNALLIB= -SRCS= hasmntopt.c misc_rpc.c mount_fs.c mtab.c nfs_prot_xdr.c \ - strutil.c wire.c xutil.c - -# These would be links created by the GNU-style configure -SRCS+= transp_sockets.c mtab_bsd.c umount_bsd44.c - -# Generated at compile time (replaces supplied xdr_func.c) -SRCS+= nfs_prot_x.c xdr_func_%undef.c -CLEANFILES+= nfs_prot_x.c xdr_func_%undef.c - -CFLAGS+= -I${SRCTOP}/contrib/amd/libamu \ - -I${OBJTOP}/include/rpcsvc - -nfs_prot_x.c: ${NFS_PROT_X} - ${RPCCOM} -c -C -DWANT_NFS3 ${.ALLSRC} -o ${.TARGET} - -XDRDEFS!= grep 'ifndef.*HAVE_XDR' ${SRCTOP}/contrib/amd/libamu/xdr_func.c | awk '{print "-D"$$2}' - -xdr_func_%undef.c: xdr_func.c - unifdef -x1 ${XDRDEFS} -o ${.TARGET} ${.ALLSRC} - -.include diff --git a/usr.sbin/amd/libamu/Makefile.depend b/usr.sbin/amd/libamu/Makefile.depend deleted file mode 100644 index 1a113366d58..00000000000 --- a/usr.sbin/amd/libamu/Makefile.depend +++ /dev/null @@ -1,16 +0,0 @@ -# Autogenerated - do NOT edit! - -DIRDEPS = \ - include \ - include/arpa \ - include/rpc \ - include/rpcsvc \ - include/xlocale \ - usr.sbin/amd/include \ - - -.include - -.if ${DEP_RELDIR} == ${_DEP_RELDIR} -# local dependencies - needed for -jN in clean tree -.endif diff --git a/usr.sbin/amd/mk-amd-map/Makefile b/usr.sbin/amd/mk-amd-map/Makefile deleted file mode 100644 index 14f3ff3c315..00000000000 --- a/usr.sbin/amd/mk-amd-map/Makefile +++ /dev/null @@ -1,14 +0,0 @@ -# ex:ts=8 -# -# Makefile for amd -# This file is under a "BSD" copyright (c) by David O'Brien 1998 -# - -.PATH: ${SRCTOP}/contrib/amd/mk-amd-map - -PROG= mk-amd-map -MAN= mk-amd-map.8 - -LIBADD= amu - -.include diff --git a/usr.sbin/amd/mk-amd-map/Makefile.depend b/usr.sbin/amd/mk-amd-map/Makefile.depend deleted file mode 100644 index bcad3fbca4b..00000000000 --- a/usr.sbin/amd/mk-amd-map/Makefile.depend +++ /dev/null @@ -1,21 +0,0 @@ -# Autogenerated - do NOT edit! - -DIRDEPS = \ - gnu/lib/csu \ - include \ - include/arpa \ - include/rpc \ - include/rpcsvc \ - include/xlocale \ - lib/${CSU_DIR} \ - lib/libc \ - lib/libcompiler_rt \ - usr.sbin/amd/include \ - usr.sbin/amd/libamu \ - - -.include - -.if ${DEP_RELDIR} == ${_DEP_RELDIR} -# local dependencies - needed for -jN in clean tree -.endif diff --git a/usr.sbin/amd/pawd/Makefile b/usr.sbin/amd/pawd/Makefile deleted file mode 100644 index 0bf30e018f3..00000000000 --- a/usr.sbin/amd/pawd/Makefile +++ /dev/null @@ -1,18 +0,0 @@ -# ex:ts=8 -# -# Makefile for amd -# This file is under a "BSD" copyright (c) by David O'Brien 1998 -# - -.PATH: ${SRCTOP}/contrib/amd/amq - -BINDIR= /usr/bin - -PROG= pawd -SRCS= pawd.c amq_clnt.c amq_xdr.c - -CFLAGS+= -I${SRCTOP}/contrib/amd/amq - -LIBADD= amu - -.include diff --git a/usr.sbin/amd/pawd/Makefile.depend b/usr.sbin/amd/pawd/Makefile.depend deleted file mode 100644 index bcad3fbca4b..00000000000 --- a/usr.sbin/amd/pawd/Makefile.depend +++ /dev/null @@ -1,21 +0,0 @@ -# Autogenerated - do NOT edit! - -DIRDEPS = \ - gnu/lib/csu \ - include \ - include/arpa \ - include/rpc \ - include/rpcsvc \ - include/xlocale \ - lib/${CSU_DIR} \ - lib/libc \ - lib/libcompiler_rt \ - usr.sbin/amd/include \ - usr.sbin/amd/libamu \ - - -.include - -.if ${DEP_RELDIR} == ${_DEP_RELDIR} -# local dependencies - needed for -jN in clean tree -.endif diff --git a/usr.sbin/amd/scripts/Makefile b/usr.sbin/amd/scripts/Makefile deleted file mode 100644 index 3f6eb708933..00000000000 --- a/usr.sbin/amd/scripts/Makefile +++ /dev/null @@ -1,6 +0,0 @@ - -.PATH: ${SRCTOP}/contrib/amd/scripts - -MAN= amd.conf.5 - -.include diff --git a/usr.sbin/amd/scripts/Makefile.depend b/usr.sbin/amd/scripts/Makefile.depend deleted file mode 100644 index 11aba52f82c..00000000000 --- a/usr.sbin/amd/scripts/Makefile.depend +++ /dev/null @@ -1,10 +0,0 @@ -# Autogenerated - do NOT edit! - -DIRDEPS = \ - - -.include - -.if ${DEP_RELDIR} == ${_DEP_RELDIR} -# local dependencies - needed for -jN in clean tree -.endif diff --git a/usr.sbin/amd/wire-test/Makefile b/usr.sbin/amd/wire-test/Makefile deleted file mode 100644 index 70e28291d51..00000000000 --- a/usr.sbin/amd/wire-test/Makefile +++ /dev/null @@ -1,14 +0,0 @@ -# ex:ts=8 -# -# Makefile for amd -# This file is under a "BSD" copyright (c) by David O'Brien 1998 -# - -.PATH: ${SRCTOP}/contrib/amd/wire-test - -PROG= wire-test -MAN= wire-test.8 - -LIBADD= amu - -.include diff --git a/usr.sbin/amd/wire-test/Makefile.depend b/usr.sbin/amd/wire-test/Makefile.depend deleted file mode 100644 index bcad3fbca4b..00000000000 --- a/usr.sbin/amd/wire-test/Makefile.depend +++ /dev/null @@ -1,21 +0,0 @@ -# Autogenerated - do NOT edit! - -DIRDEPS = \ - gnu/lib/csu \ - include \ - include/arpa \ - include/rpc \ - include/rpcsvc \ - include/xlocale \ - lib/${CSU_DIR} \ - lib/libc \ - lib/libcompiler_rt \ - usr.sbin/amd/include \ - usr.sbin/amd/libamu \ - - -.include - -.if ${DEP_RELDIR} == ${_DEP_RELDIR} -# local dependencies - needed for -jN in clean tree -.endif diff --git a/usr.sbin/ctm/Makefile b/usr.sbin/ctm/Makefile deleted file mode 100644 index f9f15ed0165..00000000000 --- a/usr.sbin/ctm/Makefile +++ /dev/null @@ -1,4 +0,0 @@ - -SUBDIR= ctm ctm_rmail ctm_smail ctm_dequeue - -.include diff --git a/usr.sbin/ctm/Makefile.inc b/usr.sbin/ctm/Makefile.inc deleted file mode 100644 index 0c5ec2083c6..00000000000 --- a/usr.sbin/ctm/Makefile.inc +++ /dev/null @@ -1,4 +0,0 @@ - -.if exists(${.CURDIR:H:H}/Makefile.inc) -.include "${.CURDIR:H:H}/Makefile.inc" -.endif diff --git a/usr.sbin/ctm/README b/usr.sbin/ctm/README deleted file mode 100644 index 834656f26e3..00000000000 --- a/usr.sbin/ctm/README +++ /dev/null @@ -1,84 +0,0 @@ -# ---------------------------------------------------------------------------- -# "THE BEER-WARE LICENSE" (Revision 42): -# 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 -# ---------------------------------------------------------------------------- -# -# - -What will I not find in this file ? ------------------------------------ -Instructions on how to obtain FreeBSD via CTM. -Contact for that. - -What is CTM ? -------------- -CTM was originally "CVS Through eMail", but has since changed scope to be -much more general. -CTM is now meant to be the definitive way to make and apply a delta between -two versions of a directory tree. -There are two parts to this, making the delta and applying it. These are two -entirely different things. CTM concentrates the computation-burden on the -generation of the deltas, as a delta very often is applied more times than -it is made. Second CTM tries to make the minimal size delta. - -Why not use diff/patch ? ------------------------- -Good question. Primarily because diff and patch doesn't do their job very -well. They don't deal with binary files (in this case files with '\0' or -'\0377' characters in them or files that doesn't end in '\n') which isn't -a big surprise: they were made to deal with text-files only. As a second -gripe, with patch you send the entire file to delete it. Not particular -efficient. - -So what does CTM do exactly ? ------------------------------ -CTM will produce a file, (a delta) containing the instructions and data needed -to take another copy of the tree from the old to the new status. CTM means to -do this in the exact sense, and therefore the delta contains MD5 checksums to -verify that the tree it is applied to is indeed in the state CTM expects. - -This means that if you have modified the tree locally, CTM might not be able -to upgrade your copy. - -How do I make a CTM-delta ? ---------------------------- - -Read the source, and be prepared to have 2 copies of the tree; One is -the reference ("From") tree, and the other is the delta ("To") tree. -The mkCTM script will create the CTM diff of the differences between -the reference tree and the delta tree. A lot of scratch space is -required, and your machine will work hard. - -How do I apply a CTM-delta ? ----------------------------- -You pass it to the 'ctm' command. You can pass a CTM-delta on stdin, or -you can give the filename as an argument. If you do the latter, you make -life a lot easier for your self, since the program can accept gzip'ed files -and since it will not have to make a temporary copy of your file. You can -specify multiple deltas at one time, they will be processed one at a time. - -The ctm command runs in a number of passes. It will process the entire -input file in each pass, before commencing with the next pass. - -Pass 1 will validate that the input file is OK. The syntax, the data and -the global MD5 checksum will be checked. If any of these fail, ctm will -never be able to do anything with the file, so it will simply reject it. - -Pass 2 will validate that the directory tree is in the state expected by -the CTM-delta. This is done by looking for files and directories which -should/should not exists and by checking the MD5 checksums of files. - -Pass 3 will actually apply the delta. - -Should I delete the delta when I have applied it ? --------------------------------------------------- -No. You might want to selectively reconstruct a file latter on. - -Why is CTM not being maintained? --------------------------------- -Because CVSUP has improved on the concept quite a bit, and is now -the method of choice. - -Poul-Henning diff --git a/usr.sbin/ctm/ctm/Makefile b/usr.sbin/ctm/ctm/Makefile deleted file mode 100644 index 96ac087ea8e..00000000000 --- a/usr.sbin/ctm/ctm/Makefile +++ /dev/null @@ -1,23 +0,0 @@ -# ---------------------------------------------------------------------------- -# "THE BEER-WARE LICENSE" (Revision 42): -# 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 -# ---------------------------------------------------------------------------- -# - -PROG= ctm -MAN= ctm.1 ctm.5 -SRCS= ctm.c ctm_input.c ctm_pass1.c ctm_pass2.c ctm_pass3.c \ - ctm_passb.c ctm_syntax.c ctm_ed.c - -NOTYET= ctm_ed.c - -LIBADD= md - -WARNS?= 2 - -.if exists(${.CURDIR:H:H}/Makefile.inc) -.include "${.CURDIR:H:H}/Makefile.inc" -.endif -.include diff --git a/usr.sbin/ctm/ctm/Makefile.depend b/usr.sbin/ctm/ctm/Makefile.depend deleted file mode 100644 index 01fbcdb0d54..00000000000 --- a/usr.sbin/ctm/ctm/Makefile.depend +++ /dev/null @@ -1,17 +0,0 @@ -# Autogenerated - do NOT edit! - -DIRDEPS = \ - gnu/lib/csu \ - include \ - include/xlocale \ - lib/${CSU_DIR} \ - lib/libc \ - lib/libcompiler_rt \ - lib/libmd \ - - -.include - -.if ${DEP_RELDIR} == ${_DEP_RELDIR} -# local dependencies - needed for -jN in clean tree -.endif diff --git a/usr.sbin/ctm/ctm/ctm.1 b/usr.sbin/ctm/ctm/ctm.1 deleted file mode 100644 index 4b26e92ed0f..00000000000 --- a/usr.sbin/ctm/ctm/ctm.1 +++ /dev/null @@ -1,335 +0,0 @@ -.\" ---------------------------------------------------------------------------- -.\" "THE BEER-WARE LICENSE" (Revision 42): -.\" 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. Joerg Wunsch -.\" ---------------------------------------------------------------------------- -.\" -.\" This manual page is partially obtained from Poul-Hennings CTM README -.\" file. -.\" -.\" CTM and ctm(1) by -.\" -.\" -.Dd November 15, 2018 -.Dt CTM 1 -.Os -.Sh NAME -.Nm ctm -.Nd source code mirror program -.Sh SYNOPSIS -.Nm -.Op Fl cFklquv -.Op Fl b Ar basedir -.Op Fl B Ar backup-file -.Op Fl e Ar include-regex -.Op Fl t Ar tar-command -.Op Fl T Ar tmpdir -.Op Fl V Ar level -.Op Fl x Ar exclude-regex -.Ar -.Sh DESCRIPTION -The -.Nm -utility was originally -.Dq Cvs Through eMail , -but now instead it seems more fitting to call it -.Dq Current Through eMail . -.Pp -The -.Nm -utility is now meant to be the definitive way to make and apply a delta between -two versions of a directory tree. -.Pp -There are two parts to this, making the delta and applying it. -These are two -entirely different things. -.Ss Usage -To apply a CTM delta, you pass it to the -.Nm -command. -You can pass a CTM delta on stdin, or you can give the -filename as an argument. -If you do the latter, you make life a lot -easier for your self, since the program can accept gzip'ed files and -since it will not have to make a temporary copy of your file. -You can -specify multiple deltas at one time, they will be processed one at a -time. -Deltas that are already applied will be ignored. -.Pp -The -.Nm -command runs in a number of passes. -It will process the entire -input file in each pass, before commencing with the next pass. -.Pp -Before working on a file -.Ar name -.Nm -first checks for the existence of the file -.Ar name.ctm . -If this file exists, -.Nm -works on it instead. -.Pp -Pass 1 will verify that the input file is OK. -The syntax, the data -and the global MD5 checksum will be checked. -If any of these fail, -.Nm -will simply reject the input file. -.Pp -Pass 2 will validate that the directory tree is in the state expected by -the CTM delta. -This is done by looking for files and directories which -should/should not exist and by checking the MD5 checksums of files. -.Pp -If a -.Ar backup-file -had been specified using the -.Fl B -option, all files that would be modified by this -.Nm -invocation are backed up -to this file using the archiver command specified by the -.Fl t -option. -The default archiver command is -.Nm "tar -rf %s -T -" . -.Pp -Pass 3 will actually apply the delta. -.Pp -The list of files that would be modified by -.Nm -is subject to filtering regular expressions specified -using the -.Fl e -and -.Fl x -options. -The -.Fl e -and -.Fl x -options are applied in order of appearance on the command line. -The last -filter that matched a given file name determines whether the file would be -operated on or left alone by -.Nm . -.Pp -The -.Nm -utility -will extract the file hierarchy below its working directory. -Absolute -filenames or filenames containing references through -.Sq Pa .\& -and -.Sq Pa ..\& -are explicitly prohibited as a security measure. -.Ss Options -.Bl -tag -width indent -.It Fl b Ar basedir -Prepend the path -.Ar basedir -to every filename. -.It Fl B Ar backup-file -Backup all files that would be modified by this CTM run to -.Ar backup-file . -If any filters are specified using the -.Fl e -and -.Fl x -options, then the final set of files backed up are those that would be -modified by CTM after the filters are applied. -.It Fl c -Check it out, do not do anything. -.It Fl e Ar regular_expression -Match each name in the CTM file against -.Ar regular_expression , -and if it matches process the file, otherwise leave it alone. -There may be -any number of these options. -Use of this option disables the -.Pa .ctm_status -sequence number checks. -For example, the expression -.Ic ^usr.sbin/ctm -for example, will select the -.Pa usr.sbin/ctm -source directory and all pathnames under it. -.Pp -Pathnames can be disabled from being considered by CTM using the -.Fl x -option. -.It Fl F -Force. -.It Fl k -Keep files and directories and do not remove them even if the CTM file -specifies they are to be removed. -If the -.Fl B -option is specified, these files and directories will not be backed up. -.It Fl l -List files that would be modified by this invocation of CTM and the -actions that would be performed on them. -Use of the -.Fl l -option disables the -.Pa .ctm_status -checks and integrity checks on the source tree being operated on. -The -.Fl l -option can be combined with the -.Fl e -and -.Fl x -options to determine which files would be modified by the given set of -command line options. -.It Fl q -Tell us less. -.It Fl t Ar tar-command -Use -.Ar tar-command -instead of the default archiver -.Nm tar . -This option takes effect only if a backup file had been specified using the -.Fl B -option. -A %s in the tar command will be replaced by the name of the backup -file. -.It Fl T Ar tmpdir -Put temporary files under -.Ar tmpdir . -.It Fl u -Set modification time of created and modified files to the CTM delta -creation time. -.It Fl v -Tell us more. -.It Fl V Ar level -Tell us more. -.Ar Level -is the level of verbosity. -.It Fl x Ar regular_expression -Match each name in the CTM file against -.Ar regular_expression -and if it matches, leave the file alone. -There may be any number of these -options. -Use of this option disables the -.Pa .ctm_status -sequence number checks. -.Pp -Pathnames can be selected for CTM's consideration using the -.Fl e -option. -.El -.Sh SECURITY -On its own, CTM is an insecure protocol -- there is no authentication performed that the -changes applied to the source code were sent by a -trusted party, and so care should be taken if the -CTM deltas are obtained via an unauthenticated -medium such as regular email. -It is a relatively simple matter for an attacker -to forge a CTM delta to replace or precede the -legitimate one and insert malicious code into your -source tree. -If the legitimate delta is somehow prevented from -arriving, this will go unnoticed until a later -delta attempts to touch the same file, at which -point the MD5 checksum will fail. -.Pp -To remedy this insecurity, CTM pieces generated by -FreeBSD.org are cryptographically signed in a -format compatible with the GNU Privacy Guard -utility, available in /usr/ports/security/gpg, and -the Pretty Good Privacy v5 utility, -/usr/ports/security/pgp5. -The relevant public key can be obtained by -fingering ctm@FreeBSD.org. -.Pp -CTM deltas which are thus signed cannot be -undetectably altered by an attacker. -Therefore it is recommended that you make use of -GPG or PGP5 to verify the signatures if you -receive your CTM deltas via email. -.Sh ENVIRONMENT -.Ev TMPDIR , -if set to a pathname, will cause ctm to use that pathname -as the location of temporary file. -See -.Xr tempnam 3 , -for more details on this. -The same effect may be achieved with the -.Fl T -flag. -.Sh FILES -.Pa .ctm_status -contains the sequence number of the last CTM delta applied. -Changing -or removing this file will greatly confuse -.Nm . -.Pp -Using the -.Fl e -and -.Fl x -options can update a partial subset of the source tree and causes sources -to be in an inconsistent state. -It is assumed that you know what you are -doing when you use these options. -.Sh EXAMPLES -.Bd -literal -cd ~cvs -/usr/sbin/ctm ~ctm/cvs-* -.Ed -.Pp -To extract and patch all sources under `lib' -.Bd -literal -cd ~/lib-srcs -/usr/sbin/ctm -e '^lib' ~ctm/src-cur* -.Ed -.Sh DIAGNOSTICS -Numerous messages, hopefully self-explanatory. -The -.Dq noise level -can be adjusted with the -.Fl q , -.Fl v -and -.Fl V -options. -.Sh SEE ALSO -.Xr ctm_dequeue 1 , -.Xr ctm_rmail 1 , -.Xr ctm_smail 1 , -.Xr ctm 5 -.Rs -.%T "Miscellaneous CTM on FreeBSD Resources" -.%U http://ctm.berklix.org -.Re -.Sh HISTORY -Initial trials were run during the work on -.Fx 1.1.5 , -and many bugs and -methods were hashed out. -.Pp -The -.Nm -command appeared in -.Fx 2.1 . -.Pp -The latest -.Nm -code has been made available as a port (misc/ctm) in preparation of removal -from base in -.Fx 13.0 . -.Sh AUTHORS -.An -nosplit -The CTM system has been designed and implemented by -.An Poul-Henning Kamp Aq Mt phk@FreeBSD.org . -.Pp -.An Joerg Wunsch Aq Mt joerg@FreeBSD.org -wrote this man-page. diff --git a/usr.sbin/ctm/ctm/ctm.5 b/usr.sbin/ctm/ctm/ctm.5 deleted file mode 100644 index 3d497ed80a8..00000000000 --- a/usr.sbin/ctm/ctm/ctm.5 +++ /dev/null @@ -1,181 +0,0 @@ -.\" ---------------------------------------------------------------------------- -.\" "THE BEER-WARE LICENSE" (Revision 42): -.\" 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. Joerg Wunsch -.\" ---------------------------------------------------------------------------- -.\" -.\" This manual page is partially obtained from Poul-Hennings CTM README -.\" file. -.\" -.\" CTM and ctm(1) by -.\" -.\" -.Dd March 25, 1995 -.Dt CTM 5 -.Os -.Sh NAME -.Nm ctm -.Nd source code mirror system -.Sh DESCRIPTION -The -.Nm -transfers data in a specific file format, called a CTM delta. -.Pp -CTM deltas consist of control lines and data chunks. -Each control -line starts with the letters -.Dq CTM , -followed by a CTM statement and control data, and ends with a '\en' -character. -.Pp -Data chunks always belong to the preceding control line, and the -last field on that control line is the number of bytes in the data -chunk. -A trailing newline '\en' character follows each data chunk, this -newline is not part of the chunk and is not included in the count. -.Pp -The CTM statements are as follows. -.Bl -tag -width indent -.It _BEGIN Ar version name number timestamp prefix -This is the overall begin of a CTM delta file. -The -.Ar version -field must match the program version -(currently 2.0). -.Ar Name -is the name and -.Ar number -the sequence number of the CTM service, it is matched against the file -.Pa .ctm_status -to see if the delta has already been applied. -.Ar Timestamp -contains the year, month, day, hour, minute, and second of the -time of delta creation for reference -(followed by the letter -.Sq Z -meaning this is a UTC timestamp). -The -.Ar prefix -field is currently not implemented. -.It _END Ar md5 -This statement ends the CTM delta, the global -.Ar md5 -checksum is matched against the MD5 checksum of the entire delta, up to -and including the space (0x20) character following ``_END''. -.It \&FM Ar name uid gid mode md5 count -Make the file -.Ar name , -the original file had the uid -.Ar uid -(numerical, decimal), -the gid -.Ar gid -(numerical, decimal), -mode -.Ar mode -(numerical, octal), -and the MD5 checksum -.Ar md5 . -.Pp -The following -.Ar count -bytes data are the contents of the new file. -.It \&FS Ar name uid gid mode md5before md5after count -Substitute the contents of file -.Ar name , -the original file had the new uid -.Ar uid -(numerical, decimal), -the new gid -.Ar gid -(numerical, decimal), -new mode -.Ar mode -(numerical, octal), -the old MD5 checksum -.Ar md5before , -and the new MD5 checksum -.Ar md5after . -.Pp -The following -.Ar count -bytes data are the contents of the new file. -.Pp -File substitution is used if the commands to edit a file would exceed -the total file length, so substituting it is more efficient. -.It \&FN Ar name uid gid mode md5before md5after count -Edit the file -.Ar name . -The arguments are as above, but the data sections contains an -.Xr diff 1 --n script which should be applied to the file in question. -.It \&FR Ar name md5 -Remove the file -.Ar name , -which must match the MD5 checksum -.Ar md5 . -.It \&AS Ar name uid gid mode -The original file -.Ar name -changed its owner to -.Ar uid , -its group to -.Ar gid , -and/or its mode to -.Ar mode . -.It \&DM Ar name uid gid mode -The directory -.Ar name -is to be created, it had originally the owner -.Ar uid , -group -.Ar gid , -and mode -.Ar mode . -.It \&DR Ar name -The directory -.Ar name -is to be removed. -.El -.Sh EXAMPLES -In the following example, long lines have been folded to make them -printable -(marked by backslashes). -.Bd -literal -CTM_BEGIN 2.0 cvs-cur 485 19950324214652Z . -CTMFR src/sys/gnu/i386/isa/scd.c,v 5225f13aa3c7e458f9dd0d4bb637b18d -CTMFR src/sys/gnu/i386/isa/scdreg.h,v e5af42b8a06f2c8030b93a7d71afb223 -CTMDM src/sys/gnu/i386/isa/Attic 0 552 775 -CTMFS .ctm_status 545 552 664 d9ccd2a84a9dbb8db56ba85663adebf0 \\ -e2a10c6f66428981782a0a18a789ee2e 12 -cvs-cur 485 - -CTMFN CVSROOT/commitlogs/gnu 545 552 664 \\ -5d7bc3549140d860bd9641b5782c002d 7fb04ed84b48160c9b8eea84b4c0b6e3 394 -a6936 21 -ache 95/03/24 09:59:50 - - Modified: gnu/lib/libdialog kernel.c prgbox.c - Log: -[...] -CTM_END 74ddd298d76215ae45a077a4b6a74e9c -.Ed -.Sh SEE ALSO -.Xr ctm 1 , -.Xr ctm_rmail 1 , -.Xr ed 1 -.Sh HISTORY -Initial trials ran during the -.Fx 1.1.5 , -and many bugs and -methods were hashed out. -The CTM system has been made publicly available in -.Fx 2.1 . -.Sh AUTHORS -.An -nosplit -The CTM system has been designed and implemented by -.An Poul-Henning Kamp Aq Mt phk@FreeBSD.org . -.Pp -.An Joerg Wunsch Aq Mt joerg@FreeBSD.org -wrote this man-page. diff --git a/usr.sbin/ctm/ctm/ctm.c b/usr.sbin/ctm/ctm/ctm.c deleted file mode 100644 index b41b17f68ab..00000000000 --- a/usr.sbin/ctm/ctm/ctm.c +++ /dev/null @@ -1,335 +0,0 @@ -/*- - * SPDX-License-Identifier: Beerware - * - * ---------------------------------------------------------------------------- - * "THE BEER-WARE LICENSE" (Revision 42): - * 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 - * ---------------------------------------------------------------------------- - * - * - * This is the client program of 'CTM'. It will apply a CTM-patch to a - * collection of files. - * - * Options we'd like to see: - * - * -a Attempt best effort. - * -d Debug TBD. - * -m Email me instead. - * -r Reconstruct file. - * -R Read list of files to reconstruct. - * - * Options we have: - * -b Base-dir - * -B Backup to tar-file. - * -t Tar command (default as in TARCMD). - * -c Check it out, don't do anything. - * -F Force - * -q Tell us less. - * -T . Temporary files. - * -u Set all file modification times to the timestamp - * -v Tell us more. - * -V Tell us more level = number of -v - * -k Keep files and directories that would have been removed. - * -l List actions. - * - * Options we don't actually use: - * -p Less paranoid. - * -P Paranoid. - */ - -#define EXTERN /* */ -#include -#include "ctm.h" - -#define CTM_STATUS ".ctm_status" - -extern int Proc(char *, unsigned applied); - -int -main(int argc, char **argv) -{ - int stat=0, err=0; - int c; - unsigned applied = 0; - FILE *statfile; - struct CTM_Filter *nfilter = NULL; /* new filter */ - u_char * basedir; - - basedir = NULL; - Verbose = 1; - Paranoid = 1; - SetTime = 0; - KeepIt = 0; - ListIt = 0; - BackupFile = NULL; - TarCmd = TARCMD; - LastFilter = FilterList = NULL; - TmpDir = getenv("TMPDIR"); - if (TmpDir == NULL) - TmpDir = strdup(_PATH_TMP); - setbuf(stderr,0); - setbuf(stdout,0); - - while((c=getopt(argc,argv,"ab:B:cd:e:Fklm:pPqr:R:t:T:uV:vx:")) != -1) { - switch (c) { - case 'b': basedir = optarg; break; /* Base Directory */ - case 'B': BackupFile = optarg; break; - case 'c': CheckIt++; break; /* Only check it */ - case 'F': Force = 1; break; - case 'k': KeepIt++; break; /* Don't do removes */ - case 'l': ListIt++; break; /* Only list actions and files */ - case 'p': Paranoid--; break; /* Less Paranoid */ - case 'P': Paranoid++; break; /* More Paranoid */ - case 'q': Verbose--; break; /* Quiet */ - case 't': TarCmd = optarg; break; /* archiver command */ - case 'T': TmpDir = optarg; break; /* set temporary directory */ - case 'u': SetTime++; break; /* Set timestamp on files */ - case 'v': Verbose++; break; /* Verbose */ - case 'V': sscanf(optarg,"%d", &c); /* Verbose */ - Verbose += c; - break; - case 'e': /* filter expressions */ - case 'x': - if (NULL == (nfilter = Malloc(sizeof(struct CTM_Filter)))) { - warnx("out of memory for expressions: \"%s\"", optarg); - stat++; - break; - } - - (void) memset(nfilter, 0, sizeof(struct CTM_Filter)); - - if (0 != (err = - regcomp(&nfilter->CompiledRegex, optarg, REG_NOSUB))) { - - char errmsg[128]; - - regerror(err, &nfilter->CompiledRegex, errmsg, - sizeof(errmsg)); - warnx("regular expression: \"%s\"", errmsg); - stat++; - break; - } - - /* note whether the filter enables or disables on match */ - nfilter->Action = - (('e' == c) ? CTM_FILTER_ENABLE : CTM_FILTER_DISABLE); - - /* link in the expression into the list */ - nfilter->Next = NULL; - if (NULL == FilterList) { - LastFilter = FilterList = nfilter; /* init head and tail */ - } else { /* place at tail */ - LastFilter->Next = nfilter; - LastFilter = nfilter; - } - break; - case ':': - warnx("option '%c' requires an argument",optopt); - stat++; - break; - case '?': - warnx("option '%c' not supported",optopt); - stat++; - break; - default: - warnx("option '%c' not yet implemented",optopt); - break; - } - } - - if(stat) { - warnx("%d errors during option processing",stat); - return Exit_Pilot; - } - fprintf(stderr, "CTM will be removed from FreeBSD-13, and will be " - "provided as a port (misc/ctm) or package (ctm).\n\n"); - - stat = Exit_Done; - argc -= optind; - argv += optind; - - if (basedir == NULL) { - Buffer = (u_char *)Malloc(BUFSIZ + strlen(SUBSUFF) +1); - CatPtr = Buffer; - *Buffer = '\0'; - } else { - Buffer = (u_char *)Malloc(strlen(basedir)+ BUFSIZ + strlen(SUBSUFF) +1); - strcpy(Buffer, basedir); - CatPtr = Buffer + strlen(basedir); - if (CatPtr[-1] != '/') { - strcat(Buffer, "/"); - CatPtr++; - } - } - strcat(Buffer, CTM_STATUS); - - if(ListIt) - applied = 0; - else - if((statfile = fopen(Buffer, "r")) == NULL) { - if (Verbose > 0) - warnx("warning: %s not found", Buffer); - } else { - fscanf(statfile, "%*s %u", &applied); - fclose(statfile); - } - - if(!argc) - stat |= Proc("-", applied); - - while(argc-- && stat == Exit_Done) { - stat |= Proc(*argv++, applied); - stat &= ~(Exit_Version | Exit_NoMatch); - } - - if(stat == Exit_Done) - stat = Exit_OK; - - if(Verbose > 0) - warnx("exit(%d)",stat); - - if (FilterList) - for (nfilter = FilterList; nfilter; ) { - struct CTM_Filter *tmp = nfilter->Next; - Free(nfilter); - nfilter = tmp; - } - return stat; -} - -int -Proc(char *filename, unsigned applied) -{ - FILE *f; - int i; - char *p = strrchr(filename,'.'); - - if(!strcmp(filename,"-")) { - p = 0; - f = stdin; - } else if(p && (!strcmp(p,".gz") || !strcmp(p,".Z"))) { - p = alloca(20 + strlen(filename)); - strcpy(p,"gunzip < "); - strcat(p,filename); - f = popen(p,"r"); - if(!f) { warn("%s", p); return Exit_Garbage; } - } else { - p = 0; - f = fopen(filename,"r"); - } - if(!f) { - warn("%s", filename); - return Exit_Garbage; - } - - if(Verbose > 1) - fprintf(stderr,"Working on <%s>\n",filename); - - Delete(FileName); - FileName = String(filename); - - /* If we cannot seek, we're doomed, so copy to a tmp-file in that case */ - if(!p && -1 == fseek(f,0,SEEK_END)) { - char *fn; - FILE *f2; - int fd; - - if (asprintf(&fn, "%s/CTMclient.XXXXXXXXXX", TmpDir) == -1) { - fprintf(stderr, "Cannot allocate memory\n"); - fclose(f); - return Exit_Broke; - } - if ((fd = mkstemp(fn)) == -1 || (f2 = fdopen(fd, "w+")) == NULL) { - warn("%s", fn); - free(fn); - if (fd != -1) - close(fd); - fclose(f); - return Exit_Broke; - } - unlink(fn); - if (Verbose > 0) - fprintf(stderr,"Writing tmp-file \"%s\"\n",fn); - free(fn); - while(EOF != (i=getc(f))) - if(EOF == putc(i,f2)) { - fclose(f2); - return Exit_Broke; - } - fclose(f); - f = f2; - } - - if(!p) - rewind(f); - - if((i=Pass1(f, applied))) - goto exit_and_close; - - if(ListIt) { - i = Exit_Done; - goto exit_and_close; - } - - if(!p) { - rewind(f); - } else { - pclose(f); - f = popen(p,"r"); - if(!f) { warn("%s", p); return Exit_Broke; } - } - - i=Pass2(f); - - if(!p) { - rewind(f); - } else { - pclose(f); - f = popen(p,"r"); - if(!f) { warn("%s", p); return Exit_Broke; } - } - - if(i) { - if((!Force) || (i & ~Exit_Forcible)) - goto exit_and_close; - } - - if(CheckIt) { - if (Verbose > 0) - fprintf(stderr,"All checks out ok.\n"); - i = Exit_Done; - goto exit_and_close; - } - - /* backup files if requested */ - if(BackupFile) { - - i = PassB(f); - - if(!p) { - rewind(f); - } else { - pclose(f); - f = popen(p,"r"); - if(!f) { warn("%s", p); return Exit_Broke; } - } - } - - i=Pass3(f); - -exit_and_close: - if(!p) - fclose(f); - else - pclose(f); - - if(i) - return i; - - if (Verbose > 0) - fprintf(stderr,"All done ok\n"); - - return Exit_Done; -} diff --git a/usr.sbin/ctm/ctm/ctm.h b/usr.sbin/ctm/ctm/ctm.h deleted file mode 100644 index 8bd189e5e87..00000000000 --- a/usr.sbin/ctm/ctm/ctm.h +++ /dev/null @@ -1,162 +0,0 @@ -/* - * ---------------------------------------------------------------------------- - * "THE BEER-WARE LICENSE" (Revision 42): - * 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 - * ---------------------------------------------------------------------------- - * - * - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#define VERSION "2.0" - -#define SUBSUFF ".ctm" -#define TMPSUFF ".ctmtmp" -#define TARCMD "tar -rf %s -T -" - -/* The fields... */ -#define CTM_F_MASK 0xff -#define CTM_F_Name 0x01 -#define CTM_F_Uid 0x02 -#define CTM_F_Gid 0x03 -#define CTM_F_Mode 0x04 -#define CTM_F_MD5 0x05 -#define CTM_F_Count 0x06 -#define CTM_F_Bytes 0x07 - -/* The qualifiers... */ -#define CTM_Q_MASK 0xff00 -#define CTM_Q_Name_File 0x0100 -#define CTM_Q_Name_Dir 0x0200 -#define CTM_Q_Name_New 0x0400 -#define CTM_Q_Name_Subst 0x0800 -#define CTM_Q_MD5_After 0x0100 -#define CTM_Q_MD5_Before 0x0200 -#define CTM_Q_MD5_Chunk 0x0400 -#define CTM_Q_MD5_Force 0x0800 - -struct CTM_Syntax { - char *Key; /* CTM key for operation */ - int *List; /* List of operations */ - }; - -extern struct CTM_Syntax Syntax[]; - -struct CTM_Filter { - struct CTM_Filter *Next; /* next filter in the list */ - int Action; /* enable or disable */ - regex_t CompiledRegex; /* compiled regex */ -}; - -#define CTM_FILTER_DISABLE 0 -#define CTM_FILTER_ENABLE 1 - -#define Malloc malloc -#define Free free -#define Delete(foo) if (!foo) ; else {Free(foo); foo = 0; } -#define String(foo) strdup(foo) - -#ifndef EXTERN -# define EXTERN extern -#endif -EXTERN u_char *Version; -EXTERN u_char *Name; -EXTERN u_char *Nbr; -EXTERN u_char *TimeStamp; -EXTERN u_char *Prefix; -EXTERN u_char *FileName; -EXTERN u_char *TmpDir; -EXTERN u_char *CatPtr; -EXTERN u_char *Buffer; -EXTERN u_char *BackupFile; -EXTERN u_char *TarCmd; - -/* - * Paranoid -- Just in case they should be after us... - * 0 not at all. - * 1 normal. - * 2 somewhat. - * 3 you bet!. - * - * Verbose -- What to tell mom... - * 0 Nothing which wouldn't surprise. - * 1 Normal. - * 2 Show progress '.'. - * 3 Show progress names, and actions. - * 4 even more... - * and so on - * - * ExitCode -- our Epitaph - * 0 Perfect, all input digested, no problems - * 1 Bad input, no point in retrying. - * 2 Pilot error, commandline problem &c - * 4 Out of resources. - * 8 Destination-tree not correct. - * 16 Destination-tree not correct, can force. - * 32 Internal problems. - * - */ - -EXTERN int Paranoid; -EXTERN int Verbose; -EXTERN int Exit; -EXTERN int Force; -EXTERN int CheckIt; -EXTERN int KeepIt; -EXTERN int ListIt; -EXTERN int SetTime; -EXTERN struct timeval Times[2]; -EXTERN struct CTM_Filter *FilterList; -EXTERN struct CTM_Filter *LastFilter; - -#define Exit_OK 0 -#define Exit_Garbage 1 -#define Exit_Pilot 2 -#define Exit_Broke 4 -#define Exit_NotOK 8 -#define Exit_Forcible 16 -#define Exit_Mess 32 -#define Exit_Done 64 -#define Exit_Version 128 -#define Exit_NoMatch 256 - -void Fatal_(int ln, char *fn, char *kind); -#define Fatal(foo) Fatal_(__LINE__,__FILE__,foo) -#define Assert() Fatal_(__LINE__,__FILE__,"Assert failed.") -#define WRONG {Assert(); return Exit_Mess;} - -u_char * Ffield(FILE *fd, MD5_CTX *ctx,u_char term); -u_char * Fname(FILE *fd, MD5_CTX *ctx,u_char term,int qual, int verbose); - -int Fbytecnt(FILE *fd, MD5_CTX *ctx, u_char term); - -u_char * Fdata(FILE *fd, int u_chars, MD5_CTX *ctx); - -#define GETFIELD(p,q) if(!((p)=Ffield(fd,&ctx,(q)))) return BADREAD -#define GETFIELDCOPY(p,q) if(!((p)=Ffield(fd,&ctx,(q)))) return BADREAD; else p=String(p) -#define GETBYTECNT(p,q) if(0 >((p)= Fbytecnt(fd,&ctx,(q)))) return BADREAD -#define GETDATA(p,q) if(!((p) = Fdata(fd,(q),&ctx))) return BADREAD -#define GETNAMECOPY(p,q,r,v) if(!((p)=Fname(fd,&ctx,(q),(r),(v)))) return BADREAD; else p=String(p) - -int Pass1(FILE *fd, unsigned applied); -int Pass2(FILE *fd); -int PassB(FILE *fd); -int Pass3(FILE *fd); - -int ctm_edit(u_char *script, int length, char *filein, char *fileout); diff --git a/usr.sbin/ctm/ctm/ctm_ed.c b/usr.sbin/ctm/ctm/ctm_ed.c deleted file mode 100644 index 89117a3b59e..00000000000 --- a/usr.sbin/ctm/ctm/ctm_ed.c +++ /dev/null @@ -1,115 +0,0 @@ -/*- - * SPDX-License-Identifier: Beerware - * - * ---------------------------------------------------------------------------- - * "THE BEER-WARE LICENSE" (Revision 42): - * 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 - * ---------------------------------------------------------------------------- - * - * - */ - -#include "ctm.h" - -int -ctm_edit(u_char *script, int length, char *filein, char *fileout) -{ - u_char *ep, cmd; - int ln, ln2, iln, ret=0, c; - FILE *fi=0,*fo=0; - - fi = fopen(filein,"r"); - if(!fi) { - warn("%s", filein); - return 8; - } - - fo = fopen(fileout,"w"); - if(!fo) { - warn("%s", fileout); - fclose(fi); - return 4; - } - iln = 1; - for(ep=script;ep < script+length;) { - cmd = *ep++; - if(cmd != 'a' && cmd != 'd') { ret = 1; goto bye; } - ln = 0; - while(isdigit(*ep)) { - ln *= 10; - ln += (*ep++ - '0'); - } - if(*ep++ != ' ') { ret = 1; goto bye; } - ln2 = 0; - while(isdigit(*ep)) { - ln2 *= 10; - ln2 += (*ep++ - '0'); - } - if(*ep++ != '\n') { ret = 1; goto bye; } - - - if(cmd == 'd') { - while(iln < ln) { - c = getc(fi); - if(c == EOF) { ret = 1; goto bye; } - putc(c,fo); - if(c == '\n') - iln++; - } - while(ln2) { - c = getc(fi); - if(c == EOF) { ret = 1; goto bye; } - if(c != '\n') - continue; - ln2--; - iln++; - } - continue; - } - if(cmd == 'a') { - while(iln <= ln) { - c = getc(fi); - if(c == EOF) { ret = 1; goto bye; } - putc(c,fo); - if(c == '\n') - iln++; - } - while(ln2) { - c = *ep++; - putc(c,fo); - if(c != '\n') - continue; - ln2--; - } - continue; - } - ret = 1; - goto bye; - } - while(1) { - c = getc(fi); - if(c == EOF) break; - putc(c,fo); - } - ret = 0; -bye: - if(fi) { - if(fclose(fi) != 0) { - warn("%s", filein); - ret = 1; - } - } - if(fo) { - if(fflush(fo) != 0) { - warn("%s", fileout); - ret = 1; - } - if(fclose(fo) != 0) { - warn("%s", fileout); - ret = 1; - } - } - return ret; -} diff --git a/usr.sbin/ctm/ctm/ctm_input.c b/usr.sbin/ctm/ctm/ctm_input.c deleted file mode 100644 index 6bafc9d1377..00000000000 --- a/usr.sbin/ctm/ctm/ctm_input.c +++ /dev/null @@ -1,135 +0,0 @@ -/*- - * SPDX-License-Identifier: Beerware - * - * ---------------------------------------------------------------------------- - * "THE BEER-WARE LICENSE" (Revision 42): - * 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 - * ---------------------------------------------------------------------------- - * - * - */ - -#include "ctm.h" - -/*---------------------------------------------------------------------------*/ -void -Fatal_(int ln, char *fn, char *kind) -{ - if(Verbose > 2) - fprintf(stderr,"Fatal error. (%s:%d)\n",fn,ln); - fprintf(stderr,"%s Fatal error: %s\n",FileName, kind); -} -#define Fatal(foo) Fatal_(__LINE__,__FILE__,foo) -#define Assert() Fatal_(__LINE__,__FILE__,"Assert failed.") - -/*---------------------------------------------------------------------------*/ -/* get next field, check that the terminating whitespace is what we expect */ -u_char * -Ffield(FILE *fd, MD5_CTX *ctx,u_char term) -{ - static u_char buf[BUFSIZ]; - int i,l; - - for(l=0;;) { - if((i=getc(fd)) == EOF) { - Fatal("Truncated patch."); - return 0; - } - buf[l++] = i; - if(isspace(i)) - break; - if(l >= sizeof buf) { - Fatal("Corrupt patch."); - printf("Token is too long.\n"); - return 0; - } - } - buf[l] = '\0'; - MD5Update(ctx,buf,l); - if(buf[l-1] != term) { - Fatal("Corrupt patch."); - fprintf(stderr,"Expected \"%s\" but didn't find it {%02x}.\n", - term == '\n' ? "\\n" : " ",buf[l-1]); - if(Verbose > 4) - fprintf(stderr,"{%s}\n",buf); - return 0; - } - buf[--l] = '\0'; - if(Verbose > 4) - fprintf(stderr,"<%s>\n",buf); - return buf; -} - -int -Fbytecnt(FILE *fd, MD5_CTX *ctx, u_char term) -{ - u_char *p,*q; - int u_chars=0; - - p = Ffield(fd,ctx,term); - if(!p) return -1; - for(q=p;*q;q++) { - if(!isdigit(*q)) { - Fatal("Bytecount contains non-digit."); - return -1; - } - u_chars *= 10; - u_chars += (*q - '0'); - } - return u_chars; -} - -u_char * -Fdata(FILE *fd, int u_chars, MD5_CTX *ctx) -{ - u_char *p = Malloc(u_chars+1); - - if(u_chars+1 != fread(p,1,u_chars+1,fd)) { - Fatal("Truncated patch."); - return 0; - } - MD5Update(ctx,p,u_chars+1); - if(p[u_chars] != '\n') { - if(Verbose > 3) - printf("FileData wasn't followed by a newline.\n"); - Fatal("Corrupt patch."); - return 0; - } - p[u_chars] = '\0'; - return p; -} - -/*---------------------------------------------------------------------------*/ -/* get the filename in the next field, prepend BaseDir and give back the result - strings. The sustitute filename is return (the one with the suffix SUBSUFF) - if it exists and the qualifier contains CTM_Q_Name_Subst - NOTA: Buffer is already initialize with BaseDir, CatPtr is the insertion - point on this buffer + the length test in Ffield() is enough for Fname() */ - -u_char * -Fname(FILE *fd, MD5_CTX *ctx,u_char term,int qual, int verbose) -{ - u_char * p; - struct stat st; - - if ((p = Ffield(fd,ctx,term)) == NULL) return(NULL); - - strcpy(CatPtr, p); - - if (!(qual & CTM_Q_Name_Subst)) return(Buffer); - - p = Buffer + strlen(Buffer); - - strcat(Buffer, SUBSUFF); - - if ( -1 == stat(Buffer, &st) ) { - *p = '\0'; - } else { - if(verbose > 2) - fprintf(stderr,"Using %s as substitute file\n", Buffer); - } - - return (Buffer); -} diff --git a/usr.sbin/ctm/ctm/ctm_pass1.c b/usr.sbin/ctm/ctm/ctm_pass1.c deleted file mode 100644 index a9664f06880..00000000000 --- a/usr.sbin/ctm/ctm/ctm_pass1.c +++ /dev/null @@ -1,253 +0,0 @@ -/*- - * SPDX-License-Identifier: Beerware - * - * ---------------------------------------------------------------------------- - * "THE BEER-WARE LICENSE" (Revision 42): - * 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 - * ---------------------------------------------------------------------------- - * - * - */ - -#include "ctm.h" -#define BADREAD 1 - -/*---------------------------------------------------------------------------*/ -/* Pass1 -- Validate the incoming CTM-file. - */ - -int -Pass1(FILE *fd, unsigned applied) -{ - u_char *p,*q; - MD5_CTX ctx; - int i,j,sep,cnt; - u_char *md5=0,*name=0,*trash=0; - struct CTM_Syntax *sp; - int slashwarn=0, match=0, total_matches=0; - unsigned current; - char md5_1[33]; - - if(Verbose>3) - printf("Pass1 -- Checking integrity of incoming CTM-patch\n"); - MD5Init (&ctx); - - GETFIELD(p,' '); /* CTM_BEGIN */ - if(strcmp(p,"CTM_BEGIN")) { - Fatal("Probably not a CTM-patch at all."); - if(Verbose>3) - fprintf(stderr,"Expected \"CTM_BEGIN\" got \"%s\".\n",p); - return 1; - } - - GETFIELDCOPY(Version,' '); /* */ - if(strcmp(Version,VERSION)) { - Fatal("CTM-patch is wrong version."); - if(Verbose>3) - fprintf(stderr,"Expected \"%s\" got \"%s\".\n",VERSION,p); - return 1; - } - - GETFIELDCOPY(Name,' '); /* */ - GETFIELDCOPY(Nbr,' '); /* */ - GETFIELDCOPY(TimeStamp,' '); /* */ - GETFIELDCOPY(Prefix,'\n'); /* */ - - sscanf(Nbr, "%u", ¤t); - if (FilterList || ListIt) - current = 0; /* ignore if -l or if filters are present */ - if(current && current <= applied) { - if(Verbose > 0) - fprintf(stderr,"Delta number %u is already applied; ignoring.\n", - current); - return Exit_Version; - } - - for(;;) { - Delete(md5); - Delete(name); - Delete(trash); - cnt = -1; - /* if a filter list is defined we assume that all pathnames require - an action opposite to that requested by the first filter in the - list. - If no filter is defined, all pathnames are assumed to match. */ - match = (FilterList ? !(FilterList->Action) : CTM_FILTER_ENABLE); - - GETFIELD(p,' '); /* CTM_something */ - - if (p[0] != 'C' || p[1] != 'T' || p[2] != 'M') { - Fatal("Expected CTM keyword."); - fprintf(stderr,"Got [%s]\n",p); - return 1; - } - - if(!strcmp(p+3,"_END")) - break; - - for(sp=Syntax;sp->Key;sp++) - if(!strcmp(p+3,sp->Key)) - goto found; - Fatal("Expected CTM keyword."); - fprintf(stderr,"Got [%s]\n",p); - return 1; - found: - if(Verbose > 5) - fprintf(stderr,"%s ",sp->Key); - for(i=0;(j = sp->List[i]);i++) { - if (sp->List[i+1] && (sp->List[i+1] & CTM_F_MASK) != CTM_F_Bytes) - sep = ' '; - else - sep = '\n'; - - if(Verbose > 5) - fprintf(stderr," %x(%d)",sp->List[i],sep); - - switch (j & CTM_F_MASK) { - case CTM_F_Name: /* XXX check for garbage and .. */ - GETFIELDCOPY(name,sep); - j = strlen(name); - if(name[j-1] == '/' && !slashwarn) { - fprintf(stderr,"Warning: contains trailing slash\n"); - slashwarn++; - } - if (name[0] == '/') { - Fatal("Absolute paths are illegal."); - Delete(name); - return Exit_Mess; - } - q = name; - for (;;) { - if (q[0] == '.' && q[1] == '.') - if (q[2] == '/' || q[2] == '\0') { - Fatal("Paths containing '..' are illegal."); - Delete(name); - return Exit_Mess; - } - if ((q = strchr(q, '/')) == NULL) - break; - q++; - } - - /* if we have been asked to `keep' files then skip - removes; i.e. we don't match these entries at - all. */ - if (KeepIt && - (!strcmp(sp->Key,"DR") || !strcmp(sp->Key,"FR"))) { - match = CTM_FILTER_DISABLE; - break; - } - - /* If filter expression have been defined, match the - path name against the expression list. */ - - if (FilterList) { - struct CTM_Filter *filter; - - for (filter = FilterList; filter; - filter = filter->Next) { - if (0 == regexec(&filter->CompiledRegex, name, - 0, 0, 0)) - /* if the name matches, adopt the - action */ - match = filter->Action; - } - } - - /* Add up the total number of matches */ - total_matches += match; - break; - case CTM_F_Uid: - GETFIELD(p,sep); - while(*p) { - if(!isdigit(*p)) { - Fatal("Non-digit in uid."); - return 32; - } - p++; - } - break; - case CTM_F_Gid: - GETFIELD(p,sep); - while(*p) { - if(!isdigit(*p)) { - Fatal("Non-digit in gid."); - return 32; - } - p++; - } - break; - case CTM_F_Mode: - GETFIELD(p,sep); - while(*p) { - if(!isdigit(*p)) { - Fatal("Non-digit in mode."); - return 32; - } - p++; - } - break; - case CTM_F_MD5: - if(j & CTM_Q_MD5_Chunk) { - GETFIELDCOPY(md5,sep); /* XXX check for garbage */ - } else if(j & CTM_Q_MD5_Before) { - GETFIELD(p,sep); /* XXX check for garbage */ - } else if(j & CTM_Q_MD5_After) { - GETFIELD(p,sep); /* XXX check for garbage */ - } else { - fprintf(stderr,"List = 0x%x\n",j); - Fatal("Unqualified MD5."); - return 32; - } - break; - case CTM_F_Count: - GETBYTECNT(cnt,sep); - break; - case CTM_F_Bytes: - if(cnt < 0) WRONG - GETDATA(trash,cnt); - p = MD5Data(trash,cnt,md5_1); - if(md5 && strcmp(md5,p)) { - Fatal("Internal MD5 failed."); - return Exit_Garbage; - default: - fprintf(stderr,"List = 0x%x\n",j); - Fatal("List had garbage."); - return Exit_Garbage; - } - } - } - if(Verbose > 5) - putc('\n',stderr); - if(ListIt && match) - printf("> %s %s\n", sp->Key, name); - } - - Delete(md5); - Delete(name); - Delete(trash); - - q = MD5End (&ctx,md5_1); - if(Verbose > 2) - printf("Expecting Global MD5 <%s>\n",q); - GETFIELD(p,'\n'); /* */ - if(Verbose > 2) - printf("Reference Global MD5 <%s>\n",p); - if(strcmp(q,p)) { - Fatal("MD5 sum doesn't match."); - fprintf(stderr,"\tI have:<%s>\n",q); - fprintf(stderr,"\tShould have been:<%s>\n",p); - return Exit_Garbage; - } - if (-1 != getc(fd)) { - if(!Force) { - Fatal("Trailing junk in CTM-file. Can Force with -F."); - return 16; - } - } - if ((Verbose > 1) && (0 == total_matches)) - printf("No matches in \"%s\"\n", FileName); - return (total_matches ? Exit_OK : Exit_NoMatch); -} diff --git a/usr.sbin/ctm/ctm/ctm_pass2.c b/usr.sbin/ctm/ctm/ctm_pass2.c deleted file mode 100644 index 3799e47ca6b..00000000000 --- a/usr.sbin/ctm/ctm/ctm_pass2.c +++ /dev/null @@ -1,302 +0,0 @@ -/*- - * SPDX-License-Identifier: Beerware - * - * ---------------------------------------------------------------------------- - * "THE BEER-WARE LICENSE" (Revision 42): - * 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 - * ---------------------------------------------------------------------------- - * - * - */ - -#include "ctm.h" -#define BADREAD 32 - -/*---------------------------------------------------------------------------*/ -/* Pass2 -- Validate the incoming CTM-file. - */ - -int -Pass2(FILE *fd) -{ - u_char *p,*q,*md5=0; - MD5_CTX ctx; - int i,j,sep,cnt,fdesc; - u_char *trash=0,*name=0; - struct CTM_Syntax *sp; - struct stat st; - int ret = 0; - int match = 0; - char md5_1[33]; - struct CTM_Filter *filter; - FILE *ed = NULL; - static char *template = NULL; - - if(Verbose>3) - printf("Pass2 -- Checking if CTM-patch will apply\n"); - MD5Init (&ctx); - - GETFIELD(p,' '); if(strcmp("CTM_BEGIN",p)) WRONG - GETFIELD(p,' '); if(strcmp(Version,p)) WRONG - GETFIELD(p,' '); if(strcmp(Name,p)) WRONG - /* XXX Lookup name in /etc/ctm,conf, read stuff */ - GETFIELD(p,' '); if(strcmp(Nbr,p)) WRONG - /* XXX Verify that this is the next patch to apply */ - GETFIELD(p,' '); if(strcmp(TimeStamp,p)) WRONG - GETFIELD(p,'\n'); if(strcmp(Prefix,p)) WRONG - /* XXX drop or use ? */ - - for(;;) { - Delete(trash); - Delete(name); - Delete(md5); - cnt = -1; - - /* if a filter list was specified, check file name against - the filters specified - if no filter was given operate on all files. */ - match = (FilterList ? - !(FilterList->Action) : CTM_FILTER_ENABLE); - - GETFIELD(p,' '); - - if (p[0] != 'C' || p[1] != 'T' || p[2] != 'M') WRONG - - if(!strcmp(p+3,"_END")) - break; - - for(sp=Syntax;sp->Key;sp++) - if(!strcmp(p+3,sp->Key)) - goto found; - WRONG - found: - for(i=0;(j = sp->List[i]);i++) { - if (sp->List[i+1] && (sp->List[i+1] & CTM_F_MASK) != CTM_F_Bytes) - sep = ' '; - else - sep = '\n'; - - switch (j & CTM_F_MASK) { - case CTM_F_Name: - GETNAMECOPY(name,sep,j,0); - /* If `keep' was specified, we won't remove any files, - so don't check if the file exists */ - if (KeepIt && - (!strcmp(sp->Key,"FR") || !strcmp(sp->Key,"DR"))) { - match = CTM_FILTER_DISABLE; - break; - } - - for (filter = FilterList; filter; filter = filter->Next) if (0 == regexec(&filter->CompiledRegex, name, - 0, 0, 0)) { - match = filter->Action; - } - - if (CTM_FILTER_DISABLE == match) - break; /* should ignore this file */ - - /* XXX Check DR DM rec's for parent-dir */ - if(j & CTM_Q_Name_New) { - /* XXX Check DR FR rec's for item */ - if(-1 != stat(name,&st)) { - fprintf(stderr," %s: %s exists.\n", - sp->Key,name); - ret |= Exit_Forcible; - } - break; - } - if(-1 == stat(name,&st)) { - fprintf(stderr," %s: %s doesn't exist.\n", - sp->Key,name); - if (sp->Key[1] == 'R') - ret |= Exit_Forcible; - else - ret |= Exit_NotOK; - break; - } - if (SetTime && getuid() && (getuid() != st.st_uid)) { - fprintf(stderr, - " %s: %s not mine, cannot set time.\n", - sp->Key,name); - ret |= Exit_NotOK; - } - if (j & CTM_Q_Name_Dir) { - if((st.st_mode & S_IFMT) != S_IFDIR) { - fprintf(stderr, - " %s: %s exist, but isn't dir.\n", - sp->Key,name); - ret |= Exit_NotOK; - } - break; - } - if (j & CTM_Q_Name_File) { - if((st.st_mode & S_IFMT) != S_IFREG) { - fprintf(stderr, - " %s: %s exist, but isn't file.\n", - sp->Key,name); - ret |= Exit_NotOK; - } - break; - } - break; - case CTM_F_Uid: - case CTM_F_Gid: - case CTM_F_Mode: - GETFIELD(p,sep); - break; - case CTM_F_MD5: - if(!name) WRONG - if(j & CTM_Q_MD5_Before) { - char *tmp; - GETFIELD(p,sep); - if(match && (st.st_mode & S_IFMT) == S_IFREG && - (tmp = MD5File(name,md5_1)) != NULL && - strcmp(tmp,p)) { - fprintf(stderr," %s: %s md5 mismatch.\n", - sp->Key,name); - GETFIELDCOPY(md5,sep); - if(md5 != NULL && strcmp(tmp,md5) == 0) { - fprintf(stderr," %s: %s already applied.\n", - sp->Key,name); - match = CTM_FILTER_DISABLE; - } else if(j & CTM_Q_MD5_Force) { - if(Force) - fprintf(stderr," Can and will force.\n"); - else - fprintf(stderr," Could have forced.\n"); - ret |= Exit_Forcible; - } else { - ret |= Exit_NotOK; - } - } - break; - } else if(j & CTM_Q_MD5_After) { - if(md5 == NULL) { - GETFIELDCOPY(md5,sep); - } - break; - } - /* Unqualified MD5 */ - WRONG - break; - case CTM_F_Count: - GETBYTECNT(cnt,sep); - break; - case CTM_F_Bytes: - if(cnt < 0) WRONG - GETDATA(trash,cnt); - if (!match) - break; - if (!template) { - if (asprintf(&template, "%s/CTMclientXXXXXX", - TmpDir) == -1) { - fprintf(stderr, " %s: malloc failed.\n", - sp->Key); - ret |= Exit_Mess; - return ret; - } - } - if(!strcmp(sp->Key,"FN")) { - if ((p = strdup(template)) == NULL) { - fprintf(stderr, " %s: malloc failed.\n", - sp->Key); - ret |= Exit_Mess; - return ret; - } - if ((fdesc = mkstemp(p)) == -1) { - fprintf(stderr, " %s: mkstemp failed.\n", - sp->Key); - ret |= Exit_Mess; - Free(p); - return ret; - } - if (close(fdesc) == -1) { - fprintf(stderr, " %s: close failed.\n", - sp->Key); - ret |= Exit_Mess; - unlink(p); - Free(p); - return ret; - } - j = ctm_edit(trash,cnt,name,p); - if(j) { - fprintf(stderr," %s: %s edit returned %d.\n", - sp->Key,name,j); - ret |= j; - unlink(p); - Free(p); - return ret; - } else if(strcmp(md5,MD5File(p,md5_1))) { - fprintf(stderr," %s: %s edit fails.\n", - sp->Key,name); - ret |= Exit_Mess; - unlink(p); - Free(p); - return ret; - } - unlink(p); - Free(p); - } else if (!strcmp(sp->Key,"FE")) { - if ((p = strdup(template)) == NULL) { - fprintf(stderr, " %s: malloc failed.\n", - sp->Key); - ret |= Exit_Mess; - return ret; - } - if ((fdesc = mkstemp(p)) == -1) { - fprintf(stderr, " %s: mkstemp failed.\n", - sp->Key); - ret |= Exit_Mess; - Free(p); - return ret; - } - if (close(fdesc) == -1) { - fprintf(stderr, " %s: close failed.\n", - sp->Key); - ret |= Exit_Mess; - unlink(p); - Free(p); - return ret; - } - ed = popen("ed","w"); - if (!ed) { - WRONG - } - fprintf(ed,"e %s\n", name); - if (cnt != fwrite(trash,1,cnt,ed)) { - warn("%s", name); - pclose(ed); - WRONG - } - fprintf(ed,"w %s\n",p); - if (pclose(ed)) { - warn("%s", p); - WRONG - } - if(strcmp(md5,MD5File(p,md5_1))) { - fprintf(stderr,"%s %s MD5 didn't come out right\n", - sp->Key, name); - WRONG - } - unlink(p); - Free(p); - } - - break; - default: WRONG - } - } - } - - Delete(trash); - Delete(name); - Delete(md5); - - q = MD5End (&ctx,md5_1); - GETFIELD(p,'\n'); /* */ - if(strcmp(q,p)) WRONG - if (-1 != getc(fd)) WRONG - return ret; -} diff --git a/usr.sbin/ctm/ctm/ctm_pass3.c b/usr.sbin/ctm/ctm/ctm_pass3.c deleted file mode 100644 index c13ce94a64d..00000000000 --- a/usr.sbin/ctm/ctm/ctm_pass3.c +++ /dev/null @@ -1,296 +0,0 @@ -/*- - * SPDX-License-Identifier: Beerware - * - * ---------------------------------------------------------------------------- - * "THE BEER-WARE LICENSE" (Revision 42): - * 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 - * ---------------------------------------------------------------------------- - * - * - */ - -#include "ctm.h" -#define BADREAD 32 - -/*---------------------------------------------------------------------------*/ -/* Pass3 -- Validate the incoming CTM-file. - */ - -int -settime(const char *name, const struct timeval *times) -{ - if (SetTime) - if (utimes(name,times)) { - warn("utimes(): %s", name); - return -1; - } - return 0; -} - -int -Pass3(FILE *fd) -{ - u_char *p,*q,buf[BUFSIZ]; - MD5_CTX ctx; - int i,j,sep,cnt; - u_char *md5=0,*md5before=0,*trash=0,*name=0,*uid=0,*gid=0,*mode=0; - struct CTM_Syntax *sp; - FILE *ed=0; - struct stat st; - char md5_1[33]; - int match=0; - struct timeval times[2]; - struct CTM_Filter *filter = NULL; - if(Verbose>3) - printf("Pass3 -- Applying the CTM-patch\n"); - MD5Init (&ctx); - - GETFIELD(p,' '); if(strcmp("CTM_BEGIN",p)) WRONG - GETFIELD(p,' '); if(strcmp(Version,p)) WRONG - GETFIELD(p,' '); if(strcmp(Name,p)) WRONG - GETFIELD(p,' '); if(strcmp(Nbr,p)) WRONG - GETFIELD(p,' '); if(strcmp(TimeStamp,p)) WRONG - GETFIELD(p,'\n'); if(strcmp(Prefix,p)) WRONG - - /* - * This would be cleaner if mktime() worked in UTC rather than - * local time. - */ - if (SetTime) { - struct tm tm; - char *tz; - char buf[5]; - int i; - -#define SUBSTR(off,len) strncpy(buf, &TimeStamp[off], len), buf[len] = '\0' -#define WRONGDATE { fprintf(stderr, " %s failed date validation\n",\ - TimeStamp); WRONG} - - if (strlen(TimeStamp) != 15 || TimeStamp[14] != 'Z') WRONGDATE - for (i = 0; i < 14; i++) - if (!isdigit(TimeStamp[i])) WRONGDATE - - tz = getenv("TZ"); - if (setenv("TZ", "UTC", 1) < 0) WRONG - tzset(); - - tm.tm_isdst = tm.tm_gmtoff = 0; - - SUBSTR(0, 4); - tm.tm_year = atoi(buf) - 1900; - SUBSTR(4, 2); - tm.tm_mon = atoi(buf) - 1; - if (tm.tm_mon < 0 || tm.tm_mon > 11) WRONGDATE - SUBSTR(6, 2); - tm.tm_mday = atoi(buf); - if (tm.tm_mday < 1 || tm.tm_mday > 31) WRONG; - SUBSTR(8, 2); - tm.tm_hour = atoi(buf); - if (tm.tm_hour > 24) WRONGDATE - SUBSTR(10, 2); - tm.tm_min = atoi(buf); - if (tm.tm_min > 59) WRONGDATE - SUBSTR(12, 2); - tm.tm_sec = atoi(buf); - if (tm.tm_min > 62) WRONGDATE /* allow leap seconds */ - - times[0].tv_sec = times[1].tv_sec = mktime(&tm); - if (times[0].tv_sec == -1) WRONGDATE - times[0].tv_usec = times[1].tv_usec = 0; - - if (tz) { - if (setenv("TZ", tz, 1) < 0) WRONGDATE - } else { - unsetenv("TZ"); - } - } - - for(;;) { - Delete(md5); - Delete(uid); - Delete(gid); - Delete(mode); - Delete(md5before); - Delete(trash); - Delete(name); - cnt = -1; - - GETFIELD(p,' '); - - if (p[0] != 'C' || p[1] != 'T' || p[2] != 'M') WRONG - - if(!strcmp(p+3,"_END")) - break; - - for(sp=Syntax;sp->Key;sp++) - if(!strcmp(p+3,sp->Key)) - goto found; - WRONG - found: - for(i=0;(j = sp->List[i]);i++) { - if (sp->List[i+1] && (sp->List[i+1] & CTM_F_MASK) != CTM_F_Bytes) - sep = ' '; - else - sep = '\n'; - - switch (j & CTM_F_MASK) { - case CTM_F_Name: GETNAMECOPY(name,sep,j, Verbose); break; - case CTM_F_Uid: GETFIELDCOPY(uid,sep); break; - case CTM_F_Gid: GETFIELDCOPY(gid,sep); break; - case CTM_F_Mode: GETFIELDCOPY(mode,sep); break; - case CTM_F_MD5: - if(j & CTM_Q_MD5_Before) - GETFIELDCOPY(md5before,sep); - else - GETFIELDCOPY(md5,sep); - break; - case CTM_F_Count: GETBYTECNT(cnt,sep); break; - case CTM_F_Bytes: GETDATA(trash,cnt); break; - default: WRONG - } - } - /* XXX This should go away. Disallow trailing '/' */ - j = strlen(name)-1; - if(name[j] == '/') name[j] = '\0'; - - /* - * If a filter list is specified, run thru the filter list and - * match `name' against filters. If the name matches, set the - * required action to that specified in the filter. - * The default action if no filterlist is given is to match - * everything. - */ - - match = (FilterList ? !(FilterList->Action) : CTM_FILTER_ENABLE); - for (filter = FilterList; filter; filter = filter->Next) { - if (0 == regexec(&filter->CompiledRegex, name, - 0, 0, 0)) { - match = filter->Action; - } - } - - if (CTM_FILTER_DISABLE == match) /* skip file if disabled */ - continue; - - if (Verbose > 0) - fprintf(stderr,"> %s %s\n",sp->Key,name); - if(!strcmp(sp->Key,"FM") || !strcmp(sp->Key, "FS")) { - i = open(name,O_WRONLY|O_CREAT|O_TRUNC,0666); - if(i < 0) { - warn("%s", name); - WRONG - } - if(cnt != write(i,trash,cnt)) { - warn("%s", name); - WRONG - } - close(i); - if(strcmp(md5,MD5File(name,md5_1))) { - fprintf(stderr," %s %s MD5 didn't come out right\n", - sp->Key,name); - WRONG - } - if (settime(name,times)) WRONG - continue; - } - if(!strcmp(sp->Key,"FE")) { - ed = popen("ed","w"); - if(!ed) { - WRONG - } - fprintf(ed,"e %s\n",name); - if(cnt != fwrite(trash,1,cnt,ed)) { - warn("%s", name); - pclose(ed); - WRONG - } - fprintf(ed,"w %s\n",name); - if(pclose(ed)) { - warn("ed"); - WRONG - } - if(strcmp(md5,MD5File(name,md5_1))) { - fprintf(stderr," %s %s MD5 didn't come out right\n", - sp->Key,name); - WRONG - } - if (settime(name,times)) WRONG - continue; - } - if(!strcmp(sp->Key,"FN")) { - strcpy(buf,name); - strcat(buf,TMPSUFF); - i = ctm_edit(trash,cnt,name,buf); - if(i) { - fprintf(stderr," %s %s Edit failed with code %d.\n", - sp->Key,name,i); - WRONG - } - if(strcmp(md5,MD5File(buf,md5_1))) { - fprintf(stderr," %s %s Edit failed MD5 check.\n", - sp->Key,name); - WRONG - } - if (rename(buf,name) == -1) - WRONG - if (settime(name,times)) WRONG - continue; - } - if(!strcmp(sp->Key,"DM")) { - if(0 > mkdir(name,0777)) { - sprintf(buf,"mkdir -p %s",name); - system(buf); - } - if(0 > stat(name,&st) || ((st.st_mode & S_IFMT) != S_IFDIR)) { - fprintf(stderr,"<%s> mkdir failed\n",name); - WRONG - } - if (settime(name,times)) WRONG - continue; - } - if(!strcmp(sp->Key,"FR")) { - if (KeepIt) { - if (Verbose > 1) - printf("<%s> not removed\n", name); - } - else if (0 != unlink(name)) { - fprintf(stderr,"<%s> unlink failed\n",name); - if (!Force) - WRONG - } - continue; - } - if(!strcmp(sp->Key,"DR")) { - /* - * We cannot use rmdir() because we do not get the directories - * in '-depth' order (cvs-cur.0018.gz for examples) - */ - if (KeepIt) { - if (Verbose > 1) { - printf("<%s> not removed\n", name); - } - } else { - sprintf(buf,"rm -rf %s",name); - system(buf); - } - continue; - } - WRONG - } - - Delete(md5); - Delete(uid); - Delete(gid); - Delete(mode); - Delete(md5before); - Delete(trash); - Delete(name); - - q = MD5End (&ctx,md5_1); - GETFIELD(p,'\n'); - if(strcmp(q,p)) WRONG - if (-1 != getc(fd)) WRONG - return 0; -} diff --git a/usr.sbin/ctm/ctm/ctm_passb.c b/usr.sbin/ctm/ctm/ctm_passb.c deleted file mode 100644 index f54cb8b18b0..00000000000 --- a/usr.sbin/ctm/ctm/ctm_passb.c +++ /dev/null @@ -1,143 +0,0 @@ -/*- - * SPDX-License-Identifier: Beerware - * - * ---------------------------------------------------------------------------- - * "THE BEER-WARE LICENSE" (Revision 42): - * 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. Joseph Koshy - * ---------------------------------------------------------------------------- - * - * - */ - -#include "ctm.h" -#define BADREAD 32 - -/*---------------------------------------------------------------------------*/ -/* PassB -- Backup modified files. - */ - -int -PassB(FILE *fd) -{ - u_char *p,*q; - MD5_CTX ctx; - int i,j,sep,cnt; - u_char *md5=0,*md5before=0,*trash=0,*name=0,*uid=0,*gid=0,*mode=0; - struct CTM_Syntax *sp; - FILE *b = 0; /* backup command */ - u_char buf[BUFSIZ]; - char md5_1[33]; - int ret = 0; - int match = 0; - struct CTM_Filter *filter = NULL; - - if(Verbose>3) - printf("PassB -- Backing up files which would be changed.\n"); - - MD5Init (&ctx); - snprintf(buf, sizeof(buf), fmtcheck(TarCmd, TARCMD), BackupFile); - b=popen(buf, "w"); - if(!b) { warn("%s", buf); return Exit_Garbage; } - - GETFIELD(p,' '); if(strcmp("CTM_BEGIN",p)) WRONG - GETFIELD(p,' '); if(strcmp(Version,p)) WRONG - GETFIELD(p,' '); if(strcmp(Name,p)) WRONG - GETFIELD(p,' '); if(strcmp(Nbr,p)) WRONG - GETFIELD(p,' '); if(strcmp(TimeStamp,p)) WRONG - GETFIELD(p,'\n'); if(strcmp(Prefix,p)) WRONG - - for(;;) { - Delete(md5); - Delete(uid); - Delete(gid); - Delete(mode); - Delete(md5before); - Delete(trash); - Delete(name); - cnt = -1; - - GETFIELD(p,' '); - - if (p[0] != 'C' || p[1] != 'T' || p[2] != 'M') WRONG - - if(!strcmp(p+3,"_END")) - break; - - for(sp=Syntax;sp->Key;sp++) - if(!strcmp(p+3,sp->Key)) - goto found; - WRONG - found: - for(i=0;(j = sp->List[i]);i++) { - if (sp->List[i+1] && (sp->List[i+1] & CTM_F_MASK) != CTM_F_Bytes) - sep = ' '; - else - sep = '\n'; - - switch (j & CTM_F_MASK) { - case CTM_F_Name: GETNAMECOPY(name,sep,j, Verbose); break; - case CTM_F_Uid: GETFIELDCOPY(uid,sep); break; - case CTM_F_Gid: GETFIELDCOPY(gid,sep); break; - case CTM_F_Mode: GETFIELDCOPY(mode,sep); break; - case CTM_F_MD5: - if(j & CTM_Q_MD5_Before) - GETFIELDCOPY(md5before,sep); - else - GETFIELDCOPY(md5,sep); - break; - case CTM_F_Count: GETBYTECNT(cnt,sep); break; - case CTM_F_Bytes: GETDATA(trash,cnt); break; - default: WRONG - } - } - /* XXX This should go away. Disallow trailing '/' */ - j = strlen(name)-1; - if(name[j] == '/') name[j] = '\0'; - - if (KeepIt && - (!strcmp(sp->Key,"DR") || !strcmp(sp->Key,"FR"))) - continue; - - /* match the name against the elements of the filter list. The - action associated with the last matched filter determines whether - this file should be ignored or backed up. */ - match = (FilterList ? !(FilterList->Action) : CTM_FILTER_ENABLE); - for (filter = FilterList; filter; filter = filter->Next) { - if (0 == regexec(&filter->CompiledRegex, name, 0, 0, 0)) - match = filter->Action; - } - - if (CTM_FILTER_DISABLE == match) - continue; - - if (!strcmp(sp->Key,"FS") || !strcmp(sp->Key,"FN") || - !strcmp(sp->Key,"AS") || !strcmp(sp->Key,"DR") || - !strcmp(sp->Key,"FR")) { - /* send name to the archiver for a backup */ - cnt = strlen(name); - if (cnt != fwrite(name,1,cnt,b) || EOF == fputc('\n',b)) { - warn("%s", name); - pclose(b); - WRONG; - } - } - } - - ret = pclose(b); - - Delete(md5); - Delete(uid); - Delete(gid); - Delete(mode); - Delete(md5before); - Delete(trash); - Delete(name); - - q = MD5End (&ctx,md5_1); - GETFIELD(p,'\n'); /* */ - if(strcmp(q,p)) WRONG - if (-1 != getc(fd)) WRONG - return ret; -} diff --git a/usr.sbin/ctm/ctm/ctm_syntax.c b/usr.sbin/ctm/ctm/ctm_syntax.c deleted file mode 100644 index c243f89e4a2..00000000000 --- a/usr.sbin/ctm/ctm/ctm_syntax.c +++ /dev/null @@ -1,68 +0,0 @@ -/*- - * SPDX-License-Identifier: Beerware - * - * ---------------------------------------------------------------------------- - * "THE BEER-WARE LICENSE" (Revision 42): - * 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 - * ---------------------------------------------------------------------------- - * - * - */ - -#include "ctm.h" - -/* The fields... */ -#define Name CTM_F_Name -#define Uid CTM_F_Uid -#define Gid CTM_F_Gid -#define Mode CTM_F_Mode -#define MD5 CTM_F_MD5 -#define Count CTM_F_Count -#define Bytes CTM_F_Bytes - -/* The qualifiers... */ -#define File CTM_Q_Name_File -#define Dir CTM_Q_Name_Dir -#define New CTM_Q_Name_New -#define Subst CTM_Q_Name_Subst -#define After CTM_Q_MD5_After -#define Before CTM_Q_MD5_Before -#define Chunk CTM_Q_MD5_Chunk -#define Force CTM_Q_MD5_Force - -static int ctmFM[] = /* File Make */ - { Name|File|New|Subst, Uid, Gid, Mode, - MD5|After|Chunk, Count, Bytes,0 }; - -static int ctmFS[] = /* File Substitute */ - { Name|File|Subst, Uid, Gid, Mode, - MD5|Before|Force, MD5|After|Chunk, Count, Bytes,0 }; - -static int ctmFE[] = /* File Edit */ - { Name|File|Subst, Uid, Gid, Mode, - MD5|Before, MD5|After, Count, Bytes,0 }; - -static int ctmFR[] = /* File Remove */ - { Name|File|Subst, MD5|Before, 0 }; - -static int ctmAS[] = /* Attribute Substitute */ - { Name|Subst, Uid, Gid, Mode, 0 }; - -static int ctmDM[] = /* Directory Make */ - { Name|Dir|New , Uid, Gid, Mode, 0 }; - -static int ctmDR[] = /* Directory Remove */ - { Name|Dir, 0 }; - -struct CTM_Syntax Syntax[] = { - { "FM", ctmFM }, - { "FS", ctmFS }, - { "FE", ctmFE }, - { "FN", ctmFE }, - { "FR", ctmFR }, - { "AS", ctmAS }, - { "DM", ctmDM }, - { "DR", ctmDR }, - { 0, 0} }; diff --git a/usr.sbin/ctm/ctm_dequeue/Makefile b/usr.sbin/ctm/ctm_dequeue/Makefile deleted file mode 100644 index 1390c67625e..00000000000 --- a/usr.sbin/ctm/ctm_dequeue/Makefile +++ /dev/null @@ -1,12 +0,0 @@ - -.PATH: ${.CURDIR:H}/ctm_rmail - -PROG= ctm_dequeue -MAN= -SRCS= ctm_dequeue.c error.c - -CFLAGS+= -I${.CURDIR:H}/ctm_rmail - -WARNS?= 1 - -.include diff --git a/usr.sbin/ctm/ctm_dequeue/Makefile.depend b/usr.sbin/ctm/ctm_dequeue/Makefile.depend deleted file mode 100644 index 84b8ddd67e3..00000000000 --- a/usr.sbin/ctm/ctm_dequeue/Makefile.depend +++ /dev/null @@ -1,16 +0,0 @@ -# Autogenerated - do NOT edit! - -DIRDEPS = \ - gnu/lib/csu \ - include \ - include/xlocale \ - lib/${CSU_DIR} \ - lib/libc \ - lib/libcompiler_rt \ - - -.include - -.if ${DEP_RELDIR} == ${_DEP_RELDIR} -# local dependencies - needed for -jN in clean tree -.endif diff --git a/usr.sbin/ctm/ctm_dequeue/ctm_dequeue.c b/usr.sbin/ctm/ctm_dequeue/ctm_dequeue.c deleted file mode 100644 index df272cdd9b9..00000000000 --- a/usr.sbin/ctm/ctm_dequeue/ctm_dequeue.c +++ /dev/null @@ -1,211 +0,0 @@ -/*- - * SPDX-License-Identifier: BSD-2-Clause-FreeBSD - * - * Copyright (c) 1996, 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 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. - * - */ - -/* - * ctm_dequeue: Dequeue queued delta pieces and mail them. - * - * The pieces have already been packaged up as mail messages by ctm_smail, - * and will be simply passed to sendmail in alphabetical order. - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "error.h" -#include "options.h" - -#define DEFAULT_NUM 1 /* Default number of pieces mailed per run. */ - -int fts_sort(const FTSENT * const *, const FTSENT * const *); -int run_sendmail(int ifd); - -int -main(int argc, char **argv) -{ - char *log_file = NULL; - char *queue_dir = NULL; - char *list[2]; - int num_to_send = DEFAULT_NUM, chunk; - int fd; - FTS *fts; - FTSENT *ftsent; - int piece, npieces; - char filename[PATH_MAX]; - - err_prog_name(argv[0]); - - OPTIONS("[-l log] [-n num] queuedir") - NUMBER('n', num_to_send) - STRING('l', log_file) - ENDOPTS - - if (argc != 2) - usage(); - - if (log_file) - err_set_log(log_file); - - queue_dir = argv[1]; - list[0] = queue_dir; - list[1] = NULL; - - fts = fts_open(list, FTS_PHYSICAL|FTS_COMFOLLOW, fts_sort); - if (fts == NULL) - { - err("fts failed on `%s'", queue_dir); - exit(1); - } - - ftsent = fts_read(fts); - if (ftsent == NULL || ftsent->fts_info != FTS_D) - { - err("not a directory: %s", queue_dir); - exit(1); - } - - ftsent = fts_children(fts, 0); - if (ftsent == NULL && errno) - { - err("*ftschildren failed"); - exit(1); - } - - for (chunk = 1; ftsent != NULL; ftsent = ftsent->fts_link) - { - /* - * Skip non-files and ctm_smail tmp files (ones starting with `.') - */ - if (ftsent->fts_info != FTS_F || ftsent->fts_name[0] == '.') - continue; - - snprintf(filename, sizeof(filename), "%s/%s", queue_dir, - ftsent->fts_name); - fd = open(filename, O_RDONLY); - if (fd < 0) - { - err("*open: %s", filename); - exit(1); - } - - if (run_sendmail(fd)) - exit(1); - - close(fd); - - if (unlink(filename) < 0) - { - err("*unlink: %s", filename); - exit(1); - } - - /* - * Deduce the delta, piece number, and number of pieces from - * the name of the file in the queue. Ideally, we should be - * able to get the mail alias name too. - * - * NOTE: This depends intimately on the queue name used in ctm_smail. - */ - npieces = atoi(&ftsent->fts_name[ftsent->fts_namelen-3]); - piece = atoi(&ftsent->fts_name[ftsent->fts_namelen-7]); - err("%.*s %d/%d sent", (int)(ftsent->fts_namelen-8), ftsent->fts_name, - piece, npieces); - - if (chunk++ == num_to_send) - break; - } - - fts_close(fts); - - return(0); -} - -int -fts_sort(const FTSENT * const * a, const FTSENT * const * b) -{ - if ((*a)->fts_info != FTS_F) - return(0); - if ((*a)->fts_info != FTS_F) - return(0); - - return (strcmp((*a)->fts_name, (*b)->fts_name)); -} - -/* - * Run sendmail with the given file descriptor as standard input. - * Sendmail will decode the destination from the message contents. - * Returns 0 on success, 1 on failure. - */ -int -run_sendmail(int ifd) -{ - pid_t child, pid; - int status; - - switch (child = fork()) - { - case -1: - err("*fork"); - return(1); - - case 0: /* Child */ - dup2(ifd, 0); - execl(_PATH_SENDMAIL, _PATH_SENDMAIL, "-odq", "-t", (char *)NULL); - err("*exec: %s", _PATH_SENDMAIL); - _exit(1); - - default: /* Parent */ - while ((pid = wait(&status)) != child) - { - if (pid == -1 && errno != EINTR) - { - err("*wait"); - return(1); - } - } - if (!WIFEXITED(status) || WEXITSTATUS(status) != 0) - { - err("sendmail failed"); - return(1); - } - } - - return(0); -} diff --git a/usr.sbin/ctm/ctm_rmail/Makefile b/usr.sbin/ctm/ctm_rmail/Makefile deleted file mode 100644 index 6f1a1ba958e..00000000000 --- a/usr.sbin/ctm/ctm_rmail/Makefile +++ /dev/null @@ -1,9 +0,0 @@ - -PROG= ctm_rmail -MLINKS= ctm_rmail.1 ctm_smail.1 \ - ctm_rmail.1 ctm_dequeue.1 -SRCS= ctm_rmail.c error.c - -WARNS?= 2 - -.include diff --git a/usr.sbin/ctm/ctm_rmail/Makefile.depend b/usr.sbin/ctm/ctm_rmail/Makefile.depend deleted file mode 100644 index 84b8ddd67e3..00000000000 --- a/usr.sbin/ctm/ctm_rmail/Makefile.depend +++ /dev/null @@ -1,16 +0,0 @@ -# Autogenerated - do NOT edit! - -DIRDEPS = \ - gnu/lib/csu \ - include \ - include/xlocale \ - lib/${CSU_DIR} \ - lib/libc \ - lib/libcompiler_rt \ - - -.include - -.if ${DEP_RELDIR} == ${_DEP_RELDIR} -# local dependencies - needed for -jN in clean tree -.endif diff --git a/usr.sbin/ctm/ctm_rmail/ctm_rmail.1 b/usr.sbin/ctm/ctm_rmail/ctm_rmail.1 deleted file mode 100644 index 4d591fdbdc0..00000000000 --- a/usr.sbin/ctm/ctm_rmail/ctm_rmail.1 +++ /dev/null @@ -1,509 +0,0 @@ -.\" NOTICE: This is free documentation. I hope you get some use from these -.\" words. In return you should think about all the nice people who sweat -.\" blood to document their free software. Maybe you should write some -.\" documentation and give it away. Maybe with a free program attached! -.\" -.\" Author: Stephen McKay -.\" -.\" -.Dd January 24, 1995 -.Dt CTM_MAIL 1 -.Os -.Sh NAME -.Nm ctm_smail , -.Nm ctm_dequeue , -.Nm ctm_rmail -.Nd send and receive -.Xr ctm 1 -deltas via mail -.Sh SYNOPSIS -.Nm ctm_smail -.Op Fl l Ar log -.Op Fl m Ar maxmsgsize -.Op Fl c Ar maxctmsize -.Op Fl q Ar queue-dir -.Ar ctm-delta -.Ar mail-alias -.Nm ctm_dequeue -.Op Fl l Ar log -.Op Fl n Ar numchunks -.Ar queue-dir -.Nm ctm_rmail -.Op Fl Dfuv -.Op Fl l Ar log -.Op Fl p Ar piecedir -.Op Fl d Ar deltadir -.Op Fl b Ar basedir -.Op Ar -.Sh DESCRIPTION -In conjunction with the -.Xr ctm 1 -command, -.Nm ctm_smail , -.Nm ctm_dequeue -and -.Nm ctm_rmail -are used to distribute changes to a source tree via email. -The -.Nm ctm_smail -utility is given a compressed -.Xr ctm -delta, and a mailing list to send it to. -It splits the delta into manageable -pieces, encodes them as mail messages and sends them to the mailing list -(optionally queued to spread the mail load). -Each recipient uses -.Nm ctm_rmail -(either manually or automatically) to decode and reassemble the delta, and -optionally call -.Xr ctm -to apply it to the source tree. -At the moment, -several source trees are distributed, and by several sites. -These include -the -.Fx Ns -current -source and CVS trees, distributed by -.Li freefall.FreeBSD.org . -.Pp -Command line arguments for -.Nm ctm_smail : -.Bl -tag -width indent -.It Fl l Ar log -Instead of appearing on -.Em stderr , -error diagnostics and informational messages (other than command line errors) -are time stamped and written to the file -.Em log . -.It Fl m Ar maxmsgsize -Limit the maximum size mail message that -.Nm ctm_smail -is allowed to send. -It is approximate since mail headers and other niceties -are not counted in this limit. -If not specified, it will default to 64000 -bytes, leaving room for 1535 bytes of headers before the rumoured 64k mail -limit. -.It Fl c Ar maxctmsize -Limit the maximum size delta that will be sent. -Deltas bigger that this -limit will cause an apology mail message to be sent to the mailing list. -This is to prevent massive changes overwhelming users' mail boxes. -Note that -this is the size before encoding. -Encoding causes a 4/3 size increase before -mail headers are added. -If not specified, there is no limit. -.It Fl q Ar queue-dir -Instead of mailing the delta pieces now, store them in the given directory -to be mailed later using -.Nm ctm_dequeue . -This feature allows the mailing of large deltas to be spread out over -hours or even days to limit the impact on recipients with limited network -bandwidth or small mail spool areas. -.El -.Pp -.Ar ctm-delta -is the delta to be sent, and -.Ar mail-alias -is the mailing list to send the delta to. -The mail messages are sent using -.Xr sendmail 8 . -.Pp -Command line arguments for -.Nm ctm_dequeue : -.Bl -tag -width indent -.It Fl l Ar log -Instead of appearing on -.Em stderr , -error diagnostics and informational messages (other than command line errors) -are time stamped and written to the file -.Em log . -.It Fl n Ar numchunks -Limit the number of mail messages that -.Nm ctm_dequeue -will send per run. -By default, -.Nm ctm_dequeue -will send one mail message per run. -.El -.Pp -.Ar queuedir -is the directory containing the mail messages stored by -.Nm ctm_smail . -Up to -.Ar numchunks -mail messages will be sent in each run. -The recipient mailing list is already -encoded in the queued files. -.Pp -It is safe to run -.Nm ctm_dequeue -while -.Nm ctm_smail -is adding entries to the queue, or even to run -.Nm ctm_smail -multiple times concurrently, but a separate queue directory should be used -for each tree being distributed. -This is because entries are served in -alphabetical order, and one tree will be unfairly serviced before any others, -based on the delta names, not delta creation times. -.Pp -Command line arguments for -.Nm ctm_rmail : -.Bl -tag -width indent -.It Fl l Ar log -Instead of appearing on -.Em stderr , -error diagnostics and informational messages (other than command line errors) -are time stamped and written to the file -.Em log . -.It Fl p Ar piecedir -Collect pieces of deltas in this directory. -Each piece corresponds to a -single mail message. -Pieces are removed when complete deltas are built. -If this flag is not given, no input files will be read, but completed -deltas may still be applied with -.Xr ctm -if the -.Fl b -flag is given. -.It Fl d Ar deltadir -Collect completed deltas in this directory. -Deltas are built from one or -more pieces when all pieces are present. -.It Fl b Ar basedir -Apply any completed deltas to this source tree. -If this flag is not given, -deltas will be stored, but not applied. -The user may then apply the deltas -manually, or by using -.Nm ctm_rmail -without the -.Fl p -flag. -Deltas will not be applied if they do not match the -.Li .ctm_status -file in -.Ar basedir -(or if -.Li .ctm_status -does not exist). -.It Fl D -Delete deltas after successful application by -.Xr ctm . -It is probably a good idea to avoid this flag (and keep all the deltas) as -.Xr ctm -has the ability to recover small groups of files from a full set of deltas. -.It Fl f -Fork and execute in the background while applying deltas with -.Xr ctm . -This is useful when automatically invoking -.Nm ctm_rmail -from -.Xr sendmail -because -.Xr ctm -can take a very long time to complete, causing other people's mail to -be delayed, and can in theory cause spurious -mail retransmission due to the remote -.Xr sendmail -timing out, or even termination of -.Nm ctm_rmail -by mail filters such as -.Xr "MH's" -.Xr slocal . -Do not worry about zillions of background -.Xr ctm -processes loading your machine, since locking is used to prevent more than one -.Xr ctm -invocation at a time. -.It Fl u -Pass the -.Fl u -flag to the -.Xr ctm -command when applying the complete deltas, causing it to set the modification -time of created and modified files to the CTM delta creation time. -.It Fl v -Pass the -.Fl v -flag to the -.Xr ctm -command when applying the complete deltas, causing a more informative -output. -All -.Xr ctm -output appears in the -.Nm ctm_rmail -log file. -.El -.Pp -The file arguments (or -.Em stdin , -if there are none) are scanned for delta pieces. -Multiple delta pieces -can be read from a single file, so an entire maildrop can be scanned -and processed with a single command. -.Pp -It is safe to invoke -.Nm ctm_rmail -multiple times concurrently (with different input files), -as might happen when -.Xr sendmail -is delivering mail asynchronously. -This is because locking is used to -keep things orderly. -.Sh FILE FORMAT -Following are the important parts of an actual (very small) delta piece: -.Bd -literal -From: owner-src-cur -To: src-cur -Subject: ctm-mail src-cur.0003.gz 1/4 - -CTM_MAIL BEGIN src-cur.0003.gz 1 4 -H4sIAAAAAAACA3VU72/bNhD9bP0VByQoEiyRSZEUSQP9kKTeYCR2gDTdsGFAwB/HRogtG5K8NCj6 -v4+UZSdtUQh6Rz0eee/xaF/dzx8up3/MFlDkBNrGnbttAwyo1pxoRgoiBNX/QJ5d3c9/X8DcPGGo -lggkPiXngE4W1gUjKPJCYyk5MZRbIqmNW/ASglIFcdwIzTUxaAqhnCPcBqloKEkJVNDMF0Azk+Bo -dDzzk0Ods/+A5gXv9YyJHjMCtJwQNeESNma7hOmXDRxn -CTM_MAIL END 61065 -.Ed -.Pp -The subject of the message always begins with -.Dq ctm-mail -followed by the name of the delta, which piece this is, and how many total -pieces there are. -The data are bracketed by -.Dq CTM_MAIL BEGIN -and -.Dq CTM_MAIL END -lines, duplicating the information in the subject line, plus a simple checksum. -.Pp -If the delta exceeds -.Ar maxctmsize , -then a message like this will be received instead: -.Bd -literal -From: owner-src-cur -To: src-cur -Subject: ctm-notice src-cur.0999.gz - -src-cur.0999.gz is 792843 bytes. The limit is 300000 bytes. - -You can retrieve this delta via ftp. -.Ed -.Pp -You are then on your own! -.Sh ENVIRONMENT -If deltas are to be applied then -.Xr ctm 1 -and -.Xr gunzip 1 -must be in your -.Ev PATH . -.Sh FILES -.Bl -tag -width indent -.It Pa QUEUEDIR/* -Pieces of deltas encoded as mail messages waiting to be sent to the -mailing list. -.It Pa PIECEDIR/* -Pieces of deltas waiting for the rest to arrive. -.It Pa DELTADIR/* -Completed deltas. -.It Pa BASEDIR/.ctm_status -File containing the name and number of the next delta to be applied to this -source tree. -.El -.Sh EXIT STATUS -The -.Nm ctm_smail , -.Nm ctm_dequeue -and -.Nm ctm_rmail -utilities return exit status 0 for success, and 1 for various failures. -The -.Nm ctm_rmail -utility is expected to be called from a mail transfer program, and thus signals -failure only when the input mail message should be bounced (preferably into -your regular maildrop, not back to the sender). -In short, failure to -apply a completed delta with -.Xr ctm -is not considered an error important enough to bounce the mail, and -.Nm ctm_rmail -returns an exit status of 0. -.Sh EXAMPLES -To send delta 32 of -.Em src-cur -to a group of wonderful code hackers known to -.Xr sendmail -as -.Em src-guys , -limiting the mail size to roughly 60000 bytes, you could use: -.Bd -literal -offset indent -ctm_smail -m 60000 /wherever/it/is/src-cur.0032.gz src-guys -.Ed -.Pp -To decode every -.Nm ctm-mail -message in your mailbox, assemble them into complete deltas, then apply -any deltas built or lying around, you could use: -.Bd -literal -offset indent -ctm_rmail -p ~/pieces -d ~/deltas -b /usr/ctm-src-cur $MAIL -.Ed -.Pp -(Note that no messages are deleted by -.Nm ctm_rmail . -Any mail reader could be used for that purpose.) -.Pp -To create a mail alias called -.Em receiver-dude -that will automatically decode and assemble deltas, but not apply them, -you could put the following lines in your -.Pa /etc/mail/aliases -file (assuming the -.Pa /ctm/tmp -and -.Pa /ctm/deltas -directories and -.Pa /ctm/log -file are writable by user -.Em daemon -or group -.Em wheel ) : -.Bd -literal -offset indent -receiver-dude: "|ctm_rmail -p /ctm/tmp -d /ctm/deltas -l /ctm/log" -owner-receiver-dude: real_dude@wherever.you.like -.Ed -.Pp -The second line will catch failures and drop them into your regular mailbox, -or wherever else you like. -.Pp -To apply all the deltas collected, and delete those applied, you could use: -.Bd -literal -offset indent -ctm_rmail -D -d /ctm/deltas -b /ctm/src-cur -l /ctm/apply.log -.Ed -.Pp -For maximum flexibility, consider this excerpt from a -.Xr procmail -script: -.Bd -literal -offset indent -PATH=$HOME/bin:$PATH - -:0 w -* ^Subject: ctm-mail cvs-cur -| ctm_incoming -.Ed -.Pp -together with the -shell script -.Pa ~/bin/ctm_incoming : -.Bd -literal -offset indent -#! /bin/sh -PATH="$HOME/bin:/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin" -export PATH - -cd $HOME/ctm && ctm_rmail -f -p pieces -d deltas -l log -b /ctm -.Ed -.Pp -which will deposit all -.Xr ctm -deltas in -.Pa ~/ctm/deltas , -apply them to the tree in -.Pa /ctm , -and drop any failures into your regular mail box. -Note the -.Ev PATH -manipulation in -.Pa ctm_incoming -which allows -.Nm ctm_rmail -to execute -.Xr ctm 1 -on the -.Pq non- Ns Fx -machine that this example was taken from. -.Sh SECURITY -On its own, CTM is an insecure protocol -- there is no authentication performed that the -changes applied to the source code were sent by a -trusted party, and so care should be taken if the -CTM deltas are obtained via an unauthenticated -medium such as regular email. -It is a relatively simple matter for an attacker -to forge a CTM delta to replace or precede the -legitimate one and insert malicious code into your -source tree. -If the legitimate delta is somehow prevented from -arriving, this will go unnoticed until a later -delta attempts to touch the same file, at which -point the MD5 checksum will fail. -.Pp -To remedy this insecurity, CTM delta pieces generated by -FreeBSD.org are cryptographically signed in a -format compatible with the GNU Privacy Guard -utility, available in /usr/ports/security/gpg, and -the Pretty Good Privacy v5 utility, -/usr/ports/security/pgp5. -The relevant public key can be obtained by -fingering ctm@FreeBSD.org. -.Pp -CTM deltas which are thus signed cannot be -undetectably altered by an attacker. -Therefore it is recommended that you make use of -GPG or PGP5 to verify the signatures if you -receive your CTM deltas via email. -.Sh DIAGNOSTICS -In normal operation, -.Nm ctm_smail -will report messages like: -.Bd -literal -offset indent -ctm_smail: src-cur.0250.gz 1/2 sent to src-guys -.Ed -.Pp -or, if queueing, -.Bd -literal -offset indent -ctm_smail: src-cur.0250.gz 1/2 queued for src-guys -.Ed -.Pp -The -.Nm ctm_dequeue -utility will report messages like: -.Bd -literal -offset indent -ctm_dequeue: src-cur.0250.gz 1/2 sent -.Ed -.Pp -The -.Nm ctm_rmail -utility will report messages like: -.Bd -literal -offset indent -ctm_rmail: src-cur.0250.gz 1/2 stored -ctm_rmail: src-cur.0250.gz 2/2 stored -ctm_rmail: src-cur.0250.gz complete -.Ed -.Pp -If any of the input files do not contain a valid delta piece, -.Nm ctm_rmail -will report: -.Bd -literal -offset indent -ctm_rmail: message contains no delta -.Ed -.Pp -and return an exit status of 1. -You can use this to redirect wayward messages -back into your real mailbox if your mail filter goes wonky. -.Pp -These messages go to -.Em stderr -or to the log file. -Messages from -.Xr ctm 1 -turn up here too. -Error messages should be self explanatory. -.Sh SEE ALSO -.Xr ctm 1 , -.Xr ctm 5 -.\" .Sh HISTORY -.Sh AUTHORS -.An Stephen McKay Aq Mt mckay@FreeBSD.org diff --git a/usr.sbin/ctm/ctm_rmail/ctm_rmail.c b/usr.sbin/ctm/ctm_rmail/ctm_rmail.c deleted file mode 100644 index 5eaefeeb4d7..00000000000 --- a/usr.sbin/ctm/ctm_rmail/ctm_rmail.c +++ /dev/null @@ -1,671 +0,0 @@ -/* - * Accept one (or more) ASCII encoded chunks that together make a compressed - * CTM delta. Decode them and reconstruct the deltas. Any completed - * deltas may be passed to ctm for unpacking. - * - * Author: Stephen McKay - * - * NOTICE: This is free software. I hope you get some use from this program. - * In return you should think about all the nice people who give away software. - * Maybe you should write some free software too. - * - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "error.h" -#include "options.h" - -#define CTM_STATUS ".ctm_status" - -char *piece_dir = NULL; /* Where to store pieces of deltas. */ -char *delta_dir = NULL; /* Where to store completed deltas. */ -char *base_dir = NULL; /* The tree to apply deltas to. */ -int delete_after = 0; /* Delete deltas after ctm applies them. */ -int apply_verbose = 0; /* Run with '-v' */ -int set_time = 0; /* Set the time of the files that is changed. */ -int mask = 0; /* The current umask */ - -void apply_complete(void); -int read_piece(char *input_file); -int combine_if_complete(char *delta, int pce, int npieces); -int combine(char *delta, int npieces, char *dname, char *pname, char *tname); -int decode_line(char *line, char *out_buf); -int lock_file(char *name); - -/* - * If given a '-p' flag, read encoded delta pieces from stdin or file - * arguments, decode them and assemble any completed deltas. If given - * a '-b' flag, pass any completed deltas to 'ctm' for application to - * the source tree. The '-d' flag is mandatory, but either of '-p' or - * '-b' can be omitted. If given the '-l' flag, notes and errors will - * be timestamped and written to the given file. - * - * Exit status is 0 for success or 1 for indigestible input. That is, - * 0 means the encode input pieces were decoded and stored, and 1 means - * some input was discarded. If a delta fails to apply, this won't be - * reflected in the exit status. In this case, the delta is left in - * 'deltadir'. - */ -int -main(int argc, char **argv) - { - char *log_file = NULL; - int status = 0; - int fork_ctm = 0; - - mask = umask(0); - umask(mask); - - err_prog_name(argv[0]); - - OPTIONS("[-Dfuv] [-p piecedir] [-d deltadir] [-b basedir] [-l log] [file ...]") - FLAG('D', delete_after) - FLAG('f', fork_ctm) - FLAG('u', set_time) - FLAG('v', apply_verbose) - STRING('p', piece_dir) - STRING('d', delta_dir) - STRING('b', base_dir) - STRING('l', log_file) - ENDOPTS - - if (delta_dir == NULL) - usage(); - - if (piece_dir == NULL && (base_dir == NULL || argc > 1)) - usage(); - - if (log_file != NULL) - err_set_log(log_file); - - /* - * Digest each file in turn, or just stdin if no files were given. - */ - if (argc <= 1) - { - if (piece_dir != NULL) - status = read_piece(NULL); - } - else - { - while (*++argv != NULL) - status |= read_piece(*argv); - } - - /* - * Maybe it's time to look for and apply completed deltas with ctm. - * - * Shall we report back to sendmail immediately, and let a child do - * the work? Sendmail will be waiting for us to complete, delaying - * other mail, and possibly some intermediate process (like MH slocal) - * will terminate us if we take too long! - * - * If fork() fails, it's unlikely we'll be able to run ctm, so give up. - * Also, the child exit status is unimportant. - */ - if (base_dir != NULL) - if (!fork_ctm || fork() == 0) - apply_complete(); - - return status; - } - - -/* - * Construct the file name of a piece of a delta. - */ -#define mk_piece_name(fn,d,p,n) \ - sprintf((fn), "%s/%s+%03d-%03d", piece_dir, (d), (p), (n)) - -/* - * Construct the file name of an assembled delta. - */ -#define mk_delta_name(fn,d) \ - sprintf((fn), "%s/%s", delta_dir, (d)) - -/* - * If the next required delta is now present, let ctm lunch on it and any - * contiguous deltas. - */ -void -apply_complete() - { - int i, dn; - int lfd; - FILE *fp, *ctm; - struct stat sb; - char class[20]; - char delta[30]; - char junk[2]; - char fname[PATH_MAX]; - char here[PATH_MAX]; - char buf[PATH_MAX*2]; - - /* - * Grab a lock on the ctm mutex file so that we can be sure we are - * working alone, not fighting another ctm_rmail! - */ - strcpy(fname, delta_dir); - strcat(fname, "/.mutex_apply"); - if ((lfd = lock_file(fname)) < 0) - return; - - /* - * Find out which delta ctm needs next. - */ - sprintf(fname, "%s/%s", base_dir, CTM_STATUS); - if ((fp = fopen(fname, "r")) == NULL) - { - close(lfd); - return; - } - - i = fscanf(fp, "%19s %d %c", class, &dn, junk); - fclose(fp); - if (i != 2) - { - close(lfd); - return; - } - - /* - * We might need to convert the delta filename to an absolute pathname. - */ - here[0] = '\0'; - if (delta_dir[0] != '/') - { - getcwd(here, sizeof(here)-1); - i = strlen(here) - 1; - if (i >= 0 && here[i] != '/') - { - here[++i] = '/'; - here[++i] = '\0'; - } - } - - /* - * Keep applying deltas until we run out or something bad happens. - */ - for (;;) - { - sprintf(delta, "%s.%04d.gz", class, ++dn); - mk_delta_name(fname, delta); - - if (stat(fname, &sb) < 0) - break; - - sprintf(buf, "(cd %s && ctm %s%s%s%s) 2>&1", base_dir, - set_time ? "-u " : "", - apply_verbose ? "-v " : "", here, fname); - if ((ctm = popen(buf, "r")) == NULL) - { - err("ctm failed to apply %s", delta); - break; - } - - while (fgets(buf, sizeof(buf), ctm) != NULL) - { - i = strlen(buf) - 1; - if (i >= 0 && buf[i] == '\n') - buf[i] = '\0'; - err("ctm: %s", buf); - } - - if (pclose(ctm) != 0) - { - err("ctm failed to apply %s", delta); - break; - } - - if (delete_after) - unlink(fname); - - err("%s applied%s", delta, delete_after ? " and deleted" : ""); - } - - /* - * Closing the lock file clears the lock. - */ - close(lfd); - } - - -/* - * This cheap plastic checksum effectively rotates our checksum-so-far - * left one, then adds the character. We only want 16 bits of it, and - * don't care what happens to the rest. It ain't much, but it's small. - */ -#define add_ck(sum,x) \ - ((sum) += ((x)&0xff) + (sum) + (((sum)&0x8000) ? 1 : 0)) - - -/* - * Decode the data between BEGIN and END, and stash it in the staging area. - * Multiple pieces can be present in a single file, bracketed by BEGIN/END. - * If we have all pieces of a delta, combine them. Returns 0 on success, - * and 1 for any sort of failure. - */ -int -read_piece(char *input_file) - { - int status = 0; - FILE *ifp, *ofp = 0; - int decoding = 0; - int got_one = 0; - int line_no = 0; - int i, n; - int pce, npieces; - unsigned claimed_cksum; - unsigned short cksum = 0; - char out_buf[200]; - char line[200]; - char delta[30]; - char pname[PATH_MAX]; - char tname[PATH_MAX]; - char junk[2]; - - ifp = stdin; - if (input_file != NULL && (ifp = fopen(input_file, "r")) == NULL) - { - err("cannot open '%s' for reading", input_file); - return 1; - } - - while (fgets(line, sizeof(line), ifp) != NULL) - { - line_no++; - - /* - * Remove all trailing white space. - */ - i = strlen(line) - 1; - while (i > 0 && isspace(line[i])) - line[i--] = '\0'; - - /* - * Look for the beginning of an encoded piece. - */ - if (!decoding) - { - char *s; - int fd = -1; - - if (sscanf(line, "CTM_MAIL BEGIN %29s %d %d %c", - delta, &pce, &npieces, junk) != 3) - continue; - - while ((s = strchr(delta, '/')) != NULL) - *s = '_'; - - got_one++; - strcpy(tname, piece_dir); - strcat(tname, "/p.XXXXXXXXXX"); - if ((fd = mkstemp(tname)) == -1 || - (ofp = fdopen(fd, "w")) == NULL) - { - if (fd != -1) { - err("cannot open '%s' for writing", tname); - close(fd); - } - else - err("*mkstemp: '%s'", tname); - status++; - continue; - } - - cksum = 0xffff; - decoding++; - continue; - } - - /* - * We are decoding. Stop if we see the end flag. - */ - if (sscanf(line, "CTM_MAIL END %d %c", &claimed_cksum, junk) == 1) - { - int e; - - decoding = 0; - - fflush(ofp); - e = ferror(ofp); - fclose(ofp); - - if (e) - err("error writing %s", tname); - - if (cksum != claimed_cksum) - err("checksum: read %d, calculated %d", claimed_cksum, cksum); - - if (e || cksum != claimed_cksum) - { - err("%s %d/%d discarded", delta, pce, npieces); - unlink(tname); - status++; - continue; - } - - mk_piece_name(pname, delta, pce, npieces); - if (rename(tname, pname) < 0) - { - err("*rename: '%s' to '%s'", tname, pname); - err("%s %d/%d lost!", delta, pce, npieces); - unlink(tname); - status++; - continue; - } - - err("%s %d/%d stored", delta, pce, npieces); - - if (!combine_if_complete(delta, pce, npieces)) - status++; - continue; - } - - /* - * Must be a line of encoded data. Decode it, sum it, and save it. - */ - n = decode_line(line, out_buf); - if (n <= 0) - { - err("line %d: illegal character: '%c'", line_no, line[-n]); - err("%s %d/%d discarded", delta, pce, npieces); - - fclose(ofp); - unlink(tname); - - status++; - decoding = 0; - continue; - } - - for (i = 0; i < n; i++) - add_ck(cksum, out_buf[i]); - - fwrite(out_buf, sizeof(char), n, ofp); - } - - if (decoding) - { - err("truncated file"); - err("%s %d/%d discarded", delta, pce, npieces); - - fclose(ofp); - unlink(tname); - - status++; - } - - if (ferror(ifp)) - { - err("error reading %s", input_file == NULL ? "stdin" : input_file); - status++; - } - - if (input_file != NULL) - fclose(ifp); - - if (!got_one) - { - err("message contains no delta"); - status++; - } - - return (status != 0); - } - - -/* - * Put the pieces together to form a delta, if they are all present. - * Returns 1 on success (even if we didn't do anything), and 0 on failure. - */ -int -combine_if_complete(char *delta, int pce, int npieces) - { - int i, e; - int lfd; - struct stat sb; - char pname[PATH_MAX]; - char dname[PATH_MAX]; - char tname[PATH_MAX]; - - /* - * We can probably just rename() it into place if it is a small delta. - */ - if (npieces == 1) - { - mk_delta_name(dname, delta); - mk_piece_name(pname, delta, 1, 1); - if (rename(pname, dname) == 0) - { - chmod(dname, 0666 & ~mask); - err("%s complete", delta); - return 1; - } - } - - /* - * Grab a lock on the reassembly mutex file so that we can be sure we are - * working alone, not fighting another ctm_rmail! - */ - strcpy(tname, delta_dir); - strcat(tname, "/.mutex_build"); - if ((lfd = lock_file(tname)) < 0) - return 0; - - /* - * Are all of the pieces present? Of course the current one is, - * unless all pieces are missing because another ctm_rmail has - * processed them already. - */ - for (i = 1; i <= npieces; i++) - { - if (i == pce) - continue; - mk_piece_name(pname, delta, i, npieces); - if (stat(pname, &sb) < 0) - { - close(lfd); - return 1; - } - } - - /* - * Stick them together. Let combine() use our file name buffers, since - * we're such good buddies. :-) - */ - e = combine(delta, npieces, dname, pname, tname); - close(lfd); - return e; - } - - -/* - * Put the pieces together to form a delta. - * Returns 1 on success, and 0 on failure. - * Note: dname, pname, and tname are room for some file names that just - * happened to by lying around in the calling routine. Waste not, want not! - */ -int -combine(char *delta, int npieces, char *dname, char *pname, char *tname) - { - FILE *dfp, *pfp; - int i, n, e; - char buf[BUFSIZ]; - int fd = -1; - - strcpy(tname, delta_dir); - strcat(tname, "/d.XXXXXXXXXX"); - if ((fd = mkstemp(tname)) == -1 || - (dfp = fdopen(fd, "w")) == NULL) - { - if (fd != -1) { - close(fd); - err("cannot open '%s' for writing", tname); - } - else - err("*mkstemp: '%s'", tname); - return 0; - } - - /* - * Reconstruct the delta by reading each piece in order. - */ - for (i = 1; i <= npieces; i++) - { - mk_piece_name(pname, delta, i, npieces); - if ((pfp = fopen(pname, "r")) == NULL) - { - err("cannot open '%s' for reading", pname); - fclose(dfp); - unlink(tname); - return 0; - } - while ((n = fread(buf, sizeof(char), sizeof(buf), pfp)) != 0) - fwrite(buf, sizeof(char), n, dfp); - e = ferror(pfp); - fclose(pfp); - if (e) - { - err("error reading '%s'", pname); - fclose(dfp); - unlink(tname); - return 0; - } - } - fflush(dfp); - e = ferror(dfp); - fclose(dfp); - if (e) - { - err("error writing '%s'", tname); - unlink(tname); - return 0; - } - - mk_delta_name(dname, delta); - if (rename(tname, dname) < 0) - { - err("*rename: '%s' to '%s'", tname, dname); - unlink(tname); - return 0; - } - chmod(dname, 0666 & ~mask); - - /* - * Throw the pieces away. - */ - for (i = 1; i <= npieces; i++) - { - mk_piece_name(pname, delta, i, npieces); - if (unlink(pname) < 0) - err("*unlink: '%s'", pname); - } - - err("%s complete", delta); - return 1; - } - - -/* - * MIME BASE64 decode table. - */ -static unsigned char from_b64[0x80] = - { - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0x3e, 0xff, 0xff, 0xff, 0x3f, - 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3a, 0x3b, - 0x3c, 0x3d, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, - 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, - 0x0f, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, - 0x17, 0x18, 0x19, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, 0x20, - 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, - 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f, 0x30, - 0x31, 0x32, 0x33, 0xff, 0xff, 0xff, 0xff, 0xff - }; - - -/* - * Decode a line of ASCII into binary. Returns the number of bytes in - * the output buffer, or < 0 on indigestable input. Error output is - * the negative of the index of the inedible character. - */ -int -decode_line(char *line, char *out_buf) - { - unsigned char *ip = (unsigned char *)line; - unsigned char *op = (unsigned char *)out_buf; - unsigned long bits; - unsigned x; - - for (;;) - { - if (*ip >= 0x80 || (x = from_b64[*ip]) >= 0x40) - break; - bits = x << 18; - ip++; - if (*ip < 0x80 && (x = from_b64[*ip]) < 0x40) - { - bits |= x << 12; - *op++ = bits >> 16; - ip++; - if (*ip < 0x80 && (x = from_b64[*ip]) < 0x40) - { - bits |= x << 6; - *op++ = bits >> 8; - ip++; - if (*ip < 0x80 && (x = from_b64[*ip]) < 0x40) - { - bits |= x; - *op++ = bits; - ip++; - } - } - } - } - - if (*ip == '\0' || *ip == '\n') - return op - (unsigned char *)out_buf; - else - return -(ip - (unsigned char *)line); - } - - -/* - * Create and lock the given file. - * - * Clearing the lock is as simple as closing the file descriptor we return. - */ -int -lock_file(char *name) - { - int lfd; - - if ((lfd = open(name, O_WRONLY|O_CREAT, 0600)) < 0) - { - err("*open: '%s'", name); - return -1; - } - if (flock(lfd, LOCK_EX) < 0) - { - close(lfd); - err("*flock: '%s'", name); - return -1; - } - return lfd; - } diff --git a/usr.sbin/ctm/ctm_rmail/error.c b/usr.sbin/ctm/ctm_rmail/error.c deleted file mode 100644 index 8976571cab2..00000000000 --- a/usr.sbin/ctm/ctm_rmail/error.c +++ /dev/null @@ -1,97 +0,0 @@ -/* - * Routines for logging error messages or other informative messages. - * - * Log messages can easily contain the program name, a time stamp, system - * error messages, and arbitrary printf-style strings, and can be directed - * to stderr or a log file. - * - * Author: Stephen McKay - * - * NOTICE: This is free software. I hope you get some use from this program. - * In return you should think about all the nice people who give away software. - * Maybe you should write some free software too. - */ - -#include -#include -#include -#include -#include -#include "error.h" - -static FILE *error_fp = NULL; -static char *prog = NULL; - - -/* - * Log errors to the given file. - */ -void -err_set_log(char *log_file) - { - FILE *fp; - - if ((fp = fopen(log_file, "a")) == NULL) - err("cannot log to '%s'", log_file); - else - error_fp = fp; - } - - -/* - * Set the error prefix if not logging to a file. - */ -void -err_prog_name(char *name) - { - if ((prog = strrchr(name, '/')) == NULL) - prog = name; - else - prog++; - } - - -/* - * Log an error. - * - * A leading '*' in the message format means we want the system errno - * decoded and appended. - */ -void -err(const char *fmt, ...) - { - va_list ap; - time_t now; - struct tm *tm; - FILE *fp; - int x = errno; - int want_errno; - - if ((fp = error_fp) == NULL) - { - fp = stderr; - if (prog != NULL) - fprintf(fp, "%s: ", prog); - } - else - { - time(&now); - tm = localtime(&now); - fprintf(fp, "%04d-%02d-%02d %02d:%02d ", tm->tm_year+1900, - tm->tm_mon+1, tm->tm_mday, tm->tm_hour, tm->tm_min); - } - - want_errno = 0; - if (*fmt == '*') - want_errno++, fmt++; - - va_start(ap, fmt); - vfprintf(fp, fmt, ap); - va_end(ap); - - if (want_errno) - fprintf(fp, ": %s", strerror(x)); - - fprintf(fp, "\n"); - fflush(fp); - } diff --git a/usr.sbin/ctm/ctm_rmail/error.h b/usr.sbin/ctm/ctm_rmail/error.h deleted file mode 100644 index aa1f530e70d..00000000000 --- a/usr.sbin/ctm/ctm_rmail/error.h +++ /dev/null @@ -1,4 +0,0 @@ - -extern void err_set_log(char *log_file); -extern void err_prog_name(char *name); -extern void err(const char *fmt, ...) __printflike(1, 2); diff --git a/usr.sbin/ctm/ctm_rmail/options.h b/usr.sbin/ctm/ctm_rmail/options.h deleted file mode 100644 index b782a983ad9..00000000000 --- a/usr.sbin/ctm/ctm_rmail/options.h +++ /dev/null @@ -1,138 +0,0 @@ -/* - * Macros for processing command arguments. - * - * Conforms closely to the command option requirements of intro(1) in System V - * and intro(C) in Xenix. - * - * A command consists of: cmdname [ options ] [ cmdarguments ] - * - * Options consist of a leading dash '-' and a flag letter. An argument may - * follow optionally preceded by white space. - * Options without arguments may be grouped behind a single dash. - * A dash on its own is interpreted as the end of the options and is retained - * as a command argument. - * A double dash '--' is interpreted as the end of the options and is discarded. - * - * For example: - * zap -xz -f flame -q34 -- -x - * - * where zap.c contains the following in main(): - * - * OPTIONS("[-xz] [-q queue-id] [-f dump-file] user") - * FLAG('x', xecute) - * FLAG('z', zot) - * STRING('f', file) - * fp = fopen(file, "w"); - * NUMBER('q', queue) - * ENDOPTS - * - * Results in: - * xecute = 1 - * zot = 1 - * file = "flame" - * fp = fopen("flame", "w") - * queue = 34 - * argc = 2 - * argv[0] = "zap" - * argv[1] = "-x" - * - * Should the user enter unknown flags or leave out required arguments, - * the message: - * - * Usage: zap [-xz] [-q queue-id] [-f dump-file] user - * - * will be printed. This message can be printed by calling pusage(), or - * usage(). usage() will also cause program termination with exit code 1. - * - * Author: Stephen McKay, February 1991 - * - * Based on recollection of the original options.h produced at the University - * of Queensland by Ross Patterson (and possibly others). - * - */ - -static char *O_usage; -static char *O_name; -extern long atol(); - -void -pusage() - { - /* - * Avoid gratuitously loading stdio. - */ - write(STDERR_FILENO, "usage: ", 7); - write(STDERR_FILENO, O_name, strlen(O_name)); - write(STDERR_FILENO, " ", 1); - write(STDERR_FILENO, O_usage, strlen(O_usage)); - write(STDERR_FILENO, "\n", 1); - } - -#define usage() (pusage(), exit(1)) - -#define OPTIONS(usage_msg) \ - { \ - char O_cont; \ - O_usage = (usage_msg); \ - O_name = argv[0]; \ - while (*++argv && **argv == '-') \ - { \ - if ((*argv)[1] == '\0') \ - break; \ - argc--; \ - if ((*argv)[1] == '-' && (*argv)[2] == '\0') \ - { \ - argv++; \ - break; \ - } \ - O_cont = 1; \ - while (O_cont) \ - switch (*++*argv) \ - { \ - default: \ - case '-': \ - usage(); \ - case '\0': \ - O_cont = 0; - -#define FLAG(x,flag) \ - break; \ - case (x): \ - (flag) = 1; - -#define CHAR(x,ch) \ - break; \ - case (x): \ - O_cont = 0; \ - if (*++*argv == '\0' && (--argc, *++argv == 0)) \ - usage(); \ - (ch) = **argv; - -#define NUMBER(x,n) \ - break; \ - case (x): \ - O_cont = 0; \ - if (*++*argv == '\0' && (--argc, *++argv == 0)) \ - usage(); \ - (n) = atol(*argv); - -#define STRING(x,str) \ - break; \ - case (x): \ - O_cont = 0; \ - if (*++*argv == '\0' && (--argc, *++argv == 0)) \ - usage(); \ - (str) = *argv; - -#define SUFFIX(x,str) \ - break; \ - case (x): \ - (str) = ++*argv; \ - O_cont = 0; - -#define ENDOPTS \ - break; \ - } \ - } \ - *--argv = O_name; \ - } diff --git a/usr.sbin/ctm/ctm_smail/Makefile b/usr.sbin/ctm/ctm_smail/Makefile deleted file mode 100644 index a489ee8225d..00000000000 --- a/usr.sbin/ctm/ctm_smail/Makefile +++ /dev/null @@ -1,12 +0,0 @@ - -.PATH: ${.CURDIR:H}/ctm_rmail - -PROG= ctm_smail -MAN= -SRCS= ctm_smail.c error.c - -CFLAGS+= -I${.CURDIR:H}/ctm_rmail - -WARNS?= 2 - -.include diff --git a/usr.sbin/ctm/ctm_smail/Makefile.depend b/usr.sbin/ctm/ctm_smail/Makefile.depend deleted file mode 100644 index 84b8ddd67e3..00000000000 --- a/usr.sbin/ctm/ctm_smail/Makefile.depend +++ /dev/null @@ -1,16 +0,0 @@ -# Autogenerated - do NOT edit! - -DIRDEPS = \ - gnu/lib/csu \ - include \ - include/xlocale \ - lib/${CSU_DIR} \ - lib/libc \ - lib/libcompiler_rt \ - - -.include - -.if ${DEP_RELDIR} == ${_DEP_RELDIR} -# local dependencies - needed for -jN in clean tree -.endif diff --git a/usr.sbin/ctm/ctm_smail/ctm_smail.c b/usr.sbin/ctm/ctm_smail/ctm_smail.c deleted file mode 100644 index 8cb54dc718d..00000000000 --- a/usr.sbin/ctm/ctm_smail/ctm_smail.c +++ /dev/null @@ -1,496 +0,0 @@ -/* - * Send a compressed CTM delta to a recipient mailing list by encoding it - * in safe ASCII characters, in mailer-friendly chunks, and passing them - * to sendmail. Optionally, the chunks can be queued to be sent later by - * ctm_dequeue in controlled bursts. The encoding is almost the same as - * MIME BASE64, and is protected by a simple checksum. - * - * Author: Stephen McKay - * - * NOTICE: This is free software. I hope you get some use from this program. - * In return you should think about all the nice people who give away software. - * Maybe you should write some free software too. - * - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "error.h" -#include "options.h" - -#define DEF_MAX_MSG 64000 /* Default maximum mail msg minus headers. */ - -#define LINE_LENGTH 72 /* Chars per encoded line. Divisible by 4. */ - -int chop_and_send_or_queue(FILE *dfp, char *delta, off_t ctm_size, - long max_msg_size, char *mail_alias, char *queue_dir); -int chop_and_send(FILE *dfp, char *delta, long msg_size, int npieces, - char *mail_alias); -int chop_and_queue(FILE *dfp, char *delta, long msg_size, int npieces, - char *mail_alias, char *queue_dir); -void clean_up_queue(char *queue_dir); -int encode_body(FILE *sm_fp, FILE *delta_fp, long msg_size, unsigned *sum); -void write_header(FILE *sfp, char *mail_alias, char *delta, int pce, - int npieces); -void write_trailer(FILE *sfp, unsigned sum); -int apologise(char *delta, off_t ctm_size, long max_ctm_size, - char *mail_alias, char *queue_dir); -FILE *open_sendmail(void); -int close_sendmail(FILE *fp); - -int -main(int argc, char **argv) - { - int status = 0; - char *delta_file; - char *mail_alias; - long max_msg_size = DEF_MAX_MSG; - long max_ctm_size = 0; - char *log_file = NULL; - char *queue_dir = NULL; - char *delta; - FILE *dfp; - struct stat sb; - - err_prog_name(argv[0]); - - OPTIONS("[-l log] [-m maxmsgsize] [-c maxctmsize] [-q queuedir] ctm-delta mail-alias") - NUMBER('m', max_msg_size) - NUMBER('c', max_ctm_size) - STRING('l', log_file) - STRING('q', queue_dir) - ENDOPTS - - if (argc != 3) - usage(); - - if (log_file != NULL) - err_set_log(log_file); - - delta_file = argv[1]; - mail_alias = argv[2]; - - if ((delta = strrchr(delta_file, '/')) == NULL) - delta = delta_file; - else - delta++; - - if ((dfp = fopen(delta_file, "r")) == NULL || fstat(fileno(dfp), &sb) < 0) - { - err("*%s", delta_file); - exit(1); - } - - if (max_ctm_size != 0 && sb.st_size > max_ctm_size) - status = apologise(delta, sb.st_size, max_ctm_size, mail_alias, - queue_dir); - else - status = chop_and_send_or_queue(dfp, delta, sb.st_size, max_msg_size, - mail_alias, queue_dir); - - fclose(dfp); - - return status; - } - - -/* - * Carve our CTM delta into pieces, encode them, and send or queue them. - * Returns 0 on success, and 1 on failure. - */ -int -chop_and_send_or_queue(FILE *dfp, char *delta, off_t ctm_size, - long max_msg_size, char *mail_alias, char *queue_dir) - { - int npieces; - long msg_size; - long exp_size; - int status; - -#undef howmany -#define howmany(x,y) (((x)+((y)-1)) / (y)) - - /* - * Work out how many pieces we need, bearing in mind that each piece - * grows by 4/3 when encoded. We count the newlines too, but ignore - * all mail headers and piece headers. They are a "small" (almost - * constant) per message overhead that we make the user worry about. :-) - */ - exp_size = ctm_size * 4 / 3; - exp_size += howmany(exp_size, LINE_LENGTH); - npieces = howmany(exp_size, max_msg_size); - msg_size = howmany(ctm_size, npieces); - -#undef howmany - - if (queue_dir == NULL) - status = chop_and_send(dfp, delta, msg_size, npieces, mail_alias); - else - { - status = chop_and_queue(dfp, delta, msg_size, npieces, mail_alias, - queue_dir); - if (status) - clean_up_queue(queue_dir); - } - - return status; - } - - -/* - * Carve our CTM delta into pieces, encode them, and send them. - * Returns 0 on success, and 1 on failure. - */ -int -chop_and_send(FILE *dfp, char *delta, long msg_size, int npieces, - char *mail_alias) - { - int pce; - FILE *sfp; - unsigned sum; - - /* - * Send each chunk directly to sendmail as it is generated. - * No temporary files necessary. If things turn ugly, we just - * have to live with the fact the we have sent only part of - * the delta. - */ - for (pce = 1; pce <= npieces; pce++) - { - int read_error; - - if ((sfp = open_sendmail()) == NULL) - return 1; - - write_header(sfp, mail_alias, delta, pce, npieces); - read_error = encode_body(sfp, dfp, msg_size, &sum); - if (!read_error) - write_trailer(sfp, sum); - - if (!close_sendmail(sfp) || read_error) - return 1; - - err("%s %d/%d sent to %s", delta, pce, npieces, mail_alias); - } - - return 0; - } - - -/* - * Construct the tmp queue file name of a delta piece. - */ -#define mk_tmp_name(fn,qd,p) \ - snprintf((fn), sizeof(fn), "%s/.%08ld.%03d", (qd), (long)getpid(), (p)) - -/* - * Construct the final queue file name of a delta piece. - */ -#define mk_queue_name(fn,qd,d,p,n) \ - snprintf((fn), sizeof(fn), "%s/%s+%03d-%03d", (qd), (d), (p), (n)) - -/* - * Carve our CTM delta into pieces, encode them, and queue them. - * Returns 0 on success, and 1 on failure. - */ -int -chop_and_queue(FILE *dfp, char *delta, long msg_size, int npieces, - char *mail_alias, char *queue_dir) - { - int pce; - FILE *qfp; - unsigned sum; - char tname[PATH_MAX]; - char qname[PATH_MAX]; - - /* - * Store each piece in the queue directory, but under temporary names, - * so that they can be deleted without unpleasant consequences if - * anything goes wrong. We could easily fill up a disk, for example. - */ - for (pce = 1; pce <= npieces; pce++) - { - int write_error; - - mk_tmp_name(tname, queue_dir, pce); - if ((qfp = fopen(tname, "w")) == NULL) - { - err("cannot open '%s' for writing", tname); - return 1; - } - - write_header(qfp, mail_alias, delta, pce, npieces); - if (encode_body(qfp, dfp, msg_size, &sum)) - return 1; - write_trailer(qfp, sum); - - fflush(qfp); - write_error = ferror(qfp); - fclose(qfp); - if (write_error) - { - err("error writing '%s'", tname); - return 1; - } - - /* - * Give the warm success message now, instead of all in a rush - * during the rename phase. - */ - err("%s %d/%d queued for %s", delta, pce, npieces, mail_alias); - } - - /* - * Rename the pieces into place. If an error occurs now, we are - * stuffed, but there is no neat way to back out. rename() should - * only fail now under extreme circumstances. - */ - for (pce = 1; pce <= npieces; pce++) - { - mk_tmp_name(tname, queue_dir, pce); - mk_queue_name(qname, queue_dir, delta, pce, npieces); - if (rename(tname, qname) < 0) - { - err("*rename: '%s' to '%s'", tname, qname); - unlink(tname); - } - } - - return 0; - } - - -/* - * There may be temporary files cluttering up the queue directory. - */ -void -clean_up_queue(char *queue_dir) - { - int pce; - char tname[PATH_MAX]; - - err("discarding queued delta pieces"); - for (pce = 1; ; pce++) - { - mk_tmp_name(tname, queue_dir, pce); - if (unlink(tname) < 0) - break; - } - } - - -/* - * MIME BASE64 encode table. - */ -static char to_b64[0x40] = - "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; - -/* - * This cheap plastic checksum effectively rotates our checksum-so-far - * left one, then adds the character. We only want 16 bits of it, and - * don't care what happens to the rest. It ain't much, but it's small. - */ -#define add_ck(sum,x) \ - ((sum) += ((x)&0xff) + (sum) + (((sum)&0x8000) ? 1 : 0)) - -/* - * Encode the body. Use an encoding almost the same as MIME BASE64. - * - * Characters are read from delta_fp and encoded characters are written - * to sm_fp. At most 'msg_size' characters should be read from delta_fp. - * - * The body consists of lines of up to LINE_LENGTH characters. Each group - * of 4 characters encodes 3 input characters. Each output character encodes - * 6 bits. Thus 64 different characters are needed in this representation. - */ -int -encode_body(FILE *sm_fp, FILE *delta_fp, long msg_size, unsigned *sum) - { - unsigned short cksum = 0xffff; - unsigned char *ip; - char *op; - int want, n, i; - unsigned char inbuf[LINE_LENGTH*3/4]; - char outbuf[LINE_LENGTH+1]; - - /* - * Round up to the nearest line boundary, for the tiniest of gains, - * and lots of neatness. :-) - */ - msg_size += (LINE_LENGTH*3/4) - 1; - msg_size -= msg_size % (LINE_LENGTH*3/4); - - while (msg_size > 0) - { - want = (msg_size < sizeof(inbuf)) ? msg_size : sizeof(inbuf); - if ((n = fread(inbuf, sizeof(char), want, delta_fp)) == 0) - break; - msg_size -= n; - - for (i = 0; i < n; i++) - add_ck(cksum, inbuf[i]); - - /* - * Produce a line of encoded data. Every line length will be a - * multiple of 4, except for, perhaps, the last line. - */ - ip = inbuf; - op = outbuf; - while (n >= 3) - { - *op++ = to_b64[ip[0] >> 2]; - *op++ = to_b64[(ip[0] << 4 & 0x3f) | ip[1] >> 4]; - *op++ = to_b64[(ip[1] << 2 & 0x3f) | ip[2] >> 6]; - *op++ = to_b64[ip[2] & 0x3f]; - ip += 3; - n -= 3; - } - if (n > 0) - { - *op++ = to_b64[ip[0] >> 2]; - *op++ = to_b64[(ip[0] << 4 & 0x3f) | ip[1] >> 4]; - if (n >= 2) - *op++ = to_b64[ip[1] << 2 & 0x3f]; - } - *op++ = '\n'; - fwrite(outbuf, sizeof(char), op - outbuf, sm_fp); - } - - if (ferror(delta_fp)) - { - err("error reading input file."); - return 1; - } - - *sum = cksum; - - return 0; - } - - -/* - * Write the mail header and data header. - */ -void -write_header(FILE *sfp, char *mail_alias, char *delta, int pce, int npieces) - { - fprintf(sfp, "From: owner-%s\n", mail_alias); - fprintf(sfp, "To: %s\n", mail_alias); - fprintf(sfp, "Subject: ctm-mail %s %d/%d\n\n", delta, pce, npieces); - - fprintf(sfp, "CTM_MAIL BEGIN %s %d %d\n", delta, pce, npieces); - } - - -/* - * Write the data trailer. - */ -void -write_trailer(FILE *sfp, unsigned sum) - { - fprintf(sfp, "CTM_MAIL END %ld\n", (long)sum); - } - - -/* - * We're terribly sorry, but the delta is too big to send. - * Returns 0 on success, 1 on failure. - */ -int -apologise(char *delta, off_t ctm_size, long max_ctm_size, char *mail_alias, - char *queue_dir) - { - FILE *sfp; - char qname[PATH_MAX]; - - if (queue_dir == NULL) - { - sfp = open_sendmail(); - if (sfp == NULL) - return 1; - } - else - { - mk_queue_name(qname, queue_dir, delta, 1, 1); - sfp = fopen(qname, "w"); - if (sfp == NULL) - { - err("cannot open '%s' for writing", qname); - return 1; - } - } - - - fprintf(sfp, "From: owner-%s\n", mail_alias); - fprintf(sfp, "To: %s\n", mail_alias); - fprintf(sfp, "Subject: ctm-notice %s\n\n", delta); - - fprintf(sfp, "%s is %ld bytes. The limit is %ld bytes.\n\n", delta, - (long)ctm_size, max_ctm_size); - fprintf(sfp, "You can retrieve this delta via ftp.\n"); - - if (queue_dir == NULL) - { - if (!close_sendmail(sfp)) - return 1; - } - else - { - if (fclose(sfp)!=0) - { - err("error writing '%s'", qname); - unlink(qname); - return 1; - } - } - - return 0; - } - - -/* - * Start a pipe to sendmail. Sendmail will decode the destination - * from the message contents. - */ -FILE * -open_sendmail() - { - FILE *fp; - char buf[100]; - - sprintf(buf, "%s -odq -t", _PATH_SENDMAIL); - if ((fp = popen(buf, "w")) == NULL) - err("cannot start sendmail"); - return fp; - } - - -/* - * Close a pipe to sendmail. Sendmail will then do its bit. - * Return 1 on success, 0 on failure. - */ -int -close_sendmail(FILE *fp) - { - int status; - - fflush(fp); - if (ferror(fp)) - { - err("error writing to sendmail"); - return 0; - } - - if ((status = pclose(fp)) != 0) - err("sendmail failed with status %d", status); - - return (status == 0); - } diff --git a/usr.sbin/ctm/mkCTM/Makefile b/usr.sbin/ctm/mkCTM/Makefile deleted file mode 100644 index 371f93fb064..00000000000 --- a/usr.sbin/ctm/mkCTM/Makefile +++ /dev/null @@ -1,24 +0,0 @@ - -PROG= mkctm -MAN= - -LIBADD= md - -test: mkctm - rm -f tst.out* - time ./mkctm -v -v /3c/210src /a/r1/usr/src \ - 2>a | md5 -p > /a/tst.out - ls -l /a/tst.out - gzip -9 -v /a/tst.out - ls -l /a/tst.out.gz - # cd /usr/src/release && ctm -c -v -v ${.CURDIR}/tst.out - -test1: mkctm - rm -f tst.out* - time ./mkctm -v -v /3c/210src /home/ncvs/src \ - 2> b | md5 -p > /a/tst2.out - ls -l /a/tst2.out - gzip -9 -v /a/tst2.out - ls -l /a/tst2.out.gz - -.include diff --git a/usr.sbin/ctm/mkCTM/ctm_conf.cvs-cur b/usr.sbin/ctm/mkCTM/ctm_conf.cvs-cur deleted file mode 100644 index fbb5bf26ce7..00000000000 --- a/usr.sbin/ctm/mkCTM/ctm_conf.cvs-cur +++ /dev/null @@ -1,9 +0,0 @@ -#!/usr/local/bin/tclsh - -set CTMname cvs-cur -set CTMref /home/ncvs -set CTMignore {^src/secure|^src/eBones|^src/kerberosIV|^CVSROOT/val-tags$|CVSROOT/\\.#} -set CTMbogus {\\.core$|/#cvs|/\\.#} -set CTMmail ctm-cvs-cur-fast@freebsd.org -set CTMqueuemail ctm-cvs-cur@freebsd.org -set CTMqueue /home/ctm/queue/ctm-cvs-cur diff --git a/usr.sbin/ctm/mkCTM/ctm_conf.gnats b/usr.sbin/ctm/mkCTM/ctm_conf.gnats deleted file mode 100644 index c2223f02cd1..00000000000 --- a/usr.sbin/ctm/mkCTM/ctm_conf.gnats +++ /dev/null @@ -1,8 +0,0 @@ -#!/usr/local/bin/tclsh - -#set CTMfirst 1 -set CTMname gnats -set CTMref /home/gnats -set CTMdest $CTMSW/../CTM-pub/$CTMname -set CTMignore {\\.lock$} -set CTMmail ctm-gnats@freebsd.org diff --git a/usr.sbin/ctm/mkCTM/ctm_conf.ports-cur b/usr.sbin/ctm/mkCTM/ctm_conf.ports-cur deleted file mode 100644 index b9d3d13a102..00000000000 --- a/usr.sbin/ctm/mkCTM/ctm_conf.ports-cur +++ /dev/null @@ -1,7 +0,0 @@ -#!/usr/local/bin/tclsh - -set CTMname ports-cur -set CTMref /usr/ports -set CTMignore {/CVS$|/CVS/|^distfiles} -set CTMbogus {\\.core$|/#cvs|/\\.#} -set CTMmail ctm-ports-cur@freebsd.org diff --git a/usr.sbin/ctm/mkCTM/ctm_conf.smp-cur b/usr.sbin/ctm/mkCTM/ctm_conf.smp-cur deleted file mode 100644 index 5c3e1d1bf21..00000000000 --- a/usr.sbin/ctm/mkCTM/ctm_conf.smp-cur +++ /dev/null @@ -1,7 +0,0 @@ -#!/usr/local/bin/tclsh - -set CTMname smp-cur -set CTMref /home/smp -set CTMignore {^CVSROOT/history.*$|^CVSROOT/val-tags$|^CVSROOT/\\.#} -set CTMbogus {\\.core$|/#cvs|/\\.#} -set CTMmail smp-cvs-cur@freebsd.org diff --git a/usr.sbin/ctm/mkCTM/ctm_conf.src-cur b/usr.sbin/ctm/mkCTM/ctm_conf.src-cur deleted file mode 100644 index 8589d040efb..00000000000 --- a/usr.sbin/ctm/mkCTM/ctm_conf.src-cur +++ /dev/null @@ -1,9 +0,0 @@ -#!/usr/local/bin/tclsh - -set CTMname src-cur -set CTMref /c/src -set CTMignore {/CVS$|/CVS/|^/secure|^/eBones} -set CTMbogus {\\.core$|/#cvs|/\\.#} -set CTMmail ctm-src-cur-fast@freebsd.org -set CTMqueue /home/ctm/queue/ctm-src-cur -set CTMqueuemail ctm-src-cur@freebsd.org diff --git a/usr.sbin/ctm/mkCTM/ctm_conf.src-special b/usr.sbin/ctm/mkCTM/ctm_conf.src-special deleted file mode 100644 index 2a8ca70aeb6..00000000000 --- a/usr.sbin/ctm/mkCTM/ctm_conf.src-special +++ /dev/null @@ -1,9 +0,0 @@ -#!/usr/local/bin/tclsh - -set CTMname src-cur -set CTMref $CTMSW/../$CTMname -set CTMcopy /c/phk/20R/usr/src -set CTMdont {\.core$|/CVS$|/CVS/|^/secure|^/eBones|/#cvs|/\.#} -set CTMtest 1 -set CTMspecial 1 -set CTMsuff R20 diff --git a/usr.sbin/ctm/mkCTM/dequeue b/usr.sbin/ctm/mkCTM/dequeue deleted file mode 100755 index be165829893..00000000000 --- a/usr.sbin/ctm/mkCTM/dequeue +++ /dev/null @@ -1,5 +0,0 @@ -#! /bin/sh - -L=/home/ctm/log.dequeue -/usr/sbin/ctm_dequeue -n 1 -l $L /home/ctm/queue/ctm-cvs-cur -/usr/sbin/ctm_dequeue -n 1 -l $L /home/ctm/queue/ctm-src-cur diff --git a/usr.sbin/ctm/mkCTM/mkCTM b/usr.sbin/ctm/mkCTM/mkCTM deleted file mode 100644 index 45e72d65b37..00000000000 --- a/usr.sbin/ctm/mkCTM/mkCTM +++ /dev/null @@ -1,187 +0,0 @@ -#!/usr/local/bin/tclsh7.4 -# - -############################################################################# -### Do we already have this delta ? -############################################################################# - -proc find_delta {nbr} { - global CTMname CTMdest - if {[file exists [format "%s/$CTMname.%04d" $CTMdest $nbr]]} { return 1 } - if {[file exists [format "%s/$CTMname.%04d.gz" $CTMdest $nbr]]} { return 1 } - return 0 -} - -############################################################################# -### The top level code... -############################################################################# - -set CTMSW /home/ctm/SW - -cd $CTMSW - -# Defaults... -set CTMapply 1 -set CTMignore {^///} -set CTMbogus {\.core$} -set CTMmail {} -set CTMqueue {} -set CTMqueuemail {} -set CTMmaxctm 10000000 -set CTMmaxmsg 100000 -set CTMsuff {} -set CTMdate [exec date -u +%Y%m%d%H%M%SZ] -set CTMtmp {} -set CTMcopy {} -set CTMdest {} -set CTMprefix . -set CTMtest 0 -set CTMspecial 0 -set CTMscan . -set CTMfirst 0 -set max_damage 100 - -set damage 0 -set changes 0 - -source $argv -exec sh -c "date -u '+%Y%m%d%H%M%S $argv'" >> ${CTMSW}/log - -if {$CTMtmp == ""} { - set CTMtmp $CTMSW/../tmp/${CTMname}_${CTMsuff} -} -if {$CTMcopy == ""} { - set CTMcopy $CTMSW/../$CTMname -} -if {$CTMdest == ""} { - set CTMdest $CTMSW/../CTM-pub/$CTMname -} - -# Make sure we only run one at a time... - -set CTMlock Lck.${CTMname}.${CTMdate}.[pid] -exec rm -f ${CTMlock} -exec echo starting > ${CTMlock} -if {[catch "exec ln $CTMlock LCK.$CTMname" a]} { - puts "Not going, lock exists..." - exec rm -f $CTMlock - exit 1 -} -exec rm -f $CTMlock -set CTMlock LCK.$CTMname - -set CTMscratch ${CTMtmp}.tmp - -while 1 { - if { ! $CTMspecial} { - if {$CTMfirst} { - set CTMnbr 0 - } else { - set CTMnbr [lindex [exec cat $CTMcopy/.ctm_status] 1] - } - - if {$CTMnbr > 0 && ![find_delta $CTMnbr]} { - puts "$CTMname delta $CTMnbr doesn't exist..." - exec rm -f $CTMlock - exit 1 - } - - incr CTMnbr - - if {[find_delta $CTMnbr]} { - puts "$CTMname delta $CTMnbr does already exist..." - exec rm -f $CTMlock - exit 1 - } - - set fo [open $CTMref/.ctm_status w] - puts $fo "$CTMname $CTMnbr" - close $fo - incr changes -1 - - } else { - set CTMnbr [lindex [exec cat $CTMref/.ctm_status] 1] - } - - puts "Doing CTMname $CTMname CTMnbr $CTMnbr$CTMsuff CTMdate $CTMdate" - flush stdout - exec sh -c "rm -f ${CTMtmp}.* ${CTMtmp}:*" >&@ stdout - - set nm [format "%s.%04d%s" $CTMname $CTMnbr $CTMsuff] - - set x1 $CTMcopy - if {$x1 == ""} { - exec mkdir ${CTMtmp}.dir - set x1 ${CTMtmp}.dir - } - set r1 [catch "exec ${CTMSW}/mkctm -I ${CTMignore} -B ${CTMbogus} -l ${CTMtmp}.log -D $max_damage $CTMname $CTMnbr $CTMdate . $x1 $CTMref | md5 -p | gzip -9 > ${CTMtmp}:${nm}.gz 2>@ stderr" r2] - - if {$r1} { - if {[lindex $errorCode 2] == 4} { - puts "No changes, stopping." - exec rm -f $CTMlock - exit 0 - } - puts "problems, stopping now." - puts "errorCode $errorCode" - puts "$r2" - exec rm -f $CTMlock - exit 1 - } - - puts "mkctm done" - - if {$CTMtest} { - puts "testing, stopping now." - exec rm -f $CTMlock - exit 0 - } - if {$CTMapply} { - puts "Applying delta" - flush stdout - exec echo now applying > $CTMlock - exec sh -e -c "cd $CTMcopy ; $CTMSW/ctm -v -v -v ${CTMtmp}:${nm}.gz" >& ${CTMtmp}.apply - exec echo did apply > $CTMlock - } - puts "Moving delta" - flush stdout - exec mv ${CTMtmp}:${nm}.gz $CTMdest/.CTMtmp_${nm}.gz >&@ stdout - exec mv $CTMdest/.CTMtmp_${nm}.gz $CTMdest/${nm}.gz >&@ stdout - exec echo moved > $CTMlock - - exec sh -c "rm -rf ${CTMtmp}.*" >&@ stdout - - if {$CTMmail != ""} { - puts "Mailing delta" - flush stdout - exec $CTMSW/ctm_smail -m $CTMmaxmsg -c $CTMmaxctm $CTMdest/${nm}.gz $CTMmail >&@ stdout - if {$CTMqueue != "" && $CTMqueuemail != ""} { - puts "Queueing delta" - flush stdout - exec $CTMSW/ctm_smail -m $CTMmaxmsg -c $CTMmaxctm -q $CTMqueue $CTMdest/${nm}.gz $CTMqueuemail >&@ stdout - puts "Sending initial two deltas" - flush stdout - exec $CTMSW/ctm_dequeue -n 2 $CTMqueue >&@ stdout - } - } - exec echo mailed > $CTMlock - - # If we did an absolute delta: stop. - if {$CTMsuff != ""} break - - # Make an absolute delta (!) every 100 deltas - if {$CTMnbr == 0 || ($CTMnbr % 100)} break - - # Make an absolute delta too... - set CTMref $CTMcopy - set CTMsuff A - set CTMcopy "" - set CTMmail "" - set CTMqueue "" - set CTMqueuemail "" - set CTMapply 0 - set CTMspecial 1 - exec rm -f $CTMlock -} -puts "done." -exec rm -f $CTMlock diff --git a/usr.sbin/ctm/mkCTM/mkctm.c b/usr.sbin/ctm/mkCTM/mkctm.c deleted file mode 100644 index 6a8e10bda04..00000000000 --- a/usr.sbin/ctm/mkCTM/mkctm.c +++ /dev/null @@ -1,595 +0,0 @@ - -/* Still missing: - * - * mkctm - * -B regex Bogus - * -I regex Ignore - * -D int Damage - * -q decrease verbosity - * -v increase verbosity - * -l file logfile - * name cvs-cur - * prefix src/secure - * dir1 "Soll" - * dir2 "Ist" - * - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#define DEFAULT_IGNORE "/CVS$|/\\.#|00_TRANS\\.TBL$" -#define DEFAULT_BOGUS "\\.core$|\\.orig$|\\.rej$|\\.o$" -regex_t reg_ignore, reg_bogus; -int flag_ignore, flag_bogus; - -int verbose; -int damage, damage_limit; -int change; - -FILE *logf; - -u_long s1_ignored, s2_ignored; -u_long s1_bogus, s2_bogus; -u_long s1_wrong, s2_wrong; -u_long s_new_dirs, s_new_files, s_new_bytes; -u_long s_del_dirs, s_del_files, s_del_bytes; -u_long s_files_chg, s_bytes_add, s_bytes_del; -u_long s_same_dirs, s_same_files, s_same_bytes; -u_long s_edit_files, s_edit_bytes, s_edit_saves; -u_long s_sub_files, s_sub_bytes; - -void -Usage(void) -{ - fprintf(stderr, - "usage: mkctm [-options] name number timestamp prefix dir1 dir2\n"); - fprintf(stderr, "options:\n"); - fprintf(stderr, "\t\t-B bogus_regexp\n"); - fprintf(stderr, "\t\t-D damage_limit\n"); - fprintf(stderr, "\t\t-I ignore_regexp\n"); - fprintf(stderr, "\t\t-q\n"); - fprintf(stderr, "\t\t-v\n"); -} - -void -print_stat(FILE *fd, char *pre) -{ - fprintf(fd, "%sNames:\n", pre); - fprintf(fd, "%s ignore: %5lu ref %5lu target\n", - pre, s1_ignored, s2_ignored); - fprintf(fd, "%s bogus: %5lu ref %5lu target\n", - pre, s1_bogus, s2_bogus); - fprintf(fd, "%s wrong: %5lu ref %5lu target\n", - pre, s1_wrong, s2_wrong); - fprintf(fd, "%sDelta:\n", pre); - fprintf(fd, "%s new: %5lu dirs %5lu files %9lu plus\n", - pre, s_new_dirs, s_new_files, s_new_bytes); - fprintf(fd, "%s del: %5lu dirs %5lu files %9lu minus\n", - pre, s_del_dirs, s_del_files, s_del_bytes); - fprintf(fd, "%s chg: %5lu files %9lu plus %9lu minus\n", - pre, s_files_chg, s_bytes_add, s_bytes_del); - fprintf(fd, "%s same: %5lu dirs %5lu files %9lu bytes\n", - pre, s_same_dirs, s_same_files, s_same_bytes); - fprintf(fd, "%sMethod:\n", pre); - fprintf(fd, "%s edit: %5lu files %9lu bytes %9lu saved\n", - pre, s_edit_files, s_edit_bytes, s_edit_saves); - fprintf(fd, "%s sub: %5lu files %9lu bytes\n", - pre, s_sub_files, s_sub_bytes); - -} - -void -stat_info(int foo) -{ - signal(SIGINFO, stat_info); - print_stat(stderr, "INFO: "); -} - -void DoDir(const char *dir1, const char *dir2, const char *name); - -static struct stat st; -static __inline struct stat * -StatFile(char *name) -{ - if (lstat(name, &st) < 0) - err(1, "couldn't stat %s", name); - return &st; -} - -int -dirselect(struct dirent *de) -{ - if (!strcmp(de->d_name, ".")) return 0; - if (!strcmp(de->d_name, "..")) return 0; - return 1; -} - -void -name_stat(const char *pfx, const char *dir, const char *name, struct dirent *de) -{ - char *buf = alloca(strlen(dir) + strlen(name) + - strlen(de->d_name) + 3); - struct stat *st; - - strcpy(buf, dir); - strcat(buf, "/"); strcat(buf, name); - strcat(buf, "/"); strcat(buf, de->d_name); - st = StatFile(buf); - printf("%s %s%s %u %u %o", - pfx, name, de->d_name, - st->st_uid, st->st_gid, st->st_mode & ~S_IFMT); - fprintf(logf, "%s %s%s\n", pfx, name, de->d_name); - if (verbose > 1) { - fprintf(stderr, "%s %s%s\n", pfx, name, de->d_name); - } -} - -void -Equ(const char *dir1, const char *dir2, const char *name, struct dirent *de) -{ - if (de->d_type == DT_DIR) { - char *p = alloca(strlen(name)+strlen(de->d_name)+2); - - strcpy(p, name); strcat(p, de->d_name); strcat(p, "/"); - DoDir(dir1, dir2, p); - s_same_dirs++; - } else { - char *buf1 = alloca(strlen(dir1) + strlen(name) + - strlen(de->d_name) + 3); - char *buf2 = alloca(strlen(dir2) + strlen(name) + - strlen(de->d_name) + 3); - char *m1, md5_1[33], *m2, md5_2[33]; - u_char *p1, *p2; - int fd1, fd2; - struct stat s1, s2; - - strcpy(buf1, dir1); - strcat(buf1, "/"); strcat(buf1, name); - strcat(buf1, "/"); strcat(buf1, de->d_name); - fd1 = open(buf1, O_RDONLY); - if(fd1 < 0) { err(3, "%s", buf1); } - fstat(fd1, &s1); - strcpy(buf2, dir2); - strcat(buf2, "/"); strcat(buf2, name); - strcat(buf2, "/"); strcat(buf2, de->d_name); - fd2 = open(buf2, O_RDONLY); - if(fd2 < 0) { err(3, "%s", buf2); } - fstat(fd2, &s2); -#if 0 - /* XXX if we could just trust the size to change... */ - if (s1.st_size == s2.st_size) { - s_same_files++; - s_same_bytes += s1.st_size; - close(fd1); - close(fd2); - goto finish; - } -#endif - p1=mmap(0, s1.st_size, PROT_READ, MAP_PRIVATE, fd1, 0); - if (p1 == (u_char *)MAP_FAILED) { err(3, "%s", buf1); } - close(fd1); - - p2=mmap(0, s2.st_size, PROT_READ, MAP_PRIVATE, fd2, 0); - if (p2 == (u_char *)MAP_FAILED) { err(3, "%s", buf2); } - close(fd2); - - /* If identical, we're done. */ - if((s1.st_size == s2.st_size) && !memcmp(p1, p2, s1.st_size)) { - s_same_files++; - s_same_bytes += s1.st_size; - goto finish; - } - - s_files_chg++; - change++; - if (s1.st_size > s2.st_size) - s_bytes_del += (s1.st_size - s2.st_size); - else - s_bytes_add += (s2.st_size - s1.st_size); - - m1 = MD5Data(p1, s1.st_size, md5_1); - m2 = MD5Data(p2, s2.st_size, md5_2); - - /* Just a curiosity... */ - if(!strcmp(m1, m2)) { - if (s1.st_size != s2.st_size) - fprintf(stderr, - "Notice: MD5 same for files of diffent size:\n\t%s\n\t%s\n", - buf1, buf2); - goto finish; - } - - { - u_long l = s2.st_size + 2; - u_char *cmd = alloca(strlen(buf1)+strlen(buf2)+100); - u_char *ob = malloc(l), *p; - int j; - FILE *F; - - if (s1.st_size && p1[s1.st_size-1] != '\n') { - if (verbose > 0) - fprintf(stderr, - "last char != \\n in %s\n", - buf1); - goto subst; - } - - if (s2.st_size && p2[s2.st_size-1] != '\n') { - if (verbose > 0) - fprintf(stderr, - "last char != \\n in %s\n", - buf2); - goto subst; - } - - for (p=p1; p 0) - fprintf(stderr, - "NULL char in %s\n", - buf1); - goto subst; - } - - for (p=p2; p 0) - fprintf(stderr, - "NULL char in %s\n", - buf2); - goto subst; - } - - strcpy(cmd, "diff -n "); - strcat(cmd, buf1); - strcat(cmd, " "); - strcat(cmd, buf2); - F = popen(cmd, "r"); - for (j = 1, l = 0; l < s2.st_size; ) { - j = fread(ob+l, 1, s2.st_size - l, F); - if (j < 1) - break; - l += j; - continue; - } - if (j) { - l = 0; - while (EOF != fgetc(F)) - continue; - } - pclose(F); - - if (l && l < s2.st_size) { - name_stat("CTMFN", dir2, name, de); - printf(" %s %s %d\n", m1, m2, (unsigned)l); - fwrite(ob, 1, l, stdout); - putchar('\n'); - s_edit_files++; - s_edit_bytes += l; - s_edit_saves += (s2.st_size - l); - } else { - subst: - name_stat("CTMFS", dir2, name, de); - printf(" %s %s %u\n", m1, m2, (unsigned)s2.st_size); - fwrite(p2, 1, s2.st_size, stdout); - putchar('\n'); - s_sub_files++; - s_sub_bytes += s2.st_size; - } - free(ob); - } - finish: - munmap(p1, s1.st_size); - munmap(p2, s2.st_size); - } -} - -void -Add(const char *dir1, const char *dir2, const char *name, struct dirent *de) -{ - change++; - if (de->d_type == DT_DIR) { - char *p = alloca(strlen(name)+strlen(de->d_name)+2); - strcpy(p, name); strcat(p, de->d_name); strcat(p, "/"); - name_stat("CTMDM", dir2, name, de); - putchar('\n'); - s_new_dirs++; - DoDir(dir1, dir2, p); - } else if (de->d_type == DT_REG) { - char *buf2 = alloca(strlen(dir2) + strlen(name) + - strlen(de->d_name) + 3); - char *m2, md5_2[33]; - u_char *p1; - struct stat st; - int fd1; - - strcpy(buf2, dir2); - strcat(buf2, "/"); strcat(buf2, name); - strcat(buf2, "/"); strcat(buf2, de->d_name); - fd1 = open(buf2, O_RDONLY); - if (fd1 < 0) { err(3, "%s", buf2); } - fstat(fd1, &st); - p1=mmap(0, st.st_size, PROT_READ, MAP_PRIVATE, fd1, 0); - if (p1 == (u_char *)MAP_FAILED) { err(3, "%s", buf2); } - close(fd1); - m2 = MD5Data(p1, st.st_size, md5_2); - name_stat("CTMFM", dir2, name, de); - printf(" %s %u\n", m2, (unsigned)st.st_size); - fwrite(p1, 1, st.st_size, stdout); - putchar('\n'); - munmap(p1, st.st_size); - s_new_files++; - s_new_bytes += st.st_size; - } -} - -void -Del (const char *dir1, const char *dir2, const char *name, struct dirent *de) -{ - damage++; - change++; - if (de->d_type == DT_DIR) { - char *p = alloca(strlen(name)+strlen(de->d_name)+2); - strcpy(p, name); strcat(p, de->d_name); strcat(p, "/"); - DoDir(dir1, dir2, p); - printf("CTMDR %s%s\n", name, de->d_name); - fprintf(logf, "CTMDR %s%s\n", name, de->d_name); - if (verbose > 1) { - fprintf(stderr, "CTMDR %s%s\n", name, de->d_name); - } - s_del_dirs++; - } else if (de->d_type == DT_REG) { - char *buf1 = alloca(strlen(dir1) + strlen(name) + - strlen(de->d_name) + 3); - char *m1, md5_1[33]; - strcpy(buf1, dir1); - strcat(buf1, "/"); strcat(buf1, name); - strcat(buf1, "/"); strcat(buf1, de->d_name); - m1 = MD5File(buf1, md5_1); - printf("CTMFR %s%s %s\n", name, de->d_name, m1); - fprintf(logf, "CTMFR %s%s %s\n", name, de->d_name, m1); - if (verbose > 1) { - fprintf(stderr, "CTMFR %s%s\n", name, de->d_name); - } - s_del_files++; - s_del_bytes += StatFile(buf1)->st_size; - } -} - -void -GetNext(int *i, int *n, struct dirent **nl, const char *dir, const char *name, u_long *ignored, u_long *bogus, u_long *wrong) -{ - char buf[BUFSIZ]; - char buf1[BUFSIZ]; - - for (;;) { - for (;;) { - (*i)++; - if (*i >= *n) - return; - strcpy(buf1, name); - if (buf1[strlen(buf1)-1] != '/') - strcat(buf1, "/"); - strcat(buf1, nl[*i]->d_name); - if (flag_ignore && - !regexec(®_ignore, buf1, 0, 0, 0)) { - (*ignored)++; - fprintf(logf, "Ignore %s\n", buf1); - if (verbose > 2) { - fprintf(stderr, "Ignore %s\n", buf1); - } - } else if (flag_bogus && - !regexec(®_bogus, buf1, 0, 0, 0)) { - (*bogus)++; - fprintf(logf, "Bogus %s\n", buf1); - fprintf(stderr, "Bogus %s\n", buf1); - damage++; - } else { - *buf = 0; - if (*dir != '/') - strcat(buf, "/"); - strcat(buf, dir); - if (buf[strlen(buf)-1] != '/') - strcat(buf, "/"); - strcat(buf, buf1); - break; - } - free(nl[*i]); nl[*i] = 0; - } - /* If the filesystem didn't tell us, find type */ - if (nl[*i]->d_type == DT_UNKNOWN) - nl[*i]->d_type = IFTODT(StatFile(buf)->st_mode); - if (nl[*i]->d_type == DT_REG || nl[*i]->d_type == DT_DIR) - break; - (*wrong)++; - if (verbose > 0) - fprintf(stderr, "Wrong %s\n", buf); - free(nl[*i]); nl[*i] = 0; - } -} - -void -DoDir(const char *dir1, const char *dir2, const char *name) -{ - int i1, i2, n1, n2, i; - struct dirent **nl1, **nl2; - char *buf1 = alloca(strlen(dir1) + strlen(name) + 4); - char *buf2 = alloca(strlen(dir2) + strlen(name) + 4); - - strcpy(buf1, dir1); strcat(buf1, "/"); strcat(buf1, name); - strcpy(buf2, dir2); strcat(buf2, "/"); strcat(buf2, name); - n1 = scandir(buf1, &nl1, dirselect, alphasort); - n2 = scandir(buf2, &nl2, dirselect, alphasort); - i1 = i2 = -1; - GetNext(&i1, &n1, nl1, dir1, name, &s1_ignored, &s1_bogus, &s1_wrong); - GetNext(&i2, &n2, nl2, dir2, name, &s2_ignored, &s2_bogus, &s2_wrong); - for (;i1 < n1 || i2 < n2;) { - - if (damage_limit && damage > damage_limit) - break; - - /* Get next item from list 1 */ - if (i1 < n1 && !nl1[i1]) - GetNext(&i1, &n1, nl1, dir1, name, - &s1_ignored, &s1_bogus, &s1_wrong); - - /* Get next item from list 2 */ - if (i2 < n2 && !nl2[i2]) - GetNext(&i2, &n2, nl2, dir2, name, - &s2_ignored, &s2_bogus, &s2_wrong); - - if (i1 >= n1 && i2 >= n2) { - /* Done */ - break; - } else if (i1 >= n1 && i2 < n2) { - /* end of list 1, add anything left on list 2 */ - Add(dir1, dir2, name, nl2[i2]); - free(nl2[i2]); nl2[i2] = 0; - } else if (i1 < n1 && i2 >= n2) { - /* end of list 2, delete anything left on list 1 */ - Del(dir1, dir2, name, nl1[i1]); - free(nl1[i1]); nl1[i1] = 0; - } else if (!(i = strcmp(nl1[i1]->d_name, nl2[i2]->d_name))) { - /* Identical names */ - if (nl1[i1]->d_type == nl2[i2]->d_type) { - /* same type */ - Equ(dir1, dir2, name, nl1[i1]); - } else { - /* different types */ - Del(dir1, dir2, name, nl1[i1]); - Add(dir1, dir2, name, nl2[i2]); - } - free(nl1[i1]); nl1[i1] = 0; - free(nl2[i2]); nl2[i2] = 0; - } else if (i < 0) { - /* Something extra in list 1, delete it */ - Del(dir1, dir2, name, nl1[i1]); - free(nl1[i1]); nl1[i1] = 0; - } else { - /* Something extra in list 2, add it */ - Add(dir1, dir2, name, nl2[i2]); - free(nl2[i2]); nl2[i2] = 0; - } - } - if (n1 >= 0) - free(nl1); - if (n2 >= 0) - free(nl2); -} - -int -main(int argc, char **argv) -{ - int i; - - setbuf(stderr, NULL); - -#if 0 - if (regcomp(®_bogus, DEFAULT_BOGUS, REG_EXTENDED | REG_NEWLINE)) - /* XXX use regerror to explain it */ - errx(1, "default regular expression argument to -B is botched"); - flag_bogus = 1; - - if (regcomp(®_ignore, DEFAULT_IGNORE, REG_EXTENDED | REG_NEWLINE)) - /* XXX use regerror to explain it */ - errx(1, "default regular expression argument to -I is botched"); - flag_ignore = 1; -#endif - - while ((i = getopt(argc, argv, "D:I:B:l:qv")) != -1) - switch (i) { - case 'D': - damage_limit = strtol(optarg, 0, 0); - if (damage_limit < 0) - errx(1, "damage limit must be positive"); - break; - case 'I': - if (flag_ignore) - regfree(®_ignore); - flag_ignore = 0; - if (!*optarg) - break; - if (regcomp(®_ignore, optarg, - REG_EXTENDED | REG_NEWLINE)) - /* XXX use regerror to explain it */ - errx(1, "regular expression argument to -I is botched"); - flag_ignore = 1; - break; - case 'B': - if (flag_bogus) - regfree(®_bogus); - flag_bogus = 0; - if (!*optarg) - break; - if (regcomp(®_bogus, optarg, - REG_EXTENDED | REG_NEWLINE)) - /* XXX use regerror to explain it */ - errx(1, "regular expression argument to -B is botched"); - flag_bogus = 1; - break; - case 'l': - logf = fopen(optarg, "w"); - if (!logf) - err(1, "%s", optarg); - setlinebuf(logf); - break; - case 'q': - verbose--; - break; - case 'v': - verbose++; - break; - case '?': - default: - Usage(); - return (1); - } - argc -= optind; - argv += optind; - - if (!logf) - logf = fopen(_PATH_DEVNULL, "w"); - - setbuf(stdout, 0); - - if (argc != 6) { - Usage(); - return (1); - } - - signal(SIGINFO, stat_info); - - fprintf(stderr, "CTM_BEGIN 2.0 %s %s %s %s\n", - argv[0], argv[1], argv[2], argv[3]); - fprintf(logf, "CTM_BEGIN 2.0 %s %s %s %s\n", - argv[0], argv[1], argv[2], argv[3]); - printf("CTM_BEGIN 2.0 %s %s %s %s\n", - argv[0], argv[1], argv[2], argv[3]); - DoDir(argv[4], argv[5], ""); - if (damage_limit && damage > damage_limit) { - print_stat(stderr, "DAMAGE: "); - errx(1, "damage of %d would exceed %d files", - damage, damage_limit); - } else if (change < 2) { - errx(4, "no changes"); - } else { - printf("CTM_END "); - fprintf(logf, "CTM_END\n"); - print_stat(stderr, "END: "); - } - exit(0); -} diff --git a/usr.sbin/eeprom/Makefile b/usr.sbin/eeprom/Makefile deleted file mode 100644 index 91d0b246d5b..00000000000 --- a/usr.sbin/eeprom/Makefile +++ /dev/null @@ -1,10 +0,0 @@ - -.PATH: ${.CURDIR:H}/ofwdump - -PROG= eeprom -MAN= eeprom.8 -MANSUBDIR= /sparc64 -SRCS= eeprom.c ofw_options.c ofw_util.c -CFLAGS+= -I${.CURDIR:H}/ofwdump - -.include diff --git a/usr.sbin/eeprom/Makefile.depend b/usr.sbin/eeprom/Makefile.depend deleted file mode 100644 index 77f8f90c31c..00000000000 --- a/usr.sbin/eeprom/Makefile.depend +++ /dev/null @@ -1,14 +0,0 @@ -# Autogenerated - do NOT edit! - -DIRDEPS = \ - include \ - include/xlocale \ - lib/${CSU_DIR} \ - lib/libc \ - - -.include - -.if ${DEP_RELDIR} == ${_DEP_RELDIR} -# local dependencies - needed for -jN in clean tree -.endif diff --git a/usr.sbin/eeprom/eeprom.8 b/usr.sbin/eeprom/eeprom.8 deleted file mode 100644 index 73920e0c4bf..00000000000 --- a/usr.sbin/eeprom/eeprom.8 +++ /dev/null @@ -1,699 +0,0 @@ -.\" Copyright (c) 1996 The NetBSD Foundation, Inc. -.\" Copyright (c) 2004 Marius Strobl -.\" All rights reserved. -.\" -.\" This code is derived from software contributed to The NetBSD Foundation -.\" by Jason R. Thorpe. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS -.\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -.\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS -.\" BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -.\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -.\" POSSIBILITY OF SUCH DAMAGE. -.\" -.\" from: NetBSD: eeprom.8,v 1.11 2003/03/31 01:31:39 perry Exp -.\" -.Dd September 1, 2006 -.Dt EEPROM 8 sparc64 -.Os -.Sh NAME -.Nm eeprom -.Nd "display or modify contents of the EEPROM or NVRAM" -.Sh SYNOPSIS -.Nm -.Fl a -.Nm -.Op Fl -.Ar name Ns Op = Ns Ar value -.Ar ... -.Sh DESCRIPTION -The -.Nm -utility provides an interface for displaying and changing the system's -configuration variables contained in EEPROM or NVRAM. -In the first synopsis form, all available configuration variables and their -current values are printed. -In the second form, only the variable selected by -.Ar name -and its value is printed or changed if -.Ar name -is followed by -.Ql = -and a -.Ar value . -.Pp -The following options are available: -.Bl -tag -width indent -.It Fl -Commands for displaying or changing variables are taken from stdin, allowing -one -.Ar name -or one -.Ar name -and -.Ar value -pair per line. -The output is printed on stdout. -.It Fl a -Print all available configuration variables and their current values. -.El -.Sh VARIABLES AND VALUES -Below are variables and values that one is likely to find on a system equipped -with OpenBoot 3.x and Open Firmware respectively. -.Pp -Note: the attempt to set a variable to an illegal value results in the -Open Firmware setting it to some legal value instead. -The -.Nm -utility will detect this, try to recover the previous value of the variable -and issue a warning telling that the requested value could not be set. -.Bl -tag -width ".Va last-hardware-update" -.It Va auto-boot? -If -.Dq Li true , -the system will try to boot automatically from the devices listed in -.Va boot-device -and -.Va diag-device -respectively, using the command specified in -.Va boot-command -at power-up. -Default: -.Dq Li true . -.It Va auto-boot-retry? -If set to -.Dq Li true -and -.Va auto-boot? -is also set to -.Dq Li true , -the system will try to boot from the specified boot devices forever. -Default: -.Dq Li false . -.It Va ansi-terminal? -If -.Dq Li false , -.Tn ANSI -escape sequences are not interpreted by the terminal emulator. -Default: -.Dq Li true . -.It Va boot-command -Command executed when -.Va auto-boot? -is set to -.Dq Li true . -Default: -.Dq Li boot . -.It Va boot-device -Default device to boot from if -.Va diag-switch? -is set to -.Dq Li false . -Takes one or more device aliases or device paths. -The boot devices are sequentially tried to boot from, beginning with the first -one specified. -Default: -.Dq Li "net disk" . -.It Va cpci-probe-list -Digits in the format -.Dq Li 0,1,2 -specifying in which order to probe the devices on the CompactPCI bus at -power-up. -Default: system-dependent. -.It Va boot-file -Default arguments for boot when -.Va diag-switch? -is set to -.Dq Li false . -When empty, the secondary boot loader will choose the file to boot. -Default: empty string. -.It Va diag-device -Like -.Va boot-device . -Used when -.Va diag-switch? -is set to -.Dq Li true . -Default: -.Dq Li net . -.It Va diag-file -Like -.Va boot-file . -Used when -.Va diag-switch? -is set to -.Dq Li true . -Default: empty string. -.It Va diag-level -Level of diagnostics to run when -.Va diag-switch? -is set to -.Dq Li true . -Possible values are -.Dq Li max , -.Dq Li menus , -.Dq Li min -and -.Dq Li off -(depending on the system model). -When set to -.Dq Li off , -the Power-On Self Test (POST) is not run. -The other values are interpreted by the POST. -Default: -.Dq Li min -or -.Dq Li max -(system-dependent). -.It Va diag-switch? -If -.Dq Li true , -the system will boot and run in diagnostic mode. -Default: -.Dq Li false -or -.Dq Li true -(system-dependent). -.It Va env-monitor -Enables or disables the Advanced System Monitoring (ASM). -Possible values are -.Dq Li enabled -and -.Dq Li disabled . -Default: -.Dq Li enabled . -.It Va fcode-debug? -Used for debugging FCode programs. -If set to -.Dq Li true , -names of additional FCodes are registered in the Forth dictionary. -Default: -.Dq Li false . -.It Va hardware-revision -A string describing the system hardware version. -Default: system-dependent. -.It Va input-device -One of the strings -.Dq Li keyboard , -.Dq Li ttya , -or -.Dq Li ttyb , -specifying the default console input device. -Default: -.Dq Li keyboard -or -.Dq Li ttya -(system-dependent). -.It Va keyboard-click? -If set to -.Dq Li true , -the keys click annoyingly. -Default: -.Dq Li false . -.It Va keymap -Keymap for a custom keyboard. -Default: empty string. -.It Va last-hardware-update -Similar to -.Va hardware-revision , -describing when the hardware was last updated. -Default: system-dependent. -.It Va last-poweroff-cause -Cause of the last power-off. -Used internally by the OpenBoot PROM. -Default: -.Dq Li 0 . -.It Va load-base -Default address where client programs are loaded to. -It is unlikely that this value should ever be changed. -Default: -.Dq Li 16384 . -.It Va local-mac-address? -If set to -.Dq Li false , -all Ethernet devices with FCode will use the system default MAC address. -If set to -.Dq Li true , -Ethernet devices with FCode that contains a unique MAC address will use it -rather than the system's default MAC address. -Default: -.Dq Li false . -.Pp -Ethernet devices with FCode include those supported by -.Xr dc 4 , -.Xr gem 4 -and -.Xr hme 4 . -Please see the respective manual page for further information. -.It Va mfg-mode -Manufacture test mode interpreted by the POST. -Possible values are -.Dq Li chamber -and -.Dq Li off . -Default: -.Dq Li off . -.It Va mfg-switch? -If set to -.Dq Li true , -manufacturing tests are repeated until stopped by pressing STOP-A. -Default: -.Dq Li off . -.It Va net-timeout -If set to -.Dq Li 0 , -the system will try to boot forever when the boot device used is a network -device. -Any non-zero value is interpreted as minutes to try a network boot. -Default: -.Dq Li 0 . -.It Va nvramrc -Contents of the NVRAMRC. -Default: empty string. -.Pp -While -.Va nvramrc -can be set using -.Nm , -it is preferred to use -.Ic nvedit -in the boot monitor instead. -.It Va oem-banner -A string displayed at power-up, rather than the default banner. -Used when -.Va oem-banner? -is set to -.Dq Li true . -Default: system-dependent. -.It Va oem-banner? -If set to -.Dq Li true , -the string stored in -.Va oem-banner -is displayed at power-up rather than the default banner. -Default: system-dependent. -.It Va oem-logo -A logo displayed at power-up when -.Va oem-logo? -is set to -.Dq Li true , -rather than the default logo. -The logo has to be 512 bytes in size, containing a 64x64-bit monochrome image -in Sun Raster format without the leading 32-byte header. -Default: system-dependent. -.Pp -To set the logo with -.Nm , -give the pathname of the file containing the image as the -.Ar value . -Using an empty -.Ar value -will remove the image. -.It Va oem-logo? -If set to -.Dq Li true , -the logo stored in -.Va oem-logo -is displayed at power-up rather than the default logo. -.It Va output-device -One of the strings -.Dq Li screen , -.Dq Li ttya , -or -.Dq Li ttyb , -specifying the default console output device. -Default: -.Dq Li screen -or -.Dq Li ttya -(system-dependent). -.It Va pcia-probe-list -Digits in the format -.Dq Li 1,2,3 -specifying in which order to probe the devices on the PCI bus A. -Default: system-dependent. -.It Va pcib-probe-list -Like -.Va pcia-probe-list , -but for PCI bus B. -Default: system-dependent. -.It Va #power-cycles -Number of power-cycles. -Automatically incremented on each power-cycle. -Default: system-dependent. -.It Va sbus-probe-list -Digits in the format -.Dq Li 0123 -specifying in which order to probe the SBus slots at power-up. -Default: system-dependent. -.It Va screen-#columns -An integer specifying the screen width in characters per line. -Default: -.Dq Li 80 . -.It Va screen-#rows -An integer specifying the screen height in lines. -Default: -.Dq Li 34 . -.It Va scsi-initiator-id -The SCSI ID of SCSI controllers in the range of [0-7] or [0-f] (depending -on the controller). -A SCSI controller may or may not adhere to this setting, depending on its -FCode and device driver. -Default: -.Dq Li 7 . -.It Va security-#badlogins -Number of incorrect password attempts when -.Va security-mode -is set to -.Dq Li command -or -.Dq Li full . -Default: -.Dq Li 0 . -.It Va security-mode -Boot monitor security level. -One of the three possible values -.Dq Li full , -.Dq Li command , -or -.Dq Li none . -When set to -.Dq Li full , -all boot monitor commands except for -.Ic go -require the password. -When set to -.Dq Li command , -all boot monitor commands except for -.Ic boot -and -.Ic go -require the password. -When set to -.Dq Li none , -no password is required. -Default: -.Dq Li none . -.Pp -When -.Nm -is used to set -.Va security-mode -to -.Dq Li full -or -.Dq Li command , -you will be prompted for the password. -When -.Va security-mode -is set to -.Dq Li none , -.Nm -will clear the password. -.It Va security-password -The password used when -.Va security-mode -is set to -.Dq Li full -or -.Dq Li command . -The maximum length for this password is 8 characters. -All characters exceeding this length will be ignored. -The value displayed for -.Va security-password -is always an empty string, even when a password is set. -Default: empty string. -.Pp -When -.Va security-mode -is set to -.Dq Li full -or -.Dq Li command , -.Nm -can be used to enter a new password using any -.Ar value -for -.Va security-password -on the command line. -You will be prompted by -.Nm -to type in the new password in this case. -Trying to set -.Va security-password -when -.Va security-mode -is set to -.Dq Li none -using -.Nm -has no effect. -.It Va selftest-#megs -An integer specifying the number of megabytes of memory to test upon -power-up when -.Va diag-switch? -is set to -.Dq Li false . -Default: -.Dq Li 1 . -.It Va shutdown-temperature -Temperature at which the ASM issues an over-temperature shutdown. -Default: system-dependent. -.It Va silent-mode -If set to -.Dq Li true , -memory test messages will not be displayed at power-up. -Default: -.Dq Li false . -.It Va sunmon-compat? -If set to -.Dq Li true , -the old bootROM interface will be used while in the boot monitor, -rather than the OpenBoot PROM interface. -Default: -.Dq Li false . -.It Va system-board-date -Manufacturing date of the system board. -Default: system-dependent. -.It Va system-board-serial# -Serial number of the system board. -Default: system-dependent. -.It Va tpe-link-test? -Enable link test on 10baseT and 100baseTX Ethernet devices. -Default: -.Dq Li true . -.It Va ttya-mode -A string of five comma separated fields in the format -.Dq Li 9600,8,n,1,- . -The first field is the baud rate. -The second field is the number of data bits. -The third field is the parity; acceptable values for parity are -.Ql n -(none), -.Ql e -(even), -.Ql o -(odd), -.Ql m -(mark), and -.Ql s -(space). -The fourth field is the number of stop bits. -The fifth field is the -.Dq handshake -field; acceptable values are -.Ql - -(none), -.Ql h -(RTS/CTS), and -.Ql s -(Xon/Xoff). -Default: -.Dq Li 9600,8,n,1,- . -.It Va ttya-ignore-cd -If set to -.Dq Li true , -the system will ignore carrier detect. -Default: -.Dq Li true . -.It Va ttya-rts-dtr-off -If set to -.Dq Li true , -the system will ignore RTS/DTR. -Default: -.Dq Li false . -.It Va ttyb-mode -Like -.Va ttya-mode , -but for ttyb. -Default: -.Dq Li 9600,8,n,1,- . -.It Va ttyb-ignore-cd -Like -.Va ttya-ignore-cd , -but for ttyb. -Default: -.Dq Li true . -.It Va ttyb-rts-dtr-off -Like -.Va ttya-rts-dtr-off , -but for ttyb. -Default: -.Dq Li false . -.It Va use-boot-table? -Use boot table defined by the OEM. -Default: system-dependent. -.It Va use-nvramrc? -If set to -.Dq Li true , -the script stored in -.Va nvramrc -will be executed during start-up. -Default: -.Dq Li false . -.It Va warning-temperature -Temperature at which the ASM issues an over-temperature warning. -Default: system-dependent. -.It Va watchdog-enable? -Enables or disables the system watchdog timer. -Default: -.Dq Li false . -.It Va watchdog-reboot? -If set to -.Dq Li true , -the system will reboot upon terminal count of the system watchdog timer. -If set to -.Dq Li false , -the system will fall into the boot monitor. -Default: -.Dq Li false . -.It Va watchdog-timeout -Expiry limit for the system watchdog timer. -Range and unit depend on the system model. -Default: system-dependent. -.El -.Sh EXAMPLES -Print all available configuration variables and their current values: -.Pp -.Dl "eeprom -a" -.Pp -Print the current value of the -.Va local-mac-address? -variable: -.Pp -.Dl "eeprom local-mac-address\e?" -.Pp -Set the value of the -.Va local-mac-address? -variable to -.Dq Li true : -.Pp -.Dl "eeprom local-mac-address\e?=true" -.Pp -Note that the -.Ql \e -in the above examples is used to keep the shell from interpreting the -.Ql \&? . -.Pp -Write an image to the -.Va oem-logo -variable: -.Pp -.Dl "eeprom oem-logo=/path/to/image.raw" -.Pp -Remove the image from the -.Va oem-logo -variable again: -.Pp -.Dl "eeprom oem-logo=" -.Pp -Set the value of the -.Va security-mode -variable to -.Dq Li full , -and set the password: -.Bd -literal -offset indent -eeprom security-mode=full -New password: -Retype new password: -.Ed -.Pp -Remember that the maximum length for the password is 8 characters. -All characters exceeding this length will be ignored. -.Pp -Set a new password when the -.Va security-mode -variable is set to -.Dq Li command -or -.Dq Li full : -.Bd -literal -offset indent -eeprom security-password= -New password: -Retype new password: -.Ed -.Sh SEE ALSO -.Xr dc 4 , -.Xr gem 4 , -.Xr hme 4 , -.Xr ofwdump 8 -.Sh HISTORY -The -.Nm -utility first appeared in -.Bx 4.4 . -It was adopted from there by -.Fx 2.0 . -The -.Nm -utility was removed from -.Fx -again after -.Fx 2.1.7 -because the utility was unused at that time. -The present implementation of the -.Nm -utility first appeared in -.Fx 5.3 . -It is inspired by the -.Nx -.Xr eeprom 8 -and SunOS/Solaris -.Xr eeprom 1M -utilities. -.Sh AUTHORS -.An -nosplit -The -.Nm -utility uses base code from the -.Nx -version written by -.An Jason R. Thorpe . -The handlers for the Open Firmware -.Pa /options -node were written by -.An Marius Strobl Aq Mt marius@FreeBSD.org . -The code for accessing the Open Firmware device tree is shared with the -.Xr ofwdump 8 -utility written by -.An Thomas Moestl Aq Mt tmm@FreeBSD.org . -.Sh BUGS -Currently, -.Nm -only supports systems equipped with Open Firmware and is only tested on Sun -Microsystems sun4u machines. diff --git a/usr.sbin/eeprom/eeprom.c b/usr.sbin/eeprom/eeprom.c deleted file mode 100644 index df54d48799d..00000000000 --- a/usr.sbin/eeprom/eeprom.c +++ /dev/null @@ -1,147 +0,0 @@ -/*- - * SPDX-License-Identifier: BSD-2-Clause-NetBSD - * - * Copyright (c) 1996 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Jason R. Thorpe. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - * from: NetBSD: main.c,v 1.15 2001/02/19 23:22:42 cgd Exp - */ - -#include - -#include -#include -#include -#include -#include -#include - -#include "ofw_options.h" - -static int action(char *); -static void dump_config(void); -static void usage(void); - -static void -usage(void) -{ - - fprintf(stderr, - "usage: eeprom -a\n" - " eeprom [-] name[=value] ...\n"); - exit(EX_USAGE); -} - -int -main(int argc, char *argv[]) -{ - int do_stdin, opt; - int aflag, rv; - char *cp; - char line[BUFSIZ]; - - aflag = do_stdin = 0; - rv = EX_OK; - while ((opt = getopt(argc, argv, "-a")) != -1) { - switch (opt) { - case '-': - if (aflag) - usage(); - do_stdin = 1; - break; - case 'a': - if (do_stdin) - usage(); - aflag = 1; - break; - case '?': - default: - usage(); - /* NOTREACHED */ - } - } - argc -= optind; - argv += optind; - - if (aflag) { - if (argc != 0) - usage(); - dump_config(); - } else { - if (do_stdin) { - while (fgets(line, BUFSIZ, stdin) != NULL && - rv == EX_OK) { - if (line[0] == '\n') - continue; - if ((cp = strrchr(line, '\n')) != NULL) - *cp = '\0'; - rv = action(line); - } - if (ferror(stdin)) - err(EX_NOINPUT, "stdin"); - } else { - if (argc == 0) - usage(); - while (argc && rv == EX_OK) { - rv = action(*argv); - ++argv; - --argc; - } - } - } - return (rv); -} - -static int -action(char *line) -{ - int rv; - char *keyword, *arg; - - keyword = strdup(line); - if (keyword == NULL) - err(EX_OSERR, "malloc() failed"); - if ((arg = strrchr(keyword, '=')) != NULL) - *arg++ = '\0'; - switch (rv = ofwo_action(keyword, arg)) { - case EX_UNAVAILABLE: - warnx("nothing available for '%s'.", keyword); - break; - case EX_DATAERR: - warnx("invalid value '%s' for '%s'.", arg, keyword); - break; - } - free(keyword); - return(rv); -} - -static void -dump_config(void) -{ - - ofwo_dump(); -} diff --git a/usr.sbin/eeprom/ofw_options.c b/usr.sbin/eeprom/ofw_options.c deleted file mode 100644 index 7af119deddc..00000000000 --- a/usr.sbin/eeprom/ofw_options.c +++ /dev/null @@ -1,311 +0,0 @@ -/*- - * SPDX-License-Identifier: BSD-2-Clause-FreeBSD - * - * Copyright (c) 2004 Marius Strobl - * 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 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. - */ - -#include - -/* - * Handlers for Open Firmware /options node. - */ - -#include - -#include - -#include -#include -#include -#include -#include -#include -#include -#include - -#include "ofw_options.h" -#include "ofw_util.h" - -#define OFWO_LOGO 512 -#define OFWO_MAXPROP 31 -#define OFWO_MAXPWD 8 - -struct ofwo_extabent { - const char *ex_prop; - int (*ex_handler)(const struct ofwo_extabent *, int, - const void *, int, const char *); -}; - -static int ofwo_oemlogo(const struct ofwo_extabent *, int, const void *, - int, const char *); -static int ofwo_secmode(const struct ofwo_extabent *, int, const void *, - int, const char *); -static int ofwo_secpwd(const struct ofwo_extabent *, int, const void *, - int, const char *); - -static const struct ofwo_extabent ofwo_extab[] = { - { "oem-logo", ofwo_oemlogo }, - { "security-mode", ofwo_secmode }, - { "security-password", ofwo_secpwd }, - { NULL, NULL } -}; - -static int ofwo_setpass(int); -static int ofwo_setstr(int, const void *, int, const char *, const char *); - -static __inline void -ofwo_printprop(const char *prop, const char* buf, int buflen) -{ - - printf("%s: %.*s\n", prop, buflen, buf); -} - -static int -ofwo_oemlogo(const struct ofwo_extabent *exent, int fd, const void *buf, - int buflen, const char *val) -{ - int lfd; - char logo[OFWO_LOGO + 1]; - - if (val) { - if (val[0] == '\0') - ofw_setprop(fd, ofw_optnode(fd), exent->ex_prop, "", 1); - else { - if ((lfd = open(val, O_RDONLY)) == -1) { - warn("could not open '%s'", val); - return (EX_USAGE); - } - if (read(lfd, logo, OFWO_LOGO) != OFWO_LOGO || - lseek(lfd, 0, SEEK_END) != OFWO_LOGO) { - close(lfd); - warnx("logo '%s' has wrong size.", val); - return (EX_USAGE); - } - close(lfd); - logo[OFWO_LOGO] = '\0'; - if (ofw_setprop(fd, ofw_optnode(fd), exent->ex_prop, - logo, OFWO_LOGO + 1) != OFWO_LOGO) - errx(EX_IOERR, "writing logo failed."); - } - } else - if (buflen != 0) - printf("%s: \n", exent->ex_prop); - else - ofwo_printprop(exent->ex_prop, (const char *)buf, - buflen); - return (EX_OK); -} - -static int -ofwo_secmode(const struct ofwo_extabent *exent, int fd, const void *buf, - int buflen, const char *val) -{ - int res; - - if (val) { - if (strcmp(val, "full") == 0 || strcmp(val, "command") == 0) { - if ((res = ofwo_setpass(fd)) != EX_OK) - return (res); - if ((res = ofwo_setstr(fd, buf, buflen, exent->ex_prop, - val)) != EX_OK) - ofw_setprop(fd, ofw_optnode(fd), - "security-password", "", 1); - return (res); - } - if (strcmp(val, "none") == 0) { - ofw_setprop(fd, ofw_optnode(fd), "security-password", - "", 1); - return (ofwo_setstr(fd, buf, buflen, exent->ex_prop, - val)); - } - return (EX_DATAERR); - } else - ofwo_printprop(exent->ex_prop, (const char *)buf, buflen); - return (EX_OK); -} - -static int -ofwo_secpwd(const struct ofwo_extabent *exent, int fd, const void *buf, - int buflen, const char *val) -{ - void *pbuf; - int len, pblen, rv; - - pblen = 0; - rv = EX_OK; - pbuf = NULL; - if (val) { - len = ofw_getprop_alloc(fd, ofw_optnode(fd), "security-mode", - &pbuf, &pblen, 1); - if (len <= 0 || strncmp("none", (char *)pbuf, len) == 0) { - rv = EX_CONFIG; - warnx("no security mode set."); - } else if (strncmp("command", (char *)pbuf, len) == 0 || - strncmp("full", (char *)pbuf, len) == 0) { - rv = ofwo_setpass(fd); - } else { - rv = EX_CONFIG; - warnx("invalid security mode."); - } - } else - ofwo_printprop(exent->ex_prop, (const char *)buf, buflen); - if (pbuf != NULL) - free(pbuf); - return (rv); -} - -static int -ofwo_setpass(int fd) -{ - char pwd1[OFWO_MAXPWD + 1], pwd2[OFWO_MAXPWD + 1]; - - if (readpassphrase("New password:", pwd1, sizeof(pwd1), - RPP_ECHO_OFF | RPP_REQUIRE_TTY) == NULL || - readpassphrase("Retype new password:", pwd2, sizeof(pwd2), - RPP_ECHO_OFF | RPP_REQUIRE_TTY) == NULL) - errx(EX_USAGE, "failed to get password."); - if (strlen(pwd1) == 0) { - printf("Password unchanged.\n"); - return (EX_OK); - } - if (strcmp(pwd1, pwd2) != 0) { - printf("Mismatch - password unchanged.\n"); - return (EX_USAGE); - } - ofw_setprop(fd, ofw_optnode(fd), "security-password", pwd1, - strlen(pwd1) + 1); - return (EX_OK); -} - -static int -ofwo_setstr(int fd, const void *buf, int buflen, const char *prop, - const char *val) -{ - void *pbuf; - int len, pblen, rv; - phandle_t optnode; - char *oval; - - pblen = 0; - rv = EX_OK; - pbuf = NULL; - optnode = ofw_optnode(fd); - ofw_setprop(fd, optnode, prop, val, strlen(val) + 1); - len = ofw_getprop_alloc(fd, optnode, prop, &pbuf, &pblen, 1); - if (len < 0 || strncmp(val, (char *)pbuf, len) != 0) { - /* - * The value is too long for this property and the OFW has - * truncated it to fit or the value is illegal and a legal - * one has been written instead (e.g. attempted to write - * "foobar" to a "true"/"false"-property) - try to recover - * the old value. - */ - rv = EX_DATAERR; - if ((oval = malloc(buflen + 1)) == NULL) - err(EX_OSERR, "malloc() failed."); - strncpy(oval, buf, buflen); - oval[buflen] = '\0'; - len = ofw_setprop(fd, optnode, prop, oval, buflen + 1); - if (len != buflen) - errx(EX_IOERR, "recovery of old value failed."); - free(oval); - goto out; - } - printf("%s: %.*s%s->%s%.*s\n", prop, buflen, (const char *)buf, - buflen > 0 ? " " : "", len > 0 ? " " : "", len, (char *)pbuf); -out: - if (pbuf != NULL) - free(pbuf); - return (rv); -} - -void -ofwo_dump(void) -{ - void *pbuf; - int fd, len, nlen, pblen; - phandle_t optnode; - char prop[OFWO_MAXPROP + 1]; - const struct ofwo_extabent *ex; - - pblen = 0; - pbuf = NULL; - fd = ofw_open(O_RDONLY); - optnode = ofw_optnode(fd); - for (nlen = ofw_firstprop(fd, optnode, prop, sizeof(prop)); nlen != 0; - nlen = ofw_nextprop(fd, optnode, prop, prop, sizeof(prop))) { - len = ofw_getprop_alloc(fd, optnode, prop, &pbuf, &pblen, 1); - if (len < 0) - continue; - if (strcmp(prop, "name") == 0) - continue; - for (ex = ofwo_extab; ex->ex_prop != NULL; ++ex) - if (strcmp(ex->ex_prop, prop) == 0) - break; - if (ex->ex_prop != NULL) - (*ex->ex_handler)(ex, fd, pbuf, len, NULL); - else - ofwo_printprop(prop, (char *)pbuf, len); - } - if (pbuf != NULL) - free(pbuf); - ofw_close(fd); -} - -int -ofwo_action(const char *prop, const char *val) -{ - void *pbuf; - int fd, len, pblen, rv; - const struct ofwo_extabent *ex; - - pblen = 0; - rv = EX_OK; - pbuf = NULL; - if (strcmp(prop, "name") == 0) - return (EX_UNAVAILABLE); - if (val) - fd = ofw_open(O_RDWR); - else - fd = ofw_open(O_RDONLY); - len = ofw_getprop_alloc(fd, ofw_optnode(fd), prop, &pbuf, &pblen, 1); - if (len < 0) { - rv = EX_UNAVAILABLE; - goto out; - } - for (ex = ofwo_extab; ex->ex_prop != NULL; ++ex) - if (strcmp(ex->ex_prop, prop) == 0) - break; - if (ex->ex_prop != NULL) - rv = (*ex->ex_handler)(ex, fd, pbuf, len, val); - else if (val) - rv = ofwo_setstr(fd, pbuf, len, prop, val); - else - ofwo_printprop(prop, (char *)pbuf, len); -out: - if (pbuf != NULL) - free(pbuf); - ofw_close(fd); - return (rv); -} diff --git a/usr.sbin/eeprom/ofw_options.h b/usr.sbin/eeprom/ofw_options.h deleted file mode 100644 index 12f3cf20805..00000000000 --- a/usr.sbin/eeprom/ofw_options.h +++ /dev/null @@ -1,35 +0,0 @@ -/*- - * SPDX-License-Identifier: BSD-2-Clause-FreeBSD - * - * Copyright (c) 2004 Marius Strobl - * 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 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. - * - */ - -#ifndef OFW_OPTIONS_H -#define OFW_OPTIONS_H - -void ofwo_dump(void); -int ofwo_action(const char *prop, const char *val); - -#endif /* OFW_OPTIONS_H */ diff --git a/usr.sbin/nandsim/Makefile b/usr.sbin/nandsim/Makefile deleted file mode 100644 index 9ea00bb3f32..00000000000 --- a/usr.sbin/nandsim/Makefile +++ /dev/null @@ -1,7 +0,0 @@ - -PROG= nandsim -SRCS= nandsim.c nandsim_rcfile.c nandsim_cfgparse.c -BINDIR= /usr/sbin -MAN= nandsim.8 - -.include diff --git a/usr.sbin/nandsim/Makefile.depend b/usr.sbin/nandsim/Makefile.depend deleted file mode 100644 index 84b8ddd67e3..00000000000 --- a/usr.sbin/nandsim/Makefile.depend +++ /dev/null @@ -1,16 +0,0 @@ -# Autogenerated - do NOT edit! - -DIRDEPS = \ - gnu/lib/csu \ - include \ - include/xlocale \ - lib/${CSU_DIR} \ - lib/libc \ - lib/libcompiler_rt \ - - -.include - -.if ${DEP_RELDIR} == ${_DEP_RELDIR} -# local dependencies - needed for -jN in clean tree -.endif diff --git a/usr.sbin/nandsim/nandsim.8 b/usr.sbin/nandsim/nandsim.8 deleted file mode 100644 index 8e26a86bb52..00000000000 --- a/usr.sbin/nandsim/nandsim.8 +++ /dev/null @@ -1,228 +0,0 @@ -.\" Copyright (c) 2010 Semihalf -.\" 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. -.\" -.\" -.Dd August 10, 2010 -.Dt NANDSIM 8 -.Os -.Sh NAME -.Nm nandsim -.Nd NAND simulator control program -.Sh SYNOPSIS -.Nm -.Ic status -.Aq ctrl_no | Fl -all | Fl a -.Op Fl v -.Nm -.Ic conf -.Aq filename -.Nm -.Ic start -.Aq ctrl_no -.Nm -.Ic mod -.Aq ctrl_no:cs_no | Fl l Aq loglevel -.Op Fl p Aq prog_time -.Op Fl e Aq erase_time -.Op Fl r Aq read_time -.Op Fl E Aq error_ratio -.Op Fl h -.Nm -.Ic stop -.Aq ctrl_no -.Nm -.Ic error -.Aq ctrl_no:cs_no -.Aq page_num -.Aq column -.Aq length -.Aq pattern -.Nm -.Ic bb -.Aq ctrl_no:cs_no -.Op blk_num,blk_num2,... -.Op Fl U -.Op Fl L -.Nm -.Ic freeze -.Op ctrl_no -.Nm -.Ic log -.Aq ctrl_no | Fl -all | Fl a -.Nm -.Ic stats -.Aq ctrl_no:cs_no -.Aq page_num -.Nm -.Ic dump -.Aq ctrl_no:cs_no -.Aq filename -.Nm -.Ic restore -.Aq ctrl_no:chip_no -.Aq filename -.Nm -.Ic destroy -.Aq ctrl_no[:cs_no] | Fl -all | Fl a -.Nm -.Ic help -.Op Fl v -.Sh COMMAND DESCRIPTION -Controllers and chips are arranged into a simple hierarchy. -There can be up to 4 controllers configured, each with 4 chip select (CS) lines. -A given chip is connected to one of the chip selects. -.Pp -Controllers are specified as -.Aq ctrl_no ; -chip selects are specified as -.Aq cs_no . -.Bl -tag -width periphlist -.It Ic status -Gets controller(s) status. If -.Fl a -or -.Fl -all -flag is specified - command will print status of every controller -currently available. -Optional flag -.Fl v -causes printing complete information about the controller, and all -chips attached to it. -.It Ic conf -Reads simulator configuration from a specified file (this includes -the simulation "layout" i.e. controllers-chips assignments). -Configuration changes for an already started simulation require a -full stop-start cycle in order to take effect i.e.: -.Bl -column -.It nandsim stop ... -.It nandsim destroy ... -.Pp -.It << edit config file >> -.Pp -.It nandsim conf ... -.It nandsim start ... -.El -.It Ic mod -Alters simulator parameters on-the-fly. -If controller number and CS pair is not specified, the general -simulator parameters (not specific to a controller or a chip) will be modified. -Changing chip's parameters requires specifying both controller number and CS -to which the given chip is connected. -Parameters which can be altered: -.Pp -General simulator related: -.Bl -tag -width flag -.It Fl l Aq log_level -change logging level to -.Aq log_level -.El -.Pp -Chip related: -.Bl -tag -width flag -.It Fl p Aq prog_time -change prog time for specified chip to -.Aq prog_time -.It Fl e Aq erase_time -change erase time for specified chip to -.Aq erase_time -.It Fl r Aq read_time -change read time for specified chip to -.Aq read_time -.It Fl E Aq error_ratio -change error ratio for specified chip to -.Aq error_ratio . -Error ratio is a number of errors per million read/write bytes. -.El -.Pp -Additionally, flag -.Fl h -will list parameters which can be altered. -.El -.Bl -tag -width periphlist -.It Ic bb -Marks/unmarks a specified block as bad. -To mark/unmark the bad condition an a block, the following parameters -have to be supplied: controller number, CS number, and at least one -block number. -It is possible to specify multiple blocks, by separating blocks numbers -with a comma. -The following options can be used for the 'bb' command: -.Bl -tag -width flag -.It Fl U -unmark the bad previously marked block as bad. -.It Fl L -list all blocks marked as bad on a given chip. -.El -.It Ic log -Prints activity log of the specified controller to stdout; if -controller number is not specified, logs for all available -controllers are printed. -.It Ic stats -Print statistics of the selected controller, chip and page. -Statistics includes read count, write count, raw read count, raw -write count, ECC stats (succeeded corrections, failed correction). -.It Ic dump -Dumps a snaphot of a single chip (including data and bad blocks -information, wearout level) into the file. -.It Ic restore -Restores chip state from a dump-file snapshot (produced previously -with the 'dump' command). -.It Ic start -Starts a controller i.e. the simulation. -.It Ic stop -Stops an already started controller; if the controller number is not -supplied, attempts to stop all currently working controllers. -.It Ic destroy -Removes existing active chip/controller and its configuration from -memory and releases the resources. -Specifying flag -.Fl a -or -.Fl -all -causes removal of every chip and controller. -Controller must be stopped in order to be destroyed. -.It Ic error -Directly overwrites a certain number of bytes in the specified page -at a given offset with a supplied pattern (which mimics the -corruption of flash contents). -.It Ic help -Prints synopsis, -.Fl v -gives more verbose output. -.It Ic freeze -Stops simulation of given controller (simulates power-loss). -All commands issues to any chip on this controller are ignored. -.El -.Sh SEE ALSO -.Xr nand 4 , -.Xr nandsim 4 , -.Xr nandsim.conf 5 -.Sh HISTORY -The -.Nm -utility first appeared in -.Fx 10.0 . -.Sh AUTHORS -This utility was written by -.An Lukasz Wojcik . diff --git a/usr.sbin/nandsim/nandsim.c b/usr.sbin/nandsim/nandsim.c deleted file mode 100644 index 90ff3a191ef..00000000000 --- a/usr.sbin/nandsim/nandsim.c +++ /dev/null @@ -1,1398 +0,0 @@ -/*- - * SPDX-License-Identifier: BSD-2-Clause-FreeBSD - * - * Copyright (C) 2009-2012 Semihalf - * 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 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. - */ - -/* - * Control application for the NAND simulator. - */ - -#include - -#include -#include -#include -#include -#include - -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "nandsim_cfgparse.h" - -#define SIMDEVICE "/dev/nandsim.ioctl" - -#define error(fmt, args...) do { \ - printf("ERROR: " fmt "\n", ##args); } while (0) - -#define warn(fmt, args...) do { \ - printf("WARNING: " fmt "\n", ##args); } while (0) - -#define DEBUG -#undef DEBUG - -#ifdef DEBUG -#define debug(fmt, args...) do { \ - printf("NANDSIM_CONF:" fmt "\n", ##args); } while (0) -#else -#define debug(fmt, args...) do {} while(0) -#endif - -#define NANDSIM_RAM_LOG_SIZE 16384 - -#define MSG_NOTRUNNING "Controller#%d is not running.Please start" \ - " it first." -#define MSG_RUNNING "Controller#%d is already running!" -#define MSG_CTRLCHIPNEEDED "You have to specify ctrl_no:cs_no pair!" -#define MSG_STATUSACQCTRLCHIP "Could not acquire status for ctrl#%d chip#%d" -#define MSG_STATUSACQCTRL "Could not acquire status for ctrl#%d" -#define MSG_NOCHIP "There is no such chip configured (chip#%d "\ - "at ctrl#%d)!" - -#define MSG_NOCTRL "Controller#%d is not configured!" -#define MSG_NOTCONFIGDCTRLCHIP "Chip connected to ctrl#%d at cs#%d " \ - "is not configured." - -typedef int (commandfunc_t)(int , char **); - -static struct nandsim_command *getcommand(char *); -static int parse_devstring(char *, int *, int *); -static void printchip(struct sim_chip *, uint8_t); -static void printctrl(struct sim_ctrl *); -static int opendev(int *); -static commandfunc_t cmdstatus; -static commandfunc_t cmdconf; -static commandfunc_t cmdstart; -static commandfunc_t cmdstop; -static commandfunc_t cmdmod; -static commandfunc_t cmderror; -static commandfunc_t cmdbb; -static commandfunc_t cmdfreeze; -static commandfunc_t cmdlog; -static commandfunc_t cmdstats; -static commandfunc_t cmddump; -static commandfunc_t cmdrestore; -static commandfunc_t cmddestroy; -static commandfunc_t cmdhelp; -static int checkusage(int, int, char **); -static int is_chip_created(int, int, int *); -static int is_ctrl_created(int, int *); -static int is_ctrl_running(int, int *); -static int assert_chip_connected(int , int); -static int printstats(int, int, uint32_t, int); - -struct nandsim_command { - const char *cmd_name; /* Command name */ - commandfunc_t *commandfunc; /* Ptr to command function */ - uint8_t req_argc; /* Mandatory arguments count */ - const char *usagestring; /* Usage string */ -}; - -static struct nandsim_command commands[] = { - {"status", cmdstatus, 1, - "status [-v]\n" }, - {"conf", cmdconf, 1, - "conf \n" }, - {"start", cmdstart, 1, - "start \n" }, - {"mod", cmdmod, 2, - "mod [-l ] | [-p ]\n" - "\t[-e ] [-r ]\n" - "\t[-E ] | [-h]\n" }, - {"stop", cmdstop, 1, - "stop \n" }, - {"error", cmderror, 5, - "error \n" }, - {"bb", cmdbb, 2, - "bb [blk_num1,blk_num2,..] [-U] [-L]\n" }, - {"freeze", cmdfreeze, 1, - "freeze [ctrl_no]\n" }, - {"log", cmdlog, 1, - "log \n" }, - {"stats", cmdstats, 2, - "stats \n" }, - {"dump", cmddump, 2, - "dump \n" }, - {"restore", cmdrestore, 2, - "restore \n" }, - {"destroy", cmddestroy, 1, - "destroy \n" }, - {"help", cmdhelp, 0, - "help [-v]" }, - {NULL, NULL, 0, NULL}, -}; - - -/* Parse command name, and start appropriate function */ -static struct nandsim_command* -getcommand(char *arg) -{ - struct nandsim_command *opts; - - for (opts = commands; (opts != NULL) && - (opts->cmd_name != NULL); opts++) { - if (strcmp(opts->cmd_name, arg) == 0) - return (opts); - } - return (NULL); -} - -/* - * Parse given string in format :, if possible -- set - * ctrl and/or cs, and return 0 (success) or 1 (in case of error). - * - * ctrl == 0xff && chip == 0xff : '--all' flag specified - * ctrl != 0xff && chip != 0xff : both ctrl & chip were specified - * ctrl != 0xff && chip == 0xff : only ctrl was specified - */ -static int -parse_devstring(char *str, int *ctrl, int *cs) -{ - char *tmpstr; - unsigned int num = 0; - - /* Ignore white spaces at the beginning */ - while (isspace(*str) && (*str != '\0')) - str++; - - *ctrl = 0xff; - *cs = 0xff; - if (strcmp(str, "--all") == 0 || - strcmp(str, "-a") == 0) { - /* If --all or -a is specified, ctl==chip==0xff */ - debug("CTRL=%d CHIP=%d\n", *ctrl, *cs); - return (0); - } - /* Separate token and try to convert it to int */ - tmpstr = (char *)strtok(str, ":"); - if ((tmpstr != NULL) && (*tmpstr != '\0')) { - if (convert_arguint(tmpstr, &num) != 0) - return (1); - - if (num > MAX_SIM_DEV - 1) { - error("Invalid ctrl_no supplied: %s. Valid ctrl_no " - "value must lie between 0 and 3!", tmpstr); - return (1); - } - - *ctrl = num; - tmpstr = (char *)strtok(NULL, ":"); - - if ((tmpstr != NULL) && (*tmpstr != '\0')) { - if (convert_arguint(tmpstr, &num) != 0) - return (1); - - /* Check if chip_no is valid */ - if (num > MAX_CTRL_CS - 1) { - error("Invalid chip_no supplied: %s. Valid " - "chip_no value must lie between 0 and 3!", - tmpstr); - return (1); - } - *cs = num; - } - } else - /* Empty devstring supplied */ - return (1); - - debug("CTRL=%d CHIP=%d\n", *ctrl, *cs); - return (0); -} - -static int -opendev(int *fd) -{ - - *fd = open(SIMDEVICE, O_RDWR); - if (*fd == -1) { - error("Could not open simulator device file (%s)!", - SIMDEVICE); - return (EX_OSFILE); - } - return (EX_OK); -} - -static int -opencdev(int *cdevd, int ctrl, int chip) -{ - char fname[255]; - - sprintf(fname, "/dev/nandsim%d.%d", ctrl, chip); - *cdevd = open(fname, O_RDWR); - if (*cdevd == -1) - return (EX_NOINPUT); - - return (EX_OK); -} - -/* - * Check if given arguments count match requirements. If no, or - * --help (-h) flag is specified -- return 1 (print usage) - */ -static int -checkusage(int gargc, int argsreqd, char **gargv) -{ - - if (gargc < argsreqd + 2 || (gargc >= (argsreqd + 2) && - (strcmp(gargv[1], "--help") == 0 || - strcmp(gargv[1], "-h") == 0))) - return (1); - - return (0); -} - -static int -cmdstatus(int gargc, char **gargv) -{ - int chip = 0, ctl = 0, err = 0, fd, idx, idx2, start, stop; - uint8_t verbose = 0; - struct sim_ctrl ctrlconf; - struct sim_chip chipconf; - - err = parse_devstring(gargv[2], &ctl, &chip); - if (err) { - return (EX_USAGE); - } else if (ctl == 0xff) { - /* Every controller */ - start = 0; - stop = MAX_SIM_DEV-1; - } else { - /* Specified controller only */ - start = ctl; - stop = ctl; - } - - if (opendev(&fd) != EX_OK) - return (EX_OSFILE); - - for (idx = 0; idx < gargc; idx ++) - if (strcmp(gargv[idx], "-v") == 0 || - strcmp(gargv[idx], "--verbose") == 0) - verbose = 1; - - for (idx = start; idx <= stop; idx++) { - ctrlconf.num = idx; - err = ioctl(fd, NANDSIM_STATUS_CTRL, &ctrlconf); - if (err) { - err = EX_SOFTWARE; - error(MSG_STATUSACQCTRL, idx); - continue; - } - - printctrl(&ctrlconf); - - for (idx2 = 0; idx2 < MAX_CTRL_CS; idx2++) { - chipconf.num = idx2; - chipconf.ctrl_num = idx; - - err = ioctl(fd, NANDSIM_STATUS_CHIP, &chipconf); - if (err) { - err = EX_SOFTWARE; - error(MSG_STATUSACQCTRL, idx); - continue; - } - - printchip(&chipconf, verbose); - } - } - close(fd); - return (err); -} - -static int -cmdconf(int gargc __unused, char **gargv) -{ - int err; - - err = parse_config(gargv[2], SIMDEVICE); - if (err) - return (EX_DATAERR); - - return (EX_OK); -} - -static int -cmdstart(int gargc __unused, char **gargv) -{ - int chip = 0, ctl = 0, err = 0, fd, running, state; - - err = parse_devstring(gargv[2], &ctl, &chip); - if (err) - return (EX_USAGE); - - err = is_ctrl_created(ctl, &state); - if (err) { - return (EX_SOFTWARE); - } else if (state == 0) { - error(MSG_NOCTRL, ctl); - return (EX_SOFTWARE); - } - - err = is_ctrl_running(ctl, &running); - if (err) - return (EX_SOFTWARE); - - if (running) { - warn(MSG_RUNNING, ctl); - } else { - if (opendev(&fd) != EX_OK) - return (EX_OSFILE); - - err = ioctl(fd, NANDSIM_START_CTRL, &ctl); - close(fd); - if (err) { - error("Cannot start controller#%d", ctl); - err = EX_SOFTWARE; - } - } - return (err); -} - -static int -cmdstop(int gargc __unused, char **gargv) -{ - int chip = 0, ctl = 0, err = 0, fd, running; - - err = parse_devstring(gargv[2], &ctl, &chip); - if (err) - return (EX_USAGE); - - err = is_ctrl_running(ctl, &running); - if (err) - return (EX_SOFTWARE); - - if (!running) { - error(MSG_NOTRUNNING, ctl); - } else { - if (opendev(&fd) != EX_OK) - return (EX_OSFILE); - - err = ioctl(fd, NANDSIM_STOP_CTRL, &ctl); - close(fd); - if (err) { - error("Cannot stop controller#%d", ctl); - err = EX_SOFTWARE; - } - } - - return (err); -} - -static int -cmdmod(int gargc __unused, char **gargv) -{ - int chip, ctl, err = 0, fd = -1, i; - struct sim_mod mods; - - if (gargc >= 4) { - if (strcmp(gargv[2], "--loglevel") == 0 || strcmp(gargv[2], - "-l") == 0) { - /* Set loglevel (ctrl:chip pair independent) */ - mods.field = SIM_MOD_LOG_LEVEL; - - if (convert_arguint(gargv[3], &mods.new_value) != 0) - return (EX_SOFTWARE); - - if (opendev(&fd) != EX_OK) - return (EX_OSFILE); - - err = ioctl(fd, NANDSIM_MODIFY, &mods); - if (err) { - error("simulator parameter %s could not be " - "modified !", gargv[3]); - close(fd); - return (EX_SOFTWARE); - } - - debug("request : loglevel = %d\n", mods.new_value); - close(fd); - return (EX_OK); - } - } - - err = parse_devstring(gargv[2], &ctl, &chip); - if (err) - return (EX_USAGE); - - else if (chip == 0xff) { - error(MSG_CTRLCHIPNEEDED); - return (EX_USAGE); - } - - if (!assert_chip_connected(ctl, chip)) - return (EX_SOFTWARE); - - if (opendev(&fd) != EX_OK) - return (EX_OSFILE); - - /* Find out which flags were passed */ - for (i = 3; i < gargc; i++) { - - if (convert_arguint(gargv[i + 1], &mods.new_value) != 0) - continue; - - if (strcmp(gargv[i], "--prog-time") == 0 || - strcmp(gargv[i], "-p") == 0) { - - mods.field = SIM_MOD_PROG_TIME; - debug("request : progtime = %d\n", mods.new_value); - - } else if (strcmp(gargv[i], "--erase-time") == 0 || - strcmp(gargv[i], "-e") == 0) { - - mods.field = SIM_MOD_ERASE_TIME; - debug("request : eraseime = %d\n", mods.new_value); - - } else if (strcmp(gargv[i], "--read-time") == 0 || - strcmp(gargv[i], "-r") == 0) { - - mods.field = SIM_MOD_READ_TIME; - debug("request : read_time = %d\n", mods.new_value); - - } else if (strcmp(gargv[i], "--error-ratio") == 0 || - strcmp(gargv[i], "-E") == 0) { - - mods.field = SIM_MOD_ERROR_RATIO; - debug("request : error_ratio = %d\n", mods.new_value); - - } else { - /* Flag not recognized, or nothing specified. */ - error("Unrecognized flag:%s\n", gargv[i]); - if (fd >= 0) - close(fd); - return (EX_USAGE); - } - - mods.chip_num = chip; - mods.ctrl_num = ctl; - - /* Call appropriate ioctl */ - err = ioctl(fd, NANDSIM_MODIFY, &mods); - if (err) { - error("simulator parameter %s could not be modified! ", - gargv[i]); - continue; - } - i++; - } - close(fd); - return (EX_OK); -} - -static int -cmderror(int gargc __unused, char **gargv) -{ - uint32_t page, column, len, pattern; - int chip = 0, ctl = 0, err = 0, fd; - struct sim_error sim_err; - - err = parse_devstring(gargv[2], &ctl, &chip); - if (err) - return (EX_USAGE); - - if (chip == 0xff) { - error(MSG_CTRLCHIPNEEDED); - return (EX_USAGE); - } - - if (convert_arguint(gargv[3], &page) || - convert_arguint(gargv[4], &column) || - convert_arguint(gargv[5], &len) || - convert_arguint(gargv[6], &pattern)) - return (EX_SOFTWARE); - - if (!assert_chip_connected(ctl, chip)) - return (EX_SOFTWARE); - - sim_err.page_num = page; - sim_err.column = column; - sim_err.len = len; - sim_err.pattern = pattern; - sim_err.ctrl_num = ctl; - sim_err.chip_num = chip; - - if (opendev(&fd) != EX_OK) - return (EX_OSFILE); - - err = ioctl(fd, NANDSIM_INJECT_ERROR, &sim_err); - - close(fd); - if (err) { - error("Could not inject error !"); - return (EX_SOFTWARE); - } - return (EX_OK); -} - -static int -cmdbb(int gargc, char **gargv) -{ - struct sim_block_state bs; - struct chip_param_io cparams; - uint32_t blkidx; - int c, cdevd, chip = 0, ctl = 0, err = 0, fd, idx; - uint8_t flagL = 0, flagU = 0; - int *badblocks = NULL; - - /* Check for --list/-L or --unmark/-U flags */ - for (idx = 3; idx < gargc; idx++) { - if (strcmp(gargv[idx], "--list") == 0 || - strcmp(gargv[idx], "-L") == 0) - flagL = idx; - if (strcmp(gargv[idx], "--unmark") == 0 || - strcmp(gargv[idx], "-U") == 0) - flagU = idx; - } - - if (flagL == 2 || flagU == 2 || flagU == 3) - return (EX_USAGE); - - err = parse_devstring(gargv[2], &ctl, &chip); - if (err) { - return (EX_USAGE); - } - if (chip == 0xff || ctl == 0xff) { - error(MSG_CTRLCHIPNEEDED); - return (EX_USAGE); - } - - bs.ctrl_num = ctl; - bs.chip_num = chip; - - if (!assert_chip_connected(ctl, chip)) - return (EX_SOFTWARE); - - if (opencdev(&cdevd, ctl, chip) != EX_OK) - return (EX_OSFILE); - - err = ioctl(cdevd, NAND_IO_GET_CHIP_PARAM, &cparams); - if (err) - return (EX_SOFTWARE); - - close(cdevd); - - bs.ctrl_num = ctl; - bs.chip_num = chip; - - if (opendev(&fd) != EX_OK) - return (EX_OSFILE); - - if (flagL != 3) { - /* - * Flag -L was specified either after blocklist or was not - * specified at all. - */ - c = parse_intarray(gargv[3], &badblocks); - - for (idx = 0; idx < c; idx++) { - bs.block_num = badblocks[idx]; - /* Do not change wearout */ - bs.wearout = -1; - bs.state = (flagU == 0) ? NANDSIM_BAD_BLOCK : - NANDSIM_GOOD_BLOCK; - - err = ioctl(fd, NANDSIM_SET_BLOCK_STATE, &bs); - if (err) { - error("Could not set bad block(%d) for " - "controller (%d)!", - badblocks[idx], ctl); - err = EX_SOFTWARE; - break; - } - } - } - if (flagL != 0) { - /* If flag -L was specified (anywhere) */ - for (blkidx = 0; blkidx < cparams.blocks; blkidx++) { - bs.block_num = blkidx; - /* Do not change the wearout */ - bs.wearout = -1; - err = ioctl(fd, NANDSIM_GET_BLOCK_STATE, &bs); - if (err) { - error("Could not acquire block state"); - err = EX_SOFTWARE; - continue; - } - printf("Block#%d: wear count: %d %s\n", blkidx, - bs.wearout, - (bs.state == NANDSIM_BAD_BLOCK) ? "BAD":"GOOD"); - } - } - close(fd); - return (err); -} - -static int -cmdfreeze(int gargc __unused, char **gargv) -{ - int chip = 0, ctl = 0, err = 0, fd, i, start = 0, state, stop = 0; - struct sim_ctrl_chip ctrlchip; - - err = parse_devstring(gargv[2], &ctl, &chip); - if (err) - return (EX_USAGE); - - if (ctl == 0xff) { - error("You have to specify at least controller number"); - return (EX_USAGE); - } - - if (ctl != 0xff && chip == 0xff) { - start = 0; - stop = MAX_CTRL_CS - 1; - } else { - start = chip; - stop = chip; - } - - ctrlchip.ctrl_num = ctl; - - err = is_ctrl_running(ctl, &state); - if (err) - return (EX_SOFTWARE); - if (state == 0) { - error(MSG_NOTRUNNING, ctl); - return (EX_SOFTWARE); - } - - if (opendev(&fd) != EX_OK) - return (EX_OSFILE); - - for (i = start; i <= stop; i++) { - err = is_chip_created(ctl, i, &state); - if (err) - return (EX_SOFTWARE); - else if (state == 0) { - continue; - } - - ctrlchip.chip_num = i; - err = ioctl(fd, NANDSIM_FREEZE, &ctrlchip); - if (err) { - error("Could not freeze ctrl#%d chip#%d", ctl, i); - close(fd); - return (EX_SOFTWARE); - } - } - close(fd); - return (EX_OK); -} - -static int -cmdlog(int gargc __unused, char **gargv) -{ - struct sim_log log; - int chip = 0, ctl = 0, err = 0, fd, idx, start = 0, stop = 0; - char *logbuf; - - err = parse_devstring(gargv[2], &ctl, &chip); - if (err) - return (EX_USAGE); - - logbuf = (char *)malloc(sizeof(char) * NANDSIM_RAM_LOG_SIZE); - if (logbuf == NULL) { - error("Not enough memory to create log buffer"); - return (EX_SOFTWARE); - } - - memset(logbuf, 0, NANDSIM_RAM_LOG_SIZE); - log.log = logbuf; - log.len = NANDSIM_RAM_LOG_SIZE; - - if (ctl == 0xff) { - start = 0; - stop = MAX_SIM_DEV-1; - } else { - start = ctl; - stop = ctl; - } - - if (opendev(&fd) != EX_OK) { - free(logbuf); - return (EX_OSFILE); - } - - /* Print logs for selected controller(s) */ - for (idx = start; idx <= stop; idx++) { - log.ctrl_num = idx; - - err = ioctl(fd, NANDSIM_PRINT_LOG, &log); - if (err) { - error("Could not get log for controller %d!", idx); - continue; - } - - printf("Logs for controller#%d:\n%s\n", idx, logbuf); - } - - free(logbuf); - close(fd); - return (EX_OK); -} - -static int -cmdstats(int gargc __unused, char **gargv) -{ - int cdevd, chip = 0, ctl = 0, err = 0; - uint32_t pageno = 0; - - err = parse_devstring(gargv[2], &ctl, &chip); - - if (err) - return (EX_USAGE); - - if (chip == 0xff) { - error(MSG_CTRLCHIPNEEDED); - return (EX_USAGE); - } - - if (convert_arguint(gargv[3], &pageno) != 0) - return (EX_USAGE); - - if (!assert_chip_connected(ctl, chip)) - return (EX_SOFTWARE); - - if (opencdev(&cdevd, ctl, chip) != EX_OK) - return (EX_OSFILE); - - err = printstats(ctl, chip, pageno, cdevd); - if (err) { - close(cdevd); - return (EX_SOFTWARE); - } - close(cdevd); - return (EX_OK); -} - -static int -cmddump(int gargc __unused, char **gargv) -{ - struct sim_dump dump; - struct sim_block_state bs; - struct chip_param_io cparams; - int chip = 0, ctl = 0, err = EX_OK, fd, dumpfd; - uint32_t blkidx, bwritten = 0, totalwritten = 0; - void *buf; - - err = parse_devstring(gargv[2], &ctl, &chip); - if (err) - return (EX_USAGE); - - if (chip == 0xff || ctl == 0xff) { - error(MSG_CTRLCHIPNEEDED); - return (EX_USAGE); - } - - if (!assert_chip_connected(ctl, chip)) - return (EX_SOFTWARE); - - if (opencdev(&fd, ctl, chip) != EX_OK) - return (EX_OSFILE); - - err = ioctl(fd, NAND_IO_GET_CHIP_PARAM, &cparams); - if (err) { - error("Cannot get parameters for chip %d:%d", ctl, chip); - close(fd); - return (EX_SOFTWARE); - } - close(fd); - - dump.ctrl_num = ctl; - dump.chip_num = chip; - - dump.len = cparams.pages_per_block * (cparams.page_size + - cparams.oob_size); - - buf = malloc(dump.len); - if (buf == NULL) { - error("Could not allocate memory!"); - return (EX_SOFTWARE); - } - dump.data = buf; - - errno = 0; - dumpfd = open(gargv[3], O_WRONLY | O_CREAT, 0666); - if (dumpfd == -1) { - error("Cannot create dump file."); - free(buf); - return (EX_SOFTWARE); - } - - if (opendev(&fd)) { - close(dumpfd); - free(buf); - return (EX_SOFTWARE); - } - - bs.ctrl_num = ctl; - bs.chip_num = chip; - - /* First uint32_t in file shall contain block count */ - if (write(dumpfd, &cparams, sizeof(cparams)) < (int)sizeof(cparams)) { - error("Error writing to dumpfile!"); - close(fd); - close(dumpfd); - free(buf); - return (EX_SOFTWARE); - } - - /* - * First loop acquires blocks states and writes them to - * the dump file. - */ - for (blkidx = 0; blkidx < cparams.blocks; blkidx++) { - bs.block_num = blkidx; - err = ioctl(fd, NANDSIM_GET_BLOCK_STATE, &bs); - if (err) { - error("Could not get bad block(%d) for " - "controller (%d)!", blkidx, ctl); - close(fd); - close(dumpfd); - free(buf); - return (EX_SOFTWARE); - } - - bwritten = write(dumpfd, &bs, sizeof(bs)); - if (bwritten != sizeof(bs)) { - error("Error writing to dumpfile"); - close(fd); - close(dumpfd); - free(buf); - return (EX_SOFTWARE); - } - } - - /* Second loop dumps the data */ - for (blkidx = 0; blkidx < cparams.blocks; blkidx++) { - debug("Block#%d...", blkidx); - dump.block_num = blkidx; - - err = ioctl(fd, NANDSIM_DUMP, &dump); - if (err) { - error("Could not dump ctrl#%d chip#%d " - "block#%d", ctl, chip, blkidx); - err = EX_SOFTWARE; - break; - } - - bwritten = write(dumpfd, dump.data, dump.len); - if (bwritten != dump.len) { - error("Error writing to dumpfile"); - err = EX_SOFTWARE; - break; - } - debug("OK!\n"); - totalwritten += bwritten; - } - printf("%d out of %d B written.\n", totalwritten, dump.len * blkidx); - - close(fd); - close(dumpfd); - free(buf); - return (err); -} - -static int -cmdrestore(int gargc __unused, char **gargv) -{ - struct sim_dump dump; - struct sim_block_state bs; - struct stat filestat; - int chip = 0, ctl = 0, err = 0, fd, dumpfd = -1; - uint32_t blkidx, blksz, fsize = 0, expfilesz; - void *buf; - struct chip_param_io cparams, dumpcparams; - - err = parse_devstring(gargv[2], &ctl, &chip); - if (err) - return (EX_USAGE); - else if (ctl == 0xff) { - error(MSG_CTRLCHIPNEEDED); - return (EX_USAGE); - } - - if (!assert_chip_connected(ctl, chip)) - return (EX_SOFTWARE); - - /* Get chip geometry */ - if (opencdev(&fd, ctl, chip) != EX_OK) - return (EX_OSFILE); - - err = ioctl(fd, NAND_IO_GET_CHIP_PARAM, &cparams); - if (err) { - error("Cannot get parameters for chip %d:%d", ctl, chip); - close(fd); - return (err); - } - close(fd); - - /* Obtain dump file size */ - errno = 0; - if (stat(gargv[3], &filestat) != 0) { - error("Could not acquire file size! : %s", - strerror(errno)); - return (EX_IOERR); - } - - fsize = filestat.st_size; - blksz = cparams.pages_per_block * (cparams.page_size + - cparams.oob_size); - - /* Expected dump file size for chip */ - expfilesz = cparams.blocks * (blksz + sizeof(bs)) + sizeof(cparams); - - if (fsize != expfilesz) { - error("File size does not match chip geometry (file size: %d" - ", dump size: %d)", fsize, expfilesz); - return (EX_SOFTWARE); - } - - dumpfd = open(gargv[3], O_RDONLY); - if (dumpfd == -1) { - error("Could not open dump file!"); - return (EX_IOERR); - } - - /* Read chip params saved in dumpfile */ - read(dumpfd, &dumpcparams, sizeof(dumpcparams)); - - /* XXX */ - if (bcmp(&dumpcparams, &cparams, sizeof(cparams)) != 0) { - error("Supplied dump is created for a chip with different " - "chip configuration!"); - close(dumpfd); - return (EX_SOFTWARE); - } - - if (opendev(&fd) != EX_OK) { - close(dumpfd); - return (EX_OSFILE); - } - - buf = malloc(blksz); - if (buf == NULL) { - error("Could not allocate memory for block buffer"); - close(dumpfd); - close(fd); - return (EX_SOFTWARE); - } - - dump.ctrl_num = ctl; - dump.chip_num = chip; - dump.data = buf; - /* Restore block states and wearouts */ - for (blkidx = 0; blkidx < cparams.blocks; blkidx++) { - dump.block_num = blkidx; - if (read(dumpfd, &bs, sizeof(bs)) != sizeof(bs)) { - error("Error reading dumpfile"); - close(dumpfd); - close(fd); - free(buf); - return (EX_SOFTWARE); - } - bs.ctrl_num = ctl; - bs.chip_num = chip; - debug("BLKIDX=%d BLOCKS=%d CTRL=%d CHIP=%d STATE=%d\n" - "WEAROUT=%d BS.CTRL_NUM=%d BS.CHIP_NUM=%d\n", - blkidx, cparams.blocks, dump.ctrl_num, dump.chip_num, - bs.state, bs.wearout, bs.ctrl_num, bs.chip_num); - - err = ioctl(fd, NANDSIM_SET_BLOCK_STATE, &bs); - if (err) { - error("Could not set bad block(%d) for " - "controller: %d, chip: %d!", blkidx, ctl, chip); - close(dumpfd); - close(fd); - free(buf); - return (EX_SOFTWARE); - } - } - /* Restore data */ - for (blkidx = 0; blkidx < cparams.blocks; blkidx++) { - errno = 0; - dump.len = read(dumpfd, buf, blksz); - if (errno) { - error("Failed to read block#%d from dumpfile.", blkidx); - err = EX_SOFTWARE; - break; - } - dump.block_num = blkidx; - err = ioctl(fd, NANDSIM_RESTORE, &dump); - if (err) { - error("Could not restore block#%d of ctrl#%d chip#%d" - ": %s", blkidx, ctl, chip, strerror(errno)); - err = EX_SOFTWARE; - break; - } - } - - free(buf); - close(dumpfd); - close(fd); - return (err); - -} - -static int -cmddestroy(int gargc __unused, char **gargv) -{ - int chip = 0, ctl = 0, err = 0, fd, idx, idx2, state; - int chipstart, chipstop, ctrlstart, ctrlstop; - struct sim_chip_destroy chip_destroy; - - err = parse_devstring(gargv[2], &ctl, &chip); - - if (err) - return (EX_USAGE); - - if (ctl == 0xff) { - /* Every chip at every controller */ - ctrlstart = chipstart = 0; - ctrlstop = MAX_SIM_DEV - 1; - chipstop = MAX_CTRL_CS - 1; - } else { - ctrlstart = ctrlstop = ctl; - if (chip == 0xff) { - /* Every chip at selected controller */ - chipstart = 0; - chipstop = MAX_CTRL_CS - 1; - } else - /* Selected chip at selected controller */ - chipstart = chipstop = chip; - } - debug("CTRLSTART=%d CTRLSTOP=%d CHIPSTART=%d CHIPSTOP=%d\n", - ctrlstart, ctrlstop, chipstart, chipstop); - for (idx = ctrlstart; idx <= ctrlstop; idx++) { - err = is_ctrl_created(idx, &state); - if (err) { - error("Could not acquire ctrl#%d state. Cannot " - "destroy controller.", idx); - return (EX_SOFTWARE); - } - if (state == 0) { - continue; - } - err = is_ctrl_running(idx, &state); - if (err) { - error(MSG_STATUSACQCTRL, idx); - return (EX_SOFTWARE); - } - if (state != 0) { - error(MSG_RUNNING, ctl); - return (EX_SOFTWARE); - } - if (opendev(&fd) != EX_OK) - return (EX_OSFILE); - - for (idx2 = chipstart; idx2 <= chipstop; idx2++) { - err = is_chip_created(idx, idx2, &state); - if (err) { - error(MSG_STATUSACQCTRLCHIP, idx2, idx); - continue; - } - if (state == 0) - /* There is no such chip running */ - continue; - chip_destroy.ctrl_num = idx; - chip_destroy.chip_num = idx2; - ioctl(fd, NANDSIM_DESTROY_CHIP, - &chip_destroy); - } - /* If chip isn't explicitly specified -- destroy ctrl */ - if (chip == 0xff) { - err = ioctl(fd, NANDSIM_DESTROY_CTRL, &idx); - if (err) { - error("Could not destroy ctrl#%d", idx); - continue; - } - } - close(fd); - } - return (err); -} - -int -main(int argc, char **argv) -{ - struct nandsim_command *cmdopts; - int retcode = 0; - - if (argc < 2) { - cmdhelp(argc, argv); - retcode = EX_USAGE; - } else { - cmdopts = getcommand(argv[1]); - if (cmdopts != NULL && cmdopts->commandfunc != NULL) { - if (checkusage(argc, cmdopts->req_argc, argv) == 1) { - /* Print command specific usage */ - printf("nandsim %s", cmdopts->usagestring); - return (EX_USAGE); - } - retcode = cmdopts->commandfunc(argc, argv); - - if (retcode == EX_USAGE) { - /* Print command-specific usage */ - printf("nandsim %s", cmdopts->usagestring); - } else if (retcode == EX_OSFILE) { - error("Could not open device file"); - } - - } else { - error("Unknown command!"); - retcode = EX_USAGE; - } - } - return (retcode); -} - -static int -cmdhelp(int gargc __unused, char **gargv __unused) -{ - struct nandsim_command *opts; - - printf("usage: nandsim [command params] [params]\n\n"); - - for (opts = commands; (opts != NULL) && - (opts->cmd_name != NULL); opts++) - printf("nandsim %s", opts->usagestring); - - printf("\n"); - return (EX_OK); -} - -static void -printchip(struct sim_chip *chip, uint8_t verbose) -{ - - if (chip->created == 0) - return; - if (verbose > 0) { - printf("\n[Chip info]\n"); - printf("num= %d\nctrl_num=%d\ndevice_id=%02x" - "\tmanufacturer_id=%02x\ndevice_model=%s\nmanufacturer=" - "%s\ncol_addr_cycles=%d\nrow_addr_cycles=%d" - "\npage_size=%d\noob_size=%d\npages_per_block=%d\n" - "blocks_per_lun=%d\nluns=%d\n\nprog_time=%d\n" - "erase_time=%d\nread_time=%d\n" - "error_ratio=%d\nwear_level=%d\nwrite_protect=%c\n" - "chip_width=%db\n", chip->num, chip->ctrl_num, - chip->device_id, chip->manufact_id,chip->device_model, - chip->manufacturer, chip->col_addr_cycles, - chip->row_addr_cycles, chip->page_size, - chip->oob_size, chip->pgs_per_blk, chip->blks_per_lun, - chip->luns,chip->prog_time, chip->erase_time, - chip->read_time, chip->error_ratio, chip->wear_level, - (chip->is_wp == 0) ? 'N':'Y', chip->width); - } else { - printf("[Chip info]\n"); - printf("\tnum=%d\n\tdevice_model=%s\n\tmanufacturer=%s\n" - "\tpage_size=%d\n\twrite_protect=%s\n", - chip->num, chip->device_model, chip->manufacturer, - chip->page_size, (chip->is_wp == 0) ? "NO":"YES"); - } -} - -static void -printctrl(struct sim_ctrl *ctrl) -{ - int i; - - if (ctrl->created == 0) { - printf(MSG_NOCTRL "\n", ctrl->num); - return; - } - printf("\n[Controller info]\n"); - printf("\trunning: %s\n", ctrl->running ? "yes" : "no"); - printf("\tnum cs: %d\n", ctrl->num_cs); - printf("\tecc: %d\n", ctrl->ecc); - printf("\tlog_filename: %s\n", ctrl->filename); - printf("\tecc_layout:"); - for (i = 0; i < MAX_ECC_BYTES; i++) { - if (ctrl->ecc_layout[i] == 0xffff) - break; - else - printf("%c%d", i%16 ? ' ' : '\n', - ctrl->ecc_layout[i]); - } - printf("\n"); -} - -static int -is_ctrl_running(int ctrl_no, int *running) -{ - struct sim_ctrl ctrl; - int err, fd; - - ctrl.num = ctrl_no; - if (opendev(&fd) != EX_OK) - return (EX_OSFILE); - - err = ioctl(fd, NANDSIM_STATUS_CTRL, &ctrl); - if (err) { - error(MSG_STATUSACQCTRL, ctrl_no); - close(fd); - return (err); - } - *running = ctrl.running; - close(fd); - return (0); -} - -static int -is_ctrl_created(int ctrl_no, int *created) -{ - struct sim_ctrl ctrl; - int err, fd; - - ctrl.num = ctrl_no; - - if (opendev(&fd) != EX_OK) - return (EX_OSFILE); - - err = ioctl(fd, NANDSIM_STATUS_CTRL, &ctrl); - if (err) { - error("Could not acquire conf for ctrl#%d", ctrl_no); - close(fd); - return (err); - } - *created = ctrl.created; - close(fd); - return (0); -} - -static int -is_chip_created(int ctrl_no, int chip_no, int *created) -{ - struct sim_chip chip; - int err, fd; - - chip.ctrl_num = ctrl_no; - chip.num = chip_no; - - if (opendev(&fd) != EX_OK) - return (EX_OSFILE); - - err = ioctl(fd, NANDSIM_STATUS_CHIP, &chip); - if (err) { - error("Could not acquire conf for chip#%d", chip_no); - close(fd); - return (err); - } - *created = chip.created; - close(fd); - return (0); -} - -static int -assert_chip_connected(int ctrl_no, int chip_no) -{ - int created, running; - - if (is_ctrl_created(ctrl_no, &created)) - return (0); - - if (!created) { - error(MSG_NOCTRL, ctrl_no); - return (0); - } - - if (is_chip_created(ctrl_no, chip_no, &created)) - return (0); - - if (!created) { - error(MSG_NOTCONFIGDCTRLCHIP, ctrl_no, chip_no); - return (0); - } - - if (is_ctrl_running(ctrl_no, &running)) - return (0); - - if (!running) { - error(MSG_NOTRUNNING, ctrl_no); - return (0); - } - - return (1); -} - -static int -printstats(int ctrlno, int chipno, uint32_t pageno, int cdevd) -{ - struct page_stat_io pstats; - struct block_stat_io bstats; - struct chip_param_io cparams; - uint32_t blkidx; - int err; - - /* Gather information about chip */ - err = ioctl(cdevd, NAND_IO_GET_CHIP_PARAM, &cparams); - - if (err) { - error("Could not acquire chip info for chip attached to cs#" - "%d, ctrl#%d", chipno, ctrlno); - return (EX_SOFTWARE); - } - - blkidx = (pageno / cparams.pages_per_block); - bstats.block_num = blkidx; - - err = ioctl(cdevd, NAND_IO_BLOCK_STAT, &bstats); - if (err) { - error("Could not acquire block#%d statistics!", blkidx); - return (ENXIO); - } - - printf("Block #%d erased: %d\n", blkidx, bstats.block_erased); - pstats.page_num = pageno; - - err = ioctl(cdevd, NAND_IO_PAGE_STAT, &pstats); - if (err) { - error("Could not acquire page statistics!"); - return (ENXIO); - } - - debug("BLOCKIDX = %d PAGENO (REL. TO BLK) = %d\n", blkidx, - pstats.page_num); - - printf("Page#%d : reads:%d writes:%d \n\traw reads:%d raw writes:%d " - "\n\tecc_succeeded:%d ecc_corrected:%d ecc_failed:%d\n", - pstats.page_num, pstats.page_read, pstats.page_written, - pstats.page_raw_read, pstats.page_raw_written, - pstats.ecc_succeded, pstats.ecc_corrected, pstats.ecc_failed); - return (0); -} diff --git a/usr.sbin/nandsim/nandsim_cfgparse.c b/usr.sbin/nandsim/nandsim_cfgparse.c deleted file mode 100644 index 0445f0363df..00000000000 --- a/usr.sbin/nandsim/nandsim_cfgparse.c +++ /dev/null @@ -1,960 +0,0 @@ -/*- - * SPDX-License-Identifier: BSD-2-Clause-FreeBSD - * - * Copyright (C) 2009-2012 Semihalf - * 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 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. - */ - -#include - -#include -#include -#include - -#include - -#include -#include -#include -#include -#include -#include -#include - -#include "nandsim_cfgparse.h" - -#define warn(fmt, args...) do { \ - printf("WARNING: " fmt "\n", ##args); } while (0) - -#define error(fmt, args...) do { \ - printf("ERROR: " fmt "\n", ##args); } while (0) - -#define MSG_MANDATORYKEYMISSING "mandatory key \"%s\" value belonging to " \ - "section \"%s\" is missing!\n" - -#define DEBUG -#undef DEBUG - -#ifdef DEBUG -#define debug(fmt, args...) do { \ - printf("NANDSIM_CONF:" fmt "\n", ##args); } while (0) -#else -#define debug(fmt, args...) do {} while(0) -#endif - -#define STRBUFSIZ 2000 - -/* Macros extracts type and type size */ -#define TYPE(x) ((x) & 0xf8) -#define SIZE(x) (((x) & 0x07)) - -/* Erase/Prog/Read time max and min values */ -#define DELAYTIME_MIN 10000 -#define DELAYTIME_MAX 10000000 - -/* Structure holding configuration for controller. */ -static struct sim_ctrl ctrl_conf; -/* Structure holding configuration for chip. */ -static struct sim_chip chip_conf; - -static struct nandsim_key nandsim_ctrl_keys[] = { - {"num_cs", 1, VALUE_UINT | SIZE_8, (void *)&ctrl_conf.num_cs, 0}, - {"ctrl_num", 1, VALUE_UINT | SIZE_8, (void *)&ctrl_conf.num, 0}, - - {"ecc_layout", 1, VALUE_UINTARRAY | SIZE_16, - (void *)&ctrl_conf.ecc_layout, MAX_ECC_BYTES}, - - {"filename", 0, VALUE_STRING, - (void *)&ctrl_conf.filename, FILENAME_SIZE}, - - {"ecc", 0, VALUE_BOOL, (void *)&ctrl_conf.ecc, 0}, - {NULL, 0, 0, NULL, 0}, -}; - -static struct nandsim_key nandsim_chip_keys[] = { - {"chip_cs", 1, VALUE_UINT | SIZE_8, (void *)&chip_conf.num, 0}, - {"chip_ctrl", 1, VALUE_UINT | SIZE_8, (void *)&chip_conf.ctrl_num, - 0}, - {"device_id", 1, VALUE_UINT | SIZE_8, (void *)&chip_conf.device_id, - 0}, - {"manufacturer_id", 1, VALUE_UINT | SIZE_8, - (void *)&chip_conf.manufact_id, 0}, - {"model", 0, VALUE_STRING, (void *)&chip_conf.device_model, - DEV_MODEL_STR_SIZE}, - {"manufacturer", 0, VALUE_STRING, (void *)&chip_conf.manufacturer, - MAN_STR_SIZE}, - {"page_size", 1, VALUE_UINT | SIZE_32, (void *)&chip_conf.page_size, - 0}, - {"oob_size", 1, VALUE_UINT | SIZE_32, (void *)&chip_conf.oob_size, - 0}, - {"pages_per_block", 1, VALUE_UINT | SIZE_32, - (void *)&chip_conf.pgs_per_blk, 0}, - {"blocks_per_lun", 1, VALUE_UINT | SIZE_32, - (void *)&chip_conf.blks_per_lun, 0}, - {"luns", 1, VALUE_UINT | SIZE_32, (void *)&chip_conf.luns, 0}, - {"column_addr_cycle", 1,VALUE_UINT | SIZE_8, - (void *)&chip_conf.col_addr_cycles, 0}, - {"row_addr_cycle", 1, VALUE_UINT | SIZE_8, - (void *)&chip_conf.row_addr_cycles, 0}, - {"program_time", 0, VALUE_UINT | SIZE_32, - (void *)&chip_conf.prog_time, 0}, - {"erase_time", 0, VALUE_UINT | SIZE_32, - (void *)&chip_conf.erase_time, 0}, - {"read_time", 0, VALUE_UINT | SIZE_32, - (void *)&chip_conf.read_time, 0}, - {"width", 1, VALUE_UINT | SIZE_8, (void *)&chip_conf.width, 0}, - {"wear_out", 1, VALUE_UINT | SIZE_32, (void *)&chip_conf.wear_level, - 0}, - {"bad_block_map", 0, VALUE_UINTARRAY | SIZE_32, - (void *)&chip_conf.bad_block_map, MAX_BAD_BLOCKS}, - {NULL, 0, 0, NULL, 0}, -}; - -static struct nandsim_section sections[] = { - {"ctrl", (struct nandsim_key *)&nandsim_ctrl_keys}, - {"chip", (struct nandsim_key *)&nandsim_chip_keys}, - {NULL, NULL}, -}; - -static uint8_t logoutputtoint(char *, int *); -static uint8_t validate_chips(struct sim_chip *, int, struct sim_ctrl *, int); -static uint8_t validate_ctrls(struct sim_ctrl *, int); -static int configure_sim(const char *, struct rcfile *); -static int create_ctrls(struct rcfile *, struct sim_ctrl **, int *); -static int create_chips(struct rcfile *, struct sim_chip **, int *); -static void destroy_ctrls(struct sim_ctrl *); -static void destroy_chips(struct sim_chip *); -static int validate_section_config(struct rcfile *, const char *, int); - -int -convert_argint(char *arg, int *value) -{ - - if (arg == NULL || value == NULL) - return (EINVAL); - - errno = 0; - *value = (int)strtol(arg, NULL, 0); - if (*value == 0 && errno != 0) { - error("Cannot convert to number argument \'%s\'", arg); - return (EINVAL); - } - return (0); -} - -int -convert_arguint(char *arg, unsigned int *value) -{ - - if (arg == NULL || value == NULL) - return (EINVAL); - - errno = 0; - *value = (unsigned int)strtol(arg, NULL, 0); - if (*value == 0 && errno != 0) { - error("Cannot convert to number argument \'%s\'", arg); - return (EINVAL); - } - return (0); -} - -/* Parse given ',' separated list of bytes into buffer. */ -int -parse_intarray(char *array, int **buffer) -{ - char *tmp, *tmpstr, *origstr; - unsigned int currbufp = 0, i; - unsigned int count = 0, from = 0, to = 0; - - /* Remove square braces */ - if (array[0] == '[') - array ++; - if (array[strlen(array)-1] == ']') - array[strlen(array)-1] = ','; - - from = strlen(array); - origstr = (char *)malloc(sizeof(char) * from); - strcpy(origstr, array); - - tmpstr = (char *)strtok(array, ","); - /* First loop checks for how big int array we need to allocate */ - while (tmpstr != NULL) { - errno = 0; - if ((tmp = strchr(tmpstr, '-')) != NULL) { - *tmp = ' '; - if (convert_arguint(tmpstr, &from) || - convert_arguint(tmp, &to)) { - free(origstr); - return (EINVAL); - } - - count += to - from + 1; - } else { - if (convert_arguint(tmpstr, &from)) { - free(origstr); - return (EINVAL); - } - count++; - } - tmpstr = (char *)strtok(NULL, ","); - } - - if (count == 0) - goto out; - - /* Allocate buffer of ints */ - tmpstr = (char *)strtok(origstr, ","); - *buffer = malloc(count * sizeof(int)); - - /* Second loop is just inserting converted values into int array */ - while (tmpstr != NULL) { - errno = 0; - if ((tmp = strchr(tmpstr, '-')) != NULL) { - *tmp = ' '; - from = strtol(tmpstr, NULL, 0); - to = strtol(tmp, NULL, 0); - tmpstr = strtok(NULL, ","); - for (i = from; i <= to; i ++) - (*buffer)[currbufp++] = i; - continue; - } - errno = 0; - from = (int)strtol(tmpstr, NULL, 0); - (*buffer)[currbufp++] = from; - tmpstr = (char *)strtok(NULL, ","); - } -out: - free(origstr); - return (count); -} - -/* Convert logoutput strings literals into appropriate ints. */ -static uint8_t -logoutputtoint(char *logoutput, int *output) -{ - int out; - - if (strcmp(logoutput, "file") == 0) - out = NANDSIM_OUTPUT_FILE; - - else if (strcmp(logoutput, "console") == 0) - out = NANDSIM_OUTPUT_CONSOLE; - - else if (strcmp(logoutput, "ram") == 0) - out = NANDSIM_OUTPUT_RAM; - - else if (strcmp(logoutput, "none") == 0) - out = NANDSIM_OUTPUT_NONE; - else - out = -1; - - *output = out; - - if (out == -1) - return (EINVAL); - else - return (0); -} - -static int -configure_sim(const char *devfname, struct rcfile *f) -{ - struct sim_param sim_conf; - char buf[255]; - int err, tmpv, fd; - - err = rc_getint(f, "sim", 0, "log_level", &tmpv); - - if (tmpv < 0 || tmpv > 255 || err) { - error("Bad log level specified (%d)\n", tmpv); - return (ENOTSUP); - } else - sim_conf.log_level = tmpv; - - rc_getstring(f, "sim", 0, "log_output", 255, (char *)&buf); - - tmpv = -1; - err = logoutputtoint((char *)&buf, &tmpv); - if (err) { - error("Log output specified in config file does not seem to " - "be valid (%s)!", (char *)&buf); - return (ENOTSUP); - } - - sim_conf.log_output = tmpv; - - fd = open(devfname, O_RDWR); - if (fd == -1) { - error("could not open simulator device file (%s)!", - devfname); - return (EX_OSFILE); - } - - err = ioctl(fd, NANDSIM_SIM_PARAM, &sim_conf); - if (err) { - error("simulator parameters could not be modified: %s", - strerror(errno)); - close(fd); - return (ENXIO); - } - - close(fd); - return (EX_OK); -} - -static int -create_ctrls(struct rcfile *f, struct sim_ctrl **ctrls, int *cnt) -{ - int count, i; - struct sim_ctrl *ctrlsptr; - - count = rc_getsectionscount(f, "ctrl"); - if (count > MAX_SIM_DEV) { - error("Too many CTRL sections specified(%d)", count); - return (ENOTSUP); - } else if (count == 0) { - error("No ctrl sections specified"); - return (ENOENT); - } - - ctrlsptr = (struct sim_ctrl *)malloc(sizeof(struct sim_ctrl) * count); - if (ctrlsptr == NULL) { - error("Could not allocate memory for ctrl configuration"); - return (ENOMEM); - } - - for (i = 0; i < count; i++) { - bzero((void *)&ctrl_conf, sizeof(ctrl_conf)); - - /* - * ECC layout have to end up with 0xffff, so - * we're filling buffer with 0xff. If ecc_layout is - * defined in config file, values will be overridden. - */ - memset((void *)&ctrl_conf.ecc_layout, 0xff, - sizeof(ctrl_conf.ecc_layout)); - - if (validate_section_config(f, "ctrl", i) != 0) { - free(ctrlsptr); - return (EINVAL); - } - - if (parse_section(f, "ctrl", i) != 0) { - free(ctrlsptr); - return (EINVAL); - } - - memcpy(&ctrlsptr[i], &ctrl_conf, sizeof(ctrl_conf)); - /* Try to create ctrl with config parsed */ - debug("NUM=%d\nNUM_CS=%d\nECC=%d\nFILENAME=%s\nECC_LAYOUT[0]" - "=%d\nECC_LAYOUT[1]=%d\n\n", - ctrlsptr[i].num, ctrlsptr[i].num_cs, ctrlsptr[i].ecc, - ctrlsptr[i].filename, ctrlsptr[i].ecc_layout[0], - ctrlsptr[i].ecc_layout[1]); - } - *cnt = count; - *ctrls = ctrlsptr; - return (0); -} - -static void -destroy_ctrls(struct sim_ctrl *ctrls) -{ - - free(ctrls); -} - -static int -create_chips(struct rcfile *f, struct sim_chip **chips, int *cnt) -{ - struct sim_chip *chipsptr; - int count, i; - - count = rc_getsectionscount(f, "chip"); - if (count > (MAX_CTRL_CS * MAX_SIM_DEV)) { - error("Too many chip sections specified(%d)", count); - return (ENOTSUP); - } else if (count == 0) { - error("No chip sections specified"); - return (ENOENT); - } - - chipsptr = (struct sim_chip *)malloc(sizeof(struct sim_chip) * count); - if (chipsptr == NULL) { - error("Could not allocate memory for chip configuration"); - return (ENOMEM); - } - - for (i = 0; i < count; i++) { - bzero((void *)&chip_conf, sizeof(chip_conf)); - - /* - * Bad block map have to end up with 0xffff, so - * we're filling array with 0xff. If bad block map is - * defined in config file, values will be overridden. - */ - memset((void *)&chip_conf.bad_block_map, 0xff, - sizeof(chip_conf.bad_block_map)); - - if (validate_section_config(f, "chip", i) != 0) { - free(chipsptr); - return (EINVAL); - } - - if (parse_section(f, "chip", i) != 0) { - free(chipsptr); - return (EINVAL); - } - - memcpy(&chipsptr[i], &chip_conf, sizeof(chip_conf)); - - /* Try to create chip with config parsed */ - debug("CHIP:\nNUM=%d\nCTRL_NUM=%d\nDEVID=%d\nMANID=%d\n" - "PAGE_SZ=%d\nOOBSZ=%d\nREAD_T=%d\nDEVMODEL=%s\n" - "MAN=%s\nCOLADDRCYCLES=%d\nROWADDRCYCLES=%d\nCHWIDTH=%d\n" - "PGS/BLK=%d\nBLK/LUN=%d\nLUNS=%d\nERR_RATIO=%d\n" - "WEARLEVEL=%d\nISWP=%d\n\n\n\n", - chipsptr[i].num, chipsptr[i].ctrl_num, - chipsptr[i].device_id, chipsptr[i].manufact_id, - chipsptr[i].page_size, chipsptr[i].oob_size, - chipsptr[i].read_time, chipsptr[i].device_model, - chipsptr[i].manufacturer, chipsptr[i].col_addr_cycles, - chipsptr[i].row_addr_cycles, chipsptr[i].width, - chipsptr[i].pgs_per_blk, chipsptr[i].blks_per_lun, - chipsptr[i].luns, chipsptr[i].error_ratio, - chipsptr[i].wear_level, chipsptr[i].is_wp); - } - *cnt = count; - *chips = chipsptr; - return (0); -} - -static void -destroy_chips(struct sim_chip *chips) -{ - - free(chips); -} - -int -parse_config(char *cfgfname, const char *devfname) -{ - int err = 0, fd; - unsigned int chipsectionscnt, ctrlsectionscnt, i; - struct rcfile *f; - struct sim_chip *chips; - struct sim_ctrl *ctrls; - - err = rc_open(cfgfname, "r", &f); - if (err) { - error("could not open configuration file (%s)", cfgfname); - return (EX_NOINPUT); - } - - /* First, try to configure simulator itself. */ - if (configure_sim(devfname, f) != EX_OK) { - rc_close(f); - return (EINVAL); - } - - debug("SIM CONFIGURED!\n"); - /* Then create controllers' configs */ - if (create_ctrls(f, &ctrls, &ctrlsectionscnt) != 0) { - rc_close(f); - return (ENXIO); - } - debug("CTRLS CONFIG READ!\n"); - - /* Then create chips' configs */ - if (create_chips(f, &chips, &chipsectionscnt) != 0) { - destroy_ctrls(ctrls); - rc_close(f); - return (ENXIO); - } - debug("CHIPS CONFIG READ!\n"); - - if (validate_ctrls(ctrls, ctrlsectionscnt) != 0) { - destroy_ctrls(ctrls); - destroy_chips(chips); - rc_close(f); - return (EX_SOFTWARE); - } - if (validate_chips(chips, chipsectionscnt, ctrls, - ctrlsectionscnt) != 0) { - destroy_ctrls(ctrls); - destroy_chips(chips); - rc_close(f); - return (EX_SOFTWARE); - } - - /* Open device */ - fd = open(devfname, O_RDWR); - if (fd == -1) { - error("could not open simulator device file (%s)!", - devfname); - rc_close(f); - destroy_chips(chips); - destroy_ctrls(ctrls); - return (EX_OSFILE); - } - - debug("SIM CONFIG STARTED!\n"); - - /* At this stage, both ctrls' and chips' configs should be valid */ - for (i = 0; i < ctrlsectionscnt; i++) { - err = ioctl(fd, NANDSIM_CREATE_CTRL, &ctrls[i]); - if (err) { - if (err == EEXIST) - error("Controller#%d already created\n", - ctrls[i].num); - else if (err == EINVAL) - error("Incorrect controller number (%d)\n", - ctrls[i].num); - else - error("Could not created controller#%d\n", - ctrls[i].num); - /* Errors during controller creation stops parsing */ - close(fd); - rc_close(f); - destroy_ctrls(ctrls); - destroy_chips(chips); - return (ENXIO); - } - debug("CTRL#%d CONFIG STARTED!\n", i); - } - - for (i = 0; i < chipsectionscnt; i++) { - err = ioctl(fd, NANDSIM_CREATE_CHIP, &chips[i]); - if (err) { - if (err == EEXIST) - error("Chip#%d for controller#%d already " - "created\n", chips[i].num, - chips[i].ctrl_num); - else if (err == EINVAL) - error("Incorrect chip number (%d:%d)\n", - chips[i].num, chips[i].ctrl_num); - else - error("Could not create chip (%d:%d)\n", - chips[i].num, chips[i].ctrl_num); - error("Could not start chip#%d\n", i); - destroy_chips(chips); - destroy_ctrls(ctrls); - close(fd); - rc_close(f); - return (ENXIO); - } - } - debug("CHIPS CONFIG STARTED!\n"); - - close(fd); - rc_close(f); - destroy_chips(chips); - destroy_ctrls(ctrls); - return (0); -} - -/* - * Function tries to get appropriate value for given key, convert it to - * array of ints (of given size), and perform all the necessary checks and - * conversions. - */ -static int -get_argument_intarray(const char *sect_name, int sectno, - struct nandsim_key *key, struct rcfile *f) -{ - char strbuf[STRBUFSIZ]; - int *intbuf; - int getres; - uint32_t cnt, i = 0; - - getres = rc_getstring(f, sect_name, sectno, key->keyname, STRBUFSIZ, - (char *)&strbuf); - - if (getres != 0) { - if (key->mandatory != 0) { - error(MSG_MANDATORYKEYMISSING, key->keyname, - sect_name); - return (EINVAL); - } else - /* Non-mandatory key, not present -- skip */ - return (0); - } - cnt = parse_intarray((char *)&strbuf, &intbuf); - cnt = (cnt <= key->maxlength) ? cnt : key->maxlength; - - for (i = 0; i < cnt; i++) { - if (SIZE(key->valuetype) == SIZE_8) - *((uint8_t *)(key->field) + i) = - (uint8_t)intbuf[i]; - else if (SIZE(key->valuetype) == SIZE_16) - *((uint16_t *)(key->field) + i) = - (uint16_t)intbuf[i]; - else - *((uint32_t *)(key->field) + i) = - (uint32_t)intbuf[i]; - } - free(intbuf); - return (0); -} - -/* - * Function tries to get appropriate value for given key, convert it to - * int of certain length. - */ -static int -get_argument_int(const char *sect_name, int sectno, struct nandsim_key *key, - struct rcfile *f) -{ - int getres; - uint32_t val; - - getres = rc_getint(f, sect_name, sectno, key->keyname, &val); - if (getres != 0) { - - if (key->mandatory != 0) { - error(MSG_MANDATORYKEYMISSING, key->keyname, - sect_name); - - return (EINVAL); - } else - /* Non-mandatory key, not present -- skip */ - return (0); - } - if (SIZE(key->valuetype) == SIZE_8) - *(uint8_t *)(key->field) = (uint8_t)val; - else if (SIZE(key->valuetype) == SIZE_16) - *(uint16_t *)(key->field) = (uint16_t)val; - else - *(uint32_t *)(key->field) = (uint32_t)val; - return (0); -} - -/* Function tries to get string value for given key */ -static int -get_argument_string(const char *sect_name, int sectno, - struct nandsim_key *key, struct rcfile *f) -{ - char strbuf[STRBUFSIZ]; - int getres; - - getres = rc_getstring(f, sect_name, sectno, key->keyname, STRBUFSIZ, - strbuf); - - if (getres != 0) { - if (key->mandatory != 0) { - error(MSG_MANDATORYKEYMISSING, key->keyname, - sect_name); - return (1); - } else - /* Non-mandatory key, not present -- skip */ - return (0); - } - strncpy(key->field, (char *)&strbuf, (size_t)(key->maxlength - 1)); - return (0); -} - -/* Function tries to get on/off value for given key */ -static int -get_argument_bool(const char *sect_name, int sectno, struct nandsim_key *key, - struct rcfile *f) -{ - int getres, val; - - getres = rc_getbool(f, sect_name, sectno, key->keyname, &val); - if (getres != 0) { - if (key->mandatory != 0) { - error(MSG_MANDATORYKEYMISSING, key->keyname, - sect_name); - return (1); - } else - /* Non-mandatory key, not present -- skip */ - return (0); - } - *(uint8_t *)key->field = (uint8_t)val; - return (0); -} - -int -parse_section(struct rcfile *f, const char *sect_name, int sectno) -{ - struct nandsim_key *key; - struct nandsim_section *sect = (struct nandsim_section *)§ions; - int getres = 0; - - while (1) { - if (sect == NULL) - return (EINVAL); - - if (strcmp(sect->name, sect_name) == 0) - break; - else - sect++; - } - key = sect->keys; - do { - debug("->Section: %s, Key: %s, type: %d, size: %d", - sect_name, key->keyname, TYPE(key->valuetype), - SIZE(key->valuetype)/2); - - switch (TYPE(key->valuetype)) { - case VALUE_UINT: - /* Single int value */ - getres = get_argument_int(sect_name, sectno, key, f); - - if (getres != 0) - return (getres); - - break; - case VALUE_UINTARRAY: - /* Array of ints */ - getres = get_argument_intarray(sect_name, - sectno, key, f); - - if (getres != 0) - return (getres); - - break; - case VALUE_STRING: - /* Array of chars */ - getres = get_argument_string(sect_name, sectno, key, - f); - - if (getres != 0) - return (getres); - - break; - case VALUE_BOOL: - /* Boolean value (true/false/on/off/yes/no) */ - getres = get_argument_bool(sect_name, sectno, key, - f); - - if (getres != 0) - return (getres); - - break; - } - } while ((++key)->keyname != NULL); - - return (0); -} - -static uint8_t -validate_chips(struct sim_chip *chips, int chipcnt, - struct sim_ctrl *ctrls, int ctrlcnt) -{ - int cchipcnt, i, width, j, id, max; - - cchipcnt = chipcnt; - for (chipcnt -= 1; chipcnt >= 0; chipcnt--) { - if (chips[chipcnt].num >= MAX_CTRL_CS) { - error("chip no. too high (%d)!!\n", - chips[chipcnt].num); - return (EINVAL); - } - - if (chips[chipcnt].ctrl_num >= MAX_SIM_DEV) { - error("controller no. too high (%d)!!\n", - chips[chipcnt].ctrl_num); - return (EINVAL); - } - - if (chips[chipcnt].width != 8 && - chips[chipcnt].width != 16) { - error("invalid width:%d for chip#%d", - chips[chipcnt].width, chips[chipcnt].num); - return (EINVAL); - } - - /* Check if page size is > 512 and if its power of 2 */ - if (chips[chipcnt].page_size < 512 || - (chips[chipcnt].page_size & - (chips[chipcnt].page_size - 1)) != 0) { - error("invalid page size:%d for chip#%d at ctrl#%d!!" - "\n", chips[chipcnt].page_size, - chips[chipcnt].num, - chips[chipcnt].ctrl_num); - return (EINVAL); - } - - /* Check if controller no. ctrl_num is configured */ - for (i = 0, id = -1; i < ctrlcnt && id == -1; i++) - if (ctrls[i].num == chips[chipcnt].ctrl_num) - id = i; - - if (i == ctrlcnt && id == -1) { - error("Missing configuration for controller %d" - " (at least one chip is connected to it)", - chips[chipcnt].ctrl_num); - return (EINVAL); - } else { - /* - * Controller is configured -> check oob_size - * validity - */ - i = 0; - max = ctrls[id].ecc_layout[0]; - while (i < MAX_ECC_BYTES && - ctrls[id].ecc_layout[i] != 0xffff) { - - if (ctrls[id].ecc_layout[i] > max) - max = ctrls[id].ecc_layout[i]; - i++; - } - - if (chips[chipcnt].oob_size < (unsigned)i) { - error("OOB size for chip#%d at ctrl#%d is " - "smaller than ecc layout length!", - chips[chipcnt].num, - chips[chipcnt].ctrl_num); - exit(EINVAL); - } - - if (chips[chipcnt].oob_size < (unsigned)max) { - error("OOB size for chip#%d at ctrl#%d is " - "smaller than maximal ecc position in " - "defined layout!", chips[chipcnt].num, - chips[chipcnt].ctrl_num); - exit(EINVAL); - } - - - } - - if ((chips[chipcnt].erase_time < DELAYTIME_MIN || - chips[chipcnt].erase_time > DELAYTIME_MAX) && - chips[chipcnt].erase_time != 0) { - error("Invalid erase time value for chip#%d at " - "ctrl#%d", - chips[chipcnt].num, - chips[chipcnt].ctrl_num); - return (EINVAL); - } - - if ((chips[chipcnt].prog_time < DELAYTIME_MIN || - chips[chipcnt].prog_time > DELAYTIME_MAX) && - chips[chipcnt].prog_time != 0) { - error("Invalid prog time value for chip#%d at " - "ctr#%d!", - chips[chipcnt].num, - chips[chipcnt].ctrl_num); - return (EINVAL); - } - - if ((chips[chipcnt].read_time < DELAYTIME_MIN || - chips[chipcnt].read_time > DELAYTIME_MAX) && - chips[chipcnt].read_time != 0) { - error("Invalid read time value for chip#%d at " - "ctrl#%d!", - chips[chipcnt].num, - chips[chipcnt].ctrl_num); - return (EINVAL); - } - } - /* Check if chips attached to the same controller, have same width */ - for (i = 0; i < ctrlcnt; i++) { - width = -1; - for (j = 0; j < cchipcnt; j++) { - if (chips[j].ctrl_num == i) { - if (width == -1) { - width = chips[j].width; - } else { - if (width != chips[j].width) { - error("Chips attached to " - "ctrl#%d have different " - "widths!\n", i); - return (EINVAL); - } - } - } - } - } - - return (0); -} - -static uint8_t -validate_ctrls(struct sim_ctrl *ctrl, int ctrlcnt) -{ - for (ctrlcnt -= 1; ctrlcnt >= 0; ctrlcnt--) { - if (ctrl[ctrlcnt].num > MAX_SIM_DEV) { - error("Controller no. too high (%d)!!\n", - ctrl[ctrlcnt].num); - return (EINVAL); - } - if (ctrl[ctrlcnt].num_cs > MAX_CTRL_CS) { - error("Too many CS (%d)!!\n", ctrl[ctrlcnt].num_cs); - return (EINVAL); - } - if (ctrl[ctrlcnt].ecc != 0 && ctrl[ctrlcnt].ecc != 1) { - error("ECC is set to neither 0 nor 1 !\n"); - return (EINVAL); - } - } - - return (0); -} - -static int validate_section_config(struct rcfile *f, const char *sect_name, - int sectno) -{ - struct nandsim_key *key; - struct nandsim_section *sect; - char **keys_tbl; - int i, match; - - for (match = 0, sect = (struct nandsim_section *)§ions; - sect != NULL; sect++) { - if (strcmp(sect->name, sect_name) == 0) { - match = 1; - break; - } - } - - if (match == 0) - return (EINVAL); - - keys_tbl = rc_getkeys(f, sect_name, sectno); - if (keys_tbl == NULL) - return (ENOMEM); - - for (i = 0; keys_tbl[i] != NULL; i++) { - key = sect->keys; - match = 0; - do { - if (strcmp(keys_tbl[i], key->keyname) == 0) { - match = 1; - break; - } - } while ((++key)->keyname != NULL); - - if (match == 0) { - error("Invalid key in config file: %s\n", keys_tbl[i]); - free(keys_tbl); - return (EINVAL); - } - } - - free(keys_tbl); - return (0); -} diff --git a/usr.sbin/nandsim/nandsim_cfgparse.h b/usr.sbin/nandsim/nandsim_cfgparse.h deleted file mode 100644 index cb2a89e18a2..00000000000 --- a/usr.sbin/nandsim/nandsim_cfgparse.h +++ /dev/null @@ -1,87 +0,0 @@ -/*- - * SPDX-License-Identifier: BSD-2-Clause-FreeBSD - * - * Copyright (C) 2009-2012 Semihalf - * 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 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. - * - */ - -#ifndef _NANDSIM_CONFPARSER_H_ -#define _NANDSIM_CONFPARSER_H_ - -#define VALUE_UINT 0x08 -#define VALUE_INT 0x10 -#define VALUE_UINTARRAY 0x18 -#define VALUE_INTARRAY 0x20 -#define VALUE_STRING 0x28 -#define VALUE_CHAR 0x40 -#define VALUE_BOOL 0x48 - -#define SIZE_8 0x01 -#define SIZE_16 0x02 -#define SIZE_32 0x04 - -#include "nandsim_rcfile.h" - -/* - * keyname = name of a key, - * mandatory = is key mandatory in section belonging to, 0=false 1=true - * valuetype = what kind of value is assigned to that key, e.g. - * VALUE_UINT | SIZE_8 -- unsigned uint size 8 bits; - * VALUE_UINTARRAY | SIZE_8 -- array of uints 8-bit long; - * VALUE_BOOL -- 'on', 'off','true','false','yes' or 'no' - * literals; - * VALUE_STRING -- strings - * field = ptr to the field that should hold value for parsed value - * maxlength = contains maximum length of an array (used only with either - * VALUE_STRING or VALUE_(U)INTARRAY value types. - */ -struct nandsim_key { - const char *keyname; - uint8_t mandatory; - uint8_t valuetype; - void *field; - uint32_t maxlength; -}; -struct nandsim_section { - const char *name; - struct nandsim_key *keys; -}; - -struct nandsim_config { - struct sim_param **simparams; - struct sim_chip **simchips; - struct sim_ctrl **simctrls; - int chipcnt; - int ctrlcnt; -}; - -int parse_intarray(char *, int **); -int parse_config(char *, const char *); -int parse_section(struct rcfile *, const char *, int); -int compare_configs(struct nandsim_config *, struct nandsim_config *); -int convert_argint(char *, int *); -int convert_arguint(char *, unsigned int *); - -#endif /* _NANDSIM_CONFPARSER_H_ */ diff --git a/usr.sbin/nandsim/nandsim_rcfile.c b/usr.sbin/nandsim/nandsim_rcfile.c deleted file mode 100644 index a6085ccf078..00000000000 --- a/usr.sbin/nandsim/nandsim_rcfile.c +++ /dev/null @@ -1,441 +0,0 @@ -/* - * SPDX-License-Identifier: BSD-3-Clause - * - * Copyright (c) 1999, Boris Popov - * 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. Neither the name of the author nor the names of any co-contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * 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. - * - * from: FreeBSD: src/lib/libncp/ncpl_rcfile.c,v 1.5 2007/01/09 23:27:39 imp Exp - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "nandsim_rcfile.h" - -SLIST_HEAD(rcfile_head, rcfile); -static struct rcfile_head pf_head = {NULL}; -static struct rcsection *rc_findsect(struct rcfile *rcp, - const char *sectname, int sect_id); -static struct rcsection *rc_addsect(struct rcfile *rcp, - const char *sectname); -static int rc_sect_free(struct rcsection *rsp); -static struct rckey *rc_sect_findkey(struct rcsection *rsp, - const char *keyname); -static struct rckey *rc_sect_addkey(struct rcsection *rsp, const char *name, - char *value); -static void rc_key_free(struct rckey *p); -static void rc_parse(struct rcfile *rcp); - -static struct rcfile* rc_find(const char *filename); - -/* - * open rcfile and load its content, if already open - return previous handle - */ -int -rc_open(const char *filename, const char *mode,struct rcfile **rcfile) -{ - struct rcfile *rcp; - FILE *f; - rcp = rc_find(filename); - if (rcp) { - *rcfile = rcp; - return (0); - } - f = fopen (filename, mode); - if (f == NULL) - return errno; - rcp = malloc(sizeof(struct rcfile)); - if (rcp == NULL) { - fclose(f); - return ENOMEM; - } - bzero(rcp, sizeof(struct rcfile)); - rcp->rf_name = strdup(filename); - rcp->rf_f = f; - SLIST_INSERT_HEAD(&pf_head, rcp, rf_next); - rc_parse(rcp); - *rcfile = rcp; - return (0); -} - -int -rc_close(struct rcfile *rcp) -{ - struct rcsection *p,*n; - - fclose(rcp->rf_f); - for (p = SLIST_FIRST(&rcp->rf_sect); p; ) { - n = p; - p = SLIST_NEXT(p,rs_next); - rc_sect_free(n); - } - free(rcp->rf_name); - SLIST_REMOVE(&pf_head, rcp, rcfile, rf_next); - free(rcp); - return (0); -} - -static struct rcfile* -rc_find(const char *filename) -{ - struct rcfile *p; - - SLIST_FOREACH(p, &pf_head, rf_next) - if (strcmp (filename, p->rf_name) == 0) - return (p); - return (0); -} - -/* Find section with given name and id */ -static struct rcsection * -rc_findsect(struct rcfile *rcp, const char *sectname, int sect_id) -{ - struct rcsection *p; - - SLIST_FOREACH(p, &rcp->rf_sect, rs_next) - if (strcmp(p->rs_name, sectname) == 0 && p->rs_id == sect_id) - return (p); - return (NULL); -} - -static struct rcsection * -rc_addsect(struct rcfile *rcp, const char *sectname) -{ - struct rcsection *p; - int id = 0; - p = rc_findsect(rcp, sectname, 0); - if (p) { - /* - * If section with that name already exists -- add one more, - * same named, but with different id (higher by one) - */ - while (p != NULL) { - id = p->rs_id + 1; - p = rc_findsect(rcp, sectname, id); - } - } - p = malloc(sizeof(*p)); - if (!p) - return (NULL); - p->rs_name = strdup(sectname); - p->rs_id = id; - SLIST_INIT(&p->rs_keys); - SLIST_INSERT_HEAD(&rcp->rf_sect, p, rs_next); - return (p); -} - -static int -rc_sect_free(struct rcsection *rsp) -{ - struct rckey *p,*n; - - for (p = SLIST_FIRST(&rsp->rs_keys); p; ) { - n = p; - p = SLIST_NEXT(p,rk_next); - rc_key_free(n); - } - free(rsp->rs_name); - free(rsp); - return (0); -} - -static struct rckey * -rc_sect_findkey(struct rcsection *rsp, const char *keyname) -{ - struct rckey *p; - - SLIST_FOREACH(p, &rsp->rs_keys, rk_next) - if (strcmp(p->rk_name, keyname)==0) - return (p); - return (NULL); -} - -static struct rckey * -rc_sect_addkey(struct rcsection *rsp, const char *name, char *value) -{ - struct rckey *p; - p = rc_sect_findkey(rsp, name); - if (p) { - free(p->rk_value); - } else { - p = malloc(sizeof(*p)); - if (!p) - return (NULL); - SLIST_INSERT_HEAD(&rsp->rs_keys, p, rk_next); - p->rk_name = strdup(name); - } - p->rk_value = value ? strdup(value) : strdup(""); - return (p); -} - -static void -rc_key_free(struct rckey *p) -{ - free(p->rk_value); - free(p->rk_name); - free(p); -} - -enum { stNewLine, stHeader, stSkipToEOL, stGetKey, stGetValue}; - -static void -rc_parse(struct rcfile *rcp) -{ - FILE *f = rcp->rf_f; - int state = stNewLine, c; - struct rcsection *rsp = NULL; - struct rckey *rkp = NULL; - char buf[2048]; - char *next = buf, *last = &buf[sizeof(buf)-1]; - - while ((c = getc (f)) != EOF) { - if (c == '\r') - continue; - if (state == stNewLine) { - next = buf; - if (isspace(c)) - continue; /* skip leading junk */ - if (c == '[') { - state = stHeader; - rsp = NULL; - continue; - } - if (c == '#' || c == ';') { - state = stSkipToEOL; - } else { /* something meaningful */ - state = stGetKey; - } - } - if (state == stSkipToEOL || next == last) {/* ignore long lines */ - if (c == '\n') { - state = stNewLine; - next = buf; - } - continue; - } - if (state == stHeader) { - if (c == ']') { - *next = 0; - next = buf; - rsp = rc_addsect(rcp, buf); - state = stSkipToEOL; - } else - *next++ = c; - continue; - } - if (state == stGetKey) { - if (c == ' ' || c == '\t')/* side effect: 'key name='*/ - continue; /* become 'keyname=' */ - if (c == '\n') { /* silently ignore ... */ - state = stNewLine; - continue; - } - if (c != '=') { - *next++ = c; - continue; - } - *next = 0; - if (rsp == NULL) { - fprintf(stderr, "Key '%s' defined before " - "section\n", buf); - state = stSkipToEOL; - continue; - } - rkp = rc_sect_addkey(rsp, buf, NULL); - next = buf; - state = stGetValue; - continue; - } - /* only stGetValue left */ - if (state != stGetValue) { - fprintf(stderr, "Well, I can't parse file " - "'%s'\n",rcp->rf_name); - state = stSkipToEOL; - } - if (c != '\n') { - *next++ = c; - continue; - } - *next = 0; - rkp->rk_value = strdup(buf); - state = stNewLine; - rkp = NULL; - } /* while */ - if (c == EOF && state == stGetValue) { - *next = 0; - rkp->rk_value = strdup(buf); - } -} - -int -rc_getstringptr(struct rcfile *rcp, const char *section, int sect_id, - const char *key, char **dest) -{ - struct rcsection *rsp; - struct rckey *rkp; - - *dest = NULL; - rsp = rc_findsect(rcp, section, sect_id); - if (!rsp) - return (ENOENT); - rkp = rc_sect_findkey(rsp,key); - if (!rkp) - return (ENOENT); - *dest = rkp->rk_value; - return (0); -} - -int -rc_getstring(struct rcfile *rcp, const char *section, int sect_id, - const char *key, unsigned int maxlen, char *dest) -{ - char *value; - int error; - - error = rc_getstringptr(rcp, section, sect_id, key, &value); - if (error) - return (error); - if (strlen(value) >= maxlen) { - fprintf(stderr, "line too long for key '%s' in section '%s'," - "max = %d\n",key, section, maxlen); - return (EINVAL); - } - strcpy(dest,value); - return (0); -} - -int -rc_getint(struct rcfile *rcp, const char *section, int sect_id, - const char *key, int *value) -{ - struct rcsection *rsp; - struct rckey *rkp; - - rsp = rc_findsect(rcp, section, sect_id); - if (!rsp) - return (ENOENT); - rkp = rc_sect_findkey(rsp,key); - if (!rkp) - return (ENOENT); - errno = 0; - *value = strtol(rkp->rk_value,NULL,0); - if (errno) { - fprintf(stderr, "invalid int value '%s' for key '%s' in " - "section '%s'\n",rkp->rk_value,key,section); - return (errno); - } - return (0); -} - -/* - * 1,yes,true - * 0,no,false - */ -int -rc_getbool(struct rcfile *rcp, const char *section, int sect_id, - const char *key, int *value) -{ - struct rcsection *rsp; - struct rckey *rkp; - char *p; - - rsp = rc_findsect(rcp, section, sect_id); - if (!rsp) - return (ENOENT); - rkp = rc_sect_findkey(rsp,key); - if (!rkp) - return (ENOENT); - p = rkp->rk_value; - while (*p && isspace(*p)) p++; - if (*p == '0' || strcasecmp(p,"no") == 0 || - strcasecmp(p, "false") == 0 || - strcasecmp(p, "off") == 0) { - *value = 0; - return (0); - } - if (*p == '1' || strcasecmp(p,"yes") == 0 || - strcasecmp(p, "true") == 0 || - strcasecmp(p, "on") == 0) { - *value = 1; - return (0); - } - fprintf(stderr, "invalid boolean value '%s' for key '%s' in section " - "'%s' \n",p, key, section); - return (EINVAL); -} - -/* Count how many sections with given name exists in configuration. */ -int rc_getsectionscount(struct rcfile *f, const char *sectname) -{ - struct rcsection *p; - int count = 0; - - p = rc_findsect(f, sectname, 0); - if (p) { - while (p != NULL) { - count = p->rs_id + 1; - p = rc_findsect(f, sectname, count); - } - return (count); - } else - return (0); -} - -char ** -rc_getkeys(struct rcfile *rcp, const char *sectname, int sect_id) -{ - struct rcsection *rsp; - struct rckey *p; - char **names_tbl; - int i = 0, count = 0; - - rsp = rc_findsect(rcp, sectname, sect_id); - if (rsp == NULL) - return (NULL); - - SLIST_FOREACH(p, &rsp->rs_keys, rk_next) - count++; - - names_tbl = malloc(sizeof(char *) * (count + 1)); - if (names_tbl == NULL) - return (NULL); - - SLIST_FOREACH(p, &rsp->rs_keys, rk_next) - names_tbl[i++] = p->rk_name; - - names_tbl[i] = NULL; - return (names_tbl); -} - diff --git a/usr.sbin/nandsim/nandsim_rcfile.h b/usr.sbin/nandsim/nandsim_rcfile.h deleted file mode 100644 index 60a3f920e13..00000000000 --- a/usr.sbin/nandsim/nandsim_rcfile.h +++ /dev/null @@ -1,71 +0,0 @@ -/*- - * SPDX-License-Identifier: BSD-3-Clause - * - * Copyright (c) 1999, Boris Popov - * 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. Neither the name of the author nor the names of any co-contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * 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. - * - * - * from: FreeBSD: src/lib/libncp/ncpl_rcfile.c,v 1.5 2007/01/09 23:27:39 imp Exp - */ - -#ifndef _SIMRC_H_ -#define _SIMRC_H_ - -#include - -struct rckey { - SLIST_ENTRY(rckey) rk_next; - char *rk_name; /* key name */ - char *rk_value; /* key value */ -}; - -struct rcsection { - SLIST_ENTRY(rcsection) rs_next; - SLIST_HEAD(rckey_head,rckey) rs_keys; /* key list */ - char *rs_name; /* section name */ - int rs_id; /* allow few same named */ -}; - -struct rcfile { - SLIST_ENTRY(rcfile) rf_next; - SLIST_HEAD(rcsec_head, rcsection) rf_sect; /* sections list */ - char *rf_name; /* file name */ - FILE *rf_f; /* file desc */ -}; - -int rc_open(const char *, const char *,struct rcfile **); -int rc_close(struct rcfile *); -int rc_getstringptr(struct rcfile *, const char *, int, const char *, - char **); -int rc_getstring(struct rcfile *, const char *, int, const char *, - unsigned int, char *); -int rc_getint(struct rcfile *, const char *, int, const char *, int *); -int rc_getbool(struct rcfile *, const char *, int, const char *, int *); -int rc_getsectionscount(struct rcfile *, const char *); -char **rc_getkeys(struct rcfile *, const char *, int); - -#endif /* _SIMRC_H_ */ diff --git a/usr.sbin/nandsim/sample.conf b/usr.sbin/nandsim/sample.conf deleted file mode 100644 index 6a9bb9633a3..00000000000 --- a/usr.sbin/nandsim/sample.conf +++ /dev/null @@ -1,173 +0,0 @@ -#- -# Copyright (C) 2009-2012 Semihalf -# 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. -# - -# -# Sample NANDsim configuration file. -# - -############################################################################# -# -# [sim] General (common) simulator configuration section. -# -[sim] -# log_level=0..255 -log_level=11 - -# log_output=[none, console, ram, file] -# -# When log_output=file is specified, each [ctrl] section must have a -# corresponding 'log_filename' field provided, which specifies log file name -# to be used. -log_output=none - -############################################################################# -# -# [ctrl] Controller configuration section. -# -# There can be a number of controllers defined for simulation, each has a -# dedicated [ctrl] section. With a given controller there are associated -# subordinate NAND chips, which are tied to chip select lines. -# -[ctrl] -# The number of this controller. -# ctrl_num=0..3 -ctrl_num=0 - -# The number of chip selects available at this controller. -# num_cs=1..4 -num_cs=1 - -# ECC enable flag. -# ecc=[on|off] -ecc=on - -# ECC layout. This is the list of byte offsets within OOB area, which comprise -# the ECC contents set. -# -# ecc_layout=[byte1, byte2-byte3, ..byten] -ecc_layout=[0-53] - -# Absolute path to the log file for this controller. -#log_filename=/var/log/nandsim-ctl0.log - - -############################################################################# -# -# [chip] Chip configuration section. -# -# There can be a number of individual NAND chip devices defined for -# simulation, and each has a dedicated [chip] section. -# -# A particular chip needs to be associated with its parent NAND controller by -# specifying the following fields: controller number (chip_ctrl) and the chip -# select line it is connected to (chip_cs). The chip can be connected to only -# a single (and unique) controller:cs pair. -# -[chip] -# The number of parent controller. This has to fit one of the controller -# instance number (ctrl_num from [ctrl] section). -# chip_ctrl=0..3 -chip_ctrl=0 - -# Chip select line. -# chip_cs=0..3 -chip_cs=0 - -# ONFI device identifier. -# device_id=0x00..0xff -device_id=0xd3 - -# ONFI manufacturer identifier. -# manufacturer_id=0x00..0xff -manufacturer_id=0xec - -# Textual description of the chip. -# model="model_name" -model="k9xxg08uxM:1GiB 3,3V 8-bit" - -# Textual name of the chip manufacturer. -# manufacturer="manufacturer name" -manufacturer="SAMSUNG" - -# page_size=[must be power of 2 and >= 512] (in bytes) -page_size=2048 -# oob_size=[>0] -oob_size=64 -# pages_per_block=n*32 -pages_per_block=64 -# blocks_per_lun=[>0] -blocks_per_lun=4096 -# luns=1..N -luns=1 -# column_addr_cycle=[1,2] -column_addr_cycle=2 -# row_addr_cycle=[1,2,3] -row_addr_cycle=3 - -# program_time= (in us) -program_time=0 -# erase_time= (in us) -erase_time=0 -# read_time= (in us) -read_time=0 -# ccs_time= (in us) -#ccs_time=200 - -# Simulate write-protect on the chip. -# write_protect=[yes|no] -#write_protect=no - -# Blocks wear-out threshold. Each block has a counter of program-erase cycles; -# when this counter reaches 'wear_out' value a given block is treated as a bad -# block (access will report error). -# -# Setting wear_out to 0 means that blocks will never wear out. -# -# wear_out=0..100000 -wear_out=50000 - -# Errors per million read/write bytes. This simulates an accidental read/write -# block error, which can happen in real devices with certain probability. Note -# this isn't a bad block condition i.e. the block at which the read/write -# operation is simulated to fail here remains usable, only the operation has -# not succeeded (this is where ECC comes into play and is supposed to correct -# such problems). -# -# error_ratio=0..1000000 -#error_ratio=50 - -# Chip data bus width. All chips connected to the same controller must have -# the same bus width. -# -# width=[8|16] -width=8 - -# Bad block map. NANDsim emulates bad block behavior upon accessing a block -# with number from the specified list. -# -# bad_block_map=[bad_block1, bad_block2-bad_block3, ..bad_blockn] -bad_block_map=[100-200] - diff --git a/usr.sbin/nandtool/Makefile b/usr.sbin/nandtool/Makefile deleted file mode 100644 index 994be0b3027..00000000000 --- a/usr.sbin/nandtool/Makefile +++ /dev/null @@ -1,10 +0,0 @@ -# $FreeBSD: stable/11/usr.sbin/nandtool/Makefile 275054 2014-11-25 16:57:27Z bapt $ - -PROG= nandtool -SRCS= nandtool.c nand_read.c nand_write.c nand_erase.c nand_info.c -SRCS+= nand_readoob.c nand_writeoob.c -BINDIR= /usr/sbin -LIBADD= geom -MAN= nandtool.8 - -.include diff --git a/usr.sbin/nandtool/Makefile.depend b/usr.sbin/nandtool/Makefile.depend deleted file mode 100644 index b90b813c26a..00000000000 --- a/usr.sbin/nandtool/Makefile.depend +++ /dev/null @@ -1,19 +0,0 @@ -# Autogenerated - do NOT edit! - -DIRDEPS = \ - gnu/lib/csu \ - include \ - include/xlocale \ - lib/${CSU_DIR} \ - lib/libc \ - lib/libcompiler_rt \ - lib/libexpat \ - lib/libgeom \ - lib/libsbuf \ - - -.include - -.if ${DEP_RELDIR} == ${_DEP_RELDIR} -# local dependencies - needed for -jN in clean tree -.endif diff --git a/usr.sbin/nandtool/nand_erase.c b/usr.sbin/nandtool/nand_erase.c deleted file mode 100644 index 8535349cb6e..00000000000 --- a/usr.sbin/nandtool/nand_erase.c +++ /dev/null @@ -1,115 +0,0 @@ -/*- - * SPDX-License-Identifier: BSD-2-Clause-FreeBSD - * - * Copyright (c) 2010-2012 Semihalf. - * 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. - */ - -#include - -#include -#include -#include -#include -#include -#include -#include -#include "nandtool.h" - -int nand_erase(struct cmd_param *params) -{ - struct chip_param_io chip_params; - char *dev; - int fd = -1, ret = 0; - off_t pos, count; - off_t start, nblocks, i; - int block_size, mult; - - if (!(dev = param_get_string(params, "dev"))) { - fprintf(stderr, "Please supply valid 'dev' parameter.\n"); - return (1); - } - - if (param_has_value(params, "count")) - count = param_get_intx(params, "count"); - else - count = 1; - - if ((fd = g_open(dev, 1)) < 0) { - perrorf("Cannot open %s", dev); - return (1); - } - - if (ioctl(fd, NAND_IO_GET_CHIP_PARAM, &chip_params) == -1) { - perrorf("Cannot ioctl(NAND_IO_GET_CHIP_PARAM)"); - ret = 1; - goto out; - } - - block_size = chip_params.page_size * chip_params.pages_per_block; - - if (param_has_value(params, "page")) { - pos = chip_params.page_size * param_get_intx(params, "page"); - mult = chip_params.page_size; - } else if (param_has_value(params, "block")) { - pos = block_size * param_get_intx(params, "block"); - mult = block_size; - } else if (param_has_value(params, "pos")) { - pos = param_get_intx(params, "pos"); - mult = 1; - } else { - /* Erase whole chip */ - if (ioctl(fd, DIOCGMEDIASIZE, &count) == -1) { - ret = 1; - goto out; - } - - pos = 0; - mult = 1; - } - - if (pos % block_size) { - fprintf(stderr, "Position must be block-size aligned!\n"); - ret = 1; - goto out; - } - - count *= mult; - start = pos / block_size; - nblocks = count / block_size; - - for (i = 0; i < nblocks; i++) { - if (g_delete(fd, (start + i) * block_size, block_size) == -1) { - perrorf("Cannot erase block %d - probably a bad block", - start + i); - ret = 1; - } - } - -out: - g_close(fd); - - return (ret); -} - diff --git a/usr.sbin/nandtool/nand_info.c b/usr.sbin/nandtool/nand_info.c deleted file mode 100644 index d61e3a92a65..00000000000 --- a/usr.sbin/nandtool/nand_info.c +++ /dev/null @@ -1,87 +0,0 @@ -/*- - * SPDX-License-Identifier: BSD-2-Clause-FreeBSD - * - * Copyright (c) 2010-2012 Semihalf. - * 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. - */ - -#include - -#include -#include -#include -#include -#include -#include -#include -#include "nandtool.h" - -int nand_info(struct cmd_param *params) -{ - struct chip_param_io chip_params; - int fd = -1, ret = 0; - int block_size; - off_t chip_size, media_size; - const char *dev; - - if ((dev = param_get_string(params, "dev")) == NULL) { - fprintf(stderr, "Please supply 'dev' parameter, eg. " - "'dev=/dev/gnand0'\n"); - return (1); - } - - if ((fd = g_open(dev, 1)) == -1) { - perrorf("Cannot open %s", dev); - return (1); - } - - if (ioctl(fd, NAND_IO_GET_CHIP_PARAM, &chip_params) == -1) { - perrorf("Cannot ioctl(NAND_IO_GET_CHIP_PARAM)"); - ret = 1; - goto out; - } - - if (ioctl(fd, DIOCGMEDIASIZE, &media_size) == -1) { - perrorf("Cannot ioctl(DIOCGMEDIASIZE)"); - ret = 1; - goto out; - } - - block_size = chip_params.page_size * chip_params.pages_per_block; - chip_size = block_size * chip_params.blocks; - - printf("Device:\t\t\t%s\n", dev); - printf("Page size:\t\t%d bytes\n", chip_params.page_size); - printf("Block size:\t\t%d bytes (%d KB)\n", block_size, - block_size / 1024); - printf("OOB size per page:\t%d bytes\n", chip_params.oob_size); - printf("Chip size:\t\t%jd MB\n", (uintmax_t)(chip_size / 1024 / 1024)); - printf("Slice size:\t\t%jd MB\n", - (uintmax_t)(media_size / 1024 / 1024)); - -out: - g_close(fd); - - return (ret); -} diff --git a/usr.sbin/nandtool/nand_read.c b/usr.sbin/nandtool/nand_read.c deleted file mode 100644 index 0018a877f3f..00000000000 --- a/usr.sbin/nandtool/nand_read.c +++ /dev/null @@ -1,140 +0,0 @@ -/*- - * SPDX-License-Identifier: BSD-2-Clause-FreeBSD - * - * Copyright (c) 2010-2012 Semihalf. - * 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. - */ - -#include - -#include -#include -#include -#include -#include -#include -#include -#include "nandtool.h" - -int nand_read(struct cmd_param *params) -{ - struct chip_param_io chip_params; - int fd = -1, out_fd = -1, done = 0, ret = 0; - char *dev, *out; - int pos, count, mult, block_size; - uint8_t *buf = NULL; - - if (!(dev = param_get_string(params, "dev"))) { - fprintf(stderr, "You must specify 'dev' parameter\n"); - return (1); - } - - if ((out = param_get_string(params, "out"))) { - out_fd = open(out, O_WRONLY|O_CREAT, 0666); - if (out_fd == -1) { - perrorf("Cannot open %s for writing", out); - return (1); - } - } - - if ((fd = g_open(dev, 1)) == -1) { - perrorf("Cannot open %s", dev); - ret = 1; - goto out; - } - - if (ioctl(fd, NAND_IO_GET_CHIP_PARAM, &chip_params) == -1) { - perrorf("Cannot ioctl(NAND_IO_GET_CHIP_PARAM)"); - ret = 1; - goto out; - } - - block_size = chip_params.page_size * chip_params.pages_per_block; - - if (param_has_value(params, "page")) { - pos = chip_params.page_size * param_get_int(params, "page"); - mult = chip_params.page_size; - } else if (param_has_value(params, "block")) { - pos = block_size * param_get_int(params, "block"); - mult = block_size; - } else if (param_has_value(params, "pos")) { - pos = param_get_int(params, "pos"); - mult = 1; - if (pos % chip_params.page_size) { - fprintf(stderr, "Position must be page-size aligned!\n"); - ret = 1; - goto out; - } - } else { - fprintf(stderr, "You must specify one of: 'block', 'page'," - "'pos' arguments\n"); - ret = 1; - goto out; - } - - if (!(param_has_value(params, "count"))) - count = mult; - else - count = param_get_int(params, "count") * mult; - - if (!(buf = malloc(chip_params.page_size))) { - perrorf("Cannot allocate buffer [size %x]", - chip_params.page_size); - ret = 1; - goto out; - } - - lseek(fd, pos, SEEK_SET); - - while (done < count) { - if ((ret = read(fd, buf, chip_params.page_size)) != - (int32_t)chip_params.page_size) { - perrorf("read error (read %d bytes)", ret); - goto out; - } - - if (out_fd != -1) { - done += ret; - if ((ret = write(out_fd, buf, chip_params.page_size)) != - (int32_t)chip_params.page_size) { - perrorf("write error (written %d bytes)", ret); - ret = 1; - goto out; - } - } else { - hexdumpoffset(buf, chip_params.page_size, done); - done += ret; - } - } - -out: - g_close(fd); - if (out_fd != -1) - close(out_fd); - if (buf) - free(buf); - - return (ret); -} - diff --git a/usr.sbin/nandtool/nand_readoob.c b/usr.sbin/nandtool/nand_readoob.c deleted file mode 100644 index 60568cbd04e..00000000000 --- a/usr.sbin/nandtool/nand_readoob.c +++ /dev/null @@ -1,112 +0,0 @@ -/*- - * SPDX-License-Identifier: BSD-2-Clause-FreeBSD - * - * Copyright (c) 2010-2012 Semihalf. - * 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. - */ - -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include "nandtool.h" - -int nand_read_oob(struct cmd_param *params) -{ - struct chip_param_io chip_params; - struct nand_oob_rw req; - char *dev, *out; - int fd = -1, fd_out = -1, ret = 0; - int page; - uint8_t *buf = NULL; - - if ((page = param_get_int(params, "page")) < 0) { - fprintf(stderr, "You must supply valid 'page' argument.\n"); - return (1); - } - - if (!(dev = param_get_string(params, "dev"))) { - fprintf(stderr, "You must supply 'dev' argument.\n"); - return (1); - } - - if ((out = param_get_string(params, "out"))) { - if ((fd_out = open(out, O_WRONLY | O_CREAT, 0666)) == -1) { - perrorf("Cannot open %s", out); - ret = 1; - goto out; - } - } - - if ((fd = g_open(dev, 1)) == -1) { - perrorf("Cannot open %s", dev); - ret = 1; - goto out; - } - - if (ioctl(fd, NAND_IO_GET_CHIP_PARAM, &chip_params) == -1) { - perrorf("Cannot ioctl(NAND_IO_GET_CHIP_PARAM)"); - ret = 1; - goto out; - } - - buf = malloc(chip_params.oob_size); - if (buf == NULL) { - perrorf("Cannot allocate %d bytes\n", chip_params.oob_size); - ret = 1; - goto out; - } - - req.page = page; - req.len = chip_params.oob_size; - req.data = buf; - - if (ioctl(fd, NAND_IO_OOB_READ, &req) == -1) { - perrorf("Cannot read OOB from %s", dev); - ret = 1; - goto out; - } - - if (fd_out != -1) - write(fd_out, buf, chip_params.oob_size); - else - hexdump(buf, chip_params.oob_size); - -out: - close(fd_out); - - if (fd != -1) - g_close(fd); - if (buf) - free(buf); - - return (ret); -} - diff --git a/usr.sbin/nandtool/nand_write.c b/usr.sbin/nandtool/nand_write.c deleted file mode 100644 index 2de2f30446e..00000000000 --- a/usr.sbin/nandtool/nand_write.c +++ /dev/null @@ -1,144 +0,0 @@ -/*- - * SPDX-License-Identifier: BSD-2-Clause-FreeBSD - * - * Copyright (c) 2010-2012 Semihalf. - * 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. - */ - -#include - -#include -#include -#include -#include -#include -#include -#include -#include "nandtool.h" - -int nand_write(struct cmd_param *params) -{ - struct chip_param_io chip_params; - char *dev, *file; - int in_fd = -1, ret = 0, done = 0; - int fd, block_size, mult, pos, count; - uint8_t *buf = NULL; - - if (!(dev = param_get_string(params, "dev"))) { - fprintf(stderr, "Please supply 'dev' argument.\n"); - return (1); - } - - if (!(file = param_get_string(params, "in"))) { - fprintf(stderr, "Please supply 'in' argument.\n"); - return (1); - } - - if ((fd = g_open(dev, 1)) == -1) { - perrorf("Cannot open %s", dev); - return (1); - } - - if ((in_fd = open(file, O_RDONLY)) == -1) { - perrorf("Cannot open file %s", file); - ret = 1; - goto out; - } - - if (ioctl(fd, NAND_IO_GET_CHIP_PARAM, &chip_params) == -1) { - perrorf("Cannot ioctl(NAND_IO_GET_CHIP_PARAM)"); - ret = 1; - goto out; - } - - block_size = chip_params.page_size * chip_params.pages_per_block; - - if (param_has_value(params, "page")) { - pos = chip_params.page_size * param_get_int(params, "page"); - mult = chip_params.page_size; - } else if (param_has_value(params, "block")) { - pos = block_size * param_get_int(params, "block"); - mult = block_size; - } else if (param_has_value(params, "pos")) { - pos = param_get_int(params, "pos"); - mult = 1; - if (pos % chip_params.page_size) { - fprintf(stderr, "Position must be page-size " - "aligned!\n"); - ret = 1; - goto out; - } - } else { - fprintf(stderr, "You must specify one of: 'block', 'page'," - "'pos' arguments\n"); - ret = 1; - goto out; - } - - if (!(param_has_value(params, "count"))) - count = mult; - else - count = param_get_int(params, "count") * mult; - - if (!(buf = malloc(chip_params.page_size))) { - perrorf("Cannot allocate buffer [size %x]", - chip_params.page_size); - ret = 1; - goto out; - } - - lseek(fd, pos, SEEK_SET); - - while (done < count) { - if ((ret = read(in_fd, buf, chip_params.page_size)) != - (int32_t)chip_params.page_size) { - if (ret > 0) { - /* End of file ahead, truncate here */ - break; - } else { - perrorf("Cannot read from %s", file); - ret = 1; - goto out; - } - } - - if ((ret = write(fd, buf, chip_params.page_size)) != - (int32_t)chip_params.page_size) { - ret = 1; - goto out; - } - - done += ret; - } - -out: - g_close(fd); - if (in_fd != -1) - close(in_fd); - if (buf) - free(buf); - - return (ret); -} - diff --git a/usr.sbin/nandtool/nand_writeoob.c b/usr.sbin/nandtool/nand_writeoob.c deleted file mode 100644 index 675d9f48251..00000000000 --- a/usr.sbin/nandtool/nand_writeoob.c +++ /dev/null @@ -1,114 +0,0 @@ -/*- - * SPDX-License-Identifier: BSD-2-Clause-FreeBSD - * - * Copyright (c) 2010-2012 Semihalf. - * 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. - */ - -#include - -#include -#include -#include -#include -#include -#include -#include -#include "nandtool.h" - -int nand_write_oob(struct cmd_param *params) -{ - struct chip_param_io chip_params; - struct nand_oob_rw req; - char *dev, *in; - int fd = -1, fd_in = -1, ret = 0; - uint8_t *buf = NULL; - int page; - - if (!(dev = param_get_string(params, "dev"))) { - fprintf(stderr, "Please supply valid 'dev' parameter.\n"); - return (1); - } - - if (!(in = param_get_string(params, "in"))) { - fprintf(stderr, "Please supply valid 'in' parameter.\n"); - return (1); - } - - if ((page = param_get_int(params, "page")) < 0) { - fprintf(stderr, "Please supply valid 'page' parameter.\n"); - return (1); - } - - if ((fd = g_open(dev, 1)) == -1) { - perrorf("Cannot open %s", dev); - return (1); - } - - if ((fd_in = open(in, O_RDONLY)) == -1) { - perrorf("Cannot open %s", in); - ret = 1; - goto out; - } - - if (ioctl(fd, NAND_IO_GET_CHIP_PARAM, &chip_params) == -1) { - perrorf("Cannot ioctl(NAND_IO_GET_CHIP_PARAM)"); - ret = 1; - goto out; - } - - buf = malloc(chip_params.oob_size); - if (buf == NULL) { - perrorf("Cannot allocate %d bytes\n", chip_params.oob_size); - ret = 1; - goto out; - } - - if (read(fd_in, buf, chip_params.oob_size) == -1) { - perrorf("Cannot read from %s", in); - ret = 1; - goto out; - } - - req.page = page; - req.len = chip_params.oob_size; - req.data = buf; - - if (ioctl(fd, NAND_IO_OOB_PROG, &req) == -1) { - perrorf("Cannot write OOB to %s", dev); - ret = 1; - goto out; - } - -out: - g_close(fd); - if (fd_in != -1) - close(fd_in); - if (buf) - free(buf); - - return (ret); -} - - diff --git a/usr.sbin/nandtool/nandtool.8 b/usr.sbin/nandtool/nandtool.8 deleted file mode 100644 index 9df5a8a3e13..00000000000 --- a/usr.sbin/nandtool/nandtool.8 +++ /dev/null @@ -1,183 +0,0 @@ -.\" Copyright (c) 2010 Semihalf -.\" 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. -.\" -.\" -.Dd April 10, 2012 -.Dt NANDTOOL 8 -.Os -.Sh NAME -.Nm nandtool -.Nd NAND devices swiss army knife -.Sh SYNOPSIS -.Nm -.Ar command -.Op Ar operands ... -.Sh DESCRIPTION -The -.Nm -utility can be used to perform various operations on -.Xr gnand 4 -devices (read, write, erase, -read and write OOB area and to get info about NAND flash chip). -.Pp -The following commands are available: -.Bl -tag -width ".Cm of Ns = Ns Ar file" -.It Cm read Ns -Read pages from NAND device. -.It Cm write Ns -Write pages to NAND device. -.It Cm erase Ns -Erase blocks. -Requires offset aligned to block granularity. -.It Cm info Ns -Get information about NAND chip (page size, block size, OOB area size, chip size -and media size) -.It Cm readoob Ns -Read OOB area from specified page. -.It Cm writeoob Ns -Write OOB area bound to specified page. -.It Cm help Ns -Get usage info. -.El -.Sh COMMAND read -The following operands are available for -.Nm -.Cm read -command: -.Bl -tag -width ".Cm of Ns = Ns Ar file" -.It Cm dev Ns = Ns Ar -Path to a -.Xr gnand 4 -device node, required for all operations. -.It Cm out Ns = Ns Ar -Output file path. If not specified, page contents -will be dumped to stdout in format similar to -.Xr hexdump 1 -.It Cm page Ns = Ns Ar -Offset on device, expressed as page number. -.It Cm block Ns = Ns Ar -Offset on device, expressed as block number. -.It Cm pos Ns = Ns Ar -Offset on device, expressed in bytes (however, must be aligned -to page granularity). -.It Cm count Ns = Ns Ar -Count of objects (pages, blocks, bytes). -.El -.Sh COMMAND readoob -The following operands are available for -.Nm -.Cm readoob -command: -.Bl -tag -width ".Cm of Ns = Ns Ar file" -.It Cm dev Ns = Ns Ar -Path to NAND device node. -.It Cm page Ns = Ns Ar -Offset on device, expressed as page number. -.It Cm out Ns = Ns Ar -Output file path, optional. -.El -.Sh COMMAND write -The following operands are available for -.Nm -.Cm write -command: -.Bl -tag -width ".Cm of Ns = Ns Ar file" -.It Cm dev Ns = Ns Ar -Path to NAND device node. -.It Cm page Ns = Ns Ar -Offset on device, expressed as page number. -.It Cm block Ns = Ns Ar -Offset on device, expressed as block number. -.It Cm pos Ns = Ns Ar -Offset on device, expressed in bytes (however, must be aligned -to page granularity). -.It Cm in Ns = Ns Ar -Input file path. -.El -.Sh COMMAND writeoob -The following operands are available for -.Nm -.Cm writeoob -command: -.Bl -tag -width ".Cm of Ns = Ns Ar file" -.It Cm dev Ns = Ns Ar -Path to NAND device node. -.It Cm page Ns = Ns Ar -Offset on device, expressed as page number. -.It Cm in Ns = Ns Ar -Input file path. -.El -.Sh COMMAND erase -The following operands are available for -.Nm -.Cm erase -command: -.Bl -tag -width ".Cm of Ns = Ns Ar file" -.It Cm dev Ns = Ns Ar -Path to NAND device node. -.It Cm page Ns = Ns Ar -Offset on device, expressed as page number. -.It Cm block Ns = Ns Ar -Offset on device, expressed as block number. -.It Cm pos Ns = Ns Ar -Offset on device, epressed in bytes (however, must be aligned -to block granularity). -.It Cm count Ns = Ns Ar -Count of objects (pages, blocks, bytes). -.El -.Pp -WARNING: The only required parameter for the \fBerase\fP command is -.Ar dev . -When no other arguments are provided the whole device is erased! -.Sh COMMAND info -There is only one operand available for -.Nm -.Cm info -command: -.Bl -tag -width ".Cm of Ns = Ns Ar file" -.It Cm dev Ns = Ns Ar -Path to NAND device node. -.El -.Sh COMMAND help -There is only one operand available for -.Nm -.Cm help -command: -.Bl -tag -width ".Cm of Ns = Ns Ar file" -.It Cm topic Ns = Ns Ar -Help topic. -.El -.Sh EXIT STATUS -.Ex -std -If the supplied argument -.Ar dev -points to a device node other than gnand or gnand.raw both -.Nm -.Cm readoob -and -.Nm -.Cm writeoob -return error. -.Sh SEE ALSO -.Xr gnand 4 diff --git a/usr.sbin/nandtool/nandtool.c b/usr.sbin/nandtool/nandtool.c deleted file mode 100644 index 4135d15c0b1..00000000000 --- a/usr.sbin/nandtool/nandtool.c +++ /dev/null @@ -1,284 +0,0 @@ -/*- - * SPDX-License-Identifier: BSD-2-Clause-FreeBSD - * - * Copyright (c) 2010-2012 Semihalf. - * 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. - */ - -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include "nandtool.h" -#include "usage.h" - -int usage(struct cmd_param *); - -static const struct { - const char *name; - const char *usage; - int (*handler)(struct cmd_param *); -} commands[] = { - { "help", nand_help_usage, usage }, - { "read", nand_read_usage, nand_read }, - { "write", nand_write_usage, nand_write }, - { "erase", nand_erase_usage, nand_erase }, - { "readoob", nand_read_oob_usage, nand_read_oob }, - { "writeoob", nand_write_oob_usage, nand_write_oob }, - { "info", nand_info_usage, nand_info }, - { NULL, NULL, NULL }, -}; - -static char * -_param_get_stringx(struct cmd_param *params, const char *name, int doexit) -{ - int i; - - for (i = 0; params[i].name[0] != '\0'; i++) { - if (!strcmp(params[i].name, name)) - return params[i].value; - } - - if (doexit) { - perrorf("Missing parameter %s", name); - exit(1); - } - return (NULL); -} - -char * -param_get_string(struct cmd_param *params, const char *name) -{ - - return (_param_get_stringx(params, name, 0)); -} - -static int -_param_get_intx(struct cmd_param *params, const char *name, int doexit) -{ - int ret; - char *str = _param_get_stringx(params, name, doexit); - - if (!str) - return (-1); - - errno = 0; - ret = (int)strtol(str, (char **)NULL, 10); - if (errno) { - if (doexit) { - perrorf("Invalid value for parameter %s", name); - exit(1); - } - return (-1); - } - - return (ret); -} - -int -param_get_intx(struct cmd_param *params, const char *name) -{ - - return (_param_get_intx(params, name, 1)); -} - -int -param_get_int(struct cmd_param *params, const char *name) -{ - - return (_param_get_intx(params, name, 0)); -} - -int -param_get_boolean(struct cmd_param *params, const char *name) -{ - char *str = param_get_string(params, name); - - if (!str) - return (0); - - if (!strcmp(str, "true") || !strcmp(str, "yes")) - return (1); - - return (0); -} - -int -param_has_value(struct cmd_param *params, const char *name) -{ - int i; - - for (i = 0; params[i].name[0] != '\0'; i++) { - if (!strcmp(params[i].name, name)) - return (1); - } - - return (0); -} - -int -param_get_count(struct cmd_param *params) -{ - int i; - - for (i = 0; params[i].name[0] != '\0'; i++); - - return (i); -} - -void -hexdumpoffset(uint8_t *buf, int length, int off) -{ - int i, j; - for (i = 0; i < length; i += 16) { - printf("%08x: ", off + i); - - for (j = 0; j < 16; j++) - printf("%02x ", buf[i+j]); - - printf("| "); - - for (j = 0; j < 16; j++) { - printf("%c", isalnum(buf[i+j]) - ? buf[i+j] - : '.'); - } - - printf("\n"); - } -} - -void -hexdump(uint8_t *buf, int length) -{ - - hexdumpoffset(buf, length, 0); -} - -void * -xmalloc(size_t len) -{ - void *ret = malloc(len); - - if (!ret) { - fprintf(stderr, "Cannot allocate buffer of %zd bytes. " - "Exiting.\n", len); - exit(EX_OSERR); - } - - return (ret); -} - -void -perrorf(const char *format, ...) -{ - va_list args; - - va_start(args, format); - vfprintf(stderr, format, args); - va_end(args); - fprintf(stderr, ": %s\n", strerror(errno)); -} - -int -usage(struct cmd_param *params) -{ - int i; - - if (!params || !param_get_count(params)) { - fprintf(stderr, "Usage: nandtool [arguments...]\n"); - fprintf(stderr, "Arguments are in form 'name=value'.\n\n"); - fprintf(stderr, "Available commands:\n"); - - for (i = 0; commands[i].name != NULL; i++) - fprintf(stderr, "\t%s\n", commands[i].name); - - fprintf(stderr, "\n"); - fprintf(stderr, "For information about particular command, " - "type:\n"); - fprintf(stderr, "'nandtool help topic='\n"); - } else if (param_has_value(params, "topic")) { - for (i = 0; commands[i].name != NULL; i++) { - if (!strcmp(param_get_string(params, "topic"), - commands[i].name)) { - fprintf(stderr, commands[i].usage, "nandtool"); - return (0); - } - } - - fprintf(stderr, "No such command\n"); - return (EX_SOFTWARE); - } else { - fprintf(stderr, "Wrong arguments given. Try: 'nandtool help'\n"); - } - - return (EX_USAGE); -} - -int -main(int argc, const char *argv[]) -{ - struct cmd_param *params; - int i, ret, idx; - - if (argc < 2) { - usage(NULL); - return (0); - } - - params = malloc(sizeof(struct cmd_param) * (argc - 1)); - - for (i = 2, idx = 0; i < argc; i++, idx++) { - if (sscanf(argv[i], "%63[^=]=%63s", params[idx].name, - params[idx].value) < 2) { - fprintf(stderr, "Syntax error in argument %d. " - "Argument should be in form 'name=value'.\n", i); - free(params); - return (-1); - } - } - - params[idx].name[0] = '\0'; - params[idx].value[0] = '\0'; - - for (i = 0; commands[i].name != NULL; i++) { - if (!strcmp(commands[i].name, argv[1])) { - ret = commands[i].handler(params); - free(params); - return (ret); - } - } - - free(params); - fprintf(stderr, "Unknown command. Try '%s help'\n", argv[0]); - - return (-1); -} - diff --git a/usr.sbin/nandtool/nandtool.h b/usr.sbin/nandtool/nandtool.h deleted file mode 100644 index 77499ecf060..00000000000 --- a/usr.sbin/nandtool/nandtool.h +++ /dev/null @@ -1,58 +0,0 @@ -/*- - * SPDX-License-Identifier: BSD-2-Clause-FreeBSD - * - * Copyright (c) 2010-2012 Semihalf. - * 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. - * - */ - -#ifndef __UTILS_H -#define __UTILS_H - -struct cmd_param -{ - char name[64]; - char value[64]; -}; - -char *param_get_string(struct cmd_param *, const char *); -int param_get_int(struct cmd_param *, const char *); -int param_get_intx(struct cmd_param *, const char *); -int param_get_boolean(struct cmd_param *, const char *); -int param_has_value(struct cmd_param *, const char *); -int param_get_count(struct cmd_param *); -void perrorf(const char *, ...); -void hexdumpoffset(uint8_t *, int, int); -void hexdump(uint8_t *, int); -void *xmalloc(size_t); - -/* Command handlers */ -int nand_read(struct cmd_param *); -int nand_write(struct cmd_param *); -int nand_read_oob(struct cmd_param *); -int nand_write_oob(struct cmd_param *); -int nand_erase(struct cmd_param *); -int nand_info(struct cmd_param *); - -#endif /* __UTILS_H */ diff --git a/usr.sbin/nandtool/usage.h b/usr.sbin/nandtool/usage.h deleted file mode 100644 index c1878aeaebb..00000000000 --- a/usr.sbin/nandtool/usage.h +++ /dev/null @@ -1,113 +0,0 @@ -/*- - * SPDX-License-Identifier: BSD-2-Clause-FreeBSD - * - * Copyright (c) 2010-2012 Semihalf. - * 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. - * - */ - -#ifndef __USAGE_H -#define __USAGE_H - -static const char nand_help_usage[] = - "Usage: %s help topic=\n" - "\n" - "Arguments:\n" - "\tcmd\t- [help|read|write|erase|readoob|writeoob|info]\n" - "\n"; - -static const char nand_read_usage[] = - "Usage: %s read dev= (block|page|pos)=n [count=n]\n" - "\n" - "Arguments:\n" - "\tdev\t- path to gnand device node\n" - "\tblock\t- starting block or\n" - "\tpage\t- starting page or\n" - "\tpos\t- starting position (in bytes, must be page-aligned)\n" - "\tout\t- output file (hexdump to stdout if not supplied)\n" - "\n" - "Note that you can only specify only one of: 'block', 'page', 'pos'\n" - "parameters at once. 'count' parameter is meaningful in terms of used\n" - "unit (page, block or byte).\n"; - -static const char nand_write_usage[] = - "Usage: %s write dev= in= (block|page|pos)=n [count=n]\n" - "\n" - "Arguments:\n" - "\tdev\t- path to gnand device node\n" - "\tin\t- path to input file which be writed to gnand\n" - "\tblock\t- starting block or\n" - "\tpage\t- starting page or\n" - "\tpos\t- starting position (in bytes, must be page-aligned)\n" - "\tcount\t- byte/page/block count\n" - "\n" - ""; - -static const char nand_erase_usage[] = - "Usage: %s erase dev= (block|page|pos)=n [count=n]\n" - "\n" - "Arguments:\n" - "\tdev\t- path to gnand device node\n" - "\tblock\t- starting block or\n" - "\tpage\t- starting page or\n" - "\tpos\t- starting position (in bytes, muse be block-aligned)\n" - "\tcount\t- byte/page/block count\n" - "\n" - "NOTE: position and count for erase operation MUST be block-aligned\n"; - -static const char nand_read_oob_usage[] = - "Usage: %s readoob dev= page=n [out=file] [count=n]\n" - "\n" - "Arguments:\n" - "\tdev\t- path to gnand device node\n" - "\tpage\t- page (page) number\n" - "\tout\t- outut file (hexdump to stdout if not supplied)\n" - "\tcount\t- page count (default is 1)\n" - "\n" - "If you supply count parameter with value other than 1, data will be\n" - "read from subsequent page's OOB areas\n"; - -static const char nand_write_oob_usage[] = - "Usage: %s writeoob dev= in= page=n [count=n]\n" - "\n" - "\tdev\t- path to gnand device node\n" - "\tin\t- path to file containing data which will be written\n" - "\tpage\t- page (page) number\n" - "\n" - "If you supply count parameter with value other than 1, data will be\n" - "written to subsequent page's OOB areas\n"; - -static const char nand_info_usage[] = - "Usage: %s info dev=\n" - "\n" - "Arguments:\n" - "\tdev\t- path to gnand device node\n"; - -static const char nand_stats_usage[] = - "Usage: %s stats dev= (page|block)=\n" - "\n" - "Arguments:\n" - "\tdev\t- path to gnand device node\n"; - -#endif /* __USAGE_H */ diff --git a/usr.sbin/pc-sysinstall/Makefile b/usr.sbin/pc-sysinstall/Makefile deleted file mode 100644 index 96c0e95cab2..00000000000 --- a/usr.sbin/pc-sysinstall/Makefile +++ /dev/null @@ -1,6 +0,0 @@ -# $FreeBSD: stable/11/usr.sbin/pc-sysinstall/Makefile 288266 2015-09-26 14:13:51Z bdrewery $ -SUBDIR=backend backend-partmanager backend-query conf doc examples -SUBDIR+=pc-sysinstall -SUBDIR_PARALLEL= - -.include diff --git a/usr.sbin/pc-sysinstall/Makefile.inc b/usr.sbin/pc-sysinstall/Makefile.inc deleted file mode 100644 index 0db2383f1b6..00000000000 --- a/usr.sbin/pc-sysinstall/Makefile.inc +++ /dev/null @@ -1,3 +0,0 @@ -# $FreeBSD: stable/11/usr.sbin/pc-sysinstall/Makefile.inc 209554 2010-06-27 17:14:04Z imp $ - -.include "../Makefile.inc" diff --git a/usr.sbin/pc-sysinstall/backend-partmanager/Makefile b/usr.sbin/pc-sysinstall/backend-partmanager/Makefile deleted file mode 100644 index af23313b8fd..00000000000 --- a/usr.sbin/pc-sysinstall/backend-partmanager/Makefile +++ /dev/null @@ -1,7 +0,0 @@ -# $FreeBSD: stable/11/usr.sbin/pc-sysinstall/backend-partmanager/Makefile 284255 2015-06-11 04:22:17Z sjg $ - -FILES= create-part.sh delete-part.sh -FILESMODE= ${BINMODE} -FILESDIR=${SHAREDIR}/pc-sysinstall/backend-partmanager - -.include diff --git a/usr.sbin/pc-sysinstall/backend-partmanager/Makefile.depend b/usr.sbin/pc-sysinstall/backend-partmanager/Makefile.depend deleted file mode 100644 index 6ba6851ecf1..00000000000 --- a/usr.sbin/pc-sysinstall/backend-partmanager/Makefile.depend +++ /dev/null @@ -1,11 +0,0 @@ -# $FreeBSD: stable/11/usr.sbin/pc-sysinstall/backend-partmanager/Makefile.depend 284345 2015-06-13 19:20:56Z sjg $ -# Autogenerated - do NOT edit! - -DIRDEPS = \ - - -.include - -.if ${DEP_RELDIR} == ${_DEP_RELDIR} -# local dependencies - needed for -jN in clean tree -.endif diff --git a/usr.sbin/pc-sysinstall/backend-partmanager/create-part.sh b/usr.sbin/pc-sysinstall/backend-partmanager/create-part.sh deleted file mode 100755 index a353946b132..00000000000 --- a/usr.sbin/pc-sysinstall/backend-partmanager/create-part.sh +++ /dev/null @@ -1,102 +0,0 @@ -#!/bin/sh -#- -# SPDX-License-Identifier: BSD-2-Clause-FreeBSD -# -# Copyright (c) 2010 iXsystems, Inc. All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions -# are met: -# 1. Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# 2. Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# -# THIS SOFTWARE IS PROVIDED BY 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. -# - -# Create partitions on a target disk -############################# - -. ${PROGDIR}/backend/functions.sh - -if [ -z "${1}" ] ; then - echo "Error: No disk specified!" - exit 1 -fi - -if [ -z "${2}" ] ; then - echo "Error: No size specified!" - exit 1 -fi - -if [ ! -e "/dev/${1}" ] ; then - echo "Error: Disk /dev/${1} does not exist!" - exit 1 -fi - -DISK="${1}" -MB="${2}" -TYPE="${3}" -STARTBLOCK="${4}" - -TOTALBLOCKS="`expr $MB \* 2048`" - -# If no TYPE specified, default to MBR -if [ -z "$TYPE" ] ; then TYPE="mbr" ; fi - -# Sanity check the gpart type -case $TYPE in - apm|APM) ;; - bsd|BSD) ;; - ebr|EBR) ;; - gpt|GPT) ;; - mbr|MBR) ;; - *) echo "Error: Unknown gpart type: $TYPE" ; exit 1 ;; -esac - -# Lets figure out what number this partition will be -LASTSLICE="`gpart show $DISK | grep -v -e $DISK -e '\- free \-' -e '^$' | awk 'END {print $3}'`" -if [ -z "${LASTSLICE}" ] ; then - LASTSLICE="1" -else - LASTSLICE="`expr $LASTSLICE + 1`" -fi - -SLICENUM="${LASTSLICE}" - -# Set a 4k Aligned start block if none specified -if [ "${SLICENUM}" = "1" -a -z "$STARTBLOCK" ] ; then - STARTBLOCK="2016" -fi - - -# If this is an empty disk, see if we need to create a new scheme for it -gpart show ${DISK} >/dev/null 2>/dev/null -if [ $? -eq 0 -a "${SLICENUM}" = "1" ] ; then - if [ "${TYPE}" = "mbr" -o "${TYPE}" = "MBR" ] ; then - flags="-s ${TYPE} -f active" - else - flags="-s ${TYPE}" - fi - gpart create ${flags} ${DISK} -fi - -# If we have a starting block, use it -if [ -n "$STARTBLOCK" ] ; then - sBLOCK="-b $STARTBLOCK" -fi - -gpart add ${sBLOCK} -s ${TOTALBLOCKS} -t freebsd -i ${SLICENUM} ${DISK} -exit "$?" diff --git a/usr.sbin/pc-sysinstall/backend-partmanager/delete-part.sh b/usr.sbin/pc-sysinstall/backend-partmanager/delete-part.sh deleted file mode 100755 index bd222866a06..00000000000 --- a/usr.sbin/pc-sysinstall/backend-partmanager/delete-part.sh +++ /dev/null @@ -1,89 +0,0 @@ -#!/bin/sh -#- -# Copyright (c) 2010 iXsystems, Inc. All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions -# are met: -# 1. Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# 2. Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# -# THIS SOFTWARE IS PROVIDED BY 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. -# -# $FreeBSD: stable/11/usr.sbin/pc-sysinstall/backend-partmanager/delete-part.sh 228990 2011-12-30 10:58:14Z uqs $ - -# Delete a specified partition, takes effect immediately -######################################################## - -. ${PROGDIR}/backend/functions.sh -. ${PROGDIR}/backend/functions-disk.sh - -if [ -z "${1}" ] -then - echo "Error: No partition specified!" - exit 1 -fi - -if [ ! -e "/dev/${1}" ] -then - echo "Error: Partition /dev/${1} does not exist!" - exit 1 -fi - -PARTITION="${1}" - -# First lets figure out the partition number for the given device -################################################################## - -# Get the number of characters in this dev -CHARS="`echo $PARTITION | wc -c`" - -PARTINDEX="" - -# Lets read through backwards until we get the part number -while -z=1 -do - CHARS=$((CHARS-1)) - LAST_CHAR=`echo "${PARTITION}" | cut -c $CHARS` - echo "${LAST_CHAR}" | grep -q "^[0-9]$" 2>/dev/null - if [ $? -eq 0 ] ; then - PARTINDEX="${LAST_CHAR}${PARTINDEX}" - else - break - fi -done - -# Now get current disk we are working on -CHARS=`expr $CHARS - 1` -DISK="`echo $PARTITION | cut -c 1-${CHARS}`" - -# Make sure we have a valid disk name still -if [ ! -e "/dev/${DISK}" ] ; then - echo "Error: Disk: ${DISK} doesn't exist!" - exit 1 -fi - -echo "Running: gpart delete -i ${PARTINDEX} ${DISK}" -gpart delete -i ${PARTINDEX} ${DISK} >/dev/null 2>/dev/null - -# Check if this was the last partition and destroy the disk geom if so -get_disk_partitions "${DISK}" -if [ -z "${VAL}" ] ; then - gpart destroy ${DISK} -fi - -exit "$?" diff --git a/usr.sbin/pc-sysinstall/backend-query/Makefile b/usr.sbin/pc-sysinstall/backend-query/Makefile deleted file mode 100644 index efb04c1ccd9..00000000000 --- a/usr.sbin/pc-sysinstall/backend-query/Makefile +++ /dev/null @@ -1,12 +0,0 @@ -# $FreeBSD: stable/11/usr.sbin/pc-sysinstall/backend-query/Makefile 284255 2015-06-11 04:22:17Z sjg $ - -FILES= detect-laptop.sh detect-nics.sh detect-emulation.sh disk-info.sh \ - disk-list.sh disk-part.sh enable-net.sh get-packages.sh list-config.sh \ - list-components.sh list-mirrors.sh list-packages.sh list-rsync-backups.sh \ - list-tzones.sh query-langs.sh send-logs.sh set-mirror.sh setup-ssh-keys.sh \ - sys-mem.sh test-live.sh test-netup.sh update-part-list.sh xkeyboard-layouts.sh \ - xkeyboard-models.sh xkeyboard-variants.sh -FILESMODE= ${BINMODE} -FILESDIR=${SHAREDIR}/pc-sysinstall/backend-query - -.include diff --git a/usr.sbin/pc-sysinstall/backend-query/Makefile.depend b/usr.sbin/pc-sysinstall/backend-query/Makefile.depend deleted file mode 100644 index 8265be84e1e..00000000000 --- a/usr.sbin/pc-sysinstall/backend-query/Makefile.depend +++ /dev/null @@ -1,11 +0,0 @@ -# $FreeBSD: stable/11/usr.sbin/pc-sysinstall/backend-query/Makefile.depend 284345 2015-06-13 19:20:56Z sjg $ -# Autogenerated - do NOT edit! - -DIRDEPS = \ - - -.include - -.if ${DEP_RELDIR} == ${_DEP_RELDIR} -# local dependencies - needed for -jN in clean tree -.endif diff --git a/usr.sbin/pc-sysinstall/backend-query/detect-emulation.sh b/usr.sbin/pc-sysinstall/backend-query/detect-emulation.sh deleted file mode 100755 index 8e103f8ab4b..00000000000 --- a/usr.sbin/pc-sysinstall/backend-query/detect-emulation.sh +++ /dev/null @@ -1,42 +0,0 @@ -#!/bin/sh -#- -# SPDX-License-Identifier: BSD-2-Clause-FreeBSD -# -# Copyright (c) 2010 iXsystems, Inc. All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions -# are met: -# 1. Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# 2. Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# -# THIS SOFTWARE IS PROVIDED BY 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. -# - -case "$(kenv smbios.system.product)" in -VirtualBox) - echo "emulation: VIRTUALBOX" - exit 0 - ;; -VMware*) - echo "emulation: VMWARE" - exit 0 - ;; -*) - echo "emulation: NO" - exit 1 - ;; -esac diff --git a/usr.sbin/pc-sysinstall/backend-query/detect-laptop.sh b/usr.sbin/pc-sysinstall/backend-query/detect-laptop.sh deleted file mode 100755 index d07d36bafc5..00000000000 --- a/usr.sbin/pc-sysinstall/backend-query/detect-laptop.sh +++ /dev/null @@ -1,33 +0,0 @@ -#!/bin/sh -#- -# SPDX-License-Identifier: BSD-2-Clause-FreeBSD -# -# Copyright (c) 2010 iXsystems, Inc. All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions -# are met: -# 1. Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# 2. Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# -# THIS SOFTWARE IS PROVIDED BY 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. -# - -if devinfo | grep -q acpi_acad0; then - echo "laptop: YES" -else - echo "laptop: NO" -fi diff --git a/usr.sbin/pc-sysinstall/backend-query/detect-nics.sh b/usr.sbin/pc-sysinstall/backend-query/detect-nics.sh deleted file mode 100755 index a2d8da19f0d..00000000000 --- a/usr.sbin/pc-sysinstall/backend-query/detect-nics.sh +++ /dev/null @@ -1,37 +0,0 @@ -#!/bin/sh -#- -# SPDX-License-Identifier: BSD-2-Clause-FreeBSD -# -# Copyright (c) 2010 iXsystems, Inc. All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions -# are met: -# 1. Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# 2. Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# -# THIS SOFTWARE IS PROVIDED BY 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. -# - -for i in $(ifconfig -l); do - case "${i%%[0-9]*}" in - lo|fwe|fwip|plip|pfsync|pflog|tun) - continue - ;; - esac - IDENT=$(dmesg | sed -n "s/^$i: <\(.*\)>.*$/\1/p" | head -1) - echo "${i}: <$IDENT>" -done diff --git a/usr.sbin/pc-sysinstall/backend-query/disk-info.sh b/usr.sbin/pc-sysinstall/backend-query/disk-info.sh deleted file mode 100755 index c6ef254b136..00000000000 --- a/usr.sbin/pc-sysinstall/backend-query/disk-info.sh +++ /dev/null @@ -1,61 +0,0 @@ -#!/bin/sh -#- -# SPDX-License-Identifier: BSD-2-Clause-FreeBSD -# -# Copyright (c) 2010 iXsystems, Inc. All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions -# are met: -# 1. Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# 2. Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# -# THIS SOFTWARE IS PROVIDED BY 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. -# - -# Query a disk for partitions and display them -############################################################################# - -. ${PROGDIR}/backend/functions.sh -. ${PROGDIR}/backend/functions-disk.sh - -DISK="${1}" - -[ -z "${DISK}" ] && { echo 'Error: No disk specified!'; exit 1; } -[ ! -e "/dev/${DISK}" ] && \ - { echo "Error: Disk /dev/${DISK} does not exist!"; exit 1; } - -get_disk_cyl "${DISK}" -CYLS="${VAL}" - -get_disk_heads "${DISK}" -HEADS="${VAL}" - -get_disk_sectors "${DISK}" -SECS="${VAL}" - -# Now get the disks size in MB -KB="`diskinfo -v ${1} | grep 'bytes' | cut -d '#' -f 1 | tr -s '\t' ' ' | tr -d ' '`" -MB=$(convert_byte_to_megabyte ${KB}) - -# Now get the Controller Type -CTYPE="`dmesg | grep "^${1}:" | grep "B <" | cut -d '>' -f 2 | cut -d ' ' -f 3-10`" - -echo "cylinders=${CYLS}" -echo "heads=${HEADS}" -echo "sectors=${SECS}" -echo "size=${MB}" -echo "type=${CTYPE}" diff --git a/usr.sbin/pc-sysinstall/backend-query/disk-list.sh b/usr.sbin/pc-sysinstall/backend-query/disk-list.sh deleted file mode 100755 index ab2fc05f010..00000000000 --- a/usr.sbin/pc-sysinstall/backend-query/disk-list.sh +++ /dev/null @@ -1,113 +0,0 @@ -#!/bin/sh -#- -# SPDX-License-Identifier: BSD-2-Clause-FreeBSD -# -# Copyright (c) 2010 iXsystems, Inc. All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions -# are met: -# 1. Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# 2. Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# -# THIS SOFTWARE IS PROVIDED BY 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. -# - -ARGS=$1 -FLAGS_MD="" -FLAGS_CD="" -FLAGS_VERBOSE="" - -shift -while [ -n "$1" ] -do - case "$1" in - -m) - FLAGS_MD=1 - ;; - -v) - FLAGS_VERBOSE=1 - ;; - -c) - FLAGS_CD=1 - ;; - esac - shift -done - -# Create our device listing -SYSDISK=$(sysctl -n kern.disks) -if [ -n "${FLAGS_MD}" ] -then - MDS=`mdconfig -l` - if [ -n "${MDS}" ] - then - SYSDISK="${SYSDISK} ${MDS}" - fi -fi - -# Add any RAID devices -if [ -d "/dev/raid" ] ; then - cd /dev/raid - for i in `ls` - do - SYSDISK="${SYSDISK} ${i}" - done -fi - -# Now loop through these devices, and list the disk drives -for i in ${SYSDISK} -do - - # Get the current device - DEV="${i}" - - # Make sure we don't find any cd devices - if [ -z "${FLAGS_CD}" ] - then - case "${DEV}" in - acd[0-9]*|cd[0-9]*|scd[0-9]*) continue ;; - esac - fi - - # Try and get some identification information from GEOM - NEWLINE=$(geom disk list $DEV 2>/dev/null | sed -ne 's/^ descr: *//p') - if [ -z "$NEWLINE" ]; then - NEWLINE=" " - fi - - if [ -n "${FLAGS_MD}" ] && echo "${DEV}" | grep -E '^md[0-9]+' >/dev/null 2>/dev/null - then - NEWLINE=" " - fi - - if [ -n "${FLAGS_VERBOSE}" ] - then - : - fi - - # Save the disk list - if [ ! -z "$DLIST" ] - then - DLIST="\n${DLIST}" - fi - - DLIST="${DEV}:${NEWLINE}${DLIST}" - -done - -# Echo out the found line -echo -e "$DLIST" | sort diff --git a/usr.sbin/pc-sysinstall/backend-query/disk-part.sh b/usr.sbin/pc-sysinstall/backend-query/disk-part.sh deleted file mode 100755 index cd8ab7820a5..00000000000 --- a/usr.sbin/pc-sysinstall/backend-query/disk-part.sh +++ /dev/null @@ -1,112 +0,0 @@ -#!/bin/sh -#- -# SPDX-License-Identifier: BSD-2-Clause-FreeBSD -# -# Copyright (c) 2010 iXsystems, Inc. All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions -# are met: -# 1. Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# 2. Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# -# THIS SOFTWARE IS PROVIDED BY 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. -# - -# Query a disk for partitions and display them -############################# - -. ${PROGDIR}/backend/functions.sh -. ${PROGDIR}/backend/functions-disk.sh - -if [ -z "${1}" ] -then - echo "Error: No disk specified!" - exit 1 -fi - -if [ ! -e "/dev/${1}" ] -then - echo "Error: Disk /dev/${1} does not exist!" - exit 1 -fi - -DISK="${1}" - -# Now get the disks size in MB -KB="`diskinfo -v ${1} | grep 'bytes' | cut -d '#' -f 1 | tr -s '\t' ' ' | tr -d ' '`" -MB=$(convert_byte_to_megabyte ${KB}) -TOTALSIZE="$MB" -TOTALB="`diskinfo -v ${1} | grep 'in sectors' | tr -s '\t' ' ' | cut -d ' ' -f 2`" - -gpart show ${1} >/dev/null 2>/dev/null -if [ "$?" != "0" ] ; then - # No partitions on this disk, display entire disk size and exit - echo "${1}-freemb: ${TOTALSIZE}" - echo "${1}-freeblocks: ${TOTALB}" - exit -fi - -# Display if this is GPT or MBR formatted -TYPE=`gpart show ${1} | awk '/^=>/ { printf("%s",$5); }'` -echo "${1}-format: $TYPE" - -# Set some search flags -PART="0" -EXTENDED="0" -START="0" -SIZEB="0" - -# Get a listing of partitions on this disk -get_disk_partitions "${DISK}" -PARTS="${VAL}" -for curpart in $PARTS -do - - # First get the sysid / label for this partition - if [ "$TYPE" = "MBR" ] ; then - get_partition_sysid_mbr "${DISK}" "${curpart}" - echo "${curpart}-sysid: ${VAL}" - get_partition_label_mbr "${DISK}" "${curpart}" - echo "${curpart}-label: ${VAL}" - else - get_partition_label_gpt "${DISK}" "${curpart}" - echo "${curpart}-sysid: ${VAL}" - echo "${curpart}-label: ${VAL}" - fi - - # Now get the startblock, blocksize and MB size of this partition - - get_partition_startblock "${DISK}" "${curpart}" - START="${VAL}" - echo "${curpart}-blockstart: ${START}" - - get_partition_blocksize "${DISK}" "${curpart}" - SIZEB="${VAL}" - echo "${curpart}-blocksize: ${SIZEB}" - - SIZEMB=$(convert_blocks_to_megabyte ${SIZEB}) - echo "${curpart}-sizemb: ${SIZEMB}" - -done - - -# Now calculate any free space -LASTB="`expr $SIZEB + $START`" -FREEB="`expr $TOTALB - $LASTB`" -FREEMB="`expr ${FREEB} / 2048`" -echo "${1}-freemb: $FREEMB" -echo "${1}-freeblocks: $FREEB" diff --git a/usr.sbin/pc-sysinstall/backend-query/enable-net.sh b/usr.sbin/pc-sysinstall/backend-query/enable-net.sh deleted file mode 100755 index f1aa78dbb96..00000000000 --- a/usr.sbin/pc-sysinstall/backend-query/enable-net.sh +++ /dev/null @@ -1,115 +0,0 @@ -#!/bin/sh -#- -# SPDX-License-Identifier: BSD-2-Clause-FreeBSD -# -# Copyright (c) 2010 iXsystems, Inc. All rights reserved. -# Copyright (c) 2011 The FreeBSD Foundation -# All rights reserved. -# -# Portions of this software were developed by Bjoern Zeeb -# under sponsorship from the FreeBSD Foundation. -# -# 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. -# - -# Script which enables networking with specified options -########################################################################### - -. ${PROGDIR}/backend/functions.sh -. ${PROGDIR}/conf/pc-sysinstall.conf -. ${BACKEND}/functions-networking.sh -. ${BACKEND}/functions-parse.sh - - -NIC="$1" -IP="$2" -NETMASK="$3" -DNS="$4" -GATEWAY="$5" -MIRRORFETCH="$6" -IPV6="$7" -IPV6GATE="$8" -IPV6DNS="$9" - -if [ -z "${NIC}" ] -then - echo "ERROR: Usage enable-net " \ - " " - exit 150 -fi - -if [ "$NIC" = "AUTO-DHCP" ] -then - enable_auto_dhcp -elif [ "$NIC" = "IPv6-SLAAC" ] -then - enable_auto_slaac - # In addition, if static values were defined, add them as well. - # We might not get DNS information from RAs, for example. - if [ -n "${IPV6}" ]; then - VAL="" - get_first_wired_nic - if [ -n "${VAL}" ]; then - ifconfig ${VAL} inet6 ${IPV6} alias - fi - fi - # Append only here. - if [ -n "${IPV6DNS}" ]; then - echo "nameserver ${IPV6DNS}" >>/etc/resolv.conf - fi - # Do not - if [ -n "${IPV6GATE}" ]; then - # Check if we have a default route already to not overwrite. - if ! route -n get -inet6 default > /dev/null 2>&1 ; then - route add -inet6 default ${IPV6GATE} - fi - fi -else - echo "Enabling NIC: $NIC" - if [ -n "${IP}" ]; then - ifconfig ${NIC} inet ${IP} ${NETMASK} - fi - if [ -n "${IPV6}" ]; then - ifconfig ${NIC} inet6 ${IPV6} alias - fi - - # Keep default from IPv4-only support times and clear the resolv.conf file. - : > /etc/resolv.conf - if [ -n "${DNS}" ]; then - echo "nameserver ${DNS}" >>/etc/resolv.conf - fi - if [ -n "${IPV6DNS}" ]; then - echo "nameserver ${IPV6DNS}" >>/etc/resolv.conf - fi - - if [ -n "${GATE}" ]; then - route add -inet default ${GATE} - fi - if [ -n "${IPV6GATE}" ]; then - route add -inet6 default ${IPV6GATE} - fi -fi - -case ${MIRRORFETCH} in - ON|on|yes|YES) fetch -o /tmp/mirrors-list.txt ${MIRRORLIST} >/dev/null 2>/dev/null;; - *) ;; -esac diff --git a/usr.sbin/pc-sysinstall/backend-query/get-packages.sh b/usr.sbin/pc-sysinstall/backend-query/get-packages.sh deleted file mode 100755 index a1b2c2f2f92..00000000000 --- a/usr.sbin/pc-sysinstall/backend-query/get-packages.sh +++ /dev/null @@ -1,53 +0,0 @@ -#!/bin/sh -#- -# SPDX-License-Identifier: BSD-2-Clause-FreeBSD -# -# Copyright (c) 2010 iXsystems, Inc. All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions -# are met: -# 1. Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# 2. Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# -# THIS SOFTWARE IS PROVIDED BY 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. -# - -# Script which lists the available packages for this release -########################################################################### - -. ${PROGDIR}/backend/functions.sh -. ${PROGDIR}/backend/functions-packages.sh - -ID=`id -u` -if [ "${ID}" -ne "0" ] -then - echo "Error: must be root!" - exit 1 -fi - -if [ ! -f "${PKGDIR}/INDEX" ] -then - get_package_index -fi - -if [ -f "${PKGDIR}/INDEX" ] -then - echo "${PKGDIR}/INDEX" - exit 0 -fi - -exit 1 diff --git a/usr.sbin/pc-sysinstall/backend-query/list-components.sh b/usr.sbin/pc-sysinstall/backend-query/list-components.sh deleted file mode 100755 index 9affb52506f..00000000000 --- a/usr.sbin/pc-sysinstall/backend-query/list-components.sh +++ /dev/null @@ -1,56 +0,0 @@ -#!/bin/sh -#- -# SPDX-License-Identifier: BSD-2-Clause-FreeBSD -# -# Copyright (c) 2010 iXsystems, Inc. All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions -# are met: -# 1. Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# 2. Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# -# THIS SOFTWARE IS PROVIDED BY 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. -# - -# Script which lists the available components for this release -########################################################################### - -. ${PROGDIR}/backend/functions.sh - -echo "Available Components:" - -if [ -d "${COMPDIR}" ] -then - cd ${COMPDIR} - for i in `ls -d *` - do - if [ -e "${i}/component.cfg" -a -e "${i}/install.sh" -a -e "${i}/distfiles" ] - then - NAME="`grep 'name:' ${i}/component.cfg | cut -d ':' -f 2`" - DESC="`grep 'description:' ${i}/component.cfg | cut -d ':' -f 2`" - TYPE="`grep 'type:' ${i}/component.cfg | cut -d ':' -f 2`" - echo " " - echo "name: ${i}" - echo "desc:${DESC}" - echo "type:${TYPE}" - if [ -e "${i}/component.png" ] - then - echo "icon: ${COMPDIR}/${i}/component.png" - fi - fi - done -fi diff --git a/usr.sbin/pc-sysinstall/backend-query/list-config.sh b/usr.sbin/pc-sysinstall/backend-query/list-config.sh deleted file mode 100755 index 00bd668d250..00000000000 --- a/usr.sbin/pc-sysinstall/backend-query/list-config.sh +++ /dev/null @@ -1,31 +0,0 @@ -#!/bin/sh -#- -# SPDX-License-Identifier: BSD-2-Clause-FreeBSD -# -# Copyright (c) 2010 iXsystems, Inc. All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions -# are met: -# 1. Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# 2. Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# -# THIS SOFTWARE IS PROVIDED BY 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. -# - -echo "branch=${FBSD_BRANCH}" -echo "arch=${FBSD_ARCH}" -exit 0 diff --git a/usr.sbin/pc-sysinstall/backend-query/list-mirrors.sh b/usr.sbin/pc-sysinstall/backend-query/list-mirrors.sh deleted file mode 100755 index d18eae31c05..00000000000 --- a/usr.sbin/pc-sysinstall/backend-query/list-mirrors.sh +++ /dev/null @@ -1,38 +0,0 @@ -#!/bin/sh -#- -# SPDX-License-Identifier: BSD-2-Clause-FreeBSD -# -# Copyright (c) 2010 iXsystems, Inc. All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions -# are met: -# 1. Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# 2. Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# -# THIS SOFTWARE IS PROVIDED BY 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. -# - -. ${PROGDIR}/backend/functions.sh -. ${PROGDIR}/backend/functions-ftp.sh - -# Backend script which lists all the available ftp mirrors for front-ends to display -COUNTRY="${1}" - -get_ftp_mirrors "${COUNTRY}" -show_mirrors "${VAL}" - -exit 0 diff --git a/usr.sbin/pc-sysinstall/backend-query/list-packages.sh b/usr.sbin/pc-sysinstall/backend-query/list-packages.sh deleted file mode 100755 index fbffb3cc425..00000000000 --- a/usr.sbin/pc-sysinstall/backend-query/list-packages.sh +++ /dev/null @@ -1,87 +0,0 @@ -#!/bin/sh -#- -# SPDX-License-Identifier: BSD-2-Clause-FreeBSD -# -# Copyright (c) 2010 iXsystems, Inc. All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions -# are met: -# 1. Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# 2. Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# -# THIS SOFTWARE IS PROVIDED BY 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. -# - -# Script which lists the available packages for this release -########################################################################### - -. ${PROGDIR}/backend/functions.sh -. ${PROGDIR}/backend/functions-packages.sh - -PACKAGE_CATEGORY="${1}" -PACKAGE_NAME="${2}" -NARGS=0 - -if [ ! -f "${PKGDIR}/INDEX" ] -then - echo "Error: please fetch package index with get-packages!" - exit 1 -fi - -if [ ! -f "${PKGDIR}/INDEX.parsed" ] -then - parse_package_index -fi - -if [ -n "${PACKAGE_CATEGORY}" ] -then - NARGS=$((NARGS+1)) -fi - -if [ -n "${PACKAGE_NAME}" ] -then - NARGS=$((NARGS+1)) -fi - -if [ "${NARGS}" -eq "0" ] -then - show_packages - -elif [ "${NARGS}" -eq "1" ] -then - - if [ "${PACKAGE_CATEGORY}" = "@INDEX@" ] - then - if [ -f "${PKGDIR}/INDEX" ] - then - echo "${PKGDIR}/INDEX" - exit 0 - else - exit 1 - fi - - else - show_packages_by_category "${PACKAGE_CATEGORY}" - fi - -elif [ "${NARGS}" -eq "2" ] -then - show_package_by_name "${PACKAGE_CATEGORY}" "${PACKAGE_NAME}" - -else - show_packages -fi diff --git a/usr.sbin/pc-sysinstall/backend-query/list-rsync-backups.sh b/usr.sbin/pc-sysinstall/backend-query/list-rsync-backups.sh deleted file mode 100755 index 979fa81de32..00000000000 --- a/usr.sbin/pc-sysinstall/backend-query/list-rsync-backups.sh +++ /dev/null @@ -1,71 +0,0 @@ -#!/bin/sh -#- -# SPDX-License-Identifier: BSD-2-Clause-FreeBSD -# -# Copyright (c) 2010 iXsystems, Inc. All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions -# are met: -# 1. Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# 2. Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# -# THIS SOFTWARE IS PROVIDED BY 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. -# - -# Script which lists the backups present on a server -########################################################################### - -. ${PROGDIR}/backend/functions.sh - -SSHUSER=$1 -SSHHOST=$2 -SSHPORT=$3 - -if [ -z "${SSHHOST}" -o -z "${SSHPORT}" ] -then - echo "ERROR: Usage list-rsync-backups.sh " - exit 150 -fi - -# Look for full-system backups, needs at minimum a kernel to be bootable -FINDCMD="find . -type d -maxdepth 6 -name 'kernel' | grep '/boot/kernel'" - -# Get a listing of the number of full backups saved -OLDBACKUPS=`ssh -o 'BatchMode=yes' -p ${SSHPORT} ${SSHUSER}@${SSHHOST} "${FINDCMD}"` -if [ "$?" = "0" ] -then - for i in ${OLDBACKUPS} - do - BACKPATH="`echo ${i} | sed 's|/boot/.*||g' | sed 's|^./||g'`" - if [ -z "${BACKLIST}" ] - then - BACKLIST="${BACKPATH}" - else - BACKLIST="${BACKLIST}:${BACKPATH}" - fi - done - - if [ -z "${BACKLIST}" ] - then - echo "NONE" - else - echo "$BACKLIST" - fi - -else - echo "FAILED" -fi diff --git a/usr.sbin/pc-sysinstall/backend-query/list-tzones.sh b/usr.sbin/pc-sysinstall/backend-query/list-tzones.sh deleted file mode 100755 index f920408f397..00000000000 --- a/usr.sbin/pc-sysinstall/backend-query/list-tzones.sh +++ /dev/null @@ -1,35 +0,0 @@ -#!/bin/sh -#- -# SPDX-License-Identifier: BSD-2-Clause-FreeBSD -# -# Copyright (c) 2010 iXsystems, Inc. All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions -# are met: -# 1. Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# 2. Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# -# THIS SOFTWARE IS PROVIDED BY 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. -# - -# Backend script which lists all the available timezones for front-ends to display -egrep -v '^#' /usr/share/zoneinfo/zone.tab |\ - tr -s "\t" ":" |\ - cut -d ":" -f 3-4 |\ - sort - -exit 0 diff --git a/usr.sbin/pc-sysinstall/backend-query/query-langs.sh b/usr.sbin/pc-sysinstall/backend-query/query-langs.sh deleted file mode 100755 index fa3426bdde1..00000000000 --- a/usr.sbin/pc-sysinstall/backend-query/query-langs.sh +++ /dev/null @@ -1,31 +0,0 @@ -#!/bin/sh -#- -# SPDX-License-Identifier: BSD-2-Clause-FreeBSD -# -# Copyright (c) 2010 iXsystems, Inc. All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions -# are met: -# 1. Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# 2. Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# -# THIS SOFTWARE IS PROVIDED BY 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. -# - -cat ${PROGDIR}/conf/avail-langs - -exit 0 diff --git a/usr.sbin/pc-sysinstall/backend-query/send-logs.sh b/usr.sbin/pc-sysinstall/backend-query/send-logs.sh deleted file mode 100755 index bc16d7146fc..00000000000 --- a/usr.sbin/pc-sysinstall/backend-query/send-logs.sh +++ /dev/null @@ -1,84 +0,0 @@ -#!/bin/sh -#- -# SPDX-License-Identifier: BSD-2-Clause-FreeBSD -# -# Copyright (c) 2010 iXsystems, Inc. All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions -# are met: -# 1. Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# 2. Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# -# THIS SOFTWARE IS PROVIDED BY 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. -# - -# Script which creates a gzipped log and optionally mails it to the specified address -############################################################################ - -. ${PROGDIR}/backend/functions.sh -. ${PROGDIR}/conf/pc-sysinstall.conf -. ${BACKEND}/functions-networking.sh -. ${BACKEND}/functions-parse.sh - -# Bring up all NICS under DHCP -enable_auto_dhcp - -MAILTO="$1" -MAILRESULT="0" - -# Set the location of our compressed log -TMPLOG="/tmp/pc-sysinstall.log" - -echo "# PC-SYSINSTALL LOG" >${TMPLOG} -cat ${LOGOUT} >> ${TMPLOG} - -# Check if we have a GUI generated install cfg -if [ -e "/tmp/sys-install.cfg" ] -then - echo "" >>${TMPLOG} - echo "# PC-SYSINSTALL CFG " >>${TMPLOG} - cat /tmp/sys-install.cfg | grep -vE 'rootPass|userPass' >> ${TMPLOG} -fi - -# Save dmesg output -echo "" >>${TMPLOG} -echo "# DMESG OUTPUT " >>${TMPLOG} -dmesg >> ${TMPLOG} - -# Get gpart info on all disks -for i in `pc-sysinstall disk-list | cut -d ':' -f 1` -do - echo "" >>${TMPLOG} - echo "# DISK INFO $i " >>${TMPLOG} - ls /dev/${i}* >>${TMPLOG} - gpart show ${i} >> ${TMPLOG} -done - -# Show Mounted volumes -echo "" >>${TMPLOG} -echo "# MOUNT OUTPUT " >>${TMPLOG} -mount >> ${TMPLOG} - -echo "Log file saved to ${TMPLOG}" -echo "Warning: This file will be lost once the system is rebooted." - -echo "Do you wish to view this logfile now? (Y/N)" -read tmp -if [ "$tmp" = "Y" -o "$tmp" = "y" ] -then - more ${TMPLOG} -fi diff --git a/usr.sbin/pc-sysinstall/backend-query/set-mirror.sh b/usr.sbin/pc-sysinstall/backend-query/set-mirror.sh deleted file mode 100755 index b571c0af6fb..00000000000 --- a/usr.sbin/pc-sysinstall/backend-query/set-mirror.sh +++ /dev/null @@ -1,41 +0,0 @@ -#!/bin/sh -#- -# SPDX-License-Identifier: BSD-2-Clause-FreeBSD -# -# Copyright (c) 2010 iXSystems, Inc. All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions -# are met: -# 1. Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# 2. Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# -# THIS SOFTWARE IS PROVIDED BY 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. -# - -. ${PROGDIR}/backend/functions.sh -. ${PROGDIR}/backend/functions-ftp.sh - -MIRROR="${1}" - -if [ -z "${MIRROR}" ] -then - echo "Error: No mirror specified!" - exit 1 -fi - -set_ftp_mirror "${MIRROR}" -exit 0 diff --git a/usr.sbin/pc-sysinstall/backend-query/setup-ssh-keys.sh b/usr.sbin/pc-sysinstall/backend-query/setup-ssh-keys.sh deleted file mode 100755 index 7f0af93c9f3..00000000000 --- a/usr.sbin/pc-sysinstall/backend-query/setup-ssh-keys.sh +++ /dev/null @@ -1,65 +0,0 @@ -#!/bin/sh -#- -# SPDX-License-Identifier: BSD-2-Clause-FreeBSD -# -# Copyright (c) 2010 iXsystems, Inc. All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions -# are met: -# 1. Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# 2. Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# -# THIS SOFTWARE IS PROVIDED BY 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. -# - -# Script which sets up password-less logins for ssh host -########################################################################### - -. ${PROGDIR}/backend/functions.sh - -SSHUSER=$1 -SSHHOST=$2 -SSHPORT=$3 - -if [ -z "${SSHUSER}" -o -z "${SSHHOST}" -o -z "${SSHPORT}" ] -then - echo "ERROR: Usage setup-ssh-keys " - exit 150 -fi - -cd ~ - -echo "Preparing to setup SSH key authorization..." -echo "When prompted, enter your password for ${SSHUSER}@${SSHHOST}" - -if [ ! -e ".ssh/id_rsa.pub" ] -then - mkdir .ssh >/dev/null 2>/dev/null - ssh-keygen -q -t rsa -N '' -f .ssh/id_rsa - sleep 1 -fi - -if [ ! -e ".ssh/id_rsa.pub" ] -then - echo "ERROR: Failed creating .ssh/id_rsa.pub" - exit 150 -fi - -# Get the .pub key -PUBKEY="`cat .ssh/id_rsa.pub`" - -ssh -p ${SSHPORT} ${SSHUSER}@${SSHHOST} "mkdir .ssh ; echo $PUBKEY >> .ssh/authorized_keys; chmod 600 .ssh/authorized_keys ; echo $PUBKEY >> .ssh/authorized_keys2; chmod 600 .ssh/authorized_keys2" diff --git a/usr.sbin/pc-sysinstall/backend-query/sys-mem.sh b/usr.sbin/pc-sysinstall/backend-query/sys-mem.sh deleted file mode 100755 index 9f8c4cd9373..00000000000 --- a/usr.sbin/pc-sysinstall/backend-query/sys-mem.sh +++ /dev/null @@ -1,40 +0,0 @@ -#!/bin/sh -#- -# SPDX-License-Identifier: BSD-2-Clause-FreeBSD -# -# Copyright (c) 2010 iXsystems, Inc. All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions -# are met: -# 1. Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# 2. Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# -# THIS SOFTWARE IS PROVIDED BY 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. -# - -if smbios_mem=$(kenv -q smbios.memory.enabled); then - smbios_mem=$(expr $smbios_mem / 1024) -else - smbios_mem=0 -fi -realmem=$(expr $(sysctl -n hw.realmem) / 1048576) - -if [ $smbios_mem -gt $realmem ]; then - echo $smbios_mem -else - echo $realmem -fi diff --git a/usr.sbin/pc-sysinstall/backend-query/test-live.sh b/usr.sbin/pc-sysinstall/backend-query/test-live.sh deleted file mode 100755 index 7f97fb1471d..00000000000 --- a/usr.sbin/pc-sysinstall/backend-query/test-live.sh +++ /dev/null @@ -1,34 +0,0 @@ -#!/bin/sh -#- -# SPDX-License-Identifier: BSD-2-Clause-FreeBSD -# -# Copyright (c) 2010 iXsystems, Inc. All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions -# are met: -# 1. Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# 2. Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# -# THIS SOFTWARE IS PROVIDED BY 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. -# - -# Script which checks if we are running from install media, or real system -############################################################################# - -dmesg | grep -q 'md0: Preloaded image' || { echo 'REAL-DISK'; exit 1; } - -echo 'INSTALL-MEDIA' diff --git a/usr.sbin/pc-sysinstall/backend-query/test-netup.sh b/usr.sbin/pc-sysinstall/backend-query/test-netup.sh deleted file mode 100755 index 10b176f2845..00000000000 --- a/usr.sbin/pc-sysinstall/backend-query/test-netup.sh +++ /dev/null @@ -1,70 +0,0 @@ -#!/bin/sh -#- -# SPDX-License-Identifier: BSD-2-Clause-FreeBSD -# -# Copyright (c) 2010 iXsystems, Inc. All rights reserved. -# Copyright (c) 2011 The FreeBSD Foundation -# All rights reserved. -# -# Portions of this software were developed by Bjoern Zeeb -# under sponsorship from the FreeBSD Foundation.# -# -# 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. -# - - -# Script which tries to ping "home" to see if Internet connectivity is -# available. -############################################################################# - -rm ${TMPDIR}/.testftp >/dev/null 2>/dev/null - -ping -c 2 www.pcbsd.org >/dev/null 2>/dev/null -if [ "$?" = "0" ] -then - echo "ftp: Up" - exit 0 -fi - -ping6 -c 2 www.pcbsd.org >/dev/null 2>/dev/null -if [ "$?" = "0" ] -then - echo "ftp: Up" - exit 0 -fi - -ping -c 2 www.freebsd.org >/dev/null 2>/dev/null -if [ "$?" = "0" ] -then - echo "ftp: Up" - exit 0 -fi - -ping6 -c 2 www.freebsd.org >/dev/null 2>/dev/null -if [ "$?" = "0" ] -then - echo "ftp: Up" - exit 0 -fi - -echo "ftp: Down" -exit 1 diff --git a/usr.sbin/pc-sysinstall/backend-query/update-part-list.sh b/usr.sbin/pc-sysinstall/backend-query/update-part-list.sh deleted file mode 100755 index 18cc7621924..00000000000 --- a/usr.sbin/pc-sysinstall/backend-query/update-part-list.sh +++ /dev/null @@ -1,100 +0,0 @@ -#!/bin/sh -#- -# SPDX-License-Identifier: BSD-2-Clause-FreeBSD -# -# Copyright (c) 2010 iXsystems, Inc. All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions -# are met: -# 1. Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# 2. Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# -# THIS SOFTWARE IS PROVIDED BY 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. -# - -# Need access to a some unmount functions -. ${PROGDIR}/backend/functions-unmount.sh - -echo "Running: find-update-parts" >> ${LOGOUT} - -rm ${TMPDIR}/AvailUpgrades >/dev/null 2>/dev/null - -FSMNT="/mnt" - -# Get the freebsd version on this partition -get_fbsd_ver() -{ - sFiles="/bin/sh /boot/kernel/kernel" - for file in $sFiles - do - if [ ! -e "${FSMNT}/$file" ] ; then continue ; fi - - VER="`file ${FSMNT}/$file | grep 'for FreeBSD' | sed 's|for FreeBSD |;|g' | cut -d ';' -f 2 | cut -d ',' -f 1`" - if [ "$?" = "0" ] ; then - file ${FSMNT}/$file | grep '32-bit' >/dev/null 2>/dev/null - if [ "${?}" = "0" ] ; then - echo "${1}: FreeBSD ${VER} (32bit)" - else - echo "${1}: FreeBSD ${VER} (64bit)" - fi - fi - break - done - -} - -# Create our device listing -SYSDISK="`sysctl kern.disks | cut -d ':' -f 2 | sed 's/^[ \t]*//'`" -DEVS="" - -# Now loop through these devices, and list the disk drives -for i in ${SYSDISK} -do - - # Get the current device - DEV="${i}" - # Make sure we don't find any cd devices - echo "${DEV}" | grep -e "^acd[0-9]" -e "^cd[0-9]" -e "^scd[0-9]" >/dev/null 2>/dev/null - if [ "$?" != "0" ] ; then - DEVS="${DEVS} `ls /dev/${i}*`" - fi - -done - -# Search for regular UFS / Geom Partitions to upgrade -for i in $DEVS -do - if [ ! -e "${i}a.journal" -a ! -e "${i}a" -a ! -e "${i}p2" -a ! -e "${i}p2.journal" ] ; then - continue - fi - - if [ -e "${i}a.journal" ] ; then - _dsk="${i}a.journal" - elif [ -e "${i}a" ] ; then - _dsk="${i}a" - elif [ -e "${i}p2" ] ; then - _dsk="${i}p2" - elif [ -e "${i}p2.journal" ] ; then - _dsk="${i}p2.journal" - fi - - mount -o ro ${_dsk} ${FSMNT} >>${LOGOUT} 2>>${LOGOUT} - if [ $? -eq 0 ] ; then - get_fbsd_ver "`echo ${_dsk} | sed 's|/dev/||g'`" - umount -f ${FSMNT} >/dev/null 2>/dev/null - fi -done diff --git a/usr.sbin/pc-sysinstall/backend-query/xkeyboard-layouts.sh b/usr.sbin/pc-sysinstall/backend-query/xkeyboard-layouts.sh deleted file mode 100755 index 7e25903da19..00000000000 --- a/usr.sbin/pc-sysinstall/backend-query/xkeyboard-layouts.sh +++ /dev/null @@ -1,68 +0,0 @@ -#!/bin/sh -#- -# SPDX-License-Identifier: BSD-2-Clause-FreeBSD -# -# Copyright (c) 2010 iXsystems, Inc. All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions -# are met: -# 1. Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# 2. Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# -# THIS SOFTWARE IS PROVIDED BY 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. -# - -FOUND="0" -TMPLIST="/tmp/.xkeyList.$$" -XLST="/usr/local/share/X11/xkb/rules/xorg.lst" - -if [ ! -e "${XLST}" ] ; then - exit 1 -fi - -# Lets parse the xorg.list file, and see what layouts are supported -while read line -do - - if [ "$FOUND" = "1" -a ! -z "$line" ] - then - echo $line | grep '! ' >/dev/null 2>/dev/null - if [ "$?" = "0" ] - then - break - else - echo "$line" >> ${TMPLIST} - fi - fi - - if [ "${FOUND}" = "0" ] - then - echo $line | grep '! layout' >/dev/null 2>/dev/null - if [ "$?" = "0" ] - then - FOUND="1" - fi - fi - -done < $XLST - -sort -b -d +1 $TMPLIST - -# Delete the tmp file -rm $TMPLIST - -exit 0 diff --git a/usr.sbin/pc-sysinstall/backend-query/xkeyboard-models.sh b/usr.sbin/pc-sysinstall/backend-query/xkeyboard-models.sh deleted file mode 100755 index 6e815fd7903..00000000000 --- a/usr.sbin/pc-sysinstall/backend-query/xkeyboard-models.sh +++ /dev/null @@ -1,59 +0,0 @@ -#!/bin/sh -#- -# SPDX-License-Identifier: BSD-2-Clause-FreeBSD -# -# Copyright (c) 2010 iXsystems, Inc. All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions -# are met: -# 1. Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# 2. Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# -# THIS SOFTWARE IS PROVIDED BY 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. -# - -FOUND="0" - -# Lets parse the xorg.list file, and see what models are supported -while read line -do - - if [ "$FOUND" = "1" -a ! -z "$line" ] - then - echo $line | grep '! ' >/dev/null 2>/dev/null - if [ "$?" = "0" ] - then - exit 0 - else - model="`echo $line | sed 's|(|[|g'`" - model="`echo $model | sed 's|)|]|g'`" - echo "$model" - fi - fi - - if [ "${FOUND}" = "0" ] - then - echo $line | grep '! model' >/dev/null 2>/dev/null - if [ "$?" = "0" ] - then - FOUND="1" - fi - fi - -done < /usr/local/share/X11/xkb/rules/xorg.lst - -exit 0 diff --git a/usr.sbin/pc-sysinstall/backend-query/xkeyboard-variants.sh b/usr.sbin/pc-sysinstall/backend-query/xkeyboard-variants.sh deleted file mode 100755 index 6b836419f94..00000000000 --- a/usr.sbin/pc-sysinstall/backend-query/xkeyboard-variants.sh +++ /dev/null @@ -1,57 +0,0 @@ -#!/bin/sh -#- -# SPDX-License-Identifier: BSD-2-Clause-FreeBSD -# -# Copyright (c) 2010 iXsystems, Inc. All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions -# are met: -# 1. Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# 2. Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# -# THIS SOFTWARE IS PROVIDED BY 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. -# - -FOUND="0" - -# Lets parse the xorg.list file, and see what varients are supported -while read line -do - - if [ "$FOUND" = "1" -a ! -z "$line" ] - then - echo $line | grep '! ' >/dev/null 2>/dev/null - if [ "$?" = "0" ] - then - exit 0 - else - echo "$line" - fi - fi - - if [ "${FOUND}" = "0" ] - then - echo $line | grep '! variant' >/dev/null 2>/dev/null - if [ "$?" = "0" ] - then - FOUND="1" - fi - fi - -done < /usr/local/share/X11/xkb/rules/xorg.lst - -exit 0 diff --git a/usr.sbin/pc-sysinstall/backend/Makefile b/usr.sbin/pc-sysinstall/backend/Makefile deleted file mode 100644 index 3be14ef4693..00000000000 --- a/usr.sbin/pc-sysinstall/backend/Makefile +++ /dev/null @@ -1,14 +0,0 @@ -# $FreeBSD: stable/11/usr.sbin/pc-sysinstall/backend/Makefile 284255 2015-06-11 04:22:17Z sjg $ - -FILES= functions-bsdlabel.sh functions-cleanup.sh functions-disk.sh \ - functions-extractimage.sh functions-ftp.sh functions-installcomponents.sh \ - functions-installpackages.sh functions-localize.sh functions-mountdisk.sh \ - functions-mountoptical.sh functions-networking.sh \ - functions-newfs.sh functions-packages.sh functions-parse.sh \ - functions-runcommands.sh functions-unmount.sh \ - functions-upgrade.sh functions-users.sh \ - functions.sh parseconfig.sh startautoinstall.sh installimage.sh -FILESMODE= ${BINMODE} -FILESDIR=${SHAREDIR}/pc-sysinstall/backend - -.include diff --git a/usr.sbin/pc-sysinstall/backend/Makefile.depend b/usr.sbin/pc-sysinstall/backend/Makefile.depend deleted file mode 100644 index f8a505cf0d4..00000000000 --- a/usr.sbin/pc-sysinstall/backend/Makefile.depend +++ /dev/null @@ -1,11 +0,0 @@ -# $FreeBSD: stable/11/usr.sbin/pc-sysinstall/backend/Makefile.depend 284345 2015-06-13 19:20:56Z sjg $ -# Autogenerated - do NOT edit! - -DIRDEPS = \ - - -.include - -.if ${DEP_RELDIR} == ${_DEP_RELDIR} -# local dependencies - needed for -jN in clean tree -.endif diff --git a/usr.sbin/pc-sysinstall/backend/functions-bsdlabel.sh b/usr.sbin/pc-sysinstall/backend/functions-bsdlabel.sh deleted file mode 100755 index f0e1601bbf4..00000000000 --- a/usr.sbin/pc-sysinstall/backend/functions-bsdlabel.sh +++ /dev/null @@ -1,783 +0,0 @@ -#!/bin/sh -#- -# SPDX-License-Identifier: BSD-2-Clause-FreeBSD -# -# Copyright (c) 2010 iXsystems, Inc. All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions -# are met: -# 1. Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# 2. Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# -# THIS SOFTWARE IS PROVIDED BY 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. -# - -# Functions related to disk operations using bsdlabel - -# Check if we are are provided a geli password on the nextline of the config -check_for_enc_pass() -{ - CURLINE="${1}" - - get_next_cfg_line "${CFGF}" "${CURLINE}" - echo ${VAL} | grep -q "^encpass=" 2>/dev/null - if [ $? -eq 0 ] ; then - # Found a password, return it - get_value_from_string "${VAL}" - return - fi - - export VAL="" - return -}; - -# On check on the disk-label line if we have any extra vars for this device -get_fs_line_xvars() -{ - ACTIVEDEV="${1}" - LINE="${2}" - - echo $LINE | cut -d ' ' -f 4 | grep -q '(' 2>/dev/null - if [ $? -ne 0 ] ; then return ; fi - - # See if we are looking for ZFS specific options - echo $LINE | grep -q '^ZFS' 2>/dev/null - if [ $? -eq 0 ] ; then - ZTYPE="NONE" - ZFSVARS="`echo $LINE | cut -d ' ' -f 4-20 |cut -d '(' -f 2- | cut -d ')' -f 1 | xargs`" - - echo $ZFSVARS | grep -qE "^(disk|file|mirror|raidz(1|2|3)?|spare|log|cache):" 2>/dev/null - if [ $? -eq 0 ] ; then - ZTYPE=`echo $ZFSVARS | cut -f1 -d:` - tmpVars=`echo $ZFSVARS | sed "s|$ZTYPE: ||g" | sed "s|$ZTYPE:||g"` - ZFSVARS="" - # make sure we have a '/dev' in front of the extra devices - for i in $tmpVars - do - echo $i | grep -q '/dev/' - if [ $? -ne 0 ] ; then - ZFSVARS="$ZFSVARS /dev/${i}" - else - ZFSVARS="$ZFSVARS $i" - fi - done - fi - - # Return the ZFS options - if [ "${ZTYPE}" = "NONE" ] ; then - VAR="${ACTIVEDEV} ${ZFSVARS}" - else - VAR="${ZTYPE} ${ACTIVEDEV} ${ZFSVARS}" - fi - export VAR - return - fi # End of ZFS block - - # See if we are looking for UFS specific newfs options - echo $LINE | grep -q '^UFS' 2>/dev/null - if [ $? -eq 0 ] ; then - FSVARS="`echo $LINE | cut -d '(' -f 2- | cut -d ')' -f 1 | xargs`" - VAR="${FSVARS}" - export VAR - return - fi - - # If we got here, set VAR to empty and export - export VAR="" - return -}; - -# Init each zfs mirror disk with a boot sector so we can failover -setup_zfs_mirror_parts() -{ - _nZFS="" - - ZTYPE="`echo ${1} | awk '{print $1}'`" - - # Using mirroring, setup boot partitions on each disk - _mirrline="`echo ${1} | sed 's|mirror ||g' | sed 's|raidz1 ||g' | sed 's|raidz2 ||g' | sed 's|raidz3 ||g' | sed 's|raidz ||g'`" - for _zvars in $_mirrline - do - echo "Looping through _zvars: $_zvars" >>${LOGOUT} - echo "$_zvars" | grep -q "${2}" 2>/dev/null - if [ $? -eq 0 ] ; then continue ; fi - if [ -z "$_zvars" ] ; then continue ; fi - - is_disk "$_zvars" >/dev/null 2>/dev/null - if [ $? -eq 0 ] ; then - echo "Setting up ZFS disk $_zvars" >>${LOGOUT} - init_gpt_full_disk "$_zvars" >/dev/null 2>/dev/null - rc_halt "gpart add -a 4k -t freebsd-zfs ${_zvars}" >/dev/null 2>/dev/null - rc_halt "gpart bootcode -b /boot/pmbr -p /boot/gptzfsboot -i 1 ${_zvars}" >/dev/null 2>/dev/null - _nZFS="$_nZFS ${_zvars}p2" - else - _nZFS="$_nZFS ${_zvars}" - fi - done - echo "$ZTYPE $2 `echo $_nZFS | tr -s ' '`" -} ; - -# Function which creates a unique label name for the specified mount -gen_glabel_name() -{ - MOUNT="$1" - TYPE="$2" - NUM="0" - MAXNUM="20" - - if [ "$TYPE" = "ZFS" ] ; then - NAME="zpool" - elif [ "$MOUNT" = "/" ] ; then - NAME="rootfs" - else - # If doing a swap partition, also rename it - if [ "${TYPE}" = "SWAP" ] - then - NAME="swap" - else - NAME="`echo $MOUNT | sed 's|/||g' | sed 's| ||g'`" - fi - fi - - # Loop through and break when we find our first available label - while - Z=1 - do - glabel status | grep -q "${NAME}${NUM}" 2>/dev/null - if [ $? -ne 0 ] - then - break - else - NUM=$((NUM+1)) - fi - - if [ $NUM -gt $MAXNUM ] - then - exit_err "Cannot allocate additional glabel name for $NAME" - break - fi - done - - - export VAL="${NAME}${NUM}" -}; - -# Function to determine the size we can safely use when 0 is specified -get_autosize() -{ - # Disk tag to look for - dTag="$1" - - # Total MB Avail - get_disk_mediasize_mb "$2" - local _aSize=$VAL - - while read line - do - # Check for data on this slice - echo $line | grep -q "^${_dTag}-part=" 2>/dev/null - if [ $? -ne 0 ] ; then continue ; fi - - get_value_from_string "${line}" - STRING="$VAL" - - # Get the size of this partition - SIZE=`echo $STRING | tr -s '\t' ' ' | cut -d ' ' -f 2` - if [ $SIZE -eq 0 ] ; then continue ; fi - _aSize=`expr $_aSize - $SIZE` - done <${CFGF} - - # Pad the size a bit - _aSize=`expr $_aSize - 2` - - VAL="$_aSize" - export VAL -}; - -# Function to setup partitions using gpart -setup_gpart_partitions() -{ - local _dTag="$1" - local _pDisk="$2" - local _wSlice="$3" - local _sNum="$4" - local _pType="$5" - FOUNDPARTS="1" - USEDAUTOSIZE=0 - - # Lets read in the config file now and setup our partitions - if [ "${_pType}" = "gpt" ] ; then - CURPART="2" - elif [ "${_pType}" = "apm" ] ; then - CURPART="3" - else - PARTLETTER="a" - CURPART="1" - if [ "${_pType}" = "mbr" ] ; then - rc_halt "gpart create -s BSD ${_wSlice}" - fi - fi - - while read line - do - # Check for data on this slice - echo $line | grep -q "^${_dTag}-part=" 2>/dev/null - if [ $? -eq 0 ] - then - FOUNDPARTS="0" - # Found a slice- entry, lets get the slice info - get_value_from_string "${line}" - STRING="$VAL" - - # We need to split up the string now, and pick out the variables - FS=`echo $STRING | tr -s '\t' ' ' | cut -d ' ' -f 1` - SIZE=`echo $STRING | tr -s '\t' ' ' | cut -d ' ' -f 2` - MNT=`echo $STRING | tr -s '\t' ' ' | cut -d ' ' -f 3` - - # Check if we have a .eli extension on this FS - echo ${FS} | grep -q ".eli" 2>/dev/null - if [ $? -eq 0 ] - then - FS="`echo ${FS} | cut -d '.' -f 1`" - ENC="ON" - check_for_enc_pass "${line}" - if [ "${VAL}" != "" ] ; then - # We have a user supplied password, save it for later - ENCPASS="${VAL}" - fi - else - ENC="OFF" - fi - - # Check if the user tried to setup / as an encrypted partition - check_for_mount "${MNT}" "/" - if [ $? -eq 0 -a "${ENC}" = "ON" ] - then - export USINGENCROOT="0" - fi - - # Now check that these values are sane - case $FS in - UFS|UFS+S|UFS+J|UFS+SUJ|ZFS|SWAP) ;; - *) exit_err "ERROR: Invalid file system specified on $line" ;; - esac - - # Check that we have a valid size number - expr $SIZE + 1 >/dev/null 2>/dev/null - if [ $? -ne 0 ]; then - exit_err "ERROR: The size specified on $line is invalid" - fi - - # Check that the mount-point starts with / - echo "$MNT" | grep -qe "^/" -e "^none" 2>/dev/null - if [ $? -ne 0 ]; then - exit_err "ERROR: The mount-point specified on $line is invalid" - fi - - if [ "$SIZE" = "0" ] - then - if [ $USEDAUTOSIZE -eq 1 ] ; then - exit_err "ERROR: You can not have two partitions with a size of 0 specified!" - fi - case ${_pType} in - gpt|apm) get_autosize "${_dTag}" "$_pDisk" ;; - *) get_autosize "${_dTag}" "$_wSlice" ;; - esac - SOUT="-s ${VAL}M" - USEDAUTOSIZE=1 - else - SOUT="-s ${SIZE}M" - fi - - # Check if we found a valid root partition - check_for_mount "${MNT}" "/" - if [ $? -eq 0 ] ; then - export FOUNDROOT="1" - if [ "${CURPART}" = "2" -a "$_pType" = "gpt" ] ; then - export FOUNDROOT="0" - fi - if [ "${CURPART}" = "3" -a "$_pType" = "apm" ] ; then - export FOUNDROOT="0" - fi - if [ "${CURPART}" = "1" -a "$_pType" = "mbr" ] ; then - export FOUNDROOT="0" - fi - if [ "${CURPART}" = "1" -a "$_pType" = "gptslice" ] ; then - export FOUNDROOT="0" - fi - fi - - check_for_mount "${MNT}" "/boot" - if [ $? -eq 0 ] ; then - export USINGBOOTPART="0" - if [ "${CURPART}" != "2" -a "${_pType}" = "gpt" ] ; then - exit_err "/boot partition must be first partition" - fi - if [ "${CURPART}" != "3" -a "${_pType}" = "apm" ] ; then - exit_err "/boot partition must be first partition" - fi - if [ "${CURPART}" != "1" -a "${_pType}" = "mbr" ] ; then - exit_err "/boot partition must be first partition" - fi - if [ "${CURPART}" != "1" -a "${_pType}" = "gptslice" ] ; then - exit_err "/boot partition must be first partition" - fi - - if [ "${FS}" != "UFS" -a "${FS}" != "UFS+S" -a "${FS}" != "UFS+J" -a "${FS}" != "UFS+SUJ" ] ; then - exit_err "/boot partition must be formatted with UFS" - fi - fi - - # Generate a unique label name for this mount - gen_glabel_name "${MNT}" "${FS}" - PLABEL="${VAL}" - - # Get any extra options for this fs / line - if [ "${_pType}" = "gpt" ] ; then - get_fs_line_xvars "${_pDisk}p${CURPART}" "${STRING}" - elif [ "${_pType}" = "apm" ] ; then - get_fs_line_xvars "${_pDisk}s${CURPART}" "${STRING}" - else - get_fs_line_xvars "${_wSlice}${PARTLETTER}" "${STRING}" - fi - XTRAOPTS="$VAR" - - # Check if using zfs mirror - echo ${XTRAOPTS} | grep -q -e "mirror" -e "raidz" - if [ $? -eq 0 -a "$FS" = "ZFS" ] ; then - if [ "${_pType}" = "gpt" -o "${_pType}" = "gptslice" ] ; then - XTRAOPTS=$(setup_zfs_mirror_parts "$XTRAOPTS" "${_pDisk}p${CURPART}") - elif [ "${_pType}" = "apm" ] ; then - XTRAOPTS=$(setup_zfs_mirror_parts "$XTRAOPTS" "${_pDisk}s${CURPART}") - else - XTRAOPTS=$(setup_zfs_mirror_parts "$XTRAOPTS" "${_wSlice}${PARTLETTER}") - fi - fi - - # Figure out the gpart type to use - case ${FS} in - ZFS) PARTYPE="freebsd-zfs" ;; - SWAP) PARTYPE="freebsd-swap" ;; - *) PARTYPE="freebsd-ufs" ;; - esac - - # Create the partition - if [ "${_pType}" = "gpt" ] ; then - if [ "$CURPART" = "2" ] ; then - # If this is GPT, make sure first partition is aligned to 4k - sleep 2 - rc_halt "gpart add -a 4k ${SOUT} -t ${PARTYPE} ${_pDisk}" - else - sleep 2 - rc_halt "gpart add ${SOUT} -t ${PARTYPE} ${_pDisk}" - fi - elif [ "${_pType}" = "gptslice" ]; then - sleep 2 - rc_halt "gpart add ${SOUT} -t ${PARTYPE} ${_wSlice}" - elif [ "${_pType}" = "apm" ]; then - sleep 2 - rc_halt "gpart add ${SOUT} -t ${PARTYPE} ${_pDisk}" - else - sleep 2 - rc_halt "gpart add ${SOUT} -t ${PARTYPE} -i ${CURPART} ${_wSlice}" - fi - - # Check if this is a root / boot partition, and stamp the right loader - for TESTMNT in `echo ${MNT} | sed 's|,| |g'` - do - if [ "${TESTMNT}" = "/" -a -z "${BOOTTYPE}" ] ; then - BOOTTYPE="${PARTYPE}" - fi - if [ "${TESTMNT}" = "/boot" ] ; then - BOOTTYPE="${PARTYPE}" - fi - done - - # Save this data to our partition config dir - if [ "${_pType}" = "gpt" ] ; then - _dFile="`echo $_pDisk | sed 's|/|-|g'`" - echo "${FS}#${MNT}#${ENC}#${PLABEL}#GPT#${XTRAOPTS}" >${PARTDIR}/${_dFile}p${CURPART} - - # Clear out any headers - sleep 2 - dd if=/dev/zero of=${_pDisk}p${CURPART} count=2048 2>/dev/null - - # If we have a enc password, save it as well - if [ -n "${ENCPASS}" ] ; then - echo "${ENCPASS}" >${PARTDIR}-enc/${_dFile}p${CURPART}-encpass - fi - elif [ "${_pType}" = "apm" ] ; then - _dFile="`echo $_pDisk | sed 's|/|-|g'`" - echo "${FS}#${MNT}#${ENC}#${PLABEL}#GPT#${XTRAOPTS}" >${PARTDIR}/${_dFile}s${CURPART} - - # Clear out any headers - sleep 2 - dd if=/dev/zero of=${_pDisk}s${CURPART} count=2048 2>/dev/null - - # If we have a enc password, save it as well - if [ -n "${ENCPASS}" ] ; then - echo "${ENCPASS}" >${PARTDIR}-enc/${_dFile}s${CURPART}-encpass - fi - else - # MBR Partition or GPT slice - _dFile="`echo $_wSlice | sed 's|/|-|g'`" - echo "${FS}#${MNT}#${ENC}#${PLABEL}#MBR#${XTRAOPTS}#${IMAGE}" >${PARTDIR}/${_dFile}${PARTLETTER} - # Clear out any headers - sleep 2 - dd if=/dev/zero of=${_wSlice}${PARTLETTER} count=2048 2>/dev/null - - # If we have a enc password, save it as well - if [ -n "${ENCPASS}" ] ; then - echo "${ENCPASS}" >${PARTDIR}-enc/${_dFile}${PARTLETTER}-encpass - fi - fi - - - # Increment our parts counter - if [ "$_pType" = "gpt" -o "$_pType" = "apm" ] ; then - CURPART=$((CURPART+1)) - # If this is a gpt/apm partition, - # we can continue and skip the MBR part letter stuff - continue - else - CURPART=$((CURPART+1)) - if [ "$CURPART" = "3" ] ; then CURPART="4" ; fi - fi - - - # This partition letter is used, get the next one - case ${PARTLETTER} in - a) PARTLETTER="b" ;; - b) PARTLETTER="d" ;; - d) PARTLETTER="e" ;; - e) PARTLETTER="f" ;; - f) PARTLETTER="g" ;; - g) PARTLETTER="h" ;; - h) PARTLETTER="ERR" ;; - *) exit_err "ERROR: bsdlabel only supports up to letter h for partitions." ;; - esac - - fi # End of subsection locating a slice in config - - echo $line | grep -q "^commitDiskLabel" 2>/dev/null - if [ $? -eq 0 -a "${FOUNDPARTS}" = "0" ] - then - - # If this is the boot disk, stamp the right gptboot - if [ ! -z "${BOOTTYPE}" -a "$_pType" = "gpt" ] ; then - case ${BOOTTYPE} in - freebsd-ufs) rc_halt "gpart bootcode -p /boot/gptboot -i 1 ${_pDisk}" ;; - freebsd-zfs) rc_halt "gpart bootcode -p /boot/gptzfsboot -i 1 ${_pDisk}" ;; - esac - fi - - # Make sure to stamp the MBR loader - if [ "$_pType" = "mbr" ] ; then - rc_halt "gpart bootcode -b /boot/boot ${_wSlice}" - fi - - # Found our flag to commit this label setup, check that we found at least 1 partition - if [ "${CURPART}" = "1" ] ; then - exit_err "ERROR: commitDiskLabel was called without any partition entries for it!" - fi - - break - fi - done <${CFGF} -}; - -# Reads through the config and sets up a BSDLabel for the given slice -populate_disk_label() -{ - if [ -z "${1}" ] - then - exit_err "ERROR: populate_disk_label() called without argument!" - fi - - # Set some vars from the given working slice - diskid="`echo $1 | cut -d ':' -f 1`" - disk="`echo $1 | cut -d ':' -f 1 | sed 's|-|/|g'`" - slicenum="`echo $1 | cut -d ':' -f 2`" - type="`echo $1 | cut -d ':' -f 3`" - - # Set WRKSLICE based upon format we are using - if [ "$type" = "mbr" ] ; then - wrkslice="${diskid}s${slicenum}" - fi - if [ "$type" = "apm" ] ; then - wrkslice="${diskid}s${slicenum}" - fi - if [ "$type" = "gpt" -o "$type" = "gptslice" ] ; then - wrkslice="${diskid}p${slicenum}" - fi - - if [ ! -e "${SLICECFGDIR}/${wrkslice}" ] ; then - exit_err "ERROR: Missing SLICETAG data. This shouldn't happen - please let the developers know" - fi - - disktag="`cat ${SLICECFGDIR}/${wrkslice}`" - slicedev="`echo $wrkslice | sed 's|-|/|g'`" - - # Setup the partitions with gpart - setup_gpart_partitions "${disktag}" "${disk}" "${slicedev}" "${slicenum}" "${type}" - -}; - -# Function which reads in the disk slice config, and performs it -setup_disk_label() -{ - # We are ready to start setting up the label, lets read the config and do the actions - # First confirm that we have a valid WORKINGSLICES - if [ -z "${WORKINGSLICES}" ]; then - exit_err "ERROR: No slices were setup! Please report this to the maintainers" - fi - - # Check that the slices we have did indeed get setup and gpart worked - for i in $WORKINGSLICES - do - disk="`echo $i | cut -d '-' -f 1`" - pnum="`echo $i | cut -d '-' -f 2`" - type="`echo $i | cut -d '-' -f 3`" - if [ "$type" = "mbr" -a ! -e "${disk}s${pnum}" ] ; then - exit_err "ERROR: The partition ${i} doesn't exist! gpart failure!" - fi - if [ "$type" = "gpt" -a ! -e "${disk}p${pnum}" ] ; then - exit_err "ERROR: The partition ${i} doesn't exist! gpart failure!" - fi - if [ "$type" = "apm" -a ! -e "${disk}s${pnum}" ] ; then - exit_err "ERROR: The partition ${i} doesn't exist! gpart failure!" - fi - if [ "$type" = "gptslice" -a ! -e "${disk}p${pnum}" ] ; then - exit_err "ERROR: The partition ${i} doesn't exist! gpart failure!" - fi - done - - # Setup some files which we'll be referring to - export LABELLIST="${TMPDIR}/workingLabels" - rm $LABELLIST >/dev/null 2>/dev/null - - # Set our flag to determine if we've got a valid root partition in this setup - export FOUNDROOT="-1" - - # Check if we are using a /boot partition - export USINGBOOTPART="1" - - # Set encryption on root check - export USINGENCROOT="1" - - # Make the tmp directory where we'll store FS info & mount-points - rm -rf ${PARTDIR} >/dev/null 2>/dev/null - mkdir -p ${PARTDIR} >/dev/null 2>/dev/null - rm -rf ${PARTDIR}-enc >/dev/null 2>/dev/null - mkdir -p ${PARTDIR}-enc >/dev/null 2>/dev/null - - for i in $WORKINGSLICES - do - populate_disk_label "${i}" - done - - # Check if we made a root partition - if [ "$FOUNDROOT" = "-1" ] - then - exit_err "ERROR: No root (/) partition specified!!" - fi - - # Check if we made a root partition - if [ "$FOUNDROOT" = "1" -a "${USINGBOOTPART}" != "0" ] - then - exit_err "ERROR: (/) partition isn't first partition on disk!" - fi - - if [ "${USINGENCROOT}" = "0" -a "${USINGBOOTPART}" != "0" ] - then - exit_err "ERROR: Can't encrypt (/) with no (/boot) partition!" - fi -}; - -check_fstab_mbr() -{ - local SLICE - local FSTAB - - if [ -z "$2" ] - then - return 1 - fi - - SLICE="$1" - FSTAB="$2/etc/fstab" - - if [ -f "${FSTAB}" ] - then - PARTLETTER=`echo "$SLICE" | sed -E 's|^.+([a-h])$|\1|'` - - cat "${FSTAB}" | awk '{ print $2 }' | grep -qE '^/$' 2>&1 - if [ $? -eq 0 ] - then - if [ "${PARTLETTER}" = "a" ] - then - FOUNDROOT="0" - else - FOUNDROOT="1" - fi - - ROOTIMAGE="1" - - export FOUNDROOT - export ROOTIMAGE - fi - - cat "${FSTAB}" | awk '{ print $2 }' | grep -qE '^/boot$' 2>&1 - if [ $? -eq 0 ] - then - if [ "${PARTLETTER}" = "a" ] - then - USINGBOOTPART="0" - else - exit_err "/boot partition must be first partition" - fi - export USINGBOOTPART - fi - - return 0 - fi - - return 1 -}; - -check_fstab_gpt() -{ - local SLICE - local FSTAB - - if [ -z "$2" ] - then - return 1 - fi - - SLICE="$1" - FSTAB="$2/etc/fstab" - - if [ -f "${FSTAB}" ] - then - PARTNUMBER=`echo "${SLICE}" | sed -E 's|^.+p([0-9]*)$|\1|'` - - cat "${FSTAB}" | awk '{ print $2 }' | grep -qE '^/$' 2>&1 - if [ $? -eq 0 ] - then - if [ "${PARTNUMBER}" = "2" ] - then - FOUNDROOT="0" - else - FOUNDROOT="1" - fi - - ROOTIMAGE="1" - - export FOUNDROOT - export ROOTIMAGE - fi - - cat "${FSTAB}" | awk '{ print $2 }' | grep -qE '^/boot$' 2>&1 - if [ $? -eq 0 ] - then - if [ "${PARTNUMBER}" = "2" ] - then - USINGBOOTPART="0" - else - exit_err "/boot partition must be first partition" - fi - export USINGBOOTPART - fi - - return 0 - fi - - - return 1 -}; - -check_disk_layout() -{ - local SLICES - local TYPE - local DISK - local RES - local F - - DISK="$1" - TYPE="MBR" - - if [ -z "${DISK}" ] - then - return 1 - fi - - SLICES_MBR=`ls /dev/${DISK}s[1-4]*[a-h]* 2>/dev/null` - SLICES_GPT=`ls /dev/${DISK}p[0-9]* 2>/dev/null` - SLICES_SLICE=`ls /dev/${DISK}[a-h]* 2>/dev/null` - - if [ -n "${SLICES_MBR}" ] - then - SLICES="${SLICES_MBR}" - TYPE="MBR" - RES=0 - fi - if [ -n "${SLICES_GPT}" ] - then - SLICES="${SLICES_GPT}" - TYPE="GPT" - RES=0 - fi - if [ -n "${SLICES_SLICE}" ] - then - SLICES="${SLICES_SLICE}" - TYPE="MBR" - RES=0 - fi - - for slice in ${SLICES} - do - F=1 - mount ${slice} /mnt 2>/dev/null - if [ $? -ne 0 ] - then - continue - fi - - if [ "${TYPE}" = "MBR" ] - then - check_fstab_mbr "${slice}" "/mnt" - F="$?" - - elif [ "${TYPE}" = "GPT" ] - then - check_fstab_gpt "${slice}" "/mnt" - F="$?" - fi - - if [ ${F} -eq 0 ] - then - umount /mnt - break - fi - - umount /mnt - done - - return ${RES} -}; diff --git a/usr.sbin/pc-sysinstall/backend/functions-cleanup.sh b/usr.sbin/pc-sysinstall/backend/functions-cleanup.sh deleted file mode 100755 index 352308d43c0..00000000000 --- a/usr.sbin/pc-sysinstall/backend/functions-cleanup.sh +++ /dev/null @@ -1,412 +0,0 @@ -#!/bin/sh -#- -# SPDX-License-Identifier: BSD-2-Clause-FreeBSD -# -# Copyright (c) 2010 iXsystems, Inc. All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions -# are met: -# 1. Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# 2. Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# -# THIS SOFTWARE IS PROVIDED BY 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. -# - -# Functions which perform the final cleanup after an install - -# Finishes up with ZFS setup before unmounting -zfs_cleanup_unmount() -{ - # Loop through our FS and see if we have any ZFS partitions to cleanup - for PART in `ls ${PARTDIR}` - do - PARTDEV=`echo $PART | sed 's|-|/|g'` - PARTFS="`cat ${PARTDIR}/${PART} | cut -d '#' -f 1`" - PARTMNT="`cat ${PARTDIR}/${PART} | cut -d '#' -f 2`" - ZPOOLNAME=$(get_zpool_name "${PARTDEV}") - - if [ "$PARTFS" = "ZFS" ] - then - # Check if we have multiple zfs mounts specified - for ZMNT in `echo ${PARTMNT} | sed 's|,| |g'` - do - if [ "${ZMNT}" = "/" ] - then - # Make sure we haven't already added the zfs boot line when - # Creating a dedicated "/boot" partition - cat ${FSMNT}/boot/loader.conf 2>/dev/null | grep -q "vfs.root.mountfrom=" 2>/dev/null - if [ $? -ne 0 ] ; then - echo "vfs.root.mountfrom=\"zfs:${ZPOOLNAME}/ROOT/default\"" >> ${FSMNT}/boot/loader.conf - fi - export FOUNDZFSROOT="${ZPOOLNAME}" - fi - done - FOUNDZFS="1" - fi - done - - if [ -n "${FOUNDZFS}" ] - then - # Check if we need to add our ZFS flags to rc.conf, src.conf and loader.conf - cat ${FSMNT}/boot/loader.conf 2>/dev/null | grep -q 'zfs_load="YES"' 2>/dev/null - if [ $? -ne 0 ] - then - echo 'zfs_load="YES"' >>${FSMNT}/boot/loader.conf - fi - cat ${FSMNT}/etc/rc.conf 2>/dev/null | grep -q 'zfs_enable="YES"' 2>/dev/null - if [ $? -ne 0 ] - then - echo 'zfs_enable="YES"' >>${FSMNT}/etc/rc.conf - fi - - sleep 2 - # Copy over any ZFS cache data - cp /boot/zfs/* ${FSMNT}/boot/zfs/ - - # Copy the hostid so that our zfs cache works - cp /etc/hostid ${FSMNT}/etc/hostid - fi - - # Loop through our FS and see if we have any ZFS partitions to cleanup - for PART in `ls ${PARTDIR}` - do - PARTDEV=`echo $PART | sed 's|-|/|g'` - PARTFS="`cat ${PARTDIR}/${PART} | cut -d '#' -f 1`" - PARTMNT="`cat ${PARTDIR}/${PART} | cut -d '#' -f 2`" - PARTENC="`cat ${PARTDIR}/${PART} | cut -d '#' -f 3`" - ZPOOLNAME=$(get_zpool_name "${PARTDEV}") - - if [ "$PARTFS" = "ZFS" ] - then - - # Create a list of zpool names we can export - echo $ZPOOLEXPORTS | grep -q "$ZPOOLNAME " - if [ $? -ne 0 ] ; then - export ZPOOLEXPORTS="$ZPOOLNAME $ZPOOLEXPORTS" - fi - - # Check if we have multiple zfs mounts specified - for ZMNT in `echo ${PARTMNT} | sed 's|,| |g'` - do - ZMNT="`echo $ZMNT | cut -d '(' -f 1`" - PARTMNTREV="${ZMNT} ${PARTMNTREV}" - done - - for ZMNT in ${PARTMNTREV} - do - if [ "${ZMNT}" = "/" ] ; then continue ; fi - # Some ZFS like /swap aren't mounted, and dont need unmounting - mount | grep -q "${FSMNT}${ZMNT}" - if [ $? -eq 0 ] ; then - rc_halt "zfs unmount ${ZPOOLNAME}${ZMNT}" - rc_halt "zfs set mountpoint=${ZMNT} ${ZPOOLNAME}${ZMNT}" - fi - sleep 2 - done - fi - done - -}; - -# Function which performs the specific setup for using a /boot partition -setup_dedicated_boot_part() -{ - ROOTFS="${1}" - ROOTFSTYPE="${2}" - BOOTFS="${3}" - BOOTMNT="${4}" - - # Set the root mount in loader.conf - echo "vfs.root.mountfrom=\"${ROOTFSTYPE}:${ROOTFS}\"" >> ${FSMNT}/boot/loader.conf - rc_halt "mkdir -p ${FSMNT}/${BOOTMNT}/boot" - rc_halt "mv ${FSMNT}/boot/* ${FSMNT}${BOOTMNT}/boot/" - rc_halt "mv ${FSMNT}${BOOTMNT}/boot ${FSMNT}/boot/" - rc_halt "umount ${BOOTFS}" - rc_halt "mount ${BOOTFS} ${FSMNT}${BOOTMNT}" - rc_halt "rmdir ${FSMNT}/boot" - - # Strip the '/' from BOOTMNT before making symlink - BOOTMNTNS="`echo ${BOOTMNT} | sed 's|/||g'`" - rc_halt "chroot ${FSMNT} ln -s ${BOOTMNTNS}/boot /boot" - -}; - -# Function which creates the /etc/fstab for the installed system -setup_fstab() -{ - FSTAB="${FSMNT}/etc/fstab" - rm ${FSTAB} >/dev/null 2>/dev/null - - # Create the header - echo "# Device Mountpoint FStype Options Dump Pass" >> ${FSTAB} - - # Loop through the partitions, and start creating /etc/fstab - for PART in `ls ${PARTDIR}` - do - PARTDEV=`echo $PART | sed 's|-|/|g'` - PARTFS="`cat ${PARTDIR}/${PART} | cut -d '#' -f 1`" - PARTMNT="`cat ${PARTDIR}/${PART} | cut -d '#' -f 2`" - PARTENC="`cat ${PARTDIR}/${PART} | cut -d '#' -f 3`" - PARTLABEL="`cat ${PARTDIR}/${PART} | cut -d '#' -f 4`" - - # Unset EXT - EXT="" - - # Set mount options for file-systems - case $PARTFS in - UFS+J) MNTOPTS="rw,noatime,async" ;; - SWAP) MNTOPTS="sw" ;; - *) MNTOPTS="rw,noatime" ;; - esac - - - # Figure out if we are using a glabel, or the raw name for this entry - if [ -n "${PARTLABEL}" ] - then - DEVICE="label/${PARTLABEL}" - else - # Check if using encryption - if [ "${PARTENC}" = "ON" ] ; then - EXT=".eli" - fi - - if [ "${PARTFS}" = "UFS+J" ] ; then - EXT="${EXT}.journal" - fi - DEVICE="${PARTDEV}${EXT}" - fi - - - # Set our ROOTFSTYPE for loader.conf if necessary - check_for_mount "${PARTMNT}" "/" - if [ $? -eq 0 ] ; then - if [ "${PARTFS}" = "ZFS" ] ; then - ROOTFSTYPE="zfs" - ZPOOLNAME=$(get_zpool_name "${PARTDEV}") - ROOTFS="${ZPOOLNAME}/ROOT/default" - else - ROOTFS="${DEVICE}" - ROOTFSTYPE="ufs" - fi - fi - - # Only create non-zfs partitions - if [ "${PARTFS}" != "ZFS" ] - then - - # Make sure geom_journal is loaded - if [ "${PARTFS}" = "UFS+J" ] ; then - setup_gjournal - fi - - # Save the BOOTFS for call at the end - if [ "${PARTMNT}" = "/boot" ] ; then - BOOTFS="${PARTDEV}${EXT}" - BOOTMNT="${BOOT_PART_MOUNT}" - PARTMNT="${BOOTMNT}" - fi - - # Echo out the fstab entry now - if [ "${PARTFS}" = "SWAP" ] - then - echo "/dev/${DEVICE} none swap ${MNTOPTS} 0 0" >> ${FSTAB} - else - echo "/dev/${DEVICE} ${PARTMNT} ufs ${MNTOPTS} 1 1" >> ${FSTAB} - fi - - fi # End of ZFS Check - done - - # Setup some specific PC-BSD fstab options - if [ "$INSTALLTYPE" != "FreeBSD" ] - then - echo "procfs /proc procfs rw 0 0" >> ${FSTAB} - echo "linprocfs /compat/linux/proc linprocfs rw 0 0" >> ${FSTAB} - fi - - # If we have a dedicated /boot, run the post-install setup of it now - if [ ! -z "${BOOTMNT}" ] ; then - setup_dedicated_boot_part "${ROOTFS}" "${ROOTFSTYPE}" "${BOOTFS}" "${BOOTMNT}" - fi - -}; - -# Setup our disk mirroring with gmirror -setup_gmirror() -{ - cat ${FSMNT}/boot/loader.conf 2>/dev/null | grep -q 'geom_mirror_load="YES"' 2>/dev/null - if [ $? -ne 0 ] - then - echo 'geom_mirror_load="YES"' >>${FSMNT}/boot/loader.conf - fi - -}; - -# Function which saves geli keys and sets up loading of them at boot -setup_geli_loading() -{ - - # Make our keys dir - mkdir -p ${FSMNT}/boot/keys >/dev/null 2>/dev/null - - cd ${GELIKEYDIR} - for KEYFILE in `ls` - do - # Figure out the partition name based on keyfile name removing .key - PART="`echo ${KEYFILE} | cut -d '.' -f 1`" - PARTDEV="`echo ${PART} | sed 's|-|/|g'`" - PARTNAME="`echo ${PART} | sed 's|-dev-||g'`" - - rc_halt "geli configure -b ${PARTDEV}" - - # If no passphrase, setup key files - if [ ! -e "${PARTDIR}-enc/${PART}-encpass" ] ; then - echo "geli_${PARTNAME}_keyfile0_load=\"YES\"" >> ${FSMNT}/boot/loader.conf - echo "geli_${PARTNAME}_keyfile0_type=\"${PARTNAME}:geli_keyfile0\"" >> ${FSMNT}/boot/loader.conf - echo "geli_${PARTNAME}_keyfile0_name=\"/boot/keys/${PARTNAME}.key\"" >> ${FSMNT}/boot/loader.conf - - # Copy the key to the disk - rc_halt "cp ${GELIKEYDIR}/${KEYFILE} ${FSMNT}/boot/keys/${PARTNAME}.key" - fi - - done - - # Make sure we have geom_eli set to load at boot - cat ${FSMNT}/boot/loader.conf 2>/dev/null | grep -q 'geom_eli_load="YES"' 2>/dev/null - if [ $? -ne 0 ] - then - echo 'geom_eli_load="YES"' >>${FSMNT}/boot/loader.conf - fi - -}; - - -# Function to generate a random hostname if none was specified -gen_hostname() -{ - RAND="`jot -r 1 1 9000`" - - if [ "$INSTALLTYPE" = "FreeBSD" ] - then - VAL="freebsd-${RAND}" - else - VAL="pcbsd-${RAND}" - fi - - export VAL - -}; - -# Function which sets up the hostname for the system -setup_hostname() -{ - - get_value_from_cfg hostname - HOSTNAME="${VAL}" - - # If we don't have a hostname, make one up - if [ -z "${HOSTNAME}" ] - then - gen_hostname - HOSTNAME="${VAL}" - fi - - # Clean up any saved hostname - cat ${FSMNT}/etc/rc.conf | grep -v "hostname=" >${FSMNT}/etc/rc.conf.new - mv ${FSMNT}/etc/rc.conf.new ${FSMNT}/etc/rc.conf - - # Set the hostname now - echo_log "Setting hostname: ${HOSTNAME}" - echo "hostname=\"${HOSTNAME}\"" >> ${FSMNT}/etc/rc.conf - sed -i -e "s|my.domain|${HOSTNAME} ${HOSTNAME}|g" ${FSMNT}/etc/hosts - -}; - - -# Check and make sure geom_journal is enabled on the system -setup_gjournal() -{ - - # Make sure we have geom_journal set to load at boot - cat ${FSMNT}/boot/loader.conf 2>/dev/null | grep -q 'geom_journal_load="YES"' 2>/dev/null - if [ $? -ne 0 ] - then - echo 'geom_journal_load="YES"' >>${FSMNT}/boot/loader.conf - fi - -}; - -# Function which sets the root password from the install config -set_root_pw() -{ - # Get the plaintext string - get_value_from_cfg_with_spaces rootPass - local PW="${VAL}" - - # Get the encrypted string - get_value_from_cfg_with_spaces rootEncPass - local ENCPW="${VAL}" - - # If we don't have a root pass, return - if [ -z "${PW}" -a -z "${ENCPW}" ] ; then return 0 ; fi - - echo_log "Setting root password" - - # Check if setting plaintext password - if [ -n "${PW}" ] ; then - echo "${PW}" > ${FSMNT}/.rootpw - run_chroot_cmd "cat /.rootpw | pw usermod root -h 0" - rc_halt "rm ${FSMNT}/.rootpw" - fi - - # Check if setting encrypted password - if [ -n "${ENCPW}" ] ; then - echo "${ENCPW}" > ${FSMNT}/.rootpw - run_chroot_cmd "cat /.rootpw | pw usermod root -H 0" - rc_halt "rm ${FSMNT}/.rootpw" - fi - -}; - - -run_final_cleanup() -{ - # Check if we need to run any gmirror setup - ls ${MIRRORCFGDIR}/* >/dev/null 2>/dev/null - if [ $? -eq 0 ] - then - # Lets setup gmirror now - setup_gmirror - fi - - # Check if we need to save any geli keys - ls ${GELIKEYDIR}/* >/dev/null 2>/dev/null - if [ $? -eq 0 ] - then - # Lets setup geli loading - setup_geli_loading - fi - - # Set a hostname on the install system - setup_hostname - - # Set the root_pw if it is specified - set_root_pw - - # Generate the fstab for the installed system - setup_fstab -}; diff --git a/usr.sbin/pc-sysinstall/backend/functions-disk.sh b/usr.sbin/pc-sysinstall/backend/functions-disk.sh deleted file mode 100755 index 5a4980f5613..00000000000 --- a/usr.sbin/pc-sysinstall/backend/functions-disk.sh +++ /dev/null @@ -1,909 +0,0 @@ -#!/bin/sh -#- -# SPDX-License-Identifier: BSD-2-Clause-FreeBSD -# -# Copyright (c) 2010 iXsystems, Inc. All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions -# are met: -# 1. Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# 2. Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# -# THIS SOFTWARE IS PROVIDED BY 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. -# - -# Functions related to disk operations using gpart - -# See if device is a full disk or partition/slice -is_disk() -{ - for _dsk in `sysctl -n kern.disks` - do - [ "$_dsk" = "${1}" ] && return 0 - [ "/dev/$_dsk" = "${1}" ] && return 0 - done - - return 1 -} - -# Get a MBR partitions sysid -get_partition_sysid_mbr() -{ - INPART="0" - DISK="$1" - PARTNUM=`echo ${2} | sed "s|${DISK}s||g"` - fdisk ${DISK} >${TMPDIR}/disk-${DISK} 2>/dev/null - while read i - do - echo "$i" | grep -q "The data for partition" 2>/dev/null - if [ $? -eq 0 ] ; then - INPART="0" - PART="`echo ${i} | cut -d ' ' -f 5`" - if [ "$PART" = "$PARTNUM" ] ; then - INPART="1" - fi - fi - - # In the partition section - if [ "$INPART" = "1" ] ; then - echo "$i" | grep -q "^sysid" 2>/dev/null - if [ $? -eq 0 ] ; then - SYSID="`echo ${i} | tr -s '\t' ' ' | cut -d ' ' -f 2`" - break - fi - - fi - - done < ${TMPDIR}/disk-${DISK} - rm ${TMPDIR}/disk-${DISK} - - export VAL="${SYSID}" -}; - -# Get the partitions MBR label -get_partition_label_mbr() -{ - INPART="0" - DISK="$1" - PARTNUM=`echo ${2} | sed "s|${DISK}s||g"` - fdisk ${DISK} >${TMPDIR}/disk-${DISK} 2>/dev/null - while read i - do - echo "$i" | grep -q "The data for partition" 2>/dev/null - if [ $? -eq 0 ] ; then - INPART="0" - PART="`echo ${i} | cut -d ' ' -f 5`" - if [ "$PART" = "$PARTNUM" ] ; then - INPART="1" - fi - fi - - # In the partition section - if [ "$INPART" = "1" ] ; then - echo "$i" | grep -q "^sysid" 2>/dev/null - if [ $? -eq 0 ] ; then - LABEL="`echo ${i} | tr -s '\t' ' ' | cut -d ',' -f 2-10`" - break - fi - - fi - - done < ${TMPDIR}/disk-${DISK} - rm ${TMPDIR}/disk-${DISK} - - export VAL="${LABEL}" -}; - -# Get a GPT partitions label -get_partition_label_gpt() -{ - DISK="${1}" - PARTNUM=`echo ${2} | sed "s|${DISK}p||g"` - - gpart show ${DISK} >${TMPDIR}/disk-${DISK} - while read i - do - SLICE="`echo ${i} | grep -v ${DISK} | grep -v ' free ' |tr -s '\t' ' ' | cut -d ' ' -f 3`" - if [ "${SLICE}" = "${PARTNUM}" ] ; then - LABEL="`echo ${i} | grep -v ${DISK} | grep -v ' free ' |tr -s '\t' ' ' | cut -d ' ' -f 4`" - break - fi - done <${TMPDIR}/disk-${DISK} - rm ${TMPDIR}/disk-${DISK} - - export VAL="${LABEL}" -}; - -# Get a partitions startblock -get_partition_startblock() -{ - DISK="${1}" - PARTNUM=`echo ${2} | sed "s|${DISK}p||g" | sed "s|${DISK}s||g"` - - gpart show ${DISK} >${TMPDIR}/disk-${DISK} - while read i - do - SLICE="`echo ${i} | grep -v ${DISK} | grep -v ' free ' |tr -s '\t' ' ' | cut -d ' ' -f 3`" - if [ "$SLICE" = "${PARTNUM}" ] ; then - SB="`echo ${i} | grep -v ${DISK} | grep -v ' free ' |tr -s '\t' ' ' | cut -d ' ' -f 1`" - break - fi - done <${TMPDIR}/disk-${DISK} - rm ${TMPDIR}/disk-${DISK} - - export VAL="${SB}" -}; - -# Get a partitions blocksize -get_partition_blocksize() -{ - DISK="${1}" - PARTNUM=`echo ${2} | sed "s|${DISK}p||g" | sed "s|${DISK}s||g"` - - gpart show ${DISK} >${TMPDIR}/disk-${DISK} - while read i - do - SLICE="`echo ${i} | grep -v ${DISK} | grep -v ' free ' |tr -s '\t' ' ' | cut -d ' ' -f 3`" - if [ "$SLICE" = "${PARTNUM}" ] ; then - BS="`echo ${i} | grep -v ${DISK} | grep -v ' free ' |tr -s '\t' ' ' | cut -d ' ' -f 2`" - break - fi - done <${TMPDIR}/disk-${DISK} - rm ${TMPDIR}/disk-${DISK} - - export VAL="${BS}" -}; - -# Function which returns the partitions on a target disk -get_disk_partitions() -{ - gpart show ${1} >/dev/null 2>/dev/null - if [ $? -ne 0 ] ; then - export VAL="" - return - fi - - type=`gpart show ${1} | awk '/^=>/ { printf("%s",$5); }'` - - SLICES="`gpart show ${1} | grep -v ${1} | grep -v ' free ' |tr -s '\t' ' ' | cut -d ' ' -f 4 | sed '/^$/d'`" - for i in ${SLICES} - do - case $type in - MBR) name="${1}s${i}" ;; - GPT) name="${1}p${i}";; - *) name="${1}s${i}";; - esac - if [ -z "${RSLICES}" ] - then - RSLICES="${name}" - else - RSLICES="${RSLICES} ${name}" - fi - done - - export VAL="${RSLICES}" -}; - -# Function which returns a target disks cylinders -get_disk_cyl() -{ - cyl=`diskinfo -v ${1} | grep "# Cylinders" | tr -s ' ' | cut -f 2` - export VAL="${cyl}" -}; - -# Function which returns a target disks sectors -get_disk_sectors() -{ - sec=`diskinfo -v ${1} | grep "# Sectors" | tr -s ' ' | cut -f 2` - export VAL="${sec}" -}; - -# Function which returns a target disks heads -get_disk_heads() -{ - head=`diskinfo -v ${1} | grep "# Heads" | tr -s ' ' | cut -f 2` - export VAL="${head}" -}; - -# Function which returns a target disks mediasize in sectors -get_disk_mediasize() -{ - mediasize=`diskinfo -v ${1} | grep "# mediasize in sectors" | tr -s ' ' | cut -f 2` - export VAL="${mediasize}" -}; - -# Function which returns a target disks mediasize in megabytes -get_disk_mediasize_mb() -{ - mediasize=`diskinfo -v ${1} | grep "# mediasize in bytes" | tr -s ' ' | cut -f 2` - mediasize=`expr $mediasize / 1024` - mediasize=`expr $mediasize / 1024` - export VAL="${mediasize}" -}; - -# Function to delete all gparts before starting an install -delete_all_gpart() -{ - echo_log "Deleting all gparts" - local DISK="$1" - - # Check for any swaps to stop - for i in `swapctl -l | grep "$DISK" | awk '{print $1}'` - do - swapoff ${i} >/dev/null 2>/dev/null - done - - # Delete the gparts now - for i in `gpart show ${DISK} 2>/dev/null | tr -s ' ' | cut -d ' ' -f 4` - do - if [ "/dev/${i}" != "${DISK}" -a "${i}" != "-" ] ; then - rc_nohalt "gpart delete -i ${i} ${DISK}" - fi - done - - # Destroy the disk geom - rc_nohalt "gpart destroy ${DISK}" - - wipe_metadata "${DISK}" -}; - -# Function to export all zpools before starting an install -stop_all_zfs() -{ - if [ ! -c /dev/zfs ]; then - return; - fi - local DISK="`echo ${1} | sed 's|/dev/||g'`" - - # Export any zpools using this device so we can overwrite - for i in `zpool list -H -o name` - do - ztst=`zpool status ${i} | grep "ONLINE" | awk '{print $1}' | grep -q ${DISK}` - if [ "$ztst" = "$DISK" ] ; then - zpool export -f ${i} - fi - done -}; - -# Function which stops all gmirrors before doing any disk manipulation -stop_all_gmirror() -{ - if [ ! -d /dev/mirror ]; then - return; - fi - local DISK="`echo ${1} | sed 's|/dev/||g'`" - GPROV="`gmirror list | grep ". Name: mirror/" | cut -d '/' -f 2`" - for gprov in $GPROV - do - gmirror list | grep -q "Name: ${DISK}" 2>/dev/null - if [ $? -eq 0 ] - then - echo_log "Stopping mirror $gprov $DISK" - rc_nohalt "gmirror remove $gprov $DISK" - wipe_metadata "${DISK}" - fi - done -}; - -# Make sure we don't have any geli providers active on this disk -stop_all_geli() -{ - local _geld="`echo ${1} | sed 's|/dev/||g'`" - cd /dev - - for i in `ls ${_geld}*` - do - echo $i | grep -q '.eli' 2>/dev/null - if [ $? -eq 0 ] - then - echo_log "Detaching GELI on ${i}" - rc_halt "geli detach ${i}" - fi - done - -}; - -# Function which reads in the disk slice config, and performs it -setup_disk_slice() -{ - - # Cleanup any slice / mirror dirs - rm -rf ${SLICECFGDIR} >/dev/null 2>/dev/null - mkdir ${SLICECFGDIR} - rm -rf ${MIRRORCFGDIR} >/dev/null 2>/dev/null - mkdir ${MIRRORCFGDIR} - - # Start with disk0 and gm0 - disknum="0" - gmnum="0" - - # We are ready to start setting up the disks, lets read the config and do the actions - while read line - do - echo $line | grep -q "^disk${disknum}=" 2>/dev/null - if [ $? -eq 0 ] - then - - # Found a disk= entry, lets get the disk we are working on - get_value_from_string "${line}" - strip_white_space "$VAL" - DISK="$VAL" - - echo "${DISK}" | grep -q '^/dev/' - if [ $? -ne 0 ] ; then DISK="/dev/$DISK" ; fi - - # Before we go further, lets confirm this disk really exists - if [ ! -e "${DISK}" ] ; then - exit_err "ERROR: The disk ${DISK} does not exist!" - fi - - # Make sure we stop any gmirrors on this disk - stop_all_gmirror ${DISK} - - # Make sure we stop any geli stuff on this disk - stop_all_geli ${DISK} - - # Make sure we don't have any zpools loaded - stop_all_zfs ${DISK} - - fi - - # Lets look if this device will be mirrored on another disk - echo $line | grep -q "^mirror=" 2>/dev/null - if [ $? -eq 0 ] - then - - # Found a disk= entry, lets get the disk we are working on - get_value_from_string "${line}" - strip_white_space "$VAL" - MIRRORDISK="$VAL" - echo "${MIRRORDISK}" | grep -q '^/dev/' - if [ $? -ne 0 ] ; then MIRRORDISK="/dev/$MIRRORDISK" ; fi - - # Before we go further, lets confirm this disk really exists - if [ ! -e "${MIRRORDISK}" ] - then - exit_err "ERROR: The mirror disk ${MIRRORDISK} does not exist!" - fi - - # Make sure we stop any gmirrors on this mirror disk - stop_all_gmirror ${MIRRORDISK} - - # Make sure we stop any geli stuff on this mirror disk - stop_all_geli ${MIRRORDISK} - - # Make sure we don't have any zpools mirror loaded - stop_all_zfs ${MIRRORDISK} - - fi - - # Lets see if we have been given a mirror balance choice - echo $line | grep -q "^mirrorbal=" 2>/dev/null - if [ $? -eq 0 ] - then - - # Found a disk= entry, lets get the disk we are working on - get_value_from_string "${line}" - strip_white_space "$VAL" - MIRRORBAL="$VAL" - fi - - echo $line | grep -q "^partition=" 2>/dev/null - if [ $? -eq 0 ] - then - # Found a partition= entry, lets read / set it - get_value_from_string "${line}" - strip_white_space "$VAL" - PTYPE=`echo $VAL|tr A-Z a-z` - - # We are using free space, figure out the slice number - if [ "${PTYPE}" = "free" ] - then - # Lets figure out what number this slice will be - LASTSLICE="`gpart show ${DISK} \ - | grep -v ${DISK} \ - | grep -v ' free' \ - | tr -s '\t' ' ' \ - | cut -d ' ' -f 4 \ - | sed '/^$/d' \ - | tail -n 1`" - - if [ -z "${LASTSLICE}" ] - then - LASTSLICE="1" - else - LASTSLICE=$((LASTSLICE+1)) - fi - - if [ $LASTSLICE -gt 4 ] - then - exit_err "ERROR: BSD only supports primary partitions, and there are none available on $DISK" - fi - - fi - fi - - # Check if we have an image file defined - echo $line | grep -q "^image=" 2>/dev/null - if [ $? -eq 0 ] ; then - # Found an image= entry, lets read / set it - get_value_from_string "${line}" - strip_white_space "$VAL" - IMAGE="$VAL" - if [ ! -f "$IMAGE" ] ; then - exit_err "$IMAGE file does not exist" - fi - fi - - # Check if we have a partscheme specified - echo $line | grep -q "^partscheme=" 2>/dev/null - if [ $? -eq 0 ] ; then - # Found a partscheme= entry, lets read / set it - get_value_from_string "${line}" - strip_white_space "$VAL" - PSCHEME="$VAL" - if [ "$PSCHEME" != "GPT" -a "$PSCHEME" != "MBR" ] ; then - exit_err "Unknown partition scheme: $PSCHEME" - fi - fi - - echo $line | grep -q "^bootManager=" 2>/dev/null - if [ $? -eq 0 ] - then - # Found a bootManager= entry, lets read /set it - get_value_from_string "${line}" - strip_white_space "$VAL" - BMANAGER="$VAL" - fi - - echo $line | grep -q "^commitDiskPart" 2>/dev/null - if [ $? -eq 0 ] - then - # Found our flag to commit this disk setup / lets do sanity check and do it - if [ ! -z "${DISK}" -a ! -z "${PTYPE}" ] - then - # Make sure we are only installing ppc to full disk - if [ `uname -m` = "powerpc" -o `uname -m` = "powerpc64" ]; then - if [ "$PTYPE" != "all" ] ; then - exit_err "powerpc can only be installed to a full disk" - fi - fi - - case ${PTYPE} in - all) - # If we have a gmirror, lets set it up - if [ -n "$MIRRORDISK" ]; then - # Default to round-robin if the user didn't specify - if [ -z "$MIRRORBAL" ]; then MIRRORBAL="round-robin" ; fi - - _mFile=`echo $DISK | sed 's|/|%|g'` - echo "$MIRRORDISK:$MIRRORBAL:gm${gmnum}" >${MIRRORCFGDIR}/$_mFile - init_gmirror "$gmnum" "$MIRRORBAL" "$DISK" "$MIRRORDISK" - - # Reset DISK to the gmirror device - DISK="/dev/mirror/gm${gmnum}" - gmnum=$((gmknum+1)) - fi - - if [ "$PSCHEME" = "MBR" -o -z "$PSCHEME" ] ; then - PSCHEME="MBR" - tmpSLICE="${DISK}s1" - else - tmpSLICE="${DISK}p1" - fi - - if [ `uname -m` = "powerpc" -o `uname -m` = "powerpc64" ] - then - PSCHEME="APM" - tmpSLICE="${DISK}s1" - fi - - run_gpart_full "${DISK}" "${BMANAGER}" "${PSCHEME}" - ;; - - s1|s2|s3|s4) - tmpSLICE="${DISK}${PTYPE}" - # Get the number of the slice we are working on - s="`echo ${PTYPE} | awk '{print substr($0,length,1)}'`" - run_gpart_slice "${DISK}" "${BMANAGER}" "${s}" - ;; - - p1|p2|p3|p4|p5|p6|p7|p8|p9|p10|p11|p12|p13|p14|p15|p16|p17|p18|p19|p20) - tmpSLICE="${DISK}${PTYPE}" - # Get the number of the gpt partition we are working on - s="`echo ${PTYPE} | awk '{print substr($0,length,1)}'`" - run_gpart_gpt_part "${DISK}" "${BMANAGER}" "${s}" - ;; - - free) - tmpSLICE="${DISK}s${LASTSLICE}" - run_gpart_free "${DISK}" "${LASTSLICE}" "${BMANAGER}" - ;; - - image) - if [ -z "${IMAGE}" ] - then - exit_err "ERROR: partition type image specified with no image!" - fi - ;; - - *) exit_err "ERROR: Unknown PTYPE: $PTYPE" ;; - esac - - - if [ -n "${IMAGE}" ] - then - local DEST - - if [ -n "${tmpSLICE}" ] - then - DEST="${tmpSLICE}" - else - DEST="${DISK}" - fi - - write_image "${IMAGE}" "${DEST}" - check_disk_layout "${DEST}" - fi - - # Now save which disk this is, so we can parse it later during slice partition setup - if [ -z "${IMAGE}" ] - then - _sFile=`echo $tmpSLICE | sed 's|/|-|g'` - echo "disk${disknum}" >${SLICECFGDIR}/$_sFile - fi - - # Increment our disk counter to look for next disk and unset - unset BMANAGER PTYPE DISK MIRRORDISK MIRRORBAL PSCHEME IMAGE - disknum=$((disknum+1)) - else - exit_err "ERROR: commitDiskPart was called without procceding disk= and partition= entries!!!" - fi - fi - - done <${CFGF} - -}; - - -# Init the gmirror device -init_gmirror() -{ - local _mNum=$1 - local _mBal=$2 - local _mDisk=$3 - - # Create this mirror device - rc_halt "gmirror label -vb ${_mBal} gm${_mNum} ${_mDisk}" - - sleep 3 - -} - -# Stop all gjournals on disk / slice -stop_gjournal() -{ - _gdsk="`echo $1 | sed 's|/dev/||g'`" - # Check if we need to shutdown any journals on this drive - ls /dev/${_gdsk}*.journal >/dev/null 2>/dev/null - if [ $? -eq 0 ] - then - cd /dev - for i in `ls ${_gdsk}*.journal` - do - rawjournal="`echo ${i} | cut -d '.' -f 1`" - gjournal stop -f ${rawjournal} >>${LOGOUT} 2>>${LOGOUT} - gjournal clear ${rawjournal} >>${LOGOUT} 2>>${LOGOUT} - done - fi -} ; - - -# Function to wipe the potential metadata from a disk -wipe_metadata() -{ - echo_log "Wiping possible metadata on ${1}" - local SIZE="`diskinfo ${1} | awk '{print int($3/(1024*1024)) }'`" - if [ "$SIZE" -gt "5" ] ; then - rc_halt "dd if=/dev/zero of=${1} bs=1m count=1" - rc_nohalt "dd if=/dev/zero of=${1} bs=1m oseek=$((SIZE-4))" - else - rc_nohalt "dd if=/dev/zero of=${1} bs=128k" - fi -} ; - -# Function which runs gpart and creates a single large APM partition scheme -init_apm_full_disk() -{ - _intDISK=$1 - - # Set our sysctl so we can overwrite any geom using drives - sysctl kern.geom.debugflags=16 >>${LOGOUT} 2>>${LOGOUT} - - # Stop any journaling - stop_gjournal "${_intDISK}" - - # Remove any existing partitions - delete_all_gpart "${_intDISK}" - - sleep 2 - - echo_log "Running gpart on ${_intDISK}" - rc_halt "gpart create -s APM ${_intDISK}" - rc_halt "gpart add -s 800k -t freebsd-boot ${_intDISK}" - - echo_log "Stamping boot sector on ${_intDISK}" - rc_halt "gpart bootcode -p /boot/boot1.hfs -i 1 ${_intDISK}" - -} - -# Function which runs gpart and creates a single large GPT partition scheme -init_gpt_full_disk() -{ - _intDISK=$1 - - # Set our sysctl so we can overwrite any geom using drives - sysctl kern.geom.debugflags=16 >>${LOGOUT} 2>>${LOGOUT} - - # Stop any journaling - stop_gjournal "${_intDISK}" - - # Remove any existing partitions - delete_all_gpart "${_intDISK}" - - sleep 2 - - echo_log "Running gpart on ${_intDISK}" - rc_halt "gpart create -s GPT ${_intDISK}" - rc_halt "gpart add -b 34 -s 128 -t freebsd-boot ${_intDISK}" - - echo_log "Stamping boot sector on ${_intDISK}" - rc_halt "gpart bootcode -b /boot/pmbr ${_intDISK}" - -} - -# Function which runs gpart and creates a single large MBR partition scheme -init_mbr_full_disk() -{ - _intDISK=$1 - _intBOOT=$2 - - startblock="2016" - - # Set our sysctl so we can overwrite any geom using drives - sysctl kern.geom.debugflags=16 >>${LOGOUT} 2>>${LOGOUT} - - # Stop any journaling - stop_gjournal "${_intDISK}" - - # Remove any existing partitions - delete_all_gpart "${_intDISK}" - - sleep 2 - - echo_log "Running gpart on ${_intDISK}" - rc_halt "gpart create -s mbr -f active ${_intDISK}" - - # Install new partition setup - echo_log "Running gpart add on ${_intDISK}" - rc_halt "gpart add -a 4k -t freebsd -i 1 ${_intDISK}" - sleep 2 - - wipe_metadata "${_intDISK}s1" - - # Make the partition active - rc_halt "gpart set -a active -i 1 ${_intDISK}" - - if [ "$_intBOOT" = "bsd" ] ; then - echo_log "Stamping boot0 on ${_intDISK}" - rc_halt "gpart bootcode -b /boot/boot0 ${_intDISK}" - else - echo_log "Stamping boot1 on ${_intDISK}" - rc_halt "gpart bootcode -b /boot/boot1 ${_intDISK}" - fi - -} - -# Function which runs gpart and creates a single large slice -run_gpart_full() -{ - DISK=$1 - BOOT=$2 - SCHEME=$3 - - if [ "$SCHEME" = "APM" ] ; then - init_apm_full_disk "$DISK" - slice=`echo "${DISK}:1:apm" | sed 's|/|-|g'` - elif [ "$SCHEME" = "MBR" ] ; then - init_mbr_full_disk "$DISK" "$BOOT" - slice=`echo "${DISK}:1:mbr" | sed 's|/|-|g'` - else - init_gpt_full_disk "$DISK" - slice=`echo "${DISK}:1:gpt" | sed 's|/|-|g'` - fi - - # Lets save our slice, so we know what to look for in the config file later on - if [ -z "$WORKINGSLICES" ] - then - WORKINGSLICES="${slice}" - export WORKINGSLICES - else - WORKINGSLICES="${WORKINGSLICES} ${slice}" - export WORKINGSLICES - fi -}; - -# Function which runs gpart on a specified gpt partition -run_gpart_gpt_part() -{ - DISK=$1 - - # Set the slice we will use later - slice="${1}p${3}" - - # Set our sysctl so we can overwrite any geom using drives - sysctl kern.geom.debugflags=16 >>${LOGOUT} 2>>${LOGOUT} - - # Get the number of the slice we are working on - slicenum="$3" - - # Stop any journaling - stop_gjournal "${slice}" - - # Make sure we have disabled swap on this drive - if [ -e "${slice}b" ] - then - swapoff ${slice}b >/dev/null 2>/dev/null - swapoff ${slice}b.eli >/dev/null 2>/dev/null - fi - - # Modify partition type - echo_log "Running gpart modify on ${DISK}" - rc_halt "gpart modify -t freebsd -i ${slicenum} ${DISK}" - sleep 2 - - wipe_metadata "${slice}" - - sleep 4 - - # Init the MBR partition - rc_halt "gpart create -s BSD ${DISK}p${slicenum}" - - # Stamp the bootloader - sleep 4 - rc_halt "gpart bootcode -b /boot/boot ${DISK}p${slicenum}" - - # Set the slice to the format we'll be using for gpart later - slice=`echo "${1}:${3}:gptslice" | sed 's|/|-|g'` - - # Lets save our slice, so we know what to look for in the config file later on - if [ -z "$WORKINGSLICES" ] - then - WORKINGSLICES="${slice}" - export WORKINGSLICES - else - WORKINGSLICES="${WORKINGSLICES} ${slice}" - export WORKINGSLICES - fi -}; - -# Function which runs gpart on a specified s1-4 slice -run_gpart_slice() -{ - DISK=$1 - if [ -n "$2" ] - then - BMANAGER="$2" - fi - - # Set the slice we will use later - slice="${1}s${3}" - - # Set our sysctl so we can overwrite any geom using drives - sysctl kern.geom.debugflags=16 >>${LOGOUT} 2>>${LOGOUT} - - # Get the number of the slice we are working on - slicenum="$3" - - # Stop any journaling - stop_gjournal "${slice}" - - # Make sure we have disabled swap on this drive - if [ -e "${slice}b" ] - then - swapoff ${slice}b >/dev/null 2>/dev/null - swapoff ${slice}b.eli >/dev/null 2>/dev/null - fi - - # Modify partition type - echo_log "Running gpart modify on ${DISK}" - rc_halt "gpart modify -t freebsd -i ${slicenum} ${DISK}" - sleep 2 - - wipe_metadata "${slice}" - - sleep 1 - - if [ "${BMANAGER}" = "bsd" ] - then - echo_log "Stamping boot sector on ${DISK}" - rc_halt "gpart bootcode -b /boot/boot0 ${DISK}" - fi - - # Set the slice to the format we'll be using for gpart later - slice=`echo "${1}:${3}:mbr" | sed 's|/|-|g'` - - # Lets save our slice, so we know what to look for in the config file later on - if [ -z "$WORKINGSLICES" ] - then - WORKINGSLICES="${slice}" - export WORKINGSLICES - else - WORKINGSLICES="${WORKINGSLICES} ${slice}" - export WORKINGSLICES - fi -}; - -# Function which runs gpart and creates a new slice from free disk space -run_gpart_free() -{ - DISK=$1 - SLICENUM=$2 - if [ -n "$3" ] - then - BMANAGER="$3" - fi - - # Set our sysctl so we can overwrite any geom using drives - sysctl kern.geom.debugflags=16 >>${LOGOUT} 2>>${LOGOUT} - - slice="${DISK}s${SLICENUM}" - slicenum="${SLICENUM}" - - # Working on the first slice, make sure we have MBR setup - gpart show ${DISK} >/dev/null 2>/dev/null - if [ $? -ne 0 -a "$SLICENUM" = "1" ] ; then - echo_log "Initializing disk, no existing MBR setup" - rc_halt "gpart create -s mbr ${DISK}" - fi - - # Install new partition setup - echo_log "Running gpart on ${DISK}" - rc_halt "gpart add -a 4k -t freebsd -i ${slicenum} ${DISK}" - sleep 2 - - wipe_metadata "${slice}" - - sleep 1 - - if [ "${BMANAGER}" = "bsd" ] - then - echo_log "Stamping boot sector on ${DISK}" - rc_halt "gpart bootcode -b /boot/boot0 ${DISK}" - fi - - slice=`echo "${DISK}:${SLICENUM}:mbr" | sed 's|/|-|g'` - # Lets save our slice, so we know what to look for in the config file later on - if [ -z "$WORKINGSLICES" ] - then - WORKINGSLICES="${slice}" - export WORKINGSLICES - else - WORKINGSLICES="${WORKINGSLICES} ${slice}" - export WORKINGSLICES - fi -}; diff --git a/usr.sbin/pc-sysinstall/backend/functions-extractimage.sh b/usr.sbin/pc-sysinstall/backend/functions-extractimage.sh deleted file mode 100755 index 0e7064bd8a6..00000000000 --- a/usr.sbin/pc-sysinstall/backend/functions-extractimage.sh +++ /dev/null @@ -1,553 +0,0 @@ -#!/bin/sh -#- -# SPDX-License-Identifier: BSD-2-Clause-FreeBSD -# -# Copyright (c) 2010 iXsystems, Inc. All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions -# are met: -# 1. Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# 2. Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# -# THIS SOFTWARE IS PROVIDED BY 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. -# - -# Functions which perform the extraction / installation of system to disk - -. ${BACKEND}/functions-mountoptical.sh - -# Performs the extraction of data to disk from FreeBSD dist files -start_extract_dist() -{ - if [ -z "$1" ] ; then exit_err "Called dist extraction with no directory set!"; fi - if [ -z "$INSFILE" ]; then exit_err "Called extraction with no install file set!"; fi - local DDIR="$1" - - # Check if we are doing an upgrade, and if so use our exclude list - if [ "${INSTALLMODE}" = "upgrade" ]; then - TAROPTS="-X ${PROGDIR}/conf/exclude-from-upgrade" - else - TAROPTS="" - fi - - # Loop though and extract dist files - for di in $INSFILE - do - # Check the MANIFEST see if we have an archive size / count - if [ -e "${DDIR}/MANIFEST" ]; then - count=`grep "^${di}.txz" ${DDIR}/MANIFEST | awk '{print $3}'` - if [ ! -z "$count" ] ; then - echo "INSTALLCOUNT: $count" - fi - fi - echo_log "pc-sysinstall: Starting Extraction (${di})" - tar -xpv -C ${FSMNT} -f ${DDIR}/${di}.txz ${TAROPTS} >&1 2>&1 - if [ $? -ne 0 ]; then - exit_err "ERROR: Failed extracting the dist file: $di" - fi - done - - # Check if this was a FTP download and clean it up now - if [ "${INSTALLMEDIUM}" = "ftp" ]; then - echo_log "Cleaning up downloaded archives" - rm -rf ${DDIR} - fi - - echo_log "pc-sysinstall: Extraction Finished" -} - -# Performs the extraction of data to disk from a uzip or tar archive -start_extract_uzip_tar() -{ - if [ -z "$INSFILE" ]; then - exit_err "ERROR: Called extraction with no install file set!" - fi - - # Check if we have a .count file, and echo it out for a front-end to use in progress bars - if [ -e "${INSFILE}.count" ]; then - echo "INSTALLCOUNT: `cat ${INSFILE}.count`" - fi - - # Check if we are doing an upgrade, and if so use our exclude list - if [ "${INSTALLMODE}" = "upgrade" ]; then - TAROPTS="-X ${PROGDIR}/conf/exclude-from-upgrade" - else - TAROPTS="" - fi - - echo_log "pc-sysinstall: Starting Extraction" - - case ${PACKAGETYPE} in - uzip) - if ! kldstat -v | grep -q "geom_uzip" ; then - exit_err "Kernel module geom_uzip not loaded" - fi - - # Start by mounting the uzip image - MDDEVICE=`mdconfig -a -t vnode -o readonly -f ${INSFILE}` - mkdir -p ${FSMNT}.uzip - mount -r /dev/${MDDEVICE}.uzip ${FSMNT}.uzip - if [ $? -ne 0 ] - then - exit_err "ERROR: Failed mounting the ${INSFILE}" - fi - cd ${FSMNT}.uzip - - # Copy over all the files now! - tar cvf - . 2>/dev/null | tar -xpv -C ${FSMNT} ${TAROPTS} -f - 2>&1 | tee -a ${FSMNT}/.tar-extract.log - if [ $? -ne 0 ] - then - cd / - echo "TAR failure occurred:" >>${LOGOUT} - cat ${FSMNT}/.tar-extract.log | grep "tar:" >>${LOGOUT} - umount ${FSMNT}.uzip - mdconfig -d -u ${MDDEVICE} - exit_err "ERROR: Failed extracting the tar image" - fi - - # All finished, now lets umount and cleanup - cd / - umount ${FSMNT}.uzip - mdconfig -d -u ${MDDEVICE} - ;; - tar) - tar -xpv -C ${FSMNT} -f ${INSFILE} ${TAROPTS} >&1 2>&1 - if [ $? -ne 0 ]; then - exit_err "ERROR: Failed extracting the tar image" - fi - ;; - esac - - # Check if this was a FTP download and clean it up now - if [ "${INSTALLMEDIUM}" = "ftp" ] - then - echo_log "Cleaning up downloaded archive" - rm ${INSFILE} - rm ${INSFILE}.count >/dev/null 2>/dev/null - rm ${INSFILE}.md5 >/dev/null 2>/dev/null - fi - - echo_log "pc-sysinstall: Extraction Finished" - -}; - -# Performs the extraction of data to disk from a directory with split files -start_extract_split() -{ - if [ -z "${INSDIR}" ] - then - exit_err "ERROR: Called extraction with no install directory set!" - fi - - echo_log "pc-sysinstall: Starting Extraction" - - # Used by install.sh - DESTDIR="${FSMNT}" - export DESTDIR - - HERE=`pwd` - DIRS=`ls -d ${INSDIR}/*|grep -Ev '(uzip|kernels|src)'` - for dir in ${DIRS} - do - cd "${dir}" - if [ -f "install.sh" ] - then - echo_log "Extracting" `basename ${dir}` - echo "y" | sh install.sh >/dev/null - if [ $? -ne 0 ] - then - exit_err "ERROR: Failed extracting ${dir}" - fi - else - exit_err "ERROR: ${dir}/install.sh does not exist" - fi - done - cd "${HERE}" - - KERNELS=`ls -d ${INSDIR}/*|grep kernels` - cd "${KERNELS}" - if [ -f "install.sh" ] - then - echo_log "Extracting" `basename ${KERNELS}` - echo "y" | sh install.sh generic >/dev/null - if [ $? -ne 0 ] - then - exit_err "ERROR: Failed extracting ${KERNELS}" - fi - rm -rf "${FSMNT}/boot/kernel" - mv "${FSMNT}/boot/GENERIC" "${FSMNT}/boot/kernel" - else - exit_err "ERROR: ${KERNELS}/install.sh does not exist" - fi - cd "${HERE}" - - SOURCE=`ls -d ${INSDIR}/*|grep src` - cd "${SOURCE}" - if [ -f "install.sh" ] - then - echo_log "Extracting" `basename ${SOURCE}` - echo "y" | sh install.sh all >/dev/null - if [ $? -ne 0 ] - then - exit_err "ERROR: Failed extracting ${SOURCE}" - fi - else - exit_err "ERROR: ${SOURCE}/install.sh does not exist" - fi - cd "${HERE}" - - echo_log "pc-sysinstall: Extraction Finished" -}; - -# Function which will attempt to fetch the dist file(s) before we start -fetch_dist_file() -{ - get_value_from_cfg ftpPath - if [ -z "$VAL" ] - then - exit_err "ERROR: Install medium was set to ftp, but no ftpPath was provided!" - fi - - FTPPATH="${VAL}" - - # Check if we have a /usr partition to save the download - if [ -d "${FSMNT}/usr" ] - then - DLDIR="${FSMNT}/usr/.fetch.$$" - else - DLDIR="${FSMNT}/.fetch.$$" - fi - mkdir -p ${DLDIR} - - # Do the fetch of the dist archive(s) now - for di in $INSFILE - do - fetch_file "${FTPPATH}/${di}.txz" "${DLDIR}/${di}.txz" "1" - done - - # Check to see if there is a MANIFEST file for this install - fetch_file "${FTPPATH}/MANIFEST" "${DLDIR}/MANIFEST" "0" - - export DLDIR -}; - -# Function which will attempt to fetch the install file before we start -# the install -fetch_install_file() -{ - get_value_from_cfg ftpPath - if [ -z "$VAL" ] - then - exit_err "ERROR: Install medium was set to ftp, but no ftpPath was provided!" - fi - - FTPPATH="${VAL}" - - # Check if we have a /usr partition to save the download - if [ -d "${FSMNT}/usr" ] - then - OUTFILE="${FSMNT}/usr/.fetch-${INSFILE}" - else - OUTFILE="${FSMNT}/.fetch-${INSFILE}" - fi - - # Do the fetch of the archive now - fetch_file "${FTPPATH}/${INSFILE}" "${OUTFILE}" "1" - - # Check to see if there is a .count file for this install - fetch_file "${FTPPATH}/${INSFILE}.count" "${OUTFILE}.count" "0" - - # Check to see if there is a .md5 file for this install - fetch_file "${FTPPATH}/${INSFILE}.md5" "${OUTFILE}.md5" "0" - - # Done fetching, now reset the INSFILE to our downloaded archived - export INSFILE="${OUTFILE}" - -}; - -# Function which will download freebsd install files -fetch_split_files() -{ - get_ftpHost - if [ -z "$VAL" ] - then - exit_err "ERROR: Install medium was set to ftp, but no ftpHost was provided!" - fi - FTPHOST="${VAL}" - - get_ftpDir - if [ -z "$VAL" ] - then - exit_err "ERROR: Install medium was set to ftp, but no ftpDir was provided!" - fi - FTPDIR="${VAL}" - - # Check if we have a /usr partition to save the download - if [ -d "${FSMNT}/usr" ] - then - OUTFILE="${FSMNT}/usr/.fetch-${INSFILE}" - else - OUTFILE="${FSMNT}/.fetch-${INSFILE}" - fi - - DIRS="base catpages dict doc info manpages proflibs kernels src" - if [ "${FBSD_ARCH}" = "amd64" ] - then - DIRS="${DIRS} lib32" - fi - - for d in ${DIRS} - do - mkdir -p "${OUTFILE}/${d}" - done - - - NETRC="${OUTFILE}/.netrc" - cat <"${NETRC}" -machine ${FTPHOST} -login anonymous -password anonymous -macdef INSTALL -bin -prompt -EOF - - for d in ${DIRS} - do - cat <>"${NETRC}" -cd ${FTPDIR}/${d} -lcd ${OUTFILE}/${d} -mreget * -EOF - done - - cat <>"${NETRC}" -bye - - -EOF - - # Fetch the files via ftp - echo "$ INSTALL" | ftp -N "${NETRC}" "${FTPHOST}" - - # Done fetching, now reset the INSFILE to our downloaded archived - export INSFILE="${OUTFILE}" -} - -# Function which does the rsync download from the server specified in cfg -start_rsync_copy() -{ - # Load our rsync config values - get_value_from_cfg rsyncPath - if [ -z "${VAL}" ]; then - exit_err "ERROR: rsyncPath is unset! Please check your config and try again." - fi - export RSYNCPATH="${VAL}" - - get_value_from_cfg rsyncHost - if [ -z "${VAL}" ]; then - exit_err "ERROR: rsyncHost is unset! Please check your config and try again." - fi - export RSYNCHOST="${VAL}" - - get_value_from_cfg rsyncUser - if [ -z "${VAL}" ]; then - exit_err "ERROR: rsyncUser is unset! Please check your config and try again." - fi - export RSYNCUSER="${VAL}" - - get_value_from_cfg rsyncPort - if [ -z "${VAL}" ]; then - exit_err "ERROR: rsyncPort is unset! Please check your config and try again." - fi - export RSYNCPORT="${VAL}" - - COUNT=1 - while - z=1 - do - if [ ${COUNT} -gt ${RSYNCTRIES} ] - then - exit_err "ERROR: Failed rsync command!" - break - fi - - rsync -avvzHsR \ - --rsync-path="rsync --fake-super" \ - -e "ssh -p ${RSYNCPORT}" \ - ${RSYNCUSER}@${RSYNCHOST}:${RSYNCPATH}/./ ${FSMNT} - if [ $? -ne 0 ] - then - echo "Rsync failed! Tries: ${COUNT}" - else - break - fi - - COUNT=$((COUNT+1)) - done - -}; - -start_image_install() -{ - if [ -z "${IMAGE_FILE}" ] - then - exit_err "ERROR: installMedium set to image but no image file specified!" - fi - - # We are ready to start mounting, lets read the config and do it - while read line - do - echo $line | grep -q "^disk0=" 2>/dev/null - if [ $? -eq 0 ] - then - # Found a disk= entry, lets get the disk we are working on - get_value_from_string "${line}" - strip_white_space "$VAL" - DISK="$VAL" - fi - - echo $line | grep -q "^commitDiskPart" 2>/dev/null - if [ $? -eq 0 ] - then - # Found our flag to commit this disk setup / lets do sanity check and do it - if [ -n "${DISK}" ] - then - - # Write the image - write_image "${IMAGE_FILE}" "${DISK}" - - # Increment our disk counter to look for next disk and unset - unset DISK - break - - else - exit_err "ERROR: commitDiskPart was called without procceding disk= and partition= entries!!!" - fi - fi - - done <${CFGF} -}; - -# Entrance function, which starts the installation process -init_extraction() -{ - # Figure out what file we are using to install from via the config - get_value_from_cfg installFile - - if [ -n "${VAL}" ] - then - export INSFILE="${VAL}" - else - # If no installFile specified, try our defaults - if [ "$INSTALLTYPE" = "FreeBSD" ] - then - case $PACKAGETYPE in - uzip) INSFILE="${FBSD_UZIP_FILE}" ;; - tar) INSFILE="${FBSD_TAR_FILE}" ;; - dist) - get_value_from_cfg_with_spaces distFiles - if [ -z "$VAL" ] ; then - exit_err "No dist files specified!" - fi - INSFILE="${VAL}" - ;; - split) - INSDIR="${FBSD_BRANCH_DIR}" - - # This is to trick opt_mount into not failing - INSFILE="${INSDIR}" - ;; - esac - else - case $PACKAGETYPE in - uzip) INSFILE="${UZIP_FILE}" ;; - tar) INSFILE="${TAR_FILE}" ;; - dist) - get_value_from_cfg_with_spaces distFiles - if [ -z "$VAL" ] ; then - exit_err "No dist files specified!" - fi - INSFILE="${VAL}" - ;; - esac - fi - export INSFILE - fi - - # Lets start by figuring out what medium we are using - case ${INSTALLMEDIUM} in - dvd|usb) - # Lets start by mounting the disk - opt_mount - if [ -n "${INSDIR}" ] - then - INSDIR="${CDMNT}/${INSDIR}" ; export INSDIR - start_extract_split - - else - if [ "$PACKAGETYPE" = "dist" ] ; then - start_extract_dist "${CDMNT}/usr/freebsd-dist" - else - INSFILE="${CDMNT}/${INSFILE}" ; export INSFILE - start_extract_uzip_tar - fi - fi - ;; - - ftp) - case $PACKAGETYPE in - split) - fetch_split_files - - INSDIR="${INSFILE}" ; export INSDIR - start_extract_split - ;; - dist) - fetch_dist_file - start_extract_dist "$DLDIR" - ;; - *) - fetch_install_file - start_extract_uzip_tar - ;; - esac - ;; - - sftp) ;; - - rsync) start_rsync_copy ;; - image) start_image_install ;; - local) - get_value_from_cfg localPath - if [ -z "$VAL" ] - then - exit_err "Install medium was set to local, but no localPath was provided!" - fi - LOCALPATH=$VAL - if [ "$PACKAGETYPE" = "dist" ] ; then - INSFILE="${INSFILE}" ; export INSFILE - start_extract_dist "$LOCALPATH" - else - INSFILE="${LOCALPATH}/${INSFILE}" ; export INSFILE - start_extract_uzip_tar - fi - ;; - *) exit_err "ERROR: Unknown install medium" ;; - esac - -}; diff --git a/usr.sbin/pc-sysinstall/backend/functions-ftp.sh b/usr.sbin/pc-sysinstall/backend/functions-ftp.sh deleted file mode 100755 index 62a9c0a411e..00000000000 --- a/usr.sbin/pc-sysinstall/backend/functions-ftp.sh +++ /dev/null @@ -1,415 +0,0 @@ -#!/bin/sh -#- -# SPDX-License-Identifier: BSD-2-Clause-FreeBSD -# -# Copyright (c) 2010 iXsystems, Inc. All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions -# are met: -# 1. Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# 2. Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# -# THIS SOFTWARE IS PROVIDED BY 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. -# - -# Functions which runs commands on the system - -. ${BACKEND}/functions.sh -. ${BACKEND}/functions-parse.sh - -DEFAULT_FTP_SERVER="ftp.freebsd.org" - -MAIN_FTP_SERVERS="\ -Main Site: ftp.freebsd.org" - -IPV6_FTP_SERVERS="\ -IPv6 Main Site: ftp.freebsd.org|\ -IPv6 Ireland: ftp3.ie.freebsd.org|\ -IPv6 Israel: ftp.il.freebsd.org|\ -IPv6 Japan: ftp2.jp.freebsd.org|\ -IPv6 Sweden: ftp4.se.freebsd.org|\ -IPv6 USA: ftp4.us.freebsd.org|\ -IPv6 Turkey: ftp2.tr.freebsd.org" - -PRIMARY_FTP_SERVERS="\ -Primary: ftp1.freebsd.org|\ -Primary #2: ftp2.freebsd.org|\ -Primary #3: ftp3.freebsd.org|\ -Primary #4: ftp4.freebsd.org|\ -Primary #5: ftp5.freebsd.org|\ -Primary #6: ftp6.freebsd.org|\ -Primary #7: ftp7.freebsd.org|\ -Primary #8: ftp8.freebsd.org|\ -Primary #9: ftp9.freebsd.org|\ -Primary #10: ftp10.freebsd.org|\ -Primary #11: ftp11.freebsd.org|\ -Primary #12: ftp12.freebsd.org|\ -Primary #13: ftp13.freebsd.org|\ -Primary #14: ftp14.freebsd.org" - -ARGENTINA_FTP_SERVERS="\ -Argentina: ftp.ar.freebsd.org" - -AUSTRALIA_FTP_SERVERS="\ -Australia: ftp.au.freebsd.org|\ -Australia #2: ftp2.au.freebsd.org|\ -Australia #3: ftp3.au.freebsd.org" - -AUSTRIA_FTP_SERVERS="\ -Austria: ftp.at.freebsd.org|\ -Austria #2: ftp2.at.freebsd.org" - -BRAZIL_FTP_SERVERS="\ -Brazil: ftp.br.freebsd.org|\ -Brazil #2: ftp2.br.freebsd.org|\ -Brazil #3: ftp3.br.freebsd.org|\ -Brazil #4: ftp4.br.freebsd.org|\ -Brazil #5: ftp5.br.freebsd.org|\ -Brazil #6: ftp6.br.freebsd.org|\ -Brazil #7: ftp7.br.freebsd.org" - -CANADA_FTP_SERVERS="\ -Canada: ftp.ca.freebsd.org" - -CHINA_FTP_SERVERS="\ -China: ftp.cn.freebsd.org|\ -China #2: ftp2.cn.freebsd.org" - -CROATIA_FTP_SERVERS="\ -Croatia: ftp.hr.freebsd.org" - -CZECH_REPUBLIC_FTP_SERVERS="\ -Czech Republic: ftp.cz.freebsd.org" - -DENMARK_FTP_SERVERS="\ -Denmark: ftp.dk.freebsd.org|\ -Denmark #2: ftp2.dk.freebsd.org" - -ESTONIA_FTP_SERVERS="\ -Estonia: ftp.ee.freebsd.org" - -FINLAND_FTP_SERVERS="\ -Finland: ftp.fi.freebsd.org" - -FRANCE_FTP_SERVERS="\ -France: ftp.fr.freebsd.org|\ -France #2: ftp2.fr.freebsd.org|\ -France #3: ftp3.fr.freebsd.org|\ -France #5: ftp5.fr.freebsd.org|\ -France #6: ftp6.fr.freebsd.org|\ -France #8: ftp8.fr.freebsd.org" - -GERMANY_FTP_SERVERS="\ -Germany: ftp.de.freebsd.org|\ -Germany #2: ftp2.de.freebsd.org|\ -Germany #3: ftp3.de.freebsd.org|\ -Germany #4: ftp4.de.freebsd.org|\ -Germany #5: ftp5.de.freebsd.org|\ -Germany #6: ftp6.de.freebsd.org|\ -Germany #7: ftp7.de.freebsd.org|\ -Germany #8: ftp8.de.freebsd.org" - -GREECE_FTP_SERVERS="\ -Greece: ftp.gr.freebsd.org|\ -Greece #2: ftp2.gr.freebsd.org" - -HUNGARY_FTP_SERVERS="\ -Hungary: ftp.hu.freebsd.org" - -ICELAND_FTP_SERVERS="\ -Iceland: ftp.is.freebsd.org" - -IRELAND_FTP_SERVERS="\ -Ireland: ftp.ie.freebsd.org|\ -Ireland #2: ftp2.ie.freebsd.org|\ -Ireland #3: ftp3.ie.freebsd.org" - -ISRAEL_FTP_SERVERS="\ -Israel: ftp.il.freebsd.org" - -ITALY_FTP_SERVERS="\ -Italy: ftp.it.freebsd.org" - -JAPAN_FTP_SERVERS="\ -Japan: ftp.jp.freebsd.org|\ -Japan #2: ftp2.jp.freebsd.org|\ -Japan #3: ftp3.jp.freebsd.org|\ -Japan #4: ftp4.jp.freebsd.org|\ -Japan #5: ftp5.jp.freebsd.org|\ -Japan #6: ftp6.jp.freebsd.org|\ -Japan #7: ftp7.jp.freebsd.org|\ -Japan #8: ftp8.jp.freebsd.org|\ -Japan #9: ftp9.jp.freebsd.org" - -KOREA_FTP_SERVERS="\ -Korea: ftp.kr.freebsd.org|\ -Korea #2: ftp2.kr.freebsd.org" - -LITHUANIA_FTP_SERVERS="\ -Lithuania: ftp.lt.freebsd.org" - -NETHERLANDS_FTP_SERVERS="\ -Netherlands: ftp.nl.freebsd.org|\ -Netherlands #2: ftp2.nl.freebsd.org" - -NORWAY_FTP_SERVERS="\ -Norway: ftp.no.freebsd.org|\ -Norway #3: ftp3.no.freebsd.org" - -POLAND_FTP_SERVERS="\ -Poland: ftp.pl.freebsd.org|\ -Poland #2: ftp2.pl.freebsd.org|\ -Poland #5: ftp5.pl.freebsd.org" - -PORTUGAL_FTP_SERVERS="\ -Portugal: ftp.pt.freebsd.org|\ -Portugal #2: ftp2.pt.freebsd.org|\ -Portugal #4: ftp4.pt.freebsd.org" - -ROMANIA_FTP_SERVERS="\ -Romania: ftp.ro.freebsd.org" - -RUSSIA_FTP_SERVERS="\ -Russia: ftp.ru.freebsd.org|\ -Russia #2: ftp2.ru.freebsd.org|\ -Russia #3: ftp3.ru.freebsd.org|\ -Russia #4: ftp4.ru.freebsd.org" - -SINGAPORE_FTP_SERVERS="\ -Singapore: ftp.sg.freebsd.org" - -SLOVAK_REPUBLIC_FTP_SERVERS="\ -Slovak Republic: ftp.sk.freebsd.org" - -SLOVENIA_FTP_SERVERS="\ -Slovenia: ftp.si.freebsd.org|\ -Slovenia #2: ftp2.si.freebsd.org" - -SOUTH_AFRICA_FTP_SERVERS="\ -South Africa: ftp.za.freebsd.org|\ -South Africa #2: ftp2.za.freebsd.org|\ -South Africa #3: ftp3.za.freebsd.org|\ -South Africa #4: ftp4.za.freebsd.org" - -SPAIN_FTP_SERVERS="\ -Spain: ftp.es.freebsd.org|\ -Spain #2: ftp2.es.freebsd.org|\ -Spain #3: ftp3.es.freebsd.org" - -SWEDEN_FTP_SERVERS="\ -Sweden: ftp.se.freebsd.org|\ -Sweden #2: ftp2.se.freebsd.org|\ -Sweden #3: ftp3.se.freebsd.org|\ -Sweden #4: ftp4.se.freebsd.org|\ -Sweden #5: ftp5.se.freebsd.org" - -SWITZERLAND_FTP_SERVERS="\ -Switzerland: ftp.ch.freebsd.org|\ -Switzerland #2: ftp2.ch.freebsd.org" - -TAIWAN_FTP_SERVERS="\ -Taiwan: ftp.tw.freebsd.org|\ -Taiwan #2: ftp2.tw.freebsd.org|\ -Taiwan #3: ftp3.tw.freebsd.org|\ -Taiwan #4: ftp4.tw.freebsd.org|\ -Taiwan #6: ftp6.tw.freebsd.org|\ -Taiwan #11: ftp11.tw.freebsd.org" - -TURKEY_FTP_SERVERS="\ -Turkey: ftp.tr.freebsd.org|\ -Turkey #2: ftp2.tr.freebsd.org" - -UK_FTP_SERVERS="\ -UK: ftp.uk.freebsd.org|\ -UK #2: ftp2.uk.freebsd.org|\ -UK #3: ftp3.uk.freebsd.org|\ -UK #4: ftp4.uk.freebsd.org|\ -UK #5: ftp5.uk.freebsd.org|\ -UK #6: ftp6.uk.freebsd.org" - -UKRAINE_FTP_SERVERS="\ -Ukraine: ftp.ua.freebsd.org|\ -Ukraine #2: ftp2.ua.freebsd.org|\ -Ukraine #5: ftp5.ua.freebsd.org|\ -Ukraine #6: ftp6.ua.freebsd.org|\ -Ukraine #7: ftp7.ua.freebsd.org|\ -Ukraine #8: ftp8.ua.freebsd.org" - -USA_FTP_SERVERS="\ -USA #1: ftp1.us.freebsd.org|\ -USA #2: ftp2.us.freebsd.org|\ -USA #3: ftp3.us.freebsd.org|\ -USA #4: ftp4.us.freebsd.org|\ -USA #5: ftp5.us.freebsd.org|\ -USA #6: ftp6.us.freebsd.org|\ -USA #7: ftp7.us.freebsd.org|\ -USA #8: ftp8.us.freebsd.org|\ -USA #9: ftp9.us.freebsd.org|\ -USA #10: ftp10.us.freebsd.org|\ -USA #11: ftp11.us.freebsd.org|\ -USA #12: ftp12.us.freebsd.org|\ -USA #13: ftp13.us.freebsd.org|\ -USA #14: ftp14.us.freebsd.org|\ -USA #15: ftp15.us.freebsd.org" - -show_mirrors() -{ - MIRRORS="${1}" - if [ -n "${MIRRORS}" ] - then - SAVE_IFS="${IFS}" - IFS="|" - for m in ${MIRRORS} - do - echo "$m" - done - IFS="${SAVE_IFS}" - fi -}; - -set_ftp_mirror() -{ - MIRROR="${1}" - echo "${MIRROR}" > "${CONFDIR}/mirrors.conf" -}; - -get_ftp_mirror() -{ - MIRROR="${DEFAULT_FTP_SERVER}" - if [ -f "${CONFDIR}/mirrors.conf" ] - then - MIRROR=`cat "${CONFDIR}/mirrors.conf"` - fi - - export VAL="${MIRROR}" -}; - - -get_ftpHost() -{ - get_value_from_cfg ftpPath - ftpPath="$VAL" - - ftpHost=`echo "${ftpPath}" | sed -E 's|^(ftp://)([^/]*)(.*)|\2|'` - export VAL="${ftpHost}" -}; - -get_ftpDir() -{ - get_value_from_cfg ftpPath - ftpPath="$VAL" - - ftpDir=`echo "${ftpPath}" | sed -E 's|^(ftp://)([^/]*)(.*)|\3|'` - export VAL="${ftpDir}" -}; - -get_ftp_mirrors() -{ - COUNTRY="${1}" - if [ -n "$COUNTRY" ] - then - COUNTRY=`echo $COUNTRY|tr A-Z a-z` - case "${COUNTRY}" in - argentina*) VAL="${ARGENTINA_FTP_SERVERS}" ;; - australia*) VAL="${AUSTRALIA_FTP_SERVERS}" ;; - austria*) VAL="${AUSTRIA_FTP_SERVERS}" ;; - brazil*) VAL="${BRAZIL_FTP_SERVERS}" ;; - canada*) VAL="${CANADA_FTP_SERVERS}" ;; - china*) VAL="${CHINA_FTP_SERVERS}" ;; - croatia*) VAL="${CROATIA_FTP_SERVERS}" ;; - czech*) VAL="${CZECH_REPUBLIC_FTP_SERVERS}" ;; - denmark*) VAL="${DENMARK_FTP_SERVERS}" ;; - estonia*) VAL="${ESTONIA_FTP_SERVERS}" ;; - finland*) VAL="${FINLAND_FTP_SERVERS}" ;; - france*) VAL="${FRANCE_FTP_SERVERS}" ;; - germany*) VAL="${GERMANY_FTP_SERVERS}" ;; - greece*) VAL="${GREECE_FTP_SERVERS}" ;; - hungary*) VAL="${HUNGARY_FTP_SERVERS}" ;; - iceland*) VAL="${ICELAND_FTP_SERVERS}" ;; - ireland*) VAL="${IRELAND_FTP_SERVERS}" ;; - israel*) VAL="${ISRAEL_FTP_SERVERS}" ;; - italy*) VAL="${ITALY_FTP_SERVERS}" ;; - japan*) VAL="${JAPAN_FTP_SERVERS}" ;; - korea*) VAL="${KOREA_FTP_SERVERS}" ;; - lithuania*) VAL="${LITHUANIA_FTP_SERVERS}" ;; - netherlands*) VAL="${NETHERLANDS_FTP_SERVERS}" ;; - norway*) VAL="${NORWAY_FTP_SERVERS}" ;; - poland*) VAL="${POLAND_FTP_SERVERS}" ;; - portugal*) VAL="${PORTUGAL_FTP_SERVERS}" ;; - romania*) VAL="${ROMAINIA_FTP_SERVERS}" ;; - russia*) VAL="${RUSSIA_FTP_SERVERS}" ;; - singapore*) VAL="${SINGAPORE_FTP_SERVERS}" ;; - slovak*) VAL="${SLOVAK_REPUBLIC_FTP_SERVERS}" ;; - slovenia*) VAL="${SLOVENIA_FTP_SERVERS}" ;; - *africa*) VAL="${SOUTH_AFRICA_FTP_SERVERS}" ;; - spain*) VAL="${SPAIN_FTP_SERVERS}" ;; - sweden*) VAL="${SWEDEN_FTP_SERVERS}" ;; - switzerland*) VAL="${SWITZERLAND_FTP_SERVERS}" ;; - taiwan*) VAL="${TAIWAN_FTP_SERVERS}" ;; - turkey*) VAL="${TURKEY_FTP_SERVERS}" ;; - ukraine*) VAL="${UKRAINE_FTP_SERVERS}" ;; - uk*) VAL="${UK_FTP_SERVERS}" ;; - usa*) VAL="${USA_FTP_SERVERS}" ;; - esac - else - VAL="${MAIN_FTP_SERVERS}" - VAL="${VAL}|${IPV6_FTP_SERVERS}" - VAL="${VAL}|${PRIMARY_FTP_SERVERS}" - VAL="${VAL}|${ARGENTINA_FTP_SERVERS}" - VAL="${VAL}|${AUSTRALIA_FTP_SERVERS}" - VAL="${VAL}|${AUSTRIA_FTP_SERVERS}" - VAL="${VAL}|${BRAZIL_FTP_SERVERS}" - VAL="${VAL}|${CANADA_FTP_SERVERS}" - VAL="${VAL}|${CHINA_FTP_SERVERS}" - VAL="${VAL}|${CROATIA_FTP_SERVERS}" - VAL="${VAL}|${CZECH_REPUBLIC_FTP_SERVERS}" - VAL="${VAL}|${DENMARK_FTP_SERVERS}" - VAL="${VAL}|${ESTONIA_FTP_SERVERS}" - VAL="${VAL}|${FINLAND_FTP_SERVERS}" - VAL="${VAL}|${FRANCE_FTP_SERVERS}" - VAL="${VAL}|${GERMANY_FTP_SERVERS}" - VAL="${VAL}|${GREECE_FTP_SERVERS}" - VAL="${VAL}|${HUNGARY_FTP_SERVERS}" - VAL="${VAL}|${ICELAND_FTP_SERVERS}" - VAL="${VAL}|${IRELAND_FTP_SERVERS}" - VAL="${VAL}|${ISRAEL_FTP_SERVERS}" - VAL="${VAL}|${ITALY_FTP_SERVERS}" - VAL="${VAL}|${JAPAN_FTP_SERVERS}" - VAL="${VAL}|${KOREA_FTP_SERVERS}" - VAL="${VAL}|${LITHUANIA_FTP_SERVERS}" - VAL="${VAL}|${NETHERLANDS_FTP_SERVERS}" - VAL="${VAL}|${NORWAY_FTP_SERVERS}" - VAL="${VAL}|${POLAND_FTP_SERVERS}" - VAL="${VAL}|${PORTUGAL_FTP_SERVERS}" - VAL="${VAL}|${ROMANIA_FTP_SERVERS}" - VAL="${VAL}|${RUSSIA_FTP_SERVERS}" - VAL="${VAL}|${SINGAPORE_FTP_SERVERS}" - VAL="${VAL}|${SLOVAK_REPUBLIC_FTP_SERVERS}" - VAL="${VAL}|${SLOVENIA_FTP_SERVERS}" - VAL="${VAL}|${SOUTH_AFRICA_FTP_SERVERS}" - VAL="${VAL}|${SPAIN_FTP_SERVERS}" - VAL="${VAL}|${SWEDEN_FTP_SERVERS}" - VAL="${VAL}|${SWITZERLAND_FTP_SERVERS}" - VAL="${VAL}|${TAIWAN_FTP_SERVERS}" - VAL="${VAL}|${TURKEY_FTP_SERVERS}" - VAL="${VAL}|${UKRAINE_FTP_SERVERS}" - VAL="${VAL}|${UK_FTP_SERVERS}" - VAL="${VAL}|${USA_FTP_SERVERS}" - fi - - export VAL -}; diff --git a/usr.sbin/pc-sysinstall/backend/functions-installcomponents.sh b/usr.sbin/pc-sysinstall/backend/functions-installcomponents.sh deleted file mode 100755 index 5f1a7855349..00000000000 --- a/usr.sbin/pc-sysinstall/backend/functions-installcomponents.sh +++ /dev/null @@ -1,178 +0,0 @@ -#!/bin/sh -#- -# SPDX-License-Identifier: BSD-2-Clause-FreeBSD -# -# Copyright (c) 2010 iXsystems, Inc. All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions -# are met: -# 1. Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# 2. Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# -# THIS SOFTWARE IS PROVIDED BY 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. -# - -# Functions which check and load any optional modules specified in the config - -. ${BACKEND}/functions.sh -. ${BACKEND}/functions-parse.sh - -copy_component() -{ - COMPONENT="$1" - FAILED="0" - CFILES="" - - # Check the type, and set the components subdir properly - TYPE="`grep 'type:' ${COMPDIR}/${COMPONENT}/component.cfg | cut -d ' ' -f 2`" - if [ "${TYPE}" = "PBI" ] - then - SUBDIR="PBI" - else - SUBDIR="components" - fi - - # Lets start by downloading / copying the files this component needs - while read line - do - CFILE="`echo $line | cut -d ':' -f 1`" - CFILEMD5="`echo $line | cut -d ':' -f 2`" - CFILE2MD5="`echo $line | cut -d ':' -f 3`" - - case ${INSTALLMEDIUM} in - dvd|usb) - # On both dvd / usb, we can just copy the file - cp ${CDMNT}/${COMPFILEDIR}/${SUBDIR}/${CFILE} \ - ${FSMNT}/${COMPTMPDIR} >>${LOGOUT} 2>>${LOGOUT} - RESULT="$?" - ;; - - ftp) - get_value_from_cfg ftpPath - if [ -z "$VAL" ] - then - exit_err "ERROR: Install medium was set to ftp, but no ftpPath was provided!" - fi - FTPPATH="${VAL}" - - fetch_file "${FTPPATH}/${COMPFILEDIR}/${SUBDIR}/${CFILE}" "${FSMNT}/${COMPTMPDIR}/${CFILE}" "0" - RESULT="$?" - ;; - local) - get_value_from_cfg localPath - if [ -z "$VAL" ]; then - exit_err "Install medium was set to local, but no localPath was provided!" - fi - LOCALPATH=$VAL - cp ${LOCALPATH}/${COMPFILEDIR}/${SUBDIR}/${CFILE} \ - ${FSMNT}/${COMPTMPDIR} >>${LOGOUT} 2>>${LOGOUT} - RESULT="$?" - ;; - esac - - if [ "${RESULT}" != "0" ] - then - echo_log "WARNING: Failed to copy ${CFILE}" - FAILED="1" - else - # Now lets check the MD5 to confirm the file is valid - CHECKMD5=`md5 -q ${FSMNT}/${COMPTMPDIR}/${CFILE}` - if [ "${CHECKMD5}" != "${CFILEMD5}" -a "${CHECKMD5}" != "${CFILE2MD5}" ] - then - echo_log "WARNING: ${CFILE} failed md5 checksum" - FAILED="1" - else - if [ -z "${CFILES}" ] - then - CFILES="${CFILE}" - else - CFILES="${CFILES},${CFILE}" - fi - fi - fi - - - done < ${COMPDIR}/${COMPONENT}/distfiles - - if [ "${FAILED}" = "0" ] - then - # Now install the component - run_component_install ${COMPONENT} ${CFILES} - fi - -}; - -run_component_install() -{ - COMPONENT="$1" - CFILES="$1" - - # Lets install this component now - # Start by making a wrapper script which sets the variables - # for the component to use - echo "#!/bin/sh -COMPTMPDIR=\"${COMPTMPDIR}\" -export COMPTMPDIR -CFILE=\"${CFILE}\" -export CFILE -mount -t devfs devfs /dev - -sh ${COMPTMPDIR}/install.sh - -umount /dev -" >${FSMNT}/.componentwrapper.sh - chmod 755 ${FSMNT}/.componentwrapper.sh - - # Copy over the install script for this component - cp ${COMPDIR}/${COMPONENT}/install.sh ${FSMNT}/${COMPTMPDIR}/ - - echo_log "INSTALL COMPONENT: ${i}" - chroot ${FSMNT} /.componentwrapper.sh >>${LOGOUT} 2>>${LOGOUT} - rm ${FSMNT}/.componentwrapper.sh - -}; - -# Check for any modules specified, and begin loading them -install_components() -{ - # First, lets check and see if we even have any optional modules - get_value_from_cfg installComponents - if [ -n "${VAL}" ] - then - # Lets start by cleaning up the string and getting it ready to parse - strip_white_space ${VAL} - COMPONENTS=`echo ${VAL} | sed -e "s|,| |g"` - for i in $COMPONENTS - do - if [ ! -e "${COMPDIR}/${i}/install.sh" -o ! -e "${COMPDIR}/${i}/distfiles" ] - then - echo_log "WARNING: Component ${i} doesn't seem to exist" - else - - # Make the tmpdir on the disk - mkdir -p ${FSMNT}/${COMPTMPDIR} >>${LOGOUT} 2>>${LOGOUT} - - # Start by grabbing the component files - copy_component ${i} - - # Remove the tmpdir now - rm -rf ${FSMNT}/${COMPTMPDIR} >>${LOGOUT} 2>>${LOGOUT} - fi - done - fi - -}; diff --git a/usr.sbin/pc-sysinstall/backend/functions-installpackages.sh b/usr.sbin/pc-sysinstall/backend/functions-installpackages.sh deleted file mode 100755 index f4415d7e35e..00000000000 --- a/usr.sbin/pc-sysinstall/backend/functions-installpackages.sh +++ /dev/null @@ -1,189 +0,0 @@ -#!/bin/sh -#- -# SPDX-License-Identifier: BSD-2-Clause-FreeBSD -# -# Copyright (c) 2010 iXsystems, Inc. All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions -# are met: -# 1. Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# 2. Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# -# THIS SOFTWARE IS PROVIDED BY 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. -# - -# Functions which check and load any optional packages specified in the config - -. ${BACKEND}/functions.sh -. ${BACKEND}/functions-parse.sh - -# Recursively determine all dependencies for this package -determine_package_dependencies() -{ - local PKGNAME="${1}" - local DEPFILE="${2}" - - grep -q "${PKGNAME}" "${DEPFILE}" - if [ $? -ne 0 ] - then - echo "${PKGNAME}" >> "${DEPFILE}" - get_package_dependencies "${PKGNAME}" "1" - - local DEPS="${VAL}" - for d in ${DEPS} - do - determine_package_dependencies "${d}" "${DEPFILE}" - done - fi -}; - -# Fetch packages dependencies from a file -fetch_package_dependencies() -{ - local DEPFILE - local DEPS - local SAVEDIR - - DEPFILE="${1}" - DEPS=`cat "${DEPFILE}"` - SAVEDIR="${2}" - - for d in ${DEPS} - do - get_package_short_name "${d}" - SNAME="${VAL}" - - get_package_category "${SNAME}" - CATEGORY="${VAL}" - - fetch_package "${CATEGORY}" "${d}" "${SAVEDIR}" - done -}; - -# Check for any packages specified, and begin loading them -install_packages() -{ - echo "Checking for packages to install..." - sleep 2 - - # First, lets check and see if we even have any packages to install - get_value_from_cfg installPackages - - # Nothing to do? - if [ -z "${VAL}" ]; then return; fi - - echo "Installing packages..." - sleep 3 - - local PKGPTH - - HERE=`pwd` - rc_halt "mkdir -p ${FSMNT}${PKGTMPDIR}" - - # Determine the directory we will install packages from - get_package_location - rc_halt "cd ${PKGDLDIR}" - - # Set the location of the INDEXFILE - INDEXFILE="${TMPDIR}/INDEX" - - if [ ! -f "${INDEXFILE}" ]; then - get_package_index - fi - - if [ ! -f "${TMPDIR}/INDEX.parsed" -a "$INSTALLMEDIUM" = "ftp" ]; then - parse_package_index - fi - - # What extension are we using for pkgs? - PKGEXT="txz" - get_value_from_cfg pkgExt - if [ -n "${VAL}" ]; then - strip_white_space ${VAL} - PKGEXT="$VAL" - fi - export PKGEXT - - # We dont want to be bothered with scripts asking questions - PACKAGE_BUILDING=yes - export PACKAGE_BUILDING - - # Lets start by cleaning up the string and getting it ready to parse - get_value_from_cfg_with_spaces installPackages - PACKAGES="${VAL}" - echo_log "Packages to install: `echo $PACKAGES | wc -w | awk '{print $1}'`" - for i in $PACKAGES - do - if ! get_package_name "${i}" - then - echo_log "Unable to locate package ${i}" - continue - fi - - PKGNAME="${VAL}" - - # Fetch package + deps, but skip if installing from local media - if [ "${INSTALLMEDIUM}" = "ftp" ] ; then - DEPFILE="${FSMNT}/${PKGTMPDIR}/.${PKGNAME}.deps" - rc_nohalt "touch ${DEPFILE}" - determine_package_dependencies "${PKGNAME}" "${DEPFILE}" - fetch_package_dependencies "${DEPFILE}" "${FSMNT}/${PKGTMPDIR}" - fi - - # Set package location - case "${INSTALLMEDIUM}" in - usb|dvd|local) PKGPTH="${PKGTMPDIR}/All/${PKGNAME}" ;; - *) PKGPTH="${PKGTMPDIR}/${PKGNAME}" ;; - esac - - # See if we need to determine the package format we are working with - if [ -z "${PKGINFO}" ] ; then - tar tqf "${FSMNT}${PKGPTH}" '+MANIFEST' >/dev/null 2>/dev/null - if [ $? -ne 0 ] ; then - PKGADD="pkg_add -C ${FSMNT}" - PKGINFO="pkg_info" - else - PKGADD="pkg -c ${FSMNT} add" - PKGINFO="pkg info" - bootstrap_pkgng - fi - fi - - # If the package is not already installed, install it! - if ! run_chroot_cmd "${PKGINFO} -e ${PKGNAME}" >/dev/null 2>/dev/null - then - echo_log "Installing package: ${PKGNAME}" - rc_nohalt "${PKGADD} ${PKGPTH}" - fi - - if [ "${INSTALLMEDIUM}" = "ftp" ] ; then - rc_nohalt "rm ${DEPFILE}" - fi - - done - - echo_log "Package installation complete!" - - # Cleanup after ourselves - rc_halt "cd ${HERE}" - if [ "${INSTALLMEDIUM}" = "ftp" ] ; then - rc_halt "rm -rf ${FSMNT}${PKGTMPDIR}" >/dev/null 2>/dev/null - else - rc_halt "umount ${FSMNT}${PKGTMPDIR}" >/dev/null 2>/dev/null - rc_halt "rmdir ${FSMNT}${PKGTMPDIR}" >/dev/null 2>/dev/null - fi -}; diff --git a/usr.sbin/pc-sysinstall/backend/functions-localize.sh b/usr.sbin/pc-sysinstall/backend/functions-localize.sh deleted file mode 100755 index ff686fe11f7..00000000000 --- a/usr.sbin/pc-sysinstall/backend/functions-localize.sh +++ /dev/null @@ -1,542 +0,0 @@ -#!/bin/sh -#- -# SPDX-License-Identifier: BSD-2-Clause-FreeBSD -# -# Copyright (c) 2010 iXsystems, Inc. All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions -# are met: -# 1. Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# 2. Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# -# THIS SOFTWARE IS PROVIDED BY 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. -# - -# Functions which runs commands on the system - -. ${BACKEND}/functions.sh -. ${BACKEND}/functions-parse.sh - - -# Function which localizes a FreeBSD install -localize_freebsd() -{ - sed -i.bak "s/lang=en_US/lang=${LOCALE}/g" ${FSMNT}/etc/login.conf - rm ${FSMNT}/etc/login.conf.bak -}; - -localize_x_desktops() { - - # Check for and customize KDE lang - ########################################################################## - - # Check if we can localize KDE via skel - if [ -e "${FSMNT}/usr/share/skel/.kde4/share/config/kdeglobals" ] ; then - sed -i '' "s/Country=us/Country=${COUNTRY}/g" ${FSMNT}/usr/share/skel/.kde4/share/config/kdeglobals - sed -i '' "s/Country=us/Country=${COUNTRY}/g" ${FSMNT}/root/.kde4/share/config/kdeglobals - sed -i '' "s/Language=en_US/Language=${SETLANG}:${LOCALE}/g" ${FSMNT}/usr/share/skel/.kde4/share/config/kdeglobals - fi - - # Check if we have a KDE root config - if [ -e "${FSMNT}/root/.kde4/share/config/kdeglobals" ] ; then - sed -i '' "s/Language=en_US/Language=${SETLANG}:${LOCALE}/g" ${FSMNT}/root/.kde4/share/config/kdeglobals - fi - - # Check for KDM - if [ -e "${FSMNT}/usr/local/kde4/share/config/kdm/kdmrc" ] ; then - sed -i '' "s/Language=en_US/Language=${LOCALE}.UTF-8/g" ${FSMNT}/usr/local/kde4/share/config/kdm/kdmrc - fi - - # Check for and customize GNOME / GDM lang - ########################################################################## - - # See if GDM is enabled and customize its lang - cat ${FSMNT}/etc/rc.conf 2>/dev/null | grep -q "gdm_enable=\"YES\"" 2>/dev/null - if [ "$?" = "0" ] ; then - echo "gdm_lang=\"${LOCALE}.UTF-8\"" >> ${FSMNT}/etc/rc.conf - fi - -}; - -# Function which localizes a PC-BSD install -localize_pcbsd() -{ - # Check if we have a localized splash screen and copy it - if [ -e "${FSMNT}/usr/local/share/pcbsd/splash-screens/loading-screen-${SETLANG}.pcx" ] - then - cp ${FSMNT}/usr/local/share/pcbsd/splash-screens/loading-screen-${SETLANG}.pcx ${FSMNT}/boot/loading-screen.pcx - fi - -}; - -localize_x_keyboard() -{ - KEYMOD="$1" - KEYLAY="$2" - KEYVAR="$3" - COUNTRY="$4" - OPTION="grp:alt_shift_toggle" - SETXKBMAP="" - - if [ "${COUNTRY}" = "NONE" -o "${COUNTRY}" = "us" -o "${COUNTRY}" = "C" ] ; then - #In this case we don't need any additional language - COUNTRY="" - OPTION="" - else - COUNTRY=",${COUNTRY}" - fi - - if [ "${KEYMOD}" != "NONE" ] - then - SETXKBMAP="-model ${KEYMOD}" - KXMODEL="${KEYMOD}" - else - KXMODEL="pc104" - fi - - if [ "${KEYLAY}" != "NONE" ] - then - localize_key_layout "$KEYLAY" - SETXKBMAP="${SETXKBMAP} -layout ${KEYLAY}" - KXLAYOUT="${KEYLAY}" - else - KXLAYOUT="us" - fi - - if [ "${KEYVAR}" != "NONE" ] - then - SETXKBMAP="${SETXKBMAP} -variant ${KEYVAR}" - KXVAR="(${KEYVAR})" - else - KXVAR="" - fi - - # Setup .xprofile with our setxkbmap call now - if [ ! -z "${SETXKBMAP}" ] - then - if [ ! -e "${FSMNT}/usr/share/skel/.xprofile" ] - then - echo "#!/bin/sh" >${FSMNT}/usr/share/skel/.xprofile - fi - - # Save the keyboard layout for user / root X logins - echo "setxkbmap ${SETXKBMAP}" >>${FSMNT}/usr/share/skel/.xprofile - chmod 755 ${FSMNT}/usr/share/skel/.xprofile - cp ${FSMNT}/usr/share/skel/.xprofile ${FSMNT}/root/.xprofile - - # Save it for KDM - if [ -e "${FSMNT}/usr/local/kde4/share/config/kdm/Xsetup" ] ; then - echo "setxkbmap ${SETXKBMAP}" >>${FSMNT}/usr/local/kde4/share/config/kdm/Xsetup - fi - fi - - # Create the kxkbrc configuration using these options - if [ -d "${FSMNT}/usr/share/skel/.kde4/share/config" ] ; then - echo "[Layout] -DisplayNames=${KXLAYOUT}${COUNTRY} -IndicatorOnly=false -LayoutList=${KXLAYOUT}${KXVAR}${COUNTRY} -Model=${KXMODEL} -Options=${OPTION} -ResetOldOptions=true -ShowFlag=true -ShowSingle=false -SwitchMode=WinClass -Use=true " >${FSMNT}/usr/share/skel/.kde4/share/config/kxkbrc - fi - -}; - -localize_key_layout() -{ - - KEYLAYOUT="$1" - - # Set the keylayout in rc.conf - case ${KEYLAYOUT} in - am) KEYLAYOUT_CONSOLE="hy.armscii-8" ;; - ca) KEYLAYOUT_CONSOLE="fr_CA.acc.iso" ;; - ch) KEYLAYOUT_CONSOLE="swissgerman.iso" ;; - cz) KEYLAYOUT_CONSOLE="cz.iso2" ;; - de) KEYLAYOUT_CONSOLE="german.iso" ;; - dk) KEYLAYOUT_CONSOLE="danish.iso" ;; - ee) KEYLAYOUT_CONSOLE="estonian.iso" ;; - es) KEYLAYOUT_CONSOLE="spanish.iso" ;; - fi) KEYLAYOUT_CONSOLE="finnish.iso" ;; - is) KEYLAYOUT_CONSOLE="icelandic.iso" ;; - jp) KEYLAYOUT_CONSOLE="jp.106" ;; - nl) KEYLAYOUT_CONSOLE="dutch.iso.acc" ;; - no) KEYLAYOUT_CONSOLE="norwegian.iso" ;; - pl) KEYLAYOUT_CONSOLE="pl_PL.ISO8859-2" ;; - ru) KEYLAYOUT_CONSOLE="ru.koi8-r" ;; - sk) KEYLAYOUT_CONSOLE="sk.iso2" ;; - se) KEYLAYOUT_CONSOLE="swedish.iso" ;; - tr) KEYLAYOUT_CONSOLE="tr.iso9.q" ;; - gb) KEYLAYOUT_CONSOLE="uk.iso" ;; - *) if [ ! -z "${KEYLAYOUT}" ] - then - KEYLAYOUT_CONSOLE="${KEYLAYOUT}.iso" - fi - ;; - esac - - if [ -n "${KEYLAYOUT_CONSOLE}" ] - then - echo "keymap=\"${KEYLAYOUT_CONSOLE}\"" >>${FSMNT}/etc/rc.conf - fi - -}; - -# Function which prunes other l10n files from the KDE install -localize_prune_langs() -{ - get_value_from_cfg localizeLang - KEEPLANG="$VAL" - if [ -z "$KEEPLANG" ] ; then - KEEPLANG="en" - fi - export KEEPLANG - - echo_log "Pruning other l10n files, keeping ${KEEPLANG}" - - # Create the script to do uninstalls - echo '#!/bin/sh - - for i in `pkg_info -xEI kde-l10n` - do - echo "$i" | grep "${KEEPLANG}-kde" - if [ $? -ne 0 ] ; then - pkg_delete ${i} - fi - done - ' > ${FSMNT}/.pruneLangs.sh - - chmod 755 ${FSMNT}/.pruneLangs.sh - chroot ${FSMNT} /.pruneLangs.sh >/dev/null 2>/dev/null - rm ${FSMNT}/.pruneLangs.sh - -}; - -# Function which sets COUNTRY SETLANG and LOCALE based upon $1 -localize_get_codes() -{ - TARGETLANG="${1}" - # Setup the presets for the specific lang - case $TARGETLANG in - af) - COUNTRY="C" - SETLANG="af" - LOCALE="af_ZA" - ;; - ar) - COUNTRY="C" - SETLANG="ar" - LOCALE="en_US" - ;; - az) - COUNTRY="C" - SETLANG="az" - LOCALE="en_US" - ;; - ca) - COUNTRY="es" - SETLANG="es:ca" - LOCALE="ca_ES" - ;; - be) - COUNTRY="be" - SETLANG="be" - LOCALE="be_BY" - ;; - bn) - COUNTRY="bn" - SETLANG="bn" - LOCALE="en_US" - ;; - bg) - COUNTRY="bg" - SETLANG="bg" - LOCALE="bg_BG" - ;; - cs) - COUNTRY="cz" - SETLANG="cs" - LOCALE="cs_CZ" - ;; - da) - COUNTRY="dk" - SETLANG="da" - LOCALE="da_DK" - ;; - de) - COUNTRY="de" - SETLANG="de" - LOCALE="de_DE" - ;; - en_GB) - COUNTRY="gb" - SETLANG="en_GB:cy" - LOCALE="en_GB" - ;; - el) - COUNTRY="gr" - SETLANG="el:gr" - LOCALE="el_GR" - ;; - es) - COUNTRY="es" - SETLANG="es" - LOCALE="es_ES" - ;; - es_LA) - COUNTRY="us" - SETLANG="es:en_US" - LOCALE="es_ES" - ;; - et) - COUNTRY="ee" - SETLANG="et" - LOCALE="et_EE" - ;; - fr) - COUNTRY="fr" - SETLANG="fr" - LOCALE="fr_FR" - ;; - he) - COUNTRY="il" - SETLANG="he:ar" - LOCALE="he_IL" - ;; - hr) - COUNTRY="hr" - SETLANG="hr" - LOCALE="hr_HR" - ;; - hu) - COUNTRY="hu" - SETLANG="hu" - LOCALE="hu_HU" - ;; - it) - COUNTRY="it" - SETLANG="it" - LOCALE="it_IT" - ;; - ja) - COUNTRY="jp" - SETLANG="ja" - LOCALE="ja_JP" - ;; - ko) - COUNTRY="kr" - SETLANG="ko" - LOCALE="ko_KR" - ;; - nl) - COUNTRY="nl" - SETLANG="nl" - LOCALE="nl_NL" - ;; - nn) - COUNTRY="no" - SETLANG="nn" - LOCALE="en_US" - ;; - pa) - COUNTRY="pa" - SETLANG="pa" - LOCALE="en_US" - ;; - pl) - COUNTRY="pl" - SETLANG="pl" - LOCALE="pl_PL" - ;; - pt) - COUNTRY="pt" - SETLANG="pt" - LOCALE="pt_PT" - ;; - pt_BR) - COUNTRY="br" - SETLANG="pt_BR" - LOCALE="pt_BR" - ;; - ru) - COUNTRY="ru" - SETLANG="ru" - LOCALE="ru_RU" - ;; - sl) - COUNTRY="si" - SETLANG="sl" - LOCALE="sl_SI" - ;; - sk) - COUNTRY="sk" - SETLANG="sk" - LOCALE="sk_SK" - ;; - sv) - COUNTRY="se" - SETLANG="sv" - LOCALE="sv_SE" - ;; - uk) - COUNTRY="ua" - SETLANG="uk" - LOCALE="uk_UA" - ;; - vi) - COUNTRY="vn" - SETLANG="vi" - LOCALE="en_US" - ;; - zh_CN) - COUNTRY="cn" - SETLANG="zh_CN" - LOCALE="zh_CN" - ;; - zh_TW) - COUNTRY="tw" - SETLANG="zh_TW" - LOCALE="zh_TW" - ;; - *) - COUNTRY="C" - SETLANG="${TARGETLANG}" - LOCALE="en_US" - ;; - esac - - export COUNTRY SETLANG LOCALE - -}; - -# Function which sets the timezone on the system -set_timezone() -{ - TZONE="$1" - cp ${FSMNT}/usr/share/zoneinfo/${TZONE} ${FSMNT}/etc/localtime -}; - -# Function which enables / disables NTP -set_ntp() -{ - ENABLED="$1" - if [ "$ENABLED" = "yes" -o "${ENABLED}" = "YES" ] - then - cat ${FSMNT}/etc/rc.conf 2>/dev/null | grep -q 'ntpd_enable="YES"' 2>/dev/null - if [ $? -ne 0 ] - then - echo 'ntpd_enable="YES"' >>${FSMNT}/etc/rc.conf - echo 'ntpd_sync_on_start="YES"' >>${FSMNT}/etc/rc.conf - fi - else - cat ${FSMNT}/etc/rc.conf 2>/dev/null | grep -q 'ntpd_enable="YES"' 2>/dev/null - if [ $? -ne 0 ] - then - sed -i.bak 's|ntpd_enable="YES"||g' ${FSMNT}/etc/rc.conf - fi - fi -}; - -# Starts checking for localization directives -run_localize() -{ - KEYLAYOUT="NONE" - KEYMOD="NONE" - KEYVAR="NONE" - - while read line - do - # Check if we need to do any localization - echo $line | grep -q "^localizeLang=" 2>/dev/null - if [ $? -eq 0 ] - then - - # Set our country / lang / locale variables - get_value_from_string "$line" - localize_get_codes ${VAL} - - get_value_from_string "$line" - # If we are doing PC-BSD install, localize it as well as FreeBSD base - if [ "${INSTALLTYPE}" != "FreeBSD" ] - then - localize_pcbsd "$VAL" - fi - - # Localize FreeBSD - localize_freebsd "$VAL" - - # Localize any X pkgs - localize_x_desktops "$VAL" - fi - - # Check if we need to do any keylayouts - echo $line | grep -q "^localizeKeyLayout=" 2>/dev/null - if [ $? -eq 0 ] ; then - get_value_from_string "$line" - KEYLAYOUT="$VAL" - fi - - # Check if we need to do any key models - echo $line | grep -q "^localizeKeyModel=" 2>/dev/null - if [ $? -eq 0 ] ; then - get_value_from_string "$line" - KEYMOD="$VAL" - fi - - # Check if we need to do any key variant - echo $line | grep -q "^localizeKeyVariant=" 2>/dev/null - if [ $? -eq 0 ] ; then - get_value_from_string "$line" - KEYVAR="$VAL" - fi - - - # Check if we need to set a timezone - echo $line | grep -q "^timeZone=" 2>/dev/null - if [ $? -eq 0 ] ; then - get_value_from_string "$line" - set_timezone "$VAL" - fi - - # Check if we need to set a timezone - echo $line | grep -q "^enableNTP=" 2>/dev/null - if [ $? -eq 0 ] ; then - get_value_from_string "$line" - set_ntp "$VAL" - fi - done <${CFGF} - - if [ "${INSTALLTYPE}" != "FreeBSD" ] ; then - # Do our X keyboard localization - localize_x_keyboard "${KEYMOD}" "${KEYLAYOUT}" "${KEYVAR}" "${COUNTRY}" - fi - - # Check if we want to prunt any other KDE lang files to save some disk space - get_value_from_cfg localizePrune - if [ "${VAL}" = "yes" -o "${VAL}" = "YES" ] ; then - localize_prune_langs - fi - - # Update the login.conf db, even if we didn't localize, its a good idea to make sure its up2date - run_chroot_cmd "/usr/bin/cap_mkdb /etc/login.conf" >/dev/null 2>/dev/null - -}; diff --git a/usr.sbin/pc-sysinstall/backend/functions-mountdisk.sh b/usr.sbin/pc-sysinstall/backend/functions-mountdisk.sh deleted file mode 100755 index 087cf3dd586..00000000000 --- a/usr.sbin/pc-sysinstall/backend/functions-mountdisk.sh +++ /dev/null @@ -1,241 +0,0 @@ -#!/bin/sh -#- -# SPDX-License-Identifier: BSD-2-Clause-FreeBSD -# -# Copyright (c) 2010 iXsystems, Inc. All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions -# are met: -# 1. Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# 2. Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# -# THIS SOFTWARE IS PROVIDED BY 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. -# - -# Functions related mounting the newly formatted disk partitions - -# Mounts all the specified partition to the mount-point -mount_partition() -{ - if [ -z "${1}" -o -z "${2}" -o -z "${3}" ] - then - exit_err "ERROR: Missing arguments for mount_partition" - fi - - PART="${1}" - PARTFS="${2}" - MNTPOINT="${3}" - MNTFLAGS="${4}" - - # Setup the MNTOPTS - if [ -z "${MNTOPTS}" ] - then - MNTFLAGS="-o rw" - else - MNTFLAGS="-o rw,${MNTFLAGS}" - fi - - - #We are on ZFS, lets setup this mount-point - if [ "${PARTFS}" = "ZFS" ] - then - ZPOOLNAME=$(get_zpool_name "${PART}") - - # Check if we have multiple zfs mounts specified - for ZMNT in `echo ${MNTPOINT} | sed 's|,| |g'` - do - # Check for any ZFS specific mount options - ZMNTOPTS="`echo $ZMNT | cut -d '(' -f 2 | cut -d ')' -f 1`" - if [ "$ZMNTOPTS" = "$ZMNT" ] ; then ZMNTOPTS="" ; fi - - # Reset ZMNT with options removed - ZMNT="`echo $ZMNT | cut -d '(' -f 1`" - - # First make sure we create the mount point - if [ ! -d "${FSMNT}${ZMNT}" ] ; then - mkdir -p ${FSMNT}${ZMNT} >>${LOGOUT} 2>>${LOGOUT} - fi - - # Check for any volsize args - zcopt="" - for ZOPT in `echo $ZMNTOPTS | sed 's/|/ /g'` - do - echo "$ZOPT" | grep -q volsize - if [ $? -eq 0 ] ; then - volsize=`echo $ZOPT | cut -d '=' -f 2` - zcopt="-V $volsize" - fi - done - - if [ "${ZMNT}" = "/" ] ; then - # If creating ZFS / dataset, give it name that beadm works with - ZNAME="/ROOT/default" - ZMKMNT="" - echo_log "zfs create $zcopt -p ${ZPOOLNAME}/ROOT" - rc_halt "zfs create $zcopt -p ${ZPOOLNAME}/ROOT" - echo_log "zfs create $zcopt -p ${ZPOOLNAME}${ZNAME}" - rc_halt "zfs create $zcopt -p ${ZPOOLNAME}${ZNAME}" - else - ZNAME="${ZMNT}" - ZMKMNT="${ZMNT}" - echo_log "zfs create $zcopt -p ${ZPOOLNAME}${ZNAME}" - rc_halt "zfs create $zcopt -p ${ZPOOLNAME}${ZNAME}" - fi - sleep 2 - if [ -z "$zcopt" ] ; then - rc_halt "zfs set mountpoint=${FSMNT}${ZMKMNT} ${ZPOOLNAME}${ZNAME}" - fi - - # Do we need to make this / zfs dataset bootable? - if [ "$ZMNT" = "/" ] ; then - echo_log "Stamping ${ZPOOLNAME}/ROOT/default as bootfs" - rc_halt "zpool set bootfs=${ZPOOLNAME}/ROOT/default ${ZPOOLNAME}" - fi - - # Do we need to make this /boot zfs dataset bootable? - if [ "$ZMNT" = "/boot" ] ; then - echo_log "Stamping ${ZPOOLNAME}${ZMNT} as bootfs" - rc_halt "zpool set bootfs=${ZPOOLNAME}${ZMNT} ${ZPOOLNAME}" - fi - - # If no ZFS options, we can skip - if [ -z "$ZMNTOPTS" ] ; then continue ; fi - - # Parse any ZFS options now - for ZOPT in `echo $ZMNTOPTS | sed 's/|/ /g'` - do - echo "$ZOPT" | grep -q volsize - if [ $? -eq 0 ] ; then continue ; fi - rc_halt "zfs set $ZOPT ${ZPOOLNAME}${ZNAME}" - done - done # End of adding ZFS mounts - - else - # If we are not on ZFS, lets do the mount now - # First make sure we create the mount point - if [ ! -d "${FSMNT}${MNTPOINT}" ] - then - mkdir -p ${FSMNT}${MNTPOINT} >>${LOGOUT} 2>>${LOGOUT} - fi - - echo_log "mount ${MNTFLAGS} ${PART} -> ${FSMNT}${MNTPOINT}" - sleep 2 - rc_halt "mount ${MNTFLAGS} ${PART} ${FSMNT}${MNTPOINT}" - fi - -}; - -# Mounts all the new file systems to prepare for installation -mount_all_filesystems() -{ - # Make sure our mount point exists - mkdir -p ${FSMNT} >/dev/null 2>/dev/null - - # First lets find and mount the / partition - ######################################################### - for PART in `ls ${PARTDIR}` - do - PARTDEV=`echo $PART | sed 's|-|/|g'` - PARTFS="`cat ${PARTDIR}/${PART} | cut -d '#' -f 1`" - if [ ! -e "${PARTDEV}" -a "${PARTFS}" != "ZFS" ] - then - exit_err "ERROR: The partition ${PARTDEV} does not exist. Failure in bsdlabel?" - fi - - PARTMNT="`cat ${PARTDIR}/${PART} | cut -d '#' -f 2`" - PARTENC="`cat ${PARTDIR}/${PART} | cut -d '#' -f 3`" - - if [ "${PARTENC}" = "ON" ] - then - EXT=".eli" - else - EXT="" - fi - - # Check for root partition for mounting, including ZFS "/,/usr" type - echo "$PARTMNT" | grep "/," >/dev/null - if [ "$?" = "0" -o "$PARTMNT" = "/" ] - then - case ${PARTFS} in - UFS) mount_partition ${PARTDEV}${EXT} ${PARTFS} ${PARTMNT} "noatime" ;; - UFS+S) mount_partition ${PARTDEV}${EXT} ${PARTFS} ${PARTMNT} "noatime" ;; - UFS+SUJ) mount_partition ${PARTDEV}${EXT} ${PARTFS} ${PARTMNT} "noatime" ;; - UFS+J) mount_partition ${PARTDEV}${EXT}.journal ${PARTFS} ${PARTMNT} "async,noatime" ;; - ZFS) mount_partition ${PARTDEV} ${PARTFS} ${PARTMNT} ;; - IMAGE) mount_partition ${PARTDEV} ${PARTFS} ${PARTMNT} ;; - *) exit_err "ERROR: Got unknown file-system type $PARTFS" ;; - esac - fi - done - - # Now that we've mounted "/" lets do any other remaining mount-points - ################################################################## - for PART in `ls ${PARTDIR}` - do - PARTDEV=`echo $PART | sed 's|-|/|g'` - PARTFS="`cat ${PARTDIR}/${PART} | cut -d '#' -f 1`" - if [ ! -e "${PARTDEV}" -a "${PARTFS}" != "ZFS" ] - then - exit_err "ERROR: The partition ${PARTDEV} does not exist. Failure in bsdlabel?" - fi - - PARTMNT="`cat ${PARTDIR}/${PART} | cut -d '#' -f 2`" - PARTENC="`cat ${PARTDIR}/${PART} | cut -d '#' -f 3`" - - if [ "${PARTENC}" = "ON" ] - then - EXT=".eli" - else - EXT="" - fi - - # Check if we've found "/" again, don't need to mount it twice - echo "$PARTMNT" | grep "/," >/dev/null - if [ "$?" != "0" -a "$PARTMNT" != "/" ] - then - case ${PARTFS} in - UFS) mount_partition ${PARTDEV}${EXT} ${PARTFS} ${PARTMNT} "noatime" ;; - UFS+S) mount_partition ${PARTDEV}${EXT} ${PARTFS} ${PARTMNT} "noatime" ;; - UFS+SUJ) mount_partition ${PARTDEV}${EXT} ${PARTFS} ${PARTMNT} "noatime" ;; - UFS+J) mount_partition ${PARTDEV}${EXT}.journal ${PARTFS} ${PARTMNT} "async,noatime" ;; - ZFS) mount_partition ${PARTDEV} ${PARTFS} ${PARTMNT} ;; - SWAP) - # Lets enable this swap now - if [ "$PARTENC" = "ON" ] - then - echo_log "Enabling encrypted swap on ${PARTDEV}" - rc_halt "geli onetime -d -e 3des ${PARTDEV}" - sleep 5 - rc_halt "swapon ${PARTDEV}.eli" - else - echo_log "swapon ${PARTDEV}" - sleep 5 - rc_halt "swapon ${PARTDEV}" - fi - ;; - IMAGE) - if [ ! -d "${PARTMNT}" ] - then - mkdir -p "${PARTMNT}" - fi - mount_partition ${PARTDEV} ${PARTFS} ${PARTMNT} - ;; - *) exit_err "ERROR: Got unknown file-system type $PARTFS" ;; - esac - fi - done -}; diff --git a/usr.sbin/pc-sysinstall/backend/functions-mountoptical.sh b/usr.sbin/pc-sysinstall/backend/functions-mountoptical.sh deleted file mode 100755 index 1e545a1280b..00000000000 --- a/usr.sbin/pc-sysinstall/backend/functions-mountoptical.sh +++ /dev/null @@ -1,153 +0,0 @@ -#!/bin/sh -#- -# SPDX-License-Identifier: BSD-2-Clause-FreeBSD -# -# Copyright (c) 2010 iXsystems, Inc. All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions -# are met: -# 1. Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# 2. Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# -# THIS SOFTWARE IS PROVIDED BY 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. -# - -# Functions which perform mounting / unmounting and switching of -# optical / usb media - -. ${BACKEND}/functions.sh -. ${BACKEND}/functions-parse.sh - -# Displays an optical failure message -opt_fail() -{ - # If we got here, we must not have a DVD/USB we can find :( - get_value_from_cfg installInteractive - if [ "${VAL}" = "yes" ] - then - # We are running interactive, and didn't find a DVD, prompt user again - echo_log "DISK ERROR: Unable to find installation disk!" - echo_log "Please insert the installation disk and press enter." - read tmp - else - exit_err "ERROR: Unable to locate installation DVD/USB" - fi -}; - -# Performs the extraction of data to disk -opt_mount() -{ - FOUND="0" - - # Ensure we have a directory where its supposed to be - if [ ! -d "${CDMNT}" ] - then - mkdir -p ${CDMNT} - fi - - - # Start by checking if we already have a cd mounted at CDMNT - mount | grep -q "${CDMNT} " 2>/dev/null - if [ $? -eq 0 ] - then - if [ -e "${CDMNT}/${INSFILE}" ] - then - echo "MOUNTED" >${TMPDIR}/cdmnt - echo_log "FOUND DVD: MOUNTED" - FOUND="1" - return - fi - - # failed to find optical disk - opt_fail - return - fi - - # Setup our loop to search for installation media - while - z=1 - do - - # Loop though and look for an installation disk - for i in `ls -1 /dev/cd* 2>/dev/null` - do - # Find the CD Device - /sbin/mount_cd9660 $i ${CDMNT} - - # Check the package type to see if we have our install data - if [ -e "${CDMNT}/${INSFILE}" ] - then - echo "${i}" >${TMPDIR}/cdmnt - echo_log "FOUND DVD: ${i}" - FOUND="1" - break - fi - /sbin/umount ${CDMNT} >/dev/null 2>/dev/null - done - - # If no DVD found, try USB - if [ "$FOUND" != "1" ] - then - # Loop though and look for an installation disk - for i in `ls -1 /dev/da* 2>/dev/null` - do - # Check if we can mount this device UFS - /sbin/mount -r $i ${CDMNT} - - # Check the package type to see if we have our install data - if [ -e "${CDMNT}/${INSFILE}" ] - then - echo "${i}" >${TMPDIR}/cdmnt - echo_log "FOUND USB: ${i}" - FOUND="1" - break - fi - /sbin/umount ${CDMNT} >/dev/null 2>/dev/null - - # Also check if it is a FAT mount - /sbin/mount -r -t msdosfs $i ${CDMNT} - - # Check the package type to see if we have our install data - if [ -e "${CDMNT}/${INSFILE}" ] - then - echo "${i}" >${TMPDIR}/cdmnt - echo_log "FOUND USB: ${i}" - FOUND="1" - break - fi - /sbin/umount ${CDMNT} >/dev/null 2>/dev/null - done - fi # End of USB Check - - - if [ "$FOUND" = "1" ] - then - break - fi - - # Failed to find a disk, take action now - opt_fail - - done - -}; - -# Function to unmount optical media -opt_umount() -{ - /sbin/umount ${CDMNT} >/dev/null 2>/dev/null -}; diff --git a/usr.sbin/pc-sysinstall/backend/functions-networking.sh b/usr.sbin/pc-sysinstall/backend/functions-networking.sh deleted file mode 100755 index 52b47a36085..00000000000 --- a/usr.sbin/pc-sysinstall/backend/functions-networking.sh +++ /dev/null @@ -1,501 +0,0 @@ -#!/bin/sh -#- -# SPDX-License-Identifier: BSD-2-Clause-FreeBSD -# -# Copyright (c) 2010 iXsystems, Inc. All rights reserved. -# Copyright (c) 2011 The FreeBSD Foundation -# All rights reserved. -# -# Portions of this software were developed by Bjoern Zeeb -# under sponsorship from the FreeBSD Foundation. -# -# 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. -# - -# Functions which perform our networking setup - -# Function which creates a kde4 .desktop file for the PC-BSD net tray -create_desktop_nettray() -{ - NIC="${1}" - echo "#!/usr/bin/env xdg-open -[Desktop Entry] -Exec=/usr/local/kde4/bin/pc-nettray ${NIC} -Icon=network -StartupNotify=false -Type=Application" > ${FSMNT}/usr/share/skel/.kde4/Autostart/tray-${NIC}.desktop - chmod 744 ${FSMNT}/usr/share/skel/.kde4/Autostart/tray-${NIC}.desktop - -}; - -# Function which checks is a nic is wifi or not -check_is_wifi() -{ - NIC="$1" - ifconfig ${NIC} | grep -q "802.11" 2>/dev/null - if [ $? -eq 0 ] - then - return 0 - else - return 1 - fi -}; - -# Function to get the first available wired nic, used for setup -get_first_wired_nic() -{ - rm ${TMPDIR}/.niclist >/dev/null 2>/dev/null - # start by getting a list of nics on this system - ${QUERYDIR}/detect-nics.sh > ${TMPDIR}/.niclist - if [ -e "${TMPDIR}/.niclist" ] - then - while read line - do - NIC="`echo $line | cut -d ':' -f 1`" - check_is_wifi ${NIC} - if [ $? -ne 0 ] - then - export VAL="${NIC}" - return - fi - done < ${TMPDIR}/.niclist - fi - - export VAL="" - return -}; - - -# Function which simply enables plain dhcp on all detected nics -enable_dhcp_all() -{ - rm ${TMPDIR}/.niclist >/dev/null 2>/dev/null - # start by getting a list of nics on this system - ${QUERYDIR}/detect-nics.sh > ${TMPDIR}/.niclist - if [ -e "${TMPDIR}/.niclist" ] - then - echo "# Auto-Enabled NICs from pc-sysinstall" >>${FSMNT}/etc/rc.conf - WLANCOUNT="0" - while read line - do - NIC="`echo $line | cut -d ':' -f 1`" - DESC="`echo $line | cut -d ':' -f 2`" - echo_log "Setting $NIC to DHCP on the system." - check_is_wifi ${NIC} - if [ $? -eq 0 ] - then - # We have a wifi device, setup a wlan* entry for it - WLAN="wlan${WLANCOUNT}" - cat ${FSMNT}/etc/rc.conf | grep -q "wlans_${NIC}=" - if [ $? -ne 0 ] ; then - echo "wlans_${NIC}=\"${WLAN}\"" >>${FSMNT}/etc/rc.conf - fi - echo "ifconfig_${WLAN}=\"DHCP\"" >>${FSMNT}/etc/rc.conf - CNIC="${WLAN}" - WLANCOUNT=$((WLANCOUNT+1)) - else - echo "ifconfig_${NIC}=\"DHCP\"" >>${FSMNT}/etc/rc.conf - CNIC="${NIC}" - fi - - done < ${TMPDIR}/.niclist - fi -}; - - -# Function which detects available nics, and enables dhcp on them -save_auto_dhcp() -{ - enable_dhcp_all -}; - -# Function which simply enables iPv6 SLAAC on all detected nics -enable_slaac_all() -{ - rm ${TMPDIR}/.niclist >/dev/null 2>/dev/null - # start by getting a list of nics on this system - ${QUERYDIR}/detect-nics.sh > ${TMPDIR}/.niclist - if [ -e "${TMPDIR}/.niclist" ] - then - echo "# Auto-Enabled NICs from pc-sysinstall" >>${FSMNT}/etc/rc.conf - WLANCOUNT="0" - while read line - do - NIC="`echo $line | cut -d ':' -f 1`" - DESC="`echo $line | cut -d ':' -f 2`" - echo_log "Setting $NIC to accepting RAs on the system." - check_is_wifi ${NIC} - if [ $? -eq 0 ] - then - # We have a wifi device, setup a wlan* entry for it - # Given we cannot have DHCP and SLAAC the same time currently - # it's save to just duplicate. - WLAN="wlan${WLANCOUNT}" - cat ${FSMNT}/etc/rc.conf | grep -q "wlans_${NIC}=" - if [ $? -ne 0 ] ; then - echo "wlans_${NIC}=\"${WLAN}\"" >>${FSMNT}/etc/rc.conf - fi - #echo "ifconfig_${NIC}=\"up\"" >>${FSMNT}/etc/rc.conf - echo "ifconfig_${WLAN}_ipv6=\"inet6 accept_rtadv\"" >>${FSMNT}/etc/rc.conf - CNIC="${WLAN}" - WLANCOUNT=$((WLANCOUNT+1)) - else - #echo "ifconfig_${NIC}=\"up\"" >>${FSMNT}/etc/rc.conf - echo "ifconfig_${NIC}_ipv6=\"inet6 accept_rtadv\"" >>${FSMNT}/etc/rc.conf - CNIC="${NIC}" - fi - - done < ${TMPDIR}/.niclist - fi - - # Given we cannot yet rely on RAs to provide DNS information as much - # as we can in the DHCP world, we should append a given nameserver. - : > ${FSMNT}/etc/resolv.conf - get_value_from_cfg netSaveIPv6NameServer - NAMESERVER="${VAL}" - if [ -n "${NAMESERVER}" ] - then - echo "nameserver ${NAMESERVER}" >>${FSMNT}/etc/resolv.conf - fi - -}; - - -# Function which detects available nics, and enables IPv6 SLAAC on them -save_auto_slaac() -{ - enable_slaac_all -}; - - -# Function which saves a manual nic setup to the installed system -save_manual_nic() -{ - # Get the target nic - NIC="$1" - - get_value_from_cfg netSaveIP_${NIC} - NETIP="${VAL}" - - if [ "$NETIP" = "DHCP" ] - then - echo_log "Setting $NIC to DHCP on the system." - echo "ifconfig_${NIC}=\"DHCP\"" >>${FSMNT}/etc/rc.conf - return 0 - fi - - # If we get here, we have a manual setup, lets do so now - IFARGS="" - IF6ARGS="" - - # Set the manual IP - if [ -n "${NETIP}" ] - then - IFARGS="inet ${NETIP}" - - # Check if we have a netmask to set - get_value_from_cfg netSaveMask_${NIC} - NETMASK="${VAL}" - if [ -n "${NETMASK}" ] - then - IFARGS="${IFARGS} netmask ${NETMASK}" - fi - fi - - get_value_from_cfg netSaveIPv6_${NIC} - NETIP6="${VAL}" - if [ -n "${NETIP6}" ] - then - # Make sure we have one inet6 prefix. - IF6ARGS=`echo "${NETIP6}" | awk '{ if ("^inet6 ") { print $0; } else - { printf "inet6 %s", $0; } }'` - fi - - echo "# Auto-Enabled NICs from pc-sysinstall" >>${FSMNT}/etc/rc.conf - if [ -n "${IFARGS}" ] - then - echo "ifconfig_${NIC}=\"${IFARGS}\"" >>${FSMNT}/etc/rc.conf - fi - if [ -n "${IF6ARGS}" ] - then - echo "ifconfig_${NIC}_ipv6=\"${IF6ARGS}\"" >>${FSMNT}/etc/rc.conf - fi - -}; - -# Function which saves a manual gateway router setup to the installed system -save_manual_router() -{ - - # Check if we have a default router to set - get_value_from_cfg netSaveDefaultRouter - NETROUTE="${VAL}" - if [ -n "${NETROUTE}" ] - then - echo "defaultrouter=\"${NETROUTE}\"" >>${FSMNT}/etc/rc.conf - fi - get_value_from_cfg netSaveIPv6DefaultRouter - NETROUTE="${VAL}" - if [ -n "${NETROUTE}" ] - then - echo "ipv6_defaultrouter=\"${NETROUTE}\"" >>${FSMNT}/etc/rc.conf - fi - -}; - -save_manual_nameserver() -{ - # Check if we have a nameserver to enable - : > ${FSMNT}/etc/resolv.conf - get_value_from_cfg_with_spaces netSaveNameServer - NAMESERVERLIST="${VAL}" - if [ ! -z "${NAMESERVERLIST}" ] - then - for NAMESERVER in ${NAMESERVERLIST} - do - echo "nameserver ${NAMESERVER}" >>${FSMNT}/etc/resolv.conf - done - fi - - get_value_from_cfg_with_spaces netSaveIPv6NameServer - NAMESERVERLIST="${VAL}" - if [ ! -z "${NAMESERVERLIST}" ] - then - for NAMESERVER in ${NAMESERVERLIST} - do - echo "nameserver ${NAMESERVER}" >>${FSMNT}/etc/resolv.conf - done - fi - -}; - -# Function which determines if a nic is active / up -is_nic_active() -{ - ifconfig ${1} | grep -q "status: active" 2>/dev/null - if [ $? -eq 0 ] ; then - return 0 - else - return 1 - fi -}; - - -# Function which detects available nics, and runs DHCP on them until -# a success is found -enable_auto_dhcp() -{ - # start by getting a list of nics on this system - ${QUERYDIR}/detect-nics.sh > ${TMPDIR}/.niclist - while read line - do - NIC="`echo $line | cut -d ':' -f 1`" - DESC="`echo $line | cut -d ':' -f 2`" - - is_nic_active "${NIC}" - if [ $? -eq 0 ] ; then - echo_log "Trying DHCP on $NIC $DESC" - dhclient ${NIC} >/dev/null 2>/dev/null - if [ $? -eq 0 ] ; then - # Got a valid DHCP IP, we can return now - export WRKNIC="$NIC" - return 0 - fi - fi - done < ${TMPDIR}/.niclist - -}; - -# Function which detects available nics, and runs rtsol on them. -enable_auto_slaac() -{ - - # start by getting a list of nics on this system - ${QUERYDIR}/detect-nics.sh > ${TMPDIR}/.niclist - ALLNICS="" - while read line - do - NIC="`echo $line | cut -d ':' -f 1`" - DESC="`echo $line | cut -d ':' -f 2`" - - is_nic_active "${NIC}" - if [ $? -eq 0 ] ; then - echo_log "Will try IPv6 SLAAC on $NIC $DESC" - ifconfig ${NIC} inet6 -ifdisabled accept_rtadv up - ALLNICS="${ALLNICS} ${NIC}" - fi - done < ${TMPDIR}/.niclist - - # XXX once we support it in-tree call /sbin/resovconf here. - echo_log "Running rtsol on ${ALLNICS}" - rtsol -F ${ALLNICS} >/dev/null 2>/dev/null -} - -# Get the mac address of a target NIC -get_nic_mac() -{ - FOUNDMAC="`ifconfig ${1} | grep 'ether' | tr -d '\t' | cut -d ' ' -f 2`" - export FOUNDMAC -} - -# Function which performs the manual setup of a target nic in the cfg -enable_manual_nic() -{ - # Get the target nic - NIC="$1" - - # Check that this NIC exists - rc_halt "ifconfig ${NIC}" - - get_value_from_cfg netIP - NETIP="${VAL}" - - if [ "$NETIP" = "DHCP" ] - then - echo_log "Enabling DHCP on $NIC" - rc_halt "dhclient ${NIC}" - return 0 - fi - - # If we get here, we have a manual setup, lets do so now - - # IPv4: - - # Set the manual IP - if [ -n "${NETIP}" ] - then - # Check if we have a netmask to set - get_value_from_cfg netMask - NETMASK="${VAL}" - if [ -n "${NETMASK}" ] - then - rc_halt "ifconfig inet ${NIC} netmask ${NETMASK}" - else - rc_halt "ifconfig inet ${NIC} ${NETIP}" - fi - fi - - # Check if we have a default router to set - get_value_from_cfg netDefaultRouter - NETROUTE="${VAL}" - if [ -n "${NETROUTE}" ] - then - rc_halt "route add -inet default ${NETROUTE}" - fi - - # IPv6: - - # Set static IPv6 address - get_value_from_cfg netIPv6 - NETIP="${VAL}" - if [ -n ${NETIP} ] - then - rc_halt "ifconfig inet6 ${NIC} ${NETIP} -ifdisabled up" - fi - - # Default router - get_value_from_cfg netIPv6DefaultRouter - NETROUTE="${VAL}" - if [ -n "${NETROUTE}" ] - then - rc_halt "route add -inet6 default ${NETROUTE}" - fi - - # Check if we have a nameserver to enable - : >/etc/resolv.conf - get_value_from_cfg netNameServer - NAMESERVER="${VAL}" - if [ -n "${NAMESERVER}" ] - then - echo "nameserver ${NAMESERVER}" >>/etc/resolv.conf - fi - get_value_from_cfg netIPv6NameServer - NAMESERVER="${VAL}" - if [ -n "${NAMESERVER}" ] - then - echo "nameserver ${NAMESERVER}" >>/etc/resolv.conf - fi - -}; - - -# Function which parses the cfg and enables networking per specified -start_networking() -{ - # Check if we have any networking requested - get_value_from_cfg netDev - if [ -z "${VAL}" ] - then - return 0 - fi - - NETDEV="${VAL}" - if [ "$NETDEV" = "AUTO-DHCP" ] - then - enable_auto_dhcp - elif [ "$NETDEV" = "IPv6-SLAAC" ] - then - enable_auto_slaac - elif [ "$NETDEV" = "AUTO-DHCP-SLAAC" ] - then - enable_auto_dhcp - enable_auto_slaac - else - enable_manual_nic ${NETDEV} - fi - -}; - - -# Function which checks the cfg and enables the specified networking on -# the installed system -save_networking_install() -{ - - # Check if we have any networking requested to save - get_value_from_cfg_with_spaces netSaveDev - if [ -z "${VAL}" ] - then - return 0 - fi - - NETDEVLIST="${VAL}" - if [ "$NETDEVLIST" = "AUTO-DHCP" ] - then - save_auto_dhcp - elif [ "$NETDEVLIST" = "IPv6-SLAAC" ] - then - save_auto_slaac - elif [ "$NETDEVLIST" = "AUTO-DHCP-SLAAC" ] - then - save_auto_dhcp - save_auto_slaac - else - for NETDEV in ${NETDEVLIST} - do - save_manual_nic ${NETDEV} - done - save_manual_router - save_manual_nameserver - fi - -}; diff --git a/usr.sbin/pc-sysinstall/backend/functions-newfs.sh b/usr.sbin/pc-sysinstall/backend/functions-newfs.sh deleted file mode 100755 index fff39561622..00000000000 --- a/usr.sbin/pc-sysinstall/backend/functions-newfs.sh +++ /dev/null @@ -1,263 +0,0 @@ -#!/bin/sh -#- -# SPDX-License-Identifier: BSD-2-Clause-FreeBSD -# -# Copyright (c) 2010 iXsystems, Inc. All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions -# are met: -# 1. Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# 2. Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# -# THIS SOFTWARE IS PROVIDED BY 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. -# - -# Functions related to disk operations using newfs - - -# Function which performs the ZFS magic -setup_zfs_filesystem() -{ - PART="$1" - PARTFS="$2" - PARTMNT="$3" - EXT="$4" - PARTGEOM="$5" - ZPOOLOPTS="$6" - ROOTSLICE="`echo ${PART} | rev | cut -b 2- | rev`" - ZPOOLNAME=$(get_zpool_name "${PART}") - - # Sleep a few moments, let the disk catch its breath - sleep 5 - sync - - # Check if we have multiple zfs mounts specified - for i in `echo ${PARTMNT} | sed 's|,| |g'` - do - # Check if we ended up with needing a zfs bootable partition - if [ "${i}" = "/" -o "${i}" = "/boot" ] - then - if [ "$HAVEBOOT" = "YES" ] ; then continue ; fi - if [ "${PARTGEOM}" = "MBR" ] ; then - # Lets stamp the proper ZFS boot loader - echo_log "Setting up ZFS boot loader support" - rc_halt "dd if=/boot/zfsboot of=${ROOTSLICE} count=1" - rc_halt "dd if=/boot/zfsboot of=${PART}${EXT} skip=1 seek=1024" - fi - fi - done - - # Check if we have some custom zpool arguments and use them if so - if [ ! -z "${ZPOOLOPTS}" ] ; then - # Sort through devices and run gnop on them - local gnopDev="" - local newOpts="" - for i in $ZPOOLOPTS - do - echo "$i" | grep -q '/dev/' - if [ $? -eq 0 ] ; then - rc_halt "gnop create -S 4096 ${i}" - gnopDev="$gnopDev $i" - newOpts="$newOpts ${i}.nop" - else - newOpts="$newOpts $i" - fi - done - - echo_log "Creating zpool ${ZPOOLNAME} with $newOpts" - rc_halt "zpool create -m none -f ${ZPOOLNAME} ${newOpts}" - - # Export the pool - rc_halt "zpool export ${ZPOOLNAME}" - - # Destroy the gnop devices - for i in $gnopDev - do - rc_halt "gnop destroy ${i}.nop" - done - - # And lastly re-import the pool - rc_halt "zpool import ${ZPOOLNAME}" - else - # Lets do our pseudo-4k drive - rc_halt "gnop create -S 4096 ${PART}${EXT}" - - # No zpool options, create pool on single device - echo_log "Creating zpool ${ZPOOLNAME} on ${PART}${EXT}" - rc_halt "zpool create -m none -f ${ZPOOLNAME} ${PART}${EXT}.nop" - - # Finish up the gnop 4k trickery - rc_halt "zpool export ${ZPOOLNAME}" - rc_halt "gnop destroy ${PART}${EXT}.nop" - rc_halt "zpool import ${ZPOOLNAME}" - fi - - # Disable atime for this zfs partition, speed increase - rc_nohalt "zfs set atime=off ${ZPOOLNAME}" - - - -}; - -# Runs newfs on all the partiions which we've setup with bsdlabel -setup_filesystems() -{ - - # Create the keydir - rm -rf ${GELIKEYDIR} >/dev/null 2>/dev/null - mkdir ${GELIKEYDIR} - - # Lets go ahead and read through the saved partitions we created, and determine if we need to run - # newfs on any of them - for PART in `ls ${PARTDIR}` - do - PARTDEV="`echo $PART | sed 's|-|/|g'`" - PARTFS="`cat ${PARTDIR}/${PART} | cut -d '#' -f 1`" - PARTMNT="`cat ${PARTDIR}/${PART} | cut -d '#' -f 2`" - PARTENC="`cat ${PARTDIR}/${PART} | cut -d '#' -f 3`" - PARTLABEL="`cat ${PARTDIR}/${PART} | cut -d '#' -f 4`" - PARTGEOM="`cat ${PARTDIR}/${PART} | cut -d '#' -f 5`" - PARTXTRAOPTS="`cat ${PARTDIR}/${PART} | cut -d '#' -f 6`" - PARTIMAGE="`cat ${PARTDIR}/${PART} | cut -d '#' -f 7`" - - if [ ! -e "${PARTDEV}" ] ; then - exit_err "ERROR: The partition ${PARTDEV} does not exist. Failure in bsdlabel?" - fi - - # Make sure journaling isn't enabled on this device - if [ -e "${PARTDEV}.journal" ] - then - rc_nohalt "gjournal stop -f ${PARTDEV}.journal" - rc_nohalt "gjournal clear ${PARTDEV}" - fi - - # Setup encryption if necessary - if [ "${PARTENC}" = "ON" -a "${PARTFS}" != "SWAP" ] - then - echo_log "Creating geli provider for ${PARTDEV}" - - if [ -e "${PARTDIR}-enc/${PART}-encpass" ] ; then - # Using a passphrase - rc_halt "dd if=/dev/random of=${GELIKEYDIR}/${PART}.key bs=64 count=1" - rc_halt "geli init -J ${PARTDIR}-enc/${PART}-encpass ${PARTDEV}" - rc_halt "geli attach -j ${PARTDIR}-enc/${PART}-encpass ${PARTDEV}" - else - # No Encryption password, use key file - rc_halt "dd if=/dev/random of=${GELIKEYDIR}/${PART}.key bs=64 count=1" - rc_halt "geli init -b -s 4096 -P -K ${GELIKEYDIR}/${PART}.key ${PARTDEV}" - rc_halt "geli attach -p -k ${GELIKEYDIR}/${PART}.key ${PARTDEV}" - - fi - - EXT=".eli" - else - # No Encryption - EXT="" - fi - - case ${PARTFS} in - UFS) - echo_log "NEWFS: ${PARTDEV} - ${PARTFS}" - sleep 2 - rc_halt "newfs -t ${PARTXTRAOPTS} ${PARTDEV}${EXT}" - sleep 2 - rc_halt "sync" - rc_halt "glabel label ${PARTLABEL} ${PARTDEV}${EXT}" - rc_halt "sync" - - # Set flag that we've found a boot partition - if [ "$PARTMNT" = "/boot" -o "${PARTMNT}" = "/" ] ; then - HAVEBOOT="YES" - fi - sleep 2 - ;; - - UFS+S) - echo_log "NEWFS: ${PARTDEV} - ${PARTFS}" - sleep 2 - rc_halt "newfs -t ${PARTXTRAOPTS} -U ${PARTDEV}${EXT}" - sleep 2 - rc_halt "sync" - rc_halt "glabel label ${PARTLABEL} ${PARTDEV}${EXT}" - rc_halt "sync" - # Set flag that we've found a boot partition - if [ "$PARTMNT" = "/boot" -o "${PARTMNT}" = "/" ] ; then - HAVEBOOT="YES" - fi - sleep 2 - ;; - - UFS+SUJ) - echo_log "NEWFS: ${PARTDEV} - ${PARTFS}" - sleep 2 - rc_halt "newfs -t ${PARTXTRAOPTS} -U ${PARTDEV}${EXT}" - sleep 2 - rc_halt "sync" - rc_halt "tunefs -j enable ${PARTDEV}${EXT}" - sleep 2 - rc_halt "sync" - rc_halt "glabel label ${PARTLABEL} ${PARTDEV}${EXT}" - rc_halt "sync" - # Set flag that we've found a boot partition - if [ "$PARTMNT" = "/boot" -o "${PARTMNT}" = "/" ] ; then - HAVEBOOT="YES" - fi - sleep 2 - ;; - - - UFS+J) - echo_log "NEWFS: ${PARTDEV} - ${PARTFS}" - sleep 2 - rc_halt "newfs ${PARTDEV}${EXT}" - sleep 2 - rc_halt "gjournal label -f ${PARTDEV}${EXT}" - sleep 2 - rc_halt "newfs ${PARTXTRAOPTS} -O 2 -J ${PARTDEV}${EXT}.journal" - sleep 2 - rc_halt "sync" - rc_halt "glabel label ${PARTLABEL} ${PARTDEV}${EXT}.journal" - rc_halt "sync" - # Set flag that we've found a boot partition - if [ "$PARTMNT" = "/boot" -o "${PARTMNT}" = "/" ] ; then - HAVEBOOT="YES" - fi - sleep 2 - ;; - - ZFS) - echo_log "NEWFS: ${PARTDEV} - ${PARTFS}" - setup_zfs_filesystem "${PARTDEV}" "${PARTFS}" "${PARTMNT}" "${EXT}" "${PARTGEOM}" "${PARTXTRAOPTS}" - ;; - - SWAP) - rc_halt "sync" - rc_halt "glabel label ${PARTLABEL} ${PARTDEV}${EXT}" - rc_halt "sync" - sleep 2 - ;; - - IMAGE) - write_image "${PARTIMAGE}" "${PARTDEV}" - sleep 2 - ;; - - *) exit_err "ERROR: Got unknown file-system type $PARTFS" ;; - esac - - done -}; diff --git a/usr.sbin/pc-sysinstall/backend/functions-packages.sh b/usr.sbin/pc-sysinstall/backend/functions-packages.sh deleted file mode 100755 index 49b3e8124b8..00000000000 --- a/usr.sbin/pc-sysinstall/backend/functions-packages.sh +++ /dev/null @@ -1,412 +0,0 @@ -#!/bin/sh -#- -# SPDX-License-Identifier: BSD-2-Clause-FreeBSD -# -# Copyright (c) 2010 iXsystems, Inc. All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions -# are met: -# 1. Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# 2. Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# -# THIS SOFTWARE IS PROVIDED BY 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. -# - -# Functions which runs commands on the system - -. ${BACKEND}/functions.sh -. ${BACKEND}/functions-parse.sh -. ${BACKEND}/functions-ftp.sh - - -get_package_index_by_ftp() -{ - local INDEX_FILE - local FTP_SERVER - - FTP_SERVER="${1}" - INDEX_FILE="INDEX" - USE_BZIP2=0 - - if [ -f "/usr/bin/bzip2" ] - then - INDEX_FILE="${INDEX_FILE}.bz2" - USE_BZIP2=1 - INDEX_PATH="${INDEXFILE}.bz2" - else - INDEX_PATH="${INDEXFILE}" - fi - - fetch_file "${FTP_SERVER}/${INDEX_FILE}" "${INDEX_PATH}" "1" - if [ -f "${INDEX_PATH}" ] && [ "${USE_BZIP2}" -eq "1" ] - then - bzip2 -d "${INDEX_PATH}" - fi -}; - -get_package_index_by_fs() -{ - if [ "$INSTALLMEDIUM" = "local" ] ; then - INDEXFILE="${LOCALPATH}/packages/INDEX" - else - INDEXFILE="${CDMNT}/packages/INDEX" - fi -}; - -get_package_index_size() -{ - if [ -f "${INDEXFILE}" ] - then - SIZE=`ls -l ${INDEXFILE} | awk '{ print $5 }'` - else - get_ftp_mirror - FTPHOST="${VAL}" - - FTPDIR="/pub/FreeBSD/releases/${FBSD_ARCH}/${FBSD_BRANCH}" - FTPPATH="ftp://${FTPHOST}${FTPDIR}/packages" - - fetch -s "${FTPPATH}/INDEX.bz2" - fi -}; - -get_package_index() -{ - RES=0 - - if [ -z "${INSTALLMODE}" ] - then - get_ftp_mirror - FTPHOST="${VAL}" - - FTPDIR="/pub/FreeBSD/releases/${FBSD_ARCH}/${FBSD_BRANCH}" - FTPPATH="ftp://${FTPHOST}${FTPDIR}/packages" - - get_package_index_by_ftp "${FTPPATH}" - - else - - case "${INSTALLMEDIUM}" in - usb|dvd|local) get_package_index_by_fs ;; - ftp) get_value_from_cfg ftpHost - if [ -z "$VAL" ]; then - exit_err "ERROR: Install medium was set to ftp, but no ftpHost was provided!" - fi - FTPHOST="${VAL}" - - get_value_from_cfg ftpDir - if [ -z "$VAL" ]; then - exit_err "ERROR: Install medium was set to ftp, but no ftpDir was provided!" - fi - FTPDIR="${VAL}" - FTPPATH="ftp://${FTPHOST}${FTPDIR}" - get_package_index_by_ftp "${FTPPATH}" ;; - sftp) ;; - *) RES=1 ;; - esac - - fi - - return ${RES} -}; - -parse_package_index() -{ - echo_log "Building package dep list.. Please wait.." - INDEX_FILE="${PKGDIR}/INDEX" - - exec 3<&0 - exec 0<"${INDEXFILE}" - - while read -r line - do - PKGNAME="" - CATEGORY="" - PACKAGE="" - DESC="" - DEPS="" - i=0 - - SAVE_IFS="${IFS}" - IFS="|" - - for part in ${line} - do - if [ ${i} -eq 0 ] - then - PKGNAME="${part}" - - elif [ ${i} -eq 1 ] - then - PACKAGE=`basename "${part}"` - - elif [ ${i} -eq 3 ] - then - DESC="${part}" - - elif [ ${i} -eq 6 ] - then - CATEGORY=`echo "${part}" | cut -f1 -d' '` - - elif [ ${i} -eq 8 ] - then - DEPS="${part}" - fi - - i=$((i+1)) - done - - echo "${CATEGORY}|${PACKAGE}|${DESC}" >> "${INDEX_FILE}.parsed" - echo "${PACKAGE}|${PKGNAME}|${DEPS}" >> "${INDEX_FILE}.deps" - - IFS="${SAVE_IFS}" - done - - exec 0<&3 -}; - -show_package_file() -{ - PKGFILE="${1}" - - echo "Available Packages:" - - exec 3<&0 - exec 0<"${PKGFILE}" - - while read -r line - do - CATEGORY=`echo "${line}" | cut -f1 -d'|'` - PACKAGE=`echo "${line}" | cut -f2 -d'|'` - DESC=`echo "${line}" | cut -f3 -d'|'` - - echo "${CATEGORY}/${PACKAGE}:${DESC}" - done - - exec 0<&3 -}; - -show_packages_by_category() -{ - CATEGORY="${1}" - INDEX_FILE="${PKGDIR}/INDEX.parsed" - TMPFILE="/tmp/.pkg.cat" - - grep "^${CATEGORY}|" "${INDEX_FILE}" > "${TMPFILE}" - show_package_file "${TMPFILE}" - rm "${TMPFILE}" -}; - -show_package_by_name() -{ - CATEGORY="${1}" - PACKAGE="${2}" - INDEX_FILE="${PKGDIR}/INDEX.parsed" - TMPFILE="/tmp/.pkg.cat.pak" - - grep "^${CATEGORY}|${PACKAGE}" "${INDEX_FILE}" > "${TMPFILE}" - show_package_file "${TMPFILE}" - rm "${TMPFILE}" -}; - -show_packages() -{ - show_package_file "${PKGDIR}/INDEX.parsed" -}; - -get_package_dependencies() -{ - PACKAGE="${1}" - LONG="${2:-0}" - RES=0 - - INDEX_FILE="${PKGDIR}/INDEX.deps" - REGEX="^${PACKAGE}|" - - if [ ${LONG} -ne 0 ] - then - REGEX="^.*|${PACKAGE}|" - fi - - LINE=`grep "${REGEX}" "${INDEX_FILE}" 2>/dev/null` - DEPS=`echo "${LINE}"|cut -f3 -d'|'` - - export VAL="${DEPS}" - - if [ -z "${VAL}" ] - then - RES=1 - fi - - return ${RES} -}; - -get_package_name() -{ - PACKAGE="${1}" - RES=0 - local PKGPTH - - # If we are on a local medium, we can parse the Latest/ directory - if [ "${INSTALLMEDIUM}" != "ftp" ] ; then - case "${INSTALLMEDIUM}" in - usb|dvd) PKGPTH="${CDMNT}/packages" ;; - *) PKGPTH="${LOCALPATH}/packages" ;; - esac - - # Check the /Latest dir for generic names, then look for specific version in All/ - if [ -e "${PKGPTH}/Latest/${PACKAGE}.${PKGEXT}" ] ; then - NAME=`ls -al ${PKGPTH}/Latest/${PACKAGE}.${PKGEXT} 2>/dev/null | cut -d '>' -f 2 | rev | cut -f1 -d'/' | rev | tr -s ' '` - else - NAME=`ls -al ${PKGPTH}/All/${PACKAGE}.${PKGEXT} 2>/dev/null | cut -d '>' -f 2 | rev | cut -f1 -d'/' | rev | tr -s ' '` - fi - export VAL="${NAME}" - else - # Doing remote fetch, we we will look up, but some generic names like - # "perl" wont work, since we don't know the default version - INDEX_FILE="${PKGDIR}/INDEX.deps" - REGEX="^${PACKAGE}|" - - LINE=`grep "${REGEX}" "${INDEX_FILE}" 2>/dev/null` - NAME=`echo "${LINE}"|cut -f2 -d'|'` - - export VAL="${NAME}" - fi - - if [ -z "${VAL}" ] - then - RES=1 - fi - return ${RES} -}; - -get_package_short_name() -{ - PACKAGE="${1}" - RES=0 - - INDEX_FILE="${PKGDIR}/INDEX.deps" - REGEX="^.*|${PACKAGE}|" - - LINE=`grep "${REGEX}" "${INDEX_FILE}" 2>/dev/null` - NAME=`echo "${LINE}"|cut -f1 -d'|'` - - export VAL="${NAME}" - - if [ -z "${VAL}" ] - then - RES=1 - fi - - return ${RES} -}; - -get_package_category() -{ - PACKAGE="${1}" - INDEX_FILE="${PKGDIR}/INDEX.parsed" - RES=0 - - LINE=`grep "|${PACKAGE}|" "${INDEX_FILE}" 2>/dev/null` - NAME=`echo "${LINE}"|cut -f1 -d'|'` - - export VAL="${NAME}" - - if [ -z "${VAL}" ] - then - RES=1 - fi - - return ${RES} -}; - -fetch_package_by_ftp() -{ - CATEGORY="${1}" - PACKAGE="${2}" - SAVEDIR="${3}" - - get_value_from_cfg ftpHost - if [ -z "$VAL" ] - then - exit_err "ERROR: Install medium was set to ftp, but no ftpHost was provided!" - fi - FTPHOST="${VAL}" - - get_value_from_cfg ftpDir - if [ -z "$VAL" ] - then - exit_err "ERROR: Install medium was set to ftp, but no ftpDir was provided!" - fi - FTPDIR="${VAL}" - - PACKAGE="${PACKAGE}.${PKGEXT}" - FTP_SERVER="ftp://${FTPHOST}${FTPDIR}" - - if [ ! -f "${SAVEDIR}/${PACKAGE}" ] - then - PKGPATH="${CATEGORY}/${PACKAGE}" - FTP_PATH="${FTP_HOST}/packages/${PKGPATH}" - fetch_file "${FTP_PATH}" "${SAVEDIR}/" "0" - fi -}; - -fetch_package() -{ - CATEGORY="${1}" - PACKAGE="${2}" - SAVEDIR="${3}" - - # Fetch package, but skip if installing from local media - case "${INSTALLMEDIUM}" in - usb|dvd|local) return ;; - ftp) fetch_package_by_ftp "${CATEGORY}" "${PACKAGE}" "${SAVEDIR}" ;; - sftp) ;; - esac -}; - -bootstrap_pkgng() -{ - # Check if we need to boot-strap pkgng - if run_chroot_cmd "which pkg-static" >/dev/null 2>/dev/null - then - return - fi - local PKGPTH - - # Ok, lets boot-strap this sucker - echo_log "Bootstraping pkgng.." - fetch_package "Latest" "pkg" "${PKGDLDIR}" - - # Figure out real location of "pkg" package - case "${INSTALLMEDIUM}" in - usb|dvd|local) PKGPTH="${PKGTMPDIR}/Latest/pkg.${PKGEXT}" ;; - *) PKGPTH="${PKGTMPDIR}/pkg.${PKGEXT}" ;; - esac - rc_halt "pkg -c ${FSMNT} add ${PKGPTH}" ; run_chroot_cmd "pkg2ng" -} - -get_package_location() -{ - case "${INSTALLMEDIUM}" in - usb|dvd) rc_halt "mount_nullfs ${CDMNT}/packages ${FSMNT}${PKGTMPDIR}" - PKGDLDIR="${FSMNT}${PKGTMPDIR}/All" ;; - local) rc_halt "mount_nullfs ${LOCALPATH}/packages ${FSMNT}${PKGTMPDIR}" - PKGDLDIR="${FSMNT}${PKGTMPDIR}/All" ;; - *) PKGDLDIR="${FSMNT}${PKGTMPDIR}" ;; - esac - export PKGDLDIR -} diff --git a/usr.sbin/pc-sysinstall/backend/functions-parse.sh b/usr.sbin/pc-sysinstall/backend/functions-parse.sh deleted file mode 100755 index de22555fbb6..00000000000 --- a/usr.sbin/pc-sysinstall/backend/functions-parse.sh +++ /dev/null @@ -1,230 +0,0 @@ -#!/bin/sh -#- -# SPDX-License-Identifier: BSD-2-Clause-FreeBSD -# -# Copyright (c) 2010 iXsystems, Inc. All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions -# are met: -# 1. Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# 2. Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# -# THIS SOFTWARE IS PROVIDED BY 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. -# - -# functions.sh -# Library of functions which pc-sysinstall may call upon for parsing the config - -# which gets the value of a setting in the provided line -get_value_from_string() -{ - if [ -n "${1}" ] - then - export VAL="`echo ${1} | cut -d '=' -f 2-`" - else - echo "Error: Did we forgot to supply a string to parse?" - exit 1 - fi -}; - -# Get the value from the cfg file including spaces -get_value_from_cfg_with_spaces() -{ - if [ -n "${1}" ] - then - export VAL="`grep ^${1}= ${CFGF} | head -n 1 | cut -d '=' -f 2-`" - else - exit_err "Error: Did we forgot to supply a setting to grab?" - fi -}; - - -# Get the value from the cfg file -get_value_from_cfg() -{ - if [ -n "${1}" ] - then - export VAL=`grep "^${1}=" ${CFGF} | head -n 1 | cut -d '=' -f 2- | tr -d ' '` - else - exit_err "Error: Did we forgot to supply a setting to grab?" - fi -}; - -# Checks the value of a setting in the provided line with supplied possibilities -# 1 = setting we are checking, 2 = list of valid values -if_check_value_exists() -{ - if [ -n "${1}" -a -n "${2}" ] - then - # Get the first occurrence of the setting from the config, strip out whitespace - - VAL=`grep "^${1}" ${CFGF} | head -n 1 | cut -d '=' -f 2- | tr -d ' '` - if [ -z "${VAL}" ] - then - # This value doesn't exist, lets return - return 0 - fi - - - VALID="1" - for i in ${2} - do - VAL=`echo "$VAL"|tr A-Z a-z` - if [ "$VAL" = "${i}" ] - then - VALID="0" - fi - done - if [ "$VALID" = "1" ] - then - exit_err "Error: ${1} is set to unknown value $VAL" - fi - else - exit_err "Error: Did we forgot to supply a string to parse and setting to grab?" - fi -}; - -# Checks the value of a setting in the provided line with supplied possibilities -# 1 = setting we are checking, 2 = list of valid values -check_value() -{ - if [ -n "${1}" -a -n "${2}" ] - then - # Get the first occurrence of the setting from the config, strip out whitespace - VAL=`grep "^${1}" ${CFGF} | head -n 1 | cut -d '=' -f 2- | tr -d ' '` - VALID="1" - for i in ${2} - do - if [ "$VAL" = "${i}" ] - then - VALID="0" - fi - done - if [ "$VALID" = "1" ] - then - exit_err "Error: ${1} is set to unknown value $VAL" - fi - else - exit_err "Error: Did we forgot to supply a string to parse and setting to grab?" - fi -}; - -# Checks for the presence of the supplied arguments in the config file -# 1 = values to confirm exist -file_sanity_check() -{ - if [ -n "$CFGF" -a -n "$1" ] - then - for i in $1 - do - grep -q "^${i}=" $CFGF 2>/dev/null - if [ $? -eq 0 ] - then - LN=`grep "^${i}=" ${CFGF} | head -n 1 | cut -d '=' -f 2- | tr -d ' '` - if [ -z "${LN}" ] - then - echo "Error: Config fails sanity test! ${i}= is empty" - exit 1 - fi - else - echo "Error: Config fails sanity test! Missing ${i}=" - exit 1 - fi - done - else - echo "Error: Missing config file, and / or values to sanity check for!" - exit 1 - fi -}; - - -# Function which merges the contents of a new config into the specified old one -# Only works with = type configurations -merge_config() -{ - OLDCFG="${1}" - NEWCFG="${2}" - FINALCFG="${3}" - - # Copy our oldcfg to the new one, which will be used as basis - cp ${OLDCFG} ${FINALCFG} - - # Remove blank lines from new file - cat ${NEWCFG} | sed '/^$/d' > ${FINALCFG}.tmp - - # Set our marker if we've found any - FOUNDMERGE="NO" - - while read newline - do - echo ${newline} | grep -q "^#" 2>/dev/null - if [ $? -ne 0 ] ; then - VAL="`echo ${newline} | cut -d '=' -f 1`" - cat ${OLDCFG} | grep -q ${VAL} 2>/dev/null - if [ $? -ne 0 ] ; then - if [ "${FOUNDMERGE}" = "NO" ] ; then - echo "" >> ${FINALCFG} - echo "# Auto-merged values from newer ${NEWCFG}" >> ${FINALCFG} - FOUNDMERGE="YES" - fi - echo "${newline}" >> ${FINALCFG} - fi - fi - done < ${FINALCFG}.tmp - rm ${FINALCFG}.tmp - -}; - -# Loop to check for a specified mount-point in a list -check_for_mount() -{ - MNTS="${1}" - FINDMNT="${2}" - - # Check if we found a valid root partition - for CHECKMNT in `echo ${MNTS} | sed 's|,| |g'` - do - if [ "${CHECKMNT}" = "${FINDMNT}" ] ; then - return 0 - fi - done - - return 1 -}; - -# Function which returns the next line in the specified config file -get_next_cfg_line() -{ - CURFILE="$1" - CURLINE="$2" - - FOUND="1" - - while read line - do - if [ "$FOUND" = "0" ] ; then - export VAL="$line" - return - fi - if [ "$line" = "${CURLINE}" ] ; then - FOUND="0" - fi - done <${CURFILE} - - # Got here, couldn't find this line or at end of file, set VAL to "" - export VAL="" -}; diff --git a/usr.sbin/pc-sysinstall/backend/functions-runcommands.sh b/usr.sbin/pc-sysinstall/backend/functions-runcommands.sh deleted file mode 100755 index 87af04bed65..00000000000 --- a/usr.sbin/pc-sysinstall/backend/functions-runcommands.sh +++ /dev/null @@ -1,111 +0,0 @@ -#!/bin/sh -#- -# SPDX-License-Identifier: BSD-2-Clause-FreeBSD -# -# Copyright (c) 2010 iXsystems, Inc. All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions -# are met: -# 1. Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# 2. Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# -# THIS SOFTWARE IS PROVIDED BY 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. -# - -# Functions which runs commands on the system - -. ${BACKEND}/functions.sh -. ${BACKEND}/functions-parse.sh - -run_chroot_cmd() -{ - CMD="$@" - echo_log "Running chroot command: ${CMD}" - echo "$CMD" >${FSMNT}/.runcmd.sh - chmod 755 ${FSMNT}/.runcmd.sh - chroot ${FSMNT} sh /.runcmd.sh - RES=$? - - rm ${FSMNT}/.runcmd.sh - return ${RES} -}; - -run_chroot_script() -{ - SCRIPT="$@" - SBASE=`basename $SCRIPT` - - cp ${SCRIPT} ${FSMNT}/.$SBASE - chmod 755 ${FSMNT}/.${SBASE} - - echo_log "Running chroot script: ${SCRIPT}" - chroot ${FSMNT} /.${SBASE} - RES=$? - - rm ${FSMNT}/.${SBASE} - return ${RES} -}; - - -run_ext_cmd() -{ - CMD="$@" - # Make sure to export FSMNT, in case cmd needs it - export FSMNT - echo_log "Running external command: ${CMD}" - echo "${CMD}"> ${TMPDIR}/.runcmd.sh - chmod 755 ${TMPDIR}/.runcmd.sh - sh ${TMPDIR}/.runcmd.sh - RES=$? - - rm ${TMPDIR}/.runcmd.sh - return ${RES} -}; - - -# Starts the user setup -run_commands() -{ - while read line - do - # Check if we need to run any chroot command - echo $line | grep -q ^runCommand= 2>/dev/null - if [ $? -eq 0 ] - then - get_value_from_string "$line" - run_chroot_cmd "$VAL" - fi - - # Check if we need to run any chroot script - echo $line | grep -q ^runScript= 2>/dev/null - if [ $? -eq 0 ] - then - get_value_from_string "$line" - run_chroot_script "$VAL" - fi - - # Check if we need to run any chroot command - echo $line | grep -q ^runExtCommand= 2>/dev/null - if [ $? -eq 0 ] - then - get_value_from_string "$line" - run_ext_cmd "$VAL" - fi - - done <${CFGF} - -}; diff --git a/usr.sbin/pc-sysinstall/backend/functions-unmount.sh b/usr.sbin/pc-sysinstall/backend/functions-unmount.sh deleted file mode 100755 index da0d1645c46..00000000000 --- a/usr.sbin/pc-sysinstall/backend/functions-unmount.sh +++ /dev/null @@ -1,211 +0,0 @@ -#!/bin/sh -#- -# SPDX-License-Identifier: BSD-2-Clause-FreeBSD -# -# Copyright (c) 2010 iXsystems, Inc. All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions -# are met: -# 1. Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# 2. Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# -# THIS SOFTWARE IS PROVIDED BY 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. -# - -# Functions which unmount all mounted disk filesystems - -# Unmount all mounted partitions under specified dir -umount_all_dir() -{ - _udir="$1" - _umntdirs=`mount | sort -r | grep "on $_udir" | cut -d ' ' -f 3` - for _ud in $_umntdirs - do - umount -f ${_ud} - done -} - -# Script that adds our gmirror devices for syncing -start_gmirror_sync() -{ - - cd ${MIRRORCFGDIR} - for DISK in `ls ${MIRRORCFGDIR}` - do - MIRRORDISK="`cat ${DISK} | cut -d ':' -f 1`" - MIRRORBAL="`cat ${DISK} | cut -d ':' -f 2`" - MIRRORNAME="`cat ${DISK} | cut -d ':' -f 3`" - - # Start the mirroring service - rc_nohalt "gmirror forget ${MIRRORNAME}" - rc_halt "gmirror insert ${MIRRORNAME} ${MIRRORDISK}" - - done - -}; - -# Unmounts all our mounted file-systems -unmount_all_filesystems() -{ - # Copy the logfile to disk before we unmount - cp ${LOGOUT} ${FSMNT}/root/pc-sysinstall.log - cd / - - # Start by unmounting any ZFS partitions - zfs_cleanup_unmount - - # Lets read our partition list, and unmount each - ################################################################## - for PART in `ls ${PARTDIR}` - do - PARTDEV=`echo $PART | sed 's|-|/|g'` - PARTFS="`cat ${PARTDIR}/${PART} | cut -d '#' -f 1`" - PARTMNT="`cat ${PARTDIR}/${PART} | cut -d '#' -f 2`" - PARTENC="`cat ${PARTDIR}/${PART} | cut -d '#' -f 3`" - PARTLABEL="`cat ${PARTDIR}/${PART} | cut -d '#' -f 4`" - - if [ "${PARTENC}" = "ON" ] - then - EXT=".eli" - else - EXT="" - fi - - if [ "${PARTFS}" = "SWAP" ] - then - rc_nohalt "swapoff ${PARTDEV}${EXT}" - fi - - # Check if we've found "/", and unmount that last - if [ "$PARTMNT" != "/" -a "${PARTMNT}" != "none" -a "${PARTFS}" != "ZFS" ] - then - rc_halt "umount -f ${PARTDEV}${EXT}" - - # Re-check if we are missing a label for this device and create it again if so - if [ ! -e "/dev/label/${PARTLABEL}" ] - then - case ${PARTFS} in - UFS) glabel label ${PARTLABEL} ${PARTDEV}${EXT} ;; - UFS+S) glabel label ${PARTLABEL} ${PARTDEV}${EXT} ;; - UFS+SUJ) glabel label ${PARTLABEL} ${PARTDEV}${EXT} ;; - UFS+J) glabel label ${PARTLABEL} ${PARTDEV}${EXT}.journal ;; - *) ;; - esac - fi - fi - - # Check if we've found "/" and make sure the label exists - if [ "$PARTMNT" = "/" -a "${PARTFS}" != "ZFS" ] - then - if [ ! -e "/dev/label/${PARTLABEL}" ] - then - case ${PARTFS} in - UFS) ROOTRELABEL="glabel label ${PARTLABEL} ${PARTDEV}${EXT}" ;; - UFS+S) ROOTRELABEL="glabel label ${PARTLABEL} ${PARTDEV}${EXT}" ;; - UFS+SUJ) ROOTRELABEL="glabel label ${PARTLABEL} ${PARTDEV}${EXT}" ;; - UFS+J) ROOTRELABEL="glabel label ${PARTLABEL} ${PARTDEV}${EXT}.journal" ;; - *) ;; - esac - fi - fi - done - - # Last lets the /mnt partition - ######################################################### - rc_nohalt "umount -f ${FSMNT}" - - # If are using a ZFS on "/" set it to legacy - if [ ! -z "${FOUNDZFSROOT}" ] - then - rc_halt "zfs set mountpoint=legacy ${FOUNDZFSROOT}" - fi - - # If we need to relabel "/" do it now - if [ ! -z "${ROOTRELABEL}" ] - then - ${ROOTRELABEL} - fi - - # Unmount our CDMNT - rc_nohalt "umount -f ${CDMNT}" >/dev/null 2>/dev/null - - # Check if we need to run any gmirror syncing - ls ${MIRRORCFGDIR}/* >/dev/null 2>/dev/null - if [ $? -eq 0 ] - then - # Lets start syncing now - start_gmirror_sync - fi - -}; - -# Unmounts any filesystems after a failure -unmount_all_filesystems_failure() -{ - cd / - - # if we did a fresh install, start unmounting - if [ "${INSTALLMODE}" = "fresh" ] - then - - # Lets read our partition list, and unmount each - ################################################################## - if [ -d "${PARTDIR}" ] - then - for PART in `ls ${PARTDIR}` - do - PARTDEV=`echo $PART | sed 's|-|/|g'` - PARTFS="`cat ${PARTDIR}/${PART} | cut -d '#' -f 1`" - PARTMNT="`cat ${PARTDIR}/${PART} | cut -d '#' -f 2`" - PARTENC="`cat ${PARTDIR}/${PART} | cut -d '#' -f 3`" - - if [ "${PARTFS}" = "SWAP" ] - then - if [ "${PARTENC}" = "ON" ] - then - swapoff ${PARTDEV}.eli >/dev/null 2>/dev/null - else - swapoff ${PARTDEV} >/dev/null 2>/dev/null - fi - fi - - # Check if we've found "/" again, don't need to mount it twice - if [ "$PARTMNT" != "/" -a "${PARTMNT}" != "none" -a "${PARTFS}" != "ZFS" ] - then - umount -f ${PARTDEV} >/dev/null 2>/dev/null - umount -f ${FSMNT}${PARTMNT} >/dev/null 2>/dev/null - fi - done - - # Last lets the /mnt partition - ######################################################### - umount -f ${FSMNT} >/dev/null 2>/dev/null - - fi - else - # We are doing a upgrade, try unmounting any of these filesystems - chroot ${FSMNT} /sbin/umount -a >/dev/null 2>/dev/null - umount -f ${FSMNT}/usr >/dev/null 2>/dev/null - umount -f ${FSMNT}/dev >/dev/null 2>/dev/null - umount -f ${FSMNT} >/dev/null 2>/dev/null - sh ${TMPDIR}/.upgrade-unmount >/dev/null 2>/dev/null - fi - - # Unmount our CDMNT - umount ${CDMNT} >/dev/null 2>/dev/null - -}; diff --git a/usr.sbin/pc-sysinstall/backend/functions-upgrade.sh b/usr.sbin/pc-sysinstall/backend/functions-upgrade.sh deleted file mode 100755 index 2986a414d18..00000000000 --- a/usr.sbin/pc-sysinstall/backend/functions-upgrade.sh +++ /dev/null @@ -1,248 +0,0 @@ -#!/bin/sh -#- -# SPDX-License-Identifier: BSD-2-Clause-FreeBSD -# -# Copyright (c) 2010 iXsystems, Inc. All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions -# are met: -# 1. Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# 2. Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# -# THIS SOFTWARE IS PROVIDED BY 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. -# - -# Functions which perform the mounting / unmount for upgrades - -. ${PROGDIR}/backend/functions-unmount.sh - -mount_target_slice() -{ - MPART="${1}" - - # Import any zpools - zpool import -o altroot=${FSMNT} -a - umount_all_dir "${FSMNT}" - - # Set a variable of files we want to make backups of before doing upgrade - BKFILES="/etc/rc.conf /boot/loader.conf" - - if [ -e "/dev/${MPART}" ] ; then - rc_nohalt "mount /dev/${MPART} ${FSMNT}" - if [ $? -ne 0 ] ; then - # Check if we have ZFS tank name - rc_halt "mount -t zfs ${MPART} ${FSMNT}" - fi - else - # Check if we have ZFS tank name - rc_halt "mount -t zfs ${MPART} ${FSMNT}" - fi - - # Mount devfs in chroot - mount -t devfs devfs ${FSMNT}/dev - - # Check if we have any ZFS partitions to mount - zfs mount -a - - # Mount all the fstab goodies on disk - chroot ${FSMNT} /sbin/mount -a -t nolinprocfs >>${LOGOUT} 2>>${LOGOUT} - chroot ${FSMNT} umount /proc >/dev/null 2>/dev/null - chroot ${FSMNT} umount /compat/linux/proc >/dev/null 2>/dev/null - - # Now before we start the upgrade, make sure we set our noschg flags - echo_log "Cleaning up old filesystem... Please wait..." - rc_halt "chflags -R noschg ${FSMNT}" - - # Make backup copies of some files - for i in ${BKFILES} - do - cp ${FSMNT}${i} ${FSMNT}${i}.preUpgrade >/dev/null 2>/dev/null - done - - # Remove some old dirs - rm -rf ${FSMNT}/etc/rc.d >/dev/null 2>/dev/null - - # If we are doing PC-BSD install, lets cleanup old pkgs on disk - if [ "$INSTALLTYPE" != "FreeBSD" ] - then - echo_log "Removing old packages, this may take a while... Please wait..." - echo '#!/bin/sh -for i in `pkg_info -aE` -do - echo "Uninstalling package: ${i}" - pkg_delete -f ${i} >/dev/null 2>/dev/null -done -' >${FSMNT}/.cleanPkgs.sh - chmod 755 ${FSMNT}/.cleanPkgs.sh - chroot ${FSMNT} /.cleanPkgs.sh - rm ${FSMNT}/.cleanPkgs.sh - run_chroot_cmd "pkg_delete -f \*" >/dev/null 2>/dev/null - run_chroot_cmd "rm -rf /usr/PCBSD" >/dev/null 2>/dev/null - run_chroot_cmd "rm -rf /PCBSD" >/dev/null 2>/dev/null - run_chroot_cmd "rm -rf /var/db/pkgs" >/dev/null 2>/dev/null - run_chroot_cmd "rm -rf /usr/local32" >/dev/null 2>/dev/null - run_chroot_cmd "rm -rf /usr/sbin" >/dev/null 2>/dev/null - run_chroot_cmd "rm -rf /usr/lib" >/dev/null 2>/dev/null - run_chroot_cmd "rm -rf /usr/bin" >/dev/null 2>/dev/null - run_chroot_cmd "rm -rf /boot/kernel" >/dev/null 2>/dev/null - run_chroot_cmd "rm -rf /sbin" >/dev/null 2>/dev/null - run_chroot_cmd "rm -rf /bin" >/dev/null 2>/dev/null - run_chroot_cmd "rm -rf /lib" >/dev/null 2>/dev/null - run_chroot_cmd "rm -rf /libexec" >/dev/null 2>/dev/null - fi - -}; - -# Mount the target upgrade partitions -mount_upgrade() -{ - - # Make sure we remove the old upgrade-mount script - rm -rf ${TMPDIR}/.upgrade-unmount >/dev/null 2>/dev/null - - # We are ready to start mounting, lets read the config and do it - while read line - do - echo $line | grep -q "^disk0=" 2>/dev/null - if [ $? -eq 0 ] - then - - # Found a disk= entry, lets get the disk we are working on - get_value_from_string "${line}" - strip_white_space "$VAL" - DISK="$VAL" - fi - - echo $line | grep -q "^commitDiskPart" 2>/dev/null - if [ $? -eq 0 ] - then - # Found our flag to commit this disk setup / lets do sanity check and do it - if [ -n "${DISK}" ] - then - - # Start mounting this slice - mount_target_slice "${DISK}" - - # Increment our disk counter to look for next disk and unset - unset DISK - break - else - exit_err "ERROR: commitDiskPart was called without procceding disk= and partition= entries!!!" - fi - fi - - done <${CFGF} - -}; - -copy_skel_files_upgrade() -{ - - # Now make sure we fix any user profile scripts, which cause problems from 7.x->8.x - echo '#!/bin/sh - -cd /home -for i in `ls` -do - - # Backup the old profile dirs - if [ -d "${i}" ] - then - mv /home/${i}/.kde4 /home/${i}/.kde4.preUpgrade >/dev/null 2>/dev/null - mv /home/${i}/.kde /home/${i}/.kde.preUpgrade >/dev/null 2>/dev/null - mv /home/${i}/.fluxbox /home/${i}/.fluxbox.preUpgrade >/dev/null 2>/dev/null - - # Copy over the skel directories - tar cv --exclude "./dot.*" -f - -C /usr/share/skel . 2>/dev/null | tar xvf - -C /home/${i} 2>/dev/null - - for j in `ls /usr/share/skel/dot*` - do - dname=`echo ${j} | sed s/dot//` - cp /usr/share/skel/${j} /home/${i}/${dname} - done - - chown -R ${i}:${i} /home/${i} - fi - -done -' >${FSMNT}/.fixUserProfile.sh - chmod 755 ${FSMNT}/.fixUserProfile.sh - chroot ${FSMNT} /.fixUserProfile.sh >/dev/null 2>/dev/null - rm ${FSMNT}/.fixUserProfile.sh - - - - # if the user wants to keep their original .kde4 profile - ########################################################################### - get_value_from_cfg "upgradeKeepDesktopProfile" - if [ "$VAL" = "YES" -o "$VAL" = "yes" ] ; then - echo '#!/bin/sh - cd /home -for i in `ls` -do - # Import the old config again - if [ -d "${i}/.kde4.preUpgrade" ] - then - # Copy over the skel directories - tar cv -f - -C /home/${i}/.kde4.preUpgrade . 2>/dev/null | tar xvf - -C /home/${i}/.kde4 2>/dev/null - chown -R ${i}:${i} /home/${i}/.kde4 - fi -done -' >${FSMNT}/.fixUserProfile.sh - chmod 755 ${FSMNT}/.fixUserProfile.sh - chroot ${FSMNT} /.fixUserProfile.sh >/dev/null 2>/dev/null - rm ${FSMNT}/.fixUserProfile.sh - - fi - -}; - -# Function which merges some configuration files with the new defaults -merge_old_configs() -{ - - # Merge the loader.conf with old - cp ${FSMNT}/boot/loader.conf ${FSMNT}/boot/loader.conf.new - merge_config "${FSMNT}/boot/loader.conf.preUpgrade" "${FSMNT}/boot/loader.conf.new" "${FSMNT}/boot/loader.conf" - rm ${FSMNT}/boot/loader.conf.new - - # Merge the rc.conf with old - cp ${FSMNT}/etc/rc.conf ${FSMNT}/etc/rc.conf.new - merge_config "${FSMNT}/etc/rc.conf.preUpgrade" "${FSMNT}/etc/rc.conf.new" "${FSMNT}/etc/rc.conf" - rm ${FSMNT}/etc/rc.conf.new - -}; - -# Function which unmounts all the mounted file-systems -unmount_upgrade() -{ - - # If on PC-BSD, make sure we copy any fixed skel files - if [ "$INSTALLTYPE" != "FreeBSD" ] ; then - copy_skel_files_upgrade - fi - - cd / - - # Unmount FS - umount_all_dir "${FSMNT}" - - # Run our saved unmount script for these file-systems - rc_nohalt "umount -f ${FSMNT}" - - umount ${CDMNT} -}; diff --git a/usr.sbin/pc-sysinstall/backend/functions-users.sh b/usr.sbin/pc-sysinstall/backend/functions-users.sh deleted file mode 100755 index 85b6c89abd0..00000000000 --- a/usr.sbin/pc-sysinstall/backend/functions-users.sh +++ /dev/null @@ -1,187 +0,0 @@ -#!/bin/sh -#- -# SPDX-License-Identifier: BSD-2-Clause-FreeBSD -# -# Copyright (c) 2010 iXsystems, Inc. All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions -# are met: -# 1. Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# 2. Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# -# THIS SOFTWARE IS PROVIDED BY 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. -# - -# Functions which runs commands on the system - -. ${BACKEND}/functions.sh -. ${BACKEND}/functions-parse.sh - - -# Function which checks and sets up auto-login for a user if specified -check_autologin() -{ - get_value_from_cfg autoLoginUser - if [ -n "${VAL}" -a "${INSTALLTYPE}" = "PCBSD" ] - then - AUTOU="${VAL}" - # Add the auto-login user line - sed -i.bak "s/AutoLoginUser=/AutoLoginUser=${AUTOU}/g" ${FSMNT}/usr/local/kde4/share/config/kdm/kdmrc - - # Add the auto-login user line - sed -i.bak "s/AutoLoginEnable=false/AutoLoginEnable=true/g" ${FSMNT}/usr/local/kde4/share/config/kdm/kdmrc - - fi -}; - -# Function which actually runs the adduser command on the filesystem -add_user() -{ - ARGS="${1}" - - if [ -e "${FSMNT}/.tmpPass" ] - then - # Add a user with a supplied password - run_chroot_cmd "cat /.tmpPass | pw useradd ${ARGS}" - rc_halt "rm ${FSMNT}/.tmpPass" - else - # Add a user with no password - run_chroot_cmd "cat /.tmpPass | pw useradd ${ARGS}" - fi - -}; - -# Function which reads in the config, and adds any users specified -setup_users() -{ - - # We are ready to start setting up the users, lets read the config - while read line - do - - echo $line | grep -q "^userName=" 2>/dev/null - if [ $? -eq 0 ] - then - get_value_from_string "${line}" - USERNAME="$VAL" - fi - - echo $line | grep -q "^userComment=" 2>/dev/null - if [ $? -eq 0 ] - then - get_value_from_string "${line}" - USERCOMMENT="$VAL" - fi - - echo $line | grep -q "^userPass=" 2>/dev/null - if [ $? -eq 0 ] - then - get_value_from_string "${line}" - USERPASS="$VAL" - fi - - echo $line | grep -q "^userEncPass=" 2>/dev/null - if [ $? -eq 0 ] - then - get_value_from_string "${line}" - USERENCPASS="$VAL" - fi - - echo $line | grep -q "^userShell=" 2>/dev/null - if [ $? -eq 0 ] - then - get_value_from_string "${line}" - strip_white_space "$VAL" - USERSHELL="$VAL" - fi - - echo $line | grep -q "^userHome=" 2>/dev/null - if [ $? -eq 0 ] - then - get_value_from_string "${line}" - USERHOME="$VAL" - fi - - echo $line | grep -q "^userGroups=" 2>/dev/null - if [ $? -eq 0 ] - then - get_value_from_string "${line}" - USERGROUPS="$VAL" - fi - - - echo $line | grep -q "^commitUser" 2>/dev/null - if [ $? -eq 0 ] - then - # Found our flag to commit this user, lets check and do it - if [ -n "${USERNAME}" ] - then - - # Now add this user to the system, by building our args list - ARGS="-n ${USERNAME}" - - if [ -n "${USERCOMMENT}" ] - then - ARGS="${ARGS} -c \"${USERCOMMENT}\"" - fi - - if [ -n "${USERPASS}" ] - then - ARGS="${ARGS} -h 0" - echo "${USERPASS}" >${FSMNT}/.tmpPass - elif [ -n "${USERENCPASS}" ] - then - ARGS="${ARGS} -H 0" - echo "${USERENCPASS}" >${FSMNT}/.tmpPass - else - ARGS="${ARGS} -h -" - rm ${FSMNT}/.tmpPass 2>/dev/null 2>/dev/null - fi - - if [ -n "${USERSHELL}" ] - then - ARGS="${ARGS} -s \"${USERSHELL}\"" - else - ARGS="${ARGS} -s \"/nonexistant\"" - fi - - if [ -n "${USERHOME}" ] - then - ARGS="${ARGS} -m -d \"${USERHOME}\"" - fi - - if [ -n "${USERGROUPS}" ] - then - ARGS="${ARGS} -G \"${USERGROUPS}\"" - fi - - add_user "${ARGS}" - - # Unset our vars before looking for any more users - unset USERNAME USERCOMMENT USERPASS USERENCPASS USERSHELL USERHOME USERGROUPS - else - exit_err "ERROR: commitUser was called without any userName= entry!!!" - fi - fi - - done <${CFGF} - - - # Check if we need to enable a user to auto-login to the desktop - check_autologin - -}; diff --git a/usr.sbin/pc-sysinstall/backend/functions.sh b/usr.sbin/pc-sysinstall/backend/functions.sh deleted file mode 100755 index a092f1bb4b3..00000000000 --- a/usr.sbin/pc-sysinstall/backend/functions.sh +++ /dev/null @@ -1,541 +0,0 @@ -#!/bin/sh -#- -# SPDX-License-Identifier: BSD-2-Clause-FreeBSD -# -# Copyright (c) 2010 iXsystems, Inc. All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions -# are met: -# 1. Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# 2. Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# -# THIS SOFTWARE IS PROVIDED BY 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. -# - -# functions.sh -# Library of functions which pc-sysinstall may call upon - -# Function which displays the help-index file -display_help() -{ - if [ -e "${PROGDIR}/doc/help-index" ] - then - cat ${PROGDIR}/doc/help-index - else - echo "Error: ${PROGDIR}/doc/help-index not found" - exit 1 - fi -}; - -# Function which displays the help for a specified command -display_command_help() -{ - if [ -z "$1" ] - then - echo "Error: No command specified to display help for" - exit 1 - fi - - if [ -e "${PROGDIR}/doc/help-${1}" ] - then - cat ${PROGDIR}/doc/help-${1} - else - echo "Error: ${PROGDIR}/doc/help-${1} not found" - exit 1 - fi -}; - -# Function to convert bytes to megabytes -convert_byte_to_megabyte() -{ - if [ -z "${1}" ] - then - echo "Error: No bytes specified!" - exit 1 - fi - - expr -e ${1} / 1048576 -}; - -# Function to convert blocks to megabytes -convert_blocks_to_megabyte() -{ - if [ -z "${1}" ] ; then - echo "Error: No blocks specified!" - exit 1 - fi - - expr -e ${1} / 2048 -}; - -# Takes $1 and strips the whitespace out of it, returns VAL -strip_white_space() -{ - if [ -z "${1}" ] - then - echo "Error: No value setup to strip whitespace from!" - - exit 1 - fi - - export VAL=`echo "$1" | tr -d ' '` -}; - -# Displays an error message and exits with error 1 -exit_err() -{ - # Echo the message for the users benefit - echo "EXITERROR: $1" - - # Save this error to the log file - echo "EXITERROR: ${1}" >>$LOGOUT - - # Check if we need to unmount any file-systems after this failure - unmount_all_filesystems_failure - - echo "For more details see log file: $LOGOUT" - - exit 1 -}; - -# Run-command, don't halt if command exits with non-0 -rc_nohalt() -{ - CMD="$1" - - if [ -z "${CMD}" ] - then - exit_err "Error: missing argument in rc_nohalt()" - fi - - echo "Running: ${CMD}" >>${LOGOUT} - ${CMD} >>${LOGOUT} 2>>${LOGOUT} - -}; - -# Run-command, halt if command exits with non-0 -rc_halt() -{ - CMD="$1" - - if [ -z "${CMD}" ] - then - exit_err "Error: missing argument in rc_halt()" - fi - - echo "Running: ${CMD}" >>${LOGOUT} - eval ${CMD} >>${LOGOUT} 2>>${LOGOUT} - STATUS="$?" - if [ "${STATUS}" != "0" ] - then - exit_err "Error ${STATUS}: ${CMD}" - fi -}; - -# Run-command w/echo to screen, halt if command exits with non-0 -rc_halt_echo() -{ - CMD="$1" - - if [ -z "${CMD}" ] - then - exit_err "Error: missing argument in rc_halt_echo()" - fi - - echo "Running: ${CMD}" >>${LOGOUT} - ${CMD} 2>&1 | tee -a ${LOGOUT} - STATUS="$?" - if [ "$STATUS" != "0" ] - then - exit_err "Error ${STATUS}: $CMD" - fi - -}; - -# Run-command w/echo, don't halt if command exits with non-0 -rc_nohalt_echo() -{ - CMD="$1" - - if [ -z "${CMD}" ] - then - exit_err "Error: missing argument in rc_nohalt_echo()" - fi - - echo "Running: ${CMD}" >>${LOGOUT} - ${CMD} 2>&1 | tee -a ${LOGOUT} - -}; - -# Echo to the screen and to the log -echo_log() -{ - STR="$1" - - if [ -z "${STR}" ] - then - exit_err "Error: missing argument in echo_log()" - fi - - echo "${STR}" | tee -a ${LOGOUT} -}; - -# Make sure we have a numeric -is_num() -{ - expr $1 + 1 2>/dev/null - return $? -} - -# Function which uses "fetch" to download a file, and display a progress report -fetch_file() -{ - - FETCHFILE="$1" - FETCHOUTFILE="$2" - EXITFAILED="$3" - - EXITFILE="${TMPDIR}/.fetchExit" - - rm ${FETCHOUTFILE} 2>/dev/null >/dev/null - - SIZE=$(( `fetch -s "${FETCHFILE}"` / 1024 )) - echo "FETCH: ${FETCHFILE}" - echo "FETCH: ${FETCHOUTFILE}" >>${LOGOUT} - - ( fetch -o ${FETCHOUTFILE} "${FETCHFILE}" >/dev/null 2>/dev/null ; echo "$?" > ${EXITFILE} ) & - PID="$!" - while - z=1 - do - - if [ -e "${FETCHOUTFILE}" ] - then - DSIZE=`du -k ${FETCHOUTFILE} | tr -d '\t' | cut -d '/' -f 1` - if [ $(is_num "$DSIZE") ] ; then - if [ $SIZE -lt $DSIZE ] ; then DSIZE="$SIZE"; fi - echo "SIZE: ${SIZE} DOWNLOADED: ${DSIZE}" - echo "SIZE: ${SIZE} DOWNLOADED: ${DSIZE}" >>${LOGOUT} - fi - fi - - # Check if the download is finished - ps -p ${PID} >/dev/null 2>/dev/null - if [ $? -ne 0 ] - then - break; - fi - - sleep 2 - done - - echo "FETCHDONE" - - EXIT="`cat ${EXITFILE}`" - if [ "${EXIT}" != "0" -a "$EXITFAILED" = "1" ] - then - exit_err "Error: Failed to download ${FETCHFILE}" - fi - - return $EXIT - -}; - -# Function to return a the zpool name for this device -get_zpool_name() -{ - DEVICE="$1" - - # Set the base name we use for zpools - BASENAME="tank" - - if [ ! -d "${TMPDIR}/.zpools" ] ; then - mkdir -p ${TMPDIR}/.zpools - fi - - if [ -e "${TMPDIR}/.zpools/${DEVICE}" ] ; then - cat ${TMPDIR}/.zpools/${DEVICE} - return 0 - else - # Need to generate a zpool name for this device - NUM=`ls ${TMPDIR}/.zpools/ | wc -l | sed 's| ||g'` - - # Is it used in another zpool? - while : - do - NEWNAME="${BASENAME}${NUM}" - zpool list | grep -qw "${NEWNAME}" - local chk1=$? - zpool import | grep -qw "${NEWNAME}" - local chk2=$? - if [ $chk1 -eq 1 -a $chk2 -eq 1 ] ; then break ; fi - NUM=$((NUM+1)) - done - - # Now save the new tank name - mkdir -p ${TMPDIR}/.zpools/`dirname $DEVICE` - echo "$NEWNAME" >${TMPDIR}/.zpools/${DEVICE} - echo "${NEWNAME}" - return 0 - fi -}; - -iscompressed() -{ - local FILE - local RES - - FILE="$1" - RES=1 - - if echo "${FILE}" | \ - grep -qiE '\.(Z|lzo|lzw|lzma|gz|bz2|xz|zip)$' 2>&1 - then - RES=0 - fi - - return ${RES} -} - -get_compression_type() -{ - local FILE - local SUFFIX - - FILE="$1" - SUFFIX=`echo "${FILE}" | sed -E 's|^(.+)\.(.+)$|\2|'` - - VAL="" - SUFFIX=`echo "${SUFFIX}" | tr A-Z a-z` - case "${SUFFIX}" in - z) VAL="lzw" ;; - lzo) VAL="lzo" ;; - lzw) VAL="lzw" ;; - lzma) VAL="lzma" ;; - gz) VAL="gzip" ;; - bz2) VAL="bzip2" ;; - xz) VAL="xz" ;; - zip) VAL="zip" ;; - esac - - export VAL -} - -write_image() -{ - local DEVICE_FILE - - IMAGE_FILE="$1" - DEVICE_FILE="$2" - - if [ -z "${IMAGE_FILE}" ] - then - exit_err "ERROR: Image file not specified!" - fi - - if [ -z "${DEVICE_FILE}" ] - then - exit_err "ERROR: Device file not specified!" - fi - - if [ ! -f "${IMAGE_FILE}" ] - then - exit_err "ERROR: '${IMAGE_FILE}' does not exist!" - fi - - DEVICE_FILE="${DEVICE_FILE#/dev/}" - DEVICE_FILE="/dev/${DEVICE_FILE}" - - if [ ! -c "${DEVICE_FILE}" ] - then - exit_err "ERROR: '${DEVICE_FILE}' is not a character device!" - fi - - if iscompressed "${IMAGE_FILE}" - then - local COMPRESSION - - get_compression_type "${IMAGE_FILE}" - COMPRESSION="${VAL}" - - case "${COMPRESSION}" in - lzw) - rc_halt "uncompress ${IMAGE_FILE} -c | dd of=${DEVICE_FILE}" - IMAGE_FILE="${IMAGE_FILE%.Z}" - ;; - - lzo) - rc_halt "lzop -d $IMAGE_{FILE} -c | dd of=${DEVICE_FILE}" - IMAGE_FILE="${IMAGE_FILE%.lzo}" - ;; - - lzma) - rc_halt "lzma -d ${IMAGE_FILE} -c | dd of=${DEVICE_FILE}" - IMAGE_FILE="${IMAGE_FILE%.lzma}" - ;; - - gzip) - rc_halt "gunzip ${IMAGE_FILE} -c | dd of=${DEVICE_FILE}" - IMAGE_FILE="${IMAGE_FILE%.gz}" - ;; - - bzip2) - rc_halt "bunzip2 ${IMAGE_FILE} -c | dd of=${DEVICE_FILE}" - IMAGE_FILE="${IMAGE_FILE%.bz2}" - ;; - - xz) - rc_halt "xz -d ${IMAGE_FILE} -c | dd of=${DEVICE_FILE}" - IMAGE_FILE="${IMAGE_FILE%.xz}" - ;; - - zip) - rc_halt "unzip ${IMAGE_FILE} -c | dd of=${DEVICE_FILE}" - IMAGE_FILE="${IMAGE_FILE%.zip}" - ;; - - *) - exit_err "ERROR: ${COMPRESSION} compression is not supported" - ;; - esac - - else - rc_halt "dd if=${IMAGE_FILE} of=${DEVICE_FILE}" - - fi -}; - -# Setup and install on a new disk / partition -install_fresh() -{ - # Lets start setting up the disk slices now - setup_disk_slice - - if [ -z "${ROOTIMAGE}" ] - then - - # Disk setup complete, now lets parse WORKINGSLICES and setup the bsdlabels - setup_disk_label - - # Now we've setup the bsdlabels, lets go ahead and run newfs / zfs - # to setup the filesystems - setup_filesystems - - # Lets mount the partitions now - mount_all_filesystems - - # We are ready to begin extraction, lets start now - init_extraction - - # Check if we have any optional modules to load - install_components - - # Check if we have any packages to install - install_packages - - # Do any localization in configuration - run_localize - - # Save any networking config on the installed system - save_networking_install - - # Now add any users - setup_users - - # Do any last cleanup / setup before unmounting - run_final_cleanup - - # Now run any commands specified - run_commands - - # Unmount and finish up - unmount_all_filesystems - fi - - echo_log "Installation finished!" -}; - -# Extract the system to a pre-mounted directory -install_extractonly() -{ - # We are ready to begin extraction, lets start now - init_extraction - - # Check if we have any optional modules to load - install_components - - # Check if we have any packages to install - install_packages - - # Do any localization in configuration - run_localize - - # Save any networking config on the installed system - save_networking_install - - # Now add any users - setup_users - - # Now run any commands specified - run_commands - - # Set a hostname on the install system - setup_hostname - - # Set the root_pw if it is specified - set_root_pw - - echo_log "Installation finished!" -}; - -install_image() -{ - # We are ready to begin extraction, lets start now - init_extraction - - echo_log "Installation finished!" -}; - -install_upgrade() -{ - # We're going to do an upgrade, skip all the disk setup - # and start by mounting the target drive/slices - mount_upgrade - - # Start the extraction process - init_extraction - - # Do any localization in configuration - run_localize - - # Now run any commands specified - run_commands - - # Merge any old configuration files - merge_old_configs - - # Check if we have any optional modules to load - install_components - - # Check if we have any packages to install - install_packages - - # All finished, unmount the file-systems - unmount_upgrade - - echo_log "Upgrade finished!" -}; diff --git a/usr.sbin/pc-sysinstall/backend/installimage.sh b/usr.sbin/pc-sysinstall/backend/installimage.sh deleted file mode 100755 index d1e88a45405..00000000000 --- a/usr.sbin/pc-sysinstall/backend/installimage.sh +++ /dev/null @@ -1,35 +0,0 @@ -#!/bin/sh -#- -# SPDX-License-Identifier: BSD-2-Clause-FreeBSD -# -# Copyright (c) 2010 iXsystems, Inc. All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions -# are met: -# 1. Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# 2. Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# -# THIS SOFTWARE IS PROVIDED BY 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. -# - -# Source our functions scripts -. ${BACKEND}/functions.sh - -IMAGE_FILE="${1}" -DEVICE_FILE="${2}" - -write_image "${IMAGE_FILE}" "${DEVICE_FILE}" diff --git a/usr.sbin/pc-sysinstall/backend/parseconfig.sh b/usr.sbin/pc-sysinstall/backend/parseconfig.sh deleted file mode 100755 index cb0cc47c9f5..00000000000 --- a/usr.sbin/pc-sysinstall/backend/parseconfig.sh +++ /dev/null @@ -1,125 +0,0 @@ -#!/bin/sh -#- -# SPDX-License-Identifier: BSD-2-Clause-FreeBSD -# -# Copyright (c) 2010 iXsystems, Inc. All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions -# are met: -# 1. Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# 2. Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# -# THIS SOFTWARE IS PROVIDED BY 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. -# - -# Main install configuration parsing script -# - -# Source our functions scripts -. ${BACKEND}/functions.sh -. ${BACKEND}/functions-bsdlabel.sh -. ${BACKEND}/functions-cleanup.sh -. ${BACKEND}/functions-disk.sh -. ${BACKEND}/functions-extractimage.sh -. ${BACKEND}/functions-installcomponents.sh -. ${BACKEND}/functions-installpackages.sh -. ${BACKEND}/functions-localize.sh -. ${BACKEND}/functions-mountdisk.sh -. ${BACKEND}/functions-networking.sh -. ${BACKEND}/functions-newfs.sh -. ${BACKEND}/functions-packages.sh -. ${BACKEND}/functions-parse.sh -. ${BACKEND}/functions-runcommands.sh -. ${BACKEND}/functions-ftp.sh -. ${BACKEND}/functions-unmount.sh -. ${BACKEND}/functions-upgrade.sh -. ${BACKEND}/functions-users.sh - -# Check that the config file exists -if [ ! -e "${1}" ] -then - echo "ERROR: Install configuration $1 does not exist!" - exit 1 -fi - -# Set our config file variable -CFGF="$1" - -# Resolve any relative pathing -CFGF="`realpath ${CFGF}`" -export CFGF - -# Start by doing a sanity check, which will catch any obvious mistakes in the config -file_sanity_check "installMode installType installMedium packageType" - -# We passed the Sanity check, lets grab some of the universal config settings and store them -check_value installMode "fresh upgrade extract" -check_value installType "PCBSD FreeBSD" -check_value installMedium "dvd usb ftp rsync image local" -check_value packageType "uzip tar rsync split dist" -if_check_value_exists mirrorbal "load prefer round-robin split" - -# We passed all sanity checks! Yay, lets start the install -echo "File Sanity Check -> OK" - -# Lets load the various universal settings now -get_value_from_cfg installMode -export INSTALLMODE="${VAL}" - -get_value_from_cfg installType -export INSTALLTYPE="${VAL}" - -get_value_from_cfg installMedium -export INSTALLMEDIUM="${VAL}" - -get_value_from_cfg packageType -export PACKAGETYPE="${VAL}" - -# Check if we are doing any networking setup -start_networking - -# If we are not doing an upgrade, lets go ahead and setup the disk -case "${INSTALLMODE}" in - fresh) - if [ "${INSTALLMEDIUM}" = "image" ] - then - install_image - else - install_fresh - fi - ;; - - extract) - # Extracting only, make sure we have a valid target directory - get_value_from_cfg installLocation - export FSMNT="${VAL}" - if [ -z "$FSMNT" ] ; then exit_err "Missing installLocation=" ; fi - if [ ! -d "$FSMNT" ] ; then exit_err "No such directory: $FSMNT" ; fi - - install_extractonly - ;; - - upgrade) - install_upgrade - ;; - - *) - exit 1 - ;; -esac - -exit 0 diff --git a/usr.sbin/pc-sysinstall/backend/startautoinstall.sh b/usr.sbin/pc-sysinstall/backend/startautoinstall.sh deleted file mode 100755 index acf637580b2..00000000000 --- a/usr.sbin/pc-sysinstall/backend/startautoinstall.sh +++ /dev/null @@ -1,137 +0,0 @@ -#!/bin/sh -#- -# SPDX-License-Identifier: BSD-2-Clause-FreeBSD -# -# Copyright (c) 2010 iXsystems, Inc. All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions -# are met: -# 1. Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# 2. Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# -# THIS SOFTWARE IS PROVIDED BY 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. -# -# Script which reads the pc-autoinstall.conf directive, and begins the install -# - -# Source our functions scripts -. ${BACKEND}/functions.sh -. ${BACKEND}/functions-networking.sh -. ${BACKEND}/functions-parse.sh - -# Check that the config file exists -if [ ! -e "${1}" ] -then - echo "ERROR: Install configuration $1 does not exist!" - exit 1 -fi - -# Set our config file variable -CONF=${1} -INSTALL_CFG="/tmp/pc-sysinstall.cfg" - -# Check if the config file is on disk as well -PCCFG=`grep "pc_config:" ${CONF} | grep -v "^#" | sed "s|pc_config: ||g" | sed "s|pc_config:||g"` -SHUTDOWN_CMD=`grep "shutdown_cmd:" ${CONF} | grep -v "^#" | sed "s|shutdown_cmd: ||g" | sed "s|shutdown_cmd:||g"` -CONFIRM_INS=`grep "confirm_install:" ${CONF} | grep -v "^#" | sed "s|confirm_install: ||g" | sed "s|confirm_install:||g"` - -# Check that this isn't a http / ftp file we need to fetch later -echo "${PCCFG}" | grep -q -e "^http" -e "^ftp" 2>/dev/null -if [ $? -ne 0 ] -then - # Copy over the install cfg file, if not done already - if [ ! -e "${INSTALL_CFG}" ] - then - cp ${PCCFG} ${INSTALL_CFG} - fi - # Make sure we have the file which was copied into /tmp previously - if [ ! -e "${INSTALL_CFG}" ] - then - echo "Error: ${INSTALL_CFG} is missing! Exiting in 10 seconds..." - sleep 10 - exit 150 - fi -else - # We need to fetch a remote file, check and set any nic options before doing so - NICCFG=`grep "nic_config:" ${CONF} | grep -v "^#" | sed "s|nic_config: ||g" | sed "s|nic_config:||g"` - if [ "${NICCFG}" = "dhcp-all" -o "${NICCFG}" = "DHCP-ALL" ] - then - # Try to auto-enable dhcp on any nics we find - enable_auto_dhcp - else - echo "Running command \"ifconfig ${NICCFG}\"" - ifconfig ${NICCFG} - WRKNIC="`echo ${NICCFG} | cut -d ' ' -f 1`" - NICDNS=`grep "nic_dns:" ${CONF} | grep -v "^#" | sed "s|nic_dns: ||g" | sed "s|nic_dns:||g"` - NICGATE=`grep "nic_gateway:" ${CONF} | grep -v "^#" | sed "s|nic_gateway: ||g" | sed "s|nic_gateway:||g"` - - echo "nameserver ${NICDNS}" >/etc/resolv.conf - - echo "Running command \"route add default ${NICGATE}\"" - route add default ${NICGATE} - fi - - get_nic_mac "$WRKNIC" - nic_mac="${FOUNDMAC}" - - PCCFG=`echo ${PCCFG} | sed "s|%%NIC_MAC%%|${nic_mac}|g"` - - # Now try to fetch the remove file - echo "Fetching cfg with: \"fetch -o ${INSTALL_CFG} ${PCCFG}\"" - fetch -o "${INSTALL_CFG}" "${PCCFG}" - if [ $? -ne 0 ] - then - echo "ERROR: Failed to fetch ${PCCFG}, install aborted" - exit 150 - fi - -fi - -# If we end up with a valid config, lets proccede -if [ -e "${INSTALL_CFG}" ] -then - - if [ "${CONFIRM_INS}" != "no" -a "${CONFIRM_INS}" != "NO" ] - then - echo "Type in 'install' to begin automated installation. Warning: Data on target disks may be destroyed!" - read tmp - case $tmp in - install|INSTALL) ;; - *) echo "Install canceled!" ; exit 150 ;; - esac - fi - - pc-sysinstall -c ${INSTALL_CFG} - if [ $? -eq 0 ] - then - if [ -n "$SHUTDOWN_CMD" ] - then - ${SHUTDOWN_CMD} - else - echo "SUCCESS: Installation finished! Press ENTER to reboot." - read tmp - shutdown -r now - fi - else - echo "ERROR: Installation failed, press ENTER to drop to shell." - read tmp - /bin/csh - fi -else - echo "ERROR: Failed to get /tmp/pc-sysinstall.cfg for automated install..." - exit 150 -fi diff --git a/usr.sbin/pc-sysinstall/conf/Makefile b/usr.sbin/pc-sysinstall/conf/Makefile deleted file mode 100644 index 5399172073a..00000000000 --- a/usr.sbin/pc-sysinstall/conf/Makefile +++ /dev/null @@ -1,9 +0,0 @@ -# $FreeBSD: stable/11/usr.sbin/pc-sysinstall/conf/Makefile 284255 2015-06-11 04:22:17Z sjg $ - -FILESGROUPS= CONF LICENSE -CONF= exclude-from-upgrade pc-sysinstall.conf avail-langs -CONFDIR= ${SHAREDIR}/pc-sysinstall/conf -LICENSE= licenses/bsd-en.txt licenses/intel-en.txt licenses/nvidia-en.txt -LICENSEDIR= ${SHAREDIR}/pc-sysinstall/conf/license - -.include diff --git a/usr.sbin/pc-sysinstall/conf/Makefile.depend b/usr.sbin/pc-sysinstall/conf/Makefile.depend deleted file mode 100644 index 529696cb9f0..00000000000 --- a/usr.sbin/pc-sysinstall/conf/Makefile.depend +++ /dev/null @@ -1,11 +0,0 @@ -# $FreeBSD: stable/11/usr.sbin/pc-sysinstall/conf/Makefile.depend 284345 2015-06-13 19:20:56Z sjg $ -# Autogenerated - do NOT edit! - -DIRDEPS = \ - - -.include - -.if ${DEP_RELDIR} == ${_DEP_RELDIR} -# local dependencies - needed for -jN in clean tree -.endif diff --git a/usr.sbin/pc-sysinstall/conf/avail-langs b/usr.sbin/pc-sysinstall/conf/avail-langs deleted file mode 100644 index d78e14a9adb..00000000000 --- a/usr.sbin/pc-sysinstall/conf/avail-langs +++ /dev/null @@ -1,20 +0,0 @@ -en English -bg Bulgarian -ca Catalan -zh_TW Chinese_(Taiwan) -cs Czech -nl Dutch -fr French -de German -en_GB English_(UK) -en_ZA English_(South Africa) -it Italian -ja Japanese -pt_BR Portuguese_(Brazil) -pl Polish -pa Punjabi -ru Russian -sk Slovak -sl Slovenian -es Spanish -uk Ukrainian diff --git a/usr.sbin/pc-sysinstall/conf/exclude-from-upgrade b/usr.sbin/pc-sysinstall/conf/exclude-from-upgrade deleted file mode 100644 index b0529d411c2..00000000000 --- a/usr.sbin/pc-sysinstall/conf/exclude-from-upgrade +++ /dev/null @@ -1,15 +0,0 @@ -etc/fstab -dev -etc/passwd -etc/pwd.db -etc/group -etc/master.passwd -etc/spwd.db -etc/hosts -etc/resolv.conf -etc/localtime -etc/hosts -etc/X11 -etc/nsmb.conf -usr/Programs/.config/ProgList -Programs/.config/ProgList diff --git a/usr.sbin/pc-sysinstall/conf/licenses/bsd-en.txt b/usr.sbin/pc-sysinstall/conf/licenses/bsd-en.txt deleted file mode 100644 index a30b67e9777..00000000000 --- a/usr.sbin/pc-sysinstall/conf/licenses/bsd-en.txt +++ /dev/null @@ -1,24 +0,0 @@ -SECTION 1: BSD LICENSE --------------------------------------------------------------------------------- -Copyright (c) 1998, 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: - - Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - 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. - Neither the name of the University of California, Berkeley 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 EXPR -ESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO E -VENT SHALL THE REGENTS AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCI -DENTAL, 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 AN 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. diff --git a/usr.sbin/pc-sysinstall/conf/licenses/intel-en.txt b/usr.sbin/pc-sysinstall/conf/licenses/intel-en.txt deleted file mode 100644 index 0858ff732a1..00000000000 --- a/usr.sbin/pc-sysinstall/conf/licenses/intel-en.txt +++ /dev/null @@ -1,207 +0,0 @@ -Section 2: Intel Firmware license --------------------------------------------------------------------------------- - TERMS AND CONDITIONS - IMPORTANT - PLEASE READ BEFORE INSTALLING OR USING THIS INTEL(C) SOFTWARE - -Do not use or load this firmware (the "Software") until you have carefully read -the following terms and conditions. By loading or using the Software, you agree -to the terms of this Agreement. If you do not wish to so agree, do not install -or use the Software. - -LICENSEES: - -Please note: - -* If you are an End-User, only Exhibit A, the SOFTWARE LICENSE AGREEMENT, - applies. -* If you are an Original Equipment Manufacturer (OEM), Independent Hardware - Vendor (IHV), or Independent Software Vendor (ISV), this complete Agreement - applies - --------------------------------------------------------------------------------- - -For OEMs, IHVs, and ISVs: - -LICENSE. This Software is licensed for use only in conjunction with Intel -component products. Use of the Software in conjunction with non-Intel component -products is not licensed hereunder. Subject to the terms of this Agreement, -Intel grants to you a nonexclusive, nontransferable, worldwide, fully paid-up -license under Intel's copyrights to: (i) copy the Software internally for your -own development and maintenance purposes; (ii) copy and distribute the Software -to your end-users, but only under a license agreement with terms at least as -restrictive as those contained in Intel's Final, Single User License Agreement, -attached as Exhibit A; and (iii) modify, copy and distribute the end-user -documentation which may accompany the Software, but only in association with -the Software. - -If you are not the final manufacturer or vendor of a computer system or software -program incorporating the Software, then you may transfer a copy of the -Software, including any related documentation (modified or unmodified) to your -recipient for use in accordance with the terms of this Agreement, provided such -recipient agrees to be fully bound by the terms hereof. You shall not otherwise -assign, sublicense, lease, or in any other way transfer or disclose Software to -any third party. You may not, nor may you assist any other person or entity to -modify, translate, convert to another programming language, decompile, reverse -engineer, or disassemble any portion of the Software or otherwise attempt to -derive source code from any object code modules of the Software or any internal -data files generated by the Software. Your rights to redistribute the Software -shall be contingent upon your installation of this Agreement in its entirety in -the same directory as the Software. - -CONTRACTORS. For the purpose of this Agreement, and notwithstanding anything -to the contrary hereunder, solely with respect to the requirements for -compliance with the terms hereunder, any contractors or consultants that You -use to perform the work or otherwise assist You in the development or products -using this Software shall be deemed to be End Users and accordingly, upon -receipt of the Software, shall be bound by the terms of Exhibit A, Software -License Agreement. No additional agreement between You and such consultants or -contractors is required under this Agreement to detail such compliance. - -TRADEMARKS. Except as expressly provided herein, you shall not use Intel's -name in any publications, advertisements, or other announcements without -Intel's prior written consent. You do not have any rights to use any Intel -trademarks or logos. - -OWNERSHIP OF SOFTWARE AND COPYRIGHTS. Software and accompanying materials, if -any, are owned by Intel or its suppliers and licensors and may be protected by -copyright, trademark, patent and trade secret law and international treaties. -Any rights, express or implied, in the intellectual property embodied in the -foregoing, other than those specified in this Agreement, are reserved by Intel -and its suppliers and licensors or otherwise as set forth in any applicable -open source license agreement. You will keep the Software free of liens, -attachments, and other encumbrances. You agree not to remove any proprietary -notices and/or any labels from the Software and accompanying materials without -prior written approval by Intel - -LIMITATION OF LIABILITY. IN NO EVENT SHALL INTEL OR ITS SUPPLIERS AND LICENSORS -BE LIABLE FOR ANY DAMAGES WHATSOEVER FROM ANY CAUSE OF ACTION OF ANY KIND -(INCLUDING, WITHOUT LIMITATION, LOST PROFITS, BUSINESS INTERRUPTION, OR LOST -INFORMATION) ARISING OUT OF THE USE, MODIFICATION, OR INABILITY TO USE THE -INTEL SOFTWARE, OR OTHERWISE, NOR FOR PUNITIVE, INCIDENTAL, CONSEQUENTIAL, OR -SPECIAL DAMAGES OF ANY KIND, EVEN IF INTEL OR ITS SUPPLIERS AND LICENSORS HAS -BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME JURISDICTIONS PROHIBIT -EXCLUSION OR LIMITATION OF LIABILITY FOR IMPLIED WARRANTIES, CONSEQUENTIAL OR -INCIDENTAL DAMAGES, SO CERTAIN LIMITATIONS MAY NOT APPLY. YOU MAY ALSO HAVE -OTHER LEGAL RIGHTS THAT VARY BETWEEN JURISDICTIONS. - -EXCLUSION OF WARRANTIES. THE SOFTWARE IS PROVIDED "AS IS" AND POSSIBLY WITH -FAULTS. UNLESS EXPRESSLY AGREED OTHERWISE, INTEL AND ITS SUPPLIERS AND -LICENSORS DISCLAIM ANY AND ALL WARRANTIES AND GUARANTEES, EXPRESS, IMPLIED OR -OTHERWISE, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -NONINFRINGEMENT, OR FITNESS FOR A PARTICULAR PURPOSE. Intel does not warrant -or assume responsibility for the accuracy or completeness of any information, -text, graphics, links or other items contained within the Software. You assume -all liability, financial or otherwise, associated with Your use or disposition -of the Software. - -APPLICABLE LAW. Claims arising under this Agreement shall be governed by the -laws of State of California], excluding its principles of conflict of laws and -the United Nations Convention on Contracts for the Sale of Goods. - -WAIVER AND AMENDMENT. No modification, amendment or waiver of any provision of -this Agreement shall be effective unless in writing and signed by an officer of -Intel. No failure or delay in exercising any right, power, or remedy under -this Agreement shall operate as a waiver of any such right, power or remedy. -Without limiting the foregoing, terms and conditions on any purchase orders or -similar materials submitted by you to Intel, and any terms contained in IntelÂ’s -standard acknowledgment form that are in conflict with these terms, shall be of -no force or effect. - -SEVERABILITY. If any provision of this Agreement is held by a court of -competent jurisdiction to be contrary to law, such provision shall be changed -and interpreted so as to best accomplish the objectives of the original -provision to the fullest extent allowed by law and the remaining provisions of -this Agreement shall remain in full force and effect. - -EXPORT RESTRICTIONS. Each party acknowledges that the Software is subject to -applicable import and export regulations of the United States and of the -countries in which each party transacts business, specifically including U.S. -Export Administration Act and Export Administration Regulations. Each party -shall comply with such laws and regulations, as well as all other laws and -regulations applicable to the Software. Without limiting the generality of the -foregoing, each party agrees that it will not export, re-export, transfer or -divert any of the Software or the direct programs thereof to any restricted -place or party in accordance with U.S. export regulations. Note that Software -containing encryption may be subject to additional restrictions. - -GOVERNMENT RESTRICTED RIGHTS. The Software is provided with "RESTRICTED RIGHTS." -Use, duplication, or disclosure by the Government is subject to restrictions as -set forth in FAR52.227-14 and DFAR252.227-7013 et seq. or their successors. Use -of the Software by the Government constitutes acknowledgment of Intel's -proprietary rights therein. Contractor or Manufacturer is Intel Corporation, -2200 Mission College Blvd., Santa Clara, CA 95052. - -TERMINATION OF THE AGREEMENT. Intel may terminate this Agreement if you violate -its terms. Upon termination, you will immediately destroy the Software or -return all copies of the Software to Intel. - --------------------------------------------------------------------------------- - -EXHIBIT "A" - -SOFTWARE LICENSE AGREEMENT (Final, Single User) - -IMPORTANT - READ BEFORE COPYING, INSTALLING OR USING. - -Do not use or load this firmware image (the "Software") until you have carefully -read the following terms and conditions. By loading or using the Software, you -agree to the terms of this Agreement. If you do not wish to so agree, do not -install or use the Software. - -LICENSE. You may copy and use the Software, subject to these conditions: -1. This Software is licensed for use only in conjunction with Intel component - products. Use of the Software in conjunction with non-Intel component - products is not licensed hereunder. -2. You may not copy, modify, rent, sell, distribute or transfer any part of the - Software except as provided in this Agreement, and you agree to prevent - unauthorized copying of the Software. -3. You may not reverse engineer, decompile, or disassemble the Software. -4. You may not sublicense the Software. -5. The Software may contain the software or other property of third party - suppliers. - -OWNERSHIP OF SOFTWARE AND COPYRIGHTS. Title to all copies of the Software -remains with Intel or its suppliers. The Software is copyrighted and protected -by the laws of the United States and other countries, and international treaty -provisions. You may not remove any copyright notices from the Software. Intel -may make changes to the Software, or items referenced therein, at any time -without notice, but is not obligated to support or update the Software. Except -as otherwise expressly provided, Intel grants no express or implied right under -Intel patents, copyrights, trademarks, or other intellectual property rights. -You may transfer the Software only if a copy of this license accompanies the -Software and the recipient agrees to be fully bound by these terms. - -EXCLUSION OF OTHER WARRANTIES EXCEPT AS PROVIDED ABOVE, THE SOFTWARE IS PROVIDED -"AS IS" WITHOUT ANY EXPRESS OR IMPLIED WARRANTY OF ANY KIND INCLUDING -WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT, OR FITNESS FOR A PARTICULAR -PURPOSE. Intel does not warrant or assume responsibility for the accuracy or -completeness of any information, text, graphics, links or other items contained -within the Software. - -LIMITATION OF LIABILITY. IN NO EVENT SHALL INTEL OR ITS SUPPLIERS BE LIABLE FOR -ANY DAMAGES WHATSOEVER (INCLUDING, WITHOUT LIMITATION, LOST PROFITS, BUSINESS -INTERRUPTION, OR LOST INFORMATION) ARISING OUT OF THE USE OF OR INABILITY TO -USE THE SOFTWARE, EVEN IF INTEL HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH -DAMAGES. SOME JURISDICTIONS PROHIBIT EXCLUSION OR LIMITATION OF LIABILITY FOR -IMPLIED WARRANTIES OR CONSEQUENTIAL OR INCIDENTAL DAMAGES, SO THE ABOVE -LIMITATION MAY NOT APPLY TO YOU. YOU MAY ALSO HAVE OTHER LEGAL RIGHTS THAT VARY -BETWEEN JURISDICTIONS. - -TERMINATION OF THIS AGREEMENT. Intel may terminate this Agreement at any time if -you violate its terms. Upon termination, you will immediately destroy the -Software. - -APPLICABLE LAWS. Claims arising under this Agreement shall be governed by the -laws of California, excluding its principles of conflict of laws and the United -Nations Convention on Contracts for the Sale of Goods. You may not export the -Software in violation of applicable export laws and regulations. Intel is not -obligated under any other agreements unless they are in writing and signed by -an authorized representative -of Intel. - -GOVERNMENT RESTRICTED RIGHTS. The Software is provided with "RESTRICTED RIGHTS." -Use, duplication, or disclosure by the Government is subject to restrictions as -set forth in FAR52.227-14 and DFAR252.227-7013 et seq. or their successors. Use -of the Software by the Government constitutes acknowledgment of Intel's -proprietary rights therein. Contractor or Manufacturer is Intel Corporation, -2200 Mission College Blvd., Santa Clara, CA 95052. diff --git a/usr.sbin/pc-sysinstall/conf/licenses/nvidia-en.txt b/usr.sbin/pc-sysinstall/conf/licenses/nvidia-en.txt deleted file mode 100644 index 22c79065736..00000000000 --- a/usr.sbin/pc-sysinstall/conf/licenses/nvidia-en.txt +++ /dev/null @@ -1,53 +0,0 @@ -Section 3: NVIDIA driver license agreement --------------------------------------------------------------------------------- -License For Customer Use of NVIDIA Software - -IMPORTANT NOTICE -- READ CAREFULLY: This License For Customer Use of NVIDIA Software ("LICENSE") is the agreement which governs use of the software of NVIDIA Corporation and its subsidiaries ("NVIDIA") downloadable herefrom, including computer software and associated printed materials ("SOFTWARE"). By downloading, installing, copying, or otherwise using the SOFTWARE, you agree to be bound by the terms of this LICENSE. If you do not agree to the terms of this LICENSE, do not download the SOFTWARE. - -RECITALS - -Use of NVIDIA's products requires three elements: the SOFTWARE, the hardware on a graphics controller board, and a personal computer. The SOFTWARE is protected by copyright laws and international copyright treaties, as well as other intellectual property laws and treaties. The SOFTWARE is not sold, and instead is only licensed for use, strictly in accordance with this document. The hardware is protected by various patents, and is sold, but this LICENSE does not cover that sale, since it may not necessarily be sold as a package with the SOFTWARE. This LICENSE sets forth the terms and conditions of the SOFTWARE LICENSE only. - -1. DEFINITIONS - -1.1 Customer. Customer means the entity or individual that downloads the SOFTWARE. - -2. GRANT OF LICENSE - -2.1 Rights and Limitations of Grant. NVIDIA hereby grants Customer the following non-exclusive, non-transferable right to use the SOFTWARE, with the following limitations: - -2.1.1 Rights. Customer may install and use one copy of the SOFTWARE on a single computer, and except for making one back-up copy of the Software, may not otherwise copy the SOFTWARE. This LICENSE of SOFTWARE may not be shared or used concurrently on different computers. - -2.1.2 Linux/FreeBSD Exception. Notwithstanding the foregoing terms of Section 2.1.1, SOFTWARE designed exclusively for use on the Linux or FreeBSD operating systems, or other operating systems derived from the source code to these operating systems, may be copied and redistributed, provided that the binary files thereof are not modified in any way (except for unzipping of compressed files). - -2.1.3 Limitations. - -No Reverse Engineering. Customer may not reverse engineer, decompile, or disassemble the SOFTWARE, nor attempt in any other manner to obtain the source code. - -No Separation of Components. The SOFTWARE is licensed as a single product. Its component parts may not be separated for use on more than one computer, nor otherwise used separately from the other parts. - -No Rental. Customer may not rent or lease the SOFTWARE to someone else. - -3. TERMINATION - -This LICENSE will automatically terminate if Customer fails to comply with any of the terms and conditions hereof. In such event, Customer must destroy all copies of the SOFTWARE and all of its component parts. - -Defensive Suspension. If Customer commences or participates in any legal proceeding against NVIDIA, then NVIDIA may, in its sole discretion, suspend or terminate all license grants and any other rights provided under this LICENSE during the pendency of such legal proceedings. - -4. COPYRIGHT - -All title and copyrights in and to the SOFTWARE (including but not limited to all images, photographs, animations, video, audio, music, text, and other information incorporated into the SOFTWARE), the accompanying printed materials, and any copies of the SOFTWARE, are owned by NVIDIA, or its suppliers. The SOFTWARE is protected by copyright laws and international treaty provisions. Accordingly, Customer is required to treat the SOFTWARE like any other copyrighted material, except as otherwise allowed pursuant to this LICENSE and that it may make one copy of the SOFTWARE solely for backup or archive purposes. - -5. APPLICABLE LAW - -This LICENSE shall be deemed to have been made in, and shall be construed pursuant to, the laws of the State of California. The United Nations Convention on Contracts for the International Sale of Goods is specifically disclaimed. - -6. DISCLAIMER OF WARRANTIES AND LIMITATION ON LIABILITY - -6.1 No Warranties. TO THE MAXIMUM EXTENT PERMITTED BY APPLICABLE LAW, THE SOFTWARE IS PROVIDED "AS IS" AND NVIDIA AND ITS SUPPLIERS DISCLAIM ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. - -6.2 No Liability for Consequential Damages. TO THE MAXIMUM EXTENT PERMITTED BY APPLICABLE LAW, IN NO EVENT SHALL NVIDIA OR ITS SUPPLIERS BE LIABLE FOR ANY SPECIAL, INCIDENTAL, INDIRECT, OR CONSEQUENTIAL DAMAGES WHATSOEVER (INCLUDING, WITHOUT LIMITATION, DAMAGES FOR LOSS OF BUSINESS PROFITS, BUSINESS INTERRUPTION, LOSS OF BUSINESS INFORMATION, OR ANY OTHER PECUNIARY LOSS) ARISING OUT OF THE USE OF OR INABILITY TO USE THE SOFTWARE, EVEN IF NVIDIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. - -7. MISCELLANEOUS - -If any provision of this LICENSE is inconsistent with, or cannot be fully enforced under, the law, such provision will be construed as limited to the extent necessary to be consistent with and fully enforceable under the law. This LICENSE is the final, complete and exclusive agreement between the parties relating to the subject matter hereof, and supersedes all prior or contemporaneous understandings and agreements relating to such subject matter, whether oral or written. This LICENSE may only be modified in writing signed by an authorized officer of NVIDIA. Customer agrees that it will not ship, transfer or export the SOFTWARE into any country, or use the SOFTWARE in any manner, prohibited by the United States Bureau of Export Administration or any export laws, restrictions or regulations. diff --git a/usr.sbin/pc-sysinstall/conf/pc-sysinstall.conf b/usr.sbin/pc-sysinstall/conf/pc-sysinstall.conf deleted file mode 100644 index 87136403aed..00000000000 --- a/usr.sbin/pc-sysinstall/conf/pc-sysinstall.conf +++ /dev/null @@ -1,84 +0,0 @@ -#!/bin/sh -# $FreeBSD: stable/11/usr.sbin/pc-sysinstall/conf/pc-sysinstall.conf 247735 2013-03-03 23:07:27Z jpaetzel $ -# Configuration options for pc-sysinstall - -TMPDIR="/tmp/.pc-sysinstall" -export TMPDIR - -# Create a fresh TMPDIR -if [ -d "${TMPDIR}" -a "$TMPDIR" != '/' ]; then rm -rf ${TMPDIR}; fi -mkdir -p ${TMPDIR} - -# Set our temp directory for storing partition information -PARTDIR="${TMPDIR}/part-info" -export PARTDIR - -# Set the SLICECFGDIR -SLICECFGDIR="${TMPDIR}/.slice-cfg" -export SLICECFGDIR - -# Set the MIRRORCFGDIR -MIRRORCFGDIR="${TMPDIR}/.mirror-cfg" -export MIRRORCFGDIR - -# Set the GELIKEYDIR -GELIKEYDIR="${TMPDIR}/.geli-keys" -export GELIKEYDIR - -# Set our log file -LOGOUT="${TMPDIR}/pc-sysinstall.log" -export LOGOUT - -# Set the number of rsync tries -RSYNCTRIES="3" -export RSYNCTRIES - -# Set our mount-points -CDMNT=${CDMNT-/cdmnt-install} -FSMNT=${FSMNT-/mnt} -UZIP_DIR="/usr" -BOOT_PART_MOUNT="/boot-mount" -export FSMNT CDMNT UZIP_DIR BOOT_PART_MOUNT - -# Set the location of component files on DVD / usb / ftp -# Relative to CDMNT or the FTP root -COMPFILEDIR="extras/" -export COMPFILEDIR - -# Set the component temp directory, which is relative to FSMNT -COMPTMPDIR="/usr/.componenttmp" -export COMPTMPDIR - -# set the package temp directory, which is relative to FSMNT -PKGTMPDIR="/usr/.pkgtmp" -export PKGTMPDIR - -# Variables to set the location of installation data -UZIP_FILE="PCBSD.ufs.uzip" -TAR_FILE="PCBSD.tbz" -export UZIP_FILE TAR_FILE - -# Locations of FreeBSD only install files -FBSD_UZIP_FILE="fbsd-release.ufs.uzip" -FBSD_TAR_FILE="fbsd-release.tbz" -FBSD_BRANCH="8.0-RELEASE" -FBSD_BRANCH_DIR="${FBSD_BRANCH}" -FBSD_ARCH=`uname -m` -export FBSD_UZIP_FILE FBSD_TAR_FILE FBSD_BRANCH FBSD_BRANCH_DIR FBSD_ARCH - -# Location of image file -IMAGE_FILE="/home/john/tmp/PCBSD8.1-x86-USB.img" -export IMAGE_FILE - -# Our internet mirror listing file location -NETSERVER="http://updates.pcbsd.org" -ARCH="`uname -m`" - -# Check if we are running on a PC-BSD Disk -if [ -e "/PCBSDVERSION" ] ; then - VERSION="`cat /PCBSDVERSION`" -else - VERSION="UNKNOWN" -fi - -MIRRORLIST="${NETSERVER}/mirrors-netinstall.php?ver=${VERSION}&arch=${ARCH}" diff --git a/usr.sbin/pc-sysinstall/doc/Makefile b/usr.sbin/pc-sysinstall/doc/Makefile deleted file mode 100644 index 7d26c53cc0b..00000000000 --- a/usr.sbin/pc-sysinstall/doc/Makefile +++ /dev/null @@ -1,7 +0,0 @@ -# $FreeBSD: stable/11/usr.sbin/pc-sysinstall/doc/Makefile 284321 2015-06-12 14:30:27Z sjg $ - -FILES= help-disk-list help-disk-size help-index help-start-autoinstall - -FILESDIR=${SHAREDIR}/pc-sysinstall/doc - -.include diff --git a/usr.sbin/pc-sysinstall/doc/Makefile.depend b/usr.sbin/pc-sysinstall/doc/Makefile.depend deleted file mode 100644 index b72e2d5275e..00000000000 --- a/usr.sbin/pc-sysinstall/doc/Makefile.depend +++ /dev/null @@ -1,11 +0,0 @@ -# $FreeBSD: stable/11/usr.sbin/pc-sysinstall/doc/Makefile.depend 284345 2015-06-13 19:20:56Z sjg $ -# Autogenerated - do NOT edit! - -DIRDEPS = \ - - -.include - -.if ${DEP_RELDIR} == ${_DEP_RELDIR} -# local dependencies - needed for -jN in clean tree -.endif diff --git a/usr.sbin/pc-sysinstall/doc/help-disk-list b/usr.sbin/pc-sysinstall/doc/help-disk-list deleted file mode 100644 index 0d4bff90f3c..00000000000 --- a/usr.sbin/pc-sysinstall/doc/help-disk-list +++ /dev/null @@ -1 +0,0 @@ -Holder diff --git a/usr.sbin/pc-sysinstall/doc/help-disk-size b/usr.sbin/pc-sysinstall/doc/help-disk-size deleted file mode 100644 index 0d4bff90f3c..00000000000 --- a/usr.sbin/pc-sysinstall/doc/help-disk-size +++ /dev/null @@ -1 +0,0 @@ -Holder diff --git a/usr.sbin/pc-sysinstall/doc/help-index b/usr.sbin/pc-sysinstall/doc/help-index deleted file mode 100644 index bad401f1ef1..00000000000 --- a/usr.sbin/pc-sysinstall/doc/help-index +++ /dev/null @@ -1,100 +0,0 @@ -pc-sysinstall Help Index ------------------------------------------------ -Help Commands - - help - Display this index file - - help - Display the help data for the specified command - -System Query Commands - install-image - Installs an image file to a device file - - disk-list - Provides a listing of the disk drives detected on this system - - disk-part - Queries the specified disk and returns information about its partitions - - disk-info - Returns information about the disks size, cyls, heads, and sectors - - detect-laptop - Tests to see if this system is a laptop or desktop - - detect-emulation - Tests to see if this system is actually running in an emulator such as VirtualBox - - detect-nics - Returns a listing of the detected network cards on this system - - list-config - Returns a listing of the pc-sysinstall configuration - - list-components - Returns a listing of the available components which can be installed - - list-mirrors [country] - Returns a listing of the available FTP mirrors - - list-packages [category] [package] - Returns a listing of the available packages - - list-rsync-backups - Returns a listing of available rsync-backups on the target server in the life-preserver/ dir - - list-tzones - Returns a listing of available timezones - - query-langs - Return a list of languages that the installer supports - - get-packages - Retrieves the list of packages from an FTP mirror - - sys-mem - Return the size of installed system RAM in MegaBytes - - set-mirror - Set FTP mirror - - test-netup - Test if an internet connection is available - - update-part-list - Return a list of PC-BSD & FreeBSD installs on this system for updates - - xkeyboard-layouts - Return a list of keyboard layouts that xorg supports - - xkeyboard-models - Return a list of keyboard models that xorg supports - - xkeyboard-variants - Return a list of keyboard variants that xorg supports - -Partition Management Commands - - create-part - Create a new MBR primary slice on the target using MB - - delete-part - Deletes the disk partition specified. If this is the last partition, - the disk partition layout will also be scrubbed, leaving a clean disk - ready for MBR or GPT file system layouts. - - -Installation Commands - - -c - Begin a install / upgrade with the specified cfg file - - start-autoinstall - Start an automated installation with the specified conf file - Normally only used by automated install scripts - - setup-ssh-keys - Setup SSH without a password for the target host and user and port - Use to prompt the user to log into a server before doing a rsync + ssh restore diff --git a/usr.sbin/pc-sysinstall/doc/help-start-autoinstall b/usr.sbin/pc-sysinstall/doc/help-start-autoinstall deleted file mode 100644 index 1cb1e6aefcc..00000000000 --- a/usr.sbin/pc-sysinstall/doc/help-start-autoinstall +++ /dev/null @@ -1,39 +0,0 @@ -start-autoinstall - HELP ------------------------------------------------ - -About: - start-autoinstall is used when performing automated installationsr. It is able - to configure networking with provided settings, and fetch an installation script from - http / ftp server. This allows media to be created which fetches dynamic configuration - options from a server-side supplier. - -Usage: - pc-sysinstall start-autoinstall - -Config Syntax: - - The configuration file for start-autoinstall can contain the following options: - - pc_config: - - Location of the pc-sysinstall installation configuration file, can be local - or start with http:// or ftp:// to fetch from a remote system. - - shutdown_cmd: - - Command to execute post-installation, such as "shutdown -p now" or other. - - confirm_install: (YES/NO) - - Prompt on the console to begin installation. Defaults to YES. - Warning: Setting this to NO will start an installation as soon as start-autoinstall - is run. (I.E. after booting some install media) It may be dangerous if a disk is left - in a drive and the system is turned on! - - nic_config: (DHCP-ALL / ) - - When set to DHCP-ALL, the software will attempt to get a network address from DHCP on - any / all detected NICS. If set to some other command, it will be used as an argument - to "ifconfig" to enable networking. - - nic_dns: - - Use the following DNS server for networking - - nic_gateway: - - Use the following default route / gateway for networking diff --git a/usr.sbin/pc-sysinstall/examples/Makefile b/usr.sbin/pc-sysinstall/examples/Makefile deleted file mode 100644 index 61ca5817819..00000000000 --- a/usr.sbin/pc-sysinstall/examples/Makefile +++ /dev/null @@ -1,10 +0,0 @@ -# $FreeBSD: stable/11/usr.sbin/pc-sysinstall/examples/Makefile 284255 2015-06-11 04:22:17Z sjg $ - -FILES= README pc-autoinstall.conf pcinstall.cfg.fbsd-netinstall \ - pcinstall.cfg.geli pcinstall.cfg.gmirror pcinstall.cfg.netinstall \ - pcinstall.cfg.restore pcinstall.cfg.rsync pcinstall.cfg.upgrade \ - pcinstall.cfg.zfs - -FILESDIR=${SHAREDIR}/examples/pc-sysinstall - -.include diff --git a/usr.sbin/pc-sysinstall/examples/Makefile.depend b/usr.sbin/pc-sysinstall/examples/Makefile.depend deleted file mode 100644 index b46e3ba882e..00000000000 --- a/usr.sbin/pc-sysinstall/examples/Makefile.depend +++ /dev/null @@ -1,11 +0,0 @@ -# $FreeBSD: stable/11/usr.sbin/pc-sysinstall/examples/Makefile.depend 284345 2015-06-13 19:20:56Z sjg $ -# Autogenerated - do NOT edit! - -DIRDEPS = \ - - -.include - -.if ${DEP_RELDIR} == ${_DEP_RELDIR} -# local dependencies - needed for -jN in clean tree -.endif diff --git a/usr.sbin/pc-sysinstall/examples/README b/usr.sbin/pc-sysinstall/examples/README deleted file mode 100644 index 9a05dcc283f..00000000000 --- a/usr.sbin/pc-sysinstall/examples/README +++ /dev/null @@ -1,403 +0,0 @@ -pc-sysinstall README - -This file documents many of the variables used in pc-sysinstall -config scripts -################################################################# - -# hostname= - -Using hostname= will set the specified hostname on the -installed system - -When hostname= is not present, pc-sysinstall will auto-generate -a hostname such as freebsd-XXXX or pcbsd-XXXX - -# installMode=(fresh/upgrade/extract) - -Set the type of install we are doing. - -Fresh installs will format and mount the target disks before -extracting the install images to the system. Using this mode -it is also possible to do a system restore, by specifying a -full system backup as the install source. - -Upgrades will mount the target disk, and extract the system -archive to the disk, overwriting files on the disk. -The conf/exclude-from-upgrade file can be used to specify -additional files to exclude from overwriting during the -install process. - -Extract will skip any disk setup, and perform an installation -to the directory specified by "installLocation=". This location -should be a directory with your pre-mounted file-systems ready -for file extraction. When using the "extract" option, /etc/fstab -on the installed system will *not* be automatically configured. - -# installLocation= - -Used only when installMode is set to extract. - -This is set to the location you want to extract your system to, -and should already be mounted properly. - -# installInteractive=(yes or no) - -Set if the installer is running in interactive mode, and -is able to prompt for input from the user, defaults to no - - -######################################################################## -# NETWORK SETTINGS -######################################################################## - -# netDev=(AUTO-DHCP or ) - -netDev specifies what type of networking to enable for the installer -Can be set to AUTO-DHCP or to a network interface, such as et0 - -When set to AUTO-DHCP, pc-sysinstall will probe for all network devices -and attempt to set DHCP mode on each, until a working network connection -is established - -If netDev= is set to a network interface such as et0, the following options -will need to be set in order to enable the interface - -# netIP=(IP address such as 192.168.0.100) - - Set netIP to an address that you wish to have the interface specified in - netDev set to - Only used when netDev is not set to AUTO-DHCP - -# netMask=(Netmask such as 255.255.255.0) - -Set netMask to the address you with to have the interface specified in -netDev set to -Only used when netDev is not set to AUTO-DHCP - - -# netNameServer=(DNS Server such as 192.168.0.1) - -Set netNameServer to the DNS address you want to use during the install -Only used when netDev is not set to AUTO-DHCP - - -# netDefaultRouter=(192.168.0.1) - -Set netDefaultRouter to the gateway you wish to have the installer use -Only used when netDev is not set to AUTO-DHCP - - - -# netSaveDev=(AUTO-DHCP or network interface) - -netSaveDev specifies what networking to enable on the installed system - -When set to AUTO-DHCP, pc-sysinstall will probe all network interfaces, and -set them all to DHCP in the systems /etc/rc.conf file. Wireless devices will also -have the corresponding wlan[0-9] device created. - -When set to a network interface, pc-sysinstall will set the target device with -the settings specified by the variables below. - -# netSaveIP=192.168.0.49 -# netSaveMask=255.255.255.0 -# netSaveNameServer=208.67.222.222 -# netSaveDefaultRouter=192.168.0.1 - - - - -######################################################################## -# DISK SLICE SETTINGS -######################################################################## - -The following section specifies the target disk(s) to be used in the -install or upgrade. - -# disk0=(disk device, such as ad0) - -The diskX= variable should be set to the target device for this drive, such -as ad0, da0 -The first should begin with disk0=, and additional drives to disk1=, disk2 -if additional disks are to be setup. - -When doing an upgrade, the disk0= line should be set to the root device or -root zpool of the target system to update. I.E: - # disk0=tank0 - # disk0=ada0s1a - - -# partition=(all, free, s1, s1, s3, s4, image) - -After setting disk[0-9], the partition= variable is used to specify which target -partition we will be working with for this device. - -Setting this to "all" will setup the disk with a single FreeBSD slice as "s1" - -Setting this to "free" will allow pc-sysinstall to search for the first available -primary slice with free space, and create the slice. - -Setting this to "s1, s2, s3 or s4" will use the specified MBR slice. - -Setting this to "image" will use an image to configure the disk. - -(This tag is unused for upgrades) - -# partscheme=(MBR/GPT) - -When performing a "full" disk (partition=all), the partscheme= variable is used -to determine the partition scheme type gpart will be using on the disk. Valid -choices are MBR or GPT. - -# mirror=(disk device such as ad1) - -Setting the mirror= variable will setup the target device as a gmirror -of the diskX= device. The mirror device must be the same size or larger -than the drive being mirrored. - - -# mirrorbal=(load, prefer, round-robin, split) - -Allows the setting of the mirror balance method to be used, if not -specified this defaults to "round-robin" - -# bootManager=(none, bsd) - -Setting this option will instruct pc-sysinstall to install the BSD boot Manager, -or leave it empty - -# image=(/path/to/image/file) (/mountpoint) - -Setting this option will instruct pc-sysinstall to write the image file -specified by the path to the disk. - -# commitDiskPart - -This command must be placed at the end of the diskX= section, before starting -the listing of any additional diskX= directives. - - -######################################################################## -# DISK PARTITION / MOUNT SETTINGS -######################################################################## - -The following settings specify the partitioning / mount points to setup -on the target partition - -# disk0-part=UFS+S 500 / (-n -o time) -# disk0-part=SWAP 2000 none -# disk0-part=UFS.eli 500 /usr -# encpass=mypass -# disk0-part=UFS+J 500 /tmp -# disk0-part=ZFS 0 /data,/storage (mirror: ad1) -# commitDiskLabel - -The above values instructs pc-sysinstall which partitions / mounts -to create on the target drive / slice, specified by "disk0". -(disk0 will resolve to the drive / slice specified in the previous section) - -The notation is as follows: - - -Available FileSystems: - UFS - Standard UFS2 FileSystem -UFS+S - UFS2 + Softupdates enabled -UFS+SUJ - UFS2 + Soft Updates + Journaling enabled -UFS+J - UFS2 + Journaling through gjournal - ZFS - Z File System, pools / mounts created automatically - SWAP - BSD Swap space partition, mountpoint should be set to "none" - -Adding the ".eli" extension to any of the above file systems -will enable disk encryption via geli -(UFS.eli, UFS+S.eli, UFS+SUJ.eli, UFS+J.eli, ZFS.eli, SWAP.eli) - -If you with to use a passphrase with this encrypted partition, on the next line -the flag "encpass=" should be entered: -encpass=mypass - -All sizes are expressed in MegaBytes -Specifying a size 0 instructs pc-sysinstall to use the rest of the -available slice size, and should only be used for the last partition / mount - -When using "UFS" and its various types, it is possible to specify custom options -for newfs using (). For examplei: -disk0-part=UFS+SUJ 1000 / (-o time) -In this case "-o time" would be passed to newfs when creating the "/" filesystem. - - -When using "ZFS" specifically, it is possible to specify additional disks / partitions -to include in the zpool. By using the syntax: (mirror: ad1,ad2) or (raidz: ad1,ad2), it is possible -to include the disk "ad1" into the zpool for this partition, using the raidz / mirror methods. -If you with to just include the disk into the pool in "basic" mode, then use (ad1,ad2) with no flags - -######################################################################## -# INSTALL OPTIONS / SOURCES -######################################################################## - -The following settings specify the type, locations and sources -for this installation - -# installMedium=(dvd, usb, ftp, rsync, image) - -Set installMedium= to the source type we will be using for this install. - -Available Types: - dvd - Search for and mount the DVD which contains the install archive -local - Pull files directly from a local directory - usb - Search for and mount the USB drive which contains the install archive - ftp - The install archive will be fetched from a FTP / HTTP server before install -rsync - Pull the system data from a ssh + rsync server, specified with variables below -image - Install system from an image - -# localPath=/usr/freebsd-dist - -Location of the directory we will be pulling installation files from - -# installType=(PCBSD, FreeBSD) - -Set the type of system we are installing, PCBSD or FreeBSD - -# installFile=fbsd-release.tbz - -The installer archive, if not using the defaults specified in conf/pc-sysinstall.conf - -# packageType=(tar, uzip, split, dist) - -The archive type we are extracting from when using dvd, usb or ftp - -# distFiles=base src kernel - -List of dist files to install when packageType=dist - -# ftpPath=ftp://ftp.pcbsd.org/pub/8.0/netinstall - -Location of the installer archive when using a installMedium=ftp - -# rsyncPath=life-preserver/back-2009-11-12T14_53_14 - -The location of the rsync data on the remote server when using installMedium=rsync - -# rsyncUser=rsyncuser - -The username to use for the ssh server running rsync - -# rsyncHost=192.168.0.50 - -The rsync / ssh server we wish to connect to - -# rsyncPort=22 - -The port to use when connecting to a ssh + rsync server - -# installComponents=amarok,firefox,ports - -The specified components to install, view available with "./pc-sysinstall list-components" - - -######################################################################## -# UPGRADE OPTIONS -######################################################################## - -Options specific to performing an upgrade - -# upgradeKeepDesktopProfile=(yes/no) - -This option allows you to specify if you wish to keep your existing users desktop -profile data. The default is NO, and your existing profile will be moved to -.kde4.preUpgrade automatically. - -######################################################################## -# USER OPTIONS -######################################################################## - -Options for setting up usernames and passwords on the installed system - -# rootPass=root - -Set the root password of the installed system to the specified plaintext string - -# rootEncPass= - -Set the root password of the installed system to the specified encrypted string - -The below variables are used to setup a user on the installed system -Be sure to call commitUser after after adding these values, and before -starting another user block - -# userName=kris -# userComment=Kris Moore -# userPass=mypass -or -# userEncPass= -# userShell=/bin/csh -# userHome=/home/kris -# userGroups=wheel,operator -# commitUser - -######################################################################## -# RUN COMMANDS -######################################################################## - -The following variables can be set to run commands post-installation, -allowing the user to further tweak / modify the system - -# runCommand= - -Run the specified command within chroot of the installed system - -# runScript= - -runScript will copy the specified script into FSMNT, and run it in chroot of the system -Useful when you have a 3rd party script on the DVD / USB, and you want to copy it into -the installed system and run - -# runExtCommand= - -runExtCommand is used when you wish to run a command outside the chroot -The variable $FSMNT is set to the mount-point of your installed system - - -######################################################################## -# PC-BSD SPECIFIC OPTIONS -######################################################################## - -Options for time-zones and NTP on the installed system - -# timeZone= - -timeZone can be set to the zone file in /usr/share/zoneinfo/ that is to be used -example: America/New_York - -# enableNTP= (yes / no) - -set enableNTP to yes or no to enable or disable the NTP service on the system - - -######################################################################## -# PC-BSD SPECIFC OPTIONS -######################################################################## - -Options specific to installing PC-BSD, such as localization, and KDE settings - -# localizeLang=en - -localizeLang will set the system console and Desktop to the target language - -# localizeKeyLayout=en - -localizeKeyLayout updates the system's xorg config to set the keyboard layout - -# localizeKeyModel=pc104 - -localizeKeyModel updates the system's xorg config to set the keyboard model - -# localizeKeyVariant=intl - -localizeKeyVariant is used to update the xorg config to set the keyboard variant - -# autoLoginUser=kris - -Setting autoLoginUser will enable the specified user to log into the desktop -automatically without entering a password - -$FreeBSD: stable/11/usr.sbin/pc-sysinstall/examples/README 247705 2013-03-03 09:47:47Z jpaetzel $ diff --git a/usr.sbin/pc-sysinstall/examples/pc-autoinstall.conf b/usr.sbin/pc-sysinstall/examples/pc-autoinstall.conf deleted file mode 100644 index bd5ea3ea06b..00000000000 --- a/usr.sbin/pc-sysinstall/examples/pc-autoinstall.conf +++ /dev/null @@ -1,52 +0,0 @@ -# pc-autoinstall.conf example -# $FreeBSD: stable/11/usr.sbin/pc-sysinstall/examples/pc-autoinstall.conf 209513 2010-06-24 22:21:47Z imp $ -# -# Usage: Modify these variables, and copy the file to -# /boot/pc-autoinstall.conf on your PC-BSD installation medium -# -# The conf will then be read at bootup, and your automated -# install will take place -################################################################## - -# Where the pc-sysinstall main config is located -# Can be either a file on the booted CD / DVD / USB media, -# or a remote file on http / ftp -# -# The value %%NIC_MAC%% is special, and will be substituted with -# the macaddress of the enabled NIC from DHCP or manually set -# with 'nic_config:' -################################################################## - -# Examples: -# pc_config: ftp://192.168.0.2/cust-install.cfg -# pc_config: http://192.168.0.2/cust-install.cfg -# pc_config: http://192.168.0.2/%%NIC_MAC%%.cfg -# pc_config: /boot/cust-install.cfg - -# Set this to yes if we should confirm before doing an install -# This should normally be set to yes, otherwise booting the wrong -# disk will result in a system wipe -# confirm_install: no -confirm_install: yes - -# Set the command to run post-install, usually best to run shutdown -# but this can be replaced with any other command / script you wish -# to execute post-install -# shutdown_cmd: shutdown -p now - -# Options for the network setup, should the cfg need to be fetched -# from a remote location, only necessary when using ftp or http -################################################################## - -# Special option, will attempt dhcp on all found NICs -# until the file can be fetched, or we run out of interfaces -# nic_config: dhcp-all - -# Line to be passed to the "ifconfig" command to bring up an interface -# nic_config: em0 192.168.0.101 255.255.255.0 - -# DNS server to use -# nic_dns: 192.168.0.1 - -# Default router / gateway -# nic_gateway: 192.168.0.1 diff --git a/usr.sbin/pc-sysinstall/examples/pcinstall.cfg.fbsd-netinstall b/usr.sbin/pc-sysinstall/examples/pcinstall.cfg.fbsd-netinstall deleted file mode 100644 index 2a36f0d35be..00000000000 --- a/usr.sbin/pc-sysinstall/examples/pcinstall.cfg.fbsd-netinstall +++ /dev/null @@ -1,71 +0,0 @@ -# Sample configuration file for an installation using pc-sysinstall -#$FreeBSD: stable/11/usr.sbin/pc-sysinstall/examples/pcinstall.cfg.fbsd-netinstall 209513 2010-06-24 22:21:47Z imp $ - -installMode=fresh -installInteractive=yes -hostname=pcbsd8 - -# Set the disk parameters -disk0=ad0 -partition=all -bootManager=none -commitDiskPart - -# Setup the disk label -# All sizes are expressed in MB -# Avail FS Types, UFS, UFS+S, UFS+J, ZFS, SWAP -disk0-part=UFS 1000 / -disk0-part=SWAP 2000 none -disk0-part=UFS 0 /usr -# Size 0 means use the rest of the slice size -# Do it now! -commitDiskLabel - -netDev=AUTO-DHCP -#netDev=nfe0 -#netIP=192.168.0.49 -#netMask=255.255.255.0 -#netNameServer=208.67.222.222 -#netDefaultRouter=192.168.0.1 - -netSaveDev=AUTO-DHCP -#netSaveDev=nfe0 -#netSaveIP=192.168.0.49 -#netSaveMask=255.255.255.0 -#netSaveNameServer=208.67.222.222 -#netSaveDefaultRouter=192.168.0.1 - -# Set if we are installing via optical, USB, or FTP -#installType=PCBSD -installType=FreeBSD -#installMedium=dvd -installMedium=ftp - -ftpPath=ftp://192.168.0.2/netinstall - -#packageType=uzip -packageType=tar - -# List our components to install -installComponents=ports,src - -# Setup user "kris" to log into the desktop automatically -autoLoginUser=kris - -# Set the root pass -rootPass=root - -# Setup our users -userName=kris -userComment=Kris Moore -userPass=kris -userShell=/bin/csh -userHome=/home/kris -userGroups=wheel,operator -commitUser - -# Options for localizing an install -localizeLang="ru" -localizeKeyLayout="ru" -localizeKeyModel="pc104" -localizeKeyVariant="intl" diff --git a/usr.sbin/pc-sysinstall/examples/pcinstall.cfg.geli b/usr.sbin/pc-sysinstall/examples/pcinstall.cfg.geli deleted file mode 100644 index a9168bd2b22..00000000000 --- a/usr.sbin/pc-sysinstall/examples/pcinstall.cfg.geli +++ /dev/null @@ -1,50 +0,0 @@ -# Auto-Generated pc-sysinstall configuration -#$FreeBSD: stable/11/usr.sbin/pc-sysinstall/examples/pcinstall.cfg.geli 209513 2010-06-24 22:21:47Z imp $ - -installInteractive=no -installMode=fresh -installType=FreeBSD -packageType=tar -installMedium=dvd -netSaveDev=AUTO-DHCP - -# Timezone -timeZone=America/New_York -enableNTP=yes - -# Keyboard Layout Options -localizeKeyModel=pc104 -localizeKeyLayout=us - -# Disk Setup for ad0 -disk0=ad0 -partition=ALL -bootManager=none -commitDiskPart - -# Partition Setup for ad0(ALL) -# All sizes are expressed in MB -# Avail FS Types, UFS, UFS+S, UFS+J, ZFS, SWAP -# UFS.eli, UFS+S.eli, UFS+J.eli, ZFS.eli, SWAP.eli -disk0-part=UFS 500 /boot -disk0-part=UFS.eli 500 / -disk0-part=UFS.eli 500 /usr -encpass=mypass -commitDiskLabel - -# Optional Components -installComponents= - -# Root Password -rootPass=mypass - -# Users -userName=kris -userComment=Kris Moore -userPass=mypass -userShell=/bin/csh -userHome=/home/kris -userGroups=wheel,operator -autoLoginUser=kris -commitUser - diff --git a/usr.sbin/pc-sysinstall/examples/pcinstall.cfg.gmirror b/usr.sbin/pc-sysinstall/examples/pcinstall.cfg.gmirror deleted file mode 100644 index 3024775e61f..00000000000 --- a/usr.sbin/pc-sysinstall/examples/pcinstall.cfg.gmirror +++ /dev/null @@ -1,45 +0,0 @@ -# Sample configuration file for an installation using pc-sysinstall -#$FreeBSD: stable/11/usr.sbin/pc-sysinstall/examples/pcinstall.cfg.gmirror 209513 2010-06-24 22:21:47Z imp $ - -installMode=fresh -installInteractive=yes -hostname=pcbsd8 - -# Set the disk parameters -disk0=ad0 -mirror=ad1 -mirrorbal=split -partition=all -bootManager=bsd -commitDiskPart - -# Setup the disk label -# All sizes are expressed in MB -# Avail FS Types, UFS, UFS+S, UFS+J, ZFS, SWAP -disk0-part=UFS+S 500 / -disk0-part=SWAP 2000 none -disk0-part=UFS+S 0 /usr -# Size 0 means use the rest of the slice size -# Do it now! -commitDiskLabel - -# Set if we are installing via optical, USB, or FTP -installType=FreeBSD -installMedium=dvd - -#packageType=uzip -packageType=tar -#installComponents=ports,src - -# Run any commands post-install -runCommand=echo 'root' | pw usermod root -h 0 -#runScript=/root/test.sh -#runExtCommand=echo 'hey there'; touch $FSMNT/touched - -#autoLoginUser=kris - -# Options for localizing an install -localizeLang="ru" -localizeKeyLayout="ru" -localizeKeyModel="pc104" -localizeKeyVariant="intl" diff --git a/usr.sbin/pc-sysinstall/examples/pcinstall.cfg.netinstall b/usr.sbin/pc-sysinstall/examples/pcinstall.cfg.netinstall deleted file mode 100644 index 02b98bb99c2..00000000000 --- a/usr.sbin/pc-sysinstall/examples/pcinstall.cfg.netinstall +++ /dev/null @@ -1,68 +0,0 @@ -# Sample configuration file for an installation using pc-sysinstall -#$FreeBSD: stable/11/usr.sbin/pc-sysinstall/examples/pcinstall.cfg.netinstall 209513 2010-06-24 22:21:47Z imp $ - -installMode=fresh -installInteractive=yes -hostname=pcbsd8 - -# Set the disk parameters -disk0=ad0 -partition=all -bootManager=none -commitDiskPart - -# Setup the disk label -# All sizes are expressed in MB -# Avail FS Types, UFS, UFS+S, UFS+J, ZFS, SWAP -disk0-part=UFS 1000 / -disk0-part=SWAP 2000 none -disk0-part=UFS 0 /usr -# Size 0 means use the rest of the slice size -# Do it now! -commitDiskLabel - -netDev=AUTO-DHCP -#netDev=nfe0 -#netIP=192.168.0.49 -#netMask=255.255.255.0 -#netNameServer=208.67.222.222 -#netDefaultRouter=192.168.0.1 - -netSaveDev=AUTO-DHCP -#netSaveDev=nfe0 -#netSaveIP=192.168.0.49 -#netSaveMask=255.255.255.0 -#netSaveNameServer=208.67.222.222 -#netSaveDefaultRouter=192.168.0.1 - -# Set if we are installing via optical, USB, or FTP -#installType=PCBSD -installType=FreeBSD -#installMedium=dvd -installMedium=ftp - -ftpPath=ftp://192.168.0.2/netinstall - -#packageType=uzip -packageType=tar -#installComponents=ports,src - -#autoLoginUser=kris - -# Set the root pass -rootPass=root - -# Setup our users -userName=kris -userComment=Kris Moore -userPass=kris -userShell=/bin/csh -userHome=/home/kris -userGroups=wheel,operator -commitUser - -# Options for localizing an install -localizeLang="ru" -localizeKeyLayout="ru" -localizeKeyModel="pc104" -localizeKeyVariant="intl" diff --git a/usr.sbin/pc-sysinstall/examples/pcinstall.cfg.restore b/usr.sbin/pc-sysinstall/examples/pcinstall.cfg.restore deleted file mode 100644 index be29e78f73f..00000000000 --- a/usr.sbin/pc-sysinstall/examples/pcinstall.cfg.restore +++ /dev/null @@ -1,57 +0,0 @@ -# Sample configuration file for an installation using pc-sysinstall -#$FreeBSD: stable/11/usr.sbin/pc-sysinstall/examples/pcinstall.cfg.restore 209513 2010-06-24 22:21:47Z imp $ - -installMode=fresh -installInteractive=no -hostname=freebsd8 - -# Set the disk parameters -disk0=ad1 -partition=all -bootManager=none -commitDiskPart - -# Setup the disk label -# All sizes are expressed in MB -# Avail FS Types, UFS, UFS+S, UFS+J, ZFS, SWAP -# UFS.eli, UFS+S.eli, UFS+J.eli, ZFS.eli, SWAP.eli -disk0-part=UFS+S 500 / -disk0-part=SWAP.eli 2000 none -disk0-part=UFS+S 0 /usr -# Size 0 means use the rest of the slice size -# Do it now! -commitDiskLabel - -# Set if we are installing via optical, USB, or FTP -installType=FreeBSD -installMedium=dvd -installFile=freebsd-release.tbz - -#packageType=uzip -packageType=tar -#installComponents=ports,src - -# Run any commands post-install -#runCommand=echo 'root' | pw usermod root -h 0 -#runScript=/root/test.sh -#runExtCommand=echo 'hey there'; touch $FSMNT/touched - -# Set the root pass -rootPass=root - -# Setup our users -userName=kris -userComment=Kris Moore -userPass=kris -userShell=/bin/csh -userHome=/home/kris -userGroups=wheel,operator -commitUser - -#autoLoginUser=kris - -# Options for localizing an install -localizeLang="ru" -localizeKeyLayout="ru" -localizeKeyModel="pc104" -localizeKeyVariant="intl" diff --git a/usr.sbin/pc-sysinstall/examples/pcinstall.cfg.rsync b/usr.sbin/pc-sysinstall/examples/pcinstall.cfg.rsync deleted file mode 100644 index f0b62e6cefb..00000000000 --- a/usr.sbin/pc-sysinstall/examples/pcinstall.cfg.rsync +++ /dev/null @@ -1,45 +0,0 @@ -# Sample configuration file for an installation using pc-sysinstall -#$FreeBSD: stable/11/usr.sbin/pc-sysinstall/examples/pcinstall.cfg.rsync 209513 2010-06-24 22:21:47Z imp $ - -installMode=fresh -installInteractive=yes -hostname=pcbsd8 - -# Set the disk parameters -disk0=ad0 -partition=all -bootManager=none -commitDiskPart - -# Setup the disk label -# All sizes are expressed in MB -# Avail FS Types, UFS, UFS+S, UFS+J, ZFS, SWAP -disk0-part=UFS 2000 / -disk0-part=SWAP 2000 none -disk0-part=UFS 0 /usr -# Size 0 means use the rest of the slice size -# Do it now! -commitDiskLabel - -netDev=AUTO-DHCP -#netDev=nfe0 -#netIP=192.168.0.49 -#netMask=255.255.255.0 -#netNameServer=208.67.222.222 -#netDefaultRouter=192.168.0.1 - -# Set if we are installing via optical, USB, or FTP -#installType=PCBSD -installType=FreeBSD -#installMedium=dvd -installMedium=rsync - -rsyncPath=life-preserver/back-2009-11-12T14_53_14 -rsyncUser=lifep -rsyncHost=192.168.0.50 -rsyncPort=22 - -#packageType=uzip -packageType=tar -#installComponents=ports,src - diff --git a/usr.sbin/pc-sysinstall/examples/pcinstall.cfg.upgrade b/usr.sbin/pc-sysinstall/examples/pcinstall.cfg.upgrade deleted file mode 100644 index a88116ed3e8..00000000000 --- a/usr.sbin/pc-sysinstall/examples/pcinstall.cfg.upgrade +++ /dev/null @@ -1,24 +0,0 @@ -# Sample configuration file for an installation using pc-sysinstall -#$FreeBSD: stable/11/usr.sbin/pc-sysinstall/examples/pcinstall.cfg.upgrade 209513 2010-06-24 22:21:47Z imp $ - -installMode=upgrade -installInteractive=no -hostname=freebsd8 - -# Set the disk parameters -disk0=ada0s1a -bootManager=none -commitDiskPart - -# Set if we are installing via optical, USB, or FTP -installType=PCBSD -installMedium=dvd - -packageType=uzip -#installComponents=ports,src - -# Options for localizing an install -localizeLang="ru" -localizeKeyLayout="ru" -localizeKeyModel="pc104" -localizeKeyVariant="intl" diff --git a/usr.sbin/pc-sysinstall/examples/pcinstall.cfg.zfs b/usr.sbin/pc-sysinstall/examples/pcinstall.cfg.zfs deleted file mode 100644 index b98e130c1c0..00000000000 --- a/usr.sbin/pc-sysinstall/examples/pcinstall.cfg.zfs +++ /dev/null @@ -1,59 +0,0 @@ -# Auto-Generated pc-sysinstall configuration -#$FreeBSD: stable/11/usr.sbin/pc-sysinstall/examples/pcinstall.cfg.zfs 209513 2010-06-24 22:21:47Z imp $ -installInteractive=no -installMode=fresh -installType=FreeBSD -packageType=tar -installMedium=dvd -netSaveDev=AUTO-DHCP - -# Timezone -timeZone=America/New_York -enableNTP=yes - -# Keyboard Layout Options -localizeKeyModel=pc104 -localizeKeyLayout=us - -# Disk Setup for ad0 -disk0=ad0 -partition=ALL -bootManager=none -commitDiskPart - -# Partition Setup for ad0(ALL) -# All sizes are expressed in MB -# Avail FS Types, UFS, UFS+S, UFS+J, ZFS, SWAP -# UFS.eli, UFS+S.eli, UFS+J.eli, ZFS.eli, SWAP.eli -disk0-part=ZFS 0 /,/usr,/var,/data (mirror: ad1) -commitDiskLabel - -# Disk Setup for ad3 -disk1=ad3 -partition=ALL -bootManager=none -commitDiskPart - -# Partition Setup for ad3(ALL) -# All sizes are expressed in MB -# Avail FS Types, UFS, UFS+S, UFS+J, ZFS, SWAP -# UFS.eli, UFS+S.eli, UFS+J.eli, ZFS.eli, SWAP.eli -disk1-part=SWAP 0 none -commitDiskLabel - -# Optional Components -installComponents= - -# Root Password -rootPass=mypass - -# Users -userName=kris -userComment=Kris Moore -userPass=mypass -userShell=/bin/csh -userHome=/home/kris -userGroups=wheel,operator -autoLoginUser=kris -commitUser - diff --git a/usr.sbin/pc-sysinstall/pc-sysinstall/Makefile b/usr.sbin/pc-sysinstall/pc-sysinstall/Makefile deleted file mode 100644 index 5a118649a56..00000000000 --- a/usr.sbin/pc-sysinstall/pc-sysinstall/Makefile +++ /dev/null @@ -1,6 +0,0 @@ -# $FreeBSD: stable/11/usr.sbin/pc-sysinstall/pc-sysinstall/Makefile 209554 2010-06-27 17:14:04Z imp $ - -SCRIPTS=pc-sysinstall.sh -MAN= pc-sysinstall.8 - -.include diff --git a/usr.sbin/pc-sysinstall/pc-sysinstall/Makefile.depend b/usr.sbin/pc-sysinstall/pc-sysinstall/Makefile.depend deleted file mode 100644 index d9e5f04d8f2..00000000000 --- a/usr.sbin/pc-sysinstall/pc-sysinstall/Makefile.depend +++ /dev/null @@ -1,11 +0,0 @@ -# $FreeBSD: stable/11/usr.sbin/pc-sysinstall/pc-sysinstall/Makefile.depend 284345 2015-06-13 19:20:56Z sjg $ -# Autogenerated - do NOT edit! - -DIRDEPS = \ - - -.include - -.if ${DEP_RELDIR} == ${_DEP_RELDIR} -# local dependencies - needed for -jN in clean tree -.endif diff --git a/usr.sbin/pc-sysinstall/pc-sysinstall/pc-sysinstall.8 b/usr.sbin/pc-sysinstall/pc-sysinstall/pc-sysinstall.8 deleted file mode 100644 index 7c0b05d628f..00000000000 --- a/usr.sbin/pc-sysinstall/pc-sysinstall/pc-sysinstall.8 +++ /dev/null @@ -1,120 +0,0 @@ -.\" Copyright (c) 2010 -.\" iXsystems, Inc. All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" -.\" THIS SOFTWARE IS PROVIDED BY 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 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. -.\" -.\" $FreeBSD: stable/11/usr.sbin/pc-sysinstall/pc-sysinstall/pc-sysinstall.8 267668 2014-06-20 09:57:27Z bapt $ -.\" -.Dd June 24, 2010 -.Dt PC-SYSINSTALL 8 -.Os -.Sh NAME -.Nm pc-sysinstall -.Nd System installer backend -.Sh SYNOPSIS -.Nm -.Op Fl c Ar file -.Op Ar command -.Sh DESCRIPTION -The -.Nm -utility is a hybrid backend for installing FreeBSD. When run in install mode -it takes a configuration file and performs an installation according to the -parameters specified in the configuration file. When called with one of -the system query commands it provides information about the system to aid a -front end in building an appropriate configuration file. -.Pp -The following options are available: -.Bl -tag -width indent -.It Fl c Ar file -Perform an installation as directed by -.Ar file. -.El -.Sh COMMANDS -The -.Cm command -can be any one of the following: -.Bl -tag -width indent -.It help -Display a list of all commands. -.It help Ar command -Display the help data for the specified command. -.It disk-list -Provide a listing of the storage devices detected on this system. -.It disk-part Ar disk -Queries the specified storage device and returns information about its -partitions. -.It disk-info Ar disk -Returns information about a storage device's size, cylinders, heads, and -sectors. -.It detect-laptop -Tests to see if this system is a laptop or desktop. -.It detect-emulation -Tests to see if this system is running in an emulator -.It detect-nics -Returns a listing of the detected network cards on this system. -.It list-components -Returns a listing of the available components which can be installed. -.It list-rsync-backups Ar user Ar host Ar port -Returns a listing of available rsync-backups on the target server in the -life-preserver/ directory. -.It list-tzones -Returns a listing of available timezones. -.It query-langs -Returns a list of languages that the installer supports. -.It sys-mem -Returns the size of installed system RAM in MegaBytes. -.It test-netup -test if an internet connection is available. -.It update-part-list -Returns a list of PC-BSD and FreeBSD installs on this system for updates. -.It xkeyboard-layouts -Returns a list of keyboard layouts that xorg supports. -.It xkeyboard-models -Returns a list of keyboard models that xorg supports. -.It xkeyboard-variants -Returns a list of keyboard variants that xorg supports. -.It create-part Ar disk Ar size -Create a new MBR primary slice on the target disk using size MB. -.It delete-part Ar partition -Delete the disk partition specified. If this is the last partition, the -disk partition layout will also be scrubbed, leaving a clean disk ready -for MBR or GPT file system layouts. -.It start-autoinstall Ar file -Start an automated installation with the specified file. Normally only -used by automated install scripts. -.It setup-ssh-keys Ar user Ar host Ar port -Setup SSH without a password for the target host, user, and port. Used to -prompt the user to log into a server before doing a rsync + ssh restore. -.El -.Sh HISTORY -This version of -.Nm -first appeared in -.Fx 9.0 . -.Sh AUTHORS -.An Kris Moore Aq Mt kmoore@FreeBSD.org -.Sh BUGS -This utility was written to install PC-BSD and has seen limited use as an -installer for FreeBSD. It's likely that usage to install FreeBSD will expose -edge cases that PC-BSD doesn't, as well as generate feature requests based -on unforeseen needs. diff --git a/usr.sbin/pc-sysinstall/pc-sysinstall/pc-sysinstall.sh b/usr.sbin/pc-sysinstall/pc-sysinstall/pc-sysinstall.sh deleted file mode 100755 index 3e3a81899a3..00000000000 --- a/usr.sbin/pc-sysinstall/pc-sysinstall/pc-sysinstall.sh +++ /dev/null @@ -1,241 +0,0 @@ -#!/bin/sh -##################################################################### -# Author: Kris Moore -# License: BSD -# Description: pc-sysinstall provides a backend for performing -# system installations, as well as calls which a front-end can use -# to retrive information about the system -##################################################################### -# SPDX-License-Identifier: BSD-2-Clause-FreeBSD -# -# Copyright 2010 iXsystems -# All rights reserved -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted providing 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 AUTHOR 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. -# -##################################################################### - -# User-editable configuration variables - -# Set this to the program location -if [ -z "${PROGDIR}" ] -then - PROGDIR="/usr/share/pc-sysinstall" - export PROGDIR -fi - -# Set this to the components location -COMPDIR="${PROGDIR}/components" -export COMPDIR - -CONFDIR="${PROGDIR}/conf" -export CONFDIR - -# Set this to the packages location -PKGDIR="${CONFDIR}" -export PKGDIR - -# End of user-editable configuration -##################################################################### - -# Set our QUERYDIR -QUERYDIR="${PROGDIR}/backend-query" -export QUERYDIR - -# Set our BACKEND -BACKEND="${PROGDIR}/backend" -export BACKEND - -PARTMANAGERDIR="${PROGDIR}/backend-partmanager" -export PARTMANAGERDIR - -# Start by sourcing our conf file -if [ -e "${PROGDIR}/conf/pc-sysinstall.conf" ] -then - . ${PROGDIR}/conf/pc-sysinstall.conf -else - echo "ERROR: Could not find ${PROGDIR}/conf/pc-sysinstall.conf" - exit 1 -fi - -# Now source our functions.sh -if [ -e "${PROGDIR}/backend/functions.sh" ] -then - . ${PROGDIR}/backend/functions.sh -else - echo "ERROR: Could not find ${PROGDIR}/backend/functions.sh" - exit 1 -fi - - -# Check if we are called without any flags and display help -if [ -z "${1}" ] -then - # Display the help index - display_help - exit 0 -fi - -case $1 in - # The -c flag has been given, time to parse the script - -c) - if [ -z "${2}" ] - then - display_help - else - ${BACKEND}/parseconfig.sh ${2} - exit $? - fi - ;; - - # The user requsted help - help) - if [ -z "${2}" ] - then - display_help - else - display_command_help ${2} - fi - ;; - - # Install an image file to a device - install-image) ${BACKEND}/installimage.sh "${2}" "${3}" - ;; - - # Parse an auto-install directive, and begin the installation - start-autoinstall) ${BACKEND}/startautoinstall.sh ${2} - ;; - - # The user is wanting to create a new partition - create-part) ${PARTMANAGERDIR}/create-part.sh "${2}" "${3}" "${4}" "${5}" - ;; - - # The user is wanting to delete an existing partition - delete-part) ${PARTMANAGERDIR}/delete-part.sh "${2}" - ;; - - # The user is wanting to check if we are on a laptop or desktop - detect-laptop) ${QUERYDIR}/detect-laptop.sh - ;; - - # The user is wanting to see what nics are available on the system - detect-nics) ${QUERYDIR}/detect-nics.sh - ;; - - # The user is wanting to check if we are in emulation - detect-emulation) ${QUERYDIR}/detect-emulation.sh - ;; - - # The user is wanting to query a disk's information - disk-info) ${QUERYDIR}/disk-info.sh ${2} - ;; - - # The user is wanting to query which disks are available - disk-list) ${QUERYDIR}/disk-list.sh $* - ;; - - # The user is wanting to query a disk's partitions - disk-part) ${QUERYDIR}/disk-part.sh ${2} - ;; - - # Function allows the setting of networking by a calling front-end - enable-net) ${QUERYDIR}/enable-net.sh "${2}" "${3}" "${4}" "${5}" "${6}" "${7}" - ;; - - # Function which lists components available - list-components) ${QUERYDIR}/list-components.sh - ;; - - # Function which lists pc-sysinstall configuration - list-config) ${QUERYDIR}/list-config.sh - ;; - - # Function which lists available FTP mirrors - list-mirrors) ${QUERYDIR}/list-mirrors.sh "${2}" - ;; - - # Function which lists available packages - list-packages) ${QUERYDIR}/list-packages.sh "${2}" "${3}" - ;; - - # Function which lists available backups on a rsync/ssh server - list-rsync-backups) ${QUERYDIR}/list-rsync-backups.sh "${2}" "${3}" "${4}" - ;; - - # Function which lists timezones available - list-tzones) ${QUERYDIR}/list-tzones.sh - ;; - - # Requested a list of languages this install will support - query-langs) ${QUERYDIR}/query-langs.sh - ;; - - # Function which creates a error report, and mails it to the specified address - send-logs) ${QUERYDIR}/send-logs.sh ${2} - ;; - - # Function to get package index - get-packages) ${QUERYDIR}/get-packages.sh "${2}" - ;; - - # Function to set FTP mirror - set-mirror) ${QUERYDIR}/set-mirror.sh "${2}" - ;; - - # Function which allows setting up of SSH keys - setup-ssh-keys) ${QUERYDIR}/setup-ssh-keys.sh "${2}" "${3}" "${4}" - ;; - - # Function which lists the real memory of the system in MB - sys-mem) ${QUERYDIR}/sys-mem.sh - ;; - - # Run script which determines if we are booted from install media, or on disk - test-live) ${QUERYDIR}/test-live.sh - ;; - - # The user is wanting to test if the network is up and working - test-netup) ${QUERYDIR}/test-netup.sh - ;; - - # The user is wanting to get a list of partitions available to be updated / repaired - update-part-list) ${QUERYDIR}/update-part-list.sh - ;; - - # Requested a list of keyboard layouts that xorg supports - xkeyboard-layouts) ${QUERYDIR}/xkeyboard-layouts.sh - ;; - - # Requested a list of keyboard models that xorg supports - xkeyboard-models) ${QUERYDIR}/xkeyboard-models.sh - ;; - - # Requested a list of keyboard variants that xorg supports - xkeyboard-variants) ${QUERYDIR}/xkeyboard-variants.sh - ;; - - *) echo "Unknown Command: ${1}" - exit 1 ;; -esac - -# Exit with success if we made it to the end -exit $? diff --git a/usr.sbin/timed/Makefile b/usr.sbin/timed/Makefile deleted file mode 100644 index a89ab16ba16..00000000000 --- a/usr.sbin/timed/Makefile +++ /dev/null @@ -1,5 +0,0 @@ -# @(#)Makefile 8.1 (Berkeley) 6/6/93 - -SUBDIR= timed timedc - -.include diff --git a/usr.sbin/timed/timed/CHANGES b/usr.sbin/timed/timed/CHANGES deleted file mode 100644 index 5865f307c92..00000000000 --- a/usr.sbin/timed/timed/CHANGES +++ /dev/null @@ -1,144 +0,0 @@ -# @(#)CHANGES 5.1 (Berkeley) 5/11/93 - -This new version is almost identical to the timed and timedc code -that has been shipped for years by a workstation vendor. - -Among the many changes: - -improve `timedc msite` to accept a list of hostnames. - -change slave-masters to answer the packets generated by `timedc msite` - with the name of the real master, not their own. This makes it - possible to "chase the chain" of slave servers to the ultimate - master. - -much improve the log caused by `timedc trace on`: - -made `timed -t` work. - -suppression of repeated entries, which both slowed down the daemon - (sometimes catastrophically) and tended to make disks fill up - even more quickly. - -better time stamps on log entries - -more messages - -dump information about slaves, master, and so on each time - a message asking the log be turned on is received, and - when the log is turned off. - -fewer CPU cycles - -use a hash table to keep track of slaves, instead of the stupid linear - list. This becomes handy with hundreds of slaves, instead of - the original design limit of "a room with a few VAX's." - -separate the main protocol timer from that used to look for other networks - to master. - -time stamp packets received by the daemon, so that time corrections - are not made (even more) inaccurate by waiting in the internal, - timed queue while the daemon is processing other messages. - -made -n and -i work with subnets not named in /etc/networks - -compute the median of the measured clocks, instead of the average - of "good" times. - -vastly improve the accuracy of the clock difference measure by - `timedc clockdiff`. - -use adjtime() when possible, and directly set the clock only when - necessary. - -when the requested adjustment is small, perform only part of it, to - damp oscillations and improve the long term accuracy of the - adjustments. - -fix uncounted core-dumps on machines that do not allow dereferencing 0 - in both the daemon and timedc. - -fix "master loop detection". - -fix several cases in which multi-homed masters could get into shouting - matches, consuming all available network bandwidth and CPU cycles - (which ever runs out first), and convincing all bystanders to stop - advancing their own clocks. - -refuse to behave badly when other machines do. Instead of arguing forever, - go off and sulk when other machines refuse to play by the rules. - -increase the maximum number of clients. - -add "-F host,host2,..." to "freerun" or "trust" only some hosts. This - is handy both when only some machines should be trusted to let - root use the `date` command to change time in the network. - - It is also handy when one machine has some other way of adjusting - its clock, whether NTP or a direct radio or atomic connection. - "-F localhost" causes `timed` to "trust" only itself. - - It is also handy to build a hierarchy of timed masters crossing - networks. The TSP protocol has no provision of "goodness of clock", - no natural way to completely heal network paritions. Judicious - use of -F or -G can cause each gateway to trust only itself and - machines closer to a central machine with a radio or atomic clock. - -add #ifdef code that supports NIS "netgroups" of trusted hosts, which - can be easier to administer than -F. - -add #ifdef code to compute an aged total adjustment. This can be used - in systems that can make long term changes in their system clock - frequency, e.g. "timetrim" in the Silicon Graphics kernel. - - -Problems observed by others that are unresolved include: - -Practically any users can send to the master TSP messages and this - way corrupt the reliability of the system. Authentication - of messages should be provided. Unfortunately, that would - require changing the protocol with all of the implied - compatibility problems. Fortunately, the new -F and -G args - can be used to cause the daemon to ignore time changes from - untrusted machines. - -MAN. The limit of 1013 on the number of slaves hosts should be doc'ed. - - It should be dynamically allocated with no limit. On a - large network, one host could possibly master over many - more than 30 hosts. Given the timers in the code and - effectively in the protocol, and the time required by each - master to talk to each slave, it is not practical to have - more than 200-300 slaves. The master cannot keep up because - the slave-chatting is single-threaded. when the master - gets behind, slaves start demanding elections. To - significantly increase the number of slaves would require - multi-treading things, and given that a network with more - than 300 directly addressable machines has worse problems - than keep the time of day right, not worth worrying about. - -UGLY,CODE. timedc/cmds.c has a lots of repeated code in it. - -**** The first thing is that each command is set up as if it - were an individual program taking argc and argv. A more - conventional calling style should be used. I don't think - any of the routines take more than a couple arguments. - -UGLY. fxn definition syntax does't follow convention: - has type on same line. - -**** It needs to be fixed at least enough that tags - will work on it. An entire cleanup might be nice later, but - is noncritical. - -LOBBY(mildly),CODE: Would be very convenient if date(1) took a - +- argument to set the time relatively. With - the advent of timed it is now reasonable to synchronize - with WWV, which is nearly impossible to do "by hand" - with just an absolute date, and scripts are too slow. - format could be +-nn...nn.ss, where the '.' is required - to remove ambiguity. - -**** If you want to do it go ahead. It sounds useful. As far as - syntax goes, the normal format for the date should work just - fine for this. If the date is preceded by a plus or minus, - the change is relative, otherwise it is absolute. - - -Vernon Schryver. -vjs@sgi.com diff --git a/usr.sbin/timed/timed/Makefile b/usr.sbin/timed/timed/Makefile deleted file mode 100644 index 36eb16d4aff..00000000000 --- a/usr.sbin/timed/timed/Makefile +++ /dev/null @@ -1,15 +0,0 @@ -# @(#)Makefile 8.1 (Berkeley) 6/6/93 -# -# optional flags are: MEASURE TESTING DEBUG - -PROG= timed -MAN= timed.8 -SRCS= acksend.c candidate.c correct.c master.c networkdelta.c readmsg.c \ - slave.c timed.c byteorder.c measure.c cksum.c - -LIBADD= util - -WARNS?= 1 - -.include "../../Makefile.inc" -.include diff --git a/usr.sbin/timed/timed/Makefile.depend b/usr.sbin/timed/timed/Makefile.depend deleted file mode 100644 index d27183a3f0c..00000000000 --- a/usr.sbin/timed/timed/Makefile.depend +++ /dev/null @@ -1,20 +0,0 @@ -# Autogenerated - do NOT edit! - -DIRDEPS = \ - gnu/lib/csu \ - include \ - include/arpa \ - include/protocols \ - include/xlocale \ - lib/${CSU_DIR} \ - lib/libc \ - lib/libcompiler_rt \ - lib/libutil \ - lib/msun \ - - -.include - -.if ${DEP_RELDIR} == ${_DEP_RELDIR} -# local dependencies - needed for -jN in clean tree -.endif diff --git a/usr.sbin/timed/timed/acksend.c b/usr.sbin/timed/timed/acksend.c deleted file mode 100644 index d2efa1a478c..00000000000 --- a/usr.sbin/timed/timed/acksend.c +++ /dev/null @@ -1,125 +0,0 @@ -/*- - * SPDX-License-Identifier: BSD-3-Clause - * - * Copyright (c) 1985, 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. 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 -#if 0 -static char sccsid[] = "@(#)acksend.c 8.1 (Berkeley) 6/6/93"; -#endif -#endif /* not lint */ - -#include "globals.h" - -struct tsp *answer; - -extern u_short sequence; - -void -xmit(int type, u_int seq, struct sockaddr_in *addr) -{ - static struct tsp msg; - - msg.tsp_type = type; - msg.tsp_seq = seq; - msg.tsp_vers = TSPVERSION; - (void)strcpy(msg.tsp_name, hostname); - bytenetorder(&msg); - if (sendto(sock, (char *)&msg, sizeof(struct tsp), 0, - (struct sockaddr*)addr, sizeof(struct sockaddr)) < 0) { - trace_sendto_err(addr->sin_addr); - } -} - - -/* - * Acksend implements reliable datagram transmission by using sequence - * numbers and retransmission when necessary. - * If `name' is ANYADDR, this routine implements reliable broadcast. - * - * Because this function calls readmsg(), none of its args may be in - * a message provided by readmsg(). - * message this message - * addr to here - * ack look for this ack - * net receive from this network - * bad 1=losing patience - */ -struct tsp * -acksend(struct tsp *message, struct sockaddr_in *addr, char *name, - int ack, struct netinfo *net, int bad) -{ - struct timeval twait; - int count; - long msec; - - message->tsp_vers = TSPVERSION; - message->tsp_seq = sequence; - if (trace) { - fprintf(fd, "acksend: to %s: ", - (name == ANYADDR ? "broadcast" : name)); - print(message, addr); - } - bytenetorder(message); - - msec = 200; - count = bad ? 1 : 5; /* 5 packets in 6.4 seconds */ - answer = NULL; - do { - if (!answer) { - /* do not go crazy transmitting just because the - * other guy cannot keep our sequence numbers - * straight. - */ - if (sendto(sock, (char *)message, sizeof(struct tsp), - 0, (struct sockaddr*)addr, - sizeof(struct sockaddr)) < 0) { - trace_sendto_err(addr->sin_addr); - break; - } - } - - mstotvround(&twait, msec); - answer = readmsg(ack, name, &twait, net); - if (answer != NULL) { - if (answer->tsp_seq != sequence) { - if (trace) - fprintf(fd,"acksend: seq # %u!=%u\n", - answer->tsp_seq, sequence); - continue; - } - break; - } - - msec *= 2; - } while (--count > 0); - sequence++; - - return(answer); -} diff --git a/usr.sbin/timed/timed/byteorder.c b/usr.sbin/timed/timed/byteorder.c deleted file mode 100644 index c31d9bfee01..00000000000 --- a/usr.sbin/timed/timed/byteorder.c +++ /dev/null @@ -1,80 +0,0 @@ -/*- - * SPDX-License-Identifier: BSD-3-Clause - * - * Copyright (c) 1985, 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. 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 -#if 0 -static char sccsid[] = "@(#)byteorder.c 8.1 (Berkeley) 6/6/93"; -#endif -#endif /* not lint */ - -#include "globals.h" - -/* - * Two routines to do the necessary byte swapping for timed protocol - * messages. Protocol is defined in /usr/include/protocols/timed.h - */ -void -bytenetorder(struct tsp *ptr) -{ - ptr->tsp_seq = htons((u_short)ptr->tsp_seq); - switch (ptr->tsp_type) { - - case TSP_SETTIME: - case TSP_ADJTIME: - case TSP_SETDATE: - case TSP_SETDATEREQ: - ptr->tsp_time.tv_sec = htonl((u_long)ptr->tsp_time.tv_sec); - ptr->tsp_time.tv_usec = htonl((u_long)ptr->tsp_time.tv_usec); - break; - - default: - break; /* nothing more needed */ - } -} - -void -bytehostorder(struct tsp *ptr) -{ - ptr->tsp_seq = ntohs((u_short)ptr->tsp_seq); - switch (ptr->tsp_type) { - - case TSP_SETTIME: - case TSP_ADJTIME: - case TSP_SETDATE: - case TSP_SETDATEREQ: - ptr->tsp_time.tv_sec = ntohl((u_long)ptr->tsp_time.tv_sec); - ptr->tsp_time.tv_usec = ntohl((u_long)ptr->tsp_time.tv_usec); - break; - - default: - break; /* nothing more needed */ - } -} diff --git a/usr.sbin/timed/timed/candidate.c b/usr.sbin/timed/timed/candidate.c deleted file mode 100644 index 49a55bc2b92..00000000000 --- a/usr.sbin/timed/timed/candidate.c +++ /dev/null @@ -1,162 +0,0 @@ -/*- - * SPDX-License-Identifier: BSD-3-Clause - * - * Copyright (c) 1985, 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. 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 -#if 0 -static char sccsid[] = "@(#)candidate.c 8.1 (Berkeley) 6/6/93"; -#endif -#endif /* not lint */ - -#include "globals.h" - -/* - * `election' candidates a host as master: it is called by a slave - * which runs with the -M option set when its election timeout expires. - * Note the conservative approach: if a new timed comes up, or another - * candidate sends an election request, the candidature is withdrawn. - */ -int -election(struct netinfo *net) -{ - struct tsp *resp, msg; - struct timeval then, wait; - struct tsp *answer; - struct hosttbl *htp; - char loop_lim = 0; - -/* This code can get totally confused if it gets slightly behind. For - * example, if readmsg() has some QUIT messages waiting from the last - * round, we would send an ELECTION message, get the stale QUIT, - * and give up. This results in network storms when several machines - * do it at once. - */ - wait.tv_sec = 0; - wait.tv_usec = 0; - while (0 != readmsg(TSP_REFUSE, ANYADDR, &wait, net)) { - if (trace) - fprintf(fd, "election: discarded stale REFUSE\n"); - } - while (0 != readmsg(TSP_QUIT, ANYADDR, &wait, net)) { - if (trace) - fprintf(fd, "election: discarded stale QUIT\n"); - } - -again: - syslog(LOG_INFO, "This machine is a candidate time master"); - if (trace) - fprintf(fd, "This machine is a candidate time master\n"); - msg.tsp_type = TSP_ELECTION; - msg.tsp_vers = TSPVERSION; - (void)strcpy(msg.tsp_name, hostname); - bytenetorder(&msg); - if (sendto(sock, (char *)&msg, sizeof(struct tsp), 0, - (struct sockaddr*)&net->dest_addr, - sizeof(struct sockaddr)) < 0) { - trace_sendto_err(net->dest_addr.sin_addr); - return(SLAVE); - } - - (void)gettimeofday(&then, 0); - then.tv_sec += 3; - for (;;) { - (void)gettimeofday(&wait, 0); - timevalsub(&wait,&then,&wait); - resp = readmsg(TSP_ANY, ANYADDR, &wait, net); - if (!resp) - return(MASTER); - - switch (resp->tsp_type) { - - case TSP_ACCEPT: - (void)addmach(resp->tsp_name, &from,fromnet); - break; - - case TSP_MASTERUP: - case TSP_MASTERREQ: - /* - * If another timedaemon is coming up at the same - * time, give up, and let it be the master. - */ - if (++loop_lim < 5 - && !good_host_name(resp->tsp_name)) { - (void)addmach(resp->tsp_name, &from,fromnet); - suppress(&from, resp->tsp_name, net); - goto again; - } - rmnetmachs(net); - return(SLAVE); - - case TSP_QUIT: - case TSP_REFUSE: - /* - * Collision: change value of election timer - * using exponential backoff. - * - * Fooey. - * An exponential backoff on a delay starting at - * 6 to 15 minutes for a process that takes - * milliseconds is silly. It is particularly - * strange that the original code would increase - * the backoff without bound. - */ - rmnetmachs(net); - return(SLAVE); - - case TSP_ELECTION: - /* no master for another round */ - htp = addmach(resp->tsp_name,&from,fromnet); - msg.tsp_type = TSP_REFUSE; - (void)strcpy(msg.tsp_name, hostname); - answer = acksend(&msg, &htp->addr, htp->name, - TSP_ACK, 0, htp->noanswer); - if (!answer) { - syslog(LOG_ERR, "error in election from %s", - htp->name); - } - break; - - case TSP_SLAVEUP: - (void)addmach(resp->tsp_name, &from,fromnet); - break; - - case TSP_SETDATE: - case TSP_SETDATEREQ: - break; - - default: - if (trace) { - fprintf(fd, "candidate: "); - print(resp, &from); - } - break; - } - } -} diff --git a/usr.sbin/timed/timed/cksum.c b/usr.sbin/timed/timed/cksum.c deleted file mode 100644 index 47038a99031..00000000000 --- a/usr.sbin/timed/timed/cksum.c +++ /dev/null @@ -1,81 +0,0 @@ -/*- - * SPDX-License-Identifier: BSD-3-Clause - * - * Copyright (c) 1985, 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. 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 -#if 0 -static char sccsid[] = "@(#)cksum.c 8.1 (Berkeley) 6/6/93"; -#endif -#endif /* not lint */ - -#include - -/* - * I N _ C K S U M - * - * Checksum routine for Internet Protocol family headers (C Version) - * - * There is no profit in a specialized version of the checksum - * function for any machine where int's are 32 bits and shorts are 16. - * - * All timed packets are smaller than 32K shorts, so there is no need to - * worry about carries except at the end. - */ -int -in_cksum(u_short *addr, int len) -{ - register int nleft = len; - register u_short *w = addr; - register u_short answer; - register int sum = 0; - - /* - * Our algorithm is simple, using a 32 bit accumulator (sum), - * we add sequential 16 bit words to it, and at the end, fold - * back all the carry bits from the top 16 bits into the lower - * 16 bits. - */ - while( nleft > 1 ) { - sum += *w++; - nleft -= 2; - } - - /* mop up an odd byte, if necessary */ - if( nleft == 1 ) - sum += (*(u_char *)w) << 8; - - /* - * add back carry outs from top 16 bits to low 16 bits - */ - sum = (sum >> 16) + (sum & 0xffff); /* add hi 16 to low 16 */ - sum += (sum >> 16); /* add carry */ - answer = ~sum; /* truncate to 16 bits */ - return (answer); -} diff --git a/usr.sbin/timed/timed/correct.c b/usr.sbin/timed/timed/correct.c deleted file mode 100644 index d9cd123a42d..00000000000 --- a/usr.sbin/timed/timed/correct.c +++ /dev/null @@ -1,190 +0,0 @@ -/*- - * SPDX-License-Identifier: BSD-3-Clause - * - * Copyright (c) 1985, 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. 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 -#if 0 -static char sccsid[] = "@(#)correct.c 8.1 (Berkeley) 6/6/93"; -#endif -#endif /* not lint */ - -#include "globals.h" -#include -#include -#include - -static void adjclock(struct timeval *); - -/* - * sends to the slaves the corrections for their clocks after fixing our - * own - */ -void -correct(long avdelta) -{ - struct hosttbl *htp; - int corr; - struct timeval adjlocal, tmptv; - struct tsp to; - struct tsp *answer; - - mstotvround(&adjlocal, avdelta); - - for (htp = self.l_fwd; htp != &self; htp = htp->l_fwd) { - if (htp->delta != HOSTDOWN) { - corr = avdelta - htp->delta; -/* If the other machine is off in the weeds, set its time directly. - * If a slave gets the wrong day, the original code would simply - * fix the minutes. If you fix a network partition, you can get - * into such situations. - */ - if (htp->need_set - || corr >= MAXADJ*1000 - || corr <= -MAXADJ*1000) { - htp->need_set = 0; - (void)gettimeofday(&tmptv,0); - timevaladd(&tmptv, &adjlocal); - to.tsp_time.tv_sec = tmptv.tv_sec; - to.tsp_time.tv_usec = tmptv.tv_usec; - to.tsp_type = TSP_SETTIME; - } else { - tmptv.tv_sec = to.tsp_time.tv_sec; - tmptv.tv_usec = to.tsp_time.tv_usec; - mstotvround(&tmptv, corr); - to.tsp_time.tv_sec = tmptv.tv_sec; - to.tsp_time.tv_usec = tmptv.tv_usec; - to.tsp_type = TSP_ADJTIME; - } - (void)strcpy(to.tsp_name, hostname); - answer = acksend(&to, &htp->addr, htp->name, - TSP_ACK, 0, 0); - if (!answer) { - htp->delta = HOSTDOWN; - syslog(LOG_WARNING, - "no reply to time correction from %s", - htp->name); - if (++htp->noanswer >= LOSTHOST) { - if (trace) { - fprintf(fd, - "purging %s for not answering\n", - htp->name); - (void)fflush(fd); - } - htp = remmach(htp); - } - } - } - } - - /* - * adjust our own clock now that we are not sending it out - */ - adjclock(&adjlocal); -} - - -static void -adjclock(struct timeval *corr) -{ - static int passes = 0; - static int smoother = 0; - long delta; /* adjustment in usec */ - long ndelta; - struct timeval now; - struct timeval adj; - - if (!timerisset(corr)) - return; - - adj = *corr; - if (adj.tv_sec < MAXADJ && adj.tv_sec > - MAXADJ) { - delta = adj.tv_sec*1000000 + adj.tv_usec; - /* If the correction is less than the minimum round - * trip time for an ICMP packet, and thus - * less than the likely error in the measurement, - * do not do the entire correction. Do half - * or a quarter of it. - */ - - if (delta > -MIN_ROUND*1000 - && delta < MIN_ROUND*1000) { - if (smoother <= 4) - smoother++; - ndelta = delta >> smoother; - if (trace) - fprintf(fd, - "trimming delta %ld usec to %ld\n", - delta, ndelta); - adj.tv_usec = ndelta; - adj.tv_sec = 0; - } else if (smoother > 0) { - smoother--; - } - if (0 > adjtime(corr, 0)) { - syslog(LOG_ERR, "adjtime: %m"); - } - if (passes > 1 - && (delta < -BIG_ADJ || delta > BIG_ADJ)) { - smoother = 0; - passes = 0; - syslog(LOG_WARNING, - "large time adjustment of %+.3f sec", - delta/1000000.0); - } - } else { - syslog(LOG_WARNING, - "clock correction %jd sec too large to adjust", - (intmax_t)adj.tv_sec); - (void) gettimeofday(&now, 0); - timevaladd(&now, corr); - if (settimeofday(&now, 0) < 0) - syslog(LOG_ERR, "settimeofday: %m"); - } -} - - -/* adjust the time in a message by the time it - * spent in the queue - */ -void -adj_msg_time(struct tsp *msg, struct timeval *now) -{ - msg->tsp_time.tv_sec += (now->tv_sec - from_when.tv_sec); - msg->tsp_time.tv_usec += (now->tv_usec - from_when.tv_usec); - - while (msg->tsp_time.tv_usec < 0) { - msg->tsp_time.tv_sec--; - msg->tsp_time.tv_usec += 1000000; - } - while (msg->tsp_time.tv_usec >= 1000000) { - msg->tsp_time.tv_sec++; - msg->tsp_time.tv_usec -= 1000000; - } -} diff --git a/usr.sbin/timed/timed/extern.h b/usr.sbin/timed/timed/extern.h deleted file mode 100644 index 149b310aa22..00000000000 --- a/usr.sbin/timed/timed/extern.h +++ /dev/null @@ -1,88 +0,0 @@ - -/*- - * SPDX-License-Identifier: BSD-3-Clause - * - * 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. 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. - * - * @(#)extern.h 8.1 (Berkeley) 6/6/93 - */ - -struct hosttbl; -struct netinfo; -struct sockaddr_in; -struct timeval; -struct tsp; - -struct hosttbl *addmach(char *, struct sockaddr_in *, struct netinfo *); -struct hosttbl *findhost(char *); -struct hosttbl *remmach(struct hosttbl *); - -struct tsp *readmsg(int, - char *, struct timeval *, struct netinfo *); -struct tsp *acksend(struct tsp *, - struct sockaddr_in *, char *, int, struct netinfo *, int); - -void addnetname(char *); -void adj_msg_time(struct tsp *, struct timeval *); -void bytehostorder(struct tsp *); -void bytenetorder(struct tsp *); -void byteorder(struct tsp *); -long casual(long, long); -int cksum(u_short *, int); -void correct(long); -char *date(void); -void doquit(struct tsp *); -int election(struct netinfo *); -void get_goodgroup(int); -int good_host_name(char *); -void ignoreack(void); -int in_cksum(u_short *, int); -void lookformaster(struct netinfo *); -void makeslave(struct netinfo *); -int master(void); -void masterack(void); -void masterup(struct netinfo *); -int measure(u_long, u_long, char *, struct sockaddr_in *, int); -void msterup(struct netinfo *); -void mstotvround(struct timeval *, long); -long networkdelta(void); -void newslave(struct tsp *); -void print(struct tsp *, struct sockaddr_in *); -void prthp(clock_t); -void rmnetmachs(struct netinfo *); -void setstatus(void); -void slave(void) __dead2; -void slaveack(void); -void spreadtime(void); -void suppress(struct sockaddr_in *, char *, struct netinfo *); -void synch(long); -void timevaladd(struct timeval *, struct timeval *); -void timevalsub(struct timeval *, struct timeval *, struct timeval *); -void traceoff(char *); -void traceon(void); -void xmit(int, u_int, struct sockaddr_in *); diff --git a/usr.sbin/timed/timed/globals.h b/usr.sbin/timed/timed/globals.h deleted file mode 100644 index 21d24130823..00000000000 --- a/usr.sbin/timed/timed/globals.h +++ /dev/null @@ -1,170 +0,0 @@ -/*- - * SPDX-License-Identifier: BSD-3-Clause - * - * Copyright (c) 1985, 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. 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. - * - * @(#)globals.h 8.1 (Berkeley) 6/6/93 - */ - -#include -#include -#include - -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#define SECHR (60*60) -#define SECDAY (24*SECHR) - -/* Best expected round trip for a measurement. - * This is essentially the number of milliseconds per CPU tick (CLK_TCK?). - * All delays shorter than this are usually reported as 0. - */ -#define MIN_ROUND ((1000-1)/CLK_TCK) - - -#define SAMPLEINTVL 240 /* synch() freq for master in sec */ -#define MAXADJ 20 /* max adjtime() correction in sec */ - -#define MAX_TRIM 3000000 /* max drift in nsec/sec, 0.3% */ -#define BIG_ADJ (MAX_TRIM/1000*SAMPLEINTVL*2) /* max good adj */ - -#define MINTOUT 360 /* election delays, 6-15 minutes */ -#define MAXTOUT 900 - -#define BAD_STATUS (-1) -#define GOOD 1 -#define UNREACHABLE 2 -#define NONSTDTIME 3 -#define HOSTDOWN 0x7fffffff - -#define OFF 0 -#define ON 1 - -#define MAX_HOPCNT 10 /* max value for tsp_hpcnt */ - -#define LOSTHOST 3 /* forget after this many failures */ - -#define VALID_RANGE (MAXADJ*1000) /* good times in milliseconds */ -#define GOOD_RANGE (MIN_ROUND*2) -#define VGOOD_RANGE (MIN_ROUND-1) - - -/* - * Global and per-network states. - */ -#define NOMASTER 0 /* no good master */ -#define SLAVE 1 -#define MASTER 2 -#define IGNORE 4 -#define ALL (SLAVE|MASTER|IGNORE) -#define SUBMASTER (SLAVE|MASTER) - -#define NHOSTS 1013 /* max of hosts controlled by timed - * This must be a prime number. - */ -struct hosttbl { - struct hosttbl *h_bak; /* hash chain */ - struct hosttbl *h_fwd; - struct hosttbl *l_bak; /* "sequential" list */ - struct hosttbl *l_fwd; - struct netinfo *ntp; - struct sockaddr_in addr; - char name[MAXHOSTNAMELEN]; - u_char head; /* 1=head of hash chain */ - u_char good; /* 0=trusted host, for averaging */ - u_char noanswer; /* count of failures to answer */ - u_char need_set; /* need a SETTIME */ - u_short seq; - long delta; -}; - -/* closed hash table with internal chaining */ -extern struct hosttbl hosttbl[NHOSTS+1]; -#define self hosttbl[0] -#define hostname (self.name) - - -struct netinfo { - struct netinfo *next; - struct in_addr net; - u_int32_t mask; - struct in_addr my_addr; - struct sockaddr_in dest_addr; /* broadcast addr or point-point */ - long status; - struct timeval slvwait; /* delay before sending our time */ - int quit_count; /* recent QUITs */ -}; - -#include "extern.h" - -#define tvtomsround(tv) ((tv).tv_sec*1000 + ((tv).tv_usec + 500)/1000) - -extern struct netinfo *nettab; -extern int status; -extern int trace; -extern int sock; -extern struct sockaddr_in from; -extern struct timeval from_when; /* when the last msg arrived */ -extern u_short sequence; /* TSP message sequence number */ -extern struct netinfo *fromnet, *slavenet; -extern FILE *fd; -extern long delay1, delay2; -extern int nslavenets; /* nets were I could be a slave */ -extern int nmasternets; /* nets were I could be a master */ -extern int nignorednets; /* ignored nets */ -extern int nnets; /* nets I am connected to */ - - -#define trace_msg(msg) {if (trace) fprintf(fd, msg);} - -#define trace_sendto_err(addr) { \ - int st_errno = errno; \ - syslog(LOG_ERR, "%s %d: sendto %s: %m", \ - __FILE__, __LINE__, inet_ntoa(addr)); \ - if (trace) \ - fprintf(fd, "%s %d: sendto %s: %d", __FILE__, __LINE__, \ - inet_ntoa(addr), st_errno); \ -} - - -# define max(a,b) (ab ? b : a) -# define abs(x) (x>=0 ? x : -(x)) diff --git a/usr.sbin/timed/timed/master.c b/usr.sbin/timed/timed/master.c deleted file mode 100644 index 4df5dc55739..00000000000 --- a/usr.sbin/timed/timed/master.c +++ /dev/null @@ -1,841 +0,0 @@ -/*- - * SPDX-License-Identifier: BSD-3-Clause - * - * Copyright (c) 1985, 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. 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 -#if 0 -static char sccsid[] = "@(#)master.c 8.1 (Berkeley) 6/6/93"; -#endif -#endif /* not lint */ - -#include "globals.h" -#include -#include -#include -#include -#include -#include "pathnames.h" - -extern int measure_delta; -extern jmp_buf jmpenv; -extern int Mflag; -extern int justquit; - -static int dictate; -static int slvcount; /* slaves listening to our clock */ - -static void mchgdate(struct tsp *); - -/* - * The main function of `master' is to periodically compute the differences - * (deltas) between its clock and the clocks of the slaves, to compute the - * network average delta, and to send to the slaves the differences between - * their individual deltas and the network delta. - * While waiting, it receives messages from the slaves (i.e. requests for - * master's name, remote requests to set the network time, ...), and - * takes the appropriate action. - */ -int -master(void) -{ - struct hosttbl *htp; - long pollingtime; -#define POLLRATE 4 - int polls; - struct timeval wait, ntime; - time_t tsp_time_sec; - struct tsp *msg, *answer, to; - char newdate[32]; - struct sockaddr_in taddr; - char tname[MAXHOSTNAMELEN]; - struct netinfo *ntp; - int i; - - syslog(LOG_NOTICE, "This machine is master"); - if (trace) - fprintf(fd, "This machine is master\n"); - for (ntp = nettab; ntp != NULL; ntp = ntp->next) { - if (ntp->status == MASTER) - masterup(ntp); - } - (void)gettimeofday(&ntime, NULL); - pollingtime = ntime.tv_sec+3; - if (justquit) - polls = 0; - else - polls = POLLRATE-1; - -/* Process all outstanding messages before spending the long time necessary - * to update all timers. - */ -loop: - (void)gettimeofday(&ntime, NULL); - wait.tv_sec = pollingtime - ntime.tv_sec; - if (wait.tv_sec < 0) - wait.tv_sec = 0; - wait.tv_usec = 0; - msg = readmsg(TSP_ANY, ANYADDR, &wait, 0); - if (!msg) { - (void)gettimeofday(&ntime, NULL); - if (ntime.tv_sec >= pollingtime) { - pollingtime = ntime.tv_sec + SAMPLEINTVL; - get_goodgroup(0); - -/* If a bogus master told us to quit, we can have decided to ignore a - * network. Therefore, periodically try to take over everything. - */ - polls = (polls + 1) % POLLRATE; - if (0 == polls && nignorednets > 0) { - trace_msg("Looking for nets to re-master\n"); - for (ntp = nettab; ntp; ntp = ntp->next) { - if (ntp->status == IGNORE - || ntp->status == NOMASTER) { - lookformaster(ntp); - if (ntp->status == MASTER) { - masterup(ntp); - polls = POLLRATE-1; - } - } - if (ntp->status == MASTER - && --ntp->quit_count < 0) - ntp->quit_count = 0; - } - if (polls != 0) - setstatus(); - } - - synch(0L); - - for (ntp = nettab; ntp != NULL; ntp = ntp->next) { - to.tsp_type = TSP_LOOP; - to.tsp_vers = TSPVERSION; - to.tsp_seq = sequence++; - to.tsp_hopcnt = MAX_HOPCNT; - (void)strcpy(to.tsp_name, hostname); - bytenetorder(&to); - if (sendto(sock, (char *)&to, - sizeof(struct tsp), 0, - (struct sockaddr*)&ntp->dest_addr, - sizeof(ntp->dest_addr)) < 0) { - trace_sendto_err(ntp->dest_addr.sin_addr); - } - } - } - - - } else { - switch (msg->tsp_type) { - - case TSP_MASTERREQ: - break; - - case TSP_SLAVEUP: - newslave(msg); - break; - - case TSP_SETDATE: - /* - * XXX check to see it is from ourself - */ - tsp_time_sec = msg->tsp_time.tv_sec; - (void)strlcpy(newdate, ctime(&tsp_time_sec), - sizeof(newdate)); - if (!good_host_name(msg->tsp_name)) { - syslog(LOG_NOTICE, - "attempted date change by %s to %s", - msg->tsp_name, newdate); - spreadtime(); - break; - } - - mchgdate(msg); - (void)gettimeofday(&ntime, NULL); - pollingtime = ntime.tv_sec + SAMPLEINTVL; - break; - - case TSP_SETDATEREQ: - if (!fromnet || fromnet->status != MASTER) - break; - tsp_time_sec = msg->tsp_time.tv_sec; - (void)strlcpy(newdate, ctime(&tsp_time_sec), - sizeof(newdate)); - htp = findhost(msg->tsp_name); - if (htp == NULL) { - syslog(LOG_ERR, - "attempted SET DATEREQ by uncontrolled %s to %s", - msg->tsp_name, newdate); - break; - } - if (htp->seq == msg->tsp_seq) - break; - htp->seq = msg->tsp_seq; - if (!htp->good) { - syslog(LOG_NOTICE, - "attempted SET DATEREQ by untrusted %s to %s", - msg->tsp_name, newdate); - spreadtime(); - break; - } - - mchgdate(msg); - (void)gettimeofday(&ntime, NULL); - pollingtime = ntime.tv_sec + SAMPLEINTVL; - break; - - case TSP_MSITE: - xmit(TSP_ACK, msg->tsp_seq, &from); - break; - - case TSP_MSITEREQ: - break; - - case TSP_TRACEON: - traceon(); - break; - - case TSP_TRACEOFF: - traceoff("Tracing ended at %s\n"); - break; - - case TSP_ELECTION: - if (!fromnet) - break; - if (fromnet->status == MASTER) { - pollingtime = 0; - (void)addmach(msg->tsp_name, &from,fromnet); - } - taddr = from; - (void)strcpy(tname, msg->tsp_name); - to.tsp_type = TSP_QUIT; - (void)strcpy(to.tsp_name, hostname); - answer = acksend(&to, &taddr, tname, - TSP_ACK, 0, 1); - if (answer == NULL) { - syslog(LOG_ERR, "election error by %s", - tname); - } - break; - - case TSP_CONFLICT: - /* - * After a network partition, there can be - * more than one master: the first slave to - * come up will notify here the situation. - */ - if (!fromnet || fromnet->status != MASTER) - break; - (void)strcpy(to.tsp_name, hostname); - - /* The other master often gets into the same state, - * with boring results if we stay at it forever. - */ - ntp = fromnet; /* (acksend() can leave fromnet=0 */ - for (i = 0; i < 3; i++) { - to.tsp_type = TSP_RESOLVE; - (void)strcpy(to.tsp_name, hostname); - answer = acksend(&to, &ntp->dest_addr, - ANYADDR, TSP_MASTERACK, - ntp, 0); - if (!answer) - break; - htp = addmach(answer->tsp_name,&from,ntp); - to.tsp_type = TSP_QUIT; - msg = acksend(&to, &htp->addr, htp->name, - TSP_ACK, 0, htp->noanswer); - if (msg == NULL) { - syslog(LOG_ERR, - "no response from %s to CONFLICT-QUIT", - htp->name); - } - } - masterup(ntp); - pollingtime = 0; - break; - - case TSP_RESOLVE: - if (!fromnet || fromnet->status != MASTER) - break; - /* - * do not want to call synch() while waiting - * to be killed! - */ - (void)gettimeofday(&ntime, NULL); - pollingtime = ntime.tv_sec + SAMPLEINTVL; - break; - - case TSP_QUIT: - doquit(msg); /* become a slave */ - break; - - case TSP_LOOP: - if (!fromnet || fromnet->status != MASTER - || !strcmp(msg->tsp_name, hostname)) - break; - /* - * We should not have received this from a net - * we are master on. There must be two masters. - */ - htp = addmach(msg->tsp_name, &from,fromnet); - to.tsp_type = TSP_QUIT; - (void)strcpy(to.tsp_name, hostname); - answer = acksend(&to, &htp->addr, htp->name, - TSP_ACK, 0, 1); - if (!answer) { - syslog(LOG_WARNING, - "loop breakage: no reply from %s=%s to QUIT", - htp->name, inet_ntoa(htp->addr.sin_addr)); - (void)remmach(htp); - } - - case TSP_TEST: - if (trace) { - fprintf(fd, - "\tnets = %d, masters = %d, slaves = %d, ignored = %d\n", - nnets, nmasternets, nslavenets, nignorednets); - setstatus(); - } - pollingtime = 0; - polls = POLLRATE-1; - break; - - default: - if (trace) { - fprintf(fd, "garbage message: "); - print(msg, &from); - } - break; - } - } - goto loop; -} - - -/* - * change the system date on the master - */ -static void -mchgdate(struct tsp *msg) -{ - char tname[MAXHOSTNAMELEN]; - char olddate[32]; - struct timeval otime, ntime, tmptv; - struct utmpx utx; - - (void)strcpy(tname, msg->tsp_name); - - xmit(TSP_DATEACK, msg->tsp_seq, &from); - - (void)strlcpy(olddate, date(), sizeof(olddate)); - - /* adjust time for residence on the queue */ - (void)gettimeofday(&otime, NULL); - adj_msg_time(msg,&otime); - - tmptv.tv_sec = msg->tsp_time.tv_sec; - tmptv.tv_usec = msg->tsp_time.tv_usec; - timevalsub(&ntime, &tmptv, &otime); - if (ntime.tv_sec < MAXADJ && ntime.tv_sec > -MAXADJ) { - /* - * do not change the clock if we can adjust it - */ - dictate = 3; - synch(tvtomsround(ntime)); - } else { - utx.ut_type = OLD_TIME; - (void)gettimeofday(&utx.ut_tv, NULL); - pututxline(&utx); - (void)settimeofday(&tmptv, 0); - utx.ut_type = NEW_TIME; - (void)gettimeofday(&utx.ut_tv, NULL); - pututxline(&utx); - spreadtime(); - } - - syslog(LOG_NOTICE, "date changed by %s from %s", - tname, olddate); -} - - -/* - * synchronize all of the slaves - */ -void -synch(long mydelta) -{ - struct hosttbl *htp; - int measure_status; - struct timeval check, stop, wait; - - if (slvcount > 0) { - if (trace) - fprintf(fd, "measurements starting at %s\n", date()); - (void)gettimeofday(&check, NULL); - for (htp = self.l_fwd; htp != &self; htp = htp->l_fwd) { - if (htp->noanswer != 0) { - measure_status = measure(500, 100, - htp->name, - &htp->addr,0); - } else { - measure_status = measure(3000, 100, - htp->name, - &htp->addr,0); - } - if (measure_status != GOOD) { - /* The slave did not respond. We have - * just wasted lots of time on it. - */ - htp->delta = HOSTDOWN; - if (++htp->noanswer >= LOSTHOST) { - if (trace) { - fprintf(fd, - "purging %s for not answering ICMP\n", - htp->name); - (void)fflush(fd); - } - htp = remmach(htp); - } - } else { - htp->delta = measure_delta; - } - (void)gettimeofday(&stop, NULL); - timevalsub(&stop, &stop, &check); - if (stop.tv_sec >= 1) { - if (trace) - (void)fflush(fd); - /* - * ack messages periodically - */ - wait.tv_sec = 0; - wait.tv_usec = 0; - if (0 != readmsg(TSP_TRACEON,ANYADDR, - &wait,0)) - traceon(); - (void)gettimeofday(&check, NULL); - } - } - if (trace) - fprintf(fd, "measurements finished at %s\n", date()); - } - if (!(status & SLAVE)) { - if (!dictate) { - mydelta = networkdelta(); - } else { - dictate--; - } - } - if (trace && (mydelta != 0 || (status & SLAVE))) - fprintf(fd,"local correction of %ld ms.\n", mydelta); - correct(mydelta); -} - -/* - * sends the time to each slave after the master - * has received the command to set the network time - */ -void -spreadtime(void) -{ - struct hosttbl *htp; - struct tsp to; - struct tsp *answer; - struct timeval tmptv; - -/* Do not listen to the consensus after forcing the time. This is because - * the consensus takes a while to reach the time we are dictating. - */ - dictate = 2; - for (htp = self.l_fwd; htp != &self; htp = htp->l_fwd) { - to.tsp_type = TSP_SETTIME; - (void)strcpy(to.tsp_name, hostname); - (void)gettimeofday(&tmptv, NULL); - to.tsp_time.tv_sec = tmptv.tv_sec; - to.tsp_time.tv_usec = tmptv.tv_usec; - answer = acksend(&to, &htp->addr, htp->name, - TSP_ACK, 0, htp->noanswer); - if (answer == NULL) { - /* We client does not respond, then we have - * just wasted lots of time on it. - */ - syslog(LOG_WARNING, - "no reply to SETTIME from %s", htp->name); - if (++htp->noanswer >= LOSTHOST) { - if (trace) { - fprintf(fd, - "purging %s for not answering", - htp->name); - (void)fflush(fd); - } - htp = remmach(htp); - } - } - } -} - -void -prthp(clock_t delta) -{ - static time_t next_time; - time_t this_time; - struct tms tm; - struct hosttbl *htp; - int length, l; - int i; - - if (!fd) /* quit if tracing already off */ - return; - - this_time = times(&tm); - if ((time_t)(this_time + delta) < next_time) - return; - next_time = this_time + CLK_TCK; - - fprintf(fd, "host table: %d entries at %s\n", slvcount, date()); - htp = self.l_fwd; - length = 1; - for (i = 1; i <= slvcount; i++, htp = htp->l_fwd) { - l = strlen(htp->name) + 1; - if (length+l >= 80) { - fprintf(fd, "\n"); - length = 0; - } - length += l; - fprintf(fd, " %s", htp->name); - } - fprintf(fd, "\n"); -} - - -static struct hosttbl *newhost_hash; -static struct hosttbl *lasthfree = &hosttbl[0]; - - -struct hosttbl * /* answer or 0 */ -findhost(char *name) -{ - int i, j; - struct hosttbl *htp; - char *p; - - j= 0; - for (p = name, i = 0; i < 8 && *p != '\0'; i++, p++) - j = (j << 2) ^ *p; - newhost_hash = &hosttbl[j % NHOSTS]; - - htp = newhost_hash; - if (htp->name[0] == '\0') - return(0); - do { - if (!strcmp(name, htp->name)) - return(htp); - htp = htp->h_fwd; - } while (htp != newhost_hash); - return(0); -} - -/* - * add a host to the list of controlled machines if not already there - */ -struct hosttbl * -addmach(char *name, struct sockaddr_in *addr, struct netinfo *ntp) -{ - struct hosttbl *ret, *p, *b, *f; - - ret = findhost(name); - if (ret == NULL) { - if (slvcount >= NHOSTS) { - if (trace) { - fprintf(fd, "no more slots in host table\n"); - prthp(CLK_TCK); - } - syslog(LOG_ERR, "no more slots in host table"); - Mflag = 0; - longjmp(jmpenv, 2); /* give up and be a slave */ - } - - /* if our home hash slot is occupied, find a free entry - * in the hash table - */ - if (newhost_hash->name[0] != '\0') { - do { - ret = lasthfree; - if (++lasthfree > &hosttbl[NHOSTS]) - lasthfree = &hosttbl[1]; - } while (ret->name[0] != '\0'); - - if (!newhost_hash->head) { - /* Move an interloper using our home. Use - * scratch pointers in case the new head is - * pointing to itself. - */ - f = newhost_hash->h_fwd; - b = newhost_hash->h_bak; - f->h_bak = ret; - b->h_fwd = ret; - f = newhost_hash->l_fwd; - b = newhost_hash->l_bak; - f->l_bak = ret; - b->l_fwd = ret; - bcopy(newhost_hash,ret,sizeof(*ret)); - ret = newhost_hash; - ret->head = 1; - ret->h_fwd = ret; - ret->h_bak = ret; - } else { - /* link to an existing chain in our home - */ - ret->head = 0; - p = newhost_hash->h_bak; - ret->h_fwd = newhost_hash; - ret->h_bak = p; - p->h_fwd = ret; - newhost_hash->h_bak = ret; - } - } else { - ret = newhost_hash; - ret->head = 1; - ret->h_fwd = ret; - ret->h_bak = ret; - } - ret->addr = *addr; - ret->ntp = ntp; - (void)strlcpy(ret->name, name, sizeof(ret->name)); - ret->good = good_host_name(name); - ret->l_fwd = &self; - ret->l_bak = self.l_bak; - self.l_bak->l_fwd = ret; - self.l_bak = ret; - slvcount++; - - ret->noanswer = 0; - ret->need_set = 1; - - } else { - ret->noanswer = (ret->noanswer != 0); - } - - /* need to clear sequence number anyhow */ - ret->seq = 0; - return(ret); -} - -/* - * remove the machine with the given index in the host table. - */ -struct hosttbl * -remmach(struct hosttbl *htp) -{ - struct hosttbl *lprv, *hnxt, *f, *b; - - if (trace) - fprintf(fd, "remove %s\n", htp->name); - - /* get out of the lists */ - htp->l_fwd->l_bak = lprv = htp->l_bak; - htp->l_bak->l_fwd = htp->l_fwd; - htp->h_fwd->h_bak = htp->h_bak; - htp->h_bak->h_fwd = hnxt = htp->h_fwd; - - /* If we are in the home slot, pull up the chain */ - if (htp->head && hnxt != htp) { - if (lprv == hnxt) - lprv = htp; - - /* Use scratch pointers in case the new head is pointing to - * itself. - */ - f = hnxt->h_fwd; - b = hnxt->h_bak; - f->h_bak = htp; - b->h_fwd = htp; - f = hnxt->l_fwd; - b = hnxt->l_bak; - f->l_bak = htp; - b->l_fwd = htp; - hnxt->head = 1; - bcopy(hnxt, htp, sizeof(*htp)); - lasthfree = hnxt; - } else { - lasthfree = htp; - } - - lasthfree->name[0] = '\0'; - lasthfree->h_fwd = NULL; - lasthfree->l_fwd = NULL; - slvcount--; - - return lprv; -} - - -/* - * Remove all the machines from the host table that exist on the given - * network. This is called when a master transitions to a slave on a - * given network. - */ -void -rmnetmachs(struct netinfo *ntp) -{ - struct hosttbl *htp; - - if (trace) - prthp(CLK_TCK); - for (htp = self.l_fwd; htp != &self; htp = htp->l_fwd) { - if (ntp == htp->ntp) - htp = remmach(htp); - } - if (trace) - prthp(CLK_TCK); -} - -void -masterup(struct netinfo *net) -{ - xmit(TSP_MASTERUP, 0, &net->dest_addr); - - /* - * Do not tell new slaves our time for a while. This ensures - * we do not tell them to start using our time, before we have - * found a good master. - */ - (void)gettimeofday(&net->slvwait, NULL); -} - -void -newslave(struct tsp *msg) -{ - struct hosttbl *htp; - struct tsp *answer, to; - struct timeval now, tmptv; - - if (!fromnet || fromnet->status != MASTER) - return; - - htp = addmach(msg->tsp_name, &from,fromnet); - htp->seq = msg->tsp_seq; - if (trace) - prthp(0); - - /* - * If we are stable, send our time to the slave. - * Do not go crazy if the date has been changed. - */ - (void)gettimeofday(&now, NULL); - if (now.tv_sec >= fromnet->slvwait.tv_sec+3 - || now.tv_sec < fromnet->slvwait.tv_sec) { - to.tsp_type = TSP_SETTIME; - (void)strcpy(to.tsp_name, hostname); - (void)gettimeofday(&tmptv, NULL); - to.tsp_time.tv_sec = tmptv.tv_sec; - to.tsp_time.tv_usec = tmptv.tv_usec; - answer = acksend(&to, &htp->addr, - htp->name, TSP_ACK, - 0, htp->noanswer); - if (answer) { - htp->need_set = 0; - } else { - syslog(LOG_WARNING, - "no reply to initial SETTIME from %s", - htp->name); - htp->noanswer = LOSTHOST; - } - } -} - - -/* - * react to a TSP_QUIT: - */ -void -doquit(struct tsp *msg) -{ - if (fromnet->status == MASTER) { - if (!good_host_name(msg->tsp_name)) { - if (fromnet->quit_count <= 0) { - syslog(LOG_NOTICE,"untrusted %s told us QUIT", - msg->tsp_name); - suppress(&from, msg->tsp_name, fromnet); - fromnet->quit_count = 1; - return; - } - syslog(LOG_NOTICE, "untrusted %s told us QUIT twice", - msg->tsp_name); - fromnet->quit_count = 2; - fromnet->status = NOMASTER; - } else { - fromnet->status = SLAVE; - } - rmnetmachs(fromnet); - longjmp(jmpenv, 2); /* give up and be a slave */ - - } else { - if (!good_host_name(msg->tsp_name)) { - syslog(LOG_NOTICE, "untrusted %s told us QUIT", - msg->tsp_name); - fromnet->quit_count = 2; - } - } -} - -void -traceon(void) -{ - if (!fd) { - fd = fopen(_PATH_TIMEDLOG, "w"); - if (!fd) { - trace = 0; - return; - } - fprintf(fd,"Tracing started at %s\n", date()); - } - trace = 1; - get_goodgroup(1); - setstatus(); - prthp(CLK_TCK); -} - - -void -traceoff(char *msg) -{ - get_goodgroup(1); - setstatus(); - prthp(CLK_TCK); - if (trace) { - fprintf(fd, msg, date()); - (void)fclose(fd); - fd = NULL; - } -#ifdef GPROF - moncontrol(0); - _mcleanup(); - moncontrol(1); -#endif - trace = OFF; -} diff --git a/usr.sbin/timed/timed/measure.c b/usr.sbin/timed/timed/measure.c deleted file mode 100644 index c49fe40d7e8..00000000000 --- a/usr.sbin/timed/timed/measure.c +++ /dev/null @@ -1,336 +0,0 @@ -/*- - * SPDX-License-Identifier: BSD-3-Clause - * - * Copyright (c) 1985, 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. 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 -#if 0 -static char sccsid[] = "@(#)measure.c 8.1 (Berkeley) 6/6/93"; -#endif -#endif /* not lint */ - -#include "globals.h" -#include -#include -#include - -#define MSEC_DAY (SECDAY*1000) - -#define PACKET_IN 1024 - -#define MSGS 5 /* timestamps to average */ -#define TRIALS 10 /* max # of timestamps sent */ - -extern int sock_raw; - -int measure_delta; - -static n_short seqno = 0; - -/* - * Measures the differences between machines' clocks using - * ICMP timestamp messages. - * maxmsec wait this many msec at most - * wmsec msec to wait for an answer - * print print complaints on stderr - */ -int /* status val defined in globals.h */ -measure(u_long maxmsec, u_long wmsec, char *hname, struct sockaddr_in *addr, int print) -{ - int length; - int measure_status; - int rcvcount, trials; - int cc, count; - fd_set ready; - long sendtime, recvtime, histime1, histime2; - long idelta, odelta, total; - long min_idelta, min_odelta; - struct timeval tdone, tcur, ttrans, twait, tout; - u_char packet[PACKET_IN], opacket[64]; - register struct icmp *icp = (struct icmp *) packet; - register struct icmp *oicp = (struct icmp *) opacket; - struct ip *ip = (struct ip *) packet; - - min_idelta = min_odelta = 0x7fffffff; - measure_status = HOSTDOWN; - measure_delta = HOSTDOWN; - trials = 0; - errno = 0; - - /* open raw socket used to measure time differences */ - if (sock_raw < 0) { - sock_raw = socket(AF_INET, SOCK_RAW, IPPROTO_ICMP); - if (sock_raw < 0) { - syslog(LOG_ERR, "opening raw socket: %m"); - goto quit; - } - } - - - /* - * empty the icmp input queue - */ - FD_ZERO(&ready); - for (;;) { - tout.tv_sec = tout.tv_usec = 0; - FD_SET(sock_raw, &ready); - if (select(sock_raw+1, &ready, 0,0, &tout)) { - length = sizeof(struct sockaddr_in); - cc = recvfrom(sock_raw, (char *)packet, PACKET_IN, 0, - 0,&length); - if (cc < 0) - goto quit; - continue; - } - break; - } - - /* - * Choose the smallest transmission time in each of the two - * directions. Use these two latter quantities to compute the delta - * between the two clocks. - */ - - oicp->icmp_type = ICMP_TSTAMP; - oicp->icmp_code = 0; - oicp->icmp_id = getpid(); - oicp->icmp_rtime = 0; - oicp->icmp_ttime = 0; - oicp->icmp_seq = seqno; - - FD_ZERO(&ready); - - (void)gettimeofday(&tdone, NULL); - mstotvround(&tout, maxmsec); - timevaladd(&tdone, &tout); /* when we give up */ - - mstotvround(&twait, wmsec); - - rcvcount = 0; - while (rcvcount < MSGS) { - (void)gettimeofday(&tcur, NULL); - - /* - * keep sending until we have sent the max - */ - if (trials < TRIALS) { - trials++; - oicp->icmp_otime = htonl((tcur.tv_sec % SECDAY) * 1000 - + tcur.tv_usec / 1000); - oicp->icmp_cksum = 0; - oicp->icmp_cksum = in_cksum((u_short*)oicp, - sizeof(*oicp)); - - count = sendto(sock_raw, opacket, sizeof(*oicp), 0, - (struct sockaddr*)addr, - sizeof(struct sockaddr)); - if (count < 0) { - if (measure_status == HOSTDOWN) - measure_status = UNREACHABLE; - goto quit; - } - ++oicp->icmp_seq; - - ttrans = tcur; - timevaladd(&ttrans, &twait); - } else { - ttrans = tdone; - } - - while (rcvcount < trials) { - timevalsub(&tout, &ttrans, &tcur); - if (tout.tv_sec < 0) - tout.tv_sec = 0; - - FD_SET(sock_raw, &ready); - count = select(sock_raw+1, &ready, (fd_set *)0, - (fd_set *)0, &tout); - (void)gettimeofday(&tcur, NULL); - if (count <= 0) - break; - - length = sizeof(struct sockaddr_in); - cc = recvfrom(sock_raw, (char *)packet, PACKET_IN, 0, - 0,&length); - if (cc < 0) - goto quit; - - /* - * got something. See if it is ours - */ - icp = (struct icmp *)(packet + (ip->ip_hl << 2)); - if (cc < sizeof(*ip) - || icp->icmp_type != ICMP_TSTAMPREPLY - || icp->icmp_id != oicp->icmp_id - || icp->icmp_seq < seqno - || icp->icmp_seq >= oicp->icmp_seq) - continue; - - - sendtime = ntohl(icp->icmp_otime); - recvtime = ((tcur.tv_sec % SECDAY) * 1000 + - tcur.tv_usec / 1000); - - total = recvtime-sendtime; - if (total < 0) /* do not hassle midnight */ - continue; - - rcvcount++; - histime1 = ntohl(icp->icmp_rtime); - histime2 = ntohl(icp->icmp_ttime); - /* - * a host using a time format different from - * msec. since midnight UT (as per RFC792) should - * set the high order bit of the 32-bit time - * value it transmits. - */ - if ((histime1 & 0x80000000) != 0) { - measure_status = NONSTDTIME; - goto quit; - } - measure_status = GOOD; - - idelta = recvtime-histime2; - odelta = histime1-sendtime; - - /* do not be confused by midnight */ - if (idelta < -MSEC_DAY/2) idelta += MSEC_DAY; - else if (idelta > MSEC_DAY/2) idelta -= MSEC_DAY; - - if (odelta < -MSEC_DAY/2) odelta += MSEC_DAY; - else if (odelta > MSEC_DAY/2) odelta -= MSEC_DAY; - - /* save the quantization error so that we can get a - * measurement finer than our system clock. - */ - if (total < MIN_ROUND) { - measure_delta = (odelta - idelta)/2; - goto quit; - } - - if (idelta < min_idelta) - min_idelta = idelta; - if (odelta < min_odelta) - min_odelta = odelta; - - measure_delta = (min_odelta - min_idelta)/2; - } - - if (tcur.tv_sec > tdone.tv_sec - || (tcur.tv_sec == tdone.tv_sec - && tcur.tv_usec >= tdone.tv_usec)) - break; - } - -quit: - seqno += TRIALS; /* allocate our sequence numbers */ - - /* - * If no answer is received for TRIALS consecutive times, - * the machine is assumed to be down - */ - if (measure_status == GOOD) { - if (trace) { - fprintf(fd, - "measured delta %4d, %d trials to %-15s %s\n", - measure_delta, trials, - inet_ntoa(addr->sin_addr), hname); - } - } else if (print) { - if (errno != 0) - warn("measure %s", hname); - } else { - if (errno != 0) { - syslog(LOG_ERR, "measure %s: %m", hname); - } else { - syslog(LOG_ERR, "measure: %s did not respond", hname); - } - if (trace) { - fprintf(fd, - "measure: %s failed after %d trials\n", - hname, trials); - (void)fflush(fd); - } - } - - return(measure_status); -} - - - - - -/* - * round a number of milliseconds into a struct timeval - */ -void -mstotvround(struct timeval *res, long x) -{ - if (x < 0) - x = -((-x + 3)/5); - else - x = (x+3)/5; - x *= 5; - res->tv_sec = x/1000; - res->tv_usec = (x-res->tv_sec*1000)*1000; - if (res->tv_usec < 0) { - res->tv_usec += 1000000; - res->tv_sec--; - } -} - -void -timevaladd(struct timeval *tv1, struct timeval *tv2) -{ - tv1->tv_sec += tv2->tv_sec; - tv1->tv_usec += tv2->tv_usec; - if (tv1->tv_usec >= 1000000) { - tv1->tv_sec++; - tv1->tv_usec -= 1000000; - } - if (tv1->tv_usec < 0) { - tv1->tv_sec--; - tv1->tv_usec += 1000000; - } -} - -void -timevalsub(struct timeval *res, struct timeval *tv1, struct timeval *tv2) -{ - res->tv_sec = tv1->tv_sec - tv2->tv_sec; - res->tv_usec = tv1->tv_usec - tv2->tv_usec; - if (res->tv_usec >= 1000000) { - res->tv_sec++; - res->tv_usec -= 1000000; - } - if (res->tv_usec < 0) { - res->tv_sec--; - res->tv_usec += 1000000; - } -} diff --git a/usr.sbin/timed/timed/networkdelta.c b/usr.sbin/timed/timed/networkdelta.c deleted file mode 100644 index 56b76de4a2f..00000000000 --- a/usr.sbin/timed/timed/networkdelta.c +++ /dev/null @@ -1,260 +0,0 @@ -/*- - * SPDX-License-Identifier: BSD-3-Clause - * - * Copyright (c) 1985, 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. 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 -#if 0 -static char sccsid[] = "@(#)networkdelta.c 8.1 (Berkeley) 6/6/93"; -#endif -#endif /* not lint */ - -#include "globals.h" - -static long median(float, float *, long *, long *, unsigned int); - -/* - * Compute a corrected date. - * Compute the median of the reasonable differences. First compute - * the median of all authorized differences, and then compute the - * median of all differences that are reasonably close to the first - * median. - * - * This differs from the original BSD implementation, which looked for - * the largest group of machines with essentially the same date. - * That assumed that machines with bad clocks would be uniformly - * distributed. Unfortunately, in real life networks, the distribution - * of machines is not uniform among models of machines, and the - * distribution of errors in clocks tends to be quite consistent - * for a given model. In other words, all model VI Supre Servres - * from GoFast Inc. tend to have about the same error. - * The original BSD implementation would chose the clock of the - * most common model, and discard all others. - * - * Therefore, get best we can do is to try to average over all - * of the machines in the network, while discarding "obviously" - * bad values. - */ -long -networkdelta(void) -{ - struct hosttbl *htp; - long med; - long lodelta, hidelta; - long logood, higood; - long x[NHOSTS]; - long *xp; - int numdelta; - float eps; - - /* - * compute the median of the good values - */ - med = 0; - numdelta = 1; - xp = &x[0]; - *xp = 0; /* account for ourself */ - for (htp = self.l_fwd; htp != &self; htp = htp->l_fwd) { - if (htp->good - && htp->noanswer == 0 - && htp->delta != HOSTDOWN) { - med += htp->delta; - numdelta++; - *++xp = htp->delta; - } - } - - /* - * If we are the only trusted time keeper, then do not change our - * clock. There may be another time keeping service active. - */ - if (numdelta == 1) - return 0; - - med /= numdelta; - eps = med - x[0]; - if (trace) - fprintf(fd, "median of %d values starting at %ld is about ", - numdelta, med); - med = median(med, &eps, &x[0], xp+1, VALID_RANGE); - - /* - * compute the median of all values near the good median - */ - hidelta = med + GOOD_RANGE; - lodelta = med - GOOD_RANGE; - higood = med + VGOOD_RANGE; - logood = med - VGOOD_RANGE; - xp = &x[0]; - htp = &self; - do { - if (htp->noanswer == 0 - && htp->delta >= lodelta - && htp->delta <= hidelta - && (htp->good - || (htp->delta >= logood - && htp->delta <= higood))) { - *xp++ = htp->delta; - } - } while (&self != (htp = htp->l_fwd)); - - if (xp == &x[0]) { - if (trace) - fprintf(fd, "nothing close to median %ld\n", med); - return med; - } - - if (xp == &x[1]) { - if (trace) - fprintf(fd, "only value near median is %ld\n", x[0]); - return x[0]; - } - - if (trace) - fprintf(fd, "median of %td values starting at %ld is ", - xp-&x[0], med); - return median(med, &eps, &x[0], xp, 1); -} - - -/* - * compute the median of an array of signed integers, using the idea - * in <>. - */ -static long -median(float a, float *eps_ptr, long *x, long *xlim, unsigned int gnuf) - /* float a; */ /* initial guess for the median */ - /* float *eps_ptr; */ /* spacing near the median */ - /* long *x, *xlim; */ /* the data */ - /* unsigned int gnuf; */ /* good enough estimate */ -{ - long *xptr; - float ap = (float)LONG_MAX; /* bounds on the median */ - float am = -(float)LONG_MAX; - float aa; - int npts; /* # of points above & below guess */ - float xp; /* closet point above the guess */ - float xm; /* closet point below the guess */ - float eps; - float dum, sum, sumx; - int pass; -#define AMP 1.5 /* smoothing constants */ -#define AFAC 1.5 - - eps = *eps_ptr; - if (eps < 1.0) { - eps = -eps; - if (eps < 1.0) - eps = 1.0; - } - - for (pass = 1; ; pass++) { /* loop over the data */ - sum = 0.0; - sumx = 0.0; - npts = 0; - xp = (float)LONG_MAX; - xm = -(float)LONG_MAX; - - for (xptr = x; xptr != xlim; xptr++) { - float xx = *xptr; - - dum = xx - a; - if (dum != 0.0) { /* avoid dividing by 0 */ - if (dum > 0.0) { - npts++; - if (xx < xp) - xp = xx; - } else { - npts--; - if (xx > xm) - xm = xx; - dum = -dum; - } - dum = 1.0/(eps + dum); - sum += dum; - sumx += xx * dum; - } - } - - if (ap-am < gnuf || sum == 0) { - if (trace) - fprintf(fd, - "%ld in %d passes; early out balance=%d\n", - (long)a, pass, npts); - return a; /* guess was good enough */ - } - - aa = (sumx/sum-a)*AMP; - if (npts >= 2) { /* guess was too low */ - am = a; - aa = xp + max(0.0, aa); - if (aa > ap) - aa = (a + ap)/2; - - } else if (npts <= -2) { /* guess was two high */ - ap = a; - aa = xm + min(0.0, aa); - if (aa < am) - aa = (a + am)/2; - - } else { - break; /* got it */ - } - - if (a == aa) { - if (trace) - fprintf(fd, - "%ld in %d passes; force out balance=%d\n", - (long)a, pass, npts); - return a; - } - eps = AFAC*abs(aa - a); - *eps_ptr = eps; - a = aa; - } - - if (((x - xlim) % 2) != 0) { /* even number of points? */ - if (npts == 0) /* yes, return an average */ - a = (xp+xm)/2; - else if (npts > 0) - a = (a+xp)/2; - else - a = (xm+a)/2; - - } else if (npts != 0) { /* odd number of points */ - if (npts > 0) - a = xp; - else - a = xm; - } - - if (trace) - fprintf(fd, "%ld in %d passes\n", (long)a, pass); - return a; -} diff --git a/usr.sbin/timed/timed/pathnames.h b/usr.sbin/timed/timed/pathnames.h deleted file mode 100644 index a56d30b21cf..00000000000 --- a/usr.sbin/timed/timed/pathnames.h +++ /dev/null @@ -1,38 +0,0 @@ -/*- - * SPDX-License-Identifier: BSD-3-Clause - * - * Copyright (c) 1985, 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. 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/6/93 - * - */ - -#include - -#define _PATH_MASTERLOG "/var/log/timed.masterlog" -#define _PATH_TIMEDLOG "/var/log/timed.log" diff --git a/usr.sbin/timed/timed/readmsg.c b/usr.sbin/timed/timed/readmsg.c deleted file mode 100644 index 9cc2d67395c..00000000000 --- a/usr.sbin/timed/timed/readmsg.c +++ /dev/null @@ -1,502 +0,0 @@ -/*- - * SPDX-License-Identifier: BSD-3-Clause - * - * Copyright (c) 1985, 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. 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 -#if 0 -static char sccsid[] = "@(#)readmsg.c 8.1 (Berkeley) 6/6/93"; -#endif -#endif /* not lint */ - -#define TSPTYPES -#include "globals.h" - -/* - * LOOKAT checks if the message is of the requested type and comes from - * the right machine, returning 1 in case of affirmative answer - */ -#define LOOKAT(msg, mtype, mfrom, netp, froms) \ - (((mtype) == TSP_ANY || (mtype) == (msg).tsp_type) && \ - ((mfrom) == 0 || !strcmp((mfrom), (msg).tsp_name)) && \ - ((netp) == 0 || \ - ((netp)->mask & (froms).sin_addr.s_addr) == (netp)->net.s_addr)) - -struct timeval rtime, rwait, rtout; -struct tsp msgin; -static struct tsplist { - struct tsp info; - struct timeval when; - struct sockaddr_in addr; - struct tsplist *p; -} msgslist; -struct sockaddr_in from; -struct netinfo *fromnet; -struct timeval from_when; - -/* - * `readmsg' returns message `type' sent by `machfrom' if it finds it - * either in the receive queue, or in a linked list of previously received - * messages that it maintains. - * Otherwise it waits to see if the appropriate message arrives within - * `intvl' seconds. If not, it returns NULL. - */ - -struct tsp * -readmsg(int type, char *machfrom, struct timeval *intvl, struct netinfo *netfrom) -{ - int length; - fd_set ready; - static struct tsplist *head = &msgslist; - static struct tsplist *tail = &msgslist; - static int msgcnt = 0; - struct tsplist *prev; - register struct netinfo *ntp; - register struct tsplist *ptr; - ssize_t n; - - if (trace) { - fprintf(fd, "readmsg: looking for %s from %s, %s\n", - tsptype[type], machfrom == NULL ? "ANY" : machfrom, - netfrom == NULL ? "ANYNET" : inet_ntoa(netfrom->net)); - if (head->p != NULL) { - length = 1; - for (ptr = head->p; ptr != NULL; ptr = ptr->p) { - /* do not repeat the hundreds of messages */ - if (++length > 3) { - if (ptr == tail) { - fprintf(fd,"\t ...%d skipped\n", - length); - } else { - continue; - } - } - fprintf(fd, length > 1 ? "\t" : "queue:\t"); - print(&ptr->info, &ptr->addr); - } - } - } - - ptr = head->p; - prev = head; - - /* - * Look for the requested message scanning through the - * linked list. If found, return it and free the space - */ - - while (ptr != NULL) { - if (LOOKAT(ptr->info, type, machfrom, netfrom, ptr->addr)) { -again: - msgin = ptr->info; - from = ptr->addr; - from_when = ptr->when; - prev->p = ptr->p; - if (ptr == tail) - tail = prev; - free((char *)ptr); - fromnet = NULL; - if (netfrom == NULL) - for (ntp = nettab; ntp != NULL; ntp = ntp->next) { - if ((ntp->mask & from.sin_addr.s_addr) == - ntp->net.s_addr) { - fromnet = ntp; - break; - } - } - else - fromnet = netfrom; - if (trace) { - fprintf(fd, "readmsg: found "); - print(&msgin, &from); - } - -/* The protocol can get far behind. When it does, it gets - * hopelessly confused. So delete duplicate messages. - */ - for (ptr = prev; (ptr = ptr->p) != NULL; prev = ptr) { - if (ptr->addr.sin_addr.s_addr - == from.sin_addr.s_addr - && ptr->info.tsp_type == msgin.tsp_type) { - if (trace) - fprintf(fd, "\tdup "); - goto again; - } - } - msgcnt--; - return(&msgin); - } else { - prev = ptr; - ptr = ptr->p; - } - } - - /* - * If the message was not in the linked list, it may still be - * coming from the network. Set the timer and wait - * on a select to read the next incoming message: if it is the - * right one, return it, otherwise insert it in the linked list. - */ - - (void)gettimeofday(&rtout, NULL); - timevaladd(&rtout, intvl); - FD_ZERO(&ready); - for (;;) { - (void)gettimeofday(&rtime, NULL); - timevalsub(&rwait, &rtout, &rtime); - if (rwait.tv_sec < 0) - rwait.tv_sec = rwait.tv_usec = 0; - else if (rwait.tv_sec == 0 - && rwait.tv_usec < 1000000/CLK_TCK) - rwait.tv_usec = 1000000/CLK_TCK; - - if (trace) { - fprintf(fd, "readmsg: wait %jd.%6ld at %s\n", - (intmax_t)rwait.tv_sec, rwait.tv_usec, date()); - /* Notice a full disk, as we flush trace info. - * It is better to flush periodically than at - * every line because the tracing consists of bursts - * of many lines. Without care, tracing slows - * down the code enough to break the protocol. - */ - if (rwait.tv_sec != 0 - && EOF == fflush(fd)) - traceoff("Tracing ended for cause at %s\n"); - } - - FD_SET(sock, &ready); - if (!select(sock+1, &ready, (fd_set *)0, (fd_set *)0, - &rwait)) { - if (rwait.tv_sec == 0 && rwait.tv_usec == 0) - return(0); - continue; - } - length = sizeof(from); - if ((n = recvfrom(sock, (char *)&msgin, sizeof(struct tsp), 0, - (struct sockaddr*)&from, &length)) < 0) { - syslog(LOG_ERR, "recvfrom: %m"); - exit(1); - } - /* - * The 4.3BSD protocol spec had a 32-byte tsp_name field, and - * this is still OS-dependent. Demand that the packet is at - * least long enough to hold a 4.3BSD packet. - */ - if (n < (ssize_t)(sizeof(struct tsp) - MAXHOSTNAMELEN + 32)) { - syslog(LOG_NOTICE, - "short packet (%zd/%zu bytes) from %s", - n, sizeof(struct tsp) - MAXHOSTNAMELEN + 32, - inet_ntoa(from.sin_addr)); - continue; - } - (void)gettimeofday(&from_when, NULL); - bytehostorder(&msgin); - - if (msgin.tsp_vers > TSPVERSION) { - if (trace) { - fprintf(fd,"readmsg: version mismatch\n"); - /* should do a dump of the packet */ - } - continue; - } - - if (memchr(msgin.tsp_name, - '\0', sizeof msgin.tsp_name) == NULL) { - syslog(LOG_NOTICE, "hostname field not NUL terminated " - "in packet from %s", inet_ntoa(from.sin_addr)); - continue; - } - - fromnet = NULL; - for (ntp = nettab; ntp != NULL; ntp = ntp->next) - if ((ntp->mask & from.sin_addr.s_addr) == - ntp->net.s_addr) { - fromnet = ntp; - break; - } - - /* - * drop packets from nets we are ignoring permanently - */ - if (fromnet == NULL) { - /* - * The following messages may originate on - * this host with an ignored network address - */ - if (msgin.tsp_type != TSP_TRACEON && - msgin.tsp_type != TSP_SETDATE && - msgin.tsp_type != TSP_MSITE && - msgin.tsp_type != TSP_TEST && - msgin.tsp_type != TSP_TRACEOFF) { - if (trace) { - fprintf(fd,"readmsg: discard null net "); - print(&msgin, &from); - } - continue; - } - } - - /* - * Throw away messages coming from this machine, - * unless they are of some particular type. - * This gets rid of broadcast messages and reduces - * master processing time. - */ - if (!strcmp(msgin.tsp_name, hostname) - && msgin.tsp_type != TSP_SETDATE - && msgin.tsp_type != TSP_TEST - && msgin.tsp_type != TSP_MSITE - && msgin.tsp_type != TSP_TRACEON - && msgin.tsp_type != TSP_TRACEOFF - && msgin.tsp_type != TSP_LOOP) { - if (trace) { - fprintf(fd, "readmsg: discard own "); - print(&msgin, &from); - } - continue; - } - - /* - * Send acknowledgements here; this is faster and - * avoids deadlocks that would occur if acks were - * sent from a higher level routine. Different - * acknowledgements are necessary, depending on - * status. - */ - if (fromnet == NULL) /* do not de-reference 0 */ - ignoreack(); - else if (fromnet->status == MASTER) - masterack(); - else if (fromnet->status == SLAVE) - slaveack(); - else - ignoreack(); - - if (LOOKAT(msgin, type, machfrom, netfrom, from)) { - if (trace) { - fprintf(fd, "readmsg: "); - print(&msgin, &from); - } - return(&msgin); - } else if (++msgcnt > NHOSTS*3) { - -/* The protocol gets hopelessly confused if it gets too far -* behind. However, it seems able to recover from all cases of lost -* packets. Therefore, if we are swamped, throw everything away. -*/ - if (trace) - fprintf(fd, - "readmsg: discarding %d msgs\n", - msgcnt); - msgcnt = 0; - while ((ptr=head->p) != NULL) { - head->p = ptr->p; - free((char *)ptr); - } - tail = head; - } else { - tail->p = (struct tsplist *) - malloc(sizeof(struct tsplist)); - tail = tail->p; - tail->p = NULL; - tail->info = msgin; - tail->addr = from; - /* timestamp msgs so SETTIMEs are correct */ - tail->when = from_when; - } - } -} - -/* - * Send the necessary acknowledgements: - * only the type ACK is to be sent by a slave - */ -void -slaveack(void) -{ - switch(msgin.tsp_type) { - - case TSP_ADJTIME: - case TSP_SETTIME: - case TSP_ACCEPT: - case TSP_REFUSE: - case TSP_TRACEON: - case TSP_TRACEOFF: - case TSP_QUIT: - if (trace) { - fprintf(fd, "Slaveack: "); - print(&msgin, &from); - } - xmit(TSP_ACK,msgin.tsp_seq, &from); - break; - - default: - if (trace) { - fprintf(fd, "Slaveack: no ack: "); - print(&msgin, &from); - } - break; - } -} - -/* - * Certain packets may arrive from this machine on ignored networks. - * These packets should be acknowledged. - */ -void -ignoreack(void) -{ - switch(msgin.tsp_type) { - - case TSP_TRACEON: - case TSP_TRACEOFF: - case TSP_QUIT: - if (trace) { - fprintf(fd, "Ignoreack: "); - print(&msgin, &from); - } - xmit(TSP_ACK,msgin.tsp_seq, &from); - break; - - default: - if (trace) { - fprintf(fd, "Ignoreack: no ack: "); - print(&msgin, &from); - } - break; - } -} - -/* - * `masterack' sends the necessary acknowledgments - * to the messages received by a master - */ -void -masterack(void) -{ - struct tsp resp; - - resp = msgin; - resp.tsp_vers = TSPVERSION; - (void)strcpy(resp.tsp_name, hostname); - - switch(msgin.tsp_type) { - - case TSP_QUIT: - case TSP_TRACEON: - case TSP_TRACEOFF: - case TSP_MSITEREQ: - if (trace) { - fprintf(fd, "Masterack: "); - print(&msgin, &from); - } - xmit(TSP_ACK,msgin.tsp_seq, &from); - break; - - case TSP_RESOLVE: - case TSP_MASTERREQ: - if (trace) { - fprintf(fd, "Masterack: "); - print(&msgin, &from); - } - xmit(TSP_MASTERACK,msgin.tsp_seq, &from); - break; - - default: - if (trace) { - fprintf(fd,"Masterack: no ack: "); - print(&msgin, &from); - } - break; - } -} - -/* - * Print a TSP message - */ -void -print(struct tsp *msg, struct sockaddr_in *addr) -{ - char tm[26]; - time_t tsp_time_sec; - - if (msg->tsp_type >= TSPTYPENUMBER) { - fprintf(fd, "bad type (%u) on packet from %s\n", - msg->tsp_type, inet_ntoa(addr->sin_addr)); - return; - } - - switch (msg->tsp_type) { - - case TSP_LOOP: - fprintf(fd, "%s %d %-6u #%d %-15s %s\n", - tsptype[msg->tsp_type], - msg->tsp_vers, - msg->tsp_seq, - msg->tsp_hopcnt, - inet_ntoa(addr->sin_addr), - msg->tsp_name); - break; - - case TSP_SETTIME: - case TSP_SETDATE: - case TSP_SETDATEREQ: - tsp_time_sec = msg->tsp_time.tv_sec; - strncpy(tm, ctime(&tsp_time_sec)+3+1, sizeof(tm)); - tm[15] = '\0'; /* ugh */ - fprintf(fd, "%s %d %-6u %s %-15s %s\n", - tsptype[msg->tsp_type], - msg->tsp_vers, - msg->tsp_seq, - tm, - inet_ntoa(addr->sin_addr), - msg->tsp_name); - break; - - case TSP_ADJTIME: - fprintf(fd, "%s %d %-6u (%d,%d) %-15s %s\n", - tsptype[msg->tsp_type], - msg->tsp_vers, - msg->tsp_seq, - msg->tsp_time.tv_sec, - msg->tsp_time.tv_usec, - inet_ntoa(addr->sin_addr), - msg->tsp_name); - break; - - default: - fprintf(fd, "%s %d %-6u %-15s %s\n", - tsptype[msg->tsp_type], - msg->tsp_vers, - msg->tsp_seq, - inet_ntoa(addr->sin_addr), - msg->tsp_name); - break; - } -} diff --git a/usr.sbin/timed/timed/slave.c b/usr.sbin/timed/timed/slave.c deleted file mode 100644 index 68b160471e0..00000000000 --- a/usr.sbin/timed/timed/slave.c +++ /dev/null @@ -1,693 +0,0 @@ -/*- - * SPDX-License-Identifier: BSD-3-Clause - * - * Copyright (c) 1985, 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. 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 -#if 0 -static char sccsid[] = "@(#)slave.c 8.1 (Berkeley) 6/6/93"; -#endif -#endif /* not lint */ - -#include "globals.h" -#include -#include -#include "pathnames.h" - -extern jmp_buf jmpenv; -extern int Mflag; -extern int justquit; - -extern u_short sequence; - -static char master_name[MAXHOSTNAMELEN]; -static struct netinfo *old_slavenet; -static int old_status; - -static void schgdate(struct tsp *, char *); -static void setmaster(struct tsp *); -static void answerdelay(void); - -void -slave(void) -{ - int tries; - long electiontime, refusetime, looktime, looptime, adjtime; - u_short seq; - long fastelection; -#define FASTTOUT 3 - struct in_addr cadr; - struct timeval otime; - struct sockaddr_in taddr; - char tname[MAXHOSTNAMELEN]; - struct tsp *msg, to; - struct timeval ntime, wait, tmptv; - time_t tsp_time_sec; - struct tsp *answer; - int timeout(); - char olddate[32]; - char newdate[32]; - struct netinfo *ntp; - struct hosttbl *htp; - struct utmpx utx; - - - old_slavenet = NULL; - seq = 0; - refusetime = 0; - adjtime = 0; - - (void)gettimeofday(&ntime, NULL); - electiontime = ntime.tv_sec + delay2; - fastelection = ntime.tv_sec + FASTTOUT; - if (justquit) - looktime = electiontime; - else - looktime = fastelection; - looptime = fastelection; - - if (slavenet) - xmit(TSP_SLAVEUP, 0, &slavenet->dest_addr); - if (status & MASTER) { - for (ntp = nettab; ntp != NULL; ntp = ntp->next) { - if (ntp->status == MASTER) - masterup(ntp); - } - } - -loop: - get_goodgroup(0); - (void)gettimeofday(&ntime, NULL); - if (ntime.tv_sec > electiontime) { - if (trace) - fprintf(fd, "election timer expired\n"); - longjmp(jmpenv, 1); - } - - if (ntime.tv_sec >= looktime) { - if (trace) - fprintf(fd, "Looking for nets to master\n"); - - if (Mflag && nignorednets > 0) { - for (ntp = nettab; ntp != NULL; ntp = ntp->next) { - if (ntp->status == IGNORE - || ntp->status == NOMASTER) { - lookformaster(ntp); - if (ntp->status == MASTER) { - masterup(ntp); - } else if (ntp->status == MASTER) { - ntp->status = NOMASTER; - } - } - if (ntp->status == MASTER - && --ntp->quit_count < 0) - ntp->quit_count = 0; - } - makeslave(slavenet); /* prune extras */ - setstatus(); - } - (void)gettimeofday(&ntime, NULL); - looktime = ntime.tv_sec + delay2; - } - if (ntime.tv_sec >= looptime) { - if (trace) - fprintf(fd, "Looking for loops\n"); - for (ntp = nettab; ntp != NULL; ntp = ntp->next) { - if (ntp->status == MASTER) { - to.tsp_type = TSP_LOOP; - to.tsp_vers = TSPVERSION; - to.tsp_seq = sequence++; - to.tsp_hopcnt = MAX_HOPCNT; - (void)strcpy(to.tsp_name, hostname); - bytenetorder(&to); - if (sendto(sock, (char *)&to, sizeof(struct tsp), 0, - (struct sockaddr*)&ntp->dest_addr, - sizeof(ntp->dest_addr)) < 0) { - trace_sendto_err(ntp->dest_addr.sin_addr); - } - } - } - (void)gettimeofday(&ntime, NULL); - looptime = ntime.tv_sec + delay2; - } - - wait.tv_sec = min(electiontime,min(looktime,looptime)) - ntime.tv_sec; - if (wait.tv_sec < 0) - wait.tv_sec = 0; - wait.tv_sec += FASTTOUT; - wait.tv_usec = 0; - msg = readmsg(TSP_ANY, ANYADDR, &wait, 0); - - if (msg != NULL) { - /* - * filter stuff not for us - */ - switch (msg->tsp_type) { - case TSP_SETDATE: - case TSP_TRACEOFF: - case TSP_TRACEON: - /* - * XXX check to see they are from ourself - */ - break; - - case TSP_TEST: - case TSP_MSITE: - break; - - case TSP_MASTERUP: - if (!fromnet) { - if (trace) { - fprintf(fd, "slave ignored: "); - print(msg, &from); - } - goto loop; - } - break; - - default: - if (!fromnet - || fromnet->status == IGNORE - || fromnet->status == NOMASTER) { - if (trace) { - fprintf(fd, "slave ignored: "); - print(msg, &from); - } - goto loop; - } - break; - } - - - /* - * now process the message - */ - switch (msg->tsp_type) { - - case TSP_ADJTIME: - if (fromnet != slavenet) - break; - if (!good_host_name(msg->tsp_name)) { - syslog(LOG_NOTICE, - "attempted time adjustment by %s", - msg->tsp_name); - suppress(&from, msg->tsp_name, fromnet); - break; - } - /* - * Speed up loop detection in case we have a loop. - * Otherwise the clocks can race until the loop - * is found. - */ - (void)gettimeofday(&otime, NULL); - if (adjtime < otime.tv_sec) - looptime -= (looptime-otime.tv_sec)/2 + 1; - - setmaster(msg); - if (seq != msg->tsp_seq) { - seq = msg->tsp_seq; - synch(tvtomsround(msg->tsp_time)); - } - (void)gettimeofday(&ntime, NULL); - electiontime = ntime.tv_sec + delay2; - fastelection = ntime.tv_sec + FASTTOUT; - adjtime = ntime.tv_sec + SAMPLEINTVL*2; - break; - - case TSP_SETTIME: - if (fromnet != slavenet) - break; - if (seq == msg->tsp_seq) - break; - seq = msg->tsp_seq; - - /* adjust time for residence on the queue */ - (void)gettimeofday(&otime, NULL); - adj_msg_time(msg,&otime); - /* - * the following line is necessary due to syslog - * calling ctime() which clobbers the static buffer - */ - (void)strlcpy(olddate, date(), sizeof(olddate)); - tsp_time_sec = msg->tsp_time.tv_sec; - (void)strlcpy(newdate, ctime(&tsp_time_sec), - sizeof(newdate)); - - if (!good_host_name(msg->tsp_name)) { - syslog(LOG_NOTICE, - "attempted time setting by untrusted %s to %s", - msg->tsp_name, newdate); - suppress(&from, msg->tsp_name, fromnet); - break; - } - - setmaster(msg); - tmptv.tv_sec = msg->tsp_time.tv_sec; - tmptv.tv_usec = msg->tsp_time.tv_usec; - timevalsub(&ntime, &tmptv, &otime); - if (ntime.tv_sec < MAXADJ && ntime.tv_sec > -MAXADJ) { - /* - * do not change the clock if we can adjust it - */ - synch(tvtomsround(ntime)); - } else { - utx.ut_type = OLD_TIME; - gettimeofday(&utx.ut_tv, NULL); - pututxline(&utx); - (void)settimeofday(&tmptv, 0); - utx.ut_type = NEW_TIME; - gettimeofday(&utx.ut_tv, NULL); - pututxline(&utx); - syslog(LOG_NOTICE, - "date changed by %s from %s", - msg->tsp_name, olddate); - if (status & MASTER) - spreadtime(); - } - (void)gettimeofday(&ntime, NULL); - electiontime = ntime.tv_sec + delay2; - fastelection = ntime.tv_sec + FASTTOUT; - -/* This patches a bad protocol bug. Imagine a system with several networks, - * where there are a pair of redundant gateways between a pair of networks, - * each running timed. Assume that we start with a third machine mastering - * one of the networks, and one of the gateways mastering the other. - * Imagine that the third machine goes away and the non-master gateway - * decides to replace it. If things are timed just 'right,' we will have - * each gateway mastering one network for a little while. If a SETTIME - * message gets into the network at that time, perhaps from the newly - * masterful gateway as it was taking control, the SETTIME will loop - * forever. Each time a gateway receives it on its slave side, it will - * call spreadtime to forward it on its mastered network. We are now in - * a permanent loop, since the SETTIME msgs will keep any clock - * in the network from advancing. Normally, the 'LOOP' stuff will detect - * and correct the situation. However, with the clocks stopped, the - * 'looptime' timer cannot expire. While they are in this state, the - * masters will try to saturate the network with SETTIME packets. - */ - looptime = ntime.tv_sec + (looptime-otime.tv_sec)/2-1; - break; - - case TSP_MASTERUP: - if (slavenet && fromnet != slavenet) - break; - if (!good_host_name(msg->tsp_name)) { - suppress(&from, msg->tsp_name, fromnet); - if (electiontime > fastelection) - electiontime = fastelection; - break; - } - makeslave(fromnet); - setmaster(msg); - setstatus(); - answerdelay(); - xmit(TSP_SLAVEUP, 0, &from); - (void)gettimeofday(&ntime, NULL); - electiontime = ntime.tv_sec + delay2; - fastelection = ntime.tv_sec + FASTTOUT; - refusetime = 0; - break; - - case TSP_MASTERREQ: - if (fromnet->status != SLAVE) - break; - (void)gettimeofday(&ntime, NULL); - electiontime = ntime.tv_sec + delay2; - break; - - case TSP_SETDATE: - tsp_time_sec = msg->tsp_time.tv_sec; - (void)strlcpy(newdate, ctime(&tsp_time_sec), - sizeof(newdate)); - schgdate(msg, newdate); - break; - - case TSP_SETDATEREQ: - if (fromnet->status != MASTER) - break; - tsp_time_sec = msg->tsp_time.tv_sec; - (void)strlcpy(newdate, ctime(&tsp_time_sec), - sizeof(newdate)); - htp = findhost(msg->tsp_name); - if (htp == NULL) { - syslog(LOG_WARNING, - "DATEREQ from uncontrolled machine"); - break; - } - if (!htp->good) { - syslog(LOG_WARNING, - "attempted date change by untrusted %s to %s", - htp->name, newdate); - spreadtime(); - break; - } - schgdate(msg, newdate); - break; - - case TSP_TRACEON: - traceon(); - break; - - case TSP_TRACEOFF: - traceoff("Tracing ended at %s\n"); - break; - - case TSP_SLAVEUP: - newslave(msg); - break; - - case TSP_ELECTION: - if (fromnet->status == SLAVE) { - (void)gettimeofday(&ntime, NULL); - electiontime = ntime.tv_sec + delay2; - fastelection = ntime.tv_sec + FASTTOUT; - seq = 0; - if (!good_host_name(msg->tsp_name)) { - syslog(LOG_NOTICE, - "suppress election of %s", - msg->tsp_name); - to.tsp_type = TSP_QUIT; - electiontime = fastelection; - } else if (cadr.s_addr != from.sin_addr.s_addr - && ntime.tv_sec < refusetime) { -/* if the candidate has to repeat itself, the old code would refuse it - * the second time. That would prevent elections. - */ - to.tsp_type = TSP_REFUSE; - } else { - cadr.s_addr = from.sin_addr.s_addr; - to.tsp_type = TSP_ACCEPT; - refusetime = ntime.tv_sec + 30; - } - taddr = from; - (void)strcpy(tname, msg->tsp_name); - (void)strcpy(to.tsp_name, hostname); - answerdelay(); - if (!acksend(&to, &taddr, tname, - TSP_ACK, 0, 0)) - syslog(LOG_WARNING, - "no answer from candidate %s\n", - tname); - - } else { /* fromnet->status == MASTER */ - htp = addmach(msg->tsp_name, &from,fromnet); - to.tsp_type = TSP_QUIT; - (void)strcpy(to.tsp_name, hostname); - if (!acksend(&to, &htp->addr, htp->name, - TSP_ACK, 0, htp->noanswer)) { - syslog(LOG_ERR, - "no reply from %s to ELECTION-QUIT", - htp->name); - (void)remmach(htp); - } - } - break; - - case TSP_CONFLICT: - if (fromnet->status != MASTER) - break; - /* - * After a network partition, there can be - * more than one master: the first slave to - * come up will notify here the situation. - */ - (void)strcpy(to.tsp_name, hostname); - - /* The other master often gets into the same state, - * with boring results. - */ - ntp = fromnet; /* (acksend() can leave fromnet=0 */ - for (tries = 0; tries < 3; tries++) { - to.tsp_type = TSP_RESOLVE; - answer = acksend(&to, &ntp->dest_addr, - ANYADDR, TSP_MASTERACK, - ntp, 0); - if (answer == NULL) - break; - htp = addmach(answer->tsp_name,&from,ntp); - to.tsp_type = TSP_QUIT; - answer = acksend(&to, &htp->addr, htp->name, - TSP_ACK, 0, htp->noanswer); - if (!answer) { - syslog(LOG_WARNING, - "conflict error: no reply from %s to QUIT", - htp->name); - (void)remmach(htp); - } - } - masterup(ntp); - break; - - case TSP_MSITE: - if (!slavenet) - break; - taddr = from; - to.tsp_type = TSP_MSITEREQ; - to.tsp_vers = TSPVERSION; - to.tsp_seq = 0; - (void)strcpy(to.tsp_name, hostname); - answer = acksend(&to, &slavenet->dest_addr, - ANYADDR, TSP_ACK, - slavenet, 0); - if (answer != NULL - && good_host_name(answer->tsp_name)) { - setmaster(answer); - to.tsp_type = TSP_ACK; - (void)strcpy(to.tsp_name, answer->tsp_name); - bytenetorder(&to); - if (sendto(sock, (char *)&to, - sizeof(struct tsp), 0, - (struct sockaddr*)&taddr, - sizeof(taddr)) < 0) { - trace_sendto_err(taddr.sin_addr); - } - } - break; - - case TSP_MSITEREQ: - break; - - case TSP_ACCEPT: - case TSP_REFUSE: - case TSP_RESOLVE: - break; - - case TSP_QUIT: - doquit(msg); /* become a slave */ - break; - - case TSP_TEST: - electiontime = 0; - break; - - case TSP_LOOP: - /* looking for loops of masters */ - if (!(status & MASTER)) - break; - if (fromnet->status == SLAVE) { - if (!strcmp(msg->tsp_name, hostname)) { - /* - * Someone forwarded our message back to - * us. There must be a loop. Tell the - * master of this network to quit. - * - * The other master often gets into - * the same state, with boring results. - */ - ntp = fromnet; - for (tries = 0; tries < 3; tries++) { - to.tsp_type = TSP_RESOLVE; - answer = acksend(&to, &ntp->dest_addr, - ANYADDR, TSP_MASTERACK, - ntp,0); - if (answer == NULL) - break; - taddr = from; - (void)strcpy(tname, answer->tsp_name); - to.tsp_type = TSP_QUIT; - (void)strcpy(to.tsp_name, hostname); - if (!acksend(&to, &taddr, tname, - TSP_ACK, 0, 1)) { - syslog(LOG_ERR, - "no reply from %s to slave LOOP-QUIT", - tname); - } else { - electiontime = 0; - } - } - (void)gettimeofday(&ntime, NULL); - looptime = ntime.tv_sec + FASTTOUT; - } else { - if (msg->tsp_hopcnt-- < 1) - break; - bytenetorder(msg); - for (ntp = nettab; ntp != NULL; ntp = ntp->next) { - if (ntp->status == MASTER - && 0 > sendto(sock, (char *)msg, - sizeof(struct tsp), 0, - (struct sockaddr*)&ntp->dest_addr, - sizeof(ntp->dest_addr))) - trace_sendto_err(ntp->dest_addr.sin_addr); - } - } - } else { /* fromnet->status == MASTER */ - /* - * We should not have received this from a net - * we are master on. There must be two masters, - * unless the packet was really from us. - */ - if (from.sin_addr.s_addr - == fromnet->my_addr.s_addr) { - if (trace) - fprintf(fd,"discarding forwarded LOOP\n"); - break; - } - - /* - * The other master often gets into the same - * state, with boring results. - */ - ntp = fromnet; - for (tries = 0; tries < 3; tries++) { - to.tsp_type = TSP_RESOLVE; - answer = acksend(&to, &ntp->dest_addr, - ANYADDR, TSP_MASTERACK, - ntp,0); - if (!answer) - break; - htp = addmach(answer->tsp_name, - &from,ntp); - to.tsp_type = TSP_QUIT; - (void)strcpy(to.tsp_name, hostname); - if (!acksend(&to,&htp->addr,htp->name, - TSP_ACK, 0, htp->noanswer)) { - syslog(LOG_ERR, - "no reply from %s to master LOOP-QUIT", - htp->name); - (void)remmach(htp); - } - } - (void)gettimeofday(&ntime, NULL); - looptime = ntime.tv_sec + FASTTOUT; - } - break; - default: - if (trace) { - fprintf(fd, "garbage message: "); - print(msg, &from); - } - break; - } - } - goto loop; -} - - -/* - * tell the world who our master is - */ -static void -setmaster(struct tsp *msg) -{ - if (slavenet - && (slavenet != old_slavenet - || strcmp(msg->tsp_name, master_name) - || old_status != status)) { - (void)strcpy(master_name, msg->tsp_name); - old_slavenet = slavenet; - old_status = status; - - if (status & MASTER) { - syslog(LOG_NOTICE, "submaster to %s", master_name); - if (trace) - fprintf(fd, "submaster to %s\n", master_name); - - } else { - syslog(LOG_NOTICE, "slave to %s", master_name); - if (trace) - fprintf(fd, "slave to %s\n", master_name); - } - } -} - - - -/* - * handle date change request on a slave - */ -static void -schgdate(struct tsp *msg, char *newdate) -{ - struct tsp to; - u_short seq; - struct sockaddr_in taddr; - struct timeval otime; - - if (!slavenet) - return; /* no where to forward */ - - taddr = from; - seq = msg->tsp_seq; - - syslog(LOG_INFO, - "forwarding date change by %s to %s", - msg->tsp_name, newdate); - - /* adjust time for residence on the queue */ - (void)gettimeofday(&otime, NULL); - adj_msg_time(msg, &otime); - - to.tsp_type = TSP_SETDATEREQ; - to.tsp_time = msg->tsp_time; - (void)strcpy(to.tsp_name, hostname); - if (!acksend(&to, &slavenet->dest_addr, - ANYADDR, TSP_DATEACK, - slavenet, 0)) - return; /* no answer */ - - xmit(TSP_DATEACK, seq, &taddr); -} - - -/* - * Used before answering a broadcast message to avoid network - * contention and likely collisions. - */ -static void -answerdelay(void) -{ - struct timeval timeout; - - timeout.tv_sec = 0; - timeout.tv_usec = delay1; - - (void)select(0, (fd_set *)NULL, (fd_set *)NULL, (fd_set *)NULL, - &timeout); - return; -} diff --git a/usr.sbin/timed/timed/timed.8 b/usr.sbin/timed/timed/timed.8 deleted file mode 100644 index e3445b48a4f..00000000000 --- a/usr.sbin/timed/timed/timed.8 +++ /dev/null @@ -1,293 +0,0 @@ -.\" Copyright (c) 1980, 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. 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. -.\" -.\" @(#)timed.8 8.1 (Berkeley) 6/6/93 -.\" -.Dd February 11, 2008 -.Dt TIMED 8 -.Os -.Sh NAME -.Nm timed -.Nd time server daemon -.Sh SYNOPSIS -.Nm -.Op Fl dtM -.Op Fl i Ar network | Fl n Ar network -.Op Fl F Ar host ... -.Sh DESCRIPTION -The -.Nm -utility is a time server daemon -which is normally invoked at boot time from the -.Xr rc.conf 5 -file. -It synchronizes the host's time with the time of other -machines, which are also running -.Nm , -in a local area network. -These time servers will slow down the clocks of some machines -and speed up the clocks of others to bring them to the average network time. -The average network time is computed from measurements of clock differences -using the -.Tn ICMP -timestamp request message. -.Pp -The following options are available: -.Bl -tag -width indent -.It Fl d -Enable debugging mode; -do not detach from the terminal. -.It Fl i Ar network -Add -.Ar network -to the list of networks to ignore. -All other networks -to which the machine is directly connected -are used by -.Nm . -This option may be specified multiple times -to add more than one network to the list. -.It Fl F Ar host ... -.Bl -dash -compact -.It -Create a list of trusted hosts. -.It -Can take one or more parameters. -.It -.Nm -will only accept trusted hosts as masters. -If it finds an untrusted host claiming to be master, -.Nm -will suppress incoming messages from that host -and call for a new election. -.It -Use real host names (resolvable by RDNS) not aliases (eg in -.Xr named 8 -parlance: use A names, not C names). -.It -Use full names eg time1.domain.com not time1. -.It -.Fl F -automatically includes the functionality of -.Fl M -(so -.Fl M -does not need to asserted). -.It -If -.Fl F -is not specified, -all hosts on connected networks are treated as trustworthy. -.El -.It Fl M -Allow this host to become a -.Nm -master if necessary. -.It Fl n Ar network -Add -.Ar network -to the list of allowed networks. -All other networks -to which the machine is directly connected -are ignored by -.Nm . -This option may be specified multiple times -to add more than one network to the list. -.It Fl t -Enable tracing of received messages -and log to the file -.Pa /var/log/timed.log . -Tracing can be turned on or off while -.Nm -is running with the -.Xr timedc 8 -utility. -.El -.Pp -The -.Fl n -and -.Fl i -flags are mutually exclusive -and require as arguments real networks to which -the host is connected -(see -.Xr networks 5 ) . -If neither flag is specified, -.Nm -will listen on all connected networks. -.Pp -A -.Nm -running without the -.Fl M -nor -.Fl F -flags will always remain a slave. -If the -.Fl F -flag is not used, -.Nm -will treat all machines as trustworthy. -.Pp -The -.Nm -utility is based on a master-slave -scheme. -When -.Nm -is started on a machine, it asks the master for the network time -and sets the host's clock to that time. -After that, it accepts synchronization messages periodically sent by -the master and calls -.Xr adjtime 2 -to perform the needed corrections on the host's clock. -.Pp -It also communicates with -.Xr date 1 -in order to set the date globally, -and with -.Xr timedc 8 , -a -.Nm -control utility. -If the machine running the master becomes unreachable, -the slaves will elect a new master -from among those slaves -which are running with at least one of the -.Fl M -and -.Fl F -flags. -.Pp -At startup -.Nm -normally checks for a master time server on each network to which -it is connected, except as modified by the -.Fl n -and -.Fl i -options described above. -It will request synchronization service from the first master server -located. -If permitted by the -.Fl M -or -.Fl F -flags, it will provide synchronization service on any attached networks -on which no trusted master server was detected. -Such a server propagates the time computed by the top-level master. -The -.Nm -utility will periodically check for the presence of a master -on those networks for which it is operating as a slave. -If it finds that there are no trusted masters on a network, -it will begin the election process on that network. -.Pp -One way to synchronize a group of machines is to use -.Xr ntpd 8 -to -synchronize the clock of one machine to a distant standard or a radio -receiver and -.Fl F Ar hostname -to tell its -.Nm -to trust only itself. -.Pp -Messages printed by the kernel on the system console occur with -interrupts disabled. -This means that the clock stops while they are printing. -A machine with many disk or network hardware problems and consequent -messages cannot keep good time by itself. -Each message typically causes -the clock to lose a dozen milliseconds. -A time daemon can correct the result. -.Pp -Messages in the system log about machines that failed to respond -usually indicate machines that crashed or were turned off. -Complaints about machines that failed to respond to initial time -settings are often associated with -.Dq multi-homed -machines that looked for time masters on more than one network and eventually -chose to become a slave on the other network. -.Sh WARNINGS -Temporal chaos will result if two or more time daemons attempt -to adjust the same clock. -If both -.Nm -and another time daemon are run on the same machine, -ensure that the -.Fl F -flag is used, so that -.Nm -never attempts to adjust the local clock. -.Pp -The protocol is based on -.Tn UDP/IP -broadcasts. -All machines within the range of a broadcast that are using the -.Tn TSP -protocol must cooperate. -There cannot be more than a single administrative domain using the -.Fl F -flag among all machines reached by a broadcast packet. -Failure to follow this rule is usually indicated by complaints concerning -.Dq untrusted -machines in the system log. -.Sh FILES -.Bl -tag -width /var/log/timed.masterlog -compact -.It Pa /var/log/timed.log -tracing file for -.Nm -.It Pa /var/log/timed.masterlog -log file for master -.Nm -.El -.Sh SEE ALSO -.Xr date 1 , -.Xr adjtime 2 , -.Xr gettimeofday 2 , -.Xr icmp 4 , -.Xr networks 5 , -.Xr ntpd 8 , -.Xr timedc 8 -.Rs -.%T "TSP: The Time Synchronization Protocol for UNIX 4.3BSD" -.%A R. Gusella -.%A S. Zatti -.Re -.Sh HISTORY -The -.Nm -utility appeared in -.Bx 4.3 . -.Pp -The latest -.Nm -code has been made available as a port (net/timed) in preparation of removal -from base in -.Fx 13.0 . diff --git a/usr.sbin/timed/timed/timed.c b/usr.sbin/timed/timed/timed.c deleted file mode 100644 index eece1fedf54..00000000000 --- a/usr.sbin/timed/timed/timed.c +++ /dev/null @@ -1,834 +0,0 @@ -/*- - * SPDX-License-Identifier: BSD-3-Clause - * - * Copyright (c) 1985, 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. 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) 1985, 1993\n\ - The Regents of the University of California. All rights reserved.\n"; -#endif /* not lint */ - -#if 0 -#ifndef lint -static char sccsid[] = "@(#)timed.c 8.1 (Berkeley) 6/6/93"; -#endif /* not lint */ -#endif - -#include - -#include "globals.h" -#include -#include -#include -#include -#include "pathnames.h" -#include -#include -#include - -int trace = 0; -int sock, sock_raw = -1; -int status = 0; -u_short sequence; /* sequence number */ -long delay1; -long delay2; - -int nslavenets; /* nets were I could be a slave */ -int nmasternets; /* nets were I could be a master */ -int nignorednets; /* ignored nets */ -int nnets; /* nets I am connected to */ - -FILE *fd; /* trace file FD */ - -jmp_buf jmpenv; - -struct netinfo *nettab = NULL; -struct netinfo *slavenet; -int Mflag; -int justquit = 0; -int debug; - -static struct nets { - char *name; - long net; - struct nets *next; -} *nets = NULL; - -struct hosttbl hosttbl[NHOSTS+1]; /* known hosts */ - -static struct goodhost { /* hosts that we trust */ - char name[MAXHOSTNAMELEN]; - struct goodhost *next; - char perm; -} *goodhosts; - -static char *goodgroup; /* net group of trusted hosts */ -static void checkignorednets(void); -static void pickslavenet(struct netinfo *); -static void add_good_host(char *, int); -static void usage(void); - -/* - * The timedaemons synchronize the clocks of hosts in a local area network. - * One daemon runs as master, all the others as slaves. The master - * performs the task of computing clock differences and sends correction - * values to the slaves. - * Slaves start an election to choose a new master when the latter disappears - * because of a machine crash, network partition, or when killed. - * A resolution protocol is used to kill all but one of the masters - * that happen to exist in segments of a partitioned network when the - * network partition is fixed. - * - * Authors: Riccardo Gusella & Stefano Zatti - * - * overhauled at Silicon Graphics - */ -int -main(int argc, char *argv[]) -{ - int on; - int ret; - int nflag, iflag; - struct timeval ntime; - struct servent *srvp; - char buf[BUFSIZ], *cp, *cplim; - struct ifconf ifc; - struct ifreq ifreq, ifreqf, *ifr; - register struct netinfo *ntp; - struct netinfo *ntip; - struct netinfo *savefromnet; - struct netent *nentp; - struct nets *nt; - struct sockaddr_in server; - u_short port; - int c; - -#ifdef lint - ntip = NULL; -#endif - - on = 1; - nflag = OFF; - iflag = OFF; - - - opterr = 0; - while ((c = getopt(argc, argv, "Mtdn:i:F:G:P:")) != -1) { - switch (c) { - case 'M': - Mflag = 1; - break; - - case 't': - trace = 1; - break; - - case 'n': - if (iflag) { - errx(1, "-i and -n make no sense together"); - } else { - nflag = ON; - addnetname(optarg); - } - break; - - case 'i': - if (nflag) { - errx(1, "-i and -n make no sense together"); - } else { - iflag = ON; - addnetname(optarg); - } - break; - - case 'F': - add_good_host(optarg,1); - while (optind < argc && argv[optind][0] != '-') - add_good_host(argv[optind++], 1); - break; - - case 'd': - debug = 1; - break; - case 'G': - if (goodgroup != NULL) - errx(1, "only one net group"); - goodgroup = optarg; - break; - - default: - usage(); - break; - } - } - if (optind < argc) - usage(); - - fprintf(stderr, "TIMED will be removed from FreeBSD-13, and will be " - "provided as a port (net/timed) or package (timed).\n"); - - /* If we care about which machine is the master, then we must - * be willing to be a master - */ - if (goodgroup != NULL || goodhosts != NULL) - Mflag = 1; - - if (gethostname(hostname, sizeof(hostname) - 1) < 0) - err(1, "gethostname"); - self.l_bak = &self; - self.l_fwd = &self; - self.h_bak = &self; - self.h_fwd = &self; - self.head = 1; - self.good = 1; - - if (goodhosts != NULL) /* trust ourself */ - add_good_host(hostname,1); - - srvp = getservbyname("timed", "udp"); - if (srvp == NULL) - errx(1, "timed/udp: unknown service"); - port = srvp->s_port; - bzero(&server, sizeof(struct sockaddr_in)); - server.sin_port = srvp->s_port; - server.sin_family = AF_INET; - sock = socket(AF_INET, SOCK_DGRAM, 0); - if (sock < 0) - err(1, "socket"); - if (setsockopt(sock, SOL_SOCKET, SO_BROADCAST, (char *)&on, - sizeof(on)) < 0) - err(1, "setsockopt"); - if (bind(sock, (struct sockaddr*)&server, sizeof(server))) { - if (errno == EADDRINUSE) - warnx("time daemon already running"); - else - warn("bind"); - exit(1); - } - - sequence = arc4random(); /* initial seq number */ - - (void)gettimeofday(&ntime, NULL); - /* rounds kernel variable time to multiple of 5 ms. */ - ntime.tv_sec = 0; - ntime.tv_usec = -((ntime.tv_usec/1000) % 5) * 1000; - (void)adjtime(&ntime, (struct timeval *)0); - - for (nt = nets; nt; nt = nt->next) { - nentp = getnetbyname(nt->name); - if (nentp == NULL) { - nt->net = inet_network(nt->name); - if (nt->net != INADDR_NONE) - nentp = getnetbyaddr(nt->net, AF_INET); - } - if (nentp != NULL) { - nt->net = nentp->n_net; - } else if (nt->net == INADDR_NONE) { - errx(1, "unknown net %s", nt->name); - } else if (nt->net == INADDR_ANY) { - errx(1, "bad net %s", nt->name); - } else { - warnx("warning: %s unknown in /etc/networks", - nt->name); - } - - if (0 == (nt->net & 0xff000000)) - nt->net <<= 8; - if (0 == (nt->net & 0xff000000)) - nt->net <<= 8; - if (0 == (nt->net & 0xff000000)) - nt->net <<= 8; - } - ifc.ifc_len = sizeof(buf); - ifc.ifc_buf = buf; - if (ioctl(sock, SIOCGIFCONF, (char *)&ifc) < 0) - err(1, "get interface configuration"); - ntp = NULL; -#define size(p) max((p).sa_len, sizeof(p)) - cplim = buf + ifc.ifc_len; /*skip over if's with big ifr_addr's */ - for (cp = buf; cp < cplim; - cp += sizeof (ifr->ifr_name) + size(ifr->ifr_addr)) { - ifr = (struct ifreq *)cp; - if (ifr->ifr_addr.sa_family != AF_INET) - continue; - if (!ntp) - ntp = (struct netinfo*)malloc(sizeof(struct netinfo)); - bzero(ntp,sizeof(*ntp)); - ntp->my_addr=((struct sockaddr_in *)&ifr->ifr_addr)->sin_addr; - ntp->status = NOMASTER; - ifreq = *ifr; - ifreqf = *ifr; - - if (ioctl(sock, SIOCGIFFLAGS, (char *)&ifreqf) < 0) { - warn("get interface flags"); - continue; - } - if ((ifreqf.ifr_flags & IFF_UP) == 0) - continue; - if ((ifreqf.ifr_flags & IFF_BROADCAST) == 0 && - (ifreqf.ifr_flags & IFF_POINTOPOINT) == 0) { - continue; - } - - - if (ioctl(sock, SIOCGIFNETMASK, (char *)&ifreq) < 0) { - warn("get netmask"); - continue; - } - ntp->mask = ((struct sockaddr_in *) - &ifreq.ifr_addr)->sin_addr.s_addr; - - if (ifreqf.ifr_flags & IFF_BROADCAST) { - if (ioctl(sock, SIOCGIFBRDADDR, (char *)&ifreq) < 0) { - warn("get broadaddr"); - continue; - } - ntp->dest_addr = *(struct sockaddr_in *)&ifreq.ifr_broadaddr; - /* What if the broadcast address is all ones? - * So we cannot just mask ntp->dest_addr. */ - ntp->net = ntp->my_addr; - ntp->net.s_addr &= ntp->mask; - } else { - if (ioctl(sock, SIOCGIFDSTADDR, - (char *)&ifreq) < 0) { - warn("get destaddr"); - continue; - } - ntp->dest_addr = *(struct sockaddr_in *)&ifreq.ifr_dstaddr; - ntp->net = ntp->dest_addr.sin_addr; - } - - ntp->dest_addr.sin_port = port; - - for (nt = nets; nt; nt = nt->next) { - if (ntp->net.s_addr == htonl(nt->net)) - break; - } - if ((nflag && !nt) || (iflag && nt)) - continue; - - ntp->next = NULL; - if (nettab == NULL) { - nettab = ntp; - } else { - ntip->next = ntp; - } - ntip = ntp; - ntp = NULL; - } - if (ntp) - (void) free((char *)ntp); - if (nettab == NULL) - errx(1, "no network usable"); - - /* microseconds to delay before responding to a broadcast */ - delay1 = casual(1, 100*1000); - - /* election timer delay in secs. */ - delay2 = casual(MINTOUT, MAXTOUT); - - if (!debug) - daemon(debug, 0); - - if (trace) - traceon(); - openlog("timed", LOG_CONS|LOG_PID, LOG_DAEMON); - - /* - * keep returning here - */ - ret = setjmp(jmpenv); - savefromnet = fromnet; - setstatus(); - - if (Mflag) { - switch (ret) { - - case 0: - checkignorednets(); - pickslavenet(0); - break; - case 1: - /* Just lost our master */ - if (slavenet != NULL) - slavenet->status = election(slavenet); - if (!slavenet || slavenet->status == MASTER) { - checkignorednets(); - pickslavenet(0); - } else { - makeslave(slavenet); /* prune extras */ - } - break; - - case 2: - /* Just been told to quit */ - justquit = 1; - pickslavenet(savefromnet); - break; - } - - setstatus(); - if (!(status & MASTER) && sock_raw != -1) { - /* sock_raw is not being used now */ - (void)close(sock_raw); - sock_raw = -1; - } - - if (status == MASTER) - master(); - else - slave(); - - } else { - if (sock_raw != -1) { - (void)close(sock_raw); - sock_raw = -1; - } - - if (ret) { - /* we just lost our master or were told to quit */ - justquit = 1; - } - for (ntp = nettab; ntp != NULL; ntp = ntp->next) { - if (ntp->status == MASTER) { - rmnetmachs(ntp); - ntp->status = NOMASTER; - } - } - checkignorednets(); - pickslavenet(0); - setstatus(); - - slave(); - } - /* NOTREACHED */ - return(0); -} - -static void -usage(void) -{ -#ifdef HAVENIS - fprintf(stderr, -"usage: timed [-dtM] [-i net|-n net] [-F host1 host2 ...] [-G netgp]\n"); -#else - fprintf(stderr, -"usage: timed [-dtM] [-i net|-n net] [-F host1 host2 ...]\n"); -#endif /* HAVENIS */ - exit(1); -} - -/* - * suppress an upstart, untrustworthy, self-appointed master - */ -void -suppress(struct sockaddr_in *addr, char *name, struct netinfo *net) -{ - struct sockaddr_in tgt; - char tname[MAXHOSTNAMELEN]; - struct tsp msg; - static struct timeval wait; - - if (trace) - fprintf(fd, "suppress: %s\n", name); - tgt = *addr; - (void)strlcpy(tname, name, sizeof(tname)); - - while (0 != readmsg(TSP_ANY, ANYADDR, &wait, net)) { - if (trace) - fprintf(fd, "suppress:\tdiscarded packet from %s\n", - name); - } - - syslog(LOG_NOTICE, "suppressing false master %s", tname); - msg.tsp_type = TSP_QUIT; - (void)strcpy(msg.tsp_name, hostname); - (void)acksend(&msg, &tgt, tname, TSP_ACK, 0, 1); -} - -void -lookformaster(struct netinfo *ntp) -{ - struct tsp resp, conflict, *answer; - struct timeval ntime; - char mastername[MAXHOSTNAMELEN]; - struct sockaddr_in masteraddr; - - get_goodgroup(0); - ntp->status = SLAVE; - - /* look for master */ - resp.tsp_type = TSP_MASTERREQ; - (void)strcpy(resp.tsp_name, hostname); - answer = acksend(&resp, &ntp->dest_addr, ANYADDR, - TSP_MASTERACK, ntp, 0); - if (answer != NULL && !good_host_name(answer->tsp_name)) { - suppress(&from, answer->tsp_name, ntp); - ntp->status = NOMASTER; - answer = NULL; - } - if (answer == NULL) { - /* - * Various conditions can cause conflict: races between - * two just started timedaemons when no master is - * present, or timedaemons started during an election. - * A conservative approach is taken. Give up and became a - * slave, postponing election of a master until first - * timer expires. - */ - ntime.tv_sec = ntime.tv_usec = 0; - answer = readmsg(TSP_MASTERREQ, ANYADDR, &ntime, ntp); - if (answer != NULL) { - if (!good_host_name(answer->tsp_name)) { - suppress(&from, answer->tsp_name, ntp); - ntp->status = NOMASTER; - } - return; - } - - ntime.tv_sec = ntime.tv_usec = 0; - answer = readmsg(TSP_MASTERUP, ANYADDR, &ntime, ntp); - if (answer != NULL) { - if (!good_host_name(answer->tsp_name)) { - suppress(&from, answer->tsp_name, ntp); - ntp->status = NOMASTER; - } - return; - } - - ntime.tv_sec = ntime.tv_usec = 0; - answer = readmsg(TSP_ELECTION, ANYADDR, &ntime, ntp); - if (answer != NULL) { - if (!good_host_name(answer->tsp_name)) { - suppress(&from, answer->tsp_name, ntp); - ntp->status = NOMASTER; - } - return; - } - - if (Mflag) - ntp->status = MASTER; - else - ntp->status = NOMASTER; - return; - } - - ntp->status = SLAVE; - (void)strcpy(mastername, answer->tsp_name); - masteraddr = from; - - /* - * If network has been partitioned, there might be other - * masters; tell the one we have just acknowledged that - * it has to gain control over the others. - */ - ntime.tv_sec = 0; - ntime.tv_usec = 300000; - answer = readmsg(TSP_MASTERACK, ANYADDR, &ntime, ntp); - /* - * checking also not to send CONFLICT to ack'ed master - * due to duplicated MASTERACKs - */ - if (answer != NULL && - strcmp(answer->tsp_name, mastername) != 0) { - conflict.tsp_type = TSP_CONFLICT; - (void)strcpy(conflict.tsp_name, hostname); - if (!acksend(&conflict, &masteraddr, mastername, - TSP_ACK, 0, 0)) { - syslog(LOG_ERR, - "error on sending TSP_CONFLICT"); - } - } -} - -/* - * based on the current network configuration, set the status, and count - * networks; - */ -void -setstatus(void) -{ - struct netinfo *ntp; - - status = 0; - nmasternets = nslavenets = nnets = nignorednets = 0; - if (trace) - fprintf(fd, "Net status:\n"); - for (ntp = nettab; ntp != NULL; ntp = ntp->next) { - switch ((int)ntp->status) { - case MASTER: - nmasternets++; - break; - case SLAVE: - nslavenets++; - break; - case NOMASTER: - case IGNORE: - nignorednets++; - break; - } - if (trace) { - fprintf(fd, "\t%-16s", inet_ntoa(ntp->net)); - switch ((int)ntp->status) { - case NOMASTER: - fprintf(fd, "NOMASTER\n"); - break; - case MASTER: - fprintf(fd, "MASTER\n"); - break; - case SLAVE: - fprintf(fd, "SLAVE\n"); - break; - case IGNORE: - fprintf(fd, "IGNORE\n"); - break; - default: - fprintf(fd, "invalid state %d\n", - (int)ntp->status); - break; - } - } - nnets++; - status |= ntp->status; - } - status &= ~IGNORE; - if (trace) - fprintf(fd, - "\tnets=%d masters=%d slaves=%d ignored=%d delay2=%ld\n", - nnets, nmasternets, nslavenets, nignorednets, delay2); -} - -void -makeslave(struct netinfo *net) -{ - register struct netinfo *ntp; - - for (ntp = nettab; ntp != NULL; ntp = ntp->next) { - if (ntp->status == SLAVE && ntp != net) - ntp->status = IGNORE; - } - slavenet = net; -} - -/* - * Try to become master over ignored nets.. - */ -static void -checkignorednets(void) -{ - register struct netinfo *ntp; - - for (ntp = nettab; ntp != NULL; ntp = ntp->next) { - if (!Mflag && ntp->status == SLAVE) - break; - - if (ntp->status == IGNORE || ntp->status == NOMASTER) { - lookformaster(ntp); - if (!Mflag && ntp->status == SLAVE) - break; - } - } -} - -/* - * choose a good network on which to be a slave - * The ignored networks must have already been checked. - * Take a hint about for a good network. - */ -static void -pickslavenet(struct netinfo *ntp) -{ - if (slavenet != NULL && slavenet->status == SLAVE) { - makeslave(slavenet); /* prune extras */ - return; - } - - if (ntp == NULL || ntp->status != SLAVE) { - for (ntp = nettab; ntp != NULL; ntp = ntp->next) { - if (ntp->status == SLAVE) - break; - } - } - makeslave(ntp); -} - -/* - * returns a random number in the range [inf, sup] - */ -long -casual(long inf, long sup) -{ - double value; - - value = ((double)(random() & 0x7fffffff)) / (0x7fffffff*1.0); - return(inf + (sup - inf)*value); -} - -char * -date(void) -{ - time_t tv_sec; - - tv_sec = time(NULL); - return (ctime(&tv_sec)); -} - -void -addnetname(char *name) -{ - register struct nets **netlist = &nets; - - while (*netlist) - netlist = &((*netlist)->next); - *netlist = (struct nets *)malloc(sizeof **netlist); - if (*netlist == NULL) - errx(1, "malloc failed"); - bzero((char *)*netlist, sizeof(**netlist)); - (*netlist)->name = name; -} - -/* note a host as trustworthy - * perm 1=not part of the netgroup - */ -static void -add_good_host(char *name, int perm) -{ - register struct goodhost *ghp; - register struct hostent *hentp; - - ghp = (struct goodhost*)malloc(sizeof(*ghp)); - if (!ghp) { - syslog(LOG_ERR, "malloc failed"); - exit(1); - } - - bzero((char*)ghp, sizeof(*ghp)); - (void)strncpy(&ghp->name[0], name, sizeof(ghp->name)); - ghp->next = goodhosts; - ghp->perm = perm; - goodhosts = ghp; - - hentp = gethostbyname(name); - if (hentp == NULL && perm) - warnx("unknown host %s", name); -} - - -/* update our image of the net-group of trustworthy hosts - */ -void -get_goodgroup(int force) -{ -# define NG_DELAY (30*60*CLK_TCK) /* 30 minutes */ - static unsigned long last_update = -NG_DELAY; - unsigned long new_update; - struct goodhost *ghp, **ghpp; -#ifdef HAVENIS - struct hosttbl *htp; - char *mach, *usr, *dom; -#endif /* HAVENIS */ - struct tms tm; - - - /* if no netgroup, then we are finished */ - if (goodgroup == NULL || !Mflag) - return; - - /* Do not chatter with the netgroup master too often. - */ - new_update = times(&tm); - if (new_update < last_update + NG_DELAY - && !force) - return; - last_update = new_update; - - /* forget the old temporary entries */ - ghpp = &goodhosts; - while ((ghp = *ghpp) != NULL) { - if (!ghp->perm) { - *ghpp = ghp->next; - free(ghp); - } else { - ghpp = &ghp->next; - } - } - -#ifdef HAVENIS - /* quit now if we are not one of the trusted masters - */ - if (!innetgr(goodgroup, &hostname[0], 0,0)) { - if (trace) - (void)fprintf(fd, "get_goodgroup: %s not in %s\n", - &hostname[0], goodgroup); - return; - } - if (trace) - (void)fprintf(fd, "get_goodgroup: %s in %s\n", - &hostname[0], goodgroup); - - /* mark the entire netgroup as trusted */ - (void)setnetgrent(goodgroup); - while (getnetgrent(&mach,&usr,&dom)) { - if (mach != NULL) - add_good_host(mach,0); - } - (void)endnetgrent(); - - /* update list of slaves */ - for (htp = self.l_fwd; htp != &self; htp = htp->l_fwd) { - htp->good = good_host_name(&htp->name[0]); - } -#endif /* HAVENIS */ -} - - -/* see if a machine is trustworthy - */ -int /* 1=trust hp to change our date */ -good_host_name(char *name) -{ - register struct goodhost *ghp = goodhosts; - register char c; - - if (!ghp || !Mflag) /* trust everyone if no one named */ - return 1; - - c = *name; - do { - if (c == ghp->name[0] - && !strcasecmp(name, ghp->name)) - return 1; /* found him, so say so */ - } while ((ghp = ghp->next) != NULL); - - if (!strcasecmp(name,hostname)) /* trust ourself */ - return 1; - - return 0; /* did not find him */ -} diff --git a/usr.sbin/timed/timedc/Makefile b/usr.sbin/timed/timedc/Makefile deleted file mode 100644 index 25f056fd59a..00000000000 --- a/usr.sbin/timed/timedc/Makefile +++ /dev/null @@ -1,14 +0,0 @@ -# @(#)Makefile 8.1 (Berkeley) 6/6/93 - -.PATH: ${.CURDIR:H}/timed - -PROG= timedc -MAN= timedc.8 -SRCS= cmds.c cmdtab.c timedc.c byteorder.c measure.c cksum.c -BINOWN= root -BINMODE= 4555 - -WARNS?= 1 - -.include "../../Makefile.inc" -.include diff --git a/usr.sbin/timed/timedc/Makefile.depend b/usr.sbin/timed/timedc/Makefile.depend deleted file mode 100644 index c05a4a1cdd5..00000000000 --- a/usr.sbin/timed/timedc/Makefile.depend +++ /dev/null @@ -1,18 +0,0 @@ -# Autogenerated - do NOT edit! - -DIRDEPS = \ - gnu/lib/csu \ - include \ - include/arpa \ - include/protocols \ - include/xlocale \ - lib/${CSU_DIR} \ - lib/libc \ - lib/libcompiler_rt \ - - -.include - -.if ${DEP_RELDIR} == ${_DEP_RELDIR} -# local dependencies - needed for -jN in clean tree -.endif diff --git a/usr.sbin/timed/timedc/cmds.c b/usr.sbin/timed/timedc/cmds.c deleted file mode 100644 index 2b50ac93f9a..00000000000 --- a/usr.sbin/timed/timedc/cmds.c +++ /dev/null @@ -1,543 +0,0 @@ -/*- - * SPDX-License-Identifier: BSD-3-Clause - * - * Copyright (c) 1985, 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. 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. - */ - -#if 0 -#ifndef lint -static char sccsid[] = "@(#)cmds.c 8.1 (Berkeley) 6/6/93"; -#endif /* not lint */ -#endif -#include - -#include "timedc.h" -#include - -#include - -#include -#include -#include - -#include -#include -#include -#include - -#define TSPTYPES -#include - -#define SECHR (60*60) -#define SECDAY (24*SECHR) - -# define DATE_PROTO "udp" -# define DATE_PORT "time" - - -int sock; -int sock_raw; -char myname[MAXHOSTNAMELEN]; -struct hostent *hp; -struct sockaddr_in server; -struct sockaddr_in dayaddr; -extern int measure_delta; - -void bytenetorder(struct tsp *); -void bytehostorder(struct tsp *); - - -#define BU (2208988800UL) /* seconds before UNIX epoch */ - - -/* compute the difference between our date and another machine - */ -static int /* difference in days from our time */ -daydiff(char *hostname) -{ - int i; - int trials; - struct timeval tout, now; - fd_set ready; - struct sockaddr from; - int fromlen; - unsigned long sec; - - - /* wait 2 seconds between 10 tries */ - tout.tv_sec = 2; - tout.tv_usec = 0; - for (trials = 0; trials < 10; trials++) { - /* ask for the time */ - sec = 0; - if (sendto(sock, &sec, sizeof(sec), 0, - (struct sockaddr*)&dayaddr, sizeof(dayaddr)) < 0) { - warn("sendto(sock)"); - return 0; - } - - for (;;) { - FD_ZERO(&ready); - FD_SET(sock, &ready); - i = select(sock+1, &ready, (fd_set *)0, - (fd_set *)0, &tout); - if (i < 0) { - if (errno == EINTR) - continue; - warn("select(date read)"); - return 0; - } - if (0 == i) - break; - - fromlen = sizeof(from); - if (recvfrom(sock,&sec,sizeof(sec),0, - &from,&fromlen) < 0) { - warn("recvfrom(date read)"); - return 0; - } - - sec = ntohl(sec); - if (sec < BU) { - warnx("%s says it is before 1970: %lu", - hostname, sec); - return 0; - } - sec -= BU; - - (void)gettimeofday(&now, NULL); - return (sec - now.tv_sec); - } - } - - /* if we get here, we tried too many times */ - warnx("%s will not tell us the date", hostname); - return 0; -} - - -/* - * Clockdiff computes the difference between the time of the machine on - * which it is called and the time of the machines given as argument. - * The time differences measured by clockdiff are obtained using a sequence - * of ICMP TSTAMP messages which are returned to the sender by the IP module - * in the remote machine. - * In order to compare clocks of machines in different time zones, the time - * is transmitted (as a 32-bit value) in milliseconds since midnight UT. - * If a hosts uses a different time format, it should set the high order - * bit of the 32-bit quantity it transmits. - * However, VMS apparently transmits the time in milliseconds since midnight - * local time (rather than GMT) without setting the high order bit. - * Furthermore, it does not understand daylight-saving time. This makes - * clockdiff behaving inconsistently with hosts running VMS. - * - * In order to reduce the sensitivity to the variance of message transmission - * time, clockdiff sends a sequence of messages. Yet, measures between - * two `distant' hosts can be affected by a small error. The error can, - * however, be reduced by increasing the number of messages sent in each - * measurement. - */ -void -clockdiff(int argc, char *argv[]) -{ - int measure_status; - extern int measure(u_long, u_long, char *, struct sockaddr_in*, int); - register int avg_cnt; - register long avg; - struct servent *sp; - - if (argc < 2) { - printf("usage: timedc clockdiff host ...\n"); - return; - } - - if (gethostname(myname, sizeof(myname) - 1) < 0) - err(1, "gethostname"); - - /* get the address for the date ready */ - sp = getservbyname(DATE_PORT, DATE_PROTO); - if (!sp) { - warnx("%s/%s: unknown service", DATE_PORT, DATE_PROTO); - dayaddr.sin_port = 0; - } else { - dayaddr.sin_port = sp->s_port; - } - - while (argc > 1) { - argc--; argv++; - hp = gethostbyname(*argv); - if (hp == NULL) { - warnx("%s: %s", *argv, hstrerror(h_errno)); - continue; - } - - server.sin_family = hp->h_addrtype; - bcopy(hp->h_addr, &server.sin_addr.s_addr, hp->h_length); - for (avg_cnt = 0, avg = 0; avg_cnt < 16; avg_cnt++) { - measure_status = measure(10000,100, *argv, &server, 1); - if (measure_status != GOOD) - break; - avg += measure_delta; - } - if (measure_status == GOOD) - measure_delta = avg/avg_cnt; - - switch (measure_status) { - case HOSTDOWN: - printf("%s is down\n", hp->h_name); - continue; - case NONSTDTIME: - printf("%s transmits a non-standard time format\n", - hp->h_name); - continue; - case UNREACHABLE: - printf("%s is unreachable\n", hp->h_name); - continue; - } - - /* - * Try to get the date only after using ICMP timestamps to - * get the time. This is because the date protocol - * is optional. - */ - if (dayaddr.sin_port != 0) { - dayaddr.sin_family = hp->h_addrtype; - bcopy(hp->h_addr, &dayaddr.sin_addr.s_addr, - hp->h_length); - avg = daydiff(*argv); - if (avg > SECDAY) { - printf("time on %s is %ld days ahead %s\n", - hp->h_name, avg/SECDAY, myname); - continue; - } else if (avg < -SECDAY) { - printf("time on %s is %ld days behind %s\n", - hp->h_name, -avg/SECDAY, myname); - continue; - } - } - - if (measure_delta > 0) { - printf("time on %s is %d ms. ahead of time on %s\n", - hp->h_name, measure_delta, myname); - } else if (measure_delta == 0) { - printf("%s and %s have the same time\n", - hp->h_name, myname); - } else { - printf("time on %s is %d ms. behind time on %s\n", - hp->h_name, -measure_delta, myname); - } - } - return; -} - - -/* - * finds location of master timedaemon - */ -void -msite(int argc, char *argv[]) -{ - ssize_t cc; - fd_set ready; - struct sockaddr_in dest; - int i, length; - struct sockaddr_in from; - struct timeval tout; - struct tsp msg; - struct servent *srvp; - char *tgtname; - - if (argc < 1) { - printf("usage: timedc msite [host ...]\n"); - return; - } - - srvp = getservbyname("timed", "udp"); - if (srvp == NULL) { - warnx("timed/udp: unknown service"); - return; - } - dest.sin_port = srvp->s_port; - dest.sin_family = AF_INET; - - if (gethostname(myname, sizeof(myname) - 1) < 0) - err(1, "gethostname"); - i = 1; - do { - tgtname = (i >= argc) ? myname : argv[i]; - hp = gethostbyname(tgtname); - if (hp == NULL) { - warnx("%s: %s", tgtname, hstrerror(h_errno)); - continue; - } - bcopy(hp->h_addr, &dest.sin_addr.s_addr, hp->h_length); - - (void)strlcpy(msg.tsp_name, myname, sizeof(msg.tsp_name)); - msg.tsp_type = TSP_MSITE; - msg.tsp_vers = TSPVERSION; - bytenetorder(&msg); - if (sendto(sock, &msg, sizeof(struct tsp), 0, - (struct sockaddr*)&dest, - sizeof(struct sockaddr)) < 0) { - warn("sendto"); - continue; - } - - tout.tv_sec = 15; - tout.tv_usec = 0; - FD_ZERO(&ready); - FD_SET(sock, &ready); - if (select(FD_SETSIZE, &ready, (fd_set *)0, (fd_set *)0, - &tout)) { - length = sizeof(from); - cc = recvfrom(sock, &msg, sizeof(struct tsp), 0, - (struct sockaddr *)&from, &length); - if (cc < 0) { - warn("recvfrom"); - continue; - } - /* - * The 4.3BSD protocol spec had a 32-byte tsp_name field, and - * this is still OS-dependent. Demand that the packet is at - * least long enough to hold a 4.3BSD packet. - */ - if (cc < (sizeof(struct tsp) - MAXHOSTNAMELEN + 32)) { - fprintf(stderr, - "short packet (%zd/%zu bytes) from %s\n", - cc, sizeof(struct tsp) - MAXHOSTNAMELEN + 32, - inet_ntoa(from.sin_addr)); - continue; - } - bytehostorder(&msg); - if (msg.tsp_type == TSP_ACK) { - printf("master timedaemon at %s is %s\n", - tgtname, msg.tsp_name); - } else { - if (msg.tsp_type >= TSPTYPENUMBER) - printf("unknown ack received: %u\n", - msg.tsp_type); - else - printf("wrong ack received: %s\n", - tsptype[msg.tsp_type]); - } - } else { - printf("communication error with %s\n", tgtname); - } - } while (++i < argc); -} - -/* - * quits timedc - */ -void -quit(void) -{ - exit(0); -} - - -/* - * Causes the election timer to expire on the selected hosts - * It sends just one udp message per machine, relying on - * reliability of communication channel. - */ -void -testing(int argc, char *argv[]) -{ - struct servent *srvp; - struct sockaddr_in sin; - struct tsp msg; - - if (argc < 2) { - printf("usage: timedc election host1 [host2 ...]\n"); - return; - } - - srvp = getservbyname("timed", "udp"); - if (srvp == NULL) { - warnx("timed/udp: unknown service"); - return; - } - - while (argc > 1) { - argc--; argv++; - hp = gethostbyname(*argv); - if (hp == NULL) { - warnx("%s: %s", *argv, hstrerror(h_errno)); - argc--; argv++; - continue; - } - sin.sin_port = srvp->s_port; - sin.sin_family = hp->h_addrtype; - bcopy(hp->h_addr, &sin.sin_addr.s_addr, hp->h_length); - - msg.tsp_type = TSP_TEST; - msg.tsp_vers = TSPVERSION; - if (gethostname(myname, sizeof(myname) - 1) < 0) - err(1, "gethostname"); - (void)strlcpy(msg.tsp_name, myname, sizeof(msg.tsp_name)); - bytenetorder(&msg); - if (sendto(sock, &msg, sizeof(struct tsp), 0, - (struct sockaddr*)&sin, - sizeof(struct sockaddr)) < 0) { - warn("sendto"); - } - } -} - - -/* - * Enables or disables tracing on local timedaemon - */ -void -tracing(int argc, char *argv[]) -{ - int onflag; - int length; - ssize_t cc; - fd_set ready; - struct sockaddr_in dest; - struct sockaddr_in from; - struct timeval tout; - struct tsp msg; - struct servent *srvp; - - if (argc != 2) { - printf("usage: timedc trace { on | off }\n"); - return; - } - - srvp = getservbyname("timed", "udp"); - if (srvp == NULL) { - warnx("timed/udp: unknown service"); - return; - } - dest.sin_port = srvp->s_port; - dest.sin_family = AF_INET; - - if (gethostname(myname, sizeof(myname) - 1) < 0) - err(1, "gethostname"); - hp = gethostbyname(myname); - bcopy(hp->h_addr, &dest.sin_addr.s_addr, hp->h_length); - - if (strcmp(argv[1], "on") == 0) { - msg.tsp_type = TSP_TRACEON; - onflag = ON; - } else { - msg.tsp_type = TSP_TRACEOFF; - onflag = OFF; - } - - (void)strcpy(msg.tsp_name, myname); - msg.tsp_vers = TSPVERSION; - bytenetorder(&msg); - if (sendto(sock, &msg, sizeof(struct tsp), 0, - (struct sockaddr*)&dest, sizeof(struct sockaddr)) < 0) { - warn("sendto"); - return; - } - - tout.tv_sec = 5; - tout.tv_usec = 0; - FD_ZERO(&ready); - FD_SET(sock, &ready); - if (select(FD_SETSIZE, &ready, (fd_set *)0, (fd_set *)0, &tout)) { - length = sizeof(from); - cc = recvfrom(sock, &msg, sizeof(struct tsp), 0, - (struct sockaddr *)&from, &length); - if (cc < 0) { - warn("recvfrom"); - return; - } - /* - * The 4.3BSD protocol spec had a 32-byte tsp_name field, and - * this is still OS-dependent. Demand that the packet is at - * least long enough to hold a 4.3BSD packet. - */ - if (cc < (sizeof(struct tsp) - MAXHOSTNAMELEN + 32)) { - fprintf(stderr, "short packet (%zd/%zu bytes) from %s\n", - cc, sizeof(struct tsp) - MAXHOSTNAMELEN + 32, - inet_ntoa(from.sin_addr)); - return; - } - bytehostorder(&msg); - if (msg.tsp_type == TSP_ACK) - if (onflag) - printf("timed tracing enabled\n"); - else - printf("timed tracing disabled\n"); - else { - if (msg.tsp_type >= TSPTYPENUMBER) - printf("unknown ack received: %u\n", - msg.tsp_type); - else - printf("wrong ack received: %s\n", - tsptype[msg.tsp_type]); - } - } else - printf("communication error\n"); -} - -int -priv_resources(void) -{ - int port; - struct sockaddr_in sin; - - sock = socket(AF_INET, SOCK_DGRAM, 0); - if (sock < 0) { - warn("opening socket"); - return(-1); - } - - sin.sin_family = AF_INET; - sin.sin_addr.s_addr = 0; - for (port = IPPORT_RESERVED - 1; port > IPPORT_RESERVED / 2; port--) { - sin.sin_port = htons((u_short)port); - if (bind(sock, (struct sockaddr*)&sin, sizeof (sin)) >= 0) - break; - if (errno != EADDRINUSE && errno != EADDRNOTAVAIL) { - warn("bind"); - (void) close(sock); - return(-1); - } - } - if (port == IPPORT_RESERVED / 2) { - warnx("all reserved ports in use"); - (void) close(sock); - return(-1); - } - - sock_raw = socket(AF_INET, SOCK_RAW, IPPROTO_ICMP); - if (sock_raw < 0) { - warn("opening raw socket"); - (void) close(sock); - return(-1); - } - return(1); -} diff --git a/usr.sbin/timed/timedc/cmdtab.c b/usr.sbin/timed/timedc/cmdtab.c deleted file mode 100644 index 09a3349bff0..00000000000 --- a/usr.sbin/timed/timedc/cmdtab.c +++ /dev/null @@ -1,57 +0,0 @@ -/*- - * SPDX-License-Identifier: BSD-3-Clause - * - * Copyright (c) 1983, 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. 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 -#if 0 -static char sccsid[] = "@(#)cmdtab.c 8.1 (Berkeley) 6/6/93"; -#endif -#endif /* not lint */ - -#include "timedc.h" - -char clockdiffhelp[] = "measures clock differences between machines"; -char helphelp[] = "gets help on commands"; -char msitehelp[] = "finds location of master"; -char quithelp[] = "exits timedc"; -char testinghelp[] = "causes election timers to expire"; -char tracinghelp[] = "turns tracing on or off"; - -struct cmd cmdtab[] = { - { "clockdiff", clockdiffhelp, clockdiff, 0 }, - { "election", testinghelp, testing, 1 }, - { "help", helphelp, help, 0 }, - { "msite", msitehelp, msite, 0 }, - { "quit", quithelp, quit, 0 }, - { "trace", tracinghelp, tracing, 1 }, - { "?", helphelp, help, 0 }, -}; - -int NCMDS = sizeof (cmdtab) / sizeof (cmdtab[0]); diff --git a/usr.sbin/timed/timedc/extern.h b/usr.sbin/timed/timedc/extern.h deleted file mode 100644 index 29179fc4171..00000000000 --- a/usr.sbin/timed/timedc/extern.h +++ /dev/null @@ -1,51 +0,0 @@ - -/*- - * SPDX-License-Identifier: BSD-3-Clause - * - * 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. 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. - * - * @(#)extern.h 8.1 (Berkeley) 6/6/93 - */ - -#if __STDC__ -struct tsp; -#endif - -extern struct cmd cmdtab[]; - -void bytehostorder(struct tsp *); -void bytenetorder(struct tsp *); -void clockdiff(int, char *[]); -void help(int, char *[]); -void intr(int); -void makeargv(void); -void msite(int, char *[]); -int priv_resources(void); -void quit(void); -void testing(int, char *[]); -void tracing(int, char *[]); diff --git a/usr.sbin/timed/timedc/timedc.8 b/usr.sbin/timed/timedc/timedc.8 deleted file mode 100644 index 5e3a045e059..00000000000 --- a/usr.sbin/timed/timedc/timedc.8 +++ /dev/null @@ -1,146 +0,0 @@ -.\" Copyright (c) 1980, 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. 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. -.\" -.\" @(#)timedc.8 8.1 (Berkeley) 6/6/93 -.\" -.Dd June 6, 1993 -.Dt TIMEDC 8 -.Os -.Sh NAME -.Nm timedc -.Nd timed control program -.Sh SYNOPSIS -.Nm -.Op Ar command Op Ar argument ... -.Sh DESCRIPTION -The -.Nm -utility is used to control the operation of the -.Xr timed 8 -program. -It may be used to: -.Bl -bullet -.It -Measure the differences between machines' clocks, -.It -Find the location where the master time server is running, -.It -Enable or disable tracing of messages received by -.Xr timed 8 , -and -.It -Perform various debugging actions. -.El -.Pp -Without any arguments, -.Nm -will prompt for commands from the standard input. -If arguments are supplied, -.Nm -interprets the first argument as a command and the remaining -arguments as parameters to the command. -The standard input -may be redirected causing -.Nm -to read commands from a file. -Commands may be abbreviated; -recognized commands are: -.Pp -.Bl -tag -width Ds -compact -.It Ic \&? Op Ar command ... -.Pp -.It Ic help Op Ar command ... -Print a short description of each command specified in the argument list, -or, if no arguments are given, a list of the recognized commands. -.Pp -.It Ic clockdiff Ar host ... -Compute the differences between the clock of the host machine -and the clocks of the machines given as arguments. -.Pp -.It Ic msite Op Ar host ... -Show the master time server for specified host(s). -.Pp -.It Xo -.Ic trace -.Li \&{ Ar on Li \&| -.Ar off \&} -.Xc -Enable or disable the tracing of incoming messages to -.Xr timed 8 -in the file -.Pa /var/log/timed.log . -.Pp -.It Ic election Ar host1 Op Ar host2 ... -Asks the daemon -on the target host to reset its "election" timers and to ensure that -a time master has been elected. -.Pp -.It Ic quit -Exit from timedc. -.El -.Pp -Other commands may be included for use in testing and debugging -.Xr timed 8 ; -the help command and -the program source may be consulted for details. -.Sh FILES -.Bl -tag -width /var/log/timed.masterlog -compact -.It Pa /var/log/timed.log -tracing file for timed -.It Pa /var/log/timed.masterlog -log file for master timed -.El -.Sh DIAGNOSTICS -.Bl -diag -.It ?Ambiguous command -abbreviation matches more than one command -.It ?Invalid command -no match found -.It ?Privileged command -command can be executed by root only -.El -.Sh SEE ALSO -.Xr date 1 , -.Xr adjtime 2 , -.Xr icmp 4 , -.Xr timed 8 -.Rs -.%T "TSP: The Time Synchronization Protocol for UNIX 4.3BSD" -.%A R. Gusella -.%A S. Zatti -.Re -.Sh HISTORY -The -.Nm -utility appeared in -.Bx 4.3 . -.Pp -The latest -.Nm -code has been made available as a port (net/timed) in preparation of removal -from base in -.Fx 13.0 . diff --git a/usr.sbin/timed/timedc/timedc.c b/usr.sbin/timed/timedc/timedc.c deleted file mode 100644 index accfa355b0b..00000000000 --- a/usr.sbin/timed/timedc/timedc.c +++ /dev/null @@ -1,255 +0,0 @@ -/*- - * SPDX-License-Identifier: BSD-3-Clause - * - * Copyright (c) 1985, 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. 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) 1985, 1993\n\ - The Regents of the University of California. All rights reserved.\n"; -#endif /* not lint */ - -#ifndef lint -#if 0 -static char sccsid[] = "@(#)timedc.c 8.1 (Berkeley) 6/6/93"; -#endif -#endif /* not lint */ - -#include "timedc.h" -#include -#include -#include -#include -#include -#include -#include -#include - -int trace = 0; -FILE *fd = NULL; -int margc; -int fromatty; -#define MAX_MARGV 20 -char *margv[MAX_MARGV]; -char cmdline[200]; -jmp_buf toplevel; -static struct cmd *getcmd(char *); - -int -main(int argc, char *argv[]) -{ - register struct cmd *c; - - openlog("timedc", 0, LOG_AUTH); - - /* - * security dictates! - */ - if (priv_resources() < 0) - errx(1, "could not get privileged resources"); - if (setuid(getuid()) != 0) - err(1, "setuid()"); - - if (--argc > 0) { - c = getcmd(*++argv); - if (c == (struct cmd *)-1) { - printf("?Ambiguous command\n"); - exit(1); - } - if (c == NULL) { - printf("?Invalid command\n"); - exit(1); - } - if (c->c_priv && getuid()) { - printf("?Privileged command\n"); - exit(1); - } - (*c->c_handler)(argc, argv); - exit(0); - } - - fromatty = isatty(fileno(stdin)); - if (fromatty) - printf("TIMEDC will be removed from FreeBSD-13, and will be " - "provided as a port (net/timed) or package (timed).\n"); - if (setjmp(toplevel)) - putchar('\n'); - (void) signal(SIGINT, intr); - for (;;) { - if (fromatty) { - printf("timedc> "); - (void) fflush(stdout); - } - if (fgets(cmdline, sizeof(cmdline), stdin) == NULL) - quit(); - if (cmdline[0] == 0) - break; - makeargv(); - if (margv[0] == NULL) - continue; - c = getcmd(margv[0]); - if (c == (struct cmd *)-1) { - printf("?Ambiguous command\n"); - continue; - } - if (c == NULL) { - printf("?Invalid command\n"); - continue; - } - if (c->c_priv && getuid()) { - printf("?Privileged command\n"); - continue; - } - (*c->c_handler)(margc, margv); - } - return 0; -} - -void -intr(int signo __unused) -{ - if (!fromatty) - exit(0); - longjmp(toplevel, 1); -} - - -static struct cmd * -getcmd(char *name) -{ - register char *p, *q; - register struct cmd *c, *found; - register int nmatches, longest; - extern int NCMDS; - - longest = 0; - nmatches = 0; - found = NULL; - for (c = cmdtab; c < &cmdtab[NCMDS]; c++) { - p = c->c_name; - for (q = name; *q == *p++; q++) - if (*q == 0) /* exact match? */ - return(c); - if (!*q) { /* the name was a prefix */ - if (q - name > longest) { - longest = q - name; - nmatches = 1; - found = c; - } else if (q - name == longest) - nmatches++; - } - } - if (nmatches > 1) - return((struct cmd *)-1); - return(found); -} - -/* - * Slice a string up into argc/argv. - */ -void -makeargv(void) -{ - register char *cp; - register char **argp = margv; - - margc = 0; - for (cp = cmdline; margc < MAX_MARGV - 1 && *cp; ) { - while (isspace(*cp)) - cp++; - if (*cp == '\0') - break; - *argp++ = cp; - margc += 1; - while (*cp != '\0' && !isspace(*cp)) - cp++; - if (*cp == '\0') - break; - *cp++ = '\0'; - } - *argp++ = NULL; -} - -#define HELPINDENT (sizeof ("directory")) - -/* - * Help command. - */ -void -help(int argc, char *argv[]) -{ - register struct cmd *c; - - if (argc == 1) { - register int i, j, w; - int columns, width = 0, lines; - extern int NCMDS; - - printf("Commands may be abbreviated. Commands are:\n\n"); - for (c = cmdtab; c < &cmdtab[NCMDS]; c++) { - int len = strlen(c->c_name); - - if (len > width) - width = len; - } - width = (width + 8) &~ 7; - columns = 80 / width; - if (columns == 0) - columns = 1; - lines = (NCMDS + columns - 1) / columns; - for (i = 0; i < lines; i++) { - for (j = 0; j < columns; j++) { - c = cmdtab + j * lines + i; - printf("%s", c->c_name); - if (c + lines >= &cmdtab[NCMDS]) { - printf("\n"); - break; - } - w = strlen(c->c_name); - while (w < width) { - w = (w + 8) &~ 7; - putchar('\t'); - } - } - } - return; - } - while (--argc > 0) { - register char *arg; - arg = *++argv; - c = getcmd(arg); - if (c == (struct cmd *)-1) - printf("?Ambiguous help command %s\n", arg); - else if (c == (struct cmd *)0) - printf("?Invalid help command %s\n", arg); - else - printf("%-*s\t%s\n", (int)HELPINDENT, - c->c_name, c->c_help); - } -} diff --git a/usr.sbin/timed/timedc/timedc.h b/usr.sbin/timed/timedc/timedc.h deleted file mode 100644 index c5c3c20423b..00000000000 --- a/usr.sbin/timed/timedc/timedc.h +++ /dev/null @@ -1,60 +0,0 @@ -/*- - * SPDX-License-Identifier: BSD-3-Clause - * - * Copyright (c) 1985, 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. 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. - * - * @(#)timedc.h 8.1 (Berkeley) 6/6/93 - * - */ - -#include -#include -#include -#include -#include - -#include -#include -#include - -#define ON 1 -#define OFF 0 - -#define GOOD 1 -#define UNREACHABLE 2 -#define NONSTDTIME 3 -#define HOSTDOWN 0x7fffffff - -struct cmd { - char *c_name; /* command name */ - char *c_help; /* help message */ - void (*c_handler)(); /* routine to do the work */ - int c_priv; /* privileged command */ -}; - -#include "extern.h"