summaryrefslogtreecommitdiffstats
path: root/usr.sbin
diff options
context:
space:
mode:
authorneel <neel@FreeBSD.org>2013-01-04 19:28:32 +0000
committerneel <neel@FreeBSD.org>2013-01-04 19:28:32 +0000
commit38ad3ee53626ccab6f22009b0723f2fb7903ecc1 (patch)
tree9981bd6a02de01af545d4aff19c0afbef003cfe5 /usr.sbin
parent736fc919674c3c284d5611e7e9b572385c4dbc0e (diff)
parent661fe3468922dc71771a1f31a3562d73f41c4374 (diff)
downloadFreeBSD-src-38ad3ee53626ccab6f22009b0723f2fb7903ecc1.zip
FreeBSD-src-38ad3ee53626ccab6f22009b0723f2fb7903ecc1.tar.gz
IFC @ r244983.
Diffstat (limited to 'usr.sbin')
-rw-r--r--usr.sbin/Makefile1
-rw-r--r--usr.sbin/Makefile.amd643
-rw-r--r--usr.sbin/Makefile.i3863
-rw-r--r--usr.sbin/Makefile.sparc643
-rw-r--r--usr.sbin/acpi/acpidump/acpi.c275
-rw-r--r--usr.sbin/acpi/acpidump/acpidump.81
-rw-r--r--usr.sbin/bluetooth/hcseriald/hcseriald.82
-rw-r--r--usr.sbin/bluetooth/hcseriald/hcseriald.c2
-rwxr-xr-xusr.sbin/bsdconfig/bsdconfig23
-rwxr-xr-xusr.sbin/bsdconfig/console/console2
-rwxr-xr-xusr.sbin/bsdconfig/console/font2
-rwxr-xr-xusr.sbin/bsdconfig/console/keymap2
-rwxr-xr-xusr.sbin/bsdconfig/console/repeat2
-rwxr-xr-xusr.sbin/bsdconfig/console/saver31
-rwxr-xr-xusr.sbin/bsdconfig/console/screenmap2
-rwxr-xr-xusr.sbin/bsdconfig/console/ttys2
-rwxr-xr-xusr.sbin/bsdconfig/diskmgmt/diskmgmt2
-rwxr-xr-xusr.sbin/bsdconfig/docsinstall/docsinstall2
-rwxr-xr-xusr.sbin/bsdconfig/dot/dot1
-rw-r--r--usr.sbin/bsdconfig/examples/bsdconfigrc3
-rwxr-xr-xusr.sbin/bsdconfig/mouse/disable2
-rwxr-xr-xusr.sbin/bsdconfig/mouse/enable2
-rwxr-xr-xusr.sbin/bsdconfig/mouse/flags30
-rwxr-xr-xusr.sbin/bsdconfig/mouse/mouse2
-rwxr-xr-xusr.sbin/bsdconfig/mouse/port2
-rwxr-xr-xusr.sbin/bsdconfig/mouse/type2
-rwxr-xr-xusr.sbin/bsdconfig/networking/defaultrouter2
-rwxr-xr-xusr.sbin/bsdconfig/networking/devices2
-rwxr-xr-xusr.sbin/bsdconfig/networking/hostname2
-rwxr-xr-xusr.sbin/bsdconfig/networking/nameservers2
-rwxr-xr-xusr.sbin/bsdconfig/networking/networking2
-rw-r--r--usr.sbin/bsdconfig/networking/share/common.subr4
-rw-r--r--usr.sbin/bsdconfig/networking/share/device.subr17
-rw-r--r--usr.sbin/bsdconfig/networking/share/hostname.subr109
-rw-r--r--usr.sbin/bsdconfig/networking/share/ipaddr.subr65
-rw-r--r--usr.sbin/bsdconfig/networking/share/media.subr13
-rw-r--r--usr.sbin/bsdconfig/networking/share/netmask.subr99
-rw-r--r--usr.sbin/bsdconfig/networking/share/resolv.subr35
-rw-r--r--usr.sbin/bsdconfig/networking/share/routing.subr38
-rwxr-xr-xusr.sbin/bsdconfig/password/password2
-rw-r--r--usr.sbin/bsdconfig/password/share/password.subr5
-rwxr-xr-xusr.sbin/bsdconfig/security/kern_securelevel2
-rwxr-xr-xusr.sbin/bsdconfig/security/security2
-rw-r--r--usr.sbin/bsdconfig/share/common.subr103
-rw-r--r--usr.sbin/bsdconfig/share/dialog.subr99
-rw-r--r--usr.sbin/bsdconfig/share/mustberoot.subr11
-rw-r--r--usr.sbin/bsdconfig/share/strings.subr2
-rw-r--r--usr.sbin/bsdconfig/share/sysrc.subr9
-rwxr-xr-xusr.sbin/bsdconfig/startup/misc31
-rwxr-xr-xusr.sbin/bsdconfig/startup/rcadd2
-rwxr-xr-xusr.sbin/bsdconfig/startup/rcconf2
-rwxr-xr-xusr.sbin/bsdconfig/startup/rcdelete2
-rwxr-xr-xusr.sbin/bsdconfig/startup/rcedit2
-rwxr-xr-xusr.sbin/bsdconfig/startup/rcvar2
-rw-r--r--usr.sbin/bsdconfig/startup/share/rcconf.subr38
-rw-r--r--usr.sbin/bsdconfig/startup/share/rcedit.subr40
-rw-r--r--usr.sbin/bsdconfig/startup/share/rcvar.subr26
-rwxr-xr-xusr.sbin/bsdconfig/startup/startup2
-rw-r--r--usr.sbin/bsdconfig/timezone/share/continents.subr5
-rw-r--r--usr.sbin/bsdconfig/timezone/share/countries.subr2
-rw-r--r--usr.sbin/bsdconfig/timezone/share/iso3166.subr5
-rw-r--r--usr.sbin/bsdconfig/timezone/share/menus.subr5
-rw-r--r--usr.sbin/bsdconfig/timezone/share/zones.subr5
-rwxr-xr-xusr.sbin/bsdconfig/timezone/timezone2
-rwxr-xr-xusr.sbin/bsdconfig/ttys/ttys2
-rwxr-xr-xusr.sbin/bsdconfig/usermgmt/groupadd2
-rwxr-xr-xusr.sbin/bsdconfig/usermgmt/groupdel4
-rwxr-xr-xusr.sbin/bsdconfig/usermgmt/groupedit4
-rwxr-xr-xusr.sbin/bsdconfig/usermgmt/groupinput14
-rw-r--r--usr.sbin/bsdconfig/usermgmt/share/group_input.subr110
-rw-r--r--usr.sbin/bsdconfig/usermgmt/share/user_input.subr364
-rwxr-xr-xusr.sbin/bsdconfig/usermgmt/useradd2
-rwxr-xr-xusr.sbin/bsdconfig/usermgmt/userdel4
-rwxr-xr-xusr.sbin/bsdconfig/usermgmt/useredit4
-rwxr-xr-xusr.sbin/bsdconfig/usermgmt/userinput15
-rwxr-xr-xusr.sbin/bsdconfig/usermgmt/usermgmt4
-rw-r--r--usr.sbin/bsdinstall/partedit/Makefile3
-rw-r--r--usr.sbin/bsdinstall/partedit/partedit.c8
-rw-r--r--usr.sbin/bsdinstall/partedit/sade.8 (renamed from usr.sbin/sade/sade.8)30
-rwxr-xr-xusr.sbin/bsdinstall/scripts/mirrorselect14
-rw-r--r--usr.sbin/gssd/Makefile4
-rw-r--r--usr.sbin/gssd/gssd.828
-rw-r--r--usr.sbin/gssd/gssd.c329
-rw-r--r--usr.sbin/iostat/iostat.828
-rw-r--r--usr.sbin/iostat/iostat.c27
-rwxr-xr-xusr.sbin/mergemaster/mergemaster.sh19
-rw-r--r--usr.sbin/mountd/exports.57
-rw-r--r--usr.sbin/mountd/mountd.c2
-rw-r--r--usr.sbin/moused/moused.810
-rw-r--r--usr.sbin/mptable/mptable.c16
-rw-r--r--usr.sbin/mtest/mtest.c4
-rw-r--r--usr.sbin/ndiscvt/inf-parse.y1
-rw-r--r--usr.sbin/ndp/ndp.84
-rw-r--r--usr.sbin/ndp/ndp.c54
-rw-r--r--usr.sbin/nfsd/nfsd.c2
-rw-r--r--usr.sbin/nfsd/nfsv4.44
-rw-r--r--usr.sbin/nmtree/Makefile26
-rw-r--r--usr.sbin/pkg/Makefile2
-rw-r--r--usr.sbin/pkg/dns_utils.c136
-rw-r--r--usr.sbin/pkg/dns_utils.h (renamed from usr.sbin/sade/list.h)56
-rw-r--r--usr.sbin/pkg/pkg.c56
-rw-r--r--usr.sbin/portsnap/portsnap/portsnap.sh28
-rw-r--r--usr.sbin/ppp/README.changes2
-rw-r--r--usr.sbin/ppp/defs.h2
-rw-r--r--usr.sbin/ppp/ppp.8.m420
-rw-r--r--usr.sbin/pw/bitmap.c3
-rw-r--r--usr.sbin/pw/grupd.c11
-rw-r--r--usr.sbin/pw/pw_group.c5
-rw-r--r--usr.sbin/pw/pw_user.c26
-rw-r--r--usr.sbin/pw/pw_vpw.c236
-rw-r--r--usr.sbin/pw/pwupd.c16
-rw-r--r--usr.sbin/pw/rm_r.c2
-rw-r--r--usr.sbin/rpcbind/rpcbind.c4
-rw-r--r--usr.sbin/sade/Makefile27
-rw-r--r--usr.sbin/sade/command.c179
-rw-r--r--usr.sbin/sade/devices.c344
-rw-r--r--usr.sbin/sade/disks.c972
-rw-r--r--usr.sbin/sade/dmenu.c93
-rw-r--r--usr.sbin/sade/globals.c84
-rw-r--r--usr.sbin/sade/help/partition.hlp169
-rw-r--r--usr.sbin/sade/help/slice.hlp57
-rw-r--r--usr.sbin/sade/install.c249
-rw-r--r--usr.sbin/sade/label.c1646
-rw-r--r--usr.sbin/sade/main.c123
-rw-r--r--usr.sbin/sade/menus.c109
-rw-r--r--usr.sbin/sade/misc.c426
-rw-r--r--usr.sbin/sade/msg.c357
-rw-r--r--usr.sbin/sade/sade.h465
-rw-r--r--usr.sbin/sade/system.c304
-rw-r--r--usr.sbin/sade/termcap.c104
-rw-r--r--usr.sbin/sade/variable.c324
-rw-r--r--usr.sbin/sade/wizard.c200
-rw-r--r--usr.sbin/service/service.86
-rwxr-xr-xusr.sbin/service/service.sh31
-rw-r--r--usr.sbin/syslogd/syslogd.c6
-rw-r--r--usr.sbin/ypserv/yp_main.c2
136 files changed, 1744 insertions, 7487 deletions
diff --git a/usr.sbin/Makefile b/usr.sbin/Makefile
index aaf2483..8a2d5be 100644
--- a/usr.sbin/Makefile
+++ b/usr.sbin/Makefile
@@ -55,6 +55,7 @@ SUBDIR= adduser \
nfsdumpstate \
nfsrevoke \
nfsuserd \
+ nmtree \
nologin \
pc-sysinstall \
pciconf \
diff --git a/usr.sbin/Makefile.amd64 b/usr.sbin/Makefile.amd64
index b9747e5..e1ccf49 100644
--- a/usr.sbin/Makefile.amd64
+++ b/usr.sbin/Makefile.amd64
@@ -25,8 +25,5 @@ SUBDIR+= ndiscvt
.endif
SUBDIR+= sicontrol
SUBDIR+= spkrtest
-.if ${MK_SYSINSTALL} != "no"
-SUBDIR+= sade
-.endif
SUBDIR+= bhyvectl
SUBDIR+= zzz
diff --git a/usr.sbin/Makefile.i386 b/usr.sbin/Makefile.i386
index 9588eb8..901c2d9 100644
--- a/usr.sbin/Makefile.i386
+++ b/usr.sbin/Makefile.i386
@@ -17,9 +17,6 @@ SUBDIR+= mptable
SUBDIR+= ndiscvt
.endif
SUBDIR+= pnpinfo
-.if ${MK_SYSINSTALL} != "no"
-SUBDIR+= sade
-.endif
SUBDIR+= sicontrol
SUBDIR+= spkrtest
SUBDIR+= zzz
diff --git a/usr.sbin/Makefile.sparc64 b/usr.sbin/Makefile.sparc64
index 479dafc..81f7a9b 100644
--- a/usr.sbin/Makefile.sparc64
+++ b/usr.sbin/Makefile.sparc64
@@ -2,6 +2,3 @@
SUBDIR+= eeprom
SUBDIR+= ofwdump
-.if ${MK_SYSINSTALL} != "no"
-SUBDIR+= sade
-.endif
diff --git a/usr.sbin/acpi/acpidump/acpi.c b/usr.sbin/acpi/acpidump/acpi.c
index b0a751c..c7f5bd8 100644
--- a/usr.sbin/acpi/acpidump/acpi.c
+++ b/usr.sbin/acpi/acpidump/acpi.c
@@ -123,6 +123,31 @@ static const char *TCPA_pcclient_strings[] = {
"Table of Devices",
};
+#define PRINTFLAG_END() printflag_end()
+
+static char pf_sep = '{';
+
+static void
+printflag_end(void)
+{
+
+ if (pf_sep != '{') {
+ printf("}");
+ pf_sep = '{';
+ }
+ printf("\n");
+}
+
+static void
+printflag(uint64_t var, uint64_t mask, const char *name)
+{
+
+ if (var & mask) {
+ printf("%c%s", pf_sep, name);
+ pf_sep = ',';
+ }
+}
+
static void
acpi_print_string(char *s, size_t length)
{
@@ -729,6 +754,238 @@ acpi_handle_tcpa(ACPI_TABLE_HEADER *sdp)
printf(END_COMMENT);
}
+static const char *
+devscope_type2str(int type)
+{
+ static char typebuf[16];
+
+ switch (type) {
+ case 1:
+ return ("PCI Endpoint Device");
+ case 2:
+ return ("PCI Sub-Hierarchy");
+ case 3:
+ return ("IOAPIC");
+ case 4:
+ return ("HPET");
+ default:
+ snprintf(typebuf, sizeof(typebuf), "%d", type);
+ return (typebuf);
+ }
+}
+
+static int
+acpi_handle_dmar_devscope(void *addr, int remaining)
+{
+ char sep;
+ int pathlen;
+ ACPI_DMAR_PCI_PATH *path, *pathend;
+ ACPI_DMAR_DEVICE_SCOPE *devscope = addr;
+
+ if (remaining < (int)sizeof(ACPI_DMAR_DEVICE_SCOPE))
+ return (-1);
+
+ if (remaining < devscope->Length)
+ return (-1);
+
+ printf("\n");
+ printf("\t\tType=%s\n", devscope_type2str(devscope->EntryType));
+ printf("\t\tLength=%d\n", devscope->Length);
+ printf("\t\tEnumerationId=%d\n", devscope->EnumerationId);
+ printf("\t\tStartBusNumber=%d\n", devscope->Bus);
+
+ path = (ACPI_DMAR_PCI_PATH *)(devscope + 1);
+ pathlen = devscope->Length - sizeof(ACPI_DMAR_DEVICE_SCOPE);
+ pathend = path + pathlen / sizeof(ACPI_DMAR_PCI_PATH);
+ if (path < pathend) {
+ sep = '{';
+ printf("\t\tPath=");
+ do {
+ printf("%c%d:%d", sep, path->Device, path->Function);
+ sep=',';
+ path++;
+ } while (path < pathend);
+ printf("}\n");
+ }
+
+ return (devscope->Length);
+}
+
+static void
+acpi_handle_dmar_drhd(ACPI_DMAR_HARDWARE_UNIT *drhd)
+{
+ char *cp;
+ int remaining, consumed;
+
+ printf("\n");
+ printf("\tType=DRHD\n");
+ printf("\tLength=%d\n", drhd->Header.Length);
+
+#define PRINTFLAG(var, flag) printflag((var), ACPI_DMAR_## flag, #flag)
+
+ printf("\tFlags=");
+ PRINTFLAG(drhd->Flags, INCLUDE_ALL);
+ PRINTFLAG_END();
+
+#undef PRINTFLAG
+
+ printf("\tSegment=%d\n", drhd->Segment);
+ printf("\tAddress=0x%0jx\n", drhd->Address);
+
+ remaining = drhd->Header.Length - sizeof(ACPI_DMAR_HARDWARE_UNIT);
+ if (remaining > 0)
+ printf("\tDevice Scope:");
+ while (remaining > 0) {
+ cp = (char *)drhd + drhd->Header.Length - remaining;
+ consumed = acpi_handle_dmar_devscope(cp, remaining);
+ if (consumed <= 0)
+ break;
+ else
+ remaining -= consumed;
+ }
+}
+
+static void
+acpi_handle_dmar_rmrr(ACPI_DMAR_RESERVED_MEMORY *rmrr)
+{
+ char *cp;
+ int remaining, consumed;
+
+ printf("\n");
+ printf("\tType=RMRR\n");
+ printf("\tLength=%d\n", rmrr->Header.Length);
+ printf("\tSegment=%d\n", rmrr->Segment);
+ printf("\tBaseAddress=0x%0jx\n", rmrr->BaseAddress);
+ printf("\tLimitAddress=0x%0jx\n", rmrr->EndAddress);
+
+ remaining = rmrr->Header.Length - sizeof(ACPI_DMAR_RESERVED_MEMORY);
+ if (remaining > 0)
+ printf("\tDevice Scope:");
+ while (remaining > 0) {
+ cp = (char *)rmrr + rmrr->Header.Length - remaining;
+ consumed = acpi_handle_dmar_devscope(cp, remaining);
+ if (consumed <= 0)
+ break;
+ else
+ remaining -= consumed;
+ }
+}
+
+static void
+acpi_handle_dmar_atsr(ACPI_DMAR_ATSR *atsr)
+{
+ char *cp;
+ int remaining, consumed;
+
+ printf("\n");
+ printf("\tType=ATSR\n");
+ printf("\tLength=%d\n", atsr->Header.Length);
+
+#define PRINTFLAG(var, flag) printflag((var), ACPI_DMAR_## flag, #flag)
+
+ printf("\tFlags=");
+ PRINTFLAG(atsr->Flags, ALL_PORTS);
+ PRINTFLAG_END();
+
+#undef PRINTFLAG
+
+ printf("\tSegment=%d\n", atsr->Segment);
+
+ remaining = atsr->Header.Length - sizeof(ACPI_DMAR_ATSR);
+ if (remaining > 0)
+ printf("\tDevice Scope:");
+ while (remaining > 0) {
+ cp = (char *)atsr + atsr->Header.Length - remaining;
+ consumed = acpi_handle_dmar_devscope(cp, remaining);
+ if (consumed <= 0)
+ break;
+ else
+ remaining -= consumed;
+ }
+}
+
+static void
+acpi_handle_dmar_rhsa(ACPI_DMAR_RHSA *rhsa)
+{
+
+ printf("\n");
+ printf("\tType=RHSA\n");
+ printf("\tLength=%d\n", rhsa->Header.Length);
+ printf("\tBaseAddress=0x%0jx\n", rhsa->BaseAddress);
+ printf("\tProximityDomain=0x%08x\n", rhsa->ProximityDomain);
+}
+
+static int
+acpi_handle_dmar_remapping_structure(void *addr, int remaining)
+{
+ ACPI_DMAR_HEADER *hdr = addr;
+
+ if (remaining < (int)sizeof(ACPI_DMAR_HEADER))
+ return (-1);
+
+ if (remaining < hdr->Length)
+ return (-1);
+
+ switch (hdr->Type) {
+ case ACPI_DMAR_TYPE_HARDWARE_UNIT:
+ acpi_handle_dmar_drhd(addr);
+ break;
+ case ACPI_DMAR_TYPE_RESERVED_MEMORY:
+ acpi_handle_dmar_rmrr(addr);
+ break;
+ case ACPI_DMAR_TYPE_ATSR:
+ acpi_handle_dmar_atsr(addr);
+ break;
+ case ACPI_DMAR_HARDWARE_AFFINITY:
+ acpi_handle_dmar_rhsa(addr);
+ break;
+ default:
+ printf("\n");
+ printf("\tType=%d\n", hdr->Type);
+ printf("\tLength=%d\n", hdr->Length);
+ break;
+ }
+ return (hdr->Length);
+}
+
+#ifndef ACPI_DMAR_X2APIC_OPT_OUT
+#define ACPI_DMAR_X2APIC_OPT_OUT (0x2)
+#endif
+
+static void
+acpi_handle_dmar(ACPI_TABLE_HEADER *sdp)
+{
+ char *cp;
+ int remaining, consumed;
+ ACPI_TABLE_DMAR *dmar;
+
+ printf(BEGIN_COMMENT);
+ acpi_print_sdt(sdp);
+ dmar = (ACPI_TABLE_DMAR *)sdp;
+ printf("\tHost Address Width=%d\n", dmar->Width + 1);
+
+#define PRINTFLAG(var, flag) printflag((var), ACPI_DMAR_## flag, #flag)
+
+ printf("\tFlags=");
+ PRINTFLAG(dmar->Flags, INTR_REMAP);
+ PRINTFLAG(dmar->Flags, X2APIC_OPT_OUT);
+ PRINTFLAG_END();
+
+#undef PRINTFLAG
+
+ remaining = sdp->Length - sizeof(ACPI_TABLE_DMAR);
+ while (remaining > 0) {
+ cp = (char *)sdp + sdp->Length - remaining;
+ consumed = acpi_handle_dmar_remapping_structure(cp, remaining);
+ if (consumed <= 0)
+ break;
+ else
+ remaining -= consumed;
+ }
+
+ printf(END_COMMENT);
+}
+
static void
acpi_print_srat_memory(ACPI_SRAT_MEM_AFFINITY *mp)
{
@@ -854,7 +1111,6 @@ acpi_print_fadt(ACPI_TABLE_HEADER *sdp)
{
ACPI_TABLE_FADT *fadt;
const char *pm;
- char sep;
fadt = (ACPI_TABLE_FADT *)sdp;
printf(BEGIN_COMMENT);
@@ -914,25 +1170,17 @@ acpi_print_fadt(ACPI_TABLE_HEADER *sdp)
printf("\tDAY_ALRM=%d, MON_ALRM=%d, CENTURY=%d\n",
fadt->DayAlarm, fadt->MonthAlarm, fadt->Century);
-#define PRINTFLAG(var, flag) do { \
- if ((var) & ACPI_FADT_## flag) { \
- printf("%c%s", sep, #flag); sep = ','; \
- } \
-} while (0)
+#define PRINTFLAG(var, flag) printflag((var), ACPI_FADT_## flag, #flag)
printf("\tIAPC_BOOT_ARCH=");
- sep = '{';
PRINTFLAG(fadt->BootFlags, LEGACY_DEVICES);
PRINTFLAG(fadt->BootFlags, 8042);
PRINTFLAG(fadt->BootFlags, NO_VGA);
PRINTFLAG(fadt->BootFlags, NO_MSI);
PRINTFLAG(fadt->BootFlags, NO_ASPM);
- if (fadt->BootFlags != 0)
- printf("}");
- printf("\n");
+ PRINTFLAG_END();
printf("\tFlags=");
- sep = '{';
PRINTFLAG(fadt->Flags, WBINVD);
PRINTFLAG(fadt->Flags, WBINVD_FLUSH);
PRINTFLAG(fadt->Flags, C1_SUPPORTED);
@@ -953,8 +1201,7 @@ acpi_print_fadt(ACPI_TABLE_HEADER *sdp)
PRINTFLAG(fadt->Flags, REMOTE_POWER_ON);
PRINTFLAG(fadt->Flags, APIC_CLUSTER);
PRINTFLAG(fadt->Flags, APIC_PHYSICAL);
- if (fadt->Flags != 0)
- printf("}\n");
+ PRINTFLAG_END();
#undef PRINTFLAG
@@ -1127,6 +1374,8 @@ acpi_handle_rsdt(ACPI_TABLE_HEADER *rsdp)
acpi_handle_srat(sdp);
else if (!memcmp(sdp->Signature, ACPI_SIG_TCPA, 4))
acpi_handle_tcpa(sdp);
+ else if (!memcmp(sdp->Signature, ACPI_SIG_DMAR, 4))
+ acpi_handle_dmar(sdp);
else {
printf(BEGIN_COMMENT);
acpi_print_sdt(sdp);
diff --git a/usr.sbin/acpi/acpidump/acpidump.8 b/usr.sbin/acpi/acpidump/acpidump.8
index 1401e38..f1c7a18 100644
--- a/usr.sbin/acpi/acpidump/acpidump.8
+++ b/usr.sbin/acpi/acpidump/acpidump.8
@@ -97,6 +97,7 @@ flag, the
utility dumps contents of the following tables:
.Pp
.Bl -tag -offset indent -width 12345 -compact
+.It DMAR
.It DSDT
.It ECDT
.It FACS
diff --git a/usr.sbin/bluetooth/hcseriald/hcseriald.8 b/usr.sbin/bluetooth/hcseriald/hcseriald.8
index 111b28c..8d2dd47 100644
--- a/usr.sbin/bluetooth/hcseriald/hcseriald.8
+++ b/usr.sbin/bluetooth/hcseriald/hcseriald.8
@@ -54,7 +54,7 @@ Do not disassociate from the controlling terminal, i.e., run in foreground.
.It Fl f Ar device
Callout device name.
Example:
-.Fl f Pa /dev/cuad0 .
+.Fl f Pa /dev/cuau0 .
.It Fl h
Display usage message and exit.
.It Fl n Ar node_name
diff --git a/usr.sbin/bluetooth/hcseriald/hcseriald.c b/usr.sbin/bluetooth/hcseriald/hcseriald.c
index b811c1d..440b0d4 100644
--- a/usr.sbin/bluetooth/hcseriald/hcseriald.c
+++ b/usr.sbin/bluetooth/hcseriald/hcseriald.c
@@ -257,7 +257,7 @@ usage(void)
{
fprintf(stderr, "Usage: %s -f device -n node_name [-s speed -d -h]\n" \
"Where:\n" \
- "\t-f device tty device name, ex. /dev/cuad1\n" \
+ "\t-f device tty device name, ex. /dev/cuau1\n" \
"\t-n node_name set Netgraph node name to node_name\n" \
"\t-s speed set tty speed, ex. 115200\n" \
"\t-d run in foreground\n" \
diff --git a/usr.sbin/bsdconfig/bsdconfig b/usr.sbin/bsdconfig/bsdconfig
index 8d8245a..11ea8fc 100755
--- a/usr.sbin/bsdconfig/bsdconfig
+++ b/usr.sbin/bsdconfig/bsdconfig
@@ -31,6 +31,7 @@
BSDCFG_SHARE="/usr/share/bsdconfig"
. $BSDCFG_SHARE/common.subr || exit 1
+f_dprintf "%s: loading includes..." "$0"
f_include $BSDCFG_SHARE/dialog.subr
f_include $BSDCFG_SHARE/mustberoot.subr
f_include $BSDCFG_SHARE/strings.subr
@@ -70,7 +71,7 @@ usage()
#
local longest_cmd
longest_cmd=$( echo "$cmd_list" | f_longest_line_length )
- f_dprintf "longest_cmd=[$longest_cmd]"
+ f_dprintf "longest_cmd=[%s]" "$longest_cmd"
#
# Determine the maximum width of terminal/console
@@ -79,7 +80,7 @@ usage()
max_size=$( stty size 2> /dev/null )
: ${max_size:="24 80"}
max_width="${max_size#*[$IFS]}"
- f_dprintf "max_width=[$max_width]"
+ f_dprintf "max_width=[%s]" "$max_width"
#
# Using the longest command-length as the width of a single column,
@@ -92,7 +93,7 @@ usage()
ncols=$(( $ncols + 1 ))
x=$(( $x + 3 + $longest_cmd ))
done
- f_dprintf "ncols=[$ncols] x=[$x]"
+ f_dprintf "ncols=[%u] x=[%u]" $ncols $x
#
# Re-format the command-list into multiple columns
@@ -117,7 +118,8 @@ usage()
{
n++
cur_col = (( n - 1 ) % ncols ) + 1
- printf "f_dprintf \"row_item[%u]=[%s]\"\n", cur_col, $0
+ printf "f_dprintf \"row_item[%u]=[%%s]\" \"%s\"\n",
+ cur_col, $0
row_item[cur_col] = $0
if ( cur_col == ncols ) print_row()
}
@@ -224,7 +226,6 @@ shift $(( $OPTIND -1 ))
#
# Initialize
#
-f_dialog_init
f_dialog_title "$msg_main_menu"
[ "$SECURE" ] && f_mustberoot_init
@@ -232,14 +233,6 @@ f_dialog_title "$msg_main_menu"
# Incorporate rc-file if it exists
[ -f "$HOME/.bsdconfigrc" ] && f_include "$HOME/.bsdconfigrc"
-#
-# Log our operating environment for debugging purposes
-#
-export UNAME_S="$(uname -s)" # Operating System (i.e. FreeBSD)
-export UNAME_P="$(uname -p)" # Processor Architecture (i.e. i386)
-export UNAME_R="$(uname -r)" # Release Level (i.e. X.Y-RELEASE)
-f_dprintf "UNAME_S=[$UNAME_S] UNAME_P=[$UNAME_P] UNAME_R=[$UNAME_R]"
-
cd $BSDCFG_LIBE || f_die 1 "$msg_directory_not_found" "$BSDCFG_LIBE"
#
@@ -276,7 +269,7 @@ while :; do
dialog_menu_main
retval=$?
mtag=$( f_dialog_menutag )
- f_dprintf "retval=$retval mtag=[$mtag]"
+ f_dprintf "retval=%u mtag=[%s]" $retval "$mtag"
if [ $retval -eq 2 ]; then
# The Help button was pressed
@@ -298,7 +291,7 @@ while :; do
*) # Dynamically loaded menuitem
cmd=$( eval echo \"\$menu_program$mtag\" )
- f_dprintf "cmd=[$cmd]"
+ f_dprintf "cmd=[%s]" "$cmd"
$cmd ${USE_XDIALOG:+-X}
;;
diff --git a/usr.sbin/bsdconfig/console/console b/usr.sbin/bsdconfig/console/console
index 8cf12b6..5f3b7af 100755
--- a/usr.sbin/bsdconfig/console/console
+++ b/usr.sbin/bsdconfig/console/console
@@ -30,6 +30,7 @@
BSDCFG_SHARE="/usr/share/bsdconfig"
. $BSDCFG_SHARE/common.subr || exit 1
+f_dprintf "%s: loading includes..." "$0"
f_include $BSDCFG_SHARE/dialog.subr
f_include $BSDCFG_SHARE/mustberoot.subr
@@ -102,7 +103,6 @@ shift $(( $OPTIND - 1 ))
#
# Initialize
#
-f_dialog_init
f_dialog_title "$msg_system_console_configuration"
f_dialog_backtitle "${ipgm:+bsdconfig }$pgm"
f_mustberoot_init
diff --git a/usr.sbin/bsdconfig/console/font b/usr.sbin/bsdconfig/console/font
index 5346dd2..022952f 100755
--- a/usr.sbin/bsdconfig/console/font
+++ b/usr.sbin/bsdconfig/console/font
@@ -30,6 +30,7 @@
BSDCFG_SHARE="/usr/share/bsdconfig"
. $BSDCFG_SHARE/common.subr || exit 1
+f_dprintf "%s: loading includes..." "$0"
f_include $BSDCFG_SHARE/dialog.subr
f_include $BSDCFG_SHARE/mustberoot.subr
f_include $BSDCFG_SHARE/sysrc.subr
@@ -110,7 +111,6 @@ shift $(( $OPTIND - 1 ))
#
# Initialize
#
-f_dialog_init
f_dialog_title "$msg_system_console_font"
f_dialog_backtitle "${ipgm:+bsdconfig }$pgm"
f_mustberoot_init
diff --git a/usr.sbin/bsdconfig/console/keymap b/usr.sbin/bsdconfig/console/keymap
index 98a253c..5518140 100755
--- a/usr.sbin/bsdconfig/console/keymap
+++ b/usr.sbin/bsdconfig/console/keymap
@@ -30,6 +30,7 @@
BSDCFG_SHARE="/usr/share/bsdconfig"
. $BSDCFG_SHARE/common.subr || exit 1
+f_dprintf "%s: loading includes..." "$0"
f_include $BSDCFG_SHARE/dialog.subr
f_include $BSDCFG_SHARE/mustberoot.subr
f_include $BSDCFG_SHARE/sysrc.subr
@@ -150,7 +151,6 @@ shift $(( $OPTIND - 1 ))
#
# Initialize
#
-f_dialog_init
f_dialog_title "$msg_system_console_keymap"
f_dialog_backtitle "${ipgm:+bsdconfig }$pgm"
f_mustberoot_init
diff --git a/usr.sbin/bsdconfig/console/repeat b/usr.sbin/bsdconfig/console/repeat
index 820b0b4..93357e8 100755
--- a/usr.sbin/bsdconfig/console/repeat
+++ b/usr.sbin/bsdconfig/console/repeat
@@ -30,6 +30,7 @@
BSDCFG_SHARE="/usr/share/bsdconfig"
. $BSDCFG_SHARE/common.subr || exit 1
+f_dprintf "%s: loading includes..." "$0"
f_include $BSDCFG_SHARE/dialog.subr
f_include $BSDCFG_SHARE/mustberoot.subr
f_include $BSDCFG_SHARE/sysrc.subr
@@ -100,7 +101,6 @@ shift $(( $OPTIND - 1 ))
#
# Initialize
#
-f_dialog_init
f_dialog_title "$msg_system_console_keyboard_repeat_rate"
f_dialog_backtitle "${ipgm:+bsdconfig }$pgm"
f_mustberoot_init
diff --git a/usr.sbin/bsdconfig/console/saver b/usr.sbin/bsdconfig/console/saver
index 5313265..4f6729b 100755
--- a/usr.sbin/bsdconfig/console/saver
+++ b/usr.sbin/bsdconfig/console/saver
@@ -30,6 +30,7 @@
BSDCFG_SHARE="/usr/share/bsdconfig"
. $BSDCFG_SHARE/common.subr || exit 1
+f_dprintf "%s: loading includes..." "$0"
f_include $BSDCFG_SHARE/dialog.subr
f_include $BSDCFG_SHARE/mustberoot.subr
f_include $BSDCFG_SHARE/sysrc.subr
@@ -110,7 +111,6 @@ shift $(( $OPTIND - 1 ))
#
# Initialize
#
-f_dialog_init
f_dialog_title "$msg_system_console_screen_saver"
f_dialog_backtitle "${ipgm:+bsdconfig }$pgm"
f_mustberoot_init
@@ -167,33 +167,10 @@ while :; do
break ;;
"$msg_timeout") # Set the screen saver timeout interval
f_dialog_title "$msg_value_required"
- title="$DIALOG_TITLE"
- btitle="$DIALOG_BACKTITLE"
+ blanktime=$( f_dialog_input "$msg_enter_timeout_period" \
+ "$( f_sysrc_get blanktime )"
+ ) && f_sysrc_set blanktime "$blanktime"
f_dialog_title_restore
- prompt="$msg_enter_timeout_period"
- blanktime=$( f_sysrc_get blanktime )
- hline=""
- size=$( f_dialog_inputbox_size \
- "$title" \
- "$btitle" \
- "$prompt" \
- "$blanktime" \
- "$hline" )
- dialog_inputbox=$( $DIALOG \
- --title "$title" \
- --backtitle "$btitle" \
- --hline "$hline" \
- --ok-label "$msg_ok" \
- --cancel-label "$msg_cancel" \
- --inputbox "$prompt" $size \
- "$blanktime" \
- 2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD
- )
- retval=$?
- setvar DIALOG_INPUTBOX_$$ "$dialog_inputbox"
- blanktime=$( f_dialog_inputstr )
- [ $retval -eq $SUCCESS ] &&
- f_sysrc_set blanktime "$blanktime"
;;
esac
done
diff --git a/usr.sbin/bsdconfig/console/screenmap b/usr.sbin/bsdconfig/console/screenmap
index 99fa7ad..5c5e29e 100755
--- a/usr.sbin/bsdconfig/console/screenmap
+++ b/usr.sbin/bsdconfig/console/screenmap
@@ -30,6 +30,7 @@
BSDCFG_SHARE="/usr/share/bsdconfig"
. $BSDCFG_SHARE/common.subr || exit 1
+f_dprintf "%s: loading includes..." "$0"
f_include $BSDCFG_SHARE/dialog.subr
f_include $BSDCFG_SHARE/mustberoot.subr
f_include $BSDCFG_SHARE/sysrc.subr
@@ -102,7 +103,6 @@ shift $(( $OPTIND - 1 ))
#
# Initialize
#
-f_dialog_init
f_dialog_title "$msg_system_console_screenmap"
f_dialog_backtitle "${ipgm:+bsdconfig }$pgm"
f_mustberoot_init
diff --git a/usr.sbin/bsdconfig/console/ttys b/usr.sbin/bsdconfig/console/ttys
index 2d39a4c..e1650da 100755
--- a/usr.sbin/bsdconfig/console/ttys
+++ b/usr.sbin/bsdconfig/console/ttys
@@ -30,6 +30,7 @@
BSDCFG_SHARE="/usr/share/bsdconfig"
. $BSDCFG_SHARE/common.subr || exit 1
+f_dprintf "%s: loading includes..." "$0"
f_include $BSDCFG_SHARE/dialog.subr
f_include $BSDCFG_SHARE/mustberoot.subr
f_include $BSDCFG_SHARE/sysrc.subr
@@ -172,7 +173,6 @@ shift $(( $OPTIND - 1 ))
#
# Initialize
#
-f_dialog_init
f_dialog_title "$msg_system_console_terminal_type"
f_dialog_backtitle "${ipgm:+bsdconfig }$pgm"
f_mustberoot_init
diff --git a/usr.sbin/bsdconfig/diskmgmt/diskmgmt b/usr.sbin/bsdconfig/diskmgmt/diskmgmt
index 9cb5e09..27852fb 100755
--- a/usr.sbin/bsdconfig/diskmgmt/diskmgmt
+++ b/usr.sbin/bsdconfig/diskmgmt/diskmgmt
@@ -30,6 +30,7 @@
BSDCFG_SHARE="/usr/share/bsdconfig"
. $BSDCFG_SHARE/common.subr || exit 1
+f_dprintf "%s: loading includes..." "$0"
f_include $BSDCFG_SHARE/dialog.subr
f_include $BSDCFG_SHARE/mustberoot.subr
@@ -65,7 +66,6 @@ shift $(( $OPTIND - 1 ))
#
# Initialize
#
-f_dialog_init
f_mustberoot_init
#
diff --git a/usr.sbin/bsdconfig/docsinstall/docsinstall b/usr.sbin/bsdconfig/docsinstall/docsinstall
index 00aff61..52e0479 100755
--- a/usr.sbin/bsdconfig/docsinstall/docsinstall
+++ b/usr.sbin/bsdconfig/docsinstall/docsinstall
@@ -30,6 +30,7 @@
BSDCFG_SHARE="/usr/share/bsdconfig"
. $BSDCFG_SHARE/common.subr || exit 1
+f_dprintf "%s: loading includes..." "$0"
f_include $BSDCFG_SHARE/dialog.subr
f_include $BSDCFG_SHARE/mustberoot.subr
@@ -65,7 +66,6 @@ shift $(( $OPTIND - 1 ))
#
# Initialize
#
-f_dialog_init
f_mustberoot_init
#
diff --git a/usr.sbin/bsdconfig/dot/dot b/usr.sbin/bsdconfig/dot/dot
index 77a34a1..2cc659c 100755
--- a/usr.sbin/bsdconfig/dot/dot
+++ b/usr.sbin/bsdconfig/dot/dot
@@ -30,6 +30,7 @@
BSDCFG_SHARE="/usr/share/bsdconfig"
. $BSDCFG_SHARE/common.subr || exit 1
+f_dprintf "%s: loading includes..." "$0"
BSDCFG_LIBE="/usr/libexec/bsdconfig" APP_DIR="dot"
f_include_lang $BSDCFG_LIBE/include/messages.subr
diff --git a/usr.sbin/bsdconfig/examples/bsdconfigrc b/usr.sbin/bsdconfig/examples/bsdconfigrc
index a863a94..21d4264 100644
--- a/usr.sbin/bsdconfig/examples/bsdconfigrc
+++ b/usr.sbin/bsdconfig/examples/bsdconfigrc
@@ -31,5 +31,6 @@
# debugging aid for development
# f_dprintf() {
-# echo "$(date):$pgm: $1" >> $HOME/out
+# local format="$1"; shift
+# printf "$(date):$pgm:$format\n" "$@" >> $HOME/out
# }
diff --git a/usr.sbin/bsdconfig/mouse/disable b/usr.sbin/bsdconfig/mouse/disable
index d49cb50..0f41d73 100755
--- a/usr.sbin/bsdconfig/mouse/disable
+++ b/usr.sbin/bsdconfig/mouse/disable
@@ -30,6 +30,7 @@
BSDCFG_SHARE="/usr/share/bsdconfig"
. $BSDCFG_SHARE/common.subr || exit 1
+f_dprintf "%s: loading includes..." "$0"
f_include $BSDCFG_SHARE/dialog.subr
f_include $BSDCFG_SHARE/mustberoot.subr
f_include $BSDCFG_SHARE/sysrc.subr
@@ -65,7 +66,6 @@ shift $(( $OPTIND - 1 ))
#
# Initialize
#
-f_dialog_init
f_dialog_title "$msg_mouse_disable"
f_dialog_backtitle "${ipgm:+bsdconfig }$pgm"
f_mustberoot_init
diff --git a/usr.sbin/bsdconfig/mouse/enable b/usr.sbin/bsdconfig/mouse/enable
index 6f3d5ac..f401461 100755
--- a/usr.sbin/bsdconfig/mouse/enable
+++ b/usr.sbin/bsdconfig/mouse/enable
@@ -30,6 +30,7 @@
BSDCFG_SHARE="/usr/share/bsdconfig"
. $BSDCFG_SHARE/common.subr || exit 1
+f_dprintf "%s: loading includes..." "$0"
f_include $BSDCFG_SHARE/dialog.subr
f_include $BSDCFG_SHARE/mustberoot.subr
f_include $BSDCFG_SHARE/sysrc.subr
@@ -65,7 +66,6 @@ shift $(( $OPTIND - 1 ))
#
# Initialize
#
-f_dialog_init
f_dialog_title "$msg_mouse_enable"
f_dialog_backtitle "${ipgm:+bsdconfig }$pgm"
f_mustberoot_init
diff --git a/usr.sbin/bsdconfig/mouse/flags b/usr.sbin/bsdconfig/mouse/flags
index 21478de..06218ac 100755
--- a/usr.sbin/bsdconfig/mouse/flags
+++ b/usr.sbin/bsdconfig/mouse/flags
@@ -30,6 +30,7 @@
BSDCFG_SHARE="/usr/share/bsdconfig"
. $BSDCFG_SHARE/common.subr || exit 1
+f_dprintf "%s: loading includes..." "$0"
f_include $BSDCFG_SHARE/dialog.subr
f_include $BSDCFG_SHARE/mustberoot.subr
f_include $BSDCFG_SHARE/sysrc.subr
@@ -65,7 +66,6 @@ shift $(( $OPTIND - 1 ))
#
# Initialize
#
-f_dialog_init
f_dialog_title "$msg_mouse_flags"
f_dialog_backtitle "${ipgm:+bsdconfig }$pgm"
f_mustberoot_init
@@ -79,32 +79,10 @@ flags=$( f_sysrc_get moused_flags )
# Prompt the user with the current value
#
f_dialog_title "$msg_value_required"
-title="$DIALOG_TITLE"
-btitle="$DIALOG_BACKTITLE"
+flags=$( f_dialog_input "$msg_please_specify_the_mouse_daemon_flags" \
+ "$flags"
+ ) || f_die
f_dialog_title_restore
-hline=
-prompt="$msg_please_specify_the_mouse_daemon_flags"
-size=$( f_dialog_inputbox_size \
- "$title" \
- "$btitle" \
- "$prompt" \
- "$flags" \
- "$hline" )
-dialog_inputbox=$( eval $DIALOG \
- --title \"\$title\" \
- --backtitle \"\$btitle\" \
- --hline \"\$hline\" \
- --ok-label \"\$msg_ok\" \
- --cancel-label \"\$msg_cancel\" \
- --inputbox \"\$prompt\" $size \
- \"\$flags\" \
- 2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD
-)
-retval=$?
-setvar MENU_INPUTBOX_$$ "$dialog_inputbox"
-flags=$( f_dialog_inputstr )
-
-[ $retval -eq $SUCCESS ] || f_die
#
# Save the new value
diff --git a/usr.sbin/bsdconfig/mouse/mouse b/usr.sbin/bsdconfig/mouse/mouse
index 17cd846..95d7677 100755
--- a/usr.sbin/bsdconfig/mouse/mouse
+++ b/usr.sbin/bsdconfig/mouse/mouse
@@ -30,6 +30,7 @@
BSDCFG_SHARE="/usr/share/bsdconfig"
. $BSDCFG_SHARE/common.subr || exit 1
+f_dprintf "%s: loading includes..." "$0"
f_include $BSDCFG_SHARE/dialog.subr
f_include $BSDCFG_SHARE/mustberoot.subr
@@ -101,7 +102,6 @@ shift $(( $OPTIND - 1 ))
#
# Initialize
#
-f_dialog_init
f_dialog_title "$msg_please_configure_your_mouse"
f_dialog_backtitle "${ipgm:+bsdconfig }$pgm"
f_mustberoot_init
diff --git a/usr.sbin/bsdconfig/mouse/port b/usr.sbin/bsdconfig/mouse/port
index e14bf0a..87d4a0b 100755
--- a/usr.sbin/bsdconfig/mouse/port
+++ b/usr.sbin/bsdconfig/mouse/port
@@ -30,6 +30,7 @@
BSDCFG_SHARE="/usr/share/bsdconfig"
. $BSDCFG_SHARE/common.subr || exit 1
+f_dprintf "%s: loading includes..." "$0"
f_include $BSDCFG_SHARE/dialog.subr
f_include $BSDCFG_SHARE/mustberoot.subr
f_include $BSDCFG_SHARE/sysrc.subr
@@ -102,7 +103,6 @@ shift $(( $OPTIND - 1 ))
#
# Initialize
#
-f_dialog_init
f_dialog_title "$msg_select_your_mouse_port_from_the_following_menu"
f_dialog_backtitle "${ipgm:+bsdconfig }$pgm"
f_mustberoot_init
diff --git a/usr.sbin/bsdconfig/mouse/type b/usr.sbin/bsdconfig/mouse/type
index e4f99be..ee9c4ed 100755
--- a/usr.sbin/bsdconfig/mouse/type
+++ b/usr.sbin/bsdconfig/mouse/type
@@ -30,6 +30,7 @@
BSDCFG_SHARE="/usr/share/bsdconfig"
. $BSDCFG_SHARE/common.subr || exit 1
+f_dprintf "%s: loading includes..." "$0"
f_include $BSDCFG_SHARE/dialog.subr
f_include $BSDCFG_SHARE/mustberoot.subr
f_include $BSDCFG_SHARE/sysrc.subr
@@ -106,7 +107,6 @@ shift $(( $OPTIND - 1 ))
#
# Initialize
#
-f_dialog_init
f_dialog_title "$msg_select_a_protocol_type_for_your_mouse"
f_dialog_backtitle "${ipgm:+bsdconfig }$pgm"
f_mustberoot_init
diff --git a/usr.sbin/bsdconfig/networking/defaultrouter b/usr.sbin/bsdconfig/networking/defaultrouter
index cc9902d..44e522e 100755
--- a/usr.sbin/bsdconfig/networking/defaultrouter
+++ b/usr.sbin/bsdconfig/networking/defaultrouter
@@ -30,6 +30,7 @@
BSDCFG_SHARE="/usr/share/bsdconfig"
. $BSDCFG_SHARE/common.subr || exit 1
+f_dprintf "%s: loading includes..." "$0"
f_include $BSDCFG_SHARE/dialog.subr
f_include $BSDCFG_SHARE/mustberoot.subr
f_include $BSDCFG_SHARE/networking/routing.subr
@@ -58,7 +59,6 @@ shift $(( $OPTIND - 1 ))
#
# Initialize
#
-f_dialog_init
f_dialog_title "$msg_default_router"
f_dialog_backtitle "${ipgm:+bsdconfig }$pgm"
f_mustberoot_init
diff --git a/usr.sbin/bsdconfig/networking/devices b/usr.sbin/bsdconfig/networking/devices
index 1386e01..443294f 100755
--- a/usr.sbin/bsdconfig/networking/devices
+++ b/usr.sbin/bsdconfig/networking/devices
@@ -30,6 +30,7 @@
BSDCFG_SHARE="/usr/share/bsdconfig"
. $BSDCFG_SHARE/common.subr || exit 1
+f_dprintf "%s: loading includes..." "$0"
f_include $BSDCFG_SHARE/dialog.subr
f_include $BSDCFG_SHARE/mustberoot.subr
f_include $BSDCFG_SHARE/sysrc.subr
@@ -62,7 +63,6 @@ shift $(( $OPTIND - 1 ))
#
# Initialize
#
-f_dialog_init
f_dialog_title "$msg_networking_devices"
f_dialog_backtitle "${ipgm:+bsdconfig }$pgm"
f_mustberoot_init
diff --git a/usr.sbin/bsdconfig/networking/hostname b/usr.sbin/bsdconfig/networking/hostname
index db05678..231320e 100755
--- a/usr.sbin/bsdconfig/networking/hostname
+++ b/usr.sbin/bsdconfig/networking/hostname
@@ -30,6 +30,7 @@
BSDCFG_SHARE="/usr/share/bsdconfig"
. $BSDCFG_SHARE/common.subr || exit 1
+f_dprintf "%s: loading includes..." "$0"
f_include $BSDCFG_SHARE/dialog.subr
f_include $BSDCFG_SHARE/mustberoot.subr
f_include $BSDCFG_SHARE/networking/hostname.subr
@@ -58,7 +59,6 @@ shift $(( $OPTIND - 1 ))
#
# Initialize
#
-f_dialog_init
f_dialog_title "$msg_hostname_domain"
f_dialog_backtitle "${ipgm:+bsdconfig }$pgm"
f_mustberoot_init
diff --git a/usr.sbin/bsdconfig/networking/nameservers b/usr.sbin/bsdconfig/networking/nameservers
index c9b3004..9ebebc8 100755
--- a/usr.sbin/bsdconfig/networking/nameservers
+++ b/usr.sbin/bsdconfig/networking/nameservers
@@ -30,6 +30,7 @@
BSDCFG_SHARE="/usr/share/bsdconfig"
. $BSDCFG_SHARE/common.subr || exit 1
+f_dprintf "%s: loading includes..." "$0"
f_include $BSDCFG_SHARE/dialog.subr
f_include $BSDCFG_SHARE/mustberoot.subr
f_include $BSDCFG_SHARE/networking/resolv.subr
@@ -58,7 +59,6 @@ shift $(( $OPTIND - 1 ))
#
# Initialize
#
-f_dialog_init
f_dialog_title "$msg_dns_nameservers"
f_dialog_backtitle "${ipgm:+bsdconfig }$pgm"
f_mustberoot_init
diff --git a/usr.sbin/bsdconfig/networking/networking b/usr.sbin/bsdconfig/networking/networking
index fae5c9f..8acfbde 100755
--- a/usr.sbin/bsdconfig/networking/networking
+++ b/usr.sbin/bsdconfig/networking/networking
@@ -30,6 +30,7 @@
BSDCFG_SHARE="/usr/share/bsdconfig"
. $BSDCFG_SHARE/common.subr || exit 1
+f_dprintf "%s: loading includes..." "$0"
f_include $BSDCFG_SHARE/dialog.subr
f_include $BSDCFG_SHARE/mustberoot.subr
@@ -98,7 +99,6 @@ shift $(( $OPTIND - 1 ))
#
# Initialize
#
-f_dialog_init
f_dialog_title "$msg_network_management"
f_dialog_backtitle "${ipgm:+bsdconfig }$pgm"
f_mustberoot_init
diff --git a/usr.sbin/bsdconfig/networking/share/common.subr b/usr.sbin/bsdconfig/networking/share/common.subr
index e8970d0..e501a9c 100644
--- a/usr.sbin/bsdconfig/networking/share/common.subr
+++ b/usr.sbin/bsdconfig/networking/share/common.subr
@@ -62,4 +62,8 @@ f_nfs_mounted()
[ "$( df -t nfs )" ]
}
+############################################################ MAIN
+
+f_dprintf "%s: Successfully loaded." networking/common.subr
+
fi # ! $_NETWORKING_COMMON_SUBR
diff --git a/usr.sbin/bsdconfig/networking/share/device.subr b/usr.sbin/bsdconfig/networking/share/device.subr
index 4f870af..f77a5e7 100644
--- a/usr.sbin/bsdconfig/networking/share/device.subr
+++ b/usr.sbin/bsdconfig/networking/share/device.subr
@@ -30,6 +30,7 @@ if [ ! "$_NETWORKING_DEVICE_SUBR" ]; then _NETWORKING_DEVICE_SUBR=1
BSDCFG_SHARE="/usr/share/bsdconfig"
. $BSDCFG_SHARE/common.subr || exit 1
+f_dprintf "%s: loading includes..." networking/device.subr
f_include $BSDCFG_SHARE/dialog.subr
f_include $BSDCFG_SHARE/sysrc.subr
f_include $BSDCFG_SHARE/networking/common.subr
@@ -378,11 +379,7 @@ f_dialog_menu_netdev_edit()
if f_nfs_mounted && ! f_jailed; then
local setting="$( printf "$msg_current_dhcp_status" \
"$interface" "$dhcp_status" )"
- local message="$(
- printf "$msg_nfs_mounts_may_cause_hang" \
- "$setting"
- )"
- f_dialog_msgbox "$message"
+ f_show_msg "$msg_nfs_mounts_may_cause_hang" "$setting"
continue
fi
@@ -440,8 +437,7 @@ f_dialog_menu_netdev_edit()
"$options" != "$options_orig" -o \
"$dhcp" != "$dhcp_orig" ]
then
- f_dialog_info "$( printf "$msg_saving_network_interface" \
- "$interface" )"
+ f_show_info "$msg_saving_network_interface" "$interface"
local value=
if [ "$dhcp" ]; then
@@ -462,8 +458,7 @@ f_dialog_menu_netdev_edit()
f_dialog_yesno "Would you like to bring the $interface" \
"interface up right now?"
if [ $? -eq $SUCCESS ]; then
- f_dialog_info "$( printf "$msg_bring_interface_up" \
- "$interface" )"
+ f_show_info "$msg_bring_interface_up" "$interface"
local dr="$( f_sysrc_get defaultrouter )" err
if [ "$dr" = "NO" -o ! "$dr" ]; then
@@ -501,4 +496,8 @@ f_dialog_menu_netdev_edit()
return $SUCCESS
}
+############################################################ MAIN
+
+f_dprintf "%s: Successfully loaded." networking/device.subr
+
fi # ! $_NETWORKING_DEVICE_SUBR
diff --git a/usr.sbin/bsdconfig/networking/share/hostname.subr b/usr.sbin/bsdconfig/networking/share/hostname.subr
index fed8679..959c7df 100644
--- a/usr.sbin/bsdconfig/networking/share/hostname.subr
+++ b/usr.sbin/bsdconfig/networking/share/hostname.subr
@@ -30,6 +30,7 @@ if [ ! "$_NETWORKING_HOSTNAME_SUBR" ]; then _NETWORKING_HOSTNAME_SUBR=1
BSDCFG_SHARE="/usr/share/bsdconfig"
. $BSDCFG_SHARE/common.subr || exit 1
+f_dprintf "%s: loading includes..." networking/hostname.subr
f_include $BSDCFG_SHARE/sysrc.subr
f_include $BSDCFG_SHARE/dialog.subr
f_include $BSDCFG_SHARE/networking/common.subr
@@ -40,7 +41,7 @@ f_include_lang $BSDCFG_LIBE/$APP_DIR/include/messages.subr
############################################################ FUNCTIONS
-# f_dialog_validate_hostname $hostname
+# f_validate_hostname $hostname
#
# Returns zero if the given argument (a fully-qualified hostname) is compliant
# with standards set-forth in RFC's 952 and 1123 of the Network Working Group:
@@ -65,9 +66,9 @@ f_include_lang $BSDCFG_LIBE/$APP_DIR/include/messages.subr
# 3 One or more individual labels within the hostname are null.
#
# If the hostname is determined to be invalid, the appropriate error will be
-# displayed using the f_dialog_msgbox function.
+# displayed using the f_show_msg function.
#
-f_dialog_validate_hostname()
+f_validate_hostname()
{
local fqhn="$1"
@@ -95,23 +96,51 @@ f_dialog_validate_hostname()
done
)
+}
- #
- # Produce an appropriate error message if necessary.
- #
- local retval=$?
- case $retval in
- 1) f_dialog_msgbox "$( printf \
- "$msg_hostname_label_contains_invalid_chars" "$fqhn" )";;
- 2) f_dialog_msgbox "$( printf \
- "$msg_hostname_label_starts_or_ends_with_hyphen" "$fqhn" )";;
- 3) f_dialog_msgbox "$( printf \
- "$msg_hostname_label_is_null" "$fqhn" )";;
- 63) f_dialog_msgbox "$( printf \
- "$msg_hostname_label_exceeds_max_length" "$fqhn" )";;
- 255) f_dialog_msgbox "$( printf \
- "$msg_hostname_exceeds_max_length" "$fqhn" )";;
+# f_dialog_hnerror $error $hostname
+#
+# Display a msgbox with the appropriate error message for an error returned by
+# the f_validate_hostname function.
+#
+f_dialog_hnerror()
+{
+ local error="$1" fqhn="$2"
+
+ [ ${error:-0} -ne 0 ] || return $SUCCESS
+
+ case "$error" in
+ 1) f_show_msg "$msg_hostname_label_contains_invalid_chars" "$fqhn";;
+ 2) f_show_msg "$msg_hostname_label_starts_or_ends_with_hyphen" "$fqhn";;
+ 3) f_show_msg "$msg_hostname_label_is_null" "$fqhn";;
+ 63) f_show_msg "$msg_hostname_label_exceeds_max_length" "$fqhn";;
+ 255) f_show_msg "$msg_hostname_exceeds_max_length" "$fqhn";;
esac
+}
+
+# f_dialog_validate_hostname $hostname
+#
+# Returns zero if the given argument (a fully-qualified hostname) is compliant
+# with standards set-forth in RFC's 952 and 1123 of the Network Working Group:
+#
+# RFC 952 - DoD Internet host table specification
+# http://tools.ietf.org/html/rfc952
+#
+# RFC 1123 - Requirements for Internet Hosts - Application and Support
+# http://tools.ietf.org/html/rfc1123
+#
+# If the hostname is determined to be invalid, the appropriate error will be
+# displayed using the f_dialog_hnerror function above.
+#
+f_dialog_validate_hostname()
+{
+ local fqhn="$1"
+
+ f_validate_hostname "$fqhn"
+ local retval=$?
+
+ # Produce an appropriate error message if necessary.
+ [ $retval -eq $SUCCESS ] || f_dialog_hnerror $retval "$fqhn"
return $retval
}
@@ -132,41 +161,15 @@ f_dialog_input_hostname()
msg="$msg_please_enter_fqhn"
fi
- local hline="$hline_alnum_punc_tab_enter"
-
#
# Loop until the user provides taint-free input.
#
- local size height width
while :; do
-
- size=$( f_dialog_inputbox_size \
- "$DIALOG_TITLE" \
- "$DIALOG_BACKTITLE" \
- "$msg" \
- "$hostname" \
- "$hline" )
- local dialog_inputbox
- dialog_inputbox=$( eval $DIALOG \
- --title \"\$DIALOG_TITLE\" \
- --backtitle \"\$DIALOG_BACKTITLE\" \
- --hline \"\$hline\" \
- --ok-label \"\$msg_ok\" \
- --cancel-label \"\$msg_cancel\" \
- --inputbox \"\$msg\" $size \
- \"\$hostname\" \
- 2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD
- )
-
- local retval=$?
- setvar DIALOG_INPUTBOX_$$ "$dialog_inputbox"
- hostname=$( f_dialog_inputstr )
-
- [ $retval -eq $SUCCESS ] || return $retval
-
+ hostname=$( f_dialog_input "$msg" "$hostname" \
+ "$hline_alnum_punc_tab_enter"
+ ) || return
# Taint-check the user's input
f_dialog_validate_hostname "$hostname" && break
-
done
#
@@ -187,7 +190,7 @@ f_dialog_input_hostname()
# the stored configuration (in rc.conf(5)).
#
if [ "$( hostname )" != "$( f_sysrc_get hostname )" ]; then
- [ ! "$USE_XDIALOG" ] && dialog_clear
+ [ ! "$USE_XDIALOG" ] && f_dialog_clear
#
# If connected via ssh(1) and performing X11-Forwarding, don't
@@ -195,10 +198,8 @@ f_dialog_input_hostname()
# "X11 connection rejected because of wrong authentication."
#
if [ "$USE_XDIALOG" -a "$SSH_CONNECTION" ]; then
- f_dialog_msgbox "$(
- printf "$msg_activate_hostname_x11warning" \
- "$( hostname )" "$hostname"
- )"
+ f_show_msg "$msg_activate_hostname_x11warning" \
+ "$( hostname )" "$hostname"
else
f_dialog_yesno "$(
printf "$msg_activate_hostname" \
@@ -211,4 +212,8 @@ f_dialog_input_hostname()
return $SUCCESS
}
+############################################################ MAIN
+
+f_dprintf "%s: Successfully loaded." networking/hostname.subr
+
fi # ! $_NETWORKING_HOSTNAME_SUBR
diff --git a/usr.sbin/bsdconfig/networking/share/ipaddr.subr b/usr.sbin/bsdconfig/networking/share/ipaddr.subr
index 65c2b98..d5398e5 100644
--- a/usr.sbin/bsdconfig/networking/share/ipaddr.subr
+++ b/usr.sbin/bsdconfig/networking/share/ipaddr.subr
@@ -30,7 +30,7 @@ if [ ! "$_NETWORKING_IPADDR_SUBR" ]; then _NETWORKING_IPADDR_SUBR=1
BSDCFG_SHARE="/usr/share/bsdconfig"
. $BSDCFG_SHARE/common.subr || exit 1
-f_include $BSDCFG_SHARE/sysrc.subr
+f_dprintf "%s: loading includes..." networking/ipaddr.subr
f_include $BSDCFG_SHARE/dialog.subr
f_include $BSDCFG_SHARE/strings.subr
f_include $BSDCFG_SHARE/networking/common.subr
@@ -104,6 +104,7 @@ f_validate_ipaddr()
[ $noctets -eq 4 ] || exit 4
)
}
+
# f_dialog_iperror $error $ipaddr
#
# Display a msgbox with the appropriate error message for an error returned by
@@ -116,14 +117,10 @@ f_dialog_iperror()
[ ${error:-0} -ne 0 ] || return $SUCCESS
case "$error" in
- 1) f_dialog_msgbox "$( printf \
- "$msg_ipv4_addr_octet_contains_invalid_chars" "$ip" )";;
- 2) f_dialog_msgbox "$( printf \
- "$msg_ipv4_addr_octet_is_null" "$ip" )";;
- 3) f_dialog_msgbox "$( printf \
- "$msg_ipv4_addr_octet_exceeds_max_value" "$ip" )";;
- 4) f_dialog_msgbox "$( printf \
- "$msg_ipv4_addr_octet_missing_or_extra" "$ip" )";;
+ 1) f_show_msg "$msg_ipv4_addr_octet_contains_invalid_chars" "$ip";;
+ 2) f_show_msg "$msg_ipv4_addr_octet_is_null" "$ip";;
+ 3) f_show_msg "$msg_ipv4_addr_octet_exceeds_max_value" "$ip";;
+ 4) f_show_msg "$msg_ipv4_addr_octet_missing_or_extra" "$ip";;
esac
}
@@ -294,14 +291,10 @@ f_dialog_ip6error()
[ ${error:-0} -ne 0 ] || return $SUCCESS
case "$error" in
- 1) f_dialog_msgbox "$( printf \
- "$msg_ipv6_addr_segment_contains_invalid_chars" "$ip" )";;
- 2) f_dialog_msgbox "$( printf \
- "$msg_ipv6_addr_too_many_null_segments" "$ip" )";;
- 3) f_dialog_msgbox "$( printf \
- "$msg_ipv6_addr_segment_contains_too_many_chars" "$ip" )";;
- 4) f_dialog_msgbox "$( printf \
- "$msg_ipv6_addr_too_few_or_extra_segments" "$ip" )";;
+ 1) f_show_msg "$msg_ipv6_addr_segment_contains_invalid_chars" "$ip";;
+ 2) f_show_msg "$msg_ipv6_addr_too_many_null_segments" "$ip";;
+ 3) f_show_msg "$msg_ipv6_addr_segment_contains_too_many_chars" "$ip";;
+ 4) f_show_msg "$msg_ipv6_addr_too_few_or_extra_segments" "$ip";;
*)
if [ $(( $error & 0xF )) -eq 5 ]; then
# IPv4 at the end of IPv6 address is invalid
@@ -353,48 +346,26 @@ f_dialog_input_ipaddr()
if f_nfs_mounted && ! f_jailed; then
local setting="$( printf "$msg_current_ipaddr" \
"$interface" "$_ipaddr" )"
- local message="$( printf "$msg_nfs_mounts_may_cause_hang" \
- "$setting" )"
- f_dialog_msgbox "$message"
+ f_show_msg "$msg_nfs_mounts_may_cause_hang" "$setting"
return $FAILURE
fi
local msg="$( printf "$msg_please_enter_new_ip_addr" "$interface" )"
- local hline="$hline_num_punc_tab_enter"
- local size="$( f_dialog_inputbox_size \
- "$DIALOG_TITLE" \
- "$DIALOG_BACKTITLE" \
- "$msg" \
- "$_ipaddr" \
- "$hline" )"
#
# Loop until the user provides taint-free input.
#
+ local retval
while :; do
- local dialog_inputbox
- dialog_inputbox=$( eval $DIALOG \
- --title \"\$DIALOG_TITLE\" \
- --backtitle \"\$DIALOG_BACKTITLE\" \
- --hline \"\$hline\" \
- --ok-label \"\$msg_ok\" \
- --cancel-label \"\$msg_cancel\" \
- --inputbox \"\$msg\" $size \
- \"\$_ipaddr\" \
- 2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD
- )
-
- local retval=$?
- setvar DIALOG_INPUTBOX_$$ "$dialog_inputbox"
- _input=$( f_dialog_inputstr )
-
#
# Return error status if:
- # - User has not made any changes to the given value
# - User has either pressed ESC or chosen Cancel/No
+ # - User has not made any changes to the given value
#
+ _input=$( f_dialog_input "$msg" "$_ipaddr" \
+ "$hline_num_punc_tab_enter"
+ ) || return
[ "$_ipaddr" = "$_input" ] && return $FAILURE
- [ $retval -eq $SUCCESS ] || return $retval
# Return success if NULL value was entered
[ "$_input" ] || return $SUCCESS
@@ -441,4 +412,8 @@ f_dialog_input_ipaddr()
return $SUCCESS
}
+############################################################ MAIN
+
+f_dprintf "%s: Successfully loaded." networking/ipaddr.subr
+
fi # ! $_NETWORKING_IPADDR_SUBR
diff --git a/usr.sbin/bsdconfig/networking/share/media.subr b/usr.sbin/bsdconfig/networking/share/media.subr
index e7da98a..eed8364a 100644
--- a/usr.sbin/bsdconfig/networking/share/media.subr
+++ b/usr.sbin/bsdconfig/networking/share/media.subr
@@ -30,6 +30,7 @@ if [ ! "$_NETWORKING_MEDIA_SUBR" ]; then _NETWORKING_MEDIA_SUBR=1
BSDCFG_SHARE="/usr/share/bsdconfig"
. $BSDCFG_SHARE/common.subr || exit 1
+f_dprintf "%s: loading includes..." networking/media.subr
f_include $BSDCFG_SHARE/dialog.subr
f_include $BSDCFG_SHARE/strings.subr
f_include $BSDCFG_SHARE/sysrc.subr
@@ -114,9 +115,7 @@ f_dialog_input_options()
if f_nfs_mounted && ! f_jailed; then
local setting="$( printf "$msg_current_options" \
"$interface" "$options" )"
- local message="$( printf "$msg_nfs_mounts_may_cause_hang" \
- "$setting" )"
- f_dialog_msgbox "$message"
+ f_show_msg "$msg_nfs_mounts_may_cause_hang" "$setting"
return $FAILURE
fi
@@ -165,9 +164,7 @@ f_dialog_menu_media_options()
if f_nfs_mounted && ! f_jailed; then
local setting="$( printf "$msg_current_options" \
"$interface" "$_options" )"
- local message="$( printf "$msg_nfs_mounts_may_cause_hang" \
- "$setting" )"
- f_dialog_msgbox "$message"
+ f_show_msg "$msg_nfs_mounts_may_cause_hang" "$setting"
return $FAILURE
fi
@@ -238,4 +235,8 @@ f_dialog_menu_media_options()
return $retval
}
+############################################################ MAIN
+
+f_dprintf "%s: Successfully loaded." networking/media.subr
+
fi # ! $_NETWORKING_MEDIA_SUBR
diff --git a/usr.sbin/bsdconfig/networking/share/netmask.subr b/usr.sbin/bsdconfig/networking/share/netmask.subr
index 2f2b378..3a8665d 100644
--- a/usr.sbin/bsdconfig/networking/share/netmask.subr
+++ b/usr.sbin/bsdconfig/networking/share/netmask.subr
@@ -30,6 +30,7 @@ if [ ! "$_NETWORKING_NETMASK_SUBR" ]; then _NETWORKING_NETMASK_SUBR=1
BSDCFG_SHARE="/usr/share/bsdconfig"
. $BSDCFG_SHARE/common.subr || exit 1
+f_dprintf "%s: loading includes..." networking/netmask.subr
f_include $BSDCFG_SHARE/dialog.subr
f_include $BSDCFG_SHARE/strings.subr
f_include $BSDCFG_SHARE/networking/common.subr
@@ -69,7 +70,7 @@ f_ifconfig_netmask()
echo $netmask
}
-# f_dialog_validate_netmask $netmask
+# f_validate_netmask $netmask
#
# Returns zero if the given argument (a subnet mask) is of the proper format.
#
@@ -85,10 +86,7 @@ f_ifconfig_netmask()
# invalid integer (only 0,128,192,224,240,248,252,254,255 are
# valid integers).
#
-# If the subnet mask is determined to be invalid, the appropriate error will be
-# displayed using the f_dialog_msgbox function.
-#
-f_dialog_validate_netmask()
+f_validate_netmask()
{
local mask="$1"
@@ -121,23 +119,44 @@ f_dialog_validate_netmask()
[ $nfields -eq 4 ] || exit 4
)
+}
- #
- # Produce an appropriate error message if necessary.
- #
- local retval=$?
- case $retval in
- 1) f_dialog_msgbox "$( printf \
- "$msg_ipv4_mask_field_contains_invalid_chars" "$mask" )";;
- 2) f_dialog_msgbox "$( printf \
- "$msg_ipv4_mask_field_is_null" "$mask" )";;
- 3) f_dialog_msgbox "$( printf \
- "$msg_ipv4_mask_field_exceeds_max_value" "$mask" )";;
- 4) f_dialog_msgbox "$( printf \
- "$msg_ipv4_mask_field_missing_or_extra" "$mask" )";;
- 5) f_dialog_msgbox "$( printf \
- "$msg_ipv4_mask_field_invalid_value" "$mask" )";;
+# f_dialog_maskerror $error $netmask
+#
+# Display a msgbox with the appropriate error message for an error returned by
+# the f_validate_netmask function.
+#
+f_dialog_maskerror()
+{
+ local error="$1" netmask="$2"
+
+ [ ${error:-0} -ne 0 ] || return $SUCCESS
+
+ case "$error" in
+ 1) f_show_msg "$msg_ipv4_mask_field_contains_invalid_chars" "$mask";;
+ 2) f_show_msg "$msg_ipv4_mask_field_is_null" "$mask";;
+ 3) f_show_msg "$msg_ipv4_mask_field_exceeds_max_value" "$mask";;
+ 4) f_show_msg "$msg_ipv4_mask_field_missing_or_extra" "$mask";;
+ 5) f_show_msg "$msg_ipv4_mask_field_invalid_value" "$mask";;
esac
+}
+
+# f_dialog_validate_netmask $netmask
+#
+# Returns zero if the given argument (a subnet mask) is of the proper format.
+#
+# If the subnet mask is determined to be invalid, the appropriate error will be
+# displayed using the f_dialog_maskerror function above.
+#
+f_dialog_validate_netmask()
+{
+ local netmask="$1"
+
+ f_validate_netmask "$netmask"
+ local retval=$?
+
+ # Produce an appropriate error message if necessary.
+ [ $retval -eq $SUCCESS ] || f_dialog_maskerror $retval "$netmask"
return $retval
}
@@ -158,48 +177,24 @@ f_dialog_input_netmask()
if f_nfs_mounted && ! f_jailed; then
local setting="$( printf "$msg_current_subnet" \
"$interface" "$_netmask" )"
- local message="$( printf "$msg_nfs_mounts_may_cause_hang" \
- "$setting" )"
- f_dialog_msgbox "$message"
+ f_show_msg "$msg_nfs_mounts_may_cause_hang" "$setting"
return $FAILURE
fi
- local msg="$( printf "$msg_please_enter_subnet_mask" "$interface" )"
- local hline="$hline_num_punc_tab_enter"
- local size="$( f_dialog_inputbox_size \
- "$DIALOG_TITLE" \
- "$DIALOG_BACKTITLE" \
- "$msg" \
- "$_netmask" \
- "$hline" )"
-
#
# Loop until the user provides taint-free input.
#
+ local msg="$( printf "$msg_please_enter_subnet_mask" "$interface" )"
while :; do
- local dialog_inputbox
- dialog_inputbox=$( eval $DIALOG \
- --title \"\$DIALOG_TITLE\" \
- --backtitle \"\$DIALOG_BACKTITLE\" \
- --hline \"\$hline\" \
- --ok-label \"\$msg_ok\" \
- --cancel-label \"\$msg_cancel\" \
- --inputbox \"\$msg\" $size \
- \"\$_netmask\" \
- 2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD
- )
-
- local retval=$?
- setvar DIALOG_INPUTBOX_$$ "$dialog_inputbox"
- _input=$( f_dialog_inputstr )
-
#
# Return error status if:
- # - User has not made any changes to the given value
# - User has either pressed ESC or chosen Cancel/No
+ # - User has not made any changes to the given value
#
+ _input=$( f_dialog_input "$msg" "$_netmask" \
+ "$hline_num_punc_tab_enter"
+ ) || return
[ "$_netmask" = "$_input" ] && return $FAILURE
- [ $retval -eq $SUCCESS ] || return $retval
# Return success if NULL value was entered
[ "$_input" ] || return $SUCCESS
@@ -215,4 +210,8 @@ f_dialog_input_netmask()
netmask="$_netmask"
}
+############################################################ MAIN
+
+f_dprintf "%s: Successfully loaded." networking/netmask.subr
+
fi # ! $_NETWORKING_NETMASK_SUBR
diff --git a/usr.sbin/bsdconfig/networking/share/resolv.subr b/usr.sbin/bsdconfig/networking/share/resolv.subr
index 154748b..7d9af3b 100644
--- a/usr.sbin/bsdconfig/networking/share/resolv.subr
+++ b/usr.sbin/bsdconfig/networking/share/resolv.subr
@@ -30,6 +30,7 @@ if [ ! "$_NETWORKING_RESOLV_SUBR" ]; then _NETWORKING_RESOLV_SUBR=1
BSDCFG_SHARE="/usr/share/bsdconfig"
. $BSDCFG_SHARE/common.subr || exit 1
+f_dprintf "%s: loading includes..." networking/resolv.subr
f_include $BSDCFG_SHARE/dialog.subr
f_include $BSDCFG_SHARE/strings.subr
f_include $BSDCFG_SHARE/networking/common.subr
@@ -329,36 +330,13 @@ f_dialog_input_nameserver()
msg="$msg_please_enter_nameserver"
fi
- local hline="$hline_num_punc_tab_enter"
- local size="$( f_dialog_inputbox_size \
- "$DIALOG_TITLE" \
- "$DIALOG_BACKTITLE" \
- "$msg" \
- "$ns" \
- "$hline" )"
-
#
# Loop until the user provides taint-free input.
#
while :; do
-
- local dialog_inputbox
- dialog_inputbox=$( eval $DIALOG \
- --title \"\$DIALOG_TITLE\" \
- --backtitle \"\$DIALOG_BACKTITLE\" \
- --hline \"\$hline\" \
- --ok-label \"\$msg_ok\" \
- --cancel-label \"\$msg_cancel\" \
- --inputbox \"\$msg\" $size \
- \"\$ns\" \
- 2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD
- )
-
- local retval=$?
- setvar DIALOG_INPUTBOX_$$ "$dialog_inputbox"
- new_ns=$( f_dialog_inputstr )
-
- [ $retval -eq $SUCCESS ] || return $retval
+ new_ns=$( f_dialog_input "$msg" "$ns" \
+ "$hline_num_punc_tab_enter"
+ ) || return
# Take only the first "word" of the user's input
new_ns="${new_ns%%[$IFS]*}"
@@ -369,7 +347,6 @@ f_dialog_input_nameserver()
# Update prompt to allow user to re-edit previous entry
ns="$new_ns"
-
done
#
@@ -512,4 +489,8 @@ f_dialog_menu_nameservers()
done
}
+############################################################ MAIN
+
+f_dprintf "%s: Successfully loaded." networking/resolv.subr
+
fi # ! $_NETWORKING_RESOLV_SUBR
diff --git a/usr.sbin/bsdconfig/networking/share/routing.subr b/usr.sbin/bsdconfig/networking/share/routing.subr
index b8ccdcd..3990c03 100644
--- a/usr.sbin/bsdconfig/networking/share/routing.subr
+++ b/usr.sbin/bsdconfig/networking/share/routing.subr
@@ -30,6 +30,7 @@ if [ ! "$_NETWORKING_ROUTING_SUBR" ]; then _NETWORKING_ROUTING_SUBR=1
BSDCFG_SHARE="/usr/share/bsdconfig"
. $BSDCFG_SHARE/common.subr || exit 1
+f_dprintf "%s: loading includes..." networking/routing.subr
f_include $BSDCFG_SHARE/sysrc.subr
f_include $BSDCFG_SHARE/dialog.subr
f_include $BSDCFG_SHARE/networking/common.subr
@@ -91,41 +92,20 @@ f_dialog_input_defaultrouter()
if f_nfs_mounted && ! f_jailed; then
local setting="$( printf "$msg_current_default_router" \
"$defaultrouter" )"
- local message="$( printf "$msg_nfs_mounts_may_cause_hang" \
- "$setting" )"
- f_dialog_msgbox "$message"
+ f_show_msg "$msg_nfs_mounts_may_cause_hang" "$setting"
return $FAILURE
fi
- local msg="$msg_please_enter_default_router"
- local hline="$hline_num_punc_tab_enter"
- local size="$( f_dialog_inputbox_size \
- "$DIALOG_TITLE" \
- "$DIALOG_BACKTITLE" \
- "$msg" \
- "$defaultrouter" \
- "$hline" )"
-
#
# Loop until the user provides taint-free input.
#
+ local retval
while :; do
- local dialog_inputbox
- dialog_inputbox=$( eval $DIALOG \
- --title \"\$DIALOG_TITLE\" \
- --backtitle \"\$DIALOG_BACKTITLE\" \
- --hline \"\$hline\" \
- --ok-label \"\$msg_ok\" \
- --cancel-label \"\$msg_cancel\" \
- --inputbox \"\$msg\" $size \
- \"\$defaultrouter\" \
- 2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD
+ defaultrouter=$( f_dialog_input \
+ "$msg_please_enter_default_router" \
+ "$defaultrouter" "$hline_num_punc_tab_enter"
)
-
- local retval=$?
- setvar DIALOG_INPUTBOX_$$ "$dialog_inputbox"
- defaultrouter=$( f_dialog_inputstr )
-
+ retval=$?
[ "$defaultrouter" ] || return $SUCCESS
[ $retval -eq $SUCCESS ] || return $retval
@@ -168,4 +148,8 @@ f_dialog_input_defaultrouter()
fi
}
+############################################################ MAIN
+
+f_dprintf "%s: Successfully loaded." networking/routing.subr
+
fi # ! $_NETWORKING_ROUTING_SUBR
diff --git a/usr.sbin/bsdconfig/password/password b/usr.sbin/bsdconfig/password/password
index c060b50..6b9e57d 100755
--- a/usr.sbin/bsdconfig/password/password
+++ b/usr.sbin/bsdconfig/password/password
@@ -30,6 +30,7 @@
BSDCFG_SHARE="/usr/share/bsdconfig"
. $BSDCFG_SHARE/common.subr || exit 1
+f_dprintf "%s: loading includes..." "$0"
f_include $BSDCFG_SHARE/dialog.subr
f_include $BSDCFG_SHARE/mustberoot.subr
f_include $BSDCFG_SHARE/password/password.subr
@@ -64,7 +65,6 @@ shift $(( $OPTIND - 1 ))
#
# Initialize
#
-f_dialog_init
f_dialog_title "$msg_root_password"
f_dialog_backtitle "${ipgm:+bsdconfig }$pgm"
f_mustberoot_init
diff --git a/usr.sbin/bsdconfig/password/share/password.subr b/usr.sbin/bsdconfig/password/share/password.subr
index a0d1c50..bf83df7 100644
--- a/usr.sbin/bsdconfig/password/share/password.subr
+++ b/usr.sbin/bsdconfig/password/share/password.subr
@@ -30,6 +30,7 @@ if [ ! "$_PASSWORD_PASSWORD_SUBR" ]; then _PASSWORD_PASSWORD_SUBR=1
BSDCFG_SHARE="/usr/share/bsdconfig"
. $BSDCFG_SHARE/common.subr || exit 1
+f_dprintf "%s: loading includes..." password/password.subr
f_include $BSDCFG_SHARE/dialog.subr
BSDCFG_LIBE="/usr/libexec/bsdconfig" APP_DIR="040.password"
@@ -124,4 +125,8 @@ f_dialog_input_password()
return $SUCCESS
}
+############################################################ MAIN
+
+f_dprintf "%s: Successfully loaded." password/password.subr
+
fi # ! $_PASSWORD_PASSWORD_SUBR
diff --git a/usr.sbin/bsdconfig/security/kern_securelevel b/usr.sbin/bsdconfig/security/kern_securelevel
index e20e105..67fd1aa 100755
--- a/usr.sbin/bsdconfig/security/kern_securelevel
+++ b/usr.sbin/bsdconfig/security/kern_securelevel
@@ -30,6 +30,7 @@
BSDCFG_SHARE="/usr/share/bsdconfig"
. $BSDCFG_SHARE/common.subr || exit 1
+f_dprintf "%s: loading includes..." "$0"
f_include $BSDCFG_SHARE/dialog.subr
f_include $BSDCFG_SHARE/mustberoot.subr
f_include $BSDCFG_SHARE/sysrc.subr
@@ -105,7 +106,6 @@ shift $(( $OPTIND - 1 ))
#
# Initialize
#
-f_dialog_init
f_dialog_title "$msg_securelevels_menu_title"
f_dialog_backtitle "${ipgm:+bsdconfig }$pgm"
f_mustberoot_init
diff --git a/usr.sbin/bsdconfig/security/security b/usr.sbin/bsdconfig/security/security
index 1a3fefc..f503e51 100755
--- a/usr.sbin/bsdconfig/security/security
+++ b/usr.sbin/bsdconfig/security/security
@@ -30,6 +30,7 @@
BSDCFG_SHARE="/usr/share/bsdconfig"
. $BSDCFG_SHARE/common.subr || exit 1
+f_dprintf "%s: loading includes..." "$0"
f_include $BSDCFG_SHARE/dialog.subr
f_include $BSDCFG_SHARE/mustberoot.subr
f_include $BSDCFG_SHARE/sysrc.subr
@@ -120,7 +121,6 @@ shift $(( $OPTIND - 1 ))
#
# Initialize
#
-f_dialog_init
f_dialog_title "$msg_system_security_options_menu"
f_dialog_backtitle "${ipgm:+bsdconfig }$pgm"
f_mustberoot_init
diff --git a/usr.sbin/bsdconfig/share/common.subr b/usr.sbin/bsdconfig/share/common.subr
index 8050939..071325c 100644
--- a/usr.sbin/bsdconfig/share/common.subr
+++ b/usr.sbin/bsdconfig/share/common.subr
@@ -27,6 +27,15 @@ if [ ! "$_COMMON_SUBR" ]; then _COMMON_SUBR=1
#
# $FreeBSD$
#
+############################################################ CONFIGURATION
+
+#
+# Default file descriptors to link to stdout/stderr for passthru allowing
+# redirection within a sub-shell to bypass directly to the terminal.
+#
+: ${TERMINAL_STDOUT_PASSTHRU:=3}}
+: ${TERMINAL_STDERR_PASSTHRU:=4}}
+
############################################################ GLOBALS
#
@@ -46,15 +55,29 @@ ARGV="$@"
SUCCESS=0
FAILURE=1
+#
+# Operating environment details
+#
+export UNAME_S="$(uname -s)" # Operating System (i.e. FreeBSD)
+export UNAME_P="$(uname -p)" # Processor Architecture (i.e. i386)
+export UNAME_R="$(uname -r)" # Release Level (i.e. X.Y-RELEASE)
+
############################################################ FUNCTIONS
#
-# This is an empty function by default, to use it, copy
-# /usr/share/examples/bsdconfig/bsdconfigrc to $HOME/.bsdconfigrc
+# Sensible debug function. Override in ~/.bsdconfigrc if desired.
+# See /usr/share/examples/bsdconfig/bsdconfigrc for example.
#
f_dprintf()
{
- : this page intentionally left blank
+ [ "$debug" ] || return $SUCCESS
+ local fmt="$1"; shift
+ case "$debugFile" in ""|+*)
+ printf "DEBUG: $fmt${fmt:+\n}" "$@" >&${TERMINAL_STDOUT_PASSTHRU:-1}
+ esac
+ [ "${debugFile#+}" ] &&
+ printf "DEBUG: $fmt${fmt:+\n}" "$@" >> "${debugFile#+}"
+ return $SUCCESS
}
# f_err $fmt [ $opts ... ]
@@ -63,7 +86,7 @@ f_dprintf()
#
f_err()
{
- printf "$@" >&2
+ printf "$@" >&${TERMINAL_STDERR_PASSTHRU:-2}
}
# f_quietly $command [ $arguments ... ]
@@ -119,6 +142,27 @@ f_interrupt()
f_die
}
+# f_show_info $fmt [ $opts ... ]
+#
+# Display a message in a dialog infobox using printf(1) syntax.
+#
+f_show_info()
+{
+ local msg
+ msg=$( printf "$@" )
+
+ #
+ # Use f_dialog_infobox from dialog.subr if possible, otherwise fall
+ # back to dialog(1) (without options, making it obvious when using
+ # un-aided system dialog).
+ #
+ if f_have f_dialog_info; then
+ f_dialog_info "$msg"
+ else
+ dialog --infobox "$msg" 0 0
+ fi
+}
+
# f_show_msg $fmt [ $opts ... ]
#
# Display a message in a dialog box using printf(1) syntax.
@@ -181,6 +225,7 @@ f_show_help()
f_include()
{
local file="$1"
+ f_dprintf "f_include: file=[%s]" "$file"
. "$file" || exit $?
}
@@ -202,7 +247,7 @@ f_include_lang()
local file="$1"
local lang="${LANG:-$LC_ALL}"
- f_dprintf "lang=[$lang]"
+ f_dprintf "f_include_lang: file=[%s] lang=[%s]" "$file" "$lang"
if [ -f "$file.$lang" ]; then
. "$file.$lang" || exit $?
else
@@ -247,7 +292,7 @@ f_usage()
local file="$1"
local lang="${LANG:-$LC_ALL}"
- f_dprintf "lang=[$lang]"
+ f_dprintf "f_usage: file=[%s] lang=[%s]" "$file" "$lang"
shift 1 # file
@@ -300,7 +345,7 @@ f_index_file()
local keyword="$1"
local lang="${LANG:-$LC_ALL}"
- f_dprintf "lang=[$lang]"
+ f_dprintf "f_index_file: keyword=[%s] lang=[%s]" "$keyword" "$lang"
if [ "$lang" ]; then
awk -v keyword="$keyword" "$f_index_file_awk" \
@@ -362,7 +407,8 @@ f_index_menusel_keyword()
local indexfile="$1" pgm="$2"
local lang="${LANG:-$LC_ALL}"
- f_dprintf "lang=[$lang]"
+ f_dprintf "f_index_menusel_keyword: index=[%s] pgm=[%s] lang=[%s]" \
+ "$indexfile" "$pgm" "$lang"
if [ -f "$indexfile.$lang" ]; then
awk -v pgm="$pgm" \
@@ -424,7 +470,8 @@ f_index_menusel_command()
local indexfile="$1" keyword="$2" command
local lang="${LANG:-$LC_ALL}"
- f_dprintf "lang=[$lang]"
+ f_dprintf "f_index_menusel_command: index=[%s] key=[%s] lang=[%s]" \
+ "$indexfile" "$keyword" "$lang"
if [ -f "$indexfile.$lang" ]; then
command=$( awk -v key="$keyword" \
@@ -463,4 +510,42 @@ trap 'f_die' SIGTERM SIGPIPE SIGXCPU SIGXFSZ \
SIGFPE SIGTRAP SIGABRT SIGSEGV
trap '' SIGALRM SIGPROF SIGUSR1 SIGUSR2 SIGHUP SIGVTALRM
+#
+# Clone terminal stdout/stderr so we can redirect to it from within sub-shells
+#
+eval exec $TERMINAL_STDOUT_PASSTHRU\>\&1
+eval exec $TERMINAL_STDERR_PASSTHRU\>\&2
+
+#
+# Make debugging persistant if set
+#
+[ "$debug" ] && export debug
+
+#
+# Truncate the debug file upon initialization (now). Note that we will trim a
+# leading plus (`+') from the value of debugFile to support persistant meaning
+# that f_dprintf() should print both to standard output and $debugFile (minus
+# the leading plus, of course).
+#
+_debug_file="${debugFile#+}"
+if [ "$_debug_file" ]; then
+ if ( umask 022 && :> "$_debug_file" ); then
+ f_dprintf "Successfully initialized debugFile \`%s'" \
+ "$_debug_file"
+ else
+ unset debugFile
+ f_dprintf "Unable to initialize debugFile \`%s'" \
+ "$_debug_file"
+ fi
+fi
+unset _debug_file
+
+#
+# Log our operating environment for debugging purposes
+#
+f_dprintf "UNAME_S=[%s] UNAME_P=[%s] UNAME_R=[%s]" \
+ "$UNAME_S" "$UNAME_P" "$UNAME_R"
+
+f_dprintf "%s: Successfully loaded." common.subr
+
fi # ! $_COMMON_SUBR
diff --git a/usr.sbin/bsdconfig/share/dialog.subr b/usr.sbin/bsdconfig/share/dialog.subr
index bf10388..f614be2 100644
--- a/usr.sbin/bsdconfig/share/dialog.subr
+++ b/usr.sbin/bsdconfig/share/dialog.subr
@@ -30,6 +30,7 @@ if [ ! "$_DIALOG_SUBR" ]; then _DIALOG_SUBR=1
BSDCFG_SHARE="/usr/share/bsdconfig"
. $BSDCFG_SHARE/common.subr || exit 1
+f_dprintf "%s: loading includes..." dialog.subr
f_include $BSDCFG_SHARE/strings.subr
BSDCFG_LIBE="/usr/libexec/bsdconfig"
@@ -42,7 +43,7 @@ f_include_lang $BSDCFG_LIBE/include/messages.subr
# execution of dialog from within a sub-shell (so-long as its standard output
# is explicitly redirected to this file descriptor).
#
-: ${DIALOG_TERMINAL_PASSTHRU_FD:=3}
+: ${DIALOG_TERMINAL_PASSTHRU_FD:=${TERMINAL_STDOUT_PASSTHRU:-3}}
############################################################ GLOBALS
@@ -76,6 +77,11 @@ unset XDIALOG_INFOBOX_TIMEOUT
#
: ${DIALOG_SELF_INITIALIZE=1}
+#
+# Default terminal size (used if/when running without a controlling terminal)
+#
+: ${DEFAULT_TERMINAL_SIZE:=24 80}
+
############################################################ GENERIC FUNCTIONS
# f_dialog_title [$new_title]
@@ -192,7 +198,8 @@ f_dialog_infobox_size()
max_size="$XDIALOG_MAXSIZE" # see CONFIGURATION
else
min_width=24
- max_size=$( stty size ) # usually "24 80"
+ max_size=$( stty size 2> /dev/null ) # usually "24 80"
+ : ${max_size:=$DEFAULT_TERMINAL_SIZE}
fi
local max_height="${max_size%%[$IFS]*}"
@@ -324,7 +331,8 @@ f_dialog_buttonbox_size()
if [ "$USE_XDIALOG" ]; then
max_size="$XDIALOG_MAXSIZE" # see CONFIGURATION
else
- max_size=$( stty size ) # usually "24 80"
+ max_size=$( stty size 2> /dev/null ) # usually "24 80"
+ : ${max_size:=$DEFAULT_TERMINAL_SIZE}
fi
local max_height="${max_size%%[$IFS]*}"
[ $height -le $max_height ] || height=$max_height
@@ -362,7 +370,8 @@ f_dialog_inputbox_size()
max_size="$XDIALOG_MAXSIZE" # see CONFIGURATION
else
min_width=24
- max_size=$( stty size ) # usually "24 80"
+ max_size=$( stty size 2> /dev/null ) # usually "24 80"
+ : ${max_size:=$DEFAULT_TERMINAL_SIZE}
fi
local max_height="${max_size%%[$IFS]*}"
local max_width="${max_size##*[$IFS]}"
@@ -471,6 +480,7 @@ f_xdialog_2inputsbox_size()
# Add height for a second inputbox
height=$(( $height + 2 ))
+ [ $height -le $max_height ] || height=$max_height
#
# Bump width for second initial text (if not already at maximum width).
@@ -520,7 +530,8 @@ f_dialog_menu_size()
else
min_width=24
min_rows=0
- max_size=$( stty size ) # usually "24 80"
+ max_size=$( stty size 2> /dev/null ) # usually "24 80"
+ : ${max_size:=$DEFAULT_TERMINAL_SIZE}
fi
local max_width="${max_size##*[$IFS]}"
@@ -602,7 +613,8 @@ f_dialog_menu_with_help_size()
else
min_width=24
min_rows=0
- max_size=$( stty size ) # usually "24 80"
+ max_size=$( stty size 2> /dev/null ) # usually "24 80"
+ : ${max_size:=$DEFAULT_TERMINAL_SIZE}
fi
local max_width="${max_size##*[$IFS]}"
@@ -701,7 +713,8 @@ f_dialog_radiolist_size()
else
min_width=24
min_rows=0
- max_size=$( stty size ) # usually "24 80"
+ max_size=$( stty size 2> /dev/null ) # usually "24 80"
+ : ${max_size:=$DEFAULT_TERMINAL_SIZE}
fi
local max_width="${max_size##*[$IFS]}"
@@ -787,7 +800,8 @@ f_dialog_calendar_size()
else
min_height=0
min_width=40
- max_size=$( stty size ) # usually "24 80"
+ max_size=$( stty size 2> /dev/null ) # usually "24 80"
+ : ${max_size:=$DEFAULT_TERMINAL_SIZE}
fi
local max_height="${max_size%%[$IFS]*}"
local max_width="${max_size##*[$IFS]}"
@@ -865,7 +879,8 @@ f_dialog_timebox_size()
else
min_height=0
min_width=20
- max_size=$( stty size ) # usually "24 80"
+ max_size=$( stty size 2> /dev/null ) # usually "24 80"
+ : ${max_size:=$DEFAULT_TERMINAL_SIZE}
fi
local max_height="${max_size%%[$IFS]*}"
local max_width="${max_size##*[$IFS]}"
@@ -923,7 +938,7 @@ f_dialog_clear()
# f_dialog_info $info_text ...
#
# Throw up a dialog(1) infobox. The infobox remains until another dialog is
-# displayed or `dialog --clear' (or dialog_clear) is called.
+# displayed or `dialog --clear' (or f_dialog_clear) is called.
#
f_dialog_info()
{
@@ -1115,7 +1130,7 @@ f_dialog_noyes()
# f_dialog_inputstr
#
# Obtain the inputstr entered by the user from the most recently displayed
-# dialog(1) inputbox and clean up any temporary files.
+# dialog(1) inputbox and clean up any temporary files/variables.
#
f_dialog_inputstr()
{
@@ -1138,12 +1153,58 @@ f_dialog_inputstr()
return $SUCCESS
}
+# f_dialog_input $prompt [$init [$hline]]
+#
+# Prompt the user with a dialog(1) inputbox to enter some value. The inputbox
+# remains until the the user presses ENTER or ESC, or otherwise ends the
+# editing session, by selecting `Cancel' for example.
+#
+# If the user presses ENTER, the exit status is zero (success), otherwise if
+# the user presses ESC the exit status is 255, or if the user chose Cancel, the
+# exit status is instead 1.
+#
+# NOTE: The hline should correspond to the type of data you want from the user.
+# NOTE: Should not be used to edit multiline values.
+#
+f_dialog_input()
+{
+ local prompt="$1" init="$2" hline="$3"
+ local size="$( f_dialog_inputbox_size \
+ "$DIALOG_TITLE" \
+ "$DIALOG_BACKTITLE" \
+ "$prompt" \
+ "$init" \
+ "$hline" )"
+
+ local opterm="--"
+ [ "$USE_XDIALOG" ] && opterm=
+
+ local dialog_input
+ dialog_input=$(
+ eval $DIALOG \
+ --title \"\$DIALOG_TITLE\" \
+ --backtitle \"\$DIALOG_BACKTITLE\" \
+ --hline \"\$hline\" \
+ --ok-label \"\$msg_ok\" \
+ --cancel-label \"\$msg_cancel\" \
+ --inputbox \"\$prompt\" $size \
+ $opterm \"\$init\" \
+ 2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD
+ )
+ local retval=$?
+
+ setvar DIALOG_INPUTBOX_$$ "$dialog_input"
+ f_dialog_inputstr
+
+ return $retval
+}
+
############################################################ MENU FUNCTIONS
# f_dialog_menutag
#
# Obtain the menutag chosen by the user from the most recently displayed
-# dialog(1) menu and clean up any temporary files.
+# dialog(1) menu and clean up any temporary files/variables.
#
f_dialog_menutag()
{
@@ -1427,10 +1488,22 @@ f_dialog_init()
DIALOG_BACKTITLE="$_DIALOG_TITLE"
unset _DIALOG_TITLE
fi
+
+ f_dprintf "f_dialog_init: dialog(1) API initialized."
}
############################################################ MAIN
-[ "$DIALOG_SELF_INITIALIZE" ] && f_dialog_init
+#
+# Self-initialize unless requested otherwise
+#
+f_dprintf "%s: DIALOG_SELF_INITIALIZE=[%s]" \
+ dialog.subr "$DIALOG_SELF_INITIALIZE"
+case "$DIALOG_SELF_INITIALIZE" in
+""|0|[Nn][Oo]|[Oo][Ff][Ff]|[Ff][Aa][Ll][Ss][Ee]) : do nothing ;;
+*) f_dialog_init
+esac
+
+f_dprintf "%s: Successfully loaded." dialog.subr
fi # ! $_DIALOG_SUBR
diff --git a/usr.sbin/bsdconfig/share/mustberoot.subr b/usr.sbin/bsdconfig/share/mustberoot.subr
index ac0fd76..ebce9c1 100644
--- a/usr.sbin/bsdconfig/share/mustberoot.subr
+++ b/usr.sbin/bsdconfig/share/mustberoot.subr
@@ -30,6 +30,7 @@ if [ ! "$_MUSTBEROOT_SUBR" ]; then _MUSTBEROOT_SUBR=1
BSDCFG_SHARE="/usr/share/bsdconfig"
. $BSDCFG_SHARE/common.subr || exit 1
+f_dprintf "%s: loading includes..." mustberoot.subr
f_include $BSDCFG_SHARE/dialog.subr
BSDCFG_LIBE="/usr/libexec/bsdconfig"
@@ -338,16 +339,14 @@ f_authenticate_some_user()
case "$user" in
root|toor)
nfailures=$(( $nfailures + 1 ))
- f_dialog_msgbox "$( printf \
- "$msg_user_disallowed" "$user" )"
+ f_show_msg "$msg_user_disallowed" "$user"
continue
esac
fi
if ! f_quietly id "$user"; then
nfailures=$(( $nfailures + 1 ))
if [ "$SECURE_DIVULGE_UNKNOWN_USER" ]; then
- f_dialog_msgbox "$( printf \
- "$msg_unknown_user" "$user" )"
+ f_show_msg "$msg_unknown_user" "$user"
elif [ $nfailures -lt $PASSWD_TRIES ]; then
f_dialog_info "$msg_sorry_try_again"
sleep 1
@@ -421,4 +420,8 @@ f_mustberoot_init()
fi
}
+############################################################ MAIN
+
+f_dprintf "%s: Successfully loaded." mustberoot.subr
+
fi # ! $_MUSTBEROOT_SUBR
diff --git a/usr.sbin/bsdconfig/share/strings.subr b/usr.sbin/bsdconfig/share/strings.subr
index d11a9a2..6fe0f32 100644
--- a/usr.sbin/bsdconfig/share/strings.subr
+++ b/usr.sbin/bsdconfig/share/strings.subr
@@ -101,4 +101,6 @@ f_isinteger()
( : $((0/$arg)) ) > /dev/null 2>&1
}
+f_dprintf "%s: Successfully loaded." strings.subr
+
fi # ! $_STRINGS_SUBR
diff --git a/usr.sbin/bsdconfig/share/sysrc.subr b/usr.sbin/bsdconfig/share/sysrc.subr
index 1ee70e6..36a550e 100644
--- a/usr.sbin/bsdconfig/share/sysrc.subr
+++ b/usr.sbin/bsdconfig/share/sysrc.subr
@@ -32,7 +32,10 @@ BSDCFG_SHARE="/usr/share/bsdconfig"
[ "$_COMMON_SUBR" ] || . $BSDCFG_SHARE/common.subr || exit 1
BSDCFG_LIBE="/usr/libexec/bsdconfig"
-[ ! "$_SYSRC_JAILED" ] && f_include_lang $BSDCFG_LIBE/include/messages.subr
+if [ ! "$_SYSRC_JAILED" ]; then
+ f_dprintf "%s: loading includes..." sysrc.subr
+ f_include_lang $BSDCFG_LIBE/include/messages.subr
+fi
############################################################ CONFIGURATION
@@ -623,4 +626,8 @@ f_sysrc_delete()
done
}
+############################################################ MAIN
+
+f_dprintf "%s: Successfully loaded." sysrc.subr
+
fi # ! $_SYSRC_SUBR
diff --git a/usr.sbin/bsdconfig/startup/misc b/usr.sbin/bsdconfig/startup/misc
index 6407d08..626697a 100755
--- a/usr.sbin/bsdconfig/startup/misc
+++ b/usr.sbin/bsdconfig/startup/misc
@@ -30,6 +30,7 @@
BSDCFG_SHARE="/usr/share/bsdconfig"
. $BSDCFG_SHARE/common.subr || exit 1
+f_dprintf "%s: loading includes..." "$0"
f_include $BSDCFG_SHARE/dialog.subr
f_include $BSDCFG_SHARE/mustberoot.subr
f_include $BSDCFG_SHARE/sysrc.subr
@@ -253,34 +254,11 @@ dialog_menu_main()
#
dialog_input_value()
{
- local hline="$hline_alnum_tab_enter"
- local size prompt="$1" _input="$2"
+ local prompt="$1" _input="$2"
f_dialog_title "$msg_value_required"
-
- size=$( f_dialog_inputbox_size \
- "$DIALOG_TITLE" \
- "$DIALOG_BACKTITLE" \
- "$prompt" \
- "$_input" \
- "$hline" )
-
- local dialog_inputbox
- dialog_inputbox=$( eval $DIALOG \
- --title \"\$DIALOG_TITLE\" \
- --backtitle \"\$DIALOG_BACKTITLE\" \
- --hline \"\$hline\" \
- --ok-label \"\$msg_ok\" \
- --cancel-label \"\$msg_cancel\" \
- --inputbox \"\$prompt\" $size \
- \"\$_input\" \
- 2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD
- )
-
- retval=$?
- setvar DIALOG_INPUTBOX_$$ "$dialog_inputbox"
- _input=$( f_dialog_inputstr )
-
+ _input=$( f_dialog_input "$prompt" "$_input" "$hline_alnum_tab_enter" )
+ local retval=$?
f_dialog_title_restore
# Return if user has either pressed ESC or chosen Cancel/No
@@ -308,7 +286,6 @@ shift $(( $OPTIND - 1 ))
#
# Initialize
#
-f_dialog_init
f_dialog_title "$msg_miscellaneous_startup_services"
f_dialog_backtitle "${ipgm:+bsdconfig }$pgm"
f_mustberoot_init
diff --git a/usr.sbin/bsdconfig/startup/rcadd b/usr.sbin/bsdconfig/startup/rcadd
index 13e5fb3..3bea670 100755
--- a/usr.sbin/bsdconfig/startup/rcadd
+++ b/usr.sbin/bsdconfig/startup/rcadd
@@ -30,6 +30,7 @@
BSDCFG_SHARE="/usr/share/bsdconfig"
. $BSDCFG_SHARE/common.subr || exit 1
+f_dprintf "%s: loading includes..." "$0"
f_include $BSDCFG_SHARE/dialog.subr
f_include $BSDCFG_SHARE/mustberoot.subr
f_include $BSDCFG_SHARE/startup/rcconf.subr
@@ -106,7 +107,6 @@ shift $(( $OPTIND - 1 ))
#
# Initialize
#
-f_dialog_init
f_dialog_title "$msg_add_startup_directive"
f_dialog_backtitle "${ipgm:+bsdconfig }$pgm"
f_mustberoot_init
diff --git a/usr.sbin/bsdconfig/startup/rcconf b/usr.sbin/bsdconfig/startup/rcconf
index 34454ac..d09874b 100755
--- a/usr.sbin/bsdconfig/startup/rcconf
+++ b/usr.sbin/bsdconfig/startup/rcconf
@@ -30,6 +30,7 @@
BSDCFG_SHARE="/usr/share/bsdconfig"
. $BSDCFG_SHARE/common.subr || exit 1
+f_dprintf "%s: loading includes..." "$0"
f_include $BSDCFG_SHARE/dialog.subr
f_include $BSDCFG_SHARE/mustberoot.subr
f_include $BSDCFG_SHARE/sysrc.subr
@@ -205,7 +206,6 @@ shift $(( $OPTIND - 1 ))
#
# Initialize
#
-f_dialog_init
f_dialog_title "$msg_view_edit_startup_configuration"
f_dialog_backtitle "${ipgm:+bsdconfig }$pgm"
f_mustberoot_init
diff --git a/usr.sbin/bsdconfig/startup/rcdelete b/usr.sbin/bsdconfig/startup/rcdelete
index 8d29f87..02ec049 100755
--- a/usr.sbin/bsdconfig/startup/rcdelete
+++ b/usr.sbin/bsdconfig/startup/rcdelete
@@ -30,6 +30,7 @@
BSDCFG_SHARE="/usr/share/bsdconfig"
. $BSDCFG_SHARE/common.subr || exit 1
+f_dprintf "%s: loading includes..." "$0"
f_include $BSDCFG_SHARE/dialog.subr
f_include $BSDCFG_SHARE/mustberoot.subr
f_include $BSDCFG_SHARE/sysrc.subr
@@ -280,7 +281,6 @@ shift $(( $OPTIND - 1 ))
#
# Initialize
#
-f_dialog_init
f_dialog_title "$msg_delete_startup_directives"
f_dialog_backtitle "${ipgm:+bsdconfig }$pgm"
f_mustberoot_init
diff --git a/usr.sbin/bsdconfig/startup/rcedit b/usr.sbin/bsdconfig/startup/rcedit
index fa43291..0114368 100755
--- a/usr.sbin/bsdconfig/startup/rcedit
+++ b/usr.sbin/bsdconfig/startup/rcedit
@@ -30,6 +30,7 @@
BSDCFG_SHARE="/usr/share/bsdconfig"
. $BSDCFG_SHARE/common.subr || exit 1
+f_dprintf "%s: loading includes..." "$0"
f_include $BSDCFG_SHARE/dialog.subr
f_include $BSDCFG_SHARE/mustberoot.subr
f_include $BSDCFG_SHARE/startup/rcedit.subr
@@ -58,7 +59,6 @@ shift $(( $OPTIND - 1 ))
#
# Initialize
#
-f_dialog_init
f_dialog_backtitle "${ipgm:+bsdconfig }$pgm"
f_mustberoot_init
diff --git a/usr.sbin/bsdconfig/startup/rcvar b/usr.sbin/bsdconfig/startup/rcvar
index 8097123..8f27b51 100755
--- a/usr.sbin/bsdconfig/startup/rcvar
+++ b/usr.sbin/bsdconfig/startup/rcvar
@@ -30,6 +30,7 @@
BSDCFG_SHARE="/usr/share/bsdconfig"
. $BSDCFG_SHARE/common.subr || exit 1
+f_dprintf "%s: loading includes..." "$0"
f_include $BSDCFG_SHARE/dialog.subr
f_include $BSDCFG_SHARE/mustberoot.subr
f_include $BSDCFG_SHARE/sysrc.subr
@@ -167,7 +168,6 @@ shift $(( $OPTIND - 1 ))
#
# Initialize
#
-f_dialog_init
f_dialog_title "$msg_toggle_startup_services"
f_dialog_backtitle "${ipgm:+bsdconfig }$pgm"
f_mustberoot_init
diff --git a/usr.sbin/bsdconfig/startup/share/rcconf.subr b/usr.sbin/bsdconfig/startup/share/rcconf.subr
index 16cb290..8878d2c 100644
--- a/usr.sbin/bsdconfig/startup/share/rcconf.subr
+++ b/usr.sbin/bsdconfig/startup/share/rcconf.subr
@@ -30,6 +30,7 @@ if [ ! "$_STARTUP_RCCONF_SUBR" ]; then _STARTUP_RCCONF_SUBR=1
BSDCFG_SHARE="/usr/share/bsdconfig"
. $BSDCFG_SHARE/common.subr || exit 1
+f_dprintf "%s: loading includes..." startup/rcconf.subr
f_include $BSDCFG_SHARE/sysrc.subr
BSDCFG_LIBE="/usr/libexec/bsdconfig" APP_DIR="140.startup"
@@ -418,39 +419,16 @@ f_dialog_input_rclist()
#
f_dialog_input_rcvar()
{
- local msg="$msg_please_enter_rcvar_name"
- local hline="$hline_alnum_tab_enter"
-
#
# Loop until the user provides taint-free/valid input
#
- local size _input="$1"
+ local _input="$1"
while :; do
- size=$( f_dialog_inputbox_size \
- "$DIALOG_TITLE" \
- "$DIALOG_BACKTITLE" \
- "$msg" \
- "$_input" \
- "$hline" )
-
- local dialog_inputbox
- dialog_inputbox=$( eval $DIALOG \
- --title \"\$DIALOG_TITLE\" \
- --backtitle \"\$DIALOG_BACKTITLE\" \
- --hline \"\$hline\" \
- --ok-label \"\$msg_ok\" \
- --cancel-label \"\$msg_cancel\" \
- --inputbox \"\$msg\" $size \
- \"\$_input\" \
- 2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD
- )
-
- retval=$?
- setvar DIALOG_INPUTBOX_$$ "$dialog_inputbox"
- _input=$( f_dialog_inputstr )
# Return if user either pressed ESC or chosen Cancel/No
- [ $retval -eq $SUCCESS ] || return $retval
+ _input=$( f_dialog_input "$msg_please_enter_rcvar_name" \
+ "$_input" "$hline_alnum_tab_enter"
+ ) || return
# Check for invalid entry (1of2)
if ! echo "$_input" | grep -q "^[[:alpha:]_]"; then
@@ -469,9 +447,13 @@ f_dialog_input_rcvar()
break
done
- f_dprintf "f_dialog_input_rcvar: rcvar->[$rcvar]"
+ f_dprintf "f_dialog_input_rcvar: rcvar->[%s]" "$rcvar"
return $SUCCESS
}
+############################################################ MAIN
+
+f_dprintf "%s: Successfully loaded." startup/rcconf.subr
+
fi # ! $_STARTUP_RCCONF_SUBR
diff --git a/usr.sbin/bsdconfig/startup/share/rcedit.subr b/usr.sbin/bsdconfig/startup/share/rcedit.subr
index 4905a18..a9cba88 100644
--- a/usr.sbin/bsdconfig/startup/share/rcedit.subr
+++ b/usr.sbin/bsdconfig/startup/share/rcedit.subr
@@ -30,6 +30,7 @@ if [ ! "$_STARTUP_RCEDIT_SUBR" ]; then _STARTUP_RCEDIT_SUBR=1
BSDCFG_SHARE="/usr/share/bsdconfig"
. $BSDCFG_SHARE/common.subr || exit 1
+f_dprintf "%s: loading includes..." startup/rcedit.subr
f_include $BSDCFG_SHARE/dialog.subr
f_include $BSDCFG_SHARE/sysrc.subr
@@ -53,8 +54,7 @@ f_include_lang $BSDCFG_LIBE/$APP_DIR/include/messages.subr
#
f_dialog_rcedit()
{
- local msg size retval var="$1" _input
- local hline="$hline_alnum_punc_tab_enter"
+ local msg var="$1" _input
msg=$( printf "$msg_please_enter_a_new_value" \
"$var" "$( f_sysrc_get_default "$var" )" )
@@ -67,43 +67,23 @@ f_dialog_rcedit()
_input=$( f_sysrc_get "$var" )
fi
- size=$( f_dialog_inputbox_size \
- "$DIALOG_TITLE" \
- "$DIALOG_BACKTITLE" \
- "$msg" \
- "$_input" \
- "$hline" )
-
- local opterm="--"
- [ "$USE_XDIALOG" ] && opterm=
-
- local dialog_inputbox
- dialog_inputbox=$( eval $DIALOG \
- --title \"\$DIALOG_TITLE\" \
- --backtitle \"\$DIALOG_BACKTITLE\" \
- --hline \"\$hline\" \
- --ok-label \"\$msg_ok\" \
- --cancel-label \"\$msg_cancel\" \
- --inputbox \"\$msg\" $size \
- $opterm \"\$_input\" \
- 2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD
- )
-
- retval=$?
- setvar DIALOG_INPUTBOX_$$ "$dialog_inputbox"
- _input=$( f_dialog_inputstr )
-
# Return if user has either pressed ESC or chosen Cancel/No
- [ $retval -eq $SUCCESS ] || return $retval
+ _input=$( f_dialog_input "$msg" "$_input" \
+ "$hline_alnum_punc_tab_enter"
+ ) || return
# Return if the value has not changed from current
local cur_val="$( f_sysrc_get "$var" )"
[ "$_input" = "$cur_val" ] && return $SUCCESS
- f_dprintf "$var: [$cur_val]->[$_input]"
+ f_dprintf "%s: [%s]->[%s]" "$var" "$cur_val" "$_input"
err=$( f_sysrc_set "$var" "$_input" 2>&1 ) ||
f_show_msg "$err"
}
+############################################################ MAIN
+
+f_dprintf "%s: Successfully loaded." startup/rcedit.subr
+
fi # ! $_STARTUP_RCEDIT_SUBR
diff --git a/usr.sbin/bsdconfig/startup/share/rcvar.subr b/usr.sbin/bsdconfig/startup/share/rcvar.subr
index 3cd60e8..702c5e9 100644
--- a/usr.sbin/bsdconfig/startup/share/rcvar.subr
+++ b/usr.sbin/bsdconfig/startup/share/rcvar.subr
@@ -30,6 +30,7 @@ if [ ! "$_STARTUP_RCVAR_SUBR" ]; then _STARTUP_RCVAR_SUBR=1
BSDCFG_SHARE="/usr/share/bsdconfig"
. $BSDCFG_SHARE/common.subr || exit 1
+f_dprintf "%s: loading includes..." startup/rcvar.subr
f_include $BSDCFG_SHARE/sysrc.subr
############################################################ CONFIGURATION
@@ -106,11 +107,11 @@ f_startup_rcvar_map()
)"
#
- # Calculate a digest given the checksums of all dependencies (scripts and
- # the defaults file). This digest will be used to determine if an on-disk
- # global persistant cache file (containg this digest on the first line)
- # is valid and can be used to quickly populate the cache value for
- # immediate return.
+ # Calculate a digest given the checksums of all dependencies (scripts
+ # and the defaults file). This digest will be used to determine if an
+ # on-disk global persistant cache file (containg this digest on the
+ # first line) is valid and can be used to quickly populate the cache
+ # value for immediate return.
#
local rc_script_list_digest
rc_script_list_digest=$( cd "$ETC_RC_D" &&
@@ -130,11 +131,12 @@ f_startup_rcvar_map()
read digest rest_ignored
#
- # If the stored digest matches the calculated-one
- # populate the in-memory cache from the on-disk
- # cache and provide success exit status.
+ # If the stored digest matches the calculated-
+ # one populate the in-memory cache from the on-
+ # disk cache and provide success exit status.
#
- if [ "$digest" = "$rc_script_list_digest" ]; then
+ if [ "$digest" = "$rc_script_list_digest" ]
+ then
cat
exit $SUCCESS
else
@@ -150,7 +152,7 @@ f_startup_rcvar_map()
echo "$STARTUP_RCVAR_MAP"
return $SUCCESS
fi
- # Otherwise, fall-through to create in-memory cache from scratch
+ # Otherwise, fall-thru to create in-memory cache from scratch
fi
#
@@ -203,4 +205,8 @@ f_startup_rcvar_map()
mv "$tmpfile" "$STARTUP_RCVAR_MAP_CACHEFILE"
}
+############################################################ MAIN
+
+f_dprintf "%s: Successfully loaded." startup/rcvar.subr
+
fi # ! $_STARTUP_RCVAR_SUBR
diff --git a/usr.sbin/bsdconfig/startup/startup b/usr.sbin/bsdconfig/startup/startup
index 431607c..c9229b7 100755
--- a/usr.sbin/bsdconfig/startup/startup
+++ b/usr.sbin/bsdconfig/startup/startup
@@ -30,6 +30,7 @@
BSDCFG_SHARE="/usr/share/bsdconfig"
. $BSDCFG_SHARE/common.subr || exit 1
+f_dprintf "%s: loading includes..." "$0"
f_include $BSDCFG_SHARE/dialog.subr
f_include $BSDCFG_SHARE/mustberoot.subr
@@ -99,7 +100,6 @@ shift $(( $OPTIND - 1 ))
#
# Initialize
#
-f_dialog_init
f_dialog_title "$msg_startup"
f_dialog_backtitle "${ipgm:+bsdconfig }$pgm"
f_mustberoot_init
diff --git a/usr.sbin/bsdconfig/timezone/share/continents.subr b/usr.sbin/bsdconfig/timezone/share/continents.subr
index 8f3e516..9a66ec7 100644
--- a/usr.sbin/bsdconfig/timezone/share/continents.subr
+++ b/usr.sbin/bsdconfig/timezone/share/continents.subr
@@ -30,6 +30,7 @@ if [ ! "$_TIMEZONE_CONTINENTS_SUBR" ]; then _TIMEZONE_CONTINENTS_SUBR=1
BSDCFG_SHARE="/usr/share/bsdconfig"
. $BSDCFG_SHARE/common.subr || exit 1
+f_dprintf "%s: loading includes..." timezone/continents.subr
BSDCFG_LIBE="/usr/libexec/bsdconfig" APP_DIR="090.timezone"
f_include_lang $BSDCFG_LIBE/$APP_DIR/include/messages.subr
@@ -135,4 +136,8 @@ f_OCEANP()
esac
}
+############################################################ MAIN
+
+f_dprintf "%s: Successfully loaded." timezone/continents.subr
+
fi # ! $_TIMEZONE_CONTINENTS_SUBR
diff --git a/usr.sbin/bsdconfig/timezone/share/countries.subr b/usr.sbin/bsdconfig/timezone/share/countries.subr
index 9c6a164..6a39dc7 100644
--- a/usr.sbin/bsdconfig/timezone/share/countries.subr
+++ b/usr.sbin/bsdconfig/timezone/share/countries.subr
@@ -75,4 +75,6 @@ f_sort_countries()
export COUNTRIES
}
+f_dprintf "%s: Successfully loaded." timezone/countries.subr
+
fi # ! $_TIMEZONE_COUNTRIES_SUBR
diff --git a/usr.sbin/bsdconfig/timezone/share/iso3166.subr b/usr.sbin/bsdconfig/timezone/share/iso3166.subr
index 72e934a..9af6393 100644
--- a/usr.sbin/bsdconfig/timezone/share/iso3166.subr
+++ b/usr.sbin/bsdconfig/timezone/share/iso3166.subr
@@ -30,6 +30,7 @@ if [ ! "$_TIMEZONE_ISO3166_SUBR" ]; then _TIMEZONE_ISO3166_SUBR=1
BSDCFG_SHARE="/usr/share/bsdconfig"
. $BSDCFG_SHARE/common.subr || exit 1
+f_dprintf "%s: loading includes..." timezone/iso3166.subr
BSDCFG_LIBE="/usr/libexec/bsdconfig" APP_DIR="090.timezone"
f_include_lang $BSDCFG_LIBE/$APP_DIR/include/messages.subr
@@ -194,4 +195,8 @@ f_read_iso3166_table()
"$_PATH_ISO3166" )
}
+############################################################ MAIN
+
+f_dprintf "%s: Successfully loaded." timezone/iso3166.subr
+
fi # ! $_TIMEZONE_ISO3166_SUBR
diff --git a/usr.sbin/bsdconfig/timezone/share/menus.subr b/usr.sbin/bsdconfig/timezone/share/menus.subr
index 5ce50f8..687e102 100644
--- a/usr.sbin/bsdconfig/timezone/share/menus.subr
+++ b/usr.sbin/bsdconfig/timezone/share/menus.subr
@@ -30,6 +30,7 @@ if [ ! "$_TIMEZONE_MENUS_SUBR" ]; then _TIMEZONE_MENUS_SUBR=1
BSDCFG_SHARE="/usr/share/bsdconfig"
. $BSDCFG_SHARE/common.subr || exit 1
+f_dprintf "%s: loading includes..." timezone/menus.subr
f_include $BSDCFG_SHARE/dialog.subr
############################################################ GLOBALS
@@ -217,4 +218,8 @@ f_make_menus()
eval $( :| awk "$f_make_menus_awk" )
}
+############################################################ MAIN
+
+f_dprintf "%s: Successfully loaded." timezone/menus.subr
+
fi # ! $_TIMEZONE_MENUS_SUBR
diff --git a/usr.sbin/bsdconfig/timezone/share/zones.subr b/usr.sbin/bsdconfig/timezone/share/zones.subr
index fcfb21e..3ba1d7a 100644
--- a/usr.sbin/bsdconfig/timezone/share/zones.subr
+++ b/usr.sbin/bsdconfig/timezone/share/zones.subr
@@ -30,6 +30,7 @@ if [ ! "$_TIMEZONE_ZONES_SUBR" ]; then _TIMEZONE_ZONES_SUBR=1
BSDCFG_SHARE="/usr/share/bsdconfig"
. $BSDCFG_SHARE/common.subr || exit 1
+f_dprintf "%s: loading includes..." timezone/zones.subr
f_include $BSDCFG_SHARE/dialog.subr
f_include $BSDCFG_SHARE/timezone/continents.subr
@@ -667,4 +668,8 @@ f_set_zone_utc()
f_install_zoneinfo_file ""
}
+############################################################ MAIN
+
+f_dprintf "%s: Successfully loaded." timezone/zones.subr
+
fi # ! $_TIMEZONE_ZONES_SUBR
diff --git a/usr.sbin/bsdconfig/timezone/timezone b/usr.sbin/bsdconfig/timezone/timezone
index 7af598a..5649b60 100755
--- a/usr.sbin/bsdconfig/timezone/timezone
+++ b/usr.sbin/bsdconfig/timezone/timezone
@@ -30,6 +30,7 @@
BSDCFG_SHARE="/usr/share/bsdconfig"
. $BSDCFG_SHARE/common.subr || exit 1
+f_dprintf "%s: loading includes..." "$0"
f_include $BSDCFG_SHARE/dialog.subr
f_include $BSDCFG_SHARE/mustberoot.subr
f_include $BSDCFG_SHARE/strings.subr
@@ -131,7 +132,6 @@ shift $(( $OPTIND - 1 ))
#
# Initialize
#
-f_dialog_init
f_dialog_title "$msg_time_zone"
f_dialog_backtitle "${ipgm:+bsdconfig }$pgm"
f_mustberoot_init
diff --git a/usr.sbin/bsdconfig/ttys/ttys b/usr.sbin/bsdconfig/ttys/ttys
index 545cc1f..db7cb20 100755
--- a/usr.sbin/bsdconfig/ttys/ttys
+++ b/usr.sbin/bsdconfig/ttys/ttys
@@ -30,6 +30,7 @@
BSDCFG_SHARE="/usr/share/bsdconfig"
. $BSDCFG_SHARE/common.subr || exit 1
+f_dprintf "%s: loading includes..." "$0"
f_include $BSDCFG_SHARE/dialog.subr
f_include $BSDCFG_SHARE/mustberoot.subr
@@ -76,7 +77,6 @@ shift $(( $OPTIND - 1 ))
#
# Initialize
#
-f_dialog_init
f_dialog_title "$msg_configure_ttys"
f_dialog_backtitle "${ipgm:+bsdconfig }$pgm"
f_mustberoot_init
diff --git a/usr.sbin/bsdconfig/usermgmt/groupadd b/usr.sbin/bsdconfig/usermgmt/groupadd
index 01fbb1e..34962a9 100755
--- a/usr.sbin/bsdconfig/usermgmt/groupadd
+++ b/usr.sbin/bsdconfig/usermgmt/groupadd
@@ -31,6 +31,7 @@
BSDCFG_SHARE="/usr/share/bsdconfig"
. $BSDCFG_SHARE/common.subr || exit 1
+f_dprintf "%s: loading includes..." "$0"
f_include $BSDCFG_SHARE/dialog.subr
BSDCFG_LIBE="/usr/libexec/bsdconfig" APP_DIR="070.usermgmt"
@@ -56,7 +57,6 @@ shift $(( $OPTIND - 1 ))
#
# Chain-load to groupinput to centralize code and minimize duplication
#
-f_dialog_init
$BSDCFG_LIBE/$APP_DIR/groupinput ${USE_XDIALOG:+-X} mode="Add"
################################################################################
diff --git a/usr.sbin/bsdconfig/usermgmt/groupdel b/usr.sbin/bsdconfig/usermgmt/groupdel
index 5a2f110..b51f002 100755
--- a/usr.sbin/bsdconfig/usermgmt/groupdel
+++ b/usr.sbin/bsdconfig/usermgmt/groupdel
@@ -31,6 +31,7 @@
BSDCFG_SHARE="/usr/share/bsdconfig"
. $BSDCFG_SHARE/common.subr || exit 1
+f_dprintf "%s: loading includes..." "$0"
f_include $BSDCFG_SHARE/dialog.subr
f_include $BSDCFG_SHARE/mustberoot.subr
f_include $BSDCFG_SHARE/usermgmt/group_input.subr
@@ -59,7 +60,6 @@ shift $(( $OPTIND - 1 ))
#
# Initialize
#
-f_dialog_init
f_dialog_title "$msg_delete $msg_group"
f_dialog_backtitle "${ipgm:+bsdconfig }$pgm"
f_mustberoot_init
@@ -71,7 +71,7 @@ while :; do
f_dialog_menu_group_list
retval=$?
mtag=$( f_dialog_menutag )
- f_dprintf "retval=$retval mtag=[$mtag]"
+ f_dprintf "retval=%u mtag=[%s]" $retval "$mtag"
[ $retval -eq 0 ] || f_die
diff --git a/usr.sbin/bsdconfig/usermgmt/groupedit b/usr.sbin/bsdconfig/usermgmt/groupedit
index bb314cf..c192c0f 100755
--- a/usr.sbin/bsdconfig/usermgmt/groupedit
+++ b/usr.sbin/bsdconfig/usermgmt/groupedit
@@ -31,6 +31,7 @@
BSDCFG_SHARE="/usr/share/bsdconfig"
. $BSDCFG_SHARE/common.subr || exit 1
+f_dprintf "%s: loading includes..." "$0"
f_include $BSDCFG_SHARE/dialog.subr
f_include $BSDCFG_SHARE/mustberoot.subr
f_include $BSDCFG_SHARE/usermgmt/group_input.subr
@@ -59,7 +60,6 @@ shift $(( $OPTIND - 1 ))
#
# Initialize
#
-f_dialog_init
f_dialog_title "$msg_edit_view $msg_group"
f_dialog_backtitle "${ipgm:+bsdconfig }$pgm"
f_mustberoot_init
@@ -71,7 +71,7 @@ while :; do
f_dialog_menu_group_list
retval=$?
mtag=$( f_dialog_menutag )
- f_dprintf "retval=$retval mtag=[$mtag]"
+ f_dprintf "retval=%s mtag=[%s]" $retval "$mtag"
[ $retval -eq 0 ] || f_die
diff --git a/usr.sbin/bsdconfig/usermgmt/groupinput b/usr.sbin/bsdconfig/usermgmt/groupinput
index dc55852..83d0c1d 100755
--- a/usr.sbin/bsdconfig/usermgmt/groupinput
+++ b/usr.sbin/bsdconfig/usermgmt/groupinput
@@ -31,6 +31,7 @@
BSDCFG_SHARE="/usr/share/bsdconfig"
. $BSDCFG_SHARE/common.subr || exit 1
+f_dprintf "%s: loading includes..." "$0"
f_include $BSDCFG_SHARE/dialog.subr
f_include $BSDCFG_SHARE/mustberoot.subr
f_include $BSDCFG_SHARE/usermgmt/group_input.subr
@@ -77,7 +78,7 @@ save_changes()
elif [ "$group_password" ]; then
cmd="echo \"\$group_password\" | $cmd -h 0"
fi
- f_dprintf "cmd=$cmd"
+ f_dprintf "cmd=%s" "$cmd"
err=$( eval $cmd 2>&1 )
retval=$?
if [ $retval -ne $SUCCESS ]; then
@@ -96,7 +97,7 @@ save_changes()
elif [ "$group_password" ]; then
cmd="echo \"\$group_password\" | $cmd -h 0"
fi
- f_dprintf "cmd=$cmd"
+ f_dprintf "cmd=%s" "$cmd"
err=$( eval $cmd 2>&1 )
retval=$?
if [ $retval -ne $SUCCESS ]; then
@@ -136,19 +137,18 @@ dialog_title_update()
while [ $# -gt 0 ]; do
key="${1%%=*}"
value="${1#*=}"
- f_dprintf "key=[$key] value=[$value]"
+ f_dprintf "key=[%s] value=[%s]" "$key" "$value"
case "$key" in
mode) mode="$value";;
group) group="$value";;
esac
shift
done
-f_dprintf "mode=[$mode] group=[$group]"
+f_dprintf "mode=[%s] group=[%s]" "$mode" "$group"
#
# Initialize
#
-f_dialog_init
dialog_title_update "$mode"
f_dialog_backtitle "${ipgm:+bsdconfig }$pgm"
f_mustberoot_init
@@ -242,7 +242,7 @@ while :; do
retval=$?
setvar DIALOG_MENU_$$ "$dialog_menu"
mtag=$( f_dialog_menutag )
- f_dprintf "retval=$retval mtag=[$mtag]"
+ f_dprintf "retval=%u mtag=[%s]" $retval "$mtag"
# Exit if user has either pressed ESC or chosen Cancel/No
[ $retval -eq $SUCCESS ] || f_die
@@ -261,7 +261,7 @@ while :; do
f_dialog_menu_group_list
retval=$?
mtag=$( f_dialog_menutag )
- f_dprintf "retval=$retval mtag=[$mtag]"
+ f_dprintf "retval=%u mtag=[%s]" $retval "$mtag"
# Loop if user has either pressed ESC or chosen Cancel/No
[ $retval -eq $SUCCESS ] || continue
diff --git a/usr.sbin/bsdconfig/usermgmt/share/group_input.subr b/usr.sbin/bsdconfig/usermgmt/share/group_input.subr
index e3d59d0..4b47392 100644
--- a/usr.sbin/bsdconfig/usermgmt/share/group_input.subr
+++ b/usr.sbin/bsdconfig/usermgmt/share/group_input.subr
@@ -31,6 +31,7 @@ if [ ! "$_USERMGMT_GROUP_INPUT_SUBR" ]; then _USERMGMT_GROUP_INPUT_SUBR=1
BSDCFG_SHARE="/usr/share/bsdconfig"
. $BSDCFG_SHARE/common.subr || exit 1
+f_dprintf "%s: loading includes..." usermgmt/group_input.subr
f_include $BSDCFG_SHARE/dialog.subr
f_include $BSDCFG_SHARE/strings.subr
@@ -111,39 +112,16 @@ f_dialog_menu_group_list()
#
f_dialog_input_group_name()
{
- local msg="$( printf "$msg_group" )"
- local hline="$hline_alnum_tab_enter"
-
#
# Loop until the user provides taint-free/valid input
#
- local size retval _name="$1" _input="$1"
+ local _name="$1" _input="$1"
while :; do
- size=$( f_dialog_inputbox_size \
- "$DIALOG_TITLE" \
- "$DIALOG_BACKTITLE" \
- "$msg" \
- "$_input" \
- "$hline" )
-
- local dialog_inputbox
- dialog_inputbox=$( eval $DIALOG \
- --title \"\$DIALOG_TITLE\" \
- --backtitle \"\$DIALOG_BACKTITLE\" \
- --hline \"\$hline\" \
- --ok-label \"\$msg_ok\" \
- --cancel-label \"\$msg_cancel\" \
- --inputbox \"\$msg\" $size \
- \"\$_input\" \
- 2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD
- )
-
- retval=$?
- setvar DIALOG_INPUTBOX_$$ "$dialog_inputbox"
- _input=$( f_dialog_inputstr )
# Return if user has either pressed ESC or chosen Cancel/No
- [ $retval -eq $SUCCESS ] || return $retval
+ _input=$( f_dialog_input "$msg_group" "$_input" \
+ "$hline_alnum_tab_enter"
+ ) || return
# Check for no-change
[ "$_input" = "$_name" ] && return $SUCCESS
@@ -177,7 +155,7 @@ f_dialog_input_group_name()
done
save_flag=1
- f_dprintf "group_name: [$cur_group_name]->[$group_name]"
+ f_dprintf "group_name: [%s]->[%s]" "$cur_group_name" "$group_name"
return $SUCCESS
}
@@ -270,7 +248,8 @@ f_dialog_input_group_password()
done
save_flag=1
- f_dprintf "group_password: [$cur_group_password]->[$group_password]"
+ f_dprintf "group_password: [%s]->[%s]" \
+ "$cur_group_password" "$group_password"
return $SUCCESS
}
@@ -283,40 +262,17 @@ f_dialog_input_group_password()
#
f_dialog_input_group_gid()
{
- local msg size retval _input="$1"
- local hline="$hline_num_tab_enter"
-
- msg=$( printf "$msg_group_id_leave_empty_for_default" )
- size=$( f_dialog_inputbox_size \
- "$DIALOG_TITLE" \
- "$DIALOG_BACKTITLE" \
- "$msg" \
- "$_input" \
- "$hline" )
-
- local dialog_inputbox
- dialog_inputbox=$( eval $DIALOG \
- --title \"\$DIALOG_TITLE\" \
- --backtitle \"\$DIALOG_BACKTITLE\" \
- --hline \"\$hline\" \
- --ok-label \"\$msg_ok\" \
- --cancel-label \"\$msg_cancel\" \
- --inputbox \"\$msg\" $size \
- \"\$_input\" \
- 2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD
- )
-
- retval=$?
- setvar DIALOG_INPUTBOX_$$ "$dialog_inputbox"
- _input=$( f_dialog_inputstr )
+ local _input="$1"
# Return if user has either pressed ESC or chosen Cancel/No
- [ $retval -eq $SUCCESS ] || return $retval
+ _input=$( f_dialog_input "$msg_group_id_leave_empty_for_default" \
+ "$_input" "$hline_num_tab_enter"
+ ) || return
group_gid="$_input"
save_flag=1
- f_dprintf "group_gid: [$cur_group_gid]->[$group_gid]"
+ f_dprintf "group_gid: [%s]->[%s]" "$cur_group_gid" "$group_gid"
return $SUCCESS
}
@@ -365,7 +321,7 @@ f_dialog_input_group_members()
retval=$?
setvar DIALOG_MENU_$$ "$dialog_menu"
menu_choice=$( f_dialog_menutag )
- f_dprintf "retval=$retval menu_choice=[$menu_choice]"
+ f_dprintf "retval=%u menu_choice=[%s]" $retval "$menu_choice"
# Return if user has either pressed ESC or chosen Cancel/No
[ $retval -eq $SUCCESS ] || return $retval
@@ -416,36 +372,13 @@ f_dialog_input_group_members()
_input="$_group_members"
;;
2) # Enter Group Members manually
- hline="$hline_num_tab_enter"
- msg=$(
- printf "$msg_group_members ($msg_separated_by_commas)"
- )
- size=$( f_dialog_inputbox_size \
- "$DIALOG_TITLE" \
- "$DIALOG_BACKTITLE" \
- "$msg" \
- "$_input" \
- "$hline" )
-
- local dialog_inputbox
- dialog_inputbox=$( eval $DIALOG \
- --title \"\$DIALOG_TITLE\" \
- --backtitle \"\$DIALOG_BACKTITLE\" \
- --hline \"\$hline\" \
- --ok-label \"\$msg_ok\" \
- --cancel-label \"\$msg_cancel\" \
- --inputbox \"\$msg\" $size \
- \"\$_input\" \
- 2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD
- )
-
- retval=$?
- setvar DIALOG_INPUTBOX_$$ "$dialog_inputbox"
- _group_members=$( f_dialog_inputstr )
+ msg="$msg_group_members ($msg_separated_by_commas)"
# Return to previous menu if user has either
# pressed ESC or chosen Cancel/No
- [ $retval -eq $SUCCESS ] || continue
+ _group_members=$( f_dialog_input "$msg" "$_input" \
+ "$hline_num_tab_enter"
+ ) || continue
_input="$_group_members"
;;
@@ -454,9 +387,14 @@ f_dialog_input_group_members()
group_members="$_input"
save_flag=1
- f_dprintf "group_members: [$cur_group_members]->[$group_members]"
+ f_dprintf "group_members: [%s]->[%s]" \
+ "$cur_group_members" "$group_members"
return $SUCCESS
}
+############################################################ MAIN
+
+f_dprintf "%s: Successfully loaded." usermgmt/group_input.subr
+
fi # ! $_USERMGMT_GROUP_INPUT_SUBR
diff --git a/usr.sbin/bsdconfig/usermgmt/share/user_input.subr b/usr.sbin/bsdconfig/usermgmt/share/user_input.subr
index 8b356b6..d0b5fe3 100644
--- a/usr.sbin/bsdconfig/usermgmt/share/user_input.subr
+++ b/usr.sbin/bsdconfig/usermgmt/share/user_input.subr
@@ -31,6 +31,7 @@ if [ ! "$_USERMGMT_USER_INPUT_SUBR" ]; then _USERMGMT_USER_INPUT_SUBR=1
BSDCFG_SHARE="/usr/share/bsdconfig"
. $BSDCFG_SHARE/common.subr || exit 1
+f_dprintf "%s: loading includes..." usermgmt/user_input.subr
f_include $BSDCFG_SHARE/dialog.subr
f_include $BSDCFG_SHARE/strings.subr
@@ -198,8 +199,8 @@ f_dialog_input_member_groups()
done
save_flag=1
- local debug="pw_member_groups:"
- f_dprintf "$debug [$cur_pw_member_groups]->[$pw_member_groups]"
+ f_dprintf "pw_member_groups: [%s]->[%s]" \
+ "$cur_pw_member_groups" "$pw_member_groups"
return $SUCCESS
}
@@ -216,39 +217,16 @@ f_dialog_input_member_groups()
#
f_dialog_input_name()
{
- local msg="$( printf "$msg_login" )"
- local hline="$hline_alnum_tab_enter"
-
#
# Loop until the user provides taint-free/valid input
#
- local size retval _name="$1" _input="$1"
+ local _name="$1" _input="$1"
while :; do
- size=$( f_dialog_inputbox_size \
- "$DIALOG_TITLE" \
- "$DIALOG_BACKTITLE" \
- "$msg" \
- "$_input" \
- "$hline" )
-
- local dialog_inputbox
- dialog_inputbox=$( eval $DIALOG \
- --title \"\$DIALOG_TITLE\" \
- --backtitle \"\$DIALOG_BACKTITLE\" \
- --hline \"\$hline\" \
- --ok-label \"\$msg_ok\" \
- --cancel-label \"\$msg_cancel\" \
- --inputbox \"\$msg\" $size \
- \"\$_input\" \
- 2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD
- )
-
- retval=$?
- setvar DIALOG_INPUTBOX_$$ "$dialog_inputbox"
- _input=$( f_dialog_inputstr )
# Return if user has either pressed ESC or chosen Cancel/No
- [ $retval -eq $SUCCESS ] || return $retval
+ _input=$( f_dialog_input "$msg_login" "$_input" \
+ "$hline_alnum_tab_enter"
+ ) || return
# Check for no-change
[ "$_input" = "$_name" ] && return $SUCCESS
@@ -282,7 +260,7 @@ f_dialog_input_name()
done
save_flag=1
- f_dprintf "pw_name: [$cur_pw_name]->[$pw_name]"
+ f_dprintf "pw_name: [%s]->[%s]" "$cur_pw_name" "$pw_name"
return $SUCCESS
}
@@ -375,7 +353,7 @@ f_dialog_input_password()
done
save_flag=1
- f_dprintf "pw_password: [$cur_pw_password]->[$pw_password]"
+ f_dprintf "pw_password: [%s]->[%s]" "$cur_pw_password" "$pw_password"
return $SUCCESS
}
@@ -389,40 +367,17 @@ f_dialog_input_password()
#
f_dialog_input_gecos()
{
- local msg size retval _input="$1"
- local hline="$hline_alnum_punc_tab_enter"
-
- msg=$( printf "$msg_full_name" )
- size=$( f_dialog_inputbox_size \
- "$DIALOG_TITLE" \
- "$DIALOG_BACKTITLE" \
- "$msg" \
- "$_input" \
- "$hline" )
-
- local dialog_inputbox
- dialog_inputbox=$( eval $DIALOG \
- --title \"\$DIALOG_TITLE\" \
- --backtitle \"\$DIALOG_BACKTITLE\" \
- --hline \"\$hline\" \
- --ok-label \"\$msg_ok\" \
- --cancel-label \"\$msg_cancel\" \
- --inputbox \"\$msg\" $size \
- \"\$_input\" \
- 2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD
- )
-
- retval=$?
- setvar DIALOG_INPUTBOX_$$ "$dialog_inputbox"
- _input=$( f_dialog_inputstr )
+ local _input="$1"
# Return if user has either pressed ESC or chosen Cancel/No
- [ $retval -eq $SUCCESS ] || return $retval
+ _input=$( f_dialog_input "$msg_full_name" "$_input" \
+ "$hline_alnum_punc_tab_enter"
+ ) || return
pw_gecos="$_input"
save_flag=1
- f_dprintf "pw_gecos: [$cur_pw_gecos]->[$pw_gecos]"
+ f_dprintf "pw_gecos: [%s]->[%s]" "$cur_pw_gecos" "$pw_gecos"
return $SUCCESS
}
@@ -435,40 +390,17 @@ f_dialog_input_gecos()
#
f_dialog_input_uid()
{
- local msg size retval _input="$1"
- local hline="$hline_num_tab_enter"
-
- msg=$( printf "$msg_user_id_leave_empty_for_default" )
- size=$( f_dialog_inputbox_size \
- "$DIALOG_TITLE" \
- "$DIALOG_BACKTITLE" \
- "$msg" \
- "$_input" \
- "$hline" )
-
- local dialog_inputbox
- dialog_inputbox=$( eval $DIALOG \
- --title \"\$DIALOG_TITLE\" \
- --backtitle \"\$DIALOG_BACKTITLE\" \
- --hline \"\$hline\" \
- --ok-label \"\$msg_ok\" \
- --cancel-label \"\$msg_cancel\" \
- --inputbox \"\$msg\" $size \
- \"\$_input\" \
- 2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD
- )
-
- retval=$?
- setvar DIALOG_INPUTBOX_$$ "$dialog_inputbox"
- _input=$( f_dialog_inputstr )
+ local _input="$1"
# Return if user has either pressed ESC or chosen Cancel/No
- [ $retval -eq $SUCCESS ] || return $retval
+ _input=$( f_dialog_input "$msg_user_id_leave_empty_for_default" \
+ "$_input" "$hline_num_tab_enter"
+ ) || return
pw_uid="$_input"
save_flag=1
- f_dprintf "pw_uid: [$cur_pw_uid]->[$pw_uid]"
+ f_dprintf "pw_uid: [%s]->[%s]" "$cur_pw_uid" "$pw_uid"
return $SUCCESS
}
@@ -481,40 +413,17 @@ f_dialog_input_uid()
#
f_dialog_input_gid()
{
- local msg size retval _input="$1"
- local hline="$hline_num_tab_enter"
-
- msg=$( printf "$msg_group_id_leave_empty_for_default" )
- size=$( f_dialog_inputbox_size \
- "$DIALOG_TITLE" \
- "$DIALOG_BACKTITLE" \
- "$msg" \
- "$_input" \
- "$hline" )
-
- local dialog_inputbox
- dialog_inputbox=$( eval $DIALOG \
- --title \"\$DIALOG_TITLE\" \
- --backtitle \"\$DIALOG_BACKTITLE\" \
- --hline \"\$hline\" \
- --ok-label \"\$msg_ok\" \
- --cancel-label \"\$msg_cancel\" \
- --inputbox \"\$msg\" $size \
- \"\$_input\" \
- 2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD
- )
-
- retval=$?
- setvar DIALOG_INPUTBOX_$$ "$dialog_inputbox"
- _input=$( f_dialog_inputstr )
+ local _input="$1"
# Return if user has either pressed ESC or chosen Cancel/No
- [ $retval -eq $SUCCESS ] || return $retval
+ _input=$( f_dialog_input "$msg_group_id_leave_empty_for_default" \
+ "$_input" "$hline_num_tab_enter"
+ ) || return
pw_gid="$_input"
save_flag=1
- f_dprintf "pw_gid: [$cur_pw_gid]->[$pw_gid]"
+ f_dprintf "pw_gid: [%s]->[%s]" "$cur_pw_gid" "$pw_gid"
return $SUCCESS
}
@@ -527,40 +436,17 @@ f_dialog_input_gid()
#
f_dialog_input_class()
{
- local msg size retval _input="$1"
- local hline="$hline_alnum_tab_enter"
-
- msg=$( printf "$msg_login_class" )
- size=$( f_dialog_inputbox_size \
- "$DIALOG_TITLE" \
- "$DIALOG_BACKTITLE" \
- "$msg" \
- "$_input" \
- "$hline" )
-
- local dialog_inputbox
- dialog_inputbox=$( eval $DIALOG \
- --title \"\$DIALOG_TITLE\" \
- --backtitle \"\$DIALOG_BACKTITLE\" \
- --hline \"\$hline\" \
- --ok-label \"\$msg_ok\" \
- --cancel-label \"\$msg_cancel\" \
- --inputbox \"\$msg\" $size \
- \"\$_input\" \
- 2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD
- )
-
- retval=$?
- setvar DIALOG_INPUTBOX_$$ "$dialog_inputbox"
- _input=$( f_dialog_inputstr )
+ local _input="$1"
# Return if user has either pressed ESC or chosen Cancel/No
- [ $retval -eq $SUCCESS ] || return $retval
+ _input=$( f_dialog_input "$msg_login_class" "$_input" \
+ "$hline_alnum_tab_enter"
+ ) || return
pw_class="$_input"
save_flag=1
- f_dprintf "pw_class: [$cur_pw_class]->[$pw_class]"
+ f_dprintf "pw_class: [%s]->[%s]" "$cur_pw_class" "$pw_class"
return $SUCCESS
}
@@ -611,7 +497,7 @@ f_dialog_input_change()
retval=$?
setvar DIALOG_MENU_$$ "$dialog_menu"
date_type=$( f_dialog_menutag )
- f_dprintf "retval=$retval date_type=[$date_type]"
+ f_dprintf "retval=%u date_type=[%s]" $retval "$date_type"
# Return if user has either pressed ESC or chosen Cancel/No
[ $retval -eq $SUCCESS ] || return $retval
@@ -647,7 +533,7 @@ f_dialog_input_change()
retval=$?
setvar DIALOG_INPUTBOX_$$ "$dialog_inputbox"
ret_date=$( f_dialog_inputstr )
- f_dprintf "retval=$retval ret_date=[$ret_date]"
+ f_dprintf "retval=%u ret_date=[%s]" $retval "$ret_date"
# Return to menu if either ESC or Cancel/No
[ $retval -eq $SUCCESS ] || continue
@@ -674,7 +560,7 @@ f_dialog_input_change()
retval=$?
setvar DIALOG_INPUTBOX_$$ "$dialog_inputbox"
ret_time=$( f_dialog_inputstr )
- f_dprintf "retval=$retval ret_time=[$ret_time]"
+ f_dprintf "retval=%u ret_time=[%s]" $retval "$ret_time"
# Return to menu if either ESC or Cancel/No
[ $retval -eq $SUCCESS ] || continue
@@ -683,7 +569,7 @@ f_dialog_input_change()
-j -f "%d/%m/%Y %T" \
-- "$ret_date $ret_time" \
+%s 2> /dev/null )
- f_dprintf "_input=[$_input]"
+ f_dprintf "_input=[%s]" "$_input"
break ;;
3) # Enter number of days into the future
@@ -695,31 +581,11 @@ f_dialog_input_change()
f_isinteger "$ret_days" &&
ret_days=$(( $ret_days + 1 ))
- msg="$msg_password_expires_in_how_many_days"
- size=$( f_dialog_inputbox_size \
- "$DIALOG_TITLE" \
- "$DIALOG_BACKTITLE" \
- "$msg" \
- "$ret_days" \
- "$hline" )
-
- local dialog_inputbox
- dialog_inputbox=$( eval $DIALOG \
- --title \"\$DIALOG_TITLE\" \
- --backtitle \"\$DIALOG_BACKTITLE\" \
- --hline \"\$hline\" \
- --ok-label \"\$msg_ok\" \
- --cancel-label \"\$msg_cancel\" \
- --inputbox \"\$msg\" $size \
- \"\$ret_days\" \
- 2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD
- )
- retval=$?
- setvar DIALOG_INPUTBOX_$$ "$dialog_inputbox"
- ret_days=$( f_dialog_inputstr )
-
# Return to menu if either ESC or Cancel/No
- [ $retval -eq $SUCCESS ] || continue
+ ret_days=$( f_dialog_input \
+ "$msg_password_expires_in_how_many_days" \
+ "$ret_days" "$hline"
+ ) || continue
# Taint-check the user's input
if ! f_isinteger "$ret_days"; then
@@ -727,13 +593,13 @@ f_dialog_input_change()
continue
fi
- f_dprintf "ret_days=[$ret_days]"
+ f_dprintf "ret_days=[%s]" "$ret_days"
case "$ret_days" in
[-+]*) _input=$( date -v${ret_days}d +%s );;
0) _input=$( date +%s );;
*) _input=$( date -v+${ret_days}d +%s );;
esac
- f_dprintf "_input=[$_input]"
+ f_dprintf "_input=[%s]" "$_input"
break ;;
4) # Enter value manually
@@ -741,30 +607,10 @@ f_dialog_input_change()
msg=$( printf "$msg_number_of_seconds_since_epoch" \
"$( date -r 1 "+%c %Z" )" )
- size=$( f_dialog_inputbox_size \
- "$DIALOG_TITLE" \
- "$DIALOG_BACKTITLE" \
- "$msg" \
- "$_input" \
- "$hline" )
- local dialog_inputbox
- dialog_inputbox=$( eval $DIALOG \
- --title \"\$DIALOG_TITLE\" \
- --backtitle \"\$DIALOG_BACKTITLE\" \
- --hline \"\$hline\" \
- --ok-label \"\$msg_ok\" \
- --cancel-label \"\$msg_cancel\" \
- --inputbox \"\$msg\" $size \
- \"\$_input\" \
- 2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD
- )
-
- retval=$?
- setvar DIALOG_INPUTBOX_$$ "$dialog_inputbox"
- ret_secs=$( f_dialog_inputstr )
# Return to menu if either ESC or Cancel/No
- [ $retval -eq $SUCCESS ] || continue
+ ret_secs=$( f_dialog_input \
+ "$msg" "$_input" "$hline" ) || continue
_input="$ret_secs"
@@ -774,7 +620,7 @@ f_dialog_input_change()
continue
fi
- f_dprintf "_input=[$_input]"
+ f_dprintf "_input=[%s]" "$_input"
break ;;
esac
@@ -784,8 +630,8 @@ f_dialog_input_change()
pw_password_expire="$_input"
save_flag=1
- local debug=pw_password_expire
- f_dprintf "$debug: [$cur_pw_password_expire]->[$pw_password_expire]"
+ f_dprintf "pw_password_expire: [%s]->[%s]" \
+ "$cur_pw_password_expire" "$pw_password_expire"
return $SUCCESS
}
@@ -836,7 +682,7 @@ f_dialog_input_expire()
retval=$?
setvar DIALOG_MENU_$$ "$dialog_menu"
date_type=$( f_dialog_menutag )
- f_dprintf "retval=$retval date_type=[$date_type]"
+ f_dprintf "retval=%u date_type=[%s]" $retval "$date_type"
# Return if user has either pressed ESC or chosen Cancel/No
[ $retval -eq $SUCCESS ] || return $retval
@@ -872,7 +718,7 @@ f_dialog_input_expire()
retval=$?
setvar DIALOG_INPUTBOX_$$ "$dialog_inputbox"
ret_date=$( f_dialog_inputstr )
- f_dprintf "retval=$retval ret_date=[$ret_date]"
+ f_dprintf "retval=%u ret_date=[%s]" $retval "$ret_date"
# Return to menu if either ESC or Cancel/No
[ $retval -eq $SUCCESS ] || continue
@@ -898,7 +744,7 @@ f_dialog_input_expire()
retval=$?
setvar DIALOG_INPUTBOX_$$ "$dialog_inputbox"
ret_time=$( f_dialog_inputstr )
- f_dprintf "retval=$retval ret_time=[$ret_time]"
+ f_dprintf "retval=%u ret_time=[%s]" $retval "$ret_time"
# Return to menu if either ESC or Cancel/No
[ $retval -eq $SUCCESS ] || continue
@@ -907,7 +753,7 @@ f_dialog_input_expire()
-j -f "%d/%m/%Y %T" \
-- "$ret_date $ret_time" \
+%s 2> /dev/null )
- f_dprintf "_input=[$_input]"
+ f_dprintf "_input=[%s]" "$_input"
break ;;
3) # Enter number of days into the future
@@ -919,31 +765,11 @@ f_dialog_input_expire()
f_isinteger "$ret_days" &&
ret_days=$(( $ret_days + 1 ))
- msg="$msg_account_expires_in_how_many_days"
- size=$( f_dialog_inputbox_size \
- "$DIALOG_TITLE" \
- "$DIALOG_BACKTITLE" \
- "$msg" \
- "$ret_days" \
- "$hline" )
-
- local dialog_inputbox
- dialog_inputbox=$( eval $DIALOG \
- --title \"\$DIALOG_TITLE\" \
- --backtitle \"\$DIALOG_BACKTITLE\" \
- --hline \"\$hline\" \
- --ok-label \"\$msg_ok\" \
- --cancel-label \"\$msg_cancel\" \
- --inputbox \"\$msg\" $size \
- \"\$ret_days\" \
- 2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD
- )
- retval=$?
- setvar DIALOG_INPUTBOX_$$ "$dialog_inputbox"
- ret_days=$( f_dialog_inputstr )
-
# Return to menu if either ESC or Cancel/No
- [ $retval -eq $SUCCESS ] || continue
+ ret_days=$( f_dialog_input \
+ "$msg_account_expires_in_how_many_days" \
+ "$ret_days" "$hline"
+ ) || continue
# Taint-check the user's input
if ! f_isinteger "$ret_days"; then
@@ -951,13 +777,13 @@ f_dialog_input_expire()
continue
fi
- f_dprintf "ret_days=[$ret_days]"
+ f_dprintf "ret_days=[%s]" "$ret_days"
case "$ret_days" in
[-+]*) _input=$( date -v${ret_days}d +%s );;
0) _input=$( date +%s );;
*) _input=$( date -v+${ret_days}d +%s );;
esac
- f_dprintf "_input=[$_input]"
+ f_dprintf "_input=[%s]" "$_input"
break ;;
4) # Enter value manually
@@ -965,30 +791,10 @@ f_dialog_input_expire()
msg=$( printf "$msg_number_of_seconds_since_epoch" \
"$( date -r 1 "+%c %Z" )" )
- size=$( f_dialog_inputbox_size \
- "$DIALOG_TITLE" \
- "$DIALOG_BACKTITLE" \
- "$msg" \
- "$_input" \
- "$hline" )
- local dialog_inputbox
- dialog_inputbox=$( eval $DIALOG \
- --title \"\$DIALOG_TITLE\" \
- --backtitle \"\$DIALOG_BACKTITLE\" \
- --hline \"\$hline\" \
- --ok-label \"\$msg_ok\" \
- --cancel-label \"\$msg_cancel\" \
- --inputbox \"\$msg\" $size \
- \"\$_input\" \
- 2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD
- )
-
- retval=$?
- setvar DIALOG_INPUTBOX_$$ "$dialog_inputbox"
- ret_secs=$( f_dialog_inputstr )
# Return to menu if either ESC or Cancel/No
- [ $retval -eq $SUCCESS ] || continue
+ ret_secs=$( f_dialog_input \
+ "$msg" "$_input" "$hline" ) || continue
_input="$ret_secs"
@@ -998,7 +804,7 @@ f_dialog_input_expire()
continue
fi
- f_dprintf "_input=[$_input]"
+ f_dprintf "_input=[%s]" "$_input"
break ;;
esac
@@ -1008,8 +814,8 @@ f_dialog_input_expire()
pw_account_expire="$_input"
save_flag=1
- local debug=pw_account_expire
- f_dprintf "$debug: [$cur_pw_account_expire]->[$pw_account_expire]"
+ f_dprintf "pw_account_expire: [%s]->[%s]" \
+ "$cur_pw_account_expire" "$pw_account_expire"
return $SUCCESS
}
@@ -1022,40 +828,17 @@ f_dialog_input_expire()
#
f_dialog_input_home_dir()
{
- local msg size retval _input="$1"
- local hline="$hline_alnum_punc_tab_enter"
-
- msg=$( printf "$msg_home_directory" )
- size=$( f_dialog_inputbox_size \
- "$DIALOG_TITLE" \
- "$DIALOG_BACKTITLE" \
- "$msg" \
- "$_input" \
- "$hline" )
-
- local dialog_inputbox
- dialog_inputbox=$( eval $DIALOG \
- --title \"\$DIALOG_TITLE\" \
- --backtitle \"\$DIALOG_BACKTITLE\" \
- --hline \"\$hline\" \
- --ok-label \"\$msg_ok\" \
- --cancel-label \"\$msg_cancel\" \
- --inputbox \"\$msg\" $size \
- \"\$_input\" \
- 2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD
- )
-
- retval=$?
- setvar DIALOG_INPUTBOX_$$ "$dialog_inputbox"
- _input=$( f_dialog_inputstr )
+ local _input="$1"
# Return if user has either pressed ESC or chosen Cancel/No
- [ $retval -eq $SUCCESS ] || return $retval
+ _input=$( f_dialog_input "$msg_home_directory" "$_input" \
+ "$hline_alnum_punc_tab_enter"
+ ) || return
pw_home_dir="$_input"
save_flag=1
- f_dprintf "pw_home_dir: [$cur_pw_home_dir]->[$pw_home_dir]"
+ f_dprintf "pw_home_dir: [%s]->[%s]" "$cur_pw_home_dir" "$pw_home_dir"
return $SUCCESS
}
@@ -1081,7 +864,8 @@ f_dialog_input_home_create()
fi
save_flag=1
- f_dprintf "pw_home_create: [$cur_pw_home_create]->[$pw_home_create]"
+ f_dprintf "pw_home_create: [%s]->[%s]" \
+ "$cur_pw_home_create" "$pw_home_create"
[ $retval -ne 255 ] # return failure if user pressed ESC
}
@@ -1123,7 +907,8 @@ f_dialog_input_group_delete()
fi
save_flag=1
- f_dprintf "pw_group_delete: [$cur_pw_group_delete]->[$pw_group_delete]"
+ f_dprintf "pw_group_delete: [%s]->[%s]" \
+ "$cur_pw_group_delete" "$pw_group_delete"
[ $retval -ne 255 ] # return failure if user pressed ESC
}
@@ -1149,7 +934,8 @@ f_dialog_input_home_delete()
fi
save_flag=1
- f_dprintf "pw_home_delete: [$cur_pw_home_delete]->[$pw_home_delete]"
+ f_dprintf "pw_home_delete: [%s]->[%s]" \
+ "$cur_pw_home_delete" "$pw_home_delete"
[ $retval -ne 255 ] # return failure if user pressed ESC
}
@@ -1176,8 +962,8 @@ f_dialog_input_dotfiles_create()
fi
save_flag=1
- local debug="pw_dotfiles_create:"
- f_dprintf "$debug: [$cur_pw_dotfiles_create]->[$pw_dotfiles_create]"
+ f_dprintf "pw_dotfiles_create: [%s]->[%s]" \
+ "$cur_pw_dotfiles_create" "$pw_dotfiles_create"
[ $retval -ne 255 ] # return failure if user pressed ESC
}
@@ -1235,9 +1021,13 @@ f_dialog_input_shell()
pw_shell="$_input"
save_flag=1
- f_dprintf "pw_shell: [$cur_pw_shell]->[$pw_shell]"
+ f_dprintf "pw_shell: [%s]->[%s]" "$cur_pw_shell" "$pw_shell"
return $SUCCESS
}
+############################################################ MAIN
+
+f_dprintf "%s: Successfully loaded." usermgmt/user_input.subr
+
fi # ! $_USERMGMT_USER_INPUT_SUBR
diff --git a/usr.sbin/bsdconfig/usermgmt/useradd b/usr.sbin/bsdconfig/usermgmt/useradd
index cc1b886..8a69729 100755
--- a/usr.sbin/bsdconfig/usermgmt/useradd
+++ b/usr.sbin/bsdconfig/usermgmt/useradd
@@ -31,6 +31,7 @@
BSDCFG_SHARE="/usr/share/bsdconfig"
. $BSDCFG_SHARE/common.subr || exit 1
+f_dprintf "%s: loading includes..." "$0"
f_include $BSDCFG_SHARE/dialog.subr
BSDCFG_LIBE="/usr/libexec/bsdconfig" APP_DIR="070.usermgmt"
@@ -56,7 +57,6 @@ shift $(( $OPTIND - 1 ))
#
# Chain-load to userinput to centralize code and minimize duplication
#
-f_dialog_init
$BSDCFG_LIBE/$APP_DIR/userinput ${USE_XDIALOG:+-X} mode="Add"
################################################################################
diff --git a/usr.sbin/bsdconfig/usermgmt/userdel b/usr.sbin/bsdconfig/usermgmt/userdel
index e1a26dd..4a7e2be 100755
--- a/usr.sbin/bsdconfig/usermgmt/userdel
+++ b/usr.sbin/bsdconfig/usermgmt/userdel
@@ -31,6 +31,7 @@
BSDCFG_SHARE="/usr/share/bsdconfig"
. $BSDCFG_SHARE/common.subr || exit 1
+f_dprintf "%s: loading includes..." "$0"
f_include $BSDCFG_SHARE/dialog.subr
f_include $BSDCFG_SHARE/mustberoot.subr
f_include $BSDCFG_SHARE/usermgmt/user_input.subr
@@ -59,7 +60,6 @@ shift $(( $OPTIND - 1 ))
#
# Initialize
#
-f_dialog_init
f_dialog_title "$msg_delete $msg_login"
f_dialog_backtitle "${ipgm:+bsdconfig }$pgm"
f_mustberoot_init
@@ -71,7 +71,7 @@ while :; do
f_dialog_menu_user_list
retval=$?
mtag=$( f_dialog_menutag )
- f_dprintf "retval=$retval mtag=[$mtag]"
+ f_dprintf "retval=%u mtag=[%s]" $retval "$mtag"
[ $retval -eq 0 ] || f_die
diff --git a/usr.sbin/bsdconfig/usermgmt/useredit b/usr.sbin/bsdconfig/usermgmt/useredit
index 40a93a8..67aba07 100755
--- a/usr.sbin/bsdconfig/usermgmt/useredit
+++ b/usr.sbin/bsdconfig/usermgmt/useredit
@@ -31,6 +31,7 @@
BSDCFG_SHARE="/usr/share/bsdconfig"
. $BSDCFG_SHARE/common.subr || exit 1
+f_dprintf "%s: loading includes..." "$0"
f_include $BSDCFG_SHARE/dialog.subr
f_include $BSDCFG_SHARE/mustberoot.subr
f_include $BSDCFG_SHARE/usermgmt/user_input.subr
@@ -59,7 +60,6 @@ shift $(( $OPTIND - 1 ))
#
# Initialize
#
-f_dialog_init
f_dialog_title "$msg_edit_view $msg_login"
f_dialog_backtitle "${ipgm:+bsdconfig }$pgm"
f_mustberoot_init
@@ -71,7 +71,7 @@ while :; do
f_dialog_menu_user_list
retval=$?
mtag=$( f_dialog_menutag )
- f_dprintf "retval=$retval mtag=[$mtag]"
+ f_dprintf "retval=%u mtag=[%s]" $retval "$mtag"
[ $retval -eq 0 ] || f_die
diff --git a/usr.sbin/bsdconfig/usermgmt/userinput b/usr.sbin/bsdconfig/usermgmt/userinput
index 0bf8d89..36c43e1 100755
--- a/usr.sbin/bsdconfig/usermgmt/userinput
+++ b/usr.sbin/bsdconfig/usermgmt/userinput
@@ -31,6 +31,7 @@
BSDCFG_SHARE="/usr/share/bsdconfig"
. $BSDCFG_SHARE/common.subr || exit 1
+f_dprintf "%s: loading includes..." "$0"
f_include $BSDCFG_SHARE/dialog.subr
f_include $BSDCFG_SHARE/mustberoot.subr
f_include $BSDCFG_SHARE/usermgmt/user_input.subr
@@ -114,7 +115,7 @@ save_changes()
elif [ "$pw_password" ]; then
cmd="echo \"\$pw_password\" | $cmd -h 0"
fi
- f_dprintf "cmd=$cmd"
+ f_dprintf "cmd=%s" "$cmd"
err=$( eval $cmd 2>&1 )
retval=$?
if [ $retval -ne $SUCCESS ]; then
@@ -160,7 +161,7 @@ save_changes()
elif [ "$pw_password" ]; then
cmd="echo \"\$pw_password\" | $cmd -h 0"
fi
- f_dprintf "cmd=$cmd"
+ f_dprintf "cmd=%s" "$cmd"
err=$( eval $cmd 2>&1 )
retval=$?
if [ $retval -ne $SUCCESS ]; then
@@ -217,19 +218,18 @@ dialog_title_update()
while [ $# -gt 0 ]; do
key="${1%%=*}"
value="${1#*=}"
- f_dprintf "key=[$key] value=[$value]"
+ f_dprintf "key=[%s] value=[%s]" "$key" "$value"
case "$key" in
mode) mode="$value";;
user) user="$value";;
esac
shift
done
-f_dprintf "mode=[$mode] user=[$user]"
+f_dprintf "mode=[%s] user=[%s]" "$mode" "$user"
#
# Initialize
#
-f_dialog_init
dialog_title_update "$mode"
f_dialog_backtitle "${ipgm:+bsdconfig }$pgm"
f_mustberoot_init
@@ -391,7 +391,6 @@ while :; do
\"\$hline\" \
$menu_items )
- local dialog_menu
dialog_menu=$( eval $DIALOG \
--title \"\$DIALOG_TITLE\" \
--backtitle \"\$DIALOG_BACKTITLE\" \
@@ -406,7 +405,7 @@ while :; do
retval=$?
setvar DIALOG_MENU_$$ "$dialog_menu"
mtag=$( f_dialog_menutag )
- f_dprintf "retval=$retval mtag=[$mtag]"
+ f_dprintf "retval=%u mtag=[%s]" $retval "$mtag"
# Exit if user has either pressed ESC or chosen Cancel/No
[ $retval -eq $SUCCESS ] || f_die
@@ -425,7 +424,7 @@ while :; do
f_dialog_menu_user_list
retval=$?
mtag=$( f_dialog_menutag )
- f_dprintf "retval=$retval mtag=[$mtag]"
+ f_dprintf "retval=%u mtag=[%s]" $retval "$mtag"
# Loop if user has either pressed ESC or chosen Cancel/No
[ $retval -eq $SUCCESS ] || continue
diff --git a/usr.sbin/bsdconfig/usermgmt/usermgmt b/usr.sbin/bsdconfig/usermgmt/usermgmt
index f3357d4..5b69efd 100755
--- a/usr.sbin/bsdconfig/usermgmt/usermgmt
+++ b/usr.sbin/bsdconfig/usermgmt/usermgmt
@@ -31,6 +31,7 @@
BSDCFG_SHARE="/usr/share/bsdconfig"
. $BSDCFG_SHARE/common.subr || exit 1
+f_dprintf "%s: loading includes..." "$0"
f_include $BSDCFG_SHARE/dialog.subr
f_include $BSDCFG_SHARE/mustberoot.subr
@@ -114,7 +115,6 @@ shift $(( $OPTIND - 1 ))
#
# Initialize
#
-f_dialog_init
f_dialog_title "$msg_login_management"
f_dialog_backtitle "${ipgm:+bsdconfig }$pgm"
f_mustberoot_init
@@ -126,7 +126,7 @@ while :; do
dialog_menu_main
retval=$?
mtag=$( f_dialog_menutag )
- f_dprintf "retval=$retval mtag=[$mtag]"
+ f_dprintf "retval=%u mtag=[%s]" $retval "$mtag"
if [ $retval -eq 2 ]; then
# The Help button was pressed
diff --git a/usr.sbin/bsdinstall/partedit/Makefile b/usr.sbin/bsdinstall/partedit/Makefile
index 9618b09..21eaf91 100644
--- a/usr.sbin/bsdinstall/partedit/Makefile
+++ b/usr.sbin/bsdinstall/partedit/Makefile
@@ -3,6 +3,7 @@
BINDIR= /usr/libexec/bsdinstall
PROG= partedit
LINKS= ${BINDIR}/partedit ${BINDIR}/autopart
+SYMLINKS= ${BINDIR}/partedit /usr/sbin/sade
LDADD= -lgeom -lncursesw -lutil -ldialog -lm
PARTEDIT_ARCH= ${MACHINE}
@@ -17,6 +18,6 @@ SRCS= diskeditor.c partedit.c gpart_ops.c partedit_${PARTEDIT_ARCH}.c \
part_wizard.c
WARNS?= 3
-NO_MAN= true
+MAN= sade.8
.include <bsd.prog.mk>
diff --git a/usr.sbin/bsdinstall/partedit/partedit.c b/usr.sbin/bsdinstall/partedit/partedit.c
index 2436f08..d470c80 100644
--- a/usr.sbin/bsdinstall/partedit/partedit.c
+++ b/usr.sbin/bsdinstall/partedit/partedit.c
@@ -41,6 +41,7 @@
#include "partedit.h"
struct pmetadata_head part_metadata;
+static int sade_mode = 0;
static int apply_changes(struct gmesh *mesh);
static struct partedit_item *read_geom_mesh(struct gmesh *mesh, int *nitems);
@@ -75,12 +76,15 @@ main(int argc, const char **argv)
int i, op, nitems, nscroll;
int error;
+ if (strcmp(basename(argv[0]), "sade") == 0)
+ sade_mode = 1;
+
TAILQ_INIT(&part_metadata);
init_fstab_metadata();
init_dialog(stdin, stdout);
- if (strcmp(basename(argv[0]), "sade") != 0)
+ if (!sade_mode)
dialog_vars.backtitle = __DECONST(char *, "FreeBSD Installer");
dialog_vars.item_help = TRUE;
nscroll = i = 0;
@@ -261,7 +265,7 @@ validate_setup(void)
* Check for root partitions that we aren't formatting, which is
* usually a mistake
*/
- if (root->newfs == NULL) {
+ if (root->newfs == NULL && !sade_mode) {
dialog_vars.defaultno = TRUE;
cancel = dialog_yesno("Warning", "The chosen root partition "
"has a preexisting filesystem. If it contains an existing "
diff --git a/usr.sbin/sade/sade.8 b/usr.sbin/bsdinstall/partedit/sade.8
index 8acda90..8b2af49 100644
--- a/usr.sbin/sade/sade.8
+++ b/usr.sbin/bsdinstall/partedit/sade.8
@@ -24,7 +24,7 @@
.\"
.\" $FreeBSD$
.\"
-.Dd August 8, 2006
+.Dd December 30, 2012
.Dt SADE 8
.Os
.Sh NAME
@@ -46,28 +46,30 @@ The
.Nm
utility aims to provide a handy tool for disk management
tasks on an already installed system.
-The goal is to save
-some of the useful functionality of the old
-.Xr sysinstall 8
-which
-will be removed from the system in favor of the new installer.
+The goal is to provide the same text interface for disk management in
+.Xr bsdinstall 8
+in the post-installation environment.
.Sh SEE ALSO
-.Xr sysinstall 8
+.Xr bsdinstall 8 ,
+.Xr gpart 8
.Sh HISTORY
-This version of
+A program called
.Nm
first appeared in
-.Fx 6.3 .
-The code is extracted from the
+.Fx 6.3
+as a utility encapsulating features from the
.Xr sysinstall 8
-utility.
+installer. It was replaced in
+.Fx 10.0
+with the equivalent part of
+.Xr bsdinstall 8 .
.Sh AUTHORS
-.An Jordan K. Hubbard Aq jkh@FreeBSD.org
+.An Nathan Whitehorn Aq nwhitehorn@FreeBSD.org
.Sh BUGS
The utility misses a lot of nice features, such as tools for
manipulating
.Xr gmirror 8
or
-.Xr gvinum 8
-stuff.
+.Xr zfs 8
+.
These will be added later.
diff --git a/usr.sbin/bsdinstall/scripts/mirrorselect b/usr.sbin/bsdinstall/scripts/mirrorselect
index d17a16a..30df830 100755
--- a/usr.sbin/bsdinstall/scripts/mirrorselect
+++ b/usr.sbin/bsdinstall/scripts/mirrorselect
@@ -39,7 +39,6 @@ MIRROR=`dialog --backtitle "FreeBSD Installer" \
--menu "Please select the site closest to you or \"other\" if you'd like to specify a different choice. Also note that not every site listed here carries more than the base distribution kits. Only Primary sites are guaranteed to carry the full range of possible distributions. Select a site that's close!" \
0 0 0 \
ftp://ftp.freebsd.org "Main Site"\
- ftp://snapshots.jp.freebsd.org "Snapshots Server Japan"\
ftp://ftp.freebsd.org "IPv6 Main Site"\
ftp://ftp3.ie.freebsd.org "IPv6 Ireland"\
ftp://ftp.il.freebsd.org "IPv6 Israel"\
@@ -192,7 +191,18 @@ MIRROR=`dialog --backtitle "FreeBSD Installer" \
MIRROR_BUTTON=$?
exec 3>&-
-BSDINSTALL_DISTSITE="$MIRROR/pub/FreeBSD/releases/`uname -m`/`uname -p`/`uname -r`"
+_UNAME_R=`uname -r`
+
+case ${_UNAME_R} in
+ *-CURRENT|*-STABLE|*-BETA*|*-PRERELEASE|*-RC*)
+ RELDIR="snapshots"
+ ;;
+ *)
+ RELDIR="releases"
+ ;;
+esac
+
+BSDINSTALL_DISTSITE="$MIRROR/pub/FreeBSD/${RELDIR}/`uname -m`/`uname -p`/${_UNAME_R}"
case $MIRROR_BUTTON in
$DIALOG_CANCEL)
diff --git a/usr.sbin/gssd/Makefile b/usr.sbin/gssd/Makefile
index 3fab810..28e8f7d 100644
--- a/usr.sbin/gssd/Makefile
+++ b/usr.sbin/gssd/Makefile
@@ -7,8 +7,8 @@ SRCS= gssd.c gssd.h gssd_svc.c gssd_xdr.c gssd_prot.c
CFLAGS+= -I.
WARNS?= 1
-DPADD= ${LIBGSSAPI}
-LDADD= -lgssapi
+DPADD= ${LIBGSSAPI} ${LIBKRB5} ${LIBHX509} ${LIBASN1} ${LIBROKEN} ${LIBCOM_ERR} ${LIBCRYPT} ${LIBCRYPTO}
+LDADD= -lgssapi -lkrb5 -lhx509 -lasn1 -lroken -lcom_err -lcrypt -lcrypto
CLEANFILES= gssd_svc.c gssd.h
diff --git a/usr.sbin/gssd/gssd.8 b/usr.sbin/gssd/gssd.8
index 273a9ff..7b006e8 100644
--- a/usr.sbin/gssd/gssd.8
+++ b/usr.sbin/gssd/gssd.8
@@ -25,7 +25,7 @@
.\"
.\" $FreeBSD$
.\"
-.Dd November 5, 2008
+.Dd December 22, 2012
.Dt GSSD 8
.Os
.Sh NAME
@@ -34,6 +34,9 @@
.Sh SYNOPSIS
.Nm
.Op Fl d
+.Op Fl s Ar dir-list
+.Op Fl c Ar file-substring
+.Op Fl r Ar preferred-realm
.Sh DESCRIPTION
The
.Nm
@@ -46,6 +49,29 @@ Run in debug mode.
In this mode,
.Nm
will not fork when it starts.
+.It Fl s Ar dir-list
+Look for an appropriate credential cache file in this list of directories.
+The list should be full pathnames from root, separated by ':' characters.
+Usually this list will simply be "/tmp".
+Without this option, the
+.Nm
+daemon assumes that the credential cache file is called /tmp/krb5cc_<uid>,
+where <uid> is the effective uid for the RPC caller.
+.It Fl c Ar file-substring
+Set a file-substring for the credential cache file names.
+Only files with this substring embedded in their names will be
+selected as candidates when the
+.Fl s
+has been specified.
+If not specified, it defaults to "krb5cc_".
+.It Fl r Ar preferred-realm
+Set a preferred Kerberos realm for the search of the directory list for
+a credentials cache file.
+When set, files with TGT credentials for this realm will be selected over
+other credential files.
+This option is only meaningful when the
+.Fl s
+option has been specified.
.El
.Sh FILES
.Bl -tag -width ".Pa /etc/krb5.keytab" -compact
diff --git a/usr.sbin/gssd/gssd.c b/usr.sbin/gssd/gssd.c
index ba2805b..78ca859 100644
--- a/usr.sbin/gssd/gssd.c
+++ b/usr.sbin/gssd/gssd.c
@@ -33,8 +33,11 @@ __FBSDID("$FreeBSD$");
#include <sys/linker.h>
#include <sys/module.h>
#include <sys/queue.h>
+#include <sys/syslog.h>
#include <ctype.h>
+#include <dirent.h>
#include <err.h>
+#include <krb5.h>
#include <pwd.h>
#include <stdio.h>
#include <stdlib.h>
@@ -63,8 +66,12 @@ int gss_resource_count;
uint32_t gss_next_id;
uint32_t gss_start_time;
int debug_level;
+static char ccfile_dirlist[PATH_MAX + 1], ccfile_substring[NAME_MAX + 1];
+static char pref_realm[1024];
static void gssd_load_mech(void);
+static int find_ccache_file(const char *, uid_t, char *);
+static int is_a_valid_tgt_cache(const char *, uid_t, int *, time_t *);
extern void gssd_1(struct svc_req *rqstp, SVCXPRT *transp);
extern int gssd_syscall(char *path);
@@ -81,14 +88,45 @@ main(int argc, char **argv)
int fd, oldmask, ch, debug;
SVCXPRT *xprt;
+ /*
+ * Initialize the credential cache file name substring and the
+ * search directory list.
+ */
+ strlcpy(ccfile_substring, "krb5cc_", sizeof(ccfile_substring));
+ ccfile_dirlist[0] = '\0';
+ pref_realm[0] = '\0';
debug = 0;
- while ((ch = getopt(argc, argv, "d")) != -1) {
+ while ((ch = getopt(argc, argv, "ds:c:r:")) != -1) {
switch (ch) {
case 'd':
debug_level++;
break;
+ case 's':
+ /*
+ * Set the directory search list. This enables use of
+ * find_ccache_file() to search the directories for a
+ * suitable credentials cache file.
+ */
+ strlcpy(ccfile_dirlist, optarg, sizeof(ccfile_dirlist));
+ break;
+ case 'c':
+ /*
+ * Specify a non-default credential cache file
+ * substring.
+ */
+ strlcpy(ccfile_substring, optarg,
+ sizeof(ccfile_substring));
+ break;
+ case 'r':
+ /*
+ * Set the preferred realm for the credential cache tgt.
+ */
+ strlcpy(pref_realm, optarg, sizeof(pref_realm));
+ break;
default:
- fprintf(stderr, "usage: %s [-d]\n", argv[0]);
+ fprintf(stderr,
+ "usage: %s [-d] [-s dir-list] [-c file-substring]"
+ " [-r preferred-realm]\n", argv[0]);
exit(1);
break;
}
@@ -106,21 +144,43 @@ main(int argc, char **argv)
sun.sun_len = SUN_LEN(&sun);
fd = socket(AF_LOCAL, SOCK_STREAM, 0);
if (!fd) {
+ if (debug_level == 0) {
+ syslog(LOG_ERR, "Can't create local gssd socket");
+ exit(1);
+ }
err(1, "Can't create local gssd socket");
}
oldmask = umask(S_IXUSR|S_IRWXG|S_IRWXO);
if (bind(fd, (struct sockaddr *) &sun, sun.sun_len) < 0) {
+ if (debug_level == 0) {
+ syslog(LOG_ERR, "Can't bind local gssd socket");
+ exit(1);
+ }
err(1, "Can't bind local gssd socket");
}
umask(oldmask);
if (listen(fd, SOMAXCONN) < 0) {
+ if (debug_level == 0) {
+ syslog(LOG_ERR, "Can't listen on local gssd socket");
+ exit(1);
+ }
err(1, "Can't listen on local gssd socket");
}
xprt = svc_vc_create(fd, RPC_MAXDATASIZE, RPC_MAXDATASIZE);
if (!xprt) {
+ if (debug_level == 0) {
+ syslog(LOG_ERR,
+ "Can't create transport for local gssd socket");
+ exit(1);
+ }
err(1, "Can't create transport for local gssd socket");
}
if (!svc_reg(xprt, GSSD, GSSDVERS, gssd_1, NULL)) {
+ if (debug_level == 0) {
+ syslog(LOG_ERR,
+ "Can't register service for local gssd socket");
+ exit(1);
+ }
err(1, "Can't register service for local gssd socket");
}
@@ -244,13 +304,52 @@ gssd_init_sec_context_1_svc(init_sec_context_args *argp, init_sec_context_res *r
gss_cred_id_t cred = GSS_C_NO_CREDENTIAL;
gss_ctx_id_t ctx = GSS_C_NO_CONTEXT;
gss_name_t name = GSS_C_NO_NAME;
- char ccname[strlen("FILE:/tmp/krb5cc_") + 6 + 1];
+ char ccname[PATH_MAX + 5 + 1], *cp, *cp2;
+ int gotone;
- snprintf(ccname, sizeof(ccname), "FILE:/tmp/krb5cc_%d",
- (int) argp->uid);
+ memset(result, 0, sizeof(*result));
+ if (ccfile_dirlist[0] != '\0' && argp->cred == 0) {
+ /*
+ * For the "-s" case and no credentials provided as an
+ * argument, search the directory list for an appropriate
+ * credential cache file. If the search fails, return failure.
+ */
+ gotone = 0;
+ cp = ccfile_dirlist;
+ do {
+ cp2 = strchr(cp, ':');
+ if (cp2 != NULL)
+ *cp2 = '\0';
+ gotone = find_ccache_file(cp, argp->uid, ccname);
+ if (gotone != 0)
+ break;
+ if (cp2 != NULL)
+ *cp2++ = ':';
+ cp = cp2;
+ } while (cp != NULL && *cp != '\0');
+ if (gotone == 0) {
+ result->major_status = GSS_S_CREDENTIALS_EXPIRED;
+ return (TRUE);
+ }
+ } else {
+ /*
+ * If there wasn't a "-s" option or the credentials have
+ * been provided as an argument, do it the old way.
+ * When credentials are provided, the uid should be root.
+ */
+ if (argp->cred != 0 && argp->uid != 0) {
+ if (debug_level == 0)
+ syslog(LOG_ERR, "gss_init_sec_context:"
+ " cred for non-root");
+ else
+ fprintf(stderr, "gss_init_sec_context:"
+ " cred for non-root\n");
+ }
+ snprintf(ccname, sizeof(ccname), "FILE:/tmp/krb5cc_%d",
+ (int) argp->uid);
+ }
setenv("KRB5CCNAME", ccname, TRUE);
- memset(result, 0, sizeof(*result));
if (argp->cred) {
cred = gssd_find_resource(argp->cred);
if (!cred) {
@@ -273,7 +372,6 @@ gssd_init_sec_context_1_svc(init_sec_context_args *argp, init_sec_context_res *r
}
}
- memset(result, 0, sizeof(*result));
result->major_status = gss_init_sec_context(&result->minor_status,
cred, &ctx, name, argp->mech_type,
argp->req_flags, argp->time_req, argp->input_chan_bindings,
@@ -493,13 +591,53 @@ gssd_acquire_cred_1_svc(acquire_cred_args *argp, acquire_cred_res *result, struc
{
gss_name_t desired_name = GSS_C_NO_NAME;
gss_cred_id_t cred;
- char ccname[strlen("FILE:/tmp/krb5cc_") + 6 + 1];
+ char ccname[PATH_MAX + 5 + 1], *cp, *cp2;
+ int gotone;
- snprintf(ccname, sizeof(ccname), "FILE:/tmp/krb5cc_%d",
- (int) argp->uid);
+ memset(result, 0, sizeof(*result));
+ if (ccfile_dirlist[0] != '\0' && argp->desired_name == 0) {
+ /*
+ * For the "-s" case and no name provided as an
+ * argument, search the directory list for an appropriate
+ * credential cache file. If the search fails, return failure.
+ */
+ gotone = 0;
+ cp = ccfile_dirlist;
+ do {
+ cp2 = strchr(cp, ':');
+ if (cp2 != NULL)
+ *cp2 = '\0';
+ gotone = find_ccache_file(cp, argp->uid, ccname);
+ if (gotone != 0)
+ break;
+ if (cp2 != NULL)
+ *cp2++ = ':';
+ cp = cp2;
+ } while (cp != NULL && *cp != '\0');
+ if (gotone == 0) {
+ result->major_status = GSS_S_CREDENTIALS_EXPIRED;
+ return (TRUE);
+ }
+ } else {
+ /*
+ * If there wasn't a "-s" option or the name has
+ * been provided as an argument, do it the old way.
+ * When a name is provided, it will normally exist in the
+ * default keytab file and the uid will be root.
+ */
+ if (argp->desired_name != 0 && argp->uid != 0) {
+ if (debug_level == 0)
+ syslog(LOG_ERR, "gss_acquire_cred:"
+ " principal_name for non-root");
+ else
+ fprintf(stderr, "gss_acquire_cred:"
+ " principal_name for non-root\n");
+ }
+ snprintf(ccname, sizeof(ccname), "FILE:/tmp/krb5cc_%d",
+ (int) argp->uid);
+ }
setenv("KRB5CCNAME", ccname, TRUE);
- memset(result, 0, sizeof(*result));
if (argp->desired_name) {
desired_name = gssd_find_resource(argp->desired_name);
if (!desired_name) {
@@ -608,3 +746,172 @@ gssd_1_freeresult(SVCXPRT *transp, xdrproc_t xdr_result, caddr_t result)
return (TRUE);
}
+
+/*
+ * Search a directory for the most likely candidate to be used as the
+ * credential cache for a uid. If successful, return 1 and fill the
+ * file's path id into "rpath". Otherwise, return 0.
+ */
+static int
+find_ccache_file(const char *dirpath, uid_t uid, char *rpath)
+{
+ DIR *dirp;
+ struct dirent *dp;
+ struct stat sb;
+ time_t exptime, oexptime;
+ int gotone, len, rating, orating;
+ char namepath[PATH_MAX + 5 + 1];
+ char retpath[PATH_MAX + 5 + 1];
+
+ dirp = opendir(dirpath);
+ if (dirp == NULL)
+ return (0);
+ gotone = 0;
+ orating = 0;
+ oexptime = 0;
+ while ((dp = readdir(dirp)) != NULL) {
+ len = snprintf(namepath, sizeof(namepath), "%s/%s", dirpath,
+ dp->d_name);
+ if (len < sizeof(namepath) &&
+ strstr(dp->d_name, ccfile_substring) != NULL &&
+ lstat(namepath, &sb) >= 0 &&
+ sb.st_uid == uid &&
+ S_ISREG(sb.st_mode)) {
+ len = snprintf(namepath, sizeof(namepath), "FILE:%s/%s",
+ dirpath, dp->d_name);
+ if (len < sizeof(namepath) &&
+ is_a_valid_tgt_cache(namepath, uid, &rating,
+ &exptime) != 0) {
+ if (gotone == 0 || rating > orating ||
+ (rating == orating && exptime > oexptime)) {
+ orating = rating;
+ oexptime = exptime;
+ strcpy(retpath, namepath);
+ gotone = 1;
+ }
+ }
+ }
+ }
+ closedir(dirp);
+ if (gotone != 0) {
+ strcpy(rpath, retpath);
+ return (1);
+ }
+ return (0);
+}
+
+/*
+ * Try to determine if the file is a valid tgt cache file.
+ * Check that the file has a valid tgt for a principal.
+ * If it does, return 1, otherwise return 0.
+ * It also returns a "rating" and the expiry time for the TGT, when found.
+ * This "rating" is higher based on heuristics that make it more
+ * likely to be the correct credential cache file to use. It can
+ * be used by the caller, along with expiry time, to select from
+ * multiple credential cache files.
+ */
+static int
+is_a_valid_tgt_cache(const char *filepath, uid_t uid, int *retrating,
+ time_t *retexptime)
+{
+ krb5_context context;
+ krb5_principal princ;
+ krb5_ccache ccache;
+ krb5_error_code retval;
+ krb5_cc_cursor curse;
+ krb5_creds krbcred;
+ int gotone, orating, rating, ret;
+ struct passwd *pw;
+ char *cp, *cp2, *pname;
+ time_t exptime;
+
+ /* Find a likely name for the uid principal. */
+ pw = getpwuid(uid);
+
+ /*
+ * Do a bunch of krb5 library stuff to try and determine if
+ * this file is a credentials cache with an appropriate TGT
+ * in it.
+ */
+ retval = krb5_init_context(&context);
+ if (retval != 0)
+ return (0);
+ retval = krb5_cc_resolve(context, filepath, &ccache);
+ if (retval != 0) {
+ krb5_free_context(context);
+ return (0);
+ }
+ ret = 0;
+ orating = 0;
+ exptime = 0;
+ retval = krb5_cc_start_seq_get(context, ccache, &curse);
+ if (retval == 0) {
+ while ((retval = krb5_cc_next_cred(context, ccache, &curse,
+ &krbcred)) == 0) {
+ gotone = 0;
+ rating = 0;
+ retval = krb5_unparse_name(context, krbcred.server,
+ &pname);
+ if (retval == 0) {
+ cp = strchr(pname, '/');
+ if (cp != NULL) {
+ *cp++ = '\0';
+ if (strcmp(pname, "krbtgt") == 0 &&
+ krbcred.times.endtime > time(NULL)
+ ) {
+ gotone = 1;
+ /*
+ * Test to see if this is a
+ * tgt for cross-realm auth.
+ * Rate it higher, if it is not.
+ */
+ cp2 = strchr(cp, '@');
+ if (cp2 != NULL) {
+ *cp2++ = '\0';
+ if (strcmp(cp, cp2) ==
+ 0)
+ rating++;
+ }
+ }
+ }
+ free(pname);
+ }
+ if (gotone != 0) {
+ retval = krb5_unparse_name(context,
+ krbcred.client, &pname);
+ if (retval == 0) {
+ cp = strchr(pname, '@');
+ if (cp != NULL) {
+ *cp++ = '\0';
+ if (pw != NULL && strcmp(pname,
+ pw->pw_name) == 0)
+ rating++;
+ if (strchr(pname, '/') == NULL)
+ rating++;
+ if (pref_realm[0] != '\0' &&
+ strcmp(cp, pref_realm) == 0)
+ rating++;
+ }
+ }
+ free(pname);
+ if (rating > orating) {
+ orating = rating;
+ exptime = krbcred.times.endtime;
+ } else if (rating == orating &&
+ krbcred.times.endtime > exptime)
+ exptime = krbcred.times.endtime;
+ ret = 1;
+ }
+ krb5_free_cred_contents(context, &krbcred);
+ }
+ krb5_cc_end_seq_get(context, ccache, &curse);
+ }
+ krb5_cc_close(context, ccache);
+ krb5_free_context(context);
+ if (ret != 0) {
+ *retrating = orating;
+ *retexptime = exptime;
+ }
+ return (ret);
+}
+
diff --git a/usr.sbin/iostat/iostat.8 b/usr.sbin/iostat/iostat.8
index d8957ef..1d2d517 100644
--- a/usr.sbin/iostat/iostat.8
+++ b/usr.sbin/iostat/iostat.8
@@ -56,7 +56,7 @@
.\"
.\" @(#)iostat.8 8.1 (Berkeley) 6/6/93
.\"
-.Dd November 24, 2010
+.Dd December 15, 2012
.Dt IOSTAT 8
.Os
.Sh NAME
@@ -366,6 +366,32 @@ average duration of transactions, in milliseconds
% of time the device had one or more outstanding transactions
.El
.Pp
+The extended
+.Nm
+device display, with the
+.Fl x
+and
+.Fl I
+flags specified, shows the following statistics:
+.Pp
+.Bl -tag -width indent -compact
+.It r/i
+read operations per time period
+.It w/i
+write operations per time period
+.It kr/i
+kilobytes read per time period
+.It kw/i
+kilobytes write per time period
+.It qlen
+transactions queue length
+.It tsvc_t/i
+total duration of transactions per time period, in seconds
+.It sb/i
+total time the device had one or more outstanding transactions per
+time period, in seconds
+.El
+.Pp
The old-style
.Nm
display (using
diff --git a/usr.sbin/iostat/iostat.c b/usr.sbin/iostat/iostat.c
index 1c32f94..92b98e4 100644
--- a/usr.sbin/iostat/iostat.c
+++ b/usr.sbin/iostat/iostat.c
@@ -731,10 +731,10 @@ devstats(int perf_select, long double etime, int havelast)
u_int64_t total_bytes, total_transfers, total_blocks;
u_int64_t total_bytes_read, total_transfers_read;
u_int64_t total_bytes_write, total_transfers_write;
- long double busy_pct;
+ long double busy_pct, busy_time;
u_int64_t queue_len;
long double total_mb;
- long double blocks_per_second, ms_per_transaction;
+ long double blocks_per_second, ms_per_transaction, total_duration;
int firstline = 1;
char *devname;
@@ -745,14 +745,13 @@ devstats(int perf_select, long double etime, int havelast)
if (Cflag > 0)
printf(" cpu ");
printf("\n");
- if (Iflag == 0)
- printf(
- "device r/s w/s kr/s kw/s qlen svc_t %%b "
- );
- else
- printf(
- "device r/i w/i kr/i kw/i qlen svc_t %%b "
- );
+ if (Iflag == 0) {
+ printf("device r/s w/s kr/s kw/s qlen "
+ "svc_t %%b ");
+ } else {
+ printf("device r/i w/i kr/i"
+ " kw/i qlen tsvc_t/i sb/i ");
+ }
if (Tflag > 0)
printf("tin tout ");
if (Cflag > 0)
@@ -789,6 +788,8 @@ devstats(int perf_select, long double etime, int havelast)
DSM_MS_PER_TRANSACTION, &ms_per_transaction,
DSM_BUSY_PCT, &busy_pct,
DSM_QUEUE_LENGTH, &queue_len,
+ DSM_TOTAL_DURATION, &total_duration,
+ DSM_TOTAL_BUSY_TIME, &busy_time,
DSM_NONE) != 0)
errx(1, "%s", devstat_errbuf);
@@ -827,7 +828,9 @@ devstats(int perf_select, long double etime, int havelast)
queue_len,
ms_per_transaction, busy_pct);
else
- printf("%-8.8s %5.1Lf %5.1Lf %7.1Lf %7.1Lf %4" PRIu64 " %5.1Lf %3.0Lf ",
+ printf("%-8.8s %11.1Lf %11.1Lf "
+ "%12.1Lf %12.1Lf %4" PRIu64
+ " %10.1Lf %9.1Lf ",
devname,
(long double)total_transfers_read,
(long double)total_transfers_write,
@@ -836,7 +839,7 @@ devstats(int perf_select, long double etime, int havelast)
(long double)
total_bytes_write / 1024,
queue_len,
- ms_per_transaction, busy_pct);
+ total_duration, busy_time);
if (firstline) {
/*
* If this is the first device
diff --git a/usr.sbin/mergemaster/mergemaster.sh b/usr.sbin/mergemaster/mergemaster.sh
index 1723fee..48b58f3 100755
--- a/usr.sbin/mergemaster/mergemaster.sh
+++ b/usr.sbin/mergemaster/mergemaster.sh
@@ -421,11 +421,11 @@ check_pager () {
echo " I cannot execute it. So, what would you like to do?"
echo ''
echo " Use 'e' to exit mergemaster and fix your PAGER variable"
- if [ -x /usr/bin/less -o -x /usr/local/bin/less ]; then
echo " Use 'l' to set PAGER to 'less' for this run"
- fi
echo " Use 'm' to use plain old 'more' as your PAGER for this run"
echo ''
+ echo " or you may type an absolute path to PAGER for this run"
+ echo ''
echo " Default is to use plain old 'more' "
echo ''
echo -n "What should I do? [Use 'more'] "
@@ -436,21 +436,14 @@ check_pager () {
exit 0
;;
[lL])
- if [ -x /usr/bin/less ]; then
- PAGER=/usr/bin/less
- elif [ -x /usr/local/bin/less ]; then
- PAGER=/usr/local/bin/less
- else
- echo ''
- echo " *** Fatal Error:"
- echo " You asked to use 'less' as your pager, but I can't"
- echo " find it in /usr/bin or /usr/local/bin"
- exit 1
- fi
+ PAGER=less
;;
[mM]|'')
PAGER=more
;;
+ /*)
+ PAGER="$FIXPAGER"
+ ;;
*)
echo ''
echo "invalid choice: ${FIXPAGER}"
diff --git a/usr.sbin/mountd/exports.5 b/usr.sbin/mountd/exports.5
index 75a5121..1293524 100644
--- a/usr.sbin/mountd/exports.5
+++ b/usr.sbin/mountd/exports.5
@@ -28,7 +28,7 @@
.\" @(#)exports.5 8.3 (Berkeley) 3/29/95
.\" $FreeBSD$
.\"
-.Dd July 12, 2011
+.Dd December 23, 2012
.Dt EXPORTS 5
.Os
.Sh NAME
@@ -311,12 +311,15 @@ For the third form which specifies the NFSv4 tree root, the directory path
specifies the location within the server's file system tree which is the
root of the NFSv4 tree.
All entries of this form must specify the same directory path.
-This location can be any directory and does not
+For file systems other than ZFS,
+this location can be any directory and does not
need to be within an exported file system. If it is not in an exported
file system, a very limited set of operations are permitted, so that an
NFSv4 client can traverse the tree to an exported file system.
Although parts of the NFSv4 tree can be non-exported, the entire NFSv4 tree
must consist of local file systems capable of being exported via NFS.
+All ZFS file systems in the subtree below the NFSv4 tree root must be
+exported.
NFSv4 does not use the mount protocol and does permit clients to cross server
mount point boundaries, although not all clients are capable of crossing the
mount points.
diff --git a/usr.sbin/mountd/mountd.c b/usr.sbin/mountd/mountd.c
index 543fc14..bc290d6 100644
--- a/usr.sbin/mountd/mountd.c
+++ b/usr.sbin/mountd/mountd.c
@@ -649,7 +649,7 @@ create_service(struct netconfig *nconf)
*/
if ((fd = __rpc_nconf2fd(nconf)) < 0) {
int non_fatal = 0;
- if (errno == EPROTONOSUPPORT &&
+ if (errno == EAFNOSUPPORT &&
nconf->nc_semantics != NC_TPI_CLTS)
non_fatal = 1;
diff --git a/usr.sbin/moused/moused.8 b/usr.sbin/moused/moused.8
index 30b2200..5e4dd43 100644
--- a/usr.sbin/moused/moused.8
+++ b/usr.sbin/moused/moused.8
@@ -296,7 +296,7 @@ information are:
.Bl -tag -compact -width modelxxx
.It Ar port
Port (device file) name, i.e.\&
-.Pa /dev/cuad0 ,
+.Pa /dev/cuau0 ,
.Pa /dev/mse0
and
.Pa /dev/psm0 .
@@ -564,7 +564,7 @@ There may be more than one serial port to which the serial
mouse can be attached.
Many people often assign the first, built-in
serial port
-.Pa /dev/cuad0
+.Pa /dev/cuau0
to the mouse.
You can attach multiple USB mice to your system or to your USB hub.
They are accessible as
@@ -731,16 +731,16 @@ utility
UNIX-domain stream socket for X10 MouseRemote events
.El
.Sh EXAMPLES
-.Dl "moused -p /dev/cuad0 -i type"
+.Dl "moused -p /dev/cuau0 -i type"
.Pp
Let the
.Nm
utility determine the protocol type of the mouse at the serial port
-.Pa /dev/cuad0 .
+.Pa /dev/cuau0 .
If successful, the command will print the type, otherwise it will say
.Dq Li unknown .
.Bd -literal -offset indent
-moused -p /dev/cuad0
+moused -p /dev/cuau0
vidcontrol -m on
.Ed
.Pp
diff --git a/usr.sbin/mptable/mptable.c b/usr.sbin/mptable/mptable.c
index 3c38ccf..01fa897 100644
--- a/usr.sbin/mptable/mptable.c
+++ b/usr.sbin/mptable/mptable.c
@@ -42,7 +42,7 @@ static const char rcsid[] =
#define EXTENDED_PROCESSING_READY
#define OEM_PROCESSING_READY_NOT
-#include <sys/types.h>
+#include <sys/param.h>
#include <err.h>
#include <fcntl.h>
#include <paths.h>
@@ -270,8 +270,8 @@ static void pnstr( char* s, int c );
/* global data */
static int pfd; /* physical /dev/mem fd */
-static int busses[16];
-static int apics[16];
+static int busses[256];
+static int apics[256];
static int ncpu;
static int nbus;
@@ -710,10 +710,12 @@ MPConfigTableHeader( u_int32_t pap )
printf( "MP Config Base Table Entries:\n\n" );
- /* initialze tables */
- for ( x = 0; x < 16; ++x ) {
- busses[ x ] = apics[ x ] = 0xff;
- }
+ /* initialize tables */
+ for (x = 0; x < (int)nitems(busses); x++)
+ busses[x] = 0xff;
+
+ for (x = 0; x < (int)nitems(apics); x++)
+ apics[x] = 0xff;
ncpu = 0;
nbus = 0;
diff --git a/usr.sbin/mtest/mtest.c b/usr.sbin/mtest/mtest.c
index 60f7e09..a28fab7 100644
--- a/usr.sbin/mtest/mtest.c
+++ b/usr.sbin/mtest/mtest.c
@@ -204,12 +204,12 @@ main(int argc, char **argv)
s6 = -1;
#ifdef INET
s = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP);
- if (s == -1 && errno != EPROTONOSUPPORT)
+ if (s == -1 && errno != EAFNOSUPPORT)
err(1, "can't open IPv4 socket");
#endif
#ifdef INET6
s6 = socket(AF_INET6, SOCK_DGRAM, IPPROTO_UDP);
- if (s6 == -1 && errno != EPROTONOSUPPORT)
+ if (s6 == -1 && errno != EAFNOSUPPORT)
err(1, "can't open IPv6 socket");
#endif
if (s == -1 && s6 == -1)
diff --git a/usr.sbin/ndiscvt/inf-parse.y b/usr.sbin/ndiscvt/inf-parse.y
index 8a84956..2a8876d 100644
--- a/usr.sbin/ndiscvt/inf-parse.y
+++ b/usr.sbin/ndiscvt/inf-parse.y
@@ -40,7 +40,6 @@ __FBSDID("$FreeBSD$");
#include "inf.h"
-extern int yyparse (void);
extern int yylex (void);
extern void yyerror(const char *);
%}
diff --git a/usr.sbin/ndp/ndp.8 b/usr.sbin/ndp/ndp.8
index 1fb63f81..9eabfe4 100644
--- a/usr.sbin/ndp/ndp.8
+++ b/usr.sbin/ndp/ndp.8
@@ -231,8 +231,8 @@ responding to requests for
.Ar hostname
even though the host address is not its own.
.It Fl t
-Print timestamp on each entry,
-making it possible to merge output with
+Print timestamp for each entry,
+to make it possible to merge the output with
.Xr tcpdump 1 .
Most useful when used with
.Fl A .
diff --git a/usr.sbin/ndp/ndp.c b/usr.sbin/ndp/ndp.c
index be21d0f..b50ddb7 100644
--- a/usr.sbin/ndp/ndp.c
+++ b/usr.sbin/ndp/ndp.c
@@ -404,12 +404,8 @@ set(argc, argv)
return 1;
}
sin->sin6_addr = ((struct sockaddr_in6 *)res->ai_addr)->sin6_addr;
-#ifdef __KAME__
- if (IN6_IS_ADDR_LINKLOCAL(&sin->sin6_addr)) {
- *(u_int16_t *)&sin->sin6_addr.s6_addr[2] =
- htons(((struct sockaddr_in6 *)res->ai_addr)->sin6_scope_id);
- }
-#endif
+ sin->sin6_scope_id =
+ ((struct sockaddr_in6 *)res->ai_addr)->sin6_scope_id;
ea = (u_char *)LLADDR(&sdl_m);
if (ndp_ether_aton(eaddr, ea) == 0)
sdl_m.sdl_alen = 6;
@@ -478,12 +474,6 @@ get(host)
return;
}
sin->sin6_addr = ((struct sockaddr_in6 *)res->ai_addr)->sin6_addr;
-#ifdef __KAME__
- if (IN6_IS_ADDR_LINKLOCAL(&sin->sin6_addr)) {
- *(u_int16_t *)&sin->sin6_addr.s6_addr[2] =
- htons(((struct sockaddr_in6 *)res->ai_addr)->sin6_scope_id);
- }
-#endif
dump(&sin->sin6_addr, 0);
if (found_entry == 0) {
getnameinfo((struct sockaddr *)sin, sin->sin6_len, host_buf,
@@ -520,12 +510,8 @@ delete(host)
return 1;
}
sin->sin6_addr = ((struct sockaddr_in6 *)res->ai_addr)->sin6_addr;
-#ifdef __KAME__
- if (IN6_IS_ADDR_LINKLOCAL(&sin->sin6_addr)) {
- *(u_int16_t *)&sin->sin6_addr.s6_addr[2] =
- htons(((struct sockaddr_in6 *)res->ai_addr)->sin6_scope_id);
- }
-#endif
+ sin->sin6_scope_id =
+ ((struct sockaddr_in6 *)res->ai_addr)->sin6_scope_id;
if (rtmsg(RTM_GET) < 0) {
errx(1, "RTM_GET(%s) failed", host);
/* NOTREACHED */
@@ -556,16 +542,8 @@ delete:
NEXTADDR(RTA_DST, sin_m);
rtm->rtm_flags |= RTF_LLDATA;
if (rtmsg(RTM_DELETE) == 0) {
- struct sockaddr_in6 s6 = *sin; /* XXX: for safety */
-
-#ifdef __KAME__
- if (IN6_IS_ADDR_LINKLOCAL(&s6.sin6_addr)) {
- s6.sin6_scope_id = ntohs(*(u_int16_t *)&s6.sin6_addr.s6_addr[2]);
- *(u_int16_t *)&s6.sin6_addr.s6_addr[2] = 0;
- }
-#endif
- getnameinfo((struct sockaddr *)&s6,
- s6.sin6_len, host_buf,
+ getnameinfo((struct sockaddr *)sin,
+ sin->sin6_len, host_buf,
sizeof(host_buf), NULL, 0,
(nflag ? NI_NUMERICHOST : 0));
printf("%s (%s) deleted\n", host, host_buf);
@@ -666,10 +644,6 @@ again:;
/* XXX: should scope id be filled in the kernel? */
if (sin->sin6_scope_id == 0)
sin->sin6_scope_id = sdl->sdl_index;
-#ifdef __KAME__
- /* KAME specific hack; removed the embedded id */
- *(u_int16_t *)&sin->sin6_addr.s6_addr[2] = 0;
-#endif
}
getnameinfo((struct sockaddr *)sin, sin->sin6_len, host_buf,
sizeof(host_buf), NULL, 0, (nflag ? NI_NUMERICHOST : 0));
@@ -1331,22 +1305,6 @@ plist()
p6.sin6_len = sizeof(p6);
p6.sin6_addr = PR.prefix;
#endif
-
- /*
- * copy link index to sin6_scope_id field.
- * XXX: KAME specific.
- */
- if (IN6_IS_ADDR_LINKLOCAL(&p6.sin6_addr)) {
- u_int16_t linkid;
-
- memcpy(&linkid, &p6.sin6_addr.s6_addr[2],
- sizeof(linkid));
- linkid = ntohs(linkid);
- p6.sin6_scope_id = linkid;
- p6.sin6_addr.s6_addr[2] = 0;
- p6.sin6_addr.s6_addr[3] = 0;
- }
-
niflags = NI_NUMERICHOST;
if (getnameinfo((struct sockaddr *)&p6,
sizeof(p6), namebuf, sizeof(namebuf),
diff --git a/usr.sbin/nfsd/nfsd.c b/usr.sbin/nfsd/nfsd.c
index 6a2f785..0e39138 100644
--- a/usr.sbin/nfsd/nfsd.c
+++ b/usr.sbin/nfsd/nfsd.c
@@ -264,7 +264,7 @@ main(int argc, char **argv)
ip6flag = 1;
s = socket(AF_INET6, SOCK_DGRAM, IPPROTO_UDP);
if (s == -1) {
- if (errno != EPROTONOSUPPORT)
+ if (errno != EPROTONOSUPPORT && errno != EAFNOSUPPORT)
err(1, "socket");
ip6flag = 0;
} else if (getnetconfigent("udp6") == NULL ||
diff --git a/usr.sbin/nfsd/nfsv4.4 b/usr.sbin/nfsd/nfsv4.4
index d2c19ed..679bb69 100644
--- a/usr.sbin/nfsd/nfsv4.4
+++ b/usr.sbin/nfsd/nfsv4.4
@@ -24,7 +24,7 @@
.\"
.\" $FreeBSD$
.\"
-.Dd May 15, 2011
+.Dd December 23, 2012
.Dt NFSV4 4
.Os
.Sh NAME
@@ -98,6 +98,8 @@ allows a limited subset of operations to be performed on non-exported subtrees
of the local file system, so that traversal of the tree to the exported
subtrees is possible.
As such, the ``<rootdir>'' can be in a non-exported file system.
+The exception is ZFS, which checks exports and, as such, all ZFS file systems
+below the ``<rootdir>'' must be exported.
However,
the entire tree that is rooted at that point must be in local file systems
that are of types that can be NFS exported.
diff --git a/usr.sbin/nmtree/Makefile b/usr.sbin/nmtree/Makefile
new file mode 100644
index 0000000..58e46ea
--- /dev/null
+++ b/usr.sbin/nmtree/Makefile
@@ -0,0 +1,26 @@
+# $FreeBSD$
+
+.include <bsd.own.mk>
+
+.PATH: ${.CURDIR}/../../contrib/mtree
+
+PROG= nmtree
+MAN= nmtree.8
+SRCS= compare.c crc.c create.c excludes.c getid.c misc.c mtree.c \
+ spec.c specspec.c verify.c
+LDADD+= -lmd -lutil
+
+CFLAGS+= -I${.CURDIR}/../../contrib/mknod
+.PATH: ${.CURDIR}/../../contrib/mknod
+SRCS+= pack_dev.c
+
+CFLAGS+= -I${.CURDIR}/../../lib/libnetbsd
+LIBNETBSDDIR= ${.OBJDIR}/../../lib/libnetbsd
+LIBNETBSD= ${LIBNETBSDDIR}/libnetbsd.a
+DPADD+= ${LIBNETBSD}
+LDADD+= ${LIBNETBSD}
+
+nmtree.8: mtree.8
+ cp ${.ALLSRC} ${.TARGET}
+
+.include <bsd.prog.mk>
diff --git a/usr.sbin/pkg/Makefile b/usr.sbin/pkg/Makefile
index 360e301..c2ca0a3 100644
--- a/usr.sbin/pkg/Makefile
+++ b/usr.sbin/pkg/Makefile
@@ -1,7 +1,7 @@
# $FreeBSD$
PROG= pkg
-SRC= pkg.c
+SRCS= pkg.c dns_utils.c
NO_MAN= yes
DPADD= ${LIBARCHIVE} ${LIBELF} ${LIBFETCH}
diff --git a/usr.sbin/pkg/dns_utils.c b/usr.sbin/pkg/dns_utils.c
new file mode 100644
index 0000000..e88bf98
--- /dev/null
+++ b/usr.sbin/pkg/dns_utils.c
@@ -0,0 +1,136 @@
+/*-
+ * Copyright (c) 2012 Baptiste Daroussin <bapt@FreeBSD.org>
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer,
+ * without modification, immediately at the beginning of 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 ``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.
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
+#include <stdlib.h>
+#include <string.h>
+#include <netinet/in.h>
+#include <resolv.h>
+
+#include "dns_utils.h"
+
+typedef union {
+ HEADER hdr;
+ unsigned char buf[1024];
+} dns_query;
+
+struct dns_srvinfo *
+dns_getsrvinfo(const char *zone)
+{
+ struct dns_srvinfo **res, *first;
+ unsigned char *end, *p;
+ char host[MAXHOSTNAMELEN];
+ dns_query q;
+ int len, qdcount, ancount, n, i;
+ unsigned int type, class, ttl, priority, weight, port;
+
+ if ((len = res_query(zone, C_IN, T_SRV, q.buf, sizeof(q.buf))) == -1 ||
+ len < (int)sizeof(HEADER))
+ return (NULL);
+
+ qdcount = ntohs(q.hdr.qdcount);
+ ancount = ntohs(q.hdr.ancount);
+
+ end = q.buf + len;
+ p = q.buf + sizeof(HEADER);
+
+ while(qdcount > 0 && p < end) {
+ qdcount--;
+ if((len = dn_expand(q.buf, end, p, host, MAXHOSTNAMELEN)) < 0)
+ return (NULL);
+ p += len + NS_QFIXEDSZ;
+ }
+
+ res = malloc(sizeof(struct dns_srvinfo) * ancount);
+ if (res == NULL)
+ return (NULL);
+ memset(res, 0, sizeof(struct dns_srvinfo) * ancount);
+
+ n = 0;
+ while (ancount > 0 && p < end) {
+ ancount--;
+ len = dn_expand(q.buf, end, p, host, MAXHOSTNAMELEN);
+ if (len < 0) {
+ for (i = 0; i < n; i++)
+ free(res[i]);
+ free(res);
+ return NULL;
+ }
+
+ p += len;
+
+ NS_GET16(type, p);
+ NS_GET16(class, p);
+ NS_GET32(ttl, p);
+ NS_GET16(len, p);
+
+ if (type != T_SRV) {
+ p += len;
+ continue;
+ }
+
+ NS_GET16(priority, p);
+ NS_GET16(weight, p);
+ NS_GET16(port, p);
+
+ len = dn_expand(q.buf, end, p, host, MAXHOSTNAMELEN);
+ if (len < 0) {
+ for (i = 0; i < n; i++)
+ free(res[i]);
+ free(res);
+ return (NULL);
+ }
+
+ res[n] = malloc(sizeof(struct dns_srvinfo));
+ if (res[n] == NULL) {
+ for (i = 0; i < n; i++)
+ free(res[i]);
+ free(res);
+ return (NULL);
+ }
+ res[n]->type = type;
+ res[n]->class = class;
+ res[n]->ttl = ttl;
+ res[n]->priority = priority;
+ res[n]->weight = weight;
+ res[n]->port = port;
+ res[n]->next = NULL;
+ strlcpy(res[n]->host, host, MAXHOSTNAMELEN);
+
+ p += len;
+ n++;
+ }
+
+ for (i = 0; i < n - 1; i++)
+ res[i]->next = res[i + 1];
+
+ first = res[0];
+ free(res);
+
+ return (first);
+}
diff --git a/usr.sbin/sade/list.h b/usr.sbin/pkg/dns_utils.h
index 8c5cf2a..0f3367b 100644
--- a/usr.sbin/sade/list.h
+++ b/usr.sbin/pkg/dns_utils.h
@@ -1,55 +1,45 @@
-/*
- * $FreeBSD$
- *
- * Copyright (c) 1997 FreeBSD, Inc.
+/*-
+ * Copyright (c) 2012 Baptiste Daroussin <bapt@FreeBSD.org>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer,
- * verbatim and that no modifications are made prior to this
- * point in the file.
+ * 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 PAUL TRAINA ``AS IS'' AND
+ *
+ * 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 PAUL TRAINA OR HIS KILLER RATS BE LIABLE
+ * 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, LIFE OR PROFITS; OR BUSINESS INTERRUPTION)
+ * 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$
*/
-/* The structure */
-typedef struct _qelement {
- struct _qelement *q_forw;
- struct _qelement *q_back;
-} qelement;
-
-#define INITQUE(Xhead) { \
- (Xhead).q_forw = &(Xhead); \
- (Xhead).q_back = &(Xhead); \
-}
-
-#define EMPTYQUE(Xhead) \
- ((Xhead).q_forw == &(Xhead))
+#ifndef DNS_UTILS_H
+#define DNS_UTILS_H
+struct dns_srvinfo {
+ unsigned int type;
+ unsigned int class;
+ unsigned int ttl;
+ unsigned int priority;
+ unsigned int weight;
+ unsigned int port;
+ char host[MAXHOSTNAMELEN];
+ struct dns_srvinfo *next;
+};
-#define INSQUEUE(elem, pred) { \
- register qelement *Xe = (qelement *) (elem); \
- register qelement *Xp = (qelement *) (pred); \
- Xp->q_forw = (Xe->q_forw = (Xe->q_back = Xp)->q_forw)->q_back = Xe; \
-}
+struct dns_srvinfo *
+ dns_getsrvinfo(const char *zone);
-#define REMQUE(elem) { \
- register qelement *Xe = (qelement *) (elem); \
- (Xe->q_back->q_forw = Xe->q_forw)->q_back = Xe->q_back; \
-}
+#endif
diff --git a/usr.sbin/pkg/pkg.c b/usr.sbin/pkg/pkg.c
index 8dc7bcf..1b3146b 100644
--- a/usr.sbin/pkg/pkg.c
+++ b/usr.sbin/pkg/pkg.c
@@ -48,9 +48,10 @@ __FBSDID("$FreeBSD$");
#include <unistd.h>
#include "elf_tables.h"
+#include "dns_utils.h"
#define _LOCALBASE "/usr/local"
-#define _PKGS_URL "http://pkgbeta.FreeBSD.org"
+#define _PKGS_URL "http://pkg.FreeBSD.org"
static const char *
elf_corres_to_string(struct _elf_corres *m, int e)
@@ -281,16 +282,20 @@ install_pkg_static(char *path, char *pkgpath)
static int
bootstrap_pkg(void)
{
+ struct url *u;
FILE *remote;
FILE *config;
char *site;
+ struct dns_srvinfo *mirrors, *current;
+ /* To store _https._tcp. + hostname + \0 */
+ char zone[MAXHOSTNAMELEN + 13];
char url[MAXPATHLEN];
char conf[MAXPATHLEN];
char abi[BUFSIZ];
char tmppkg[MAXPATHLEN];
char buf[10240];
char pkgstatic[MAXPATHLEN];
- int fd, retry, ret;
+ int fd, retry, ret, max_retry;
struct url_stat st;
off_t done, r;
time_t now;
@@ -298,9 +303,11 @@ bootstrap_pkg(void)
done = 0;
last = 0;
+ max_retry = 3;
ret = -1;
remote = NULL;
config = NULL;
+ current = mirrors = NULL;
printf("Bootstrapping pkg please wait\n");
@@ -324,12 +331,37 @@ bootstrap_pkg(void)
return (-1);
}
- retry = 3;
- do {
- remote = fetchXGetURL(url, &st, "");
- if (remote == NULL)
- sleep(1);
- } while (remote == NULL && retry-- > 0);
+ retry = max_retry;
+
+ u = fetchParseURL(url);
+ while (remote == NULL) {
+ if (retry == max_retry) {
+ if (strcmp(u->scheme, "file") != 0) {
+ snprintf(zone, sizeof(zone),
+ "_%s._tcp.%s", u->scheme, u->host);
+ printf("%s\n", zone);
+ mirrors = dns_getsrvinfo(zone);
+ current = mirrors;
+ }
+ }
+
+ if (mirrors != NULL)
+ strlcpy(u->host, current->host, sizeof(u->host));
+
+ remote = fetchXGet(u, &st, "");
+ if (remote == NULL) {
+ --retry;
+ if (retry <= 0)
+ goto fetchfail;
+ if (mirrors == NULL) {
+ sleep(1);
+ } else {
+ current = current->next;
+ if (current == NULL)
+ current = mirrors;
+ }
+ }
+ }
if (remote == NULL)
goto fetchfail;
@@ -420,6 +452,14 @@ main(__unused int argc, char *argv[])
getenv("LOCALBASE") ? getenv("LOCALBASE") : _LOCALBASE);
if (access(pkgpath, X_OK) == -1) {
+ /*
+ * To allow 'pkg -N' to be used as a reliable test for whether
+ * a system is configured to use pkg, don't bootstrap pkg
+ * when that argument is given as argv[1].
+ */
+ if (argv[1] != NULL && strcmp(argv[1], "-N") == 0)
+ errx(EXIT_FAILURE, "pkg is not installed");
+
/*
* Do not ask for confirmation if either of stdin or stdout is
* not tty. Check the environment to see if user has answer
diff --git a/usr.sbin/portsnap/portsnap/portsnap.sh b/usr.sbin/portsnap/portsnap/portsnap.sh
index ed9c28d..f9f4716 100644
--- a/usr.sbin/portsnap/portsnap/portsnap.sh
+++ b/usr.sbin/portsnap/portsnap/portsnap.sh
@@ -612,6 +612,28 @@ fetch_progress() {
echo -n " "
}
+pct_fmt()
+{
+ printf " \r"
+ printf "($1/$2) %02.2f%% " `echo "scale=4;$LNC / $TOTAL * 100"|bc`
+}
+
+fetch_progress_percent() {
+ TOTAL=$1
+ LNC=0
+ pct_fmt $LNC $TOTAL
+ while read x; do
+ LNC=$(($LNC + 1))
+ if [ $(($LNC % 100)) = 0 ]; then
+ pct_fmt $LNC $TOTAL
+ elif [ $(($LNC % 10)) = 0 ]; then
+ echo -n .
+ fi
+ done
+ pct_fmt $LNC $TOTAL
+ echo " done. "
+}
+
# Sanity-check an index file
fetch_index_sanity() {
if grep -qvE "^[-_+./@0-9A-Za-z]+\|[0-9a-f]{64}$" INDEX.new ||
@@ -781,11 +803,13 @@ fetch_update() {
echo " done." 1>${QUIETREDIR}
# Attempt to fetch ports patches
- echo -n "Fetching `wc -l < patchlist | tr -d ' '` "
+ patchcnt=`wc -l < patchlist | tr -d ' '`
+ echo -n "Fetching $patchcnt "
echo ${NDEBUG} "patches.${DDSTATS}"
+ echo " "
tr '|' '-' < patchlist | lam -s "bp/" - |
xargs ${XARGST} ${PHTTPGET} ${SERVERNAME} \
- 2>${STATSREDIR} | fetch_progress
+ 2>${STATSREDIR} | fetch_progress_percent $patchcnt
echo "done."
# Attempt to apply ports patches
diff --git a/usr.sbin/ppp/README.changes b/usr.sbin/ppp/README.changes
index bf626e3..4ed3da6 100644
--- a/usr.sbin/ppp/README.changes
+++ b/usr.sbin/ppp/README.changes
@@ -53,7 +53,7 @@ o Errors in `add' and `delete' are logged as warnings rather than being
written to the TCP/IP log.
o Any number of diagnostic prompts are allowed, and they are allowed in
interactive mode.
-o The default `device' is cuad1, then cuad0
+o The default `device' is cuau1, then cuau0
o A password of "*" in ppp.secret causes a passwd database lookup in
pap mode.
o The value of the CONNECT environment variable is logged in the
diff --git a/usr.sbin/ppp/defs.h b/usr.sbin/ppp/defs.h
index f56ee32..d7cc799 100644
--- a/usr.sbin/ppp/defs.h
+++ b/usr.sbin/ppp/defs.h
@@ -30,7 +30,7 @@
/* Check the following definitions for your machine environment */
#ifdef __FreeBSD__
-# define MODEM_LIST "/dev/cuad1\0/dev/cuad0" /* name of tty device */
+# define MODEM_LIST "/dev/cuau1\0/dev/cuau0" /* name of tty device */
#else
# ifdef __OpenBSD__
# define MODEM_LIST "/dev/cua01\0/dev/cua00" /* name of tty device */
diff --git a/usr.sbin/ppp/ppp.8.m4 b/usr.sbin/ppp/ppp.8.m4
index 7d3f6d2..91b9c51 100644
--- a/usr.sbin/ppp/ppp.8.m4
+++ b/usr.sbin/ppp/ppp.8.m4
@@ -551,7 +551,7 @@ and have not authenticated yourself using the correct password.
.Pp
You can start by specifying the device name and speed:
.Bd -literal -offset indent
-ppp ON awfulhak> set device /dev/cuad0
+ppp ON awfulhak> set device /dev/cuau0
ppp ON awfulhak> set speed 38400
.Ed
.Pp
@@ -610,7 +610,7 @@ Name: deflink
Phone Number: N/A
Defaults:
- Device List: /dev/cuad0
+ Device List: /dev/cuau0
Characteristics: 38400bps, cs8, even parity, CTS/RTS on
Connect time: 0 secs
@@ -1216,10 +1216,10 @@ It is usually also necessary to train your modem to the same DTR speed
as the getty:
.Bd -literal -offset indent
# ppp
-ppp ON awfulhak> set device /dev/cuad1
+ppp ON awfulhak> set device /dev/cuau1
ppp ON awfulhak> set speed 38400
ppp ON awfulhak> term
-deflink: Entering terminal mode on /dev/cuad1
+deflink: Entering terminal mode on /dev/cuau1
Type `~?' for help
at
OK
@@ -2164,7 +2164,7 @@ and
.Dq set speed
to specify your serial line and speed, for example:
.Bd -literal -offset indent
-set device /dev/cuad0
+set device /dev/cuau0
set speed 115200
.Ed
.Pp
@@ -2529,7 +2529,7 @@ Armed with this information, the following configuration might be used:
mp:
set timeout 0
set log phase chat
- set device /dev/cuad0 /dev/cuad1 /dev/cuad2
+ set device /dev/cuau0 /dev/cuau1 /dev/cuau2
set phone "123456789"
set dial "ABORT BUSY ABORT NO\\sCARRIER TIMEOUT 5 \\"\\" ATZ \e
OK-AT-OK \\\\dATDT\\\\T TIMEOUT 45 CONNECT"
@@ -2563,9 +2563,9 @@ line above, and specifying the following after the
.Dq clone
command:
.Bd -literal -offset indent
- link 1 set device /dev/cuad0
- link 2 set device /dev/cuad1
- link 3 set device /dev/cuad2
+ link 1 set device /dev/cuau0
+ link 2 set device /dev/cuau1
+ link 3 set device /dev/cuau2
.Ed
.Pp
Use the
@@ -4073,7 +4073,7 @@ The default link name is
.Sq deflink .
Renaming it to
.Sq modem ,
-.Sq cuad0
+.Sq cuau0
or
.Sq USR
may make the log file more readable.
diff --git a/usr.sbin/pw/bitmap.c b/usr.sbin/pw/bitmap.c
index bcfea7e..8e96bff 100644
--- a/usr.sbin/pw/bitmap.c
+++ b/usr.sbin/pw/bitmap.c
@@ -50,8 +50,7 @@ bm_alloc(int size)
void
bm_dealloc(struct bitmap * bm)
{
- if (bm->map)
- free(bm->map);
+ free(bm->map);
}
static void
diff --git a/usr.sbin/pw/grupd.c b/usr.sbin/pw/grupd.c
index e9f6b5e..3f78e95 100644
--- a/usr.sbin/pw/grupd.c
+++ b/usr.sbin/pw/grupd.c
@@ -50,12 +50,11 @@ setgrdir(const char * dir)
{
if (dir == NULL)
return -1;
- else {
- char * d = malloc(strlen(dir)+1);
- if (d == NULL)
- return -1;
- grpath = strcpy(d, dir);
- }
+ else
+ grpath = strdup(dir);
+ if (grpath == NULL)
+ return -1;
+
return 0;
}
diff --git a/usr.sbin/pw/pw_group.c b/usr.sbin/pw/pw_group.c
index f4f2116..3259412 100644
--- a/usr.sbin/pw/pw_group.c
+++ b/usr.sbin/pw/pw_group.c
@@ -274,8 +274,7 @@ pw_group(struct userconf * cnf, int mode, struct cargs * args)
pw_log(cnf, mode, W_GROUP, "%s(%ld)", grp->gr_name, (long) grp->gr_gid);
- if (members)
- free(members);
+ free(members);
return EXIT_SUCCESS;
}
@@ -408,7 +407,7 @@ print_group(struct group * grp, int pretty)
char *buf = NULL;
buf = gr_make(grp);
- fputs(buf, stdout);
+ printf("%s\n", buf);
free(buf);
} else {
int i;
diff --git a/usr.sbin/pw/pw_user.c b/usr.sbin/pw/pw_user.c
index abf1c35..5577511 100644
--- a/usr.sbin/pw/pw_user.c
+++ b/usr.sbin/pw/pw_user.c
@@ -394,7 +394,7 @@ pw_user(struct userconf * cnf, int mode, struct cargs * args)
/*
* Remove crontabs
*/
- sprintf(file, "/var/cron/tabs/%s", pwd->pw_name);
+ snprintf(file, sizeof(file), "/var/cron/tabs/%s", pwd->pw_name);
if (access(file, F_OK) == 0) {
sprintf(file, "crontab -u %s -r", pwd->pw_name);
system(file);
@@ -745,24 +745,18 @@ pw_user(struct userconf * cnf, int mode, struct cargs * args)
*/
if (mode == M_ADD || getarg(args, 'G') != NULL) {
- int i, j;
+ int i;
for (i = 0; cnf->groups[i] != NULL; i++) {
grp = GETGRNAM(cnf->groups[i]);
- for (j = 0; grp->gr_mem[j] != NULL; j++) {
- if (!strcmp(grp->gr_mem[j], pwd->pw_name))
- break;
- }
- if (grp->gr_mem[j] != NULL) /* user already member of group */
+ grp = gr_add(grp, pwd->pw_name);
+ /*
+ * grp can only be NULL in 2 cases:
+ * - the new member is already a member
+ * - a problem with memory occurs
+ * in both cases we want to skip now.
+ */
+ if (grp == NULL)
continue;
-
- if (j == 0)
- grp->gr_mem = NULL;
-
- grp->gr_mem = reallocf(grp->gr_mem, sizeof(*grp->gr_mem) *
- (j + 2));
-
- grp->gr_mem[j] = pwd->pw_name;
- grp->gr_mem[j+1] = NULL;
chggrent(cnf->groups[i], grp);
}
}
diff --git a/usr.sbin/pw/pw_vpw.c b/usr.sbin/pw/pw_vpw.c
index 674b64f..99663be 100644
--- a/usr.sbin/pw/pw_vpw.c
+++ b/usr.sbin/pw/pw_vpw.c
@@ -30,6 +30,10 @@ static const char rcsid[] =
"$FreeBSD$";
#endif /* not lint */
+#include <pwd.h>
+#include <grp.h>
+#include <libutil.h>
+#define _WITH_GETLINE
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
@@ -55,101 +59,44 @@ vsetpwent(void)
}
static struct passwd *
-vnextpwent(char const * nam, uid_t uid, int doclose)
+vnextpwent(char const *nam, uid_t uid, int doclose)
{
- struct passwd * pw = NULL;
- static char pwtmp[1024];
-
- strlcpy(pwtmp, getpwpath(_MASTERPASSWD), sizeof(pwtmp));
-
- if (pwd_fp != NULL || (pwd_fp = fopen(pwtmp, "r")) != NULL) {
- int done = 0;
-
- static struct passwd pwd;
-
- while (!done && fgets(pwtmp, sizeof pwtmp, pwd_fp) != NULL)
- {
- int i, quickout = 0;
- char * q;
- char * p = strchr(pwtmp, '\n');
-
- if (p == NULL) {
- while (fgets(pwtmp, sizeof pwtmp, pwd_fp) != NULL && strchr(pwtmp, '\n')==NULL)
- ; /* Skip long lines */
- continue;
- }
-
- /* skip comments & empty lines */
- if (*pwtmp =='\n' || *pwtmp == '#')
+ struct passwd *pw;
+ char *line;
+ size_t linecap;
+ ssize_t linelen;
+
+ pw = NULL;
+ line = NULL;
+ linecap = 0;
+ linelen = 0;
+
+ if (pwd_fp != NULL || (pwd_fp = fopen(getpwpath(_MASTERPASSWD), "r")) != NULL) {
+ while ((linelen = getline(&line, &linecap, pwd_fp)) > 0) {
+ /* Skip comments and empty lines */
+ if (*line == '\n' || *line == '#')
continue;
-
- i = 0;
- q = p = pwtmp;
- bzero(&pwd, sizeof pwd);
- while (!quickout && (p = strsep(&q, ":\n")) != NULL) {
- switch (i++)
- {
- case 0: /* username */
- pwd.pw_name = p;
- if (nam) {
- if (strcmp(nam, p) == 0)
- done = 1;
- else
- quickout = 1;
- }
- break;
- case 1: /* password */
- pwd.pw_passwd = p;
- break;
- case 2: /* uid */
- pwd.pw_uid = atoi(p);
- if (uid != (uid_t)-1) {
- if (uid == pwd.pw_uid)
- done = 1;
- else
- quickout = 1;
- }
- break;
- case 3: /* gid */
- pwd.pw_gid = atoi(p);
- break;
- case 4: /* class */
- if (nam == NULL && uid == (uid_t)-1)
- done = 1;
- pwd.pw_class = p;
- break;
- case 5: /* change */
- pwd.pw_change = (time_t)atol(p);
- break;
- case 6: /* expire */
- pwd.pw_expire = (time_t)atol(p);
- break;
- case 7: /* gecos */
- pwd.pw_gecos = p;
- break;
- case 8: /* directory */
- pwd.pw_dir = p;
- break;
- case 9: /* shell */
- pwd.pw_shell = p;
- break;
- }
- }
- }
+ /* trim latest \n */
+ if (line[linelen - 1 ] == '\n')
+ line[linelen - 1] = '\0';
+ pw = pw_scan(line, PWSCAN_MASTER);
+ if (uid != (uid_t)-1) {
+ if (uid == pw->pw_uid)
+ break;
+ } else if (nam != NULL) {
+ if (strcmp(nam, pw->pw_name) == 0)
+ break;
+ } else
+ break;
+ free(pw);
+ pw = NULL;
+ }
if (doclose)
vendpwent();
- if (done && pwd.pw_name) {
- pw = &pwd;
+ }
+ free(line);
- #define CKNULL(s) s = s ? s : ""
- CKNULL(pwd.pw_passwd);
- CKNULL(pwd.pw_class);
- CKNULL(pwd.pw_gecos);
- CKNULL(pwd.pw_dir);
- CKNULL(pwd.pw_shell);
- }
- }
- return pw;
+ return (pw);
}
struct passwd *
@@ -192,93 +139,44 @@ vsetgrent(void)
}
static struct group *
-vnextgrent(char const * nam, gid_t gid, int doclose)
+vnextgrent(char const *nam, gid_t gid, int doclose)
{
- struct group * gr = NULL;
-
- static char * grtmp = NULL;
- static int grlen = 0;
- static char ** mems = NULL;
- static int memlen = 0;
-
- extendline(&grtmp, &grlen, MAXPATHLEN);
- strlcpy(grtmp, getgrpath(_GROUP), MAXPATHLEN);
-
- if (grp_fp != NULL || (grp_fp = fopen(grtmp, "r")) != NULL) {
- int done = 0;
-
- static struct group grp;
-
- while (!done && fgets(grtmp, grlen, grp_fp) != NULL)
- {
- int i, quickout = 0;
- int mno = 0;
- char * q, * p;
- const char * sep = ":\n";
-
- if ((p = strchr(grtmp, '\n')) == NULL) {
- int l;
- extendline(&grtmp, &grlen, grlen + PWBUFSZ);
- l = strlen(grtmp);
- if (fgets(grtmp + l, grlen - l, grp_fp) == NULL)
- break; /* No newline terminator on last line */
- }
+ struct group *gr;
+ char *line;
+ size_t linecap;
+ ssize_t linelen;
+
+ gr = NULL;
+ line = NULL;
+ linecap = 0;
+ linelen = 0;
+
+ if (grp_fp != NULL || (grp_fp = fopen(getgrpath(_GROUP), "r")) != NULL) {
+ while ((linelen = getline(&line, &linecap, grp_fp)) > 0) {
/* Skip comments and empty lines */
- if (*grtmp == '\n' || *grtmp == '#')
+ if (*line == '\n' || *line == '#')
continue;
- i = 0;
- q = p = grtmp;
- bzero(&grp, sizeof grp);
- extendarray(&mems, &memlen, 200);
- while (!quickout && (p = strsep(&q, sep)) != NULL) {
- switch (i++)
- {
- case 0: /* groupname */
- grp.gr_name = p;
- if (nam) {
- if (strcmp(nam, p) == 0)
- done = 1;
- else
- quickout = 1;
- }
- break;
- case 1: /* password */
- grp.gr_passwd = p;
+ /* trim latest \n */
+ if (line[linelen - 1 ] == '\n')
+ line[linelen - 1] = '\0';
+ gr = gr_scan(line);
+ if (gid != (gid_t)-1) {
+ if (gid == gr->gr_gid)
break;
- case 2: /* gid */
- grp.gr_gid = atoi(p);
- if (gid != (gid_t)-1) {
- if (gid == (gid_t)grp.gr_gid)
- done = 1;
- else
- quickout = 1;
- } else if (nam == NULL)
- done = 1;
+ } else if (nam != NULL) {
+ if (strcmp(nam, gr->gr_name) == 0)
break;
- case 3:
- q = p;
- sep = ",\n";
- break;
- default:
- if (*p) {
- extendarray(&mems, &memlen, mno + 2);
- mems[mno++] = p;
- }
- break;
- }
- }
- grp.gr_mem = mems;
- mems[mno] = NULL;
- }
+ } else
+ break;
+ free(gr);
+ gr = NULL;
+ }
if (doclose)
vendgrent();
- if (done && grp.gr_name) {
- gr = &grp;
-
- CKNULL(grp.gr_passwd);
- }
}
- return gr;
+ free(line);
+
+ return (gr);
}
struct group *
diff --git a/usr.sbin/pw/pwupd.c b/usr.sbin/pw/pwupd.c
index 4ab0f01..22662db 100644
--- a/usr.sbin/pw/pwupd.c
+++ b/usr.sbin/pw/pwupd.c
@@ -56,12 +56,10 @@ setpwdir(const char * dir)
{
if (dir == NULL)
return -1;
- else {
- char * d = malloc(strlen(dir)+1);
- if (d == NULL)
- return -1;
- pwpath = strcpy(d, dir);
- }
+ else
+ pwpath = strdup(dir);
+ if (pwpath == NULL)
+ return -1;
return 0;
}
@@ -148,7 +146,11 @@ pw_update(struct passwd * pwd, char const * user)
pw_fini();
err(1, "pw_copy()");
}
- if (pw_mkdb(user) == -1) {
+ /*
+ * in case of deletion of a user, the whole database
+ * needs to be regenerated
+ */
+ if (pw_mkdb(pw != NULL ? user : NULL) == -1) {
pw_fini();
err(1, "pw_mkdb()");
}
diff --git a/usr.sbin/pw/rm_r.c b/usr.sbin/pw/rm_r.c
index 4ad590b..797ca9d 100644
--- a/usr.sbin/pw/rm_r.c
+++ b/usr.sbin/pw/rm_r.c
@@ -52,7 +52,7 @@ rm_r(char const * dir, uid_t uid)
while ((e = readdir(d)) != NULL) {
if (strcmp(e->d_name, ".") != 0 && strcmp(e->d_name, "..") != 0) {
- sprintf(file, "%s/%s", dir, e->d_name);
+ snprintf(file, sizeof(file), "%s/%s", dir, e->d_name);
if (lstat(file, &st) == 0) { /* Need symlinks, not
* linked file */
if (S_ISDIR(st.st_mode)) /* Directory - recurse */
diff --git a/usr.sbin/rpcbind/rpcbind.c b/usr.sbin/rpcbind/rpcbind.c
index 3d11af1..fb6c99d 100644
--- a/usr.sbin/rpcbind/rpcbind.c
+++ b/usr.sbin/rpcbind/rpcbind.c
@@ -289,7 +289,7 @@ init_transport(struct netconfig *nconf)
*/
if ((fd = __rpc_nconf2fd(nconf)) < 0) {
int non_fatal = 0;
- if (errno == EPROTONOSUPPORT)
+ if (errno == EAFNOSUPPORT)
non_fatal = 1;
syslog(non_fatal?LOG_DEBUG:LOG_ERR, "cannot create socket for %s",
nconf->nc_netid);
@@ -352,7 +352,7 @@ init_transport(struct netconfig *nconf)
*/
if ((fd = __rpc_nconf2fd(nconf)) < 0) {
int non_fatal = 0;
- if (errno == EPROTONOSUPPORT &&
+ if (errno == EAFNOSUPPORT &&
nconf->nc_semantics != NC_TPI_CLTS)
non_fatal = 1;
syslog(non_fatal ? LOG_DEBUG : LOG_ERR,
diff --git a/usr.sbin/sade/Makefile b/usr.sbin/sade/Makefile
deleted file mode 100644
index 1a7c8b2..0000000
--- a/usr.sbin/sade/Makefile
+++ /dev/null
@@ -1,27 +0,0 @@
-# $FreeBSD$
-
-.if ${MACHINE_CPUARCH} != "ia64"
-_wizard= wizard.c
-.endif
-
-PROG= sade
-MAN= sade.8
-SRCS= command.c devices.c \
- disks.c dmenu.c \
- globals.c install.c \
- label.c main.c menus.c misc.c \
- msg.c system.c termcap.c \
- variable.c ${_wizard}
-WARNS?= 3
-
-# command.c
-
-.if ${MACHINE} == "pc98"
-CFLAGS+= -DPC98
-.endif
-CFLAGS+= -I${.CURDIR}/../../contrib/dialog -I.
-
-DPADD= ${LIBDIALOG} ${LIBNCURSESW} ${LIBM} ${LIBUTIL} ${LIBDISK}
-LDADD= -ldialog -lncursesw -lm -lutil -ldisk
-
-.include <bsd.prog.mk>
diff --git a/usr.sbin/sade/command.c b/usr.sbin/sade/command.c
deleted file mode 100644
index b3968df..0000000
--- a/usr.sbin/sade/command.c
+++ /dev/null
@@ -1,179 +0,0 @@
-/*
- * $FreeBSD$
- *
- * Copyright (c) 1995
- * Jordan Hubbard. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer,
- * verbatim and that no modifications are made prior to this
- * point in the file.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY JORDAN HUBBARD ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL JORDAN HUBBARD OR HIS PETS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, LIFE OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- */
-
-#include "sade.h"
-
-#define MAX_NUM_COMMANDS 10
-
-typedef struct {
- char key[FILENAME_MAX];
- struct {
- enum { CMD_SHELL, CMD_FUNCTION } type;
- void *ptr, *data;
- } cmds[MAX_NUM_COMMANDS];
- int ncmds;
-} Command;
-
-#define MAX_CMDS 200
-static Command *commandStack[MAX_CMDS];
-int numCommands;
-
-/* Nuke the command stack */
-void
-command_clear(void)
-{
- int i, j;
-
- for (i = 0; i < numCommands; i++)
- for (j = 0; j < commandStack[i]->ncmds; j++)
- if (commandStack[i]->cmds[j].type == CMD_SHELL)
- free(commandStack[i]->cmds[j].ptr);
- free(commandStack[i]);
- numCommands = 0;
-}
-
-static void
-addit(char *key, int type, void *cmd, void *data)
-{
- int i;
-
- /* First, look for the key already present and add a command to it if found */
- for (i = 0; i < numCommands; i++) {
- if (!strcmp(commandStack[i]->key, key)) {
- if (commandStack[i]->ncmds == MAX_NUM_COMMANDS)
- msgFatal("More than %d commands stacked up behind %s??", MAX_NUM_COMMANDS, key);
- commandStack[i]->cmds[commandStack[i]->ncmds].type = type;
- commandStack[i]->cmds[commandStack[i]->ncmds].ptr = cmd;
- commandStack[i]->cmds[commandStack[i]->ncmds].data = data;
- ++(commandStack[i]->ncmds);
- return;
- }
- }
- if (numCommands == MAX_CMDS)
- msgFatal("More than %d commands accumulated??", MAX_CMDS);
-
- /* If we fell to here, it's a new key */
- commandStack[numCommands] = safe_malloc(sizeof(Command));
- strcpy(commandStack[numCommands]->key, key);
- commandStack[numCommands]->ncmds = 1;
- commandStack[numCommands]->cmds[0].type = type;
- commandStack[numCommands]->cmds[0].ptr = cmd;
- commandStack[numCommands]->cmds[0].data = data;
- ++numCommands;
-}
-
-/* Add a shell command under a given key */
-void
-command_shell_add(char *key, const char *fmt, ...)
-{
- va_list args;
- char *cmd;
-
- cmd = (char *)safe_malloc(256);
- va_start(args, fmt);
- vsnprintf(cmd, 256, fmt, args);
- va_end(args);
-
- addit(key, CMD_SHELL, cmd, NULL);
-}
-
-/* Add a shell command under a given key */
-void
-command_func_add(char *key, commandFunc func, void *data)
-{
- addit(key, CMD_FUNCTION, func, data);
-}
-
-static int
-sort_compare(Command *p1, Command *p2)
-{
- if (!p1 && !p2)
- return 0;
- else if (!p1 && p2) /* NULL has a "greater" value for commands */
- return 1;
- else if (p1 && !p2)
- return -1;
- else
- return strcmp(p1->key, p2->key);
-}
-
-void
-command_sort(void)
-{
- int i, j;
-
- commandStack[numCommands] = NULL;
- /* Just do a crude bubble sort since the list is small */
- for (i = 0; i < numCommands; i++) {
- for (j = 0; j < numCommands; j++) {
- if (sort_compare(commandStack[j], commandStack[j + 1]) > 0) {
- Command *tmp = commandStack[j];
-
- commandStack[j] = commandStack[j + 1];
- commandStack[j + 1] = tmp;
- }
- }
- }
-}
-
-/* Run all accumulated commands in sorted order */
-void
-command_execute(void)
-{
- int i, j, ret;
- commandFunc func;
-
- for (i = 0; i < numCommands; i++) {
- for (j = 0; j < commandStack[i]->ncmds; j++) {
- /* If it's a shell command, run system on it */
- if (commandStack[i]->cmds[j].type == CMD_SHELL) {
- msgNotify("Doing %s", (char *)commandStack[i]->cmds[j].ptr);
- ret = vsystem("%s", (char *)commandStack[i]->cmds[j].ptr);
- if (isDebug())
- msgDebug("Command `%s' returns status %d\n",
- (char *)commandStack[i]->cmds[j].ptr, ret);
- }
- else {
- /* It's a function pointer - call it with the key and
- the data */
- func = (commandFunc)commandStack[i]->cmds[j].ptr;
- if (isDebug())
- msgDebug("%p: Execute(%s, %s)\n",
- func, commandStack[i]->key,
- (char *)commandStack[i]->cmds[j].data);
- ret = (*func)(commandStack[i]->key, commandStack[i]->cmds[j].data);
- if (isDebug())
- msgDebug("Function @ %p returns status %d\n",
- commandStack[i]->cmds[j].ptr, ret);
- }
- }
- }
-}
diff --git a/usr.sbin/sade/devices.c b/usr.sbin/sade/devices.c
deleted file mode 100644
index 672ee20..0000000
--- a/usr.sbin/sade/devices.c
+++ /dev/null
@@ -1,344 +0,0 @@
-/*
- * $FreeBSD$
- *
- * Copyright (c) 1995
- * Jordan Hubbard. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer,
- * verbatim and that no modifications are made prior to this
- * point in the file.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY JORDAN HUBBARD ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL JORDAN HUBBARD OR HIS PETS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, LIFE OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- */
-
-#include <sys/fcntl.h>
-#include <sys/param.h>
-#include <sys/socket.h>
-#include <sys/ioctl.h>
-#include <sys/errno.h>
-#include <sys/time.h>
-#include <sys/stat.h>
-#include <ctype.h>
-#include <libdisk.h>
-
-#include "sade.h"
-
-/* how much to bias minor number for a given /dev/<ct#><un#>s<s#> slice */
-#define SLICE_DELTA (0x10000)
-
-static Device *Devices[DEV_MAX];
-static int numDevs;
-
-#define DEVICE_ENTRY(type, name, descr, max) { type, name, descr, max }
-
-#define DISK(name, descr, max) \
- DEVICE_ENTRY(DEVICE_TYPE_DISK, name, descr, max)
-
-static struct _devname {
- DeviceType type;
- char *name;
- char *description;
- int max;
-} device_names[] = {
- DISK("da%d", "SCSI disk device", 16),
- DISK("ad%d", "ATA/IDE disk device", 16),
- DISK("ar%d", "ATA/IDE RAID device", 16),
- DISK("afd%d", "ATAPI/IDE floppy device", 4),
- DISK("mlxd%d", "Mylex RAID disk", 4),
- DISK("amrd%d", "AMI MegaRAID drive", 4),
- DISK("idad%d", "Compaq RAID array", 4),
- DISK("twed%d", "3ware ATA RAID array", 4),
- DISK("aacd%d", "Adaptec FSA RAID array", 4),
- DISK("ipsd%d", "IBM ServeRAID RAID array", 4),
- DISK("mfid%d", "LSI MegaRAID SAS array", 4),
- { 0, NULL, NULL, 0 },
-};
-
-Device *
-new_device(char *name)
-{
- Device *dev;
-
- dev = safe_malloc(sizeof(Device));
- bzero(dev, sizeof(Device));
- if (name)
- SAFE_STRCPY(dev->name, name);
- return dev;
-}
-
-/* Stubs for unimplemented strategy routines */
-Boolean
-dummyInit(Device *dev)
-{
- return TRUE;
-}
-
-FILE *
-dummyGet(Device *dev, char *dist, Boolean probe)
-{
- return NULL;
-}
-
-void
-dummyShutdown(Device *dev)
-{
- return;
-}
-
-static int
-deviceTry(struct _devname dev, char *try, int i)
-{
- int fd;
- char unit[80];
-
- snprintf(unit, sizeof unit, dev.name, i);
- snprintf(try, FILENAME_MAX, "/dev/%s", unit);
- if (isDebug())
- msgDebug("deviceTry: attempting to open %s\n", try);
- fd = open(try, O_RDONLY);
- if (fd >= 0) {
- if (isDebug())
- msgDebug("deviceTry: open of %s succeeded.\n", try);
- }
- return fd;
-}
-
-/* Register a new device in the devices array */
-Device *
-deviceRegister(char *name, char *desc, char *devname, DeviceType type,
- Boolean (*init)(Device *), FILE * (*get)(Device *, char *, Boolean),
- void (*shutdown)(Device *), void *private)
-{
- Device *newdev = NULL;
-
- if (numDevs == DEV_MAX)
- msgFatal("Too many devices found!");
- else {
- newdev = new_device(name);
- newdev->description = desc;
- newdev->devname = devname;
- newdev->type = type;
- newdev->init = init ? init : dummyInit;
- newdev->get = get ? get : dummyGet;
- newdev->shutdown = shutdown ? shutdown : dummyShutdown;
- newdev->private = private;
- Devices[numDevs] = newdev;
- Devices[++numDevs] = NULL;
- }
- return newdev;
-}
-
-/* Reset the registered device chain */
-void
-deviceReset(void)
-{
- int i;
-
- for (i = 0; i < numDevs; i++) {
- DEVICE_SHUTDOWN(Devices[i]);
-
- /* XXX this potentially leaks Devices[i]->private if it's being
- * used to point to something dynamic, but you're not supposed
- * to call this routine at such times that some open instance
- * has its private ptr pointing somewhere anyway. XXX
- */
- free(Devices[i]);
- }
- Devices[numDevs = 0] = NULL;
-}
-
-/* Get all device information for devices we have attached */
-void
-deviceGetAll(void)
-{
- int i, j;
- char **names;
-
- msgNotify("Probing devices, please wait (this can take a while)...");
-
- /* Next, try to find all the types of devices one might need
- * during the second stage of the installation.
- */
- for (i = 0; device_names[i].name; i++) {
- for (j = 0; j < device_names[i].max; j++) {
- char try[FILENAME_MAX];
-
- switch(device_names[i].type) {
- case DEVICE_TYPE_DISK:
- deviceTry(device_names[i], try, j);
- break;
-
- default:
- break;
- }
- }
- }
-
- /* Finally, go get the disks and look for DOS partitions to register */
- if ((names = Disk_Names()) != NULL) {
- int i;
-
- for (i = 0; names[i]; i++) {
- Disk *d;
-
- /* Ignore memory disks */
- if (!strncmp(names[i], "md", 2))
- continue;
-
- /*
- * XXX
- * Due to unknown reasons, Disk_Names() returns SCSI CDROM as a
- * valid disk. This is main reason why sysinstall presents SCSI
- * CDROM to available disks in Fdisk/Label menu. In addition,
- * adding a blank SCSI CDROM to the menu generates floating point
- * exception in sparc64. Disk_Names() just extracts sysctl
- * "kern.disks". Why GEOM treats SCSI CDROM as a disk is beyond
- * me and that should be investigated.
- * For temporary workaround, ignore SCSI CDROM device.
- */
- if (!strncmp(names[i], "cd", 2))
- continue;
-
- d = Open_Disk(names[i]);
- if (!d) {
- msgDebug("Unable to open disk %s\n", names[i]);
- continue;
- }
-
- deviceRegister(names[i], names[i], d->name, DEVICE_TYPE_DISK,
- dummyInit, dummyGet, dummyShutdown, d);
- if (isDebug())
- msgDebug("Found a disk device named %s\n", names[i]);
-
-#if 0
- /* Look for existing DOS partitions to register as "DOS media devices" */
- for (c1 = d->chunks->part; c1; c1 = c1->next) {
- if (c1->type == fat || c1->type == efi || c1->type == extended) {
- Device *dev;
- char devname[80];
-
- /* Got one! */
- snprintf(devname, sizeof devname, "/dev/%s", c1->name);
- dev = deviceRegister(c1->name, c1->name, strdup(devname), DEVICE_TYPE_DOS,
- mediaInitDOS, mediaGetDOS, mediaShutdownDOS, NULL);
- dev->private = c1;
- if (isDebug())
- msgDebug("Found a DOS partition %s on drive %s\n", c1->name, d->name);
- }
- }
-#endif
- }
- free(names);
- }
- dlg_clear();
-}
-
-/* Rescan all devices, after closing previous set - convenience function */
-void
-deviceRescan(void)
-{
- deviceReset();
- deviceGetAll();
-}
-
-/*
- * Find all devices that match the criteria, allowing "wildcarding" as well
- * by allowing NULL or ANY values to match all. The array returned is static
- * and may be used until the next invocation of deviceFind().
- */
-Device **
-deviceFind(char *name, DeviceType class)
-{
- static Device *found[DEV_MAX];
- int i, j;
-
- j = 0;
- for (i = 0; i < numDevs; i++) {
- if ((!name || !strcmp(Devices[i]->name, name))
- && (class == DEVICE_TYPE_ANY || class == Devices[i]->type))
- found[j++] = Devices[i];
- }
- found[j] = NULL;
- return j ? found : NULL;
-}
-
-Device **
-deviceFindDescr(char *name, char *desc, DeviceType class)
-{
- static Device *found[DEV_MAX];
- int i, j;
-
- j = 0;
- for (i = 0; i < numDevs; i++) {
- if ((!name || !strcmp(Devices[i]->name, name)) &&
- (!desc || !strcmp(Devices[i]->description, desc)) &&
- (class == DEVICE_TYPE_ANY || class == Devices[i]->type))
- found[j++] = Devices[i];
- }
- found[j] = NULL;
- return j ? found : NULL;
-}
-
-int
-deviceCount(Device **devs)
-{
- int i;
-
- if (!devs)
- return 0;
- for (i = 0; devs[i]; i++);
- return i;
-}
-
-/*
- * Create a menu listing all the devices of a certain type in the system.
- * The passed-in menu is expected to be a "prototype" from which the new
- * menu is cloned.
- */
-DMenu *
-deviceCreateMenu(DMenu *menu, DeviceType type, int (*hook)(dialogMenuItem *d))
-{
- Device **devs;
- int numdevs;
- DMenu *tmp = NULL;
- int i, j;
-
- devs = deviceFind(NULL, type);
- numdevs = deviceCount(devs);
- if (!numdevs)
- return NULL;
- tmp = (DMenu *)safe_malloc(sizeof(DMenu) + (sizeof(dialogMenuItem) * (numdevs + 1)));
- bcopy(menu, tmp, sizeof(DMenu));
- for (i = 0; devs[i]; i++) {
- tmp->items[i].prompt = devs[i]->name;
- for (j = 0; j < numDevs; j++) {
- if (devs[i] == Devices[j]) {
- tmp->items[i].title = Devices[j]->description;
- break;
- }
- }
- if (j == numDevs)
- tmp->items[i].title = "<unknown device type>";
- tmp->items[i].fire = hook;
- }
- tmp->items[i].title = NULL;
- return tmp;
-}
diff --git a/usr.sbin/sade/disks.c b/usr.sbin/sade/disks.c
deleted file mode 100644
index 513643b..0000000
--- a/usr.sbin/sade/disks.c
+++ /dev/null
@@ -1,972 +0,0 @@
-/*
- * $FreeBSD$
- *
- * Copyright (c) 1995
- * Jordan Hubbard. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer,
- * verbatim and that no modifications are made prior to this
- * point in the file.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY JORDAN HUBBARD ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL JORDAN HUBBARD OR HIS PETS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, LIFE OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- */
-
-#include "sade.h"
-#include <ctype.h>
-#include <fcntl.h>
-#include <inttypes.h>
-#include <libdisk.h>
-#include <sys/stat.h>
-#include <sys/disklabel.h>
-
-#ifdef WITH_SLICES
-enum size_units_t { UNIT_BLOCKS, UNIT_KILO, UNIT_MEG, UNIT_GIG, UNIT_SIZE };
-
-#ifdef PC98
-#define SUBTYPE_FREEBSD 50324
-#define SUBTYPE_FAT 37218
-#else
-#define SUBTYPE_FREEBSD 165
-#define SUBTYPE_FAT 6
-#endif
-#define SUBTYPE_EFI 239
-
-#ifdef PC98
-#define OTHER_SLICE_VALUES \
- "Other popular values are 37218 for a\n" \
- "DOS FAT partition.\n\n"
-#else
-#define OTHER_SLICE_VALUES \
- "Other popular values are 6 for a\n" \
- "DOS FAT partition, 131 for a Linux ext2fs partition, or\n" \
- "130 for a Linux swap partition.\n\n"
-#endif
-#define NON_FREEBSD_NOTE \
- "Note: If you choose a non-FreeBSD partition type, it will not\n" \
- "be formatted or otherwise prepared, it will simply reserve space\n" \
- "for you to use another tool, such as DOS format, to later format\n" \
- "and actually use the partition."
-
-/* Where we start displaying chunk information on the screen */
-#define CHUNK_START_ROW 5
-
-/* Where we keep track of MBR chunks */
-#define CHUNK_INFO_ENTRIES 16
-static struct chunk *chunk_info[CHUNK_INFO_ENTRIES];
-static int current_chunk;
-
-static void diskPartitionNonInteractive(Device *dev);
-#if !defined(__ia64__)
-static u_char * bootalloc(char *name, size_t *size);
-#endif
-
-static void
-record_chunks(Disk *d)
-{
- struct chunk *c1 = NULL;
- int i = 0;
- daddr_t last_free = 0;
-
- if (!d->chunks)
- msgFatal("No chunk list found for %s!", d->name);
-
- for (c1 = d->chunks->part; c1; c1 = c1->next) {
- if (c1->type == unused && c1->size > last_free) {
- last_free = c1->size;
- current_chunk = i;
- }
- chunk_info[i++] = c1;
- }
- chunk_info[i] = NULL;
- if (current_chunk >= i)
- current_chunk = i - 1;
-}
-
-static daddr_t Total;
-
-static void
-check_geometry(Disk *d)
-{
- int sg;
-
-#ifdef PC98
- if (d->bios_cyl >= 65536 || d->bios_hd > 256 || d->bios_sect >= 256)
-#else
- if (d->bios_cyl > 65536 || d->bios_hd > 256 || d->bios_sect >= 64)
-#endif
- {
- dlg_clear();
- sg = msgYesNo("WARNING: It is safe to use a geometry of %lu/%lu/%lu for %s on\n"
- "computers with modern BIOS versions. If this disk is to be used\n"
- "on an old machine it is recommended that it does not have more\n"
- "than 65535 cylinders, more than 255 heads, or more than\n"
-#ifdef PC98
- "255"
-#else
- "63"
-#endif
- " sectors per track.\n"
- "\n"
- "Would you like to keep using the current geometry?\n",
- d->bios_cyl, d->bios_hd, d->bios_sect, d->name);
- if (sg == 1) {
- Sanitize_Bios_Geom(d);
- msgConfirm("A geometry of %lu/%lu/%lu was calculated for %s.\n"
- "\n"
- "If you are not sure about this, please consult the Hardware Guide\n"
- "in the Documentation submenu or use the (G)eometry command to\n"
- "change it. Remember: you need to enter whatever your BIOS thinks\n"
- "the geometry is! For IDE, it's what you were told in the BIOS\n"
- "setup. For SCSI, it's the translation mode your controller is\n"
- "using. Do NOT use a ``physical geometry''.\n",
- d->bios_cyl, d->bios_hd, d->bios_sect, d->name);
- }
- }
-}
-
-static void
-print_chunks(Disk *d, int u)
-{
- int row;
- int i;
- daddr_t sz;
- char *szstr;
-
- szstr = (u == UNIT_GIG ? "GB" : (u == UNIT_MEG ? "MB" :
- (u == UNIT_KILO ? "KB" : "ST")));
-
- Total = 0;
- for (i = 0; chunk_info[i]; i++)
- Total += chunk_info[i]->size;
- attrset(A_NORMAL);
- mvaddstr(0, 0, "Disk name:\t");
- clrtobot();
- attrset(A_REVERSE); addstr(d->name); attrset(A_NORMAL);
- attrset(A_REVERSE); mvaddstr(0, 55, "FDISK Partition Editor"); attrset(A_NORMAL);
- mvprintw(1, 0,
- "DISK Geometry:\t%lu cyls/%lu heads/%lu sectors = %jd sectors (%jdMB)",
- d->bios_cyl, d->bios_hd, d->bios_sect,
- (intmax_t)d->bios_cyl * d->bios_hd * d->bios_sect,
- (intmax_t)d->bios_cyl * d->bios_hd * d->bios_sect / (1024/512) / 1024);
- mvprintw(3, 0, "%6s %10s(%s) %10s %8s %6s %10s %8s %8s",
- "Offset", "Size", szstr, "End", "Name", "PType", "Desc",
- "Subtype", "Flags");
- for (i = 0, row = CHUNK_START_ROW; chunk_info[i]; i++, row++) {
- switch(u) {
- default: /* fall thru */
- case UNIT_BLOCKS:
- sz = chunk_info[i]->size;
- break;
- case UNIT_KILO:
- sz = chunk_info[i]->size / (1024/512);
- break;
- case UNIT_MEG:
- sz = chunk_info[i]->size / (1024/512) / 1024;
- break;
- case UNIT_GIG:
- sz = chunk_info[i]->size / (1024/512) / 1024 / 1024;
- break;
- }
- if (i == current_chunk)
- attrset(ATTR_SELECTED);
- mvprintw(row, 0, "%10jd %10jd %10jd %8s %6d %10s %8d\t%-6s",
- (intmax_t)chunk_info[i]->offset, (intmax_t)sz,
- (intmax_t)chunk_info[i]->end, chunk_info[i]->name,
- chunk_info[i]->type,
- slice_type_name(chunk_info[i]->type, chunk_info[i]->subtype),
- chunk_info[i]->subtype, ShowChunkFlags(chunk_info[i]));
- if (i == current_chunk)
- attrset(A_NORMAL);
- }
-}
-
-static void
-print_command_summary(void)
-{
- mvprintw(14, 0, "The following commands are supported (in upper or lower case):");
- mvprintw(16, 0, "A = Use Entire Disk G = set Drive Geometry C = Create Slice");
- mvprintw(17, 0, "D = Delete Slice Z = Toggle Size Units S = Set Bootable | = Expert m.");
- mvprintw(18, 0, "T = Change Type U = Undo All Changes W = Write Changes Q = Finish");
- mvprintw(21, 0, "Use F1 or ? to get more help, arrow keys to select.");
- move(0, 0);
-}
-
-#ifdef PC98
-static void
-getBootMgr(char *dname, u_char **bootipl, size_t *bootipl_size,
- u_char **bootmenu, size_t *bootmenu_size)
-{
- static u_char *boot0;
- static size_t boot0_size;
- static u_char *boot05;
- static size_t boot05_size;
-
- char str[80];
- char *cp;
- int i = 0;
-
- dlg_clr_result();
- cp = variable_get(VAR_BOOTMGR);
- if (!cp) {
- /* Figure out what kind of IPL the user wants */
- sprintf(str, "Install Boot Manager for drive %s?", dname);
- MenuIPLType.title = str;
- i = dmenuOpen(&MenuIPLType);
- } else {
- if (!strncmp(cp, "boot", 4))
- dlg_add_result(MenuIPLType.items[0].prompt);
- else
- dlg_add_result(MenuIPLType.items[1].prompt);
- }
- if (cp || i) {
- if (!strcmp(dialog_vars.input_result, MenuIPLType.items[0].prompt)) {
- if (!boot0) boot0 = bootalloc("boot0", &boot0_size);
- *bootipl = boot0;
- *bootipl_size = boot0_size;
- if (!boot05) boot05 = bootalloc("boot0.5", &boot05_size);
- *bootmenu = boot05;
- *bootmenu_size = boot05_size;
- return;
- }
- }
- *bootipl = NULL;
- *bootipl_size = 0;
- *bootmenu = NULL;
- *bootmenu_size = 0;
-}
-#else
-static void
-getBootMgr(char *dname, u_char **bootCode, size_t *bootCodeSize)
-{
-#if defined(__i386__) || defined(__amd64__) /* only meaningful on x86 */
- static u_char *mbr, *boot0;
- static size_t mbr_size, boot0_size;
- char str[80];
- char *cp;
- int i = 0;
-
- dlg_clr_result();
- cp = variable_get(VAR_BOOTMGR);
- if (!cp) {
- /* Figure out what kind of MBR the user wants */
- sprintf(str, "Install Boot Manager for drive %s?", dname);
- MenuMBRType.title = str;
- i = dmenuOpen(&MenuMBRType);
- }
- else {
- if (!strcmp(cp, "standard"))
- dlg_add_result(MenuMBRType.items[0].prompt);
- if (!strncmp(cp, "boot", 4))
- dlg_add_result(MenuMBRType.items[1].prompt);
- else
- dlg_add_result(MenuMBRType.items[2].prompt);
- }
- if (cp || i) {
- if (!strcmp(dialog_vars.input_result, MenuMBRType.items[0].prompt)) {
- if (!mbr) mbr = bootalloc("mbr", &mbr_size);
- *bootCode = mbr;
- *bootCodeSize = mbr_size;
- return;
- } else if (!strcmp(dialog_vars.input_result, MenuMBRType.items[1].prompt)) {
- if (!boot0) boot0 = bootalloc("boot0", &boot0_size);
- *bootCode = boot0;
- *bootCodeSize = boot0_size;
- return;
- }
- }
-#endif
- *bootCode = NULL;
- *bootCodeSize = 0;
-}
-#endif
-#endif /* WITH_SLICES */
-
-#ifdef WITH_SLICES
-void
-diskPartition(Device *dev)
-{
- char *cp, *p;
- int rv, key = 0;
- int i;
- Boolean chunking;
- char *msg = NULL;
-#ifdef PC98
- u_char *bootipl;
- size_t bootipl_size;
- u_char *bootmenu;
- size_t bootmenu_size;
-#else
- u_char *mbrContents;
- size_t mbrSize;
-#endif
- WINDOW *w = savescr();
- Disk *d = (Disk *)dev->private;
- int size_unit;
-
- size_unit = UNIT_BLOCKS;
- chunking = TRUE;
- keypad(stdscr, TRUE);
-
- /* Flush both the dialog and curses library views of the screen
- since we don't always know who called us */
- dlg_clear(), clear();
- current_chunk = 0;
-
- /* Set up the chunk array */
- record_chunks(d);
-
- /* Give the user a chance to sanitize the disk geometry, if necessary */
- check_geometry(d);
-
- while (chunking) {
- char *val, geometry[80];
-
- /* Now print our overall state */
- if (d)
- print_chunks(d, size_unit);
- print_command_summary();
- if (msg) {
- attrset(title_attr); mvprintw(23, 0, msg); attrset(A_NORMAL);
- beep();
- msg = NULL;
- }
- else {
- move(23, 0);
- clrtoeol();
- }
-
- /* Get command character */
- key = getch();
- switch (toupper(key)) {
- case '\014': /* ^L (redraw) */
- clear();
- msg = NULL;
- break;
-
- case '\020': /* ^P */
- case KEY_UP:
- case '-':
- if (current_chunk != 0)
- --current_chunk;
- break;
-
- case '\016': /* ^N */
- case KEY_DOWN:
- case '+':
- case '\r':
- case '\n':
- if (chunk_info[current_chunk + 1])
- ++current_chunk;
- break;
-
- case KEY_HOME:
- current_chunk = 0;
- break;
-
- case KEY_END:
- while (chunk_info[current_chunk + 1])
- ++current_chunk;
- break;
-
- case KEY_F(1):
- case '?':
- systemDisplayHelp("slice");
- clear();
- break;
-
- case 'A':
- case 'F': /* Undocumented magic Dangerously Dedicated mode */
-#if !defined(__i386__) && !defined(__amd64__)
- rv = 1;
-#else /* The rest is only relevant on x86 */
- cp = variable_get(VAR_DEDICATE_DISK);
- if (cp && !strcasecmp(cp, "always"))
- rv = 1;
- else if (toupper(key) == 'A')
- rv = 0;
- else {
- rv = msgYesNo("Do you want to do this with a true partition entry\n"
- "so as to remain cooperative with any future possible\n"
- "operating systems on the drive(s)?\n"
- "(See also the section about ``dangerously dedicated''\n"
- "disks in the FreeBSD FAQ.)");
- if (rv == -1)
- rv = 0;
- }
-#endif
- All_FreeBSD(d, rv);
- variable_set2(DISK_PARTITIONED, "yes", 0);
- record_chunks(d);
- clear();
- break;
-
- case 'C':
- if (chunk_info[current_chunk]->type != unused)
- msg = "Slice in use, delete it first or move to an unused one.";
- else {
- char *val, tmp[20], name[16], *cp;
- daddr_t size;
- int subtype;
- chunk_e partitiontype;
-#ifdef PC98
- snprintf(name, sizeof (name), "%s", "FreeBSD");
- val = msgGetInput(name,
- "Please specify the name for new FreeBSD slice.");
- if (val)
- strncpy(name, val, sizeof (name));
-#else
- name[0] = '\0';
-#endif
- snprintf(tmp, 20, "%jd", (intmax_t)chunk_info[current_chunk]->size);
- val = msgGetInput(tmp, "Please specify the size for new FreeBSD slice in blocks\n"
- "or append a trailing `M' for megabytes (e.g. 20M).");
- if (val && (size = strtoimax(val, &cp, 0)) > 0) {
- if (*cp && toupper(*cp) == 'M')
- size *= ONE_MEG;
- else if (*cp && toupper(*cp) == 'G')
- size *= ONE_GIG;
- sprintf(tmp, "%d", SUBTYPE_FREEBSD);
- val = msgGetInput(tmp, "Enter type of partition to create:\n\n"
- "Pressing Enter will choose the default, a native FreeBSD\n"
- "slice (type %u). "
- OTHER_SLICE_VALUES
- NON_FREEBSD_NOTE, SUBTYPE_FREEBSD);
- if (val && (subtype = strtol(val, NULL, 0)) > 0) {
- if (subtype == SUBTYPE_FREEBSD)
- partitiontype = freebsd;
- else if (subtype == SUBTYPE_FAT)
- partitiontype = fat;
- else if (subtype == SUBTYPE_EFI)
- partitiontype = efi;
- else
-#ifdef PC98
- partitiontype = pc98;
-#else
- partitiontype = mbr;
-#endif
- Create_Chunk(d, chunk_info[current_chunk]->offset, size, partitiontype, subtype,
- (chunk_info[current_chunk]->flags & CHUNK_ALIGN), name);
- variable_set2(DISK_PARTITIONED, "yes", 0);
- record_chunks(d);
- }
- }
- clear();
- }
- break;
-
- case KEY_DC:
- case 'D':
- if (chunk_info[current_chunk]->type == unused)
- msg = "Slice is already unused!";
- else {
- Delete_Chunk(d, chunk_info[current_chunk]);
- variable_set2(DISK_PARTITIONED, "yes", 0);
- record_chunks(d);
- }
- break;
-
- case 'T':
- if (chunk_info[current_chunk]->type == unused)
- msg = "Slice is currently unused (use create instead)";
- else {
- char *val, tmp[20];
- int subtype;
- chunk_e partitiontype;
-
- sprintf(tmp, "%d", chunk_info[current_chunk]->subtype);
- val = msgGetInput(tmp, "New partition type:\n\n"
- "Pressing Enter will use the current type. To choose a native\n"
- "FreeBSD slice enter %u. "
- OTHER_SLICE_VALUES
- NON_FREEBSD_NOTE, SUBTYPE_FREEBSD);
- if (val && (subtype = strtol(val, NULL, 0)) > 0) {
- if (subtype == SUBTYPE_FREEBSD)
- partitiontype = freebsd;
- else if (subtype == SUBTYPE_FAT)
- partitiontype = fat;
- else if (subtype == SUBTYPE_EFI)
- partitiontype = efi;
- else
-#ifdef PC98
- partitiontype = pc98;
-#else
- partitiontype = mbr;
-#endif
- chunk_info[current_chunk]->type = partitiontype;
- chunk_info[current_chunk]->subtype = subtype;
- }
- }
- break;
-
- case 'G':
- snprintf(geometry, 80, "%lu/%lu/%lu", d->bios_cyl, d->bios_hd, d->bios_sect);
- val = msgGetInput(geometry, "Please specify the new geometry in cyl/hd/sect format.\n"
- "Don't forget to use the two slash (/) separator characters!\n"
- "It's not possible to parse the field without them.");
- if (val) {
- long nc, nh, ns;
- nc = strtol(val, &val, 0);
- nh = strtol(val + 1, &val, 0);
- ns = strtol(val + 1, 0, 0);
- Set_Bios_Geom(d, nc, nh, ns);
- }
- clear();
- break;
-
- case 'S':
- /* Clear active states so we won't have two */
- for (i = 0; (chunk_info[i] != NULL) && (i < CHUNK_INFO_ENTRIES); i++)
- chunk_info[i]->flags &= !CHUNK_ACTIVE;
-
- /* Set Bootable */
- chunk_info[current_chunk]->flags |= CHUNK_ACTIVE;
- break;
-
- case 'U':
- if (!variable_cmp(DISK_LABELLED, "written")) {
- msgConfirm("You've already written this information out - you\n"
- "can't undo it.");
- }
- else if (!msgNoYes("Are you SURE you want to Undo everything?")) {
- char cp[BUFSIZ];
-
- sstrncpy(cp, d->name, sizeof cp);
- Free_Disk(dev->private);
- d = Open_Disk(cp);
- if (!d)
- msgConfirm("Can't reopen disk %s! Internal state is probably corrupted", cp);
- dev->private = d;
- variable_unset(DISK_PARTITIONED);
- variable_unset(DISK_LABELLED);
- if (d)
- record_chunks(d);
- }
- clear();
- break;
-
- case 'W':
- if (!msgNoYes("WARNING: You are about to modify an EXISTING installation.\n"
- "You should simply type Q when you are finished\n"
- "here and write to the disk from the label editor.\n\n"
- "Are you absolutely sure you want to continue?")) {
- variable_set2(DISK_PARTITIONED, "yes", 0);
-
-#ifdef PC98
- /*
- * Don't trash the IPL if the first (and therefore only) chunk
- * is marked for a truly dedicated disk (i.e., the disklabel
- * starts at sector 0), even in cases where the user has
- * requested a FreeBSD Boot Manager -- both would be fatal in
- * this case.
- */
- /*
- * Don't offer to update the IPL on this disk if the first
- * "real" chunk looks like a FreeBSD "all disk" partition,
- * or the disk is entirely FreeBSD.
- */
- if ((d->chunks->part->type != freebsd) ||
- (d->chunks->part->offset > 1))
- getBootMgr(d->name, &bootipl, &bootipl_size,
- &bootmenu, &bootmenu_size);
- else {
- bootipl = NULL;
- bootipl_size = 0;
- bootmenu = NULL;
- bootmenu_size = 0;
- }
- Set_Boot_Mgr(d, bootipl, bootipl_size, bootmenu, bootmenu_size);
-#else
- /*
- * Don't trash the MBR if the first (and therefore only) chunk
- * is marked for a truly dedicated disk (i.e., the disklabel
- * starts at sector 0), even in cases where the user has
- * requested booteasy or a "standard" MBR -- both would be
- * fatal in this case.
- */
- /*
- * Don't offer to update the MBR on this disk if the first
- * "real" chunk looks like a FreeBSD "all disk" partition,
- * or the disk is entirely FreeBSD.
- */
- if ((d->chunks->part->type != freebsd) ||
- (d->chunks->part->offset > 1))
- getBootMgr(d->name, &mbrContents, &mbrSize);
- else {
- mbrContents = NULL;
- mbrSize = 0;
- }
- Set_Boot_Mgr(d, mbrContents, mbrSize);
-#endif
-
- if (DITEM_STATUS(diskPartitionWrite(dev)) != DITEM_SUCCESS)
- msgConfirm("Disk partition write returned an error status!");
- else
- msgConfirm("Wrote FDISK partition information out successfully.");
- }
- clear();
- break;
-
- case '|':
- if (!msgNoYes("Are you SURE you want to go into Wizard mode?\n"
- "No seat belts whatsoever are provided!")) {
- clear();
- refresh();
- slice_wizard(d);
- variable_set2(DISK_PARTITIONED, "yes", 0);
- record_chunks(d);
- }
- else
- msg = "Wise choice!";
- clear();
- break;
-
- case '\033': /* ESC */
- case 'Q':
- chunking = FALSE;
-#ifdef PC98
- /*
- * Don't trash the IPL if the first (and therefore only) chunk
- * is marked for a truly dedicated disk (i.e., the disklabel
- * starts at sector 0), even in cases where the user has requested
- * a FreeBSD Boot Manager -- both would be fatal in this case.
- */
- /*
- * Don't offer to update the IPL on this disk if the first "real"
- * chunk looks like a FreeBSD "all disk" partition, or the disk is
- * entirely FreeBSD.
- */
- if ((d->chunks->part->type != freebsd) ||
- (d->chunks->part->offset > 1)) {
- if (variable_cmp(DISK_PARTITIONED, "written")) {
- getBootMgr(d->name, &bootipl, &bootipl_size,
- &bootmenu, &bootmenu_size);
- if (bootipl != NULL && bootmenu != NULL)
- Set_Boot_Mgr(d, bootipl, bootipl_size,
- bootmenu, bootmenu_size);
- }
- }
-#else
- /*
- * Don't trash the MBR if the first (and therefore only) chunk
- * is marked for a truly dedicated disk (i.e., the disklabel
- * starts at sector 0), even in cases where the user has requested
- * booteasy or a "standard" MBR -- both would be fatal in this case.
- */
- /*
- * Don't offer to update the MBR on this disk if the first "real"
- * chunk looks like a FreeBSD "all disk" partition, or the disk is
- * entirely FreeBSD.
- */
- if ((d->chunks->part->type != freebsd) ||
- (d->chunks->part->offset > 1)) {
- if (variable_cmp(DISK_PARTITIONED, "written")) {
- getBootMgr(d->name, &mbrContents, &mbrSize);
- if (mbrContents != NULL)
- Set_Boot_Mgr(d, mbrContents, mbrSize);
- }
- }
-#endif
- break;
-
- case 'Z':
- size_unit = (size_unit + 1) % UNIT_SIZE;
- break;
-
- default:
- beep();
- msg = "Type F1 or ? for help";
- break;
- }
- }
- p = CheckRules(d);
- if (p) {
- char buf[FILENAME_MAX];
- DIALOG_VARS save_vars;
-
- dlg_save_vars(&save_vars);
- dialog_vars.help_line = "Press F1 to read more about disk slices.";
- dialog_vars.help_file = systemHelpFile("partition", buf);
- if (!variable_get(VAR_NO_WARN))
- xdialog_msgbox("Disk slicing warning:", p, -1, -1, 1);
- free(p);
- dlg_restore_vars(&save_vars);
- }
- restorescr(w);
-}
-#endif /* WITH_SLICES */
-
-#if !defined(__ia64__)
-static u_char *
-bootalloc(char *name, size_t *size)
-{
- char buf[FILENAME_MAX];
- struct stat sb;
-
- snprintf(buf, sizeof buf, "/boot/%s", name);
- if (stat(buf, &sb) != -1) {
- int fd;
-
- fd = open(buf, O_RDONLY);
- if (fd != -1) {
- u_char *cp;
-
- cp = malloc(sb.st_size);
- if (read(fd, cp, sb.st_size) != sb.st_size) {
- free(cp);
- close(fd);
- msgDebug("bootalloc: couldn't read %ld bytes from %s\n", (long)sb.st_size, buf);
- return NULL;
- }
- close(fd);
- if (size != NULL)
- *size = sb.st_size;
- return cp;
- }
- msgDebug("bootalloc: couldn't open %s\n", buf);
- }
- else
- msgDebug("bootalloc: can't stat %s\n", buf);
- return NULL;
-}
-#endif /* !__ia64__ */
-
-#ifdef WITH_SLICES
-static int
-partitionHook(dialogMenuItem *selected)
-{
- Device **devs = NULL;
-
- devs = deviceFind(selected->prompt, DEVICE_TYPE_DISK);
- if (!devs) {
- msgConfirm("Unable to find disk %s!", selected->prompt);
- return DITEM_FAILURE;
- }
- diskPartition(devs[0]);
- return DITEM_SUCCESS;
-}
-
-int
-diskPartitionEditor(dialogMenuItem *self)
-{
- DMenu *menu;
- Device **devs;
-
- devs = deviceFind(variable_get(VAR_DISK), DEVICE_TYPE_DISK);
- if (devs == NULL) {
- msgConfirm("No disks found! Please verify that your disk controller is being\n"
- "properly probed at boot time. See the Hardware Guide on the\n"
- "Documentation menu for clues on diagnosing this type of problem.");
- return DITEM_FAILURE;
- }
- else {
- /* No disks are selected, fall-back case now */
- int cnt = deviceCount(devs);
-
- if (cnt == 1) {
- if (variable_get(VAR_NONINTERACTIVE) &&
- !variable_get(VAR_DISKINTERACTIVE))
- diskPartitionNonInteractive(devs[0]);
- else
- diskPartition(devs[0]);
- return DITEM_SUCCESS;
- }
- else {
- int result;
-
- menu = deviceCreateMenu(&MenuDiskDevices, DEVICE_TYPE_DISK, partitionHook);
- if (!menu) {
- msgConfirm("No devices suitable for installation found!\n\n"
- "Please verify that your disk controller (and attached drives)\n"
- "were detected properly. This can be done by pressing the\n"
- "[Scroll Lock] key and using the Arrow keys to move back to\n"
- "the boot messages. Press [Scroll Lock] again to return.");
- return DITEM_FAILURE;
- }
-
- result = dmenuOpen(menu) ? DITEM_SUCCESS : DITEM_FAILURE;
- free(menu);
- return result;
- }
- }
- return DITEM_SUCCESS;
-}
-#endif /* WITH_SLICES */
-
-int
-diskPartitionWrite(Device *dev)
-{
- Disk *d = (Disk *)dev->private;
-#if !defined(__ia64__)
- static u_char *boot1;
-#endif
-#if defined(__i386__) || defined(__amd64__)
- static u_char *boot2;
-#endif
-
- if (!variable_cmp(DISK_PARTITIONED, "written"))
- return DITEM_SUCCESS;
-
-#if defined(__i386__) || defined(__amd64__)
- if (!boot1) boot1 = bootalloc("boot1", NULL);
- if (!boot2) boot2 = bootalloc("boot2", NULL);
- Set_Boot_Blocks(d, boot1, boot2);
-#elif !defined(__ia64__)
- if (!boot1) boot1 = bootalloc("boot1", NULL);
- Set_Boot_Blocks(d, boot1, NULL);
-#endif
-
- msgNotify("Writing partition information to drive %s", d->name);
- if (!Fake && Write_Disk(d)) {
- msgConfirm("ERROR: Unable to write data to disk %s!", d->name);
- return DITEM_FAILURE;
- }
-
- /* Now it's not "yes", but "written" */
- variable_set2(DISK_PARTITIONED, "written", 0);
- return DITEM_SUCCESS | DITEM_RESTORE;
-}
-
-#ifdef WITH_SLICES
-/* Partition a disk based wholly on which variables are set */
-static void
-diskPartitionNonInteractive(Device *dev)
-{
- char *cp;
- int i, all_disk = 0;
- daddr_t sz;
-#ifdef PC98
- u_char *bootipl;
- size_t bootipl_size;
- u_char *bootmenu;
- size_t bootmenu_size;
-#else
- u_char *mbrContents;
- size_t mbrSize;
-#endif
- Disk *d = (Disk *)dev->private;
-
- record_chunks(d);
- cp = variable_get(VAR_GEOMETRY);
- if (cp) {
- if (!strcasecmp(cp, "sane")) {
-#ifdef PC98
- if (d->bios_cyl >= 65536 || d->bios_hd > 256 || d->bios_sect >= 256)
-#else
- if (d->bios_cyl > 65536 || d->bios_hd > 256 || d->bios_sect >= 64)
-#endif
- {
- msgDebug("Warning: A geometry of %lu/%lu/%lu for %s is incorrect.\n",
- d->bios_cyl, d->bios_hd, d->bios_sect, d->name);
- Sanitize_Bios_Geom(d);
- msgDebug("Sanitized geometry for %s is %lu/%lu/%lu.\n",
- d->name, d->bios_cyl, d->bios_hd, d->bios_sect);
- }
- } else {
- msgDebug("Setting geometry from script to: %s\n", cp);
- d->bios_cyl = strtol(cp, &cp, 0);
- d->bios_hd = strtol(cp + 1, &cp, 0);
- d->bios_sect = strtol(cp + 1, 0, 0);
- }
- }
-
- cp = variable_get(VAR_PARTITION);
- if (cp) {
- if (!strcmp(cp, "free")) {
- /* Do free disk space case */
- for (i = 0; chunk_info[i]; i++) {
- /* If a chunk is at least 10MB in size, use it. */
- if (chunk_info[i]->type == unused && chunk_info[i]->size > (10 * ONE_MEG)) {
- Create_Chunk(d, chunk_info[i]->offset, chunk_info[i]->size,
- freebsd, 3,
- (chunk_info[i]->flags & CHUNK_ALIGN),
- "FreeBSD");
- variable_set2(DISK_PARTITIONED, "yes", 0);
- break;
- }
- }
- if (!chunk_info[i]) {
- msgConfirm("Unable to find any free space on this disk!");
- return;
- }
- }
- else if (!strcmp(cp, "all")) {
- /* Do all disk space case */
- msgDebug("Warning: Devoting all of disk %s to FreeBSD.\n", d->name);
-
- All_FreeBSD(d, FALSE);
- }
- else if (!strcmp(cp, "exclusive")) {
- /* Do really-all-the-disk-space case */
- msgDebug("Warning: Devoting all of disk %s to FreeBSD.\n", d->name);
-
- All_FreeBSD(d, all_disk = TRUE);
- }
- else if ((sz = strtoimax(cp, &cp, 0))) {
- /* Look for sz bytes free */
- if (*cp && toupper(*cp) == 'M')
- sz *= ONE_MEG;
- else if (*cp && toupper(*cp) == 'G')
- sz *= ONE_GIG;
- for (i = 0; chunk_info[i]; i++) {
- /* If a chunk is at least sz MB, use it. */
- if (chunk_info[i]->type == unused && chunk_info[i]->size >= sz) {
- Create_Chunk(d, chunk_info[i]->offset, sz, freebsd, 3,
- (chunk_info[i]->flags & CHUNK_ALIGN),
- "FreeBSD");
- variable_set2(DISK_PARTITIONED, "yes", 0);
- break;
- }
- }
- if (!chunk_info[i]) {
- msgConfirm("Unable to find %jd free blocks on this disk!",
- (intmax_t)sz);
- return;
- }
- }
- else if (!strcmp(cp, "existing")) {
- /* Do existing FreeBSD case */
- for (i = 0; chunk_info[i]; i++) {
- if (chunk_info[i]->type == freebsd)
- break;
- }
- if (!chunk_info[i]) {
- msgConfirm("Unable to find any existing FreeBSD partitions on this disk!");
- return;
- }
- }
- else {
- msgConfirm("`%s' is an invalid value for %s - is config file valid?", cp, VAR_PARTITION);
- return;
- }
- if (!all_disk) {
-#ifdef PC98
- getBootMgr(d->name, &bootipl, &bootipl_size,
- &bootmenu, &bootmenu_size);
- Set_Boot_Mgr(d, bootipl, bootipl_size, bootmenu, bootmenu_size);
-#else
- getBootMgr(d->name, &mbrContents, &mbrSize);
- Set_Boot_Mgr(d, mbrContents, mbrSize);
-#endif
- }
- variable_set2(DISK_PARTITIONED, "yes", 0);
- }
-}
-#endif /* WITH_SLICES */
diff --git a/usr.sbin/sade/dmenu.c b/usr.sbin/sade/dmenu.c
deleted file mode 100644
index 186c1e9..0000000
--- a/usr.sbin/sade/dmenu.c
+++ /dev/null
@@ -1,93 +0,0 @@
-/*
- * $FreeBSD$
- *
- * Copyright (c) 1995
- * Jordan Hubbard. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer,
- * verbatim and that no modifications are made prior to this
- * point in the file.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY JORDAN HUBBARD ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL JORDAN HUBBARD OR HIS PETS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, LIFE OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- */
-
-#include "sade.h"
-#include <errno.h>
-
-#define MAX_MENU 15
-
-static int
-menu_height(DMenu *menu, int n)
-{
- int max;
- char *t;
-
- max = MAX_MENU;
- if (StatusLine > 24)
- max += StatusLine - 24;
- for (t = menu->prompt; *t; t++) {
- if (*t == '\n')
- --max;
- }
- return n > max ? max : n;
-}
-
-/* Traverse over an internal menu */
-Boolean
-dmenuOpen(DMenu *menu)
-{
- int n, rval = 0;
-
- /* Count up all the items */
- for (n = 0; menu->items[n].title; n++)
- ;
-
- while (1) {
- char buf[FILENAME_MAX];
- DIALOG_VARS save_vars;
- WINDOW *w = savescr();
-
- /* Any helpful hints, put 'em up! */
- dlg_save_vars(&save_vars);
- dialog_vars.help_line = menu->helpline;
- dialog_vars.help_file = systemHelpFile(menu->helpfile, buf);
- dlg_clear();
- /* Pop up that dialog! */
- if (menu->type & DMENU_NORMAL_TYPE) {
- rval = xdialog_menu(menu->title, menu->prompt,
- -1, -1, menu_height(menu, n), n, menu->items);
- } else if (menu->type & DMENU_RADIO_TYPE) {
- rval = xdialog_radiolist(menu->title, menu->prompt,
- -1, -1, menu_height(menu, n), n, menu->items);
- } else {
- msgFatal("Menu: `%s' is of an unknown type\n", menu->title);
- }
- dlg_restore_vars(&save_vars);
- if (rval) {
- restorescr(w);
- return FALSE;
- } else if (menu->type & DMENU_SELECTION_RETURNS) {
- restorescr(w);
- return TRUE;
- } else
- delwin(w);
- }
-}
diff --git a/usr.sbin/sade/globals.c b/usr.sbin/sade/globals.c
deleted file mode 100644
index 0b08da3..0000000
--- a/usr.sbin/sade/globals.c
+++ /dev/null
@@ -1,84 +0,0 @@
-/*
- * $FreeBSD$
- *
- * Copyright (c) 1995
- * Jordan Hubbard. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer,
- * verbatim and that no modifications are made prior to this
- * point in the file.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY JORDAN HUBBARD ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL JORDAN HUBBARD OR HIS PETS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, LIFE OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- */
-
-#include "sade.h"
-
-/*
- * Various global variables and an initialization hook to set them to
- * whatever values we feel are appropriate.
- */
-
-int DebugFD; /* Where diagnostic output goes */
-Boolean Fake; /* Only pretend to be useful */
-Boolean DialogActive; /* Is libdialog initialized? */
-Boolean ColorDisplay; /* Are we on a color display? */
-Boolean OnVTY; /* Are we on a VTY? */
-Boolean Restarting; /* Are we restarting sysinstall? */
-Variable *VarHead; /* The head of the variable chain */
-int BootMgr; /* Which boot manager we're using */
-int StatusLine; /* Where to stick our status messages */
-jmp_buf BailOut; /* Beam me up, scotty! The natives are pissed! */
-
-Chunk *HomeChunk;
-Chunk *RootChunk;
-Chunk *SwapChunk;
-Chunk *TmpChunk;
-Chunk *UsrChunk;
-Chunk *VarChunk;
-#ifdef __ia64__
-Chunk *EfiChunk;
-#endif
-
-/*
- * Yes, I know some of these are already automatically initialized as
- * globals. I simply find it clearer to set everything explicitly.
- */
-void
-globalsInit(void)
-{
- DebugFD = -1;
- ColorDisplay = FALSE;
- Fake = FALSE;
- Restarting = FALSE;
- OnVTY = FALSE;
- DialogActive = FALSE;
- VarHead = NULL;
-
- HomeChunk = NULL;
- RootChunk = NULL;
- SwapChunk = NULL;
- TmpChunk = NULL;
- UsrChunk = NULL;
- VarChunk = NULL;
-#ifdef __ia64__
- EfiChunk = NULL;
-#endif
-}
diff --git a/usr.sbin/sade/help/partition.hlp b/usr.sbin/sade/help/partition.hlp
deleted file mode 100644
index 3d13b34..0000000
--- a/usr.sbin/sade/help/partition.hlp
+++ /dev/null
@@ -1,169 +0,0 @@
-This is the FreeBSD DiskLabel Editor.
-
-NOTE: If you're entering this editor from the update procedure then
-you probably shouldn't (C)reate anything at all but rather use only
-the (M)ount command to check and mount existing partitions for
-upgrading.
-
-If you would like the label editor to do most of the following for
-you, simply type `A' for automatic partitioning of the disk.
-
-If you wish to create partitions manually you may do so by moving the
-highlighted selection bar with the arrow keys over the FreeBSD
-partition(s) displayed at the top of the screen. Typing (C)reate
-while a partition with available free space is selected will allow you
-to create a BSD partition inside of it using some or all of its
-available space.
-
-Typing (M)ount over an existing partition entry (displayed in the
-middle of the screen) will allow you to set a mount point for it
-without initializing it. If you want it initialized, use the (T)oggle
-command to flip the Newfs flag. When Newfs is set to "Y", the
-filesystem in question will be ERASED and rebuilt from scratch!
-
-
-You should use this editor to create at least the following
-filesystems:
-
- Name Purpose Min Size? Optional?
- ---- ------- --------- ---------
- / Root filesystem 118MB No
- swap Swap space 2 * MEM No
- /usr System & user files 128MB or more Yes
-
-Note: If you do not create a /usr filesystem then your / filesystem
-will need to be bigger - at least 240MB. This is not recommended as
-any media errors that may occur during disk I/O to user files will
-corrupt the filesystem containing vital system files as well. It is
-for this reason that / is generally kept on its own filesystem, where
-it should be considered essentially "read only" in your administration
-of it.
-
-Swap space is a little tricker, and the rule of "2 * MEM" is simply a
-best-guess approximation and not necessarily accurate for your
-intended usage of the system. If you intend to use the system heavily
-in a server or multi-user application, you may be well advised to
-increase this size. You may also create swap space on multiple drives
-for a larger "total" swap and this is, in fact, recommended if you
-have multiple, fast drives for which such load-balancing can only help
-overall I/O performance.
-
-The /usr filesystem should be sized according to what kind of
-distributions you're trying to load and how many packages you intend
-to install in locations like /usr/local. You can also make /usr/local
-a separate filesystem if you don't want to risk filling up your /usr
-by mistake.
-
-Another useful filesystem to create is /var, which contains mail, news
-printer spool files and other temporary items. It is a popular
-candidate for a separate partition and should be sized according to
-your estimates of the amount of mail, news or spooled print jobs that
-may be stored there.
-
-WARNING: If you do not create a separate filesystem for /var, space
-for such files will be allocated out of the root (/) filesystem
-instead. You may therefore wish to make the / partition bigger if you
-expect a lot of mail or news and do not want to make /var its own
-partition.
-
-If you're new to this installation, you might also want to read the
-following explanation of how FreeBSD's new "slice" paradigm for
-looking at disk storage works:
-
-
-In FreeBSD's new system, a device name can be broken up into up to 3
-parts. Take a typical name like ``/dev/da0s1a'':
-
- The first three characters represent the drive name. If we had
- a system with two SCSI drives on it then we'd see /dev/da0 and
- /dev/da1 as the device entries representing the entire drives.
-
- Next you have the "slice" (or "FDISK Partition") number,
- as seen in the Partition Editor. Assuming that our da0
- contained two slices, a FreeBSD slice and a DOS slice, that
- would give us /dev/da0s1 and /dev/da0s2 as device entries pointing
- to the entire slices.
-
- Next, if a slice is a FreeBSD slice, you can have a number of
- (confusingly named) "partitions" inside of it.
-
- These partitions are where various filesystems or swap areas live,
- and using our hypothetical two-SCSI-disk machine again, we might
- have something like the following layout on da0:
-
- Name Mountpoint
- ---- ----------
- da0s1a /
- da0s1b <swap space>
- da0s1e /usr
-
-Once you understand all this, then the purpose of the label editor
-becomes fairly clear: You're carving up the FreeBSD slices displayed
-at the top of the screen into smaller pieces, which are displayed in
-the middle of the screen, and then assigning FreeBSD file system names
-(mount points) to them.
-
-You can also use the label editor to mount existing partitions/slices
-into your filesystem hierarchy, as is frequently done for DOS FAT
-slices. For FreeBSD partitions, you can also toggle the "newfs" state
-so that the partitions are either (re)created from scratch or simply
-checked and mounted (the contents are preserved).
-
-If you set (S)oftUpdates on a filesystem, it will cause the
-"Soft Updates" policy to be in effect for it. This basically causes
-both metadata and data blocks to be written asynchronously to disk,
-but with extra state information which causes the metadata and any
-related data blocks to be committed in a single transaction. This
-results in async metadata update speeds (which are considerably
-faster than the default sync) without the potential for data loss
-which could occur if you simply mounted the filesystem with purely
-"async" update policy and then had a power failure. If you wish
-to later turn the softupdates policy back off, use the command
-"tunefs -n disable devicename". NOTE: It is probably not wise
-to use this on your root filesystem unless you have a large
-(e.g. non-standard size) root. The reason is that smaller filesystems
-with significant activity can temporarily overflow if the soft updates
-policy results in free'd blocks not being "garbage collected" as fast
-as they're being requested.
-
-The UNIX File System (UFS) on FreeBSD supports two different on-disk
-layouts: UFS1 and UFS2. UFS1 was the default file system in use
-through FreeBSD 5.0-RELEASE; as of FreeBSD 5.1-RELEASE, the default
-is now UFS2, with the exception of the PC98 platform. UFS2 provides
-sparse inode allocation (faster fsck), 64-bit storage pointers (larger
-maximum size), and native extended attributes (required for ACLs, MAC,
-and other advanced security and file system services). The selection
-of UFS1 or UFS2 must be made when the file system is created--later
-conversion is not currently possible. UFS2 is the recommended file
-system, but if disks are to be used on older FreeBSD systems, UFS1
-improves portability. When dual-booting between FreeBSD 4.x or
-earlier and FreeBSD 5.x, UFS1 file systems will be accessible from
-both. To toggle a file system to UFS1, press '1'. To restore it to
-UFS2, press '2'.
-
-WARNING: FreeBSD on i386 is currently unable to boot from root file
-systems larger than 1.5TB.
-
-To add additional flags to the newfs command line for UFS file
-systems, press 'N'. These options will be specified before the
-device argument of the command line, but after any other options
-placed there by sysinstall, such as the UFS version and soft
-updates flag; as such, arguments provided may override existing
-settings. To completely replace the newfs command used by
-sysinstall, press 'Z' to convert a partition to a Custom
-partition type. Sysinstall will prompt you with the newfs
-command line that it would have used based on existing settings
-prior to the change, but allow you to modify any aspect of the
-command line. Once a partition has been converted to a custom
-partition in the label editor, you will need to restart the
-labeling process or delete and recreate the partition to restore
-it to a non-custom state. Custom partitions are represented by
-the letters "CST" instead of "UFS" or "FAT.
-
-When you're done, type `Q' to exit.
-
-No actual changes will be made to the disk until you (C)ommit from the
-Install menu or (W)rite directly from this one. You're working with
-what is essentially a copy of the disk label(s), both here and in the
-FDISK Partition Editor, and the actual on-disk labels won't be
-affected by any changes you make until you explicitly say so.
diff --git a/usr.sbin/sade/help/slice.hlp b/usr.sbin/sade/help/slice.hlp
deleted file mode 100644
index e9f3abb..0000000
--- a/usr.sbin/sade/help/slice.hlp
+++ /dev/null
@@ -1,57 +0,0 @@
-This is the Main Slice (``FDISK'' or PC-style Partition) Editor.
-
-Possible commands are printed at the bottom and the Master Boot Record
-contents are shown at the top. You can move up and down with the
-arrow keys and (C)reate a new slice whenever the highlighted
-selection bar is over a slice whose type is marked as "unused."
-
-You are expected to leave this screen with at least one slice
-marked "FreeBSD." Note that unlike Linux, you don't need to create
-multiple FreeBSD FDISK partition entries for different things like
-swap, file systems, etc. The usual convention is to create ONE
-FreeBSD slice (FDISK partition) per drive and then subsection this slice
-into swap and file systems with the Label editor.
-
-No actual changes will be made to the disk until you (C)ommit from the
-Install menu or use the (W)rite option here! You're working with what
-is essentially a copy of the disk label(s), both here and in the Label
-Editor.
-
-If you want to use the entire disk for FreeBSD, type `A'. Slices will
-be aligned to fictitious cylinder boundaries and space will be reserved
-in front of the FreeBSD slice for a [future] possible boot manager.
-
-For the truly dedicated disk case, type `F'. You'll be asked whether or
-not you wish to keep the disk (potentially) compatible with other
-operating systems, i.e. the information in the FDISK table should be
-kept valid. A truly dedicated disk can be achieved by selecting `No'.
-In that case, all BIOS geometry considerations will no longer be in
-effect and you can safely ignore any ``The detected geometry is
-invalid'' warning messages you may later see. It is also not necessary
-in this case to set a slice bootable or install an MBR boot manager as
-both things are then irrelevant. The FreeBSD slice will start at
-absolute sector 0 of the disk (so that FreeBSD's disk label is identical
-to the Master Boot Record) and extend to the very last sector of the
-disk medium. Needless to say, such a disk cannot have any sort of a
-boot manager, `disk manager', or anything else that has to interact with
-the BIOS. This option is therefore only considered safe for SCSI disks
-and most IDE disks and is primarily intended for people who are going to
-set up a dedicated FreeBSD server or workstation, not a typical `home PC'.
-
-If you select the default of `Yes' at the compatibility, slices will be
-aligned to fictitious cylinder boundaries and space will be reserved
-in front of the FreeBSD slice for a [future] possible boot manager.
-This is pretty much equivalent to having chosen `A' originally.
-
-The flags field has the following legend:
-
- '=' -- This slice is properly aligned.
- 'A' -- This slice is marked active.
- 'R' -- This slice contains the root (/) filesystem
-
-If no slice is marked Active, you will need to either install
-a Boot Manager (the option for which will be presented later in the
-installation) or set one Active before leaving this screen.
-
-To leave the slice editor, type `Q'.
-
diff --git a/usr.sbin/sade/install.c b/usr.sbin/sade/install.c
deleted file mode 100644
index e3364fe..0000000
--- a/usr.sbin/sade/install.c
+++ /dev/null
@@ -1,249 +0,0 @@
-/*
- * $FreeBSD$
- *
- * Copyright (c) 1995
- * Jordan Hubbard. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer,
- * verbatim and that no modifications are made prior to this
- * point in the file.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY JORDAN HUBBARD ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL JORDAN HUBBARD OR HIS PETS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, LIFE OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- */
-
-#include <ctype.h>
-#include <sys/consio.h>
-#include <sys/disklabel.h>
-#include <sys/errno.h>
-#include <sys/ioctl.h>
-#include <sys/fcntl.h>
-#include <sys/wait.h>
-#include <sys/uio.h>
-#include <sys/param.h>
-#define MSDOSFS
-#include <sys/mount.h>
-#include <ufs/ufs/ufsmount.h>
-#include <fs/msdosfs/msdosfsmount.h>
-#undef MSDOSFS
-#include <sys/stat.h>
-#include <sys/sysctl.h>
-#include <libdisk.h>
-#include <limits.h>
-#include <unistd.h>
-#include <termios.h>
-
-#include "sade.h"
-
-#define TERMCAP_FILE "/usr/share/misc/termcap"
-
-Boolean
-checkLabels(Boolean whinge)
-{
- Boolean status;
-
- /* Don't allow whinging if noWarn is set */
- if (variable_get(VAR_NO_WARN))
- whinge = FALSE;
-
- status = TRUE;
- HomeChunk = RootChunk = SwapChunk = NULL;
- TmpChunk = UsrChunk = VarChunk = NULL;
-#ifdef __ia64__
- EfiChunk = NULL;
-#endif
-
- /* We don't need to worry about root/usr/swap if we're already multiuser */
- return status;
-}
-
-#define QUEUE_YES 1
-#define QUEUE_NO 0
-static int
-performNewfs(PartInfo *pi, char *dname, int queue)
-{
- char buffer[LINE_MAX];
-
- if (pi->do_newfs) {
- switch(pi->newfs_type) {
- case NEWFS_UFS:
- snprintf(buffer, LINE_MAX, "%s %s %s %s %s",
- NEWFS_UFS_CMD,
- pi->newfs_data.newfs_ufs.softupdates ? "-U" : "",
- pi->newfs_data.newfs_ufs.ufs1 ? "-O1" : "-O2",
- pi->newfs_data.newfs_ufs.user_options,
- dname);
- break;
-
- case NEWFS_MSDOS:
- snprintf(buffer, LINE_MAX, "%s %s", NEWFS_MSDOS_CMD,
- dname);
- break;
-
- case NEWFS_CUSTOM:
- snprintf(buffer, LINE_MAX, "%s %s",
- pi->newfs_data.newfs_custom.command, dname);
- break;
- }
-
- if (queue == QUEUE_YES) {
- command_shell_add(pi->mountpoint, "%s", buffer);
- return (0);
- } else
- return (vsystem("%s", buffer));
- }
- return (0);
-}
-
-/* Go newfs and/or mount all the filesystems we've been asked to */
-int
-installFilesystems(Device *dev)
-{
- Disk *disk = (Disk *)dev->private;
- Chunk *c1, *c2;
- PartInfo *root;
- char dname[80];
- Boolean upgrade = FALSE;
-
- /* If we've already done this, bail out */
- if (!variable_cmp(DISK_LABELLED, "written"))
- return DITEM_SUCCESS;
-
- upgrade = !variable_cmp(SYSTEM_STATE, "upgrade");
- if (!checkLabels(TRUE))
- return DITEM_FAILURE;
-
- root = (RootChunk != NULL) ? (PartInfo *)RootChunk->private_data : NULL;
-
- command_clear();
-
- /* Now buzz through the rest of the partitions and mount them too */
- if (!disk->chunks) {
- msgConfirm("No chunk list found for %s!", disk->name);
- return DITEM_FAILURE | DITEM_RESTORE;
- }
- for (c1 = disk->chunks->part; c1; c1 = c1->next) {
-#ifdef __ia64__
- if (c1->type == part) {
- c2 = c1;
- {
-#elif defined(__powerpc__)
- if (c1->type == apple) {
- for (c2 = c1->part; c2; c2 = c2->next) {
-#else
- if (c1->type == freebsd) {
- for (c2 = c1->part; c2; c2 = c2->next) {
-#endif
- if (c2->type == part && c2->subtype != FS_SWAP && c2->private_data) {
- PartInfo *tmp = (PartInfo *)c2->private_data;
-
- /* Already did root */
- if (c2 == RootChunk)
- continue;
-
- sprintf(dname, "/dev/%s", c2->name);
-
- if (tmp->do_newfs && (!upgrade ||
- !msgNoYes("You are upgrading - are you SURE you"
- " want to newfs /dev/%s?", c2->name)))
- performNewfs(tmp, dname, QUEUE_YES);
- else
- command_shell_add(tmp->mountpoint,
- "fsck_ffs -y /dev/%s", c2->name);
- command_func_add(tmp->mountpoint, Mount, c2->name);
- }
- else if (c2->type == part && c2->subtype == FS_SWAP) {
- char fname[80];
- int i;
-
- if (c2 == SwapChunk)
- continue;
- sprintf(fname, "/dev/%s", c2->name);
- i = (Fake || swapon(fname));
- if (!i) {
- dlg_clear();
- msgNotify("Added %s as an additional swap device", fname);
- }
- else {
- msgConfirm("Unable to add %s as a swap device: %s", fname, strerror(errno));
- }
- }
- }
- }
- else if (c1->type == fat && c1->private_data &&
- (root->do_newfs || upgrade)) {
- char name[FILENAME_MAX];
-
- sprintf(name, "/%s", ((PartInfo *)c1->private_data)->mountpoint);
- Mkdir(name);
- }
-#if defined(__ia64__)
- else if (c1->type == efi && c1->private_data) {
- PartInfo *pi = (PartInfo *)c1->private_data;
-
- sprintf(dname, "/dev/%s", c1->name);
-
- if (pi->do_newfs && (!upgrade ||
- !msgNoYes("You are upgrading - are you SURE you want to "
- "newfs /dev/%s?", c1->name)))
- performNewfs(pi, dname, QUEUE_YES);
- }
-#endif
- }
-
- command_sort();
- command_execute();
- dlg_clear();
- return DITEM_SUCCESS | DITEM_RESTORE;
-}
-
-static char *
-getRelname(void)
-{
- static char buf[64];
- size_t sz = (sizeof buf) - 1;
-
- if (sysctlbyname("kern.osrelease", buf, &sz, NULL, 0) != -1) {
- buf[sz] = '\0';
- return buf;
- }
- else
- return "<unknown>";
-}
-
-/* Initialize various user-settable values to their defaults */
-int
-installVarDefaults(dialogMenuItem *self)
-{
-
- /* Set default startup options */
- variable_set2(VAR_RELNAME, getRelname(), 0);
- variable_set2(SYSTEM_STATE, "update", 0);
- variable_set2(VAR_NEWFS_ARGS, "-b 16384 -f 2048", 0);
- variable_set2(VAR_CONSTERM, "NO", 0);
- return DITEM_SUCCESS;
-}
-
-/* Load the environment up from various system configuration files */
-void
-installEnvironment(void)
-{
-}
-
diff --git a/usr.sbin/sade/label.c b/usr.sbin/sade/label.c
deleted file mode 100644
index d6b03b5..0000000
--- a/usr.sbin/sade/label.c
+++ /dev/null
@@ -1,1646 +0,0 @@
-/*
- * $FreeBSD$
- *
- * Copyright (c) 1995
- * Jordan Hubbard. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer,
- * verbatim and that no modifications are made prior to this
- * point in the file.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY JORDAN HUBBARD ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL JORDAN HUBBARD OR HIS PETS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, LIFE OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- */
-
-#include <sys/types.h>
-#include <ctype.h>
-#include <inttypes.h>
-#include <libdisk.h>
-#include <sys/disklabel.h>
-#include <sys/param.h>
-#include <sys/sysctl.h>
-
-#include "sade.h"
-
-#define AUTO_HOME 0 /* do not create /home automatically */
-
-/*
- * Everything to do with editing the contents of disk labels.
- */
-
-/* A nice message we use a lot in the disklabel editor */
-#define MSG_NOT_APPLICABLE "That option is not applicable here"
-
-/* Where to start printing the freebsd slices */
-#define CHUNK_SLICE_START_ROW 2
-#define CHUNK_PART_START_ROW 11
-
-/* The smallest filesystem we're willing to create */
-#define FS_MIN_SIZE ONE_MEG
-
-/*
- * Minimum partition sizes
- */
-#if defined(__alpha__) || defined(__ia64__) || defined(__sparc64__) || defined(__amd64__)
-#define ROOT_MIN_SIZE 128
-#else
-#define ROOT_MIN_SIZE 118
-#endif
-#define SWAP_MIN_SIZE 32
-#define USR_MIN_SIZE 128
-#define VAR_MIN_SIZE 20
-#define TMP_MIN_SIZE 20
-#define HOME_MIN_SIZE 20
-
-/*
- * Swap size limit for auto-partitioning (4G).
- */
-#define SWAP_AUTO_LIMIT_SIZE 4096
-
-/*
- * Default partition sizes. If we do not have sufficient disk space
- * for this configuration we scale things relative to the NOM vs DEFAULT
- * sizes. If the disk is larger then /home will get any remaining space.
- */
-#define ROOT_DEFAULT_SIZE 512
-#define USR_DEFAULT_SIZE 8192
-#define VAR_DEFAULT_SIZE 1024
-#define TMP_DEFAULT_SIZE 512
-#define HOME_DEFAULT_SIZE USR_DEFAULT_SIZE
-
-/*
- * Nominal partition sizes. These are used to scale the default sizes down
- * when we have insufficient disk space. If this isn't sufficient we scale
- * down using the MIN sizes instead.
- */
-#define ROOT_NOMINAL_SIZE 256
-#define USR_NOMINAL_SIZE 1536
-#define VAR_NOMINAL_SIZE 128
-#define TMP_NOMINAL_SIZE 128
-#define HOME_NOMINAL_SIZE USR_NOMINAL_SIZE
-
-/* The bottom-most row we're allowed to scribble on */
-#define CHUNK_ROW_MAX 16
-
-
-/* All the chunks currently displayed on the screen */
-static struct {
- struct chunk *c;
- PartType type;
-} label_chunk_info[MAX_CHUNKS + 1];
-static int here;
-
-/*** with this value we try to track the most recently added label ***/
-static int label_focus = 0, pslice_focus = 0;
-
-static int diskLabel(Device *dev);
-static int diskLabelNonInteractive(Device *dev);
-static char *try_auto_label(Device *dev, int perc, int *req);
-
-static int
-labelHook(dialogMenuItem *selected)
-{
- Device **devs = NULL;
-
- devs = deviceFind(selected->prompt, DEVICE_TYPE_DISK);
- if (!devs) {
- msgConfirm("Unable to find disk %s!", selected->prompt);
- return DITEM_FAILURE;
- }
- diskLabel(devs[0]);
- return DITEM_SUCCESS;
-}
-
-int
-diskLabelEditor(dialogMenuItem *self)
-{
- DMenu *menu;
- Device **devs;
- int result;
-
- devs = deviceFind(variable_get(VAR_DISK), DEVICE_TYPE_DISK);
- if (devs == NULL) {
- msgConfirm("No disks found! Please verify that your disk controller is being\n"
- "properly probed at boot time. See the Hardware Guide on the\n"
- "Documentation menu for clues on diagnosing this type of problem.");
- return DITEM_FAILURE;
- }
- else {
- /* No disks are selected, fall-back case now */
- int cnt = deviceCount(devs);
- if (cnt == 1) {
- if (variable_get(VAR_NONINTERACTIVE) &&
- !variable_get(VAR_DISKINTERACTIVE))
- result = diskLabelNonInteractive(devs[0]);
- else
- result = diskLabel(devs[0]);
- }
- else {
- menu = deviceCreateMenu(&MenuDiskDevices, DEVICE_TYPE_DISK, labelHook);
- if (!menu) {
- msgConfirm("No devices suitable for installation found!\n\n"
- "Please verify that your disk controller (and attached drives)\n"
- "were detected properly. This can be done by pressing the\n"
- "[Scroll Lock] key and using the Arrow keys to move back to\n"
- "the boot messages. Press [Scroll Lock] again to return.");
- result = DITEM_FAILURE;
- }
- else {
- result = dmenuOpen(menu) ? DITEM_SUCCESS : DITEM_FAILURE;
- free(menu);
- }
- }
- }
- if (DITEM_STATUS(result) != DITEM_FAILURE) {
- if (variable_cmp(DISK_LABELLED, "written"))
- variable_set2(DISK_LABELLED, "yes", 0);
- }
- return result;
-}
-
-int
-diskLabelCommit(Device *dev)
-{
- char *cp;
- int i;
-
- /* Already done? */
- if ((cp = variable_get(DISK_LABELLED)) && strcmp(cp, "yes"))
- i = DITEM_SUCCESS;
- else if (!cp) {
- msgConfirm("You must assign disk labels before this option can be used.");
- i = DITEM_FAILURE;
- }
- /* The routine will guard against redundant writes, just as this one does */
- else if (DITEM_STATUS(diskPartitionWrite(dev)) != DITEM_SUCCESS)
- i = DITEM_FAILURE;
- else if (DITEM_STATUS(installFilesystems(dev)) != DITEM_SUCCESS)
- i = DITEM_FAILURE;
- else {
- msgInfo("All filesystem information written successfully.");
- variable_set2(DISK_LABELLED, "written", 0);
- i = DITEM_SUCCESS;
- }
- return i;
-}
-
-/* See if we're already using a desired partition name */
-static Boolean
-check_conflict(char *name)
-{
- int i;
-
- for (i = 0; label_chunk_info[i].c; i++)
- if ((label_chunk_info[i].type == PART_FILESYSTEM || label_chunk_info[i].type == PART_FAT
- || label_chunk_info[i].type == PART_EFI) && label_chunk_info[i].c->private_data
- && !strcmp(((PartInfo *)label_chunk_info[i].c->private_data)->mountpoint, name))
- return TRUE;
- return FALSE;
-}
-
-/* How much space is in this FreeBSD slice? */
-static daddr_t
-space_free(struct chunk *c)
-{
- struct chunk *c1;
- daddr_t sz = c->size;
-
- for (c1 = c->part; c1; c1 = c1->next) {
- if (c1->type != unused)
- sz -= c1->size;
- }
- if (sz < 0)
- msgFatal("Partitions are larger than actual chunk??");
- return sz;
-}
-
-/* Snapshot the current situation into the displayed chunks structure */
-static void
-record_label_chunks(Device *dev)
-{
- int j, p;
- struct chunk *c1, *c2;
- Disk *d = (Disk *)dev->private;
-
- j = p = 0;
- /* First buzz through and pick up the FreeBSD slices */
- if (!d->chunks)
- msgFatal("No chunk list found for %s!", d->name);
-
-#ifdef __ia64__
- label_chunk_info[j].type = PART_SLICE;
- label_chunk_info[j].c = d->chunks;
- j++;
-#endif
-
- /* Put the slice entries first */
- for (c1 = d->chunks->part; c1; c1 = c1->next) {
- if (c1->type == freebsd) {
- label_chunk_info[j].type = PART_SLICE;
- label_chunk_info[j].c = c1;
- ++j;
- }
-#ifdef __powerpc__
- if (c1->type == apple) {
- label_chunk_info[j].type = PART_SLICE;
- label_chunk_info[j].c = c1;
- ++j;
- }
-#endif
- }
-
- /* Then buzz through and pick up the partitions */
- for (c1 = d->chunks->part; c1; c1 = c1->next) {
- if (c1->type == freebsd) {
- for (c2 = c1->part; c2; c2 = c2->next) {
- if (c2->type == part) {
- if (c2->subtype == FS_SWAP)
- label_chunk_info[j].type = PART_SWAP;
- else
- label_chunk_info[j].type = PART_FILESYSTEM;
- label_chunk_info[j].c = c2;
- ++j;
- }
- }
- }
- else if (c1->type == fat) {
- label_chunk_info[j].type = PART_FAT;
- label_chunk_info[j].c = c1;
- ++j;
- }
-#ifdef __ia64__
- else if (c1->type == efi) {
- label_chunk_info[j].type = PART_EFI;
- label_chunk_info[j].c = c1;
- ++j;
- }
- else if (c1->type == part) {
- if (c1->subtype == FS_SWAP)
- label_chunk_info[j].type = PART_SWAP;
- else
- label_chunk_info[j].type = PART_FILESYSTEM;
- label_chunk_info[j].c = c1;
- ++j;
- }
-#endif
-#ifdef __powerpc__
- else if (c1->type == apple) {
- for (c2 = c1->part; c2; c2 = c2->next) {
- if (c2->type == part) {
- if (c2->subtype == FS_SWAP)
- label_chunk_info[j].type = PART_SWAP;
- else
- label_chunk_info[j].type = PART_FILESYSTEM;
- label_chunk_info[j].c = c2;
- ++j;
- }
- }
- }
-#endif
- }
- label_chunk_info[j].c = NULL;
- if (here >= j) {
- here = j ? j - 1 : 0;
- }
-}
-
-/* A new partition entry */
-static PartInfo *
-new_part(PartType type, char *mpoint, Boolean newfs)
-{
- PartInfo *pi;
-
- if (!mpoint)
- mpoint = (type == PART_EFI) ? "/efi" : "/change_me";
-
- pi = (PartInfo *)safe_malloc(sizeof(PartInfo));
- sstrncpy(pi->mountpoint, mpoint, FILENAME_MAX);
-
- pi->do_newfs = newfs;
-
- if (type == PART_EFI) {
- pi->newfs_type = NEWFS_MSDOS;
- } else {
- pi->newfs_type = NEWFS_UFS;
- strcpy(pi->newfs_data.newfs_ufs.user_options, "");
- pi->newfs_data.newfs_ufs.acls = FALSE;
- pi->newfs_data.newfs_ufs.multilabel = FALSE;
- pi->newfs_data.newfs_ufs.softupdates = strcmp(mpoint, "/");
-#ifdef PC98
- pi->newfs_data.newfs_ufs.ufs1 = TRUE;
-#else
- pi->newfs_data.newfs_ufs.ufs1 = FALSE;
-#endif
- }
-
- return pi;
-}
-
-/* Get the mountpoint for a partition and save it away */
-static PartInfo *
-get_mountpoint(PartType type, struct chunk *old)
-{
- char *val;
- PartInfo *tmp;
- Boolean newfs;
-
- if (old && old->private_data)
- tmp = old->private_data;
- else
- tmp = NULL;
- val = (tmp != NULL) ? tmp->mountpoint : (type == PART_EFI) ? "/efi" : NULL;
- val = msgGetInput(val, "Please specify a mount point for the partition");
- if (!val || !*val) {
- if (!old)
- return NULL;
- else {
- free(old->private_data);
- old->private_data = NULL;
- }
- return NULL;
- }
-
- /* Is it just the same value? */
- if (tmp && !strcmp(tmp->mountpoint, val))
- return NULL;
-
- /* Did we use it already? */
- if (check_conflict(val)) {
- msgConfirm("You already have a mount point for %s assigned!", val);
- return NULL;
- }
-
- /* Is it bogus? */
- if (*val != '/') {
- msgConfirm("Mount point must start with a / character");
- return NULL;
- }
-
- /* Is it going to be mounted on root? */
- if (!strcmp(val, "/")) {
- if (old)
- old->flags |= CHUNK_IS_ROOT;
- }
- else if (old)
- old->flags &= ~CHUNK_IS_ROOT;
-
- newfs = TRUE;
- if (tmp) {
- newfs = tmp->do_newfs;
- safe_free(tmp);
- }
- val = string_skipwhite(string_prune(val));
- tmp = new_part(type, val, newfs);
- if (old) {
- old->private_data = tmp;
- old->private_free = safe_free;
- }
- return tmp;
-}
-
-/* Get the type of the new partiton */
-static PartType
-get_partition_type(void)
-{
- int i;
- static char *fs_types[] = {
-#ifdef __ia64__
- "EFI", "An EFI system partition",
-#endif
- "FS", "A file system",
- "Swap", "A swap partition.",
- };
- WINDOW *w = savescr();
-
- dlg_clr_result();
- i = dialog_menu("Please choose a partition type",
- "If you want to use this partition for swap space, select Swap.\n"
- "If you want to put a filesystem on it, choose FS.",
- -1, -1,
-#ifdef __ia64__
- 3, 3,
-#else
- 2, 2,
-#endif
- fs_types);
- restorescr(w);
- if (!i) {
-#ifdef __ia64__
- if (!strcmp(dialog_vars.input_result, "EFI"))
- return PART_EFI;
-#endif
- if (!strcmp(dialog_vars.input_result, "FS"))
- return PART_FILESYSTEM;
- else if (!strcmp(dialog_vars.input_result, "Swap"))
- return PART_SWAP;
- }
- return PART_NONE;
-}
-
-/* If the user wants a special newfs command for this, set it */
-static void
-getNewfsCmd(PartInfo *p)
-{
- char buffer[NEWFS_CMD_ARGS_MAX];
- char *val;
-
- switch (p->newfs_type) {
- case NEWFS_UFS:
- snprintf(buffer, NEWFS_CMD_ARGS_MAX, "%s %s %s %s",
- NEWFS_UFS_CMD, p->newfs_data.newfs_ufs.softupdates ? "-U" : "",
- p->newfs_data.newfs_ufs.ufs1 ? "-O1" : "-O2",
- p->newfs_data.newfs_ufs.user_options);
- break;
- case NEWFS_MSDOS:
- snprintf(buffer, NEWFS_CMD_ARGS_MAX, "%s", NEWFS_MSDOS_CMD);
- break;
- case NEWFS_CUSTOM:
- strcpy(buffer, p->newfs_data.newfs_custom.command);
- break;
- }
-
- val = msgGetInput(buffer,
- "Please enter the newfs command and options you'd like to use in\n"
- "creating this file system.");
- if (val != NULL) {
- p->newfs_type = NEWFS_CUSTOM;
- strlcpy(p->newfs_data.newfs_custom.command, val, NEWFS_CMD_ARGS_MAX);
- }
-}
-
-static void
-getNewfsOptionalArguments(PartInfo *p)
-{
- char buffer[NEWFS_CMD_ARGS_MAX];
- char *val;
-
- /* Must be UFS, per argument checking in I/O routines. */
-
- strlcpy(buffer, p->newfs_data.newfs_ufs.user_options,
- NEWFS_CMD_ARGS_MAX);
- val = msgGetInput(buffer,
- "Please enter any additional UFS newfs options you'd like to\n"
- "use in creating this file system.");
- if (val != NULL)
- strlcpy(p->newfs_data.newfs_ufs.user_options, val,
- NEWFS_CMD_ARGS_MAX);
-}
-
-#define MAX_MOUNT_NAME 9
-
-#define PART_PART_COL 0
-#define PART_MOUNT_COL 10
-#define PART_SIZE_COL (PART_MOUNT_COL + MAX_MOUNT_NAME + 3)
-#define PART_NEWFS_COL (PART_SIZE_COL + 8)
-#define PART_OFF 38
-
-#define TOTAL_AVAIL_LINES (10)
-#define PSLICE_SHOWABLE (4)
-
-
-/* stick this all up on the screen */
-static void
-print_label_chunks(void)
-{
- int i, j, srow, prow, pcol;
- daddr_t sz;
- char clrmsg[80];
- int ChunkPartStartRow;
- WINDOW *ChunkWin;
-
- /*********************************************************/
- /*** These values are for controlling screen resources ***/
- /*** Each label line holds up to 2 labels, so beware! ***/
- /*** strategy will be to try to always make sure the ***/
- /*** highlighted label is in the active display area. ***/
- /*********************************************************/
- int pslice_max, label_max;
- int pslice_count, label_count, label_focus_found, pslice_focus_found;
-
- attrset(A_REVERSE);
- mvaddstr(0, 25, "FreeBSD Disklabel Editor");
- attrset(A_NORMAL);
-
- /*** Count the number of partition slices ***/
- pslice_count = 0;
- for (i = 0; label_chunk_info[i].c ; i++) {
- if (label_chunk_info[i].type == PART_SLICE)
- ++pslice_count;
- }
- pslice_max = pslice_count;
-
- /*** 4 line max for partition slices ***/
- if (pslice_max > PSLICE_SHOWABLE) {
- pslice_max = PSLICE_SHOWABLE;
- }
- ChunkPartStartRow = CHUNK_SLICE_START_ROW + 3 + pslice_max;
-
- /*** View partition slices modulo pslice_max ***/
- label_max = TOTAL_AVAIL_LINES - pslice_max;
-
- for (i = 0; i < 2; i++) {
- mvaddstr(ChunkPartStartRow - 2, PART_PART_COL + (i * PART_OFF), "Part");
- mvaddstr(ChunkPartStartRow - 1, PART_PART_COL + (i * PART_OFF), "----");
-
- mvaddstr(ChunkPartStartRow - 2, PART_MOUNT_COL + (i * PART_OFF), "Mount");
- mvaddstr(ChunkPartStartRow - 1, PART_MOUNT_COL + (i * PART_OFF), "-----");
-
- mvaddstr(ChunkPartStartRow - 2, PART_SIZE_COL + (i * PART_OFF) + 3, "Size");
- mvaddstr(ChunkPartStartRow - 1, PART_SIZE_COL + (i * PART_OFF) + 3, "----");
-
- mvaddstr(ChunkPartStartRow - 2, PART_NEWFS_COL + (i * PART_OFF), "Newfs");
- mvaddstr(ChunkPartStartRow - 1, PART_NEWFS_COL + (i * PART_OFF), "-----");
- }
- srow = CHUNK_SLICE_START_ROW;
- prow = 0;
- pcol = 0;
-
- /*** these variables indicate that the focused item is shown currently ***/
- label_focus_found = 0;
- pslice_focus_found = 0;
-
- label_count = 0;
- pslice_count = 0;
- mvprintw(CHUNK_SLICE_START_ROW - 1, 0, " ");
- mvprintw(CHUNK_SLICE_START_ROW + pslice_max, 0, " ");
-
- ChunkWin = newwin(CHUNK_ROW_MAX - ChunkPartStartRow, 76, ChunkPartStartRow, 0);
-
- wclear(ChunkWin);
- /*** wrefresh(ChunkWin); ***/
-
- for (i = 0; label_chunk_info[i].c; i++) {
- /* Is it a slice entry displayed at the top? */
- if (label_chunk_info[i].type == PART_SLICE) {
- /*** This causes the new pslice to replace the previous display ***/
- /*** focus must remain on the most recently active pslice ***/
- if (pslice_count == pslice_max) {
- if (pslice_focus_found) {
- /*** This is where we can mark the more following ***/
- attrset(A_BOLD);
- mvprintw(CHUNK_SLICE_START_ROW + pslice_max, 0, "***MORE***");
- attrset(A_NORMAL);
- continue;
- }
- else {
- /*** this is where we set the more previous ***/
- attrset(A_BOLD);
- mvprintw(CHUNK_SLICE_START_ROW - 1, 0, "***MORE***");
- attrset(A_NORMAL);
- pslice_count = 0;
- srow = CHUNK_SLICE_START_ROW;
- }
- }
-
- sz = space_free(label_chunk_info[i].c);
- if (i == here)
- attrset(ATTR_SELECTED);
- if (i == pslice_focus)
- pslice_focus_found = -1;
-
- if (label_chunk_info[i].c->type == whole) {
- if (sz >= 100 * ONE_GIG)
- mvprintw(srow++, 0,
- "Disk: %s\t\tFree: %jd blocks (%jdGB)",
- label_chunk_info[i].c->disk->name, (intmax_t)sz,
- (intmax_t)(sz / ONE_GIG));
- else
- mvprintw(srow++, 0,
- "Disk: %s\t\tFree: %jd blocks (%jdMB)",
- label_chunk_info[i].c->disk->name, (intmax_t)sz,
- (intmax_t)(sz / ONE_MEG));
- } else {
- if (sz >= 100 * ONE_GIG)
- mvprintw(srow++, 0,
- "Disk: %s\tPartition name: %s\tFree: %jd blocks (%jdGB)",
- label_chunk_info[i].c->disk->name,
- label_chunk_info[i].c->name,
- (intmax_t)sz, (intmax_t)(sz / ONE_GIG));
- else
- mvprintw(srow++, 0,
- "Disk: %s\tPartition name: %s\tFree: %jd blocks (%jdMB)",
- label_chunk_info[i].c->disk->name,
- label_chunk_info[i].c->name,
- (intmax_t)sz, (intmax_t)(sz / ONE_MEG));
- }
- attrset(A_NORMAL);
- clrtoeol();
- move(0, 0);
- /*** refresh(); ***/
- ++pslice_count;
- }
- /* Otherwise it's a DOS, swap or filesystem entry in the Chunk window */
- else {
- char onestr[PART_OFF], num[10], *mountpoint, newfs[12];
-
- /*
- * We copy this into a blank-padded string so that it looks like
- * a solid bar in reverse-video
- */
- memset(onestr, ' ', PART_OFF - 1);
- onestr[PART_OFF - 1] = '\0';
-
- /*** Track how many labels have been displayed ***/
- if (label_count == ((label_max - 1 ) * 2)) {
- if (label_focus_found) {
- continue;
- }
- else {
- label_count = 0;
- prow = 0;
- pcol = 0;
- }
- }
-
- /* Go for two columns if we've written one full columns worth */
- /*** if (prow == (CHUNK_ROW_MAX - ChunkPartStartRow)) ***/
- if (label_count == label_max - 1) {
- pcol = PART_OFF;
- prow = 0;
- }
- memcpy(onestr + PART_PART_COL, label_chunk_info[i].c->name, strlen(label_chunk_info[i].c->name));
- /* If it's a filesystem, display the mountpoint */
- if (label_chunk_info[i].c->private_data && (label_chunk_info[i].type == PART_FILESYSTEM
- || label_chunk_info[i].type == PART_FAT || label_chunk_info[i].type == PART_EFI))
- mountpoint = ((PartInfo *)label_chunk_info[i].c->private_data)->mountpoint;
- else if (label_chunk_info[i].type == PART_SWAP)
- mountpoint = "swap";
- else
- mountpoint = "<none>";
-
- /* Now display the newfs field */
- if (label_chunk_info[i].type == PART_FAT)
- strcpy(newfs, "DOS");
-#if defined(__ia64__)
- else if (label_chunk_info[i].type == PART_EFI) {
- strcpy(newfs, "EFI");
- if (label_chunk_info[i].c->private_data) {
- strcat(newfs, " ");
- PartInfo *pi = (PartInfo *)label_chunk_info[i].c->private_data;
- strcat(newfs, pi->do_newfs ? " Y" : " N");
- }
- }
-#endif
- else if (label_chunk_info[i].c->private_data && label_chunk_info[i].type == PART_FILESYSTEM) {
- PartInfo *pi = (PartInfo *)label_chunk_info[i].c->private_data;
-
- switch (pi->newfs_type) {
- case NEWFS_UFS:
- strcpy(newfs, NEWFS_UFS_STRING);
- if (pi->newfs_data.newfs_ufs.ufs1)
- strcat(newfs, "1");
- else
- strcat(newfs, "2");
- if (pi->newfs_data.newfs_ufs.softupdates)
- strcat(newfs, "+S");
- else
- strcat(newfs, " ");
-
- break;
- case NEWFS_MSDOS:
- strcpy(newfs, "FAT");
- break;
- case NEWFS_CUSTOM:
- strcpy(newfs, "CUST");
- break;
- }
- strcat(newfs, pi->do_newfs ? " Y" : " N ");
- }
- else if (label_chunk_info[i].type == PART_SWAP)
- strcpy(newfs, "SWAP");
- else
- strcpy(newfs, "*");
- for (j = 0; j < MAX_MOUNT_NAME && mountpoint[j]; j++)
- onestr[PART_MOUNT_COL + j] = mountpoint[j];
- if (label_chunk_info[i].c->size == 0)
- snprintf(num, 10, "%5dMB", 0);
- else if (label_chunk_info[i].c->size < (100 * ONE_GIG))
- snprintf(num, 10, "%5jdMB",
- (intmax_t)label_chunk_info[i].c->size / ONE_MEG);
- else
- snprintf(num, 10, "%5jdGB",
- (intmax_t)label_chunk_info[i].c->size / ONE_GIG);
- memcpy(onestr + PART_SIZE_COL, num, strlen(num));
- memcpy(onestr + PART_NEWFS_COL, newfs, strlen(newfs));
- onestr[PART_NEWFS_COL + strlen(newfs)] = '\0';
- if (i == label_focus) {
- label_focus_found = -1;
- wattrset(ChunkWin, A_BOLD);
- }
- if (i == here)
- wattrset(ChunkWin, ATTR_SELECTED);
-
- /*** lazy man's way of expensively padding this string ***/
- while (strlen(onestr) < 37)
- strcat(onestr, " ");
-
- mvwaddstr(ChunkWin, prow, pcol, onestr);
- wattrset(ChunkWin, A_NORMAL);
- move(0, 0);
- ++prow;
- ++label_count;
- }
- }
-
- /*** this will erase all the extra stuff ***/
- memset(clrmsg, ' ', 37);
- clrmsg[37] = '\0';
-
- while (pslice_count < pslice_max) {
- mvprintw(srow++, 0, clrmsg);
- clrtoeol();
- ++pslice_count;
- }
- while (label_count < (2 * (label_max - 1))) {
- mvwaddstr(ChunkWin, prow++, pcol, clrmsg);
- ++label_count;
- if (prow == (label_max - 1)) {
- prow = 0;
- pcol = PART_OFF;
- }
- }
- refresh();
- wrefresh(ChunkWin);
-}
-
-static void
-print_command_summary(void)
-{
- mvprintw(17, 0, "The following commands are valid here (upper or lower case):");
- mvprintw(18, 0, "C = Create D = Delete M = Mount pt.");
- mvprintw(18, 56, "W = Write");
- mvprintw(19, 0, "N = Newfs Opts Q = Finish S = Toggle SoftUpdates Z = Custom Newfs");
- mvprintw(20, 0, "T = Toggle Newfs U = Undo A = Auto Defaults R = Delete+Merge");
- mvprintw(22, 0, "Use F1 or ? to get more help, arrow keys to select.");
- move(0, 0);
-}
-
-static void
-clear_wins(void)
-{
-
- clear();
- print_label_chunks();
-}
-
-static int
-diskLabel(Device *dev)
-{
- daddr_t sz;
- int key = 0;
- Boolean labeling;
- char *msg = NULL;
- PartInfo *p, *oldp;
- PartType type;
- WINDOW *w = savescr();
-
- label_focus = 0;
- pslice_focus = 0;
- here = 0;
-
- labeling = TRUE;
- keypad(stdscr, TRUE);
- record_label_chunks(dev);
-
- clear();
- while (labeling) {
- char *cp;
- int rflags = DELCHUNK_NORMAL;
-
- print_label_chunks();
- print_command_summary();
- if (msg) {
- attrset(title_attr); mvprintw(23, 0, msg); attrset(A_NORMAL);
- clrtoeol();
- beep();
- msg = NULL;
- }
- else {
- move(23, 0);
- clrtoeol();
- }
-
- refresh();
- key = getch();
- switch (toupper(key)) {
- static char _msg[40];
-
- case '\014': /* ^L */
- clear_wins();
- break;
-
- case '\020': /* ^P */
- case KEY_UP:
- case '-':
- if (here != 0)
- --here;
- else
- while (label_chunk_info[here + 1].c)
- ++here;
- break;
-
- case '\016': /* ^N */
- case KEY_DOWN:
- case '+':
- case '\r':
- case '\n':
- if (label_chunk_info[here + 1].c)
- ++here;
- else
- here = 0;
- break;
-
- case KEY_HOME:
- here = 0;
- break;
-
- case KEY_END:
- while (label_chunk_info[here + 1].c)
- ++here;
- break;
-
- case KEY_F(1):
- case '?':
- systemDisplayHelp("partition");
- clear_wins();
- break;
-
- case '1':
- if (label_chunk_info[here].type == PART_FILESYSTEM) {
- PartInfo *pi =
- ((PartInfo *)label_chunk_info[here].c->private_data);
-
- if ((pi != NULL) &&
- (pi->newfs_type == NEWFS_UFS)) {
- pi->newfs_data.newfs_ufs.ufs1 = true;
- } else
- msg = MSG_NOT_APPLICABLE;
- } else
- msg = MSG_NOT_APPLICABLE;
- break;
- break;
-
- case '2':
- if (label_chunk_info[here].type == PART_FILESYSTEM) {
- PartInfo *pi =
- ((PartInfo *)label_chunk_info[here].c->private_data);
-
- if ((pi != NULL) &&
- (pi->newfs_type == NEWFS_UFS)) {
- pi->newfs_data.newfs_ufs.ufs1 = false;
- } else
- msg = MSG_NOT_APPLICABLE;
- } else
- msg = MSG_NOT_APPLICABLE;
- break;
- break;
-
- case 'A':
- if (label_chunk_info[here].type != PART_SLICE) {
- msg = "You can only do this in a disk slice (at top of screen)";
- break;
- }
- /*
- * Generate standard partitions automatically. If we do not
- * have sufficient space we attempt to scale-down the size
- * of the partitions within certain bounds.
- */
- {
- int perc;
- int req = 0;
-
- for (perc = 100; perc > 0; perc -= 5) {
- req = 0; /* reset for each loop */
- if ((msg = try_auto_label(dev, perc, &req)) == NULL)
- break;
- }
- if (msg) {
- if (req) {
- msgConfirm("%s", msg);
- clear_wins();
- msg = NULL;
- }
- }
- }
- break;
-
- case 'C':
- if (label_chunk_info[here].type != PART_SLICE) {
- msg = "You can only do this in a master partition (see top of screen)";
- break;
- }
- sz = space_free(label_chunk_info[here].c);
- if (sz <= FS_MIN_SIZE) {
- msg = "Not enough space to create an additional FreeBSD partition";
- break;
- }
- else {
- char *val;
- daddr_t size;
- struct chunk *tmp;
- char osize[80];
- u_long flags = 0;
-
-#ifdef __powerpc__
- /* Always use the maximum size for apple partitions */
- if (label_chunk_info[here].c->type == apple)
- size = sz;
- else {
-#endif
- sprintf(osize, "%jd", (intmax_t)sz);
- val = msgGetInput(osize,
- "Please specify the partition size in blocks or append a trailing G for\n"
-#ifdef __ia64__
- "gigabytes, M for megabytes.\n"
-#else
- "gigabytes, M for megabytes, or C for cylinders.\n"
-#endif
- "%jd blocks (%jdMB) are free.",
- (intmax_t)sz, (intmax_t)sz / ONE_MEG);
- if (!val || (size = strtoimax(val, &cp, 0)) <= 0) {
- clear_wins();
- break;
- }
-
- if (*cp) {
- if (toupper(*cp) == 'M')
- size *= ONE_MEG;
- else if (toupper(*cp) == 'G')
- size *= ONE_GIG;
-#ifndef __ia64__
- else if (toupper(*cp) == 'C')
- size *= (label_chunk_info[here].c->disk->bios_hd * label_chunk_info[here].c->disk->bios_sect);
-#endif
- }
- if (size <= FS_MIN_SIZE) {
- msgConfirm("The minimum filesystem size is %dMB", FS_MIN_SIZE / ONE_MEG);
- clear_wins();
- break;
- }
-#ifdef __powerpc__
- }
-#endif
- type = get_partition_type();
- if (type == PART_NONE) {
- clear_wins();
- beep();
- break;
- }
-
- if (type == PART_FILESYSTEM || type == PART_EFI) {
- if ((p = get_mountpoint(type, NULL)) == NULL) {
- clear_wins();
- beep();
- break;
- }
- else if (!strcmp(p->mountpoint, "/")) {
- if (type != PART_FILESYSTEM) {
- clear_wins();
- beep();
- break;
- }
- else
- flags |= CHUNK_IS_ROOT;
- }
- else
- flags &= ~CHUNK_IS_ROOT;
- }
- else
- p = NULL;
-
- if ((flags & CHUNK_IS_ROOT) && (size < (ROOT_MIN_SIZE * ONE_MEG))) {
- msgConfirm("Warning: This is smaller than the recommended size for a\n"
- "root partition. For a variety of reasons, root\n"
- "partitions should usually be at least %dMB in size", ROOT_MIN_SIZE);
- }
- tmp = Create_Chunk_DWIM(label_chunk_info[here].c->disk,
- label_chunk_info[here].c, size,
-#ifdef __ia64__
- (type == PART_EFI) ? efi : part,
- (type == PART_EFI) ? 0 : (type == PART_SWAP) ? FS_SWAP : FS_BSDFFS,
-#else
- part, (type == PART_SWAP) ? FS_SWAP : FS_BSDFFS,
-#endif
- flags);
- if (!tmp) {
- msgConfirm("Unable to create the partition. Too big?");
- clear_wins();
- break;
- }
-
-#ifdef __alpha__
- /*
- * SRM requires that the root partition is at the
- * beginning of the disk and cannot boot otherwise.
- * Warn Alpha users if they are about to shoot themselves in
- * the foot in this way.
- *
- * Since partitions may not start precisely at offset 0 we
- * check for a "close to 0" instead. :-(
- */
- if ((flags & CHUNK_IS_ROOT) && (tmp->offset > 1024)) {
- msgConfirm("Your root partition `a' does not seem to be the first\n"
- "partition. The Alpha's firmware can only boot from the\n"
- "first partition. So it is unlikely that your current\n"
- "disk layout will be bootable boot after installation.\n"
- "\n"
- "Please allocate the root partition before allocating\n"
- "any others.\n");
- }
-#endif /* alpha */
-
- tmp->private_data = p;
- tmp->private_free = safe_free;
- if (variable_cmp(DISK_LABELLED, "written"))
- variable_set2(DISK_LABELLED, "yes", 0);
- record_label_chunks(dev);
- clear_wins();
- /* This is where we assign focus to new label so it shows. */
- {
- int i;
- label_focus = -1;
- for (i = 0; label_chunk_info[i].c; ++i) {
- if (label_chunk_info[i].c == tmp) {
- label_focus = i;
- break;
- }
- }
- if (label_focus == -1)
- label_focus = i - 1;
- }
- }
- break;
-
- case KEY_DC:
- case 'R': /* recover space (delete w/ recover) */
- /*
- * Delete the partition w/ space recovery.
- */
- rflags = DELCHUNK_RECOVER;
- /* fall through */
- case 'D': /* delete */
- if (label_chunk_info[here].type == PART_SLICE) {
- msg = MSG_NOT_APPLICABLE;
- break;
- }
- else if (label_chunk_info[here].type == PART_FAT) {
- msg = "Use the Disk Partition Editor to delete DOS partitions";
- break;
- }
- Delete_Chunk2(label_chunk_info[here].c->disk, label_chunk_info[here].c, rflags);
- if (variable_cmp(DISK_LABELLED, "written"))
- variable_set2(DISK_LABELLED, "yes", 0);
- record_label_chunks(dev);
- break;
-
- case 'M': /* mount */
- switch(label_chunk_info[here].type) {
- case PART_SLICE:
- msg = MSG_NOT_APPLICABLE;
- break;
-
- case PART_SWAP:
- msg = "You don't need to specify a mountpoint for a swap partition.";
- break;
-
- case PART_FAT:
- case PART_EFI:
- case PART_FILESYSTEM:
- oldp = label_chunk_info[here].c->private_data;
- p = get_mountpoint(label_chunk_info[here].type, label_chunk_info[here].c);
- if (p) {
- if (!oldp)
- p->do_newfs = FALSE;
- if ((label_chunk_info[here].type == PART_FAT ||
- label_chunk_info[here].type == PART_EFI) &&
- (!strcmp(p->mountpoint, "/") ||
- !strcmp(p->mountpoint, "/usr") ||
- !strcmp(p->mountpoint, "/var"))) {
- msgConfirm("%s is an invalid mount point for a DOS partition!", p->mountpoint);
- strcpy(p->mountpoint, "/bogus");
- }
- }
- if (variable_cmp(DISK_LABELLED, "written"))
- variable_set2(DISK_LABELLED, "yes", 0);
- record_label_chunks(dev);
- clear_wins();
- break;
-
- default:
- msgFatal("Bogus partition under cursor???");
- break;
- }
- break;
-
- case 'N': /* Set newfs options */
- if (label_chunk_info[here].c->private_data &&
- ((PartInfo *)label_chunk_info[here].c->private_data)->do_newfs)
- getNewfsOptionalArguments(
- label_chunk_info[here].c->private_data);
- else
- msg = MSG_NOT_APPLICABLE;
- clear_wins();
- break;
-
- case 'S': /* Toggle soft updates flag */
- if (label_chunk_info[here].type == PART_FILESYSTEM) {
- PartInfo *pi = ((PartInfo *)label_chunk_info[here].c->private_data);
- if (pi != NULL &&
- pi->newfs_type == NEWFS_UFS)
- pi->newfs_data.newfs_ufs.softupdates =
- !pi->newfs_data.newfs_ufs.softupdates;
- else
- msg = MSG_NOT_APPLICABLE;
- }
- else
- msg = MSG_NOT_APPLICABLE;
- break;
-
- case 'T': /* Toggle newfs state */
- if ((label_chunk_info[here].type == PART_FILESYSTEM ||
- label_chunk_info[here].type == PART_EFI) &&
- (label_chunk_info[here].c->private_data)) {
- PartInfo *pi = ((PartInfo *)label_chunk_info[here].c->private_data);
- if (!pi->do_newfs)
- label_chunk_info[here].c->flags |= CHUNK_NEWFS;
- else
- label_chunk_info[here].c->flags &= ~CHUNK_NEWFS;
-
- label_chunk_info[here].c->private_data =
- new_part(label_chunk_info[here].type, pi ? pi->mountpoint : NULL, pi ? !pi->do_newfs
- : TRUE);
- if (pi != NULL &&
- pi->newfs_type == NEWFS_UFS) {
- PartInfo *pi_new = label_chunk_info[here].c->private_data;
-
- pi_new->newfs_data.newfs_ufs = pi->newfs_data.newfs_ufs;
- }
- safe_free(pi);
- label_chunk_info[here].c->private_free = safe_free;
- if (variable_cmp(DISK_LABELLED, "written"))
- variable_set2(DISK_LABELLED, "yes", 0);
- }
- else
- msg = MSG_NOT_APPLICABLE;
- break;
-
- case 'U':
- clear();
- if (!variable_cmp(DISK_LABELLED, "written")) {
- msgConfirm("You've already written out your changes -\n"
- "it's too late to undo!");
- }
- else if (!msgNoYes("Are you SURE you want to Undo everything?")) {
- Disk *d;
-
- variable_unset(DISK_PARTITIONED);
- variable_unset(DISK_LABELLED);
- if ((d = Open_Disk(dev->name)) != NULL) {
- Free_Disk(dev->private);
- dev->private = d;
-#ifdef WITH_SLICES
- diskPartition(dev);
-#endif
- }
- record_label_chunks(dev);
- }
- clear_wins();
- break;
-
- case 'W':
- if (!variable_cmp(DISK_LABELLED, "written")) {
- msgConfirm("You've already written out your changes - if you\n"
- "wish to overwrite them, you'll have to restart\n"
- "%s first.", ProgName);
- }
- else if (!msgNoYes("WARNING: You are about to modify an EXISTING\n"
- "installation.\n\n"
- "Are you absolutely sure you want to continue?")) {
- variable_set2(DISK_LABELLED, "yes", 0);
- diskLabelCommit(dev);
- }
- clear_wins();
- break;
-
- case 'Z': /* Set newfs command line */
- if (label_chunk_info[here].c->private_data &&
- ((PartInfo *)label_chunk_info[here].c->private_data)->do_newfs)
- getNewfsCmd(label_chunk_info[here].c->private_data);
- else
- msg = MSG_NOT_APPLICABLE;
- clear_wins();
- break;
-
-#ifndef __ia64__
- case '|':
- if (!msgNoYes("Are you sure you want to go into Wizard mode?\n\n"
- "This is an entirely undocumented feature which you are not\n"
- "expected to understand!")) {
- dlg_clear();
- end_dialog();
- DialogActive = FALSE;
- if (dev->private) {
- slice_wizard(((Disk *)dev->private));
- }
- if (variable_cmp(DISK_LABELLED, "written"))
- variable_set2(DISK_LABELLED, "yes", 0);
- DialogActive = TRUE;
- record_label_chunks(dev);
- clear_wins();
- }
- else
- msg = "A most prudent choice!";
- break;
-#endif
-
- case '\033': /* ESC */
- case 'Q':
- labeling = FALSE;
- break;
-
- default:
- beep();
- sprintf(_msg, "Invalid key %d - Type F1 or ? for help", key);
- msg = _msg;
- break;
- }
- if (label_chunk_info[here].type == PART_SLICE)
- pslice_focus = here;
- else
- label_focus = here;
- }
- restorescr(w);
- return DITEM_SUCCESS;
-}
-
-static __inline daddr_t
-requested_part_size(char *varName, daddr_t nom, int def, int perc)
-{
- char *cp;
- daddr_t sz;
-
- if ((cp = variable_get(varName)) != NULL)
- sz = strtoimax(cp, NULL, 0);
- else
- sz = nom + (def - nom) * perc / 100;
- return(sz * ONE_MEG);
-}
-
-/*
- * Attempt to auto-label the disk. 'perc' (0-100) scales
- * the size of the various partitions within appropriate
- * bounds (NOMINAL through DEFAULT sizes). The procedure
- * succeeds of NULL is returned. A non-null return message
- * is either a failure-status message (*req == 0), or
- * a confirmation requestor (*req == 1). *req is 0 on
- * entry to this call.
- *
- * As a special exception to the usual sizing rules, /var is given
- * additional space equal to the amount of physical memory present
- * if perc == 100 in order to ensure that users with large hard drives
- * will have enough space to store a crashdump in /var/crash.
- *
- * We autolabel the following partitions: /, swap, /var, /tmp, /usr,
- * and /home. /home receives any extra left over disk space.
- */
-static char *
-try_auto_label(Device *dev, int perc, int *req)
-{
- daddr_t sz;
- Chunk *AutoHome, *AutoRoot, *AutoSwap;
- Chunk *AutoTmp, *AutoUsr, *AutoVar;
-#ifdef __ia64__
- Chunk *AutoEfi;
-#endif
- int mib[2];
- unsigned long physmem;
- size_t size;
- char *msg = NULL;
-
- sz = space_free(label_chunk_info[here].c);
- if (sz <= FS_MIN_SIZE)
- return("Not enough free space to create a new partition in the slice");
-
- (void)checkLabels(FALSE);
- AutoHome = AutoRoot = AutoSwap = NULL;
- AutoTmp = AutoUsr = AutoVar = NULL;
-
-#ifdef __ia64__
- AutoEfi = NULL;
- if (EfiChunk == NULL) {
- sz = 100 * ONE_MEG;
- AutoEfi = Create_Chunk_DWIM(label_chunk_info[here].c->disk,
- label_chunk_info[here].c, sz, efi, 0, 0);
- if (AutoEfi == NULL) {
- *req = 1;
- msg = "Unable to create the EFI system partition. Too big?";
- goto done;
- }
- AutoEfi->private_data = new_part(PART_EFI, "/efi", TRUE);
- AutoEfi->private_free = safe_free;
- AutoEfi->flags |= CHUNK_NEWFS;
- record_label_chunks(dev);
- }
-#endif
-
- if (RootChunk == NULL) {
- sz = requested_part_size(VAR_ROOT_SIZE, ROOT_NOMINAL_SIZE, ROOT_DEFAULT_SIZE, perc);
-
- AutoRoot = Create_Chunk_DWIM(label_chunk_info[here].c->disk,
- label_chunk_info[here].c, sz, part,
- FS_BSDFFS, CHUNK_IS_ROOT | CHUNK_AUTO_SIZE);
- if (!AutoRoot) {
- *req = 1;
- msg = "Unable to create the root partition. Too big?";
- goto done;
- }
- AutoRoot->private_data = new_part(PART_FILESYSTEM, "/", TRUE);
- AutoRoot->private_free = safe_free;
- AutoRoot->flags |= CHUNK_NEWFS;
- record_label_chunks(dev);
- }
- if (SwapChunk == NULL) {
- sz = requested_part_size(VAR_SWAP_SIZE, 0, 0, perc);
- if (sz == 0) {
- daddr_t nom;
- daddr_t def;
-
- mib[0] = CTL_HW;
- mib[1] = HW_PHYSMEM;
- size = sizeof physmem;
- sysctl(mib, 2, &physmem, &size, (void *)0, (size_t)0);
- def = 2 * (int)(physmem / 512);
- if (def < SWAP_MIN_SIZE * ONE_MEG)
- def = SWAP_MIN_SIZE * ONE_MEG;
- if (def > SWAP_AUTO_LIMIT_SIZE * ONE_MEG)
- def = SWAP_AUTO_LIMIT_SIZE * ONE_MEG;
- nom = (int)(physmem / 512) / 8;
- sz = nom + (def - nom) * perc / 100;
- }
- AutoSwap = Create_Chunk_DWIM(label_chunk_info[here].c->disk,
- label_chunk_info[here].c, sz, part,
- FS_SWAP, CHUNK_AUTO_SIZE);
- if (!AutoSwap) {
- *req = 1;
- msg = "Unable to create the swap partition. Too big?";
- goto done;
- }
- AutoSwap->private_data = 0;
- AutoSwap->private_free = safe_free;
- record_label_chunks(dev);
- }
- if (VarChunk == NULL) {
- /* Work out how much extra space we want for a crash dump */
- unsigned long crashdumpsz;
-
- mib[0] = CTL_HW;
- mib[1] = HW_PHYSMEM;
- size = sizeof(physmem);
- sysctl(mib, 2, &physmem, &size, (void *)0, (size_t)0);
-
- if (perc == 100)
- crashdumpsz = physmem / 1048576;
- else
- crashdumpsz = 0;
-
- sz = requested_part_size(VAR_VAR_SIZE, VAR_NOMINAL_SIZE, \
- VAR_DEFAULT_SIZE + crashdumpsz, perc);
-
- AutoVar = Create_Chunk_DWIM(label_chunk_info[here].c->disk,
- label_chunk_info[here].c, sz, part,
- FS_BSDFFS, CHUNK_AUTO_SIZE);
- if (!AutoVar) {
- *req = 1;
- msg = "Not enough free space for /var - you will need to\n"
- "partition your disk manually with a custom install!";
- goto done;
- }
- AutoVar->private_data = new_part(PART_FILESYSTEM, "/var", TRUE);
- AutoVar->private_free = safe_free;
- AutoVar->flags |= CHUNK_NEWFS;
- record_label_chunks(dev);
- }
- if (TmpChunk == NULL && !variable_get(VAR_NO_TMP)) {
- sz = requested_part_size(VAR_TMP_SIZE, TMP_NOMINAL_SIZE, TMP_DEFAULT_SIZE, perc);
-
- AutoTmp = Create_Chunk_DWIM(label_chunk_info[here].c->disk,
- label_chunk_info[here].c, sz, part,
- FS_BSDFFS, CHUNK_AUTO_SIZE);
- if (!AutoTmp) {
- *req = 1;
- msg = "Not enough free space for /tmp - you will need to\n"
- "partition your disk manually with a custom install!";
- goto done;
- }
- AutoTmp->private_data = new_part(PART_FILESYSTEM, "/tmp", TRUE);
- AutoTmp->private_free = safe_free;
- AutoTmp->flags |= CHUNK_NEWFS;
- record_label_chunks(dev);
- }
- if (UsrChunk == NULL && !variable_get(VAR_NO_USR)) {
- sz = requested_part_size(VAR_USR_SIZE, USR_NOMINAL_SIZE, USR_DEFAULT_SIZE, perc);
-#if AUTO_HOME == 0
- if (sz < space_free(label_chunk_info[here].c))
- sz = space_free(label_chunk_info[here].c);
-#endif
- if (sz) {
- if (sz < (USR_MIN_SIZE * ONE_MEG)) {
- *req = 1;
- msg = "Not enough free space for /usr - you will need to\n"
- "partition your disk manually with a custom install!";
- }
-
- AutoUsr = Create_Chunk_DWIM(label_chunk_info[here].c->disk,
- label_chunk_info[here].c, sz, part,
- FS_BSDFFS, CHUNK_AUTO_SIZE);
- if (!AutoUsr) {
- msg = "Unable to create the /usr partition. Not enough space?\n"
- "You will need to partition your disk manually with a custom install!";
- goto done;
- }
- AutoUsr->private_data = new_part(PART_FILESYSTEM, "/usr", TRUE);
- AutoUsr->private_free = safe_free;
- AutoUsr->flags |= CHUNK_NEWFS;
- record_label_chunks(dev);
- }
- }
-#if AUTO_HOME == 1
- if (HomeChunk == NULL && !variable_get(VAR_NO_HOME)) {
- sz = requested_part_size(VAR_HOME_SIZE, HOME_NOMINAL_SIZE, HOME_DEFAULT_SIZE, perc);
- if (sz < space_free(label_chunk_info[here].c))
- sz = space_free(label_chunk_info[here].c);
- if (sz) {
- if (sz < (HOME_MIN_SIZE * ONE_MEG)) {
- *req = 1;
- msg = "Not enough free space for /home - you will need to\n"
- "partition your disk manually with a custom install!";
- goto done;
- }
-
- AutoHome = Create_Chunk_DWIM(label_chunk_info[here].c->disk,
- label_chunk_info[here].c, sz, part,
- FS_BSDFFS, CHUNK_AUTO_SIZE);
- if (!AutoHome) {
- msg = "Unable to create the /home partition. Not enough space?\n"
- "You will need to partition your disk manually with a custom install!";
- goto done;
- }
- AutoHome->private_data = new_part(PART_FILESYSTEM, "/home", TRUE);
- AutoHome->private_free = safe_free;
- AutoHome->flags |= CHUNK_NEWFS;
- record_label_chunks(dev);
- }
- }
-#endif
-
- /* At this point, we're reasonably "labelled" */
- if (variable_cmp(DISK_LABELLED, "written"))
- variable_set2(DISK_LABELLED, "yes", 0);
-
-done:
- if (msg) {
- if (AutoRoot != NULL)
- Delete_Chunk(AutoRoot->disk, AutoRoot);
- if (AutoSwap != NULL)
- Delete_Chunk(AutoSwap->disk, AutoSwap);
- if (AutoVar != NULL)
- Delete_Chunk(AutoVar->disk, AutoVar);
- if (AutoTmp != NULL)
- Delete_Chunk(AutoTmp->disk, AutoTmp);
- if (AutoUsr != NULL)
- Delete_Chunk(AutoUsr->disk, AutoUsr);
- if (AutoHome != NULL)
- Delete_Chunk(AutoHome->disk, AutoHome);
- record_label_chunks(dev);
- }
- return(msg);
-}
-
-static int
-diskLabelNonInteractive(Device *dev)
-{
- char *cp;
- PartType type;
- PartInfo *p;
- u_long flags;
- int i, status;
- Device **devs;
- Disk *d;
-
- status = DITEM_SUCCESS;
- cp = variable_get(VAR_DISK);
- if (!cp) {
- msgConfirm("diskLabel: No disk selected - can't label automatically.");
- return DITEM_FAILURE;
- }
- devs = deviceFind(cp, DEVICE_TYPE_DISK);
- if (!devs) {
- msgConfirm("diskLabel: No disk device %s found!", cp);
- return DITEM_FAILURE;
- }
- if (dev)
- d = dev->private;
- else
- d = devs[0]->private;
- record_label_chunks(dev);
- for (i = 0; label_chunk_info[i].c; i++) {
- Chunk *c1 = label_chunk_info[i].c;
-
- if (label_chunk_info[i].type == PART_SLICE) {
- char name[512];
- char typ[10], mpoint[50];
- int entries;
-
- for (entries = 1;; entries++) {
- intmax_t sz;
- int soft = 0;
- snprintf(name, sizeof name, "%s-%d", c1->name, entries);
- if ((cp = variable_get(name)) == NULL)
- break;
- if (sscanf(cp, "%s %jd %s %d", typ, &sz, mpoint, &soft) < 3) {
- msgConfirm("For slice entry %s, got an invalid detail entry of: %s", c1->name, cp);
- status = DITEM_FAILURE;
- break;
- } else {
- Chunk *tmp;
-
- flags = 0;
- if (!strcmp(typ, "swap")) {
- type = PART_SWAP;
- strcpy(mpoint, "SWAP");
- } else {
- type = PART_FILESYSTEM;
- if (!strcmp(mpoint, "/"))
- flags |= CHUNK_IS_ROOT;
- }
- if (!sz)
- sz = space_free(c1);
- if (sz > space_free(c1)) {
- msgConfirm("Not enough free space to create partition: %s", mpoint);
- status = DITEM_FAILURE;
- break;
- }
- if (!(tmp = Create_Chunk_DWIM(d, c1, sz, part,
- (type == PART_SWAP) ? FS_SWAP : FS_BSDFFS, flags))) {
- msgConfirm("Unable to create from partition spec: %s. Too big?", cp);
- status = DITEM_FAILURE;
- break;
- } else {
- PartInfo *pi;
- pi = tmp->private_data = new_part(PART_FILESYSTEM, mpoint, TRUE);
- tmp->private_free = safe_free;
- pi->newfs_data.newfs_ufs.softupdates = soft;
- }
- }
- }
- } else {
- /* Must be something we can set a mountpoint for */
- cp = variable_get(c1->name);
- if (cp) {
- char mpoint[50], do_newfs[8];
- Boolean newfs = FALSE;
-
- do_newfs[0] = '\0';
- if (sscanf(cp, "%s %s", mpoint, do_newfs) != 2) {
- msgConfirm("For slice entry %s, got an invalid detail entry of: %s", c1->name, cp);
- status = DITEM_FAILURE;
- break;
- }
- newfs = toupper(do_newfs[0]) == 'Y' ? TRUE : FALSE;
- if (c1->private_data) {
- p = c1->private_data;
- p->do_newfs = newfs;
- strcpy(p->mountpoint, mpoint);
- }
- else {
- c1->private_data = new_part(PART_FILESYSTEM, mpoint, newfs);
- c1->private_free = safe_free;
- }
- if (!strcmp(mpoint, "/"))
- c1->flags |= CHUNK_IS_ROOT;
- else
- c1->flags &= ~CHUNK_IS_ROOT;
- }
- }
- }
- if (status == DITEM_SUCCESS)
- variable_set2(DISK_LABELLED, "yes", 0);
- return status;
-}
diff --git a/usr.sbin/sade/main.c b/usr.sbin/sade/main.c
deleted file mode 100644
index cb493f3..0000000
--- a/usr.sbin/sade/main.c
+++ /dev/null
@@ -1,123 +0,0 @@
-/*
- * $FreeBSD$
- *
- * Copyright (c) 1995
- * Jordan Hubbard. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer,
- * verbatim and that no modifications are made prior to this
- * point in the file.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY JORDAN HUBBARD ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL JORDAN HUBBARD OR HIS PETS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, LIFE OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- */
-
-#include "sade.h"
-#include <sys/signal.h>
-#include <sys/fcntl.h>
-
-const char *StartName; /* Initial contents of argv[0] */
-const char *ProgName = "sade";
-
-int
-main(int argc, char **argv)
-{
- int status;
-
- /* Record name to be able to restart */
- StartName = argv[0];
-
- signal(SIGPIPE, SIG_IGN);
-
- /* We don't work too well when running as non-root anymore */
- if (geteuid() != 0) {
- fprintf(stderr, "Error: This utility should only be run as root.\n");
- return 1;
- }
-
-#ifdef PC98
- {
- /* XXX */
- char *p = getenv("TERM");
- if (p && strcmp(p, "cons25") == 0)
- setenv("TERM", "cons25w", 1);
- }
-#endif
-
- /* Set up whatever things need setting up */
- systemInitialize(argc, argv);
-
- /* Set default flag and variable values */
- installVarDefaults(NULL);
-
- if (argc > 1 && !strcmp(argv[1], "-fake")) {
- variable_set2(VAR_DEBUG, "YES", 0);
- Fake = TRUE;
- msgConfirm("I'll be just faking it from here on out, OK?");
- }
- if (argc > 1 && !strcmp(argv[1], "-restart"))
- Restarting = TRUE;
-
- /* Try to preserve our scroll-back buffer */
- if (OnVTY) {
- int i;
-
- for (i = 0; i < 25; i++)
- putchar('\n');
- }
- /* Move stderr aside */
- if (DebugFD)
- dup2(DebugFD, 2);
-
- /* Initialize driver modules, if we haven't already done so (ie,
- the user hit Ctrl-C -> Restart. */
- if (!pvariable_get("modulesInitialize")) {
- pvariable_set("modulesInitialize=1");
- }
-
- /* Probe for all relevant devices on the system */
- deviceGetAll();
-
- /* First, see if we have any arguments to process (and argv[0] counts if it's not "sysinstall") */
-
- status = setjmp(BailOut);
- if (status) {
- msgConfirm("A signal %d was caught - I'm saving what I can and shutting\n"
- "down. If you can reproduce the problem, please turn Debug on\n"
- "in the Options menu for the extra information it provides\n"
- "in debugging problems like this.", status);
- ;
- }
-
- /* Begin user dialog at outer menu */
- dlg_clear();
- while (1) {
- dmenuOpen(&MenuMain);
- if (getpid() != 1
- || !msgNoYes("Are you sure you wish to exit?")
- )
- break;
- }
-
- /* Shut down curses */
- endwin();
-
- return 0;
-}
diff --git a/usr.sbin/sade/menus.c b/usr.sbin/sade/menus.c
deleted file mode 100644
index 886f80c..0000000
--- a/usr.sbin/sade/menus.c
+++ /dev/null
@@ -1,109 +0,0 @@
-/*
- * Copyright (c) 1995
- * Jordan Hubbard. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer,
- * verbatim and that no modifications are made prior to this
- * point in the file.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY JORDAN HUBBARD ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL JORDAN HUBBARD OR HIS PETS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, LIFE OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- */
-
-#ifndef lint
-static const char rcsid[] =
- "$FreeBSD$";
-#endif
-
-#include "sade.h"
-
-/* All the system menus go here.
- *
- * Hardcoded things like version number strings will disappear from
- * these menus just as soon as I add the code for doing inline variable
- * expansion.
- */
-
-DMenu MenuDiskDevices = {
- DMENU_NORMAL_TYPE | DMENU_SELECTION_RETURNS,
- "Select Drive(s)",
- "Please select the drive on which you wish to perform this\n"
- "operation. If you are attempting to install a boot partition\n"
- "on a drive other than the first one or have multiple operating\n"
- "systems on your machine, you will have the option to install a boot\n"
- "manager later. To select a drive, use the arrow keys to move to it\n"
- "and press [SPACE] or [ENTER].\n\n"
- "Use [TAB] to get to the buttons and leave this menu.",
- "Press F1 for important information regarding disk geometry!",
- "drives",
- { { NULL, NULL, NULL } },
-};
-
-DMenu MenuMain = {
- DMENU_NORMAL_TYPE,
- "Disklabel and partitioning utility",
- "This is a utility for partitioning and/or labelling your disks.",
- "DISKUTIL",
- "main",
- {
-#ifdef WITH_SLICES
- { "1 Partition", "Managing disk partitions", diskPartitionEditor },
-#endif
- { "2 Label", "Label allocated disk partitions", diskLabelEditor },
- { NULL, NULL, NULL }
- },
-};
-
-#if defined(__i386__) || defined(__amd64__)
-#ifdef PC98
-/* IPL type menu */
-DMenu MenuIPLType = {
- DMENU_RADIO_TYPE | DMENU_SELECTION_RETURNS,
- "overwrite me", /* will be disk specific label */
- "If you want a FreeBSD Boot Manager, select \"BootMgr\". If you would\n"
- "prefer your Boot Manager to remain untouched then select \"None\".\n\n",
- "Press F1 to read about drive setup",
- "drives",
- { { "BootMgr", "Install the FreeBSD Boot Manager", NULL },
- { "None", "Leave the IPL untouched", NULL },
- { NULL, NULL, NULL } },
-};
-#else
-/* MBR type menu */
-DMenu MenuMBRType = {
- DMENU_RADIO_TYPE | DMENU_SELECTION_RETURNS,
- "overwrite me", /* will be disk specific label */
- "FreeBSD comes with a boot manager that allows you to easily\n"
- "select between FreeBSD and any other operating systems on your machine\n"
- "at boot time. If you have more than one drive and want to boot\n"
- "from the second one, the boot manager will also make it possible\n"
- "to do so (limitations in the PC BIOS usually prevent this otherwise).\n"
- "If you have other operating systems installed and would like a choice when\n"
- "booting, choose \"BootMgr\". If you would prefer to keep your existing\n"
- "boot manager, select \"None\".\n",
- "",
- "drives",
- { { "Standard", "Install a standard MBR (non-interactive boot manager)", NULL },
- { "BootMgr", "Install the FreeBSD boot manager", NULL },
- { "None", "Do not install a boot manager", NULL },
- { NULL, NULL, NULL } }
-};
-#endif /* PC98 */
-#endif /* __i386__ */
diff --git a/usr.sbin/sade/misc.c b/usr.sbin/sade/misc.c
deleted file mode 100644
index 3279e63..0000000
--- a/usr.sbin/sade/misc.c
+++ /dev/null
@@ -1,426 +0,0 @@
-/*
- * Miscellaneous support routines..
- *
- * $FreeBSD$
- *
- * Copyright (c) 1995
- * Jordan Hubbard. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer,
- * verbatim and that no modifications are made prior to this
- * point in the file.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY JORDAN HUBBARD ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL JORDAN HUBBARD OR HIS PETS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, LIFE OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- */
-
-#include <ctype.h>
-#include <unistd.h>
-#include <sys/stat.h>
-#include <sys/errno.h>
-#include <sys/file.h>
-#include <sys/types.h>
-#include <dirent.h>
-#include <sys/wait.h>
-#include <sys/param.h>
-#include <sys/mount.h>
-#include <ufs/ufs/ufsmount.h>
-#include <sys/reboot.h>
-#include <sys/disklabel.h>
-#include <fs/msdosfs/msdosfsmount.h>
-
-#include "sade.h"
-
-/* Quick check to see if a file is readable */
-Boolean
-file_readable(char *fname)
-{
- if (!access(fname, F_OK))
- return TRUE;
- return FALSE;
-}
-
-/* sane strncpy() function */
-char *
-sstrncpy(char *dst, const char *src, int size)
-{
- dst[size] = '\0';
- return strncpy(dst, src, size);
-}
-
-/* Clip the whitespace off the end of a string */
-char *
-string_prune(char *str)
-{
- int len = str ? strlen(str) : 0;
-
- while (len && isspace(str[len - 1]))
- str[--len] = '\0';
- return str;
-}
-
-/* run the whitespace off the front of a string */
-char *
-string_skipwhite(char *str)
-{
- while (*str && isspace(*str))
- ++str;
- return str;
-}
-
-Boolean
-directory_exists(const char *dirname)
-{
- DIR *tptr;
-
- if (!dirname)
- return FALSE;
- if (!strlen(dirname))
- return FALSE;
-
- tptr = opendir(dirname);
- if (!tptr)
- return (FALSE);
-
- closedir(tptr);
- return (TRUE);
-}
-
-/* A free guaranteed to take NULL ptrs */
-void
-safe_free(void *ptr)
-{
- if (ptr)
- free(ptr);
-}
-
-/* A malloc that checks errors */
-void *
-safe_malloc(size_t size)
-{
- void *ptr;
-
- if (size <= 0)
- msgFatal("Invalid malloc size of %ld!", (long)size);
- ptr = malloc(size);
- if (!ptr)
- msgFatal("Out of memory!");
- bzero(ptr, size);
- return ptr;
-}
-
-int
-Mkdir(char *ipath)
-{
- struct stat sb;
- int final;
- char *p, *path;
-
- if (file_readable(ipath) || Fake)
- return DITEM_SUCCESS;
-
- path = strcpy(alloca(strlen(ipath) + 1), ipath);
- if (isDebug())
- msgDebug("mkdir(%s)\n", path);
- p = path;
- if (p[0] == '/') /* Skip leading '/'. */
- ++p;
- for (final = FALSE; !final; ++p) {
- if (p[0] == '\0' || (p[0] == '/' && p[1] == '\0'))
- final = TRUE;
- else if (p[0] != '/')
- continue;
- *p = '\0';
- if (stat(path, &sb)) {
- if (errno != ENOENT) {
- msgConfirm("Couldn't stat directory %s: %s", path, strerror(errno));
- return DITEM_FAILURE;
- }
- if (isDebug())
- msgDebug("mkdir(%s..)\n", path);
- if (mkdir(path, S_IRWXU | S_IRWXG | S_IRWXO) < 0) {
- msgConfirm("Couldn't create directory %s: %s", path,strerror(errno));
- return DITEM_FAILURE;
- }
- }
- *p = '/';
- }
- return DITEM_SUCCESS;
-}
-
-int
-Mount(char *mountp, void *dev)
-{
- struct ufs_args ufsargs;
- char device[80];
- char mountpoint[FILENAME_MAX];
-
- if (Fake)
- return DITEM_SUCCESS;
-
- if (*((char *)dev) != '/') {
- sprintf(device, "/dev/%s", (char *)dev);
- sprintf(mountpoint, "%s", mountp);
- }
- else {
- strcpy(device, dev);
- strcpy(mountpoint, mountp);
- }
- memset(&ufsargs,0,sizeof ufsargs);
-
- if (Mkdir(mountpoint)) {
- msgConfirm("Unable to make directory mountpoint for %s!", mountpoint);
- return DITEM_FAILURE;
- }
- if (isDebug())
- msgDebug("mount %s %s\n", device, mountpoint);
-
- ufsargs.fspec = device;
- if (mount("ufs", mountpoint, 0,
- (caddr_t)&ufsargs) == -1) {
- msgConfirm("Error mounting %s on %s : %s", device, mountpoint, strerror(errno));
- return DITEM_FAILURE;
- }
- return DITEM_SUCCESS;
-}
-
-WINDOW *
-savescr(void)
-{
- WINDOW *w;
-
- w = dupwin(newscr);
- return w;
-}
-
-void
-restorescr(WINDOW *w)
-{
- touchwin(w);
- wrefresh(w);
- delwin(w);
-}
-
-static int
-xdialog_count_rows(const char *p)
-{
- int rows = 0;
-
- while ((p = strchr(p, '\n')) != NULL) {
- p++;
- if (*p == '\0')
- break;
- rows++;
- }
-
- return rows ? rows : 1;
-}
-
-static int
-xdialog_count_columns(const char *p)
-{
- int len;
- int max_len = 0;
- const char *q;
-
- for (; (q = strchr(p, '\n')) != NULL; p = q + 1) {
- len = q - p;
- max_len = MAX(max_len, len);
- }
-
- len = strlen(p);
- max_len = MAX(max_len, len);
- return max_len;
-}
-
-int
-xdialog_menu(const char *title, const char *cprompt, int height, int width,
- int menu_height, int item_no, dialogMenuItem *ditems)
-{
- int i, result, choice = 0;
- DIALOG_LISTITEM *listitems;
- DIALOG_VARS save_vars;
-
- dlg_save_vars(&save_vars);
-
- /* initialize list items */
- listitems = dlg_calloc(DIALOG_LISTITEM, item_no + 1);
- assert_ptr(listitems, "xdialog_menu");
- for (i = 0; i < item_no; i++) {
- listitems[i].name = ditems[i].prompt;
- listitems[i].text = ditems[i].title;
- }
-
- /* calculate height */
- if (height < 0)
- height = xdialog_count_rows(cprompt) + menu_height + 4 + 2;
- if (height > LINES)
- height = LINES;
-
- /* calculate width */
- if (width < 0) {
- int tag_x = 0;
-
- for (i = 0; i < item_no; i++) {
- int j, l;
-
- l = strlen(listitems[i].name);
- for (j = 0; j < item_no; j++) {
- int k = strlen(listitems[j].text);
- tag_x = MAX(tag_x, l + k + 2);
- }
- }
- width = MAX(xdialog_count_columns(cprompt), title != NULL ? xdialog_count_columns(title) : 0);
- width = MAX(width, tag_x + 4) + 4;
- }
- width = MAX(width, 24);
- if (width > COLS)
- width = COLS;
-
- /* show menu */
- dialog_vars.default_item = listitems[choice].name;
- result = dlg_menu(title, cprompt, height, width,
- menu_height, item_no, listitems, &choice, NULL);
- switch (result) {
- case DLG_EXIT_ESC:
- result = -1;
- break;
- case DLG_EXIT_OK:
- if (ditems[choice].fire != NULL) {
- int status;
- WINDOW *save;
-
- save = savescr();
- status = ditems[choice].fire(ditems + choice);
- restorescr(save);
- }
- result = 0;
- break;
- case DLG_EXIT_CANCEL:
- default:
- result = 1;
- break;
- }
-
- free(listitems);
- dlg_restore_vars(&save_vars);
- return result;
-}
-
-int
-xdialog_radiolist(const char *title, const char *cprompt, int height, int width,
- int menu_height, int item_no, dialogMenuItem *ditems)
-{
- int i, result, choice = 0;
- DIALOG_LISTITEM *listitems;
- DIALOG_VARS save_vars;
-
- dlg_save_vars(&save_vars);
-
- /* initialize list items */
- listitems = dlg_calloc(DIALOG_LISTITEM, item_no + 1);
- assert_ptr(listitems, "xdialog_menu");
- for (i = 0; i < item_no; i++) {
- listitems[i].name = ditems[i].prompt;
- listitems[i].text = ditems[i].title;
- listitems[i].state = i == choice;
- }
-
- /* calculate height */
- if (height < 0)
- height = xdialog_count_rows(cprompt) + menu_height + 4 + 2;
- if (height > LINES)
- height = LINES;
-
- /* calculate width */
- if (width < 0) {
- int check_x = 0;
-
- for (i = 0; i < item_no; i++) {
- int j, l;
-
- l = strlen(listitems[i].name);
- for (j = 0; j < item_no; j++) {
- int k = strlen(listitems[j].text);
- check_x = MAX(check_x, l + k + 6);
- }
- }
- width = MAX(xdialog_count_columns(cprompt), title != NULL ? xdialog_count_columns(title) : 0);
- width = MAX(width, check_x + 4) + 4;
- }
- width = MAX(width, 24);
- if (width > COLS)
- width = COLS;
-
- /* show menu */
- dialog_vars.default_item = listitems[choice].name;
- result = dlg_checklist(title, cprompt, height, width,
- menu_height, item_no, listitems, NULL, FLAG_RADIO, &choice);
- switch (result) {
- case DLG_EXIT_ESC:
- result = -1;
- break;
- case DLG_EXIT_OK:
- if (ditems[choice].fire != NULL) {
- int status;
- WINDOW *save;
-
- save = savescr();
- status = ditems[choice].fire(ditems + choice);
- restorescr(save);
- }
- result = 0;
- break;
- case DLG_EXIT_CANCEL:
- default:
- result = 1;
- break;
- }
-
- /* save result */
- if (result == 0)
- dlg_add_result(listitems[choice].name);
- free(listitems);
- dlg_restore_vars(&save_vars);
- return result;
-}
-
-int
-xdialog_msgbox(const char *title, const char *cprompt,
- int height, int width, int pauseopt)
-{
- /* calculate height */
- if (height < 0)
- height = 2 + xdialog_count_rows(cprompt) + 2 + !!pauseopt;
- if (height > LINES)
- height = LINES;
-
- /* calculate width */
- if (width < 0) {
- width = title != NULL ? xdialog_count_columns(title) : 0;
- width = MAX(width, xdialog_count_columns(cprompt)) + 4;
- }
- if (pauseopt)
- width = MAX(width, 10);
- if (width > COLS)
- width = COLS;
-
- return dialog_msgbox(title, cprompt, height, width, pauseopt);
-}
diff --git a/usr.sbin/sade/msg.c b/usr.sbin/sade/msg.c
deleted file mode 100644
index fb3368e..0000000
--- a/usr.sbin/sade/msg.c
+++ /dev/null
@@ -1,357 +0,0 @@
-/*
- * $FreeBSD$
- *
- * Copyright (c) 1995
- * Jordan Hubbard. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer,
- * verbatim and that no modifications are made prior to this
- * point in the file.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY JORDAN HUBBARD ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL JORDAN HUBBARD OR HIS PETS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, LIFE OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- */
-
-#include "sade.h"
-#include <stdarg.h>
-#include <sys/ioctl.h>
-#include <sys/consio.h>
-
-Boolean
-isDebug(void)
-{
- char *cp;
-
- return (cp = variable_get(VAR_DEBUG)) && strcmp(cp, "no");
-}
-
-/* Whack up an informational message on the status line, in stand-out */
-void
-msgYap(const char *fmt, ...)
-{
- va_list args;
- char *errstr;
- int attrs;
-
- errstr = (char *)alloca(FILENAME_MAX);
- va_start(args, fmt);
- vsnprintf(errstr, FILENAME_MAX, fmt, args);
- va_end(args);
- attrs = getattrs(stdscr);
- attrset(A_REVERSE);
- mvaddstr(StatusLine, 0, errstr);
- attrset(attrs);
- refresh();
-}
-
-/* Whack up an informational message on the status line */
-void
-msgInfo(const char *fmt, ...)
-{
- va_list args;
- char *errstr;
- int i, attrs;
- char line[81];
-
- attrs = getattrs(stdscr);
- /* NULL is a special convention meaning "erase the old stuff" */
- if (!fmt) {
- move(StatusLine, 0);
- clrtoeol();
- return;
- }
- errstr = (char *)alloca(FILENAME_MAX);
- va_start(args, fmt);
- vsnprintf(errstr, FILENAME_MAX, fmt, args);
- va_end(args);
- memset(line, ' ', 80);
- for (i = 0; i < 80; i++) {
- if (errstr[i])
- line[i] = errstr[i];
- else
- break;
- }
- line[80] = '\0';
- attrset(ATTR_TITLE);
- mvaddstr(StatusLine, 0, line);
- attrset(attrs);
- move(StatusLine, 79);
- refresh();
-}
-
-/* Whack up a warning on the status line */
-void
-msgWarn(const char *fmt, ...)
-{
- va_list args;
- char *errstr;
- int attrs;
-
- errstr = (char *)alloca(FILENAME_MAX);
- strcpy(errstr, "Warning: ");
- va_start(args, fmt);
- vsnprintf((char *)(errstr + strlen(errstr)), FILENAME_MAX, fmt, args);
- va_end(args);
- attrs = getattrs(stdscr);
- beep();
- attrset(ATTR_TITLE);
- mvaddstr(StatusLine, 0, errstr);
- attrset(attrs);
- refresh();
- if (OnVTY && isDebug())
- msgDebug("Warning message `%s'\n", errstr);
-}
-
-/* Whack up an error on the status line */
-void
-msgError(const char *fmt, ...)
-{
- va_list args;
- char *errstr;
- int attrs;
-
- errstr = (char *)alloca(FILENAME_MAX);
- strcpy(errstr, "Error: ");
- va_start(args, fmt);
- vsnprintf((char *)(errstr + strlen(errstr)), FILENAME_MAX, fmt, args);
- va_end(args);
- beep();
- attrs = getattrs(stdscr);
- attrset(ATTR_TITLE);
- mvaddstr(StatusLine, 0, errstr);
- attrset(attrs);
- refresh();
- if (OnVTY && isDebug())
- msgDebug("Error message `%s'\n", errstr);
-}
-
-/* Whack up a fatal error on the status line */
-void
-msgFatal(const char *fmt, ...)
-{
- va_list args;
- char *errstr;
- int attrs;
-
- errstr = (char *)alloca(FILENAME_MAX);
- strcpy(errstr, "Fatal Error: ");
- va_start(args, fmt);
- vsnprintf((char *)(errstr + strlen(errstr)), FILENAME_MAX, fmt, args);
- va_end(args);
- beep();
- attrs = getattrs(stdscr);
- attrset(ATTR_TITLE);
- mvaddstr(StatusLine, 0, errstr);
- addstr(" - ");
- addstr("PRESS ANY KEY TO ");
- if (getpid() == 1)
- addstr("REBOOT");
- else
- addstr("QUIT");
- attrset(attrs);
- refresh();
- if (OnVTY)
- msgDebug("Fatal error `%s'!\n", errstr);
- getch();
-}
-
-/* Put up a message in a popup confirmation box */
-void
-msgConfirm(const char *fmt, ...)
-{
- va_list args;
- char *errstr;
- WINDOW *w = savescr();
-
- errstr = (char *)alloca(FILENAME_MAX);
- va_start(args, fmt);
- vsnprintf(errstr, FILENAME_MAX, fmt, args);
- va_end(args);
- dialog_vars.help_line = NULL;
- dialog_vars.help_file = NULL;
- if (OnVTY) {
- ioctl(0, VT_ACTIVATE, 1);
- msgInfo(NULL);
- }
- dialog_vars.help_line = "Press Enter or Space";
- xdialog_msgbox("Message", errstr, -1, -1, 1);
- dialog_vars.help_line = NULL;
-
- restorescr(w);
-}
-
-/* Put up a message in a popup information box */
-void
-msgNotify(const char *fmt, ...)
-{
- va_list args;
- char *errstr;
-
- errstr = (char *)alloca(FILENAME_MAX);
- va_start(args, fmt);
- vsnprintf(errstr, FILENAME_MAX, fmt, args);
- va_end(args);
- dialog_vars.help_line = NULL;
- dialog_vars.help_file = NULL;
- if (isDebug())
- msgDebug("Notify: %s\n", errstr);
- xdialog_msgbox(NULL, errstr, -1, -1, 0);
-}
-
-/* Put up a message in a popup yes/no box and return 0 for YES, 1 for NO */
-int
-msgYesNo(const char *fmt, ...)
-{
- va_list args;
- char *errstr;
- int ret;
- WINDOW *w = savescr();
-
- errstr = (char *)alloca(FILENAME_MAX);
- va_start(args, fmt);
- vsnprintf(errstr, FILENAME_MAX, fmt, args);
- va_end(args);
- dialog_vars.help_line = NULL;
- dialog_vars.help_file = NULL;
- if (OnVTY) {
- ioctl(0, VT_ACTIVATE, 1); /* Switch back */
- msgInfo(NULL);
- }
- if (variable_get(VAR_NONINTERACTIVE))
- return 0; /* If non-interactive, return YES all the time */
- ret = dialog_yesno("User Confirmation Requested", errstr, -1, -1);
- restorescr(w);
- return ret;
-}
-
-/* Put up a message in a popup no/yes box and return 0 for YES, 1 for NO */
-int
-msgNoYes(const char *fmt, ...)
-{
- va_list args;
- char *errstr;
- int ret;
- WINDOW *w = savescr();
- DIALOG_VARS save_vars;
-
- errstr = (char *)alloca(FILENAME_MAX);
- va_start(args, fmt);
- vsnprintf(errstr, FILENAME_MAX, fmt, args);
- va_end(args);
- dialog_vars.help_line = NULL;
- dialog_vars.help_file = NULL;
- if (OnVTY) {
- ioctl(0, VT_ACTIVATE, 1); /* Switch back */
- msgInfo(NULL);
- }
- if (variable_get(VAR_NONINTERACTIVE))
- return 1; /* If non-interactive, return NO all the time */
- dlg_save_vars(&save_vars);
- dialog_vars.defaultno = TRUE;
- ret = dialog_yesno("User Confirmation Requested", errstr, -1, -1);
- dlg_restore_vars(&save_vars);
- restorescr(w);
- return ret;
-}
-
-/* Put up a message in an input box and return the value */
-char *
-msgGetInput(char *buf, const char *fmt, ...)
-{
- va_list args;
- char *errstr;
- static char input_buffer[256];
- int rval;
- WINDOW *w = savescr();
-
- errstr = (char *)alloca(FILENAME_MAX);
- va_start(args, fmt);
- vsnprintf(errstr, FILENAME_MAX, fmt, args);
- va_end(args);
- dialog_vars.help_line = NULL;
- dialog_vars.help_file = NULL;
- if (buf)
- SAFE_STRCPY(input_buffer, buf);
- else
- input_buffer[0] = '\0';
- if (OnVTY) {
- ioctl(0, VT_ACTIVATE, 1); /* Switch back */
- msgInfo(NULL);
- }
- rval = dialog_inputbox("Value Required", errstr, -1, -1, input_buffer, 0);
- restorescr(w);
- if (!rval)
- return dialog_vars.input_result;
- else
- return NULL;
-}
-
-/* Write something to the debugging port */
-void
-msgDebug(const char *fmt, ...)
-{
- va_list args;
- char *dbg;
-
- if (DebugFD == -1)
- return;
- dbg = (char *)alloca(FILENAME_MAX);
- strcpy(dbg, "DEBUG: ");
- va_start(args, fmt);
- vsnprintf((char *)(dbg + strlen(dbg)), FILENAME_MAX, fmt, args);
- va_end(args);
- write(DebugFD, dbg, strlen(dbg));
-}
-
-/* Tell the user there's some output to go look at */
-void
-msgWeHaveOutput(const char *fmt, ...)
-{
- va_list args;
- char *errstr;
- WINDOW *w = savescr();
-
- errstr = (char *)alloca(FILENAME_MAX);
- va_start(args, fmt);
- vsnprintf(errstr, FILENAME_MAX, fmt, args);
- va_end(args);
- dialog_vars.help_line = NULL;
- dialog_vars.help_file = NULL;
- msgDebug("Notify: %s\n", errstr);
- dlg_clear();
- sleep(2);
- xdialog_msgbox(NULL, errstr, -1, -1, 0);
- restorescr(w);
-}
-
-/* Simple versions of msgConfirm() and msgNotify() for calling from scripts */
-int
-msgSimpleConfirm(const char *str)
-{
- msgConfirm("%s", str);
- return DITEM_SUCCESS;
-}
-
-int
-msgSimpleNotify(const char *str)
-{
- msgNotify("%s", str);
- return DITEM_SUCCESS;
-}
diff --git a/usr.sbin/sade/sade.h b/usr.sbin/sade/sade.h
deleted file mode 100644
index 3e163ad..0000000
--- a/usr.sbin/sade/sade.h
+++ /dev/null
@@ -1,465 +0,0 @@
-/*
- * Copyright (c) 1995
- * Jordan Hubbard. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer,
- * verbatim and that no modifications are made prior to this
- * point in the file.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY JORDAN HUBBARD ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL JORDAN HUBBARD OR HIS PETS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, LIFE OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- * $FreeBSD$
- */
-
-#ifndef _SADE_H_INCLUDE
-#define _SADE_H_INCLUDE
-
-#include <sys/types.h>
-#include <sys/wait.h>
-#include <errno.h>
-#include <setjmp.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <unistd.h>
-#include <dialog.h>
-
-/*** Defines ***/
-
-#if defined(__i386__) || defined(__amd64__)
-#define WITH_SYSCONS
-#define WITH_MICE
-#endif
-
-#if defined(__i386__) || defined(__amd64__)
-#define WITH_SLICES
-#endif
-
-#if defined(__i386__)
-#define WITH_LINUX
-#endif
-
-/* device limits */
-#define DEV_NAME_MAX 128 /* The maximum length of a device name */
-#define DEV_MAX 100 /* The maximum number of devices we'll deal with */
-#define IO_ERROR -2 /* Status code for I/O error rather than normal EOF */
-
-/*
- * I make some pretty gross assumptions about having a max of 50 chunks
- * total - 8 slices and 42 partitions. I can't easily display many more
- * than that on the screen at once!
- *
- * For 2.1 I'll revisit this and try to make it more dynamic, but since
- * this will catch 99.99% of all possible cases, I'm not too worried.
- */
-#define MAX_CHUNKS 40
-
-/* Internal environment variable names */
-#define DISK_PARTITIONED "_diskPartitioned"
-#define DISK_LABELLED "_diskLabelled"
-#define DISK_SELECTED "_diskSelected"
-#define SYSTEM_STATE "_systemState"
-#define RUNNING_ON_ROOT "_runningOnRoot"
-
-/* Ones that can be tweaked from config files */
-#define VAR_BLANKTIME "blanktime"
-#define VAR_BOOTMGR "bootManager"
-#define VAR_DEBUG "debug"
-#define VAR_DISK "disk"
-#define VAR_DISKINTERACTIVE "diskInteractive"
-#define VAR_DEDICATE_DISK "dedicateDisk"
-#define VAR_COMMAND "command"
-#define VAR_CONFIG_FILE "configFile"
-#define VAR_GEOMETRY "geometry"
-#define VAR_INSTALL_CFG "installConfig"
-#define VAR_INSTALL_ROOT "installRoot"
-#define VAR_LABEL "label"
-#define VAR_LABEL_COUNT "labelCount"
-#define VAR_NEWFS_ARGS "newfsArgs"
-#define VAR_NO_CONFIRM "noConfirm"
-#define VAR_NO_ERROR "noError"
-#define VAR_NO_WARN "noWarn"
-#define VAR_NO_USR "noUsr"
-#define VAR_NO_TMP "noTmp"
-#define VAR_NO_HOME "noHome"
-#define VAR_NONINTERACTIVE "nonInteractive"
-#define VAR_PARTITION "partition"
-#define VAR_RELNAME "releaseName"
-#define VAR_ROOT_SIZE "rootSize"
-#define VAR_SWAP_SIZE "swapSize"
-#define VAR_TAPE_BLOCKSIZE "tapeBlocksize"
-#define VAR_UFS_PATH "ufs"
-#define VAR_USR_SIZE "usrSize"
-#define VAR_VAR_SIZE "varSize"
-#define VAR_TMP_SIZE "tmpSize"
-#define VAR_TERM "TERM"
-#define VAR_CONSTERM "_consterm"
-
-#define DEFAULT_TAPE_BLOCKSIZE "20"
-
-/* One MB worth of blocks */
-#define ONE_MEG 2048
-#define ONE_GIG (ONE_MEG * 1024)
-
-/* Which selection attributes to use */
-#define ATTR_SELECTED (ColorDisplay ? item_selected_attr : item_attr)
-#define ATTR_TITLE button_active_attr
-
-/* Handy strncpy() macro */
-#define SAFE_STRCPY(to, from) sstrncpy((to), (from), sizeof (to) - 1)
-
-/*** Types ***/
-typedef int Boolean;
-typedef struct disk Disk;
-typedef struct chunk Chunk;
-
-/* special return codes for `fire' actions */
-#define DITEM_STATUS(flag) ((flag) & 0x0000FFFF)
-#define DITEM_SUCCESS 0
-#define DITEM_FAILURE 1
-
-/* flags - returned in upper 16 bits of return status */
-#define DITEM_LEAVE_MENU (1 << 16)
-#define DITEM_RESTORE (1 << 19)
-
-/* for use in describing more exotic behaviors */
-typedef struct _dmenu_item {
- char *prompt;
- char *title;
- int (*fire)(struct _dmenu_item *self);
-} dialogMenuItem;
-
-/* Bitfields for menu options */
-#define DMENU_NORMAL_TYPE 0x1 /* Normal dialog menu */
-#define DMENU_RADIO_TYPE 0x2 /* Radio dialog menu */
-#define DMENU_SELECTION_RETURNS 0x8 /* Immediate return on item selection */
-
-typedef struct _dmenu {
- int type; /* What sort of menu we are */
- char *title; /* Our title */
- char *prompt; /* Our prompt */
- char *helpline; /* Line of help at bottom */
- char *helpfile; /* Help file for "F1" */
- dialogMenuItem items[]; /* Array of menu items */
-} DMenu;
-
-/* An rc.conf variable */
-typedef struct _variable {
- struct _variable *next;
- char *name;
- char *value;
- int dirty;
-} Variable;
-
-#define NO_ECHO_OBJ(type) ((type) | (DITEM_NO_ECHO << 16))
-#define TYPE_OF_OBJ(type) ((type) & 0xff)
-#define ATTR_OF_OBJ(type) ((type) >> 16)
-
-/* A screen layout structure */
-typedef struct _layout {
- int y; /* x & Y co-ordinates */
- int x;
- int len; /* The size of the dialog on the screen */
- int maxlen; /* How much the user can type in ... */
- char *prompt; /* The string for the prompt */
- char *help; /* The display for the help line */
- void *var; /* The var to set when this changes */
- int type; /* The type of the dialog to create */
- void *obj; /* The obj pointer returned by libdialog */
-} Layout;
-
-typedef enum {
- DEVICE_TYPE_NONE,
- DEVICE_TYPE_DISK,
- DEVICE_TYPE_DOS,
- DEVICE_TYPE_UFS,
- DEVICE_TYPE_ANY,
-} DeviceType;
-
-/* A "device" from sade's point of view */
-typedef struct _device {
- char name[DEV_NAME_MAX];
- char *description;
- char *devname;
- DeviceType type;
- Boolean (*init)(struct _device *dev);
- FILE * (*get)(struct _device *dev, char *file, Boolean probe);
- void (*shutdown)(struct _device *dev);
- void *private;
- unsigned int flags;
- unsigned int volume;
-} Device;
-
-/* Some internal representations of partitions */
-typedef enum {
- PART_NONE,
- PART_SLICE,
- PART_SWAP,
- PART_FILESYSTEM,
- PART_FAT,
- PART_EFI
-} PartType;
-
-#define NEWFS_UFS_CMD "newfs"
-#define NEWFS_MSDOS_CMD "newfs_msdos"
-
-enum newfs_type { NEWFS_UFS, NEWFS_MSDOS, NEWFS_CUSTOM };
-#define NEWFS_UFS_STRING "UFS"
-#define NEWFS_MSDOS_STRING "FAT"
-#define NEWFS_CUSTOM_STRING "CST"
-
-/* The longest set of custom command line arguments we'll pass. */
-#define NEWFS_CMD_ARGS_MAX 256
-
-typedef struct _part_info {
- char mountpoint[FILENAME_MAX];
-
- /* Is invocation of newfs desired? */
- Boolean do_newfs;
-
- enum newfs_type newfs_type;
- union {
- struct {
- char user_options[NEWFS_CMD_ARGS_MAX];
- Boolean acls; /* unused */
- Boolean multilabel; /* unused */
- Boolean softupdates;
- Boolean ufs1;
- } newfs_ufs;
- struct {
- /* unused */
- } newfs_msdos;
- struct {
- char command[NEWFS_CMD_ARGS_MAX];
- } newfs_custom;
- } newfs_data;
-} PartInfo;
-
-/* An option */
-typedef struct _opt {
- char *name;
- char *desc;
- enum { OPT_IS_STRING, OPT_IS_INT, OPT_IS_FUNC, OPT_IS_VAR } type;
- void *data;
- void *aux;
- char *(*check)(void);
-} Option;
-
-typedef int (*commandFunc)(char *key, void *data);
-
-#define EXTRAS_FIELD_LEN 128
-
-/*** Externs ***/
-extern jmp_buf BailOut; /* Used to get the heck out */
-extern int DebugFD; /* Where diagnostic output goes */
-extern Boolean Fake; /* Don't actually modify anything - testing */
-extern Boolean Restarting; /* Are we restarting sysinstall? */
-extern Boolean SystemWasInstalled; /* Did we install it? */
-extern Boolean RunningAsInit; /* Are we running stand-alone? */
-extern Boolean DialogActive; /* Is the dialog() stuff up? */
-extern Boolean ColorDisplay; /* Are we on a color display? */
-extern Boolean OnVTY; /* On a syscons VTY? */
-extern Variable *VarHead; /* The head of the variable chain */
-extern int BootMgr; /* Which boot manager to use */
-extern int StatusLine; /* Where to print our status messages */
-#if defined(__i386__) || defined(__amd64__)
-#ifdef PC98
-extern DMenu MenuIPLType; /* Type of IPL to write on the disk */
-#else
-extern DMenu MenuMBRType; /* Type of MBR to write on the disk */
-#endif
-#endif
-extern DMenu MenuMain; /* New main menu */
-extern DMenu MenuDiskDevices; /* Disk type devices */
-extern const char * StartName; /* Which name we were started as */
-extern const char * ProgName; /* Program's proper name */
-
-/* Important chunks. */
-extern Chunk *HomeChunk;
-extern Chunk *RootChunk;
-extern Chunk *SwapChunk;
-extern Chunk *TmpChunk;
-extern Chunk *UsrChunk;
-extern Chunk *VarChunk;
-#ifdef __ia64__
-extern Chunk *EfiChunk;
-#endif
-
-/* Stuff from libdialog which isn't properly declared outside */
-extern void display_helpfile(void);
-extern void display_helpline(WINDOW *w, int y, int width);
-
-/*** Prototypes ***/
-
-/* command.c */
-extern void command_clear(void);
-extern void command_sort(void);
-extern void command_execute(void);
-extern void command_shell_add(char *key, const char *fmt, ...) __printflike(2, 3);
-extern void command_func_add(char *key, commandFunc func, void *data);
-
-/* devices.c */
-extern DMenu *deviceCreateMenu(DMenu *menu, DeviceType type, int (*hook)(dialogMenuItem *d));
-extern void deviceGetAll(void);
-extern void deviceReset(void);
-extern void deviceRescan(void);
-extern Device **deviceFind(char *name, DeviceType type);
-extern Device **deviceFindDescr(char *name, char *desc, DeviceType class);
-extern int deviceCount(Device **devs);
-extern Device *new_device(char *name);
-extern Device *deviceRegister(char *name, char *desc, char *devicename, DeviceType type,
- Boolean (*init)(Device *mediadev),
- FILE * (*get)(Device *dev, char *file, Boolean probe),
- void (*shutDown)(Device *mediadev),
- void *private);
-extern Boolean dummyInit(Device *dev);
-extern FILE *dummyGet(Device *dev, char *dist, Boolean probe);
-extern void dummyShutdown(Device *dev);
-
-/* disks.c */
-#ifdef WITH_SLICES
-extern void diskPartition(Device *dev);
-extern int diskPartitionEditor(dialogMenuItem *self);
-#endif
-extern int diskPartitionWrite(Device *dev);
-
-/* dispatch.c */
-extern int dispatchCommand(char *command);
-extern int dispatch_load_floppy(dialogMenuItem *self);
-extern int dispatch_load_file_int(int);
-extern int dispatch_load_file(dialogMenuItem *self);
-
-/* dmenu.c */
-extern int dmenuSetValue(dialogMenuItem *tmp);
-extern Boolean dmenuOpen(DMenu *menu);
-extern int dmenuRadioCheck(dialogMenuItem *item);
-
-/* dos.c */
-extern Boolean mediaCloseDOS(Device *dev, FILE *fp);
-extern Boolean mediaInitDOS(Device *dev);
-extern FILE *mediaGetDOS(Device *dev, char *file, Boolean probe);
-extern void mediaShutdownDOS(Device *dev);
-
-/* globals.c */
-extern void globalsInit(void);
-
-/* install.c */
-extern Boolean checkLabels(Boolean whinge);
-extern int installCommit(dialogMenuItem *self);
-extern int installCustomCommit(dialogMenuItem *self);
-extern int installFilesystems(Device *dev);
-extern int installVarDefaults(dialogMenuItem *self);
-extern void installEnvironment(void);
-extern Boolean copySelf(void);
-
-/* kget.c */
-extern int kget(char *out);
-
-/* label.c */
-extern int diskLabelEditor(dialogMenuItem *self);
-extern int diskLabelCommit(Device *dev);
-
-/* misc.c */
-extern Boolean file_readable(char *fname);
-extern Boolean directory_exists(const char *dirname);
-extern char *string_prune(char *str);
-extern char *string_skipwhite(char *str);
-extern void safe_free(void *ptr);
-extern void *safe_malloc(size_t size);
-extern int Mkdir(char *);
-extern int Mount(char *, void *data);
-
-extern WINDOW *savescr(void);
-extern void restorescr(WINDOW *w);
-extern char *sstrncpy(char *dst, const char *src, int size);
-
-extern int xdialog_menu(const char *title, const char *cprompt,
- int height, int width, int menu_height,
- int item_no, dialogMenuItem *ditems);
-extern int xdialog_radiolist(const char *title, const char *cprompt,
- int height, int width, int menu_height,
- int item_no, dialogMenuItem *ditems);
-extern int xdialog_msgbox(const char *title, const char *cprompt,
- int height, int width, int pauseopt);
-
-/* msg.c */
-extern Boolean isDebug(void);
-extern void msgInfo(const char *fmt, ...) __printf0like(1, 2);
-extern void msgYap(const char *fmt, ...) __printflike(1, 2);
-extern void msgWarn(const char *fmt, ...) __printflike(1, 2);
-extern void msgDebug(const char *fmt, ...) __printflike(1, 2);
-extern void msgError(const char *fmt, ...) __printflike(1, 2);
-extern void msgFatal(const char *fmt, ...) __printflike(1, 2);
-extern void msgConfirm(const char *fmt, ...) __printflike(1, 2);
-extern void msgNotify(const char *fmt, ...) __printflike(1, 2);
-extern void msgWeHaveOutput(const char *fmt, ...) __printflike(1, 2);
-extern int msgYesNo(const char *fmt, ...) __printflike(1, 2);
-extern int msgNoYes(const char *fmt, ...) __printflike(1, 2);
-extern char *msgGetInput(char *buf, const char *fmt, ...) __printflike(2, 3);
-extern int msgSimpleConfirm(const char *);
-extern int msgSimpleNotify(const char *);
-
-/* pccard.c */
-extern void pccardInitialize(void);
-
-/* system.c */
-extern void systemInitialize(int argc, char **argv);
-extern void systemShutdown(int status);
-extern int execExecute(char *cmd, char *name);
-extern int systemExecute(char *cmd);
-extern void systemSuspendDialog(void);
-extern void systemResumeDialog(void);
-extern int systemDisplayHelp(char *file);
-extern char *systemHelpFile(char *file, char *buf);
-extern void systemChangeFont(const u_char font[]);
-extern void systemChangeLang(char *lang);
-extern void systemChangeTerminal(char *color, const u_char c_termcap[], char *mono, const u_char m_termcap[]);
-extern void systemChangeScreenmap(const u_char newmap[]);
-extern int vsystem(const char *fmt, ...) __printflike(1, 2);
-
-/* termcap.c */
-extern int set_termcap(void);
-
-/* variable.c */
-extern void variable_set(char *var, int dirty);
-extern void variable_set2(char *name, char *value, int dirty);
-extern char *variable_get(char *var);
-extern int variable_cmp(char *var, char *value);
-extern void variable_unset(char *var);
-extern char *variable_get_value(char *var, char *prompt, int dirty);
-extern int variable_check(char *data);
-extern int variable_check2(char *data);
-extern int dump_variables(dialogMenuItem *self);
-extern void free_variables(void);
-extern void pvariable_set(char *var);
-extern char *pvariable_get(char *var);
-
-/* wizard.c */
-extern void slice_wizard(Disk *d);
-
-/*
- * Macros. Please find a better place for us!
- */
-#define DEVICE_INIT(d) ((d) != NULL ? (d)->init((d)) : (Boolean)0)
-#define DEVICE_GET(d, b, f) ((d) != NULL ? (d)->get((d), (b), (f)) : NULL)
-#define DEVICE_SHUTDOWN(d) ((d) != NULL ? (d)->shutdown((d)) : (void)0)
-
-#endif
-/* _SYSINSTALL_H_INCLUDE */
diff --git a/usr.sbin/sade/system.c b/usr.sbin/sade/system.c
deleted file mode 100644
index 1e0e52f..0000000
--- a/usr.sbin/sade/system.c
+++ /dev/null
@@ -1,304 +0,0 @@
-/*
- * $FreeBSD$
- *
- * Jordan Hubbard
- *
- * My contributions are in the public domain.
- *
- * Parts of this file are also blatently stolen from Poul-Henning Kamp's
- * previous version of sysinstall, and as such fall under his "BEERWARE license"
- * so buy him a beer if you like it! Buy him a beer for me, too!
- * Heck, get him completely drunk and send me pictures! :-)
- */
-
-#include <signal.h>
-#include <termios.h>
-#include <sys/param.h>
-#include <sys/reboot.h>
-#include <sys/consio.h>
-#include <sys/fcntl.h>
-#include <sys/ioctl.h>
-#include <sys/mount.h>
-#include <sys/stat.h>
-#include <sys/sysctl.h>
-#include <ufs/ufs/ufsmount.h>
-
-#include "sade.h"
-
-/* Where we stick our temporary expanded doc file */
-#define DOC_TMP_DIR "/tmp/.doc"
-#define DOC_TMP_FILE "/tmp/.doc/doc.tmp"
-
-/*
- * Handle interrupt signals - this probably won't work in all cases
- * due to our having bogotified the internal state of dialog or curses,
- * but we'll give it a try.
- */
-static int
-intr_continue(dialogMenuItem *self)
-{
- return DITEM_LEAVE_MENU;
-}
-
-static int
-intr_restart(dialogMenuItem *self)
-{
- int ret, fd, fdmax;
-
- free_variables();
- fdmax = getdtablesize();
- for (fd = 3; fd < fdmax; fd++)
- close(fd);
- ret = execl(StartName, StartName, "-restart", (char *)NULL);
- msgDebug("execl failed (%s)\n", strerror(errno));
- /* NOTREACHED */
- return -1;
-}
-
-static dialogMenuItem intrmenu[] = {
- { "Restart", "Restart the program", intr_restart },
- { "Continue", "Continue without restarting", intr_continue },
-};
-
-
-static void
-handle_intr(int sig)
-{
- WINDOW *save = savescr();
-
- dialog_vars.help_line = NULL;
- dialog_vars.help_file = NULL;
- if (OnVTY) {
- ioctl(0, VT_ACTIVATE, 1); /* Switch back */
- msgInfo(NULL);
- }
- (void)xdialog_menu("Installation interrupt",
- "Do you want to abort the installation?",
- -1, -1, 2, 2, intrmenu);
- restorescr(save);
-}
-
-/* Expand a file into a convenient location, nuking it each time */
-static char *
-expand(char *fname)
-{
- char *gunzip = "/usr/bin/gunzip";
-
- if (!directory_exists(DOC_TMP_DIR)) {
- Mkdir(DOC_TMP_DIR);
- if (chown(DOC_TMP_DIR, 0, 0) < 0)
- return NULL;
- if (chmod(DOC_TMP_DIR, S_IRWXU) < 0)
- return NULL;
- }
- else
- unlink(DOC_TMP_FILE);
- if (!file_readable(fname) || vsystem("%s < %s > %s", gunzip, fname, DOC_TMP_FILE))
- return NULL;
- return DOC_TMP_FILE;
-}
-
-/* Initialize system defaults */
-void
-systemInitialize(int argc, char **argv)
-{
- size_t i;
- int boothowto;
- sigset_t signalset;
-
- signal(SIGINT, SIG_IGN);
- globalsInit();
-
- i = sizeof(boothowto);
- if (!sysctlbyname("debug.boothowto", &boothowto, &i, NULL, 0) &&
- (i == sizeof(boothowto)) && (boothowto & RB_VERBOSE))
- variable_set2(VAR_DEBUG, "YES", 0);
-
- if (set_termcap() == -1) {
- printf("Can't find terminal entry\n");
- exit(-1);
- }
-
- /* XXX - libdialog has particularly bad return value checking */
- init_dialog(stdin, stdout);
-
- /* If we haven't crashed I guess dialog is running ! */
- DialogActive = TRUE;
-
- /* Make sure HOME is set for those utilities that need it */
- signal(SIGINT, handle_intr);
- /*
- * Make sure we can be interrupted even if we were re-executed
- * from an interrupt.
- */
- sigemptyset(&signalset);
- sigaddset(&signalset, SIGINT);
- sigprocmask(SIG_UNBLOCK, &signalset, NULL);
-
- (void)vsystem("rm -rf %s", DOC_TMP_DIR);
-}
-
-/* Run some general command */
-int
-systemExecute(char *command)
-{
- int status;
- struct termios foo;
- WINDOW *w = savescr();
-
- dlg_clear();
- end_dialog();
- DialogActive = FALSE;
- if (tcgetattr(0, &foo) != -1) {
- foo.c_cc[VERASE] = '\010';
- tcsetattr(0, TCSANOW, &foo);
- }
- if (!Fake)
- status = system(command);
- else {
- status = 0;
- msgDebug("systemExecute: Faked execution of `%s'\n", command);
- }
- DialogActive = TRUE;
- restorescr(w);
- return status;
-}
-
-/* suspend/resume libdialog/curses screen */
-static WINDOW *oldW;
-
-void
-systemSuspendDialog(void)
-{
-
- oldW = savescr();
- dlg_clear();
- end_dialog();
- DialogActive = FALSE;
-}
-
-void
-systemResumeDialog(void)
-{
-
- DialogActive = TRUE;
- restorescr(oldW);
-}
-
-/* Display a help file in a filebox */
-int
-systemDisplayHelp(char *file)
-{
- char *fname = NULL;
- char buf[FILENAME_MAX];
- int ret = 0;
- WINDOW *w = savescr();
-
- fname = systemHelpFile(file, buf);
- if (!fname) {
- snprintf(buf, FILENAME_MAX, "The %s file is not provided on this particular floppy image.", file);
- dialog_vars.help_line = NULL;
- dialog_vars.help_file = NULL;
- xdialog_msgbox("Sorry!", buf, -1, -1, 1);
- ret = 1;
- }
- else {
- dialog_vars.help_line = NULL;
- dialog_vars.help_file = NULL;
- dialog_textbox(file, fname, LINES, COLS);
- }
- restorescr(w);
- return ret;
-}
-
-char *
-systemHelpFile(char *file, char *buf)
-{
- if (!file)
- return NULL;
- if (file[0] == '/')
- return file;
- snprintf(buf, FILENAME_MAX, "/stand/help/%s.hlp.gz", file);
- if (file_readable(buf))
- return expand(buf);
- snprintf(buf, FILENAME_MAX, "/stand/help/%s.hlp", file);
- if (file_readable(buf))
- return expand(buf);
- snprintf(buf, FILENAME_MAX, "/stand/help/%s.TXT.gz", file);
- if (file_readable(buf))
- return expand(buf);
- snprintf(buf, FILENAME_MAX, "/stand/help/%s.TXT", file);
- if (file_readable(buf))
- return expand(buf);
- snprintf(buf, FILENAME_MAX, "/usr/src/usr.sbin/%s/help/%s.hlp", ProgName,
- file);
- if (file_readable(buf))
- return buf;
- snprintf(buf, FILENAME_MAX, "/usr/src/usr.sbin/%s/help/%s.TXT", ProgName,
- file);
- if (file_readable(buf))
- return buf;
- return NULL;
-}
-
-int
-vsystem(const char *fmt, ...)
-{
- va_list args;
- int pstat;
- pid_t pid;
- int omask;
- sig_t intsave, quitsave;
- char *cmd;
- int i;
- struct stat sb;
-
- cmd = (char *)alloca(FILENAME_MAX);
- cmd[0] = '\0';
- va_start(args, fmt);
- vsnprintf(cmd, FILENAME_MAX, fmt, args);
- va_end(args);
-
- omask = sigblock(sigmask(SIGCHLD));
- if (Fake) {
- msgDebug("vsystem: Faked execution of `%s'\n", cmd);
- return 0;
- }
- if (isDebug())
- msgDebug("Executing command `%s'\n", cmd);
- pid = fork();
- if (pid == -1) {
- (void)sigsetmask(omask);
- i = 127;
- }
- else if (!pid) { /* Junior */
- (void)sigsetmask(omask);
- if (DebugFD != -1) {
- dup2(DebugFD, 0);
- dup2(DebugFD, 1);
- dup2(DebugFD, 2);
- }
- else {
- close(1); open("/dev/null", O_WRONLY);
- dup2(1, 2);
- }
- if (stat("/stand/sh", &sb) == 0)
- execl("/stand/sh", "/stand/sh", "-c", cmd, (char *)NULL);
- else
- execl("/bin/sh", "/bin/sh", "-c", cmd, (char *)NULL);
- exit(1);
- }
- else {
- intsave = signal(SIGINT, SIG_IGN);
- quitsave = signal(SIGQUIT, SIG_IGN);
- pid = waitpid(pid, &pstat, 0);
- (void)sigsetmask(omask);
- (void)signal(SIGINT, intsave);
- (void)signal(SIGQUIT, quitsave);
- i = (pid == -1) ? -1 : WEXITSTATUS(pstat);
- if (isDebug())
- msgDebug("Command `%s' returns status of %d\n", cmd, i);
- }
- return i;
-}
-
diff --git a/usr.sbin/sade/termcap.c b/usr.sbin/sade/termcap.c
deleted file mode 100644
index 1c2f39b..0000000
--- a/usr.sbin/sade/termcap.c
+++ /dev/null
@@ -1,104 +0,0 @@
-/*
- * Copyright (c) 1994, Paul Richards.
- *
- * All rights reserved.
- *
- * This software may be used, modified, copied, distributed, and sold, in both
- * source and binary form provided that the above copyright and these terms
- * are retained, verbatim, as the first lines of this file. Under no
- * circumstances is the author responsible for the proper functioning of this
- * software, nor does the author assume any responsibility for damages
- * incurred with its use.
- *
- * $FreeBSD$
- */
-
-#include "sade.h"
-#include <stdarg.h>
-#include <fcntl.h>
-#include <sys/errno.h>
-#include <sys/ioctl.h>
-#include <sys/consio.h>
-
-#define VTY_STATUS_LINE 24
-#define TTY_STATUS_LINE 23
-
-static void
-prompt_term(char **termp)
-{
- char str[80];
-
- printf("\nPlease set your TERM variable before running this program.\n");
- printf("Defaulting to an ANSI compatible terminal - please press RETURN\n");
- fgets(str, sizeof(str), stdin); /* Just to make it interactive */
- *termp = (char *)"ansi";
-}
-
-int
-set_termcap(void)
-{
- char *term;
- int stat;
- struct winsize ws;
-
- term = getenv("TERM");
- stat = ioctl(STDERR_FILENO, GIO_COLOR, &ColorDisplay);
-
- if (isDebug())
- DebugFD = open("sade.debug", O_WRONLY|O_CREAT|O_TRUNC, 0644);
- else
- DebugFD = -1;
- if (DebugFD < 0)
- DebugFD = open("/dev/null", O_RDWR, 0);
-
- if (!OnVTY || (stat < 0)) {
- if (!term) {
- char *term;
-
- prompt_term(&term);
- if (setenv("TERM", term, 1) < 0)
- return -1;
- }
- if (DebugFD < 0)
- DebugFD = open("/dev/null", O_RDWR, 0);
- }
- else {
- int i, on;
-
- if (getpid() == 1) {
- DebugFD = open("/dev/ttyv1", O_WRONLY);
- if (DebugFD != -1) {
- on = 1;
- i = ioctl(DebugFD, TIOCCONS, (char *)&on);
- msgDebug("ioctl(%d, TIOCCONS, NULL) = %d (%s)\n",
- DebugFD, i, !i ? "success" : strerror(errno));
- }
- }
-
-#ifdef PC98
- if (!term) {
- if (setenv("TERM", "cons25w", 1) < 0)
- return -1;
- }
-#else
- if (ColorDisplay) {
- if (!term) {
- if (setenv("TERM", "xterm", 1) < 0)
- return -1;
- }
- }
- else {
- if (!term) {
- if (setenv("TERM", "vt100", 1) < 0)
- return -1;
- }
- }
-#endif
- }
- if (ioctl(0, TIOCGWINSZ, &ws) == -1) {
- msgDebug("Unable to get terminal size - errno %d\n", errno);
- ws.ws_row = 0;
- }
- StatusLine = ws.ws_row ? ws.ws_row - 1: (OnVTY ? VTY_STATUS_LINE : TTY_STATUS_LINE);
- return 0;
-}
diff --git a/usr.sbin/sade/variable.c b/usr.sbin/sade/variable.c
deleted file mode 100644
index ae3a6e0..0000000
--- a/usr.sbin/sade/variable.c
+++ /dev/null
@@ -1,324 +0,0 @@
-/*
- * $FreeBSD$
- *
- * Copyright (c) 1995
- * Jordan Hubbard. All rights reserved.
- * Copyright (c) 2001
- * Murray Stokely. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer,
- * verbatim and that no modifications are made prior to this
- * point in the file.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY JORDAN HUBBARD ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL JORDAN HUBBARD OR HIS PETS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, LIFE OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- */
-
-#include "sade.h"
-
-/* Routines for dealing with variable lists */
-
-static void
-make_variable(char *var, char *value, int dirty)
-{
- Variable *vp;
-
- /* Trim leading and trailing whitespace */
- var = string_skipwhite(string_prune(var));
-
- if (!var || !*var)
- return;
-
-
- /* Now search to see if it's already in the list */
- for (vp = VarHead; vp; vp = vp->next) {
- if (!strcmp(vp->name, var)) {
- if (vp->dirty && !dirty)
- return;
- setenv(var, value, 1);
- free(vp->value);
- vp->value = strdup(value);
- if (dirty != -1)
- vp->dirty = dirty;
- return;
- }
- }
-
- setenv(var, value, 1);
- /* No? Create a new one */
- vp = (Variable *)safe_malloc(sizeof(Variable));
- vp->name = strdup(var);
- vp->value = strdup(value);
- if (dirty == -1)
- dirty = 0;
- vp->dirty = dirty;
- vp->next = VarHead;
- VarHead = vp;
-}
-
-void
-variable_set(char *var, int dirty)
-{
- char tmp[1024], *cp;
-
- if (!var)
- msgFatal("NULL variable name & value passed.");
- else if (!*var)
- msgDebug("Warning: Zero length name & value passed to variable_set()\n");
- SAFE_STRCPY(tmp, var);
- if ((cp = strchr(tmp, '=')) == NULL)
- msgFatal("Invalid variable format: %s", var);
- *(cp++) = '\0';
- make_variable(tmp, string_skipwhite(cp), dirty);
-}
-
-void
-variable_set2(char *var, char *value, int dirty)
-{
- if (!var || !value)
- msgFatal("Null name or value passed to set_variable2(%s) = %s!",
- var ? var : "", value ? value : "");
- else if (!*var || !*value)
- msgDebug("Warning: Zero length name or value passed to variable_set2(%s) = %s\n",
- var, value);
- make_variable(var, value, dirty);
-}
-
-char *
-variable_get(char *var)
-{
- return getenv(var);
-}
-
-int
-variable_cmp(char *var, char *value)
-{
- char *val;
-
- if ((val = variable_get(var)))
- return strcmp(val, value);
- return -1;
-}
-
-void
-variable_unset(char *var)
-{
- Variable *vp;
- char name[512], *cp;
-
- if ((cp = strchr(var, '=')) != NULL)
- sstrncpy(name, var, cp - var);
- else
- SAFE_STRCPY(name, var);
- unsetenv(name);
- /* Now search to see if it's in our list, if we have one.. */
- if (!VarHead)
- return;
- else if (!VarHead->next && !strcmp(VarHead->name, name)) {
- safe_free(VarHead->name);
- safe_free(VarHead->value);
- free(VarHead);
- VarHead = NULL;
- }
- else {
- for (vp = VarHead; vp; vp = vp->next) {
- if (!strcmp(vp->name, name)) {
- Variable *save = vp->next;
-
- safe_free(vp->name);
- safe_free(vp->value);
- *vp = *save;
- safe_free(save);
- break;
- }
- }
- }
-}
-
-/* Prompt user for the name of a variable */
-char *
-variable_get_value(char *var, char *prompt, int dirty)
-{
- char *cp;
-
- cp = variable_get(var);
- if (cp && variable_get(VAR_NONINTERACTIVE))
- return cp;
- else if ((cp = msgGetInput(cp, "%s", prompt)) != NULL)
- variable_set2(var, cp, dirty);
- else
- cp = NULL;
- return cp;
-}
-
-/* Check if value passed in data (in the form "variable=value") is
- * valid, and it's status compared to the value of variable stored in
- * env
- *
- * Possible return values :
- * -3: Invalid line, the data string is NOT set as an env variable
- * -2: Invalid line, the data string is set as an env variable
- * -1: Invalid line
- * 0: Valid line, is NOT equal to env version
- * 1: Valid line, is equal to env version
- * 2: Valid line, value empty - e.g. foo=""
- * 3: Valid line, does not exist in env
-*/
-int
-variable_check2(char *data)
-{
- char *cp, *cp2, *cp3, tmp[256];
-
- if (data == NULL)
- return -1;
- SAFE_STRCPY(tmp, data);
- if ((cp = strchr(tmp, '=')) != NULL) {
- *(cp++) = '\0';
- if (*cp == '"') { /* smash quotes if present */
- ++cp;
- if ((cp3 = strchr(cp, '"')) != NULL)
- *cp3 = '\0';
- }
- else if ((cp3 = strchr(cp, ',')) != NULL)
- *cp3 = '\0';
- cp2 = variable_get(tmp);
- if (cp2 != NULL) {
- if (*cp == '\0')
- return 2;
- else
- return strcmp(cp, cp2) == 0 ? 1 : 0;
- }
- else
- return 3;
- }
- else
- return variable_get(tmp) != NULL ? -2 : -3;
-}
-
-/* Check if the value passed in data (in the form "variable=value") is
- equal to the value of variable stored in env */
-int
-variable_check(char *data)
-{
- int ret;
- ret = variable_check2(data);
-
- switch(ret) {
- case -2:
- case 1:
- case 2:
- return TRUE;
- /* NOT REACHED */
- default:
- return FALSE;
- }
-}
-
-int
-dump_variables(dialogMenuItem *unused)
-{
- FILE *fp;
- Variable *vp;
-
- if (isDebug())
- msgDebug("Writing %s variables to file..\n", ProgName);
-
- fp = fopen("/etc/sade.vars", "w");
- if (!fp) {
- msgConfirm("Unable to write to /etc/%s.vars: %s",
- ProgName, strerror(errno));
- return DITEM_FAILURE;
- }
-
- for (vp = VarHead; vp; vp = vp->next)
- fprintf(fp, "%s=\"%s\" (%d)\n", vp->name, vp->value, vp->dirty);
-
- fclose(fp);
-
- return DITEM_SUCCESS;
-}
-
-/* Free all of the variables, useful to really start over as when the
- user selects "restart" from the interrupt menu. */
-void
-free_variables(void)
-{
- Variable *vp;
-
- /* Free the variables from our list, if we have one.. */
- if (!VarHead)
- return;
- else if (!VarHead->next) {
- unsetenv(VarHead->name);
- safe_free(VarHead->name);
- safe_free(VarHead->value);
- free(VarHead);
- VarHead = NULL;
- }
- else {
- for (vp = VarHead; vp; ) {
- Variable *save = vp;
- unsetenv(vp->name);
- safe_free(vp->name);
- safe_free(vp->value);
- vp = vp->next;
- safe_free(save);
- }
- VarHead = NULL;
- }
-}
-
-/*
- * Persistent variables. The variables modified by these functions
- * are not cleared between invocations of sysinstall. This is useful
- * to allow the user to completely restart sysinstall, without having
- * it load all of the modules again from the installation media which
- * are still in memory.
- */
-
-void
-pvariable_set(char *var)
-{
- char *p;
- char tmp[1024];
-
- if (!var)
- msgFatal("NULL variable name & value passed.");
- else if (!*var)
- msgDebug("Warning: Zero length name & value passed to variable_set()\n");
- /* Add a trivial namespace to whatever name the caller chooses. */
- SAFE_STRCPY(tmp, "SYSINSTALL_PVAR");
- if (strchr(var, '=') == NULL)
- msgFatal("Invalid variable format: %s", var);
- strlcat(tmp, var, 1024);
- p = strchr(tmp, '=');
- *p = '\0';
- setenv(tmp, p + 1, 1);
-}
-
-char *
-pvariable_get(char *var)
-{
- char tmp[1024];
-
- SAFE_STRCPY(tmp, "SYSINSTALL_PVAR");
- strlcat(tmp, var, 1024);
- return getenv(tmp);
-}
diff --git a/usr.sbin/sade/wizard.c b/usr.sbin/sade/wizard.c
deleted file mode 100644
index 5edd872..0000000
--- a/usr.sbin/sade/wizard.c
+++ /dev/null
@@ -1,200 +0,0 @@
-/*
- * ----------------------------------------------------------------------------
- * "THE BEER-WARE LICENSE" (Revision 42):
- * <phk@FreeBSD.org> 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
- * ----------------------------------------------------------------------------
- *
- * $FreeBSD$
- */
-
-#include "sade.h"
-#include <fcntl.h>
-#include <err.h>
-#include <libdisk.h>
-
-static int
-scan_block(int fd, daddr_t block)
-{
- u_char foo[512];
-
- if (-1 == lseek(fd,block * 512,SEEK_SET))
- err(1,"lseek");
- if (512 != read(fd,foo, 512))
- return 1;
- return 0;
-}
-
-static void
-Scan_Disk(Disk *d)
-{
- char device[64];
- u_long l;
- int i,j,fd;
-
- strcpy(device,"/dev/");
- strcat(device,d->name);
-
- fd = open(device,O_RDWR);
- if (fd < 0) {
- msgWarn("open(%s) failed", device);
- return;
- }
- for(i=-1,l=0;;l++) {
- j = scan_block(fd,l);
- if (j != i) {
- if (i == -1) {
- printf("%c: %lu.",j ? 'B' : 'G', l);
- fflush(stdout);
- } else if (i == 0) {
- printf(".%lu\nB: %lu.",l-1,l);
- fflush(stdout);
- } else {
- printf(".%lu\nG: %lu.",l-1,l);
- fflush(stdout);
- }
- i = j;
- }
- }
- close(fd);
-}
-
-void
-slice_wizard(Disk *d)
-{
- Disk *db;
- char myprompt[BUFSIZ];
- char input[BUFSIZ];
- char *p,*q=0;
- char **cp,*cmds[200];
- int ncmd,i;
-
- systemSuspendDialog();
- sprintf(myprompt,"%s> ", d->name);
- while(1) {
- printf("--==##==--\n");
- Debug_Disk(d);
- p = CheckRules(d);
- if (p) {
- printf("%s",p);
- free(p);
- }
- printf("%s", myprompt);
- fflush(stdout);
- q = p = fgets(input,sizeof(input),stdin);
- if(!p)
- break;
- for(cp = cmds; (*cp = strsep(&p, " \t\n")) != NULL;)
- if (**cp != '\0')
- cp++;
- ncmd = cp - cmds;
- if(!ncmd)
- continue;
- if (!strcasecmp(*cmds,"quit")) { break; }
- if (!strcasecmp(*cmds,"exit")) { break; }
- if (!strcasecmp(*cmds,"q")) { break; }
- if (!strcasecmp(*cmds,"x")) { break; }
- if (!strcasecmp(*cmds,"delete") && ncmd == 2) {
- printf("delete = %d\n",
- Delete_Chunk(d,
- (struct chunk *)strtol(cmds[1],0,0)));
- continue;
- }
- if (!strcasecmp(*cmds,"allfreebsd")) {
- All_FreeBSD(d, 0);
- continue;
- }
- if (!strcasecmp(*cmds,"dedicate")) {
- All_FreeBSD(d, 1);
- continue;
- }
- if (!strcasecmp(*cmds,"bios") && ncmd == 4) {
- Set_Bios_Geom(d,
- strtol(cmds[1],0,0),
- strtol(cmds[2],0,0),
- strtol(cmds[3],0,0));
- continue;
- }
- if (!strcasecmp(*cmds,"list")) {
- cp = Disk_Names();
- printf("Disks:");
- for(i=0;cp[i];i++) {
- printf(" %s",cp[i]);
- free(cp[i]);
- }
- free(cp);
- continue;
- }
-#ifdef PC98
- if (!strcasecmp(*cmds,"create") && ncmd == 7) {
- printf("Create=%d\n",
- Create_Chunk(d,
- strtol(cmds[1],0,0),
- strtol(cmds[2],0,0),
- strtol(cmds[3],0,0),
- strtol(cmds[4],0,0),
- strtol(cmds[5],0,0),
- cmds[6]));
- continue;
- }
-#else
- if (!strcasecmp(*cmds,"create") && ncmd == 6) {
- printf("Create=%d\n",
- Create_Chunk(d,
- strtol(cmds[1],0,0),
- strtol(cmds[2],0,0),
- strtol(cmds[3],0,0),
- strtol(cmds[4],0,0),
- strtol(cmds[5],0,0), ""));
- continue;
- }
-#endif
- if (!strcasecmp(*cmds,"read")) {
- db = d;
- if (ncmd > 1)
- d = Open_Disk(cmds[1]);
- else
- d = Open_Disk(d->name);
- if (d)
- Free_Disk(db);
- else
- d = db;
- continue;
- }
- if (!strcasecmp(*cmds,"scan")) {
- Scan_Disk(d);
- continue;
- }
- if (!strcasecmp(*cmds,"write")) {
- printf("Write=%d\n",
- Fake ? 0 : Write_Disk(d));
- q = strdup(d->name);
- Free_Disk(d);
- d = Open_Disk(q);
- continue;
- }
- if (strcasecmp(*cmds,"help"))
- printf("\007ERROR\n");
- printf("CMDS:\n");
- printf("allfreebsd\t\t");
- printf("dedicate\t\t");
- printf("bios cyl hd sect\n");
- printf("collapse [pointer]\t\t");
-#ifdef PC98
- printf("create offset size enum subtype flags name\n");
-#else
- printf("create offset size enum subtype flags\n");
-#endif
- printf("subtype(part): swap=1, ffs=7\t\t");
- printf("delete pointer\n");
- printf("list\t\t");
- printf("quit\n");
- printf("read [disk]\t\t");
- printf("scan\n");
- printf("write\t\t");
- printf("\n");
-
- }
- systemResumeDialog();
-}
diff --git a/usr.sbin/service/service.8 b/usr.sbin/service/service.8
index 10f2e8f..0c2b2d3 100644
--- a/usr.sbin/service/service.8
+++ b/usr.sbin/service/service.8
@@ -24,7 +24,7 @@
.\"
.\" $FreeBSD$
.\"
-.Dd December 26, 2009
+.Dd December 11, 2012
.Dt SERVICE 8
.Os
.Sh NAME
@@ -34,6 +34,8 @@
.Nm
.Fl e
.Nm
+.Fl R
+.Nm
.Op Fl v
.Fl l | r
.Nm
@@ -62,6 +64,8 @@ then that list of scripts is checked for an
.Qq rcvar
assignment.
If present the script is checked to see if it is enabled.
+.It Fl R
+Restart all enabled local services.
.It Fl l
List all files in
.Pa /etc/rc.d
diff --git a/usr.sbin/service/service.sh b/usr.sbin/service/service.sh
index 1794315..cf181fa 100755
--- a/usr.sbin/service/service.sh
+++ b/usr.sbin/service/service.sh
@@ -33,29 +33,58 @@ usage () {
echo ''
echo 'Usage:'
echo "${0##*/} -e"
+ echo "${0##*/} -R"
echo "${0##*/} [-v] -l | -r"
echo "${0##*/} [-v] <rc.d script> start|stop|etc."
echo "${0##*/} -h"
echo ''
echo '-e Show services that are enabled'
+ echo "-R Stop and start enabled $local_startup services"
echo "-l List all scripts in /etc/rc.d and $local_startup"
echo '-r Show the results of boot time rcorder'
echo '-v Verbose'
echo ''
}
-while getopts 'ehlrv' COMMAND_LINE_ARGUMENT ; do
+while getopts 'ehlrRv' COMMAND_LINE_ARGUMENT ; do
case "${COMMAND_LINE_ARGUMENT}" in
e) ENABLED=eopt ;;
h) usage ; exit 0 ;;
l) LIST=lopt ;;
r) RCORDER=ropt ;;
+ R) RESTART=Ropt ;;
v) VERBOSE=vopt ;;
*) usage ; exit 1 ;;
esac
done
shift $(( $OPTIND - 1 ))
+if [ -n "$RESTART" ]; then
+ skip="-s nostart"
+ if [ `/sbin/sysctl -n security.jail.jailed` -eq 1 ]; then
+ skip="$skip -s nojail"
+ fi
+ [ -n "$local_startup" ] && find_local_scripts_new
+ files=`rcorder ${skip} ${local_rc} 2>/dev/null`
+
+ for file in `reverse_list ${files}`; do
+ if grep -q ^rcvar $file; then
+ eval `grep ^name= $file`
+ eval `grep ^rcvar $file`
+ checkyesno $rcvar 2>/dev/null && run_rc_script ${file} stop
+ fi
+ done
+ for file in $files; do
+ if grep -q ^rcvar $file; then
+ eval `grep ^name= $file`
+ eval `grep ^rcvar $file`
+ checkyesno $rcvar 2>/dev/null && run_rc_script ${file} start
+ fi
+ done
+
+ exit 0
+fi
+
if [ -n "$ENABLED" -o -n "$RCORDER" ]; then
# Copied from /etc/rc
skip="-s nostart"
diff --git a/usr.sbin/syslogd/syslogd.c b/usr.sbin/syslogd/syslogd.c
index fff7e4c..bb56b6b 100644
--- a/usr.sbin/syslogd/syslogd.c
+++ b/usr.sbin/syslogd/syslogd.c
@@ -1873,6 +1873,7 @@ cfline(const char *line, struct filed *f, const char *prog, const char *host)
pri = decode(buf, prioritynames);
if (pri < 0) {
+ errno = 0;
(void)snprintf(ebuf, sizeof ebuf,
"unknown priority name \"%s\"", buf);
logerror(ebuf);
@@ -1901,6 +1902,7 @@ cfline(const char *line, struct filed *f, const char *prog, const char *host)
} else {
i = decode(buf, facilitynames);
if (i < 0) {
+ errno = 0;
(void)snprintf(ebuf, sizeof ebuf,
"unknown facility name \"%s\"",
buf);
@@ -2687,6 +2689,7 @@ socksetup(int af, char *bindhostname)
logerror("socket");
continue;
}
+#ifdef INET6
if (r->ai_family == AF_INET6) {
if (setsockopt(*s, IPPROTO_IPV6, IPV6_V6ONLY,
(char *)&on, sizeof (on)) < 0) {
@@ -2695,6 +2698,7 @@ socksetup(int af, char *bindhostname)
continue;
}
}
+#endif
if (setsockopt(*s, SOL_SOCKET, SO_REUSEADDR,
(char *)&on, sizeof (on)) < 0) {
logerror("setsockopt");
@@ -2711,8 +2715,8 @@ socksetup(int af, char *bindhostname)
*/
if (!NoBind) {
if (bind(*s, r->ai_addr, r->ai_addrlen) < 0) {
- close(*s);
logerror("bind");
+ close(*s);
continue;
}
diff --git a/usr.sbin/ypserv/yp_main.c b/usr.sbin/ypserv/yp_main.c
index 69dae29..60bd6a1 100644
--- a/usr.sbin/ypserv/yp_main.c
+++ b/usr.sbin/ypserv/yp_main.c
@@ -292,7 +292,7 @@ create_service(const int sock, const struct netconfig *nconf,
s = __rpc_nconf2fd(nconf);
if (s < 0) {
- if (errno == EPROTONOSUPPORT)
+ if (errno == EAFNOSUPPORT)
_msgout("unsupported"
" transport: %s",
nconf->nc_netid);
OpenPOWER on IntegriCloud