]> xenbits.xensource.com Git - people/julieng/freebsd.git/commitdiff
Revert r289133; retry the merge
authorngie <ngie@FreeBSD.org>
Sun, 11 Oct 2015 08:26:48 +0000 (08:26 +0000)
committerngie <ngie@FreeBSD.org>
Sun, 11 Oct 2015 08:26:48 +0000 (08:26 +0000)
70 files changed:
Makefile.inc1
contrib/dma/BSDmakefile [new file with mode: 0644]
contrib/dma/LICENSE
contrib/dma/README.markdown
contrib/dma/TODO
contrib/dma/VERSION
contrib/dma/aliases_parse.y
contrib/dma/aliases_scan.l
contrib/dma/conf.c
contrib/dma/debian/NEWS [new file with mode: 0644]
contrib/dma/debian/README.Debian [new file with mode: 0644]
contrib/dma/debian/changelog [new file with mode: 0644]
contrib/dma/debian/compat [new file with mode: 0644]
contrib/dma/debian/control [new file with mode: 0644]
contrib/dma/debian/copyright [new file with mode: 0644]
contrib/dma/debian/dma-migrate.dirs [new file with mode: 0644]
contrib/dma/debian/dma-migrate.install [new file with mode: 0644]
contrib/dma/debian/dma-migrate.manpages [new file with mode: 0644]
contrib/dma/debian/dma.dirs [new file with mode: 0644]
contrib/dma/debian/dma.links [new file with mode: 0644]
contrib/dma/debian/dma.lintian-overrides [new file with mode: 0644]
contrib/dma/debian/migrate/Makefile [new file with mode: 0644]
contrib/dma/debian/migrate/NEWS [new file with mode: 0644]
contrib/dma/debian/migrate/dma-migrate.8 [new file with mode: 0644]
contrib/dma/debian/migrate/dma-migrate.c [new file with mode: 0644]
contrib/dma/debian/rules [new file with mode: 0755]
contrib/dma/debian/source/format [new file with mode: 0644]
contrib/dma/debian/source/options [new file with mode: 0644]
contrib/dma/dma-mbox-create.c
contrib/dma/dma.8
contrib/dma/dma.c
contrib/dma/dma.h
contrib/dma/dns.c
contrib/dma/get-version.sh
contrib/dma/local.c
contrib/dma/mail.c
contrib/dma/net.c
contrib/dma/spool.c
contrib/dma/util.c
lib/libarchive/tests/Makefile [new file with mode: 0644]
lib/libarchive/tests/functional_test.sh [new file with mode: 0755]
lib/libc/sys/shmctl.2
libexec/dma/Makefile.inc
libexec/dma/dmagent/Makefile
sbin/geom/class/nop/gnop.8
sbin/mdconfig/mdconfig.8
sbin/mdconfig/mdconfig.c
share/man/man4/vtnet.4
share/mk/Makefile
share/mk/bsd.confs.mk
share/mk/bsd.own.mk
sys/dev/cxgbe/iw_cxgbe/cm.c
sys/dev/drm2/i915/i915_gem.c
sys/dev/iicbus/icee.c
sys/dev/iicbus/iiconf.h
sys/dev/wpi/if_wpi.c
sys/dev/wpi/if_wpireg.h
sys/dev/wpi/if_wpivar.h
sys/geom/nop/g_nop.c
sys/geom/nop/g_nop.h
sys/kern/kern_module.c
sys/kern/sysv_shm.c
sys/mips/conf/AP135.hints
sys/mips/conf/TP-MR3020
sys/mips/conf/TP-MR3020.hints
usr.bin/cpio/tests/Makefile [new file with mode: 0644]
usr.bin/cpio/tests/functional_test.sh [new file with mode: 0755]
usr.bin/tar/tests/Makefile [new file with mode: 0644]
usr.bin/tar/tests/functional_test.sh [new file with mode: 0755]
usr.sbin/ppp/Makefile

index 9332b300e06065bbeab64d0bbf2ee1767342b49b..d4e24e4b5d37a7b5dad62d922360746da490c24e 100644 (file)
@@ -1003,9 +1003,7 @@ distrib-dirs: .MAKE
 distribution: .MAKE
        cd ${.CURDIR}/etc; ${CROSSENV} PATH=${TMPPATH} ${MAKE} \
            ${IMAKE_INSTALL} ${IMAKE_MTREE} METALOG=${METALOG} ${.TARGET}
-       ${_+_}cd ${.CURDIR}; ${CROSSENV} PATH=${TMPPATH} \
-               ${MAKE} -f Makefile.inc1 ${IMAKE_INSTALL} \
-               METALOG=${METALOG} installconfig
+       ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 installconfig
 
 #
 # buildkernel and installkernel
diff --git a/contrib/dma/BSDmakefile b/contrib/dma/BSDmakefile
new file mode 100644 (file)
index 0000000..af3a0ac
--- /dev/null
@@ -0,0 +1,28 @@
+# $DragonFly: src/libexec/dma/Makefile,v 1.5 2008/09/19 00:36:57 corecode Exp $
+#
+
+version!=      sh get-version.sh
+
+CFLAGS+= -I${.CURDIR}
+CFLAGS+= -DHAVE_REALLOCF -DHAVE_STRLCPY -DHAVE_GETPROGNAME
+CFLAGS+= -DLIBEXEC_PATH='"${LIBEXEC}"' -DDMA_VERSION='"${version}"'
+CFLAGS+= -DCONF_PATH='"${CONFDIR}"'
+
+DPADD=  ${LIBSSL} ${LIBCRYPTO}
+LDADD=  -lssl -lcrypto
+
+PROG=  dma
+SRCS=  aliases_parse.y aliases_scan.l base64.c conf.c crypto.c
+SRCS+= dma.c dns.c local.c mail.c net.c spool.c util.c
+MAN=   dma.8
+
+PREFIX?=       /usr/local
+LIBEXEC?=      ${PREFIX}/libexec
+CONFDIR?=      ${PREFIX}/etc/dma
+
+BINOWN= root
+BINGRP= mail
+BINMODE=2555
+WARNS?=        6
+
+.include <bsd.prog.mk>
index 277b3e4e8be34cc8f3a0bfe170d70803e9832c49..b89e5bcd16f366f1c9f4129914d7e274362f1a43 100644 (file)
@@ -1,5 +1,5 @@
-Copyright (c) 2008-2014, Simon Schubert <2@0x2c.org>.
 Copyright (c) 2008 The DragonFly Project.
+Copyright (c) 2008-2011, Simon Schubert <2@0x2c.org>.
 All rights reserved.
 
 This code is derived from software contributed to The DragonFly Project
@@ -37,7 +37,7 @@ OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 SUCH DAMAGE.
 
 
-Copyright (c) 1995-2001 Kungliga Tekniska Högskolan
+Copyright (c) 1995-2001 Kungliga Tekniska Högskolan
 (Royal Institute of Technology, Stockholm, Sweden).
 All rights reserved.
 
index 3e043de33df9ed8000efd26aa3fb6453c98f64c4..13ff20c9aa417308ad607e217372164b06550a98 100644 (file)
@@ -15,13 +15,8 @@ incoming connections.
 Building
 --------
 
-In Linux:
-
        make
 
-In BSD:
-
-       cd bsd && make
 
 Installation
 ------------
index e70814cf61272f11abc4a8646646d48c0d527401..01de465d66af19078b40534820d1d2e34de2f92b 100644 (file)
@@ -1,4 +1,5 @@
 - unquote/handle quoted local recipients
+- use proper sysexit codes
 - handle/use ESMTP extensions
 - .forward support
 - suggest way to run a queue flush on boot
index 9097bf9dbe5f4b742b02c05b9146c9afc3b7c01a..490a0cdcc1398290263f20f9f3eb38febaccf23b 100644 (file)
@@ -1 +1 @@
-v0.10
+v0.9
index 46728e6f205dd3db4b79fcd2b87ee4765d62794c..a5a9e7b32f071aa0ca3026938296dea8f8847ef8 100644 (file)
@@ -7,6 +7,8 @@
 
 extern int yylineno;
 static void yyerror(const char *);
+int yywrap(void);
+int yylex(void);
 
 static void
 yyerror(const char *msg)
index 8130c3e43098dc6a3ba7c444234764d96c9e6a64..809d1e1687310515b4f91cbb06b8a2dbe9017eb7 100644 (file)
@@ -1,11 +1,11 @@
 %{
 
 #include <string.h>
-#include "dma.h"
 #include "aliases_parse.h"
 
 #define YY_NO_INPUT
 
+int yylex(void);
 %}
 
 %option yylineno
index 3e3c7d3d8bd2af783d196ee850451bcb2f5f09df..86d72f7bf9064908472b4c4092d52e7f75c60099 100644 (file)
@@ -64,7 +64,7 @@ trim_line(char *line)
        if (line[0] == '.') {
                if ((linelen + 2) > 1000) {
                        syslog(LOG_CRIT, "Cannot escape leading dot.  Buffer overflow");
-                       exit(EX_DATAERR);
+                       exit(1);
                }
                memmove((line + 1), line, (linelen + 1));
                line[0] = '.';
@@ -101,7 +101,7 @@ parse_authfile(const char *path)
 
        a = fopen(path, "r");
        if (a == NULL) {
-               errlog(EX_NOINPUT, "can not open auth file `%s'", path);
+               errlog(1, "can not open auth file `%s'", path);
                /* NOTREACHED */
        }
 
@@ -121,7 +121,7 @@ parse_authfile(const char *path)
 
                au = calloc(1, sizeof(*au));
                if (au == NULL)
-                       errlog(EX_OSERR, NULL);
+                       errlog(1, "calloc failed");
 
                data = strdup(line);
                au->login = strsep(&data, "|");
@@ -131,7 +131,8 @@ parse_authfile(const char *path)
                if (au->login == NULL ||
                    au->host == NULL ||
                    au->password == NULL) {
-                       errlogx(EX_CONFIG, "syntax error in authfile %s:%d", path, lineno);
+                       errlogx(1, "syntax error in authfile %s:%d",
+                               path, lineno);
                        /* NOTREACHED */
                }
 
@@ -159,7 +160,7 @@ parse_conf(const char *config_path)
                /* Don't treat a non-existing config file as error */
                if (errno == ENOENT)
                        return;
-               errlog(EX_NOINPUT, "can not open config `%s'", config_path);
+               errlog(1, "can not open config `%s'", config_path);
                /* NOTREACHED */
        }
 
@@ -210,7 +211,7 @@ parse_conf(const char *config_path)
                        } else {
                                host = data;
                        }
-                       if (host && *host == 0)
+                       if (host && *host == 0)
                                host = NULL;
                         if (user && *user == 0)
                                 user = NULL;
@@ -231,13 +232,13 @@ parse_conf(const char *config_path)
                else if (strcmp(word, "NULLCLIENT") == 0 && data == NULL)
                        config.features |= NULLCLIENT;
                else {
-                       errlogx(EX_CONFIG, "syntax error in %s:%d", config_path, lineno);
+                       errlogx(1, "syntax error in %s:%d", config_path, lineno);
                        /* NOTREACHED */
                }
        }
 
        if ((config.features & NULLCLIENT) && config.smarthost == NULL) {
-               errlogx(EX_CONFIG, "%s: NULLCLIENT requires SMARTHOST", config_path);
+               errlogx(1, "%s: NULLCLIENT requires SMARTHOST", config_path);
                /* NOTREACHED */
        }
 
