summaryrefslogtreecommitdiffstats
path: root/usr.sbin
diff options
context:
space:
mode:
authormckusick <mckusick@FreeBSD.org>2010-04-28 05:33:59 +0000
committermckusick <mckusick@FreeBSD.org>2010-04-28 05:33:59 +0000
commit3a0f5972a0de87aebef1af257922515700da4217 (patch)
treea65d36ab57a1e076de7e7a1d78add642fbd7062e /usr.sbin
parentf40c3a9dc50f808e512fcc9f9f738717013b483b (diff)
parenta768cbcadec7189b9947e9f3cde39fe806bbc1d7 (diff)
downloadFreeBSD-src-3a0f5972a0de87aebef1af257922515700da4217.zip
FreeBSD-src-3a0f5972a0de87aebef1af257922515700da4217.tar.gz
Update to current version of head.
Diffstat (limited to 'usr.sbin')
-rw-r--r--usr.sbin/Makefile3
-rw-r--r--usr.sbin/ac/ac.c3
-rw-r--r--usr.sbin/acpi/acpidb/Makefile10
-rw-r--r--usr.sbin/acpi/iasl/Makefile6
-rw-r--r--usr.sbin/asf/asf.82
-rw-r--r--usr.sbin/bluetooth/bthidd/Makefile1
-rw-r--r--usr.sbin/bsnmpd/modules/Makefile.inc3
-rw-r--r--usr.sbin/bsnmpd/modules/snmp_pf/BEGEMOT-PF-MIB.txt151
-rw-r--r--usr.sbin/bsnmpd/modules/snmp_pf/Makefile1
-rw-r--r--usr.sbin/bsnmpd/modules/snmp_pf/pf_snmp.c577
-rw-r--r--usr.sbin/bsnmpd/modules/snmp_pf/pf_tree.def47
-rw-r--r--usr.sbin/burncd/burncd.82
-rw-r--r--usr.sbin/config/config.h2
-rw-r--r--usr.sbin/config/config.y10
-rw-r--r--usr.sbin/config/configvers.h2
-rw-r--r--usr.sbin/config/lang.l3
-rw-r--r--usr.sbin/config/main.c20
-rw-r--r--usr.sbin/config/mkmakefile.c4
-rw-r--r--usr.sbin/config/mkoptions.c37
-rw-r--r--usr.sbin/ctm/ctm/ctm.12
-rw-r--r--usr.sbin/ctm/ctm/ctm.52
-rw-r--r--usr.sbin/devinfo/devinfo.82
-rw-r--r--usr.sbin/fdformat/fdformat.12
-rw-r--r--usr.sbin/fdread/fdread.12
-rw-r--r--usr.sbin/fdwrite/fdwrite.12
-rw-r--r--usr.sbin/fifolog/fifolog_create/fifolog.12
-rw-r--r--usr.sbin/flowctl/flowctl.82
-rw-r--r--usr.sbin/freebsd-update/freebsd-update.82
-rw-r--r--usr.sbin/fwcontrol/Makefile2
-rw-r--r--usr.sbin/jail/jail.86
-rw-r--r--usr.sbin/jls/jls.c2
-rw-r--r--usr.sbin/lastlogin/lastlogin.82
-rw-r--r--usr.sbin/lastlogin/lastlogin.c29
-rw-r--r--usr.sbin/mailwrapper/mailwrapper.83
-rw-r--r--usr.sbin/mailwrapper/mailwrapper.c8
-rw-r--r--usr.sbin/makefs/ffs/ffs_bswap.c2
-rw-r--r--usr.sbin/mergemaster/mergemaster.815
-rwxr-xr-xusr.sbin/mergemaster/mergemaster.sh14
-rw-r--r--usr.sbin/mount_nwfs/Makefile1
-rw-r--r--usr.sbin/mount_nwfs/mount_nwfs.c20
-rw-r--r--usr.sbin/mtest/mtest.82
-rw-r--r--usr.sbin/mtree/compare.c6
-rw-r--r--usr.sbin/mtree/create.c4
-rw-r--r--usr.sbin/mtree/mtree.87
-rw-r--r--usr.sbin/periodic/periodic.82
-rw-r--r--usr.sbin/pkg_install/Makefile4
-rw-r--r--usr.sbin/pkg_install/Makefile.inc13
-rw-r--r--usr.sbin/pkg_install/add/Makefile7
-rw-r--r--usr.sbin/pkg_install/add/extract.c2
-rw-r--r--usr.sbin/pkg_install/add/futil.c4
-rw-r--r--usr.sbin/pkg_install/add/main.c4
-rw-r--r--usr.sbin/pkg_install/add/perform.c26
-rw-r--r--usr.sbin/pkg_install/create/Makefile6
-rw-r--r--usr.sbin/pkg_install/create/main.c4
-rw-r--r--usr.sbin/pkg_install/create/perform.c2
-rw-r--r--usr.sbin/pkg_install/create/pl.c2
-rw-r--r--usr.sbin/pkg_install/delete/Makefile5
-rw-r--r--usr.sbin/pkg_install/delete/main.c4
-rw-r--r--usr.sbin/pkg_install/delete/perform.c22
-rw-r--r--usr.sbin/pkg_install/info/Makefile6
-rw-r--r--usr.sbin/pkg_install/info/info.h39
-rw-r--r--usr.sbin/pkg_install/info/main.c14
-rw-r--r--usr.sbin/pkg_install/info/perform.c2
-rw-r--r--usr.sbin/pkg_install/info/show.c2
-rw-r--r--usr.sbin/pkg_install/lib/Makefile11
-rw-r--r--usr.sbin/pkg_install/lib/deps.c241
-rw-r--r--usr.sbin/pkg_install/lib/exec.c106
-rw-r--r--usr.sbin/pkg_install/lib/file.c427
-rw-r--r--usr.sbin/pkg_install/lib/global.c32
-rw-r--r--usr.sbin/pkg_install/lib/lib.h248
-rw-r--r--usr.sbin/pkg_install/lib/match.c603
-rw-r--r--usr.sbin/pkg_install/lib/msg.c75
-rw-r--r--usr.sbin/pkg_install/lib/pen.c190
-rw-r--r--usr.sbin/pkg_install/lib/pkgwrap.c89
-rw-r--r--usr.sbin/pkg_install/lib/plist.c592
-rw-r--r--usr.sbin/pkg_install/lib/str.c129
-rw-r--r--usr.sbin/pkg_install/lib/url.c167
-rw-r--r--usr.sbin/pkg_install/lib/version.c328
-rw-r--r--usr.sbin/pkg_install/updating/Makefile5
-rw-r--r--usr.sbin/pkg_install/updating/main.c4
-rw-r--r--usr.sbin/pkg_install/updating/pkg_updating.19
-rw-r--r--usr.sbin/pkg_install/version/Makefile5
-rw-r--r--usr.sbin/pkg_install/version/main.c4
-rw-r--r--usr.sbin/pkg_install/version/perform.c33
-rw-r--r--usr.sbin/pmcannotate/pmcannotate.83
-rw-r--r--usr.sbin/pmccontrol/pmccontrol.82
-rw-r--r--usr.sbin/pmcstat/pmcpl_callgraph.c5
-rw-r--r--usr.sbin/pmcstat/pmcpl_calltree.c33
-rw-r--r--usr.sbin/pmcstat/pmcpl_gprof.c2
-rw-r--r--usr.sbin/pmcstat/pmcstat.82
-rw-r--r--usr.sbin/pmcstat/pmcstat.c3
-rw-r--r--usr.sbin/pmcstat/pmcstat_log.c65
-rw-r--r--usr.sbin/pmcstat/pmcstat_log.h2
-rw-r--r--usr.sbin/powerd/powerd.82
-rw-r--r--usr.sbin/ppp/arp.c2
-rw-r--r--usr.sbin/pppctl/pppctl.82
-rw-r--r--usr.sbin/sade/disks.c7
-rw-r--r--usr.sbin/sade/menus.c23
-rw-r--r--usr.sbin/services_mkdb/Makefile10
-rw-r--r--usr.sbin/services_mkdb/services_mkdb.897
-rw-r--r--usr.sbin/services_mkdb/services_mkdb.c429
-rw-r--r--usr.sbin/services_mkdb/uniq.c159
-rw-r--r--usr.sbin/setfmac/setfsmac.82
-rw-r--r--usr.sbin/setpmac/setpmac.82
-rw-r--r--usr.sbin/sysinstall/devices.c1
-rw-r--r--usr.sbin/sysinstall/disks.c7
-rw-r--r--usr.sbin/sysinstall/menus.c40
-rw-r--r--usr.sbin/sysinstall/sysinstall.82
-rw-r--r--usr.sbin/sysinstall/tcpip.c2
-rw-r--r--usr.sbin/uhsoctl/Makefile2
-rw-r--r--usr.sbin/uhsoctl/uhsoctl.18
-rw-r--r--usr.sbin/vidcontrol/vidcontrol.c37
-rw-r--r--usr.sbin/wpa/wpa_supplicant/driver_freebsd.c13
-rw-r--r--usr.sbin/wpa/wpa_supplicant/wpa_supplicant.conf.524
-rw-r--r--usr.sbin/zic/Makefile1
115 files changed, 1915 insertions, 3567 deletions
diff --git a/usr.sbin/Makefile b/usr.sbin/Makefile
index cdcaaf3..c47ef76 100644
--- a/usr.sbin/Makefile
+++ b/usr.sbin/Makefile
@@ -3,7 +3,6 @@
.include <bsd.own.mk>
-# XXX MISSING: mkproto
SUBDIR= ${_ac} \
${_accton} \
${_acpi} \
@@ -168,6 +167,7 @@ SUBDIR= ${_ac} \
${_sade} \
${_sendmail} \
service \
+ services_mkdb \
setfib \
setfmac \
setpmac \
@@ -302,7 +302,6 @@ _jls= jls
.endif
# XXX MK_SYSCONS
-# XXX is moused w/ usb useful?
.if ${MK_LEGACY_CONSOLE} != "no"
_kbdcontrol= kbdcontrol
_kbdmap= kbdmap
diff --git a/usr.sbin/ac/ac.c b/usr.sbin/ac/ac.c
index d6db2d8..c584cd4 100644
--- a/usr.sbin/ac/ac.c
+++ b/usr.sbin/ac/ac.c
@@ -583,10 +583,11 @@ ac(const char *file)
endutxent();
if (!(Flags & AC_W))
usht.ut_tv.tv_sec = time(NULL);
+ else
+ usht.ut_tv.tv_sec = ut_timecopy;;
usht.ut_type = SHUTDOWN_TIME;
if (Flags & AC_D) {
- ut_timecopy = usht.ut_tv.tv_sec;
ltm = localtime(&ut_timecopy);
if (day >= 0 && day != ltm->tm_yday) {
/*
diff --git a/usr.sbin/acpi/acpidb/Makefile b/usr.sbin/acpi/acpidb/Makefile
index 5981f38..c2fe844 100644
--- a/usr.sbin/acpi/acpidb/Makefile
+++ b/usr.sbin/acpi/acpidb/Makefile
@@ -25,11 +25,11 @@ SRCS+= dsfield.c dsinit.c dsmethod.c dsmthdat.c dsobject.c \
dswstate.c
# interpreter/executer
-SRCS+= exconfig.c exconvrt.c excreate.c exdump.c exfield.c \
- exfldio.c exmisc.c exmutex.c exnames.c exoparg1.c \
- exoparg2.c exoparg3.c exoparg6.c exprep.c exregion.c \
- exresnte.c exresolv.c exresop.c exstore.c exstoren.c \
- exstorob.c exsystem.c exutils.c
+SRCS+= exconfig.c exconvrt.c excreate.c exdebug.c exdump.c \
+ exfield.c exfldio.c exmisc.c exmutex.c exnames.c \
+ exoparg1.c exoparg2.c exoparg3.c exoparg6.c exprep.c \
+ exregion.c exresnte.c exresolv.c exresop.c exstore.c \
+ exstoren.c exstorob.c exsystem.c exutils.c
# interpreter/parser
SRCS+= psargs.c psloop.c psopcode.c psparse.c psscope.c \
diff --git a/usr.sbin/acpi/iasl/Makefile b/usr.sbin/acpi/iasl/Makefile
index 130c39e..ea7a325 100644
--- a/usr.sbin/acpi/iasl/Makefile
+++ b/usr.sbin/acpi/iasl/Makefile
@@ -13,9 +13,9 @@ SRCS+= aslanalyze.c aslcodegen.c aslcompile.c aslcompiler.y.h \
aslcompilerlex.l aslcompilerparse.y aslerror.c \
aslfiles.c aslfold.c asllength.c asllisting.c \
aslload.c asllookup.c aslmain.c aslmap.c aslopcodes.c \
- asloperands.c aslopt.c aslresource.c aslrestype1.c \
- aslrestype2.c aslstartup.c aslstubs.c asltransform.c \
- asltree.c aslutils.c
+ asloperands.c aslopt.c aslpredef.c aslresource.c \
+ aslrestype1.c aslrestype2.c aslstartup.c aslstubs.c \
+ asltransform.c asltree.c aslutils.c
# debugger
SRCS+= dbfileio.c
diff --git a/usr.sbin/asf/asf.8 b/usr.sbin/asf/asf.8
index 25b0308..92edb4b 100644
--- a/usr.sbin/asf/asf.8
+++ b/usr.sbin/asf/asf.8
@@ -24,8 +24,8 @@
.\" $FreeBSD$
.\"
.Dd December 20, 2006
-.Os
.Dt ASF 8
+.Os
.Sh NAME
.Nm asf
.Nd add symbol files
diff --git a/usr.sbin/bluetooth/bthidd/Makefile b/usr.sbin/bluetooth/bthidd/Makefile
index 128bd20..dd0754d 100644
--- a/usr.sbin/bluetooth/bthidd/Makefile
+++ b/usr.sbin/bluetooth/bthidd/Makefile
@@ -8,7 +8,6 @@ SRCS= bthidd.c client.c hid.c kbd.c lexer.l parser.y server.c \
session.c
CFLAGS+= -I${.CURDIR}
-WARNS?= 6
DEBUG_FLAGS= -g
DPADD= ${LIBBLUETOOTH} ${LIBUSBHID}
diff --git a/usr.sbin/bsnmpd/modules/Makefile.inc b/usr.sbin/bsnmpd/modules/Makefile.inc
index adf6d72..b5dad56 100644
--- a/usr.sbin/bsnmpd/modules/Makefile.inc
+++ b/usr.sbin/bsnmpd/modules/Makefile.inc
@@ -1,8 +1,9 @@
# $FreeBSD$
SHLIB_MAJOR= 6
-WARNS?= 6
MANFILTER= sed -e 's%@MODPATH@%${LIBDIR}/%g' \
-e 's%@DEFPATH@%${DEFSDIR}/%g' \
-e 's%@MIBSPATH@%${BMIBSDIR}/%g'
+
+.include "../Makefile.inc"
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 72ebdb7..0b90bb2 100644
--- a/usr.sbin/bsnmpd/modules/snmp_pf/BEGEMOT-PF-MIB.txt
+++ b/usr.sbin/bsnmpd/modules/snmp_pf/BEGEMOT-PF-MIB.txt
@@ -17,11 +17,13 @@ IMPORTS
FROM SNMPv2-SMI
TruthValue
FROM SNMPv2-TC
+ InetAddress, InetAddressType, InetAddressPrefixLength
+ FROM INET-ADDRESS-MIB
begemot
FROM BEGEMOT-MIB;
begemotPf MODULE-IDENTITY
- LAST-UPDATED "200501240000Z"
+ LAST-UPDATED "201003180000Z"
ORGANIZATION "NixSys BVBA"
CONTACT-INFO
" Philip Paeps
@@ -34,6 +36,19 @@ begemotPf MODULE-IDENTITY
E-Mail: philip@FreeBSD.org"
DESCRIPTION
"The Begemot MIB for the pf packet filter."
+ REVISION "201003180000Z"
+ DESCRIPTION
+ "Modified pfTablesAddrEntry to support IPv6
+ addresses - added pfTablesAddrNetType column
+ and modified type of pfTablesAddrNet to
+ InetAddress."
+ REVISION "200912050000Z"
+ DESCRIPTION
+ "Added support for retrieving counters of labeled
+ pf filter rules via pfLabelspfLabels subtree."
+ REVISION "200501240000Z"
+ DESCRIPTION
+ "Initial revision."
::= { begemot 200 }
@@ -51,6 +66,7 @@ pfLogInterface OBJECT IDENTIFIER ::= { begemotPfObjects 7 }
pfInterfaces OBJECT IDENTIFIER ::= { begemotPfObjects 8 }
pfTables OBJECT IDENTIFIER ::= { begemotPfObjects 9 }
pfAltq OBJECT IDENTIFIER ::= { begemotPfObjects 10 }
+pfLabels OBJECT IDENTIFIER ::= { begemotPfObjects 11 }
-- --------------------------------------------------------------------------
@@ -1017,8 +1033,9 @@ pfTablesAddrEntry OBJECT-TYPE
PfTablesAddrEntry ::= SEQUENCE {
pfTablesAddrIndex Integer32,
- pfTablesAddrNet IpAddress,
- pfTablesAddrMask Integer32,
+ pfTablesAddrNetType InetAddressType,
+ pfTablesAddrNet InetAddress,
+ pfTablesAddrPrefix InetAddressPrefixLength,
pfTablesAddrTZero TimeTicks,
pfTablesAddrBytesInPass Counter64,
pfTablesAddrBytesInBlock Counter64,
@@ -1038,21 +1055,29 @@ pfTablesAddrIndex OBJECT-TYPE
"A unique value, greater than zero, for each address."
::= { pfTablesAddrEntry 1 }
+pfTablesAddrNetType OBJECT-TYPE
+ SYNTAX InetAddressType
+ MAX-ACCESS read-only
+ STATUS current
+ DESCRIPTION
+ "The type of address in the corresponding pfTablesAddrNet object."
+ ::= { pfTablesAddrEntry 2 }
+
pfTablesAddrNet OBJECT-TYPE
- SYNTAX IpAddress
+ SYNTAX InetAddress
MAX-ACCESS read-only
STATUS current
DESCRIPTION
"The IP address of this particular table entry."
- ::= { pfTablesAddrEntry 2 }
+ ::= { pfTablesAddrEntry 3 }
-pfTablesAddrMask OBJECT-TYPE
- SYNTAX Integer32 (0..32)
+pfTablesAddrPrefix OBJECT-TYPE
+ SYNTAX InetAddressPrefixLength
MAX-ACCESS read-only
STATUS current
DESCRIPTION
"The CIDR netmask of this particular table entry."
- ::= { pfTablesAddrEntry 3 }
+ ::= { pfTablesAddrEntry 4 }
pfTablesAddrTZero OBJECT-TYPE
SYNTAX TimeTicks
@@ -1063,7 +1088,7 @@ pfTablesAddrTZero OBJECT-TYPE
"The time passed since this entry's statistics were last
cleared, or the time passed since this entry was loaded
into the table, whichever is sooner."
- ::= { pfTablesAddrEntry 4 }
+ ::= { pfTablesAddrEntry 5 }
pfTablesAddrBytesInPass OBJECT-TYPE
SYNTAX Counter64
@@ -1071,7 +1096,7 @@ pfTablesAddrBytesInPass OBJECT-TYPE
STATUS current
DESCRIPTION
"The number of inbound bytes passed as a result of this entry."
- ::= { pfTablesAddrEntry 5 }
+ ::= { pfTablesAddrEntry 6 }
pfTablesAddrBytesInBlock OBJECT-TYPE
SYNTAX Counter64
@@ -1079,7 +1104,7 @@ pfTablesAddrBytesInBlock OBJECT-TYPE
STATUS current
DESCRIPTION
"The number of inbound bytes blocked as a result of this entry."
- ::= { pfTablesAddrEntry 6 }
+ ::= { pfTablesAddrEntry 7 }
pfTablesAddrBytesOutPass OBJECT-TYPE
SYNTAX Counter64
@@ -1087,7 +1112,7 @@ pfTablesAddrBytesOutPass OBJECT-TYPE
STATUS current
DESCRIPTION
"The number of outbound bytes passed as a result of this entry."
- ::= { pfTablesAddrEntry 7 }
+ ::= { pfTablesAddrEntry 8 }
pfTablesAddrBytesOutBlock OBJECT-TYPE
SYNTAX Counter64
@@ -1095,7 +1120,7 @@ pfTablesAddrBytesOutBlock OBJECT-TYPE
STATUS current
DESCRIPTION
"The number of outbound bytes blocked as a result of this entry."
- ::= { pfTablesAddrEntry 8 }
+ ::= { pfTablesAddrEntry 9 }
pfTablesAddrPktsInPass OBJECT-TYPE
SYNTAX Counter64
@@ -1103,7 +1128,7 @@ pfTablesAddrPktsInPass OBJECT-TYPE
STATUS current
DESCRIPTION
"The number of inbound packets passed as a result of this entry."
- ::= { pfTablesAddrEntry 9 }
+ ::= { pfTablesAddrEntry 10 }
pfTablesAddrPktsInBlock OBJECT-TYPE
SYNTAX Counter64
@@ -1111,7 +1136,7 @@ pfTablesAddrPktsInBlock OBJECT-TYPE
STATUS current
DESCRIPTION
"The number of inbound packets blocked as a result of this entry."
- ::= { pfTablesAddrEntry 10 }
+ ::= { pfTablesAddrEntry 11 }
pfTablesAddrPktsOutPass OBJECT-TYPE
SYNTAX Counter64
@@ -1119,7 +1144,7 @@ pfTablesAddrPktsOutPass OBJECT-TYPE
STATUS current
DESCRIPTION
"The number of outbound packets passed as a result of this entry."
- ::= { pfTablesAddrEntry 11 }
+ ::= { pfTablesAddrEntry 12 }
pfTablesAddrPktsOutBlock OBJECT-TYPE
SYNTAX Counter64
@@ -1128,7 +1153,7 @@ pfTablesAddrPktsOutBlock OBJECT-TYPE
DESCRIPTION
"The number of outbound packets blocked as a result of this
entry."
- ::= { pfTablesAddrEntry 12 }
+ ::= { pfTablesAddrEntry 13 }
-- --------------------------------------------------------------------------
@@ -1227,4 +1252,96 @@ pfAltqQueueLimit OBJECT-TYPE
"Maximum number of packets in the queue."
::= { pfAltqQueueEntry 7 }
+pfLabelsLblNumber OBJECT-TYPE
+ SYNTAX Integer32
+ MAX-ACCESS read-only
+ STATUS current
+ DESCRIPTION
+ "The number of labeled filter rules on this system."
+ ::= { pfLabels 1 }
+
+pfLabelsLblTable OBJECT-TYPE
+ SYNTAX SEQUENCE OF PfLabelsLblEntry
+ MAX-ACCESS not-accessible
+ STATUS current
+ DESCRIPTION
+ "Table of filter rules, index on pfLabelsLblIndex."
+ ::= { pfLabels 2 }
+
+pfLabelsLblEntry OBJECT-TYPE
+ SYNTAX PfLabelsLblEntry
+ MAX-ACCESS not-accessible
+ STATUS current
+ DESCRIPTION
+ "Any entry in the pfLabelsLblTable containing information
+ about a particular filter rule on the system."
+ INDEX { pfLabelsLblIndex }
+ ::= { pfLabelsLblTable 1 }
+
+PfLabelsLblEntry ::= SEQUENCE {
+ pfLabelsLblIndex Integer32,
+ pfLabelsLblName OCTET STRING,
+ pfLabelsLblEvals Counter64,
+ pfLabelsLblBytesIn Counter64,
+ pfLabelsLblBytesOut Counter64,
+ pfLabelsLblPktsIn Counter64,
+ pfLabelsLblPktsOut Counter64
+}
+
+pfLabelsLblIndex OBJECT-TYPE
+ SYNTAX Integer32 (1..2147483647)
+ MAX-ACCESS not-accessible
+ STATUS current
+ DESCRIPTION
+ "A unique value, greater than zero, for each label."
+ ::= { pfLabelsLblEntry 1 }
+
+pfLabelsLblName OBJECT-TYPE
+ SYNTAX OCTET STRING
+ MAX-ACCESS read-only
+ STATUS current
+ DESCRIPTION
+ "The name of the rule label."
+ ::= { pfLabelsLblEntry 2 }
+
+pfLabelsLblEvals OBJECT-TYPE
+ SYNTAX Counter64
+ MAX-ACCESS read-only
+ STATUS current
+ DESCRIPTION
+ "The number of rule evaluations."
+ ::= { pfLabelsLblEntry 3 }
+
+pfLabelsLblBytesIn OBJECT-TYPE
+ SYNTAX Counter64
+ MAX-ACCESS read-only
+ STATUS current
+ DESCRIPTION
+ "The number of incoming bytes matched by the rule."
+ ::= { pfLabelsLblEntry 4 }
+
+pfLabelsLblBytesOut OBJECT-TYPE
+ SYNTAX Counter64
+ MAX-ACCESS read-only
+ STATUS current
+ DESCRIPTION
+ "The number of outgoing bytes matched by the rule."
+ ::= { pfLabelsLblEntry 5 }
+
+pfLabelsLblPktsIn OBJECT-TYPE
+ SYNTAX Counter64
+ MAX-ACCESS read-only
+ STATUS current
+ DESCRIPTION
+ "The number of incoming packets matched by the rule."
+ ::= { pfLabelsLblEntry 6 }
+
+pfLabelsLblPktsOut OBJECT-TYPE
+ SYNTAX Counter64
+ MAX-ACCESS read-only
+ STATUS current
+ DESCRIPTION
+ "The number of outgoing packets matched by the rule."
+ ::= { pfLabelsLblEntry 7 }
+
END
diff --git a/usr.sbin/bsnmpd/modules/snmp_pf/Makefile b/usr.sbin/bsnmpd/modules/snmp_pf/Makefile
index 92b0a4ba..6218932 100644
--- a/usr.sbin/bsnmpd/modules/snmp_pf/Makefile
+++ b/usr.sbin/bsnmpd/modules/snmp_pf/Makefile
@@ -4,6 +4,7 @@
MOD= pf
SRCS= pf_snmp.c
+CFLAGS+= -DSNMPTREE_TYPES
XSYM= begemotPf
DEFS= ${MOD}_tree.def
diff --git a/usr.sbin/bsnmpd/modules/snmp_pf/pf_snmp.c b/usr.sbin/bsnmpd/modules/snmp_pf/pf_snmp.c
index 4e554c0..c7178f3 100644
--- a/usr.sbin/bsnmpd/modules/snmp_pf/pf_snmp.c
+++ b/usr.sbin/bsnmpd/modules/snmp_pf/pf_snmp.c
@@ -85,6 +85,19 @@ static int pft_table_count;
#define PFT_TABLE_MAXAGE 5
+struct pfa_entry {
+ struct pfr_astats pfas;
+ u_int index;
+ TAILQ_ENTRY(pfa_entry) link;
+};
+TAILQ_HEAD(pfa_table, pfa_entry);
+
+static struct pfa_table pfa_table;
+static time_t pfa_table_age;
+static int pfa_table_count;
+
+#define PFA_TABLE_MAXAGE 5
+
struct pfq_entry {
struct pf_altq altq;
u_int index;
@@ -100,14 +113,34 @@ static int altq_enabled = 0;
#define PFQ_TABLE_MAXAGE 5
+struct pfl_entry {
+ char name[MAXPATHLEN + PF_RULE_LABEL_SIZE];
+ u_int64_t evals;
+ u_int64_t bytes[2];
+ u_int64_t pkts[2];
+ u_int index;
+ TAILQ_ENTRY(pfl_entry) link;
+};
+TAILQ_HEAD(pfl_table, pfl_entry);
+
+static struct pfl_table pfl_table;
+static time_t pfl_table_age;
+static int pfl_table_count;
+
+#define PFL_TABLE_MAXAGE 5
+
/* Forward declarations */
static int pfi_refresh(void);
static int pfq_refresh(void);
static int pfs_refresh(void);
static int pft_refresh(void);
+static int pfa_refresh(void);
+static int pfl_refresh(void);
static struct pfi_entry * pfi_table_find(u_int idx);
static struct pfq_entry * pfq_table_find(u_int idx);
static struct pft_entry * pft_table_find(u_int idx);
+static struct pfa_entry * pfa_table_find(u_int idx);
+static struct pfl_entry * pfl_table_find(u_int idx);
static int altq_is_enabled(int pfdevice);
@@ -516,6 +549,9 @@ pf_iftable(struct snmp_context __unused *ctx, struct snmp_value *val,
asn_subid_t which = val->var.subs[sub - 1];
struct pfi_entry *e = NULL;
+ if ((time(NULL) - pfi_table_age) > PFI_TABLE_MAXAGE)
+ pfi_refresh();
+
switch (op) {
case SNMP_OP_SET:
return (SNMP_ERR_NOT_WRITEABLE);
@@ -539,9 +575,6 @@ pf_iftable(struct snmp_context __unused *ctx, struct snmp_value *val,
abort();
}
- if ((time(NULL) - pfi_table_age) > PFI_TABLE_MAXAGE)
- pfi_refresh();
-
switch (which) {
case LEAF_pfInterfacesIfDescr:
return (string_get(val, e->pfi.pfik_name, -1));
@@ -666,6 +699,9 @@ pf_tbltable(struct snmp_context __unused *ctx, struct snmp_value *val,
asn_subid_t which = val->var.subs[sub - 1];
struct pft_entry *e = NULL;
+ if ((time(NULL) - pft_table_age) > PFT_TABLE_MAXAGE)
+ pft_refresh();
+
switch (op) {
case SNMP_OP_SET:
return (SNMP_ERR_NOT_WRITEABLE);
@@ -689,9 +725,6 @@ pf_tbltable(struct snmp_context __unused *ctx, struct snmp_value *val,
abort();
}
- if ((time(NULL) - pft_table_age) > PFT_TABLE_MAXAGE)
- pft_refresh();
-
switch (which) {
case LEAF_pfTablesTblDescr:
return (string_get(val, e->pft.pfrts_name, -1));
@@ -776,7 +809,98 @@ int
pf_tbladdr(struct snmp_context __unused *ctx, struct snmp_value __unused *val,
u_int __unused sub, u_int __unused vindex, enum snmp_op __unused op)
{
- return (SNMP_ERR_GENERR);
+ asn_subid_t which = val->var.subs[sub - 1];
+ struct pfa_entry *e = NULL;
+
+ if ((time(NULL) - pfa_table_age) > PFA_TABLE_MAXAGE)
+ pfa_refresh();
+
+ switch (op) {
+ case SNMP_OP_SET:
+ return (SNMP_ERR_NOT_WRITEABLE);
+ case SNMP_OP_GETNEXT:
+ if ((e = NEXT_OBJECT_INT(&pfa_table,
+ &val->var, sub)) == NULL)
+ return (SNMP_ERR_NOSUCHNAME);
+ val->var.len = sub + 1;
+ val->var.subs[sub] = e->index;
+ break;
+ case SNMP_OP_GET:
+ if (val->var.len - sub != 1)
+ return (SNMP_ERR_NOSUCHNAME);
+ if ((e = pfa_table_find(val->var.subs[sub])) == NULL)
+ return (SNMP_ERR_NOSUCHNAME);
+ break;
+
+ case SNMP_OP_COMMIT:
+ case SNMP_OP_ROLLBACK:
+ default:
+ abort();
+ }
+
+ switch (which) {
+ case LEAF_pfTablesAddrNetType:
+ if (e->pfas.pfras_a.pfra_af == AF_INET)
+ val->v.integer = pfTablesAddrNetType_ipv4;
+ else if (e->pfas.pfras_a.pfra_af == AF_INET6)
+ val->v.integer = pfTablesAddrNetType_ipv6;
+ else
+ return (SNMP_ERR_GENERR);
+ break;
+ case LEAF_pfTablesAddrNet:
+ if (e->pfas.pfras_a.pfra_af == AF_INET) {
+ return (string_get(val,
+ (u_char *)&e->pfas.pfras_a.pfra_ip4addr, 4));
+ } else if (e->pfas.pfras_a.pfra_af == AF_INET6)
+ return (string_get(val,
+ (u_char *)&e->pfas.pfras_a.pfra_ip6addr, 16));
+ else
+ return (SNMP_ERR_GENERR);
+ break;
+ case LEAF_pfTablesAddrPrefix:
+ val->v.integer = (int32_t) e->pfas.pfras_a.pfra_net;
+ break;
+ case LEAF_pfTablesAddrTZero:
+ val->v.uint32 =
+ (time(NULL) - e->pfas.pfras_tzero) * 100;
+ break;
+ case LEAF_pfTablesAddrBytesInPass:
+ val->v.counter64 =
+ e->pfas.pfras_bytes[PFR_DIR_IN][PFR_OP_PASS];
+ break;
+ case LEAF_pfTablesAddrBytesInBlock:
+ val->v.counter64 =
+ e->pfas.pfras_bytes[PFR_DIR_IN][PFR_OP_BLOCK];
+ break;
+ case LEAF_pfTablesAddrBytesOutPass:
+ val->v.counter64 =
+ e->pfas.pfras_bytes[PFR_DIR_OUT][PFR_OP_PASS];
+ break;
+ case LEAF_pfTablesAddrBytesOutBlock:
+ val->v.counter64 =
+ e->pfas.pfras_bytes[PFR_DIR_OUT][PFR_OP_BLOCK];
+ break;
+ case LEAF_pfTablesAddrPktsInPass:
+ val->v.counter64 =
+ e->pfas.pfras_packets[PFR_DIR_IN][PFR_OP_PASS];
+ break;
+ case LEAF_pfTablesAddrPktsInBlock:
+ val->v.counter64 =
+ e->pfas.pfras_packets[PFR_DIR_IN][PFR_OP_BLOCK];
+ break;
+ case LEAF_pfTablesAddrPktsOutPass:
+ val->v.counter64 =
+ e->pfas.pfras_packets[PFR_DIR_OUT][PFR_OP_PASS];
+ break;
+ case LEAF_pfTablesAddrPktsOutBlock:
+ val->v.counter64 =
+ e->pfas.pfras_packets[PFR_DIR_OUT][PFR_OP_BLOCK];
+ break;
+ default:
+ return (SNMP_ERR_NOSUCHNAME);
+ }
+
+ return (SNMP_ERR_NOERROR);
}
int
@@ -785,9 +909,8 @@ pf_altq(struct snmp_context __unused *ctx, struct snmp_value *val,
{
asn_subid_t which = val->var.subs[sub - 1];
- if (!altq_enabled) {
- return (SNMP_ERR_NOERROR);
- }
+ if (!altq_enabled)
+ return (SNMP_ERR_NOSUCHNAME);
if (op == SNMP_OP_SET)
return (SNMP_ERR_NOT_WRITEABLE);
@@ -820,9 +943,11 @@ pf_altqq(struct snmp_context __unused *ctx, struct snmp_value *val,
asn_subid_t which = val->var.subs[sub - 1];
struct pfq_entry *e = NULL;
- if (!altq_enabled) {
- return (SNMP_ERR_NOERROR);
- }
+ if (!altq_enabled)
+ return (SNMP_ERR_NOSUCHNAME);
+
+ if ((time(NULL) - pfq_table_age) > PFQ_TABLE_MAXAGE)
+ pfq_refresh();
switch (op) {
case SNMP_OP_SET:
@@ -847,9 +972,6 @@ pf_altqq(struct snmp_context __unused *ctx, struct snmp_value *val,
abort();
}
- if ((time(NULL) - pfq_table_age) > PFQ_TABLE_MAXAGE)
- pfq_refresh();
-
switch (which) {
case LEAF_pfAltqQueueDescr:
return (string_get(val, e->altq.qname, -1));
@@ -873,7 +995,95 @@ pf_altqq(struct snmp_context __unused *ctx, struct snmp_value *val,
}
return (SNMP_ERR_NOERROR);
-}
+}
+
+int
+pf_labels(struct snmp_context __unused *ctx, struct snmp_value *val,
+ u_int sub, u_int __unused vindex, enum snmp_op op)
+{
+ asn_subid_t which = val->var.subs[sub - 1];
+
+ if (op == SNMP_OP_SET)
+ return (SNMP_ERR_NOT_WRITEABLE);
+
+ if (op == SNMP_OP_GET) {
+ if ((time(NULL) - pfl_table_age) > PFL_TABLE_MAXAGE)
+ if (pfl_refresh() == -1)
+ return (SNMP_ERR_GENERR);
+
+ switch (which) {
+ case LEAF_pfLabelsLblNumber:
+ val->v.uint32 = pfl_table_count;
+ break;
+
+ default:
+ return (SNMP_ERR_NOSUCHNAME);
+ }
+
+ return (SNMP_ERR_NOERROR);
+ }
+
+ abort();
+ return (SNMP_ERR_GENERR);
+}
+
+int
+pf_lbltable(struct snmp_context __unused *ctx, struct snmp_value *val,
+ u_int sub, u_int __unused vindex, enum snmp_op op)
+{
+ asn_subid_t which = val->var.subs[sub - 1];
+ struct pfl_entry *e = NULL;
+
+ if ((time(NULL) - pfl_table_age) > PFL_TABLE_MAXAGE)
+ pfl_refresh();
+
+ switch (op) {
+ case SNMP_OP_SET:
+ return (SNMP_ERR_NOT_WRITEABLE);
+ case SNMP_OP_GETNEXT:
+ if ((e = NEXT_OBJECT_INT(&pfl_table,
+ &val->var, sub)) == NULL)
+ return (SNMP_ERR_NOSUCHNAME);
+ val->var.len = sub + 1;
+ val->var.subs[sub] = e->index;
+ break;
+ case SNMP_OP_GET:
+ if (val->var.len - sub != 1)
+ return (SNMP_ERR_NOSUCHNAME);
+ if ((e = pfl_table_find(val->var.subs[sub])) == NULL)
+ return (SNMP_ERR_NOSUCHNAME);
+ break;
+
+ case SNMP_OP_COMMIT:
+ case SNMP_OP_ROLLBACK:
+ default:
+ abort();
+ }
+
+ switch (which) {
+ case LEAF_pfLabelsLblName:
+ return (string_get(val, e->name, -1));
+ case LEAF_pfLabelsLblEvals:
+ val->v.counter64 = e->evals;
+ break;
+ case LEAF_pfLabelsLblBytesIn:
+ val->v.counter64 = e->bytes[IN];
+ break;
+ case LEAF_pfLabelsLblBytesOut:
+ val->v.counter64 = e->bytes[OUT];
+ break;
+ case LEAF_pfLabelsLblPktsIn:
+ val->v.counter64 = e->pkts[IN];
+ break;
+ case LEAF_pfLabelsLblPktsOut:
+ val->v.counter64 = e->pkts[OUT];
+ break;
+ default:
+ return (SNMP_ERR_NOSUCHNAME);
+ }
+
+ return (SNMP_ERR_NOERROR);
+}
static struct pfi_entry *
pfi_table_find(u_int idx)
@@ -890,6 +1100,7 @@ static struct pfq_entry *
pfq_table_find(u_int idx)
{
struct pfq_entry *e;
+
TAILQ_FOREACH(e, &pfq_table, link)
if (e->index == idx)
return (e);
@@ -907,6 +1118,29 @@ pft_table_find(u_int idx)
return (NULL);
}
+static struct pfa_entry *
+pfa_table_find(u_int idx)
+{
+ struct pfa_entry *e;
+
+ TAILQ_FOREACH(e, &pfa_table, link)
+ if (e->index == idx)
+ return (e);
+ return (NULL);
+}
+
+static struct pfl_entry *
+pfl_table_find(u_int idx)
+{
+ struct pfl_entry *e;
+
+ TAILQ_FOREACH(e, &pfl_table, link)
+ if (e->index == idx)
+ return (e);
+
+ return (NULL);
+}
+
static int
pfi_refresh(void)
{
@@ -1129,6 +1363,278 @@ err2:
return(-1);
}
+static int
+pfa_table_addrs(u_int sidx, struct pfr_table *pt)
+{
+ struct pfioc_table io;
+ struct pfr_astats *t = NULL;
+ struct pfa_entry *e;
+ int i, numaddrs = 1;
+
+ if (pt == NULL)
+ return (-1);
+
+ memset(&io, 0, sizeof(io));
+ strlcpy(io.pfrio_table.pfrt_name, pt->pfrt_name,
+ sizeof(io.pfrio_table.pfrt_name));
+
+ for (;;) {
+ t = reallocf(t, numaddrs * sizeof(struct pfr_astats));
+ if (t == NULL) {
+ syslog(LOG_ERR, "pfa_table_addrs(): reallocf(): %s",
+ strerror(errno));
+ numaddrs = -1;
+ goto error;
+ }
+
+ memset(t, 0, sizeof(*t));
+ io.pfrio_size = numaddrs;
+ io.pfrio_buffer = t;
+ io.pfrio_esize = sizeof(struct pfr_astats);
+
+ if (ioctl(dev, DIOCRGETASTATS, &io)) {
+ syslog(LOG_ERR, "pfa_table_addrs(): ioctl() on %s: %s",
+ pt->pfrt_name, strerror(errno));
+ numaddrs = -1;
+ break;
+ }
+
+ if (numaddrs >= io.pfrio_size)
+ break;
+
+ numaddrs = io.pfrio_size;
+ }
+
+ for (i = 0; i < numaddrs; i++) {
+ if ((t + i)->pfras_a.pfra_af != AF_INET &&
+ (t + i)->pfras_a.pfra_af != AF_INET6) {
+ numaddrs = i;
+ break;
+ }
+
+ e = (struct pfa_entry *)malloc(sizeof(struct pfa_entry));
+ if (e == NULL) {
+ syslog(LOG_ERR, "pfa_table_addrs(): malloc(): %s",
+ strerror(errno));
+ numaddrs = -1;
+ break;
+ }
+ e->index = sidx + i;
+ memcpy(&e->pfas, t + i, sizeof(struct pfr_astats));
+ TAILQ_INSERT_TAIL(&pfa_table, e, link);
+ }
+
+ free(t);
+error:
+ return (numaddrs);
+}
+
+static int
+pfa_refresh(void)
+{
+ struct pfioc_table io;
+ struct pfr_table *pt = NULL, *it = NULL;
+ struct pfa_entry *e;
+ int i, numtbls = 1, cidx, naddrs;
+
+ if (started && this_tick <= pf_tick)
+ return (0);
+
+ while (!TAILQ_EMPTY(&pfa_table)) {
+ e = TAILQ_FIRST(&pfa_table);
+ TAILQ_REMOVE(&pfa_table, e, link);
+ free(e);
+ }
+
+ memset(&io, 0, sizeof(io));
+ io.pfrio_esize = sizeof(struct pfr_table);
+
+ for (;;) {
+ pt = reallocf(pt, numtbls * sizeof(struct pfr_table));
+ if (pt == NULL) {
+ syslog(LOG_ERR, "pfa_refresh(): reallocf() %s",
+ strerror(errno));
+ return (-1);
+ }
+ memset(pt, 0, sizeof(*pt));
+ io.pfrio_size = numtbls;
+ io.pfrio_buffer = pt;
+
+ if (ioctl(dev, DIOCRGETTABLES, &io)) {
+ syslog(LOG_ERR, "pfa_refresh(): ioctl(): %s",
+ strerror(errno));
+ goto err2;
+ }
+
+ if (numtbls >= io.pfrio_size)
+ break;
+
+ numtbls = io.pfrio_size;
+ }
+
+ cidx = 1;
+
+ for (it = pt, i = 0; i < numtbls; it++, i++) {
+ /*
+ * Skip the table if not active - ioctl(DIOCRGETASTATS) will
+ * return ESRCH for this entry anyway.
+ */
+ if (!(it->pfrt_flags & PFR_TFLAG_ACTIVE))
+ continue;
+
+ if ((naddrs = pfa_table_addrs(cidx, it)) < 0)
+ goto err1;
+
+ cidx += naddrs;
+ }
+
+ pfa_table_age = time(NULL);
+ pfa_table_count = cidx;
+ pf_tick = this_tick;
+
+ free(pt);
+ return (0);
+err1:
+ while (!TAILQ_EMPTY(&pfa_table)) {
+ e = TAILQ_FIRST(&pfa_table);
+ TAILQ_REMOVE(&pfa_table, e, link);
+ free(e);
+ }
+
+err2:
+ free(pt);
+ return (-1);
+}
+
+static int
+pfl_scan_ruleset(const char *path)
+{
+ struct pfioc_rule pr;
+ struct pfl_entry *e;
+ u_int32_t nr, i;
+
+ bzero(&pr, sizeof(pr));
+ strlcpy(pr.anchor, path, sizeof(pr.anchor));
+ pr.rule.action = PF_PASS;
+ if (ioctl(dev, DIOCGETRULES, &pr)) {
+ syslog(LOG_ERR, "pfl_scan_ruleset: ioctl(DIOCGETRULES): %s",
+ strerror(errno));
+ goto err;
+ }
+
+ for (nr = pr.nr, i = 0; i < nr; i++) {
+ pr.nr = i;
+ if (ioctl(dev, DIOCGETRULE, &pr)) {
+ syslog(LOG_ERR, "pfl_scan_ruleset: ioctl(DIOCGETRULE):"
+ " %s", strerror(errno));
+ goto err;
+ }
+
+ if (pr.rule.label[0]) {
+ e = (struct pfl_entry *)malloc(sizeof(*e));
+ if (e == NULL)
+ goto err;
+
+ strlcpy(e->name, path, sizeof(e->name));
+ if (path[0])
+ strlcat(e->name, "/", sizeof(e->name));
+ strlcat(e->name, pr.rule.label, sizeof(e->name));
+
+ e->evals = pr.rule.evaluations;
+ e->bytes[IN] = pr.rule.bytes[IN];
+ e->bytes[OUT] = pr.rule.bytes[OUT];
+ e->pkts[IN] = pr.rule.packets[IN];
+ e->pkts[OUT] = pr.rule.packets[OUT];
+ e->index = ++pfl_table_count;
+
+ TAILQ_INSERT_TAIL(&pfl_table, e, link);
+ }
+ }
+
+ return (0);
+
+err:
+ return (-1);
+}
+
+static int
+pfl_walk_rulesets(const char *path)
+{
+ struct pfioc_ruleset prs;
+ char newpath[MAXPATHLEN];
+ u_int32_t nr, i;
+
+ if (pfl_scan_ruleset(path))
+ goto err;
+
+ bzero(&prs, sizeof(prs));
+ strlcpy(prs.path, path, sizeof(prs.path));
+ if (ioctl(dev, DIOCGETRULESETS, &prs)) {
+ syslog(LOG_ERR, "pfl_walk_rulesets: ioctl(DIOCGETRULESETS): %s",
+ strerror(errno));
+ goto err;
+ }
+
+ for (nr = prs.nr, i = 0; i < nr; i++) {
+ prs.nr = i;
+ if (ioctl(dev, DIOCGETRULESET, &prs)) {
+ syslog(LOG_ERR, "pfl_walk_rulesets: ioctl(DIOCGETRULESET):"
+ " %s", strerror(errno));
+ goto err;
+ }
+
+ if (strcmp(prs.name, PF_RESERVED_ANCHOR) == 0)
+ continue;
+
+ strlcpy(newpath, path, sizeof(newpath));
+ if (path[0])
+ strlcat(newpath, "/", sizeof(newpath));
+
+ strlcat(newpath, prs.name, sizeof(newpath));
+ if (pfl_walk_rulesets(newpath))
+ goto err;
+ }
+
+ return (0);
+
+err:
+ return (-1);
+}
+
+static int
+pfl_refresh(void)
+{
+ struct pfl_entry *e;
+
+ if (started && this_tick <= pf_tick)
+ return (0);
+
+ while (!TAILQ_EMPTY(&pfl_table)) {
+ e = TAILQ_FIRST(&pfl_table);
+ TAILQ_REMOVE(&pfl_table, e, link);
+ free(e);
+ }
+ pfl_table_count = 0;
+
+ if (pfl_walk_rulesets(""))
+ goto err;
+
+ pfl_table_age = time(NULL);
+ pf_tick = this_tick;
+
+ return (0);
+
+err:
+ while (!TAILQ_EMPTY(&pfl_table)) {
+ e = TAILQ_FIRST(&pfl_table);
+ TAILQ_REMOVE(&pfl_table, e, link);
+ free(e);
+ }
+ pfl_table_count = 0;
+
+ return (-1);
+}
+
/*
* check whether altq support is enabled in kernel
*/
@@ -1175,6 +1681,8 @@ pf_init(struct lmodule *mod, int __unused argc, char __unused *argv[])
TAILQ_INIT(&pfi_table);
TAILQ_INIT(&pfq_table);
TAILQ_INIT(&pft_table);
+ TAILQ_INIT(&pfa_table);
+ TAILQ_INIT(&pfl_table);
pfi_refresh();
if (altq_enabled) {
@@ -1183,6 +1691,8 @@ pf_init(struct lmodule *mod, int __unused argc, char __unused *argv[])
pfs_refresh();
pft_refresh();
+ pfa_refresh();
+ pfl_refresh();
started = 1;
@@ -1195,6 +1705,8 @@ pf_fini(void)
struct pfi_entry *i1, *i2;
struct pfq_entry *q1, *q2;
struct pft_entry *t1, *t2;
+ struct pfa_entry *a1, *a2;
+ struct pfl_entry *l1, *l2;
/* Empty the list of interfaces */
i1 = TAILQ_FIRST(&pfi_table);
@@ -1212,7 +1724,7 @@ pf_fini(void)
q1 = q2;
}
- /* And the list of tables */
+ /* List of tables */
t1 = TAILQ_FIRST(&pft_table);
while (t1 != NULL) {
t2 = TAILQ_NEXT(t1, link);
@@ -1220,6 +1732,22 @@ pf_fini(void)
t1 = t2;
}
+ /* List of table addresses */
+ a1 = TAILQ_FIRST(&pfa_table);
+ while (a1 != NULL) {
+ a2 = TAILQ_NEXT(a1, link);
+ free(a1);
+ a1 = a2;
+ }
+
+ /* And the list of labeled filter rules */
+ l1 = TAILQ_FIRST(&pfl_table);
+ while (l1 != NULL) {
+ l2 = TAILQ_NEXT(l1, link);
+ free(l1);
+ l1 = l2;
+ }
+
close(dev);
return (0);
}
@@ -1232,6 +1760,8 @@ pf_dump(void)
pfq_refresh();
}
pft_refresh();
+ pfa_refresh();
+ pfl_refresh();
syslog(LOG_ERR, "Dump: pfi_table_age = %jd",
(intmax_t)pfi_table_age);
@@ -1245,9 +1775,18 @@ pf_dump(void)
syslog(LOG_ERR, "Dump: pft_table_age = %jd",
(intmax_t)pft_table_age);
-
syslog(LOG_ERR, "Dump: pft_table_count = %d",
pft_table_count);
+
+ syslog(LOG_ERR, "Dump: pfa_table_age = %jd",
+ (intmax_t)pfa_table_age);
+ syslog(LOG_ERR, "Dump: pfa_table_count = %d",
+ pfa_table_count);
+
+ syslog(LOG_ERR, "Dump: pfl_table_age = %jd",
+ (intmax_t)pfl_table_age);
+ syslog(LOG_ERR, "Dump: pfl_table_count = %d",
+ pfl_table_count);
}
const struct snmp_module config = {
diff --git a/usr.sbin/bsnmpd/modules/snmp_pf/pf_tree.def b/usr.sbin/bsnmpd/modules/snmp_pf/pf_tree.def
index 003a3ec..7b791b3 100644
--- a/usr.sbin/bsnmpd/modules/snmp_pf/pf_tree.def
+++ b/usr.sbin/bsnmpd/modules/snmp_pf/pf_tree.def
@@ -1,5 +1,5 @@
#
-# Copyright (c) 2005 Philip Paeps <philip@FreeBSD.org>
+# Copyright (c) 2010 Philip Paeps <philip@FreeBSD.org>
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
@@ -34,9 +34,9 @@
(200 begemotPf
(1 begemotPfObjects
(1 pfStatus
- (1 pfStatusRunning INTEGER pf_status GET)
+ (1 pfStatusRunning ENUM ( 1 true 2 false ) pf_status GET)
(2 pfStatusRuntime TIMETICKS pf_status GET)
- (3 pfStatusDebug INTEGER pf_status GET)
+ (3 pfStatusDebug ENUM ( 0 none 1 urgent 2 misc 3 loud ) pf_status GET)
(4 pfStatusHostId OCTETSTRING pf_status GET)
)
(2 pfCounter
@@ -106,7 +106,7 @@
(1 pfInterfacesIfEntry : INTEGER32 pf_iftable
(1 pfInterfacesIfIndex INTEGER32)
(2 pfInterfacesIfDescr OCTETSTRING GET)
- (3 pfInterfacesIfType INTEGER GET)
+ (3 pfInterfacesIfType ENUM ( 0 group 1 instance 2 detached ) GET)
(4 pfInterfacesIfTZero TIMETICKS GET)
(5 pfInterfacesIfRefsState UNSIGNED32 GET)
(6 pfInterfacesIfRefsRule UNSIGNED32 GET)
@@ -158,17 +158,18 @@
(3 pfTablesAddrTable
(1 pfTablesAddrEntry : INTEGER32 pf_tbladdr
(1 pfTablesAddrIndex INTEGER32)
- (2 pfTablesAddrNet IPADDRESS GET)
- (3 pfTablesAddrMask INTEGER32 GET)
- (4 pfTablesAddrTZero TIMETICKS GET)
- (5 pfTablesAddrBytesInPass COUNTER64 GET)
- (6 pfTablesAddrBytesInBlock COUNTER64 GET)
- (7 pfTablesAddrBytesOutPass COUNTER64 GET)
- (8 pfTablesAddrBytesOutBlock COUNTER64 GET)
- (9 pfTablesAddrPktsInPass COUNTER64 GET)
- (10 pfTablesAddrPktsInBlock COUNTER64 GET)
- (11 pfTablesAddrPktsOutPass COUNTER64 GET)
- (12 pfTablesAddrPktsOutBlock COUNTER64 GET)
+ (2 pfTablesAddrNetType ENUM ( 0 unknown 1 ipv4 2 ipv6) GET)
+ (3 pfTablesAddrNet OCTETSTRING | InetAddress GET)
+ (4 pfTablesAddrPrefix UNSIGNED32 GET)
+ (5 pfTablesAddrTZero TIMETICKS GET)
+ (6 pfTablesAddrBytesInPass COUNTER64 GET)
+ (7 pfTablesAddrBytesInBlock COUNTER64 GET)
+ (8 pfTablesAddrBytesOutPass COUNTER64 GET)
+ (9 pfTablesAddrBytesOutBlock COUNTER64 GET)
+ (10 pfTablesAddrPktsInPass COUNTER64 GET)
+ (11 pfTablesAddrPktsInBlock COUNTER64 GET)
+ (12 pfTablesAddrPktsOutPass COUNTER64 GET)
+ (13 pfTablesAddrPktsOutBlock COUNTER64 GET)
)
)
)
@@ -179,13 +180,27 @@
(1 pfAltqQueueIndex INTEGER32)
(2 pfAltqQueueDescr OCTETSTRING GET)
(3 pfAltqQueueParent OCTETSTRING GET)
- (4 pfAltqQueueScheduler INTEGER GET)
+ (4 pfAltqQueueScheduler ENUM ( 1 cbq 8 hfsc 11 priq ) GET)
(5 pfAltqQueueBandwidth UNSIGNED32 GET)
(6 pfAltqQueuePriority INTEGER32 GET)
(7 pfAltqQueueLimit INTEGER32 GET)
)
)
)
+ (11 pfLabels
+ (1 pfLabelsLblNumber INTEGER32 pf_labels GET)
+ (2 pfLabelsLblTable
+ (1 pfLabelsLblEntry : INTEGER pf_lbltable
+ (1 pfLabelsLblIndex INTEGER)
+ (2 pfLabelsLblName OCTETSTRING GET)
+ (3 pfLabelsLblEvals COUNTER64 GET)
+ (4 pfLabelsLblBytesIn COUNTER64 GET)
+ (5 pfLabelsLblBytesOut COUNTER64 GET)
+ (6 pfLabelsLblPktsIn COUNTER64 GET)
+ (7 pfLabelsLblPktsOut COUNTER64 GET)
+ )
+ )
+ )
)
)
)
diff --git a/usr.sbin/burncd/burncd.8 b/usr.sbin/burncd/burncd.8
index 2501e72..a9c53e6 100644
--- a/usr.sbin/burncd/burncd.8
+++ b/usr.sbin/burncd/burncd.8
@@ -28,8 +28,8 @@
.\" $FreeBSD$
.\"
.Dd December 21, 2009
-.Os
.Dt BURNCD 8
+.Os
.Sh NAME
.Nm burncd
.Nd control the ATAPI CD-R/RW driver
diff --git a/usr.sbin/config/config.h b/usr.sbin/config/config.h
index d55c96b..ec19986 100644
--- a/usr.sbin/config/config.h
+++ b/usr.sbin/config/config.h
@@ -129,6 +129,8 @@ SLIST_HEAD(opt_head, opt) opt, mkopt, rmopts;
struct opt_list {
char *o_name;
char *o_file;
+ int o_flags;
+#define OL_ALIAS 1
SLIST_ENTRY(opt_list) o_next;
};
diff --git a/usr.sbin/config/config.y b/usr.sbin/config/config.y
index 9425daf..19f2779 100644
--- a/usr.sbin/config/config.y
+++ b/usr.sbin/config/config.y
@@ -166,6 +166,8 @@ Config_spec:
CPU Save_id {
struct cputype *cp =
(struct cputype *)calloc(1, sizeof (struct cputype));
+ if (cp == NULL)
+ err(EXIT_FAILURE, "calloc");
cp->cpu_name = $2;
SLIST_INSERT_HEAD(&cputype, cp, cpu_next);
} |
@@ -197,6 +199,8 @@ Config_spec:
struct hint *hint;
hint = (struct hint *)calloc(1, sizeof (struct hint));
+ if (hint == NULL)
+ err(EXIT_FAILURE, "calloc");
hint->hint_name = $2;
STAILQ_INSERT_TAIL(&hints, hint, hint_next);
hintmode = 1;
@@ -331,6 +335,8 @@ newfile(char *name)
struct files_name *nl;
nl = (struct files_name *) calloc(1, sizeof *nl);
+ if (nl == NULL)
+ err(EXIT_FAILURE, "calloc");
nl->f_name = name;
STAILQ_INSERT_TAIL(&fntab, nl, f_next);
}
@@ -364,6 +370,8 @@ newdev(char *name)
}
np = (struct device *) calloc(1, sizeof *np);
+ if (np == NULL)
+ err(EXIT_FAILURE, "calloc");
np->d_name = name;
STAILQ_INSERT_TAIL(&dtab, np, d_next);
}
@@ -422,6 +430,8 @@ newopt(struct opt_head *list, char *name, char *value, int append)
}
op = (struct opt *)calloc(1, sizeof (struct opt));
+ if (op == NULL)
+ err(EXIT_FAILURE, "calloc");
op->op_name = name;
op->op_ownfile = 0;
op->op_value = value;
diff --git a/usr.sbin/config/configvers.h b/usr.sbin/config/configvers.h
index 28451585..73310bd 100644
--- a/usr.sbin/config/configvers.h
+++ b/usr.sbin/config/configvers.h
@@ -49,5 +49,5 @@
*
* $FreeBSD$
*/
-#define CONFIGVERS 600007
+#define CONFIGVERS 600008
#define MAJOR_VERS(x) ((x) / 100000)
diff --git a/usr.sbin/config/lang.l b/usr.sbin/config/lang.l
index c7845cb..4eb94da 100644
--- a/usr.sbin/config/lang.l
+++ b/usr.sbin/config/lang.l
@@ -33,6 +33,7 @@
#include <assert.h>
#include <ctype.h>
+#include <err.h>
#include <string.h>
#include "y.tab.h"
#include "config.h"
@@ -220,6 +221,8 @@ cfgfile_add(const char *fname)
struct cfgfile *cf;
cf = calloc(1, sizeof(*cf));
+ if (cf == NULL)
+ err(EXIT_FAILURE, "calloc");
assert(cf != NULL);
asprintf(&cf->cfg_path, "%s", fname);
STAILQ_INSERT_TAIL(&cfgfiles, cf, cfg_next);
diff --git a/usr.sbin/config/main.c b/usr.sbin/config/main.c
index 34806ab..2b5e055 100644
--- a/usr.sbin/config/main.c
+++ b/usr.sbin/config/main.c
@@ -120,7 +120,7 @@ main(int argc, char **argv)
if (*destdir == '\0')
strlcpy(destdir, optarg, sizeof(destdir));
else
- errx(2, "directory already set");
+ errx(EXIT_FAILURE, "directory already set");
break;
case 'g':
debugging++;
@@ -175,7 +175,7 @@ main(int argc, char **argv)
if (mkdir(p, 0777))
err(2, "%s", p);
} else if (!S_ISDIR(buf.st_mode))
- errx(2, "%s isn't a directory", p);
+ errx(EXIT_FAILURE, "%s isn't a directory", p);
SLIST_INIT(&cputype);
SLIST_INIT(&mkopt);
@@ -256,7 +256,7 @@ get_srcdir(void)
int i;
if (realpath("../..", srcdir) == NULL)
- errx(2, "Unable to find root of source tree");
+ err(EXIT_FAILURE, "Unable to find root of source tree");
if ((pwd = getenv("PWD")) != NULL && *pwd == '/' &&
(pwd = strdup(pwd)) != NULL) {
/* Remove the last two path components. */
@@ -513,7 +513,7 @@ configfile(void)
}
sbuf_finish(sb);
/*
- * We print first part of the tamplate, replace our tag with
+ * We print first part of the template, replace our tag with
* configuration files content and later continue writing our
* template.
*/
@@ -650,6 +650,8 @@ remember(const char *file)
}
}
hl = calloc(1, sizeof(*hl));
+ if (hl == NULL)
+ err(EXIT_FAILURE, "calloc");
hl->h_name = s;
hl->h_next = htab;
htab = hl;
@@ -671,19 +673,19 @@ kernconfdump(const char *file)
r = open(file, O_RDONLY);
if (r == -1)
- errx(EXIT_FAILURE, "Couldn't open file '%s'", file);
+ err(EXIT_FAILURE, "Couldn't open file '%s'", file);
error = fstat(r, &st);
if (error == -1)
- errx(EXIT_FAILURE, "fstat() failed");
+ err(EXIT_FAILURE, "fstat() failed");
if (S_ISDIR(st.st_mode))
errx(EXIT_FAILURE, "'%s' is a directory", file);
fp = fdopen(r, "r");
if (fp == NULL)
- errx(EXIT_FAILURE, "fdopen() failed");
+ err(EXIT_FAILURE, "fdopen() failed");
osz = 1024;
o = calloc(1, osz);
if (o == NULL)
- errx(EXIT_FAILURE, "Couldn't allocate memory");
+ err(EXIT_FAILURE, "Couldn't allocate memory");
/* ELF note section header. */
asprintf(&cmd, "/usr/bin/elfdump -c %s | grep -A 5 kern_conf"
"| tail -2 | cut -d ' ' -f 2 | paste - - -", file);
@@ -703,7 +705,7 @@ kernconfdump(const char *file)
"INCLUDE_CONFIG_FILE", file);
r = fseek(fp, off, SEEK_CUR);
if (r != 0)
- errx(EXIT_FAILURE, "fseek() failed");
+ err(EXIT_FAILURE, "fseek() failed");
for (i = 0; i < size - 1; i++) {
r = fgetc(fp);
if (r == EOF)
diff --git a/usr.sbin/config/mkmakefile.c b/usr.sbin/config/mkmakefile.c
index a89db8e..7845089 100644
--- a/usr.sbin/config/mkmakefile.c
+++ b/usr.sbin/config/mkmakefile.c
@@ -98,6 +98,8 @@ new_fent(void)
struct file_list *fp;
fp = (struct file_list *) calloc(1, sizeof *fp);
+ if (fp == NULL)
+ err(EXIT_FAILURE, "calloc");
STAILQ_INSERT_TAIL(&ftab, fp, f_next);
return (fp);
}
@@ -739,7 +741,7 @@ do_rules(FILE *f)
printf("config: don't know rules for %s\n", np);
break;
}
- snprintf(cmd, sizeof(cmd), "${%s_%c%s}\n.if defined(NORMAL_CTFCONVERT) && !empty(NORMAL_CTFCONVERT)\n\t${NORMAL_CTFCONVERT}\n.endif", ftype,
+ snprintf(cmd, sizeof(cmd), "${%s_%c%s}\n\t@${NORMAL_CTFCONVERT}", ftype,
toupper(och),
ftp->f_flags & NOWERROR ? "_NOWERROR" : "");
compilewith = cmd;
diff --git a/usr.sbin/config/mkoptions.c b/usr.sbin/config/mkoptions.c
index c4bd624..1a6ccc8 100644
--- a/usr.sbin/config/mkoptions.c
+++ b/usr.sbin/config/mkoptions.c
@@ -70,6 +70,8 @@ options(void)
/* Fake the cpu types as options. */
SLIST_FOREACH(cp, &cputype, cpu_next) {
op = (struct opt *)calloc(1, sizeof(*op));
+ if (op == NULL)
+ err(EXIT_FAILURE, "calloc");
op->op_name = ns(cp->cpu_name);
SLIST_INSERT_HEAD(&opt, op, op_next);
}
@@ -84,12 +86,25 @@ options(void)
/* Fake MAXUSERS as an option. */
op = (struct opt *)calloc(1, sizeof(*op));
+ if (op == NULL)
+ err(EXIT_FAILURE, "calloc");
op->op_name = ns("MAXUSERS");
snprintf(buf, sizeof(buf), "%d", maxusers);
op->op_value = ns(buf);
SLIST_INSERT_HEAD(&opt, op, op_next);
read_options();
+ SLIST_FOREACH(op, &opt, op_next) {
+ SLIST_FOREACH(ol, &otab, o_next) {
+ if (eq(op->op_name, ol->o_name) &&
+ (ol->o_flags & OL_ALIAS)) {
+ printf("Mapping option %s to %s.\n",
+ op->op_name, ol->o_file);
+ op->op_name = ol->o_file;
+ break;
+ }
+ }
+ }
SLIST_FOREACH(ol, &otab, o_next)
do_option(ol->o_name);
SLIST_FOREACH(op, &opt, op_next) {
@@ -120,7 +135,6 @@ do_option(char *name)
int tidy;
file = tooption(name);
-
/*
* Check to see if the option was specified..
*/
@@ -199,6 +213,8 @@ do_option(char *name)
tidy++;
} else {
op = (struct opt *) calloc(1, sizeof *op);
+ if (op == NULL)
+ err(EXIT_FAILURE, "calloc");
op->op_name = inw;
op->op_value = invalue;
SLIST_INSERT_HEAD(&op_head, op, op_next);
@@ -225,6 +241,8 @@ do_option(char *name)
if (value && !seen) {
/* New option appears */
op = (struct opt *) calloc(1, sizeof *op);
+ if (op == NULL)
+ err(EXIT_FAILURE, "calloc");
op->op_name = ns(name);
op->op_value = value ? ns(value) : NULL;
SLIST_INSERT_HEAD(&op_head, op, op_next);
@@ -284,6 +302,7 @@ read_options(void)
struct opt_list *po;
int first = 1;
char genopt[MAXPATHLEN];
+ int flags = 0;
SLIST_INIT(&otab);
(void) snprintf(fname, sizeof(fname), "../../conf/options");
@@ -293,6 +312,7 @@ openit:
return;
}
next:
+ flags = 0;
wd = get_word(fp);
if (wd == (char *)EOF) {
(void) fclose(fp);
@@ -324,6 +344,18 @@ next:
(void) snprintf(genopt, sizeof(genopt), "opt_%s.h", lower(s));
val = genopt;
free(s);
+ } else if (eq(val, "=")) {
+ val = get_word(fp);
+ if (val == (char *)EOF) {
+ printf("%s: unexpected end of file\n", fname);
+ exit(1);
+ }
+ if (val == 0) {
+ printf("%s: Expected a right hand side at %s\n", fname,
+ this);
+ exit(1);
+ }
+ flags |= OL_ALIAS;
}
val = ns(val);
@@ -336,8 +368,11 @@ next:
}
po = (struct opt_list *) calloc(1, sizeof *po);
+ if (po == NULL)
+ err(EXIT_FAILURE, "calloc");
po->o_name = this;
po->o_file = val;
+ po->o_flags = flags;
SLIST_INSERT_HEAD(&otab, po, o_next);
goto next;
diff --git a/usr.sbin/ctm/ctm/ctm.1 b/usr.sbin/ctm/ctm/ctm.1
index 732b0b9..d5cc614 100644
--- a/usr.sbin/ctm/ctm/ctm.1
+++ b/usr.sbin/ctm/ctm/ctm.1
@@ -13,8 +13,8 @@
.\" $FreeBSD$
.\"
.Dd March 25, 1995
-.Os
.Dt CTM 1
+.Os
.Sh NAME
.Nm ctm
.Nd source code mirror program
diff --git a/usr.sbin/ctm/ctm/ctm.5 b/usr.sbin/ctm/ctm/ctm.5
index 678837e..a51c93b 100644
--- a/usr.sbin/ctm/ctm/ctm.5
+++ b/usr.sbin/ctm/ctm/ctm.5
@@ -13,8 +13,8 @@
.\" $FreeBSD$
.\"
.Dd March 25, 1995
-.Os
.Dt CTM 5
+.Os
.Sh NAME
.Nm ctm
.Nd source code mirror system
diff --git a/usr.sbin/devinfo/devinfo.8 b/usr.sbin/devinfo/devinfo.8
index 6c893dc..ecb3b01 100644
--- a/usr.sbin/devinfo/devinfo.8
+++ b/usr.sbin/devinfo/devinfo.8
@@ -28,8 +28,8 @@
.\" $FreeBSD$
.\"
.Dd November 28, 2005
-.Os
.Dt DEVINFO 8
+.Os
.Sh NAME
.Nm devinfo
.Nd print information about system device configuration
diff --git a/usr.sbin/fdformat/fdformat.1 b/usr.sbin/fdformat/fdformat.1
index 25891c0..596b09b 100644
--- a/usr.sbin/fdformat/fdformat.1
+++ b/usr.sbin/fdformat/fdformat.1
@@ -25,8 +25,8 @@
.\" $FreeBSD$
.\"
.Dd December 25, 2001
-.Os
.Dt FDFORMAT 1
+.Os
.Sh NAME
.Nm fdformat
.Nd format floppy disks
diff --git a/usr.sbin/fdread/fdread.1 b/usr.sbin/fdread/fdread.1
index 20a79fc..d29a4a4 100644
--- a/usr.sbin/fdread/fdread.1
+++ b/usr.sbin/fdread/fdread.1
@@ -27,8 +27,8 @@
.\"
.\"
.Dd May 14, 2001
-.Os
.Dt FDREAD 1
+.Os
.Sh NAME
.Nm fdread
.Nd read floppy disks
diff --git a/usr.sbin/fdwrite/fdwrite.1 b/usr.sbin/fdwrite/fdwrite.1
index 28df514..e847398 100644
--- a/usr.sbin/fdwrite/fdwrite.1
+++ b/usr.sbin/fdwrite/fdwrite.1
@@ -10,8 +10,8 @@
.\"
.\"
.Dd September 16, 1993
-.Os
.Dt FDWRITE 1
+.Os
.Sh NAME
.Nm fdwrite
.Nd format and write floppy disks
diff --git a/usr.sbin/fifolog/fifolog_create/fifolog.1 b/usr.sbin/fifolog/fifolog_create/fifolog.1
index 7db58e7..d0be0ce 100644
--- a/usr.sbin/fifolog/fifolog_create/fifolog.1
+++ b/usr.sbin/fifolog/fifolog_create/fifolog.1
@@ -25,8 +25,8 @@
.\" $FreeBSD$
.\"
.Dd February 9, 2008
-.Os
.Dt FIFOLOG 1
+.Os
.Sh NAME
.Nm fifolog_create , fifolog_writer , fifolog_reader
.Nd "initialize, write, seek and extract data from a fifolog"
diff --git a/usr.sbin/flowctl/flowctl.8 b/usr.sbin/flowctl/flowctl.8
index e72486b..75304c4 100644
--- a/usr.sbin/flowctl/flowctl.8
+++ b/usr.sbin/flowctl/flowctl.8
@@ -25,8 +25,8 @@
.\" $FreeBSD$
.\"
.Dd March 23, 2005
-.Os
.Dt FLOWCTL 8
+.Os
.Sh NAME
.Nm flowctl
.Nd
diff --git a/usr.sbin/freebsd-update/freebsd-update.8 b/usr.sbin/freebsd-update/freebsd-update.8
index 9c8120f..1d684b0 100644
--- a/usr.sbin/freebsd-update/freebsd-update.8
+++ b/usr.sbin/freebsd-update/freebsd-update.8
@@ -149,7 +149,7 @@ other than 3AM, to avoid overly imposing an uneven load
on the server(s) hosting the updates.
.It
In spite of its name,
-.Cm
+.Nm
IDS should not be relied upon as an "Intrusion Detection
System", since if the system has been tampered with
it cannot be trusted to operate correctly.
diff --git a/usr.sbin/fwcontrol/Makefile b/usr.sbin/fwcontrol/Makefile
index 9694d5e..10320d2 100644
--- a/usr.sbin/fwcontrol/Makefile
+++ b/usr.sbin/fwcontrol/Makefile
@@ -3,7 +3,7 @@
PROG= fwcontrol
SRCS= fwcontrol.c fwcrom.c fwdv.c fwmpegts.c
MAN= fwcontrol.8
-WARNS= 3
+WARNS?= 3
.PATH: ${.CURDIR}/../../sys/dev/firewire
diff --git a/usr.sbin/jail/jail.8 b/usr.sbin/jail/jail.8
index 77f1b95..85fe988 100644
--- a/usr.sbin/jail/jail.8
+++ b/usr.sbin/jail/jail.8
@@ -47,7 +47,6 @@
.Op Fl l u Ar username | Fl U Ar username
.Op Fl c | m
.Op Ar parameter=value ...
-.Br
.Nm
.Op Fl hi
.Op Fl n Ar jailname
@@ -55,7 +54,6 @@
.Op Fl s Ar securelevel
.Op Fl l u Ar username | Fl U Ar username
.Op Ar path hostname [ip[,..]] command ...
-.Br
.Nm
.Op Fl r Ar jail
.Sh DESCRIPTION
@@ -67,9 +65,7 @@ imprisoning the current process (and future descendants) inside it.
The options are as follows:
.Bl -tag -width indent
.It Fl d
-Allow making changes to a
-.Va
-dying jail.
+Allow making changes to a dying jail.
.It Fl h
Resolve the
.Va host.hostname
diff --git a/usr.sbin/jls/jls.c b/usr.sbin/jls/jls.c
index 3f4800c..a3a23b7 100644
--- a/usr.sbin/jls/jls.c
+++ b/usr.sbin/jls/jls.c
@@ -355,7 +355,7 @@ print_jail(int pflags, int jflags)
count = params[7].jp_valuelen / sizeof(struct in6_addr);
for (ai = 0; ai < count; ai++)
if (inet_ntop(AF_INET6,
- &((struct in_addr *)params[7].jp_value)[ai],
+ &((struct in6_addr *)params[7].jp_value)[ai],
ipbuf, sizeof(ipbuf)) == NULL)
err(1, "inet_ntop");
else
diff --git a/usr.sbin/lastlogin/lastlogin.8 b/usr.sbin/lastlogin/lastlogin.8
index 4d07a2b..0630163 100644
--- a/usr.sbin/lastlogin/lastlogin.8
+++ b/usr.sbin/lastlogin/lastlogin.8
@@ -55,7 +55,7 @@ If more than one
is given, the session information for each user is printed in
the order given on the command line.
Otherwise, information
-for all users is printed, sorted by uid.
+for all users is printed, sorted by name.
.Pp
The
.Nm
diff --git a/usr.sbin/lastlogin/lastlogin.c b/usr.sbin/lastlogin/lastlogin.c
index a1b5b6e..4c08547 100644
--- a/usr.sbin/lastlogin/lastlogin.c
+++ b/usr.sbin/lastlogin/lastlogin.c
@@ -39,6 +39,7 @@ __RCSID("$NetBSD: lastlogin.c,v 1.4 1998/02/03 04:45:35 perry Exp $");
#include <err.h>
#include <stdio.h>
#include <stdlib.h>
+#include <string.h>
#include <time.h>
#include <unistd.h>
#include <utmpx.h>
@@ -47,11 +48,19 @@ __RCSID("$NetBSD: lastlogin.c,v 1.4 1998/02/03 04:45:35 perry Exp $");
static void output(struct utmpx *);
static void usage(void);
+static int
+utcmp(const void *u1, const void *u2)
+{
+
+ return (strcmp(((const struct utmpx *)u1)->ut_user,
+ ((const struct utmpx *)u2)->ut_user));
+}
+
int
main(int argc, char *argv[])
{
- int ch, i;
- struct utmpx *u;
+ int ch, i, ulistsize;
+ struct utmpx *u, *ulist;
while ((ch = getopt(argc, argv, "")) != -1) {
usage();
@@ -74,12 +83,24 @@ main(int argc, char *argv[])
else {
if (setutxdb(UTXDB_LASTLOGIN, NULL) != 0)
errx(1, "failed to open lastlog database");
+ ulist = NULL;
+ ulistsize = 0;
while ((u = getutxent()) != NULL) {
if (u->ut_type != USER_PROCESS)
continue;
- output(u);
+ if ((ulistsize % 16) == 0) {
+ ulist = realloc(ulist,
+ (ulistsize + 16) * sizeof(struct utmpx));
+ if (ulist == NULL)
+ err(1, "malloc");
+ }
+ ulist[ulistsize++] = *u;
}
endutxent();
+
+ qsort(ulist, ulistsize, sizeof(struct utmpx), utcmp);
+ for (i = 0; i < ulistsize; i++)
+ output(&ulist[i]);
}
exit(0);
@@ -91,7 +112,7 @@ output(struct utmpx *u)
{
time_t t = u->ut_tv.tv_sec;
- printf("%-10s %-8s %-22s %s",
+ printf("%-10s %-8s %-22.22s %s",
u->ut_user, u->ut_line, u->ut_host, ctime(&t));
}
diff --git a/usr.sbin/mailwrapper/mailwrapper.8 b/usr.sbin/mailwrapper/mailwrapper.8
index 587826b..6e498f6 100644
--- a/usr.sbin/mailwrapper/mailwrapper.8
+++ b/usr.sbin/mailwrapper/mailwrapper.8
@@ -1,5 +1,5 @@
+.\" $OpenBSD: mailwrapper.8,v 1.10 2009/02/07 16:58:23 martynas Exp $
.\" $NetBSD: mailwrapper.8,v 1.11 2002/02/08 01:38:50 ross Exp $
-.\" $OpenBSD: mailwrapper.8,v 1.8 2003/06/12 12:59:51 jmc Exp $
.\" $FreeBSD$
.\"
.\" Copyright (c) 1998
@@ -31,7 +31,6 @@
.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
.\"
-.\" The following requests are required for all man pages.
.Dd August 7, 2006
.Dt MAILWRAPPER 8
.Os
diff --git a/usr.sbin/mailwrapper/mailwrapper.c b/usr.sbin/mailwrapper/mailwrapper.c
index d696d25..1b52a64 100644
--- a/usr.sbin/mailwrapper/mailwrapper.c
+++ b/usr.sbin/mailwrapper/mailwrapper.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: mailwrapper.c,v 1.16 2004/07/06 03:38:14 millert Exp $ */
+/* $OpenBSD: mailwrapper.c,v 1.18 2007/11/06 14:39:19 otto Exp $ */
/* $NetBSD: mailwrapper.c,v 1.9 2003/03/09 08:10:43 mjl Exp $ */
/*
@@ -61,8 +61,8 @@ initarg(struct arglist *al)
{
al->argc = 0;
al->maxc = 10;
- if ((al->argv = malloc(al->maxc * sizeof(char *))) == NULL)
- err(EX_TEMPFAIL, "malloc");
+ if ((al->argv = calloc(al->maxc, sizeof(char *))) == NULL)
+ err(EX_TEMPFAIL, "calloc");
}
static void
@@ -126,7 +126,7 @@ main(int argc, char *argv[], char *envp[])
continue;
}
- if ((from = strsep(&cp, WS)) == NULL)
+ if ((from = strsep(&cp, WS)) == NULL || cp == NULL)
goto parse_error;
cp += strspn(cp, WS);
diff --git a/usr.sbin/makefs/ffs/ffs_bswap.c b/usr.sbin/makefs/ffs/ffs_bswap.c
index d560884..18ace03 100644
--- a/usr.sbin/makefs/ffs/ffs_bswap.c
+++ b/usr.sbin/makefs/ffs/ffs_bswap.c
@@ -136,8 +136,6 @@ ffs_dinode1_swap(struct ufs1_dinode *o, struct ufs1_dinode *n)
n->di_mode = bswap16(o->di_mode);
n->di_nlink = bswap16(o->di_nlink);
- n->di_u.oldids[0] = bswap16(o->di_u.oldids[0]);
- n->di_u.oldids[1] = bswap16(o->di_u.oldids[1]);
n->di_size = bswap64(o->di_size);
n->di_atime = bswap32(o->di_atime);
n->di_atimensec = bswap32(o->di_atimensec);
diff --git a/usr.sbin/mergemaster/mergemaster.8 b/usr.sbin/mergemaster/mergemaster.8
index a56897c..2715791 100644
--- a/usr.sbin/mergemaster/mergemaster.8
+++ b/usr.sbin/mergemaster/mergemaster.8
@@ -24,7 +24,7 @@
.\"
.\" $FreeBSD$
.\"
-.Dd January 7, 2010
+.Dd March 13, 2010
.Dt MERGEMASTER 8
.Os
.Sh NAME
@@ -32,7 +32,8 @@
.Nd merge configuration files, et al during an upgrade
.Sh SYNOPSIS
.Nm
-.Op Fl scrvahipFCPU
+.Op Fl scrvhpCP
+.Op Fl a|iFU
.Op Fl m Ar /path/to/sources
.Op Fl t Ar /path/to/temp/root
.Op Fl d
@@ -168,7 +169,7 @@ and therefore can override both files.
When the comparison is done if there are any files remaining
in the temproot directory they will be listed, and if the
.Fl a
-option is not in use the user will be given the option of
+option is not in use the user will be given the option of
deleting the temproot directory.
If there are no files remaining in the temproot directory
it will be deleted.
@@ -206,9 +207,11 @@ If the
directory exists, it creates a new one in a previously
non-existent directory.
This option unsets the verbose flag,
-but other than
-.Fl U
-it is compatible with all other options.
+and is not compatible with
+.Fl i ,
+.Fl F ,
+or
+.Fl U .
Setting
.Fl a
makes
diff --git a/usr.sbin/mergemaster/mergemaster.sh b/usr.sbin/mergemaster/mergemaster.sh
index 2fa9906..7f06968 100755
--- a/usr.sbin/mergemaster/mergemaster.sh
+++ b/usr.sbin/mergemaster/mergemaster.sh
@@ -15,7 +15,7 @@ PATH=/bin:/usr/bin:/usr/sbin
display_usage () {
VERSION_NUMBER=`grep "[$]FreeBSD:" $0 | cut -d ' ' -f 4`
echo "mergemaster version ${VERSION_NUMBER}"
- echo 'Usage: mergemaster [-scrvahipFCPU]'
+ echo 'Usage: mergemaster [-scrvhpCP] [-a|[-iFU]]'
echo ' [-m /path] [-t /path] [-d] [-u N] [-w N] [-A arch] [-D /path]'
echo "Options:"
echo " -s Strict comparison (diff every pair of files)"
@@ -337,6 +337,18 @@ while getopts ":ascrvhipCPm:t:du:w:D:A:FU" COMMAND_LINE_ARGUMENT ; do
esac
done
+if [ -n "$AUTO_RUN" ]; then
+ if [ -n "$FREEBSD_ID" -o -n "$AUTO_UPGRADE" -o -n "$AUTO_INSTALL" ]; then
+ echo ''
+ echo "*** You have included the -a option along with one or more options"
+ echo ' that indicate that you wish mergemaster to actually make updates'
+ echo ' (-F, -U, or -i), however these options are not compatible.'
+ echo ' Please read mergemaster(8) for more information.'
+ echo ''
+ exit 1
+ fi
+fi
+
# Assign the location of the mtree database
#
MTREEDB=${MTREEDB:-${DESTDIR}/var/db}
diff --git a/usr.sbin/mount_nwfs/Makefile b/usr.sbin/mount_nwfs/Makefile
index 8fbb9a8..8f46581 100644
--- a/usr.sbin/mount_nwfs/Makefile
+++ b/usr.sbin/mount_nwfs/Makefile
@@ -6,7 +6,6 @@ MAN= mount_nwfs.8
MOUNT= ${.CURDIR}/../../sbin/mount
CFLAGS+= -DNWFS -I${MOUNT}
-WARNS?= 0
.PATH: ${MOUNT}
diff --git a/usr.sbin/mount_nwfs/mount_nwfs.c b/usr.sbin/mount_nwfs/mount_nwfs.c
index 98a5f8e..5f5f19a 100644
--- a/usr.sbin/mount_nwfs/mount_nwfs.c
+++ b/usr.sbin/mount_nwfs/mount_nwfs.c
@@ -62,16 +62,19 @@ static int parsercfile(struct ncp_conn_loginfo *li, struct nwfs_args *mdata);
static struct mntopt mopts[] = {
MOPT_STDOPTS,
- { NULL }
+ MOPT_END
};
-static int
-parsercfile(struct ncp_conn_loginfo *li, struct nwfs_args *mdata) {
+static int
+parsercfile(struct ncp_conn_loginfo *li __unused,
+ struct nwfs_args *mdata __unused)
+{
return 0;
}
int
-main(int argc, char *argv[]) {
+main(int argc, char *argv[])
+{
NWCONN_HANDLE connHandle;
struct nwfs_args mdata;
struct ncp_conn_loginfo li;
@@ -80,6 +83,7 @@ main(int argc, char *argv[]) {
struct tm *tm;
time_t ltime;
int opt, error, mntflags, nlsopt, wall_clock;
+ int uid_set, gid_set;
size_t len;
char *p, *p1, tmp[1024];
u_char *pv;
@@ -100,7 +104,7 @@ main(int argc, char *argv[]) {
mntflags = error = 0;
bzero(&mdata,sizeof(mdata));
- mdata.uid = mdata.gid = -1;
+ gid_set = uid_set = 0;
nlsopt = 0;
if (ncp_li_init(&li, argc, argv)) return 1;
@@ -182,6 +186,7 @@ main(int argc, char *argv[]) {
if (pwd == NULL)
errx(EX_NOUSER, "unknown user '%s'", optarg);
mdata.uid = pwd->pw_uid;
+ uid_set = 1;
break;
}
case 'g': {
@@ -192,6 +197,7 @@ main(int argc, char *argv[]) {
if (grp == NULL)
errx(EX_NOUSER, "unknown group '%s'", optarg);
mdata.gid = grp->gr_gid;
+ gid_set = 1;
break;
}
case 'd':
@@ -282,10 +288,10 @@ main(int argc, char *argv[]) {
if (ncp_geteinfo(mount_point, &einfo) == 0)
errx(EX_OSERR, "can't mount on %s twice", mount_point);
- if (mdata.uid == -1) {
+ if (uid_set == 0) {
mdata.uid = st.st_uid;
}
- if (mdata.gid == -1) {
+ if (gid_set == 0) {
mdata.gid = st.st_gid;
}
if (mdata.file_mode == 0 ) {
diff --git a/usr.sbin/mtest/mtest.8 b/usr.sbin/mtest/mtest.8
index b4d3514..9a961e0 100644
--- a/usr.sbin/mtest/mtest.8
+++ b/usr.sbin/mtest/mtest.8
@@ -27,8 +27,8 @@
.\" $FreeBSD$
.\"
.Dd April 29, 2009
-.Os
.Dt MTEST 8
+.Os
.Sh NAME
.Nm mtest
.Nd test multicast socket operations
diff --git a/usr.sbin/mtree/compare.c b/usr.sbin/mtree/compare.c
index 44556d6..fdd3767 100644
--- a/usr.sbin/mtree/compare.c
+++ b/usr.sbin/mtree/compare.c
@@ -181,13 +181,13 @@ typeerr: LABEL;
* Catches nano-second differences, but doesn't display them.
*/
if ((s->flags & F_TIME) &&
- ((s->st_mtimespec.tv_sec != p->fts_statp->st_mtimespec.tv_sec) ||
- (s->st_mtimespec.tv_nsec != p->fts_statp->st_mtimespec.tv_nsec))) {
+ ((s->st_mtimespec.tv_sec != p->fts_statp->st_mtim.tv_sec) ||
+ (s->st_mtimespec.tv_nsec != p->fts_statp->st_mtim.tv_nsec))) {
LABEL;
(void)printf("%smodification time expected %.24s ",
tab, ctime(&s->st_mtimespec.tv_sec));
(void)printf("found %.24s",
- ctime(&p->fts_statp->st_mtimespec.tv_sec));
+ ctime(&p->fts_statp->st_mtim.tv_sec));
if (uflag) {
tv[0].tv_sec = s->st_mtimespec.tv_sec;
tv[0].tv_usec = s->st_mtimespec.tv_nsec / 1000;
diff --git a/usr.sbin/mtree/create.c b/usr.sbin/mtree/create.c
index eee5037..da72fc6 100644
--- a/usr.sbin/mtree/create.c
+++ b/usr.sbin/mtree/create.c
@@ -213,8 +213,8 @@ statf(int indent, FTSENT *p)
(intmax_t)p->fts_statp->st_size);
if (keys & F_TIME)
output(indent, &offset, "time=%ld.%09ld",
- (long)p->fts_statp->st_mtimespec.tv_sec,
- p->fts_statp->st_mtimespec.tv_nsec);
+ (long)p->fts_statp->st_mtim.tv_sec,
+ p->fts_statp->st_mtim.tv_nsec);
if (keys & F_CKSUM && S_ISREG(p->fts_statp->st_mode)) {
if ((fd = open(p->fts_accpath, O_RDONLY, 0)) < 0 ||
crc(fd, &val, &len))
diff --git a/usr.sbin/mtree/mtree.8 b/usr.sbin/mtree/mtree.8
index f0a93ed..e57b798 100644
--- a/usr.sbin/mtree/mtree.8
+++ b/usr.sbin/mtree/mtree.8
@@ -41,9 +41,6 @@
.Op Fl f Ar spec
.Ek
.Bk -words
-.Op Fl f Ar spec
-.Ek
-.Bk -words
.Op Fl K Ar keywords
.Ek
.Bk -words
@@ -119,7 +116,7 @@ Same as
except a status of 2 is returned if the file hierarchy did not match
the specification.
.It Fl w
-Make some errorconditions non-fatal warnings.
+Make some errors non-fatal warnings.
.It Fl x
Do not descend below mount points in the file hierarchy.
.It Fl f Ar file
@@ -260,10 +257,10 @@ socket
The default set of keywords are
.Cm flags ,
.Cm gid ,
+.Cm link ,
.Cm mode ,
.Cm nlink ,
.Cm size ,
-.Cm link ,
.Cm time ,
and
.Cm uid .
diff --git a/usr.sbin/periodic/periodic.8 b/usr.sbin/periodic/periodic.8
index 6335930..22a96a2 100644
--- a/usr.sbin/periodic/periodic.8
+++ b/usr.sbin/periodic/periodic.8
@@ -25,8 +25,8 @@
.\" $FreeBSD$
.\"
.Dd August 30, 2007
-.Os
.Dt PERIODIC 8
+.Os
.Sh NAME
.Nm periodic
.Nd run periodic system functions
diff --git a/usr.sbin/pkg_install/Makefile b/usr.sbin/pkg_install/Makefile
index bf1a213..0aa1941 100644
--- a/usr.sbin/pkg_install/Makefile
+++ b/usr.sbin/pkg_install/Makefile
@@ -2,11 +2,11 @@
.include <bsd.own.mk>
-SUBDIR= lib add create delete info updating version
+SUBDIR= add create delete info updating version
.include <bsd.subdir.mk>
-DATE!= grep PKG_INSTALL_VERSION ${.CURDIR}/lib/lib.h | sed 's|.*[ ]||'
+DATE!= grep PKG_INSTALL_VERSION ${.CURDIR}/Makefile.inc | sed 's|.*=||'
distfile: clean
@(cd ${.CURDIR}/..; \
diff --git a/usr.sbin/pkg_install/Makefile.inc b/usr.sbin/pkg_install/Makefile.inc
index 2fa20aa..5c9e266 100644
--- a/usr.sbin/pkg_install/Makefile.inc
+++ b/usr.sbin/pkg_install/Makefile.inc
@@ -2,16 +2,11 @@
.include <bsd.own.mk>
-LIBINSTALL= ${.OBJDIR}/../lib/libinstall.a
+CFLAGS+= -DPKG_INSTALL_VERSION=20100423
+CFLAGS+= -DYES_I_KNOW_THE_API_IS_RUBBISH_AND_IS_DOOMED_TO_CHANGE
-DPADD+= ${LIBUTIL}
-LDADD+= -lutil
-
-.if ${MK_OPENSSL} != "no" && \
- defined(LDADD) && ${LDADD:M-lfetch} != ""
-DPADD+= ${LIBSSL} ${LIBCRYPTO}
-LDADD+= -lssl -lcrypto
-.endif
+DPADD+= ${LIBPKG}
+LDADD+= -lpkg
# Inherit BINDIR from one level up.
.include "../Makefile.inc"
diff --git a/usr.sbin/pkg_install/add/Makefile b/usr.sbin/pkg_install/add/Makefile
index 89988e7..03a43f0 100644
--- a/usr.sbin/pkg_install/add/Makefile
+++ b/usr.sbin/pkg_install/add/Makefile
@@ -1,14 +1,11 @@
# $FreeBSD$
+.include <bsd.own.mk>
+
PROG= pkg_add
SRCS= main.c perform.c futil.c extract.c
-CFLAGS+= -I${.CURDIR}/../lib
-
WARNS?= 3
WFORMAT?= 1
-DPADD= ${LIBINSTALL} ${LIBFETCH} ${LIBMD}
-LDADD= ${LIBINSTALL} -lfetch -lmd
-
.include <bsd.prog.mk>
diff --git a/usr.sbin/pkg_install/add/extract.c b/usr.sbin/pkg_install/add/extract.c
index 732a13f..6c2c4fc 100644
--- a/usr.sbin/pkg_install/add/extract.c
+++ b/usr.sbin/pkg_install/add/extract.c
@@ -23,7 +23,7 @@ __FBSDID("$FreeBSD$");
#include <ctype.h>
#include <err.h>
-#include "lib.h"
+#include <pkg.h>
#include "add.h"
diff --git a/usr.sbin/pkg_install/add/futil.c b/usr.sbin/pkg_install/add/futil.c
index e097140..c525320 100644
--- a/usr.sbin/pkg_install/add/futil.c
+++ b/usr.sbin/pkg_install/add/futil.c
@@ -22,7 +22,7 @@
__FBSDID("$FreeBSD$");
#include <err.h>
-#include "lib.h"
+#include <pkg.h>
#include "add.h"
/*
@@ -50,7 +50,7 @@ make_hierarchy(char *dir)
}
}
else {
- if (vsystem("/bin/mkdir %s", dir)) {
+ if (mkdir(dir, 0777) < 0) {
if (cp2)
*cp2 = '/';
return FAIL;
diff --git a/usr.sbin/pkg_install/add/main.c b/usr.sbin/pkg_install/add/main.c
index d9b381b..762b61a 100644
--- a/usr.sbin/pkg_install/add/main.c
+++ b/usr.sbin/pkg_install/add/main.c
@@ -26,7 +26,7 @@ __FBSDID("$FreeBSD$");
#include <err.h>
#include <getopt.h>
-#include "lib.h"
+#include <pkg.h>
#include "add.h"
char *Prefix = NULL;
@@ -128,6 +128,8 @@ main(int argc, char **argv)
static char temppackageroot[MAXPATHLEN];
static char pkgaddpath[MAXPATHLEN];
+ pkg_wrap(PKG_INSTALL_VERSION, argv);
+
if (*argv[0] != '/' && strchr(argv[0], '/') != NULL)
PkgAddCmd = realpath(argv[0], pkgaddpath);
else
diff --git a/usr.sbin/pkg_install/add/perform.c b/usr.sbin/pkg_install/add/perform.c
index 499d6c6..653a1d6 100644
--- a/usr.sbin/pkg_install/add/perform.c
+++ b/usr.sbin/pkg_install/add/perform.c
@@ -23,7 +23,7 @@ __FBSDID("$FreeBSD$");
#include <err.h>
#include <paths.h>
-#include "lib.h"
+#include <pkg.h>
#include "add.h"
#include <libgen.h>
@@ -78,6 +78,7 @@ pkg_do(char *pkg)
char pre_arg[FILENAME_MAX], post_arg[FILENAME_MAX];
char *conflict[2];
char **matched;
+ int fd;
conflictsfound = 0;
code = 0;
@@ -408,8 +409,10 @@ pkg_do(char *pkg)
goto bomb;
/* Look for the requirements file */
- if (fexists(REQUIRE_FNAME)) {
- vsystem("/bin/chmod +x %s", REQUIRE_FNAME); /* be sure */
+ if ((fd = open(REQUIRE_FNAME, O_RDWR)) != -1) {
+ fstat(fd, &sb);
+ fchmod(fd, sb.st_mode | S_IXALL); /* be sure, chmod a+x */
+ close(fd);
if (Verbose)
printf("Running requirements file first for %s..\n", Plist.name);
if (!Fake && vsystem("./%s %s INSTALL", REQUIRE_FNAME, Plist.name)) {
@@ -441,8 +444,10 @@ pkg_do(char *pkg)
}
/* If we're really installing, and have an installation file, run it */
- if (!NoInstall && fexists(pre_script)) {
- vsystem("/bin/chmod +x %s", pre_script); /* make sure */
+ if (!NoInstall && (fd = open(pre_script, O_RDWR)) != -1) {
+ fstat(fd, &sb);
+ fchmod(fd, sb.st_mode | S_IXALL); /* be sure, chmod a+x */
+ close(fd);
if (Verbose)
printf("Running pre-install for %s..\n", Plist.name);
if (!Fake && vsystem("./%s %s %s", pre_script, Plist.name, pre_arg)) {
@@ -470,8 +475,10 @@ pkg_do(char *pkg)
}
/* Run the installation script one last time? */
- if (!NoInstall && fexists(post_script)) {
- vsystem("/bin/chmod +x %s", post_script); /* make sure */
+ if (!NoInstall && (fd = open(post_script, O_RDWR)) != -1) {
+ fstat(fd, &sb);
+ fchmod(fd, sb.st_mode | S_IXALL); /* be sure, chmod a+x */
+ close(fd);
if (Verbose)
printf("Running post-install for %s..\n", Plist.name);
if (!Fake && vsystem("./%s %s %s", post_script, Plist.name, post_arg)) {
@@ -503,7 +510,10 @@ pkg_do(char *pkg)
goto success; /* close enough for government work */
}
/* Make sure pkg_info can read the entry */
- vsystem("/bin/chmod a+rx %s", LogDir);
+ fd = open(LogDir, O_RDWR);
+ fstat(fd, &sb);
+ fchmod(fd, sb.st_mode | S_IRALL | S_IXALL); /* be sure, chmod a+rx */
+ close(fd);
move_file(".", DESC_FNAME, LogDir);
move_file(".", COMMENT_FNAME, LogDir);
if (fexists(INSTALL_FNAME))
diff --git a/usr.sbin/pkg_install/create/Makefile b/usr.sbin/pkg_install/create/Makefile
index 42718c6..3334037 100644
--- a/usr.sbin/pkg_install/create/Makefile
+++ b/usr.sbin/pkg_install/create/Makefile
@@ -3,12 +3,10 @@
PROG= pkg_create
SRCS= main.c perform.c pl.c
-CFLAGS+= -I${.CURDIR}/../lib
-
WARNS?= 3
WFORMAT?= 1
-DPADD= ${LIBINSTALL} ${LIBMD}
-LDADD= ${LIBINSTALL} -lmd
+DPADD= ${LIBMD}
+LDADD= -lmd
.include <bsd.prog.mk>
diff --git a/usr.sbin/pkg_install/create/main.c b/usr.sbin/pkg_install/create/main.c
index d85392d..e463d1f 100644
--- a/usr.sbin/pkg_install/create/main.c
+++ b/usr.sbin/pkg_install/create/main.c
@@ -15,7 +15,7 @@ __FBSDID("$FreeBSD$");
#include <getopt.h>
#include <err.h>
-#include "lib.h"
+#include <pkg.h>
#include "create.h"
match_t MatchType = MATCH_GLOB;
@@ -72,6 +72,8 @@ main(int argc, char **argv)
int ch;
char **pkgs, **start, *tmp;
+ pkg_wrap(PKG_INSTALL_VERSION, argv);
+
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 e4f0d2e..0e14095 100644
--- a/usr.sbin/pkg_install/create/perform.c
+++ b/usr.sbin/pkg_install/create/perform.c
@@ -21,7 +21,7 @@
#include <sys/cdefs.h>
__FBSDID("$FreeBSD$");
-#include "lib.h"
+#include <pkg.h>
#include "create.h"
#include <err.h>
diff --git a/usr.sbin/pkg_install/create/pl.c b/usr.sbin/pkg_install/create/pl.c
index 18bbaf2..fe62d42 100644
--- a/usr.sbin/pkg_install/create/pl.c
+++ b/usr.sbin/pkg_install/create/pl.c
@@ -21,7 +21,7 @@
#include <sys/cdefs.h>
__FBSDID("$FreeBSD$");
-#include "lib.h"
+#include <pkg.h>
#include "create.h"
#include <errno.h>
#include <err.h>
diff --git a/usr.sbin/pkg_install/delete/Makefile b/usr.sbin/pkg_install/delete/Makefile
index c9a0fde..4f3b390 100644
--- a/usr.sbin/pkg_install/delete/Makefile
+++ b/usr.sbin/pkg_install/delete/Makefile
@@ -3,11 +3,6 @@
PROG= pkg_delete
SRCS= main.c perform.c
-CFLAGS+= -I${.CURDIR}/../lib
-
WFORMAT?= 1
-DPADD= ${LIBINSTALL} ${LIBMD}
-LDADD= ${LIBINSTALL} -lmd
-
.include <bsd.prog.mk>
diff --git a/usr.sbin/pkg_install/delete/main.c b/usr.sbin/pkg_install/delete/main.c
index f09a432..7677fe9 100644
--- a/usr.sbin/pkg_install/delete/main.c
+++ b/usr.sbin/pkg_install/delete/main.c
@@ -27,7 +27,7 @@ __FBSDID("$FreeBSD$");
#include <getopt.h>
#include <err.h>
-#include "lib.h"
+#include <pkg.h>
#include "delete.h"
char *Prefix = NULL;
@@ -67,6 +67,8 @@ main(int argc, char **argv)
const char *tmp;
struct stat stat_s;
+ pkg_wrap(PKG_INSTALL_VERSION, argv);
+
pkgs = start = argv;
while ((ch = getopt_long(argc, argv, opts, longopts, NULL)) != -1)
switch(ch) {
diff --git a/usr.sbin/pkg_install/delete/perform.c b/usr.sbin/pkg_install/delete/perform.c
index 1519fd7..02f9717 100644
--- a/usr.sbin/pkg_install/delete/perform.c
+++ b/usr.sbin/pkg_install/delete/perform.c
@@ -22,7 +22,7 @@
__FBSDID("$FreeBSD$");
#include <err.h>
-#include "lib.h"
+#include <pkg.h>
#include "delete.h"
static int pkg_do(char *);
@@ -132,6 +132,8 @@ pkg_do(char *pkg)
const char *post_script, *pre_arg, *post_arg;
struct reqr_by_entry *rb_entry;
struct reqr_by_head *rb_list;
+ int fd;
+ struct stat sb;
if (!pkg || !(len = strlen(pkg)))
return 1;
@@ -221,10 +223,12 @@ pkg_do(char *pkg)
setenv(PKG_PREFIX_VNAME, p->name, 1);
- if (fexists(REQUIRE_FNAME)) {
+ if ((fd = open(REQUIRE_FNAME, O_RDWR)) != -1) {
+ fstat(fd, &sb);
+ fchmod(fd, sb.st_mode | S_IXALL); /* be sure, chmod a+x */
+ close(fd);
if (Verbose)
printf("Executing 'require' script.\n");
- vsystem("/bin/chmod +x %s", REQUIRE_FNAME); /* be sure */
if (vsystem("./%s %s DEINSTALL", REQUIRE_FNAME, pkg)) {
warnx("package %s fails requirements %s", pkg,
Force ? "" : "- not deleted");
@@ -250,11 +254,13 @@ pkg_do(char *pkg)
post_script = pre_arg = post_arg = NULL;
}
- if (!NoDeInstall && pre_script != NULL && fexists(pre_script)) {
+ if (!NoDeInstall && pre_script != NULL && (fd = open(pre_script, O_RDWR)) != -1) {
if (Fake)
printf("Would execute de-install script at this point.\n");
else {
- vsystem("/bin/chmod +x %s", pre_script); /* make sure */
+ fstat(fd, &sb);
+ fchmod(fd, sb.st_mode | S_IXALL); /* be sure, chmod a+x */
+ close(fd);
if (vsystem("./%s %s %s", pre_script, pkg, pre_arg)) {
warnx("deinstall script returned error status");
if (!Force)
@@ -326,11 +332,13 @@ pkg_do(char *pkg)
return 1;
}
- if (!NoDeInstall && post_script != NULL && fexists(post_script)) {
+ if (!NoDeInstall && post_script != NULL && (fd = open(post_script, O_RDWR)) != -1) {
if (Fake)
printf("Would execute post-deinstall script at this point.\n");
else {
- vsystem("/bin/chmod +x %s", post_script); /* make sure */
+ fstat(fd, &sb);
+ fchmod(fd, sb.st_mode | S_IXALL); /* be sure, chmod a+x */
+ close(fd);
if (vsystem("./%s %s %s", post_script, pkg, post_arg)) {
warnx("post-deinstall script returned error status");
if (!Force)
diff --git a/usr.sbin/pkg_install/info/Makefile b/usr.sbin/pkg_install/info/Makefile
index 485cb22..ba3909d 100644
--- a/usr.sbin/pkg_install/info/Makefile
+++ b/usr.sbin/pkg_install/info/Makefile
@@ -3,11 +3,9 @@
PROG= pkg_info
SRCS= main.c perform.c show.c
-CFLAGS+= -I${.CURDIR}/../lib
-
WFORMAT?= 1
-DPADD= ${LIBINSTALL} ${LIBFETCH} ${LIBMD}
-LDADD= ${LIBINSTALL} -lfetch -lmd
+DPADD= ${LIBMD}
+LDADD= -lmd
.include <bsd.prog.mk>
diff --git a/usr.sbin/pkg_install/info/info.h b/usr.sbin/pkg_install/info/info.h
index 46e29b1..68ec710 100644
--- a/usr.sbin/pkg_install/info/info.h
+++ b/usr.sbin/pkg_install/info/info.h
@@ -33,25 +33,26 @@
#define MAXNAMESIZE 20
#endif
-#define SHOW_COMMENT 0x00001
-#define SHOW_DESC 0x00002
-#define SHOW_PLIST 0x00004
-#define SHOW_INSTALL 0x00008
-#define SHOW_DEINSTALL 0x00010
-#define SHOW_REQUIRE 0x00020
-#define SHOW_PREFIX 0x00040
-#define SHOW_INDEX 0x00080
-#define SHOW_FILES 0x00100
-#define SHOW_DISPLAY 0x00200
-#define SHOW_REQBY 0x00400
-#define SHOW_MTREE 0x00800
-#define SHOW_SIZE 0x01000
-#define SHOW_ORIGIN 0x02000
-#define SHOW_CKSUM 0x04000
-#define SHOW_FMTREV 0x08000
-#define SHOW_PTREV 0x10000
-#define SHOW_DEPEND 0x20000
-#define SHOW_PKGNAME 0x40000
+#define SHOW_COMMENT 0x000001
+#define SHOW_DESC 0x000002
+#define SHOW_PLIST 0x000004
+#define SHOW_INSTALL 0x000008
+#define SHOW_DEINSTALL 0x000010
+#define SHOW_REQUIRE 0x000020
+#define SHOW_PREFIX 0x000040
+#define SHOW_INDEX 0x000080
+#define SHOW_FILES 0x000100
+#define SHOW_DISPLAY 0x000200
+#define SHOW_REQBY 0x000400
+#define SHOW_MTREE 0x000800
+#define SHOW_SIZE 0x001000
+#define SHOW_ORIGIN 0x002000
+#define SHOW_CKSUM 0x004000
+#define SHOW_FMTREV 0x008000
+#define SHOW_PTREV 0x010000
+#define SHOW_DEPEND 0x020000
+#define SHOW_PKGNAME 0x040000
+#define SHOW_LPREV 0x100000
struct which_entry {
TAILQ_ENTRY(which_entry) next;
diff --git a/usr.sbin/pkg_install/info/main.c b/usr.sbin/pkg_install/info/main.c
index 2de638e..ca4e477 100644
--- a/usr.sbin/pkg_install/info/main.c
+++ b/usr.sbin/pkg_install/info/main.c
@@ -25,7 +25,7 @@ __FBSDID("$FreeBSD$");
#include <getopt.h>
#include <err.h>
-#include "lib.h"
+#include <pkg.h>
#include "info.h"
int Flags = 0;
@@ -68,6 +68,8 @@ main(int argc, char **argv)
char **pkgs, **start;
char *pkgs_split;
+ pkg_wrap(PKG_INSTALL_VERSION, argv);
+
whead = malloc(sizeof(struct which_head));
if (whead == NULL)
err(2, NULL);
@@ -225,7 +227,10 @@ main(int argc, char **argv)
}
case 'P':
- Flags = SHOW_PTREV;
+ if (Flags & SHOW_PTREV)
+ Flags |= SHOW_LPREV;
+ else
+ Flags = SHOW_PTREV;
break;
case 'h':
@@ -242,6 +247,11 @@ main(int argc, char **argv)
if (!Quiet)
printf("Package tools revision: ");
printf("%d\n", PKG_INSTALL_VERSION);
+ if (Flags & SHOW_LPREV) {
+ if (!Quiet)
+ printf("Libpkg revision: ");
+ printf("%d\n", libpkg_version());
+ }
exit(0);
}
diff --git a/usr.sbin/pkg_install/info/perform.c b/usr.sbin/pkg_install/info/perform.c
index 09cad78..d295612 100644
--- a/usr.sbin/pkg_install/info/perform.c
+++ b/usr.sbin/pkg_install/info/perform.c
@@ -21,7 +21,7 @@
#include <sys/cdefs.h>
__FBSDID("$FreeBSD$");
-#include "lib.h"
+#include <pkg.h>
#include "info.h"
#include <err.h>
#include <signal.h>
diff --git a/usr.sbin/pkg_install/info/show.c b/usr.sbin/pkg_install/info/show.c
index c65c312..0d3b4ad 100644
--- a/usr.sbin/pkg_install/info/show.c
+++ b/usr.sbin/pkg_install/info/show.c
@@ -21,7 +21,7 @@
#include <sys/cdefs.h>
__FBSDID("$FreeBSD$");
-#include "lib.h"
+#include <pkg.h>
#include "info.h"
#include <err.h>
#include <stdlib.h>
diff --git a/usr.sbin/pkg_install/lib/Makefile b/usr.sbin/pkg_install/lib/Makefile
deleted file mode 100644
index 84a41b8..0000000
--- a/usr.sbin/pkg_install/lib/Makefile
+++ /dev/null
@@ -1,11 +0,0 @@
-# $FreeBSD$
-
-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
-
-WARNS?= 3
-WFORMAT?= 1
-
-.include <bsd.lib.mk>
diff --git a/usr.sbin/pkg_install/lib/deps.c b/usr.sbin/pkg_install/lib/deps.c
deleted file mode 100644
index 66f44a9..0000000
--- a/usr.sbin/pkg_install/lib/deps.c
+++ /dev/null
@@ -1,241 +0,0 @@
-/*
- * FreeBSD install - a package for the installation and maintainance
- * 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.
- *
- * Maxim Sobolev
- * 14 March 2001
- *
- * Routines used to do various operations with dependencies
- * among installed packages.
- *
- */
-
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
-#include "lib.h"
-#include <err.h>
-#include <stdio.h>
-
-void list_deps(const char *pkgname, char **pkgs, char *listed,
- char *check_loop, char **newpkgs, int *nrnewpkgs,
- int *err_cnt);
-
-/*
- * Sort given NULL-terminated list of installed packages (pkgs) in
- * such a way that if package A depends on package B then after
- * sorting A will be listed before B no matter how they were
- * originally positioned in the list.
- *
- * Works by performing a recursive depth-first search on the
- * required-by lists.
- */
-
-int
-sortdeps(char **pkgs)
-{
- int i, err_cnt=0;
- int nrpkgs, nrnewpkgs;
- char *listed, *check_loop, **newpkgs;
- char *cp;
-
- if (pkgs[0] == NULL || pkgs[1] == NULL)
- return (0);
-
- nrpkgs = 0;
- while (pkgs[nrpkgs]) nrpkgs++;
- listed = alloca(nrpkgs);
- if (listed == NULL) {
- warnx("%s(): alloca() failed", __func__);
- return 1;
- }
- bzero(listed,nrpkgs);
- check_loop = alloca(nrpkgs);
- if (check_loop == NULL) {
- warnx("%s(): alloca() failed", __func__);
- return 1;
- }
- bzero(check_loop,nrpkgs);
- newpkgs = alloca(nrpkgs*sizeof(char*));
- if (newpkgs == NULL) {
- warnx("%s(): alloca() failed", __func__);
- return 1;
- }
- nrnewpkgs = 0;
-
- for (i = 0; pkgs[i]; i++) if (!listed[i]) {
- check_loop[i] = 1;
- cp = strchr(pkgs[i], ':');
- if (cp != NULL)
- *cp = '\0';
- list_deps(pkgs[i],pkgs,listed,check_loop,newpkgs,&nrnewpkgs,&err_cnt);
- if (cp != NULL)
- *cp = ':';
- listed[i] = 1;
- newpkgs[nrnewpkgs] = pkgs[i];
- nrnewpkgs++;
- }
-
- if (nrnewpkgs != nrpkgs) {
- fprintf(stderr,"This shouldn't happen, and indicates a huge error in the code.\n");
- exit(1);
- }
- for (i = 0; i < nrnewpkgs; i++) pkgs[i] = newpkgs[i];
-
- return err_cnt;
-}
-
-/*
- * This recursive function lists the dependencies (that is, the
- * "required-by"s) for pkgname, putting them into newpkgs.
- */
-
-void list_deps(const char *pkgname, char **pkgs, char *listed,
- char *check_loop, char **newpkgs, int *nrnewpkgs,
- int *err_cnt) {
- char **rb, **rbtmp;
- char *cp;
- int errcode, i, j;
- struct reqr_by_entry *rb_entry;
- struct reqr_by_head *rb_list;
-
- if (isinstalledpkg(pkgname) <= 0)
- return;
-
- errcode = requiredby(pkgname, &rb_list, FALSE, TRUE);
- if (errcode < 0)
- return;
- /*
- * We put rb_list into an argv style NULL terminated list,
- * because requiredby uses some static storage, and list_deps
- * is a recursive function.
- */
-
- rbtmp = rb = alloca((errcode + 1) * sizeof(*rb));
- if (rb == NULL) {
- warnx("%s(): alloca() failed", __func__);
- (*err_cnt)++;
- return;
- }
- STAILQ_FOREACH(rb_entry, rb_list, link) {
- *rbtmp = alloca(strlen(rb_entry->pkgname) + 1);
- if (*rbtmp == NULL) {
- warnx("%s(): alloca() failed", __func__);
- (*err_cnt)++;
- return;
- }
- strcpy(*rbtmp, rb_entry->pkgname);
- rbtmp++;
- }
- *rbtmp = NULL;
-
- for (i = 0; rb[i]; i++)
- for (j = 0; pkgs[j]; j++) if (!listed[j]) {
- cp = strchr(pkgs[j], ':');
- if (cp != NULL)
- *cp = '\0';
- if (strcmp(rb[i], pkgs[j]) == 0) { /*match */
- /*
- * Try to avoid deadlock if package A depends on B which in
- * turn depends on C and C due to an error depends on A.
- * It Should Never Happen[tm] in real life.
- */
- if (check_loop[j]) {
- warnx("dependency loop detected for package %s", pkgs[j]);
- (*err_cnt)++;
- }
- else {
- check_loop[j] = 1;
- list_deps(pkgs[j],pkgs,listed,check_loop,newpkgs,nrnewpkgs,err_cnt);
- listed[j] = 1;
- newpkgs[*nrnewpkgs] = pkgs[j];
- (*nrnewpkgs)++;
- }
- }
- if (cp != NULL)
- *cp = ':';
- }
-}
-
-/*
- * Load +REQUIRED_BY file and return a list with names of
- * packages that require package reffered to by `pkgname'.
- *
- * Optionally check that packages listed there are actually
- * installed and filter out those that don't (filter == TRUE).
- *
- * strict argument controls whether the caller want warnings
- * to be emitted when there are some non-fatal conditions,
- * i.e. package doesn't have +REQUIRED_BY file or some packages
- * listed in +REQUIRED_BY don't exist.
- *
- * Result returned in the **list, while return value is equal
- * to the number of entries in the resulting list. Print error
- * message and return -1 on error.
- */
-int
-requiredby(const char *pkgname, struct reqr_by_head **list, Boolean strict, Boolean filter)
-{
- FILE *fp;
- char fbuf[FILENAME_MAX], fname[FILENAME_MAX];
- int retval;
- struct reqr_by_entry *rb_entry;
- static struct reqr_by_head rb_list = STAILQ_HEAD_INITIALIZER(rb_list);
-
- *list = &rb_list;
- /* Deallocate any previously allocated space */
- while (!STAILQ_EMPTY(&rb_list)) {
- rb_entry = STAILQ_FIRST(&rb_list);
- STAILQ_REMOVE_HEAD(&rb_list, link);
- free(rb_entry);
- }
-
- if (isinstalledpkg(pkgname) <= 0) {
- if (strict == TRUE)
- warnx("no such package '%s' installed", pkgname);
- return -1;
- }
-
- snprintf(fname, sizeof(fname), "%s/%s/%s", LOG_DIR, pkgname,
- REQUIRED_BY_FNAME);
- fp = fopen(fname, "r");
- if (fp == NULL) {
- /* Probably pkgname doesn't have any packages that depend on it */
- if (strict == TRUE)
- warnx("couldn't open dependency file '%s'", fname);
- return 0;
- }
-
- retval = 0;
- while (fgets(fbuf, sizeof(fbuf), fp) != NULL) {
- if (fbuf[strlen(fbuf) - 1] == '\n')
- fbuf[strlen(fbuf) - 1] = '\0';
- if (filter == TRUE && isinstalledpkg(fbuf) <= 0) {
- if (strict == TRUE)
- warnx("package '%s' is recorded in the '%s' but isn't "
- "actually installed", fbuf, fname);
- continue;
- }
- retval++;
- rb_entry = malloc(sizeof(*rb_entry));
- if (rb_entry == NULL) {
- warnx("%s(): malloc() failed", __func__);
- retval = -1;
- break;
- }
- strlcpy(rb_entry->pkgname, fbuf, sizeof(rb_entry->pkgname));
- STAILQ_INSERT_TAIL(&rb_list, rb_entry, link);
- }
- fclose(fp);
-
- return retval;
-}
diff --git a/usr.sbin/pkg_install/lib/exec.c b/usr.sbin/pkg_install/lib/exec.c
deleted file mode 100644
index fc8220c..0000000
--- a/usr.sbin/pkg_install/lib/exec.c
+++ /dev/null
@@ -1,106 +0,0 @@
-/*
- * FreeBSD install - a package for the installation and maintainance
- * 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.
- *
- * Jordan K. Hubbard
- * 18 July 1993
- *
- * Miscellaneous system routines.
- *
- */
-
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
-#include "lib.h"
-#include <err.h>
-
-/*
- * Unusual system() substitute. Accepts format string and args,
- * builds and executes command. Returns exit code.
- */
-
-int
-vsystem(const char *fmt, ...)
-{
- va_list args;
- char *cmd;
- int ret, maxargs;
-
- maxargs = sysconf(_SC_ARG_MAX);
- maxargs -= 32; /* some slop for the sh -c */
- cmd = malloc(maxargs);
- if (!cmd) {
- warnx("vsystem can't alloc arg space");
- return 1;
- }
-
- va_start(args, fmt);
- if (vsnprintf(cmd, maxargs, fmt, args) > maxargs) {
- warnx("vsystem args are too long");
- return 1;
- }
-#ifdef DEBUG
-printf("Executing %s\n", cmd);
-#endif
- ret = system(cmd);
- va_end(args);
- free(cmd);
- return ret;
-}
-
-char *
-vpipe(const char *fmt, ...)
-{
- FILE *fp;
- char *cmd, *rp;
- int maxargs;
- va_list args;
-
- rp = malloc(MAXPATHLEN);
- if (!rp) {
- warnx("vpipe can't alloc buffer space");
- return NULL;
- }
- maxargs = sysconf(_SC_ARG_MAX);
- maxargs -= 32; /* some slop for the sh -c */
- cmd = alloca(maxargs);
- if (!cmd) {
- warnx("vpipe can't alloc arg space");
- return NULL;
- }
-
- va_start(args, fmt);
- if (vsnprintf(cmd, maxargs, fmt, args) > maxargs) {
- warnx("vsystem args are too long");
- return NULL;
- }
-#ifdef DEBUG
- fprintf(stderr, "Executing %s\n", cmd);
-#endif
- fflush(NULL);
- fp = popen(cmd, "r");
- if (fp == NULL) {
- warnx("popen() failed");
- return NULL;
- }
- get_string(rp, MAXPATHLEN, fp);
-#ifdef DEBUG
- fprintf(stderr, "Returned %s\n", rp);
-#endif
- va_end(args);
- if (pclose(fp) || (strlen(rp) == 0)) {
- free(rp);
- return NULL;
- }
- return rp;
-}
diff --git a/usr.sbin/pkg_install/lib/file.c b/usr.sbin/pkg_install/lib/file.c
deleted file mode 100644
index 0b74ddf..0000000
--- a/usr.sbin/pkg_install/lib/file.c
+++ /dev/null
@@ -1,427 +0,0 @@
-/*
- * FreeBSD install - a package for the installation and maintainance
- * 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.
- *
- * Jordan K. Hubbard
- * 18 July 1993
- *
- * Miscellaneous file access utilities.
- *
- */
-
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
-#include "lib.h"
-#include <err.h>
-#include <pwd.h>
-#include <time.h>
-#include <sys/wait.h>
-
-/* Quick check to see if a file exists */
-Boolean
-fexists(const char *fname)
-{
- struct stat dummy;
- if (!lstat(fname, &dummy))
- return TRUE;
- return FALSE;
-}
-
-/* Quick check to see if something is a directory or symlink to a directory */
-Boolean
-isdir(const char *fname)
-{
- struct stat sb;
-
- if (lstat(fname, &sb) != FAIL && S_ISDIR(sb.st_mode))
- return TRUE;
- else if (lstat(strconcat(fname, "/."), &sb) != FAIL && S_ISDIR(sb.st_mode))
- return TRUE;
- else
- return FALSE;
-}
-
-/* Check to see if file is a dir or symlink to a dir, and is empty */
-Boolean
-isemptydir(const char *fname)
-{
- if (isdir(fname)) {
- DIR *dirp;
- struct dirent *dp;
-
- dirp = opendir(fname);
- if (!dirp)
- return FALSE; /* no perms, leave it alone */
- for (dp = readdir(dirp); dp != NULL; dp = readdir(dirp)) {
- if (strcmp(dp->d_name, ".") && strcmp(dp->d_name, "..")) {
- closedir(dirp);
- return FALSE;
- }
- }
- (void)closedir(dirp);
- return TRUE;
- }
- return FALSE;
-}
-
-/*
- * Returns TRUE if file is a regular file or symlink pointing to a regular
- * file
- */
-Boolean
-isfile(const char *fname)
-{
- struct stat sb;
- if (stat(fname, &sb) != FAIL && S_ISREG(sb.st_mode))
- return TRUE;
- return FALSE;
-}
-
-/*
- * Check to see if file is a file or symlink pointing to a file and is empty.
- * If nonexistent or not a file, say "it's empty", otherwise return TRUE if
- * zero sized.
- */
-Boolean
-isemptyfile(const char *fname)
-{
- struct stat sb;
- if (stat(fname, &sb) != FAIL && S_ISREG(sb.st_mode)) {
- if (sb.st_size != 0)
- return FALSE;
- }
- return TRUE;
-}
-
-/* Returns TRUE if file is a symbolic link. */
-Boolean
-issymlink(const char *fname)
-{
- struct stat sb;
- if (lstat(fname, &sb) != FAIL && S_ISLNK(sb.st_mode))
- return TRUE;
- return FALSE;
-}
-
-/* Returns TRUE if file is a URL specification */
-Boolean
-isURL(const char *fname)
-{
- /*
- * I'm sure there are other types of URL specifications that I could
- * also be looking for here, but for now I'll just be happy to get ftp
- * and http working.
- */
- if (!fname)
- return FALSE;
- while (isspace(*fname))
- ++fname;
- if (!strncmp(fname, "ftp://", 6) || !strncmp(fname, "http://", 7) ||
- !strncmp(fname, "https://", 8) || !strncmp(fname, "file://", 7))
- return TRUE;
- return FALSE;
-}
-
-char *
-fileFindByPath(const char *base, const char *fname)
-{
- static char tmp[FILENAME_MAX];
- char *cp;
- const char *suffixes[] = {".tbz", ".tgz", ".tar", NULL};
- int i;
-
- if (fexists(fname) && isfile(fname)) {
- strcpy(tmp, fname);
- return tmp;
- }
- if (base) {
- strcpy(tmp, base);
-
- cp = strrchr(tmp, '/');
- if (cp) {
- *cp = '\0'; /* chop name */
- cp = strrchr(tmp, '/');
- }
- if (cp)
- for (i = 0; suffixes[i] != NULL; i++) {
- *(cp + 1) = '\0';
- strcat(cp, "All/");
- strcat(cp, fname);
- strcat(cp, suffixes[i]);
- if (fexists(tmp))
- return tmp;
- }
- }
-
- cp = getenv("PKG_PATH");
- while (cp) {
- char *cp2 = strsep(&cp, ":");
-
- for (i = 0; suffixes[i] != NULL; i++) {
- snprintf(tmp, FILENAME_MAX, "%s/%s%s", cp2 ? cp2 : cp, fname, suffixes[i]);
- if (fexists(tmp) && isfile(tmp))
- return tmp;
- }
- }
- return NULL;
-}
-
-char *
-fileGetContents(const char *fname)
-{
- char *contents;
- struct stat sb;
- int fd;
-
- if (stat(fname, &sb) == FAIL) {
- cleanup(0);
- errx(2, "%s: can't stat '%s'", __func__, fname);
- }
-
- contents = (char *)malloc(sb.st_size + 1);
- fd = open(fname, O_RDONLY, 0);
- if (fd == FAIL) {
- cleanup(0);
- errx(2, "%s: unable to open '%s' for reading", __func__, fname);
- }
- if (read(fd, contents, sb.st_size) != sb.st_size) {
- cleanup(0);
- errx(2, "%s: short read on '%s' - did not get %lld bytes", __func__,
- fname, (long long)sb.st_size);
- }
- close(fd);
- contents[sb.st_size] = '\0';
- return contents;
-}
-
-/*
- * Takes a filename and package name, returning (in "try") the
- * canonical "preserve" name for it.
- */
-Boolean
-make_preserve_name(char *try, int max, const char *name, const char *file)
-{
- int len, i;
-
- if ((len = strlen(file)) == 0)
- return FALSE;
- else
- i = len - 1;
- strncpy(try, file, max);
- if (try[i] == '/') /* Catch trailing slash early and save checking in the loop */
- --i;
- for (; i; i--) {
- if (try[i] == '/') {
- try[i + 1]= '.';
- strncpy(&try[i + 2], &file[i + 1], max - i - 2);
- break;
- }
- }
- if (!i) {
- try[0] = '.';
- strncpy(try + 1, file, max - 1);
- }
- /* I should probably be called rude names for these inline assignments */
- strncat(try, ".", max -= strlen(try));
- strncat(try, name, max -= strlen(name));
- strncat(try, ".", max--);
- strncat(try, "backup", max -= 6);
- return TRUE;
-}
-
-/* Write the contents of "str" to a file */
-void
-write_file(const char *name, const char *str)
-{
- FILE *fp;
- size_t len;
-
- fp = fopen(name, "w");
- if (!fp) {
- cleanup(0);
- errx(2, "%s: cannot fopen '%s' for writing", __func__, name);
- }
- len = strlen(str);
- if (fwrite(str, 1, len, fp) != len) {
- cleanup(0);
- errx(2, "%s: short fwrite on '%s', tried to write %ld bytes",
- __func__, name, (long)len);
- }
- if (fclose(fp)) {
- cleanup(0);
- errx(2, "%s: failure to fclose '%s'", __func__, name);
- }
-}
-
-void
-copy_file(const char *dir, const char *fname, const char *to)
-{
- char cmd[FILENAME_MAX];
-
- if (fname[0] == '/')
- snprintf(cmd, FILENAME_MAX, "/bin/cp -r %s %s", fname, to);
- else
- snprintf(cmd, FILENAME_MAX, "/bin/cp -r %s/%s %s", dir, fname, to);
- if (vsystem(cmd)) {
- cleanup(0);
- errx(2, "%s: could not perform '%s'", __func__, cmd);
- }
-}
-
-void
-move_file(const char *dir, const char *fname, const char *to)
-{
- char cmd[FILENAME_MAX];
-
- if (fname[0] == '/')
- snprintf(cmd, FILENAME_MAX, "/bin/mv %s %s", fname, to);
- else
- snprintf(cmd, FILENAME_MAX, "/bin/mv %s/%s %s", dir, fname, to);
- if (vsystem(cmd)) {
- cleanup(0);
- errx(2, "%s: could not perform '%s'", __func__, cmd);
- }
-}
-
-/*
- * Copy a hierarchy (possibly from dir) to the current directory, or
- * if "to" is TRUE, from the current directory to a location someplace
- * else.
- *
- * Though slower, using tar to copy preserves symlinks and everything
- * without me having to write some big hairy routine to do it.
- */
-void
-copy_hierarchy(const char *dir, const char *fname, Boolean to)
-{
- char cmd[FILENAME_MAX * 3];
-
- if (!to) {
- /* If absolute path, use it */
- if (*fname == '/')
- dir = "/";
- snprintf(cmd, FILENAME_MAX * 3, "/usr/bin/tar cf - -C %s %s | /usr/bin/tar xpf -",
- dir, fname);
- }
- else
- snprintf(cmd, FILENAME_MAX * 3, "/usr/bin/tar cf - %s | /usr/bin/tar xpf - -C %s",
- fname, dir);
-#ifdef DEBUG
- printf("Using '%s' to copy trees.\n", cmd);
-#endif
- if (system(cmd)) {
- cleanup(0);
- errx(2, "%s: could not perform '%s'", __func__, cmd);
- }
-}
-
-/* Unpack a tar file */
-int
-unpack(const char *pkg, const char *flist)
-{
- const char *comp, *cp;
- char suff[80];
-
- comp = "";
- /*
- * Figure out by a crude heuristic whether this or not this is probably
- * compressed and whichever compression utility was used (gzip or bzip2).
- */
- if (strcmp(pkg, "-")) {
- cp = strrchr(pkg, '.');
- if (cp) {
- strcpy(suff, cp + 1);
- if (strchr(suff, 'z') || strchr(suff, 'Z')) {
- if (strchr(suff, 'b'))
- comp = "-j";
- else
- comp = "-z";
- }
- }
- }
- else
- comp = "-j";
- if (vsystem("/usr/bin/tar -xp %s -f '%s' %s", comp, pkg, flist ? flist : "")) {
- warnx("tar extract of %s failed!", pkg);
- return 1;
- }
- return 0;
-}
-
-/*
- * Using fmt, replace all instances of:
- *
- * %F With the parameter "name"
- * %D With the parameter "dir"
- * %B Return the directory part ("base") of %D/%F
- * %f Return the filename part of %D/%F
- *
- * Does not check for overflow - caution!
- *
- */
-void
-format_cmd(char *buf, int max, const char *fmt, const char *dir, const char *name)
-{
- char *cp, scratch[FILENAME_MAX * 2];
- int l;
-
- while (*fmt && max > 0) {
- if (*fmt == '%') {
- switch (*++fmt) {
- case 'F':
- strncpy(buf, name, max);
- l = strlen(name);
- buf += l, max -= l;
- break;
-
- case 'D':
- strncpy(buf, dir, max);
- l = strlen(dir);
- buf += l, max -= l;
- break;
-
- case 'B':
- snprintf(scratch, FILENAME_MAX * 2, "%s/%s", dir, name);
- cp = &scratch[strlen(scratch) - 1];
- while (cp != scratch && *cp != '/')
- --cp;
- *cp = '\0';
- strncpy(buf, scratch, max);
- l = strlen(scratch);
- buf += l, max -= l;
- break;
-
- case 'f':
- snprintf(scratch, FILENAME_MAX * 2, "%s/%s", dir, name);
- cp = &scratch[strlen(scratch) - 1];
- while (cp != scratch && *(cp - 1) != '/')
- --cp;
- strncpy(buf, cp, max);
- l = strlen(cp);
- buf += l, max -= l;
- break;
-
- default:
- *buf++ = *fmt;
- --max;
- break;
- }
- ++fmt;
- }
- else {
- *buf++ = *fmt++;
- --max;
- }
- }
- *buf = '\0';
-}
diff --git a/usr.sbin/pkg_install/lib/global.c b/usr.sbin/pkg_install/lib/global.c
deleted file mode 100644
index e136ec8..0000000
--- a/usr.sbin/pkg_install/lib/global.c
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- * FreeBSD install - a package for the installation and maintainance
- * 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.
- *
- * Jordan K. Hubbard
-
- * 18 July 1993
- *
- * Semi-convenient place to stick some needed globals.
- *
- */
-
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
-#include "lib.h"
-
-/* These are global for all utils */
-Boolean Quiet = FALSE;
-Boolean Fake = FALSE;
-Boolean Force = FALSE;
-int AutoAnswer = FALSE;
-int Verbose = 0; /* Allow multiple levels of verbose. */
diff --git a/usr.sbin/pkg_install/lib/lib.h b/usr.sbin/pkg_install/lib/lib.h
deleted file mode 100644
index 4a6c625..0000000
--- a/usr.sbin/pkg_install/lib/lib.h
+++ /dev/null
@@ -1,248 +0,0 @@
-/* $FreeBSD$ */
-
-/*
- * FreeBSD install - a package for the installation and maintainance
- * 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.
- *
- * Jordan K. Hubbard
- * 18 July 1993
- *
- * Include and define various things wanted by the library routines.
- *
- */
-
-#ifndef _INST_LIB_LIB_H_
-#define _INST_LIB_LIB_H_
-
-/* Includes */
-#include <sys/param.h>
-#include <sys/file.h>
-#include <sys/stat.h>
-#include <sys/queue.h>
-#include <ctype.h>
-#include <dirent.h>
-#include <stdarg.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <unistd.h>
-
-/* Macros */
-#define SUCCESS (0)
-#define FAIL (-1)
-
-#ifndef TRUE
-#define TRUE (1)
-#endif
-
-#ifndef FALSE
-#define FALSE (0)
-#endif
-
-#define YES 2
-#define NO 1
-
-/* Usually "rm", but often "echo" during debugging! */
-#define REMOVE_CMD "/bin/rm"
-
-/* Usually "rm", but often "echo" during debugging! */
-#define RMDIR_CMD "/bin/rmdir"
-
-/* Where the ports lives by default */
-#define DEF_PORTS_DIR "/usr/ports"
-/* just in case we change the environment variable name */
-#define PORTSDIR "PORTSDIR"
-/* macro to get name of directory where the ports lives */
-#define PORTS_DIR (getenv(PORTSDIR) ? getenv(PORTSDIR) : DEF_PORTS_DIR)
-
-/* Where we put logging information by default, else ${PKG_DBDIR} if set */
-#define DEF_LOG_DIR "/var/db/pkg"
-/* just in case we change the environment variable name */
-#define PKG_DBDIR "PKG_DBDIR"
-/* macro to get name of directory where we put logging information */
-#define LOG_DIR (getenv(PKG_DBDIR) ? getenv(PKG_DBDIR) : DEF_LOG_DIR)
-
-/* The names of our "special" files */
-#define CONTENTS_FNAME "+CONTENTS"
-#define COMMENT_FNAME "+COMMENT"
-#define DESC_FNAME "+DESC"
-#define INSTALL_FNAME "+INSTALL"
-#define POST_INSTALL_FNAME "+POST-INSTALL"
-#define DEINSTALL_FNAME "+DEINSTALL"
-#define POST_DEINSTALL_FNAME "+POST-DEINSTALL"
-#define REQUIRE_FNAME "+REQUIRE"
-#define REQUIRED_BY_FNAME "+REQUIRED_BY"
-#define DISPLAY_FNAME "+DISPLAY"
-#define MTREE_FNAME "+MTREE_DIRS"
-
-#if defined(__FreeBSD_version) && __FreeBSD_version >= 900000
-#define INDEX_FNAME "INDEX-9"
-#elif defined(__FreeBSD_version) && __FreeBSD_version >= 800000
-#define INDEX_FNAME "INDEX-8"
-#elif defined(__FreeBSD_version) && __FreeBSD_version >= 700000
-#define INDEX_FNAME "INDEX-7"
-#elif defined(__FreeBSD_version) && __FreeBSD_version >= 600000
-#define INDEX_FNAME "INDEX-6"
-#else
-#define INDEX_FNAME "INDEX"
-#endif
-
-#define CMD_CHAR '@' /* prefix for extended PLIST cmd */
-
-/* The name of the "prefix" environment variable given to scripts */
-#define PKG_PREFIX_VNAME "PKG_PREFIX"
-
-/*
- * Version of the package tools - increase whenever you make a change
- * in the code that is not cosmetic only.
- */
-#define PKG_INSTALL_VERSION 20100122
-
-#define PKG_WRAPCONF_FNAME "/var/db/pkg_install.conf"
-#define main(argc, argv) real_main(argc, argv)
-
-/* Version numbers to assist with changes in package file format */
-#define PLIST_FMT_VER_MAJOR 1
-#define PLIST_FMT_VER_MINOR 1
-
-enum _plist_t {
- PLIST_FILE, PLIST_CWD, PLIST_CMD, PLIST_CHMOD,
- PLIST_CHOWN, PLIST_CHGRP, PLIST_COMMENT, PLIST_IGNORE,
- PLIST_NAME, PLIST_UNEXEC, PLIST_SRC, PLIST_DISPLAY,
- PLIST_PKGDEP, PLIST_CONFLICTS, PLIST_MTREE, PLIST_DIR_RM,
- PLIST_IGNORE_INST, PLIST_OPTION, PLIST_ORIGIN, PLIST_DEPORIGIN,
- PLIST_NOINST
-};
-typedef enum _plist_t plist_t;
-
-enum _match_t {
- MATCH_ALL, MATCH_EXACT, MATCH_GLOB, MATCH_NGLOB, MATCH_EREGEX, MATCH_REGEX
-};
-typedef enum _match_t match_t;
-
-/* Types */
-typedef unsigned int Boolean;
-
-struct _plist {
- struct _plist *prev, *next;
- char *name;
- Boolean marked;
- plist_t type;
-};
-typedef struct _plist *PackingList;
-
-struct _pack {
- struct _plist *head, *tail;
- const char *name;
- const char *origin;
- int fmtver_maj, fmtver_mnr;
-};
-typedef struct _pack Package;
-
-struct reqr_by_entry {
- STAILQ_ENTRY(reqr_by_entry) link;
- char pkgname[PATH_MAX];
-};
-STAILQ_HEAD(reqr_by_head, reqr_by_entry);
-
-/* Prototypes */
-/* Misc */
-int vsystem(const char *, ...);
-char *vpipe(const char *, ...);
-void cleanup(int);
-const char *make_playpen(char *, off_t);
-char *where_playpen(void);
-int leave_playpen(void);
-off_t min_free(const char *);
-
-/* String */
-char *get_dash_string(char **);
-char *copy_string(const char *);
-char *copy_string_adds_newline(const char *);
-Boolean suffix(const char *, const char *);
-void nuke_suffix(char *);
-void str_lowercase(char *);
-char *strconcat(const char *, const char *);
-char *get_string(char *, int, FILE *);
-
-/* File */
-Boolean fexists(const char *);
-Boolean isdir(const char *);
-Boolean isemptydir(const char *fname);
-Boolean isemptyfile(const char *fname);
-Boolean isfile(const char *);
-Boolean isempty(const char *);
-Boolean issymlink(const char *);
-Boolean isURL(const char *);
-const char *fileGetURL(const char *, const char *, int);
-char *fileFindByPath(const char *, const char *);
-char *fileGetContents(const char *);
-void write_file(const char *, const char *);
-void copy_file(const char *, const char *, const char *);
-void move_file(const char *, const char *, const char *);
-void copy_hierarchy(const char *, const char *, Boolean);
-int delete_hierarchy(const char *, Boolean, Boolean);
-int unpack(const char *, const char *);
-void format_cmd(char *, int, const char *, const char *, const char *);
-
-/* Msg */
-void upchuck(const char *);
-void barf(const char *, ...);
-void whinge(const char *, ...);
-Boolean y_or_n(Boolean, const char *, ...);
-
-/* Packing list */
-PackingList new_plist_entry(void);
-PackingList last_plist(Package *);
-PackingList find_plist(Package *, plist_t);
-char *find_plist_option(Package *, const char *name);
-void plist_delete(Package *, Boolean, plist_t, const char *);
-void free_plist(Package *);
-void mark_plist(Package *);
-void csum_plist_entry(char *, PackingList);
-void add_plist(Package *, plist_t, const char *);
-void add_plist_top(Package *, plist_t, const char *);
-void delete_plist(Package *pkg, Boolean all, plist_t type, const char *name);
-void write_plist(Package *, FILE *);
-void read_plist(Package *, FILE *);
-int plist_cmd(const char *, char **);
-int delete_package(Boolean, Boolean, Package *);
-Boolean make_preserve_name(char *, int, const char *, const char *);
-
-/* For all */
-int pkg_perform(char **);
-int real_main(int, char **);
-
-/* Query installed packages */
-char **matchinstalled(match_t, char **, int *);
-char **matchbyorigin(const char *, int *);
-char ***matchallbyorigin(const char **, int *);
-int isinstalledpkg(const char *name);
-int pattern_match(match_t MatchType, char *pattern, const char *pkgname);
-
-/* Dependencies */
-int sortdeps(char **);
-int chkifdepends(const char *, const char *);
-int requiredby(const char *, struct reqr_by_head **, Boolean, Boolean);
-
-/* Version */
-int verscmp(Package *, int, int);
-int version_cmp(const char *, const char *);
-
-/* Externs */
-extern Boolean Quiet;
-extern Boolean Fake;
-extern Boolean Force;
-extern int AutoAnswer;
-extern int Verbose;
-
-#endif /* _INST_LIB_LIB_H_ */
diff --git a/usr.sbin/pkg_install/lib/match.c b/usr.sbin/pkg_install/lib/match.c
deleted file mode 100644
index 1f8b02a..0000000
--- a/usr.sbin/pkg_install/lib/match.c
+++ /dev/null
@@ -1,603 +0,0 @@
-/*
- * FreeBSD install - a package for the installation and maintainance
- * 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.
- *
- * Maxim Sobolev
- * 24 February 2001
- *
- * Routines used to query installed packages.
- *
- */
-
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
-#include "lib.h"
-#include <err.h>
-#include <fnmatch.h>
-#include <fts.h>
-#include <regex.h>
-
-/*
- * Simple structure representing argv-like
- * NULL-terminated list.
- */
-struct store {
- int currlen;
- int used;
- char **store;
-};
-
-static int rex_match(const char *, const char *, int);
-static int csh_match(const char *, const char *, int);
-struct store *storecreate(struct store *);
-static int storeappend(struct store *, const char *);
-static int fname_cmp(const FTSENT * const *, const FTSENT * const *);
-
-/*
- * Function to query names of installed packages.
- * MatchType - one of MATCH_ALL, MATCH_EREGEX, MATCH_REGEX, MATCH_GLOB, MATCH_NGLOB;
- * patterns - NULL-terminated list of glob or regex patterns
- * (could be NULL for MATCH_ALL);
- * retval - return value (could be NULL if you don't want/need
- * return value).
- * Returns NULL-terminated list with matching names.
- * Names in list returned are dynamically allocated and should
- * not be altered by the caller.
- */
-char **
-matchinstalled(match_t MatchType, char **patterns, int *retval)
-{
- int i, errcode, len;
- char *matched;
- const char *paths[2] = {LOG_DIR, NULL};
- static struct store *store = NULL;
- FTS *ftsp;
- FTSENT *f;
- Boolean *lmatched = NULL;
-
- store = storecreate(store);
- if (store == NULL) {
- if (retval != NULL)
- *retval = 1;
- return NULL;
- }
-
- if (retval != NULL)
- *retval = 0;
-
- if (!isdir(paths[0])) {
- if (retval != NULL)
- *retval = 1;
- return NULL;
- /* Not reached */
- }
-
- /* Count number of patterns */
- if (patterns != NULL) {
- for (len = 0; patterns[len]; len++) {}
- lmatched = alloca(sizeof(*lmatched) * len);
- if (lmatched == NULL) {
- warnx("%s(): alloca() failed", __func__);
- if (retval != NULL)
- *retval = 1;
- return NULL;
- }
- } else
- len = 0;
-
- for (i = 0; i < len; i++)
- lmatched[i] = FALSE;
-
- ftsp = fts_open((char * const *)(uintptr_t)paths, FTS_LOGICAL | FTS_NOCHDIR | FTS_NOSTAT, fname_cmp);
- if (ftsp != NULL) {
- while ((f = fts_read(ftsp)) != NULL) {
- if (f->fts_info == FTS_D && f->fts_level == 1) {
- fts_set(ftsp, f, FTS_SKIP);
- matched = NULL;
- errcode = 0;
- if (MatchType == MATCH_ALL)
- matched = f->fts_name;
- else
- for (i = 0; patterns[i]; i++) {
- errcode = pattern_match(MatchType, patterns[i], f->fts_name);
- if (errcode == 1) {
- matched = f->fts_name;
- lmatched[i] = TRUE;
- errcode = 0;
- }
- if (matched != NULL || errcode != 0)
- break;
- }
- if (errcode == 0 && matched != NULL)
- errcode = storeappend(store, matched);
- if (errcode != 0) {
- if (retval != NULL)
- *retval = 1;
- return NULL;
- /* Not reached */
- }
- }
- }
- fts_close(ftsp);
- }
-
- if (MatchType == MATCH_GLOB) {
- for (i = 0; i < len; i++)
- if (lmatched[i] == FALSE)
- storeappend(store, patterns[i]);
- }
-
- if (store->used == 0)
- return NULL;
- else
- return store->store;
-}
-
-int
-pattern_match(match_t MatchType, char *pattern, const char *pkgname)
-{
- int errcode = 0;
- const char *fname = pkgname;
- char basefname[PATH_MAX];
- char condchar = '\0';
- char *condition;
-
- /* do we have an appended condition? */
- condition = strpbrk(pattern, "<>=");
- if (condition) {
- const char *ch;
- /* yes, isolate the pattern from the condition ... */
- if (condition > pattern && condition[-1] == '!')
- condition--;
- condchar = *condition;
- *condition = '\0';
- /* ... and compare the name without version */
- ch = strrchr(fname, '-');
- if (ch && ch - fname < PATH_MAX) {
- strlcpy(basefname, fname, ch - fname + 1);
- fname = basefname;
- }
- }
-
- switch (MatchType) {
- case MATCH_EREGEX:
- case MATCH_REGEX:
- errcode = rex_match(pattern, fname, MatchType == MATCH_EREGEX ? 1 : 0);
- break;
- case MATCH_NGLOB:
- case MATCH_GLOB:
- errcode = (csh_match(pattern, fname, 0) == 0) ? 1 : 0;
- break;
- case MATCH_EXACT:
- errcode = (strcmp(pattern, fname) == 0) ? 1 : 0;
- break;
- case MATCH_ALL:
- errcode = 1;
- break;
- default:
- break;
- }
-
- /* loop over all appended conditions */
- while (condition) {
- /* restore the pattern */
- *condition = condchar;
- /* parse the condition (fun with bits) */
- if (errcode == 1) {
- char *nextcondition;
- /* compare version numbers */
- int match = 0;
- if (*++condition == '=') {
- match = 2;
- condition++;
- }
- switch(condchar) {
- case '<':
- match |= 1;
- break;
- case '>':
- match |= 4;
- break;
- case '=':
- match |= 2;
- break;
- case '!':
- match = 5;
- break;
- }
- /* isolate the version number from the next condition ... */
- nextcondition = strpbrk(condition, "<>=!");
- if (nextcondition) {
- condchar = *nextcondition;
- *nextcondition = '\0';
- }
- /* and compare the versions (version_cmp removes the filename for us) */
- if ((match & (1 << (version_cmp(pkgname, condition) + 1))) == 0)
- errcode = 0;
- condition = nextcondition;
- } else {
- break;
- }
- }
-
- return errcode;
-}
-
-/*
- * Synopsis is similar to matchinstalled(), but use origin
- * as a key for matching packages.
- */
-char ***
-matchallbyorigin(const char **origins, int *retval)
-{
- char **installed, **allorigins = NULL;
- char ***matches = NULL;
- int i, j;
-
- if (retval != NULL)
- *retval = 0;
-
- installed = matchinstalled(MATCH_ALL, NULL, retval);
- if (installed == NULL)
- return NULL;
-
- /* Gather origins for all installed packages */
- for (i = 0; installed[i] != NULL; i++) {
- FILE *fp;
- char *buf, *cp, tmp[PATH_MAX];
- int cmd;
-
- allorigins = realloc(allorigins, (i + 1) * sizeof(*allorigins));
- allorigins[i] = NULL;
-
- snprintf(tmp, PATH_MAX, "%s/%s", LOG_DIR, installed[i]);
- /*
- * SPECIAL CASE: ignore empty dirs, since we can can see them
- * during port installation.
- */
- if (isemptydir(tmp))
- continue;
- snprintf(tmp, PATH_MAX, "%s/%s", tmp, CONTENTS_FNAME);
- fp = fopen(tmp, "r");
- if (fp == NULL) {
- warnx("the package info for package '%s' is corrupt", installed[i]);
- continue;
- }
-
- cmd = -1;
- while (fgets(tmp, sizeof(tmp), fp)) {
- int len = strlen(tmp);
-
- while (len && isspace(tmp[len - 1]))
- tmp[--len] = '\0';
- if (!len)
- continue;
- cp = tmp;
- if (tmp[0] != CMD_CHAR)
- continue;
- cmd = plist_cmd(tmp + 1, &cp);
- if (cmd == PLIST_ORIGIN) {
- asprintf(&buf, "%s", cp);
- allorigins[i] = buf;
- break;
- }
- }
- if (cmd != PLIST_ORIGIN && ( Verbose || 0 != strncmp("bsdpan-", installed[i], 7 ) ) )
- warnx("package %s has no origin recorded", installed[i]);
- fclose(fp);
- }
-
- /* Resolve origins into package names, retaining the sequence */
- for (i = 0; origins[i] != NULL; i++) {
- matches = realloc(matches, (i + 1) * sizeof(*matches));
- struct store *store = NULL;
- store = storecreate(store);
-
- for (j = 0; installed[j] != NULL; j++) {
- if (allorigins[j]) {
- if (csh_match(origins[i], allorigins[j], FNM_PATHNAME) == 0) {
- storeappend(store, installed[j]);
- }
- }
- }
- if (store->used == 0)
- matches[i] = NULL;
- else
- matches[i] = store->store;
- }
-
- if (allorigins) {
- for (i = 0; installed[i] != NULL; i++)
- if (allorigins[i])
- free(allorigins[i]);
- free(allorigins);
- }
-
- return matches;
-}
-
-/*
- * Synopsis is similar to matchinstalled(), but use origin
- * as a key for matching packages.
- */
-char **
-matchbyorigin(const char *origin, int *retval)
-{
- const char *origins[2];
- char ***tmp;
-
- origins[0] = origin;
- origins[1] = NULL;
-
- tmp = matchallbyorigin(origins, retval);
- if (tmp && tmp[0]) {
- return tmp[0];
- } else {
- return NULL;
- }
-}
-
-/*
- * Small linked list to memoize results of isinstalledpkg(). A hash table
- * would be faster but for n ~= 1000 may be overkill.
- */
-struct iip_memo {
- LIST_ENTRY(iip_memo) iip_link;
- char *iip_name;
- int iip_result;
-};
-LIST_HEAD(, iip_memo) iip_memo = LIST_HEAD_INITIALIZER(iip_memo);
-
-/*
- *
- * Return 1 if the specified package is installed,
- * 0 if not, and -1 if an error occured.
- */
-int
-isinstalledpkg(const char *name)
-{
- int result;
- char *buf, *buf2;
- struct iip_memo *memo;
-
- LIST_FOREACH(memo, &iip_memo, iip_link) {
- if (strcmp(memo->iip_name, name) == 0)
- return memo->iip_result;
- }
-
- buf2 = NULL;
- asprintf(&buf, "%s/%s", LOG_DIR, name);
- if (buf == NULL)
- goto errout;
- if (!isdir(buf) || access(buf, R_OK) == FAIL) {
- result = 0;
- } else {
- asprintf(&buf2, "%s/%s", buf, CONTENTS_FNAME);
- if (buf2 == NULL)
- goto errout;
-
- if (!isfile(buf2) || access(buf2, R_OK) == FAIL)
- result = -1;
- else
- result = 1;
- }
-
- free(buf);
- buf = strdup(name);
- if (buf == NULL)
- goto errout;
- free(buf2);
- buf2 = NULL;
-
- memo = malloc(sizeof *memo);
- if (memo == NULL)
- goto errout;
- memo->iip_name = buf;
- memo->iip_result = result;
- LIST_INSERT_HEAD(&iip_memo, memo, iip_link);
- return result;
-
-errout:
- if (buf != NULL)
- free(buf);
- if (buf2 != NULL)
- free(buf2);
- return -1;
-}
-
-/*
- * Returns 1 if specified pkgname matches RE pattern.
- * Otherwise returns 0 if doesn't match or -1 if RE
- * engine reported an error (usually invalid syntax).
- */
-static int
-rex_match(const char *pattern, const char *pkgname, int extended)
-{
- char errbuf[128];
- int errcode;
- int retval;
- regex_t rex;
-
- retval = 0;
-
- errcode = regcomp(&rex, pattern, (extended ? REG_EXTENDED : REG_BASIC) | REG_NOSUB);
- if (errcode == 0)
- errcode = regexec(&rex, pkgname, 0, NULL, 0);
-
- if (errcode == 0) {
- retval = 1;
- } else if (errcode != REG_NOMATCH) {
- regerror(errcode, &rex, errbuf, sizeof(errbuf));
- warnx("%s: %s", pattern, errbuf);
- retval = -1;
- }
-
- regfree(&rex);
-
- return retval;
-}
-
-/*
- * Match string by a csh-style glob pattern. Returns 0 on
- * match and FNM_NOMATCH otherwise, to be compatible with
- * fnmatch(3).
- */
-static int
-csh_match(const char *pattern, const char *string, int flags)
-{
- int ret = FNM_NOMATCH;
-
-
- const char *nextchoice = pattern;
- const char *current = NULL;
-
- int prefixlen = -1;
- int currentlen = 0;
-
- int level = 0;
-
- do {
- const char *pos = nextchoice;
- const char *postfix = NULL;
-
- Boolean quoted = FALSE;
-
- nextchoice = NULL;
-
- do {
- const char *eb;
- if (!*pos) {
- postfix = pos;
- } else if (quoted) {
- quoted = FALSE;
- } else {
- switch (*pos) {
- case '{':
- ++level;
- if (level == 1) {
- current = pos+1;
- prefixlen = pos-pattern;
- }
- break;
- case ',':
- if (level == 1 && !nextchoice) {
- nextchoice = pos+1;
- currentlen = pos-current;
- }
- break;
- case '}':
- if (level == 1) {
- postfix = pos+1;
- if (!nextchoice)
- currentlen = pos-current;
- }
- level--;
- break;
- case '[':
- eb = pos+1;
- if (*eb == '!' || *eb == '^')
- eb++;
- if (*eb == ']')
- eb++;
- while(*eb && *eb != ']')
- eb++;
- if (*eb)
- pos=eb;
- break;
- case '\\':
- quoted = TRUE;
- break;
- default:
- ;
- }
- }
- pos++;
- } while (!postfix);
-
- if (current) {
- char buf[FILENAME_MAX];
- snprintf(buf, sizeof(buf), "%.*s%.*s%s", prefixlen, pattern, currentlen, current, postfix);
- ret = csh_match(buf, string, flags);
- if (ret) {
- current = nextchoice;
- level = 1;
- } else
- current = NULL;
- } else
- ret = fnmatch(pattern, string, flags);
- } while (current);
-
- return ret;
-}
-
-/*
- * Create an empty store, optionally deallocating
- * any previously allocated space if store != NULL.
- */
-struct store *
-storecreate(struct store *store)
-{
- int i;
-
- if (store == NULL) {
- store = malloc(sizeof *store);
- if (store == NULL) {
- warnx("%s(): malloc() failed", __func__);
- return NULL;
- }
- store->currlen = 0;
- store->store = NULL;
- } else if (store->store != NULL) {
- /* Free previously allocated memory */
- for (i = 0; store->store[i] != NULL; i++)
- free(store->store[i]);
- store->store[0] = NULL;
- }
- store->used = 0;
-
- return store;
-}
-
-/*
- * Append specified element to the provided store.
- */
-static int
-storeappend(struct store *store, const char *item)
-{
- if (store->used + 2 > store->currlen) {
- store->currlen += 16;
- store->store = reallocf(store->store,
- store->currlen * sizeof(*(store->store)));
- if (store->store == NULL) {
- store->currlen = 0;
- warnx("%s(): reallocf() failed", __func__);
- return 1;
- }
- }
-
- asprintf(&(store->store[store->used]), "%s", item);
- if (store->store[store->used] == NULL) {
- warnx("%s(): malloc() failed", __func__);
- return 1;
- }
- store->used++;
- store->store[store->used] = NULL;
-
- return 0;
-}
-
-static int
-fname_cmp(const FTSENT * const *a, const FTSENT * const *b)
-{
- return strcmp((*a)->fts_name, (*b)->fts_name);
-}
diff --git a/usr.sbin/pkg_install/lib/msg.c b/usr.sbin/pkg_install/lib/msg.c
deleted file mode 100644
index 5b17624..0000000
--- a/usr.sbin/pkg_install/lib/msg.c
+++ /dev/null
@@ -1,75 +0,0 @@
-/*
- * FreeBSD install - a package for the installation and maintainance
- * 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.
- *
- * Jordan K. Hubbard
- * 18 July 1993
- *
- * Miscellaneous message routines.
- *
- */
-
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
-#include "lib.h"
-#include <err.h>
-#include <paths.h>
-
-/* Die a relatively simple death */
-void
-upchuck(const char *message)
-{
- cleanup(0);
- errx(1, "fatal error during execution: %s", message);
-}
-
-/*
- * As a yes/no question, prompting from the varargs string and using
- * default if user just hits return.
- */
-Boolean
-y_or_n(Boolean def, const char *msg, ...)
-{
- va_list args;
- int ch = 0;
- FILE *tty;
-
- va_start(args, msg);
- /*
- * Need to open /dev/tty because file collection may have been
- * collected on stdin
- */
- tty = fopen(_PATH_TTY, "r");
- if (!tty) {
- cleanup(0);
- errx(2, "can't open %s!", _PATH_TTY);
- }
- while (ch != 'Y' && ch != 'N') {
- vfprintf(stderr, msg, args);
- if (def)
- fprintf(stderr, " [yes]? ");
- else
- fprintf(stderr, " [no]? ");
- fflush(stderr);
- if (AutoAnswer) {
- ch = (AutoAnswer == YES) ? 'Y' : 'N';
- fprintf(stderr, "%c\n", ch);
- }
- else
- ch = toupper(fgetc(tty));
- if (ch == '\n')
- ch = (def) ? 'Y' : 'N';
- }
- fclose(tty) ;
- return (ch == 'Y') ? TRUE : FALSE;
-}
diff --git a/usr.sbin/pkg_install/lib/pen.c b/usr.sbin/pkg_install/lib/pen.c
deleted file mode 100644
index 2f7e917..0000000
--- a/usr.sbin/pkg_install/lib/pen.c
+++ /dev/null
@@ -1,190 +0,0 @@
-/*
- * FreeBSD install - a package for the installation and maintainance
- * 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.
- *
- * Jordan K. Hubbard
- * 18 July 1993
- *
- * Routines for managing the "play pen".
- *
- */
-
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
-#include "lib.h"
-#include <err.h>
-#include <libutil.h>
-#include <libgen.h>
-#include <sys/signal.h>
-#include <sys/param.h>
-#include <sys/mount.h>
-
-/* For keeping track of where we are */
-static char PenLocation[FILENAME_MAX];
-
-char *
-where_playpen(void)
-{
- return PenLocation;
-}
-
-/* Find a good place to play. */
-static char *
-find_play_pen(char *pen, off_t sz)
-{
- char *cp;
- struct stat sb;
- char humbuf[6];
-
- if (pen[0] && isdir(dirname(pen)) == TRUE && (min_free(dirname(pen)) >= sz))
- return pen;
- else if ((cp = getenv("PKG_TMPDIR")) != NULL && stat(cp, &sb) != FAIL && (min_free(cp) >= sz))
- sprintf(pen, "%s/instmp.XXXXXX", cp);
- else if ((cp = getenv("TMPDIR")) != NULL && stat(cp, &sb) != FAIL && (min_free(cp) >= sz))
- sprintf(pen, "%s/instmp.XXXXXX", cp);
- else if (stat("/var/tmp", &sb) != FAIL && min_free("/var/tmp") >= sz)
- strcpy(pen, "/var/tmp/instmp.XXXXXX");
- else if (stat("/tmp", &sb) != FAIL && min_free("/tmp") >= sz)
- strcpy(pen, "/tmp/instmp.XXXXXX");
- else if ((stat("/usr/tmp", &sb) == SUCCESS || mkdir("/usr/tmp", 01777) == SUCCESS) && min_free("/usr/tmp") >= sz)
- strcpy(pen, "/usr/tmp/instmp.XXXXXX");
- else {
- cleanup(0);
- humanize_number(humbuf, sizeof humbuf, sz, "", HN_AUTOSCALE,
- HN_NOSPACE);
- errx(2,
-"%s: can't find enough temporary space to extract the files, please set your\n"
-"PKG_TMPDIR environment variable to a location with at least %s bytes\n"
-"free", __func__, humbuf);
- return NULL;
- }
- return pen;
-}
-
-#define MAX_STACK 20
-static char *pstack[MAX_STACK];
-static int pdepth = -1;
-
-static const char *
-pushPen(const char *pen)
-{
- if (++pdepth == MAX_STACK)
- errx(2, "%s: stack overflow.\n", __func__);
- pstack[pdepth] = strdup(pen);
-
- return pstack[pdepth];
-}
-
-static void
-popPen(char *pen)
-{
- if (pdepth == -1) {
- pen[0] = '\0';
- return;
- }
- strcpy(pen, pstack[pdepth]);
- free(pstack[pdepth--]);
-}
-
-/*
- * Make a temporary directory to play in and chdir() to it, returning
- * pathname of previous working directory.
- */
-const char *
-make_playpen(char *pen, off_t sz)
-{
- char humbuf1[6], humbuf2[6];
- char cwd[FILENAME_MAX];
-
- if (!find_play_pen(pen, sz))
- return NULL;
-
- if (!mkdtemp(pen)) {
- cleanup(0);
- errx(2, "%s: can't mktemp '%s'", __func__, pen);
- }
- if (chmod(pen, 0700) == FAIL) {
- cleanup(0);
- errx(2, "%s: can't mkdir '%s'", __func__, pen);
- }
-
- if (Verbose) {
- if (sz) {
- humanize_number(humbuf1, sizeof humbuf1, sz, "", HN_AUTOSCALE,
- HN_NOSPACE);
- humanize_number(humbuf2, sizeof humbuf2, min_free(pen),
- "", HN_AUTOSCALE, HN_NOSPACE);
- fprintf(stderr, "Requested space: %s bytes, free space: %s bytes in %s\n", humbuf1, humbuf2, pen);
- }
- }
-
- if (min_free(pen) < sz) {
- rmdir(pen);
- cleanup(0);
- errx(2, "%s: not enough free space to create '%s'.\n"
- "Please set your PKG_TMPDIR environment variable to a location\n"
- "with more space and\ntry the command again", __func__, pen);
- }
-
- if (!getcwd(cwd, FILENAME_MAX)) {
- upchuck("getcwd");
- return NULL;
- }
-
- if (chdir(pen) == FAIL) {
- cleanup(0);
- errx(2, "%s: can't chdir to '%s'", __func__, pen);
- }
-
- strcpy(PenLocation, pen);
- return pushPen(cwd);
-}
-
-/* Convenience routine for getting out of playpen */
-int
-leave_playpen()
-{
- static char left[FILENAME_MAX];
- void (*oldsig)(int);
-
- if (!PenLocation[0])
- return 0;
-
- /* Don't interrupt while we're cleaning up */
- oldsig = signal(SIGINT, SIG_IGN);
- strcpy(left, PenLocation);
- popPen(PenLocation);
-
- if (chdir(PenLocation) == FAIL) {
- cleanup(0);
- errx(2, "%s: can't chdir back to '%s'", __func__, PenLocation);
- }
-
- if (left[0] == '/' && vsystem("/bin/rm -rf %s", left))
- warnx("couldn't remove temporary dir '%s'", left);
- signal(SIGINT, oldsig);
-
- return 1;
-}
-
-off_t
-min_free(const char *tmpdir)
-{
- struct statfs buf;
-
- if (statfs(tmpdir, &buf) != 0) {
- warn("statfs");
- return -1;
- }
- return (off_t)buf.f_bavail * (off_t)buf.f_bsize;
-}
diff --git a/usr.sbin/pkg_install/lib/pkgwrap.c b/usr.sbin/pkg_install/lib/pkgwrap.c
deleted file mode 100644
index cbd15cd..0000000
--- a/usr.sbin/pkg_install/lib/pkgwrap.c
+++ /dev/null
@@ -1,89 +0,0 @@
-/*
- * 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.
- *
- * Maxim Sobolev
- * 8 September 2002
- *
- */
-
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
-#include "lib.h"
-#include <ctype.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <unistd.h>
-
-#undef main
-
-#define SEPARATORS " \t"
-
-extern char **environ;
-
-int
-main(int argc, char **argv)
-{
- FILE *f;
- char buffer[FILENAME_MAX], *cp, *verstr;
- int len;
-
- if (getenv("PKG_NOWRAP") != NULL)
- goto nowrap;
- f = fopen(PKG_WRAPCONF_FNAME, "r");
- if (f == NULL)
- goto nowrap;
- cp = fgets(buffer, 256, f);
- fclose(f);
- if (cp == NULL)
- goto nowrap;
- len = strlen(cp);
- if (cp[len - 1] == '\n')
- cp[len - 1] = '\0';
- while (strchr(SEPARATORS, *cp) != NULL)
- cp++;
- verstr = cp;
- cp = strpbrk(cp, SEPARATORS);
- if (cp == NULL)
- goto nowrap;
- *cp = '\0';
- for (cp = verstr; *cp != '\0'; cp++)
- if (isdigit(*cp) == 0)
- goto nowrap;
- if (atoi(verstr) < PKG_INSTALL_VERSION)
- goto nowrap;
- cp++;
- while (*cp != '\0' && strchr(SEPARATORS, *cp) != NULL)
- cp++;
- if (*cp == '\0')
- goto nowrap;
- bcopy(cp, buffer, strlen(cp) + 1);
- cp = strpbrk(buffer, SEPARATORS);
- if (cp != NULL)
- *cp = '\0';
- if (!isdir(buffer))
- goto nowrap;
- cp = strrchr(argv[0], '/');
- if (cp == NULL)
- cp = argv[0];
- else
- cp++;
- strlcat(buffer, "/", sizeof(buffer));
- strlcat(buffer, cp, sizeof(buffer));
- setenv("PKG_NOWRAP", "1", 1);
- execve(buffer, argv, environ);
-
-nowrap:
- unsetenv("PKG_NOWRAP");
- return(real_main(argc, argv));
-}
diff --git a/usr.sbin/pkg_install/lib/plist.c b/usr.sbin/pkg_install/lib/plist.c
deleted file mode 100644
index 3c87d62..0000000
--- a/usr.sbin/pkg_install/lib/plist.c
+++ /dev/null
@@ -1,592 +0,0 @@
-/*
- * FreeBSD install - a package for the installation and maintainance
- * 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.
- *
- * Jordan K. Hubbard
- * 18 July 1993
- *
- * General packing list routines.
- *
- */
-
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
-#include "lib.h"
-#include <err.h>
-#include <md5.h>
-
-/* Add an item to a packing list */
-void
-add_plist(Package *p, plist_t type, const char *arg)
-{
- PackingList tmp;
-
- tmp = new_plist_entry();
- tmp->name = copy_string(arg);
- tmp->type = type;
-
- if (!p->head)
- p->head = p->tail = tmp;
- else {
- tmp->prev = p->tail;
- p->tail->next = tmp;
- p->tail = tmp;
- }
- switch (type) {
- case PLIST_NAME:
- p->name = tmp->name;
- break;
-
- case PLIST_ORIGIN:
- p->origin = tmp->name;
- break;
-
- default:
- break;
- }
-}
-
-void
-add_plist_top(Package *p, plist_t type, const char *arg)
-{
- PackingList tmp;
-
- tmp = new_plist_entry();
- tmp->name = copy_string(arg);
- tmp->type = type;
-
- if (!p->head)
- p->head = p->tail = tmp;
- else {
- tmp->next = p->head;
- p->head->prev = tmp;
- p->head = tmp;
- }
-}
-
-/* Return the last (most recent) entry in a packing list */
-PackingList
-last_plist(Package *p)
-{
- return p->tail;
-}
-
-/* Mark all items in a packing list to prevent iteration over them */
-void
-mark_plist(Package *pkg)
-{
- PackingList p = pkg->head;
-
- while (p) {
- p->marked = TRUE;
- p = p->next;
- }
-}
-
-/* Find a given item in a packing list and, if so, return it (else NULL) */
-PackingList
-find_plist(Package *pkg, plist_t type)
-{
- PackingList p = pkg->head;
-
- while (p) {
- if (p->type == type)
- return p;
- p = p->next;
- }
- return NULL;
-}
-
-/* Look for a specific boolean option argument in the list */
-char *
-find_plist_option(Package *pkg, const char *name)
-{
- PackingList p = pkg->head;
-
- while (p) {
- if (p->type == PLIST_OPTION && !strcmp(p->name, name))
- return p->name;
- p = p->next;
- }
- return NULL;
-}
-
-/*
- * Delete plist item 'type' in the list (if 'name' is non-null, match it
- * too.) If 'all' is set, delete all items, not just the first occurance.
- */
-void
-delete_plist(Package *pkg, Boolean all, plist_t type, const char *name)
-{
- PackingList p = pkg->head;
-
- while (p) {
- PackingList pnext = p->next;
-
- if (p->type == type && (!name || !strcmp(name, p->name))) {
- free(p->name);
- if (p->prev)
- p->prev->next = pnext;
- else
- pkg->head = pnext;
- if (pnext)
- pnext->prev = p->prev;
- else
- pkg->tail = p->prev;
- free(p);
- if (!all)
- return;
- p = pnext;
- }
- else
- p = p->next;
- }
-}
-
-/* Allocate a new packing list entry */
-PackingList
-new_plist_entry(void)
-{
- PackingList ret;
-
- ret = (PackingList)malloc(sizeof(struct _plist));
- bzero(ret, sizeof(struct _plist));
- return ret;
-}
-
-/* Free an entire packing list */
-void
-free_plist(Package *pkg)
-{
- PackingList p = pkg->head;
-
- while (p) {
- PackingList p1 = p->next;
-
- free(p->name);
- free(p);
- p = p1;
- }
- pkg->head = pkg->tail = NULL;
-}
-
-/*
- * For an ascii string denoting a plist command, return its code and
- * optionally its argument(s)
- */
-int
-plist_cmd(const char *s, char **arg)
-{
- char cmd[FILENAME_MAX + 20]; /* 20 == fudge for max cmd len */
- char *cp;
- const char *sp;
-
- strcpy(cmd, s);
- str_lowercase(cmd);
- cp = cmd;
- sp = s;
- while (*cp) {
- if (isspace(*cp)) {
- *cp = '\0';
- while (isspace(*sp)) /* Never sure if macro, increment later */
- ++sp;
- break;
- }
- ++cp, ++sp;
- }
- if (arg)
- *arg = (char *)sp;
- if (!strcmp(cmd, "cwd"))
- return PLIST_CWD;
- else if (!strcmp(cmd, "srcdir"))
- return PLIST_SRC;
- else if (!strcmp(cmd, "cd"))
- return PLIST_CWD;
- else if (!strcmp(cmd, "exec"))
- return PLIST_CMD;
- else if (!strcmp(cmd, "unexec"))
- return PLIST_UNEXEC;
- else if (!strcmp(cmd, "mode"))
- return PLIST_CHMOD;
- else if (!strcmp(cmd, "owner"))
- return PLIST_CHOWN;
- else if (!strcmp(cmd, "group"))
- return PLIST_CHGRP;
- else if (!strcmp(cmd, "noinst"))
- return PLIST_NOINST;
- else if (!strcmp(cmd, "comment")) {
- if (!strncmp(*arg, "ORIGIN:", 7)) {
- *arg += 7;
- return PLIST_ORIGIN;
- } else if (!strncmp(*arg, "DEPORIGIN:", 10)) {
- *arg += 10;
- return PLIST_DEPORIGIN;
- }
- return PLIST_COMMENT;
- } else if (!strcmp(cmd, "ignore"))
- return PLIST_IGNORE;
- else if (!strcmp(cmd, "ignore_inst"))
- return PLIST_IGNORE_INST;
- else if (!strcmp(cmd, "name"))
- return PLIST_NAME;
- else if (!strcmp(cmd, "display"))
- return PLIST_DISPLAY;
- else if (!strcmp(cmd, "pkgdep"))
- return PLIST_PKGDEP;
- else if (!strcmp(cmd, "conflicts"))
- return PLIST_CONFLICTS;
- else if (!strcmp(cmd, "mtree"))
- return PLIST_MTREE;
- else if (!strcmp(cmd, "dirrm"))
- return PLIST_DIR_RM;
- else if (!strcmp(cmd, "option"))
- return PLIST_OPTION;
- else
- return FAIL;
-}
-
-/* Read a packing list from a file */
-void
-read_plist(Package *pkg, FILE *fp)
-{
- char *cp, pline[FILENAME_MAX];
- int cmd, major, minor;
-
- pkg->fmtver_maj = 1;
- pkg->fmtver_mnr = 0;
- pkg->origin = NULL;
- while (fgets(pline, FILENAME_MAX, fp)) {
- int len = strlen(pline);
-
- while (len && isspace(pline[len - 1]))
- pline[--len] = '\0';
- if (!len)
- continue;
- cp = pline;
- if (pline[0] != CMD_CHAR) {
- cmd = PLIST_FILE;
- goto bottom;
- }
- cmd = plist_cmd(pline + 1, &cp);
- if (cmd == FAIL) {
- warnx("%s: unknown command '%s' (package tools out of date?)",
- __func__, pline);
- goto bottom;
- }
- if (*cp == '\0') {
- cp = NULL;
- if (cmd == PLIST_PKGDEP) {
- warnx("corrupted record (pkgdep line without argument), ignoring");
- cmd = FAIL;
- }
- goto bottom;
- }
- if (cmd == PLIST_COMMENT && sscanf(cp, "PKG_FORMAT_REVISION:%d.%d\n",
- &major, &minor) == 2) {
- pkg->fmtver_maj = major;
- pkg->fmtver_mnr = minor;
- if (verscmp(pkg, PLIST_FMT_VER_MAJOR, PLIST_FMT_VER_MINOR) <= 0)
- goto bottom;
-
- warnx("plist format revision (%d.%d) is higher than supported"
- "(%d.%d)", pkg->fmtver_maj, pkg->fmtver_mnr,
- PLIST_FMT_VER_MAJOR, PLIST_FMT_VER_MINOR);
- if (pkg->fmtver_maj > PLIST_FMT_VER_MAJOR) {
- cleanup(0);
- exit(2);
- }
- }
-bottom:
- add_plist(pkg, cmd, cp);
- }
-}
-
-/* Write a packing list to a file, converting commands to ascii equivs */
-void
-write_plist(Package *pkg, FILE *fp)
-{
- PackingList plist = pkg->head;
-
- while (plist) {
- switch(plist->type) {
- case PLIST_FILE:
- fprintf(fp, "%s\n", plist->name);
- break;
-
- case PLIST_CWD:
- fprintf(fp, "%ccwd %s\n", CMD_CHAR, (plist->name == NULL) ? "" : plist->name);
- break;
-
- case PLIST_SRC:
- fprintf(fp, "%csrcdir %s\n", CMD_CHAR, plist->name);
- break;
-
- case PLIST_CMD:
- fprintf(fp, "%cexec %s\n", CMD_CHAR, plist->name);
- break;
-
- case PLIST_UNEXEC:
- fprintf(fp, "%cunexec %s\n", CMD_CHAR, plist->name);
- break;
-
- case PLIST_CHMOD:
- fprintf(fp, "%cmode %s\n", CMD_CHAR, plist->name ? plist->name : "");
- break;
-
- case PLIST_CHOWN:
- fprintf(fp, "%cowner %s\n", CMD_CHAR, plist->name ? plist->name : "");
- break;
-
- case PLIST_CHGRP:
- fprintf(fp, "%cgroup %s\n", CMD_CHAR, plist->name ? plist->name : "");
- break;
-
- case PLIST_COMMENT:
- fprintf(fp, "%ccomment %s\n", CMD_CHAR, plist->name);
- break;
-
- case PLIST_NOINST:
- fprintf(fp, "%cnoinst %s\n", CMD_CHAR, plist->name);
- break;
-
- case PLIST_IGNORE:
- case PLIST_IGNORE_INST: /* a one-time non-ignored file */
- fprintf(fp, "%cignore\n", CMD_CHAR);
- break;
-
- case PLIST_NAME:
- fprintf(fp, "%cname %s\n", CMD_CHAR, plist->name);
- break;
-
- case PLIST_DISPLAY:
- fprintf(fp, "%cdisplay %s\n", CMD_CHAR, plist->name);
- break;
-
- case PLIST_PKGDEP:
- fprintf(fp, "%cpkgdep %s\n", CMD_CHAR, plist->name);
- break;
-
- case PLIST_CONFLICTS:
- fprintf(fp, "%cconflicts %s\n", CMD_CHAR, plist->name);
- break;
-
- case PLIST_MTREE:
- fprintf(fp, "%cmtree %s\n", CMD_CHAR, plist->name);
- break;
-
- case PLIST_DIR_RM:
- fprintf(fp, "%cdirrm %s\n", CMD_CHAR, plist->name);
- break;
-
- case PLIST_OPTION:
- fprintf(fp, "%coption %s\n", CMD_CHAR, plist->name);
- break;
-
- case PLIST_ORIGIN:
- fprintf(fp, "%ccomment ORIGIN:%s\n", CMD_CHAR, plist->name);
- break;
-
- case PLIST_DEPORIGIN:
- fprintf(fp, "%ccomment DEPORIGIN:%s\n", CMD_CHAR, plist->name);
- break;
-
- default:
- cleanup(0);
- errx(2, "%s: unknown command type %d (%s)", __func__,
- plist->type, plist->name);
- break;
- }
- plist = plist->next;
- }
-}
-
-/*
- * Delete the results of a package installation.
- *
- * This is here rather than in the pkg_delete code because pkg_add needs to
- * run it too in cases of failure.
- */
-int
-delete_package(Boolean ign_err, Boolean nukedirs, Package *pkg)
-{
- PackingList p;
- const char *Where = ".", *last_file = "";
- Boolean fail = SUCCESS;
- Boolean preserve;
- char tmp[FILENAME_MAX], *name = NULL;
- char *prefix = NULL;
-
- preserve = find_plist_option(pkg, "preserve") ? TRUE : FALSE;
- for (p = pkg->head; p; p = p->next) {
- switch (p->type) {
- case PLIST_NAME:
- name = p->name;
- break;
-
- case PLIST_IGNORE:
- p = p->next;
- break;
-
- case PLIST_CWD:
- if (!prefix)
- prefix = p->name;
- Where = (p->name == NULL) ? prefix : p->name;
- if (Verbose)
- printf("Change working directory to %s\n", Where);
- break;
-
- case PLIST_UNEXEC:
- format_cmd(tmp, FILENAME_MAX, p->name, Where, last_file);
- if (Verbose)
- printf("Execute '%s'\n", tmp);
- if (!Fake && system(tmp)) {
- warnx("unexec command for '%s' failed", tmp);
- fail = FAIL;
- }
- break;
-
- case PLIST_FILE:
- last_file = p->name;
- 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);
- }
- else {
- if (p->next && p->next->type == PLIST_COMMENT && !strncmp(p->next->name, "MD5:", 4)) {
- char *cp = NULL, buf[33];
-
- /*
- * For packing lists whose version is 1.1 or greater, the md5
- * hash for a symlink is calculated on the string returned
- * by readlink().
- */
- if (issymlink(tmp) && verscmp(pkg, 1, 0) > 0) {
- int len;
- char linkbuf[FILENAME_MAX];
-
- if ((len = readlink(tmp, linkbuf, FILENAME_MAX)) > 0)
- cp = MD5Data((unsigned char *)linkbuf, len, buf);
- } else if (isfile(tmp) || verscmp(pkg, 1, 1) < 0)
- cp = MD5File(tmp, buf);
-
- if (cp != NULL) {
- /* Mismatch? */
- if (strcmp(cp, p->next->name + 4)) {
- warnx("'%s' fails original MD5 checksum - %s",
- tmp, Force ? "deleted anyway." : "not deleted.");
- if (!Force) {
- fail = FAIL;
- continue;
- }
- }
- }
- }
- if (Verbose)
- printf("Delete file %s\n", tmp);
- if (!Fake) {
- if (delete_hierarchy(tmp, ign_err, nukedirs))
- fail = FAIL;
- if (preserve && name) {
- char tmp2[FILENAME_MAX];
-
- if (make_preserve_name(tmp2, FILENAME_MAX, name, tmp)) {
- if (fexists(tmp2)) {
- if (rename(tmp2, tmp))
- warn("preserve: unable to restore %s as %s",
- tmp2, tmp);
- }
- }
- }
- }
- }
- break;
-
- case PLIST_DIR_RM:
- sprintf(tmp, "%s/%s", Where, p->name);
- if (!isdir(tmp) && fexists(tmp)) {
- warnx("cannot delete specified directory '%s' - it is a file!\n"
- "this packing list is incorrect - ignoring delete request", tmp);
- }
- else {
- if (Verbose)
- printf("Delete directory %s\n", tmp);
- if (!Fake && delete_hierarchy(tmp, ign_err, FALSE)) {
- warnx("unable to completely remove directory '%s'", tmp);
- fail = FAIL;
- }
- }
- last_file = p->name;
- break;
-
- default:
- break;
- }
- }
- return fail;
-}
-
-#ifdef DEBUG
-#define RMDIR(dir) vsystem("%s %s", RMDIR_CMD, dir)
-#define REMOVE(dir,ie) vsystem("%s %s%s", REMOVE_CMD, (ie ? "-f " : ""), dir)
-#else
-#define RMDIR rmdir
-#define REMOVE(file,ie) (remove(file) && !(ie))
-#endif
-
-/* Selectively delete a hierarchy */
-int
-delete_hierarchy(const char *dir, Boolean ign_err, Boolean nukedirs)
-{
- char *cp1, *cp2;
-
- cp1 = cp2 = strdup(dir);
- if (!fexists(dir)) {
- if (!ign_err)
- warnx("%s '%s' doesn't exist",
- isdir(dir) ? "directory" : "file", dir);
- return !ign_err;
- }
- else if (nukedirs) {
- if (vsystem("%s -r%s %s", REMOVE_CMD, (ign_err ? "f" : ""), dir))
- return 1;
- }
- else if (isdir(dir) && !issymlink(dir)) {
- if (RMDIR(dir) && !ign_err)
- return 1;
- }
- else {
- if (REMOVE(dir, ign_err))
- return 1;
- }
-
- if (!nukedirs)
- return 0;
- while (cp2) {
- if ((cp2 = strrchr(cp1, '/')) != NULL)
- *cp2 = '\0';
- if (!isemptydir(dir))
- return 0;
- if (RMDIR(dir) && !ign_err) {
- if (!fexists(dir))
- warnx("directory '%s' doesn't exist", dir);
- else
- return 1;
- }
- /* back up the pathname one component */
- if (cp2) {
- cp1 = strdup(dir);
- }
- }
- return 0;
-}
diff --git a/usr.sbin/pkg_install/lib/str.c b/usr.sbin/pkg_install/lib/str.c
deleted file mode 100644
index 0d9e288..0000000
--- a/usr.sbin/pkg_install/lib/str.c
+++ /dev/null
@@ -1,129 +0,0 @@
-/*
- * FreeBSD install - a package for the installation and maintainance
- * 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.
- *
- * Jordan K. Hubbard
- * 18 July 1993
- *
- * Miscellaneous string utilities.
- *
- */
-
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
-#include "lib.h"
-
-char *
-strconcat(const char *s1, const char *s2)
-{
- static char tmp[FILENAME_MAX];
-
- tmp[0] = '\0';
- strncpy(tmp, s1 ? s1 : s2, FILENAME_MAX); /* XXX: what if both are NULL? */
- if (s1 && s2)
- strncat(tmp, s2, FILENAME_MAX - strlen(tmp));
- return tmp;
-}
-
-/* Get a string parameter as a file spec or as a "contents follow -" spec */
-char *
-get_dash_string(char **str)
-{
- char *s = *str;
-
- if (*s == '-')
- *str = copy_string_adds_newline(s + 1);
- else
- *str = fileGetContents(s);
- return *str;
-}
-
-/* Rather Obvious */
-char *
-copy_string(const char *str)
-{
- return (str ? strdup(str) : NULL);
-}
-
-/* Rather Obvious but adds a trailing \n newline */
-char *
-copy_string_adds_newline(const char *str)
-{
- if (str == NULL) {
- return (NULL);
- } else {
- char *copy;
- size_t line_length;
-
- line_length = strlen(str) + 2;
- if ((copy = malloc(line_length)) == NULL)
- return (NULL);
- memcpy(copy, str, line_length - 2);
- copy[line_length - 2] = '\n'; /* Adds trailing \n */
- copy[line_length - 1] = '\0';
-
- return (copy);
- }
-}
-
-/* Return TRUE if 'str' ends in suffix 'suff' */
-Boolean
-suffix(const char *str, const char *suff)
-{
- char *idx;
- Boolean ret = FALSE;
-
- idx = strrchr(str, '.');
- if (idx && !strcmp(idx + 1, suff))
- ret = TRUE;
- return ret;
-}
-
-/* Assuming str has a suffix, brutally murder it! */
-void
-nuke_suffix(char *str)
-{
- char *idx;
-
- idx = strrchr(str, '.');
- if (idx)
- *idx = '\0'; /* Yow! Don't try this on a const! */
-}
-
-/* Lowercase a whole string */
-void
-str_lowercase(char *str)
-{
- while (*str) {
- *str = tolower(*str);
- ++str;
- }
-}
-
-char *
-get_string(char *str, int max, FILE *fp)
-{
- int len;
-
- if (!str)
- return NULL;
- str[0] = '\0';
- while (fgets(str, max, fp)) {
- len = strlen(str);
- while (len && isspace(str[len - 1]))
- str[--len] = '\0';
- if (len)
- return str;
- }
- return NULL;
-}
diff --git a/usr.sbin/pkg_install/lib/url.c b/usr.sbin/pkg_install/lib/url.c
deleted file mode 100644
index b598c60..0000000
--- a/usr.sbin/pkg_install/lib/url.c
+++ /dev/null
@@ -1,167 +0,0 @@
-/*
- * FreeBSD install - a package for the installation and maintainance
- * 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.
- *
- * Jordan K. Hubbard
- * 18 July 1993
- *
- * URL file access utilities.
- *
- */
-
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
-#include "lib.h"
-#include <err.h>
-#include <fetch.h>
-#include <libgen.h>
-#include <sys/wait.h>
-#include <stdio.h>
-
-/*
- * Try and fetch a file by URL, returning the directory name for where
- * it's unpacked, if successful.
- */
-const char *
-fileGetURL(const char *base, const char *spec, int keep_package)
-{
- const char *rp;
- char *cp, *tmp;
- char fname[FILENAME_MAX];
- char pen[FILENAME_MAX];
- char pkg[FILENAME_MAX];
- char buf[8192];
- FILE *ftp;
- pid_t tpid;
- int pfd[2], pstat, r, w = 0;
- char *hint;
- int fd, pkgfd = 0;
-
- rp = NULL;
- /* Special tip that sysinstall left for us */
- hint = getenv("PKG_ADD_BASE");
- if (!isURL(spec)) {
- if (!base && !hint)
- return NULL;
- /*
- * We've been given an existing URL (that's known-good) and now we need
- * to construct a composite one out of that and the basename we were
- * handed as a dependency.
- */
- if (base) {
- strcpy(fname, base);
- /*
- * Advance back two slashes to get to the root of the package
- * hierarchy
- */
- cp = strrchr(fname, '/');
- if (cp) {
- *cp = '\0'; /* chop name */
- cp = strrchr(fname, '/');
- }
- if (cp) {
- *(cp + 1) = '\0';
- strcat(cp, "All/");
- strcat(cp, spec);
- strcat(cp, ".tbz");
- }
- else
- return NULL;
- }
- else {
- /*
- * Otherwise, we've been given an environment variable hinting
- * at the right location from sysinstall
- */
- strcpy(fname, hint);
- strcat(fname, spec);
- strcat(fname, ".tbz");
- }
- }
- else
- strcpy(fname, spec);
-
- if (keep_package) {
- tmp = getenv("PKGDIR");
- strlcpy(pkg, tmp ? tmp : ".", sizeof(pkg));
- tmp = basename(fname);
- strlcat(pkg, "/", sizeof(pkg));
- strlcat(pkg, tmp, sizeof(pkg));
- if ((pkgfd = open(pkg, O_WRONLY|O_CREAT|O_TRUNC, 0644)) == -1) {
- printf("Error: Unable to open %s\n", pkg);
- perror("open");
- return NULL;
- }
- }
-
- fetchDebug = (Verbose > 0);
- if ((ftp = fetchGetURL(fname, Verbose ? "v" : NULL)) == NULL) {
- printf("Error: Unable to get %s: %s\n",
- fname, fetchLastErrString);
- return NULL;
- }
-
- if (isatty(0) || Verbose)
- printf("Fetching %s...", fname), fflush(stdout);
- pen[0] = '\0';
- if ((rp = make_playpen(pen, 0)) == NULL) {
- printf("Error: Unable to construct a new playpen for FTP!\n");
- fclose(ftp);
- return NULL;
- }
- if (pipe(pfd) == -1) {
- warn("pipe()");
- cleanup(0);
- exit(2);
- }
- if ((tpid = fork()) == -1) {
- warn("pipe()");
- cleanup(0);
- exit(2);
- }
- if (!tpid) {
- dup2(pfd[0], 0);
- for (fd = getdtablesize() - 1; fd >= 3; --fd)
- close(fd);
- execl("/usr/bin/tar", "tar",
- Verbose ? "-xpjvf" : "-xpjf",
- "-", (char *)0);
- _exit(2);
- }
- close(pfd[0]);
- for (;;) {
- if ((r = fread(buf, 1, sizeof buf, ftp)) < 1)
- break;
- if ((w = write(pfd[1], buf, r)) != r)
- break;
- if (keep_package) {
- if ((w = write(pkgfd, buf, r)) != r)
- break;
- }
- }
- if (ferror(ftp))
- warn("warning: error reading from server");
- fclose(ftp);
- if (keep_package) {
- close(pkgfd);
- }
- close(pfd[1]);
- if (w == -1)
- warn("warning: error writing to tar");
- tpid = waitpid(tpid, &pstat, 0);
- if (Verbose)
- printf("tar command returns %d status\n", WEXITSTATUS(pstat));
- if (rp && (isatty(0) || Verbose))
- printf(" Done.\n");
- return rp;
-}
diff --git a/usr.sbin/pkg_install/lib/version.c b/usr.sbin/pkg_install/lib/version.c
deleted file mode 100644
index d9c4fe7..0000000
--- a/usr.sbin/pkg_install/lib/version.c
+++ /dev/null
@@ -1,328 +0,0 @@
-/*
- * 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.
- *
- * Maxim Sobolev
- * 31 July 2001
- *
- */
-
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
-#include "lib.h"
-#include <err.h>
-
-/*
- * Routines to assist with PLIST_FMT_VER numbers in the packing
- * lists.
- *
- * Following is the PLIST_FMT_VER history:
- * 1.0 - Initial revision;
- * 1.1 - When recording/checking checksum of symlink use hash of readlink()
- * value instead of the hash of an object this links points to.
- *
- */
-int
-verscmp(Package *pkg, int major, int minor)
-{
- int rval = 0;
-
- if ((pkg->fmtver_maj < major) || (pkg->fmtver_maj == major &&
- pkg->fmtver_mnr < minor))
- rval = -1;
- else if ((pkg->fmtver_maj > major) || (pkg->fmtver_maj == major &&
- pkg->fmtver_mnr > minor))
- rval = 1;
-
- return rval;
-}
-
-/*
- * split_version(pkgname, endname, epoch, revision) returns a pointer to
- * the version portion of a package name and the two special components.
- *
- * Syntax is: ${PORTNAME}-${PORTVERSION}[_${PORTREVISION}][,${PORTEPOCH}]
- *
- * Written by Oliver Eikemeier
- * Based on work of Jeremy D. Lea.
- */
-static const char *
-split_version(const char *pkgname, const char **endname, unsigned long *epoch, unsigned long *revision)
-{
- char *ch;
- const char *versionstr;
- const char *endversionstr;
-
- if (pkgname == NULL)
- errx(2, "%s: Passed NULL pkgname.", __func__);
-
- /* Look for the last '-' the the pkgname */
- ch = strrchr(pkgname, '-');
- /* Cheat if we are just passed a version, not a valid package name */
- versionstr = ch ? ch + 1 : pkgname;
-
- /* Look for the last '_' in the version string, advancing the end pointer */
- ch = strrchr(versionstr, '_');
- if (revision != NULL) {
- *revision = ch ? strtoul(ch + 1, NULL, 10) : 0;
- }
- endversionstr = ch;
-
- /* Look for the last ',' in the remaining version string */
- ch = strrchr(endversionstr ? endversionstr + 1 : versionstr, ',');
- if (epoch != NULL) {
- *epoch = ch ? strtoul(ch + 1, NULL, 10) : 0;
- }
- if (ch && !endversionstr)
- endversionstr = ch;
-
- /* set the pointer behind the last character of the version without revision or epoch */
- if (endname)
- *endname = endversionstr ? endversionstr : strrchr(versionstr, '\0');
-
- return versionstr;
-}
-
-/*
- * PORTVERSIONs are composed of components separated by dots. A component
- * consists of a version number, a letter and a patchlevel number. This does
- * not conform to the porter's handbook, but let us formulate rules that
- * fit the current practice and are far simpler than to make decisions
- * based on the order of netters and lumbers. Besides, people use versions
- * like 10b2 in the ports...
- */
-
-typedef struct {
-#ifdef __LONG_LONG_SUPPORTED
- long long n;
- long long pl;
-#else
- long n;
- long pl;
-#endif
- int a;
-} version_component;
-
-/*
- * get_component(position, component) gets the value of the next component
- * (number - letter - number triple) and returns a pointer to the next character
- * after any leading separators
- *
- * - components are separated by dots
- * - characters !~ [a-zA-Z0-9.+*] are treated as separators
- * (1.0:2003.09.16 = 1.0.2003.09.16), this may not be what you expect:
- * 1.0.1:2003.09.16 < 1.0:2003.09.16
- * - consecutive separators are collapsed (10..1 = 10.1)
- * - missing separators are inserted, essentially
- * letter number letter => letter number . letter (10a1b2 = 10a1.b2)
- * - missing components are assumed to be equal to 0 (10 = 10.0 = 10.0.0)
- * - the letter sort order is: [none], a, b, ..., z; numbers without letters
- * sort first (10 < 10a < 10b)
- * - missing version numbers (in components starting with a letter) sort as -1
- * (a < 0, 10.a < 10)
- * - a separator is inserted before the special strings "pl", "alpha", "beta",
- * "pre" and "rc".
- * - "pl" sorts before every other letter, "alpha", "beta", "pre" and "rc"
- * sort as a, b, p and r. (10alpha = 10.a < 10, but 10 < 10a; pl11 < alpha3
- * < 0.1beta2 = 0.1.b2 < 0.1)
- * - other strings use only the first letter for sorting, case is ignored
- * (1.d2 = 1.dev2 = 1.Development2)
- * - The special component `*' is guaranteed to be the smallest possible
- * component (2.* < 2pl1 < 2alpha3 < 2.9f7 < 3.*)
- * - components separated by `+' are handled by version_cmp below
- *
- * Oliver Eikemeier
- */
-
-static const struct {
- const char *name;
- size_t namelen;
- int value;
-} stage[] = {
- { "pl", 2, 0 },
- { "alpha", 5, 'a'-'a'+1 },
- { "beta", 4, 'b'-'a'+1 },
- { "pre", 3, 'p'-'a'+1 },
- { "rc", 2, 'r'-'a'+1 },
- { NULL, 0, -1 }
-};
-
-static const char *
-get_component(const char *position, version_component *component)
-{
- const char *pos = position;
- int hasstage = 0, haspatchlevel = 0;
-
- if (!pos)
- errx(2, "%s: Passed NULL position.", __func__);
-
- /* handle version number */
- if (isdigit(*pos)) {
- char *endptr;
-#ifdef __LONG_LONG_SUPPORTED
- component->n = strtoll(pos, &endptr, 10);
-#else
- component->n = strtol(pos, &endptr, 10);
-#endif
- /* should we test for errno == ERANGE? */
- pos = endptr;
- } else if (*pos == '*') {
- component->n = -2;
- do {
- pos++;
- } while(*pos && *pos != '+');
- } else {
- component->n = -1;
- hasstage = 1;
- }
-
- /* handle letter */
- if (isalpha(*pos)) {
- int c = tolower(*pos);
- haspatchlevel = 1;
- /* handle special suffixes */
- if (isalpha(pos[1])) {
- int i;
- for (i = 0; stage[i].name; i++) {
- if (strncasecmp(pos, stage[i].name, stage[i].namelen) == 0
- && !isalpha(pos[stage[i].namelen])) {
- if (hasstage) {
- /* stage to value */
- component->a = stage[i].value;
- pos += stage[i].namelen;
- } else {
- /* insert dot */
- component->a = 0;
- haspatchlevel = 0;
- }
- c = 0;
- break;
- }
- }
- }
- /* unhandled above */
- if (c) {
- /* use the first letter and skip following */
- component->a = c - 'a' + 1;
- do {
- ++pos;
- } while (isalpha(*pos));
- }
- } else {
- component->a = 0;
- haspatchlevel = 0;
- }
-
- if (haspatchlevel) {
- /* handle patch number */
- if (isdigit(*pos)) {
- char *endptr;
-#ifdef __LONG_LONG_SUPPORTED
- component->pl = strtoll(pos, &endptr, 10);
-#else
- component->pl = strtol(pos, &endptr, 10);
-#endif
- /* should we test for errno == ERANGE? */
- pos = endptr;
- } else {
- component->pl = -1;
- }
- } else {
- component->pl = 0;
- }
-
- /* skip trailing separators */
- while (*pos && !isdigit(*pos) && !isalpha(*pos) && *pos != '+' && *pos != '*') {
- pos++;
- }
-
- return pos;
-}
-
-/*
- * version_cmp(pkg1, pkg2) returns -1, 0 or 1 depending on if the version
- * components of pkg1 is less than, equal to or greater than pkg2. No
- * comparison of the basenames is done.
- *
- * The port version is defined by:
- * ${PORTVERSION}[_${PORTREVISION}][,${PORTEPOCH}]
- * ${PORTEPOCH} supersedes ${PORTVERSION} supersedes ${PORTREVISION}.
- * See the commit log for revision 1.349 of ports/Mk/bsd.port.mk
- * for more information.
- *
- * The epoch and revision are defined to be a single number, while the rest
- * of the version should conform to the porting guidelines. It can contain
- * multiple components, separated by a period, including letters.
- *
- * The tests allow for significantly more latitude in the version numbers
- * than is allowed in the guidelines. No point in enforcing them here.
- * That's what portlint is for.
- *
- * Jeremy D. Lea.
- * reimplemented by Oliver Eikemeier
- */
-int
-version_cmp(const char *pkg1, const char *pkg2)
-{
- const char *v1, *v2, *ve1, *ve2;
- unsigned long e1, e2, r1, r2;
- int result = 0;
-
- v1 = split_version(pkg1, &ve1, &e1, &r1);
- v2 = split_version(pkg2, &ve2, &e2, &r2);
-
- /* Check epoch, port version, and port revision, in that order. */
- if (e1 != e2) {
- result = (e1 < e2 ? -1 : 1);
- }
-
- /* Shortcut check for equality before invoking the parsing routines. */
- if (result == 0 && (ve1 - v1 != ve2 - v2 || strncasecmp(v1, v2, ve1 - v1) != 0)) {
- /* Loop over different components (the parts separated by dots).
- * If any component differs, we have the basis for an inequality. */
- while(result == 0 && (v1 < ve1 || v2 < ve2)) {
- int block_v1 = 0;
- int block_v2 = 0;
- version_component vc1 = {0, 0, 0};
- version_component vc2 = {0, 0, 0};
- if (v1 < ve1 && *v1 != '+') {
- v1 = get_component(v1, &vc1);
- } else {
- block_v1 = 1;
- }
- if (v2 < ve2 && *v2 != '+') {
- v2 = get_component(v2, &vc2);
- } else {
- block_v2 = 1;
- }
- if (block_v1 && block_v2) {
- if (v1 < ve1)
- v1++;
- if (v2 < ve2)
- v2++;
- } else if (vc1.n != vc2.n) {
- result = (vc1.n < vc2.n ? -1 : 1);
- } else if (vc1.a != vc2.a) {
- result = (vc1.a < vc2.a ? -1 : 1);
- } else if (vc1.pl != vc2.pl) {
- result = (vc1.pl < vc2.pl ? -1 : 1);
- }
- }
- }
-
- /* Compare FreeBSD revision numbers. */
- if (result == 0 && r1 != r2) {
- result = (r1 < r2 ? -1 : 1);
- }
- return result;
-}
diff --git a/usr.sbin/pkg_install/updating/Makefile b/usr.sbin/pkg_install/updating/Makefile
index b0d3689..f5b7525 100644
--- a/usr.sbin/pkg_install/updating/Makefile
+++ b/usr.sbin/pkg_install/updating/Makefile
@@ -3,11 +3,6 @@
PROG= pkg_updating
SRCS= main.c
-CFLAGS+= -I${.CURDIR}/../lib
-
WFORMAT?= 1
-DPADD= ${LIBINSTALL} ${LIBFETCH} ${LIBMD}
-LDADD= ${LIBINSTALL} -lfetch -lmd
-
.include <bsd.prog.mk>
diff --git a/usr.sbin/pkg_install/updating/main.c b/usr.sbin/pkg_install/updating/main.c
index 0ab2ec0..993ccd5 100644
--- a/usr.sbin/pkg_install/updating/main.c
+++ b/usr.sbin/pkg_install/updating/main.c
@@ -19,7 +19,7 @@ __FBSDID("$FreeBSD$");
#include <sysexits.h>
#include <getopt.h>
-#include "lib.h"
+#include <pkg.h>
#include "pathnames.h"
typedef struct installedport {
@@ -87,6 +87,8 @@ main(int argc, char *argv[])
DIR *dir;
FILE *fd;
+ pkg_wrap(PKG_INSTALL_VERSION, argv);
+
while ((ch = getopt_long(argc, argv, opts, longopts, NULL)) != -1) {
switch (ch) {
case 'd':
diff --git a/usr.sbin/pkg_install/updating/pkg_updating.1 b/usr.sbin/pkg_install/updating/pkg_updating.1
index 0c35f9a..998b4c4 100644
--- a/usr.sbin/pkg_install/updating/pkg_updating.1
+++ b/usr.sbin/pkg_install/updating/pkg_updating.1
@@ -44,34 +44,25 @@ Defines a alternative location of the UPDATING
Print help message.
.El
.Sh EXAMPLES
-.Bl -tag -width indent
Shows all entries of all installed ports:
-.Pp
.Dl % pkg_updating
.Pp
Shows all entries of all installed ports since 2007-01-01:
-.Pp
.Dl % pkg_updating -d 20070101
.Pp
Shows all entries for all apache and mysql ports:
-.Pp
.Dl % pkg_updating apache mysql
.Pp
Shows all apache entries since 2006-01-01:
-.Pp
.Dl % pkg_updating -d 20060101 apache
.Pp
Defines that the UPDATING file is in /tmp and shows all entries of all
installed ports:
-.Pp
.Dl % pkg_updating -f /tmp/UPDATING
.Pp
Fetch UPDATING file from ftp mirror and show all entries of all
installed ports:
-.Pp
.Dl % pkg_updating -f ftp://ftp.freebsd.org/pub/FreeBSD/ports/packages/UPDATING
-.Pp
-.El
.Sh ENVIRONMENT
.Bl -tag -width PKG_DBDIR
.It Ev PKG_DBDIR
diff --git a/usr.sbin/pkg_install/version/Makefile b/usr.sbin/pkg_install/version/Makefile
index 3e1d7a5..fb079e3 100644
--- a/usr.sbin/pkg_install/version/Makefile
+++ b/usr.sbin/pkg_install/version/Makefile
@@ -3,13 +3,8 @@
PROG= pkg_version
SRCS= main.c perform.c
-CFLAGS+= -I${.CURDIR}/../lib
-
WFORMAT?= 1
-DPADD= ${LIBINSTALL} ${LIBFETCH} ${LIBMD}
-LDADD= ${LIBINSTALL} -lfetch -lmd
-
test:
sh ${.CURDIR}/test-pkg_version.sh
diff --git a/usr.sbin/pkg_install/version/main.c b/usr.sbin/pkg_install/version/main.c
index cad8583..4238497 100644
--- a/usr.sbin/pkg_install/version/main.c
+++ b/usr.sbin/pkg_install/version/main.c
@@ -25,7 +25,7 @@ __FBSDID("$FreeBSD$");
#include <getopt.h>
#include <err.h>
-#include "lib.h"
+#include <pkg.h>
#include "version.h"
char *LimitChars = NULL;
@@ -58,6 +58,8 @@ main(int argc, char **argv)
{
int ch, cmp = 0;
+ pkg_wrap(PKG_INSTALL_VERSION, argv);
+
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 e39adaf..79575a3 100644
--- a/usr.sbin/pkg_install/version/perform.c
+++ b/usr.sbin/pkg_install/version/perform.c
@@ -21,7 +21,7 @@
#include <sys/cdefs.h>
__FBSDID("$FreeBSD$");
-#include "lib.h"
+#include <pkg.h>
#include "version.h"
#include <err.h>
#include <fetch.h>
@@ -35,28 +35,41 @@ static int pkg_do(char *);
static void show_version(Package, const char *, const char *);
/*
- * This is the traditional pkg_perform, except that the argument is _not_
- * a list of packages. It is the index file from the command line.
+ * This is the traditional pkg_perform, except that the argument is _not_ a
+ * list of packages. It is the index file from the command line.
*
- * We loop over the installed packages, matching them with the -s flag
- * if needed and calling pkg_do(). Before hand we set up a few things,
- * and after we tear them down...
+ * We loop over the installed packages, matching them with the -s flag if
+ * needed and calling pkg_do(). Beforehand we set up a few things, and after
+ * we tear them down...
+ *
+ * Returns 0 on success, non-zero on failure, corresponding to the number of
+ * failed attempts to access the INDEX.
*/
int
pkg_perform(char **indexarg)
{
char **pkgs, *pat[2], **patterns;
struct index_entry *ie;
- int i, err_cnt = 0;
+ int i, err_cnt = 0, rel_major_ver;
int MatchType;
+ struct utsname u;
+
+ if (uname(&u) == -1) {
+ warn("%s(): failed to determine uname information", __func__);
+ return 1;
+ } else if ((rel_major_ver = (int) strtol(u.release, NULL, 10)) <= 0) {
+
+ }
+
/*
* Try to find and open the INDEX. We only check IndexFile != NULL
* later, if we actually need the INDEX.
*/
- if (*indexarg == NULL)
- snprintf(IndexPath, sizeof(IndexPath), "%s/%s", PORTS_DIR, INDEX_FNAME);
- else
+ if (*indexarg == NULL) {
+ snprintf(IndexPath, sizeof(IndexPath), "%s/INDEX-%d", PORTS_DIR,
+ rel_major_ver);
+ } else
strlcpy(IndexPath, *indexarg, sizeof(IndexPath));
if (isURL(IndexPath))
IndexFile = fetchGetURL(IndexPath, "");
diff --git a/usr.sbin/pmcannotate/pmcannotate.8 b/usr.sbin/pmcannotate/pmcannotate.8
index 38a413a..17c7c0e 100644
--- a/usr.sbin/pmcannotate/pmcannotate.8
+++ b/usr.sbin/pmcannotate/pmcannotate.8
@@ -28,8 +28,8 @@
.\" $FreeBSD$
.\"
.Dd November 20, 2008
-.Os
.Dt PMCANNOTATE 8
+.Os
.Sh NAME
.Nm pmcannotate
.Nd "sources printout with inlined profiling"
@@ -86,6 +86,7 @@ This directory specifies where
should look for the kernel and its modules.
The default is
.Pa /boot/kernel .
+.El
.Sh LIMITATIONS
As long as
.Nm
diff --git a/usr.sbin/pmccontrol/pmccontrol.8 b/usr.sbin/pmccontrol/pmccontrol.8
index e521a1f..f436753 100644
--- a/usr.sbin/pmccontrol/pmccontrol.8
+++ b/usr.sbin/pmccontrol/pmccontrol.8
@@ -24,8 +24,8 @@
.\" $FreeBSD$
.\"
.Dd November 9, 2008
-.Os
.Dt PMCCONTROL 8
+.Os
.Sh NAME
.Nm pmccontrol
.Nd "control hardware performance monitoring counters"
diff --git a/usr.sbin/pmcstat/pmcpl_callgraph.c b/usr.sbin/pmcstat/pmcpl_callgraph.c
index d6f1a9d..d948b77 100644
--- a/usr.sbin/pmcstat/pmcpl_callgraph.c
+++ b/usr.sbin/pmcstat/pmcpl_callgraph.c
@@ -341,6 +341,7 @@ pmcpl_cg_process(struct pmcstat_process *pp, struct pmcstat_pmcrecord *pmcr,
parent = pmcstat_cgnode_hash_lookup_pc(pp, pmcid, pc, usermode);
if (parent == NULL) {
pmcstat_stats.ps_callchain_dubious_frames++;
+ pmcr->pr_dubious_frames++;
return;
}
@@ -550,7 +551,7 @@ pmcstat_cgnode_topprint(struct pmcstat_cgnode *cg,
len = ns_len + vs_len + 1;
if (width - len < 0) {
- PMCSTAT_PRINTW("...");
+ PMCSTAT_PRINTW(" ...");
break;
}
width -= len;
@@ -580,6 +581,8 @@ pmcpl_cg_topdisplay(void)
struct pmcstat_pmcrecord *pmcr;
pmcr = pmcstat_pmcindex_to_pmcr(pmcstat_pmcinfilter);
+ if (!pmcr)
+ err(EX_SOFTWARE, "ERROR: invalid pmcindex");
/*
* We pull out all callgraph nodes in the top-level hash table
diff --git a/usr.sbin/pmcstat/pmcpl_calltree.c b/usr.sbin/pmcstat/pmcpl_calltree.c
index 498092d..f8ceece 100644
--- a/usr.sbin/pmcstat/pmcpl_calltree.c
+++ b/usr.sbin/pmcstat/pmcpl_calltree.c
@@ -366,7 +366,7 @@ pmcpl_ct_node_cleartag(void)
static int
pmcpl_ct_node_dumptop(int pmcin, struct pmcpl_ct_node *ct,
- struct pmcpl_ct_sample *rsamples, int x, int *y)
+ struct pmcpl_ct_sample *rsamples, int x, int *y, int maxy)
{
int i;
@@ -387,7 +387,7 @@ pmcpl_ct_node_dumptop(int pmcin, struct pmcpl_ct_node *ct,
if (ct->pct_narc == 0) {
pmcpl_ct_topscreen[x+1][*y] = NULL;
if (*y >= PMCPL_CT_MAXLINE ||
- *y >= pmcstat_displaywidth)
+ *y >= maxy)
return 1;
*y = *y + 1;
for (i=0; i < x; i++)
@@ -403,11 +403,15 @@ pmcpl_ct_node_dumptop(int pmcin, struct pmcpl_ct_node *ct,
&pmcin, pmcpl_ct_arc_compare);
for (i = 0; i < ct->pct_narc; i++) {
+ /* Skip this arc if there is no sample at all. */
+ if (PMCPL_CT_SAMPLE(pmcin,
+ &ct->pct_arc[i].pcta_samples) == 0)
+ continue;
if (PMCPL_CT_SAMPLEP(pmcin,
&ct->pct_arc[i].pcta_samples) > pmcstat_threshold) {
if (pmcpl_ct_node_dumptop(pmcin,
ct->pct_arc[i].pcta_child,
- rsamples, x+1, y))
+ rsamples, x+1, y, maxy))
return 1;
}
}
@@ -472,6 +476,9 @@ pmcpl_ct_node_printtop(struct pmcpl_ct_sample *rsamples, int pmcin, int maxy)
/* Check for line wrap. */
width += ns_len + is_len + vs_len + 1;
if (width >= pmcstat_displaywidth) {
+ maxy--;
+ if (y >= maxy)
+ break;
PMCSTAT_PRINTW("\n%*s", indentwidth, space);
width = indentwidth + ns_len + is_len + vs_len;
}
@@ -492,9 +499,10 @@ void
pmcpl_ct_topdisplay(void)
{
int i, x, y, pmcin;
- struct pmcpl_ct_sample rsamples;
+ struct pmcpl_ct_sample r, *rsamples;
- pmcpl_ct_samples_root(&rsamples);
+ rsamples = &r;
+ pmcpl_ct_samples_root(rsamples);
PMCSTAT_PRINTW("%-10.10s %s\n", "IMAGE", "CALLTREE");
@@ -513,16 +521,24 @@ pmcpl_ct_topdisplay(void)
x = y = 0;
for (i = 0; i < pmcpl_ct_root->pct_narc; i++) {
+ /* Skip this arc if there is no sample at all. */
+ if (PMCPL_CT_SAMPLE(pmcin,
+ &pmcpl_ct_root->pct_arc[i].pcta_samples) == 0)
+ continue;
+ if (PMCPL_CT_SAMPLEP(pmcin,
+ &pmcpl_ct_root->pct_arc[i].pcta_samples) <=
+ pmcstat_threshold)
+ continue;
if (pmcpl_ct_node_dumptop(pmcin,
pmcpl_ct_root->pct_arc[i].pcta_child,
- &rsamples, x, &y)) {
+ rsamples, x, &y, pmcstat_displayheight - 2)) {
break;
}
}
- pmcpl_ct_node_printtop(&rsamples, pmcin, y);
+ pmcpl_ct_node_printtop(rsamples, pmcin, y);
}
- pmcpl_ct_samples_free(&rsamples);
+ pmcpl_ct_samples_free(rsamples);
}
/*
@@ -690,6 +706,7 @@ pmcpl_ct_process(struct pmcstat_process *pp, struct pmcstat_pmcrecord *pmcr,
}
if (n-- == 0) {
pmcstat_stats.ps_callchain_dubious_frames++;
+ pmcr->pr_dubious_frames++;
return;
}
diff --git a/usr.sbin/pmcstat/pmcpl_gprof.c b/usr.sbin/pmcstat/pmcpl_gprof.c
index 9327eb9..2027ecf 100644
--- a/usr.sbin/pmcstat/pmcpl_gprof.c
+++ b/usr.sbin/pmcstat/pmcpl_gprof.c
@@ -171,6 +171,8 @@ pmcstat_gmon_create_name(const char *samplesdir, struct pmcstat_image *image,
char fullpath[PATH_MAX];
pmcname = pmcstat_pmcid_to_name(pmcid);
+ if (!pmcname)
+ err(EX_SOFTWARE, "ERROR: cannot find pmcid");
(void) snprintf(fullpath, sizeof(fullpath),
"%s/%s/%s", samplesdir, pmcname,
diff --git a/usr.sbin/pmcstat/pmcstat.8 b/usr.sbin/pmcstat/pmcstat.8
index 309eb3e..b033357 100644
--- a/usr.sbin/pmcstat/pmcstat.8
+++ b/usr.sbin/pmcstat/pmcstat.8
@@ -26,8 +26,8 @@
.\" $FreeBSD$
.\"
.Dd September 19, 2008
-.Os
.Dt PMCSTAT 8
+.Os
.Sh NAME
.Nm pmcstat
.Nd "performance measurement with performance monitoring hardware"
diff --git a/usr.sbin/pmcstat/pmcstat.c b/usr.sbin/pmcstat/pmcstat.c
index a73d293..89ec8f0 100644
--- a/usr.sbin/pmcstat/pmcstat.c
+++ b/usr.sbin/pmcstat/pmcstat.c
@@ -1311,6 +1311,9 @@ main(int argc, char **argv)
intrflush(stdscr, FALSE);
keypad(stdscr, TRUE);
clear();
+ /* Get terminal width / height with ncurses. */
+ getmaxyx(stdscr, pmcstat_displayheight, pmcstat_displaywidth);
+ pmcstat_displayheight--; pmcstat_displaywidth--;
atexit(pmcstat_topexit);
}
}
diff --git a/usr.sbin/pmcstat/pmcstat_log.c b/usr.sbin/pmcstat/pmcstat_log.c
index 5811af3..6d8c57a 100644
--- a/usr.sbin/pmcstat/pmcstat_log.c
+++ b/usr.sbin/pmcstat/pmcstat_log.c
@@ -247,6 +247,7 @@ static int pmcstat_string_compute_hash(const char *_string);
static void pmcstat_string_initialize(void);
static int pmcstat_string_lookup_hash(pmcstat_interned_string _is);
static void pmcstat_string_shutdown(void);
+static void pmcstat_stats_reset(void);
/*
* A simple implementation of interned strings. Each interned string
@@ -274,6 +275,21 @@ int pmcstat_npmcs;
*/
int pmcstat_pause;
+static void
+pmcstat_stats_reset(void)
+{
+ struct pmcstat_pmcrecord *pr;
+
+ /* Flush PMCs stats. */
+ LIST_FOREACH(pr, &pmcstat_pmcs, pr_next) {
+ pr->pr_samples = 0;
+ pr->pr_dubious_frames = 0;
+ }
+
+ /* Flush global stats. */
+ bzero(&pmcstat_stats, sizeof(struct pmcstat_stats));
+}
+
/*
* Compute a 'hash' value for a string.
*/
@@ -1009,6 +1025,8 @@ pmcstat_pmcid_add(pmc_id_t pmcid, pmcstat_interned_string ps)
pr->pr_pmcid = pmcid;
pr->pr_pmcname = ps;
pr->pr_pmcin = pmcstat_npmcs++;
+ pr->pr_samples = 0;
+ pr->pr_dubious_frames = 0;
pr->pr_merge = prm == NULL ? pr : prm;
LIST_INSERT_HEAD(&pmcstat_pmcs, pr, pr_next);
@@ -1032,7 +1050,6 @@ pmcstat_pmcid_to_name(pmc_id_t pmcid)
if (pr->pr_pmcid == pmcid)
return (pmcstat_string_unintern(pr->pr_pmcname));
- err(EX_SOFTWARE, "ERROR: cannot find pmcid");
return NULL;
}
@@ -1049,7 +1066,6 @@ pmcstat_pmcindex_to_name(int pmcin)
if (pr->pr_pmcin == pmcin)
return pmcstat_string_unintern(pr->pr_pmcname);
- err(EX_SOFTWARE, "ERROR: cannot find pmcid name");
return NULL;
}
@@ -1066,7 +1082,6 @@ pmcstat_pmcindex_to_pmcr(int pmcin)
if (pr->pr_pmcin == pmcin)
return pr;
- err(EX_SOFTWARE, "ERROR: invalid pmcindex");
return NULL;
}
@@ -1388,6 +1403,7 @@ pmcstat_analyze_log(void)
/* Get PMC record. */
pmcr = pmcstat_lookup_pmcid(ev.pl_u.pl_s.pl_pmcid);
assert(pmcr != NULL);
+ pmcr->pr_samples++;
/*
* Call the plugins processing
@@ -1421,6 +1437,7 @@ pmcstat_analyze_log(void)
/* Get PMC record. */
pmcr = pmcstat_lookup_pmcid(ev.pl_u.pl_cc.pl_pmcid);
assert(pmcr != NULL);
+ pmcr->pr_samples++;
/*
* Call the plugins processing
@@ -1670,10 +1687,8 @@ pmcstat_print_log(void)
int
pmcstat_close_log(void)
{
- if (pmc_flush_logfile() < 0 ||
- pmc_configure_logfile(-1) < 0)
+ if (pmc_flush_logfile() < 0)
err(EX_OSERR, "ERROR: logging failed");
- args.pa_flags &= ~(FLAG_HAS_OUTPUT_LOGFILE | FLAG_HAS_PIPE);
return (args.pa_flags & FLAG_HAS_PIPE ? PMCSTAT_EXITING :
PMCSTAT_FINISHED);
}
@@ -1790,28 +1805,46 @@ pmcstat_process_log(void)
static void
pmcstat_refresh_top(void)
{
+ int v_attrs;
+ float v;
char pmcname[40];
+ struct pmcstat_pmcrecord *pmcpr;
/* If in pause mode do not refresh display. */
if (pmcstat_pause)
return;
+ /* Wait until PMC pop in the log. */
+ pmcpr = pmcstat_pmcindex_to_pmcr(pmcstat_pmcinfilter);
+ if (pmcpr == NULL)
+ return;
+
/* Format PMC name. */
if (pmcstat_mergepmc)
snprintf(pmcname, sizeof(pmcname), "[%s]",
- pmcstat_pmcindex_to_name(pmcstat_pmcinfilter));
+ pmcstat_string_unintern(pmcpr->pr_pmcname));
else
snprintf(pmcname, sizeof(pmcname), "%s.%d",
- pmcstat_pmcindex_to_name(pmcstat_pmcinfilter),
+ pmcstat_string_unintern(pmcpr->pr_pmcname),
pmcstat_pmcinfilter);
+ /* Format samples count. */
+ if (pmcstat_stats.ps_samples_total > 0)
+ v = (pmcpr->pr_samples * 100.0) /
+ pmcstat_stats.ps_samples_total;
+ else
+ v = 0.;
+ v_attrs = PMCSTAT_ATTRPERCENT(v);
+
PMCSTAT_PRINTBEGIN();
- PMCSTAT_PRINTW("PMC: %s Samples: %u processed, %u invalid\n\n",
+ PMCSTAT_PRINTW("PMC: %s Samples: %u ",
pmcname,
- pmcstat_stats.ps_samples_total,
- pmcstat_stats.ps_samples_unknown_offset +
- pmcstat_stats.ps_samples_indeterminable +
- pmcstat_stats.ps_callchain_dubious_frames);
+ pmcpr->pr_samples);
+ PMCSTAT_ATTRON(v_attrs);
+ PMCSTAT_PRINTW("(%.1f%%) ", v);
+ PMCSTAT_ATTROFF(v_attrs);
+ PMCSTAT_PRINTW(", %u unresolved\n\n",
+ pmcpr->pr_dubious_frames);
if (plugins[args.pa_plugin].pl_topdisplay != NULL)
plugins[args.pa_plugin].pl_topdisplay();
PMCSTAT_PRINTEND();
@@ -1878,7 +1911,7 @@ pmcstat_keypress_log(void)
*/
if (plugins[args.pa_plugin].pl_shutdown != NULL)
plugins[args.pa_plugin].pl_shutdown(NULL);
- bzero(&pmcstat_stats, sizeof(struct pmcstat_stats));
+ pmcstat_stats_reset();
if (plugins[args.pa_plugin].pl_init != NULL)
plugins[args.pa_plugin].pl_init();
@@ -1899,7 +1932,7 @@ pmcstat_keypress_log(void)
} while (plugins[args.pa_plugin].pl_topdisplay == NULL);
/* Open new plugin. */
- bzero(&pmcstat_stats, sizeof(struct pmcstat_stats));
+ pmcstat_stats_reset();
if (plugins[args.pa_plugin].pl_init != NULL)
plugins[args.pa_plugin].pl_init();
wprintw(w, "switching to plugin %s",
@@ -1948,7 +1981,7 @@ pmcstat_display_log(void)
if (args.pa_topmode == PMCSTAT_TOP_DELTA) {
if (plugins[args.pa_plugin].pl_shutdown != NULL)
plugins[args.pa_plugin].pl_shutdown(NULL);
- bzero(&pmcstat_stats, sizeof(struct pmcstat_stats));
+ pmcstat_stats_reset();
if (plugins[args.pa_plugin].pl_init != NULL)
plugins[args.pa_plugin].pl_init();
}
diff --git a/usr.sbin/pmcstat/pmcstat_log.h b/usr.sbin/pmcstat/pmcstat_log.h
index de92649..8936fad 100644
--- a/usr.sbin/pmcstat/pmcstat_log.h
+++ b/usr.sbin/pmcstat/pmcstat_log.h
@@ -146,6 +146,8 @@ struct pmcstat_pmcrecord {
pmc_id_t pr_pmcid;
int pr_pmcin;
pmcstat_interned_string pr_pmcname;
+ int pr_samples;
+ int pr_dubious_frames;
struct pmcstat_pmcrecord *pr_merge;
};
extern LIST_HEAD(pmcstat_pmcs, pmcstat_pmcrecord) pmcstat_pmcs; /* PMC list */
diff --git a/usr.sbin/powerd/powerd.8 b/usr.sbin/powerd/powerd.8
index 5808862..2d6acff 100644
--- a/usr.sbin/powerd/powerd.8
+++ b/usr.sbin/powerd/powerd.8
@@ -58,7 +58,7 @@ the system appears idle and increasing it when the system is busy.
It offers a good balance between a small performance loss for greatly
increased power savings.
Hiadaptive mode is like adaptive mode, but tuned for systems where
-performance and interactivity are more important then power consumption.
+performance and interactivity are more important than power consumption.
It increases frequency faster, reduces the frequency less aggressively and
will maintain full frequency for longer.
The default mode is adaptive for battery power and hiadaptive for the rest.
diff --git a/usr.sbin/ppp/arp.c b/usr.sbin/ppp/arp.c
index 02dce51..e67f89b 100644
--- a/usr.sbin/ppp/arp.c
+++ b/usr.sbin/ppp/arp.c
@@ -119,7 +119,7 @@ arp_ProxySub(struct bundle *bundle, struct in_addr addr, int add)
return 0;
}
arpmsg.hdr.rtm_type = add ? RTM_ADD : RTM_DELETE;
- arpmsg.hdr.rtm_flags = RTF_ANNOUNCE | RTF_HOST | RTF_STATIC;
+ arpmsg.hdr.rtm_flags = RTF_ANNOUNCE | RTF_HOST | RTF_STATIC | RTF_LLDATA;
arpmsg.hdr.rtm_version = RTM_VERSION;
arpmsg.hdr.rtm_seq = ++bundle->routing_seq;
arpmsg.hdr.rtm_addrs = RTA_DST | RTA_GATEWAY;
diff --git a/usr.sbin/pppctl/pppctl.8 b/usr.sbin/pppctl/pppctl.8
index 245690f..431b7d7 100644
--- a/usr.sbin/pppctl/pppctl.8
+++ b/usr.sbin/pppctl/pppctl.8
@@ -1,7 +1,7 @@
.\" $FreeBSD$
.Dd June 26, 1997
-.Os
.Dt PPPCTL 8
+.Os
.Sh NAME
.Nm pppctl
.Nd PPP control program
diff --git a/usr.sbin/sade/disks.c b/usr.sbin/sade/disks.c
index b802e12..3158ff3 100644
--- a/usr.sbin/sade/disks.c
+++ b/usr.sbin/sade/disks.c
@@ -202,10 +202,9 @@ static void
print_command_summary(void)
{
mvprintw(14, 0, "The following commands are supported (in upper or lower case):");
- mvprintw(16, 0, "A = Use Entire Disk G = set Drive Geometry C = Create Slice F = `DD' mode");
- mvprintw(17, 0, "D = Delete Slice Z = Toggle Size Units S = Set Bootable | = Wizard m.");
- mvprintw(18, 0, "T = Change Type U = Undo All Changes Q = Finish");
- mvprintw(18, 47, "W = Write Changes");
+ mvprintw(16, 0, "A = Use Entire Disk G = set Drive Geometry C = Create Slice");
+ mvprintw(17, 0, "D = Delete Slice Z = Toggle Size Units S = Set Bootable | = Expert m.");
+ mvprintw(18, 0, "T = Change Type U = Undo All Changes W = Write Changes Q = Finish");
mvprintw(21, 0, "Use F1 or ? to get more help, arrow keys to select.");
move(0, 0);
}
diff --git a/usr.sbin/sade/menus.c b/usr.sbin/sade/menus.c
index f48c772..df51804 100644
--- a/usr.sbin/sade/menus.c
+++ b/usr.sbin/sade/menus.c
@@ -92,24 +92,23 @@ DMenu MenuIPLType = {
DMenu MenuMBRType = {
DMENU_NORMAL_TYPE | DMENU_SELECTION_RETURNS,
"overwrite me", /* will be disk specific label */
- "FreeBSD comes with a boot selector that allows you to easily\n"
+ "FreeBSD comes with a boot manager that allows you to easily\n"
"select between FreeBSD and any other operating systems on your machine\n"
"at boot time. If you have more than one drive and want to boot\n"
- "from the second one, the boot selector will also make it possible\n"
+ "from the second one, the boot manager will also make it possible\n"
"to do so (limitations in the PC BIOS usually prevent this otherwise).\n"
- "If you do not want a boot selector, or wish to replace an existing\n"
- "one, select \"standard\". If you would prefer your Master Boot\n"
- "Record to remain untouched then select \"None\".\n\n"
- " NOTE: PC-DOS users will almost certainly require \"None\"!",
- "Press F1 to read about drive setup",
+ "If you have other operating systems installed and would like a choice when\n"
+ "booting, choose \"BootMgr\". If you would prefer to keep your existing\n"
+ "boot manager, select \"None\".\n\n",
+ "",
"drives",
- { { "BootMgr", "Install the FreeBSD Boot Manager",
- dmenuRadioCheck, dmenuSetValue, NULL, &BootMgr, 0, 0, 0, 0 },
- { "Standard", "Install a standard MBR (no boot manager)",
+ { { "Standard", "Install a standard MBR (non-interactive boot manager)",
dmenuRadioCheck, dmenuSetValue, NULL, &BootMgr, '(', '*', ')', 1 },
- { "None", "Leave the Master Boot Record untouched",
+ { "BootMgr", "Install the FreeBSD boot manager",
+ dmenuRadioCheck, dmenuSetValue, NULL, &BootMgr, '(', '*', ')', 0 },
+ { "None", "Do not install a boot manager",
dmenuRadioCheck, dmenuSetValue, NULL, &BootMgr, '(', '*', ')', 2 },
- { NULL, NULL, NULL, NULL, NULL, NULL, 0, 0, 0, 0 } },
+ { NULL, NULL, NULL, NULL, NULL, NULL, 0, 0, 0, 0 } }
};
#endif /* PC98 */
#endif /* __i386__ */
diff --git a/usr.sbin/services_mkdb/Makefile b/usr.sbin/services_mkdb/Makefile
new file mode 100644
index 0000000..659cdb8
--- /dev/null
+++ b/usr.sbin/services_mkdb/Makefile
@@ -0,0 +1,10 @@
+# $FreeBSD$
+
+PROG= services_mkdb
+MAN= services_mkdb.8
+SRCS= services_mkdb.c uniq.c
+
+DPADD+= ${LIBUTIL}
+LDADD+= -lutil
+
+.include <bsd.prog.mk>
diff --git a/usr.sbin/services_mkdb/services_mkdb.8 b/usr.sbin/services_mkdb/services_mkdb.8
new file mode 100644
index 0000000..6468fd2
--- /dev/null
+++ b/usr.sbin/services_mkdb/services_mkdb.8
@@ -0,0 +1,97 @@
+.\" $NetBSD: services_mkdb.8,v 1.9 2009/05/13 22:36:39 wiz Exp $
+.\"
+.\" Copyright (c) 1999 The NetBSD Foundation, Inc.
+.\" All rights reserved.
+.\"
+.\" This code is derived from software contributed to The NetBSD Foundation
+.\" by Luke Mewburn.
+.\"
+.\" Redistribution and use in source and binary forms, with or without
+.\" modification, are permitted provided that 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$
+.\"
+.Dd April 4, 2010
+.Dt SERVICES_MKDB 8
+.Os
+.Sh NAME
+.Nm services_mkdb
+.Nd generate the services databases
+.Sh SYNOPSIS
+.Nm
+.Op Fl q
+.Op Fl o Ar database
+.Op file
+.Nm
+.Fl u
+.Op file
+.Sh DESCRIPTION
+.Nm
+creates a
+.Xr db 3
+database for the specified file.
+If no file is specified, then
+.Pa /etc/services
+is used.
+The database is installed into
+.Pa /var/db/services.db .
+The file must be in the correct format (see
+.Xr services 5 ) .
+.Pp
+The options are as follows:
+.Bl -tag -width indent
+.It Fl o Ar database
+Put the output databases in the named file.
+.It Fl q
+Don't warn about duplicate services.
+.It Fl u
+Print the services file to stdout, omitting duplicate entries and comments.
+.El
+.Pp
+The databases are used by the C library services routines (see
+.Xr getservent 3 ) .
+.Pp
+.Nm
+exits zero on success, non-zero on failure.
+.Sh FILES
+.Bl -tag -width 24n -compact
+.It Pa /var/db/services.db
+The current services database.
+.It Pa /var/db/services.db.tmp
+A temporary file.
+.It Pa /etc/services
+The current services file.
+.El
+.Sh SEE ALSO
+.Xr db 3 ,
+.Xr getservent 3 ,
+.Xr services 5
+.Sh BUGS
+Because
+.Nm
+guarantees not to install a partial destination file it must
+build a temporary file in the same file system and if successful use
+.Xr rename 2
+to install over the destination file.
+.Pp
+If
+.Nm
+fails it will leave the previous version of the destination file intact.
diff --git a/usr.sbin/services_mkdb/services_mkdb.c b/usr.sbin/services_mkdb/services_mkdb.c
new file mode 100644
index 0000000..f4cf62a
--- /dev/null
+++ b/usr.sbin/services_mkdb/services_mkdb.c
@@ -0,0 +1,429 @@
+/* $NetBSD: services_mkdb.c,v 1.14 2008/04/28 20:24:17 martin Exp $ */
+
+/*-
+ * Copyright (c) 1999 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Luke Mewburn and 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.
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
+#include <sys/param.h>
+#include <sys/stat.h>
+
+#include <assert.h>
+#include <db.h>
+#include <err.h>
+#include <fcntl.h>
+#include <netdb.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+#include <libutil.h>
+#include <ctype.h>
+#include <errno.h>
+#include <stringlist.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);
+static void store(DB *, DBT *, DBT *, int);
+static void killproto(DBT *);
+static char *getstring(const char *, size_t, char **, const char *);
+static size_t getprotoindex(StringList *, const char *);
+static const char *getprotostr(StringList *, size_t);
+static const char *mkaliases(StringList *, char *, size_t);
+static void usage(void);
+
+const HASHINFO hinfo = {
+ .bsize = 256,
+ .ffactor = 4,
+ .nelem = 32768,
+ .cachesize = 1024,
+ .hash = NULL,
+ .lorder = 0
+};
+
+
+int
+main(int argc, char *argv[])
+{
+ DB *db;
+ int ch;
+ const char *fname = _PATH_SERVICES;
+ const char *dbname = _PATH_SERVICES_DB;
+ int warndup = 1;
+ int unique = 0;
+ int otherflag = 0;
+ size_t cnt = 0;
+ StringList *sl, ***svc;
+ size_t port, proto;
+
+ setprogname(argv[0]);
+
+ while ((ch = getopt(argc, argv, "qo:u")) != -1)
+ switch (ch) {
+ case 'q':
+ otherflag = 1;
+ warndup = 0;
+ break;
+ case 'o':
+ otherflag = 1;
+ dbname = optarg;
+ break;
+ case 'u':
+ unique++;
+ break;
+ case '?':
+ default:
+ usage();
+ }
+
+ argc -= optind;
+ argv += optind;
+
+ if (argc > 1 || (unique && otherflag))
+ usage();
+ if (argc == 1)
+ fname = argv[0];
+
+ if (unique)
+ uniq(fname);
+
+ svc = parseservices(fname, sl = sl_init());
+
+ if (atexit(cleanup))
+ err(1, "Cannot install exit handler");
+
+ (void)snprintf(tname, sizeof(tname), "%s.tmp", dbname);
+ db = dbopen(tname, O_RDWR | O_CREAT | O_EXCL,
+ (S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH), DB_HASH, &hinfo);
+ if (!db)
+ err(1, "Error opening temporary database `%s'", tname);
+
+
+ for (port = 0; port < PMASK + 1; port++) {
+ if (svc[port] == NULL)
+ continue;
+
+ for (proto = 0; proto < PROTOMAX; proto++) {
+ StringList *s;
+ if ((s = svc[port][proto]) == NULL)
+ continue;
+ add(db, s, port, getprotostr(sl, proto), &cnt, warndup);
+ }
+
+ free(svc[port]);
+ }
+
+ free(svc);
+ sl_free(sl, 1);
+
+ if ((db->close)(db))
+ err(1, "Error closing temporary database `%s'", tname);
+
+ if (rename(tname, dbname) == -1)
+ err(1, "Cannot rename `%s' to `%s'", tname, dbname);
+
+ return 0;
+}
+
+static void
+add(DB *db, StringList *sl, size_t port, const char *proto, size_t *cnt,
+ int warndup)
+{
+ size_t i;
+ char keyb[BUFSIZ], datab[BUFSIZ], abuf[BUFSIZ];
+ DBT data, key;
+ key.data = keyb;
+ data.data = datab;
+
+#ifdef DEBUG
+ (void)printf("add %s %zu %s [ ", sl->sl_str[0], port, proto);
+ for (i = 1; i < sl->sl_cur; i++)
+ (void)printf("%s ", sl->sl_str[i]);
+ (void)printf("]\n");
+#endif
+
+ /* key `indirect key', data `full line' */
+ data.size = snprintf(datab, sizeof(datab), "%zu", (*cnt)++) + 1;
+ key.size = snprintf(keyb, sizeof(keyb), "%s %zu/%s %s",
+ sl->sl_str[0], port, proto, mkaliases(sl, abuf, sizeof(abuf))) + 1;
+ store(db, &data, &key, warndup);
+
+ /* key `\377port/proto', data = `indirect key' */
+ key.size = snprintf(keyb, sizeof(keyb), "\377%zu/%s",
+ port, proto) + 1;
+ store(db, &key, &data, warndup);
+
+ /* key `\377port', data = `indirect key' */
+ killproto(&key);
+ store(db, &key, &data, warndup);
+
+ /* add references for service and all aliases */
+ for (i = 0; i < sl->sl_cur; i++) {
+ /* key `\376service/proto', data = `indirect key' */
+ key.size = snprintf(keyb, sizeof(keyb), "\376%s/%s",
+ sl->sl_str[i], proto) + 1;
+ store(db, &key, &data, warndup);
+
+ /* key `\376service', data = `indirect key' */
+ killproto(&key);
+ store(db, &key, &data, warndup);
+ }
+ sl_free(sl, 1);
+}
+
+static StringList ***
+parseservices(const char *fname, StringList *sl)
+{
+ size_t len, line, pindex;
+ FILE *fp;
+ StringList ***svc, *s;
+ char *p, *ep;
+
+ if ((fp = fopen(fname, "r")) == NULL)
+ err(1, "Cannot open `%s'", fname);
+
+ line = 0;
+ if ((svc = calloc(PMASK + 1, sizeof(StringList **))) == NULL)
+ err(1, "Cannot allocate %zu bytes", (size_t)(PMASK + 1));
+
+ /* XXX: change NULL to "\0\0#" when fparseln fixed */
+ for (; (p = fparseln(fp, &len, &line, NULL, 0)) != NULL; free(p)) {
+ char *name, *port, *proto, *aliases, *cp, *alias;
+ unsigned long pnum;
+
+ if (len == 0)
+ continue;
+
+ for (cp = p; *cp && isspace((unsigned char)*cp); cp++)
+ continue;
+
+ if (*cp == '\0' || *cp == '#')
+ continue;
+
+ if ((name = getstring(fname, line, &cp, "name")) == NULL)
+ continue;
+
+ if ((port = getstring(fname, line, &cp, "port")) == NULL)
+ continue;
+
+ if (cp) {
+ for (aliases = cp; *cp && *cp != '#'; cp++)
+ continue;
+
+ if (*cp)
+ *cp = '\0';
+ } else
+ aliases = NULL;
+
+ proto = strchr(port, '/');
+ if (proto == NULL || proto[1] == '\0') {
+ warnx("%s, %zu: no protocol found", fname, line);
+ continue;
+ }
+ *proto++ = '\0';
+
+ errno = 0;
+ pnum = strtoul(port, &ep, 0);
+ if (*port == '\0' || *ep != '\0') {
+ warnx("%s, %zu: invalid port `%s'", fname, line, port);
+ continue;
+ }
+ if ((errno == ERANGE && pnum == ULONG_MAX) || pnum > PMASK) {
+ warnx("%s, %zu: port too big `%s'", fname, line, port);
+ continue;
+ }
+
+ if (svc[pnum] == NULL) {
+ svc[pnum] = calloc(PROTOMAX, sizeof(StringList *));
+ if (svc[pnum] == NULL)
+ err(1, "Cannot allocate %zu bytes",
+ (size_t)PROTOMAX);
+ }
+
+ pindex = getprotoindex(sl, proto);
+ if (svc[pnum][pindex] == NULL)
+ s = svc[pnum][pindex] = sl_init();
+ else
+ s = svc[pnum][pindex];
+
+ /* build list of aliases */
+ if (sl_find(s, name) == NULL) {
+ char *p2;
+
+ if ((p2 = strdup(name)) == NULL)
+ err(1, "Cannot copy string");
+ (void)sl_add(s, p2);
+ }
+
+ if (aliases) {
+ while ((alias = strsep(&aliases, " \t")) != NULL) {
+ if (alias[0] == '\0')
+ continue;
+ if (sl_find(s, alias) == NULL) {
+ char *p2;
+
+ if ((p2 = strdup(alias)) == NULL)
+ err(1, "Cannot copy string");
+ (void)sl_add(s, p2);
+ }
+ }
+ }
+ }
+ (void)fclose(fp);
+ return svc;
+}
+
+/*
+ * cleanup(): Remove temporary files upon exit
+ */
+static void
+cleanup(void)
+{
+ if (tname[0])
+ (void)unlink(tname);
+}
+
+static char *
+getstring(const char *fname, size_t line, char **cp, const char *tag)
+{
+ char *str;
+
+ while ((str = strsep(cp, " \t")) != NULL && *str == '\0')
+ continue;
+
+ if (str == NULL)
+ warnx("%s, %zu: no %s found", fname, line, tag);
+
+ return str;
+}
+
+static void
+killproto(DBT *key)
+{
+ char *p, *d = key->data;
+
+ if ((p = strchr(d, '/')) == NULL)
+ abort();
+ *p++ = '\0';
+ key->size = p - d;
+}
+
+static void
+store(DB *db, DBT *key, DBT *data, int warndup)
+{
+#ifdef DEBUG
+ int k = key->size - 1;
+ int d = data->size - 1;
+ (void)printf("store [%*.*s] [%*.*s]\n",
+ k, k, (char *)key->data + 1,
+ d, d, (char *)data->data + 1);
+#endif
+ switch ((db->put)(db, key, data, R_NOOVERWRITE)) {
+ case 0:
+ break;
+ case 1:
+ if (warndup)
+ warnx("duplicate service `%s'",
+ &((char *)key->data)[1]);
+ break;
+ case -1:
+ err(1, "put");
+ break;
+ default:
+ abort();
+ break;
+ }
+}
+
+static size_t
+getprotoindex(StringList *sl, const char *str)
+{
+ size_t i;
+ char *p;
+
+ for (i= 0; i < sl->sl_cur; i++)
+ if (strcmp(sl->sl_str[i], str) == 0)
+ return i;
+
+ if (i == PROTOMAX)
+ errx(1, "Ran out of protocols adding `%s';"
+ " recompile with larger PROTOMAX", str);
+ if ((p = strdup(str)) == NULL)
+ err(1, "Cannot copy string");
+ (void)sl_add(sl, p);
+ return i;
+}
+
+static const char *
+getprotostr(StringList *sl, size_t i)
+{
+ assert(i < sl->sl_cur);
+ return sl->sl_str[i];
+}
+
+static const char *
+mkaliases(StringList *sl, char *buf, size_t len)
+{
+ size_t nc, i, pos;
+
+ buf[0] = 0;
+ for (i = 1, pos = 0; i < sl->sl_cur; i++) {
+ nc = strlcpy(buf + pos, sl->sl_str[i], len);
+ if (nc >= len)
+ goto out;
+ pos += nc;
+ len -= nc;
+ nc = strlcpy(buf + pos, " ", len);
+ if (nc >= len)
+ goto out;
+ pos += nc;
+ len -= nc;
+ }
+ return buf;
+out:
+ warn("aliases for `%s' truncated", sl->sl_str[0]);
+ return buf;
+}
+
+static void
+usage(void)
+{
+ (void)fprintf(stderr, "Usage:\t%s [-q] [-o <db>] [<servicefile>]\n"
+ "\t%s -u [<servicefile>]\n", getprogname(), getprogname());
+ exit(1);
+}
diff --git a/usr.sbin/services_mkdb/uniq.c b/usr.sbin/services_mkdb/uniq.c
new file mode 100644
index 0000000..0674b4b
--- /dev/null
+++ b/usr.sbin/services_mkdb/uniq.c
@@ -0,0 +1,159 @@
+/* $NetBSD: uniq.c,v 1.4 2008/04/28 20:24:17 martin Exp $ */
+
+/*-
+ * 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.
+ */
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#include <db.h>
+#include <err.h>
+#include <libutil.h>
+#include <ctype.h>
+#include <fcntl.h>
+
+extern const HASHINFO hinfo;
+
+void uniq(const char *);
+static int comp(const char *, char **, size_t *);
+
+/*
+ * Preserve only unique content lines in a file. Input lines that have
+ * content [alphanumeric characters before a comment] are white-space
+ * normalized and have their comments removed. Then they are placed
+ * in a hash table, and only the first instance of them is printed.
+ * Comment lines without any alphanumeric content are always printed
+ * since they are there to make the file "pretty". Comment lines with
+ * alphanumeric content are also placed into the hash table and only
+ * printed once.
+ */
+void
+uniq(const char *fname)
+{
+ DB *db;
+ DBT key;
+ static const DBT data = { NULL, 0 };
+ FILE *fp;
+ char *line;
+ size_t len;
+
+ if ((db = dbopen(NULL, O_RDWR, 0, DB_HASH, &hinfo)) == NULL)
+ err(1, "Cannot create in memory database");
+
+ if ((fp = fopen(fname, "r")) == NULL)
+ err(1, "Cannot open `%s'", fname);
+ while ((line = fgetln(fp, &len)) != NULL) {
+ size_t complen = len;
+ char *compline;
+ if (!comp(line, &compline, &complen)) {
+ (void)fprintf(stdout, "%*.*s", (int)len, (int)len,
+ line);
+ continue;
+ }
+ key.data = compline;
+ key.size = complen;
+ switch ((db->put)(db, &key, &data, R_NOOVERWRITE)) {
+ case 0:
+ (void)fprintf(stdout, "%*.*s", (int)len, (int)len,
+ line);
+ break;
+ case 1:
+ break;
+ case -1:
+ err(1, "put");
+ default:
+ abort();
+ break;
+ }
+ }
+ (void)fflush(stdout);
+ exit(0);
+}
+
+/*
+ * normalize whitespace in the original line and place a new string
+ * with whitespace converted to a single space in compline. If the line
+ * contains just comments, we preserve them. If it contains data and
+ * comments, we kill the comments. Return 1 if the line had actual
+ * contents, or 0 if it was just a comment without alphanumeric characters.
+ */
+static int
+comp(const char *origline, char **compline, size_t *len)
+{
+ const unsigned char *p;
+ unsigned char *q;
+ char *cline;
+ size_t l = *len, complen;
+ int hasalnum, iscomment;
+
+ /* Eat leading space */
+ for (p = (const unsigned char *)origline; l && *p && isspace(*p);
+ p++, l--)
+ continue;
+ if ((cline = malloc(l + 1)) == NULL)
+ err(1, "Cannot allocate %zu bytes", l + 1);
+ (void)memcpy(cline, p, l);
+ cline[l] = '\0';
+ if (*cline == '\0')
+ return 0;
+
+ complen = 0;
+ hasalnum = 0;
+ iscomment = 0;
+
+ for (q = (unsigned char *)cline; l && *p; p++, l--) {
+ if (isspace(*p)) {
+ if (complen && isspace(q[-1]))
+ continue;
+ *q++ = ' ';
+ complen++;
+ } else {
+ if (!iscomment && *p == '#') {
+ if (hasalnum)
+ break;
+ iscomment = 1;
+ } else
+ hasalnum |= isalnum(*p);
+ *q++ = *p;
+ complen++;
+ }
+ }
+
+ /* Eat trailing space */
+ while (complen && isspace(q[-1])) {
+ --q;
+ --complen;
+ }
+ *q = '\0';
+ *compline = cline;
+ *len = complen;
+ return hasalnum;
+}
diff --git a/usr.sbin/setfmac/setfsmac.8 b/usr.sbin/setfmac/setfsmac.8
index 7d4150f..9bdb0e8 100644
--- a/usr.sbin/setfmac/setfsmac.8
+++ b/usr.sbin/setfmac/setfsmac.8
@@ -31,8 +31,8 @@
.\" $FreeBSD$
.\"
.Dd February 17, 2004
-.Os
.Dt SETFSMAC 8
+.Os
.Sh NAME
.Nm setfsmac
.Nd set MAC label for a file hierarchy
diff --git a/usr.sbin/setpmac/setpmac.8 b/usr.sbin/setpmac/setpmac.8
index e84a8bc6..c5c2963 100644
--- a/usr.sbin/setpmac/setpmac.8
+++ b/usr.sbin/setpmac/setpmac.8
@@ -31,8 +31,8 @@
.\" $FreeBSD$
.\"
.Dd January 14, 2003
-.Os
.Dt SETPMAC 8
+.Os
.Sh NAME
.Nm setpmac
.Nd "run a command with a different MAC process label"
diff --git a/usr.sbin/sysinstall/devices.c b/usr.sbin/sysinstall/devices.c
index a2b7939..8cf1fb3 100644
--- a/usr.sbin/sysinstall/devices.c
+++ b/usr.sbin/sysinstall/devices.c
@@ -150,6 +150,7 @@ static struct _devname {
NETWORK("rue", "RealTek USB Ethernet card"),
NETWORK("rum", "Ralink Technology USB IEEE 802.11 wireless adapter"),
NETWORK("sf", "Adaptec AIC-6915 PCI Ethernet card"),
+ NETWORK("sge", "Silicon Integrated Systems SiS190/191 Ethernet"),
NETWORK("sis", "SiS 900/SiS 7016 PCI Ethernet card"),
#ifdef PC98
NETWORK("snc", "SONIC Ethernet card"),
diff --git a/usr.sbin/sysinstall/disks.c b/usr.sbin/sysinstall/disks.c
index a1c09b6..c0fd12a 100644
--- a/usr.sbin/sysinstall/disks.c
+++ b/usr.sbin/sysinstall/disks.c
@@ -207,9 +207,12 @@ print_command_summary(void)
mvprintw(14, 0, "The following commands are supported (in upper or lower case):");
mvprintw(16, 0, "A = Use Entire Disk G = set Drive Geometry C = Create Slice");
mvprintw(17, 0, "D = Delete Slice Z = Toggle Size Units S = Set Bootable | = Expert m.");
- mvprintw(18, 0, "T = Change Type U = Undo All Changes Q = Finish");
+ mvprintw(18, 0, "T = Change Type U = Undo All Changes");
+
if (!RunningAsInit)
- mvprintw(18, 47, "W = Write Changes");
+ mvprintw(18, 47, "W = Write Changes Q = Finish");
+ else
+ mvprintw(18, 47, "Q = Finish");
mvprintw(21, 0, "Use F1 or ? to get more help, arrow keys to select.");
move(0, 0);
}
diff --git a/usr.sbin/sysinstall/menus.c b/usr.sbin/sysinstall/menus.c
index decb4fd..65cab4c 100644
--- a/usr.sbin/sysinstall/menus.c
+++ b/usr.sbin/sysinstall/menus.c
@@ -1175,20 +1175,16 @@ DMenu MenuMBRType = {
"at boot time. If you have more than one drive and want to boot\n"
"from the second one, the boot manager will also make it possible\n"
"to do so (limitations in the PC BIOS usually prevent this otherwise).\n"
- "If you will only have FreeBSD on the machine the boot manager is\n"
- "not needed and it slows down the boot while offering you the choice\n"
- "of which operating system to boot. If you do not want a boot\n"
- "manager, or wish to replace an existing one, select \"standard\".\n"
- "If you would prefer your Master Boot Record remain untouched then\n"
- "select \"None\".\n\n"
- " NOTE: PC-DOS users will almost certainly require \"None\"!",
- "Press F1 to read about drive setup",
+ "If you have other operating systems installed and would like a choice when\n"
+ "booting, choose \"BootMgr\". If you would prefer to keep your existing\n"
+ "boot manager, select \"None\".\n\n",
+ "",
"drives",
- { { "Standard", "Install a standard MBR (no boot manager)",
+ { { "Standard", "Install a standard MBR (non-interactive boot manager)",
dmenuRadioCheck, dmenuSetValue, NULL, &BootMgr, '(', '*', ')', 1 },
{ "BootMgr", "Install the FreeBSD Boot Manager",
dmenuRadioCheck, dmenuSetValue, NULL, &BootMgr, '(', '*', ')', 0 },
- { "None", "Leave the Master Boot Record untouched",
+ { "None", "Do not install a boot manager",
dmenuRadioCheck, dmenuSetValue, NULL, &BootMgr, '(', '*', ')', 2 },
{ NULL } },
};
@@ -1980,26 +1976,28 @@ DMenu MenuSysconsSaver = {
NULL,
{ { "1 Blank", "Simply blank the screen",
dmenuVarCheck, configSaver, NULL, "saver=blank" },
- { "2 Daemon", "\"BSD Daemon\" animated screen saver (text)",
+ { "2 Beastie", "\"BSD Daemon\" animated screen saver (graphics)",
+ dmenuVarCheck, configSaver, NULL, "saver=beastie" },
+ { "3 Daemon", "\"BSD Daemon\" animated screen saver (text)",
dmenuVarCheck, configSaver, NULL, "saver=daemon" },
- { "3 Fade", "Fade out effect screen saver",
+ { "4 Dragon", "Dragon screensaver (graphics)",
+ dmenuVarCheck, configSaver, NULL, "saver=dragon" },
+ { "5 Fade", "Fade out effect screen saver",
dmenuVarCheck, configSaver, NULL, "saver=fade" },
- { "4 Fire", "Flames effect screen saver",
+ { "6 Fire", "Flames effect screen saver",
dmenuVarCheck, configSaver, NULL, "saver=fire" },
- { "5 Green", "\"Green\" power saving mode (if supported by monitor)",
+ { "7 Green", "\"Green\" power saving mode (if supported by monitor)",
dmenuVarCheck, configSaver, NULL, "saver=green" },
- { "6 Logo", "\"BSD Daemon\" animated screen saver (graphics)",
+ { "8 Logo", "FreeBSD \"logo\" animated screen saver (graphics)",
dmenuVarCheck, configSaver, NULL, "saver=logo" },
- { "7 Rain", "Rain drops screen saver",
+ { "9 Rain", "Rain drops screen saver",
dmenuVarCheck, configSaver, NULL, "saver=rain" },
- { "8 Snake", "Draw a FreeBSD \"snake\" on your screen",
+ { "a Snake", "Draw a FreeBSD \"snake\" on your screen",
dmenuVarCheck, configSaver, NULL, "saver=snake" },
- { "9 Star", "A \"twinkling stars\" effect",
+ { "b Star", "A \"twinkling stars\" effect",
dmenuVarCheck, configSaver, NULL, "saver=star" },
- { "Warp", "A \"stars warping\" effect",
+ { "c Warp", "A \"stars warping\" effect",
dmenuVarCheck, configSaver, NULL, "saver=warp" },
- { "Dragon", "Dragon screensaver (graphics)",
- dmenuVarCheck, configSaver, NULL, "saver=dragon" },
{ "Timeout", "Set the screen saver timeout interval",
NULL, configSaverTimeout, NULL, NULL, ' ', ' ', ' ' },
{ NULL } },
diff --git a/usr.sbin/sysinstall/sysinstall.8 b/usr.sbin/sysinstall/sysinstall.8
index cdaec6d..010b9eb 100644
--- a/usr.sbin/sysinstall/sysinstall.8
+++ b/usr.sbin/sysinstall/sysinstall.8
@@ -541,7 +541,7 @@ Commit any rc.conf changes to disk.
Preserve existing rc.conf parameters.
This is useful if you have a post-install script which modifies rc.conf.
.El
- .It installExpress
+.It installExpress
Start an "express" installation, asking few questions of
the user.
.Pp
diff --git a/usr.sbin/sysinstall/tcpip.c b/usr.sbin/sysinstall/tcpip.c
index 75a40e8..1c1d676 100644
--- a/usr.sbin/sysinstall/tcpip.c
+++ b/usr.sbin/sysinstall/tcpip.c
@@ -683,6 +683,8 @@ tcpDeviceScan(void)
}
}
+ close(s);
+
freeifaddrs(ifap);
return (NULL);
diff --git a/usr.sbin/uhsoctl/Makefile b/usr.sbin/uhsoctl/Makefile
index 9704923..565b2e6 100644
--- a/usr.sbin/uhsoctl/Makefile
+++ b/usr.sbin/uhsoctl/Makefile
@@ -2,7 +2,7 @@
PROG= uhsoctl
MAN= uhsoctl.1
-WARNS= 1
+WARNS?= 1
DPADD= ${LIBUTIL}
LDADD= -lutil
diff --git a/usr.sbin/uhsoctl/uhsoctl.1 b/usr.sbin/uhsoctl/uhsoctl.1
index 932cefa..cd0c5ca 100644
--- a/usr.sbin/uhsoctl/uhsoctl.1
+++ b/usr.sbin/uhsoctl/uhsoctl.1
@@ -24,8 +24,8 @@
.\" $FreeBSD$
.\"
.Dd Aug 12, 2009
-.Os
.Dt UHSOCTL 1
+.Os
.Sh NAME
.Nm uhsoctl
.Nd connection utility for Option based devices
@@ -94,11 +94,9 @@ on interface
and use PIN
.Dq 1234
to enable the SIM card.
-
.Dl "uhsoctl -a apn.example.com -p 1234 uhso0"
-
-Disconnect from a previously established connection
-
+.Pp
+Disconnect from a previously established connection.
.Dl "uhsoctl -d uhso0"
.Sh SEE ALSO
.Xr uhso 4
diff --git a/usr.sbin/vidcontrol/vidcontrol.c b/usr.sbin/vidcontrol/vidcontrol.c
index 06afe53..48580f1 100644
--- a/usr.sbin/vidcontrol/vidcontrol.c
+++ b/usr.sbin/vidcontrol/vidcontrol.c
@@ -950,10 +950,11 @@ show_adapter_info(void)
static void
show_mode_info(void)
{
- struct video_info _info;
char buf[80];
- int mode;
+ struct video_info _info;
int c;
+ int mm;
+ int mode;
printf(" mode# flags type size "
"font window linear buffer\n");
@@ -972,9 +973,35 @@ show_mode_info(void)
if (_info.vi_flags & V_INFO_GRAPHICS) {
c = 'G';
- snprintf(buf, sizeof(buf), "%dx%dx%d %d",
- _info.vi_width, _info.vi_height,
- _info.vi_depth, _info.vi_planes);
+ if (_info.vi_mem_model == V_INFO_MM_PLANAR)
+ snprintf(buf, sizeof(buf), "%dx%dx%d %d",
+ _info.vi_width, _info.vi_height,
+ _info.vi_depth, _info.vi_planes);
+ else {
+ switch (_info.vi_mem_model) {
+ case V_INFO_MM_PACKED:
+ mm = 'P';
+ break;
+ case V_INFO_MM_DIRECT:
+ mm = 'D';
+ break;
+ case V_INFO_MM_CGA:
+ mm = 'C';
+ break;
+ case V_INFO_MM_HGC:
+ mm = 'H';
+ break;
+ case V_INFO_MM_VGAX:
+ mm = 'V';
+ break;
+ default:
+ mm = ' ';
+ break;
+ }
+ snprintf(buf, sizeof(buf), "%dx%dx%d %c",
+ _info.vi_width, _info.vi_height,
+ _info.vi_depth, mm);
+ }
} else {
c = 'T';
diff --git a/usr.sbin/wpa/wpa_supplicant/driver_freebsd.c b/usr.sbin/wpa/wpa_supplicant/driver_freebsd.c
index ec8ae98..65989c2 100644
--- a/usr.sbin/wpa/wpa_supplicant/driver_freebsd.c
+++ b/usr.sbin/wpa/wpa_supplicant/driver_freebsd.c
@@ -396,7 +396,7 @@ wpa_driver_bsd_associate(void *priv, struct wpa_driver_associate_params *params)
{
struct wpa_driver_bsd_data *drv = priv;
struct ieee80211req_mlme mlme;
- int privacy;
+ int flags, privacy;
wpa_printf(MSG_DEBUG,
"%s: ssid '%.*s' wpa ie len %u pairwise %u group %u key mgmt %u"
@@ -408,6 +408,17 @@ wpa_driver_bsd_associate(void *priv, struct wpa_driver_associate_params *params)
, params->key_mgmt_suite
);
+ /* NB: interface must be marked UP to associate */
+ if (getifflags(drv, &flags) != 0) {
+ wpa_printf(MSG_DEBUG, "%s did not mark interface UP", __func__);
+ return -1;
+ }
+ if ((flags & IFF_UP) == 0 && setifflags(drv, flags | IFF_UP) != 0) {
+ wpa_printf(MSG_DEBUG, "%s unable to mark interface UP",
+ __func__);
+ return -1;
+ }
+
/* XXX error handling is wrong but unclear what to do... */
if (wpa_driver_bsd_set_wpa_ie(drv, params->wpa_ie, params->wpa_ie_len) < 0)
return -1;
diff --git a/usr.sbin/wpa/wpa_supplicant/wpa_supplicant.conf.5 b/usr.sbin/wpa/wpa_supplicant/wpa_supplicant.conf.5
index a7a1698..7e25391 100644
--- a/usr.sbin/wpa/wpa_supplicant/wpa_supplicant.conf.5
+++ b/usr.sbin/wpa/wpa_supplicant/wpa_supplicant.conf.5
@@ -24,7 +24,7 @@
.\"
.\" $FreeBSD$
.\"
-.Dd July 8, 2007
+.Dd April 10, 2010
.Dt WPA_SUPPLICANT.CONF 5
.Os
.Sh NAME
@@ -153,7 +153,27 @@ Note that IBSS (adhoc) mode can only be used with
.Va key_mgmt
set to
.Li NONE
-(plaintext and static WEP).
+(plaintext and static WEP), or
+.Va key_mgmt
+set to
+.Li WPA-NONE
+(fixed group key TKIP/CCMP).
+In addition,
+.Va ap_scan
+has to be set to 2 for IBSS.
+.Li WPA-NONE
+requires
+.Va proto
+set to WPA,
+.Va key_mgmt
+set to WPA-NONE,
+.Va pairwise
+set to NONE,
+.Va group
+set to either
+CCMP or TKIP (but not both), and
+.Va psk
+must also be set.
.It Va proto
List of acceptable protocols; one or more of:
.Li WPA
diff --git a/usr.sbin/zic/Makefile b/usr.sbin/zic/Makefile
index 2496e82..9d699a8 100644
--- a/usr.sbin/zic/Makefile
+++ b/usr.sbin/zic/Makefile
@@ -1,7 +1,6 @@
# $FreeBSD$
# Vendor contact: tz@elsie.nci.nih.gov
-MAINTAINER= wollman@FreeBSD.org
SUBDIR= zic zdump
OpenPOWER on IntegriCloud