summaryrefslogtreecommitdiffstats
path: root/usr.sbin
diff options
context:
space:
mode:
Diffstat (limited to 'usr.sbin')
-rw-r--r--usr.sbin/IPXrouted/Makefile.depend20
-rw-r--r--usr.sbin/Makefile13
-rw-r--r--usr.sbin/Makefile.amd644
-rw-r--r--usr.sbin/Makefile.i3864
-rw-r--r--usr.sbin/Makefile.ia641
-rw-r--r--usr.sbin/Makefile.powerpc1
-rw-r--r--usr.sbin/Makefile.sparc641
-rw-r--r--usr.sbin/ac/Makefile5
-rw-r--r--usr.sbin/ac/Makefile.depend19
-rw-r--r--usr.sbin/ac/ac.87
-rw-r--r--usr.sbin/ac/ac.c537
-rw-r--r--usr.sbin/accton/Makefile.depend19
-rw-r--r--usr.sbin/acpi/acpiconf/Makefile.depend19
-rw-r--r--usr.sbin/acpi/acpidb/Makefile9
-rw-r--r--usr.sbin/acpi/acpidb/Makefile.depend20
-rw-r--r--usr.sbin/acpi/acpidump/Makefile.depend19
-rw-r--r--usr.sbin/acpi/acpidump/acpi.c55
-rw-r--r--usr.sbin/acpi/acpidump/acpi_user.c2
-rw-r--r--usr.sbin/acpi/iasl/Makefile10
-rw-r--r--usr.sbin/acpi/iasl/Makefile.depend87
-rw-r--r--usr.sbin/adduser/Makefile.depend14
-rw-r--r--usr.sbin/adduser/adduser.87
-rw-r--r--usr.sbin/amd/amd/Makefile.depend33
-rw-r--r--usr.sbin/amd/amq/Makefile.depend25
-rw-r--r--usr.sbin/amd/fixmount/Makefile.depend26
-rw-r--r--usr.sbin/amd/fsinfo/Makefile.depend33
-rw-r--r--usr.sbin/amd/hlfsd/Makefile.depend25
-rw-r--r--usr.sbin/amd/include/Makefile.depend14
-rw-r--r--usr.sbin/amd/libamu/Makefile.depend25
-rw-r--r--usr.sbin/amd/mk-amd-map/Makefile.depend25
-rw-r--r--usr.sbin/amd/pawd/Makefile.depend25
-rw-r--r--usr.sbin/amd/scripts/Makefile.depend14
-rw-r--r--usr.sbin/amd/wire-test/Makefile.depend25
-rw-r--r--usr.sbin/ancontrol/Makefile.depend21
-rw-r--r--usr.sbin/ancontrol/ancontrol.c2
-rw-r--r--usr.sbin/apm/Makefile.depend19
-rw-r--r--usr.sbin/apmd/Makefile.depend25
-rw-r--r--usr.sbin/apmd/apmd.86
-rw-r--r--usr.sbin/arp/Makefile.depend20
-rw-r--r--usr.sbin/arp/arp.454
-rw-r--r--usr.sbin/arpaname/Makefile.depend28
-rw-r--r--usr.sbin/asf/Makefile.depend20
-rw-r--r--usr.sbin/audit/Makefile.depend20
-rw-r--r--usr.sbin/auditd/Makefile.depend21
-rw-r--r--usr.sbin/auditreduce/Makefile.depend20
-rw-r--r--usr.sbin/authpf/Makefile3
-rw-r--r--usr.sbin/authpf/Makefile.depend23
-rw-r--r--usr.sbin/bluetooth/ath3kfw/Makefile.depend20
-rw-r--r--usr.sbin/bluetooth/bcmfw/Makefile.depend20
-rw-r--r--usr.sbin/bluetooth/bt3cfw/Makefile.depend20
-rw-r--r--usr.sbin/bluetooth/bthidcontrol/Makefile.depend28
-rw-r--r--usr.sbin/bluetooth/bthidd/Makefile.depend27
-rw-r--r--usr.sbin/bluetooth/btpand/Makefile.depend22
-rw-r--r--usr.sbin/bluetooth/btpand/client.c34
-rw-r--r--usr.sbin/bluetooth/btpand/server.c12
-rw-r--r--usr.sbin/bluetooth/hccontrol/Makefile.depend20
-rw-r--r--usr.sbin/bluetooth/hcsecd/Makefile.depend26
-rw-r--r--usr.sbin/bluetooth/hcseriald/Makefile.depend20
-rw-r--r--usr.sbin/bluetooth/l2control/Makefile.depend20
-rw-r--r--usr.sbin/bluetooth/l2ping/Makefile.depend21
-rw-r--r--usr.sbin/bluetooth/rfcomm_pppd/Makefile.depend21
-rw-r--r--usr.sbin/bluetooth/sdpcontrol/Makefile.depend21
-rw-r--r--usr.sbin/bluetooth/sdpd/Makefile.depend22
-rw-r--r--usr.sbin/boot0cfg/Makefile.depend22
-rw-r--r--usr.sbin/boot98cfg/Makefile.depend20
-rw-r--r--usr.sbin/bootparamd/bootparamd/Makefile.depend34
-rw-r--r--usr.sbin/bootparamd/callbootd/Makefile.depend31
-rw-r--r--usr.sbin/bsdconfig/Makefile33
-rw-r--r--usr.sbin/bsdconfig/USAGE40
-rwxr-xr-xusr.sbin/bsdconfig/bsdconfig335
-rw-r--r--usr.sbin/bsdconfig/bsdconfig.8233
-rw-r--r--usr.sbin/bsdconfig/console/INDEX59
-rw-r--r--usr.sbin/bsdconfig/console/Makefile16
-rw-r--r--usr.sbin/bsdconfig/console/USAGE33
-rwxr-xr-xusr.sbin/bsdconfig/console/console142
-rwxr-xr-xusr.sbin/bsdconfig/console/font210
-rw-r--r--usr.sbin/bsdconfig/console/include/Makefile11
-rw-r--r--usr.sbin/bsdconfig/console/include/messages.subr264
-rwxr-xr-xusr.sbin/bsdconfig/console/keymap370
-rwxr-xr-xusr.sbin/bsdconfig/console/repeat139
-rwxr-xr-xusr.sbin/bsdconfig/console/saver205
-rwxr-xr-xusr.sbin/bsdconfig/console/screenmap147
-rwxr-xr-xusr.sbin/bsdconfig/console/ttys202
-rw-r--r--usr.sbin/bsdconfig/diskmgmt/INDEX53
-rw-r--r--usr.sbin/bsdconfig/diskmgmt/Makefile16
-rw-r--r--usr.sbin/bsdconfig/diskmgmt/USAGE33
-rwxr-xr-xusr.sbin/bsdconfig/diskmgmt/diskmgmt85
-rw-r--r--usr.sbin/bsdconfig/diskmgmt/include/Makefile11
-rw-r--r--usr.sbin/bsdconfig/diskmgmt/include/messages.subr27
-rw-r--r--usr.sbin/bsdconfig/docsinstall/INDEX53
-rw-r--r--usr.sbin/bsdconfig/docsinstall/Makefile16
-rw-r--r--usr.sbin/bsdconfig/docsinstall/USAGE33
-rwxr-xr-xusr.sbin/bsdconfig/docsinstall/docsinstall97
-rw-r--r--usr.sbin/bsdconfig/docsinstall/include/Makefile11
-rw-r--r--usr.sbin/bsdconfig/docsinstall/include/messages.subr28
-rw-r--r--usr.sbin/bsdconfig/dot/INDEX53
-rw-r--r--usr.sbin/bsdconfig/dot/Makefile16
-rw-r--r--usr.sbin/bsdconfig/dot/USAGE143
-rwxr-xr-xusr.sbin/bsdconfig/dot/dot666
-rw-r--r--usr.sbin/bsdconfig/dot/include/Makefile11
-rw-r--r--usr.sbin/bsdconfig/dot/include/messages.subr30
-rw-r--r--usr.sbin/bsdconfig/examples/Makefile11
-rw-r--r--usr.sbin/bsdconfig/examples/bsdconfigrc35
-rw-r--r--usr.sbin/bsdconfig/include/Makefile11
-rw-r--r--usr.sbin/bsdconfig/include/bsdconfig.hlp12
-rw-r--r--usr.sbin/bsdconfig/include/messages.subr63
-rw-r--r--usr.sbin/bsdconfig/include/usage.hlp64
-rw-r--r--usr.sbin/bsdconfig/mouse/INDEX58
-rw-r--r--usr.sbin/bsdconfig/mouse/Makefile16
-rw-r--r--usr.sbin/bsdconfig/mouse/USAGE33
-rwxr-xr-xusr.sbin/bsdconfig/mouse/disable104
-rwxr-xr-xusr.sbin/bsdconfig/mouse/enable118
-rwxr-xr-xusr.sbin/bsdconfig/mouse/flags118
-rw-r--r--usr.sbin/bsdconfig/mouse/include/Makefile11
-rw-r--r--usr.sbin/bsdconfig/mouse/include/messages.subr90
-rwxr-xr-xusr.sbin/bsdconfig/mouse/mouse139
-rwxr-xr-xusr.sbin/bsdconfig/mouse/port147
-rwxr-xr-xusr.sbin/bsdconfig/mouse/type163
-rw-r--r--usr.sbin/bsdconfig/networking/INDEX57
-rw-r--r--usr.sbin/bsdconfig/networking/Makefile16
-rw-r--r--usr.sbin/bsdconfig/networking/USAGE33
-rwxr-xr-xusr.sbin/bsdconfig/networking/defaultrouter73
-rwxr-xr-xusr.sbin/bsdconfig/networking/devices158
-rwxr-xr-xusr.sbin/bsdconfig/networking/hostname73
-rw-r--r--usr.sbin/bsdconfig/networking/include/Makefile11
-rw-r--r--usr.sbin/bsdconfig/networking/include/messages.subr100
-rw-r--r--usr.sbin/bsdconfig/networking/include/tcp.hlp33
-rwxr-xr-xusr.sbin/bsdconfig/networking/nameservers73
-rwxr-xr-xusr.sbin/bsdconfig/networking/networking151
-rw-r--r--usr.sbin/bsdconfig/networking/share/Makefile12
-rw-r--r--usr.sbin/bsdconfig/networking/share/common.subr65
-rw-r--r--usr.sbin/bsdconfig/networking/share/device.subr504
-rw-r--r--usr.sbin/bsdconfig/networking/share/hostname.subr214
-rw-r--r--usr.sbin/bsdconfig/networking/share/ipaddr.subr239
-rw-r--r--usr.sbin/bsdconfig/networking/share/media.subr241
-rw-r--r--usr.sbin/bsdconfig/networking/share/netmask.subr218
-rw-r--r--usr.sbin/bsdconfig/networking/share/resolv.subr515
-rw-r--r--usr.sbin/bsdconfig/networking/share/routing.subr171
-rw-r--r--usr.sbin/bsdconfig/password/INDEX53
-rw-r--r--usr.sbin/bsdconfig/password/Makefile16
-rw-r--r--usr.sbin/bsdconfig/password/USAGE33
-rw-r--r--usr.sbin/bsdconfig/password/include/Makefile11
-rw-r--r--usr.sbin/bsdconfig/password/include/messages.subr35
-rwxr-xr-xusr.sbin/bsdconfig/password/password82
-rw-r--r--usr.sbin/bsdconfig/password/share/Makefile11
-rw-r--r--usr.sbin/bsdconfig/password/share/password.subr127
-rw-r--r--usr.sbin/bsdconfig/security/INDEX54
-rw-r--r--usr.sbin/bsdconfig/security/Makefile16
-rw-r--r--usr.sbin/bsdconfig/security/USAGE33
-rw-r--r--usr.sbin/bsdconfig/security/include/Makefile11
-rw-r--r--usr.sbin/bsdconfig/security/include/messages.subr48
-rw-r--r--usr.sbin/bsdconfig/security/include/securelevel.hlp40
-rwxr-xr-xusr.sbin/bsdconfig/security/kern_securelevel154
-rwxr-xr-xusr.sbin/bsdconfig/security/security154
-rw-r--r--usr.sbin/bsdconfig/share/Makefile11
-rw-r--r--usr.sbin/bsdconfig/share/common.subr330
-rw-r--r--usr.sbin/bsdconfig/share/dialog.subr1465
-rw-r--r--usr.sbin/bsdconfig/share/mustberoot.subr424
-rw-r--r--usr.sbin/bsdconfig/share/strings.subr104
-rw-r--r--usr.sbin/bsdconfig/share/sysrc.subr626
-rw-r--r--usr.sbin/bsdconfig/startup/INDEX58
-rw-r--r--usr.sbin/bsdconfig/startup/Makefile16
-rw-r--r--usr.sbin/bsdconfig/startup/USAGE33
-rw-r--r--usr.sbin/bsdconfig/startup/include/Makefile11
-rw-r--r--usr.sbin/bsdconfig/startup/include/messages.subr112
-rwxr-xr-xusr.sbin/bsdconfig/startup/misc414
-rwxr-xr-xusr.sbin/bsdconfig/startup/rcadd158
-rwxr-xr-xusr.sbin/bsdconfig/startup/rcconf251
-rwxr-xr-xusr.sbin/bsdconfig/startup/rcdelete365
-rwxr-xr-xusr.sbin/bsdconfig/startup/rcedit69
-rwxr-xr-xusr.sbin/bsdconfig/startup/rcvar205
-rw-r--r--usr.sbin/bsdconfig/startup/share/Makefile11
-rw-r--r--usr.sbin/bsdconfig/startup/share/rcconf.subr477
-rw-r--r--usr.sbin/bsdconfig/startup/share/rcedit.subr109
-rw-r--r--usr.sbin/bsdconfig/startup/share/rcvar.subr206
-rwxr-xr-xusr.sbin/bsdconfig/startup/startup133
-rw-r--r--usr.sbin/bsdconfig/timezone/INDEX53
-rw-r--r--usr.sbin/bsdconfig/timezone/Makefile16
-rw-r--r--usr.sbin/bsdconfig/timezone/USAGE42
-rw-r--r--usr.sbin/bsdconfig/timezone/include/Makefile11
-rw-r--r--usr.sbin/bsdconfig/timezone/include/messages.subr78
-rw-r--r--usr.sbin/bsdconfig/timezone/share/Makefile12
-rw-r--r--usr.sbin/bsdconfig/timezone/share/continents.subr138
-rw-r--r--usr.sbin/bsdconfig/timezone/share/countries.subr78
-rw-r--r--usr.sbin/bsdconfig/timezone/share/iso3166.subr197
-rw-r--r--usr.sbin/bsdconfig/timezone/share/menus.subr220
-rw-r--r--usr.sbin/bsdconfig/timezone/share/zones.subr670
-rwxr-xr-xusr.sbin/bsdconfig/timezone/timezone457
-rw-r--r--usr.sbin/bsdconfig/ttys/INDEX53
-rw-r--r--usr.sbin/bsdconfig/ttys/Makefile16
-rw-r--r--usr.sbin/bsdconfig/ttys/USAGE33
-rw-r--r--usr.sbin/bsdconfig/ttys/include/Makefile11
-rw-r--r--usr.sbin/bsdconfig/ttys/include/messages.subr31
-rwxr-xr-xusr.sbin/bsdconfig/ttys/ttys128
-rw-r--r--usr.sbin/bsdconfig/usermgmt/INDEX60
-rw-r--r--usr.sbin/bsdconfig/usermgmt/Makefile17
-rw-r--r--usr.sbin/bsdconfig/usermgmt/USAGE33
-rwxr-xr-xusr.sbin/bsdconfig/usermgmt/groupadd64
-rwxr-xr-xusr.sbin/bsdconfig/usermgmt/groupdel93
-rwxr-xr-xusr.sbin/bsdconfig/usermgmt/groupedit93
-rwxr-xr-xusr.sbin/bsdconfig/usermgmt/groupinput297
-rw-r--r--usr.sbin/bsdconfig/usermgmt/include/Makefile11
-rw-r--r--usr.sbin/bsdconfig/usermgmt/include/messages.subr111
-rw-r--r--usr.sbin/bsdconfig/usermgmt/include/usermgmt.hlp76
-rw-r--r--usr.sbin/bsdconfig/usermgmt/share/Makefile11
-rw-r--r--usr.sbin/bsdconfig/usermgmt/share/group_input.subr462
-rw-r--r--usr.sbin/bsdconfig/usermgmt/share/user_input.subr1243
-rwxr-xr-xusr.sbin/bsdconfig/usermgmt/useradd64
-rwxr-xr-xusr.sbin/bsdconfig/usermgmt/userdel93
-rwxr-xr-xusr.sbin/bsdconfig/usermgmt/useredit93
-rwxr-xr-xusr.sbin/bsdconfig/usermgmt/userinput518
-rwxr-xr-xusr.sbin/bsdconfig/usermgmt/usermgmt173
-rw-r--r--usr.sbin/bsdinstall/Makefile.depend14
-rwxr-xr-xusr.sbin/bsdinstall/bsdinstall13
-rw-r--r--usr.sbin/bsdinstall/distextract/Makefile.depend23
-rw-r--r--usr.sbin/bsdinstall/distfetch/Makefile.depend23
-rw-r--r--usr.sbin/bsdinstall/partedit/Makefile.depend24
-rw-r--r--usr.sbin/bsdinstall/partedit/diskeditor.c3
-rw-r--r--usr.sbin/bsdinstall/partedit/part_wizard.c6
-rwxr-xr-xusr.sbin/bsdinstall/scripts/auto14
-rw-r--r--usr.sbin/bsnmpd/bsnmpd/Makefile.depend51
-rw-r--r--usr.sbin/bsnmpd/gensnmptree/Makefile.depend19
-rw-r--r--usr.sbin/bsnmpd/modules/Makefile.depend14
-rw-r--r--usr.sbin/bsnmpd/modules/snmp_atm/Makefile.depend30
-rw-r--r--usr.sbin/bsnmpd/modules/snmp_bridge/Makefile.depend38
-rw-r--r--usr.sbin/bsnmpd/modules/snmp_hostres/Makefile.depend79
-rw-r--r--usr.sbin/bsnmpd/modules/snmp_hostres/hostres_diskstorage_tbl.c6
-rw-r--r--usr.sbin/bsnmpd/modules/snmp_hostres/hostres_scalars.c2
-rw-r--r--usr.sbin/bsnmpd/modules/snmp_hostres/hostres_swrun_tbl.c2
-rw-r--r--usr.sbin/bsnmpd/modules/snmp_mibII/Makefile2
-rw-r--r--usr.sbin/bsnmpd/modules/snmp_mibII/Makefile.depend68
-rw-r--r--usr.sbin/bsnmpd/modules/snmp_netgraph/Makefile.depend27
-rw-r--r--usr.sbin/bsnmpd/modules/snmp_pf/BEGEMOT-PF-MIB.txt2
-rw-r--r--usr.sbin/bsnmpd/modules/snmp_pf/Makefile.depend26
-rw-r--r--usr.sbin/bsnmpd/modules/snmp_pf/pf_snmp.c5
-rw-r--r--usr.sbin/bsnmpd/modules/snmp_pf/pf_tree.def2
-rw-r--r--usr.sbin/bsnmpd/modules/snmp_target/Makefile.depend25
-rw-r--r--usr.sbin/bsnmpd/modules/snmp_usm/Makefile.depend25
-rw-r--r--usr.sbin/bsnmpd/modules/snmp_vacm/Makefile.depend25
-rw-r--r--usr.sbin/bsnmpd/modules/snmp_wlan/Makefile.depend29
-rw-r--r--usr.sbin/bsnmpd/tools/bsnmptools/Makefile.depend22
-rw-r--r--usr.sbin/bsnmpd/tools/libbsnmptools/Makefile.depend18
-rw-r--r--usr.sbin/btxld/Makefile.depend19
-rw-r--r--usr.sbin/burncd/Makefile.depend20
-rw-r--r--usr.sbin/cdcontrol/Makefile.depend22
-rw-r--r--usr.sbin/chkgrp/Makefile.depend19
-rw-r--r--usr.sbin/chown/Makefile.depend19
-rw-r--r--usr.sbin/chroot/Makefile.depend19
-rw-r--r--usr.sbin/chroot/chroot.82
-rw-r--r--usr.sbin/ckdist/Makefile.depend20
-rw-r--r--usr.sbin/clear_locks/Makefile.depend22
-rw-r--r--usr.sbin/config/Makefile.depend36
-rw-r--r--usr.sbin/config/mkmakefile.c4
-rw-r--r--usr.sbin/cpucontrol/Makefile.depend19
-rw-r--r--usr.sbin/cpucontrol/cpucontrol.c2
-rw-r--r--usr.sbin/crashinfo/Makefile.depend14
-rw-r--r--usr.sbin/cron/cron/Makefile.depend22
-rw-r--r--usr.sbin/cron/cron/cron.c152
-rw-r--r--usr.sbin/cron/cron/cron.h6
-rw-r--r--usr.sbin/cron/crontab/Makefile.depend22
-rw-r--r--usr.sbin/cron/crontab/crontab.52
-rw-r--r--usr.sbin/cron/crontab/crontab.c12
-rw-r--r--usr.sbin/cron/lib/Makefile.depend17
-rw-r--r--usr.sbin/cron/lib/entry.c23
-rw-r--r--usr.sbin/cron/lib/misc.c2
-rw-r--r--usr.sbin/crunch/crunchgen/Makefile.depend21
-rw-r--r--usr.sbin/crunch/crunchgen/crunched_main.c19
-rw-r--r--usr.sbin/crunch/crunchgen/crunchgen.c115
-rw-r--r--usr.sbin/crunch/crunchide/Makefile.depend19
-rw-r--r--usr.sbin/crunch/crunchide/crunchide.c29
-rw-r--r--usr.sbin/crunch/crunchide/exec_elf32.c3
-rw-r--r--usr.sbin/crunch/examples/Makefile6
-rw-r--r--usr.sbin/crunch/examples/really-big.conf2
-rw-r--r--usr.sbin/ctladm/Makefile.depend23
-rw-r--r--usr.sbin/ctladm/ctladm.c18
-rw-r--r--usr.sbin/ctladm/util.c2
-rw-r--r--usr.sbin/ctm/ctm/Makefile.depend20
-rw-r--r--usr.sbin/ctm/ctm_dequeue/Makefile.depend19
-rw-r--r--usr.sbin/ctm/ctm_rmail/Makefile.depend19
-rw-r--r--usr.sbin/ctm/ctm_smail/Makefile.depend19
-rw-r--r--usr.sbin/daemon/Makefile.depend19
-rw-r--r--usr.sbin/dconschat/Makefile.depend21
-rw-r--r--usr.sbin/ddns-confgen/Makefile.depend28
-rw-r--r--usr.sbin/devinfo/Makefile.depend19
-rw-r--r--usr.sbin/digictl/Makefile.depend19
-rw-r--r--usr.sbin/diskinfo/Makefile.depend20
-rw-r--r--usr.sbin/diskinfo/diskinfo.c2
-rw-r--r--usr.sbin/dnssec-dsfromkey/Makefile.depend28
-rw-r--r--usr.sbin/dnssec-keyfromlabel/Makefile.depend28
-rw-r--r--usr.sbin/dnssec-keygen/Makefile.depend28
-rw-r--r--usr.sbin/dnssec-revoke/Makefile.depend28
-rw-r--r--usr.sbin/dnssec-settime/Makefile.depend28
-rw-r--r--usr.sbin/dnssec-signzone/Makefile.depend28
-rw-r--r--usr.sbin/dumpcis/Makefile.depend19
-rw-r--r--usr.sbin/editmap/Makefile.depend25
-rw-r--r--usr.sbin/edquota/Makefile.depend20
-rw-r--r--usr.sbin/edquota/edquota.c6
-rw-r--r--usr.sbin/eeprom/Makefile.depend19
-rw-r--r--usr.sbin/etcupdate/Makefile6
-rw-r--r--usr.sbin/etcupdate/etcupdate.8789
-rwxr-xr-xusr.sbin/etcupdate/etcupdate.sh1675
-rw-r--r--usr.sbin/extattr/Makefile.depend20
-rw-r--r--usr.sbin/extattrctl/Makefile.depend20
-rw-r--r--usr.sbin/faithd/Makefile.depend21
-rw-r--r--usr.sbin/fdcontrol/Makefile.depend19
-rw-r--r--usr.sbin/fdformat/Makefile.depend19
-rw-r--r--usr.sbin/fdread/Makefile.depend19
-rw-r--r--usr.sbin/fdwrite/Makefile.depend19
-rw-r--r--usr.sbin/fifolog/fifolog_create/Makefile.depend20
-rw-r--r--usr.sbin/fifolog/fifolog_create/fifolog.12
-rw-r--r--usr.sbin/fifolog/fifolog_reader/Makefile.depend22
-rw-r--r--usr.sbin/fifolog/fifolog_writer/Makefile.depend22
-rw-r--r--usr.sbin/fifolog/lib/Makefile.depend19
-rw-r--r--usr.sbin/flowctl/Makefile.depend21
-rw-r--r--usr.sbin/flowctl/flowctl.88
-rw-r--r--usr.sbin/flowctl/flowctl.c39
-rw-r--r--usr.sbin/freebsd-update/Makefile.depend14
-rw-r--r--usr.sbin/ftp-proxy/ftp-proxy/Makefile1
-rw-r--r--usr.sbin/ftp-proxy/ftp-proxy/Makefile.depend21
-rw-r--r--usr.sbin/ftp-proxy/libevent/Makefile.depend16
-rw-r--r--usr.sbin/fwcontrol/Makefile.depend20
-rw-r--r--usr.sbin/genrandom/Makefile.depend27
-rw-r--r--usr.sbin/getfmac/Makefile.depend19
-rw-r--r--usr.sbin/getpmac/Makefile.depend19
-rw-r--r--usr.sbin/gpioctl/Makefile.depend19
-rw-r--r--usr.sbin/gpioctl/gpioctl.c2
-rw-r--r--usr.sbin/gssd/Makefile.depend34
-rw-r--r--usr.sbin/gstat/Makefile.depend27
-rw-r--r--usr.sbin/i2c/Makefile.depend19
-rw-r--r--usr.sbin/ifmcstat/Makefile.depend21
-rw-r--r--usr.sbin/ifmcstat/ifmcstat.c5
-rw-r--r--usr.sbin/inetd/Makefile.depend24
-rw-r--r--usr.sbin/inetd/builtins.c8
-rw-r--r--usr.sbin/iostat/Makefile.depend22
-rw-r--r--usr.sbin/ip6addrctl/Makefile2
-rw-r--r--usr.sbin/ip6addrctl/Makefile.depend19
-rw-r--r--usr.sbin/ip6addrctl/ip6addrctl.c46
-rw-r--r--usr.sbin/ipfwpcap/Makefile.depend20
-rw-r--r--usr.sbin/ipfwpcap/ipfwpcap.84
-rw-r--r--usr.sbin/isc-hmac-fixup/Makefile.depend27
-rw-r--r--usr.sbin/isfctl/Makefile7
-rw-r--r--usr.sbin/isfctl/isfctl.889
-rw-r--r--usr.sbin/isfctl/isfctl.c115
-rw-r--r--usr.sbin/jail/Makefile.depend29
-rw-r--r--usr.sbin/jail/config.c14
-rw-r--r--usr.sbin/jail/jail.810
-rw-r--r--usr.sbin/jail/jail.c30
-rw-r--r--usr.sbin/jexec/Makefile.depend22
-rw-r--r--usr.sbin/jls/Makefile.depend21
-rw-r--r--usr.sbin/kbdcontrol/Makefile.depend21
-rw-r--r--usr.sbin/kbdmap/Makefile.depend19
-rw-r--r--usr.sbin/kbdmap/kbdmap.c3
-rw-r--r--usr.sbin/keyserv/Makefile.depend30
-rw-r--r--usr.sbin/keyserv/keyserv.c4
-rw-r--r--usr.sbin/kgmon/Makefile.depend20
-rw-r--r--usr.sbin/kgmon/kgmon.c4
-rw-r--r--usr.sbin/kgzip/Makefile.depend19
-rw-r--r--usr.sbin/kldxref/Makefile.depend19
-rw-r--r--usr.sbin/kldxref/ef.c7
-rw-r--r--usr.sbin/lastlogin/Makefile.depend19
-rw-r--r--usr.sbin/lmcconfig/Makefile.depend20
-rw-r--r--usr.sbin/lmcconfig/lmcconfig.c16
-rw-r--r--usr.sbin/lpr/chkprintcap/Makefile.depend20
-rw-r--r--usr.sbin/lpr/common_source/Makefile.depend17
-rw-r--r--usr.sbin/lpr/common_source/common.c37
-rw-r--r--usr.sbin/lpr/common_source/displayq.c43
-rw-r--r--usr.sbin/lpr/common_source/lp.h14
-rw-r--r--usr.sbin/lpr/common_source/net.c39
-rw-r--r--usr.sbin/lpr/common_source/rmjob.c27
-rw-r--r--usr.sbin/lpr/common_source/startdaemon.c6
-rw-r--r--usr.sbin/lpr/filters.ru/Makefile.depend14
-rw-r--r--usr.sbin/lpr/filters.ru/koi2855/Makefile.depend18
-rw-r--r--usr.sbin/lpr/filters.ru/koi2alt/Makefile.depend18
-rw-r--r--usr.sbin/lpr/filters/Makefile.depend19
-rw-r--r--usr.sbin/lpr/filters/lpf.c22
-rw-r--r--usr.sbin/lpr/lp/Makefile.depend14
-rw-r--r--usr.sbin/lpr/lpc/Makefile.depend22
-rw-r--r--usr.sbin/lpr/lpc/cmds.c59
-rw-r--r--usr.sbin/lpr/lpc/lpc.c6
-rw-r--r--usr.sbin/lpr/lpc/movejobs.c5
-rw-r--r--usr.sbin/lpr/lpd/Makefile.depend21
-rw-r--r--usr.sbin/lpr/lpd/lpd.82
-rw-r--r--usr.sbin/lpr/lpd/printjob.c5
-rw-r--r--usr.sbin/lpr/lpq/Makefile.depend20
-rw-r--r--usr.sbin/lpr/lpq/lpq.c2
-rw-r--r--usr.sbin/lpr/lpr/Makefile.depend20
-rw-r--r--usr.sbin/lpr/lpr/lpr.c39
-rw-r--r--usr.sbin/lpr/lprm/Makefile.depend20
-rw-r--r--usr.sbin/lpr/lprm/lprm.c3
-rw-r--r--usr.sbin/lpr/lptest/Makefile.depend18
-rw-r--r--usr.sbin/lpr/pac/Makefile.depend20
-rw-r--r--usr.sbin/lptcontrol/Makefile.depend18
-rw-r--r--usr.sbin/mailstats/Makefile.depend24
-rw-r--r--usr.sbin/mailwrapper/Makefile.depend20
-rw-r--r--usr.sbin/makefs/Makefile.depend20
-rw-r--r--usr.sbin/makefs/ffs.c29
-rw-r--r--usr.sbin/makefs/ffs/ffs_alloc.c5
-rw-r--r--usr.sbin/makefs/ffs/ffs_extern.h1
-rw-r--r--usr.sbin/makefs/ffs/ufs_bmap.c2
-rw-r--r--usr.sbin/makefs/makefs.86
-rw-r--r--usr.sbin/makefs/makefs.c7
-rw-r--r--usr.sbin/makefs/makefs.h1
-rw-r--r--usr.sbin/makefs/mtree.c47
-rw-r--r--usr.sbin/makemap/Makefile.depend25
-rw-r--r--usr.sbin/manctl/Makefile.depend14
-rw-r--r--usr.sbin/memcontrol/Makefile.depend19
-rw-r--r--usr.sbin/memcontrol/memcontrol.c2
-rw-r--r--usr.sbin/mergemaster/Makefile.depend14
-rwxr-xr-xusr.sbin/mergemaster/mergemaster.sh68
-rw-r--r--usr.sbin/mfiutil/Makefile1
-rw-r--r--usr.sbin/mfiutil/Makefile.depend20
-rw-r--r--usr.sbin/mfiutil/mfi_cmd.c4
-rw-r--r--usr.sbin/mfiutil/mfi_config.c19
-rw-r--r--usr.sbin/mfiutil/mfi_drive.c21
-rw-r--r--usr.sbin/mfiutil/mfi_evt.c7
-rw-r--r--usr.sbin/mfiutil/mfi_flash.c36
-rw-r--r--usr.sbin/mfiutil/mfi_patrol.c15
-rw-r--r--usr.sbin/mfiutil/mfi_show.c59
-rw-r--r--usr.sbin/mfiutil/mfi_volume.c7
-rw-r--r--usr.sbin/mfiutil/mfiutil.c34
-rw-r--r--usr.sbin/mfiutil/mfiutil.h6
-rw-r--r--usr.sbin/mixer/Makefile.depend19
-rw-r--r--usr.sbin/mld6query/Makefile.depend20
-rw-r--r--usr.sbin/mlxcontrol/Makefile.depend19
-rw-r--r--usr.sbin/mount_nwfs/Makefile.depend20
-rw-r--r--usr.sbin/mount_portalfs/Makefile.depend20
-rw-r--r--usr.sbin/mount_smbfs/Makefile.depend20
-rw-r--r--usr.sbin/mountd/Makefile.depend23
-rw-r--r--usr.sbin/mountd/exports.52
-rw-r--r--usr.sbin/mountd/mountd.817
-rw-r--r--usr.sbin/mountd/mountd.c92
-rw-r--r--usr.sbin/moused/Makefile.depend21
-rw-r--r--usr.sbin/moused/moused.c20
-rw-r--r--usr.sbin/mptable/Makefile.depend19
-rw-r--r--usr.sbin/mptutil/Makefile.depend22
-rw-r--r--usr.sbin/mtest/Makefile.depend20
-rw-r--r--usr.sbin/mtree/Makefile.depend20
-rw-r--r--usr.sbin/mtree/mtree.c3
-rw-r--r--usr.sbin/named-checkconf/Makefile.depend28
-rw-r--r--usr.sbin/named-checkzone/Makefile.depend28
-rw-r--r--usr.sbin/named-journalprint/Makefile.depend27
-rw-r--r--usr.sbin/named/Makefile.depend28
-rw-r--r--usr.sbin/ndiscvt/Makefile.depend25
-rw-r--r--usr.sbin/ndp/Makefile.depend20
-rw-r--r--usr.sbin/ndp/ndp.811
-rw-r--r--usr.sbin/ndp/ndp.c7
-rw-r--r--usr.sbin/newsyslog/Makefile.depend19
-rw-r--r--usr.sbin/newsyslog/newsyslog.c47
-rw-r--r--usr.sbin/newsyslog/newsyslog.conf.515
-rw-r--r--usr.sbin/nfscbd/Makefile.depend20
-rw-r--r--usr.sbin/nfscbd/nfscbd.c6
-rw-r--r--usr.sbin/nfsd/Makefile.depend22
-rw-r--r--usr.sbin/nfsd/nfsd.c20
-rw-r--r--usr.sbin/nfsdumpstate/Makefile.depend20
-rw-r--r--usr.sbin/nfsrevoke/Makefile.depend19
-rw-r--r--usr.sbin/nfsuserd/Makefile.depend20
-rw-r--r--usr.sbin/ngctl/Makefile.depend23
-rw-r--r--usr.sbin/nghook/Makefile.depend20
-rw-r--r--usr.sbin/nologin/Makefile.depend17
-rw-r--r--usr.sbin/nscd/Makefile.depend22
-rw-r--r--usr.sbin/nscd/cachelib.c26
-rw-r--r--usr.sbin/nscd/cachelib.h2
-rw-r--r--usr.sbin/nscd/config.c2
-rw-r--r--usr.sbin/nscd/config.h2
-rw-r--r--usr.sbin/nscd/nscd.conf.511
-rw-r--r--usr.sbin/nscd/parser.c44
-rw-r--r--usr.sbin/nsec3hash/Makefile.depend28
-rw-r--r--usr.sbin/ntp/libntp/Makefile.depend20
-rw-r--r--usr.sbin/ntp/libopts/Makefile.depend16
-rw-r--r--usr.sbin/ntp/libparse/Makefile.depend18
-rw-r--r--usr.sbin/ntp/ntp-keygen/Makefile.depend23
-rw-r--r--usr.sbin/ntp/ntpd/Makefile.depend29
-rw-r--r--usr.sbin/ntp/ntpdate/Makefile.depend27
-rw-r--r--usr.sbin/ntp/ntpdc/Makefile.depend30
-rw-r--r--usr.sbin/ntp/ntpq/Makefile.depend30
-rw-r--r--usr.sbin/ntp/ntptime/Makefile.depend20
-rw-r--r--usr.sbin/ntp/sntp/Makefile.depend22
-rw-r--r--usr.sbin/nvram/nvram.c12
-rw-r--r--usr.sbin/ofwdump/Makefile.depend19
-rw-r--r--usr.sbin/pc-sysinstall/backend-partmanager/Makefile.depend14
-rw-r--r--usr.sbin/pc-sysinstall/backend-query/Makefile.depend14
-rw-r--r--usr.sbin/pc-sysinstall/backend/Makefile.depend14
-rwxr-xr-xusr.sbin/pc-sysinstall/backend/functions-bsdlabel.sh43
-rwxr-xr-xusr.sbin/pc-sysinstall/backend/functions-cleanup.sh6
-rwxr-xr-xusr.sbin/pc-sysinstall/backend/functions-disk.sh9
-rwxr-xr-xusr.sbin/pc-sysinstall/backend/functions-installcomponents.sh12
-rwxr-xr-xusr.sbin/pc-sysinstall/backend/functions-mountdisk.sh23
-rwxr-xr-xusr.sbin/pc-sysinstall/backend/functions-newfs.sh16
-rw-r--r--usr.sbin/pc-sysinstall/conf/Makefile.depend14
-rw-r--r--usr.sbin/pc-sysinstall/pc-sysinstall/Makefile.depend14
-rw-r--r--usr.sbin/pciconf/Makefile.depend19
-rw-r--r--usr.sbin/pciconf/cap.c146
-rw-r--r--usr.sbin/pciconf/err.c24
-rw-r--r--usr.sbin/pciconf/pciconf.c1
-rw-r--r--usr.sbin/periodic/Makefile.depend14
-rw-r--r--usr.sbin/pkg/Makefile.depend22
-rw-r--r--usr.sbin/pkg/elf_tables.h11
-rw-r--r--usr.sbin/pkg/pkg.c38
-rw-r--r--usr.sbin/pkg_install/add/Makefile.depend25
-rw-r--r--usr.sbin/pkg_install/add/add.h2
-rw-r--r--usr.sbin/pkg_install/add/extract.c2
-rw-r--r--usr.sbin/pkg_install/add/futil.c5
-rw-r--r--usr.sbin/pkg_install/add/main.c6
-rw-r--r--usr.sbin/pkg_install/add/perform.c2
-rw-r--r--usr.sbin/pkg_install/create/Makefile.depend22
-rw-r--r--usr.sbin/pkg_install/create/main.c1
-rw-r--r--usr.sbin/pkg_install/create/perform.c12
-rw-r--r--usr.sbin/pkg_install/delete/Makefile.depend22
-rw-r--r--usr.sbin/pkg_install/delete/main.c1
-rw-r--r--usr.sbin/pkg_install/info/Makefile.depend25
-rw-r--r--usr.sbin/pkg_install/info/info.h2
-rw-r--r--usr.sbin/pkg_install/info/main.c1
-rw-r--r--usr.sbin/pkg_install/info/perform.c4
-rw-r--r--usr.sbin/pkg_install/info/show.c33
-rw-r--r--usr.sbin/pkg_install/lib/Makefile2
-rw-r--r--usr.sbin/pkg_install/lib/Makefile.depend19
-rw-r--r--usr.sbin/pkg_install/lib/exec.c1
-rw-r--r--usr.sbin/pkg_install/lib/lib.h3
-rw-r--r--usr.sbin/pkg_install/lib/pkgng.c38
-rw-r--r--usr.sbin/pkg_install/lib/plist.c5
-rw-r--r--usr.sbin/pkg_install/updating/Makefile.depend25
-rw-r--r--usr.sbin/pkg_install/updating/main.c1
-rw-r--r--usr.sbin/pkg_install/version/Makefile.depend25
-rw-r--r--usr.sbin/pkg_install/version/main.c1
-rw-r--r--usr.sbin/pkg_install/version/perform.c41
-rw-r--r--usr.sbin/pmcannotate/Makefile.depend19
-rw-r--r--usr.sbin/pmccontrol/Makefile.depend20
-rw-r--r--usr.sbin/pmccontrol/pmccontrol.c13
-rw-r--r--usr.sbin/pmcstat/Makefile.depend25
-rw-r--r--usr.sbin/pmcstat/pmcpl_calltree.c6
-rw-r--r--usr.sbin/pmcstat/pmcstat.c14
-rw-r--r--usr.sbin/pmcstat/pmcstat_log.c16
-rw-r--r--usr.sbin/pmcstat/pmcstat_log.h4
-rw-r--r--usr.sbin/pnpinfo/Makefile.depend19
-rw-r--r--usr.sbin/portsnap/make_index/Makefile.depend19
-rw-r--r--usr.sbin/portsnap/phttpget/Makefile.depend19
-rw-r--r--usr.sbin/portsnap/portsnap/Makefile.depend14
-rw-r--r--usr.sbin/portsnap/portsnap/portsnap.829
-rw-r--r--usr.sbin/portsnap/portsnap/portsnap.sh35
-rw-r--r--usr.sbin/powerd/Makefile.depend20
-rw-r--r--usr.sbin/ppp/Makefile.depend29
-rw-r--r--usr.sbin/ppp/lqr.c3
-rw-r--r--usr.sbin/ppp/ppp.8.m462
-rw-r--r--usr.sbin/ppp/radius.c2
-rw-r--r--usr.sbin/pppctl/Makefile.depend23
-rw-r--r--usr.sbin/praliases/Makefile.depend25
-rw-r--r--usr.sbin/praudit/Makefile.depend20
-rw-r--r--usr.sbin/procctl/Makefile.depend19
-rw-r--r--usr.sbin/pstat/Makefile.depend21
-rw-r--r--usr.sbin/pw/Makefile4
-rw-r--r--usr.sbin/pw/Makefile.depend21
-rw-r--r--usr.sbin/pw/edgroup.c229
-rw-r--r--usr.sbin/pw/fileupd.c135
-rw-r--r--usr.sbin/pw/grupd.c120
-rw-r--r--usr.sbin/pw/pw.88
-rw-r--r--usr.sbin/pw/pw.c4
-rw-r--r--usr.sbin/pw/pw.h9
-rw-r--r--usr.sbin/pw/pw_group.c5
-rw-r--r--usr.sbin/pw/pw_log.c2
-rw-r--r--usr.sbin/pw/pw_nis.c52
-rw-r--r--usr.sbin/pw/pw_user.c60
-rw-r--r--usr.sbin/pw/pw_vpw.c16
-rw-r--r--usr.sbin/pw/pwupd.c115
-rw-r--r--usr.sbin/pw/pwupd.h39
-rw-r--r--usr.sbin/pwd_mkdb/Makefile.depend20
-rw-r--r--usr.sbin/quot/Makefile.depend19
-rw-r--r--usr.sbin/quot/quot.c6
-rw-r--r--usr.sbin/quotaon/Makefile.depend20
-rw-r--r--usr.sbin/quotaon/quotaon.c19
-rw-r--r--usr.sbin/rarpd/Makefile3
-rw-r--r--usr.sbin/rarpd/Makefile.depend20
-rw-r--r--usr.sbin/rarpd/rarpd.814
-rw-r--r--usr.sbin/rarpd/rarpd.c80
-rw-r--r--usr.sbin/repquota/Makefile.depend20
-rw-r--r--usr.sbin/repquota/repquota.c19
-rw-r--r--usr.sbin/rip6query/Makefile.depend20
-rw-r--r--usr.sbin/rmt/Makefile.depend19
-rw-r--r--usr.sbin/rndc-confgen/Makefile.depend28
-rw-r--r--usr.sbin/rndc/Makefile.depend28
-rw-r--r--usr.sbin/route6d/Makefile.depend20
-rw-r--r--usr.sbin/rpc.lockd/Makefile.depend26
-rw-r--r--usr.sbin/rpc.lockd/lockd_lock.c2
-rw-r--r--usr.sbin/rpc.statd/Makefile.depend32
-rw-r--r--usr.sbin/rpc.umntall/Makefile.depend21
-rw-r--r--usr.sbin/rpc.yppasswdd/Makefile.depend49
-rw-r--r--usr.sbin/rpc.ypupdated/Makefile.depend30
-rw-r--r--usr.sbin/rpc.ypxfrd/Makefile.depend31
-rw-r--r--usr.sbin/rpcbind/Makefile.depend24
-rw-r--r--usr.sbin/rrenumd/Makefile.depend28
-rw-r--r--usr.sbin/rtadvctl/Makefile.depend20
-rw-r--r--usr.sbin/rtadvd/Makefile.depend21
-rw-r--r--usr.sbin/rtprio/Makefile.depend19
-rw-r--r--usr.sbin/rtprio/rtprio.110
-rw-r--r--usr.sbin/rtsold/Makefile.depend21
-rw-r--r--usr.sbin/rwhod/Makefile.depend21
-rw-r--r--usr.sbin/rwhod/rwhod.82
-rw-r--r--usr.sbin/sa/Makefile.depend19
-rw-r--r--usr.sbin/sade/Makefile.depend24
-rw-r--r--usr.sbin/sendmail/Makefile.depend107
-rw-r--r--usr.sbin/service/Makefile.depend14
-rw-r--r--usr.sbin/services_mkdb/Makefile2
-rw-r--r--usr.sbin/services_mkdb/Makefile.depend20
-rw-r--r--usr.sbin/services_mkdb/extern.h34
-rw-r--r--usr.sbin/services_mkdb/services_mkdb.c4
-rw-r--r--usr.sbin/services_mkdb/uniq.c3
-rw-r--r--usr.sbin/setfib/Makefile.depend19
-rw-r--r--usr.sbin/setfmac/Makefile.depend19
-rw-r--r--usr.sbin/setpmac/Makefile.depend19
-rw-r--r--usr.sbin/sicontrol/Makefile.depend19
-rw-r--r--usr.sbin/smbmsg/Makefile.depend19
-rw-r--r--usr.sbin/snapinfo/Makefile.depend20
-rw-r--r--usr.sbin/snapinfo/snapinfo.c3
-rw-r--r--usr.sbin/spkrtest/Makefile.depend14
-rw-r--r--usr.sbin/spray/Makefile.depend22
-rw-r--r--usr.sbin/syslogd/Makefile.depend21
-rw-r--r--usr.sbin/syslogd/syslog.conf.510
-rw-r--r--usr.sbin/syslogd/syslogd.c21
-rw-r--r--usr.sbin/sysrc/Makefile13
-rw-r--r--usr.sbin/sysrc/sysrc617
-rw-r--r--usr.sbin/sysrc/sysrc.8301
-rw-r--r--usr.sbin/tcpdchk/Makefile.depend21
-rw-r--r--usr.sbin/tcpdmatch/Makefile.depend21
-rw-r--r--usr.sbin/tcpdrop/Makefile.depend19
-rw-r--r--usr.sbin/tcpdump/tcpdump/Makefile4
-rw-r--r--usr.sbin/tcpdump/tcpdump/Makefile.depend25
-rw-r--r--usr.sbin/tcpdump/tcpdump/tcpdump.181
-rw-r--r--usr.sbin/timed/timed/Makefile.depend23
-rw-r--r--usr.sbin/timed/timed/master.c32
-rw-r--r--usr.sbin/timed/timed/measure.c6
-rw-r--r--usr.sbin/timed/timed/readmsg.c6
-rw-r--r--usr.sbin/timed/timed/slave.c28
-rw-r--r--usr.sbin/timed/timed/timed.c9
-rw-r--r--usr.sbin/timed/timedc/Makefile.depend21
-rw-r--r--usr.sbin/timed/timedc/cmds.c2
-rw-r--r--usr.sbin/traceroute/Makefile.depend23
-rw-r--r--usr.sbin/traceroute6/Makefile.depend21
-rw-r--r--usr.sbin/trpt/Makefile.depend20
-rw-r--r--usr.sbin/tzsetup/Makefile.depend22
-rw-r--r--usr.sbin/uathload/Makefile.depend19
-rw-r--r--usr.sbin/ugidfw/Makefile.depend20
-rw-r--r--usr.sbin/uhsoctl/Makefile.depend21
-rw-r--r--usr.sbin/usbconfig/Makefile.depend20
-rw-r--r--usr.sbin/usbdump/Makefile.depend19
-rw-r--r--usr.sbin/usbdump/usbdump.c26
-rw-r--r--usr.sbin/utx/Makefile.depend19
-rw-r--r--usr.sbin/vidcontrol/Makefile.depend19
-rw-r--r--usr.sbin/vidcontrol/vidcontrol.c14
-rw-r--r--usr.sbin/vipw/Makefile.depend20
-rw-r--r--usr.sbin/wake/Makefile.depend19
-rw-r--r--usr.sbin/watch/Makefile.depend21
-rw-r--r--usr.sbin/watchdogd/Makefile4
-rw-r--r--usr.sbin/watchdogd/Makefile.depend21
-rw-r--r--usr.sbin/watchdogd/watchdogd.c5
-rw-r--r--usr.sbin/wlandebug/Makefile.depend19
-rw-r--r--usr.sbin/wlconfig/Makefile.depend19
-rw-r--r--usr.sbin/wpa/hostapd/Makefile.depend23
-rw-r--r--usr.sbin/wpa/hostapd/hostapd.84
-rw-r--r--usr.sbin/wpa/hostapd_cli/Makefile.depend20
-rw-r--r--usr.sbin/wpa/ndis_events/Makefile.depend20
-rw-r--r--usr.sbin/wpa/wpa_cli/Makefile.depend23
-rw-r--r--usr.sbin/wpa/wpa_passphrase/Makefile.depend20
-rw-r--r--usr.sbin/wpa/wpa_supplicant/Makefile.depend23
-rw-r--r--usr.sbin/yp_mkdb/Makefile.depend21
-rw-r--r--usr.sbin/ypbind/Makefile.depend22
-rw-r--r--usr.sbin/yppoll/Makefile.depend21
-rw-r--r--usr.sbin/yppush/Makefile.depend29
-rw-r--r--usr.sbin/ypserv/Makefile.depend35
-rw-r--r--usr.sbin/ypset/Makefile.depend22
-rw-r--r--usr.sbin/zic/zdump/Makefile.depend19
-rw-r--r--usr.sbin/zic/zic/Makefile.depend19
-rw-r--r--usr.sbin/zzz/Makefile.depend14
671 files changed, 33214 insertions, 1968 deletions
diff --git a/usr.sbin/IPXrouted/Makefile.depend b/usr.sbin/IPXrouted/Makefile.depend
new file mode 100644
index 0000000..16b5e42
--- /dev/null
+++ b/usr.sbin/IPXrouted/Makefile.depend
@@ -0,0 +1,20 @@
+# Autogenerated - do NOT edit!
+
+DEP_RELDIR := ${_PARSEDIR:S,${SRCTOP}/,,}
+
+DEP_MACHINE := ${.PARSEFILE:E}
+
+DIRDEPS = \
+ gnu/lib/libgcc \
+ include \
+ include/arpa \
+ include/xlocale \
+ lib/${CSU_DIR} \
+ lib/libc \
+
+
+.include <dirdeps.mk>
+
+.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+# local dependencies - needed for -jN in clean tree
+.endif
diff --git a/usr.sbin/Makefile b/usr.sbin/Makefile
index ded1725..296856b 100644
--- a/usr.sbin/Makefile
+++ b/usr.sbin/Makefile
@@ -23,6 +23,7 @@ SUBDIR= adduser \
digictl \
diskinfo \
dumpcis \
+ etcupdate \
extattr \
extattrctl \
fifolog \
@@ -34,6 +35,7 @@ SUBDIR= adduser \
ifmcstat \
inetd \
iostat \
+ isfctl \
kldxref \
mailwrapper \
makefs \
@@ -44,7 +46,6 @@ SUBDIR= adduser \
mixer \
mlxcontrol \
mountd \
- mount_portalfs \
mptutil \
mtest \
mtree \
@@ -143,6 +144,11 @@ SUBDIR+= rndc-confgen
SUBDIR+= bluetooth
.endif
+.if ${MK_BSDCONFIG} != "no"
+SUBDIR+= bsdconfig
+SUBDIR+= sysrc
+.endif
+
.if ${MK_BSNMP} != "no"
SUBDIR+= bsnmpd
.endif
@@ -259,9 +265,12 @@ SUBDIR+= keyserv
SUBDIR+= ftp-proxy
.endif
+.if ${MK_PKGBOOTSTRAP} != "no"
+SUBDIR+= pkg
+.endif
+
.if ${MK_PKGTOOLS} != "no"
SUBDIR+= pkg_install
-SUBDIR+= pkg
.endif
# XXX MK_TOOLCHAIN?
diff --git a/usr.sbin/Makefile.amd64 b/usr.sbin/Makefile.amd64
index 232831b..26eb2b0 100644
--- a/usr.sbin/Makefile.amd64
+++ b/usr.sbin/Makefile.amd64
@@ -17,10 +17,6 @@ SUBDIR+= btxld
SUBDIR+= cpucontrol
SUBDIR+= kgmon
SUBDIR+= lptcontrol
-.if ${MK_NCP} != "no"
-SUBDIR+= mount_nwfs
-.endif
-SUBDIR+= mount_smbfs
SUBDIR+= mptable
.if ${MK_NDIS} != "no"
SUBDIR+= ndiscvt
diff --git a/usr.sbin/Makefile.i386 b/usr.sbin/Makefile.i386
index f7870dc..9588eb8 100644
--- a/usr.sbin/Makefile.i386
+++ b/usr.sbin/Makefile.i386
@@ -12,10 +12,6 @@ SUBDIR+= cpucontrol
SUBDIR+= kgmon
SUBDIR+= kgzip
SUBDIR+= lptcontrol
-.if ${MK_NCP} != "no"
-SUBDIR+= mount_nwfs
-.endif
-SUBDIR+= mount_smbfs
SUBDIR+= mptable
.if ${MK_NDIS} != "no"
SUBDIR+= ndiscvt
diff --git a/usr.sbin/Makefile.ia64 b/usr.sbin/Makefile.ia64
index 0a897b4..d047b33 100644
--- a/usr.sbin/Makefile.ia64
+++ b/usr.sbin/Makefile.ia64
@@ -4,6 +4,5 @@
SUBDIR+= acpi
.endif
SUBDIR+= kgmon
-SUBDIR+= mount_smbfs
SUBDIR:= ${SUBDIR:Nuathload}
SUBDIR+= zzz
diff --git a/usr.sbin/Makefile.powerpc b/usr.sbin/Makefile.powerpc
index 8833a27..131eb57 100644
--- a/usr.sbin/Makefile.powerpc
+++ b/usr.sbin/Makefile.powerpc
@@ -1,5 +1,4 @@
# $FreeBSD$
-SUBDIR+= mount_smbfs
SUBDIR+= nvram
SUBDIR+= ofwdump
diff --git a/usr.sbin/Makefile.sparc64 b/usr.sbin/Makefile.sparc64
index 320226d..479dafc 100644
--- a/usr.sbin/Makefile.sparc64
+++ b/usr.sbin/Makefile.sparc64
@@ -1,7 +1,6 @@
# $FreeBSD$
SUBDIR+= eeprom
-SUBDIR+= mount_smbfs
SUBDIR+= ofwdump
.if ${MK_SYSINSTALL} != "no"
SUBDIR+= sade
diff --git a/usr.sbin/ac/Makefile b/usr.sbin/ac/Makefile
index 576dbb3..0fac2fb 100644
--- a/usr.sbin/ac/Makefile
+++ b/usr.sbin/ac/Makefile
@@ -3,11 +3,6 @@
PROG= ac
MAN= ac.8
-# Temporary, while tracking down problem wrt 64-bit time_t's on sparc64
-.if ${MACHINE_CPUARCH} == "sparc64"
-CFLAGS+=-DDEBUG
-.endif
-
# If "CONSOLE_TTY" is not defined, this program is compatible with the
# traditional implementation (using SunOS 4.x as the sample traditional
# implementation). This is the default.
diff --git a/usr.sbin/ac/Makefile.depend b/usr.sbin/ac/Makefile.depend
new file mode 100644
index 0000000..a839545
--- /dev/null
+++ b/usr.sbin/ac/Makefile.depend
@@ -0,0 +1,19 @@
+# Autogenerated - do NOT edit!
+
+DEP_RELDIR := ${_PARSEDIR:S,${SRCTOP}/,,}
+
+DEP_MACHINE := ${.PARSEFILE:E}
+
+DIRDEPS = \
+ gnu/lib/libgcc \
+ include \
+ include/xlocale \
+ lib/${CSU_DIR} \
+ lib/libc \
+
+
+.include <dirdeps.mk>
+
+.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+# local dependencies - needed for -jN in clean tree
+.endif
diff --git a/usr.sbin/ac/ac.8 b/usr.sbin/ac/ac.8
index 63b5618..26667d8 100644
--- a/usr.sbin/ac/ac.8
+++ b/usr.sbin/ac/ac.8
@@ -11,11 +11,6 @@
.\" 2. Redistributions in binary form must reproduce the above copyright
.\" notice, this list of conditions and the following disclaimer in the
.\" documentation and/or other materials provided with the distribution.
-.\" 3. All advertising materials mentioning features or use of this software
-.\" must display the following acknowledgement:
-.\" This product includes software developed by Christopher G. Demetriou.
-.\" 3. The name of the author may not be used to endorse or promote products
-.\" derived from this software without specific prior written permission
.\"
.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
.\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
@@ -30,7 +25,7 @@
.\"
.\" $FreeBSD$
.\"
-.Dd March 15, 1994
+.Dd January 21, 2010
.Dt AC 8
.Os
.Sh NAME
diff --git a/usr.sbin/ac/ac.c b/usr.sbin/ac/ac.c
index 5dc8271..f5d4bda 100644
--- a/usr.sbin/ac/ac.c
+++ b/usr.sbin/ac/ac.c
@@ -1,23 +1,37 @@
-/*
- * Copyright (c) 1994 Christopher G. Demetriou.
- * @(#)Copyright (c) 1994, Simon J. Gerraty.
+/*-
+ * Copyright (c) 1994 Christopher G. Demetriou
+ * Copyright (c) 1994 Simon J. Gerraty
+ * Copyright (c) 2012 Ed Schouten <ed@FreeBSD.org>
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
*
- * This is free software. It comes with NO WARRANTY.
- * Permission to use, modify and distribute this source code
- * is granted subject to the following conditions.
- * 1/ that the above copyright notice and this notice
- * are preserved in all copies and that due credit be given
- * to the author.
- * 2/ that any changes to this code are clearly commented
- * as such so that the author does not get blamed for bugs
- * other than his own.
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
*/
#include <sys/cdefs.h>
__FBSDID("$FreeBSD$");
-#include <sys/types.h>
+#include <sys/queue.h>
#include <sys/time.h>
+
#include <err.h>
#include <errno.h>
#include <langinfo.h>
@@ -32,43 +46,47 @@ __FBSDID("$FreeBSD$");
/*
* this is for our list of currently logged in sessions
*/
-struct utmp_list {
- struct utmp_list *next;
- struct utmpx usr;
+struct utmpx_entry {
+ SLIST_ENTRY(utmpx_entry) next;
+ char user[sizeof(((struct utmpx *)0)->ut_user)];
+ char id[sizeof(((struct utmpx *)0)->ut_id)];
+#ifdef CONSOLE_TTY
+ char line[sizeof(((struct utmpx *)0)->ut_line)];
+#endif
+ struct timeval time;
};
/*
* this is for our list of users that are accumulating time.
*/
-struct user_list {
- struct user_list *next;
- char name[sizeof(((struct utmpx *)0)->ut_user)];
- time_t secs;
+struct user_entry {
+ SLIST_ENTRY(user_entry) next;
+ char user[sizeof(((struct utmpx *)0)->ut_user)];
+ struct timeval time;
};
/*
* this is for chosing whether to ignore a login
*/
-struct tty_list {
- struct tty_list *next;
- char name[sizeof(((struct utmpx *)0)->ut_host) + 2];
- size_t len;
- int ret;
+struct tty_entry {
+ SLIST_ENTRY(tty_entry) next;
+ char line[sizeof(((struct utmpx *)0)->ut_line) + 2];
+ size_t len;
+ int ret;
};
/*
* globals - yes yuk
*/
#ifdef CONSOLE_TTY
-static char *Console = CONSOLE_TTY;
+static const char *Console = CONSOLE_TTY;
#endif
-static time_t Total = 0;
-static time_t FirstTime = 0;
+static struct timeval Total = { 0, 0 };
+static struct timeval FirstTime = { 0, 0 };
static int Flags = 0;
-static struct user_list *Users = NULL;
-static struct tty_list *Ttys = NULL;
-
-#define NEW(type) (type *)malloc(sizeof (type))
+static SLIST_HEAD(, utmpx_entry) CurUtmpx = SLIST_HEAD_INITIALIZER(CurUtmpx);
+static SLIST_HEAD(, user_entry) Users = SLIST_HEAD_INITIALIZER(Users);
+static SLIST_HEAD(, tty_entry) Ttys = SLIST_HEAD_INITIALIZER(Ttys);
#define AC_W 1 /* not _PATH_WTMP */
#define AC_D 2 /* daily totals (ignore -p) */
@@ -76,182 +94,112 @@ static struct tty_list *Ttys = NULL;
#define AC_U 8 /* specified users only */
#define AC_T 16 /* specified ttys only */
-#ifdef DEBUG
-static int Debug = 0;
-#endif
+static void ac(const char *);
+static void usage(void);
-int main(int, char **);
-int ac(const char *);
-struct tty_list *add_tty(char *);
-#ifdef DEBUG
-const char *debug_pfx(const struct utmpx *, const struct utmpx *);
-#endif
-int do_tty(char *);
-struct utmp_list *log_in(struct utmp_list *, struct utmpx *);
-struct utmp_list *log_out(struct utmp_list *, struct utmpx *);
-int on_console(struct utmp_list *);
-void show(const char *, time_t);
-void show_today(struct user_list *, struct utmp_list *,
- time_t);
-void show_users(struct user_list *);
-struct user_list *update_user(struct user_list *, char *, time_t);
-void usage(void);
-
-struct tty_list *
-add_tty(char *name)
+static void
+add_tty(const char *line)
{
- struct tty_list *tp;
+ struct tty_entry *tp;
char *rcp;
Flags |= AC_T;
- if ((tp = NEW(struct tty_list)) == NULL)
+ if ((tp = malloc(sizeof(*tp))) == NULL)
errx(1, "malloc failed");
tp->len = 0; /* full match */
tp->ret = 1; /* do if match */
- if (*name == '!') { /* don't do if match */
+ if (*line == '!') { /* don't do if match */
tp->ret = 0;
- name++;
+ line++;
}
- strlcpy(tp->name, name, sizeof (tp->name));
- if ((rcp = strchr(tp->name, '*')) != NULL) { /* wild card */
+ strlcpy(tp->line, line, sizeof(tp->line));
+ /* Wildcard. */
+ if ((rcp = strchr(tp->line, '*')) != NULL) {
*rcp = '\0';
- tp->len = strlen(tp->name); /* match len bytes only */
+ /* Match len bytes only. */
+ tp->len = strlen(tp->line);
}
- tp->next = Ttys;
- Ttys = tp;
- return Ttys;
+ SLIST_INSERT_HEAD(&Ttys, tp, next);
}
/*
* should we process the named tty?
*/
-int
-do_tty(char *name)
+static int
+do_tty(const char *line)
{
- struct tty_list *tp;
+ struct tty_entry *tp;
int def_ret = 0;
- for (tp = Ttys; tp != NULL; tp = tp->next) {
+ SLIST_FOREACH(tp, &Ttys, next) {
if (tp->ret == 0) /* specific don't */
def_ret = 1; /* default do */
if (tp->len != 0) {
- if (strncmp(name, tp->name, tp->len) == 0)
+ if (strncmp(line, tp->line, tp->len) == 0)
return tp->ret;
} else {
- if (strncmp(name, tp->name, sizeof (tp->name)) == 0)
+ if (strncmp(line, tp->line, sizeof(tp->line)) == 0)
return tp->ret;
}
}
- return def_ret;
+ return (def_ret);
}
#ifdef CONSOLE_TTY
/*
* is someone logged in on Console?
*/
-int
-on_console(struct utmp_list *head)
+static int
+on_console(void)
{
- struct utmp_list *up;
+ struct utmpx_entry *up;
- for (up = head; up; up = up->next) {
- if (strcmp(up->usr.ut_line, Console) == 0)
- return 1;
- }
- return 0;
+ SLIST_FOREACH(up, &CurUtmpx, next)
+ if (strcmp(up->line, Console) == 0)
+ return (1);
+ return (0);
}
#endif
/*
- * update user's login time
+ * Update user's login time.
+ * If no entry for this user is found, a new entry is inserted into the
+ * list alphabetically.
*/
-struct user_list *
-update_user(struct user_list *head, char *name, time_t secs)
+static void
+update_user(const char *user, struct timeval secs)
{
- struct user_list *up;
+ struct user_entry *up, *aup;
+ int c;
- for (up = head; up != NULL; up = up->next) {
- if (strcmp(up->name, name) == 0) {
- up->secs += secs;
- Total += secs;
- return head;
- }
+ aup = NULL;
+ SLIST_FOREACH(up, &Users, next) {
+ c = strcmp(up->user, user);
+ if (c == 0) {
+ timeradd(&up->time, &secs, &up->time);
+ timeradd(&Total, &secs, &Total);
+ return;
+ } else if (c > 0)
+ break;
+ aup = up;
}
/*
* not found so add new user unless specified users only
*/
if (Flags & AC_U)
- return head;
+ return;
- if ((up = NEW(struct user_list)) == NULL)
+ if ((up = malloc(sizeof(*up))) == NULL)
errx(1, "malloc failed");
- up->next = head;
- strlcpy(up->name, name, sizeof (up->name));
- up->secs = secs;
- Total += secs;
- return up;
-}
-
-#ifdef DEBUG
-/*
- * Create a string which is the standard prefix for a debug line. It
- * includes a timestamp (perhaps with year), device-name, and user-name.
- */
-const char *
-debug_pfx(const struct utmpx *event_up, const struct utmpx *userinf_up)
-{
- static char str_result[40 + sizeof(userinf_up->ut_line) +
- sizeof(userinf_up->ut_user)];
- static char thisyear[5];
- size_t maxcopy;
- time_t ut_timecopy;
-
- if (thisyear[0] == '\0') {
- /* Figure out what "this year" is. */
- time(&ut_timecopy);
- strlcpy(str_result, ctime(&ut_timecopy), sizeof(str_result));
- strlcpy(thisyear, &str_result[20], sizeof(thisyear));
- }
-
- if (event_up->ut_tv.tv_sec == 0)
- strlcpy(str_result, "*ZeroTime* --:--:-- ", sizeof(str_result));
- else {
- ut_timecopy = event_up->ut_tv.tv_sec;
- strlcpy(str_result, ctime(&ut_timecopy), sizeof(str_result));
- /*
- * Include the year, if it is not the same year as "now".
- */
- if (strncmp(&str_result[20], thisyear, 4) == 0)
- str_result[20] = '\0';
- else {
- str_result[24] = ' '; /* Replace a '\n' */
- str_result[25] = '\0';
- }
- }
-
- if (userinf_up->ut_line[0] == '\0')
- strlcat(str_result, "NoDev", sizeof(str_result));
- else {
- maxcopy = strlen(str_result) + sizeof(userinf_up->ut_line);
- if (maxcopy > sizeof(str_result))
- maxcopy = sizeof(str_result);
- strlcat(str_result, userinf_up->ut_line, maxcopy);
- }
- strlcat(str_result, ": ", sizeof(str_result));
-
- if (userinf_up->ut_user[0] == '\0')
- strlcat(str_result, "LogOff", sizeof(str_result));
- else {
- maxcopy = strlen(str_result) + sizeof(userinf_up->ut_user);
- if (maxcopy > sizeof(str_result))
- maxcopy = sizeof(str_result);
- strlcat(str_result, userinf_up->ut_user, maxcopy);
- }
-
- return (str_result);
+ if (aup == NULL)
+ SLIST_INSERT_HEAD(&Users, up, next);
+ else
+ SLIST_INSERT_AFTER(aup, up, next);
+ strlcpy(up->user, user, sizeof(up->user));
+ up->time = secs;
+ timeradd(&Total, &secs, &Total);
}
-#endif
int
main(int argc, char *argv[])
@@ -261,13 +209,8 @@ main(int argc, char *argv[])
(void) setlocale(LC_TIME, "");
- while ((c = getopt(argc, argv, "Dc:dpt:w:")) != -1) {
+ while ((c = getopt(argc, argv, "c:dpt:w:")) != -1) {
switch (c) {
-#ifdef DEBUG
- case 'D':
- Debug++;
- break;
-#endif
case 'c':
#ifdef CONSOLE_TTY
Console = optarg;
@@ -299,7 +242,7 @@ main(int argc, char *argv[])
* initialize user list
*/
for (; optind < argc; optind++) {
- Users = update_user(Users, argv[optind], (time_t)0);
+ update_user(argv[optind], (struct timeval){ 0, 0 });
}
Flags |= AC_U; /* freeze user list */
}
@@ -307,113 +250,103 @@ main(int argc, char *argv[])
Flags &= ~AC_P;
ac(wtmpf);
- return 0;
+ return (0);
}
/*
* print login time in decimal hours
*/
-void
-show(const char *name, time_t secs)
+static void
+show(const char *user, struct timeval secs)
{
(void)printf("\t%-*s %8.2f\n",
- (int)sizeof(((struct utmpx *)0)->ut_user), name,
- ((double)secs / 3600));
+ (int)sizeof(((struct user_entry *)0)->user), user,
+ (double)secs.tv_sec / 3600);
}
-void
-show_users(struct user_list *list)
+static void
+show_users(void)
{
- struct user_list *lp;
+ struct user_entry *lp;
- for (lp = list; lp; lp = lp->next)
- show(lp->name, lp->secs);
+ SLIST_FOREACH(lp, &Users, next)
+ show(lp->user, lp->time);
}
/*
* print total login time for 24hr period in decimal hours
*/
-void
-show_today(struct user_list *users, struct utmp_list *logins, time_t secs)
+static void
+show_today(struct timeval today)
{
- struct user_list *up;
- struct utmp_list *lp;
+ struct user_entry *up;
+ struct utmpx_entry *lp;
char date[64];
- time_t yesterday = secs - 1;
+ struct timeval diff, total = { 0, 0 }, usec = { 0, 1 }, yesterday;
static int d_first = -1;
if (d_first < 0)
d_first = (*nl_langinfo(D_MD_ORDER) == 'd');
- (void)strftime(date, sizeof (date),
+ timersub(&today, &usec, &yesterday);
+ (void)strftime(date, sizeof(date),
d_first ? "%e %b total" : "%b %e total",
- localtime(&yesterday));
+ localtime(&yesterday.tv_sec));
- /* restore the missing second */
- yesterday++;
-
- for (lp = logins; lp != NULL; lp = lp->next) {
- secs = yesterday - lp->usr.ut_tv.tv_sec;
- Users = update_user(Users, lp->usr.ut_user, secs);
- lp->usr.ut_tv.tv_sec = yesterday; /* as if they just logged in */
+ SLIST_FOREACH(lp, &CurUtmpx, next) {
+ timersub(&today, &lp->time, &diff);
+ update_user(lp->user, diff);
+ /* As if they just logged in. */
+ lp->time = today;
}
- secs = 0;
- for (up = users; up != NULL; up = up->next) {
- secs += up->secs;
- up->secs = 0; /* for next day */
+ SLIST_FOREACH(up, &Users, next) {
+ timeradd(&total, &up->time, &total);
+ /* For next day. */
+ timerclear(&up->time);
}
- if (secs)
- (void)printf("%s %11.2f\n", date, ((double)secs / 3600));
+ if (timerisset(&total))
+ (void)printf("%s %11.2f\n", date, (double)total.tv_sec / 3600);
}
/*
- * log a user out and update their times.
- * if ut_line is "~", we log all users out as the system has
- * been shut down.
+ * Log a user out and update their times.
+ * If ut_type is BOOT_TIME or SHUTDOWN_TIME, we log all users out as the
+ * system has been shut down.
*/
-struct utmp_list *
-log_out(struct utmp_list *head, struct utmpx *up)
+static void
+log_out(const struct utmpx *up)
{
- struct utmp_list *lp, *lp2, *tlp;
- time_t secs;
+ struct utmpx_entry *lp, *lp2, *tlp;
+ struct timeval secs;
- for (lp = head, lp2 = NULL; lp != NULL; )
+ for (lp = SLIST_FIRST(&CurUtmpx), lp2 = NULL; lp != NULL;)
if (up->ut_type == BOOT_TIME || up->ut_type == SHUTDOWN_TIME ||
(up->ut_type == DEAD_PROCESS &&
- memcmp(lp->usr.ut_id, up->ut_id, sizeof up->ut_id) == 0)) {
- secs = up->ut_tv.tv_sec - lp->usr.ut_tv.tv_sec;
- Users = update_user(Users, lp->usr.ut_user, secs);
-#ifdef DEBUG
- if (Debug)
- printf("%s logged out (%2d:%02d:%02d)\n",
- debug_pfx(up, &lp->usr), (int)(secs / 3600),
- (int)((secs % 3600) / 60),
- (int)(secs % 60));
-#endif
+ memcmp(lp->id, up->ut_id, sizeof(up->ut_id)) == 0)) {
+ timersub(&up->ut_tv, &lp->time, &secs);
+ update_user(lp->user, secs);
/*
* now lose it
*/
tlp = lp;
- lp = lp->next;
- if (tlp == head)
- head = lp;
- else if (lp2 != NULL)
- lp2->next = lp;
+ lp = SLIST_NEXT(lp, next);
+ if (lp2 == NULL)
+ SLIST_REMOVE_HEAD(&CurUtmpx, next);
+ else
+ SLIST_REMOVE_AFTER(lp2, next);
free(tlp);
} else {
lp2 = lp;
- lp = lp->next;
+ lp = SLIST_NEXT(lp, next);
}
- return head;
}
-
/*
* if do_tty says ok, login a user
*/
-struct utmp_list *
-log_in(struct utmp_list *head, struct utmpx *up)
+static void
+log_in(struct utmpx *up)
{
- struct utmp_list *lp;
+ struct utmpx_entry *lp;
/*
* this could be a login. if we're not dealing with
@@ -432,198 +365,150 @@ log_in(struct utmp_list *head, struct utmpx *up)
* SunOS 4.0.2 does not treat ":0.0" as special but we
* do.
*/
- if (on_console(head))
- return head;
+ if (on_console())
+ return;
/*
* ok, no recorded login, so they were here when wtmp
* started! Adjust ut_time!
*/
- up->ut_time = FirstTime;
+ up->ut_tv = FirstTime;
/*
* this allows us to pick the right logout
*/
- strlcpy(up->ut_line, Console, sizeof (up->ut_line));
+ strlcpy(up->ut_line, Console, sizeof(up->ut_line));
}
#endif
/*
* If we are doing specified ttys only, we ignore
* anything else.
*/
- if (Flags & AC_T)
- if (!do_tty(up->ut_line))
- return head;
+ if (Flags & AC_T && !do_tty(up->ut_line))
+ return;
/*
* go ahead and log them in
*/
- if ((lp = NEW(struct utmp_list)) == NULL)
+ if ((lp = malloc(sizeof(*lp))) == NULL)
errx(1, "malloc failed");
- lp->next = head;
- head = lp;
- memmove(&lp->usr, up, sizeof *up);
-#ifdef DEBUG
- if (Debug) {
- printf("%s logged in", debug_pfx(&lp->usr, up));
- if (*up->ut_host)
- printf(" (%-.*s)", (int)sizeof(up->ut_host),
- up->ut_host);
- putchar('\n');
- }
+ SLIST_INSERT_HEAD(&CurUtmpx, lp, next);
+ strlcpy(lp->user, up->ut_user, sizeof(lp->user));
+ memcpy(lp->id, up->ut_id, sizeof(lp->id));
+#ifdef CONSOLE_TTY
+ memcpy(lp->line, up->ut_line, sizeof(lp->line));
#endif
- return head;
+ lp->time = up->ut_tv;
}
-int
+static void
ac(const char *file)
{
- struct utmp_list *lp, *head = NULL;
+ struct utmpx_entry *lp;
struct utmpx *usr, usht;
struct tm *ltm;
- time_t prev_secs, secs, ut_timecopy;
- int day, rfound, tchanged, tskipped;
+ struct timeval prev_secs, ut_timecopy, secs, clock_shift, now;
+ int day, rfound;
day = -1;
- prev_secs = 1; /* Minimum acceptable date == 1970 */
- rfound = tchanged = tskipped = 0;
- secs = 0;
+ timerclear(&prev_secs); /* Minimum acceptable date == 1970. */
+ timerclear(&secs);
+ timerclear(&clock_shift);
+ rfound = 0;
if (setutxdb(UTXDB_LOG, file) != 0)
err(1, "%s", file);
while ((usr = getutxent()) != NULL) {
rfound++;
- ut_timecopy = usr->ut_tv.tv_sec;
- /*
- * With sparc64 using 64-bit time_t's, there is some system
- * routine which sets ut_time==0 (the high-order word of a
- * 64-bit time) instead of a 32-bit time value. For those
- * wtmp files, it is "more-accurate" to substitute the most-
- * recent time found, instead of throwing away the entire
- * record. While it is still just a guess, it is a better
- * guess than throwing away a log-off record and therefore
- * counting a session as if it continued to the end of the
- * month, or the next system-reboot.
- */
- if (ut_timecopy == 0 && prev_secs > 1) {
-#ifdef DEBUG
- if (Debug)
- printf("%s - date changed to: %s",
- debug_pfx(usr, usr), ctime(&prev_secs));
-#endif
- tchanged++;
- usr->ut_tv.tv_sec = ut_timecopy = prev_secs;
- }
- /*
- * Skip records where the time goes backwards.
- */
- if (ut_timecopy < prev_secs) {
-#ifdef DEBUG
- if (Debug)
- printf("%s - bad date, record skipped\n",
- debug_pfx(usr, usr));
-#endif
- tskipped++;
- continue; /* Skip this invalid record. */
- }
+ ut_timecopy = usr->ut_tv;
+ /* Don't let the time run backwards. */
+ if (timercmp(&ut_timecopy, &prev_secs, <))
+ ut_timecopy = prev_secs;
prev_secs = ut_timecopy;
- if (!FirstTime)
+ if (!timerisset(&FirstTime))
FirstTime = ut_timecopy;
if (Flags & AC_D) {
- ltm = localtime(&ut_timecopy);
+ ltm = localtime(&ut_timecopy.tv_sec);
if (day >= 0 && day != ltm->tm_yday) {
day = ltm->tm_yday;
/*
* print yesterday's total
*/
secs = ut_timecopy;
- secs -= ltm->tm_sec;
- secs -= 60 * ltm->tm_min;
- secs -= 3600 * ltm->tm_hour;
- show_today(Users, head, secs);
+ secs.tv_sec -= ltm->tm_sec;
+ secs.tv_sec -= 60 * ltm->tm_min;
+ secs.tv_sec -= 3600 * ltm->tm_hour;
+ secs.tv_usec = 0;
+ show_today(secs);
} else
day = ltm->tm_yday;
}
switch(usr->ut_type) {
case OLD_TIME:
- secs = ut_timecopy;
+ clock_shift = ut_timecopy;
break;
case NEW_TIME:
- secs -= ut_timecopy;
+ timersub(&clock_shift, &ut_timecopy, &clock_shift);
/*
* adjust time for those logged in
*/
- for (lp = head; lp != NULL; lp = lp->next)
- lp->usr.ut_tv.tv_sec -= secs;
+ SLIST_FOREACH(lp, &CurUtmpx, next)
+ timersub(&lp->time, &clock_shift, &lp->time);
break;
case BOOT_TIME:
case SHUTDOWN_TIME:
- head = log_out(head, usr);
+ log_out(usr);
FirstTime = ut_timecopy; /* shouldn't be needed */
break;
case USER_PROCESS:
/*
- * if they came in on tty[p-sP-S]*, then it is only
- * a login session if the ut_host field is non-empty
+ * If they came in on pts/..., then it is only
+ * a login session if the ut_host field is non-empty.
*/
- if (strncmp(usr->ut_line, "tty", 3) != 0 ||
- strchr("pqrsPQRS", usr->ut_line[3]) == NULL ||
+ if (strncmp(usr->ut_line, "pts/", 4) != 0 ||
*usr->ut_host != '\0')
- head = log_in(head, usr);
-#ifdef DEBUG
- else if (Debug > 1)
- /* Things such as 'screen' sessions. */
- printf("%s - record ignored\n",
- debug_pfx(usr, usr));
-#endif
+ log_in(usr);
break;
case DEAD_PROCESS:
- head = log_out(head, usr);
+ log_out(usr);
break;
}
}
endutxent();
- if (!(Flags & AC_W))
- usht.ut_tv.tv_sec = time(NULL);
+ (void)gettimeofday(&now, NULL);
+ if (Flags & AC_W)
+ usht.ut_tv = ut_timecopy;
else
- usht.ut_tv.tv_sec = ut_timecopy;
+ usht.ut_tv = now;
usht.ut_type = SHUTDOWN_TIME;
if (Flags & AC_D) {
- ltm = localtime(&ut_timecopy);
+ ltm = localtime(&ut_timecopy.tv_sec);
if (day >= 0 && day != ltm->tm_yday) {
/*
* print yesterday's total
*/
secs = ut_timecopy;
- secs -= ltm->tm_sec;
- secs -= 60 * ltm->tm_min;
- secs -= 3600 * ltm->tm_hour;
- show_today(Users, head, secs);
+ secs.tv_sec -= ltm->tm_sec;
+ secs.tv_sec -= 60 * ltm->tm_min;
+ secs.tv_sec -= 3600 * ltm->tm_hour;
+ secs.tv_usec = 0;
+ show_today(secs);
}
}
/*
* anyone still logged in gets time up to now
*/
- head = log_out(head, &usht);
+ log_out(&usht);
if (Flags & AC_D)
- show_today(Users, head, time((time_t *)0));
+ show_today(now);
else {
if (Flags & AC_P)
- show_users(Users);
+ show_users();
show("total", Total);
}
-
- if (tskipped > 0)
- printf("(Skipped %d of %d records due to invalid time values)\n",
- tskipped, rfound);
- if (tchanged > 0)
- printf("(Changed %d of %d records to have a more likely time value)\n",
- tchanged, rfound);
-
- return 0;
}
-void
+static void
usage(void)
{
(void)fprintf(stderr,
diff --git a/usr.sbin/accton/Makefile.depend b/usr.sbin/accton/Makefile.depend
new file mode 100644
index 0000000..a839545
--- /dev/null
+++ b/usr.sbin/accton/Makefile.depend
@@ -0,0 +1,19 @@
+# Autogenerated - do NOT edit!
+
+DEP_RELDIR := ${_PARSEDIR:S,${SRCTOP}/,,}
+
+DEP_MACHINE := ${.PARSEFILE:E}
+
+DIRDEPS = \
+ gnu/lib/libgcc \
+ include \
+ include/xlocale \
+ lib/${CSU_DIR} \
+ lib/libc \
+
+
+.include <dirdeps.mk>
+
+.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+# local dependencies - needed for -jN in clean tree
+.endif
diff --git a/usr.sbin/acpi/acpiconf/Makefile.depend b/usr.sbin/acpi/acpiconf/Makefile.depend
new file mode 100644
index 0000000..a839545
--- /dev/null
+++ b/usr.sbin/acpi/acpiconf/Makefile.depend
@@ -0,0 +1,19 @@
+# Autogenerated - do NOT edit!
+
+DEP_RELDIR := ${_PARSEDIR:S,${SRCTOP}/,,}
+
+DEP_MACHINE := ${.PARSEFILE:E}
+
+DIRDEPS = \
+ gnu/lib/libgcc \
+ include \
+ include/xlocale \
+ lib/${CSU_DIR} \
+ lib/libc \
+
+
+.include <dirdeps.mk>
+
+.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+# local dependencies - needed for -jN in clean tree
+.endif
diff --git a/usr.sbin/acpi/acpidb/Makefile b/usr.sbin/acpi/acpidb/Makefile
index 9d2d7ec..eab9e38 100644
--- a/usr.sbin/acpi/acpidb/Makefile
+++ b/usr.sbin/acpi/acpidb/Makefile
@@ -52,14 +52,15 @@ SRCS+= rsaddr.c rscalc.c rscreate.c rsdump.c rsinfo.c \
rsserial.c rsutils.c rsxface.c
# components/tables
-SRCS+= tbfadt.c tbfind.c tbinstal.c tbutils.c tbxface.c
+SRCS+= tbfadt.c tbfind.c tbinstal.c tbutils.c tbxface.c \
+ tbxfload.c
# components/utilities
SRCS+= utaddress.c utalloc.c utcache.c utcopy.c utdebug.c \
- utdecode.c utdelete.c uteval.c utglobal.c utids.c \
- utinit.c utlock.c utmath.c utmisc.c utmutex.c \
+ utdecode.c utdelete.c uteval.c utexcep.c utglobal.c \
+ utids.c utinit.c utlock.c utmath.c utmisc.c utmutex.c \
utobject.c utosi.c utresrc.c utstate.c uttrack.c \
- utxface.c utxferror.c
+ utxface.c utxferror.c utxfinit.c
MAN= acpidb.8
WARNS?= 2
diff --git a/usr.sbin/acpi/acpidb/Makefile.depend b/usr.sbin/acpi/acpidb/Makefile.depend
new file mode 100644
index 0000000..a274268
--- /dev/null
+++ b/usr.sbin/acpi/acpidb/Makefile.depend
@@ -0,0 +1,20 @@
+# Autogenerated - do NOT edit!
+
+DEP_RELDIR := ${_PARSEDIR:S,${SRCTOP}/,,}
+
+DEP_MACHINE := ${.PARSEFILE:E}
+
+DIRDEPS = \
+ gnu/lib/libgcc \
+ include \
+ include/xlocale \
+ lib/${CSU_DIR} \
+ lib/libc \
+ lib/libthr \
+
+
+.include <dirdeps.mk>
+
+.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+# local dependencies - needed for -jN in clean tree
+.endif
diff --git a/usr.sbin/acpi/acpidump/Makefile.depend b/usr.sbin/acpi/acpidump/Makefile.depend
new file mode 100644
index 0000000..a839545
--- /dev/null
+++ b/usr.sbin/acpi/acpidump/Makefile.depend
@@ -0,0 +1,19 @@
+# Autogenerated - do NOT edit!
+
+DEP_RELDIR := ${_PARSEDIR:S,${SRCTOP}/,,}
+
+DEP_MACHINE := ${.PARSEFILE:E}
+
+DIRDEPS = \
+ gnu/lib/libgcc \
+ include \
+ include/xlocale \
+ lib/${CSU_DIR} \
+ lib/libc \
+
+
+.include <dirdeps.mk>
+
+.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+# local dependencies - needed for -jN in clean tree
+.endif
diff --git a/usr.sbin/acpi/acpidump/acpi.c b/usr.sbin/acpi/acpidump/acpi.c
index f8ac2a3..b0a751c 100644
--- a/usr.sbin/acpi/acpidump/acpi.c
+++ b/usr.sbin/acpi/acpidump/acpi.c
@@ -63,6 +63,7 @@ static void acpi_handle_madt(ACPI_TABLE_HEADER *sdp);
static void acpi_handle_ecdt(ACPI_TABLE_HEADER *sdp);
static void acpi_handle_hpet(ACPI_TABLE_HEADER *sdp);
static void acpi_handle_mcfg(ACPI_TABLE_HEADER *sdp);
+static void acpi_handle_slit(ACPI_TABLE_HEADER *sdp);
static void acpi_print_srat_cpu(uint32_t apic_id, uint32_t proximity_domain,
uint32_t flags);
static void acpi_print_srat_memory(ACPI_SRAT_MEM_AFFINITY *mp);
@@ -339,12 +340,13 @@ acpi_print_local_nmi(u_int lint, uint16_t mps_flags)
acpi_print_mps_flags(mps_flags);
}
-const char *apic_types[] = { "Local APIC", "IO APIC", "INT Override", "NMI",
- "Local APIC NMI", "Local APIC Override",
- "IO SAPIC", "Local SAPIC", "Platform Interrupt",
- "Local X2APIC", "Local X2APIC NMI" };
-const char *platform_int_types[] = { "0 (unknown)", "PMI", "INIT",
- "Corrected Platform Error" };
+static const char *apic_types[] = { "Local APIC", "IO APIC", "INT Override",
+ "NMI", "Local APIC NMI",
+ "Local APIC Override", "IO SAPIC",
+ "Local SAPIC", "Platform Interrupt",
+ "Local X2APIC", "Local X2APIC NMI" };
+static const char *platform_int_types[] = { "0 (unknown)", "PMI", "INIT",
+ "Corrected Platform Error" };
static void
acpi_print_madt(ACPI_SUBTABLE_HEADER *mp)
@@ -519,6 +521,33 @@ acpi_handle_mcfg(ACPI_TABLE_HEADER *sdp)
}
static void
+acpi_handle_slit(ACPI_TABLE_HEADER *sdp)
+{
+ ACPI_TABLE_SLIT *slit;
+ UINT64 i, j;
+
+ printf(BEGIN_COMMENT);
+ acpi_print_sdt(sdp);
+ slit = (ACPI_TABLE_SLIT *)sdp;
+ printf("\tLocality Count=%jd\n", slit->LocalityCount);
+ printf("\n\t ");
+ for (i = 0; i < slit->LocalityCount; i++)
+ printf(" %3jd", i);
+ printf("\n\t +");
+ for (i = 0; i < slit->LocalityCount; i++)
+ printf("----");
+ printf("\n");
+ for (i = 0; i < slit->LocalityCount; i++) {
+ printf("\t %3jd |", i);
+ for (j = 0; j < slit->LocalityCount; j++)
+ printf(" %3d",
+ slit->Entry[i * slit->LocalityCount + j]);
+ printf("\n");
+ }
+ printf(END_COMMENT);
+}
+
+static void
acpi_print_srat_cpu(uint32_t apic_id, uint32_t proximity_domain,
uint32_t flags)
{
@@ -654,16 +683,24 @@ acpi_handle_tcpa(ACPI_TABLE_HEADER *sdp)
printf(END_COMMENT);
return;
}
+ if(sdp->Revision == 1){
+ printf("\tOLD TCPA spec log found. Dumping not supported.\n");
+ printf(END_COMMENT);
+ return;
+ }
vaddr = (unsigned char *)acpi_map_physical(paddr, len);
vend = vaddr + len;
while (vaddr != NULL) {
- if (vaddr + sizeof(struct TCPAevent) >= vend)
+ if ((vaddr + sizeof(struct TCPAevent) >= vend)||
+ (vaddr + sizeof(struct TCPAevent) < vaddr))
break;
event = (struct TCPAevent *)(void *)vaddr;
if (vaddr + event->event_size >= vend)
break;
+ if (vaddr + event->event_size < vaddr)
+ break;
if (event->event_type == 0 && event->event_size == 0)
break;
#if 0
@@ -711,7 +748,7 @@ acpi_print_srat_memory(ACPI_SRAT_MEM_AFFINITY *mp)
printf("\tProximity Domain=%d\n", mp->ProximityDomain);
}
-const char *srat_types[] = { "CPU", "Memory", "X2APIC" };
+static const char *srat_types[] = { "CPU", "Memory", "X2APIC" };
static void
acpi_print_srat(ACPI_SUBTABLE_HEADER *srat)
@@ -1084,6 +1121,8 @@ acpi_handle_rsdt(ACPI_TABLE_HEADER *rsdp)
acpi_handle_ecdt(sdp);
else if (!memcmp(sdp->Signature, ACPI_SIG_MCFG, 4))
acpi_handle_mcfg(sdp);
+ else if (!memcmp(sdp->Signature, ACPI_SIG_SLIT, 4))
+ acpi_handle_slit(sdp);
else if (!memcmp(sdp->Signature, ACPI_SIG_SRAT, 4))
acpi_handle_srat(sdp);
else if (!memcmp(sdp->Signature, ACPI_SIG_TCPA, 4))
diff --git a/usr.sbin/acpi/acpidump/acpi_user.c b/usr.sbin/acpi/acpidump/acpi_user.c
index 86e581f..0b2beb2 100644
--- a/usr.sbin/acpi/acpidump/acpi_user.c
+++ b/usr.sbin/acpi/acpidump/acpi_user.c
@@ -53,7 +53,7 @@ struct acpi_user_mapping {
size_t size;
};
-LIST_HEAD(acpi_user_mapping_list, acpi_user_mapping) maplist;
+static LIST_HEAD(acpi_user_mapping_list, acpi_user_mapping) maplist;
static void
acpi_user_init(void)
diff --git a/usr.sbin/acpi/iasl/Makefile b/usr.sbin/acpi/iasl/Makefile
index 58f9429..6c263ce 100644
--- a/usr.sbin/acpi/iasl/Makefile
+++ b/usr.sbin/acpi/iasl/Makefile
@@ -4,8 +4,8 @@ PROG= iasl
SRCS= adfile.c adisasm.c adwalk.c
# common
-SRCS+= dmextern.c dmrestag.c dmtable.c dmtbdump.c dmtbinfo.c \
- getopt.c
+SRCS+= ahpredef.c dmextern.c dmrestag.c dmtable.c dmtbdump.c \
+ dmtbinfo.c getopt.c
# compiler
SRCS+= aslanalyze.c aslbtypes.c aslcodegen.c aslcompile.c \
@@ -54,9 +54,9 @@ SRCS+= tbfadt.c tbinstal.c tbutils.c tbxface.c
# components/utilities
SRCS+= utaddress.c utalloc.c utcache.c utcopy.c utdebug.c \
- utdecode.c utdelete.c utglobal.c utinit.c utlock.c \
- utmath.c utmisc.c utmutex.c utobject.c utresrc.c \
- utstate.c utxface.c utxferror.c
+ utdecode.c utdelete.c utexcep.c utglobal.c utinit.c \
+ utlock.c utmath.c utmisc.c utmutex.c utobject.c \
+ utresrc.c utstate.c utxface.c utxferror.c
# os_specific/service_layers
SRCS+= osunixxf.c
diff --git a/usr.sbin/acpi/iasl/Makefile.depend b/usr.sbin/acpi/iasl/Makefile.depend
new file mode 100644
index 0000000..ffc65ca
--- /dev/null
+++ b/usr.sbin/acpi/iasl/Makefile.depend
@@ -0,0 +1,87 @@
+# Autogenerated - do NOT edit!
+
+DEP_RELDIR := ${_PARSEDIR:S,${SRCTOP}/,,}
+
+DEP_MACHINE := ${.PARSEFILE:E}
+
+DIRDEPS = \
+ gnu/lib/libgcc \
+ include \
+ include/xlocale \
+ lib/${CSU_DIR} \
+ lib/libc \
+
+
+.include <dirdeps.mk>
+
+.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+# local dependencies - needed for -jN in clean tree
+aslanalyze.o: aslcompiler.y.h
+aslanalyze.po: aslcompiler.y.h
+aslbtypes.o: aslcompiler.y.h
+aslbtypes.po: aslcompiler.y.h
+aslcodegen.o: aslcompiler.y.h
+aslcodegen.po: aslcompiler.y.h
+aslcompilerlex.o: aslcompiler.y.h
+aslcompilerlex.o: aslcompilerlex.c
+aslcompilerlex.po: aslcompiler.y.h
+aslcompilerlex.po: aslcompilerlex.c
+aslcompilerparse.o: aslcompilerparse.c
+aslcompilerparse.po: aslcompilerparse.c
+aslfold.o: aslcompiler.y.h
+aslfold.po: aslcompiler.y.h
+asllength.o: aslcompiler.y.h
+asllength.po: aslcompiler.y.h
+asllisting.o: aslcompiler.y.h
+asllisting.po: aslcompiler.y.h
+aslload.o: aslcompiler.y.h
+aslload.po: aslcompiler.y.h
+asllookup.o: aslcompiler.y.h
+asllookup.po: aslcompiler.y.h
+aslopcodes.o: aslcompiler.y.h
+aslopcodes.po: aslcompiler.y.h
+asloperands.o: aslcompiler.y.h
+asloperands.po: aslcompiler.y.h
+aslopt.o: aslcompiler.y.h
+aslopt.po: aslcompiler.y.h
+aslpredef.o: aslcompiler.y.h
+aslpredef.po: aslcompiler.y.h
+aslresource.o: aslcompiler.y.h
+aslresource.po: aslcompiler.y.h
+aslrestype1.o: aslcompiler.y.h
+aslrestype1.po: aslcompiler.y.h
+aslrestype1i.o: aslcompiler.y.h
+aslrestype1i.po: aslcompiler.y.h
+aslrestype2.o: aslcompiler.y.h
+aslrestype2.po: aslcompiler.y.h
+aslrestype2d.o: aslcompiler.y.h
+aslrestype2d.po: aslcompiler.y.h
+aslrestype2q.o: aslcompiler.y.h
+aslrestype2q.po: aslcompiler.y.h
+aslrestype2s.o: aslcompiler.y.h
+aslrestype2s.po: aslcompiler.y.h
+aslrestype2w.o: aslcompiler.y.h
+aslrestype2w.po: aslcompiler.y.h
+asltransform.o: aslcompiler.y.h
+asltransform.po: aslcompiler.y.h
+asltree.o: aslcompiler.y.h
+asltree.po: aslcompiler.y.h
+aslutils.o: aslcompiler.y.h
+aslutils.po: aslcompiler.y.h
+aslwalks.o: aslcompiler.y.h
+aslwalks.po: aslcompiler.y.h
+dtexpress.o: dtparser.y.h
+dtexpress.po: dtparser.y.h
+dtparserlex.o: dtparser.y.h
+dtparserlex.o: dtparserlex.c
+dtparserlex.po: dtparser.y.h
+dtparserlex.po: dtparserlex.c
+dtparserparse.o: dtparserparse.c
+dtparserparse.po: dtparserparse.c
+prparserlex.o: prparser.y.h
+prparserlex.o: prparserlex.c
+prparserlex.po: prparser.y.h
+prparserlex.po: prparserlex.c
+prparserparse.o: prparserparse.c
+prparserparse.po: prparserparse.c
+.endif
diff --git a/usr.sbin/adduser/Makefile.depend b/usr.sbin/adduser/Makefile.depend
new file mode 100644
index 0000000..29fda55
--- /dev/null
+++ b/usr.sbin/adduser/Makefile.depend
@@ -0,0 +1,14 @@
+# Autogenerated - do NOT edit!
+
+DEP_RELDIR := ${_PARSEDIR:S,${SRCTOP}/,,}
+
+DEP_MACHINE := ${.PARSEFILE:E}
+
+DIRDEPS = \
+
+
+.include <dirdeps.mk>
+
+.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+# local dependencies - needed for -jN in clean tree
+.endif
diff --git a/usr.sbin/adduser/adduser.8 b/usr.sbin/adduser/adduser.8
index 03f7e34..f23ecff 100644
--- a/usr.sbin/adduser/adduser.8
+++ b/usr.sbin/adduser/adduser.8
@@ -26,7 +26,7 @@
.\"
.\" $FreeBSD$
.\"
-.Dd March 16, 2008
+.Dd September 15, 2012
.Dt ADDUSER 8
.Os
.Sh NAME
@@ -129,9 +129,8 @@ they can safely run with a umask of 002 instead of the usual 022
and create files in their home directory
without worrying about others being able to change them.
.Pp
-For a shared area you create a separate UID/GID (like cvs or ncvs on freefall),
-you place each person that should be able to access this area into that new
-group.
+For a shared area you create a separate UID/GID, you place each person
+that should be able to access this area into that new group.
.Pp
This model of UID/GID administration allows far greater flexibility than lumping
users into groups and having to muck with the umask when working in a shared
diff --git a/usr.sbin/amd/amd/Makefile.depend b/usr.sbin/amd/amd/Makefile.depend
new file mode 100644
index 0000000..fd1a688
--- /dev/null
+++ b/usr.sbin/amd/amd/Makefile.depend
@@ -0,0 +1,33 @@
+# Autogenerated - do NOT edit!
+
+DEP_RELDIR := ${_PARSEDIR:S,${SRCTOP}/,,}
+
+DEP_MACHINE := ${.PARSEFILE:E}
+
+DIRDEPS = \
+ gnu/lib/libgcc \
+ include \
+ include/arpa \
+ include/rpc \
+ include/rpcsvc \
+ include/xlocale \
+ lib/${CSU_DIR} \
+ lib/libc \
+ lib/libwrap \
+ usr.sbin/amd/include \
+ usr.sbin/amd/libamu \
+
+
+.include <dirdeps.mk>
+
+.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+# local dependencies - needed for -jN in clean tree
+conf_parse.o: conf_parse.c
+conf_parse.po: conf_parse.c
+conf_tok.o: conf_parse.h
+conf_tok.o: conf_tok.c
+conf_tok.po: conf_parse.h
+conf_tok.po: conf_tok.c
+mount_xdr.o: mount_xdr.c
+mount_xdr.po: mount_xdr.c
+.endif
diff --git a/usr.sbin/amd/amq/Makefile.depend b/usr.sbin/amd/amq/Makefile.depend
new file mode 100644
index 0000000..66f893e
--- /dev/null
+++ b/usr.sbin/amd/amq/Makefile.depend
@@ -0,0 +1,25 @@
+# Autogenerated - do NOT edit!
+
+DEP_RELDIR := ${_PARSEDIR:S,${SRCTOP}/,,}
+
+DEP_MACHINE := ${.PARSEFILE:E}
+
+DIRDEPS = \
+ gnu/lib/libgcc \
+ include \
+ include/arpa \
+ include/rpc \
+ include/rpcsvc \
+ include/xlocale \
+ lib/${CSU_DIR} \
+ lib/libc \
+ lib/libwrap \
+ usr.sbin/amd/include \
+ usr.sbin/amd/libamu \
+
+
+.include <dirdeps.mk>
+
+.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+# local dependencies - needed for -jN in clean tree
+.endif
diff --git a/usr.sbin/amd/fixmount/Makefile.depend b/usr.sbin/amd/fixmount/Makefile.depend
new file mode 100644
index 0000000..1ed02e5
--- /dev/null
+++ b/usr.sbin/amd/fixmount/Makefile.depend
@@ -0,0 +1,26 @@
+# Autogenerated - do NOT edit!
+
+DEP_RELDIR := ${_PARSEDIR:S,${SRCTOP}/,,}
+
+DEP_MACHINE := ${.PARSEFILE:E}
+
+DIRDEPS = \
+ gnu/lib/libgcc \
+ include \
+ include/arpa \
+ include/rpc \
+ include/rpcsvc \
+ include/xlocale \
+ lib/${CSU_DIR} \
+ lib/libc \
+ lib/librpcsvc \
+ lib/libwrap \
+ usr.sbin/amd/include \
+ usr.sbin/amd/libamu \
+
+
+.include <dirdeps.mk>
+
+.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+# local dependencies - needed for -jN in clean tree
+.endif
diff --git a/usr.sbin/amd/fsinfo/Makefile.depend b/usr.sbin/amd/fsinfo/Makefile.depend
new file mode 100644
index 0000000..63070f4
--- /dev/null
+++ b/usr.sbin/amd/fsinfo/Makefile.depend
@@ -0,0 +1,33 @@
+# Autogenerated - do NOT edit!
+
+DEP_RELDIR := ${_PARSEDIR:S,${SRCTOP}/,,}
+
+DEP_MACHINE := ${.PARSEFILE:E}
+
+DIRDEPS = \
+ gnu/lib/libgcc \
+ include \
+ include/arpa \
+ include/rpc \
+ include/rpcsvc \
+ include/xlocale \
+ lib/${CSU_DIR} \
+ lib/libc \
+ lib/libwrap \
+ usr.sbin/amd/include \
+ usr.sbin/amd/libamu \
+
+
+.include <dirdeps.mk>
+
+.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+# local dependencies - needed for -jN in clean tree
+fsi_gram.o: fsi_gram.c
+fsi_gram.po: fsi_gram.c
+fsi_lex.o: fsi_gram.h
+fsi_lex.o: fsi_lex.c
+fsi_lex.po: fsi_gram.h
+fsi_lex.po: fsi_lex.c
+fsinfo.o: fsi_gram.h
+fsinfo.po: fsi_gram.h
+.endif
diff --git a/usr.sbin/amd/hlfsd/Makefile.depend b/usr.sbin/amd/hlfsd/Makefile.depend
new file mode 100644
index 0000000..66f893e
--- /dev/null
+++ b/usr.sbin/amd/hlfsd/Makefile.depend
@@ -0,0 +1,25 @@
+# Autogenerated - do NOT edit!
+
+DEP_RELDIR := ${_PARSEDIR:S,${SRCTOP}/,,}
+
+DEP_MACHINE := ${.PARSEFILE:E}
+
+DIRDEPS = \
+ gnu/lib/libgcc \
+ include \
+ include/arpa \
+ include/rpc \
+ include/rpcsvc \
+ include/xlocale \
+ lib/${CSU_DIR} \
+ lib/libc \
+ lib/libwrap \
+ usr.sbin/amd/include \
+ usr.sbin/amd/libamu \
+
+
+.include <dirdeps.mk>
+
+.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+# local dependencies - needed for -jN in clean tree
+.endif
diff --git a/usr.sbin/amd/include/Makefile.depend b/usr.sbin/amd/include/Makefile.depend
new file mode 100644
index 0000000..29fda55
--- /dev/null
+++ b/usr.sbin/amd/include/Makefile.depend
@@ -0,0 +1,14 @@
+# Autogenerated - do NOT edit!
+
+DEP_RELDIR := ${_PARSEDIR:S,${SRCTOP}/,,}
+
+DEP_MACHINE := ${.PARSEFILE:E}
+
+DIRDEPS = \
+
+
+.include <dirdeps.mk>
+
+.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+# local dependencies - needed for -jN in clean tree
+.endif
diff --git a/usr.sbin/amd/libamu/Makefile.depend b/usr.sbin/amd/libamu/Makefile.depend
new file mode 100644
index 0000000..a0399ce
--- /dev/null
+++ b/usr.sbin/amd/libamu/Makefile.depend
@@ -0,0 +1,25 @@
+# Autogenerated - do NOT edit!
+
+DEP_RELDIR := ${_PARSEDIR:S,${SRCTOP}/,,}
+
+DEP_MACHINE := ${.PARSEFILE:E}
+
+DIRDEPS = \
+ include \
+ include/arpa \
+ include/rpc \
+ include/rpcsvc \
+ include/xlocale \
+ lib/libwrap \
+ usr.sbin/amd/include \
+
+
+.include <dirdeps.mk>
+
+.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+# local dependencies - needed for -jN in clean tree
+nfs_prot_x.o: nfs_prot_x.c
+nfs_prot_x.po: nfs_prot_x.c
+xdr_func_%undef.o: xdr_func_%undef.c
+xdr_func_%undef.po: xdr_func_%undef.c
+.endif
diff --git a/usr.sbin/amd/mk-amd-map/Makefile.depend b/usr.sbin/amd/mk-amd-map/Makefile.depend
new file mode 100644
index 0000000..66f893e
--- /dev/null
+++ b/usr.sbin/amd/mk-amd-map/Makefile.depend
@@ -0,0 +1,25 @@
+# Autogenerated - do NOT edit!
+
+DEP_RELDIR := ${_PARSEDIR:S,${SRCTOP}/,,}
+
+DEP_MACHINE := ${.PARSEFILE:E}
+
+DIRDEPS = \
+ gnu/lib/libgcc \
+ include \
+ include/arpa \
+ include/rpc \
+ include/rpcsvc \
+ include/xlocale \
+ lib/${CSU_DIR} \
+ lib/libc \
+ lib/libwrap \
+ usr.sbin/amd/include \
+ usr.sbin/amd/libamu \
+
+
+.include <dirdeps.mk>
+
+.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+# local dependencies - needed for -jN in clean tree
+.endif
diff --git a/usr.sbin/amd/pawd/Makefile.depend b/usr.sbin/amd/pawd/Makefile.depend
new file mode 100644
index 0000000..66f893e
--- /dev/null
+++ b/usr.sbin/amd/pawd/Makefile.depend
@@ -0,0 +1,25 @@
+# Autogenerated - do NOT edit!
+
+DEP_RELDIR := ${_PARSEDIR:S,${SRCTOP}/,,}
+
+DEP_MACHINE := ${.PARSEFILE:E}
+
+DIRDEPS = \
+ gnu/lib/libgcc \
+ include \
+ include/arpa \
+ include/rpc \
+ include/rpcsvc \
+ include/xlocale \
+ lib/${CSU_DIR} \
+ lib/libc \
+ lib/libwrap \
+ usr.sbin/amd/include \
+ usr.sbin/amd/libamu \
+
+
+.include <dirdeps.mk>
+
+.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+# local dependencies - needed for -jN in clean tree
+.endif
diff --git a/usr.sbin/amd/scripts/Makefile.depend b/usr.sbin/amd/scripts/Makefile.depend
new file mode 100644
index 0000000..29fda55
--- /dev/null
+++ b/usr.sbin/amd/scripts/Makefile.depend
@@ -0,0 +1,14 @@
+# Autogenerated - do NOT edit!
+
+DEP_RELDIR := ${_PARSEDIR:S,${SRCTOP}/,,}
+
+DEP_MACHINE := ${.PARSEFILE:E}
+
+DIRDEPS = \
+
+
+.include <dirdeps.mk>
+
+.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+# local dependencies - needed for -jN in clean tree
+.endif
diff --git a/usr.sbin/amd/wire-test/Makefile.depend b/usr.sbin/amd/wire-test/Makefile.depend
new file mode 100644
index 0000000..66f893e
--- /dev/null
+++ b/usr.sbin/amd/wire-test/Makefile.depend
@@ -0,0 +1,25 @@
+# Autogenerated - do NOT edit!
+
+DEP_RELDIR := ${_PARSEDIR:S,${SRCTOP}/,,}
+
+DEP_MACHINE := ${.PARSEFILE:E}
+
+DIRDEPS = \
+ gnu/lib/libgcc \
+ include \
+ include/arpa \
+ include/rpc \
+ include/rpcsvc \
+ include/xlocale \
+ lib/${CSU_DIR} \
+ lib/libc \
+ lib/libwrap \
+ usr.sbin/amd/include \
+ usr.sbin/amd/libamu \
+
+
+.include <dirdeps.mk>
+
+.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+# local dependencies - needed for -jN in clean tree
+.endif
diff --git a/usr.sbin/ancontrol/Makefile.depend b/usr.sbin/ancontrol/Makefile.depend
new file mode 100644
index 0000000..f7894b5
--- /dev/null
+++ b/usr.sbin/ancontrol/Makefile.depend
@@ -0,0 +1,21 @@
+# Autogenerated - do NOT edit!
+
+DEP_RELDIR := ${_PARSEDIR:S,${SRCTOP}/,,}
+
+DEP_MACHINE := ${.PARSEFILE:E}
+
+DIRDEPS = \
+ gnu/lib/libgcc \
+ include \
+ include/arpa \
+ include/xlocale \
+ lib/${CSU_DIR} \
+ lib/libc \
+ lib/libmd \
+
+
+.include <dirdeps.mk>
+
+.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+# local dependencies - needed for -jN in clean tree
+.endif
diff --git a/usr.sbin/ancontrol/ancontrol.c b/usr.sbin/ancontrol/ancontrol.c
index 4a11453..839cdcb 100644
--- a/usr.sbin/ancontrol/ancontrol.c
+++ b/usr.sbin/ancontrol/ancontrol.c
@@ -1443,7 +1443,7 @@ an_enable_leap_mode(const char *iface, const char *username)
caps = (struct an_ltv_caps *)&areq;
- if (!caps->an_softcaps & AN_AUTHTYPE_LEAP) {
+ if (!(caps->an_softcaps & AN_AUTHTYPE_LEAP)) {
fprintf(stderr, "Firmware does not support LEAP\n");
exit(1);
}
diff --git a/usr.sbin/apm/Makefile.depend b/usr.sbin/apm/Makefile.depend
new file mode 100644
index 0000000..a839545
--- /dev/null
+++ b/usr.sbin/apm/Makefile.depend
@@ -0,0 +1,19 @@
+# Autogenerated - do NOT edit!
+
+DEP_RELDIR := ${_PARSEDIR:S,${SRCTOP}/,,}
+
+DEP_MACHINE := ${.PARSEFILE:E}
+
+DIRDEPS = \
+ gnu/lib/libgcc \
+ include \
+ include/xlocale \
+ lib/${CSU_DIR} \
+ lib/libc \
+
+
+.include <dirdeps.mk>
+
+.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+# local dependencies - needed for -jN in clean tree
+.endif
diff --git a/usr.sbin/apmd/Makefile.depend b/usr.sbin/apmd/Makefile.depend
new file mode 100644
index 0000000..554c4cc
--- /dev/null
+++ b/usr.sbin/apmd/Makefile.depend
@@ -0,0 +1,25 @@
+# Autogenerated - do NOT edit!
+
+DEP_RELDIR := ${_PARSEDIR:S,${SRCTOP}/,,}
+
+DEP_MACHINE := ${.PARSEFILE:E}
+
+DIRDEPS = \
+ gnu/lib/libgcc \
+ include \
+ include/xlocale \
+ lib/${CSU_DIR} \
+ lib/libc \
+
+
+.include <dirdeps.mk>
+
+.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+# local dependencies - needed for -jN in clean tree
+apmdlex.o: apmdlex.c
+apmdlex.o: y.tab.h
+apmdlex.po: apmdlex.c
+apmdlex.po: y.tab.h
+apmdparse.o: apmdparse.c
+apmdparse.po: apmdparse.c
+.endif
diff --git a/usr.sbin/apmd/apmd.8 b/usr.sbin/apmd/apmd.8
index 5bfd9dc..633217f 100644
--- a/usr.sbin/apmd/apmd.8
+++ b/usr.sbin/apmd/apmd.8
@@ -245,13 +245,13 @@ just as with a command line.
The following built-in functions are currently supported:
.Bl -item
.It
-- reject:
-.Bd -ragged -offset indent
+.Bl -tag -width ".It - reject"
+.It - reject
Reject last request posted by APM BIOS.
This can be used to reject
a SUSPEND request when the LCD is closed and put the system in a
STANDBY state instead.
-.Ed
+.El
.El
.Ed
.El
diff --git a/usr.sbin/arp/Makefile.depend b/usr.sbin/arp/Makefile.depend
new file mode 100644
index 0000000..16b5e42
--- /dev/null
+++ b/usr.sbin/arp/Makefile.depend
@@ -0,0 +1,20 @@
+# Autogenerated - do NOT edit!
+
+DEP_RELDIR := ${_PARSEDIR:S,${SRCTOP}/,,}
+
+DEP_MACHINE := ${.PARSEFILE:E}
+
+DIRDEPS = \
+ gnu/lib/libgcc \
+ include \
+ include/arpa \
+ include/xlocale \
+ lib/${CSU_DIR} \
+ lib/libc \
+
+
+.include <dirdeps.mk>
+
+.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+# local dependencies - needed for -jN in clean tree
+.endif
diff --git a/usr.sbin/arp/arp.4 b/usr.sbin/arp/arp.4
index b7273f2..0ff0f2c 100644
--- a/usr.sbin/arp/arp.4
+++ b/usr.sbin/arp/arp.4
@@ -28,7 +28,7 @@
.\" @(#)arp4.4 6.5 (Berkeley) 4/18/94
.\" $FreeBSD$
.\"
-.Dd March 28, 2007
+.Dd September 3, 2012
.Dt ARP 4
.Os
.Sh NAME
@@ -119,20 +119,59 @@ branch
of the
.Xr sysctl 3
MIB.
-.Bl -tag -width "useloopback"
+.Bl -tag -width "log_arp_permanent_modify"
+.It Va allow_multicast
+Should the kernel install ARP entries with multicast bit set in
+the hardware address.
+Installing such entries is RFC 1812 violation, but some prorietary
+load balancing techniques require routers on network to do so.
+Turned off by default.
+.It Va log_arp_movements
+Should the kernel log movements of IP addresses from one hardware
+address to an other.
+See
+.Sx DIAGNOSTICS
+below.
+Turned on by default.
+.It Va log_arp_permanent_modify
+Should the kernel log attempts of remote host on network to modify a
+permanent ARP entry.
+See
+.Sx DIAGNOSTICS
+below.
+Turned on by default.
+.It Va log_arp_wrong_iface
+Should the kernel log attempts to insert an ARP entry on an interface
+when the IP network the address belongs to is connected to an other
+interface.
+See
+.Sx DIAGNOSTICS
+below.
+Turned on by default.
.It Va max_age
How long an ARP entry is held in the cache until it needs to be refreshed.
+Default is 1200 seconds.
+.It Va maxhold
+How many packets hold in the per-entry output queue while the entry
+is being resolved.
+Default is one packet.
.It Va maxtries
Number of retransmits before host is considered down and error is returned.
+Default is 5 tries.
+.It Va proxyall
+Enables ARP proxying for all hosts on net.
+Turned off by default.
.It Va useloopback
If an ARP entry is added for local address, force the traffic to go through
the loopback interface.
-.It Va proxyall
-Enables ARP proxying for all hosts on net.
+Turned on by default.
+.It Va wait
+Lifetime of an incomplete ARP entry.
+Default is 20 seconds.
.El
.Sh DIAGNOSTICS
.Bl -diag
-.It "arp: %x:%x:%x:%x:%x:%x is using my IP address %d.%d.%d.%d!"
+.It "arp: %x:%x:%x:%x:%x:%x is using my IP address %d.%d.%d.%d on %s!"
ARP has discovered another host on the local network which responds to
mapping requests for its own Internet address with a different Ethernet
address, generally indicating that two hosts are attempting to use the
@@ -170,6 +209,11 @@ entry in the local ARP table.
This error will only be logged if the sysctl
.Va net.link.ether.inet.log_arp_permanent_modify
is set to 1, which is the system's default behaviour.
+.It "arp: %x:%x:%x:%x:%x:%x is multicast"
+Kernel refused to install an entry with multicast hardware address.
+If you really want such addresses being installed, set the sysctl
+.Va net.link.ether.inet.allow_multicast
+to a positive value.
.El
.Sh SEE ALSO
.Xr inet 4 ,
diff --git a/usr.sbin/arpaname/Makefile.depend b/usr.sbin/arpaname/Makefile.depend
new file mode 100644
index 0000000..78e28c0
--- /dev/null
+++ b/usr.sbin/arpaname/Makefile.depend
@@ -0,0 +1,28 @@
+# Autogenerated - do NOT edit!
+
+DEP_RELDIR := ${_PARSEDIR:S,${SRCTOP}/,,}
+
+DEP_MACHINE := ${.PARSEFILE:E}
+
+DIRDEPS = \
+ gnu/lib/libgcc \
+ include \
+ include/arpa \
+ include/xlocale \
+ lib/${CSU_DIR} \
+ lib/bind/bind9 \
+ lib/bind/dns \
+ lib/bind/isc \
+ lib/bind/isccc \
+ lib/bind/isccfg \
+ lib/bind/lwres \
+ lib/libc \
+ lib/libthr \
+ secure/lib/libcrypto \
+
+
+.include <dirdeps.mk>
+
+.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+# local dependencies - needed for -jN in clean tree
+.endif
diff --git a/usr.sbin/asf/Makefile.depend b/usr.sbin/asf/Makefile.depend
new file mode 100644
index 0000000..553674c
--- /dev/null
+++ b/usr.sbin/asf/Makefile.depend
@@ -0,0 +1,20 @@
+# Autogenerated - do NOT edit!
+
+DEP_RELDIR := ${_PARSEDIR:S,${SRCTOP}/,,}
+
+DEP_MACHINE := ${.PARSEFILE:E}
+
+DIRDEPS = \
+ gnu/lib/libgcc \
+ include \
+ include/xlocale \
+ lib/${CSU_DIR} \
+ lib/libc \
+ lib/libkvm \
+
+
+.include <dirdeps.mk>
+
+.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+# local dependencies - needed for -jN in clean tree
+.endif
diff --git a/usr.sbin/audit/Makefile.depend b/usr.sbin/audit/Makefile.depend
new file mode 100644
index 0000000..1aedff5
--- /dev/null
+++ b/usr.sbin/audit/Makefile.depend
@@ -0,0 +1,20 @@
+# Autogenerated - do NOT edit!
+
+DEP_RELDIR := ${_PARSEDIR:S,${SRCTOP}/,,}
+
+DEP_MACHINE := ${.PARSEFILE:E}
+
+DIRDEPS = \
+ gnu/lib/libgcc \
+ include \
+ include/xlocale \
+ lib/${CSU_DIR} \
+ lib/libbsm \
+ lib/libc \
+
+
+.include <dirdeps.mk>
+
+.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+# local dependencies - needed for -jN in clean tree
+.endif
diff --git a/usr.sbin/auditd/Makefile.depend b/usr.sbin/auditd/Makefile.depend
new file mode 100644
index 0000000..e062403
--- /dev/null
+++ b/usr.sbin/auditd/Makefile.depend
@@ -0,0 +1,21 @@
+# Autogenerated - do NOT edit!
+
+DEP_RELDIR := ${_PARSEDIR:S,${SRCTOP}/,,}
+
+DEP_MACHINE := ${.PARSEFILE:E}
+
+DIRDEPS = \
+ gnu/lib/libgcc \
+ include \
+ include/xlocale \
+ lib/${CSU_DIR} \
+ lib/libauditd \
+ lib/libbsm \
+ lib/libc \
+
+
+.include <dirdeps.mk>
+
+.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+# local dependencies - needed for -jN in clean tree
+.endif
diff --git a/usr.sbin/auditreduce/Makefile.depend b/usr.sbin/auditreduce/Makefile.depend
new file mode 100644
index 0000000..1aedff5
--- /dev/null
+++ b/usr.sbin/auditreduce/Makefile.depend
@@ -0,0 +1,20 @@
+# Autogenerated - do NOT edit!
+
+DEP_RELDIR := ${_PARSEDIR:S,${SRCTOP}/,,}
+
+DEP_MACHINE := ${.PARSEFILE:E}
+
+DIRDEPS = \
+ gnu/lib/libgcc \
+ include \
+ include/xlocale \
+ lib/${CSU_DIR} \
+ lib/libbsm \
+ lib/libc \
+
+
+.include <dirdeps.mk>
+
+.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+# local dependencies - needed for -jN in clean tree
+.endif
diff --git a/usr.sbin/authpf/Makefile b/usr.sbin/authpf/Makefile
index 0a24b8e..1d15beb 100644
--- a/usr.sbin/authpf/Makefile
+++ b/usr.sbin/authpf/Makefile
@@ -1,7 +1,6 @@
# $FreeBSD$
.PATH: ${.CURDIR}/../../contrib/pf/authpf
-.PATH: ${.CURDIR}/../../contrib/pf/pfctl
PROG= authpf
MAN= authpf.8
@@ -11,8 +10,6 @@ BINMODE= 6555
SRCS= authpf.c
-CFLAGS+= -I${.CURDIR}/../../contrib/pf/pfctl
-
# XXX ALTQ:
CFLAGS+= -DENABLE_ALTQ
diff --git a/usr.sbin/authpf/Makefile.depend b/usr.sbin/authpf/Makefile.depend
new file mode 100644
index 0000000..157f511
--- /dev/null
+++ b/usr.sbin/authpf/Makefile.depend
@@ -0,0 +1,23 @@
+# Autogenerated - do NOT edit!
+
+DEP_RELDIR := ${_PARSEDIR:S,${SRCTOP}/,,}
+
+DEP_MACHINE := ${.PARSEFILE:E}
+
+DIRDEPS = \
+ gnu/lib/libgcc \
+ include \
+ include/arpa \
+ include/xlocale \
+ lib/${CSU_DIR} \
+ lib/libc \
+ lib/libmd \
+ lib/libutil \
+ lib/msun \
+
+
+.include <dirdeps.mk>
+
+.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+# local dependencies - needed for -jN in clean tree
+.endif
diff --git a/usr.sbin/bluetooth/ath3kfw/Makefile.depend b/usr.sbin/bluetooth/ath3kfw/Makefile.depend
new file mode 100644
index 0000000..f779151
--- /dev/null
+++ b/usr.sbin/bluetooth/ath3kfw/Makefile.depend
@@ -0,0 +1,20 @@
+# Autogenerated - do NOT edit!
+
+DEP_RELDIR := ${_PARSEDIR:S,${SRCTOP}/,,}
+
+DEP_MACHINE := ${.PARSEFILE:E}
+
+DIRDEPS = \
+ gnu/lib/libgcc \
+ include \
+ include/xlocale \
+ lib/${CSU_DIR} \
+ lib/libc \
+ lib/libusb \
+
+
+.include <dirdeps.mk>
+
+.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+# local dependencies - needed for -jN in clean tree
+.endif
diff --git a/usr.sbin/bluetooth/bcmfw/Makefile.depend b/usr.sbin/bluetooth/bcmfw/Makefile.depend
new file mode 100644
index 0000000..e6d80d3
--- /dev/null
+++ b/usr.sbin/bluetooth/bcmfw/Makefile.depend
@@ -0,0 +1,20 @@
+# Autogenerated - do NOT edit!
+
+DEP_RELDIR := ${_PARSEDIR:S,${SRCTOP}/,,}
+
+DEP_MACHINE := ${.PARSEFILE:E}
+
+DIRDEPS = \
+ gnu/lib/libgcc \
+ include \
+ include/xlocale \
+ lib/${CSU_DIR} \
+ lib/libc \
+ lib/libnetgraph \
+
+
+.include <dirdeps.mk>
+
+.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+# local dependencies - needed for -jN in clean tree
+.endif
diff --git a/usr.sbin/bluetooth/bt3cfw/Makefile.depend b/usr.sbin/bluetooth/bt3cfw/Makefile.depend
new file mode 100644
index 0000000..e6d80d3
--- /dev/null
+++ b/usr.sbin/bluetooth/bt3cfw/Makefile.depend
@@ -0,0 +1,20 @@
+# Autogenerated - do NOT edit!
+
+DEP_RELDIR := ${_PARSEDIR:S,${SRCTOP}/,,}
+
+DEP_MACHINE := ${.PARSEFILE:E}
+
+DIRDEPS = \
+ gnu/lib/libgcc \
+ include \
+ include/xlocale \
+ lib/${CSU_DIR} \
+ lib/libc \
+ lib/libnetgraph \
+
+
+.include <dirdeps.mk>
+
+.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+# local dependencies - needed for -jN in clean tree
+.endif
diff --git a/usr.sbin/bluetooth/bthidcontrol/Makefile.depend b/usr.sbin/bluetooth/bthidcontrol/Makefile.depend
new file mode 100644
index 0000000..bf7f962
--- /dev/null
+++ b/usr.sbin/bluetooth/bthidcontrol/Makefile.depend
@@ -0,0 +1,28 @@
+# Autogenerated - do NOT edit!
+
+DEP_RELDIR := ${_PARSEDIR:S,${SRCTOP}/,,}
+
+DEP_MACHINE := ${.PARSEFILE:E}
+
+DIRDEPS = \
+ gnu/lib/libgcc \
+ include \
+ include/xlocale \
+ lib/${CSU_DIR} \
+ lib/libbluetooth \
+ lib/libc \
+ lib/libsdp \
+ lib/libusbhid \
+
+
+.include <dirdeps.mk>
+
+.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+# local dependencies - needed for -jN in clean tree
+lexer.o: lexer.c
+lexer.o: parser.h
+lexer.po: lexer.c
+lexer.po: parser.h
+parser.o: parser.c
+parser.po: parser.c
+.endif
diff --git a/usr.sbin/bluetooth/bthidd/Makefile.depend b/usr.sbin/bluetooth/bthidd/Makefile.depend
new file mode 100644
index 0000000..61ae926
--- /dev/null
+++ b/usr.sbin/bluetooth/bthidd/Makefile.depend
@@ -0,0 +1,27 @@
+# Autogenerated - do NOT edit!
+
+DEP_RELDIR := ${_PARSEDIR:S,${SRCTOP}/,,}
+
+DEP_MACHINE := ${.PARSEFILE:E}
+
+DIRDEPS = \
+ gnu/lib/libgcc \
+ include \
+ include/xlocale \
+ lib/${CSU_DIR} \
+ lib/libbluetooth \
+ lib/libc \
+ lib/libusbhid \
+
+
+.include <dirdeps.mk>
+
+.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+# local dependencies - needed for -jN in clean tree
+lexer.o: lexer.c
+lexer.o: parser.h
+lexer.po: lexer.c
+lexer.po: parser.h
+parser.o: parser.c
+parser.po: parser.c
+.endif
diff --git a/usr.sbin/bluetooth/btpand/Makefile.depend b/usr.sbin/bluetooth/btpand/Makefile.depend
new file mode 100644
index 0000000..336a9db
--- /dev/null
+++ b/usr.sbin/bluetooth/btpand/Makefile.depend
@@ -0,0 +1,22 @@
+# Autogenerated - do NOT edit!
+
+DEP_RELDIR := ${_PARSEDIR:S,${SRCTOP}/,,}
+
+DEP_MACHINE := ${.PARSEFILE:E}
+
+DIRDEPS = \
+ gnu/lib/libgcc \
+ include \
+ include/xlocale \
+ lib/${CSU_DIR} \
+ lib/libbluetooth \
+ lib/libc \
+ lib/libsdp \
+ lib/libutil \
+
+
+.include <dirdeps.mk>
+
+.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+# local dependencies - needed for -jN in clean tree
+.endif
diff --git a/usr.sbin/bluetooth/btpand/client.c b/usr.sbin/bluetooth/btpand/client.c
index 97064db..2cc9089 100644
--- a/usr.sbin/bluetooth/btpand/client.c
+++ b/usr.sbin/bluetooth/btpand/client.c
@@ -47,7 +47,7 @@ client_init(void)
struct sockaddr_l2cap sa;
channel_t *chan;
socklen_t len;
- int fd;
+ int fd, n;
uint16_t mru, mtu;
if (bdaddr_any(&remote_bdaddr))
@@ -97,6 +97,17 @@ client_init(void)
exit(EXIT_FAILURE);
}
+ len = sizeof(n);
+ if (getsockopt(fd, SOL_SOCKET, SO_RCVBUF, &n, &len) == -1) {
+ log_err("Could not read SO_RCVBUF");
+ exit(EXIT_FAILURE);
+ }
+ if (n < (mru * 10)) {
+ n = mru * 10;
+ if (setsockopt(fd, SOL_SOCKET, SO_RCVBUF, &n, sizeof(n)) == -1)
+ log_info("Could not increase SO_RCVBUF (from %d)", n);
+ }
+
len = sizeof(mtu);
if (getsockopt(fd, SOL_L2CAP, SO_L2CAP_OMTU, &mtu, &len) == -1) {
log_err("Could not get L2CAP OMTU: %m");
@@ -107,6 +118,27 @@ client_init(void)
exit(EXIT_FAILURE);
}
+ len = sizeof(n);
+ if (getsockopt(fd, SOL_SOCKET, SO_SNDBUF, &n, &len) == -1) {
+ log_err("Could not get socket send buffer size: %m");
+ close(fd);
+ return;
+ }
+ if (n < (mtu * 2)) {
+ n = mtu * 2;
+ if (setsockopt(fd, SOL_SOCKET, SO_SNDBUF, &n, sizeof(n)) == -1) {
+ log_err("Could not set socket send buffer size (%d): %m", n);
+ close(fd);
+ return;
+ }
+ }
+ n = mtu;
+ if (setsockopt(fd, SOL_SOCKET, SO_SNDLOWAT, &n, sizeof(n)) == -1) {
+ log_err("Could not set socket low water mark (%d): %m", n);
+ close(fd);
+ return;
+ }
+
chan = channel_alloc();
if (chan == NULL)
exit(EXIT_FAILURE);
diff --git a/usr.sbin/bluetooth/btpand/server.c b/usr.sbin/bluetooth/btpand/server.c
index 0843d0c..b24d416 100644
--- a/usr.sbin/bluetooth/btpand/server.c
+++ b/usr.sbin/bluetooth/btpand/server.c
@@ -177,6 +177,18 @@ server_read(int s, short ev, void *arg)
return;
}
+ len = sizeof(n);
+ if (getsockopt(fd, SOL_SOCKET, SO_RCVBUF, &n, &len) == -1) {
+ log_err("Could not read SO_RCVBUF");
+ close(fd);
+ return;
+ }
+ if (n < (mru * 10)) {
+ n = mru * 10;
+ if (setsockopt(fd, SOL_SOCKET, SO_RCVBUF, &n, sizeof(n)) == -1)
+ log_info("Could not increase SO_RCVBUF (from %d)", n);
+ }
+
len = sizeof(mtu);
if (getsockopt(fd, SOL_L2CAP, SO_L2CAP_OMTU, &mtu, &len) == -1) {
log_err("Could not get L2CAP OMTU: %m");
diff --git a/usr.sbin/bluetooth/hccontrol/Makefile.depend b/usr.sbin/bluetooth/hccontrol/Makefile.depend
new file mode 100644
index 0000000..e188ca8
--- /dev/null
+++ b/usr.sbin/bluetooth/hccontrol/Makefile.depend
@@ -0,0 +1,20 @@
+# Autogenerated - do NOT edit!
+
+DEP_RELDIR := ${_PARSEDIR:S,${SRCTOP}/,,}
+
+DEP_MACHINE := ${.PARSEFILE:E}
+
+DIRDEPS = \
+ gnu/lib/libgcc \
+ include \
+ include/xlocale \
+ lib/${CSU_DIR} \
+ lib/libbluetooth \
+ lib/libc \
+
+
+.include <dirdeps.mk>
+
+.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+# local dependencies - needed for -jN in clean tree
+.endif
diff --git a/usr.sbin/bluetooth/hcsecd/Makefile.depend b/usr.sbin/bluetooth/hcsecd/Makefile.depend
new file mode 100644
index 0000000..d800014
--- /dev/null
+++ b/usr.sbin/bluetooth/hcsecd/Makefile.depend
@@ -0,0 +1,26 @@
+# Autogenerated - do NOT edit!
+
+DEP_RELDIR := ${_PARSEDIR:S,${SRCTOP}/,,}
+
+DEP_MACHINE := ${.PARSEFILE:E}
+
+DIRDEPS = \
+ gnu/lib/libgcc \
+ include \
+ include/xlocale \
+ lib/${CSU_DIR} \
+ lib/libbluetooth \
+ lib/libc \
+
+
+.include <dirdeps.mk>
+
+.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+# local dependencies - needed for -jN in clean tree
+lexer.o: lexer.c
+lexer.o: parser.h
+lexer.po: lexer.c
+lexer.po: parser.h
+parser.o: parser.c
+parser.po: parser.c
+.endif
diff --git a/usr.sbin/bluetooth/hcseriald/Makefile.depend b/usr.sbin/bluetooth/hcseriald/Makefile.depend
new file mode 100644
index 0000000..e6d80d3
--- /dev/null
+++ b/usr.sbin/bluetooth/hcseriald/Makefile.depend
@@ -0,0 +1,20 @@
+# Autogenerated - do NOT edit!
+
+DEP_RELDIR := ${_PARSEDIR:S,${SRCTOP}/,,}
+
+DEP_MACHINE := ${.PARSEFILE:E}
+
+DIRDEPS = \
+ gnu/lib/libgcc \
+ include \
+ include/xlocale \
+ lib/${CSU_DIR} \
+ lib/libc \
+ lib/libnetgraph \
+
+
+.include <dirdeps.mk>
+
+.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+# local dependencies - needed for -jN in clean tree
+.endif
diff --git a/usr.sbin/bluetooth/l2control/Makefile.depend b/usr.sbin/bluetooth/l2control/Makefile.depend
new file mode 100644
index 0000000..e188ca8
--- /dev/null
+++ b/usr.sbin/bluetooth/l2control/Makefile.depend
@@ -0,0 +1,20 @@
+# Autogenerated - do NOT edit!
+
+DEP_RELDIR := ${_PARSEDIR:S,${SRCTOP}/,,}
+
+DEP_MACHINE := ${.PARSEFILE:E}
+
+DIRDEPS = \
+ gnu/lib/libgcc \
+ include \
+ include/xlocale \
+ lib/${CSU_DIR} \
+ lib/libbluetooth \
+ lib/libc \
+
+
+.include <dirdeps.mk>
+
+.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+# local dependencies - needed for -jN in clean tree
+.endif
diff --git a/usr.sbin/bluetooth/l2ping/Makefile.depend b/usr.sbin/bluetooth/l2ping/Makefile.depend
new file mode 100644
index 0000000..ff4e7a5
--- /dev/null
+++ b/usr.sbin/bluetooth/l2ping/Makefile.depend
@@ -0,0 +1,21 @@
+# Autogenerated - do NOT edit!
+
+DEP_RELDIR := ${_PARSEDIR:S,${SRCTOP}/,,}
+
+DEP_MACHINE := ${.PARSEFILE:E}
+
+DIRDEPS = \
+ gnu/lib/libgcc \
+ include \
+ include/arpa \
+ include/xlocale \
+ lib/${CSU_DIR} \
+ lib/libbluetooth \
+ lib/libc \
+
+
+.include <dirdeps.mk>
+
+.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+# local dependencies - needed for -jN in clean tree
+.endif
diff --git a/usr.sbin/bluetooth/rfcomm_pppd/Makefile.depend b/usr.sbin/bluetooth/rfcomm_pppd/Makefile.depend
new file mode 100644
index 0000000..b3a6c2b
--- /dev/null
+++ b/usr.sbin/bluetooth/rfcomm_pppd/Makefile.depend
@@ -0,0 +1,21 @@
+# Autogenerated - do NOT edit!
+
+DEP_RELDIR := ${_PARSEDIR:S,${SRCTOP}/,,}
+
+DEP_MACHINE := ${.PARSEFILE:E}
+
+DIRDEPS = \
+ gnu/lib/libgcc \
+ include \
+ include/xlocale \
+ lib/${CSU_DIR} \
+ lib/libbluetooth \
+ lib/libc \
+ lib/libsdp \
+
+
+.include <dirdeps.mk>
+
+.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+# local dependencies - needed for -jN in clean tree
+.endif
diff --git a/usr.sbin/bluetooth/sdpcontrol/Makefile.depend b/usr.sbin/bluetooth/sdpcontrol/Makefile.depend
new file mode 100644
index 0000000..b3a6c2b
--- /dev/null
+++ b/usr.sbin/bluetooth/sdpcontrol/Makefile.depend
@@ -0,0 +1,21 @@
+# Autogenerated - do NOT edit!
+
+DEP_RELDIR := ${_PARSEDIR:S,${SRCTOP}/,,}
+
+DEP_MACHINE := ${.PARSEFILE:E}
+
+DIRDEPS = \
+ gnu/lib/libgcc \
+ include \
+ include/xlocale \
+ lib/${CSU_DIR} \
+ lib/libbluetooth \
+ lib/libc \
+ lib/libsdp \
+
+
+.include <dirdeps.mk>
+
+.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+# local dependencies - needed for -jN in clean tree
+.endif
diff --git a/usr.sbin/bluetooth/sdpd/Makefile.depend b/usr.sbin/bluetooth/sdpd/Makefile.depend
new file mode 100644
index 0000000..e98dae0
--- /dev/null
+++ b/usr.sbin/bluetooth/sdpd/Makefile.depend
@@ -0,0 +1,22 @@
+# Autogenerated - do NOT edit!
+
+DEP_RELDIR := ${_PARSEDIR:S,${SRCTOP}/,,}
+
+DEP_MACHINE := ${.PARSEFILE:E}
+
+DIRDEPS = \
+ gnu/lib/libgcc \
+ include \
+ include/arpa \
+ include/xlocale \
+ lib/${CSU_DIR} \
+ lib/libbluetooth \
+ lib/libc \
+ lib/libsdp \
+
+
+.include <dirdeps.mk>
+
+.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+# local dependencies - needed for -jN in clean tree
+.endif
diff --git a/usr.sbin/boot0cfg/Makefile.depend b/usr.sbin/boot0cfg/Makefile.depend
new file mode 100644
index 0000000..378b35f
--- /dev/null
+++ b/usr.sbin/boot0cfg/Makefile.depend
@@ -0,0 +1,22 @@
+# Autogenerated - do NOT edit!
+
+DEP_RELDIR := ${_PARSEDIR:S,${SRCTOP}/,,}
+
+DEP_MACHINE := ${.PARSEFILE:E}
+
+DIRDEPS = \
+ gnu/lib/libgcc \
+ include \
+ include/xlocale \
+ lib/${CSU_DIR} \
+ lib/libc \
+ lib/libexpat \
+ lib/libgeom \
+ lib/libsbuf \
+
+
+.include <dirdeps.mk>
+
+.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+# local dependencies - needed for -jN in clean tree
+.endif
diff --git a/usr.sbin/boot98cfg/Makefile.depend b/usr.sbin/boot98cfg/Makefile.depend
new file mode 100644
index 0000000..25f093b
--- /dev/null
+++ b/usr.sbin/boot98cfg/Makefile.depend
@@ -0,0 +1,20 @@
+# Autogenerated - do NOT edit!
+
+DEP_RELDIR := ${_PARSEDIR:S,${SRCTOP}/,,}
+
+DEP_MACHINE := ${.PARSEFILE:E}
+
+DIRDEPS = \
+ gnu/lib/libgcc \
+ include \
+ include/xlocale \
+ lib/${CSU_DIR} \
+ lib/libc \
+ lib/libgeom \
+
+
+.include <dirdeps.mk>
+
+.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+# local dependencies - needed for -jN in clean tree
+.endif
diff --git a/usr.sbin/bootparamd/bootparamd/Makefile.depend b/usr.sbin/bootparamd/bootparamd/Makefile.depend
new file mode 100644
index 0000000..4a1ecc5
--- /dev/null
+++ b/usr.sbin/bootparamd/bootparamd/Makefile.depend
@@ -0,0 +1,34 @@
+# Autogenerated - do NOT edit!
+
+DEP_RELDIR := ${_PARSEDIR:S,${SRCTOP}/,,}
+
+DEP_MACHINE := ${.PARSEFILE:E}
+
+DIRDEPS = \
+ gnu/lib/libgcc \
+ include \
+ include/arpa \
+ include/rpc \
+ include/rpcsvc \
+ include/xlocale \
+ lib/${CSU_DIR} \
+ lib/libc \
+
+
+.include <dirdeps.mk>
+
+.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+# local dependencies - needed for -jN in clean tree
+bootparam_prot_svc.o: bootparam_prot.h
+bootparam_prot_svc.o: bootparam_prot_svc.c
+bootparam_prot_svc.po: bootparam_prot.h
+bootparam_prot_svc.po: bootparam_prot_svc.c
+bootparam_prot_xdr.o: bootparam_prot.h
+bootparam_prot_xdr.o: bootparam_prot_xdr.c
+bootparam_prot_xdr.po: bootparam_prot.h
+bootparam_prot_xdr.po: bootparam_prot_xdr.c
+bootparamd.o: bootparam_prot.h
+bootparamd.po: bootparam_prot.h
+main.o: bootparam_prot.h
+main.po: bootparam_prot.h
+.endif
diff --git a/usr.sbin/bootparamd/callbootd/Makefile.depend b/usr.sbin/bootparamd/callbootd/Makefile.depend
new file mode 100644
index 0000000..a134d08
--- /dev/null
+++ b/usr.sbin/bootparamd/callbootd/Makefile.depend
@@ -0,0 +1,31 @@
+# Autogenerated - do NOT edit!
+
+DEP_RELDIR := ${_PARSEDIR:S,${SRCTOP}/,,}
+
+DEP_MACHINE := ${.PARSEFILE:E}
+
+DIRDEPS = \
+ gnu/lib/libgcc \
+ include \
+ include/arpa \
+ include/rpc \
+ include/xlocale \
+ lib/${CSU_DIR} \
+ lib/libc \
+
+
+.include <dirdeps.mk>
+
+.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+# local dependencies - needed for -jN in clean tree
+bootparam_prot_clnt.o: bootparam_prot.h
+bootparam_prot_clnt.o: bootparam_prot_clnt.c
+bootparam_prot_clnt.po: bootparam_prot.h
+bootparam_prot_clnt.po: bootparam_prot_clnt.c
+bootparam_prot_xdr.o: bootparam_prot.h
+bootparam_prot_xdr.o: bootparam_prot_xdr.c
+bootparam_prot_xdr.po: bootparam_prot.h
+bootparam_prot_xdr.po: bootparam_prot_xdr.c
+callbootd.o: bootparam_prot.h
+callbootd.po: bootparam_prot.h
+.endif
diff --git a/usr.sbin/bsdconfig/Makefile b/usr.sbin/bsdconfig/Makefile
new file mode 100644
index 0000000..7576194
--- /dev/null
+++ b/usr.sbin/bsdconfig/Makefile
@@ -0,0 +1,33 @@
+# $FreeBSD$
+
+NO_OBJ=
+
+SUBDIR= console \
+ diskmgmt \
+ docsinstall \
+ dot \
+ examples \
+ include \
+ mouse \
+ networking \
+ password \
+ security \
+ share \
+ startup \
+ timezone \
+ ttys \
+ usermgmt
+
+FILESDIR= ${LIBEXECDIR}/bsdconfig
+FILES= USAGE
+
+SCRIPTS= bsdconfig
+
+MAN= bsdconfig.8
+
+beforeinstall:
+ mkdir -p ${DESTDIR}${FILESDIR}
+ mkdir -p ${DESTDIR}${SCRIPTSDIR}
+ mkdir -p ${DESTDIR}${MANDIR}8
+
+.include <bsd.prog.mk>
diff --git a/usr.sbin/bsdconfig/USAGE b/usr.sbin/bsdconfig/USAGE
new file mode 100644
index 0000000..86355b0
--- /dev/null
+++ b/usr.sbin/bsdconfig/USAGE
@@ -0,0 +1,40 @@
+# Copyright (c) 2012 Ron McDowell
+# Copyright (c) 2012 Devin Teske
+# All Rights Reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in the
+# documentation and/or other materials provided with the distribution.
+#
+# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING BUT NOT LIMITED TO, THE
+# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+# DAMAGES (INLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+# SUCH DAMAGE.
+#
+# $FreeBSD$
+
+Usage:
+ @PROGRAM_NAME@ [-h]
+ @PROGRAM_NAME@ command [-h]
+ @PROGRAM_NAME@ [OPTIONS] [command [OPTIONS]]
+
+OPTIONS:
+ -h Print usage statement and exit.
+ -S Secure X11 mode (implies `-X'). As root, always prompt-for
+ and validate sudo(8) username/password before starting.
+ -X Use Xdialog(1) in place of dialog(1).
+
+COMMANDS:
+@COMMAND_LIST@
diff --git a/usr.sbin/bsdconfig/bsdconfig b/usr.sbin/bsdconfig/bsdconfig
new file mode 100755
index 0000000..f80e5a9
--- /dev/null
+++ b/usr.sbin/bsdconfig/bsdconfig
@@ -0,0 +1,335 @@
+#!/bin/sh
+#-
+# Copyright (c) 2012 Ron McDowell
+# Copyright (c) 2012 Devin Teske
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in the
+# documentation and/or other materials provided with the distribution.
+#
+# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+# SUCH DAMAGE.
+#
+# $FreeBSD$
+#
+############################################################ INCLUDES
+
+BSDCFG_SHARE="/usr/share/bsdconfig"
+. $BSDCFG_SHARE/common.subr || exit 1
+f_include $BSDCFG_SHARE/dialog.subr
+f_include $BSDCFG_SHARE/mustberoot.subr
+f_include $BSDCFG_SHARE/strings.subr
+
+BSDCFG_LIBE="/usr/libexec/bsdconfig"
+f_include_lang $BSDCFG_LIBE/include/messages.subr
+
+BSDCONFIG_HELPFILE=$BSDCFG_LIBE/include/bsdconfig.hlp
+USAGE_HELPFILE=$BSDCFG_LIBE/include/usage.hlp
+
+############################################################ FUNCTIONS
+
+# usage
+#
+# display usage and exit
+#
+usage()
+{
+ local index="INDEX" cmd_list=""
+
+ cd $BSDCFG_LIBE
+
+ # Test for language-specific indices
+ f_quietly ls */"$index.${LANG:-$LC_ALL}" &&
+ index="$index.${LANG:-$LC_ALL}"
+
+ cmd_list=$(
+ awk '/^menu_selection="/ {
+ sub(/\|.*/, "")
+ sub(/^menu_selection="/, "")
+ print
+ }' */$index | sort
+ )
+
+ #
+ # Determine the longest command-length (in characters)
+ #
+ local longest_cmd
+ longest_cmd=$( echo "$cmd_list" | f_longest_line_length )
+ f_dprintf "longest_cmd=[$longest_cmd]"
+
+ #
+ # Determine the maximum width of terminal/console
+ #
+ local max_size max_width
+ max_size=$( stty size 2> /dev/null )
+ : ${max_size:="24 80"}
+ max_width="${max_size#*[$IFS]}"
+ f_dprintf "max_width=[$max_width]"
+
+ #
+ # Using the longest command-length as the width of a single column,
+ # determine if we can use more than one column to display commands.
+ #
+ local x=$longest_cmd ncols=1
+ x=$(( $x + 8 )) # Accomodate leading tab character
+ x=$(( $x + 3 + $longest_cmd )) # Preload end of next column
+ while [ $x -lt $max_width ]; do
+ ncols=$(( $ncols + 1 ))
+ x=$(( $x + 3 + $longest_cmd ))
+ done
+ f_dprintf "ncols=[$ncols] x=[$x]"
+
+ #
+ # Re-format the command-list into multiple columns
+ #
+ cmd_list=$( eval "$( echo "$cmd_list" |
+ awk -v ncols=$ncols -v size=$longest_cmd '
+ BEGIN {
+ n = 0
+ row_item[1] = ""
+ }
+ function print_row()
+ {
+ fmt = "printf \"\\t%-" size "s"
+ for (i = 1; i < cur_col; i++)
+ fmt = fmt " %-" size "s"
+ fmt = fmt "\\n\""
+ printf "%s", fmt
+ for (i = 1; i <= cur_col; i++)
+ printf " \"%s\"", row_item[i]
+ print ""
+ }
+ {
+ n++
+ cur_col = (( n - 1 ) % ncols ) + 1
+ printf "f_dprintf \"row_item[%u]=[%s]\"\n", cur_col, $0
+ row_item[cur_col] = $0
+ if ( cur_col == ncols ) print_row()
+ }
+ END {
+ if ( cur_col < ncols ) print_row()
+ }' )"
+ )
+
+ f_usage $BSDCFG_LIBE/USAGE \
+ "PROGRAM_NAME" "$pgm" \
+ "COMMAND_LIST" "$cmd_list"
+}
+
+# dialog_menu_main
+#
+# Display the dialog(1)-based application main menu.
+#
+dialog_menu_main()
+{
+ local title="$DIALOG_TITLE"
+ local btitle="$DIALOG_BACKTITLE"
+ local prompt="$msg_menu_text"
+ local menu_list size
+
+ menu_list="
+ 'X' '$msg_exit' '$msg_exit_bsdconfig'
+ '1' '$msg_usage' '$msg_quick_start_how_to_use_this_menu_system'
+ " # END-QUOTE
+
+ local sanitize_awk="{ gsub(/'/, \"'\\\\''\"); print }"
+
+ local menuitem menu_title menu_help menu_selection index=2
+ for menuitem in $( ls -d [0-9][0-9][0-9].* ); do
+ [ $index -lt ${#DIALOG_MENU_TAGS} ] || break
+ tag=$( f_substr "$DIALOG_MENU_TAGS" $index 1 )
+
+ menu_program=
+ menu_title=
+ menu_help=
+ f_include_lang $menuitem/INDEX
+ [ "$menu_program" ] || continue
+
+ case "$menu_program" in
+ /*) : already fully qualified ;;
+ *)
+ menu_program="$menuitem/$menu_program"
+ esac
+
+ menu_title=$( echo "$menu_title" | awk "$sanitize_awk" )
+ menu_help=$( echo "$menu_help" | awk "$sanitize_awk" )
+ setvar "menu_program$tag" "$menu_program"
+ menu_list="$menu_list '$tag' '$menu_title' '$menu_help'"
+
+ index=$(( $index + 1 ))
+ done
+
+ size=$( eval f_dialog_menu_with_help_size \
+ \"\$title\" \
+ \"\$btitle\" \
+ \"\$prompt\" \
+ \"\" \
+ $menu_list )
+
+ local dialog_menu
+ dialog_menu=$( eval $DIALOG \
+ --clear \
+ --title \"\$title\" \
+ --backtitle \"\$btitle\" \
+ --item-help \
+ --ok-label \"\$msg_ok\" \
+ --cancel-label \"\$msg_exit_bsdconfig\" \
+ --help-button \
+ ${USE_XDIALOG:+--help \"\"} \
+ --menu \"\$prompt\" $size $menu_list \
+ 2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD
+ )
+ local retval=$?
+ setvar DIALOG_MENU_$$ "$dialog_menu"
+ return $retval
+}
+
+############################################################ MAIN
+
+#
+# Process command-line arguments
+#
+while getopts hSX flag; do
+ case "$flag" in
+ h|\?) usage;;
+ esac
+done
+shift $(( $OPTIND -1 ))
+
+#
+# Initialize
+#
+f_dialog_init
+f_dialog_title "$msg_main_menu"
+
+[ "$SECURE" ] && f_mustberoot_init
+
+# 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"
+
+#
+# If a non-option argument was passed, process it as a menuitem selection...
+#
+if [ "$1" ]; then
+ #
+ # ...unless it's a long-option for usage.
+ #
+ case "$1" in
+ -help|--help|-\?) usage;;
+ esac
+
+ #
+ # Find the INDEX (possibly i18n) claiming this keyword
+ #
+ lang="${LANG:-$LC_ALL}"
+ if [ "$lang" ]; then
+ sel=$( grep "^menu_selection=\"$1|" */INDEX.$lang \
+ 2> /dev/null | tail -1 )
+
+ # Fall-back to non-i18n sources if nothing was found
+ [ "$sel" ] ||
+ sel=$( grep "^menu_selection=\"$1|" */INDEX | tail -1 )
+ else
+ sel=$( grep "^menu_selection=\"$1|" */INDEX | tail -1 )
+ fi
+
+ #
+ # If no matches, display usage (which shows valid keywords)
+ #
+ if [ ! "$sel" ]; then
+ f_err "%s: %s: $msg_not_found\n" "$pgm" "$1"
+ usage
+ fi
+
+ #
+ # The command to execute is after the pipe-character (|) in the
+ # menu_selection property of the INDEX file for the menuitem.
+ #
+ cmd="${sel#*|}"
+ cmd="${cmd%\"}"
+ if [ ! "$cmd" ]; then
+ echo "$pgm: $1: $msg_not_found"
+ usage
+ fi
+ shift
+
+ #
+ # If the command pathname is not fully qualified fix-up/force to be
+ # relative to the menuitem directory.
+ #
+ case "$cmd" in
+ /*) : already fully qualified ;;
+ *)
+ dir="${sel%%/*}"
+ cmd="$dir/$cmd"
+ esac
+
+ exec $cmd ${USE_XDIALOG:+-X} "$@" || exit 1
+fi
+
+#
+# Launch application main menu
+#
+while :; do
+ dialog_menu_main
+ retval=$?
+ mtag=$( f_dialog_menutag )
+ f_dprintf "retval=$retval mtag=[$mtag]"
+
+ if [ $retval -eq 2 ]; then
+ # The Help button was pressed
+ f_show_help "$BSDCONFIG_HELPFILE"
+ continue
+ elif [ $retval -ne 0 ]; then
+ f_die
+ fi
+
+ case "$mtag" in
+ X) # Exit
+ break
+ ;;
+
+ 1) # Usage
+ f_show_help "$USAGE_HELPFILE"
+ continue
+ ;;
+
+ *) # Dynamically loaded menuitem
+ cmd=$( eval echo \"\$menu_program$mtag\" )
+ f_dprintf "cmd=[$cmd]"
+ $cmd ${USE_XDIALOG:+-X}
+ ;;
+
+ esac
+done
+
+exit $SUCCESS
+
+################################################################################
+# END
+################################################################################
diff --git a/usr.sbin/bsdconfig/bsdconfig.8 b/usr.sbin/bsdconfig/bsdconfig.8
new file mode 100644
index 0000000..5bb3e73
--- /dev/null
+++ b/usr.sbin/bsdconfig/bsdconfig.8
@@ -0,0 +1,233 @@
+.\" Copyright (c) 2012 Ron McDowell
+.\" Copyright (c) 2012 Devin Teske
+.\" All rights reserved.
+.\"
+.\" Redistribution and use in source and binary forms, with or without
+.\" modification, are permitted provided that the following conditions
+.\" are met:
+.\" 1. Redistributions of source code must retain the above copyright
+.\" notice, this list of conditions and the following disclaimer.
+.\" 2. Redistributions in binary form must reproduce the above copyright
+.\" notice, this list of conditions and the following disclaimer in the
+.\" documentation and/or other materials provided with the distribution.
+.\"
+.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+.\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+.\" WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+.\" DISCLAIMED. IN NO EVENT SHALL THE AUTHOR 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.
+.\"
+.\" docsinstall
+.\" password
+.\" diskmgmt
+.\" usermgmt
+.\" useradd
+.\" useredit
+.\" userdel
+.\" groupmgmt
+.\" groupadd
+.\" groupedit
+.\" groupdel
+.\" console
+.\" syscons_font
+.\" syscons_keymap
+.\" syscons_repeat
+.\" syscons_saver
+.\" syscons_screenmap
+.\" syscons_ttys
+.\" timezone
+.\" mouse
+.\" mouse_enable
+.\" mouse_type
+.\" mouse_port
+.\" mouse_flags
+.\" mouse_disable
+.\" networking
+.\" defaultrouter
+.\" hostname
+.\" nameservers
+.\" netdev
+.\" security
+.\" ttys
+.\" [dot]
+.\"
+.\" $FreeBSD$
+.\"
+.Dd Mar 20, 2012
+.Dt BSDCONFIG 8
+.Os
+.Sh NAME
+.Nm bsdconfig
+.Nd system configuration utility
+.Sh SYNOPSIS
+.Nm
+.Op Fl h
+.Nm
+.Ar command
+.Op Fl h
+.Nm
+.Op OPTIONS
+.Op command Op OPTIONS
+.Sh DESCRIPTION
+.Nm
+is used to set up many system configuration settings, both for new systems, as
+well as changing configuration settings of existing systems.
+.Pp
+.Nm
+takes a command as an argument. If invoked with no arguments, it will bring up
+a master menu listing the available commands.
+.Pp
+The following options are available:
+.Bl -tag -width indent+
+.It Fl h
+Print usage statement and exit.
+.It Fl S
+Secure X11 mode
+.Pq implies Fl X .
+As root, always prompt-for and validate
+.Xr sudo 8
+username/password before starting.
+.It Fl X
+Use
+.Xr Xdialog 1
+in place of
+.Xr dialog 1 .
+.El
+.Sh COMMANDS
+The following commands
+.Pq sorted alphabetically
+are currently included in the base
+.Nm
+program, with more to be added soon. Other commands can be added, as detailed
+below in the
+.Cm ADDING COMMANDS
+section, and once added, will appear in the master menu as well as in the
+.Cm -h
+listing.
+.Bl -tag -width ".Cm syscons_screenmap"
+.It Cm console
+Utilities to customize the behavior of the system console.
+.It Cm defaultrouter
+Shortcut to the Default Router/Gateway menu under networking.
+.It Cm diskmgmt
+Manage disk partitions and/or labels. Executes
+.Xr sade 8 .
+.It Cm docsinstall
+Executes the
+.Cm bsdinstall docsinstall
+sub-utility to allow installation/re-installation of the FreeBSD Documentation
+set(s).
+.It Cm dot
+Generate a graphviz
+.Xr dot 1
+language file
+.Pq printed on stdout
+visualizing the
+.Nm
+menu, include, and shortcut structure and relationships. See
+.Dq bsdconfig dot -h
+for more details.
+.It Cm groupadd
+Shortcut to the Add Groups menu under groupmgmt.
+.It Cm groupdel
+Shortcut to the Delete Groups menu under groupmgmt.
+.It Cm groupedit
+Shortcut to the Edit/View Groups menu under groupmgmt.
+.It Cm groupmgmt
+Utilities to Add/Change/View/Delete Group Accounts.
+.It Cm hostname
+Shortcut to the Hostname/Domain menu under networking.
+.It Cm mouse
+Utilities for configuring, exploring, and enabling console mouse support.
+.It Cm mouse_disable
+Shortcut to the Disable menu under mouse.
+.It Cm mouse_enable
+Shortcut to the Enable menu under mouse.
+.It Cm mouse_flags
+Shortcut to the Flags menu under mouse.
+.It Cm mouse_port
+Shortcut to the Port menu under mouse.
+.It Cm mouse_type
+Shortcut to the Type menu under mouse.
+.It Cm nameservers
+Shortcut to the DNS Nameservers menu under networking.
+.It Cm netdev
+Shortcut to the Network Interfaces menu under networking.
+.It Cm networking
+Utilities to set/change Hostname/Domain, Network Interfaces, Default
+Router/Gateway, and DNS Nameservers.
+.It Cm password
+Set the system administrator
+.Pq root
+password.
+.It Cm security
+Configure various system security settings.
+.It Cm syscons_font
+Shortcut to the Font menu under console.
+.It Cm syscons_keymap
+Shortcut to the Keymap menu under console.
+.It Cm syscons_repeat
+Shortcut to the Repeat menu under console.
+.It Cm syscons_saver
+Shortcut to the Saver menu under console.
+.It Cm syscons_screenmap
+Shortcut to the Screenmap menu under console.
+.It Cm syscons_ttys
+Shortcut to the Ttys menu under console.
+.It Cm timezone
+Set the regional timezone of the local machine.
+.It Cm useradd
+Shortcut to the Add Users menu under usermgmt.
+.It Cm userdel
+Shortcut to the Delete Users menu under usermgmt.
+.It Cm useredit
+Shortcut to the Edit/View Users menu under usermgmt.
+.It Cm usermgmt
+Utilities to Add/Edit/View/Delete User Accounts.
+.El
+.Sh INTERNATIONALIZATION
+i18n features are built into
+.Nm
+and language-specific translation files will be added as they become available.
+In the absence of language-specific translation files, the default
+.Pq en_US.ISO8859-1
+files will be used.
+.Sh ADDING COMMANDS
+To be documented later. Document menu_selection="command|*" syntax of INDEX
+files.
+.Sh ENVIRONMENT VARIABLES
+The following environment variables affect the execution of
+.Nm :
+.Bl -tag -width ".Ev LC_ALL"
+.It Ev LANG
+If LANG is set, messages and index information will be read from files named
+messages.$LANG and INDEX.$LANG and fall back to files named messages and INDEX if
+messages.$LANG and INDEX.$LANG do not exist. LANG takes precedence over LC_ALL.
+.It Ev LC_ALL
+If LC_ALL is set, messages and index information will be read from files named
+messages.$LC_ALL and INDEX.$LC_ALL and fall back to files named messages and INDEX if
+messages.$LC_ALL and INDEX.$LC_ALL do not exist.
+.El
+.Sh FILES
+/usr/share/examples/bsdconfig/bsdconfigrc can be copied to $HOME/.bsdconfigrc and
+customized as needed.
+.Sh EXIT STATUS
+.Ex -std
+.Sh SEE ALSO
+.Xr host-setup 8 ,
+.Xr sade 8
+.Sh HISTORY
+.Nm
+first appeared in
+.Fx 10.0 .
+.Sh AUTHORS
+.An Ron McDowell Aq rcm@FuzzWad.ORG
+.An Devin Teske Aq devinteske@hotmail.com
+.Sh BUGS
+Undoubtedly.
diff --git a/usr.sbin/bsdconfig/console/INDEX b/usr.sbin/bsdconfig/console/INDEX
new file mode 100644
index 0000000..30ebcf8
--- /dev/null
+++ b/usr.sbin/bsdconfig/console/INDEX
@@ -0,0 +1,59 @@
+# Copyright (c) 2012 Ron McDowell
+# Copyright (c) 2012 Devin Teske
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in the
+# documentation and/or other materials provided with the distribution.
+#
+# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+# SUCH DAMAGE.
+#
+# $FreeBSD$
+
+#
+# Title that will be shown on the bsdconfig menu
+menu_title="Console"
+#
+# a short descriptive line shown at the bottom of the bsdconfig menu.
+# keep it short because any line longer than the terminal width will
+# be truncated.
+menu_help="Customize system console behavior"
+#
+# two-part variable that defines an action to take when 'keyword'
+# is passed on a bsdconfig command line. variable takes the form
+# "keyword|command" and multiple occurrences of the variable
+# (with different 'keyword's, or different 'keyword's AND 'command's)
+# are allowed. If 'command' begins with a '/' then the full
+# path to the program is needed. If 'command' begins with anything
+# else it is a path relative to the directory this INDEX file is in.
+# 'keyword' can be i18n'ed but 'command' is the name of a script.
+menu_selection="console|console"
+menu_selection="syscons_font|font"
+menu_selection="syscons_keymap|keymap"
+menu_selection="syscons_repeat|repeat"
+menu_selection="syscons_saver|saver"
+menu_selection="syscons_screenmap|screenmap"
+menu_selection="syscons_ttys|ttys"
+#
+# Items below this line do NOT need i18n translation----------------------
+#
+# Name of the program to be run when this menu choice is selected.
+# if it begins with a '/' then the full path to the program is needed.
+# if it begins with anything else it is a path relative to the directory
+# this INDEX file is in.
+menu_program="console"
diff --git a/usr.sbin/bsdconfig/console/Makefile b/usr.sbin/bsdconfig/console/Makefile
new file mode 100644
index 0000000..aa6c6f1
--- /dev/null
+++ b/usr.sbin/bsdconfig/console/Makefile
@@ -0,0 +1,16 @@
+# $FreeBSD$
+
+NO_OBJ=
+
+SUBDIR= include
+
+FILESDIR= ${LIBEXECDIR}/bsdconfig/080.console
+FILES= INDEX USAGE
+
+SCRIPTSDIR= ${FILESDIR}
+SCRIPTS= console font keymap repeat saver screenmap ttys
+
+beforeinstall:
+ mkdir -p ${DESTDIR}${FILESDIR}
+
+.include <bsd.prog.mk>
diff --git a/usr.sbin/bsdconfig/console/USAGE b/usr.sbin/bsdconfig/console/USAGE
new file mode 100644
index 0000000..9aa4dca
--- /dev/null
+++ b/usr.sbin/bsdconfig/console/USAGE
@@ -0,0 +1,33 @@
+# Copyright (c) 2012 Devin Teske
+# All Rights Reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in the
+# documentation and/or other materials provided with the distribution.
+#
+# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING BUT NOT LIMITED TO, THE
+# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+# DAMAGES (INLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+# SUCH DAMAGE.
+#
+# $FreeBSD$
+
+Usage: bsdconfig @PROGRAM_NAME@ [OPTIONS]
+
+OPTIONS:
+ -h Print usage statement and exit.
+ -S Secure X11 mode (implies `-X'). As root, always prompt-for
+ and validate sudo(8) username/password before starting.
+ -X Use Xdialog(1) in place of dialog(1).
diff --git a/usr.sbin/bsdconfig/console/console b/usr.sbin/bsdconfig/console/console
new file mode 100755
index 0000000..73d9f5b
--- /dev/null
+++ b/usr.sbin/bsdconfig/console/console
@@ -0,0 +1,142 @@
+#!/bin/sh
+#-
+# Copyright (c) 2012 Devin Teske
+# All Rights Reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in the
+# documentation and/or other materials provided with the distribution.
+#
+# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING BUT NOT LIMITED TO, THE
+# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+# DAMAGES (INLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+# SUCH DAMAGE.
+#
+# $FreeBSD$
+#
+############################################################ INCLUDES
+
+BSDCFG_SHARE="/usr/share/bsdconfig"
+. $BSDCFG_SHARE/common.subr || exit 1
+f_include $BSDCFG_SHARE/dialog.subr
+f_include $BSDCFG_SHARE/mustberoot.subr
+
+BSDCFG_LIBE="/usr/libexec/bsdconfig" APP_DIR="080.console"
+f_include_lang $BSDCFG_LIBE/$APP_DIR/include/messages.subr
+
+ipgm=$( f_index_menu_selection $BSDCFG_LIBE/$APP_DIR/INDEX "$pgm" )
+[ $? -eq $SUCCESS -a "$ipgm" ] && pgm="$ipgm"
+
+############################################################ FUNCTIONS
+
+# dialog_menu_main
+#
+# Display the dialog(1)-based application main menu.
+#
+dialog_menu_main()
+{
+ local menu_list size
+ local hline="$hline_configure_system_console_settings"
+ local prompt="$msg_console_menu_text"
+
+ menu_list="
+ 'X $msg_exit' '$msg_exit_this_menu'
+ '2 $msg_font' '$msg_choose_alternate_screen_font'
+ '3 $msg_keymap' '$msg_choose_alternate_keyboard_map'
+ '4 $msg_repeat' '$msg_set_repeat_rate'
+ '5 $msg_saver' '$msg_configure_screen_saver'
+ '6 $msg_screenmap' '$msg_choose_alternate_screenmap'
+ '7 $msg_ttys' '$msg_choose_console_terminal_type'
+ " # END-QUOTE
+
+ size=$( eval f_dialog_menu_size \
+ \"\$DIALOG_TITLE\" \
+ \"\$DIALOG_BACKTITLE\" \
+ \"\$prompt\" \
+ \"\$hline\" \
+ $menu_list )
+
+ local dialog_menu
+ dialog_menu=$( eval $DIALOG \
+ --clear --title \"\$DIALOG_TITLE\" \
+ --backtitle \"\$DIALOG_BACKTITLE\" \
+ --hline \"\$hline\" \
+ --ok-label \"\$msg_ok\" \
+ --cancel-label \"\$msg_cancel\" \
+ --menu \"\$prompt\" $size \
+ $menu_list \
+ 2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD
+ )
+ local retval=$?
+ setvar DIALOG_MENU_$$ "$dialog_menu"
+ return $retval
+}
+
+############################################################ MAIN
+
+# Incorporate rc-file if it exists
+[ -f "$HOME/.bsdconfigrc" ] && f_include "$HOME/.bsdconfigrc"
+
+#
+# Process command-line arguments
+#
+while getopts hSX flag; do
+ case "$flag" in
+ h|\?) f_usage $BSDCFG_LIBE/$APP_DIR/USAGE "PROGRAM_NAME" "$pgm";;
+ esac
+done
+shift $(( $OPTIND - 1 ))
+
+#
+# Initialize
+#
+f_dialog_init
+f_dialog_title "$msg_system_console_configuration"
+f_dialog_backtitle "${ipgm:+bsdconfig }$pgm"
+f_mustberoot_init
+
+#
+# Launch application main menu
+#
+while :; do
+ dialog_menu_main
+ retval=$?
+ mtag=$( f_dialog_menutag )
+
+ [ $retval -eq 0 ] || f_die
+
+ case "$mtag" in
+ "X $msg_exit") break ;;
+ "2 $msg_font") # Choose an alternate screen font
+ $BSDCFG_LIBE/$APP_DIR/font ${USE_XDIALOG:+-X} ;;
+ "3 $msg_keymap") # Choose an alternate keyboard map
+ $BSDCFG_LIBE/$APP_DIR/keymap ${USE_XDIALOG:+-X} ;;
+ "4 $msg_repeat") # Set the rate at which keys repeat
+ $BSDCFG_LIBE/$APP_DIR/repeat ${USE_XDIALOG:+-X} ;;
+ "5 $msg_saver") # Configure the screen saver
+ $BSDCFG_LIBE/$APP_DIR/saver ${USE_XDIALOG:+-X} ;;
+ "6 $msg_screenmap") # Choose an alternate screenmap
+ $BSDCFG_LIBE/$APP_DIR/screenmap ${USE_XDIALOG:+-X} ;;
+ "7 $msg_ttys") # Choose console terminal type
+ $BSDCFG_LIBE/$APP_DIR/ttys ${USE_XDIALOG:+-X} ;;
+ esac
+
+done
+
+exit $SUCCESS
+
+################################################################################
+# END
+################################################################################
diff --git a/usr.sbin/bsdconfig/console/font b/usr.sbin/bsdconfig/console/font
new file mode 100755
index 0000000..2fe4611
--- /dev/null
+++ b/usr.sbin/bsdconfig/console/font
@@ -0,0 +1,210 @@
+#!/bin/sh
+#-
+# Copyright (c) 2012 Devin Teske
+# All Rights Reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in the
+# documentation and/or other materials provided with the distribution.
+#
+# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING BUT NOT LIMITED TO, THE
+# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+# DAMAGES (INLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+# SUCH DAMAGE.
+#
+# $FreeBSD$
+#
+############################################################ INCLUDES
+
+BSDCFG_SHARE="/usr/share/bsdconfig"
+. $BSDCFG_SHARE/common.subr || exit 1
+f_include $BSDCFG_SHARE/dialog.subr
+f_include $BSDCFG_SHARE/mustberoot.subr
+f_include $BSDCFG_SHARE/sysrc.subr
+
+BSDCFG_LIBE="/usr/libexec/bsdconfig" APP_DIR="080.console"
+f_include_lang $BSDCFG_LIBE/$APP_DIR/include/messages.subr
+
+ipgm=$( f_index_menu_selection $BSDCFG_LIBE/$APP_DIR/INDEX "$pgm" )
+[ $? -eq $SUCCESS -a "$ipgm" ] && pgm="$ipgm"
+
+############################################################ FUNCTIONS
+
+# dialog_menu_main
+#
+# Display the dialog(1)-based application main menu.
+#
+dialog_menu_main()
+{
+ local menu_list size
+ local hline="$hline_choose_a_font"
+ local prompt="$msg_font_menu_text"
+
+ menu_list="
+ '1 $msg_none' '$msg_use_hardware_default_font'
+ '2 $msg_ibm_437' '$msg_ibm_437_desc'
+ '3 $msg_ibm_850' '$msg_ibm_850_desc'
+ '4 $msg_ibm_865' '$msg_ibm_865_desc'
+ '5 $msg_ibm_866' '$msg_ibm_866_desc'
+ '6 $msg_ibm_866u' '$msg_ibm_866u_desc'
+ '7 $msg_ibm_1251' '$msg_ibm_1251_desc'
+ '8 $msg_iso_8859_1' '$msg_iso_8859_1_desc'
+ '9 $msg_iso_8859_2' '$msg_iso_8859_2_desc'
+ 'a $msg_iso_8859_4' '$msg_iso_8859_4_desc'
+ 'b $msg_iso_8859_7' '$msg_iso_8859_7_desc'
+ 'c $msg_iso_8859_8' '$msg_iso_8859_8_desc'
+ 'd $msg_iso_8859_15' '$msg_iso_8859_15_desc'
+ 'e $msg_swiss' '$msg_swiss_desc'
+ " # END-QUOTE
+
+ size=$( eval f_dialog_menu_size \
+ \"\$DIALOG_TITLE\" \
+ \"\$DIALOG_BACKTITLE\" \
+ \"\$prompt\" \
+ \"\$hline\" \
+ $menu_list )
+
+ local dialog_menu
+ dialog_menu=$( eval $DIALOG \
+ --clear --title \"\$DIALOG_TITLE\" \
+ --backtitle \"\$DIALOG_BACKTITLE\" \
+ --hline \"\$hline\" \
+ --ok-label \"\$msg_ok\" \
+ --cancel-label \"\$msg_cancel\" \
+ --menu \"\$prompt\" $size \
+ $menu_list \
+ 2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD
+ )
+ local retval=$?
+ setvar DIALOG_MENU_$$ "$dialog_menu"
+ return $retval
+}
+
+############################################################ MAIN
+
+# Incorporate rc-file if it exists
+[ -f "$HOME/.bsdconfigrc" ] && f_include "$HOME/.bsdconfigrc"
+
+#
+# Process command-line arguments
+#
+while getopts hSX flag; do
+ case "$flag" in
+ h|\?) f_usage $BSDCFG_LIBE/$APP_DIR/USAGE "PROGRAM_NAME" "$pgm";;
+ esac
+done
+shift $(( $OPTIND - 1 ))
+
+#
+# Initialize
+#
+f_dialog_init
+f_dialog_title "$msg_system_console_font"
+f_dialog_backtitle "${ipgm:+bsdconfig }$pgm"
+f_mustberoot_init
+
+#
+# Launch application main menu
+#
+while :; do
+ dialog_menu_main
+ retval=$?
+ mtag=$( f_dialog_menutag )
+
+ [ $retval -eq 0 ] || f_die
+
+ case "$mtag" in
+ "1 $msg_none") # Use hardware default font
+ f_sysrc_set font8x8 "NO" || f_die
+ f_sysrc_set font8x14 "NO" || f_die
+ f_sysrc_set font8x16 "NO" || f_die
+ break ;;
+ "2 $msg_ibm_437") # English and others, VGA default
+ f_sysrc_set font8x8 "cp437-8x8" || f_die
+ f_sysrc_set font8x14 "cp437-8x14" || f_die
+ f_sysrc_set font8x16 "cp437-8x16" || f_die
+ break ;;
+ "3 $msg_ibm_850") # Western Europe, IBM encoding
+ f_sysrc_set font8x8 "cp850-8x8" || f_die
+ f_sysrc_set font8x14 "cp850-8x14" || f_die
+ f_sysrc_set font8x16 "cp850-8x16" || f_die
+ break ;;
+ "4 $msg_ibm_865") # Norwegian, IBM encoding
+ f_sysrc_set font8x8 "cp865-8x8" || f_die
+ f_sysrc_set font8x14 "cp865-8x14" || f_die
+ f_sysrc_set font8x16 "cp865-8x16" || f_die
+ break ;;
+ "5 $msg_ibm_866") # Russian, IBM encoding (use with KOI8-R screenmap)
+ f_sysrc_set font8x8 "cp866-8x8" || f_die
+ f_sysrc_set font8x14 "cp866-8x14" || f_die
+ f_sysrc_set font8x16 "cp866b-8x16" || f_die
+ f_sysrc_set mousechar_start 3 || f_die
+ break ;;
+ "6 $msg_ibm_866u") # Ukrainian, IBM encoding (use w/ KOI8-U screenmap)
+ f_sysrc_set font8x8 "cp866u-8x8" || f_die
+ f_sysrc_set font8x14 "cp866u-8x14" || f_die
+ f_sysrc_set font8x16 "cp866u-8x16" || f_die
+ f_sysrc_set mousechar_start 3 || f_die
+ break ;;
+ "7 $msg_ibm_1251") # Cyrillic, MS Windows encoding
+ f_sysrc_set font8x8 "cp1251-8x8" || f_die
+ f_sysrc_set font8x14 "cp1251-8x14" || f_die
+ f_sysrc_set font8x16 "cp1251-8x16" || f_die
+ f_sysrc_set mousechar_start 3 || f_die
+ break ;;
+ "8 $msg_iso_8859_1") # Western Europe, ISO encoding
+ f_sysrc_set font8x8 "iso-8x8" || f_die
+ f_sysrc_set font8x14 "iso-8x14" || f_die
+ f_sysrc_set font8x16 "iso-8x16" || f_die
+ break ;;
+ "9 $msg_iso_8859_2") # Eastern Europe, ISO encoding
+ f_sysrc_set font8x8 "iso02-8x8" || f_die
+ f_sysrc_set font8x14 "iso02-8x14" || f_die
+ f_sysrc_set font8x16 "iso02-8x16" || f_die
+ break ;;
+ "a $msg_iso_8859_4") # Baltic, ISO encoding
+ f_sysrc_set font8x8 "iso04-8x8" || f_die
+ f_sysrc_set font8x14 "iso04-8x14" || f_die
+ f_sysrc_set font8x16 "iso04-8x16" || f_die
+ break ;;
+ "b $msg_iso_8859_7") # Greek, ISO encoding
+ f_sysrc_set font8x8 "iso07-8x8" || f_die
+ f_sysrc_set font8x14 "iso07-8x14" || f_die
+ f_sysrc_set font8x16 "iso07-8x16" || f_die
+ break ;;
+ "c $msg_iso_8859_8") # Hebrew, ISO encoding
+ f_sysrc_set font8x8 "iso08-8x8" || f_die
+ f_sysrc_set font8x14 "iso08-8x14" || f_die
+ f_sysrc_set font8x16 "iso08-8x16" || f_die
+ break ;;
+ "d $msg_iso_8859_15") # Europe, ISO encoding
+ f_sysrc_set font8x8 "iso15-8x8" || f_die
+ f_sysrc_set font8x14 "iso15-8x14" || f_die
+ f_sysrc_set font8x16 "iso15-8x16" || f_die
+ break ;;
+ "e $msg_swiss") # English, better resolution
+ f_sysrc_set font8x8 "swiss-8x8" || f_die
+ f_sysrc_set font8x14 "NO" || f_die
+ f_sysrc_set font8x16 "swiss-8x16" || f_die
+ break ;;
+ esac
+
+done
+
+exit $SUCCESS
+
+################################################################################
+# END
+################################################################################
diff --git a/usr.sbin/bsdconfig/console/include/Makefile b/usr.sbin/bsdconfig/console/include/Makefile
new file mode 100644
index 0000000..e915751
--- /dev/null
+++ b/usr.sbin/bsdconfig/console/include/Makefile
@@ -0,0 +1,11 @@
+# $FreeBSD$
+
+NO_OBJ=
+
+FILESDIR= ${LIBEXECDIR}/bsdconfig/080.console/include
+FILES= messages.subr
+
+beforeinstall:
+ mkdir -p ${DESTDIR}${FILESDIR}
+
+.include <bsd.prog.mk>
diff --git a/usr.sbin/bsdconfig/console/include/messages.subr b/usr.sbin/bsdconfig/console/include/messages.subr
new file mode 100644
index 0000000..ffc9084
--- /dev/null
+++ b/usr.sbin/bsdconfig/console/include/messages.subr
@@ -0,0 +1,264 @@
+# Copyright (c) 2012 Devin Teske
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in the
+# documentation and/or other materials provided with the distribution.
+#
+# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+# SUCH DAMAGE.
+#
+# $FreeBSD$
+
+hline_choose_a_font="Choose a font"
+hline_choose_a_keyboard_map="Choose a keyboard map"
+hline_choose_a_keyboard_repeat_rate="Choose a keyboard repeat rate"
+hline_choose_a_screen_map="Choose a screen map"
+hline_choose_a_screen_saver="Choose a nifty-looking screen saver"
+hline_choose_a_terminal_type="Choose a terminal type"
+hline_configure_system_console_settings="Configure your system console settings"
+msg_beastie="Beastie"
+msg_beastie_desc="\"BSD Daemon\" animated screen saver (graphics)"
+msg_belgian="Belgian"
+msg_belgian_desc="Belgian ISO keymap"
+msg_blank="Blank"
+msg_blank_desc="Simply blank the screen"
+msg_brazil_cp850="Brazil CP850"
+msg_brazil_cp850_desc="Brazil CP850 keymap"
+msg_brazil_iso="Brazil ISO"
+msg_brazil_iso_accent="Brazil ISO (accent)"
+msg_brazil_iso_accent_desc="Brazil ISO keymap (accent keys)"
+msg_brazil_iso_desc="Brazil ISO keymap"
+msg_bulgarian_bds="Bulgarian BDS"
+msg_bulgarian_bds_desc="Bulgarian BDS keymap"
+msg_bulgarian_phonetic="Bulgarian Phonetic"
+msg_bulgarian_phonetic_desc="Bulgarian Phonetic keymap"
+msg_cancel="Cancel"
+msg_central_european_iso="Central European ISO"
+msg_central_european_iso_desc="Central European ISO keymap"
+msg_choose_alternate_keyboard_map="Choose an alternate keyboard map"
+msg_choose_alternate_screenmap="Choose an alternate screenmap"
+msg_choose_alternate_screen_font="Choose an alternate screen font"
+msg_choose_console_terminal_type="Choose console terminal type"
+msg_configure_screen_saver="Configure the screen saver"
+msg_console_menu_text="The system console driver for FreeBSD has a number of configuration\noptions which may be set according to your preference.\n\nWhen you are done setting configuration options, select Cancel."
+msg_croatian_iso="Croation ISO"
+msg_croatian_iso_desc="Croation ISO keymap"
+msg_czech_iso_accent="Czech ISO (accent)"
+msg_czech_iso_accent_desc="Czech ISO keymap (accent keys)"
+msg_daemon="Daemon"
+msg_daemon_desc="\"BSD Daemon\" animated screen saver (text)"
+msg_danish_cp865="Danish CP865"
+msg_danish_cp865_desc="Danish Code Page 865 keymap"
+msg_danish_iso="Danish ISO"
+msg_danish_iso_desc="Danish ISO keymap"
+msg_default="Default"
+msg_default_desc="Use default keyboard repeat rate"
+msg_dragon="Dragon"
+msg_dragon_desc="Dragon screensaver (graphics)"
+msg_enter_timeout_period="Enter time-out period in seconds for screen saver"
+msg_estonian_cp850="Estonian CP850"
+msg_estonian_cp850_desc="Estonian Code Page 850 keymap"
+msg_estonian_iso="Estonian ISO"
+msg_estonian_iso_desc="Estonian ISO keymap"
+msg_estonian_iso_15="Estonian ISO 15"
+msg_estonian_iso_15_desc="Estonian ISO 8859-15 keymap"
+msg_exit="Exit"
+msg_exit_this_menu="Exit this menu (returning to previous)"
+msg_fade="Fade"
+msg_fade_desc="Fade out effect screen saver"
+msg_fast="Fast"
+msg_fast_desc="Fast keyboard repeat rate"
+msg_finnish_cp850="Finnish CP850"
+msg_finnish_cp850_desc="Finnish Code Page 850 keymap"
+msg_finnish_iso="Finnish ISO"
+msg_finnish_iso_desc="Finnish ISO keymap"
+msg_fire="Fire"
+msg_fire_desc="Flames effect screen saver"
+msg_font="Font"
+msg_font_menu_text="Most PC hardware defaults to displaying characters in the\nIBM 437 character set. However, in the Unix world, this\ncharacter set is very rarely used. Most Western European\ncountries, for example, prefer ISO 8859-1.\nAmerican users won't notice the difference since the bottom half\nof all these charactersets is ANSI anyway. However, they might\nwant to load a font anyway to use the 30- or 50-line displays.\nIf your hardware is capable of downloading a new display font,\nyou can select the appropriate font below."
+msg_french_iso="French ISO"
+msg_french_iso_accent="French ISO (accent)"
+msg_french_iso_accent_desc="French ISO keymap (accent keys)"
+msg_french_iso_desc="French ISO keymap"
+msg_french_iso_macbook="French ISO/Macbook"
+msg_french_iso_macbook_desc="French ISO keymap on macbook"
+msg_green="Green"
+msg_green_desc="\"Green\" power saving mode (if supported by monitor)"
+msg_german_cp850="German CP850"
+msg_german_cp850_desc="German Code Page 850 keymap"
+msg_german_iso="German ISO"
+msg_german_iso_desc="German ISO keymap"
+msg_greek_101="Greek 101"
+msg_greek_101_desc="Greek ISO keymap (101 keys)"
+msg_greek_104="Greek 104"
+msg_greek_104_desc="Greek ISO keymap (104 keys)"
+msg_greek_elot="Greek ELOT"
+msg_greek_elot_desc="Greek ISO keymap (ELOT 1000)"
+msg_hungarian_101="Hungarian 101"
+msg_hungarian_101_desc="Hungarian ISO keymap (101 key)"
+msg_hungarian_102="Hungarian 102"
+msg_hungarian_102_desc="Hungarian ISO keymap (102 key)"
+msg_ibm_437="IBM 437"
+msg_ibm_437_desc="English and others, VGA default"
+msg_ibm_437_vga_default="IBM437 (VGA default)"
+msg_ibm_850="IBM 850"
+msg_ibm_850_desc="Western Europe, IBM encoding"
+msg_ibm_865="IBM 865"
+msg_ibm_865_desc="Norwegian, IBM encoding"
+msg_ibm_866="IBM 866"
+msg_ibm_866_desc="Russian, IBM encoding (use with KOI8-R screenmap)"
+msg_ibm_866u="IBM 866u"
+msg_ibm_866u_desc="Ukrainian, IBM encoding (use with KOI8-U screenmap)"
+msg_ibm_1251="IBM 1251"
+msg_ibm_1251_desc="Cyrillic, MS Windows encoding"
+msg_icelandic="Icelandic"
+msg_icelandic_accent="Icelandic (accent)"
+msg_icelandic_accent_desc="Icelandic ISO keymap (accent keys)"
+msg_icelandic_desc="Icelandic ISO keymap"
+msg_iso_8859_1="ISO 8859-1"
+msg_iso_8859_1_desc="Western Europe, ISO encoding"
+msg_iso_8859_1_to_ibm437="ISO 8859-1 to IBM437"
+msg_iso_8859_1_to_ibm437_desc="W-Europe ISO 8859-1 to IBM 437 screenmap"
+msg_iso_8859_2="ISO 8859-2"
+msg_iso_8859_2_desc="Eastern Europe, ISO encoding"
+msg_iso_8859_4="ISO 8859-4"
+msg_iso_8859_4_desc="Baltic, ISO encoding"
+msg_iso_8859_7="ISO 8859-7"
+msg_iso_8859_7_desc="Greek, ISO encoding"
+msg_iso_8859_7_to_ibm437="ISO 8859-7 to IBM437"
+msg_iso_8859_7_to_ibm437_desc="Greek ISO 8859-1 to IBM 437 screenmap"
+msg_iso_8859_8="ISO 8859-8"
+msg_iso_8859_8_desc="Hebrew, ISO encoding"
+msg_iso_8859_15="ISO 8859-15"
+msg_iso_8859_15_desc="Europe, ISO encoding"
+msg_italian="Italian"
+msg_italian_desc="Italian ISO keymap"
+msg_japanese_106="Japanese 106"
+msg_japanese_106_desc="Japanese 106 keymap"
+msg_keymap="Keymap"
+msg_keymap_menu_text="The system console driver for FreeBSD defaults to a standard\n\"US\" keyboard map. Users may wish to choose one of the\nother keymaps below."
+msg_koi8_r="KOI8-R"
+msg_koi8_u="KOI8-U"
+msg_koi8_r_to_ibm866="KOI8-R to IBM866"
+msg_koi8_r_to_ibm866_desc="Russian KOI8-R to IBM 866 screenmap"
+msg_koi8_u_to_ibm866u="KOI8-U to IBM866u"
+msg_koi8_u_to_ibm866u_desc="Ukrainian KOI8-U to IBM 866u screenmap"
+msg_latin_american="Latin American"
+msg_latin_american_accent="Latin American (accent)"
+msg_latin_american_accent_desc="Latin American ISO keymap (accent keys)"
+msg_latin_american_desc="Latin American ISO keymap"
+msg_logo="Logo"
+msg_logo_desc="FreeBSD \"logo\" animated screen saver (graphics)"
+msg_none="None"
+msg_none_saver_desc="Disable the screensaver"
+msg_none_screenmap_desc="No screenmap, don'\''t touch font"
+msg_none_ttys_desc="Don'\''t touch anything"
+msg_normal="Normal"
+msg_normal_desc="\"Normal\" keyboard repeat rate"
+msg_norway_iso="Norway ISO"
+msg_norway_iso_desc="Norwegian ISO keymap"
+msg_ok="OK"
+msg_polish_iso="Polish ISO"
+msg_polish_iso_desc="Polish ISO keymap"
+msg_portuguese="Portuguese"
+msg_portuguese_accent="Portuguese (accent)"
+msg_portuguese_accent_desc="Portuguese ISO keymap (accent keys)"
+msg_portuguese_desc="Portuguese ISO keymap"
+msg_rain="Rain"
+msg_rain_desc="Rain drops screen saver"
+msg_repeat="Repeat"
+msg_repeat_menu_text="This menu allows you to set the speed at which keys repeat\nwhen held down."
+msg_russia_koi8_r="Russia KOI8-R"
+msg_russia_koi8_r_desc="Russia KOI8-R keymap"
+msg_saver="Saver"
+msg_saver_menu_text="By default, the console driver will not attempt to do anything\nspecial with your screen when it's idle. If you expect to leave your\nmonitor switched on and idle for long periods of time then you should\nprobably enable one of these screen savers to prevent burn-in."
+msg_screenmap="Screenmap"
+msg_screenmap_menu_text="Unless you load a specific font, most PC hardware defaults to\ndisplaying characters in the IBM 437 character set. However,\nin the Unix world, this character set is very rarely used. Most\nWestern European countries, for example, prefer ISO 8859-1.\nAmerican users won't notice the difference since the bottom half\nof all these character sets is ANSI anyway.\nIf your hardware is capable of downloading a new display font,\nyou should probably choose that option. However, for hardware\nwhere this is not possible (e.g. monochrome adapters), a screen\nmap will give you the best approximation that your hardware can\ndisplay at all."
+msg_set_repeat_rate="Set the rate at which keys repeat"
+msg_slovak="Slovak"
+msg_slovak_desc="Slovak ISO keymap"
+msg_slovenian="Slovenian"
+msg_slovenian_desc="Slovenian ISO keymap"
+msg_slow="Slow"
+msg_slow_desc="Slow keyboard repeat rate"
+msg_snake="Snake"
+msg_snake_desc="Draw a FreeBSD \"snake\" on your screen"
+msg_spanish="Spanish"
+msg_spanish_accent="Spanish (accent)"
+msg_spanish_accent_desc="Spanish ISO keymap (accent keys)"
+msg_spanish_desc="Spanish ISO keymap"
+msg_star="Star"
+msg_star_desc="A \"twinkling stars\" effect"
+msg_swedish_cp850="Swedish CP850"
+msg_swedish_cp850_desc="Swedish Code Page 850 keymap"
+msg_swedish_iso="Swedish ISO"
+msg_swedish_iso_desc="Swedish ISO keymap"
+msg_swiss="SWISS"
+msg_swiss_desc="English, better resolution"
+msg_swiss_french_cp850="Swiss French CP850"
+msg_swiss_french_cp850_desc="Swiss French Code Page 850 keymap"
+msg_swiss_french_iso="Swiss French ISO"
+msg_swiss_french_iso_accent="Swiss French ISO (accent)"
+msg_swiss_french_iso_accent_desc="Swiss French ISO keymap (accent keys)"
+msg_swiss_french_iso_desc="Swiss French ISO keymap"
+msg_swiss_german_cp850="Swiss German CP850"
+msg_swiss_german_cp850_desc="Swiss German Code Page 850 keymap"
+msg_swiss_german_iso="Swiss German ISO"
+msg_swiss_german_iso_accent="Swiss German ISO (accent)"
+msg_swiss_german_iso_accent_desc="Swiss German ISO keymap (accent keys)"
+msg_swiss_german_iso_desc="Swiss German ISO keymap"
+msg_system_console_configuration="System Console Configuration"
+msg_system_console_font="System Console Font"
+msg_system_console_keymap="System Console Keymap"
+msg_system_console_keyboard_repeat_rate="System Console Keyboard Repeat Rate"
+msg_system_console_screen_saver="System Console Screen Saver"
+msg_system_console_screenmap="System Console Screenmap"
+msg_system_console_terminal_type="System Console Terminal Type"
+msg_timeout="Timeout"
+msg_timeout_desc="Set the screen saver timeout interval"
+msg_ttys="Ttys"
+msg_ttys_menu_text="For various console encodings, a corresponding terminal type\nmust be chosen in /etc/ttys.\n\nWARNING: For compatibility reasons, only entries starting with\nttyv and terminal types starting with cons[0-9] can be changed\nvia this menu."
+msg_uk_cp850="UK CP850"
+msg_uk_cp850_desc="UK Code Page 850 keymap"
+msg_uk_iso="UK ISO"
+msg_uk_iso_desc="UK ISO keymap"
+msg_ukrainian_koi8_u="Ukranian KOI8-U"
+msg_ukrainian_koi8_u_desc="Ukranian KOI8-U keymap"
+msg_ukrainian_koi8_u_koi8_r="Ukranian KOI8-U+KOI8-R"
+msg_ukrainian_koi8_u_koi8_r_desc="Ukranian KOI8-U+KOI8-R keymap (alter)"
+msg_us_ascii="US-ASCII"
+msg_us_ascii_to_ibm327="US-ASCII to IBM437"
+msg_us_ascii_to_ibm327_desc="US-ASCII to IBM 437 screenmap"
+msg_usa_capslock_ctrl="USA CapsLock->Ctrl"
+msg_usa_capslock_ctrl_desc="US standard (Caps as L-Control)"
+msg_usa_dvorak="USA Dvorak"
+msg_usa_dvorak_desc="US Dvorak keymap"
+msg_usa_dvorak_left="USA Dvorak (left)"
+msg_usa_dvorak_left_desc="US left handed Dvorak keymap"
+msg_usa_dvorak_right="USA Dvorak (right)"
+msg_usa_dvorak_right_desc="US right handed Dvorak keymap"
+msg_usa_emacs="USA Emacs"
+msg_usa_emacs_desc="US standard optimized for EMACS"
+msg_usa_iso="USA ISO"
+msg_usa_iso_desc="US ISO keymap"
+msg_usa_unix="USA UNIX"
+msg_usa_unix_desc="US traditional UNIX-workstation"
+msg_use_hardware_default_font="Use hardware default font"
+msg_value_required="Value Required"
+msg_warp="Warp"
+msg_warp_desc="A \"stars warping\" effect"
diff --git a/usr.sbin/bsdconfig/console/keymap b/usr.sbin/bsdconfig/console/keymap
new file mode 100755
index 0000000..ea1de2d
--- /dev/null
+++ b/usr.sbin/bsdconfig/console/keymap
@@ -0,0 +1,370 @@
+#!/bin/sh
+#-
+# Copyright (c) 2012 Devin Teske
+# All Rights Reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in the
+# documentation and/or other materials provided with the distribution.
+#
+# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING BUT NOT LIMITED TO, THE
+# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+# DAMAGES (INLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+# SUCH DAMAGE.
+#
+# $FreeBSD$
+#
+############################################################ INCLUDES
+
+BSDCFG_SHARE="/usr/share/bsdconfig"
+. $BSDCFG_SHARE/common.subr || exit 1
+f_include $BSDCFG_SHARE/dialog.subr
+f_include $BSDCFG_SHARE/mustberoot.subr
+f_include $BSDCFG_SHARE/sysrc.subr
+
+BSDCFG_LIBE="/usr/libexec/bsdconfig" APP_DIR="080.console"
+f_include_lang $BSDCFG_LIBE/$APP_DIR/include/messages.subr
+
+ipgm=$( f_index_menu_selection $BSDCFG_LIBE/$APP_DIR/INDEX "$pgm" )
+[ $? -eq $SUCCESS -a "$ipgm" ] && pgm="$ipgm"
+
+############################################################ CONFIGURATION
+
+#
+# List of keymap names
+#
+KEYMAP_NAMES="
+ belgian brazil_cp850 brazil_iso
+ brazil_iso_accent bulgarian_bds bulgarian_phonetic
+ central_european_iso croatian_iso czech_iso_accent
+ danish_cp865 danish_iso estonian_cp850
+ estonian_iso estonian_iso_15 finnish_cp850
+ finnish_iso french_iso french_iso_accent
+ french_iso_macbook german_cp850 german_iso
+ greek_101 greek_104 greek_elot
+ hungarian_101 hungarian_102 icelandic
+ icelandic_accent italian japanese_106
+ latin_american latin_american_accent norway_iso
+ polish_iso portuguese portuguese_accent
+ russia_koi8_r slovak slovenian
+ spanish spanish_accent swedish_cp850
+ swedish_iso swiss_french_cp850 swiss_french_iso
+ swiss_french_iso_accent swiss_german_cp850 swiss_german_iso
+ swiss_german_iso_accent uk_cp850 uk_iso
+ ukrainian_koi8_u ukrainian_koi8_u_koi8_r usa_capslock_ctrl
+ usa_dvorak usa_dvorak_left usa_dvorak_right
+ usa_emacs usa_iso usa_unix
+" # END-QUOTE
+
+############################################################ FUNCTIONS
+
+# dialog_menu_main
+#
+# Display the dialog(1)-based application main menu.
+#
+dialog_menu_main()
+{
+ local menu_list size
+ local hline="$hline_choose_a_keyboard_map"
+ local prompt="$msg_keymap_menu_text"
+
+ #
+ # Export variables for awk(1) ENVIRON visibility
+ #
+ local name
+ for name in $KEYMAP_NAMES; do
+ export msg_$name msg_${name}_desc
+ done
+
+ #
+ # Generate a sorted list of keymaps. If the first letter of the keymap
+ # name is unique (case-insensitive) then it is used as the tag to allow
+ # the user to jump to that entry.
+ #
+ menu_list=$(
+ for name in $KEYMAP_NAMES; do
+ eval echo \"\$msg_$name\" msg_$name
+ done | sort | awk 'BEGIN { prefix = "" }
+ {
+ cur_prefix = tolower(substr(ENVIRON[$NF], 1, 1))
+ printf "'\''"
+ if ( prefix != cur_prefix )
+ prefix = cur_prefix
+ else
+ printf " "
+ printf "%s'\'' '\''%s'\''\n",
+ ENVIRON[$NF], ENVIRON[$NF"_desc"]
+ }'
+ )
+
+ size=$( eval f_dialog_menu_size \
+ \"\$DIALOG_TITLE\" \
+ \"\$DIALOG_BACKTITLE\" \
+ \"\$prompt\" \
+ \"\$hline\" \
+ $menu_list )
+
+ local dialog_menu
+ dialog_menu=$( eval $DIALOG \
+ --clear --title \"\$DIALOG_TITLE\" \
+ --backtitle \"\$DIALOG_BACKTITLE\" \
+ --hline \"\$hline\" \
+ --ok-label \"\$msg_ok\" \
+ --cancel-label \"\$msg_cancel\" \
+ --menu \"\$prompt\" $size \
+ $menu_list \
+ 2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD
+ )
+ local retval=$?
+ setvar DIALOG_MENU_$$ "$dialog_menu"
+ return $retval
+}
+
+############################################################ MAIN
+
+# Incorporate rc-file if it exists
+[ -f "$HOME/.bsdconfigrc" ] && f_include "$HOME/.bsdconfigrc"
+
+#
+# Process command-line arguments
+#
+while getopts hSX flag; do
+ case "$flag" in
+ h|\?) f_usage $BSDCFG_LIBE/$APP_DIR/USAGE "PROGRAM_NAME" "$pgm";;
+ esac
+done
+shift $(( $OPTIND - 1 ))
+
+#
+# Initialize
+#
+f_dialog_init
+f_dialog_title "$msg_system_console_keymap"
+f_dialog_backtitle "${ipgm:+bsdconfig }$pgm"
+f_mustberoot_init
+
+#
+# Launch application main menu
+#
+while :; do
+ dialog_menu_main
+ retval=$?
+ mtag=$( f_dialog_menutag )
+
+ [ $retval -eq 0 ] || f_die
+
+ #
+ # Reverse the users choice into the variable name
+ #
+ keymap_name=
+ mtag="${mtag# }" # remove single leading-space if-present
+ for name in $KEYMAP_NAMES; do
+ if [ "$( eval echo \"\$msg_$name\" )" = "$mtag" ]; then
+ keymap_name="$name"
+ break
+ fi
+ done
+
+ [ "$keymap_name" ] || continue
+
+ case "$keymap_name" in
+ belgian)
+ f_sysrc_set keymap "be.iso" || f_die
+ break ;;
+ brazil_cp850)
+ f_sysrc_set keymap "br275.cp850" || f_die
+ break ;;
+ brazil_iso)
+ f_sysrc_set keymap "br275.iso" || f_die
+ break ;;
+ brazil_iso_accent)
+ f_sysrc_set keymap "br275.iso.acc" || f_die
+ break ;;
+ bulgarian_bds)
+ f_sysrc_set keymap "bg.bds.ctrlcaps" || f_die
+ break ;;
+ bulgarian_phonetic)
+ f_sysrc_set keymap "bg.phonetic.ctrlcaps" || f_die
+ break ;;
+ central_european_iso)
+ f_sysrc_set keymap "ce.iso2" || f_die
+ break ;;
+ croatian_iso)
+ f_sysrc_set keymap "hr.iso" || f_die
+ break ;;
+ czech_iso_accent)
+ f_sysrc_set keymap "cs.latin2.qwertz" || f_die
+ break ;;
+ danish_cp865)
+ f_sysrc_set keymap "danish.cp865" || f_die
+ break ;;
+ danish_iso)
+ f_sysrc_set keymap "danish.iso" || f_die
+ break ;;
+ estonian_cp850)
+ f_sysrc_set keymap "estonian.cp850" || f_die
+ break ;;
+ estonian_iso)
+ f_sysrc_set keymap "estonian.iso" || f_die
+ break ;;
+ estonian_iso_15)
+ f_sysrc_set keymap "estonian.iso15" || f_die
+ break ;;
+ finnish_cp850)
+ f_sysrc_set keymap "finnish.cp850" || f_die
+ break ;;
+ finnish_iso)
+ f_sysrc_set keymap "finnish.iso" || f_die
+ break ;;
+ french_iso)
+ f_sysrc_set keymap "fr.iso" || f_die
+ break ;;
+ french_iso_accent)
+ f_sysrc_set keymap "fr.iso.acc" || f_die
+ break ;;
+ french_iso_macbook)
+ f_sysrc_set keymap "fr.macbook.acc" || f_die
+ break ;;
+ german_cp850)
+ f_sysrc_set keymap "german.cp850" || f_die
+ break ;;
+ german_iso)
+ f_sysrc_set keymap "german.iso" || f_die
+ break ;;
+ greek_101)
+ f_sysrc_set keymap "gr.us101.acc" || f_die
+ break ;;
+ greek_104)
+ f_sysrc_set keymap "el.iso07" || f_die
+ break ;;
+ greek_elot)
+ f_sysrc_set keymap "gr.elot.acc" || f_die
+ break ;;
+ hungarian_101)
+ f_sysrc_set keymap "hu.iso2.101keys" || f_die
+ break ;;
+ hungarian_102)
+ f_sysrc_set keymap "hu.iso2.102keys" || f_die
+ break ;;
+ icelandic)
+ f_sysrc_set keymap "icelandic.iso" || f_die
+ break ;;
+ icelandic_accent)
+ f_sysrc_set keymap "icelandic.iso.acc" || f_die
+ break ;;
+ italian)
+ f_sysrc_set keymap "it.iso" || f_die
+ break ;;
+ japanese_106)
+ f_sysrc_set keymap "jp.106" || f_die
+ break ;;
+ latin_american)
+ f_sysrc_set keymap "latinamerican" || f_die
+ break ;;
+ latin_american_accent)
+ f_sysrc_set keymap "latinamerican.iso.acc" || f_die
+ break ;;
+ norway_iso)
+ f_sysrc_set keymap "norwegian.iso" || f_die
+ break ;;
+ polish_iso)
+ f_sysrc_set keymap "pl_PL.ISO8859-2" || f_die
+ break ;;
+ portuguese)
+ f_sysrc_set keymap "pt.iso" || f_die
+ break ;;
+ portuguese_accent)
+ f_sysrc_set keymap "pt.iso.acc" || f_die
+ break ;;
+ russia_koi8_r)
+ f_sysrc_set keymap "ru.koi8-r" || f_die
+ break ;;
+ slovak)
+ f_sysrc_set keymap "sk.iso2" || f_die
+ break ;;
+ slovenian)
+ f_sysrc_set keymap "si.iso" || f_die
+ break ;;
+ spanish)
+ f_sysrc_set keymap "spanish.iso" || f_die
+ break ;;
+ spanish_accent)
+ f_sysrc_set keymap "spanish.iso.acc" || f_die
+ break ;;
+ swedish_cp850)
+ f_sysrc_set keymap "swedish.cp850" || f_die
+ break ;;
+ swedish_iso)
+ f_sysrc_set keymap "swedish.iso" || f_die
+ break ;;
+ swiss_french_cp850)
+ f_sysrc_set keymap "swissfrench.cp850" || f_die
+ break ;;
+ swiss_french_iso)
+ f_sysrc_set keymap "swissfrench.iso" || f_die
+ break ;;
+ swiss_french_iso_accent)
+ f_sysrc_set keymap "swissfrench.iso.acc" || f_die
+ break ;;
+ swiss_german_cp850)
+ f_sysrc_set keymap "swissgerman.cp850" || f_die
+ break ;;
+ swiss_german_iso)
+ f_sysrc_set keymap "swissgerman.iso" || f_die
+ break ;;
+ swiss_german_iso_accent)
+ f_sysrc_set keymap "swissgerman.iso.acc" || f_die
+ break ;;
+ uk_cp850)
+ f_sysrc_set keymap "uk.cp850" || f_die
+ break ;;
+ uk_iso)
+ f_sysrc_set keymap "uk.iso" || f_die
+ break ;;
+ ukrainian_koi8_u)
+ f_sysrc_set keymap "ua.koi8-u" || f_die
+ break ;;
+ ukrainian_koi8_u_koi8_r)
+ f_sysrc_set keymap "ua.koi8-u.shift.alt" || f_die
+ break ;;
+ usa_capslock_ctrl)
+ f_sysrc_set keymap "us.pc-ctrl" || f_die
+ break ;;
+ usa_dvorak)
+ f_sysrc_set keymap "us.dvorak" || f_die
+ break ;;
+ usa_dvorak_left)
+ f_sysrc_set keymap "us.dvorakl" || f_die
+ break ;;
+ usa_dvorak_right)
+ f_sysrc_set keymap "us.dvorakr" || f_die
+ break ;;
+ usa_emacs)
+ f_sysrc_set keymap "us.emacs" || f_die
+ break ;;
+ usa_iso)
+ f_sysrc_set keymap "us.iso" || f_die
+ break ;;
+ usa_unix)
+ f_sysrc_set keymap "us.unix" || f_die
+ break ;;
+ esac
+done
+
+exit $SUCCESS
+
+################################################################################
+# END
+################################################################################
diff --git a/usr.sbin/bsdconfig/console/repeat b/usr.sbin/bsdconfig/console/repeat
new file mode 100755
index 0000000..76d60d1
--- /dev/null
+++ b/usr.sbin/bsdconfig/console/repeat
@@ -0,0 +1,139 @@
+#!/bin/sh
+#-
+# Copyright (c) 2012 Devin Teske
+# All Rights Reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in the
+# documentation and/or other materials provided with the distribution.
+#
+# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING BUT NOT LIMITED TO, THE
+# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+# DAMAGES (INLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+# SUCH DAMAGE.
+#
+# $FreeBSD$
+#
+############################################################ INCLUDES
+
+BSDCFG_SHARE="/usr/share/bsdconfig"
+. $BSDCFG_SHARE/common.subr || exit 1
+f_include $BSDCFG_SHARE/dialog.subr
+f_include $BSDCFG_SHARE/mustberoot.subr
+f_include $BSDCFG_SHARE/sysrc.subr
+
+BSDCFG_LIBE="/usr/libexec/bsdconfig" APP_DIR="080.console"
+f_include_lang $BSDCFG_LIBE/$APP_DIR/include/messages.subr
+
+ipgm=$( f_index_menu_selection $BSDCFG_LIBE/$APP_DIR/INDEX "$pgm" )
+[ $? -eq $SUCCESS -a "$ipgm" ] && pgm="$ipgm"
+
+############################################################ FUNCTIONS
+
+# dialog_menu_main
+#
+# Display the dialog(1)-based application main menu.
+#
+dialog_menu_main()
+{
+ local menu_list size
+ local hline="$hline_choose_a_keyboard_repeat_rate"
+ local prompt="$msg_repeat_menu_text"
+
+ menu_list="
+ '$msg_slow' '$msg_slow_desc'
+ '$msg_normal' '$msg_normal_desc'
+ '$msg_fast' '$msg_fast_desc'
+ '$msg_default' '$msg_default_desc'
+ " # END-QUOTE
+
+ size=$( eval f_dialog_menu_size \
+ \"\$DIALOG_TITLE\" \
+ \"\$DIALOG_BACKTITLE\" \
+ \"\$prompt\" \
+ \"\$hline\" \
+ $menu_list )
+
+ local dialog_menu
+ dialog_menu=$( eval $DIALOG \
+ --clear --title \"\$DIALOG_TITLE\" \
+ --backtitle \"\$DIALOG_BACKTITLE\" \
+ --hline \"\$hline\" \
+ --ok-label \"\$msg_ok\" \
+ --cancel-label \"\$msg_cancel\" \
+ --menu \"\$prompt\" $size \
+ $menu_list \
+ 2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD
+ )
+ local retval=$?
+ setvar DIALOG_MENU_$$ "$dialog_menu"
+ return $retval
+}
+
+############################################################ MAIN
+
+# Incorporate rc-file if it exists
+[ -f "$HOME/.bsdconfigrc" ] && f_include "$HOME/.bsdconfigrc"
+
+#
+# Process command-line arguments
+#
+while getopts hSX flag; do
+ case "$flag" in
+ h|\?) f_usage $BSDCFG_LIBE/$APP_DIR/USAGE "PROGRAM_NAME" "$pgm";;
+ esac
+done
+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
+
+#
+# Launch application main menu
+#
+while :; do
+ dialog_menu_main
+ retval=$?
+ mtag=$( f_dialog_menutag )
+
+ [ $retval -eq 0 ] || f_die
+
+ case "$mtag" in
+ "$msg_slow") # Slow keyboard repeat rate
+ f_sysrc_set keyrate "slow" || f_die
+ break ;;
+ "$msg_normal") # "Normal" keyboard repeat rate
+ f_sysrc_set keyrate "normal" || f_die
+ break ;;
+ "$msg_fast") # Fast keyboard repeat rate
+ f_sysrc_set keyrate "fast" || f_die
+ break ;;
+ "$msg_default") # Use default keyboard repeat rate
+ f_sysrc_set keyrate "NO" || f_die
+ break ;;
+ esac
+
+done
+
+exit $SUCCESS
+
+################################################################################
+# END
+################################################################################
diff --git a/usr.sbin/bsdconfig/console/saver b/usr.sbin/bsdconfig/console/saver
new file mode 100755
index 0000000..0ec332c
--- /dev/null
+++ b/usr.sbin/bsdconfig/console/saver
@@ -0,0 +1,205 @@
+#!/bin/sh
+#-
+# Copyright (c) 2012 Devin Teske
+# All Rights Reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in the
+# documentation and/or other materials provided with the distribution.
+#
+# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING BUT NOT LIMITED TO, THE
+# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+# DAMAGES (INLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+# SUCH DAMAGE.
+#
+# $FreeBSD$
+#
+############################################################ INCLUDES
+
+BSDCFG_SHARE="/usr/share/bsdconfig"
+. $BSDCFG_SHARE/common.subr || exit 1
+f_include $BSDCFG_SHARE/dialog.subr
+f_include $BSDCFG_SHARE/mustberoot.subr
+f_include $BSDCFG_SHARE/sysrc.subr
+
+BSDCFG_LIBE="/usr/libexec/bsdconfig" APP_DIR="080.console"
+f_include_lang $BSDCFG_LIBE/$APP_DIR/include/messages.subr
+
+ipgm=$( f_index_menu_selection $BSDCFG_LIBE/$APP_DIR/INDEX "$pgm" )
+[ $? -eq $SUCCESS -a "$ipgm" ] && pgm="$ipgm"
+
+############################################################ FUNCTIONS
+
+# dialog_menu_main
+#
+# Display the dialog(1)-based application main menu.
+#
+dialog_menu_main()
+{
+ local menu_list size
+ local hline="$hline_choose_a_screen_saver"
+ local prompt="$msg_saver_menu_text"
+
+ menu_list="
+ '1 $msg_blank' '$msg_blank_desc'
+ '2 $msg_beastie' '$msg_beastie_desc'
+ '3 $msg_daemon' '$msg_daemon_desc'
+ '4 $msg_dragon' '$msg_dragon_desc'
+ '5 $msg_fade' '$msg_fade_desc'
+ '6 $msg_fire' '$msg_fire_desc'
+ '7 $msg_green' '$msg_green_desc'
+ '8 $msg_logo' '$msg_logo_desc'
+ '9 $msg_rain' '$msg_rain_desc'
+ 'a $msg_snake' '$msg_snake_desc'
+ 'b $msg_star' '$msg_star_desc'
+ 'c $msg_warp' '$msg_warp_desc'
+ 'd $msg_none' '$msg_none_saver_desc'
+ '$msg_timeout' '$msg_timeout_desc'
+ " # END-QUOTE
+
+ size=$( eval f_dialog_menu_size \
+ \"\$DIALOG_TITLE\" \
+ \"\$DIALOG_BACKTITLE\" \
+ \"\$prompt\" \
+ \"\$hline\" \
+ $menu_list )
+
+ local dialog_menu
+ dialog_menu=$( eval $DIALOG \
+ --clear --title \"\$DIALOG_TITLE\" \
+ --backtitle \"\$DIALOG_BACKTITLE\" \
+ --hline \"\$hline\" \
+ --ok-label \"\$msg_ok\" \
+ --cancel-label \"\$msg_cancel\" \
+ --menu \"\$prompt\" $size \
+ $menu_list \
+ 2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD
+ )
+ local retval=$?
+ setvar DIALOG_MENU_$$ "$dialog_menu"
+ return $retval
+}
+
+############################################################ MAIN
+
+# Incorporate rc-file if it exists
+[ -f "$HOME/.bsdconfigrc" ] && f_include "$HOME/.bsdconfigrc"
+
+#
+# Process command-line arguments
+#
+while getopts hSX flag; do
+ case "$flag" in
+ h|\?) f_usage $BSDCFG_LIBE/$APP_DIR/USAGE "PROGRAM_NAME" "$pgm";;
+ esac
+done
+shift $(( $OPTIND - 1 ))
+
+#
+# Initialize
+#
+f_dialog_init
+f_dialog_title "$msg_system_console_screen_saver"
+f_dialog_backtitle "${ipgm:+bsdconfig }$pgm"
+f_mustberoot_init
+
+#
+# Launch application main menu
+#
+while :; do
+ dialog_menu_main
+ retval=$?
+ mtag=$( f_dialog_menutag )
+
+ [ $retval -eq 0 ] || f_die
+
+ case "$mtag" in
+ "1 $msg_blank") # Simply blank the screen
+ f_sysrc_set saver "blank" || f_die
+ break ;;
+ "2 $msg_beastie") # "BSD Daemon" animated screen saver (graphics)
+ f_sysrc_set saver "beastie" || f_die
+ break ;;
+ "3 $msg_daemon") # "BSD Daemon" animated screen saver (text)
+ f_sysrc_set saver "daemon" || f_die
+ break ;;
+ "4 $msg_dragon") # Dragon screensaver (graphics)
+ f_sysrc_set saver "dragon" || f_die
+ break ;;
+ "5 $msg_fade") # Fade out effect screen saver
+ f_sysrc_set saver "fade" || f_die
+ break ;;
+ "6 $msg_fire") # Flames effect screen saver
+ f_sysrc_set saver "fire" || f_die
+ break ;;
+ "7 $msg_green") # "Green" power saving mode (if supported by monitor)
+ f_sysrc_set saver "green" || f_die
+ break ;;
+ "8 $msg_logo") # FreeBSD "logo" animated screen saver (graphics)
+ f_sysrc_set saver "logo" || f_die
+ break ;;
+ "9 $msg_rain") # Rain drops screen saver
+ f_sysrc_set saver "rain" || f_die
+ break ;;
+ "a $msg_snake") # Draw a FreeBSD "snake" on your screen
+ f_sysrc_set saver "snake" || f_die
+ break ;;
+ "b $msg_star") # A "twinkling stars" effect
+ f_sysrc_set saver "star" || f_die
+ break ;;
+ "c $msg_warp") # A "stars warping" effect
+ f_sysrc_set saver "warp" || f_die
+ break ;;
+ "d $msg_none") # Disable the screensaver
+ f_sysrc_set saver "NO" || f_die
+ break ;;
+ "$msg_timeout") # Set the screen saver timeout interval
+ f_dialog_title "$msg_value_required"
+ title="$DIALOG_TITLE"
+ btitle="$DIALOG_BACKTITLE"
+ 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
+
+exit $SUCCESS
+
+################################################################################
+# END
+################################################################################
diff --git a/usr.sbin/bsdconfig/console/screenmap b/usr.sbin/bsdconfig/console/screenmap
new file mode 100755
index 0000000..bdabe6a
--- /dev/null
+++ b/usr.sbin/bsdconfig/console/screenmap
@@ -0,0 +1,147 @@
+#!/bin/sh
+#-
+# Copyright (c) 2012 Devin Teske
+# All Rights Reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in the
+# documentation and/or other materials provided with the distribution.
+#
+# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING BUT NOT LIMITED TO, THE
+# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+# DAMAGES (INLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+# SUCH DAMAGE.
+#
+# $FreeBSD$
+#
+############################################################ INCLUDES
+
+BSDCFG_SHARE="/usr/share/bsdconfig"
+. $BSDCFG_SHARE/common.subr || exit 1
+f_include $BSDCFG_SHARE/dialog.subr
+f_include $BSDCFG_SHARE/mustberoot.subr
+f_include $BSDCFG_SHARE/sysrc.subr
+
+BSDCFG_LIBE="/usr/libexec/bsdconfig" APP_DIR="080.console"
+f_include_lang $BSDCFG_LIBE/$APP_DIR/include/messages.subr
+
+ipgm=$( f_index_menu_selection $BSDCFG_LIBE/$APP_DIR/INDEX "$pgm" )
+[ $? -eq $SUCCESS -a "$ipgm" ] && pgm="$ipgm"
+
+############################################################ FUNCTIONS
+
+# dialog_menu_main
+#
+# Display the dialog(1)-based application main menu.
+#
+dialog_menu_main()
+{
+ local menu_list size
+ local hline="$hline_choose_a_screen_map"
+ local prompt="$msg_screenmap_menu_text"
+
+ menu_list="
+ '1 $msg_none' '$msg_none_screenmap_desc'
+ '2 $msg_iso_8859_1_to_ibm437' '$msg_iso_8859_1_to_ibm437_desc'
+ '3 $msg_iso_8859_7_to_ibm437' '$msg_iso_8859_7_to_ibm437_desc'
+ '4 $msg_us_ascii_to_ibm327' '$msg_us_ascii_to_ibm327_desc'
+ '5 $msg_koi8_r_to_ibm866' '$msg_koi8_r_to_ibm866_desc'
+ '6 $msg_koi8_u_to_ibm866u' '$msg_koi8_u_to_ibm866u_desc'
+ " # END-QUOTE
+
+ size=$( eval f_dialog_menu_size \
+ \"\$DIALOG_TITLE\" \
+ \"\$DIALOG_BACKTITLE\" \
+ \"\$prompt\" \
+ \"\$hline\" \
+ $menu_list )
+
+ local dialog_menu
+ dialog_menu=$( eval $DIALOG \
+ --clear --title \"\$DIALOG_TITLE\" \
+ --backtitle \"\$DIALOG_BACKTITLE\" \
+ --hline \"\$hline\" \
+ --ok-label \"\$msg_ok\" \
+ --cancel-label \"\$msg_cancel\" \
+ --menu \"\$prompt\" $size \
+ $menu_list \
+ 2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD
+ )
+ local retval=$?
+ setvar DIALOG_MENU_$$ "$dialog_menu"
+ return $retval
+}
+
+############################################################ MAIN
+
+# Incorporate rc-file if it exists
+[ -f "$HOME/.bsdconfigrc" ] && f_include "$HOME/.bsdconfigrc"
+
+#
+# Process command-line arguments
+#
+while getopts hSX flag; do
+ case "$flag" in
+ h|\?) f_usage $BSDCFG_LIBE/$APP_DIR/USAGE "PROGRAM_NAME" "$pgm";;
+ esac
+done
+shift $(( $OPTIND - 1 ))
+
+#
+# Initialize
+#
+f_dialog_init
+f_dialog_title "$msg_system_console_screenmap"
+f_dialog_backtitle "${ipgm:+bsdconfig }$pgm"
+f_mustberoot_init
+
+#
+# Launch application main menu
+#
+while :; do
+ dialog_menu_main
+ retval=$?
+ mtag=$( f_dialog_menutag )
+
+ [ $retval -eq 0 ] || f_die
+
+ case "$mtag" in
+ "1 $msg_none") # No screenmap, don't touch font
+ f_sysrc_set scrnmap "NO" || f_die
+ break ;;
+ "2 $msg_iso_8859_1_to_ibm437") # W-Europe ISO 8859-1 to IBM 437 scrnmap
+ f_sysrc_set scrnmap "iso-8859-1_to_cp437" || f_die
+ break ;;
+ "3 $msg_iso_8859_7_to_ibm437") # Greek ISO 8859-7 to IBM 437 screenmap
+ f_sysrc_set scrnmap "iso-8859-7_to_cp437" || f_die
+ break ;;
+ "4 $msg_us_ascii_to_ibm327") # US-ASCII to IBM 437 screenmap
+ f_sysrc_set scrnmap "us-ascii_to_cp437" || f_die
+ break ;;
+ "5 $msg_koi8_r_to_ibm866") # Russian KOI8-R to IBM 866 screenmap
+ f_sysrc_set scrnmap "koi8-r2cp866" || f_die
+ break ;;
+ "6 $msg_koi8_u_to_ibm866u") # Ukrainian KOI8-U to IBM 866u screenmap
+ f_sysrc_set scrnmap "koi8-u2cp866u" || f_die
+ break ;;
+ esac
+
+done
+
+exit $SUCCESS
+
+################################################################################
+# END
+################################################################################
diff --git a/usr.sbin/bsdconfig/console/ttys b/usr.sbin/bsdconfig/console/ttys
new file mode 100755
index 0000000..fcf45ef
--- /dev/null
+++ b/usr.sbin/bsdconfig/console/ttys
@@ -0,0 +1,202 @@
+#!/bin/sh
+#-
+# Copyright (c) 2012 Devin Teske
+# All Rights Reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in the
+# documentation and/or other materials provided with the distribution.
+#
+# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING BUT NOT LIMITED TO, THE
+# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+# DAMAGES (INLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+# SUCH DAMAGE.
+#
+# $FreeBSD$
+#
+############################################################ INCLUDES
+
+BSDCFG_SHARE="/usr/share/bsdconfig"
+. $BSDCFG_SHARE/common.subr || exit 1
+f_include $BSDCFG_SHARE/dialog.subr
+f_include $BSDCFG_SHARE/mustberoot.subr
+f_include $BSDCFG_SHARE/sysrc.subr
+
+BSDCFG_LIBE="/usr/libexec/bsdconfig" APP_DIR="080.console"
+f_include_lang $BSDCFG_LIBE/$APP_DIR/include/messages.subr
+
+ipgm=$( f_index_menu_selection $BSDCFG_LIBE/$APP_DIR/INDEX "$pgm" )
+[ $? -eq $SUCCESS -a "$ipgm" ] && pgm="$ipgm"
+
+############################################################ CONFIGURATION
+
+#
+# Location of ttys(5)
+#
+ETC_TTYS=/etc/ttys
+
+############################################################ GLOBALS
+
+#
+# Terminal-type map/menu-item list
+#
+TTY_MENU_LIST="
+ '1 $msg_none' '$msg_none_ttys_desc'
+ '2 $msg_ibm_437_vga_default' 'cons25'
+ '3 $msg_iso_8859_1' 'cons25l1'
+ '4 $msg_iso_8859_2' 'cons25l2'
+ '5 $msg_iso_8859_7' 'cons25l7'
+ '6 $msg_koi8_r' 'cons25r'
+ '7 $msg_koi8_u' 'cons25u'
+ '8 $msg_us_ascii' 'cons25w'
+" # END-QUOTE
+
+############################################################ FUNCTIONS
+
+# dialog_menu_main
+#
+# Display the dialog(1)-based application main menu.
+#
+dialog_menu_main()
+{
+ local size
+ local hline="$hline_choose_a_terminal_type"
+ local prompt="$msg_ttys_menu_text"
+
+ size=$( eval f_dialog_menu_size \
+ \"\$DIALOG_TITLE\" \
+ \"\$DIALOG_BACKTITLE\" \
+ \"\$prompt\" \
+ \"\$hline\" \
+ $TTY_MENU_LIST )
+
+ local dialog_menu
+ dialog_menu=$( eval $DIALOG \
+ --clear --title \"\$DIALOG_TITLE\" \
+ --backtitle \"\$DIALOG_BACKTITLE\" \
+ --hline \"\$hline\" \
+ --ok-label \"\$msg_ok\" \
+ --cancel-label \"\$msg_cancel\" \
+ --menu \"\$prompt\" $size \
+ $TTY_MENU_LIST \
+ 2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD
+ )
+ local retval=$?
+ setvar DIALOG_MENU_$$ "$dialog_menu"
+ return $retval
+}
+
+# ttys_set_type $consterm
+#
+# Set terminal type of `ttyv*' and `cons[0-9]' entries in ttys(5) to $consterm.
+#
+ttys_set_type()
+{
+ local consterm="$1"
+
+ #
+ # Create new temporary file to write our ttys(5) update with new types.
+ #
+ local tmpfile="$( mktemp -t "pgm" )"
+ [ "$tmpfile" ] || return $FAILURE
+
+ #
+ # Fixup permissions and ownership (mktemp(1) creates the temporary file
+ # with 0600 permissions -- change the permissions and ownership to
+ # match ttys(5) before we write it out and mv(1) it into place).
+ #
+ local mode="$( stat -f '%#Lp' "$ETC_TTYS" 2> /dev/null )"
+ local owner="$( stat -f '%u:%g' "$ETC_TTYS" 2> /dev/null )"
+ f_quietly chmod "${mode:-0644}" "$tmpfile"
+ f_quietly chown "${owner:-root:wheel}" "$tmpfile"
+
+ #
+ # Operate on ttys(5), replacing only the types of `ttyv*' and
+ # `cons[0-9]' terminals with the new type.
+ #
+ awk -v consterm="$consterm" '
+ BEGIN {
+ }
+ {
+ # "Skip" blank-lines, lines containing only whitespace, and
+ # lines containing only a comment or whitespace-then-comment.
+ #
+ if ( $0 ~ /^[[:space:]]*(#|$)/ ) { print; next }
+
+ # "Skip" terminal types other than those supported
+ #
+ if ( $1 !~ /^(ttyv.*|cons[0-9])$/ ) { print; next }
+
+ # Change the terminal type to the new value
+ #
+ match($0, /[[:alnum:]\.\+-_]+[[:space:]]+(on|off).*$/)
+ if ( ! RSTART ) { print; next }
+ left = substr($0, 0, RSTART - 1)
+ match($0, /[[:space:]]+(on|off).*$/)
+ right = substr($0, RSTART)
+ printf "%s%s%s\n", left, consterm, right
+ }
+ ' "$ETC_TTYS" > "$tmpfile" || return $FAILURE
+ f_quietly mv "$tmpfile" "$ETC_TTYS" || return $FAILURE
+
+ return $SUCCESS
+}
+
+############################################################ MAIN
+
+# Incorporate rc-file if it exists
+[ -f "$HOME/.bsdconfigrc" ] && f_include "$HOME/.bsdconfigrc"
+
+#
+# Process command-line arguments
+#
+while getopts hSX flag; do
+ case "$flag" in
+ h|\?) f_usage $BSDCFG_LIBE/$APP_DIR/USAGE "PROGRAM_NAME" "$pgm";;
+ esac
+done
+shift $(( $OPTIND - 1 ))
+
+#
+# Initialize
+#
+f_dialog_init
+f_dialog_title "$msg_system_console_terminal_type"
+f_dialog_backtitle "${ipgm:+bsdconfig }$pgm"
+f_mustberoot_init
+
+#
+# Launch application main menu
+#
+while :; do
+ dialog_menu_main
+ retval=$?
+ mtag=$( f_dialog_menutag )
+
+ [ $retval -eq 0 ] || f_die
+ [ "$mtag" = "1 $msg_none" ] && break
+
+ consterm=$( eval f_dialog_menutag2item \"\$mtag\" $TTY_MENU_LIST )
+ err=$( ttys_set_type "$consterm" 2>&1 )
+ [ "$err" ] || break
+
+ f_show_msg "%s" "$err"
+done
+
+exit $SUCCESS
+
+################################################################################
+# END
+################################################################################
diff --git a/usr.sbin/bsdconfig/diskmgmt/INDEX b/usr.sbin/bsdconfig/diskmgmt/INDEX
new file mode 100644
index 0000000..2d03af8
--- /dev/null
+++ b/usr.sbin/bsdconfig/diskmgmt/INDEX
@@ -0,0 +1,53 @@
+# Copyright (c) 2012 Ron McDowell
+# Copyright (c) 2012 Devin Teske
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in the
+# documentation and/or other materials provided with the distribution.
+#
+# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+# SUCH DAMAGE.
+#
+# $FreeBSD$
+
+#
+# Title that will be shown on the bsdconfig menu
+menu_title="Disk Management"
+#
+# a short descriptive line shown at the bottom of the bsdconfig menu.
+# keep it short because any line longer than the terminal width will
+# be truncated.
+menu_help="Manage disk partitions and/or labels"
+#
+# two-part variable that defines an action to take when 'keyword'
+# is passed on a bsdconfig command line. variable takes the form
+# "keyword|command" and multiple occurrences of the variable
+# (with different 'keyword's, or different 'keyword's AND 'command's)
+# are allowed. If 'command' begins with a '/' then the full
+# path to the program is needed. If 'command' begins with anything
+# else it is a path relative to the directory this INDEX file is in.
+# 'keyword' can be i18n'ed but 'command' is the name of a script.
+menu_selection="diskmgmt|diskmgmt"
+#
+# Items below this line do NOT need i18n translation----------------------
+#
+# Name of the program to be run when this menu choice is selected.
+# if it begins with a '/' then the full path to the program is needed.
+# if it begins with anything else it is a path relative to the directory
+# this INDEX file is in.
+menu_program="diskmgmt"
diff --git a/usr.sbin/bsdconfig/diskmgmt/Makefile b/usr.sbin/bsdconfig/diskmgmt/Makefile
new file mode 100644
index 0000000..894c62c
--- /dev/null
+++ b/usr.sbin/bsdconfig/diskmgmt/Makefile
@@ -0,0 +1,16 @@
+# $FreeBSD$
+
+NO_OBJ=
+
+SUBDIR= include
+
+FILESDIR= ${LIBEXECDIR}/bsdconfig/050.diskmgmt
+FILES= INDEX USAGE
+
+SCRIPTSDIR= ${FILESDIR}
+SCRIPTS= diskmgmt
+
+beforeinstall:
+ mkdir -p ${DESTDIR}${FILESDIR}
+
+.include <bsd.prog.mk>
diff --git a/usr.sbin/bsdconfig/diskmgmt/USAGE b/usr.sbin/bsdconfig/diskmgmt/USAGE
new file mode 100644
index 0000000..9aa4dca
--- /dev/null
+++ b/usr.sbin/bsdconfig/diskmgmt/USAGE
@@ -0,0 +1,33 @@
+# Copyright (c) 2012 Devin Teske
+# All Rights Reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in the
+# documentation and/or other materials provided with the distribution.
+#
+# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING BUT NOT LIMITED TO, THE
+# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+# DAMAGES (INLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+# SUCH DAMAGE.
+#
+# $FreeBSD$
+
+Usage: bsdconfig @PROGRAM_NAME@ [OPTIONS]
+
+OPTIONS:
+ -h Print usage statement and exit.
+ -S Secure X11 mode (implies `-X'). As root, always prompt-for
+ and validate sudo(8) username/password before starting.
+ -X Use Xdialog(1) in place of dialog(1).
diff --git a/usr.sbin/bsdconfig/diskmgmt/diskmgmt b/usr.sbin/bsdconfig/diskmgmt/diskmgmt
new file mode 100755
index 0000000..aab901f
--- /dev/null
+++ b/usr.sbin/bsdconfig/diskmgmt/diskmgmt
@@ -0,0 +1,85 @@
+#!/bin/sh
+#-
+# Copyright (c) 2012 Devin Teske
+# All Rights Reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in the
+# documentation and/or other materials provided with the distribution.
+#
+# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING BUT NOT LIMITED TO, THE
+# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+# DAMAGES (INLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+# SUCH DAMAGE.
+#
+# $FreeBSD$
+#
+############################################################ INCLUDES
+
+BSDCFG_SHARE="/usr/share/bsdconfig"
+. $BSDCFG_SHARE/common.subr || exit 1
+f_include $BSDCFG_SHARE/dialog.subr
+f_include $BSDCFG_SHARE/mustberoot.subr
+
+BSDCFG_LIBE="/usr/libexec/bsdconfig" APP_DIR="050.diskmgmt"
+f_include_lang $BSDCFG_LIBE/$APP_DIR/include/messages.subr
+
+ipgm=$( f_index_menu_selection $BSDCFG_LIBE/$APP_DIR/INDEX "$pgm" )
+[ $? -eq $SUCCESS -a "$ipgm" ] && pgm="$ipgm"
+
+############################################################ CONFIGURATION
+
+#
+# If X11 is requested, which terminal and what options should we use?
+#
+X11TERM=xterm
+X11TERM_OPTS=
+
+############################################################ MAIN
+
+# Incorporate rc-file if it exists
+[ -f "$HOME/.bsdconfigrc" ] && f_include "$HOME/.bsdconfigrc"
+
+#
+# Process command-line arguments
+#
+while getopts hSX flag; do
+ case "$flag" in
+ h|\?) f_usage $BSDCFG_LIBE/$APP_DIR/USAGE "PROGRAM_NAME" "$pgm";;
+ esac
+done
+shift $(( $OPTIND - 1 ))
+
+#
+# Initialize
+#
+f_dialog_init
+f_mustberoot_init
+
+#
+# If Xdialog(1) is requested, we'll need to wrap bsdinstall(8) into xterm(1)
+#
+if [ "$USE_XDIALOG" ]; then
+ f_have "$X11TERM" || f_die 1 \
+ "$msg_no_such_file_or_directory" "$pgm" "$X11TERM"
+
+ exec $X11TERM $X11TERM_OPTS -e /usr/sbin/sade
+else
+ exec /usr/sbin/sade
+fi
+
+################################################################################
+# END
+################################################################################
diff --git a/usr.sbin/bsdconfig/diskmgmt/include/Makefile b/usr.sbin/bsdconfig/diskmgmt/include/Makefile
new file mode 100644
index 0000000..9c94c0e
--- /dev/null
+++ b/usr.sbin/bsdconfig/diskmgmt/include/Makefile
@@ -0,0 +1,11 @@
+# $FreeBSD$
+
+NO_OBJ=
+
+FILESDIR= ${LIBEXECDIR}/bsdconfig/050.diskmgmt/include
+FILES= messages.subr
+
+beforeinstall:
+ mkdir -p ${DESTDIR}${FILESDIR}
+
+.include <bsd.prog.mk>
diff --git a/usr.sbin/bsdconfig/diskmgmt/include/messages.subr b/usr.sbin/bsdconfig/diskmgmt/include/messages.subr
new file mode 100644
index 0000000..f0b563f
--- /dev/null
+++ b/usr.sbin/bsdconfig/diskmgmt/include/messages.subr
@@ -0,0 +1,27 @@
+# Copyright (c) 2012 Devin Teske
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in the
+# documentation and/or other materials provided with the distribution.
+#
+# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+# SUCH DAMAGE.
+#
+# $FreeBSD$
+
+msg_no_such_file_or_directory="%s: %s: No such file or directory"
diff --git a/usr.sbin/bsdconfig/docsinstall/INDEX b/usr.sbin/bsdconfig/docsinstall/INDEX
new file mode 100644
index 0000000..c61e221
--- /dev/null
+++ b/usr.sbin/bsdconfig/docsinstall/INDEX
@@ -0,0 +1,53 @@
+# Copyright (c) 2012 Ron McDowell
+# Copyright (c) 2012 Devin Teske
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in the
+# documentation and/or other materials provided with the distribution.
+#
+# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+# SUCH DAMAGE.
+#
+# $FreeBSD$
+
+#
+# Title that will be shown on the bsdconfig menu
+menu_title="Documentation installation"
+#
+# a short descriptive line shown at the bottom of the bsdconfig menu.
+# keep it short because any line longer than the terminal width will
+# be truncated.
+menu_help="Install FreeBSD Documentation set"
+#
+# two-part variable that defines an action to take when 'keyword'
+# is passed on a bsdconfig command line. variable takes the form
+# "keyword|command" and multiple occurrences of the variable
+# (with different 'keyword's, or different 'keyword's AND 'command's)
+# are allowed. If 'command' begins with a '/' then the full
+# path to the program is needed. If 'command' begins with anything
+# else it is a path relative to the directory this INDEX file is in.
+# 'keyword' can be i18n'ed but 'command' is the name of a script.
+menu_selection="docsinstall|docsinstall"
+#
+# Items below this line do NOT need i18n translation----------------------
+#
+# Name of the program to be run when this menu choice is selected.
+# if it begins with a '/' then the full path to the program is needed.
+# if it begins with anything else it is a path relative to the directory
+# this INDEX file is in.
+menu_program="docsinstall"
diff --git a/usr.sbin/bsdconfig/docsinstall/Makefile b/usr.sbin/bsdconfig/docsinstall/Makefile
new file mode 100644
index 0000000..de03d7d
--- /dev/null
+++ b/usr.sbin/bsdconfig/docsinstall/Makefile
@@ -0,0 +1,16 @@
+# $FreeBSD$
+
+NO_OBJ=
+
+SUBDIR= include
+
+FILESDIR= ${LIBEXECDIR}/bsdconfig/020.docsinstall
+FILES= INDEX USAGE
+
+SCRIPTSDIR= ${FILESDIR}
+SCRIPTS= docsinstall
+
+beforeinstall:
+ mkdir -p ${DESTDIR}${FILESDIR}
+
+.include <bsd.prog.mk>
diff --git a/usr.sbin/bsdconfig/docsinstall/USAGE b/usr.sbin/bsdconfig/docsinstall/USAGE
new file mode 100644
index 0000000..9aa4dca
--- /dev/null
+++ b/usr.sbin/bsdconfig/docsinstall/USAGE
@@ -0,0 +1,33 @@
+# Copyright (c) 2012 Devin Teske
+# All Rights Reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in the
+# documentation and/or other materials provided with the distribution.
+#
+# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING BUT NOT LIMITED TO, THE
+# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+# DAMAGES (INLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+# SUCH DAMAGE.
+#
+# $FreeBSD$
+
+Usage: bsdconfig @PROGRAM_NAME@ [OPTIONS]
+
+OPTIONS:
+ -h Print usage statement and exit.
+ -S Secure X11 mode (implies `-X'). As root, always prompt-for
+ and validate sudo(8) username/password before starting.
+ -X Use Xdialog(1) in place of dialog(1).
diff --git a/usr.sbin/bsdconfig/docsinstall/docsinstall b/usr.sbin/bsdconfig/docsinstall/docsinstall
new file mode 100755
index 0000000..d6fe2d2
--- /dev/null
+++ b/usr.sbin/bsdconfig/docsinstall/docsinstall
@@ -0,0 +1,97 @@
+#!/bin/sh
+#-
+# Copyright (c) 2012 Devin Teske
+# All Rights Reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in the
+# documentation and/or other materials provided with the distribution.
+#
+# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING BUT NOT LIMITED TO, THE
+# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+# DAMAGES (INLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+# SUCH DAMAGE.
+#
+# $FreeBSD$
+#
+############################################################ INCLUDES
+
+BSDCFG_SHARE="/usr/share/bsdconfig"
+. $BSDCFG_SHARE/common.subr || exit 1
+f_include $BSDCFG_SHARE/dialog.subr
+f_include $BSDCFG_SHARE/mustberoot.subr
+
+BSDCFG_LIBE="/usr/libexec/bsdconfig" APP_DIR="020.docsinstall"
+f_include_lang $BSDCFG_LIBE/$APP_DIR/include/messages.subr
+
+ipgm=$( f_index_menu_selection $BSDCFG_LIBE/$APP_DIR/INDEX "$pgm" )
+[ $? -eq $SUCCESS -a "$ipgm" ] && pgm="$ipgm"
+
+############################################################ CONFIGURATION
+
+#
+# If X11 is requested, which terminal and what options should we use?
+#
+X11TERM=xterm
+X11TERM_OPTS=
+
+############################################################ MAIN
+
+# Incorporate rc-file if it exists
+[ -f "$HOME/.bsdconfigrc" ] && f_include "$HOME/.bsdconfigrc"
+
+#
+# Process command-line arguments
+#
+while getopts hSX flag; do
+ case "$flag" in
+ h|\?) f_usage $BSDCFG_LIBE/$APP_DIR/USAGE "PROGRAM_NAME" "$pgm";;
+ esac
+done
+shift $(( $OPTIND - 1 ))
+
+#
+# Initialize
+#
+f_dialog_init
+f_mustberoot_init
+
+#
+# If Xdialog(1) is requested, we'll need to wrap bsdinstall(8) into xterm(1)
+#
+if [ "$USE_XDIALOG" ]; then
+ #
+ # Make sure $X11TERM exists and is executable
+ #
+ case "$X11TERM" in
+ */*)
+ [ -e "$X11TERM" ] || f_die 1 \
+ "$msg_no_such_file_or_directory" "$pgm" "$X11TERM"
+ [ -x "$X11TERM" ] || f_die 1 \
+ "$msg_permission_denied" "$pgm" "$X11TERM"
+ ;;
+ *)
+ f_have "$X11TERM" || f_die 1 \
+ "$msg_no_such_file_or_directory" "$pgm" "$X11TERM"
+ esac
+
+ exec $X11TERM $X11TERM_OPTS -e /usr/sbin/bsdinstall docsinstall
+else
+ exec /usr/sbin/bsdinstall docsinstall
+fi
+
+################################################################################
+# END
+################################################################################
diff --git a/usr.sbin/bsdconfig/docsinstall/include/Makefile b/usr.sbin/bsdconfig/docsinstall/include/Makefile
new file mode 100644
index 0000000..9f75f7d
--- /dev/null
+++ b/usr.sbin/bsdconfig/docsinstall/include/Makefile
@@ -0,0 +1,11 @@
+# $FreeBSD$
+
+NO_OBJ=
+
+FILESDIR= ${LIBEXECDIR}/bsdconfig/020.docsinstall/include
+FILES= messages.subr
+
+beforeinstall:
+ mkdir -p ${DESTDIR}${FILESDIR}
+
+.include <bsd.prog.mk>
diff --git a/usr.sbin/bsdconfig/docsinstall/include/messages.subr b/usr.sbin/bsdconfig/docsinstall/include/messages.subr
new file mode 100644
index 0000000..4c55f0f
--- /dev/null
+++ b/usr.sbin/bsdconfig/docsinstall/include/messages.subr
@@ -0,0 +1,28 @@
+# Copyright (c) 2012 Devin Teske
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in the
+# documentation and/or other materials provided with the distribution.
+#
+# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+# SUCH DAMAGE.
+#
+# $FreeBSD$
+
+msg_no_such_file_or_directory="%s: %s: No such file or directory"
+msg_permission_denied="%s: %s: permission denied"
diff --git a/usr.sbin/bsdconfig/dot/INDEX b/usr.sbin/bsdconfig/dot/INDEX
new file mode 100644
index 0000000..96b0c87
--- /dev/null
+++ b/usr.sbin/bsdconfig/dot/INDEX
@@ -0,0 +1,53 @@
+# Copyright (c) 2012 Ron McDowell
+# Copyright (c) 2012 Devin Teske
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in the
+# documentation and/or other materials provided with the distribution.
+#
+# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+# SUCH DAMAGE.
+#
+# $FreeBSD$
+
+#
+# Title that will be shown on the bsdconfig menu
+menu_title=""
+#
+# a short descriptive line shown at the bottom of the bsdconfig menu.
+# keep it short because any line longer than the terminal width will
+# be truncated.
+menu_help=""
+#
+# two-part variable that defines an action to take when 'keyword'
+# is passed on a bsdconfig command line. variable takes the form
+# "keyword|command" and multiple occurrences of the variable
+# (with different 'keyword's, or different 'keyword's AND 'command's)
+# are allowed. If 'command' begins with a '/' then the full
+# path to the program is needed. If 'command' begins with anything
+# else it is a path relative to the directory this INDEX file is in.
+# 'keyword' can be i18n'ed but 'command' is the name of a script.
+menu_selection="dot|dot"
+#
+# Items below this line do NOT need i18n translation----------------------
+#
+# Name of the program to be run when this menu choice is selected.
+# if it begins with a '/' then the full path to the program is needed.
+# if it begins with anything else it is a path relative to the directory
+# this INDEX file is in.
+menu_program=""
diff --git a/usr.sbin/bsdconfig/dot/Makefile b/usr.sbin/bsdconfig/dot/Makefile
new file mode 100644
index 0000000..5a87282
--- /dev/null
+++ b/usr.sbin/bsdconfig/dot/Makefile
@@ -0,0 +1,16 @@
+# $FreeBSD$
+
+NO_OBJ=
+
+SUBDIR= include
+
+FILESDIR= ${LIBEXECDIR}/bsdconfig/dot
+FILES= INDEX USAGE
+
+SCRIPTSDIR= ${FILESDIR}
+SCRIPTS= dot
+
+beforeinstall:
+ mkdir -p ${DESTDIR}${FILESDIR}
+
+.include <bsd.prog.mk>
diff --git a/usr.sbin/bsdconfig/dot/USAGE b/usr.sbin/bsdconfig/dot/USAGE
new file mode 100644
index 0000000..c1c0dc3
--- /dev/null
+++ b/usr.sbin/bsdconfig/dot/USAGE
@@ -0,0 +1,143 @@
+# Copyright (c) 2012 Devin Teske
+# All Rights Reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in the
+# documentation and/or other materials provided with the distribution.
+#
+# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING BUT NOT LIMITED TO, THE
+# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+# DAMAGES (INLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+# SUCH DAMAGE.
+#
+# $FreeBSD$
+
+Usage: bsdconfig @PROGRAM_NAME@ [OPTIONS]
+
+OPTIONS:
+ -h Print usage statement and exit.
+ -c Don't show command-line shortcut relationships.
+ -d Don't show the date in the graph label.
+ -i Don't show include relationships.
+
+EXAMPLES:
+ View dot(1) language output describing bsdconfig(8) layout/make-up:
+
+ bsdconfig @PROGRAM_NAME@ | less
+
+ Render dot(1) output in SVG format (displays in most modern browsers):
+
+ bsdconfig @PROGRAM_NAME@ | dot -Tsvg -o bsdconfig.svg
+
+ NOTE: Requires `graphics/graphviz' from ports/packages.
+
+ View the above-rendered SVG file using your favorite X11-based viewer:
+
+ gimmage bsdconfig.svg
+
+ NOTE: Requires `graphics/gimmage' from ports/packages.
+
+ or
+
+ gthumb bsdconfig.svg
+
+ NOTE: Image is scaled to fit window on launch.
+ NOTE: Requires `graphics/gthumb' from ports/packages.
+
+ or
+
+ gqview bsdconfig.svg
+
+ NOTE: Requires `graphics/gqview' from ports/packages.
+
+ or
+
+ gx bsdconfig.svg
+
+ NOTE: Image is scaled to fit window on launch.
+ NOTE: Requires `graphics/gx' from ports/packages.
+
+ or
+
+ eog bsdconfig.svg
+
+ NOTE: Requires `graphics/eog' from ports/packages.
+
+ Render dot(1) output as PostScript print output consisting of multiple
+ US-Letter sized pages that can be assembled into a large poster (using
+ traditional tools such as scissors and tape):
+
+ bsdconfig @PROGRAM_NAME@ | dot -Teps -o bsdconfig.eps
+ poster -v -mLet -s1 -o bsdconfig.ps bsdconfig.eps
+
+ NOTE: Change "-s1" above to "-s0.5" to halve the size of the
+ poster or "-s2", for example, to double the poster size.
+
+ NOTE: Requires both `graphics/graphviz' and `print/poster' from
+ ports/packages.
+
+ Render dot(1) output as PostScript scaled to fit on a poster consisting
+ of 2x-wide and 4x-tall US-Letter sized pages:
+
+ bsdconfig @PROGRAM_NAME@ | dot -Teps -o bsdconfig.eps
+ poster -v -mLet -p2x4Letter -o bsdconfig.ps bsdconfig.eps
+
+ NOTE: Requires both `graphics/graphviz' and `print/poster' from
+ ports/packages.
+
+ View the above-rendered PostScript poster using X11:
+
+ gsview bsdconfig.ps
+
+ NOTE: Requires `print/gsview' from ports/packages.
+
+ or
+
+ convert bsdconfig.ps bsdconfig.pdf
+ xpdf bsdconfig.pdf
+
+ NOTE: Requires both `graphics/ImageMagick' and
+ `graphics/xdpf' from ports/packages.
+
+ NOTE: The converted PDF file is not suitable for
+ printing due to loss of quality during the
+ conversion process.
+
+ Print the above-rendered PostScript poster:
+
+ lpr -h bsdconfig.ps
+
+ NOTE: Requires configuration of a printer in `/etc/printcap'.
+
+ Extract each page of the poster into a separate PNG file:
+
+ gs -q -dNOPAUSE -dBATCH -sPAPERSIZE=letter \
+ -dTextAlphaBits=4 -dGraphicsAlphaBits=4 \
+ -sDEVICE=png16m -sOutputFile=bsdconfig%03d.png \
+ bsdconfig.ps
+
+ NOTE: Requires `print/ghostscript9' from ports/packages.
+
+ NOTE: The converted PNG files are not suitable for printing
+ due to loss of quality during the conversion process.
+
+ Extract a single page of the poster into a separate PostScript file for
+ printing individual pages from the command-line:
+
+ psselect 1 bsdconfig.ps bsdconfig-page1.ps
+ lpr -h bsdconfig-page1.ps
+
+ NOTE: Change "1" to "2" for the second page, ad-infinitum.
+ NOTE: Requires `print/psutils-letter' from ports/packages.
diff --git a/usr.sbin/bsdconfig/dot/dot b/usr.sbin/bsdconfig/dot/dot
new file mode 100755
index 0000000..1a90324
--- /dev/null
+++ b/usr.sbin/bsdconfig/dot/dot
@@ -0,0 +1,666 @@
+#!/bin/sh
+#-
+# Copyright (c) 2012 Devin Teske
+# All Rights Reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in the
+# documentation and/or other materials provided with the distribution.
+#
+# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING BUT NOT LIMITED TO, THE
+# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+# DAMAGES (INLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+# SUCH DAMAGE.
+#
+# $FreeBSD$
+#
+############################################################ INCLUDES
+
+BSDCFG_SHARE="/usr/share/bsdconfig"
+. $BSDCFG_SHARE/common.subr || exit 1
+
+BSDCFG_LIBE="/usr/libexec/bsdconfig" APP_DIR="dot"
+f_include_lang $BSDCFG_LIBE/include/messages.subr
+f_include_lang $BSDCFG_LIBE/$APP_DIR/include/messages.subr
+
+ipgm=$( f_index_menu_selection $BSDCFG_LIBE/$APP_DIR/INDEX "$pgm" )
+[ $? -eq $SUCCESS -a "$ipgm" ] && pgm="$ipgm"
+
+############################################################ CONFIGURATION
+
+#
+# Locataion of bsdconfig(8)
+#
+BSDCONFIG=/usr/sbin/bsdconfig
+
+############################################################ GLOBALS
+
+#
+# Options
+#
+SHOW_GRAPH_LABEL_DATE=1
+SHOW_INCLUDES=1
+SHOW_CMDLINE=1
+
+############################################################ FUNCTIONS
+
+# begin_nodelist $shape $color $fillcolor $style
+#
+# Create a new multi-node list rendering nodes in a specific style described by
+# the arguments passed.
+#
+begin_nodelist()
+{
+ local shape="$1" color="$2" fillcolor="$3" style="$4"
+
+ printf "\tnode [\n"
+ [ "$shape" ] &&
+ printf '\t\tshape = "%s",\n' "$shape"
+ [ "$color" ] &&
+ printf '\t\tcolor = "%s",\n' "$color"
+ [ "$fillcolor" ] &&
+ printf '\t\tfillcolor = "%s",\n' "$fillcolor"
+ [ "$style" ] &&
+ printf '\t\tstyle = "%s",\n' "$style"
+ printf "\t] {\n"
+}
+
+# print_node $node [$attributes ...]
+#
+# Print a node within a multi-node list.
+#
+print_node()
+{
+ local node="$1"
+
+ shift 1 # node
+
+ case "$node" in
+ edge) printf '\t\t%s' "$node";;
+ *) printf '\t\t"%s"' "$node";;
+ esac
+
+ if [ $# -gt 0 ]; then
+ echo -n ' ['
+ while [ $# -gt 0 ]; do
+ printf " %s" "$1"
+ shift 1
+ [ $# -gt 0 ] && echo -n ","
+ done
+ echo -n " ]"
+ fi
+
+ echo ";"
+}
+
+# print_node2 $node $node [$attributes ...]
+#
+# Print a directed node-node connection within a multi-node list.
+#
+print_node2()
+{
+ local node1="$1" node2="$2"
+
+ shift 2 # node1 node2
+
+ printf '\t\t"%s" -> "%s"' "$node1" "$node2"
+
+ if [ $# -gt 0 ]; then
+ echo -n ' ['
+ while [ $# -gt 0 ]; do
+ printf " %s" "$1"
+ shift 1
+ [ $# -gt 0 ] && echo -n ","
+ done
+ echo -n " ]"
+ fi
+
+ echo ";"
+}
+
+# end_nodelist
+#
+# Close a multi-node list.
+#
+end_nodelist()
+{
+ printf "\t};\n"
+}
+
+############################################################ MAIN
+
+# Incorporate rc-file if it exists
+[ -f "$HOME/.bsdconfigrc" ] && f_include "$HOME/.bsdconfigrc"
+
+#
+# Process command-line arguments
+#
+while getopts cdhi flag; do
+ case "$flag" in
+ i) SHOW_INCLUDES=;;
+ d) SHOW_GRAPH_LABEL_DATE=;;
+ c) SHOW_CMDLINE=;;
+ h|\?) f_usage $BSDCFG_LIBE/$APP_DIR/USAGE "PROGRAM_NAME" "$pgm";;
+ esac
+done
+shift $(( $OPTIND - 1 ))
+
+cd $BSDCFG_LIBE || f_die 1 "$msg_directory_not_found" "$BSDCFG_LIB"
+
+#
+# Get a list of menu programs
+#
+menu_program_list=
+for file in [0-9][0-9][0-9].*/INDEX; do
+ menu_program_list="$menu_program_list $(
+ tail -r "$file" | awk -v item="${file%%/*}" '
+ /^[[:space:]]*menu_program="/ {
+ sub(/^.*="/, "")
+ sub(/"$/, "")
+ if ( ! $0 ) next
+ if ( $0 !~ "^/" ) sub(/^/, item "/")
+ print; exit
+ }'
+ )"
+done
+
+#
+# Get a list of submenu programs
+#
+submenu_program_list=
+for menu_program in $menu_program_list; do
+ case "$menu_program" in
+ [0-9][0-9][0-9].*/*) : fall-through ;;
+ *) continue # No sub-menus we can process
+ esac
+
+ submenu_program_list="$submenu_program_list $(
+ awk -v menu_program="$menu_program" \
+ -v item="${menu_program%%/*}" \
+ '
+ /^menu_selection="/ {
+ sub(/.*\|/, "")
+ sub(/"$/, "")
+ if ( ! $0 ) next
+ if ( $0 !~ "^/" )
+ sub(/^/, item "/")
+ if ( $0 == menu_program ) next
+ print
+ }
+ ' "${menu_program%%/*}/INDEX"
+ )"
+done
+
+#
+# Get a list of command-line programs
+#
+cmd_program_list=
+for file in */INDEX; do
+ cmd_program_list="$cmd_program_list $(
+ awk -v item="${file%%/*}" '
+ /^menu_selection="/ {
+ sub(/.*\|/, "")
+ sub(/"$/, "")
+
+ if ( ! $0 ) next
+
+ if ( $0 !~ "^/" )
+ sub(/^/, item "/")
+
+ print
+ }
+ ' $file
+ )"
+done
+
+#
+# [Optionally] Calculate list of include files
+#
+if [ "$SHOW_INCLUDES" ]; then
+ print_includes_awk='
+ BEGIN { regex = "^f_include \\$BSDCFG_SHARE/" }
+ ( $0 ~ regex ) { sub(regex, ""); print }
+ ' # END-QUOTE
+
+ #
+ # Build list of files in which to search for includes
+ #
+ file_list=$(
+ for file in \
+ $BSDCONFIG \
+ $menu_program_list \
+ $submenu_program_list \
+ $cmd_program_list \
+ ; do
+ [ -e "$file" ] && echo $file
+ done | sort -u
+ )
+
+ #
+ # Build list of includes used by the above files
+ #
+ include_file_list=
+ for file in $file_list; do
+ include_file_list="$include_file_list $(
+ awk -v file="$file" -v item="${file%%/*}" \
+ "$print_includes_awk" $file
+ )"
+ done
+
+ #
+ # Sort the list of includes and remove duplicate entries
+ #
+ include_file_list=$(
+ for include_file in $include_file_list; do
+ echo "$include_file"
+ done | sort -u
+ )
+
+ #
+ # Search previously-discovered include files for further includes
+ #
+ for file in $include_file_list; do
+ include_file_list="$include_file_list $(
+ awk -v file="$file" -v item="${file%%/*}" \
+ "$print_includes_awk" $BSDCFG_SHARE/$file
+ )"
+ done
+
+ #
+ # Sort the list of includes and remove duplicate entries [again]
+ #
+ include_file_list=$(
+ for include_file in $include_file_list; do
+ echo "$include_file"
+ done | sort -u
+ )
+fi
+
+#
+# Start the directional-graph (digraph) output
+#
+printf 'strict digraph "" { // Empty name to prevent SVG Auto-Tooltip\n'
+label_format="$msg_graph_label_with_command"
+[ "$SHOW_GRAPH_LABEL_DATE" ] &&
+ label_format="$msg_graph_label_with_command_and_date"
+lang="${LANG:-$LC_ALL}"
+printf "\n\tlabel = \"$label_format\"\n" \
+ "${lang:+LANG=${lang%%[$IFS]*} }bsdconfig $pgm${ARGV:+ $ARGV}" \
+ "$( date +"%c %Z" )"
+
+#
+# Print graph-specific properties
+#
+printf '\n\t/*\n\t * Graph setup and orientation\n\t */\n'
+printf '\tlabelloc = top;\t\t// display above label at top of graph\n'
+printf '\trankdir = LR;\t\t// create ranks left-to-right\n'
+printf '\torientation = portrait;\t// default\n'
+printf '\tratio = fill;\t\t// approximate aspect ratio\n'
+printf '\tcenter = 1;\t\t// center drawing on page\n'
+
+#
+# Perform edge-concentration when displaying a lot of information
+#
+# NOTE: This is disabled because dot version 2.28.0 (current) and older have a
+# bug that causes a crash when rankdir = LR and concentrate = true
+#
+# NOTE: Do not re-enable until said bug is fixed in some future revision.
+#
+#[ "$SHOW_INCLUDES" -a "$SHOW_CMDLINE" ] &&
+# printf '\tconcentrate = true;\t// enable edge concentrators\n'
+
+#
+# Print font details for graph/cluster label(s)
+#
+printf '\n\t/*\n\t * Font details for graph/cluster label(s)\n\t */\n'
+printf '\tfontname = "Times-Italic";\n'
+printf '\tfontsize = 14;\n'
+
+#
+# Print default node attributes
+#
+printf '\n\t/*\n\t * Default node attributes\n\t */\n'
+printf '\tnode [\n'
+printf '\t\tfontname = "Times-Roman",\n'
+printf '\t\tfontsize = 12,\n'
+printf '\t\twidth = 2.5, // arbitrary minimum width for all nodes\n'
+printf '\t\tfixedsize, // turn minimum width into exact width\n'
+printf '\t];\n'
+
+#
+# Print top-level item(s)
+#
+printf '\n\t/*\n\t * bsdconfig(8)\n\t */\n'
+shape=circle color=black fillcolor=yellow style=filled
+begin_nodelist "$shape" "$color" "$fillcolor" "$style"
+print_node "bsdconfig" "fontname = \"Times-Bold\"" "fontsize = 16"
+end_nodelist
+
+#
+# Print menus
+#
+printf '\n\t/*\n\t * Menu items\n\t */\n'
+shape=box color=black fillcolor=lightblue style=filled
+begin_nodelist "$shape" "$color" "$fillcolor" "$style"
+for menu_program in $menu_program_list; do
+ print_node "$menu_program" "label = \"${menu_program#*/}\""
+done
+end_nodelist
+
+#
+# Print sub-menus
+#
+printf '\n\t/*\n\t * Sub-menu items\n\t */\n'
+shape=box color=black fillcolor=lightblue style=filled
+begin_nodelist "$shape" "$color" "$fillcolor" "$style"
+for submenu_program in $submenu_program_list; do
+ print_node "$submenu_program" "label = \"${submenu_program#*/}\""
+done
+end_nodelist
+
+#
+# Print menu relationships
+#
+printf '\n\t/*\n\t * Menu item relationships\n\t */\n'
+shape=box color=black fillcolor=lightblue style=filled edge_color=blue
+begin_nodelist "$shape" "$color" "$fillcolor" "$style"
+print_node edge "penwidth = 5.0" "style = bold" "color = $edge_color"
+for menu_program in $menu_program_list; do
+ print_node2 "bsdconfig" "$menu_program"
+done
+end_nodelist
+
+#
+# Print sub-menu relationships
+#
+printf '\n\t/*\n\t * Sub-menu item relationships\n\t */\n'
+shape=box color=black fillcolor=lightblue style=filled edge_color=blue
+begin_nodelist "$shape" "$color" "$fillcolor" "$style"
+# Lock sub-menu headport to the West (unless `-c' was passed)
+[ "$SHOW_CMDLINE" -o ! "$SHOW_INCLUDES" ] && print_node edge "headport = w"
+print_node edge "style = bold" "color = $edge_color"
+for submenu_program in $submenu_program_list; do
+ for menu_program in $menu_program_list; do
+ case "$menu_program" in
+ [0-9][0-9][0-9].*/*) : fall-through ;;
+ *) continue # Not a menu item
+ esac
+
+ # Continue if program directories do not match
+ [ "${menu_program%%/*}" = "${submenu_program%%/*}" ] ||
+ continue
+
+ print_node2 "$menu_program" "$submenu_program"
+ break
+ done
+done
+end_nodelist
+
+#
+# [Optionally] Print include files
+#
+if [ "$SHOW_INCLUDES" ]; then
+ printf '\n\t/*\n\t * Include files\n\t */\n'
+ shape=oval color=black fillcolor=white style=filled
+ begin_nodelist "$shape" "$color" "$fillcolor" "$style"
+ printf '\t\tconstraint = false;\n'
+ for include_file in $include_file_list; do
+ print_node "$include_file" \
+ "label = \"${include_file##*/}\""
+ done
+ end_nodelist
+fi
+
+#
+# [Optionally] Print f_include() usage/relationships
+#
+if [ "$SHOW_INCLUDES" ]; then
+ printf '\n\t/*\n\t * Include usage\n\t */\n'
+ shape=oval color=black fillcolor=white style=filled edge_color=grey
+ begin_nodelist "$shape" "$color" "$fillcolor" "$style"
+ print_node edge "style = dashed" "color = $edge_color"
+ print_node edge "label = \"\\T\"" "fontsize = 9"
+ file_list=$(
+ for file in \
+ $BSDCONFIG \
+ $menu_program_list \
+ $submenu_program_list \
+ $cmd_program_list \
+ $include_file_list \
+ ; do
+ [ -f "$BSDCFG_SHARE/$file" ] &&
+ echo $BSDCFG_SHARE/$file
+ [ -e "$file" ] && echo $file
+ done | sort -u
+ )
+ for file in $file_list; do
+ # Skip binary files and text files that don't use f_include()
+ grep -qlI f_include $file || continue
+
+ awk \
+ -v file="${file#$BSDCFG_SHARE/}" \
+ -v bsdconfig="$BSDCONFIG" \
+ '
+ BEGIN { regex = "^f_include \\$BSDCFG_SHARE/" }
+ ( $0 ~ regex ) {
+ sub(regex, "")
+ if ( file == bsdconfig ) sub(".*/", "", file)
+ printf "\t\t\"%s\" -> \"%s\";\n", $0, file
+ }
+ ' $file
+ done | sort
+ end_nodelist
+fi
+
+#
+# Print command-line shortcuts
+#
+if [ "$SHOW_CMDLINE" ]; then
+ printf '\n\t/*\n\t * Command-line shortcuts\n\t */\n'
+ shape=parallelogram color=black fillcolor=lightseagreen style=filled
+ begin_nodelist "$shape" "$color" "$fillcolor" "$style"
+ for file in */INDEX; do
+ awk -v item="${file%%/*}" '
+ /^menu_selection="/ {
+ sub(/^.*="/, "")
+ sub(/\|.*/, "")
+ printf "\t\t\"bsdconfig %s\"", $0
+ printf " [ label = \"%s\" ];\n", $0
+ }
+ ' $file
+ done
+ end_nodelist
+fi
+
+#
+# Print command-line shortcut relationships
+#
+if [ "$SHOW_CMDLINE" ]; then
+ printf '\n\t/*\n\t * Command-line shortcut relationships\n\t */\n'
+ shape=box color=black fillcolor=lightseagreen style=filled
+ begin_nodelist "$shape" "$color" "$fillcolor" "$style"
+ print_node edge "headport = w" "weight = 100.0"
+ print_node edge "style = bold" "color = $fillcolor"
+ for file in */INDEX; do
+ awk -v item="${file%%/*}" \
+ -v node_fillcolor="$node_fillcolor" \
+ -v edge_color="$edge_color" \
+ '
+ /^menu_selection="/ {
+ sub(/^.*="/, "")
+ sub(/"$/, "")
+
+ if ( ! $0 ) next
+
+ split($0, menusel, "|")
+ if ( menusel[2] !~ "^/" )
+ sub(/^/, item "/", menusel[2])
+
+ printf "\t\t\"bsdconfig %s\" -> \"%s\";\n",
+ menusel[1], menusel[2]
+ }
+ ' $file
+ done
+ end_nodelist
+fi
+
+#
+# Print clusters
+#
+bgcolor_bsdconfig="lightyellow"
+bgcolor_includes="gray98"
+bgcolor_menuitem="aliceblue"
+bgcolor_shortcuts="honeydew"
+printf '\n\t/*\n\t * Clusters\n\t */\n'
+printf '\tsubgraph "cluster_bsdconfig" {\n'
+printf '\t\tbgcolor = "%s";\n' "$bgcolor_bsdconfig"
+printf '\t\tlabel = "bsdconfig(8)";\n'
+printf '\t\ttooltip = "bsdconfig(8)";\n'
+print_node "bsdconfig"
+if [ "$SHOW_INCLUDES" ]; then
+ printf '\t\tsubgraph "cluster_includes" {\n'
+ printf '\t\t\tbgcolor = "%s";\n' "$bgcolor_includes"
+ printf '\t\t\tlabel = "%s";\n' "$msg_includes"
+
+ for include_file in $include_file_list; do
+ echo $include_file
+ done | awk -v bgcolor="$bgcolor_bsdconfig" '
+ BEGIN { created = 0 }
+ function end_subgraph() { printf "\t\t\t};\n" }
+ ( $0 !~ "/" ) {
+ if ( ! created )
+ {
+ printf "\t\t\tsubgraph \"%s\" {\n",
+ "cluster_bsdconfig_includes"
+ printf "\t\t\t\tbgcolor = \"%s\";\n", bgcolor
+ printf "\t\t\t\tlabel = \"bsdconfig\";\n"
+ created++
+ }
+ printf "\t\t\t\t\"%s\";\n", $1
+ }
+ END { created && end_subgraph() }'
+
+ for include_file in $include_file_list; do
+ echo $include_file
+ done | awk '
+ BEGIN { created = 0 }
+ function end_subgraph() { printf "\t\t\t};\n" }
+ ( $0 ~ "/" ) {
+ include_dir_tmp = $1
+ sub("/[^/]*$", "", include_dir_tmp)
+ gsub(/[^[:alnum:]_]/, "_", include_dir_tmp)
+
+ if ( created && include_dir != include_dir_tmp )
+ {
+ end_subgraph()
+ created = 0
+ }
+
+ if ( ! created )
+ {
+ include_dir = include_dir_tmp
+ printf "\t\t\tsubgraph \"cluster_%s_includes\" {\n",
+ include_dir
+ printf "\t\t\t\tbgcolor = \"white\";\n"
+ printf "\t\t\t\tlabel = \"%s\";\n", include_dir
+ created++
+ }
+
+ printf "\t\t\t\t\"%s\";\n", $1
+ }
+ END { created && end_subgraph() }'
+
+ printf '\t\t};\n'
+fi
+end_nodelist
+for INDEX in */INDEX; do
+ menu_title=
+ menu_help=
+ f_include_lang "$INDEX"
+
+ item="${INDEX%%/*}"
+ printf '\tsubgraph "cluster_%s" {\n' "$item"
+
+ case "$item" in
+ [0-9][0-9][0-9].*) bgcolor="$bgcolor_menuitem";;
+ *) bgcolor="$bgcolor_shortcuts"
+ esac
+ printf '\t\tbgcolor = "%s";\n' "$bgcolor"
+ if [ "$menu_title" ]; then
+ printf '\t\tlabel = "%s\\n\\"%s\\"";\n' "$item" "$menu_title"
+ else
+ printf '\t\tlabel = "%s";\n' "$item"
+ fi
+ printf '\t\ttooltip = "%s";\n' "${menu_help:-$item}"
+
+ program_list=$(
+ for program in \
+ $menu_program_list \
+ $submenu_program_list \
+ $cmd_program_list \
+ ; do
+ echo "$program"
+ done | sort -u
+ )
+ for program in $program_list; do
+ case "$program" in "$item"/*)
+ print_node "$program" "label = \"${program#*/}\""
+ esac
+ done
+
+ if [ "$SHOW_INCLUDES" ]; then
+ item_include_list=
+ [ -d "$item/include" ] &&
+ item_include_list=$( find "$item/include" -type f )
+ item_include_list=$(
+ for item_include in $item_include_list; do
+ for include_file in $include_file_list; do
+ [ "$item_include" = "$include_file" ] ||
+ continue
+ echo "$item_include"; break
+ done
+ done
+ )
+ if [ "$item_include_list" ]; then
+ printf '\t\tsubgraph "cluster_%s_includes" {\n' "$item"
+ printf '\t\t\tbgcolor = "%s";\n' "$bgcolor_includes"
+ printf '\t\t\tlabel = "%s";\n' "$msg_includes"
+ fi
+ for item_include in $item_include_list; do
+ printf '\t\t\t"%s";\n' "$item_include"
+ done
+ [ "$item_include_list" ] && printf '\t\t};\n'
+ fi
+
+ if [ "$SHOW_CMDLINE" ]; then
+ printf '\t\tsubgraph "cluster_%s_shortcuts" {\n' "$item"
+ printf '\t\t\tbgcolor = "%s";\n' "$bgcolor_shortcuts"
+ printf '\t\t\tlabel = "%s";\n' "$msg_shortcuts"
+ awk '/^menu_selection="/ {
+ sub(/^.*="/, "")
+ sub(/\|.*/, "")
+ printf "\t\t\t\"bsdconfig %s\";\n", $0
+ }' "$INDEX"
+ printf '\t\t};\n'
+ fi
+
+ end_nodelist
+done
+
+printf '\n};\n'
+
+################################################################################
+# END
+################################################################################
diff --git a/usr.sbin/bsdconfig/dot/include/Makefile b/usr.sbin/bsdconfig/dot/include/Makefile
new file mode 100644
index 0000000..9bbdea0
--- /dev/null
+++ b/usr.sbin/bsdconfig/dot/include/Makefile
@@ -0,0 +1,11 @@
+# $FreeBSD$
+
+NO_OBJ=
+
+FILESDIR= ${LIBEXECDIR}/bsdconfig/dot/include
+FILES= messages.subr
+
+beforeinstall:
+ mkdir -p ${DESTDIR}${FILESDIR}
+
+.include <bsd.prog.mk>
diff --git a/usr.sbin/bsdconfig/dot/include/messages.subr b/usr.sbin/bsdconfig/dot/include/messages.subr
new file mode 100644
index 0000000..527f308
--- /dev/null
+++ b/usr.sbin/bsdconfig/dot/include/messages.subr
@@ -0,0 +1,30 @@
+# Copyright (c) 2012 Devin Teske
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in the
+# documentation and/or other materials provided with the distribution.
+#
+# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+# SUCH DAMAGE.
+#
+# $FreeBSD$
+
+msg_graph_label_with_command="bsdconfig(8)\\\ndot(1) output generated by \`\`%s''"
+msg_graph_label_with_command_and_date="bsdconfig(8)\\\ndot(1) output generated by \`\`%s'' on\\\n%s"
+msg_includes="Includes"
+msg_shortcuts="Shortcuts"
diff --git a/usr.sbin/bsdconfig/examples/Makefile b/usr.sbin/bsdconfig/examples/Makefile
new file mode 100644
index 0000000..f072350
--- /dev/null
+++ b/usr.sbin/bsdconfig/examples/Makefile
@@ -0,0 +1,11 @@
+# $FreeBSD$
+
+NO_OBJ=
+
+FILESDIR= ${SHAREDIR}/examples/bsdconfig
+FILES= bsdconfigrc
+
+beforeinstall:
+ mkdir -p ${DESTDIR}${FILESDIR}
+
+.include <bsd.prog.mk>
diff --git a/usr.sbin/bsdconfig/examples/bsdconfigrc b/usr.sbin/bsdconfig/examples/bsdconfigrc
new file mode 100644
index 0000000..a863a94
--- /dev/null
+++ b/usr.sbin/bsdconfig/examples/bsdconfigrc
@@ -0,0 +1,35 @@
+# Copyright (c) 2012 Ron McDowell
+# Copyright (c) 2012 Devin Teske
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in the
+# documentation and/or other materials provided with the distribution.
+#
+# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+# SUCH DAMAGE.
+#
+# $FreeBSD$
+
+# This file allows you to customize the behavior of bsdconfig.
+# Copy it to your $HOME/.bsdconfigrc and edit to suit.
+# defaults are shown.
+
+# debugging aid for development
+# f_dprintf() {
+# echo "$(date):$pgm: $1" >> $HOME/out
+# }
diff --git a/usr.sbin/bsdconfig/include/Makefile b/usr.sbin/bsdconfig/include/Makefile
new file mode 100644
index 0000000..cb4b1b6
--- /dev/null
+++ b/usr.sbin/bsdconfig/include/Makefile
@@ -0,0 +1,11 @@
+# $FreeBSD$
+
+NO_OBJ=
+
+FILESDIR= ${LIBEXECDIR}/bsdconfig/include
+FILES= bsdconfig.hlp messages.subr usage.hlp
+
+beforeinstall:
+ mkdir -p ${DESTDIR}${FILESDIR}
+
+.include <bsd.prog.mk>
diff --git a/usr.sbin/bsdconfig/include/bsdconfig.hlp b/usr.sbin/bsdconfig/include/bsdconfig.hlp
new file mode 100644
index 0000000..b6eeaf3
--- /dev/null
+++ b/usr.sbin/bsdconfig/include/bsdconfig.hlp
@@ -0,0 +1,12 @@
+This menu allows you to configure your system after the installation
+process is complete. At the minimum, you should probably set the root
+password and the system time zone.
+
+For extra goodies like bash, emacs, firefox, etc., you should look at
+the Packages item in this menu.
+
+For setting the timezone after the system is installed, use the 'Time
+Zone' item in this menu.
+
+For more information on the overall general system configuration, see
+the /etc/rc.conf and /etc/defaults/rc.conf files.
diff --git a/usr.sbin/bsdconfig/include/messages.subr b/usr.sbin/bsdconfig/include/messages.subr
new file mode 100644
index 0000000..ec988ad
--- /dev/null
+++ b/usr.sbin/bsdconfig/include/messages.subr
@@ -0,0 +1,63 @@
+# Copyright (c) 2012 Ron McDowell
+# Copyright (c) 2012 Devin Teske
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in the
+# documentation and/or other materials provided with the distribution.
+#
+# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+# SUCH DAMAGE.
+#
+# $FreeBSD$
+
+field_username="Username:"
+field_password="Password:"
+hline_alnum_punc_tab_enter="Use alpha-numeric, punctuation, TAB or ENTER"
+hline_arrows_tab_enter="Press arrows, TAB or ENTER"
+msg_always_try_sudo_when_run_as="Always try sudo(8) when run as %s"
+msg_becoming_root_via_sudo="Becoming root via sudo(8)..."
+msg_cancel="Cancel"
+msg_cancel_exit="Cancel/Exit"
+msg_cannot_create_permission_denied="%s: cannot create %s: Permission denied"
+msg_created_path="Created %s"
+msg_directory_not_found="%s: Directory not found."
+msg_exit="Exit"
+msg_exit_bsdconfig="Exit bsdconfig"
+msg_main_menu="Main Menu"
+msg_menu_text="If you've already installed FreeBSD, you may use\nthis menu to customize it somewhat to suit your\nparticular configuration. Most importantly, you\ncan use the Packages utility to load extra '3rd\nparty' software not provided in the base\ndistributions."
+msg_must_be_root_to_execute="%s: must be root to execute"
+msg_nfailed_attempts="%u incorrect password attempts"
+msg_no="No"
+msg_no_such_file_or_directory="%s: %s: No such file or directory"
+msg_no_username="No username provided!"
+msg_not_found="not found"
+msg_ok="OK"
+msg_permission_denied="%s: %s: Permission denied"
+msg_please_enter_password="Please enter your password for sudo(8):"
+msg_please_enter_username_password="Please enter a username and password for sudo(8):"
+msg_previous_syntax_errors="%s: Not overwriting \`%s' due to previous syntax errors"
+msg_quick_start_how_to_use_this_menu_system="Quick start - How to use this menu system"
+msg_secure_mode_requires_x11="Secure-mode requires X11 (use \`-X')!"
+msg_secure_mode_requires_root="Secure-mode requires root-access!"
+msg_sorry_try_again="Sorry, try again."
+msg_try_sudo_only_this_once="Try sudo(8) only this once"
+msg_unknown_user="Unknown user: %s"
+msg_usage="Usage"
+msg_user_disallowed="User disallowed: %s"
+msg_yes="Yes"
+msg_you_are_not_root_but="You are not root but %s can use sudo(8).\nWhat would you like to do?"
diff --git a/usr.sbin/bsdconfig/include/usage.hlp b/usr.sbin/bsdconfig/include/usage.hlp
new file mode 100644
index 0000000..4412da7
--- /dev/null
+++ b/usr.sbin/bsdconfig/include/usage.hlp
@@ -0,0 +1,64 @@
+HOW TO USE THIS SYSTEM
+======================
+
+[press the PageDown key to go to the next screen when you finish
+ reading this one]
+
+The following keys are recognized in most of the dialogs you'll
+encounter during this installation:
+
+KEY ACTION
+--- ------
+SPACE Select or toggle the current item.
+ENTER Finish with a menu or item.
+UP ARROW Move to previous item (or up, in a text display box).
+DOWN ARROW Move to next item (or down, in a text display box).
+TAB Move to next item or group.
+RIGHT ARROW Move to next item or group (same as TAB).
+SHIFT-TAB Move to previous item or group.
+LEFT ARROW Move to previous item or group (same as SHIFT-TAB).
+PAGE UP In text display boxes, scrolls up one page.
+PAGE DOWN In text display boxes, scrolls down one page.
+F1 Display associated help text.
+
+If you see small "^(-)" or "v(+)" symbols at the edges of a menu, it
+means that there are more items above or below the current one that
+aren't being shown (due to insufficient screen space). In text
+display boxes, the amount of text above the current point will be
+displayed as a percentage in the lower right corner. Using the
+Up/Down arrow keys will cause the object to scroll by line. The
+PageUp and PageDown keys will scroll by entire screens.
+
+Selecting OK in a menu will confirm whatever action it's controlling.
+Selecting Cancel will cancel the operation and generally return you to
+the previous menu. Use TAB to move the cursor around and select the
+buttons.
+
+Most screens offer a Help button - USE IT! It generally offers useful
+context-specific hints on what to do and if you're at all unsure about
+what to do at a given configuration menu, choose Help!
+
+
+SPECIAL FEATURES:
+=================
+
+It is possible to select a menu item by typing the first character of
+its name, if unique. This will generally be an item number.
+
+The console driver contains a scroll-back buffer for reviewing things
+that may have scrolled off the screen. To use scroll-back, press the
+"Scroll Lock" key on your keyboard and use the arrow or Page Up/Page
+Down keys to move through the saved text. To leave scroll-back mode,
+press the Scroll Lock key again. This feature is most useful for
+reading back through your boot messages (go ahead, try it now!) though
+it's also useful when dealing with sub-shells or other "expert modes"
+that don't use menus and tend to scroll their output off the top of
+the screen.
+
+FreeBSD also supports multiple "virtual consoles" which you can use
+in order to have several active sessions at once. Use ALT-F<n> to
+switch between screens, where `F<n>' is the function key corresponding
+to the screen you wish to see. By default, the system comes with 8
+virtual consoles enabled - you can enable more by editing the
+/etc/ttys file and turning the "off" field to "on" in the relevant vty
+entries (up to 12).
diff --git a/usr.sbin/bsdconfig/mouse/INDEX b/usr.sbin/bsdconfig/mouse/INDEX
new file mode 100644
index 0000000..cf7224c
--- /dev/null
+++ b/usr.sbin/bsdconfig/mouse/INDEX
@@ -0,0 +1,58 @@
+# Copyright (c) 2012 Ron McDowell
+# Copyright (c) 2012 Devin Teske
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in the
+# documentation and/or other materials provided with the distribution.
+#
+# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+# SUCH DAMAGE.
+#
+# $FreeBSD$
+
+#
+# Title that will be shown on the bsdconfig menu
+menu_title="Mouse"
+#
+# a short descriptive line shown at the bottom of the bsdconfig menu.
+# keep it short because any line longer than the terminal width will
+# be truncated.
+menu_help="Configure the Mouse"
+#
+# two-part variable that defines an action to take when 'keyword'
+# is passed on a bsdconfig command line. variable takes the form
+# "keyword|command" and multiple occurrences of the variable
+# (with different 'keyword's, or different 'keyword's AND 'command's)
+# are allowed. If 'command' begins with a '/' then the full
+# path to the program is needed. If 'command' begins with anything
+# else it is a path relative to the directory this INDEX file is in.
+# 'keyword' can be i18n'ed but 'command' is the name of a script.
+menu_selection="mouse|mouse"
+menu_selection="mouse_enable|enable"
+menu_selection="mouse_type|type"
+menu_selection="mouse_port|port"
+menu_selection="mouse_flags|flags"
+menu_selection="mouse_disable|disable"
+#
+# Items below this line do NOT need i18n translation----------------------
+#
+# Name of the program to be run when this menu choice is selected.
+# if it begins with a '/' then the full path to the program is needed.
+# if it begins with anything else it is a path relative to the directory
+# this INDEX file is in.
+menu_program="mouse"
diff --git a/usr.sbin/bsdconfig/mouse/Makefile b/usr.sbin/bsdconfig/mouse/Makefile
new file mode 100644
index 0000000..3b68cad
--- /dev/null
+++ b/usr.sbin/bsdconfig/mouse/Makefile
@@ -0,0 +1,16 @@
+# $FreeBSD$
+
+NO_OBJ=
+
+SUBDIR= include
+
+FILESDIR= ${LIBEXECDIR}/bsdconfig/110.mouse
+FILES= INDEX USAGE
+
+SCRIPTSDIR= ${FILESDIR}
+SCRIPTS= disable enable flags mouse port type
+
+beforeinstall:
+ mkdir -p ${DESTDIR}${FILESDIR}
+
+.include <bsd.prog.mk>
diff --git a/usr.sbin/bsdconfig/mouse/USAGE b/usr.sbin/bsdconfig/mouse/USAGE
new file mode 100644
index 0000000..9aa4dca
--- /dev/null
+++ b/usr.sbin/bsdconfig/mouse/USAGE
@@ -0,0 +1,33 @@
+# Copyright (c) 2012 Devin Teske
+# All Rights Reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in the
+# documentation and/or other materials provided with the distribution.
+#
+# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING BUT NOT LIMITED TO, THE
+# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+# DAMAGES (INLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+# SUCH DAMAGE.
+#
+# $FreeBSD$
+
+Usage: bsdconfig @PROGRAM_NAME@ [OPTIONS]
+
+OPTIONS:
+ -h Print usage statement and exit.
+ -S Secure X11 mode (implies `-X'). As root, always prompt-for
+ and validate sudo(8) username/password before starting.
+ -X Use Xdialog(1) in place of dialog(1).
diff --git a/usr.sbin/bsdconfig/mouse/disable b/usr.sbin/bsdconfig/mouse/disable
new file mode 100755
index 0000000..099cf31
--- /dev/null
+++ b/usr.sbin/bsdconfig/mouse/disable
@@ -0,0 +1,104 @@
+#!/bin/sh
+#-
+# Copyright (c) 2012 Devin Teske
+# All Rights Reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in the
+# documentation and/or other materials provided with the distribution.
+#
+# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING BUT NOT LIMITED TO, THE
+# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+# DAMAGES (INLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+# SUCH DAMAGE.
+#
+# $FreeBSD$
+#
+############################################################ INCLUDES
+
+BSDCFG_SHARE="/usr/share/bsdconfig"
+. $BSDCFG_SHARE/common.subr || exit 1
+f_include $BSDCFG_SHARE/dialog.subr
+f_include $BSDCFG_SHARE/mustberoot.subr
+f_include $BSDCFG_SHARE/sysrc.subr
+
+BSDCFG_LIBE="/usr/libexec/bsdconfig" APP_DIR="110.mouse"
+f_include_lang $BSDCFG_LIBE/$APP_DIR/include/messages.subr
+
+ipgm=$( f_index_menu_selection $BSDCFG_LIBE/$APP_DIR/INDEX "$pgm" )
+[ $? -eq $SUCCESS -a "$ipgm" ] && pgm="$ipgm"
+
+############################################################ CONFIGURATION
+
+#
+# Location of moused(8) pidfile
+#
+MOUSED_PIDFILE=/var/run/moused.pid
+
+############################################################ MAIN
+
+# Incorporate rc-file if it exists
+[ -f "$HOME/.bsdconfigrc" ] && f_include "$HOME/.bsdconfigrc"
+
+#
+# Process command-line arguments
+#
+while getopts hSX flag; do
+ case "$flag" in
+ h|\?) f_usage $BSDCFG_LIBE/$APP_DIR/USAGE "PROGRAM_NAME" "$pgm";;
+ esac
+done
+shift $(( $OPTIND - 1 ))
+
+#
+# Initialize
+#
+f_dialog_init
+f_dialog_title "$msg_mouse_disable"
+f_dialog_backtitle "${ipgm:+bsdconfig }$pgm"
+f_mustberoot_init
+
+#
+# Stop the mouse daemon
+#
+[ -r "$MOUSED_PIDFILE" ] &&
+ f_quietly kill "$( cat "$MOUSED_PIDFILE" )"
+f_sysrc_set moused_enable "NO" || f_die
+f_sysrc_set moused_type "NO" || f_die
+f_sysrc_delete moused_port || f_die
+f_sysrc_delete moused_flags || f_die
+
+#
+# Message box
+#
+f_dialog_title "$msg_message"
+hline="$hline_press_enter_or_space"
+prompt="$msg_mouse_daemon_is_disabled"
+size=$( f_dialog_buttonbox_size \
+ "$DIALOG_TITLE" \
+ "$DIALOG_BACKTITLE" \
+ "$prompt" )
+eval $DIALOG \
+ --title \"\$DIALOG_TITLE\" \
+ --backtitle \"\$DIALOG_BACKTITLE\" \
+ --hline \"\$hline\" \
+ --ok-label \"\$msg_ok\" \
+ --msgbox \"\$prompt\" $size
+
+exit $SUCCESS
+
+################################################################################
+# END
+################################################################################
diff --git a/usr.sbin/bsdconfig/mouse/enable b/usr.sbin/bsdconfig/mouse/enable
new file mode 100755
index 0000000..e1cf796
--- /dev/null
+++ b/usr.sbin/bsdconfig/mouse/enable
@@ -0,0 +1,118 @@
+#!/bin/sh
+#-
+# Copyright (c) 2012 Devin Teske
+# All Rights Reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in the
+# documentation and/or other materials provided with the distribution.
+#
+# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING BUT NOT LIMITED TO, THE
+# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+# DAMAGES (INLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+# SUCH DAMAGE.
+#
+# $FreeBSD$
+#
+############################################################ INCLUDES
+
+BSDCFG_SHARE="/usr/share/bsdconfig"
+. $BSDCFG_SHARE/common.subr || exit 1
+f_include $BSDCFG_SHARE/dialog.subr
+f_include $BSDCFG_SHARE/mustberoot.subr
+f_include $BSDCFG_SHARE/sysrc.subr
+
+BSDCFG_LIBE="/usr/libexec/bsdconfig" APP_DIR="110.mouse"
+f_include_lang $BSDCFG_LIBE/$APP_DIR/include/messages.subr
+
+ipgm=$( f_index_menu_selection $BSDCFG_LIBE/$APP_DIR/INDEX "$pgm" )
+[ $? -eq $SUCCESS -a "$ipgm" ] && pgm="$ipgm"
+
+############################################################ CONFIGURATION
+
+#
+# Location of moused(8) pidfile
+#
+MOUSED_PIDFILE=/var/run/moused.pid
+
+############################################################ MAIN
+
+# Incorporate rc-file if it exists
+[ -f "$HOME/.bsdconfigrc" ] && f_include "$HOME/.bsdconfigrc"
+
+#
+# Process command-line arguments
+#
+while getopts hSX flag; do
+ case "$flag" in
+ h|\?) f_usage $BSDCFG_LIBE/$APP_DIR/USAGE "PROGRAM_NAME" "$pgm";;
+ esac
+done
+shift $(( $OPTIND - 1 ))
+
+#
+# Initialize
+#
+f_dialog_init
+f_dialog_title "$msg_mouse_enable"
+f_dialog_backtitle "${ipgm:+bsdconfig }$pgm"
+f_mustberoot_init
+
+#
+# Get the type, port, and flags
+#
+type=$( f_sysrc_get moused_type )
+case "$type" in
+[Nn][Oo]|"") f_die 1 "$msg_please_select_protocol_and_port_first" ;;
+esac
+port=$( f_sysrc_get moused_port )
+[ "$port" ] || f_die 1 "$msg_please_select_protocol_and_port_first"
+flags=$( f_sysrc_get moused_flags )
+
+#
+# Start the mouse daemon
+#
+f_dialog_info "$msg_trying_to_start_the_mouse_daemon"
+[ -r "$MOUSED_PIDFILE" ] &&
+ f_quietly kill "$( cat "$MOUSED_PIDFILE" 2> /dev/null )"
+f_quietly vidcontrol -m on
+f_quietly moused -t "$type" -p "$port" $flags
+
+#
+# Confirm with the user that the mouse is working
+#
+f_dialog_title "$msg_user_confirmation_requested"
+f_dialog_yesno "$msg_now_move_the_mouse"
+retval=$?
+f_dialog_title_restore
+
+#
+# Stop the mouse daemon
+#
+f_quietly vidcontrol -m off
+if [ $retval -eq $SUCCESS ]; then
+ f_sysrc_set moused_enable "YES" || f_die
+ ln -fs /dev/sysmouse /dev/mouse || f_die # backwards compat
+else
+ [ -r "$MOUSED_PIDFILE" ] &&
+ f_quietly kill "$( cat "$MOUSED_PIDFILE" )"
+ f_sysrc_set moused_enable "NO" || f_die
+fi
+
+exit $SUCCESS
+
+################################################################################
+# END
+################################################################################
diff --git a/usr.sbin/bsdconfig/mouse/flags b/usr.sbin/bsdconfig/mouse/flags
new file mode 100755
index 0000000..c989048
--- /dev/null
+++ b/usr.sbin/bsdconfig/mouse/flags
@@ -0,0 +1,118 @@
+#!/bin/sh
+#-
+# Copyright (c) 2012 Devin Teske
+# All Rights Reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in the
+# documentation and/or other materials provided with the distribution.
+#
+# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING BUT NOT LIMITED TO, THE
+# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+# DAMAGES (INLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+# SUCH DAMAGE.
+#
+# $FreeBSD$
+#
+############################################################ INCLUDES
+
+BSDCFG_SHARE="/usr/share/bsdconfig"
+. $BSDCFG_SHARE/common.subr || exit 1
+f_include $BSDCFG_SHARE/dialog.subr
+f_include $BSDCFG_SHARE/mustberoot.subr
+f_include $BSDCFG_SHARE/sysrc.subr
+
+BSDCFG_LIBE="/usr/libexec/bsdconfig" APP_DIR="110.mouse"
+f_include_lang $BSDCFG_LIBE/$APP_DIR/include/messages.subr
+
+ipgm=$( f_index_menu_selection $BSDCFG_LIBE/$APP_DIR/INDEX "$pgm" )
+[ $? -eq $SUCCESS -a "$ipgm" ] && pgm="$ipgm"
+
+############################################################ CONFIGURATION
+
+#
+# Location of moused(8) pidfile
+#
+MOUSED_PIDFILE=/var/run/moused.pid
+
+############################################################ MAIN
+
+# Incorporate rc-file if it exists
+[ -f "$HOME/.bsdconfigrc" ] && f_include "$HOME/.bsdconfigrc"
+
+#
+# Process command-line arguments
+#
+while getopts hSX flag; do
+ case "$flag" in
+ h|\?) f_usage $BSDCFG_LIBE/$APP_DIR/USAGE "PROGRAM_NAME" "$pgm";;
+ esac
+done
+shift $(( $OPTIND - 1 ))
+
+#
+# Initialize
+#
+f_dialog_init
+f_dialog_title "$msg_mouse_flags"
+f_dialog_backtitle "${ipgm:+bsdconfig }$pgm"
+f_mustberoot_init
+
+#
+# Get the current flags
+#
+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"
+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
+#
+f_sysrc_set moused_flags "$flags" || f_die
+
+exit $SUCCESS
+
+################################################################################
+# END
+################################################################################
diff --git a/usr.sbin/bsdconfig/mouse/include/Makefile b/usr.sbin/bsdconfig/mouse/include/Makefile
new file mode 100644
index 0000000..ed0b24d
--- /dev/null
+++ b/usr.sbin/bsdconfig/mouse/include/Makefile
@@ -0,0 +1,11 @@
+# $FreeBSD$
+
+NO_OBJ=
+
+FILESDIR= ${LIBEXECDIR}/bsdconfig/110.mouse/include
+FILES= messages.subr
+
+beforeinstall:
+ mkdir -p ${DESTDIR}${FILESDIR}
+
+.include <bsd.prog.mk>
diff --git a/usr.sbin/bsdconfig/mouse/include/messages.subr b/usr.sbin/bsdconfig/mouse/include/messages.subr
new file mode 100644
index 0000000..c6f4969
--- /dev/null
+++ b/usr.sbin/bsdconfig/mouse/include/messages.subr
@@ -0,0 +1,90 @@
+# Copyright (c) 2012 Devin Teske
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in the
+# documentation and/or other materials provided with the distribution.
+#
+# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+# SUCH DAMAGE.
+#
+# $FreeBSD$
+
+hline_press_enter_or_space="Press enter or space"
+msg_auto="Auto"
+msg_auto_desc="Bus mouse, PS/2 style mouse or PnP serial mouse"
+msg_busmouse="BusMouse"
+msg_busmouse_desc="Logitech, ATI or MS bus mouse (/dev/mse0)"
+msg_cancel="Cancel"
+msg_com1="COM1"
+msg_com1_desc="Serial mouse on COM1 (/dev/cuau0)"
+msg_com2="COM2"
+msg_com2_desc="Serial mouse on COM2 (/dev/cuau1)"
+msg_com3="COM3"
+msg_com3_desc="Serial mouse on COM3 (/dev/cuau2)"
+msg_com4="COM4"
+msg_com4_desc="Serial mouse on COM4 (/dev/cuau3)"
+msg_disable="Disable"
+msg_disable_the_mouse_daemon="Disable the mouse daemon"
+msg_enable="Enable"
+msg_exit="Exit"
+msg_exit_this_menu="Exit this menu (returning to previous)"
+msg_flags="Flags"
+msg_glidepoint="GlidePoint"
+msg_glidepoint_desc="ALPS GlidePoint pad (serial)"
+msg_hitachi="Hitachi"
+msg_hitachi_desc="Hitachi tablet (serial)"
+msg_intellimouse="IntelliMouse"
+msg_intellimouse_desc="Microsoft IntelliMouse (serial)"
+msg_logitech="Logitech"
+msg_logitech_desc="Logitech protocol (old models) (serial)"
+msg_menu_text="You can cut and paste text in the text console by running the mouse\ndaemon. Specify a port and a protocol type of your mouse and enable\nthe mouse daemon. If you don't want this feature, select 6 to disable\nthe daemon.\nOnce you've enabled the mouse daemon, you can specify \"/dev/sysmouse\"\nas your mouse device and \"SysMouse\" or \"MouseSystems\" as mouse\nprotocol when running the X configuration utility (see Configuration\nmenu)."
+msg_message="Message"
+msg_microsoft="Microsoft"
+msg_microsoft_desc="Microsoft protocol (serial)"
+msg_mm_series="MM Series"
+msg_mm_series_desc="MM Series protocol (serial)"
+msg_mouseman="MouseMan"
+msg_mouseman_desc="Logitech MouseMan/TrackMan models (serial)"
+msg_mousesystems="MouseSystems"
+msg_mousesystems_desc="MouseSystems protocol (serial)"
+msg_mouse_daemon_is_disabled="The mouse daemon is disabled."
+msg_mouse_disable="Mouse Disable"
+msg_mouse_enable="Mouse Enable"
+msg_mouse_flags="Mouse Flags"
+msg_now_move_the_mouse="Now move the mouse and see if it works.\n(Note that buttons don't have any effect for now.)\n\n Is the mouse cursor moving?\n"
+msg_ok="OK"
+msg_please_configure_your_mouse="Please configure your mouse"
+msg_please_select_protocol_and_port_first="Please select a mouse protocol and a port first."
+msg_please_specify_the_mouse_daemon_flags="Please specify the mouse daemon flags. If you would like to\nemulate 3 buttons, use -3 here.\n "
+msg_port="Port"
+msg_port_menu_text="The built-in pointing device of laptop/notebook computers is usually\na PS/2 style device."
+msg_protocol_menu_text="If your mouse is attached to the PS/2 mouse port or the bus mouse port,\nyou should always choose \"Auto\", regardless of the model and the brand\nof the mouse. All other protocol types are for serial mice and should\nnot be used with the PS/2 port mouse or the bus mouse. If you have\na serial mouse and are not sure about its protocol, you should also try\n\"Auto\". It may not work for the serial mouse if the mouse does not\nsupport the PnP standard. But, it won't hurt. Many 2-button serial mice\nare compatible with \"Microsoft\" or \"MouseMan\". 3-button serial mice\nmay be compatible with \"MouseSystems\" or \"MouseMan\". If the serial\nmouse has a wheel, it may be compatible with \"IntelliMouse\"."
+msg_ps2="PS/2"
+msg_ps2_desc="PS/2 style mouse (/dev/psm0)"
+msg_select_a_protocol_type_for_your_mouse="Select a protocol type for your mouse"
+msg_select_mouse_port="Select mouse port"
+msg_select_mouse_protocol_type="Select mouse protocol type"
+msg_select_your_mouse_port_from_the_following_menu="Select your mouse port from the following menu"
+msg_set_additional_flags="Set additional flags"
+msg_test_and_run_the_mouse_daemon="Test and run the mouse daemon"
+msg_thinkingmouse="ThinkingMouse"
+msg_thinkingmouse_desc="Kensington ThinkingMouse (serial)"
+msg_trying_to_start_the_mouse_daemon="Trying to start the mouse daemon..."
+msg_type="Type"
+msg_user_confirmation_requested="User Confirmation Requested"
+msg_value_required="Value Required"
diff --git a/usr.sbin/bsdconfig/mouse/mouse b/usr.sbin/bsdconfig/mouse/mouse
new file mode 100755
index 0000000..911ea95
--- /dev/null
+++ b/usr.sbin/bsdconfig/mouse/mouse
@@ -0,0 +1,139 @@
+#!/bin/sh
+#-
+# Copyright (c) 2012 Devin Teske
+# All Rights Reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in the
+# documentation and/or other materials provided with the distribution.
+#
+# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING BUT NOT LIMITED TO, THE
+# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+# DAMAGES (INLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+# SUCH DAMAGE.
+#
+# $FreeBSD$
+#
+############################################################ INCLUDES
+
+BSDCFG_SHARE="/usr/share/bsdconfig"
+. $BSDCFG_SHARE/common.subr || exit 1
+f_include $BSDCFG_SHARE/dialog.subr
+f_include $BSDCFG_SHARE/mustberoot.subr
+
+BSDCFG_LIBE="/usr/libexec/bsdconfig" APP_DIR="110.mouse"
+f_include_lang $BSDCFG_LIBE/$APP_DIR/include/messages.subr
+
+ipgm=$( f_index_menu_selection $BSDCFG_LIBE/$APP_DIR/INDEX "$pgm" )
+[ $? -eq $SUCCESS -a "$ipgm" ] && pgm="$ipgm"
+
+############################################################ FUNCTIONS
+
+# dialog_menu_main
+#
+# Display the dialog(1)-based application main menu.
+#
+dialog_menu_main()
+{
+ local menu_list size
+ local hline=""
+ local prompt="$msg_menu_text"
+
+ menu_list="
+ 'X $msg_exit' '$msg_exit_this_menu'
+ '2 $msg_enable' '$msg_test_and_run_the_mouse_daemon'
+ '3 $msg_type' '$msg_select_mouse_protocol_type'
+ '4 $msg_port' '$msg_select_mouse_port'
+ '5 $msg_flags' '$msg_set_additional_flags'
+ '6 $msg_disable' '$msg_disable_the_mouse_daemon'
+ " # END-QUOTE
+
+ size=$( eval f_dialog_menu_size \
+ \"\$DIALOG_TITLE\" \
+ \"\$DIALOG_BACKTITLE\" \
+ \"\$prompt\" \
+ \"\$hline\" \
+ $menu_list )
+
+ local dialog_menu
+ dialog_menu=$( eval $DIALOG \
+ --clear --title \"\$DIALOG_TITLE\" \
+ --backtitle \"\$DIALOG_BACKTITLE\" \
+ --hline \"\$hline\" \
+ --ok-label \"\$msg_ok\" \
+ --cancel-label \"\$msg_cancel\" \
+ --menu \"\$prompt\" $size \
+ $menu_list \
+ 2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD
+ )
+ local retval=$?
+ setvar DIALOG_MENU_$$ "$dialog_menu"
+ return $retval
+}
+
+############################################################ MAIN
+
+# Incorporate rc-file if it exists
+[ -f "$HOME/.bsdconfigrc" ] && f_include "$HOME/.bsdconfigrc"
+
+#
+# Process command-line arguments
+#
+while getopts hSX flag; do
+ case "$flag" in
+ h|\?) f_usage $BSDCFG_LIBE/$APP_DIR/USAGE "PROGRAM_NAME" "$pgm";;
+ esac
+done
+shift $(( $OPTIND - 1 ))
+
+#
+# Initialize
+#
+f_dialog_init
+f_dialog_title "$msg_please_configure_your_mouse"
+f_dialog_backtitle "${ipgm:+bsdconfig }$pgm"
+f_mustberoot_init
+
+#
+# Launch application main menu
+#
+while :; do
+ dialog_menu_main
+ retval=$?
+ mtag=$( f_dialog_menutag )
+
+ [ $retval -eq 0 ] || f_die
+
+ case "$mtag" in
+ "X $msg_exit") break ;;
+ "2 $msg_enable") # Test and run the mouse daemon
+ $BSDCFG_LIBE/$APP_DIR/enable ${USE_XDIALOG:+-X} ;;
+ "3 $msg_type") # Select mouse protocol type
+ $BSDCFG_LIBE/$APP_DIR/type ${USE_XDIALOG:+-X} ;;
+ "4 $msg_port") # Select mouse port
+ $BSDCFG_LIBE/$APP_DIR/port ${USE_XDIALOG:+-X} ;;
+ "5 $msg_flags") # Set additional flags
+ $BSDCFG_LIBE/$APP_DIR/flags ${USE_XDIALOG:+-X} ;;
+ "6 $msg_disable") # Disable the mouse daemon
+ $BSDCFG_LIBE/$APP_DIR/disable ${USE_XDIALOG:+-X} ;;
+ esac
+
+done
+
+exit $SUCCESS
+
+################################################################################
+# END
+################################################################################
diff --git a/usr.sbin/bsdconfig/mouse/port b/usr.sbin/bsdconfig/mouse/port
new file mode 100755
index 0000000..4ab54a7
--- /dev/null
+++ b/usr.sbin/bsdconfig/mouse/port
@@ -0,0 +1,147 @@
+#!/bin/sh
+#-
+# Copyright (c) 2012 Devin Teske
+# All Rights Reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in the
+# documentation and/or other materials provided with the distribution.
+#
+# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING BUT NOT LIMITED TO, THE
+# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+# DAMAGES (INLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+# SUCH DAMAGE.
+#
+# $FreeBSD$
+#
+############################################################ INCLUDES
+
+BSDCFG_SHARE="/usr/share/bsdconfig"
+. $BSDCFG_SHARE/common.subr || exit 1
+f_include $BSDCFG_SHARE/dialog.subr
+f_include $BSDCFG_SHARE/mustberoot.subr
+f_include $BSDCFG_SHARE/sysrc.subr
+
+BSDCFG_LIBE="/usr/libexec/bsdconfig" APP_DIR="110.mouse"
+f_include_lang $BSDCFG_LIBE/$APP_DIR/include/messages.subr
+
+ipgm=$( f_index_menu_selection $BSDCFG_LIBE/$APP_DIR/INDEX "$pgm" )
+[ $? -eq $SUCCESS -a "$ipgm" ] && pgm="$ipgm"
+
+############################################################ FUNCTIONS
+
+# dialog_menu_main
+#
+# Display the dialog(1)-based application main menu.
+#
+dialog_menu_main()
+{
+ local menu_list size
+ local hline=""
+ local prompt="$msg_port_menu_text"
+
+ menu_list="
+ '1 $msg_ps2' '$msg_ps2_desc'
+ '2 $msg_com1' '$msg_com1_desc'
+ '3 $msg_com2' '$msg_com2_desc'
+ '4 $msg_com3' '$msg_com3_desc'
+ '5 $msg_com4' '$msg_com4_desc'
+ '6 $msg_busmouse' '$msg_busmouse_desc'
+ " # END-QUOTE
+
+ size=$( eval f_dialog_menu_size \
+ \"\$DIALOG_TITLE\" \
+ \"\$DIALOG_BACKTITLE\" \
+ \"\$prompt\" \
+ \"\$hline\" \
+ $menu_list )
+
+ local dialog_menu
+ dialog_menu=$( eval $DIALOG \
+ --clear --title \"\$DIALOG_TITLE\" \
+ --backtitle \"\$DIALOG_BACKTITLE\" \
+ --hline \"\$hline\" \
+ --ok-label \"\$msg_ok\" \
+ --cancel-label \"\$msg_cancel\" \
+ --menu \"\$prompt\" $size \
+ $menu_list \
+ 2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD
+ )
+ local retval=$?
+ setvar DIALOG_MENU_$$ "$dialog_menu"
+ return $retval
+}
+
+############################################################ MAIN
+
+# Incorporate rc-file if it exists
+[ -f "$HOME/.bsdconfigrc" ] && f_include "$HOME/.bsdconfigrc"
+
+#
+# Process command-line arguments
+#
+while getopts hSX flag; do
+ case "$flag" in
+ h|\?) f_usage $BSDCFG_LIBE/$APP_DIR/USAGE "PROGRAM_NAME" "$pgm";;
+ esac
+done
+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
+
+#
+# Launch application main menu
+#
+while :; do
+ dialog_menu_main
+ retval=$?
+ mtag=$( f_dialog_menutag )
+
+ [ $retval -eq 0 ] || f_die
+
+ case "$mtag" in
+ "1 $msg_ps2") # PS/2 style mouse (/dev/psm0)
+ f_sysrc_set moused_port "/dev/psm0" || f_die
+ break ;;
+ "2 $msg_com1") # Serial mouse on COM1 (/dev/cuau0)
+ f_sysrc_set moused_port "/dev/cuau0" || f_die
+ break ;;
+ "3 $msg_com2") # Serial mouse on COM2 (/dev/cuau1)
+ f_sysrc_set moused_port "/dev/cuau1" || f_die
+ break ;;
+ "4 $msg_com3") # Serial mouse on COM3 (/dev/cuau2)
+ f_sysrc_set moused_port "/dev/cuau2" || f_die
+ break ;;
+ "5 $msg_com4") # Serial mouse on COM4 (/dev/cuau3)
+ f_sysrc_set moused_port "/dev/cuau3" || f_die
+ break ;;
+ "6 $msg_busmouse") # Logitech, ATI or MS bus mouse (/dev/mse0)
+ f_sysrc_set moused_port "/dev/mse0" || f_die
+ break ;;
+ esac
+
+done
+
+exit $SUCCESS
+
+################################################################################
+# END
+################################################################################
diff --git a/usr.sbin/bsdconfig/mouse/type b/usr.sbin/bsdconfig/mouse/type
new file mode 100755
index 0000000..f1e88fb
--- /dev/null
+++ b/usr.sbin/bsdconfig/mouse/type
@@ -0,0 +1,163 @@
+#!/bin/sh
+#-
+# Copyright (c) 2012 Devin Teske
+# All Rights Reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in the
+# documentation and/or other materials provided with the distribution.
+#
+# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING BUT NOT LIMITED TO, THE
+# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+# DAMAGES (INLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+# SUCH DAMAGE.
+#
+# $FreeBSD$
+#
+############################################################ INCLUDES
+
+BSDCFG_SHARE="/usr/share/bsdconfig"
+. $BSDCFG_SHARE/common.subr || exit 1
+f_include $BSDCFG_SHARE/dialog.subr
+f_include $BSDCFG_SHARE/mustberoot.subr
+f_include $BSDCFG_SHARE/sysrc.subr
+
+BSDCFG_LIBE="/usr/libexec/bsdconfig" APP_DIR="110.mouse"
+f_include_lang $BSDCFG_LIBE/$APP_DIR/include/messages.subr
+
+ipgm=$( f_index_menu_selection $BSDCFG_LIBE/$APP_DIR/INDEX "$pgm" )
+[ $? -eq $SUCCESS -a "$ipgm" ] && pgm="$ipgm"
+
+############################################################ FUNCTIONS
+
+# dialog_menu_main
+#
+# Display the dialog(1)-based application main menu.
+#
+dialog_menu_main()
+{
+ local menu_list size
+ local hline=""
+ local prompt="$msg_protocol_menu_text"
+
+ menu_list="
+ '1 $msg_auto' '$msg_auto_desc'
+ '2 $msg_glidepoint' '$msg_glidepoint_desc'
+ '3 $msg_hitachi' '$msg_hitachi_desc'
+ '4 $msg_intellimouse' '$msg_intellimouse_desc'
+ '5 $msg_logitech' '$msg_logitech_desc'
+ '6 $msg_microsoft' '$msg_microsoft_desc'
+ '7 $msg_mm_series' '$msg_mm_series_desc'
+ '8 $msg_mouseman' '$msg_mouseman_desc'
+ '9 $msg_mousesystems' '$msg_mousesystems_desc'
+ 'A $msg_thinkingmouse' '$msg_thinkingmouse_desc'
+ " # END-QUOTE
+
+ size=$( eval f_dialog_menu_size \
+ \"\$DIALOG_TITLE\" \
+ \"\$DIALOG_BACKTITLE\" \
+ \"\$prompt\" \
+ \"\$hline\" \
+ $menu_list )
+
+ local dialog_menu
+ dialog_menu=$( eval $DIALOG \
+ --clear --title \"\$DIALOG_TITLE\" \
+ --backtitle \"\$DIALOG_BACKTITLE\" \
+ --hline \"\$hline\" \
+ --ok-label \"\$msg_ok\" \
+ --cancel-label \"\$msg_cancel\" \
+ --menu \"\$prompt\" $size \
+ $menu_list \
+ 2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD
+ )
+ local retval=$?
+ setvar DIALOG_MENU_$$ "$dialog_menu"
+ return $retval
+}
+
+############################################################ MAIN
+
+# Incorporate rc-file if it exists
+[ -f "$HOME/.bsdconfigrc" ] && f_include "$HOME/.bsdconfigrc"
+
+#
+# Process command-line arguments
+#
+while getopts hSX flag; do
+ case "$flag" in
+ h|\?) f_usage $BSDCFG_LIBE/$APP_DIR/USAGE "PROGRAM_NAME" "$pgm";;
+ esac
+done
+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
+
+#
+# Launch application main menu
+#
+while :; do
+ dialog_menu_main
+ retval=$?
+ mtag=$( f_dialog_menutag )
+
+ [ $retval -eq 0 ] || f_die
+
+ case "$mtag" in
+ "1 $msg_auto") # Bus mouse, PS/2 style mouse or PnP serial mouse
+ f_sysrc_set moused_type "auto" || f_die
+ break ;;
+ "2 $msg_glidepoint") # ALPS GlidePoint pad (serial)
+ f_sysrc_set moused_type "glidepoint" || f_die
+ break ;;
+ "3 $msg_hitachi") # Hitachi tablet (serial)
+ f_sysrc_set moused_type "mmhittab" || f_die
+ break ;;
+ "4 $msg_intellimouse") # Microsoft Intellimouse (serial)
+ f_sysrc_set moused_type "intellimouse" || f_die
+ break ;;
+ "5 $msg_logitech") # Logitech protocol (old models) (serial)
+ f_sysrc_set moused_type "logitech" || f_die
+ break ;;
+ "6 $msg_microsoft") # Microsoft protocol (serial)
+ f_sysrc_set moused_type "microsoft" || f_die
+ break ;;
+ "7 $msg_mm_series") # MM Series protocol (serial)
+ f_sysrc_set moused_type "mmseries" || f_die
+ break ;;
+ "8 $msg_mouseman") # Logitech MouseMan/TrackMan models (serial)
+ f_sysrc_set moused_type "mouseman" || f_die
+ break ;;
+ "9 $msg_mousesystems") # MouseSystems protocol (serial)
+ f_sysrc_set moused_type "mousesystems" || f_die
+ break ;;
+ "A $msg_thinkingmouse") # Kensignton ThinkingMouse (serial)
+ f_sysrc_set moused_type "thinkingmouse" || f_die
+ break ;;
+ esac
+
+done
+
+exit $SUCCESS
+
+################################################################################
+# END
+################################################################################
diff --git a/usr.sbin/bsdconfig/networking/INDEX b/usr.sbin/bsdconfig/networking/INDEX
new file mode 100644
index 0000000..1d23911
--- /dev/null
+++ b/usr.sbin/bsdconfig/networking/INDEX
@@ -0,0 +1,57 @@
+# Copyright (c) 2012 Ron McDowell
+# Copyright (c) 2012 Devin Teske
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in the
+# documentation and/or other materials provided with the distribution.
+#
+# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+# SUCH DAMAGE.
+#
+# $FreeBSD$
+
+#
+# Title that will be shown on the bsdconfig menu
+menu_title="Networking Management"
+#
+# a short descriptive line shown at the bottom of the bsdconfig menu.
+# keep it short because any line longer than the terminal width will
+# be truncated.
+menu_help="Setup Networking interfaces, services, etc."
+#
+# two-part variable that defines an action to take when 'keyword'
+# is passed on a bsdconfig command line. variable takes the form
+# "keyword|command" and multiple occurrences of the variable
+# (with different 'keyword's, or different 'keyword's AND 'command's)
+# are allowed. If 'command' begins with a '/' then the full
+# path to the program is needed. If 'command' begins with anything
+# else it is a path relative to the directory this INDEX file is in.
+# 'keyword' can be i18n'ed but 'command' is the name of a script.
+menu_selection="networking|networking"
+menu_selection="defaultrouter|defaultrouter"
+menu_selection="hostname|hostname"
+menu_selection="nameservers|nameservers"
+menu_selection="netdev|devices"
+#
+# Items below this line do NOT need i18n translation----------------------
+#
+# Name of the program to be run when this menu choice is selected.
+# if it begins with a '/' then the full path to the program is needed.
+# if it begins with anything else it is a path relative to the directory
+# this INDEX file is in.
+menu_program="networking"
diff --git a/usr.sbin/bsdconfig/networking/Makefile b/usr.sbin/bsdconfig/networking/Makefile
new file mode 100644
index 0000000..4b7d528
--- /dev/null
+++ b/usr.sbin/bsdconfig/networking/Makefile
@@ -0,0 +1,16 @@
+# $FreeBSD$
+
+NO_OBJ=
+
+SUBDIR= include share
+
+FILESDIR= ${LIBEXECDIR}/bsdconfig/120.networking
+FILES= INDEX USAGE
+
+SCRIPTSDIR= ${FILESDIR}
+SCRIPTS= defaultrouter devices hostname nameservers networking
+
+beforeinstall:
+ mkdir -p ${DESTDIR}${FILESDIR}
+
+.include <bsd.prog.mk>
diff --git a/usr.sbin/bsdconfig/networking/USAGE b/usr.sbin/bsdconfig/networking/USAGE
new file mode 100644
index 0000000..a4dd74c
--- /dev/null
+++ b/usr.sbin/bsdconfig/networking/USAGE
@@ -0,0 +1,33 @@
+# Copyright (c) 2006-2012 Devin Teske
+# All Rights Reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in the
+# documentation and/or other materials provided with the distribution.
+#
+# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING BUT NOT LIMITED TO, THE
+# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+# DAMAGES (INLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+# SUCH DAMAGE.
+#
+# $FreeBSD$
+
+Usage: bsdconfig @PROGRAM_NAME@ [OPTIONS]
+
+OPTIONS:
+ -h Print usage statement and exit.
+ -S Secure X11 mode (implies `-X'). As root, always prompt-for
+ and validate sudo(8) username/password before starting.
+ -X Use Xdialog(1) in place of dialog(1).
diff --git a/usr.sbin/bsdconfig/networking/defaultrouter b/usr.sbin/bsdconfig/networking/defaultrouter
new file mode 100755
index 0000000..c2375b3
--- /dev/null
+++ b/usr.sbin/bsdconfig/networking/defaultrouter
@@ -0,0 +1,73 @@
+#!/bin/sh
+#-
+# Copyright (c) 2006-2012 Devin Teske
+# All Rights Reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in the
+# documentation and/or other materials provided with the distribution.
+#
+# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING BUT NOT LIMITED TO, THE
+# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+# DAMAGES (INLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+# SUCH DAMAGE.
+#
+# $FreeBSD$
+#
+############################################################ INCLUDES
+
+BSDCFG_SHARE="/usr/share/bsdconfig"
+. $BSDCFG_SHARE/common.subr || exit 1
+f_include $BSDCFG_SHARE/dialog.subr
+f_include $BSDCFG_SHARE/mustberoot.subr
+f_include $BSDCFG_SHARE/networking/routing.subr
+
+BSDCFG_LIBE="/usr/libexec/bsdconfig" APP_DIR="120.networking"
+f_include_lang $BSDCFG_LIBE/$APP_DIR/include/messages.subr
+
+ipgm=$( f_index_menu_selection $BSDCFG_LIBE/$APP_DIR/INDEX "$pgm" )
+[ $? -eq $SUCCESS -a "$ipgm" ] && pgm="$ipgm"
+
+############################################################ MAIN
+
+# Incorporate rc-file if it exists
+[ -f "$HOME/.bsdconfigrc" ] && f_include "$HOME/.bsdconfigrc"
+
+#
+# Process command-line arguments
+#
+while getopts hSX flag; do
+ case "$flag" in
+ h|\?) f_usage $BSDCFG_LIBE/$APP_DIR/USAGE "PROGRAM_NAME" "$pgm";;
+ esac
+done
+shift $(( $OPTIND - 1 ))
+
+#
+# Initialize
+#
+f_dialog_init
+f_dialog_title "$msg_default_router"
+f_dialog_backtitle "${ipgm:+bsdconfig }$pgm"
+f_mustberoot_init
+
+#
+# Change the default router/gateway
+#
+f_dialog_input_defaultrouter
+
+################################################################################
+# END
+################################################################################
diff --git a/usr.sbin/bsdconfig/networking/devices b/usr.sbin/bsdconfig/networking/devices
new file mode 100755
index 0000000..c7c550f
--- /dev/null
+++ b/usr.sbin/bsdconfig/networking/devices
@@ -0,0 +1,158 @@
+#!/bin/sh
+#-
+# Copyright (c) 2006-2012 Devin Teske
+# All Rights Reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in the
+# documentation and/or other materials provided with the distribution.
+#
+# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING BUT NOT LIMITED TO, THE
+# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+# DAMAGES (INLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+# SUCH DAMAGE.
+#
+# $FreeBSD$
+#
+############################################################ INCLUDES
+
+BSDCFG_SHARE="/usr/share/bsdconfig"
+. $BSDCFG_SHARE/common.subr || exit 1
+f_include $BSDCFG_SHARE/dialog.subr
+f_include $BSDCFG_SHARE/mustberoot.subr
+f_include $BSDCFG_SHARE/sysrc.subr
+f_include $BSDCFG_SHARE/networking/device.subr
+f_include $BSDCFG_SHARE/networking/ipaddr.subr
+f_include $BSDCFG_SHARE/networking/media.subr
+f_include $BSDCFG_SHARE/networking/netmask.subr
+
+BSDCFG_LIBE="/usr/libexec/bsdconfig" APP_DIR="120.networking"
+f_include_lang $BSDCFG_LIBE/$APP_DIR/include/messages.subr
+
+ipgm=$( f_index_menu_selection $BSDCFG_LIBE/$APP_DIR/INDEX "$pgm" )
+[ $? -eq $SUCCESS -a "$ipgm" ] && pgm="$ipgm"
+
+############################################################ MAIN
+
+# Incorporate rc-file if it exists
+[ -f "$HOME/.bsdconfigrc" ] && f_include "$HOME/.bsdconfigrc"
+
+#
+# Process command-line options
+#
+while getopts hSX flag; do
+ case "$flag" in
+ h|\?) f_usage $BSDCFG_LIBE/$APP_DIR/USAGE "PROGRAM_NAME" "$pgm";;
+ esac
+done
+shift $(( $OPTIND - 1 ))
+
+#
+# Initialize
+#
+f_dialog_init
+f_dialog_title "$msg_networking_devices"
+f_dialog_backtitle "${ipgm:+bsdconfig }$pgm"
+f_mustberoot_init
+
+#
+# Launch application main menu
+#
+while :; do
+ f_dialog_menu_netdev
+ retval=$?
+ interface=$( f_dialog_menutag )
+
+ [ $retval -eq 0 ] || break
+
+ #
+ # dialog_menu_netdev adds an asterisk (*) to the right of the
+ # device name if the interface is active. Remove the asterisk
+ # from the device name if present.
+ #
+ case "$interface" in
+ *\*) interface="${interface%?}";;
+ esac
+
+ #
+ # Obtain initial interface settings to be configured. These will be
+ # passed to the f_dialog_menu_netdev_edit function-call below which
+ # will block until the user has either cancelled or finished editing
+ # the values.
+ #
+ # First, attempt to read stored configuration from rc.conf(5) and
+ # fallback to reading the active configuration if not configured in
+ # the rc.conf(5) file(s).
+ #
+ _ipaddr=
+ _netmask=
+ _ifconfig=$( f_sysrc_get ifconfig_$interface )
+ if [ "$_ifconfig" ]; then
+ # If DHCP get IP address/netmask later from ifconfig(8)
+ glob="[Dd][Hh][Cc][Pp]"
+ case "$_ifconfig" in
+ $glob) dhcp=1;;
+ [Ss][Yy][Nn][Cc]$glob) dhcp=1;;
+ [Nn][Oo][Ss][Yy][Nn][Cc]$glob) dhcp=1;;
+ *)
+ #
+ # Get IP address/netmask from rc.conf(5)
+ # configuration
+ #
+ dhcp=
+ eval "$( exec 2> /dev/null
+ set -- $_ifconfig
+ while [ $# -gt 0 ]; do
+ case "$1" in
+ inet)
+ shift 1
+ echo "_ipaddr='$1'"
+ ;;
+ netmask)
+ shift 1
+ echo "_netmask='$1'"
+ ;;
+ esac
+ shift 1
+ done
+ )"
+ ;;
+ esac
+ fi
+
+ #
+ # Fill in IP address/netmask from active settings if no
+ # configuration could be extrapolated from rc.conf(5)
+ #
+ [ "$_ipaddr" ] || _ipaddr=$( f_ifconfig_inet $interface )
+ [ "$_netmask" ] || _netmask=$( f_ifconfig_netmask $interface )
+
+ # Get the extra options (this always comes from rc.conf(5))
+ _options=$( f_ifconfig_options $interface )
+
+ # Block on user-configuration of the probed settings
+ f_dialog_menu_netdev_edit \
+ $interface $_ipaddr $_netmask "$_options" $dhcp
+
+ # Return to root menu if above returns success
+ [ $? -eq $SUCCESS ] && break
+
+done
+
+exit $SUCCESS
+
+################################################################################
+# END
+################################################################################
diff --git a/usr.sbin/bsdconfig/networking/hostname b/usr.sbin/bsdconfig/networking/hostname
new file mode 100755
index 0000000..32679b4
--- /dev/null
+++ b/usr.sbin/bsdconfig/networking/hostname
@@ -0,0 +1,73 @@
+#!/bin/sh
+#-
+# Copyright (c) 2006-2012 Devin Teske
+# All Rights Reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in the
+# documentation and/or other materials provided with the distribution.
+#
+# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING BUT NOT LIMITED TO, THE
+# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+# DAMAGES (INLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+# SUCH DAMAGE.
+#
+# $FreeBSD$
+#
+############################################################ INCLUDES
+
+BSDCFG_SHARE="/usr/share/bsdconfig"
+. $BSDCFG_SHARE/common.subr || exit 1
+f_include $BSDCFG_SHARE/dialog.subr
+f_include $BSDCFG_SHARE/mustberoot.subr
+f_include $BSDCFG_SHARE/networking/hostname.subr
+
+BSDCFG_LIBE="/usr/libexec/bsdconfig" APP_DIR="120.networking"
+f_include_lang $BSDCFG_LIBE/$APP_DIR/include/messages.subr
+
+ipgm=$( f_index_menu_selection $BSDCFG_LIBE/$APP_DIR/INDEX "$pgm" )
+[ $? -eq $SUCCESS -a "$ipgm" ] && pgm="$ipgm"
+
+############################################################ MAIN
+
+# Incorporate rc-file if it exists
+[ -f "$HOME/.bsdconfigrc" ] && f_include "$HOME/.bsdconfigrc"
+
+#
+# Process command-line arguments
+#
+while getopts hSX flag; do
+ case "$flag" in
+ h|\?) f_usage $BSDCFG_LIBE/$APP_DIR/USAGE "PROGRAM_NAME" "$pgm";;
+ esac
+done
+shift $(( $OPTIND - 1 ))
+
+#
+# Initialize
+#
+f_dialog_init
+f_dialog_title "$msg_hostname_domain"
+f_dialog_backtitle "${ipgm:+bsdconfig }$pgm"
+f_mustberoot_init
+
+#
+# Change the local hostname
+#
+f_dialog_input_hostname
+
+################################################################################
+# END
+################################################################################
diff --git a/usr.sbin/bsdconfig/networking/include/Makefile b/usr.sbin/bsdconfig/networking/include/Makefile
new file mode 100644
index 0000000..be6cacb
--- /dev/null
+++ b/usr.sbin/bsdconfig/networking/include/Makefile
@@ -0,0 +1,11 @@
+# $FreeBSD$
+
+NO_OBJ=
+
+FILESDIR= ${LIBEXECDIR}/bsdconfig/120.networking/include
+FILES= messages.subr tcp.hlp
+
+beforeinstall:
+ mkdir -p ${DESTDIR}${FILESDIR}
+
+.include <bsd.prog.mk>
diff --git a/usr.sbin/bsdconfig/networking/include/messages.subr b/usr.sbin/bsdconfig/networking/include/messages.subr
new file mode 100644
index 0000000..dac8e20
--- /dev/null
+++ b/usr.sbin/bsdconfig/networking/include/messages.subr
@@ -0,0 +1,100 @@
+# Copyright (c) 2012 Devin Teske
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in the
+# documentation and/or other materials provided with the distribution.
+#
+# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+# SUCH DAMAGE.
+#
+# $FreeBSD$
+
+hline_alnum_punc_tab_enter="Use alpha-numeric, punctuation, TAB or ENTER"
+hline_arrows_tab_enter="Press arrows, TAB or ENTER"
+hline_num_punc_tab_enter="Use numbers, punctuation, TAB or ENTER"
+msg_activate_default_router="Would you like to activate the new defaultrouter right now?\nIf you choose NO or press ESC, changes will be applied\nduring the next boot.\n\n Current Default Router: %s\n New Default Router: %s\n"
+msg_activate_hostname="Would you like to activate the new hostname right now?\nIf you choose NO or press ESC, changes will be applied\nduring the next boot.\n\n Current Hostname: %s\n New Hostname: %s\n\nNOTE: Your shell prompt may still reflect the original\nhostname until your next login."
+msg_activate_hostname_x11warning="WARNING! Activating the new hostname during an X11-Forwarded\n ssh(1) session will cause an X11 authentication error.\n\n Current Hostname: %s\n New Hostname: %s\n\nNOTE: Settings will become active upon reboot or if you\n relaunch this utility either locally or on the console."
+msg_add="Add"
+msg_add_nameserver="Add a new nameserver"
+msg_bring_interface_up="Would you like to bring the %s interface up right now?"
+msg_cancel="Cancel"
+msg_current_default_router="Current Default Route/Gateway: %s"
+msg_current_dhcp_status="Current DHCP status for %s: %s"
+msg_current_ipaddr="Current IP Address for %s: %s"
+msg_current_options="Current Options for %s: %s"
+msg_current_subnet="Current Subnet Mask for %s: %s"
+msg_custom="Custom (Manual)"
+msg_default_router="Default Router/Gateway"
+msg_dhcp="DHCP"
+msg_disabled="Disabled"
+msg_dns_configuration="DNS Nameserver Configuration:\nChoose Exit when finished else Cancel."
+msg_dns_nameservers="DNS nameservers"
+msg_enabled="Enabled"
+msg_exit="Exit"
+msg_hostname_domain="Hostname/Domain"
+msg_hostname_exceeds_max_length="ERROR! The hostname entered exceeds the maximum length of\n255 characters.\n\nInvalid Hostname: %s"
+msg_hostname_label_contains_invalid_chars="ERROR! One or more individual labels within the hostname\n(separated by dots) contains one or more invalid characters.\nLabels are case-insensitive and must contain only 0-9, a-z,\n or dash (though must not begin with or end with a dash).\n\nInvalid Hostname: %s"
+msg_hostname_label_exceeds_max_length="ERROR! One or more individual labels within the hostname\n(separated by dots) exceeds the maximum of 63 characters.\n\nInvalid Hostname: %s"
+msg_hostname_label_is_null="ERROR! One or more individual labels within the hostname\n(separated by dots) are null.\n\nInvalid Hostname: %s"
+msg_hostname_label_starts_or_ends_with_hyphen="ERROR! One or more individual labels within the hostname\n(separated by dots) starts or ends with a hyphen (hyphens\nare allowed, but a label cannot begin or end with a hyphen).\n\nInvalid Hostname: %s"
+msg_internal_error_nsindex_value="FATAL! dialog_input_nameserver_edit_awk: variable\nnsindex must be a whole positive integer greater-\nthan or equal-to zero.\n\nInvalid nsindex: %s"
+msg_ipaddr4="ipaddr"
+msg_ipv4_addr_octet_contains_invalid_chars="ERROR! One or more individual octets within the IP address\n(separated by dots) contains one or more invalid characters.\nOctets must contain only the characters 0-9.\n\nInvalid IP Address: %s"
+msg_ipv4_addr_octet_exceeds_max_value="ERROR! One or more individual octets within the IP address\n(separated by dots) exceeds the maximum of 255.\n\nInvalid IP Address: %s"
+msg_ipv4_addr_octet_is_null="ERROR! One or more individual octets within the IP address\n(separated by dots) are null and/or missing.\n\nInvalid IP Address: %s"
+msg_ipv4_addr_octet_missing_or_extra="ERROR! The IP address entered has either too few or too many\noctets.\n\nInvalid IP Address: %s"
+msg_ipv4_mask_field_contains_invalid_chars="ERROR! One or more individual fields within the subnet mask\n(separated by dots) contains one or more invalid characters.\n\nInvalid Subnet Mask: %s"
+msg_ipv4_mask_field_exceeds_max_value="ERROR! One or more individual fields within the subnet mask\n(separated by dots) exceeds the maximum of 255.\n\nInvalid Subnet Mask: %s"
+msg_ipv4_mask_field_invalid_value="ERROR! One or more individual fields within the subnet mask\n(separated by dots) contains one or more invalid integers.\nFields must be one of 0/128/192/224/240/248/252/254/255.\n\nInvalid Subnet Mask: %s"
+msg_ipv4_mask_field_is_null="ERROR! One or more individual fields within the subnet mask\n(separated by dots) are null and/or missing.\n\nInvalid Subnet Mask: %s"
+msg_ipv4_mask_field_missing_or_extra="ERROR! The subnet mask entered has either too few or too many\nfields.\n\nInvalid Subnet Mask: %s"
+msg_netmask="netmask"
+msg_network_configuration="%s Network Configuration:\nChoose Save/Exit when finished or Cancel."
+msg_network_interfaces="Network Interfaces"
+msg_network_management="Network Management"
+msg_networking_devices="Networking Devices"
+msg_nfs_mounts_may_cause_hang="WARNING! Changing this setting while NFS directories are\nmounted may cause the system to hang. Please exit this\nutility and dismount any/all remaining NFS-mounts before\nattempting to change this setting.\n\n%s"
+msg_no_network_interfaces="No network interfaces detected."
+msg_no_options="No options (Default)"
+msg_ok="OK"
+msg_options="options"
+msg_please_enter_default_router="Please enter the IP address of your default\nrouter/gateway. The address entered will be\napplied as the default gateway for all interfaces\nusing route(4)."
+msg_please_enter_fqhn="Please enter your fully qualified hostname (e.g. full.example.com). The\ndomain portion of the hostname will be configured in resolv.conf(5)."
+msg_please_enter_mediaopts="Please enter additional network media options to be passed to ifconfig(8) for the %s interface:"
+msg_please_enter_nameserver="Please enter the new IP address of the DNS nameserver:"
+msg_please_enter_nameserver_existing="Please enter the new IP address of the DNS nameserver\n(set to the NULL string [Ctrl-U] to remove entry):"
+msg_please_enter_new_ip_addr="Please enter the new IP address of the %s interface:"
+msg_please_enter_subnet_mask="Please enter the new network subnet mask for the %s interface:"
+msg_probing_network_interfaces="Probing network interface devices..."
+msg_removing_nameserver="Removing DNS nameserver from resolv.conf(5)..."
+msg_resolv_conf_changed_while_editing="ERROR! resolv.conf(5) has changed while editing this\nvalue. Please try again after waiting a few seconds."
+msg_resolv_conf_entry_no_longer_exists="ERROR! The entry you are trying to edit no longer\nexists in resolv.conf(5). Please try again after\nwaiting a few seconds."
+msg_return_to_previous_menu="Return to previous menu"
+msg_save_exit="Save/Exit"
+msg_saving_default_router="Saving new default router/gateway settings..."
+msg_saving_hostname="Saving new hostname/domain settings..."
+msg_saving_nameserver="Saving new DNS nameserver to resolv.conf(5)..."
+msg_saving_nameserver_existing="Editing DNS nameserver in resolv.conf(5)..."
+msg_saving_network_interface="Saving %s network interface settings..."
+msg_scanning_for_dhcp="Scanning for DHCP servers on %s interface..."
+msg_select_network_interface="Select a network interface to configure.\n\n* Interface is marked as \"active\""
+msg_supported_media_options="Below is a list of supported media options for the %s interface. Please select the options that you would like to set for the %s network interface"
+xmsg_please_enter_fqhn="Please enter your fully qualified hostname (e.g. foo.bar.com).\n The domain portion of the hostname will be configured in resolv.conf(5)."
+xmsg_please_enter_nameserver_existing="Please enter the new IP address of the DNS nameserver\n(set to the NULL string to remove entry):"
+xmsg_supported_media_options="Below is a list of supported media options for the %s interface. Please\nselect the options that you would like to set for the %s network interface"
diff --git a/usr.sbin/bsdconfig/networking/include/tcp.hlp b/usr.sbin/bsdconfig/networking/include/tcp.hlp
new file mode 100644
index 0000000..6d0ba10
--- /dev/null
+++ b/usr.sbin/bsdconfig/networking/include/tcp.hlp
@@ -0,0 +1,33 @@
+This screen allows you to set up your general network parameters
+(hostname, domain name, DNS server, etc) as well as the settings for a
+given interface (which was selected from the menu before this screen).
+
+PLIP/SLIP users - please read through to the end of this doc!
+
+The "options" field is kind of special (read: a hack :-):
+
+Any valid options to ifconfig can be specified here, so if you need
+to do something "special" to get your interface working, then here
+is the place to do it.
+
+If you're running SLIP or PLIP, you also need to use it for specifying
+the remote end of the link (simply type the foreign IP address in).
+In the specific case where you're running PLIP with a Linux host peer
+rather than a FreeBSD one, you also must add the "-link0" flag after the
+foreign address.
+
+If you're dealing with an ethernet adaptor with multiple media
+connectors (e.g. AUI, 10BT, 10B2, etc), you can use this field to
+specify which one to use. Examples of valid strings include:
+
+ "media 10base5/AUI" - Select the AUI port.
+ "media 10baseT/UTP" - Select the twisted pair port.
+ "media 10base2/BNC" - Select the BNC connector.
+ "media 100baseTX" - Select 100BaseT on a 100/10 dual adaptor.
+
+If you have a wireless interface and must specify arguments such as a
+WEP key here, you may use something like:
+
+ "wepmode on wepkey 0xFEEDFACE"
+
+When you're done with this form, select OK.
diff --git a/usr.sbin/bsdconfig/networking/nameservers b/usr.sbin/bsdconfig/networking/nameservers
new file mode 100755
index 0000000..13cdf51
--- /dev/null
+++ b/usr.sbin/bsdconfig/networking/nameservers
@@ -0,0 +1,73 @@
+#!/bin/sh
+#-
+# Copyright (c) 2006-2012 Devin Teske
+# All Rights Reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in the
+# documentation and/or other materials provided with the distribution.
+#
+# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING BUT NOT LIMITED TO, THE
+# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+# DAMAGES (INLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+# SUCH DAMAGE.
+#
+# $FreeBSD$
+#
+############################################################ INCLUDES
+
+BSDCFG_SHARE="/usr/share/bsdconfig"
+. $BSDCFG_SHARE/common.subr || exit 1
+f_include $BSDCFG_SHARE/dialog.subr
+f_include $BSDCFG_SHARE/mustberoot.subr
+f_include $BSDCFG_SHARE/networking/resolv.subr
+
+BSDCFG_LIBE="/usr/libexec/bsdconfig" APP_DIR="120.networking"
+f_include_lang $BSDCFG_LIBE/$APP_DIR/include/messages.subr
+
+ipgm=$( f_index_menu_selection $BSDCFG_LIBE/$APP_DIR/INDEX "$pgm" )
+[ $? -eq $SUCCESS -a "$ipgm" ] && pgm="$ipgm"
+
+############################################################ MAIN
+
+# Incorporate rc-file if it exists
+[ -f "$HOME/.bsdconfigrc" ] && f_include "$HOME/.bsdconfigrc"
+
+#
+# Process command-line arguments
+#
+while getopts hSX flag; do
+ case "$flag" in
+ h|\?) f_usage $BSDCFG_LIBE/$APP_DIR/USAGE "PROGRAM_NAME" "$pgm";;
+ esac
+done
+shift $(( $OPTIND - 1 ))
+
+#
+# Initialize
+#
+f_dialog_init
+f_dialog_title "$msg_dns_nameservers"
+f_dialog_backtitle "${ipgm:+bsdconfig }$pgm"
+f_mustberoot_init
+
+#
+# Change the DNS nameservers
+#
+f_dialog_menu_nameservers
+
+################################################################################
+# END
+################################################################################
diff --git a/usr.sbin/bsdconfig/networking/networking b/usr.sbin/bsdconfig/networking/networking
new file mode 100755
index 0000000..fe3ce1b
--- /dev/null
+++ b/usr.sbin/bsdconfig/networking/networking
@@ -0,0 +1,151 @@
+#!/bin/sh
+#-
+# Copyright (c) 2006-2012 Devin Teske
+# All Rights Reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in the
+# documentation and/or other materials provided with the distribution.
+#
+# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING BUT NOT LIMITED TO, THE
+# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+# DAMAGES (INLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+# SUCH DAMAGE.
+#
+# $FreeBSD$
+#
+############################################################ INCLUDES
+
+BSDCFG_SHARE="/usr/share/bsdconfig"
+. $BSDCFG_SHARE/common.subr || exit 1
+f_include $BSDCFG_SHARE/dialog.subr
+f_include $BSDCFG_SHARE/mustberoot.subr
+
+BSDCFG_LIBE="/usr/libexec/bsdconfig" APP_DIR="120.networking"
+f_include_lang $BSDCFG_LIBE/$APP_DIR/include/messages.subr
+
+ipgm=$( f_index_menu_selection $BSDCFG_LIBE/$APP_DIR/INDEX "$pgm" )
+[ $? -eq $SUCCESS -a "$ipgm" ] && pgm="$ipgm"
+
+############################################################ FUNCTIONS
+
+# dialog_menu_main
+#
+# Display the dialog(1)-based application main menu.
+#
+dialog_menu_main()
+{
+ local menu_list size
+ local hline="$hline_arrows_tab_enter"
+
+ menu_list="
+ 'X' '$msg_exit'
+ '1' '$msg_hostname_domain'
+ '2' '$msg_network_interfaces'
+ '3' '$msg_default_router'
+ '4' '$msg_dns_nameservers'
+ " # END-QUOTE
+
+ size=$( eval f_dialog_menu_size \
+ \"\$DIALOG_TITLE\" \
+ \"\$DIALOG_BACKTITLE\" \
+ \"\" \
+ \"\$hline\" \
+ $menu_list )
+
+ local dialog_menu
+ dialog_menu=$( eval $DIALOG \
+ --clear --title \"\$DIALOG_TITLE\" \
+ --backtitle \"\$DIALOG_BACKTITLE\" \
+ --hline \"\$hline\" \
+ --ok-label \"\$msg_ok\" \
+ --cancel-label \"\$msg_cancel\" \
+ --menu \"\" $size $menu_list \
+ 2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD
+ )
+ local retval=$?
+ setvar DIALOG_MENU_$$ "$dialog_menu"
+ return $retval
+}
+
+############################################################ MAIN
+
+# Incorporate rc-file if it exists
+[ -f "$HOME/.bsdconfigrc" ] && f_include "$HOME/.bsdconfigrc"
+
+#
+# Process command-line arguments
+#
+while getopts hSX flag; do
+ case "$flag" in
+ h|\?) f_usage $BSDCFG_LIBE/$APP_DIR/USAGE "PROGRAM_NAME" "$pgm";;
+ esac
+done
+shift $(( $OPTIND - 1 ))
+
+#
+# Initialize
+#
+f_dialog_init
+f_dialog_title "$msg_network_management"
+f_dialog_backtitle "${ipgm:+bsdconfig }$pgm"
+f_mustberoot_init
+
+#
+# Launch application main menu
+#
+while :; do
+ dialog_menu_main
+ retval=$?
+ mtag=$( f_dialog_menutag )
+
+ [ $retval -eq 0 ] || f_die
+
+ case "$mtag" in
+ X) # Exit
+ break
+ ;;
+
+ 1) # Hostname/Domain
+ $BSDCFG_LIBE/$APP_DIR/hostname ${USE_XDIALOG:+-X}
+ ;;
+
+ 2) # Network Interfaces
+ $BSDCFG_LIBE/$APP_DIR/devices ${USE_XDIALOG:+-X}
+
+ # Make subsequent uses of this menu faster by not performing
+ # "ifconfig up" (limiting the pain one must endure). See also
+ # `$BSDCFG_SHARE/networking/device.subr'.
+ #
+ export DIALOG_MENU_NETDEV_KICK_INTERFACES=
+ ;;
+
+ 3) # Default Router/Gateway
+ $BSDCFG_LIBE/$APP_DIR/defaultrouter ${USE_XDIALOG:+-X}
+ ;;
+
+ 4) # DNS nameservers
+ $BSDCFG_LIBE/$APP_DIR/nameservers ${USE_XDIALOG:+-X}
+ ;;
+
+ esac
+
+done
+
+exit $SUCCESS
+
+################################################################################
+# END
+################################################################################
diff --git a/usr.sbin/bsdconfig/networking/share/Makefile b/usr.sbin/bsdconfig/networking/share/Makefile
new file mode 100644
index 0000000..6bd594c
--- /dev/null
+++ b/usr.sbin/bsdconfig/networking/share/Makefile
@@ -0,0 +1,12 @@
+# $FreeBSD$
+
+NO_OBJ=
+
+FILESDIR= ${SHAREDIR}/bsdconfig/networking
+FILES= common.subr device.subr hostname.subr ipaddr.subr media.subr \
+ netmask.subr resolv.subr routing.subr
+
+beforeinstall:
+ mkdir -p ${DESTDIR}${FILESDIR}
+
+.include <bsd.prog.mk>
diff --git a/usr.sbin/bsdconfig/networking/share/common.subr b/usr.sbin/bsdconfig/networking/share/common.subr
new file mode 100644
index 0000000..e8970d0
--- /dev/null
+++ b/usr.sbin/bsdconfig/networking/share/common.subr
@@ -0,0 +1,65 @@
+if [ ! "$_NETWORKING_COMMON_SUBR" ]; then _NETWORKING_COMMON_SUBR=1
+#
+# Copyright (c) 2006-2012 Devin Teske
+# All Rights Reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in the
+# documentation and/or other materials provided with the distribution.
+#
+# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING BUT NOT LIMITED TO, THE
+# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+# DAMAGES (INLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+# SUCH DAMAGE.
+#
+# $FreeBSD$
+#
+############################################################ INCLUDES
+
+BSDCFG_SHARE="/usr/share/bsdconfig"
+. $BSDCFG_SHARE/common.subr || exit 1
+
+############################################################ FUNCTIONS
+
+# f_mounted $local_directory
+#
+# Return success if a filesystem is mounted on a particular directory.
+#
+f_mounted()
+{
+ local dir="$1"
+ [ -d "$dir" ] || return $FAILURE
+ mount | grep -Eq " on $dir \([^)]+\)$"
+}
+
+# f_jailed
+#
+# Returns true if the current process is jail(8)ed.
+#
+f_jailed()
+{
+ ! f_quietly ps 1
+}
+
+# f_nfs_mounted
+#
+# Returns true if there are any NFS mounts currently active, otherwise false.
+#
+f_nfs_mounted()
+{
+ [ "$( df -t nfs )" ]
+}
+
+fi # ! $_NETWORKING_COMMON_SUBR
diff --git a/usr.sbin/bsdconfig/networking/share/device.subr b/usr.sbin/bsdconfig/networking/share/device.subr
new file mode 100644
index 0000000..4f870af
--- /dev/null
+++ b/usr.sbin/bsdconfig/networking/share/device.subr
@@ -0,0 +1,504 @@
+if [ ! "$_NETWORKING_DEVICE_SUBR" ]; then _NETWORKING_DEVICE_SUBR=1
+#
+# Copyright (c) 2006-2012 Devin Teske
+# All Rights Reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in the
+# documentation and/or other materials provided with the distribution.
+#
+# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING BUT NOT LIMITED TO, THE
+# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+# DAMAGES (INLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+# SUCH DAMAGE.
+#
+# $FreeBSD$
+#
+############################################################ INCLUDES
+
+BSDCFG_SHARE="/usr/share/bsdconfig"
+. $BSDCFG_SHARE/common.subr || exit 1
+f_include $BSDCFG_SHARE/dialog.subr
+f_include $BSDCFG_SHARE/sysrc.subr
+f_include $BSDCFG_SHARE/networking/common.subr
+f_include $BSDCFG_SHARE/networking/ipaddr.subr
+f_include $BSDCFG_SHARE/networking/media.subr
+f_include $BSDCFG_SHARE/networking/netmask.subr
+f_include $BSDCFG_SHARE/networking/resolv.subr
+f_include $BSDCFG_SHARE/networking/routing.subr
+
+BSDCFG_LIBE="/usr/libexec/bsdconfig" APP_DIR="120.networking"
+f_include_lang $BSDCFG_LIBE/$APP_DIR/include/messages.subr
+
+TCP_HELPFILE=$BSDCFG_LIBE/$APP_DIR/include/tcp.hlp
+
+############################################################ GLOBALS
+
+#
+# Settings used while interacting with various dialog(1) menus
+#
+: ${DIALOG_MENU_NETDEV_KICK_INTERFACES=1}
+: ${DIALOG_MENU_NETDEV_SLEEP_AFTER_KICK=3}
+
+############################################################ FUNCTIONS
+
+# f_device_desc $device_name
+#
+# Print a description for a device name (eg., `fxp0').
+#
+f_device_desc()
+{
+ local device="$1" d="[1234567890]" desc=""
+
+ # Check variables
+ [ "$device" ] || return $SUCCESS
+
+ #
+ # Return sysctl MIB dev.NAME.UNIT.%desc if it exists,
+ # otherwise fall through to below static list.
+ #
+ if f_have sysctl; then
+ local devname devunit
+ devname="${device%%$d*}"
+ devunit="${device#$devname}"
+ devunit="${devunit%%[a-zA-Z_]*}"
+ sysctl -n "dev.$devname.$devunit.%desc" 2> /dev/null &&
+ return $SUCCESS
+ fi
+
+ case "$device" in
+ # Network devices
+ ae$d) desc="Attansic/Atheros L2 Fast Ethernet";;
+ age$d) desc="Attansic/Atheros L1 Gigabit Ethernet";;
+ alc$d) desc="Atheros AR8131/AR8132 PCIe Ethernet";;
+ ale$d) desc="Atheros AR8121/AR8113/AR8114 PCIe Ethernet";;
+ an$d) desc="Aironet 4500/4800 802.11 wireless adapter";;
+ ath$d) desc="Atheros IEEE 802.11 wireless adapter";;
+ aue$d) desc="ADMtek USB Ethernet adapter";;
+ axe$d) desc="ASIX Electronics USB Ethernet adapter";;
+ bce$d) desc="Broadcom NetXtreme II Gigabit Ethernet card";;
+ bfe$d) desc="Broadcom BCM440x PCI Ethernet card";;
+ bge$d) desc="Broadcom BCM570x PCI Gigabit Ethernet card";;
+ bm$d) desc="Apple BMAC Built-in Ethernet";;
+ bwn$d) desc="Broadcom BCM43xx IEEE 802.11 wireless adapter";;
+ cas$d) desc="Sun Cassini/Cassini+ or NS DP83065 Saturn Ethernet";;
+ cc3i$d) desc="SDL HSSI sync serial PCI card";;
+ cue$d) desc="CATC USB Ethernet adapter";;
+ cxgb$d) desc="Chelsio T3 10Gb Ethernet card";;
+ dc$d) desc="DEC/Intel 21143 (and clones) PCI Fast Ethernet card";;
+ de$d) desc="DEC DE435 PCI NIC or other DC21040-AA based card";;
+ disc$d) desc="Software discard network interface";;
+ ed$d) desc="Novell NE1000/2000; 3C503; NE2000-compatible PCMCIA";;
+ el$d) desc="3Com 3C501 Ethernet card";;
+ em$d) desc="Intel(R) PRO/1000 Ethernet card";;
+ en$d) desc="Efficient Networks ATM PCI card";;
+ ep$d) desc="3Com 3C509 Ethernet card/3C589 PCMCIA";;
+ et$d) desc="Agere ET1310 based PCI Express Gigabit Ethernet card";;
+ ex$d) desc="Intel EtherExpress Pro/10 Ethernet card";;
+ fe$d) desc="Fujitsu MB86960A/MB86965A Ethernet card";;
+ fpa$d) desc="DEC DEFPA PCI FDDI card";;
+ fwe$d) desc="FireWire Ethernet emulation";;
+ fwip$d) desc="IP over FireWire";;
+ fxp$d) desc="Intel EtherExpress Pro/100B PCI Fast Ethernet card";;
+ gem$d) desc="Apple GMAC or Sun ERI/GEM Ethernet adapter";;
+ hme$d) desc="Sun HME (Happy Meal Ethernet) Ethernet adapter";;
+ ie$d) desc="AT&T StarLAN 10 and EN100; 3Com 3C507; NI5210";;
+ igb$d) desc="Intel(R) PRO/1000 PCI Express Gigabit Ethernet card";;
+ ipw$d) desc="Intel PRO/Wireless 2100 IEEE 802.11 adapter";;
+ iwi$d) desc="Intel PRO/Wireless 2200BG/2225BG/2915ABG adapter";;
+ iwn$d) desc="Intel Wireless WiFi Link 4965AGN IEEE 802.11n adapter";;
+ ix$d) desc="Intel Etherexpress Ethernet card";;
+ ixgb$d) desc="Intel(R) PRO/10Gb Ethernet card";;
+ ixgbe$d) desc="Intel(R) PRO/10Gb Ethernet card";;
+ jme$d) desc="JMicron JMC250 Gigabit/JMC260 Fast Ethernet";;
+ kue$d) desc="Kawasaki LSI USB Ethernet adapter";;
+ le$d) desc="AMD Am7900 LANCE or Am79C9xx PCnet Ethernet adapter";;
+ lge$d) desc="Level 1 LXT1001 Gigabit Ethernet card";;
+ lnc$d) desc="Lance/PCnet (Isolan/Novell NE2100/NE32-VL) Ethernet";;
+ lp$d) desc="Parallel Port IP (PLIP) peer connection";;
+ lo$d) desc="Loop-back (local) network interface";;
+ malo$d) desc="Marvell Libertas 88W8335 802.11 wireless adapter";;
+ msk$d) desc="Marvell/SysKonnect Yukon II Gigabit Ethernet";;
+ mxge$d) desc="Myricom Myri10GE 10Gb Ethernet card";;
+ nfe$d) desc="NVIDIA nForce MCP Ethernet";;
+ ng${d}_*|ng$d${d}_*|ng$d$d${d}_*|ng$d$d$d${d}_*|ng$d$d$d$d${d}_*)
+ desc="Vimage netgraph(4) bridged Ethernet device";;
+ nge$d) desc="NatSemi PCI Gigabit Ethernet card";;
+ nve$d) desc="NVIDIA nForce MCP Ethernet";;
+ nxge$d) desc="Neterion Xframe 10GbE Server/Storage adapter";;
+ pcn$d) desc="AMD Am79c79x PCI Ethernet card";;
+ plip$d) desc="Parallel Port IP (PLIP) peer connection";;
+ ral$d) desc="Ralink Technology IEEE 802.11 wireless adapter";;
+ ray$d) desc="Raytheon Raylink 802.11 wireless adapter";;
+ re$d) desc="RealTek 8139C+/8169/8169S/8110S PCI Ethernet adapter";;
+ rl$d) desc="RealTek 8129/8139 PCI Ethernet card";;
+ rue$d) desc="RealTek USB Ethernet card";;
+ rum$d) desc="Ralink Technology USB IEEE 802.11 wireless adapter";;
+ sf$d) desc="Adaptec AIC-6915 PCI Ethernet card";;
+ sge$d) desc="Silicon Integrated Systems SiS190/191 Ethernet";;
+ sis$d) desc="SiS 900/SiS 7016 PCI Ethernet card";;
+ sk$d) desc="SysKonnect PCI Gigabit Ethernet card";;
+ sn$d) desc="SMC/Megahertz Ethernet card";;
+ snc$d) desc="SONIC Ethernet card";;
+ sr$d) desc="SDL T1/E1 sync serial PCI card";;
+ ste$d) desc="Sundance ST201 PCI Ethernet card";;
+ stge$d) desc="Sundance/Tamarack TC9021 Gigabit Ethernet";;
+ ti$d) desc="Alteon Networks PCI Gigabit Ethernet card";;
+ tl$d) desc="Texas Instruments ThunderLAN PCI Ethernet card";;
+ tx$d) desc="SMC 9432TX Ethernet card";;
+ txp$d) desc="3Com 3cR990 Ethernet card";;
+ uath$d) desc="Atheros AR5005UG and AR5005UX USB wireless adapter";;
+ upgt$d) desc="Conexant/Intersil PrismGT USB wireless adapter";;
+ ural$d) desc="Ralink Technology RT2500USB 802.11 wireless adapter";;
+ urtw$d) desc="Realtek 8187L USB wireless adapter";;
+ vge$d) desc="VIA VT612x PCI Gigabit Ethernet card";;
+ vlan$d|vlan$d$d|vlan$d$d$d|vlan$d$d$d$d|vlan$d$d$d$d$d)
+ desc="IEEE 802.1Q VLAN network interface";;
+ vr$d) desc="VIA VT3043/VT86C100A Rhine PCI Ethernet card";;
+ vx$d) desc="3COM 3c590 / 3c595 Ethernet card";;
+ wb$d) desc="Winbond W89C840F PCI Ethernet card";;
+ wi$d) desc="Lucent WaveLAN/IEEE 802.11 wireless adapter";;
+ wpi$d) desc="Intel 3945ABG IEEE 802.11 wireless adapter";;
+ wx$d) desc="Intel Gigabit Ethernet (82452) card";;
+ xe$d) desc="Xircom/Intel EtherExpress Pro100/16 Ethernet card";;
+ xl$d) desc="3COM 3c90x / 3c90xB PCI Ethernet card";;
+ zyd$d) desc="ZyDAS ZD1211/ZD1211B USB 802.11 wireless adapter";;
+ # Unknown device
+ *) desc="<unknown network interface type>";;
+ esac
+ printf "%s\n" "$desc"
+}
+
+# f_dialog_menu_netdev
+#
+# Display a list of network devices with descriptions.
+#
+f_dialog_menu_netdev()
+{
+ #
+ # Display a message to let the user know we're working...
+ # (message will remain until we throw up the next dialog)
+ #
+ f_dialog_info "$msg_probing_network_interfaces"
+
+ #
+ # Get list of usable network interfaces
+ #
+ local d='[[:digit:]]+:'
+ local iflist="`echo "$(ifconfig -l):" | sed -E -e "
+ # Convert all spaces to colons
+ y/ /:/
+
+ # Prune unsavory interfaces
+ s/lo$d//g
+ s/ppp$d//g
+ s/sl$d//g
+ s/faith$d//g
+
+ # Convert all colons back into spaces
+ y/:/ /
+ "`"
+
+ #
+ # Optionally kick interfaces in the head to get them to accurately
+ # track the carrier status in realtime (required on FreeBSD).
+ #
+ if [ "$DIALOG_MENU_NETDEV_KICK_INTERFACES" ]; then
+ DIALOG_MENU_NETDEV_KICK_INTERFACES=
+
+ local ifn
+ for ifn in $iflist; do
+ f_quietly ifconfig $ifn up
+ done
+
+ if [ "$DIALOG_MENU_NETDEV_SLEEP_AFTER_KICK" ]; then
+ # interfaces need time to update carrier status
+ sleep $DIALOG_MENU_NETDEV_SLEEP_AFTER_KICK
+ fi
+ fi
+
+ #
+ # Mark any "active" interfaces with an asterisk (*)
+ # to the right of the device name.
+ #
+ interfaces=$(
+ for ifn in $iflist; do
+ active=$( ifconfig $ifn | awk \
+ '
+ ( $1 == "status:" ) \
+ {
+ if ( $2 == "active" ) { print 1; exit }
+ }
+ ' )
+ printf "'%s%s' '%s'\n" \
+ $ifn "${active:+*}" "$( f_device_desc $ifn )"
+ done
+ )
+ if [ ! "$interfaces" ]; then
+ f_dialog_msgbox "$msg_no_network_interfaces"
+ return $FAILURE
+ fi
+
+ local hline="$hline_arrows_tab_enter"
+
+ #
+ # Ask user to select an interface
+ #
+ local prompt size
+ prompt="$msg_select_network_interface"
+ size=$( eval f_dialog_menu_size \
+ \"\$DIALOG_TITLE\" \
+ \"\$DIALOG_BACKTITLE\" \
+ \"\$prompt\" \
+ \"\$hline\" \
+ $interfaces )
+ local dialog_menu
+ dialog_menu=$( eval $DIALOG \
+ --clear --title \"\$DIALOG_TITLE\" \
+ --backtitle \"\$DIALOG_BACKTITLE\" \
+ --hline \"\$hline\" \
+ --ok-label \"\$msg_ok\" \
+ --cancel-label \"\$msg_cancel\" \
+ --menu \"\$prompt\" $size \
+ $interfaces \
+ 2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD
+ )
+ local retval=$?
+ setvar DIALOG_MENU_$$ "$dialog_menu"
+ return $retval
+}
+
+# f_dialog_menu_netdev_edit $interface $ipaddr $netmask $options $dhcp
+#
+# Allow a user to edit network interface settings. Current values are not
+# probed but rather taken from the positional arguments.
+#
+f_dialog_menu_netdev_edit()
+{
+ local interface="$1" ipaddr="$2" netmask="$3" options="$4" dhcp="$5"
+ local prompt menu_list size
+
+ #
+ # Create a duplicate set of variables for change-tracking...
+ #
+ local ipaddr_orig="$2" \
+ netmask_orig="$3" \
+ options_orig="$4" \
+ dhcp_orig="$5"
+
+ local hline="$hline_arrows_tab_enter"
+ prompt=$( printf "$msg_network_configuration" "$interface" )
+
+ #
+ # Loop forever until the user has finished configuring the different
+ # components of the network interface.
+ #
+ # To apply the settings, we need to know each of the following:
+ # - IP Address
+ # - Network subnet mask
+ # - Additional ifconfig(8) options
+ #
+ # It is only when we have all of the above values that we can make the
+ # changes effective because all three options must be specified at-once
+ # to ifconfig(8).
+ #
+ while :; do
+ local dhcp_status="$msg_disabled"
+ [ "$dhcp" ] && dhcp_status="$msg_enabled"
+
+ #
+ # Display configuration-edit menu
+ #
+ menu_list="
+ 'X $msg_save_exit' '$msg_return_to_previous_menu'
+ '2 $msg_dhcp' '$dhcp_status'
+ '3 $msg_ipaddr4' '$ipaddr'
+ '4 $msg_netmask' '$netmask'
+ '5 $msg_options' '$options'
+ "
+ size=$( eval f_dialog_menu_size \
+ \"\$DIALOG_TITLE\" \
+ \"\$DIALOG_BACKTITLE\" \
+ \"\$prompt\" \
+ \"\$hline\" \
+ $menu_list )
+ local dialog_menu
+ dialog_menu=$( eval $DIALOG \
+ --clear --title \"\$DIALOG_TITLE\" \
+ --backtitle \"\$DIALOG_BACKTITLE\" \
+ --hline \"\$hline\" \
+ --ok-label \"\$msg_ok\" \
+ --cancel-label \"\$msg_cancel\" \
+ --help-button \
+ ${USE_XDIALOG:+--help \"\"} \
+ --menu \"\$prompt\" $size \
+ $menu_list \
+ 2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD
+ )
+
+ local retval=$?
+ setvar DIALOG_MENU_$$ "$dialog_menu"
+ local tag="$( f_dialog_menutag )"
+
+ if [ $retval -eq 2 ]; then
+ # The Help button was pressed
+ f_show_help "$TCP_HELPFILE"
+ continue
+ elif [ $retval -ne $SUCCESS ]; then
+ # "Cancel" was chosen (-1) or ESC was pressed (255)
+ return $retval
+ fi
+
+ #
+ # Call the below ``modifier functions'' whose job it is to take
+ # input from the user and assign the newly-acquired values back
+ # to the ipaddr, netmask, and options variables for us to re-
+ # read and display in the summary dialog.
+ #
+ case "$tag" in
+ X\ *) break;;
+ 2\ *) #
+ # Do not proceed if/when there are NFS-mounts currently
+ # active. If the network is changed while NFS-exported
+ # directories are mounted, the system may hang (if any
+ # NFS mounts are using that interface).
+ #
+ 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"
+ continue
+ fi
+
+ #
+ # Toggle DHCP status
+ #
+ if [ "$dhcp_status" = "$msg_enabled" ]; then
+ dhcp=
+ else
+ trap - SIGINT
+ ( # Execute within sub-shell to allow/catch Ctrl-C
+ trap 'exit $FAILURE' SIGINT
+ msg=$( printf "$msg_scanning_for_dhcp" "$interface" )
+ if [ "$USE_XDIALOG" ]; then
+ (
+ f_quietly ifconfig $interface delete
+ f_quietly dhclient $interface
+ ) |
+ f_xdialog_info "$msg"
+ else
+ f_dialog_info "$msg"
+ f_quietly ifconfig $interface delete
+ f_quietly dhclient $interface
+ fi
+ )
+ retval=$?
+ trap 'interrupt' SIGINT
+ if [ $retval -eq $SUCCESS ]; then
+ dhcp=1
+ ipaddr=$( f_ifconfig_inet $interface )
+ netmask=$( f_ifconfig_netmask $interface )
+ options=
+
+ # Fixup search/domain in resolv.conf(5)
+ hostname=$( f_sysrc_get \
+ 'hostname:-$(hostname)' )
+ f_dialog_resolv_conf_update "$hostname"
+ fi
+ fi
+ ;;
+ 3\ *) f_dialog_input_ipaddr "$interface" "$ipaddr"
+ [ $? -eq $SUCCESS ] && dhcp=;;
+ 4\ *) f_dialog_input_netmask "$interface" "$netmask"
+ [ $? -eq $SUCCESS -a "$_netmask" ] && dhcp=;;
+ 5\ *) f_dialog_menu_media_options "$interface" "$options"
+ [ $? -eq $SUCCESS ] && dhcp=;;
+ esac
+ done
+
+ #
+ # Save only if the user changed at least one feature of the interface
+ #
+ if [ "$ipaddr" != "$ipaddr_orig" -o \
+ "$netmask" != "$netmask_orig" -o \
+ "$options" != "$options_orig" -o \
+ "$dhcp" != "$dhcp_orig" ]
+ then
+ f_dialog_info "$( printf "$msg_saving_network_interface" \
+ "$interface" )"
+
+ local value=
+ if [ "$dhcp" ]; then
+ f_sysrc_delete defaultrouter
+ value=DHCP
+ else
+ value="inet $ipaddr netmask $netmask"
+ value="$value${options:+ }$options"
+ fi
+
+ f_sysrc_set ifconfig_$interface "$value"
+ fi
+
+ #
+ # Re/Apply the settings if desired
+ #
+ if [ ! "$dhcp" ]; then
+ 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" )"
+
+ local dr="$( f_sysrc_get defaultrouter )" err
+ if [ "$dr" = "NO" -o ! "$dr" ]; then
+ dr=$( f_route_get_default )
+ [ "$dr" ] && f_sysrc_set defaultrouter "$dr"
+ fi
+ #
+ # Make a backup of resolv.conf(5) before using
+ # ifconfig(8) and then restore it afterward. This
+ # allows preservation of nameservers acquired via
+ # DHCP on FreeBSD-8.x (normally lost as ifconfig(8)
+ # usage causes dhclient(8) to exit which scrubs
+ # resolv.conf(5) by-default upon termination).
+ #
+ f_quietly cp -fp "$RESOLV_CONF" "$RESOLV_CONF.$$"
+ err=$( ifconfig $interface inet $ipaddr \
+ netmask $netmask $options 2>&1 )
+ if [ $? -eq $SUCCESS ]; then
+ if [ "$dr" -a "$dr" != "NO" ]; then
+ err=$( route add default "$dr" 2>&1 )
+ [ $? -eq $SUCCESS ] || \
+ dialog_msgbox "$err"
+ fi
+ else
+ dialog_msgbox "$err"
+ fi
+ if cmp -s "$RESOLV_CONF" "$RESOLV_CONF.$$"; then
+ f_quietly rm -f "$RESOLV_CONF.$$"
+ else
+ f_quietly mv -f "$RESOLV_CONF.$$" "$RESOLV_CONF"
+ fi
+ fi
+ fi
+
+ return $SUCCESS
+}
+
+fi # ! $_NETWORKING_DEVICE_SUBR
diff --git a/usr.sbin/bsdconfig/networking/share/hostname.subr b/usr.sbin/bsdconfig/networking/share/hostname.subr
new file mode 100644
index 0000000..fed8679
--- /dev/null
+++ b/usr.sbin/bsdconfig/networking/share/hostname.subr
@@ -0,0 +1,214 @@
+if [ ! "$_NETWORKING_HOSTNAME_SUBR" ]; then _NETWORKING_HOSTNAME_SUBR=1
+#
+# Copyright (c) 2006-2012 Devin Teske
+# All Rights Reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in the
+# documentation and/or other materials provided with the distribution.
+#
+# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING BUT NOT LIMITED TO, THE
+# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+# DAMAGES (INLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+# SUCH DAMAGE.
+#
+# $FreeBSD$
+#
+############################################################ INCLUDES
+
+BSDCFG_SHARE="/usr/share/bsdconfig"
+. $BSDCFG_SHARE/common.subr || exit 1
+f_include $BSDCFG_SHARE/sysrc.subr
+f_include $BSDCFG_SHARE/dialog.subr
+f_include $BSDCFG_SHARE/networking/common.subr
+f_include $BSDCFG_SHARE/networking/resolv.subr
+
+BSDCFG_LIBE="/usr/libexec/bsdconfig" APP_DIR="120.networking"
+f_include_lang $BSDCFG_LIBE/$APP_DIR/include/messages.subr
+
+############################################################ FUNCTIONS
+
+# 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
+#
+# See http://en.wikipedia.org/wiki/Hostname for a brief overview.
+#
+# The return status for invalid hostnames is one of:
+# 255 Entire hostname exceeds the maximum length of 255 characters.
+# 63 One or more individual labels within the hostname (separated by
+# dots) exceeds the maximum of 63 characters.
+# 1 One or more individual labels within the hostname contains one
+# or more invalid characters.
+# 2 One or more individual labels within the hostname starts or
+# ends with a hyphen (hyphens are allowed, but a label cannot
+# begin or end with a hyphen).
+# 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.
+#
+f_dialog_validate_hostname()
+{
+ local fqhn="$1"
+
+ ( # Operate within a sub-shell to protect the parent environment
+
+ # Return error if the hostname exceeds 255 characters
+ [ ${#fqhn} -gt 255 ] && exit 255
+
+ IFS="." # Split on `dot'
+ for label in $fqhn; do
+
+ # Return error if the label exceeds 63 characters
+ [ ${#label} -gt 63 ] && exit 63
+
+ # Return error if the label is null
+ [ "$label" ] || exit 3
+
+ # Return error if label begins/ends with dash
+ case "$label" in
+ -*|*-) exit 2
+ esac
+
+ # Return error if the label contains any invalid chars
+ echo "$label" | grep -q '^[[:alnum:]-]*$' || exit 1
+
+ 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" )";;
+ esac
+
+ return $retval
+}
+
+# f_dialog_input_hostname
+#
+# Edits the current hostname.
+#
+f_dialog_input_hostname()
+{
+ local hostname="$( f_sysrc_get 'hostname:-$(hostname)' )"
+ local hostname_orig="$hostname" # for change-tracking
+
+ local msg
+ if [ "$USE_XDIALOG" ]; then
+ msg="$xmsg_please_enter_fqhn"
+ else
+ 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
+
+ # Taint-check the user's input
+ f_dialog_validate_hostname "$hostname" && break
+
+ done
+
+ #
+ # Save hostname only if the user changed the hostname.
+ #
+ if [ "$hostname" != "$hostname_orig" ]; then
+ f_dialog_info "$msg_saving_hostname"
+ f_sysrc_set hostname "$hostname"
+ fi
+
+ #
+ # Update resolv.conf(5) search/domain directives
+ #
+ f_dialog_resolv_conf_update "$hostname"
+
+ #
+ # Only ask to apply setting if the current hostname is different than
+ # the stored configuration (in rc.conf(5)).
+ #
+ if [ "$( hostname )" != "$( f_sysrc_get hostname )" ]; then
+ [ ! "$USE_XDIALOG" ] && dialog_clear
+
+ #
+ # If connected via ssh(1) and performing X11-Forwarding, don't
+ # allow the hostname to be changed to prevent the fatal error
+ # "X11 connection rejected because of wrong authentication."
+ #
+ if [ "$USE_XDIALOG" -a "$SSH_CONNECTION" ]; then
+ f_dialog_msgbox "$(
+ printf "$msg_activate_hostname_x11warning" \
+ "$( hostname )" "$hostname"
+ )"
+ else
+ f_dialog_yesno "$(
+ printf "$msg_activate_hostname" \
+ "$( hostname )" "$hostname" \
+ )" \
+ && hostname "$hostname"
+ fi
+ fi
+
+ return $SUCCESS
+}
+
+fi # ! $_NETWORKING_HOSTNAME_SUBR
diff --git a/usr.sbin/bsdconfig/networking/share/ipaddr.subr b/usr.sbin/bsdconfig/networking/share/ipaddr.subr
new file mode 100644
index 0000000..7e858dc
--- /dev/null
+++ b/usr.sbin/bsdconfig/networking/share/ipaddr.subr
@@ -0,0 +1,239 @@
+if [ ! "$_NETWORKING_IPADDR_SUBR" ]; then _NETWORKING_IPADDR_SUBR=1
+#
+# Copyright (c) 2006-2012 Devin Teske
+# All Rights Reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in the
+# documentation and/or other materials provided with the distribution.
+#
+# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING BUT NOT LIMITED TO, THE
+# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+# DAMAGES (INLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+# SUCH DAMAGE.
+#
+# $FreeBSD$
+#
+############################################################ INCLUDES
+
+BSDCFG_SHARE="/usr/share/bsdconfig"
+. $BSDCFG_SHARE/common.subr || exit 1
+f_include $BSDCFG_SHARE/sysrc.subr
+f_include $BSDCFG_SHARE/dialog.subr
+f_include $BSDCFG_SHARE/strings.subr
+f_include $BSDCFG_SHARE/networking/common.subr
+
+BSDCFG_LIBE="/usr/libexec/bsdconfig" APP_DIR="120.networking"
+f_include_lang $BSDCFG_LIBE/$APP_DIR/include/messages.subr
+
+############################################################ FUNCTIONS
+
+# f_ifconfig_inet $interface
+#
+# Returns the IPv4 address associated with $interface.
+#
+f_ifconfig_inet()
+{
+ local interface="$1"
+ ifconfig "$interface" 2> /dev/null | awk \
+ '
+ BEGIN { found = 0 }
+ ( $1 == "inet" ) \
+ {
+ print $2
+ found = 1
+ exit
+ }
+ END { exit ! found }
+ '
+}
+
+# f_dialog_validate_ipaddr $ipaddr
+#
+# Returns zero if the given argument (an IP address) is of the proper format.
+#
+# The return status for invalid IP address is one of:
+# 1 One or more individual octets within the IP address (separated
+# by dots) contains one or more invalid characters.
+# 2 One or more individual octets within the IP address are null
+# and/or missing.
+# 3 One or more individual octets within the IP address exceeds the
+# maximum of 255 (or 2^8, being an octet comprised of 8 bits).
+# 4 The IP address has either too few or too many octets.
+#
+# If the IP address is determined to be invalid, the appropriate error will be
+# displayed using the above dialog_msgbox function.
+#
+f_dialog_validate_ipaddr()
+{
+ local ip="$1"
+
+ ( # Operate within a sub-shell to protect the parent environment
+
+ # Track number of octets for error checking
+ noctets=0
+
+ IFS="." # Split on `dot'
+ for octet in $ip; do
+
+ # Return error if the octet is null
+ [ "$octet" ] || exit 2
+
+ # Return error if not a whole integer
+ f_isinteger "$octet" || exit 1
+
+ # Return error if not a positive integer
+ [ $octet -ge 0 ] || exit 1
+
+ # Return error if the octet exceeds 255
+ [ $octet -gt 255 ] && exit 3
+
+ noctets=$(( $noctets + 1 ))
+
+ done
+
+ [ $noctets -eq 4 ] || exit 4
+ )
+
+ #
+ # Produce an appropriate error message if necessary.
+ #
+ local retval=$?
+ case $retval 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" )";;
+ esac
+
+ return $retval
+}
+
+# f_dialog_input_ipaddr $interface $ipaddr
+#
+# Allows the user to edit a given IP address. If the user does not cancel or
+# press ESC, the $ipaddr environment variable will hold the newly-configured
+# value upon return.
+#
+# Optionally, the user can enter the format "IP_ADDRESS/NBITS" to set the
+# netmask at the same time as the IP address. If such a format is entered by
+# the user, the $netmask environment variable will hold the newly-configured
+# netmask upon return.
+#
+f_dialog_input_ipaddr()
+{
+ local interface="$1" _ipaddr="$2" _input
+
+ #
+ # Return with-error when there are NFS-mounts currently active. If the
+ # IP address is changed while NFS-exported directories are mounted, the
+ # system may hang (if any NFS mounts are using that interface).
+ #
+ 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"
+ 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.
+ #
+ 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
+ #
+ [ "$_ipaddr" = "$_input" ] && return $FAILURE
+ [ $retval -eq $SUCCESS ] || return $retval
+
+ # Return success if NULL value was entered
+ [ "$_input" ] || return $SUCCESS
+
+ # Take only the first "word" of the user's input
+ _ipaddr="$_input"
+ _ipaddr="${_ipaddr%%[$IFS]*}"
+
+ # Taint-check the user's input
+ f_dialog_validate_ipaddr "${_ipaddr%%/*}" && break
+ done
+
+ #
+ # Support the syntax: IP_ADDRESS/NBITS
+ #
+ local _netmask=""
+ case "$_ipaddr" in
+ */*)
+ local nbits="${_ipaddr#*/}" n=0
+ _ipaddr="${_ipaddr%%/*}"
+
+ #
+ # Taint-check $nbits to be (a) a positive whole-integer,
+ # and (b) to be less than or equal to 32. Otherwise, set
+ # $n so that the below loop never executes.
+ #
+ ( f_isinteger "$nbits" && [ $nbits -ge 0 -a $nbits -le 32 ] ) \
+ || n=4
+
+ while [ $n -lt 4 ]; do
+ _netmask="$_netmask${_netmask:+.}$((
+ (65280 >> ($nbits - 8 * $n) & 255)
+ * ((8*$n) < $nbits & $nbits <= (8*($n+1)))
+ + 255 * ($nbits > (8*($n+1)))
+ ))"
+ n=$(( $n + 1 ))
+ done
+ ;;
+ esac
+
+ ipaddr="$_ipaddr"
+ [ "$_netmask" ] && netmask="$_netmask"
+
+ return $SUCCESS
+}
+
+fi # ! $_NETWORKING_IPADDR_SUBR
diff --git a/usr.sbin/bsdconfig/networking/share/media.subr b/usr.sbin/bsdconfig/networking/share/media.subr
new file mode 100644
index 0000000..e7da98a
--- /dev/null
+++ b/usr.sbin/bsdconfig/networking/share/media.subr
@@ -0,0 +1,241 @@
+if [ ! "$_NETWORKING_MEDIA_SUBR" ]; then _NETWORKING_MEDIA_SUBR=1
+#
+# Copyright (c) 2006-2012 Devin Teske
+# All Rights Reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in the
+# documentation and/or other materials provided with the distribution.
+#
+# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING BUT NOT LIMITED TO, THE
+# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+# DAMAGES (INLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+# SUCH DAMAGE.
+#
+# $FreeBSD$
+#
+############################################################ INCLUDES
+
+BSDCFG_SHARE="/usr/share/bsdconfig"
+. $BSDCFG_SHARE/common.subr || exit 1
+f_include $BSDCFG_SHARE/dialog.subr
+f_include $BSDCFG_SHARE/strings.subr
+f_include $BSDCFG_SHARE/sysrc.subr
+f_include $BSDCFG_SHARE/networking/common.subr
+
+BSDCFG_LIBE="/usr/libexec/bsdconfig" APP_DIR="120.networking"
+f_include_lang $BSDCFG_LIBE/$APP_DIR/include/messages.subr
+
+############################################################ FUNCTIONS
+
+# f_ifconfig_options $interface
+#
+# Returns any/all extra ifconfig(8) parameters associated with $interface.
+#
+f_ifconfig_options()
+{
+ local interface="$1"
+ [ "$interface" ] || return $SUCCESS
+
+ #
+ # Loop over the options, removing what we don't want
+ #
+ (
+ set -- $( f_sysrc_get ifconfig_$interface )
+
+ #
+ # Return if the interface is configured for DHCP
+ #
+ glob="[Dd][Hh][Cc][Pp]"
+ case "$*" in
+ $glob|[Ss][Yy][Nn][Cc]$glob|[Nn][Oo][Ss][Yy][Nn][Cc]$glob)
+ exit $SUCCESS
+ esac
+
+ output=
+ while [ $# -gt 0 ]; do
+ case "$1" in
+ inet|netmask) shift 1;;
+ *) output="$output${output:+ }$1"
+ esac
+ shift 1
+ done
+ echo "$output"
+ )
+}
+
+# f_ifconfig_media $interface
+#
+# Returns list of supported media for $interface.
+#
+f_ifconfig_media()
+{
+ local interface="$1"
+ ifconfig -m "$interface" 2> /dev/null | awk \
+ '
+ BEGIN { media_found = 0 }
+ {
+ if ( media_found == 1 ) { print; next }
+ }
+ ( $1 $2 == "supported" "media:" ) \
+ {
+ media_found = 1
+ next
+ }
+ END { exit ! media_found }
+ '
+}
+
+# f_dialog_input_options $interface
+#
+# Input custom interface options.
+#
+f_dialog_input_options()
+{
+ local interface="$1"
+
+ #
+ # Return with-error when there are NFS-mounts currently active. If the
+ # options are changed while NFS-exported directories are mounted,
+ # the system may hang (if any NFS mounts are using that interface).
+ #
+ 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"
+ return $FAILURE
+ fi
+
+ local msg="$( printf "$msg_please_enter_mediaopts" "$interface" )"
+ local hline="$hline_alnum_punc_tab_enter"
+
+ local dialog_inputbox
+ dialog_inputbox=$( $DIALOG \
+ --title "$DIALOG_TITLE" \
+ --backtitle "$DIALOG_BACKTITLE" \
+ --hline "$hline" \
+ --ok-label "$msg_ok" \
+ --cancel-label "$msg_cancel" \
+ --inputbox "$msg" 9 70 \
+ "$options" \
+ 2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD
+ )
+
+ local retval=$?
+ setvar DIALOG_INPUTBOX_$$ "$dialog_inputbox"
+ local _options="$( f_dialog_inputstr )"
+
+ [ $retval -eq $SUCCESS ] && options="$_options"
+
+ return $retval
+}
+
+# f_dialog_menu_media_options $interface
+#
+# Display a menu of additional media options for the given network interface.
+#
+f_dialog_menu_media_options()
+{
+ local interface="$1" _options="$2"
+ #
+ # Not all network interfaces support additional media options, but
+ # when available we should prompt the user to select from a list
+ # of available options (or none, as is the first/default option).
+ #
+
+ #
+ # Return with-error when there are NFS-mounts currently active. If the
+ # media options are changed while NFS-exported directories are mounted,
+ # the system may hang (if any NFS mounts are using that interface).
+ #
+ 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"
+ return $FAILURE
+ fi
+
+ #
+ # Build list of additional media options
+ #
+ local opt_none="$msg_no_options"
+ local opt_cust="$msg_custom"
+ local supported_media="$(
+ f_ifconfig_media $interface | \
+ ( index=1
+
+ echo "'$( f_substr "$DIALOG_MENU_TAGS" $index 1 )'"
+ echo "'$opt_none'"
+ index=$(( $index + 1 ))
+
+ echo "'$( f_substr "$DIALOG_MENU_TAGS" $index 1 )'"
+ echo "'$opt_cust'"
+ index=$(( $index + 1 ))
+
+ while read media_options; do
+ [ $index -lt ${#DIALOG_MENU_TAGS} ] || break
+ echo "'$( f_substr "$DIALOG_MENU_TAGS" $index 1 )'"
+ echo "'$media_options'"
+ index=$(( $index + 1 ))
+ done
+ )
+ )"
+
+ local msg
+ if [ "$USE_XDIALOG" ]; then
+ msg=$( printf "$xmsg_supported_media_options" \
+ "$interface" "$interface" )
+ else
+ msg=$( printf "$msg_supported_media_options" \
+ "$interface" "$interface" )
+ fi
+
+ local hline="$hline_arrows_tab_enter"
+
+ local dialog_menu
+ dialog_menu=$( eval $DIALOG \
+ --clear --title \"\$DIALOG_TITLE\" \
+ --backtitle \"\$DIALOG_BACKTITLE\" \
+ --hline \"\$hline\" \
+ --ok-label \"\$msg_ok\" \
+ --cancel-label \"\$msg_cancel\" \
+ --menu \"\$msg\" 21 60 12 \
+ $supported_media \
+ 2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD
+ )
+
+ local retval=$?
+ setvar DIALOG_MENU_$$ "$dialog_menu"
+ if [ $retval -eq $SUCCESS ]; then
+ local tag="$( f_dialog_menutag )"
+ options=$( eval f_dialog_menutag2item \"\$tag\" \
+ $supported_media )
+ [ "$options" = "$opt_none" ] && options=
+
+ if [ "$options" = "$opt_cust" ]; then
+ options="$_options"
+ f_dialog_input_options "$interface"
+ retval=$?
+ fi
+ fi
+
+ return $retval
+}
+
+fi # ! $_NETWORKING_MEDIA_SUBR
diff --git a/usr.sbin/bsdconfig/networking/share/netmask.subr b/usr.sbin/bsdconfig/networking/share/netmask.subr
new file mode 100644
index 0000000..2f2b378
--- /dev/null
+++ b/usr.sbin/bsdconfig/networking/share/netmask.subr
@@ -0,0 +1,218 @@
+if [ ! "$_NETWORKING_NETMASK_SUBR" ]; then _NETWORKING_NETMASK_SUBR=1
+#
+# Copyright (c) 2006-2012 Devin Teske
+# All Rights Reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in the
+# documentation and/or other materials provided with the distribution.
+#
+# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING BUT NOT LIMITED TO, THE
+# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+# DAMAGES (INLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+# SUCH DAMAGE.
+#
+# $FreeBSD$
+#
+############################################################ INCLUDES
+
+BSDCFG_SHARE="/usr/share/bsdconfig"
+. $BSDCFG_SHARE/common.subr || exit 1
+f_include $BSDCFG_SHARE/dialog.subr
+f_include $BSDCFG_SHARE/strings.subr
+f_include $BSDCFG_SHARE/networking/common.subr
+
+BSDCFG_LIBE="/usr/libexec/bsdconfig" APP_DIR="120.networking"
+f_include_lang $BSDCFG_LIBE/$APP_DIR/include/messages.subr
+
+############################################################ FUNCTIONS
+
+# f_ifconfig_netmask $interface
+#
+# Returns the IPv4 subnet mask associated with $interface.
+#
+f_ifconfig_netmask()
+{
+ local interface="$1" octets
+ octets=$( ifconfig "$interface" 2> /dev/null | awk \
+ '
+ BEGIN { found = 0 }
+ ( $1 == "inet" ) \
+ {
+ printf "%s %s %s %s\n",
+ substr($4,3,2),
+ substr($4,5,2),
+ substr($4,7,2),
+ substr($4,9,2)
+ found = 1
+ exit
+ }
+ END { exit ! found }
+ ' ) || return $FAILURE
+
+ local octet netmask=
+ for octet in $octets; do
+ netmask="$netmask${netmask:+.}$( printf "%u" "0x$octet" )"
+ done
+ echo $netmask
+}
+
+# f_dialog_validate_netmask $netmask
+#
+# Returns zero if the given argument (a subnet mask) is of the proper format.
+#
+# The return status for invalid IP address is one of:
+# 1 One or more individual fields within the subnet mask (separated
+# by dots) contains one or more invalid characters.
+# 2 One or more individual fields within the subnet mask are null
+# and/or missing.
+# 3 One or more individual fields within the subnet mask exceeds
+# the maximum of 255 (a full 8-bit register).
+# 4 The subnet mask has either too few or too many fields.
+# 5 One or more individual fields within the subnet mask is an
+# 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()
+{
+ local mask="$1"
+
+ ( # Operate within a sub-shell to protect the parent environment
+
+ # Track number of fields for error checking
+ nfields=0
+
+ IFS="." # Split on `dot'
+ for field in $mask; do
+
+ # Return error if the field is null
+ [ "$field" ] || exit 2
+
+ # Return error if not a whole positive integer
+ f_isinteger "$field" || exit 1
+
+ # Return error if the field exceeds 255
+ [ $field -gt 255 ] && exit 3
+
+ # Return error if the field is an invalid integer
+ case "$field" in
+ 0|128|192|224|240|248|252|254|255) :;;
+ *) exit 5;;
+ esac
+
+ nfields=$(( $nfields + 1 ))
+
+ done
+
+ [ $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" )";;
+ esac
+
+ return $retval
+}
+
+# f_dialog_input_netmask $interface $netmask
+#
+# Edits the IP netmask of the given interface.
+#
+f_dialog_input_netmask()
+{
+ local interface="$1" _netmask="$2" _input
+
+ #
+ # Return with-error when there are NFS-mounts currently active. If the
+ # subnet mask is changed while NFS-exported directories are mounted,
+ # the system may hang (if any NFS mounts are using that interface).
+ #
+ 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"
+ 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.
+ #
+ 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
+ #
+ [ "$_netmask" = "$_input" ] && return $FAILURE
+ [ $retval -eq $SUCCESS ] || return $retval
+
+ # Return success if NULL value was entered
+ [ "$_input" ] || return $SUCCESS
+
+ # Take only the first "word" of the user's input
+ _netmask="$_input"
+ _netmask="${_netmask%%[$IFS]*}"
+
+ # Taint-check the user's input
+ f_dialog_validate_netmask "$_netmask" && break
+ done
+
+ netmask="$_netmask"
+}
+
+fi # ! $_NETWORKING_NETMASK_SUBR
diff --git a/usr.sbin/bsdconfig/networking/share/resolv.subr b/usr.sbin/bsdconfig/networking/share/resolv.subr
new file mode 100644
index 0000000..154748b
--- /dev/null
+++ b/usr.sbin/bsdconfig/networking/share/resolv.subr
@@ -0,0 +1,515 @@
+if [ ! "$_NETWORKING_RESOLV_SUBR" ]; then _NETWORKING_RESOLV_SUBR=1
+#
+# Copyright (c) 2006-2012 Devin Teske
+# All Rights Reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in the
+# documentation and/or other materials provided with the distribution.
+#
+# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING BUT NOT LIMITED TO, THE
+# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+# DAMAGES (INLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+# SUCH DAMAGE.
+#
+# $FreeBSD$
+#
+############################################################ INCLUDES
+
+BSDCFG_SHARE="/usr/share/bsdconfig"
+. $BSDCFG_SHARE/common.subr || exit 1
+f_include $BSDCFG_SHARE/dialog.subr
+f_include $BSDCFG_SHARE/strings.subr
+f_include $BSDCFG_SHARE/networking/common.subr
+f_include $BSDCFG_SHARE/networking/ipaddr.subr
+
+BSDCFG_LIBE="/usr/libexec/bsdconfig" APP_DIR="120.networking"
+f_include_lang $BSDCFG_LIBE/$APP_DIR/include/messages.subr
+
+############################################################ CONFIGURATION
+
+#
+# Path to resolv.conf(5).
+#
+: ${RESOLV_CONF:="/etc/resolv.conf"}
+
+#
+# When updating resolv.conf(5), should we populate the `search' directive with
+# all possible sub-domains? In example, if the domain is "sub.domain.com", when
+# the below option is set to 1, include both "sub.domain.com" and "domain.com"
+# in the `search' directive, otherwise use only "sub.domain.com".
+#
+# When enabled (set to 1), specify the minimum number of dots required for each
+# `search' domain by setting the second option below, `RESOLVER_SEARCH_NDOTS'.
+#
+: ${RESOLVER_SEARCH_DOMAINS_ALL:=1}
+: ${RESOLVER_SEARCH_NDOTS:=1}
+
+############################################################ FUNCTIONS
+
+# f_resolv_conf_domain
+#
+# Returns the domain configured in resolv.conf(5).
+#
+f_resolv_conf_domain()
+{
+ tail -r "$RESOLV_CONF" 2> /dev/null | awk \
+ '
+ BEGIN { found = 0 }
+ ( tolower($1) == "domain" ) \
+ {
+ print $2
+ found = 1
+ exit
+ }
+ END { exit ! found }
+ '
+}
+
+# f_resolv_conf_search
+#
+# Returns the search configured in resolv.conf(5).
+#
+f_resolv_conf_search()
+{
+ tail -r "$RESOLV_CONF" 2> /dev/null | awk \
+ '
+ BEGIN { found = 0 }
+ {
+ tl0 = tolower($0)
+ if ( match(tl0, /^[[:space:]]*search[[:space:]]+/) ) {
+ search = substr($0, RLENGTH + 1)
+ sub(/[[:space:]]*#.*$/, "", search)
+ gsub(/[[:space:]]+/, " ", search)
+ print search
+ found = 1
+ exit
+ }
+ }
+ END { exit ! found }
+ '
+}
+
+# f_resolv_conf_nameservers
+#
+# Returns nameserver(s) configured in resolv.conf(5).
+#
+f_resolv_conf_nameservers()
+{
+ awk \
+ '
+ BEGIN { found = 0 }
+ ( $1 == "nameserver" ) \
+ {
+ print $2
+ found = 1
+ }
+ END { exit ! found }
+ ' \
+ "$RESOLV_CONF" 2> /dev/null
+}
+
+# f_dialog_resolv_conf_update $hostname
+#
+# Updates the search/domain directives in resolv.conf(5) given a valid fully-
+# qualified hostname.
+#
+# This function is a two-parter. Below is the awk(1) portion of the function,
+# afterward is the sh(1) function which utilizes the below awk script.
+#
+f_dialog_resolv_conf_update_awk='
+# Variables that should be defined on the invocation line:
+# -v domain="domain"
+# -v search_all="0|1"
+# -v search_ndots="1+"
+#
+BEGIN {
+ domain_found = search_found = 0
+
+ if ( search_all ) {
+ search = ""
+ subdomain = domain
+ if ( search_ndots < 1 )
+ search_ndots = 1
+
+ ndots = split(subdomain, labels, ".") - 1
+ while ( ndots-- >= search_ndots ) {
+ if ( length(search) ) search = search " "
+ search = search subdomain
+ sub(/[^.]*\./, "", subdomain)
+ }
+ }
+ else search = domain
+}
+{
+ if ( domain_found && search_found ) { print; next }
+
+ tl0 = tolower($0)
+ if ( ! domain_found && \
+ match(tl0, /^[[:space:]]*domain[[:space:]]+/) ) \
+ {
+ if ( length(domain) ) {
+ printf "%s%s\n", substr($0, 0, RLENGTH), domain
+ domain_found = 1
+ }
+ }
+ else if ( ! search_found && \
+ match(tl0, /^[[:space:]]*search[[:space:]]+/) ) \
+ {
+ if ( length(search) ) {
+ printf "%s%s\n", substr($0, 0, RLENGTH), search
+ search_found = 1
+ }
+ }
+ else print
+}
+END {
+ if ( ! search_found && length(search) )
+ printf "search\t%s\n", search
+ if ( ! domain_found && length(domain) )
+ printf "domain\t%s\n", domain
+}
+'
+f_dialog_resolv_conf_update()
+{
+ local hostname="$1"
+
+ #
+ # Extrapolate the desired domain search parameter for resolv.conf(5)
+ #
+ local search ndots domain="${hostname#*.}"
+ if [ "$RESOLVER_SEARCH_DOMAINS_ALL" = "1" ]; then
+ search=""
+ ndots=$( IFS=.; set -- $domain; echo $(( $# - 1 )) )
+ while [ $ndots -ge ${RESOLVER_SEARCH_NDOTS:-1} ]; do
+ search="$search${search:+ }$domain"
+ domain="${domain#*.}"
+ ndots=$(( $ndots - 1 ))
+ done
+ domain="${hostname#*.}"
+ else
+ search="$domain"
+ fi
+
+ #
+ # Save domain/search information only if different from resolv.conf(5)
+ #
+ if [ "$domain" != "$( f_resolv_conf_domain )" -o \
+ "$search" != "$( f_resolv_conf_search )" ]
+ then
+ f_dialog_info "Saving new domain/search settings" \
+ "to resolv.conf(5)..."
+
+ #
+ # Create a new temporary file to write our resolv.conf(5)
+ # update with our new `domain' and `search' directives.
+ #
+ local tmpfile="$( mktemp -t "$pgm" )"
+ [ "$tmpfile" ] || return $FAILURE
+
+ #
+ # Fixup permissions and ownership (mktemp(1) creates the
+ # temporary file with 0600 permissions -- change the
+ # permissions and ownership to match resolv.conf(5) before
+ # we write it out and mv(1) it into place).
+ #
+ local mode="$( stat -f '%#Lp' "$RESOLV_CONF" 2> /dev/null )"
+ local owner="$( stat -f '%u:%g' "$RESOLV_CONF" 2> /dev/null )"
+ f_quietly chmod "${mode:-0644}" "$tmpfile"
+ f_quietly chown "${owner:-root:wheel}" "$tmpfile"
+
+ #
+ # Operate on resolv.conf(5), replacing only the last
+ # occurrences of `domain' and `search' directives (or add
+ # them to the top if not found), in strict-adherence to the
+ # following entry in resolver(5):
+ #
+ # The domain and search keywords are mutually exclusive.
+ # If more than one instance of these keywords is present,
+ # the last instance will override.
+ #
+ # NOTE: If RESOLVER_SEARCH_DOMAINS_ALL is set to `1' in the
+ # environment, all sub-domains will be added to the `search'
+ # directive, not just the FQDN.
+ #
+ local domain="${hostname#*.}" new_contents
+ [ "$domain" = "$hostname" ] && domain=
+ new_contents=$( tail -r "$RESOLV_CONF" 2> /dev/null )
+ new_contents=$( echo "$new_contents" | awk \
+ -v domain="$domain" \
+ -v search_all="${RESOLVER_SEARCH_DOMAINS_ALL:-1}" \
+ -v search_ndots="${RESOLVER_SEARCH_NDOTS:-1}" \
+ "$f_dialog_resolv_conf_update_awk" )
+
+ #
+ # Write the temporary file contents and move the temporary
+ # file into place.
+ #
+ echo "$new_contents" | tail -r > "$tmpfile" || return $FAILURE
+ f_quietly mv "$tmpfile" "$RESOLV_CONF"
+
+ fi
+}
+
+# f_dialog_input_nameserver [ $n $nameserver ]
+#
+# Allows the user to edit a given nameserver. The first argument is the
+# resolv.conf(5) nameserver ``instance'' integer. For example, this will be one
+# if editing the first nameserver instance, two if editing the second, three if
+# the third, ad nauseum. If this argument is zero, null, or missing, the value
+# entered by the user (if non-null) will be added to resolv.conf(5) as a new
+# `nameserver' entry. The second argument is the IPv4 address of the nameserver
+# to be edited -- this will be displayed as the initial value during the edit.
+#
+# Taint-checking is performed when editing an existing entry (when the second
+# argument is one or higher) in that the first argument must match the current
+# value of the Nth `nameserver' instance in resolv.conf(5) else an error is
+# generated discarding any/all changes.
+#
+# This function is a two-parter. Below is the awk(1) portion of the function,
+# afterward is the sh(1) function which utilizes the below awk script.
+#
+f_dialog_input_nameserver_edit_awk='
+# Variables that should be defined on the invocation line:
+# -v nsindex="1+"
+# -v old_value="..."
+# -v new_value="..."
+#
+BEGIN {
+ if ( nsindex < 1 ) exit 1
+ found = n = 0
+}
+{
+ if ( found ) { print; next }
+
+ if ( match(tolower($0), /^[[:space:]]*nameserver[[:space:]]+/)) {
+ if ( ++n == nsindex ) {
+ if ( $2 != old_value ) exit 2
+ if ( new_value != "" ) printf "%s%s\n", \
+ substr($0, 0, RLENGTH), new_value
+ found = 1
+ }
+ else print
+ }
+ else print
+}
+END { if ( ! found ) exit 3 }
+'
+f_dialog_input_nameserver()
+{
+ local index="${1:-0}" old_ns="$2" new_ns
+ local ns="$old_ns"
+
+ #
+ # Perform sanity checks
+ #
+ f_isinteger "$index" || return $FAILURE
+ [ $index -ge 0 ] || return $FAILURE
+
+ local msg
+ if [ $index -gt 0 ]; then
+ if [ "$USE_XDIALOG" ]; then
+ msg="$xmsg_please_enter_nameserver_existing"
+ else
+ msg="$msg_please_enter_nameserver_existing"
+ fi
+ else
+ 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
+
+ # Take only the first "word" of the user's input
+ new_ns="${new_ns%%[$IFS]*}"
+
+ # Taint-check the user's input
+ [ "$new_ns" ] || break
+ f_dialog_validate_ipaddr "$new_ns" && break
+
+ # Update prompt to allow user to re-edit previous entry
+ ns="$new_ns"
+
+ done
+
+ #
+ # Save only if the user changed the nameserver.
+ #
+ if [ $index -eq "0" -a "$new_ns" ]; then
+ f_dialog_info "$msg_saving_nameserver"
+ printf "nameserver\t%s\n" "$new_ns" >> "$RESOLV_CONF"
+ return $SUCCESS
+ elif [ $index -gt 0 -a "$old_ns" != "$new_ns" ]; then
+ if [ "$new_ns" ]; then
+ msg="$msg_saving_nameserver_existing"
+ else
+ msg="$msg_removing_nameserver"
+ fi
+ f_dialog_info "$msg"
+
+ #
+ # Create a new temporary file to write our new resolv.conf(5)
+ #
+ local tmpfile="$( mktemp -t "$pgm" )"
+ [ "$tmpfile" ] || return $FAILURE
+
+ #
+ # Quietly fixup permissions and ownership
+ #
+ local mode owner
+ mode=$( stat -f '%#Lp' "$RESOLV_CONF" 2> /dev/null )
+ owner=$( stat -f '%u:%g' "$RESOLV_CONF" 2> /dev/null )
+ f_quietly chmod "${mode:-0644}" "$tmpfile"
+ f_quietly chown "${owner:-root:wheel}" "$tmpfile"
+
+ #
+ # Operate on resolv.conf(5)
+ #
+ local new_contents
+ new_contents=$( awk -v nsindex="$index" \
+ -v old_value="$old_ns" \
+ -v new_value="$new_ns" \
+ "$f_dialog_input_nameserver_edit_awk" \
+ "$RESOLV_CONF" )
+
+ #
+ # Produce an appropriate error message if necessary.
+ #
+ local retval=$?
+ case $retval in
+ 1) f_die 1 "$msg_internal_error_nsindex_value" "$nsindex";;
+ 2) f_dialog_msgbox "$msg_resolv_conf_changed_while_editing"
+ return $retval;;
+ 3) f_dialog_msgbox "$msg_resolv_conf_entry_no_longer_exists"
+ return $retval;;
+ esac
+
+ #
+ # Write the temporary file contents and move the temporary
+ # file into place.
+ #
+ echo "$new_contents" > "$tmpfile" || return $FAILURE
+ f_quietly mv "$tmpfile" "$RESOLV_CONF"
+ fi
+}
+
+# f_dialog_menu_nameservers
+#
+# Edit the nameservers in resolv.conf(5).
+#
+f_dialog_menu_nameservers()
+{
+ local opt_exit="$msg_return_to_previous_menu"
+ local opt_add="$msg_add_nameserver"
+ local hline="$hline_arrows_tab_enter"
+ local prompt size
+
+ #
+ # Loop forever until the user has finished configuring nameservers
+ #
+ prompt="$msg_dns_configuration"
+ while :; do
+ #
+ # Re/Build list of nameservers
+ #
+ local nameservers="$( f_resolv_conf_nameservers )"
+ local menu_list="$(
+ index=1
+
+ echo "'X $msg_exit' '$opt_exit'"
+ index=$(( $index + 1 ))
+
+ echo "'A $msg_add' '$opt_add'"
+ index=$(( $index + 1 ))
+
+ for ns in $nameservers; do
+ [ $index -lt ${#DIALOG_MENU_TAGS} ] || break
+ tag=$( f_substr "$DIALOG_MENU_TAGS" $index 1 )
+ echo "'$tag nameserver' '$ns'"
+ index=$(( $index + 1 ))
+ done
+ )"
+
+ #
+ # Display configuration-edit menu
+ #
+ size=$( eval f_dialog_menu_size \
+ \"\$DIALOG_TITLE\" \
+ \"\$DIALOG_BACKTITLE\" \
+ \"\$prompt\" \
+ \"\$hline\" \
+ $menu_list )
+ local dialog_menu
+ dialog_menu=$( eval $DIALOG \
+ --clear --title \"\$DIALOG_TITLE\" \
+ --backtitle \"\$DIALOG_BACKTITLE\" \
+ --hline \"\$hline\" \
+ --ok-label \"\$msg_ok\" \
+ --cancel-label \"\$msg_cancel\" \
+ --menu \"\$prompt\" $size \
+ $menu_list \
+ 2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD
+ )
+
+ local retval=$?
+ setvar DIALOG_MENU_$$ "$dialog_menu"
+ local tag="$( f_dialog_menutag )" ns=""
+
+ # Return if "Cancel" was chosen (-1) or ESC was pressed (255)
+ [ $retval -eq $SUCCESS ] || return $retval
+
+ case "$tag" in
+ "X $msg_exit") break;;
+ "A $msg_add")
+ f_dialog_input_nameserver
+ ;;
+ *)
+ n=$( eval f_dialog_menutag2index \"\$tag\" $menu_list )
+ ns=$( eval f_dialog_menutag2item \"\$tag\" $menu_list )
+ f_dialog_input_nameserver $(( $n - 2 )) "$ns"
+ ;;
+ esac
+ done
+}
+
+fi # ! $_NETWORKING_RESOLV_SUBR
diff --git a/usr.sbin/bsdconfig/networking/share/routing.subr b/usr.sbin/bsdconfig/networking/share/routing.subr
new file mode 100644
index 0000000..b8ccdcd
--- /dev/null
+++ b/usr.sbin/bsdconfig/networking/share/routing.subr
@@ -0,0 +1,171 @@
+if [ ! "$_NETWORKING_ROUTING_SUBR" ]; then _NETWORKING_ROUTING_SUBR=1
+#
+# Copyright (c) 2006-2012 Devin Teske
+# All Rights Reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in the
+# documentation and/or other materials provided with the distribution.
+#
+# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING BUT NOT LIMITED TO, THE
+# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+# DAMAGES (INLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+# SUCH DAMAGE.
+#
+# $FreeBSD$
+#
+############################################################ INCLUDES
+
+BSDCFG_SHARE="/usr/share/bsdconfig"
+. $BSDCFG_SHARE/common.subr || exit 1
+f_include $BSDCFG_SHARE/sysrc.subr
+f_include $BSDCFG_SHARE/dialog.subr
+f_include $BSDCFG_SHARE/networking/common.subr
+f_include $BSDCFG_SHARE/networking/ipaddr.subr
+
+BSDCFG_LIBE="/usr/libexec/bsdconfig" APP_DIR="120.networking"
+f_include_lang $BSDCFG_LIBE/$APP_DIR/include/messages.subr
+
+############################################################ FUNCTIONS
+
+# f_route_get_default
+#
+# Returns the IP address of the currently active default router.
+#
+f_route_get_default()
+{
+ route -n get default 2> /dev/null | awk \
+ '
+ BEGIN { found = 0 }
+ ( $1 == "gateway:" ) \
+ {
+ print $2
+ found = 1
+ exit
+ }
+ END { exit ! found }
+ '
+}
+
+# f_dialog_input_defaultrouter
+#
+# Edits the default router.
+#
+f_dialog_input_defaultrouter()
+{
+ #
+ # Get the defaultrouter. When this is not configured, the default is
+ # "NO", however we don't ever want to present this default to the user
+ # in the following dialog. If the current value is "NO", then try to
+ # obtain the value from the running system using route(8).
+ #
+ # NOTE: Our `f_route_get_default' function will return NULL if the
+ # system does not have an active default router set (which is what we
+ # want).
+ #
+ local defaultrouter="$( f_sysrc_get 'defaultrouter:-NO' )"
+ local defaultrouter_orig="$defaultrouter" # for change-tracking
+ case "$defaultrouter" in
+ [Nn][Oo])
+ defaultrouter=$( f_route_get_default )
+ ;;
+ esac
+
+ #
+ # Return with-error when there are NFS-mounts currently active. If the
+ # default router/gateway is changed while NFS-exported directories are
+ # mounted, the system will hang.
+ #
+ 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"
+ 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.
+ #
+ 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
+ )
+
+ local retval=$?
+ setvar DIALOG_INPUTBOX_$$ "$dialog_inputbox"
+ defaultrouter=$( f_dialog_inputstr )
+
+ [ "$defaultrouter" ] || return $SUCCESS
+ [ $retval -eq $SUCCESS ] || return $retval
+
+ # Taint-check the user's input
+ f_dialog_validate_ipaddr "$defaultrouter" && break
+ done
+
+ #
+ # Save only if the user changed the default router/gateway.
+ #
+ if [ "$defaultrouter" != "$defaultrouter_orig" ]; then
+ f_dialog_info "$msg_saving_default_router"
+
+ # Save the default router/gateway
+ f_sysrc_set defaultrouter "$defaultrouter"
+ fi
+
+ #
+ # Only ask to apply setting if the current defaultrouter is different
+ # than the stored configuration (in rc.conf(5)).
+ #
+ if [ "$( f_route_get_default )" != "$defaultrouter" ]; then
+ f_dialog_clear
+ f_dialog_yesno "$(
+ printf "$msg_activate_default_router" \
+ "$( f_route_get_default )" "$defaultrouter"
+ )"
+
+ if [ $? -eq $SUCCESS ]; then
+ local err
+
+ # Apply the default router/gateway
+ f_quietly route delete default
+ err=$( route add default "$defaultrouter" 2>&1 )
+ if [ $? -ne $SUCCESS ]; then
+ f_dialog_msgbox "$err"
+ return $FAILURE
+ fi
+ fi
+ fi
+}
+
+fi # ! $_NETWORKING_ROUTING_SUBR
diff --git a/usr.sbin/bsdconfig/password/INDEX b/usr.sbin/bsdconfig/password/INDEX
new file mode 100644
index 0000000..224897b
--- /dev/null
+++ b/usr.sbin/bsdconfig/password/INDEX
@@ -0,0 +1,53 @@
+# Copyright (c) 2012 Ron McDowell
+# Copyright (c) 2012 Devin Teske
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in the
+# documentation and/or other materials provided with the distribution.
+#
+# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+# SUCH DAMAGE.
+#
+# $FreeBSD$
+
+#
+# Title that will be shown on the bsdconfig menu
+menu_title="Root Password"
+#
+# a short descriptive line shown at the bottom of the bsdconfig menu.
+# keep it short because any line longer than the terminal width will
+# be truncated.
+menu_help="Set the system manager's password"
+#
+# two-part variable that defines an action to take when 'keyword'
+# is passed on a bsdconfig command line. variable takes the form
+# "keyword|command" and multiple occurrences of the variable
+# (with different 'keyword's, or different 'keyword's AND 'command's)
+# are allowed. If 'command' begins with a '/' then the full
+# path to the program is needed. If 'command' begins with anything
+# else it is a path relative to the directory this INDEX file is in.
+# 'keyword' can be i18n'ed but 'command' is the name of a script.
+menu_selection="password|password"
+#
+# Items below this line do NOT need i18n translation----------------------
+#
+# Name of the program to be run when this menu choice is selected.
+# if it begins with a '/' then the full path to the program is needed.
+# if it begins with anything else it is a path relative to the directory
+# this INDEX file is in.
+menu_program="password"
diff --git a/usr.sbin/bsdconfig/password/Makefile b/usr.sbin/bsdconfig/password/Makefile
new file mode 100644
index 0000000..7330c31
--- /dev/null
+++ b/usr.sbin/bsdconfig/password/Makefile
@@ -0,0 +1,16 @@
+# $FreeBSD$
+
+NO_OBJ=
+
+SUBDIR= include share
+
+FILESDIR= ${LIBEXECDIR}/bsdconfig/040.password
+FILES= INDEX USAGE
+
+SCRIPTSDIR= ${FILESDIR}
+SCRIPTS= password
+
+beforeinstall:
+ mkdir -p ${DESTDIR}${FILESDIR}
+
+.include <bsd.prog.mk>
diff --git a/usr.sbin/bsdconfig/password/USAGE b/usr.sbin/bsdconfig/password/USAGE
new file mode 100644
index 0000000..9aa4dca
--- /dev/null
+++ b/usr.sbin/bsdconfig/password/USAGE
@@ -0,0 +1,33 @@
+# Copyright (c) 2012 Devin Teske
+# All Rights Reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in the
+# documentation and/or other materials provided with the distribution.
+#
+# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING BUT NOT LIMITED TO, THE
+# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+# DAMAGES (INLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+# SUCH DAMAGE.
+#
+# $FreeBSD$
+
+Usage: bsdconfig @PROGRAM_NAME@ [OPTIONS]
+
+OPTIONS:
+ -h Print usage statement and exit.
+ -S Secure X11 mode (implies `-X'). As root, always prompt-for
+ and validate sudo(8) username/password before starting.
+ -X Use Xdialog(1) in place of dialog(1).
diff --git a/usr.sbin/bsdconfig/password/include/Makefile b/usr.sbin/bsdconfig/password/include/Makefile
new file mode 100644
index 0000000..27ad607
--- /dev/null
+++ b/usr.sbin/bsdconfig/password/include/Makefile
@@ -0,0 +1,11 @@
+# $FreeBSD$
+
+NO_OBJ=
+
+FILESDIR= ${LIBEXECDIR}/bsdconfig/040.password/include
+FILES= messages.subr
+
+beforeinstall:
+ mkdir -p ${DESTDIR}${FILESDIR}
+
+.include <bsd.prog.mk>
diff --git a/usr.sbin/bsdconfig/password/include/messages.subr b/usr.sbin/bsdconfig/password/include/messages.subr
new file mode 100644
index 0000000..ac01ccc
--- /dev/null
+++ b/usr.sbin/bsdconfig/password/include/messages.subr
@@ -0,0 +1,35 @@
+# Copyright (c) 2012 Devin Teske
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in the
+# documentation and/or other materials provided with the distribution.
+#
+# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+# SUCH DAMAGE.
+#
+# $FreeBSD$
+
+hline_alnum_punc_tab_enter="Use alpha-numeric, punctuation, TAB or ENTER"
+msg_cancel="Cancel"
+msg_ok="OK"
+msg_password="Password"
+msg_password_changed="Password successfully changed."
+msg_password_is_empty="Password is empty."
+msg_passwords_do_not_match="Passwords do not match."
+msg_reenter_password="Re-enter Password"
+msg_root_password="Root Password"
diff --git a/usr.sbin/bsdconfig/password/password b/usr.sbin/bsdconfig/password/password
new file mode 100755
index 0000000..7a439e6
--- /dev/null
+++ b/usr.sbin/bsdconfig/password/password
@@ -0,0 +1,82 @@
+#!/bin/sh
+#-
+# Copyright (c) 2012 Devin Teske
+# All Rights Reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in the
+# documentation and/or other materials provided with the distribution.
+#
+# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING BUT NOT LIMITED TO, THE
+# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+# DAMAGES (INLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+# SUCH DAMAGE.
+#
+# $FreeBSD$
+#
+############################################################ INCLUDES
+
+BSDCFG_SHARE="/usr/share/bsdconfig"
+. $BSDCFG_SHARE/common.subr || exit 1
+f_include $BSDCFG_SHARE/dialog.subr
+f_include $BSDCFG_SHARE/mustberoot.subr
+f_include $BSDCFG_SHARE/password/password.subr
+
+BSDCFG_LIBE="/usr/libexec/bsdconfig" APP_DIR="040.password"
+
+ipgm=$( f_index_menu_selection $BSDCFG_LIBE/$APP_DIR/INDEX "$pgm" )
+[ $? -eq $SUCCESS -a "$ipgm" ] && pgm="$ipgm"
+
+############################################################ CONFIGURATION
+
+#
+# Default login of system manager
+#
+USER_ROOT=root
+
+############################################################ MAIN
+
+# Incorporate rc-file if it exists
+[ -f "$HOME/.bsdconfigrc" ] && f_include "$HOME/.bsdconfigrc"
+
+#
+# Process command-line arguments
+#
+while getopts hSX flag; do
+ case "$flag" in
+ h|\?) f_usage $BSDCFG_LIBE/$APP_DIR/USAGE "PROGRAM_NAME" "$pgm";;
+ esac
+done
+shift $(( $OPTIND - 1 ))
+
+#
+# Initialize
+#
+f_dialog_init
+f_dialog_title "$msg_root_password"
+f_dialog_backtitle "${ipgm:+bsdconfig }$pgm"
+f_mustberoot_init
+
+if f_dialog_input_password; then
+ err=$( echo "$pw_password" | pw usermod $USER_ROOT -h 0 2>&1 ) ||
+ f_die $? "%s" "$err"
+ f_show_msg "$msg_password_changed"
+fi
+
+return $SUCCESS
+
+################################################################################
+# END
+################################################################################
diff --git a/usr.sbin/bsdconfig/password/share/Makefile b/usr.sbin/bsdconfig/password/share/Makefile
new file mode 100644
index 0000000..ceba510
--- /dev/null
+++ b/usr.sbin/bsdconfig/password/share/Makefile
@@ -0,0 +1,11 @@
+# $FreeBSD$
+
+NO_OBJ=
+
+FILESDIR= ${SHAREDIR}/bsdconfig/password
+FILES= password.subr
+
+beforeinstall:
+ mkdir -p ${DESTDIR}${FILESDIR}
+
+.include <bsd.prog.mk>
diff --git a/usr.sbin/bsdconfig/password/share/password.subr b/usr.sbin/bsdconfig/password/share/password.subr
new file mode 100644
index 0000000..a0d1c50
--- /dev/null
+++ b/usr.sbin/bsdconfig/password/share/password.subr
@@ -0,0 +1,127 @@
+if [ ! "$_PASSWORD_PASSWORD_SUBR" ]; then _PASSWORD_PASSWORD_SUBR=1
+#
+# Copyright (c) 2012 Devin Teske
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in the
+# documentation and/or other materials provided with the distribution.
+#
+# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+# SUCH DAMAGE.
+#
+# $FreeBSD$
+#
+############################################################ INCLUDES
+
+BSDCFG_SHARE="/usr/share/bsdconfig"
+. $BSDCFG_SHARE/common.subr || exit 1
+f_include $BSDCFG_SHARE/dialog.subr
+
+BSDCFG_LIBE="/usr/libexec/bsdconfig" APP_DIR="040.password"
+f_include_lang $BSDCFG_LIBE/$APP_DIR/include/messages.subr
+
+############################################################ FUNCTIONS
+
+# f_dialog_input_password
+#
+# Prompt the user to enter a password (twice). If the user does not cancel or
+# press ESC, the $pw_password environment variable will hold the password.
+#
+f_dialog_input_password()
+{
+ local hline="$hline_alnum_punc_tab_enter"
+ local msg size rmsg rsize
+
+ msg=$( printf "$msg_password" )
+ size=$( f_dialog_inputbox_size \
+ "$DIALOG_TITLE" \
+ "$DIALOG_BACKTITLE" \
+ "$msg" \
+ "" \
+ "$hline" )
+
+ rmsg=$( printf "$msg_reenter_password" )
+ rsize=$( f_dialog_inputbox_size \
+ "$DIALOG_TITLE" \
+ "$DIALOG_BACKTITLE" \
+ "$rmsg" \
+ "" \
+ "$hline" )
+
+ #
+ # Loop until the user provides taint-free/valid input
+ #
+ local retval _password1 _password2
+ 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\" \
+ --insecure \
+ --passwordbox \"\$msg\" $size \
+ 2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD
+ )
+
+ retval=$?
+ setvar DIALOG_INPUTBOX_$$ "$dialog_inputbox"
+ _password1=$( f_dialog_inputstr )
+
+ # Return if user has either pressed ESC or chosen Cancel/No
+ [ $retval -eq $SUCCESS ] || return $retval
+
+ dialog_inputbox=$( eval $DIALOG \
+ --title \"\$DIALOG_TITLE\" \
+ --backtitle \"\$DIALOG_BACKTITLE\" \
+ --hline \"\$hline\" \
+ --ok-label \"\$msg_ok\" \
+ --cancel-label \"\$msg_cancel\" \
+ --insecure \
+ --passwordbox \"\$rmsg\" $rsize \
+ 2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD
+ )
+
+ retval=$?
+ setvar DIALOG_INPUTBOX_$$ "$dialog_inputbox"
+ _password2=$( f_dialog_inputstr )
+
+ # Return if user has either pressed ESC or chosen Cancel/No
+ [ $retval -eq $SUCCESS ] || return $retval
+
+ # Check for NULL entry
+ if ! [ "$_password1" -o "$_password2" ]; then
+ f_show_msg "$msg_password_is_empty"
+ continue
+ fi
+
+ # Check for password mismatch
+ if [ "$_password1" != "$_password2" ]; then
+ f_show_msg "$msg_passwords_do_not_match"
+ continue
+ fi
+
+ pw_password="$_password1"
+ break
+ done
+
+ return $SUCCESS
+}
+
+fi # ! $_PASSWORD_PASSWORD_SUBR
diff --git a/usr.sbin/bsdconfig/security/INDEX b/usr.sbin/bsdconfig/security/INDEX
new file mode 100644
index 0000000..1a271ec
--- /dev/null
+++ b/usr.sbin/bsdconfig/security/INDEX
@@ -0,0 +1,54 @@
+# Copyright (c) 2012 Ron McDowell
+# Copyright (c) 2012 Devin Teske
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in the
+# documentation and/or other materials provided with the distribution.
+#
+# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+# SUCH DAMAGE.
+#
+# $FreeBSD$
+
+#
+# Title that will be shown on the bsdconfig menu
+menu_title="Security"
+#
+# a short descriptive line shown at the bottom of the bsdconfig menu.
+# keep it short because any line longer than the terminal width will
+# be truncated.
+menu_help="Set Security Parameters"
+#
+# two-part variable that defines an action to take when 'keyword'
+# is passed on a bsdconfig command line. variable takes the form
+# "keyword|command" and multiple occurrences of the variable
+# (with different 'keyword's, or different 'keyword's AND 'command's)
+# are allowed. If 'command' begins with a '/' then the full
+# path to the program is needed. If 'command' begins with anything
+# else it is a path relative to the directory this INDEX file is in.
+# 'keyword' can be i18n'ed but 'command' is the name of a script.
+menu_selection="security|security"
+menu_selection="kern_securelevel|kern_securelevel"
+#
+# Items below this line do NOT need i18n translation----------------------
+#
+# Name of the program to be run when this menu choice is selected.
+# if it begins with a '/' then the full path to the program is needed.
+# if it begins with anything else it is a path relative to the directory
+# this INDEX file is in.
+menu_program="security"
diff --git a/usr.sbin/bsdconfig/security/Makefile b/usr.sbin/bsdconfig/security/Makefile
new file mode 100644
index 0000000..c230973
--- /dev/null
+++ b/usr.sbin/bsdconfig/security/Makefile
@@ -0,0 +1,16 @@
+# $FreeBSD$
+
+NO_OBJ=
+
+SUBDIR= include
+
+FILESDIR= ${LIBEXECDIR}/bsdconfig/130.security
+FILES= INDEX USAGE
+
+SCRIPTSDIR= ${FILESDIR}
+SCRIPTS= kern_securelevel security
+
+beforeinstall:
+ mkdir -p ${DESTDIR}${FILESDIR}
+
+.include <bsd.prog.mk>
diff --git a/usr.sbin/bsdconfig/security/USAGE b/usr.sbin/bsdconfig/security/USAGE
new file mode 100644
index 0000000..9aa4dca
--- /dev/null
+++ b/usr.sbin/bsdconfig/security/USAGE
@@ -0,0 +1,33 @@
+# Copyright (c) 2012 Devin Teske
+# All Rights Reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in the
+# documentation and/or other materials provided with the distribution.
+#
+# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING BUT NOT LIMITED TO, THE
+# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+# DAMAGES (INLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+# SUCH DAMAGE.
+#
+# $FreeBSD$
+
+Usage: bsdconfig @PROGRAM_NAME@ [OPTIONS]
+
+OPTIONS:
+ -h Print usage statement and exit.
+ -S Secure X11 mode (implies `-X'). As root, always prompt-for
+ and validate sudo(8) username/password before starting.
+ -X Use Xdialog(1) in place of dialog(1).
diff --git a/usr.sbin/bsdconfig/security/include/Makefile b/usr.sbin/bsdconfig/security/include/Makefile
new file mode 100644
index 0000000..a94c127
--- /dev/null
+++ b/usr.sbin/bsdconfig/security/include/Makefile
@@ -0,0 +1,11 @@
+# $FreeBSD$
+
+NO_OBJ=
+
+FILESDIR= ${LIBEXECDIR}/bsdconfig/130.security/include
+FILES= messages.subr securelevel.hlp
+
+beforeinstall:
+ mkdir -p ${DESTDIR}${FILESDIR}
+
+.include <bsd.prog.mk>
diff --git a/usr.sbin/bsdconfig/security/include/messages.subr b/usr.sbin/bsdconfig/security/include/messages.subr
new file mode 100644
index 0000000..162cebd
--- /dev/null
+++ b/usr.sbin/bsdconfig/security/include/messages.subr
@@ -0,0 +1,48 @@
+# Copyright (c) 2012 Devin Teske
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in the
+# documentation and/or other materials provided with the distribution.
+#
+# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+# SUCH DAMAGE.
+#
+# $FreeBSD$
+
+hline_arrows_tab_enter="Press arrows, TAB or ENTER"
+hline_select_securelevel_to_operate_at="Select a securelevel to operate at"
+msg_cancel="Cancel"
+msg_disable_securelevels="Disable securelevels"
+msg_disabled="Disabled"
+msg_exit="Exit"
+msg_exit_this_menu="Exit this menu (returning to previous)"
+msg_highly_secure="Highly Secure"
+msg_highly_secure_mode="Highly secure mode"
+msg_menu_text="This menu allows you to configure aspects of the operating system security\npolicy. Please read the system documentation carefully before modifying\nthese settings, as they may cause service disruption if used improperly.\n\nMost settings will take affect only following a system reboot."
+msg_network_secure="Network Secure"
+msg_network_secure_mode="Network secure mode"
+msg_nfs_port="NFS port"
+msg_nfs_port_desc="Require that the NFS clients use reserved ports"
+msg_ok="OK"
+msg_secure="Secure"
+msg_secure_mode="Secure mode"
+msg_securelevel="Securelevel"
+msg_securelevel_desc="Configure securelevels for the system"
+msg_securelevels_menu_text="This menu allows you to select the securelevel your system runs with.\nWhen operating at a securelevel, certain root privileges are disabled,\nwhich may increase resistance to exploits and protect system integrity.\nIn secure mode system flags may not be overridden by the root user,\naccess to direct kernel memory is limited, and kernel modules may not\nbe changed. In highly secure mode, mounted file systems may not be\nmodified on-disk, tampering with the system clock is prohibited. In\nnetwork secure mode configuration changes to firewalling are prohibited.\n "
+msg_securelevels_menu_title="Securelevel Configuration Menu"
+msg_system_security_options_menu="System Security Options Menu"
diff --git a/usr.sbin/bsdconfig/security/include/securelevel.hlp b/usr.sbin/bsdconfig/security/include/securelevel.hlp
new file mode 100644
index 0000000..27eb1ec
--- /dev/null
+++ b/usr.sbin/bsdconfig/security/include/securelevel.hlp
@@ -0,0 +1,40 @@
+This menu allows you to configure the Securelevel mechanism in FreeBSD.
+
+Securelevels may be used to limit the privileges assigned to the
+root user in multi-user mode, which in turn may limit the effects of
+a root compromise, at the cost of reducing administrative functions.
+Refer to the security(7) and init(8) manual pages for complete details.
+
+ -1 Permanently insecure mode - always run the system in level 0
+ mode. This is the default initial value.
+
+ 0 Insecure mode - immutable and append-only flags may be turned
+ off. All devices may be read or written subject to their
+ permissions.
+
+ 1 Secure mode - the system immutable and system append-only
+ flags may not be turned off; disks for mounted file systems,
+ /dev/mem, /dev/kmem and /dev/io (if your platform has it)
+ may not be opened for writing; kernel modules (see kld(4))
+ may not be loaded or unloaded.
+
+ 2 Highly secure mode - same as secure mode, plus disks may not
+ be opened for writing (except by mount(2)) whether mounted or
+ not. This level precludes tampering with file systems by
+ unmounting them, but also inhibits running newfs(8) while the
+ system is multi-user.
+
+ In addition, kernel time changes are restricted to less than
+ or equal to one second. Attempts to change the time by more
+ than this will log the message ``Time adjustment clamped to +1
+ second''.
+
+ 3 Network secure mode - same as highly secure mode, plus IP
+ packet filter rules (see ipfw(8), ipfirewall(4) and pfctl(8))
+ cannot be changed and dummynet(4) or pf(4) configuration
+ cannot be adjusted.
+
+Securelevels must be used in combination with careful system design and
+application of protective mechanisms to prevent system configuration
+files from being modified in a way that compromises the protections of
+the securelevel variable upon reboot.
diff --git a/usr.sbin/bsdconfig/security/kern_securelevel b/usr.sbin/bsdconfig/security/kern_securelevel
new file mode 100755
index 0000000..1bb89d8
--- /dev/null
+++ b/usr.sbin/bsdconfig/security/kern_securelevel
@@ -0,0 +1,154 @@
+#!/bin/sh
+#-
+# Copyright (c) 2012 Devin Teske
+# All Rights Reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in the
+# documentation and/or other materials provided with the distribution.
+#
+# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING BUT NOT LIMITED TO, THE
+# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+# DAMAGES (INLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+# SUCH DAMAGE.
+#
+# $FreeBSD$
+#
+############################################################ INCLUDES
+
+BSDCFG_SHARE="/usr/share/bsdconfig"
+. $BSDCFG_SHARE/common.subr || exit 1
+f_include $BSDCFG_SHARE/dialog.subr
+f_include $BSDCFG_SHARE/mustberoot.subr
+f_include $BSDCFG_SHARE/sysrc.subr
+
+BSDCFG_LIBE="/usr/libexec/bsdconfig" APP_DIR="130.security"
+f_include_lang $BSDCFG_LIBE/$APP_DIR/include/messages.subr
+
+SECURELEVEL_HELPFILE=$BSDCFG_LIBE/$APP_DIR/include/securelevel.hlp
+
+ipgm=$( f_index_menu_selection $BSDCFG_LIBE/$APP_DIR/INDEX "$pgm" )
+[ $? -eq $SUCCESS -a "$ipgm" ] && pgm="$ipgm"
+
+############################################################ FUNCTIONS
+
+# dialog_menu_main
+#
+# Display the dialog(1)-based application main menu.
+#
+dialog_menu_main()
+{
+ local menu_list size
+ local hline="$hline_select_securelevel_to_operate_at"
+ local prompt="$msg_securelevels_menu_text"
+
+ menu_list="
+ 'X $msg_exit' '$msg_exit_this_menu'
+ '$msg_disabled' '$msg_disable_securelevels'
+ '$msg_secure' '$msg_secure_mode'
+ '$msg_highly_secure' '$msg_highly_secure_mode'
+ '$msg_network_secure' '$msg_network_secure_mode'
+ " # END-QUOTE
+
+ size=$( eval f_dialog_menu_size \
+ \"\$DIALOG_TITLE\" \
+ \"\$DIALOG_BACKTITLE\" \
+ \"\$prompt\" \
+ \"\$hline\" \
+ $menu_list )
+
+ local dialog_menu
+ dialog_menu=$( eval $DIALOG \
+ --clear --title \"\$DIALOG_TITLE\" \
+ --backtitle \"\$DIALOG_BACKTITLE\" \
+ --hline \"\$hline\" \
+ --ok-label \"\$msg_ok\" \
+ --cancel-label \"\$msg_cancel\" \
+ --help-button \
+ ${USE_XDIALOG:+--help \"\"} \
+ --menu \"\$prompt\" $size \
+ $menu_list \
+ 2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD
+ )
+ local retval=$?
+ setvar DIALOG_MENU_$$ "$dialog_menu"
+ return $retval
+}
+
+############################################################ MAIN
+
+# Incorporate rc-file if it exists
+[ -f "$HOME/.bsdconfigrc" ] && f_include "$HOME/.bsdconfigrc"
+
+#
+# Process command-line arguments
+#
+while getopts hSX flag; do
+ case "$flag" in
+ h|\?) f_usage $BSDCFG_LIBE/$APP_DIR/USAGE "PROGRAM_NAME" "$pgm";;
+ esac
+done
+shift $(( $OPTIND - 1 ))
+
+#
+# Initialize
+#
+f_dialog_init
+f_dialog_title "$msg_securelevels_menu_title"
+f_dialog_backtitle "${ipgm:+bsdconfig }$pgm"
+f_mustberoot_init
+
+#
+# Launch application main menu
+#
+while :; do
+ dialog_menu_main
+ retval=$?
+ mtag=$( f_dialog_menutag )
+
+ if [ $retval -eq 2 ]; then
+ # The Help button was pressed
+ f_show_help "$SECURELEVEL_HELPFILE"
+ continue
+ elif [ $retval -ne 0 ]; then
+ f_die
+ fi
+
+ break
+done
+
+case "$mtag" in
+"$msg_disabled")
+ f_sysrc_set kern_securelevel_enable "NO"
+ ;;
+"$msg_secure")
+ f_sysrc_set kern_securelevel_enable "YES"
+ f_sysrc_set kern_securelevel "1"
+ ;;
+"$msg_highly_secure")
+ f_sysrc_set kern_securelevel_enable "YES"
+ f_sysrc_set kern_securelevel "2"
+ ;;
+"$msg_network_secure")
+ f_sysrc_set kern_securelevel_enable "YES"
+ f_sysrc_set kern_securelevel "3"
+ ;;
+esac
+
+exit $SUCCESS
+
+################################################################################
+# END
+################################################################################
diff --git a/usr.sbin/bsdconfig/security/security b/usr.sbin/bsdconfig/security/security
new file mode 100755
index 0000000..3dd71c5
--- /dev/null
+++ b/usr.sbin/bsdconfig/security/security
@@ -0,0 +1,154 @@
+#!/bin/sh
+#-
+# Copyright (c) 2012 Devin Teske
+# All Rights Reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in the
+# documentation and/or other materials provided with the distribution.
+#
+# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING BUT NOT LIMITED TO, THE
+# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+# DAMAGES (INLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+# SUCH DAMAGE.
+#
+# $FreeBSD$
+#
+############################################################ INCLUDES
+
+BSDCFG_SHARE="/usr/share/bsdconfig"
+. $BSDCFG_SHARE/common.subr || exit 1
+f_include $BSDCFG_SHARE/dialog.subr
+f_include $BSDCFG_SHARE/mustberoot.subr
+f_include $BSDCFG_SHARE/sysrc.subr
+
+BSDCFG_LIBE="/usr/libexec/bsdconfig" APP_DIR="130.security"
+f_include_lang $BSDCFG_LIBE/$APP_DIR/include/messages.subr
+
+ipgm=$( f_index_menu_selection $BSDCFG_LIBE/$APP_DIR/INDEX "$pgm" )
+[ $? -eq $SUCCESS -a "$ipgm" ] && pgm="$ipgm"
+
+############################################################ FUNCTIONS
+
+# dialog_menu_main
+#
+# Display the dialog(1)-based application main menu.
+#
+dialog_menu_main()
+{
+ local menu_list size
+ local hline="$hline_arrows_tab_enter"
+ local prompt="$msg_menu_text"
+
+ menu_list="
+ 'X <<< $msg_exit' '$msg_exit_this_menu'
+ " # END-QUOTE
+
+ case "$( f_sysrc_get kern_securelevel_enable )" in
+ [Yy][Ee][Ss])
+ local kern_securelevel="$( f_sysrc_get kern_securelevel )"
+ if [ ${#kern_securelevel} -eq 1 ] &&
+ f_isinteger "$kern_securelevel"
+ then menu_list="$menu_list
+ '2 [$kern_securelevel] $msg_securelevel'"
+ else menu_list="$menu_list
+ '2 [X] $msg_securelevel'"
+ fi
+ menu_list="$menu_list '$msg_securelevel_desc'"
+ ;;
+ *) menu_list="$menu_list
+ '2 [ ] $msg_securelevel' '$msg_securelevel_desc'"
+ esac
+
+ case "$( f_sysrc_get nfs_reserved_port_only )" in
+ [Yy][Ee][Ss]) menu_list="$menu_list
+ '3 [X] $msg_nfs_port' '$msg_nfs_port_desc'";;
+ *) menu_list="$menu_list
+ '3 [ ] $msg_nfs_port' '$msg_nfs_port_desc'";;
+ esac
+
+ size=$( eval f_dialog_menu_size \
+ \"\$DIALOG_TITLE\" \
+ \"\$DIALOG_BACKTITLE\" \
+ \"\$prompt\" \
+ \"\$hline\" \
+ $menu_list )
+
+ local dialog_menu
+ dialog_menu=$( eval $DIALOG \
+ --clear --title \"\$DIALOG_TITLE\" \
+ --backtitle \"\$DIALOG_BACKTITLE\" \
+ --hline \"\$hline\" \
+ --ok-label \"\$msg_ok\" \
+ --cancel-label \"\$msg_cancel\" \
+ --menu \"\$prompt\" $size \
+ $menu_list \
+ 2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD
+ )
+ local retval=$?
+ setvar DIALOG_MENU_$$ "$dialog_menu"
+ return $retval
+}
+
+############################################################ MAIN
+
+# Incorporate rc-file if it exists
+[ -f "$HOME/.bsdconfigrc" ] && f_include "$HOME/.bsdconfigrc"
+
+#
+# Process command-line arguments
+#
+while getopts hSX flag; do
+ case "$flag" in
+ h|\?) f_usage $BSDCFG_LIBE/$APP_DIR/USAGE "PROGRAM_NAME" "$pgm";;
+ esac
+done
+shift $(( $OPTIND - 1 ))
+
+#
+# Initialize
+#
+f_dialog_init
+f_dialog_title "$msg_system_security_options_menu"
+f_dialog_backtitle "${ipgm:+bsdconfig }$pgm"
+f_mustberoot_init
+
+#
+# Launch application main menu
+#
+while :; do
+ dialog_menu_main
+ retval=$?
+ mtag=$( f_dialog_menutag )
+
+ [ $retval -eq 0 ] || f_die
+
+ case "$mtag" in
+ "X <<< $msg_exit") break ;;
+ "2 ["?"] $msg_securelevel") # Configure securelevels for the system
+ $BSDCFG_LIBE/$APP_DIR/kern_securelevel ${USE_XDIALOG:+-X} ;;
+ "3 [X] $msg_nfs_port") # Require that NFS clients use reserved ports
+ f_sysrc_set nfs_reserved_port_only "NO";;
+ "3 [ ] $msg_nfs_port") # Same; Toggle value
+ f_sysrc_set nfs_reserved_port_only "YES";;
+ esac
+
+done
+
+exit $SUCCESS
+
+################################################################################
+# END
+################################################################################
diff --git a/usr.sbin/bsdconfig/share/Makefile b/usr.sbin/bsdconfig/share/Makefile
new file mode 100644
index 0000000..7f299ec
--- /dev/null
+++ b/usr.sbin/bsdconfig/share/Makefile
@@ -0,0 +1,11 @@
+# $FreeBSD$
+
+NO_OBJ=
+
+FILESDIR= ${SHAREDIR}/bsdconfig
+FILES= common.subr dialog.subr mustberoot.subr strings.subr sysrc.subr
+
+beforeinstall:
+ mkdir -p ${DESTDIR}${FILESDIR}
+
+.include <bsd.prog.mk>
diff --git a/usr.sbin/bsdconfig/share/common.subr b/usr.sbin/bsdconfig/share/common.subr
new file mode 100644
index 0000000..46fdc6f
--- /dev/null
+++ b/usr.sbin/bsdconfig/share/common.subr
@@ -0,0 +1,330 @@
+if [ ! "$_COMMON_SUBR" ]; then _COMMON_SUBR=1
+#
+# Copyright (c) 2012 Ron McDowell
+# Copyright (c) 2012 Devin Teske
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in the
+# documentation and/or other materials provided with the distribution.
+#
+# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+# SUCH DAMAGE.
+#
+# $FreeBSD$
+#
+############################################################ GLOBALS
+
+#
+# Program name
+#
+pgm="${0##*/}"
+
+#
+# Program arguments
+#
+ARGC="$#"
+ARGV="$@"
+
+#
+# Global exit status variables
+#
+SUCCESS=0
+FAILURE=1
+
+############################################################ FUNCTIONS
+
+#
+# This is an empty function by default, to use it, copy
+# /usr/share/examples/bsdconfig/bsdconfigrc to $HOME/.bsdconfigrc
+#
+f_dprintf()
+{
+ : this page intentionally left blank
+}
+
+# f_err $fmt [ $opts ... ]
+#
+# Print a message to stderr (fd=2).
+#
+f_err()
+{
+ printf "$@" >&2
+}
+
+# f_quietly $command [ $arguments ... ]
+#
+# Run a command quietly (quell any output to stdout or stderr)
+#
+f_quietly()
+{
+ "$@" > /dev/null 2>&1
+}
+
+# f_have $anything ...
+#
+# A wrapper to the `type' built-in. Returns true if argument is a valid shell
+# built-in, keyword, or externally-tracked binary, otherwise false.
+#
+f_have()
+{
+ f_quietly type "$@"
+}
+
+# f_die [ $status [ $fmt [ $opts ... ]]]
+#
+# Abruptly terminate due to an error optionally displaying a message in a
+# dialog box using printf(1) syntax.
+#
+f_die()
+{
+ local status=$FAILURE
+
+ # If there is at least one argument, take it as the status
+ if [ $# -gt 0 ]; then
+ status=$1
+ shift 1 # status
+ fi
+
+ # If there are still arguments left, pass them to f_show_msg
+ [ $# -gt 0 ] && f_show_msg "$@"
+
+ # Optionally call f_clean_up() function if it exists
+ f_have f_clean_up && f_clean_up
+
+ exit $status
+}
+
+# f_interrupt
+#
+# Interrupt handler.
+#
+f_interrupt()
+{
+ exec 2>&1 # fix sh(1) bug where stderr gets lost within async-trap
+ f_die
+}
+
+# f_show_msg $fmt [ $opts ... ]
+#
+# Display a message in a dialog box using printf(1) syntax.
+#
+f_show_msg()
+{
+ local msg
+ msg=$( printf "$@" )
+
+ #
+ # Use f_dialog_msgbox 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_msgbox; then
+ f_dialog_msgbox "$msg"
+ else
+ dialog --msgbox "$msg" 0 0
+ fi
+}
+
+# f_show_help $file
+#
+# Display a language help-file. Automatically takes $LANG and $LC_ALL into
+# consideration when displaying $file (suffix ".$LC_ALL" or ".$LANG" will
+# automatically be added prior to loading the language help-file).
+#
+# If a language has been requested by setting either $LANG or $LC_ALL in the
+# environment and the language-specific help-file does not exist we will fall
+# back to $file without-suffix.
+#
+# If the language help-file does not exist, an error is displayed instead.
+#
+f_show_help()
+{
+ local file="$1"
+ local lang="${LANG:-$LC_ALL}"
+
+ [ -f "$file.$lang" ] && file="$file.$lang"
+
+ #
+ # Use f_dialog_textbox 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_textbox; then
+ f_dialog_textbox "$file"
+ else
+ dialog --msgbox "$( cat "$file" 2>&1 )" 0 0
+ fi
+}
+
+# f_include $file
+#
+# Include a shell subroutine file.
+#
+# If the subroutine file exists but returns error status during loading, exit
+# is called and execution is prematurely terminated with the same error status.
+#
+f_include()
+{
+ local file="$1"
+ . "$file" || exit $?
+}
+
+# f_include_lang $file
+#
+# Include a language file. Automatically takes $LANG and $LC_ALL into
+# consideration when including $file (suffix ".$LC_ALL" or ".$LANG" will
+# automatically by added prior to loading the language file).
+#
+# No error is produced if (a) a language has been requested (by setting either
+# $LANG or $LC_ALL in the environment) and (b) the language file does not
+# exist -- in which case we will fall back to loading $file without-suffix.
+#
+# If the language file exists but returns error status during loading, exit
+# is called and execution is prematurely terminated with the same error status.
+#
+f_include_lang()
+{
+ local file="$1"
+ local lang="${LANG:-$LC_ALL}"
+
+ f_dprintf "lang=[$lang]"
+ if [ -f "$file.$lang" ]; then
+ . "$file.$lang" || exit $?
+ else
+ . "$file" || exit $?
+ fi
+}
+
+# f_usage $file [ $key1 $value1 ... ]
+#
+# Display USAGE file with optional pre-processor macro definitions. The first
+# argument is the template file containing the usage text to be displayed. If
+# $LANG or $LC_ALL (in order of preference, respectively) is set, ".encoding"
+# will automatically be appended as a suffix to the provided $file pathname.
+#
+# When processing $file, output begins at the first line containing that is
+# (a) not a comment, (b) not empty, and (c) is not pure-whitespace. All lines
+# appearing after this first-line are output, including (a) comments (b) empty
+# lines, and (c) lines that are purely whitespace-only.
+#
+# If additional arguments appear after $file, substitutions are made while
+# printing the contents of the USAGE file. The pre-processor macro syntax is in
+# the style of autoconf(1), for example:
+#
+# f_usage $file "FOO" "BAR"
+#
+# Will cause instances of "@FOO@" appearing in $file to be replaced with the
+# text "BAR" before bering printed to the screen.
+#
+# This function is a two-parter. Below is the awk(1) portion of the function,
+# afterward is the sh(1) function which utilizes the below awk script.
+#
+f_usage_awk='
+BEGIN { found = 0 }
+{
+ if ( !found && $0 ~ /^[[:space:]]*($|#)/ ) next
+ found = 1
+ print
+}
+'
+f_usage()
+{
+ local file="$1"
+ local lang="${LANG:-$LC_ALL}"
+
+ f_dprintf "lang=[$lang]"
+
+ shift 1 # file
+
+ local usage
+ if [ -f "$file.$lang" ]; then
+ usage=$( awk "$f_usage_awk" "$file.$lang" ) || exit $FAILURE
+ else
+ usage=$( awk "$f_usage_awk" "$file" ) || exit $FAILURE
+ fi
+
+ while [ $# -gt 0 ]; do
+ local key="$1"
+ export value="$2"
+ usage=$( echo "$usage" | awk \
+ "{ gsub(/@$key@/, ENVIRON[\"value\"]); print }" )
+ shift 2
+ done
+
+ f_err "%s\n" "$usage"
+
+ exit $FAILURE
+}
+
+# f_index_menu_selection $file $pgm
+#
+# Process $file looking for $menu_selection values that correspond to $pgm.
+# This function is for internationalization (i18n) mapping of the on-disk
+# scriptname ($pgm) into the localized language (given language-specific
+# $file). If $LANG or $LC_ALL (in orderder of preference, respectively) is set,
+# ".encoding" will automatically be appended as a suffix to the provided $file
+# pathname.
+#
+# If, within $file, multiple $menu_selection values map to $pgm, only the first
+# one will be returned. If no mapping can be made, the NULL string is returned.
+#
+# If $file does not exist, error status is returned along with the NULL string.
+#
+# This function is a two-parter. Below is the awk(1) portion of the function,
+# afterward is the sh(1) function which utilizes the below awk script.
+#
+f_index_menusel_awk='
+# Variables that should be defined on the invocation line:
+# -v pgm="program_name"
+#
+( $0 ~ "^menu_selection=.*\\|" pgm "\"" ) {
+ sub(/\|.*/, "")
+ sub(/^menu_selection="/, "")
+ print
+ exit
+}
+'
+f_index_menu_selection()
+{
+ local file="$1" pgm="$2"
+ local lang="${LANG:-$LC_ALL}"
+
+ f_dprintf "lang=[$lang]"
+
+ if [ -f "$file.$lang" ]; then
+ awk -v pgm="$pgm" "$f_index_menusel_awk" "$file.$lang" ||
+ exit $FAILURE
+ elif [ -f "$file" ]; then
+ awk -v pgm="$pgm" "$f_index_menusel_awk" "$file" ||
+ exit $FAILURE
+ else
+ return $FAILURE
+ fi
+}
+
+############################################################ MAIN
+
+#
+# Trap signals so we can recover gracefully
+#
+trap 'f_interrupt' SIGINT
+trap 'f_die' SIGTERM SIGPIPE SIGXCPU SIGXFSZ \
+ SIGFPE SIGTRAP SIGABRT SIGSEGV
+trap '' SIGALRM SIGPROF SIGUSR1 SIGUSR2 SIGHUP SIGVTALRM
+
+fi # ! $_COMMON_SUBR
diff --git a/usr.sbin/bsdconfig/share/dialog.subr b/usr.sbin/bsdconfig/share/dialog.subr
new file mode 100644
index 0000000..353a8da
--- /dev/null
+++ b/usr.sbin/bsdconfig/share/dialog.subr
@@ -0,0 +1,1465 @@
+if [ ! "$_DIALOG_SUBR" ]; then _DIALOG_SUBR=1
+#
+# Copyright (c) 2006-2012 Devin Teske
+# All Rights Reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in the
+# documentation and/or other materials provided with the distribution.
+#
+# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING BUT NOT LIMITED TO, THE
+# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+# DAMAGES (INLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+# SUCH DAMAGE.
+#
+# $FreeBSD$
+#
+############################################################ INCLUDES
+
+BSDCFG_SHARE="/usr/share/bsdconfig"
+. $BSDCFG_SHARE/common.subr || exit 1
+f_include $BSDCFG_SHARE/strings.subr
+
+BSDCFG_LIBE="/usr/libexec/bsdconfig"
+f_include_lang $BSDCFG_LIBE/include/messages.subr
+
+############################################################ CONFIGURATION
+
+#
+# Default file descriptor to link to stdout for dialog(1) passthru allowing
+# 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}
+
+############################################################ GLOBALS
+
+#
+# Default name of dialog(1) utility
+# NOTE: This is changed to "Xdialog" by the optional `-X' argument
+#
+DIALOG="dialog"
+
+#
+# Default dialog(1) title and backtitle text
+#
+DIALOG_TITLE="$pgm"
+DIALOG_BACKTITLE="bsdconfig"
+
+#
+# Settings used while interacting with dialog(1)
+#
+DIALOG_MENU_TAGS="123456789ABCDEFGHIJKLMNOPQRSTUVWYZabcdefghijklmnopqrstuvwxyz"
+
+#
+# Declare that we are fully-compliant with Xdialog(1) by unset'ing all
+# compatibility settings.
+#
+unset XDIALOG_HIGH_DIALOG_COMPAT
+unset XDIALOG_FORCE_AUTOSIZE
+unset XDIALOG_INFOBOX_TIMEOUT
+
+#
+# Default behavior is to call f_dialog_init() automatically if not already
+# called manually by the time the first f_dialog_*() function is used.
+#
+: ${DIALOG_SELF_INITIALIZE=1}
+
+############################################################ GENERIC FUNCTIONS
+
+# f_dialog_title [$new_title]
+#
+# Set the title of future dialog(1) ($DIALOG_TITLE) or backtitle of Xdialog(1)
+# ($DIALOG_BACKTITLE) invocations. If no arguments are given or the first
+# argument is NULL, the current title is returned.
+#
+# Each time this function is called, a backup of the current values is made
+# allowing a one-time (single-level) restoration of the previous title using the
+# f_dialog_title_restore() function (below).
+#
+f_dialog_title()
+{
+ local new_title="$1"
+
+ if [ "$new_title" ]; then
+ if [ "$USE_XDIALOG" ]; then
+ _DIALOG_BACKTITLE="$DIALOG_BACKTITLE"
+ DIALOG_BACKTITLE="$new_title"
+ else
+ _DIALOG_TITLE="$DIALOG_TITLE"
+ DIALOG_TITLE="$new_title"
+ fi
+ else
+ if [ "$USE_XDIALOG" ]; then
+ echo "$DIALOG_BACKTITLE"
+ else
+ echo "$DIALOG_TITLE"
+ fi
+ fi
+}
+
+# f_dialog_title_restore
+#
+# Restore the previous title set by the last call to f_dialog_title().
+# Restoration is non-recursive and only works to restore the most-recent title.
+#
+f_dialog_title_restore()
+{
+ if [ "$USE_XDIALOG" ]; then
+ DIALOG_BACKTITLE="$_DIALOG_BACKTITLE"
+ else
+ DIALOG_TITLE="$_DIALOG_TITLE"
+ fi
+}
+
+# f_dialog_backtitle [$new_backtitle]
+#
+# Set the backtitle of future dialog(1) ($DIALOG_BACKTITLE) or title of
+# Xdialog(1) ($DIALOG_TITLE) invocations. If no arguments are given or the
+# first argument is NULL, the current backtitle is returned.
+#
+f_dialog_backtitle()
+{
+ local new_backtitle="$1"
+
+ if [ "$new_backtitle" ]; then
+ if [ "$USE_XDIALOG" ]; then
+ _DIALOG_TITLE="$DIALOG_TITLE"
+ DIALOG_TITLE="$new_backtitle"
+ else
+ _DIALOG_BACKTITLE="$DIALOG_BACKTITLE"
+ DIALOG_BACKTITLE="$new_backtitle"
+ fi
+ else
+ if [ "$USE_XDIALOG" ]; then
+ echo "$DIALOG_TITLE"
+ else
+ echo "$DIALOG_BACKTITLE"
+ fi
+ fi
+}
+
+# f_dialog_backtitle_restore
+#
+# Restore the previous backtitle set by the last call to f_dialog_backtitle().
+# Restoration is non-recursive and only works to restore the most-recent
+# backtitle.
+#
+f_dialog_backtitle_restore()
+{
+ if [ "$USE_XDIALOG" ]; then
+ DIALOG_TITLE="$_DIALOG_TITLE"
+ else
+ DIALOG_BACKTITLE="$_DIALOG_BACKTITLE"
+ fi
+}
+
+############################################################ SIZE FUNCTIONS
+
+# f_dialog_infobox_size $title $backtitle $prompt [$hline]
+#
+# Not all versions of dialog(1) perform auto-sizing of the width and height of
+# `--infobox' boxes sensibly.
+#
+# This function helps solve this issue by taking as arguments (in order of
+# appearance) the title, backtitle, prompt, and [optionally] hline returning
+# the optimal width and height for the box (not exceeding the actual terminal
+# width or height).
+#
+# Newline character sequences (``\n'') in $prompt are expanded as-is done by
+# dialog(1).
+#
+# Output is in the format of "height width".
+#
+f_dialog_infobox_size()
+{
+ [ "$DIALOG_SELF_INITIALIZE" ] && f_dialog_init
+
+ local title="$1" btitle="$2" prompt="$3" hline="$4" n=0
+ local min_width max_size
+
+ if [ "$USE_XDIALOG" ]; then
+ min_width=35
+ max_size="$XDIALOG_MAXSIZE" # see CONFIGURATION
+ else
+ min_width=24
+ max_size=$( stty size ) # usually "24 80"
+ fi
+
+ local max_height="${max_size%%[$IFS]*}"
+ local max_width="${max_size##*[$IFS]}"
+ local height width=$min_width
+
+ #
+ # Bump width for long titles (but don't exceed terminal width).
+ #
+ n=$(( ${#title} + 4 ))
+ if [ $n -gt $width -a $n -gt $min_width ]; then
+ # Add 16.6% width for Xdialog(1)
+ [ "$USE_XDIALOG" ] && n=$(( $n + $n / 6 ))
+
+ if [ $n -lt $max_width ]; then
+ width=$n
+ else
+ width=$max_width
+ fi
+ fi
+
+ #
+ # For Xdialog(1), bump width for long backtitles (which appear within
+ # the window; don't exceed maximum width).
+ #
+ if [ "$USE_XDIALOG" ]; then
+ n=$(( ${#btitle} + 4 ))
+ n=$(( $n + $n / 6 ))
+ if [ $n -gt $width -a $n -gt $min_width ]; then
+ if [ $n -lt $max_width ]; then
+ width=$n
+ else
+ width=$max_width
+ fi
+ fi
+ fi
+
+ #
+ # Bump width for long prompts (if not already at maximum width).
+ #
+ if [ $width -lt $max_width ]; then
+ n=$( echo "$prompt" | f_longest_line_length )
+ n=$(( $n + 4 ))
+
+ # Add 16.6% width for Xdialog(1)
+ [ "$USE_XDIALOG" ] && n=$(( $n + $n / 6 ))
+
+ if [ $n -gt $width -a $n -gt $min_width ]; then
+ if [ $n -lt $max_width ]; then
+ width=$n
+ else
+ width=$max_width
+ fi
+ fi
+ fi
+
+ #
+ # Bump width for long hlines (if not already at maximum width).
+ # NOTE: Though Xdialog(1) supports `--hline', it's not currently used.
+ #
+ if [ ! "$USE_XDIALOG" ]; then
+ if [ $width -lt $max_width ]; then
+ n=$(( ${#hline} + 10 ))
+ if [ $n -gt $width -a $n -gt $min_width ]; then
+ if [ $n -lt $max_width ]; then
+ width=$n
+ else
+ width=$max_width
+ fi
+ fi
+ fi
+ fi
+
+ #
+ # Set height based on number of rows in prompt
+ #
+ height=$( echo -n "$prompt" | f_number_of_lines )
+ height=$(( $height + 2 ))
+
+ #
+ # For Xdialog(1) bump height if backtitle is enabled (displayed in the
+ # X11 window with a separator line between the backtitle and msg text)
+ #
+ if [ "$USE_XDIALOG" -a "$btitle" ]; then
+ n=$( echo "$btitle" | f_number_of_lines )
+ height=$(( $height + $n + 2 ))
+ fi
+
+ # Make sure height is less than maximum screen size
+ [ $height -le $max_height ] || height=$max_height
+
+ # Return both
+ echo "$height $width"
+}
+
+# f_dialog_buttonbox_size $title $backtitle $prompt [$hline]
+#
+# Not all versions of dialog(1) perform auto-sizing of the width and height of
+# `--msgbox' and `--yesno' boxes sensibly.
+#
+# This function helps solve this issue by taking as arguments (in order of
+# appearance) the title, backtitle, prompt, and [optionally] hline returning
+# the optimal width and height for the box (not exceeding the actual terminal
+# width or height).
+#
+# Newline character sequences (``\n'') in $prompt are expanded as-is done by
+# dialog(1).
+#
+# Output is in the format of "height width".
+#
+f_dialog_buttonbox_size()
+{
+ [ "$DIALOG_SELF_INITIALIZE" ] && f_dialog_init
+
+ local title="$1" btitle="$2" prompt="$3" hline="$4"
+ local size="$( f_dialog_infobox_size \
+ "$title" "$btitle" "$prompt" "$hline" )"
+ local height="${size%%[$IFS]*}"
+ local width="${size##*[$IFS]}"
+
+ # Add height to accomodate the buttons
+ height=$(( $height + 2 ))
+
+ # Adjust for clipping with Xdialog(1) on Linux/GTK2
+ [ "$USE_XDIALOG" ] && height=$(( $height + 3 ))
+
+ #
+ # Enforce maximum height regardless
+ #
+ local max_size
+ if [ "$USE_XDIALOG" ]; then
+ max_size="$XDIALOG_MAXSIZE" # see CONFIGURATION
+ else
+ max_size=$( stty size ) # usually "24 80"
+ fi
+ local max_height="${max_size%%[$IFS]*}"
+ [ $height -le $max_height ] || height=$max_height
+
+ # Return both
+ echo "$height $width"
+}
+
+# f_dialog_inputbox_size $title $backtitle $prompt $init [$hline]
+#
+# Not all versions of dialog(1) perform auto-sizing of the width and height of
+# `--inputbox' boxes sensibly.
+#
+# This function helps solve this issue by taking as arguments (in order of
+# appearance) the title, backtitle, prompt, initial text, and [optionally]
+# hline returning the optimal width and height for the box (not exceeding the
+# actual terminal width and height).
+#
+# Newline character sequences (``\n'') in $prompt are expanded as-is done by
+# dialog(1).
+#
+# Output is in the format of "height width".
+#
+f_dialog_inputbox_size()
+{
+ [ "$DIALOG_SELF_INITIALIZE" ] && f_dialog_init
+
+ local title="$1" btitle="$2" prompt="$3" init="$4" hline="$5" n
+ local size="$( f_dialog_buttonbox_size \
+ "$title" "$btitle" "$prompt" "$hline" )"
+ local height="${size%%[$IFS]*}"
+ local width="${size##*[$IFS]}"
+
+ local min_width max_size
+ if [ "$USE_XDIALOG" ]; then
+ min_width=35
+ max_size="$XDIALOG_MAXSIZE" # see CONFIGURATION
+ else
+ min_width=24
+ max_size=$( stty size ) # usually "24 80"
+ fi
+ local max_height="${max_size%%[$IFS]*}"
+ local max_width="${max_size##*[$IFS]}"
+
+ #
+ # Add height to accomodate the input box
+ #
+ [ ! "$USE_XDIALOG" ] && height=$(( $height + 3 ))
+ [ $height -le $max_height ] || height=$max_height
+
+ #
+ # Bump width for initial text (if not already at maximum width).
+ # NOTE: Something neither dialog(1)/Xdialog(1) do, but worth it!
+ #
+ if [ $width -lt $max_width ]; then
+ n=$(( ${#init} + 7 ))
+
+ # Add 16.6% width for Xdialog(1)
+ [ "$USE_XDIALOG" ] && n=$(( $n + $n / 6 ))
+
+ if [ $n -gt $width -a $n -gt $min_width ]; then
+ if [ $n -lt $max_width ]; then
+ width=$n
+ else
+ width=$max_width
+ fi
+ fi
+ fi
+
+ # Return both
+ echo "$height $width"
+}
+
+# f_xdialog_2inputsbox_size $title $backtitle $prompt \
+# $label1 $init1 $label2 $init2
+#
+# Xdialog(1) does not perform auto-sizing of the width and height of
+# `--2inputsbox' boxes sensibly.
+#
+# This function helps solve this issue by taking as arguments (in order of
+# appearance) the title, backtitle, prompt, label for the first field, initial
+# text for said field, label for the second field, and initial text for said
+# field returning the optimal width and height for the box (not exceeding the
+# actual terminal width and height).
+#
+# Newline character sequences (``\n'') in $prompt are expanded as-is done by
+# Xdialog(1).
+#
+# Output is in the format of "height width".
+#
+f_xdialog_2inputsbox_size()
+{
+ [ "$DIALOG_SELF_INITIALIZE" ] && f_dialog_init
+
+ local title="$1" btitle="$2" prompt="$3"
+ local label1="$4" init1="$5" label2="$6" init2="$7" n
+ local size="$( f_dialog_inputbox_size \
+ "$title" "$btitle" "$prompt" "$init1" )"
+ local height="${size%%[$IFS]*}"
+ local width="${size##*[$IFS]}"
+
+ local min_width=35
+ local max_size="$XDIALOG_MAXSIZE" # see CONFIGURATION
+ local max_height="${max_size%%[$IFS]*}"
+ local max_width="${max_size##*[$IFS]}"
+
+ # Add height for first label
+ height=$(( $height + 2 ))
+
+ #
+ # Bump width for first label text (if not already at maximum width).
+ #
+ if [ $width -lt $max_width ]; then
+ n=$(( ${#label1} + 7 ))
+
+ # Add 16.6% width for Xdialog(1)
+ n=$(( $n + $n / 6 ))
+
+ if [ $n -gt $width -a $n -gt $min_width ]; then
+ if [ $n -lt $max_width ]; then
+ width=$n
+ else
+ width=$max_width
+ fi
+ fi
+ fi
+
+ # Add height for second label
+ height=$(( $height + 2 ))
+
+ #
+ # Bump width for second label text (if not already at maximum width).
+ #
+ if [ $width -lt $max_width ]; then
+ n=$(( ${#label2} + 7 ))
+
+ # Add 16.6% width for Xdialog(1)
+ n=$(( $n + $n / 6 ))
+
+ if [ $n -gt $width -a $n -gt $min_width ]; then
+ if [ $n -lt $max_width ]; then
+ width=$n
+ else
+ width=$max_width
+ fi
+ fi
+ fi
+
+ # Add height for a second inputbox
+ height=$(( $height + 2 ))
+
+ #
+ # Bump width for second initial text (if not already at maximum width).
+ # NOTE: Something neither dialog(1)/Xdialog(1) do, but worth it!
+ #
+ if [ $width -lt $max_width ]; then
+ n=$(( ${#init2} + 7 ))
+
+ # Add 16.6% width for Xdialog(1)
+ n=$(( $n + $n / 6 ))
+
+ if [ $n -gt $width -a $n -gt $min_width ]; then
+ if [ $n -lt $max_width ]; then
+ width=$n
+ else
+ width=$max_width
+ fi
+ fi
+ fi
+
+ # Return both
+ echo "$height $width"
+}
+
+# f_dialog_menu_size $title $backtitle $prompt $hline \
+# $tag1 $item1 $tag2 $item2 ...
+#
+# Not all versions of dialog(1) perform auto-sizing of the width and height of
+# `--menu' boxes sensibly.
+#
+# This function helps solve this issue by taking as arguments (in order of
+# appearance) the title, backtitle, prompt, hline and list of tag/item pairs,
+# returning the optimal width and height for the menu (not exceeding the actual
+# terminal width or height).
+#
+# Output is in the format of "height width rows".
+#
+f_dialog_menu_size()
+{
+ [ "$DIALOG_SELF_INITIALIZE" ] && f_dialog_init
+
+ local title="$1" btitle="$2" prompt="$3" hline="$4" n=0
+ local min_width min_rows max_size
+
+ if [ "$USE_XDIALOG" ]; then
+ min_width=35
+ min_rows=1
+ max_size="$XDIALOG_MAXSIZE" # see CONFIGURATION
+ else
+ min_width=24
+ min_rows=0
+ max_size=$( stty size ) # usually "24 80"
+ fi
+
+ local max_width="${max_size##*[$IFS]}"
+ local max_height="${max_size%%[$IFS]*}"
+ local box_size="$( f_dialog_infobox_size \
+ "$title" "$btitle" "$prompt" "$hline" )"
+ local box_height="${box_size%%[$IFS]*}"
+ local box_width="${box_size##*[$IFS]}"
+ local max_rows=$(( $max_height - 8 ))
+ local height width=$box_width rows=$min_rows
+
+ shift 4 # title/btitle/prompt/hline
+
+ # If there's no prompt, bump the max-rows by 1
+ [ "$prompt" ] || max_rows=$(( $max_rows + 1 ))
+
+ #
+ # The sum total between the longest tag-length and longest item-length
+ # should be used for the menu width (not to exceed terminal width).
+ #
+ # Also, calculate the number of rows (not to exceed terminal height).
+ #
+ local longest_tag=0 longest_item=0
+ while [ $# -ge 2 ]; do
+ local tag="$1" item="$2"
+ shift 2 # tag/item
+
+ [ ${#tag} -gt $longest_tag ] && longest_tag=${#tag}
+ [ ${#item} -gt $longest_item ] && longest_item=${#item}
+ [ $rows -lt $max_rows ] && rows=$(( $rows + 1 ))
+ done
+
+ # Update width
+ n=$(( $longest_tag + $longest_item + 10 ))
+ [ "$USE_XDIALOG" ] && n=$(( $n + $n / 6 )) # Add 16.6% for Xdialog(1)
+ if [ $n -gt $width -a $n -gt $min_width ]; then
+ if [ $n -lt $max_width ]; then
+ width=$n
+ else
+ width=$max_width
+ fi
+ fi
+
+ # Fix rows and set height
+ [ $rows -gt 0 ] || rows=1
+ if [ "$USE_XDIALOG" ]; then
+ height=$(( $rows + $box_height + 7 ))
+ else
+ height=$(( $rows + $box_height + 4 ))
+ fi
+ [ $height -le $max_height ] || height=$max_height
+
+ # Return all three
+ echo "$height $width $rows"
+}
+
+# f_dialog_menu_with_help_size $title $backtitle $prompt $hline \
+# $tag1 $item1 $help1 $tag2 $item2 $help2 ...
+#
+# Not all versions of dialog(1) perform auto-sizing of the width and height of
+# `--menu' boxes sensibly.
+#
+# This function helps solve this issue by taking as arguments (in order of
+# appearance) the title, backtitle, prompt, hline and list of tag/item/help
+# triplets, returning the optimal width and height for the menu (not exceeding
+# the actual terminal width or height).
+#
+# Output is in the format of "height width rows".
+#
+f_dialog_menu_with_help_size()
+{
+ [ "$DIALOG_SELF_INITIALIZE" ] && f_dialog_init
+
+ local title="$1" btitle="$2" prompt="$3" hline="$4" n=0
+ local min_width min_rows max_size
+
+ if [ "$USE_XDIALOG" ]; then
+ min_width=35
+ min_rows=1
+ max_size="$XDIALOG_MAXSIZE" # see CONFIGURATION
+ else
+ min_width=24
+ min_rows=0
+ max_size=$( stty size ) # usually "24 80"
+ fi
+
+ local max_width="${max_size##*[$IFS]}"
+ local max_height="${max_size%%[$IFS]*}"
+ local box_size="$( f_dialog_infobox_size \
+ "$title" "$btitle" "$prompt" "$hline" )"
+ local box_height="${box_size%%[$IFS]*}"
+ local box_width="${box_size##*[$IFS]}"
+ local max_rows=$(( $max_height - 8 ))
+ local height width=$box_width rows=$min_rows
+
+ shift 4 # title/btitle/prompt/hline
+
+ # If there's no prompt, bump the max-rows by 1
+ [ "$prompt" ] || max_rows=$(( $max_rows + 1 ))
+
+ #
+ # The sum total between the longest tag-length and longest item-length
+ # should be used for the menu width (not to exceed terminal width).
+ #
+ # Also, calculate the number of rows (not to exceed terminal height).
+ #
+ # Also, calculate the longest help while we're here. This will be used
+ # to influence the width of the menu if (and only-if) using Xdialog(1).
+ #
+ local longest_tag=0 longest_item=0 longest_help=0
+ while [ $# -ge 3 ]; do
+ local tag="$1" item="$2" help="$3"
+ shift 3 # tag/item/help
+
+ [ ${#tag} -gt $longest_tag ] && longest_tag=${#tag}
+ [ ${#item} -gt $longest_item ] && longest_item=${#item}
+ [ ${#help} -gt $longest_help ] && longest_help=${#help}
+ [ $rows -lt $max_rows ] && rows=$(( $rows + 1 ))
+ done
+
+ # Update width
+ n=$(( $longest_tag + $longest_item + 10 ))
+ [ "$USE_XDIALOG" ] && n=$(( $n + $n / 6 )) # Add 16.6% for Xdialog(1)
+ if [ $n -gt $width -a $n -gt $min_width ]; then
+ if [ $n -lt $max_width ]; then
+ width=$n
+ else
+ width=$max_width
+ fi
+ fi
+
+ # Update width for help text if using Xdialog(1)
+ if [ "$USE_XDIALOG" ]; then
+ n=$(( $longest_help + 10 ))
+ n=$(( $n + $n / 6 )) # +16.6%
+ if [ $n -gt $width -a $n -gt $min_width ]; then
+ if [ $n -lt $max_width ]; then
+ width=$n
+ else
+ width=$max_width
+ fi
+ fi
+ fi
+
+ # Fix rows and set height
+ [ $rows -gt 0 ] || rows=1
+ if [ "$USE_XDIALOG" ]; then
+ height=$(( $rows + $box_height + 8 ))
+ else
+ height=$(( $rows + $box_height + 4 ))
+ fi
+ [ $height -le $max_height ] || height=$max_height
+
+ # Return all three
+ echo "$height $width $rows"
+}
+
+# f_dialog_radiolist_size $title $backtitle $prompt $hline \
+# $tag1 $item1 $status1 $tag2 $item2 $status2 ...
+#
+# Not all versions of dialog(1) perform auto-sizing of the width and height of
+# `--radiolist' boxes sensibly.
+#
+# This function helps solve this issue by taking as arguments (in order of
+# appearance) the title, backtitle, prompt, hline and list of tag/item/status
+# triplets, returning the optimal width and height for the radiolist (not
+# exceeding the actual terminal width or height).
+#
+# Output is in the format of "height width rows".
+#
+f_dialog_radiolist_size()
+{
+ [ "$DIALOG_SELF_INITIALIZE" ] && f_dialog_init
+
+ local title="$1" btitle="$2" prompt="$3" hline="$4" n=0
+ local min_width min_rows max_size
+
+ if [ "$USE_XDIALOG" ]; then
+ min_width=35
+ min_rows=1
+ max_size="$XDIALOG_MAXSIZE" # see CONFIGURATION
+ else
+ min_width=24
+ min_rows=0
+ max_size=$( stty size ) # usually "24 80"
+ fi
+
+ local max_width="${max_size##*[$IFS]}"
+ local max_height="${max_size%%[$IFS]*}"
+ local box_size="$( f_dialog_infobox_size \
+ "$title" "$btitle" "$prompt" "$hline" )"
+ local box_height="${box_size%%[$IFS]*}"
+ local box_width="${box_size##*[$IFS]}"
+ local max_rows=$(( $max_height - 8 ))
+ local height width=$box_width rows=$min_rows
+
+ shift 4 # title/btitle/prompt/hline
+
+ #
+ # The sum total between the longest tag-length, longest item-length,
+ # and radio-button width should be used for the menu width (not to
+ # exceed terminal width).
+ #
+ # Also, calculate the number of rows (not to exceed terminal height).
+ #
+ local longest_tag=0 longest_item=0
+ while [ $# -ge 2 ]; do
+ local tag="$1" item="$2" help="$3"
+ shift 3 # tag/item/status
+
+ [ ${#tag} -gt $longest_tag ] && longest_tag=${#tag}
+ [ ${#item} -gt $longest_item ] && longest_item=${#item}
+ [ $rows -lt $max_rows ] && rows=$(( $rows + 1 ))
+ done
+
+ # Update width
+ n=$(( $longest_tag + $longest_item + 13 ))
+ [ "$USE_XDIALOG" ] && n=$(( $n + $n / 6 )) # Add 16.6% for Xdialog(1)
+ if [ $n -gt $width -a $n -gt $min_width ]; then
+ if [ $n -lt $max_width ]; then
+ width=$n
+ else
+ width=$max_width
+ fi
+ fi
+
+ # Fix rows and set height
+ [ $rows -gt 0 ] || rows=1
+ if [ "$USE_XDIALOG" ]; then
+ height=$(( $rows + $box_height + 7 ))
+ else
+ height=$(( $rows + $box_height + 4 ))
+ fi
+ [ $height -le $max_height ] || height=$max_height
+
+ # Return all three
+ echo "$height $width $rows"
+}
+
+# f_dialog_calendar_size $title $backtitle $prompt [$hline]
+#
+# Not all versions of dialog(1) perform auto-sizing of the width and height of
+# `--calendar' boxes sensibly.
+#
+# This function helps solve this issue by taking as arguments (in order of
+# appearance) the title, backtitle, prompt, and [optionally] hline returning
+# the optimal width and height for the box (not exceeding the actual terminal
+# width and height).
+#
+# Newline character sequences (``\n'') in $prompt are expanded as-is done by
+# dialog(1).
+#
+# Output is in the format of "height width".
+#
+f_dialog_calendar_size()
+{
+ [ "$DIALOG_SELF_INITIALIZE" ] && f_dialog_init
+
+ local title="$1" btitle="$2" prompt="$3" hline="$4" n
+ local size="$( f_dialog_infobox_size \
+ "$title" "$btitle" "$prompt" "$hline" )"
+ local height="${size%%[$IFS]*}"
+ local width="${size##*[$IFS]}"
+
+ local min_width min_height max_size
+ if [ "$USE_XDIALOG" ]; then
+ min_height=15
+ min_width=55
+ max_size="$XDIALOG_MAXSIZE" # see CONFIGURATION
+ else
+ min_height=0
+ min_width=40
+ max_size=$( stty size ) # usually "24 80"
+ fi
+ local max_height="${max_size%%[$IFS]*}"
+ local max_width="${max_size##*[$IFS]}"
+
+ #
+ # Enforce the minimum width for displaying the calendar
+ #
+ [ $width -ge $min_width ] || width=$min_width
+
+ #
+ # When using dialog(1), the calendar box is unique from other dialog(1)
+ # boxes in-that the height passed should not accomodate the 15-lines
+ # required to display the calendar. This does not apply to Xdialog(1).
+ #
+ # When using Xdialog(1), the height must accomodate the 15-lines
+ # required to display the calendar.
+ #
+ # NOTE: Also under dialog(1), because we can't predict whether the user
+ # has disabled shadow's in their `$HOME/.dialogrc' file, we'll subtract
+ # 16 rather than 15. This does not apply to Xdialog(1).
+ #
+ max_height=$(( $max_height - 16 ))
+ height=$( echo "$prompt" | f_number_of_lines )
+ if [ "$USE_XDIALOG" ]; then
+ # Add height to accomodate for the embedded calendar widget
+ height=$(( $height + $min_height - 1 ))
+
+ # Also, bump height if backtitle is enabled
+ if [ "$btitle" ]; then
+ local n="$( echo "$btitle" | f_number_of_lines )"
+ height=$(( $height + $n + 2 ))
+ fi
+ else
+ [ "$prompt" ] && height=$(( $height + 1 ))
+ fi
+ [ $height -le $max_height ] || height=$max_height
+
+ #
+ # The calendar box refuses to display if too large.
+ #
+ max_width=$(( $max_width - 2 ))
+ [ $width -le $max_width ] || width=$max_width
+
+ # Return both
+ echo "$height $width"
+}
+
+# f_dialog_timebox_size $title $backtitle $prompt [$hline]
+#
+# Not all versions of dialog(1) perform auto-sizing of the width and height of
+# `--timebox' boxes sensibly.
+#
+# This function helps solve this issue by taking as arguments (in order of
+# appearance) the title, backtitle, prompt, and [optionally] hline returning
+# the optimal width and height for the box (not exceeding the actual terminal
+# width and height).
+#
+# Newline character sequences (``\n'') in $prompt are expanded as-is done by
+# dialog(1).
+#
+# Output is in the format of "height width".
+#
+f_dialog_timebox_size()
+{
+ [ "$DIALOG_SELF_INITIALIZE" ] && f_dialog_init
+
+ local title="$1" btitle="$2" prompt="$3" hline="$4" n
+ local size="$( f_dialog_infobox_size \
+ "$title" "$btitle" "$prompt" "$hline" )"
+ local height="${size%%[$IFS]*}"
+ local width="${size##*[$IFS]}"
+
+ local min_width min_height max_size
+ if [ "$USE_XDIALOG" ]; then
+ min_width=40
+ max_size="$XDIALOG_MAXSIZE" # see CONFIGURATION
+ else
+ min_height=0
+ min_width=20
+ max_size=$( stty size ) # usually "24 80"
+ fi
+ local max_height="${max_size%%[$IFS]*}"
+ local max_width="${max_size##*[$IFS]}"
+
+ #
+ # Enforce the minimum width for displaying the timebox
+ #
+ [ $width -ge $min_width ] || width=$min_width
+
+ #
+ # When using dialog(1), the timebox box is unique from other dialog(1)
+ # boxes in-that the height passed should not accomodate the 6-lines
+ # required to display the timebox. This does not apply to Xdialog(1).
+ #
+ # When using Xdialog(1), the height seems to have no effect. All values
+ # provide the same results.
+ #
+ # NOTE: Also under dialog(1), because we can't predict whether the user
+ # has disabled shadow's in their `$HOME/.dialogrc' file, we'll subtract
+ # 7 rather than 6. This does not apply to Xdialog(1).
+ #
+ if [ "$USE_XDIALOG" ]; then
+ height=0 # Autosize; all values produce same results
+ else
+ max_height=$(( $max_height - 7 ))
+ height=$( echo "$prompt" | f_number_of_lines )
+ height=$(( $height + 1 ))
+ [ $height -le $max_height ] || height=$max_height
+ [ "$prompt" ] && height=$(( $height + 1 ))
+ fi
+
+ #
+ # The timebox box refuses to display if too large.
+ #
+ max_width=$(( $max_width - 2 ))
+ [ $width -le $max_width ] || width=$max_width
+
+ # Return both
+ echo "$height $width"
+}
+
+############################################################ CLEAR FUNCTIONS
+
+# f_dialog_clear
+#
+# Clears any/all previous dialog(1) displays.
+#
+f_dialog_clear()
+{
+ [ "$DIALOG_SELF_INITIALIZE" ] && f_dialog_init
+
+ $DIALOG --clear
+}
+
+############################################################ INFO FUNCTIONS
+
+# 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.
+#
+f_dialog_info()
+{
+ [ "$DIALOG_SELF_INITIALIZE" ] && f_dialog_init
+
+ local info_text="$*"
+ local size="$( f_dialog_infobox_size \
+ "$DIALOG_TITLE" \
+ "$DIALOG_BACKTITLE" \
+ "$info_text" )"
+
+ eval $DIALOG \
+ --title \"\$DIALOG_TITLE\" \
+ --backtitle \"\$DIALOG_BACKTITLE\" \
+ ${USE_XDIALOG:+--ignore-eof} \
+ ${USE_XDIALOG:+--no-buttons} \
+ --infobox \"\$info_text\" $size
+}
+
+# f_xdialog_info $info_text ...
+#
+# Throw up an Xdialog(1) infobox and do not dismiss it until stdin produces
+# EOF. This implies that you must execute this either as an rvalue to a pipe,
+# lvalue to indirection or in a sub-shell that provides data on stdin.
+#
+f_xdialog_info()
+{
+ [ "$DIALOG_SELF_INITIALIZE" ] && f_dialog_init
+
+ local info_text="$*"
+ local size="$( f_dialog_infobox_size \
+ "$DIALOG_TITLE" \
+ "$DIALOG_BACKTITLE" \
+ "$info_text" )"
+
+ eval $DIALOG \
+ --title \"\$DIALOG_TITLE\" \
+ --backtitle \"\$DIALOG_BACKTITLE\" \
+ --no-close --no-buttons \
+ --infobox \"\$info_text\" $size \
+ -1 # timeout of -1 means abort when EOF on stdin
+}
+
+############################################################ MSGBOX FUNCTIONS
+
+# f_dialog_msgbox $msg_text ...
+#
+# Throw up a dialog(1) msgbox. The msgbox remains until the user presses ENTER
+# or ESC, acknowledging the modal dialog.
+#
+# If the user presses ENTER, the exit status is zero (success), otherwise if
+# the user presses ESC the exit status is 255.
+#
+f_dialog_msgbox()
+{
+ [ "$DIALOG_SELF_INITIALIZE" ] && f_dialog_init
+
+ local msg_text="$*"
+ local size="$( f_dialog_buttonbox_size \
+ "$DIALOG_TITLE" \
+ "$DIALOG_BACKTITLE" \
+ "$msg_text" )"
+
+ eval $DIALOG \
+ --title \"\$DIALOG_TITLE\" \
+ --backtitle \"\$DIALOG_BACKTITLE\" \
+ --ok-label \"\$msg_ok\" \
+ --msgbox \"\$msg_text\" $size
+}
+
+############################################################ TEXTBOX FUNCTIONS
+
+# f_dialog_textbox $file
+#
+# Display the contents of $file (or an error if $file does not exist, etc.) in
+# a dialog(1) textbox (which has a scrollable region for the text). The textbox
+# remains until the user presses ENTER or ESC, acknowledging the modal dialog.
+#
+# If the user presses ENTER, the exit status is zero (success), otherwise if
+# the user presses ESC the exit status is 255.
+#
+f_dialog_textbox()
+{
+ [ "$DIALOG_SELF_INITIALIZE" ] && f_dialog_init
+
+ local file="$1"
+ local contents retval size
+
+ contents=$( cat "$file" 2>&1 )
+ retval=$?
+
+ size=$( f_dialog_buttonbox_size \
+ "$DIALOG_TITLE" \
+ "$DIALOG_BACKTITLE" \
+ "$contents" )
+
+ if [ $retval -eq $SUCCESS ]; then
+ eval $DIALOG \
+ --title \"\$DIALOG_TITLE\" \
+ --backtitle \"\$DIALOG_BACKTITLE\" \
+ --exit-label \"\$msg_ok\" \
+ --no-cancel \
+ --textbox \"\$file\" $size
+ else
+ eval $DIALOG \
+ --title \"\$DIALOG_TITLE\" \
+ --backtitle \"\$DIALOG_BACKTITLE\" \
+ --ok-label \"\$msg_ok\" \
+ --msgbox \"\$contents\" $size
+ fi
+}
+
+############################################################ YESNO FUNCTIONS
+
+# f_dialog_yesno $msg_text ...
+#
+# Display a dialog(1) Yes/No prompt to allow the user to make some decision.
+# The yesno prompt remains until the user presses ENTER or ESC, acknowledging
+# the modal dialog.
+#
+# If the user chooses YES the exit status is zero, or chooses NO the exit
+# status is one, or presses ESC the exit status is 255.
+#
+f_dialog_yesno()
+{
+ [ "$DIALOG_SELF_INITIALIZE" ] && f_dialog_init
+
+ local msg_text="$*"
+ local hline="$hline_arrows_tab_enter"
+ local size="$( f_dialog_buttonbox_size \
+ "$DIALOG_TITLE" \
+ "$DIALOG_BACKTITLE" \
+ "$msg_text" \
+ "$hline" )"
+
+ if [ "$USE_XDIALOG" ]; then
+ eval $DIALOG \
+ --title \"\$DIALOG_TITLE\" \
+ --backtitle \"\$DIALOG_BACKTITLE\" \
+ --hline \"\$hline\" \
+ --ok-label \"\$msg_yes\" \
+ --cancel-label \"\$msg_no\" \
+ --yesno \"\$msg_text\" $size
+ else
+ eval $DIALOG \
+ --title \"\$DIALOG_TITLE\" \
+ --backtitle \"\$DIALOG_BACKTITLE\" \
+ --hline \"\$hline\" \
+ --yes-label \"\$msg_yes\" \
+ --no-label \"\$msg_no\" \
+ --yesno \"\$msg_text\" $size
+ fi
+}
+
+# f_dialog_noyes $msg_text ...
+#
+# Display a dialog(1) No/Yes prompt to allow the user to make some decision.
+# The noyes prompt remains until the user presses ENTER or ESC, acknowledging
+# the modal dialog.
+#
+# If the user chooses YES the exit status is zero, or chooses NO the exit
+# status is one, or presses ESC the exit status is 255.
+#
+# NOTE: This is just like the f_dialog_yesno function except "No" is default.
+#
+f_dialog_noyes()
+{
+ [ "$DIALOG_SELF_INITIALIZE" ] && f_dialog_init
+
+ local msg_text="$*"
+ local hline="$hline_arrows_tab_enter"
+ local size="$( f_dialog_buttonbox_size \
+ "$DIALOG_TITLE" \
+ "$DIALOG_BACKTITLE" \
+ "$msg_text" \
+ "$hline" )"
+
+ if [ "$USE_XDIALOG" ]; then
+ eval $DIALOG \
+ --title \"\$DIALOG_TITLE\" \
+ --backtitle \"\$DIALOG_BACKTITLE\" \
+ --hline \"\$hline\" \
+ --default-no \
+ --ok-label \"\$msg_yes\" \
+ --cancel-label \"\$msg_no\" \
+ --yesno \"\$msg_text\" $size
+ else
+ eval $DIALOG \
+ --title \"\$DIALOG_TITLE\" \
+ --backtitle \"\$DIALOG_BACKTITLE\" \
+ --hline \"\$hline\" \
+ --defaultno \
+ --yes-label \"\$msg_yes\" \
+ --no-label \"\$msg_no\" \
+ --yesno \"\$msg_text\" $size
+ fi
+}
+
+############################################################ INPUT FUNCTIONS
+
+# f_dialog_inputstr
+#
+# Obtain the inputstr entered by the user from the most recently displayed
+# dialog(1) inputbox and clean up any temporary files.
+#
+f_dialog_inputstr()
+{
+ # Skip warnings and trim leading/trailing whitespace from user input
+ eval echo \"\$DIALOG_INPUTBOX_$$\" | awk '
+ BEGIN { found = 0 }
+ {
+ if ( ! found )
+ {
+ if ( $0 ~ /^$/ ) next
+ if ( $0 ~ /^Gdk-WARNING \*\*:/ ) next
+ found = 1
+ }
+ sub(/^[[:space:]]*/, "")
+ sub(/[[:space:]]*$/, "")
+ print
+ }
+ '
+ setvar DIALOG_INPUTBOX_$$ "" # scrub memory in case data was sensitive
+ return $SUCCESS
+}
+
+############################################################ 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.
+#
+f_dialog_menutag()
+{
+ # Skip warnings
+ eval echo \"\$DIALOG_MENU_$$\" | awk '
+ BEGIN { found = 0 }
+ {
+ if ( found ) # ... just spew
+ {
+ print
+ next
+ }
+ if ( $0 ~ /^$/ ) next
+ if ( $0 ~ /^Gdk-WARNING \*\*:/ ) next
+ found = 1
+ print
+ }
+ '
+ setvar DIALOG_MENU_$$ "" # scrub memory in case data was sensitive
+ return $SUCCESS
+}
+
+# f_dialog_menutag2item $tag_chosen $tag1 $item1 $tag2 $item2 ...
+#
+# To use the `--menu' option of dialog(1) you must pass an ordered list of
+# tag/item pairs on the command-line. When the user selects a menu option the
+# tag for that item is printed to stderr.
+#
+# This function allows you to dereference the tag chosen by the user back into
+# the item associated with said tag.
+#
+# Pass the tag chosen by the user as the first argument, followed by the
+# ordered list of tag/item pairs (HINT: use the same tag/item list as was
+# passed to dialog(1) for consistency).
+#
+# If the tag cannot be found, NULL is returned.
+#
+f_dialog_menutag2item()
+{
+ local tag="$1" tagn item
+ shift 1 # tag
+
+ while [ $# -gt 0 ]; do
+ tagn="$1"
+ item="$2"
+ shift 2 # tagn/item
+
+ if [ "$tag" = "$tagn" ]; then
+ echo "$item"
+ return $SUCCESS
+ fi
+ done
+ return $FAILURE
+}
+
+# f_dialog_menutag2item_with_help $tag_chosen $tag1 $item1 $help1 \
+# $tag2 $item2 $help2 ...
+#
+# To use the `--menu' option of dialog(1) with the `--item-help' option, you
+# must pass an ordered list of tag/item/help triplets on the command-line. When
+# the user selects a menu option the tag for that item is printed to stderr.
+#
+# This function allows you to dereference the tag chosen by the user back into
+# the item associated with said tag (help is discarded/ignored).
+#
+# Pass the tag chosen by the user as the first argument, followed by the
+# ordered list of tag/item/help triplets (HINT: use the same tag/item/help list
+# as was passed to dialog(1) for consistency).
+#
+# If the tag cannot be found, NULL is returned.
+#
+f_dialog_menutag2item_with_help()
+{
+ local tag="$1" tagn item
+ shift 1 # tag
+
+ while [ $# -gt 0 ]; do
+ tagn="$1"
+ item="$2"
+ shift 3 # tagn/item/help
+
+ if [ "$tag" = "$tagn" ]; then
+ echo "$item"
+ return $SUCCESS
+ fi
+ done
+ return $FAILURE
+}
+
+# f_dialog_menutag2index $tag_chosen $tag1 $item1 $tag2 $item2 ...
+#
+# To use the `--menu' option of dialog(1) you must pass an ordered list of
+# tag/item pairs on the command-line. When the user selects a menu option the
+# tag for that item is printed to stderr.
+#
+# This function allows you to dereference the tag chosen by the user back into
+# the index associated with said tag. The index is the one-based tag/item pair
+# array position within the ordered list of tag/item pairs passed to dialog(1).
+#
+# Pass the tag chosen by the user as the first argument, followed by the
+# ordered list of tag/item pairs (HINT: use the same tag/item list as was
+# passed to dialog(1) for consistency).
+#
+# If the tag cannot be found, NULL is returned.
+#
+f_dialog_menutag2index()
+{
+ local tag="$1" tagn n=1
+ shift 1 # tag
+
+ while [ $# -gt 0 ]; do
+ tagn="$1"
+ shift 2 # tagn/item
+
+ if [ "$tag" = "$tagn" ]; then
+ echo $n
+ return $SUCCESS
+ fi
+ n=$(( $n + 1 ))
+ done
+ return $FAILURE
+}
+
+# f_dialog_menutag2index_with_help $tag_chosen $tag1 $item1 $help1 \
+# $tag2 $item2 $help2 ...
+#
+# To use the `--menu' option of dialog(1) with the `--item-help' option, you
+# must pass an ordered list of tag/item/help triplets on the command-line. When
+# the user selects a menu option the tag for that item is printed to stderr.
+#
+# This function allows you to dereference the tag chosen by the user back into
+# the index associated with said tag. The index is the one-based tag/item/help
+# triplet array position within the ordered list of tag/item/help triplets
+# passed to dialog(1).
+#
+# Pass the tag chosen by the user as the first argument, followed by the
+# ordered list of tag/item/help triplets (HINT: use the same tag/item/help list
+# as was passed to dialog(1) for consistency).
+#
+# If the tag cannot be found, NULL is returned.
+#
+f_dialog_menutag2index_with_help()
+{
+ local tag="$1" tagn n=1
+ shift 1 # tag
+
+ while [ $# -gt 0 ]; do
+ tagn="$1"
+ shift 3 # tagn/item/help
+
+ if [ "$tag" = "$tagn" ]; then
+ echo $n
+ return $SUCCESS
+ fi
+ n=$(( $n + 1 ))
+ done
+ return $FAILURE
+}
+
+############################################################ INIT FUNCTIONS
+
+# f_dialog_init
+#
+# Initialize (or re-initialize) the dialog module after setting/changing any
+# of the following environment variables:
+#
+# USE_XDIALOG Either NULL or Non-NULL. If given a value will indicate
+# that Xdialog(1) should be used instead of dialog(1).
+#
+# SECURE Either NULL or Non-NULL. If given a value will indicate
+# that (while running as root) sudo(8) authentication is
+# required to proceed.
+#
+f_dialog_init()
+{
+ DIALOG_SELF_INITIALIZE=
+
+ #
+ # Clone terminal stdout so we can redirect to it from within sub-shells
+ #
+ eval exec $DIALOG_TERMINAL_PASSTHRU_FD\>\&1
+
+ #
+ # Process stored command-line arguments
+ #
+ SECURE=$( set -- "$ARGV"
+ while getopts S flag > /dev/null; do
+ case "$flag" in
+ S) echo 1;;
+ \?) continue;;
+ esac
+ done
+ )
+ USE_XDIALOG=$( set -- "$ARGV"
+ while getopts SX flag > /dev/null; do
+ case "$flag" in
+ S|X) echo 1;;
+ \?) continue;;
+ esac
+ done
+ )
+
+ #
+ # Process `-X' command-line option
+ #
+ [ "$USE_XDIALOG" ] && DIALOG=Xdialog
+
+ #
+ # Sanity check, or die gracefully
+ #
+ if ! f_have $DIALOG; then
+ unset USE_XDIALOG
+ failed_dialog="$DIALOG"
+ DIALOG=dialog
+ f_die 1 "$msg_no_such_file_or_directory" "$pgm" "$failed_dialog"
+ fi
+
+ #
+ # If we're already running as root but we got there by way of sudo(8)
+ # and we have X11, we should merge the xauth(1) credentials from our
+ # original user.
+ #
+ if [ "$USE_XDIALOG" ] &&
+ [ "$( id -u )" = "0" ] &&
+ [ "$SUDO_USER" -a "$DISPLAY" ]
+ then
+ if ! f_have xauth; then
+ # Die gracefully, as we [likely] can't use Xdialog(1)
+ unset USE_XDIALOG
+ DIALOG=dialog
+ f_die 1 "$msg_no_such_file_or_directory" "$pgm" "xauth"
+ fi
+ HOSTNAME=$(hostname)
+ displaynum="${DISPLAY#*:}"
+ eval xauth -if \~$SUDO_USER/.Xauthority extract - \
+ \"\$HOSTNAME/unix:\$displaynum\" \
+ \"\$HOSTNAME:\$displaynum\" | sudo sh -c 'xauth -ivf \
+ ~root/.Xauthority merge - > /dev/null 2>&1'
+ fi
+
+ #
+ # Probe Xdialog(1) for maximum height/width constraints, or die
+ # gracefully
+ #
+ if [ "$USE_XDIALOG" ]; then
+ if ! maxsize=$( LANG= LC_ALL= $DIALOG --print-maxsize 2>&1 )
+ then
+ # Xdialog(1) failed, fall back to dialog(1)
+ unset USE_XDIALOG
+ size=$( f_dialog_buttonbox_size "$DIALOG_TITLE" \
+ "$DIALOG_BACKTITLE" \
+ "$maxsize" "" )
+ eval dialog \
+ --title \"\$DIALOG_TITLE\" \
+ --backtitle \"\$DIALOG_BACKTITLE\" \
+ --ok-label \"\$msg_ok\" \
+ --msgbox \"\$maxsize\" $size
+ exit $FAILURE
+ fi
+
+ XDIALOG_MAXSIZE=$(
+ set -- ${maxsize##*:}
+
+ height=${1%,}
+ width=$2
+
+ echo $height $width
+ )
+ unset maxsize
+ fi
+
+ #
+ # If using Xdialog(1), swap DIALOG_TITLE with DIALOG_BACKTITLE.
+ # The reason for this is because many dialog(1) applications use
+ # --backtitle for the program name (which is better suited as
+ # --title with Xdialog(1)).
+ #
+ if [ "$USE_XDIALOG" ]; then
+ _DIALOG_TITLE="$DIALOG_TITLE"
+ DIALOG_TITLE="$DIALOG_BACKTITLE"
+ DIALOG_BACKTITLE="$_DIALOG_TITLE"
+ unset _DIALOG_TITLE
+ fi
+}
+
+fi # ! $_DIALOG_SUBR
diff --git a/usr.sbin/bsdconfig/share/mustberoot.subr b/usr.sbin/bsdconfig/share/mustberoot.subr
new file mode 100644
index 0000000..fd37c64
--- /dev/null
+++ b/usr.sbin/bsdconfig/share/mustberoot.subr
@@ -0,0 +1,424 @@
+if [ ! "$_MUSTBEROOT_SUBR" ]; then _MUSTBEROOT_SUBR=1
+#
+# Copyright (c) 2006-2012 Devin Teske
+# All Rights Reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in the
+# documentation and/or other materials provided with the distribution.
+#
+# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING BUT NOT LIMITED TO, THE
+# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+# DAMAGES (INLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+# SUCH DAMAGE.
+#
+# $FreeBSD$
+#
+############################################################ INCLUDES
+
+BSDCFG_SHARE="/usr/share/bsdconfig"
+. $BSDCFG_SHARE/common.subr || exit 1
+f_include $BSDCFG_SHARE/dialog.subr
+
+BSDCFG_LIBE="/usr/libexec/bsdconfig"
+f_include_lang $BSDCFG_LIBE/include/messages.subr
+
+############################################################ CONFIGURATION
+# NOTE: These are not able to be overridden/inherited for security purposes.
+
+#
+# Number of tries a user gets to enter his/her password before we log the
+# sudo(8) failure and exit.
+#
+PASSWD_TRIES=3
+
+#
+# While in SECURE mode, should authentication as `root' be allowed? Set to
+# non-NULL to enable authentication as `root', otherwise disabled.
+#
+# WARNING:
+# Unless using a custom sudo(8) configuration, user `root' should not be
+# allowed because no password is required to become `root' when already `root'
+# and therefore, any value entered as password will work.
+#
+SECURE_ALLOW_ROOT=
+
+#
+# While in SECURE mode, should we divulge (through error message) when the
+# requested authentication user does not exist? Set to non-NULL to enable,
+# otherwise a non-existent user is treated like an invalid password.
+#
+SECURE_DIVULGE_UNKNOWN_USER=
+
+############################################################ FUNCTIONS
+
+# f_become_root_via_sudo
+#
+# If not running as root, prompt for sudo(8) credentials to become root.
+# Re-execution of the current program via sudo is automatically handled.
+#
+# The following environment variables effect functionality:
+#
+# USE_XDIALOG Either NULL or Non-NULL. If given a value will indicate
+# that Xdialog(1) should be used instead of dialog(1).
+#
+f_become_root_via_sudo()
+{
+ local msg hline size
+
+ [ "$( id -u )" = "0" ] && return $SUCCESS
+
+ f_have sudo || f_die 1 "$msg_must_be_root_to_execute" "$pgm"
+
+ #
+ # Ask the user if it's OK to become root via sudo(8) and give them
+ # the option to save this preference (by touch(1)ing a file in the
+ # user's $HOME directory).
+ #
+ local checkpath="${HOME%/}/.bsdconfig_uses_sudo"
+ if [ ! -e "$checkpath" ]; then
+ msg=$( printf "$msg_always_try_sudo_when_run_as" "$USER" )
+ local menu_list="
+ 'X' '$msg_cancel_exit'
+ '1' '$msg'
+ '2' '$msg_try_sudo_only_this_once'
+ " # END-QUOTE
+ msg=$( printf "$msg_you_are_not_root_but" bsdconfig )
+ hline="$hline_arrows_tab_enter"
+ size=$( eval f_dialog_menu_size \
+ \"\$DIALOG_TITLE\" \
+ \"\$DIALOG_BACKTITLE\" \
+ \"\$msg\" \
+ \"\$hline\" \
+ $menu_list )
+
+ local dialog_menu mtag retval
+ dialog_menu=$( eval $DIALOG \
+ --title \"\$DIALOG_TITLE\" \
+ --backtitle \"\$DIALOG_BACKTITLE\" \
+ --hline \"\$hline\" \
+ --ok-label \"\$msg_ok\" \
+ --cancel-label \"\$msg_cancel\" \
+ --menu \"\$msg\" $size \
+ $menu_list \
+ 2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD
+ )
+ retval=$?
+ setvar DIALOG_MENU_$$ "$dialog_menu"
+ mtag=$( f_dialog_menutag )
+
+ [ $retval -eq 0 ] || f_die
+
+ case "$mtag" in
+ X) # Cancel/Exit
+ f_die ;;
+ 1) # Always try sudo(8) when run as $user
+ local err
+ if ! err=$( touch "$checkpath" 2>&1 ); then
+ f_show_msg "%s" "$err"
+ else
+ f_show_msg "$msg_created_path" "$checkpath"
+ fi
+ esac
+ else
+ #
+ # This user has created the path signing-off on sudo(8)-use
+ # but let's still give them a short/quick/unobtrusive reminder
+ #
+ f_dialog_info "$msg_becoming_root_via_sudo"
+ [ "$USE_XDIALOG" ] || sleep 0.6
+ fi
+
+ #
+ # Check sudo(8) access before prompting for password.
+ #
+ :| sudo -S -v 2> /dev/null
+ if [ $? -ne $SUCCESS ]; then
+ #
+ # sudo(8) access denied. Prompt for their password.
+ #
+ msg="$msg_please_enter_password"
+ hline="$hline_alnum_punc_tab_enter"
+ size=$( f_dialog_inputbox_size \
+ "$DIALOG_TITLE" \
+ "$DIALOG_BACKTITLE" \
+ "$msg" \
+ "$hline" )
+
+ #
+ # Continue prompting until they either Cancel, succeed
+ # or exceed the number of allowed failures.
+ #
+ local password nfailures=0 retval
+ while [ $nfailures -lt $PASSWD_TRIES ]; do
+ if [ "$USE_XDIALOG" ]; then
+ password=$( $DIALOG \
+ --title "$DIALOG_TITLE" \
+ --backtitle "$DIALOG_BACKTITLE" \
+ --hline "$hline" \
+ --ok-label "$msg_ok" \
+ --cancel-label "$msg_cancel" \
+ --password --inputbox "$msg" $size \
+ 2>&1 > /dev/null )
+ retval=$?
+
+ # Catch X11-related errors
+ [ $retval -eq 255 ] &&
+ f_die $retval "$password"
+ else
+ local dialog_inputbox
+ dialog_inputbox=$( $DIALOG \
+ --title "$DIALOG_TITLE" \
+ --backtitle "$DIALOG_BACKTITLE" \
+ --hline "$hline" \
+ --ok-label "$msg_ok" \
+ --cancel-label "$msg_cancel" \
+ --insecure \
+ --passwordbox "$msg" $size \
+ 2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD
+ )
+ retval=$?
+ setvar DIALOG_INPUTBOX_$$ "$dialog_inputbox"
+ password=$( f_dialog_inputstr )
+ fi
+
+ # Exit if the user cancelled.
+ [ $retval -eq $SUCCESS ] || exit $retval
+
+ #
+ # Validate sudo(8) credentials
+ #
+ sudo -S -v 2> /dev/null <<-EOF
+ $password
+ EOF
+ retval=$?
+ unset password # scrub memory
+ if [ $retval -eq $SUCCESS ]; then
+ # Access granted...
+ break
+ else
+ # Access denied...
+ nfailures=$(( $nfailures + 1 ))
+
+ # introduce a short delay
+ if [ $nfailures -lt $PASSWD_TRIES ]; then
+ f_dialog_info "$msg_sorry_try_again"
+ sleep 1
+ fi
+ fi
+ done
+
+ #
+ # If user exhausted number of allowed password tries, log
+ # the security event and exit immediately.
+ #
+ if [ $nfailures -ge $PASSWD_TRIES ]; then
+ msg=$( printf "$msg_nfailed_attempts" "$nfailures" )
+ logger -p auth.notice -t sudo " " \
+ "$USER : $msg" \
+ "; TTY=$(tty)" \
+ "; PWD=$PWD" \
+ "; USER=root" \
+ "; COMMAND=$0"
+ f_die 1 "sudo: $msg"
+ fi
+ fi
+
+ # Use xauth(1) to grant root the ability to use this X11/SSH session
+ if [ "$USE_XDIALOG" -a "$SSH_CONNECTION" -a "$DISPLAY" ]; then
+ f_have xauth || f_die 1 \
+ "$msg_no_such_file_or_directory" "$pgm" "xauth"
+ local HOSTNAME displaynum
+ HOSTNAME=$(hostname)
+ displaynum="${DISPLAY#*:}"
+ xauth -f ~/.Xauthority extract - $HOSTNAME/unix:$displaynum \
+ $HOSTNAME:$displaynum | sudo sh -c 'xauth -ivf \
+ ~root/.Xauthority merge - > /dev/null 2>&1'
+ fi
+
+ # Re-execute ourselves with sudo(8)
+ if [ $ARGC -gt 0 ]; then
+ exec sudo "$0" $ARGV
+ else
+ exec sudo "$0"
+ fi
+ exit $? # Never reached unless error
+}
+
+# f_authenticate_some_user
+#
+# Only used if running as root and requires X11 (see USE_XDIALOG below).
+# Prompts the user to enter a username and password to be authenticated via
+# sudo(8) to proceed.
+#
+# The following environment variables effect functionality:
+#
+# USE_XDIALOG Either NULL or Non-NULL. If given a value will indicate
+# that Xdialog(1) should be used instead of dialog(1).
+#
+f_authenticate_some_user()
+{
+ local msg hline size width height
+
+ f_have sudo || f_die 1 "$msg_must_be_root_to_execute" "$pgm"
+
+ #
+ # Secure-mode has been requested.
+ #
+
+ [ "$USE_XDIALOG" ] || f_die 1 "$msg_secure_mode_requires_x11"
+ [ "$(id -u)" = "0" ] || f_die 1 "$msg_secure_mode_requires_root"
+
+ #
+ # Prompt for sudo(8) credentials.
+ #
+
+ msg="$msg_please_enter_username_password"
+ hline="$hline_alnum_punc_tab_enter"
+ size=$( f_xdialog_2inputsbox_size \
+ "$DIALOG_TITLE" \
+ "$DIALOG_BACKTITLE" \
+ "$msg" \
+ "$field_username" "" \
+ "$field_password" "" )
+ width="${size##*[$IFS]}"
+ height="${size%%[$IFS]*}"
+ height=$(( $height + 2 )) # Add height for --password
+
+ #
+ # Continue prompting until they either Cancel, succeed or exceed the
+ # number of allowed failures.
+ #
+ local user_pass nfailures=0 retval
+ while [ $nfailures -lt $PASSWD_TRIES ]; do
+ user_pass=$( $DIALOG \
+ --title "$DIALOG_TITLE" \
+ --backtitle "$DIALOG_BACKTITLE" \
+ --hline "$hline" \
+ --ok-label "$msg_ok" \
+ --cancel-label "$msg_cancel" \
+ --password --2inputsbox "$msg" \
+ $height $width \
+ "$field_username" "" \
+ "$field_password" "" \
+ 2>&1 > /dev/null )
+ retval=$?
+
+ # Catch X11-related errors
+ [ $retval -eq 255 ] && f_die $retval "$user_pass"
+
+ # Exit if the user cancelled.
+ [ $retval -eq $SUCCESS ] || exit $retval
+
+ #
+ # Make sure the user exists and is non-root
+ #
+ local user password
+ user="${user_pass%%/*}"
+ password="${user_pass#*/}"
+ unset user_pass # scrub memory
+ if [ ! "$user" ]; then
+ nfailures=$(( $nfailures + 1 ))
+ f_dialog_msgbox "$msg_no_username"
+ continue
+ fi
+ if [ ! "$SECURE_ALLOW_ROOT" ]; then
+ case "$user" in
+ root|toor)
+ nfailures=$(( $nfailures + 1 ))
+ f_dialog_msgbox "$( printf \
+ "$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" )"
+ elif [ $nfailures -lt $PASSWD_TRIES ]; then
+ f_dialog_info "$msg_sorry_try_again"
+ sleep 1
+ fi
+ continue
+ fi
+
+ #
+ # Validate sudo(8) credentials for given user
+ #
+ su -m "$user" <<-EOF
+ sh <<EOS
+ sudo -k
+ sudo -S -v 2> /dev/null <<EOP
+ $password
+ EOP
+ EOS
+ EOF
+ retval=$?
+ unset user
+ unset password # scrub memory
+
+ if [ $retval -eq $SUCCESS ]; then
+ # Access granted...
+ break
+ else
+ # Access denied...
+ nfailures=$(( $nfailures + 1 ))
+
+ # introduce a short delay
+ if [ $nfailures -lt $PASSWD_TRIES ]; then
+ f_dialog_info "$msg_sorry_try_again"
+ sleep 1
+ fi
+ fi
+ done
+
+ #
+ # If user exhausted number of allowed password tries, log
+ # the security event and exit immediately.
+ #
+ if [ $nfailures -ge $PASSWD_TRIES ]; then
+ msg=$( printf "$msg_nfailed_attempts" "$nfailures" )
+ logger -p auth.notice -t sudo " " \
+ "${SUDO_USER:-$USER} : $msg" \
+ "; TTY=$(tty)" \
+ "; PWD=$PWD" \
+ "; USER=root" \
+ "; COMMAND=$0"
+ f_die 1 "sudo: $message"
+ fi
+}
+
+# f_mustberoot_init
+#
+# If not already root, make the switch to root by re-executing ourselves via
+# sudo(8) using user-supplied credentials.
+#
+# The following environment variables effect functionality:
+#
+# SECURE Either NULL or Non-NULL. If given a value will indicate
+# that (while running as root) sudo(8) authentication is
+# required to proceed.
+#
+f_mustberoot_init()
+{
+ if [ "$(id -u)" != "0" -a ! "$SECURE" ]; then
+ f_become_root_via_sudo
+ elif [ "$SECURE" ]; then
+ f_authenticate_some_user
+ fi
+}
+
+fi # ! $_MUSTBEROOT_SUBR
diff --git a/usr.sbin/bsdconfig/share/strings.subr b/usr.sbin/bsdconfig/share/strings.subr
new file mode 100644
index 0000000..d11a9a2
--- /dev/null
+++ b/usr.sbin/bsdconfig/share/strings.subr
@@ -0,0 +1,104 @@
+if [ ! "$_STRINGS_SUBR" ]; then _STRINGS_SUBR=1
+#
+# Copyright (c) 2006-2012 Devin Teske
+# All Rights Reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in the
+# documentation and/or other materials provided with the distribution.
+#
+# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING BUT NOT LIMITED TO, THE
+# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+# DAMAGES (INLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+# SUCH DAMAGE.
+#
+# $FreeBSD$
+
+# f_substr "$string" $start [ $length ]
+#
+# Simple wrapper to awk(1)'s `substr' function.
+#
+f_substr()
+{
+ local string="$1" start="${2:-0}" len="${3:-0}"
+ echo "$string" | awk "{ print substr(\$0, $start, $len) }"
+}
+
+# f_longest_line_length
+#
+# Simple wrapper to an awk(1) script to print the length of the longest line of
+# input (read from stdin). Supports the newline escape-sequence `\n' for
+# splitting a single line into multiple lines.
+#
+f_longest_line_length_awk='
+BEGIN { longest = 0 }
+{
+ if (split($0, lines, /\\n/) > 1)
+ {
+ for (n in lines)
+ {
+ len = length(lines[n])
+ longest = ( len > longest ? len : longest )
+ }
+ }
+ else
+ {
+ len = length($0)
+ longest = ( len > longest ? len : longest )
+ }
+}
+END { print longest }
+'
+f_longest_line_length()
+{
+ awk "$f_longest_line_length_awk"
+}
+
+# f_number_of_lines
+#
+# Simple wrapper to an awk(1) script to print the number of lines read from
+# stdin. Supports newline escape-sequence `\n' for splitting a single line into
+# multiple lines.
+#
+f_number_of_lines_awk='
+BEGIN { num_lines = 0 }
+{
+ num_lines += split(" "$0, unused, /\\n/)
+}
+END { print num_lines }
+'
+f_number_of_lines()
+{
+ awk "$f_number_of_lines_awk"
+}
+
+# f_isinteger $arg
+#
+# Returns true if argument is a positive/negative whole integer.
+#
+f_isinteger()
+{
+ local arg="$1"
+
+ # Prevent division-by-zero
+ [ "$arg" = "0" ] && return $SUCCESS
+
+ # Attempt to perform arithmetic divison (an operation which will exit
+ # with error unless arg is a valid positive/negative whole integer).
+ #
+ ( : $((0/$arg)) ) > /dev/null 2>&1
+}
+
+fi # ! $_STRINGS_SUBR
diff --git a/usr.sbin/bsdconfig/share/sysrc.subr b/usr.sbin/bsdconfig/share/sysrc.subr
new file mode 100644
index 0000000..1ee70e6
--- /dev/null
+++ b/usr.sbin/bsdconfig/share/sysrc.subr
@@ -0,0 +1,626 @@
+if [ ! "$_SYSRC_SUBR" ]; then _SYSRC_SUBR=1
+#
+# Copyright (c) 2006-2012 Devin Teske
+# All Rights Reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in the
+# documentation and/or other materials provided with the distribution.
+#
+# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING BUT NOT LIMITED TO, THE
+# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+# SUCH DAMAGE.
+#
+# $FreeBSD$
+#
+############################################################ INCLUDES
+
+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
+
+############################################################ CONFIGURATION
+
+#
+# Standard pathnames (inherit values from shell if available)
+#
+: ${RC_DEFAULTS:="/etc/defaults/rc.conf"}
+
+############################################################ GLOBALS
+
+#
+# Global exit status variables
+#
+SUCCESS=0
+FAILURE=1
+
+#
+# Valid characters that can appear in an sh(1) variable name
+#
+# Please note that the character ranges A-Z and a-z should be avoided because
+# these can include accent characters (which are not valid in a variable name).
+# For example, A-Z matches any character that sorts after A but before Z,
+# including A and Z. Although ASCII order would make more sense, that is not
+# how it works.
+#
+VALID_VARNAME_CHARS="0-9ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz_"
+
+############################################################ FUNCTIONS
+
+# f_clean_env [ --except $varname ... ]
+#
+# Unset all environment variables in the current scope. An optional list of
+# arguments can be passed, indicating which variables to avoid unsetting; the
+# `--except' is required to enable the exclusion-list as the remainder of
+# positional arguments.
+#
+# Be careful not to call this in a shell that you still expect to perform
+# $PATH expansion in, because this will blow $PATH away. This is best used
+# within a sub-shell block "(...)" or "$(...)" or "`...`".
+#
+f_clean_env()
+{
+ local var arg except=
+
+ #
+ # Should we process an exclusion-list?
+ #
+ if [ "$1" = "--except" ]; then
+ except=1
+ shift 1
+ fi
+
+ #
+ # Loop over a list of variable names from set(1) built-in.
+ #
+ for var in $( set | awk -F= \
+ '/^[[:alpha:]_][[:alnum:]_]*=/ {print $1}' \
+ | grep -v '^except$'
+ ); do
+ #
+ # In POSIX bourne-shell, attempting to unset(1) OPTIND results
+ # in "unset: Illegal number:" and causes abrupt termination.
+ #
+ [ "$var" = OPTIND ] && continue
+
+ #
+ # Process the exclusion-list?
+ #
+ if [ "$except" ]; then
+ for arg in "$@" ""; do
+ [ "$var" = "$arg" ] && break
+ done
+ [ "$arg" ] && continue
+ fi
+
+ unset "$var"
+ done
+}
+
+# f_sysrc_get $varname
+#
+# Get a system configuration setting from the collection of system-
+# configuration files (in order: /etc/defaults/rc.conf /etc/rc.conf
+# and /etc/rc.conf).
+#
+# NOTE: Additional shell parameter-expansion formats are supported. For
+# example, passing an argument of "hostname%%.*" (properly quoted) will
+# return the hostname up to (but not including) the first `.' (see sh(1),
+# "Parameter Expansion" for more information on additional formats).
+#
+f_sysrc_get()
+{
+ # Sanity check
+ [ -f "$RC_DEFAULTS" -a -r "$RC_DEFAULTS" ] || return $FAILURE
+
+ # Taint-check variable name
+ case "$1" in
+ [0-9]*)
+ # Don't expand possible positional parameters
+ return $FAILURE;;
+ *)
+ [ "$1" ] || return $FAILURE
+ esac
+
+ ( # Execute within sub-shell to protect parent environment
+
+ #
+ # Clear the environment of all variables, preventing the
+ # expansion of normals such as `PS1', `TERM', etc.
+ #
+ f_clean_env --except IFS RC_CONFS RC_DEFAULTS
+
+ . "$RC_DEFAULTS" > /dev/null 2>&1
+
+ unset RC_DEFAULTS
+ # no longer needed
+
+ #
+ # If the query is for `rc_conf_files' then store the value that
+ # we inherited from sourcing RC_DEFAULTS (above) so that we may
+ # conditionally restore this value after source_rc_confs in the
+ # event that RC_CONFS does not customize the value.
+ #
+ if [ "$1" = "rc_conf_files" ]; then
+ _rc_conf_files="$rc_conf_files"
+ fi
+
+ #
+ # If RC_CONFS is defined, set $rc_conf_files to an explicit
+ # value, modifying the default behavior of source_rc_confs().
+ #
+ if [ "${RC_CONFS+set}" ]; then
+ rc_conf_files="$RC_CONFS"
+ _rc_confs_set=1
+ fi
+
+ source_rc_confs > /dev/null 2>&1
+
+ #
+ # If the query was for `rc_conf_files' AND after calling
+ # source_rc_confs the value has not changed, then we should
+ # restore the value to the one inherited from RC_DEFAULTS
+ # before performing the final query (preventing us from
+ # returning what was set via RC_CONFS when the intent was
+ # instead to query the value from the file(s) specified).
+ #
+ if [ "$1" = "rc_conf_files" -a \
+ "$_rc_confs_set" -a \
+ "$rc_conf_files" = "$RC_CONFS" \
+ ]; then
+ rc_conf_files="$_rc_conf_files"
+ unset _rc_conf_files
+ unset _rc_confs_set
+ fi
+
+ unset RC_CONFS
+ # no longer needed
+
+ #
+ # This must be the last functional line for both the sub-shell
+ # and the function to preserve the return status from formats
+ # such as "${varname?}" and "${varname:?}" (see "Parameter
+ # Expansion" in sh(1) for more information).
+ #
+ eval echo '"${'"$1"'}"' 2> /dev/null
+ )
+}
+
+# f_sysrc_get_default $varname
+#
+# Get a system configuration default setting from the default rc.conf(5) file
+# (or whatever RC_DEFAULTS points at).
+#
+f_sysrc_get_default()
+{
+ # Sanity check
+ [ -f "$RC_DEFAULTS" -a -r "$RC_DEFAULTS" ] || return $FAILURE
+
+ # Taint-check variable name
+ case "$1" in
+ [0-9]*)
+ # Don't expand possible positional parameters
+ return $FAILURE;;
+ *)
+ [ "$1" ] || return $FAILURE
+ esac
+
+ ( # Execute within sub-shell to protect parent environment
+
+ #
+ # Clear the environment of all variables, preventing the
+ # expansion of normals such as `PS1', `TERM', etc.
+ #
+ f_clean_env --except RC_DEFAULTS
+
+ . "$RC_DEFAULTS" > /dev/null 2>&1
+
+ unset RC_DEFAULTS
+ # no longer needed
+
+ #
+ # This must be the last functional line for both the sub-shell
+ # and the function to preserve the return status from formats
+ # such as "${varname?}" and "${varname:?}" (see "Parameter
+ # Expansion" in sh(1) for more information).
+ #
+ eval echo '"${'"$1"'}"' 2> /dev/null
+ )
+}
+
+# f_sysrc_find $varname
+#
+# Find which file holds the effective last-assignment to a given variable
+# within the rc.conf(5) file(s).
+#
+# If the variable is found in any of the rc.conf(5) files, the function prints
+# the filename it was found in and then returns success. Otherwise output is
+# NULL and the function returns with error status.
+#
+f_sysrc_find()
+{
+ local varname="${1%%[!$VALID_VARNAME_CHARS]*}"
+ local regex="^[[:space:]]*$varname="
+ local rc_conf_files="$( f_sysrc_get rc_conf_files )"
+ local conf_files=
+ local file
+
+ # Check parameters
+ case "$varname" in
+ ""|[0-9]*) return $FAILURE
+ esac
+
+ #
+ # If RC_CONFS is defined, set $rc_conf_files to an explicit
+ # value, modifying the default behavior of source_rc_confs().
+ #
+ [ "${RC_CONFS+set}" ] && rc_conf_files="$RC_CONFS"
+
+ #
+ # Reverse the order of files in rc_conf_files (the boot process sources
+ # these in order, so we will search them in reverse-order to find the
+ # last-assignment -- the one that ultimately effects the environment).
+ #
+ for file in $rc_conf_files; do
+ conf_files="$file${conf_files:+ }$conf_files"
+ done
+
+ #
+ # Append the defaults file (since directives in the defaults file
+ # indeed affect the boot process, we'll want to know when a directive
+ # is found there).
+ #
+ conf_files="$conf_files${conf_files:+ }$RC_DEFAULTS"
+
+ #
+ # Find which file matches assignment to the given variable name.
+ #
+ for file in $conf_files; do
+ [ -f "$file" -a -r "$file" ] || continue
+ if grep -Eq "$regex" $file; then
+ echo $file
+ return $SUCCESS
+ fi
+ done
+
+ return $FAILURE # Not found
+}
+
+# f_sysrc_desc $varname
+#
+# Attempts to return the comments associated with varname from the rc.conf(5)
+# defaults file `/etc/defaults/rc.conf' (or whatever RC_DEFAULTS points to).
+#
+# Multi-line comments are joined together. Results are NULL if no description
+# could be found.
+#
+# This function is a two-parter. Below is the awk(1) portion of the function,
+# afterward is the sh(1) function which utilizes the below awk script.
+#
+f_sysrc_desc_awk='
+# Variables that should be defined on the invocation line:
+# -v varname="varname"
+#
+BEGIN {
+ regex = "^[[:space:]]*"varname"="
+ found = 0
+ buffer = ""
+}
+{
+ if ( ! found )
+ {
+ if ( ! match($0, regex) ) next
+
+ found = 1
+ sub(/^[^#]*(#[[:space:]]*)?/, "")
+ buffer = $0
+ next
+ }
+
+ if ( !/^[[:space:]]*#/ ||
+ /^[[:space:]]*[[:alpha:]_][[:alnum:]_]*=/ ||
+ /^[[:space:]]*#[[:alpha:]_][[:alnum:]_]*=/ ||
+ /^[[:space:]]*$/ ) exit
+
+ sub(/(.*#)*[[:space:]]*/, "")
+ buffer = buffer" "$0
+}
+END {
+ # Clean up the buffer
+ sub(/^[[:space:]]*/, "", buffer)
+ sub(/[[:space:]]*$/, "", buffer)
+
+ print buffer
+ exit ! found
+}
+'
+f_sysrc_desc()
+{
+ awk -v varname="$1" "$f_sysrc_desc_awk" < "$RC_DEFAULTS"
+}
+
+# f_sysrc_set $varname $new_value
+#
+# Change a setting in the system configuration files (edits the files in-place
+# to change the value in the last assignment to the variable). If the variable
+# does not appear in the source file, it is appended to the end of the primary
+# system configuration file `/etc/rc.conf'.
+#
+# This function is a two-parter. Below is the awk(1) portion of the function,
+# afterward is the sh(1) function which utilizes the below awk script.
+#
+f_sysrc_set_awk='
+# Variables that should be defined on the invocation line:
+# -v varname="varname"
+# -v new_value="new_value"
+#
+BEGIN {
+ regex = "^[[:space:]]*"varname"="
+ found = retval = 0
+}
+{
+ # If already found... just spew
+ if ( found ) { print; next }
+
+ # Does this line match an assignment to our variable?
+ if ( ! match($0, regex) ) { print; next }
+
+ # Save important match information
+ found = 1
+ matchlen = RSTART + RLENGTH - 1
+
+ # Store the value text for later munging
+ value = substr($0, matchlen + 1, length($0) - matchlen)
+
+ # Store the first character of the value
+ t1 = t2 = substr(value, 0, 1)
+
+ # Assignment w/ back-ticks, expression, or misc.
+ # We ignore these since we did not generate them
+ #
+ if ( t1 ~ /[`$\\]/ ) { retval = 1; print; next }
+
+ # Assignment w/ single-quoted value
+ else if ( t1 == "'\''" ) {
+ sub(/^'\''[^'\'']*/, "", value)
+ if ( length(value) == 0 ) t2 = ""
+ sub(/^'\''/, "", value)
+ }
+
+ # Assignment w/ double-quoted value
+ else if ( t1 == "\"" ) {
+ sub(/^"(.*\\\\+")*[^"]*/, "", value)
+ if ( length(value) == 0 ) t2 = ""
+ sub(/^"/, "", value)
+ }
+
+ # Assignment w/ non-quoted value
+ else if ( t1 ~ /[^[:space:];]/ ) {
+ t1 = t2 = "\""
+ sub(/^[^[:space:]]*/, "", value)
+ }
+
+ # Null-assignment
+ else if ( t1 ~ /[[:space:];]/ ) { t1 = t2 = "\"" }
+
+ printf "%s%c%s%c%s\n", substr($0, 0, matchlen), \
+ t1, new_value, t2, value
+}
+END { exit retval }
+'
+f_sysrc_set()
+{
+ local varname="$1" new_value="$2"
+
+ # Check arguments
+ [ "$varname" ] || return $FAILURE
+
+ #
+ # Find which rc.conf(5) file contains the last-assignment
+ #
+ local not_found=
+ local file="$( f_sysrc_find "$varname" )"
+ if [ "$file" = "$RC_DEFAULTS" -o ! "$file" ]; then
+ #
+ # We either got a null response (not found) or the variable
+ # was only found in the rc.conf(5) defaults. In either case,
+ # let's instead modify the first file from $rc_conf_files.
+ #
+
+ not_found=1
+
+ #
+ # If RC_CONFS is defined, use $RC_CONFS
+ # rather than $rc_conf_files.
+ #
+ if [ "${RC_CONFS+set}" ]; then
+ file="${RC_CONFS%%[$IFS]*}"
+ else
+ file=$( f_sysrc_get 'rc_conf_files%%[$IFS]*' )
+ fi
+ fi
+
+ #
+ # If not found, append new value to last file and return.
+ #
+ if [ "$not_found" ]; then
+ echo "$varname=\"$new_value\"" >> "$file"
+ return $?
+ fi
+
+ #
+ # Perform sanity checks.
+ #
+ if [ ! -w "$file" ]; then
+ f_err "$msg_cannot_create_permission_denied\n" \
+ "$pgm" "$file"
+ return $FAILURE
+ fi
+
+ #
+ # Create a new temporary file to write to.
+ #
+ local tmpfile="$( mktemp -t "$pgm" )"
+ [ "$tmpfile" ] || return $FAILURE
+
+ #
+ # Fixup permissions (else we're in for a surprise, as mktemp(1) creates
+ # the temporary file with 0600 permissions, and if we simply mv(1) the
+ # temporary file over the destination, the destination will inherit the
+ # permissions from the temporary file).
+ #
+ local mode
+ mode=$( stat -f '%#Lp' "$file" 2> /dev/null )
+ f_quietly chmod "${mode:-0644}" "$tmpfile"
+
+ #
+ # Fixup ownership. The destination file _is_ writable (we tested
+ # earlier above). However, this will fail if we don't have sufficient
+ # permissions (so we throw stderr into the bit-bucket).
+ #
+ local owner
+ owner=$( stat -f '%u:%g' "$file" 2> /dev/null )
+ f_quietly chown "${owner:-root:wheel}" "$tmpfile"
+
+ #
+ # Operate on the matching file, replacing only the last occurrence.
+ #
+ local new_contents retval
+ new_contents=$( tail -r $file 2> /dev/null )
+ new_contents=$( echo "$new_contents" | awk -v varname="$varname" \
+ -v new_value="$new_value" "$f_sysrc_set_awk" )
+ retval=$?
+
+ #
+ # Write the temporary file contents.
+ #
+ echo "$new_contents" | tail -r > "$tmpfile" || return $FAILURE
+ if [ $retval -ne $SUCCESS ]; then
+ echo "$varname=\"$new_value\"" >> "$tmpfile"
+ fi
+
+ #
+ # Taint-check our results.
+ #
+ if ! /bin/sh -n "$tmpfile"; then
+ f_err "$msg_previous_syntax_errors\n" "$pgm" "$file"
+ rm -f "$tmpfile"
+ return $FAILURE
+ fi
+
+ #
+ # Finally, move the temporary file into place.
+ #
+ mv "$tmpfile" "$file"
+}
+
+# f_sysrc_delete $varname
+#
+# Remove a setting from the system configuration files (edits files in-place).
+# Deletes all assignments to the given variable in all config files. If the
+# `-f file' option is passed, the removal is restricted to only those files
+# specified, otherwise the system collection of rc_conf_files is used.
+#
+# This function is a two-parter. Below is the awk(1) portion of the function,
+# afterward is the sh(1) function which utilizes the below awk script.
+#
+f_sysrc_delete_awk='
+# Variables that should be defined on the invocation line:
+# -v varname="varname"
+#
+BEGIN {
+ regex = "^[[:space:]]*"varname"="
+ found = 0
+}
+{
+ if ( $0 ~ regex )
+ found = 1
+ else
+ print
+}
+END { exit ! found }
+'
+f_sysrc_delete()
+{
+ local varname="$1"
+ local file
+
+ # Check arguments
+ [ "$varname" ] || return $FAILURE
+
+ #
+ # Operate on each of the specified files
+ #
+ for file in ${RC_CONFS-$( f_sysrc_get rc_conf_files )}; do
+ [ -e "$file" ] || continue
+
+ #
+ # Create a new temporary file to write to.
+ #
+ local tmpfile="$( mktemp -t "$pgm" )"
+ [ "$tmpfile" ] || return $FAILURE
+
+ #
+ # Fixup permissions and ownership (mktemp(1) defaults to 0600
+ # permissions) to instead match the destination file.
+ #
+ local mode owner
+ mode=$( stat -f '%#Lp' "$file" 2> /dev/null )
+ owner=$( stat -f '%u:%g' "$file" 2> /dev/null )
+ f_quietly chmod "${mode:-0644}" "$tmpfile"
+ f_quietly chown "${owner:-root:wheel}" "$tmpfile"
+
+ #
+ # Operate on the file, removing all occurrences, saving the
+ # output in our temporary file.
+ #
+ awk -v varname="$varname" "$f_sysrc_delete_awk" "$file" \
+ > "$tmpfile"
+ if [ $? -ne $SUCCESS ]; then
+ # The file didn't contain any assignments
+ rm -f "$tmpfile"
+ continue
+ fi
+
+ #
+ # Taint-check our results.
+ #
+ if ! /bin/sh -n "$tmpfile"; then
+ f_err "$msg_previous_syntax_errors\n" \
+ "$pgm" "$file"
+ rm -f "$tmpfile"
+ return $FAILURE
+ fi
+
+ #
+ # Perform sanity checks
+ #
+ if [ ! -w "$file" ]; then
+ f_err "$msg_permission_denied\n" "$pgm" "$file"
+ rm -f "$tmpfile"
+ return $FAILURE
+ fi
+
+ #
+ # Finally, move the temporary file into place.
+ #
+ mv "$tmpfile" "$file"
+ done
+}
+
+fi # ! $_SYSRC_SUBR
diff --git a/usr.sbin/bsdconfig/startup/INDEX b/usr.sbin/bsdconfig/startup/INDEX
new file mode 100644
index 0000000..1b6f5cd
--- /dev/null
+++ b/usr.sbin/bsdconfig/startup/INDEX
@@ -0,0 +1,58 @@
+# Copyright (c) 2012 Ron McDowell
+# Copyright (c) 2012 Devin Teske
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in the
+# documentation and/or other materials provided with the distribution.
+#
+# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+# SUCH DAMAGE.
+#
+# $FreeBSD$
+
+#
+# Title that will be shown on the bsdconfig menu
+menu_title="Startup"
+#
+# a short descriptive line shown at the bottom of the bsdconfig menu.
+# keep it short because any line longer than the terminal width will
+# be truncated.
+menu_help="Set Startup Parameters"
+#
+# two-part variable that defines an action to take when 'keyword'
+# is passed on a bsdconfig command line. variable takes the form
+# "keyword|command" and multiple occurrences of the variable
+# (with different 'keyword's, or different 'keyword's AND 'command's)
+# are allowed. If 'command' begins with a '/' then the full
+# path to the program is needed. If 'command' begins with anything
+# else it is a path relative to the directory this INDEX file is in.
+# 'keyword' can be i18n'ed but 'command' is the name of a script.
+menu_selection="startup|startup"
+menu_selection="startup_misc|misc"
+menu_selection="startup_rcadd|rcadd"
+menu_selection="startup_rcconf|rcconf"
+menu_selection="startup_rcdelete|rcdelete"
+menu_selection="startup_rcvar|rcvar"
+#
+# Items below this line do NOT need i18n translation----------------------
+#
+# Name of the program to be run when this menu choice is selected.
+# if it begins with a '/' then the full path to the program is needed.
+# if it begins with anything else it is a path relative to the directory
+# this INDEX file is in.
+menu_program="startup"
diff --git a/usr.sbin/bsdconfig/startup/Makefile b/usr.sbin/bsdconfig/startup/Makefile
new file mode 100644
index 0000000..0bba510
--- /dev/null
+++ b/usr.sbin/bsdconfig/startup/Makefile
@@ -0,0 +1,16 @@
+# $FreeBSD$
+
+NO_OBJ=
+
+SUBDIR= include share
+
+FILESDIR= ${LIBEXECDIR}/bsdconfig/140.startup
+FILES= INDEX USAGE
+
+SCRIPTSDIR= ${FILESDIR}
+SCRIPTS= misc rcadd rcconf rcdelete rcedit rcvar startup
+
+beforeinstall:
+ mkdir -p ${DESTDIR}${FILESDIR}
+
+.include <bsd.prog.mk>
diff --git a/usr.sbin/bsdconfig/startup/USAGE b/usr.sbin/bsdconfig/startup/USAGE
new file mode 100644
index 0000000..9aa4dca
--- /dev/null
+++ b/usr.sbin/bsdconfig/startup/USAGE
@@ -0,0 +1,33 @@
+# Copyright (c) 2012 Devin Teske
+# All Rights Reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in the
+# documentation and/or other materials provided with the distribution.
+#
+# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING BUT NOT LIMITED TO, THE
+# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+# DAMAGES (INLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+# SUCH DAMAGE.
+#
+# $FreeBSD$
+
+Usage: bsdconfig @PROGRAM_NAME@ [OPTIONS]
+
+OPTIONS:
+ -h Print usage statement and exit.
+ -S Secure X11 mode (implies `-X'). As root, always prompt-for
+ and validate sudo(8) username/password before starting.
+ -X Use Xdialog(1) in place of dialog(1).
diff --git a/usr.sbin/bsdconfig/startup/include/Makefile b/usr.sbin/bsdconfig/startup/include/Makefile
new file mode 100644
index 0000000..1634314
--- /dev/null
+++ b/usr.sbin/bsdconfig/startup/include/Makefile
@@ -0,0 +1,11 @@
+# $FreeBSD$
+
+NO_OBJ=
+
+FILESDIR= ${LIBEXECDIR}/bsdconfig/140.startup/include
+FILES= messages.subr
+
+beforeinstall:
+ mkdir -p ${DESTDIR}${FILESDIR}
+
+.include <bsd.prog.mk>
diff --git a/usr.sbin/bsdconfig/startup/include/messages.subr b/usr.sbin/bsdconfig/startup/include/messages.subr
new file mode 100644
index 0000000..b3cb57f
--- /dev/null
+++ b/usr.sbin/bsdconfig/startup/include/messages.subr
@@ -0,0 +1,112 @@
+# Copyright (c) 2012 Devin Teske
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in the
+# documentation and/or other materials provided with the distribution.
+#
+# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+# SUCH DAMAGE.
+#
+# $FreeBSD$
+
+hline_alnum_punc_tab_enter="Use alpha-numeric, punctuation, TAB or ENTER"
+hline_arrows_tab_enter="Press arrows, TAB or ENTER"
+msg_accounting="Accounting"
+msg_accounting_desc="This host wishes to run process accounting."
+msg_add_custom="Add Custom"
+msg_add_from_list="Add From List"
+msg_add_new="Add New"
+msg_add_new_desc="Add new directive"
+msg_add_new_help="Add new rc.conf(5) configuration directive"
+msg_add_startup_directive="Add Startup Directive"
+msg_all="All"
+msg_all_desc="Select all directives"
+msg_all_help="Select all displayed rc.conf(5) configuration directives"
+msg_apm="APM"
+msg_apm_desc="Auto-power management services (typically laptops)"
+msg_are_you_sure_you_want_to_delete="Are you sure you want to delete the \`%s' directive\nfrom the rc.conf(5) collection of system configuration files?"
+msg_are_you_sure_you_want_delete_the_following="Are you sure you want to delete the following directives\nfrom the rc.conf(5) collection of system configuration files?"
+msg_cancel="Cancel"
+msg_choose_view_details="Choose View Details"
+msg_creating_menu_list="Creating menu list...\nThis may take a while."
+msg_creating_rcconf_map="Creating rc.conf(5) map...\nThis may take a while."
+msg_creating_rcvar_map="Creating rcvar map...\nThis may take a while."
+msg_default_value="Default: %s"
+msg_delete="Delete"
+msg_delete_desc="Delete directive(s)"
+msg_delete_help="Select one or more directives from a list to delete"
+msg_delete_selected="Delete Selected"
+msg_delete_selected_desc="Delete selected directive(s)"
+msg_delete_selected_help="Delete each of the selected rc.conf(5) configuration directives"
+msg_delete_startup_directives="Delete Startup Directive(s)"
+msg_deleting_selected_directives="Deleting selected directive(s)..."
+msg_desc="Description"
+msg_desc_desc="Toggle display of system description"
+msg_details="Details"
+msg_exit="Exit"
+msg_exit_cancel="Exit/Cancel"
+msg_exit_cancel_desc="Return to previous menu"
+msg_exit_cancel_help="Return to the previous menu (selected items are untouched)"
+msg_exit_desc="Return to previous menu"
+msg_exit_help="Exit this menu (returning to previous)"
+msg_exit_this_menu="Exit this menu (returning to previous)"
+msg_info="Info"
+msg_lpd="lpd"
+msg_lpd_desc="This host has a printer and wants to run lpd."
+msg_miscellaneous_startup_services="Miscellaneous Startup Services"
+msg_miscellaneous_menu_text="This menu allows you to configure various aspects of your system's\nstartup configuration. Use [SPACE] or [ENTER] to select items, and\n[TAB] to move to the buttons. Select Exit to leave this menu."
+msg_named="named"
+msg_named_desc="Run a local name server on this host"
+msg_named_flags="named flags"
+msg_named_flags_desc="Set default flags to named (if enabled)"
+msg_nis_client="NIS client"
+msg_nis_client_desc="This host wishes to be an NIS client."
+msg_nis_domainname="NIS domainname"
+msg_nis_domainname_desc="Set NIS domainname (if enabled)"
+msg_nis_server="NIS Server"
+msg_nis_server_desc="This host wishes to be an NIS server."
+msg_none="None"
+msg_none_desc="Un-Select all directives"
+msg_none_help="Un-Select all rc.conf(5) configuration directives"
+msg_ok="OK"
+msg_please_enter_a_new_value="Please enter a new value for \`%s' (Default: %s):"
+msg_please_enter_rcvar_name="Please enter rc.conf(5) variable name:"
+msg_please_select_an_rcconf_directive="Please select an rc.conf(5) directive:"
+msg_rcvar_contains_invalid_chars="ERROR! rc.conf(5) variable name contains invalid characters.\n Name may only consist of letters [a-zA-Z], numbers [0-9],\n or underscore [_] and must not start with a number."
+msg_rcvar_must_start_with="ERROR! rc.conf(5) variable name must start with\n a letter [a-zA-Z] or underscore [_]."
+msg_reset="Reset"
+msg_reset_desc="Reset to default view settings"
+msg_sco="SCO"
+msg_sco_desc="This host wants to be able to run IBCS2 binaries."
+msg_show_configured="Show Configured"
+msg_show_configured_desc="Calculate rc.conf(5) locations (slow)"
+msg_show_default_value="Show Default/Value"
+msg_show_default_value_desc="Show default/configured values"
+msg_show_value="Show Value"
+msg_show_value_desc="Show configured startup value"
+msg_startup="Startup"
+msg_startup_dirs="Startup dirs"
+msg_startup_dirs_desc="Set the list of dirs to look for startup scripts"
+msg_svr4="SVR4"
+msg_svr4_desc="This host wants to be able to run SVR4 binaries."
+msg_toggle_startup_services="Toggle Startup Services"
+msg_value_required="Value Required"
+msg_view_details="View Details"
+msg_view_details_desc="Choose view details"
+msg_view_details_help="Choose which details are shown in the current view"
+msg_view_edit_startup_configuration="View/Edit Startup Configuration"
diff --git a/usr.sbin/bsdconfig/startup/misc b/usr.sbin/bsdconfig/startup/misc
new file mode 100755
index 0000000..3879c57
--- /dev/null
+++ b/usr.sbin/bsdconfig/startup/misc
@@ -0,0 +1,414 @@
+#!/bin/sh
+#-
+# Copyright (c) 2012 Devin Teske
+# All Rights Reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in the
+# documentation and/or other materials provided with the distribution.
+#
+# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING BUT NOT LIMITED TO, THE
+# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+# DAMAGES (INLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+# SUCH DAMAGE.
+#
+# $FreeBSD$
+#
+############################################################ INCLUDES
+
+BSDCFG_SHARE="/usr/share/bsdconfig"
+. $BSDCFG_SHARE/common.subr || exit 1
+f_include $BSDCFG_SHARE/dialog.subr
+f_include $BSDCFG_SHARE/mustberoot.subr
+f_include $BSDCFG_SHARE/sysrc.subr
+
+BSDCFG_LIBE="/usr/libexec/bsdconfig" APP_DIR="140.startup"
+f_include_lang $BSDCFG_LIBE/$APP_DIR/include/messages.subr
+
+ipgm=$( f_index_menu_selection $BSDCFG_LIBE/$APP_DIR/INDEX "$pgm" )
+[ $? -eq $SUCCESS -a "$ipgm" ] && pgm="$ipgm"
+
+############################################################ GLOBALS
+
+#
+# Operating environment
+#
+UNAME_P=$( uname -p ) # Processor Architecture (i.e. i386)
+
+############################################################ FUNCTIONS
+
+# dialog_menu_main
+#
+# Display the dialog(1)-based application main menu.
+#
+dialog_menu_main()
+{
+ local menu_list var_list size
+ local hline="$hline_arrows_tab_enter"
+ local prompt="$msg_miscellaneous_menu_text"
+
+ menu_list="
+ 'X <<< $msg_exit' '$msg_exit_this_menu'
+ " # END-QUOTE
+
+ var_list="
+ accounting_enable
+ local_startup
+ lpd_enable
+ named_enable
+ named_flags
+ nis_client_enable
+ nis_server_enable
+ nisdomainname
+ startup_dirs
+ " # END-QUOTE
+
+ if [ "$UNAME_P" = "i386" ]; then
+ var_list="$var_list
+ apm_enable
+ ibcs2_enable
+ svr4_enable
+ " # END-QUOTE
+ fi
+
+ menu_list="$menu_list $(
+ . "$RC_DEFAULTS"
+ source_rc_confs
+ export $var_list
+ export msg_apm msg_apm_desc
+ export msg_startup_dirs msg_startup_dirs_desc
+ export msg_named msg_named_desc
+ export msg_named_flags msg_named_flags_desc
+ export msg_nis_client msg_nis_client_desc
+ export msg_nis_domainname msg_nis_domainname_desc
+ export msg_nis_server msg_nis_server_desc
+ export msg_accounting msg_accounting_desc
+ export msg_lpd msg_lpd_desc
+ export msg_sco msg_sco_desc
+ export msg_svr4 msg_svr4_desc
+ :| awk \
+ -v uname_p="$UNAME_P" \
+ -v menu_tags="$DIALOG_MENU_TAGS" \
+ -v menu_fmt="'%c [%c] %s' '%s'\n" \
+ -v sep_fmt="' ' ' -- '\n" \
+ 'END {
+ i = 1
+ if ( uname_p == "i386" )
+ {
+ #
+ # APM: Auto-power management services
+ # (typically laptops)
+ #
+ printf menu_fmt, substr(menu_tags, i++, 1),
+ ( ENVIRON["apm_enable"] ~ \
+ /^[Yy][Ee][Ss]$/ ? "X" : " " ),
+ ENVIRON["msg_apm"],
+ ENVIRON["msg_apm_desc"]
+ }
+
+ # Separator
+ printf sep_fmt
+
+ #
+ # Startup dirs: Set the list of dirs to look for
+ # startup scripts
+ #
+ printf menu_fmt, substr(menu_tags, i++, 1),
+ ( length(ENVIRON["local_startup"]) > 0 \
+ ? "X" : " " ),
+ ENVIRON["msg_startup_dirs"],
+ ENVIRON["msg_startup_dirs_desc"]
+
+ #
+ # named: Run a local name server on this host
+ #
+ printf menu_fmt, substr(menu_tags, i++, 1),
+ ( ENVIRON["named_enable"] ~ \
+ /^[Yy][Ee][Ss]$/ ? "X" : " " ),
+ ENVIRON["msg_named"],
+ ENVIRON["msg_named_desc"]
+
+ #
+ # named flags: Set default flags to named (if enabled)
+ #
+ printf menu_fmt, substr(menu_tags, i++, 1),
+ ( length(ENVIRON["named_flags"]) > 0 \
+ ? "X" : " " ),
+ ENVIRON["msg_named_flags"],
+ ENVIRON["msg_named_flags_desc"]
+
+ #
+ # NIS client: This host wishes to be an NIS client.
+ #
+ printf menu_fmt, substr(menu_tags, i++, 1),
+ ( ENVIRON["nis_client_enable"] ~ \
+ /^[Yy][Ee][Ss]$/ ? "X" : " " ),
+ ENVIRON["msg_nis_client"],
+ ENVIRON["msg_nis_client_desc"]
+
+ #
+ # NIS domainname: Set NIS domainname (if enabled)
+ #
+ printf menu_fmt, substr(menu_tags, i++, 1),
+ ( length(ENVIRON["nisdomainname"]) > 0 \
+ ? "X" : " " ),
+ ENVIRON["msg_nis_domainname"],
+ ENVIRON["msg_nis_domainname_desc"]
+
+ #
+ # NIS server: This host wishes to be an NIS server.
+ #
+ printf menu_fmt, substr(menu_tags, i++, 1),
+ ( ENVIRON["nis_server_enable"] ~ \
+ /^[Yy][Ee][Ss]$/ ? "X" : " " ),
+ ENVIRON["msg_nis_server"],
+ ENVIRON["msg_nis_server_desc"]
+
+ # Separator
+ printf sep_fmt
+
+ #
+ # Accounting: This host wishes to run process
+ # accounting.
+ #
+ printf menu_fmt, substr(menu_tags, i++, 1),
+ ( ENVIRON["accounting_enable"] ~ \
+ /^[Yy][Ee][Ss]$/ ? "X" : " " ),
+ ENVIRON["msg_accounting"],
+ ENVIRON["msg_accounting_desc"]
+
+ #
+ # lpd: This host has a printer and wants to run lpd.
+ #
+ printf menu_fmt, substr(menu_tags, i++, 1),
+ ( ENVIRON["lpd_enable"] ~ \
+ /^[Yy][Ee][Ss]$/ ? "X" : " " ),
+ ENVIRON["msg_lpd"],
+ ENVIRON["msg_lpd_desc"]
+
+ if ( uname_p == "i386" )
+ {
+ #
+ # SCO: This host wants to be able to run IBCS2
+ # binaries.
+ #
+ printf menu_fmt, substr(menu_tags, i++, 1),
+ ( ENVIRON["ibcs2_enable"] ~ \
+ /^[Yy][Ee][Ss]$/ ? "X" : " " ),
+ ENVIRON["msg_sco"],
+ ENVIRON["msg_sco_desc"]
+
+ #
+ # SVR4: This host wants to be able to run SVR4
+ # binaries.
+ #
+ printf menu_fmt, substr(menu_tags, i++, 1),
+ ( ENVIRON["svr4_enable"] ~ \
+ /^[Yy][Ee][Ss]$/ ? "X" : " " ),
+ ENVIRON["msg_svr4"],
+ ENVIRON["msg_svr4_desc"]
+ }
+ }'
+ )"
+
+ size=$( eval f_dialog_menu_size \
+ \"\$DIALOG_TITLE\" \
+ \"\$DIALOG_BACKTITLE\" \
+ \"\$prompt\" \
+ \"\$hline\" \
+ $menu_list )
+
+ local dialog_menu
+ dialog_menu=$( eval $DIALOG \
+ --clear --title \"\$DIALOG_TITLE\" \
+ --backtitle \"\$DIALOG_BACKTITLE\" \
+ --hline \"\$hline\" \
+ --ok-label \"\$msg_ok\" \
+ --cancel-label \"\$msg_cancel\" \
+ --menu \"\$prompt\" $size \
+ $menu_list \
+ 2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD
+ )
+ local retval=$?
+ setvar DIALOG_MENU_$$ "$dialog_menu"
+ return $retval
+}
+
+# dialog_input_value [ $prompt [ $init ] ]
+#
+# Prompt the user to input a value. If the user does not cancel or press ESC,
+# the return value is zero ($SUCCESS) and $value holds the user's input.
+#
+dialog_input_value()
+{
+ local hline="$hline_alnum_tab_enter"
+ local size 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 )
+
+ f_dialog_title_restore
+
+ # Return if user has either pressed ESC or chosen Cancel/No
+ [ $retval -eq $SUCCESS ] || return $retval
+
+ value="$_input"
+ return $SUCCESS
+}
+
+############################################################ MAIN
+
+# Incorporate rc-file if it exists
+[ -f "$HOME/.bsdconfigrc" ] && f_include "$HOME/.bsdconfigrc"
+
+#
+# Process command-line arguments
+#
+while getopts hSX flag; do
+ case "$flag" in
+ h|\?) f_usage $BSDCFG_LIBE/$APP_DIR/USAGE "PROGRAM_NAME" "$pgm";;
+ esac
+done
+shift $(( $OPTIND - 1 ))
+
+#
+# Initialize
+#
+f_dialog_init
+f_dialog_title "$msg_miscellaneous_startup_services"
+f_dialog_backtitle "${ipgm:+bsdconfig }$pgm"
+f_mustberoot_init
+
+#
+# Launch application main menu
+#
+while :; do
+ dialog_menu_main
+ retval=$?
+ mtag=$( f_dialog_menutag )
+
+ [ $retval -eq 0 ] || f_die
+
+ case "$mtag" in
+ "X <<< $msg_exit") break ;;
+ ?" ["?"] $msg_apm")
+ case "$mtag" in
+ ?" [X] "*) err=$( f_sysrc_set apm_enable NO 2>&1 ) ;;
+ ?" [ ] "*) err=$( f_sysrc_set apm_enable YES 2>&1 ) ;;
+ esac
+ [ $? -eq $SUCCESS ] || f_show_msg "%s\n" "$err" ;;
+ ?" ["?"] $msg_startup_dirs")
+ dialog_input_value \
+ "$msg_startup_dirs_desc" \
+ "$( f_sysrc_get local_startup )"
+ if [ $? -eq $SUCCESS ]; then
+ err=$( f_sysrc_set local_startup "$value" ) ||
+ f_show_msg "%s\n" "$err"
+ fi
+ ;;
+ ?" ["?"] $msg_named")
+ case "$mtag" in
+ ?" [X] "*) err=$( f_sysrc_set named_enable NO 2>&1 ) ;;
+ ?" [ ] "*) err=$( f_sysrc_set named_enable YES 2>&1 ) ;;
+ esac
+ [ $? -eq $SUCCESS ] || f_show_msg "%s\n" "$err" ;;
+ ?" ["?"] $msg_named_flags")
+ dialog_input_value \
+ "$msg_named_flags_desc" \
+ "$( f_sysrc_get named_flags )"
+ if [ $? -eq $SUCCESS ]; then
+ err=$( f_sysrc_set named_flags "$value" ) ||
+ f_show_msg "%s\n" "$err"
+ fi
+ ;;
+ ?" ["?"] $msg_nis_client")
+ case "$mtag" in
+ ?" [X] "*) err=$( f_sysrc_set nis_client_enable NO 2>&1 ) ;;
+ ?" [ ] "*)
+ err=$( f_sysrc_set nis_client_enable YES 2>&1 ) \
+ && err=$( f_sysrc_set rpcbind_enable YES 2>&1 ) ;;
+ esac
+ [ $? -eq $SUCCESS ] || f_show_msg "%s\n" "$err" ;;
+ ?" ["?"] $msg_nis_domainname")
+ dialog_input_value \
+ "$msg_nis_domainname_desc" \
+ "$( f_sysrc_get nisdomainname )"
+ if [ $? -eq $SUCCESS ]; then
+ err=$( f_sysrc_set nisdomainname "$value" ) ||
+ f_show_msg "%s\n" "$err"
+ fi
+ ;;
+ ?" ["?"] $msg_nis_server")
+ case "$mtag" in
+ ?" [X] "*) err=$( f_sysrc_set nis_server_enable NO 2>&1 ) ;;
+ ?" [ ] "*)
+ err=$( f_sysrc_set nis_server_enable YES 2>&1 ) \
+ && err=$( f_sysrc_set rpcbind_enable YES 2>&1 ) ;;
+ esac
+ [ $? -eq $SUCCESS ] || f_show_msg "%s\n" "$err" ;;
+ ?" ["?"] $msg_accounting")
+ case "$mtag" in
+ ?" [X] "*) err=$( f_sysrc_set accounting_enable NO 2>&1 ) ;;
+ ?" [ ] "*) err=$( f_sysrc_set accounting_enable YES 2>&1 ) ;;
+ esac
+ [ $? -eq $SUCCESS ] || f_show_msg "%s\n" "$err" ;;
+ ?" ["?"] $msg_lpd")
+ case "$mtag" in
+ ?" [X] "*) err=$( f_sysrc_set lpd_enable NO 2>&1 ) ;;
+ ?" [ ] "*) err=$( f_sysrc_set lpd_enable YES 2>&1 ) ;;
+ esac
+ [ $? -eq $SUCCESS ] || f_show_msg "%s\n" "$err" ;;
+ ?" ["?"] $msg_sco")
+ case "$mtag" in
+ ?" [X] "*) err=$( f_sysrc_set ibcs2_enable NO 2>&1 ) ;;
+ ?" [ ] "*) err=$( f_sysrc_set ibcs2_enable YES 2>&1 ) ;;
+ esac
+ [ $? -eq $SUCCESS ] || f_show_msg "%s\n" "$err" ;;
+ ?" ["?"] $msg_svr4")
+ case "$mtag" in
+ ?" [X] "*) err=$( f_sysrc_set svr4_enable NO 2>&1 ) ;;
+ ?" [ ] "*) err=$( f_sysrc_set svr4_enable YES 2>&1 ) ;;
+ esac
+ [ $? -eq $SUCCESS ] || f_show_msg "%s\n" "$err" ;;
+ esac
+done
+
+exit $SUCCESS
+
+################################################################################
+# END
+################################################################################
diff --git a/usr.sbin/bsdconfig/startup/rcadd b/usr.sbin/bsdconfig/startup/rcadd
new file mode 100755
index 0000000..8f28840
--- /dev/null
+++ b/usr.sbin/bsdconfig/startup/rcadd
@@ -0,0 +1,158 @@
+#!/bin/sh
+#-
+# Copyright (c) 2012 Devin Teske
+# All Rights Reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in the
+# documentation and/or other materials provided with the distribution.
+#
+# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING BUT NOT LIMITED TO, THE
+# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+# DAMAGES (INLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+# SUCH DAMAGE.
+#
+# $FreeBSD$
+#
+############################################################ INCLUDES
+
+BSDCFG_SHARE="/usr/share/bsdconfig"
+. $BSDCFG_SHARE/common.subr || exit 1
+f_include $BSDCFG_SHARE/dialog.subr
+f_include $BSDCFG_SHARE/mustberoot.subr
+f_include $BSDCFG_SHARE/startup/rcconf.subr
+
+BSDCFG_LIBE="/usr/libexec/bsdconfig" APP_DIR="140.startup"
+f_include_lang $BSDCFG_LIBE/$APP_DIR/include/messages.subr
+
+ipgm=$( f_index_menu_selection $BSDCFG_LIBE/$APP_DIR/INDEX "$pgm" )
+[ $? -eq $SUCCESS -a "$ipgm" ] && pgm="$ipgm"
+
+############################################################ GLOBALS
+
+#
+# Options
+#
+# Inherit SHOW_DESC value if set, otherwise default to 1
+[ "${SHOW_DESC+set}" ] || SHOW_DESC=1
+
+############################################################ FUNCTIONS
+
+# dialog_menu_main
+#
+# Display the dialog(1)-based application main menu.
+#
+dialog_menu_main()
+{
+ local menu_list size
+ local hline="$hline_arrows_tab_enter"
+ local prompt=""
+
+ menu_list="
+ '1' '$msg_add_from_list'
+ '2' '$msg_add_custom'
+ " # END-QUOTE
+
+ size=$( eval f_dialog_menu_size \
+ \"\$DIALOG_TITLE\" \
+ \"\$DIALOG_BACKTITLE\" \
+ \"\$prompt\" \
+ \"\$hline\" \
+ $menu_list )
+
+ local dialog_menu
+ dialog_menu=$( eval $DIALOG \
+ --clear --title \"\$DIALOG_TITLE\" \
+ --backtitle \"\$DIALOG_BACKTITLE\" \
+ --hline \"\$hline\" \
+ --ok-label \"\$msg_ok\" \
+ --cancel-label \"\$msg_cancel\" \
+ --menu \"\$prompt\" $size \
+ $menu_list \
+ 2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD
+ )
+ local retval=$?
+ setvar DIALOG_MENU_$$ "$dialog_menu"
+ return $retval
+}
+
+############################################################ MAIN
+
+# Incorporate rc-file if it exists
+[ -f "$HOME/.bsdconfigrc" ] && f_include "$HOME/.bsdconfigrc"
+
+#
+# Process command-line arguments
+#
+while getopts hSX flag; do
+ case "$flag" in
+ h|\?) f_usage $BSDCFG_LIBE/$APP_DIR/USAGE "PROGRAM_NAME" "$pgm";;
+ esac
+done
+shift $(( $OPTIND - 1 ))
+
+#
+# Initialize
+#
+f_dialog_init
+f_dialog_title "$msg_add_startup_directive"
+f_dialog_backtitle "${ipgm:+bsdconfig }$pgm"
+f_mustberoot_init
+
+#
+# Launch application main menu
+#
+while :; do
+ dialog_menu_main
+ retval=$?
+ mtag=$( f_dialog_menutag )
+
+ [ $retval -eq 0 ] || f_die
+
+ case "$mtag" in
+ 1) # Add From List
+ # Loop for easy return
+ while :; do
+ f_dialog_input_rclist
+ retval=$?
+ mtag=$( f_dialog_menutag )
+
+ [ $retval -eq 0 ] || break
+
+ case "$mtag" in
+ "X $msg_exit" ) break ;;
+ *) # Anything else is a directive
+ rcvar="${mtag# }"
+ $BSDCFG_LIBE/$APP_DIR/rcedit \
+ ${USE_XDIALOG:+-X} \
+ "$rcvar" || continue
+ esac
+ break
+ done
+ [ $retval -eq 0 ] || continue
+ ;;
+ 2) # Add Custom
+ f_dialog_input_rcvar || continue
+ $BSDCFG_LIBE/$APP_DIR/rcedit ${USE_XDIALOG:+-X} "$rcvar" ||
+ continue
+ ;;
+ esac
+done
+
+exit $SUCCESS
+
+################################################################################
+# END
+################################################################################
diff --git a/usr.sbin/bsdconfig/startup/rcconf b/usr.sbin/bsdconfig/startup/rcconf
new file mode 100755
index 0000000..4fb5859
--- /dev/null
+++ b/usr.sbin/bsdconfig/startup/rcconf
@@ -0,0 +1,251 @@
+#!/bin/sh
+#-
+# Copyright (c) 2012 Devin Teske
+# All Rights Reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in the
+# documentation and/or other materials provided with the distribution.
+#
+# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING BUT NOT LIMITED TO, THE
+# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+# DAMAGES (INLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+# SUCH DAMAGE.
+#
+# $FreeBSD$
+#
+############################################################ INCLUDES
+
+BSDCFG_SHARE="/usr/share/bsdconfig"
+. $BSDCFG_SHARE/common.subr || exit 1
+f_include $BSDCFG_SHARE/dialog.subr
+f_include $BSDCFG_SHARE/mustberoot.subr
+f_include $BSDCFG_SHARE/sysrc.subr
+f_include $BSDCFG_SHARE/startup/rcconf.subr
+
+BSDCFG_LIBE="/usr/libexec/bsdconfig" APP_DIR="140.startup"
+f_include_lang $BSDCFG_LIBE/$APP_DIR/include/messages.subr
+
+ipgm=$( f_index_menu_selection $BSDCFG_LIBE/$APP_DIR/INDEX "$pgm" )
+[ $? -eq $SUCCESS -a "$ipgm" ] && pgm="$ipgm"
+
+############################################################ GLOBALS
+
+#
+# Global map/menu-list for the main menu
+#
+RCCONF_MAP=
+_RCCONF_MAP=
+RCCONF_MENU_LIST=
+
+#
+# Options
+#
+# Inherit SHOW_DESC value if set, otherwise default to 1
+[ "${SHOW_DESC+set}" ] || SHOW_DESC=1
+# Selectively inherit SHOW_* value (in order of preference)
+if [ "$SHOW_DEFAULT_VALUE" ]; then
+ SHOW_DEFAULT_VALUE=1
+ SHOW_CONFIGURED=
+ SHOW_VALUE=
+elif [ "$SHOW_CONFIGURED" ]; then
+ SHOW_DEFAULT_VALUE=
+ SHOW_CONFIGURED=1
+ SHOW_VALUE=
+else
+ SHOW_DEFAULT_VALUE=
+ SHOW_CONFIGURED=
+ SHOW_VALUE=1
+fi
+
+############################################################ FUNCTIONS
+
+# dialog_menu_main
+#
+# Display the dialog(1)-based application main menu.
+#
+dialog_menu_main()
+{
+ local size
+ local hline="$hline_arrows_tab_enter"
+ local prompt=""
+
+ RCCONF_MENU_LIST="
+ 'X $msg_exit' '$msg_exit_desc'
+ ${SHOW_DESC:+'$msg_exit_help'}
+ '> $msg_add_new' '$msg_add_new_desc'
+ ${SHOW_DESC:+'$msg_add_new_help'}
+ '> $msg_delete' '$msg_delete_desc'
+ ${SHOW_DESC:+'$msg_delete_help'}
+ ${USE_XDIALOG:+
+ '> $msg_view_details' '$msg_view_details_desc'
+ ${SHOW_DESC:+'$msg_view_details_help'}
+ }
+ " # END-QUOTE
+
+ if [ ! "$_RCCONF_MAP" ]; then
+ # Genreate RCCONF_MAP of `var desc ...' per-line
+ f_dialog_info "$msg_creating_rcconf_map"
+ RCCONF_MAP=$( f_startup_rcconf_map )
+ export RCCONF_MAP
+ # Generate _${var}_desc variables from $RCCONF_MAP
+ f_startup_rcconf_map_expand
+ export _RCCONF_MAP=1
+ fi
+
+ # Show infobox for modes that take a while to calculate/display
+ [ "$SHOW_DEFAULT_VALUE" -o "$SHOW_CONFIGURED" ] &&
+ f_dialog_info "$msg_creating_menu_list"
+
+ RCCONF_MENU_LIST="$RCCONF_MENU_LIST $(
+ . "$RC_DEFAULTS" > /dev/null
+ source_rc_confs > /dev/null
+ var_list=$( f_startup_rcconf_list )
+ for var in $var_list; do
+ eval export $var
+ [ "$SHOW_DEFAULT_VALUE" ] && export \
+ _${var}_default="$( f_sysrc_get_default $var )"
+ [ "$SHOW_CONFIGURED" ] && export \
+ _${var}_file="$( f_sysrc_find $var )"
+ done
+ export SHOW_VALUE SHOW_DESC SHOW_DEFAULT_VALUE SHOW_CONFIGURED
+ export msg_default_value
+ echo "$var_list" | awk '
+ BEGIN {
+ prefix = ""
+ }
+ {
+ cur_prefix = tolower(substr($1, 1, 1))
+ printf "'\''"
+ if ( prefix != cur_prefix )
+ prefix = cur_prefix
+ else
+ printf " "
+ var = $1
+ printf "%s'\'' '\''", var
+ if ( ENVIRON["SHOW_DEFAULT_VALUE"] ) {
+ default = ENVIRON["_" var "_default"]
+ gsub(/'\''/, "'\''\\'\'\''", default)
+ value = ENVIRON[var]
+ gsub(/'\''/, "'\''\\'\'\''", value)
+ printf ENVIRON["msg_default_value"] "; %s",
+ default, value
+ } else if ( ENVIRON["SHOW_CONFIGURED"] ) {
+ printf "%s", ENVIRON["_" var "_file"]
+ } else { # SHOW_VALUE (default behavior)
+ value = ENVIRON[var]
+ gsub(/'\''/, "'\''\\'\'\''", value)
+ printf "%s", value
+ }
+ printf "'\''"
+ if ( ENVIRON["SHOW_DESC"] ) {
+ desc = ENVIRON["_" var "_desc"]
+ gsub(/'\''/, "'\''\\'\'\''", desc)
+ printf " '\''%s'\''", desc
+ }
+ printf "\n"
+ }'
+ )"
+
+ set -f # noglob
+
+ size=$( eval f_dialog_menu_${SHOW_DESC:+with_help_}size \
+ \"\$DIALOG_TITLE\" \
+ \"\$DIALOG_BACKTITLE\" \
+ \"\$prompt\" \
+ \"\$hline\" \
+ $RCCONF_MENU_LIST )
+
+ local dialog_menu
+ dialog_menu=$( eval $DIALOG \
+ --clear --title \"\$DIALOG_TITLE\" \
+ --backtitle \"\$DIALOG_BACKTITLE\" \
+ --hline \"\$hline\" \
+ --ok-label \"\$msg_ok\" \
+ --cancel-label \"\$msg_cancel\" \
+ --help-button \
+ --help-label \"\$msg_details\" \
+ ${SHOW_DESC:+--item-help} \
+ --menu \"\$prompt\" $size \
+ $RCCONF_MENU_LIST \
+ 2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD
+ )
+ local retval=$?
+ setvar DIALOG_MENU_$$ "$dialog_menu"
+ return $retval
+}
+
+############################################################ MAIN
+
+# Incorporate rc-file if it exists
+[ -f "$HOME/.bsdconfigrc" ] && f_include "$HOME/.bsdconfigrc"
+
+#
+# Process command-line arguments
+#
+while getopts hSX flag; do
+ case "$flag" in
+ h|\?) f_usage $BSDCFG_LIBE/$APP_DIR/USAGE "PROGRAM_NAME" "$pgm";;
+ esac
+done
+shift $(( $OPTIND - 1 ))
+
+#
+# Initialize
+#
+f_dialog_init
+f_dialog_title "$msg_view_edit_startup_configuration"
+f_dialog_backtitle "${ipgm:+bsdconfig }$pgm"
+f_mustberoot_init
+
+while :; do
+ dialog_menu_main
+ retval=$?
+ mtag=$( f_dialog_menutag )
+
+ if [ "$USE_XDIALOG" ]; then
+ case "$mtag" in
+ "> $msg_view_details")
+ f_dialog_input_view_details
+ continue
+ esac
+ elif [ $retval -eq 2 ]; then
+ # The ``Help'' button (labeled "Details") was pressed
+ f_dialog_input_view_details
+ continue
+ fi
+
+ [ $retval -eq 0 ] || f_die
+
+ case "$mtag" in
+ "X $msg_exit") break ;;
+ "> $msg_add_new")
+ $BSDCFG_LIBE/$APP_DIR/rcadd ${USE_XDIALOG:+-X}
+ ;;
+ "> $msg_delete")
+ # rcdelete has a similar interface that can inherit the below:
+ export SHOW_VALUE SHOW_DESC SHOW_DEFAULT_VALUE SHOW_CONFIGURED
+ $BSDCFG_LIBE/$APP_DIR/rcdelete ${USE_XDIALOG:+-X}
+ ;;
+ *) # Anything else is a variable to edit
+ $BSDCFG_LIBE/$APP_DIR/rcedit ${USE_XDIALOG:+-X} "${mtag# }"
+ esac
+done
+
+exit $SUCCESS
+
+################################################################################
+# END
+################################################################################
diff --git a/usr.sbin/bsdconfig/startup/rcdelete b/usr.sbin/bsdconfig/startup/rcdelete
new file mode 100755
index 0000000..b431d88
--- /dev/null
+++ b/usr.sbin/bsdconfig/startup/rcdelete
@@ -0,0 +1,365 @@
+#!/bin/sh
+#-
+# Copyright (c) 2012 Devin Teske
+# All Rights Reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in the
+# documentation and/or other materials provided with the distribution.
+#
+# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING BUT NOT LIMITED TO, THE
+# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+# DAMAGES (INLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+# SUCH DAMAGE.
+#
+# $FreeBSD$
+#
+############################################################ INCLUDES
+
+BSDCFG_SHARE="/usr/share/bsdconfig"
+. $BSDCFG_SHARE/common.subr || exit 1
+f_include $BSDCFG_SHARE/dialog.subr
+f_include $BSDCFG_SHARE/mustberoot.subr
+f_include $BSDCFG_SHARE/sysrc.subr
+f_include $BSDCFG_SHARE/startup/rcconf.subr
+
+BSDCFG_LIBE="/usr/libexec/bsdconfig" APP_DIR="140.startup"
+f_include_lang $BSDCFG_LIBE/$APP_DIR/include/messages.subr
+
+ipgm=$( f_index_menu_selection $BSDCFG_LIBE/$APP_DIR/INDEX "$pgm" )
+[ $? -eq $SUCCESS -a "$ipgm" ] && pgm="$ipgm"
+
+############################################################ GLOBALS
+
+#
+# Global map/menu-list for the main menu
+#
+RCCONF_MAP=
+_RCCONF_MAP=
+RCCONF_MENU_LIST=
+
+#
+# Options
+#
+# Inherit SHOW_DESC value if set, otherwise default to 1
+[ "${SHOW_DESC+set}" ] || SHOW_DESC=1
+# Selectively inherit SHOW_* value (in order of preference)
+if [ "$SHOW_DEFAULT_VALUE" ]; then
+ SHOW_DEFAULT_VALUE=1
+ SHOW_CONFIGURED=
+ SHOW_VALUE=
+elif [ "$SHOW_CONFIGURED" ]; then
+ SHOW_DEFAULT_VALUE=
+ SHOW_CONFIGURED=1
+ SHOW_VALUE=
+else
+ SHOW_DEFAULT_VALUE=
+ SHOW_CONFIGURED=
+ SHOW_VALUE=1
+fi
+
+############################################################ FUNCTIONS
+
+# dialog_menu_main
+#
+# Display the dialog(1)-based application main menu.
+#
+dialog_menu_main()
+{
+ local size
+ local hline="$hline_arrows_tab_enter"
+ local prompt=""
+
+ RCCONF_MENU_LIST="
+ 'X $msg_exit_cancel' '$msg_exit_cancel_desc'
+ ${SHOW_DESC:+'$msg_exit_cancel_help'}
+ '> $msg_delete_selected' '$msg_delete_selected_desc'
+ ${SHOW_DESC:+'$msg_delete_selected_help'}
+ '> $msg_all' '$msg_all_desc'
+ ${SHOW_DESC:+'$msg_all_help'}
+ '> $msg_none' '$msg_none_desc'
+ ${SHOW_DESC:+'$msg_none_help'}
+ ${USE_XDIALOG:+
+ '> $msg_view_details' '$msg_view_details_desc'
+ ${SHOW_DESC:+'$msg_view_details_help'}
+ }
+ " # END-QUOTE
+
+ if [ ! "$_RCCONF_MAP" ]; then
+ # Genreate RCCONF_MAP of `var desc ...' per-line
+ f_dialog_info "$msg_creating_rcconf_map"
+ RCCONF_MAP=$( f_startup_rcconf_map )
+ export RCCONF_MAP
+ # Generate _${var}_desc variables from $RCCONF_MAP
+ f_startup_rcconf_map_expand
+ export _RCCONF_MAP=1
+ fi
+
+ # Show infobox for modes that take a while to calculate/display
+ [ "$SHOW_DEFAULT_VALUE" -o "$SHOW_CONFIGURED" ] &&
+ f_dialog_info "$msg_creating_menu_list"
+
+ RCCONF_MENU_LIST="$RCCONF_MENU_LIST $(
+ . "$RC_DEFAULTS" > /dev/null
+ source_rc_confs > /dev/null
+ var_list=$( f_startup_rcconf_list )
+ for var in $var_list; do
+ eval export $var
+ [ "$SHOW_DEFAULT_VALUE" ] && export \
+ _${var}_default="$( f_sysrc_get_default $var )"
+ [ "$SHOW_CONFIGURED" ] && export \
+ _${var}_file="$( f_sysrc_find $var )"
+ done
+ export SHOW_VALUE SHOW_DESC SHOW_DEFAULT_VALUE SHOW_CONFIGURED
+ export msg_default_value
+ echo "$var_list" | awk '
+ BEGIN {
+ prefix = ""
+ }
+ {
+ cur_prefix = tolower(substr($1, 1, 1))
+ printf "'\''"
+ if ( prefix != cur_prefix )
+ prefix = cur_prefix
+ else
+ printf " "
+ var = $1
+ printf "%s'\'' '\''[", var
+ if ( ENVIRON["_" var "_delete"] )
+ printf "X"
+ else
+ printf " "
+ printf "] "
+ if ( ENVIRON["SHOW_DEFAULT_VALUE"] ) {
+ default = ENVIRON["_" var "_default"]
+ gsub(/'\''/, "'\''\\'\'\''", default)
+ value = ENVIRON[var]
+ gsub(/'\''/, "'\''\\'\'\''", value)
+ printf ENVIRON["msg_default_value"] "; %s",
+ default, value
+ } else if ( ENVIRON["SHOW_CONFIGURED"] ) {
+ printf "%s", ENVIRON["_" var "_file"]
+ } else { # SHOW_VALUE (default behavior)
+ value = ENVIRON[var]
+ gsub(/'\''/, "'\''\\'\'\''", value)
+ printf "%s", value
+ }
+ printf "'\''"
+ if ( ENVIRON["SHOW_DESC"] ) {
+ desc = ENVIRON["_" var "_desc"]
+ gsub(/'\''/, "'\''\\'\'\''", desc)
+ printf " '\''%s'\''", desc
+ }
+ printf "\n"
+ }'
+ )"
+
+ set -f # noglob
+
+ size=$( eval f_dialog_menu_${SHOW_DESC:+with_help_}size \
+ \"\$DIALOG_TITLE\" \
+ \"\$DIALOG_BACKTITLE\" \
+ \"\$prompt\" \
+ \"\$hline\" \
+ $RCCONF_MENU_LIST )
+
+ local dialog_menu
+ dialog_menu=$( eval $DIALOG \
+ --clear --title \"\$DIALOG_TITLE\" \
+ --backtitle \"\$DIALOG_BACKTITLE\" \
+ --hline \"\$hline\" \
+ --ok-label \"\$msg_ok\" \
+ --cancel-label \"\$msg_cancel\" \
+ --help-button \
+ --help-label \"\$msg_details\" \
+ ${SHOW_DESC:+--item-help} \
+ --menu \"\$prompt\" $size \
+ $RCCONF_MENU_LIST \
+ 2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD
+ )
+ local retval=$?
+ setvar DIALOG_MENU_$$ "$dialog_menu"
+ return $retval
+}
+
+# dialog_menu_delete $var1 [$var2 ...]
+#
+# Get the user's blessing to delete one or more variables.
+# if (and only-if) the user confirms (does not press ESC or Cancel/NO).
+#
+dialog_menu_delete()
+{
+ local size
+ local hline="$hline_arrows_tab_enter"
+ local prompt="$msg_are_you_sure_you_want_delete_the_following"
+ local var_list menu_list
+
+ [ $# -ge 1 ] || return $FAILURE
+
+ if [ $# -eq 1 ]; then
+ msg=$( printf "$msg_are_you_sure_you_want_to_delete" \
+ "$delete_vars" )
+ f_dialog_noyes "$msg"
+ return $?
+ fi
+
+ var_list=$( for var in $*; do echo "$var"; done | sort -u )
+ menu_list=$(
+ . "$RC_DEFAULTS"
+ source_rc_confs
+ echo "$var_list" | awk '
+ BEGIN {
+ prefix = ""
+ }
+ {
+ cur_prefix = tolower(substr($1, 1, 1))
+ printf "'\''"
+ if ( prefix != cur_prefix )
+ prefix = cur_prefix
+ else
+ printf " "
+ var = $1
+ printf "%s'\'' '\'\''\n", var
+ }'
+ )
+
+ size=$( eval f_dialog_menu_size \
+ \"\$DIALOG_TITLE\" \
+ \"\$DIALOG_BACKTITLE\" \
+ \"\$prompt\" \
+ \"\$hline\" \
+ $menu_list )
+
+ local defaultno="defaultno"
+ [ "$USE_XDIALOG" ] && defaultno="default-no"
+
+ local dialog_menu
+ dialog_menu=$( eval $DIALOG \
+ --clear --title \"\$DIALOG_TITLE\" \
+ --backtitle \"\$DIALOG_BACKTITLE\" \
+ --hline \"\$hline\" \
+ --$defaultno \
+ --ok-label \"\$msg_ok\" \
+ --cancel-label \"\$msg_cancel\" \
+ --menu \"\$prompt\" $size \
+ $menu_list \
+ 2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD
+ )
+ local retval=$?
+ setvar DIALOG_MENU_$$ "$dialog_menu"
+ return $retval
+}
+
+############################################################ MAIN
+
+# Incorporate rc-file if it exists
+[ -f "$HOME/.bsdconfigrc" ] && f_include "$HOME/.bsdconfigrc"
+
+#
+# Process command-line arguments
+#
+while getopts hSX flag; do
+ case "$flag" in
+ h|\?) f_usage $BSDCFG_LIBE/$APP_DIR/USAGE "PROGRAM_NAME" "$pgm";;
+ esac
+done
+shift $(( $OPTIND - 1 ))
+
+#
+# Initialize
+#
+f_dialog_init
+f_dialog_title "$msg_delete_startup_directives"
+f_dialog_backtitle "${ipgm:+bsdconfig }$pgm"
+f_mustberoot_init
+
+while :; do
+ dialog_menu_main
+ retval=$?
+ mtag=$( f_dialog_menutag )
+
+ if [ "$USE_XDIALOG" ]; then
+ case "$mtag" in
+ "> $msg_view_details")
+ f_dialog_input_view_details
+ continue
+ esac
+ elif [ $retval -eq 2 ]; then
+ # The ``Help'' button (labeled "Details") was pressed
+ f_dialog_input_view_details
+ continue
+ fi
+
+ [ $retval -eq 0 ] || f_die
+
+ case "$mtag" in
+ "X $msg_exit_cancel") break ;;
+ "> $msg_delete_selected")
+ delete_vars=
+ for var in $( f_startup_rcconf_list ); do
+ [ "$( eval echo \$_${var}_delete )" ] || continue
+ delete_vars="$delete_vars${delete_vars:+ }$var"
+ done
+ unset var # no longer needed
+ if dialog_menu_delete $delete_vars; then
+ f_dialog_title "$msg_info"
+ f_dialog_info "$msg_deleting_selected_directives"
+ f_dialog_title_restore
+ for var in $delete_vars; do
+ err=$( f_sysrc_delete $var 2>&1 )
+ if [ $? -ne $SUCCESS ]; then
+ f_show_msg "%s\n" "$err"
+ break
+ fi
+ done
+ unset var # no longer needed
+ fi
+ ;;
+ "> $msg_all")
+ for var in $( f_startup_rcconf_list ); do
+ setvar _${var}_delete 1
+ export _${var}_delete
+ done
+ unset var # no longer needed
+ ;;
+ "> $msg_none")
+ var_list=$( set | awk -F= "
+ /$STARTUP_RCCONF_REGEX/ {
+ if (\$1 ~ /^_[[:alpha:]_][[:alnum:]_]*_delete/)
+ print \$1
+ }"
+ )
+ [ "$var_list" ] && unset $var_list
+ unset var_list # no longer needed
+ ;;
+ *) # Anything else is a variable to edit
+ var="${mtag# }"
+
+ # Toggle the state-variable and loop back to menu
+ if eval [ \"\${_${var}_delete+set}\" ]; then
+ unset _${var}_delete
+ else
+ setvar _${var}_delete 1
+ export _${var}_delete
+ fi
+ unset var # no longer needed
+ esac
+done
+
+exit $SUCCESS
+
+################################################################################
+# END
+################################################################################
diff --git a/usr.sbin/bsdconfig/startup/rcedit b/usr.sbin/bsdconfig/startup/rcedit
new file mode 100755
index 0000000..c060fcb
--- /dev/null
+++ b/usr.sbin/bsdconfig/startup/rcedit
@@ -0,0 +1,69 @@
+#!/bin/sh
+#-
+# Copyright (c) 2012 Devin Teske
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in the
+# documentation and/or other materials provided with the distribution.
+#
+# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+# SUCH DAMAGE.
+#
+# $FreeBSD$
+#
+############################################################ INCLUDES
+
+BSDCFG_SHARE="/usr/share/bsdconfig"
+. $BSDCFG_SHARE/common.subr || exit 1
+f_include $BSDCFG_SHARE/dialog.subr
+f_include $BSDCFG_SHARE/mustberoot.subr
+f_include $BSDCFG_SHARE/startup/rcedit.subr
+
+BSDCFG_LIBE="/usr/libexec/bsdconfig" APP_DIR="140.startup"
+f_include_lang $BSDCFG_LIBE/$APP_DIR/include/messages.subr
+
+ipgm=$( f_index_menu_selection $BSDCFG_LIBE/$APP_DIR/INDEX "$pgm" )
+[ $? -eq $SUCCESS -a "$ipgm" ] && pgm="$ipgm"
+
+############################################################ MAIN
+
+# Incorporate rc-file if it exists
+[ -f "$HOME/.bsdconfigrc" ] && f_include "$HOME/.bsdconfigrc"
+
+#
+# Process command-line arguments
+#
+while getopts hSX flag; do
+ case "$flag" in
+ h|\?) f_usage $BSDCFG_LIBE/$APP_DIR/USAGE "PROGRAM_NAME" "$pgm";;
+ esac
+done
+shift $(( $OPTIND - 1 ))
+
+#
+# Initialize
+#
+f_dialog_init
+f_dialog_backtitle "${ipgm:+bsdconfig }$pgm"
+f_mustberoot_init
+
+f_dialog_rcedit "$@"
+
+################################################################################
+# END
+################################################################################
diff --git a/usr.sbin/bsdconfig/startup/rcvar b/usr.sbin/bsdconfig/startup/rcvar
new file mode 100755
index 0000000..b7a5229
--- /dev/null
+++ b/usr.sbin/bsdconfig/startup/rcvar
@@ -0,0 +1,205 @@
+#!/bin/sh
+#-
+# Copyright (c) 2012 Devin Teske
+# All Rights Reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in the
+# documentation and/or other materials provided with the distribution.
+#
+# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING BUT NOT LIMITED TO, THE
+# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+# DAMAGES (INLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+# SUCH DAMAGE.
+#
+# $FreeBSD$
+#
+############################################################ INCLUDES
+
+BSDCFG_SHARE="/usr/share/bsdconfig"
+. $BSDCFG_SHARE/common.subr || exit 1
+f_include $BSDCFG_SHARE/dialog.subr
+f_include $BSDCFG_SHARE/mustberoot.subr
+f_include $BSDCFG_SHARE/sysrc.subr
+f_include $BSDCFG_SHARE/startup/rcvar.subr
+
+BSDCFG_LIBE="/usr/libexec/bsdconfig" APP_DIR="140.startup"
+f_include_lang $BSDCFG_LIBE/$APP_DIR/include/messages.subr
+
+ipgm=$( f_index_menu_selection $BSDCFG_LIBE/$APP_DIR/INDEX "$pgm" )
+[ $? -eq $SUCCESS -a "$ipgm" ] && pgm="$ipgm"
+
+############################################################ GLOBALS
+
+#
+# Global map/menu-list for the main menu
+#
+RCVAR_MAP=
+_RCVAR_MAP=
+RCVAR_MENU_LIST=
+
+#
+# Options
+#
+# Inherit SHOW_DESC value if set, otherwise default to 1
+[ "${SHOW_DESC+set}" ] || SHOW_DESC=1
+
+############################################################ FUNCTIONS
+
+# dialog_menu_main
+#
+# Display the dialog(1)-based application main menu.
+#
+dialog_menu_main()
+{
+ local size
+ local hline="$hline_arrows_tab_enter"
+ local prompt=""
+
+ RCVAR_MENU_LIST="
+ 'X $msg_exit' '$msg_exit_this_menu'
+ ${SHOW_DESC:+'$msg_exit_this_menu'}
+ " # END-QUOTE
+
+ if [ ! "$_RCVAR_MAP" ]; then
+ # Genreate RCVAR_MAP of `rcvar dflt script desc ...' per-line
+ f_dialog_info "$msg_creating_rcvar_map"
+ RCVAR_MAP=$( f_startup_rcvar_map )
+ export RCVAR_MAP
+ export _RCVAR_MAP=1
+ fi
+
+ RCVAR_MENU_LIST="$RCVAR_MENU_LIST $(
+ . "$RC_DEFAULTS" > /dev/null
+ source_rc_confs > /dev/null
+ for rcvar in $( echo "$RCVAR_MAP" | awk '{print $1}' ); do
+ eval export $rcvar
+ done
+ export SHOW_DESC msg_default_value
+ echo "$RCVAR_MAP" | awk '
+ BEGIN {
+ prefix = ""
+ rword = "^[[:space:]]*[^[:space:]]*[[:space:]]*"
+ }
+ {
+ cur_prefix = tolower(substr($1, 1, 1))
+ printf "'\''"
+ if ( prefix != cur_prefix )
+ prefix = cur_prefix
+ else
+ printf " "
+ rcvar = $1
+ default = $2
+ script = $3
+ printf "%s'\'' '\''", rcvar
+ if ( ENVIRON[rcvar] ~ /[Yy][Ee][Ss]/ )
+ printf "[X] "
+ else
+ printf "[ ] "
+ printf "%s; " ENVIRON["msg_default_value"],
+ script, default
+ printf "'\''"
+ if ( ENVIRON["SHOW_DESC"] ) {
+ desc = $0
+ sub(rword, "", desc)
+ sub(rword, "", desc)
+ sub(rword, "", desc)
+ gsub(/'\''/, "'\''\\'\'\''", desc)
+ printf " '\''%s'\''", desc
+ }
+ printf "\n"
+ }'
+ )"
+
+ set -f # noglob
+
+ size=$( eval f_dialog_menu_${SHOW_DESC:+with_help_}size \
+ \"\$DIALOG_TITLE\" \
+ \"\$DIALOG_BACKTITLE\" \
+ \"\$prompt\" \
+ \"\$hline\" \
+ $RCVAR_MENU_LIST )
+
+ local dialog_menu
+ dialog_menu=$( eval $DIALOG \
+ --clear --title \"\$DIALOG_TITLE\" \
+ --backtitle \"\$DIALOG_BACKTITLE\" \
+ --hline \"\$hline\" \
+ --ok-label \"\$msg_ok\" \
+ --cancel-label \"\$msg_cancel\" \
+ ${SHOW_DESC:+--item-help} \
+ --menu \"\$prompt\" $size \
+ $RCVAR_MENU_LIST \
+ 2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD
+ )
+ local retval=$?
+ setvar DIALOG_MENU_$$ "$dialog_menu"
+ return $retval
+}
+
+############################################################ MAIN
+
+# Incorporate rc-file if it exists
+[ -f "$HOME/.bsdconfigrc" ] && f_include "$HOME/.bsdconfigrc"
+
+#
+# Process command-line arguments
+#
+while getopts hSX flag; do
+ case "$flag" in
+ h|\?) f_usage $BSDCFG_LIBE/$APP_DIR/USAGE "PROGRAM_NAME" "$pgm";;
+ esac
+done
+shift $(( $OPTIND - 1 ))
+
+#
+# Initialize
+#
+f_dialog_init
+f_dialog_title "$msg_toggle_startup_services"
+f_dialog_backtitle "${ipgm:+bsdconfig }$pgm"
+f_mustberoot_init
+
+while :; do
+ dialog_menu_main
+ retval=$?
+ mtag=$( f_dialog_menutag )
+
+ [ $retval -eq 0 ] || f_die
+
+ case "$mtag" in
+ "X $msg_exit") break ;;
+ *) # Anything else is an rcvar to toggle
+
+ rcvar="${mtag# }"
+ value=$( eval f_dialog_menutag2item${SHOW_DESC:+_with_help} \
+ \"\$mtag\" $RCVAR_MENU_LIST )
+
+ # Determine the new [toggled] value to use
+ case "$value" in
+ "[X]"*) value="NO";;
+ *) value="YES";;
+ esac
+
+ err=$( f_sysrc_set "$rcvar" "$value" 2>&1 ) ||
+ f_show_msg "$err"
+ esac
+done
+
+exit $SUCCESS
+
+################################################################################
+# END
+################################################################################
diff --git a/usr.sbin/bsdconfig/startup/share/Makefile b/usr.sbin/bsdconfig/startup/share/Makefile
new file mode 100644
index 0000000..01c7d03
--- /dev/null
+++ b/usr.sbin/bsdconfig/startup/share/Makefile
@@ -0,0 +1,11 @@
+# $FreeBSD$
+
+NO_OBJ=
+
+FILESDIR= ${SHAREDIR}/bsdconfig/startup
+FILES= rcconf.subr rcedit.subr rcvar.subr
+
+beforeinstall:
+ mkdir -p ${DESTDIR}${FILESDIR}
+
+.include <bsd.prog.mk>
diff --git a/usr.sbin/bsdconfig/startup/share/rcconf.subr b/usr.sbin/bsdconfig/startup/share/rcconf.subr
new file mode 100644
index 0000000..16cb290
--- /dev/null
+++ b/usr.sbin/bsdconfig/startup/share/rcconf.subr
@@ -0,0 +1,477 @@
+if [ ! "$_STARTUP_RCCONF_SUBR" ]; then _STARTUP_RCCONF_SUBR=1
+#
+# Copyright (c) 2006-2012 Devin Teske
+# All Rights Reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in the
+# documentation and/or other materials provided with the distribution.
+#
+# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING BUT NOT LIMITED TO, THE
+# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+# DAMAGES (INLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+# SUCH DAMAGE.
+#
+# $FreeBSD$
+#
+############################################################ INCLUDES
+
+BSDCFG_SHARE="/usr/share/bsdconfig"
+. $BSDCFG_SHARE/common.subr || exit 1
+f_include $BSDCFG_SHARE/sysrc.subr
+
+BSDCFG_LIBE="/usr/libexec/bsdconfig" APP_DIR="140.startup"
+f_include_lang $BSDCFG_LIBE/$APP_DIR/include/messages.subr
+
+############################################################ GLOBALS
+
+#
+# Initialize in-memory cache variables
+#
+STARTUP_RCCONF_MAP=
+_STARTUP_RCCONF_MAP=
+
+#
+# Define what a variable looks like
+#
+STARTUP_RCCONF_REGEX="^[[:alpha:]_][[:alnum:]_]*="
+
+#
+# Default path to on-disk cache file(s)
+#
+STARTUP_RCCONF_MAP_CACHEFILE="/var/run/bsdconfig/startup_rcconf_map.cache"
+
+############################################################ FUNCTIONS
+
+# f_startup_rcconf_list
+#
+# Produce a list of non-default configuration variables configured in the
+# rc.conf(5) collection of files.
+#
+f_startup_rcconf_list()
+{
+ ( # Operate within a sub-shell to protect the parent environment
+ . "$RC_DEFAULTS" > /dev/null
+ f_clean_env --except PATH STARTUP_RCCONF_REGEX rc_conf_files
+ source_rc_confs > /dev/null
+ export _rc_conf_files_file="$( f_sysrc_find rc_conf_files )"
+ export RC_DEFAULTS
+ set | awk -F= "
+ function test_print(var)
+ {
+ if ( var == \"OPTIND\" ) return
+ if ( var == \"PATH\" ) return
+ if ( var == \"RC_DEFAULTS\" ) return
+ if ( var == \"STARTUP_RCCONF_REGEX\" ) return
+ if ( var == \"_rc_conf_files_file\" ) return
+ if ( var == \"rc_conf_files\" )
+ {
+ if ( ENVIRON[\"_rc_conf_files_file\"] == \
+ ENVIRON[\"RC_DEFAULTS\"] ) return
+ }
+ print var
+ }
+ /$STARTUP_RCCONF_REGEX/ { test_print(\$1) }"
+ )
+}
+
+# f_startup_rcconf_map
+#
+# Produce a map (beit from in-memory cache or on-disk cache) of rc.conf(5)
+# variables and their descriptions. The map returned has the following format:
+#
+# var description
+#
+# With each as follows:
+#
+# var the rc.conf(5) variable
+# description description of the variable
+#
+f_startup_rcconf_map()
+{
+ # If the in-memory cached value is available, return it immediately
+ if [ "$_STARTUP_RCCONF_MAP" ]; then
+ echo "$STARTUP_RCCONF_MAP"
+ return $SUCCESS
+ fi
+
+ #
+ # create the in-memory cache (potentially from validated on-disk cache)
+ #
+
+ #
+ # Calculate digest used to determine if the on-disk global persistant
+ # cache file (containing this digest on the first line) is valid and
+ # can be used to quickly populate the cache value for immediate return.
+ #
+ local rc_defaults_digest
+ rc_defaults_digest=$( md5 < "$RC_DEFAULTS" )
+
+ #
+ # Check to see if the global persistant cache file exists
+ #
+ if [ -f "$STARTUP_RCCONF_MAP_CACHEFILE" ]; then
+ #
+ # Attempt to populate the in-memory cache with the (soon to be)
+ # be validated on-disk cache. If validation fails, fall-back to
+ # the current value and provide error exit status.
+ #
+ STARTUP_RCCONF_MAP=$(
+ ( # Get digest as the first word on the first line
+ 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 [ "$digest" = "$rc_defaults_digest" ]; then
+ cat
+ exit $SUCCESS
+ else
+ # Otherwise, return the current value
+ echo "$STARTUP_RCCONF_MAP"
+ exit $FAILURE
+ fi
+ ) < "$STARTUP_RCCONF_MAP_CACHEFILE"
+ )
+ export STARTUP_RCCONF_MAP
+ if [ $? -eq $SUCCESS ]; then
+ export _STARTUP_RCCONF_MAP=1
+ echo "$STARTUP_RCCONF_MAP"
+ return $SUCCESS
+ fi
+ # Otherwise, fall-thru to create in-memory cache from scratch
+ fi
+
+ #
+ # If we reach this point, we need to generate the data from scratch
+ # (and after we do, we'll attempt to create the global persistant
+ # cache file to speed up future executions).
+ #
+
+ STARTUP_RCCONF_MAP=$(
+ f_clean_env --except \
+ PATH \
+ RC_DEFAULTS \
+ STARTUP_RCCONF_REGEX \
+ f_sysrc_desc_awk
+ . "$RC_DEFAULTS"
+
+ # Unset variables we don't want reported
+ unset source_rc_confs_defined
+
+ for var in $( set | awk -F= "
+ function test_print(var)
+ {
+ if ( var == \"OPTIND\" ) return
+ if ( var == \"PATH\" ) return
+ if ( var == \"RC_DEFAULTS\" ) return
+ if ( var == \"STARTUP_RCCONF_REGEX\" ) return
+ if ( var == \"f_sysrc_desc_awk\" ) return
+ print var
+ }
+ /$STARTUP_RCCONF_REGEX/ { test_print(\$1) }
+ " ); do
+ echo $var "$( f_sysrc_desc $var )"
+ done
+ )
+ export STARTUP_RCCONF_MAP
+ export _STARTUP_RCCONF_MAP=1
+ echo "$STARTUP_RCCONF_MAP"
+
+ #
+ # Attempt to create the persistant global cache
+ #
+
+ # Create a new temporary file to write to
+ local tmpfile="$( mktemp -t "$pgm" )"
+ [ "$tmpfile" ] || return $FAILURE
+
+ # Write the temporary file contents
+ echo "$rc_defaults_digest" > "$tmpfile"
+ echo "$STARTUP_RCCONF_MAP" >> "$tmpfile"
+
+ # Finally, move the temporary file into place
+ case "$STARTUP_RCCONF_MAP_CACHEFILE" in
+ */*) f_quietly mkdir -p "${STARTUP_RCCONF_MAP_CACHEFILE%/*}"
+ esac
+ mv "$tmpfile" "$STARTUP_RCCONF_MAP_CACHEFILE"
+}
+
+# f_startup_rcconf_map_expand
+#
+# Expands the map ($RCCONF_MAP) into the shell environment namespace by
+# creating _${var}_desc variables containing the description of each variable
+# encountered.
+#
+# NOTE: Variables are exported for later-required awk(1) ENVIRON visibility.
+#
+f_startup_rcconf_map_expand()
+{
+ eval "$( echo "$RCCONF_MAP" | awk '
+ BEGIN {
+ rword = "^[[:space:]]*[^[:space:]]*[[:space:]]*"
+ }
+ {
+ var = $1
+ desc = $0
+ sub(rword, "", desc)
+ gsub(/'\''/, "'\''\\'\'\''", desc)
+ printf "_%s_desc='\''%s'\''\n", var, desc
+ printf "export _%s_desc\n", var
+ }' )"
+}
+
+# f_dialog_input_view_details
+#
+# Display a menu for selecting which details are to be displayed. The following
+# variables are tracked/modified by the menu/user's selection:
+#
+# SHOW_DESC Show or hide descriptions
+#
+# Mutually exclusive options:
+#
+# SHOW_VALUE Show the value (default; override only)
+# SHOW_VALUE_DEFAULT Show both value and default
+# SHOW_CONFIGURED Show rc.conf(5) file variable is configured in
+#
+# Each variable is treated as a boolean (NULL for false, non-NULL for true).
+#
+# Variables are exported for later-required awk(1) ENVIRON visibility.
+#
+f_dialog_input_view_details()
+{
+ local menu_list size
+ local hline="$hline_arrows_tab_enter"
+ local prompt=""
+
+ local md=" " m1=" " m2=" " m3=" "
+ [ "$SHOW_DESC" ] && md="X"
+ [ "$SHOW_VALUE" ] && m1="*"
+ [ "$SHOW_DEFAULT_VALUE" ] && m2="*"
+ [ "$SHOW_CONFIGURED" ] && m3="*"
+
+ menu_list="
+ 'X $msg_exit' '$msg_exit_this_menu'
+ 'R $msg_reset' '$msg_reset_desc'
+ 'D [$md] $msg_desc' '$msg_desc_desc'
+ '1 ($m1) $msg_show_value' '$msg_show_value_desc'
+ '2 ($m2) $msg_show_default_value' '$msg_show_default_value_desc'
+ '3 ($m3) $msg_show_configured' '$msg_show_configured_desc'
+ " # END-QUOTE
+
+ size=$( eval f_dialog_menu_size \
+ \"\$DIALOG_TITLE\" \
+ \"\$DIALOG_BACKTITLE\" \
+ \"\$prompt\" \
+ \"\$hline\" \
+ $menu_list )
+
+ f_dialog_title "$msg_choose_view_details"
+
+ local dialog_menu
+ dialog_menu=$( eval $DIALOG \
+ --title \"\$DIALOG_TITLE\" \
+ --backtitle \"\$DIALOG_BACKTITLE\" \
+ --hline \"\$hline\" \
+ --ok-label \"\$msg_ok\" \
+ --cancel-label \"\$msg_cancel\" \
+ --menu \"\$prompt\" $size \
+ $menu_list \
+ 2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD
+ )
+
+ local retval=$?
+ setvar DIALOG_MENU_$$ "$dialog_menu"
+ local mtag="$( f_dialog_menutag )"
+
+ f_dialog_title_restore
+
+ [ $retval -eq 0 ] || return $SUCCESS
+ [ "$mtag" = "X $msg_exit" ] && return $SUCCESS
+
+ case "$mtag" in
+ "R $msg_reset")
+ SHOW_VALUE=1
+ SHOW_DESC=1
+ SHOW_DEFAULT_VALUE=
+ SHOW_CONFIGURED=
+ ;;
+ "D [X] $msg_desc") SHOW_DESC= ;;
+ "D [ ] $msg_desc") SHOW_DESC=1 ;;
+ "1 ("?") $msg_show_value")
+ SHOW_VALUE=1
+ SHOW_DEFAULT_VALUE=
+ SHOW_CONFIGURED=
+ ;;
+ "2 ("?") $msg_show_default_value")
+ SHOW_VALUE=
+ SHOW_DEFAULT_VALUE=1
+ SHOW_CONFIGURED=
+ ;;
+ "3 ("?") $msg_show_configured")
+ SHOW_VALUE=
+ SHOW_DEFAULT_VALUE=
+ SHOW_CONFIGURED=1
+ ;;
+ esac
+}
+
+# f_dialog_input_rclist
+#
+# Presents a menu of rc.conf(5) defaults (with, or without descriptions). This
+# function should be treated like a call to dialog(1) (the exit status should
+# be captured and f_dialog_menutag() should be used to clean-up and get the
+# user's response).
+#
+f_dialog_input_rclist()
+{
+ local size
+ local hline="$hline_arrows_tab_enter"
+ local prompt="$msg_please_select_an_rcconf_directive"
+ local menu_list
+
+ menu_list="
+ 'X $msg_exit' '' ${SHOW_DESC:+'$msg_exit_help'}
+ " # END-QUOTE
+
+ if [ ! "$_RCCONF_MAP" ]; then
+ # Generate RCCONF_MAP of `var desc ...' per-line
+ f_dialog_info "$msg_creating_rcconf_map"
+ RCCONF_MAP=$( f_startup_rcconf_map )
+ export RCCONF_MAP
+ # Generate _${var}_desc variables from $RCCONF_MAP
+ f_startup_rcconf_map_expand
+ export _RCCONF_MAP=1
+ fi
+
+ menu_list="$menu_list $(
+ export SHOW_DESC
+ echo "$RCCONF_MAP" | awk '
+ BEGIN {
+ prefix = ""
+ rword = "^[[:space:]]*[^[:space:]]*[[:space:]]*"
+ }
+ {
+ cur_prefix = tolower(substr($1, 1, 1))
+ printf "'\''"
+ if ( prefix != cur_prefix )
+ prefix = cur_prefix
+ else
+ printf " "
+ rcvar = $1
+ printf "%s'\'' '\'\''", rcvar
+ if ( ENVIRON["SHOW_DESC"] ) {
+ desc = $0
+ sub(rword, "", desc)
+ gsub(/'\''/, "'\''\\'\'\''", desc)
+ printf " '\''%s'\''", desc
+ }
+ printf "\n"
+ }'
+ )"
+
+ set -f # noglob
+
+ size=$( eval f_dialog_menu_${SHOW_DESC:+with_help_}size \
+ \"\$DIALOG_TITLE\" \
+ \"\$DIALOG_BACKTITLE\" \
+ \"\$prompt\" \
+ \"\$hline\" \
+ $menu_list )
+
+ local dialog_menu
+ dialog_menu=$( eval $DIALOG \
+ --title \"\$DIALOG_TITLE\" \
+ --backtitle \"\$DIALOG_BACKTITLE\" \
+ --hline \"\$hline\" \
+ --ok-label \"\$msg_ok\" \
+ --cancel-label \"\$msg_cancel\" \
+ ${SHOW_DESC:+--item-help} \
+ --menu \"\$prompt\" $size \
+ $menu_list \
+ 2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD
+ )
+ local retval=$?
+ setvar DIALOG_MENU_$$ "$dialog_menu"
+ return $retval
+}
+
+# f_dialog_input_rcvar [$init]
+#
+# Allows the user to enter the name for a new rc.conf(5) variable. If the user
+# does not cancel or press ESC, the $rcvar variable will hold the newly-
+# configured value upon return.
+#
+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"
+ 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
+
+ # Check for invalid entry (1of2)
+ if ! echo "$_input" | grep -q "^[[:alpha:]_]"; then
+ f_show_msg "$msg_rcvar_must_start_with"
+ continue
+ fi
+
+ # Check for invalid entry (2of2)
+ if ! echo "$_input" | grep -q "^[[:alpha:]_][[:alnum:]_]*$"
+ then
+ f_show_msg "$msg_rcvar_contains_invalid_chars"
+ continue
+ fi
+
+ rcvar="$_input"
+ break
+ done
+
+ f_dprintf "f_dialog_input_rcvar: rcvar->[$rcvar]"
+
+ return $SUCCESS
+}
+
+fi # ! $_STARTUP_RCCONF_SUBR
diff --git a/usr.sbin/bsdconfig/startup/share/rcedit.subr b/usr.sbin/bsdconfig/startup/share/rcedit.subr
new file mode 100644
index 0000000..909fef2
--- /dev/null
+++ b/usr.sbin/bsdconfig/startup/share/rcedit.subr
@@ -0,0 +1,109 @@
+if [ ! "$_STARTUP_RCEDIT_SUBR" ]; then _STARTUP_RCEDIT_SUBR=1
+#
+# Copyright (c) 2012 Devin Teske
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in the
+# documentation and/or other materials provided with the distribution.
+#
+# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+# SUCH DAMAGE.
+#
+# $FreeBSD$
+#
+############################################################ INCLUDES
+
+BSDCFG_SHARE="/usr/share/bsdconfig"
+. $BSDCFG_SHARE/common.subr || exit 1
+f_include $BSDCFG_SHARE/dialog.subr
+f_include $BSDCFG_SHARE/sysrc.subr
+
+BSDCFG_LIBE="/usr/libexec/bsdconfig" APP_DIR="140.startup"
+f_include_lang $BSDCFG_LIBE/$APP_DIR/include/messages.subr
+
+############################################################ FUNCTIONS
+
+# f_dialog_rcedit $var [[--] $init ...]
+#
+# Allow the user to enter a new value for a given rc.conf(5) variable. If the
+# user does not cancel or press ESC, the variable will be saved without
+# confirmation.
+#
+# If the second argument is non-NULL, it will be processed as the initial text
+# to be displayed, overriding the default behavior to display the currently
+# configured value as the initial text.
+#
+# If instead the second argument is "--", then the third argument (NULL or
+# otherwise) will be treated as the initial text.
+#
+f_dialog_rcedit()
+{
+ local msg size retval var="$1" _input
+ local hline="$hline_alnum_punc_tab_enter"
+
+ msg=$( printf "$msg_please_enter_a_new_value" \
+ "$var" "$( f_sysrc_get_default "$var" )" )
+
+ shift 1 # var
+ if [ "$1" ]; then
+ [ "$1" = "--" ] && shift 1 # --
+ _input="$1"
+ else
+ _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
+
+ # 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]"
+
+ err=$( f_sysrc_set "$var" "$_input" 2>&1 ) ||
+ f_show_msg "$err"
+}
+
+fi # ! $_STARTUP_RCEDIT_SUBR
diff --git a/usr.sbin/bsdconfig/startup/share/rcvar.subr b/usr.sbin/bsdconfig/startup/share/rcvar.subr
new file mode 100644
index 0000000..3cd60e8
--- /dev/null
+++ b/usr.sbin/bsdconfig/startup/share/rcvar.subr
@@ -0,0 +1,206 @@
+if [ ! "$_STARTUP_RCVAR_SUBR" ]; then _STARTUP_RCVAR_SUBR=1
+#
+# Copyright (c) 2006-2012 Devin Teske
+# All Rights Reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in the
+# documentation and/or other materials provided with the distribution.
+#
+# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING BUT NOT LIMITED TO, THE
+# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+# DAMAGES (INLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+# SUCH DAMAGE.
+#
+# $FreeBSD$
+#
+############################################################ INCLUDES
+
+BSDCFG_SHARE="/usr/share/bsdconfig"
+. $BSDCFG_SHARE/common.subr || exit 1
+f_include $BSDCFG_SHARE/sysrc.subr
+
+############################################################ CONFIGURATION
+
+#
+# Default path to the `/etc/rc.d' directory where service(8) scripts are stored
+#
+: ${ETC_RC_D:=/etc/rc.d}
+
+#
+# Default path to `/etc/rc.subr' (for find_local_scripts_new())
+#
+: ${ETC_RC_SUBR:=/etc/rc.subr}
+
+############################################################ GLOBALS
+
+#
+# Initialize in-memory cache variables
+#
+STARTUP_RCVAR_MAP=
+_STARTUP_RCVAR_MAP=
+
+#
+# Define what an rcvar looks like
+#
+STARTUP_RCVAR_REGEX='[[:alpha:]_][[:alnum:]_]*="([Yy][Ee][Ss]|[Nn][Oo])"'
+
+#
+# Default path to on-disk cache file(s)
+#
+STARTUP_RCVAR_MAP_CACHEFILE="/var/run/bsdconfig/startup_rcvar_map.cache"
+
+############################################################ FUNCTIONS
+
+# f_startup_rcvar_map
+#
+# Produce a map (beit from in-memory cache or on-disk cache) of rc.d scripts
+# and their associated rcvar's. The map returned has the following format:
+#
+# rcvar default script description
+#
+# With each as follows:
+#
+# rcvar the variable used to enable this rc.d script
+# default default value for this variable
+# script the rc.d script in-question
+# description description of the variable from rc.conf(5) defaults
+#
+f_startup_rcvar_map()
+{
+ # If the in-memory cached value is available, return it immediately
+ if [ "$_STARTUP_RCVAR_MAP" ]; then
+ echo "$STARTUP_RCVAR_MAP"
+ return $SUCCESS
+ fi
+
+ #
+ # create the in-memory cache (potentially from validated on-disk cache)
+ #
+
+ # Get a list of /etc/rc.d scripts ...
+ local file rc_script_list=
+ for file in "$ETC_RC_D"/*; do
+ [ -f "$file" ] || continue
+ [ -x "$file" ] || continue
+ rc_script_list="$rc_script_list${rc_script_list:+ }$file"
+ done
+ # ... and /usr/local/etc/rc.d scripts
+ rc_script_list="$rc_script_list${rc_script_list:+ }$(
+ local_startup=$( f_sysrc_get local_startup )
+ f_include "$ETC_RC_SUBR"
+ find_local_scripts_new
+ echo $local_rc
+ )"
+
+ #
+ # 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" &&
+ cksum "$RC_DEFAULTS" $rc_script_list | md5 )
+
+ #
+ # Check to see if the global persistant cache file exists
+ #
+ if [ -f "$STARTUP_RCVAR_MAP_CACHEFILE" ]; then
+ #
+ # Attempt to populate the in-memory cache with the (soon to be)
+ # be validated on-disk cache. If validation fails, fall-back to
+ # the current value and provide error exit status.
+ #
+ STARTUP_RCVAR_MAP=$(
+ ( # Get digest as the first word on the first line
+ 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 [ "$digest" = "$rc_script_list_digest" ]; then
+ cat
+ exit $SUCCESS
+ else
+ # Otherwise, return the current value
+ echo "$STARTUP_RCVAR_MAP"
+ exit $FAILURE
+ fi
+ ) < "$STARTUP_RCVAR_MAP_CACHEFILE"
+ )
+ export STARTUP_RCVAR_MAP
+ if [ $? -eq $SUCCESS ]; then
+ export _STARTUP_RCVAR_MAP=1
+ echo "$STARTUP_RCVAR_MAP"
+ return $SUCCESS
+ fi
+ # Otherwise, fall-through to create in-memory cache from scratch
+ fi
+
+ #
+ # If we reach this point, we need to generate the data from scratch
+ # (and after we do, we'll attempt to create the global persistant
+ # cache file to speed up future executions).
+ #
+
+ STARTUP_RCVAR_MAP=$(
+ for script in $rc_script_list; do
+ rcvar_list=$( $script rcvar | awk -F= \
+ -v script="$script" '
+ /^'"$STARTUP_RCVAR_REGEX"'/ {
+ if ( $2 ~ /^"[Yy][Ee][Ss]"$/ )
+ print $1 ",YES"
+ else
+ print $1 ",NO"
+ }' )
+ for entry in $rcvar_list; do
+ rcvar="${entry%%,*}"
+ rcvar_default=$( f_sysrc_get_default "$rcvar" )
+ [ "$rcvar_default" ] ||
+ rcvar_default="${entry#*,}"
+ rcvar_desc=$( f_sysrc_desc "$rcvar" )
+ echo $rcvar ${rcvar_default:-NO} \
+ $script "$rcvar_desc"
+ done
+ done | sort -u
+ )
+ export STARTUP_RCVAR_MAP
+ export _STARTUP_RCVAR_MAP=1
+ echo "$STARTUP_RCVAR_MAP"
+
+ #
+ # Attempt to create the persistant global cache
+ #
+
+ # Create a new temporary file to write to
+ local tmpfile="$( mktemp -t "$pgm" )"
+ [ "$tmpfile" ] || return $FAILURE
+
+ # Write the temporary file contents
+ echo "$rc_script_list_digest" > "$tmpfile"
+ echo "$STARTUP_RCVAR_MAP" >> "$tmpfile"
+
+ # Finally, move the temporary file into place
+ case "$STARTUP_RCVAR_MAP_CACHEFILE" in
+ */*) f_quietly mkdir -p "${STARTUP_RCVAR_MAP_CACHEFILE%/*}"
+ esac
+ mv "$tmpfile" "$STARTUP_RCVAR_MAP_CACHEFILE"
+}
+
+fi # ! $_STARTUP_RCVAR_SUBR
diff --git a/usr.sbin/bsdconfig/startup/startup b/usr.sbin/bsdconfig/startup/startup
new file mode 100755
index 0000000..c481761
--- /dev/null
+++ b/usr.sbin/bsdconfig/startup/startup
@@ -0,0 +1,133 @@
+#!/bin/sh
+#-
+# Copyright (c) 2012 Devin Teske
+# All Rights Reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in the
+# documentation and/or other materials provided with the distribution.
+#
+# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING BUT NOT LIMITED TO, THE
+# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+# DAMAGES (INLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+# SUCH DAMAGE.
+#
+# $FreeBSD$
+#
+############################################################ INCLUDES
+
+BSDCFG_SHARE="/usr/share/bsdconfig"
+. $BSDCFG_SHARE/common.subr || exit 1
+f_include $BSDCFG_SHARE/dialog.subr
+f_include $BSDCFG_SHARE/mustberoot.subr
+
+BSDCFG_LIBE="/usr/libexec/bsdconfig" APP_DIR="140.startup"
+f_include_lang $BSDCFG_LIBE/$APP_DIR/include/messages.subr
+
+ipgm=$( f_index_menu_selection $BSDCFG_LIBE/$APP_DIR/INDEX "$pgm" )
+[ $? -eq $SUCCESS -a "$ipgm" ] && pgm="$ipgm"
+
+############################################################ FUNCTIONS
+
+# dialog_menu_main
+#
+# Display the dialog(1)-based application main menu.
+#
+dialog_menu_main()
+{
+ local menu_list size
+ local hline="$hline_arrows_tab_enter"
+ local prompt=""
+
+ menu_list="
+ 'X' '$msg_exit'
+ '1' '$msg_toggle_startup_services'
+ '2' '$msg_view_edit_startup_configuration'
+ '3' '$msg_miscellaneous_startup_services'
+ " # END-QUOTE
+
+ size=$( eval f_dialog_menu_size \
+ \"\$DIALOG_TITLE\" \
+ \"\$DIALOG_BACKTITLE\" \
+ \"\$prompt\" \
+ \"\$hline\" \
+ $menu_list )
+
+ local dialog_menu
+ dialog_menu=$( eval $DIALOG \
+ --clear --title \"\$DIALOG_TITLE\" \
+ --backtitle \"\$DIALOG_BACKTITLE\" \
+ --hline \"\$hline\" \
+ --ok-label \"\$msg_ok\" \
+ --cancel-label \"\$msg_cancel\" \
+ --menu \"\$prompt\" $size \
+ $menu_list \
+ 2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD
+ )
+ local retval=$?
+ setvar DIALOG_MENU_$$ "$dialog_menu"
+ return $retval
+}
+
+############################################################ MAIN
+
+# Incorporate rc-file if it exists
+[ -f "$HOME/.bsdconfigrc" ] && f_include "$HOME/.bsdconfigrc"
+
+#
+# Process command-line arguments
+#
+while getopts hSX flag; do
+ case "$flag" in
+ h|\?) f_usage $BSDCFG_LIBE/$APP_DIR/USAGE "PROGRAM_NAME" "$pgm";;
+ esac
+done
+shift $(( $OPTIND - 1 ))
+
+#
+# Initialize
+#
+f_dialog_init
+f_dialog_title "$msg_startup"
+f_dialog_backtitle "${ipgm:+bsdconfig }$pgm"
+f_mustberoot_init
+
+#
+# Launch application main menu
+#
+while :; do
+ dialog_menu_main
+ retval=$?
+ mtag=$( f_dialog_menutag )
+
+ [ $retval -eq 0 ] || f_die
+
+ case "$mtag" in
+ X) # Exit
+ break ;;
+ 1) # Toggle Startup Services
+ $BSDCFG_LIBE/$APP_DIR/rcvar ${USE_XDIALOG:+-X} ;;
+ 2) # View/Edit Startup Configuration
+ $BSDCFG_LIBE/$APP_DIR/rcconf ${USE_XDIALOG:+-X} ;;
+ 3) # Miscellaneous Startup Services
+ $BSDCFG_LIBE/$APP_DIR/misc ${USE_XDIALOG:+-X} ;;
+ esac
+done
+
+exit $SUCCESS
+
+################################################################################
+# END
+################################################################################
diff --git a/usr.sbin/bsdconfig/timezone/INDEX b/usr.sbin/bsdconfig/timezone/INDEX
new file mode 100644
index 0000000..af17594
--- /dev/null
+++ b/usr.sbin/bsdconfig/timezone/INDEX
@@ -0,0 +1,53 @@
+# Copyright (c) 2012 Ron McDowell
+# Copyright (c) 2012 Devin Teske
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in the
+# documentation and/or other materials provided with the distribution.
+#
+# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+# SUCH DAMAGE.
+#
+# $FreeBSD$
+
+#
+# Title that will be shown on the bsdconfig menu
+menu_title="Timezone"
+#
+# a short descriptive line shown at the bottom of the bsdconfig menu.
+# keep it short because any line longer than the terminal width will
+# be truncated.
+menu_help="Set up Time Zone"
+#
+# two-part variable that defines an action to take when 'keyword'
+# is passed on a bsdconfig command line. variable takes the form
+# "keyword|command" and multiple occurrences of the variable
+# (with different 'keyword's, or different 'keyword's AND 'command's)
+# are allowed. If 'command' begins with a '/' then the full
+# path to the program is needed. If 'command' begins with anything
+# else it is a path relative to the directory this INDEX file is in.
+# 'keyword' can be i18n'ed but 'command' is the name of a script.
+menu_selection="timezone|timezone"
+#
+# Items below this line do NOT need i18n translation----------------------
+#
+# Name of the program to be run when this menu choice is selected.
+# if it begins with a '/' then the full path to the program is needed.
+# if it begins with anything else it is a path relative to the directory
+# this INDEX file is in.
+menu_program="timezone"
diff --git a/usr.sbin/bsdconfig/timezone/Makefile b/usr.sbin/bsdconfig/timezone/Makefile
new file mode 100644
index 0000000..b4ef0cb
--- /dev/null
+++ b/usr.sbin/bsdconfig/timezone/Makefile
@@ -0,0 +1,16 @@
+# $FreeBSD$
+
+NO_OBJ=
+
+SUBDIR= include share
+
+FILESDIR= ${LIBEXECDIR}/bsdconfig/090.timezone
+FILES= INDEX USAGE
+
+SCRIPTSDIR= ${FILESDIR}
+SCRIPTS= timezone
+
+beforeinstall:
+ mkdir -p ${DESTDIR}${FILESDIR}
+
+.include <bsd.prog.mk>
diff --git a/usr.sbin/bsdconfig/timezone/USAGE b/usr.sbin/bsdconfig/timezone/USAGE
new file mode 100644
index 0000000..a88369c
--- /dev/null
+++ b/usr.sbin/bsdconfig/timezone/USAGE
@@ -0,0 +1,42 @@
+# Copyright (c) 2011-2012 Devin Teske
+# All Rights Reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in the
+# documentation and/or other materials provided with the distribution.
+#
+# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING BUT NOT LIMITED TO, THE
+# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+# DAMAGES (INLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+# SUCH DAMAGE.
+#
+# $FreeBSD$
+
+Usage: bsdconfig @PROGRAM_NAME@ [-ehnrSsvX] [-C chroot_dir] [zinfo_file | zinfo_name]
+OPTIONS:
+ -h Print usage statement and exit.
+ -e Only return success on exit if user selects a timezone AND
+ the selected timezone was successfully installed. By default
+ (without this flag), success is always returned unless an
+ error has occurred.
+ -n Do not create or copy files.
+ -r Reinstall the zoneinfo file installed last time. The name is
+ obtained from /var/db/zoneinfo.
+ -S Secure X11 mode (implies `-X'). As root, always prompt-for
+ and validate sudo(8) username/password before starting.
+ -s Skip the initial question about adjusting the clock if
+ not set to UTC.
+ -v Verbose. Enable extra output when installing the zone file.
+ -X Enable the use of Xdialog(1) instead of dialog(1).
diff --git a/usr.sbin/bsdconfig/timezone/include/Makefile b/usr.sbin/bsdconfig/timezone/include/Makefile
new file mode 100644
index 0000000..887536e
--- /dev/null
+++ b/usr.sbin/bsdconfig/timezone/include/Makefile
@@ -0,0 +1,11 @@
+# $FreeBSD$
+
+NO_OBJ=
+
+FILESDIR= ${LIBEXECDIR}/bsdconfig/090.timezone/include
+FILES= messages.subr
+
+beforeinstall:
+ mkdir -p ${DESTDIR}${FILESDIR}
+
+.include <bsd.prog.mk>
diff --git a/usr.sbin/bsdconfig/timezone/include/messages.subr b/usr.sbin/bsdconfig/timezone/include/messages.subr
new file mode 100644
index 0000000..6a7f045
--- /dev/null
+++ b/usr.sbin/bsdconfig/timezone/include/messages.subr
@@ -0,0 +1,78 @@
+# Copyright (c) 2012 Devin Teske
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in the
+# documentation and/or other materials provided with the distribution.
+#
+# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+# SUCH DAMAGE.
+#
+# $FreeBSD$
+
+continent_africa_title="Africa"
+continent_america_title="America -- North and South"
+continent_antarctica_title="Antarctica"
+continent_arctic_title="Arctic Ocean"
+continent_asia_title="Asia"
+continent_atlantic_title="Atlantic Ocean"
+continent_australia_title="Australia"
+continent_europe_title="Europe"
+continent_indian_title="Indian Ocean"
+continent_pacific_title="Pacific Ocean"
+continent_utc_title="UTC"
+msg_cancel="Cancel"
+msg_cannot_open_for_reading="Cannot open %s for reading. Does it exist?"
+msg_confirmation="Confirmation"
+msg_conflicting_zone_definition="%s:%d: conflicting zone definition"
+msg_copied_timezone_file="Copied timezone file from %s to %s"
+msg_copying_file="Copying %s to %s"
+msg_country_code_invalid="%s:%d: country code \`%s' invalid"
+msg_country_code_multiply_defined="%s:%d: country code \`%s' multiply defined: %s"
+msg_country_code_unknown="%s:%d: country code \`%s' unknown"
+msg_country_time_zones="%s Time Zones"
+msg_country_title="Countries in %s"
+msg_created_symlink="Created symbolic link from %s to %s"
+msg_creating_symlink="Creating symbolic link %s to %s"
+msg_default_zone_provided="Default timezone provided"
+msg_done="Done"
+msg_error="Error"
+msg_error_reading="Error reading %s."
+msg_info="Info"
+msg_invalid_code="%s:%d: invalid code \`%s'"
+msg_invalid_country_code="%s:%d: invalid country code \`%s'"
+msg_invalid_format="%s:%d: invalid format"
+msg_invalid_region="%s:%d: invalid region \`%s'"
+msg_invalid_zone_name="%s:%d: invalid zone name \`%s'"
+msg_is_machine_clock_utc="Is the machine's CMOS clock set to UTC? If it is set to local time,\nor you don't know, please choose NO here!"
+msg_island_and_group_title="Islands and groups in the %s"
+msg_look_reasonable="Does the abbreviation \`%s' look reasonable?"
+msg_no="No"
+msg_ok="OK"
+msg_removed_file="Removed %s"
+msg_removing_file="Removing %s"
+msg_select_country="Select a country"
+msg_select_island_or_group="Select an island or group"
+msg_select_local_or_utc="Select local or UTC (Greenwhich Mean Time) clock"
+msg_select_region="Select a region"
+msg_select_zone="Select a zone which observes the same time as your locality."
+msg_time_zone="Time Zone"
+msg_unable_to_determine_name_from_db="Unable to determine earlier installed zoneinfo name. Check %s"
+msg_use_default_zone="Use the default \`%s' zone?"
+msg_yes="Yes"
+msg_zone_multiply_defined="%s:%d: zone multiply defined"
+msg_zone_must_have_description="%s:%d: zone must have description"
diff --git a/usr.sbin/bsdconfig/timezone/share/Makefile b/usr.sbin/bsdconfig/timezone/share/Makefile
new file mode 100644
index 0000000..1b7b80c
--- /dev/null
+++ b/usr.sbin/bsdconfig/timezone/share/Makefile
@@ -0,0 +1,12 @@
+# $FreeBSD$
+
+NO_OBJ=
+
+FILESDIR= ${SHAREDIR}/bsdconfig/timezone
+FILES= continents.subr countries.subr iso3166.subr menus.subr \
+ zones.subr
+
+beforeinstall:
+ mkdir -p ${DESTDIR}${FILESDIR}
+
+.include <bsd.prog.mk>
diff --git a/usr.sbin/bsdconfig/timezone/share/continents.subr b/usr.sbin/bsdconfig/timezone/share/continents.subr
new file mode 100644
index 0000000..8f3e516
--- /dev/null
+++ b/usr.sbin/bsdconfig/timezone/share/continents.subr
@@ -0,0 +1,138 @@
+if [ ! "$_TIMEZONE_CONTINENTS_SUBR" ]; then _TIMEZONE_CONTINENTS_SUBR=1
+#
+# Copyright (c) 2011-2012 Devin Teske
+# All Rights Reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in the
+# documentation and/or other materials provided with the distribution.
+#
+# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING BUT NOT LIMITED TO, THE
+# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+# DAMAGES (INLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+# SUCH DAMAGE.
+#
+# $FreeBSD$
+#
+############################################################ INCLUDES
+
+BSDCFG_SHARE="/usr/share/bsdconfig"
+. $BSDCFG_SHARE/common.subr || exit 1
+
+BSDCFG_LIBE="/usr/libexec/bsdconfig" APP_DIR="090.timezone"
+f_include_lang $BSDCFG_LIBE/$APP_DIR/include/messages.subr
+
+############################################################ CONFIGURATION
+
+#
+# List of worldly continents/oceans (export'ed for awk(1) ENVIRON visibility)
+#
+export CONTINENTS="
+ africa
+ america
+ antarctica
+ arctic
+ asia
+ atlantic
+ australia
+ europe
+ indian
+ pacific
+ utc
+"
+
+#
+# Directory name of each continent/ocean (in _PATH_ZONEINFO)
+#
+export continent_africa_name="Africa"
+export continent_america_name="America"
+export continent_antarctica_name="Antarctica"
+export continent_arctic_name="Arctic"
+export continent_asia_name="Asia"
+export continent_atlantic_name="Atlantic"
+export continent_australia_name="Australia"
+export continent_europe_name="Europe"
+export continent_indian_name="Indian"
+export continent_pacific_name="Pacific"
+export continent_utc_name="UTC"
+
+#
+# Export i18n menu texts of continents/oceans for awk(1) ENVIRON visibility
+# NOTE: These are defined in messages.subr included above.
+#
+export continent_africa_title
+export continent_america_title
+export continent_antarctica_title
+export continent_arctic_title
+export continent_asia_title
+export continent_atlantic_title
+export continent_australia_title
+export continent_europe_title
+export continent_indian_title
+export continent_pacific_title
+export continent_utc_title
+
+############################################################ FUNCTIONS
+
+# f_continent $cont $property
+#
+# Returns a single property of a given continent. Available properties are:
+#
+# name Directory name of continent/ocean as it appears in
+# _PATH_ZONEINFO.
+# title Menu text of this continent/ocean to be displayed in the
+# continent-selection menu.
+# nitems Number of submenu items associated with this
+# continent/ocean.
+# tlc_N 2-character country code of the Nth submenu item associated
+# with this continent displayed in the country-selection menu
+# (which appears after continent selection).
+# menu_list Menu-list of regions for this continent.
+#
+f_continent()
+{
+ local cont="$1" property="$2"
+ eval echo \"\${continent_${cont}_$property}\"
+}
+
+# f_find_continent $title
+#
+# Returns continent identifier given continent title.
+#
+f_find_continent()
+{
+ local cont
+ for cont in $CONTINENTS; do
+ if [ "$1" = "$( f_continent $cont title )" ]; then
+ echo "$cont"
+ return $SUCCESS
+ fi
+ done
+ return $FAILURE
+}
+
+# f_OCEANP $cont
+#
+# Returns "1" if the first argument is an ocean, otherwise NULL.
+#
+f_OCEANP()
+{
+ case "$1" in
+ arctic|atlantic|indian|pacific)
+ echo 1
+ esac
+}
+
+fi # ! $_TIMEZONE_CONTINENTS_SUBR
diff --git a/usr.sbin/bsdconfig/timezone/share/countries.subr b/usr.sbin/bsdconfig/timezone/share/countries.subr
new file mode 100644
index 0000000..9c6a164
--- /dev/null
+++ b/usr.sbin/bsdconfig/timezone/share/countries.subr
@@ -0,0 +1,78 @@
+if [ ! "$_TIMEZONE_COUNTRIES_SUBR" ]; then _TIMEZONE_COUNTRIES_SUBR=1
+#
+# Copyright (c) 2011-2012 Devin Teske
+# All Rights Reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in the
+# documentation and/or other materials provided with the distribution.
+#
+# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING BUT NOT LIMITED TO, THE
+# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+# DAMAGES (INLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+# SUCH DAMAGE.
+#
+# $FreeBSD$
+
+# f_country $code $property
+#
+# Returns a single property of a given country. Available properties are:
+#
+# name Name of the country as read from _PATH_ISO3166.
+# nzones Number of zones within the country (-1 if country has
+# only a single zone).
+# filename The filename portion of the TZ field (after the `/') as
+# read from _PATH_ZONETAB.
+# cont The principal continent in which the country lies (appears
+# before the `/' in the TZ field of _PATH_ZONETAB).
+# filename_N Like filename, but for the Nth zone when the country has
+# multiple zones (nzones > 0).
+# cont_N Like cont, but for the Nth zone when the country has
+# multiple zones (nzones > 0).
+# descr_N Like name, but for the Nth zone when the country has
+# multiple zones (nzones > 0)
+#
+f_country()
+{
+ local code="$1" property="$2"
+ eval echo \"\${country_${code}_$property}\"
+}
+
+# f_sort_countries
+#
+# Sorts alphabetically the 2-character country codes listed in $COUNTRIES based
+# on the name of each country.
+#
+# This function is a two-parter. Below is the awk(1) portion of the function,
+# afterward is the sh(1) function which utilizes the below awk script.
+#
+f_sort_countries_awk='
+{
+ split($0, array, /[[:space:]]+/)
+ for (item in array)
+ {
+ tlc = array[item]
+ print ENVIRON["country_" tlc "_name"] " " tlc
+ }
+}
+'
+f_sort_countries()
+{
+ COUNTRIES=$( echo "$COUNTRIES" | awk "$f_sort_countries_awk" |
+ sort | awk '{print $NF}' )
+ export COUNTRIES
+}
+
+fi # ! $_TIMEZONE_COUNTRIES_SUBR
diff --git a/usr.sbin/bsdconfig/timezone/share/iso3166.subr b/usr.sbin/bsdconfig/timezone/share/iso3166.subr
new file mode 100644
index 0000000..72e934a
--- /dev/null
+++ b/usr.sbin/bsdconfig/timezone/share/iso3166.subr
@@ -0,0 +1,197 @@
+if [ ! "$_TIMEZONE_ISO3166_SUBR" ]; then _TIMEZONE_ISO3166_SUBR=1
+#
+# Copyright (c) 2011-2012 Devin Teske
+# All Rights Reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in the
+# documentation and/or other materials provided with the distribution.
+#
+# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING BUT NOT LIMITED TO, THE
+# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+# DAMAGES (INLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+# SUCH DAMAGE.
+#
+# $FreeBSD$
+#
+############################################################ INCLUDES
+
+BSDCFG_SHARE="/usr/share/bsdconfig"
+. $BSDCFG_SHARE/common.subr || exit 1
+
+BSDCFG_LIBE="/usr/libexec/bsdconfig" APP_DIR="090.timezone"
+f_include_lang $BSDCFG_LIBE/$APP_DIR/include/messages.subr
+
+############################################################ CONFIGURATION
+
+#
+# Standard pathnames
+#
+_PATH_ISO3166="/usr/share/misc/iso3166"
+
+#
+# Export required i18n messages for awk(1) ENVIRON visibility
+#
+export msg_country_code_multiply_defined
+export msg_invalid_code
+export msg_invalid_format
+
+############################################################ FUNCTIONS
+
+# f_read_iso3166_table
+#
+# Read the ISO 3166 country code database in _PATH_ISO3166:
+# /usr/share/misc/iso3166 on FreeBSD
+# /usr/share/zoneinfo/iso3166.tab on Linux, Mac OS X, and Cygwin
+#
+# The format of this file on FreeBSD is:
+# two three number name
+#
+# The format of this file on Linux, Mac OS X, and Cygwin is:
+# two name
+#
+# With each of the following elements (described below) being separated by a
+# single tab character:
+#
+# two ISO 3166 2-character country code
+# three ISO 3166 3-character country code (if provided)
+# number ISO 3166 numeric country code (if provided)
+# name Human-readable country name (may contain spaces)
+#
+# Variables created by this function:
+#
+# COUNTRIES
+# A space-separated list of 2-character country codes.
+# country_CODE_name
+# The country `name' (as described above).
+#
+# where CODE is the 2-character country code.
+#
+# This function is a two-parter. Below is the awk(1) portion of the function,
+# afterward is the sh(1) function which utilizes the below awk script.
+#
+f_read_iso3166_table_awk='
+# Variables that should be defined on the invocation line:
+# -v progname="progname"
+#
+BEGIN {
+ lineno = 0
+ failed = 0
+}
+function die(fmt, argc, argv)
+{
+ printf "f_die 1 \"%%s: %s\" \"%s\"", fmt, progname
+ for (n = 1; n <= argc; n++)
+ printf " \"%s\"", argv[n]
+ print ""
+ failed++
+ exit 1
+}
+function add_country(tlc, name)
+{
+ if (country_name[tlc])
+ {
+ argv[1] = FILENAME
+ argv[2] = lineno
+ argv[3] = tlc
+ argv[4] = name
+ die(ENVIRON["msg_country_code_multiply_defined"], 4, argv)
+ }
+
+ country_name[tlc] = name
+}
+function print_country_name(tlc)
+{
+ name = country_name[tlc]
+ gsub(/"/, "\\\"", name)
+ printf "country_%s_name=\"%s\"\n", tlc, name
+ printf "export country_%s_name\n", tlc
+}
+/^#/ {
+ lineno++
+ next
+}
+!/^#/ {
+ lineno++
+
+ # Split the current record (on TAB) into an array
+ split($0, line, /\t/)
+
+ # Get the ISO3166-1 (Alpha 1) 2-letter country code
+ tlc = line[1]
+
+ #
+ # Validate the two-character country code
+ #
+ if (length(tlc) != 2)
+ {
+ argv[1] = FILENAME
+ argv[2] = lineno
+ die(ENVIRON["msg_invalid_format"], 2, argv)
+ }
+ if (!match(tlc, /^[A-Z][A-Z]$/))
+ {
+ argv[1] = FILENAME
+ argv[2] = lineno
+ argv[3] = tlc
+ die(ENVIRON["msg_invalid_code"], 3, argv)
+ }
+
+ #
+ # Calculate the substr start-position of the name
+ #
+ name_start = 0
+ n = 4
+ if (FILENAME ~ /\.tab$/)
+ n = 2
+ while (--n)
+ {
+ #
+ # Validate field-length of 2nd/3rd columns while we are here
+ #
+ if (n > 1 && length(line[n]) != 3)
+ {
+ argv[1] = FILENAME
+ argv[2] = lineno
+ die(ENVIRON["msg_invalid_format"], 2, argv)
+ }
+
+ name_start += length(line[n]) + 1
+ }
+
+ # Get the name field
+ name = substr($0, name_start + 1)
+
+ add_country(tlc, name)
+}
+END {
+ list = ""
+ for (tlc in country_name)
+ {
+ list = list (length(list) > 0 ? " " : "") tlc
+ print_country_name(tlc)
+ }
+ printf "COUNTRIES=\"%s\"\n", list
+ print "export COUNTRIES"
+}
+'
+f_read_iso3166_table()
+{
+ eval $( awk -v progname="$pgm" \
+ "$f_read_iso3166_table_awk" \
+ "$_PATH_ISO3166" )
+}
+
+fi # ! $_TIMEZONE_ISO3166_SUBR
diff --git a/usr.sbin/bsdconfig/timezone/share/menus.subr b/usr.sbin/bsdconfig/timezone/share/menus.subr
new file mode 100644
index 0000000..5ce50f8
--- /dev/null
+++ b/usr.sbin/bsdconfig/timezone/share/menus.subr
@@ -0,0 +1,220 @@
+if [ ! "$_TIMEZONE_MENUS_SUBR" ]; then _TIMEZONE_MENUS_SUBR=1
+#
+# Copyright (c) 2011-2012 Devin Teske
+# All Rights Reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in the
+# documentation and/or other materials provided with the distribution.
+#
+# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING BUT NOT LIMITED TO, THE
+# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+# DAMAGES (INLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+# SUCH DAMAGE.
+#
+# $FreeBSD$
+#
+############################################################ INCLUDES
+
+BSDCFG_SHARE="/usr/share/bsdconfig"
+. $BSDCFG_SHARE/common.subr || exit 1
+f_include $BSDCFG_SHARE/dialog.subr
+
+############################################################ GLOBALS
+
+#
+# Export special included variables required by awk(1) for `ENVIRON' visibility
+#
+export DIALOG_MENU_TAGS
+
+############################################################ FUNCTIONS
+
+# f_make_menus
+#
+# Creates the tag/item ordered-pair list environment variables for the
+# continent and country menus.
+#
+# Required variables [from continents.subr]:
+#
+# CONTINENTS
+# Space-separated list of continents.
+# continent_*_title
+# Desired menu text for the continent represented by *.
+#
+# Required variables [created by f_read_iso3166_table from iso3166.subr]:
+#
+# COUNTRIES
+# Space-separated list of 2-character country codes.
+# country_*_name :: when country_*_nzones < 0
+# Desired menu text for the country-zone represented by *, the 2-
+# character country code.
+#
+# Required variables [created by f_read_zones from zones.subr]:
+#
+# country_*_nzones
+# Number of zones for the country represented by *, the 2-
+# character country code. Should be -1 if the country has only
+# one single zone, otherwise 1 or greater to indicate how many
+# zones the country has.
+# country_*_cont :: when country_*_nzones < 0
+# Principal continent (or ocean) in which the country-zone
+# represented by *, the 2-character country code, resides.
+# country_*_cont_N :: when country_*_nzones > 0
+# Principal continent (or ocean) in which zone-N of the country
+# represented by * resides, the 2-character country code.
+# country_*_descr_N :: when country_*_nzones > 0
+# Desired submenu text for zone-N of the country represented by
+# *, the 2-character country code.
+#
+# Variables created by this function:
+#
+# continent_menu_list
+# Menu-list of continents.
+# continent_*_nitems
+# Number of items associated with the continent represented by *,
+# the continent identifier.
+# continent_*_tlc_N
+# 2-character country code of the Nth item in the continent menu
+# for the continent represented by *, the continent identifier.
+# continent_*_menu_list
+# Menu-list of countries/zones for each continent represented by
+# *, the continent identifier.
+# country_*_menu_list
+# For countries that have multiple zones, this is the submenu-
+# list of zones for said country represented by *, the 2-
+# character country code.
+#
+# This function is a two-parter. Below is the awk(1) portion of the function,
+# afterward is the sh(1) function which utilizes the below awk script.
+#
+f_make_menus_awk='
+function add_zone_n_to_country_menu(tlc, n)
+{
+ zone_title = ENVIRON["country_" tlc "_descr_" n]
+ gsub(/'\''/, "'\''\\'\'''\''", zone_title)
+ country_menu_list[tlc] = country_menu_list[tlc] \
+ ( length(country_menu_list[tlc]) > 0 ? "\n" : "" ) \
+ n " '\''" zone_title "'\''"
+}
+BEGIN {
+ #
+ # First, count up all the countries in each continent/ocean.
+ # Be careful to count those countries which have multiple zones
+ # only once for each. NB: some countries are in multiple
+ # continents/oceans.
+ #
+ i = split(ENVIRON["COUNTRIES"], countries, /[[:space:]]+/)
+ for (cp = 1; cp <= i; cp++)
+ {
+ tlc = countries[cp]
+ title = ENVIRON["country_" tlc "_name"]
+ gsub(/'\''/, "'\''\\'\'''\''", title)
+ nzones = ENVIRON["country_" tlc "_nzones"]
+ if (!nzones)
+ {
+ # Country has no zones
+ continue
+ }
+ else if (nzones < 0)
+ {
+ # Country has only one zone
+ cont = ENVIRON["country_" tlc "_cont"]
+ nitems = ++continent_nitems[cont]
+ continent_tlc[cont,nitems] = tlc
+ continent_title[cont,nitems] = title
+ }
+ else
+ {
+ # Country has one or more zones
+ for (n = 1; n <= nzones; n++)
+ {
+ add_zone_n_to_country_menu(tlc, n)
+ cont = ENVIRON["country_" tlc "_cont_" n]
+ for (x = 1; x < n; x++)
+ {
+ contx = ENVIRON["country_"tlc"_cont_"x]
+ if (cont == contx) break
+ }
+ if (x == n)
+ {
+ nitems = ++continent_nitems[cont]
+ continent_tlc[cont,nitems] = tlc
+ continent_title[cont,nitems] = title
+ }
+ }
+ }
+ }
+}
+END {
+ tags = ENVIRON["DIALOG_MENU_TAGS"]
+ cont_menu_list = ""
+ tagn = 0
+
+ #
+ # Assemble the menu items in the menu list for each continent/ocean.
+ #
+ i = split(ENVIRON["CONTINENTS"], array, /[[:space:]]+/)
+ for (item = 1; item <= i; item++)
+ {
+ cont = array[item]
+ if (!cont) continue
+
+ if (++tagn >= length(tags)) break
+ tag = substr(tags, tagn, 1)
+ cont_menu_list = cont_menu_list \
+ ( length(cont_menu_list) > 0 ? "\n" : "" ) \
+ "'\''" tag "'\'' '\''" \
+ ENVIRON["continent_" cont "_title"] "'\''"
+
+ nitems = continent_nitems[cont]
+ printf "continent_%s_nitems=%d\n", cont, nitems
+
+ menu_list = ""
+ for (n = 1; n <= nitems; n++)
+ {
+ printf "continent_%s_tlc_%d=%s\n",
+ cont, n, continent_tlc[cont,n]
+
+ title = continent_title[cont,n]
+ menu_list = menu_list \
+ ( length(menu_list) > 0 ? "\n" : "" ) \
+ n " '\''" title "'\''"
+ }
+
+ gsub(/"/, "\\\"", menu_list)
+ printf "continent_%s_menu_list=\"%s\"\n", cont, menu_list
+ }
+
+ gsub(/"/, "\\\"", continent_menu_list)
+ printf "continent_menu_list=\"%s\"\n", cont_menu_list
+ print "export continent_menu_list"
+
+ #
+ # Dump the submenus of countries with multiple zones
+ #
+ for (tlc in country_menu_list)
+ {
+ menu_list = country_menu_list[tlc]
+ gsub(/"/, "\\\"", menu_list)
+ printf "country_%s_menu_list=\"%s\"\n", tlc, menu_list
+ }
+}
+'
+f_make_menus()
+{
+ eval $( :| awk "$f_make_menus_awk" )
+}
+
+fi # ! $_TIMEZONE_MENUS_SUBR
diff --git a/usr.sbin/bsdconfig/timezone/share/zones.subr b/usr.sbin/bsdconfig/timezone/share/zones.subr
new file mode 100644
index 0000000..81008a9
--- /dev/null
+++ b/usr.sbin/bsdconfig/timezone/share/zones.subr
@@ -0,0 +1,670 @@
+if [ ! "$_TIMEZONE_ZONES_SUBR" ]; then _TIMEZONE_ZONES_SUBR=1
+#
+# Copyright (c) 2011-2012 Devin Teske
+# All Rights Reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in the
+# documentation and/or other materials provided with the distribution.
+#
+# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING BUT NOT LIMITED TO, THE
+# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+# DAMAGES (INLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+# SUCH DAMAGE.
+#
+# $FreeBSD$
+#
+############################################################ INCLUDES
+
+BSDCFG_SHARE="/usr/share/bsdconfig"
+. $BSDCFG_SHARE/common.subr || exit 1
+f_include $BSDCFG_SHARE/dialog.subr
+f_include $BSDCFG_SHARE/timezone/continents.subr
+
+BSDCFG_LIBE="/usr/libexec/bsdconfig" APP_DIR="090.timezone"
+f_include_lang $BSDCFG_LIBE/$APP_DIR/include/messages.subr
+
+############################################################ CONFIGURATION
+
+#
+# Standard pathnames
+#
+_PATH_ZONETAB="/usr/share/zoneinfo/zone.tab"
+_PATH_ZONEINFO="/usr/share/zoneinfo"
+_PATH_LOCALTIME="/etc/localtime"
+_PATH_DB="/var/db/zoneinfo"
+
+#
+# Export required i18n messages for awk(1) ENVIRON visibility
+#
+export msg_conflicting_zone_definition
+export msg_country_code_invalid
+export msg_country_code_unknown
+export msg_invalid_country_code
+export msg_invalid_format
+export msg_invalid_region
+export msg_invalid_zone_name
+export msg_zone_multiply_defined
+export msg_zone_must_have_description
+
+############################################################ FUNCTIONS
+
+# f_read_zones
+#
+# Read the zone descriptions database in _PATH_ZONETAB:
+# /usr/share/zoneinfo/zone.tab on all OSes
+#
+# The format of this file (on all OSes) is:
+# code coordinates TZ comments
+#
+# With each of the following elements (described below) being separated by a
+# single tab character:
+#
+# code
+# The ISO 3166 2-character country code.
+# coordinates
+# Latitude and logitude of the zone's principal location in ISO
+# 6709 sign-degrees-minutes-seconds format, either +-DDMM+-DDDMM
+# or +-DDMMSS+-DDDMMSS, first latitude (+ is north), then long-
+# itude (+ is east).
+# TZ
+# Zone name used in value of TZ environment variable.
+# comments
+# Comments; present if and only if the country has multiple rows.
+#
+# Required variables [from continents.subr]:
+#
+# CONTINENTS
+# Space-separated list of continents.
+# continent_*_name
+# Directory element in _PATH_ZONEINFO for the continent
+# represented by *.
+#
+# Required variables [created by f_read_iso3166_table from iso3166.subr]:
+#
+# country_CODE_name
+# Country name of the country represented by CODE, the 2-
+# character country code.
+#
+# Variables created by this function:
+#
+# country_CODE_nzones
+# Either set to `-1' to indicate that the 2-character country
+# code has only a single zone associated with it (and therefore
+# you should query the `country_CODE_*' environment variables),
+# or set to `0' or higher to indicate how many zones are assoc-
+# iated with the given country code. When multiple zones are
+# configured for a single code, you should instead query the
+# `country_CODE_*_N' environment variables (e.g., `echo
+# $country_AQ_descr_1' prints the description of the first
+# timezone in Antarctica).
+# country_CODE_filename
+# The ``filename'' portion of the TZ value that appears after the
+# `/' (e.g., `Hong_Kong' from `Asia/Hong_Kong' or `Isle_of_Man'
+# from `Europe/Isle_of_Man').
+# country_CODE_cont
+# The ``continent'' portion of the TZ value that appears before
+# the `/' (e.g., `Asia' from `Asia/Hong_Kong' or `Europe' from
+# `Europe/Isle_of_Man').
+# country_CODE_descr
+# The comments associated with the ISO 3166 code entry (if any).
+#
+# NOTE: CODE is the 2-character country code.
+#
+# This function is a two-parter. Below is the awk(1) portion of the function,
+# afterward is the sh(1) function which utilizes the below awk script.
+#
+f_read_zones_awk='
+# Variables that should be defined on the invocation line:
+# -v progname="progname"
+#
+BEGIN {
+ lineno = 0
+ failed = 0
+
+ #
+ # Initialize continents array/map (name => id)
+ #
+ split(ENVIRON["CONTINENTS"], array, /[[:space:]]+/)
+ for (item in array)
+ {
+ cont = array[item]
+ if (!cont) continue
+ name = ENVIRON["continent_" cont "_name"]
+ continents[name] = cont
+ }
+}
+function die(fmt, argc, argv)
+{
+ printf "f_die 1 \"%%s: %s\" \"%s\"", fmt, progname
+ for (n = 1; n <= argc; n++)
+ printf " \"%s\"", argv[n]
+ print ""
+ failed++
+ exit 1
+}
+function find_continent(name)
+{
+ return continents[name]
+}
+function add_zone_to_country(lineno, tlc, descr, file, cont)
+{
+ #
+ # Validate the two-character country code
+ #
+ if (!match(tlc, /^[A-Z][A-Z]$/))
+ {
+ argv[1] = FILENAME
+ argv[2] = lineno
+ argv[3] = tlc
+ die(ENVRION["msg_country_code_invalid"], 3, argv)
+ }
+ if (!ENVIRON["country_" tlc "_name"])
+ {
+ argv[1] = FILENAME
+ argv[2] = lineno
+ argv[3] = tlc
+ die(ENVIRON["msg_country_code_unknown"], 3, argv)
+ }
+
+ #
+ # Add Zone to an array that we will parse at the end
+ #
+ if (length(descr) > 0)
+ {
+ if (country_nzones[tlc] < 0)
+ {
+ argv[1] = FILENAME
+ argv[2] = lineno
+ die(ENVIRON["msg_conflicting_zone_definition"], 2, argv)
+ }
+
+ n = ++country_nzones[tlc]
+ country_cont[tlc,n] = cont
+ country_filename[tlc,n] = file
+ country_descr[tlc,n] = descr
+ }
+ else
+ {
+ if (country_nzones[tlc] > 0)
+ {
+ argv[1] = FILENAME
+ argv[2] = lineno
+ die(ENVIRON["msg_zone_must_have_description"], 2, argv)
+ }
+ if (country_nzones[tlc] < 0)
+ {
+ argv[1] = FILENAME
+ argv[2] = lineno
+ die(ENVIRON["msg_zone_multiply_defined"], 2, argv)
+ }
+
+ country_nzones[tlc] = -1
+ country_cont[tlc] = cont
+ country_filename[tlc] = file
+ }
+}
+function print_country_code(tlc)
+{
+ nz = country_nzones[tlc]
+
+ printf "country_%s_nzones=%d\n", tlc, nz
+ printf "export country_%s_nzones\n", tlc
+
+ if (nz < 0)
+ {
+ printf "country_%s_cont=\"%s\"\n", tlc, country_cont[tlc]
+ printf "export country_%s_cont\n", tlc
+ printf "country_%s_filename=\"%s\"\n",
+ tlc, country_filename[tlc]
+ }
+ else
+ {
+ n = 0
+ while ( ++n <= nz )
+ {
+ printf "country_%s_cont_%d=\"%s\"\n",
+ tlc, n, country_cont[tlc,n]
+ printf "export country_%s_cont_%d\n", tlc, n
+ printf "country_%s_filename_%d=\"%s\"\n",
+ tlc, n, country_filename[tlc,n]
+ printf "country_%s_descr_%d=\"%s\"\n",
+ tlc, n, country_descr[tlc,n]
+ }
+ }
+}
+/^#/ {
+ lineno++
+ next
+}
+!/^#/ {
+ lineno++
+
+ #
+ # Split the current record (on TAB) into an array
+ #
+ if (split($0, line, /\t/) < 2)
+ {
+ argv[1] = FILENAME
+ argv[2] = lineno
+ die(ENVIRON["msg_invalid_format"], 2, argv)
+ }
+
+ # Get the ISO3166-1 (Alpha 1) 2-letter country code
+ tlc = line[1]
+
+ #
+ # Validate the two-character country code
+ #
+ if (length(tlc) != 2)
+ {
+ argv[1] = FILENAME
+ argv[2] = lineno
+ argv[3] = tlc
+ die(ENVIRON["msg_invalid_country_code"], 3, argv)
+ }
+
+ # Get the TZ field
+ tz = line[3]
+
+ #
+ # Validate the TZ field
+ #
+ if (!match(tz, "/"))
+ {
+ argv[1] = FILENAME
+ argv[2] = lineno
+ argv[3] = tz
+ die(ENVIRON["msg_invalid_zone_name"], 3, argv)
+ }
+
+ #
+ # Get the continent portion of the TZ field
+ #
+ contbuf = tz
+ sub("/.*$", "", contbuf)
+
+ #
+ # Validate the continent
+ #
+ cont = find_continent(contbuf)
+ if (!cont)
+ {
+ argv[1] = FILENAME
+ argv[2] = lineno
+ argv[3] = contbuf
+ die(ENVIRON["msg_invalid_region"], 3, argv)
+ }
+
+ #
+ # Get the filename portion of the TZ field
+ #
+ filename = tz
+ sub("^[^/]*/", "", filename)
+
+ #
+ # Calculate the substr start-position of the comment
+ #
+ descr_start = 0
+ n = 4
+ while (--n)
+ descr_start += length(line[n]) + 1
+
+ # Get the comment field
+ descr = substr($0, descr_start + 1)
+
+ add_zone_to_country(lineno, tlc, descr, filename, cont)
+}
+END {
+ if (failed) exit failed
+ for (tlc in country_nzones)
+ print_country_code(tlc)
+}
+'
+f_read_zones()
+{
+ eval $( awk -v progname="$pgm" \
+ "$f_read_zones_awk" \
+ "$_PATH_ZONETAB" )
+}
+
+# f_install_zoneinfo_file $filename
+#
+# Installs a zone file to _PATH_LOCALTIME.
+#
+f_install_zoneinfo_file()
+{
+ local zoneinfo_file="$1"
+ local copymode title msg err size
+
+ if [ -L "$_PATH_LOCALTIME" ]; then
+ copymode=
+ elif [ ! -e "$_PATH_LOCALTIME" ]; then
+ # Nothing there yet...
+ copymode=1
+ else
+ copymode=1
+ fi
+
+ if [ "$VERBOSE" ]; then
+ if [ ! "$zoneinfo_file" ]; then
+ msg=$( printf "$msg_removing_file" "$_PATH_LOCALTIME" )
+ elif [ "$copymode" ]; then
+ msg=$( printf "$msg_copying_file" \
+ "$zoneinfo_file" "$_PATH_LOCALTIME" )
+ else
+ msg=$( printf "$msg_creating_symlink" \
+ "$_PATH_LOCALTIME" "$zoneinfo_file" )
+ fi
+ if [ "$USEDIALOG" ]; then
+ f_dialog_title "$msg_info"
+ title="$DIALOG_TITLE"
+ btitle="$DIALOG_BACKTITLE"
+ f_dialog_title_restore
+ size=$( f_dialog_buttonbox_size "$title" \
+ "$btitle" "$msg" )
+ eval $DIALOG \
+ --title \"\$title\" \
+ --backtitle \"\$btitle\" \
+ --ok-label \"\$msg_ok\" \
+ --msgbox \"\$msg\" $size
+ else
+ printf "%s\n" "$msg"
+ fi
+ fi
+
+ if [ "$REALLYDOIT" ]; then
+ f_dialog_title "$msg_error"
+ title="$DIALOG_TITLE"
+ btitle="$DIALOG_BACKTITLE"
+ f_dialog_title_restore
+
+ if [ ! "$zoneinfo_file" ]; then
+
+ err=$( rm -f "$_PATH_LOCALTIME" 2>&1 )
+ if [ "$err" ]; then
+ if [ "$USEDIALOG" ]; then
+ size=$( f_dialog_buttonbox_size \
+ "$title" \
+ "$btitle" \
+ "$err" )
+ eval $DIALOG \
+ --title \"\$title\" \
+ --backtitle \"\$btitle\" \
+ --ok-label \"\$msg_ok\" \
+ --msgbox \"\$err\" $size
+ else
+ f_err "%s\n" "$err"
+ fi
+ return $FAILURE
+ fi
+
+ err=$( rm -f "$_PATH_DB" 2>&1 )
+ if [ "$err" ]; then
+ if [ "$USEDIALOG" ]; then
+ size=$( f_dialog_buttonbox_size \
+ "$title" \
+ "$btitle" \
+ "$err" )
+ eval $DIALOG \
+ --title \"\$title\" \
+ --backtitle \"\$btitle\" \
+ --ok-label \"\$msg_ok\" \
+ --msgbox \"\$err\" $size
+ else
+ f_err "%s\n" "$err"
+ fi
+ return $FAILURE
+ fi
+
+ if [ "$VERBOSE" ]; then
+ title="$msg_done"
+ msg=$( printf "$msg_removed_file" \
+ "$_PATH_LOCALTIME" )
+ if [ "$USEDIALOG" ]; then
+ size=$( f_dialog_buttonbox_size \
+ "$title" \
+ "$btitle" \
+ "$msg" )
+ eval $DIALOG \
+ --title \"\$title\" \
+ --backtitle \"\$btitle\" \
+ --ok-label \"\$msg_ok\" \
+ --msgbox \"\$msg\" $size
+ else
+ printf "%s\n" "$msg"
+ fi
+ fi
+
+ return $SUCCESS
+
+ fi # ! zoneinfo_file
+
+ if [ "$copymode" ]; then
+
+ err=$( rm -f "$_PATH_LOCALTIME" 2>&1 )
+ if [ "$err" ]; then
+ if [ "$USEDIALOG" ]; then
+ size=$( f_dialog_buttonbox_size \
+ "$title" \
+ "$btitle" \
+ "$err" )
+ eval $DIALOG \
+ --title \"\$title\" \
+ --backtitle \"\$btitle\" \
+ --ok-label \"\$msg_ok\" \
+ --msgbox \"\$err\" $size
+ else
+ f_err "%s\n" "$err"
+ fi
+ return $FAILURE
+ fi
+
+ err=$( umask 222 && : 2>&1 > "$_PATH_LOCALTIME" )
+ if [ "$err" ]; then
+ if [ "$USEDIALOG" ]; then
+ size=$( f_dialog_buttonbox_size \
+ "$title" \
+ "$btitle" \
+ "$err" )
+ eval $DIALOG \
+ --title \"\$title\" \
+ --backtitle \"\$btitle\" \
+ --ok-label \"\$msg_ok\" \
+ --msgbox \"\$err\" $size
+ else
+ f_err "%s\n" "$err"
+ fi
+ return $FAILURE
+ fi
+
+ err=$( cat "$zoneinfo_file" 2>&1 > "$_PATH_LOCALTIME" )
+ if [ "$err" ]; then
+ if [ "$USEDIALOG" ]; then
+ size=$( f_dialog_buttonbox_size \
+ "$title" \
+ "$btitle" \
+ "$err" )
+ eval $DIALOG \
+ --title \"\$title\" \
+ --backtitle \"\$btitle\" \
+ --ok-label \"\$msg_ok\" \
+ --msgbox \"\$err\" $size
+ else
+ f_err "%s\n" "$err"
+ fi
+ return $FAILURE
+ fi
+
+ else # ! copymode
+
+ err=$( ( :< "$zoneinfo_file" ) 2>&1 )
+ if [ "$err" ]; then
+ if [ "$USEDIALOG" ]; then
+ size=$( f_dialog_buttonbox_size \
+ "$title" \
+ "$btitle" \
+ "$err" )
+ eval $DIALOG \
+ --title \"\$title\" \
+ --backtitle \"\$btitle\" \
+ --ok-label \"\$msg_ok\" \
+ --msgbox \"\$err\" $size
+ else
+ f_err "%s\n" "$err"
+ fi
+ return $FAILURE
+ fi
+
+ err=$( rm -f "$_PATH_LOCALTIME" 2>&1 )
+ if [ "$err" ]; then
+ if [ "$USEDIALOG" ]; then
+ size=$( f_dialog_buttonbox_size \
+ "$title" \
+ "$btitle" \
+ "$err" )
+ eval $DIALOG \
+ --title \"\$title\" \
+ --backtitle \"\$btitle\" \
+ --ok-label \"\$msg_ok\" \
+ --msgbox \"\$err\" $size
+ else
+ f_err "%s\n" "$err"
+ fi
+ return $FAILURE
+ fi
+
+ err=$( ln -s "$zoneinfo_file" "$_PATH_LOCALTIME" 2>&1 )
+ if [ "$err" ]; then
+ if [ "$USEDIALOG" ]; then
+ size=$( f_dialog_buttonbox_size \
+ "$title" \
+ "$btitle" \
+ "$err" )
+ eval $DIALOG \
+ --title \"\$title\" \
+ --backtitle \"\$btitle\" \
+ --ok-label \"\$msg_ok\" \
+ --msgbox \"\$err\" $size
+ else
+ f_err "%s\n" "$err"
+ fi
+ return $FAILURE
+ fi
+
+ fi # copymode
+
+ if [ "$VERBOSE" ]; then
+ title="$msg_done"
+ if [ "$copymode" ]; then
+ msg=$( printf "$msg_copied_timezone_file" \
+ "$zoneinfo_file" \
+ "$_PATH_LOCALTIME" )
+ else
+ msg=$( printf "$msg_created_symlink" \
+ "$_PATH_LOCALTIME" \
+ "$zoneinfo_file" )
+ fi
+ if [ "$USEDIALOG" ]; then
+ size=$( f_dialog_buttonbox_size \
+ "$title" "$btitle" "$msg" )
+ eval $DIALOG \
+ --title \"\$title\" \
+ --backtitle \"\$btitle\" \
+ --ok-label \"\$msg_ok\" \
+ --msgbox \"\$msg\" $size
+ else
+ printf "%s\n" "$msg"
+ fi
+ fi
+
+ fi # REALLYDOIT
+
+ return $SUCCESS
+}
+
+# f_install_zoneinfo $zoneinfo
+#
+# Install a zoneinfo file relative to _PATH_ZONEINFO. The given $zoneinfo
+# will be written to _PATH_DB (usable later with the `-r' flag).
+#
+f_install_zoneinfo()
+{
+ local zoneinfo="$1"
+ local rv
+
+ f_install_zoneinfo_file "$_PATH_ZONEINFO/$zoneinfo"
+ rv=$?
+
+ # Save knowledge for later
+ if [ "$REALLYDOIT" -a $rv -eq $SUCCESS ]; then
+ if true 2> /dev/null > "$_PATH_DB"; then
+ cat <<-EOF > "$_PATH_DB"
+ $zoneinfo
+ EOF
+ fi
+ fi
+
+ return $rv
+}
+
+# f_confirm_zone $filename
+#
+# Prompt the user to confirm the new timezone data. The first (and only)
+# argument should be the pathname to the zoneinfo file, either absolute or
+# relative to `/usr/share/zoneinfo' (e.g., "America/Los_Angeles").
+#
+# The return status is 0 if "Yes" is chosen, 1 if "No", and 255 if Esc is
+# pressed (see dialog(1) for additional details).
+#
+f_confirm_zone()
+{
+ local filename="$1"
+ f_dialog_title "$msg_confirmation"
+ local title="$DIALOG_TITLE" btitle="$DIALOG_BACKTITLE"
+ f_dialog_title_restore
+ local tm_zone="$( TZ="$filename" date +%Z )"
+ local prompt="$( printf "$msg_look_reasonable" "$tm_zone" )"
+ local height=5 width=72
+
+ if [ "$USE_XDIALOG" ]; then
+ height=$(( $height + 4 ))
+ $DIALOG \
+ --title "$title" \
+ --backtitle "$btitle" \
+ --ok-label "$msg_yes" \
+ --cancel-label "$msg_no" \
+ --yesno "$prompt" $height $width
+ else
+ $DIALOG \
+ --title "$title" \
+ --backtitle "$btitle" \
+ --yes-label "$msg_yes" \
+ --no-label "$msg_no" \
+ --yesno "$prompt" $height $width
+ fi
+}
+
+# f_set_zone_utc
+#
+# Resets to the UTC timezone.
+#
+f_set_zone_utc()
+{
+ f_confirm_zone "" || return $FAILURE
+ f_install_zoneinfo_file ""
+}
+
+fi # ! $_TIMEZONE_ZONES_SUBR
diff --git a/usr.sbin/bsdconfig/timezone/timezone b/usr.sbin/bsdconfig/timezone/timezone
new file mode 100755
index 0000000..02626a6
--- /dev/null
+++ b/usr.sbin/bsdconfig/timezone/timezone
@@ -0,0 +1,457 @@
+#!/bin/sh
+#-
+# Copyright (c) 2011-2012 Devin Teske
+# All Rights Reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in the
+# documentation and/or other materials provided with the distribution.
+#
+# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING BUT NOT LIMITED TO, THE
+# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+# DAMAGES (INLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+# SUCH DAMAGE.
+#
+# $FreeBSD$
+#
+############################################################ INCLUDES
+
+BSDCFG_SHARE="/usr/share/bsdconfig"
+. $BSDCFG_SHARE/common.subr || exit 1
+f_include $BSDCFG_SHARE/dialog.subr
+f_include $BSDCFG_SHARE/mustberoot.subr
+f_include $BSDCFG_SHARE/strings.subr
+f_include $BSDCFG_SHARE/timezone/continents.subr
+f_include $BSDCFG_SHARE/timezone/countries.subr
+f_include $BSDCFG_SHARE/timezone/iso3166.subr
+f_include $BSDCFG_SHARE/timezone/menus.subr
+f_include $BSDCFG_SHARE/timezone/zones.subr
+
+BSDCFG_LIBE="/usr/libexec/bsdconfig" APP_DIR="090.timezone"
+f_include_lang $BSDCFG_LIBE/$APP_DIR/include/messages.subr
+
+ipgm=$( f_index_menu_selection $BSDCFG_LIBE/$APP_DIR/INDEX "$pgm" )
+[ $? -eq $SUCCESS -a "$ipgm" ] && pgm="$ipgm"
+
+############################################################ CONFIGURATION
+
+#
+# Standard pathnames
+#
+_PATH_DB="/var/db/zoneinfo"
+_PATH_WALL_CMOS_CLOCK="/etc/wall_cmos_clock"
+
+############################################################ GLOBALS
+
+#
+# Options
+#
+REALLYDOIT=1
+REINSTALL=
+USEDIALOG=1
+SKIPUTC=
+VERBOSE=
+TZ_OR_FAIL=
+CHROOTENV=
+
+#
+# Dummy vars (populated dynamically)
+#
+COUNTRIES= # list of 2-character country codes created by f_read_iso3166_table
+
+############################################################ FUNCTIONS
+
+# dialog_menu_main
+#
+# Display the dialog(1)-based application main menu.
+#
+dialog_menu_main()
+{
+ local title="$DIALOG_TITLE"
+ local btitle="$DIALOG_BACKTITLE"
+ local prompt="$msg_select_region"
+ local size
+
+ size=$( eval f_dialog_menu_size \
+ \"\$title\" \
+ \"\$btitle\" \
+ \"\$prompt\" \
+ \"\" \
+ $continent_menu_list )
+
+ local dialog_menu
+ dialog_menu=$( eval $DIALOG \
+ --title \"\$title\" \
+ --backtitle \"\$btitle\" \
+ --ok-label \"\$msg_ok\" \
+ --cancel-label \"\$msg_cancel\" \
+ --menu \"\$prompt\" $size \
+ $continent_menu_list \
+ 2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD
+ )
+ local retval=$?
+ setvar DIALOG_MENU_$$ "$dialog_menu"
+ return $retval
+}
+
+############################################################ MAIN
+
+# Incorporate rc-file if it exists
+[ -f "$HOME/.bsdconfigrc" ] && f_include "$HOME/.bsdconfigrc"
+
+#
+# Process command-line arguments
+#
+while getopts C:ehnrsSvX flag; do
+ case "$flag" in
+ C) CHROOTENV="$OPTARG";;
+ e) TZ_OR_FAIL=1;;
+ n) REALLYDOIT=;;
+ r) REINSTALL=1
+ USEDIALOG=;;
+ s) SKIPUTC=1;;
+ v) VERBOSE=1;;
+ h|\?) f_usage $BSDCFG_LIBE/$APP_DIR/USAGE "PROGRAM_NAME" "$pgm";;
+ esac
+done
+shift $(( $OPTIND - 1 ))
+
+#
+# Initialize
+#
+f_dialog_init
+f_dialog_title "$msg_time_zone"
+f_dialog_backtitle "${ipgm:+bsdconfig }$pgm"
+f_mustberoot_init
+
+#
+# Process `-C chroot_directory' command-line argument
+#
+if [ "$CHROOTENV" ]; then
+ _PATH_ZONETAB="$CHROOTENV$_PATH_ZONETAB"
+ _PATH_ISO3166="$CHROOTENV$_PATH_ISO3166"
+ _PATH_ZONEINFO="$CHROOTENV$_PATH_ZONEINFO"
+ _PATH_LOCALTIME="$CHROOTENV$_PATH_LOCALTIME"
+ _PATH_DB="$CHROOTENV$_PATH_DB"
+ _PATH_WALL_CMOS_CLOCK="$CHROOTENV$_PATH_WALL_CMOS_CLOCK"
+fi
+
+#
+# Process `-r' command-line option
+#
+if [ "$REINSTALL" ]; then
+ [ -f "$_PATH_DB" -a -r "$_PATH_DB" ] ||
+ f_die 1 "$msg_cannot_open_for_reading" "$_PATH_DB"
+ zoneinfo=$( cat "$_PATH_DB" ) ||
+ f_die 1 "$msg_error_reading" "$_PATH_DB"
+ [ "$zoneinfo" ] ||
+ f_die 1 "$msg_unable_to_determine_name_from_db" "$_PATH_DB"
+ f_install_zoneinfo "$zoneinfo"
+ exit $?
+fi
+
+#
+# If the arguments on the command-line do not specify a file,
+# then interpret it as a zoneinfo name
+#
+if [ $# -ge 1 ]; then
+ zoneinfo="$1"
+
+ if [ ! -f "$zoneinfo" ]; then
+ USEDIALOG=
+ f_install_zoneinfo "$zoneinfo"
+ exit $?
+ fi
+
+ # FALLTHROUGH
+fi
+
+#
+# Process the UTC option
+#
+if [ "$_PATH_WALL_CMOS_CLOCK" -a ! "$SKIPUTC" ]; then
+ f_dialog_title "$msg_select_local_or_utc"
+ title="$DIALOG_TITLE"
+ btitle="$DIALOG_BACKTITLE"
+ f_dialog_title_restore
+ msg="$msg_is_machine_clock_utc"
+
+ if [ "$USE_XDIALOG" ]; then
+ defaultno="default-no"
+ height=10 width=77
+ else
+ defaultno="defaultno"
+ height=7 width=73
+ fi
+
+ if [ "$USE_XDIALOG" ]; then
+ $DIALOG \
+ --title "$title" \
+ --backtitle "$btitle" \
+ --$defaultno \
+ --ok-label "$msg_yes" \
+ --cancel-label "$msg_no" \
+ --yesno "$msg" $height $width
+ result=$?
+ else
+ $DIALOG \
+ --title "$title" \
+ --backtitle "$btitle" \
+ --$defaultno \
+ --yes-label "$msg_yes" \
+ --no-label "$msg_no" \
+ --yesno "$msg" $height $width
+ result=$?
+ fi
+
+ if [ $result -eq 0 ]; then
+ # User chose YES
+ [ "$REALLYDOIT" ] &&
+ f_quietly rm -f "$_PATH_WALL_CMOS_CLOCK"
+ else
+ # User chose NO, pressed ESC (or Ctrl-C), or closed box
+ [ "$REALLYDOIT" ] &&
+ ( umask 222 && :> "$_PATH_WALL_CMOS_CLOCK" )
+ fi
+fi
+
+#
+# Process optional default zone argument
+#
+if [ $# -ge 1 ]; then
+ default="$1"
+
+ f_dialog_title "$msg_default_zone_provided"
+ title="$DIALOG_TITLE"
+ btitle="$DIALOG_BACKTITLE"
+ f_dialog_title_restore
+ msg=$( printf "\n$msg_use_default_zone" "$default" )
+ size=$( f_dialog_buttonbox_size "$title" "$btitle" "$msg" )
+
+ if [ "$USE_XDIALOG" ]; then
+ eval $DIALOG \
+ --title \"\$title\" \
+ --backtitle \"\$btitle\" \
+ --ok-label \"\$msg_yes\" \
+ --cancel-label \"\$msg_no\" \
+ --yesno \"\$msg\" $size
+ result=$?
+ else
+ eval $DIALOG \
+ --title \"\$title\" \
+ --backtitle \"\$btitle\" \
+ --yes-label \"\$msg_yes\" \
+ --no-label \"\$msg_no\" \
+ --yesno \"\$msg\" $size
+ result=$?
+ fi
+
+ if [ $result -eq 0 ]; then
+ # User chose YES
+ f_install_zoneinfo_file "$default"
+ result=$?
+ [ ! "$USE_XDIALOG" ] && f_dialog_clear
+ exit $result
+ fi
+
+ [ ! "$USE_XDIALOG" ] && f_dialog_clear
+fi
+
+#
+# Override the user-supplied umask
+#
+umask 022
+
+#
+# Read databases and perform initialization
+#
+f_read_iso3166_table # creates $COUNTRIES and $country_*_name
+f_read_zones # creates $country_*_{descr,cont,filename}
+f_sort_countries # sorts the countries listed for each continent
+f_make_menus # creates $continent_menu_list and $continent_*_menu_list
+
+#
+# Launch application main menu
+#
+NEED_CONTINENT=1
+NEED_COUNTRY=1
+while :; do
+ if [ "$NEED_CONTINENT" ]; then
+ dialog_menu_main # prompt the user to select a continent/ocean
+ retval=$?
+ mtag=$( f_dialog_menutag )
+
+ if [ $retval -ne 0 ]; then
+ [ "$TZ_OR_FAIL" ] && f_die
+ exit $SUCCESS
+ fi
+
+ NEED_CONTINENT=
+
+ continent=$( eval f_dialog_menutag2item \"\$mtag\" \
+ $continent_menu_list )
+ cont=$( f_find_continent "$continent" )
+ cont_title=$( f_continent $cont title )
+ nitems=$( f_continent $cont nitems )
+ isocean=$( f_OCEANP $cont )
+ fi
+
+ if [ "$NEED_COUNTRY" ]; then
+ if [ "$cont_title" = "$continent_utc_title" ]; then
+ if f_set_zone_utc; then
+ break
+ else
+ NEED_CONTINENT=1
+ continue
+ fi
+ fi
+
+ #
+ # Short cut -- if there's only one country, don't post a menu.
+ #
+ if [ $nitems -eq 1 ]; then
+ tag=1
+ else
+ #
+ # It's amazing how much good grammar really matters...
+ #
+ if [ ! "$isocean" ]; then
+ title=$( printf "$msg_country_title" \
+ "$cont_title" )
+ f_dialog_title "$title"
+ title="$DIALOG_TITLE"
+ btitle="$DIALOG_BACKTITLE"
+ f_dialog_title_restore
+ prompt="$msg_select_country"
+ else
+ title=$( printf "$msg_island_and_group_title" \
+ "$cont_title" )
+ f_dialog_title "$title"
+ title="$DIALOG_TITLE"
+ btitle="$DIALOG_BACKTITLE"
+ f_dialog_title_restore
+ prompt="$msg_select_island_or_group"
+ fi
+
+ #
+ # Calculate size of menu
+ #
+ menu_list=$( f_continent $cont menu_list )
+ size=$( eval f_dialog_menu_size \
+ \"\$title\" \
+ \"\$btitle\" \
+ \"\$prompt\" \
+ \"\" \
+ $menu_list )
+
+ #
+ # Launch the country selection menu
+ #
+ dialog_menu=$( eval $DIALOG \
+ --title \"\$title\" \
+ --backtitle \"\$btitle\" \
+ --ok-label \"\$msg_ok\" \
+ --cancel-label \"\$msg_cancel\" \
+ --menu \"\$prompt\" $size \
+ $menu_list \
+ 2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD
+ )
+ retval=$?
+ setvar DIALOG_MENU_$$ "$dialog_menu"
+ tag=$( f_dialog_menutag )
+
+ if [ $retval -ne 0 ]; then
+ NEED_CONTINENT=1
+ continue # back to main menu
+ fi
+ fi
+
+ # Get the country code from the user's selection
+ tlc=$( f_continent $cont tlc_$tag )
+
+ NEED_COUNTRY=
+ fi
+
+ #
+ # If the selection has only one zone (nzones == -1),
+ # just set it.
+ #
+ nzones=$( f_country $tlc nzones )
+ if [ $nzones -lt 0 ]; then
+ real_cont=$( f_country $tlc cont )
+ real_continent=$( f_continent $real_cont name )
+ name=$( f_country $tlc name )
+ filename=$( f_country $tlc filename )
+
+ if ! f_confirm_zone "$real_continent/$filename"; then
+ [ $nitems -eq 1 ] && NEED_CONTINENT=1
+ NEED_COUNTRY=1
+ continue
+ fi
+ else
+ title=$( printf "$msg_country_time_zones" \
+ "$( f_country $tlc name )" )
+ f_dialog_title "$title"
+ title="$DIALOG_TITLE"
+ btitle="$DIALOG_BACKTITLE"
+ f_dialog_title_restore
+ prompt="$msg_select_zone"
+ menu_list=$( f_country $tlc menu_list )
+ size=$( eval f_dialog_menu_size \"\$title\" \"\$btitle\" \
+ \"\$prompt\" \"\" $menu_list )
+
+ #
+ # Launch the zone selection menu
+ # NOTE: This is as deep as we go
+ #
+ dialog_menu=$( eval $DIALOG \
+ --title \"\$title\" \
+ --backtitle \"\$btitle\" \
+ --ok-label \"\$msg_ok\" \
+ --cancel-label \"\$msg_cancel\" \
+ --menu \"\$prompt\" $size \
+ $menu_list \
+ 2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD
+ )
+ retval=$?
+ setvar DIALOG_MENU_$$ "$dialog_menu"
+ n=$( f_dialog_menutag )
+
+ if [ $retval -ne 0 ]; then
+ [ $nitems -eq 1 ] && NEED_CONTINENT=1
+ NEED_COUNTRY=1
+ continue
+ fi
+
+ real_cont=$( f_country $tlc cont_$n )
+ real_continent=$( f_continent $real_cont name )
+ name=$( f_country $tlc name )
+ filename=$( f_country $tlc filename_$n )
+
+ f_confirm_zone "$real_continent/$filename" || continue
+ fi
+
+ [ $retval -eq 0 ] || continue # back to main menu
+
+ if ! f_install_zoneinfo "$real_continent/$filename"; then
+ [ $nzones -lt 0 ] && NEED_COUNTRY=1
+ else
+ break
+ fi
+done
+
+################################################################################
+# END
+################################################################################
diff --git a/usr.sbin/bsdconfig/ttys/INDEX b/usr.sbin/bsdconfig/ttys/INDEX
new file mode 100644
index 0000000..4ecc68e
--- /dev/null
+++ b/usr.sbin/bsdconfig/ttys/INDEX
@@ -0,0 +1,53 @@
+# Copyright (c) 2012 Ron McDowell
+# Copyright (c) 2012 Devin Teske
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in the
+# documentation and/or other materials provided with the distribution.
+#
+# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+# SUCH DAMAGE.
+#
+# $FreeBSD$
+
+#
+# Title that will be shown on the bsdconfig menu
+menu_title="Ttys"
+#
+# a short descriptive line shown at the bottom of the bsdconfig menu.
+# keep it short because any line longer than the terminal width will
+# be truncated.
+menu_help="Configure Ttys"
+#
+# two-part variable that defines an action to take when 'keyword'
+# is passed on a bsdconfig command line. variable takes the form
+# "keyword|command" and multiple occurrences of the variable
+# (with different 'keyword's, or different 'keyword's AND 'command's)
+# are allowed. If 'command' begins with a '/' then the full
+# path to the program is needed. If 'command' begins with anything
+# else it is a path relative to the directory this INDEX file is in.
+# 'keyword' can be i18n'ed but 'command' is the name of a script.
+menu_selection="ttys|ttys"
+#
+# Items below this line do NOT need i18n translation----------------------
+#
+# Name of the program to be run when this menu choice is selected.
+# if it begins with a '/' then the full path to the program is needed.
+# if it begins with anything else it is a path relative to the directory
+# this INDEX file is in.
+menu_program="ttys"
diff --git a/usr.sbin/bsdconfig/ttys/Makefile b/usr.sbin/bsdconfig/ttys/Makefile
new file mode 100644
index 0000000..b77bc24
--- /dev/null
+++ b/usr.sbin/bsdconfig/ttys/Makefile
@@ -0,0 +1,16 @@
+# $FreeBSD$
+
+NO_OBJ=
+
+SUBDIR= include
+
+FILESDIR= ${LIBEXECDIR}/bsdconfig/150.ttys
+FILES= INDEX USAGE
+
+SCRIPTSDIR= ${FILESDIR}
+SCRIPTS= ttys
+
+beforeinstall:
+ mkdir -p ${DESTDIR}${FILESDIR}
+
+.include <bsd.prog.mk>
diff --git a/usr.sbin/bsdconfig/ttys/USAGE b/usr.sbin/bsdconfig/ttys/USAGE
new file mode 100644
index 0000000..9aa4dca
--- /dev/null
+++ b/usr.sbin/bsdconfig/ttys/USAGE
@@ -0,0 +1,33 @@
+# Copyright (c) 2012 Devin Teske
+# All Rights Reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in the
+# documentation and/or other materials provided with the distribution.
+#
+# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING BUT NOT LIMITED TO, THE
+# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+# DAMAGES (INLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+# SUCH DAMAGE.
+#
+# $FreeBSD$
+
+Usage: bsdconfig @PROGRAM_NAME@ [OPTIONS]
+
+OPTIONS:
+ -h Print usage statement and exit.
+ -S Secure X11 mode (implies `-X'). As root, always prompt-for
+ and validate sudo(8) username/password before starting.
+ -X Use Xdialog(1) in place of dialog(1).
diff --git a/usr.sbin/bsdconfig/ttys/include/Makefile b/usr.sbin/bsdconfig/ttys/include/Makefile
new file mode 100644
index 0000000..9333abe
--- /dev/null
+++ b/usr.sbin/bsdconfig/ttys/include/Makefile
@@ -0,0 +1,11 @@
+# $FreeBSD$
+
+NO_OBJ=
+
+FILESDIR= ${LIBEXECDIR}/bsdconfig/150.ttys/include
+FILES= messages.subr
+
+beforeinstall:
+ mkdir -p ${DESTDIR}${FILESDIR}
+
+.include <bsd.prog.mk>
diff --git a/usr.sbin/bsdconfig/ttys/include/messages.subr b/usr.sbin/bsdconfig/ttys/include/messages.subr
new file mode 100644
index 0000000..296f756
--- /dev/null
+++ b/usr.sbin/bsdconfig/ttys/include/messages.subr
@@ -0,0 +1,31 @@
+# Copyright (c) 2012 Devin Teske
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in the
+# documentation and/or other materials provided with the distribution.
+#
+# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+# SUCH DAMAGE.
+#
+# $FreeBSD$
+
+msg_configure_ttys="Configure TTYs"
+msg_help_text="Configuration of system TTYs requires editing the /etc/ttys file.\nTypical configuration activities might include enabling getty(8)\non the first serial port to allow login via serial console after\nreboot, or to enable xdm. The default ttys file enables normal\nvirtual consoles, and most sites will not need to perform manual\nconfiguration.\n\nTo load /etc/ttys in the editor, select [Yes], otherwise, [No]."
+msg_no_such_file_or_directory="%s: %s: No such file or directory"
+msg_permission_denied="%s: %s: permission denied"
+msg_user_confirmation_requested="User Confirmation Requested"
diff --git a/usr.sbin/bsdconfig/ttys/ttys b/usr.sbin/bsdconfig/ttys/ttys
new file mode 100755
index 0000000..4e67e2c
--- /dev/null
+++ b/usr.sbin/bsdconfig/ttys/ttys
@@ -0,0 +1,128 @@
+#!/bin/sh
+#-
+# Copyright (c) 2012 Devin Teske
+# All Rights Reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in the
+# documentation and/or other materials provided with the distribution.
+#
+# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING BUT NOT LIMITED TO, THE
+# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+# DAMAGES (INLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+# SUCH DAMAGE.
+#
+# $FreeBSD$
+#
+############################################################ INCLUDES
+
+BSDCFG_SHARE="/usr/share/bsdconfig"
+. $BSDCFG_SHARE/common.subr || exit 1
+f_include $BSDCFG_SHARE/dialog.subr
+f_include $BSDCFG_SHARE/mustberoot.subr
+
+BSDCFG_LIBE="/usr/libexec/bsdconfig" APP_DIR="150.ttys"
+f_include_lang $BSDCFG_LIBE/$APP_DIR/include/messages.subr
+
+ipgm=$( f_index_menu_selection $BSDCFG_LIBE/$APP_DIR/INDEX "$pgm" )
+[ $? -eq $SUCCESS -a "$ipgm" ] && pgm="$ipgm"
+
+############################################################ CONFIGURATION
+
+#
+# Default text-editor to use
+#
+: ${EDITOR:=ee}
+
+
+#
+# If X11 is requested, which terminal and what options should we use?
+#
+X11TERM=xterm
+X11TERM_OPTS=
+
+#
+# Location of ttys(5)
+#
+ETC_TTYS=/etc/ttys
+
+############################################################ MAIN
+
+# Incorporate rc-file if it exists
+[ -f "$HOME/.bsdconfigrc" ] && f_include "$HOME/.bsdconfigrc"
+
+#
+# Process command-line arguments
+#
+while getopts hSX flag; do
+ case "$flag" in
+ h|\?) f_usage $BSDCFG_LIBE/$APP_DIR/USAGE "PROGRAM_NAME" "$pgm";;
+ esac
+done
+shift $(( $OPTIND - 1 ))
+
+#
+# Initialize
+#
+f_dialog_init
+f_dialog_title "$msg_configure_ttys"
+f_dialog_backtitle "${ipgm:+bsdconfig }$pgm"
+f_mustberoot_init
+f_dialog_title "$msg_user_confirmation_requested"
+f_dialog_yesno "$msg_help_text" || exit $SUCCESS
+f_dialog_title_restore
+
+#
+# Make sure $EDITOR exists and is executable
+#
+case "$EDITOR" in
+*/*)
+ [ -e "$EDITOR" ] ||
+ f_die 1 "$msg_no_such_file_or_directory" "$pgm" "$EDITOR"
+ [ -x "$EDITOR" ] ||
+ f_die 1 "$msg_permission_denied" "$pgm" "$EDITOR"
+ ;;
+*)
+ f_have "$EDITOR" ||
+ f_die 1 "$msg_no_such_file_or_directory" "$pgm" "$EDITOR"
+esac
+
+#
+# If Xdialog(1) is requested, we'll need to wrap bsdinstall(8) into xterm(1)
+#
+if [ "$USE_XDIALOG" ]; then
+ #
+ # Make sure $X11TERM exists and is executable
+ #
+ case "$X11TERM" in
+ */*)
+ [ -e "$X11TERM" ] || f_die 1 \
+ "$msg_no_such_file_or_directory" "$pgm" "$X11TERM"
+ [ -x "$X11TERM" ] || f_die 1 \
+ "$msg_permission_denied" "$pgm" "$X11TERM"
+ ;;
+ *)
+ f_have "$X11TERM" || f_die 1 \
+ "$msg_no_such_file_or_directory" "$pgm" "$X11TERM"
+ esac
+
+ exec $X11TERM $X11TERM_OPTS -e $EDITOR $ETC_TTYS
+else
+ exec $EDITOR $ETC_TTYS
+fi
+
+################################################################################
+# END
+################################################################################
diff --git a/usr.sbin/bsdconfig/usermgmt/INDEX b/usr.sbin/bsdconfig/usermgmt/INDEX
new file mode 100644
index 0000000..81e43aa
--- /dev/null
+++ b/usr.sbin/bsdconfig/usermgmt/INDEX
@@ -0,0 +1,60 @@
+# Copyright (c) 2012 Ron McDowell
+# Copyright (c) 2012 Devin Teske
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in the
+# documentation and/or other materials provided with the distribution.
+#
+# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+# SUCH DAMAGE.
+#
+# $FreeBSD$
+
+#
+# Title that will be shown on the bsdconfig menu
+menu_title="Login/Group Management"
+#
+# a short descriptive line shown at the bottom of the bsdconfig menu.
+# keep it short because any line longer than the terminal width will
+# be truncated.
+menu_help="Manage system user and/or group information"
+#
+# two-part variable that defines an action to take when 'keyword'
+# is passed on a bsdconfig command line. variable takes the form
+# "keyword|command" and multiple occurrences of the variable
+# (with different 'keyword's, or different 'keyword's AND 'command's)
+# are allowed. If 'command' begins with a '/' then the full
+# path to the program is needed. If 'command' begins with anything
+# else it is a path relative to the directory this INDEX file is in.
+# 'keyword' can be i18n'ed but 'command' is the name of a script.
+menu_selection="usermgmt|usermgmt"
+menu_selection="useradd|useradd"
+menu_selection="useredit|useredit"
+menu_selection="userdel|userdel"
+menu_selection="groupmgmt|usermgmt"
+menu_selection="groupadd|groupadd"
+menu_selection="groupedit|groupedit"
+menu_selection="groupdel|groupdel"
+#
+# Items below this line do NOT need i18n translation----------------------
+#
+# Name of the program to be run when this menu choice is selected.
+# if it begins with a '/' then the full path to the program is needed.
+# if it begins with anything else it is a path relative to the directory
+# this INDEX file is in.
+menu_program="usermgmt"
diff --git a/usr.sbin/bsdconfig/usermgmt/Makefile b/usr.sbin/bsdconfig/usermgmt/Makefile
new file mode 100644
index 0000000..910d380
--- /dev/null
+++ b/usr.sbin/bsdconfig/usermgmt/Makefile
@@ -0,0 +1,17 @@
+# $FreeBSD$
+
+NO_OBJ=
+
+SUBDIR= include share
+
+FILESDIR= ${LIBEXECDIR}/bsdconfig/070.usermgmt
+FILES= INDEX USAGE
+
+SCRIPTSDIR= ${FILESDIR}
+SCRIPTS= groupadd groupdel groupedit groupinput \
+ useradd userdel useredit userinput usermgmt
+
+beforeinstall:
+ mkdir -p ${DESTDIR}${FILESDIR}
+
+.include <bsd.prog.mk>
diff --git a/usr.sbin/bsdconfig/usermgmt/USAGE b/usr.sbin/bsdconfig/usermgmt/USAGE
new file mode 100644
index 0000000..9aa4dca
--- /dev/null
+++ b/usr.sbin/bsdconfig/usermgmt/USAGE
@@ -0,0 +1,33 @@
+# Copyright (c) 2012 Devin Teske
+# All Rights Reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in the
+# documentation and/or other materials provided with the distribution.
+#
+# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING BUT NOT LIMITED TO, THE
+# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+# DAMAGES (INLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+# SUCH DAMAGE.
+#
+# $FreeBSD$
+
+Usage: bsdconfig @PROGRAM_NAME@ [OPTIONS]
+
+OPTIONS:
+ -h Print usage statement and exit.
+ -S Secure X11 mode (implies `-X'). As root, always prompt-for
+ and validate sudo(8) username/password before starting.
+ -X Use Xdialog(1) in place of dialog(1).
diff --git a/usr.sbin/bsdconfig/usermgmt/groupadd b/usr.sbin/bsdconfig/usermgmt/groupadd
new file mode 100755
index 0000000..7326ab3
--- /dev/null
+++ b/usr.sbin/bsdconfig/usermgmt/groupadd
@@ -0,0 +1,64 @@
+#!/bin/sh
+#-
+# Copyright (c) 2012 Ron McDowell
+# Copyright (c) 2012 Devin Teske
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in the
+# documentation and/or other materials provided with the distribution.
+#
+# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+# SUCH DAMAGE.
+#
+# $FreeBSD$
+#
+############################################################ INCLUDES
+
+BSDCFG_SHARE="/usr/share/bsdconfig"
+. $BSDCFG_SHARE/common.subr || exit 1
+f_include $BSDCFG_SHARE/dialog.subr
+
+BSDCFG_LIBE="/usr/libexec/bsdconfig" APP_DIR="070.usermgmt"
+
+ipgm=$( f_index_menu_selection $BSDCFG_LIBE/$APP_DIR/INDEX "$pgm" )
+[ $? -eq $SUCCESS -a "$ipgm" ] && pgm="$ipgm"
+
+############################################################ MAIN
+
+# Incorporate rc-file if it exists
+[ -f "$HOME/.bsdconfigrc" ] && f_include "$HOME/.bsdconfigrc"
+
+#
+# Process command-line arguments
+#
+while getopts hSX flag; do
+ case "$flag" in
+ h|\?) f_usage $BSDCFG_LIBE/$APP_DIR/USAGE "PROGRAM_NAME" "$pgm";;
+ esac
+done
+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"
+
+################################################################################
+# END
+################################################################################
diff --git a/usr.sbin/bsdconfig/usermgmt/groupdel b/usr.sbin/bsdconfig/usermgmt/groupdel
new file mode 100755
index 0000000..cbbe554
--- /dev/null
+++ b/usr.sbin/bsdconfig/usermgmt/groupdel
@@ -0,0 +1,93 @@
+#!/bin/sh
+#-
+# Copyright (c) 2012 Ron McDowell
+# Copyright (c) 2012 Devin Teske
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in the
+# documentation and/or other materials provided with the distribution.
+#
+# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+# SUCH DAMAGE.
+#
+# $FreeBSD$
+#
+############################################################ INCLUDES
+
+BSDCFG_SHARE="/usr/share/bsdconfig"
+. $BSDCFG_SHARE/common.subr || exit 1
+f_include $BSDCFG_SHARE/dialog.subr
+f_include $BSDCFG_SHARE/mustberoot.subr
+f_include $BSDCFG_SHARE/usermgmt/group_input.subr
+
+BSDCFG_LIBE="/usr/libexec/bsdconfig" APP_DIR="070.usermgmt"
+f_include_lang $BSDCFG_LIBE/$APP_DIR/include/messages.subr
+
+ipgm=$( f_index_menu_selection $BSDCFG_LIBE/$APP_DIR/INDEX "$pgm" )
+[ $? -eq $SUCCESS -a "$ipgm" ] && pgm="$ipgm"
+
+############################################################ MAIN
+
+# Incorporate rc-file if it exists
+[ -f "$HOME/.bsdconfigrc" ] && f_include "$HOME/.bsdconfigrc"
+
+#
+# Process command-line arguments
+#
+while getopts hSX flag; do
+ case "$flag" in
+ h|\?) f_usage $BSDCFG_LIBE/$APP_DIR/USAGE "PROGRAM_NAME" "$pgm";;
+ esac
+done
+shift $(( $OPTIND - 1 ))
+
+#
+# Initialize
+#
+f_dialog_init
+f_dialog_title "$msg_delete $msg_group"
+f_dialog_backtitle "${ipgm:+bsdconfig }$pgm"
+f_mustberoot_init
+
+#
+# Loop until the user Exits, Cancels or presses ESC
+#
+while :; do
+ f_dialog_menu_group_list
+ retval=$?
+ mtag=$( f_dialog_menutag )
+ f_dprintf "retval=$retval mtag=[$mtag]"
+
+ [ $retval -eq 0 ] || f_die
+
+ case "$mtag" in
+ "X $msg_exit") break ;;
+
+ *) # anything else is a group name
+ $BSDCFG_LIBE/$APP_DIR/groupinput \
+ ${USE_XDIALOG:+-X} mode="Delete" group="$mtag"
+ ;;
+
+ esac
+done
+
+exit $SUCCESS
+
+################################################################################
+# END
+################################################################################
diff --git a/usr.sbin/bsdconfig/usermgmt/groupedit b/usr.sbin/bsdconfig/usermgmt/groupedit
new file mode 100755
index 0000000..6de6fa8
--- /dev/null
+++ b/usr.sbin/bsdconfig/usermgmt/groupedit
@@ -0,0 +1,93 @@
+#!/bin/sh
+#-
+# Copyright (c) 2012 Ron McDowell
+# Copyright (c) 2012 Devin Teske
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in the
+# documentation and/or other materials provided with the distribution.
+#
+# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+# SUCH DAMAGE.
+#
+# $FreeBSD$
+#
+############################################################ INCLUDES
+
+BSDCFG_SHARE="/usr/share/bsdconfig"
+. $BSDCFG_SHARE/common.subr || exit 1
+f_include $BSDCFG_SHARE/dialog.subr
+f_include $BSDCFG_SHARE/mustberoot.subr
+f_include $BSDCFG_SHARE/usermgmt/group_input.subr
+
+BSDCFG_LIBE="/usr/libexec/bsdconfig" APP_DIR="070.usermgmt"
+f_include_lang $BSDCFG_LIBE/$APP_DIR/include/messages.subr
+
+ipgm=$( f_index_menu_selection $BSDCFG_LIBE/$APP_DIR/INDEX "$pgm" )
+[ $? -eq $SUCCESS -a "$ipgm" ] && pgm="$ipgm"
+
+############################################################ MAIN
+
+# Incorporate rc-file if it exists
+[ -f "$HOME/.bsdconfigrc" ] && f_include "$HOME/.bsdconfigrc"
+
+#
+# Process command-line arguments
+#
+while getopts hSX flag; do
+ case "$flag" in
+ h|\?) f_usage $BSDCFG_LIBE/$APP_DIR/USAGE "PROGRAM_NAME" "$pgm";;
+ esac
+done
+shift $(( $OPTIND - 1 ))
+
+#
+# Initialize
+#
+f_dialog_init
+f_dialog_title "$msg_edit_view $msg_group"
+f_dialog_backtitle "${ipgm:+bsdconfig }$pgm"
+f_mustberoot_init
+
+#
+# Loop until the user Exits, Cancels or presses ESC
+#
+while :; do
+ f_dialog_menu_group_list
+ retval=$?
+ mtag=$( f_dialog_menutag )
+ f_dprintf "retval=$retval mtag=[$mtag]"
+
+ [ $retval -eq 0 ] || f_die
+
+ case "$mtag" in
+ "X $msg_exit") break ;;
+
+ *) # anything else is a group name
+ $BSDCFG_LIBE/$APP_DIR/groupinput \
+ ${USE_XDIALOG:+-X} mode="Edit/View" group="$mtag"
+ ;;
+
+ esac
+done
+
+exit $SUCCESS
+
+################################################################################
+# END
+################################################################################
diff --git a/usr.sbin/bsdconfig/usermgmt/groupinput b/usr.sbin/bsdconfig/usermgmt/groupinput
new file mode 100755
index 0000000..2991d33
--- /dev/null
+++ b/usr.sbin/bsdconfig/usermgmt/groupinput
@@ -0,0 +1,297 @@
+#!/bin/sh
+#-
+# Copyright (c) 2012 Ron McDowell
+# Copyright (c) 2012 Devin Teske
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in the
+# documentation and/or other materials provided with the distribution.
+#
+# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+# SUCH DAMAGE.
+#
+# $FreeBSD$
+#
+############################################################ INCLUDES
+
+BSDCFG_SHARE="/usr/share/bsdconfig"
+. $BSDCFG_SHARE/common.subr || exit 1
+f_include $BSDCFG_SHARE/dialog.subr
+f_include $BSDCFG_SHARE/mustberoot.subr
+f_include $BSDCFG_SHARE/usermgmt/group_input.subr
+
+BSDCFG_LIBE="/usr/libexec/bsdconfig" APP_DIR="070.usermgmt"
+f_include_lang $BSDCFG_LIBE/$APP_DIR/include/messages.subr
+
+ipgm=$( f_index_menu_selection $BSDCFG_LIBE/$APP_DIR/INDEX "$pgm" )
+[ $? -eq $SUCCESS -a "$ipgm" ] && pgm="$ipgm"
+
+############################################################ CONFIGURATION
+
+# set some reasonable defaults if /etc/adduser.conf does not exist.
+[ -f /etc/adduser.conf ] && f_include /etc/adduser.conf
+: ${passwdtype:="yes"}
+
+############################################################ FUNCTIONS
+
+# save_changes
+#
+# Save any/all settings (actions performed depend on $mode value).
+#
+save_changes()
+{
+ local err retval=$SUCCESS
+
+ case "$mode" in
+ Delete)
+ err=$( pw groupdel "$group_name" 2>&1 )
+ retval=$?
+ if [ $retval -ne $SUCCESS ]; then
+ f_show_msg "%s %s\n" "$msg_error" "$err"
+ return $retval
+ fi
+ f_show_msg "$msg_group_deleted"
+ ;;
+ Add)
+ local cmd="pw groupadd -n '$group_name'"
+ [ "$group_gid" ] && cmd="$cmd -g '$group_gid'"
+ [ "$group_members" != "$cur_group_members" ] &&
+ cmd="$cmd -M '$group_members'"
+ if [ "$pw_group_password_disable" ]; then
+ cmd="$cmd -h -"
+ elif [ "$group_password" ]; then
+ cmd="echo \"\$group_password\" | $cmd -h 0"
+ fi
+ f_dprintf "cmd=$cmd"
+ err=$( eval $cmd 2>&1 )
+ retval=$?
+ if [ $retval -ne $SUCCESS ]; then
+ f_show_msg "%s %s\n" "$msg_error" "$err"
+ return $retval
+ fi
+ f_show_msg "$msg_group_added"
+ ;;
+ Edit/View)
+ local cmd="pw groupmod -n '$group_name'"
+ [ "$group_gid" ] && cmd="$cmd -g '$group_gid'"
+ [ "$group_members" != "$cur_group_members" ] &&
+ cmd="$cmd -M '$group_members'"
+ if [ "$pw_group_password_disable" ]; then
+ cmd="$cmd -h -"
+ elif [ "$group_password" ]; then
+ cmd="echo \"\$group_password\" | $cmd -h 0"
+ fi
+ f_dprintf "cmd=$cmd"
+ err=$( eval $cmd 2>&1 )
+ retval=$?
+ if [ $retval -ne $SUCCESS ]; then
+ f_show_msg "%s %s\n" "$msg_error" "$err"
+ return $retval
+ fi
+ f_show_msg "$msg_group_updated"
+ ;;
+ esac
+
+ save_flag=
+ return $SUCCESS
+}
+
+# dialog_title_update $mode
+#
+# Set the title based on the given $mode.
+#
+dialog_title_update()
+{
+ local mode="$1"
+ case "$mode" in
+ Add) f_dialog_title "$msg_add $msg_group" ;;
+ Edit/View) f_dialog_title "$msg_edit_view $msg_group: $group" ;;
+ Delete) f_dialog_title "$msg_delete $msg_group: $group" ;;
+ esac
+}
+
+############################################################ MAIN
+
+# Incorporate rc-file if it exists
+[ -f "$HOME/.bsdconfigrc" ] && f_include "$HOME/.bsdconfigrc"
+
+#
+# Process command-line arguments
+#
+while [ $# -gt 0 ]; do
+ key="${1%%=*}"
+ value="${1#*=}"
+ f_dprintf "key=[$key] value=[$value]"
+ case "$key" in
+ mode) mode="$value";;
+ group) group="$value";;
+ esac
+ shift
+done
+f_dprintf "mode=[$mode] group=[$group]"
+
+#
+# Initialize
+#
+f_dialog_init
+dialog_title_update "$mode"
+f_dialog_backtitle "${ipgm:+bsdconfig }$pgm"
+f_mustberoot_init
+menu_text=
+save_flag=
+hline="$hline_arrows_tab_enter"
+
+if [ "$mode" = "Add" ]; then
+ #
+ # Ask a series of questions to pre-fill the editor screen.
+ #
+ # The defaults used in each dialog should allow the user to simply
+ # hit ENTER to proceed, because cancelling a single dialog will
+ # cause them to be returned to the main groupmenu.
+ #
+
+ f_dialog_input_group_name || exit 0
+ [ "$passwdtype" = "yes" ] &&
+ { f_dialog_input_group_password || exit 0; }
+ f_dialog_input_group_gid || exit 0
+ f_dialog_input_group_members || exit 0
+fi
+
+if [ "$mode" = "Edit/View" -o "$mode" = "Delete" ]; then
+ f_input_group "$group" || f_die 1 "$msg_group_not_found"
+fi
+
+cur_group_name="$group_name"
+cur_group_password="$group_password"
+cur_group_gid="$group_gid"
+cur_group_members="$group_members"
+
+[ "$mode" = "Delete" ] && save_flag=1
+
+#
+# Loop until the user decides to Exit, Cancel, or presses ESC
+#
+while :; do
+ dialog_title_update "$mode"
+
+ menu_text=
+ menu_exit="$msg_exit"
+ if [ "$save_flag" ]; then
+ if [ "$mode" = "Delete" ]; then
+ menu_exit="$msg_delete/$msg_exit"
+ menu_text="$msg_delete_exit_or_cancel"
+ else
+ menu_exit="$msg_save/$msg_exit"
+ menu_text="$msg_save_exit_or_cancel"
+ fi
+ fi
+
+ case "$mode" in
+ Delete)
+ menu_items="
+ 'X' '$menu_exit'
+ '1' '$msg_group: $group_name'
+ '-' '$msg_password: -----'
+ '-' '$msg_group_id: $group_gid'
+ '-' '$msg_group_members: $group_members'
+ " # END-QUOTE
+ ;;
+ *)
+ menu_items="
+ 'X' '$menu_exit'
+ '1' '$msg_group: $group_name'
+ '2' '$msg_password: -----'
+ '3' '$msg_group_id: $group_gid'
+ '4' '$msg_group_members: $group_members'
+ " # END-QUOTE
+ esac
+
+ size=$( eval f_dialog_menu_size \
+ \"\$DIALOG_TITLE\" \
+ \"\$DIALOG_BACKTITLE\" \
+ \"\$menu_text\" \
+ \"\$hline\" \
+ $menu_items )
+
+ dialog_menu=$( eval $DIALOG \
+ --title \"\$DIALOG_TITLE\" \
+ --backtitle \"\$DIALOG_BACKTITLE\" \
+ --hline \"\$hline\" \
+ --ok-label \"\$msg_ok\" \
+ --cancel-label \"\$msg_cancel\" \
+ --menu \"\$menu_text\" $size \
+ $menu_items \
+ 2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD
+ )
+
+ retval=$?
+ setvar DIALOG_MENU_$$ "$dialog_menu"
+ mtag=$( f_dialog_menutag )
+ f_dprintf "retval=$retval mtag=[$mtag]"
+
+ # Exit if user has either pressed ESC or chosen Cancel/No
+ [ $retval -eq $SUCCESS ] || f_die
+
+ case "$mtag" in
+ X) # Exit
+ if [ "$save_flag" ]; then
+ save_changes || continue
+ fi
+ break
+ ;;
+ 1) # Group Name
+ case "$mode" in
+ Add) f_dialog_input_group_name "$group_name" ;;
+ Edit/View|Delete)
+ f_dialog_menu_group_list
+ retval=$?
+ mtag=$( f_dialog_menutag )
+ f_dprintf "retval=$retval mtag=[$mtag]"
+
+ # Loop if user has either pressed ESC or chosen Cancel/No
+ [ $retval -eq $SUCCESS ] || continue
+
+ [ "$mtag" = "X $msg_exit" ] && continue
+
+ group="$mtag"
+ f_input_group "$group" || f_die 1 "$msg_group_not_found"
+ cur_group_name="$group_name"
+ cur_group_password="$group_password"
+ cur_group_gid="$group_gid"
+ cur_group_members="$group_members"
+ [ "$mode" != "Delete" ] && save_flag=
+ esac
+ ;;
+ 2) # Password
+ f_dialog_input_group_password
+ ;;
+ 3) # GID
+ f_dialog_input_group_gid "$group_gid"
+ ;;
+ 4) # Users in Group
+ f_dialog_input_group_members "$group_members"
+ ;;
+ esac
+
+done
+
+exit $SUCCESS
+
+################################################################################
+# END
+################################################################################
diff --git a/usr.sbin/bsdconfig/usermgmt/include/Makefile b/usr.sbin/bsdconfig/usermgmt/include/Makefile
new file mode 100644
index 0000000..25d2a07
--- /dev/null
+++ b/usr.sbin/bsdconfig/usermgmt/include/Makefile
@@ -0,0 +1,11 @@
+# $FreeBSD$
+
+NO_OBJ=
+
+FILESDIR= ${LIBEXECDIR}/bsdconfig/070.usermgmt/include
+FILES= messages.subr usermgmt.hlp
+
+beforeinstall:
+ mkdir -p ${DESTDIR}${FILESDIR}
+
+.include <bsd.prog.mk>
diff --git a/usr.sbin/bsdconfig/usermgmt/include/messages.subr b/usr.sbin/bsdconfig/usermgmt/include/messages.subr
new file mode 100644
index 0000000..e2e7bf3
--- /dev/null
+++ b/usr.sbin/bsdconfig/usermgmt/include/messages.subr
@@ -0,0 +1,111 @@
+# Copyright (c) 2012 Ron McDowell
+# Copyright (c) 2012 Devin Teske
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in the
+# documentation and/or other materials provided with the distribution.
+#
+# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+# SUCH DAMAGE.
+#
+# $FreeBSD$
+
+hline_alnum_punc_tab_enter="Use alpha-numeric, punctuation, TAB or ENTER"
+hline_alnum_tab_enter="Use alpha-numeric, TAB or ENTER"
+hline_arrows_space_tab_enter="Use arrows, SPACE, TAB or ENTER"
+hline_arrows_tab_enter="Press arrows, TAB or ENTER"
+hline_num_arrows_tab_enter="Use numbers, arrows, TAB or ENTER"
+hline_num_tab_enter="Use numbers, TAB or ENTER"
+msg_account_expires_in_how_many_days="Account expires in how many days?"
+msg_account_expires_on="Account Expires on"
+msg_account_does_not_expire="Account does not expire"
+msg_add="Add"
+msg_add_group="Add Group"
+msg_add_login="Add Login"
+msg_cancel="Cancel"
+msg_continue="Continue"
+msg_create_dotfiles="Create Dotfiles"
+msg_create_home_directory="Create Home Directory"
+msg_delete="Delete"
+msg_delete_exit_or_cancel="Choose Delete/Exit when finished or Cancel."
+msg_delete_group="Delete Group"
+msg_delete_home_directory="Delete Home Directory"
+msg_delete_login="Delete Login"
+msg_delete_primary_group="Delete Primary Group"
+msg_deleting_home_directory="Deleting home directory..."
+msg_disable_password_auth_for_account="Disable password authentication for this account?"
+msg_disable_password_auth_for_group="Disable password authentication for this group?"
+msg_edit_date_time_with_a_calendar="Edit date/time with a calendar"
+msg_edit_group="Edit/View Group"
+msg_edit_login="Edit/View Login"
+msg_edit_view="Edit/View"
+msg_enter_group_members_manually="Enter Group Members manually"
+msg_enter_number_of_days_into_the_future="Enter number of days into the future"
+msg_enter_value_manually="Edit value manually"
+msg_error="ERROR!"
+msg_exit="Exit"
+msg_full_name="Full Name"
+msg_group="Group"
+msg_group_added="Group Added"
+msg_group_already_used="%s: Group is already used."
+msg_group_deleted="Group Deleted"
+msg_group_is_empty="Group is empty."
+msg_group_id="Group ID"
+msg_group_id_leave_empty_for_default="Group ID (Leave empty for default)"
+msg_group_members="Group Members"
+msg_group_must_start_with_letter="Group must start with a letter."
+msg_group_not_found="%s: Group not found."
+msg_group_password="Group Password"
+msg_group_passwords_do_not_match="Group Passwords do not match."
+msg_group_updated="Group Updated"
+msg_home_directory="Home Directory"
+msg_invalid_number_of_days="Invalid number of days."
+msg_invalid_number_of_seconds="Invalid number of seconds."
+msg_login="Login"
+msg_login_added="Login Added"
+msg_login_already_used="%s: Login is already used."
+msg_login_class="Login Class"
+msg_login_deleted="Login Deleted"
+msg_login_is_empty="Login is empty."
+msg_login_management="Login/Group Management"
+msg_login_must_start_with_letter="Login must start with a letter."
+msg_login_not_found="Login not found."
+msg_login_updated="Login Updated"
+msg_member_of_groups="Member of Groups"
+msg_n_a="N/A"
+msg_number_of_seconds_since_epoch="Number of seconds since the Epoch\n(1 = %s)\nNULL or zero to disable:"
+msg_no="No"
+msg_ok="OK"
+msg_password="Password"
+msg_password_expires_in_how_many_days="Password expires in how many days?"
+msg_password_expires_on="Password Expires on"
+msg_passwords_do_not_match="Passwords do not match."
+msg_password_does_not_expire="Password does not expire"
+msg_reenter_group_password="Re-enter Group Password"
+msg_reenter_password="Re-enter Password"
+msg_save="Save"
+msg_save_exit_or_cancel="Choose Save/Exit when finished or Cancel."
+msg_separated_by_commas="Separated by commas"
+msg_select_group_members_from_list="Select Group Members from a list"
+msg_select_login_shell="Select Login Shell"
+msg_shell="Shell"
+msg_user="User"
+msg_user_id="UID"
+msg_user_id_leave_empty_for_default="UID (Leave empty for default)"
+msg_warning="WARNING!"
+msg_yes="Yes"
diff --git a/usr.sbin/bsdconfig/usermgmt/include/usermgmt.hlp b/usr.sbin/bsdconfig/usermgmt/include/usermgmt.hlp
new file mode 100644
index 0000000..77be9bd
--- /dev/null
+++ b/usr.sbin/bsdconfig/usermgmt/include/usermgmt.hlp
@@ -0,0 +1,76 @@
+These screens allow you to add groups and users to your system.
+
+Many of the settings get reasonable defaults if you leave them blank.
+The first time you have entered the name of the new group or user, the
+system will show you what it would chose for most of these fields.
+You are free to change them, of course.
+
+
+User groups
+===========
+
+It's certainly almost generally a good idea to first create a new
+group for your users. Common names for such a group are "users", or
+even simply "other". Group names are used to control file access
+permissions for users that belong to the same group. Several group
+names are already used for system files.
+
+The numerical user or group IDs are often nothing you want to care for
+explicitly. If you don't fill in these fields, the system will choose
+reasonable defaults. However, these numbers (rather than the
+associated names) are what the operating system actually uses to
+distinguish users and groups -- hence they should normally be unique
+to each person or group, respectively.
+
+
+Users
+=====
+
+The user's login ID is a short (up to 15 characters) alphanumeric ID
+that the user must enter when logging into the system. It's often the
+initial letters of the user's name, and commonly used in lower case.
+It's also the local mail name for this user (though it's possible to
+also set up more descriptive mail alias names later).
+
+The user's login group determines which group access rights the user
+will initially get when logging in. If an additional list of groups is
+provided which the user will become a member of, (s)he will also be
+able to access files of those groups later without providing any
+additional password etc. Except for the "wheel" case mentioned below,
+the additional group membership list should normally not contain the
+login group again.
+
+The user's password can also be set here, and should be chosen with
+care - 6 or more characters, intermixing punctuation and numerics, and
+*not* a word from the dictionary or related to the username is a good
+password choice.
+
+Some of the system's groups have a special meaning. In particular,
+members of group "wheel" are the only people who are later allowed to
+become superuser using the command su(1). So if you're going to add a
+new user who should later perform administrative tasks, don't forget
+to add him to this group! (Well, ``he'' will most likely be yourself
+in the very first place. :)
+
+Also, members of group "operator" will by default get permissions for
+minor administrative operations, like performing system backups, or
+shutting down the system -- without first becoming superuser! So,
+take care when adding people to this group.
+
+The ``full name'' field serves as a comment only. It is also used by
+mail front ends to determine the real name of the user, hence you
+should actually fill in the first and last name of this user. By
+convention, this field can be divided into comma-separated subfields,
+where the office location, the work phone number, and the home phone
+number follow the full name of the user.
+
+The home directory is the directory in the filesystem where the user
+is being logged into, and where his personalized setup files (``dot
+files'', since they usually begin with a `.' and are not displayed by
+the ls(1) command by default) will be looked up. It is often created
+under /usr/home/ or /home/.
+
+Finally, the shell is the user's initial command interpreter. The
+default shell is /bin/sh, some users prefer the more historic
+/bin/csh. Other, often more user-friendly and comfortable shells can
+be found in the ports and packages collection.
diff --git a/usr.sbin/bsdconfig/usermgmt/share/Makefile b/usr.sbin/bsdconfig/usermgmt/share/Makefile
new file mode 100644
index 0000000..d6b9e3a
--- /dev/null
+++ b/usr.sbin/bsdconfig/usermgmt/share/Makefile
@@ -0,0 +1,11 @@
+# $FreeBSD$
+
+NO_OBJ=
+
+FILESDIR= ${SHAREDIR}/bsdconfig/usermgmt
+FILES= group_input.subr user_input.subr
+
+beforeinstall:
+ mkdir -p ${DESTDIR}${FILESDIR}
+
+.include <bsd.prog.mk>
diff --git a/usr.sbin/bsdconfig/usermgmt/share/group_input.subr b/usr.sbin/bsdconfig/usermgmt/share/group_input.subr
new file mode 100644
index 0000000..e3d59d0
--- /dev/null
+++ b/usr.sbin/bsdconfig/usermgmt/share/group_input.subr
@@ -0,0 +1,462 @@
+if [ ! "$_USERMGMT_GROUP_INPUT_SUBR" ]; then _USERMGMT_GROUP_INPUT_SUBR=1
+#
+# Copyright (c) 2012 Ron McDowell
+# Copyright (c) 2012 Devin Teske
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in the
+# documentation and/or other materials provided with the distribution.
+#
+# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+# SUCH DAMAGE.
+#
+# $FreeBSD$
+#
+############################################################ INCLUDES
+
+BSDCFG_SHARE="/usr/share/bsdconfig"
+. $BSDCFG_SHARE/common.subr || exit 1
+f_include $BSDCFG_SHARE/dialog.subr
+f_include $BSDCFG_SHARE/strings.subr
+
+BSDCFG_LIBE="/usr/libexec/bsdconfig" APP_DIR="070.usermgmt"
+f_include_lang $BSDCFG_LIBE/include/messages.subr
+f_include_lang $BSDCFG_LIBE/$APP_DIR/include/messages.subr
+
+############################################################ FUNCTIONS
+
+# f_input_group $group
+#
+# Given $group name or id, create the environment variables group_name,
+# group_gid, and group_members (and group_password is reset to NULL).
+#
+f_input_group()
+{
+ eval $( pw groupshow "$1" | awk -F: '
+ {
+ printf "group_name='\'%s\''\n", $1
+ printf "group_password=\n"
+ printf "group_gid='\'%s\''\n", $3
+ printf "group_members='\'%s\''\n", $4
+ exit
+ }' )
+}
+
+# f_dialog_menu_group_list
+#
+# Allows the user to select a group from a list.
+#
+f_dialog_menu_group_list()
+{
+ local menu_list size
+ local hline="$hline_alnum_punc_tab_enter"
+
+ menu_list="
+ 'X $msg_exit' ''
+ " # END-QUOTE
+
+ # Add groups from group(5)
+ menu_list="$menu_list $( pw groupshow -a | awk -F: '
+ !/^[[:space:]]*(#|$)/ {
+ printf "'\'%s\'\ \'%s\''\n", $1, $1
+ }'
+ )"
+
+ size=$( eval f_dialog_menu_size \
+ \"\$DIALOG_TITLE\" \
+ \"\$DIALOG_BACKTITLE\" \
+ \"\" \
+ \"\$hline\" \
+ $menu_list )
+
+ local dialog_menu
+ dialog_menu=$( eval $DIALOG \
+ --clear --title \"\$DIALOG_TITLE\" \
+ --backtitle \"\$DIALOG_BACKTITLE\" \
+ --hline \"\$hline\" \
+ --ok-label \"\$msg_ok\" \
+ --cancel-label \"\$msg_cancel\" \
+ --menu \"\" $size $menu_list \
+ 2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD
+ )
+ local retval=$?
+ setvar DIALOG_MENU_$$ "$dialog_menu"
+ return $retval
+}
+
+# f_dialog_input_group_name [$group_name]
+#
+# Allows the user to enter a new groupname for a given group. If the user does
+# not cancel or press ESC, the $group_name variable will hold the
+# newly-configured value upon return.
+#
+# If $cur_group_name is defined, the user can enter that and by-pass error-
+# checking (allowing the user to "revert" to an old value without, for example,
+# being told that the groupname already exists).
+#
+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"
+ 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
+
+ # Check for no-change
+ [ "$_input" = "$_name" ] && return $SUCCESS
+
+ # Check for reversion
+ if [ "$_input" = "$cur_group_name" ]; then
+ group_name="$cur_group_name"
+ return $SUCCESS
+ fi
+
+ # Check for NULL entry
+ if [ ! "$_input" ]; then
+ f_show_msg "$msg_group_is_empty"
+ continue
+ fi
+
+ # Check for invalid entry
+ if ! echo "$_input" | grep -q "^[[:alpha:]]"; then
+ f_show_msg "$msg_group_must_start_with_letter"
+ continue
+ fi
+
+ # Check for duplicate entry
+ if f_quietly pw groupshow -n "$_input"; then
+ f_show_msg "$msg_group_already_used" "$_input"
+ continue
+ fi
+
+ group_name="$_input"
+ break
+ done
+ save_flag=1
+
+ f_dprintf "group_name: [$cur_group_name]->[$group_name]"
+
+ return $SUCCESS
+}
+
+# f_dialog_input_group_password
+#
+# Prompt the user to enter a password (twice).
+#
+f_dialog_input_group_password()
+{
+ local hline="$hline_alnum_punc_tab_enter"
+ local msg size rmsg rsize
+
+ msg=$( printf "$msg_group_password" )
+ size=$( f_dialog_inputbox_size \
+ "$DIALOG_TITLE" \
+ "$DIALOG_BACKTITLE" \
+ "$msg" \
+ "" \
+ "$hline" )
+
+ rmsg=$( printf "$msg_reenter_group_password" )
+ rsize=$( f_dialog_inputbox_size \
+ "$DIALOG_TITLE" \
+ "$DIALOG_BACKTITLE" \
+ "$rmsg" \
+ "" \
+ "$hline" )
+
+ #
+ # Loop until the user provides taint-free/valid input
+ #
+ local retval _password1 _password2
+ 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\" \
+ --insecure \
+ --passwordbox \"\$msg\" $size \
+ 2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD
+ )
+
+ retval=$?
+ setvar DIALOG_INPUTBOX_$$ "$dialog_inputbox"
+ _password1=$( f_dialog_inputstr )
+
+ # Return if user has either pressed ESC or chosen Cancel/No
+ [ $retval -eq $SUCCESS ] || return $retval
+
+ dialog_inputbox=$( eval $DIALOG \
+ --title \"\$DIALOG_TITLE\" \
+ --backtitle \"\$DIALOG_BACKTITLE\" \
+ --hline \"\$hline\" \
+ --ok-label \"\$msg_ok\" \
+ --cancel-label \"\$msg_cancel\" \
+ --insecure \
+ --passwordbox \"\$rmsg\" $rsize \
+ 2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD
+ )
+
+ retval=$?
+ setvar DIALOG_INPUTBOX_$$ "$dialog_inputbox"
+ _password2=$( f_dialog_inputstr )
+
+ # Return if user has either pressed ESC or chosen Cancel/No
+ [ $retval -eq $SUCCESS ] || return $retval
+
+ # Check for password mismatch
+ if [ "$_password1" != "$_password2" ]; then
+ f_show_msg "$msg_group_passwords_do_not_match"
+ continue
+ fi
+
+ # Check for NULL entry
+ if [ ! "$_password1" ]; then
+ f_dialog_yesno \
+ "$msg_disable_password_auth_for_group" ||
+ continue
+ pw_group_password_disable=1
+ else
+ pw_group_password_disable=
+ fi
+
+ group_password="$_password1"
+ break
+ done
+ save_flag=1
+
+ f_dprintf "group_password: [$cur_group_password]->[$group_password]"
+
+ return $SUCCESS
+}
+
+# f_dialog_input_group_gid [$group_gid]
+#
+# Allow the user to enter a new GID for a given group. If the user does not
+# cancel or press ESC, the $group_gid variable will hold the newly-configured
+# value upon return.
+#
+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 )
+
+ # Return if user has either pressed ESC or chosen Cancel/No
+ [ $retval -eq $SUCCESS ] || return $retval
+
+ group_gid="$_input"
+ save_flag=1
+
+ f_dprintf "group_gid: [$cur_group_gid]->[$group_gid]"
+
+ return $SUCCESS
+}
+
+# f_dialog_input_group_members [$group_members]
+#
+# Allow the user to modify a list of members for a given group. If the user does
+# not cancel or press ESC, the $group_members variable will hold the newly-
+# configured value upon return.
+#
+f_dialog_input_group_members()
+{
+ local menu_choice msg size retval _input="$1"
+ local hline="$hline_num_arrows_tab_enter"
+ local user
+ local menu_list
+ local all_users_valid
+ local _group_members
+ local checklist_users
+
+ menu_list="
+ 'X' '$msg_continue'
+ '1' '$msg_select_group_members_from_list'
+ '2' '$msg_enter_group_members_manually'
+ " # END-QUOTE
+
+ local dialog_menu
+ while :; do
+ msg="$msg_group_members:"
+ menu_size=$( eval f_dialog_menu_size \
+ \"\$DIALOG_TITLE\" \
+ \"\$DIALOG_BACKTITLE\" \
+ \"\$msg\" \
+ \"\$hline\" \
+ $menu_list )
+ dialog_menu=$( eval $DIALOG \
+ --title \"\$DIALOG_TITLE\" \
+ --backtitle \"\$DIALOG_BACKTITLE\" \
+ --hline \"\$hline\" \
+ --ok-label \"\$msg_ok\" \
+ --cancel-label \"\$msg_cancel\" \
+ --menu \"\$msg\" $menu_size \
+ $menu_list \
+ 2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD
+ )
+ retval=$?
+ setvar DIALOG_MENU_$$ "$dialog_menu"
+ menu_choice=$( f_dialog_menutag )
+ f_dprintf "retval=$retval menu_choice=[$menu_choice]"
+
+ # Return if user has either pressed ESC or chosen Cancel/No
+ [ $retval -eq $SUCCESS ] || return $retval
+
+ case "$menu_choice" in
+ X) # Exit
+ break ;;
+ 1) # Select Group Members from a list
+ user_list=$( pw usershow -a | awk -F: '
+ !/^[[:space:]]*(#|$)/ { printf "%s\n", $1 }' )
+ checklist_users=
+ for user in $user_list; do
+ checklist_users="$checklist_users $user \"\""
+ if echo "$_input" | grep -q "\<$user\>"; then
+ checklist_users="$checklist_users on"
+ else
+ checklist_users="$checklist_users off"
+ fi
+ done
+
+ size=$( eval f_dialog_radiolist_size \
+ \"\$DIALOG_TITLE\" \
+ \"\$DIALOG_BACKTITLE\" \
+ \"\" \
+ \"\$hline\" \
+ $checklist_users )
+ local dialog_inputbox
+ dialog_inputbox=$( eval $DIALOG \
+ --title \"\$DIALOG_TITLE\" \
+ --backtitle \"\$DIALOG_BACKTITLE\" \
+ --separate-output \
+ --hline \"\$hline\" \
+ --ok-label \"\$msg_ok\" \
+ --cancel-label \"\$msg_cancel\" \
+ --checklist \"\$msg\" $size \
+ $checklist_users \
+ 2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD
+ )
+ retval=$?
+ setvar DIALOG_INPUTBOX_$$ "$dialog_inputbox"
+ _group_members=$( f_dialog_inputstr | tr '\n' ' ' |
+ sed -e 's/[[:space:]]\{1,\}/,/g;s/^,//;s/,$//' )
+
+ # Return to previous menu if user has either
+ # pressed ESC or chosen Cancel/No
+ [ $retval -eq $SUCCESS ] || continue
+
+ _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 )
+
+ # Return to previous menu if user has either
+ # pressed ESC or chosen Cancel/No
+ [ $retval -eq $SUCCESS ] || continue
+
+ _input="$_group_members"
+ ;;
+ esac
+ done
+
+ group_members="$_input"
+ save_flag=1
+ f_dprintf "group_members: [$cur_group_members]->[$group_members]"
+
+ return $SUCCESS
+}
+
+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
new file mode 100644
index 0000000..8b356b6
--- /dev/null
+++ b/usr.sbin/bsdconfig/usermgmt/share/user_input.subr
@@ -0,0 +1,1243 @@
+if [ ! "$_USERMGMT_USER_INPUT_SUBR" ]; then _USERMGMT_USER_INPUT_SUBR=1
+#
+# Copyright (c) 2012 Ron McDowell
+# Copyright (c) 2012 Devin Teske
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in the
+# documentation and/or other materials provided with the distribution.
+#
+# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+# SUCH DAMAGE.
+#
+# $FreeBSD$
+#
+############################################################ INCLUDES
+
+BSDCFG_SHARE="/usr/share/bsdconfig"
+. $BSDCFG_SHARE/common.subr || exit 1
+f_include $BSDCFG_SHARE/dialog.subr
+f_include $BSDCFG_SHARE/strings.subr
+
+BSDCFG_LIBE="/usr/libexec/bsdconfig" APP_DIR="070.usermgmt"
+f_include_lang $BSDCFG_LIBE/include/messages.subr
+f_include_lang $BSDCFG_LIBE/$APP_DIR/include/messages.subr
+
+############################################################ CONFIGURATION
+
+#
+# Default location of shells(5)
+#
+: ${ETC_SHELLS:=/etc/shells}
+
+############################################################ FUNCTIONS
+
+# f_get_member_groups $user
+#
+# Get a list of additional groups $user is a member of in group(5).
+#
+f_get_member_groups()
+{
+ echo $( pw groupshow -a | awk -F: "/[:,]$1(,|\$)/{print \$1}" )
+}
+
+# f_input_user $user
+#
+# Given $user name or id, create the environment variables pw_name, pw_uid,
+# pw_gid, pw_class, pw_password_expire, pw_account_expire, pw_gecos,
+# pw_home_dir, pw_shell, and pw_member_groups (and pw_password is reset to
+# NULL).
+#
+f_input_user()
+{
+ local user="$1"
+ eval $( pw usershow "$user" | awk -F: '
+ {
+ printf "pw_name='\'%s\''\n", $1
+ printf "pw_password=\n"
+ printf "pw_uid='\'%s\''\n", $3
+ printf "pw_gid='\'%s\''\n", $4
+ printf "pw_class='\'%s\''\n", $5
+ printf "pw_password_expire='\'%s\''\n", $6
+ printf "pw_account_expire='\'%s\''\n", $7
+ printf "pw_gecos='\'%s\''\n", $8
+ printf "pw_home_dir='\'%s\''\n", $9
+ printf "pw_shell='\'%s\''\n", $10
+ }' )
+ pw_member_groups=$( f_get_member_groups "$user" )
+}
+
+# f_dialog_menu_user_list
+#
+# Allows the user to select a login from a list.
+#
+f_dialog_menu_user_list()
+{
+ local menu_list size
+ local hline="$hline_alnum_punc_tab_enter"
+
+ menu_list="
+ 'X $msg_exit' ''
+ " # END-QUOTE
+
+ # Add users from passwd(5)
+ menu_list="$menu_list $( pw usershow -a | awk -F: '
+ !/^[[:space:]]*(#|$)/ {
+ printf "'\'%s\'\ \'%s\''\n", $1, $8
+ }'
+ )"
+
+ size=$( eval f_dialog_menu_size \
+ \"\$DIALOG_TITLE\" \
+ \"\$DIALOG_BACKTITLE\" \
+ \"\" \
+ \"\$hline\" \
+ $menu_list )
+
+ local dialog_menu
+ dialog_menu=$( eval $DIALOG \
+ --clear --title \"\$DIALOG_TITLE\" \
+ --backtitle \"\$DIALOG_BACKTITLE\" \
+ --hline \"\$hline\" \
+ --ok-label \"\$msg_ok\" \
+ --cancel-label \"\$msg_cancel\" \
+ --menu \"\" $size $menu_list \
+ 2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD
+ )
+ local retval=$?
+ setvar DIALOG_MENU_$$ "$dialog_menu"
+ return $retval
+}
+
+# f_dialog_input_member_groups [$member_groups]
+#
+# Allows the user to edit group memberships for a given user. If the user does
+# not cancel or press ESC, the $pw_member_groups variable will hold the newly-
+# configured value upon return.
+#
+f_dialog_input_member_groups()
+{
+ local msg="$( printf "$msg_member_of_groups" )"
+ local hline="$hline_alnum_tab_enter"
+
+ #
+ # Loop until the user provides taint-free/valid input
+ #
+ local size retval all_groups checklist_groups="" _member_groups="$1"
+ all_groups=$( pw groupshow -a | awk -F: '
+ !/^[[:space:]]*(#|$)/ {
+ printf "%s\n", $1
+ }'
+ )
+ for grp in $all_groups; do
+ checklist_groups="$checklist_groups $grp $grp"
+ if echo "$_member_groups" | grep -q "\<$grp\>"; then
+ checklist_groups="$checklist_groups on"
+ else
+ checklist_groups="$checklist_groups off"
+ fi
+ done
+
+ while :; do
+ size=$( eval f_dialog_radiolist_size \
+ \"\$DIALOG_TITLE\" \
+ \"\$DIALOG_BACKTITLE\" \
+ \"\" \
+ \"\$hline\" \
+ $checklist_groups )
+ local dialog_inputbox
+ dialog_inputbox=$( eval $DIALOG \
+ --title \"\$DIALOG_TITLE\" \
+ --backtitle \"\$DIALOG_BACKTITLE\" \
+ --separate-output \
+ --hline \"\$hline\" \
+ --ok-label \"\$msg_ok\" \
+ --cancel-label \"\$msg_cancel\" \
+ --checklist \"\$msg\" $size \
+ $checklist_groups \
+ 2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD
+ )
+
+ retval=$?
+ setvar DIALOG_INPUTBOX_$$ "$dialog_inputbox"
+ _member_groups=$( f_dialog_inputstr )
+
+ # Return if user has either pressed ESC or chosen Cancel/No
+ [ $retval -eq $SUCCESS ] || return $retval
+
+ #
+ # Validate each of the groups the user has entered
+ #
+ local group all_groups_valid=1
+ for group in $_member_groups; do
+ if ! f_quietly pw groupshow -n "$group"; then
+ f_show_msg "$msg_group_not_found" "$group"
+ all_groups_valid=
+ break
+ fi
+ done
+ [ "$all_groups_valid" ] || continue
+
+ pw_member_groups="$_member_groups"
+ break
+ done
+ save_flag=1
+
+ local debug="pw_member_groups:"
+ f_dprintf "$debug [$cur_pw_member_groups]->[$pw_member_groups]"
+
+ return $SUCCESS
+}
+
+# f_dialog_input_name [$name]
+#
+# Allows the user to enter a new username for a given user. If the user does
+# not cancel or press ESC, the $pw_name variable will hold the newly-configured
+# value upon return.
+#
+# If $cur_pw_name is defined, the user can enter that and by-pass error-
+# checking (allowing the user to "revert" to an old value without, for example,
+# being told that the username already exists).
+#
+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"
+ 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
+
+ # Check for no-change
+ [ "$_input" = "$_name" ] && return $SUCCESS
+
+ # Check for reversion
+ if [ "$_input" = "$cur_pw_name" ]; then
+ pw_name="$cur_pw_name"
+ return $SUCCESS
+ fi
+
+ # Check for NULL entry
+ if [ ! "$_input" ]; then
+ f_show_msg "$msg_login_is_empty"
+ continue
+ fi
+
+ # Check for invalid entry
+ if ! echo "$_input" | grep -q "^[[:alpha:]]"; then
+ f_show_msg "$msg_login_must_start_with_letter"
+ continue
+ fi
+
+ # Check for duplicate entry
+ if f_quietly pw usershow -n "$_input"; then
+ f_show_msg "$msg_login_already_used" "$_input"
+ continue
+ fi
+
+ pw_name="$_input"
+ break
+ done
+ save_flag=1
+
+ f_dprintf "pw_name: [$cur_pw_name]->[$pw_name]"
+
+ return $SUCCESS
+}
+
+# f_dialog_input_password
+#
+# Prompt the user to enter a password (twice).
+#
+f_dialog_input_password()
+{
+ local hline="$hline_alnum_punc_tab_enter"
+ local msg size rmsg rsize
+
+ msg=$( printf "$msg_password" )
+ size=$( f_dialog_inputbox_size \
+ "$DIALOG_TITLE" \
+ "$DIALOG_BACKTITLE" \
+ "$msg" \
+ "" \
+ "$hline" )
+
+ rmsg=$( printf "$msg_reenter_password" )
+ rsize=$( f_dialog_inputbox_size \
+ "$DIALOG_TITLE" \
+ "$DIALOG_BACKTITLE" \
+ "$rmsg" \
+ "" \
+ "$hline" )
+
+ #
+ # Loop until the user provides taint-free/valid input
+ #
+ local retval _password1 _password2
+ 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\" \
+ --insecure \
+ --passwordbox \"\$msg\" $size \
+ 2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD
+ )
+
+ retval=$?
+ setvar DIALOG_INPUTBOX_$$ "$dialog_inputbox"
+ _password1=$( f_dialog_inputstr )
+
+ # Return if user has either pressed ESC or chosen Cancel/No
+ [ $retval -eq $SUCCESS ] || return $retval
+
+ dialog_inputbox=$( eval $DIALOG \
+ --title \"\$DIALOG_TITLE\" \
+ --backtitle \"\$DIALOG_BACKTITLE\" \
+ --hline \"\$hline\" \
+ --ok-label \"\$msg_ok\" \
+ --cancel-label \"\$msg_cancel\" \
+ --insecure \
+ --passwordbox \"\$rmsg\" $rsize \
+ 2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD
+ )
+
+ retval=$?
+ setvar DIALOG_INPUTBOX_$$ "$dialog_inputbox"
+ _password2=$( f_dialog_inputstr )
+
+ # Return if user has either pressed ESC or chosen Cancel/No
+ [ $retval -eq $SUCCESS ] || return $retval
+
+ # Check for password mismatch
+ if [ "$_password1" != "$_password2" ]; then
+ f_show_msg "$msg_passwords_do_not_match"
+ continue
+ fi
+
+ # Check for NULL entry
+ if [ ! "$_password1" ]; then
+ f_dialog_yesno \
+ "$msg_disable_password_auth_for_account" ||
+ continue
+ pw_password_disable=1
+ else
+ pw_password_disable=
+ fi
+
+ pw_password="$_password1"
+ break
+ done
+ save_flag=1
+
+ f_dprintf "pw_password: [$cur_pw_password]->[$pw_password]"
+
+ return $SUCCESS
+}
+
+# f_dialog_input_gecos [$gecos]
+#
+# Allow the user to enter new GECOS information for a given user. This
+# information is commonly used to store the ``Full Name'' of the user. If the
+# user does not cancel or press ESC, the $pw_gecos variable will hold the
+# newly-configured value upon return.
+#
+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 )
+
+ # Return if user has either pressed ESC or chosen Cancel/No
+ [ $retval -eq $SUCCESS ] || return $retval
+
+ pw_gecos="$_input"
+ save_flag=1
+
+ f_dprintf "pw_gecos: [$cur_pw_gecos]->[$pw_gecos]"
+
+ return $SUCCESS
+}
+
+# f_dialog_input_uid [$uid]
+#
+# Allow the user to enter a new UID for a given user. If the user does not
+# cancel or press ESC, the $pw_uid variable will hold the newly-configured
+# value upon return.
+#
+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 )
+
+ # Return if user has either pressed ESC or chosen Cancel/No
+ [ $retval -eq $SUCCESS ] || return $retval
+
+ pw_uid="$_input"
+ save_flag=1
+
+ f_dprintf "pw_uid: [$cur_pw_uid]->[$pw_uid]"
+
+ return $SUCCESS
+}
+
+# f_dialog_input_gid [$gid]
+#
+# Allow the user to enter a new primary GID for a given user. If the user does
+# not cancel or press ESC, the $pw_gid variable will hold the newly-configured
+# value upon return.
+#
+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 )
+
+ # Return if user has either pressed ESC or chosen Cancel/No
+ [ $retval -eq $SUCCESS ] || return $retval
+
+ pw_gid="$_input"
+ save_flag=1
+
+ f_dprintf "pw_gid: [$cur_pw_gid]->[$pw_gid]"
+
+ return $SUCCESS
+}
+
+# f_dialog_input_class [$class]
+#
+# Allow the user to enter a new login class for a given user. If the user does
+# not cancel or press ESC, the $pw_class variable will hold the newly-
+# configured value upon return.
+#
+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 )
+
+ # Return if user has either pressed ESC or chosen Cancel/No
+ [ $retval -eq $SUCCESS ] || return $retval
+
+ pw_class="$_input"
+ save_flag=1
+
+ f_dprintf "pw_class: [$cur_pw_class]->[$pw_class]"
+
+ return $SUCCESS
+}
+
+# f_dialog_input_change [$seconds]
+#
+# Allow the user to enter a date/time (in number-of-seconds since the `epoch')
+# for when a given user's password must be changed. If the user does not cancel
+# or press ESC, the $pw_password_expire variable will hold the newly-
+# configured value upon return.
+#
+f_dialog_input_change()
+{
+ local calendar_size timebox_size
+ local msg menu_size size retval _input="$1"
+ local hline="$hline_num_arrows_tab_enter"
+
+ local menu_list="
+ '1' '$msg_password_does_not_expire'
+ '2' '$msg_edit_date_time_with_a_calendar'
+ '3' '$msg_enter_number_of_days_into_the_future'
+ '4' '$msg_enter_value_manually'
+ " # END-QUOTE
+
+ #
+ # Loop until the user provides taint-free/cancellation-free input
+ #
+ while :; do
+ msg="$msg_password_expires_on"
+ menu_size=$( eval f_dialog_menu_size \
+ \"\$DIALOG_TITLE\" \
+ \"\$DIALOG_BACKTITLE\" \
+ \"\$msg\" \
+ \"\$hline\" \
+ $menu_list )
+
+ local dialog_menu
+ dialog_menu=$( eval $DIALOG \
+ --title \"\$DIALOG_TITLE\" \
+ --backtitle \"\$DIALOG_BACKTITLE\" \
+ --hline \"\$hline\" \
+ --ok-label \"\$msg_ok\" \
+ --cancel-label \"\$msg_cancel\" \
+ --menu \"\$msg\" $menu_size \
+ $menu_list \
+ 2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD
+ )
+ retval=$?
+ setvar DIALOG_MENU_$$ "$dialog_menu"
+ date_type=$( f_dialog_menutag )
+ f_dprintf "retval=$retval date_type=[$date_type]"
+
+ # Return if user has either pressed ESC or chosen Cancel/No
+ [ $retval -eq $SUCCESS ] || return $retval
+
+ case "$date_type" in
+ 1) # Password does not expire
+ _input=""
+ break ;;
+
+ 2) # Edit date/time with a calendar
+ local _input_date _input_time ret_date ret_time
+
+ local secs="$_input"
+ { f_isinteger "$secs" && [ $secs -gt 0 ]; } || secs=
+ _input_date=$( date -j -f "%s" -- "$secs" \
+ "+%d %m %Y" 2> /dev/null )
+ calendar_size=$( f_dialog_calendar_size \
+ "$DIALOG_TITLE" \
+ "$DIALOG_BACKTITLE" \
+ "$msg" \
+ "$hline" )
+ local dialog_inputbox
+ dialog_inputbox=$( eval $DIALOG \
+ --title \"\$DIALOG_TITLE\" \
+ --backtitle \"\$DIALOG_BACKTITLE\" \
+ --hline \"\$hline\" \
+ --ok-label \"\$msg_ok\" \
+ --cancel-label \"\$msg_cancel\" \
+ --calendar \"\$msg\" $calendar_size \
+ $_input_date \
+ 2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD
+ )
+ retval=$?
+ setvar DIALOG_INPUTBOX_$$ "$dialog_inputbox"
+ ret_date=$( f_dialog_inputstr )
+ f_dprintf "retval=$retval ret_date=[$ret_date]"
+
+ # Return to menu if either ESC or Cancel/No
+ [ $retval -eq $SUCCESS ] || continue
+
+ _input_time=
+ [ "$secs" ] && _input_time=$( date -j \
+ -f %s -- "$_input" "+%H %M %S" 2> /dev/null )
+ timebox_size=$( f_dialog_timebox_size \
+ "$DIALOG_TITLE" \
+ "$DIALOG_BACKTITLE" \
+ "$msg" \
+ "$hline" )
+ local dialog_inputbox
+ dialog_inputbox=$( eval $DIALOG \
+ --title \"\$DIALOG_TITLE\" \
+ --backtitle \"\$DIALOG_BACKTITLE\" \
+ --hline \"\$hline\" \
+ --ok-label \"\$msg_ok\" \
+ --cancel-label \"\$msg_cancel\" \
+ --timebox \"\$msg\" $timebox_size \
+ $_input_time \
+ 2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD
+ )
+ retval=$?
+ setvar DIALOG_INPUTBOX_$$ "$dialog_inputbox"
+ ret_time=$( f_dialog_inputstr )
+ f_dprintf "retval=$retval ret_time=[$ret_time]"
+
+ # Return to menu if either ESC or Cancel/No
+ [ $retval -eq $SUCCESS ] || continue
+
+ _input=$( date \
+ -j -f "%d/%m/%Y %T" \
+ -- "$ret_date $ret_time" \
+ +%s 2> /dev/null )
+ f_dprintf "_input=[$_input]"
+ break ;;
+
+ 3) # Enter number of days into the future
+ local ret_days seconds="$( date +%s )"
+
+ f_isinteger "$_input" || _input=0
+ [ $_input -gt 0 -a $_input -gt $seconds ] &&
+ ret_days=$(( ( $_input - $seconds ) / 86400 ))
+ 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
+
+ # Taint-check the user's input
+ if ! f_isinteger "$ret_days"; then
+ f_show_msg "$msg_invalid_number_of_days"
+ continue
+ fi
+
+ f_dprintf "ret_days=[$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]"
+ break ;;
+
+ 4) # Enter value manually
+ local ret_secs
+
+ 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
+
+ _input="$ret_secs"
+
+ # Taint-check the user's input
+ if ! f_isinteger "${_input:-0}"; then
+ f_show_msg "$msg_invalid_number_of_seconds"
+ continue
+ fi
+
+ f_dprintf "_input=[$_input]"
+ break ;;
+
+ esac
+
+ done # Loop forever
+
+ pw_password_expire="$_input"
+ save_flag=1
+
+ local debug=pw_password_expire
+ f_dprintf "$debug: [$cur_pw_password_expire]->[$pw_password_expire]"
+
+ return $SUCCESS
+}
+
+# f_dialog_input_expire [$seconds]
+#
+# Allow the user to enter a date/time (in number-of-seconds since the `epoch')
+# for when a given user's account should become expired. If the user does not
+# cancel or press ESC, the $pw_account_expire variable will hold the newly-
+# configured value upon return.
+#
+f_dialog_input_expire()
+{
+ local calendar_size timebox_size
+ local msg menu_size size retval _input="$1"
+ local hline="$hline_num_arrows_tab_enter"
+
+ local menu_list="
+ '1' '$msg_account_does_not_expire'
+ '2' '$msg_edit_date_time_with_a_calendar'
+ '3' '$msg_enter_number_of_days_into_the_future'
+ '4' '$msg_enter_value_manually'
+ " # END-QUOTE
+
+ #
+ # Loop until the user provides taint-free/cancellation-free input
+ #
+ while :; do
+ msg="$msg_account_expires_on"
+ menu_size=$( eval f_dialog_menu_size \
+ \"\$DIALOG_TITLE\" \
+ \"\$DIALOG_BACKTITLE\" \
+ \"\$msg\" \
+ \"\$hline\" \
+ $menu_list )
+
+ local dialog_menu
+ dialog_menu=$( eval $DIALOG \
+ --title \"\$DIALOG_TITLE\" \
+ --backtitle \"\$DIALOG_BACKTITLE\" \
+ --hline \"\$hline\" \
+ --ok-label \"\$msg_ok\" \
+ --cancel-label \"\$msg_cancel\" \
+ --menu \"\$msg\" $menu_size \
+ $menu_list \
+ 2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD
+ )
+ retval=$?
+ setvar DIALOG_MENU_$$ "$dialog_menu"
+ date_type=$( f_dialog_menutag )
+ f_dprintf "retval=$retval date_type=[$date_type]"
+
+ # Return if user has either pressed ESC or chosen Cancel/No
+ [ $retval -eq $SUCCESS ] || return $retval
+
+ case "$date_type" in
+ 1) # Account does not expire
+ _input=""
+ break ;;
+
+ 2) # Edit date/time with a calendar
+ local _input_date _input_time ret_date ret_time
+
+ local secs="$_input"
+ { f_isinteger "$secs" && [ $secs -gt 0 ]; } || secs=
+ _input_date=$( date -j -f "%s" -- "$secs" \
+ "+%d %m %Y" 2> /dev/null )
+ calendar_size=$( f_dialog_calendar_size \
+ "$DIALOG_TITLE" \
+ "$DIALOG_BACKTITLE" \
+ "$msg" \
+ "$hline" )
+ local dialog_inputbox
+ dialog_inputbox=$( eval $DIALOG \
+ --title \"\$DIALOG_TITLE\" \
+ --backtitle \"\$DIALOG_BACKTITLE\" \
+ --hline \"\$hline\" \
+ --ok-label \"\$msg_ok\" \
+ --cancel-label \"\$msg_cancel\" \
+ --calendar \"\$msg\" $calendar_size \
+ $_input_date \
+ 2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD
+ )
+ retval=$?
+ setvar DIALOG_INPUTBOX_$$ "$dialog_inputbox"
+ ret_date=$( f_dialog_inputstr )
+ f_dprintf "retval=$retval ret_date=[$ret_date]"
+
+ # Return to menu if either ESC or Cancel/No
+ [ $retval -eq $SUCCESS ] || continue
+
+ _input_time=
+ [ "$secs" ] && _input_time=$( date -j \
+ -f %s -- "$_input" "+%H %M %S" 2> /dev/null )
+ timebox_size=$( f_dialog_timebox_size \
+ "$DIALOG_TITLE" \
+ "$DIALOG_BACKTITLE" \
+ "$msg" \
+ "$hline" )
+ dialog_inputbox=$( eval $DIALOG \
+ --title \"\$DIALOG_TITLE\" \
+ --backtitle \"\$DIALOG_BACKTITLE\" \
+ --hline \"\$hline\" \
+ --ok-label \"\$msg_ok\" \
+ --cancel-label \"\$msg_cancel\" \
+ --timebox \"\$msg\" $timebox_size \
+ $_input_time \
+ 2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD
+ )
+ retval=$?
+ setvar DIALOG_INPUTBOX_$$ "$dialog_inputbox"
+ ret_time=$( f_dialog_inputstr )
+ f_dprintf "retval=$retval ret_time=[$ret_time]"
+
+ # Return to menu if either ESC or Cancel/No
+ [ $retval -eq $SUCCESS ] || continue
+
+ _input=$( date \
+ -j -f "%d/%m/%Y %T" \
+ -- "$ret_date $ret_time" \
+ +%s 2> /dev/null )
+ f_dprintf "_input=[$_input]"
+ break ;;
+
+ 3) # Enter number of days into the future
+ local ret_days seconds="$( date +%s )"
+
+ f_isinteger "$_input" || _input=0
+ [ $_input -gt 0 -a $_input -gt $seconds ] &&
+ ret_days=$(( ( $_input - $seconds ) / 86400 ))
+ 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
+
+ # Taint-check the user's input
+ if ! f_isinteger "$ret_days"; then
+ f_show_msg "$msg_invalid_number_of_days"
+ continue
+ fi
+
+ f_dprintf "ret_days=[$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]"
+ break ;;
+
+ 4) # Enter value manually
+ local ret_secs
+
+ 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
+
+ _input="$ret_secs"
+
+ # Taint-check the user's input
+ if ! f_isinteger "${_input:-0}"; then
+ f_show_msg "$msg_invalid_number_of_seconds"
+ continue
+ fi
+
+ f_dprintf "_input=[$_input]"
+ break ;;
+
+ esac
+
+ done # Loop forever
+
+ pw_account_expire="$_input"
+ save_flag=1
+
+ local debug=pw_account_expire
+ f_dprintf "$debug: [$cur_pw_account_expire]->[$pw_account_expire]"
+
+ return $SUCCESS
+}
+
+# f_dialog_input_home_dir [$home_dir]
+#
+# Allow the user to enter a new home directory for a given user. If the user
+# does not cancel or press ESC, the $pw_home_dir variable will hold the newly-
+# configured value upon return.
+#
+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 )
+
+ # Return if user has either pressed ESC or chosen Cancel/No
+ [ $retval -eq $SUCCESS ] || return $retval
+
+ pw_home_dir="$_input"
+ save_flag=1
+
+ f_dprintf "pw_home_dir: [$cur_pw_home_dir]->[$pw_home_dir]"
+
+ return $SUCCESS
+}
+
+# f_dialog_input_home_create
+#
+# Prompt the user to confirm creation of a given user's home directory. If the
+# user does not cancel (by choosing "No") or press ESC, the $pw_home_create
+# variable will hold $msg_yes upon return, otherwise $msg_no. Use these return
+# variables ($msg_yes and $msg_no) for comparisons to be i18n-compatible.
+#
+f_dialog_input_home_create()
+{
+ local retval
+
+ f_dialog_yesno "$msg_create_home_directory"
+ retval=$?
+
+ if [ $retval -eq $SUCCESS ]; then
+ pw_home_create="$msg_yes"
+ else
+ pw_home_create="$msg_no"
+ fi
+ save_flag=1
+
+ f_dprintf "pw_home_create: [$cur_pw_home_create]->[$pw_home_create]"
+
+ [ $retval -ne 255 ] # return failure if user pressed ESC
+}
+
+# f_dialog_input_group_delete
+#
+# Prompt the user to confirm deletion of a given user's primary group. If the
+# user does not cancel (by choosing "No") or press ESC, the $pw_group_delete
+# variable will hold $msg_yes upon return, otherwise $msg_no. Use these return
+# variables ($msg_yes and $msg_no) for comparisons to be i18n-compatible.
+#
+f_dialog_input_group_delete()
+{
+ local retval
+
+ if f_isinteger "$pw_gid"; then
+ if [ $pw_gid -lt 1000 ]; then
+ f_dialog_noyes "$msg_delete_primary_group"
+ else
+ f_dialog_yesno "$msg_delete_primary_group"
+ fi
+ elif [ "$pw_gid" ]; then
+ local gid=0
+ gid=$( pw groupshow "$pw_gid" | awk -F: '{print $3}' )
+ if f_isinteger "$gid" && [ $gid -lt 1000 ]; then
+ f_dialog_noyes "$msg_delete_primary_group"
+ else
+ f_dialog_yesno "$msg_delete_primary_group"
+ fi
+ else
+ f_dialog_yesno "$msg_delete_primary_group"
+ fi
+ retval=$?
+
+ if [ $retval -eq $SUCCESS ]; then
+ pw_group_delete="$msg_yes"
+ else
+ pw_group_delete="$msg_no"
+ fi
+ save_flag=1
+
+ f_dprintf "pw_group_delete: [$cur_pw_group_delete]->[$pw_group_delete]"
+
+ [ $retval -ne 255 ] # return failure if user pressed ESC
+}
+
+# f_dialog_input_home_delete
+#
+# Prompt the user to confirm deletion of a given user's home directory. If the
+# user does not cancel (by choosing "No") or press ESC, the $pw_home_delete
+# variable will hold $msg_yes upon return, otherwise $msg_no. Use these return
+# variables ($msg_yes and $msg_no) for comparisons to be i18n-compatible.
+#
+f_dialog_input_home_delete()
+{
+ local retval
+
+ f_dialog_yesno "$msg_delete_home_directory"
+ retval=$?
+
+ if [ $retval -eq $SUCCESS ]; then
+ pw_home_delete="$msg_yes"
+ else
+ pw_home_delete="$msg_no"
+ fi
+ save_flag=1
+
+ f_dprintf "pw_home_delete: [$cur_pw_home_delete]->[$pw_home_delete]"
+
+ [ $retval -ne 255 ] # return failure if user pressed ESC
+}
+
+# f_dialog_input_dotfiles_create
+#
+# Prompt the user to confirm population of a given user's home directory with
+# sample dotfiles. If the user does not cancel (by choosing "No") or press ESC,
+# the $pw_dotfiles_create variable will hold $msg_yes upon return, otherwise
+# $msg_no. Use these return variables ($msg_yes and $msg_no) for comparison to
+# be i18n-compatible.
+#
+f_dialog_input_dotfiles_create()
+{
+ local retval
+
+ f_dialog_yesno "$msg_create_dotfiles"
+ retval=$?
+
+ if [ $retval -eq $SUCCESS ]; then
+ pw_dotfiles_create="$msg_yes"
+ else
+ pw_dotfiles_create="$msg_no"
+ fi
+ save_flag=1
+
+ local debug="pw_dotfiles_create:"
+ f_dprintf "$debug: [$cur_pw_dotfiles_create]->[$pw_dotfiles_create]"
+
+ [ $retval -ne 255 ] # return failure if user pressed ESC
+}
+
+# f_dialog_input_shell [$shell]
+#
+# Allow the user to select a new login shell for a given user. If the user does
+# not cancel or press ESC, the $pw_home_dir variable will hold the newly-
+# configured value upon return.
+#
+#
+f_dialog_input_shell()
+{
+ local size retval shells shell_list _input="$1"
+ local hline="$hline_arrows_space_tab_enter"
+ local prompt="$msg_select_login_shell"
+
+ shells=$( awk '!/^[[:space:]]*(#|$)/{print}' "$ETC_SHELLS" )
+ shell_list=$(
+ for shell in $shells; do
+ if [ "$shell" = "$_input" ]; then
+ echo "'$shell' '' 'on'"
+ else
+ echo "'$shell' '' 'off'"
+ fi
+ done
+ )
+
+ size=$( eval f_dialog_radiolist_size \
+ \"\$DIALOG_TITLE\" \
+ \"\$DIALOG_BACKTITLE\" \
+ \"\$prompt\" \
+ \"\$hline\" \
+ $shell_list )
+
+ local dialog_inputbox
+ dialog_inputbox=$( eval $DIALOG \
+ --title \"\$DIALOG_TITLE\" \
+ --backtitle \"\$DIALOG_BACKTITLE\" \
+ --hline \"\$hline\" \
+ --ok-label \"\$msg_ok\" \
+ --cancel-label \"\$msg_cancel\" \
+ --radiolist \"\$prompt\" $size \
+ $shell_list \
+ 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
+
+ pw_shell="$_input"
+ save_flag=1
+
+ f_dprintf "pw_shell: [$cur_pw_shell]->[$pw_shell]"
+
+ return $SUCCESS
+}
+
+fi # ! $_USERMGMT_USER_INPUT_SUBR
diff --git a/usr.sbin/bsdconfig/usermgmt/useradd b/usr.sbin/bsdconfig/usermgmt/useradd
new file mode 100755
index 0000000..4821ccd
--- /dev/null
+++ b/usr.sbin/bsdconfig/usermgmt/useradd
@@ -0,0 +1,64 @@
+#!/bin/sh
+#-
+# Copyright (c) 2012 Ron McDowell
+# Copyright (c) 2012 Devin Teske
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in the
+# documentation and/or other materials provided with the distribution.
+#
+# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+# SUCH DAMAGE.
+#
+# $FreeBSD$
+#
+############################################################ INCLUDES
+
+BSDCFG_SHARE="/usr/share/bsdconfig"
+. $BSDCFG_SHARE/common.subr || exit 1
+f_include $BSDCFG_SHARE/dialog.subr
+
+BSDCFG_LIBE="/usr/libexec/bsdconfig" APP_DIR="070.usermgmt"
+
+ipgm=$( f_index_menu_selection $BSDCFG_LIBE/$APP_DIR/INDEX "$pgm" )
+[ $? -eq $SUCCESS -a "$ipgm" ] && pgm="$ipgm"
+
+############################################################ MAIN
+
+# Incorporate rc-file if it exists
+[ -f "$HOME/.bsdconfigrc" ] && f_include "$HOME/.bsdconfigrc"
+
+#
+# Process command-line arguments
+#
+while getopts hSX flag; do
+ case "$flag" in
+ h|\?) f_usage $BSDCFG_LIBE/$APP_DIR/USAGE "PROGRAM_NAME" "$pgm";;
+ esac
+done
+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"
+
+################################################################################
+# END
+################################################################################
diff --git a/usr.sbin/bsdconfig/usermgmt/userdel b/usr.sbin/bsdconfig/usermgmt/userdel
new file mode 100755
index 0000000..c530682
--- /dev/null
+++ b/usr.sbin/bsdconfig/usermgmt/userdel
@@ -0,0 +1,93 @@
+#!/bin/sh
+#-
+# Copyright (c) 2012 Ron McDowell
+# Copyright (c) 2012 Devin Teske
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in the
+# documentation and/or other materials provided with the distribution.
+#
+# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+# SUCH DAMAGE.
+#
+# $FreeBSD$
+#
+############################################################ INCLUDES
+
+BSDCFG_SHARE="/usr/share/bsdconfig"
+. $BSDCFG_SHARE/common.subr || exit 1
+f_include $BSDCFG_SHARE/dialog.subr
+f_include $BSDCFG_SHARE/mustberoot.subr
+f_include $BSDCFG_SHARE/usermgmt/user_input.subr
+
+BSDCFG_LIBE="/usr/libexec/bsdconfig" APP_DIR="070.usermgmt"
+f_include_lang $BSDCFG_LIBE/$APP_DIR/include/messages.subr
+
+ipgm=$( f_index_menu_selection $BSDCFG_LIBE/$APP_DIR/INDEX "$pgm" )
+[ $? -eq $SUCCESS -a "$ipgm" ] && pgm="$ipgm"
+
+############################################################ MAIN
+
+# Incorporate rc-file if it exists
+[ -f "$HOME/.bsdconfigrc" ] && f_include "$HOME/.bsdconfigrc"
+
+#
+# Process command-line arguments
+#
+while getopts hSX flag; do
+ case "$flag" in
+ h|\?) f_usage $BSDCFG_LIBE/$APP_DIR/USAGE "PROGRAM_NAME" "$pgm";;
+ esac
+done
+shift $(( $OPTIND - 1 ))
+
+#
+# Initialize
+#
+f_dialog_init
+f_dialog_title "$msg_delete $msg_login"
+f_dialog_backtitle "${ipgm:+bsdconfig }$pgm"
+f_mustberoot_init
+
+#
+# Loop until the user Exits, Cancels or presses ESC
+#
+while :; do
+ f_dialog_menu_user_list
+ retval=$?
+ mtag=$( f_dialog_menutag )
+ f_dprintf "retval=$retval mtag=[$mtag]"
+
+ [ $retval -eq 0 ] || f_die
+
+ case "$mtag" in
+ "X $msg_exit") break ;;
+
+ *) # anything else is a userid
+ $BSDCFG_LIBE/$APP_DIR/userinput \
+ ${USE_XDIALOG:+-X} mode="Delete" user="$mtag"
+ ;;
+
+ esac
+done
+
+exit $SUCCESS
+
+################################################################################
+# END
+################################################################################
diff --git a/usr.sbin/bsdconfig/usermgmt/useredit b/usr.sbin/bsdconfig/usermgmt/useredit
new file mode 100755
index 0000000..a38afa2
--- /dev/null
+++ b/usr.sbin/bsdconfig/usermgmt/useredit
@@ -0,0 +1,93 @@
+#!/bin/sh
+#-
+# Copyright (c) 2012 Ron McDowell
+# Copyright (c) 2012 Devin Teske
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in the
+# documentation and/or other materials provided with the distribution.
+#
+# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+# SUCH DAMAGE.
+#
+# $FreeBSD$
+#
+############################################################ INCLUDES
+
+BSDCFG_SHARE="/usr/share/bsdconfig"
+. $BSDCFG_SHARE/common.subr || exit 1
+f_include $BSDCFG_SHARE/dialog.subr
+f_include $BSDCFG_SHARE/mustberoot.subr
+f_include $BSDCFG_SHARE/usermgmt/user_input.subr
+
+BSDCFG_LIBE="/usr/libexec/bsdconfig" APP_DIR="070.usermgmt"
+f_include_lang $BSDCFG_LIBE/$APP_DIR/include/messages.subr
+
+ipgm=$( f_index_menu_selection $BSDCFG_LIBE/$APP_DIR/INDEX "$pgm" )
+[ $? -eq $SUCCESS -a "$ipgm" ] && pgm="$ipgm"
+
+############################################################ MAIN
+
+# Incorporate rc-file if it exists
+[ -f "$HOME/.bsdconfigrc" ] && f_include "$HOME/.bsdconfigrc"
+
+#
+# Process command-line arguments
+#
+while getopts hSX flag; do
+ case "$flag" in
+ h|\?) f_usage $BSDCFG_LIBE/$APP_DIR/USAGE "PROGRAM_NAME" "$pgm";;
+ esac
+done
+shift $(( $OPTIND - 1 ))
+
+#
+# Initialize
+#
+f_dialog_init
+f_dialog_title "$msg_edit_view $msg_login"
+f_dialog_backtitle "${ipgm:+bsdconfig }$pgm"
+f_mustberoot_init
+
+#
+# Loop until the user Exits, Cancels or presses ESC
+#
+while :; do
+ f_dialog_menu_user_list
+ retval=$?
+ mtag=$( f_dialog_menutag )
+ f_dprintf "retval=$retval mtag=[$mtag]"
+
+ [ $retval -eq 0 ] || f_die
+
+ case "$mtag" in
+ "X $msg_exit") break ;;
+
+ *) # anything else is a userid
+ $BSDCFG_LIBE/$APP_DIR/userinput \
+ ${USE_XDIALOG:+-X} mode="Edit/View" user="$mtag"
+ ;;
+
+ esac
+done
+
+exit $SUCCESS
+
+################################################################################
+# END
+################################################################################
diff --git a/usr.sbin/bsdconfig/usermgmt/userinput b/usr.sbin/bsdconfig/usermgmt/userinput
new file mode 100755
index 0000000..aca8aed
--- /dev/null
+++ b/usr.sbin/bsdconfig/usermgmt/userinput
@@ -0,0 +1,518 @@
+#!/bin/sh
+#-
+# Copyright (c) 2012 Ron McDowell
+# Copyright (c) 2012 Devin Teske
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in the
+# documentation and/or other materials provided with the distribution.
+#
+# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+# SUCH DAMAGE.
+#
+# $FreeBSD$
+#
+############################################################ INCLUDES
+
+BSDCFG_SHARE="/usr/share/bsdconfig"
+. $BSDCFG_SHARE/common.subr || exit 1
+f_include $BSDCFG_SHARE/dialog.subr
+f_include $BSDCFG_SHARE/mustberoot.subr
+f_include $BSDCFG_SHARE/usermgmt/user_input.subr
+
+BSDCFG_LIBE="/usr/libexec/bsdconfig" APP_DIR="070.usermgmt"
+f_include_lang $BSDCFG_LIBE/$APP_DIR/include/messages.subr
+
+ipgm=$( f_index_menu_selection $BSDCFG_LIBE/$APP_DIR/INDEX "$pgm" )
+[ $? -eq $SUCCESS -a "$ipgm" ] && pgm="$ipgm"
+
+############################################################ CONFIGURATION
+
+# set some reasonable defaults if /etc/adduser.conf does not exist.
+[ -f /etc/adduser.conf ] && f_include /etc/adduser.conf
+: ${passwdtype:="yes"}
+: ${homeprefix:="/home"}
+: ${defaultshell:="/bin/sh"}
+: ${udotdir:="/usr/share/skel"}
+
+############################################################ FUNCTIONS
+
+# copy_dotfiles
+#
+# Copy `skel' dot-files to a new home directory.
+#
+copy_dotfiles()
+{
+ ( # Operate within sub-shell to protect CWD/glob of parent
+ cd "$udotdir" || exit $?
+ set +f # glob
+ for file in dot.*; do
+ cp -n "$file" "$pw_home_dir/${file#dot}" || exit $?
+ done
+ )
+}
+
+# save_changes
+#
+# Save any/all settings (actions performed depend on $mode value).
+#
+save_changes()
+{
+ local err retval=$SUCCESS
+
+ case "$mode" in
+ Delete)
+ err=$( pw userdel -u "$pw_uid" 2>&1 )
+ retval=$?
+ if [ $retval -ne $SUCCESS ]; then
+ f_show_msg "%s %s\n" "$msg_error" "$err"
+ return $retval
+ fi
+ f_show_msg "$msg_login_deleted"
+
+ if [ "$pw_group_delete" = "$msg_yes" ] &&
+ f_quietly pw groupshow -g "$pw_gid"
+ then
+ err=$( pw groupdel -g "$pw_gid" 2>&1 ) ||
+ f_show_msg "%s %s\n" "$msg_warning" "$err"
+ fi
+
+ if [ "$pw_home_delete" = "$msg_yes" ]; then
+ f_dialog_info "$msg_deleting_home_directory"
+ err=$( rm -Rf "$pw_home_dir" 2>&1 ) ||
+ f_show_msg "%s %s\n" "$msg_warning" "$err"
+ fi
+ ;;
+ Add)
+ local cmd="pw useradd -n '$pw_name'"
+ [ "$pw_member_groups" ] && cmd="$cmd -G '$pw_member_groups'"
+ [ "$pw_class" ] && cmd="$cmd -L '$pw_class'"
+ [ "$pw_gecos" ] && cmd="$cmd -c '$pw_gecos'"
+ [ "$pw_home_dir" ] && cmd="$cmd -d '$pw_home_dir'"
+ [ "$pw_account_expire" ] && cmd="$cmd -e '$pw_account_expire'"
+ [ "$pw_gid" ] && cmd="$cmd -g '$pw_gid'"
+ [ "$pw_password_expire" ] && cmd="$cmd -p '$pw_password_expire'"
+ [ "$pw_shell" ] && cmd="$cmd -s '$pw_shell'"
+ [ "$pw_uid" ] && cmd="$cmd -u '$pw_uid'"
+ if [ "$pw_password_disable" ]; then
+ cmd="$cmd -h -"
+ elif [ "$pw_password" ]; then
+ cmd="echo \"\$pw_password\" | $cmd -h 0"
+ fi
+ f_dprintf "cmd=$cmd"
+ err=$( eval $cmd 2>&1 )
+ retval=$?
+ if [ $retval -ne $SUCCESS ]; then
+ f_show_msg "%s %s\n" "$msg_error" "$err"
+ return $retval
+ fi
+ f_show_msg "$msg_login_added"
+
+ if [ "$pw_home_create" = "$msg_yes" ]; then
+ err=$( mkdir -p "$pw_home_dir" 2>&1 )
+ if [ $? -ne $SUCCESS ]; then
+ f_show_msg "%s %s\n" "$msg_warning" "$err"
+ elif [ -e "$pw_home_dir" ]; then
+ err=$( chown -R "$pw_uid:$pw_gid" \
+ "$pw_home_dir" 2>&1 )
+ [ $? -eq $SUCCESS ] || f_show_msg \
+ "%s %s\n" "$msg_warning" "$err"
+ fi
+ fi
+
+ if [ "$pw_dotfiles_create" = "$msg_yes" ]; then
+ err=$( copy_dotfiles 2>&1 ) ||
+ f_show_msg "%s %s\n" "$msg_warning" "$err"
+ fi
+
+ user="$pw_name"
+ f_quietly pw usershow -n "$pw_name" &&
+ mode="Edit/View" # Change mode
+ ;;
+ Edit/View)
+ local cmd="pw usermod -n '$pw_name'"
+ [ "$pw_member_groups" ] && cmd="$cmd -G '$pw_member_groups'"
+ [ "$pw_class" ] && cmd="$cmd -L '$pw_class'"
+ [ "$pw_gecos" ] && cmd="$cmd -c '$pw_gecos'"
+ [ "$pw_home_dir" ] && cmd="$cmd -d '$pw_home_dir'"
+ [ "$pw_account_expire" ] && cmd="$cmd -e '$pw_account_expire'"
+ [ "$pw_gid" ] && cmd="$cmd -g '$pw_gid'"
+ [ "$pw_password_expire" ] && cmd="$cmd -p '$pw_password_expire'"
+ [ "$pw_shell" ] && cmd="$cmd -s '$pw_shell'"
+ [ "$pw_uid" ] && cmd="$cmd -u '$pw_uid'"
+ if [ "$pw_password_disable" ]; then
+ cmd="$cmd -h -"
+ elif [ "$pw_password" ]; then
+ cmd="echo \"\$pw_password\" | $cmd -h 0"
+ fi
+ f_dprintf "cmd=$cmd"
+ err=$( eval $cmd 2>&1 )
+ retval=$?
+ if [ $retval -ne $SUCCESS ]; then
+ f_show_msg "%s %s\n" "$msg_error" "$err"
+ return $retval
+ fi
+ f_show_msg "$msg_login_updated"
+
+ if [ "$pw_home_create" = "$msg_yes" ]; then
+ err=$( mkdir -p "$pw_home_dir" )
+ if [ $? -ne $SUCCESS ]; then
+ f_show_msg "%s %s\n" "$msg_warning" "$err"
+ elif [ -e "$pw_home_dir" ]; then
+ err=$( chown -R "$pw_uid:$pw_gid" \
+ "$pw_home_dir" 2>&1 )
+ [ $? -eq $SUCCESS ] || f_show_msg \
+ "%s %s\n" "$msg_warning" "$err"
+ fi
+ fi
+
+ if [ "$pw_dotfiles_create" = "$msg_yes" ]; then
+ err=$( copy_dotfiles 2>&1 ) ||
+ f_show_msg "%s %s\n" "$msg_warning" "$err"
+ fi
+ ;;
+ esac
+
+ save_flag=
+ return $SUCCESS
+}
+
+# dialog_title_update $mode
+#
+# Set the title based on the given $mode.
+#
+dialog_title_update()
+{
+ local mode="$1"
+ case "$mode" in
+ Add) f_dialog_title "$msg_add $msg_user" ;;
+ Edit/View) f_dialog_title "$msg_edit_view $msg_user: $user" ;;
+ Delete) f_dialog_title "$msg_delete $msg_user: $user" ;;
+ esac
+}
+
+############################################################ MAIN
+
+# Incorporate rc-file if it exists
+[ -f "$HOME/.bsdconfigrc" ] && f_include "$HOME/.bsdconfigrc"
+
+#
+# Process command-line arguments
+#
+while [ $# -gt 0 ]; do
+ key="${1%%=*}"
+ value="${1#*=}"
+ f_dprintf "key=[$key] value=[$value]"
+ case "$key" in
+ mode) mode="$value";;
+ user) user="$value";;
+ esac
+ shift
+done
+f_dprintf "mode=[$mode] user=[$user]"
+
+#
+# Initialize
+#
+f_dialog_init
+dialog_title_update "$mode"
+f_dialog_backtitle "${ipgm:+bsdconfig }$pgm"
+f_mustberoot_init
+menu_text=
+save_flag=
+hline="$hline_arrows_tab_enter"
+
+if [ "$mode" = "Add" ]; then
+ #
+ # Ask a series of questions to pre-fill the editor screen.
+ #
+ # The defaults used in each dialog should allow the user to simply
+ # hit ENTER to proceed, because cancelling a single dialog will
+ # cause them to be returned to the main usermenu.
+ #
+
+ f_dialog_input_name || exit 0
+ f_dialog_input_gecos "$pw_name" || exit 0
+ [ "$passwdtype" = "yes" ] &&
+ { f_dialog_input_password || exit 0; }
+ f_dialog_input_uid || exit 0
+ f_dialog_input_gid || exit 0
+ f_dialog_input_member_groups || exit 0
+ f_dialog_input_class || exit 0
+ f_dialog_input_change || exit 0
+ f_dialog_input_expire || exit 0
+ f_dialog_input_home_dir "$homeprefix/$pw_name" || exit 0
+ pw_dotfiles_create="$msg_no"
+ if [ ! -d "$homeprefix/$pw_name" ]; then
+ f_dialog_input_home_create || exit 0
+ [ "$pw_home_create" = "$msg_yes" ] &&
+ { f_dialog_input_dotfiles_create || exit 0; }
+ fi
+ f_dialog_input_shell "$defaultshell" || exit 0
+fi
+
+if [ "$mode" = "Edit/View" -o "$mode" = "Delete" ]; then
+ f_input_user "$user" || f_die 1 "$msg_login_not_found"
+fi
+
+if [ "$mode" = "Edit/View" ]; then
+ [ -d "$pw_home_dir" ] || pw_home_create="$msg_no"
+ pw_dotfiles_create="$msg_no"
+fi
+
+if [ "$mode" = "Delete" ]; then
+ f_dialog_input_group_delete || exit 0
+ pw_home_delete="$msg_no"
+ [ -d "$pw_home_dir" ] &&
+ { f_dialog_input_home_delete || exit 0; }
+fi
+
+cur_pw_name="$pw_name"
+cur_pw_password="$pw_password"
+cur_pw_uid="$pw_uid"
+cur_pw_gid="$pw_gid"
+cur_pw_member_groups="$pw_member_groups"
+cur_pw_class="$pw_class"
+cur_pw_password_expire="$pw_password_expire"
+cur_pw_account_expire="$pw_account_expire"
+cur_pw_gecos="$pw_gecos"
+cur_pw_home_dir="$pw_home_dir"
+cur_pw_shell="$pw_shell"
+cur_pw_group_delete="$pw_group_delete"
+cur_pw_home_create="$pw_home_create"
+cur_pw_home_delete="$pw_home_delete"
+cur_pw_dotfiles_create="$pw_dotfiles_create"
+
+[ "$mode" = "Delete" ] && save_flag=1
+
+#
+# Loop until the user decides to Exit, Cancel, or presses ESC
+#
+while :; do
+ dialog_title_update "$mode"
+
+ menu_text=
+ menu_exit="$msg_exit"
+ if [ "$save_flag" ]; then
+ if [ "$mode" = "Delete" ]; then
+ menu_exit="$msg_delete/$msg_exit"
+ menu_text="$msg_delete_exit_or_cancel"
+ else
+ menu_exit="$msg_save/$msg_exit"
+ menu_text="$msg_save_exit_or_cancel"
+ fi
+ fi
+
+ pw_password_expires_on="$pw_password_expire"
+ f_isinteger "$pw_password_expire" && [ $pw_password_expire -ne 0 ] &&
+ pw_password_expires_on=$(
+ date -r "$pw_password_expire" "+%F %T %Z"
+ )
+ pw_account_expires_on="$pw_account_expire"
+ f_isinteger "$pw_account_expire" && [ "$pw_account_expire" -ne 0 ] &&
+ pw_account_expires_on=$(
+ date -r "$pw_account_expire" "+%F %T %Z"
+ )
+
+ case "$mode" in
+ Delete)
+ menu_items="
+ 'X' '$menu_exit'
+ '1' '$msg_login: $pw_name'
+ '-' '$msg_full_name: $pw_gecos'
+ '-' '$msg_password: -----'
+ '-' '$msg_user_id: $pw_uid'
+ '-' '$msg_group_id: $pw_gid'
+ '-' '$msg_member_of_groups: $pw_member_groups'
+ '-' '$msg_login_class: $pw_class'
+ '-' '$msg_password_expires_on: $pw_password_expires_on'
+ '-' '$msg_account_expires_on: $pw_account_expires_on'
+ '-' '$msg_home_directory: $pw_home_dir'
+ '-' '$msg_shell: $pw_shell'
+ " # END-QUOTE
+ ;;
+ *)
+ menu_items="
+ 'X' '$menu_exit'
+ '1' '$msg_login: $pw_name'
+ '2' '$msg_full_name: $pw_gecos'
+ '3' '$msg_password: -----'
+ '4' '$msg_user_id: $pw_uid'
+ '5' '$msg_group_id: $pw_gid'
+ '6' '$msg_member_of_groups: $pw_member_groups'
+ '7' '$msg_login_class: $pw_class'
+ '8' '$msg_password_expires_on: $pw_password_expires_on'
+ '9' '$msg_account_expires_on: $pw_account_expires_on'
+ 'A' '$msg_home_directory: $pw_home_dir'
+ 'B' '$msg_shell: $pw_shell'
+ " # END-QUOTE
+ esac
+
+ case "$mode" in
+ Add|Edit/View)
+ if [ -d "$pw_home_dir" ]; then menu_items="$menu_items
+ '-' '$msg_create_home_directory: $msg_n_a'
+ 'D' '$msg_create_dotfiles: $pw_dotfiles_create'
+ "; else menu_items="$menu_items
+ 'C' '$msg_create_home_directory: $pw_home_create'
+ 'D' '$msg_create_dotfiles: $pw_dotfiles_create'
+ "; fi
+ ;;
+ Delete)
+ if [ -d "$pw_home_dir" ]; then menu_items="$menu_items
+ 'C' '$msg_delete_primary_group: $pw_group_delete'
+ 'D' '$msg_delete_home_directory: $pw_home_delete'
+ "; else menu_items="$menu_items
+ 'C' '$msg_delete_primary_group: $pw_group_delete'
+ '-' '$msg_delete_home_directory: $msg_n_a'
+ "; fi
+ ;;
+ esac
+
+ size=$( eval f_dialog_menu_size \
+ \"\$DIALOG_TITLE\" \
+ \"\$DIALOG_BACKTITLE\" \
+ \"\$menu_text\" \
+ \"\$hline\" \
+ $menu_items )
+
+ local dialog_menu
+ dialog_menu=$( eval $DIALOG \
+ --title \"\$DIALOG_TITLE\" \
+ --backtitle \"\$DIALOG_BACKTITLE\" \
+ --hline \"\$hline\" \
+ --ok-label \"\$msg_ok\" \
+ --cancel-label \"\$msg_cancel\" \
+ --menu \"\$menu_text\" $size \
+ $menu_items \
+ 2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD
+ )
+
+ retval=$?
+ setvar DIALOG_MENU_$$ "$dialog_menu"
+ mtag=$( f_dialog_menutag )
+ f_dprintf "retval=$retval mtag=[$mtag]"
+
+ # Exit if user has either pressed ESC or chosen Cancel/No
+ [ $retval -eq $SUCCESS ] || f_die
+
+ case "$mtag" in
+ X) # Exit
+ if [ "$save_flag" ]; then
+ save_changes || continue
+ fi
+ break
+ ;;
+ 1) # Login
+ case "$mode" in
+ Add) f_dialog_input_name "$pw_name" ;;
+ Edit/View|Delete)
+ f_dialog_menu_user_list
+ retval=$?
+ mtag=$( f_dialog_menutag )
+ f_dprintf "retval=$retval mtag=[$mtag]"
+
+ # Loop if user has either pressed ESC or chosen Cancel/No
+ [ $retval -eq $SUCCESS ] || continue
+
+ [ "$mtag" = "X $msg_exit" ] && continue
+
+ user="$mtag"
+ f_input_user "$user" || f_die 1 "$msg_login_not_found"
+ cur_pw_name="$pw_name"
+ cur_pw_password="$pw_password"
+ cur_pw_uid="$pw_uid"
+ cur_pw_gid="$pw_gid"
+ cur_pw_member_groups="$pw_member_groups"
+ cur_pw_class="$pw_class"
+ cur_pw_password_expire="$pw_password_expire"
+ cur_pw_account_expire="$pw_account_expire"
+ cur_pw_gecos="$pw_gecos"
+ cur_pw_home_dir="$pw_home_dir"
+ cur_pw_shell="$pw_shell"
+ cur_pw_group_delete="$pw_group_delete"
+ cur_pw_home_create="$pw_home_create"
+ cur_pw_home_delete="$pw_home_delete"
+ cur_pw_dotfiles_create="$pw_dotfiles_create"
+ [ "$mode" != "Delete" ] && save_flag=
+ esac
+ ;;
+ 2) # Full Name
+ f_dialog_input_gecos "$pw_gecos"
+ ;;
+ 3) # Password
+ f_dialog_input_password
+ ;;
+ 4) # UID
+ f_dialog_input_uid "$pw_uid"
+ ;;
+ 5) # Default Group
+ f_dialog_input_gid "$pw_gid"
+ ;;
+ 6) # Member of Groups
+ f_dialog_input_member_groups "$pw_member_groups"
+ ;;
+ 7) # Login Class
+ f_dialog_input_class "$pw_class"
+ ;;
+ 8) # Password Expire on
+ f_dialog_input_change "$pw_password_expire"
+ ;;
+ 9) # Account Expire on
+ f_dialog_input_expire "$pw_account_expire"
+ ;;
+ A) # Home Directory
+ f_dialog_input_home_dir "$pw_home_dir"
+ ;;
+ B) # Shell
+ f_dialog_input_shell "$pw_shell"
+ ;;
+ esac
+
+ case "$mode" in
+ Delete)
+ case "$mtag" in
+ C) # Delete Primary Group
+ f_dialog_input_group_delete ;;
+ D) # Delete Home Directory
+ f_dialog_input_home_delete ;;
+ esac
+ ;;
+ Add|Edit/View)
+ case "$mtag" in
+ C) # Create Home Directory
+ f_dialog_input_home_create
+ [ "$pw_home_create" = "$msg_no" ] &&
+ pw_dotfiles_create="$msg_no"
+ ;;
+ D) # Create Dotfiles
+ f_dialog_input_dotfiles_create
+ [ "$pw_dotfiles_create" = "$msg_yes" ] &&
+ pw_home_create="$msg_yes"
+ ;;
+ esac
+ ;;
+ esac
+
+done
+
+exit $SUCCESS
+
+################################################################################
+# END
+################################################################################
diff --git a/usr.sbin/bsdconfig/usermgmt/usermgmt b/usr.sbin/bsdconfig/usermgmt/usermgmt
new file mode 100755
index 0000000..a2e4b40
--- /dev/null
+++ b/usr.sbin/bsdconfig/usermgmt/usermgmt
@@ -0,0 +1,173 @@
+#!/bin/sh
+#-
+# Copyright (c) 2012 Ron McDowell
+# Copyright (c) 2012 Devin Teske
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in the
+# documentation and/or other materials provided with the distribution.
+#
+# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+# SUCH DAMAGE.
+#
+# $FreeBSD$
+#
+############################################################ INCLUDES
+
+BSDCFG_SHARE="/usr/share/bsdconfig"
+. $BSDCFG_SHARE/common.subr || exit 1
+f_include $BSDCFG_SHARE/dialog.subr
+f_include $BSDCFG_SHARE/mustberoot.subr
+
+BSDCFG_LIBE="/usr/libexec/bsdconfig" APP_DIR="070.usermgmt"
+f_include_lang $BSDCFG_LIBE/$APP_DIR/include/messages.subr
+
+USERMGMT_HELPFILE=$BSDCFG_LIBE/$APP_DIR/include/usermgmt.hlp
+
+ipgm=$( f_index_menu_selection $BSDCFG_LIBE/$APP_DIR/INDEX "$pgm" )
+[ $? -eq $SUCCESS -a "$ipgm" ] && pgm="$ipgm"
+
+############################################################ FUNCTIONS
+
+# dialog_menu_main
+#
+# Display the dialog(1)-based application main menu.
+#
+dialog_menu_main()
+{
+ local menu_list size
+ local hline="$hline_arrows_tab_enter"
+
+ menu_list="
+ 'X' '$msg_exit'
+ '1' '$msg_add_login'
+ '2' '$msg_edit_login'
+ '3' '$msg_delete_login'
+ '-' '-'
+ '4' '$msg_add_group'
+ '5' '$msg_edit_group'
+ '6' '$msg_delete_group'
+ " # END-QUOTE
+
+ size=$( eval f_dialog_menu_size \
+ \"\$DIALOG_TITLE\" \
+ \"\$DIALOG_BACKTITLE\" \
+ \"\" \
+ \"\$hline\" \
+ $menu_list )
+
+ if [ "$USE_XDIALOG" ]; then
+ # need to bump the width for the buttons
+ local height menu_height
+ height="${size%%[$IFS]*}" # first word
+ menu_height="${size##*[$IFS]}" # last word
+ size="$height 40 $menu_height"
+ fi
+
+ local dialog_menu
+ dialog_menu=$( eval $DIALOG \
+ --clear --title \"\$DIALOG_TITLE\" \
+ --backtitle \"\$DIALOG_BACKTITLE\" \
+ --hline \"\$hline\" \
+ --ok-label \"\$msg_ok\" \
+ --cancel-label \"\$msg_cancel\" \
+ --help-button \
+ ${USE_XDIALOG:+--help \"\"} \
+ --menu \"\" $size $menu_list \
+ 2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD
+ )
+ local retval=$?
+ setvar DIALOG_MENU_$$ "$dialog_menu"
+ return $retval
+}
+
+############################################################ MAIN
+
+# Incorporate rc-file if it exists
+[ -f "$HOME/.bsdconfigrc" ] && f_include "$HOME/.bsdconfigrc"
+
+#
+# Process command-line arguments
+#
+while getopts hSX flag; do
+ case "$flag" in
+ h|\?) f_usage $BSDCFG_LIBE/$APP_DIR/USAGE "PROGRAM_NAME" "$pgm";;
+ esac
+done
+shift $(( $OPTIND - 1 ))
+
+#
+# Initialize
+#
+f_dialog_init
+f_dialog_title "$msg_login_management"
+f_dialog_backtitle "${ipgm:+bsdconfig }$pgm"
+f_mustberoot_init
+
+#
+# Launch application main menu
+#
+while :; do
+ dialog_menu_main
+ retval=$?
+ mtag=$( f_dialog_menutag )
+ f_dprintf "retval=$retval mtag=[$mtag]"
+
+ if [ $retval -eq 2 ]; then
+ # The Help button was pressed
+ f_show_help "$USERMGMT_HELPFILE"
+ continue
+ elif [ $retval -ne $SUCCESS ]; then
+ f_die
+ fi
+
+ case "$mtag" in
+ X) # Exit
+ exit 0
+ ;;
+
+ 1) # Add User
+ $BSDCFG_LIBE/$APP_DIR/useradd ${USE_XDIALOG:+-X}
+ ;;
+
+ 2) # Edit/View User
+ $BSDCFG_LIBE/$APP_DIR/useredit ${USE_XDIALOG:+-X}
+ ;;
+
+ 3) # Delete User
+ $BSDCFG_LIBE/$APP_DIR/userdel ${USE_XDIALOG:+-X}
+ ;;
+
+ 4) # Add Group
+ $BSDCFG_LIBE/$APP_DIR/groupadd ${USE_XDIALOG:+-X}
+ ;;
+
+ 5) # Edit/View Group
+ $BSDCFG_LIBE/$APP_DIR/groupedit ${USE_XDIALOG:+-X}
+ ;;
+
+ 6) # Delete Group
+ $BSDCFG_LIBE/$APP_DIR/groupdel ${USE_XDIALOG:+-X}
+ ;;
+
+ esac
+done
+
+################################################################################
+# END
+################################################################################
diff --git a/usr.sbin/bsdinstall/Makefile.depend b/usr.sbin/bsdinstall/Makefile.depend
new file mode 100644
index 0000000..29fda55
--- /dev/null
+++ b/usr.sbin/bsdinstall/Makefile.depend
@@ -0,0 +1,14 @@
+# Autogenerated - do NOT edit!
+
+DEP_RELDIR := ${_PARSEDIR:S,${SRCTOP}/,,}
+
+DEP_MACHINE := ${.PARSEFILE:E}
+
+DIRDEPS = \
+
+
+.include <dirdeps.mk>
+
+.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+# local dependencies - needed for -jN in clean tree
+.endif
diff --git a/usr.sbin/bsdinstall/bsdinstall b/usr.sbin/bsdinstall/bsdinstall
index 236dbac..2b55501 100755
--- a/usr.sbin/bsdinstall/bsdinstall
+++ b/usr.sbin/bsdinstall/bsdinstall
@@ -32,13 +32,8 @@
: ${BSDINSTALL_DISTDIR="/usr/freebsd-dist"}; export BSDINSTALL_DISTDIR
: ${BSDINSTALL_CHROOT="/mnt"}; export BSDINSTALL_CHROOT
-VERB=$1; shift
-
-if [ -z $VERB ]; then
- VERB=auto
-fi
-
-test -d "$BSDINSTALL_TMPETC" || mkdir "$BSDINSTALL_TMPETC"
-echo Running installation step: $VERB $@ >> "$BSDINSTALL_LOG"
-exec /usr/libexec/bsdinstall/$VERB $@ 2>>"$BSDINSTALL_LOG"
+VERB=${1:-auto}; shift
+[ -d "$BSDINSTALL_TMPETC" ] || mkdir -p "$BSDINSTALL_TMPETC"
+echo "Running installation step: $VERB $@" >> "$BSDINSTALL_LOG"
+exec "/usr/libexec/bsdinstall/$VERB" "$@" 2>> "$BSDINSTALL_LOG"
diff --git a/usr.sbin/bsdinstall/distextract/Makefile.depend b/usr.sbin/bsdinstall/distextract/Makefile.depend
new file mode 100644
index 0000000..975ca25
--- /dev/null
+++ b/usr.sbin/bsdinstall/distextract/Makefile.depend
@@ -0,0 +1,23 @@
+# Autogenerated - do NOT edit!
+
+DEP_RELDIR := ${_PARSEDIR:S,${SRCTOP}/,,}
+
+DEP_MACHINE := ${.PARSEFILE:E}
+
+DIRDEPS = \
+ gnu/lib/libdialog \
+ gnu/lib/libgcc \
+ include \
+ include/xlocale \
+ lib/${CSU_DIR} \
+ lib/libarchive \
+ lib/libc \
+ lib/msun \
+ lib/ncurses/ncursesw \
+
+
+.include <dirdeps.mk>
+
+.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+# local dependencies - needed for -jN in clean tree
+.endif
diff --git a/usr.sbin/bsdinstall/distfetch/Makefile.depend b/usr.sbin/bsdinstall/distfetch/Makefile.depend
new file mode 100644
index 0000000..2c289cd
--- /dev/null
+++ b/usr.sbin/bsdinstall/distfetch/Makefile.depend
@@ -0,0 +1,23 @@
+# Autogenerated - do NOT edit!
+
+DEP_RELDIR := ${_PARSEDIR:S,${SRCTOP}/,,}
+
+DEP_MACHINE := ${.PARSEFILE:E}
+
+DIRDEPS = \
+ gnu/lib/libdialog \
+ gnu/lib/libgcc \
+ include \
+ include/xlocale \
+ lib/${CSU_DIR} \
+ lib/libc \
+ lib/libfetch \
+ lib/msun \
+ lib/ncurses/ncursesw \
+
+
+.include <dirdeps.mk>
+
+.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+# local dependencies - needed for -jN in clean tree
+.endif
diff --git a/usr.sbin/bsdinstall/partedit/Makefile.depend b/usr.sbin/bsdinstall/partedit/Makefile.depend
new file mode 100644
index 0000000..2ec2bb4
--- /dev/null
+++ b/usr.sbin/bsdinstall/partedit/Makefile.depend
@@ -0,0 +1,24 @@
+# Autogenerated - do NOT edit!
+
+DEP_RELDIR := ${_PARSEDIR:S,${SRCTOP}/,,}
+
+DEP_MACHINE := ${.PARSEFILE:E}
+
+DIRDEPS = \
+ gnu/lib/libdialog \
+ gnu/lib/libgcc \
+ include \
+ include/xlocale \
+ lib/${CSU_DIR} \
+ lib/libc \
+ lib/libgeom \
+ lib/libutil \
+ lib/msun \
+ lib/ncurses/ncursesw \
+
+
+.include <dirdeps.mk>
+
+.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+# local dependencies - needed for -jN in clean tree
+.endif
diff --git a/usr.sbin/bsdinstall/partedit/diskeditor.c b/usr.sbin/bsdinstall/partedit/diskeditor.c
index 94c374b..7933caa 100644
--- a/usr.sbin/bsdinstall/partedit/diskeditor.c
+++ b/usr.sbin/bsdinstall/partedit/diskeditor.c
@@ -74,7 +74,7 @@ diskeditor_show(const char *title, const char *cprompt,
int x, y;
int i;
int height, width, min_width;
- int partlist_height, partlist_width, min_partlist_width;
+ int partlist_height, partlist_width;
int cur_scroll = 0;
int key, fkey;
int cur_button = 0, cur_part = 0;
@@ -102,7 +102,6 @@ diskeditor_show(const char *title, const char *cprompt,
min_width = 50;
height = width = 0;
partlist_height = 10;
- min_partlist_width = 0;
dlg_tab_correct_str(prompt);
dlg_button_layout(buttons, &min_width);
dlg_auto_size(title, prompt, &height, &width, 2, min_width);
diff --git a/usr.sbin/bsdinstall/partedit/part_wizard.c b/usr.sbin/bsdinstall/partedit/part_wizard.c
index efd4a07..e840ac9 100644
--- a/usr.sbin/bsdinstall/partedit/part_wizard.c
+++ b/usr.sbin/bsdinstall/partedit/part_wizard.c
@@ -294,8 +294,6 @@ wizard_makeparts(struct gmesh *mesh, const char *disk)
struct gmesh submesh;
struct gclass *classp;
struct ggeom *gp;
- struct gconfig *gc;
- const char *scheme;
struct gprovider *pp;
intmax_t swapsize, available;
char swapsizestr[10], rootsizestr[10];
@@ -309,10 +307,6 @@ wizard_makeparts(struct gmesh *mesh, const char *disk)
if (strcmp(gp->lg_name, disk) == 0)
break;
- LIST_FOREACH(gc, &gp->lg_config, lg_config)
- if (strcmp(gc->lg_name, "scheme") == 0)
- scheme = gc->lg_val;
-
pp = provider_for_name(mesh, disk);
available = gpart_max_free(gp, NULL)*pp->lg_sectorsize;
diff --git a/usr.sbin/bsdinstall/scripts/auto b/usr.sbin/bsdinstall/scripts/auto
index f6d1d37..fe4e041 100755
--- a/usr.sbin/bsdinstall/scripts/auto
+++ b/usr.sbin/bsdinstall/scripts/auto
@@ -53,15 +53,15 @@ bsdinstall hostname || error
export DISTRIBUTIONS="base.txz kernel.txz"
if [ -f $BSDINSTALL_DISTDIR/MANIFEST ]; then
- DISTMENU=`cut -f 4,5,6 $BSDINSTALL_DISTDIR/MANIFEST | grep -v -e ^kernel -e ^base`
+ DISTMENU=`awk -F'\t' '!/^(kernel|base)/{print $4,$5,$6}' $BSDINSTALL_DISTDIR/MANIFEST`
exec 3>&1
- EXTRA_DISTS=$(echo $DISTMENU | xargs dialog \
- --backtitle "FreeBSD Installer" \
- --title "Distribution Select" --nocancel --separate-output \
- --checklist "Choose optional system components to install:" \
- 0 0 0 \
- 2>&1 1>&3)
+ EXTRA_DISTS=$( eval dialog \
+ --backtitle \"FreeBSD Installer\" \
+ --title \"Distribution Select\" --nocancel --separate-output \
+ --checklist \"Choose optional system components to install:\" \
+ 0 0 0 $DISTMENU \
+ 2>&1 1>&3 )
for dist in $EXTRA_DISTS; do
export DISTRIBUTIONS="$DISTRIBUTIONS $dist.txz"
done
diff --git a/usr.sbin/bsnmpd/bsnmpd/Makefile.depend b/usr.sbin/bsnmpd/bsnmpd/Makefile.depend
new file mode 100644
index 0000000..6b34d29
--- /dev/null
+++ b/usr.sbin/bsnmpd/bsnmpd/Makefile.depend
@@ -0,0 +1,51 @@
+# Autogenerated - do NOT edit!
+
+DEP_RELDIR := ${_PARSEDIR:S,${SRCTOP}/,,}
+
+DEP_MACHINE := ${.PARSEFILE:E}
+
+DIRDEPS = \
+ gnu/lib/libgcc \
+ include \
+ include/arpa \
+ include/xlocale \
+ lib/${CSU_DIR} \
+ lib/libbegemot \
+ lib/libbsnmp/libbsnmp \
+ lib/libc \
+ lib/libwrap \
+
+
+.include <dirdeps.mk>
+
+.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+# local dependencies - needed for -jN in clean tree
+action.o: oid.h
+action.o: tree.h
+action.po: oid.h
+action.po: tree.h
+config.o: tree.h
+config.po: tree.h
+export.o: tree.h
+export.po: tree.h
+main.o: oid.h
+main.o: tree.h
+main.po: oid.h
+main.po: tree.h
+trans_lsock.o: oid.h
+trans_lsock.o: tree.h
+trans_lsock.po: oid.h
+trans_lsock.po: tree.h
+trans_udp.o: oid.h
+trans_udp.o: tree.h
+trans_udp.po: oid.h
+trans_udp.po: tree.h
+trap.o: oid.h
+trap.o: tree.h
+trap.po: oid.h
+trap.po: tree.h
+tree.o: tree.c
+tree.o: tree.h
+tree.po: tree.c
+tree.po: tree.h
+.endif
diff --git a/usr.sbin/bsnmpd/gensnmptree/Makefile.depend b/usr.sbin/bsnmpd/gensnmptree/Makefile.depend
new file mode 100644
index 0000000..a839545
--- /dev/null
+++ b/usr.sbin/bsnmpd/gensnmptree/Makefile.depend
@@ -0,0 +1,19 @@
+# Autogenerated - do NOT edit!
+
+DEP_RELDIR := ${_PARSEDIR:S,${SRCTOP}/,,}
+
+DEP_MACHINE := ${.PARSEFILE:E}
+
+DIRDEPS = \
+ gnu/lib/libgcc \
+ include \
+ include/xlocale \
+ lib/${CSU_DIR} \
+ lib/libc \
+
+
+.include <dirdeps.mk>
+
+.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+# local dependencies - needed for -jN in clean tree
+.endif
diff --git a/usr.sbin/bsnmpd/modules/Makefile.depend b/usr.sbin/bsnmpd/modules/Makefile.depend
new file mode 100644
index 0000000..29fda55
--- /dev/null
+++ b/usr.sbin/bsnmpd/modules/Makefile.depend
@@ -0,0 +1,14 @@
+# Autogenerated - do NOT edit!
+
+DEP_RELDIR := ${_PARSEDIR:S,${SRCTOP}/,,}
+
+DEP_MACHINE := ${.PARSEFILE:E}
+
+DIRDEPS = \
+
+
+.include <dirdeps.mk>
+
+.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+# local dependencies - needed for -jN in clean tree
+.endif
diff --git a/usr.sbin/bsnmpd/modules/snmp_atm/Makefile.depend b/usr.sbin/bsnmpd/modules/snmp_atm/Makefile.depend
new file mode 100644
index 0000000..6c0e842
--- /dev/null
+++ b/usr.sbin/bsnmpd/modules/snmp_atm/Makefile.depend
@@ -0,0 +1,30 @@
+# Autogenerated - do NOT edit!
+
+DEP_RELDIR := ${_PARSEDIR:S,${SRCTOP}/,,}
+
+DEP_MACHINE := ${.PARSEFILE:E}
+
+DIRDEPS = \
+ include \
+ include/xlocale \
+ lib/libbsnmp/libbsnmp \
+ usr.sbin/bsnmpd/modules \
+
+
+.include <dirdeps.mk>
+
+.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+# local dependencies - needed for -jN in clean tree
+atm_sys.So: atm_oid.h
+atm_sys.So: atm_tree.h
+atm_sys.po: atm_oid.h
+atm_sys.po: atm_tree.h
+atm_tree.So: atm_tree.c
+atm_tree.So: atm_tree.h
+atm_tree.po: atm_tree.c
+atm_tree.po: atm_tree.h
+snmp_atm.So: atm_oid.h
+snmp_atm.So: atm_tree.h
+snmp_atm.po: atm_oid.h
+snmp_atm.po: atm_tree.h
+.endif
diff --git a/usr.sbin/bsnmpd/modules/snmp_bridge/Makefile.depend b/usr.sbin/bsnmpd/modules/snmp_bridge/Makefile.depend
new file mode 100644
index 0000000..6399234
--- /dev/null
+++ b/usr.sbin/bsnmpd/modules/snmp_bridge/Makefile.depend
@@ -0,0 +1,38 @@
+# Autogenerated - do NOT edit!
+
+DEP_RELDIR := ${_PARSEDIR:S,${SRCTOP}/,,}
+
+DEP_MACHINE := ${.PARSEFILE:E}
+
+DIRDEPS = \
+ include \
+ include/xlocale \
+ lib/libbsnmp/libbsnmp \
+ usr.sbin/bsnmpd/modules \
+
+
+.include <dirdeps.mk>
+
+.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+# local dependencies - needed for -jN in clean tree
+bridge_addrs.So: bridge_tree.h
+bridge_addrs.po: bridge_tree.h
+bridge_if.So: bridge_oid.h
+bridge_if.So: bridge_tree.h
+bridge_if.po: bridge_oid.h
+bridge_if.po: bridge_tree.h
+bridge_pf.So: bridge_tree.h
+bridge_pf.po: bridge_tree.h
+bridge_port.So: bridge_tree.h
+bridge_port.po: bridge_tree.h
+bridge_snmp.So: bridge_oid.h
+bridge_snmp.So: bridge_tree.h
+bridge_snmp.po: bridge_oid.h
+bridge_snmp.po: bridge_tree.h
+bridge_sys.So: bridge_tree.h
+bridge_sys.po: bridge_tree.h
+bridge_tree.So: bridge_tree.c
+bridge_tree.So: bridge_tree.h
+bridge_tree.po: bridge_tree.c
+bridge_tree.po: bridge_tree.h
+.endif
diff --git a/usr.sbin/bsnmpd/modules/snmp_hostres/Makefile.depend b/usr.sbin/bsnmpd/modules/snmp_hostres/Makefile.depend
new file mode 100644
index 0000000..ea8cdcf
--- /dev/null
+++ b/usr.sbin/bsnmpd/modules/snmp_hostres/Makefile.depend
@@ -0,0 +1,79 @@
+# Autogenerated - do NOT edit!
+
+DEP_RELDIR := ${_PARSEDIR:S,${SRCTOP}/,,}
+
+DEP_MACHINE := ${.PARSEFILE:E}
+
+DIRDEPS = \
+ include \
+ include/xlocale \
+ lib/libbsnmp/libbsnmp \
+ lib/libdevinfo \
+ lib/libgeom \
+ lib/libkvm \
+ lib/libmemstat \
+ lib/msun \
+ usr.sbin/bsnmpd/modules \
+
+
+.include <dirdeps.mk>
+
+.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+# local dependencies - needed for -jN in clean tree
+hostres_begemot.So: hostres_oid.h
+hostres_begemot.So: hostres_tree.h
+hostres_begemot.po: hostres_oid.h
+hostres_begemot.po: hostres_tree.h
+hostres_device_tbl.So: hostres_oid.h
+hostres_device_tbl.So: hostres_tree.h
+hostres_device_tbl.po: hostres_oid.h
+hostres_device_tbl.po: hostres_tree.h
+hostres_diskstorage_tbl.So: hostres_oid.h
+hostres_diskstorage_tbl.So: hostres_tree.h
+hostres_diskstorage_tbl.po: hostres_oid.h
+hostres_diskstorage_tbl.po: hostres_tree.h
+hostres_fs_tbl.So: hostres_oid.h
+hostres_fs_tbl.So: hostres_tree.h
+hostres_fs_tbl.po: hostres_oid.h
+hostres_fs_tbl.po: hostres_tree.h
+hostres_network_tbl.So: hostres_oid.h
+hostres_network_tbl.So: hostres_tree.h
+hostres_network_tbl.po: hostres_oid.h
+hostres_network_tbl.po: hostres_tree.h
+hostres_partition_tbl.So: hostres_oid.h
+hostres_partition_tbl.So: hostres_tree.h
+hostres_partition_tbl.po: hostres_oid.h
+hostres_partition_tbl.po: hostres_tree.h
+hostres_printer_tbl.So: hostres_oid.h
+hostres_printer_tbl.So: hostres_tree.h
+hostres_printer_tbl.po: hostres_oid.h
+hostres_printer_tbl.po: hostres_tree.h
+hostres_processor_tbl.So: hostres_oid.h
+hostres_processor_tbl.So: hostres_tree.h
+hostres_processor_tbl.po: hostres_oid.h
+hostres_processor_tbl.po: hostres_tree.h
+hostres_scalars.So: hostres_oid.h
+hostres_scalars.So: hostres_tree.h
+hostres_scalars.po: hostres_oid.h
+hostres_scalars.po: hostres_tree.h
+hostres_snmp.So: hostres_oid.h
+hostres_snmp.So: hostres_tree.h
+hostres_snmp.po: hostres_oid.h
+hostres_snmp.po: hostres_tree.h
+hostres_storage_tbl.So: hostres_oid.h
+hostres_storage_tbl.So: hostres_tree.h
+hostres_storage_tbl.po: hostres_oid.h
+hostres_storage_tbl.po: hostres_tree.h
+hostres_swinstalled_tbl.So: hostres_oid.h
+hostres_swinstalled_tbl.So: hostres_tree.h
+hostres_swinstalled_tbl.po: hostres_oid.h
+hostres_swinstalled_tbl.po: hostres_tree.h
+hostres_swrun_tbl.So: hostres_oid.h
+hostres_swrun_tbl.So: hostres_tree.h
+hostres_swrun_tbl.po: hostres_oid.h
+hostres_swrun_tbl.po: hostres_tree.h
+hostres_tree.So: hostres_tree.c
+hostres_tree.So: hostres_tree.h
+hostres_tree.po: hostres_tree.c
+hostres_tree.po: hostres_tree.h
+.endif
diff --git a/usr.sbin/bsnmpd/modules/snmp_hostres/hostres_diskstorage_tbl.c b/usr.sbin/bsnmpd/modules/snmp_hostres/hostres_diskstorage_tbl.c
index 25ba56a..5675350 100644
--- a/usr.sbin/bsnmpd/modules/snmp_hostres/hostres_diskstorage_tbl.c
+++ b/usr.sbin/bsnmpd/modules/snmp_hostres/hostres_diskstorage_tbl.c
@@ -287,6 +287,9 @@ disk_OS_get_ATA_disks(void)
/* Walk over the device table looking for ata disks */
STAILQ_FOREACH(map, &device_map, link) {
+ /* Skip deleted entries. */
+ if (map->entry_p == NULL)
+ continue;
for (found = lookup; found->media != DSM_UNKNOWN; found++) {
if (strncmp(map->name_key, found->dev_name,
strlen(found->dev_name)) != 0)
@@ -345,6 +348,9 @@ disk_OS_get_MD_disks(void)
/* Look for md devices */
STAILQ_FOREACH(map, &device_map, link) {
+ /* Skip deleted entries. */
+ if (map->entry_p == NULL)
+ continue;
if (sscanf(map->name_key, "md%d", &unit) != 1)
continue;
diff --git a/usr.sbin/bsnmpd/modules/snmp_hostres/hostres_scalars.c b/usr.sbin/bsnmpd/modules/snmp_hostres/hostres_scalars.c
index 87b78e8..ee7d4b1 100644
--- a/usr.sbin/bsnmpd/modules/snmp_hostres/hostres_scalars.c
+++ b/usr.sbin/bsnmpd/modules/snmp_hostres/hostres_scalars.c
@@ -238,7 +238,7 @@ OS_getSystemProcesses(uint32_t *proc_count)
if (hr_kd == NULL)
return (SNMP_ERR_GENERR);
- if (kvm_getprocs(hr_kd, KERN_PROC_ALL, 0, &pc) == NULL) {
+ if (kvm_getprocs(hr_kd, KERN_PROC_PROC, 0, &pc) == NULL) {
syslog(LOG_ERR, "kvm_getprocs failed: %m");
return (SNMP_ERR_GENERR);
}
diff --git a/usr.sbin/bsnmpd/modules/snmp_hostres/hostres_swrun_tbl.c b/usr.sbin/bsnmpd/modules/snmp_hostres/hostres_swrun_tbl.c
index 1f82648..f1a2f09 100644
--- a/usr.sbin/bsnmpd/modules/snmp_hostres/hostres_swrun_tbl.c
+++ b/usr.sbin/bsnmpd/modules/snmp_hostres/hostres_swrun_tbl.c
@@ -319,7 +319,7 @@ kld_file_stat_to_swrun(const struct kld_file_stat *kfs,
}
/**
- * Get all visible proceses including the kernel visible threads
+ * Get all visible processes including the kernel visible threads
*/
static void
swrun_OS_get_procs(void)
diff --git a/usr.sbin/bsnmpd/modules/snmp_mibII/Makefile b/usr.sbin/bsnmpd/modules/snmp_mibII/Makefile
index 278dc24..32bca7d 100644
--- a/usr.sbin/bsnmpd/modules/snmp_mibII/Makefile
+++ b/usr.sbin/bsnmpd/modules/snmp_mibII/Makefile
@@ -15,6 +15,8 @@ MAN= snmp_mibII.3
CFLAGS+= -I${CONTRIB}/lib -I${CONTRIB}/snmpd
CFLAGS+= -DHAVE_ERR_H -DHAVE_GETADDRINFO -DHAVE_STRLCPY -DHAVE_SYS_TREE_H
+# XXX Work around clang warning, until maintainer approves fix.
+NO_WERROR.clang=
DEFS= ${MOD}_tree.def
INCS= snmp_${MOD}.h
diff --git a/usr.sbin/bsnmpd/modules/snmp_mibII/Makefile.depend b/usr.sbin/bsnmpd/modules/snmp_mibII/Makefile.depend
new file mode 100644
index 0000000..118a7bd
--- /dev/null
+++ b/usr.sbin/bsnmpd/modules/snmp_mibII/Makefile.depend
@@ -0,0 +1,68 @@
+# Autogenerated - do NOT edit!
+
+DEP_RELDIR := ${_PARSEDIR:S,${SRCTOP}/,,}
+
+DEP_MACHINE := ${.PARSEFILE:E}
+
+DIRDEPS = \
+ include \
+ include/arpa \
+ include/xlocale \
+ lib/libbsnmp/libbsnmp \
+
+
+.include <dirdeps.mk>
+
+.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+# local dependencies - needed for -jN in clean tree
+mibII.So: mibII_oid.h
+mibII.So: mibII_tree.h
+mibII.po: mibII_oid.h
+mibII.po: mibII_tree.h
+mibII_begemot.So: mibII_oid.h
+mibII_begemot.So: mibII_tree.h
+mibII_begemot.po: mibII_oid.h
+mibII_begemot.po: mibII_tree.h
+mibII_ifmib.So: mibII_oid.h
+mibII_ifmib.So: mibII_tree.h
+mibII_ifmib.po: mibII_oid.h
+mibII_ifmib.po: mibII_tree.h
+mibII_ifstack.So: mibII_tree.h
+mibII_ifstack.po: mibII_tree.h
+mibII_interfaces.So: mibII_oid.h
+mibII_interfaces.So: mibII_tree.h
+mibII_interfaces.po: mibII_oid.h
+mibII_interfaces.po: mibII_tree.h
+mibII_ip.So: mibII_oid.h
+mibII_ip.So: mibII_tree.h
+mibII_ip.po: mibII_oid.h
+mibII_ip.po: mibII_tree.h
+mibII_ipaddr.So: mibII_oid.h
+mibII_ipaddr.So: mibII_tree.h
+mibII_ipaddr.po: mibII_oid.h
+mibII_ipaddr.po: mibII_tree.h
+mibII_nettomedia.So: mibII_oid.h
+mibII_nettomedia.So: mibII_tree.h
+mibII_nettomedia.po: mibII_oid.h
+mibII_nettomedia.po: mibII_tree.h
+mibII_rcvaddr.So: mibII_oid.h
+mibII_rcvaddr.So: mibII_tree.h
+mibII_rcvaddr.po: mibII_oid.h
+mibII_rcvaddr.po: mibII_tree.h
+mibII_route.So: mibII_oid.h
+mibII_route.So: mibII_tree.h
+mibII_route.po: mibII_oid.h
+mibII_route.po: mibII_tree.h
+mibII_tcp.So: mibII_oid.h
+mibII_tcp.So: mibII_tree.h
+mibII_tcp.po: mibII_oid.h
+mibII_tcp.po: mibII_tree.h
+mibII_tree.So: mibII_tree.c
+mibII_tree.So: mibII_tree.h
+mibII_tree.po: mibII_tree.c
+mibII_tree.po: mibII_tree.h
+mibII_udp.So: mibII_oid.h
+mibII_udp.So: mibII_tree.h
+mibII_udp.po: mibII_oid.h
+mibII_udp.po: mibII_tree.h
+.endif
diff --git a/usr.sbin/bsnmpd/modules/snmp_netgraph/Makefile.depend b/usr.sbin/bsnmpd/modules/snmp_netgraph/Makefile.depend
new file mode 100644
index 0000000..e5425f3
--- /dev/null
+++ b/usr.sbin/bsnmpd/modules/snmp_netgraph/Makefile.depend
@@ -0,0 +1,27 @@
+# Autogenerated - do NOT edit!
+
+DEP_RELDIR := ${_PARSEDIR:S,${SRCTOP}/,,}
+
+DEP_MACHINE := ${.PARSEFILE:E}
+
+DIRDEPS = \
+ include \
+ include/xlocale \
+ lib/libbsnmp/libbsnmp \
+ lib/libnetgraph \
+ usr.sbin/bsnmpd/modules \
+
+
+.include <dirdeps.mk>
+
+.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+# local dependencies - needed for -jN in clean tree
+netgraph_tree.So: netgraph_tree.c
+netgraph_tree.So: netgraph_tree.h
+netgraph_tree.po: netgraph_tree.c
+netgraph_tree.po: netgraph_tree.h
+snmp_netgraph.So: netgraph_oid.h
+snmp_netgraph.So: netgraph_tree.h
+snmp_netgraph.po: netgraph_oid.h
+snmp_netgraph.po: netgraph_tree.h
+.endif
diff --git a/usr.sbin/bsnmpd/modules/snmp_pf/BEGEMOT-PF-MIB.txt b/usr.sbin/bsnmpd/modules/snmp_pf/BEGEMOT-PF-MIB.txt
index 0b90bb2..d2b247f 100644
--- a/usr.sbin/bsnmpd/modules/snmp_pf/BEGEMOT-PF-MIB.txt
+++ b/usr.sbin/bsnmpd/modules/snmp_pf/BEGEMOT-PF-MIB.txt
@@ -585,7 +585,7 @@ PfInterfacesIfEntry ::= SEQUENCE {
pfInterfacesIfDescr OCTET STRING,
pfInterfacesIfType INTEGER,
pfInterfacesIfTZero TimeTicks,
- pfInterfacesIfRefsState Unsigned32,
+ pfInterfacesIfRefsState Null,
pfInterfacesIfRefsRule Unsigned32,
pfInterfacesIf4BytesInPass Counter64,
pfInterfacesIf4BytesInBlock Counter64,
diff --git a/usr.sbin/bsnmpd/modules/snmp_pf/Makefile.depend b/usr.sbin/bsnmpd/modules/snmp_pf/Makefile.depend
new file mode 100644
index 0000000..a1ecc91
--- /dev/null
+++ b/usr.sbin/bsnmpd/modules/snmp_pf/Makefile.depend
@@ -0,0 +1,26 @@
+# Autogenerated - do NOT edit!
+
+DEP_RELDIR := ${_PARSEDIR:S,${SRCTOP}/,,}
+
+DEP_MACHINE := ${.PARSEFILE:E}
+
+DIRDEPS = \
+ include \
+ include/xlocale \
+ lib/libbsnmp/libbsnmp \
+ usr.sbin/bsnmpd/modules \
+
+
+.include <dirdeps.mk>
+
+.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+# local dependencies - needed for -jN in clean tree
+pf_snmp.So: pf_oid.h
+pf_snmp.So: pf_tree.h
+pf_snmp.po: pf_oid.h
+pf_snmp.po: pf_tree.h
+pf_tree.So: pf_tree.c
+pf_tree.So: pf_tree.h
+pf_tree.po: pf_tree.c
+pf_tree.po: pf_tree.h
+.endif
diff --git a/usr.sbin/bsnmpd/modules/snmp_pf/pf_snmp.c b/usr.sbin/bsnmpd/modules/snmp_pf/pf_snmp.c
index bc4bc35..1048ffe 100644
--- a/usr.sbin/bsnmpd/modules/snmp_pf/pf_snmp.c
+++ b/usr.sbin/bsnmpd/modules/snmp_pf/pf_snmp.c
@@ -586,11 +586,8 @@ pf_iftable(struct snmp_context __unused *ctx, struct snmp_value *val,
val->v.uint32 =
(time(NULL) - e->pfi.pfik_tzero) * 100;
break;
- case LEAF_pfInterfacesIfRefsState:
- val->v.uint32 = e->pfi.pfik_states;
- break;
case LEAF_pfInterfacesIfRefsRule:
- val->v.uint32 = e->pfi.pfik_rules;
+ val->v.uint32 = e->pfi.pfik_rulerefs;
break;
case LEAF_pfInterfacesIf4BytesInPass:
val->v.counter64 =
diff --git a/usr.sbin/bsnmpd/modules/snmp_pf/pf_tree.def b/usr.sbin/bsnmpd/modules/snmp_pf/pf_tree.def
index 7b791b3..1dfa14c 100644
--- a/usr.sbin/bsnmpd/modules/snmp_pf/pf_tree.def
+++ b/usr.sbin/bsnmpd/modules/snmp_pf/pf_tree.def
@@ -108,7 +108,7 @@
(2 pfInterfacesIfDescr OCTETSTRING GET)
(3 pfInterfacesIfType ENUM ( 0 group 1 instance 2 detached ) GET)
(4 pfInterfacesIfTZero TIMETICKS GET)
- (5 pfInterfacesIfRefsState UNSIGNED32 GET)
+ (5 pfInterfacesIfRefsState NULL GET)
(6 pfInterfacesIfRefsRule UNSIGNED32 GET)
(7 pfInterfacesIf4BytesInPass COUNTER64 GET)
(8 pfInterfacesIf4BytesInBlock COUNTER64 GET)
diff --git a/usr.sbin/bsnmpd/modules/snmp_target/Makefile.depend b/usr.sbin/bsnmpd/modules/snmp_target/Makefile.depend
new file mode 100644
index 0000000..5d9de80
--- /dev/null
+++ b/usr.sbin/bsnmpd/modules/snmp_target/Makefile.depend
@@ -0,0 +1,25 @@
+# Autogenerated - do NOT edit!
+
+DEP_RELDIR := ${_PARSEDIR:S,${SRCTOP}/,,}
+
+DEP_MACHINE := ${.PARSEFILE:E}
+
+DIRDEPS = \
+ include \
+ include/xlocale \
+ lib/libbsnmp/libbsnmp \
+
+
+.include <dirdeps.mk>
+
+.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+# local dependencies - needed for -jN in clean tree
+target_snmp.So: target_oid.h
+target_snmp.So: target_tree.h
+target_snmp.po: target_oid.h
+target_snmp.po: target_tree.h
+target_tree.So: target_tree.c
+target_tree.So: target_tree.h
+target_tree.po: target_tree.c
+target_tree.po: target_tree.h
+.endif
diff --git a/usr.sbin/bsnmpd/modules/snmp_usm/Makefile.depend b/usr.sbin/bsnmpd/modules/snmp_usm/Makefile.depend
new file mode 100644
index 0000000..bf3304a
--- /dev/null
+++ b/usr.sbin/bsnmpd/modules/snmp_usm/Makefile.depend
@@ -0,0 +1,25 @@
+# Autogenerated - do NOT edit!
+
+DEP_RELDIR := ${_PARSEDIR:S,${SRCTOP}/,,}
+
+DEP_MACHINE := ${.PARSEFILE:E}
+
+DIRDEPS = \
+ include \
+ include/xlocale \
+ lib/libbsnmp/libbsnmp \
+
+
+.include <dirdeps.mk>
+
+.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+# local dependencies - needed for -jN in clean tree
+usm_snmp.So: usm_oid.h
+usm_snmp.So: usm_tree.h
+usm_snmp.po: usm_oid.h
+usm_snmp.po: usm_tree.h
+usm_tree.So: usm_tree.c
+usm_tree.So: usm_tree.h
+usm_tree.po: usm_tree.c
+usm_tree.po: usm_tree.h
+.endif
diff --git a/usr.sbin/bsnmpd/modules/snmp_vacm/Makefile.depend b/usr.sbin/bsnmpd/modules/snmp_vacm/Makefile.depend
new file mode 100644
index 0000000..0c08629
--- /dev/null
+++ b/usr.sbin/bsnmpd/modules/snmp_vacm/Makefile.depend
@@ -0,0 +1,25 @@
+# Autogenerated - do NOT edit!
+
+DEP_RELDIR := ${_PARSEDIR:S,${SRCTOP}/,,}
+
+DEP_MACHINE := ${.PARSEFILE:E}
+
+DIRDEPS = \
+ include \
+ include/xlocale \
+ lib/libbsnmp/libbsnmp \
+
+
+.include <dirdeps.mk>
+
+.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+# local dependencies - needed for -jN in clean tree
+vacm_snmp.So: vacm_oid.h
+vacm_snmp.So: vacm_tree.h
+vacm_snmp.po: vacm_oid.h
+vacm_snmp.po: vacm_tree.h
+vacm_tree.So: vacm_tree.c
+vacm_tree.So: vacm_tree.h
+vacm_tree.po: vacm_tree.c
+vacm_tree.po: vacm_tree.h
+.endif
diff --git a/usr.sbin/bsnmpd/modules/snmp_wlan/Makefile.depend b/usr.sbin/bsnmpd/modules/snmp_wlan/Makefile.depend
new file mode 100644
index 0000000..3c1e872
--- /dev/null
+++ b/usr.sbin/bsnmpd/modules/snmp_wlan/Makefile.depend
@@ -0,0 +1,29 @@
+# Autogenerated - do NOT edit!
+
+DEP_RELDIR := ${_PARSEDIR:S,${SRCTOP}/,,}
+
+DEP_MACHINE := ${.PARSEFILE:E}
+
+DIRDEPS = \
+ include \
+ include/xlocale \
+ lib/libbsnmp/libbsnmp \
+ usr.sbin/bsnmpd/modules \
+ usr.sbin/bsnmpd/modules/snmp_mibII \
+
+
+.include <dirdeps.mk>
+
+.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+# local dependencies - needed for -jN in clean tree
+wlan_snmp.So: wlan_oid.h
+wlan_snmp.So: wlan_tree.h
+wlan_snmp.po: wlan_oid.h
+wlan_snmp.po: wlan_tree.h
+wlan_sys.So: wlan_tree.h
+wlan_sys.po: wlan_tree.h
+wlan_tree.So: wlan_tree.c
+wlan_tree.So: wlan_tree.h
+wlan_tree.po: wlan_tree.c
+wlan_tree.po: wlan_tree.h
+.endif
diff --git a/usr.sbin/bsnmpd/tools/bsnmptools/Makefile.depend b/usr.sbin/bsnmpd/tools/bsnmptools/Makefile.depend
new file mode 100644
index 0000000..58da794
--- /dev/null
+++ b/usr.sbin/bsnmpd/tools/bsnmptools/Makefile.depend
@@ -0,0 +1,22 @@
+# Autogenerated - do NOT edit!
+
+DEP_RELDIR := ${_PARSEDIR:S,${SRCTOP}/,,}
+
+DEP_MACHINE := ${.PARSEFILE:E}
+
+DIRDEPS = \
+ gnu/lib/libgcc \
+ include \
+ include/xlocale \
+ lib/${CSU_DIR} \
+ lib/libbsnmp/libbsnmp \
+ lib/libc \
+ secure/lib/libcrypto \
+ usr.sbin/bsnmpd/tools/libbsnmptools \
+
+
+.include <dirdeps.mk>
+
+.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+# local dependencies - needed for -jN in clean tree
+.endif
diff --git a/usr.sbin/bsnmpd/tools/libbsnmptools/Makefile.depend b/usr.sbin/bsnmpd/tools/libbsnmptools/Makefile.depend
new file mode 100644
index 0000000..05587d8
--- /dev/null
+++ b/usr.sbin/bsnmpd/tools/libbsnmptools/Makefile.depend
@@ -0,0 +1,18 @@
+# Autogenerated - do NOT edit!
+
+DEP_RELDIR := ${_PARSEDIR:S,${SRCTOP}/,,}
+
+DEP_MACHINE := ${.PARSEFILE:E}
+
+DIRDEPS = \
+ include \
+ include/arpa \
+ include/xlocale \
+ lib/libbsnmp/libbsnmp \
+
+
+.include <dirdeps.mk>
+
+.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+# local dependencies - needed for -jN in clean tree
+.endif
diff --git a/usr.sbin/btxld/Makefile.depend b/usr.sbin/btxld/Makefile.depend
new file mode 100644
index 0000000..a839545
--- /dev/null
+++ b/usr.sbin/btxld/Makefile.depend
@@ -0,0 +1,19 @@
+# Autogenerated - do NOT edit!
+
+DEP_RELDIR := ${_PARSEDIR:S,${SRCTOP}/,,}
+
+DEP_MACHINE := ${.PARSEFILE:E}
+
+DIRDEPS = \
+ gnu/lib/libgcc \
+ include \
+ include/xlocale \
+ lib/${CSU_DIR} \
+ lib/libc \
+
+
+.include <dirdeps.mk>
+
+.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+# local dependencies - needed for -jN in clean tree
+.endif
diff --git a/usr.sbin/burncd/Makefile.depend b/usr.sbin/burncd/Makefile.depend
new file mode 100644
index 0000000..16b5e42
--- /dev/null
+++ b/usr.sbin/burncd/Makefile.depend
@@ -0,0 +1,20 @@
+# Autogenerated - do NOT edit!
+
+DEP_RELDIR := ${_PARSEDIR:S,${SRCTOP}/,,}
+
+DEP_MACHINE := ${.PARSEFILE:E}
+
+DIRDEPS = \
+ gnu/lib/libgcc \
+ include \
+ include/arpa \
+ include/xlocale \
+ lib/${CSU_DIR} \
+ lib/libc \
+
+
+.include <dirdeps.mk>
+
+.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+# local dependencies - needed for -jN in clean tree
+.endif
diff --git a/usr.sbin/cdcontrol/Makefile.depend b/usr.sbin/cdcontrol/Makefile.depend
new file mode 100644
index 0000000..501fd51
--- /dev/null
+++ b/usr.sbin/cdcontrol/Makefile.depend
@@ -0,0 +1,22 @@
+# Autogenerated - do NOT edit!
+
+DEP_RELDIR := ${_PARSEDIR:S,${SRCTOP}/,,}
+
+DEP_MACHINE := ${.PARSEFILE:E}
+
+DIRDEPS = \
+ gnu/lib/libgcc \
+ include \
+ include/arpa \
+ include/xlocale \
+ lib/${CSU_DIR} \
+ lib/libc \
+ lib/libedit \
+ lib/ncurses/ncurses \
+
+
+.include <dirdeps.mk>
+
+.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+# local dependencies - needed for -jN in clean tree
+.endif
diff --git a/usr.sbin/chkgrp/Makefile.depend b/usr.sbin/chkgrp/Makefile.depend
new file mode 100644
index 0000000..a839545
--- /dev/null
+++ b/usr.sbin/chkgrp/Makefile.depend
@@ -0,0 +1,19 @@
+# Autogenerated - do NOT edit!
+
+DEP_RELDIR := ${_PARSEDIR:S,${SRCTOP}/,,}
+
+DEP_MACHINE := ${.PARSEFILE:E}
+
+DIRDEPS = \
+ gnu/lib/libgcc \
+ include \
+ include/xlocale \
+ lib/${CSU_DIR} \
+ lib/libc \
+
+
+.include <dirdeps.mk>
+
+.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+# local dependencies - needed for -jN in clean tree
+.endif
diff --git a/usr.sbin/chown/Makefile.depend b/usr.sbin/chown/Makefile.depend
new file mode 100644
index 0000000..a839545
--- /dev/null
+++ b/usr.sbin/chown/Makefile.depend
@@ -0,0 +1,19 @@
+# Autogenerated - do NOT edit!
+
+DEP_RELDIR := ${_PARSEDIR:S,${SRCTOP}/,,}
+
+DEP_MACHINE := ${.PARSEFILE:E}
+
+DIRDEPS = \
+ gnu/lib/libgcc \
+ include \
+ include/xlocale \
+ lib/${CSU_DIR} \
+ lib/libc \
+
+
+.include <dirdeps.mk>
+
+.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+# local dependencies - needed for -jN in clean tree
+.endif
diff --git a/usr.sbin/chroot/Makefile.depend b/usr.sbin/chroot/Makefile.depend
new file mode 100644
index 0000000..a839545
--- /dev/null
+++ b/usr.sbin/chroot/Makefile.depend
@@ -0,0 +1,19 @@
+# Autogenerated - do NOT edit!
+
+DEP_RELDIR := ${_PARSEDIR:S,${SRCTOP}/,,}
+
+DEP_MACHINE := ${.PARSEFILE:E}
+
+DIRDEPS = \
+ gnu/lib/libgcc \
+ include \
+ include/xlocale \
+ lib/${CSU_DIR} \
+ lib/libc \
+
+
+.include <dirdeps.mk>
+
+.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+# local dependencies - needed for -jN in clean tree
+.endif
diff --git a/usr.sbin/chroot/chroot.8 b/usr.sbin/chroot/chroot.8
index d847175..e5f9f44 100644
--- a/usr.sbin/chroot/chroot.8
+++ b/usr.sbin/chroot/chroot.8
@@ -60,7 +60,7 @@ options are given,
the user,
group and group list of the process are set to
these values after the
-.Xr chroot 8
+.Nm
has taken place.
.Sh ENVIRONMENT
The following environment variable is referenced by
diff --git a/usr.sbin/ckdist/Makefile.depend b/usr.sbin/ckdist/Makefile.depend
new file mode 100644
index 0000000..7520d5d
--- /dev/null
+++ b/usr.sbin/ckdist/Makefile.depend
@@ -0,0 +1,20 @@
+# Autogenerated - do NOT edit!
+
+DEP_RELDIR := ${_PARSEDIR:S,${SRCTOP}/,,}
+
+DEP_MACHINE := ${.PARSEFILE:E}
+
+DIRDEPS = \
+ gnu/lib/libgcc \
+ include \
+ include/xlocale \
+ lib/${CSU_DIR} \
+ lib/libc \
+ lib/libmd \
+
+
+.include <dirdeps.mk>
+
+.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+# local dependencies - needed for -jN in clean tree
+.endif
diff --git a/usr.sbin/clear_locks/Makefile.depend b/usr.sbin/clear_locks/Makefile.depend
new file mode 100644
index 0000000..60fe900
--- /dev/null
+++ b/usr.sbin/clear_locks/Makefile.depend
@@ -0,0 +1,22 @@
+# Autogenerated - do NOT edit!
+
+DEP_RELDIR := ${_PARSEDIR:S,${SRCTOP}/,,}
+
+DEP_MACHINE := ${.PARSEFILE:E}
+
+DIRDEPS = \
+ gnu/lib/libgcc \
+ include \
+ include/rpc \
+ include/rpcsvc \
+ include/xlocale \
+ lib/${CSU_DIR} \
+ lib/libc \
+ lib/librpcsvc \
+
+
+.include <dirdeps.mk>
+
+.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+# local dependencies - needed for -jN in clean tree
+.endif
diff --git a/usr.sbin/config/Makefile.depend b/usr.sbin/config/Makefile.depend
new file mode 100644
index 0000000..d414840
--- /dev/null
+++ b/usr.sbin/config/Makefile.depend
@@ -0,0 +1,36 @@
+# Autogenerated - do NOT edit!
+
+DEP_RELDIR := ${_PARSEDIR:S,${SRCTOP}/,,}
+
+DEP_MACHINE := ${.PARSEFILE:E}
+
+DIRDEPS = \
+ gnu/lib/libgcc \
+ include \
+ include/xlocale \
+ lib/${CSU_DIR} \
+ lib/libc \
+ lib/libsbuf \
+
+
+.include <dirdeps.mk>
+
+.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+# local dependencies - needed for -jN in clean tree
+config.o: config.c
+config.po: config.c
+kernconf.o: kernconf.c
+kernconf.po: kernconf.c
+lang.o: lang.c
+lang.o: y.tab.h
+lang.po: lang.c
+lang.po: y.tab.h
+main.o: y.tab.h
+main.po: y.tab.h
+mkheaders.o: y.tab.h
+mkheaders.po: y.tab.h
+mkmakefile.o: y.tab.h
+mkmakefile.po: y.tab.h
+mkoptions.o: y.tab.h
+mkoptions.po: y.tab.h
+.endif
diff --git a/usr.sbin/config/mkmakefile.c b/usr.sbin/config/mkmakefile.c
index 8a7f55a..324ad3b 100644
--- a/usr.sbin/config/mkmakefile.c
+++ b/usr.sbin/config/mkmakefile.c
@@ -431,7 +431,7 @@ nextparam:
next_quoted_word(fp, wd);
if (wd == 0) {
fprintf(stderr,
- "%s: %s missing compile command string.\n",
+ "%s: %s missing dependency string.\n",
fname, this);
exit(1);
}
@@ -762,7 +762,7 @@ do_rules(FILE *f)
break;
}
snprintf(cmd, sizeof(cmd),
- "${%s_%c%s}\n", ftype,
+ "${%s_%c%s}", ftype,
toupper(och),
ftp->f_flags & NOWERROR ? "_NOWERROR" : "");
compilewith = cmd;
diff --git a/usr.sbin/cpucontrol/Makefile.depend b/usr.sbin/cpucontrol/Makefile.depend
new file mode 100644
index 0000000..a839545
--- /dev/null
+++ b/usr.sbin/cpucontrol/Makefile.depend
@@ -0,0 +1,19 @@
+# Autogenerated - do NOT edit!
+
+DEP_RELDIR := ${_PARSEDIR:S,${SRCTOP}/,,}
+
+DEP_MACHINE := ${.PARSEFILE:E}
+
+DIRDEPS = \
+ gnu/lib/libgcc \
+ include \
+ include/xlocale \
+ lib/${CSU_DIR} \
+ lib/libc \
+
+
+.include <dirdeps.mk>
+
+.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+# local dependencies - needed for -jN in clean tree
+.endif
diff --git a/usr.sbin/cpucontrol/cpucontrol.c b/usr.sbin/cpucontrol/cpucontrol.c
index 8738612..c0d5a31 100644
--- a/usr.sbin/cpucontrol/cpucontrol.c
+++ b/usr.sbin/cpucontrol/cpucontrol.c
@@ -86,7 +86,7 @@ struct datadir {
};
static SLIST_HEAD(, datadir) datadirs = SLIST_HEAD_INITIALIZER(datadirs);
-struct ucode_handler {
+static struct ucode_handler {
ucode_probe_t *probe;
ucode_update_t *update;
} handlers[] = {
diff --git a/usr.sbin/crashinfo/Makefile.depend b/usr.sbin/crashinfo/Makefile.depend
new file mode 100644
index 0000000..29fda55
--- /dev/null
+++ b/usr.sbin/crashinfo/Makefile.depend
@@ -0,0 +1,14 @@
+# Autogenerated - do NOT edit!
+
+DEP_RELDIR := ${_PARSEDIR:S,${SRCTOP}/,,}
+
+DEP_MACHINE := ${.PARSEFILE:E}
+
+DIRDEPS = \
+
+
+.include <dirdeps.mk>
+
+.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+# local dependencies - needed for -jN in clean tree
+.endif
diff --git a/usr.sbin/cron/cron/Makefile.depend b/usr.sbin/cron/cron/Makefile.depend
new file mode 100644
index 0000000..e033fdf
--- /dev/null
+++ b/usr.sbin/cron/cron/Makefile.depend
@@ -0,0 +1,22 @@
+# Autogenerated - do NOT edit!
+
+DEP_RELDIR := ${_PARSEDIR:S,${SRCTOP}/,,}
+
+DEP_MACHINE := ${.PARSEFILE:E}
+
+DIRDEPS = \
+ gnu/lib/libgcc \
+ include \
+ include/xlocale \
+ lib/${CSU_DIR} \
+ lib/libc \
+ lib/libpam/libpam \
+ lib/libutil \
+ usr.sbin/cron/lib \
+
+
+.include <dirdeps.mk>
+
+.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+# local dependencies - needed for -jN in clean tree
+.endif
diff --git a/usr.sbin/cron/cron/cron.c b/usr.sbin/cron/cron/cron.c
index 52cdcc8..d374319 100644
--- a/usr.sbin/cron/cron/cron.c
+++ b/usr.sbin/cron/cron/cron.c
@@ -35,9 +35,9 @@ static const char rcsid[] =
static void usage(void),
run_reboot_jobs(cron_db *),
- cron_tick(cron_db *),
- cron_sync(void),
- cron_sleep(cron_db *),
+ cron_tick(cron_db *, int),
+ cron_sync(int),
+ cron_sleep(cron_db *, int),
cron_clean(cron_db *),
#ifdef USE_SIGCHLD
sigchld_handler(int),
@@ -45,22 +45,28 @@ static void usage(void),
sighup_handler(int),
parse_args(int c, char *v[]);
+static int run_at_secres(cron_db *);
+
static time_t last_time = 0;
static int dst_enabled = 0;
struct pidfh *pfh;
static void
usage() {
+#if DEBUGGING
char **dflags;
+#endif
fprintf(stderr, "usage: cron [-j jitter] [-J rootjitter] "
"[-m mailto] [-s] [-o] [-x debugflag[,...]]\n");
+#if DEBUGGING
fprintf(stderr, "\ndebugflags: ");
for(dflags = DebugFlagNames; *dflags; dflags++) {
fprintf(stderr, "%s ", *dflags);
}
fprintf(stderr, "\n");
+#endif
exit(ERROR_EXIT);
}
@@ -94,6 +100,9 @@ main(argc, argv)
char *argv[];
{
cron_db database;
+ int runnum;
+ int secres1, secres2;
+ struct tm *tm;
ProgramName = argv[0];
@@ -143,23 +152,47 @@ main(argc, argv)
database.tail = NULL;
database.mtime = (time_t) 0;
load_database(&database);
+ secres1 = secres2 = run_at_secres(&database);
run_reboot_jobs(&database);
- cron_sync();
+ cron_sync(secres1);
+ runnum = 0;
while (TRUE) {
# if DEBUGGING
/* if (!(DebugFlags & DTEST)) */
# endif /*DEBUGGING*/
- cron_sleep(&database);
-
- load_database(&database);
+ cron_sleep(&database, secres1);
+
+ if (secres1 == 0 || runnum % 60 == 0) {
+ load_database(&database);
+ secres2 = run_at_secres(&database);
+ if (secres2 != secres1) {
+ secres1 = secres2;
+ if (secres1 != 0) {
+ runnum = 0;
+ } else {
+ /*
+ * Going from 1 sec to 60 sec res. If we
+ * are already at minute's boundary, so
+ * let it run, otherwise schedule for the
+ * next minute.
+ */
+ tm = localtime(&TargetTime);
+ if (tm->tm_sec > 0) {
+ cron_sync(secres2);
+ continue;
+ }
+ }
+ }
+ }
/* do this iteration
*/
- cron_tick(&database);
+ cron_tick(&database, secres1);
- /* sleep 1 minute
+ /* sleep 1 or 60 seconds
*/
- TargetTime += 60;
+ TargetTime += (secres1 != 0) ? 1 : 60;
+ runnum += 1;
}
}
@@ -183,29 +216,29 @@ run_reboot_jobs(db)
static void
-cron_tick(db)
- cron_db *db;
+cron_tick(cron_db *db, int secres)
{
static struct tm lasttm;
static time_t diff = 0, /* time difference in seconds from the last offset change */
difflimit = 0; /* end point for the time zone correction */
struct tm otztm; /* time in the old time zone */
- int otzminute, otzhour, otzdom, otzmonth, otzdow;
+ int otzsecond, otzminute, otzhour, otzdom, otzmonth, otzdow;
register struct tm *tm = localtime(&TargetTime);
- register int minute, hour, dom, month, dow;
+ register int second, minute, hour, dom, month, dow;
register user *u;
register entry *e;
/* make 0-based values out of these so we can use them as indicies
*/
+ second = (secres == 0) ? 0 : tm->tm_sec -FIRST_SECOND;
minute = tm->tm_min -FIRST_MINUTE;
hour = tm->tm_hour -FIRST_HOUR;
dom = tm->tm_mday -FIRST_DOM;
month = tm->tm_mon +1 /* 0..11 -> 1..12 */ -FIRST_MONTH;
dow = tm->tm_wday -FIRST_DOW;
- Debug(DSCH, ("[%d] tick(%d,%d,%d,%d,%d)\n",
- getpid(), minute, hour, dom, month, dow))
+ Debug(DSCH, ("[%d] tick(%d,%d,%d,%d,%d,%d)\n",
+ getpid(), second, minute, hour, dom, month, dow))
if (dst_enabled && last_time != 0
&& TargetTime > last_time /* exclude stepping back */
@@ -258,6 +291,7 @@ cron_tick(db)
/* make 0-based values out of these so we can use them as indicies
*/
+ otzsecond = (secres == 0) ? 0 : otztm.tm_sec -FIRST_SECOND;
otzminute = otztm.tm_min -FIRST_MINUTE;
otzhour = otztm.tm_hour -FIRST_HOUR;
otzdom = otztm.tm_mday -FIRST_DOM;
@@ -279,7 +313,8 @@ cron_tick(db)
e->uid, e->gid, e->cmd))
if ( diff != 0 && (e->flags & (RUN_AT|NOT_UNTIL)) ) {
- if (bit_test(e->minute, otzminute)
+ if (bit_test(e->second, otzsecond)
+ && bit_test(e->minute, otzminute)
&& bit_test(e->hour, otzhour)
&& bit_test(e->month, otzmonth)
&& ( ((e->flags & DOM_STAR) || (e->flags & DOW_STAR))
@@ -298,7 +333,8 @@ cron_tick(db)
continue;
}
- if (bit_test(e->minute, minute)
+ if (bit_test(e->second, second)
+ && bit_test(e->minute, minute)
&& bit_test(e->hour, hour)
&& bit_test(e->month, month)
&& ( ((e->flags & DOM_STAR) || (e->flags & DOW_STAR))
@@ -328,38 +364,74 @@ cron_tick(db)
* that's something sysadmin's know to expect what with crashing computers..
*/
static void
-cron_sync() {
- register struct tm *tm;
+cron_sync(int secres) {
+ struct tm *tm;
TargetTime = time((time_t*)0);
- tm = localtime(&TargetTime);
- TargetTime += (60 - tm->tm_sec);
+ if (secres != 0) {
+ TargetTime += 1;
+ } else {
+ tm = localtime(&TargetTime);
+ TargetTime += (60 - tm->tm_sec);
+ }
}
+static int
+timespec_subtract(struct timespec *result, struct timespec *x,
+ struct timespec *y)
+{
+ time_t nsec;
+
+ /* Perform the carry for the later subtraction by updating y. */
+ if (x->tv_nsec < y->tv_nsec) {
+ nsec = (y->tv_nsec - x->tv_nsec) / 10000000 + 1;
+ y->tv_nsec -= 1000000000 * nsec;
+ y->tv_sec += nsec;
+ }
+ if (x->tv_nsec - y->tv_nsec > 1000000000) {
+ nsec = (x->tv_nsec - y->tv_nsec) / 1000000000;
+ y->tv_nsec += 1000000000 * nsec;
+ y->tv_sec -= nsec;
+ }
+
+ /* tv_nsec is certainly positive. */
+ result->tv_sec = x->tv_sec - y->tv_sec;
+ result->tv_nsec = x->tv_nsec - y->tv_nsec;
+
+ /* Return True if result is negative. */
+ return (x->tv_sec < y->tv_sec);
+}
static void
-cron_sleep(db)
- cron_db *db;
+cron_sleep(cron_db *db, int secres)
{
- int seconds_to_wait = 0;
+ int seconds_to_wait;
+ int rval;
+ struct timespec ctime, ttime, stime, remtime;
/*
* Loop until we reach the top of the next minute, sleep when possible.
*/
for (;;) {
- seconds_to_wait = (int) (TargetTime - time((time_t*)0));
+ clock_gettime(CLOCK_REALTIME, &ctime);
+ ttime.tv_sec = TargetTime;
+ ttime.tv_nsec = 0;
+ timespec_subtract(&stime, &ttime, &ctime);
/*
* If the seconds_to_wait value is insane, jump the cron
*/
- if (seconds_to_wait < -600 || seconds_to_wait > 600) {
+ if (stime.tv_sec < -600 || stime.tv_sec > 600) {
cron_clean(db);
- cron_sync();
+ cron_sync(secres);
continue;
}
+ seconds_to_wait = (stime.tv_nsec > 0) ? stime.tv_sec + 1 :
+ stime.tv_sec;
+
Debug(DSCH, ("[%d] TargetTime=%ld, sec-to-wait=%d\n",
getpid(), (long)TargetTime, seconds_to_wait))
@@ -368,13 +440,19 @@ cron_sleep(db)
* to run, break
*/
- if (seconds_to_wait <= 0)
+ if (stime.tv_sec < 0)
break;
if (job_runqueue() == 0) {
Debug(DSCH, ("[%d] sleeping for %d seconds\n",
getpid(), seconds_to_wait))
- sleep(seconds_to_wait);
+ for (;;) {
+ rval = nanosleep(&stime, &remtime);
+ if (rval == 0 || errno != EINTR)
+ break;
+ stime.tv_sec = remtime.tv_sec;
+ stime.tv_nsec = remtime.tv_nsec;
+ }
}
}
}
@@ -480,3 +558,17 @@ parse_args(argc, argv)
}
}
+static int
+run_at_secres(cron_db *db)
+{
+ user *u;
+ entry *e;
+
+ for (u = db->head; u != NULL; u = u->next) {
+ for (e = u->crontab; e != NULL; e = e->next) {
+ if ((e->flags & SEC_RES) != 0)
+ return 1;
+ }
+ }
+ return 0;
+}
diff --git a/usr.sbin/cron/cron/cron.h b/usr.sbin/cron/cron/cron.h
index 38eb33b..1a814df 100644
--- a/usr.sbin/cron/cron/cron.h
+++ b/usr.sbin/cron/cron/cron.h
@@ -124,6 +124,10 @@
LineNumber = ln; \
}
+#define FIRST_SECOND 0
+#define LAST_SECOND 59
+#define SECOND_COUNT (LAST_SECOND - FIRST_SECOND + 1)
+
#define FIRST_MINUTE 0
#define LAST_MINUTE 59
#define MINUTE_COUNT (LAST_MINUTE - FIRST_MINUTE + 1)
@@ -165,6 +169,7 @@ typedef struct _entry {
#endif
char **envp;
char *cmd;
+ bitstr_t bit_decl(second, SECOND_COUNT);
bitstr_t bit_decl(minute, MINUTE_COUNT);
bitstr_t bit_decl(hour, HOUR_COUNT);
bitstr_t bit_decl(dom, DOM_COUNT);
@@ -176,6 +181,7 @@ typedef struct _entry {
#define WHEN_REBOOT 0x04
#define RUN_AT 0x08
#define NOT_UNTIL 0x10
+#define SEC_RES 0x20
time_t lastrun;
} entry;
diff --git a/usr.sbin/cron/crontab/Makefile.depend b/usr.sbin/cron/crontab/Makefile.depend
new file mode 100644
index 0000000..faa54bd
--- /dev/null
+++ b/usr.sbin/cron/crontab/Makefile.depend
@@ -0,0 +1,22 @@
+# Autogenerated - do NOT edit!
+
+DEP_RELDIR := ${_PARSEDIR:S,${SRCTOP}/,,}
+
+DEP_MACHINE := ${.PARSEFILE:E}
+
+DIRDEPS = \
+ gnu/lib/libgcc \
+ include \
+ include/xlocale \
+ lib/${CSU_DIR} \
+ lib/libc \
+ lib/libmd \
+ lib/libutil \
+ usr.sbin/cron/lib \
+
+
+.include <dirdeps.mk>
+
+.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+# local dependencies - needed for -jN in clean tree
+.endif
diff --git a/usr.sbin/cron/crontab/crontab.5 b/usr.sbin/cron/crontab/crontab.5
index 458175e..9be37df 100644
--- a/usr.sbin/cron/crontab/crontab.5
+++ b/usr.sbin/cron/crontab/crontab.5
@@ -232,6 +232,8 @@ string meaning
@daily Run once a day, "0 0 * * *".
@midnight (same as @daily)
@hourly Run once an hour, "0 * * * *".
+@every_minute Run once a minute, "*/1 * * * *".
+@every_second Run once a second.
.Ed
.Sh EXAMPLE CRON FILE
.Bd -literal
diff --git a/usr.sbin/cron/crontab/crontab.c b/usr.sbin/cron/crontab/crontab.c
index 3bb54a5..1ac81b0 100644
--- a/usr.sbin/cron/crontab/crontab.c
+++ b/usr.sbin/cron/crontab/crontab.c
@@ -608,6 +608,15 @@ replace_cmd() {
log_it(RealUser, Pid, "REPLACE", User);
+ /*
+ * Creating the 'tn' temp file has already updated the
+ * modification time of the spool directory. Sleep for a
+ * second to ensure that poke_daemon() sets a later
+ * modification time. Otherwise, this can race with the cron
+ * daemon scanning for updated crontabs.
+ */
+ sleep(1);
+
poke_daemon();
return (0);
@@ -618,9 +627,8 @@ static void
poke_daemon() {
#ifdef USE_UTIMES
struct timeval tvs[2];
- struct timezone tz;
- (void) gettimeofday(&tvs[0], &tz);
+ (void)gettimeofday(&tvs[0], NULL);
tvs[1] = tvs[0];
if (utimes(SPOOL_DIR, tvs) < OK) {
warn("can't update mtime on spooldir %s", SPOOL_DIR);
diff --git a/usr.sbin/cron/lib/Makefile.depend b/usr.sbin/cron/lib/Makefile.depend
new file mode 100644
index 0000000..4046f0e
--- /dev/null
+++ b/usr.sbin/cron/lib/Makefile.depend
@@ -0,0 +1,17 @@
+# Autogenerated - do NOT edit!
+
+DEP_RELDIR := ${_PARSEDIR:S,${SRCTOP}/,,}
+
+DEP_MACHINE := ${.PARSEFILE:E}
+
+DIRDEPS = \
+ include \
+ include/xlocale \
+ lib/libutil \
+
+
+.include <dirdeps.mk>
+
+.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+# local dependencies - needed for -jN in clean tree
+.endif
diff --git a/usr.sbin/cron/lib/entry.c b/usr.sbin/cron/lib/entry.c
index ea015da..57f7255 100644
--- a/usr.sbin/cron/lib/entry.c
+++ b/usr.sbin/cron/lib/entry.c
@@ -151,6 +151,7 @@ load_entry(file, error_func, pw, envp)
e->flags |= WHEN_REBOOT;
} else if (!strcmp("yearly", cmd) || !strcmp("annually", cmd)){
Debug(DPARS, ("load_entry()...yearly shortcut\n"))
+ bit_set(e->second, 0);
bit_set(e->minute, 0);
bit_set(e->hour, 0);
bit_set(e->dom, 0);
@@ -159,6 +160,7 @@ load_entry(file, error_func, pw, envp)
e->flags |= DOW_STAR;
} else if (!strcmp("monthly", cmd)) {
Debug(DPARS, ("load_entry()...monthly shortcut\n"))
+ bit_set(e->second, 0);
bit_set(e->minute, 0);
bit_set(e->hour, 0);
bit_set(e->dom, 0);
@@ -167,6 +169,7 @@ load_entry(file, error_func, pw, envp)
e->flags |= DOW_STAR;
} else if (!strcmp("weekly", cmd)) {
Debug(DPARS, ("load_entry()...weekly shortcut\n"))
+ bit_set(e->second, 0);
bit_set(e->minute, 0);
bit_set(e->hour, 0);
bit_nset(e->dom, 0, (LAST_DOM-FIRST_DOM+1));
@@ -175,6 +178,7 @@ load_entry(file, error_func, pw, envp)
bit_set(e->dow, 0);
} else if (!strcmp("daily", cmd) || !strcmp("midnight", cmd)) {
Debug(DPARS, ("load_entry()...daily shortcut\n"))
+ bit_set(e->second, 0);
bit_set(e->minute, 0);
bit_set(e->hour, 0);
bit_nset(e->dom, 0, (LAST_DOM-FIRST_DOM+1));
@@ -182,11 +186,29 @@ load_entry(file, error_func, pw, envp)
bit_nset(e->dow, 0, (LAST_DOW-FIRST_DOW+1));
} else if (!strcmp("hourly", cmd)) {
Debug(DPARS, ("load_entry()...hourly shortcut\n"))
+ bit_set(e->second, 0);
bit_set(e->minute, 0);
bit_nset(e->hour, 0, (LAST_HOUR-FIRST_HOUR+1));
bit_nset(e->dom, 0, (LAST_DOM-FIRST_DOM+1));
bit_nset(e->month, 0, (LAST_MONTH-FIRST_MONTH+1));
bit_nset(e->dow, 0, (LAST_DOW-FIRST_DOW+1));
+ } else if (!strcmp("every_minute", cmd)) {
+ Debug(DPARS, ("load_entry()...every_minute shortcut\n"))
+ bit_set(e->second, 0);
+ bit_nset(e->minute, 0, (LAST_MINUTE-FIRST_MINUTE+1));
+ bit_nset(e->hour, 0, (LAST_HOUR-FIRST_HOUR+1));
+ bit_nset(e->dom, 0, (LAST_DOM-FIRST_DOM+1));
+ bit_nset(e->month, 0, (LAST_MONTH-FIRST_MONTH+1));
+ bit_nset(e->dow, 0, (LAST_DOW-FIRST_DOW+1));
+ } else if (!strcmp("every_second", cmd)) {
+ Debug(DPARS, ("load_entry()...every_second shortcut\n"))
+ e->flags |= SEC_RES;
+ bit_nset(e->second, 0, (LAST_SECOND-FIRST_SECOND+1));
+ bit_nset(e->minute, 0, (LAST_MINUTE-FIRST_MINUTE+1));
+ bit_nset(e->hour, 0, (LAST_HOUR-FIRST_HOUR+1));
+ bit_nset(e->dom, 0, (LAST_DOM-FIRST_DOM+1));
+ bit_nset(e->month, 0, (LAST_MONTH-FIRST_MONTH+1));
+ bit_nset(e->dow, 0, (LAST_DOW-FIRST_DOW+1));
} else {
ecode = e_timespec;
goto eof;
@@ -201,6 +223,7 @@ load_entry(file, error_func, pw, envp)
}
} else {
Debug(DPARS, ("load_entry()...about to parse numerics\n"))
+ bit_set(e->second, 0);
ch = get_list(e->minute, FIRST_MINUTE, LAST_MINUTE,
PPC_NULL, ch, file);
diff --git a/usr.sbin/cron/lib/misc.c b/usr.sbin/cron/lib/misc.c
index 5a08ad0..afed07f 100644
--- a/usr.sbin/cron/lib/misc.c
+++ b/usr.sbin/cron/lib/misc.c
@@ -391,7 +391,9 @@ log_it(username, xpid, event, detail)
char *event;
char *detail;
{
+#if defined(LOG_FILE) || DEBUGGING
PID_T pid = xpid;
+#endif
#if defined(LOG_FILE)
char *msg;
TIME_T now = time((TIME_T) 0);
diff --git a/usr.sbin/crunch/crunchgen/Makefile.depend b/usr.sbin/crunch/crunchgen/Makefile.depend
new file mode 100644
index 0000000..56c209e
--- /dev/null
+++ b/usr.sbin/crunch/crunchgen/Makefile.depend
@@ -0,0 +1,21 @@
+# Autogenerated - do NOT edit!
+
+DEP_RELDIR := ${_PARSEDIR:S,${SRCTOP}/,,}
+
+DEP_MACHINE := ${.PARSEFILE:E}
+
+DIRDEPS = \
+ gnu/lib/libgcc \
+ include \
+ include/xlocale \
+ lib/${CSU_DIR} \
+ lib/libc \
+
+
+.include <dirdeps.mk>
+
+.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+# local dependencies - needed for -jN in clean tree
+crunched_skel.o: crunched_skel.c
+crunched_skel.po: crunched_skel.c
+.endif
diff --git a/usr.sbin/crunch/crunchgen/crunched_main.c b/usr.sbin/crunch/crunchgen/crunched_main.c
index df40d9d..f920c1f 100644
--- a/usr.sbin/crunch/crunchgen/crunched_main.c
+++ b/usr.sbin/crunch/crunchgen/crunched_main.c
@@ -22,8 +22,6 @@
* Author: James da Silva, Systems Design and Analysis Group
* Computer Science Department
* University of Maryland at College Park
- *
- * $FreeBSD$
*/
/*
* crunched_main.c - main program for crunched binaries, it branches to a
@@ -33,6 +31,10 @@
* or calls one of them based on argv[1]. This allows the testing of
* the crunched binary without creating all the links.
*/
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -45,7 +47,8 @@ struct stub {
extern char *__progname;
extern struct stub entry_points[];
-int main(int argc, char **argv, char **envp)
+int
+main(int argc, char **argv, char **envp)
{
char *slash, *basename;
struct stub *ep;
@@ -68,7 +71,8 @@ int main(int argc, char **argv, char **envp)
}
-int crunched_here(char *path)
+int
+crunched_here(char *path)
{
char *slash, *basename;
struct stub *ep;
@@ -83,7 +87,8 @@ int crunched_here(char *path)
}
-int crunched_main(int argc, char **argv, char **envp)
+int
+crunched_main(int argc, char **argv, char **envp)
{
char *slash;
struct stub *ep;
@@ -99,7 +104,8 @@ int crunched_main(int argc, char **argv, char **envp)
}
-int crunched_usage()
+int
+crunched_usage()
{
int columns, len;
struct stub *ep;
@@ -122,4 +128,3 @@ int crunched_usage()
}
/* end of crunched_main.c */
-
diff --git a/usr.sbin/crunch/crunchgen/crunchgen.c b/usr.sbin/crunch/crunchgen/crunchgen.c
index 752acc6..48d6f33 100644
--- a/usr.sbin/crunch/crunchgen/crunchgen.c
+++ b/usr.sbin/crunch/crunchgen/crunchgen.c
@@ -22,8 +22,6 @@
* Author: James da Silva, Systems Design and Analysis Group
* Computer Science Department
* University of Maryland at College Park
- *
- * $FreeBSD$
*/
/*
* ========================================================================
@@ -32,9 +30,12 @@
* Generates a Makefile and main C file for a crunched executable,
* from specs given in a .conf file.
*/
-#include <sys/types.h>
-#include <sys/stat.h>
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
#include <sys/param.h>
+#include <sys/stat.h>
#include <ctype.h>
#include <err.h>
@@ -92,6 +93,7 @@ char outmkname[MAXPATHLEN], outcfname[MAXPATHLEN], execfname[MAXPATHLEN];
char tempfname[MAXPATHLEN], cachename[MAXPATHLEN], curfilename[MAXPATHLEN];
char outhdrname[MAXPATHLEN] ; /* user-supplied header for *.mk */
char *objprefix; /* where are the objects ? */
+char *path_make;
int linenum = -1;
int goterror = 0;
@@ -118,7 +120,8 @@ void parse_conf_file(void);
void gen_outputs(void);
-int main(int argc, char **argv)
+int
+main(int argc, char **argv)
{
char *p;
int optc;
@@ -127,6 +130,10 @@ int main(int argc, char **argv)
readcache = 1;
*outmkname = *outcfname = *execfname = '\0';
+ path_make = getenv("MAKE");
+ if (path_make == NULL || *path_make == '\0')
+ path_make = "make";
+
p = getenv("MAKEOBJDIRPREFIX");
if (p == NULL || *p == '\0')
objprefix = "/usr/obj"; /* default */
@@ -218,7 +225,8 @@ int main(int argc, char **argv)
}
-void usage(void)
+void
+usage(void)
{
fprintf(stderr, "%s%s\n\t%s%s\n", "usage: crunchgen [-foq] ",
"[-h <makefile-header-name>] [-m <makefile>]",
@@ -250,7 +258,8 @@ prog_t *find_prog(char *str);
void add_prog(char *progname);
-void parse_conf_file(void)
+void
+parse_conf_file(void)
{
if (!is_nonempty_file(infilename))
errx(1, "fatal: input file \"%s\" not found", infilename);
@@ -263,7 +272,8 @@ void parse_conf_file(void)
}
-void parse_one_file(char *filename)
+void
+parse_one_file(char *filename)
{
char *fieldv[MAXFIELDS];
int fieldc;
@@ -329,7 +339,8 @@ void parse_one_file(char *filename)
}
-void parse_line(char *line, int *fc, char **fv, int nf)
+void
+parse_line(char *line, int *fc, char **fv, int nf)
{
char *p;
@@ -360,7 +371,8 @@ void parse_line(char *line, int *fc, char **fv, int nf)
}
-void add_srcdirs(int argc, char **argv)
+void
+add_srcdirs(int argc, char **argv)
{
int i;
@@ -376,7 +388,8 @@ void add_srcdirs(int argc, char **argv)
}
-void add_progs(int argc, char **argv)
+void
+add_progs(int argc, char **argv)
{
int i;
@@ -385,7 +398,8 @@ void add_progs(int argc, char **argv)
}
-void add_prog(char *progname)
+void
+add_prog(char *progname)
{
prog_t *p1, *p2;
@@ -426,7 +440,8 @@ void add_prog(char *progname)
}
-void add_link(int argc, char **argv)
+void
+add_link(int argc, char **argv)
{
int i;
prog_t *p = find_prog(argv[1]);
@@ -447,7 +462,8 @@ void add_link(int argc, char **argv)
}
-void add_libs(int argc, char **argv)
+void
+add_libs(int argc, char **argv)
{
int i;
@@ -461,7 +477,8 @@ void add_libs(int argc, char **argv)
}
-void add_libs_so(int argc, char **argv)
+void
+add_libs_so(int argc, char **argv)
{
int i;
@@ -475,7 +492,8 @@ void add_libs_so(int argc, char **argv)
}
-void add_buildopts(int argc, char **argv)
+void
+add_buildopts(int argc, char **argv)
{
int i;
@@ -484,7 +502,8 @@ void add_buildopts(int argc, char **argv)
}
-void add_special(int argc, char **argv)
+void
+add_special(int argc, char **argv)
{
int i;
prog_t *p = find_prog(argv[1]);
@@ -586,7 +605,8 @@ char *genident(char *str);
char *dir_search(char *progname);
-void gen_outputs(void)
+void
+gen_outputs(void)
{
prog_t *p;
@@ -599,13 +619,15 @@ void gen_outputs(void)
gen_output_makefile();
status("");
fprintf(stderr,
- "Run \"make -f %s\" to build crunched binary.\n", outmkname);
+ "Run \"%s -f %s\" to build crunched binary.\n",
+ path_make, outmkname);
}
/*
* run the makefile for the program to find which objects are necessary
*/
-void fillin_program(prog_t *p)
+void
+fillin_program(prog_t *p)
{
char path[MAXPATHLEN];
char line[MAXLINELEN];
@@ -680,7 +702,8 @@ void fillin_program(prog_t *p)
p->goterror = 1;
}
-void fillin_program_objs(prog_t *p, char *path)
+void
+fillin_program_objs(prog_t *p, char *path)
{
char *obj, *cp;
int fd, rc;
@@ -720,16 +743,16 @@ void fillin_program_objs(prog_t *p, char *path)
fprintf(f, "loop:\n\t@echo 'OBJS= '${%s}\n", objvar);
fprintf(f, "crunchgen_objs:\n"
- "\t@cd %s && make -f %s $(BUILDOPTS) $(%s_OPTS)",
- p->srcdir, tempfname, p->ident);
+ "\t@cd %s && %s -f %s $(BUILDOPTS) $(%s_OPTS)",
+ p->srcdir, path_make, tempfname, p->ident);
for (s = p->buildopts; s != NULL; s = s->next)
fprintf(f, " %s", s->str);
fprintf(f, " loop\n");
fclose(f);
- snprintf(line, MAXLINELEN, "cd %s && make -f %s -B crunchgen_objs",
- p->srcdir, tempfname);
+ snprintf(line, MAXLINELEN, "cd %s && %s -f %s -B crunchgen_objs",
+ p->srcdir, path_make, tempfname);
if ((f = popen(line, "r")) == NULL) {
warn("submake pipe");
goterror = 1;
@@ -767,7 +790,8 @@ void fillin_program_objs(prog_t *p, char *path)
unlink(tempfname);
}
-void remove_error_progs(void)
+void
+remove_error_progs(void)
{
prog_t *p1, *p2;
@@ -788,7 +812,8 @@ void remove_error_progs(void)
}
}
-void gen_specials_cache(void)
+void
+gen_specials_cache(void)
{
FILE *cachef;
prog_t *p;
@@ -828,7 +853,8 @@ void gen_specials_cache(void)
}
-void gen_output_makefile(void)
+void
+gen_output_makefile(void)
{
prog_t *p;
FILE *outmk;
@@ -858,7 +884,8 @@ void gen_output_makefile(void)
}
-void gen_output_cfile(void)
+void
+gen_output_cfile(void)
{
extern char *crunched_skel[];
char **cp;
@@ -946,7 +973,8 @@ char *dir_search(char *progname)
}
-void top_makefile_rules(FILE *outmk)
+void
+top_makefile_rules(FILE *outmk)
{
prog_t *p;
@@ -1004,7 +1032,8 @@ void top_makefile_rules(FILE *outmk)
}
-void prog_makefile_rules(FILE *outmk, prog_t *p)
+void
+prog_makefile_rules(FILE *outmk, prog_t *p)
{
strlst_t *lst;
@@ -1089,7 +1118,8 @@ void prog_makefile_rules(FILE *outmk, prog_t *p)
fprintf(outmk, "%s.lo\n", p->name);
}
-void output_strlst(FILE *outf, strlst_t *lst)
+void
+output_strlst(FILE *outf, strlst_t *lst)
{
for (; lst != NULL; lst = lst->next)
if ( strlen(lst->str) )
@@ -1104,7 +1134,8 @@ void output_strlst(FILE *outf, strlst_t *lst)
*
*/
-void status(char *str)
+void
+status(char *str)
{
static int lastlen = 0;
int len, spaces;
@@ -1123,13 +1154,15 @@ void status(char *str)
}
-void out_of_memory(void)
+void
+out_of_memory(void)
{
err(1, "%s: %d: out of memory, stopping", infilename, linenum);
}
-void add_string(strlst_t **listp, char *str)
+void
+add_string(strlst_t **listp, char *str)
{
strlst_t *p1, *p2;
@@ -1153,7 +1186,8 @@ void add_string(strlst_t **listp, char *str)
p1->next = p2;
}
-int subtract_strlst(strlst_t **lista, strlst_t **listb)
+int
+subtract_strlst(strlst_t **lista, strlst_t **listb)
{
int subtract_count = 0;
strlst_t *p1;
@@ -1166,7 +1200,8 @@ int subtract_strlst(strlst_t **lista, strlst_t **listb)
return subtract_count;
}
-int in_list(strlst_t **listp, char *str)
+int
+in_list(strlst_t **listp, char *str)
{
strlst_t *p1;
for (p1 = *listp; p1 != NULL; p1 = p1->next)
@@ -1175,7 +1210,8 @@ int in_list(strlst_t **listp, char *str)
return 0;
}
-int is_dir(char *pathname)
+int
+is_dir(char *pathname)
{
struct stat buf;
@@ -1185,7 +1221,8 @@ int is_dir(char *pathname)
return S_ISDIR(buf.st_mode);
}
-int is_nonempty_file(char *pathname)
+int
+is_nonempty_file(char *pathname)
{
struct stat buf;
diff --git a/usr.sbin/crunch/crunchide/Makefile.depend b/usr.sbin/crunch/crunchide/Makefile.depend
new file mode 100644
index 0000000..a839545
--- /dev/null
+++ b/usr.sbin/crunch/crunchide/Makefile.depend
@@ -0,0 +1,19 @@
+# Autogenerated - do NOT edit!
+
+DEP_RELDIR := ${_PARSEDIR:S,${SRCTOP}/,,}
+
+DEP_MACHINE := ${.PARSEFILE:E}
+
+DIRDEPS = \
+ gnu/lib/libgcc \
+ include \
+ include/xlocale \
+ lib/${CSU_DIR} \
+ lib/libc \
+
+
+.include <dirdeps.mk>
+
+.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+# local dependencies - needed for -jN in clean tree
+.endif
diff --git a/usr.sbin/crunch/crunchide/crunchide.c b/usr.sbin/crunch/crunchide/crunchide.c
index 32c42db..d2b1123 100644
--- a/usr.sbin/crunch/crunchide/crunchide.c
+++ b/usr.sbin/crunch/crunchide/crunchide.c
@@ -1,5 +1,4 @@
/* $NetBSD: crunchide.c,v 1.8 1997/11/01 06:51:45 lukem Exp $ */
-/* $FreeBSD$ */
/*
* Copyright (c) 1997 Christopher G. Demetriou. All rights reserved.
* Copyright (c) 1994 University of Maryland
@@ -59,20 +58,22 @@
* that the final crunched binary BSS size is the max of all the
* component programs' BSS sizes, rather than their sum.
*/
+
#include <sys/cdefs.h>
#ifndef lint
__RCSID("$NetBSD: crunchide.c,v 1.8 1997/11/01 06:51:45 lukem Exp $");
#endif
+__FBSDID("$FreeBSD$");
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <sys/errno.h>
#include <unistd.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <fcntl.h>
#include <a.out.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <sys/errno.h>
#include "extern.h"
@@ -89,9 +90,8 @@ int verbose;
int main(int, char *[]);
-int main(argc, argv)
-int argc;
-char **argv;
+int
+main(int argc, char **argv)
{
int ch, errors;
@@ -127,7 +127,8 @@ char **argv;
return errors;
}
-void usage(void)
+void
+usage(void)
{
fprintf(stderr,
"usage: %s [-k <symbol-name>] [-f <keep-list-file>] <files> ...\n",
@@ -142,7 +143,8 @@ struct keep {
char *sym;
} *keep_list;
-void add_to_keep_list(char *symbol)
+void
+add_to_keep_list(char *symbol)
{
struct keep *newp, *prevp, *curp;
int cmp;
@@ -167,7 +169,8 @@ void add_to_keep_list(char *symbol)
else keep_list = newp;
}
-int in_keep_list(const char *symbol)
+int
+in_keep_list(const char *symbol)
{
struct keep *curp;
int cmp;
@@ -180,7 +183,8 @@ int in_keep_list(const char *symbol)
return curp && cmp == 0;
}
-void add_file_to_keep_list(char *filename)
+void
+add_file_to_keep_list(char *filename)
{
FILE *keepf;
char symbol[1024];
@@ -222,7 +226,8 @@ struct {
#endif
};
-int hide_syms(const char *filename)
+int
+hide_syms(const char *filename)
{
int fd, i, n, rv;
diff --git a/usr.sbin/crunch/crunchide/exec_elf32.c b/usr.sbin/crunch/crunchide/exec_elf32.c
index 2b2e27f..d01fe7e 100644
--- a/usr.sbin/crunch/crunchide/exec_elf32.c
+++ b/usr.sbin/crunch/crunchide/exec_elf32.c
@@ -238,7 +238,7 @@ ELFNAMEEND(hide)(int fd, const char *fn)
Elf_Shdr *shdrp = NULL, *symtabshdr, *strtabshdr;
Elf_Sym *symtabp = NULL;
char *strtabp = NULL;
- Elf_Size nsyms, nlocalsyms, ewi;
+ Elf_Size nsyms, ewi;
ssize_t shdrsize;
int rv, i, weird;
size_t nstrtab_size, nstrtab_nextoff, fn_size;
@@ -327,7 +327,6 @@ ELFNAMEEND(hide)(int fd, const char *fn)
/* Prepare data structures for symbol movement. */
nsyms = xewtoh(symtabshdr->sh_size) / xewtoh(symtabshdr->sh_entsize);
- nlocalsyms = xe32toh(symtabshdr->sh_info);
/* move symbols, making them local */
for (ewi = 0; ewi < nsyms; ewi++) {
diff --git a/usr.sbin/crunch/examples/Makefile b/usr.sbin/crunch/examples/Makefile
index 6dd49ac..1208301 100644
--- a/usr.sbin/crunch/examples/Makefile
+++ b/usr.sbin/crunch/examples/Makefile
@@ -19,14 +19,14 @@ all: $(CRUNCHED)
exe: $(CRUNCHED)
$(OUTPUTS): $(CONF)
- crunchgen ${.CURDIR}/$(CONF)
+ MAKE=${MAKE} crunchgen ${.CURDIR}/$(CONF)
$(CRUNCHED): $(OUTPUTS) submake
submake:
- make -f $(OUTMK)
+ ${MAKE} -f $(OUTMK)
objs:
- make -f $(OUTMK) objs
+ ${MAKE} -f $(OUTMK) objs
cleandir:
rm -f $(CLEANDIRFILES)
diff --git a/usr.sbin/crunch/examples/really-big.conf b/usr.sbin/crunch/examples/really-big.conf
index ab8a939..fbd7f03 100644
--- a/usr.sbin/crunch/examples/really-big.conf
+++ b/usr.sbin/crunch/examples/really-big.conf
@@ -25,7 +25,7 @@ srcdirs /usr/src/sbin
progs badsect bim clri disklabel dmesg dump dumpfs fdisk fsck halt
progs ifconfig init mknod modload modunload mount mount_isofs
-progs mount_lofs mount_msdosfs mount_portalfs mountd
+progs mount_lofs mount_msdosfs mountd
progs newfs nfsd nfsiod ping quotacheck reboot restore route routed savecore
progs shutdown swapon ttyflags tunefs umount
# shell scripts: fastboot
diff --git a/usr.sbin/ctladm/Makefile.depend b/usr.sbin/ctladm/Makefile.depend
new file mode 100644
index 0000000..7dcf1b8
--- /dev/null
+++ b/usr.sbin/ctladm/Makefile.depend
@@ -0,0 +1,23 @@
+# Autogenerated - do NOT edit!
+
+DEP_RELDIR := ${_PARSEDIR:S,${SRCTOP}/,,}
+
+DEP_MACHINE := ${.PARSEFILE:E}
+
+DIRDEPS = \
+ gnu/lib/libgcc \
+ include \
+ include/xlocale \
+ lib/${CSU_DIR} \
+ lib/libc \
+ lib/libcam \
+ lib/libexpat \
+ lib/libsbuf \
+ lib/libutil \
+
+
+.include <dirdeps.mk>
+
+.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+# local dependencies - needed for -jN in clean tree
+.endif
diff --git a/usr.sbin/ctladm/ctladm.c b/usr.sbin/ctladm/ctladm.c
index f53e9f1..2a743da 100644
--- a/usr.sbin/ctladm/ctladm.c
+++ b/usr.sbin/ctladm/ctladm.c
@@ -164,7 +164,7 @@ typedef enum {
static const char rw_opts[] = "Nb:c:d:f:l:";
static const char startstop_opts[] = "io";
-struct ctladm_opts option_table[] = {
+static struct ctladm_opts option_table[] = {
{"adddev", CTLADM_CMD_ADDDEV, CTLADM_ARG_NONE, NULL},
{"bbrread", CTLADM_CMD_BBRREAD, CTLADM_ARG_NEED_TL, "d:l:"},
{"create", CTLADM_CMD_CREATE, CTLADM_ARG_NONE, "b:B:d:l:o:s:S:t:"},
@@ -572,7 +572,7 @@ typedef enum {
CCTL_PORT_MODE_OFF
} cctl_port_mode;
-struct ctladm_opts cctl_fe_table[] = {
+static struct ctladm_opts cctl_fe_table[] = {
{"fc", CTL_PORT_FC, CTLADM_ARG_NONE, NULL},
{"scsi", CTL_PORT_SCSI, CTLADM_ARG_NONE, NULL},
{"internal", CTL_PORT_INTERNAL, CTLADM_ARG_NONE, NULL},
@@ -772,7 +772,6 @@ static int
cctl_delay(int fd, int target, int lun, int argc, char **argv,
char *combinedopt)
{
- int datamove_delay;
struct ctl_io_delay_info delay_info;
char *delayloc = NULL;
char *delaytype = NULL;
@@ -781,7 +780,6 @@ cctl_delay(int fd, int target, int lun, int argc, char **argv,
int c;
retval = 0;
- datamove_delay = 0;
memset(&delay_info, 0, sizeof(delay_info));
@@ -1001,7 +999,7 @@ bailout:
return (retval);
}
-struct ctladm_opts cctl_err_types[] = {
+static struct ctladm_opts cctl_err_types[] = {
{"aborted", CTL_LUN_INJ_ABORTED, CTLADM_ARG_NONE, NULL},
{"mediumerr", CTL_LUN_INJ_MEDIUM_ERR, CTLADM_ARG_NONE, NULL},
{"ua", CTL_LUN_INJ_UA, CTLADM_ARG_NONE, NULL},
@@ -1010,7 +1008,7 @@ struct ctladm_opts cctl_err_types[] = {
};
-struct ctladm_opts cctl_err_patterns[] = {
+static struct ctladm_opts cctl_err_patterns[] = {
{"read", CTL_LUN_PAT_READ, CTLADM_ARG_NONE, NULL},
{"write", CTL_LUN_PAT_WRITE, CTLADM_ARG_NONE, NULL},
{"rw", CTL_LUN_PAT_READWRITE, CTLADM_ARG_NONE, NULL},
@@ -1028,7 +1026,7 @@ static int
cctl_error_inject(int fd, uint32_t target, uint32_t lun, int argc, char **argv,
char *combinedopt)
{
- int retval;
+ int retval = 0;
struct ctl_error_desc err_desc;
uint64_t lba = 0;
uint32_t len = 0;
@@ -3803,7 +3801,7 @@ CTL_DEFAULT_DEV);
int
main(int argc, char **argv)
{
- int option_index, c;
+ int c;
ctladm_cmdfunction command;
ctladm_cmdargs cmdargs;
ctladm_optret optreturn;
@@ -3814,10 +3812,9 @@ main(int argc, char **argv)
int target, lun;
int optstart = 2;
int retval, fd;
- int retries, timeout;
+ int retries;
int initid;
- option_index = 0;
retval = 0;
cmdargs = CTLADM_ARG_NONE;
command = CTLADM_CMD_HELP;
@@ -3826,7 +3823,6 @@ main(int argc, char **argv)
retries = 0;
target = 0;
lun = 0;
- timeout = 0;
initid = 7;
if (argc < 2) {
diff --git a/usr.sbin/ctladm/util.c b/usr.sbin/ctladm/util.c
index df13357..52d8d17 100644
--- a/usr.sbin/ctladm/util.c
+++ b/usr.sbin/ctladm/util.c
@@ -56,7 +56,7 @@ __FBSDID("$FreeBSD$");
#include <camlib.h>
#include "ctladm.h"
-int verbose;
+static int verbose;
/* iget: Integer argument callback
*/
diff --git a/usr.sbin/ctm/ctm/Makefile.depend b/usr.sbin/ctm/ctm/Makefile.depend
new file mode 100644
index 0000000..7520d5d
--- /dev/null
+++ b/usr.sbin/ctm/ctm/Makefile.depend
@@ -0,0 +1,20 @@
+# Autogenerated - do NOT edit!
+
+DEP_RELDIR := ${_PARSEDIR:S,${SRCTOP}/,,}
+
+DEP_MACHINE := ${.PARSEFILE:E}
+
+DIRDEPS = \
+ gnu/lib/libgcc \
+ include \
+ include/xlocale \
+ lib/${CSU_DIR} \
+ lib/libc \
+ lib/libmd \
+
+
+.include <dirdeps.mk>
+
+.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+# local dependencies - needed for -jN in clean tree
+.endif
diff --git a/usr.sbin/ctm/ctm_dequeue/Makefile.depend b/usr.sbin/ctm/ctm_dequeue/Makefile.depend
new file mode 100644
index 0000000..a839545
--- /dev/null
+++ b/usr.sbin/ctm/ctm_dequeue/Makefile.depend
@@ -0,0 +1,19 @@
+# Autogenerated - do NOT edit!
+
+DEP_RELDIR := ${_PARSEDIR:S,${SRCTOP}/,,}
+
+DEP_MACHINE := ${.PARSEFILE:E}
+
+DIRDEPS = \
+ gnu/lib/libgcc \
+ include \
+ include/xlocale \
+ lib/${CSU_DIR} \
+ lib/libc \
+
+
+.include <dirdeps.mk>
+
+.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+# local dependencies - needed for -jN in clean tree
+.endif
diff --git a/usr.sbin/ctm/ctm_rmail/Makefile.depend b/usr.sbin/ctm/ctm_rmail/Makefile.depend
new file mode 100644
index 0000000..a839545
--- /dev/null
+++ b/usr.sbin/ctm/ctm_rmail/Makefile.depend
@@ -0,0 +1,19 @@
+# Autogenerated - do NOT edit!
+
+DEP_RELDIR := ${_PARSEDIR:S,${SRCTOP}/,,}
+
+DEP_MACHINE := ${.PARSEFILE:E}
+
+DIRDEPS = \
+ gnu/lib/libgcc \
+ include \
+ include/xlocale \
+ lib/${CSU_DIR} \
+ lib/libc \
+
+
+.include <dirdeps.mk>
+
+.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+# local dependencies - needed for -jN in clean tree
+.endif
diff --git a/usr.sbin/ctm/ctm_smail/Makefile.depend b/usr.sbin/ctm/ctm_smail/Makefile.depend
new file mode 100644
index 0000000..a839545
--- /dev/null
+++ b/usr.sbin/ctm/ctm_smail/Makefile.depend
@@ -0,0 +1,19 @@
+# Autogenerated - do NOT edit!
+
+DEP_RELDIR := ${_PARSEDIR:S,${SRCTOP}/,,}
+
+DEP_MACHINE := ${.PARSEFILE:E}
+
+DIRDEPS = \
+ gnu/lib/libgcc \
+ include \
+ include/xlocale \
+ lib/${CSU_DIR} \
+ lib/libc \
+
+
+.include <dirdeps.mk>
+
+.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+# local dependencies - needed for -jN in clean tree
+.endif
diff --git a/usr.sbin/daemon/Makefile.depend b/usr.sbin/daemon/Makefile.depend
new file mode 100644
index 0000000..2530420
--- /dev/null
+++ b/usr.sbin/daemon/Makefile.depend
@@ -0,0 +1,19 @@
+# Autogenerated - do NOT edit!
+
+DEP_RELDIR := ${_PARSEDIR:S,${SRCTOP}/,,}
+
+DEP_MACHINE := ${.PARSEFILE:E}
+
+DIRDEPS = \
+ gnu/lib/libgcc \
+ include \
+ lib/${CSU_DIR} \
+ lib/libc \
+ lib/libutil \
+
+
+.include <dirdeps.mk>
+
+.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+# local dependencies - needed for -jN in clean tree
+.endif
diff --git a/usr.sbin/dconschat/Makefile.depend b/usr.sbin/dconschat/Makefile.depend
new file mode 100644
index 0000000..6e3782c
--- /dev/null
+++ b/usr.sbin/dconschat/Makefile.depend
@@ -0,0 +1,21 @@
+# Autogenerated - do NOT edit!
+
+DEP_RELDIR := ${_PARSEDIR:S,${SRCTOP}/,,}
+
+DEP_MACHINE := ${.PARSEFILE:E}
+
+DIRDEPS = \
+ gnu/lib/libgcc \
+ include \
+ include/xlocale \
+ lib/${CSU_DIR} \
+ lib/libc \
+ lib/libkvm \
+ lib/libtelnet \
+
+
+.include <dirdeps.mk>
+
+.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+# local dependencies - needed for -jN in clean tree
+.endif
diff --git a/usr.sbin/ddns-confgen/Makefile.depend b/usr.sbin/ddns-confgen/Makefile.depend
new file mode 100644
index 0000000..78e28c0
--- /dev/null
+++ b/usr.sbin/ddns-confgen/Makefile.depend
@@ -0,0 +1,28 @@
+# Autogenerated - do NOT edit!
+
+DEP_RELDIR := ${_PARSEDIR:S,${SRCTOP}/,,}
+
+DEP_MACHINE := ${.PARSEFILE:E}
+
+DIRDEPS = \
+ gnu/lib/libgcc \
+ include \
+ include/arpa \
+ include/xlocale \
+ lib/${CSU_DIR} \
+ lib/bind/bind9 \
+ lib/bind/dns \
+ lib/bind/isc \
+ lib/bind/isccc \
+ lib/bind/isccfg \
+ lib/bind/lwres \
+ lib/libc \
+ lib/libthr \
+ secure/lib/libcrypto \
+
+
+.include <dirdeps.mk>
+
+.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+# local dependencies - needed for -jN in clean tree
+.endif
diff --git a/usr.sbin/devinfo/Makefile.depend b/usr.sbin/devinfo/Makefile.depend
new file mode 100644
index 0000000..36a5a32
--- /dev/null
+++ b/usr.sbin/devinfo/Makefile.depend
@@ -0,0 +1,19 @@
+# Autogenerated - do NOT edit!
+
+DEP_RELDIR := ${_PARSEDIR:S,${SRCTOP}/,,}
+
+DEP_MACHINE := ${.PARSEFILE:E}
+
+DIRDEPS = \
+ gnu/lib/libgcc \
+ include \
+ lib/${CSU_DIR} \
+ lib/libc \
+ lib/libdevinfo \
+
+
+.include <dirdeps.mk>
+
+.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+# local dependencies - needed for -jN in clean tree
+.endif
diff --git a/usr.sbin/digictl/Makefile.depend b/usr.sbin/digictl/Makefile.depend
new file mode 100644
index 0000000..a839545
--- /dev/null
+++ b/usr.sbin/digictl/Makefile.depend
@@ -0,0 +1,19 @@
+# Autogenerated - do NOT edit!
+
+DEP_RELDIR := ${_PARSEDIR:S,${SRCTOP}/,,}
+
+DEP_MACHINE := ${.PARSEFILE:E}
+
+DIRDEPS = \
+ gnu/lib/libgcc \
+ include \
+ include/xlocale \
+ lib/${CSU_DIR} \
+ lib/libc \
+
+
+.include <dirdeps.mk>
+
+.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+# local dependencies - needed for -jN in clean tree
+.endif
diff --git a/usr.sbin/diskinfo/Makefile.depend b/usr.sbin/diskinfo/Makefile.depend
new file mode 100644
index 0000000..2dd29af
--- /dev/null
+++ b/usr.sbin/diskinfo/Makefile.depend
@@ -0,0 +1,20 @@
+# Autogenerated - do NOT edit!
+
+DEP_RELDIR := ${_PARSEDIR:S,${SRCTOP}/,,}
+
+DEP_MACHINE := ${.PARSEFILE:E}
+
+DIRDEPS = \
+ gnu/lib/libgcc \
+ include \
+ include/xlocale \
+ lib/${CSU_DIR} \
+ lib/libc \
+ lib/libutil \
+
+
+.include <dirdeps.mk>
+
+.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+# local dependencies - needed for -jN in clean tree
+.endif
diff --git a/usr.sbin/diskinfo/diskinfo.c b/usr.sbin/diskinfo/diskinfo.c
index fa23443..90beba2 100644
--- a/usr.sbin/diskinfo/diskinfo.c
+++ b/usr.sbin/diskinfo/diskinfo.c
@@ -339,7 +339,7 @@ speeddisk(int fd, off_t mediasize, u_int sectorsize)
TR(bulk * 1024);
printf("\tinside: ");
- b0 = sectorcount - bulk * (1024*1024 / sectorsize) - 1;;
+ b0 = sectorcount - bulk * (1024*1024 / sectorsize) - 1;
rdsect(fd, b0, sectorsize);
T0();
for (i = 0; i < bulk; i++) {
diff --git a/usr.sbin/dnssec-dsfromkey/Makefile.depend b/usr.sbin/dnssec-dsfromkey/Makefile.depend
new file mode 100644
index 0000000..78e28c0
--- /dev/null
+++ b/usr.sbin/dnssec-dsfromkey/Makefile.depend
@@ -0,0 +1,28 @@
+# Autogenerated - do NOT edit!
+
+DEP_RELDIR := ${_PARSEDIR:S,${SRCTOP}/,,}
+
+DEP_MACHINE := ${.PARSEFILE:E}
+
+DIRDEPS = \
+ gnu/lib/libgcc \
+ include \
+ include/arpa \
+ include/xlocale \
+ lib/${CSU_DIR} \
+ lib/bind/bind9 \
+ lib/bind/dns \
+ lib/bind/isc \
+ lib/bind/isccc \
+ lib/bind/isccfg \
+ lib/bind/lwres \
+ lib/libc \
+ lib/libthr \
+ secure/lib/libcrypto \
+
+
+.include <dirdeps.mk>
+
+.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+# local dependencies - needed for -jN in clean tree
+.endif
diff --git a/usr.sbin/dnssec-keyfromlabel/Makefile.depend b/usr.sbin/dnssec-keyfromlabel/Makefile.depend
new file mode 100644
index 0000000..78e28c0
--- /dev/null
+++ b/usr.sbin/dnssec-keyfromlabel/Makefile.depend
@@ -0,0 +1,28 @@
+# Autogenerated - do NOT edit!
+
+DEP_RELDIR := ${_PARSEDIR:S,${SRCTOP}/,,}
+
+DEP_MACHINE := ${.PARSEFILE:E}
+
+DIRDEPS = \
+ gnu/lib/libgcc \
+ include \
+ include/arpa \
+ include/xlocale \
+ lib/${CSU_DIR} \
+ lib/bind/bind9 \
+ lib/bind/dns \
+ lib/bind/isc \
+ lib/bind/isccc \
+ lib/bind/isccfg \
+ lib/bind/lwres \
+ lib/libc \
+ lib/libthr \
+ secure/lib/libcrypto \
+
+
+.include <dirdeps.mk>
+
+.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+# local dependencies - needed for -jN in clean tree
+.endif
diff --git a/usr.sbin/dnssec-keygen/Makefile.depend b/usr.sbin/dnssec-keygen/Makefile.depend
new file mode 100644
index 0000000..78e28c0
--- /dev/null
+++ b/usr.sbin/dnssec-keygen/Makefile.depend
@@ -0,0 +1,28 @@
+# Autogenerated - do NOT edit!
+
+DEP_RELDIR := ${_PARSEDIR:S,${SRCTOP}/,,}
+
+DEP_MACHINE := ${.PARSEFILE:E}
+
+DIRDEPS = \
+ gnu/lib/libgcc \
+ include \
+ include/arpa \
+ include/xlocale \
+ lib/${CSU_DIR} \
+ lib/bind/bind9 \
+ lib/bind/dns \
+ lib/bind/isc \
+ lib/bind/isccc \
+ lib/bind/isccfg \
+ lib/bind/lwres \
+ lib/libc \
+ lib/libthr \
+ secure/lib/libcrypto \
+
+
+.include <dirdeps.mk>
+
+.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+# local dependencies - needed for -jN in clean tree
+.endif
diff --git a/usr.sbin/dnssec-revoke/Makefile.depend b/usr.sbin/dnssec-revoke/Makefile.depend
new file mode 100644
index 0000000..78e28c0
--- /dev/null
+++ b/usr.sbin/dnssec-revoke/Makefile.depend
@@ -0,0 +1,28 @@
+# Autogenerated - do NOT edit!
+
+DEP_RELDIR := ${_PARSEDIR:S,${SRCTOP}/,,}
+
+DEP_MACHINE := ${.PARSEFILE:E}
+
+DIRDEPS = \
+ gnu/lib/libgcc \
+ include \
+ include/arpa \
+ include/xlocale \
+ lib/${CSU_DIR} \
+ lib/bind/bind9 \
+ lib/bind/dns \
+ lib/bind/isc \
+ lib/bind/isccc \
+ lib/bind/isccfg \
+ lib/bind/lwres \
+ lib/libc \
+ lib/libthr \
+ secure/lib/libcrypto \
+
+
+.include <dirdeps.mk>
+
+.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+# local dependencies - needed for -jN in clean tree
+.endif
diff --git a/usr.sbin/dnssec-settime/Makefile.depend b/usr.sbin/dnssec-settime/Makefile.depend
new file mode 100644
index 0000000..78e28c0
--- /dev/null
+++ b/usr.sbin/dnssec-settime/Makefile.depend
@@ -0,0 +1,28 @@
+# Autogenerated - do NOT edit!
+
+DEP_RELDIR := ${_PARSEDIR:S,${SRCTOP}/,,}
+
+DEP_MACHINE := ${.PARSEFILE:E}
+
+DIRDEPS = \
+ gnu/lib/libgcc \
+ include \
+ include/arpa \
+ include/xlocale \
+ lib/${CSU_DIR} \
+ lib/bind/bind9 \
+ lib/bind/dns \
+ lib/bind/isc \
+ lib/bind/isccc \
+ lib/bind/isccfg \
+ lib/bind/lwres \
+ lib/libc \
+ lib/libthr \
+ secure/lib/libcrypto \
+
+
+.include <dirdeps.mk>
+
+.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+# local dependencies - needed for -jN in clean tree
+.endif
diff --git a/usr.sbin/dnssec-signzone/Makefile.depend b/usr.sbin/dnssec-signzone/Makefile.depend
new file mode 100644
index 0000000..78e28c0
--- /dev/null
+++ b/usr.sbin/dnssec-signzone/Makefile.depend
@@ -0,0 +1,28 @@
+# Autogenerated - do NOT edit!
+
+DEP_RELDIR := ${_PARSEDIR:S,${SRCTOP}/,,}
+
+DEP_MACHINE := ${.PARSEFILE:E}
+
+DIRDEPS = \
+ gnu/lib/libgcc \
+ include \
+ include/arpa \
+ include/xlocale \
+ lib/${CSU_DIR} \
+ lib/bind/bind9 \
+ lib/bind/dns \
+ lib/bind/isc \
+ lib/bind/isccc \
+ lib/bind/isccfg \
+ lib/bind/lwres \
+ lib/libc \
+ lib/libthr \
+ secure/lib/libcrypto \
+
+
+.include <dirdeps.mk>
+
+.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+# local dependencies - needed for -jN in clean tree
+.endif
diff --git a/usr.sbin/dumpcis/Makefile.depend b/usr.sbin/dumpcis/Makefile.depend
new file mode 100644
index 0000000..a839545
--- /dev/null
+++ b/usr.sbin/dumpcis/Makefile.depend
@@ -0,0 +1,19 @@
+# Autogenerated - do NOT edit!
+
+DEP_RELDIR := ${_PARSEDIR:S,${SRCTOP}/,,}
+
+DEP_MACHINE := ${.PARSEFILE:E}
+
+DIRDEPS = \
+ gnu/lib/libgcc \
+ include \
+ include/xlocale \
+ lib/${CSU_DIR} \
+ lib/libc \
+
+
+.include <dirdeps.mk>
+
+.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+# local dependencies - needed for -jN in clean tree
+.endif
diff --git a/usr.sbin/editmap/Makefile.depend b/usr.sbin/editmap/Makefile.depend
new file mode 100644
index 0000000..48902cc
--- /dev/null
+++ b/usr.sbin/editmap/Makefile.depend
@@ -0,0 +1,25 @@
+# Autogenerated - do NOT edit!
+
+DEP_RELDIR := ${_PARSEDIR:S,${SRCTOP}/,,}
+
+DEP_MACHINE := ${.PARSEFILE:E}
+
+DIRDEPS = \
+ gnu/lib/libgcc \
+ include \
+ include/xlocale \
+ lib/${CSU_DIR} \
+ lib/libc \
+ lib/libsm \
+ lib/libsmdb \
+ lib/libsmutil \
+ lib/libutil \
+
+
+.include <dirdeps.mk>
+
+.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+# local dependencies - needed for -jN in clean tree
+editmap.o: sm_os.h
+editmap.po: sm_os.h
+.endif
diff --git a/usr.sbin/edquota/Makefile.depend b/usr.sbin/edquota/Makefile.depend
new file mode 100644
index 0000000..2dd29af
--- /dev/null
+++ b/usr.sbin/edquota/Makefile.depend
@@ -0,0 +1,20 @@
+# Autogenerated - do NOT edit!
+
+DEP_RELDIR := ${_PARSEDIR:S,${SRCTOP}/,,}
+
+DEP_MACHINE := ${.PARSEFILE:E}
+
+DIRDEPS = \
+ gnu/lib/libgcc \
+ include \
+ include/xlocale \
+ lib/${CSU_DIR} \
+ lib/libc \
+ lib/libutil \
+
+
+.include <dirdeps.mk>
+
+.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+# local dependencies - needed for -jN in clean tree
+.endif
diff --git a/usr.sbin/edquota/edquota.c b/usr.sbin/edquota/edquota.c
index 0957011..930a460 100644
--- a/usr.sbin/edquota/edquota.c
+++ b/usr.sbin/edquota/edquota.c
@@ -453,8 +453,10 @@ editit(char *tmpf)
const char *ed;
sigsetmask(omask);
- setgid(getgid());
- setuid(getuid());
+ if (setgid(getgid()) != 0)
+ err(1, "setgid failed");
+ if (setuid(getuid()) != 0)
+ err(1, "setuid failed");
if ((ed = getenv("EDITOR")) == (char *)0)
ed = _PATH_VI;
execlp(ed, ed, tmpf, (char *)0);
diff --git a/usr.sbin/eeprom/Makefile.depend b/usr.sbin/eeprom/Makefile.depend
new file mode 100644
index 0000000..a839545
--- /dev/null
+++ b/usr.sbin/eeprom/Makefile.depend
@@ -0,0 +1,19 @@
+# Autogenerated - do NOT edit!
+
+DEP_RELDIR := ${_PARSEDIR:S,${SRCTOP}/,,}
+
+DEP_MACHINE := ${.PARSEFILE:E}
+
+DIRDEPS = \
+ gnu/lib/libgcc \
+ include \
+ include/xlocale \
+ lib/${CSU_DIR} \
+ lib/libc \
+
+
+.include <dirdeps.mk>
+
+.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+# local dependencies - needed for -jN in clean tree
+.endif
diff --git a/usr.sbin/etcupdate/Makefile b/usr.sbin/etcupdate/Makefile
new file mode 100644
index 0000000..9f6d17e
--- /dev/null
+++ b/usr.sbin/etcupdate/Makefile
@@ -0,0 +1,6 @@
+# $FreeBSD$
+
+SCRIPTS=etcupdate.sh
+MAN= etcupdate.8
+
+.include <bsd.prog.mk>
diff --git a/usr.sbin/etcupdate/etcupdate.8 b/usr.sbin/etcupdate/etcupdate.8
new file mode 100644
index 0000000..a61f181
--- /dev/null
+++ b/usr.sbin/etcupdate/etcupdate.8
@@ -0,0 +1,789 @@
+.\" Copyright (c) 2010-2012 Advanced Computing Technologies LLC
+.\" Written by: John H. Baldwin <jhb@FreeBSD.org>
+.\" All rights reserved.
+.\"
+.\" Redistribution and use in source and binary forms, with or without
+.\" modification, are permitted provided that the following conditions
+.\" are met:
+.\" 1. Redistributions of source code must retain the above copyright
+.\" notice, this list of conditions and the following disclaimer.
+.\" 2. Redistributions in binary form must reproduce the above copyright
+.\" notice, this list of conditions and the following disclaimer in the
+.\" documentation and/or other materials provided with the distribution.
+.\"
+.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+.\" SUCH DAMAGE.
+.\"
+.\" $FreeBSD$
+.\"
+.Dd March 16, 2012
+.Dt ETCUPDATE 8
+.Os
+.Sh NAME
+.Nm etcupdate
+.Nd "manage updates to system files not updated by installworld"
+.Sh SYNOPSIS
+.Nm
+.Op Fl nBF
+.Op Fl d Ar workdir
+.Op Fl r | Fl s Ar source | Fl t Ar tarball
+.Op Fl A Ar patterns
+.Op Fl D Ar destdir
+.Op Fl I Ar patterns
+.Op Fl L Ar logfile
+.Op Fl M Ar options
+.Nm
+.Cm build
+.Op Fl B
+.Op Fl d Ar workdir
+.Op Fl s Ar source
+.Op Fl L Ar logfile
+.Op Fl M Ar options
+.Ar tarball
+.Nm
+.Cm diff
+.Op Fl d Ar workdir
+.Op Fl D Ar destdir
+.Op Fl I Ar patterns
+.Op Fl L Ar logfile
+.Nm
+.Cm extract
+.Op Fl B
+.Op Fl d Ar workdir
+.Op Fl s Ar source | Fl t Ar tarball
+.Op Fl L Ar logfile
+.Op Fl M Ar options
+.Nm
+.Cm resolve
+.Op Fl d Ar workdir
+.Op Fl D Ar destdir
+.Op Fl L Ar logfile
+.Nm
+.Cm status
+.Op Fl d Ar workdir
+.Op Fl D Ar destdir
+.Sh DESCRIPTION
+The
+.Nm
+utility is a tool for managing updates to files that are not updated as
+part of
+.Sq make installworld
+such as files in
+.Pa /etc .
+It manages updates by doing a three-way merge of changes made to these
+files against the local versions.
+It is also designed to minimize the amount of user intervention with
+the goal of simplifying upgrades for clusters of machines.
+.Pp
+To perform a three-way merge,
+.Nm
+keeps copies of the current and previous versions of files that it manages.
+These copies are stored in two trees known as the
+.Dq current
+and
+.Dq previous
+trees.
+During a merge,
+.Nm
+compares the
+.Dq current
+and
+.Dq previous
+copies of each file to determine which changes need to be merged into the
+local version of each file.
+If a file can be updated without generating a conflict,
+.Nm
+will update the file automatically.
+If the local changes to a file conflict with the changes made to a file in
+the source tree,
+then a merge conflict is generated.
+The conflict must be resolved after the merge has finished.
+The
+.Nm
+utility will not perform a new merge until all conflicts from an earlier
+merge are resolved.
+.Sh MODES
+The
+.Nm
+utility supports several modes of operation.
+The mode is specified via an optional command argument.
+If present, the command must be the first argument on the command line.
+If a command is not specified, the default mode is used.
+.Ss Default Mode
+The default mode merges changes from the source tree to the destination
+directory.
+First,
+it updates the
+.Dq current
+and
+.Dq previous
+trees.
+Next,
+it compares the two trees merging changes into the destination directory.
+Finally,
+it displays warnings for any conditions it could not handle automatically.
+.Pp
+If the
+.Fl r
+option is not specified,
+then the first step taken is to update the
+.Dq current
+and
+.Dq previous
+trees.
+If a
+.Dq current
+tree already exists,
+then that tree is saved as the
+.Dq previous
+tree.
+An older
+.Dq previous
+tree is removed if it exists.
+By default the new
+.Dq current
+tree is built from a source tree.
+However,
+if a tarball is specified via the
+.Fl t
+option,
+then the tree is extracted from that tarball instead.
+.Pp
+Next,
+.Nm
+compares the files in the
+.Dq current
+and
+.Dq previous
+trees.
+If a file was removed from the
+.Dq current
+tree,
+then it will be removed from the destination directory only if it
+does not have any local modifications.
+If a file was added to the
+.Dq current
+tree,
+then it will be copied to the destination directory only if it
+would not clobber an existing file.
+If a file is changed in the
+.Dq current
+tree,
+then
+.Nm
+will attempt to merge the changes into the version of the file in the
+destination directory.
+If the merge encounters conflicts,
+then a version of the file with conflict markers will be saved for
+future resolution.
+If the merge does not encounter conflicts,
+then the merged version of the file will be saved in the destination
+directory.
+If
+.Nm
+is not able to safely merge in changes to a file other than a merge conflict,
+it will generate a warning.
+.Pp
+For each file that is updated a line will be output with a leading character
+to indicate the action taken.
+The possible actions follow:
+.Pp
+.Bl -tag -width "A" -compact -offset indent
+.It A
+Added
+.It C
+Conflict
+.It D
+Deleted
+.It M
+Merged
+.It U
+Updated
+.El
+.Pp
+Finally,
+if any warnings were encountered they are displayed after the merge has
+completed.
+.Pp
+Note that for certain files
+.Nm
+will perform post-install actions any time that the file is updated.
+Specifically,
+.Xr pwd_mkdb 8
+is invoked if
+.Pa /etc/master.passwd
+is changed,
+.Xr cap_mkdb 1
+is invoked to update
+.Pa /etc/login.conf.db
+if
+.Pa /etc/login.conf
+is changed,
+.Xr newaliases 1
+is invoked if
+.Pa /etc/mail/aliases
+is changed,
+and
+.Pa /etc/rc.d/motd
+is invoked if
+.Pa /etc/motd
+is changed.
+One exception is that if
+.Pa /etc/mail/aliases
+is changed and the destination directory is not the default,
+then a warning will be issued instead.
+This is due to a limitation of the
+.Xr newaliases 1
+command.
+Similarly,
+if
+.Pa /etc/motd
+is changed and the destination directory is not the default,
+then
+.Pa /etc/rc.d/motd
+will not be executed due to a limitation of that script.
+In this case no warning is issued as the result of
+.Pa /etc/rc.d/motd
+is merely cosmetic and will be corrected on the next reboot.
+.Ss Build Mode
+The
+.Cm build
+mode is used to build a tarball that contains a snapshot of a
+.Dq current
+tree.
+This tarball can be used by the default and extract modes.
+Using a tarball can allow
+.Nm
+to perform a merge without requiring a source tree that matches the
+currently installed world.
+The
+.Fa tarball
+argument specifies the name of the file to create.
+The file will be a
+.Xr tar 5
+file compressed with
+.Xr bzip2 1 .
+.Ss Diff Mode
+The
+.Cm diff
+mode compares the versions of files in the destination directory to the
+.Dq current
+tree and generates a unified format diff of the changes.
+This can be used to determine which files have been locally modified and how.
+Note that
+.Nm
+does not manage files that are not maintained in the source tree such as
+.Pa /etc/fstab
+and
+.Pa /etc/rc.conf .
+.Ss Extract Mode
+The
+.Cm extract
+mode generates a new
+.Dq current
+tree.
+Unlike the default mode,
+it does not save any existing
+.Dq current
+tree and does not modify any existing
+.Dq previous
+tree.
+The new
+.Dq current
+tree can either be built from a source tree or extracted from a tarball.
+.Ss Resolve Mode
+The
+.Cm resolve
+mode is used to resolve any conflicts encountered during a merge.
+In this mode,
+.Nm
+iterates over any existing conflicts prompting the user for actions to take
+on each conflicted file.
+For each file, the following actions are available:
+.Pp
+.Bl -tag -width "(tf) theirs-full" -compact
+.It (p) postpone
+Ignore this conflict for now.
+.It (df) diff-full
+Show all changes made to the merged file as a unified diff.
+.It (e) edit
+Change the merged file in an editor.
+.It (r) resolved
+Install the merged version of the file into the destination directory.
+.It (mf) mine-full
+Use the version of the file in the destination directory and ignore any
+changes made to the file in the
+.Dq current
+tree.
+.It (tf) theirs-full
+Use the version of the file from the
+.Dq current
+tree and discard any local changes made to the file.
+.It (h) help
+Display the list of commands.
+.El
+.Ss Status Mode
+The
+.Cm status
+mode shows a summary of the results of the most recent merge.
+First it lists any files for which there are unresolved conflicts.
+Next it lists any warnings generated during the last merge.
+If the last merge did not generate any conflicts or warnings,
+then nothing will be output.
+.Sh OPTIONS
+The following options are available.
+Note that most options do not apply to all modes.
+.Bl -tag -width ".Fl d Ar workdir"
+.It Fl B
+Do not build generated files in a private object tree.
+Instead,
+reuse the generated files from a previously built object tree that matches
+the source tree.
+This can be useful to avoid gratuitous conflicts in
+.Xr sendmail 8
+configuration
+files when bootstrapping.
+It can also be useful for building a tarball that matches a specific
+world build.
+.It Fl d Ar workdir
+Specify an alternate directory to use as the work directory.
+The work directory is used to store the
+.Dq current
+and
+.Dq previous
+trees as well as unresolved conflicts.
+The default work directory is
+.Pa <destdir>/var/db/etcupdate .
+.It Fl A Ar patterns
+Always install the new version of any files that match any of the patterns
+listed in
+.Ar patterns .
+Each pattern is evaluated as an
+.Xr sh 1
+shell pattern.
+This option may be specified multiple times to specify multiple patterns.
+Multiple space-separated patterns may also be specified in a single
+option.
+Note that ignored files specified via the
+.Ev IGNORE_FILES
+variable or the
+.Fl I
+option will not be installed.
+.It Fl D Ar destdir
+Specify an alternate destination directory as the target of a merge.
+This is analogous to the
+.Dv DESTDIR
+variable used with
+.Sq make installworld .
+The default destination directory is an empty string which results in
+merges updating
+.Pa /etc
+on the local machine.
+.It Fl F
+Ignore changes in the FreeBSD ID string when comparing files in the
+destination directory to files in either of the
+.Dq current
+or
+.Dq previous
+trees.
+In
+.Cm diff
+mode,
+this reduces noise due to FreeBSD ID string changes in the output.
+During an update this can simplify handling for harmless conflicts caused
+by FreeBSD ID string changes.
+.Pp
+Specifically,
+if a file in the destination directory is identical to the same file in the
+.Dq previous
+tree modulo the FreeBSD ID string,
+then the file is treated as if it was unmodified and the
+.Dq current
+version of the file will be installed.
+Similarly,
+if a file in the destination directory is identical to the same file in the
+.Dq current
+tree modulo the FreeBSD ID string,
+then the
+.Dq current
+version of the file will be installed to update the ID string.
+If the
+.Dq previous
+and
+.Dq current
+versions of the file are identical,
+then
+.Nm
+will not change the file in the destination directory.
+.Pp
+Due to limitations in the
+.Xr diff 1
+command,
+this option may not have an effect if there are other changes in a file that
+are close to the FreeBSD ID string.
+.It Fl I Ar patterns
+Ignore any files that match any of the patterns listed in
+.Ar patterns .
+No warnings or other messages will be generated for those files during a
+merge.
+Each pattern is evaluated as an
+.Xr sh 1
+shell pattern.
+This option may be specified multiple times to specify multiple patterns.
+Multiple space-separated patterns may also be specified in a single
+option.
+.It Fl L Ar logfile
+Specify an alternate path for the log file.
+The
+.Nm
+utility logs each command that it invokes along with the standard output
+and standard error to this file.
+By default the log file is stored in a file named
+.Pa log
+in the work directory.
+.It Fl M Ar options
+Pass
+.Ar options
+as additional parameters to
+.Xr make 1
+when building a
+.Dq current
+tree.
+This can be used for to set the
+.Dv TARGET
+or
+.Dv TARGET_ARCH
+variables for a cross-build.
+.It Fl n
+Enable
+.Dq dry-run
+mode.
+Do not merge any changes to the destination directory.
+Instead,
+report what actions would be taken during a merge.
+Note that the existing
+.Dq current
+and
+.Dq previous
+trees will not be changed.
+If the
+.Fl r
+option is not specified,
+then a temporary
+.Dq current
+tree will be extracted to perform the comparison.
+.It Fl r
+Do not update the
+.Dq current
+and
+.Dq previous
+trees during a merge.
+This can be used to
+.Dq re-run
+a previous merge operation.
+.It Fl s Ar source
+Specify an alternate source tree to use when building or extracting a
+.Dq current
+tree.
+The default source tree is
+.Pa /usr/src .
+.It Fl t Ar tarball
+Extract a new
+.Dq current
+tree from a tarball previously generated by the
+.Cm build
+command rather than building the tree from a source tree.
+.El
+.Sh CONFIG FILE
+The
+.Nm
+utility can also be configured by setting variables in an optional
+configuration file named
+.Pa /etc/etcupdate.conf .
+Note that command line options override settings in the configuration file.
+The configuration file is executed by
+.Xr sh 1 ,
+so it uses that syntax to set configuration variables.
+The following variables can be set:
+.Bl -tag -width ".Ev ALWAYS_INSTALL"
+.It Ev ALWAYS_INSTALL
+Always install files that match any of the patterns listed in this variable
+similar to the
+.Fl A
+option.
+.It Ev DESTDIR
+Specify an alternate destination directory similar to the
+.Fl D
+option.
+.It Ev EDITOR
+Specify a program to edit merge conflicts.
+.It Ev FREEBSD_ID
+Ignore changes in the FreeBSD ID string similar to the
+.Fl F
+option.
+This is enabled by setting the variable to a non-empty value.
+.It Ev IGNORE_FILES
+Ignore files that match any of the patterns listed in this variable
+similar to the
+.Fl I
+option.
+.It Ev LOGFILE
+Specify an alternate path for the log file similar to the
+.Fl L
+option.
+.It Ev MAKE_OPTIONS
+Pass additional options to
+.Xr make 1
+when building a
+.Dq current
+tree similar to the
+.Fl M
+option.
+.It Ev SRCDIR
+Specify an alternate source tree similar to the
+.Fl s
+option.
+.It Ev WORKDIR
+Specify an alternate work directory similar to the
+.Fl d
+option.
+.El
+.Sh ENVIRONMENT
+The
+.Nm
+utility uses the program identified in the
+.Ev EDITOR
+environment variable to edit merge conflicts.
+If
+.Ev EDITOR
+is not set,
+.Xr vi 1
+is used as the default editor.
+.Sh FILES
+.Bl -tag -width ".Pa /var/db/etcupdate/log" -compact
+.It Pa /etc/etcupdate.conf
+Optional config file.
+.It Pa /var/db/etcupdate
+Default work directory used to store trees and other data.
+.It Pa /var/db/etcupdate/log
+Default log file.
+.El
+.Sh EXIT STATUS
+.Ex -std
+.Sh EXAMPLES
+If the source tree matches the currently installed world,
+then the following can be used to bootstrap
+.Nm
+so that it can be used for future upgrades:
+.Pp
+.Dl "etcupdate extract"
+.Pp
+To merge changes after an upgrade via the buildworld and installworld process:
+.Pp
+.Dl "etcupdate"
+.Pp
+To resolve any conflicts generated during a merge:
+.Pp
+.Dl "etcupdate resolve"
+.Sh DIAGNOSTICS
+The following warning messages may be generated during a merge.
+Note that several of these warnings cover obscure cases that should occur
+rarely if at all in practice.
+For example,
+if a file changes from a file to a directory in the
+.Dq current
+tree
+and the file was modified in the destination directory,
+then a warning will be triggered.
+In general,
+when a warning references a pathname,
+the corresponding file in the destination directory is not changed by a
+merge operation.
+.Bl -diag
+.It "Directory mismatch: <path> (<type>)"
+An attempt was made to create a directory at
+.Pa path
+but an existing file of type
+.Dq type
+already exists for that path name.
+.It "Modified link changed: <file> (<old> became <new>)"
+The target of a symbolic link named
+.Pa file
+was changed from
+.Dq old
+to
+.Dq new
+in the
+.Dq current
+tree.
+The symbolic link has been modified to point to a target that is neither
+.Dq old
+nor
+.Dq new
+in the destination directory.
+.It "Modified mismatch: <file> (<new> vs <dest>)"
+A file named
+.Pa file
+of type
+.Dq new
+was modified in the
+.Dq current
+tree,
+but the file exists as a different type
+.Dq dest
+in the destination directory.
+.It "Modified <type> changed: <file> (<old> became <new>)"
+A file named
+.Pa file
+changed type from
+.Dq old
+in the
+.Dq previous
+tree to type
+.Dq new
+in the
+.Dq current
+tree.
+The file in the destination directory of type
+.Dq type
+has been modified,
+so it could not be merged automatically.
+.It "Modified <type> remains: <file>"
+The file of type
+.Dq type
+named
+.Pa file
+has been removed from the
+.Dq current
+tree,
+but it has been locally modified.
+The modified version of the file remains in the destination directory.
+.It "Needs update: /etc/mail/aliases.db (required manual update via newaliases(1))"
+The file
+.Pa /etc/mail/aliases
+was updated during a merge with a non-empty destination directory.
+Due to a limitation of the
+.Xr newaliases 1
+command,
+.Nm
+was not able to automatically update the corresponding aliases database.
+.It "New file mismatch: <file> (<new> vs <dest>)"
+A new file named
+.Pa file
+of type
+.Dq new
+has been added to the
+.Dq current
+tree.
+A file of that name already exists in the destination directory,
+but it is of a different type
+.Dq dest .
+.It "New link conflict: <file> (<new> vs <dest>)"
+A symbolic link named
+.Pa file
+has been added to the
+.Dq current
+tree that links to
+.Dq new .
+A symbolic link of the same name already exists in the destination
+directory,
+but it links to a different target
+.Dq dest .
+.It "Non-empty directory remains: <file>"
+The directory
+.Pa file
+was removed from the
+.Dq current
+tree,
+but it contains additional files in the destination directory.
+These additional files as well as the directory remain.
+.It "Remove mismatch: <file> (<old> became <new>)"
+A file named
+.Pa file
+changed from type
+.Dq old
+in the
+.Dq previous
+tree to type
+.Dq new
+in the
+.Dq current
+tree,
+but it has been removed in the destination directory.
+.It "Removed file changed: <file>"
+A file named
+.Pa file
+was modified in the
+.Dq current
+tree,
+but it has been removed in the destination directory.
+.It "Removed link changed: <file> (<old> became <new>)"
+The target of a symbolic link named
+.Pa file
+was changed from
+.Dq old
+to
+.Dq new
+in the
+.Dq current
+tree,
+but it has been removed in the destination directory.
+.El
+.Sh SEE ALSO
+.Xr cap_mkdb 1 ,
+.Xr diff 1 ,
+.Xr make 1 ,
+.Xr newaliases 1 ,
+.Xr sh 1 ,
+.Xr pwd_mkdb 8
+.Sh HISTORY
+The
+.Nm
+utility first appeared in
+.Fx 10.0 .
+.Sh AUTHORS
+The
+.Nm
+utility was written by
+.An John Baldwin Aq jhb@FreeBSD.org .
+.Sh BUGS
+Rerunning a merge does not automatically delete conflicts left over from a
+previous merge.
+Any conflicts must be resolved before the merge can be rerun.
+It it is not clear if this is a feature or a bug.
+.Pp
+There is no way to easily automate conflict resolution for specific files.
+For example, one can imagine a syntax along the lines of
+.Pp
+.Dl "etcupdate resolve tf /some/file"
+.Pp
+to resolve a specific conflict in an automated fashion.
+.Pp
+It might be nice to have something like a
+.Sq revert
+command to replace a locally modified version of a file with the stock
+version of the file.
+For example:
+.Pp
+.Dl "etcupdate revert /etc/mail/freebsd.cf"
+.Pp
+Bootstrapping
+.Nm
+often results in gratuitous diffs in
+.Pa /etc/mail/*.cf
+that cause conflicts in the first merge.
+If an object tree that matches the source tree is present when bootstrapping,
+then passing the
+.Fl B
+flag to the
+.Cm extract
+command can work around this.
diff --git a/usr.sbin/etcupdate/etcupdate.sh b/usr.sbin/etcupdate/etcupdate.sh
new file mode 100755
index 0000000..2216836
--- /dev/null
+++ b/usr.sbin/etcupdate/etcupdate.sh
@@ -0,0 +1,1675 @@
+#!/bin/sh
+#
+# Copyright (c) 2010 Advanced Computing Technologies LLC
+# Written by: John H. Baldwin <jhb@FreeBSD.org>
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in the
+# documentation and/or other materials provided with the distribution.
+#
+# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+# SUCH DAMAGE.
+#
+# $FreeBSD$
+
+# This is a tool to manage updating files that are not updated as part
+# of 'make installworld' such as files in /etc. Unlike other tools,
+# this one is specifically tailored to assisting with mass upgrades.
+# To that end it does not require user intervention while running.
+#
+# Theory of operation:
+#
+# The most reliable way to update changes to files that have local
+# modifications is to perform a three-way merge between the original
+# unmodified file, the new version of the file, and the modified file.
+# This requires having all three versions of the file available when
+# performing an update.
+#
+# To that end, etcupdate uses a strategy where the current unmodified
+# tree is kept in WORKDIR/current and the previous unmodified tree is
+# kept in WORKDIR/old. When performing a merge, a new tree is built
+# if needed and then the changes are merged into DESTDIR. Any files
+# with unresolved conflicts after the merge are left in a tree rooted
+# at WORKDIR/conflicts.
+#
+# To provide extra flexibility, etcupdate can also build tarballs of
+# root trees that can later be used. It can also use a tarball as the
+# source of a new tree instead of building it from /usr/src.
+
+# Global settings. These can be adjusted by config files and in some
+# cases by command line options.
+
+# TODO:
+# - automatable conflict resolution
+# - a 'revert' command to make a file "stock"
+
+usage()
+{
+ cat <<EOF
+usage: etcupdate [-nBF] [-d workdir] [-r | -s source | -t tarball] [-A patterns]
+ [-D destdir] [-I patterns] [-L logfile] [-M options]
+ etcupdate build [-B] [-d workdir] [-s source] [-L logfile] [-M options]
+ <tarball>
+ etcupdate diff [-d workdir] [-D destdir] [-I patterns] [-L logfile]
+ etcupdate extract [-B] [-d workdir] [-s source | -t tarball] [-L logfile]
+ [-M options]
+ etcupdate resolve [-d workdir] [-D destdir] [-L logfile]
+ etcupdate status [-d workdir] [-D destdir]
+EOF
+ exit 1
+}
+
+# Used to write a message prepended with '>>>' to the logfile.
+log()
+{
+ echo ">>>" "$@" >&3
+}
+
+# Used for assertion conditions that should never happen.
+panic()
+{
+ echo "PANIC:" "$@"
+ exit 10
+}
+
+# Used to write a warning message. These are saved to the WARNINGS
+# file with " " prepended.
+warn()
+{
+ echo -n " " >> $WARNINGS
+ echo "$@" >> $WARNINGS
+}
+
+# Output a horizontal rule using the passed-in character. Matches the
+# length used for Index lines in CVS and SVN diffs.
+#
+# $1 - character
+rule()
+{
+ jot -b "$1" -s "" 67
+}
+
+# Output a text description of a specified file's type.
+#
+# $1 - file pathname.
+file_type()
+{
+ stat -f "%HT" $1 | tr "[:upper:]" "[:lower:]"
+}
+
+# Returns true (0) if a file exists
+#
+# $1 - file pathname.
+exists()
+{
+ [ -e $1 -o -L $1 ]
+}
+
+# Returns true (0) if a file should be ignored, false otherwise.
+#
+# $1 - file pathname
+ignore()
+{
+ local pattern -
+
+ set -o noglob
+ for pattern in $IGNORE_FILES; do
+ set +o noglob
+ case $1 in
+ $pattern)
+ return 0
+ ;;
+ esac
+ set -o noglob
+ done
+
+ # Ignore /.cshrc and /.profile if they are hardlinked to the
+ # same file in /root. This ensures we only compare those
+ # files once in that case.
+ case $1 in
+ /.cshrc|/.profile)
+ if [ ${DESTDIR}$1 -ef ${DESTDIR}/root$1 ]; then
+ return 0
+ fi
+ ;;
+ *)
+ ;;
+ esac
+
+ return 1
+}
+
+# Returns true (0) if the new version of a file should always be
+# installed rather than attempting to do a merge.
+#
+# $1 - file pathname
+always_install()
+{
+ local pattern -
+
+ set -o noglob
+ for pattern in $ALWAYS_INSTALL; do
+ set +o noglob
+ case $1 in
+ $pattern)
+ return 0
+ ;;
+ esac
+ set -o noglob
+ done
+
+ return 1
+}
+
+# Build a new tree
+#
+# $1 - directory to store new tree in
+build_tree()
+{
+ local make
+
+ make="make $MAKE_OPTIONS"
+
+ log "Building tree at $1 with $make"
+ mkdir -p $1/usr/obj >&3 2>&1
+ (cd $SRCDIR; $make DESTDIR=$1 distrib-dirs) >&3 2>&1 || return 1
+
+ if ! [ -n "$nobuild" ]; then
+ (cd $SRCDIR; \
+ MAKEOBJDIRPREFIX=$1/usr/obj $make _obj SUBDIR_OVERRIDE=etc &&
+ MAKEOBJDIRPREFIX=$1/usr/obj $make everything SUBDIR_OVERRIDE=etc &&
+ MAKEOBJDIRPREFIX=$1/usr/obj $make DESTDIR=$1 distribution) \
+ >&3 2>&1 || return 1
+ else
+ (cd $SRCDIR; $make DESTDIR=$1 distribution) >&3 2>&1 || return 1
+ fi
+ chflags -R noschg $1 >&3 2>&1 || return 1
+ rm -rf $1/usr/obj >&3 2>&1 || return 1
+
+ # Purge auto-generated files. Only the source files need to
+ # be updated after which these files are regenerated.
+ rm -f $1/etc/*.db $1/etc/passwd >&3 2>&1 || return 1
+
+ # Remove empty files. These just clutter the output of 'diff'.
+ find $1 -type f -size 0 -delete >&3 2>&1 || return 1
+
+ # Trim empty directories.
+ find -d $1 -type d -empty -delete >&3 2>&1 || return 1
+ return 0
+}
+
+# Generate a new NEWTREE tree. If tarball is set, then the tree is
+# extracted from the tarball. Otherwise the tree is built from a
+# source tree.
+extract_tree()
+{
+ # If we have a tarball, extract that into the new directory.
+ if [ -n "$tarball" ]; then
+ if ! (mkdir -p $NEWTREE && tar xf $tarball -C $NEWTREE) \
+ >&3 2>&1; then
+ echo "Failed to extract new tree."
+ remove_tree $NEWTREE
+ exit 1
+ fi
+ else
+ if ! build_tree $NEWTREE; then
+ echo "Failed to build new tree."
+ remove_tree $NEWTREE
+ exit 1
+ fi
+ fi
+}
+
+# Forcefully remove a tree. Returns true (0) if the operation succeeds.
+#
+# $1 - path to tree
+remove_tree()
+{
+
+ rm -rf $1 >&3 2>&1
+ if [ -e $1 ]; then
+ chflags -R noschg $1 >&3 2>&1
+ rm -rf $1 >&3 2>&1
+ fi
+ [ ! -e $1 ]
+}
+
+# Return values for compare()
+COMPARE_EQUAL=0
+COMPARE_ONLYFIRST=1
+COMPARE_ONLYSECOND=2
+COMPARE_DIFFTYPE=3
+COMPARE_DIFFLINKS=4
+COMPARE_DIFFFILES=5
+
+# Compare two files/directories/symlinks. Note that this does not
+# recurse into subdirectories. Instead, if two nodes are both
+# directories, they are assumed to be equivalent.
+#
+# Returns true (0) if the nodes are identical. If only one of the two
+# nodes are present, return one of the COMPARE_ONLY* constants. If
+# the nodes are different, return one of the COMPARE_DIFF* constants
+# to indicate the type of difference.
+#
+# $1 - first node
+# $2 - second node
+compare()
+{
+ local first second
+
+ # If the first node doesn't exist, then check for the second
+ # node. Note that -e will fail for a symbolic link that
+ # points to a missing target.
+ if ! exists $1; then
+ if exists $2; then
+ return $COMPARE_ONLYSECOND
+ else
+ return $COMPARE_EQUAL
+ fi
+ elif ! exists $2; then
+ return $COMPARE_ONLYFIRST
+ fi
+
+ # If the two nodes are different file types fail.
+ first=`stat -f "%Hp" $1`
+ second=`stat -f "%Hp" $2`
+ if [ "$first" != "$second" ]; then
+ return $COMPARE_DIFFTYPE
+ fi
+
+ # If both are symlinks, compare the link values.
+ if [ -L $1 ]; then
+ first=`readlink $1`
+ second=`readlink $2`
+ if [ "$first" = "$second" ]; then
+ return $COMPARE_EQUAL
+ else
+ return $COMPARE_DIFFLINKS
+ fi
+ fi
+
+ # If both are files, compare the file contents.
+ if [ -f $1 ]; then
+ if cmp -s $1 $2; then
+ return $COMPARE_EQUAL
+ else
+ return $COMPARE_DIFFFILES
+ fi
+ fi
+
+ # As long as the two nodes are the same type of file, consider
+ # them equivalent.
+ return $COMPARE_EQUAL
+}
+
+# Returns true (0) if the only difference between two regular files is a
+# change in the FreeBSD ID string.
+#
+# $1 - path of first file
+# $2 - path of second file
+fbsdid_only()
+{
+
+ diff -qI '\$FreeBSD.*\$' $1 $2 >/dev/null 2>&1
+}
+
+# This is a wrapper around compare that will return COMPARE_EQUAL if
+# the only difference between two regular files is a change in the
+# FreeBSD ID string. It only makes this adjustment if the -F flag has
+# been specified.
+#
+# $1 - first node
+# $2 - second node
+compare_fbsdid()
+{
+ local cmp
+
+ compare $1 $2
+ cmp=$?
+
+ if [ -n "$FREEBSD_ID" -a "$cmp" -eq $COMPARE_DIFFFILES ] && \
+ fbsdid_only $1 $2; then
+ return $COMPARE_EQUAL
+ fi
+
+ return $cmp
+}
+
+# Returns true (0) if a directory is empty.
+#
+# $1 - pathname of the directory to check
+empty_dir()
+{
+ local contents
+
+ contents=`ls -A $1`
+ [ -z "$contents" ]
+}
+
+# Returns true (0) if one directories contents are a subset of the
+# other. This will recurse to handle subdirectories and compares
+# individual files in the trees. Its purpose is to quiet spurious
+# directory warnings for dryrun invocations.
+#
+# $1 - first directory (sub)
+# $2 - second directory (super)
+dir_subset()
+{
+ local contents file
+
+ if ! [ -d $1 -a -d $2 ]; then
+ return 1
+ fi
+
+ # Ignore files that are present in the second directory but not
+ # in the first.
+ contents=`ls -A $1`
+ for file in $contents; do
+ if ! compare $1/$file $2/$file; then
+ return 1
+ fi
+
+ if [ -d $1/$file ]; then
+ if ! dir_subset $1/$file $2/$file; then
+ return 1
+ fi
+ fi
+ done
+ return 0
+}
+
+# Returns true (0) if a directory in the destination tree is empty.
+# If this is a dryrun, then this returns true as long as the contents
+# of the directory are a subset of the contents in the old tree
+# (meaning that the directory would be empty in a non-dryrun when this
+# was invoked) to quiet spurious warnings.
+#
+# $1 - pathname of the directory to check relative to DESTDIR.
+empty_destdir()
+{
+
+ if [ -n "$dryrun" ]; then
+ dir_subset $DESTDIR/$1 $OLDTREE/$1
+ return
+ fi
+
+ empty_dir $DESTDIR/$1
+}
+
+# Output a diff of two directory entries with the same relative name
+# in different trees. Note that as with compare(), this does not
+# recurse into subdirectories. If the nodes are identical, nothing is
+# output.
+#
+# $1 - first tree
+# $2 - second tree
+# $3 - node name
+# $4 - label for first tree
+# $5 - label for second tree
+diffnode()
+{
+ local first second file old new diffargs
+
+ if [ -n "$FREEBSD_ID" ]; then
+ diffargs="-I \\\$FreeBSD.*\\\$"
+ else
+ diffargs=""
+ fi
+
+ compare_fbsdid $1/$3 $2/$3
+ case $? in
+ $COMPARE_EQUAL)
+ ;;
+ $COMPARE_ONLYFIRST)
+ echo
+ echo "Removed: $3"
+ echo
+ ;;
+ $COMPARE_ONLYSECOND)
+ echo
+ echo "Added: $3"
+ echo
+ ;;
+ $COMPARE_DIFFTYPE)
+ first=`file_type $1/$3`
+ second=`file_type $2/$3`
+ echo
+ echo "Node changed from a $first to a $second: $3"
+ echo
+ ;;
+ $COMPARE_DIFFLINKS)
+ first=`readlink $1/$file`
+ second=`readlink $2/$file`
+ echo
+ echo "Link changed: $file"
+ rule "="
+ echo "-$first"
+ echo "+$second"
+ echo
+ ;;
+ $COMPARE_DIFFFILES)
+ echo "Index: $3"
+ rule "="
+ diff -u $diffargs -L "$3 ($4)" $1/$3 -L "$3 ($5)" $2/$3
+ ;;
+ esac
+}
+
+# Create missing parent directories of a node in a target tree
+# preserving the owner, group, and permissions from a specified
+# template tree.
+#
+# $1 - template tree
+# $2 - target tree
+# $3 - pathname of the node (relative to both trees)
+install_dirs()
+{
+ local args dir
+
+ dir=`dirname $3`
+
+ # Nothing to do if the parent directory exists. This also
+ # catches the degenerate cases when the path is just a simple
+ # filename.
+ if [ -d ${2}$dir ]; then
+ return 0
+ fi
+
+ # If non-directory file exists with the desired directory
+ # name, then fail.
+ if exists ${2}$dir; then
+ # If this is a dryrun and we are installing the
+ # directory in the DESTDIR and the file in the DESTDIR
+ # matches the file in the old tree, then fake success
+ # to quiet spurious warnings.
+ if [ -n "$dryrun" -a "$2" = "$DESTDIR" ]; then
+ if compare $OLDTREE/$dir $DESTDIR/$dir; then
+ return 0
+ fi
+ fi
+
+ args=`file_type ${2}$dir`
+ warn "Directory mismatch: ${2}$dir ($args)"
+ return 1
+ fi
+
+ # Ensure the parent directory of the directory is present
+ # first.
+ if ! install_dirs $1 "$2" $dir; then
+ return 1
+ fi
+
+ # Format attributes from template directory as install(1)
+ # arguments.
+ args=`stat -f "-o %Su -g %Sg -m %0Mp%0Lp" $1/$dir`
+
+ log "install -d $args ${2}$dir"
+ if [ -z "$dryrun" ]; then
+ install -d $args ${2}$dir >&3 2>&1
+ fi
+ return 0
+}
+
+# Perform post-install fixups for a file. This largely consists of
+# regenerating any files that depend on the newly installed file.
+#
+# $1 - pathname of the updated file (relative to DESTDIR)
+post_install_file()
+{
+ case $1 in
+ /etc/mail/aliases)
+ # Grr, newaliases only works for an empty DESTDIR.
+ if [ -z "$DESTDIR" ]; then
+ log "newaliases"
+ if [ -z "$dryrun" ]; then
+ newaliases >&3 2>&1
+ fi
+ else
+ NEWALIAS_WARN=yes
+ fi
+ ;;
+ /etc/login.conf)
+ log "cap_mkdb ${DESTDIR}$1"
+ if [ -z "$dryrun" ]; then
+ cap_mkdb ${DESTDIR}$1 >&3 2>&1
+ fi
+ ;;
+ /etc/master.passwd)
+ log "pwd_mkdb -p -d $DESTDIR/etc ${DESTDIR}$1"
+ if [ -z "$dryrun" ]; then
+ pwd_mkdb -p -d $DESTDIR/etc ${DESTDIR}$1 \
+ >&3 2>&1
+ fi
+ ;;
+ /etc/motd)
+ # /etc/rc.d/motd hardcodes the /etc/motd path.
+ # Don't warn about non-empty DESTDIR's since this
+ # change is only cosmetic anyway.
+ if [ -z "$DESTDIR" ]; then
+ log "sh /etc/rc.d/motd start"
+ if [ -z "$dryrun" ]; then
+ sh /etc/rc.d/motd start >&3 2>&1
+ fi
+ fi
+ ;;
+ esac
+}
+
+# Install the "new" version of a file. Returns true if it succeeds
+# and false otherwise.
+#
+# $1 - pathname of the file to install (relative to DESTDIR)
+install_new()
+{
+
+ if ! install_dirs $NEWTREE "$DESTDIR" $1; then
+ return 1
+ fi
+ log "cp -Rp ${NEWTREE}$1 ${DESTDIR}$1"
+ if [ -z "$dryrun" ]; then
+ cp -Rp ${NEWTREE}$1 ${DESTDIR}$1 >&3 2>&1
+ fi
+ post_install_file $1
+ return 0
+}
+
+# Install the "resolved" version of a file. Returns true if it succeeds
+# and false otherwise.
+#
+# $1 - pathname of the file to install (relative to DESTDIR)
+install_resolved()
+{
+
+ # This should always be present since the file is already
+ # there (it caused a conflict). However, it doesn't hurt to
+ # just be safe.
+ if ! install_dirs $NEWTREE "$DESTDIR" $1; then
+ return 1
+ fi
+
+ log "cp -Rp ${CONFLICTS}$1 ${DESTDIR}$1"
+ cp -Rp ${CONFLICTS}$1 ${DESTDIR}$1 >&3 2>&1
+ post_install_file $1
+ return 0
+}
+
+# Generate a conflict file when a "new" file conflicts with an
+# existing file in DESTDIR.
+#
+# $1 - pathname of the file that conflicts (relative to DESTDIR)
+new_conflict()
+{
+
+ if [ -n "$dryrun" ]; then
+ return
+ fi
+
+ install_dirs $NEWTREE $CONFLICTS $1
+ diff --changed-group-format='<<<<<<< (local)
+%<=======
+%>>>>>>>> (stock)
+' $DESTDIR/$1 $NEWTREE/$1 > $CONFLICTS/$1
+}
+
+# Remove the "old" version of a file.
+#
+# $1 - pathname of the old file to remove (relative to DESTDIR)
+remove_old()
+{
+ log "rm -f ${DESTDIR}$1"
+ if [ -z "$dryrun" ]; then
+ rm -f ${DESTDIR}$1 >&3 2>&1
+ fi
+ echo " D $1"
+}
+
+# Update a file that has no local modifications.
+#
+# $1 - pathname of the file to update (relative to DESTDIR)
+update_unmodified()
+{
+ local new old
+
+ # If the old file is a directory, then remove it with rmdir
+ # (this should only happen if the file has changed its type
+ # from a directory to a non-directory). If the directory
+ # isn't empty, then fail. This will be reported as a warning
+ # later.
+ if [ -d $DESTDIR/$1 ]; then
+ if empty_destdir $1; then
+ log "rmdir ${DESTDIR}$1"
+ if [ -z "$dryrun" ]; then
+ rmdir ${DESTDIR}$1 >&3 2>&1
+ fi
+ else
+ return 1
+ fi
+
+ # If both the old and new files are regular files, leave the
+ # existing file. This avoids breaking hard links for /.cshrc
+ # and /.profile. Otherwise, explicitly remove the old file.
+ elif ! [ -f ${DESTDIR}$1 -a -f ${NEWTREE}$1 ]; then
+ log "rm -f ${DESTDIR}$1"
+ if [ -z "$dryrun" ]; then
+ rm -f ${DESTDIR}$1 >&3 2>&1
+ fi
+ fi
+
+ # If the new file is a directory, note that the old file has
+ # been removed, but don't do anything else for now. The
+ # directory will be installed if needed when new files within
+ # that directory are installed.
+ if [ -d $NEWTREE/$1 ]; then
+ if empty_dir $NEWTREE/$1; then
+ echo " D $file"
+ else
+ echo " U $file"
+ fi
+ elif install_new $1; then
+ echo " U $file"
+ fi
+ return 0
+}
+
+# Update the FreeBSD ID string in a locally modified file to match the
+# FreeBSD ID string from the "new" version of the file.
+#
+# $1 - pathname of the file to update (relative to DESTDIR)
+update_freebsdid()
+{
+ local new dest file
+
+ # If the FreeBSD ID string is removed from the local file,
+ # there is nothing to do. In this case, treat the file as
+ # updated. Otherwise, if either file has more than one
+ # FreeBSD ID string, just punt and let the user handle the
+ # conflict manually.
+ new=`grep -c '\$FreeBSD.*\$' ${NEWTREE}$1`
+ dest=`grep -c '\$FreeBSD.*\$' ${DESTDIR}$1`
+ if [ "$dest" -eq 0 ]; then
+ return 0
+ fi
+ if [ "$dest" -ne 1 -o "$dest" -ne 1 ]; then
+ return 1
+ fi
+
+ # If the FreeBSD ID string in the new file matches the FreeBSD ID
+ # string in the local file, there is nothing to do.
+ new=`grep '\$FreeBSD.*\$' ${NEWTREE}$1`
+ dest=`grep '\$FreeBSD.*\$' ${DESTDIR}$1`
+ if [ "$new" = "$dest" ]; then
+ return 0
+ fi
+
+ # Build the new file in three passes. First, copy all the
+ # lines preceding the FreeBSD ID string from the local version
+ # of the file. Second, append the FreeBSD ID string line from
+ # the new version. Finally, append all the lines after the
+ # FreeBSD ID string from the local version of the file.
+ file=`mktemp $WORKDIR/etcupdate-XXXXXXX`
+ awk '/\$FreeBSD.*\$/ { exit } { print }' ${DESTDIR}$1 >> $file
+ awk '/\$FreeBSD.*\$/ { print }' ${NEWTREE}$1 >> $file
+ awk '/\$FreeBSD.*\$/ { ok = 1; next } { if (ok) print }' \
+ ${DESTDIR}$1 >> $file
+
+ # As an extra sanity check, fail the attempt if the updated
+ # version of the file has any differences aside from the
+ # FreeBSD ID string.
+ if ! fbsdid_only ${DESTDIR}$1 $file; then
+ rm -f $file
+ return 1
+ fi
+
+ log "cp $file ${DESTDIR}$1"
+ if [ -z "$dryrun" ]; then
+ cp $file ${DESTDIR}$1 >&3 2>&1
+ fi
+ rm -f $file
+ post_install_file $1
+ echo " M $1"
+ return 0
+}
+
+# Attempt to update a file that has local modifications. This routine
+# only handles regular files. If the 3-way merge succeeds without
+# conflicts, the updated file is installed. If the merge fails, the
+# merged version with conflict markers is left in the CONFLICTS tree.
+#
+# $1 - pathname of the file to merge (relative to DESTDIR)
+merge_file()
+{
+ local res
+
+ # Try the merge to see if there is a conflict.
+ merge -q -p ${DESTDIR}$1 ${OLDTREE}$1 ${NEWTREE}$1 >/dev/null 2>&3
+ res=$?
+ case $res in
+ 0)
+ # No conflicts, so just redo the merge to the
+ # real file.
+ log "merge ${DESTDIR}$1 ${OLDTREE}$1 ${NEWTREE}$1"
+ if [ -z "$dryrun" ]; then
+ merge ${DESTDIR}$1 ${OLDTREE}$1 ${NEWTREE}$1
+ fi
+ post_install_file $1
+ echo " M $1"
+ ;;
+ 1)
+ # Conflicts, save a version with conflict markers in
+ # the conflicts directory.
+ if [ -z "$dryrun" ]; then
+ install_dirs $NEWTREE $CONFLICTS $1
+ log "cp -Rp ${DESTDIR}$1 ${CONFLICTS}$1"
+ cp -Rp ${DESTDIR}$1 ${CONFLICTS}$1 >&3 2>&1
+ merge -A -q -L "yours" -L "original" -L "new" \
+ ${CONFLICTS}$1 ${OLDTREE}$1 ${NEWTREE}$1
+ fi
+ echo " C $1"
+ ;;
+ *)
+ panic "merge failed with status $res"
+ ;;
+ esac
+}
+
+# Returns true if a file contains conflict markers from a merge conflict.
+#
+# $1 - pathname of the file to resolve (relative to DESTDIR)
+has_conflicts()
+{
+
+ egrep -q '^(<{7}|\|{7}|={7}|>{7}) ' $CONFLICTS/$1
+}
+
+# Attempt to resolve a conflict. The user is prompted to choose an
+# action for each conflict. If the user edits the file, they are
+# prompted again for an action. The process is very similar to
+# resolving conflicts after an update or merge with Perforce or
+# Subversion. The prompts are modelled on a subset of the available
+# commands for resolving conflicts with Subversion.
+#
+# $1 - pathname of the file to resolve (relative to DESTDIR)
+resolve_conflict()
+{
+ local command junk
+
+ echo "Resolving conflict in '$1':"
+ edit=
+ while true; do
+ # Only display the resolved command if the file
+ # doesn't contain any conflicts.
+ echo -n "Select: (p) postpone, (df) diff-full, (e) edit,"
+ if ! has_conflicts $1; then
+ echo -n " (r) resolved,"
+ fi
+ echo
+ echo -n " (h) help for more options: "
+ read command
+ case $command in
+ df)
+ diff -u ${DESTDIR}$1 ${CONFLICTS}$1
+ ;;
+ e)
+ $EDITOR ${CONFLICTS}$1
+ ;;
+ h)
+ cat <<EOF
+ (p) postpone - ignore this conflict for now
+ (df) diff-full - show all changes made to merged file
+ (e) edit - change merged file in an editor
+ (r) resolved - accept merged version of file
+ (mf) mine-full - accept local version of entire file (ignore new changes)
+ (tf) theirs-full - accept new version of entire file (lose local changes)
+ (h) help - show this list
+EOF
+ ;;
+ mf)
+ # For mine-full, just delete the
+ # merged file and leave the local
+ # version of the file as-is.
+ rm ${CONFLICTS}$1
+ return
+ ;;
+ p)
+ return
+ ;;
+ r)
+ # If the merged file has conflict
+ # markers, require confirmation.
+ if has_conflicts $1; then
+ echo "File '$1' still has conflicts," \
+ "are you sure? (y/n) "
+ read junk
+ if [ "$junk" != "y" ]; then
+ continue
+ fi
+ fi
+
+ if ! install_resolved $1; then
+ panic "Unable to install merged" \
+ "version of $1"
+ fi
+ rm ${CONFLICTS}$1
+ return
+ ;;
+ tf)
+ # For theirs-full, install the new
+ # version of the file over top of the
+ # existing file.
+ if ! install_new $1; then
+ panic "Unable to install new" \
+ "version of $1"
+ fi
+ rm ${CONFLICTS}$1
+ return
+ ;;
+ *)
+ echo "Invalid command."
+ ;;
+ esac
+ done
+}
+
+# Handle a file that has been removed from the new tree. If the file
+# does not exist in DESTDIR, then there is nothing to do. If the file
+# exists in DESTDIR and is identical to the old version, remove it
+# from DESTDIR. Otherwise, whine about the conflict but leave the
+# file in DESTDIR. To handle directories, this uses two passes. The
+# first pass handles all non-directory files. The second pass handles
+# just directories and removes them if they are empty.
+#
+# If -F is specified, and the only difference in the file in DESTDIR
+# is a change in the FreeBSD ID string, then remove the file.
+#
+# $1 - pathname of the file (relative to DESTDIR)
+handle_removed_file()
+{
+ local dest file
+
+ file=$1
+ if ignore $file; then
+ log "IGNORE: removed file $file"
+ return
+ fi
+
+ compare_fbsdid $DESTDIR/$file $OLDTREE/$file
+ case $? in
+ $COMPARE_EQUAL)
+ if ! [ -d $DESTDIR/$file ]; then
+ remove_old $file
+ fi
+ ;;
+ $COMPARE_ONLYFIRST)
+ panic "Removed file now missing"
+ ;;
+ $COMPARE_ONLYSECOND)
+ # Already removed, nothing to do.
+ ;;
+ $COMPARE_DIFFTYPE|$COMPARE_DIFFLINKS|$COMPARE_DIFFFILES)
+ dest=`file_type $DESTDIR/$file`
+ warn "Modified $dest remains: $file"
+ ;;
+ esac
+}
+
+# Handle a directory that has been removed from the new tree. Only
+# remove the directory if it is empty.
+#
+# $1 - pathname of the directory (relative to DESTDIR)
+handle_removed_directory()
+{
+ local dir
+
+ dir=$1
+ if ignore $dir; then
+ log "IGNORE: removed dir $dir"
+ return
+ fi
+
+ if [ -d $DESTDIR/$dir -a -d $OLDTREE/$dir ]; then
+ if empty_destdir $dir; then
+ log "rmdir ${DESTDIR}$dir"
+ if [ -z "$dryrun" ]; then
+ rmdir ${DESTDIR}$dir >/dev/null 2>&1
+ fi
+ echo " D $dir"
+ else
+ warn "Non-empty directory remains: $dir"
+ fi
+ fi
+}
+
+# Handle a file that exists in both the old and new trees. If the
+# file has not changed in the old and new trees, there is nothing to
+# do. If the file in the destination directory matches the new file,
+# there is nothing to do. If the file in the destination directory
+# matches the old file, then the new file should be installed.
+# Everything else becomes some sort of conflict with more detailed
+# handling.
+#
+# $1 - pathname of the file (relative to DESTDIR)
+handle_modified_file()
+{
+ local cmp dest file new newdestcmp old
+
+ file=$1
+ if ignore $file; then
+ log "IGNORE: modified file $file"
+ return
+ fi
+
+ compare $OLDTREE/$file $NEWTREE/$file
+ cmp=$?
+ if [ $cmp -eq $COMPARE_EQUAL ]; then
+ return
+ fi
+
+ if [ $cmp -eq $COMPARE_ONLYFIRST -o $cmp -eq $COMPARE_ONLYSECOND ]; then
+ panic "Changed file now missing"
+ fi
+
+ compare $NEWTREE/$file $DESTDIR/$file
+ newdestcmp=$?
+ if [ $newdestcmp -eq $COMPARE_EQUAL ]; then
+ return
+ fi
+
+ # If the only change in the new file versus the destination
+ # file is a change in the FreeBSD ID string and -F is
+ # specified, just install the new file.
+ if [ -n "$FREEBSD_ID" -a $newdestcmp -eq $COMPARE_DIFFFILES ] && \
+ fbsdid_only $NEWTREE/$file $DESTDIR/$file; then
+ if update_unmodified $file; then
+ return
+ else
+ panic "Updating FreeBSD ID string failed"
+ fi
+ fi
+
+ # If the local file is the same as the old file, install the
+ # new file. If -F is specified and the only local change is
+ # in the FreeBSD ID string, then install the new file as well.
+ if compare_fbsdid $OLDTREE/$file $DESTDIR/$file; then
+ if update_unmodified $file; then
+ return
+ fi
+ fi
+
+ # If the only change in the new file versus the old file is a
+ # change in the FreeBSD ID string and -F is specified, just
+ # update the FreeBSD ID string in the local file.
+ if [ -n "$FREEBSD_ID" -a $cmp -eq $COMPARE_DIFFFILES ] && \
+ fbsdid_only $OLDTREE/$file $NEWTREE/$file; then
+ if update_freebsdid $file; then
+ continue
+ fi
+ fi
+
+ # If the file was removed from the dest tree, just whine.
+ if [ $newdestcmp -eq $COMPARE_ONLYFIRST ]; then
+ # If the removed file matches an ALWAYS_INSTALL glob,
+ # then just install the new version of the file.
+ if always_install $file; then
+ log "ALWAYS: adding $file"
+ if ! [ -d $NEWTREE/$file ]; then
+ if install_new $file; then
+ echo " A $file"
+ fi
+ fi
+ return
+ fi
+
+ case $cmp in
+ $COMPARE_DIFFTYPE)
+ old=`file_type $OLDTREE/$file`
+ new=`file_type $NEWTREE/$file`
+ warn "Remove mismatch: $file ($old became $new)"
+ ;;
+ $COMPARE_DIFFLINKS)
+ old=`readlink $OLDTREE/$file`
+ new=`readlink $NEWTREE/$file`
+ warn \
+ "Removed link changed: $file (\"$old\" became \"$new\")"
+ ;;
+ $COMPARE_DIFFFILES)
+ warn "Removed file changed: $file"
+ ;;
+ esac
+ return
+ fi
+
+ # Treat the file as unmodified and force install of the new
+ # file if it matches an ALWAYS_INSTALL glob. If the update
+ # attempt fails, then fall through to the normal case so a
+ # warning is generated.
+ if always_install $file; then
+ log "ALWAYS: updating $file"
+ if update_unmodified $file; then
+ return
+ fi
+ fi
+
+ # If the file changed types between the old and new trees but
+ # the files in the new and dest tree are both of the same
+ # type, treat it like an added file just comparing the new and
+ # dest files.
+ if [ $cmp -eq $COMPARE_DIFFTYPE ]; then
+ case $newdestcmp in
+ $COMPARE_DIFFLINKS)
+ new=`readlink $NEWTREE/$file`
+ dest=`readlink $DESTDIR/$file`
+ warn \
+ "New link conflict: $file (\"$new\" vs \"$dest\")"
+ return
+ ;;
+ $COMPARE_DIFFFILES)
+ new_conflict $file
+ echo " C $file"
+ return
+ ;;
+ esac
+ else
+ # If the file has not changed types between the old
+ # and new trees, but it is a different type in
+ # DESTDIR, then just warn.
+ if [ $newdestcmp -eq $COMPARE_DIFFTYPE ]; then
+ new=`file_type $NEWTREE/$file`
+ dest=`file_type $DESTDIR/$file`
+ warn "Modified mismatch: $file ($new vs $dest)"
+ return
+ fi
+ fi
+
+ case $cmp in
+ $COMPARE_DIFFTYPE)
+ old=`file_type $OLDTREE/$file`
+ new=`file_type $NEWTREE/$file`
+ dest=`file_type $DESTDIR/$file`
+ warn "Modified $dest changed: $file ($old became $new)"
+ ;;
+ $COMPARE_DIFFLINKS)
+ old=`readlink $OLDTREE/$file`
+ new=`readlink $NEWTREE/$file`
+ warn \
+ "Modified link changed: $file (\"$old\" became \"$new\")"
+ ;;
+ $COMPARE_DIFFFILES)
+ merge_file $file
+ ;;
+ esac
+}
+
+# Handle a file that has been added in the new tree. If the file does
+# not exist in DESTDIR, simply copy the file into DESTDIR. If the
+# file exists in the DESTDIR and is identical to the new version, do
+# nothing. Otherwise, generate a diff of the two versions of the file
+# and mark it as a conflict.
+#
+# $1 - pathname of the file (relative to DESTDIR)
+handle_added_file()
+{
+ local cmp dest file new
+
+ file=$1
+ if ignore $file; then
+ log "IGNORE: added file $file"
+ return
+ fi
+
+ compare $DESTDIR/$file $NEWTREE/$file
+ cmp=$?
+ case $cmp in
+ $COMPARE_EQUAL)
+ return
+ ;;
+ $COMPARE_ONLYFIRST)
+ panic "Added file now missing"
+ ;;
+ $COMPARE_ONLYSECOND)
+ # Ignore new directories. They will be
+ # created as needed when non-directory nodes
+ # are installed.
+ if ! [ -d $NEWTREE/$file ]; then
+ if install_new $file; then
+ echo " A $file"
+ fi
+ fi
+ return
+ ;;
+ esac
+
+
+ # Treat the file as unmodified and force install of the new
+ # file if it matches an ALWAYS_INSTALL glob. If the update
+ # attempt fails, then fall through to the normal case so a
+ # warning is generated.
+ if always_install $file; then
+ log "ALWAYS: updating $file"
+ if update_unmodified $file; then
+ return
+ fi
+ fi
+
+ case $cmp in
+ $COMPARE_DIFFTYPE)
+ new=`file_type $NEWTREE/$file`
+ dest=`file_type $DESTDIR/$file`
+ warn "New file mismatch: $file ($new vs $dest)"
+ ;;
+ $COMPARE_DIFFLINKS)
+ new=`readlink $NEWTREE/$file`
+ dest=`readlink $DESTDIR/$file`
+ warn "New link conflict: $file (\"$new\" vs \"$dest\")"
+ ;;
+ $COMPARE_DIFFFILES)
+ # If the only change in the new file versus
+ # the destination file is a change in the
+ # FreeBSD ID string and -F is specified, just
+ # install the new file.
+ if [ -n "$FREEBSD_ID" ] && \
+ fbsdid_only $NEWTREE/$file $DESTDIR/$file; then
+ if update_unmodified $file; then
+ return
+ else
+ panic \
+ "Updating FreeBSD ID string failed"
+ fi
+ fi
+
+ new_conflict $file
+ echo " C $file"
+ ;;
+ esac
+}
+
+# Main routines for each command
+
+# Build a new tree and save it in a tarball.
+build_cmd()
+{
+ local dir
+
+ if [ $# -ne 1 ]; then
+ echo "Missing required tarball."
+ echo
+ usage
+ fi
+
+ log "build command: $1"
+
+ # Create a temporary directory to hold the tree
+ dir=`mktemp -d $WORKDIR/etcupdate-XXXXXXX`
+ if [ $? -ne 0 ]; then
+ echo "Unable to create temporary directory."
+ exit 1
+ fi
+ if ! build_tree $dir; then
+ echo "Failed to build tree."
+ remove_tree $dir
+ exit 1
+ fi
+ if ! tar cfj $1 -C $dir . >&3 2>&1; then
+ echo "Failed to create tarball."
+ remove_tree $dir
+ exit 1
+ fi
+ remove_tree $dir
+}
+
+# Output a diff comparing the tree at DESTDIR to the current
+# unmodified tree. Note that this diff does not include files that
+# are present in DESTDIR but not in the unmodified tree.
+diff_cmd()
+{
+ local file
+
+ if [ $# -ne 0 ]; then
+ usage
+ fi
+
+ # Requires an unmodified tree to diff against.
+ if ! [ -d $NEWTREE ]; then
+ echo "Reference tree to diff against unavailable."
+ exit 1
+ fi
+
+ # Unfortunately, diff alone does not quite provide the right
+ # level of options that we want, so improvise.
+ for file in `(cd $NEWTREE; find .) | sed -e 's/^\.//'`; do
+ if ignore $file; then
+ continue
+ fi
+
+ diffnode $NEWTREE "$DESTDIR" $file "stock" "local"
+ done
+}
+
+# Just extract a new tree into NEWTREE either by building a tree or
+# extracting a tarball. This can be used to bootstrap updates by
+# initializing the current "stock" tree to match the currently
+# installed system.
+#
+# Unlike 'update', this command does not rotate or preserve an
+# existing NEWTREE, it just replaces any existing tree.
+extract_cmd()
+{
+
+ if [ $# -ne 0 ]; then
+ usage
+ fi
+
+ log "extract command: tarball=$tarball"
+
+ if [ -d $NEWTREE ]; then
+ if ! remove_tree $NEWTREE; then
+ echo "Unable to remove current tree."
+ exit 1
+ fi
+ fi
+
+ extract_tree
+}
+
+# Resolve conflicts left from an earlier merge.
+resolve_cmd()
+{
+ local conflicts
+
+ if [ $# -ne 0 ]; then
+ usage
+ fi
+
+ if ! [ -d $CONFLICTS ]; then
+ return
+ fi
+
+ conflicts=`(cd $CONFLICTS; find . ! -type d) | sed -e 's/^\.//'`
+ for file in $conflicts; do
+ resolve_conflict $file
+ done
+
+ if [ -n "$NEWALIAS_WARN" ]; then
+ warn "Needs update: /etc/mail/aliases.db" \
+ "(requires manual update via newaliases(1))"
+ echo
+ echo "Warnings:"
+ echo " Needs update: /etc/mail/aliases.db" \
+ "(requires manual update via newaliases(1))"
+ fi
+}
+
+# Report a summary of the previous merge. Specifically, list any
+# remaining conflicts followed by any warnings from the previous
+# update.
+status_cmd()
+{
+
+ if [ $# -ne 0 ]; then
+ usage
+ fi
+
+ if [ -d $CONFLICTS ]; then
+ (cd $CONFLICTS; find . ! -type d) | sed -e 's/^\./ C /'
+ fi
+ if [ -s $WARNINGS ]; then
+ echo "Warnings:"
+ cat $WARNINGS
+ fi
+}
+
+# Perform an actual merge. The new tree can either already exist (if
+# rerunning a merge), be extracted from a tarball, or generated from a
+# source tree.
+update_cmd()
+{
+ local dir
+
+ if [ $# -ne 0 ]; then
+ usage
+ fi
+
+ log "update command: rerun=$rerun tarball=$tarball"
+
+ if [ `id -u` -ne 0 ]; then
+ echo "Must be root to update a tree."
+ exit 1
+ fi
+
+ # Enforce a sane umask
+ umask 022
+
+ # XXX: Should existing conflicts be ignored and removed during
+ # a rerun?
+
+ # Trim the conflicts tree. Whine if there is anything left.
+ if [ -e $CONFLICTS ]; then
+ find -d $CONFLICTS -type d -empty -delete >&3 2>&1
+ rmdir $CONFLICTS >&3 2>&1
+ fi
+ if [ -d $CONFLICTS ]; then
+ echo "Conflicts remain from previous update, aborting."
+ exit 1
+ fi
+
+ if [ -z "$rerun" ]; then
+ # For a dryrun that is not a rerun, do not rotate the existing
+ # stock tree. Instead, extract a tree to a temporary directory
+ # and use that for the comparison.
+ if [ -n "$dryrun" ]; then
+ dir=`mktemp -d $WORKDIR/etcupdate-XXXXXXX`
+ if [ $? -ne 0 ]; then
+ echo "Unable to create temporary directory."
+ exit 1
+ fi
+ OLDTREE=$NEWTREE
+ NEWTREE=$dir
+
+ # Rotate the existing stock tree to the old tree.
+ elif [ -d $NEWTREE ]; then
+ # First, delete the previous old tree if it exists.
+ if ! remove_tree $OLDTREE; then
+ echo "Unable to remove old tree."
+ exit 1
+ fi
+
+ # Move the current stock tree.
+ if ! mv $NEWTREE $OLDTREE >&3 2>&1; then
+ echo "Unable to rename current stock tree."
+ exit 1
+ fi
+ fi
+
+ if ! [ -d $OLDTREE ]; then
+ cat <<EOF
+No previous tree to compare against, a sane comparison is not possible.
+EOF
+ log "No previous tree to compare against."
+ if [ -n "$dir" ]; then
+ rmdir $dir
+ fi
+ exit 1
+ fi
+
+ # Populate the new tree.
+ extract_tree
+ fi
+
+ # Build lists of nodes in the old and new trees.
+ (cd $OLDTREE; find .) | sed -e 's/^\.//' | sort > $WORKDIR/old.files
+ (cd $NEWTREE; find .) | sed -e 's/^\.//' | sort > $WORKDIR/new.files
+
+ # Split the files up into three groups using comm.
+ comm -23 $WORKDIR/old.files $WORKDIR/new.files > $WORKDIR/removed.files
+ comm -13 $WORKDIR/old.files $WORKDIR/new.files > $WORKDIR/added.files
+ comm -12 $WORKDIR/old.files $WORKDIR/new.files > $WORKDIR/both.files
+
+ # Initialize conflicts and warnings handling.
+ rm -f $WARNINGS
+ mkdir -p $CONFLICTS
+
+ # The order for the following sections is important. In the
+ # odd case that a directory is converted into a file, the
+ # existing subfiles need to be removed if possible before the
+ # file is converted. Similarly, in the case that a file is
+ # converted into a directory, the file needs to be converted
+ # into a directory if possible before the new files are added.
+
+ # First, handle removed files.
+ for file in `cat $WORKDIR/removed.files`; do
+ handle_removed_file $file
+ done
+
+ # For the directory pass, reverse sort the list to effect a
+ # depth-first traversal. This is needed to ensure that if a
+ # directory with subdirectories is removed, the entire
+ # directory is removed if there are no local modifications.
+ for file in `sort -r $WORKDIR/removed.files`; do
+ handle_removed_directory $file
+ done
+
+ # Second, handle files that exist in both the old and new
+ # trees.
+ for file in `cat $WORKDIR/both.files`; do
+ handle_modified_file $file
+ done
+
+ # Finally, handle newly added files.
+ for file in `cat $WORKDIR/added.files`; do
+ handle_added_file $file
+ done
+
+ if [ -n "$NEWALIAS_WARN" ]; then
+ warn "Needs update: /etc/mail/aliases.db" \
+ "(requires manual update via newaliases(1))"
+ fi
+
+ if [ -s $WARNINGS ]; then
+ echo "Warnings:"
+ cat $WARNINGS
+ fi
+
+ if [ -n "$dir" ]; then
+ if [ -z "$dryrun" -o -n "$rerun" ]; then
+ panic "Should not have a temporary directory"
+ fi
+
+ remove_tree $dir
+ fi
+}
+
+# Determine which command we are executing. A command may be
+# specified as the first word. If one is not specified then 'update'
+# is assumed as the default command.
+command="update"
+if [ $# -gt 0 ]; then
+ case "$1" in
+ build|diff|extract|status|resolve)
+ command="$1"
+ shift
+ ;;
+ -*)
+ # If first arg is an option, assume the
+ # default command.
+ ;;
+ *)
+ usage
+ ;;
+ esac
+fi
+
+# Set default variable values.
+
+# The path to the source tree used to build trees.
+SRCDIR=/usr/src
+
+# The destination directory where the modified files live.
+DESTDIR=
+
+# Ignore changes in the FreeBSD ID string.
+FREEBSD_ID=
+
+# Files that should always have the new version of the file installed.
+ALWAYS_INSTALL=
+
+# Files to ignore and never update during a merge.
+IGNORE_FILES=
+
+# Flags to pass to 'make' when building a tree.
+MAKE_OPTIONS=
+
+# Include a config file if it exists. Note that command line options
+# override any settings in the config file. More details are in the
+# manual, but in general the following variables can be set:
+# - ALWAYS_INSTALL
+# - DESTDIR
+# - EDITOR
+# - FREEBSD_ID
+# - IGNORE_FILES
+# - LOGFILE
+# - MAKE_OPTIONS
+# - SRCDIR
+# - WORKDIR
+if [ -r /etc/etcupdate.conf ]; then
+ . /etc/etcupdate.conf
+fi
+
+# Parse command line options
+tarball=
+rerun=
+always=
+dryrun=
+ignore=
+nobuild=
+while getopts "d:nrs:t:A:BD:FI:L:M:" option; do
+ case "$option" in
+ d)
+ WORKDIR=$OPTARG
+ ;;
+ n)
+ dryrun=YES
+ ;;
+ r)
+ rerun=YES
+ ;;
+ s)
+ SRCDIR=$OPTARG
+ ;;
+ t)
+ tarball=$OPTARG
+ ;;
+ A)
+ # To allow this option to be specified
+ # multiple times, accumulate command-line
+ # specified patterns in an 'always' variable
+ # and use that to overwrite ALWAYS_INSTALL
+ # after parsing all options. Need to be
+ # careful here with globbing expansion.
+ set -o noglob
+ always="$always $OPTARG"
+ set +o noglob
+ ;;
+ B)
+ nobuild=YES
+ ;;
+ D)
+ DESTDIR=$OPTARG
+ ;;
+ F)
+ FREEBSD_ID=YES
+ ;;
+ I)
+ # To allow this option to be specified
+ # multiple times, accumulate command-line
+ # specified patterns in an 'ignore' variable
+ # and use that to overwrite IGNORE_FILES after
+ # parsing all options. Need to be careful
+ # here with globbing expansion.
+ set -o noglob
+ ignore="$ignore $OPTARG"
+ set +o noglob
+ ;;
+ L)
+ LOGFILE=$OPTARG
+ ;;
+ M)
+ MAKE_OPTIONS="$OPTARG"
+ ;;
+ *)
+ echo
+ usage
+ ;;
+ esac
+done
+shift $((OPTIND - 1))
+
+# Allow -A command line options to override ALWAYS_INSTALL set from
+# the config file.
+set -o noglob
+if [ -n "$always" ]; then
+ ALWAYS_INSTALL="$always"
+fi
+
+# Allow -I command line options to override IGNORE_FILES set from the
+# config file.
+if [ -n "$ignore" ]; then
+ IGNORE_FILES="$ignore"
+fi
+set +o noglob
+
+# Where the "old" and "new" trees are stored.
+WORKDIR=${WORKDIR:-$DESTDIR/var/db/etcupdate}
+
+# Log file for verbose output from program that are run. The log file
+# is opened on fd '3'.
+LOGFILE=${LOGFILE:-$WORKDIR/log}
+
+# The path of the "old" tree
+OLDTREE=$WORKDIR/old
+
+# The path of the "new" tree
+NEWTREE=$WORKDIR/current
+
+# The path of the "conflicts" tree where files with merge conflicts are saved.
+CONFLICTS=$WORKDIR/conflicts
+
+# The path of the "warnings" file that accumulates warning notes from an update.
+WARNINGS=$WORKDIR/warnings
+
+# Use $EDITOR for resolving conflicts. If it is not set, default to vi.
+EDITOR=${EDITOR:-/usr/bin/vi}
+
+# Handle command-specific argument processing such as complaining
+# about unsupported options. Since the configuration file is always
+# included, do not complain about extra command line arguments that
+# may have been set via the config file rather than the command line.
+case $command in
+ update)
+ if [ -n "$rerun" -a -n "$tarball" ]; then
+ echo "Only one of -r or -t can be specified."
+ echo
+ usage
+ fi
+ ;;
+ build|diff|resolve|status)
+ if [ -n "$dryrun" -o -n "$rerun" -o -n "$tarball" ]; then
+ usage
+ fi
+ ;;
+ extract)
+ if [ -n "$dryrun" -o -n "$rerun" ]; then
+ usage
+ fi
+ ;;
+esac
+
+# Open the log file. Don't truncate it if doing a minor operation so
+# that a minor operation doesn't lose log info from a major operation.
+if ! mkdir -p $WORKDIR 2>/dev/null; then
+ echo "Failed to create work directory $WORKDIR"
+fi
+
+case $command in
+ diff|resolve|status)
+ exec 3>>$LOGFILE
+ ;;
+ *)
+ exec 3>$LOGFILE
+ ;;
+esac
+
+${command}_cmd "$@"
diff --git a/usr.sbin/extattr/Makefile.depend b/usr.sbin/extattr/Makefile.depend
new file mode 100644
index 0000000..2dd29af
--- /dev/null
+++ b/usr.sbin/extattr/Makefile.depend
@@ -0,0 +1,20 @@
+# Autogenerated - do NOT edit!
+
+DEP_RELDIR := ${_PARSEDIR:S,${SRCTOP}/,,}
+
+DEP_MACHINE := ${.PARSEFILE:E}
+
+DIRDEPS = \
+ gnu/lib/libgcc \
+ include \
+ include/xlocale \
+ lib/${CSU_DIR} \
+ lib/libc \
+ lib/libutil \
+
+
+.include <dirdeps.mk>
+
+.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+# local dependencies - needed for -jN in clean tree
+.endif
diff --git a/usr.sbin/extattrctl/Makefile.depend b/usr.sbin/extattrctl/Makefile.depend
new file mode 100644
index 0000000..2dd29af
--- /dev/null
+++ b/usr.sbin/extattrctl/Makefile.depend
@@ -0,0 +1,20 @@
+# Autogenerated - do NOT edit!
+
+DEP_RELDIR := ${_PARSEDIR:S,${SRCTOP}/,,}
+
+DEP_MACHINE := ${.PARSEFILE:E}
+
+DIRDEPS = \
+ gnu/lib/libgcc \
+ include \
+ include/xlocale \
+ lib/${CSU_DIR} \
+ lib/libc \
+ lib/libutil \
+
+
+.include <dirdeps.mk>
+
+.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+# local dependencies - needed for -jN in clean tree
+.endif
diff --git a/usr.sbin/faithd/Makefile.depend b/usr.sbin/faithd/Makefile.depend
new file mode 100644
index 0000000..c262920
--- /dev/null
+++ b/usr.sbin/faithd/Makefile.depend
@@ -0,0 +1,21 @@
+# Autogenerated - do NOT edit!
+
+DEP_RELDIR := ${_PARSEDIR:S,${SRCTOP}/,,}
+
+DEP_MACHINE := ${.PARSEFILE:E}
+
+DIRDEPS = \
+ gnu/lib/libgcc \
+ include \
+ include/arpa \
+ include/xlocale \
+ lib/${CSU_DIR} \
+ lib/libc \
+ lib/libutil \
+
+
+.include <dirdeps.mk>
+
+.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+# local dependencies - needed for -jN in clean tree
+.endif
diff --git a/usr.sbin/fdcontrol/Makefile.depend b/usr.sbin/fdcontrol/Makefile.depend
new file mode 100644
index 0000000..a839545
--- /dev/null
+++ b/usr.sbin/fdcontrol/Makefile.depend
@@ -0,0 +1,19 @@
+# Autogenerated - do NOT edit!
+
+DEP_RELDIR := ${_PARSEDIR:S,${SRCTOP}/,,}
+
+DEP_MACHINE := ${.PARSEFILE:E}
+
+DIRDEPS = \
+ gnu/lib/libgcc \
+ include \
+ include/xlocale \
+ lib/${CSU_DIR} \
+ lib/libc \
+
+
+.include <dirdeps.mk>
+
+.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+# local dependencies - needed for -jN in clean tree
+.endif
diff --git a/usr.sbin/fdformat/Makefile.depend b/usr.sbin/fdformat/Makefile.depend
new file mode 100644
index 0000000..a839545
--- /dev/null
+++ b/usr.sbin/fdformat/Makefile.depend
@@ -0,0 +1,19 @@
+# Autogenerated - do NOT edit!
+
+DEP_RELDIR := ${_PARSEDIR:S,${SRCTOP}/,,}
+
+DEP_MACHINE := ${.PARSEFILE:E}
+
+DIRDEPS = \
+ gnu/lib/libgcc \
+ include \
+ include/xlocale \
+ lib/${CSU_DIR} \
+ lib/libc \
+
+
+.include <dirdeps.mk>
+
+.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+# local dependencies - needed for -jN in clean tree
+.endif
diff --git a/usr.sbin/fdread/Makefile.depend b/usr.sbin/fdread/Makefile.depend
new file mode 100644
index 0000000..a839545
--- /dev/null
+++ b/usr.sbin/fdread/Makefile.depend
@@ -0,0 +1,19 @@
+# Autogenerated - do NOT edit!
+
+DEP_RELDIR := ${_PARSEDIR:S,${SRCTOP}/,,}
+
+DEP_MACHINE := ${.PARSEFILE:E}
+
+DIRDEPS = \
+ gnu/lib/libgcc \
+ include \
+ include/xlocale \
+ lib/${CSU_DIR} \
+ lib/libc \
+
+
+.include <dirdeps.mk>
+
+.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+# local dependencies - needed for -jN in clean tree
+.endif
diff --git a/usr.sbin/fdwrite/Makefile.depend b/usr.sbin/fdwrite/Makefile.depend
new file mode 100644
index 0000000..a839545
--- /dev/null
+++ b/usr.sbin/fdwrite/Makefile.depend
@@ -0,0 +1,19 @@
+# Autogenerated - do NOT edit!
+
+DEP_RELDIR := ${_PARSEDIR:S,${SRCTOP}/,,}
+
+DEP_MACHINE := ${.PARSEFILE:E}
+
+DIRDEPS = \
+ gnu/lib/libgcc \
+ include \
+ include/xlocale \
+ lib/${CSU_DIR} \
+ lib/libc \
+
+
+.include <dirdeps.mk>
+
+.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+# local dependencies - needed for -jN in clean tree
+.endif
diff --git a/usr.sbin/fifolog/fifolog_create/Makefile.depend b/usr.sbin/fifolog/fifolog_create/Makefile.depend
new file mode 100644
index 0000000..46df9bb
--- /dev/null
+++ b/usr.sbin/fifolog/fifolog_create/Makefile.depend
@@ -0,0 +1,20 @@
+# Autogenerated - do NOT edit!
+
+DEP_RELDIR := ${_PARSEDIR:S,${SRCTOP}/,,}
+
+DEP_MACHINE := ${.PARSEFILE:E}
+
+DIRDEPS = \
+ gnu/lib/libgcc \
+ include \
+ lib/${CSU_DIR} \
+ lib/libc \
+ lib/libutil \
+ usr.sbin/fifolog/lib \
+
+
+.include <dirdeps.mk>
+
+.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+# local dependencies - needed for -jN in clean tree
+.endif
diff --git a/usr.sbin/fifolog/fifolog_create/fifolog.1 b/usr.sbin/fifolog/fifolog_create/fifolog.1
index d0be0ce..69e8fbe 100644
--- a/usr.sbin/fifolog/fifolog_create/fifolog.1
+++ b/usr.sbin/fifolog/fifolog_create/fifolog.1
@@ -203,7 +203,7 @@ One particular useful use of
is with
.Xr syslogd 8
using a line such as this in
-.Xr /etc/syslog.conf 5 :
+.Xr syslog.conf 5 :
.Pp
.Dl "*.* |fifolog_writer /var/log/syslog_fifolog"
.Sh HISTORY
diff --git a/usr.sbin/fifolog/fifolog_reader/Makefile.depend b/usr.sbin/fifolog/fifolog_reader/Makefile.depend
new file mode 100644
index 0000000..5b0d32e
--- /dev/null
+++ b/usr.sbin/fifolog/fifolog_reader/Makefile.depend
@@ -0,0 +1,22 @@
+# Autogenerated - do NOT edit!
+
+DEP_RELDIR := ${_PARSEDIR:S,${SRCTOP}/,,}
+
+DEP_MACHINE := ${.PARSEFILE:E}
+
+DIRDEPS = \
+ gnu/lib/libgcc \
+ include \
+ include/xlocale \
+ lib/${CSU_DIR} \
+ lib/libc \
+ lib/libutil \
+ lib/libz \
+ usr.sbin/fifolog/lib \
+
+
+.include <dirdeps.mk>
+
+.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+# local dependencies - needed for -jN in clean tree
+.endif
diff --git a/usr.sbin/fifolog/fifolog_writer/Makefile.depend b/usr.sbin/fifolog/fifolog_writer/Makefile.depend
new file mode 100644
index 0000000..5b0d32e
--- /dev/null
+++ b/usr.sbin/fifolog/fifolog_writer/Makefile.depend
@@ -0,0 +1,22 @@
+# Autogenerated - do NOT edit!
+
+DEP_RELDIR := ${_PARSEDIR:S,${SRCTOP}/,,}
+
+DEP_MACHINE := ${.PARSEFILE:E}
+
+DIRDEPS = \
+ gnu/lib/libgcc \
+ include \
+ include/xlocale \
+ lib/${CSU_DIR} \
+ lib/libc \
+ lib/libutil \
+ lib/libz \
+ usr.sbin/fifolog/lib \
+
+
+.include <dirdeps.mk>
+
+.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+# local dependencies - needed for -jN in clean tree
+.endif
diff --git a/usr.sbin/fifolog/lib/Makefile.depend b/usr.sbin/fifolog/lib/Makefile.depend
new file mode 100644
index 0000000..e28547c
--- /dev/null
+++ b/usr.sbin/fifolog/lib/Makefile.depend
@@ -0,0 +1,19 @@
+# Autogenerated - do NOT edit!
+
+DEP_RELDIR := ${_PARSEDIR:S,${SRCTOP}/,,}
+
+DEP_MACHINE := ${.PARSEFILE:E}
+
+DIRDEPS = \
+ include \
+ include/xlocale \
+ lib/libz \
+
+
+.include <dirdeps.mk>
+
+.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+# local dependencies - needed for -jN in clean tree
+getdate.o: getdate.c
+getdate.po: getdate.c
+.endif
diff --git a/usr.sbin/flowctl/Makefile.depend b/usr.sbin/flowctl/Makefile.depend
new file mode 100644
index 0000000..1835644
--- /dev/null
+++ b/usr.sbin/flowctl/Makefile.depend
@@ -0,0 +1,21 @@
+# Autogenerated - do NOT edit!
+
+DEP_RELDIR := ${_PARSEDIR:S,${SRCTOP}/,,}
+
+DEP_MACHINE := ${.PARSEFILE:E}
+
+DIRDEPS = \
+ gnu/lib/libgcc \
+ include \
+ include/arpa \
+ include/xlocale \
+ lib/${CSU_DIR} \
+ lib/libc \
+ lib/libnetgraph \
+
+
+.include <dirdeps.mk>
+
+.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+# local dependencies - needed for -jN in clean tree
+.endif
diff --git a/usr.sbin/flowctl/flowctl.8 b/usr.sbin/flowctl/flowctl.8
index cbb97d4..5780e10 100644
--- a/usr.sbin/flowctl/flowctl.8
+++ b/usr.sbin/flowctl/flowctl.8
@@ -24,7 +24,7 @@
.\"
.\" $FreeBSD$
.\"
-.Dd July 5, 2011
+.Dd June 8, 2012
.Dt FLOWCTL 8
.Os
.Sh NAME
@@ -55,7 +55,7 @@ Currently,
.Nm
supports only one command.
.Bl -tag -width ".Cm show"
-.It Cm show Op Cm ipv4|ipv6
+.It Cm show Oo Cm ipv4|ipv6 Oc Op Cm human|verbose
This command is the analog of the
.Dq "show ip cache flow"
command of a Cisco router.
@@ -69,7 +69,9 @@ It has optional parameter
.Cm verbose ,
which is analog of the
.Dq "show ip cache verbose flow"
-command.
+command. Additionally,
+.Cm human
+parameter can be specify to show selected flows in human-readable format.
.El
.Sh EXIT STATUS
.Ex -std
diff --git a/usr.sbin/flowctl/flowctl.c b/usr.sbin/flowctl/flowctl.c
index 4bf86f0..47ddadf 100644
--- a/usr.sbin/flowctl/flowctl.c
+++ b/usr.sbin/flowctl/flowctl.c
@@ -52,19 +52,33 @@ static const char rcs_id[] =
#include <netgraph.h>
#include <netgraph/netflow/ng_netflow.h>
-#define CISCO_SH_FLOW_HEADER "SrcIf SrcIPaddress DstIf DstIPaddress Pr SrcP DstP Pkts\n"
+#define CISCO_SH_FLOW_HEADER "SrcIf SrcIPaddress " \
+"DstIf DstIPaddress Pr SrcP DstP Pkts\n"
#define CISCO_SH_FLOW "%-13s %-15s %-13s %-15s %2u %4.4x %4.4x %6lu\n"
-#define CISCO_SH_FLOW6_HEADER "SrcIf SrcIPaddress DstIf DstIPaddress Pr SrcP DstP Pkts\n"
-#define CISCO_SH_FLOW6 "%-13s %-30s %-13s %-30s %2u %4.4x %4.4x %6lu\n"
+/* human-readable IPv4 header */
+#define CISCO_SH_FLOW_HHEADER "SrcIf SrcIPaddress " \
+"DstIf DstIPaddress Proto SrcPort DstPort Pkts\n"
+#define CISCO_SH_FLOW_H "%-13s %-15s %-13s %-15s %5u %8d %8d %8lu\n"
-#define CISCO_SH_VERB_FLOW_HEADER "SrcIf SrcIPaddress DstIf DstIPaddress Pr TOS Flgs Pkts\n" \
+#define CISCO_SH_FLOW6_HEADER "SrcIf SrcIPaddress " \
+"DstIf DstIPaddress Pr SrcP DstP Pkts\n"
+#define CISCO_SH_FLOW6 "%-13s %-30s %-13s %-30s %2u %4.4x %4.4x %6lu\n"
+
+/* Human-readable IPv6 headers */
+#define CISCO_SH_FLOW6_HHEADER "SrcIf SrcIPaddress " \
+"DstIf DstIPaddress Proto SrcPort DstPort Pkts\n"
+#define CISCO_SH_FLOW6_H "%-13s %-36s %-13s %-36s %5u %8d %8d %8lu\n"
+
+#define CISCO_SH_VERB_FLOW_HEADER "SrcIf SrcIPaddress " \
+"DstIf DstIPaddress Pr TOS Flgs Pkts\n" \
"Port Msk AS Port Msk AS NextHop B/Pk Active\n"
#define CISCO_SH_VERB_FLOW "%-14s %-15s %-14s %-15s %2u %3x %4x %6lu\n" \
"%4.4x /%-2u %-5u %4.4x /%-2u %-5u %-15s %9u %8u\n\n"
-#define CISCO_SH_VERB_FLOW6_HEADER "SrcIf SrcIPaddress DstIf DstIPaddress Pr TOS Flgs Pkts\n" \
+#define CISCO_SH_VERB_FLOW6_HEADER "SrcIf SrcIPaddress " \
+"DstIf DstIPaddress Pr TOS Flgs Pkts\n" \
"Port Msk AS Port Msk AS NextHop B/Pk Active\n"
#define CISCO_SH_VERB_FLOW6 "%-14s %-30s %-14s %-30s %2u %3x %4x %6lu\n" \
@@ -94,7 +108,7 @@ struct ip_ctl_cmd cmds[] = {
{NULL, NULL},
};
-int cs;
+int cs, human = 0;
char *ng_path;
int
@@ -182,6 +196,9 @@ ctl_show(int argc, char **argv)
if (argc > 0 && !strncmp(argv[0], "verbose", strlen(argv[0])))
verbose = 1;
+ if (argc > 0 && !strncmp(argv[0], "human", strlen(argv[0])))
+ human = 1;
+
#ifdef INET
if (ipv4) {
if (verbose)
@@ -259,13 +276,14 @@ flow_cache_print(struct ngnf_show_header *resp)
errx(EX_SOFTWARE, "%s: version mismatch: %u",
__func__, resp->version);
- printf(CISCO_SH_FLOW_HEADER);
+ if (resp->nentries > 0)
+ printf(human ? CISCO_SH_FLOW_HHEADER : CISCO_SH_FLOW_HEADER);
fle = (struct flow_entry_data *)(resp + 1);
for (i = 0; i < resp->nentries; i++, fle++) {
inet_ntop(AF_INET, &fle->r.r_src, src, sizeof(src));
inet_ntop(AF_INET, &fle->r.r_dst, dst, sizeof(dst));
- printf(CISCO_SH_FLOW,
+ printf(human ? CISCO_SH_FLOW_H : CISCO_SH_FLOW,
if_indextoname(fle->fle_i_ifx, src_if),
src,
if_indextoname(fle->fle_o_ifx, dst_if),
@@ -292,13 +310,14 @@ flow_cache_print6(struct ngnf_show_header *resp)
errx(EX_SOFTWARE, "%s: version mismatch: %u",
__func__, resp->version);
- printf(CISCO_SH_FLOW6_HEADER);
+ if (resp->nentries > 0)
+ printf(human ? CISCO_SH_FLOW6_HHEADER : CISCO_SH_FLOW6_HEADER);
fle6 = (struct flow6_entry_data *)(resp + 1);
for (i = 0; i < resp->nentries; i++, fle6++) {
inet_ntop(AF_INET6, &fle6->r.src.r_src6, src6, sizeof(src6));
inet_ntop(AF_INET6, &fle6->r.dst.r_dst6, dst6, sizeof(dst6));
- printf(CISCO_SH_FLOW6,
+ printf(human ? CISCO_SH_FLOW6_H : CISCO_SH_FLOW6,
if_indextoname(fle6->fle_i_ifx, src_if),
src6,
if_indextoname(fle6->fle_o_ifx, dst_if),
diff --git a/usr.sbin/freebsd-update/Makefile.depend b/usr.sbin/freebsd-update/Makefile.depend
new file mode 100644
index 0000000..29fda55
--- /dev/null
+++ b/usr.sbin/freebsd-update/Makefile.depend
@@ -0,0 +1,14 @@
+# Autogenerated - do NOT edit!
+
+DEP_RELDIR := ${_PARSEDIR:S,${SRCTOP}/,,}
+
+DEP_MACHINE := ${.PARSEFILE:E}
+
+DIRDEPS = \
+
+
+.include <dirdeps.mk>
+
+.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+# local dependencies - needed for -jN in clean tree
+.endif
diff --git a/usr.sbin/ftp-proxy/ftp-proxy/Makefile b/usr.sbin/ftp-proxy/ftp-proxy/Makefile
index c21a107..de49888 100644
--- a/usr.sbin/ftp-proxy/ftp-proxy/Makefile
+++ b/usr.sbin/ftp-proxy/ftp-proxy/Makefile
@@ -8,7 +8,6 @@ MAN= ftp-proxy.8
SRCS= ftp-proxy.c filter.c
CFLAGS+= -I${.CURDIR}/../../../contrib/pf/libevent
-CFLAGS+= -I${.CURDIR}/../../../sys/contrib/pf
LDADD+= ${LIBEVENT}
DPADD+= ${LIBEVENT}
diff --git a/usr.sbin/ftp-proxy/ftp-proxy/Makefile.depend b/usr.sbin/ftp-proxy/ftp-proxy/Makefile.depend
new file mode 100644
index 0000000..dd343ad
--- /dev/null
+++ b/usr.sbin/ftp-proxy/ftp-proxy/Makefile.depend
@@ -0,0 +1,21 @@
+# Autogenerated - do NOT edit!
+
+DEP_RELDIR := ${_PARSEDIR:S,${SRCTOP}/,,}
+
+DEP_MACHINE := ${.PARSEFILE:E}
+
+DIRDEPS = \
+ gnu/lib/libgcc \
+ include \
+ include/arpa \
+ include/xlocale \
+ lib/${CSU_DIR} \
+ lib/libc \
+ usr.sbin/ftp-proxy/libevent \
+
+
+.include <dirdeps.mk>
+
+.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+# local dependencies - needed for -jN in clean tree
+.endif
diff --git a/usr.sbin/ftp-proxy/libevent/Makefile.depend b/usr.sbin/ftp-proxy/libevent/Makefile.depend
new file mode 100644
index 0000000..e248139
--- /dev/null
+++ b/usr.sbin/ftp-proxy/libevent/Makefile.depend
@@ -0,0 +1,16 @@
+# Autogenerated - do NOT edit!
+
+DEP_RELDIR := ${_PARSEDIR:S,${SRCTOP}/,,}
+
+DEP_MACHINE := ${.PARSEFILE:E}
+
+DIRDEPS = \
+ include \
+ include/xlocale \
+
+
+.include <dirdeps.mk>
+
+.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+# local dependencies - needed for -jN in clean tree
+.endif
diff --git a/usr.sbin/fwcontrol/Makefile.depend b/usr.sbin/fwcontrol/Makefile.depend
new file mode 100644
index 0000000..16b5e42
--- /dev/null
+++ b/usr.sbin/fwcontrol/Makefile.depend
@@ -0,0 +1,20 @@
+# Autogenerated - do NOT edit!
+
+DEP_RELDIR := ${_PARSEDIR:S,${SRCTOP}/,,}
+
+DEP_MACHINE := ${.PARSEFILE:E}
+
+DIRDEPS = \
+ gnu/lib/libgcc \
+ include \
+ include/arpa \
+ include/xlocale \
+ lib/${CSU_DIR} \
+ lib/libc \
+
+
+.include <dirdeps.mk>
+
+.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+# local dependencies - needed for -jN in clean tree
+.endif
diff --git a/usr.sbin/genrandom/Makefile.depend b/usr.sbin/genrandom/Makefile.depend
new file mode 100644
index 0000000..418e041
--- /dev/null
+++ b/usr.sbin/genrandom/Makefile.depend
@@ -0,0 +1,27 @@
+# Autogenerated - do NOT edit!
+
+DEP_RELDIR := ${_PARSEDIR:S,${SRCTOP}/,,}
+
+DEP_MACHINE := ${.PARSEFILE:E}
+
+DIRDEPS = \
+ gnu/lib/libgcc \
+ include \
+ include/xlocale \
+ lib/${CSU_DIR} \
+ lib/bind/bind9 \
+ lib/bind/dns \
+ lib/bind/isc \
+ lib/bind/isccc \
+ lib/bind/isccfg \
+ lib/bind/lwres \
+ lib/libc \
+ lib/libthr \
+ secure/lib/libcrypto \
+
+
+.include <dirdeps.mk>
+
+.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+# local dependencies - needed for -jN in clean tree
+.endif
diff --git a/usr.sbin/getfmac/Makefile.depend b/usr.sbin/getfmac/Makefile.depend
new file mode 100644
index 0000000..a839545
--- /dev/null
+++ b/usr.sbin/getfmac/Makefile.depend
@@ -0,0 +1,19 @@
+# Autogenerated - do NOT edit!
+
+DEP_RELDIR := ${_PARSEDIR:S,${SRCTOP}/,,}
+
+DEP_MACHINE := ${.PARSEFILE:E}
+
+DIRDEPS = \
+ gnu/lib/libgcc \
+ include \
+ include/xlocale \
+ lib/${CSU_DIR} \
+ lib/libc \
+
+
+.include <dirdeps.mk>
+
+.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+# local dependencies - needed for -jN in clean tree
+.endif
diff --git a/usr.sbin/getpmac/Makefile.depend b/usr.sbin/getpmac/Makefile.depend
new file mode 100644
index 0000000..a839545
--- /dev/null
+++ b/usr.sbin/getpmac/Makefile.depend
@@ -0,0 +1,19 @@
+# Autogenerated - do NOT edit!
+
+DEP_RELDIR := ${_PARSEDIR:S,${SRCTOP}/,,}
+
+DEP_MACHINE := ${.PARSEFILE:E}
+
+DIRDEPS = \
+ gnu/lib/libgcc \
+ include \
+ include/xlocale \
+ lib/${CSU_DIR} \
+ lib/libc \
+
+
+.include <dirdeps.mk>
+
+.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+# local dependencies - needed for -jN in clean tree
+.endif
diff --git a/usr.sbin/gpioctl/Makefile.depend b/usr.sbin/gpioctl/Makefile.depend
new file mode 100644
index 0000000..a839545
--- /dev/null
+++ b/usr.sbin/gpioctl/Makefile.depend
@@ -0,0 +1,19 @@
+# Autogenerated - do NOT edit!
+
+DEP_RELDIR := ${_PARSEDIR:S,${SRCTOP}/,,}
+
+DEP_MACHINE := ${.PARSEFILE:E}
+
+DIRDEPS = \
+ gnu/lib/libgcc \
+ include \
+ include/xlocale \
+ lib/${CSU_DIR} \
+ lib/libc \
+
+
+.include <dirdeps.mk>
+
+.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+# local dependencies - needed for -jN in clean tree
+.endif
diff --git a/usr.sbin/gpioctl/gpioctl.c b/usr.sbin/gpioctl/gpioctl.c
index 8956ef4..9d76e1d 100644
--- a/usr.sbin/gpioctl/gpioctl.c
+++ b/usr.sbin/gpioctl/gpioctl.c
@@ -43,7 +43,7 @@ struct flag_desc {
uint32_t flag;
};
-struct flag_desc gpio_flags[] = {
+static struct flag_desc gpio_flags[] = {
{ "IN", GPIO_PIN_INPUT },
{ "OUT", GPIO_PIN_OUTPUT },
{ "OD", GPIO_PIN_OPENDRAIN },
diff --git a/usr.sbin/gssd/Makefile.depend b/usr.sbin/gssd/Makefile.depend
new file mode 100644
index 0000000..cdbb525
--- /dev/null
+++ b/usr.sbin/gssd/Makefile.depend
@@ -0,0 +1,34 @@
+# Autogenerated - do NOT edit!
+
+DEP_RELDIR := ${_PARSEDIR:S,${SRCTOP}/,,}
+
+DEP_MACHINE := ${.PARSEFILE:E}
+
+DIRDEPS = \
+ gnu/lib/libgcc \
+ include \
+ include/gssapi \
+ include/rpc \
+ include/xlocale \
+ lib/${CSU_DIR} \
+ lib/libc \
+ lib/libgssapi \
+
+
+.include <dirdeps.mk>
+
+.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+# local dependencies - needed for -jN in clean tree
+gssd.o: gssd.h
+gssd.po: gssd.h
+gssd_prot.o: gssd.h
+gssd_prot.po: gssd.h
+gssd_svc.o: gssd.h
+gssd_svc.o: gssd_svc.c
+gssd_svc.po: gssd.h
+gssd_svc.po: gssd_svc.c
+gssd_xdr.o: gssd.h
+gssd_xdr.o: gssd_xdr.c
+gssd_xdr.po: gssd.h
+gssd_xdr.po: gssd_xdr.c
+.endif
diff --git a/usr.sbin/gstat/Makefile.depend b/usr.sbin/gstat/Makefile.depend
new file mode 100644
index 0000000..b5ed130
--- /dev/null
+++ b/usr.sbin/gstat/Makefile.depend
@@ -0,0 +1,27 @@
+# Autogenerated - do NOT edit!
+
+DEP_RELDIR := ${_PARSEDIR:S,${SRCTOP}/,,}
+
+DEP_MACHINE := ${.PARSEFILE:E}
+
+DIRDEPS = \
+ gnu/lib/libgcc \
+ include \
+ include/xlocale \
+ lib/${CSU_DIR} \
+ lib/libc \
+ lib/libdevstat \
+ lib/libedit \
+ lib/libexpat \
+ lib/libgeom \
+ lib/libkvm \
+ lib/libsbuf \
+ lib/ncurses/ncurses \
+ lib/ncurses/ncursesw \
+
+
+.include <dirdeps.mk>
+
+.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+# local dependencies - needed for -jN in clean tree
+.endif
diff --git a/usr.sbin/i2c/Makefile.depend b/usr.sbin/i2c/Makefile.depend
new file mode 100644
index 0000000..a839545
--- /dev/null
+++ b/usr.sbin/i2c/Makefile.depend
@@ -0,0 +1,19 @@
+# Autogenerated - do NOT edit!
+
+DEP_RELDIR := ${_PARSEDIR:S,${SRCTOP}/,,}
+
+DEP_MACHINE := ${.PARSEFILE:E}
+
+DIRDEPS = \
+ gnu/lib/libgcc \
+ include \
+ include/xlocale \
+ lib/${CSU_DIR} \
+ lib/libc \
+
+
+.include <dirdeps.mk>
+
+.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+# local dependencies - needed for -jN in clean tree
+.endif
diff --git a/usr.sbin/ifmcstat/Makefile.depend b/usr.sbin/ifmcstat/Makefile.depend
new file mode 100644
index 0000000..e6478bb
--- /dev/null
+++ b/usr.sbin/ifmcstat/Makefile.depend
@@ -0,0 +1,21 @@
+# Autogenerated - do NOT edit!
+
+DEP_RELDIR := ${_PARSEDIR:S,${SRCTOP}/,,}
+
+DEP_MACHINE := ${.PARSEFILE:E}
+
+DIRDEPS = \
+ gnu/lib/libgcc \
+ include \
+ include/arpa \
+ include/xlocale \
+ lib/${CSU_DIR} \
+ lib/libc \
+ lib/libkvm \
+
+
+.include <dirdeps.mk>
+
+.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+# local dependencies - needed for -jN in clean tree
+.endif
diff --git a/usr.sbin/ifmcstat/ifmcstat.c b/usr.sbin/ifmcstat/ifmcstat.c
index d92c056..838c83d 100644
--- a/usr.sbin/ifmcstat/ifmcstat.c
+++ b/usr.sbin/ifmcstat/ifmcstat.c
@@ -387,7 +387,6 @@ ll_addrlist(struct ifaddr *ifap)
struct sockaddr sa;
struct sockaddr_dl sdl;
struct ifaddr *ifap0;
- int error;
if (af && af != AF_LINK)
return;
@@ -404,7 +403,7 @@ ll_addrlist(struct ifaddr *ifap)
if (sdl.sdl_alen == 0)
goto nextifap;
addrbuf[0] = '\0';
- error = getnameinfo((struct sockaddr *)&sdl, sdl.sdl_len,
+ getnameinfo((struct sockaddr *)&sdl, sdl.sdl_len,
addrbuf, sizeof(addrbuf), NULL, 0, NI_NUMERICHOST);
printf("\tlink %s\n", addrbuf);
nextifap:
@@ -427,7 +426,7 @@ ll_addrlist(struct ifaddr *ifap)
goto nextmulti;
KREAD(ifm.ifma_addr, &sdl, struct sockaddr_dl);
addrbuf[0] = '\0';
- error = getnameinfo((struct sockaddr *)&sdl,
+ getnameinfo((struct sockaddr *)&sdl,
sdl.sdl_len, addrbuf, sizeof(addrbuf),
NULL, 0, NI_NUMERICHOST);
printf("\t\tgroup %s refcnt %d\n",
diff --git a/usr.sbin/inetd/Makefile.depend b/usr.sbin/inetd/Makefile.depend
new file mode 100644
index 0000000..e9ba4b9
--- /dev/null
+++ b/usr.sbin/inetd/Makefile.depend
@@ -0,0 +1,24 @@
+# Autogenerated - do NOT edit!
+
+DEP_RELDIR := ${_PARSEDIR:S,${SRCTOP}/,,}
+
+DEP_MACHINE := ${.PARSEFILE:E}
+
+DIRDEPS = \
+ gnu/lib/libgcc \
+ include \
+ include/arpa \
+ include/rpc \
+ include/xlocale \
+ lib/${CSU_DIR} \
+ lib/libc \
+ lib/libipsec \
+ lib/libutil \
+ lib/libwrap \
+
+
+.include <dirdeps.mk>
+
+.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+# local dependencies - needed for -jN in clean tree
+.endif
diff --git a/usr.sbin/inetd/builtins.c b/usr.sbin/inetd/builtins.c
index 974e54f..3ccdab0 100644
--- a/usr.sbin/inetd/builtins.c
+++ b/usr.sbin/inetd/builtins.c
@@ -691,15 +691,9 @@ printit:
uint32_t
machtime(void)
{
- struct timeval tv;
- if (gettimeofday(&tv, (struct timezone *)NULL) < 0) {
- if (debug)
- warnx("unable to get time of day");
- return (0L);
- }
#define OFFSET ((uint32_t)25567 * 24*60*60)
- return (htonl((uint32_t)(tv.tv_sec + OFFSET)));
+ return (htonl((uint32_t)(time(NULL) + OFFSET)));
#undef OFFSET
}
diff --git a/usr.sbin/iostat/Makefile.depend b/usr.sbin/iostat/Makefile.depend
new file mode 100644
index 0000000..022357f
--- /dev/null
+++ b/usr.sbin/iostat/Makefile.depend
@@ -0,0 +1,22 @@
+# Autogenerated - do NOT edit!
+
+DEP_RELDIR := ${_PARSEDIR:S,${SRCTOP}/,,}
+
+DEP_MACHINE := ${.PARSEFILE:E}
+
+DIRDEPS = \
+ gnu/lib/libgcc \
+ include \
+ include/xlocale \
+ lib/${CSU_DIR} \
+ lib/libc \
+ lib/libdevstat \
+ lib/libkvm \
+ lib/msun \
+
+
+.include <dirdeps.mk>
+
+.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+# local dependencies - needed for -jN in clean tree
+.endif
diff --git a/usr.sbin/ip6addrctl/Makefile b/usr.sbin/ip6addrctl/Makefile
index 93a2990..cd2510e 100644
--- a/usr.sbin/ip6addrctl/Makefile
+++ b/usr.sbin/ip6addrctl/Makefile
@@ -3,6 +3,4 @@
PROG= ip6addrctl
MAN= ip6addrctl.8
-WARNS?= 2
-
.include <bsd.prog.mk>
diff --git a/usr.sbin/ip6addrctl/Makefile.depend b/usr.sbin/ip6addrctl/Makefile.depend
new file mode 100644
index 0000000..a839545
--- /dev/null
+++ b/usr.sbin/ip6addrctl/Makefile.depend
@@ -0,0 +1,19 @@
+# Autogenerated - do NOT edit!
+
+DEP_RELDIR := ${_PARSEDIR:S,${SRCTOP}/,,}
+
+DEP_MACHINE := ${.PARSEFILE:E}
+
+DIRDEPS = \
+ gnu/lib/libgcc \
+ include \
+ include/xlocale \
+ lib/${CSU_DIR} \
+ lib/libc \
+
+
+.include <dirdeps.mk>
+
+.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+# local dependencies - needed for -jN in clean tree
+.endif
diff --git a/usr.sbin/ip6addrctl/ip6addrctl.c b/usr.sbin/ip6addrctl/ip6addrctl.c
index 532a096..6a730ff 100644
--- a/usr.sbin/ip6addrctl/ip6addrctl.c
+++ b/usr.sbin/ip6addrctl/ip6addrctl.c
@@ -59,7 +59,7 @@ struct policyqueue {
struct in6_addrpolicy pc_policy;
};
TAILQ_HEAD(policyhead, policyqueue);
-struct policyhead policyhead;
+static struct policyhead policyhead;
static void usage(void);
static void get_policy(void);
@@ -71,12 +71,10 @@ static void plen2mask(struct sockaddr_in6 *, int);
static void set_policy(void);
static void add_policy(char *, char *, char *);
static void delete_policy(char *);
-static void flush_policy();
+static void flush_policy(void);
int
-main(argc, argv)
- int argc;
- char *argv[];
+main(int argc, char *argv[])
{
TAILQ_INIT(&policyhead);
@@ -107,11 +105,11 @@ main(argc, argv)
}
static void
-get_policy()
+get_policy(void)
{
int mib[] = { CTL_NET, PF_INET6, IPPROTO_IPV6, IPV6CTL_ADDRCTLPOLICY };
size_t l;
- char *buf;
+ struct in6_addrpolicy *buf;
struct in6_addrpolicy *pol, *ep;
if (sysctl(mib, sizeof(mib) / sizeof(mib[0]), NULL, &l, NULL, 0) < 0) {
@@ -131,8 +129,8 @@ get_policy()
/* NOTREACHED */
}
- ep = (struct in6_addrpolicy *)(buf + l);
- for (pol = (struct in6_addrpolicy *)buf; pol + 1 <= ep; pol++) {
+ ep = buf + l/sizeof(*buf);
+ for (pol = buf; pol + 1 <= ep; pol++) {
struct policyqueue *new;
if ((new = malloc(sizeof(*new))) == NULL)
@@ -145,7 +143,7 @@ get_policy()
}
static void
-dump_policy()
+dump_policy(void)
{
size_t addrlen;
char addrbuf[NI_MAXHOST];
@@ -201,8 +199,7 @@ dump_policy()
} while (0);
static void
-make_policy_fromfile(conf)
- char *conf;
+make_policy_fromfile(char *conf)
{
char line[_POSIX2_LINE_MAX], *cp;
char *addrstr;
@@ -257,9 +254,7 @@ make_policy_fromfile(conf)
}
static int
-parse_prefix(prefix0, pol)
- const char *prefix0;
- struct in6_addrpolicy *pol;
+parse_prefix(const char *prefix0, struct in6_addrpolicy *pol)
{
int e = 0, plen;
char *prefix, *plenstr;
@@ -299,11 +294,9 @@ parse_prefix(prefix0, pol)
}
static void
-plen2mask(mask, plen)
- struct sockaddr_in6 *mask;
- int plen;
+plen2mask(struct sockaddr_in6 *mask, int plen)
{
- u_char *cp = (char *)&mask->sin6_addr;
+ u_char *cp = (unsigned char *)&mask->sin6_addr;
memset(mask, 0, sizeof(*mask));
mask->sin6_family = AF_INET6; /* just in case */
@@ -316,7 +309,7 @@ plen2mask(mask, plen)
}
static void
-set_policy()
+set_policy(void)
{
struct policyqueue *ent;
int s;
@@ -334,8 +327,7 @@ set_policy()
}
static int
-mask2plen(mask)
- struct sockaddr_in6 *mask;
+mask2plen(struct sockaddr_in6 *mask)
{
int masklen, final = 0;
u_char *p, *lim;
@@ -394,8 +386,7 @@ mask2plen(mask)
}
static void
-add_policy(prefix, prec, label)
- char *prefix, *prec, *label;
+add_policy(char *prefix, char *prec, char *label)
{
struct in6_addrpolicy p;
int s;
@@ -416,8 +407,7 @@ add_policy(prefix, prec, label)
}
static void
-delete_policy(prefix)
- char *prefix;
+delete_policy(char *prefix)
{
struct in6_addrpolicy p;
int s;
@@ -436,7 +426,7 @@ delete_policy(prefix)
}
static void
-flush_policy()
+flush_policy(void)
{
struct policyqueue *ent;
int s;
@@ -454,7 +444,7 @@ flush_policy()
}
static void
-usage()
+usage(void)
{
fprintf(stderr, "usage: ip6addrctl [show]\n");
fprintf(stderr, " ip6addrctl add "
diff --git a/usr.sbin/ipfwpcap/Makefile.depend b/usr.sbin/ipfwpcap/Makefile.depend
new file mode 100644
index 0000000..447f532
--- /dev/null
+++ b/usr.sbin/ipfwpcap/Makefile.depend
@@ -0,0 +1,20 @@
+# Autogenerated - do NOT edit!
+
+DEP_RELDIR := ${_PARSEDIR:S,${SRCTOP}/,,}
+
+DEP_MACHINE := ${.PARSEFILE:E}
+
+DIRDEPS = \
+ gnu/lib/libgcc \
+ include \
+ include/xlocale \
+ lib/${CSU_DIR} \
+ lib/libc \
+ lib/libpcap \
+
+
+.include <dirdeps.mk>
+
+.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+# local dependencies - needed for -jN in clean tree
+.endif
diff --git a/usr.sbin/ipfwpcap/ipfwpcap.8 b/usr.sbin/ipfwpcap/ipfwpcap.8
index 53787fc..523b059 100644
--- a/usr.sbin/ipfwpcap/ipfwpcap.8
+++ b/usr.sbin/ipfwpcap/ipfwpcap.8
@@ -1,4 +1,4 @@
-.\" Copyright (c) 2006 Niclas Zeising
+.\" Copyright (c) 2006 Niclas Zeising <zeising@FreeBSD.org>
.\" All rights reserved.
.\"
.\" Redistribution and use in source and binary forms, with or without
@@ -129,4 +129,4 @@ utility first appeared in
was written by
.An P. Kern Aq pkern@cns.utoronto.ca .
This manual page was written by
-.An Niclas Zeising Aq niclas.zeising@gmail.com .
+.An Niclas Zeising Aq zeising@FreeBSD.org .
diff --git a/usr.sbin/isc-hmac-fixup/Makefile.depend b/usr.sbin/isc-hmac-fixup/Makefile.depend
new file mode 100644
index 0000000..418e041
--- /dev/null
+++ b/usr.sbin/isc-hmac-fixup/Makefile.depend
@@ -0,0 +1,27 @@
+# Autogenerated - do NOT edit!
+
+DEP_RELDIR := ${_PARSEDIR:S,${SRCTOP}/,,}
+
+DEP_MACHINE := ${.PARSEFILE:E}
+
+DIRDEPS = \
+ gnu/lib/libgcc \
+ include \
+ include/xlocale \
+ lib/${CSU_DIR} \
+ lib/bind/bind9 \
+ lib/bind/dns \
+ lib/bind/isc \
+ lib/bind/isccc \
+ lib/bind/isccfg \
+ lib/bind/lwres \
+ lib/libc \
+ lib/libthr \
+ secure/lib/libcrypto \
+
+
+.include <dirdeps.mk>
+
+.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+# local dependencies - needed for -jN in clean tree
+.endif
diff --git a/usr.sbin/isfctl/Makefile b/usr.sbin/isfctl/Makefile
new file mode 100644
index 0000000..30f8e5b
--- /dev/null
+++ b/usr.sbin/isfctl/Makefile
@@ -0,0 +1,7 @@
+# $FreeBSD$
+
+PROG= isfctl
+
+MAN= isfctl.8
+
+.include <bsd.prog.mk>
diff --git a/usr.sbin/isfctl/isfctl.8 b/usr.sbin/isfctl/isfctl.8
new file mode 100644
index 0000000..06b2f3a
--- /dev/null
+++ b/usr.sbin/isfctl/isfctl.8
@@ -0,0 +1,89 @@
+.\"-
+.\" Copyright (c) 2012 SRI International
+.\" All rights reserved.
+.\"
+.\" This software was developed by SRI International and the University of
+.\" Cambridge Computer Laboratory under DARPA/AFRL contract (FA8750-10-C-0237)
+.\" ("CTSRD"), as part of the DARPA CRASH research programme.
+.\"
+.\" Redistribution and use in source and binary forms, with or without
+.\" modification, are permitted provided that the following conditions
+.\" are met:
+.\" 1. Redistributions of source code must retain the above copyright
+.\" notice, this list of conditions and the following disclaimer.
+.\" 2. Redistributions in binary form must reproduce the above copyright
+.\" notice, this list of conditions and the following disclaimer in the
+.\" documentation and/or other materials provided with the distribution.
+.\"
+.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+.\" SUCH DAMAGE.
+.\"
+.\" $FreeBSD$
+.\"
+.Dd August 3, 2012
+.Dt ISFCTL 8
+.Os
+.Sh NAME
+.Nm isfctl
+.Nd Intel StrataFlash device control program
+.Sh SYNOPSIS
+.Nm
+.Ar device
+.Ic erase
+.Ar offset
+.Ar size
+.Sh DESCRIPTION
+The
+.Nm
+utility provides a way for administrators to control aspects of
+.Xr isf 4
+devices that can not be managed though the
+.Xr disk 9
+interface.
+.Pp
+The
+.Nm
+utility takes a device name as its first argument followed by a command.
+Currently supported commands are:
+.Bl -tag -width erase
+.It Ic erase
+Erase blocks beginning at
+.Ar offset
+covering a total of
+.Ar size
+bytes.
+The
+.Ar offset
+argument must be a multiple of 128K.
+The
+.Ar size
+argument must either be a multiple of 128K or a number less than 32K in
+which case it is treated as a number of 128K blocks to erase.
+.El
+.Sh EXAMPLES
+.Dl isfctl isf0 erase 0 0x20000
+.Pp
+Erase the first block of the isf0 device.
+.Sh SEE ALSO
+.Xr isf 4
+.Sh HISTORY
+The
+.Nm
+utility first appeared in
+.Fx 10.0 .
+.Sh AUTHORS
+This software and this manual page were
+developed by SRI International and the University of Cambridge Computer
+Laboratory under DARPA/AFRL contract
+.Pq FA8750-10-C-0237
+.Pq Do CTSRD Dc ,
+as part of the DARPA CRASH research programme.
diff --git a/usr.sbin/isfctl/isfctl.c b/usr.sbin/isfctl/isfctl.c
new file mode 100644
index 0000000..af99093
--- /dev/null
+++ b/usr.sbin/isfctl/isfctl.c
@@ -0,0 +1,115 @@
+/*-
+ * Copyright (c) 2012 SRI International
+ * All rights reserved.
+ *
+ * This software was developed by SRI International and the University of
+ * Cambridge Computer Laboratory under DARPA/AFRL contract (FA8750-10-C-0237)
+ * ("CTSRD"), as part of the DARPA CRASH research programme.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * $FreeBSD$
+ */
+
+#include <sys/types.h>
+#include <sys/ioctl.h>
+
+#include <err.h>
+#include <fcntl.h>
+#include <inttypes.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#include <unistd.h>
+
+/* XXXBED: should install and include sys/dev/isf.h */
+struct isf_range {
+ off_t ir_off; /* Offset of range to delete (set to 0xFF) */
+ size_t ir_size; /* Size of range */
+};
+
+#define ISF_ERASE _IOW('I', 1, struct isf_range)
+
+#define ISF_ERASE_BLOCK (128 * 1024)
+
+static enum {UNSET, ERASE} action = UNSET;
+
+static void
+usage(void)
+{
+ fprintf(stderr, "usage: isfctl <device> erase <offset> <size>\n");
+ exit(1);
+}
+
+int
+main(int argc, char **argv)
+{
+ struct isf_range ir;
+ int fd, i;
+ char *p, *dev;
+
+ if (argc < 2)
+ usage();
+ argc--; argv++;
+
+ if (*argv[0] == '/')
+ dev = argv[0];
+ else
+ asprintf(&dev, "/dev/%s", argv[0]);
+ argc--; argv++;
+ fd = open(dev, O_RDWR);
+ if (fd < 0)
+ err(1, "unable to open device -- %s", dev);
+
+ if (strcmp(argv[0], "erase") == 0) {
+ if (argc != 3)
+ usage();
+ action = ERASE;
+ ir.ir_off = strtol(argv[1], &p, 0);
+ if (*p)
+ errx(1, "invalid offset -- %s", argv[2]);
+ ir.ir_size = strtol(argv[2], &p, 0);
+ if (*p)
+ errx(1, "invalid size -- %s", argv[3]);
+ /*
+ * If the user requests to delete less than 32K of space
+ * then assume that they want to delete a number of 128K
+ * blocks.
+ */
+ if (ir.ir_size < 32 * 1024)
+ ir.ir_size *= 128 * 1024;
+ }
+
+ switch (action) {
+ case ERASE:
+ i = ioctl(fd, ISF_ERASE, &ir);
+ if (i < 0)
+ err(1, "ioctl(%s, %jx, %zx)", dev,
+ (intmax_t)ir.ir_off, ir.ir_size);
+ break;
+ default:
+ usage();
+ }
+
+ close(fd);
+ return (0);
+}
diff --git a/usr.sbin/jail/Makefile.depend b/usr.sbin/jail/Makefile.depend
new file mode 100644
index 0000000..e3e2159
--- /dev/null
+++ b/usr.sbin/jail/Makefile.depend
@@ -0,0 +1,29 @@
+# Autogenerated - do NOT edit!
+
+DEP_RELDIR := ${_PARSEDIR:S,${SRCTOP}/,,}
+
+DEP_MACHINE := ${.PARSEFILE:E}
+
+DIRDEPS = \
+ gnu/lib/libgcc \
+ include \
+ include/arpa \
+ include/xlocale \
+ lib/${CSU_DIR} \
+ lib/libc \
+ lib/libjail \
+ lib/libkvm \
+ lib/libutil \
+
+
+.include <dirdeps.mk>
+
+.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+# local dependencies - needed for -jN in clean tree
+jaillex.o: jaillex.c
+jaillex.o: y.tab.h
+jaillex.po: jaillex.c
+jaillex.po: y.tab.h
+jailparse.o: jailparse.c
+jailparse.po: jailparse.c
+.endif
diff --git a/usr.sbin/jail/config.c b/usr.sbin/jail/config.c
index 7a7917d..d0b7d26 100644
--- a/usr.sbin/jail/config.c
+++ b/usr.sbin/jail/config.c
@@ -598,7 +598,7 @@ check_intparams(struct cfjail *j)
error = -1;
}
*cs = '\0';
- s->len = cs - s->s + 1;
+ s->len = cs - s->s;
}
}
}
@@ -622,7 +622,7 @@ check_intparams(struct cfjail *j)
error = -1;
}
*cs = '\0';
- s->len = cs - s->s + 1;
+ s->len = cs - s->s;
}
}
}
@@ -690,6 +690,7 @@ import_params(struct cfjail *j)
if (jailparam_init(jp, p->name) < 0) {
error = -1;
jail_warnx(j, "%s", jail_errmsg);
+ jp++;
continue;
}
if (TAILQ_EMPTY(&p->val))
@@ -714,12 +715,11 @@ import_params(struct cfjail *j)
value = alloca(vallen);
cs = value;
TAILQ_FOREACH_SAFE(s, &p->val, tq, ts) {
- strcpy(cs, s->s);
- if (ts != NULL) {
- cs += s->len + 1;
- cs[-1] = ',';
- }
+ memcpy(cs, s->s, s->len);
+ cs += s->len + 1;
+ cs[-1] = ',';
}
+ value[vallen - 1] = '\0';
}
if (jailparam_import(jp, value) < 0) {
error = -1;
diff --git a/usr.sbin/jail/jail.8 b/usr.sbin/jail/jail.8
index 9204686..b96cfef 100644
--- a/usr.sbin/jail/jail.8
+++ b/usr.sbin/jail/jail.8
@@ -25,7 +25,7 @@
.\"
.\" $FreeBSD$
.\"
-.Dd May 23, 2012
+.Dd September 15, 2012
.Dt JAIL 8
.Os
.Sh NAME
@@ -1225,3 +1225,11 @@ directory that is moved out of the jail's chroot, then the process may gain
access to the file space outside of the jail.
It is recommended that directories always be copied, rather than moved, out
of a jail.
+.Pp
+In addition, there are several ways in which an unprivileged user
+outside the jail can cooperate with a privileged user inside the jail
+and thereby obtain elevated privileges in the host environment.
+Most of these attacks can be mitigated by ensuring that the jail root
+is not accessible to unprivileged users in the host environment.
+Regardless, as a general rule, untrusted users with privileged access
+to a jail should not be given access to the host environment.
diff --git a/usr.sbin/jail/jail.c b/usr.sbin/jail/jail.c
index 4fc03c9..6970ae1 100644
--- a/usr.sbin/jail/jail.c
+++ b/usr.sbin/jail/jail.c
@@ -145,7 +145,7 @@ main(int argc, char **argv)
cfname = CONF_FILE;
JidFile = NULL;
- while ((ch = getopt(argc, argv, "cdf:hiJ:lmn:p:qrRs:U:v")) != -1) {
+ while ((ch = getopt(argc, argv, "cdf:hiJ:lmn:p:qrRs:u:U:v")) != -1) {
switch (ch) {
case 'c':
op |= JF_START;
@@ -304,9 +304,33 @@ main(int argc, char **argv)
for (i++; i < argc; i++)
add_param(NULL, NULL, IP_COMMAND,
argv[i]);
- break;
}
- add_param(NULL, NULL, 0, argv[i]);
+#ifdef INET
+ else if (!strncmp(argv[i], "ip4.addr=", 9)) {
+ for (cs = argv[i] + 9;; cs = ncs + 1) {
+ ncs = strchr(cs, ',');
+ if (ncs)
+ *ncs = '\0';
+ add_param(NULL, NULL, KP_IP4_ADDR, cs);
+ if (!ncs)
+ break;
+ }
+ }
+#endif
+#ifdef INET6
+ else if (!strncmp(argv[i], "ip6.addr=", 9)) {
+ for (cs = argv[i] + 9;; cs = ncs + 1) {
+ ncs = strchr(cs, ',');
+ if (ncs)
+ *ncs = '\0';
+ add_param(NULL, NULL, KP_IP6_ADDR, cs);
+ if (!ncs)
+ break;
+ }
+ }
+#endif
+ else
+ add_param(NULL, NULL, 0, argv[i]);
}
} else {
/* From the config file, perhaps with a specified jail */
diff --git a/usr.sbin/jexec/Makefile.depend b/usr.sbin/jexec/Makefile.depend
new file mode 100644
index 0000000..5c682ee
--- /dev/null
+++ b/usr.sbin/jexec/Makefile.depend
@@ -0,0 +1,22 @@
+# Autogenerated - do NOT edit!
+
+DEP_RELDIR := ${_PARSEDIR:S,${SRCTOP}/,,}
+
+DEP_MACHINE := ${.PARSEFILE:E}
+
+DIRDEPS = \
+ gnu/lib/libgcc \
+ include \
+ include/arpa \
+ include/xlocale \
+ lib/${CSU_DIR} \
+ lib/libc \
+ lib/libjail \
+ lib/libutil \
+
+
+.include <dirdeps.mk>
+
+.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+# local dependencies - needed for -jN in clean tree
+.endif
diff --git a/usr.sbin/jls/Makefile.depend b/usr.sbin/jls/Makefile.depend
new file mode 100644
index 0000000..3d5f6ab
--- /dev/null
+++ b/usr.sbin/jls/Makefile.depend
@@ -0,0 +1,21 @@
+# Autogenerated - do NOT edit!
+
+DEP_RELDIR := ${_PARSEDIR:S,${SRCTOP}/,,}
+
+DEP_MACHINE := ${.PARSEFILE:E}
+
+DIRDEPS = \
+ gnu/lib/libgcc \
+ include \
+ include/arpa \
+ include/xlocale \
+ lib/${CSU_DIR} \
+ lib/libc \
+ lib/libjail \
+
+
+.include <dirdeps.mk>
+
+.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+# local dependencies - needed for -jN in clean tree
+.endif
diff --git a/usr.sbin/kbdcontrol/Makefile.depend b/usr.sbin/kbdcontrol/Makefile.depend
new file mode 100644
index 0000000..37e3bbd
--- /dev/null
+++ b/usr.sbin/kbdcontrol/Makefile.depend
@@ -0,0 +1,21 @@
+# Autogenerated - do NOT edit!
+
+DEP_RELDIR := ${_PARSEDIR:S,${SRCTOP}/,,}
+
+DEP_MACHINE := ${.PARSEFILE:E}
+
+DIRDEPS = \
+ gnu/lib/libgcc \
+ include \
+ include/xlocale \
+ lib/${CSU_DIR} \
+ lib/libc \
+
+
+.include <dirdeps.mk>
+
+.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+# local dependencies - needed for -jN in clean tree
+lex.o: lex.c
+lex.po: lex.c
+.endif
diff --git a/usr.sbin/kbdmap/Makefile.depend b/usr.sbin/kbdmap/Makefile.depend
new file mode 100644
index 0000000..a839545
--- /dev/null
+++ b/usr.sbin/kbdmap/Makefile.depend
@@ -0,0 +1,19 @@
+# Autogenerated - do NOT edit!
+
+DEP_RELDIR := ${_PARSEDIR:S,${SRCTOP}/,,}
+
+DEP_MACHINE := ${.PARSEFILE:E}
+
+DIRDEPS = \
+ gnu/lib/libgcc \
+ include \
+ include/xlocale \
+ lib/${CSU_DIR} \
+ lib/libc \
+
+
+.include <dirdeps.mk>
+
+.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+# local dependencies - needed for -jN in clean tree
+.endif
diff --git a/usr.sbin/kbdmap/kbdmap.c b/usr.sbin/kbdmap/kbdmap.c
index c6348a6..7d5a0d1 100644
--- a/usr.sbin/kbdmap/kbdmap.c
+++ b/usr.sbin/kbdmap/kbdmap.c
@@ -327,7 +327,6 @@ show_dialog(struct keymap **km_sorted, int num_keymaps)
FILE *fp;
char *cmd, *dialog;
char tmp_name[] = "/tmp/_kbd_lang.XXXX";
- const char *ext;
int fd, i, size;
fd = mkstemp(tmp_name);
@@ -339,8 +338,6 @@ show_dialog(struct keymap **km_sorted, int num_keymaps)
asprintf(&dialog, "/usr/bin/dialog --clear --title \"Keyboard Menu\" "
"--menu \"%s\" 0 0 0", menu);
- ext = extract_name(dir);
-
/* start right font, assume that current font is equal
* to default font in /etc/rc.conf
*
diff --git a/usr.sbin/keyserv/Makefile.depend b/usr.sbin/keyserv/Makefile.depend
new file mode 100644
index 0000000..e5b3b87
--- /dev/null
+++ b/usr.sbin/keyserv/Makefile.depend
@@ -0,0 +1,30 @@
+# Autogenerated - do NOT edit!
+
+DEP_RELDIR := ${_PARSEDIR:S,${SRCTOP}/,,}
+
+DEP_MACHINE := ${.PARSEFILE:E}
+
+DIRDEPS = \
+ gnu/lib/libgcc \
+ include \
+ include/rpc \
+ include/rpcsvc \
+ include/xlocale \
+ lib/${CSU_DIR} \
+ lib/libc \
+ lib/libmp \
+ lib/librpcsvc \
+ secure/lib/libcrypto \
+
+
+.include <dirdeps.mk>
+
+.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+# local dependencies - needed for -jN in clean tree
+crypt_server.o: crypt.h
+crypt_server.po: crypt.h
+crypt_svc.o: crypt.h
+crypt_svc.o: crypt_svc.c
+crypt_svc.po: crypt.h
+crypt_svc.po: crypt_svc.c
+.endif
diff --git a/usr.sbin/keyserv/keyserv.c b/usr.sbin/keyserv/keyserv.c
index 2366ba0..79bf90d 100644
--- a/usr.sbin/keyserv/keyserv.c
+++ b/usr.sbin/keyserv/keyserv.c
@@ -232,7 +232,7 @@ randomize(master)
seed = 0;
for (i = 0; i < 1024; i++) {
- (void) gettimeofday(&tv, (struct timezone *) NULL);
+ (void)gettimeofday(&tv, NULL);
shift = i % 8 * sizeof (int);
seed ^= (tv.tv_usec << shift) | (tv.tv_usec >> (32 - shift));
}
@@ -575,7 +575,7 @@ key_gen_1_svc_prog(v, s)
static des_block keygen;
static des_block key;
- (void) gettimeofday(&time, (struct timezone *) NULL);
+ (void)gettimeofday(&time, NULL);
keygen.key.high += (time.tv_sec ^ time.tv_usec);
keygen.key.low += (time.tv_sec ^ time.tv_usec);
ecb_crypt((char *)&masterkey, (char *)&keygen, sizeof (keygen),
diff --git a/usr.sbin/kgmon/Makefile.depend b/usr.sbin/kgmon/Makefile.depend
new file mode 100644
index 0000000..553674c
--- /dev/null
+++ b/usr.sbin/kgmon/Makefile.depend
@@ -0,0 +1,20 @@
+# Autogenerated - do NOT edit!
+
+DEP_RELDIR := ${_PARSEDIR:S,${SRCTOP}/,,}
+
+DEP_MACHINE := ${.PARSEFILE:E}
+
+DIRDEPS = \
+ gnu/lib/libgcc \
+ include \
+ include/xlocale \
+ lib/${CSU_DIR} \
+ lib/libc \
+ lib/libkvm \
+
+
+.include <dirdeps.mk>
+
+.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+# local dependencies - needed for -jN in clean tree
+.endif
diff --git a/usr.sbin/kgmon/kgmon.c b/usr.sbin/kgmon/kgmon.c
index d5cdf96..c691d6e 100644
--- a/usr.sbin/kgmon/kgmon.c
+++ b/usr.sbin/kgmon/kgmon.c
@@ -90,7 +90,9 @@ main(int argc, char **argv)
struct kvmvars kvmvars;
char *system, *kmemf;
- seteuid(getuid());
+ if (seteuid(getuid()) != 0) {
+ err(1, "seteuid failed\n");
+ }
kmemf = NULL;
system = NULL;
while ((ch = getopt(argc, argv, "M:N:Bbhpr")) != -1) {
diff --git a/usr.sbin/kgzip/Makefile.depend b/usr.sbin/kgzip/Makefile.depend
new file mode 100644
index 0000000..a839545
--- /dev/null
+++ b/usr.sbin/kgzip/Makefile.depend
@@ -0,0 +1,19 @@
+# Autogenerated - do NOT edit!
+
+DEP_RELDIR := ${_PARSEDIR:S,${SRCTOP}/,,}
+
+DEP_MACHINE := ${.PARSEFILE:E}
+
+DIRDEPS = \
+ gnu/lib/libgcc \
+ include \
+ include/xlocale \
+ lib/${CSU_DIR} \
+ lib/libc \
+
+
+.include <dirdeps.mk>
+
+.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+# local dependencies - needed for -jN in clean tree
+.endif
diff --git a/usr.sbin/kldxref/Makefile.depend b/usr.sbin/kldxref/Makefile.depend
new file mode 100644
index 0000000..a839545
--- /dev/null
+++ b/usr.sbin/kldxref/Makefile.depend
@@ -0,0 +1,19 @@
+# Autogenerated - do NOT edit!
+
+DEP_RELDIR := ${_PARSEDIR:S,${SRCTOP}/,,}
+
+DEP_MACHINE := ${.PARSEFILE:E}
+
+DIRDEPS = \
+ gnu/lib/libgcc \
+ include \
+ include/xlocale \
+ lib/${CSU_DIR} \
+ lib/libc \
+
+
+.include <dirdeps.mk>
+
+.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+# local dependencies - needed for -jN in clean tree
+.endif
diff --git a/usr.sbin/kldxref/ef.c b/usr.sbin/kldxref/ef.c
index 276771d..b1b00cc 100644
--- a/usr.sbin/kldxref/ef.c
+++ b/usr.sbin/kldxref/ef.c
@@ -532,7 +532,7 @@ ef_open(const char *filename, struct elf_file *efile, int verbose)
int error;
int phlen, res;
int nsegs;
- Elf_Phdr *phdr, *phdyn, *phphdr, *phlimit;
+ Elf_Phdr *phdr, *phdyn, *phlimit;
if (filename == NULL)
return EFTYPE;
@@ -576,7 +576,6 @@ ef_open(const char *filename, struct elf_file *efile, int verbose)
phlimit = phdr + hdr->e_phnum;
nsegs = 0;
phdyn = NULL;
- phphdr = NULL;
while (phdr < phlimit) {
if (verbose > 1)
ef_print_phdr(phdr);
@@ -590,7 +589,6 @@ ef_open(const char *filename, struct elf_file *efile, int verbose)
ef->ef_segs[nsegs++] = phdr;
break;
case PT_PHDR:
- phphdr = phdr;
break;
case PT_DYNAMIC:
phdyn = phdr;
@@ -602,7 +600,8 @@ ef_open(const char *filename, struct elf_file *efile, int verbose)
printf("\n");
ef->ef_nsegs = nsegs;
if (phdyn == NULL) {
- warnx("file isn't dynamically-linked");
+ warnx("Skipping %s: not dynamically-linked",
+ filename);
break;
}
if (ef_read_entry(ef, phdyn->p_offset,
diff --git a/usr.sbin/lastlogin/Makefile.depend b/usr.sbin/lastlogin/Makefile.depend
new file mode 100644
index 0000000..a839545
--- /dev/null
+++ b/usr.sbin/lastlogin/Makefile.depend
@@ -0,0 +1,19 @@
+# Autogenerated - do NOT edit!
+
+DEP_RELDIR := ${_PARSEDIR:S,${SRCTOP}/,,}
+
+DEP_MACHINE := ${.PARSEFILE:E}
+
+DIRDEPS = \
+ gnu/lib/libgcc \
+ include \
+ include/xlocale \
+ lib/${CSU_DIR} \
+ lib/libc \
+
+
+.include <dirdeps.mk>
+
+.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+# local dependencies - needed for -jN in clean tree
+.endif
diff --git a/usr.sbin/lmcconfig/Makefile.depend b/usr.sbin/lmcconfig/Makefile.depend
new file mode 100644
index 0000000..e6d80d3
--- /dev/null
+++ b/usr.sbin/lmcconfig/Makefile.depend
@@ -0,0 +1,20 @@
+# Autogenerated - do NOT edit!
+
+DEP_RELDIR := ${_PARSEDIR:S,${SRCTOP}/,,}
+
+DEP_MACHINE := ${.PARSEFILE:E}
+
+DIRDEPS = \
+ gnu/lib/libgcc \
+ include \
+ include/xlocale \
+ lib/${CSU_DIR} \
+ lib/libc \
+ lib/libnetgraph \
+
+
+.include <dirdeps.mk>
+
+.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+# local dependencies - needed for -jN in clean tree
+.endif
diff --git a/usr.sbin/lmcconfig/lmcconfig.c b/usr.sbin/lmcconfig/lmcconfig.c
index ece19f7..7fbc216 100644
--- a/usr.sbin/lmcconfig/lmcconfig.c
+++ b/usr.sbin/lmcconfig/lmcconfig.c
@@ -1074,18 +1074,16 @@ print_hssi_sigs(void)
static void
print_events(void)
{
- char *time;
- struct timeval tv;
- struct timezone tz;
+ const char *reset_time;
+ time_t now;
- gettimeofday(&tv, &tz);
- time = (char *)ctime((time_t *)&tv);
- printf("Current time:\t\t%s", time);
+ now = time(NULL);
+ printf("Current time:\t\t%s", ctime(&now));
if (status.cntrs.reset_time.tv_sec < 1000)
- time = "Never\n";
+ reset_time = "Never\n";
else
- time = (char *)ctime((time_t *)&status.cntrs.reset_time.tv_sec);
- printf("Cntrs reset:\t\t%s", time);
+ reset_time = ctime(&status.cntrs.reset_time.tv_sec);
+ printf("Cntrs reset:\t\t%s", reset_time);
if (status.cntrs.ibytes) printf("Rx bytes:\t\t%ju\n", (uintmax_t)status.cntrs.ibytes);
if (status.cntrs.obytes) printf("Tx bytes:\t\t%ju\n", (uintmax_t)status.cntrs.obytes);
diff --git a/usr.sbin/lpr/chkprintcap/Makefile.depend b/usr.sbin/lpr/chkprintcap/Makefile.depend
new file mode 100644
index 0000000..2eeeb7a
--- /dev/null
+++ b/usr.sbin/lpr/chkprintcap/Makefile.depend
@@ -0,0 +1,20 @@
+# Autogenerated - do NOT edit!
+
+DEP_RELDIR := ${_PARSEDIR:S,${SRCTOP}/,,}
+
+DEP_MACHINE := ${.PARSEFILE:E}
+
+DIRDEPS = \
+ gnu/lib/libgcc \
+ include \
+ include/xlocale \
+ lib/${CSU_DIR} \
+ lib/libc \
+ usr.sbin/lpr/common_source \
+
+
+.include <dirdeps.mk>
+
+.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+# local dependencies - needed for -jN in clean tree
+.endif
diff --git a/usr.sbin/lpr/common_source/Makefile.depend b/usr.sbin/lpr/common_source/Makefile.depend
new file mode 100644
index 0000000..e54ec8c
--- /dev/null
+++ b/usr.sbin/lpr/common_source/Makefile.depend
@@ -0,0 +1,17 @@
+# Autogenerated - do NOT edit!
+
+DEP_RELDIR := ${_PARSEDIR:S,${SRCTOP}/,,}
+
+DEP_MACHINE := ${.PARSEFILE:E}
+
+DIRDEPS = \
+ include \
+ include/arpa \
+ include/xlocale \
+
+
+.include <dirdeps.mk>
+
+.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+# local dependencies - needed for -jN in clean tree
+.endif
diff --git a/usr.sbin/lpr/common_source/common.c b/usr.sbin/lpr/common_source/common.c
index 819d7dd..93657d9 100644
--- a/usr.sbin/lpr/common_source/common.c
+++ b/usr.sbin/lpr/common_source/common.c
@@ -52,6 +52,7 @@ __FBSDID("$FreeBSD$");
#include <ctype.h>
#include <dirent.h>
+#include <err.h>
#include <errno.h>
#include <fcntl.h>
#include <stdio.h>
@@ -69,8 +70,6 @@ __FBSDID("$FreeBSD$");
char line[BUFSIZ];
const char *progname; /* program name */
-extern uid_t uid, euid;
-
static int compar(const void *_p1, const void *_p2);
/*
@@ -125,20 +124,22 @@ getq(const struct printer *pp, struct jobqueue *(*namelist[]))
DIR *dirp;
int statres;
- seteuid(euid);
+ PRIV_START
if ((dirp = opendir(pp->spool_dir)) == NULL) {
- seteuid(uid);
+ PRIV_END
return (-1);
}
if (fstat(dirfd(dirp), &stbuf) < 0)
goto errdone;
- seteuid(uid);
+ PRIV_END
/*
* Estimate the array size by taking the size of the directory file
- * and dividing it by a multiple of the minimum size entry.
+ * and dividing it by a multiple of the minimum size entry.
*/
arraysz = (stbuf.st_size / 24);
+ if (arraysz < 16)
+ arraysz = 16;
queue = (struct jobqueue **)malloc(arraysz * sizeof(struct jobqueue *));
if (queue == NULL)
goto errdone;
@@ -147,9 +148,9 @@ getq(const struct printer *pp, struct jobqueue *(*namelist[]))
while ((d = readdir(dirp)) != NULL) {
if (d->d_name[0] != 'c' || d->d_name[1] != 'f')
continue; /* daemon control files only */
- seteuid(euid);
+ PRIV_START
statres = stat(d->d_name, &stbuf);
- seteuid(uid);
+ PRIV_END
if (statres < 0)
continue; /* Doesn't exist */
entrysz = sizeof(struct jobqueue) - sizeof(q->job_cfname) +
@@ -182,7 +183,7 @@ getq(const struct printer *pp, struct jobqueue *(*namelist[]))
errdone:
closedir(dirp);
- seteuid(uid);
+ PRIV_END
return (-1);
}
@@ -338,10 +339,10 @@ set_qstate(int action, const char *lfname)
* Find what the current access-bits are.
*/
memset(&stbuf, 0, sizeof(stbuf));
- seteuid(euid);
+ PRIV_START
statres = stat(lfname, &stbuf);
errsav = errno;
- seteuid(uid);
+ PRIV_END
if ((statres < 0) && (errsav != ENOENT)) {
printf("\tcannot stat() lock file\n");
return (SQS_STATFAIL);
@@ -400,10 +401,10 @@ set_qstate(int action, const char *lfname)
res = 0;
if (statres >= 0) {
/* The file already exists, so change the access. */
- seteuid(euid);
+ PRIV_START
chres = chmod(lfname, chgbits);
errsav = errno;
- seteuid(uid);
+ PRIV_END
res = SQS_CHGOK;
if (chres < 0)
res = SQS_CHGFAIL;
@@ -422,10 +423,10 @@ set_qstate(int action, const char *lfname)
* all the read/write bits are set as desired.
*/
oldmask = umask(S_IWOTH);
- seteuid(euid);
+ PRIV_START
fd = open(lfname, O_WRONLY|O_CREAT, newbits);
errsav = errno;
- seteuid(uid);
+ PRIV_END
umask(oldmask);
res = SQS_CREFAIL;
if (fd >= 0) {
@@ -641,7 +642,7 @@ trstat_write(struct printer *pp, tr_sendrecv sendrecv, size_t bytecnt,
* secs=<n> - seconds it took to transfer the file
* bytes=<n> - number of bytes transfered (ie, "bytecount")
* bps=<n.n>e<n> - Bytes/sec (if the transfer was "big enough"
- * for this to be useful)
+ * for this to be useful)
* ! top=<str> - type of printer (if the type is defined in
* printcap, and if this statline is for sending
* a file to that ptr)
@@ -719,7 +720,7 @@ trstat_write(struct printer *pp, tr_sendrecv sendrecv, size_t bytecnt,
if (remspace > 1) {
strcpy(eostat, "\n");
} else {
- /* probably should back up to just before the final " x=".. */
+ /* probably should back up to just before the final " x=".. */
strcpy(statline+STATLINE_SIZE-2, "\n");
}
statfile = open(statfname, O_WRONLY|O_APPEND, 0664);
@@ -732,7 +733,7 @@ trstat_write(struct printer *pp, tr_sendrecv sendrecv, size_t bytecnt,
close(statfile);
return;
-#undef UPD_EOSTAT
+#undef UPD_EOSTAT
}
#include <stdarg.h>
diff --git a/usr.sbin/lpr/common_source/displayq.c b/usr.sbin/lpr/common_source/displayq.c
index 061b370..3c038d6 100644
--- a/usr.sbin/lpr/common_source/displayq.c
+++ b/usr.sbin/lpr/common_source/displayq.c
@@ -41,6 +41,7 @@ __FBSDID("$FreeBSD$");
#include <ctype.h>
#include <dirent.h>
+#include <err.h>
#include <errno.h>
#include <fcntl.h>
#include <signal.h>
@@ -74,8 +75,6 @@ __FBSDID("$FreeBSD$");
/*
* Stuff for handling job specifications
*/
-extern uid_t uid, euid;
-
static int col; /* column on screen */
static char current[MAXNAMLEN+1]; /* current file being printed */
static char file[MAXNAMLEN+1]; /* print file name */
@@ -90,7 +89,7 @@ static const char *head1 = "Total Size\n";
static void alarmhandler(int _signo);
static void filtered_write(char *_obuffer, int _wlen, FILE *_wstream);
-static void warn(const struct printer *_pp);
+static void daemonwarn(const struct printer *_pp);
/*
* Display the current state of the queue. Format = 1 if long format.
@@ -119,24 +118,24 @@ displayq(struct printer *pp, int format)
* Print out local queue
* Find all the control files in the spooling directory
*/
- seteuid(euid);
+ PRIV_START
if (chdir(pp->spool_dir) < 0)
fatal(pp, "cannot chdir to spooling directory: %s",
strerror(errno));
- seteuid(uid);
+ PRIV_END
if ((nitems = getq(pp, &queue)) < 0)
fatal(pp, "cannot examine spooling area\n");
- seteuid(euid);
+ PRIV_START
ret = stat(pp->lock_file, &statb);
- seteuid(uid);
+ PRIV_END
if (ret >= 0) {
if (statb.st_mode & LFM_PRINT_DIS) {
if (pp->remote)
printf("%s: ", local_host);
printf("Warning: %s is down: ", pp->printer);
- seteuid(euid);
+ PRIV_START
fd = open(pp->status_file, O_RDONLY|O_SHLOCK);
- seteuid(uid);
+ PRIV_END
if (fd >= 0) {
while ((i = read(fd, line, sizeof(line))) > 0)
(void) fwrite(line, 1, i, stdout);
@@ -153,11 +152,11 @@ displayq(struct printer *pp, int format)
}
if (nitems) {
- seteuid(euid);
+ PRIV_START
fp = fopen(pp->lock_file, "r");
- seteuid(uid);
+ PRIV_END
if (fp == NULL)
- warn(pp);
+ daemonwarn(pp);
else {
/* get daemon pid */
cp = current;
@@ -171,12 +170,12 @@ displayq(struct printer *pp, int format)
if (i <= 0) {
ret = -1;
} else {
- seteuid(euid);
+ PRIV_START
ret = kill(i, 0);
- seteuid(uid);
+ PRIV_END
}
if (ret < 0) {
- warn(pp);
+ daemonwarn(pp);
} else {
/* read current file name */
cp = current;
@@ -191,9 +190,9 @@ displayq(struct printer *pp, int format)
*/
if (pp->remote)
printf("%s: ", local_host);
- seteuid(euid);
+ PRIV_START
fd = open(pp->status_file, O_RDONLY|O_SHLOCK);
- seteuid(uid);
+ PRIV_END
if (fd >= 0) {
while ((i = read(fd, line,
sizeof(line))) > 0)
@@ -360,7 +359,7 @@ check_next:
* Print a warning message if there is no daemon present.
*/
static void
-warn(const struct printer *pp)
+daemonwarn(const struct printer *pp)
{
if (pp->remote)
printf("%s: ", local_host);
@@ -391,10 +390,10 @@ inform(const struct printer *pp, char *cf)
* There's a chance the control file has gone away
* in the meantime; if this is the case just keep going
*/
- seteuid(euid);
+ PRIV_START
if ((cfp = fopen(cf, "r")) == NULL)
return;
- seteuid(uid);
+ PRIV_END
if (rank < 0)
rank = 0;
@@ -578,10 +577,10 @@ dump(const char *nfile, const char *datafile, int copies)
}
first = 0;
- seteuid(euid);
+ PRIV_START
if (*datafile && !stat(datafile, &lbuf))
totsize += copies * lbuf.st_size;
- seteuid(uid);
+ PRIV_END
}
/*
diff --git a/usr.sbin/lpr/common_source/lp.h b/usr.sbin/lpr/common_source/lp.h
index b7ebff6..fb05d2f 100644
--- a/usr.sbin/lpr/common_source/lp.h
+++ b/usr.sbin/lpr/common_source/lp.h
@@ -249,6 +249,20 @@ typedef enum { TR_SENDING, TR_RECVING, TR_PRINTING } tr_sendrecv;
#define CMD_SHOWQ_LONG '\4'
#define CMD_RMJOB '\5'
+/*
+ * seteuid() macros.
+*/
+
+extern uid_t uid, euid;
+
+#define PRIV_START { \
+ if (seteuid(euid) != 0) err(1, "seteuid failed"); \
+}
+#define PRIV_END { \
+ if (seteuid(uid) != 0) err(1, "seteuid failed"); \
+}
+
+
#include "lp.cdefs.h" /* A cross-platform version of <sys/cdefs.h> */
__BEGIN_DECLS
diff --git a/usr.sbin/lpr/common_source/net.c b/usr.sbin/lpr/common_source/net.c
index 2a1e0c8..ab6fa16 100644
--- a/usr.sbin/lpr/common_source/net.c
+++ b/usr.sbin/lpr/common_source/net.c
@@ -52,6 +52,7 @@ __FBSDID("$FreeBSD$");
#include <netdb.h>
#include <dirent.h> /* required for lp.h, not used here */
+#include <err.h>
#include <errno.h>
#include <stdarg.h>
#include <stdio.h>
@@ -79,8 +80,6 @@ u_char family = PF_UNSPEC;
u_char family = PF_INET;
#endif
-extern uid_t uid, euid;
-
/*
* Create a TCP connection to host "rhost" at port "rport".
* If rport == 0, then use the printer service port.
@@ -91,7 +90,7 @@ getport(const struct printer *pp, const char *rhost, int rport)
{
struct addrinfo hints, *res, *ai;
int s, timo = 1, lport = IPPORT_RESERVED - 1;
- int err, refused = 0;
+ int error, refused = 0;
/*
* Get the host address and port number to connect to.
@@ -102,10 +101,10 @@ getport(const struct printer *pp, const char *rhost, int rport)
hints.ai_family = family;
hints.ai_socktype = SOCK_STREAM;
hints.ai_protocol = 0;
- err = getaddrinfo(rhost, (rport == 0 ? "printer" : NULL),
+ error = getaddrinfo(rhost, (rport == 0 ? "printer" : NULL),
&hints, &res);
- if (err)
- fatal(pp, "%s\n", gai_strerror(err));
+ if (error)
+ fatal(pp, "%s\n", gai_strerror(error));
if (rport != 0)
((struct sockaddr_in *) res->ai_addr)->sin_port = htons(rport);
@@ -114,9 +113,9 @@ getport(const struct printer *pp, const char *rhost, int rport)
*/
ai = res;
retry:
- seteuid(euid);
+ PRIV_START
s = rresvport_af(&lport, ai->ai_family);
- seteuid(uid);
+ PRIV_END
if (s < 0) {
if (errno != EAGAIN) {
if (ai->ai_next) {
@@ -135,9 +134,9 @@ retry:
return(-1);
}
if (connect(s, ai->ai_addr, ai->ai_addrlen) < 0) {
- err = errno;
+ error = errno;
(void) close(s);
- errno = err;
+ errno = error;
/*
* This used to decrement lport, but the current semantics
* of rresvport do not provide such a function (in fact,
@@ -184,8 +183,8 @@ checkremote(struct printer *pp)
{
char lclhost[MAXHOSTNAMELEN];
struct addrinfo hints, *local_res, *remote_res, *lr, *rr;
- char *err;
- int ncommonaddrs, error;
+ char *error;
+ int ncommonaddrs, errno;
char h1[NI_MAXHOST], h2[NI_MAXHOST];
if (!pp->rp_matches_local) { /* Remote printer doesn't match local */
@@ -205,11 +204,11 @@ checkremote(struct printer *pp)
hints.ai_family = family;
hints.ai_socktype = SOCK_STREAM;
hints.ai_flags = AI_PASSIVE;
- if ((error = getaddrinfo(lclhost, NULL, &hints, &local_res)) != 0) {
- asprintf(&err, "unable to get official name "
+ if ((errno = getaddrinfo(lclhost, NULL, &hints, &local_res)) != 0) {
+ asprintf(&error, "unable to get official name "
"for local machine %s: %s",
- lclhost, gai_strerror(error));
- return err;
+ lclhost, gai_strerror(errno));
+ return error;
}
/* get the official name of RM */
@@ -217,13 +216,13 @@ checkremote(struct printer *pp)
hints.ai_family = family;
hints.ai_socktype = SOCK_STREAM;
hints.ai_flags = AI_PASSIVE;
- if ((error = getaddrinfo(pp->remote_host, NULL,
+ if ((errno = getaddrinfo(pp->remote_host, NULL,
&hints, &remote_res)) != 0) {
- asprintf(&err, "unable to get address list for "
+ asprintf(&error, "unable to get address list for "
"remote machine %s: %s",
- pp->remote_host, gai_strerror(error));
+ pp->remote_host, gai_strerror(errno));
freeaddrinfo(local_res);
- return err;
+ return error;
}
ncommonaddrs = 0;
diff --git a/usr.sbin/lpr/common_source/rmjob.c b/usr.sbin/lpr/common_source/rmjob.c
index 912a48f..c89a6f0 100644
--- a/usr.sbin/lpr/common_source/rmjob.c
+++ b/usr.sbin/lpr/common_source/rmjob.c
@@ -41,6 +41,7 @@ __FBSDID("$FreeBSD$");
#include <ctype.h>
#include <dirent.h>
+#include <err.h>
#include <errno.h>
#include <signal.h>
#include <stdio.h>
@@ -68,8 +69,6 @@ static int all = 0; /* eliminate all files (root only) */
static int cur_daemon; /* daemon's pid */
static char current[7+MAXHOSTNAMELEN]; /* active control file name */
-extern uid_t uid, euid; /* real and effective user id's */
-
static void alarmhandler(int _signo);
static void do_unlink(char *_file);
static int isowner(char *_owner, char *_file, const char *_cfhost);
@@ -110,12 +109,12 @@ rmjob(const char *printer)
person = root;
}
- seteuid(euid);
+ PRIV_START
if (chdir(pp->spool_dir) < 0)
fatal(pp, "cannot chdir to spool directory");
if ((nitems = scandir(".", &files, iscf, NULL)) < 0)
fatal(pp, "cannot access spool directory");
- seteuid(uid);
+ PRIV_END
if (nitems) {
/*
@@ -124,9 +123,9 @@ rmjob(const char *printer)
* (after which we have to restart the daemon).
*/
if (lockchk(pp, pp->lock_file) && chk(current)) {
- seteuid(euid);
+ PRIV_START
assassinated = kill(cur_daemon, SIGINT) == 0;
- seteuid(uid);
+ PRIV_END
if (!assassinated)
fatal(pp, "cannot kill printer daemon");
}
@@ -156,14 +155,14 @@ lockchk(struct printer *pp, char *slockf)
register FILE *fp;
register int i, n;
- seteuid(euid);
+ PRIV_START
if ((fp = fopen(slockf, "r")) == NULL) {
if (errno == EACCES)
fatal(pp, "%s: %s", slockf, strerror(errno));
else
return(0);
}
- seteuid(uid);
+ PRIV_END
if (!getline(fp)) {
(void) fclose(fp);
return(0); /* no daemon present */
@@ -195,10 +194,10 @@ process(const struct printer *pp, char *file)
if (!chk(file))
return;
- seteuid(euid);
+ PRIV_START
if ((cfp = fopen(file, "r")) == NULL)
fatal(pp, "cannot open %s", file);
- seteuid(uid);
+ PRIV_END
while (getline(cfp)) {
switch (line[0]) {
case 'U': /* unlink associated files */
@@ -218,9 +217,9 @@ do_unlink(char *file)
if (from_host != local_host)
printf("%s: ", local_host);
- seteuid(euid);
+ PRIV_START
ret = unlink(file);
- seteuid(uid);
+ PRIV_END
printf(ret ? "cannot dequeue %s\n" : "%s dequeued\n", file);
}
@@ -248,10 +247,10 @@ chk(char *file)
/*
* get the owner's name from the control file.
*/
- seteuid(euid);
+ PRIV_START
if ((cfp = fopen(file, "r")) == NULL)
return(0);
- seteuid(uid);
+ PRIV_END
while (getline(cfp)) {
if (line[0] == 'P')
break;
diff --git a/usr.sbin/lpr/common_source/startdaemon.c b/usr.sbin/lpr/common_source/startdaemon.c
index b175d79..8e4f60a 100644
--- a/usr.sbin/lpr/common_source/startdaemon.c
+++ b/usr.sbin/lpr/common_source/startdaemon.c
@@ -49,8 +49,6 @@ __FBSDID("$FreeBSD$");
#include "lp.h"
#include "pathnames.h"
-extern uid_t uid, euid;
-
/*
* Tell the printer daemon that there are new files in the spool directory.
*/
@@ -74,9 +72,9 @@ startdaemon(const struct printer *pp)
#ifndef SUN_LEN
#define SUN_LEN(unp) (strlen((unp)->sun_path) + 2)
#endif
- seteuid(euid);
+ PRIV_START
connectres = connect(s, (struct sockaddr *)&un, SUN_LEN(&un));
- seteuid(uid);
+ PRIV_END
if (connectres < 0) {
warn("Unable to connect to %s", _PATH_SOCKETNAME);
warnx("Check to see if the master 'lpd' process is running.");
diff --git a/usr.sbin/lpr/filters.ru/Makefile.depend b/usr.sbin/lpr/filters.ru/Makefile.depend
new file mode 100644
index 0000000..29fda55
--- /dev/null
+++ b/usr.sbin/lpr/filters.ru/Makefile.depend
@@ -0,0 +1,14 @@
+# Autogenerated - do NOT edit!
+
+DEP_RELDIR := ${_PARSEDIR:S,${SRCTOP}/,,}
+
+DEP_MACHINE := ${.PARSEFILE:E}
+
+DIRDEPS = \
+
+
+.include <dirdeps.mk>
+
+.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+# local dependencies - needed for -jN in clean tree
+.endif
diff --git a/usr.sbin/lpr/filters.ru/koi2855/Makefile.depend b/usr.sbin/lpr/filters.ru/koi2855/Makefile.depend
new file mode 100644
index 0000000..ac1b131
--- /dev/null
+++ b/usr.sbin/lpr/filters.ru/koi2855/Makefile.depend
@@ -0,0 +1,18 @@
+# Autogenerated - do NOT edit!
+
+DEP_RELDIR := ${_PARSEDIR:S,${SRCTOP}/,,}
+
+DEP_MACHINE := ${.PARSEFILE:E}
+
+DIRDEPS = \
+ gnu/lib/libgcc \
+ include \
+ lib/${CSU_DIR} \
+ lib/libc \
+
+
+.include <dirdeps.mk>
+
+.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+# local dependencies - needed for -jN in clean tree
+.endif
diff --git a/usr.sbin/lpr/filters.ru/koi2alt/Makefile.depend b/usr.sbin/lpr/filters.ru/koi2alt/Makefile.depend
new file mode 100644
index 0000000..ac1b131
--- /dev/null
+++ b/usr.sbin/lpr/filters.ru/koi2alt/Makefile.depend
@@ -0,0 +1,18 @@
+# Autogenerated - do NOT edit!
+
+DEP_RELDIR := ${_PARSEDIR:S,${SRCTOP}/,,}
+
+DEP_MACHINE := ${.PARSEFILE:E}
+
+DIRDEPS = \
+ gnu/lib/libgcc \
+ include \
+ lib/${CSU_DIR} \
+ lib/libc \
+
+
+.include <dirdeps.mk>
+
+.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+# local dependencies - needed for -jN in clean tree
+.endif
diff --git a/usr.sbin/lpr/filters/Makefile.depend b/usr.sbin/lpr/filters/Makefile.depend
new file mode 100644
index 0000000..a839545
--- /dev/null
+++ b/usr.sbin/lpr/filters/Makefile.depend
@@ -0,0 +1,19 @@
+# Autogenerated - do NOT edit!
+
+DEP_RELDIR := ${_PARSEDIR:S,${SRCTOP}/,,}
+
+DEP_MACHINE := ${.PARSEFILE:E}
+
+DIRDEPS = \
+ gnu/lib/libgcc \
+ include \
+ include/xlocale \
+ lib/${CSU_DIR} \
+ lib/libc \
+
+
+.include <dirdeps.mk>
+
+.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+# local dependencies - needed for -jN in clean tree
+.endif
diff --git a/usr.sbin/lpr/filters/lpf.c b/usr.sbin/lpr/filters/lpf.c
index b277d17..f8ffe52 100644
--- a/usr.sbin/lpr/filters/lpf.c
+++ b/usr.sbin/lpr/filters/lpf.c
@@ -60,17 +60,17 @@ __FBSDID("$FreeBSD$");
#define MAXWIDTH 132
#define MAXREP 10
-char buf[MAXREP][MAXWIDTH];
-int maxcol[MAXREP] = {-1};
-int lineno;
-int width = 132; /* default line length */
-int length = 66; /* page length */
-int indent; /* indentation length */
-int npages = 1;
-int literal; /* print control characters */
-char *name; /* user's login name */
-char *host; /* user's machine name */
-char *acctfile; /* accounting information file */
+static char buf[MAXREP][MAXWIDTH];
+static int maxcol[MAXREP] = {-1};
+static int lineno;
+static int width = 132; /* default line length */
+static int length = 66; /* page length */
+static int indent; /* indentation length */
+static int npages = 1;
+static int literal; /* print control characters */
+static char *name; /* user's login name */
+static char *host; /* user's machine name */
+static char *acctfile; /* accounting information file */
int
main(int argc, char *argv[])
diff --git a/usr.sbin/lpr/lp/Makefile.depend b/usr.sbin/lpr/lp/Makefile.depend
new file mode 100644
index 0000000..29fda55
--- /dev/null
+++ b/usr.sbin/lpr/lp/Makefile.depend
@@ -0,0 +1,14 @@
+# Autogenerated - do NOT edit!
+
+DEP_RELDIR := ${_PARSEDIR:S,${SRCTOP}/,,}
+
+DEP_MACHINE := ${.PARSEFILE:E}
+
+DIRDEPS = \
+
+
+.include <dirdeps.mk>
+
+.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+# local dependencies - needed for -jN in clean tree
+.endif
diff --git a/usr.sbin/lpr/lpc/Makefile.depend b/usr.sbin/lpr/lpc/Makefile.depend
new file mode 100644
index 0000000..529eecd
--- /dev/null
+++ b/usr.sbin/lpr/lpc/Makefile.depend
@@ -0,0 +1,22 @@
+# Autogenerated - do NOT edit!
+
+DEP_RELDIR := ${_PARSEDIR:S,${SRCTOP}/,,}
+
+DEP_MACHINE := ${.PARSEFILE:E}
+
+DIRDEPS = \
+ gnu/lib/libgcc \
+ include \
+ include/xlocale \
+ lib/${CSU_DIR} \
+ lib/libc \
+ lib/libedit \
+ lib/ncurses/ncurses \
+ usr.sbin/lpr/common_source \
+
+
+.include <dirdeps.mk>
+
+.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+# local dependencies - needed for -jN in clean tree
+.endif
diff --git a/usr.sbin/lpr/lpc/cmds.c b/usr.sbin/lpr/lpc/cmds.c
index 44516d8..f960f7c 100644
--- a/usr.sbin/lpr/lpc/cmds.c
+++ b/usr.sbin/lpr/lpc/cmds.c
@@ -54,6 +54,7 @@ __FBSDID("$FreeBSD$");
#include <signal.h>
#include <fcntl.h>
+#include <err.h>
#include <errno.h>
#include <dirent.h>
#include <unistd.h>
@@ -288,10 +289,10 @@ kill_qtask(const char *lf)
pid_t pid;
int errsav, killres, lockres, res;
- seteuid(euid);
+ PRIV_START
fp = fopen(lf, "r");
errsav = errno;
- seteuid(uid);
+ PRIV_END
res = KQT_NODAEMON;
if (fp == NULL) {
/*
@@ -329,10 +330,10 @@ kill_qtask(const char *lf)
goto killdone;
}
- seteuid(uid);
+ PRIV_END
killres = kill(pid, SIGTERM);
errsav = errno;
- seteuid(uid);
+ PRIV_END
if (killres == 0) {
res = KQT_KILLOK;
printf("\tdaemon (pid %d) killed\n", pid);
@@ -376,9 +377,9 @@ upstat(struct printer *pp, const char *msg, int notifyuser)
status_file_name(pp, statfile, sizeof statfile);
umask(0);
- seteuid(euid);
+ PRIV_START
fd = open(statfile, O_WRONLY|O_CREAT|O_EXLOCK, STAT_FILE_MODE);
- seteuid(uid);
+ PRIV_END
if (fd < 0) {
printf("\tcannot create status file: %s\n", strerror(errno));
return;
@@ -683,9 +684,9 @@ clean_q(struct printer *pp)
linerem = sizeof(line) - (lp - line);
cln_foundcore = 0;
- seteuid(euid);
+ PRIV_START
nitems = scandir(pp->spool_dir, &queue, doselect, sortq);
- seteuid(uid);
+ PRIV_END
if (nitems < 0) {
if (!didhead) {
printf("%s:\n", pp->printer);
@@ -795,9 +796,9 @@ unlinkf(char *name)
* that case, we need to check the last-mod time of the symlink, and
* not the file that the symlink is pointed at.
*/
- seteuid(euid);
+ PRIV_START
res = lstat(name, &stbuf);
- seteuid(uid);
+ PRIV_END
if (res < 0) {
printf("\terror return from stat(%s):\n", name);
printf("\t %s\n", strerror(errno));
@@ -819,9 +820,9 @@ unlinkf(char *name)
* symlink before unlink-ing the file itself
*/
if (S_ISLNK(stbuf.st_mode)) {
- seteuid(euid);
+ PRIV_START
res = readlink(name, linkbuf, sizeof(linkbuf));
- seteuid(uid);
+ PRIV_END
if (res < 0) {
printf("\terror return from readlink(%s):\n", name);
printf("\t %s\n", strerror(errno));
@@ -841,9 +842,9 @@ unlinkf(char *name)
printf("\t (which is a symlink to %s)\n", linkbuf);
}
} else {
- seteuid(euid);
+ PRIV_START
res = unlink(name);
- seteuid(uid);
+ PRIV_END
if (res < 0)
printf("\tcannot remove %s (!)\n", name);
else
@@ -983,9 +984,9 @@ restart_q(struct printer *pp)
/* make sure the queue is set to print jobs */
setres = set_qstate(SQS_STARTP, lf);
- seteuid(euid);
+ PRIV_START
startok = startdaemon(pp);
- seteuid(uid);
+ PRIV_END
if (!startok)
printf("\tcouldn't restart daemon\n");
else
@@ -1049,14 +1050,14 @@ start_q(struct printer *pp)
setres = set_qstate(SQS_STARTP, lf);
- seteuid(euid);
+ PRIV_START
startok = startdaemon(pp);
- seteuid(uid);
+ PRIV_END
if (!startok)
printf("\tcouldn't start daemon\n");
else
printf("\tdaemon started\n");
- seteuid(uid);
+ PRIV_END
}
/*
@@ -1178,12 +1179,12 @@ topq(int argc, char *argv[])
}
printf("%s:\n", pp->printer);
- seteuid(euid);
+ PRIV_START
if (chdir(pp->spool_dir) < 0) {
printf("\tcannot chdir to %s\n", pp->spool_dir);
goto out;
}
- seteuid(uid);
+ PRIV_END
nitems = getq(pp, &queue);
if (nitems == 0)
return;
@@ -1207,12 +1208,12 @@ topq(int argc, char *argv[])
* Turn on the public execute bit of the lock file to
* get lpd to rebuild the queue after the current job.
*/
- seteuid(euid);
+ PRIV_START
if (changed && stat(pp->lock_file, &stbuf) >= 0)
(void) chmod(pp->lock_file, stbuf.st_mode | LFM_RESET_QUE);
out:
- seteuid(uid);
+ PRIV_END
}
/*
@@ -1227,9 +1228,9 @@ touch(struct jobqueue *jq)
tvp[0].tv_sec = tvp[1].tv_sec = --mtime;
tvp[0].tv_usec = tvp[1].tv_usec = 0;
- seteuid(euid);
+ PRIV_START
ret = utimes(jq->job_cfname, tvp);
- seteuid(uid);
+ PRIV_END
return (ret);
}
@@ -1286,9 +1287,9 @@ doarg(char *job)
* Process item consisting of owner's name (example: henry).
*/
for (qq = queue + nitems; --qq >= queue; ) {
- seteuid(euid);
+ PRIV_START
fp = fopen((*qq)->job_cfname, "r");
- seteuid(uid);
+ PRIV_END
if (fp == NULL)
continue;
while (getline(fp) > 0)
@@ -1319,9 +1320,9 @@ up_q(struct printer *pp)
setres = set_qstate(SQS_ENABLEQ+SQS_STARTP, lf);
- seteuid(euid);
+ PRIV_START
startok = startdaemon(pp);
- seteuid(uid);
+ PRIV_END
if (!startok)
printf("\tcouldn't start daemon\n");
else
diff --git a/usr.sbin/lpr/lpc/lpc.c b/usr.sbin/lpr/lpc/lpc.c
index f9fb920..cc58bd9 100644
--- a/usr.sbin/lpr/lpc/lpc.c
+++ b/usr.sbin/lpr/lpc/lpc.c
@@ -93,7 +93,7 @@ main(int argc, char *argv[])
euid = geteuid();
uid = getuid();
- seteuid(uid);
+ PRIV_END
progname = argv[0];
openlog("lpd", 0, LOG_LPR);
@@ -405,9 +405,9 @@ setup_myprinter(char *pwanted, struct printer *pp, int sump_opts)
printf("%s:\n", pp->printer);
if (sump_opts & SUMP_CHDIR_SD) {
- seteuid(euid);
+ PRIV_START
cdres = chdir(pp->spool_dir);
- seteuid(uid);
+ PRIV_END
if (cdres < 0) {
printf("\tcannot chdir to %s\n", pp->spool_dir);
free_printer(pp);
diff --git a/usr.sbin/lpr/lpc/movejobs.c b/usr.sbin/lpr/lpc/movejobs.c
index 60c9b38..c349601 100644
--- a/usr.sbin/lpr/lpc/movejobs.c
+++ b/usr.sbin/lpr/lpc/movejobs.c
@@ -47,6 +47,7 @@ __FBSDID("$FreeBSD$");
#include <ctype.h>
#include <dirent.h> /* just for MAXNAMLEN, for job_cfname in lp.h! */
+#include <err.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -147,9 +148,9 @@ touch_jqe(void *myinfo, struct jobqueue *jq, struct jobspec *jspec)
touch_info = myinfo;
tvp[0].tv_sec = tvp[1].tv_sec = ++touch_info->newtime;
tvp[0].tv_usec = tvp[1].tv_usec = 0;
- seteuid(euid);
+ PRIV_START
ret = utimes(jq->job_cfname, tvp);
- seteuid(uid);
+ PRIV_END
if (ret == 0) {
if (jspec->matcheduser)
diff --git a/usr.sbin/lpr/lpd/Makefile.depend b/usr.sbin/lpr/lpd/Makefile.depend
new file mode 100644
index 0000000..a8a1c2b
--- /dev/null
+++ b/usr.sbin/lpr/lpd/Makefile.depend
@@ -0,0 +1,21 @@
+# Autogenerated - do NOT edit!
+
+DEP_RELDIR := ${_PARSEDIR:S,${SRCTOP}/,,}
+
+DEP_MACHINE := ${.PARSEFILE:E}
+
+DIRDEPS = \
+ gnu/lib/libgcc \
+ include \
+ include/arpa \
+ include/xlocale \
+ lib/${CSU_DIR} \
+ lib/libc \
+ usr.sbin/lpr/common_source \
+
+
+.include <dirdeps.mk>
+
+.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+# local dependencies - needed for -jN in clean tree
+.endif
diff --git a/usr.sbin/lpr/lpd/lpd.8 b/usr.sbin/lpr/lpd/lpd.8
index 34b0882..a3d7aa9 100644
--- a/usr.sbin/lpr/lpd/lpd.8
+++ b/usr.sbin/lpr/lpd/lpd.8
@@ -152,7 +152,7 @@ machine with the printer.
.Pp
The file
.Em minfree
-in each spool directory contains the number of disk blocks to leave free
+in each spool directory contains the number of kilobytes to leave free
so that the line printer queue will not completely fill the disk.
The
.Em minfree
diff --git a/usr.sbin/lpr/lpd/printjob.c b/usr.sbin/lpr/lpd/printjob.c
index 2407c3c..9771498 100644
--- a/usr.sbin/lpr/lpd/printjob.c
+++ b/usr.sbin/lpr/lpd/printjob.c
@@ -61,6 +61,7 @@ __FBSDID("$FreeBSD$");
#include <syslog.h>
#include <fcntl.h>
#include <dirent.h>
+#include <err.h>
#include <errno.h>
#include <inttypes.h>
#include <stdio.h>
@@ -173,7 +174,7 @@ printjob(struct printer *pp)
pp->log_file);
(void) open(_PATH_DEVNULL, O_WRONLY);
}
- setgid(getegid());
+ if(setgid(getegid()) != 0) err(1, "setgid() failed");
printpid = getpid(); /* for use with lprm */
setpgrp(0, printpid);
@@ -1788,7 +1789,7 @@ openpr(const struct printer *pp)
of_pid = 0;
return;
} else if (*pp->lp) {
- if ((cp = strchr(pp->lp, '@')) != NULL)
+ if (strchr(pp->lp, '@') != NULL)
opennet(pp);
else
opentty(pp);
diff --git a/usr.sbin/lpr/lpq/Makefile.depend b/usr.sbin/lpr/lpq/Makefile.depend
new file mode 100644
index 0000000..2eeeb7a
--- /dev/null
+++ b/usr.sbin/lpr/lpq/Makefile.depend
@@ -0,0 +1,20 @@
+# Autogenerated - do NOT edit!
+
+DEP_RELDIR := ${_PARSEDIR:S,${SRCTOP}/,,}
+
+DEP_MACHINE := ${.PARSEFILE:E}
+
+DIRDEPS = \
+ gnu/lib/libgcc \
+ include \
+ include/xlocale \
+ lib/${CSU_DIR} \
+ lib/libc \
+ usr.sbin/lpr/common_source \
+
+
+.include <dirdeps.mk>
+
+.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+# local dependencies - needed for -jN in clean tree
+.endif
diff --git a/usr.sbin/lpr/lpq/lpq.c b/usr.sbin/lpr/lpq/lpq.c
index 33082e5..f39c81b 100644
--- a/usr.sbin/lpr/lpq/lpq.c
+++ b/usr.sbin/lpr/lpq/lpq.c
@@ -88,7 +88,7 @@ main(int argc, char **argv)
printer = NULL;
euid = geteuid();
uid = getuid();
- seteuid(uid);
+ PRIV_END
progname = *argv;
if (gethostname(local_host, sizeof(local_host)))
err(1, "gethostname");
diff --git a/usr.sbin/lpr/lpr/Makefile.depend b/usr.sbin/lpr/lpr/Makefile.depend
new file mode 100644
index 0000000..2eeeb7a
--- /dev/null
+++ b/usr.sbin/lpr/lpr/Makefile.depend
@@ -0,0 +1,20 @@
+# Autogenerated - do NOT edit!
+
+DEP_RELDIR := ${_PARSEDIR:S,${SRCTOP}/,,}
+
+DEP_MACHINE := ${.PARSEFILE:E}
+
+DIRDEPS = \
+ gnu/lib/libgcc \
+ include \
+ include/xlocale \
+ lib/${CSU_DIR} \
+ lib/libc \
+ usr.sbin/lpr/common_source \
+
+
+.include <dirdeps.mk>
+
+.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+# local dependencies - needed for -jN in clean tree
+.endif
diff --git a/usr.sbin/lpr/lpr/lpr.c b/usr.sbin/lpr/lpr/lpr.c
index 9ae72f6..394ccb0 100644
--- a/usr.sbin/lpr/lpr/lpr.c
+++ b/usr.sbin/lpr/lpr/lpr.c
@@ -75,6 +75,7 @@ __FBSDID("$FreeBSD$");
#include <grp.h>
#include <unistd.h>
#include <stdlib.h>
+#include <stdint.h>
#include <stdio.h>
#include <ctype.h>
#include <string.h>
@@ -144,7 +145,7 @@ main(int argc, char *argv[])
printer = NULL;
euid = geteuid();
uid = getuid();
- seteuid(uid);
+ PRIV_END
if (signal(SIGHUP, SIG_IGN) != SIG_IGN)
signal(SIGHUP, cleanup);
if (signal(SIGINT, SIG_IGN) != SIG_IGN)
@@ -325,10 +326,10 @@ main(int argc, char *argv[])
*/
mktemps(pp);
tfd = nfile(tfname);
- seteuid(euid);
+ PRIV_START
(void) fchown(tfd, pp->daemon_user, -1);
/* owned by daemon for protection */
- seteuid(uid);
+ PRIV_END
card('H', local_host);
card('P', lpr_username);
card('C', class);
@@ -386,8 +387,8 @@ main(int argc, char *argv[])
continue; /* file unreasonable */
if (sflag && (cp = linked(arg)) != NULL) {
- (void) snprintf(buf, sizeof(buf), "%u %u", statb.st_dev,
- statb.st_ino);
+ (void)snprintf(buf, sizeof(buf), "%u %ju",
+ statb.st_dev, (uintmax_t)statb.st_ino);
card('S', buf);
if (format == 'p')
card('T', title ? title : arg);
@@ -414,7 +415,7 @@ main(int argc, char *argv[])
* can be very significant when running services like
* samba, pcnfs, CAP, et al.
*/
- seteuid(euid);
+ PRIV_START
didlink = 0;
/*
* There are several things to check to avoid any
@@ -452,11 +453,11 @@ main(int argc, char *argv[])
* safe. Otherwise, abandon the move and fall back
* to the (usual) copy method.
*/
- seteuid(uid);
+ PRIV_END
ret = access(dfname, R_OK);
if (ret == 0)
ret = unlink(arg);
- seteuid(euid);
+ PRIV_START
if (ret != 0)
goto nohardlink;
/*
@@ -466,7 +467,7 @@ main(int argc, char *argv[])
*/
chown(dfname, pp->daemon_user, getegid());
chmod(dfname, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP);
- seteuid(uid);
+ PRIV_END
if (format == 'p')
card('T', title ? title : arg);
for (i = 0; i < ncopies; i++)
@@ -478,7 +479,7 @@ main(int argc, char *argv[])
nohardlink:
if (didlink)
unlink(dfname);
- seteuid(uid); /* restore old uid */
+ PRIV_END /* restore old uid */
} /* end: if (f) */
if ((i = open(arg, O_RDONLY)) < 0) {
@@ -497,7 +498,7 @@ main(int argc, char *argv[])
/*
* Touch the control file to fix position in the queue.
*/
- seteuid(euid);
+ PRIV_START
if ((tfd = open(tfname, O_RDWR)) >= 0) {
char touch_c;
@@ -517,7 +518,7 @@ main(int argc, char *argv[])
cleanup(0);
}
unlink(tfname);
- seteuid(uid);
+ PRIV_END
if (qflag) /* just q things up */
exit(0);
if (!startdaemon(pp))
@@ -603,9 +604,9 @@ linked(const char *file)
strncat(buf, file, sizeof(buf) - strlen(buf) - 1);
file = buf;
}
- seteuid(euid);
+ PRIV_START
ret = symlink(file, dfname);
- seteuid(uid);
+ PRIV_END
return(ret ? NULL : file);
}
@@ -637,7 +638,7 @@ nfile(char *n)
register int f;
int oldumask = umask(0); /* should block signals */
- seteuid(euid);
+ PRIV_START
f = open(n, O_WRONLY | O_EXCL | O_CREAT, FILMOD);
(void) umask(oldumask);
if (f < 0) {
@@ -648,7 +649,7 @@ nfile(char *n)
printf("%s: cannot chown %s\n", progname, n);
cleanup(0); /* cleanup does exit */
}
- seteuid(uid);
+ PRIV_END
if (++n[inchar] > 'z') {
if (++n[inchar-2] == 't') {
printf("too many files - break up the job\n");
@@ -673,7 +674,7 @@ cleanup(int signo __unused)
signal(SIGQUIT, SIG_IGN);
signal(SIGTERM, SIG_IGN);
i = inchar;
- seteuid(euid);
+ PRIV_START
if (tfname)
do
unlink(tfname);
@@ -845,7 +846,7 @@ mktemps(const struct printer *pp)
char buf[BUFSIZ];
(void) snprintf(buf, sizeof(buf), "%s/.seq", pp->spool_dir);
- seteuid(euid);
+ PRIV_START
if ((fd = open(buf, O_RDWR|O_CREAT, 0664)) < 0) {
printf("%s: cannot create %s\n", progname, buf);
exit(1);
@@ -854,7 +855,7 @@ mktemps(const struct printer *pp)
printf("%s: cannot lock %s\n", progname, buf);
exit(1);
}
- seteuid(uid);
+ PRIV_END
n = 0;
if ((len = read(fd, buf, sizeof(buf))) > 0) {
for (cp = buf; len--; ) {
diff --git a/usr.sbin/lpr/lprm/Makefile.depend b/usr.sbin/lpr/lprm/Makefile.depend
new file mode 100644
index 0000000..2eeeb7a
--- /dev/null
+++ b/usr.sbin/lpr/lprm/Makefile.depend
@@ -0,0 +1,20 @@
+# Autogenerated - do NOT edit!
+
+DEP_RELDIR := ${_PARSEDIR:S,${SRCTOP}/,,}
+
+DEP_MACHINE := ${.PARSEFILE:E}
+
+DIRDEPS = \
+ gnu/lib/libgcc \
+ include \
+ include/xlocale \
+ lib/${CSU_DIR} \
+ lib/libc \
+ usr.sbin/lpr/common_source \
+
+
+.include <dirdeps.mk>
+
+.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+# local dependencies - needed for -jN in clean tree
+.endif
diff --git a/usr.sbin/lpr/lprm/lprm.c b/usr.sbin/lpr/lprm/lprm.c
index 741a8fa..35d8814 100644
--- a/usr.sbin/lpr/lprm/lprm.c
+++ b/usr.sbin/lpr/lprm/lprm.c
@@ -58,6 +58,7 @@ __FBSDID("$FreeBSD$");
#include <syslog.h>
#include <dirent.h>
+#include <err.h>
#include <pwd.h>
#include <unistd.h>
#include <stdlib.h>
@@ -93,7 +94,7 @@ main(int argc, char *argv[])
printer = NULL;
uid = getuid();
euid = geteuid();
- seteuid(uid); /* be safe */
+ PRIV_END /* be safe */
progname = argv[0];
gethostname(local_host, sizeof(local_host));
openlog("lpd", 0, LOG_LPR);
diff --git a/usr.sbin/lpr/lptest/Makefile.depend b/usr.sbin/lpr/lptest/Makefile.depend
new file mode 100644
index 0000000..ac1b131
--- /dev/null
+++ b/usr.sbin/lpr/lptest/Makefile.depend
@@ -0,0 +1,18 @@
+# Autogenerated - do NOT edit!
+
+DEP_RELDIR := ${_PARSEDIR:S,${SRCTOP}/,,}
+
+DEP_MACHINE := ${.PARSEFILE:E}
+
+DIRDEPS = \
+ gnu/lib/libgcc \
+ include \
+ lib/${CSU_DIR} \
+ lib/libc \
+
+
+.include <dirdeps.mk>
+
+.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+# local dependencies - needed for -jN in clean tree
+.endif
diff --git a/usr.sbin/lpr/pac/Makefile.depend b/usr.sbin/lpr/pac/Makefile.depend
new file mode 100644
index 0000000..2eeeb7a
--- /dev/null
+++ b/usr.sbin/lpr/pac/Makefile.depend
@@ -0,0 +1,20 @@
+# Autogenerated - do NOT edit!
+
+DEP_RELDIR := ${_PARSEDIR:S,${SRCTOP}/,,}
+
+DEP_MACHINE := ${.PARSEFILE:E}
+
+DIRDEPS = \
+ gnu/lib/libgcc \
+ include \
+ include/xlocale \
+ lib/${CSU_DIR} \
+ lib/libc \
+ usr.sbin/lpr/common_source \
+
+
+.include <dirdeps.mk>
+
+.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+# local dependencies - needed for -jN in clean tree
+.endif
diff --git a/usr.sbin/lptcontrol/Makefile.depend b/usr.sbin/lptcontrol/Makefile.depend
new file mode 100644
index 0000000..ac1b131
--- /dev/null
+++ b/usr.sbin/lptcontrol/Makefile.depend
@@ -0,0 +1,18 @@
+# Autogenerated - do NOT edit!
+
+DEP_RELDIR := ${_PARSEDIR:S,${SRCTOP}/,,}
+
+DEP_MACHINE := ${.PARSEFILE:E}
+
+DIRDEPS = \
+ gnu/lib/libgcc \
+ include \
+ lib/${CSU_DIR} \
+ lib/libc \
+
+
+.include <dirdeps.mk>
+
+.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+# local dependencies - needed for -jN in clean tree
+.endif
diff --git a/usr.sbin/mailstats/Makefile.depend b/usr.sbin/mailstats/Makefile.depend
new file mode 100644
index 0000000..19ee02b
--- /dev/null
+++ b/usr.sbin/mailstats/Makefile.depend
@@ -0,0 +1,24 @@
+# Autogenerated - do NOT edit!
+
+DEP_RELDIR := ${_PARSEDIR:S,${SRCTOP}/,,}
+
+DEP_MACHINE := ${.PARSEFILE:E}
+
+DIRDEPS = \
+ gnu/lib/libgcc \
+ include \
+ include/xlocale \
+ lib/${CSU_DIR} \
+ lib/libc \
+ lib/libsm \
+ lib/libsmutil \
+ lib/libutil \
+
+
+.include <dirdeps.mk>
+
+.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+# local dependencies - needed for -jN in clean tree
+mailstats.o: sm_os.h
+mailstats.po: sm_os.h
+.endif
diff --git a/usr.sbin/mailwrapper/Makefile.depend b/usr.sbin/mailwrapper/Makefile.depend
new file mode 100644
index 0000000..2dd29af
--- /dev/null
+++ b/usr.sbin/mailwrapper/Makefile.depend
@@ -0,0 +1,20 @@
+# Autogenerated - do NOT edit!
+
+DEP_RELDIR := ${_PARSEDIR:S,${SRCTOP}/,,}
+
+DEP_MACHINE := ${.PARSEFILE:E}
+
+DIRDEPS = \
+ gnu/lib/libgcc \
+ include \
+ include/xlocale \
+ lib/${CSU_DIR} \
+ lib/libc \
+ lib/libutil \
+
+
+.include <dirdeps.mk>
+
+.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+# local dependencies - needed for -jN in clean tree
+.endif
diff --git a/usr.sbin/makefs/Makefile.depend b/usr.sbin/makefs/Makefile.depend
new file mode 100644
index 0000000..887c9bd
--- /dev/null
+++ b/usr.sbin/makefs/Makefile.depend
@@ -0,0 +1,20 @@
+# Autogenerated - do NOT edit!
+
+DEP_RELDIR := ${_PARSEDIR:S,${SRCTOP}/,,}
+
+DEP_MACHINE := ${.PARSEFILE:E}
+
+DIRDEPS = \
+ gnu/lib/libgcc \
+ include \
+ include/xlocale \
+ lib/${CSU_DIR} \
+ lib/libc \
+ lib/libsbuf \
+
+
+.include <dirdeps.mk>
+
+.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+# local dependencies - needed for -jN in clean tree
+.endif
diff --git a/usr.sbin/makefs/ffs.c b/usr.sbin/makefs/ffs.c
index 13f00cf..0417d86 100644
--- a/usr.sbin/makefs/ffs.c
+++ b/usr.sbin/makefs/ffs.c
@@ -493,13 +493,25 @@ ffs_create_image(const char *image, fsinfo_t *fsopts)
bufsize = sfs.f_iosize;
#endif
bufrem = fsopts->size;
- if (debug & DEBUG_FS_CREATE_IMAGE)
- printf(
- "zero-ing image `%s', %lld sectors, using %d byte chunks\n",
- image, (long long)bufrem, bufsize);
- if ((buf = calloc(1, bufsize)) == NULL) {
- warn("Can't create buffer for sector");
- return (-1);
+ if (fsopts->sparse) {
+ if (ftruncate(fsopts->fd, bufrem) == -1) {
+ warn("sparse option disabled.\n");
+ fsopts->sparse = 0;
+ }
+ }
+ if (fsopts->sparse) {
+ /* File truncated at bufrem. Remaining is 0 */
+ bufrem = 0;
+ buf = NULL;
+ } else {
+ if (debug & DEBUG_FS_CREATE_IMAGE)
+ printf("zero-ing image `%s', %lld sectors, "
+ "using %d byte chunks\n", image, (long long)bufrem,
+ bufsize);
+ if ((buf = calloc(1, bufsize)) == NULL) {
+ warn("Can't create buffer for sector");
+ return (-1);
+ }
}
while (bufrem > 0) {
i = write(fsopts->fd, buf, MIN(bufsize, bufrem));
@@ -511,7 +523,8 @@ ffs_create_image(const char *image, fsinfo_t *fsopts)
}
bufrem -= i;
}
- free(buf);
+ if (buf)
+ free(buf);
/* make the file system */
if (debug & DEBUG_FS_CREATE_IMAGE)
diff --git a/usr.sbin/makefs/ffs/ffs_alloc.c b/usr.sbin/makefs/ffs/ffs_alloc.c
index f676a39..afab869 100644
--- a/usr.sbin/makefs/ffs/ffs_alloc.c
+++ b/usr.sbin/makefs/ffs/ffs_alloc.c
@@ -48,6 +48,7 @@ __FBSDID("$FreeBSD$");
#include <sys/time.h>
#include <errno.h>
+#include <stdint.h>
#include "makefs.h"
@@ -439,8 +440,8 @@ ffs_blkfree(struct inode *ip, daddr_t bno, long size)
}
cg = dtog(fs, bno);
if (bno >= fs->fs_size) {
- warnx("bad block %lld, ino %llu", (long long)bno,
- (unsigned long long)ip->i_number);
+ warnx("bad block %lld, ino %ju", (long long)bno,
+ (uintmax_t)ip->i_number);
return;
}
error = bread(ip->i_fd, ip->i_fs, fsbtodb(fs, cgtod(fs, cg)),
diff --git a/usr.sbin/makefs/ffs/ffs_extern.h b/usr.sbin/makefs/ffs/ffs_extern.h
index 1c3442f5..7755823 100644
--- a/usr.sbin/makefs/ffs/ffs_extern.h
+++ b/usr.sbin/makefs/ffs/ffs_extern.h
@@ -44,7 +44,6 @@ struct inode;
struct indir {
daddr_t in_lbn; /* Logical block number. */
int in_off; /* Offset in buffer. */
- int in_exists; /* Flag if the block exists. */
};
/* ffs.c */
diff --git a/usr.sbin/makefs/ffs/ufs_bmap.c b/usr.sbin/makefs/ffs/ufs_bmap.c
index 85c1d87..b65b416 100644
--- a/usr.sbin/makefs/ffs/ufs_bmap.c
+++ b/usr.sbin/makefs/ffs/ufs_bmap.c
@@ -117,7 +117,6 @@ ufs_getlbns(struct inode *ip, daddr_t bn, struct indir *ap, int *nump)
*/
ap->in_lbn = metalbn;
ap->in_off = off = NIADDR - i;
- ap->in_exists = 0;
ap++;
for (++numlevels; i <= NIADDR; i++) {
/* If searching for a meta-data block, quit when found. */
@@ -131,7 +130,6 @@ ufs_getlbns(struct inode *ip, daddr_t bn, struct indir *ap, int *nump)
++numlevels;
ap->in_lbn = metalbn;
ap->in_off = off;
- ap->in_exists = 0;
++ap;
metalbn -= -1 + (off << lbc);
diff --git a/usr.sbin/makefs/makefs.8 b/usr.sbin/makefs/makefs.8
index cc6e389..b1a5751 100644
--- a/usr.sbin/makefs/makefs.8
+++ b/usr.sbin/makefs/makefs.8
@@ -35,7 +35,7 @@
.\"
.\" $FreeBSD$
.\"
-.Dd January 30, 2012
+.Dd August 22, 2012
.Dt MAKEFS 8
.Os
.Sh NAME
@@ -43,7 +43,7 @@
.Nd create a file system image from a directory tree or a mtree manifest
.Sh SYNOPSIS
.Nm
-.Op Fl x
+.Op Fl px
.Op Fl B Ar byte-order
.Op Fl b Ar free-blocks
.Op Fl d Ar debug-mask
@@ -188,6 +188,8 @@ Set file system specific options.
.Ar fs-options
is a comma separated list of options.
Valid file system specific options are detailed below.
+.It Fl p
+Create the image as a sparse file.
.It Fl S Ar sector-size
Set the file system sector size to
.Ar sector-size .
diff --git a/usr.sbin/makefs/makefs.c b/usr.sbin/makefs/makefs.c
index 623ca8a..b2da82b 100644
--- a/usr.sbin/makefs/makefs.c
+++ b/usr.sbin/makefs/makefs.c
@@ -112,7 +112,7 @@ main(int argc, char *argv[])
start_time.tv_sec = start.tv_sec;
start_time.tv_nsec = start.tv_usec * 1000;
- while ((ch = getopt(argc, argv, "B:b:d:f:F:M:m:N:o:s:S:t:x")) != -1) {
+ while ((ch = getopt(argc, argv, "B:b:d:f:F:M:m:N:o:ps:S:t:x")) != -1) {
switch (ch) {
case 'B':
@@ -199,6 +199,9 @@ main(int argc, char *argv[])
}
break;
}
+ case 'p':
+ fsoptions.sparse = 1;
+ break;
case 's':
fsoptions.minsize = fsoptions.maxsize =
@@ -346,7 +349,7 @@ usage(void)
fprintf(stderr,
"usage: %s [-t fs-type] [-o fs-options] [-d debug-mask] [-B endian]\n"
"\t[-S sector-size] [-M minimum-size] [-m maximum-size] [-s image-size]\n"
-"\t[-b free-blocks] [-f free-files] [-F mtree-specfile] [-x]\n"
+"\t[-b free-blocks] [-f free-files] [-F mtree-specfile] [-px]\n"
"\t[-N userdb-dir] image-file directory | manifest [extra-directory ...]\n",
prog);
exit(1);
diff --git a/usr.sbin/makefs/makefs.h b/usr.sbin/makefs/makefs.h
index f6cadeb..483ccff 100644
--- a/usr.sbin/makefs/makefs.h
+++ b/usr.sbin/makefs/makefs.h
@@ -129,6 +129,7 @@ typedef struct {
int freeblockpc; /* free block % */
int needswap; /* non-zero if byte swapping needed */
int sectorsize; /* sector size */
+ int sparse; /* sparse image, don't fill it with zeros */
void *fs_specific; /* File system specific additions. */
} fsinfo_t;
diff --git a/usr.sbin/makefs/mtree.c b/usr.sbin/makefs/mtree.c
index 5d88ad6..836e766 100644
--- a/usr.sbin/makefs/mtree.c
+++ b/usr.sbin/makefs/mtree.c
@@ -135,6 +135,47 @@ mtree_warning(const char *fmt, ...)
fputc('\n', stderr);
}
+#ifndef MAKEFS_MAX_TREE_DEPTH
+# define MAKEFS_MAX_TREE_DEPTH (MAXPATHLEN/2)
+#endif
+
+/* construct path to node->name */
+static char *
+mtree_file_path(fsnode *node)
+{
+ fsnode *pnode;
+ struct sbuf *sb;
+ char *res, *rp[MAKEFS_MAX_TREE_DEPTH];
+ int depth;
+
+ depth = 0;
+ rp[depth] = node->name;
+ for (pnode = node->parent; pnode && depth < MAKEFS_MAX_TREE_DEPTH;
+ pnode = pnode->parent) {
+ if (strcmp(pnode->name, ".") == 0)
+ break;
+ rp[++depth] = pnode->name;
+ }
+
+ sb = sbuf_new(NULL, NULL, 0, SBUF_AUTOEXTEND);
+ if (sb == NULL) {
+ errno = ENOMEM;
+ return (NULL);
+ }
+ while (depth > 0) {
+ sbuf_cat(sb, rp[depth--]);
+ sbuf_putc(sb, '/');
+ }
+ sbuf_cat(sb, rp[depth]);
+ sbuf_finish(sb);
+ res = strdup(sbuf_data(sb));
+ sbuf_delete(sb);
+ if (res == NULL)
+ errno = ENOMEM;
+ return res;
+
+}
+
/* mtree_resolve() sets errno to indicate why NULL was returned. */
static char *
mtree_resolve(const char *spec, int *istemp)
@@ -706,6 +747,12 @@ read_mtree_keywords(FILE *fp, fsnode *node)
return (0);
}
type = S_IFREG;
+ } else if (node->type != 0) {
+ type = node->type;
+ if (type == S_IFREG) {
+ /* the named path is the default contents */
+ node->contents = mtree_file_path(node);
+ }
} else
type = (node->symlink != NULL) ? S_IFLNK : S_IFDIR;
diff --git a/usr.sbin/makemap/Makefile.depend b/usr.sbin/makemap/Makefile.depend
new file mode 100644
index 0000000..c1dc46a
--- /dev/null
+++ b/usr.sbin/makemap/Makefile.depend
@@ -0,0 +1,25 @@
+# Autogenerated - do NOT edit!
+
+DEP_RELDIR := ${_PARSEDIR:S,${SRCTOP}/,,}
+
+DEP_MACHINE := ${.PARSEFILE:E}
+
+DIRDEPS = \
+ gnu/lib/libgcc \
+ include \
+ include/xlocale \
+ lib/${CSU_DIR} \
+ lib/libc \
+ lib/libsm \
+ lib/libsmdb \
+ lib/libsmutil \
+ lib/libutil \
+
+
+.include <dirdeps.mk>
+
+.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+# local dependencies - needed for -jN in clean tree
+makemap.o: sm_os.h
+makemap.po: sm_os.h
+.endif
diff --git a/usr.sbin/manctl/Makefile.depend b/usr.sbin/manctl/Makefile.depend
new file mode 100644
index 0000000..29fda55
--- /dev/null
+++ b/usr.sbin/manctl/Makefile.depend
@@ -0,0 +1,14 @@
+# Autogenerated - do NOT edit!
+
+DEP_RELDIR := ${_PARSEDIR:S,${SRCTOP}/,,}
+
+DEP_MACHINE := ${.PARSEFILE:E}
+
+DIRDEPS = \
+
+
+.include <dirdeps.mk>
+
+.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+# local dependencies - needed for -jN in clean tree
+.endif
diff --git a/usr.sbin/memcontrol/Makefile.depend b/usr.sbin/memcontrol/Makefile.depend
new file mode 100644
index 0000000..a839545
--- /dev/null
+++ b/usr.sbin/memcontrol/Makefile.depend
@@ -0,0 +1,19 @@
+# Autogenerated - do NOT edit!
+
+DEP_RELDIR := ${_PARSEDIR:S,${SRCTOP}/,,}
+
+DEP_MACHINE := ${.PARSEFILE:E}
+
+DIRDEPS = \
+ gnu/lib/libgcc \
+ include \
+ include/xlocale \
+ lib/${CSU_DIR} \
+ lib/libc \
+
+
+.include <dirdeps.mk>
+
+.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+# local dependencies - needed for -jN in clean tree
+.endif
diff --git a/usr.sbin/memcontrol/memcontrol.c b/usr.sbin/memcontrol/memcontrol.c
index 542bc3a..36329af 100644
--- a/usr.sbin/memcontrol/memcontrol.c
+++ b/usr.sbin/memcontrol/memcontrol.c
@@ -233,7 +233,7 @@ setfunc(int memfd, int argc, char *argv[])
while(argc--) {
for (i = 0; attrnames[i].name != NULL; i++) {
if (!strcmp(attrnames[i].name, argv[0])) {
- if (!attrnames[i].kind & MDF_SETTABLE)
+ if (!(attrnames[i].kind & MDF_SETTABLE))
help("flags");
mrd.mr_flags |= attrnames[i].val;
break;
diff --git a/usr.sbin/mergemaster/Makefile.depend b/usr.sbin/mergemaster/Makefile.depend
new file mode 100644
index 0000000..29fda55
--- /dev/null
+++ b/usr.sbin/mergemaster/Makefile.depend
@@ -0,0 +1,14 @@
+# Autogenerated - do NOT edit!
+
+DEP_RELDIR := ${_PARSEDIR:S,${SRCTOP}/,,}
+
+DEP_MACHINE := ${.PARSEFILE:E}
+
+DIRDEPS = \
+
+
+.include <dirdeps.mk>
+
+.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+# local dependencies - needed for -jN in clean tree
+.endif
diff --git a/usr.sbin/mergemaster/mergemaster.sh b/usr.sbin/mergemaster/mergemaster.sh
index eb10bba..1723fee 100755
--- a/usr.sbin/mergemaster/mergemaster.sh
+++ b/usr.sbin/mergemaster/mergemaster.sh
@@ -5,8 +5,8 @@
# Compare files created by /usr/src/etc/Makefile (or the directory
# the user specifies) with the currently installed copies.
-# Copyright 1998-2011 Douglas Barton
-# dougb@FreeBSD.org
+# Copyright (c) 1998-2012 Douglas Barton, All rights reserved
+# Please see detailed copyright below
# $FreeBSD$
@@ -532,9 +532,9 @@ if [ -t 0 ]; then
esac
fi
-# Define what CVS $Id tag to look for to aid portability.
+# Define what $Id tag to look for to aid portability.
#
-CVS_ID_TAG=FreeBSD
+ID_TAG=FreeBSD
delete_temproot () {
rm -rf "${TEMPROOT}" 2>/dev/null
@@ -1095,17 +1095,17 @@ for COMPFILE in `find . -type f | sort`; do
case "${STRICT}" in
'' | [Nn][Oo])
- # Compare CVS $Id's first so if the file hasn't been modified
+ # Compare $Id's first so if the file hasn't been modified
# local changes will be ignored.
# If the files have the same $Id, delete the one in temproot so the
# user will have less to wade through if files are left to merge by hand.
#
- CVSID1=`grep "[$]${CVS_ID_TAG}:" ${DESTDIR}${COMPFILE#.} 2>/dev/null`
- CVSID2=`grep "[$]${CVS_ID_TAG}:" ${COMPFILE} 2>/dev/null` || CVSID2=none
+ ID1=`grep "[$]${ID_TAG}:" ${DESTDIR}${COMPFILE#.} 2>/dev/null`
+ ID2=`grep "[$]${ID_TAG}:" ${COMPFILE} 2>/dev/null` || ID2=none
- case "${CVSID2}" in
- "${CVSID1}")
- echo " *** Temp ${COMPFILE} and installed have the same CVS Id, deleting"
+ case "${ID2}" in
+ "${ID1}")
+ echo " *** Temp ${COMPFILE} and installed have the same Id, deleting"
rm "${COMPFILE}"
;;
esac
@@ -1334,7 +1334,7 @@ case "${NEED_PWD_MKDB}" in
;;
esac
-if [ -e "${DESTDIR}/etc/localtime" ]; then # Ignore if TZ == UTC
+if [ -e "${DESTDIR}/etc/localtime" -a -z "${PRE_WORLD}" ]; then # Ignore if TZ == UTC
echo ''
[ -n "${DESTDIR}" ] && tzs_args="-C ${DESTDIR}"
if [ -f "${DESTDIR}/var/db/zoneinfo" ]; then
@@ -1380,29 +1380,35 @@ case "${COMP_CONFS}" in
;;
esac
-case "${PRE_WORLD}" in
-'') ;;
-*)
- MAKE_CONF="${SOURCEDIR}/share/examples/etc/make.conf"
-
- (echo ''
- echo '*** Comparing make variables'
- echo ''
- echo "*** From ${DESTDIR}/etc/make.conf"
- echo "*** From ${MAKE_CONF}"
-
- for MAKE_VAR in `grep -i ^[a-z] ${DESTDIR}/etc/make.conf | cut -d '=' -f 1`; do
- echo ''
- grep -w ^${MAKE_VAR} ${DESTDIR}/etc/make.conf
- grep -w ^#${MAKE_VAR} ${MAKE_CONF} ||
- echo ' * No example variable with this name'
- done) | ${PAGER}
- ;;
-esac
-
if [ -n "${PRESERVE_FILES}" ]; then
find -d $PRESERVE_FILES_DIR -type d -empty -delete 2>/dev/null
rmdir $PRESERVE_FILES_DIR 2>/dev/null
fi
exit 0
+
+#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+# Copyright (c) 1998-2012 Douglas Barton
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in the
+# documentation and/or other materials provided with the distribution.
+#
+# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+# SUCH DAMAGE.
diff --git a/usr.sbin/mfiutil/Makefile b/usr.sbin/mfiutil/Makefile
index dbf158d..e100358 100644
--- a/usr.sbin/mfiutil/Makefile
+++ b/usr.sbin/mfiutil/Makefile
@@ -6,7 +6,6 @@ SRCS= mfiutil.c mfi_cmd.c mfi_config.c mfi_drive.c mfi_evt.c mfi_flash.c \
MAN8= mfiutil.8
CFLAGS+= -fno-builtin-strftime
-WARNS?=3
DPADD= ${LIBUTIL}
LDADD= -lutil
diff --git a/usr.sbin/mfiutil/Makefile.depend b/usr.sbin/mfiutil/Makefile.depend
new file mode 100644
index 0000000..2dd29af
--- /dev/null
+++ b/usr.sbin/mfiutil/Makefile.depend
@@ -0,0 +1,20 @@
+# Autogenerated - do NOT edit!
+
+DEP_RELDIR := ${_PARSEDIR:S,${SRCTOP}/,,}
+
+DEP_MACHINE := ${.PARSEFILE:E}
+
+DIRDEPS = \
+ gnu/lib/libgcc \
+ include \
+ include/xlocale \
+ lib/${CSU_DIR} \
+ lib/libc \
+ lib/libutil \
+
+
+.include <dirdeps.mk>
+
+.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+# local dependencies - needed for -jN in clean tree
+.endif
diff --git a/usr.sbin/mfiutil/mfi_cmd.c b/usr.sbin/mfiutil/mfi_cmd.c
index 7fedfb6..3cf703a 100644
--- a/usr.sbin/mfiutil/mfi_cmd.c
+++ b/usr.sbin/mfiutil/mfi_cmd.c
@@ -301,12 +301,12 @@ mfi_ctrl_get_info(int fd, struct mfi_ctrl_info *info, uint8_t *statusp)
}
int
-mfi_open(int unit)
+mfi_open(int unit, int acs)
{
char path[MAXPATHLEN];
snprintf(path, sizeof(path), "/dev/mfi%d", unit);
- return (open(path, O_RDWR));
+ return (open(path, acs));
}
void
diff --git a/usr.sbin/mfiutil/mfi_config.c b/usr.sbin/mfiutil/mfi_config.c
index feb285d..8576bc3 100644
--- a/usr.sbin/mfiutil/mfi_config.c
+++ b/usr.sbin/mfiutil/mfi_config.c
@@ -35,6 +35,7 @@
#endif
#include <err.h>
#include <errno.h>
+#include <fcntl.h>
#include <libutil.h>
#ifdef DEBUG
#include <stdint.h>
@@ -151,13 +152,13 @@ mfi_config_lookup_volume(struct mfi_config_data *config, uint8_t target_id)
}
static int
-clear_config(int ac, char **av)
+clear_config(int ac __unused, char **av __unused)
{
struct mfi_ld_list list;
int ch, error, fd;
u_int i;
- fd = mfi_open(mfi_unit);
+ fd = mfi_open(mfi_unit, O_RDWR);
if (fd < 0) {
error = errno;
warn("mfi_open");
@@ -410,7 +411,7 @@ find_next_volume(struct config_id_state *state)
/* Populate an array with drives. */
static void
-build_array(int fd, char *arrayp, struct array_info *array_info,
+build_array(int fd __unused, char *arrayp, struct array_info *array_info,
struct config_id_state *state, int verbose)
{
struct mfi_array *ar = (struct mfi_array *)arrayp;
@@ -575,7 +576,7 @@ create_volume(int ac, char **av)
narrays = 0;
error = 0;
- fd = mfi_open(mfi_unit);
+ fd = mfi_open(mfi_unit, O_RDWR);
if (fd < 0) {
error = errno;
warn("mfi_open");
@@ -857,7 +858,7 @@ delete_volume(int ac, char **av)
return (EINVAL);
}
- fd = mfi_open(mfi_unit);
+ fd = mfi_open(mfi_unit, O_RDWR);
if (fd < 0) {
error = errno;
warn("mfi_open");
@@ -925,7 +926,7 @@ add_spare(int ac, char **av)
return (EINVAL);
}
- fd = mfi_open(mfi_unit);
+ fd = mfi_open(mfi_unit, O_RDWR);
if (fd < 0) {
error = errno;
warn("mfi_open");
@@ -1050,7 +1051,7 @@ remove_spare(int ac, char **av)
return (EINVAL);
}
- fd = mfi_open(mfi_unit);
+ fd = mfi_open(mfi_unit, O_RDWR);
if (fd < 0) {
error = errno;
warn("mfi_open");
@@ -1196,7 +1197,7 @@ debug_config(int ac, char **av)
return (EINVAL);
}
- fd = mfi_open(mfi_unit);
+ fd = mfi_open(mfi_unit, O_RDWR);
if (fd < 0) {
error = errno;
warn("mfi_open");
@@ -1233,7 +1234,7 @@ dump(int ac, char **av)
return (EINVAL);
}
- fd = mfi_open(mfi_unit);
+ fd = mfi_open(mfi_unit, O_RDWR);
if (fd < 0) {
error = errno;
warn("mfi_open");
diff --git a/usr.sbin/mfiutil/mfi_drive.c b/usr.sbin/mfiutil/mfi_drive.c
index 231b070..1927fac 100644
--- a/usr.sbin/mfiutil/mfi_drive.c
+++ b/usr.sbin/mfiutil/mfi_drive.c
@@ -33,6 +33,7 @@
#include <sys/errno.h>
#include <ctype.h>
#include <err.h>
+#include <fcntl.h>
#include <libutil.h>
#include <limits.h>
#include <stdio.h>
@@ -71,7 +72,7 @@ mfi_drive_name(struct mfi_pd_info *pinfo, uint16_t device_id, uint32_t def)
else
snprintf(buf, sizeof(buf), "%2u", device_id);
- fd = mfi_open(mfi_unit);
+ fd = mfi_open(mfi_unit, O_RDWR);
if (fd < 0) {
warn("mfi_open");
return (buf);
@@ -329,11 +330,13 @@ cam_strvis(char *dst, const char *src, int srclen, int dstlen)
const char *
mfi_pd_inq_string(struct mfi_pd_info *info)
{
- struct scsi_inquiry_data *inq_data;
+ struct scsi_inquiry_data iqd, *inq_data = &iqd;
char vendor[16], product[48], revision[16], rstr[12], serial[SID_VENDOR_SPECIFIC_0_SIZE];
static char inq_string[64];
- inq_data = (struct scsi_inquiry_data *)info->inquiry_data;
+ memcpy(inq_data, info->inquiry_data,
+ (sizeof (iqd) < sizeof (info->inquiry_data))?
+ sizeof (iqd) : sizeof (info->inquiry_data));
if (SID_QUAL_IS_VENDOR_UNIQUE(inq_data))
return (NULL);
if (SID_TYPE(inq_data) != T_DIRECT)
@@ -383,7 +386,7 @@ drive_set_state(char *drive, uint16_t new_state)
uint8_t mbox[6];
int error, fd;
- fd = mfi_open(mfi_unit);
+ fd = mfi_open(mfi_unit, O_RDWR);
if (fd < 0) {
error = errno;
warn("mfi_open");
@@ -484,7 +487,7 @@ start_rebuild(int ac, char **av)
return (EINVAL);
}
- fd = mfi_open(mfi_unit);
+ fd = mfi_open(mfi_unit, O_RDWR);
if (fd < 0) {
error = errno;
warn("mfi_open");
@@ -541,7 +544,7 @@ abort_rebuild(int ac, char **av)
return (EINVAL);
}
- fd = mfi_open(mfi_unit);
+ fd = mfi_open(mfi_unit, O_RDWR);
if (fd < 0) {
error = errno;
warn("mfi_open");
@@ -597,7 +600,7 @@ drive_progress(int ac, char **av)
return (EINVAL);
}
- fd = mfi_open(mfi_unit);
+ fd = mfi_open(mfi_unit, O_RDWR);
if (fd < 0) {
error = errno;
warn("mfi_open");
@@ -663,7 +666,7 @@ drive_clear(int ac, char **av)
return (EINVAL);
}
- fd = mfi_open(mfi_unit);
+ fd = mfi_open(mfi_unit, O_RDWR);
if (fd < 0) {
error = errno;
warn("mfi_open");
@@ -723,7 +726,7 @@ drive_locate(int ac, char **av)
return (EINVAL);
}
- fd = mfi_open(mfi_unit);
+ fd = mfi_open(mfi_unit, O_RDWR);
if (fd < 0) {
error = errno;
warn("mfi_open");
diff --git a/usr.sbin/mfiutil/mfi_evt.c b/usr.sbin/mfiutil/mfi_evt.c
index dbf8272..c9a1a6d 100644
--- a/usr.sbin/mfiutil/mfi_evt.c
+++ b/usr.sbin/mfiutil/mfi_evt.c
@@ -32,6 +32,7 @@
#include <sys/types.h>
#include <sys/errno.h>
#include <err.h>
+#include <fcntl.h>
#include <stdio.h>
#include <stdlib.h>
#include <strings.h>
@@ -63,7 +64,7 @@ mfi_get_events(int fd, struct mfi_evt_list *list, int num_events,
}
static int
-show_logstate(int ac, char **av)
+show_logstate(int ac, char **av __unused)
{
struct mfi_evt_log_state info;
int error, fd;
@@ -73,7 +74,7 @@ show_logstate(int ac, char **av)
return (EINVAL);
}
- fd = mfi_open(mfi_unit);
+ fd = mfi_open(mfi_unit, O_RDWR);
if (fd < 0) {
error = errno;
warn("mfi_open");
@@ -541,7 +542,7 @@ show_events(int ac, char **av)
int ch, error, fd, num_events, verbose;
u_int i;
- fd = mfi_open(mfi_unit);
+ fd = mfi_open(mfi_unit, O_RDWR);
if (fd < 0) {
error = errno;
warn("mfi_open");
diff --git a/usr.sbin/mfiutil/mfi_flash.c b/usr.sbin/mfiutil/mfi_flash.c
index 6d07cb0..d640cf7 100644
--- a/usr.sbin/mfiutil/mfi_flash.c
+++ b/usr.sbin/mfiutil/mfi_flash.c
@@ -42,36 +42,6 @@
#define FLASH_BUF_SIZE (64 * 1024)
-int fw_name_width, fw_version_width, fw_date_width, fw_time_width;
-
-static void
-scan_firmware(struct mfi_info_component *comp)
-{
- int len;
-
- len = strlen(comp->name);
- if (fw_name_width < len)
- fw_name_width = len;
- len = strlen(comp->version);
- if (fw_version_width < len)
- fw_version_width = len;
- len = strlen(comp->build_date);
- if (fw_date_width < len)
- fw_date_width = len;
- len = strlen(comp->build_time);
- if (fw_time_width < len)
- fw_time_width = len;
-}
-
-static void
-display_firmware(struct mfi_info_component *comp)
-{
-
- printf("%-*s %-*s %-*s %-*s\n", fw_name_width, comp->name,
- fw_version_width, comp->version, fw_date_width, comp->build_date,
- fw_time_width, comp->build_time);
-}
-
static int
display_pending_firmware(int fd)
{
@@ -96,9 +66,9 @@ display_pending_firmware(int fd)
info.pending_image_component_count = 8;
for (i = 0; i < info.pending_image_component_count; i++)
scan_firmware(&info.pending_image_component[i]);
- display_firmware(&header);
+ display_firmware(&header, "");
for (i = 0; i < info.pending_image_component_count; i++)
- display_firmware(&info.pending_image_component[i]);
+ display_firmware(&info.pending_image_component[i], "");
return (0);
}
@@ -150,7 +120,7 @@ flash_adapter(int ac, char **av)
goto error;
}
- fd = mfi_open(mfi_unit);
+ fd = mfi_open(mfi_unit, O_RDWR);
if (fd < 0) {
error = errno;
warn("mfi_open");
diff --git a/usr.sbin/mfiutil/mfi_patrol.c b/usr.sbin/mfiutil/mfi_patrol.c
index dd348ad..c3e47f3 100644
--- a/usr.sbin/mfiutil/mfi_patrol.c
+++ b/usr.sbin/mfiutil/mfi_patrol.c
@@ -32,6 +32,7 @@
#include <sys/types.h>
#include <sys/errno.h>
#include <err.h>
+#include <fcntl.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -74,7 +75,7 @@ patrol_get_props(int fd, struct mfi_pr_properties *prop)
}
static int
-show_patrol(int ac, char **av)
+show_patrol(int ac __unused, char **av __unused)
{
struct mfi_pr_properties prop;
struct mfi_pr_status status;
@@ -86,7 +87,7 @@ show_patrol(int ac, char **av)
int error, fd;
u_int i;
- fd = mfi_open(mfi_unit);
+ fd = mfi_open(mfi_unit, O_RDWR);
if (fd < 0) {
error = errno;
warn("mfi_open");
@@ -192,11 +193,11 @@ show_patrol(int ac, char **av)
MFI_COMMAND(show, patrol, show_patrol);
static int
-start_patrol(int ac, char **av)
+start_patrol(int ac __unused, char **av __unused)
{
int error, fd;
- fd = mfi_open(mfi_unit);
+ fd = mfi_open(mfi_unit, O_RDWR);
if (fd < 0) {
error = errno;
warn("mfi_open");
@@ -218,11 +219,11 @@ start_patrol(int ac, char **av)
MFI_COMMAND(start, patrol, start_patrol);
static int
-stop_patrol(int ac, char **av)
+stop_patrol(int ac __unused, char **av __unused)
{
int error, fd;
- fd = mfi_open(mfi_unit);
+ fd = mfi_open(mfi_unit, O_RDWR);
if (fd < 0) {
error = errno;
warn("mfi_open");
@@ -292,7 +293,7 @@ patrol_config(int ac, char **av)
return (EINVAL);
}
- fd = mfi_open(mfi_unit);
+ fd = mfi_open(mfi_unit, O_RDWR);
if (fd < 0) {
error = errno;
warn("mfi_open");
diff --git a/usr.sbin/mfiutil/mfi_show.c b/usr.sbin/mfiutil/mfi_show.c
index 8311f4b..be395bb 100644
--- a/usr.sbin/mfiutil/mfi_show.c
+++ b/usr.sbin/mfiutil/mfi_show.c
@@ -32,6 +32,7 @@
#include <sys/types.h>
#include <sys/errno.h>
#include <err.h>
+#include <fcntl.h>
#include <libutil.h>
#include <stdio.h>
#include <stdlib.h>
@@ -50,7 +51,7 @@ format_stripe(char *buf, size_t buflen, uint8_t stripe)
}
static int
-show_adapter(int ac, char **av)
+show_adapter(int ac, char **av __unused)
{
struct mfi_ctrl_info info;
char stripe[5];
@@ -61,7 +62,7 @@ show_adapter(int ac, char **av)
return (EINVAL);
}
- fd = mfi_open(mfi_unit);
+ fd = mfi_open(mfi_unit, O_RDONLY);
if (fd < 0) {
error = errno;
warn("mfi_open");
@@ -135,7 +136,7 @@ show_adapter(int ac, char **av)
MFI_COMMAND(show, adapter, show_adapter);
static int
-show_battery(int ac, char **av)
+show_battery(int ac, char **av __unused)
{
struct mfi_bbu_capacity_info cap;
struct mfi_bbu_design_info design;
@@ -148,7 +149,7 @@ show_battery(int ac, char **av)
return (EINVAL);
}
- fd = mfi_open(mfi_unit);
+ fd = mfi_open(mfi_unit, O_RDONLY);
if (fd < 0) {
error = errno;
warn("mfi_open");
@@ -303,7 +304,7 @@ print_pd(struct mfi_pd_info *info, int state_len)
}
static int
-show_config(int ac, char **av)
+show_config(int ac, char **av __unused)
{
struct mfi_config_data *config;
struct mfi_array *ar;
@@ -320,7 +321,7 @@ show_config(int ac, char **av)
return (EINVAL);
}
- fd = mfi_open(mfi_unit);
+ fd = mfi_open(mfi_unit, O_RDONLY);
if (fd < 0) {
error = errno;
warn("mfi_open");
@@ -409,7 +410,7 @@ show_config(int ac, char **av)
MFI_COMMAND(show, config, show_config);
static int
-show_volumes(int ac, char **av)
+show_volumes(int ac, char **av __unused)
{
struct mfi_ld_list list;
struct mfi_ld_info info;
@@ -421,7 +422,7 @@ show_volumes(int ac, char **av)
return (EINVAL);
}
- fd = mfi_open(mfi_unit);
+ fd = mfi_open(mfi_unit, O_RDONLY);
if (fd < 0) {
error = errno;
warn("mfi_open");
@@ -492,7 +493,7 @@ show_volumes(int ac, char **av)
MFI_COMMAND(show, volumes, show_volumes);
static int
-show_drives(int ac, char **av)
+show_drives(int ac, char **av __unused)
{
struct mfi_pd_list *list;
struct mfi_pd_info info;
@@ -504,7 +505,7 @@ show_drives(int ac, char **av)
return (EINVAL);
}
- fd = mfi_open(mfi_unit);
+ fd = mfi_open(mfi_unit, O_RDONLY);
if (fd < 0) {
error = errno;
warn("mfi_open");
@@ -569,38 +570,8 @@ error:
}
MFI_COMMAND(show, drives, show_drives);
-int fw_name_width, fw_version_width, fw_date_width, fw_time_width;
-
-static void
-scan_firmware(struct mfi_info_component *comp)
-{
- int len;
-
- len = strlen(comp->name);
- if (fw_name_width < len)
- fw_name_width = len;
- len = strlen(comp->version);
- if (fw_version_width < len)
- fw_version_width = len;
- len = strlen(comp->build_date);
- if (fw_date_width < len)
- fw_date_width = len;
- len = strlen(comp->build_time);
- if (fw_time_width < len)
- fw_time_width = len;
-}
-
-static void
-display_firmware(struct mfi_info_component *comp, const char *tag)
-{
-
- printf("%-*s %-*s %-*s %-*s %s\n", fw_name_width, comp->name,
- fw_version_width, comp->version, fw_date_width, comp->build_date,
- fw_time_width, comp->build_time, tag);
-}
-
static int
-show_firmware(int ac, char **av)
+show_firmware(int ac, char **av __unused)
{
struct mfi_ctrl_info info;
struct mfi_info_component header;
@@ -612,7 +583,7 @@ show_firmware(int ac, char **av)
return (EINVAL);
}
- fd = mfi_open(mfi_unit);
+ fd = mfi_open(mfi_unit, O_RDONLY);
if (fd < 0) {
error = errno;
warn("mfi_open");
@@ -656,7 +627,7 @@ show_firmware(int ac, char **av)
MFI_COMMAND(show, firmware, show_firmware);
static int
-show_progress(int ac, char **av)
+show_progress(int ac, char **av __unused)
{
struct mfi_ld_list llist;
struct mfi_pd_list *plist;
@@ -672,7 +643,7 @@ show_progress(int ac, char **av)
return (EINVAL);
}
- fd = mfi_open(mfi_unit);
+ fd = mfi_open(mfi_unit, O_RDONLY);
if (fd < 0) {
error = errno;
warn("mfi_open");
diff --git a/usr.sbin/mfiutil/mfi_volume.c b/usr.sbin/mfiutil/mfi_volume.c
index 836f045..49417d0 100644
--- a/usr.sbin/mfiutil/mfi_volume.c
+++ b/usr.sbin/mfiutil/mfi_volume.c
@@ -32,6 +32,7 @@
#include <sys/types.h>
#include <sys/errno.h>
#include <err.h>
+#include <fcntl.h>
#include <libutil.h>
#include <stdio.h>
#include <stdlib.h>
@@ -294,7 +295,7 @@ volume_cache(int ac, char **av)
return (EINVAL);
}
- fd = mfi_open(mfi_unit);
+ fd = mfi_open(mfi_unit, O_RDWR);
if (fd < 0) {
error = errno;
warn("mfi_open");
@@ -402,7 +403,7 @@ volume_name(int ac, char **av)
return (ENOSPC);
}
- fd = mfi_open(mfi_unit);
+ fd = mfi_open(mfi_unit, O_RDWR);
if (fd < 0) {
error = errno;
warn("mfi_open");
@@ -453,7 +454,7 @@ volume_progress(int ac, char **av)
return (EINVAL);
}
- fd = mfi_open(mfi_unit);
+ fd = mfi_open(mfi_unit, O_RDONLY);
if (fd < 0) {
error = errno;
warn("mfi_open");
diff --git a/usr.sbin/mfiutil/mfiutil.c b/usr.sbin/mfiutil/mfiutil.c
index 43bb6bb..79c6a4b 100644
--- a/usr.sbin/mfiutil/mfiutil.c
+++ b/usr.sbin/mfiutil/mfiutil.c
@@ -44,8 +44,8 @@ MFI_TABLE(top, stop);
MFI_TABLE(top, abort);
int mfi_unit;
-
u_int mfi_opts;
+static int fw_name_width, fw_version_width, fw_date_width, fw_time_width;
static void
usage(void)
@@ -92,10 +92,10 @@ usage(void)
}
static int
-version(int ac, char **av)
+version(int ac __unused, char **av __unused)
{
- printf("mfiutil version 1.0.13");
+ printf("mfiutil version 1.0.14");
#ifdef DEBUG
printf(" (DEBUG)");
#endif
@@ -144,3 +144,31 @@ main(int ac, char **av)
warnx("Unknown command %s.", av[0]);
return (1);
}
+
+void
+scan_firmware(struct mfi_info_component *comp)
+{
+ int len;
+
+ len = strlen(comp->name);
+ if (fw_name_width < len)
+ fw_name_width = len;
+ len = strlen(comp->version);
+ if (fw_version_width < len)
+ fw_version_width = len;
+ len = strlen(comp->build_date);
+ if (fw_date_width < len)
+ fw_date_width = len;
+ len = strlen(comp->build_time);
+ if (fw_time_width < len)
+ fw_time_width = len;
+}
+
+void
+display_firmware(struct mfi_info_component *comp, const char *tag)
+{
+
+ printf("%-*s %-*s %-*s %-*s %s\n", fw_name_width, comp->name,
+ fw_version_width, comp->version, fw_date_width, comp->build_date,
+ fw_time_width, comp->build_time, tag);
+}
diff --git a/usr.sbin/mfiutil/mfiutil.h b/usr.sbin/mfiutil/mfiutil.h
index 232831e..687bdd9 100644
--- a/usr.sbin/mfiutil/mfiutil.h
+++ b/usr.sbin/mfiutil/mfiutil.h
@@ -121,6 +121,7 @@ struct mfiutil_command {
#define MFI_DNAME_HONOR_OPTS 0x8000 /* Allow cmd line to override default */
extern int mfi_unit;
+
extern u_int mfi_opts;
void mbox_store_ldref(uint8_t *mbox, union mfi_ld_ref *ref);
@@ -139,7 +140,7 @@ int mfi_lookup_drive(int fd, char *drive, uint16_t *device_id);
int mfi_lookup_volume(int fd, const char *name, uint8_t *target_id);
int mfi_dcmd_command(int fd, uint32_t opcode, void *buf, size_t bufsize,
uint8_t *mbox, size_t mboxlen, uint8_t *statusp);
-int mfi_open(int unit);
+int mfi_open(int unit, int acs);
int mfi_ctrl_get_info(int fd, struct mfi_ctrl_info *info, uint8_t *statusp);
int mfi_ld_get_info(int fd, uint8_t target_id, struct mfi_ld_info *info,
uint8_t *statusp);
@@ -152,4 +153,7 @@ const char *mfi_status(u_int status_code);
const char *mfi_drive_name(struct mfi_pd_info *pinfo, uint16_t device_id,
uint32_t def);
+void scan_firmware(struct mfi_info_component *comp);
+void display_firmware(struct mfi_info_component *comp, const char *tag);
+
#endif /* !__MFIUTIL_H__ */
diff --git a/usr.sbin/mixer/Makefile.depend b/usr.sbin/mixer/Makefile.depend
new file mode 100644
index 0000000..a839545
--- /dev/null
+++ b/usr.sbin/mixer/Makefile.depend
@@ -0,0 +1,19 @@
+# Autogenerated - do NOT edit!
+
+DEP_RELDIR := ${_PARSEDIR:S,${SRCTOP}/,,}
+
+DEP_MACHINE := ${.PARSEFILE:E}
+
+DIRDEPS = \
+ gnu/lib/libgcc \
+ include \
+ include/xlocale \
+ lib/${CSU_DIR} \
+ lib/libc \
+
+
+.include <dirdeps.mk>
+
+.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+# local dependencies - needed for -jN in clean tree
+.endif
diff --git a/usr.sbin/mld6query/Makefile.depend b/usr.sbin/mld6query/Makefile.depend
new file mode 100644
index 0000000..16b5e42
--- /dev/null
+++ b/usr.sbin/mld6query/Makefile.depend
@@ -0,0 +1,20 @@
+# Autogenerated - do NOT edit!
+
+DEP_RELDIR := ${_PARSEDIR:S,${SRCTOP}/,,}
+
+DEP_MACHINE := ${.PARSEFILE:E}
+
+DIRDEPS = \
+ gnu/lib/libgcc \
+ include \
+ include/arpa \
+ include/xlocale \
+ lib/${CSU_DIR} \
+ lib/libc \
+
+
+.include <dirdeps.mk>
+
+.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+# local dependencies - needed for -jN in clean tree
+.endif
diff --git a/usr.sbin/mlxcontrol/Makefile.depend b/usr.sbin/mlxcontrol/Makefile.depend
new file mode 100644
index 0000000..a839545
--- /dev/null
+++ b/usr.sbin/mlxcontrol/Makefile.depend
@@ -0,0 +1,19 @@
+# Autogenerated - do NOT edit!
+
+DEP_RELDIR := ${_PARSEDIR:S,${SRCTOP}/,,}
+
+DEP_MACHINE := ${.PARSEFILE:E}
+
+DIRDEPS = \
+ gnu/lib/libgcc \
+ include \
+ include/xlocale \
+ lib/${CSU_DIR} \
+ lib/libc \
+
+
+.include <dirdeps.mk>
+
+.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+# local dependencies - needed for -jN in clean tree
+.endif
diff --git a/usr.sbin/mount_nwfs/Makefile.depend b/usr.sbin/mount_nwfs/Makefile.depend
new file mode 100644
index 0000000..bfecf09
--- /dev/null
+++ b/usr.sbin/mount_nwfs/Makefile.depend
@@ -0,0 +1,20 @@
+# Autogenerated - do NOT edit!
+
+DEP_RELDIR := ${_PARSEDIR:S,${SRCTOP}/,,}
+
+DEP_MACHINE := ${.PARSEFILE:E}
+
+DIRDEPS = \
+ gnu/lib/libgcc \
+ include \
+ include/xlocale \
+ lib/${CSU_DIR} \
+ lib/libc \
+ lib/libipx \
+
+
+.include <dirdeps.mk>
+
+.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+# local dependencies - needed for -jN in clean tree
+.endif
diff --git a/usr.sbin/mount_portalfs/Makefile.depend b/usr.sbin/mount_portalfs/Makefile.depend
new file mode 100644
index 0000000..16b5e42
--- /dev/null
+++ b/usr.sbin/mount_portalfs/Makefile.depend
@@ -0,0 +1,20 @@
+# Autogenerated - do NOT edit!
+
+DEP_RELDIR := ${_PARSEDIR:S,${SRCTOP}/,,}
+
+DEP_MACHINE := ${.PARSEFILE:E}
+
+DIRDEPS = \
+ gnu/lib/libgcc \
+ include \
+ include/arpa \
+ include/xlocale \
+ lib/${CSU_DIR} \
+ lib/libc \
+
+
+.include <dirdeps.mk>
+
+.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+# local dependencies - needed for -jN in clean tree
+.endif
diff --git a/usr.sbin/mount_smbfs/Makefile.depend b/usr.sbin/mount_smbfs/Makefile.depend
new file mode 100644
index 0000000..18a3d5f
--- /dev/null
+++ b/usr.sbin/mount_smbfs/Makefile.depend
@@ -0,0 +1,20 @@
+# Autogenerated - do NOT edit!
+
+DEP_RELDIR := ${_PARSEDIR:S,${SRCTOP}/,,}
+
+DEP_MACHINE := ${.PARSEFILE:E}
+
+DIRDEPS = \
+ gnu/lib/libgcc \
+ include \
+ include/xlocale \
+ lib/${CSU_DIR} \
+ lib/libc \
+ lib/libkiconv \
+
+
+.include <dirdeps.mk>
+
+.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+# local dependencies - needed for -jN in clean tree
+.endif
diff --git a/usr.sbin/mountd/Makefile.depend b/usr.sbin/mountd/Makefile.depend
new file mode 100644
index 0000000..7ca71be
--- /dev/null
+++ b/usr.sbin/mountd/Makefile.depend
@@ -0,0 +1,23 @@
+# Autogenerated - do NOT edit!
+
+DEP_RELDIR := ${_PARSEDIR:S,${SRCTOP}/,,}
+
+DEP_MACHINE := ${.PARSEFILE:E}
+
+DIRDEPS = \
+ gnu/lib/libgcc \
+ include \
+ include/arpa \
+ include/rpc \
+ include/rpcsvc \
+ include/xlocale \
+ lib/${CSU_DIR} \
+ lib/libc \
+ lib/libutil \
+
+
+.include <dirdeps.mk>
+
+.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+# local dependencies - needed for -jN in clean tree
+.endif
diff --git a/usr.sbin/mountd/exports.5 b/usr.sbin/mountd/exports.5
index 3a8950f..75a5121 100644
--- a/usr.sbin/mountd/exports.5
+++ b/usr.sbin/mountd/exports.5
@@ -101,7 +101,7 @@ This line does not export any file system, but simply marks where the root
of the server's directory tree is for NFSv4 clients.
The exported file systems for NFSv4 are specified via the other lines
in the
-.Xr exports 5
+.Nm
file in the same way as for NFSv2 and NFSv3.
The pathnames must not have any symbolic links in them and should not have
any
diff --git a/usr.sbin/mountd/mountd.8 b/usr.sbin/mountd/mountd.8
index 2bc670c..fe73743 100644
--- a/usr.sbin/mountd/mountd.8
+++ b/usr.sbin/mountd/mountd.8
@@ -28,7 +28,7 @@
.\" @(#)mountd.8 8.4 (Berkeley) 4/28/95
.\" $FreeBSD$
.\"
-.Dd April 23, 2011
+.Dd October 14, 2012
.Dt MOUNTD 8
.Os
.Sh NAME
@@ -38,7 +38,7 @@
mount requests
.Sh SYNOPSIS
.Nm
-.Op Fl 2delnor
+.Op Fl 2delnorS
.Op Fl h Ar bindip
.Op Fl p Ar port
.Op Ar exportsfile ...
@@ -131,6 +131,19 @@ flag.
Specify an alternate location
for the exports file.
More than one exports file can be specified.
+.It Fl S
+Tell mountd to suspend/resume execution of the nfsd threads whenever
+the exports list is being reloaded.
+This avoids intermittent access
+errors for clients that do NFS RPCs while the exports are being
+reloaded, but introduces a delay in RPC response while the reload
+is in progress.
+If
+.Nm
+crashes while an exports load is in progress,
+.Nm
+must be restarted to get the nfsd threads running again, if this
+option is used.
.El
.Pp
When
diff --git a/usr.sbin/mountd/mountd.c b/usr.sbin/mountd/mountd.c
index 1e56e10..543fc14 100644
--- a/usr.sbin/mountd/mountd.c
+++ b/usr.sbin/mountd/mountd.c
@@ -117,6 +117,8 @@ struct exportlist {
char *ex_indexfile;
int ex_numsecflavors;
int ex_secflavors[MAXSECFLAVORS];
+ int ex_defnumsecflavors;
+ int ex_defsecflavors[MAXSECFLAVORS];
};
/* ex_flag bits */
#define EX_LINKED 0x1
@@ -136,6 +138,8 @@ struct grouplist {
int gr_type;
union grouptypes gr_ptr;
struct grouplist *gr_next;
+ int gr_numsecflavors;
+ int gr_secflavors[MAXSECFLAVORS];
};
/* Group types */
#define GT_NULL 0x0
@@ -163,12 +167,13 @@ struct fhreturn {
/* Global defs */
char *add_expdir(struct dirlist **, char *, int);
void add_dlist(struct dirlist **, struct dirlist *,
- struct grouplist *, int);
+ struct grouplist *, int, struct exportlist *);
void add_mlist(char *, char *);
int check_dirpath(char *);
int check_options(struct dirlist *);
int checkmask(struct sockaddr *sa);
-int chk_host(struct dirlist *, struct sockaddr *, int *, int *);
+int chk_host(struct dirlist *, struct sockaddr *, int *, int *, int *,
+ int **);
static int create_service(struct netconfig *nconf);
static void complete_service(struct netconfig *nconf, char *port_str);
static void clearout_service(void);
@@ -241,6 +246,7 @@ static int mallocd_svcport = 0;
static int *sock_fd;
static int sock_fdcnt;
static int sock_fdpos;
+static int suspend_nfsd = 0;
int opt_flags;
static int have_v6 = 1;
@@ -306,7 +312,7 @@ main(int argc, char **argv)
else
close(s);
- while ((c = getopt(argc, argv, "2deh:lnop:r")) != -1)
+ while ((c = getopt(argc, argv, "2deh:lnop:rS")) != -1)
switch (c) {
case '2':
force_v2 = 1;
@@ -358,6 +364,9 @@ main(int argc, char **argv)
out_of_mem();
}
break;
+ case 'S':
+ suspend_nfsd = 1;
+ break;
default:
usage();
};
@@ -916,7 +925,7 @@ usage(void)
{
fprintf(stderr,
"usage: mountd [-2] [-d] [-e] [-l] [-n] [-p <port>] [-r] "
- "[-h <bindip>] [export_file ...]\n");
+ "[-S] [-h <bindip>] [export_file ...]\n");
exit(1);
}
@@ -938,6 +947,7 @@ mntsrv(struct svc_req *rqstp, SVCXPRT *transp)
char rpcpath[MNTPATHLEN + 1], dirpath[MAXPATHLEN];
int bad = 0, defset, hostset;
sigset_t sighup_mask;
+ int numsecflavors, *secflavorsp;
sigemptyset(&sighup_mask);
sigaddset(&sighup_mask, SIGHUP);
@@ -1000,9 +1010,11 @@ mntsrv(struct svc_req *rqstp, SVCXPRT *transp)
sigprocmask(SIG_BLOCK, &sighup_mask, NULL);
ep = ex_search(&fsb.f_fsid);
hostset = defset = 0;
- if (ep && (chk_host(ep->ex_defdir, saddr, &defset, &hostset) ||
+ if (ep && (chk_host(ep->ex_defdir, saddr, &defset, &hostset,
+ &numsecflavors, &secflavorsp) ||
((dp = dirp_search(ep->ex_dirl, dirpath)) &&
- chk_host(dp, saddr, &defset, &hostset)) ||
+ chk_host(dp, saddr, &defset, &hostset, &numsecflavors,
+ &secflavorsp)) ||
(defset && scan_tree(ep->ex_defdir, saddr) == 0 &&
scan_tree(ep->ex_dirl, saddr) == 0))) {
if (bad) {
@@ -1012,10 +1024,15 @@ mntsrv(struct svc_req *rqstp, SVCXPRT *transp)
sigprocmask(SIG_UNBLOCK, &sighup_mask, NULL);
return;
}
- if (hostset & DP_HOSTSET)
+ if (hostset & DP_HOSTSET) {
fhr.fhr_flag = hostset;
- else
+ fhr.fhr_numsecflavors = numsecflavors;
+ fhr.fhr_secflavors = secflavorsp;
+ } else {
fhr.fhr_flag = defset;
+ fhr.fhr_numsecflavors = ep->ex_defnumsecflavors;
+ fhr.fhr_secflavors = ep->ex_defsecflavors;
+ }
fhr.fhr_vers = rqstp->rq_vers;
/* Get the file handle */
memset(&fhr.fhr_fh, 0, sizeof(nfsfh_t));
@@ -1028,8 +1045,6 @@ mntsrv(struct svc_req *rqstp, SVCXPRT *transp)
sigprocmask(SIG_UNBLOCK, &sighup_mask, NULL);
return;
}
- fhr.fhr_numsecflavors = ep->ex_numsecflavors;
- fhr.fhr_secflavors = ep->ex_secflavors;
if (!svc_sendreply(transp, (xdrproc_t)xdr_fhs,
(caddr_t)&fhr))
syslog(LOG_ERR, "can't send reply");
@@ -1648,6 +1663,8 @@ get_exportlist(void)
int done;
struct nfsex_args eargs;
+ if (suspend_nfsd != 0)
+ (void)nfssvc(NFSSVC_SUSPENDNFSD, NULL);
v4root_dirpath[0] = '\0';
bzero(&export, sizeof(export));
export.ex_flags = MNT_DELEXPORT;
@@ -1776,6 +1793,9 @@ get_exportlist(void)
*/
if (run_v4server > 0 && has_publicfh == 0)
(void) nfssvc(NFSSVC_NOPUBLICFH, NULL);
+
+ /* Resume the nfsd. If they weren't suspended, this is harmless. */
+ (void)nfssvc(NFSSVC_RESUMENFSD, NULL);
}
/*
@@ -1881,11 +1901,21 @@ hang_dirp(struct dirlist *dp, struct grouplist *grp, struct exportlist *ep,
ep->ex_defdir = dp;
if (grp == (struct grouplist *)NULL) {
ep->ex_defdir->dp_flag |= DP_DEFSET;
+ /* Save the default security flavors list. */
+ ep->ex_defnumsecflavors = ep->ex_numsecflavors;
+ if (ep->ex_numsecflavors > 0)
+ memcpy(ep->ex_defsecflavors, ep->ex_secflavors,
+ sizeof(ep->ex_secflavors));
} else while (grp) {
hp = get_ht();
hp->ht_grp = grp;
hp->ht_next = ep->ex_defdir->dp_hosts;
ep->ex_defdir->dp_hosts = hp;
+ /* Save the security flavors list for this host set. */
+ grp->gr_numsecflavors = ep->ex_numsecflavors;
+ if (ep->ex_numsecflavors > 0)
+ memcpy(grp->gr_secflavors, ep->ex_secflavors,
+ sizeof(ep->ex_secflavors));
grp = grp->gr_next;
}
} else {
@@ -1895,7 +1925,7 @@ hang_dirp(struct dirlist *dp, struct grouplist *grp, struct exportlist *ep,
*/
while (dp) {
dp2 = dp->dp_left;
- add_dlist(&ep->ex_dirl, dp, grp, flags);
+ add_dlist(&ep->ex_dirl, dp, grp, flags, ep);
dp = dp2;
}
}
@@ -1907,7 +1937,7 @@ hang_dirp(struct dirlist *dp, struct grouplist *grp, struct exportlist *ep,
*/
void
add_dlist(struct dirlist **dpp, struct dirlist *newdp, struct grouplist *grp,
- int flags)
+ int flags, struct exportlist *ep)
{
struct dirlist *dp;
struct hostlist *hp;
@@ -1917,10 +1947,10 @@ add_dlist(struct dirlist **dpp, struct dirlist *newdp, struct grouplist *grp,
if (dp) {
cmp = strcmp(dp->dp_dirp, newdp->dp_dirp);
if (cmp > 0) {
- add_dlist(&dp->dp_left, newdp, grp, flags);
+ add_dlist(&dp->dp_left, newdp, grp, flags, ep);
return;
} else if (cmp < 0) {
- add_dlist(&dp->dp_right, newdp, grp, flags);
+ add_dlist(&dp->dp_right, newdp, grp, flags, ep);
return;
} else
free((caddr_t)newdp);
@@ -1939,10 +1969,20 @@ add_dlist(struct dirlist **dpp, struct dirlist *newdp, struct grouplist *grp,
hp->ht_grp = grp;
hp->ht_next = dp->dp_hosts;
dp->dp_hosts = hp;
+ /* Save the security flavors list for this host set. */
+ grp->gr_numsecflavors = ep->ex_numsecflavors;
+ if (ep->ex_numsecflavors > 0)
+ memcpy(grp->gr_secflavors, ep->ex_secflavors,
+ sizeof(ep->ex_secflavors));
grp = grp->gr_next;
} while (grp);
} else {
dp->dp_flag |= DP_DEFSET;
+ /* Save the default security flavors list. */
+ ep->ex_defnumsecflavors = ep->ex_numsecflavors;
+ if (ep->ex_numsecflavors > 0)
+ memcpy(ep->ex_defsecflavors, ep->ex_secflavors,
+ sizeof(ep->ex_secflavors));
}
}
@@ -1971,7 +2011,7 @@ dirp_search(struct dirlist *dp, char *dirp)
*/
int
chk_host(struct dirlist *dp, struct sockaddr *saddr, int *defsetp,
- int *hostsetp)
+ int *hostsetp, int *numsecflavors, int **secflavorsp)
{
struct hostlist *hp;
struct grouplist *grp;
@@ -1990,6 +2030,12 @@ chk_host(struct dirlist *dp, struct sockaddr *saddr, int *defsetp,
if (!sacmp(ai->ai_addr, saddr, NULL)) {
*hostsetp =
(hp->ht_flag | DP_HOSTSET);
+ if (numsecflavors != NULL) {
+ *numsecflavors =
+ grp->gr_numsecflavors;
+ *secflavorsp =
+ grp->gr_secflavors;
+ }
return (1);
}
}
@@ -2000,6 +2046,12 @@ chk_host(struct dirlist *dp, struct sockaddr *saddr, int *defsetp,
(struct sockaddr *)
&grp->gr_ptr.gt_net.nt_mask)) {
*hostsetp = (hp->ht_flag | DP_HOSTSET);
+ if (numsecflavors != NULL) {
+ *numsecflavors =
+ grp->gr_numsecflavors;
+ *secflavorsp =
+ grp->gr_secflavors;
+ }
return (1);
}
break;
@@ -2021,7 +2073,7 @@ scan_tree(struct dirlist *dp, struct sockaddr *saddr)
if (dp) {
if (scan_tree(dp->dp_left, saddr))
return (1);
- if (chk_host(dp, saddr, &defset, &hostset))
+ if (chk_host(dp, saddr, &defset, &hostset, NULL, NULL))
return (1);
if (scan_tree(dp->dp_right, saddr))
return (1);
@@ -2461,11 +2513,11 @@ do_mount(struct exportlist *ep, struct grouplist *grp, int exflags,
}
if (errno == EPERM) {
if (debug)
- warnx("can't change attributes for %s",
- dirp);
+ warnx("can't change attributes for %s: %s",
+ dirp, errmsg);
syslog(LOG_ERR,
- "can't change attributes for %s",
- dirp);
+ "can't change attributes for %s: %s",
+ dirp, errmsg);
ret = 1;
goto error_exit;
}
diff --git a/usr.sbin/moused/Makefile.depend b/usr.sbin/moused/Makefile.depend
new file mode 100644
index 0000000..8825ffd
--- /dev/null
+++ b/usr.sbin/moused/Makefile.depend
@@ -0,0 +1,21 @@
+# Autogenerated - do NOT edit!
+
+DEP_RELDIR := ${_PARSEDIR:S,${SRCTOP}/,,}
+
+DEP_MACHINE := ${.PARSEFILE:E}
+
+DIRDEPS = \
+ gnu/lib/libgcc \
+ include \
+ include/xlocale \
+ lib/${CSU_DIR} \
+ lib/libc \
+ lib/libutil \
+ lib/msun \
+
+
+.include <dirdeps.mk>
+
+.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+# local dependencies - needed for -jN in clean tree
+.endif
diff --git a/usr.sbin/moused/moused.c b/usr.sbin/moused/moused.c
index 78e65fa..93eec99 100644
--- a/usr.sbin/moused/moused.c
+++ b/usr.sbin/moused/moused.c
@@ -408,6 +408,7 @@ static struct rodentparam {
int cfd; /* /dev/consolectl file descriptor */
int mremsfd; /* mouse remote server file descriptor */
int mremcfd; /* mouse remote client file descriptor */
+ int is_removable; /* set if device is removable, like USB */
long clickthreshold; /* double click speed in msec */
long button2timeout; /* 3 button emulation timeout */
mousehw_t hw; /* mouse device hardware information */
@@ -434,6 +435,7 @@ static struct rodentparam {
.cfd = -1,
.mremsfd = -1,
.mremcfd = -1,
+ .is_removable = 0,
.clickthreshold = DFLT_CLICKTHRESHOLD,
.button2timeout = DFLT_BUTTON2TIMEOUT,
.accelx = 1.0,
@@ -570,7 +572,6 @@ main(int argc, char *argv[])
int c;
int i;
int j;
- static int retry;
for (i = 0; i < MOUSE_MAXBUTTON; ++i)
mstate[i] = &bstate[i];
@@ -876,10 +877,8 @@ main(int argc, char *argv[])
usage();
}
- retry = 1;
- if (strncmp(rodent.portname, "/dev/ums", 8) == 0) {
- retry = 5;
- }
+ if (strncmp(rodent.portname, "/dev/ums", 8) == 0)
+ rodent.is_removable = 1;
for (;;) {
if (setjmp(env) == 0) {
@@ -888,13 +887,8 @@ main(int argc, char *argv[])
signal(SIGQUIT, cleanup);
signal(SIGTERM, cleanup);
signal(SIGUSR1, pause_mouse);
- for (i = 0; i < retry; ++i) {
- if (i > 0)
- sleep(2);
- rodent.mfd = open(rodent.portname, O_RDWR | O_NONBLOCK);
- if (rodent.mfd != -1 || errno != ENOENT)
- break;
- }
+
+ rodent.mfd = open(rodent.portname, O_RDWR | O_NONBLOCK);
if (rodent.mfd == -1)
logerr(1, "unable to open %s", rodent.portname);
if (r_identify() == MOUSE_PROTO_UNKNOWN) {
@@ -944,6 +938,8 @@ main(int argc, char *argv[])
if (rodent.cfd != -1)
close(rodent.cfd);
rodent.mfd = rodent.cfd = -1;
+ if (rodent.is_removable)
+ exit(0);
}
/* NOT REACHED */
diff --git a/usr.sbin/mptable/Makefile.depend b/usr.sbin/mptable/Makefile.depend
new file mode 100644
index 0000000..a839545
--- /dev/null
+++ b/usr.sbin/mptable/Makefile.depend
@@ -0,0 +1,19 @@
+# Autogenerated - do NOT edit!
+
+DEP_RELDIR := ${_PARSEDIR:S,${SRCTOP}/,,}
+
+DEP_MACHINE := ${.PARSEFILE:E}
+
+DIRDEPS = \
+ gnu/lib/libgcc \
+ include \
+ include/xlocale \
+ lib/${CSU_DIR} \
+ lib/libc \
+
+
+.include <dirdeps.mk>
+
+.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+# local dependencies - needed for -jN in clean tree
+.endif
diff --git a/usr.sbin/mptutil/Makefile.depend b/usr.sbin/mptutil/Makefile.depend
new file mode 100644
index 0000000..f9f3597
--- /dev/null
+++ b/usr.sbin/mptutil/Makefile.depend
@@ -0,0 +1,22 @@
+# Autogenerated - do NOT edit!
+
+DEP_RELDIR := ${_PARSEDIR:S,${SRCTOP}/,,}
+
+DEP_MACHINE := ${.PARSEFILE:E}
+
+DIRDEPS = \
+ gnu/lib/libgcc \
+ include \
+ include/xlocale \
+ lib/${CSU_DIR} \
+ lib/libc \
+ lib/libcam \
+ lib/libsbuf \
+ lib/libutil \
+
+
+.include <dirdeps.mk>
+
+.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+# local dependencies - needed for -jN in clean tree
+.endif
diff --git a/usr.sbin/mtest/Makefile.depend b/usr.sbin/mtest/Makefile.depend
new file mode 100644
index 0000000..16b5e42
--- /dev/null
+++ b/usr.sbin/mtest/Makefile.depend
@@ -0,0 +1,20 @@
+# Autogenerated - do NOT edit!
+
+DEP_RELDIR := ${_PARSEDIR:S,${SRCTOP}/,,}
+
+DEP_MACHINE := ${.PARSEFILE:E}
+
+DIRDEPS = \
+ gnu/lib/libgcc \
+ include \
+ include/arpa \
+ include/xlocale \
+ lib/${CSU_DIR} \
+ lib/libc \
+
+
+.include <dirdeps.mk>
+
+.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+# local dependencies - needed for -jN in clean tree
+.endif
diff --git a/usr.sbin/mtree/Makefile.depend b/usr.sbin/mtree/Makefile.depend
new file mode 100644
index 0000000..7520d5d
--- /dev/null
+++ b/usr.sbin/mtree/Makefile.depend
@@ -0,0 +1,20 @@
+# Autogenerated - do NOT edit!
+
+DEP_RELDIR := ${_PARSEDIR:S,${SRCTOP}/,,}
+
+DEP_MACHINE := ${.PARSEFILE:E}
+
+DIRDEPS = \
+ gnu/lib/libgcc \
+ include \
+ include/xlocale \
+ lib/${CSU_DIR} \
+ lib/libc \
+ lib/libmd \
+
+
+.include <dirdeps.mk>
+
+.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+# local dependencies - needed for -jN in clean tree
+.endif
diff --git a/usr.sbin/mtree/mtree.c b/usr.sbin/mtree/mtree.c
index 49e3e6b..e90a5bb 100644
--- a/usr.sbin/mtree/mtree.c
+++ b/usr.sbin/mtree/mtree.c
@@ -52,7 +52,8 @@ __FBSDID("$FreeBSD$");
#include "extern.h"
int ftsoptions = FTS_PHYSICAL;
-int cflag, dflag, eflag, iflag, nflag, qflag, rflag, sflag, uflag, Uflag, wflag;
+int dflag, eflag, iflag, nflag, qflag, rflag, sflag, uflag, wflag;
+static int cflag, Uflag;
u_int keys;
char fullpath[MAXPATHLEN];
diff --git a/usr.sbin/named-checkconf/Makefile.depend b/usr.sbin/named-checkconf/Makefile.depend
new file mode 100644
index 0000000..78e28c0
--- /dev/null
+++ b/usr.sbin/named-checkconf/Makefile.depend
@@ -0,0 +1,28 @@
+# Autogenerated - do NOT edit!
+
+DEP_RELDIR := ${_PARSEDIR:S,${SRCTOP}/,,}
+
+DEP_MACHINE := ${.PARSEFILE:E}
+
+DIRDEPS = \
+ gnu/lib/libgcc \
+ include \
+ include/arpa \
+ include/xlocale \
+ lib/${CSU_DIR} \
+ lib/bind/bind9 \
+ lib/bind/dns \
+ lib/bind/isc \
+ lib/bind/isccc \
+ lib/bind/isccfg \
+ lib/bind/lwres \
+ lib/libc \
+ lib/libthr \
+ secure/lib/libcrypto \
+
+
+.include <dirdeps.mk>
+
+.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+# local dependencies - needed for -jN in clean tree
+.endif
diff --git a/usr.sbin/named-checkzone/Makefile.depend b/usr.sbin/named-checkzone/Makefile.depend
new file mode 100644
index 0000000..78e28c0
--- /dev/null
+++ b/usr.sbin/named-checkzone/Makefile.depend
@@ -0,0 +1,28 @@
+# Autogenerated - do NOT edit!
+
+DEP_RELDIR := ${_PARSEDIR:S,${SRCTOP}/,,}
+
+DEP_MACHINE := ${.PARSEFILE:E}
+
+DIRDEPS = \
+ gnu/lib/libgcc \
+ include \
+ include/arpa \
+ include/xlocale \
+ lib/${CSU_DIR} \
+ lib/bind/bind9 \
+ lib/bind/dns \
+ lib/bind/isc \
+ lib/bind/isccc \
+ lib/bind/isccfg \
+ lib/bind/lwres \
+ lib/libc \
+ lib/libthr \
+ secure/lib/libcrypto \
+
+
+.include <dirdeps.mk>
+
+.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+# local dependencies - needed for -jN in clean tree
+.endif
diff --git a/usr.sbin/named-journalprint/Makefile.depend b/usr.sbin/named-journalprint/Makefile.depend
new file mode 100644
index 0000000..418e041
--- /dev/null
+++ b/usr.sbin/named-journalprint/Makefile.depend
@@ -0,0 +1,27 @@
+# Autogenerated - do NOT edit!
+
+DEP_RELDIR := ${_PARSEDIR:S,${SRCTOP}/,,}
+
+DEP_MACHINE := ${.PARSEFILE:E}
+
+DIRDEPS = \
+ gnu/lib/libgcc \
+ include \
+ include/xlocale \
+ lib/${CSU_DIR} \
+ lib/bind/bind9 \
+ lib/bind/dns \
+ lib/bind/isc \
+ lib/bind/isccc \
+ lib/bind/isccfg \
+ lib/bind/lwres \
+ lib/libc \
+ lib/libthr \
+ secure/lib/libcrypto \
+
+
+.include <dirdeps.mk>
+
+.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+# local dependencies - needed for -jN in clean tree
+.endif
diff --git a/usr.sbin/named/Makefile.depend b/usr.sbin/named/Makefile.depend
new file mode 100644
index 0000000..78e28c0
--- /dev/null
+++ b/usr.sbin/named/Makefile.depend
@@ -0,0 +1,28 @@
+# Autogenerated - do NOT edit!
+
+DEP_RELDIR := ${_PARSEDIR:S,${SRCTOP}/,,}
+
+DEP_MACHINE := ${.PARSEFILE:E}
+
+DIRDEPS = \
+ gnu/lib/libgcc \
+ include \
+ include/arpa \
+ include/xlocale \
+ lib/${CSU_DIR} \
+ lib/bind/bind9 \
+ lib/bind/dns \
+ lib/bind/isc \
+ lib/bind/isccc \
+ lib/bind/isccfg \
+ lib/bind/lwres \
+ lib/libc \
+ lib/libthr \
+ secure/lib/libcrypto \
+
+
+.include <dirdeps.mk>
+
+.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+# local dependencies - needed for -jN in clean tree
+.endif
diff --git a/usr.sbin/ndiscvt/Makefile.depend b/usr.sbin/ndiscvt/Makefile.depend
new file mode 100644
index 0000000..ee58cc4
--- /dev/null
+++ b/usr.sbin/ndiscvt/Makefile.depend
@@ -0,0 +1,25 @@
+# Autogenerated - do NOT edit!
+
+DEP_RELDIR := ${_PARSEDIR:S,${SRCTOP}/,,}
+
+DEP_MACHINE := ${.PARSEFILE:E}
+
+DIRDEPS = \
+ gnu/lib/libgcc \
+ include \
+ include/xlocale \
+ lib/${CSU_DIR} \
+ lib/libc \
+
+
+.include <dirdeps.mk>
+
+.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+# local dependencies - needed for -jN in clean tree
+inf-parse.o: inf-parse.c
+inf-parse.po: inf-parse.c
+inf-token.o: inf-token.c
+inf-token.o: y.tab.h
+inf-token.po: inf-token.c
+inf-token.po: y.tab.h
+.endif
diff --git a/usr.sbin/ndp/Makefile.depend b/usr.sbin/ndp/Makefile.depend
new file mode 100644
index 0000000..16b5e42
--- /dev/null
+++ b/usr.sbin/ndp/Makefile.depend
@@ -0,0 +1,20 @@
+# Autogenerated - do NOT edit!
+
+DEP_RELDIR := ${_PARSEDIR:S,${SRCTOP}/,,}
+
+DEP_MACHINE := ${.PARSEFILE:E}
+
+DIRDEPS = \
+ gnu/lib/libgcc \
+ include \
+ include/arpa \
+ include/xlocale \
+ lib/${CSU_DIR} \
+ lib/libc \
+
+
+.include <dirdeps.mk>
+
+.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+# local dependencies - needed for -jN in clean tree
+.endif
diff --git a/usr.sbin/ndp/ndp.8 b/usr.sbin/ndp/ndp.8
index 76f558c..1fb63f81 100644
--- a/usr.sbin/ndp/ndp.8
+++ b/usr.sbin/ndp/ndp.8
@@ -29,7 +29,7 @@
.\"
.\" $FreeBSD$
.\"
-.Dd September 2, 2009
+.Dd July 9, 2012
.Dt NDP 8
.Os
.\"
@@ -192,15 +192,6 @@ on
This flag is set by
.Va net.inet6.ip6.auto_linklocal
sysctl variable.
-.It Ic prefer_source
-Prefer addresses on the
-.Ar interface
-as candidates of the source address for outgoing packets.
-The default value of this flag is off.
-For more details about the entire algorithm of source address
-selection, see the
-.Pa IMPLEMENTATION
-file supplied with the KAME kit.
.It Ic disabled
Disable IPv6 operation on the interface.
When disabled, the interface discards any IPv6 packets
diff --git a/usr.sbin/ndp/ndp.c b/usr.sbin/ndp/ndp.c
index e245ac2..be21d0f 100644
--- a/usr.sbin/ndp/ndp.c
+++ b/usr.sbin/ndp/ndp.c
@@ -1008,9 +1008,6 @@ ifinfo(ifname, argc, argv)
#ifdef ND6_IFF_AUTO_LINKLOCAL
SETFLAG("auto_linklocal", ND6_IFF_AUTO_LINKLOCAL);
#endif
-#ifdef ND6_IFF_PREFER_SOURCE
- SETFLAG("prefer_source", ND6_IFF_PREFER_SOURCE);
-#endif
SETVALUE("basereachable", ND.basereachable);
SETVALUE("retrans", ND.retrans);
SETVALUE("curhlim", ND.chlim);
@@ -1084,10 +1081,6 @@ ifinfo(ifname, argc, argv)
if ((ND.flags & ND6_IFF_AUTO_LINKLOCAL))
printf("auto_linklocal ");
#endif
-#ifdef ND6_IFF_PREFER_SOURCE
- if ((ND.flags & ND6_IFF_PREFER_SOURCE))
- printf("prefer_source ");
-#endif
}
putc('\n', stdout);
#undef ND
diff --git a/usr.sbin/newsyslog/Makefile.depend b/usr.sbin/newsyslog/Makefile.depend
new file mode 100644
index 0000000..a839545
--- /dev/null
+++ b/usr.sbin/newsyslog/Makefile.depend
@@ -0,0 +1,19 @@
+# Autogenerated - do NOT edit!
+
+DEP_RELDIR := ${_PARSEDIR:S,${SRCTOP}/,,}
+
+DEP_MACHINE := ${.PARSEFILE:E}
+
+DIRDEPS = \
+ gnu/lib/libgcc \
+ include \
+ include/xlocale \
+ lib/${CSU_DIR} \
+ lib/libc \
+
+
+.include <dirdeps.mk>
+
+.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+# local dependencies - needed for -jN in clean tree
+.endif
diff --git a/usr.sbin/newsyslog/newsyslog.c b/usr.sbin/newsyslog/newsyslog.c
index 227ea00..875f911 100644
--- a/usr.sbin/newsyslog/newsyslog.c
+++ b/usr.sbin/newsyslog/newsyslog.c
@@ -145,7 +145,7 @@ struct compress_types {
const char *path; /* Path to compression program */
};
-const struct compress_types compress_type[COMPRESS_TYPES] = {
+static const struct compress_types compress_type[COMPRESS_TYPES] = {
{ "", "", "" }, /* no compression */
{ "Z", COMPRESS_SUFFIX_GZ, _PATH_GZIP }, /* gzip compression */
{ "J", COMPRESS_SUFFIX_BZ2, _PATH_BZIP2 }, /* bzip2 compression */
@@ -206,42 +206,44 @@ typedef enum {
} fk_entry;
STAILQ_HEAD(cflist, conf_entry);
-SLIST_HEAD(swlisthead, sigwork_entry) swhead = SLIST_HEAD_INITIALIZER(swhead);
-SLIST_HEAD(zwlisthead, zipwork_entry) zwhead = SLIST_HEAD_INITIALIZER(zwhead);
+static SLIST_HEAD(swlisthead, sigwork_entry) swhead =
+ SLIST_HEAD_INITIALIZER(swhead);
+static SLIST_HEAD(zwlisthead, zipwork_entry) zwhead =
+ SLIST_HEAD_INITIALIZER(zwhead);
STAILQ_HEAD(ilist, include_entry);
int dbg_at_times; /* -D Show details of 'trim_at' code */
-int archtodir = 0; /* Archive old logfiles to other directory */
-int createlogs; /* Create (non-GLOB) logfiles which do not */
+static int archtodir = 0; /* Archive old logfiles to other directory */
+static int createlogs; /* Create (non-GLOB) logfiles which do not */
/* already exist. 1=='for entries with */
/* C flag', 2=='for all entries'. */
int verbose = 0; /* Print out what's going on */
-int needroot = 1; /* Root privs are necessary */
+static int needroot = 1; /* Root privs are necessary */
int noaction = 0; /* Don't do anything, just show it */
-int norotate = 0; /* Don't rotate */
-int nosignal; /* Do not send any signals */
-int enforcepid = 0; /* If PID file does not exist or empty, do nothing */
-int force = 0; /* Force the trim no matter what */
-int rotatereq = 0; /* -R = Always rotate the file(s) as given */
+static int norotate = 0; /* Don't rotate */
+static int nosignal; /* Do not send any signals */
+static int enforcepid = 0; /* If PID file does not exist or empty, do nothing */
+static int force = 0; /* Force the trim no matter what */
+static int rotatereq = 0; /* -R = Always rotate the file(s) as given */
/* on the command (this also requires */
/* that a list of files *are* given on */
/* the run command). */
-char *requestor; /* The name given on a -R request */
-char *timefnamefmt = NULL; /* Use time based filenames instead of .0 etc */
-char *archdirname; /* Directory path to old logfiles archive */
-char *destdir = NULL; /* Directory to treat at root for logs */
-const char *conf; /* Configuration file to use */
+static char *requestor; /* The name given on a -R request */
+static char *timefnamefmt = NULL;/* Use time based filenames instead of .0 */
+static char *archdirname; /* Directory path to old logfiles archive */
+static char *destdir = NULL; /* Directory to treat at root for logs */
+static const char *conf; /* Configuration file to use */
struct ptime_data *dbg_timenow; /* A "timenow" value set via -D option */
-struct ptime_data *timenow; /* The time to use for checking at-fields */
+static struct ptime_data *timenow; /* The time to use for checking at-fields */
#define DAYTIME_LEN 16
-char daytime[DAYTIME_LEN]; /* The current time in human readable form,
- * used for rotation-tracking messages. */
-char hostname[MAXHOSTNAMELEN]; /* hostname */
+static char daytime[DAYTIME_LEN];/* The current time in human readable form,
+ * used for rotation-tracking messages. */
+static char hostname[MAXHOSTNAMELEN]; /* hostname */
-const char *path_syslogpid = _PATH_SYSLOGPID;
+static const char *path_syslogpid = _PATH_SYSLOGPID;
static struct cflist *get_worklist(char **files);
static void parse_file(FILE *cf, struct cflist *work_p, struct cflist *glob_p,
@@ -1972,7 +1974,8 @@ do_zipwork(struct zipwork_entry *zwork)
else
pgm_name++;
- if (zwork->zw_swork != NULL && zwork->zw_swork->sw_pidok <= 0) {
+ if (zwork->zw_swork != NULL && zwork->zw_swork->run_cmd == 0 &&
+ zwork->zw_swork->sw_pidok <= 0) {
warnx(
"log %s not compressed because daemon(s) not notified",
zwork->zw_fname);
diff --git a/usr.sbin/newsyslog/newsyslog.conf.5 b/usr.sbin/newsyslog/newsyslog.conf.5
index 589d98f..a053f2f 100644
--- a/usr.sbin/newsyslog/newsyslog.conf.5
+++ b/usr.sbin/newsyslog/newsyslog.conf.5
@@ -155,12 +155,17 @@ The particular format of the time in restricted
.Tn ISO 8601
is:
.Sm off
+.Oo Oo Oo Oo Oo
+.Va cc Oc
+.Va yy Oc
+.Va mm Oc
+.Va dd Oc
.Oo
-.Op Oo Oo Oo Va cc Oc Va yy Oc Va mm Oc Va dd
-.Oo
-.Li T
-.Op Va hh Oo Va mm Oo Va ss Oc Oc Oc
-.Oc .
+.Li T Oo
+.Va hh Oo
+.Va mm Oo
+.Va ss
+.Oc Oc Oc Oc Oc .
.Sm on
Optional date fields default to the appropriate component of the
current date; optional time fields default to midnight; hence if today
diff --git a/usr.sbin/nfscbd/Makefile.depend b/usr.sbin/nfscbd/Makefile.depend
new file mode 100644
index 0000000..1832799
--- /dev/null
+++ b/usr.sbin/nfscbd/Makefile.depend
@@ -0,0 +1,20 @@
+# Autogenerated - do NOT edit!
+
+DEP_RELDIR := ${_PARSEDIR:S,${SRCTOP}/,,}
+
+DEP_MACHINE := ${.PARSEFILE:E}
+
+DIRDEPS = \
+ gnu/lib/libgcc \
+ include \
+ include/rpc \
+ include/xlocale \
+ lib/${CSU_DIR} \
+ lib/libc \
+
+
+.include <dirdeps.mk>
+
+.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+# local dependencies - needed for -jN in clean tree
+.endif
diff --git a/usr.sbin/nfscbd/nfscbd.c b/usr.sbin/nfscbd/nfscbd.c
index ba09311..c9153b4 100644
--- a/usr.sbin/nfscbd/nfscbd.c
+++ b/usr.sbin/nfscbd/nfscbd.c
@@ -66,12 +66,12 @@ __FBSDID("$FreeBSD$");
/* Global defs */
#ifdef DEBUG
#define syslog(e, s) fprintf(stderr,(s))
-int debug = 1;
+static int debug = 1;
#else
-int debug = 0;
+static int debug = 0;
#endif
-pid_t children;
+static pid_t children;
static void nonfs(int);
static void reapchild(int);
diff --git a/usr.sbin/nfsd/Makefile.depend b/usr.sbin/nfsd/Makefile.depend
new file mode 100644
index 0000000..a3e1b44
--- /dev/null
+++ b/usr.sbin/nfsd/Makefile.depend
@@ -0,0 +1,22 @@
+# Autogenerated - do NOT edit!
+
+DEP_RELDIR := ${_PARSEDIR:S,${SRCTOP}/,,}
+
+DEP_MACHINE := ${.PARSEFILE:E}
+
+DIRDEPS = \
+ gnu/lib/libgcc \
+ include \
+ include/arpa \
+ include/rpc \
+ include/rpcsvc \
+ include/xlocale \
+ lib/${CSU_DIR} \
+ lib/libc \
+
+
+.include <dirdeps.mk>
+
+.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+# local dependencies - needed for -jN in clean tree
+.endif
diff --git a/usr.sbin/nfsd/nfsd.c b/usr.sbin/nfsd/nfsd.c
index c5cec5e..c269e47 100644
--- a/usr.sbin/nfsd/nfsd.c
+++ b/usr.sbin/nfsd/nfsd.c
@@ -75,22 +75,22 @@ static const char rcsid[] =
/* Global defs */
#ifdef DEBUG
#define syslog(e, s...) fprintf(stderr,s)
-int debug = 1;
+static int debug = 1;
#else
-int debug = 0;
+static int debug = 0;
#endif
#define NFSD_STABLERESTART "/var/db/nfs-stablerestart"
#define NFSD_STABLEBACKUP "/var/db/nfs-stablerestart.bak"
#define MAXNFSDCNT 256
#define DEFNFSDCNT 4
-pid_t children[MAXNFSDCNT]; /* PIDs of children */
-int nfsdcnt; /* number of children */
-int new_syscall;
-int run_v4server = 1; /* Force running of nfsv4 server */
-int nfssvc_nfsd; /* Set to correct NFSSVC_xxx flag */
-int stablefd = -1; /* Fd for the stable restart file */
-int backupfd; /* Fd for the backup stable restart file */
+static pid_t children[MAXNFSDCNT]; /* PIDs of children */
+static int nfsdcnt; /* number of children */
+static int new_syscall;
+static int run_v4server = 1; /* Force running of nfsv4 server */
+static int nfssvc_nfsd; /* Set to correct NFSSVC_xxx flag */
+static int stablefd = -1; /* Fd for the stable restart file */
+static int backupfd; /* Fd for the backup stable restart file */
void cleanup(int);
void child_cleanup(int);
@@ -590,7 +590,7 @@ main(int argc, char **argv)
if ((tcpsock = socket(AF_INET, SOCK_STREAM,
0)) < 0) {
syslog(LOG_ERR,
- "can't create tpc socket");
+ "can't create tcp socket");
nfsd_exit(1);
}
if (setsockopt(tcpsock, SOL_SOCKET,
diff --git a/usr.sbin/nfsdumpstate/Makefile.depend b/usr.sbin/nfsdumpstate/Makefile.depend
new file mode 100644
index 0000000..16b5e42
--- /dev/null
+++ b/usr.sbin/nfsdumpstate/Makefile.depend
@@ -0,0 +1,20 @@
+# Autogenerated - do NOT edit!
+
+DEP_RELDIR := ${_PARSEDIR:S,${SRCTOP}/,,}
+
+DEP_MACHINE := ${.PARSEFILE:E}
+
+DIRDEPS = \
+ gnu/lib/libgcc \
+ include \
+ include/arpa \
+ include/xlocale \
+ lib/${CSU_DIR} \
+ lib/libc \
+
+
+.include <dirdeps.mk>
+
+.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+# local dependencies - needed for -jN in clean tree
+.endif
diff --git a/usr.sbin/nfsrevoke/Makefile.depend b/usr.sbin/nfsrevoke/Makefile.depend
new file mode 100644
index 0000000..a839545
--- /dev/null
+++ b/usr.sbin/nfsrevoke/Makefile.depend
@@ -0,0 +1,19 @@
+# Autogenerated - do NOT edit!
+
+DEP_RELDIR := ${_PARSEDIR:S,${SRCTOP}/,,}
+
+DEP_MACHINE := ${.PARSEFILE:E}
+
+DIRDEPS = \
+ gnu/lib/libgcc \
+ include \
+ include/xlocale \
+ lib/${CSU_DIR} \
+ lib/libc \
+
+
+.include <dirdeps.mk>
+
+.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+# local dependencies - needed for -jN in clean tree
+.endif
diff --git a/usr.sbin/nfsuserd/Makefile.depend b/usr.sbin/nfsuserd/Makefile.depend
new file mode 100644
index 0000000..1832799
--- /dev/null
+++ b/usr.sbin/nfsuserd/Makefile.depend
@@ -0,0 +1,20 @@
+# Autogenerated - do NOT edit!
+
+DEP_RELDIR := ${_PARSEDIR:S,${SRCTOP}/,,}
+
+DEP_MACHINE := ${.PARSEFILE:E}
+
+DIRDEPS = \
+ gnu/lib/libgcc \
+ include \
+ include/rpc \
+ include/xlocale \
+ lib/${CSU_DIR} \
+ lib/libc \
+
+
+.include <dirdeps.mk>
+
+.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+# local dependencies - needed for -jN in clean tree
+.endif
diff --git a/usr.sbin/ngctl/Makefile.depend b/usr.sbin/ngctl/Makefile.depend
new file mode 100644
index 0000000..90942ad
--- /dev/null
+++ b/usr.sbin/ngctl/Makefile.depend
@@ -0,0 +1,23 @@
+# Autogenerated - do NOT edit!
+
+DEP_RELDIR := ${_PARSEDIR:S,${SRCTOP}/,,}
+
+DEP_MACHINE := ${.PARSEFILE:E}
+
+DIRDEPS = \
+ gnu/lib/libgcc \
+ include \
+ include/xlocale \
+ lib/${CSU_DIR} \
+ lib/libc \
+ lib/libedit \
+ lib/libnetgraph \
+ lib/libthr \
+ lib/ncurses/ncurses \
+
+
+.include <dirdeps.mk>
+
+.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+# local dependencies - needed for -jN in clean tree
+.endif
diff --git a/usr.sbin/nghook/Makefile.depend b/usr.sbin/nghook/Makefile.depend
new file mode 100644
index 0000000..e6d80d3
--- /dev/null
+++ b/usr.sbin/nghook/Makefile.depend
@@ -0,0 +1,20 @@
+# Autogenerated - do NOT edit!
+
+DEP_RELDIR := ${_PARSEDIR:S,${SRCTOP}/,,}
+
+DEP_MACHINE := ${.PARSEFILE:E}
+
+DIRDEPS = \
+ gnu/lib/libgcc \
+ include \
+ include/xlocale \
+ lib/${CSU_DIR} \
+ lib/libc \
+ lib/libnetgraph \
+
+
+.include <dirdeps.mk>
+
+.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+# local dependencies - needed for -jN in clean tree
+.endif
diff --git a/usr.sbin/nologin/Makefile.depend b/usr.sbin/nologin/Makefile.depend
new file mode 100644
index 0000000..f5418c0
--- /dev/null
+++ b/usr.sbin/nologin/Makefile.depend
@@ -0,0 +1,17 @@
+# Autogenerated - do NOT edit!
+
+DEP_RELDIR := ${_PARSEDIR:S,${SRCTOP}/,,}
+
+DEP_MACHINE := ${.PARSEFILE:E}
+
+DIRDEPS = \
+ include \
+ lib/${CSU_DIR} \
+ lib/libc \
+
+
+.include <dirdeps.mk>
+
+.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+# local dependencies - needed for -jN in clean tree
+.endif
diff --git a/usr.sbin/nscd/Makefile.depend b/usr.sbin/nscd/Makefile.depend
new file mode 100644
index 0000000..0853258
--- /dev/null
+++ b/usr.sbin/nscd/Makefile.depend
@@ -0,0 +1,22 @@
+# Autogenerated - do NOT edit!
+
+DEP_RELDIR := ${_PARSEDIR:S,${SRCTOP}/,,}
+
+DEP_MACHINE := ${.PARSEFILE:E}
+
+DIRDEPS = \
+ gnu/lib/libgcc \
+ include \
+ include/xlocale \
+ lib/${CSU_DIR} \
+ lib/libc \
+ lib/libthr \
+ lib/libutil \
+ lib/msun \
+
+
+.include <dirdeps.mk>
+
+.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+# local dependencies - needed for -jN in clean tree
+.endif
diff --git a/usr.sbin/nscd/cachelib.c b/usr.sbin/nscd/cachelib.c
index afdbc0a..ab95b29 100644
--- a/usr.sbin/nscd/cachelib.c
+++ b/usr.sbin/nscd/cachelib.c
@@ -726,6 +726,12 @@ cache_read(struct cache_entry_ *entry, const char *key, size_t key_size,
TRACE_OUT(cache_read);
return (-1);
}
+ /* pretend that entry was not found if confidence is below threshold*/
+ if (find_res->confidence <
+ common_entry->common_params.confidence_threshold) {
+ TRACE_OUT(cache_read);
+ return (-1);
+ }
if ((common_entry->common_params.max_lifetime.tv_sec != 0) ||
(common_entry->common_params.max_lifetime.tv_usec != 0)) {
@@ -826,6 +832,24 @@ cache_write(struct cache_entry_ *entry, const char *key, size_t key_size,
item = HASHTABLE_GET_ENTRY(&(common_entry->items), hash);
find_res = HASHTABLE_ENTRY_FIND(cache_ht_, item, &item_data);
if (find_res != NULL) {
+ if (find_res->confidence < common_entry->common_params.confidence_threshold) {
+ /* duplicate entry is no error, if confidence is low */
+ if ((find_res->value_size == value_size) &&
+ (memcmp(find_res->value, value, value_size) == 0)) {
+ /* increase confidence on exact match (key and values) */
+ find_res->confidence++;
+ } else {
+ /* create new entry with low confidence, if value changed */
+ free(item_data.value);
+ item_data.value = malloc(value_size);
+ assert(item_data.value != NULL);
+ memcpy(item_data.value, value, value_size);
+ item_data.value_size = value_size;
+ find_res->confidence = 1;
+ }
+ TRACE_OUT(cache_write);
+ return (0);
+ }
TRACE_OUT(cache_write);
return (-1);
}
@@ -839,6 +863,8 @@ cache_write(struct cache_entry_ *entry, const char *key, size_t key_size,
memcpy(item_data.value, value, value_size);
item_data.value_size = value_size;
+ item_data.confidence = 1;
+
policy_item = common_entry->policies[0]->create_item_func();
policy_item->key = item_data.key;
policy_item->key_size = item_data.key_size;
diff --git a/usr.sbin/nscd/cachelib.h b/usr.sbin/nscd/cachelib.h
index 37f0041..9df50e7 100644
--- a/usr.sbin/nscd/cachelib.h
+++ b/usr.sbin/nscd/cachelib.h
@@ -92,6 +92,7 @@ struct common_cache_entry_params {
size_t satisf_elemsize; /* if entry size is exceeded,
* this number of elements will be left,
* others will be deleted */
+ int confidence_threshold; /* number matching replies required */
struct timeval max_lifetime; /* if 0 then no check is made */
enum cache_policy_t policy; /* policy used for transformations */
};
@@ -116,6 +117,7 @@ struct cache_ht_item_data_ {
size_t value_size;
struct cache_policy_item_ *fifo_policy_item;
+ int confidence; /* incremented for each verification */
};
struct cache_ht_item_ {
diff --git a/usr.sbin/nscd/config.c b/usr.sbin/nscd/config.c
index 856cf97..f44e986 100644
--- a/usr.sbin/nscd/config.c
+++ b/usr.sbin/nscd/config.c
@@ -209,6 +209,7 @@ create_def_configuration_entry(const char *name)
positive_params.max_elemsize = DEFAULT_POSITIVE_ELEMENTS_SIZE;
positive_params.satisf_elemsize = DEFAULT_POSITIVE_ELEMENTS_SIZE / 2;
positive_params.max_lifetime.tv_sec = DEFAULT_POSITIVE_LIFETIME;
+ positive_params.confidence_threshold = DEFAULT_POSITIVE_CONF_THRESH;
positive_params.policy = CPT_LRU;
memcpy(&negative_params, &positive_params,
@@ -216,6 +217,7 @@ create_def_configuration_entry(const char *name)
negative_params.max_elemsize = DEFAULT_NEGATIVE_ELEMENTS_SIZE;
negative_params.satisf_elemsize = DEFAULT_NEGATIVE_ELEMENTS_SIZE / 2;
negative_params.max_lifetime.tv_sec = DEFAULT_NEGATIVE_LIFETIME;
+ negative_params.confidence_threshold = DEFAULT_NEGATIVE_CONF_THRESH;
negative_params.policy = CPT_FIFO;
memset(&default_common_timeout, 0, sizeof(struct timeval));
diff --git a/usr.sbin/nscd/config.h b/usr.sbin/nscd/config.h
index 6c42932..29770e6 100644
--- a/usr.sbin/nscd/config.h
+++ b/usr.sbin/nscd/config.h
@@ -44,9 +44,11 @@
#define DEFAULT_POSITIVE_ELEMENTS_SIZE (2048)
#define DEFAULT_POSITIVE_LIFETIME (3600)
+#define DEFAULT_POSITIVE_CONF_THRESH (1)
#define DEFAULT_NEGATIVE_ELEMENTS_SIZE (2048)
#define DEFAULT_NEGATIVE_LIFETIME (60)
+#define DEFAULT_NEGATIVE_CONF_THRESH (1) /* (2) ??? */
#define DEFAULT_MULTIPART_ELEMENTS_SIZE (1024 * 8)
#define DEFAULT_MULITPART_SESSIONS_SIZE (1024)
diff --git a/usr.sbin/nscd/nscd.conf.5 b/usr.sbin/nscd/nscd.conf.5
index b5700a4..b59449b 100644
--- a/usr.sbin/nscd/nscd.conf.5
+++ b/usr.sbin/nscd/nscd.conf.5
@@ -102,6 +102,17 @@ The same as the positive-policy, but this one is applied to the negative
elements of the given
.Ar cachename .
The default policy is fifo.
+.It Va negative-confidence-threshold Oo Ar cachename Oc Op Ar value
+The number of times a query must have failed before the cache accepts
+that the element can not be found.
+At the default value of 1 each negative query result is cached and
+immediately returned from the cache on further queries.
+Higher numbers cause queries to be retried at the configured data
+sources the given number of times, before the negative result is
+returned from the cache on further queries.
+This allows to probe for the existence of an entry, and then to create
+it if it did not exist, without the negative probe result preventing
+access to the new entry for the duration of the negative TTL.
.It Va suggested-size Oo Ar cachename Oc Op Ar value
This is the internal hash table size.
The value should be a prime number for optimum performance.
diff --git a/usr.sbin/nscd/parser.c b/usr.sbin/nscd/parser.c
index a36821a..533dc79 100644
--- a/usr.sbin/nscd/parser.c
+++ b/usr.sbin/nscd/parser.c
@@ -167,6 +167,38 @@ set_negative_time_to_live(struct configuration *config,
TRACE_OUT(set_negative_time_to_live);
}
+static void
+set_positive_confidence_threshold(struct configuration *config,
+ const char *entry_name, int conf_thresh)
+{
+ struct configuration_entry *entry;
+
+ TRACE_IN(set_positive_conf_thresh);
+ assert(conf_thresh > 0);
+ assert(entry_name != NULL);
+
+ entry = find_create_entry(config, entry_name);
+ assert(entry != NULL);
+ entry->positive_cache_params.confidence_threshold = conf_thresh;
+
+ TRACE_OUT(set_positive_conf_thresh);
+}
+
+static void
+set_negative_confidence_threshold(struct configuration *config,
+ const char *entry_name, int conf_thresh)
+{
+ struct configuration_entry *entry;
+
+ TRACE_IN(set_negative_conf_thresh);
+ assert(conf_thresh > 0);
+ assert(entry_name != NULL);
+ entry = find_create_entry(config, entry_name);
+ assert(entry != NULL);
+ entry->negative_cache_params.confidence_threshold = conf_thresh;
+ TRACE_OUT(set_negative_conf_thresh);
+}
+
/*
* Hot count is actually the elements size limit.
*/
@@ -393,6 +425,12 @@ parse_config_file(struct configuration *config,
fields[1], value);
continue;
} else if ((field_count == 3) &&
+ (strcmp(fields[0], "positive-confidence-threshold") == 0) &&
+ ((value = get_number(fields[2], 1, -1)) != -1)) {
+ set_positive_confidence_threshold(config,
+ fields[1], value);
+ continue;
+ } else if ((field_count == 3) &&
(strcmp(fields[0], "positive-policy") == 0) &&
(check_cachename(fields[1]) == 0) &&
((value = get_policy(fields[2])) != -1)) {
@@ -416,6 +454,12 @@ parse_config_file(struct configuration *config,
fields[1], value);
continue;
} else if ((field_count == 3) &&
+ (strcmp(fields[0], "negative-confidence-threshold") == 0) &&
+ ((value = get_number(fields[2], 1, -1)) != -1)) {
+ set_negative_confidence_threshold(config,
+ fields[1], value);
+ continue;
+ } else if ((field_count == 3) &&
(strcmp(fields[0], "negative-policy") == 0) &&
(check_cachename(fields[1]) == 0) &&
((value = get_policy(fields[2])) != -1)) {
diff --git a/usr.sbin/nsec3hash/Makefile.depend b/usr.sbin/nsec3hash/Makefile.depend
new file mode 100644
index 0000000..78e28c0
--- /dev/null
+++ b/usr.sbin/nsec3hash/Makefile.depend
@@ -0,0 +1,28 @@
+# Autogenerated - do NOT edit!
+
+DEP_RELDIR := ${_PARSEDIR:S,${SRCTOP}/,,}
+
+DEP_MACHINE := ${.PARSEFILE:E}
+
+DIRDEPS = \
+ gnu/lib/libgcc \
+ include \
+ include/arpa \
+ include/xlocale \
+ lib/${CSU_DIR} \
+ lib/bind/bind9 \
+ lib/bind/dns \
+ lib/bind/isc \
+ lib/bind/isccc \
+ lib/bind/isccfg \
+ lib/bind/lwres \
+ lib/libc \
+ lib/libthr \
+ secure/lib/libcrypto \
+
+
+.include <dirdeps.mk>
+
+.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+# local dependencies - needed for -jN in clean tree
+.endif
diff --git a/usr.sbin/ntp/libntp/Makefile.depend b/usr.sbin/ntp/libntp/Makefile.depend
new file mode 100644
index 0000000..09476fe
--- /dev/null
+++ b/usr.sbin/ntp/libntp/Makefile.depend
@@ -0,0 +1,20 @@
+# Autogenerated - do NOT edit!
+
+DEP_RELDIR := ${_PARSEDIR:S,${SRCTOP}/,,}
+
+DEP_MACHINE := ${.PARSEFILE:E}
+
+DIRDEPS = \
+ include \
+ include/arpa \
+ include/xlocale \
+ lib/libmd \
+ lib/msun \
+ secure/lib/libcrypto \
+
+
+.include <dirdeps.mk>
+
+.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+# local dependencies - needed for -jN in clean tree
+.endif
diff --git a/usr.sbin/ntp/libopts/Makefile.depend b/usr.sbin/ntp/libopts/Makefile.depend
new file mode 100644
index 0000000..e248139
--- /dev/null
+++ b/usr.sbin/ntp/libopts/Makefile.depend
@@ -0,0 +1,16 @@
+# Autogenerated - do NOT edit!
+
+DEP_RELDIR := ${_PARSEDIR:S,${SRCTOP}/,,}
+
+DEP_MACHINE := ${.PARSEFILE:E}
+
+DIRDEPS = \
+ include \
+ include/xlocale \
+
+
+.include <dirdeps.mk>
+
+.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+# local dependencies - needed for -jN in clean tree
+.endif
diff --git a/usr.sbin/ntp/libparse/Makefile.depend b/usr.sbin/ntp/libparse/Makefile.depend
new file mode 100644
index 0000000..db05d20
--- /dev/null
+++ b/usr.sbin/ntp/libparse/Makefile.depend
@@ -0,0 +1,18 @@
+# Autogenerated - do NOT edit!
+
+DEP_RELDIR := ${_PARSEDIR:S,${SRCTOP}/,,}
+
+DEP_MACHINE := ${.PARSEFILE:E}
+
+DIRDEPS = \
+ include \
+ include/xlocale \
+ lib/msun \
+ secure/lib/libcrypto \
+
+
+.include <dirdeps.mk>
+
+.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+# local dependencies - needed for -jN in clean tree
+.endif
diff --git a/usr.sbin/ntp/ntp-keygen/Makefile.depend b/usr.sbin/ntp/ntp-keygen/Makefile.depend
new file mode 100644
index 0000000..b26d4df
--- /dev/null
+++ b/usr.sbin/ntp/ntp-keygen/Makefile.depend
@@ -0,0 +1,23 @@
+# Autogenerated - do NOT edit!
+
+DEP_RELDIR := ${_PARSEDIR:S,${SRCTOP}/,,}
+
+DEP_MACHINE := ${.PARSEFILE:E}
+
+DIRDEPS = \
+ gnu/lib/libgcc \
+ include \
+ include/xlocale \
+ lib/${CSU_DIR} \
+ lib/libc \
+ lib/libmd \
+ secure/lib/libcrypto \
+ usr.sbin/ntp/libntp \
+ usr.sbin/ntp/libopts \
+
+
+.include <dirdeps.mk>
+
+.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+# local dependencies - needed for -jN in clean tree
+.endif
diff --git a/usr.sbin/ntp/ntpd/Makefile.depend b/usr.sbin/ntp/ntpd/Makefile.depend
new file mode 100644
index 0000000..72d3eb6
--- /dev/null
+++ b/usr.sbin/ntp/ntpd/Makefile.depend
@@ -0,0 +1,29 @@
+# Autogenerated - do NOT edit!
+
+DEP_RELDIR := ${_PARSEDIR:S,${SRCTOP}/,,}
+
+DEP_MACHINE := ${.PARSEFILE:E}
+
+DIRDEPS = \
+ gnu/lib/libgcc \
+ include \
+ include/arpa \
+ include/xlocale \
+ lib/${CSU_DIR} \
+ lib/libc \
+ lib/libmd \
+ lib/librt \
+ lib/msun \
+ secure/lib/libcrypto \
+ usr.sbin/ntp/libntp \
+ usr.sbin/ntp/libopts \
+ usr.sbin/ntp/libparse \
+
+
+.include <dirdeps.mk>
+
+.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+# local dependencies - needed for -jN in clean tree
+version.o: version.c
+version.po: version.c
+.endif
diff --git a/usr.sbin/ntp/ntpdate/Makefile.depend b/usr.sbin/ntp/ntpdate/Makefile.depend
new file mode 100644
index 0000000..b27014c
--- /dev/null
+++ b/usr.sbin/ntp/ntpdate/Makefile.depend
@@ -0,0 +1,27 @@
+# Autogenerated - do NOT edit!
+
+DEP_RELDIR := ${_PARSEDIR:S,${SRCTOP}/,,}
+
+DEP_MACHINE := ${.PARSEFILE:E}
+
+DIRDEPS = \
+ gnu/lib/libgcc \
+ include \
+ include/arpa \
+ include/xlocale \
+ lib/${CSU_DIR} \
+ lib/libc \
+ lib/libmd \
+ lib/librt \
+ lib/msun \
+ secure/lib/libcrypto \
+ usr.sbin/ntp/libntp \
+
+
+.include <dirdeps.mk>
+
+.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+# local dependencies - needed for -jN in clean tree
+version.o: version.c
+version.po: version.c
+.endif
diff --git a/usr.sbin/ntp/ntpdc/Makefile.depend b/usr.sbin/ntp/ntpdc/Makefile.depend
new file mode 100644
index 0000000..80ce108
--- /dev/null
+++ b/usr.sbin/ntp/ntpdc/Makefile.depend
@@ -0,0 +1,30 @@
+# Autogenerated - do NOT edit!
+
+DEP_RELDIR := ${_PARSEDIR:S,${SRCTOP}/,,}
+
+DEP_MACHINE := ${.PARSEFILE:E}
+
+DIRDEPS = \
+ gnu/lib/libgcc \
+ include \
+ include/arpa \
+ include/xlocale \
+ lib/${CSU_DIR} \
+ lib/libc \
+ lib/libedit \
+ lib/libedit/edit/readline \
+ lib/libmd \
+ lib/msun \
+ lib/ncurses/ncurses \
+ secure/lib/libcrypto \
+ usr.sbin/ntp/libntp \
+ usr.sbin/ntp/libopts \
+
+
+.include <dirdeps.mk>
+
+.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+# local dependencies - needed for -jN in clean tree
+version.o: version.c
+version.po: version.c
+.endif
diff --git a/usr.sbin/ntp/ntpq/Makefile.depend b/usr.sbin/ntp/ntpq/Makefile.depend
new file mode 100644
index 0000000..80ce108
--- /dev/null
+++ b/usr.sbin/ntp/ntpq/Makefile.depend
@@ -0,0 +1,30 @@
+# Autogenerated - do NOT edit!
+
+DEP_RELDIR := ${_PARSEDIR:S,${SRCTOP}/,,}
+
+DEP_MACHINE := ${.PARSEFILE:E}
+
+DIRDEPS = \
+ gnu/lib/libgcc \
+ include \
+ include/arpa \
+ include/xlocale \
+ lib/${CSU_DIR} \
+ lib/libc \
+ lib/libedit \
+ lib/libedit/edit/readline \
+ lib/libmd \
+ lib/msun \
+ lib/ncurses/ncurses \
+ secure/lib/libcrypto \
+ usr.sbin/ntp/libntp \
+ usr.sbin/ntp/libopts \
+
+
+.include <dirdeps.mk>
+
+.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+# local dependencies - needed for -jN in clean tree
+version.o: version.c
+version.po: version.c
+.endif
diff --git a/usr.sbin/ntp/ntptime/Makefile.depend b/usr.sbin/ntp/ntptime/Makefile.depend
new file mode 100644
index 0000000..d4203a9
--- /dev/null
+++ b/usr.sbin/ntp/ntptime/Makefile.depend
@@ -0,0 +1,20 @@
+# Autogenerated - do NOT edit!
+
+DEP_RELDIR := ${_PARSEDIR:S,${SRCTOP}/,,}
+
+DEP_MACHINE := ${.PARSEFILE:E}
+
+DIRDEPS = \
+ gnu/lib/libgcc \
+ include \
+ include/xlocale \
+ lib/${CSU_DIR} \
+ lib/libc \
+ usr.sbin/ntp/libntp \
+
+
+.include <dirdeps.mk>
+
+.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+# local dependencies - needed for -jN in clean tree
+.endif
diff --git a/usr.sbin/ntp/sntp/Makefile.depend b/usr.sbin/ntp/sntp/Makefile.depend
new file mode 100644
index 0000000..84c4708
--- /dev/null
+++ b/usr.sbin/ntp/sntp/Makefile.depend
@@ -0,0 +1,22 @@
+# Autogenerated - do NOT edit!
+
+DEP_RELDIR := ${_PARSEDIR:S,${SRCTOP}/,,}
+
+DEP_MACHINE := ${.PARSEFILE:E}
+
+DIRDEPS = \
+ gnu/lib/libgcc \
+ include \
+ include/arpa \
+ include/xlocale \
+ lib/${CSU_DIR} \
+ lib/libc \
+ lib/msun \
+ usr.sbin/ntp/libopts \
+
+
+.include <dirdeps.mk>
+
+.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+# local dependencies - needed for -jN in clean tree
+.endif
diff --git a/usr.sbin/nvram/nvram.c b/usr.sbin/nvram/nvram.c
index 9d56f9d..a286ee3 100644
--- a/usr.sbin/nvram/nvram.c
+++ b/usr.sbin/nvram/nvram.c
@@ -51,12 +51,16 @@ struct deletelist {
struct deletelist *last;
};
+union {
+ uint8_t buf[sizeof(struct chrp_header)];
+ struct chrp_header header;
+} conv;
+
int
main(int argc, char **argv)
{
int opt, dump, fd, res, i, size;
uint8_t buf[NVRAM_SIZE], *cp, *common;
- struct chrp_header *header;
struct deletelist *dl;
dump = 0;
@@ -116,9 +120,9 @@ main(int argc, char **argv)
/* Locate common block */
size = 0;
for (cp = buf; cp < buf + sizeof(buf); cp += size) {
- header = (struct chrp_header *)cp;
- size = header->length * 0x10;
- if (strncmp(header->name, "common", 7) == 0)
+ memcpy(conv.buf, cp, sizeof(struct chrp_header));
+ size = conv.header.length * 0x10;
+ if (strncmp(conv.header.name, "common", 7) == 0)
break;
}
if (cp >= buf + sizeof(buf) || size <= (int)sizeof(struct chrp_header))
diff --git a/usr.sbin/ofwdump/Makefile.depend b/usr.sbin/ofwdump/Makefile.depend
new file mode 100644
index 0000000..a839545
--- /dev/null
+++ b/usr.sbin/ofwdump/Makefile.depend
@@ -0,0 +1,19 @@
+# Autogenerated - do NOT edit!
+
+DEP_RELDIR := ${_PARSEDIR:S,${SRCTOP}/,,}
+
+DEP_MACHINE := ${.PARSEFILE:E}
+
+DIRDEPS = \
+ gnu/lib/libgcc \
+ include \
+ include/xlocale \
+ lib/${CSU_DIR} \
+ lib/libc \
+
+
+.include <dirdeps.mk>
+
+.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+# local dependencies - needed for -jN in clean tree
+.endif
diff --git a/usr.sbin/pc-sysinstall/backend-partmanager/Makefile.depend b/usr.sbin/pc-sysinstall/backend-partmanager/Makefile.depend
new file mode 100644
index 0000000..29fda55
--- /dev/null
+++ b/usr.sbin/pc-sysinstall/backend-partmanager/Makefile.depend
@@ -0,0 +1,14 @@
+# Autogenerated - do NOT edit!
+
+DEP_RELDIR := ${_PARSEDIR:S,${SRCTOP}/,,}
+
+DEP_MACHINE := ${.PARSEFILE:E}
+
+DIRDEPS = \
+
+
+.include <dirdeps.mk>
+
+.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+# local dependencies - needed for -jN in clean tree
+.endif
diff --git a/usr.sbin/pc-sysinstall/backend-query/Makefile.depend b/usr.sbin/pc-sysinstall/backend-query/Makefile.depend
new file mode 100644
index 0000000..29fda55
--- /dev/null
+++ b/usr.sbin/pc-sysinstall/backend-query/Makefile.depend
@@ -0,0 +1,14 @@
+# Autogenerated - do NOT edit!
+
+DEP_RELDIR := ${_PARSEDIR:S,${SRCTOP}/,,}
+
+DEP_MACHINE := ${.PARSEFILE:E}
+
+DIRDEPS = \
+
+
+.include <dirdeps.mk>
+
+.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+# local dependencies - needed for -jN in clean tree
+.endif
diff --git a/usr.sbin/pc-sysinstall/backend/Makefile.depend b/usr.sbin/pc-sysinstall/backend/Makefile.depend
new file mode 100644
index 0000000..29fda55
--- /dev/null
+++ b/usr.sbin/pc-sysinstall/backend/Makefile.depend
@@ -0,0 +1,14 @@
+# Autogenerated - do NOT edit!
+
+DEP_RELDIR := ${_PARSEDIR:S,${SRCTOP}/,,}
+
+DEP_MACHINE := ${.PARSEFILE:E}
+
+DIRDEPS = \
+
+
+.include <dirdeps.mk>
+
+.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+# local dependencies - needed for -jN in clean tree
+.endif
diff --git a/usr.sbin/pc-sysinstall/backend/functions-bsdlabel.sh b/usr.sbin/pc-sysinstall/backend/functions-bsdlabel.sh
index e76721c..0eedfad 100755
--- a/usr.sbin/pc-sysinstall/backend/functions-bsdlabel.sh
+++ b/usr.sbin/pc-sysinstall/backend/functions-bsdlabel.sh
@@ -164,6 +164,38 @@ gen_glabel_name()
export VAL="${NAME}${NUM}"
};
+# Function to determine the size we can safely use when 0 is specified
+get_autosize()
+{
+ # Disk tag to look for
+ dTag="$1"
+
+ # Total MB Avail
+ get_disk_mediasize_mb "$2"
+ local _aSize=$VAL
+
+ while read line
+ do
+ # Check for data on this slice
+ echo $line | grep -q "^${_dTag}-part=" 2>/dev/null
+ if [ $? -ne 0 ] ; then continue ; fi
+
+ get_value_from_string "${line}"
+ STRING="$VAL"
+
+ # Get the size of this partition
+ SIZE=`echo $STRING | tr -s '\t' ' ' | cut -d ' ' -f 2`
+ if [ $SIZE -eq 0 ] ; then continue ; fi
+ _aSize=`expr $_aSize - $SIZE`
+ done <${CFGF}
+
+ # Pad the size a bit
+ _aSize=`expr $_aSize - 2`
+
+ VAL="$_aSize"
+ export VAL
+};
+
# Function to setup partitions using gpart
setup_gpart_partitions()
{
@@ -173,6 +205,7 @@ setup_gpart_partitions()
local _sNum="$4"
local _pType="$5"
FOUNDPARTS="1"
+ USEDAUTOSIZE=0
# Lets read in the config file now and setup our partitions
if [ "${_pType}" = "gpt" ] ; then
@@ -245,7 +278,15 @@ setup_gpart_partitions()
if [ "$SIZE" = "0" ]
then
- SOUT=""
+ if [ $USEDAUTOSIZE -eq 1 ] ; then
+ exit_err "ERROR: You can not have two partitions with a size of 0 specified!"
+ fi
+ case ${_pType} in
+ gpt|apm) get_autosize "${_dTag}" "$_pDisk" ;;
+ *) get_autosize "${_dTag}" "$_wSlice" ;;
+ esac
+ SOUT="-s ${VAL}M"
+ USEDAUTOSIZE=1
else
SOUT="-s ${SIZE}M"
fi
diff --git a/usr.sbin/pc-sysinstall/backend/functions-cleanup.sh b/usr.sbin/pc-sysinstall/backend/functions-cleanup.sh
index 255dbc8..787f891 100755
--- a/usr.sbin/pc-sysinstall/backend/functions-cleanup.sh
+++ b/usr.sbin/pc-sysinstall/backend/functions-cleanup.sh
@@ -49,7 +49,7 @@ zfs_cleanup_unmount()
# Creating a dedicated "/boot" partition
cat ${FSMNT}/boot/loader.conf 2>/dev/null | grep -q "vfs.root.mountfrom=" 2>/dev/null
if [ $? -ne 0 ] ; then
- echo "vfs.root.mountfrom=\"zfs:${ZPOOLNAME}\"" >> ${FSMNT}/boot/loader.conf
+ echo "vfs.root.mountfrom=\"zfs:${ZPOOLNAME}/ROOT/default\"" >> ${FSMNT}/boot/loader.conf
fi
export FOUNDZFSROOT="${ZPOOLNAME}"
fi
@@ -195,8 +195,8 @@ setup_fstab()
if [ $? -eq 0 ] ; then
if [ "${PARTFS}" = "ZFS" ] ; then
ROOTFSTYPE="zfs"
- XPOOLNAME=$(get_zpool_name "${PARTDEV}")
- ROOTFS="${ZPOOLNAME}"
+ ZPOOLNAME=$(get_zpool_name "${PARTDEV}")
+ ROOTFS="${ZPOOLNAME}/ROOT/default"
else
ROOTFS="${DEVICE}"
ROOTFSTYPE="ufs"
diff --git a/usr.sbin/pc-sysinstall/backend/functions-disk.sh b/usr.sbin/pc-sysinstall/backend/functions-disk.sh
index 8e8cbfd..b1b815d 100755
--- a/usr.sbin/pc-sysinstall/backend/functions-disk.sh
+++ b/usr.sbin/pc-sysinstall/backend/functions-disk.sh
@@ -224,6 +224,15 @@ get_disk_mediasize()
export VAL="${mediasize}"
};
+# Function which returns a target disks mediasize in megabytes
+get_disk_mediasize_mb()
+{
+ mediasize=`diskinfo -v ${1} | grep "# mediasize in bytes" | tr -s ' ' | cut -f 2`
+ mediasize=`expr $mediasize / 1024`
+ mediasize=`expr $mediasize / 1024`
+ export VAL="${mediasize}"
+};
+
# Function to delete all gparts before starting an install
delete_all_gpart()
{
diff --git a/usr.sbin/pc-sysinstall/backend/functions-installcomponents.sh b/usr.sbin/pc-sysinstall/backend/functions-installcomponents.sh
index 05e4d49..f388dd4 100755
--- a/usr.sbin/pc-sysinstall/backend/functions-installcomponents.sh
+++ b/usr.sbin/pc-sysinstall/backend/functions-installcomponents.sh
@@ -71,8 +71,16 @@ copy_component()
fetch_file "${FTPPATH}/${COMPFILEDIR}/${SUBDIR}/${CFILE}" "${FSMNT}/${COMPTMPDIR}/${CFILE}" "0"
RESULT="$?"
;;
-
- sftp) ;;
+ local)
+ get_value_from_cfg localPath
+ if [ -z "$VAL" ]; then
+ exit_err "Install medium was set to local, but no localPath was provided!"
+ fi
+ LOCALPATH=$VAL
+ cp ${LOCALPATH}/${COMPFILEDIR}/${SUBDIR}/${CFILE} \
+ ${FSMNT}/${COMPTMPDIR} >>${LOGOUT} 2>>${LOGOUT}
+ RESULT="$?"
+ ;;
esac
if [ "${RESULT}" != "0" ]
diff --git a/usr.sbin/pc-sysinstall/backend/functions-mountdisk.sh b/usr.sbin/pc-sysinstall/backend/functions-mountdisk.sh
index 6d785b9..c90c058 100755
--- a/usr.sbin/pc-sysinstall/backend/functions-mountdisk.sh
+++ b/usr.sbin/pc-sysinstall/backend/functions-mountdisk.sh
@@ -81,15 +81,34 @@ mount_partition()
done
if [ "${ZMNT}" = "/" ] ; then
- ZNAME=""
+ # If creating ZFS / dataset, give it name that beadm works with
+ ZNAME="/ROOT/default"
+ ZMKMNT=""
+ echo_log "zfs create $zcopt -p ${ZPOOLNAME}/ROOT"
+ rc_halt "zfs create $zcopt -p ${ZPOOLNAME}/ROOT"
+ echo_log "zfs create $zcopt -p ${ZPOOLNAME}${ZNAME}"
+ rc_halt "zfs create $zcopt -p ${ZPOOLNAME}${ZNAME}"
else
ZNAME="${ZMNT}"
+ ZMKMNT="${ZMNT}"
echo_log "zfs create $zcopt -p ${ZPOOLNAME}${ZNAME}"
rc_halt "zfs create $zcopt -p ${ZPOOLNAME}${ZNAME}"
fi
sleep 2
if [ -z "$zcopt" ] ; then
- rc_halt "zfs set mountpoint=${FSMNT}${ZNAME} ${ZPOOLNAME}${ZNAME}"
+ rc_halt "zfs set mountpoint=${FSMNT}${ZMKMNT} ${ZPOOLNAME}${ZNAME}"
+ fi
+
+ # Do we need to make this / zfs dataset bootable?
+ if [ "$ZMNT" = "/" ] ; then
+ echo_log "Stamping ${ZPOOLNAME}/ROOT/default as bootfs"
+ rc_halt "zpool set bootfs=${ZPOOLNAME}/ROOT/default ${ZPOOLNAME}"
+ fi
+
+ # Do we need to make this /boot zfs dataset bootable?
+ if [ "$ZMNT" = "/boot" ] ; then
+ echo_log "Stamping ${ZPOOLNAME}${ZMNT} as bootfs"
+ rc_halt "zpool set bootfs=${ZPOOLNAME}${ZMNT} ${ZPOOLNAME}"
fi
# If no ZFS options, we can skip
diff --git a/usr.sbin/pc-sysinstall/backend/functions-newfs.sh b/usr.sbin/pc-sysinstall/backend/functions-newfs.sh
index 1ebf922..2ab4a83 100755
--- a/usr.sbin/pc-sysinstall/backend/functions-newfs.sh
+++ b/usr.sbin/pc-sysinstall/backend/functions-newfs.sh
@@ -72,16 +72,6 @@ setup_zfs_filesystem()
# Disable atime for this zfs partition, speed increase
rc_nohalt "zfs set atime=off ${ZPOOLNAME}"
- # Check if we need to set a bootable zpool
- for i in `echo ${PARTMNT} | sed 's|,| |g'`
- do
- if [ "${i}" = "/" -o "${i}" = "/boot" ] ; then
- if [ "$HAVEBOOT" = "YES" ] ; then continue ; fi
- echo_log "Stamping zpool as bootfs"
- rc_halt "zpool set bootfs=${ZPOOLNAME} ${ZPOOLNAME}"
- fi
- done
-
};
# Runs newfs on all the partiions which we've setup with bsdlabel
@@ -144,7 +134,7 @@ setup_filesystems()
UFS)
echo_log "NEWFS: ${PARTDEV} - ${PARTFS}"
sleep 2
- rc_halt "newfs ${PARTXTRAOPTS} ${PARTDEV}${EXT}"
+ rc_halt "newfs -t ${PARTXTRAOPTS} ${PARTDEV}${EXT}"
sleep 2
rc_halt "sync"
rc_halt "glabel label ${PARTLABEL} ${PARTDEV}${EXT}"
@@ -160,7 +150,7 @@ setup_filesystems()
UFS+S)
echo_log "NEWFS: ${PARTDEV} - ${PARTFS}"
sleep 2
- rc_halt "newfs ${PARTXTRAOPTS} -U ${PARTDEV}${EXT}"
+ rc_halt "newfs -t ${PARTXTRAOPTS} -U ${PARTDEV}${EXT}"
sleep 2
rc_halt "sync"
rc_halt "glabel label ${PARTLABEL} ${PARTDEV}${EXT}"
@@ -175,7 +165,7 @@ setup_filesystems()
UFS+SUJ)
echo_log "NEWFS: ${PARTDEV} - ${PARTFS}"
sleep 2
- rc_halt "newfs ${PARTXTRAOPTS} -U ${PARTDEV}${EXT}"
+ rc_halt "newfs -t ${PARTXTRAOPTS} -U ${PARTDEV}${EXT}"
sleep 2
rc_halt "sync"
rc_halt "tunefs -j enable ${PARTDEV}${EXT}"
diff --git a/usr.sbin/pc-sysinstall/conf/Makefile.depend b/usr.sbin/pc-sysinstall/conf/Makefile.depend
new file mode 100644
index 0000000..29fda55
--- /dev/null
+++ b/usr.sbin/pc-sysinstall/conf/Makefile.depend
@@ -0,0 +1,14 @@
+# Autogenerated - do NOT edit!
+
+DEP_RELDIR := ${_PARSEDIR:S,${SRCTOP}/,,}
+
+DEP_MACHINE := ${.PARSEFILE:E}
+
+DIRDEPS = \
+
+
+.include <dirdeps.mk>
+
+.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+# local dependencies - needed for -jN in clean tree
+.endif
diff --git a/usr.sbin/pc-sysinstall/pc-sysinstall/Makefile.depend b/usr.sbin/pc-sysinstall/pc-sysinstall/Makefile.depend
new file mode 100644
index 0000000..29fda55
--- /dev/null
+++ b/usr.sbin/pc-sysinstall/pc-sysinstall/Makefile.depend
@@ -0,0 +1,14 @@
+# Autogenerated - do NOT edit!
+
+DEP_RELDIR := ${_PARSEDIR:S,${SRCTOP}/,,}
+
+DEP_MACHINE := ${.PARSEFILE:E}
+
+DIRDEPS = \
+
+
+.include <dirdeps.mk>
+
+.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+# local dependencies - needed for -jN in clean tree
+.endif
diff --git a/usr.sbin/pciconf/Makefile.depend b/usr.sbin/pciconf/Makefile.depend
new file mode 100644
index 0000000..a839545
--- /dev/null
+++ b/usr.sbin/pciconf/Makefile.depend
@@ -0,0 +1,19 @@
+# Autogenerated - do NOT edit!
+
+DEP_RELDIR := ${_PARSEDIR:S,${SRCTOP}/,,}
+
+DEP_MACHINE := ${.PARSEFILE:E}
+
+DIRDEPS = \
+ gnu/lib/libgcc \
+ include \
+ include/xlocale \
+ lib/${CSU_DIR} \
+ lib/libc \
+
+
+.include <dirdeps.mk>
+
+.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+# local dependencies - needed for -jN in clean tree
+.endif
diff --git a/usr.sbin/pciconf/cap.c b/usr.sbin/pciconf/cap.c
index 4eed9ca..ce184dd 100644
--- a/usr.sbin/pciconf/cap.c
+++ b/usr.sbin/pciconf/cap.c
@@ -363,57 +363,87 @@ cap_subvendor(int fd, struct pci_conf *p, uint8_t ptr)
#define MAX_PAYLOAD(field) (128 << (field))
+static const char *
+link_speed_string(uint8_t speed)
+{
+
+ switch (speed) {
+ case 1:
+ return ("2.5");
+ case 2:
+ return ("5.0");
+ case 3:
+ return ("8.0");
+ default:
+ return ("undef");
+ }
+}
+
static void
cap_express(int fd, struct pci_conf *p, uint8_t ptr)
{
uint32_t val;
uint16_t flags;
- flags = read_config(fd, &p->pc_sel, ptr + PCIR_EXPRESS_FLAGS, 2);
- printf("PCI-Express %d ", flags & PCIM_EXP_FLAGS_VERSION);
- switch (flags & PCIM_EXP_FLAGS_TYPE) {
- case PCIM_EXP_TYPE_ENDPOINT:
+ flags = read_config(fd, &p->pc_sel, ptr + PCIER_FLAGS, 2);
+ printf("PCI-Express %d ", flags & PCIEM_FLAGS_VERSION);
+ switch (flags & PCIEM_FLAGS_TYPE) {
+ case PCIEM_TYPE_ENDPOINT:
printf("endpoint");
break;
- case PCIM_EXP_TYPE_LEGACY_ENDPOINT:
+ case PCIEM_TYPE_LEGACY_ENDPOINT:
printf("legacy endpoint");
break;
- case PCIM_EXP_TYPE_ROOT_PORT:
+ case PCIEM_TYPE_ROOT_PORT:
printf("root port");
break;
- case PCIM_EXP_TYPE_UPSTREAM_PORT:
+ case PCIEM_TYPE_UPSTREAM_PORT:
printf("upstream port");
break;
- case PCIM_EXP_TYPE_DOWNSTREAM_PORT:
+ case PCIEM_TYPE_DOWNSTREAM_PORT:
printf("downstream port");
break;
- case PCIM_EXP_TYPE_PCI_BRIDGE:
+ case PCIEM_TYPE_PCI_BRIDGE:
printf("PCI bridge");
break;
- case PCIM_EXP_TYPE_PCIE_BRIDGE:
+ case PCIEM_TYPE_PCIE_BRIDGE:
printf("PCI to PCIe bridge");
break;
- case PCIM_EXP_TYPE_ROOT_INT_EP:
+ case PCIEM_TYPE_ROOT_INT_EP:
printf("root endpoint");
break;
- case PCIM_EXP_TYPE_ROOT_EC:
+ case PCIEM_TYPE_ROOT_EC:
printf("event collector");
break;
default:
- printf("type %d", (flags & PCIM_EXP_FLAGS_TYPE) >> 4);
+ printf("type %d", (flags & PCIEM_FLAGS_TYPE) >> 4);
break;
}
- if (flags & PCIM_EXP_FLAGS_IRQ)
- printf(" IRQ %d", (flags & PCIM_EXP_FLAGS_IRQ) >> 8);
- val = read_config(fd, &p->pc_sel, ptr + PCIR_EXPRESS_DEVICE_CAP, 4);
- flags = read_config(fd, &p->pc_sel, ptr + PCIR_EXPRESS_DEVICE_CTL, 2);
+ if (flags & PCIEM_FLAGS_SLOT)
+ printf(" slot");
+ if (flags & PCIEM_FLAGS_IRQ)
+ printf(" IRQ %d", (flags & PCIEM_FLAGS_IRQ) >> 9);
+ val = read_config(fd, &p->pc_sel, ptr + PCIER_DEVICE_CAP, 4);
+ flags = read_config(fd, &p->pc_sel, ptr + PCIER_DEVICE_CTL, 2);
printf(" max data %d(%d)",
- MAX_PAYLOAD((flags & PCIM_EXP_CTL_MAX_PAYLOAD) >> 5),
- MAX_PAYLOAD(val & PCIM_EXP_CAP_MAX_PAYLOAD));
- val = read_config(fd, &p->pc_sel, ptr + PCIR_EXPRESS_LINK_CAP, 4);
- flags = read_config(fd, &p->pc_sel, ptr+ PCIR_EXPRESS_LINK_STA, 2);
- printf(" link x%d(x%d)", (flags & PCIM_LINK_STA_WIDTH) >> 4,
- (val & PCIM_LINK_CAP_MAX_WIDTH) >> 4);
+ MAX_PAYLOAD((flags & PCIEM_CTL_MAX_PAYLOAD) >> 5),
+ MAX_PAYLOAD(val & PCIEM_CAP_MAX_PAYLOAD));
+ if (val & PCIEM_CAP_FLR)
+ printf(" FLR");
+ val = read_config(fd, &p->pc_sel, ptr + PCIER_LINK_CAP, 4);
+ flags = read_config(fd, &p->pc_sel, ptr+ PCIER_LINK_STA, 2);
+ printf(" link x%d(x%d)", (flags & PCIEM_LINK_STA_WIDTH) >> 4,
+ (val & PCIEM_LINK_CAP_MAX_WIDTH) >> 4);
+ /*
+ * Only print link speed info if the link's max width is
+ * greater than 0.
+ */
+ if ((val & PCIEM_LINK_CAP_MAX_WIDTH) != 0) {
+ printf("\n speed");
+ printf(" %s(%s)", (flags & PCIEM_LINK_STA_WIDTH) == 0 ?
+ "0.0" : link_speed_string(flags & PCIEM_LINK_STA_SPEED),
+ link_speed_string(val & PCIEM_LINK_CAP_MAX_SPEED));
+ }
}
static void
@@ -559,7 +589,7 @@ ecap_aer(int fd, struct pci_conf *p, uint16_t ptr, uint8_t ver)
uint32_t sta, mask;
printf("AER %d", ver);
- if (ver != 1)
+ if (ver < 1)
return;
sta = read_config(fd, &p->pc_sel, ptr + PCIR_AER_UC_STATUS, 4);
mask = read_config(fd, &p->pc_sel, ptr + PCIR_AER_UC_SEVERITY, 4);
@@ -575,7 +605,7 @@ ecap_vc(int fd, struct pci_conf *p, uint16_t ptr, uint8_t ver)
uint32_t cap1;
printf("VC %d", ver);
- if (ver != 1)
+ if (ver < 1)
return;
cap1 = read_config(fd, &p->pc_sel, ptr + PCIR_VC_CAP1, 4);
printf(" max VC%d", cap1 & PCIM_VC_CAP1_EXT_COUNT);
@@ -590,7 +620,7 @@ ecap_sernum(int fd, struct pci_conf *p, uint16_t ptr, uint8_t ver)
uint32_t high, low;
printf("Serial %d", ver);
- if (ver != 1)
+ if (ver < 1)
return;
low = read_config(fd, &p->pc_sel, ptr + PCIR_SERIAL_LOW, 4);
high = read_config(fd, &p->pc_sel, ptr + PCIR_SERIAL_HIGH, 4);
@@ -598,17 +628,65 @@ ecap_sernum(int fd, struct pci_conf *p, uint16_t ptr, uint8_t ver)
}
static void
+ecap_vendor(int fd, struct pci_conf *p, uint16_t ptr, uint8_t ver)
+{
+ uint32_t val;
+
+ printf("Vendor %d", ver);
+ if (ver < 1)
+ return;
+ val = read_config(fd, &p->pc_sel, ptr + 4, 4);
+ printf(" ID %d", val & 0xffff);
+}
+
+static void
+ecap_sec_pcie(int fd, struct pci_conf *p, uint16_t ptr, uint8_t ver)
+{
+ uint32_t val;
+
+ printf("PCIe Sec %d", ver);
+ if (ver < 1)
+ return;
+ val = read_config(fd, &p->pc_sel, ptr + 8, 4);
+ printf(" lane errors %#x", val);
+}
+
+struct {
+ uint16_t id;
+ const char *name;
+} ecap_names[] = {
+ { PCIZ_PWRBDGT, "Power Budgeting" },
+ { PCIZ_RCLINK_DCL, "Root Complex Link Declaration" },
+ { PCIZ_RCLINK_CTL, "Root Complex Internal Link Control" },
+ { PCIZ_RCEC_ASSOC, "Root Complex Event Collector ASsociation" },
+ { PCIZ_MFVC, "MFVC" },
+ { PCIZ_RCRB, "RCRB" },
+ { PCIZ_ACS, "ACS" },
+ { PCIZ_ARI, "ARI" },
+ { PCIZ_ATS, "ATS" },
+ { PCIZ_SRIOV, "SRIOV" },
+ { PCIZ_MULTICAST, "Multicast" },
+ { PCIZ_RESIZE_BAR, "Resizable BAR" },
+ { PCIZ_DPA, "DPA" },
+ { PCIZ_TPH_REQ, "TPH Requester" },
+ { PCIZ_LTR, "LTR" },
+ { 0, NULL }
+};
+
+static void
list_ecaps(int fd, struct pci_conf *p)
{
+ const char *name;
uint32_t ecap;
uint16_t ptr;
+ int i;
ptr = PCIR_EXTCAP;
ecap = read_config(fd, &p->pc_sel, ptr, 4);
if (ecap == 0xffffffff || ecap == 0)
return;
for (;;) {
- printf("ecap %04x[%03x] = ", PCI_EXTCAP_ID(ecap), ptr);
+ printf(" ecap %04x[%03x] = ", PCI_EXTCAP_ID(ecap), ptr);
switch (PCI_EXTCAP_ID(ecap)) {
case PCIZ_AER:
ecap_aer(fd, p, ptr, PCI_EXTCAP_VER(ecap));
@@ -619,8 +697,20 @@ list_ecaps(int fd, struct pci_conf *p)
case PCIZ_SERNUM:
ecap_sernum(fd, p, ptr, PCI_EXTCAP_VER(ecap));
break;
+ case PCIZ_VENDOR:
+ ecap_vendor(fd, p, ptr, PCI_EXTCAP_VER(ecap));
+ break;
+ case PCIZ_SEC_PCIE:
+ ecap_sec_pcie(fd, p, ptr, PCI_EXTCAP_VER(ecap));
+ break;
default:
- printf("unknown %d", PCI_EXTCAP_VER(ecap));
+ name = "unknown";
+ for (i = 0; ecap_names[i].name != NULL; i++)
+ if (ecap_names[i].id == PCI_EXTCAP_ID(ecap)) {
+ name = ecap_names[i].name;
+ break;
+ }
+ printf("%s %d", name, PCI_EXTCAP_VER(ecap));
break;
}
printf("\n");
diff --git a/usr.sbin/pciconf/err.c b/usr.sbin/pciconf/err.c
index 62445b1..b67d1f5 100644
--- a/usr.sbin/pciconf/err.c
+++ b/usr.sbin/pciconf/err.c
@@ -63,18 +63,18 @@ static struct bit_table pci_status[] = {
/* Error indicators in the PCI-Express device status register. */
static struct bit_table pcie_device_status[] = {
- { PCIM_EXP_STA_CORRECTABLE_ERROR, "Correctable Error Detected" },
- { PCIM_EXP_STA_NON_FATAL_ERROR, "Non-Fatal Error Detected" },
- { PCIM_EXP_STA_FATAL_ERROR, "Fatal Error Detected" },
- { PCIM_EXP_STA_UNSUPPORTED_REQ, "Unsupported Request Detected" },
+ { PCIEM_STA_CORRECTABLE_ERROR, "Correctable Error Detected" },
+ { PCIEM_STA_NON_FATAL_ERROR, "Non-Fatal Error Detected" },
+ { PCIEM_STA_FATAL_ERROR, "Fatal Error Detected" },
+ { PCIEM_STA_UNSUPPORTED_REQ, "Unsupported Request Detected" },
{ 0, NULL },
};
/* Valid error indicator bits in the PCI-Express device status register. */
-#define PCIE_ERRORS (PCIM_EXP_STA_CORRECTABLE_ERROR | \
- PCIM_EXP_STA_NON_FATAL_ERROR | \
- PCIM_EXP_STA_FATAL_ERROR | \
- PCIM_EXP_STA_UNSUPPORTED_REQ)
+#define PCIE_ERRORS (PCIEM_STA_CORRECTABLE_ERROR | \
+ PCIEM_STA_NON_FATAL_ERROR | \
+ PCIEM_STA_FATAL_ERROR | \
+ PCIEM_STA_UNSUPPORTED_REQ)
/* AER Uncorrected errors. */
static struct bit_table aer_uc[] = {
@@ -91,6 +91,10 @@ static struct bit_table aer_uc[] = {
{ PCIM_AER_UC_ECRC_ERROR, "ECRC Error" },
{ PCIM_AER_UC_UNSUPPORTED_REQUEST, "Unsupported Request" },
{ PCIM_AER_UC_ACS_VIOLATION, "ACS Violation" },
+ { PCIM_AER_UC_INTERNAL_ERROR, "Uncorrectable Internal Error" },
+ { PCIM_AER_UC_MC_BLOCKED_TLP, "MC Blocked TLP" },
+ { PCIM_AER_UC_ATOMIC_EGRESS_BLK, "AtomicOp Egress Blocked" },
+ { PCIM_AER_UC_TLP_PREFIX_BLOCKED, "TLP Prefix Blocked Error" },
{ 0, NULL },
};
@@ -102,6 +106,8 @@ static struct bit_table aer_cor[] = {
{ PCIM_AER_COR_REPLAY_ROLLOVER, "REPLAY_NUM Rollover" },
{ PCIM_AER_COR_REPLAY_TIMEOUT, "Replay Timer Timeout" },
{ PCIM_AER_COR_ADVISORY_NF_ERROR, "Advisory Non-Fatal Error" },
+ { PCIM_AER_COR_INTERNAL_ERROR, "Corrected Internal Error" },
+ { PCIM_AER_COR_HEADER_LOG_OVFLOW, "Header Log Overflow" },
{ 0, NULL },
};
@@ -147,7 +153,7 @@ list_errors(int fd, struct pci_conf *p)
return;
/* Check for PCI-e errors. */
- sta = read_config(fd, &p->pc_sel, pcie + PCIR_EXPRESS_DEVICE_STA, 2);
+ sta = read_config(fd, &p->pc_sel, pcie + PCIER_DEVICE_STA, 2);
print_bits("PCI-e errors", pcie_device_status, sta & PCIE_ERRORS);
/* See if this device supports AER. */
diff --git a/usr.sbin/pciconf/pciconf.c b/usr.sbin/pciconf/pciconf.c
index 76e478b..52ad09a 100644
--- a/usr.sbin/pciconf/pciconf.c
+++ b/usr.sbin/pciconf/pciconf.c
@@ -345,6 +345,7 @@ static struct
{PCIC_STORAGE, PCIS_STORAGE_ATA_ADMA, "ATA (ADMA)"},
{PCIC_STORAGE, PCIS_STORAGE_SATA, "SATA"},
{PCIC_STORAGE, PCIS_STORAGE_SAS, "SAS"},
+ {PCIC_STORAGE, PCIS_STORAGE_NVM, "NVM"},
{PCIC_NETWORK, -1, "network"},
{PCIC_NETWORK, PCIS_NETWORK_ETHERNET, "ethernet"},
{PCIC_NETWORK, PCIS_NETWORK_TOKENRING, "token ring"},
diff --git a/usr.sbin/periodic/Makefile.depend b/usr.sbin/periodic/Makefile.depend
new file mode 100644
index 0000000..29fda55
--- /dev/null
+++ b/usr.sbin/periodic/Makefile.depend
@@ -0,0 +1,14 @@
+# Autogenerated - do NOT edit!
+
+DEP_RELDIR := ${_PARSEDIR:S,${SRCTOP}/,,}
+
+DEP_MACHINE := ${.PARSEFILE:E}
+
+DIRDEPS = \
+
+
+.include <dirdeps.mk>
+
+.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+# local dependencies - needed for -jN in clean tree
+.endif
diff --git a/usr.sbin/pkg/Makefile.depend b/usr.sbin/pkg/Makefile.depend
new file mode 100644
index 0000000..b097b19
--- /dev/null
+++ b/usr.sbin/pkg/Makefile.depend
@@ -0,0 +1,22 @@
+# Autogenerated - do NOT edit!
+
+DEP_RELDIR := ${_PARSEDIR:S,${SRCTOP}/,,}
+
+DEP_MACHINE := ${.PARSEFILE:E}
+
+DIRDEPS = \
+ gnu/lib/libgcc \
+ include \
+ include/xlocale \
+ lib/${CSU_DIR} \
+ lib/libarchive \
+ lib/libc \
+ lib/libelf \
+ lib/libfetch \
+
+
+.include <dirdeps.mk>
+
+.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+# local dependencies - needed for -jN in clean tree
+.endif
diff --git a/usr.sbin/pkg/elf_tables.h b/usr.sbin/pkg/elf_tables.h
index e02a2f7..d3d689a 100644
--- a/usr.sbin/pkg/elf_tables.h
+++ b/usr.sbin/pkg/elf_tables.h
@@ -34,7 +34,7 @@ struct _elf_corres {
const char *string;
};
-struct _elf_corres mach_corres[] = {
+static struct _elf_corres mach_corres[] = {
{ EM_386, "x86" },
{ EM_AMD64, "x86" },
{ EM_ARM, "arm" },
@@ -46,23 +46,18 @@ struct _elf_corres mach_corres[] = {
{ -1, NULL },
};
-struct _elf_corres wordsize_corres[] = {
+static struct _elf_corres wordsize_corres[] = {
{ ELFCLASS32, "32" },
{ ELFCLASS64, "64" },
{ -1, NULL},
};
-struct _elf_corres endian_corres[] = {
+static struct _elf_corres endian_corres[] = {
{ ELFDATA2MSB, "eb" },
{ ELFDATA2LSB, "el" },
{ -1, NULL}
};
-struct _elf_corres os_corres[] = {
- { ELFOSABI_FREEBSD, "freebsd" },
- { -1, NULL }
-};
-
#define EF_MIPS_ABI 0x0000F000
#define E_MIPS_ABI_O32 0x00001000
#define E_MIPS_ABI_N32 0x00000020
diff --git a/usr.sbin/pkg/pkg.c b/usr.sbin/pkg/pkg.c
index b6c0207..8dc7bcf 100644
--- a/usr.sbin/pkg/pkg.c
+++ b/usr.sbin/pkg/pkg.c
@@ -389,6 +389,28 @@ cleanup:
return (ret);
}
+static const char confirmation_message[] =
+"The package management tool is not yet installed on your system.\n"
+"Do you want to fetch and install it now? [y/N]: ";
+
+static int
+pkg_query_yes_no(void)
+{
+ int ret, c;
+
+ c = getchar();
+
+ if (c == 'y' || c == 'Y')
+ ret = 1;
+ else
+ ret = 0;
+
+ while (c != '\n' && c != EOF)
+ c = getchar();
+
+ return (ret);
+}
+
int
main(__unused int argc, char *argv[])
{
@@ -397,9 +419,23 @@ main(__unused int argc, char *argv[])
snprintf(pkgpath, MAXPATHLEN, "%s/sbin/pkg",
getenv("LOCALBASE") ? getenv("LOCALBASE") : _LOCALBASE);
- if (access(pkgpath, X_OK) == -1)
+ if (access(pkgpath, X_OK) == -1) {
+ /*
+ * Do not ask for confirmation if either of stdin or stdout is
+ * not tty. Check the environment to see if user has answer
+ * tucked in there already.
+ */
+ if (getenv("ASSUME_ALWAYS_YES") == NULL) {
+ printf("%s", confirmation_message);
+ if (!isatty(fileno(stdin)))
+ exit(EXIT_FAILURE);
+
+ if (pkg_query_yes_no() == 0)
+ exit(EXIT_FAILURE);
+ }
if (bootstrap_pkg() != 0)
exit(EXIT_FAILURE);
+ }
execv(pkgpath, argv);
diff --git a/usr.sbin/pkg_install/add/Makefile.depend b/usr.sbin/pkg_install/add/Makefile.depend
new file mode 100644
index 0000000..fa35fef
--- /dev/null
+++ b/usr.sbin/pkg_install/add/Makefile.depend
@@ -0,0 +1,25 @@
+# Autogenerated - do NOT edit!
+
+DEP_RELDIR := ${_PARSEDIR:S,${SRCTOP}/,,}
+
+DEP_MACHINE := ${.PARSEFILE:E}
+
+DIRDEPS = \
+ gnu/lib/libgcc \
+ include \
+ include/xlocale \
+ lib/${CSU_DIR} \
+ lib/libc \
+ lib/libfetch \
+ lib/libmd \
+ lib/libutil \
+ secure/lib/libcrypto \
+ secure/lib/libssl \
+ usr.sbin/pkg_install/lib \
+
+
+.include <dirdeps.mk>
+
+.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+# local dependencies - needed for -jN in clean tree
+.endif
diff --git a/usr.sbin/pkg_install/add/add.h b/usr.sbin/pkg_install/add/add.h
index d9892ad..e796120 100644
--- a/usr.sbin/pkg_install/add/add.h
+++ b/usr.sbin/pkg_install/add/add.h
@@ -41,7 +41,7 @@ extern char *PkgAddCmd;
extern char FirstPen[];
extern add_mode_t AddMode;
-int make_hierarchy(char *);
+int make_hierarchy(char *, Boolean);
void extract_plist(const char *, Package *);
void apply_perms(const char *, const char *);
diff --git a/usr.sbin/pkg_install/add/extract.c b/usr.sbin/pkg_install/add/extract.c
index 90c33c0..9769464 100644
--- a/usr.sbin/pkg_install/add/extract.c
+++ b/usr.sbin/pkg_install/add/extract.c
@@ -225,7 +225,7 @@ extract_plist(const char *home, Package *pkg)
printf("extract: CWD to %s\n", p->name);
PUSHOUT(Directory);
if (strcmp(p->name, ".")) {
- if (!Fake && make_hierarchy(p->name) == FAIL) {
+ if (!Fake && make_hierarchy(p->name, TRUE) == FAIL) {
cleanup(0);
errx(2, "%s: unable to cwd to '%s'", __func__, p->name);
}
diff --git a/usr.sbin/pkg_install/add/futil.c b/usr.sbin/pkg_install/add/futil.c
index 8f9d369..82217f5 100644
--- a/usr.sbin/pkg_install/add/futil.c
+++ b/usr.sbin/pkg_install/add/futil.c
@@ -31,7 +31,7 @@ __FBSDID("$FreeBSD$");
*/
int
-make_hierarchy(char *dir)
+make_hierarchy(char *dir, Boolean set_perm)
{
char *cp1, *cp2;
@@ -55,7 +55,8 @@ make_hierarchy(char *dir)
*cp2 = '/';
return FAIL;
}
- apply_perms(NULL, dir);
+ if (set_perm)
+ apply_perms(NULL, dir);
}
/* Put it back */
if (cp2) {
diff --git a/usr.sbin/pkg_install/add/main.c b/usr.sbin/pkg_install/add/main.c
index 39c1247..563e04b 100644
--- a/usr.sbin/pkg_install/add/main.c
+++ b/usr.sbin/pkg_install/add/main.c
@@ -89,6 +89,7 @@ struct {
{ 802000, 802499, "/packages-8.2-release" },
{ 803000, 803499, "/packages-8.3-release" },
{ 900000, 900499, "/packages-9.0-release" },
+ { 901000, 901499, "/packages-9.1-release" },
{ 300000, 399000, "/packages-3-stable" },
{ 400000, 499000, "/packages-4-stable" },
{ 502100, 502128, "/packages-5-current" },
@@ -135,6 +136,7 @@ main(int argc, char **argv)
static char temppackageroot[MAXPATHLEN];
static char pkgaddpath[MAXPATHLEN];
+ warnpkgng();
if (*argv[0] != '/' && strchr(argv[0], '/') != NULL)
PkgAddCmd = realpath(argv[0], pkgaddpath);
else
@@ -288,7 +290,9 @@ main(int argc, char **argv)
}
/* Perform chroot if requested */
if (Chroot != NULL) {
- if (chroot(Chroot))
+ if (chdir(Chroot))
+ errx(1, "chdir to %s failed", Chroot);
+ if (chroot("."))
errx(1, "chroot to %s failed", Chroot);
}
/* Make sure the sub-execs we invoke get found */
diff --git a/usr.sbin/pkg_install/add/perform.c b/usr.sbin/pkg_install/add/perform.c
index 24637eb..638e046 100644
--- a/usr.sbin/pkg_install/add/perform.c
+++ b/usr.sbin/pkg_install/add/perform.c
@@ -511,7 +511,7 @@ pkg_do(char *pkg)
zapLogDir = 1;
if (Verbose)
printf("Attempting to record package into %s..\n", LogDir);
- if (make_hierarchy(LogDir)) {
+ if (make_hierarchy(LogDir, FALSE)) {
warnx("can't record package into '%s', you're on your own!",
LogDir);
bzero(LogDir, FILENAME_MAX);
diff --git a/usr.sbin/pkg_install/create/Makefile.depend b/usr.sbin/pkg_install/create/Makefile.depend
new file mode 100644
index 0000000..be409ac
--- /dev/null
+++ b/usr.sbin/pkg_install/create/Makefile.depend
@@ -0,0 +1,22 @@
+# Autogenerated - do NOT edit!
+
+DEP_RELDIR := ${_PARSEDIR:S,${SRCTOP}/,,}
+
+DEP_MACHINE := ${.PARSEFILE:E}
+
+DIRDEPS = \
+ gnu/lib/libgcc \
+ include \
+ include/xlocale \
+ lib/${CSU_DIR} \
+ lib/libc \
+ lib/libmd \
+ lib/libutil \
+ usr.sbin/pkg_install/lib \
+
+
+.include <dirdeps.mk>
+
+.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+# local dependencies - needed for -jN in clean tree
+.endif
diff --git a/usr.sbin/pkg_install/create/main.c b/usr.sbin/pkg_install/create/main.c
index 5b5ecb2..4f68697 100644
--- a/usr.sbin/pkg_install/create/main.c
+++ b/usr.sbin/pkg_install/create/main.c
@@ -72,6 +72,7 @@ main(int argc, char **argv)
int ch;
char **pkgs, **start, *tmp;
+ warnpkgng();
pkgs = start = argv;
while ((ch = getopt_long(argc, argv, opts, longopts, NULL)) != -1)
switch(ch) {
diff --git a/usr.sbin/pkg_install/create/perform.c b/usr.sbin/pkg_install/create/perform.c
index 4409551..e2a884a 100644
--- a/usr.sbin/pkg_install/create/perform.c
+++ b/usr.sbin/pkg_install/create/perform.c
@@ -215,10 +215,14 @@ pkg_perform(char **pkgs)
/* Prefix should add an @cwd to the packing list */
if (Prefix) {
- char resolved_prefix[PATH_MAX];
- if (realpath(Prefix, resolved_prefix) == NULL)
- err(EXIT_FAILURE, "couldn't resolve path for prefix: %s", Prefix);
- add_plist_top(&plist, PLIST_CWD, resolved_prefix);
+ if (Prefix[0] != '/') {
+ char resolved_prefix[PATH_MAX];
+ if (realpath(Prefix, resolved_prefix) == NULL)
+ err(EXIT_FAILURE, "couldn't resolve path for prefix: %s", Prefix);
+ add_plist_top(&plist, PLIST_CWD, resolved_prefix);
+ } else {
+ add_plist_top(&plist, PLIST_CWD, Prefix);
+ }
}
/* Add the origin if asked, at the top */
diff --git a/usr.sbin/pkg_install/delete/Makefile.depend b/usr.sbin/pkg_install/delete/Makefile.depend
new file mode 100644
index 0000000..be409ac
--- /dev/null
+++ b/usr.sbin/pkg_install/delete/Makefile.depend
@@ -0,0 +1,22 @@
+# Autogenerated - do NOT edit!
+
+DEP_RELDIR := ${_PARSEDIR:S,${SRCTOP}/,,}
+
+DEP_MACHINE := ${.PARSEFILE:E}
+
+DIRDEPS = \
+ gnu/lib/libgcc \
+ include \
+ include/xlocale \
+ lib/${CSU_DIR} \
+ lib/libc \
+ lib/libmd \
+ lib/libutil \
+ usr.sbin/pkg_install/lib \
+
+
+.include <dirdeps.mk>
+
+.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+# local dependencies - needed for -jN in clean tree
+.endif
diff --git a/usr.sbin/pkg_install/delete/main.c b/usr.sbin/pkg_install/delete/main.c
index 7cd4677..0b97ddd 100644
--- a/usr.sbin/pkg_install/delete/main.c
+++ b/usr.sbin/pkg_install/delete/main.c
@@ -67,6 +67,7 @@ main(int argc, char **argv)
const char *tmp;
struct stat stat_s;
+ warnpkgng();
pkgs = start = argv;
while ((ch = getopt_long(argc, argv, opts, longopts, NULL)) != -1)
switch(ch) {
diff --git a/usr.sbin/pkg_install/info/Makefile.depend b/usr.sbin/pkg_install/info/Makefile.depend
new file mode 100644
index 0000000..fa35fef
--- /dev/null
+++ b/usr.sbin/pkg_install/info/Makefile.depend
@@ -0,0 +1,25 @@
+# Autogenerated - do NOT edit!
+
+DEP_RELDIR := ${_PARSEDIR:S,${SRCTOP}/,,}
+
+DEP_MACHINE := ${.PARSEFILE:E}
+
+DIRDEPS = \
+ gnu/lib/libgcc \
+ include \
+ include/xlocale \
+ lib/${CSU_DIR} \
+ lib/libc \
+ lib/libfetch \
+ lib/libmd \
+ lib/libutil \
+ secure/lib/libcrypto \
+ secure/lib/libssl \
+ usr.sbin/pkg_install/lib \
+
+
+.include <dirdeps.mk>
+
+.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+# local dependencies - needed for -jN in clean tree
+.endif
diff --git a/usr.sbin/pkg_install/info/info.h b/usr.sbin/pkg_install/info/info.h
index 6aa1aa7..6569b5f 100644
--- a/usr.sbin/pkg_install/info/info.h
+++ b/usr.sbin/pkg_install/info/info.h
@@ -77,7 +77,7 @@ extern void show_plist(const char *, Package *, plist_t, Boolean);
extern void show_files(const char *, Package *);
extern void show_index(const char *, const char *);
extern void show_size(const char *, Package *);
-extern void show_cksum(const char *, Package *);
+extern int show_cksum(const char *, Package *);
extern void show_origin(const char *, Package *);
extern void show_fmtrev(const char *, Package *);
diff --git a/usr.sbin/pkg_install/info/main.c b/usr.sbin/pkg_install/info/main.c
index 6692148..ff2ea79 100644
--- a/usr.sbin/pkg_install/info/main.c
+++ b/usr.sbin/pkg_install/info/main.c
@@ -68,6 +68,7 @@ main(int argc, char **argv)
char **pkgs, **start;
char *pkgs_split;
+ warnpkgng();
whead = malloc(sizeof(struct which_head));
if (whead == NULL)
err(2, NULL);
diff --git a/usr.sbin/pkg_install/info/perform.c b/usr.sbin/pkg_install/info/perform.c
index bba2de8..551f862 100644
--- a/usr.sbin/pkg_install/info/perform.c
+++ b/usr.sbin/pkg_install/info/perform.c
@@ -221,7 +221,7 @@ pkg_do(char *pkg)
if ((Flags & SHOW_SIZE) && installed)
show_size("Package Size:\n", &plist);
if ((Flags & SHOW_CKSUM) && installed)
- show_cksum("Mismatched Checksums:\n", &plist);
+ code += show_cksum("Mismatched Checksums:\n", &plist);
if (Flags & SHOW_ORIGIN)
show_origin("Origin:\n", &plist);
if (Flags & SHOW_FMTREV)
@@ -234,7 +234,7 @@ pkg_do(char *pkg)
leave_playpen();
if (isTMP)
unlink(fname);
- return code;
+ return (code ? 1 : 0);
}
void
diff --git a/usr.sbin/pkg_install/info/show.c b/usr.sbin/pkg_install/info/show.c
index 3dc47f9..be05695 100644
--- a/usr.sbin/pkg_install/info/show.c
+++ b/usr.sbin/pkg_install/info/show.c
@@ -61,8 +61,10 @@ show_index(const char *title, const char *fname)
strlcpy(line, "???\n", sizeof(line));
- if (!Quiet)
+ if (!Quiet) {
printf("%s%s", InfoPrefix, title);
+ fflush(stdout);
+ }
fp = fopen(fname, "r");
if (fp == (FILE *) NULL) {
warnx("show_file: can't open '%s' for reading", fname);
@@ -88,8 +90,10 @@ show_plist(const char *title, Package *plist, plist_t type, Boolean showall)
Boolean ign = FALSE;
char *prefix = NULL;
- if (!Quiet)
+ if (!Quiet) {
printf("%s%s", InfoPrefix, title);
+ fflush(stdout);
+ }
p = plist->head;
while (p) {
if (p->type != type && showall != TRUE) {
@@ -272,8 +276,10 @@ show_size(const char *title, Package *plist)
char *prefix = NULL;
descr = getbsize(&headerlen, &blksize);
- if (!Quiet)
+ if (!Quiet) {
printf("%s%s", InfoPrefix, title);
+ fflush(stdout);
+ }
for (p = plist->head; p != NULL; p = p->next) {
switch (p->type) {
case PLIST_FILE:
@@ -316,16 +322,19 @@ show_size(const char *title, Package *plist)
}
/* Show files that don't match the recorded checksum */
-void
+int
show_cksum(const char *title, Package *plist)
{
PackingList p;
const char *dir = ".";
char *prefix = NULL;
char tmp[FILENAME_MAX];
+ int errcode = 0;
- if (!Quiet)
+ if (!Quiet) {
printf("%s%s", InfoPrefix, title);
+ fflush(stdout);
+ }
for (p = plist->head; p != NULL; p = p->next)
if (p->type == PLIST_CWD) {
@@ -337,9 +346,10 @@ show_cksum(const char *title, Package *plist)
dir = p->name;
} else if (p->type == PLIST_FILE) {
snprintf(tmp, FILENAME_MAX, "%s/%s", elide_root(dir), p->name);
- if (!fexists(tmp))
+ if (!fexists(tmp)) {
warnx("%s doesn't exist", tmp);
- else if (p->next && p->next->type == PLIST_COMMENT &&
+ errcode = 1;
+ } else if (p->next && p->next->type == PLIST_COMMENT &&
(strncmp(p->next->name, "MD5:", 4) == 0)) {
char *cp = NULL, buf[33];
@@ -366,6 +376,7 @@ show_cksum(const char *title, Package *plist)
}
}
}
+ return (errcode);
}
/* Show an "origin" path (usually category/portname) */
@@ -373,8 +384,10 @@ void
show_origin(const char *title, Package *plist)
{
- if (!Quiet)
+ if (!Quiet) {
printf("%s%s", InfoPrefix, title);
+ fflush(stdout);
+ }
printf("%s\n", plist->origin != NULL ? plist->origin : "");
}
@@ -383,7 +396,9 @@ void
show_fmtrev(const char *title, Package *plist)
{
- if (!Quiet)
+ if (!Quiet) {
printf("%s%s", InfoPrefix, title);
+ fflush(stdout);
+ }
printf("%d.%d\n", plist->fmtver_maj, plist->fmtver_mnr);
}
diff --git a/usr.sbin/pkg_install/lib/Makefile b/usr.sbin/pkg_install/lib/Makefile
index 84a41b8..12cc307 100644
--- a/usr.sbin/pkg_install/lib/Makefile
+++ b/usr.sbin/pkg_install/lib/Makefile
@@ -3,7 +3,7 @@
LIB= install
INTERNALLIB=
SRCS= file.c msg.c plist.c str.c exec.c global.c pen.c match.c \
- deps.c version.c pkgwrap.c url.c
+ deps.c version.c pkgwrap.c url.c pkgng.c
WARNS?= 3
WFORMAT?= 1
diff --git a/usr.sbin/pkg_install/lib/Makefile.depend b/usr.sbin/pkg_install/lib/Makefile.depend
new file mode 100644
index 0000000..8d84ca1
--- /dev/null
+++ b/usr.sbin/pkg_install/lib/Makefile.depend
@@ -0,0 +1,19 @@
+# Autogenerated - do NOT edit!
+
+DEP_RELDIR := ${_PARSEDIR:S,${SRCTOP}/,,}
+
+DEP_MACHINE := ${.PARSEFILE:E}
+
+DIRDEPS = \
+ include \
+ include/xlocale \
+ lib/libfetch \
+ lib/libmd \
+ lib/libutil \
+
+
+.include <dirdeps.mk>
+
+.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+# local dependencies - needed for -jN in clean tree
+.endif
diff --git a/usr.sbin/pkg_install/lib/exec.c b/usr.sbin/pkg_install/lib/exec.c
index c95ac47..0804501 100644
--- a/usr.sbin/pkg_install/lib/exec.c
+++ b/usr.sbin/pkg_install/lib/exec.c
@@ -93,6 +93,7 @@ vpipe(const char *fmt, ...)
fp = popen(cmd, "r");
if (fp == NULL) {
warnx("popen() failed");
+ va_end(args);
return NULL;
}
get_string(rp, MAXPATHLEN, fp);
diff --git a/usr.sbin/pkg_install/lib/lib.h b/usr.sbin/pkg_install/lib/lib.h
index 7890254..88fcf34 100644
--- a/usr.sbin/pkg_install/lib/lib.h
+++ b/usr.sbin/pkg_install/lib/lib.h
@@ -99,7 +99,7 @@
* Version of the package tools - increase whenever you make a change
* in the code that is not cosmetic only.
*/
-#define PKG_INSTALL_VERSION 20120530
+#define PKG_INSTALL_VERSION 20120918
#define PKG_WRAPCONF_FNAME "/var/db/pkg_install.conf"
#define main(argc, argv) real_main(argc, argv)
@@ -157,6 +157,7 @@ const char *make_playpen(char *, off_t);
char *where_playpen(void);
int leave_playpen(void);
off_t min_free(const char *);
+void warnpkgng(void);
/* String */
char *get_dash_string(char **);
diff --git a/usr.sbin/pkg_install/lib/pkgng.c b/usr.sbin/pkg_install/lib/pkgng.c
new file mode 100644
index 0000000..76c8ad8
--- /dev/null
+++ b/usr.sbin/pkg_install/lib/pkgng.c
@@ -0,0 +1,38 @@
+/*
+ * FreeBSD install - a package for the installation and maintenance
+ * of non-core utilities.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * Eitan Adler
+ *
+ * detect pkgng's existence and warn
+ *
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
+#include "lib.h"
+#include <err.h>
+
+void warnpkgng(void) {
+ char pkgngpath[MAXPATHLEN];
+ char *pkgngdir;
+
+ pkgngdir = getenv("PKG_DBDIR");
+ if (pkgngdir == NULL)
+ pkgngdir = "/var/db/pkg";
+ strcpy(pkgngpath, pkgngdir);
+ strcat(pkgngpath, "/local.sqlite");
+
+ if (access(pkgngpath, F_OK) == 0)
+ warnx("Don't use the pkg_ tools if you are using pkgng");
+}
diff --git a/usr.sbin/pkg_install/lib/plist.c b/usr.sbin/pkg_install/lib/plist.c
index a1b5c55..bce6d04 100644
--- a/usr.sbin/pkg_install/lib/plist.c
+++ b/usr.sbin/pkg_install/lib/plist.c
@@ -458,7 +458,10 @@ delete_package(Boolean ign_err, Boolean nukedirs, Package *pkg)
case PLIST_FILE:
last_file = p->name;
- sprintf(tmp, "%s/%s", Where, p->name);
+ if (*p->name == '/')
+ strlcpy(tmp, p->name, FILENAME_MAX);
+ else
+ sprintf(tmp, "%s/%s", Where, p->name);
if (isdir(tmp) && fexists(tmp) && !issymlink(tmp)) {
warnx("cannot delete specified file '%s' - it is a directory!\n"
"this packing list is incorrect - ignoring delete request", tmp);
diff --git a/usr.sbin/pkg_install/updating/Makefile.depend b/usr.sbin/pkg_install/updating/Makefile.depend
new file mode 100644
index 0000000..fa35fef
--- /dev/null
+++ b/usr.sbin/pkg_install/updating/Makefile.depend
@@ -0,0 +1,25 @@
+# Autogenerated - do NOT edit!
+
+DEP_RELDIR := ${_PARSEDIR:S,${SRCTOP}/,,}
+
+DEP_MACHINE := ${.PARSEFILE:E}
+
+DIRDEPS = \
+ gnu/lib/libgcc \
+ include \
+ include/xlocale \
+ lib/${CSU_DIR} \
+ lib/libc \
+ lib/libfetch \
+ lib/libmd \
+ lib/libutil \
+ secure/lib/libcrypto \
+ secure/lib/libssl \
+ usr.sbin/pkg_install/lib \
+
+
+.include <dirdeps.mk>
+
+.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+# local dependencies - needed for -jN in clean tree
+.endif
diff --git a/usr.sbin/pkg_install/updating/main.c b/usr.sbin/pkg_install/updating/main.c
index e7a840f..4a36e22 100644
--- a/usr.sbin/pkg_install/updating/main.c
+++ b/usr.sbin/pkg_install/updating/main.c
@@ -87,6 +87,7 @@ main(int argc, char *argv[])
DIR *dir;
FILE *fd;
+ warnpkgng();
while ((ch = getopt_long(argc, argv, opts, longopts, NULL)) != -1) {
switch (ch) {
case 'd':
diff --git a/usr.sbin/pkg_install/version/Makefile.depend b/usr.sbin/pkg_install/version/Makefile.depend
new file mode 100644
index 0000000..fa35fef
--- /dev/null
+++ b/usr.sbin/pkg_install/version/Makefile.depend
@@ -0,0 +1,25 @@
+# Autogenerated - do NOT edit!
+
+DEP_RELDIR := ${_PARSEDIR:S,${SRCTOP}/,,}
+
+DEP_MACHINE := ${.PARSEFILE:E}
+
+DIRDEPS = \
+ gnu/lib/libgcc \
+ include \
+ include/xlocale \
+ lib/${CSU_DIR} \
+ lib/libc \
+ lib/libfetch \
+ lib/libmd \
+ lib/libutil \
+ secure/lib/libcrypto \
+ secure/lib/libssl \
+ usr.sbin/pkg_install/lib \
+
+
+.include <dirdeps.mk>
+
+.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+# local dependencies - needed for -jN in clean tree
+.endif
diff --git a/usr.sbin/pkg_install/version/main.c b/usr.sbin/pkg_install/version/main.c
index 39c603e..dd67e63 100644
--- a/usr.sbin/pkg_install/version/main.c
+++ b/usr.sbin/pkg_install/version/main.c
@@ -58,6 +58,7 @@ main(int argc, char **argv)
{
int ch, cmp = 0;
+ warnpkgng();
if (argc == 4 && !strcmp(argv[1], "-t")) {
cmp = version_cmp(argv[2], argv[3]);
printf(cmp > 0 ? ">\n" : (cmp < 0 ? "<\n" : "=\n"));
diff --git a/usr.sbin/pkg_install/version/perform.c b/usr.sbin/pkg_install/version/perform.c
index 733cb5e..426d979 100644
--- a/usr.sbin/pkg_install/version/perform.c
+++ b/usr.sbin/pkg_install/version/perform.c
@@ -27,9 +27,9 @@ __FBSDID("$FreeBSD$");
#include <fetch.h>
#include <signal.h>
-FILE *IndexFile;
-char IndexPath[PATH_MAX] = "";
-struct index_head Index = SLIST_HEAD_INITIALIZER(Index);
+static FILE *IndexFile;
+static char IndexPath[PATH_MAX] = "";
+static struct index_head Index = SLIST_HEAD_INITIALIZER(Index);
static int pkg_do(char *);
static void show_version(Package, const char *, const char *);
@@ -56,10 +56,11 @@ pkg_perform(char **indexarg)
struct utsname u;
if (uname(&u) == -1) {
- warn("%s(): failed to determine uname information", __func__);
+ warn("%s: failed to determine uname information", __func__);
return 1;
} else if ((rel_major_ver = (int) strtol(u.release, NULL, 10)) <= 0) {
-
+ warnx("%s: bad release version specified: %s", __func__, u.release);
+ return 1;
}
/*
@@ -321,19 +322,31 @@ show_version(Package plist, const char *latest, const char *source)
ver = strrchr(latest, '-');
ver = ver ? &ver[1] : latest;
if (cmp < 0 && OUTPUT('<')) {
- printf("%-34s %c", tmp, Quiet ? '\0' : '<');
- if (Verbose)
- printf(" needs updating (%s has %s)", source, ver);
+ if (Quiet)
+ printf("%s", tmp);
+ else {
+ printf("%-34s <", tmp);
+ if (Verbose)
+ printf(" needs updating (%s has %s)", source, ver);
+ }
printf("\n");
} else if (cmp == 0 && OUTPUT('=')) {
- printf("%-34s %c", tmp, Quiet ? '\0' : '=');
- if (Verbose)
- printf(" up-to-date with %s", source);
+ if (Quiet)
+ printf("%s", tmp);
+ else {
+ printf("%-34s =", tmp);
+ if (Verbose)
+ printf(" up-to-date with %s", source);
+ }
printf("\n");
} else if (cmp > 0 && OUTPUT('>')) {
- printf("%-34s %c", tmp, Quiet ? '\0' : '>');
- if (Verbose)
- printf(" succeeds %s (%s has %s)", source, source, ver);
+ if (Quiet)
+ printf("%s", tmp);
+ else {
+ printf("%-34s >", tmp);
+ if (Verbose)
+ printf(" succeeds %s (%s has %s)", source, source, ver);
+ }
printf("\n");
}
}
diff --git a/usr.sbin/pmcannotate/Makefile.depend b/usr.sbin/pmcannotate/Makefile.depend
new file mode 100644
index 0000000..a839545
--- /dev/null
+++ b/usr.sbin/pmcannotate/Makefile.depend
@@ -0,0 +1,19 @@
+# Autogenerated - do NOT edit!
+
+DEP_RELDIR := ${_PARSEDIR:S,${SRCTOP}/,,}
+
+DEP_MACHINE := ${.PARSEFILE:E}
+
+DIRDEPS = \
+ gnu/lib/libgcc \
+ include \
+ include/xlocale \
+ lib/${CSU_DIR} \
+ lib/libc \
+
+
+.include <dirdeps.mk>
+
+.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+# local dependencies - needed for -jN in clean tree
+.endif
diff --git a/usr.sbin/pmccontrol/Makefile.depend b/usr.sbin/pmccontrol/Makefile.depend
new file mode 100644
index 0000000..43f31ea
--- /dev/null
+++ b/usr.sbin/pmccontrol/Makefile.depend
@@ -0,0 +1,20 @@
+# Autogenerated - do NOT edit!
+
+DEP_RELDIR := ${_PARSEDIR:S,${SRCTOP}/,,}
+
+DEP_MACHINE := ${.PARSEFILE:E}
+
+DIRDEPS = \
+ gnu/lib/libgcc \
+ include \
+ include/xlocale \
+ lib/${CSU_DIR} \
+ lib/libc \
+ lib/libpmc \
+
+
+.include <dirdeps.mk>
+
+.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+# local dependencies - needed for -jN in clean tree
+.endif
diff --git a/usr.sbin/pmccontrol/pmccontrol.c b/usr.sbin/pmccontrol/pmccontrol.c
index bc0ebdc..b3585d0 100644
--- a/usr.sbin/pmccontrol/pmccontrol.c
+++ b/usr.sbin/pmccontrol/pmccontrol.c
@@ -66,7 +66,7 @@ __FBSDID("$FreeBSD$");
#define PMCC_PROGRAM_NAME "pmccontrol"
-STAILQ_HEAD(pmcc_op_list, pmcc_op) head = STAILQ_HEAD_INITIALIZER(head);
+static STAILQ_HEAD(pmcc_op_list, pmcc_op) head = STAILQ_HEAD_INITIALIZER(head);
struct pmcc_op {
char op_cpu;
@@ -94,7 +94,7 @@ static char usage_message[] =
" " PMCC_PROGRAM_NAME " [-e pmc | -d pmc | -c cpu] ...";
#if DEBUG
-FILE *debug_stream = NULL;
+static FILE *debug_stream = NULL;
#endif
#if DEBUG
@@ -104,15 +104,6 @@ FILE *debug_stream = NULL;
#define DEBUG_MSG(m) /* */
#endif /* !DEBUG */
-int pmc_syscall = -1;
-
-#define PMC_CALL(cmd, params) \
-if ((error = syscall(pmc_syscall, PMC_OP_##cmd, (params))) != 0) \
-{ \
- DEBUG_MSG("ERROR: syscall [" #cmd "]"); \
- exit(EX_OSERR); \
-}
-
#if DEBUG
/* log debug messages to a separate file */
static void
diff --git a/usr.sbin/pmcstat/Makefile.depend b/usr.sbin/pmcstat/Makefile.depend
new file mode 100644
index 0000000..c2f6f64
--- /dev/null
+++ b/usr.sbin/pmcstat/Makefile.depend
@@ -0,0 +1,25 @@
+# Autogenerated - do NOT edit!
+
+DEP_RELDIR := ${_PARSEDIR:S,${SRCTOP}/,,}
+
+DEP_MACHINE := ${.PARSEFILE:E}
+
+DIRDEPS = \
+ gnu/lib/libgcc \
+ include \
+ include/xlocale \
+ lib/${CSU_DIR} \
+ lib/libc \
+ lib/libelf \
+ lib/libkvm \
+ lib/libpmc \
+ lib/msun \
+ lib/ncurses/ncurses \
+ lib/ncurses/ncursesw \
+
+
+.include <dirdeps.mk>
+
+.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+# local dependencies - needed for -jN in clean tree
+.endif
diff --git a/usr.sbin/pmcstat/pmcpl_calltree.c b/usr.sbin/pmcstat/pmcpl_calltree.c
index 6b8bc61..3d0127d 100644
--- a/usr.sbin/pmcstat/pmcpl_calltree.c
+++ b/usr.sbin/pmcstat/pmcpl_calltree.c
@@ -125,7 +125,7 @@ struct pmcpl_ct_node_hash {
STAILQ_ENTRY(pmcpl_ct_node_hash) pch_next;
};
-struct pmcpl_ct_sample pmcpl_ct_callid;
+static struct pmcpl_ct_sample pmcpl_ct_callid;
#define PMCPL_CT_MAXCOL PMC_CALLCHAIN_DEPTH_MAX
#define PMCPL_CT_MAXLINE 1024 /* TODO: dynamic. */
@@ -135,8 +135,8 @@ struct pmcpl_ct_line {
unsigned ln_index;
};
-struct pmcpl_ct_line pmcpl_ct_topmax[PMCPL_CT_MAXLINE+1];
-struct pmcpl_ct_node
+static struct pmcpl_ct_line pmcpl_ct_topmax[PMCPL_CT_MAXLINE+1];
+static struct pmcpl_ct_node
*pmcpl_ct_topscreen[PMCPL_CT_MAXCOL+1][PMCPL_CT_MAXLINE+1];
/*
diff --git a/usr.sbin/pmcstat/pmcstat.c b/usr.sbin/pmcstat/pmcstat.c
index 0133119..cc43b82 100644
--- a/usr.sbin/pmcstat/pmcstat.c
+++ b/usr.sbin/pmcstat/pmcstat.c
@@ -105,13 +105,12 @@ __FBSDID("$FreeBSD$");
/* Globals */
-int pmcstat_interrupt = 0;
-int pmcstat_displayheight = DEFAULT_DISPLAY_HEIGHT;
-int pmcstat_displaywidth = DEFAULT_DISPLAY_WIDTH;
-int pmcstat_sockpair[NSOCKPAIRFD];
-int pmcstat_kq;
-kvm_t *pmcstat_kvm;
-struct kinfo_proc *pmcstat_plist;
+int pmcstat_displayheight = DEFAULT_DISPLAY_HEIGHT;
+int pmcstat_displaywidth = DEFAULT_DISPLAY_WIDTH;
+static int pmcstat_sockpair[NSOCKPAIRFD];
+static int pmcstat_kq;
+static kvm_t *pmcstat_kvm;
+static struct kinfo_proc *pmcstat_plist;
struct pmcstat_args args;
static void
@@ -509,6 +508,7 @@ pmcstat_show_usage(void)
"\t -f spec\t pass \"spec\" to as plugin option\n"
"\t -g\t\t produce gprof(1) compatible profiles\n"
"\t -k dir\t\t set the path to the kernel\n"
+ "\t -m file\t print sampled PCs to \"file\"\n"
"\t -n rate\t set sampling rate\n"
"\t -o file\t send print output to \"file\"\n"
"\t -p spec\t allocate a process-private counting PMC\n"
diff --git a/usr.sbin/pmcstat/pmcstat_log.c b/usr.sbin/pmcstat/pmcstat_log.c
index b7f5a23..fdcf9c4 100644
--- a/usr.sbin/pmcstat/pmcstat_log.c
+++ b/usr.sbin/pmcstat/pmcstat_log.c
@@ -142,7 +142,7 @@ struct pmcstat_image_hash_list pmcstat_image_hash[PMCSTAT_NHASH];
struct pmcstat_process_hash_list pmcstat_process_hash[PMCSTAT_NHASH];
struct pmcstat_stats pmcstat_stats; /* statistics */
-int ps_samples_period; /* samples count between top refresh. */
+static int ps_samples_period; /* samples count between top refresh. */
struct pmcstat_process *pmcstat_kernproc; /* kernel 'process' */
@@ -151,7 +151,7 @@ struct pmcstat_process *pmcstat_kernproc; /* kernel 'process' */
#include "pmcpl_annotate.h"
#include "pmcpl_calltree.h"
-struct pmc_plugins {
+static struct pmc_plugins {
const char *pl_name; /* name */
/* configure */
@@ -218,7 +218,7 @@ struct pmc_plugins {
}
};
-int pmcstat_mergepmc;
+static int pmcstat_mergepmc;
int pmcstat_pmcinfilter = 0; /* PMC filter for top mode. */
float pmcstat_threshold = 0.5; /* Cost filter for top mode. */
@@ -275,7 +275,7 @@ int pmcstat_npmcs;
/*
* PMC Top mode pause state.
*/
-int pmcstat_pause;
+static int pmcstat_pause;
static void
pmcstat_stats_reset(int reset_global)
@@ -554,6 +554,14 @@ pmcstat_image_add_symbols(struct pmcstat_image *image, Elf *e,
if ((fnname = elf_strptr(e, sh->sh_link, sym.st_name))
== NULL)
continue;
+#ifdef __arm__
+ /* Remove spurious ARM function name. */
+ if (fnname[0] == '$' &&
+ (fnname[1] == 'a' || fnname[1] == 't' ||
+ fnname[1] == 'd') &&
+ fnname[2] == '\0')
+ continue;
+#endif
symptr->ps_name = pmcstat_string_intern(fnname);
symptr->ps_start = sym.st_value - image->pi_vaddr;
diff --git a/usr.sbin/pmcstat/pmcstat_log.h b/usr.sbin/pmcstat/pmcstat_log.h
index bfa925c..b4ced4d 100644
--- a/usr.sbin/pmcstat/pmcstat_log.h
+++ b/usr.sbin/pmcstat/pmcstat_log.h
@@ -176,8 +176,8 @@ extern int pmcstat_npmcs; /* PMC count. */
/*
* Top mode global options.
*/
-float pmcstat_threshold; /* Threshold to filter node. */
-int pmcstat_pmcinfilter; /* PMC index displayed. */
+extern float pmcstat_threshold; /* Threshold to filter node. */
+extern int pmcstat_pmcinfilter; /* PMC index displayed. */
/* Function prototypes */
const char *pmcstat_pmcid_to_name(pmc_id_t _pmcid);
diff --git a/usr.sbin/pnpinfo/Makefile.depend b/usr.sbin/pnpinfo/Makefile.depend
new file mode 100644
index 0000000..a839545
--- /dev/null
+++ b/usr.sbin/pnpinfo/Makefile.depend
@@ -0,0 +1,19 @@
+# Autogenerated - do NOT edit!
+
+DEP_RELDIR := ${_PARSEDIR:S,${SRCTOP}/,,}
+
+DEP_MACHINE := ${.PARSEFILE:E}
+
+DIRDEPS = \
+ gnu/lib/libgcc \
+ include \
+ include/xlocale \
+ lib/${CSU_DIR} \
+ lib/libc \
+
+
+.include <dirdeps.mk>
+
+.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+# local dependencies - needed for -jN in clean tree
+.endif
diff --git a/usr.sbin/portsnap/make_index/Makefile.depend b/usr.sbin/portsnap/make_index/Makefile.depend
new file mode 100644
index 0000000..a839545
--- /dev/null
+++ b/usr.sbin/portsnap/make_index/Makefile.depend
@@ -0,0 +1,19 @@
+# Autogenerated - do NOT edit!
+
+DEP_RELDIR := ${_PARSEDIR:S,${SRCTOP}/,,}
+
+DEP_MACHINE := ${.PARSEFILE:E}
+
+DIRDEPS = \
+ gnu/lib/libgcc \
+ include \
+ include/xlocale \
+ lib/${CSU_DIR} \
+ lib/libc \
+
+
+.include <dirdeps.mk>
+
+.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+# local dependencies - needed for -jN in clean tree
+.endif
diff --git a/usr.sbin/portsnap/phttpget/Makefile.depend b/usr.sbin/portsnap/phttpget/Makefile.depend
new file mode 100644
index 0000000..a839545
--- /dev/null
+++ b/usr.sbin/portsnap/phttpget/Makefile.depend
@@ -0,0 +1,19 @@
+# Autogenerated - do NOT edit!
+
+DEP_RELDIR := ${_PARSEDIR:S,${SRCTOP}/,,}
+
+DEP_MACHINE := ${.PARSEFILE:E}
+
+DIRDEPS = \
+ gnu/lib/libgcc \
+ include \
+ include/xlocale \
+ lib/${CSU_DIR} \
+ lib/libc \
+
+
+.include <dirdeps.mk>
+
+.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+# local dependencies - needed for -jN in clean tree
+.endif
diff --git a/usr.sbin/portsnap/portsnap/Makefile.depend b/usr.sbin/portsnap/portsnap/Makefile.depend
new file mode 100644
index 0000000..29fda55
--- /dev/null
+++ b/usr.sbin/portsnap/portsnap/Makefile.depend
@@ -0,0 +1,14 @@
+# Autogenerated - do NOT edit!
+
+DEP_RELDIR := ${_PARSEDIR:S,${SRCTOP}/,,}
+
+DEP_MACHINE := ${.PARSEFILE:E}
+
+DIRDEPS = \
+
+
+.include <dirdeps.mk>
+
+.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+# local dependencies - needed for -jN in clean tree
+.endif
diff --git a/usr.sbin/portsnap/portsnap/portsnap.8 b/usr.sbin/portsnap/portsnap/portsnap.8
index 0d9c261..da94efc 100644
--- a/usr.sbin/portsnap/portsnap/portsnap.8
+++ b/usr.sbin/portsnap/portsnap/portsnap.8
@@ -25,7 +25,7 @@
.\"
.\" $FreeBSD$
.\"
-.Dd September 15, 2008
+.Dd October 14, 2012
.Dt PORTSNAP 8
.Os FreeBSD
.Sh NAME
@@ -55,10 +55,6 @@ In a normal update operation,
.Nm
will routinely restore modified files to their unmodified state and
delete unrecognized local files.
-This behavior is different to
-.Xr cvs 1
-and
-.Xr cvsup 1 .
.Sh OPTIONS
The following options are supported:
.Bl -tag -width "-f conffile"
@@ -110,6 +106,12 @@ command only, operate only on parts of the ports tree starting with
.Ar sysutils/port
would extract sysutils/portsman, sysutils/portsnap,
sysutils/portupgrade, etc.)
+.It Fl Fl interactive
+override auto-detection of calling process.
+Only use this when calling portsnap from an
+.Sy interactive, non-terminal application.
+(Cron jobs are particularly bad since they cause
+load spikes on the Portsnap mirrors.)
.El
.Sh COMMANDS
The
@@ -174,6 +176,23 @@ can quickly be extracted into
If your clock is set to UTC, please pick a random time other
than 3AM, to avoid overly imposing an uneven load on the
server(s) hosting the snapshots.
+.Pp
+Note that running
+.Nm
+.Cm cron
+or
+.Nm
+.Cm fetch
+does not apply the changes that were received: they only download
+them.
+To apply the changes, you must follow these commands with
+.Nm
+.Cm update .
+The
+.Nm
+.Cm update
+command is normally run by hand at a time when you are sure that
+no one is manually working in the ports tree.
.It
Running
.Nm
diff --git a/usr.sbin/portsnap/portsnap/portsnap.sh b/usr.sbin/portsnap/portsnap/portsnap.sh
index 033bb55..ed9c28d 100644
--- a/usr.sbin/portsnap/portsnap/portsnap.sh
+++ b/usr.sbin/portsnap/portsnap/portsnap.sh
@@ -48,6 +48,9 @@ Options:
(default: /usr/ports/)
-s server -- Server from which to fetch updates.
(default: portsnap.FreeBSD.org)
+ --interactive -- interactive: override auto-detection of calling process
+ (use this when calling portsnap from an interactive, non-
+ terminal application AND NEVER ELSE).
path -- Extract only parts of the tree starting with the given
string. (extract command only)
Commands:
@@ -84,6 +87,7 @@ init_params() {
SERVERNAME=""
REFUSE=""
LOCALDESC=""
+ INTERACTIVE=""
}
# Parse the command line
@@ -103,6 +107,9 @@ parse_cmdline() {
XARGST="-t"
DDSTATS=".."
;;
+ --interactive)
+ INTERACTIVE="YES"
+ ;;
-f)
if [ $# -eq 1 ]; then usage; fi
if [ ! -z "${CONFFILE}" ]; then usage; fi
@@ -228,6 +235,13 @@ default_params() {
eval ${X}=${__}
fi
done
+ if [ -z "${INTERACTIVE}" ]; then
+ if [ -t 0 ]; then
+ INTERACTIVE="YES"
+ else
+ INTERACTIVE="NO"
+ fi
+ fi
}
# Perform sanity checks and set some final parameters
@@ -573,7 +587,7 @@ fetch_metadata_sanity() {
# Take a list of ${oldhash}|${newhash} and output a list of needed patches
fetch_make_patchlist() {
- IFS='|'
+ local IFS='|'
echo "" 1>${QUIETREDIR}
grep -vE "^([0-9a-f]{64})\|\1$" |
while read X Y; do
@@ -582,7 +596,6 @@ fetch_make_patchlist() {
echo "${X}|${Y}"
done
echo "" 1>${QUIETREDIR}
- IFS=
}
# Print user-friendly progress statistics
@@ -697,7 +710,7 @@ fetch_update() {
# Attempt to apply metadata patches
echo -n "Applying metadata patches... "
- IFS='|'
+ local oldifs="$IFS" IFS='|'
while read X Y; do
if [ ! -f "${X}-${Y}.gz" ]; then continue; fi
gunzip -c < ${X}-${Y}.gz > diff
@@ -711,7 +724,7 @@ fetch_update() {
fi
rm -f diff OLD NEW ${X}-${Y}.gz ptmp
done < patchlist 2>${QUIETREDIR}
- IFS=
+ IFS="$oldifs"
echo "done."
# Update metadata without patches
@@ -778,7 +791,7 @@ fetch_update() {
# Attempt to apply ports patches
PATCHCNT=`wc -l patchlist`
echo "Applying patches... "
- IFS='|'
+ local oldifs="$IFS" IFS='|'
I=0
while read X Y; do
I=$(($I + 1))
@@ -796,7 +809,7 @@ fetch_update() {
fi
rm -f diff OLD NEW ${X}-${Y}
done < patchlist 2>${QUIETREDIR}
- IFS=
+ IFS="$oldifs"
echo "done."
# Update ports without patches
@@ -898,7 +911,7 @@ extract_metadata() {
# Do the actual work involved in "extract"
extract_run() {
- local IFS='|'
+ local oldifs="$IFS" IFS='|'
mkdir -p ${PORTSDIR} || return 1
if !
@@ -934,6 +947,8 @@ extract_run() {
return 0;
fi
+ IFS="$oldifs"
+
extract_metadata
extract_indices
}
@@ -1023,10 +1038,10 @@ get_params() {
# Fetch command. Make sure that we're being called
# interactively, then run fetch_check_params and fetch_run
cmd_fetch() {
- if [ ! -t 0 ]; then
+ if [ "${INTERACTIVE}" != "YES" ]; then
echo -n "`basename $0` fetch should not "
echo "be run non-interactively."
- echo "Run `basename $0` cron instead."
+ echo "Run `basename $0` cron instead"
exit 1
fi
fetch_check_params
@@ -1069,7 +1084,7 @@ cmd_update() {
# whether stdin is a terminal; then run 'update' or
# 'extract' depending on whether ${PORTSDIR} exists.
cmd_alfred() {
- if [ -t 0 ]; then
+ if [ "${INTERACTIVE}" = "YES" ]; then
cmd_fetch
else
cmd_cron
diff --git a/usr.sbin/powerd/Makefile.depend b/usr.sbin/powerd/Makefile.depend
new file mode 100644
index 0000000..2dd29af
--- /dev/null
+++ b/usr.sbin/powerd/Makefile.depend
@@ -0,0 +1,20 @@
+# Autogenerated - do NOT edit!
+
+DEP_RELDIR := ${_PARSEDIR:S,${SRCTOP}/,,}
+
+DEP_MACHINE := ${.PARSEFILE:E}
+
+DIRDEPS = \
+ gnu/lib/libgcc \
+ include \
+ include/xlocale \
+ lib/${CSU_DIR} \
+ lib/libc \
+ lib/libutil \
+
+
+.include <dirdeps.mk>
+
+.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+# local dependencies - needed for -jN in clean tree
+.endif
diff --git a/usr.sbin/ppp/Makefile.depend b/usr.sbin/ppp/Makefile.depend
new file mode 100644
index 0000000..7022136
--- /dev/null
+++ b/usr.sbin/ppp/Makefile.depend
@@ -0,0 +1,29 @@
+# Autogenerated - do NOT edit!
+
+DEP_RELDIR := ${_PARSEDIR:S,${SRCTOP}/,,}
+
+DEP_MACHINE := ${.PARSEFILE:E}
+
+DIRDEPS = \
+ gnu/lib/libgcc \
+ include \
+ include/arpa \
+ include/xlocale \
+ lib/${CSU_DIR} \
+ lib/libalias/libalias \
+ lib/libc \
+ lib/libcrypt \
+ lib/libmd \
+ lib/libnetgraph \
+ lib/libpam/libpam \
+ lib/libradius \
+ lib/libutil \
+ lib/libz \
+ secure/lib/libcrypto \
+
+
+.include <dirdeps.mk>
+
+.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+# local dependencies - needed for -jN in clean tree
+.endif
diff --git a/usr.sbin/ppp/lqr.c b/usr.sbin/ppp/lqr.c
index 7aca17a..7ce1513 100644
--- a/usr.sbin/ppp/lqr.c
+++ b/usr.sbin/ppp/lqr.c
@@ -108,7 +108,8 @@ lqr_RecvEcho(struct fsm *fp, struct mbuf *bp)
* die as a result.
*/
}
- if (lqr.signature == SIGNATURE) {
+ if (lqr.signature == SIGNATURE
+ || lqr.signature == lcp->want_magic) { /* some implementations return the wrong magic */
/* careful not to update lqm.echo.seq_recv with older values */
if ((hdlc->lqm.echo.seq_recv > (u_int32_t)0 - 5 && lqr.sequence < 5) ||
(hdlc->lqm.echo.seq_recv <= (u_int32_t)0 - 5 &&
diff --git a/usr.sbin/ppp/ppp.8.m4 b/usr.sbin/ppp/ppp.8.m4
index 935814e..7d3f6d2 100644
--- a/usr.sbin/ppp/ppp.8.m4
+++ b/usr.sbin/ppp/ppp.8.m4
@@ -292,7 +292,7 @@ In direct mode,
acts as server which accepts incoming
.Em PPP
connections on stdin/stdout.
-.It "Supports PAP and CHAP (rfc 1994, 2433 and 2759) authentication.
+.It Supports PAP and CHAP (rfc 1994, 2433 and 2759) authentication.
With PAP or CHAP, it is possible to skip the Unix style
.Xr login 1
procedure, and use the
@@ -1019,12 +1019,11 @@ This behaviour can be changed using the
.Dq set redial
command:
.Pp
-.No set redial Ar secs Ns Xo
+.No set redial Ar secs Ns
.Oo + Ns Ar inc Ns
-.Op - Ns Ar max Ns
-.Oc Ns Op . Ns Ar next
+.Oo - Ns Ar max Ns Oc Oc Ns
+.Op . Ns Ar next
.Op Ar attempts
-.Xc
.Pp
.Bl -tag -width attempts -compact
.It Ar secs
@@ -1083,7 +1082,6 @@ are specified, the total number of attempts is still 4 (it does not
attempt each number 4 times).
.Pp
Alternatively,
-.Pp
.Bd -literal -offset indent
set redial 10+10-5.3 20
.Ed
@@ -2029,11 +2027,8 @@ dialing and redialing separated by either a pipe
or a colon
.Pq Dq \&: :
.Bd -ragged -offset indent
-.No set phone Ar telno Ns Xo
-.Oo \&| Ns Ar backupnumber
-.Oc Ns ... Ns Oo : Ns Ar nextnumber
-.Oc Ns ...
-.Xc
+.No set phone Ar telno Ns
+.Oo \&| Ns Ar backupnumber Oc Ns ... Ns Oo : Ns Ar nextnumber Oc Ns ...
.Ed
.Pp
Numbers after the first in a pipe-separated list are only used if the
@@ -2530,7 +2525,6 @@ will show the same information at the
link level.
.Pp
Armed with this information, the following configuration might be used:
-.Pp
.Bd -literal -offset indent
mp:
set timeout 0
@@ -2554,13 +2548,11 @@ Usually, the link will be configured first, then cloned.
If you wish all links
to be up all the time, you can add the following line to the end of your
configuration.
-.Pp
.Bd -literal -offset indent
link 1,2,3 set mode ddial
.Ed
.Pp
If you want the links to dial on demand, this command could be used:
-.Pp
.Bd -literal -offset indent
link * set mode auto
.Ed
@@ -2570,7 +2562,6 @@ Links may be tied to specific names by removing the
line above, and specifying the following after the
.Dq clone
command:
-.Pp
.Bd -literal -offset indent
link 1 set device /dev/cuad0
link 2 set device /dev/cuad1
@@ -3218,9 +3209,7 @@ Disabling this option will prevent the re-application of sticky routes,
although the
.Sq stick route
list will still be maintained.
-.It Op tcp Ns Xo
-.No mssfixup
-.Xc
+.It Oo tcp Oc Ns No mssfixup
Default: Enabled.
This option tells
.Nm
@@ -3474,7 +3463,7 @@ be logged to the file
.Ar remotePort Ns
.Oo
.No - Ns Ar remotePort
-.Oc Ns
+.Oc
.Oc
.Xc
This command causes incoming
@@ -3606,7 +3595,7 @@ These commands are also discussed in the file
.Pa README.nat
which comes with the source distribution.
.Pp
-.It Op !\& Ns Xo
+.It Oo !\& Oc Ns Xo
.No bg Ar command
.Xc
The given
@@ -3808,7 +3797,7 @@ command is used
.Dq !\& ) ,
.Nm
will not complain if the route does not already exist.
-.It dial|call Op Ar label Ns Xo
+.It dial|call Oo Ar label Oc Ns Xo
.No ...
.Xc
This command is the equivalent of
@@ -3945,10 +3934,9 @@ When invoked with
.Ar sub-command ,
only the synopsis for the given sub-command is shown.
.El
-.It Op data Ns Xo
+.It Oo data Oc Ns Xo
.No link
-.Ar name Ns Op , Ns Ar name Ns
-.No ... Ar command Op Ar args
+.Ar name Ns Oo , Ns Ar name Oc Ns ... Ar command Op Ar args
.Xc
This command may prefix any other command if the user wishes to
specify which link the command should affect.
@@ -3970,7 +3958,7 @@ is
.Dq * ,
.Ar command
is executed on all links.
-.It load Op Ar label Ns Xo
+.It load Oo Ar label Oc Ns Xo
.No ...
.Xc
Load the given
@@ -4196,7 +4184,7 @@ certain characters from end to end (such as XON/XOFF etc).
.Pp
For the XON/XOFF scenario, use
.Dq set accmap 000a0000 .
-.It set Op auth Ns Xo
+.It set Oo auth Oc Ns Xo
.No key Ar value
.Xc
This sets the authentication key (or password) used in client mode
@@ -4360,7 +4348,6 @@ as an option.
The
.Ar option Ns No s
are as follows (in this order of preference):
-.Pp
.Bl -tag -width Ds
.It auth
The callee is expected to decide the callback number based on
@@ -4993,11 +4980,8 @@ If you wish to assign a dynamic IP number to the peer,
.Ar hisaddr
may also be specified as a range of IP numbers in the format
.Bd -ragged -offset indent
-.Ar \&IP Ns Oo \&- Ns Ar \&IP Ns Xo
-.Oc Ns Oo , Ns Ar \&IP Ns
-.Op \&- Ns Ar \&IP Ns
-.Oc Ns ...
-.Xc
+.Ar \&IP Ns Oo \&- Ns Ar \&IP Ns Oc Ns Oo , Ns Ar \&IP Ns
+.Oo \&- Ns Ar \&IP Ns Oc Oc Ns ...
.Ed
.Pp
for example:
@@ -5319,10 +5303,7 @@ This allows the line parity to be set.
The default value is
.Ar none .
.It set phone Ar telno Ns Xo
-.Oo \&| Ns Ar backupnumber
-.Oc Ns ... Ns Oo : Ns Ar nextnumber
-.Oc Ns ...
-.Xc
+.Oo \&| Ns Ar backupnumber Oc Ns ... Ns Oo : Ns Ar nextnumber Oc Ns ... Xc
This allows the specification of the phone number to be used in
place of the \\\\T string in the dial and login chat scripts.
Multiple phone numbers may be given separated either by a pipe
@@ -5350,7 +5331,7 @@ This option configures the underlying
.Xr ng_pppoe 4
node to either standard RFC2516 PPPoE or proprietary 3Com mode.
If not set the system default will be used.
-.It set Op proc Ns Xo
+.It set Oo proc Oc Ns Xo
.No title Op Ar value
.Xc
The current process title as displayed by
@@ -5599,7 +5580,6 @@ NAS-Port-Id.
The
.Ar option Ns No s
are as follows:
-.Pp
.Bl -tag -width Ds
.It pid
PID of the corresponding tunnel.
@@ -5634,8 +5614,8 @@ If
is unspecified or zero, the default kernel controlled value is used.
.It set redial Ar secs Ns Xo
.Oo + Ns Ar inc Ns
-.Op - Ns Ar max Ns
-.Oc Ns Op . Ns Ar next
+.Oo - Ns Ar max Ns Oc Oc Ns
+.Op . Ns Ar next
.Op Ar attempts
.Xc
.Nm
@@ -5935,7 +5915,7 @@ Show the current IPCP statistics.
Show the protocol layers currently in use.
.It show lcp
Show the current LCP statistics.
-.It show Op data Ns Xo
+.It show Oo data Oc Ns Xo
.No link
.Xc
Show high level link information.
diff --git a/usr.sbin/ppp/radius.c b/usr.sbin/ppp/radius.c
index 6b1d685..dc71ab3 100644
--- a/usr.sbin/ppp/radius.c
+++ b/usr.sbin/ppp/radius.c
@@ -784,7 +784,7 @@ radius_Init(struct radius *r)
r->mppe.recvkeylen = 0;
r->mppe.sendkey = NULL;
r->mppe.sendkeylen = 0;
- *r->cfg.file = '\0';;
+ *r->cfg.file = '\0';
log_Printf(LogDEBUG, "Radius: radius_Init\n");
}
diff --git a/usr.sbin/pppctl/Makefile.depend b/usr.sbin/pppctl/Makefile.depend
new file mode 100644
index 0000000..bc668b2
--- /dev/null
+++ b/usr.sbin/pppctl/Makefile.depend
@@ -0,0 +1,23 @@
+# Autogenerated - do NOT edit!
+
+DEP_RELDIR := ${_PARSEDIR:S,${SRCTOP}/,,}
+
+DEP_MACHINE := ${.PARSEFILE:E}
+
+DIRDEPS = \
+ gnu/lib/libgcc \
+ include \
+ include/arpa \
+ include/xlocale \
+ lib/${CSU_DIR} \
+ lib/libc \
+ lib/libedit \
+ lib/libthr \
+ lib/ncurses/ncurses \
+
+
+.include <dirdeps.mk>
+
+.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+# local dependencies - needed for -jN in clean tree
+.endif
diff --git a/usr.sbin/praliases/Makefile.depend b/usr.sbin/praliases/Makefile.depend
new file mode 100644
index 0000000..fd254a5
--- /dev/null
+++ b/usr.sbin/praliases/Makefile.depend
@@ -0,0 +1,25 @@
+# Autogenerated - do NOT edit!
+
+DEP_RELDIR := ${_PARSEDIR:S,${SRCTOP}/,,}
+
+DEP_MACHINE := ${.PARSEFILE:E}
+
+DIRDEPS = \
+ gnu/lib/libgcc \
+ include \
+ include/xlocale \
+ lib/${CSU_DIR} \
+ lib/libc \
+ lib/libsm \
+ lib/libsmdb \
+ lib/libsmutil \
+ lib/libutil \
+
+
+.include <dirdeps.mk>
+
+.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+# local dependencies - needed for -jN in clean tree
+praliases.o: sm_os.h
+praliases.po: sm_os.h
+.endif
diff --git a/usr.sbin/praudit/Makefile.depend b/usr.sbin/praudit/Makefile.depend
new file mode 100644
index 0000000..1aedff5
--- /dev/null
+++ b/usr.sbin/praudit/Makefile.depend
@@ -0,0 +1,20 @@
+# Autogenerated - do NOT edit!
+
+DEP_RELDIR := ${_PARSEDIR:S,${SRCTOP}/,,}
+
+DEP_MACHINE := ${.PARSEFILE:E}
+
+DIRDEPS = \
+ gnu/lib/libgcc \
+ include \
+ include/xlocale \
+ lib/${CSU_DIR} \
+ lib/libbsm \
+ lib/libc \
+
+
+.include <dirdeps.mk>
+
+.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+# local dependencies - needed for -jN in clean tree
+.endif
diff --git a/usr.sbin/procctl/Makefile.depend b/usr.sbin/procctl/Makefile.depend
new file mode 100644
index 0000000..a839545
--- /dev/null
+++ b/usr.sbin/procctl/Makefile.depend
@@ -0,0 +1,19 @@
+# Autogenerated - do NOT edit!
+
+DEP_RELDIR := ${_PARSEDIR:S,${SRCTOP}/,,}
+
+DEP_MACHINE := ${.PARSEFILE:E}
+
+DIRDEPS = \
+ gnu/lib/libgcc \
+ include \
+ include/xlocale \
+ lib/${CSU_DIR} \
+ lib/libc \
+
+
+.include <dirdeps.mk>
+
+.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+# local dependencies - needed for -jN in clean tree
+.endif
diff --git a/usr.sbin/pstat/Makefile.depend b/usr.sbin/pstat/Makefile.depend
new file mode 100644
index 0000000..f814107
--- /dev/null
+++ b/usr.sbin/pstat/Makefile.depend
@@ -0,0 +1,21 @@
+# Autogenerated - do NOT edit!
+
+DEP_RELDIR := ${_PARSEDIR:S,${SRCTOP}/,,}
+
+DEP_MACHINE := ${.PARSEFILE:E}
+
+DIRDEPS = \
+ gnu/lib/libgcc \
+ include \
+ include/xlocale \
+ lib/${CSU_DIR} \
+ lib/libc \
+ lib/libkvm \
+ lib/libutil \
+
+
+.include <dirdeps.mk>
+
+.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+# local dependencies - needed for -jN in clean tree
+.endif
diff --git a/usr.sbin/pw/Makefile b/usr.sbin/pw/Makefile
index ae0023c..eae0b87 100644
--- a/usr.sbin/pw/Makefile
+++ b/usr.sbin/pw/Makefile
@@ -3,10 +3,10 @@
PROG= pw
MAN= pw.conf.5 pw.8
SRCS= pw.c pw_conf.c pw_user.c pw_group.c pw_log.c pw_nis.c pw_vpw.c \
- grupd.c pwupd.c fileupd.c edgroup.c psdate.c \
+ grupd.c pwupd.c fileupd.c psdate.c \
bitmap.c cpdir.c rm_r.c
-WARNS?= 1
+WARNS?= 2
DPADD= ${LIBCRYPT} ${LIBUTIL}
LDADD= -lcrypt -lutil
diff --git a/usr.sbin/pw/Makefile.depend b/usr.sbin/pw/Makefile.depend
new file mode 100644
index 0000000..cf2b455
--- /dev/null
+++ b/usr.sbin/pw/Makefile.depend
@@ -0,0 +1,21 @@
+# Autogenerated - do NOT edit!
+
+DEP_RELDIR := ${_PARSEDIR:S,${SRCTOP}/,,}
+
+DEP_MACHINE := ${.PARSEFILE:E}
+
+DIRDEPS = \
+ gnu/lib/libgcc \
+ include \
+ include/xlocale \
+ lib/${CSU_DIR} \
+ lib/libc \
+ lib/libcrypt \
+ lib/libutil \
+
+
+.include <dirdeps.mk>
+
+.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+# local dependencies - needed for -jN in clean tree
+.endif
diff --git a/usr.sbin/pw/edgroup.c b/usr.sbin/pw/edgroup.c
deleted file mode 100644
index 1cc46b4..0000000
--- a/usr.sbin/pw/edgroup.c
+++ /dev/null
@@ -1,229 +0,0 @@
-/*-
- * Copyright (C) 1996
- * David L. Nugent. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY DAVID L. NUGENT 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 DAVID L. NUGENT OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#ifndef lint
-static const char rcsid[] =
- "$FreeBSD$";
-#endif /* not lint */
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <unistd.h>
-#include <stdarg.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <pwd.h>
-#include <grp.h>
-#include <fcntl.h>
-#include <sys/param.h>
-#include <ctype.h>
-
-#include "pwupd.h"
-
-static int
-isingroup(char const * name, char **mem)
-{
- int i;
-
- for (i = 0; mem[i] != NULL; i++)
- if (strcmp(name, mem[i]) == 0)
- return i;
- return -1;
-}
-
-int
-editgroups(char *name, char **groups)
-{
- int rc = 0;
- int infd;
- char groupfile[MAXPATHLEN];
- char grouptmp[MAXPATHLEN];
-
- strncpy(groupfile, getgrpath(_GROUP), MAXPATHLEN - 5);
- groupfile[MAXPATHLEN - 5] = '\0';
- strcpy(grouptmp, groupfile);
- strcat(grouptmp, ".new");
-
- if ((infd = open(groupfile, O_RDWR | O_CREAT | O_EXLOCK, 0644)) != -1) {
- FILE *infp;
-
- if ((infp = fdopen(infd, "r+")) == NULL)
- close(infd);
- else {
- int outfd;
-
- if ((outfd = open(grouptmp, O_RDWR | O_CREAT | O_TRUNC, 0644)) != -1) {
- FILE *outfp;
-
- if ((outfp = fdopen(outfd, "w+")) == NULL)
- close(outfd);
- else {
- int linelen = PWBUFSZ;
- int outlen = PWBUFSZ;
- int memlen = 200; /* Arbitrary */
- char *line = malloc(linelen);
- char *outl = malloc(outlen);
- char **mems = malloc(memlen * sizeof(char *));
- int namlen = strlen(name);
-
- if (line == NULL || outl == NULL || mems == NULL) {
- mem_abort:
- rc = 0;
- } else {
- while (fgets(line, linelen, infp) != NULL) {
- char *p;
- int l;
-
- while ((p = strchr(line, '\n')) == NULL)
- {
- if (extendline(&line, &linelen, linelen + PWBUFSZ) == -1) {
- goto mem_abort;
- }
- l = strlen(line);
- if (fgets(line + l, linelen - l, infp) == NULL)
- break; /* No newline terminator on last line */
- }
- l = strlen(line) + namlen + 1;
- if (extendline(&outl, &outlen, l) == -1) {
- goto mem_abort;
- }
- if (*line == '#')
- strcpy(outl, line);
- else if (*line == '\n')
- *outl = '\0';
- else {
- int i,
- mno = 0;
- char *cp = line;
- char const *sep = ":\n";
- struct group grp;
-
- memset(&grp, 0, sizeof grp);
- for (i = 0; (p = strsep(&cp, sep)) != NULL; i++) {
- switch (i) {
- case 0: /* Group name */
- grp.gr_name = p;
- break;
- case 1: /* Group password */
- grp.gr_passwd = p;
- break;
- case 2: /* Group id */
- grp.gr_gid = atoi(p);
- break;
- case 3: /* Member list */
- cp = p;
- sep = ",\n";
- break;
- default: /* Individual members */
- if (*p) {
- if (extendarray(&mems, &memlen, mno + 2) == -1) {
- goto mem_abort;
- }
- mems[mno++] = p;
- }
- break;
- }
- }
- if (i < 2) /* Bail out - insufficient fields */
- continue;
-
- grp.gr_mem = mems;
- for (i = mno; i < memlen; i++)
- mems[i] = NULL;
-
- /*
- * Delete from group, or add to group?
- */
- if (groups == NULL || isingroup(grp.gr_name, groups) == -1) { /* Delete */
- int idx;
-
- while ((idx = isingroup(name, mems)) != -1) {
- for (i = idx; i < (memlen - 1); i++)
- mems[i] = mems[i + 1];
- mems[i] = NULL;
- --mno;
- }
- /*
- * Special case - deleting user and group may be user's own
- */
- if (groups == NULL && mems[0] == NULL && strcmp(name, grp.gr_name) == 0) {
- /*
- * First, make _sure_ we don't have other members
- */
- struct passwd *pwd;
-
- SETPWENT();
- while ((pwd = GETPWENT()) != NULL && (gid_t)pwd->pw_gid != (gid_t)grp.gr_gid);
- ENDPWENT();
- if (pwd == NULL) /* No members at all */
- continue; /* Drop the group */
- }
- } else if (isingroup(name, mems) == -1) {
- if (extendarray(&mems, &memlen, mno + 2) == -1) {
- goto mem_abort;
- }
- grp.gr_mem = mems; /* May have realloced() */
- mems[mno++] = name;
- mems[mno ] = NULL;
- }
- fmtgrentry(&outl, &outlen, &grp, PWF_GROUP);
- }
- fputs(outl, outfp);
- }
- if (fflush(outfp) != EOF) {
- rc = 1;
-
- /*
- * Copy data back into the original file and truncate
- */
- rewind(infp);
- rewind(outfp);
- while (fgets(outl, outlen, outfp) != NULL)
- fputs(outl, infp);
-
- /*
- * This is a gross hack, but we may have corrupted the
- * original file.
- */
- if (fflush(infp) == EOF || ferror(infp))
- rc = rename(grouptmp, groupfile) == 0;
- else
- ftruncate(infd, ftell(infp));
- }
- }
- free(mems);
- free(outl);
- free(line);
- fclose(outfp);
- }
- remove(grouptmp);
- }
- fclose(infp);
- }
- }
- return rc;
-}
diff --git a/usr.sbin/pw/fileupd.c b/usr.sbin/pw/fileupd.c
index b88f4fa..7df4bb1 100644
--- a/usr.sbin/pw/fileupd.c
+++ b/usr.sbin/pw/fileupd.c
@@ -66,138 +66,3 @@ extendarray(char ***buf, int * buflen, int needed)
}
return *buflen;
}
-
-
-int
-fileupdate(char const * filename, mode_t fmode, char const * newline, char const * prefix, int pfxlen, int updmode)
-{
- int rc = 0;
-
- if (pfxlen <= 1)
- rc = EINVAL;
- else {
- int infd = open(filename, O_RDWR | O_CREAT | O_EXLOCK, fmode);
-
- if (infd == -1)
- rc = errno;
- else {
- FILE *infp = fdopen(infd, "r+");
-
- if (infp == NULL) {
- rc = errno; /* Assumes fopen(3) sets errno from open(2) */
- close(infd);
- } else {
- int outfd;
- char file[MAXPATHLEN];
-
- strcpy(file, filename);
- strcat(file, ".new");
- outfd = open(file, O_RDWR | O_CREAT | O_TRUNC, fmode);
- if (outfd == -1)
- rc = errno;
- else {
- FILE *outfp = fdopen(outfd, "w+");
-
- if (outfp == NULL) {
- rc = errno;
- close(outfd);
- } else {
- int updated = UPD_CREATE;
- int linesize = PWBUFSZ;
- char *line = malloc(linesize);
-
- nextline:
- while (fgets(line, linesize, infp) != NULL) {
- char *p = strchr(line, '\n');
-
- while ((p = strchr(line, '\n')) == NULL) {
- int l;
- if (extendline(&line, &linesize, linesize + PWBUFSZ) == -1) {
- int ch;
- fputs(line, outfp);
- while ((ch = fgetc(infp)) != EOF) {
- fputc(ch, outfp);
- if (ch == '\n')
- break;
- }
- goto nextline;
- }
- l = strlen(line);
- if (fgets(line + l, linesize - l, infp) == NULL)
- break;
- }
- if (*line != '#' && *line != '\n') {
- if (!updated && strncmp(line, prefix, pfxlen) == 0) {
- updated = updmode == UPD_REPLACE ? UPD_REPLACE : UPD_DELETE;
-
- /*
- * Only actually write changes if updating
- */
- if (updmode == UPD_REPLACE)
- strcpy(line, newline);
- else if (updmode == UPD_DELETE)
- continue;
- }
- }
- fputs(line, outfp);
- }
-
- /*
- * Now, we need to decide what to do: If we are in
- * update mode, and no record was updated, then error If
- * we are in insert mode, and record already exists,
- * then error
- */
- if (updmode != updated)
- /* -1 return means:
- * update,delete=no user entry
- * create=entry exists
- */
- rc = -1;
- else {
-
- /*
- * If adding a new record, append it to the end
- */
- if (updmode == UPD_CREATE)
- fputs(newline, outfp);
-
- /*
- * Flush the file and check for the result
- */
- if (fflush(outfp) == EOF)
- rc = errno; /* Failed to update */
- else {
- /*
- * Copy data back into the
- * original file and truncate
- */
- rewind(infp);
- rewind(outfp);
- while (fgets(line, linesize, outfp) != NULL)
- fputs(line, infp);
-
- /*
- * If there was a problem with copying
- * we will just rename 'file.new'
- * to 'file'.
- * This is a gross hack, but we may have
- * corrupted the original file
- */
- if (fflush(infp) == EOF || ferror(infp))
- rename(file, filename);
- else
- ftruncate(infd, ftell(infp));
- }
- }
- free(line);
- fclose(outfp);
- }
- remove(file);
- }
- fclose(infp);
- }
- }
- }
- return rc;
-}
diff --git a/usr.sbin/pw/grupd.c b/usr.sbin/pw/grupd.c
index edff76d..e9f6b5e 100644
--- a/usr.sbin/pw/grupd.c
+++ b/usr.sbin/pw/grupd.c
@@ -29,6 +29,9 @@ static const char rcsid[] =
"$FreeBSD$";
#endif /* not lint */
+#include <grp.h>
+#include <libutil.h>
+#include <err.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -65,107 +68,62 @@ getgrpath(const char * file)
return pathbuf;
}
-int
-grdb(char *arg,...)
-{
- /*
- * This is a stub for now, but maybe eventually be functional
- * if ever an indexed version of /etc/groups is implemented.
- */
- arg=arg;
- return 0;
-}
-
-int
-fmtgrentry(char **buf, int * buflen, struct group * grp, int type)
+static int
+gr_update(struct group * grp, char const * group)
{
- int i, l;
-
- /*
- * Since a group line is of arbitrary length,
- * we need to calculate up-front just how long
- * it will need to be...
- */
- /* groupname : password : gid : */
- l = strlen(grp->gr_name) + 1 + strlen(grp->gr_passwd) + 1 + 5 + 1;
- /* group members + comma separator */
- for (i = 0; grp->gr_mem[i] != NULL; i++) {
- l += strlen(grp->gr_mem[i]) + 1;
- }
- l += 2; /* For newline & NUL */
- if (extendline(buf, buflen, l) == -1)
- l = -1;
- else{
- /*
- * Now we can safely format
- */
- if (type == PWF_STANDARD)
- l = sprintf(*buf, "%s:*:%ld:", grp->gr_name, (long) grp->gr_gid);
- else
- l = sprintf(*buf, "%s:%s:%ld:", grp->gr_name, grp->gr_passwd, (long) grp->gr_gid);
-
- /*
- * List members
- */
- for (i = 0; grp->gr_mem[i] != NULL; i++) {
- l += sprintf(*buf + l, "%s%s", i ? "," : "", grp->gr_mem[i]);
- }
-
- (*buf)[l++] = '\n';
- (*buf)[l] = '\0';
- }
- return l;
-}
+ int pfd, tfd;
+ struct group *gr = NULL;
+ struct group *old_gr = NULL;
+ if (grp != NULL)
+ gr = gr_dup(grp);
-int
-fmtgrent(char **buf, int * buflen, struct group * grp)
-{
- return fmtgrentry(buf, buflen, grp, PWF_STANDARD);
-}
+ if (group != NULL)
+ old_gr = GETGRNAM(group);
+ if (gr_init(grpath, NULL))
+ err(1, "gr_init()");
-static int
-gr_update(struct group * grp, char const * group, int mode)
-{
- int l;
- char pfx[64];
- int grbuflen = 0;
- char *grbuf = NULL;
-
- ENDGRENT();
- l = snprintf(pfx, sizeof pfx, "%s:", group);
-
- /*
- * Update the group file
- */
- if (grp != NULL && fmtgrentry(&grbuf, &grbuflen, grp, PWF_PASSWD) == -1)
- l = -1;
- else {
- l = fileupdate(getgrpath(_GROUP), 0644, grbuf, pfx, l, mode);
- if (l == 0)
- l = grdb(NULL);
+ if ((pfd = gr_lock()) == -1) {
+ gr_fini();
+ err(1, "gr_lock()");
+ }
+ if ((tfd = gr_tmp(-1)) == -1) {
+ gr_fini();
+ err(1, "gr_tmp()");
}
- if (grbuf != NULL)
- free(grbuf);
- return l;
+ if (gr_copy(pfd, tfd, gr, old_gr) == -1) {
+ gr_fini();
+ err(1, "gr_copy()");
+ }
+ if (gr_mkdb() == -1) {
+ gr_fini();
+ err(1, "gr_mkdb()");
+ }
+ free(gr);
+ gr_fini();
+ return 0;
}
int
addgrent(struct group * grp)
{
- return gr_update(grp, grp->gr_name, UPD_CREATE);
+ return gr_update(grp, NULL);
}
int
chggrent(char const * login, struct group * grp)
{
- return gr_update(grp, login, UPD_REPLACE);
+ return gr_update(grp, login);
}
int
delgrent(struct group * grp)
{
- return gr_update(NULL, grp->gr_name, UPD_DELETE);
+ char group[MAXLOGNAME];
+
+ strlcpy(group, grp->gr_name, MAXLOGNAME);
+
+ return gr_update(NULL, group);
}
diff --git a/usr.sbin/pw/pw.8 b/usr.sbin/pw/pw.8
index 8b21107..076f2eb 100644
--- a/usr.sbin/pw/pw.8
+++ b/usr.sbin/pw/pw.8
@@ -24,7 +24,7 @@
.\"
.\" $FreeBSD$
.\"
-.Dd December 21, 2011
+.Dd October 29, 2012
.Dt PW 8
.Os
.Sh NAME
@@ -904,12 +904,6 @@ A Version 7 format password file
The user capabilities database
.It Pa /etc/group
The group database
-.It Pa /etc/master.passwd.new
-Temporary copy of the master password file
-.It Pa /etc/passwd.new
-Temporary copy of the Version 7 password file
-.It Pa /etc/group.new
-Temporary copy of the group file
.It Pa /etc/pw.conf
Pw default options file
.It Pa /var/log/userlog
diff --git a/usr.sbin/pw/pw.c b/usr.sbin/pw/pw.c
index e9d9363..b0ac728 100644
--- a/usr.sbin/pw/pw.c
+++ b/usr.sbin/pw/pw.c
@@ -62,13 +62,11 @@ struct pwf PWF =
getpwent,
getpwuid,
getpwnam,
- pwdb,
setgrent,
endgrent,
getgrent,
getgrgid,
getgrnam,
- grdb
};
struct pwf VPWF =
@@ -79,13 +77,11 @@ struct pwf VPWF =
vgetpwent,
vgetpwuid,
vgetpwnam,
- vpwdb,
vsetgrent,
vendgrent,
vgetgrent,
vgetgrgid,
vgetgrnam,
- vgrdb
};
static struct cargs arglist;
diff --git a/usr.sbin/pw/pw.h b/usr.sbin/pw/pw.h
index 6e521d1..1ff69a6 100644
--- a/usr.sbin/pw/pw.h
+++ b/usr.sbin/pw/pw.h
@@ -109,19 +109,10 @@ int pw_user(struct userconf * cnf, int mode, struct cargs * _args);
int pw_group(struct userconf * cnf, int mode, struct cargs * _args);
char *pw_checkname(u_char *name, int gecos);
-int addpwent(struct passwd * pwd);
-int delpwent(struct passwd * pwd);
-int chgpwent(char const * login, struct passwd * pwd);
-int fmtpwent(char *buf, struct passwd * pwd);
-
int addnispwent(const char *path, struct passwd *pwd);
int delnispwent(const char *path, const char *login);
int chgnispwent(const char *path, const char *login, struct passwd *pwd);
-int addgrent(struct group * grp);
-int delgrent(struct group * grp);
-int chggrent(char const * login, struct group * grp);
-
int boolean_val(char const * str, int dflt);
char const *boolean_str(int val);
char *newstr(char const * p);
diff --git a/usr.sbin/pw/pw_group.c b/usr.sbin/pw/pw_group.c
index a8f182c..f4f2116 100644
--- a/usr.sbin/pw/pw_group.c
+++ b/usr.sbin/pw/pw_group.c
@@ -34,6 +34,8 @@ static const char rcsid[] =
#include <termios.h>
#include <stdbool.h>
#include <unistd.h>
+#include <grp.h>
+#include <libutil.h>
#include "pw.h"
#include "bitmap.h"
@@ -403,10 +405,9 @@ static int
print_group(struct group * grp, int pretty)
{
if (!pretty) {
- int buflen = 0;
char *buf = NULL;
- fmtgrent(&buf, &buflen, grp);
+ buf = gr_make(grp);
fputs(buf, stdout);
free(buf);
} else {
diff --git a/usr.sbin/pw/pw_log.c b/usr.sbin/pw/pw_log.c
index fc85828..f16274f 100644
--- a/usr.sbin/pw/pw_log.c
+++ b/usr.sbin/pw/pw_log.c
@@ -51,7 +51,7 @@ pw_log(struct userconf * cnf, int mode, int which, char const * fmt,...)
time_t now = time(NULL);
struct tm *t = localtime(&now);
char nfmt[256];
- char *name;
+ const char *name;
if ((name = getenv("LOGNAME")) == NULL && (name = getenv("USER")) == NULL)
name = "unknown";
diff --git a/usr.sbin/pw/pw_nis.c b/usr.sbin/pw/pw_nis.c
index 74a3ed0..af5901a 100644
--- a/usr.sbin/pw/pw_nis.c
+++ b/usr.sbin/pw/pw_nis.c
@@ -33,40 +33,62 @@ static const char rcsid[] =
#include <stdlib.h>
#include <string.h>
#include <sys/types.h>
+#include <err.h>
+#include <pwd.h>
+#include <libutil.h>
#include "pw.h"
static int
-pw_nisupdate(const char * path, struct passwd * pwd, char const * user, int mode)
+pw_nisupdate(const char * path, struct passwd * pwd, char const * user)
{
- char pfx[32];
- char pwbuf[PWBUFSZ];
- int l = sprintf(pfx, "%s:", user);
+ int pfd, tfd;
+ struct passwd *pw = NULL;
+ struct passwd *old_pw = NULL;
- /*
- * Update the passwd file first
- */
- if (pwd == NULL)
- *pwbuf = '\0';
- else
- fmtpwentry(pwbuf, pwd, PWF_MASTER);
- return fileupdate(path, 0600, pwbuf, pfx, l, mode) != 0;
+ if (pwd != NULL)
+ pw = pw_dup(pwd);
+
+ if (user != NULL)
+ old_pw = GETPWNAM(user);
+
+ if (pw_init(NULL, path))
+ err(1,"pw_init()");
+ if ((pfd = pw_lock()) == -1) {
+ pw_fini();
+ err(1, "pw_lock()");
+ }
+ if ((tfd = pw_tmp(-1)) == -1) {
+ pw_fini();
+ err(1, "pw_tmp()");
+ }
+ if (pw_copy(pfd, tfd, pw, old_pw) == -1) {
+ pw_fini();
+ err(1, "pw_copy()");
+ }
+ if (rename(pw_tempname(), path) == -1)
+ err(1, "rename()");
+
+ free(pw);
+ pw_fini();
+
+ return (0);
}
int
addnispwent(const char *path, struct passwd * pwd)
{
- return pw_nisupdate(path, pwd, pwd->pw_name, UPD_CREATE);
+ return pw_nisupdate(path, pwd, NULL);
}
int
chgnispwent(const char *path, char const * login, struct passwd * pwd)
{
- return pw_nisupdate(path, pwd, login, UPD_REPLACE);
+ return pw_nisupdate(path, pwd, login);
}
int
delnispwent(const char *path, const char *login)
{
- return pw_nisupdate(path, NULL, login, UPD_DELETE);
+ return pw_nisupdate(path, NULL, login);
}
diff --git a/usr.sbin/pw/pw_user.c b/usr.sbin/pw/pw_user.c
index b59789c..abf1c35 100644
--- a/usr.sbin/pw/pw_user.c
+++ b/usr.sbin/pw/pw_user.c
@@ -42,6 +42,9 @@ static const char rcsid[] =
#include <sys/resource.h>
#include <unistd.h>
#include <login_cap.h>
+#include <pwd.h>
+#include <grp.h>
+#include <libutil.h>
#include "pw.h"
#include "bitmap.h"
@@ -292,7 +295,6 @@ pw_user(struct userconf * cnf, int mode, struct cargs * args)
if (mode == M_PRINT && getarg(args, 'a')) {
int pretty = getarg(args, 'P') != NULL;
int v7 = getarg(args, '7') != NULL;
-
SETPWENT();
while ((pwd = GETPWENT()) != NULL)
print_user(pwd, pretty, v7);
@@ -315,7 +317,7 @@ pw_user(struct userconf * cnf, int mode, struct cargs * args)
*/
if (mode != M_ADD && pwd == NULL
&& strspn(a_name->val, "0123456789") == strlen(a_name->val)
- && atoi(a_name->val) > 0) { /* Assume uid */
+ && *a_name->val) {
(a_uid = a_name)->ch = 'u';
a_name = NULL;
}
@@ -422,7 +424,24 @@ pw_user(struct userconf * cnf, int mode, struct cargs * args)
/* non-fatal */
}
- editgroups(a_name->val, NULL);
+ grp = GETGRNAM(a_name->val);
+ if (*grp->gr_mem == NULL)
+ delgrent(GETGRNAM(a_name->val));
+ SETGRENT();
+ while ((grp = GETGRENT()) != NULL) {
+ int i;
+ char group[MAXLOGNAME];
+ for (i = 0; grp->gr_mem[i] != NULL; i++) {
+ if (!strcmp(grp->gr_mem[i], a_name->val)) {
+ while (grp->gr_mem[i] != NULL) {
+ grp->gr_mem[i] = grp->gr_mem[i+1];
+ }
+ strlcpy(group, grp->gr_name, MAXLOGNAME);
+ chggrent(group, grp);
+ }
+ }
+ }
+ ENDGRENT();
pw_log(cnf, mode, W_USER, "%s(%ld) account removed", a_name->val, (long) uid);
@@ -725,8 +744,29 @@ pw_user(struct userconf * cnf, int mode, struct cargs * args)
* Ok, user is created or changed - now edit group file
*/
- if (mode == M_ADD || getarg(args, 'G') != NULL)
- editgroups(pwd->pw_name, cnf->groups);
+ if (mode == M_ADD || getarg(args, 'G') != NULL) {
+ int i, j;
+ 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 */
+ 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);
+ }
+ }
+
/* go get a current version of pwd */
pwd = GETPWNAM(a_name->val);
@@ -1090,10 +1130,14 @@ static int
print_user(struct passwd * pwd, int pretty, int v7)
{
if (!pretty) {
- char buf[_UC_MAXLINE];
+ char *buf;
+
+ if (!v7)
+ pwd->pw_passwd = (pwd->pw_passwd == NULL) ? "" : "*";
- fmtpwentry(buf, pwd, v7 ? PWF_PASSWD : PWF_STANDARD);
- fputs(buf, stdout);
+ buf = v7 ? pw_make_v7(pwd) : pw_make(pwd);
+ printf("%s\n", buf);
+ free(buf);
} else {
int j;
char *p;
diff --git a/usr.sbin/pw/pw_vpw.c b/usr.sbin/pw/pw_vpw.c
index 473cbb6..674b64f 100644
--- a/usr.sbin/pw/pw_vpw.c
+++ b/usr.sbin/pw/pw_vpw.c
@@ -170,13 +170,6 @@ vgetpwnam(const char * nam)
return vnextpwent(nam, -1, 1);
}
-int vpwdb(char *arg, ...)
-{
- arg=arg;
- return 0;
-}
-
-
static FILE * grp_fp = NULL;
@@ -221,7 +214,7 @@ vnextgrent(char const * nam, gid_t gid, int doclose)
int i, quickout = 0;
int mno = 0;
char * q, * p;
- char * sep = ":\n";
+ const char * sep = ":\n";
if ((p = strchr(grtmp, '\n')) == NULL) {
int l;
@@ -307,10 +300,3 @@ vgetgrnam(const char * nam)
return vnextgrent(nam, -1, 1);
}
-int
-vgrdb(char *arg, ...)
-{
- arg=arg;
- return 0;
-}
-
diff --git a/usr.sbin/pw/pwupd.c b/usr.sbin/pw/pwupd.c
index cb8456d..4ab0f01 100644
--- a/usr.sbin/pw/pwupd.c
+++ b/usr.sbin/pw/pwupd.c
@@ -34,7 +34,10 @@ static const char rcsid[] =
#include <string.h>
#include <unistd.h>
#include <stdarg.h>
+#include <pwd.h>
+#include <libutil.h>
#include <errno.h>
+#include <err.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/param.h>
@@ -71,7 +74,7 @@ getpwpath(char const * file)
return pathbuf;
}
-int
+static int
pwdb(char *arg,...)
{
int i = 0;
@@ -102,47 +105,15 @@ pwdb(char *arg,...)
if (WEXITSTATUS(i))
i = EIO;
}
+ va_end(ap);
return i;
}
-int
-fmtpwentry(char *buf, struct passwd * pwd, int type)
-{
- int l;
- char *pw;
-
- pw = (type == PWF_MASTER) ?
- ((pwd->pw_passwd == NULL) ? "" : pwd->pw_passwd) : "*";
-
- if (type == PWF_PASSWD)
- l = sprintf(buf, "%s:*:%ld:%ld:%s:%s:%s\n",
- pwd->pw_name, (long) pwd->pw_uid, (long) pwd->pw_gid,
- pwd->pw_gecos ? pwd->pw_gecos : "User &",
- pwd->pw_dir, pwd->pw_shell);
- else
- l = sprintf(buf, "%s:%s:%ld:%ld:%s:%lu:%lu:%s:%s:%s\n",
- pwd->pw_name, pw, (long) pwd->pw_uid, (long) pwd->pw_gid,
- pwd->pw_class ? pwd->pw_class : "",
- (unsigned long) pwd->pw_change,
- (unsigned long) pwd->pw_expire,
- pwd->pw_gecos, pwd->pw_dir, pwd->pw_shell);
- return l;
-}
-
-
-int
-fmtpwent(char *buf, struct passwd * pwd)
-{
- return fmtpwentry(buf, pwd, PWF_STANDARD);
-}
-
static int
-pw_update(struct passwd * pwd, char const * user, int mode)
+pw_update(struct passwd * pwd, char const * user)
{
int rc = 0;
- ENDPWENT();
-
/*
* First, let's check the see if the database is alright
* Note: -C is only available in FreeBSD 2.2 and above
@@ -153,61 +124,57 @@ pw_update(struct passwd * pwd, char const * user, int mode)
#else
{ /* No -C */
#endif
- char pfx[PWBUFSZ];
- char pwbuf[PWBUFSZ];
- int l = snprintf(pfx, PWBUFSZ, "%s:", user);
-#ifdef HAVE_PWDB_U
- int isrename = pwd!=NULL && strcmp(user, pwd->pw_name);
-#endif
+ int pfd, tfd;
+ struct passwd *pw = NULL;
+ struct passwd *old_pw = NULL;
- /*
- * Update the passwd file first
- */
- if (pwd == NULL)
- *pwbuf = '\0';
- else
- fmtpwentry(pwbuf, pwd, PWF_PASSWD);
-
- if (l < 0)
- l = 0;
- rc = fileupdate(getpwpath(_PASSWD), 0644, pwbuf, pfx, l, mode);
- if (rc == 0) {
-
- /*
- * Then the master.passwd file
- */
- if (pwd != NULL)
- fmtpwentry(pwbuf, pwd, PWF_MASTER);
- rc = fileupdate(getpwpath(_MASTERPASSWD), 0600, pwbuf, pfx, l, mode);
- if (rc == 0) {
-#ifdef HAVE_PWDB_U
- if (mode == UPD_DELETE || isrename)
-#endif
- rc = pwdb(NULL);
-#ifdef HAVE_PWDB_U
- else
- rc = pwdb("-u", user, (char *)NULL);
-#endif
- }
+ if (pwd != NULL)
+ pw = pw_dup(pwd);
+
+ if (user != NULL)
+ old_pw = GETPWNAM(user);
+
+ if (pw_init(pwpath, NULL))
+ err(1, "pw_init()");
+ if ((pfd = pw_lock()) == -1) {
+ pw_fini();
+ err(1, "pw_lock()");
+ }
+ if ((tfd = pw_tmp(-1)) == -1) {
+ pw_fini();
+ err(1, "pw_tmp()");
+ }
+ if (pw_copy(pfd, tfd, pw, old_pw) == -1) {
+ pw_fini();
+ err(1, "pw_copy()");
}
+ if (pw_mkdb(user) == -1) {
+ pw_fini();
+ err(1, "pw_mkdb()");
+ }
+ free(pw);
+ pw_fini();
}
- return rc;
+ return 0;
}
int
addpwent(struct passwd * pwd)
{
- return pw_update(pwd, pwd->pw_name, UPD_CREATE);
+ return pw_update(pwd, NULL);
}
int
chgpwent(char const * login, struct passwd * pwd)
{
- return pw_update(pwd, login, UPD_REPLACE);
+ return pw_update(pwd, login);
}
int
delpwent(struct passwd * pwd)
{
- return pw_update(NULL, pwd->pw_name, UPD_DELETE);
+ char login[MAXLOGNAME];
+
+ strlcpy(login, pwd->pw_name, MAXLOGNAME);
+ return pw_update(NULL, login);
}
diff --git a/usr.sbin/pw/pwupd.h b/usr.sbin/pw/pwupd.h
index 7289065..200ffee 100644
--- a/usr.sbin/pw/pwupd.h
+++ b/usr.sbin/pw/pwupd.h
@@ -41,25 +41,6 @@
#define RET_SETGRENT void
#endif
-enum updtype
-{
- UPD_DELETE = -1,
- UPD_CREATE = 0,
- UPD_REPLACE = 1
-};
-
-__BEGIN_DECLS
-int fileupdate(char const * fname, mode_t fm, char const * nline, char const * pfx, int pfxlen, int updmode);
-__END_DECLS
-
-enum pwdfmttype
-{
- PWF_STANDARD, /* MASTER format but with '*' as password */
- PWF_PASSWD, /* V7 format */
- PWF_GROUP = PWF_PASSWD,
- PWF_MASTER /* MASTER format with password */
-};
-
struct pwf
{
int _altdir;
@@ -68,13 +49,11 @@ struct pwf
struct passwd * (*_getpwent)(void);
struct passwd * (*_getpwuid)(uid_t uid);
struct passwd * (*_getpwnam)(const char * nam);
- int (*_pwdb)(char *arg, ...);
RET_SETGRENT (*_setgrent)(void);
void (*_endgrent)(void);
struct group * (*_getgrent)(void);
struct group * (*_getgrgid)(gid_t gid);
struct group * (*_getgrnam)(const char * nam);
- int (*_grdb)(char *arg, ...);
};
extern struct pwf PWF;
@@ -85,14 +64,12 @@ extern struct pwf VPWF;
#define GETPWENT() PWF._getpwent()
#define GETPWUID(uid) PWF._getpwuid(uid)
#define GETPWNAM(nam) PWF._getpwnam(nam)
-#define PWDB(args) PWF._pwdb(args)
#define SETGRENT() PWF._setgrent()
#define ENDGRENT() PWF._endgrent()
#define GETGRENT() PWF._getgrent()
#define GETGRGID(gid) PWF._getgrgid(gid)
#define GETGRNAM(nam) PWF._getgrnam(nam)
-#define GRDB(args) PWF._grdb(args)
#define PWALTDIR() PWF._altdir
#ifndef _PATH_PWD
@@ -101,51 +78,35 @@ extern struct pwf VPWF;
#ifndef _GROUP
#define _GROUP "group"
#endif
-#ifndef _PASSWD
-#define _PASSWD "passwd"
-#endif
#ifndef _MASTERPASSWD
#define _MASTERPASSWD "master.passwd"
#endif
-#ifndef _GROUP
-#define _GROUP "group"
-#endif
__BEGIN_DECLS
int addpwent(struct passwd * pwd);
int delpwent(struct passwd * pwd);
int chgpwent(char const * login, struct passwd * pwd);
-int fmtpwent(char *buf, struct passwd * pwd);
-int fmtpwentry(char *buf, struct passwd * pwd, int type);
int setpwdir(const char * dir);
char * getpwpath(char const * file);
-int pwdb(char *arg, ...);
int addgrent(struct group * grp);
int delgrent(struct group * grp);
int chggrent(char const * name, struct group * grp);
-int fmtgrent(char **buf, int * buflen, struct group * grp);
-int fmtgrentry(char **buf, int * buflen, struct group * grp, int type);
int editgroups(char *name, char **groups);
int setgrdir(const char * dir);
char * getgrpath(const char *file);
-int grdb(char *arg, ...);
void vsetpwent(void);
void vendpwent(void);
struct passwd * vgetpwent(void);
struct passwd * vgetpwuid(uid_t uid);
struct passwd * vgetpwnam(const char * nam);
-struct passwd * vgetpwent(void);
-int vpwdb(char *arg, ...);
struct group * vgetgrent(void);
struct group * vgetgrgid(gid_t gid);
struct group * vgetgrnam(const char * nam);
-struct group * vgetgrent(void);
-int vgrdb(char *arg, ...);
RET_SETGRENT vsetgrent(void);
void vendgrent(void);
diff --git a/usr.sbin/pwd_mkdb/Makefile.depend b/usr.sbin/pwd_mkdb/Makefile.depend
new file mode 100644
index 0000000..16b5e42
--- /dev/null
+++ b/usr.sbin/pwd_mkdb/Makefile.depend
@@ -0,0 +1,20 @@
+# Autogenerated - do NOT edit!
+
+DEP_RELDIR := ${_PARSEDIR:S,${SRCTOP}/,,}
+
+DEP_MACHINE := ${.PARSEFILE:E}
+
+DIRDEPS = \
+ gnu/lib/libgcc \
+ include \
+ include/arpa \
+ include/xlocale \
+ lib/${CSU_DIR} \
+ lib/libc \
+
+
+.include <dirdeps.mk>
+
+.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+# local dependencies - needed for -jN in clean tree
+.endif
diff --git a/usr.sbin/quot/Makefile.depend b/usr.sbin/quot/Makefile.depend
new file mode 100644
index 0000000..a839545
--- /dev/null
+++ b/usr.sbin/quot/Makefile.depend
@@ -0,0 +1,19 @@
+# Autogenerated - do NOT edit!
+
+DEP_RELDIR := ${_PARSEDIR:S,${SRCTOP}/,,}
+
+DEP_MACHINE := ${.PARSEFILE:E}
+
+DIRDEPS = \
+ gnu/lib/libgcc \
+ include \
+ include/xlocale \
+ lib/${CSU_DIR} \
+ lib/libc \
+
+
+.include <dirdeps.mk>
+
+.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+# local dependencies - needed for -jN in clean tree
+.endif
diff --git a/usr.sbin/quot/quot.c b/usr.sbin/quot/quot.c
index 979eef4..ac90da6 100644
--- a/usr.sbin/quot/quot.c
+++ b/usr.sbin/quot/quot.c
@@ -484,8 +484,8 @@ static void
donames(int fd, struct fs *super, char *name)
{
int c;
- ino_t inode;
ino_t maxino;
+ uintmax_t inode;
union dinode *dp;
maxino = super->fs_ncg * super->fs_ipg - 1;
@@ -493,9 +493,9 @@ donames(int fd, struct fs *super, char *name)
while ((c = getchar()) != EOF && (c < '0' || c > '9'))
while ((c = getchar()) != EOF && c != '\n');
ungetc(c,stdin);
- while (scanf("%u",&inode) == 1) {
+ while (scanf("%ju", &inode) == 1) {
if (inode > maxino) {
- warnx("illegal inode %d",inode);
+ warnx("illegal inode %ju", inode);
return;
}
errno = 0;
diff --git a/usr.sbin/quotaon/Makefile.depend b/usr.sbin/quotaon/Makefile.depend
new file mode 100644
index 0000000..2dd29af
--- /dev/null
+++ b/usr.sbin/quotaon/Makefile.depend
@@ -0,0 +1,20 @@
+# Autogenerated - do NOT edit!
+
+DEP_RELDIR := ${_PARSEDIR:S,${SRCTOP}/,,}
+
+DEP_MACHINE := ${.PARSEFILE:E}
+
+DIRDEPS = \
+ gnu/lib/libgcc \
+ include \
+ include/xlocale \
+ lib/${CSU_DIR} \
+ lib/libc \
+ lib/libutil \
+
+
+.include <dirdeps.mk>
+
+.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+# local dependencies - needed for -jN in clean tree
+.endif
diff --git a/usr.sbin/quotaon/quotaon.c b/usr.sbin/quotaon/quotaon.c
index 8d52983..740df39 100644
--- a/usr.sbin/quotaon/quotaon.c
+++ b/usr.sbin/quotaon/quotaon.c
@@ -59,16 +59,15 @@ __FBSDID("$FreeBSD$");
#include <string.h>
#include <unistd.h>
-const char *qfname = QUOTAFILENAME;
-const char *qfextension[] = INITQFNAMES;
+static const char *qfextension[] = INITQFNAMES;
-int aflag; /* all filesystems */
-int gflag; /* operate on group quotas */
-int uflag; /* operate on user quotas */
-int vflag; /* verbose */
+static int aflag; /* all filesystems */
+static int gflag; /* operate on group quotas */
+static int uflag; /* operate on user quotas */
+static int vflag; /* verbose */
-int oneof(char *, char *[], int);
-int quotaonoff(struct fstab *fs, int, int);
+static int oneof(char *, char *[], int);
+static int quotaonoff(struct fstab *fs, int, int);
static void usage(void);
int
@@ -150,7 +149,7 @@ usage(void)
exit(1);
}
-int
+static int
quotaonoff(struct fstab *fs, int offmode, int type)
{
struct quotafile *qf;
@@ -181,7 +180,7 @@ quotaonoff(struct fstab *fs, int offmode, int type)
/*
* Check to see if target appears in list of size cnt.
*/
-int
+static int
oneof(char *target, char *list[], int cnt)
{
int i;
diff --git a/usr.sbin/rarpd/Makefile b/usr.sbin/rarpd/Makefile
index 7f34457..52a9f92 100644
--- a/usr.sbin/rarpd/Makefile
+++ b/usr.sbin/rarpd/Makefile
@@ -4,6 +4,9 @@
PROG= rarpd
MAN= rarpd.8
+DPADD= ${LIBUTIL}
+LDADD= -lutil
+
WARNS?= 3
# This breaks with format strings returned by expand_syslog_m().. argh!
#FORMAT_AUDIT?= 1
diff --git a/usr.sbin/rarpd/Makefile.depend b/usr.sbin/rarpd/Makefile.depend
new file mode 100644
index 0000000..16b5e42
--- /dev/null
+++ b/usr.sbin/rarpd/Makefile.depend
@@ -0,0 +1,20 @@
+# Autogenerated - do NOT edit!
+
+DEP_RELDIR := ${_PARSEDIR:S,${SRCTOP}/,,}
+
+DEP_MACHINE := ${.PARSEFILE:E}
+
+DIRDEPS = \
+ gnu/lib/libgcc \
+ include \
+ include/arpa \
+ include/xlocale \
+ lib/${CSU_DIR} \
+ lib/libc \
+
+
+.include <dirdeps.mk>
+
+.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+# local dependencies - needed for -jN in clean tree
+.endif
diff --git a/usr.sbin/rarpd/rarpd.8 b/usr.sbin/rarpd/rarpd.8
index 8552b69..3c75de0 100644
--- a/usr.sbin/rarpd/rarpd.8
+++ b/usr.sbin/rarpd/rarpd.8
@@ -16,7 +16,7 @@
.\"
.\" $FreeBSD$
.\"
-.Dd November 16, 2001
+.Dd July 9, 2012
.Dt RARPD 8
.Os
.Sh NAME
@@ -27,9 +27,11 @@
.Fl a
.Op Fl dfsv
.Op Fl t Ar directory
+.Op Fl P Ar pidfile
.Nm
.Op Fl dfsv
.Op Fl t Ar directory
+.Op Fl P Ar pidfile
.Ar interface
.Sh DESCRIPTION
The
@@ -92,6 +94,15 @@ instead of via
.Xr syslog 3 .
.It Fl f
Run in the foreground.
+.It Fl P
+Specify the pathname of the PID file.
+If not specified,
+.Pa /var/run/rarpd.pid
+or
+.Pa /var/run/rarpd.ifname.pid
+will be used depending on the
+.Fl a
+flag or the specified interface name.
.It Fl s
Supply a response to any RARP request for which an ethernet to IP address
mapping exists; do not depend on the existence of
@@ -115,6 +126,7 @@ Enable verbose syslogging.
.It Pa /etc/ethers
.It Pa /etc/hosts
.It Pa /tftpboot
+.It Pa /var/run/rarpd.pid
.El
.Sh SEE ALSO
.Xr bpf 4
diff --git a/usr.sbin/rarpd/rarpd.c b/usr.sbin/rarpd/rarpd.c
index 25d98c6..f10a7da 100644
--- a/usr.sbin/rarpd/rarpd.c
+++ b/usr.sbin/rarpd/rarpd.c
@@ -27,8 +27,8 @@ __FBSDID("$FreeBSD$");
/*
* rarpd - Reverse ARP Daemon
*
- * Usage: rarpd -a [-dfsv] [-t directory] [hostname]
- * rarpd [-dfsv] [-t directory] interface [hostname]
+ * Usage: rarpd -a [-dfsv] [-t directory] [-P pidfile] [hostname]
+ * rarpd [-dfsv] [-t directory] [-P pidfile] interface [hostname]
*
* 'hostname' is optional solely for backwards compatibility with Sun's rarpd.
* Currently, the argument is ignored.
@@ -61,6 +61,7 @@ __FBSDID("$FreeBSD$");
#include <syslog.h>
#include <stdlib.h>
#include <unistd.h>
+#include <libutil.h>
/* Cast a struct sockaddr to a struct sockaddr_in */
#define SATOSIN(sa) ((struct sockaddr_in *)(sa))
@@ -99,6 +100,11 @@ int sflag; /* ignore /tftpboot */
static u_char zero[6];
+static char pidfile_buf[PATH_MAX];
+static char *pidfile;
+#define RARPD_PIDFILE "/var/run/rarpd.%s.pid"
+static struct pidfh *pidfile_fh;
+
static int bpf_open(void);
static in_addr_t choose_ipaddr(in_addr_t **, in_addr_t, in_addr_t);
static char *eatoa(u_char *);
@@ -140,7 +146,7 @@ main(int argc, char *argv[])
openlog(name, LOG_PID | LOG_CONS, LOG_DAEMON);
opterr = 0;
- while ((op = getopt(argc, argv, "adfst:v")) != -1)
+ while ((op = getopt(argc, argv, "adfsP:t:v")) != -1)
switch (op) {
case 'a':
++aflag;
@@ -158,6 +164,12 @@ main(int argc, char *argv[])
++sflag;
break;
+ case 'P':
+ strncpy(pidfile_buf, optarg, sizeof(pidfile_buf) - 1);
+ pidfile_buf[sizeof(pidfile_buf) - 1] = '\0';
+ pidfile = pidfile_buf;
+ break;
+
case 't':
tftp_dir = optarg;
break;
@@ -181,10 +193,23 @@ main(int argc, char *argv[])
init(ifname);
if (!fflag) {
+ if (pidfile == NULL && ifname != NULL && aflag == 0) {
+ snprintf(pidfile_buf, sizeof(pidfile_buf) - 1,
+ RARPD_PIDFILE, ifname);
+ pidfile_buf[sizeof(pidfile_buf) - 1] = '\0';
+ pidfile = pidfile_buf;
+ }
+ /* If pidfile == NULL, /var/run/<progname>.pid will be used. */
+ pidfile_fh = pidfile_open(pidfile, 0600, NULL);
+ if (pidfile_fh == NULL)
+ logmsg(LOG_ERR, "Cannot open or create pidfile: %s",
+ (pidfile == NULL) ? "/var/run/rarpd.pid" : pidfile);
if (daemon(0,0)) {
logmsg(LOG_ERR, "cannot fork");
+ pidfile_remove(pidfile_fh);
exit(1);
}
+ pidfile_write(pidfile_fh);
}
rarp_loop();
return(0);
@@ -234,6 +259,7 @@ init_one(struct ifaddrs *ifa, char *target, int pass1)
ii = (struct if_info *)malloc(sizeof(*ii));
if (ii == NULL) {
logmsg(LOG_ERR, "malloc: %m");
+ pidfile_remove(pidfile_fh);
exit(1);
}
bzero(ii, sizeof(*ii));
@@ -251,6 +277,7 @@ init_one(struct ifaddrs *ifa, char *target, int pass1)
ii2 = (struct if_info *)malloc(sizeof(*ii2));
if (ii2 == NULL) {
logmsg(LOG_ERR, "malloc: %m");
+ pidfile_remove(pidfile_fh);
exit(1);
}
memcpy(ii2, ii, sizeof(*ii2));
@@ -273,8 +300,11 @@ init_one(struct ifaddrs *ifa, char *target, int pass1)
case AF_LINK:
ll = (struct sockaddr_dl *)ifa->ifa_addr;
- if (ll->sdl_type == IFT_ETHER)
+ switch (ll->sdl_type) {
+ case IFT_ETHER:
+ case IFT_L2VLAN:
bcopy(LLADDR(ll), ii->ii_eaddr, 6);
+ }
break;
}
}
@@ -293,6 +323,7 @@ init(char *target)
error = getifaddrs(&ifhead);
if (error) {
logmsg(LOG_ERR, "getifaddrs: %m");
+ pidfile_remove(pidfile_fh);
exit(1);
}
/*
@@ -339,8 +370,8 @@ static void
usage(void)
{
(void)fprintf(stderr, "%s\n%s\n",
- "usage: rarpd -a [-dfsv] [-t directory]",
- " rarpd [-dfsv] [-t directory] interface");
+ "usage: rarpd -a [-dfsv] [-t directory] [-P pidfile]",
+ " rarpd [-dfsv] [-t directory] [-P pidfile] interface");
exit(1);
}
@@ -361,6 +392,7 @@ bpf_open(void)
if (fd == -1) {
logmsg(LOG_ERR, "%s: %m", device);
+ pidfile_remove(pidfile_fh);
exit(1);
}
return fd;
@@ -399,12 +431,12 @@ rarp_open(char *device)
immediate = 1;
if (ioctl(fd, BIOCIMMEDIATE, &immediate) == -1) {
logmsg(LOG_ERR, "BIOCIMMEDIATE: %m");
- exit(1);
+ goto rarp_open_err;
}
strlcpy(ifr.ifr_name, device, sizeof(ifr.ifr_name));
if (ioctl(fd, BIOCSETIF, (caddr_t)&ifr) == -1) {
logmsg(LOG_ERR, "BIOCSETIF: %m");
- exit(1);
+ goto rarp_open_err;
}
/*
* Check that the data link layer is an Ethernet; this code won't
@@ -412,20 +444,24 @@ rarp_open(char *device)
*/
if (ioctl(fd, BIOCGDLT, (caddr_t)&dlt) == -1) {
logmsg(LOG_ERR, "BIOCGDLT: %m");
- exit(1);
+ goto rarp_open_err;
}
if (dlt != DLT_EN10MB) {
logmsg(LOG_ERR, "%s is not an ethernet", device);
- exit(1);
+ goto rarp_open_err;
}
/*
* Set filter program.
*/
if (ioctl(fd, BIOCSETF, (caddr_t)&filter) == -1) {
logmsg(LOG_ERR, "BIOCSETF: %m");
- exit(1);
+ goto rarp_open_err;
}
return fd;
+
+rarp_open_err:
+ pidfile_remove(pidfile_fh);
+ exit(1);
}
/*
@@ -480,16 +516,16 @@ rarp_loop(void)
if (iflist == NULL) {
logmsg(LOG_ERR, "no interfaces");
- exit(1);
+ goto rarpd_loop_err;
}
if (ioctl(iflist->ii_fd, BIOCGBLEN, (caddr_t)&bufsize) == -1) {
logmsg(LOG_ERR, "BIOCGBLEN: %m");
- exit(1);
+ goto rarpd_loop_err;
}
buf = malloc(bufsize);
if (buf == NULL) {
logmsg(LOG_ERR, "malloc: %m");
- exit(1);
+ goto rarpd_loop_err;
}
while (1) {
@@ -509,7 +545,7 @@ rarp_loop(void)
if (errno == EINTR)
continue;
logmsg(LOG_ERR, "select: %m");
- exit(1);
+ goto rarpd_loop_err;
}
for (ii = iflist; ii != NULL; ii = ii->ii_next) {
fd = ii->ii_fd;
@@ -537,6 +573,11 @@ rarp_loop(void)
}
}
#undef bhp
+ return;
+
+rarpd_loop_err:
+ pidfile_remove(pidfile_fh);
+ exit(1);
}
/*
@@ -562,12 +603,12 @@ rarp_bootable(in_addr_t addr)
else {
if (chdir(tftp_dir) == -1) {
logmsg(LOG_ERR, "chdir: %s: %m", tftp_dir);
- exit(1);
+ goto rarp_bootable_err;
}
d = opendir(".");
if (d == NULL) {
logmsg(LOG_ERR, "opendir: %m");
- exit(1);
+ goto rarp_bootable_err;
}
dd = d;
}
@@ -575,6 +616,10 @@ rarp_bootable(in_addr_t addr)
if (strncmp(dent->d_name, ipname, 8) == 0)
return 1;
return 0;
+
+rarp_bootable_err:
+ pidfile_remove(pidfile_fh);
+ exit(1);
}
/*
@@ -678,6 +723,7 @@ update_arptab(u_char *ep, in_addr_t ipaddr)
r = socket(PF_ROUTE, SOCK_RAW, 0);
if (r == -1) {
logmsg(LOG_ERR, "raw route socket: %m");
+ pidfile_remove(pidfile_fh);
exit(1);
}
pid = getpid();
diff --git a/usr.sbin/repquota/Makefile.depend b/usr.sbin/repquota/Makefile.depend
new file mode 100644
index 0000000..2dd29af
--- /dev/null
+++ b/usr.sbin/repquota/Makefile.depend
@@ -0,0 +1,20 @@
+# Autogenerated - do NOT edit!
+
+DEP_RELDIR := ${_PARSEDIR:S,${SRCTOP}/,,}
+
+DEP_MACHINE := ${.PARSEFILE:E}
+
+DIRDEPS = \
+ gnu/lib/libgcc \
+ include \
+ include/xlocale \
+ lib/${CSU_DIR} \
+ lib/libc \
+ lib/libutil \
+
+
+.include <dirdeps.mk>
+
+.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+# local dependencies - needed for -jN in clean tree
+.endif
diff --git a/usr.sbin/repquota/repquota.c b/usr.sbin/repquota/repquota.c
index 8fdea20..4ffc2e6 100644
--- a/usr.sbin/repquota/repquota.c
+++ b/usr.sbin/repquota/repquota.c
@@ -79,8 +79,7 @@ __FBSDID("$FreeBSD$");
#define max(a,b) ((a) >= (b) ? (a) : (b))
-const char *qfname = QUOTAFILENAME;
-const char *qfextension[] = INITQFNAMES;
+static const char *qfextension[] = INITQFNAMES;
struct fileusage {
struct fileusage *fu_next;
@@ -89,15 +88,15 @@ struct fileusage {
/* actually bigger */
};
#define FUHASH 1024 /* must be power of two */
-struct fileusage *fuhead[MAXQUOTAS][FUHASH];
-struct fileusage *lookup(u_long, int);
-struct fileusage *addid(u_long, int, char *);
-u_long highid[MAXQUOTAS]; /* highest addid()'ed identifier per type */
+static struct fileusage *fuhead[MAXQUOTAS][FUHASH];
+static struct fileusage *lookup(u_long, int);
+static struct fileusage *addid(u_long, int, char *);
+static u_long highid[MAXQUOTAS]; /* highest addid()'ed identifier per type */
-int vflag; /* verbose */
-int aflag; /* all filesystems */
-int nflag; /* display user/group by id */
-int hflag; /* display in human readable format */
+static int vflag; /* verbose */
+static int aflag; /* all filesystems */
+static int nflag; /* display user/group by id */
+static int hflag; /* display in human readable format */
int oneof(char *, char *[], int);
int repquota(struct fstab *, int);
diff --git a/usr.sbin/rip6query/Makefile.depend b/usr.sbin/rip6query/Makefile.depend
new file mode 100644
index 0000000..16b5e42
--- /dev/null
+++ b/usr.sbin/rip6query/Makefile.depend
@@ -0,0 +1,20 @@
+# Autogenerated - do NOT edit!
+
+DEP_RELDIR := ${_PARSEDIR:S,${SRCTOP}/,,}
+
+DEP_MACHINE := ${.PARSEFILE:E}
+
+DIRDEPS = \
+ gnu/lib/libgcc \
+ include \
+ include/arpa \
+ include/xlocale \
+ lib/${CSU_DIR} \
+ lib/libc \
+
+
+.include <dirdeps.mk>
+
+.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+# local dependencies - needed for -jN in clean tree
+.endif
diff --git a/usr.sbin/rmt/Makefile.depend b/usr.sbin/rmt/Makefile.depend
new file mode 100644
index 0000000..a839545
--- /dev/null
+++ b/usr.sbin/rmt/Makefile.depend
@@ -0,0 +1,19 @@
+# Autogenerated - do NOT edit!
+
+DEP_RELDIR := ${_PARSEDIR:S,${SRCTOP}/,,}
+
+DEP_MACHINE := ${.PARSEFILE:E}
+
+DIRDEPS = \
+ gnu/lib/libgcc \
+ include \
+ include/xlocale \
+ lib/${CSU_DIR} \
+ lib/libc \
+
+
+.include <dirdeps.mk>
+
+.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+# local dependencies - needed for -jN in clean tree
+.endif
diff --git a/usr.sbin/rndc-confgen/Makefile.depend b/usr.sbin/rndc-confgen/Makefile.depend
new file mode 100644
index 0000000..78e28c0
--- /dev/null
+++ b/usr.sbin/rndc-confgen/Makefile.depend
@@ -0,0 +1,28 @@
+# Autogenerated - do NOT edit!
+
+DEP_RELDIR := ${_PARSEDIR:S,${SRCTOP}/,,}
+
+DEP_MACHINE := ${.PARSEFILE:E}
+
+DIRDEPS = \
+ gnu/lib/libgcc \
+ include \
+ include/arpa \
+ include/xlocale \
+ lib/${CSU_DIR} \
+ lib/bind/bind9 \
+ lib/bind/dns \
+ lib/bind/isc \
+ lib/bind/isccc \
+ lib/bind/isccfg \
+ lib/bind/lwres \
+ lib/libc \
+ lib/libthr \
+ secure/lib/libcrypto \
+
+
+.include <dirdeps.mk>
+
+.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+# local dependencies - needed for -jN in clean tree
+.endif
diff --git a/usr.sbin/rndc/Makefile.depend b/usr.sbin/rndc/Makefile.depend
new file mode 100644
index 0000000..78e28c0
--- /dev/null
+++ b/usr.sbin/rndc/Makefile.depend
@@ -0,0 +1,28 @@
+# Autogenerated - do NOT edit!
+
+DEP_RELDIR := ${_PARSEDIR:S,${SRCTOP}/,,}
+
+DEP_MACHINE := ${.PARSEFILE:E}
+
+DIRDEPS = \
+ gnu/lib/libgcc \
+ include \
+ include/arpa \
+ include/xlocale \
+ lib/${CSU_DIR} \
+ lib/bind/bind9 \
+ lib/bind/dns \
+ lib/bind/isc \
+ lib/bind/isccc \
+ lib/bind/isccfg \
+ lib/bind/lwres \
+ lib/libc \
+ lib/libthr \
+ secure/lib/libcrypto \
+
+
+.include <dirdeps.mk>
+
+.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+# local dependencies - needed for -jN in clean tree
+.endif
diff --git a/usr.sbin/route6d/Makefile.depend b/usr.sbin/route6d/Makefile.depend
new file mode 100644
index 0000000..16b5e42
--- /dev/null
+++ b/usr.sbin/route6d/Makefile.depend
@@ -0,0 +1,20 @@
+# Autogenerated - do NOT edit!
+
+DEP_RELDIR := ${_PARSEDIR:S,${SRCTOP}/,,}
+
+DEP_MACHINE := ${.PARSEFILE:E}
+
+DIRDEPS = \
+ gnu/lib/libgcc \
+ include \
+ include/arpa \
+ include/xlocale \
+ lib/${CSU_DIR} \
+ lib/libc \
+
+
+.include <dirdeps.mk>
+
+.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+# local dependencies - needed for -jN in clean tree
+.endif
diff --git a/usr.sbin/rpc.lockd/Makefile.depend b/usr.sbin/rpc.lockd/Makefile.depend
new file mode 100644
index 0000000..5b47922
--- /dev/null
+++ b/usr.sbin/rpc.lockd/Makefile.depend
@@ -0,0 +1,26 @@
+# Autogenerated - do NOT edit!
+
+DEP_RELDIR := ${_PARSEDIR:S,${SRCTOP}/,,}
+
+DEP_MACHINE := ${.PARSEFILE:E}
+
+DIRDEPS = \
+ gnu/lib/libgcc \
+ include \
+ include/arpa \
+ include/rpc \
+ include/rpcsvc \
+ include/xlocale \
+ lib/${CSU_DIR} \
+ lib/libc \
+ lib/librpcsvc \
+ lib/libutil \
+
+
+.include <dirdeps.mk>
+
+.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+# local dependencies - needed for -jN in clean tree
+nlm_prot_svc.o: nlm_prot_svc.c
+nlm_prot_svc.po: nlm_prot_svc.c
+.endif
diff --git a/usr.sbin/rpc.lockd/lockd_lock.c b/usr.sbin/rpc.lockd/lockd_lock.c
index 6c409ad..dfb0d2a 100644
--- a/usr.sbin/rpc.lockd/lockd_lock.c
+++ b/usr.sbin/rpc.lockd/lockd_lock.c
@@ -494,8 +494,6 @@ regions_overlap(start1, len1, start2, len2)
} else {
return 1;
}
-
- return (result);
}
/*
diff --git a/usr.sbin/rpc.statd/Makefile.depend b/usr.sbin/rpc.statd/Makefile.depend
new file mode 100644
index 0000000..f541eb9
--- /dev/null
+++ b/usr.sbin/rpc.statd/Makefile.depend
@@ -0,0 +1,32 @@
+# Autogenerated - do NOT edit!
+
+DEP_RELDIR := ${_PARSEDIR:S,${SRCTOP}/,,}
+
+DEP_MACHINE := ${.PARSEFILE:E}
+
+DIRDEPS = \
+ gnu/lib/libgcc \
+ include \
+ include/arpa \
+ include/rpc \
+ include/xlocale \
+ lib/${CSU_DIR} \
+ lib/libc \
+ lib/librpcsvc \
+
+
+.include <dirdeps.mk>
+
+.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+# local dependencies - needed for -jN in clean tree
+file.o: sm_inter.h
+file.po: sm_inter.h
+procs.o: sm_inter.h
+procs.po: sm_inter.h
+sm_inter_svc.o: sm_inter.h
+sm_inter_svc.o: sm_inter_svc.c
+sm_inter_svc.po: sm_inter.h
+sm_inter_svc.po: sm_inter_svc.c
+statd.o: sm_inter.h
+statd.po: sm_inter.h
+.endif
diff --git a/usr.sbin/rpc.umntall/Makefile.depend b/usr.sbin/rpc.umntall/Makefile.depend
new file mode 100644
index 0000000..6e9b14f
--- /dev/null
+++ b/usr.sbin/rpc.umntall/Makefile.depend
@@ -0,0 +1,21 @@
+# Autogenerated - do NOT edit!
+
+DEP_RELDIR := ${_PARSEDIR:S,${SRCTOP}/,,}
+
+DEP_MACHINE := ${.PARSEFILE:E}
+
+DIRDEPS = \
+ gnu/lib/libgcc \
+ include \
+ include/rpc \
+ include/rpcsvc \
+ include/xlocale \
+ lib/${CSU_DIR} \
+ lib/libc \
+
+
+.include <dirdeps.mk>
+
+.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+# local dependencies - needed for -jN in clean tree
+.endif
diff --git a/usr.sbin/rpc.yppasswdd/Makefile.depend b/usr.sbin/rpc.yppasswdd/Makefile.depend
new file mode 100644
index 0000000..52d3eca
--- /dev/null
+++ b/usr.sbin/rpc.yppasswdd/Makefile.depend
@@ -0,0 +1,49 @@
+# Autogenerated - do NOT edit!
+
+DEP_RELDIR := ${_PARSEDIR:S,${SRCTOP}/,,}
+
+DEP_MACHINE := ${.PARSEFILE:E}
+
+DIRDEPS = \
+ gnu/lib/libgcc \
+ include \
+ include/arpa \
+ include/rpc \
+ include/rpcsvc \
+ include/xlocale \
+ lib/${CSU_DIR} \
+ lib/libc \
+ lib/libcrypt \
+ lib/librpcsvc \
+ lib/libutil \
+
+
+.include <dirdeps.mk>
+
+.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+# local dependencies - needed for -jN in clean tree
+yp_clnt.o: yp.h
+yp_clnt.o: yp_clnt.c
+yp_clnt.po: yp.h
+yp_clnt.po: yp_clnt.c
+yppasswd_private_svc.o: yppasswd_private.h
+yppasswd_private_svc.o: yppasswd_private_svc.c
+yppasswd_private_svc.po: yppasswd_private.h
+yppasswd_private_svc.po: yppasswd_private_svc.c
+yppasswd_private_xdr.o: yppasswd_private.h
+yppasswd_private_xdr.o: yppasswd_private_xdr.c
+yppasswd_private_xdr.po: yppasswd_private.h
+yppasswd_private_xdr.po: yppasswd_private_xdr.c
+yppasswd_svc.o: yppasswd.h
+yppasswd_svc.o: yppasswd_svc.c
+yppasswd_svc.po: yppasswd.h
+yppasswd_svc.po: yppasswd_svc.c
+yppasswdd_main.o: yppasswd.h
+yppasswdd_main.o: yppasswd_private.h
+yppasswdd_main.po: yppasswd.h
+yppasswdd_main.po: yppasswd_private.h
+yppasswdd_server.o: yppasswd.h
+yppasswdd_server.o: yppasswd_private.h
+yppasswdd_server.po: yppasswd.h
+yppasswdd_server.po: yppasswd_private.h
+.endif
diff --git a/usr.sbin/rpc.ypupdated/Makefile.depend b/usr.sbin/rpc.ypupdated/Makefile.depend
new file mode 100644
index 0000000..51b99b7
--- /dev/null
+++ b/usr.sbin/rpc.ypupdated/Makefile.depend
@@ -0,0 +1,30 @@
+# Autogenerated - do NOT edit!
+
+DEP_RELDIR := ${_PARSEDIR:S,${SRCTOP}/,,}
+
+DEP_MACHINE := ${.PARSEFILE:E}
+
+DIRDEPS = \
+ gnu/lib/libgcc \
+ include \
+ include/rpc \
+ include/rpcsvc \
+ include/xlocale \
+ lib/${CSU_DIR} \
+ lib/libc \
+ lib/librpcsvc \
+
+
+.include <dirdeps.mk>
+
+.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+# local dependencies - needed for -jN in clean tree
+ypupdate_prot_svc.o: ypupdate_prot.h
+ypupdate_prot_svc.o: ypupdate_prot_svc.c
+ypupdate_prot_svc.po: ypupdate_prot.h
+ypupdate_prot_svc.po: ypupdate_prot_svc.c
+ypupdated_main.o: ypupdate_prot.h
+ypupdated_main.po: ypupdate_prot.h
+ypupdated_server.o: ypupdate_prot.h
+ypupdated_server.po: ypupdate_prot.h
+.endif
diff --git a/usr.sbin/rpc.ypxfrd/Makefile.depend b/usr.sbin/rpc.ypxfrd/Makefile.depend
new file mode 100644
index 0000000..f5063de
--- /dev/null
+++ b/usr.sbin/rpc.ypxfrd/Makefile.depend
@@ -0,0 +1,31 @@
+# Autogenerated - do NOT edit!
+
+DEP_RELDIR := ${_PARSEDIR:S,${SRCTOP}/,,}
+
+DEP_MACHINE := ${.PARSEFILE:E}
+
+DIRDEPS = \
+ gnu/lib/libgcc \
+ include \
+ include/arpa \
+ include/rpc \
+ include/rpcsvc \
+ include/xlocale \
+ lib/${CSU_DIR} \
+ lib/libc \
+ lib/librpcsvc \
+
+
+.include <dirdeps.mk>
+
+.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+# local dependencies - needed for -jN in clean tree
+ypxfrd_main.o: ypxfrd.h
+ypxfrd_main.po: ypxfrd.h
+ypxfrd_server.o: ypxfrd.h
+ypxfrd_server.po: ypxfrd.h
+ypxfrd_svc.o: ypxfrd.h
+ypxfrd_svc.o: ypxfrd_svc.c
+ypxfrd_svc.po: ypxfrd.h
+ypxfrd_svc.po: ypxfrd_svc.c
+.endif
diff --git a/usr.sbin/rpcbind/Makefile.depend b/usr.sbin/rpcbind/Makefile.depend
new file mode 100644
index 0000000..018259c
--- /dev/null
+++ b/usr.sbin/rpcbind/Makefile.depend
@@ -0,0 +1,24 @@
+# Autogenerated - do NOT edit!
+
+DEP_RELDIR := ${_PARSEDIR:S,${SRCTOP}/,,}
+
+DEP_MACHINE := ${.PARSEFILE:E}
+
+DIRDEPS = \
+ gnu/lib/libgcc \
+ include \
+ include/arpa \
+ include/rpc \
+ include/rpcsvc \
+ include/xlocale \
+ lib/${CSU_DIR} \
+ lib/libc \
+ lib/libutil \
+ lib/libwrap \
+
+
+.include <dirdeps.mk>
+
+.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+# local dependencies - needed for -jN in clean tree
+.endif
diff --git a/usr.sbin/rrenumd/Makefile.depend b/usr.sbin/rrenumd/Makefile.depend
new file mode 100644
index 0000000..8b4e2b8
--- /dev/null
+++ b/usr.sbin/rrenumd/Makefile.depend
@@ -0,0 +1,28 @@
+# Autogenerated - do NOT edit!
+
+DEP_RELDIR := ${_PARSEDIR:S,${SRCTOP}/,,}
+
+DEP_MACHINE := ${.PARSEFILE:E}
+
+DIRDEPS = \
+ gnu/lib/libgcc \
+ include \
+ include/arpa \
+ include/xlocale \
+ lib/${CSU_DIR} \
+ lib/libc \
+ lib/libipsec \
+ lib/liby \
+
+
+.include <dirdeps.mk>
+
+.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+# local dependencies - needed for -jN in clean tree
+lexer.o: lexer.c
+lexer.o: y.tab.h
+lexer.po: lexer.c
+lexer.po: y.tab.h
+parser.o: parser.c
+parser.po: parser.c
+.endif
diff --git a/usr.sbin/rtadvctl/Makefile.depend b/usr.sbin/rtadvctl/Makefile.depend
new file mode 100644
index 0000000..16b5e42
--- /dev/null
+++ b/usr.sbin/rtadvctl/Makefile.depend
@@ -0,0 +1,20 @@
+# Autogenerated - do NOT edit!
+
+DEP_RELDIR := ${_PARSEDIR:S,${SRCTOP}/,,}
+
+DEP_MACHINE := ${.PARSEFILE:E}
+
+DIRDEPS = \
+ gnu/lib/libgcc \
+ include \
+ include/arpa \
+ include/xlocale \
+ lib/${CSU_DIR} \
+ lib/libc \
+
+
+.include <dirdeps.mk>
+
+.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+# local dependencies - needed for -jN in clean tree
+.endif
diff --git a/usr.sbin/rtadvd/Makefile.depend b/usr.sbin/rtadvd/Makefile.depend
new file mode 100644
index 0000000..c262920
--- /dev/null
+++ b/usr.sbin/rtadvd/Makefile.depend
@@ -0,0 +1,21 @@
+# Autogenerated - do NOT edit!
+
+DEP_RELDIR := ${_PARSEDIR:S,${SRCTOP}/,,}
+
+DEP_MACHINE := ${.PARSEFILE:E}
+
+DIRDEPS = \
+ gnu/lib/libgcc \
+ include \
+ include/arpa \
+ include/xlocale \
+ lib/${CSU_DIR} \
+ lib/libc \
+ lib/libutil \
+
+
+.include <dirdeps.mk>
+
+.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+# local dependencies - needed for -jN in clean tree
+.endif
diff --git a/usr.sbin/rtprio/Makefile.depend b/usr.sbin/rtprio/Makefile.depend
new file mode 100644
index 0000000..a839545
--- /dev/null
+++ b/usr.sbin/rtprio/Makefile.depend
@@ -0,0 +1,19 @@
+# Autogenerated - do NOT edit!
+
+DEP_RELDIR := ${_PARSEDIR:S,${SRCTOP}/,,}
+
+DEP_MACHINE := ${.PARSEFILE:E}
+
+DIRDEPS = \
+ gnu/lib/libgcc \
+ include \
+ include/xlocale \
+ lib/${CSU_DIR} \
+ lib/libc \
+
+
+.include <dirdeps.mk>
+
+.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+# local dependencies - needed for -jN in clean tree
+.endif
diff --git a/usr.sbin/rtprio/rtprio.1 b/usr.sbin/rtprio/rtprio.1
index 567a1c4..22d0645 100644
--- a/usr.sbin/rtprio/rtprio.1
+++ b/usr.sbin/rtprio/rtprio.1
@@ -30,7 +30,7 @@
.\"
.\" $FreeBSD$
.\"
-.Dd July 23, 1994
+.Dd September 29, 2012
.Dt RTPRIO 1
.Os
.Sh NAME
@@ -113,6 +113,14 @@ highest priority
of 0 means "the current process".
.Pp
Only root is allowed to set realtime or idle priority for a process.
+A user may modify the idle priority of their own processes if the
+.Xr sysctl 8
+variable
+.Va security.bsd.unprivileged_idprio
+is set to non-zero.
+Note that this increases the chance that a deadlock can occur
+if a process locks a required resource and then does
+not get to run.
.Sh EXIT STATUS
If
.Nm
diff --git a/usr.sbin/rtsold/Makefile.depend b/usr.sbin/rtsold/Makefile.depend
new file mode 100644
index 0000000..e6478bb
--- /dev/null
+++ b/usr.sbin/rtsold/Makefile.depend
@@ -0,0 +1,21 @@
+# Autogenerated - do NOT edit!
+
+DEP_RELDIR := ${_PARSEDIR:S,${SRCTOP}/,,}
+
+DEP_MACHINE := ${.PARSEFILE:E}
+
+DIRDEPS = \
+ gnu/lib/libgcc \
+ include \
+ include/arpa \
+ include/xlocale \
+ lib/${CSU_DIR} \
+ lib/libc \
+ lib/libkvm \
+
+
+.include <dirdeps.mk>
+
+.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+# local dependencies - needed for -jN in clean tree
+.endif
diff --git a/usr.sbin/rwhod/Makefile.depend b/usr.sbin/rwhod/Makefile.depend
new file mode 100644
index 0000000..083e419
--- /dev/null
+++ b/usr.sbin/rwhod/Makefile.depend
@@ -0,0 +1,21 @@
+# Autogenerated - do NOT edit!
+
+DEP_RELDIR := ${_PARSEDIR:S,${SRCTOP}/,,}
+
+DEP_MACHINE := ${.PARSEFILE:E}
+
+DIRDEPS = \
+ gnu/lib/libgcc \
+ include \
+ include/arpa \
+ include/protocols \
+ include/xlocale \
+ lib/${CSU_DIR} \
+ lib/libc \
+
+
+.include <dirdeps.mk>
+
+.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+# local dependencies - needed for -jN in clean tree
+.endif
diff --git a/usr.sbin/rwhod/rwhod.8 b/usr.sbin/rwhod/rwhod.8
index 59fb4ad..d4ecf4e 100644
--- a/usr.sbin/rwhod/rwhod.8
+++ b/usr.sbin/rwhod/rwhod.8
@@ -28,7 +28,7 @@
.\" @(#)rwhod.8 8.2 (Berkeley) 12/11/93
.\" $FreeBSD$
.\"
-.Dd December 11, 1993
+.Dd January 21, 2010
.Dt RWHOD 8
.Os
.Sh NAME
diff --git a/usr.sbin/sa/Makefile.depend b/usr.sbin/sa/Makefile.depend
new file mode 100644
index 0000000..a839545
--- /dev/null
+++ b/usr.sbin/sa/Makefile.depend
@@ -0,0 +1,19 @@
+# Autogenerated - do NOT edit!
+
+DEP_RELDIR := ${_PARSEDIR:S,${SRCTOP}/,,}
+
+DEP_MACHINE := ${.PARSEFILE:E}
+
+DIRDEPS = \
+ gnu/lib/libgcc \
+ include \
+ include/xlocale \
+ lib/${CSU_DIR} \
+ lib/libc \
+
+
+.include <dirdeps.mk>
+
+.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+# local dependencies - needed for -jN in clean tree
+.endif
diff --git a/usr.sbin/sade/Makefile.depend b/usr.sbin/sade/Makefile.depend
new file mode 100644
index 0000000..9f05925
--- /dev/null
+++ b/usr.sbin/sade/Makefile.depend
@@ -0,0 +1,24 @@
+# Autogenerated - do NOT edit!
+
+DEP_RELDIR := ${_PARSEDIR:S,${SRCTOP}/,,}
+
+DEP_MACHINE := ${.PARSEFILE:E}
+
+DIRDEPS = \
+ gnu/lib/libdialog \
+ gnu/lib/libgcc \
+ include \
+ include/xlocale \
+ lib/${CSU_DIR} \
+ lib/libc \
+ lib/libdisk \
+ lib/libutil \
+ lib/msun \
+ lib/ncurses/ncursesw \
+
+
+.include <dirdeps.mk>
+
+.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+# local dependencies - needed for -jN in clean tree
+.endif
diff --git a/usr.sbin/sendmail/Makefile.depend b/usr.sbin/sendmail/Makefile.depend
new file mode 100644
index 0000000..9298bd4
--- /dev/null
+++ b/usr.sbin/sendmail/Makefile.depend
@@ -0,0 +1,107 @@
+# Autogenerated - do NOT edit!
+
+DEP_RELDIR := ${_PARSEDIR:S,${SRCTOP}/,,}
+
+DEP_MACHINE := ${.PARSEFILE:E}
+
+DIRDEPS = \
+ gnu/lib/libgcc \
+ include \
+ include/arpa \
+ include/rpcsvc \
+ include/xlocale \
+ lib/${CSU_DIR} \
+ lib/libc \
+ lib/libsm \
+ lib/libsmutil \
+ lib/libutil \
+ lib/libwrap \
+ secure/lib/libcrypto \
+ secure/lib/libssl \
+
+
+.include <dirdeps.mk>
+
+.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+# local dependencies - needed for -jN in clean tree
+alias.o: sm_os.h
+alias.po: sm_os.h
+arpadate.o: sm_os.h
+arpadate.po: sm_os.h
+bf.o: sm_os.h
+bf.po: sm_os.h
+collect.o: sm_os.h
+collect.po: sm_os.h
+conf.o: sm_os.h
+conf.po: sm_os.h
+control.o: sm_os.h
+control.po: sm_os.h
+convtime.o: sm_os.h
+convtime.po: sm_os.h
+daemon.o: sm_os.h
+daemon.po: sm_os.h
+deliver.o: sm_os.h
+deliver.po: sm_os.h
+domain.o: sm_os.h
+domain.po: sm_os.h
+envelope.o: sm_os.h
+envelope.po: sm_os.h
+err.o: sm_os.h
+err.po: sm_os.h
+headers.o: sm_os.h
+headers.po: sm_os.h
+macro.o: sm_os.h
+macro.po: sm_os.h
+main.o: sm_os.h
+main.po: sm_os.h
+map.o: sm_os.h
+map.po: sm_os.h
+mci.o: sm_os.h
+mci.po: sm_os.h
+milter.o: sm_os.h
+milter.po: sm_os.h
+mime.o: sm_os.h
+mime.po: sm_os.h
+parseaddr.o: sm_os.h
+parseaddr.po: sm_os.h
+queue.o: sm_os.h
+queue.po: sm_os.h
+ratectrl.o: sm_os.h
+ratectrl.po: sm_os.h
+readcf.o: sm_os.h
+readcf.po: sm_os.h
+recipient.o: sm_os.h
+recipient.po: sm_os.h
+sasl.o: sm_os.h
+sasl.po: sm_os.h
+savemail.o: sm_os.h
+savemail.po: sm_os.h
+sfsasl.o: sm_os.h
+sfsasl.po: sm_os.h
+shmticklib.o: sm_os.h
+shmticklib.po: sm_os.h
+sm_resolve.o: sm_os.h
+sm_resolve.po: sm_os.h
+srvrsmtp.o: sm_os.h
+srvrsmtp.po: sm_os.h
+stab.o: sm_os.h
+stab.po: sm_os.h
+stats.o: sm_os.h
+stats.po: sm_os.h
+sysexits.o: sm_os.h
+sysexits.po: sm_os.h
+timers.o: sm_os.h
+timers.po: sm_os.h
+tls.o: sm_os.h
+tls.po: sm_os.h
+trace.o: sm_os.h
+trace.po: sm_os.h
+udb.o: sm_os.h
+udb.po: sm_os.h
+usersmtp.o: sm_os.h
+usersmtp.po: sm_os.h
+util.o: sm_os.h
+util.po: sm_os.h
+version.o: sm_os.h
+version.po: sm_os.h
+.endif
diff --git a/usr.sbin/service/Makefile.depend b/usr.sbin/service/Makefile.depend
new file mode 100644
index 0000000..29fda55
--- /dev/null
+++ b/usr.sbin/service/Makefile.depend
@@ -0,0 +1,14 @@
+# Autogenerated - do NOT edit!
+
+DEP_RELDIR := ${_PARSEDIR:S,${SRCTOP}/,,}
+
+DEP_MACHINE := ${.PARSEFILE:E}
+
+DIRDEPS = \
+
+
+.include <dirdeps.mk>
+
+.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+# local dependencies - needed for -jN in clean tree
+.endif
diff --git a/usr.sbin/services_mkdb/Makefile b/usr.sbin/services_mkdb/Makefile
index 659cdb8..e61c6df 100644
--- a/usr.sbin/services_mkdb/Makefile
+++ b/usr.sbin/services_mkdb/Makefile
@@ -2,7 +2,7 @@
PROG= services_mkdb
MAN= services_mkdb.8
-SRCS= services_mkdb.c uniq.c
+SRCS= services_mkdb.c uniq.c extern.h
DPADD+= ${LIBUTIL}
LDADD+= -lutil
diff --git a/usr.sbin/services_mkdb/Makefile.depend b/usr.sbin/services_mkdb/Makefile.depend
new file mode 100644
index 0000000..2dd29af
--- /dev/null
+++ b/usr.sbin/services_mkdb/Makefile.depend
@@ -0,0 +1,20 @@
+# Autogenerated - do NOT edit!
+
+DEP_RELDIR := ${_PARSEDIR:S,${SRCTOP}/,,}
+
+DEP_MACHINE := ${.PARSEFILE:E}
+
+DIRDEPS = \
+ gnu/lib/libgcc \
+ include \
+ include/xlocale \
+ lib/${CSU_DIR} \
+ lib/libc \
+ lib/libutil \
+
+
+.include <dirdeps.mk>
+
+.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+# local dependencies - needed for -jN in clean tree
+.endif
diff --git a/usr.sbin/services_mkdb/extern.h b/usr.sbin/services_mkdb/extern.h
new file mode 100644
index 0000000..94e31d3
--- /dev/null
+++ b/usr.sbin/services_mkdb/extern.h
@@ -0,0 +1,34 @@
+/*-
+ * Copyright (c) 2007 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Christos Zoulas.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ * $FreeBSD$
+ */
+
+extern const HASHINFO hinfo;
+
+void uniq(const char *);
diff --git a/usr.sbin/services_mkdb/services_mkdb.c b/usr.sbin/services_mkdb/services_mkdb.c
index f4cf62a..7f5316c 100644
--- a/usr.sbin/services_mkdb/services_mkdb.c
+++ b/usr.sbin/services_mkdb/services_mkdb.c
@@ -49,13 +49,13 @@ __FBSDID("$FreeBSD$");
#include <errno.h>
#include <stringlist.h>
+#include "extern.h"
+
static char tname[MAXPATHLEN];
#define PMASK 0xffff
#define PROTOMAX 5
-extern void uniq(const char *);
-
static void add(DB *, StringList *, size_t, const char *, size_t *, int);
static StringList ***parseservices(const char *, StringList *);
static void cleanup(void);
diff --git a/usr.sbin/services_mkdb/uniq.c b/usr.sbin/services_mkdb/uniq.c
index 0674b4b..e1bac38 100644
--- a/usr.sbin/services_mkdb/uniq.c
+++ b/usr.sbin/services_mkdb/uniq.c
@@ -40,9 +40,8 @@ __FBSDID("$FreeBSD$");
#include <ctype.h>
#include <fcntl.h>
-extern const HASHINFO hinfo;
+#include "extern.h"
-void uniq(const char *);
static int comp(const char *, char **, size_t *);
/*
diff --git a/usr.sbin/setfib/Makefile.depend b/usr.sbin/setfib/Makefile.depend
new file mode 100644
index 0000000..a839545
--- /dev/null
+++ b/usr.sbin/setfib/Makefile.depend
@@ -0,0 +1,19 @@
+# Autogenerated - do NOT edit!
+
+DEP_RELDIR := ${_PARSEDIR:S,${SRCTOP}/,,}
+
+DEP_MACHINE := ${.PARSEFILE:E}
+
+DIRDEPS = \
+ gnu/lib/libgcc \
+ include \
+ include/xlocale \
+ lib/${CSU_DIR} \
+ lib/libc \
+
+
+.include <dirdeps.mk>
+
+.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+# local dependencies - needed for -jN in clean tree
+.endif
diff --git a/usr.sbin/setfmac/Makefile.depend b/usr.sbin/setfmac/Makefile.depend
new file mode 100644
index 0000000..a839545
--- /dev/null
+++ b/usr.sbin/setfmac/Makefile.depend
@@ -0,0 +1,19 @@
+# Autogenerated - do NOT edit!
+
+DEP_RELDIR := ${_PARSEDIR:S,${SRCTOP}/,,}
+
+DEP_MACHINE := ${.PARSEFILE:E}
+
+DIRDEPS = \
+ gnu/lib/libgcc \
+ include \
+ include/xlocale \
+ lib/${CSU_DIR} \
+ lib/libc \
+
+
+.include <dirdeps.mk>
+
+.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+# local dependencies - needed for -jN in clean tree
+.endif
diff --git a/usr.sbin/setpmac/Makefile.depend b/usr.sbin/setpmac/Makefile.depend
new file mode 100644
index 0000000..a839545
--- /dev/null
+++ b/usr.sbin/setpmac/Makefile.depend
@@ -0,0 +1,19 @@
+# Autogenerated - do NOT edit!
+
+DEP_RELDIR := ${_PARSEDIR:S,${SRCTOP}/,,}
+
+DEP_MACHINE := ${.PARSEFILE:E}
+
+DIRDEPS = \
+ gnu/lib/libgcc \
+ include \
+ include/xlocale \
+ lib/${CSU_DIR} \
+ lib/libc \
+
+
+.include <dirdeps.mk>
+
+.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+# local dependencies - needed for -jN in clean tree
+.endif
diff --git a/usr.sbin/sicontrol/Makefile.depend b/usr.sbin/sicontrol/Makefile.depend
new file mode 100644
index 0000000..a839545
--- /dev/null
+++ b/usr.sbin/sicontrol/Makefile.depend
@@ -0,0 +1,19 @@
+# Autogenerated - do NOT edit!
+
+DEP_RELDIR := ${_PARSEDIR:S,${SRCTOP}/,,}
+
+DEP_MACHINE := ${.PARSEFILE:E}
+
+DIRDEPS = \
+ gnu/lib/libgcc \
+ include \
+ include/xlocale \
+ lib/${CSU_DIR} \
+ lib/libc \
+
+
+.include <dirdeps.mk>
+
+.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+# local dependencies - needed for -jN in clean tree
+.endif
diff --git a/usr.sbin/smbmsg/Makefile.depend b/usr.sbin/smbmsg/Makefile.depend
new file mode 100644
index 0000000..a839545
--- /dev/null
+++ b/usr.sbin/smbmsg/Makefile.depend
@@ -0,0 +1,19 @@
+# Autogenerated - do NOT edit!
+
+DEP_RELDIR := ${_PARSEDIR:S,${SRCTOP}/,,}
+
+DEP_MACHINE := ${.PARSEFILE:E}
+
+DIRDEPS = \
+ gnu/lib/libgcc \
+ include \
+ include/xlocale \
+ lib/${CSU_DIR} \
+ lib/libc \
+
+
+.include <dirdeps.mk>
+
+.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+# local dependencies - needed for -jN in clean tree
+.endif
diff --git a/usr.sbin/snapinfo/Makefile.depend b/usr.sbin/snapinfo/Makefile.depend
new file mode 100644
index 0000000..250cad8
--- /dev/null
+++ b/usr.sbin/snapinfo/Makefile.depend
@@ -0,0 +1,20 @@
+# Autogenerated - do NOT edit!
+
+DEP_RELDIR := ${_PARSEDIR:S,${SRCTOP}/,,}
+
+DEP_MACHINE := ${.PARSEFILE:E}
+
+DIRDEPS = \
+ gnu/lib/libgcc \
+ include \
+ include/xlocale \
+ lib/${CSU_DIR} \
+ lib/libc \
+ lib/libufs \
+
+
+.include <dirdeps.mk>
+
+.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+# local dependencies - needed for -jN in clean tree
+.endif
diff --git a/usr.sbin/snapinfo/snapinfo.c b/usr.sbin/snapinfo/snapinfo.c
index 45882e0..23c3b4b 100644
--- a/usr.sbin/snapinfo/snapinfo.c
+++ b/usr.sbin/snapinfo/snapinfo.c
@@ -34,6 +34,7 @@
#include <errno.h>
#include <ftw.h>
#include <libufs.h>
+#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -149,7 +150,7 @@ compare_function(const char *path, const struct stat *st, int flags,
printf("\tsnapshot ");
printf("%s", path);
if (verbose)
- printf(" (inode %d)", st->st_ino);
+ printf(" (inode %ju)", (uintmax_t)st->st_ino);
printf("\n");
if (!cont_search)
return (EEXIST);
diff --git a/usr.sbin/spkrtest/Makefile.depend b/usr.sbin/spkrtest/Makefile.depend
new file mode 100644
index 0000000..29fda55
--- /dev/null
+++ b/usr.sbin/spkrtest/Makefile.depend
@@ -0,0 +1,14 @@
+# Autogenerated - do NOT edit!
+
+DEP_RELDIR := ${_PARSEDIR:S,${SRCTOP}/,,}
+
+DEP_MACHINE := ${.PARSEFILE:E}
+
+DIRDEPS = \
+
+
+.include <dirdeps.mk>
+
+.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+# local dependencies - needed for -jN in clean tree
+.endif
diff --git a/usr.sbin/spray/Makefile.depend b/usr.sbin/spray/Makefile.depend
new file mode 100644
index 0000000..60fe900
--- /dev/null
+++ b/usr.sbin/spray/Makefile.depend
@@ -0,0 +1,22 @@
+# Autogenerated - do NOT edit!
+
+DEP_RELDIR := ${_PARSEDIR:S,${SRCTOP}/,,}
+
+DEP_MACHINE := ${.PARSEFILE:E}
+
+DIRDEPS = \
+ gnu/lib/libgcc \
+ include \
+ include/rpc \
+ include/rpcsvc \
+ include/xlocale \
+ lib/${CSU_DIR} \
+ lib/libc \
+ lib/librpcsvc \
+
+
+.include <dirdeps.mk>
+
+.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+# local dependencies - needed for -jN in clean tree
+.endif
diff --git a/usr.sbin/syslogd/Makefile.depend b/usr.sbin/syslogd/Makefile.depend
new file mode 100644
index 0000000..c262920
--- /dev/null
+++ b/usr.sbin/syslogd/Makefile.depend
@@ -0,0 +1,21 @@
+# Autogenerated - do NOT edit!
+
+DEP_RELDIR := ${_PARSEDIR:S,${SRCTOP}/,,}
+
+DEP_MACHINE := ${.PARSEFILE:E}
+
+DIRDEPS = \
+ gnu/lib/libgcc \
+ include \
+ include/arpa \
+ include/xlocale \
+ lib/${CSU_DIR} \
+ lib/libc \
+ lib/libutil \
+
+
+.include <dirdeps.mk>
+
+.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+# local dependencies - needed for -jN in clean tree
+.endif
diff --git a/usr.sbin/syslogd/syslog.conf.5 b/usr.sbin/syslogd/syslog.conf.5
index f9d4024..3378aa0 100644
--- a/usr.sbin/syslogd/syslog.conf.5
+++ b/usr.sbin/syslogd/syslog.conf.5
@@ -28,7 +28,7 @@
.\" @(#)syslog.conf.5 8.1 (Berkeley) 6/9/93
.\" $FreeBSD$
.\"
-.Dd December 23, 2008
+.Dd September 12, 2012
.Dt SYSLOG.CONF 5
.Os
.Sh NAME
@@ -347,6 +347,14 @@ If a port number is added after a colon
.Pq Ql :\&
then that port will be used as the destination port
rather than the usual syslog port.
+IPv6 addresses can be used
+by surrounding the address portion with
+square brackets
+.Po
+.Ql [\&
+and
+.Ql ]\&
+.Pc .
.It
A comma separated list of users.
Selected messages are written to those users
diff --git a/usr.sbin/syslogd/syslogd.c b/usr.sbin/syslogd/syslogd.c
index d1c9fd1..fff7e4c 100644
--- a/usr.sbin/syslogd/syslogd.c
+++ b/usr.sbin/syslogd/syslogd.c
@@ -312,7 +312,7 @@ static void cfline(const char *, struct filed *,
static const char *cvthname(struct sockaddr *);
static void deadq_enter(pid_t, const char *);
static int deadq_remove(pid_t);
-static int decode(const char *, CODE *);
+static int decode(const char *, const CODE *);
static void die(int);
static void dodie(int);
static void dofsync(void);
@@ -1123,7 +1123,7 @@ fprintlog(struct filed *f, int flags, const char *msg)
char p_n[5]; /* Hollow laugh */
if (LogFacPri > 1) {
- CODE *c;
+ const CODE *c;
for (c = facilitynames; c->c_name; c++) {
if (c->c_val == fac) {
@@ -1931,6 +1931,7 @@ cfline(const char *line, struct filed *f, const char *prog, const char *host)
case '@':
{
char *tp;
+ char endkey = ':';
/*
* scan forward to see if there is a port defined.
* so we can't use strlcpy..
@@ -1939,9 +1940,19 @@ cfline(const char *line, struct filed *f, const char *prog, const char *host)
tp = f->f_un.f_forw.f_hname;
p++;
- while (*p && (*p != ':') && (i-- > 0)) {
+ /*
+ * an ipv6 address should start with a '[' in that case
+ * we should scan for a ']'
+ */
+ if (*p == '[') {
+ p++;
+ endkey = ']';
+ }
+ while (*p && (*p != endkey) && (i-- > 0)) {
*tp++ = *p++;
}
+ if (endkey == ']' && *p == endkey)
+ p++;
*tp = '\0';
}
/* See if we copied a domain and have a port */
@@ -2018,9 +2029,9 @@ cfline(const char *line, struct filed *f, const char *prog, const char *host)
* Decode a symbolic name to a numeric value
*/
static int
-decode(const char *name, CODE *codetab)
+decode(const char *name, const CODE *codetab)
{
- CODE *c;
+ const CODE *c;
char *p, buf[40];
if (isdigit(*name))
diff --git a/usr.sbin/sysrc/Makefile b/usr.sbin/sysrc/Makefile
new file mode 100644
index 0000000..38c52ee
--- /dev/null
+++ b/usr.sbin/sysrc/Makefile
@@ -0,0 +1,13 @@
+# $FreeBSD$
+
+NO_OBJ=
+
+SCRIPTS= sysrc
+
+MAN= sysrc.8
+
+beforeinstall:
+ mkdir -p ${DESTDIR}${SCRIPTSDIR}
+ mkdir -p ${DESTDIR}${MANDIR}8
+
+.include <bsd.prog.mk>
diff --git a/usr.sbin/sysrc/sysrc b/usr.sbin/sysrc/sysrc
new file mode 100644
index 0000000..e1c15d6
--- /dev/null
+++ b/usr.sbin/sysrc/sysrc
@@ -0,0 +1,617 @@
+#!/bin/sh
+#-
+# Copyright (c) 2010-2012 Devin Teske
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in the
+# documentation and/or other materials provided with the distribution.
+#
+# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING BUT NOT LIMITED TO, THE
+# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+# SUCH DAMAGE.
+#
+# $FreeBSD$
+#
+############################################################ INCLUDES
+
+BSDCFG_SHARE="/usr/share/bsdconfig"
+[ "$_COMMON_SUBR" ] || . $BSDCFG_SHARE/common.subr || exit 1
+[ "$_SYSRC_SUBR" ] || f_include $BSDCFG_SHARE/sysrc.subr
+
+############################################################ CONFIGURATION
+
+#
+# Default verbosity.
+#
+: ${SYSRC_VERBOSE:=}
+
+############################################################ GLOBALS
+
+#
+# Options
+#
+DELETE=
+DESCRIBE=
+IGNORE_UNKNOWNS=
+JAIL=
+QUIET=
+ROOTDIR=
+SHOW_ALL=
+SHOW_EQUALS=
+SHOW_FILE=
+SHOW_NAME=1
+SHOW_VALUE=1
+
+############################################################ FUNCTIONS
+
+# die [ $fmt [ $opts ... ]]
+#
+# Optionally print a message to stderr before exiting with failure status.
+#
+die()
+{
+ local fmt="$1"
+ [ $# -gt 0 ] && shift 1
+ [ "$fmt" ] && f_err "$fmt\n" "$@"
+
+ exit $FAILURE
+}
+
+# usage
+#
+# Prints a short syntax statement and exits.
+#
+usage()
+{
+ f_err "Usage: %s [OPTIONS] name[=value] ...\n" "$pgm"
+ f_err "Try \`%s --help' for more information.\n" "$pgm"
+ die
+}
+
+# help
+#
+# Prints a full syntax statement and exits.
+#
+help()
+{
+ local optfmt="\t%-11s%s\n"
+ local envfmt="\t%-17s%s\n"
+
+ f_err "Usage: %s [OPTIONS] name[=value] ...\n" "$pgm"
+
+ f_err "OPTIONS:\n"
+ f_err "$optfmt" "-a" \
+ "Dump a list of all non-default configuration variables."
+ f_err "$optfmt" "-A" \
+ "Dump a list of all configuration variables (incl. defaults)."
+ f_err "$optfmt" "-d" \
+ "Print a description of the given variable."
+ f_err "$optfmt" "-D" \
+ "Show default value(s) only (this is the same as setting"
+ f_err "$optfmt" "" \
+ "RC_CONFS to NULL or passing \`-f' with a NULL file-argument)."
+ f_err "$optfmt" "-e" \
+ "Print query results as \`var=value' (useful for producing"
+ f_err "$optfmt" "" \
+ "output to be fed back in). Ignored if \`-n' is specified."
+ f_err "$optfmt" "-f file" \
+ "Operate on the specified file(s) instead of rc_conf_files."
+ f_err "$optfmt" "" \
+ "Can be specified multiple times for additional files."
+ f_err "$optfmt" "-F" \
+ "Show only the last rc.conf(5) file each directive is in."
+ f_err "$optfmt" "-h" \
+ "Print a short usage statement to stderr and exit."
+ f_err "$optfmt" "--help" \
+ "Print this message to stderr and exit."
+ f_err "$optfmt" "-i" \
+ "Ignore unknown variables."
+ f_err "$optfmt" "-j jail" \
+ "The jid or name of the jail to operate within (overrides"
+ f_err "$optfmt" "" \
+ "\`-R dir'; requires jexec(8))."
+ f_err "$optfmt" "-n" \
+ "Show only variable values, not their names."
+ f_err "$optfmt" "-N" \
+ "Show only variable names, not their values."
+ f_err "$optfmt" "-q" \
+ "Quiet. Ignore previous \`-v' and/or SYSRC_VERBOSE."
+ f_err "$optfmt" "-R dir" \
+ "Operate within the root directory \`dir' rather than \`/'."
+ f_err "$optfmt" "-v" \
+ "Verbose. Print the pathname of the specific rc.conf(5)"
+ f_err "$optfmt" "" \
+ "file where the directive was found."
+ f_err "$optfmt" "-x" \
+ "Remove variable(s) from specified file(s)."
+ f_err "\n"
+
+ f_err "ENVIRONMENT:\n"
+ f_err "$envfmt" "RC_CONFS" \
+ "Override default rc_conf_files (even if set to NULL)."
+ f_err "$envfmt" "RC_DEFAULTS" \
+ "Location of \`/etc/defaults/rc.conf' file."
+ f_err "$envfmt" "SYSRC_VERBOSE" \
+ "Default verbosity. Set to non-NULL to enable."
+
+ die
+}
+
+# jail_depend
+#
+# Dump dependencies such as language-file variables and include files to stdout
+# to be piped-into sh(1) running via jexec(8)/chroot(8). As a security measure,
+# this prevents existing language files and library files from being loaded in
+# the jail. This also relaxes the requirement to have these files in every jail
+# before sysrc can be used on said jail.
+#
+jail_depend()
+{
+ #
+ # Indicate that we are jailed
+ #
+ echo export _SYSRC_JAILED=1
+
+ #
+ # Print i18n language variables (their current values are sanitized
+ # and re-printed for interpretation so that the i18n language files
+ # do not need to exist within the jail).
+ #
+ local var val
+ for var in \
+ msg_cannot_create_permission_denied \
+ msg_permission_denied \
+ msg_previous_syntax_errors \
+ ; do
+ val=$( eval echo \"\$$var\" |
+ awk '{ gsub(/'\''/, "'\''\\'\'\''"); print }' )
+ echo $var="'$val'"
+ done
+
+ #
+ # Print include dependencies
+ #
+ cat $BSDCFG_SHARE/common.subr
+ cat $BSDCFG_SHARE/sysrc.subr
+}
+
+############################################################ MAIN SOURCE
+
+#
+# Perform sanity checks
+#
+[ $# -gt 0 ] || usage
+
+#
+# Check for `--help' command-line option
+#
+( # Operate in sub-shell to protect $@ in parent
+ while [ $# -gt 0 ]; do
+ case "$1" in
+ --help) exit 1;;
+ -[fRj]) # These flags take an argument
+ shift 1;;
+ esac
+ shift 1
+ done
+ exit 0
+) || help
+
+#
+# Process command-line flags
+#
+while getopts aAdDef:Fhij:nNqR:vxX flag; do
+ case "$flag" in
+ a) SHOW_ALL=${SHOW_ALL:-1};;
+ A) SHOW_ALL=2;;
+ d) DESCRIBE=1;;
+ D) RC_CONFS=;;
+ e) SHOW_EQUALS=1;;
+ f) RC_CONFS="$RC_CONFS${RC_CONFS:+ }$OPTARG";;
+ F) SHOW_FILE=1;;
+ h) usage;;
+ i) IGNORE_UNKNOWNS=1;;
+ j) [ "$OPTARG" ] || die \
+ "%s: Missing or null argument to \`-j' flag" "$pgm"
+ JAIL="$OPTARG";;
+ n) SHOW_NAME=;;
+ N) SHOW_VALUE=;;
+ q) QUIET=1 SYSRC_VERBOSE=;;
+ R) [ "$OPTARG" ] || die \
+ "%s: Missing or null argument to \`-R' flag" "$pgm"
+ ROOTDIR="$OPTARG";;
+ v) SYSRC_VERBOSE=1 QUIET=;;
+ x) DELETE=${DELETE:-1};;
+ X) DELETE=2;;
+ \?) usage;;
+ esac
+done
+shift $(( $OPTIND - 1 ))
+
+#
+# [More] Sanity checks (e.g., "sysrc --")
+#
+[ $# -eq 0 -a ! "$SHOW_ALL" ] && usage
+
+#
+# Taint-check all rc.conf(5) files
+#
+errmsg="$pgm: Exiting due to previous syntax errors"
+if [ "${RC_CONFS+set}" ]; then
+ ( for i in $RC_CONFS; do
+ [ -e "$i" ] || continue
+ /bin/sh -n "$i" || exit $FAILURE
+ done
+ exit $SUCCESS
+ ) || die "$errmsg"
+else
+ /bin/sh -n "$RC_DEFAULTS" || die "$errmsg"
+ ( . "$RC_DEFAULTS"
+ for i in $rc_conf_files; do
+ [ -e "$i" ] || continue
+ /bin/sh -n "$i" || exit $FAILURE
+ done
+ exit $SUCCESS
+ ) || die "$errmsg"
+fi
+
+#
+# Process `-x' (and secret `-X') command-line options
+#
+errmsg="$pgm: \`-x' option incompatible with \`-a'/\`-A' options"
+errmsg="$errmsg (use \`-X' to override)"
+if [ "$DELETE" -a "$SHOW_ALL" ]; then
+ [ "$DELETE" = "2" ] || die "$errmsg"
+fi
+
+#
+# Process `-e', `-n', and `-N' command-line options
+#
+SEP=': '
+[ "$SHOW_EQUALS" ] && SEP='="'
+[ "$SHOW_NAME" ] || SHOW_EQUALS=
+[ "$SYSRC_VERBOSE" = "0" ] && SYSRC_VERBOSE=
+if [ ! "$SHOW_VALUE" ]; then
+ SHOW_NAME=1
+ SHOW_EQUALS=
+fi
+
+#
+# Process `-j jail' and `-R dir' command-line options
+#
+if [ "$JAIL" -o "$ROOTDIR" ]; then
+ #
+ # Reconstruct the arguments that we want to carry-over
+ #
+ args="
+ ${SYSRC_VERBOSE:+-v}
+ ${QUIET:+-q}
+ $( [ "$DELETE" = "1" ] && echo \ -x )
+ $( [ "$DELETE" = "2" ] && echo \ -X )
+ $( [ "$SHOW_ALL" = "1" ] && echo \ -a )
+ $( [ "$SHOW_ALL" = "2" ] && echo \ -A )
+ ${DESCRIBE:+-d}
+ ${SHOW_EQUALS:+-e}
+ ${IGNORE_UNKNOWNS:+-i}
+ $( [ "$SHOW_NAME" ] || echo \ -n )
+ $( [ "$SHOW_VALUE" ] || echo \ -N )
+ $( [ "$SHOW_FILE" ] && echo \ -F )
+ "
+ if [ "${RC_CONFS+set}" ]; then
+ args="$args -f '$RC_CONFS'"
+ fi
+ for arg in "$@"; do
+ args="$args '$arg'"
+ done
+
+ #
+ # If both are supplied, `-j jail' supercedes `-R dir'
+ #
+ if [ "$JAIL" ]; then
+ #
+ # Re-execute ourselves with sh(1) via jexec(8)
+ #
+ ( echo set -- $args
+ jail_depend
+ cat $0
+ ) | env - RC_DEFAULTS="$RC_DEFAULTS" \
+ /usr/sbin/jexec "$JAIL" /bin/sh
+ exit $?
+ elif [ "$ROOTDIR" ]; then
+ #
+ # Make sure that the root directory specified is not to any
+ # running jails.
+ #
+ # NOTE: To maintain backward compatibility with older jails on
+ # older systems, we will not perform this check if either the
+ # jls(1) or jexec(8) utilities are missing.
+ #
+ if f_have jexec && f_have jls; then
+ jid="`jls jid path | \
+ (
+ while read JID JROOT; do
+ [ "$JROOT" = "$ROOTDIR" ] || continue
+ echo $JID
+ done
+ )`"
+
+ #
+ # If multiple running jails match the specified root
+ # directory, exit with error.
+ #
+ if [ "$jid" -a "${jid%[$IFS]*}" != "$jid" ]; then
+ die "%s: %s: %s" "$pgm" "$ROOTDIR" \
+ "$( echo "Multiple jails claim this" \
+ "directory as their root." \
+ "(use \`-j jail' instead)" )"
+ fi
+
+ #
+ # If only a single running jail matches the specified
+ # root directory, implicitly use `-j jail'.
+ #
+ if [ "$jid" ]; then
+ #
+ # Re-execute outselves with sh(1) via jexec(8)
+ #
+ ( echo set -- $args
+ jail_depend
+ cat $0
+ ) | env - RC_DEFAULTS="$RC_DEFAULTS" \
+ /usr/sbin/jexec "$jid" /bin/sh
+ exit $?
+ fi
+
+ # Otherwise, fall through and allow chroot(8)
+ fi
+
+ #
+ # Re-execute ourselves with sh(1) via chroot(8)
+ #
+ ( echo set -- $args
+ jail_depend
+ cat $0
+ ) | env - RC_DEFAULTS="$RC_DEFAULTS" \
+ /usr/sbin/chroot "$ROOTDIR" /bin/sh
+ exit $?
+ fi
+fi
+
+#
+# Process `-a' or `-A' command-line options
+#
+if [ "$SHOW_ALL" ]; then
+ #
+ # Get a list of variables that are currently set in the rc.conf(5)
+ # files (included `/etc/defaults/rc.conf') by performing a call to
+ # source_rc_confs() in a clean environment.
+ #
+ ( # Operate in a sub-shell to protect the parent environment
+ #
+ # Set which variables we want to preserve in the environment.
+ # Append the pipe-character (|) to the list of internal field
+ # separation (IFS) characters, allowing us to use the below
+ # list both as an extended grep (-E) pattern and argument list
+ # (required to first get f_clean_env() to preserve these in the
+ # environment and then later to prune them from the list of
+ # variables produced by set(1)).
+ #
+ IFS="$IFS|"
+ EXCEPT="IFS|EXCEPT|PATH|RC_DEFAULTS|OPTIND|DESCRIBE|SEP"
+ EXCEPT="$EXCEPT|DELETE|SHOW_ALL|SHOW_EQUALS|SHOW_NAME"
+ EXCEPT="$EXCEPT|SHOW_VALUE|SHOW_FILE|SYSRC_VERBOSE|RC_CONFS"
+ EXCEPT="$EXCEPT|pgm|SUCCESS|FAILURE"
+ EXCEPT="$EXCEPT|f_sysrc_desc_awk|f_sysrc_delete_awk"
+
+ #
+ # Clean the environment (except for our required variables)
+ # and then source the required files.
+ #
+ f_clean_env --except $EXCEPT
+ if [ -f "$RC_DEFAULTS" -a -r "$RC_DEFAULTS" ]; then
+ . "$RC_DEFAULTS"
+
+ #
+ # If passed `-a' (rather than `-A'), re-purge the
+ # environment, removing the rc.conf(5) defaults.
+ #
+ [ "$SHOW_ALL" = "1" ] \
+ && f_clean_env --except rc_conf_files $EXCEPT
+
+ #
+ # If `-f file' was passed, set $rc_conf_files to an
+ # explicit value, modifying the default behavior of
+ # source_rc_confs().
+ #
+ [ "${RC_CONFS+set}" ] && rc_conf_files="$RC_CONFS"
+
+ source_rc_confs
+
+ #
+ # If passed `-a' (rather than `-A'), remove
+ # `rc_conf_files' unless it was defined somewhere
+ # other than rc.conf(5) defaults.
+ #
+ [ "$SHOW_ALL" = "1" -a \
+ "$( f_sysrc_find rc_conf_files )" = "$RC_DEFAULTS" \
+ ] \
+ && unset rc_conf_files
+ fi
+
+ for NAME in $( set |
+ awk -F= '/^[[:alpha:]_][[:alnum:]_]*=/ {print $1}' |
+ grep -Ev "^($EXCEPT)$"
+ ); do
+ #
+ # If enabled, describe rather than expand value
+ #
+ if [ "$DESCRIBE" ]; then
+ echo "$NAME: $( f_sysrc_desc "$NAME" )"
+ continue
+ fi
+
+ #
+ # If `-F' is passed, find it and move on
+ #
+ if [ "$SHOW_FILE" ]; then
+ [ "$SHOW_NAME" ] && echo -n "$NAME: "
+ f_sysrc_find "$NAME"
+ continue
+ fi
+
+ #
+ # If `-X' is passed, delete the variables
+ #
+ if [ "$DELETE" = "2" ]; then
+ f_sysrc_delete "$NAME"
+ continue
+ fi
+
+ [ "$SYSRC_VERBOSE" ] && \
+ echo -n "$( f_sysrc_find "$NAME" ): "
+
+ #
+ # If `-N' is passed, simplify the output
+ #
+ if [ ! "$SHOW_VALUE" ]; then
+ echo "$NAME"
+ continue
+ fi
+
+ echo "${SHOW_NAME:+$NAME$SEP}$(
+ f_sysrc_get "$NAME" )${SHOW_EQUALS:+\"}"
+
+ done
+ )
+
+ #
+ # Ignore the remainder of positional arguments.
+ #
+ exit $SUCCESS
+fi
+
+#
+# Process command-line arguments
+#
+while [ $# -gt 0 ]; do
+ NAME="${1%%=*}"
+
+ [ "$DESCRIBE" ] && \
+ echo "$NAME: $( f_sysrc_desc "$NAME" )"
+
+ case "$1" in
+ *=*)
+ #
+ # Like sysctl(8), if both `-d' AND "name=value" is passed,
+ # first describe, then attempt to set
+ #
+
+ if [ "$SYSRC_VERBOSE" ]; then
+ file=$( f_sysrc_find "$NAME" )
+ [ "$file" = "$RC_DEFAULTS" -o ! "$file" ] && \
+ file=$( f_sysrc_get 'rc_conf_files%%[$IFS]*' )
+ echo -n "$file: "
+ fi
+
+ #
+ # If `-x' or `-X' is passed, delete the variable and ignore the
+ # desire to set some value
+ #
+ if [ "$DELETE" ]; then
+ f_sysrc_delete "$NAME"
+ shift 1
+ continue
+ fi
+
+ #
+ # If `-N' is passed, simplify the output
+ #
+ if [ ! "$SHOW_VALUE" ]; then
+ echo "$NAME"
+ f_sysrc_set "$NAME" "${1#*}"
+ else
+ if [ "$SHOW_FILE" ]; then
+ before=$( f_sysrc_find "$NAME" )
+ else
+ before=$( f_sysrc_get "$NAME" )
+ fi
+ if f_sysrc_set "$NAME" "${1#*=}"; then
+ if [ "$SHOW_FILE" ]; then
+ after=$( f_sysrc_find "$NAME" )
+ echo -n "${SHOW_NAME:+$NAME$SEP}"
+ echo -n "$before${SHOW_EQUALS:+\"}"
+ echo " -> $after"
+ else
+ after=$( f_sysrc_get "$NAME" )
+ echo -n "${SHOW_NAME:+$NAME$SEP}"
+ echo "$before -> $after"
+ fi
+ fi
+ fi
+ ;;
+ *)
+ if ! IGNORED="$( f_sysrc_get "$NAME?" )"; then
+ [ "$IGNORE_UNKNOWNS" ] \
+ || echo "$pgm: unknown variable '$NAME'"
+ shift 1
+ continue
+ fi
+
+ #
+ # Like sysctl(8), when `-d' is passed,
+ # desribe it rather than expanding it
+ #
+
+ if [ "$DESCRIBE" ]; then
+ shift 1
+ continue
+ fi
+
+ #
+ # If `-x' or `-X' is passed, delete the variable
+ #
+ if [ "$DELETE" ]; then
+ f_sysrc_delete "$NAME"
+ shift 1
+ continue
+ fi
+
+ #
+ # If `-F' is passed, find it and move on
+ #
+ if [ "$SHOW_FILE" ]; then
+ [ "$SHOW_NAME" ] && echo -n "$NAME: "
+ f_sysrc_find "$NAME"
+ shift 1
+ continue
+ fi
+
+ [ "$SYSRC_VERBOSE" ] && \
+ echo -n "$( f_sysrc_find "$NAME" ): "
+
+ #
+ # If `-N' is passed, simplify the output
+ #
+ if [ ! "$SHOW_VALUE" ]; then
+ echo "$NAME"
+ else
+ echo "${SHOW_NAME:+$NAME$SEP}$(
+ f_sysrc_get "$NAME" )${SHOW_EQUALS:+\"}"
+ fi
+ esac
+ shift 1
+done
diff --git a/usr.sbin/sysrc/sysrc.8 b/usr.sbin/sysrc/sysrc.8
new file mode 100644
index 0000000..43ba885
--- /dev/null
+++ b/usr.sbin/sysrc/sysrc.8
@@ -0,0 +1,301 @@
+.\" Copyright (c) 2011-2012 Devin Teske
+.\" All rights reserved.
+.\"
+.\" Redistribution and use in source and binary forms, with or without
+.\" modification, are permitted provided that the following conditions
+.\" are met:
+.\" 1. Redistributions of source code must retain the above copyright
+.\" notice, this list of conditions and the following disclaimer.
+.\" 2. Redistributions in binary form must reproduce the above copyright
+.\" notice, this list of conditions and the following disclaimer in the
+.\" documentation and/or other materials provided with the distribution.
+.\"
+.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+.\" SUCH DAMAGE.
+.\"
+.\" $FreeBSD$
+.\"
+.Dd Aug 24, 2012
+.Dt SYSRC 8
+.Os
+.Sh NAME
+.Nm sysrc
+.Nd safely edit system rc files
+.Sh SYNOPSIS
+.Nm
+.Op Fl dDeFhinNqvx
+.Op Fl f Ar file
+.Op Fl j Ar jail | Fl R Ar dir
+.Ar name Ns Op = Ns Ar value
+.Ar ...
+.Nm
+.Op Fl dDeFhinNqvx
+.Op Fl f Ar file
+.Op Fl j Ar jail | Fl R Ar dir
+.Fl a | A
+.Sh DESCRIPTION
+The
+.Nm
+utility retrieves
+.Xr rc.conf 5
+variables from the collection of system rc files and allows processes with
+appropriate privilege to change values in a safe and effective manner.
+.Pp
+The following options are available:
+.Bl -tag -width indent+
+.It Fl a
+Dump a list of all non-default configuration variables.
+.It Fl A
+Dump a list of all configuration variables
+.Pq incl. defaults .
+.It Fl d
+Print a description of the given variable.
+.It Fl D
+Show default value(s) only (this is the same as setting RC_CONFS to NULL or
+passing `-f' with a NULL file-argument).
+.It Fl e
+Print query results as
+.Ql var=value
+.Pq useful for producing output to be fed back in .
+Ignored if
+.Fl n
+is specified.
+.It Fl f Ar file
+Operate on the specified file(s) instead of the files obtained by reading the
+.Sq rc_conf_files
+entry in the
+.Ev RC_DEFAULTS
+file.
+This option can be specified multiple times for additional files.
+.It Fl F
+Show only the last
+.Xr rc.conf 5
+file each directive is in.
+.It Fl h
+Print a short usage message to stderr and exit.
+.It Fl -help
+Print a full usage statement to stderr and exit.
+.It Fl i
+Ignore unknown variables.
+.It Fl j Ar jail
+The
+.Ar jid
+or name of the
+.Ar jail
+to operate within
+.Pq overrides So Fl R Ar dir Sc ; requires Xr jexec 8 .
+.It Fl n
+Show only variable values, not their names.
+.It Fl N
+Show only variable names, not their values.
+.It Fl q
+Quiet.
+Ignore previous
+.Fl v
+and/or
+.Ev SYSRC_VERBOSE .
+.It Fl R Ar dir
+Operate within the root directory
+.Pq Sq Ar dir
+rather than
+.Pq Sq / .
+.It Fl v
+Verbose.
+Print the pathname of the specific
+.Xr rc.conf 5
+file where the directive was found.
+.It Fl x
+Remove variable(s) from specified file(s).
+.El
+.Pp
+This utility works similar to
+.Xr sysctl 8 .
+It shares the `-e' and `-n' options
+.Pq detailed above
+and also has the same
+.Ql name[=value]
+syntax for querying/setting configuration options.
+.Pp
+However, while
+.Xr sysctl 8
+serves to query/modify MIBs in the entrant kernel,
+.Nm
+instead works on values in the system
+.Xr rc.conf 5
+configuration files.
+.Pp
+The list of system configuration files is configured in the file
+.Ql /etc/defaults/rc.conf
+within the variable
+.Ql rc_conf_files ,
+which by-default contains a space-separated list of pathnames.
+On all FreeBSD
+systems, this defaults to the value "/etc/rc.conf /etc/rc.conf.local".
+Each
+pathname is sourced in-order upon startup.
+It is in the same fashion that
+.Nm
+sources the configuration files before returning the value of the given
+variable.
+.Pp
+When supplied a variable name,
+.Nm
+will return the value of the variable.
+If the variable does not appear in any
+of the configured
+.Ql rc_conf_files ,
+an error is printed and error status is returned.
+.Pp
+When changing values of a given variable, it does not matter if the variable
+appears in any of the
+.Ql rc_conf_files
+or not.
+If the variable does not appear in any of the files, it is appended to
+the end of the first pathname in the
+.Ql rc_conf_files
+variable.
+Otherwise,
+.Nm
+will replace only the last-occurrence in the last-file found to contain the
+variable.
+This gets the value to take effect next boot without heavily
+modifying these integral files (yet taking care not to allow the file to
+grow unwieldy should
+.Nm
+be called repeatedly).
+.Sh ENVIRONMENT
+The following environment variables are referenced by
+.Nm :
+.Bl -tag -width ".Ev SYSRC_VERBOSE"
+.It Ev RC_CONFS
+Override default
+.Ql rc_conf_files
+.Pq even if set to NULL .
+.It Ev RC_DEFAULTS
+Location of
+.Ql /etc/defaults/rc.conf
+file.
+.It Ev SYSRC_VERBOSE
+Default verbosity.
+Set to non-NULL to enable.
+.El
+.Sh DEPENDENCIES
+The following standard commands are required by
+.Nm :
+.Pp
+.Xr awk 1 ,
+.Xr cat 1 ,
+.Xr chmod 1 ,
+.Xr env 1 ,
+.Xr grep 1 ,
+.Xr jls 1 ,
+.Xr mktemp 1 ,
+.Xr mv 1 ,
+.Xr rm 1 ,
+.Xr sh 1 ,
+.Xr stat 1 ,
+.Xr tail 1 ,
+.Xr chown 8
+and
+.Xr jexec 8 .
+.Sh FILES
+.Bl -tag -width ".Pa /etc/defaults/rc.conf" -compact
+.It Pa /etc/defaults/rc.conf
+.It Pa /etc/rc.conf
+.It Pa /etc/rc.conf.local
+.El
+.Sh EXAMPLES
+Below are some simple examples of how
+.Nm
+can be used to query certain values from the
+.Xr rc.conf 5
+collection of system configuration files:
+.Pp
+.Nm
+sshd_enable
+.Dl returns the value of $sshd_enable, usually YES or NO .
+.Pp
+.Nm
+defaultrouter
+.Dl returns IP address of default router Pq if configured .
+.Pp
+Working on other files, such as
+.Xr crontab 5 :
+.Pp
+.Nm
+-f /etc/crontab MAILTO
+.Dl returns the value of the MAILTO setting Pq if configured .
+.Pp
+In addition to the above syntax,
+.Nm
+also supports inline
+.Xr sh 1
+PARAMETER expansion for changing the way values are reported, shown below:
+.Pp
+.Nm
+\&'hostname%%.*'
+.Dl returns $hostname up to (but not including) first `.' .
+.Pp
+.Nm
+\&'network_interfaces%%[$IFS]*'
+.Dl returns first word of $network_interfaces .
+.Pp
+.Nm
+\&'ntpdate_flags##*[$IFS]'
+.Dl returns last word of $ntpdate_flags (time server address) .
+.Pp
+.Nm
+usbd_flags-"default"
+.Dl returns $usbd_flags or "default" if unset or NULL .
+.Pp
+.Nm
+cloned_interfaces+"alternate"
+.Dl returns "alternate" if $cloned_interfaces is set .
+.Pp
+.Nm
+\&'#kern_securelevel'
+.Dl returns length in characters of $kern_securelevel .
+.Pp
+.Nm
+\&'hostname?'
+.Dl returns NULL and error status 2 if $hostname is unset Pq or if set, returns the value of $hostname with no error status .
+.Pp
+.Nm
+\&'hostname:?'
+.Dl returns NULL and error status 2 if $hostname is unset or NULL Pq or if set and non-NULL, returns value without error status .
+.Sh LIMITATIONS
+The
+.Nm
+utility presently does not support the
+.Ql rc.conf.d
+collection of system configuration files
+.Pq which requires a service name to be known during execution .
+.Pp
+This will be corrected by a future enhancement.
+.Sh SEE ALSO
+.Xr jls 1 ,
+.Xr rc.conf 5 ,
+.Xr jail 8 ,
+.Xr jexec 8 ,
+.Xr rc 8 ,
+.Xr sysctl 8
+.Sh HISTORY
+A
+.Nm
+utility first appeared in
+.Fx 10.0 .
+.Sh AUTHORS
+.An Devin Teske Aq dteske@FreeBSD.org
+.Sh THANKS TO
+Brandon Gooch, Garrett Cooper, Julian Elischer, Pawel Jakub Dawidek,
+Cyrille Lefevre, Ross West, Stefan Esser, Marco Steinbach, and Jilles Tjoelker
+for suggestions and help.
diff --git a/usr.sbin/tcpdchk/Makefile.depend b/usr.sbin/tcpdchk/Makefile.depend
new file mode 100644
index 0000000..b30ae55
--- /dev/null
+++ b/usr.sbin/tcpdchk/Makefile.depend
@@ -0,0 +1,21 @@
+# Autogenerated - do NOT edit!
+
+DEP_RELDIR := ${_PARSEDIR:S,${SRCTOP}/,,}
+
+DEP_MACHINE := ${.PARSEFILE:E}
+
+DIRDEPS = \
+ gnu/lib/libgcc \
+ include \
+ include/arpa \
+ include/xlocale \
+ lib/${CSU_DIR} \
+ lib/libc \
+ lib/libwrap \
+
+
+.include <dirdeps.mk>
+
+.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+# local dependencies - needed for -jN in clean tree
+.endif
diff --git a/usr.sbin/tcpdmatch/Makefile.depend b/usr.sbin/tcpdmatch/Makefile.depend
new file mode 100644
index 0000000..b30ae55
--- /dev/null
+++ b/usr.sbin/tcpdmatch/Makefile.depend
@@ -0,0 +1,21 @@
+# Autogenerated - do NOT edit!
+
+DEP_RELDIR := ${_PARSEDIR:S,${SRCTOP}/,,}
+
+DEP_MACHINE := ${.PARSEFILE:E}
+
+DIRDEPS = \
+ gnu/lib/libgcc \
+ include \
+ include/arpa \
+ include/xlocale \
+ lib/${CSU_DIR} \
+ lib/libc \
+ lib/libwrap \
+
+
+.include <dirdeps.mk>
+
+.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+# local dependencies - needed for -jN in clean tree
+.endif
diff --git a/usr.sbin/tcpdrop/Makefile.depend b/usr.sbin/tcpdrop/Makefile.depend
new file mode 100644
index 0000000..a839545
--- /dev/null
+++ b/usr.sbin/tcpdrop/Makefile.depend
@@ -0,0 +1,19 @@
+# Autogenerated - do NOT edit!
+
+DEP_RELDIR := ${_PARSEDIR:S,${SRCTOP}/,,}
+
+DEP_MACHINE := ${.PARSEFILE:E}
+
+DIRDEPS = \
+ gnu/lib/libgcc \
+ include \
+ include/xlocale \
+ lib/${CSU_DIR} \
+ lib/libc \
+
+
+.include <dirdeps.mk>
+
+.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+# local dependencies - needed for -jN in clean tree
+.endif
diff --git a/usr.sbin/tcpdump/tcpdump/Makefile b/usr.sbin/tcpdump/tcpdump/Makefile
index 84fa1f6..ca8ec4c 100644
--- a/usr.sbin/tcpdump/tcpdump/Makefile
+++ b/usr.sbin/tcpdump/tcpdump/Makefile
@@ -25,6 +25,7 @@ SRCS = addrtoname.c af.c checksum.c cpack.c gmpls.c oui.c gmt2local.c \
print-lwapp.c print-lwres.c print-mobile.c print-mpls.c print-msdp.c \
print-mpcp.c \
print-nfs.c print-ntp.c print-null.c print-olsr.c print-ospf.c \
+ print-pfsync.c \
print-pgm.c print-pim.c print-ppi.c print-ppp.c print-pppoe.c \
print-pptp.c print-radius.c print-raw.c print-rip.c \
print-rpki-rtr.c \
@@ -32,7 +33,8 @@ SRCS = addrtoname.c af.c checksum.c cpack.c gmpls.c oui.c gmt2local.c \
print-sip.c print-sl.c print-sll.c \
print-slow.c print-snmp.c print-stp.c print-sunatm.c print-sunrpc.c \
print-symantec.c print-syslog.c print-tcp.c print-telnet.c print-tftp.c \
- print-timed.c print-token.c print-udld.c print-udp.c print-vjc.c \
+ print-timed.c print-tipc.c \
+ print-token.c print-udld.c print-udp.c print-vjc.c \
print-vqp.c print-vrrp.c print-vtp.c \
print-wb.c print-zephyr.c setsignal.c tcpdump.c util.c \
print-smb.c signature.c smbutil.c \
diff --git a/usr.sbin/tcpdump/tcpdump/Makefile.depend b/usr.sbin/tcpdump/tcpdump/Makefile.depend
new file mode 100644
index 0000000..02177cb
--- /dev/null
+++ b/usr.sbin/tcpdump/tcpdump/Makefile.depend
@@ -0,0 +1,25 @@
+# Autogenerated - do NOT edit!
+
+DEP_RELDIR := ${_PARSEDIR:S,${SRCTOP}/,,}
+
+DEP_MACHINE := ${.PARSEFILE:E}
+
+DIRDEPS = \
+ gnu/lib/libgcc \
+ include \
+ include/arpa \
+ include/rpc \
+ include/xlocale \
+ lib/${CSU_DIR} \
+ lib/libc \
+ lib/libpcap \
+ secure/lib/libcrypto \
+
+
+.include <dirdeps.mk>
+
+.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+# local dependencies - needed for -jN in clean tree
+version.o: version.c
+version.po: version.c
+.endif
diff --git a/usr.sbin/tcpdump/tcpdump/tcpdump.1 b/usr.sbin/tcpdump/tcpdump/tcpdump.1
index 5034bb1..11706e7 100644
--- a/usr.sbin/tcpdump/tcpdump/tcpdump.1
+++ b/usr.sbin/tcpdump/tcpdump/tcpdump.1
@@ -201,7 +201,8 @@ Print the AS number in BGP packets in ASDOT notation rather than ASPLAIN
notation.
.TP
.B \-B
-Set the operating system capture buffer size to \fIbuffer_size\fP.
+Set the operating system capture buffer size to \fIbuffer_size\fP, in
+units of KiB (1024 bytes).
.TP
.B \-c
Exit after receiving \fIcount\fP packets.
@@ -276,7 +277,7 @@ The default is \fBdes-cbc\fP.
The ability to decrypt packets is only present if \fItcpdump\fP was compiled
with cryptography enabled.
.IP
-\fIsecret\fP is the ASCII text for ESP secret key.
+\fIsecret\fP is the ASCII text for ESP secret key.
If preceded by 0x, then a hex value will be read.
.IP
The option assumes RFC2406 ESP, not RFC1827 ESP.
@@ -288,7 +289,7 @@ you make it visible to others, via
and other occasions.
.IP
In addition to the above syntax, the syntax \fIfile name\fP may be used
-to have tcpdump read the provided file in. The file is opened upon
+to have tcpdump read the provided file in. The file is opened upon
receiving the first ESP packet, so any special permissions that tcpdump
may have been given should already have been given up.
.TP
@@ -393,9 +394,37 @@ Make stdout line buffered.
Useful if you want to see the data
while capturing it.
E.g.,
-.br
-``tcpdump\ \ \-l\ \ |\ \ tee dat'' or
-``tcpdump\ \ \-l \ \ > dat\ \ &\ \ tail\ \ \-f\ \ dat''.
+.IP
+.RS
+.RS
+.nf
+\fBtcpdump \-l | tee dat\fP
+.fi
+.RE
+.RE
+.IP
+or
+.IP
+.RS
+.RS
+.nf
+\fBtcpdump \-l > dat & tail \-f dat\fP
+.fi
+.RE
+.RE
+.IP
+Note that on Windows,``line buffered'' means ``unbuffered'', so that
+WinDump will write each character individually if
+.B \-l
+is specified.
+.IP
+.B \-U
+is similar to
+.B \-l
+in its behavior, but it will cause output to be ``packet-buffered'', so
+that the output is written to stdout at the end of each packet rather
+than at the end of each line; this is buffered on all platforms,
+including Windows.
.TP
.B \-L
List the known data link types for the interface, in the specified mode,
@@ -512,11 +541,20 @@ on each dump line.
Print undecoded NFS handles.
.TP
.B \-U
-Make output saved via the
+If the
+.B \-w
+option is not specified, make the printed packet output
+``packet-buffered''; i.e., as the description of the contents of each
+packet is printed, it will be written to the standard output, rather
+than, when not writing to a terminal, being written only when the output
+buffer fills.
+.IP
+If the
.B \-w
-option ``packet-buffered''; i.e., as each packet is saved, it will be
-written to the output file, rather than being written only when the
-output buffer fills.
+option is specified, make the saved raw packet output
+``packet-buffered''; i.e., as each packet is saved, it will be written
+to the output file, rather than being written only when the output
+buffer fills.
.IP
The
.B \-U
@@ -558,21 +596,28 @@ Write the raw packets to \fIfile\fR rather than parsing and printing
them out.
They can later be printed with the \-r option.
Standard output is used if \fIfile\fR is ``-''.
+.IP
+This output will be buffered if written to a file or pipe, so a program
+reading from the file or pipe may not see packets for an arbitrary
+amount of time after they are received. Use the
+.B \-U
+flag to cause packets to be written as soon as they are received.
+.IP
See
.BR pcap-savefile (5)
for a description of the file format.
.TP
.B \-W
-Used in conjunction with the
-.B \-C
+Used in conjunction with the
+.B \-C
option, this will limit the number
of files created to the specified number, and begin overwriting files
-from the beginning, thus creating a 'rotating' buffer.
+from the beginning, thus creating a 'rotating' buffer.
In addition, it will name
the files with enough leading 0s to support the maximum number of
files, allowing them to sort correctly.
.IP
-Used in conjunction with the
+Used in conjunction with the
.B \-G
option, this will limit the number of rotated dump files that get
created, exiting with status 0 when reaching the limit. If used with
@@ -582,7 +627,7 @@ as well, the behavior will result in cyclical files per timeslice.
.B \-x
When parsing and printing,
in addition to printing the headers of each packet, print the data of
-each packet (minus its link level header) in hex.
+each packet (minus its link level header) in hex.
The smaller of the entire packet or
.I snaplen
bytes will be printed. Note that this is the entire link-layer
@@ -1181,7 +1226,7 @@ tcp-push, tcp-act, tcp-urg.
.PP
This can be demonstrated as:
.RS
-.B
+.B
tcpdump -i xl0 'tcp[tcpflags] & tcp-push != 0'
.RE
.PP
@@ -1436,11 +1481,11 @@ not be useful to people who are not familiar with the workings of
AFS and RX.
.LP
If the -v (verbose) flag is given twice, acknowledgement packets and
-additional header information is printed, such as the the RX call ID,
+additional header information is printed, such as the RX call ID,
call number, sequence number, serial number, and the RX packet flags.
.LP
If the -v flag is given twice, additional information is printed,
-such as the the RX call ID, serial number, and the RX packet flags.
+such as the RX call ID, serial number, and the RX packet flags.
The MTU negotiation information is also printed from RX ack packets.
.LP
If the -v flag is given three times, the security index and service id
diff --git a/usr.sbin/timed/timed/Makefile.depend b/usr.sbin/timed/timed/Makefile.depend
new file mode 100644
index 0000000..359f90d
--- /dev/null
+++ b/usr.sbin/timed/timed/Makefile.depend
@@ -0,0 +1,23 @@
+# Autogenerated - do NOT edit!
+
+DEP_RELDIR := ${_PARSEDIR:S,${SRCTOP}/,,}
+
+DEP_MACHINE := ${.PARSEFILE:E}
+
+DIRDEPS = \
+ gnu/lib/libgcc \
+ include \
+ include/arpa \
+ include/protocols \
+ include/xlocale \
+ lib/${CSU_DIR} \
+ lib/libc \
+ lib/libutil \
+ lib/msun \
+
+
+.include <dirdeps.mk>
+
+.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+# local dependencies - needed for -jN in clean tree
+.endif
diff --git a/usr.sbin/timed/timed/master.c b/usr.sbin/timed/timed/master.c
index a7d74ee..b64259b 100644
--- a/usr.sbin/timed/timed/master.c
+++ b/usr.sbin/timed/timed/master.c
@@ -85,7 +85,7 @@ master()
if (ntp->status == MASTER)
masterup(ntp);
}
- (void)gettimeofday(&ntime, 0);
+ (void)gettimeofday(&ntime, NULL);
pollingtime = ntime.tv_sec+3;
if (justquit)
polls = 0;
@@ -96,14 +96,14 @@ master()
* to update all timers.
*/
loop:
- (void)gettimeofday(&ntime, 0);
+ (void)gettimeofday(&ntime, NULL);
wait.tv_sec = pollingtime - ntime.tv_sec;
if (wait.tv_sec < 0)
wait.tv_sec = 0;
wait.tv_usec = 0;
msg = readmsg(TSP_ANY, ANYADDR, &wait, 0);
if (!msg) {
- (void)gettimeofday(&ntime, 0);
+ (void)gettimeofday(&ntime, NULL);
if (ntime.tv_sec >= pollingtime) {
pollingtime = ntime.tv_sec + SAMPLEINTVL;
get_goodgroup(0);
@@ -175,7 +175,7 @@ loop:
}
mchgdate(msg);
- (void)gettimeofday(&ntime, 0);
+ (void)gettimeofday(&ntime, NULL);
pollingtime = ntime.tv_sec + SAMPLEINTVL;
break;
@@ -203,7 +203,7 @@ loop:
}
mchgdate(msg);
- (void)gettimeofday(&ntime, 0);
+ (void)gettimeofday(&ntime, NULL);
pollingtime = ntime.tv_sec + SAMPLEINTVL;
break;
@@ -284,7 +284,7 @@ loop:
* do not want to call synch() while waiting
* to be killed!
*/
- (void)gettimeofday(&ntime, (struct timezone *)0);
+ (void)gettimeofday(&ntime, NULL);
pollingtime = ntime.tv_sec + SAMPLEINTVL;
break;
@@ -354,7 +354,7 @@ mchgdate(msg)
(void)strcpy(olddate, date());
/* adjust time for residence on the queue */
- (void)gettimeofday(&otime, 0);
+ (void)gettimeofday(&otime, NULL);
adj_msg_time(msg,&otime);
tmptv.tv_sec = msg->tsp_time.tv_sec;
@@ -368,11 +368,11 @@ mchgdate(msg)
synch(tvtomsround(ntime));
} else {
utx.ut_type = OLD_TIME;
- gettimeofday(&utx.ut_tv, NULL);
+ (void)gettimeofday(&utx.ut_tv, NULL);
pututxline(&utx);
(void)settimeofday(&tmptv, 0);
utx.ut_type = NEW_TIME;
- gettimeofday(&utx.ut_tv, NULL);
+ (void)gettimeofday(&utx.ut_tv, NULL);
pututxline(&utx);
spreadtime();
}
@@ -396,7 +396,7 @@ synch(mydelta)
if (slvcount > 0) {
if (trace)
fprintf(fd, "measurements starting at %s\n", date());
- (void)gettimeofday(&check, 0);
+ (void)gettimeofday(&check, NULL);
for (htp = self.l_fwd; htp != &self; htp = htp->l_fwd) {
if (htp->noanswer != 0) {
measure_status = measure(500, 100,
@@ -424,7 +424,7 @@ synch(mydelta)
} else {
htp->delta = measure_delta;
}
- (void)gettimeofday(&stop, 0);
+ (void)gettimeofday(&stop, NULL);
timevalsub(&stop, &stop, &check);
if (stop.tv_sec >= 1) {
if (trace)
@@ -437,7 +437,7 @@ synch(mydelta)
if (0 != readmsg(TSP_TRACEON,ANYADDR,
&wait,0))
traceon();
- (void)gettimeofday(&check, 0);
+ (void)gettimeofday(&check, NULL);
}
}
if (trace)
@@ -474,7 +474,7 @@ spreadtime()
for (htp = self.l_fwd; htp != &self; htp = htp->l_fwd) {
to.tsp_type = TSP_SETTIME;
(void)strcpy(to.tsp_name, hostname);
- (void)gettimeofday(&tmptv, 0);
+ (void)gettimeofday(&tmptv, NULL);
to.tsp_time.tv_sec = tmptv.tv_sec;
to.tsp_time.tv_usec = tmptv.tv_usec;
answer = acksend(&to, &htp->addr, htp->name,
@@ -732,7 +732,7 @@ masterup(net)
* we do not tell them to start using our time, before we have
* found a good master.
*/
- (void)gettimeofday(&net->slvwait, 0);
+ (void)gettimeofday(&net->slvwait, NULL);
}
void
@@ -755,12 +755,12 @@ newslave(msg)
* If we are stable, send our time to the slave.
* Do not go crazy if the date has been changed.
*/
- (void)gettimeofday(&now, 0);
+ (void)gettimeofday(&now, NULL);
if (now.tv_sec >= fromnet->slvwait.tv_sec+3
|| now.tv_sec < fromnet->slvwait.tv_sec) {
to.tsp_type = TSP_SETTIME;
(void)strcpy(to.tsp_name, hostname);
- (void)gettimeofday(&tmptv, 0);
+ (void)gettimeofday(&tmptv, NULL);
to.tsp_time.tv_sec = tmptv.tv_sec;
to.tsp_time.tv_usec = tmptv.tv_usec;
answer = acksend(&to, &htp->addr,
diff --git a/usr.sbin/timed/timed/measure.c b/usr.sbin/timed/timed/measure.c
index 7f14e79..81ab7c4 100644
--- a/usr.sbin/timed/timed/measure.c
+++ b/usr.sbin/timed/timed/measure.c
@@ -128,7 +128,7 @@ measure(maxmsec, wmsec, hname, addr, print)
FD_ZERO(&ready);
- (void)gettimeofday(&tdone, 0);
+ (void)gettimeofday(&tdone, NULL);
mstotvround(&tout, maxmsec);
timevaladd(&tdone, &tout); /* when we give up */
@@ -136,7 +136,7 @@ measure(maxmsec, wmsec, hname, addr, print)
rcvcount = 0;
while (rcvcount < MSGS) {
- (void)gettimeofday(&tcur, 0);
+ (void)gettimeofday(&tcur, NULL);
/*
* keep sending until we have sent the max
@@ -173,7 +173,7 @@ measure(maxmsec, wmsec, hname, addr, print)
FD_SET(sock_raw, &ready);
count = select(sock_raw+1, &ready, (fd_set *)0,
(fd_set *)0, &tout);
- (void)gettimeofday(&tcur, (struct timezone *)0);
+ (void)gettimeofday(&tcur, NULL);
if (count <= 0)
break;
diff --git a/usr.sbin/timed/timed/readmsg.c b/usr.sbin/timed/timed/readmsg.c
index 9bbb3d7..aca2dbe 100644
--- a/usr.sbin/timed/timed/readmsg.c
+++ b/usr.sbin/timed/timed/readmsg.c
@@ -168,11 +168,11 @@ again:
* right one, return it, otherwise insert it in the linked list.
*/
- (void)gettimeofday(&rtout, 0);
+ (void)gettimeofday(&rtout, NULL);
timevaladd(&rtout, intvl);
FD_ZERO(&ready);
for (;;) {
- (void)gettimeofday(&rtime, 0);
+ (void)gettimeofday(&rtime, NULL);
timevalsub(&rwait, &rtout, &rtime);
if (rwait.tv_sec < 0)
rwait.tv_sec = rwait.tv_usec = 0;
@@ -219,7 +219,7 @@ again:
inet_ntoa(from.sin_addr));
continue;
}
- (void)gettimeofday(&from_when, (struct timezone *)0);
+ (void)gettimeofday(&from_when, NULL);
bytehostorder(&msgin);
if (msgin.tsp_vers > TSPVERSION) {
diff --git a/usr.sbin/timed/timed/slave.c b/usr.sbin/timed/timed/slave.c
index 9076d17..26e34f7 100644
--- a/usr.sbin/timed/timed/slave.c
+++ b/usr.sbin/timed/timed/slave.c
@@ -83,7 +83,7 @@ slave()
refusetime = 0;
adjtime = 0;
- (void)gettimeofday(&ntime, 0);
+ (void)gettimeofday(&ntime, NULL);
electiontime = ntime.tv_sec + delay2;
fastelection = ntime.tv_sec + FASTTOUT;
if (justquit)
@@ -103,7 +103,7 @@ slave()
loop:
get_goodgroup(0);
- (void)gettimeofday(&ntime, (struct timezone *)0);
+ (void)gettimeofday(&ntime, NULL);
if (ntime.tv_sec > electiontime) {
if (trace)
fprintf(fd, "election timer expired\n");
@@ -132,7 +132,7 @@ loop:
makeslave(slavenet); /* prune extras */
setstatus();
}
- (void)gettimeofday(&ntime, 0);
+ (void)gettimeofday(&ntime, NULL);
looktime = ntime.tv_sec + delay2;
}
if (ntime.tv_sec >= looptime) {
@@ -153,7 +153,7 @@ loop:
}
}
}
- (void)gettimeofday(&ntime, 0);
+ (void)gettimeofday(&ntime, NULL);
looptime = ntime.tv_sec + delay2;
}
@@ -225,7 +225,7 @@ loop:
* Otherwise the clocks can race until the loop
* is found.
*/
- (void)gettimeofday(&otime, 0);
+ (void)gettimeofday(&otime, NULL);
if (adjtime < otime.tv_sec)
looptime -= (looptime-otime.tv_sec)/2 + 1;
@@ -234,7 +234,7 @@ loop:
seq = msg->tsp_seq;
synch(tvtomsround(msg->tsp_time));
}
- (void)gettimeofday(&ntime, 0);
+ (void)gettimeofday(&ntime, NULL);
electiontime = ntime.tv_sec + delay2;
fastelection = ntime.tv_sec + FASTTOUT;
adjtime = ntime.tv_sec + SAMPLEINTVL*2;
@@ -248,7 +248,7 @@ loop:
seq = msg->tsp_seq;
/* adjust time for residence on the queue */
- (void)gettimeofday(&otime, 0);
+ (void)gettimeofday(&otime, NULL);
adj_msg_time(msg,&otime);
/*
* the following line is necessary due to syslog
@@ -289,7 +289,7 @@ loop:
if (status & MASTER)
spreadtime();
}
- (void)gettimeofday(&ntime, 0);
+ (void)gettimeofday(&ntime, NULL);
electiontime = ntime.tv_sec + delay2;
fastelection = ntime.tv_sec + FASTTOUT;
@@ -327,7 +327,7 @@ loop:
setstatus();
answerdelay();
xmit(TSP_SLAVEUP, 0, &from);
- (void)gettimeofday(&ntime, 0);
+ (void)gettimeofday(&ntime, NULL);
electiontime = ntime.tv_sec + delay2;
fastelection = ntime.tv_sec + FASTTOUT;
refusetime = 0;
@@ -336,7 +336,7 @@ loop:
case TSP_MASTERREQ:
if (fromnet->status != SLAVE)
break;
- (void)gettimeofday(&ntime, 0);
+ (void)gettimeofday(&ntime, NULL);
electiontime = ntime.tv_sec + delay2;
break;
@@ -381,7 +381,7 @@ loop:
case TSP_ELECTION:
if (fromnet->status == SLAVE) {
- (void)gettimeofday(&ntime, 0);
+ (void)gettimeofday(&ntime, NULL);
electiontime = ntime.tv_sec + delay2;
fastelection = ntime.tv_sec + FASTTOUT;
seq = 0;
@@ -538,7 +538,7 @@ loop:
electiontime = 0;
}
}
- (void)gettimeofday(&ntime, 0);
+ (void)gettimeofday(&ntime, NULL);
looptime = ntime.tv_sec + FASTTOUT;
} else {
if (msg->tsp_hopcnt-- < 1)
@@ -590,7 +590,7 @@ loop:
(void)remmach(htp);
}
}
- (void)gettimeofday(&ntime, 0);
+ (void)gettimeofday(&ntime, NULL);
looptime = ntime.tv_sec + FASTTOUT;
}
break;
@@ -660,7 +660,7 @@ schgdate(msg, newdate)
msg->tsp_name, newdate);
/* adjust time for residence on the queue */
- (void)gettimeofday(&otime, 0);
+ (void)gettimeofday(&otime, NULL);
adj_msg_time(msg, &otime);
to.tsp_type = TSP_SETDATEREQ;
diff --git a/usr.sbin/timed/timed/timed.c b/usr.sbin/timed/timed/timed.c
index 63d1a48..4b0030c 100644
--- a/usr.sbin/timed/timed/timed.c
+++ b/usr.sbin/timed/timed/timed.c
@@ -232,7 +232,7 @@ main(argc, argv)
}
/* choose a unique seed for random number generation */
- (void)gettimeofday(&ntime, 0);
+ (void)gettimeofday(&ntime, NULL);
srandom(ntime.tv_sec + ntime.tv_usec);
sequence = random(); /* initial seq number */
@@ -418,9 +418,10 @@ main(argc, argv)
justquit = 1;
}
for (ntp = nettab; ntp != NULL; ntp = ntp->next) {
- if (ntp->status == MASTER)
+ if (ntp->status == MASTER) {
rmnetmachs(ntp);
ntp->status = NOMASTER;
+ }
}
checkignorednets();
pickslavenet(0);
@@ -701,11 +702,9 @@ casual(inf, sup)
char *
date()
{
- struct timeval tv;
time_t tv_sec;
- (void)gettimeofday(&tv, (struct timezone *)0);
- tv_sec = tv.tv_sec;
+ tv_sec = time(NULL);
return (ctime(&tv_sec));
}
diff --git a/usr.sbin/timed/timedc/Makefile.depend b/usr.sbin/timed/timedc/Makefile.depend
new file mode 100644
index 0000000..083e419
--- /dev/null
+++ b/usr.sbin/timed/timedc/Makefile.depend
@@ -0,0 +1,21 @@
+# Autogenerated - do NOT edit!
+
+DEP_RELDIR := ${_PARSEDIR:S,${SRCTOP}/,,}
+
+DEP_MACHINE := ${.PARSEFILE:E}
+
+DIRDEPS = \
+ gnu/lib/libgcc \
+ include \
+ include/arpa \
+ include/protocols \
+ include/xlocale \
+ lib/${CSU_DIR} \
+ lib/libc \
+
+
+.include <dirdeps.mk>
+
+.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+# local dependencies - needed for -jN in clean tree
+.endif
diff --git a/usr.sbin/timed/timedc/cmds.c b/usr.sbin/timed/timedc/cmds.c
index b778b1a..84740f6 100644
--- a/usr.sbin/timed/timedc/cmds.c
+++ b/usr.sbin/timed/timedc/cmds.c
@@ -131,7 +131,7 @@ daydiff(hostname)
}
sec -= BU;
- (void)gettimeofday(&now, (struct timezone*)0);
+ (void)gettimeofday(&now, NULL);
return (sec - now.tv_sec);
}
}
diff --git a/usr.sbin/traceroute/Makefile.depend b/usr.sbin/traceroute/Makefile.depend
new file mode 100644
index 0000000..3c92034
--- /dev/null
+++ b/usr.sbin/traceroute/Makefile.depend
@@ -0,0 +1,23 @@
+# Autogenerated - do NOT edit!
+
+DEP_RELDIR := ${_PARSEDIR:S,${SRCTOP}/,,}
+
+DEP_MACHINE := ${.PARSEFILE:E}
+
+DIRDEPS = \
+ gnu/lib/libgcc \
+ include \
+ include/arpa \
+ include/xlocale \
+ lib/${CSU_DIR} \
+ lib/libc \
+ lib/libipsec \
+
+
+.include <dirdeps.mk>
+
+.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+# local dependencies - needed for -jN in clean tree
+version.o: version.c
+version.po: version.c
+.endif
diff --git a/usr.sbin/traceroute6/Makefile.depend b/usr.sbin/traceroute6/Makefile.depend
new file mode 100644
index 0000000..3b4bd93
--- /dev/null
+++ b/usr.sbin/traceroute6/Makefile.depend
@@ -0,0 +1,21 @@
+# Autogenerated - do NOT edit!
+
+DEP_RELDIR := ${_PARSEDIR:S,${SRCTOP}/,,}
+
+DEP_MACHINE := ${.PARSEFILE:E}
+
+DIRDEPS = \
+ gnu/lib/libgcc \
+ include \
+ include/arpa \
+ include/xlocale \
+ lib/${CSU_DIR} \
+ lib/libc \
+ lib/libipsec \
+
+
+.include <dirdeps.mk>
+
+.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+# local dependencies - needed for -jN in clean tree
+.endif
diff --git a/usr.sbin/trpt/Makefile.depend b/usr.sbin/trpt/Makefile.depend
new file mode 100644
index 0000000..16b5e42
--- /dev/null
+++ b/usr.sbin/trpt/Makefile.depend
@@ -0,0 +1,20 @@
+# Autogenerated - do NOT edit!
+
+DEP_RELDIR := ${_PARSEDIR:S,${SRCTOP}/,,}
+
+DEP_MACHINE := ${.PARSEFILE:E}
+
+DIRDEPS = \
+ gnu/lib/libgcc \
+ include \
+ include/arpa \
+ include/xlocale \
+ lib/${CSU_DIR} \
+ lib/libc \
+
+
+.include <dirdeps.mk>
+
+.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+# local dependencies - needed for -jN in clean tree
+.endif
diff --git a/usr.sbin/tzsetup/Makefile.depend b/usr.sbin/tzsetup/Makefile.depend
new file mode 100644
index 0000000..3f1092b
--- /dev/null
+++ b/usr.sbin/tzsetup/Makefile.depend
@@ -0,0 +1,22 @@
+# Autogenerated - do NOT edit!
+
+DEP_RELDIR := ${_PARSEDIR:S,${SRCTOP}/,,}
+
+DEP_MACHINE := ${.PARSEFILE:E}
+
+DIRDEPS = \
+ gnu/lib/libdialog \
+ gnu/lib/libgcc \
+ include \
+ include/xlocale \
+ lib/${CSU_DIR} \
+ lib/libc \
+ lib/msun \
+ lib/ncurses/ncursesw \
+
+
+.include <dirdeps.mk>
+
+.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+# local dependencies - needed for -jN in clean tree
+.endif
diff --git a/usr.sbin/uathload/Makefile.depend b/usr.sbin/uathload/Makefile.depend
new file mode 100644
index 0000000..a839545
--- /dev/null
+++ b/usr.sbin/uathload/Makefile.depend
@@ -0,0 +1,19 @@
+# Autogenerated - do NOT edit!
+
+DEP_RELDIR := ${_PARSEDIR:S,${SRCTOP}/,,}
+
+DEP_MACHINE := ${.PARSEFILE:E}
+
+DIRDEPS = \
+ gnu/lib/libgcc \
+ include \
+ include/xlocale \
+ lib/${CSU_DIR} \
+ lib/libc \
+
+
+.include <dirdeps.mk>
+
+.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+# local dependencies - needed for -jN in clean tree
+.endif
diff --git a/usr.sbin/ugidfw/Makefile.depend b/usr.sbin/ugidfw/Makefile.depend
new file mode 100644
index 0000000..2b665a8
--- /dev/null
+++ b/usr.sbin/ugidfw/Makefile.depend
@@ -0,0 +1,20 @@
+# Autogenerated - do NOT edit!
+
+DEP_RELDIR := ${_PARSEDIR:S,${SRCTOP}/,,}
+
+DEP_MACHINE := ${.PARSEFILE:E}
+
+DIRDEPS = \
+ gnu/lib/libgcc \
+ include \
+ include/xlocale \
+ lib/${CSU_DIR} \
+ lib/libc \
+ lib/libugidfw \
+
+
+.include <dirdeps.mk>
+
+.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+# local dependencies - needed for -jN in clean tree
+.endif
diff --git a/usr.sbin/uhsoctl/Makefile.depend b/usr.sbin/uhsoctl/Makefile.depend
new file mode 100644
index 0000000..c262920
--- /dev/null
+++ b/usr.sbin/uhsoctl/Makefile.depend
@@ -0,0 +1,21 @@
+# Autogenerated - do NOT edit!
+
+DEP_RELDIR := ${_PARSEDIR:S,${SRCTOP}/,,}
+
+DEP_MACHINE := ${.PARSEFILE:E}
+
+DIRDEPS = \
+ gnu/lib/libgcc \
+ include \
+ include/arpa \
+ include/xlocale \
+ lib/${CSU_DIR} \
+ lib/libc \
+ lib/libutil \
+
+
+.include <dirdeps.mk>
+
+.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+# local dependencies - needed for -jN in clean tree
+.endif
diff --git a/usr.sbin/usbconfig/Makefile.depend b/usr.sbin/usbconfig/Makefile.depend
new file mode 100644
index 0000000..f779151
--- /dev/null
+++ b/usr.sbin/usbconfig/Makefile.depend
@@ -0,0 +1,20 @@
+# Autogenerated - do NOT edit!
+
+DEP_RELDIR := ${_PARSEDIR:S,${SRCTOP}/,,}
+
+DEP_MACHINE := ${.PARSEFILE:E}
+
+DIRDEPS = \
+ gnu/lib/libgcc \
+ include \
+ include/xlocale \
+ lib/${CSU_DIR} \
+ lib/libc \
+ lib/libusb \
+
+
+.include <dirdeps.mk>
+
+.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+# local dependencies - needed for -jN in clean tree
+.endif
diff --git a/usr.sbin/usbdump/Makefile.depend b/usr.sbin/usbdump/Makefile.depend
new file mode 100644
index 0000000..a839545
--- /dev/null
+++ b/usr.sbin/usbdump/Makefile.depend
@@ -0,0 +1,19 @@
+# Autogenerated - do NOT edit!
+
+DEP_RELDIR := ${_PARSEDIR:S,${SRCTOP}/,,}
+
+DEP_MACHINE := ${.PARSEFILE:E}
+
+DIRDEPS = \
+ gnu/lib/libgcc \
+ include \
+ include/xlocale \
+ lib/${CSU_DIR} \
+ lib/libc \
+
+
+.include <dirdeps.mk>
+
+.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+# local dependencies - needed for -jN in clean tree
+.endif
diff --git a/usr.sbin/usbdump/usbdump.c b/usr.sbin/usbdump/usbdump.c
index 1e8d171..7e7eae9 100644
--- a/usr.sbin/usbdump/usbdump.c
+++ b/usr.sbin/usbdump/usbdump.c
@@ -795,6 +795,8 @@ main(int argc, char *argv[])
int o;
int filt_unit;
int filt_ep;
+ int s;
+ int ifindex;
const char *optstring;
char *pp;
@@ -887,9 +889,20 @@ main(int argc, char *argv[])
/* clear ifr structure */
memset(&ifr, 0, sizeof(ifr));
+ /* Try to create usbusN interface if it is not available. */
+ s = socket(AF_LOCAL, SOCK_DGRAM, 0);
+ if (s < 0)
+ errx(EXIT_FAILURE, "Could not open a socket");
+ ifindex = if_nametoindex(i_arg);
+ if (ifindex == 0) {
+ (void)strlcpy(ifr.ifr_name, i_arg, sizeof(ifr.ifr_name));
+ if (ioctl(s, SIOCIFCREATE2, &ifr) < 0)
+ errx(EXIT_FAILURE, "Invalid bus interface: %s", i_arg);
+ }
+
for ( ; v >= USBPF_HDR_LEN; v >>= 1) {
(void)ioctl(fd, BIOCSBLEN, (caddr_t)&v);
- (void)strncpy(ifr.ifr_name, i_arg, sizeof(ifr.ifr_name));
+ (void)strlcpy(ifr.ifr_name, i_arg, sizeof(ifr.ifr_name));
if (ioctl(fd, BIOCSETIF, (caddr_t)&ifr) >= 0)
break;
}
@@ -930,6 +943,17 @@ main(int argc, char *argv[])
printf("%d packets received by filter\n", us.bs_recv);
printf("%d packets dropped by kernel\n", us.bs_drop);
+ /*
+ * Destroy the usbusN interface only if it was created by
+ * usbdump(8). Ignore when it was already destroyed.
+ */
+ if (ifindex == 0 && if_nametoindex(i_arg) > 0) {
+ (void)strlcpy(ifr.ifr_name, i_arg, sizeof(ifr.ifr_name));
+ if (ioctl(s, SIOCIFDESTROY, &ifr) < 0)
+ warn("SIOCIFDESTROY ioctl failed");
+ }
+ close(s);
+
if (p->fd > 0)
close(p->fd);
if (p->rfd > 0)
diff --git a/usr.sbin/utx/Makefile.depend b/usr.sbin/utx/Makefile.depend
new file mode 100644
index 0000000..a839545
--- /dev/null
+++ b/usr.sbin/utx/Makefile.depend
@@ -0,0 +1,19 @@
+# Autogenerated - do NOT edit!
+
+DEP_RELDIR := ${_PARSEDIR:S,${SRCTOP}/,,}
+
+DEP_MACHINE := ${.PARSEFILE:E}
+
+DIRDEPS = \
+ gnu/lib/libgcc \
+ include \
+ include/xlocale \
+ lib/${CSU_DIR} \
+ lib/libc \
+
+
+.include <dirdeps.mk>
+
+.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+# local dependencies - needed for -jN in clean tree
+.endif
diff --git a/usr.sbin/vidcontrol/Makefile.depend b/usr.sbin/vidcontrol/Makefile.depend
new file mode 100644
index 0000000..a839545
--- /dev/null
+++ b/usr.sbin/vidcontrol/Makefile.depend
@@ -0,0 +1,19 @@
+# Autogenerated - do NOT edit!
+
+DEP_RELDIR := ${_PARSEDIR:S,${SRCTOP}/,,}
+
+DEP_MACHINE := ${.PARSEFILE:E}
+
+DIRDEPS = \
+ gnu/lib/libgcc \
+ include \
+ include/xlocale \
+ lib/${CSU_DIR} \
+ lib/libc \
+
+
+.include <dirdeps.mk>
+
+.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+# local dependencies - needed for -jN in clean tree
+.endif
diff --git a/usr.sbin/vidcontrol/vidcontrol.c b/usr.sbin/vidcontrol/vidcontrol.c
index b2e41bf..d07f892 100644
--- a/usr.sbin/vidcontrol/vidcontrol.c
+++ b/usr.sbin/vidcontrol/vidcontrol.c
@@ -70,7 +70,7 @@ static const char *legal_colors[16] = {
"lightred", "lightmagenta", "yellow", "lightwhite"
};
-struct {
+static struct {
int active_vty;
vid_info_t console_info;
unsigned char screen_map[256];
@@ -1192,15 +1192,13 @@ set_terminal_mode(char *arg)
fprintf(stderr, "\033[=T");
else if (strcmp(arg, "cons25") == 0)
fprintf(stderr, "\033[=1T");
- else
- usage();
}
int
main(int argc, char **argv)
{
- char *font, *type;
+ char *font, *type, *termmode;
int dumpmod, dumpopt, opt;
int reterr;
@@ -1212,6 +1210,7 @@ main(int argc, char **argv)
err(1, "must be on a virtual console");
dumpmod = 0;
dumpopt = DUMP_FBF;
+ termmode = NULL;
while ((opt = getopt(argc, argv,
"b:Cc:df:g:h:Hi:l:LM:m:pPr:S:s:T:t:x")) != -1)
switch(opt) {
@@ -1283,7 +1282,10 @@ main(int argc, char **argv)
set_console(optarg);
break;
case 'T':
- set_terminal_mode(optarg);
+ if (strcmp(optarg, "xterm") != 0 &&
+ strcmp(optarg, "cons25") != 0)
+ usage();
+ termmode = optarg;
break;
case 't':
set_screensaver_timeout(optarg);
@@ -1306,6 +1308,8 @@ main(int argc, char **argv)
}
video_mode(argc, argv, &optind);
+ if (termmode != NULL)
+ set_terminal_mode(termmode);
get_normal_colors(argc, argv, &optind);
diff --git a/usr.sbin/vipw/Makefile.depend b/usr.sbin/vipw/Makefile.depend
new file mode 100644
index 0000000..2dd29af
--- /dev/null
+++ b/usr.sbin/vipw/Makefile.depend
@@ -0,0 +1,20 @@
+# Autogenerated - do NOT edit!
+
+DEP_RELDIR := ${_PARSEDIR:S,${SRCTOP}/,,}
+
+DEP_MACHINE := ${.PARSEFILE:E}
+
+DIRDEPS = \
+ gnu/lib/libgcc \
+ include \
+ include/xlocale \
+ lib/${CSU_DIR} \
+ lib/libc \
+ lib/libutil \
+
+
+.include <dirdeps.mk>
+
+.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+# local dependencies - needed for -jN in clean tree
+.endif
diff --git a/usr.sbin/wake/Makefile.depend b/usr.sbin/wake/Makefile.depend
new file mode 100644
index 0000000..a839545
--- /dev/null
+++ b/usr.sbin/wake/Makefile.depend
@@ -0,0 +1,19 @@
+# Autogenerated - do NOT edit!
+
+DEP_RELDIR := ${_PARSEDIR:S,${SRCTOP}/,,}
+
+DEP_MACHINE := ${.PARSEFILE:E}
+
+DIRDEPS = \
+ gnu/lib/libgcc \
+ include \
+ include/xlocale \
+ lib/${CSU_DIR} \
+ lib/libc \
+
+
+.include <dirdeps.mk>
+
+.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+# local dependencies - needed for -jN in clean tree
+.endif
diff --git a/usr.sbin/watch/Makefile.depend b/usr.sbin/watch/Makefile.depend
new file mode 100644
index 0000000..c74c89f
--- /dev/null
+++ b/usr.sbin/watch/Makefile.depend
@@ -0,0 +1,21 @@
+# Autogenerated - do NOT edit!
+
+DEP_RELDIR := ${_PARSEDIR:S,${SRCTOP}/,,}
+
+DEP_MACHINE := ${.PARSEFILE:E}
+
+DIRDEPS = \
+ gnu/lib/libgcc \
+ include \
+ include/xlocale \
+ lib/${CSU_DIR} \
+ lib/libc \
+ lib/ncurses/ncurses \
+ lib/ncurses/ncursesw \
+
+
+.include <dirdeps.mk>
+
+.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+# local dependencies - needed for -jN in clean tree
+.endif
diff --git a/usr.sbin/watchdogd/Makefile b/usr.sbin/watchdogd/Makefile
index be69d2b..5df7946 100644
--- a/usr.sbin/watchdogd/Makefile
+++ b/usr.sbin/watchdogd/Makefile
@@ -4,8 +4,8 @@ PROG= watchdogd
LINKS= ${BINDIR}/watchdogd ${BINDIR}/watchdog
MAN= watchdogd.8 watchdog.8
-LDADD= -lm -lutil
-DPADD= ${LIBM} ${LIBUTIL}
+LDADD= -lutil
+DPADD= ${LIBUTIL}
.include <bsd.prog.mk>
diff --git a/usr.sbin/watchdogd/Makefile.depend b/usr.sbin/watchdogd/Makefile.depend
new file mode 100644
index 0000000..8825ffd
--- /dev/null
+++ b/usr.sbin/watchdogd/Makefile.depend
@@ -0,0 +1,21 @@
+# Autogenerated - do NOT edit!
+
+DEP_RELDIR := ${_PARSEDIR:S,${SRCTOP}/,,}
+
+DEP_MACHINE := ${.PARSEFILE:E}
+
+DIRDEPS = \
+ gnu/lib/libgcc \
+ include \
+ include/xlocale \
+ lib/${CSU_DIR} \
+ lib/libc \
+ lib/libutil \
+ lib/msun \
+
+
+.include <dirdeps.mk>
+
+.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+# local dependencies - needed for -jN in clean tree
+.endif
diff --git a/usr.sbin/watchdogd/watchdogd.c b/usr.sbin/watchdogd/watchdogd.c
index 7bae4ff..8194f96 100644
--- a/usr.sbin/watchdogd/watchdogd.c
+++ b/usr.sbin/watchdogd/watchdogd.c
@@ -48,6 +48,7 @@ __FBSDID("$FreeBSD$");
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+#include <strings.h>
#include <sysexits.h>
#include <unistd.h>
@@ -118,6 +119,8 @@ main(int argc, char *argv[])
pidfile_write(pfh);
if (madvise(0, 0, MADV_PROTECT) != 0)
warn("madvise failed");
+ if (mlockall(MCL_CURRENT | MCL_FUTURE) != 0)
+ warn("mlockall failed");
watchdog_loop();
@@ -278,7 +281,7 @@ parseargs(int argc, char *argv[])
if (a == 0)
timeout = WD_TO_NEVER;
else
- timeout = 1.0 + log(a * 1e9) / log(2.0);
+ timeout = flsll(a * 1e9);
if (debugging)
printf("Timeout is 2^%d nanoseconds\n",
timeout);
diff --git a/usr.sbin/wlandebug/Makefile.depend b/usr.sbin/wlandebug/Makefile.depend
new file mode 100644
index 0000000..a839545
--- /dev/null
+++ b/usr.sbin/wlandebug/Makefile.depend
@@ -0,0 +1,19 @@
+# Autogenerated - do NOT edit!
+
+DEP_RELDIR := ${_PARSEDIR:S,${SRCTOP}/,,}
+
+DEP_MACHINE := ${.PARSEFILE:E}
+
+DIRDEPS = \
+ gnu/lib/libgcc \
+ include \
+ include/xlocale \
+ lib/${CSU_DIR} \
+ lib/libc \
+
+
+.include <dirdeps.mk>
+
+.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+# local dependencies - needed for -jN in clean tree
+.endif
diff --git a/usr.sbin/wlconfig/Makefile.depend b/usr.sbin/wlconfig/Makefile.depend
new file mode 100644
index 0000000..a839545
--- /dev/null
+++ b/usr.sbin/wlconfig/Makefile.depend
@@ -0,0 +1,19 @@
+# Autogenerated - do NOT edit!
+
+DEP_RELDIR := ${_PARSEDIR:S,${SRCTOP}/,,}
+
+DEP_MACHINE := ${.PARSEFILE:E}
+
+DIRDEPS = \
+ gnu/lib/libgcc \
+ include \
+ include/xlocale \
+ lib/${CSU_DIR} \
+ lib/libc \
+
+
+.include <dirdeps.mk>
+
+.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+# local dependencies - needed for -jN in clean tree
+.endif
diff --git a/usr.sbin/wpa/hostapd/Makefile.depend b/usr.sbin/wpa/hostapd/Makefile.depend
new file mode 100644
index 0000000..07fb89b
--- /dev/null
+++ b/usr.sbin/wpa/hostapd/Makefile.depend
@@ -0,0 +1,23 @@
+# Autogenerated - do NOT edit!
+
+DEP_RELDIR := ${_PARSEDIR:S,${SRCTOP}/,,}
+
+DEP_MACHINE := ${.PARSEFILE:E}
+
+DIRDEPS = \
+ gnu/lib/libgcc \
+ include \
+ include/arpa \
+ include/xlocale \
+ lib/${CSU_DIR} \
+ lib/libc \
+ lib/libpcap \
+ secure/lib/libcrypto \
+ secure/lib/libssl \
+
+
+.include <dirdeps.mk>
+
+.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+# local dependencies - needed for -jN in clean tree
+.endif
diff --git a/usr.sbin/wpa/hostapd/hostapd.8 b/usr.sbin/wpa/hostapd/hostapd.8
index 7be2cbf..f624cac 100644
--- a/usr.sbin/wpa/hostapd/hostapd.8
+++ b/usr.sbin/wpa/hostapd/hostapd.8
@@ -24,7 +24,7 @@
.\"
.\" $FreeBSD$
.\"
-.Dd October 26, 2007
+.Dd July 18, 2012
.Dt HOSTAPD 8
.Os
.Sh NAME
@@ -111,7 +111,9 @@ Store PID in
.Xr ath 4 ,
.Xr ipw 4 ,
.Xr iwi 4 ,
+.Xr mwl 4 ,
.Xr ral 4 ,
+.Xr rum 4 ,
.Xr run 4 ,
.Xr ural 4 ,
.Xr wi 4 ,
diff --git a/usr.sbin/wpa/hostapd_cli/Makefile.depend b/usr.sbin/wpa/hostapd_cli/Makefile.depend
new file mode 100644
index 0000000..16b5e42
--- /dev/null
+++ b/usr.sbin/wpa/hostapd_cli/Makefile.depend
@@ -0,0 +1,20 @@
+# Autogenerated - do NOT edit!
+
+DEP_RELDIR := ${_PARSEDIR:S,${SRCTOP}/,,}
+
+DEP_MACHINE := ${.PARSEFILE:E}
+
+DIRDEPS = \
+ gnu/lib/libgcc \
+ include \
+ include/arpa \
+ include/xlocale \
+ lib/${CSU_DIR} \
+ lib/libc \
+
+
+.include <dirdeps.mk>
+
+.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+# local dependencies - needed for -jN in clean tree
+.endif
diff --git a/usr.sbin/wpa/ndis_events/Makefile.depend b/usr.sbin/wpa/ndis_events/Makefile.depend
new file mode 100644
index 0000000..16b5e42
--- /dev/null
+++ b/usr.sbin/wpa/ndis_events/Makefile.depend
@@ -0,0 +1,20 @@
+# Autogenerated - do NOT edit!
+
+DEP_RELDIR := ${_PARSEDIR:S,${SRCTOP}/,,}
+
+DEP_MACHINE := ${.PARSEFILE:E}
+
+DIRDEPS = \
+ gnu/lib/libgcc \
+ include \
+ include/arpa \
+ include/xlocale \
+ lib/${CSU_DIR} \
+ lib/libc \
+
+
+.include <dirdeps.mk>
+
+.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+# local dependencies - needed for -jN in clean tree
+.endif
diff --git a/usr.sbin/wpa/wpa_cli/Makefile.depend b/usr.sbin/wpa/wpa_cli/Makefile.depend
new file mode 100644
index 0000000..5018218
--- /dev/null
+++ b/usr.sbin/wpa/wpa_cli/Makefile.depend
@@ -0,0 +1,23 @@
+# Autogenerated - do NOT edit!
+
+DEP_RELDIR := ${_PARSEDIR:S,${SRCTOP}/,,}
+
+DEP_MACHINE := ${.PARSEFILE:E}
+
+DIRDEPS = \
+ gnu/lib/libgcc \
+ include \
+ include/arpa \
+ include/xlocale \
+ lib/${CSU_DIR} \
+ lib/libc \
+ lib/libedit \
+ lib/libedit/edit/readline \
+ lib/ncurses/ncurses \
+
+
+.include <dirdeps.mk>
+
+.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+# local dependencies - needed for -jN in clean tree
+.endif
diff --git a/usr.sbin/wpa/wpa_passphrase/Makefile.depend b/usr.sbin/wpa/wpa_passphrase/Makefile.depend
new file mode 100644
index 0000000..16b5e42
--- /dev/null
+++ b/usr.sbin/wpa/wpa_passphrase/Makefile.depend
@@ -0,0 +1,20 @@
+# Autogenerated - do NOT edit!
+
+DEP_RELDIR := ${_PARSEDIR:S,${SRCTOP}/,,}
+
+DEP_MACHINE := ${.PARSEFILE:E}
+
+DIRDEPS = \
+ gnu/lib/libgcc \
+ include \
+ include/arpa \
+ include/xlocale \
+ lib/${CSU_DIR} \
+ lib/libc \
+
+
+.include <dirdeps.mk>
+
+.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+# local dependencies - needed for -jN in clean tree
+.endif
diff --git a/usr.sbin/wpa/wpa_supplicant/Makefile.depend b/usr.sbin/wpa/wpa_supplicant/Makefile.depend
new file mode 100644
index 0000000..07fb89b
--- /dev/null
+++ b/usr.sbin/wpa/wpa_supplicant/Makefile.depend
@@ -0,0 +1,23 @@
+# Autogenerated - do NOT edit!
+
+DEP_RELDIR := ${_PARSEDIR:S,${SRCTOP}/,,}
+
+DEP_MACHINE := ${.PARSEFILE:E}
+
+DIRDEPS = \
+ gnu/lib/libgcc \
+ include \
+ include/arpa \
+ include/xlocale \
+ lib/${CSU_DIR} \
+ lib/libc \
+ lib/libpcap \
+ secure/lib/libcrypto \
+ secure/lib/libssl \
+
+
+.include <dirdeps.mk>
+
+.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+# local dependencies - needed for -jN in clean tree
+.endif
diff --git a/usr.sbin/yp_mkdb/Makefile.depend b/usr.sbin/yp_mkdb/Makefile.depend
new file mode 100644
index 0000000..6e9b14f
--- /dev/null
+++ b/usr.sbin/yp_mkdb/Makefile.depend
@@ -0,0 +1,21 @@
+# Autogenerated - do NOT edit!
+
+DEP_RELDIR := ${_PARSEDIR:S,${SRCTOP}/,,}
+
+DEP_MACHINE := ${.PARSEFILE:E}
+
+DIRDEPS = \
+ gnu/lib/libgcc \
+ include \
+ include/rpc \
+ include/rpcsvc \
+ include/xlocale \
+ lib/${CSU_DIR} \
+ lib/libc \
+
+
+.include <dirdeps.mk>
+
+.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+# local dependencies - needed for -jN in clean tree
+.endif
diff --git a/usr.sbin/ypbind/Makefile.depend b/usr.sbin/ypbind/Makefile.depend
new file mode 100644
index 0000000..a3e1b44
--- /dev/null
+++ b/usr.sbin/ypbind/Makefile.depend
@@ -0,0 +1,22 @@
+# Autogenerated - do NOT edit!
+
+DEP_RELDIR := ${_PARSEDIR:S,${SRCTOP}/,,}
+
+DEP_MACHINE := ${.PARSEFILE:E}
+
+DIRDEPS = \
+ gnu/lib/libgcc \
+ include \
+ include/arpa \
+ include/rpc \
+ include/rpcsvc \
+ include/xlocale \
+ lib/${CSU_DIR} \
+ lib/libc \
+
+
+.include <dirdeps.mk>
+
+.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+# local dependencies - needed for -jN in clean tree
+.endif
diff --git a/usr.sbin/yppoll/Makefile.depend b/usr.sbin/yppoll/Makefile.depend
new file mode 100644
index 0000000..6e9b14f
--- /dev/null
+++ b/usr.sbin/yppoll/Makefile.depend
@@ -0,0 +1,21 @@
+# Autogenerated - do NOT edit!
+
+DEP_RELDIR := ${_PARSEDIR:S,${SRCTOP}/,,}
+
+DEP_MACHINE := ${.PARSEFILE:E}
+
+DIRDEPS = \
+ gnu/lib/libgcc \
+ include \
+ include/rpc \
+ include/rpcsvc \
+ include/xlocale \
+ lib/${CSU_DIR} \
+ lib/libc \
+
+
+.include <dirdeps.mk>
+
+.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+# local dependencies - needed for -jN in clean tree
+.endif
diff --git a/usr.sbin/yppush/Makefile.depend b/usr.sbin/yppush/Makefile.depend
new file mode 100644
index 0000000..ff4f7af
--- /dev/null
+++ b/usr.sbin/yppush/Makefile.depend
@@ -0,0 +1,29 @@
+# Autogenerated - do NOT edit!
+
+DEP_RELDIR := ${_PARSEDIR:S,${SRCTOP}/,,}
+
+DEP_MACHINE := ${.PARSEFILE:E}
+
+DIRDEPS = \
+ gnu/lib/libgcc \
+ include \
+ include/rpc \
+ include/rpcsvc \
+ include/xlocale \
+ lib/${CSU_DIR} \
+ lib/libc \
+
+
+.include <dirdeps.mk>
+
+.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+# local dependencies - needed for -jN in clean tree
+yp_clnt.o: yp.h
+yp_clnt.o: yp_clnt.c
+yp_clnt.po: yp.h
+yp_clnt.po: yp_clnt.c
+yppush_svc.o: yp.h
+yppush_svc.o: yppush_svc.c
+yppush_svc.po: yp.h
+yppush_svc.po: yppush_svc.c
+.endif
diff --git a/usr.sbin/ypserv/Makefile.depend b/usr.sbin/ypserv/Makefile.depend
new file mode 100644
index 0000000..c00e105
--- /dev/null
+++ b/usr.sbin/ypserv/Makefile.depend
@@ -0,0 +1,35 @@
+# Autogenerated - do NOT edit!
+
+DEP_RELDIR := ${_PARSEDIR:S,${SRCTOP}/,,}
+
+DEP_MACHINE := ${.PARSEFILE:E}
+
+DIRDEPS = \
+ gnu/lib/libgcc \
+ include \
+ include/arpa \
+ include/rpc \
+ include/rpcsvc \
+ include/xlocale \
+ lib/${CSU_DIR} \
+ lib/libc \
+ lib/libwrap \
+
+
+.include <dirdeps.mk>
+
+.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+# local dependencies - needed for -jN in clean tree
+yp_main.o: yp.h
+yp_main.po: yp.h
+yp_server.o: yp.h
+yp_server.po: yp.h
+yp_svc.o: yp.h
+yp_svc.o: yp_svc.c
+yp_svc.po: yp.h
+yp_svc.po: yp_svc.c
+ypxfr_clnt.o: yp.h
+ypxfr_clnt.o: ypxfr_clnt.c
+ypxfr_clnt.po: yp.h
+ypxfr_clnt.po: ypxfr_clnt.c
+.endif
diff --git a/usr.sbin/ypset/Makefile.depend b/usr.sbin/ypset/Makefile.depend
new file mode 100644
index 0000000..a3e1b44
--- /dev/null
+++ b/usr.sbin/ypset/Makefile.depend
@@ -0,0 +1,22 @@
+# Autogenerated - do NOT edit!
+
+DEP_RELDIR := ${_PARSEDIR:S,${SRCTOP}/,,}
+
+DEP_MACHINE := ${.PARSEFILE:E}
+
+DIRDEPS = \
+ gnu/lib/libgcc \
+ include \
+ include/arpa \
+ include/rpc \
+ include/rpcsvc \
+ include/xlocale \
+ lib/${CSU_DIR} \
+ lib/libc \
+
+
+.include <dirdeps.mk>
+
+.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+# local dependencies - needed for -jN in clean tree
+.endif
diff --git a/usr.sbin/zic/zdump/Makefile.depend b/usr.sbin/zic/zdump/Makefile.depend
new file mode 100644
index 0000000..a839545
--- /dev/null
+++ b/usr.sbin/zic/zdump/Makefile.depend
@@ -0,0 +1,19 @@
+# Autogenerated - do NOT edit!
+
+DEP_RELDIR := ${_PARSEDIR:S,${SRCTOP}/,,}
+
+DEP_MACHINE := ${.PARSEFILE:E}
+
+DIRDEPS = \
+ gnu/lib/libgcc \
+ include \
+ include/xlocale \
+ lib/${CSU_DIR} \
+ lib/libc \
+
+
+.include <dirdeps.mk>
+
+.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+# local dependencies - needed for -jN in clean tree
+.endif
diff --git a/usr.sbin/zic/zic/Makefile.depend b/usr.sbin/zic/zic/Makefile.depend
new file mode 100644
index 0000000..a839545
--- /dev/null
+++ b/usr.sbin/zic/zic/Makefile.depend
@@ -0,0 +1,19 @@
+# Autogenerated - do NOT edit!
+
+DEP_RELDIR := ${_PARSEDIR:S,${SRCTOP}/,,}
+
+DEP_MACHINE := ${.PARSEFILE:E}
+
+DIRDEPS = \
+ gnu/lib/libgcc \
+ include \
+ include/xlocale \
+ lib/${CSU_DIR} \
+ lib/libc \
+
+
+.include <dirdeps.mk>
+
+.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+# local dependencies - needed for -jN in clean tree
+.endif
diff --git a/usr.sbin/zzz/Makefile.depend b/usr.sbin/zzz/Makefile.depend
new file mode 100644
index 0000000..29fda55
--- /dev/null
+++ b/usr.sbin/zzz/Makefile.depend
@@ -0,0 +1,14 @@
+# Autogenerated - do NOT edit!
+
+DEP_RELDIR := ${_PARSEDIR:S,${SRCTOP}/,,}
+
+DEP_MACHINE := ${.PARSEFILE:E}
+
+DIRDEPS = \
+
+
+.include <dirdeps.mk>
+
+.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+# local dependencies - needed for -jN in clean tree
+.endif
OpenPOWER on IntegriCloud