diff --git a/contrib/dma/debian/NEWS b/contrib/dma/debian/NEWS
new file mode 100644 (file)
index 0000000..36ed11a
--- /dev/null
@@ -0,0 +1,29 @@
+dma (0.0.2010.06.17-3) unstable; urgency=low
+
+   The default delivery mode has been changed to immediate, as it is in
+   the upstream version of dma; the DEFER keyword is now disabled by default
+   in dma.conf.
+
+ -- Peter Pentchev <roam@ringlet.net>  Tue, 27 Jul 2010 13:26:48 +0300
+
+dma (0.0.2010.06.17-1) unstable; urgency=low
+
+   The dma spool directory format has changed.  The Debian package of dma now
+   recommends a separate package containing the dma-migrate utility; if it is
+   present, it will be invoked at each periodic dma queue flush and attempt to
+   convert the existing old-style queued messages to the new format.  In most
+   cases, this should not incur any performance penalties in normal operation,
+   since dma-migrate will scan the spool directory and ignore any new messages
+   (they should already be in the new format); however, if it appears that
+   the periodic queue flush runs take longer than usual to start up, you may
+   remove the dma-migrate package once you have ascertained that your queue
+   directory (/var/spool/dma) only contains files with names beginning with
+   the letters M or Q.
+
+   This version of dma knows how to perform MX lookups, so remote delivery is
+   now possible directly, not through a smarthost.  However, a smarthost setup
+   might still be preferred on many systems for various reasons - e.g. dynamic
+   address assignment, a central outgoing mailserver, a roaming laptop, etc.
+
+ -- Peter Pentchev <roam@ringlet.net>  Mon, 21 Jun 2010 11:03:57 +0300
+
diff --git a/contrib/dma/debian/README.Debian b/contrib/dma/debian/README.Debian
new file mode 100644 (file)
index 0000000..564aaa7
--- /dev/null
@@ -0,0 +1,12 @@
+dma for Debian
+--------------
+
+Smarthost operation by default - needs to be configured!
+
+After first installing dma, you need to configure it for proper operation -
+whether it should deliver all outgoing e-mail messages through a single
+smarthost or attempt to contact the remote mail servers directly.  This should
+be configured through the debconf questions, but you may change the setting
+using the SMARTHOST directive in the /etc/dma/dma.conf file.
+
+ -- Simon Schubert <2@0x2c.org>  Fri, 29 Oct 2010 00:25:48 +0200
diff --git a/contrib/dma/debian/changelog b/contrib/dma/debian/changelog
new file mode 100644 (file)
index 0000000..4d55300
--- /dev/null
@@ -0,0 +1,297 @@
+dma (0.9) unstable; urgency=low
+
+  [ Ed Maste ]
+  * Be explicit about missing user.
+  * Allow DMA_ROOT_USER & DMA_GROUP to be overridden.
+  * Add compat #ifdef for older OpenSSL
+  * Add CONF_DIR, as in Makefile
+  * More detailed error message for tmp file failure.
+
+  [ Simon Schubert ]
+  * spool.c: bzero contents of pointer
+
+ -- Simon Schubert <2@0x2c.org>  Mon, 03 Jun 2013 15:58:44 +0200
+
+dma (0.8) unstable; urgency=low
+
+  [ Gert van den Berg ]
+  * Added some more documentation on compiling
+  * Make Makefile and README consistent with INSTALL
+
+  [ Sascha Wildner ]
+  * dma.8: Fix a few small issues.
+
+  [ Simon Schubert ]
+  * dma.8: we only have 2 config files at the moment
+  * Merge pull request #2 from mohag/master
+  * don't treat -options following -q as argument to it
+  * deliver_remote: propagate back DNS errors
+  * don't complain when we can't lock a queue file during flush
+  * implement queue flushing prod
+
+ -- Simon Schubert <2@0x2c.org>  Fri, 30 Mar 2012 12:03:54 +0200
+
+dma (0.7) unstable; urgency=low
+
+  [ Simon Schubert ]
+  * add semicolon before date in Received: header
+  * parse_conf: fix bug with masqueraded domains
+  * clear up warnings found by clang static analysis
+  * mark printf-alike functions
+
+ -- Simon Schubert <2@0x2c.org>  Tue, 03 Jan 2012 14:53:43 +0100
+
+dma (0.6) unstable; urgency=low
+
+  [ Simon Schubert ]
+  * deliver_local: quote "From " more liberally
+
+ -- Simon Schubert <2@0x2c.org>  Wed, 07 Dec 2011 12:42:22 +0100
+
+dma (0.5) unstable; urgency=low
+
+  [ Simon Schubert ]
+  * implement masquerading using the MASQUERADE config option
+  * access config files at CONF_PATH, add makefile target to install conf files
+  * implement the "*" catch-all alias
+
+ -- Simon Schubert <2@0x2c.org>  Wed, 16 Nov 2011 13:34:43 +0100
+
+dma (0.4) unstable; urgency=low
+
+  [ Simon Schubert ]
+  * Makefile: put libraries at the end when linking
+  * LICENSE: add
+  * Merge commit 'refs/merge-requests/3' of git://gitorious.org/dma/dma
+  * Merge commit 'refs/merge-requests/4' of git://gitorious.org/dma/dma
+  * Add symlink for sendmail which is expected by many packages
+  * Makefile: create spool directories in a separate target
+  * Makefile: add symlink for mailq
+  * README: elaborate, use markdown
+
+  [ Peter Pentchev ]
+  * Fix straight SSL/TLS delivery to remote MX's.
+  * Fix a minor memory leak discovered by cppcheck.
+
+ -- Simon Schubert <2@0x2c.org>  Wed, 16 Nov 2011 00:08:28 +0100
+
+dma (0.3) unstable; urgency=low
+
+  [ Simon Schubert ]
+  * todo: we create mboxes properly now
+  * dma-mbox-create: group mail only needs to write to mboxes
+  * errlog: preserve errno
+  * dma-mbox-create: add error/status logging
+  * dns_get_mx_list: handle errors properly
+
+  [ Peter Pentchev ]
+  * Make add_host() really return an error code.
+
+  [ Simon Schubert ]
+  * readmail: accept mail without newline at the end
+
+  [ Peter Pentchev ]
+  * In OpenSSL 1.0, TLSv1_client_method() returns a const pointer.
+
+  [ Simon Schubert ]
+  * make dma compile again on DragonFly
+  * parse_addrs: fix parsing for multiple <addresses>
+
+ -- Simon Schubert <2@0x2c.org>  Sat, 09 Jul 2011 02:38:05 +0200
+
+dma (0.2) unstable; urgency=low
+
+  * Update to dma 0.2
+    - debian: better mark as UNRELEASED
+    - add ppa makefile recipe
+    - TODO: suggest way to run a queue flush on boot
+    - partially adopt 34-manpage-defaults.patch: AUTHPATH is not set by default
+    - Revert "debian: better mark as UNRELEASED"
+    - setlogident: openlog() wants a static variable
+    - writequeuef: create files with g+rw
+    - drop privileges when run by root
+    - implement mbox creation via setuid helper
+    - debian: build with consistent flags
+    - debian: remove unused files
+    - debian: fix lintian warnings and errors
+    - make ppa: force lower version number
+    - make ppa: proper name
+
+ -- Simon Schubert <2@0x2c.org>  Sun, 31 Oct 2010 23:57:50 +0100
+
+dma (0.1) unstable; urgency=low
+
+  * Update dma to 0.1
+
+ -- Simon Schubert <2@0x2c.org>  Fri, 29 Oct 2010 00:57:26 +0200
+
+dma (0.0.2010.06.17-6) unstable; urgency=low
+
+  * Add the 37-gnu-hurd patch to really fix the FTBFS on GNU/Hurd.
+  * Convert several shell output assignments from = to :=
+  * Switch to bzip2 compression for the Debian tarball.
+
+ -- Peter Pentchev <roam@ringlet.net>  Sun, 17 Oct 2010 00:08:33 +0300
+
+dma (0.0.2010.06.17-5) unstable; urgency=low
+
+  * Only use SA_NOCLDWAIT if available to fix the Hurd FTBFS.
+
+ -- Peter Pentchev <roam@ringlet.net>  Thu, 07 Oct 2010 11:42:23 +0300
+
+dma (0.0.2010.06.17-4) unstable; urgency=low
+
+  * Fix an infinite loop in dma-migrate if char is unsigned.
+    Closes: #599172
+  * Switch to Git and point the Vcs-* fields to Gitorious.
+
+ -- Peter Pentchev <roam@ringlet.net>  Wed, 06 Oct 2010 17:30:29 +0300
+
+dma (0.0.2010.06.17-3) unstable; urgency=low
+
+  * Update the debconf translations:
+    - French by Steve Petruzzello; Closes: #587883
+  * Bump Standards-Version to 3.9.1 with no changes.
+  * Disable deferred delivery by default, as in the upstream version:
+    - in the 03-debian-locations patch, comment the DEFER keyword in dma.conf,
+      as it is upstream
+    - refresh the 11-double-bounce.patch
+    - reword the README.Debian section on deferred delivery a bit
+    - add a news blurb
+
+ -- Peter Pentchev <roam@ringlet.net>  Tue, 27 Jul 2010 13:34:27 +0300
+
+dma (0.0.2010.06.17-2) unstable; urgency=low
+
+  * Quick on the heels of -1 to fix a momentary lapse of reason on my part:
+    in the 03-debian-locations patch, revert part of the 0.0.2010.06.17-1
+    change: do not set a un-overrideable default for the deferred delivery!
+    Closes: #587593
+  * Update the debconf translations:
+    - Japanese by Hideki Yamane; Closes: #587543
+
+ -- Peter Pentchev <roam@ringlet.net>  Wed, 30 Jun 2010 11:59:46 +0300
+
+dma (0.0.2010.06.17-1) unstable; urgency=low
+
+  * New upstream version:
+    - no longer reports the remote port number; Closes: #544820
+    - fixes some queue locking problems; Closes: #582593
+    - adapt the rules file to use the GNU Makefile instead of the BSD one
+    - drop pmake from Build-Depends
+    - remove the 01-debian-build patch, overtaken by upstream changes
+    - in the 03-debian-locations patch, make the Debian defaults actual
+      defaults for the dma binary, not just in the dma.conf file
+    - adapt the 04-debian-setgid patch for the GNU Makefile
+    - in the 10-liblockfile patch, change the GNU Makefile, too
+    - enhance the 11-double-bounce patch a bit:
+      - use dma's own delqueue() function instead of a naive unlink() so
+        all the queue files are cleaned up
+      - document the Debian default for DBOUNCEPROG in the manual page
+    - resurrect the 13-hardening patch, correcting a couple of
+      unchecked asprintf(3) and vasprintf(3) invocations
+    - the functionality of the 20-parse-recipient patch was implemented
+      upstream in a different way, so replace it with a small bugfix
+    - remove the 22-openfiles patch, overtaken by upstream changes
+    - in the 24-random-message-id patch, change the GNU Makefile, too
+    - add the 27-int-size patch to cast a variable to the correct type
+    - add the 28-valid-recipient patch to fix parsing recipients out of
+      the message body
+    - add the 29-double-free patch to fix a double-free error
+    - add the 30-ldflags patch to honor LDFLAGS if specified
+    - refresh the 09-typos, 17-mailname, 23-dirent-d_type, and
+      25-unsupported-starttls patches
+    - teach the dbounce-simple-safecat handler about the M*/Q* spool
+      files scheme
+  * Bump Standards-Version to 3.9.0 with no changes.
+  * Update the copyright file:
+    - bring it up to the latest revision of the DEP 5
+    - update the upstream copyright notices
+    - bump the year on my copyright notice
+  * Remove the diffsrc rules target which was intended for my own
+    internal use, but has outlived its time.
+  * Use dpkg-buildflags from dpkg-dev >= 1.15.7~ to get the default
+    values for CFLAGS, CPPFLAGS, and LDFLAGS; no longer rely on
+    dpkg-buildpackage to set them by default.
+  * Add the dma-migrate utility (in a separate binary package) to convert
+    spool files to the new queue format (M* and Q* files for each message)
+  * Add a dma-migrate invocation to dma.cron.d
+  * Shorten the Vcs-Browser URL.
+  * Add the 31-sigalrm-backoff patch to force a delivery attempt on SIGALRM.
+  * Properly substitute the debconf-supplied values for DBOUNCEPROG and
+    SMARTHOST into dma.conf even if they are empty without generating
+    an invalid dma.conf file.
+  * Remove the smarthost default; dma does MX lookups now, so it doesn't
+    really *need* one anymore.
+  * Reword the debconf relayhost question - dma does not really need
+    a smarthost anymore.
+  * Update the debconf translations:
+    - Bulgarian
+    - Portuguese by Américo Monteiro
+    - German by Helge Kreutzmann; Closes: #586531
+    - Russian by Yuri Kozlov; Closes: #586579
+    - Czech by Michal Simunek; Closes: #586791
+    - Swedish by Martin Bagge; Closes: #586825
+    - Spanish by Francisco Javier Cuadrado; Closes: #587088
+  * Update the smarthost configuration information in README.Debian.
+  * Add the 32-comment-uncomment patch to correct the manual page wording.
+  * Add the 33-opportunistic-tls patch to allow remote connections to proceed
+    even if the STARTTLS negotiation fails.
+  * Fix the 25-unsupported-starttls patch to actually error out if the SSL
+    negotiation fails.
+  * Forward all the non-Debian-specific patches upstream to Simon Schubert.
+  * Add the 34-manpage-defaults patch to properly document what dma will use
+    as default values if not specified in the config file instead of what
+    the default config file specifies.  Closes: #544748
+  * Add the 35-delivery-retry patch to try local deliveries a bit more often
+    and to randomize the delivery timeout to avoid locking issues.
+
+ -- Peter Pentchev <roam@ringlet.net>  Mon, 28 Jun 2010 23:26:36 +0300
+
+dma (0.0.2009.07.17-3) unstable; urgency=low
+
+  * Really install the files in /etc/dma/ as root/mail/640 and
+    change the ownership of the existing files in the postinst script
+    when upgrading from older versions.  Closes: #544664
+  * Install the /usr/bin/mailq and /usr/bin/newaliases symlinks.
+    Closes: #558421
+  * Switch to the 3.0 (quilt) source format.
+  * Update the debconf translations:
+    - add German.  Closes: #552754
+    - add Japanese.  Closes: #554515
+    - remove a double space and unfuzzy the translations.  Closes: #552586
+  * Fix a crash when the SMTP server does not support STARTTLS.
+    Closes: #547594
+  * Always use the user-supplied value from the debconf query for
+    the smarthost and the double-bounce program.  This may result in
+    debconf overriding a manually-edited config file, so add a note to
+    dma.conf stating that these values are handled via debconf.
+    Closes: #544663
+  * Fix a misspelling of dma/dbounceprog as dma/defer in the debconf
+    configuration script.  Oops.
+
+ -- Peter Pentchev <roam@ringlet.net>  Sat, 19 Dec 2009 14:35:10 +0200
+
+dma (0.0.2009.07.17-2) unstable; urgency=low
+
+  * Allow the spool directory to live on a filesystem that does not
+    set the d_type member of the dirent structure, like XFS.
+    Closes: #544357
+  * Randomize the Message-Id a bit more.  Closes: #544475
+  * Bump Standards-Version to 3.8.3 with no changes.
+  * Only enable the build hardening wrapper if the "hardening" build
+    option is specified.
+  * Switch the copyright file header from the Wiki to DEP 5.
+  * Remove the manual page ".Dx" patch - the groff version in Squeeze
+    knows about the .Dx mdoc macro.  Add a lintian override for
+    the "Unknown DragonFly version" error.
+  * Convert the patch file headers to the DEP 3 format.
+
+ -- Peter Pentchev <roam@ringlet.net>  Tue, 01 Sep 2009 13:36:33 +0300
+
+dma (0.0.2009.07.17-1) unstable; urgency=low
+
+  * Initial release
+    (Closes: #511410, #533458, #533614, #533890, #534101, #534860)
+
+ -- Peter Pentchev <roam@ringlet.net>  Tue, 11 Aug 2009 16:08:41 +0300
diff --git a/contrib/dma/debian/compat b/contrib/dma/debian/compat
new file mode 100644 (file)
index 0000000..7f8f011
--- /dev/null
@@ -0,0 +1 @@
+7
diff --git a/contrib/dma/debian/control b/contrib/dma/debian/control
new file mode 100644 (file)
index 0000000..6eeea08
--- /dev/null
@@ -0,0 +1,37 @@
+Source: dma
+Section: mail
+Priority: optional
+Maintainer: Peter Pentchev <roam@ringlet.net>
+DM-Upload-Allowed: yes
+Build-Depends: debhelper (>= 7.0.50), byacc, dpkg-dev (>= 1.15.7~), flex, hardening-wrapper, libssl-dev, po-debconf
+Standards-Version: 3.9.1
+Homepage: http://devel.ringlet.net/mail/dma/
+Vcs-Git: git://gitorious.org/dma-roam/pkg-debian.git
+Vcs-Browser: http://gitorious.org/dma-roam/pkg-debian
+
+Package: dma
+Architecture: any
+Depends: ${shlibs:Depends}, ${misc:Depends}
+Provides: mail-transport-agent
+Conflicts: mail-transport-agent
+Replaces: mail-transport-agent
+Recommends: dma-migrate
+Description: lightweight mail transport agent
+ The DragonFly Mail Agent is a small Mail Transport Agent (MTA),
+ designed for home and office use.  It accepts mails from local Mail
+ User Agents (MUA) and delivers them either to local mailboxes or
+ remote SMTP servers.  Remote delivery includes support for features
+ such as TLS/SSL and SMTP authentication.
+ .
+ dma is not intended as a replacement for full-featured MTAs like
+ Sendmail, Postfix, or Exim.  Consequently, dma does not listen on
+ port 25 for incoming connections.
+
+Package: dma-migrate
+Architecture: any
+Depends: ${shlibs:Depends}, ${misc:Depends}
+Enhances: dma
+Description: migration utility for the DragonFly Mail Agent's spool files
+ The dma-migrate utility examines the DragonFly Mail Agent's mail queue
+ and performs any conversions from old message file formats to the most
+ recent one as needed.
diff --git a/contrib/dma/debian/copyright b/contrib/dma/debian/copyright
new file mode 100644 (file)
index 0000000..4ad8fbb
--- /dev/null
@@ -0,0 +1,91 @@
+Format-Specification: http://svn.debian.org/wsvn/dep/web/deps/dep5.mdwn?op=file&rev=135
+Name: dma
+
+Files: base64.c
+Copyright: Copyright (c) 1995-2001 Kungliga Tekniska Högskolan
+ (Royal Institute of Technology, Stockholm, Sweden).
+ All rights reserved.
+License: BSD-3
+
+Files: conf.c crypto.c net.c
+Copyright: Copyright (c) 2008 The DragonFly Project.  All rights reserved.
+  This code is derived from software contributed to The DragonFly Project
+  by Matthias Schmidt <matthias@dragonflybsd.org>, University of Marburg,
+  Germany.
+License: BSD-3
+
+Files: dfcompat.c
+Copyright: Copyright (c) 1998 Todd C. Miller <Todd.Miller@courtesan.com>
+ Copyright (c) 1998, M. Warner Losh <imp@freebsd.org>  All rights reserved.
+License: BSD-1 BSD-2
+
+Files: dma.8
+Copyright: Copyright (c) 2008 The DragonFly Project.  All rights reserved.
+License: BSD-3
+
+Files: dma.c dns.c mail.c spool.c util.c
+Copyright: Copyright (c) 2008 The DragonFly Project.  All rights reserved.
+  This code is derived from software contributed to The DragonFly Project
+  by Simon 'corecode' Schubert <corecode@fs.ei.tum.de>.
+License: BSD-3
+
+Files: dma.h
+Copyright: Copyright (c) 2008 The DragonFly Project.  All rights reserved.
+  This code is derived from software contributed to The DragonFly Project
+  by Simon 'corecode' Schubert <corecode@fs.ei.tum.de> and
+  Matthias Schmidt <matthias@dragonflybsd.org>.
+License: BSD-3
+
+Files: debian/*
+Copyright: Copyright (c) 2009, 2010 Peter Pentchev.
+License: BSD-3
+
+License: BSD-3
+  Redistribution and use in source and binary forms, with or without
+  modification, are permitted provided that the following conditions
+  are met:
+  .
+  1. Redistributions of source code must retain the above copyright
+     notice, this list of conditions and the following disclaimer.
+  2. Redistributions in binary form must reproduce the above copyright
+     notice, this list of conditions and the following disclaimer in
+     the documentation and/or other materials provided with the
+     distribution.
+  3. Neither the name of The DragonFly Project nor the names of its
+     contributors may be used to endorse or promote products derived
+     from this software without specific, prior written permission.
+
+License: BSD-1
+  Permission to use, copy, modify, and distribute this software for any
+  purpose with or without fee is hereby granted, provided that the above
+  copyright notice and this permission notice appear in all copies.
+  .
+  THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+  WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+  MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+  ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+  WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+  ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+  OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+
+License: BSD-2
+  Redistribution and use in source and binary forms, with or without
+  modification, are permitted provided that the following conditions
+  are met:
+  1. Redistributions of source code must retain the above copyright
+     notice, this list of conditions and the following disclaimer.
+  2. Redistributions in binary form must reproduce the above copyright
+     notice, this list of conditions and the following disclaimer in the
+     documentation and/or other materials provided with the distribution.
+  .
+  THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+  ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+  IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+  ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+  FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+  DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+  OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+  HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+  LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+  OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+  SUCH DAMAGE.
diff --git a/contrib/dma/debian/dma-migrate.dirs b/contrib/dma/debian/dma-migrate.dirs
new file mode 100644 (file)
index 0000000..b174b44
--- /dev/null
@@ -0,0 +1,2 @@
+usr/sbin
+usr/share/man/man8
diff --git a/contrib/dma/debian/dma-migrate.install b/contrib/dma/debian/dma-migrate.install
new file mode 100644 (file)
index 0000000..1c35b0a
--- /dev/null
@@ -0,0 +1 @@
+debian/migrate/dma-migrate usr/sbin
diff --git a/contrib/dma/debian/dma-migrate.manpages b/contrib/dma/debian/dma-migrate.manpages
new file mode 100644 (file)
index 0000000..3629dbe
--- /dev/null
@@ -0,0 +1 @@
+debian/migrate/dma-migrate.8
diff --git a/contrib/dma/debian/dma.dirs b/contrib/dma/debian/dma.dirs
new file mode 100644 (file)
index 0000000..f10c005
--- /dev/null
@@ -0,0 +1,4 @@
+etc/dma
+usr/sbin
+usr/share/lintian/overrides
+usr/share/man/man8
diff --git a/contrib/dma/debian/dma.links b/contrib/dma/debian/dma.links
new file mode 100644 (file)
index 0000000..d9ac22a
--- /dev/null
@@ -0,0 +1,6 @@
+usr/sbin/dma usr/bin/mailq
+usr/sbin/dma usr/bin/newaliases
+usr/sbin/dma usr/sbin/sendmail
+usr/share/man/man8/dma.8 usr/share/man/man8/mailq.8
+usr/share/man/man8/dma.8 usr/share/man/man8/newaliases.8
+usr/share/man/man8/dma.8 usr/share/man/man8/sendmail.8
diff --git a/contrib/dma/debian/dma.lintian-overrides b/contrib/dma/debian/dma.lintian-overrides
new file mode 100644 (file)
index 0000000..03f5d6e
--- /dev/null
@@ -0,0 +1,8 @@
+dma: manpage-has-errors-from-man *Unknown DragonFly version*
+dma: non-standard-dir-in-var var/mail/
+dma: non-standard-dir-perm var/spool/dma/ 0770 != 0755
+dma: non-standard-dir-perm var/spool/dma/ 2775 != 0755
+dma: non-standard-file-perm etc/dma/auth.conf 0640 != 0644
+dma: no-upstream-changelog
+dma: setgid-binary usr/sbin/dma 2755 root/mail
+dma: setuid-binary usr/lib/dma-mbox-create 4754 root/mail
diff --git a/contrib/dma/debian/migrate/Makefile b/contrib/dma/debian/migrate/Makefile
new file mode 100644 (file)
index 0000000..cc7d347
--- /dev/null
@@ -0,0 +1,4 @@
+all:   dma-migrate
+
+clean:
+       rm -f dma-migrate dma-migrate.o
diff --git a/contrib/dma/debian/migrate/NEWS b/contrib/dma/debian/migrate/NEWS
new file mode 100644 (file)
index 0000000..29dca0d
--- /dev/null
@@ -0,0 +1,6 @@
+Change log for dma-migrate, the DragonFly Mail Agent queue migration utility.
+
+0.01   not yet ;)
+       - first public release
+
+Comments: Peter Pentchev <roam@ringlet.net>
diff --git a/contrib/dma/debian/migrate/dma-migrate.8 b/contrib/dma/debian/migrate/dma-migrate.8
new file mode 100644 (file)
index 0000000..e40acef
--- /dev/null
@@ -0,0 +1,98 @@
+.\" Copyright (c) 2010  Peter Pentchev
+.\" All rights reserved.
+.\"
+.\" Redistribution and use in source and binary forms, with or without
+.\" modification, are permitted provided that the following conditions
+.\" are met:
+.\" 1. Redistributions of source code must retain the above copyright
+.\"    notice, this list of conditions and the following disclaimer.
+.\" 2. Redistributions in binary form must reproduce the above copyright
+.\"    notice, this list of conditions and the following disclaimer in the
+.\"    documentation and/or other materials provided with the distribution.
+.\"
+.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+.\" SUCH DAMAGE.
+.\"
+.Dd May 11, 2009
+.Dt dma-migrate 8
+.Os
+.Sh NAME
+.Nm dma-migrate
+.Nd convert the DragonFly Mail Agent's queue files
+.Sh SYNOPSIS
+.Nm
+.Op Fl v
+.Op Fl d Ar spooldir
+.Nm
+.Op Fl h | Fl V
+.Sh DESCRIPTION
+The
+.Nm
+utility is used to convert the mail queue files in the
+.Xr dma 8
+spool directory to the latest spool directory format supported by
+the installed version of
+.Xr dma 8 .
+Currently it only handles the conversion from a single file containing
+both message and delivery metadata to the M/Q format.
+.Pp
+The following command-line options are available:
+.Bl -tag -width indent
+.It Fl d
+Specify the location of the
+.Xr dma 8
+spool directory, default
+.Pa /var/spool/dma .
+.It Fl h
+Display usage information and exit.
+.It Fl V
+Display program version information and exit.
+.It Fl v
+Verbose output - display diagnostic messages.
+.El
+.Sh ENVIRONMENT
+The operation of the
+.Nm
+utility is currently not influenced by environment variables.
+.Sh FILES
+The
+.Nm
+utility looks for the
+.Xr dma 8
+mail queue files in the
+.Pa /var/spool/dma
+directory, unless another location is specified by the
+.Fl d
+command-line option.
+.Sh EXIT STATUS
+The
+.Nm
+utility will scan the whole spool directory and attempt to convert all
+suitable files there.
+If there are no files to be converted, or if all the conversions are
+successful, it will complete with an exit code of zero.
+If any conversion errors are encountered, a message will be displayed
+to the standard error stream and
+.Nm
+will exit with an exit code of 1 after attempting to convert the rest of
+the suitable files in the spool directory.
+.Sh SEE ALSO
+.Xr dma 8
+.Sh STANDARDS
+No standards documentation was harmed in the process of creating
+.Nm .
+.Sh BUGS
+Please report any bugs in
+.Nm
+to the author.
+.Sh AUTHOR
+.An Peter Pentchev Aq roam@ringlet.net
diff --git a/contrib/dma/debian/migrate/dma-migrate.c b/contrib/dma/debian/migrate/dma-migrate.c
new file mode 100644 (file)
index 0000000..56bfa2a
--- /dev/null
@@ -0,0 +1,413 @@
+/*-
+ * Copyright (c) 2010  Peter Pentchev
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#define _GNU_SOURCE
+
+#include <sys/types.h>
+#include <sys/file.h>
+#include <sys/stat.h>
+
+#include <dirent.h>
+#include <err.h>
+#include <errno.h>
+#include <fcntl.h>
+#include <inttypes.h>
+#include <regex.h>
+#include <stdarg.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <time.h>
+#include <unistd.h>
+
+#ifndef __printflike
+#ifdef __GNUC__
+#define __printflike(fmtarg, firstvararg)      \
+       __attribute__((__format__ (__printf__, fmtarg, firstvararg)))
+#else
+#define __printflike(fmtarg, firstvararg)
+#endif
+#endif
+
+#define DEFAULT_SPOOLDIR       "/var/spool/dma"
+
+static int      verbose = 0;
+static char     copybuf[BUFSIZ];
+
+static int      dma_migrate(int, const char *);
+
+static int      open_locked(const char *, int, ...);
+static void     cleanup_file(int, char *);
+
+static void     usage(int);
+static void     version(void);
+static void     debug(const char *, ...) __printflike(1, 2);
+
+int
+main(int argc, char **argv)
+{
+       const char *spooldir;
+       int hflag, Vflag, errs, fd, res;
+       int ch;
+       DIR *d;
+       struct dirent *e;
+       struct stat sb;
+
+        srandom((unsigned long)((time(NULL) ^ getpid()) + ((uintptr_t)argv)));
+
+       hflag = Vflag = 0;
+       spooldir = DEFAULT_SPOOLDIR;
+       while (ch = getopt(argc, argv, "d:hVv"), ch != -1)
+               switch (ch) {
+                       case 'd':
+                               spooldir = optarg;
+                               break;
+
+                       case 'h':
+                               hflag = 1;
+                               break;
+
+                       case 'V':
+                               Vflag = 1;
+                               break;
+
+                       case 'v':
+                               verbose = 1;
+                               break;
+
+                       case '?':
+                       default:
+                               usage(1);
+                               /* NOTREACHED */
+               }
+       if (Vflag)
+               version();
+       if (hflag)
+               usage(0);
+       if (hflag || Vflag)
+               exit(0);
+
+       argc -= optind;
+       argv += optind;
+
+       /* Let's roll! */
+       if (chdir(spooldir) == -1)
+               err(1, "Could not change into spool directory %s", spooldir);
+       if (d = opendir("."), d == NULL)
+               err(1, "Could not read spool directory %s", spooldir);
+       errs = 0;
+       while (e = readdir(d), e != NULL) {
+               /* Do we care about this entry? */
+               debug("Read a directory entry: %s\n", e->d_name);
+               if (strncmp(e->d_name, "tmp_", 4) == 0 ||
+                   e->d_name[0] == 'M' || e->d_name[0] == 'Q' ||
+                   (e->d_type != DT_REG && e->d_type != DT_UNKNOWN))
+                       continue;
+               if (e->d_type == DT_UNKNOWN)
+                       if (stat(e->d_name, &sb) == -1 || !S_ISREG(sb.st_mode))
+                               continue;
+               debug("- want to process it\n");
+
+               /* Try to lock it - skip it if dma is delivering the message */
+               if (fd = open_locked(e->d_name, O_RDONLY|O_NDELAY), fd == -1) {
+                       debug("- seems to be locked, skipping\n");
+                       continue;
+               }
+
+               /* Okay, convert it to the M/Q schema */
+               res = dma_migrate(fd, e->d_name);
+               close(fd);
+               if (res == -1)
+                       errs++;
+       }
+       if (errs)
+               debug("Finished, %d conversion errors\n", errs);
+       else
+               debug("Everything seems to be all right\n");
+       return (errs && 1);
+}
+
+static int
+dma_migrate(int fd, const char *fname)
+{
+       const char *id;
+       char *mname, *qname, *tempname, *sender, *recp, *line, *recpline;
+       int mfd, qfd, tempfd;
+       struct stat sb;
+       FILE *fp, *qfp, *mfp;
+       size_t sz, len;
+       static regex_t *qidreg = NULL;
+
+       mfd = tempfd = qfd = -1;
+       mname = qname = sender = recp = line = NULL;
+       fp = qfp = NULL;
+
+       if (fstat(fd, &sb) == -1) {
+               warn("Could not fstat(%s)", fname);
+               return (-1);
+       }
+       /*
+        * Let's just blithely assume that the queue ID *is* the filename,
+        * since that's the way dma did things so far.
+        * Well, okay, let's check it.
+        */
+       if (qidreg == NULL) {
+               regex_t *nreg;
+
+               if ((nreg = malloc(sizeof(*qidreg))) == NULL) {
+                       warn("Could not allocate memory for a regex");
+                       return (-1);
+               }
+               if (regcomp(nreg, "^[a-fA-F0-9]\\+\\.[a-fA-F0-9]\\+$", 0)
+                   != 0) {
+                       warnx("Could not compile a dma queue ID regex");
+                       free(nreg);
+                       return (-1);
+               }
+               qidreg = nreg;
+       }
+       if (regexec(qidreg, fname, 0, NULL, 0) != 0) {
+               warnx("The name '%s' is not a valid dma queue ID", fname);
+               return (-1);
+       }
+       id = fname;
+       debug("  - queue ID %s\n", id);
+       if (asprintf(&mname, "M%s", id) == -1 ||
+           asprintf(&tempname, "tmp_%s", id) == -1 ||
+           asprintf(&qname, "Q%s", id) == -1 ||
+           mname == NULL || tempname == NULL || qname == NULL)
+               goto fail;
+
+       /* Create the message placeholder early to avoid races */
+       mfd = open_locked(mname, O_CREAT | O_EXCL | O_RDWR, 0600);
+       if (mfd == -1) {
+               warn("Could not create temporary file %s", mname);
+               goto fail;
+       }
+       if (stat(qname, &sb) != -1 || errno != ENOENT ||
+           stat(tempname, &sb) != -1 || errno != ENOENT) {
+               warnx("Some of the queue files for %s already exist", fname);
+               goto fail;
+       }
+       debug("  - mfd %d names %s, %s, %s\n", mfd, mname, tempname, qname);
+
+       fp = fdopen(fd, "r");
+       if (fp == NULL) {
+               warn("Could not reopen the descriptor for %s", fname);
+               goto fail;
+       }
+
+       /* Parse the header of the old-format message file */
+       /* ...sender... */
+       if (getline(&sender, &sz, fp) == -1) {
+               warn("Could not read the initial line from %s", fname);
+               goto fail;
+       }
+       sz = strlen(sender);
+       while (sz > 0 && (sender[sz - 1] == '\n' || sender[sz - 1] == '\r'))
+               sender[--sz] = '\0';
+       if (sz == 0) {
+               warnx("Empty sender line in %s", fname);
+               goto fail;
+       }
+       debug("  - sender %s\n", sender);
+       /* ...recipient(s)... */
+       len = strlen(fname);
+       recpline = NULL;
+       while (1) {
+               if (getline(&line, &sz, fp) == -1) {
+                       warn("Could not read a recipient line from %s", fname);
+                       goto fail;
+               }
+               sz = strlen(line);
+               while (sz > 0 &&
+                   (line[sz - 1] == '\n' || line[sz - 1] == '\r'))
+                       line[--sz] = '\0';
+               if (sz == 0) {
+                       free(line);
+                       line = NULL;
+                       break;
+               }
+               if (recp == NULL &&
+                   strncmp(line, fname, len) == 0 && line[len] == ' ') {
+                       recp = line + len + 1;
+                       recpline = line;
+               } else {
+                       free(line);
+               }
+               line = NULL;
+       }
+       if (recp == NULL) {
+               warnx("Could not find its own recipient line in %s", fname);
+               goto fail;
+       }
+       /* ..phew, finished with the header. */
+
+       tempfd = open_locked(tempname, O_CREAT | O_EXCL | O_RDWR, 0600);
+       if (tempfd == -1) {
+               warn("Could not create a queue file for %s", fname);
+               goto fail;
+       }
+       qfp = fdopen(tempfd, "w");
+       if (qfp == NULL) {
+               warn("Could not fdopen(%s) for %s", tempname, fname);
+               goto fail;
+       }
+       mfp = fdopen(mfd, "w");
+       if (mfp == NULL) {
+               warn("Could not fdopen(%s) for %s", mname, fname);
+               goto fail;
+       }
+       fprintf(qfp, "ID: %s\nSender: %s\nRecipient: %s\n", id, sender, recp);
+       fflush(qfp);
+       fsync(tempfd);
+
+       /* Copy the message file over to mname */
+       while ((sz = fread(copybuf, 1, sizeof(copybuf), fp)) > 0)
+               if (fwrite(copybuf, 1, sz, mfp) != sz) {
+                       warn("Could not copy the message from %s to %s",
+                           fname, mname);
+                       goto fail;
+               }
+       if (ferror(fp)) {
+               warn("Could not read the full message from %s", fname);
+               goto fail;
+       }
+       fflush(mfp);
+       fsync(mfd);
+
+       if (rename(tempname, qname) == -1) {
+               warn("Could not rename the queue file for %s", fname);
+               goto fail;
+       }
+       qfd = tempfd;
+       tempfd = -1;
+       if (unlink(fname) == -1) {
+               warn("Could not remove the old converted file %s", fname);
+               goto fail;
+       }
+
+       fclose(fp);
+       fclose(qfp);
+       free(sender);
+       free(line);
+       free(recpline);
+       free(mname);
+       free(qname);
+       free(tempname);
+       return (0);
+
+fail:
+       if (fp != NULL)
+               fclose(fp);
+       if (qfp != NULL)
+               fclose(qfp);
+       if (sender != NULL)
+               free(sender);
+       if (line != NULL)
+               free(line);
+       if (recpline != NULL)
+               free(recpline);
+       cleanup_file(mfd, mname);
+       cleanup_file(qfd, qname);
+       cleanup_file(tempfd, tempname);
+       return (-1);
+}
+
+static void
+cleanup_file(int fd, char *fname)
+{
+       if (fd != -1) {
+               close(fd);
+               unlink(fname);
+       }
+       if (fname != NULL)
+               free(fname);
+}
+
+static void
+usage(int ferr)
+{
+       const char *s =
+           "Usage:\tdma-migrate [-hVv] [-d spooldir]\n"
+           "\t-d\tspecify the spool directory (" DEFAULT_SPOOLDIR ")\n"
+           "\t-h\tdisplay program usage information and exit\n"
+           "\t-V\tdisplay program version information and exit\n"
+           "\t-v\tverbose operation - display diagnostic messages";
+
+       if (ferr)
+               errx(1, "%s", s);
+       puts(s);
+}
+
+static void
+version(void)
+{
+       printf("dma-migrate 0.01 (dma 0.0.2010.06.17)\n");
+}
+
+static void
+debug(const char *fmt, ...)
+{
+       va_list v;
+
+       if (verbose < 1)
+               return;
+       va_start(v, fmt);
+       vfprintf(stderr, fmt, v);
+       va_end(v);
+}
+
+static int
+open_locked(const char *fname, int flags, ...)
+{
+       int mode = 0;
+#ifndef O_EXLOCK
+       int fd, save_errno;
+#endif
+
+       if (flags & O_CREAT) {
+               va_list ap;
+               va_start(ap, flags);
+               mode = va_arg(ap, int);
+               va_end(ap);
+       }
+
+#ifndef O_EXLOCK
+       fd = open(fname, flags, mode);
+       if (fd < 0)
+               return(fd);
+       if (flock(fd, LOCK_EX|((flags & O_NONBLOCK)? LOCK_NB: 0)) < 0) {
+               save_errno = errno;
+               close(fd);
+               errno = save_errno;
+               return(-1);
+       }
+       return(fd);
+#else
+       return(open(fname, flags|O_EXLOCK, mode));
+#endif
+}
diff --git a/contrib/dma/debian/rules b/contrib/dma/debian/rules
new file mode 100755 (executable)
index 0000000..461a0a8
--- /dev/null
@@ -0,0 +1,49 @@
+#!/usr/bin/make -f
+# -*- makefile -*-
+# Debian build rules for dma, the DragonFly mail agent
+
+DDIR=          $(CURDIR)/debian
+D=             $(DDIR)/dma
+
+BUILDDEFS=     DESTDIR=$D PREFIX=/usr
+
+CFLAGS:=       $(shell dpkg-buildflags --get CFLAGS)
+CPPFLAGS:=     $(shell dpkg-buildflags --get CPPFLAGS)
+LDFLAGS:=      $(shell dpkg-buildflags --get LDFLAGS)
+
+CONFFILES=     dma.conf auth.conf
+
+ifneq (,$(filter werror,$(DEB_BUILD_OPTIONS)))
+       CFLAGS+=        -Werror
+endif
+ifneq (,$(filter nostrip,$(DEB_BUILD_OPTIONS)))
+       export STRIPFLAG=
+endif
+ifneq (,$(filter hardening,$(DEB_BUILD_OPTIONS)))
+export DEB_BUILD_HARDENING=1
+else
+export DEB_BUILD_HARDENING=0
+endif
+
+export CFLAGS CPPFLAGS LDFLAGS
+
+override_dh_auto_build:
+       $(MAKE) -f Makefile ${BUILDDEFS}
+       $(MAKE) -C $(DDIR)/migrate
+
+override_dh_auto_clean:
+       $(MAKE) -f Makefile clean
+       $(MAKE) -C $(DDIR)/migrate clean
+
+override_dh_auto_install:
+       $(MAKE) -f Makefile ${BUILDDEFS} install sendmail-link mailq-link install-spool-dirs install-etc
+
+override_dh_fixperms:
+       dh_fixperms -Xusr/sbin/dma -Xusr/lib/dma-mbox-create -Xvar/spool/dma -Xetc/dma
+
+override_dh_installchangelogs:
+       dh_installchangelogs -p dma
+       dh_installchangelogs -p dma-migrate debian/migrate/NEWS
+
+%:
+       dh $@
diff --git a/contrib/dma/debian/source/format b/contrib/dma/debian/source/format
new file mode 100644 (file)
index 0000000..89ae9db
--- /dev/null
@@ -0,0 +1 @@
+3.0 (native)
diff --git a/contrib/dma/debian/source/options b/contrib/dma/debian/source/options
new file mode 100644 (file)
index 0000000..779dbfd
--- /dev/null
@@ -0,0 +1,2 @@
+compression = "bzip2"
+compression-level = 9
index 532a7afbe0b53b43bf23515b4de8deec66ed367e..c84652b74d47afa6347b6a53a5bbc965d60a00ba 100644 (file)
@@ -1,9 +1,9 @@
 /*
- * Copyright (c) 2010-2014, Simon Schubert <2@0x2c.org>.
+ * Copyright (c) 2010 Simon Schubert <2@0x2c.org>
  * Copyright (c) 2008 The DragonFly Project.  All rights reserved.
  *
  * This code is derived from software contributed to The DragonFly Project
- * by Simon Schubert <2@0x2c.org>.
+ * by Simon 'corecode' Schubert <corecode@fs.ei.tum.de>.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -54,7 +54,7 @@
 
 
 static void
-logfail(int exitcode, const char *fmt, ...)
+logfail(const char *fmt, ...)
 {
        int oerrno = errno;
        va_list ap;
@@ -73,7 +73,7 @@ logfail(int exitcode, const char *fmt, ...)
        else
                syslog(LOG_ERR, errno ? "%m" : "unknown error");
 
-       exit(exitcode);
+       exit(1);
 }
 
 /*
@@ -98,21 +98,21 @@ main(int argc, char **argv)
        errno = 0;
        gr = getgrnam(DMA_GROUP);
        if (!gr)
-               logfail(EX_CONFIG, "cannot find dma group `%s'", DMA_GROUP);
+               logfail("cannot find dma group `%s'", DMA_GROUP);
 
        mail_gid = gr->gr_gid;
 
        if (setgid(mail_gid) != 0)
-               logfail(EX_NOPERM, "cannot set gid to %d (%s)", mail_gid, DMA_GROUP);
+               logfail("cannot set gid to %d (%s)", mail_gid, DMA_GROUP);
        if (getegid() != mail_gid)
-               logfail(EX_NOPERM, "cannot set gid to %d (%s), still at %d", mail_gid, DMA_GROUP, getegid());
+               logfail("cannot set gid to %d (%s), still at %d", mail_gid, DMA_GROUP, getegid());
 
        /*
         * We take exactly one argument: the username.
         */
        if (argc != 2) {
                errno = 0;
-               logfail(EX_USAGE, "no arguments");
+               logfail("no arguments");
        }
        user = argv[1];
 
@@ -121,7 +121,7 @@ main(int argc, char **argv)
        /* the username may not contain a pathname separator */
        if (strchr(user, '/')) {
                errno = 0;
-               logfail(EX_DATAERR, "path separator in username `%s'", user);
+               logfail("path separator in username `%s'", user);
                exit(1);
        }
 
@@ -129,7 +129,7 @@ main(int argc, char **argv)
        errno = 0;
        pw = getpwnam(user);
        if (!pw)
-               logfail(EX_NOUSER, "cannot find user `%s'", user);
+               logfail("cannot find user `%s'", user);
 
        user_uid = pw->pw_uid;
 
@@ -137,20 +137,20 @@ main(int argc, char **argv)
        if (error < 0 || (size_t)error >= sizeof(fn)) {
                if (error >= 0) {
                        errno = 0;
-                       logfail(EX_USAGE, "mbox path too long");
+                       logfail("mbox path too long");
                }
-               logfail(EX_CANTCREAT, "cannot build mbox path for `%s/%s'", _PATH_MAILDIR, user);
+               logfail("cannot build mbox path for `%s/%s'", _PATH_MAILDIR, user);
        }
 
        f = open(fn, O_RDONLY|O_CREAT, 0600);
        if (f < 0)
-               logfail(EX_NOINPUT, "cannt open mbox `%s'", fn);
+               logfail("cannot open mbox `%s'", fn);
 
        if (fchown(f, user_uid, mail_gid))
-               logfail(EX_OSERR, "cannot change owner of mbox `%s'", fn);
+               logfail("cannot change owner of mbox `%s'", fn);
 
        if (fchmod(f, 0620))
-               logfail(EX_OSERR, "cannot change permissions of mbox `%s'", fn);
+               logfail("cannot change permissions of mbox `%s'", fn);
 
        /* file should be present with the right owner and permissions */
 
index 76ab174fe590061454e91454bcc09816460f8412..5d786c6be2caf9b1bc02ce524ea7ca0e8ae205fe 100644 (file)
@@ -1,5 +1,4 @@
 .\"
-.\" Copyright (c) 2008-2014, Simon Schubert <2@0x2c.org>.
 .\" Copyright (c) 2008
 .\"    The DragonFly Project.  All rights reserved.
 .\"
index 0d1dba2af32de9be8f0be1f1ea953b595b38e109..a3a62c9bac407d2860374a14d3dfa9661327ca55 100644 (file)
@@ -1,9 +1,8 @@
 /*
- * Copyright (c) 2008-2014, Simon Schubert <2@0x2c.org>.
  * Copyright (c) 2008 The DragonFly Project.  All rights reserved.
  *
  * This code is derived from software contributed to The DragonFly Project
- * by Simon Schubert <2@0x2c.org>.
+ * by Simon 'corecode' Schubert <corecode@fs.ei.tum.de>.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -248,7 +247,7 @@ go_background(struct queue *queue)
 
        if (daemonize && daemon(0, 0) != 0) {
                syslog(LOG_ERR, "can not daemonize: %m");
-               exit(EX_OSERR);
+               exit(1);
        }
        daemonize = 0;
 
@@ -265,7 +264,7 @@ go_background(struct queue *queue)
                switch (pid) {
                case -1:
                        syslog(LOG_ERR, "can not fork: %m");
-                       exit(EX_OSERR);
+                       exit(1);
                        break;
 
                case 0:
@@ -287,11 +286,11 @@ retit:
                                break;
                        case 1:
                                if (doqueue)
-                                       exit(EX_OK);
+                                       exit(0);
                                syslog(LOG_WARNING, "could not lock queue file");
-                               exit(EX_SOFTWARE);
+                               exit(1);
                        default:
-                               exit(EX_SOFTWARE);
+                               exit(1);
                        }
                        dropspool(queue, it);
                        return (it);
@@ -307,7 +306,7 @@ retit:
        }
 
        syslog(LOG_CRIT, "reached dead code");
-       exit(EX_SOFTWARE);
+       exit(1);
 }
 
 static void
@@ -332,12 +331,12 @@ retry:
        case 0:
                delqueue(it);
                syslog(LOG_INFO, "delivery successful");
-               exit(EX_OK);
+               exit(0);
 
        case 1:
                if (stat(it->queuefn, &st) != 0) {
                        syslog(LOG_ERR, "lost queue file `%s'", it->queuefn);
-                       exit(EX_SOFTWARE);
+                       exit(1);
                }
                if (gettimeofday(&now, NULL) == 0 &&
                    (now.tv_sec - st.st_mtim.tv_sec > MAX_TIMEOUT)) {
@@ -439,16 +438,16 @@ main(int argc, char **argv)
                pw = getpwnam(DMA_ROOT_USER);
                if (pw == NULL) {
                        if (errno == 0)
-                               errx(EX_CONFIG, "user '%s' not found", DMA_ROOT_USER);
+                               errx(1, "user '%s' not found", DMA_ROOT_USER);
                        else
-                               err(EX_OSERR, "cannot drop root privileges");
+                               err(1, "cannot drop root privileges");
                }
 
                if (setuid(pw->pw_uid) != 0)
-                       err(EX_OSERR, "cannot drop root privileges");
+                       err(1, "cannot drop root privileges");
 
                if (geteuid() == 0 || getuid() == 0)
-                       errx(EX_OSERR, "cannot drop root privileges");
+                       errx(1, "cannot drop root privileges");
        }
 
        atexit(deltmp);
@@ -461,15 +460,15 @@ main(int argc, char **argv)
                argv++; argc--;
                showq = 1;
                if (argc != 0)
-                       errx(EX_USAGE, "invalid arguments");
+                       errx(1, "invalid arguments");
                goto skipopts;
        } else if (strcmp(argv[0], "newaliases") == 0) {
                logident_base = "dma";
                setlogident("%s", logident_base);
 
                if (read_aliases() != 0)
-                       errx(EX_SOFTWARE, "could not parse aliases file `%s'", config.aliases);
-               exit(EX_OK);
+                       errx(1, "could not parse aliases file `%s'", config.aliases);
+               exit(0);
        }
 
        opterr = 0;
@@ -548,7 +547,7 @@ main(int argc, char **argv)
 
                default:
                        fprintf(stderr, "invalid argument: `-%c'\n", optopt);
-                       exit(EX_USAGE);
+                       exit(1);
                }
        }
        argc -= optind;
@@ -556,10 +555,10 @@ main(int argc, char **argv)
        opterr = 1;
 
        if (argc != 0 && (showq || doqueue))
-               errx(EX_USAGE, "sending mail and queue operations are mutually exclusive");
+               errx(1, "sending mail and queue operations are mutually exclusive");
 
        if (showq + doqueue > 1)
-               errx(EX_USAGE, "conflicting queue operations");
+               errx(1, "conflicting queue operations");
 
 skipopts:
        if (logident_base == NULL)
@@ -579,7 +578,7 @@ skipopts:
 
        if (showq) {
                if (load_queue(&queue) < 0)
-                       errlog(EX_NOINPUT, "can not load queue");
+                       errlog(1, "can not load queue");
                show_queue(&queue);
                return (0);
        }
@@ -587,38 +586,38 @@ skipopts:
        if (doqueue) {
                flushqueue_signal();
                if (load_queue(&queue) < 0)
-                       errlog(EX_NOINPUT, "can not load queue");
+                       errlog(1, "can not load queue");
                run_queue(&queue);
                return (0);
        }
 
        if (read_aliases() != 0)
-               errlog(EX_SOFTWARE, "could not parse aliases file `%s'", config.aliases);
+               errlog(1, "could not parse aliases file `%s'", config.aliases);
 
        if ((sender = set_from(&queue, sender)) == NULL)
-               errlog(EX_SOFTWARE, NULL);
+               errlog(1, "set_from failed");
 
        if (newspoolf(&queue) != 0)
-               errlog(EX_CANTCREAT, "can not create temp file in `%s'", config.spooldir);
+               errlog(1, "can not create temp file in `%s'", config.spooldir);
 
        setlogident("%s", queue.id);
 
        for (i = 0; i < argc; i++) {
                if (add_recp(&queue, argv[i], EXPAND_WILDCARD) != 0)
-                       errlogx(EX_DATAERR, "invalid recipient `%s'", argv[i]);
+                       errlogx(1, "invalid recipient `%s'", argv[i]);
        }
 
        if (LIST_EMPTY(&queue.queue) && !recp_from_header)
-               errlogx(EX_NOINPUT, "no recipients");
+               errlogx(1, "no recipients");
 
        if (readmail(&queue, nodot, recp_from_header) != 0)
-               errlog(EX_NOINPUT, "can not read mail");
+               errlog(1, "can not read mail");
 
        if (LIST_EMPTY(&queue.queue))
-               errlogx(EX_NOINPUT, "no recipients");
+               errlogx(1, "no recipients");
 
        if (linkspool(&queue) != 0)
-               errlog(EX_CANTCREAT, "can not create spools");
+               errlog(1, "can not create spools");
 
        /* From here on the mail is safe. */
 
index acf5e44d07bcced8faf1420a05304323b4986fab..4ce00944a5ee1b22972a0292806bd51e912a003b 100644 (file)
@@ -1,9 +1,8 @@
 /*
- * Copyright (c) 2008-2014, Simon Schubert <2@0x2c.org>.
  * Copyright (c) 2008 The DragonFly Project.  All rights reserved.
  *
  * This code is derived from software contributed to The DragonFly Project
- * by Simon Schubert <2@0x2c.org> and
+ * by Simon 'corecode' Schubert <corecode@fs.ei.tum.de> and
  * Matthias Schmidt <matthias@dragonflybsd.org>.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -44,7 +43,6 @@
 #include <arpa/inet.h>
 #include <openssl/ssl.h>
 #include <netdb.h>
-#include <sysexits.h>
 
 #define VERSION        "DragonFly Mail Agent " DMA_VERSION
 
@@ -175,8 +173,6 @@ extern char errmsg[ERRMSG_SIZE];
 
 /* aliases_parse.y */
 int yyparse(void);
-int yywrap(void);
-int yylex(void);
 extern FILE *yyin;
 
 /* conf.c */
index dd9ebfca8d8298bb9566c585a4f40d04283d8e6c..fc5213f1ca605600baa07ebcc9b0281671b133fd 100644 (file)
@@ -1,9 +1,8 @@
 /*
- * Copyright (c) 2008-2014, Simon Schubert <2@0x2c.org>.
  * Copyright (c) 2008 The DragonFly Project.  All rights reserved.
  *
  * This code is derived from software contributed to The DragonFly Project
- * by Simon Schubert <2@0x2c.org>.
+ * by Simon 'corecode' Schubert <corecode@fs.ei.tum.de>
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -68,6 +67,7 @@ add_host(int pref, const char *host, int port, struct mx_hostentry **he, size_t
        char servname[10];
        struct mx_hostentry *p;
        const int count_inc = 10;
+       int err;
 
        memset(&hints, 0, sizeof(hints));
        hints.ai_family = PF_UNSPEC;
@@ -75,26 +75,9 @@ add_host(int pref, const char *host, int port, struct mx_hostentry **he, size_t
        hints.ai_protocol = IPPROTO_TCP;
 
        snprintf(servname, sizeof(servname), "%d", port);
-       switch (getaddrinfo(host, servname, &hints, &res0)) {
-       case 0:
-               break;
-       case EAI_AGAIN:
-       case EAI_NONAME:
-               /*
-                * EAI_NONAME gets returned for:
-                * SMARTHOST set but DNS server not reachable -> defer
-                * SMARTHOST set but DNS server returns "host does not exist"
-                *           -> buggy configuration
-                *           -> either defer or bounce would be ok -> defer
-                * MX entry was returned by DNS server but name doesn't resolve
-                *           -> hopefully transient situation -> defer
-                * all other DNS problems should have been caught earlier
-                * in dns_get_mx_list().
-                */
-               goto out;
-       default:
-               return(-1);
-       }
+       err = getaddrinfo(host, servname, &hints, &res0);
+       if (err)
+               return (err == EAI_AGAIN ? 1 : -1);
 
        for (res = res0; res != NULL; res = res->ai_next) {
                if (*ps + 1 >= roundup(*ps, count_inc)) {
index d9691ac37c95f5c6775a0a9e48578d2989dd42c3..aecc3331f446311d8bac4993c1618d3e638a6f30 100755 (executable)
@@ -1,9 +1,7 @@
 #!/bin/sh
 
-tmp=$1
-file=${tmp:=VERSION}
 gitver=$(git describe 2>/dev/null | tr - .)
-filever=$(cat ${file} 2>/dev/null)
+filever=$(cat VERSION)
 
 version=${gitver}
 : ${version:=$filever}
index e3e015217feac05493b5dc30f530a82c3905f366..6a6407ef86527fd83c3273e77ee039acaf888a5d 100644 (file)
@@ -1,9 +1,8 @@
 /*
- * Copyright (c) 2008-2014, Simon Schubert <2@0x2c.org>.
  * Copyright (c) 2008 The DragonFly Project.  All rights reserved.
  *
  * This code is derived from software contributed to The DragonFly Project
- * by Simon Schubert <2@0x2c.org>.
+ * by Simon 'corecode' Schubert <corecode@fs.ei.tum.de>.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -82,7 +81,7 @@ create_mbox(const char *name)
 
                execl(LIBEXEC_PATH "/dma-mbox-create", "dma-mbox-create", name, NULL);
                syslog(LOG_ERR, "cannot execute "LIBEXEC_PATH"/dma-mbox-create: %m");
-               exit(EX_SOFTWARE);
+               exit(1);
 
        default:
                /* parent */
index a6d11fcae685a9dd1440fd4782de4a5628826cee..f899d4b1af2ea8a9cef3d557a1aeb3b0afff28b2 100644 (file)
@@ -1,9 +1,8 @@
 /*
- * Copyright (c) 2008-2014, Simon Schubert <2@0x2c.org>.
  * Copyright (c) 2008 The DragonFly Project.  All rights reserved.
  *
  * This code is derived from software contributed to The DragonFly Project
- * by Simon Schubert <2@0x2c.org>.
+ * by Simon 'corecode' Schubert <corecode@fs.ei.tum.de>.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -52,7 +51,7 @@ bounce(struct qitem *it, const char *reason)
        /* Don't bounce bounced mails */
        if (it->sender[0] == 0) {
                syslog(LOG_INFO, "can not bounce a bounce message, discarding");
-               exit(EX_SOFTWARE);
+               exit(1);
        }
 
        bzero(&bounceq, sizeof(bounceq));
@@ -133,7 +132,7 @@ bounce(struct qitem *it, const char *reason)
 fail:
        syslog(LOG_CRIT, "error creating bounce: %m");
        delqueue(it);
-       exit(EX_IOERR);
+       exit(1);
 }
 
 struct parse_state {
@@ -333,10 +332,10 @@ newaddr:
        ps->pos = 0;
        addr = strdup(ps->addr);
        if (addr == NULL)
-               errlog(EX_SOFTWARE, NULL);
+               errlog(1, "strdup failed");
 
        if (add_recp(queue, addr, EXPAND_WILDCARD) != 0)
-               errlogx(EX_DATAERR, "invalid recipient `%s'", addr);
+               errlogx(1, "invalid recipient `%s'", addr);
 
        goto again;
 }
@@ -375,9 +374,7 @@ readmail(struct queue *queue, int nodot, int recp_from_header)
                if (fgets(line, sizeof(line) - 1, stdin) == NULL)
                        break;
                if (had_last_line)
-                       errlogx(EX_DATAERR, "bad mail input format:"
-                               " from %s (uid %d) (envelope-from %s)",
-                               username, useruid, queue->sender);
+                       errlogx(1, "bad mail input format");
                linelen = strlen(line);
                if (linelen == 0 || line[linelen - 1] != '\n') {
                        /*
@@ -408,7 +405,7 @@ readmail(struct queue *queue, int nodot, int recp_from_header)
 
                        if (parse_state.state != NONE) {
                                if (parse_addrs(&parse_state, line, queue) < 0) {
-                                       errlogx(EX_DATAERR, "invalid address in header\n");
+                                       errlogx(1, "invalid address in header\n");
                                        /* NOTREACHED */
                                }
                        }
@@ -419,7 +416,7 @@ readmail(struct queue *queue, int nodot, int recp_from_header)
                                        strprefixcmp(line, "Bcc:") == 0)) {
                                parse_state.state = START;
                                if (parse_addrs(&parse_state, line, queue) < 0) {
-                                       errlogx(EX_DATAERR, "invalid address in header\n");
+                                       errlogx(1, "invalid address in header\n");
                                        /* NOTREACHED */
                                }
                        }
index 26935a8feec8306bf6b5f7be7daa563e0c9cabd6..d95a7884b87e336f72077b64b8b1336d8c170ddc 100644 (file)
@@ -1,5 +1,4 @@
 /*
- * Copyright (c) 2008-2014, Simon Schubert <2@0x2c.org>.
  * Copyright (c) 2008 The DragonFly Project.  All rights reserved.
  *
  * This code is derived from software contributed to The DragonFly Project
index d71332b7d7f90c81989e7bea100800235f802bf4..2864909cf6a67316e412be13057a624f99798416 100644 (file)
@@ -1,9 +1,8 @@
 /*
- * Copyright (c) 2008-2014, Simon Schubert <2@0x2c.org>.
  * Copyright (c) 2008 The DragonFly Project.  All rights reserved.
  *
  * This code is derived from software contributed to The DragonFly Project
- * by Simon Schubert <2@0x2c.org>.
+ * by Simon 'corecode' Schubert <corecode@fs.ei.tum.de>.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -290,7 +289,7 @@ load_queue(struct queue *queue)
 
        spooldir = opendir(config.spooldir);
        if (spooldir == NULL)
-               err(EX_NOINPUT, "reading queue");
+               err(1, "reading queue");
 
        while ((de = readdir(spooldir)) != NULL) {
                queuefn = NULL;
index d528f313d091769b17582f8d46704165c10dcaea..a139b20d383166db75fd48f722f506509942f96f 100644 (file)
@@ -1,9 +1,8 @@
 /*
- * Copyright (c) 2008-2014, Simon Schubert <2@0x2c.org>.
  * Copyright (c) 2008 The DragonFly Project.  All rights reserved.
  *
  * This code is derived from software contributed to The DragonFly Project
- * by Simon Schubert <2@0x2c.org>.
+ * by Simon 'corecode' Schubert <corecode@fs.ei.tum.de>.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
diff --git a/lib/libarchive/tests/Makefile b/lib/libarchive/tests/Makefile
new file mode 100644 (file)
index 0000000..52fa1f8
--- /dev/null
@@ -0,0 +1,457 @@
+# $FreeBSD$
+
+LIBARCHIVEDIR= ${SRCTOP}/contrib/libarchive
+
+ATF_TESTS_SH+= functional_test
+
+BINDIR=        ${TESTSDIR}
+
+PROGS+=        libarchive_test
+
+CFLAGS+= -I${.CURDIR:H} -I${.OBJDIR}
+CFLAGS+= -I${LIBARCHIVEDIR}/libarchive -I${LIBARCHIVEDIR}/test_utils
+CFLAGS+= -DHAVE_LIBLZMA=1 -DHAVE_LZMA_H=1
+
+DEBUG_CFLAGS+= -g
+
+LIBADD.libarchive_test=        archive
+
+# Uncomment to link against dmalloc
+#LDADD+= -L/usr/local/lib -ldmalloc
+#CFLAGS+= -I/usr/local/include -DUSE_DMALLOC
+
+.PATH: ${LIBARCHIVEDIR}/libarchive/test
+TESTS_SRCS= \
+       test_acl_freebsd_nfs4.c                 \
+       test_acl_freebsd_posix1e.c              \
+       test_acl_nfs4.c                         \
+       test_acl_pax.c                          \
+       test_acl_posix1e.c                      \
+       test_archive_api_feature.c              \
+       test_archive_clear_error.c              \
+       test_archive_cmdline.c                  \
+       test_archive_crypto.c                   \
+       test_archive_getdate.c                  \
+       test_archive_match_time.c               \
+       test_archive_match_owner.c              \
+       test_archive_match_path.c               \
+       test_archive_pathmatch.c                \
+       test_archive_read_close_twice.c         \
+       test_archive_read_close_twice_open_fd.c \
+       test_archive_read_close_twice_open_filename.c   \
+       test_archive_read_multiple_data_objects.c       \
+       test_archive_read_next_header_empty.c   \
+       test_archive_read_next_header_raw.c     \
+       test_archive_read_open2.c               \
+       test_archive_read_set_filter_option.c   \
+       test_archive_read_set_format_option.c   \
+       test_archive_read_set_option.c          \
+       test_archive_read_set_options.c         \
+       test_archive_read_support.c             \
+       test_archive_set_error.c                \
+       test_archive_string.c                   \
+       test_archive_string_conversion.c        \
+       test_archive_write_add_filter_by_name.c \
+       test_archive_write_set_filter_option.c  \
+       test_archive_write_set_format_by_name.c \
+       test_archive_write_set_format_option.c  \
+       test_archive_write_set_option.c         \
+       test_archive_write_set_options.c        \
+       test_bad_fd.c                           \
+       test_compat_bzip2.c                     \
+       test_compat_cpio.c                      \
+       test_compat_gtar.c                      \
+       test_compat_gzip.c                      \
+       test_compat_lzip.c                      \
+       test_compat_lzma.c                      \
+       test_compat_lzop.c                      \
+       test_compat_mac.c                       \
+       test_compat_pax_libarchive_2x.c         \
+       test_compat_solaris_tar_acl.c           \
+       test_compat_solaris_pax_sparse.c        \
+       test_compat_tar_hardlink.c              \
+       test_compat_uudecode.c                  \
+       test_compat_xz.c                        \
+       test_compat_zip.c                       \
+       test_empty_write.c                      \
+       test_entry.c                            \
+       test_entry_strmode.c                    \
+       test_extattr_freebsd.c                  \
+       test_filter_count.c                     \
+       test_fuzz.c                             \
+       test_gnutar_filename_encoding.c         \
+       test_link_resolver.c                    \
+       test_open_fd.c                          \
+       test_open_failure.c                     \
+       test_open_file.c                        \
+       test_open_filename.c                    \
+       test_pax_filename_encoding.c            \
+       test_read_data_large.c                  \
+       test_read_disk.c                        \
+       test_read_disk_directory_traversals.c   \
+       test_read_disk_entry_from_file.c        \
+       test_read_extract.c                     \
+       test_read_file_nonexistent.c            \
+       test_read_filter_grzip.c                \
+       test_read_filter_lrzip.c                \
+       test_read_filter_lzop.c                 \
+       test_read_filter_lzop_multiple_parts.c  \
+       test_read_filter_program.c              \
+       test_read_filter_program_signature.c    \
+       test_read_filter_uudecode.c             \
+       test_read_format_7zip.c                 \
+       test_read_format_ar.c                   \
+       test_read_format_cab.c                  \
+       test_read_format_cab_filename.c         \
+       test_read_format_cpio_afio.c            \
+       test_read_format_cpio_bin.c             \
+       test_read_format_cpio_bin_Z.c           \
+       test_read_format_cpio_bin_be.c          \
+       test_read_format_cpio_bin_bz2.c         \
+       test_read_format_cpio_bin_gz.c          \
+       test_read_format_cpio_bin_lzip.c        \
+       test_read_format_cpio_bin_lzma.c        \
+       test_read_format_cpio_bin_xz.c          \
+       test_read_format_cpio_filename.c        \
+       test_read_format_cpio_odc.c             \
+       test_read_format_cpio_svr4_gzip.c       \
+       test_read_format_cpio_svr4c_Z.c         \
+       test_read_format_cpio_svr4_bzip2_rpm.c  \
+       test_read_format_cpio_svr4_gzip_rpm.c   \
+       test_read_format_empty.c                \
+       test_read_format_gtar_filename.c        \
+       test_read_format_gtar_gz.c              \
+       test_read_format_gtar_lzma.c            \
+       test_read_format_gtar_sparse.c          \
+       test_read_format_gtar_sparse_skip_entry.c \
+       test_read_format_iso_Z.c                \
+       test_read_format_iso_multi_extent.c     \
+       test_read_format_iso_xorriso.c          \
+       test_read_format_isorr_rr_moved.c       \
+       test_read_format_isojoliet_bz2.c        \
+       test_read_format_isojoliet_long.c       \
+       test_read_format_isojoliet_rr.c         \
+       test_read_format_isojoliet_versioned.c  \
+       test_read_format_isorr_bz2.c            \
+       test_read_format_isorr_ce.c             \
+       test_read_format_isorr_new_bz2.c        \
+       test_read_format_isozisofs_bz2.c        \
+       test_read_format_lha.c                  \
+       test_read_format_lha_filename.c         \
+       test_read_format_mtree.c                \
+       test_read_format_pax_bz2.c              \
+       test_read_format_rar.c                  \
+       test_read_format_raw.c                  \
+       test_read_format_tar.c                  \
+       test_read_format_tar_empty_filename.c   \
+       test_read_format_tar_filename.c         \
+       test_read_format_tbz.c                  \
+       test_read_format_tgz.c                  \
+       test_read_format_tlz.c                  \
+       test_read_format_txz.c                  \
+       test_read_format_tz.c                   \
+       test_read_format_ustar_filename.c       \
+       test_read_format_xar.c                  \
+       test_read_format_zip.c                  \
+       test_read_format_zip_comment_stored.c   \
+       test_read_format_zip_filename.c         \
+       test_read_format_zip_mac_metadata.c     \
+       test_read_format_zip_sfx.c              \
+       test_read_large.c                       \
+       test_read_pax_truncated.c               \
+       test_read_position.c                    \
+       test_read_set_format.c                  \
+       test_read_truncated.c                   \
+       test_read_truncated_filter.c            \
+       test_sparse_basic.c                     \
+       test_tar_filenames.c                    \
+       test_tar_large.c                        \
+       test_ustar_filenames.c                  \
+       test_ustar_filename_encoding.c          \
+       test_write_disk.c                       \
+       test_write_disk_appledouble.c           \
+       test_write_disk_failures.c              \
+       test_write_disk_hardlink.c              \
+       test_write_disk_hfs_compression.c       \
+       test_write_disk_lookup.c                \
+       test_write_disk_mac_metadata.c          \
+       test_write_disk_no_hfs_compression.c    \
+       test_write_disk_perms.c                 \
+       test_write_disk_secure.c                \
+       test_write_disk_sparse.c                \
+       test_write_disk_symlink.c               \
+       test_write_disk_times.c                 \
+       test_write_filter_b64encode.c           \
+       test_write_filter_bzip2.c               \
+       test_write_filter_compress.c            \
+       test_write_filter_gzip.c                \
+       test_write_filter_gzip_timestamp.c      \
+       test_write_filter_lrzip.c               \
+       test_write_filter_lzip.c                \
+       test_write_filter_lzma.c                \
+       test_write_filter_lzop.c                \
+       test_write_filter_program.c             \
+       test_write_filter_uuencode.c            \
+       test_write_filter_xz.c                  \
+       test_write_format_7zip.c                \
+       test_write_format_7zip_empty.c          \
+       test_write_format_7zip_large.c          \
+       test_write_format_ar.c                  \
+       test_write_format_cpio.c                \
+       test_write_format_cpio_empty.c          \
+       test_write_format_cpio_newc.c           \
+       test_write_format_cpio_odc.c            \
+       test_write_format_gnutar.c              \
+       test_write_format_iso9660.c             \
+       test_write_format_iso9660_boot.c        \
+       test_write_format_iso9660_empty.c       \
+       test_write_format_iso9660_filename.c    \
+       test_write_format_iso9660_zisofs.c      \
+       test_write_format_mtree.c               \
+       test_write_format_mtree_absolute_path.c \
+       test_write_format_mtree_classic.c       \
+       test_write_format_mtree_classic_indent.c        \
+       test_write_format_mtree_fflags.c        \
+       test_write_format_mtree_no_separator.c  \
+       test_write_format_mtree_quoted_filename.c       \
+       test_write_format_pax.c                 \
+       test_write_format_shar_empty.c          \
+       test_write_format_tar.c                 \
+       test_write_format_tar_empty.c           \
+       test_write_format_tar_sparse.c          \
+       test_write_format_tar_ustar.c           \
+       test_write_format_tar_v7tar.c           \
+       test_write_format_xar.c                 \
+       test_write_format_xar_empty.c           \
+       test_write_format_zip.c                 \
+       test_write_format_zip_empty.c           \
+       test_write_format_zip_no_compression.c  \
+       test_write_zip_set_compression_store.c  \
+       test_write_open_memory.c                \
+       test_zip_filename_encoding.c
+
+# Deterministic failures:
+# Crashes with SIGBUS
+BROKEN_TESTS+=                 test_archive_rmd160
+# Fails with `libarchive/test/test_archive_crypto.c:121: md != actualmd`
+BROKEN_TESTS+=                 test_archive_sha384
+# Fails with `test_compat_pax_libarchive_2x.c:122: ARCHIVE_WARN != archive_read_next_header(a, &ae)`
+BROKEN_TESTS+=                 test_compat_pax_libarchive_2x
+# Fails with `test_read_disk_directory_traversals.c:1094: File at has atime 886622, 1443306049 seconds ago`
+BROKEN_TESTS+=                 test_read_disk_directory_traversals
+
+# Non-deterministic failures:
+# (Times out?) [and] crashes
+BROKEN_TESTS+=                 test_fuzz_rar
+
+# Build the test program.
+SRCS.libarchive_test=          \
+       ${TESTS_SRCS}           \
+       main.c                  \
+       read_open_memory.c
+
+DPSRCS.libarchive_test= \
+       list.h
+
+.PATH: ${LIBARCHIVEDIR}/test_utils
+SRCS.libarchive_test+= test_utils.c
+
+# list.h is just a list of all tests, as indicated by DEFINE_TEST macro lines
+list.h: ${TESTS_SRCS} Makefile
+       @(cd ${LIBARCHIVEDIR}/libarchive/test && \
+       grep -h DEFINE_TEST ${.ALLSRC:N*Makefile} | \
+           egrep -v '${BROKEN_TESTS:tW:C/ /|/g}') > ${.TARGET}.tmp
+       @mv ${.TARGET}.tmp ${.TARGET}
+
+FILES+=        README
+FILES+=        test_acl_pax.tar.uu
+FILES+=        test_archive_string_conversion.txt.Z.uu
+FILES+=        test_compat_bzip2_1.tbz.uu
+FILES+=        test_compat_bzip2_2.tbz.uu
+FILES+=        test_compat_cpio_1.cpio.uu
+FILES+=        test_compat_gtar_1.tar.uu
+FILES+=        test_compat_gzip_1.tgz.uu
+FILES+=        test_compat_gzip_2.tgz.uu
+FILES+=        test_compat_lzip_1.tlz.uu
+FILES+=        test_compat_lzip_2.tlz.uu
+FILES+=        test_compat_lzma_1.tlz.uu
+FILES+=        test_compat_lzma_2.tlz.uu
+FILES+=        test_compat_lzma_3.tlz.uu
+FILES+=        test_compat_lzop_1.tar.lzo.uu
+FILES+=        test_compat_lzop_2.tar.lzo.uu
+FILES+=        test_compat_lzop_3.tar.lzo.uu
+FILES+=        test_compat_mac-1.tar.Z.uu
+FILES+=        test_compat_mac-2.tar.Z.uu
+FILES+=        test_compat_pax_libarchive_2x.tar.Z.uu
+FILES+=        test_compat_solaris_pax_sparse_1.pax.Z.uu
+FILES+=        test_compat_solaris_pax_sparse_2.pax.Z.uu
+FILES+=        test_compat_solaris_tar_acl.tar.uu
+FILES+=        test_compat_tar_hardlink_1.tar.uu
+FILES+=        test_compat_xz_1.txz.uu
+FILES+=        test_compat_zip_1.zip.uu
+FILES+=        test_compat_zip_2.zip.uu
+FILES+=        test_compat_zip_3.zip.uu
+FILES+=        test_compat_zip_4.zip.uu
+FILES+=        test_compat_zip_5.zip.uu
+FILES+=        test_compat_zip_6.zip.uu
+FILES+=        test_compat_zip_7.xps.uu
+FILES+=        test_fuzz.cab.uu
+FILES+=        test_fuzz.lzh.uu
+FILES+=        test_fuzz_1.iso.Z.uu
+FILES+=        test_pax_filename_encoding.tar.uu
+FILES+=        test_rar_multivolume_multiple_files.part1.rar.uu
+FILES+=        test_rar_multivolume_multiple_files.part2.rar.uu
+FILES+=        test_rar_multivolume_multiple_files.part3.rar.uu
+FILES+=        test_rar_multivolume_multiple_files.part4.rar.uu
+FILES+=        test_rar_multivolume_multiple_files.part5.rar.uu
+FILES+=        test_rar_multivolume_multiple_files.part6.rar.uu
+FILES+=        test_rar_multivolume_single_file.part1.rar.uu
+FILES+=        test_rar_multivolume_single_file.part2.rar.uu
+FILES+=        test_rar_multivolume_single_file.part3.rar.uu
+FILES+=        test_rar_multivolume_uncompressed_files.part01.rar.uu
+FILES+=        test_rar_multivolume_uncompressed_files.part02.rar.uu
+FILES+=        test_rar_multivolume_uncompressed_files.part03.rar.uu
+FILES+=        test_rar_multivolume_uncompressed_files.part04.rar.uu
+FILES+=        test_rar_multivolume_uncompressed_files.part05.rar.uu
+FILES+=        test_rar_multivolume_uncompressed_files.part06.rar.uu
+FILES+=        test_rar_multivolume_uncompressed_files.part07.rar.uu
+FILES+=        test_rar_multivolume_uncompressed_files.part08.rar.uu
+FILES+=        test_rar_multivolume_uncompressed_files.part09.rar.uu
+FILES+=        test_rar_multivolume_uncompressed_files.part10.rar.uu
+FILES+=        test_read_filter_grzip.tar.grz.uu
+FILES+=        test_read_filter_lrzip.tar.lrz.uu
+FILES+=        test_read_filter_lzop.tar.lzo.uu
+FILES+=        test_read_filter_lzop_multiple_parts.tar.lzo.uu
+FILES+=        test_read_format_7zip_bcj2_bzip2.7z.uu
+FILES+=        test_read_format_7zip_bcj2_copy_1.7z.uu
+FILES+=        test_read_format_7zip_bcj2_copy_2.7z.uu
+FILES+=        test_read_format_7zip_bcj2_copy_lzma.7z.uu
+FILES+=        test_read_format_7zip_bcj2_deflate.7z.uu
+FILES+=        test_read_format_7zip_bcj2_lzma1_1.7z.uu
+FILES+=        test_read_format_7zip_bcj2_lzma1_2.7z.uu
+FILES+=        test_read_format_7zip_bcj2_lzma2_1.7z.uu
+FILES+=        test_read_format_7zip_bcj2_lzma2_2.7z.uu
+FILES+=        test_read_format_7zip_bcj_bzip2.7z.uu
+FILES+=        test_read_format_7zip_bcj_copy.7z.uu
+FILES+=        test_read_format_7zip_bcj_deflate.7z.uu
+FILES+=        test_read_format_7zip_bcj_lzma1.7z.uu
+FILES+=        test_read_format_7zip_bcj_lzma2.7z.uu
+FILES+=        test_read_format_7zip_bzip2.7z.uu
+FILES+=        test_read_format_7zip_copy.7z.uu
+FILES+=        test_read_format_7zip_copy_2.7z.uu
+FILES+=        test_read_format_7zip_deflate.7z.uu
+FILES+=        test_read_format_7zip_delta_lzma1.7z.uu
+FILES+=        test_read_format_7zip_delta_lzma2.7z.uu
+FILES+=        test_read_format_7zip_empty_archive.7z.uu
+FILES+=        test_read_format_7zip_empty_file.7z.uu
+FILES+=        test_read_format_7zip_lzma1.7z.uu
+FILES+=        test_read_format_7zip_lzma1_2.7z.uu
+FILES+=        test_read_format_7zip_lzma1_lzma2.7z.uu
+FILES+=        test_read_format_7zip_lzma2.7z.uu
+FILES+=        test_read_format_7zip_ppmd.7z.uu
+FILES+=        test_read_format_7zip_symbolic_name.7z.uu
+FILES+=        test_read_format_ar.ar.uu
+FILES+=        test_read_format_cab_1.cab.uu
+FILES+=        test_read_format_cab_2.cab.uu
+FILES+=        test_read_format_cab_3.cab.uu
+FILES+=        test_read_format_cab_filename_cp932.cab.uu
+FILES+=        test_read_format_cpio_bin_be.cpio.uu
+FILES+=        test_read_format_cpio_filename_cp866.cpio.uu
+FILES+=        test_read_format_cpio_filename_eucjp.cpio.uu
+FILES+=        test_read_format_cpio_filename_koi8r.cpio.uu
+FILES+=        test_read_format_cpio_filename_utf8_jp.cpio.uu
+FILES+=        test_read_format_cpio_filename_utf8_ru.cpio.uu
+FILES+=        test_read_format_cpio_svr4_bzip2_rpm.rpm.uu
+FILES+=        test_read_format_cpio_svr4_gzip_rpm.rpm.uu
+FILES+=        test_read_format_gtar_filename_cp866.tar.Z.uu
+FILES+=        test_read_format_gtar_filename_eucjp.tar.Z.uu
+FILES+=        test_read_format_gtar_filename_koi8r.tar.Z.uu
+FILES+=        test_read_format_gtar_sparse_1_13.tar.uu
+FILES+=        test_read_format_gtar_sparse_1_17.tar.uu
+FILES+=        test_read_format_gtar_sparse_1_17_posix00.tar.uu
+FILES+=        test_read_format_gtar_sparse_1_17_posix01.tar.uu
+FILES+=        test_read_format_gtar_sparse_1_17_posix10.tar.uu
+FILES+=        test_read_format_gtar_sparse_1_17_posix10_modified.tar.uu
+FILES+=        test_read_format_gtar_sparse_skip_entry.tar.Z.uu
+FILES+=        test_read_format_iso.iso.Z.uu
+FILES+=        test_read_format_iso_2.iso.Z.uu
+FILES+=        test_read_format_iso_joliet.iso.Z.uu
+FILES+=        test_read_format_iso_joliet_by_nero.iso.Z.uu
+FILES+=        test_read_format_iso_joliet_long.iso.Z.uu
+FILES+=        test_read_format_iso_joliet_rockridge.iso.Z.uu
+FILES+=        test_read_format_iso_multi_extent.iso.Z.uu
+FILES+=        test_read_format_iso_rockridge.iso.Z.uu
+FILES+=        test_read_format_iso_rockridge_ce.iso.Z.uu
+FILES+=        test_read_format_iso_rockridge_new.iso.Z.uu
+FILES+=        test_read_format_iso_rockridge_rr_moved.iso.Z.uu
+FILES+=        test_read_format_iso_xorriso.iso.Z.uu
+FILES+=        test_read_format_iso_zisofs.iso.Z.uu
+FILES+=        test_read_format_lha_filename_cp932.lzh.uu
+FILES+=        test_read_format_lha_header0.lzh.uu
+FILES+=        test_read_format_lha_header1.lzh.uu
+FILES+=        test_read_format_lha_header2.lzh.uu
+FILES+=        test_read_format_lha_header3.lzh.uu
+FILES+=        test_read_format_lha_lh0.lzh.uu
+FILES+=        test_read_format_lha_lh6.lzh.uu
+FILES+=        test_read_format_lha_lh7.lzh.uu
+FILES+=        test_read_format_lha_withjunk.lzh.uu
+FILES+=        test_read_format_mtree.mtree.uu
+FILES+=        test_read_format_mtree_nomagic.mtree.uu
+FILES+=        test_read_format_mtree_nomagic2.mtree.uu
+FILES+=        test_read_format_mtree_nomagic3.mtree.uu
+FILES+=        test_read_format_rar.rar.uu
+FILES+=        test_read_format_rar_binary_data.rar.uu
+FILES+=        test_read_format_rar_compress_best.rar.uu
+FILES+=        test_read_format_rar_compress_normal.rar.uu
+FILES+=        test_read_format_rar_multi_lzss_blocks.rar.uu
+FILES+=        test_read_format_rar_multivolume.part0001.rar.uu
+FILES+=        test_read_format_rar_multivolume.part0002.rar.uu
+FILES+=        test_read_format_rar_multivolume.part0003.rar.uu
+FILES+=        test_read_format_rar_multivolume.part0004.rar.uu
+FILES+=        test_read_format_rar_noeof.rar.uu
+FILES+=        test_read_format_rar_ppmd_lzss_conversion.rar.uu
+FILES+=        test_read_format_rar_sfx.exe.uu
+FILES+=        test_read_format_rar_subblock.rar.uu
+FILES+=        test_read_format_rar_unicode.rar.uu
+FILES+=        test_read_format_rar_windows.rar.uu
+FILES+=        test_read_format_raw.data.Z.uu
+FILES+=        test_read_format_raw.data.uu
+FILES+=        test_read_format_tar_empty_filename.tar.uu
+FILES+=        test_read_format_tar_filename_koi8r.tar.Z.uu
+FILES+=        test_read_format_ustar_filename_cp866.tar.Z.uu
+FILES+=        test_read_format_ustar_filename_eucjp.tar.Z.uu
+FILES+=        test_read_format_ustar_filename_koi8r.tar.Z.uu
+FILES+=        test_read_format_zip.zip.uu
+FILES+=        test_read_format_zip_comment_stored_1.zip.uu
+FILES+=        test_read_format_zip_comment_stored_2.zip.uu
+FILES+=        test_read_format_zip_filename_cp866.zip.uu
+FILES+=        test_read_format_zip_filename_cp932.zip.uu
+FILES+=        test_read_format_zip_filename_koi8r.zip.uu
+FILES+=        test_read_format_zip_filename_utf8_jp.zip.uu
+FILES+=        test_read_format_zip_filename_utf8_ru.zip.uu
+FILES+=        test_read_format_zip_filename_utf8_ru2.zip.uu
+FILES+=        test_read_format_zip_length_at_end.zip.uu
+FILES+=        test_read_format_zip_mac_metadata.zip.uu
+FILES+=        test_read_format_zip_sfx.uu
+FILES+=        test_read_format_zip_symlink.zip.uu
+FILES+=        test_read_format_zip_ux.zip.uu
+FILES+=        test_read_large_splitted_rar_aa.uu
+FILES+=        test_read_large_splitted_rar_ab.uu
+FILES+=        test_read_large_splitted_rar_ac.uu
+FILES+=        test_read_large_splitted_rar_ad.uu
+FILES+=        test_read_large_splitted_rar_ae.uu
+FILES+=        test_read_splitted_rar_aa.uu
+FILES+=        test_read_splitted_rar_ab.uu
+FILES+=        test_read_splitted_rar_ac.uu
+FILES+=        test_read_splitted_rar_ad.uu
+FILES+=        test_splitted_rar_seek_support_aa.uu
+FILES+=        test_splitted_rar_seek_support_ab.uu
+FILES+=        test_splitted_rar_seek_support_ac.uu
+FILES+=        test_write_disk_appledouble.cpio.gz.uu
+FILES+=        test_write_disk_hfs_compression.tgz.uu
+FILES+=        test_write_disk_mac_metadata.tar.gz.uu
+FILES+=        test_write_disk_no_hfs_compression.tgz.uu
+
+CLEANFILES+=   list.h list.h.tmp
+
+.include <bsd.test.mk>
diff --git a/lib/libarchive/tests/functional_test.sh b/lib/libarchive/tests/functional_test.sh
new file mode 100755 (executable)
index 0000000..cc66b3e
--- /dev/null
@@ -0,0 +1,50 @@
+#
+# Copyright 2015 EMC Corp.
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions are
+# met:
+#
+# * Redistributions of source code must retain the above copyright
+#   notice, this list of conditions and the following disclaimer.
+# * Redistributions in binary form must reproduce the above copyright
+#   notice, this list of conditions and the following disclaimer in the
+#   documentation and/or other materials provided with the distribution.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS 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 COPYRIGHT
+# OWNER 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$
+
+SRCDIR=$(atf_get_srcdir)
+TESTER="${SRCDIR}/libarchive_test"
+
+check()
+{
+       local testcase=${1}; shift
+
+       atf_check -o ignore -s exit:0 ${TESTER} -d -r "${SRCDIR}" -v "${testcase}"
+}
+
+atf_init_test_cases()
+{
+       # Redirect stderr to stdout for the usage message because if you don't
+       # kyua list/kyua test will break:
+       # https://github.com/jmmv/kyua/issues/149
+       testcases=$(${TESTER} -h 2>&1 | awk 'p != 0 && $1 ~ /^[0-9]+:/ { print $NF } /Available tests:/ { p=1 }')
+       for testcase in ${testcases}; do
+               atf_test_case ${testcase}
+               eval "${testcase}_body() { check ${testcase}; }"
+               atf_add_test_case ${testcase}
+       done
+}
index 788e79f1900d4128eee4268acd0955db2eb066b9..98ddf13e8ec44f7bd34af1afe7ec89da2c202bc5 100644 (file)
@@ -25,7 +25,7 @@
 .\"
 .\" $FreeBSD$
 .\"
-.Dd October 10, 2015
+.Dd July 17, 1995
 .Dt SHMCTL 2
 .Os
 .Sh NAME
@@ -72,18 +72,15 @@ or it must have superuser privileges.
 .It Dv IPC_RMID
 Removes the segment from the system.
 The removal will not take
-effect until all processes having attached the segment have exited.
+effect until all processes having attached the segment have exited;
+however, once the IPC_RMID operation has taken place, no further
+processes will be allowed to attach the segment.
 For the operation
 to succeed, the calling process's effective uid must match
 .Fa shm_perm.uid
 or
 .Fa shm_perm.cuid ,
 or the process must have superuser privileges.
-If the
-.Va kern.ipc.shm_allow_removed
-.Xr sysctl 3
-variable is set to 0, once the IPC_RMID operation has taken place,
-no further processes will be allowed to attach the segment.
 .\" .It Dv SHM_LOCK
 .\" Locks the segment in memory.  The calling process must have
 .\" superuser privileges. Not implemented in FreeBSD.
index e9a0d0a1c614878ab4dffd33f51f2d307d85afbd..cdc9cea2bfaec92e7dcb8a04243d68fd14930f73 100644 (file)
@@ -7,7 +7,7 @@ DMA_SOURCES=    ${.CURDIR}/../../../contrib/dma
 CFLAGS=        -I${DMA_SOURCES} \
        -DHAVE_REALLOCF -DHAVE_STRLCPY -DHAVE_GETPROGNAME \
        -DCONF_PATH='"/etc/dma"' \
-       -DLIBEXEC_PATH='"/usr/libexec"' -DDMA_VERSION='"v0.10"' \
+       -DLIBEXEC_PATH='"/usr/libexec"' -DDMA_VERSION='"v0.9+"' \
        -DDMA_ROOT_USER='"mailnull"' \
        -DDMA_GROUP='"mail"'
 BINGRP=        mail
index 6ce13c03c4a063faa5f10987e2a67017760bb347..6a45a8d598b2f88e75ebeba46966d2caaf826e43 100644 (file)
@@ -17,7 +17,7 @@ SRCS= aliases_parse.y \
        util.c
 MAN8=  dma.8
 CONFS= dma.conf
-CONFSDIR=      ${CONFIGDIR}/dma
+CONFSDIR=      ${ETCDIR}/dma
 YFLAGS+=       -i
 CLEANFILES=    aliases_parse.i
 FILES= mailer.conf
index fc7732db15647103b977d6f3b0c2449676be6fce..c83c2f56ba1f1e0f068ee2a7d9a0845d85098da6 100644 (file)
@@ -24,7 +24,7 @@
 .\"
 .\" $FreeBSD$
 .\"
-.Dd October 10, 2015
+.Dd September 15, 2015
 .Dt GNOP 8
 .Os
 .Sh NAME
@@ -72,10 +72,9 @@ The
 utility is used for setting up transparent providers on existing ones.
 Its main purpose is testing other GEOM classes, as it allows forced provider
 removal and I/O error simulation with a given probability.
-It also gathers statistics on the number of read, write, delete,
-getattr, flush, and other requests, and the number of bytes read and written.
-.Nm
-can also be used as a good starting point for implementing new GEOM
+It also gathers the following statistics: number of read requests, number of
+write requests, number of bytes read and number of bytes written.
+In addition, it can be used as a good starting point for implementing new GEOM
 classes.
 .Pp
 The first argument to
index d5000cf1903a62d1e8796ad29ecf407585ad751b..6818d7bb951349507be9a894123ec72e2eebba7a 100644 (file)
@@ -37,7 +37,7 @@
 .\"
 .\" $FreeBSD$
 .\"
-.Dd October 10, 2015
+.Dd August 6, 2015
 .Dt MDCONFIG 8
 .Os
 .Sh NAME
@@ -159,11 +159,11 @@ prefix.
 Size of the memory disk.
 .Ar Size
 is the number of 512 byte sectors unless suffixed with a
-.Cm b , k , m , g , t ,
+.Cm b , k , m , g ,
 or
-.Cm p
+.Cm t
 which
-denotes byte, kilobyte, megabyte, gigabyte, terabyte and petabyte respectively.
+denotes byte, kilobyte, megabyte, gigabyte and terabyte respectively.
 When used without the
 .Fl r
 option, the
index 1b4e4ce2fa4007e626f1d0cc8644227d9d175b09..d741c7770cfc902e5bceb24bc6e3884d1316333c 100644 (file)
@@ -88,8 +88,8 @@ usage(void)
        fprintf(stderr, "\t\ttype = {malloc, vnode, swap}\n");
        fprintf(stderr, "\t\toption = {cluster, compress, reserve}\n");
        fprintf(stderr, "\t\tsize = %%d (512 byte blocks), %%db (B),\n");
-       fprintf(stderr, "\t\t       %%dk (kB), %%dm (MB), %%dg (GB)\n");
-       fprintf(stderr, "\t\t       %%dt (TB), or %%dp (PB)\n");
+       fprintf(stderr, "\t\t       %%dk (kB), %%dm (MB), %%dg (GB) or\n");
+       fprintf(stderr, "\t\t       %%dt (TB)\n");
        exit(1);
 }
 
@@ -217,9 +217,6 @@ main(int argc, char **argv)
                        else if (*p == 't' || *p == 'T') {
                                mdio.md_mediasize <<= 30;
                                mdio.md_mediasize <<= 10;
-                       } else if (*p == 'p' || *p == 'P') {
-                               mdio.md_mediasize <<= 30;
-                               mdio.md_mediasize <<= 20;
                        } else
                                errx(1, "unknown suffix on -s argument");
                        break;
index 0e733e5d86ba56dc7e12b4d4c18083d3d88dec08..8825049ad6a75538ac6982549ee5cb5cecc0730f 100644 (file)
@@ -52,9 +52,9 @@ device driver provides support for VirtIO Ethernet devices.
 If the hypervisor advertises the appreciate features, the
 .Nm
 driver supports TCP/UDP checksum offload for both transmit and receive,
-TCP segmentation offload (TSO), TCP large receive offload (LRO),
-hardware VLAN tag stripping/insertion features, a multicast hash filter,
-as well as Jumbo Frames (up to 9216 bytes), which can be
+TCP segmentation offload (TSO), TCP large receive offload (LRO), and
+hardware VLAN tag stripping/insertion features, as well as a multicast
+hash filter, as well as Jumbo Frames (up to 9216 bytes), which can be
 configured via the interface MTU setting.
 Selecting an MTU larger than 1500 bytes with the
 .Xr ifconfig 8
index a3560b92ff5ccdc75bdaf52cdc5364dd960d22eb..eaa8e0f82867afb35994e32a31a37d381e4086c1 100644 (file)
@@ -13,7 +13,6 @@ FILES=        \
        bsd.README \
        bsd.arch.inc.mk \
        bsd.compiler.mk \
-       bsd.confs.mk \
        bsd.cpu.mk \
        bsd.crunchgen.mk \
        bsd.dep.mk \
index 4e219e828bcfb521139265abb685e86d116fca16..a65410c0346a52ca539a663371958ae46a3add77 100644 (file)
@@ -22,7 +22,7 @@ all: buildconfig
 ${group}OWN?=  ${SHAREOWN}
 ${group}GRP?=  ${SHAREGRP}
 ${group}MODE?= ${CONFMODE}
-${group}DIR?=  ${CONFIGDIR}/
+${group}DIR?=  ${ETCDIR}/
 STAGE_SETS+=   ${group}
 STAGE_DIR.${group}= ${STAGE_OBJTOP}${${group}DIR}
 STAGE_SYMLINKS_DIR.${group}= ${STAGE_OBJTOP}
index 53fd073a44ba86ab5cf81c2635b7c5c6c9003338..450db08448622f535bf5ca6a15086a373d29e040 100644 (file)
@@ -213,7 +213,7 @@ NLSGRP?=    ${SHAREGRP}
 NLSMODE?=      ${NOBINMODE}
 
 INCLUDEDIR?=   /usr/include
-CONFIGDIR?=    /etc
+ETCDIR?=       /etc
 
 #
 # install(1) parameters.
index 71f54879adde7b6500b94059091ae901f58339dd..b665289d7473ee65dce5cc2df068f267bf5fb7d0 100644 (file)
@@ -99,7 +99,7 @@ static int abort_connection(struct c4iw_ep *ep);
 static void peer_close_upcall(struct c4iw_ep *ep);
 static void peer_abort_upcall(struct c4iw_ep *ep);
 static void connect_reply_upcall(struct c4iw_ep *ep, int status);
-static int connect_request_upcall(struct c4iw_ep *ep);
+static void connect_request_upcall(struct c4iw_ep *ep);
 static void established_upcall(struct c4iw_ep *ep);
 static void process_mpa_reply(struct c4iw_ep *ep);
 static void process_mpa_request(struct c4iw_ep *ep);
@@ -1216,6 +1216,7 @@ static int abort_connection(struct c4iw_ep *ep)
        int err;
 
        CTR2(KTR_IW_CXGBE, "%s:abB %p", __func__, ep);
+       close_complete_upcall(ep, -ECONNRESET);
        state_set(&ep->com, ABORTING);
        abort_socket(ep);
        err = close_socket(&ep->com, 0);
@@ -1318,10 +1319,9 @@ static void connect_reply_upcall(struct c4iw_ep *ep, int status)
        CTR2(KTR_IW_CXGBE, "%s:cruE %p", __func__, ep);
 }
 
-static int connect_request_upcall(struct c4iw_ep *ep)
+static void connect_request_upcall(struct c4iw_ep *ep)
 {
        struct iw_cm_event event;
-       int ret;
 
        CTR3(KTR_IW_CXGBE, "%s: ep %p, mpa_v1 %d", __func__, ep,
            ep->tried_with_mpa_v1);
@@ -1355,14 +1355,10 @@ static int connect_request_upcall(struct c4iw_ep *ep)
        }
 
        c4iw_get_ep(&ep->com);
-       ret = ep->parent_ep->com.cm_id->event_handler(ep->parent_ep->com.cm_id,
+       ep->parent_ep->com.cm_id->event_handler(ep->parent_ep->com.cm_id,
            &event);
-       if(ret)
-               c4iw_put_ep(&ep->com);
-
        set_bit(CONNREQ_UPCALL, &ep->com.history);
        c4iw_put_ep(&ep->parent_ep->com);
-       return ret;
 }
 
 static void established_upcall(struct c4iw_ep *ep)
@@ -1839,11 +1835,9 @@ abort:
 
        /* drive upcall */
        mutex_lock(&ep->parent_ep->com.mutex);
-       if (ep->parent_ep->com.state != DEAD) {
-               if(connect_request_upcall(ep)) {
-                       abort_connection(ep);
-               }
-       }else
+       if (ep->parent_ep->com.state != DEAD)
+               connect_request_upcall(ep);
+       else
                abort_connection(ep);
        mutex_unlock(&ep->parent_ep->com.mutex);
 }
@@ -2219,7 +2213,7 @@ int c4iw_ep_disconnect(struct c4iw_ep *ep, int abrupt, gfp_t gfp)
 
                CTR2(KTR_IW_CXGBE, "%s:ced1 %p", __func__, ep);
                fatal = 1;
-               close_complete_upcall(ep, -ECONNRESET);
+               close_complete_upcall(ep, -EIO);
                ep->com.state = DEAD;
        }
        CTR3(KTR_IW_CXGBE, "%s:ced2 %p %s", __func__, ep,
index 07b516c07ed48cd8c662e9ef3076a370a2d12763..3a59623bf6ec5a0e1cf42a90035258ea56da8cc9 100644 (file)
@@ -2527,8 +2527,10 @@ i915_gem_object_unbind(struct drm_i915_gem_object *obj)
        if (obj->gtt_space == NULL)
                return 0;
 
-       if (obj->pin_count)
+       if (obj->pin_count) {
+               DRM_ERROR("Attempting to unbind pinned buffer\n");
                return -EINVAL;
+       }
 
        ret = i915_gem_object_finish_gpu(obj);
        if (ret == -ERESTARTSYS || ret == -EINTR)
index 800ec4c6dff720299c1e2e66dbb62a589770dce3..bb06aa36e11024d55d13a3e6c5038e3581710f2a 100644 (file)
@@ -48,7 +48,7 @@ __FBSDID("$FreeBSD$");
 
 struct icee_softc {
        device_t        sc_dev;         /* Myself */
-       device_t        sc_busdev;      /* Parent bus */
+       struct sx       sc_lock;        /* basically a perimeter lock */
        struct cdev     *cdev;          /* user interface */
        int             addr;
        int             size;           /* How big am I? */
@@ -57,6 +57,12 @@ struct icee_softc {
        int             wr_sz;          /* What's the write page size */
 };
 
+#define ICEE_LOCK(_sc)         sx_xlock(&(_sc)->sc_lock)
+#define        ICEE_UNLOCK(_sc)        sx_xunlock(&(_sc)->sc_lock)
+#define ICEE_LOCK_INIT(_sc)    sx_init(&_sc->sc_lock, "icee")
+#define ICEE_LOCK_DESTROY(_sc) sx_destroy(&_sc->sc_lock);
+#define ICEE_ASSERT_LOCKED(_sc)        sx_assert(&_sc->sc_lock, SA_XLOCKED);
+#define ICEE_ASSERT_UNLOCKED(_sc) sx_assert(&_sc->sc_lock, SA_UNLOCKED);
 #define CDEV2SOFTC(dev)                ((dev)->si_drv1)
 
 /* cdev routines */
@@ -91,7 +97,6 @@ icee_attach(device_t dev)
        int dunit, err;
 
        sc->sc_dev = dev;
-       sc->sc_busdev = device_get_parent(sc->sc_dev);
        sc->addr = iicbus_get_addr(dev);
        err = 0;
        dname = device_get_name(dev);
@@ -112,6 +117,7 @@ icee_attach(device_t dev)
                goto out;
        }
        sc->cdev->si_drv1 = sc;
+       ICEE_LOCK_INIT(sc);
 out:
        return (err);
 }
@@ -149,9 +155,7 @@ icee_read(struct cdev *dev, struct uio *uio, int ioflag)
                return (EIO);
        if (sc->type != 8 && sc->type != 16)
                return (EINVAL);
-       error = iicbus_request_bus(sc->sc_busdev, sc->sc_dev, IIC_INTRWAIT);
-       if (error!= 0)
-               return (iic2errno(error));
+       ICEE_LOCK(sc);
        slave = error = 0;
        while (uio->uio_resid > 0) {
                if (uio->uio_offset >= sc->size)
@@ -176,15 +180,13 @@ icee_read(struct cdev *dev, struct uio *uio, int ioflag)
                for (i = 0; i < 2; i++)
                        msgs[i].slave = slave;
                error = iicbus_transfer(sc->sc_dev, msgs, 2);
-               if (error) {
-                       error = iic2errno(error);
+               if (error)
                        break;
-               }
                error = uiomove(data, len, uio);
                if (error)
                        break;
        }
-       iicbus_release_bus(sc->sc_busdev, sc->sc_dev);
+       ICEE_UNLOCK(sc);
        return (error);
 }
 
@@ -212,10 +214,7 @@ icee_write(struct cdev *dev, struct uio *uio, int ioflag)
                return (EIO);
        if (sc->type != 8 && sc->type != 16)
                return (EINVAL);
-
-       error = iicbus_request_bus(sc->sc_busdev, sc->sc_dev, IIC_INTRWAIT);
-       if (error!= 0)
-               return (iic2errno(error));
+       ICEE_LOCK(sc);
        slave = error = 0;
        while (uio->uio_resid > 0) {
                if (uio->uio_offset >= sc->size)
@@ -240,22 +239,18 @@ icee_write(struct cdev *dev, struct uio *uio, int ioflag)
                if (error)
                        break;
                error = iicbus_transfer(sc->sc_dev, wr, 1);
-               if (error) {
-                       error = iic2errno(error);
+               if (error)
                        break;
-               }
                /* Read after write to wait for write-done. */
                waitlimit = 10000;
                rd[0].slave = slave;
                do {
                        error = iicbus_transfer(sc->sc_dev, rd, 1);
                } while (waitlimit-- > 0 && error != 0);
-               if (error) {
-                       error = iic2errno(error);
+               if (error)
                        break;
-               }
        }
-       iicbus_release_bus(sc->sc_busdev, sc->sc_dev);
+       ICEE_UNLOCK(sc);
        return error;
 }
 
index aca0137d7ea09f76e1727531269b4169fc583192..462165682a859aa27a46d6a3b603df8366bc73be 100644 (file)
@@ -43,7 +43,6 @@
 #define IIC_NOINTR     0
 #define IIC_WAIT       0x1
 #define IIC_INTR       0x2
-#define IIC_INTRWAIT   (IIC_INTR | IIC_WAIT)
 
 /*
  * i2c modes
index dfd6424c71097b7c0bd69262ee7dd6f8d38ebe82..a36c2ed404e23086ec11c5eec55accbe38d88493 100644 (file)
@@ -156,7 +156,7 @@ static void wpi_update_rx_ring_ps(struct wpi_softc *);
 static void    wpi_reset_rx_ring(struct wpi_softc *);
 static void    wpi_free_rx_ring(struct wpi_softc *);
 static int     wpi_alloc_tx_ring(struct wpi_softc *, struct wpi_tx_ring *,
-                   uint8_t);
+                   int);
 static void    wpi_update_tx_ring(struct wpi_softc *, struct wpi_tx_ring *);
 static void    wpi_update_tx_ring_ps(struct wpi_softc *,
                    struct wpi_tx_ring *);
@@ -165,18 +165,19 @@ static void       wpi_free_tx_ring(struct wpi_softc *, struct wpi_tx_ring *);
 static int     wpi_read_eeprom(struct wpi_softc *,
                    uint8_t macaddr[IEEE80211_ADDR_LEN]);
 static uint32_t        wpi_eeprom_channel_flags(struct wpi_eeprom_chan *);
-static void    wpi_read_eeprom_band(struct wpi_softc *, uint8_t);
-static int     wpi_read_eeprom_channels(struct wpi_softc *, uint8_t);
+static void    wpi_read_eeprom_band(struct wpi_softc *, int);
+static int     wpi_read_eeprom_channels(struct wpi_softc *, int);
 static struct wpi_eeprom_chan *wpi_find_eeprom_channel(struct wpi_softc *,
                    struct ieee80211_channel *);
 static int     wpi_setregdomain(struct ieee80211com *,
                    struct ieee80211_regdomain *, int,
                    struct ieee80211_channel[]);
-static int     wpi_read_eeprom_group(struct wpi_softc *, uint8_t);
+static int     wpi_read_eeprom_group(struct wpi_softc *, int);
+static int     wpi_add_node_entry_adhoc(struct wpi_softc *);
 static struct ieee80211_node *wpi_node_alloc(struct ieee80211vap *,
                    const uint8_t mac[IEEE80211_ADDR_LEN]);
 static void    wpi_node_free(struct ieee80211_node *);
-static void    wpi_ibss_recv_mgmt(struct ieee80211_node *, struct mbuf *, int,
+static void    wpi_recv_mgmt(struct ieee80211_node *, struct mbuf *, int,
                    const struct ieee80211_rx_stats *,
                    int, int);
 static void    wpi_restore_node(void *, struct ieee80211_node *);
@@ -209,8 +210,7 @@ static void wpi_watchdog_rfkill(void *);
 static void    wpi_scan_timeout(void *);
 static void    wpi_tx_timeout(void *);
 static void    wpi_parent(struct ieee80211com *);
-static int     wpi_cmd(struct wpi_softc *, uint8_t, const void *, uint16_t,
-                   int);
+static int     wpi_cmd(struct wpi_softc *, int, const void *, size_t, int);
 static int     wpi_mrr_setup(struct wpi_softc *);
 static int     wpi_add_node(struct wpi_softc *, struct ieee80211_node *);
 static int     wpi_add_broadcast_node(struct wpi_softc *, int);
@@ -257,8 +257,7 @@ static int  wpi_key_set(struct ieee80211vap *,
 static int     wpi_key_delete(struct ieee80211vap *,
                    const struct ieee80211_key *);
 static int     wpi_post_alive(struct wpi_softc *);
-static int     wpi_load_bootcode(struct wpi_softc *, const uint8_t *,
-                   uint32_t);
+static int     wpi_load_bootcode(struct wpi_softc *, const uint8_t *, int);
 static int     wpi_load_firmware(struct wpi_softc *);
 static int     wpi_read_firmware(struct wpi_softc *);
 static void    wpi_unload_firmware(struct wpi_softc *);
@@ -328,8 +327,7 @@ wpi_attach(device_t dev)
 {
        struct wpi_softc *sc = (struct wpi_softc *)device_get_softc(dev);
        struct ieee80211com *ic;
-       uint8_t i;
-       int error, rid;
+       int i, error, rid;
 #ifdef WPI_DEBUG
        int supportsa = 1;
        const struct wpi_ident *ident;
@@ -389,11 +387,10 @@ wpi_attach(device_t dev)
        sc->sc_st = rman_get_bustag(sc->mem);
        sc->sc_sh = rman_get_bushandle(sc->mem);
 
-       rid = 1;
-       if (pci_alloc_msi(dev, &rid) == 0)
+       i = 1;
+       rid = 0;
+       if (pci_alloc_msi(dev, &i) == 0)
                rid = 1;
-       else
-               rid = 0;
        /* Install interrupt handler. */
        sc->irq = bus_alloc_resource_any(dev, SYS_RES_IRQ, &rid, RF_ACTIVE |
            (rid != 0 ? 0 : RF_SHAREABLE));
@@ -425,7 +422,7 @@ wpi_attach(device_t dev)
        }
 
        /* Allocate TX rings - 4 for QoS purposes, 1 for commands. */
-       for (i = 0; i < WPI_DRV_NTXQUEUES; i++) {
+       for (i = 0; i < WPI_NTXQUEUES; i++) {
                if ((error = wpi_alloc_tx_ring(sc, &sc->txq[i], i)) != 0) {
                        device_printf(dev,
                            "could not allocate TX ring %d, error %d\n", i,
@@ -640,10 +637,8 @@ wpi_vap_create(struct ieee80211com *ic, const char name[IFNAMSIZ], int unit,
        /* Override with driver methods. */
        vap->iv_key_set = wpi_key_set;
        vap->iv_key_delete = wpi_key_delete;
-       if (opmode == IEEE80211_M_IBSS) {
-               wvp->wv_recv_mgmt = vap->iv_recv_mgmt;
-               vap->iv_recv_mgmt = wpi_ibss_recv_mgmt;
-       }
+       wvp->wv_recv_mgmt = vap->iv_recv_mgmt;
+       vap->iv_recv_mgmt = wpi_recv_mgmt;
        wvp->wv_newstate = vap->iv_newstate;
        vap->iv_newstate = wpi_newstate;
        vap->iv_update_beacon = wpi_update_beacon;
@@ -682,7 +677,7 @@ wpi_detach(device_t dev)
 {
        struct wpi_softc *sc = device_get_softc(dev);
        struct ieee80211com *ic = &sc->sc_ic;
-       uint8_t qid;
+       int qid;
 
        DPRINTF(sc, WPI_DEBUG_TRACE, TRACE_STR_BEGIN, __func__);
 
@@ -713,7 +708,7 @@ wpi_detach(device_t dev)
 
        if (sc->txq[0].data_dmat) {
                /* Free DMA resources. */
-               for (qid = 0; qid < WPI_DRV_NTXQUEUES; qid++)
+               for (qid = 0; qid < WPI_NTXQUEUES; qid++)
                        wpi_free_tx_ring(sc, &sc->txq[qid]);
 
                wpi_free_rx_ring(sc);
@@ -833,9 +828,9 @@ wpi_prph_clrbits(struct wpi_softc *sc, uint32_t addr, uint32_t mask)
 
 static __inline void
 wpi_prph_write_region_4(struct wpi_softc *sc, uint32_t addr,
-    const uint32_t *data, uint32_t count)
+    const uint32_t *data, int count)
 {
-       for (; count != 0; count--, data++, addr += 4)
+       for (; count > 0; count--, data++, addr += 4)
                wpi_prph_write(sc, addr, *data);
 }
 
@@ -1093,7 +1088,6 @@ wpi_update_rx_ring_ps(struct wpi_softc *sc)
                return;
        }
 
-       WPI_TXQ_LOCK(sc);
        WPI_SETBITS(sc, WPI_GP_CNTRL, WPI_GP_CNTRL_MAC_ACCESS_REQ);
        if (WPI_READ(sc, WPI_GP_CNTRL) & WPI_GP_CNTRL_SLEEP) {
                DPRINTF(sc, WPI_DEBUG_PWRSAVE, "%s: wakeup request\n",
@@ -1103,7 +1097,6 @@ wpi_update_rx_ring_ps(struct wpi_softc *sc)
                wpi_update_rx_ring(sc);
                WPI_CLRBITS(sc, WPI_GP_CNTRL, WPI_GP_CNTRL_MAC_ACCESS_REQ);
        }
-       WPI_TXQ_UNLOCK(sc);
 }
 
 static void
@@ -1159,7 +1152,7 @@ wpi_free_rx_ring(struct wpi_softc *sc)
 }
 
 static int
-wpi_alloc_tx_ring(struct wpi_softc *sc, struct wpi_tx_ring *ring, uint8_t qid)
+wpi_alloc_tx_ring(struct wpi_softc *sc, struct wpi_tx_ring *ring, int qid)
 {
        bus_addr_t paddr;
        bus_size_t size;
@@ -1188,6 +1181,16 @@ wpi_alloc_tx_ring(struct wpi_softc *sc, struct wpi_tx_ring *ring, uint8_t qid)
        bus_dmamap_sync(sc->shared_dma.tag, sc->shared_dma.map,
            BUS_DMASYNC_PREWRITE);
 
+       /*
+        * We only use rings 0 through 4 (4 EDCA + cmd) so there is no need
+        * to allocate commands space for other rings.
+        * XXX Do we really need to allocate descriptors for other rings?
+        */
+       if (qid > WPI_CMD_QUEUE_NUM) {
+               DPRINTF(sc, WPI_DEBUG_TRACE, TRACE_STR_END, __func__);
+               return 0;
+       }
+
        size = WPI_TX_RING_COUNT * sizeof (struct wpi_tx_cmd);
        error = wpi_dma_contig_alloc(sc, &ring->cmd_dma, (void **)&ring->cmd,
            size, 4);
@@ -1329,8 +1332,7 @@ wpi_read_eeprom(struct wpi_softc *sc, uint8_t macaddr[IEEE80211_ADDR_LEN])
        if ((error = res) != 0)         \
                goto fail;              \
 } while (0)
-       uint8_t i;
-       int error;
+       int error, i;
 
        DPRINTF(sc, WPI_DEBUG_TRACE, TRACE_STR_BEGIN, __func__);
 
@@ -1414,14 +1416,14 @@ wpi_eeprom_channel_flags(struct wpi_eeprom_chan *channel)
 }
 
 static void
-wpi_read_eeprom_band(struct wpi_softc *sc, uint8_t n)
+wpi_read_eeprom_band(struct wpi_softc *sc, int n)
 {
        struct ieee80211com *ic = &sc->sc_ic;
        struct wpi_eeprom_chan *channels = sc->eeprom_channels[n];
        const struct wpi_chan_band *band = &wpi_bands[n];
        struct ieee80211_channel *c;
-       uint32_t nflags;
-       uint8_t chan, i;
+       uint8_t chan;
+       int i, nflags;
 
        for (i = 0; i < band->nchan; i++) {
                if (!(channels[i].flags & WPI_EEPROM_CHAN_VALID)) {
@@ -1471,7 +1473,7 @@ wpi_read_eeprom_band(struct wpi_softc *sc, uint8_t n)
  * band and update net80211 with what we find.
  */
 static int
-wpi_read_eeprom_channels(struct wpi_softc *sc, uint8_t n)
+wpi_read_eeprom_channels(struct wpi_softc *sc, int n)
 {
        struct ieee80211com *ic = &sc->sc_ic;
        const struct wpi_chan_band *band = &wpi_bands[n];
@@ -1535,7 +1537,7 @@ wpi_setregdomain(struct ieee80211com *ic, struct ieee80211_regdomain *rd,
 }
 
 static int
-wpi_read_eeprom_group(struct wpi_softc *sc, uint8_t n)
+wpi_read_eeprom_group(struct wpi_softc *sc, int n)
 {
        struct wpi_power_group *group = &sc->groups[n];
        struct wpi_eeprom_group rgroup;
@@ -1573,10 +1575,10 @@ wpi_read_eeprom_group(struct wpi_softc *sc, uint8_t n)
        return 0;
 }
 
-static __inline uint8_t
+static int
 wpi_add_node_entry_adhoc(struct wpi_softc *sc)
 {
-       uint8_t newid = WPI_ID_IBSS_MIN;
+       int newid = WPI_ID_IBSS_MIN;
 
        for (; newid <= WPI_ID_IBSS_MAX; newid++) {
                if ((sc->nodesmsk & (1 << newid)) == 0) {
@@ -1588,7 +1590,7 @@ wpi_add_node_entry_adhoc(struct wpi_softc *sc)
        return WPI_ID_UNDEFINED;
 }
 
-static __inline uint8_t
+static __inline int
 wpi_add_node_entry_sta(struct wpi_softc *sc)
 {
        sc->nodesmsk |= 1 << WPI_ID_BSS;
@@ -1658,7 +1660,7 @@ wpi_check_bss_filter(struct wpi_softc *sc)
 }
 
 static void
-wpi_ibss_recv_mgmt(struct ieee80211_node *ni, struct mbuf *m, int subtype,
+wpi_recv_mgmt(struct ieee80211_node *ni, struct mbuf *m, int subtype,
     const struct ieee80211_rx_stats *rxs,
     int rssi, int nf)
 {
@@ -1669,7 +1671,8 @@ wpi_ibss_recv_mgmt(struct ieee80211_node *ni, struct mbuf *m, int subtype,
 
        wvp->wv_recv_mgmt(ni, m, subtype, rxs, rssi, nf);
 
-       if (vap->iv_state == IEEE80211_S_RUN &&
+       if (vap->iv_opmode == IEEE80211_M_IBSS &&
+           vap->iv_state == IEEE80211_S_RUN &&
            (subtype == IEEE80211_FC0_SUBTYPE_BEACON ||
            subtype == IEEE80211_FC0_SUBTYPE_PROBE_RESP)) {
                ni_tstamp = le64toh(ni->ni_tstamp.tsf);
@@ -2582,9 +2585,7 @@ wpi_cmd2(struct wpi_softc *sc, struct wpi_buf *buf)
        struct wpi_tx_ring *ring;
        struct mbuf *m1;
        bus_dma_segment_t *seg, segs[WPI_MAX_SCATTER];
-       uint8_t pad;
-       uint16_t hdrlen;
-       int error, i, nsegs, totlen;
+       int error, i, hdrlen, nsegs, totlen, pad;
 
        WPI_TXQ_LOCK(sc);
 
@@ -2595,7 +2596,7 @@ wpi_cmd2(struct wpi_softc *sc, struct wpi_buf *buf)
        if (__predict_false(sc->sc_running == 0)) {
                /* wpi_stop() was called */
                error = ENETDOWN;
-               goto end;
+               goto fail;
        }
 
        wh = mtod(buf->m, struct ieee80211_frame *);
@@ -2604,7 +2605,7 @@ wpi_cmd2(struct wpi_softc *sc, struct wpi_buf *buf)
 
        if (__predict_false(totlen < sizeof(struct ieee80211_frame_min))) {
                error = EINVAL;
-               goto end;
+               goto fail;
        }
 
        if (hdrlen & 3) {
@@ -2635,7 +2636,7 @@ wpi_cmd2(struct wpi_softc *sc, struct wpi_buf *buf)
        if (error != 0 && error != EFBIG) {
                device_printf(sc->sc_dev,
                    "%s: can't map mbuf (error %d)\n", __func__, error);
-               goto end;
+               goto fail;
        }
        if (error != 0) {
                /* Too many DMA segments, linearize mbuf. */
@@ -2644,29 +2645,17 @@ wpi_cmd2(struct wpi_softc *sc, struct wpi_buf *buf)
                        device_printf(sc->sc_dev,
                            "%s: could not defrag mbuf\n", __func__);
                        error = ENOBUFS;
-                       goto end;
+                       goto fail;
                }
                buf->m = m1;
 
                error = bus_dmamap_load_mbuf_sg(ring->data_dmat, data->map,
                    buf->m, segs, &nsegs, BUS_DMA_NOWAIT);
                if (__predict_false(error != 0)) {
-                       /* XXX fix this (applicable to the iwn(4) too) */
-                       /*
-                        * NB: Do not return error;
-                        * original mbuf does not exist anymore.
-                        */
                        device_printf(sc->sc_dev,
                            "%s: can't map mbuf (error %d)\n", __func__,
                            error);
-                       if (ring->qid < WPI_CMD_QUEUE_NUM) {
-                               if_inc_counter(buf->ni->ni_vap->iv_ifp,
-                                   IFCOUNTER_OERRORS, 1);
-                               ieee80211_free_node(buf->ni);
-                       }
-                       m_freem(buf->m);
-                       error = 0;
-                       goto end;
+                       goto fail;
                }
        }
 
@@ -2710,12 +2699,19 @@ wpi_cmd2(struct wpi_softc *sc, struct wpi_buf *buf)
                WPI_TXQ_STATE_UNLOCK(sc);
        }
 
-end:   DPRINTF(sc, WPI_DEBUG_TRACE, error ? TRACE_STR_END_ERR : TRACE_STR_END,
-           __func__);
+       DPRINTF(sc, WPI_DEBUG_TRACE, TRACE_STR_END, __func__);
 
        WPI_TXQ_UNLOCK(sc);
 
-       return (error);
+       return 0;
+
+fail:  m_freem(buf->m);
+
+       DPRINTF(sc, WPI_DEBUG_TRACE, TRACE_STR_END_ERR, __func__);
+
+       WPI_TXQ_UNLOCK(sc);
+
+       return error;
 }
 
 /*
@@ -2734,9 +2730,9 @@ wpi_tx_data(struct wpi_softc *sc, struct mbuf *m, struct ieee80211_node *ni)
        struct wpi_buf tx_data;
        struct wpi_cmd_data *tx = (struct wpi_cmd_data *)&tx_data.data;
        uint32_t flags;
-       uint16_t ac, qos;
-       uint8_t tid, type, rate;
-       int swcrypt, ismcast, totlen;
+       uint16_t qos;
+       uint8_t tid, type;
+       int ac, error, swcrypt, rate, ismcast, totlen;
 
        wh = mtod(m, struct ieee80211_frame *);
        type = wh->i_fc[0] & IEEE80211_FC0_TYPE_MASK;
@@ -2776,9 +2772,10 @@ wpi_tx_data(struct wpi_softc *sc, struct mbuf *m, struct ieee80211_node *ni)
        if (wh->i_fc[1] & IEEE80211_FC1_PROTECTED) {
                /* Retrieve key for TX. */
                k = ieee80211_crypto_encap(ni, m);
-               if (k == NULL)
-                       return (ENOBUFS);
-
+               if (k == NULL) {
+                       error = ENOBUFS;
+                       goto fail;
+               }
                swcrypt = k->wk_flags & IEEE80211_KEY_SWCRYPT;
 
                /* 802.11 header may have moved. */
@@ -2847,7 +2844,8 @@ wpi_tx_data(struct wpi_softc *sc, struct mbuf *m, struct ieee80211_node *ni)
                if (wn->id == WPI_ID_UNDEFINED) {
                        device_printf(sc->sc_dev,
                            "%s: undefined node id\n", __func__);
-                       return (EINVAL);
+                       error = EINVAL;
+                       goto fail;
                }
 
                tx->id = wn->id;
@@ -2883,6 +2881,9 @@ wpi_tx_data(struct wpi_softc *sc, struct mbuf *m, struct ieee80211_node *ni)
        tx_data.ac = ac;
 
        return wpi_cmd2(sc, &tx_data);
+
+fail:  m_freem(m);
+       return error;
 }
 
 static int
@@ -2895,8 +2896,8 @@ wpi_tx_data_raw(struct wpi_softc *sc, struct mbuf *m,
        struct wpi_buf tx_data;
        struct wpi_cmd_data *tx = (struct wpi_cmd_data *)&tx_data.data;
        uint32_t flags;
-       uint8_t ac, type, rate;
-       int swcrypt, totlen;
+       uint8_t type;
+       int ac, rate, swcrypt, totlen;
 
        wh = mtod(m, struct ieee80211_frame *);
        type = wh->i_fc[0] & IEEE80211_FC0_TYPE_MASK;
@@ -2923,9 +2924,10 @@ wpi_tx_data_raw(struct wpi_softc *sc, struct mbuf *m,
        if (params->ibp_flags & IEEE80211_BPF_CRYPTO) {
                /* Retrieve key for TX. */
                k = ieee80211_crypto_encap(ni, m);
-               if (k == NULL)
-                       return (ENOBUFS);
-
+               if (k == NULL) {
+                       m_freem(m);
+                       return ENOBUFS;
+               }
                swcrypt = k->wk_flags & IEEE80211_KEY_SWCRYPT;
 
                /* 802.11 header may have moved. */
@@ -2989,7 +2991,7 @@ wpi_tx_data_raw(struct wpi_softc *sc, struct mbuf *m,
 }
 
 static __inline int
-wpi_tx_ring_is_full(struct wpi_softc *sc, uint16_t ac)
+wpi_tx_ring_is_full(struct wpi_softc *sc, int ac)
 {
        struct wpi_tx_ring *ring = &sc->txq[ac];
        int retval;
@@ -3001,14 +3003,21 @@ wpi_tx_ring_is_full(struct wpi_softc *sc, uint16_t ac)
        return retval;
 }
 
+static __inline void
+wpi_handle_tx_failure(struct ieee80211_node *ni)
+{
+       /* NB: m is reclaimed on tx failure */
+       if_inc_counter(ni->ni_vap->iv_ifp, IFCOUNTER_OERRORS, 1);
+       ieee80211_free_node(ni);
+}
+
 static int
 wpi_raw_xmit(struct ieee80211_node *ni, struct mbuf *m,
     const struct ieee80211_bpf_params *params)
 {
        struct ieee80211com *ic = ni->ni_ic;
        struct wpi_softc *sc = ic->ic_softc;
-       uint16_t ac;
-       int error = 0;
+       int ac, error = 0;
 
        DPRINTF(sc, WPI_DEBUG_TRACE, TRACE_STR_BEGIN, __func__);
 
@@ -3017,6 +3026,7 @@ wpi_raw_xmit(struct ieee80211_node *ni, struct mbuf *m,
        WPI_TX_LOCK(sc);
 
        if (sc->sc_running == 0 || wpi_tx_ring_is_full(sc, ac)) {
+               m_freem(m);
                error = sc->sc_running ? ENOBUFS : ENETDOWN;
                goto unlock;
        }
@@ -3038,8 +3048,7 @@ wpi_raw_xmit(struct ieee80211_node *ni, struct mbuf *m,
 unlock:        WPI_TX_UNLOCK(sc);
 
        if (error != 0) {
-               m_freem(m);
-               ieee80211_free_node(ni);
+               wpi_handle_tx_failure(ni);
                DPRINTF(sc, WPI_DEBUG_TRACE, TRACE_STR_END_ERR, __func__);
 
                return error;
@@ -3055,8 +3064,7 @@ wpi_transmit(struct ieee80211com *ic, struct mbuf *m)
 {
        struct wpi_softc *sc = ic->ic_softc;
        struct ieee80211_node *ni;
-       uint16_t ac;
-       int error;
+       int ac, error;
 
        WPI_TX_LOCK(sc);
        DPRINTF(sc, WPI_DEBUG_XMIT, "%s: called\n", __func__);
@@ -3077,9 +3085,7 @@ wpi_transmit(struct ieee80211com *ic, struct mbuf *m)
        error = 0;
        ni = (struct ieee80211_node *)m->m_pkthdr.rcvif;
        if (wpi_tx_data(sc, m, ni) != 0) {
-               if_inc_counter(ni->ni_vap->iv_ifp, IFCOUNTER_OERRORS, 1);
-               ieee80211_free_node(ni);
-               m_freem(m);
+               wpi_handle_tx_failure(ni);
        }
 
        DPRINTF(sc, WPI_DEBUG_XMIT, "%s: done\n", __func__);
@@ -3148,7 +3154,7 @@ wpi_parent(struct ieee80211com *ic)
  * Send a command to the firmware.
  */
 static int
-wpi_cmd(struct wpi_softc *sc, uint8_t code, const void *buf, uint16_t size,
+wpi_cmd(struct wpi_softc *sc, int code, const void *buf, size_t size,
     int async)
 {
        struct wpi_tx_ring *ring = &sc->txq[WPI_CMD_QUEUE_NUM];
@@ -3157,8 +3163,7 @@ wpi_cmd(struct wpi_softc *sc, uint8_t code, const void *buf, uint16_t size,
        struct wpi_tx_cmd *cmd;
        struct mbuf *m;
        bus_addr_t paddr;
-       uint16_t totlen;
-       int error;
+       int totlen, error;
 
        WPI_TXQ_LOCK(sc);
 
@@ -3177,7 +3182,7 @@ wpi_cmd(struct wpi_softc *sc, uint8_t code, const void *buf, uint16_t size,
        if (async == 0)
                WPI_LOCK_ASSERT(sc);
 
-       DPRINTF(sc, WPI_DEBUG_CMD, "%s: cmd %s size %u async %d\n",
+       DPRINTF(sc, WPI_DEBUG_CMD, "%s: cmd %s size %zu async %d\n",
            __func__, wpi_cmd_str(code), size, async);
 
        desc = &ring->desc[ring->cur];
@@ -3253,8 +3258,7 @@ wpi_mrr_setup(struct wpi_softc *sc)
 {
        struct ieee80211com *ic = &sc->sc_ic;
        struct wpi_mrr_setup mrr;
-       uint8_t i;
-       int error;
+       int i, error;
 
        /* CCK rates (not used with 802.11a). */
        for (i = WPI_RIDX_CCK1; i <= WPI_RIDX_CCK11; i++) {
@@ -3711,8 +3715,8 @@ wpi_set_pslevel(struct wpi_softc *sc, uint8_t dtim, int level, int async)
 {
        struct wpi_pmgt_cmd cmd;
        const struct wpi_pmgt *pmgt;
-       uint32_t max, reg;
-       uint8_t skip_dtim;
+       uint32_t max, skip_dtim;
+       uint32_t reg;
        int i;
 
        DPRINTF(sc, WPI_DEBUG_PWRSAVE,
@@ -3947,7 +3951,7 @@ wpi_limit_dwell(struct wpi_softc *sc, uint16_t dwell_time)
 {
        struct ieee80211com *ic = &sc->sc_ic;
        struct ieee80211vap *vap = TAILQ_FIRST(&ic->ic_vaps);
-       uint16_t bintval = 0;
+       int bintval = 0;
 
        /* bintval is in TU (1.024mS) */
        if (vap != NULL)
@@ -4011,9 +4015,9 @@ wpi_scan(struct wpi_softc *sc, struct ieee80211_channel *c)
        struct wpi_scan_chan *chan;
        struct ieee80211_frame *wh;
        struct ieee80211_rateset *rs;
-       uint16_t bintval, buflen, dwell_active, dwell_passive;
-       uint8_t *buf, *frm, i, nssid;
-       int bgscan, error;
+       uint16_t dwell_active, dwell_passive;
+       uint8_t *buf, *frm;
+       int bgscan, bintval, buflen, error, i, nssid;
 
        DPRINTF(sc, WPI_DEBUG_TRACE, TRACE_STR_BEGIN, __func__);
 
@@ -4293,7 +4297,6 @@ wpi_config_beacon(struct wpi_vap *wvp)
                device_printf(sc->sc_dev,
                    "%s: could not update beacon frame, error %d", __func__,
                    error);
-               m_freem(bcn->m);
        }
 
        /* Restore mbuf. */
@@ -4806,7 +4809,7 @@ wpi_post_alive(struct wpi_softc *sc)
  * the NIC internal memory (no DMA transfer).
  */
 static int
-wpi_load_bootcode(struct wpi_softc *sc, const uint8_t *ucode, uint32_t size)
+wpi_load_bootcode(struct wpi_softc *sc, const uint8_t *ucode, int size)
 {
        int error, ntries;
 
@@ -5156,8 +5159,7 @@ wpi_nic_config(struct wpi_softc *sc)
 static int
 wpi_hw_init(struct wpi_softc *sc)
 {
-       uint8_t chnl;
-       int ntries, error;
+       int chnl, ntries, error;
 
        DPRINTF(sc, WPI_DEBUG_TRACE, TRACE_STR_BEGIN, __func__);
 
@@ -5272,8 +5274,7 @@ wpi_hw_init(struct wpi_softc *sc)
 static void
 wpi_hw_stop(struct wpi_softc *sc)
 {
-       uint8_t chnl, qid;
-       int ntries;
+       int chnl, qid, ntries;
 
        DPRINTF(sc, WPI_DEBUG_TRACE, TRACE_STR_DOING, __func__);
 
@@ -5312,7 +5313,7 @@ wpi_hw_stop(struct wpi_softc *sc)
        wpi_reset_rx_ring(sc);
 
        /* Reset all TX rings. */
-       for (qid = 0; qid < WPI_DRV_NTXQUEUES; qid++)
+       for (qid = 0; qid < WPI_NTXQUEUES; qid++)
                wpi_reset_tx_ring(sc, &sc->txq[qid]);
 
        if (wpi_nic_lock(sc) == 0) {
index f36dd2512473dfa2dc9ea4a4ed9621d976e6e937..b0aa35c992d541a91aa0d07404904bf9ac9e5d84 100644 (file)
@@ -978,7 +978,7 @@ static const struct wpi_pmgt {
        uint32_t        rxtimeout;
        uint32_t        txtimeout;
        uint32_t        intval[5];
-       uint8_t         skip_dtim;
+       int             skip_dtim;
 } wpi_pmgt[WPI_NDTIMRANGES][WPI_NPOWERLEVELS] = {
        /* DTIM <= 10 */
        {
index fb566b50945b082accd4fc29bc2ebe261748f4c3..80195b59d16c410f7a124756a7631b4005270523 100644 (file)
@@ -72,10 +72,10 @@ struct wpi_tx_ring {
        struct wpi_tx_cmd       *cmd;
        struct wpi_tx_data      data[WPI_TX_RING_COUNT];
        bus_dma_tag_t           data_dmat;
-       uint8_t                 qid;
-       uint8_t                 cur;
-       int16_t                 queued;
-       int                     update:1;
+       int                     qid;
+       int                     queued;
+       int                     cur;
+       int                     update;
 };
 
 struct wpi_rx_data {
@@ -88,7 +88,7 @@ struct wpi_rx_ring {
        uint32_t                *desc;
        struct wpi_rx_data      data[WPI_RX_RING_COUNT];
        bus_dma_tag_t           data_dmat;
-       uint16_t                cur;
+       int                     cur;
        int                     update;
 };
 
@@ -116,8 +116,8 @@ struct wpi_buf {
        struct ieee80211_node   *ni;
        struct mbuf             *m;
        size_t                  size;
-       uint8_t                 code;
-       uint16_t                ac;
+       int                     code;
+       int                     ac;
 };
 
 struct wpi_vap {
@@ -126,7 +126,7 @@ struct wpi_vap {
        struct wpi_buf          wv_bcbuf;
        struct mtx              wv_mtx;
 
-       uint8_t                 wv_gtk;
+       uint32_t                wv_gtk;
 #define WPI_VAP_KEY(kid)       (1 << kid)
 
        int                     (*wv_newstate)(struct ieee80211vap *,
@@ -176,7 +176,7 @@ struct wpi_softc {
        struct wpi_dma_info     shared_dma;
        struct wpi_shared       *shared;
 
-       struct wpi_tx_ring      txq[WPI_DRV_NTXQUEUES];
+       struct wpi_tx_ring      txq[WPI_NTXQUEUES];
        struct mtx              txq_mtx;
        struct mtx              txq_state_mtx;
 
index f36472dc6450e14b1c4217ac3e7395111004b2c1..837f3f4e3394514af6717ae1dc32404100ee97c1 100644 (file)
@@ -119,24 +119,6 @@ g_nop_start(struct bio *bp)
                sc->sc_wrotebytes += bp->bio_length;
                failprob = sc->sc_wfailprob;
                break;
-       case BIO_DELETE:
-               sc->sc_deletes++;
-               break;
-       case BIO_GETATTR:
-               sc->sc_getattrs++;
-               break;
-       case BIO_FLUSH:
-               sc->sc_flushes++;
-               break;
-       case BIO_CMD0:
-               sc->sc_cmd0s++;
-               break;
-       case BIO_CMD1:
-               sc->sc_cmd1s++;
-               break;
-       case BIO_CMD2:
-               sc->sc_cmd2s++;
-               break;
        }
        mtx_unlock(&sc->sc_lock);
        if (failprob > 0) {
@@ -256,12 +238,6 @@ g_nop_create(struct gctl_req *req, struct g_class *mp, struct g_provider *pp,
        sc->sc_wfailprob = wfailprob;
        sc->sc_reads = 0;
        sc->sc_writes = 0;
-       sc->sc_deletes = 0;
-       sc->sc_getattrs = 0;
-       sc->sc_flushes = 0;
-       sc->sc_cmd0s = 0;
-       sc->sc_cmd1s = 0;
-       sc->sc_cmd2s = 0;
        sc->sc_readbytes = 0;
        sc->sc_wrotebytes = 0;
        mtx_init(&sc->sc_lock, "gnop lock", NULL, MTX_DEF);
@@ -626,12 +602,6 @@ g_nop_ctl_reset(struct gctl_req *req, struct g_class *mp)
                sc = pp->geom->softc;
                sc->sc_reads = 0;
                sc->sc_writes = 0;
-               sc->sc_deletes = 0;
-               sc->sc_getattrs = 0;
-               sc->sc_flushes = 0;
-               sc->sc_cmd0s = 0;
-               sc->sc_cmd1s = 0;
-               sc->sc_cmd2s = 0;
                sc->sc_readbytes = 0;
                sc->sc_wrotebytes = 0;
        }
@@ -689,12 +659,6 @@ g_nop_dumpconf(struct sbuf *sb, const char *indent, struct g_geom *gp,
        sbuf_printf(sb, "%s<Error>%d</Error>\n", indent, sc->sc_error);
        sbuf_printf(sb, "%s<Reads>%ju</Reads>\n", indent, sc->sc_reads);
        sbuf_printf(sb, "%s<Writes>%ju</Writes>\n", indent, sc->sc_writes);
-       sbuf_printf(sb, "%s<Deletes>%ju</Deletes>\n", indent, sc->sc_deletes);
-       sbuf_printf(sb, "%s<Getattrs>%ju</Getattrs>\n", indent, sc->sc_getattrs);
-       sbuf_printf(sb, "%s<Flushes>%ju</Flushes>\n", indent, sc->sc_flushes);
-       sbuf_printf(sb, "%s<Cmd0s>%ju</Cmd0s>\n", indent, sc->sc_cmd0s);
-       sbuf_printf(sb, "%s<Cmd1s>%ju</Cmd1s>\n", indent, sc->sc_cmd1s);
-       sbuf_printf(sb, "%s<Cmd2s>%ju</Cmd2s>\n", indent, sc->sc_cmd2s);
        sbuf_printf(sb, "%s<ReadBytes>%ju</ReadBytes>\n", indent,
            sc->sc_readbytes);
        sbuf_printf(sb, "%s<WroteBytes>%ju</WroteBytes>\n", indent,
index beba43e50ae5984f448400a0b2949381ff4d0e0c..b5e954ad6337dc63e2a915e94d261f6fdbdbe071 100644 (file)
@@ -65,12 +65,6 @@ struct g_nop_softc {
        u_int           sc_wfailprob;
        uintmax_t       sc_reads;
        uintmax_t       sc_writes;
-       uintmax_t       sc_deletes;
-       uintmax_t       sc_getattrs;
-       uintmax_t       sc_flushes;
-       uintmax_t       sc_cmd0s;
-       uintmax_t       sc_cmd1s;
-       uintmax_t       sc_cmd2s;
        uintmax_t       sc_readbytes;
        uintmax_t       sc_wrotebytes;
        struct mtx      sc_lock;
index 479345e43f74c6bb3e47129653a50281cb6407b2..b7693203283ac139bc3114f12814636e560a2eb1 100644 (file)
@@ -158,12 +158,16 @@ module_register(const moduledata_t *data, linker_file_t container)
        newmod = module_lookupbyname(data->name);
        if (newmod != NULL) {
                MOD_XUNLOCK;
-               printf("%s: cannot register %s from %s; already loaded from %s\n",
-                   __func__, data->name, container->filename, newmod->file->filename);
+               printf("module_register: module %s already exists!\n",
+                   data->name);
                return (EEXIST);
        }
        namelen = strlen(data->name) + 1;
        newmod = malloc(sizeof(struct module) + namelen, M_MODULE, M_WAITOK);
+       if (newmod == NULL) {
+               MOD_XUNLOCK;
+               return (ENOMEM);
+       }
        newmod->refs = 1;
        newmod->id = nextid++;
        newmod->name = (char *)(newmod + 1);
index b426f4561ef152ae04540f8eae625357432bd1b8..3d5dd11a2edbf8f199d6e4fd6f337cbfdcc78b4b 100644 (file)
@@ -162,7 +162,7 @@ struct      shminfo shminfo = {
 };
 
 static int shm_use_phys;
-static int shm_allow_removed = 1;
+static int shm_allow_removed;
 
 SYSCTL_ULONG(_kern_ipc, OID_AUTO, shmmax, CTLFLAG_RWTUN, &shminfo.shmmax, 0,
     "Maximum shared memory segment size");
index ec7761e849db9081c3287b70aa69f00c4015b485..3db44d0193585fe6408f906c1d2c872c0757bcea 100644 (file)
@@ -127,17 +127,6 @@ hint.ath.0.eepromsize=16384
 #
 # bootargs=console=ttyS0,115200 root=31:02 rootfstype=jffs2 init=/sbin/init mtdparts=ath-nor0:256k(u-boot),64k(u-boot-env),6336k(rootfs),1408k(uImage),8256k(mib0),64k(ART)
 
-# The default flash layout isn't enough to fit a freebsd kernel
-# now, so the layout has been shuffled around.
-#
-# By default it's set to:
-# 256KB uboot, 64KB uboot-env, 6336KB rootfs, 1344KB kernel, 64KB cfg, 8256MB mib0, 64KB ART
-# With 'bootcmd=bootm 0x9f680000' in the environment.
-#
-# Instead, now let's make it:
-# 256KB uboot, 64KB uboot-env, 2048MB kernel, 6144MB rootfs, 7644KB mib0, 64KB cfg, 64KB ART
-# .. and then you change the boot env to be:
-# 'bootcmd=bootm 0x9f050000'
 
 # 256KiB u-boot
 hint.map.0.at="flash/spi0"
@@ -153,37 +142,37 @@ hint.map.1.end=0x00050000 # 64k u-boot-env
 hint.map.1.name="u-boot-env"
 hint.map.1.readonly=1
 
-# 2048KiB kernel
+# 6336KiB rootfs
 hint.map.2.at="flash/spi0"
 hint.map.2.start=0x00050000
-hint.map.2.end=0x00250000      # 2048k rootfs
-hint.map.2.name="kernel"
+hint.map.2.end=0x00680000      # 6336k rootfs
+hint.map.2.name="rootfs"
 hint.map.2.readonly=1
 
-# 6144KiB rootfs
+# 1344KiB uImage
 hint.map.3.at="flash/spi0"
-hint.map.3.start=0x00250000
-hint.map.3.end=0x00850000
-hint.map.3.name="rootfs"
+hint.map.3.start=0x00680000
+hint.map.3.end=0x007d0000      # 1408k uImage, 64k off the end..
+hint.map.3.name="uImage"
 hint.map.3.readonly=1
 
-# 7644KiB mib0
+# 64KiB cfg
 hint.map.4.at="flash/spi0"
-hint.map.4.start=0x00850000
-hint.map.4.end=0x00fe0000
-hint.map.4.name="mib0"
+hint.map.4.start=0x007d0000
+hint.map.4.end=0x007e0000
+hint.map.4.name="cfg"
 hint.map.4.readonly=0
 
-# 64KiB cfg
+# 8256 KiB mib0
 hint.map.5.at="flash/spi0"
-hint.map.5.start=0x00fe0000
-hint.map.5.end=0x00ff0000
-hint.map.5.name="cfg"
-hint.map.5.readonly=0
+hint.map.5.start=0x007e0000
+hint.map.5.end=0x00ff0000      # 64k mib0
+hint.map.5.name="mib0"
+hint.map.5.readonly=1
 
 # 64KiB ART
 hint.map.6.at="flash/spi0"
-hint.map.6.start=0x00ff0000
+hint.map.6.start=0x007f0000
 hint.map.6.end=0x01000000      # 64k ART
 hint.map.6.name="ART"
 hint.map.6.readonly=1
index a19f41bcb0708b8273763742943a589a194777ca..f0ecb4be017a817518ba0551370ced9c6320f7df 100644 (file)
@@ -50,6 +50,16 @@ device       geom_uncompress
 # Used for the static uboot partition map
 device geom_map
 
-# With only 4MB of flash, we are stuck using USB
-# for the rootfs.
-options                ROOTDEVNAME=\"ufs:da0\"
+# Boot off of the rootfs, as defined in the geom_map setup.
+# Probably, this should be a USB device as the memory available
+# compressed rootfs is simply too small for FreeBSD
+#options       ROOTDEVNAME=\"ufs:map/rootfs.uncompress\"
+
+# Boot off of a uboot tftp ramdisk kernel image.  Because the flash
+# on this unit is so small, this is the only way to do dev work.
+# For full deployment, you will *have* to use a usb storage device
+# as a rootfs and use the flash to hold the kernel only.
+options                MD_ROOT         # md device usable as a potential root device
+options                MD_ROOT_SIZE=10240
+#makeoptions   MFS_IMAGE=/tftpboot/mfsroot-tl-mr3020.img.ulzma
+options                ROOTDEVNAME=\"ufs:md0.uncompress\"
index e346a22ef3e05e1a24cf4be94393e73f03f925eb..dfabb42c14d3624df494637a34ce3f69e3cd6bbf 100644 (file)
@@ -34,10 +34,8 @@ hint.arge.1.fduplex=1
 
 # Where the ART is - last 64k in the flash
 # 0x9fff1000 ?
-hint.ath.0.eepromaddr=0x1fff1000
+hint.ath.0.eepromaddr=0x1fff0000
 hint.ath.0.eepromsize=16384
-hint.ar71xx.0.eeprom_mac_addr=0x1f01fc00
 
 # The board 16MiB flash layout in uboot env:
 #
diff --git a/usr.bin/cpio/tests/Makefile b/usr.bin/cpio/tests/Makefile
new file mode 100644 (file)
index 0000000..f2cd52d
--- /dev/null
@@ -0,0 +1,114 @@
+# $FreeBSD$
+
+LIBARCHIVEDIR= ${SRCTOP}/contrib/libarchive
+
+ATF_TESTS_SH+= functional_test
+
+PROGS+=                bsdcpio_test
+
+BINDIR=                ${TESTSDIR}
+
+.PATH: ${LIBARCHIVEDIR}/cpio
+CPIO_SRCS= cmdline.c
+
+.PATH: ${LIBARCHIVEDIR}/libarchive_fe
+CPIO_SRCS+= err.c
+
+.PATH: ${LIBARCHIVEDIR}/cpio/test
+TESTS_SRCS=    \
+       test_0.c                                \
+       test_basic.c                            \
+       test_cmdline.c                          \
+       test_extract_cpio_Z.c                   \
+       test_extract_cpio_bz2.c                 \
+       test_extract_cpio_grz.c                 \
+       test_extract_cpio_gz.c                  \
+       test_extract_cpio_lrz.c                 \
+       test_extract_cpio_lz.c                  \
+       test_extract_cpio_lzma.c                \
+       test_extract_cpio_lzo.c                 \
+       test_extract_cpio_xz.c                  \
+       test_format_newc.c                      \
+       test_gcpio_compat.c                     \
+       test_option_0.c                         \
+       test_option_B_upper.c                   \
+       test_option_C_upper.c                   \
+       test_option_J_upper.c                   \
+       test_option_L_upper.c                   \
+       test_option_Z_upper.c                   \
+       test_option_a.c                         \
+       test_option_b64encode.c                 \
+       test_option_c.c                         \
+       test_option_d.c                         \
+       test_option_f.c                         \
+       test_option_grzip.c                     \
+       test_option_help.c                      \
+       test_option_l.c                         \
+       test_option_lrzip.c                     \
+       test_option_lzma.c                      \
+       test_option_lzop.c                      \
+       test_option_m.c                         \
+       test_option_t.c                         \
+       test_option_u.c                         \
+       test_option_uuencode.c                  \
+       test_option_version.c                   \
+       test_option_xz.c                        \
+       test_option_y.c                         \
+       test_option_z.c                         \
+       test_owner_parse.c                      \
+       test_passthrough_dotdot.c               \
+       test_passthrough_reverse.c
+
+# Build the test program
+SRCS.bsdcpio_test= list.h                      \
+       ${CPIO_SRCS}                            \
+       ${TESTS_SRCS}                           \
+       main.c
+
+.PATH: ${LIBARCHIVEDIR}/test_utils
+SRCS.bsdcpio_test+=    test_utils.c
+
+CLEANFILES+= list.h
+
+CFLAGS+=       -DPLATFORM_CONFIG_H=\"${SRCTOP}/lib/libarchive/config_freebsd.h\"
+CFLAGS+=       -I${SRCTOP}/lib/libarchive -I${.OBJDIR}
+LIBADD=                archive
+
+DEBUG_FLAGS+=  -g
+CFLAGS+=       -I${.OBJDIR}
+CFLAGS+=       -I${LIBARCHIVEDIR}/cpio -I${LIBARCHIVEDIR}/libarchive_fe
+CFLAGS+=       -I${LIBARCHIVEDIR}/test_utils
+
+# Uncomment to link against dmalloc
+#LDADD+= -L/usr/local/lib -ldmalloc
+#CFLAGS+= -I/usr/local/include -DUSE_DMALLOC
+
+list.h: ${TESTS_SRCS} Makefile
+       @(cd ${LIBARCHIVEDIR}/tar/test && \
+       grep -h DEFINE_TEST ${.ALLSRC:N*Makefile}) > ${.TARGET}.tmp
+       @mv ${.TARGET}.tmp ${.TARGET}
+
+FILES+= test_extract.cpio.Z.uu
+FILES+= test_extract.cpio.bz2.uu
+FILES+= test_extract.cpio.grz.uu
+FILES+= test_extract.cpio.gz.uu
+FILES+= test_extract.cpio.lrz.uu
+FILES+= test_extract.cpio.lz.uu
+FILES+= test_extract.cpio.lzma.uu
+FILES+= test_extract.cpio.lzo.uu
+FILES+= test_extract.cpio.xz.uu
+FILES+= test_gcpio_compat_ref.bin.uu
+FILES+= test_gcpio_compat_ref.crc.uu
+FILES+= test_gcpio_compat_ref.newc.uu
+FILES+= test_gcpio_compat_ref.ustar.uu
+FILES+= test_gcpio_compat_ref_nosym.bin.uu
+FILES+= test_gcpio_compat_ref_nosym.crc.uu
+FILES+= test_gcpio_compat_ref_nosym.newc.uu
+FILES+= test_gcpio_compat_ref_nosym.ustar.uu
+FILES+= test_option_f.cpio.uu
+FILES+= test_option_m.cpio.uu
+FILES+= test_option_t.cpio.uu
+FILES+= test_option_t.stdout.uu
+FILES+= test_option_tv.stdout.uu
+
+.include <bsd.test.mk>
diff --git a/usr.bin/cpio/tests/functional_test.sh b/usr.bin/cpio/tests/functional_test.sh
new file mode 100755 (executable)
index 0000000..48116c0
--- /dev/null
@@ -0,0 +1,56 @@
+#
+# Copyright 2015 EMC Corp.
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions are
+# met:
+#
+# * Redistributions of source code must retain the above copyright
+#   notice, this list of conditions and the following disclaimer.
+# * Redistributions in binary form must reproduce the above copyright
+#   notice, this list of conditions and the following disclaimer in the
+#   documentation and/or other materials provided with the distribution.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS 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 COPYRIGHT
+# OWNER 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$
+
+SRCDIR=$(atf_get_srcdir)
+TESTER="${SRCDIR}/bsdcpio_test"
+export BSDCPIO=$(which cpio)
+
+check()
+{
+       local testcase=${1}; shift
+
+       # For some odd reason /bin/sh spuriously writes
+       # "write error on stdout" with some of the testcases
+       #
+       # Probably an issue with how they're written as it calls system(3) to
+       # clean up directories..
+       atf_check -e ignore -o ignore -s exit:0 ${TESTER} -d -r "${SRCDIR}" -v "${testcase}"
+}
+
+atf_init_test_cases()
+{
+       # Redirect stderr to stdout for the usage message because if you don't
+       # kyua list/kyua test will break:
+       # https://github.com/jmmv/kyua/issues/149
+       testcases=$(${TESTER} -h 2>&1 | awk 'p != 0 && $1 ~ /^[0-9]+:/ { print $NF } /Available tests:/ { p=1 }')
+       for testcase in ${testcases}; do
+               atf_test_case ${testcase}
+               eval "${testcase}_body() { check ${testcase}; }"
+               atf_add_test_case ${testcase}
+       done
+}
diff --git a/usr.bin/tar/tests/Makefile b/usr.bin/tar/tests/Makefile
new file mode 100644 (file)
index 0000000..5814c5e
--- /dev/null
@@ -0,0 +1,115 @@
+# $FreeBSD$
+
+LIBARCHIVEDIR= ${SRCTOP}/contrib/libarchive
+
+ATF_TESTS_SH+= functional_test
+
+BINDIR=                ${TESTSDIR}
+
+PROGS+=                bsdtar_test
+
+.PATH: ${LIBARCHIVEDIR}/tar/test
+TESTS_SRCS=    \
+       test_0.c                                \
+       test_basic.c                            \
+       test_copy.c                             \
+       test_empty_mtree.c                      \
+       test_extract_tar_bz2.c                  \
+       test_extract_tar_grz.c                  \
+       test_extract_tar_gz.c                   \
+       test_extract_tar_lrz.c                  \
+       test_extract_tar_lz.c                   \
+       test_extract_tar_lzma.c                 \
+       test_extract_tar_lzo.c                  \
+       test_extract_tar_xz.c                   \
+       test_format_newc.c                      \
+       test_help.c                             \
+       test_option_C_upper.c                   \
+       test_option_H_upper.c                   \
+       test_option_L_upper.c                   \
+       test_option_O_upper.c                   \
+       test_option_T_upper.c                   \
+       test_option_U_upper.c                   \
+       test_option_X_upper.c                   \
+       test_option_a.c                         \
+       test_option_b.c                         \
+       test_option_b64encode.c                 \
+       test_option_exclude.c                   \
+       test_option_gid_gname.c                 \
+       test_option_grzip.c                     \
+       test_option_j.c                         \
+       test_option_k.c                         \
+       test_option_keep_newer_files.c          \
+       test_option_lrzip.c                     \
+       test_option_lzma.c                      \
+       test_option_lzop.c                      \
+       test_option_n.c                         \
+       test_option_newer_than.c                \
+       test_option_nodump.c                    \
+       test_option_older_than.c                \
+       test_option_q.c                         \
+       test_option_r.c                         \
+       test_option_s.c                         \
+       test_option_uid_uname.c                 \
+       test_option_uuencode.c                  \
+       test_option_xz.c                        \
+       test_option_z.c                         \
+       test_patterns.c                         \
+       test_print_longpath.c                   \
+       test_stdio.c                            \
+       test_strip_components.c                 \
+       test_symlink_dir.c                      \
+       test_version.c
+
+# Build the test program
+SRCS.bsdtar_test=      \
+       ${TESTS_SRCS}   \
+       list.h          \
+       main.c
+
+BROKEN_TESTS=
+
+DPSRCS.bsdtar_test+=   list.h
+
+.PATH: ${LIBARCHIVEDIR}/test_utils
+SRCS.bsdtar_test+=     test_utils.c
+
+CLEANFILES+=   list.h
+
+LIBADD+=       archive
+
+DEBUG_FLAGS+=  -g
+CFLAGS+=       -DPLATFORM_CONFIG_H=\"${SRCTOP}/lib/libarchive/config_freebsd.h\"
+CFLAGS+=       -static -Wall
+
+CFLAGS+=       -I${SRCTOP}/lib/libarchive -I${.OBJDIR}
+CFLAGS+=       -I${LIBARCHIVEDIR}/tar -I${LIBARCHIVEDIR}/test_utils
+
+# Uncomment to link against dmalloc
+#LDADD+= -L/usr/local/lib -ldmalloc
+#CFLAGS+= -I/usr/local/include -DUSE_DMALLOC
+
+list.h: ${TESTS_SRCS} Makefile
+       @(cd ${LIBARCHIVEDIR}/tar/test && \
+       grep -h DEFINE_TEST ${.ALLSRC:N*Makefile}) > ${.TARGET}.tmp
+       @mv ${.TARGET}.tmp ${.TARGET}
+
+CLEANFILES+=   list.h list.h.tmp
+
+FILES+=        test_extract.tar.Z.uu
+FILES+=        test_extract.tar.bz2.uu
+FILES+=        test_extract.tar.grz.uu
+FILES+=        test_extract.tar.gz.uu
+FILES+=        test_extract.tar.lrz.uu
+FILES+=        test_extract.tar.lz.uu
+FILES+=        test_extract.tar.lzma.uu
+FILES+=        test_extract.tar.lzo.uu
+FILES+=        test_extract.tar.xz.uu
+FILES+=        test_option_keep_newer_files.tar.Z.uu
+FILES+=        test_option_s.tar.Z.uu
+FILES+=        test_patterns_2.tar.uu
+FILES+=        test_patterns_3.tar.uu
+FILES+=        test_patterns_4.tar.uu
+FILES+=        test_print_longpath.tar.Z.uu
+
+.include <bsd.test.mk>
diff --git a/usr.bin/tar/tests/functional_test.sh b/usr.bin/tar/tests/functional_test.sh
new file mode 100755 (executable)
index 0000000..ee9de1b
--- /dev/null
@@ -0,0 +1,51 @@
+#
+# Copyright 2015 EMC Corp.
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions are
+# met:
+#
+# * Redistributions of source code must retain the above copyright
+#   notice, this list of conditions and the following disclaimer.
+# * Redistributions in binary form must reproduce the above copyright
+#   notice, this list of conditions and the following disclaimer in the
+#   documentation and/or other materials provided with the distribution.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS 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 COPYRIGHT
+# OWNER 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$
+
+export BSDTAR=$(which tar)
+SRCDIR=$(atf_get_srcdir)
+TESTER="${SRCDIR}/bsdtar_test"
+
+check()
+{
+       local testcase=${1}; shift
+
+       atf_check -o ignore -s exit:0 ${TESTER} -d -r "${SRCDIR}" -v "${testcase}"
+}
+
+atf_init_test_cases()
+{
+       # Redirect stderr to stdout for the usage message because if you don't
+       # kyua list/kyua test will break:
+       # https://github.com/jmmv/kyua/issues/149
+       testcases=$(${TESTER} -h 2>&1 | awk 'p != 0 && $1 ~ /^[0-9]+:/ { print $NF } /Available tests:/ { p=1 }')
+       for testcase in ${testcases}; do
+               atf_test_case ${testcase}
+               eval "${testcase}_body() { check ${testcase}; }"
+               atf_add_test_case ${testcase}
+       done
+}
index 8bd11534a3b4c3dfa191bc93e48242cce37a4973..6a3d8f2d1591f8de33f521689d5c09b6982c3a0a 100644 (file)
@@ -22,7 +22,7 @@ PPP_NO_RADIUS=
 PPP_NO_SUID=
 .endif
 CONFS= ppp.conf
-CONFSDIR=      ${CONFIGDIR}/ppp
+CONFSDIR=      ${ETCDIR}/ppp
 CONFSMODE=     600
 
 .if ${MK_ATM} == "no"