Switch to netifaces() for getting interface name, fixes bug on Ubuntu where IP wasn't populated

mdns
bneg 2017-04-25 21:36:06 -07:00
parent 8d931e9167
commit eeae4ead0e
183 changed files with 30433 additions and 8 deletions

View File

@ -49,6 +49,7 @@ import sqlite3
import iptools
import threading
import pickle
import netifaces
from time import localtime, strftime
from Crypto.Random import random
@ -597,6 +598,7 @@ def lhost():
Return the local IP.
"""
if os.name != 'nt':
import fcntl
import struct
@ -621,15 +623,16 @@ def lhost():
return ip
if (ip == '' or ip.startswith('127.')) and os.name != 'nt':
interfaces = ['eth0','eth1','eth2','wlan0','wlan1','wifi0','ath0','ath1','ppp0']
interfaces = netifaces.interfaces()
for ifname in interfaces:
try:
ip = get_interface_ip(ifname)
if ip != "":
break
except:
print 'Unexpected error:', sys.exc_info()[0]
pass
if "lo" not in ifname:
try:
ip = get_interface_ip(ifname)
if ip != "":
break
except:
print 'Unexpected error:', sys.exc_info()[0]
pass
return ip

1
setup/bomutils Submodule

@ -0,0 +1 @@
Subproject commit 3f7dc2dbbc36ca1c957ec629970026f45594a52c

View File

@ -26,6 +26,7 @@ if lsb_release -d | grep -q "Fedora"; then
pip install pyOpenSSL
pip install pyinstaller
pip install zlib_wrapper
pip install netifaces
elif lsb_release -d | grep -q "Kali"; then
Release=Kali
apt-get install -y make g++ python-dev python-m2crypto swig python-pip libxml2-dev default-jdk libssl-dev
@ -39,6 +40,7 @@ elif lsb_release -d | grep -q "Kali"; then
pip install pyOpenSSL
pip install pyinstaller
pip install zlib_wrapper
pip install netifaces
elif lsb_release -d | grep -q "Ubuntu"; then
Release=Ubuntu
apt-get install -y make g++ python-dev python-m2crypto swig python-pip libxml2-dev default-jdk libssl-dev
@ -53,6 +55,7 @@ elif lsb_release -d | grep -q "Ubuntu"; then
pip install pyopenssl
pip install pyinstaller
pip install zlib_wrapper
pip install netifaces
else
echo "Unknown distro - Debian/Ubuntu Fallback"
apt-get install -y make g++ python-dev python-m2crypto swig python-pip libxml2-dev default-jdk libffi-dev libssl-dev
@ -67,6 +70,7 @@ else
pip install pyOpenSSL
pip install pyinstaller
pip install zlib_wrapper
pip install netifaces
fi
tar -xvf ../data/misc/xar-1.5.2.tar.gz
(cd xar-1.5.2 && ./configure)

155
setup/xar-1.5.2/INSTALL Normal file
View File

@ -0,0 +1,155 @@
################################################################################
#
# Building and installation instructions for the Xar source distribution.
#
################################################################################
Required: Xar's build system uses GNU make.
Required: Xar depends on libxml2's XML functionality. For more information
about libxml2, see:
http://www.xmlsoft.org/
Required: Xar depends on OpenSSL (libcrypto in particular) for MD5 and SHA1
functionality. For more information about OpenSSL, see:
http://www.openssl.org/
Required: Xar depends on zlib (libz) for data compression. For more information
about zlib, see:
http://www.zlib.net/
Optional: Xar can optionally use libbzip2 for data compression. For more
information about libbzip2, see:
http://www.bzip.org/
Optional: Regenerating the configure script requires GNU autoconf. Doing so is
only necessary when making changes to the configuration system.
################################################################################
Building Xar is in many cases as simple as typing the following commands while
in the root directory of the source tree:
./configure
make
To install, do the above, then type:
make install
Additional build targets of finer granularity include:
src_all
lib_all
Additional install targets of finer granularity include:
src_install
lib_install
Uninstall targets include:
uninstall
src_uninstall
lib_uninstall
Cleanup targets include:
clean
distclean
relclean
Note that if you are using a development version of xar, configure is
not checked into the repository. You may replace the ./configure step
above with ./autogen.sh.
################################################################################
The build system is capable of building in a different directory than the
source, so that no files are written to the source tree. In order to use this
feature, run 'configure' and 'make' while in the directory that you want to
build the software in.
Optionally, pass any of the following arguments to 'configure' (run 'configure'
with the --help option for a full list):
--prefix=<install-root-dir>
Set the base directory in which to install. For example:
./configure --prefix=/usr/local
will cause files to be installed into /usr/local/bin, /usr/local/man,
/usr/local/include, /usr/local/lib, and /usr/local/share.
--enable-autogen
Include dependency rules in the build system to automatically regenerate
files created by configure when their sources are newer. This is
only of interest when making modifications to the source code.
--with-xml2-config=<path>
If specified, use <path> as the full path (including filename) to the
xml2-config program. This is useful when there is more than one copy of
xml2-config in your shell's path, or when you want to use a copy of
xml2-config that is not in your shell's path at all.
Optionally, define environment variables when invoking configure, including (not
exclusively):
CFLAGS="?"
Pass these flags to the compiler.
CPPFLAGS="?"
Pass these flags to the C preprocessor. Note that CFLAGS is not passed
to 'cpp' when 'configure' is looking for include files, so you must use
CPPFLAGS instead if you need to help 'configure' find header files.
LD_LIBRARY_PATH="?"
'ld' uses this colon-separated list to find libraries.
LDFLAGS="?"
Pass these flags when linking.
PATH="?"
'configure' uses this to find programs.
################################################################################
Optionally, define make variables when invoking make, including (not
exclusively):
PREFIX="?"
Use this as the installation prefix.
BINDIR="?"
Use this as the installation prefix for programs.
DATADIR="?"
Use this as the installation prefix for modules and documentation.
LIBDIR="?"
Use this as the installation prefix for libraries.
INCLUDEDIR="?"
Use this as the installation prefix for header files.
MANDIR="?"
Use this as the installation prefix for man pages.
CC="?"
Use this to specify the C compiler.
CFLAGS="?"
Pass these flags to the compiler.
CPPFLAGS="?"
Pass these flags to the C preprocessor.
LDFLAGS="?"
Pass these flags when linking.
PATH="?"
Use this to search for programs used during configuration and building.

33
setup/xar-1.5.2/LICENSE Normal file
View File

@ -0,0 +1,33 @@
/*
* Copyright (c) 2005 Rob Braun
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of Rob Braun nor the names of his contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* 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.
*/
/*
* 03-Apr-2005
* DRI: Rob Braun <bbraun@opendarwin.org>
*/

108
setup/xar-1.5.2/Makefile Normal file
View File

@ -0,0 +1,108 @@
# Clear out all vpaths, then set just one (default vpath) for the main build
# directory.
vpath
vpath % .
# Clear the default suffixes, so that built-in rules are not used.
.SUFFIXES :
#
# Standard definitions.
#
SHELL := /bin/sh
CC := gcc
LD := /usr/bin/ld
AR := /usr/bin/ar
RANLIB := /usr/bin/ranlib
INSTALL := /usr/bin/install -c
AUTOCONF :=
#
# Build parameters.
#
CPPFLAGS := -D_GNU_SOURCE -I/usr/include/libxml2
CFLAGS := -Wall -g
A_CFLAGS := $(CFLAGS)
S_CFLAGS := $(CFLAGS) -fPIC -DPIC
ifeq (macho, elf)
S_CFLAGS += -dynamic
endif
LDFLAGS :=
prefix := /usr/local
bindir := /usr/local/bin
datadir := /usr/local/share
libdir := /usr/local/lib
includedir := /usr/local/include
mandir := /usr/local/man
PREFIX := $(prefix)
BINDIR := $(bindir)
DATADIR := $(datadir)
LIBDIR := $(libdir)
INCLUDEDIR := $(includedir)
MANDIR := $(mandir)
dir_names := lib src
all : $(dir_names:%=%_all)
install : $(dir_names:%=%_install)
uninstall : $(dir_names:%=%_uninstall)
clean : $(dir_names:%=%_clean)
distclean : clean $(dir_names:%=%_distclean)
rm -f config.log
rm -f config.status
rm -f cfghdrs.stamp
rm -f cfgoutputs.stamp
rm -f configure.lineno
rm -f cfghdrs.stamp include/config.h
rm -f cfgoutputs.stamp Makefile include/xar.h lib/Makefile.inc lib/libxar.la.in src/Makefile.inc xar.spec
rm -rf autom4te.cache
relclean : distclean
rm -f configure
# Include Makefile.inc files in subdirectories.
include $(dir_names:%=%/Makefile.inc)
#
# Re-configuration rules.
#
ifeq (0, 1)
configure : configure.ac
cd ./ && $(AUTOCONF)
config.status : configure
./config.status --recheck
# cfghdrs rules.
cfghdrs.stamp.in : configure.ac
echo stamp > cfghdrs.stamp.in
$(patsubst %, %.in, cfghdrs.stamp include/config.h) : config.status
cfghdrs.stamp : $(patsubst %, %.in, cfghdrs.stamp include/config.h)
./config.status
echo stamp > $@
$(filter-out cfghdrs.stamp, cfghdrs.stamp include/config.h) : cfghdrs.stamp
# cfgoutputs rules.
cfgoutputs.stamp.in : configure.ac
echo stamp > cfgoutputs.stamp.in
$(patsubst %, %.in, cfgoutputs.stamp Makefile include/xar.h lib/Makefile.inc lib/libxar.la.in src/Makefile.inc xar.spec) : config.status
cfgoutputs.stamp : $(patsubst %, %.in, cfgoutputs.stamp Makefile include/xar.h lib/Makefile.inc lib/libxar.la.in src/Makefile.inc xar.spec)
./config.status
$(filter-out \
cfgoutputs.stamp, \
$(patsubst %, %, cfgoutputs.stamp Makefile include/xar.h lib/Makefile.inc lib/libxar.la.in src/Makefile.inc xar.spec)) : cfgoutputs.stamp
endif

108
setup/xar-1.5.2/Makefile.in Normal file
View File

@ -0,0 +1,108 @@
# Clear out all vpaths, then set just one (default vpath) for the main build
# directory.
vpath
vpath % .
# Clear the default suffixes, so that built-in rules are not used.
.SUFFIXES :
#
# Standard definitions.
#
SHELL := /bin/sh
CC := @CC@
LD := @LD@
AR := @AR@
RANLIB := @RANLIB@
INSTALL := @INSTALL@
AUTOCONF := @AUTOCONF@
#
# Build parameters.
#
CPPFLAGS := @CPPFLAGS@
CFLAGS := @CFLAGS@
A_CFLAGS := $(CFLAGS)
S_CFLAGS := $(CFLAGS) -fPIC -DPIC
ifeq (macho, @abi@)
S_CFLAGS += -dynamic
endif
LDFLAGS := @LDFLAGS@
prefix := @PREFIX@
bindir := @BINDIR@
datadir := @DATADIR@
libdir := @LIBDIR@
includedir := @INCLUDEDIR@
mandir := @MANDIR@
PREFIX := $(prefix)
BINDIR := $(bindir)
DATADIR := $(datadir)
LIBDIR := $(libdir)
INCLUDEDIR := $(includedir)
MANDIR := $(mandir)
dir_names := lib src
all : $(dir_names:%=%_all)
install : $(dir_names:%=%_install)
uninstall : $(dir_names:%=%_uninstall)
clean : $(dir_names:%=%_clean)
distclean : clean $(dir_names:%=%_distclean)
rm -f @objroot@config.log
rm -f @objroot@config.status
rm -f @objroot@cfghdrs.stamp
rm -f @objroot@cfgoutputs.stamp
rm -f @objroot@configure.lineno
rm -f @cfghdrs@
rm -f @cfgoutputs@
rm -rf @objroot@autom4te.cache
relclean : distclean
rm -f @objroot@configure
# Include Makefile.inc files in subdirectories.
include $(dir_names:%=%/Makefile.inc)
#
# Re-configuration rules.
#
ifeq (@enable_autogen@, 1)
@srcroot@configure : @srcroot@configure.ac
cd ./@srcroot@ && $(AUTOCONF)
@objroot@config.status : @srcroot@configure
./@objroot@config.status --recheck
# cfghdrs rules.
@srcroot@cfghdrs.stamp.in : @srcroot@configure.ac
echo stamp > @srcroot@cfghdrs.stamp.in
$(patsubst %, @srcroot@%.in, @cfghdrs@) : @objroot@config.status
@objroot@cfghdrs.stamp : $(patsubst %, @srcroot@%.in, @cfghdrs@)
./@objroot@config.status
echo stamp > $@
$(filter-out @objroot@cfghdrs.stamp, @cfghdrs@) : @objroot@cfghdrs.stamp
# cfgoutputs rules.
@srcroot@cfgoutputs.stamp.in : @srcroot@configure.ac
echo stamp > @srcroot@cfgoutputs.stamp.in
$(patsubst %, @srcroot@%.in, @cfgoutputs@) : @objroot@config.status
@objroot@cfgoutputs.stamp : $(patsubst %, @srcroot@%.in, @cfgoutputs@)
./@objroot@config.status
$(filter-out \
@objroot@cfgoutputs.stamp, \
$(patsubst %, @objroot@%, @cfgoutputs@)) : @objroot@cfgoutputs.stamp
endif

5
setup/xar-1.5.2/TODO Normal file
View File

@ -0,0 +1,5 @@
The xar TODO exists primarily on the wiki site at:
http://wiki.opendarwin.org/index.php/Xar:Todo
Find new home for wiki

View File

@ -0,0 +1,2 @@
/* cfghdrs.stamp. Generated by configure. */
stamp

View File

@ -0,0 +1 @@
stamp

View File

@ -0,0 +1 @@
stamp

View File

@ -0,0 +1 @@
stamp

1466
setup/xar-1.5.2/config.guess vendored Executable file

File diff suppressed because it is too large Load Diff

2138
setup/xar-1.5.2/config.log Normal file

File diff suppressed because it is too large Load Diff

1014
setup/xar-1.5.2/config.status Executable file

File diff suppressed because it is too large Load Diff

1579
setup/xar-1.5.2/config.sub vendored Executable file

File diff suppressed because it is too large Load Diff

9448
setup/xar-1.5.2/configure vendored Executable file

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,361 @@
AC_PREREQ(2.59)
AC_INIT([Xar], [1.5.2], [xar-devel@googlegroups.com], [xar])
AC_CONFIG_SRCDIR([LICENSE])
dnl Revision number for libxar.
LIB_REV=1
AC_SUBST([LIB_REV])
dnl xar version variables.
XAR_MAJOR_VERSION="1"
XAR_MINOR_VERSION="5.2"
XAR_VERSION="${XAR_MAJOR_VERSION}.${XAR_MINOR_VERSION}"
AC_SUBST([XAR_MAJOR_VERSION])
AC_SUBST([XAR_MINOR_VERSION])
AC_SUBST([XAR_VERSION])
dnl
dnl Various paths.
dnl
srcroot=$srcdir
if test "x${srcroot}" = "x." ; then
srcroot=""
else
srcroot="${srcroot}/"
fi
AC_SUBST([srcroot])
abs_srcroot="`cd "$srcdir"; pwd`/"
AC_SUBST([abs_srcroot])
objroot=""
AC_SUBST([objroot])
abs_objroot="`pwd`/"
AC_SUBST([abs_objroot])
dnl Set install paths.
if test "x$prefix" = "xNONE" ; then
prefix="/usr/local"
fi
if test "x$exec_prefix" = "xNONE" ; then
exec_prefix=$prefix
fi
PREFIX=$prefix
AC_SUBST([PREFIX])
BINDIR=`eval echo $bindir`
BINDIR=`eval echo $BINDIR`
AC_SUBST([BINDIR])
DATADIR=`eval echo $datadir`
DATADIR=`eval echo $DATADIR`
AC_SUBST([DATADIR])
LIBDIR=`eval echo $libdir`
LIBDIR=`eval echo $LIBDIR`
AC_SUBST([LIBDIR])
INCLUDEDIR=`eval echo $includedir`
INCLUDEDIR=`eval echo $INCLUDEDIR`
AC_SUBST([INCLUDEDIR])
MANDIR=`eval echo $mandir`
MANDIR=`eval echo $MANDIR`
AC_SUBST([MANDIR])
cfgoutputs="cfgoutputs.stamp"
cfgoutputs="${cfgoutputs} Makefile"
cfgoutputs="${cfgoutputs} include/xar.h"
cfgoutputs="${cfgoutputs} lib/Makefile.inc"
cfgoutputs="${cfgoutputs} lib/libxar.la.in"
cfgoutputs="${cfgoutputs} src/Makefile.inc"
cfgoutputs="${cfgoutputs} xar.spec"
cfghdrs="${objroot}cfghdrs.stamp"
cfghdrs="${cfghdrs} ${objroot}include/config.h"
dnl If CFLAGS isn't defined and using gcc, set CFLAGS to something reasonable.
dnl Otherwise, just prevent autoconf from molesting CFLAGS.
CFLAGS=$CFLAGS
AC_PROG_CC
AC_SYS_LARGEFILE
if test "x$CFLAGS" = "x" ; then
no_CFLAGS="yes"
fi
if test "x$no_CFLAGS" = "xyes" -a "x$GCC" = "xyes" ; then
CFLAGS="-Wall -g"
fi
dnl Append EXTRA_CFLAGS to CFLAGS, if defined.
if test "x$EXTRA_CFLAGS" != "x" ; then
CFLAGS="$CFLAGS $EXTRA_CFLAGS"
fi
AC_PROG_CPP
AC_PROG_INSTALL
AC_PATH_PROG([LD], [ld], , [$PATH])
AC_PATH_PROG([AR], [ar], , [$PATH])
AC_PATH_PROG([RANLIB], [ranlib], , [$PATH])
AC_PATH_PROG([AUTOCONF], [autoconf], , [$PATH])
dnl Some libtool envy
#AC_ENABLE_SHARED
AC_MSG_CHECKING([whether to build shared libraries])
AC_ARG_ENABLE([shared],
[AC_HELP_STRING([--enable-shared],
[build shared libraries @<:@default=yes@:>@])],
[shared=$enableval],[shared=yes])
AC_MSG_RESULT($shared)
AC_SUBST([shared])
#AC_ENABLE_STATIC
AC_MSG_CHECKING([whether to build static libraries])
AC_ARG_ENABLE([static],
[AC_HELP_STRING([--enable-static],
[build static libraries @<:@default=yes@:>@])],
[static=$enableval],[static=yes])
AC_MSG_RESULT($static)
AC_SUBST([static])
# Make sure either enable_shared or enable_static is yes.
test "$shared" = "yes" || test "$static" = "yes"
dnl Platform-specific settings. abi and RPATH can probably be determined
dnl programmatically, but doing so is error-prone, which makes it generally
dnl not worth the trouble.
dnl
dnl Define cpp macros in CPPFLAGS, rather than doing AC_DEFINE(macro), since the
dnl definitions need to be seen before and headers are included, which is a pain
dnl to make happen otherwise.
AC_CANONICAL_HOST
case "${host}" in
*-*-darwin*)
abi="macho"
RPATH=""
;;
*-*-freebsd*)
CFLAGS="$CFLAGS"
abi="elf"
RPATH="-Wl,-rpath,"
;;
*-*-linux*)
CFLAGS="$CFLAGS"
abi="elf"
dnl Linux needs this for things like asprintf() and poll() flags.
CPPFLAGS="$CPPFLAGS -D_GNU_SOURCE"
RPATH="-Wl,-rpath,"
;;
*-*-netbsd*)
AC_MSG_CHECKING([ABI])
AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
[[#ifdef __ELF__
/* ELF */
#else
#error aout
#endif
]])],
[CFLAGS="$CFLAGS"; abi="elf"],
[abi="aout"])
AC_MSG_RESULT([$abi])
RPATH="-Wl,-rpath,"
;;
*-*-solaris2*)
CFLAGS="$CFLAGS"
abi="elf"
RPATH="-Wl,-R,"
dnl XXX Remove the following if it ends up not being useful.
dnl Solaris needs this for sigwait().
dnl CPPFLAGS="$CPPFLAGS -D_POSIX_PTHREAD_SEMANTICS"
dnl LIBS="$LIBS -lposix4 -lsocket -lnsl"
;;
*)
AC_MSG_RESULT([Unsupported operating system: ${host}])
abi="elf"
RPATH="-Wl,-rpath,"
;;
esac
AC_SUBST([abi])
AC_SUBST([RPATH])
dnl Disable rules that do automatic regeneration of configure output by default.
AC_ARG_ENABLE([autogen],
[ --enable-autogen Automatically regenerate configure output],
[if test "x$enable_autogen" = "xno" ; then
enable_autogen="0"
else
enable_autogen="1"
fi
],
[enable_autogen="0"]
)
AC_SUBST([enable_autogen])
AC_TRY_COMPILE([#include <sys/types.h>
#include <sys/acl.h>], [acl_t a], [AC_DEFINE([HAVE_SYS_ACL_H],[1], [define if you have sys/acl.h and it has a working acl_t type])])
AC_CHECK_HEADERS(ext2fs/ext2_fs.h sys/statfs.h sys/xattr.h sys/param.h sys/extattr.h libutil.h)
AC_CHECK_FUNCS(lgetxattr)
AC_CHECK_FUNCS(lsetxattr)
AC_CHECK_FUNCS(getxattr)
AC_CHECK_FUNCS(setxattr)
AC_CHECK_FUNCS(getattrlist)
AC_CHECK_FUNCS(setattrlist)
AC_CHECK_FUNCS(lchmod)
AC_CHECK_FUNCS(lchown)
AC_CHECK_FUNCS(chflags)
AC_CHECK_FUNCS(statvfs)
AC_CHECK_FUNCS(statfs)
AC_CHECK_FUNCS(strmode)
AC_CHECK_MEMBERS([struct statfs.f_fstypename],,,[#include <sys/types.h>
#include <sys/param.h>
#include <sys/mount.h>])
AC_CHECK_MEMBERS([struct statvfs.f_fstypename],,,[#include <sys/statvfs.h>])
AC_CHECK_MEMBERS([struct stat.st_flags])
AC_CHECK_SIZEOF(uid_t)
if test $ac_cv_sizeof_uid_t = "4"; then
AC_DEFINE(UID_STRING, RId32)
AC_DEFINE(UID_CAST, (uint32_t))
elif test $ac_cv_sizeof_uid_t = "8"; then
AC_DEFINE(UID_STRING, PRId64)
AC_DEFINE(UID_CAST, (uint64_t))
else
AC_ERROR(can not detect the size of your system's uid_t type)
fi
AC_CHECK_SIZEOF(gid_t)
if test $ac_cv_sizeof_gid_t = "4"; then
AC_DEFINE(GID_STRING, PRId32)
AC_DEFINE(GID_CAST, (uint32_t))
elif test $ac_cv_sizeof_gid_t = "8"; then
AC_DEFINE(GID_STRING, PRId64)
AC_DEFINE(GID_CAST, (uint64_t))
else
AC_ERROR(can not detect the size of your system's gid_t type)
fi
AC_CHECK_SIZEOF(ino_t)
if test $ac_cv_sizeof_ino_t = "4"; then
AC_DEFINE(INO_STRING, PRId32)
AC_DEFINE(INO_HEXSTRING, PRIx32)
AC_DEFINE(INO_CAST, (uint32_t))
elif test $ac_cv_sizeof_ino_t = "8"; then
AC_DEFINE(INO_STRING, PRId64)
AC_DEFINE(INO_HEXSTRING, PRIx64)
AC_DEFINE(INO_CAST, (uint64_t))
else
AC_ERROR(can not detect the size of your system's ino_t type)
fi
AC_CHECK_SIZEOF(dev_t)
if test $ac_cv_sizeof_dev_t = "4"; then
AC_DEFINE(DEV_STRING, PRId32)
AC_DEFINE(DEV_HEXSTRING, PRIx32)
AC_DEFINE(DEV_CAST, (uint32_t))
elif test $ac_cv_sizeof_dev_t = "8"; then
AC_DEFINE(DEV_STRING, PRId64)
AC_DEFINE(DEV_HEXSTRING, PRIx64)
AC_DEFINE(DEV_CAST, (uint64_t))
else
AC_ERROR(can not detect the size of your system's dev_t type)
fi
AC_CHECK_LIB(acl, acl_get_file)
dnl Check for paths
AC_PREFIX_DEFAULT(/usr/local)
AC_CHECK_FUNC([asprintf], AC_DEFINE([HAVE_ASPRINTF]))
dnl
dnl Configure libxml2.
dnl
LIBXML2_VERSION_MIN=2.6.11
have_libxml2="1"
AC_ARG_WITH([xml2-config], [ --with-xml2-config libxml2 config program],
if test "x${with_xml2_config}" = "xno" ; then
XML2_CONFIG=
else
XML2_CONFIG="${with_xml2_config}"
fi
,
XML2_CONFIG=
)
if test "x${XML2_CONFIG}" != "x" ; then
if test ! -x "${XML2_CONFIG}" ; then
AC_MSG_ERROR([Unusable or missing xml2-config: ${XML2_CONFIG}])
fi
else
AC_PATH_PROG([XML2_CONFIG], [xml2-config], , [${PATH}])
if test "x${XML2_CONFIG}" = "x" ; then
AC_MSG_ERROR([Cannot configure without xml2-config])
fi
fi
dnl Make sure the version of libxml2 found is sufficient.
AC_MSG_CHECKING([for libxml >= ${LIBXML2_VERSION_MIN}])
LIBXML2_FOUND=`2>&1 ${XML2_CONFIG} --version`
LIBXML2_MAJOR=`echo ${LIBXML2_FOUND} | tr . " " | awk '{print $1}'`
LIBXML2_MINOR=`echo ${LIBXML2_FOUND} | tr . " " | awk '{print $2}' | tr a-z " " |awk '{print $1}'`
LIBXML2_BRANCH=`echo ${LIBXML2_FOUND} | tr . " " | awk '{print $3}' | tr a-z " " |awk '{print $1}'`
if test "x${LIBXML2_BRANCH}" = "x" ; then
LIBXML2_BRANCH=0
fi
LIBXML2_MAJOR_MIN=`echo ${LIBXML2_VERSION_MIN} | tr . " " | awk '{print $1}'`
LIBXML2_MINOR_MIN=`echo ${LIBXML2_VERSION_MIN} | tr . " " | awk '{print $2}'`
LIBXML2_BRANCH_MIN=`echo ${LIBXML2_VERSION_MIN} | tr . " " | awk '{print $3}'`
if test ${LIBXML2_MAJOR} -gt ${LIBXML2_MAJOR_MIN} \
-o ${LIBXML2_MAJOR} -eq ${LIBXML2_MAJOR_MIN} \
-a ${LIBXML2_MINOR} -gt ${LIBXML2_MINOR_MIN} \
-o ${LIBXML2_MAJOR} -eq ${LIBXML2_MAJOR_MIN} \
-a ${LIBXML2_MINOR} -eq ${LIBXML2_MINOR_MIN} \
-a ${LIBXML2_BRANCH} -ge $LIBXML2_BRANCH_MIN ; then
AC_MSG_RESULT([${LIBXML2_MAJOR}.${LIBXML2_MINOR}.${LIBXML2_BRANCH}])
have_libxml2="1"
CPPFLAGS="${CPPFLAGS} `${XML2_CONFIG} --cflags`"
LIBS="${LIBS} `${XML2_CONFIG} --libs`"
else
AC_MSG_RESULT([no])
have_libxml2="0"
fi
if test "x${have_libxml2}" = "x1" ; then
dnl Final sanity check, to make sure that xmlwriter is present.
AC_CHECK_HEADER([libxml/xmlwriter.h], , [have_libxml2="0"])
fi
if test "x${have_libxml2}" = "x0" ; then
AC_MSG_ERROR([Cannot build without libxml2])
fi
dnl
dnl Configure libcrypto (part of OpenSSL).
dnl
have_libcrypto="1"
AC_CHECK_HEADERS([openssl/evp.h], , [have_libcrypto="0"])
AC_CHECK_LIB([crypto], [OpenSSL_add_all_ciphers], , [have_libcrypto="0"])
if test "x${have_libcrypto}" = "x0" ; then
AC_MSG_ERROR([Cannot build without libcrypto (OpenSSL)])
fi
dnl
dnl Configure libz.
dnl
have_libz="1"
AC_CHECK_HEADERS([zlib.h], , [have_libz="0"])
AC_CHECK_LIB([z], [deflate], , [have_libz="0"])
if test "x${have_libz}" = "x0" ; then
AC_MSG_ERROR([Cannot build without libz])
fi
dnl
dnl Configure libbz2.
dnl
have_libbz2="1"
AC_CHECK_HEADERS([bzlib.h], , [have_libbz2="0"])
AC_CHECK_LIB([bz2], [BZ2_bzCompress], , [have_libbz2="0"])
if test "x${have_libbz2}" = "x1" ; then
AC_DEFINE([HAVE_LIBBZ2])
fi
dnl
dnl Process .in files.
dnl
AC_SUBST([cfghdrs])
AC_CONFIG_HEADER([$cfghdrs])
AC_SUBST([cfgoutputs])
AC_CONFIG_FILES([$cfgoutputs])
AC_OUTPUT

View File

@ -0,0 +1,34 @@
/* include/config.h. Generated by configure. */
#define HAVE_SYS_STATFS_H 1
#define HAVE_SYS_XATTR_H 1
/* #undef HAVE_SYS_EXTATTR_H */
#define HAVE_SYS_PARAM_H 1
#define HAVE_LGETXATTR 1
#define HAVE_LSETXATTR 1
#define HAVE_GETXATTR 1
#define HAVE_SETXATTR 1
/* #undef HAVE_GETATTRLIST */
/* #undef HAVE_SETATTRLIST */
/* #undef HAVE_CHFLAGS */
#define HAVE_STATVFS 1
#define HAVE_STATFS 1
/* #undef HAVE_EXT2FS_EXT2_FS_H */
/* #undef HAVE_STRUCT_STAT_ST_FLAGS */
/* #undef HAVE_STRUCT_STATVFS_F_FSTYPENAME */
/* #undef HAVE_STRUCT_STATFS_F_FSTYPENAME */
/* #undef HAVE_SYS_ACL_H */
/* #undef HAVE_LIBUTIL_H */
#define HAVE_ASPRINTF 1
/* #undef HAVE_LIBBZ2 */
#define HAVE_LCHOWN 1
/* #undef HAVE_LCHMOD */
#define UID_STRING RId32
#define UID_CAST (uint32_t)
#define GID_STRING PRId32
#define GID_CAST (uint32_t)
#define INO_STRING PRId64
#define INO_HEXSTRING PRIx64
#define INO_CAST (uint64_t)
#define DEV_STRING PRId64
#define DEV_HEXSTRING PRIx64
#define DEV_CAST (uint64_t)

View File

@ -0,0 +1,33 @@
#undef HAVE_SYS_STATFS_H
#undef HAVE_SYS_XATTR_H
#undef HAVE_SYS_EXTATTR_H
#undef HAVE_SYS_PARAM_H
#undef HAVE_LGETXATTR
#undef HAVE_LSETXATTR
#undef HAVE_GETXATTR
#undef HAVE_SETXATTR
#undef HAVE_GETATTRLIST
#undef HAVE_SETATTRLIST
#undef HAVE_CHFLAGS
#undef HAVE_STATVFS
#undef HAVE_STATFS
#undef HAVE_EXT2FS_EXT2_FS_H
#undef HAVE_STRUCT_STAT_ST_FLAGS
#undef HAVE_STRUCT_STATVFS_F_FSTYPENAME
#undef HAVE_STRUCT_STATFS_F_FSTYPENAME
#undef HAVE_SYS_ACL_H
#undef HAVE_LIBUTIL_H
#undef HAVE_ASPRINTF
#undef HAVE_LIBBZ2
#undef HAVE_LCHOWN
#undef HAVE_LCHMOD
#undef UID_STRING
#undef UID_CAST
#undef GID_STRING
#undef GID_CAST
#undef INO_STRING
#undef INO_HEXSTRING
#undef INO_CAST
#undef DEV_STRING
#undef DEV_HEXSTRING
#undef DEV_CAST

View File

@ -0,0 +1,201 @@
/*
* Copyright (c) 2005 Rob Braun
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of Rob Braun nor the names of his contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* 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.
*/
/*
* 03-Apr-2005
* DRI: Rob Braun <bbraun@opendarwin.org>
*/
/*
* Portions Copyright 2006, Apple Computer, Inc.
* Christopher Ryan <ryanc@apple.com>
*/
#ifndef _XAR_H_
#define _XAR_H_
#define XAR_VERSION "1.5.2"
#include <sys/types.h>
#include <stdint.h>
#include <sys/stat.h>
#pragma pack(4)
struct xar_header {
uint32_t magic;
uint16_t size;
uint16_t version;
uint64_t toc_length_compressed;
uint64_t toc_length_uncompressed;
uint32_t cksum_alg;
};
#pragma pack()
typedef struct xar_header xar_header_t;
#define XAR_HEADER_MAGIC 0x78617221
#define XAR_EA_FORK "ea"
#define XAR_CKSUM_NONE 0
#define XAR_CKSUM_SHA1 1
#define XAR_CKSUM_MD5 2
typedef void *xar_errctx_t;
typedef const struct __xar_file_t *xar_file_t;
typedef const struct __xar_iter_t *xar_iter_t;
typedef const struct __xar_t *xar_t;
typedef const struct __xar_subdoc_t *xar_subdoc_t;
typedef const struct __xar_signature_t *xar_signature_t;
typedef int32_t (*err_handler)(int32_t severit, int32_t instance, xar_errctx_t ctx, void *usrctx);
/* the signed_data must be allocated durring the callback and will be released by the xar lib after the callback */
typedef int32_t (*xar_signer_callback)(xar_signature_t sig, void *context, uint8_t *data, uint32_t length, uint8_t **signed_data, uint32_t *signed_len);
#define READ 0
#define WRITE 1
/* Valid xar options & values */
#define XAR_OPT_OWNERSHIP "ownership" /* setting owner/group behavior */
#define XAR_OPT_VAL_SYMBOLIC "symbolic" /* set owner/group based on names */
#define XAR_OPT_VAL_NUMERIC "numeric" /* set owner/group based on uid/gid */
#define XAR_OPT_TOCCKSUM "toc-cksum" /* set the toc checksum algorithm */
#define XAR_OPT_FILECKSUM "file-chksum" /* set the file checksum algorithm */
#define XAR_OPT_VAL_NONE "none"
#define XAR_OPT_VAL_SHA1 "sha1"
#define XAR_OPT_VAL_MD5 "md5"
#define XAR_OPT_COMPRESSION "compression" /* set the file compression type */
#define XAR_OPT_VAL_GZIP "gzip"
#define XAR_OPT_VAL_BZIP "bzip2"
#define XAR_OPT_RSIZE "rsize" /* Read io buffer size */
#define XAR_OPT_COALESCE "coalesce" /* Coalesce identical heap blocks */
#define XAR_OPT_LINKSAME "linksame" /* Hardlink identical files */
/* xar signing algorithms */
#define XAR_SIG_SHA1RSA 1
/* xar error handler macros */
#define XAR_SEVERITY_DEBUG 1
#define XAR_SEVERITY_INFO 2
#define XAR_SEVERITY_NORMAL 3
#define XAR_SEVERITY_WARNING 4
#define XAR_SEVERITY_NONFATAL 5
#define XAR_SEVERITY_FATAL 6
#define XAR_ERR_ARCHIVE_CREATION 1
#define XAR_ERR_ARCHIVE_EXTRACTION 2
xar_t xar_open(const char *file, int32_t flags);
int xar_close(xar_t x);
xar_file_t xar_add(xar_t x, const char *path);
xar_file_t xar_add_frombuffer(xar_t x, xar_file_t parent, const char *name, char *buffer, size_t length);
xar_file_t xar_add_folder(xar_t x, xar_file_t f, const char *name, struct stat *info);
xar_file_t xar_add_frompath(xar_t x, xar_file_t parent, const char *name, const char *realpath);
xar_file_t xar_add_from_archive(xar_t x, xar_file_t parent, const char *name, xar_t sourcearchive, xar_file_t sourcefile);
int32_t xar_extract(xar_t x, xar_file_t f);
int32_t xar_extract_tofile(xar_t x, xar_file_t f, const char *path);
int32_t xar_extract_tobuffer(xar_t x, xar_file_t f, char **buffer);
int32_t xar_extract_tobuffersz(xar_t x, xar_file_t f, char **buffer, size_t *size);
int32_t xar_verify(xar_t x, xar_file_t f);
const char *xar_opt_get(xar_t x, const char *option);
int32_t xar_opt_set(xar_t x, const char *option, const char *value);
int32_t xar_prop_set(xar_file_t f, const char *key, const char *value);
int32_t xar_prop_create(xar_file_t f, const char *key, const char *value);
int32_t xar_prop_get(xar_file_t f, const char *key, const char **value);
xar_iter_t xar_iter_new();
void xar_iter_free(xar_iter_t i);
const char *xar_prop_first(xar_file_t f, xar_iter_t i);
const char *xar_prop_next(xar_iter_t i);
void xar_prop_unset(xar_file_t f, const char *key);
xar_file_t xar_file_first(xar_t x, xar_iter_t i);
xar_file_t xar_file_next(xar_iter_t i);
const char *xar_attr_get(xar_file_t f, const char *prop, const char *key);
int32_t xar_attr_set(xar_file_t f, const char *prop, const char *key, const char *value);
const char *xar_attr_first(xar_file_t f, const char *prop, xar_iter_t i);
const char *xar_attr_next(xar_iter_t i);
xar_subdoc_t xar_subdoc_new(xar_t x, const char *name);
int32_t xar_subdoc_prop_set(xar_subdoc_t s, const char *key, const char *value);
int32_t xar_subdoc_prop_get(xar_subdoc_t s, const char *key, const char **value);
int32_t xar_subdoc_attr_set(xar_subdoc_t s, const char *prop, const char *key, const char *value);
const char *xar_subdoc_attr_get(xar_subdoc_t s, const char *prop, const char *key);
xar_subdoc_t xar_subdoc_first(xar_t x);
xar_subdoc_t xar_subdoc_next(xar_subdoc_t s);
const char *xar_subdoc_name(xar_subdoc_t s);
int32_t xar_subdoc_copyout(xar_subdoc_t s, unsigned char **, unsigned int *);
int32_t xar_subdoc_copyin(xar_subdoc_t s, const unsigned char *, unsigned int);
void xar_subdoc_remove(xar_subdoc_t s);
/* signature api for adding various signature types */
xar_signature_t xar_signature_new(xar_t x,const char *type, int32_t length, xar_signer_callback callback, void *callback_context);
const char *xar_signature_type(xar_signature_t s);
xar_signature_t xar_signature_first(xar_t x);
xar_signature_t xar_signature_next(xar_signature_t s);
int32_t xar_signature_add_x509certificate(xar_signature_t sig, const uint8_t *cert_data, uint32_t cert_len );
int32_t xar_signature_get_x509certificate_count(xar_signature_t sig);
int32_t xar_signature_get_x509certificate_data(xar_signature_t sig, int32_t index, const uint8_t **cert_data, uint32_t *cert_len);
uint8_t xar_signature_copy_signed_data(xar_signature_t sig, uint8_t **data, uint32_t *length, uint8_t **signed_data, uint32_t *signed_length);
/* These are for xar modules and should never be needed from a calling app */
void xar_register_errhandler(xar_t x, err_handler callback, void *usrctx);
xar_file_t xar_err_get_file(xar_errctx_t ctx);
const char *xar_err_get_string(xar_errctx_t ctx);
int xar_err_get_errno(xar_errctx_t ctx);
void xar_err_set_file(xar_t x, xar_file_t f);
void xar_err_set_string(xar_t x, const char *str);
void xar_err_set_errno(xar_t x, int e);
void xar_err_new(xar_t x);
int32_t xar_err_callback(xar_t x, int32_t sev, int32_t err);
void xar_serialize(xar_t x, const char *file);
char *xar_get_path(xar_file_t f);
off_t xar_get_heap_offset(xar_t x);
uint64_t xar_ntoh64(uint64_t num);
#endif /* _XAR_H_ */

View File

@ -0,0 +1,201 @@
/*
* Copyright (c) 2005 Rob Braun
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of Rob Braun nor the names of his contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* 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.
*/
/*
* 03-Apr-2005
* DRI: Rob Braun <bbraun@opendarwin.org>
*/
/*
* Portions Copyright 2006, Apple Computer, Inc.
* Christopher Ryan <ryanc@apple.com>
*/
#ifndef _XAR_H_
#define _XAR_H_
#define XAR_VERSION "@XAR_VERSION@"
#include <sys/types.h>
#include <stdint.h>
#include <sys/stat.h>
#pragma pack(4)
struct xar_header {
uint32_t magic;
uint16_t size;
uint16_t version;
uint64_t toc_length_compressed;
uint64_t toc_length_uncompressed;
uint32_t cksum_alg;
};
#pragma pack()
typedef struct xar_header xar_header_t;
#define XAR_HEADER_MAGIC 0x78617221
#define XAR_EA_FORK "ea"
#define XAR_CKSUM_NONE 0
#define XAR_CKSUM_SHA1 1
#define XAR_CKSUM_MD5 2
typedef void *xar_errctx_t;
typedef const struct __xar_file_t *xar_file_t;
typedef const struct __xar_iter_t *xar_iter_t;
typedef const struct __xar_t *xar_t;
typedef const struct __xar_subdoc_t *xar_subdoc_t;
typedef const struct __xar_signature_t *xar_signature_t;
typedef int32_t (*err_handler)(int32_t severit, int32_t instance, xar_errctx_t ctx, void *usrctx);
/* the signed_data must be allocated durring the callback and will be released by the xar lib after the callback */
typedef int32_t (*xar_signer_callback)(xar_signature_t sig, void *context, uint8_t *data, uint32_t length, uint8_t **signed_data, uint32_t *signed_len);
#define READ 0
#define WRITE 1
/* Valid xar options & values */
#define XAR_OPT_OWNERSHIP "ownership" /* setting owner/group behavior */
#define XAR_OPT_VAL_SYMBOLIC "symbolic" /* set owner/group based on names */
#define XAR_OPT_VAL_NUMERIC "numeric" /* set owner/group based on uid/gid */
#define XAR_OPT_TOCCKSUM "toc-cksum" /* set the toc checksum algorithm */
#define XAR_OPT_FILECKSUM "file-chksum" /* set the file checksum algorithm */
#define XAR_OPT_VAL_NONE "none"
#define XAR_OPT_VAL_SHA1 "sha1"
#define XAR_OPT_VAL_MD5 "md5"
#define XAR_OPT_COMPRESSION "compression" /* set the file compression type */
#define XAR_OPT_VAL_GZIP "gzip"
#define XAR_OPT_VAL_BZIP "bzip2"
#define XAR_OPT_RSIZE "rsize" /* Read io buffer size */
#define XAR_OPT_COALESCE "coalesce" /* Coalesce identical heap blocks */
#define XAR_OPT_LINKSAME "linksame" /* Hardlink identical files */
/* xar signing algorithms */
#define XAR_SIG_SHA1RSA 1
/* xar error handler macros */
#define XAR_SEVERITY_DEBUG 1
#define XAR_SEVERITY_INFO 2
#define XAR_SEVERITY_NORMAL 3
#define XAR_SEVERITY_WARNING 4
#define XAR_SEVERITY_NONFATAL 5
#define XAR_SEVERITY_FATAL 6
#define XAR_ERR_ARCHIVE_CREATION 1
#define XAR_ERR_ARCHIVE_EXTRACTION 2
xar_t xar_open(const char *file, int32_t flags);
int xar_close(xar_t x);
xar_file_t xar_add(xar_t x, const char *path);
xar_file_t xar_add_frombuffer(xar_t x, xar_file_t parent, const char *name, char *buffer, size_t length);
xar_file_t xar_add_folder(xar_t x, xar_file_t f, const char *name, struct stat *info);
xar_file_t xar_add_frompath(xar_t x, xar_file_t parent, const char *name, const char *realpath);
xar_file_t xar_add_from_archive(xar_t x, xar_file_t parent, const char *name, xar_t sourcearchive, xar_file_t sourcefile);
int32_t xar_extract(xar_t x, xar_file_t f);
int32_t xar_extract_tofile(xar_t x, xar_file_t f, const char *path);
int32_t xar_extract_tobuffer(xar_t x, xar_file_t f, char **buffer);
int32_t xar_extract_tobuffersz(xar_t x, xar_file_t f, char **buffer, size_t *size);
int32_t xar_verify(xar_t x, xar_file_t f);
const char *xar_opt_get(xar_t x, const char *option);
int32_t xar_opt_set(xar_t x, const char *option, const char *value);
int32_t xar_prop_set(xar_file_t f, const char *key, const char *value);
int32_t xar_prop_create(xar_file_t f, const char *key, const char *value);
int32_t xar_prop_get(xar_file_t f, const char *key, const char **value);
xar_iter_t xar_iter_new();
void xar_iter_free(xar_iter_t i);
const char *xar_prop_first(xar_file_t f, xar_iter_t i);
const char *xar_prop_next(xar_iter_t i);
void xar_prop_unset(xar_file_t f, const char *key);
xar_file_t xar_file_first(xar_t x, xar_iter_t i);
xar_file_t xar_file_next(xar_iter_t i);
const char *xar_attr_get(xar_file_t f, const char *prop, const char *key);
int32_t xar_attr_set(xar_file_t f, const char *prop, const char *key, const char *value);
const char *xar_attr_first(xar_file_t f, const char *prop, xar_iter_t i);
const char *xar_attr_next(xar_iter_t i);
xar_subdoc_t xar_subdoc_new(xar_t x, const char *name);
int32_t xar_subdoc_prop_set(xar_subdoc_t s, const char *key, const char *value);
int32_t xar_subdoc_prop_get(xar_subdoc_t s, const char *key, const char **value);
int32_t xar_subdoc_attr_set(xar_subdoc_t s, const char *prop, const char *key, const char *value);
const char *xar_subdoc_attr_get(xar_subdoc_t s, const char *prop, const char *key);
xar_subdoc_t xar_subdoc_first(xar_t x);
xar_subdoc_t xar_subdoc_next(xar_subdoc_t s);
const char *xar_subdoc_name(xar_subdoc_t s);
int32_t xar_subdoc_copyout(xar_subdoc_t s, unsigned char **, unsigned int *);
int32_t xar_subdoc_copyin(xar_subdoc_t s, const unsigned char *, unsigned int);
void xar_subdoc_remove(xar_subdoc_t s);
/* signature api for adding various signature types */
xar_signature_t xar_signature_new(xar_t x,const char *type, int32_t length, xar_signer_callback callback, void *callback_context);
const char *xar_signature_type(xar_signature_t s);
xar_signature_t xar_signature_first(xar_t x);
xar_signature_t xar_signature_next(xar_signature_t s);
int32_t xar_signature_add_x509certificate(xar_signature_t sig, const uint8_t *cert_data, uint32_t cert_len );
int32_t xar_signature_get_x509certificate_count(xar_signature_t sig);
int32_t xar_signature_get_x509certificate_data(xar_signature_t sig, int32_t index, const uint8_t **cert_data, uint32_t *cert_len);
uint8_t xar_signature_copy_signed_data(xar_signature_t sig, uint8_t **data, uint32_t *length, uint8_t **signed_data, uint32_t *signed_length);
/* These are for xar modules and should never be needed from a calling app */
void xar_register_errhandler(xar_t x, err_handler callback, void *usrctx);
xar_file_t xar_err_get_file(xar_errctx_t ctx);
const char *xar_err_get_string(xar_errctx_t ctx);
int xar_err_get_errno(xar_errctx_t ctx);
void xar_err_set_file(xar_t x, xar_file_t f);
void xar_err_set_string(xar_t x, const char *str);
void xar_err_set_errno(xar_t x, int e);
void xar_err_new(xar_t x);
int32_t xar_err_callback(xar_t x, int32_t sev, int32_t err);
void xar_serialize(xar_t x, const char *file);
char *xar_get_path(xar_file_t f);
off_t xar_get_heap_offset(xar_t x);
uint64_t xar_ntoh64(uint64_t num);
#endif /* _XAR_H_ */

250
setup/xar-1.5.2/install-sh Executable file
View File

@ -0,0 +1,250 @@
#! /bin/sh
#
# install - install a program, script, or datafile
# This comes from X11R5 (mit/util/scripts/install.sh).
#
# Copyright 1991 by the Massachusetts Institute of Technology
#
# Permission to use, copy, modify, distribute, and sell this software and its
# documentation for any purpose is hereby granted without fee, provided that
# the above copyright notice appear in all copies and that both that
# copyright notice and this permission notice appear in supporting
# documentation, and that the name of M.I.T. not be used in advertising or
# publicity pertaining to distribution of the software without specific,
# written prior permission. M.I.T. makes no representations about the
# suitability of this software for any purpose. It is provided "as is"
# without express or implied warranty.
#
# Calling this script install-sh is preferred over install.sh, to prevent
# `make' implicit rules from creating a file called install from it
# when there is no Makefile.
#
# This script is compatible with the BSD install script, but was written
# from scratch. It can only install one file at a time, a restriction
# shared with many OS's install programs.
# set DOITPROG to echo to test this script
# Don't use :- since 4.3BSD and earlier shells don't like it.
doit="${DOITPROG-}"
# put in absolute paths if you don't have them in your path; or use env. vars.
mvprog="${MVPROG-mv}"
cpprog="${CPPROG-cp}"
chmodprog="${CHMODPROG-chmod}"
chownprog="${CHOWNPROG-chown}"
chgrpprog="${CHGRPPROG-chgrp}"
stripprog="${STRIPPROG-strip}"
rmprog="${RMPROG-rm}"
mkdirprog="${MKDIRPROG-mkdir}"
transformbasename=""
transform_arg=""
instcmd="$mvprog"
chmodcmd="$chmodprog 0755"
chowncmd=""
chgrpcmd=""
stripcmd=""
rmcmd="$rmprog -f"
mvcmd="$mvprog"
src=""
dst=""
dir_arg=""
while [ x"$1" != x ]; do
case $1 in
-c) instcmd="$cpprog"
shift
continue;;
-d) dir_arg=true
shift
continue;;
-m) chmodcmd="$chmodprog $2"
shift
shift
continue;;
-o) chowncmd="$chownprog $2"
shift
shift
continue;;
-g) chgrpcmd="$chgrpprog $2"
shift
shift
continue;;
-s) stripcmd="$stripprog"
shift
continue;;
-t=*) transformarg=`echo $1 | sed 's/-t=//'`
shift
continue;;
-b=*) transformbasename=`echo $1 | sed 's/-b=//'`
shift
continue;;
*) if [ x"$src" = x ]
then
src=$1
else
# this colon is to work around a 386BSD /bin/sh bug
:
dst=$1
fi
shift
continue;;
esac
done
if [ x"$src" = x ]
then
echo "install: no input file specified"
exit 1
else
true
fi
if [ x"$dir_arg" != x ]; then
dst=$src
src=""
if [ -d $dst ]; then
instcmd=:
else
instcmd=mkdir
fi
else
# Waiting for this to be detected by the "$instcmd $src $dsttmp" command
# might cause directories to be created, which would be especially bad
# if $src (and thus $dsttmp) contains '*'.
if [ -f $src -o -d $src ]
then
true
else
echo "install: $src does not exist"
exit 1
fi
if [ x"$dst" = x ]
then
echo "install: no destination specified"
exit 1
else
true
fi
# If destination is a directory, append the input filename; if your system
# does not like double slashes in filenames, you may need to add some logic
if [ -d $dst ]
then
dst="$dst"/`basename $src`
else
true
fi
fi
## this sed command emulates the dirname command
dstdir=`echo $dst | sed -e 's,[^/]*$,,;s,/$,,;s,^$,.,'`
# Make sure that the destination directory exists.
# this part is taken from Noah Friedman's mkinstalldirs script
# Skip lots of stat calls in the usual case.
if [ ! -d "$dstdir" ]; then
defaultIFS='
'
IFS="${IFS-${defaultIFS}}"
oIFS="${IFS}"
# Some sh's can't handle IFS=/ for some reason.
IFS='%'
set - `echo ${dstdir} | sed -e 's@/@%@g' -e 's@^%@/@'`
IFS="${oIFS}"
pathcomp=''
while [ $# -ne 0 ] ; do
pathcomp="${pathcomp}${1}"
shift
if [ ! -d "${pathcomp}" ] ;
then
$mkdirprog "${pathcomp}"
else
true
fi
pathcomp="${pathcomp}/"
done
fi
if [ x"$dir_arg" != x ]
then
$doit $instcmd $dst &&
if [ x"$chowncmd" != x ]; then $doit $chowncmd $dst; else true ; fi &&
if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dst; else true ; fi &&
if [ x"$stripcmd" != x ]; then $doit $stripcmd $dst; else true ; fi &&
if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dst; else true ; fi
else
# If we're going to rename the final executable, determine the name now.
if [ x"$transformarg" = x ]
then
dstfile=`basename $dst`
else
dstfile=`basename $dst $transformbasename |
sed $transformarg`$transformbasename
fi
# don't allow the sed command to completely eliminate the filename
if [ x"$dstfile" = x ]
then
dstfile=`basename $dst`
else
true
fi
# Make a temp file name in the proper directory.
dsttmp=$dstdir/#inst.$$#
# Move or copy the file name to the temp name
$doit $instcmd $src $dsttmp &&
trap "rm -f ${dsttmp}" 0 &&
# and set any options; do chmod last to preserve setuid bits
# If any of these fail, we abort the whole thing. If we want to
# ignore errors from any of these, just make sure not to ignore
# errors from the above "$doit $instcmd $src $dsttmp" command.
if [ x"$chowncmd" != x ]; then $doit $chowncmd $dsttmp; else true;fi &&
if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dsttmp; else true;fi &&
if [ x"$stripcmd" != x ]; then $doit $stripcmd $dsttmp; else true;fi &&
if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dsttmp; else true;fi &&
# Now rename the file to the real destination.
$doit $rmcmd -f $dstdir/$dstfile &&
$doit $mvcmd $dsttmp $dstdir/$dstfile
fi &&
exit 0

View File

@ -0,0 +1 @@
../libxar.a

View File

@ -0,0 +1 @@
../libxar.so

View File

@ -0,0 +1,202 @@
#
# File lists.
#
# Internal headers.
LIBXAR_IINCS := asprintf.h
LIBXAR_IINCS := $(patsubst %, include/%, $(LIBXAR_IINCS))
LIBXAR_IINCS += include/config.h
# Headers.
LIBXAR_INCS :=
LIBXAR_INCS := $(patsubst %, include/%, $(LIBXAR_INCS))
LIBXAR_INCS += include/xar.h
# Sources.
LIBXAR_SRCS := archive.c arcmod.c b64.c bzxar.c darwinattr.c data.c ea.c err.c
LIBXAR_SRCS += ext2.c fbsdattr.c filetree.c io.c linuxattr.c hash.c signature.c stat.c
LIBXAR_SRCS += subdoc.c util.c zxar.c script.c macho.c
LIBXAR_SRCS := $(patsubst %, lib/%, $(LIBXAR_SRCS))
# Libraries. librxar is created such that it's possible to run xar without
# first installing libxar.
LIBXAR_LANAME := libxar.la
LIBXAR_ANAME := libxar.a
ifeq (elf, elf)
LIBRXAR_SNAME := librxar.so.1
LIBRXAR_LNAME := librxar.so
LIBRXAR_L := lib/$(LIBRXAR_LNAME)
LIBXAR_SNAME := libxar.so.1
LIBXAR_LNAME := libxar.so
LIBXAR_L := lib/$(LIBXAR_LNAME)
endif
ifeq (macho, elf)
LIBRXAR_SNAME := librxar.1.dylib
LIBRXAR_LNAME := librxar.dylib
LIBRXAR_L := lib/$(LIBRXAR_LNAME)
LIBXAR_SNAME := libxar.1.dylib
LIBXAR_LNAME := libxar.dylib
LIBXAR_L := lib/$(LIBXAR_LNAME)
endif
ifeq (aout, elf)
LIBRXAR_SNAME := librxar.so.1.0
LIBRXAR_LNAME :=
LIBRXAR_L :=
LIBXAR_SNAME := libxar.so.1.0
LIBXAR_LNAME :=
LIBXAR_L :=
endif
LIBXAR_LA := lib/$(LIBXAR_LANAME)
LIBXAR_A := lib/$(LIBXAR_ANAME)
LIBRXAR_S := lib/$(LIBRXAR_SNAME)
LIBXAR_S := lib/$(LIBXAR_SNAME)
#
# Include generated dependency files.
#
-include $(LIBXAR_SRCS:%.c=%.d)
LDFLAGS := -Llib $(LDFLAGS)
#
# User make'ables.
#
lib_all : lib_shared lib_static $(LIBXAR_LA)
ifeq (yes, yes)
lib_shared : $(LIBRXAR_S) $(LIBXAR_S)
else
lib_shared :
endif
ifeq (yes, yes)
lib_static : $(LIBXAR_A)
else
lib_static :
endif
lib_install : lib_shared lib_static
/usr/bin/install -c -d $(DESTDIR)$(INCLUDEDIR)/xar
/usr/bin/install -c -m 0644 $(LIBXAR_INCS) $(DESTDIR)$(INCLUDEDIR)/xar
/usr/bin/install -c -d $(DESTDIR)$(LIBDIR)
ifeq (yes, yes)
/usr/bin/install -c -m 0755 $(LIBXAR_S) $(DESTDIR)$(LIBDIR)
ifneq ($(words "" $(LIBXAR_LNAME)), 1)
rm -f $(DESTDIR)$(LIBDIR)/$(LIBXAR_LNAME)
ln -s $(LIBXAR_SNAME) $(DESTDIR)$(LIBDIR)/$(LIBXAR_LNAME)
endif
endif
ifeq (yes, yes)
/usr/bin/install -c -m 0644 $(LIBXAR_A) $(DESTDIR)$(LIBDIR)
endif
/usr/bin/install -c -m 0644 $(LIBXAR_LA) $(DESTDIR)$(LIBDIR)
lib_uninstall :
rm -rf $(DESTDIR)$(INCLUDEDIR)/xar
ifeq (yes, yes)
rm -f $(DESTDIR)$(LIBDIR)/$(LIBXAR_SNAME)
ifneq ($(words "" $(LIBXAR_LNAME)), 1)
rm -f $(DESTDIR)$(LIBDIR)/$(LIBXAR_LNAME)
endif
endif
ifeq (yes, yes)
rm -f $(DESTDIR)$(LIBDIR)/$(LIBXAR_ANAME)
endif
rm -f $(DESTDIR)$(LIBDIR)/$(LIBXAR_LANAME)
lib_clean :
rm -f $(LIBRXAR_S) $(LIBRXAR_L)
rm -f $(LIBXAR_S) $(LIBXAR_L)
rm -f $(LIBXAR_A) $(LIBXAR_LA)
rm -f $(LIBXAR_SRCS:%.c=%.o)
rm -f $(LIBXAR_SRCS:%.c=%.d)
rm -f $(LIBXAR_SRCS:%.c=%.static.o)
rm -f $(LIBXAR_SRCS:%.c=%.static.d)
lib_distclean :
#
# Various flags.
#
CPPFLAGS := -Iinclude $(CPPFLAGS)
CPPFLAGS := -Iinclude $(CPPFLAGS)
#
# Build rules.
#
# librxar is a version of the xar library that is usable without first
# installing libxar.
$(LIBRXAR_S) : $(LIBXAR_SRCS:%.c=%.o)
@mkdir -p $(@D)
ifeq (elf, elf)
$(CC) -shared -Wl,-soname,$(LIBXAR_SNAME) -o $@ $+ -lz -lcrypto -lxml2
endif
ifeq (macho, elf)
$(CC) -dynamiclib -compatibility_version 1 -current_version 1 -install_name /home/bneg/Code/Empire/2.0_beta/setup/xar-1.5.2/$(LIBRXAR_S) -o $@ $+ $(LDFLAGS) -lz -lcrypto -lxml2
endif
ifeq (aout, elf)
$(CC) -shared -o $@ $+
endif
ifneq ($(words "" $(LIBRXAR_L)), 1)
rm -f $(LIBRXAR_L)
ln -s $(LIBRXAR_SNAME) $(LIBRXAR_L)
endif
$(LIBXAR_S) : $(LIBXAR_SRCS:%.c=%.o)
@mkdir -p $(@D)
ifeq (elf, elf)
$(CC) -shared -Wl,-soname,$(LIBXAR_SNAME) -o $@ $+ -lz -lcrypto -lxml2
endif
ifeq (macho, elf)
$(CC) -dynamiclib -compatibility_version 1 -current_version 1 -install_name $(LIBDIR)/$(LIBXAR_SNAME) -o $@ $+ $(LDFLAGS) -lz -lcrypto -lxml2
endif
ifeq (aout, elf)
$(CC) -shared -o $@ $+
endif
ifneq ($(words "" $(LIBXAR_L)), 1)
rm -f $(LIBXAR_L)
ln -s $(LIBXAR_SNAME) $(LIBXAR_L)
endif
ifeq (yes, yes)
LT_LIBXAR_SNAME := $(LIBXAR_SNAME)
LT_LIBXAR_LNAME := $(LIBXAR_LNAME)
else
LT_LIBXAR_SNAME :=
LT_LIBXAR_LNAME :=
endif
ifeq (yes, yes)
LT_LIBXAR_ANAME := $(LIBXAR_ANAME)
else
LT_LIBXAR_ANAME :=
endif
$(LIBXAR_LA) : $(LIBXAR_LA).in
@mkdir -p lib/.libs
ifeq (yes, yes)
@ln -sf ../$(LIBXAR_LNAME) lib/.libs/$(LIBXAR_LNAME)
endif
ifeq (yes, yes)
@ln -sf ../$(LIBXAR_ANAME) lib/.libs/$(LIBXAR_ANAME)
endif
sed -e s/@LIBXAR_SNAME@/$(LT_LIBXAR_SNAME)/ -e s/@LIBXAR_LNAME@/$(LT_LIBXAR_LNAME)/ -e s/@LIBXAR_ANAME@/$(LT_LIBXAR_ANAME)/ < $< > $@
$(LIBXAR_A) : $(LIBXAR_SRCS:%.c=%.static.o)
@mkdir -p $(@D)
$(AR) cvr $@ $+
$(RANLIB) $@
lib/%.o : lib/%.c
@mkdir -p $(@D)
$(CC) $(S_CFLAGS) $(CPPFLAGS) -c $< -o $@
@$(SHELL) -ec "$(CC) -MM $(CPPFLAGS) $< | sed \"s/\($(subst /,\/,$(notdir $(basename $@)))\)\.o\([ :]*\)/$(subst /,\/,$(strip $(dir $@)))\1.o \2/g\" > $(@:%.o=%.d)"
lib/%.static.o : lib/%.c
@mkdir -p $(@D)
$(CC) $(A_CFLAGS) $(CPPFLAGS) -c $< -o $@
@$(SHELL) -ec "$(CC) -MM $(CPPFLAGS) $< | sed \"s/\($(subst /,\/,$(notdir $(basename $@)))\)\.o\([ :]*\)/$(subst /,\/,$(strip $(dir $@)))\1.o \2/g\" > $(@:%.o=%.d)"

View File

@ -0,0 +1,202 @@
#
# File lists.
#
# Internal headers.
LIBXAR_IINCS := asprintf.h
LIBXAR_IINCS := $(patsubst %, @srcroot@include/%, $(LIBXAR_IINCS))
LIBXAR_IINCS += @objroot@include/config.h
# Headers.
LIBXAR_INCS :=
LIBXAR_INCS := $(patsubst %, @srcroot@include/%, $(LIBXAR_INCS))
LIBXAR_INCS += @objroot@include/xar.h
# Sources.
LIBXAR_SRCS := archive.c arcmod.c b64.c bzxar.c darwinattr.c data.c ea.c err.c
LIBXAR_SRCS += ext2.c fbsdattr.c filetree.c io.c linuxattr.c hash.c signature.c stat.c
LIBXAR_SRCS += subdoc.c util.c zxar.c script.c macho.c
LIBXAR_SRCS := $(patsubst %, @srcroot@lib/%, $(LIBXAR_SRCS))
# Libraries. librxar is created such that it's possible to run xar without
# first installing libxar.
LIBXAR_LANAME := libxar.la
LIBXAR_ANAME := libxar.a
ifeq (elf, @abi@)
LIBRXAR_SNAME := librxar.so.@LIB_REV@
LIBRXAR_LNAME := librxar.so
LIBRXAR_L := @objroot@lib/$(LIBRXAR_LNAME)
LIBXAR_SNAME := libxar.so.@LIB_REV@
LIBXAR_LNAME := libxar.so
LIBXAR_L := @objroot@lib/$(LIBXAR_LNAME)
endif
ifeq (macho, @abi@)
LIBRXAR_SNAME := librxar.@LIB_REV@.dylib
LIBRXAR_LNAME := librxar.dylib
LIBRXAR_L := @objroot@lib/$(LIBRXAR_LNAME)
LIBXAR_SNAME := libxar.@LIB_REV@.dylib
LIBXAR_LNAME := libxar.dylib
LIBXAR_L := @objroot@lib/$(LIBXAR_LNAME)
endif
ifeq (aout, @abi@)
LIBRXAR_SNAME := librxar.so.@LIB_REV@.0
LIBRXAR_LNAME :=
LIBRXAR_L :=
LIBXAR_SNAME := libxar.so.@LIB_REV@.0
LIBXAR_LNAME :=
LIBXAR_L :=
endif
LIBXAR_LA := @objroot@lib/$(LIBXAR_LANAME)
LIBXAR_A := @objroot@lib/$(LIBXAR_ANAME)
LIBRXAR_S := @objroot@lib/$(LIBRXAR_SNAME)
LIBXAR_S := @objroot@lib/$(LIBXAR_SNAME)
#
# Include generated dependency files.
#
-include $(LIBXAR_SRCS:@srcroot@%.c=@objroot@%.d)
LDFLAGS := -L@objroot@lib $(LDFLAGS)
#
# User make'ables.
#
lib_all : lib_shared lib_static $(LIBXAR_LA)
ifeq (yes, @shared@)
lib_shared : $(LIBRXAR_S) $(LIBXAR_S)
else
lib_shared :
endif
ifeq (yes, @static@)
lib_static : $(LIBXAR_A)
else
lib_static :
endif
lib_install : lib_shared lib_static
@INSTALL@ -d $(DESTDIR)$(INCLUDEDIR)/xar
@INSTALL@ -m 0644 $(LIBXAR_INCS) $(DESTDIR)$(INCLUDEDIR)/xar
@INSTALL@ -d $(DESTDIR)$(LIBDIR)
ifeq (yes, @shared@)
@INSTALL@ -m 0755 $(LIBXAR_S) $(DESTDIR)$(LIBDIR)
ifneq ($(words "" $(LIBXAR_LNAME)), 1)
rm -f $(DESTDIR)$(LIBDIR)/$(LIBXAR_LNAME)
ln -s $(LIBXAR_SNAME) $(DESTDIR)$(LIBDIR)/$(LIBXAR_LNAME)
endif
endif
ifeq (yes, @static@)
@INSTALL@ -m 0644 $(LIBXAR_A) $(DESTDIR)$(LIBDIR)
endif
@INSTALL@ -m 0644 $(LIBXAR_LA) $(DESTDIR)$(LIBDIR)
lib_uninstall :
rm -rf $(DESTDIR)$(INCLUDEDIR)/xar
ifeq (yes, @shared@)
rm -f $(DESTDIR)$(LIBDIR)/$(LIBXAR_SNAME)
ifneq ($(words "" $(LIBXAR_LNAME)), 1)
rm -f $(DESTDIR)$(LIBDIR)/$(LIBXAR_LNAME)
endif
endif
ifeq (yes, @static@)
rm -f $(DESTDIR)$(LIBDIR)/$(LIBXAR_ANAME)
endif
rm -f $(DESTDIR)$(LIBDIR)/$(LIBXAR_LANAME)
lib_clean :
rm -f $(LIBRXAR_S) $(LIBRXAR_L)
rm -f $(LIBXAR_S) $(LIBXAR_L)
rm -f $(LIBXAR_A) $(LIBXAR_LA)
rm -f $(LIBXAR_SRCS:@srcroot@%.c=@objroot@%.o)
rm -f $(LIBXAR_SRCS:@srcroot@%.c=@objroot@%.d)
rm -f $(LIBXAR_SRCS:@srcroot@%.c=@objroot@%.static.o)
rm -f $(LIBXAR_SRCS:@srcroot@%.c=@objroot@%.static.d)
lib_distclean :
#
# Various flags.
#
CPPFLAGS := -I@objroot@include $(CPPFLAGS)
CPPFLAGS := -I@srcroot@include $(CPPFLAGS)
#
# Build rules.
#
# librxar is a version of the xar library that is usable without first
# installing libxar.
$(LIBRXAR_S) : $(LIBXAR_SRCS:@srcroot@%.c=@objroot@%.o)
@mkdir -p $(@D)
ifeq (elf, @abi@)
$(CC) -shared -Wl,-soname,$(LIBXAR_SNAME) -o $@ $+ @LIBS@
endif
ifeq (macho, @abi@)
$(CC) -dynamiclib -compatibility_version @LIB_REV@ -current_version @LIB_REV@ -install_name @abs_objroot@$(LIBRXAR_S) -o $@ $+ $(LDFLAGS) @LIBS@
endif
ifeq (aout, @abi@)
$(CC) -shared -o $@ $+
endif
ifneq ($(words "" $(LIBRXAR_L)), 1)
rm -f $(LIBRXAR_L)
ln -s $(LIBRXAR_SNAME) $(LIBRXAR_L)
endif
$(LIBXAR_S) : $(LIBXAR_SRCS:@srcroot@%.c=@objroot@%.o)
@mkdir -p $(@D)
ifeq (elf, @abi@)
$(CC) -shared -Wl,-soname,$(LIBXAR_SNAME) -o $@ $+ @LIBS@
endif
ifeq (macho, @abi@)
$(CC) -dynamiclib -compatibility_version @LIB_REV@ -current_version @LIB_REV@ -install_name $(LIBDIR)/$(LIBXAR_SNAME) -o $@ $+ $(LDFLAGS) @LIBS@
endif
ifeq (aout, @abi@)
$(CC) -shared -o $@ $+
endif
ifneq ($(words "" $(LIBXAR_L)), 1)
rm -f $(LIBXAR_L)
ln -s $(LIBXAR_SNAME) $(LIBXAR_L)
endif
ifeq (yes, @shared@)
LT_LIBXAR_SNAME := $(LIBXAR_SNAME)
LT_LIBXAR_LNAME := $(LIBXAR_LNAME)
else
LT_LIBXAR_SNAME :=
LT_LIBXAR_LNAME :=
endif
ifeq (yes, @static@)
LT_LIBXAR_ANAME := $(LIBXAR_ANAME)
else
LT_LIBXAR_ANAME :=
endif
$(LIBXAR_LA) : $(LIBXAR_LA).in
@mkdir -p @objroot@lib/.libs
ifeq (yes, @shared@)
@ln -sf ../$(LIBXAR_LNAME) @objroot@lib/.libs/$(LIBXAR_LNAME)
endif
ifeq (yes, @static@)
@ln -sf ../$(LIBXAR_ANAME) @objroot@lib/.libs/$(LIBXAR_ANAME)
endif
sed -e s/@LIBXAR_SNAME@/$(LT_LIBXAR_SNAME)/ -e s/@LIBXAR_LNAME@/$(LT_LIBXAR_LNAME)/ -e s/@LIBXAR_ANAME@/$(LT_LIBXAR_ANAME)/ < $< > $@
$(LIBXAR_A) : $(LIBXAR_SRCS:@srcroot@%.c=@objroot@%.static.o)
@mkdir -p $(@D)
$(AR) cvr $@ $+
$(RANLIB) $@
@objroot@lib/%.o : @srcroot@lib/%.c
@mkdir -p $(@D)
$(CC) $(S_CFLAGS) $(CPPFLAGS) -c $< -o $@
@$(SHELL) -ec "$(CC) -MM $(CPPFLAGS) $< | sed \"s/\($(subst /,\/,$(notdir $(basename $@)))\)\.o\([ :]*\)/$(subst /,\/,$(strip $(dir $@)))\1.o \2/g\" > $(@:%.o=%.d)"
@objroot@lib/%.static.o : @srcroot@lib/%.c
@mkdir -p $(@D)
$(CC) $(A_CFLAGS) $(CPPFLAGS) -c $< -o $@
@$(SHELL) -ec "$(CC) -MM $(CPPFLAGS) $< | sed \"s/\($(subst /,\/,$(notdir $(basename $@)))\)\.o\([ :]*\)/$(subst /,\/,$(strip $(dir $@)))\1.o \2/g\" > $(@:%.o=%.d)"

View File

@ -0,0 +1,103 @@
/* Information pulled from:
* "AppleSingle/AppleDouble Formats for Foreign Files Developer's Note"
* (c) Apple Computer 1990
* File assembled by Rob Braun (bbraun@synack.net)
*/
#ifndef __APPLEDOUBLE__
#define __APPLEDOUBLE__
#include <sys/types.h>
#include <stdint.h>
/* Structure of an AppleSingle file:
* ----------------------
* | AppleSingleHeader |
* |--------------------|
* | ASH.entries # of |
* | AppleSingleEntry |
* | Descriptors |
* | 1 |
* | . |
* | . |
* | n |
* |--------------------|
* | Datablock 1 |
* |--------------------|
* | Datablock 2 |
* |--------------------|
* | Datablock n |
* ----------------------
*/
struct AppleSingleHeader {
uint32_t magic; /* Magic Number (0x00051600 for AS) */
uint32_t version; /* Version #. 0x00020000 */
char filler[16]; /* All zeros */
uint16_t entries; /* Number of entries in the file */
};
#define XAR_ASH_SIZE 26 /* sizeof(struct AppleSingleHeader) will be wrong
* due to padding. */
#define APPLESINGLE_MAGIC 0x00051600
#define APPLEDOUBLE_MAGIC 0x00051607
#define APPLESINGLE_VERSION 0x00020000
#define APPLEDOUBLE_VERSION 0x00020000
struct AppleSingleEntry {
uint32_t entry_id; /* What the entry is. See defines below */
uint32_t offset; /* offset of data, offset beginning of file */
uint32_t length; /* length of data. can be 0 */
};
/* Valid entry_id values */
/* Entries 1, 3, and 8 are typically created for all files.
* Macintosh Icon entries are rare, since those are typically in the resource
* fork.
*/
#define AS_ID_DATA 1 /* Data fork */
#define AS_ID_RESOURCE 2 /* Resource fork */
#define AS_ID_NAME 3 /* Name of the file */
#define AS_ID_COMMENT 4 /* Standard Macintosh comment */
#define AS_ID_BWICON 5 /* Standard Macintosh B&W icon */
#define AS_ID_COLORICON 6 /* Standard Macintosh Color icon */
/* There is no 7 */
#define AS_ID_DATES 8 /* File creation date, modification date, etc. */
#define AS_ID_FINDER 9 /* Finder Information */
#define AS_ID_MAC 10 /* Macintosh File information, attributes, etc. */
#define AS_ID_PRODOS 11 /* ProDOS file information */
#define AS_ID_MSDOS 12 /* MS-DOS file information */
#define AS_ID_SHORTNAME 13 /* AFP short name */
#define AS_ID_AFPINFO 14 /* AFP file information */
#define AS_ID_AFPDIR 15 /* AFP directory id */
/* 1-0x7FFFFFFF are reserved by Apple */
/* File Dates are stored as the # of seconds before or after
* 12am Jan 1, 2000 GMT. The default value is 0x80000000.
*/
struct MacTimes {
uint32_t creation;
uint32_t modification;
uint32_t backup;
uint32_t access;
};
/* Finder Information is two 16 byte quantities.
* Newly created files have all 0's in both entries.
*/
/* Macintosh File Info entry (10) a 32 bit bitmask. */
/* Entries can be placed in any order, although Apple recommends:
* Place the data block (1) last.
* Finder Info, File Dates Info, and Macintosh File Info first.
* Allocate resource for entries in 4K blocks.
*/
/* AppleDouble files are simply AppleSingle files without the data fork.
* The magic number is different as a read optimization.
*/
#endif /* __APPLEDOUBLE__ */

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,23 @@
lib/archive.o : lib/archive.c /usr/include/libxml2/libxml/xmlwriter.h \
/usr/include/libxml2/libxml/xmlversion.h \
/usr/include/libxml2/libxml/xmlexports.h \
/usr/include/libxml2/libxml/xmlIO.h \
/usr/include/libxml2/libxml/globals.h \
/usr/include/libxml2/libxml/parser.h /usr/include/libxml2/libxml/tree.h \
/usr/include/libxml2/libxml/xmlstring.h \
/usr/include/libxml2/libxml/xmlregexp.h \
/usr/include/libxml2/libxml/dict.h /usr/include/libxml2/libxml/hash.h \
/usr/include/libxml2/libxml/valid.h \
/usr/include/libxml2/libxml/xmlerror.h \
/usr/include/libxml2/libxml/list.h \
/usr/include/libxml2/libxml/xmlautomata.h \
/usr/include/libxml2/libxml/entities.h \
/usr/include/libxml2/libxml/encoding.h /usr/include/libxml2/libxml/SAX.h \
/usr/include/libxml2/libxml/xlink.h /usr/include/libxml2/libxml/SAX2.h \
/usr/include/libxml2/libxml/xmlmemory.h \
/usr/include/libxml2/libxml/threads.h \
/usr/include/libxml2/libxml/xmlreader.h \
/usr/include/libxml2/libxml/relaxng.h \
/usr/include/libxml2/libxml/xmlschemas.h include/config.h include/xar.h \
lib/filetree.h lib/ea.h lib/archive.h lib/signature.h lib/arcmod.h \
lib/io.h lib/util.h lib/subdoc.h lib/darwinattr.h

View File

@ -0,0 +1,94 @@
/*
* Copyright (c) 2005 Rob Braun
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of Rob Braun nor the names of his contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* 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.
*/
/*
* 03-Apr-2005
* DRI: Rob Braun <bbraun@opendarwin.org>
*/
/*
* Portions Copyright 2006, Apple Computer, Inc.
* Christopher Ryan <ryanc@apple.com>
*/
#ifndef _XAR_ARCHIVE_H_
#define _XAR_ARCHIVE_H_
#include <zlib.h>
#include <libxml/hash.h>
#include <openssl/evp.h>
#include <sys/types.h>
#include <sys/stat.h>
#include "xar.h"
#include "filetree.h"
struct errctx {
const char *str;
int saved_errno;
xar_file_t file;
void *usrctx;
};
struct __xar_t {
xar_prop_t props;
xar_attr_t attrs; /* archive options, such as rsize */
const char *prefix;
const char *ns;
const char *filler1;
const char *filler2;
xar_file_t files; /* file forest */
const char *filename; /* name of the archive we are operating on */
char *dirname; /* directory of the archive, used in creation */
int fd; /* open file descriptor for the archive */
int heap_fd; /* fd for tmp heap archive, used in creation */
off_t heap_offset; /* current offset within the heap */
off_t heap_len; /* current length of the heap */
xar_header_t header; /* header of the xar archive */
void *readbuf; /* buffer for reading/writing compressed toc */
size_t readbuf_len; /* length of readbuf */
size_t offset; /* offset into readbuf for keeping track
* between callbacks. */
size_t toc_count; /* current bytes read of the toc */
z_stream zs; /* gz state for compressing/decompressing toc */
char *path_prefix; /* used for distinguishing absolute paths */
err_handler ercallback; /* callback for errors/warnings */
struct errctx errctx; /* error callback context */
xar_subdoc_t subdocs; /* linked list of subdocs */
xar_signature_t signatures; /* linked list of signatures */
uint64_t last_fileid; /* unique fileid's in the archive */
xmlHashTablePtr ino_hash; /* Hash for looking up hardlinked files (add)*/
xmlHashTablePtr link_hash; /* Hash for looking up hardlinked files (extract)*/
xmlHashTablePtr csum_hash; /* Hash for looking up checksums of files */
EVP_MD_CTX toc_ctx;
int docksum;
int skipwarn;
struct stat sbcache;
};
#define XAR(x) ((struct __xar_t *)(x))
#endif /* _XAR_ARCHIVE_H_ */

Binary file not shown.

View File

@ -0,0 +1,23 @@
archive.o: lib/archive.c /usr/include/libxml2/libxml/xmlwriter.h \
/usr/include/libxml2/libxml/xmlversion.h \
/usr/include/libxml2/libxml/xmlexports.h \
/usr/include/libxml2/libxml/xmlIO.h \
/usr/include/libxml2/libxml/globals.h \
/usr/include/libxml2/libxml/parser.h /usr/include/libxml2/libxml/tree.h \
/usr/include/libxml2/libxml/xmlstring.h \
/usr/include/libxml2/libxml/xmlregexp.h \
/usr/include/libxml2/libxml/dict.h /usr/include/libxml2/libxml/hash.h \
/usr/include/libxml2/libxml/valid.h \
/usr/include/libxml2/libxml/xmlerror.h \
/usr/include/libxml2/libxml/list.h \
/usr/include/libxml2/libxml/xmlautomata.h \
/usr/include/libxml2/libxml/entities.h \
/usr/include/libxml2/libxml/encoding.h /usr/include/libxml2/libxml/SAX.h \
/usr/include/libxml2/libxml/xlink.h /usr/include/libxml2/libxml/SAX2.h \
/usr/include/libxml2/libxml/xmlmemory.h \
/usr/include/libxml2/libxml/threads.h \
/usr/include/libxml2/libxml/xmlreader.h \
/usr/include/libxml2/libxml/relaxng.h \
/usr/include/libxml2/libxml/xmlschemas.h include/config.h include/xar.h \
lib/filetree.h lib/ea.h lib/archive.h lib/signature.h lib/arcmod.h \
lib/io.h lib/util.h lib/subdoc.h lib/darwinattr.h

Binary file not shown.

View File

@ -0,0 +1,109 @@
/*
* Copyright (c) 2007 Rob Braun
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of Rob Braun nor the names of his contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* 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.
*/
/*
* 03-Apr-2005
* DRI: Rob Braun <bbraun@opendarwin.org>
*/
/*
* Portions Copyright 2006, Apple Computer, Inc.
* Christopher Ryan <ryanc@apple.com>
*/
#include "arcmod.h"
#include "stat.h"
#include "data.h"
#include "linuxattr.h"
#include "fbsdattr.h"
#include "darwinattr.h"
#include "ext2.h"
struct arcmod xar_arcmods[] = {
{ xar_stat_archive, xar_stat_extract }, /* must be first */
{ xar_linuxattr_archive, xar_linuxattr_extract },
{ xar_fbsdattr_archive, xar_fbsdattr_extract },
{ xar_darwinattr_archive, xar_darwinattr_extract },
{ xar_ext2attr_archive, xar_ext2attr_extract },
{ xar_data_archive, xar_data_extract },
/* Add new modules here */
{ NULL, xar_set_perm },
{ NULL, xar_flags_extract }
};
/* xar_arcmod_archive
* x: archive to add the file to
* f: node representing the file
* file: the filesystem path to the file
* Returns: 0 on success
* Summary: This is the entry point to actual file archival.
*/
int32_t xar_arcmod_archive(xar_t x, xar_file_t f, const char *file, const char *buffer, size_t len) {
int i;
int32_t ret;
for(i = 0; i < (sizeof(xar_arcmods)/sizeof(struct arcmod)); i++) {
if( xar_arcmods[i].archive ) {
ret = xar_arcmods[i].archive(x, f, file, buffer, len);
if( ret < 0 ) {
return ret;
}
if( ret > 0 ) {
return 0;
}
}
}
return 0;
}
/* xar_arcmod_extract
* x: archive to extract the file from
* f: node representing the file
* file: the filesystem path to the target file
* Returns: 0 on success
* Summary: This is the entry point to actual file archival.
*/
int32_t xar_arcmod_extract(xar_t x, xar_file_t f, const char *file, char *buffer, size_t len) {
int i;
int32_t ret;
for(i = 0; i < (sizeof(xar_arcmods)/sizeof(struct arcmod)); i++) {
if( xar_arcmods[i].extract ) {
ret = xar_arcmods[i].extract(x, f, file, buffer, len);
if( ret < 0 ) {
return ret;
}
if( ret > 0 ) {
return 0;
}
}
}
return 0;
}
int32_t xar_arcmod_verify(xar_t x, xar_file_t f){
return xar_data_verify(x,f);
}

View File

@ -0,0 +1,23 @@
lib/arcmod.o : lib/arcmod.c lib/arcmod.h include/xar.h lib/filetree.h \
/usr/include/libxml2/libxml/xmlwriter.h \
/usr/include/libxml2/libxml/xmlversion.h \
/usr/include/libxml2/libxml/xmlexports.h \
/usr/include/libxml2/libxml/xmlIO.h \
/usr/include/libxml2/libxml/globals.h \
/usr/include/libxml2/libxml/parser.h /usr/include/libxml2/libxml/tree.h \
/usr/include/libxml2/libxml/xmlstring.h \
/usr/include/libxml2/libxml/xmlregexp.h \
/usr/include/libxml2/libxml/dict.h /usr/include/libxml2/libxml/hash.h \
/usr/include/libxml2/libxml/valid.h \
/usr/include/libxml2/libxml/xmlerror.h \
/usr/include/libxml2/libxml/list.h \
/usr/include/libxml2/libxml/xmlautomata.h \
/usr/include/libxml2/libxml/entities.h \
/usr/include/libxml2/libxml/encoding.h /usr/include/libxml2/libxml/SAX.h \
/usr/include/libxml2/libxml/xlink.h /usr/include/libxml2/libxml/SAX2.h \
/usr/include/libxml2/libxml/xmlmemory.h \
/usr/include/libxml2/libxml/threads.h \
/usr/include/libxml2/libxml/xmlreader.h \
/usr/include/libxml2/libxml/relaxng.h \
/usr/include/libxml2/libxml/xmlschemas.h lib/ea.h lib/stat.h lib/data.h \
lib/linuxattr.h lib/fbsdattr.h lib/darwinattr.h lib/ext2.h

View File

@ -0,0 +1,58 @@
/*
* Copyright (c) 2005 Rob Braun
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of Rob Braun nor the names of his contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* 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.
*/
/*
* 03-Apr-2005
* DRI: Rob Braun <bbraun@opendarwin.org>
*/
/*
* Portions Copyright 2006, Apple Computer, Inc.
* Christopher Ryan <ryanc@apple.com>
*/
#ifndef _XAR_ARCMOD_H_
#define _XAR_ARCMOD_H_
#include "xar.h"
#include "filetree.h"
typedef int32_t (*arcmod_archive)(xar_t x, xar_file_t f, const char* file, const char *buffer, size_t len);
typedef int32_t (*arcmod_extract)(xar_t x, xar_file_t f, const char* file, char *buffer, size_t len);
struct arcmod {
arcmod_archive archive;
arcmod_extract extract;
};
int32_t xar_arcmod_archive(xar_t x, xar_file_t f, const char *file, const char *buffer, size_t len);
int32_t xar_arcmod_extract(xar_t x, xar_file_t f, const char *file, char *buffer, size_t len);
int32_t xar_arcmod_verify(xar_t x, xar_file_t f);
#endif /* _XAR_ARCMOD_H_ */

Binary file not shown.

View File

@ -0,0 +1,23 @@
arcmod.o: lib/arcmod.c lib/arcmod.h include/xar.h lib/filetree.h \
/usr/include/libxml2/libxml/xmlwriter.h \
/usr/include/libxml2/libxml/xmlversion.h \
/usr/include/libxml2/libxml/xmlexports.h \
/usr/include/libxml2/libxml/xmlIO.h \
/usr/include/libxml2/libxml/globals.h \
/usr/include/libxml2/libxml/parser.h /usr/include/libxml2/libxml/tree.h \
/usr/include/libxml2/libxml/xmlstring.h \
/usr/include/libxml2/libxml/xmlregexp.h \
/usr/include/libxml2/libxml/dict.h /usr/include/libxml2/libxml/hash.h \
/usr/include/libxml2/libxml/valid.h \
/usr/include/libxml2/libxml/xmlerror.h \
/usr/include/libxml2/libxml/list.h \
/usr/include/libxml2/libxml/xmlautomata.h \
/usr/include/libxml2/libxml/entities.h \
/usr/include/libxml2/libxml/encoding.h /usr/include/libxml2/libxml/SAX.h \
/usr/include/libxml2/libxml/xlink.h /usr/include/libxml2/libxml/SAX2.h \
/usr/include/libxml2/libxml/xmlmemory.h \
/usr/include/libxml2/libxml/threads.h \
/usr/include/libxml2/libxml/xmlreader.h \
/usr/include/libxml2/libxml/relaxng.h \
/usr/include/libxml2/libxml/xmlschemas.h lib/ea.h lib/stat.h lib/data.h \
lib/linuxattr.h lib/fbsdattr.h lib/darwinattr.h lib/ext2.h

Binary file not shown.

View File

@ -0,0 +1,92 @@
//==============================================================================
//
// Copyright (C) 2005 Jason Evans <jasone@canonware.com>. 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(s),
// this list of conditions and the following disclaimer unmodified other than
// the allowable addition of one or more copyright notices.
//
// 2. Redistributions in binary form must reproduce the above copyright
// notice(s), 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 HOLDER(S) `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 HOLDER(S) 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.
//
//==============================================================================
//
// Emulate vasprintf() and asprintf().
//
//==============================================================================
#include <stdlib.h>
#include <stdio.h>
#include <stdarg.h>
static inline int
vasprintf(char **rResult, const char *aFormat, va_list aAp)
{
int rVal;
char *result;
va_list ap;
#define XarAsprintfStartLen 16
result = (char *) malloc(XarAsprintfStartLen);
if (result == NULL)
{
rVal = -1;
goto RETURN;
}
va_copy(ap, aAp);
rVal = vsnprintf(result, XarAsprintfStartLen, aFormat, ap);
va_end(ap);
if (rVal == -1)
{
goto RETURN;
}
else if (rVal >= XarAsprintfStartLen)
{
free(result);
result = (char *) malloc(rVal + 1);
if (result == NULL)
{
rVal = -1;
goto RETURN;
}
va_copy(ap, aAp);
rVal = vsnprintf(result, rVal + 1, aFormat, aAp);
va_end(ap);
}
*rResult = result;
RETURN:
#undef XarAsprintfStartLen
return rVal;
}
static int
asprintf(char **rResult, const char *aFormat, ...)
{
int rVal;
va_list ap;
va_start(ap, aFormat);
rVal = vasprintf(rResult, aFormat, ap);
va_end(ap);
return rVal;
}

207
setup/xar-1.5.2/lib/b64.c Normal file
View File

@ -0,0 +1,207 @@
/*
* Copyright (c) 2004 Rob Braun
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of Rob Braun nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE 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.
*/
/*
* 1-Oct-2004
* DRI: Rob Braun <bbraun@synack.net>
*/
#include <stdlib.h>
#include <string.h>
static unsigned char table [] = {
'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K',
'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V',
'W', 'X', 'Y', 'Z', 'a', 'b', 'c', 'd', 'e', 'f', 'g',
'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r',
's', 't', 'u', 'v', 'w', 'x', 'y', 'z', '0', '1', '2',
'3', '4', '5', '6', '7', '8', '9', '+', '/' };
unsigned char* xar_to_base64(const unsigned char* input, int len)
{
unsigned char b6;
/*UNUSED unsigned char tmp; */
unsigned char count = 0;
int i=0;
unsigned char* output;
int outsize = (((float)len)*4/3)+5;
output = malloc(outsize);
if( !output )
return NULL;
while(1) {
if( i >= len ) {
output[count++] = '\n';
output[count++] = '\0';
return output;
}
b6 = input[i];
b6 >>= 2;
output[count++] = table[b6];
b6 = input[i++];
b6 &= 0x03;
b6 <<= 4;
if( i >= len ) {
output[count++] = table[b6];
output[count++] = '=';
output[count++] = '=';
output[count++] = '\n';
output[count++] = '\0';
return output;
}
b6 |= input[i] >> 4;
output[count++] = table[b6];
b6 = input[i++] & 0x0F;
b6 <<= 2;
if( i >= len ) {
output[count++] = table[b6];
output[count++] = '=';
output[count++] = '\n';
output[count++] = '\0';
return output;
}
b6 |= input[i] >> 6;
output[count++] = table[b6];
b6 = input[i++] & 0x3F;
output[count++] = table[b6];
}
}
#ifdef _BTEST_
int main(int argc, char* argv[]) {
unsigned char* enc = benc(argv[1], strlen(argv[1]));
printf("%s", enc);
printf("%s\n", bdec(enc, strlen(enc)));
}
#endif
/*
* The code below derives from "Secure Programming Cookbook for C and
* C++"* and adapted by Kogule, Ryo (kogule@opendarwin.org).
*
* *John Viega and Matt Messier, O'Reilly, 2003
* http://www.secureprogramming.com/
*/
static char b64revtb[256] = {
-3, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, /*0-15*/
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, /*16-31*/
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 62, -1, -1, -1, 63, /*32-47*/
52, 53, 54, 55, 56, 57, 58, 59, 60, 61, -1, -1, -1, -2, -1, -1, /*48-63*/
-1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, /*64-79*/
15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, -1, -1, -1, -1, -1, /*80-95*/
-1, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, /*96-111*/
41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, -1, -1, -1, -1, -1, /*112-127*/
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, /*128-143*/
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, /*144-159*/
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, /*160-175*/
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, /*176-191*/
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, /*192-207*/
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, /*208-223*/
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, /*224-239*/
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 /*240-255*/
};
static unsigned int raw_base64_decode(
const unsigned char *input, unsigned char *output, int len)
{
unsigned int x, i = 0, ignr = 0;
unsigned char buf[3], pad = 0;
while (i < len || !pad) {
x = b64revtb[input[i++]];
switch (x) {
case -3: /* NULL TERMINATOR */
if ((i - ignr - 1) % 4) return 1;
return 0;
case -2: /* PADDING CHARACTER */
if ((i - ignr - 1) % 4 < 2) {
/* Invalid here */
return 1;
} else if ((i - ignr - 1) % 4 == 2) {
/* Make sure there's appropriate padding */
if (input[i] != '=') return 1;
buf[2] = 0;
pad = 2;
break;
} else {
pad = 1;
break;
}
return 0;
case -1:
ignr++;
break;
default:
switch ((i - ignr - 1) % 4) {
case 0:
buf[0] = x << 2;
break;
case 1:
buf[0] |= (x >> 4);
buf[1] = x << 4;
break;
case 2:
buf[1] |= (x >> 2);
buf[2] = x << 6;
break;
case 3:
buf[2] |= x;
for (x = 0; x < 3 - pad; x++) *output++ = buf[x];
break;
}
break;
}
}
if (i > len) return 2;
for (x = 0; x < 3 - pad; x++) *output++ = buf[x];
return 0;
}
unsigned char* xar_from_base64(const unsigned char* input, int len)
{
int err;
unsigned char *output;
output = malloc(3 * (len / 4 + 1));
if (!output) return NULL;
err = raw_base64_decode(input, output, len);
if (err) {
free(output);
return NULL;
}
return output;
}

View File

@ -0,0 +1 @@
lib/b64.o : lib/b64.c

13
setup/xar-1.5.2/lib/b64.h Normal file
View File

@ -0,0 +1,13 @@
/*
* Rob Braun <bbraun@synack.net>
* 1-Oct-2004
* Copyright (c) 2004 Rob Braun. All rights reserved.
*/
#ifndef _XAR_BASE64_H_
#define _XAR_BASE64_H_
unsigned char* xar_to_base64(const unsigned char* input, int len);
unsigned char* xar_from_base64(const unsigned char* input, int len);
#endif /* _XAR_BASE64_H_ */

BIN
setup/xar-1.5.2/lib/b64.o Normal file

Binary file not shown.

View File

@ -0,0 +1 @@
b64.o: lib/b64.c

Binary file not shown.

222
setup/xar-1.5.2/lib/bzxar.c Normal file
View File

@ -0,0 +1,222 @@
/*
* Copyright (c) 2005 Rob Braun
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of Rob Braun nor the names of his contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* 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.
*/
/*
* 03-Apr-2005
* DRI: Rob Braun <bbraun@opendarwin.org>
*/
/*
* Portions Copyright 2006, Apple Computer, Inc.
* Christopher Ryan <ryanc@apple.com>
*/
#include "config.h"
#ifndef HAVE_ASPRINTF
#include "asprintf.h"
#endif
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/types.h>
#ifdef HAVE_LIBBZ2
#include <bzlib.h>
#endif
#include "xar.h"
#include "filetree.h"
#include "io.h"
#ifdef HAVE_LIBBZ2
struct _bzip_context{
uint8_t bzipcompressed;
bz_stream bz;
};
#define BZIP2_CONTEXT(x) ((struct _bzip_context *)(*x))
#endif
int xar_bzip_fromheap_done(xar_t x, xar_file_t f, xar_prop_t p, void **context);
int xar_bzip_fromheap_in(xar_t x, xar_file_t f, xar_prop_t p, void **in, size_t *inlen, void **context) {
#ifdef HAVE_LIBBZ2
const char *opt;
void *out = NULL;
size_t outlen, offset = 0;
int r;
xar_prop_t tmpp;
/* on first run, we init the context and check the compression type */
if( !BZIP2_CONTEXT(context) ) {
*context = calloc(1,sizeof(struct _bzip_context));
opt = NULL;
tmpp = xar_prop_pget(p, "encoding");
if( tmpp )
opt = xar_attr_pget(f, tmpp, "style");
if( !opt ) return 0;
if( strcmp(opt, "application/x-bzip2") != 0 ) return 0;
BZ2_bzDecompressInit(&BZIP2_CONTEXT(context)->bz, 0, 0);
BZIP2_CONTEXT(context)->bzipcompressed = 1;
if( *inlen == 0 )
return 0;
}else if( !(BZIP2_CONTEXT(context)->bzipcompressed) ){
/* once the context has been initialized, then we have already
checked the compression type, so we need only check if we
actually are compressed */
return 0;
}
outlen = *inlen;
BZIP2_CONTEXT(context)->bz.next_in = *in;
BZIP2_CONTEXT(context)->bz.avail_in = *inlen;
BZIP2_CONTEXT(context)->bz.next_out = out;
BZIP2_CONTEXT(context)->bz.avail_out = 0;
while( BZIP2_CONTEXT(context)->bz.avail_in != 0 ) {
outlen = outlen * 2;
out = realloc(out, outlen);
if( out == NULL ) abort();
BZIP2_CONTEXT(context)->bz.next_out = out + offset;
BZIP2_CONTEXT(context)->bz.avail_out = outlen - offset;
r = BZ2_bzDecompress(&BZIP2_CONTEXT(context)->bz);
if( (r != BZ_OK) && (r != BZ_STREAM_END) ) {
xar_err_new(x);
xar_err_set_file(x, f);
xar_err_set_string(x, "Error decompressing file");
xar_err_callback(x, XAR_SEVERITY_FATAL, XAR_ERR_ARCHIVE_EXTRACTION);
return -1;
}
offset += outlen - offset - BZIP2_CONTEXT(context)->bz.avail_out;
if( (r == BZ_STREAM_END) && (offset == 0) )
break;
}
free(*in);
*in = out;
*inlen = offset;
#endif /* HAVE_LIBBZ2 */
return 0;
}
int xar_bzip_fromheap_done(xar_t x, xar_file_t f, xar_prop_t p, void **context) {
#ifdef HAVE_LIBBZ2
if( !context || !BZIP2_CONTEXT(context) )
return 0;
if( BZIP2_CONTEXT(context)->bzipcompressed){
BZ2_bzDecompressEnd(&BZIP2_CONTEXT(context)->bz);
}
free(BZIP2_CONTEXT(context));
*context = NULL;
#endif /* HAVE_LIBBZ2 */
return 0;
}
int xar_bzip_toheap_done(xar_t x, xar_file_t f, xar_prop_t p, void **context) {
#ifdef HAVE_LIBBZ2
xar_prop_t tmpp;
if( BZIP2_CONTEXT(context)->bzipcompressed){
BZ2_bzCompressEnd(&BZIP2_CONTEXT(context)->bz);
tmpp = xar_prop_pset(f, p, "encoding", NULL);
if( tmpp )
xar_attr_pset(f, tmpp, "style", "application/x-bzip2");
}
free(BZIP2_CONTEXT(context));
*context = NULL;
#endif /* HAVE_LIBBZ2 */
return 0;
}
int32_t xar_bzip_toheap_in(xar_t x, xar_file_t f, xar_prop_t p, void **in, size_t *inlen, void **context) {
#ifdef HAVE_LIBBZ2
void *out = NULL;
size_t outlen, offset = 0;
int r;
const char *opt;
/* on first run, we init the context and check the compression type */
if( !BZIP2_CONTEXT(context) ) {
*context = calloc(1,sizeof(struct _bzip_context));
opt = xar_opt_get(x, XAR_OPT_COMPRESSION);
if( !opt )
return 0;
if( strcmp(opt, XAR_OPT_VAL_BZIP) != 0 )
return 0;
BZ2_bzCompressInit(&BZIP2_CONTEXT(context)->bz, 9, 0, 30);
BZIP2_CONTEXT(context)->bzipcompressed = 1;
}else if( !BZIP2_CONTEXT(context)->bzipcompressed ){
/* once the context has been initialized, then we have already
checked the compression type, so we need only check if we
actually are compressed */
return 0;
}
outlen = *inlen/2;
if(outlen == 0) outlen = 1024;
BZIP2_CONTEXT(context)->bz.next_in = *in;
BZIP2_CONTEXT(context)->bz.avail_in = *inlen;
BZIP2_CONTEXT(context)->bz.next_out = out;
BZIP2_CONTEXT(context)->bz.avail_out = 0;
do {
outlen *= 2;
out = realloc(out, outlen);
if( out == NULL ) abort();
BZIP2_CONTEXT(context)->bz.next_out = out + offset;
BZIP2_CONTEXT(context)->bz.avail_out = outlen - offset;
if( (*inlen == 0) )
r = BZ2_bzCompress(&BZIP2_CONTEXT(context)->bz, BZ_FINISH);
else
r = BZ2_bzCompress(&BZIP2_CONTEXT(context)->bz, BZ_RUN);
offset = outlen - BZIP2_CONTEXT(context)->bz.avail_out;
} while( BZIP2_CONTEXT(context)->bz.avail_in != 0 );
free(*in);
*in = out;
*inlen = offset;
#endif /* HAVE_LIBBZ2 */
return 0;
}

View File

@ -0,0 +1,22 @@
lib/bzxar.o : lib/bzxar.c include/config.h include/xar.h lib/filetree.h \
/usr/include/libxml2/libxml/xmlwriter.h \
/usr/include/libxml2/libxml/xmlversion.h \
/usr/include/libxml2/libxml/xmlexports.h \
/usr/include/libxml2/libxml/xmlIO.h \
/usr/include/libxml2/libxml/globals.h \
/usr/include/libxml2/libxml/parser.h /usr/include/libxml2/libxml/tree.h \
/usr/include/libxml2/libxml/xmlstring.h \
/usr/include/libxml2/libxml/xmlregexp.h \
/usr/include/libxml2/libxml/dict.h /usr/include/libxml2/libxml/hash.h \
/usr/include/libxml2/libxml/valid.h \
/usr/include/libxml2/libxml/xmlerror.h \
/usr/include/libxml2/libxml/list.h \
/usr/include/libxml2/libxml/xmlautomata.h \
/usr/include/libxml2/libxml/entities.h \
/usr/include/libxml2/libxml/encoding.h /usr/include/libxml2/libxml/SAX.h \
/usr/include/libxml2/libxml/xlink.h /usr/include/libxml2/libxml/SAX2.h \
/usr/include/libxml2/libxml/xmlmemory.h \
/usr/include/libxml2/libxml/threads.h \
/usr/include/libxml2/libxml/xmlreader.h \
/usr/include/libxml2/libxml/relaxng.h \
/usr/include/libxml2/libxml/xmlschemas.h lib/ea.h lib/io.h

View File

@ -0,0 +1,47 @@
/*
* Copyright (c) 2005 Rob Braun
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of Rob Braun nor the names of his contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* 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.
*/
/*
* 03-Apr-2005
* DRI: Rob Braun <bbraun@opendarwin.org>
*/
/*
* Portions Copyright 2006, Apple Computer, Inc.
* Christopher Ryan <ryanc@apple.com>
*/
#ifndef _XAR_BZLIB_H_
#define _XAR_BZLIB_H_
int xar_bzip_fromheap_in(xar_t x, xar_file_t f, xar_prop_t p, void **in, size_t *inlen, void **context);
int xar_bzip_fromheap_done(xar_t x, xar_file_t f, xar_prop_t p, void **context);
int32_t xar_bzip_toheap_in(xar_t x, xar_file_t f, xar_prop_t p, void **in, size_t *inlen, void **context);
int xar_bzip_toheap_done(xar_t x, xar_file_t f, xar_prop_t p, void **context);
#endif /* _XAR_BZLIB_H_ */

BIN
setup/xar-1.5.2/lib/bzxar.o Normal file

Binary file not shown.

View File

@ -0,0 +1,22 @@
bzxar.o: lib/bzxar.c include/config.h include/xar.h lib/filetree.h \
/usr/include/libxml2/libxml/xmlwriter.h \
/usr/include/libxml2/libxml/xmlversion.h \
/usr/include/libxml2/libxml/xmlexports.h \
/usr/include/libxml2/libxml/xmlIO.h \
/usr/include/libxml2/libxml/globals.h \
/usr/include/libxml2/libxml/parser.h /usr/include/libxml2/libxml/tree.h \
/usr/include/libxml2/libxml/xmlstring.h \
/usr/include/libxml2/libxml/xmlregexp.h \
/usr/include/libxml2/libxml/dict.h /usr/include/libxml2/libxml/hash.h \
/usr/include/libxml2/libxml/valid.h \
/usr/include/libxml2/libxml/xmlerror.h \
/usr/include/libxml2/libxml/list.h \
/usr/include/libxml2/libxml/xmlautomata.h \
/usr/include/libxml2/libxml/entities.h \
/usr/include/libxml2/libxml/encoding.h /usr/include/libxml2/libxml/SAX.h \
/usr/include/libxml2/libxml/xlink.h /usr/include/libxml2/libxml/SAX2.h \
/usr/include/libxml2/libxml/xmlmemory.h \
/usr/include/libxml2/libxml/threads.h \
/usr/include/libxml2/libxml/xmlreader.h \
/usr/include/libxml2/libxml/relaxng.h \
/usr/include/libxml2/libxml/xmlschemas.h lib/ea.h lib/io.h

Binary file not shown.

View File

@ -0,0 +1,747 @@
/*
* Copyright (c) 2004 Rob Braun
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of Rob Braun nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE 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.
*/
/*
* 24-Apr-2005
* DRI: Rob Braun <bbraun@synack.net>
*/
/*
* Portions Copyright 2006, Apple Computer, Inc.
* Christopher Ryan <ryanc@apple.com>
*/
#include "config.h"
#include <stdio.h>
#include <unistd.h>
#include <string.h>
#include <libgen.h>
#include <sys/fcntl.h>
#include <sys/stat.h>
#include <arpa/inet.h>
#include "xar.h"
#include "arcmod.h"
#include "b64.h"
#include <errno.h>
#include <string.h>
#include "util.h"
#include "linuxattr.h"
#include "io.h"
#include "appledouble.h"
#include "stat.h"
#include "archive.h"
#if defined(HAVE_SYS_XATTR_H)
#include <sys/xattr.h>
#endif
struct _darwinattr_context{
int fd;
char *finfo;
char *buf;
int len;
int off;
};
#define DARWINATTR_CONTEXT(x) ((struct _darwinattr_context *)(x))
#if defined(__APPLE__)
#ifdef HAVE_GETATTRLIST
#include <sys/attr.h>
#include <sys/vnode.h>
struct fi {
uint32_t length;
fsobj_type_t objtype;
char finderinfo[32];
};
/* finfo_read
* This is for archiving the finderinfo via the getattrlist method.
* This function is used from the nonea_archive() function.
*/
static int32_t finfo_read(xar_t x, xar_file_t f, void *buf, size_t len, void *context) {
if( len < 32 )
return -1;
if( DARWINATTR_CONTEXT(context)->finfo == NULL )
return 0;
memcpy(buf, DARWINATTR_CONTEXT(context)->finfo, 32);
DARWINATTR_CONTEXT(context)->finfo = NULL;
return 32;
}
/* finfo_write
* This is for extracting the finderinfo via the setattrlist method.
* This function is used from the nonea_extract() function.
*/
static int32_t finfo_write(xar_t x, xar_file_t f, void *buf, size_t len, void *context) {
struct attrlist attrs;
struct fi finfo;
if( len < 32 )
return -1;
if( DARWINATTR_CONTEXT(context)->finfo == NULL )
return 0;
memset(&attrs, 0, sizeof(attrs));
attrs.bitmapcount = ATTR_BIT_MAP_COUNT;
attrs.commonattr = ATTR_CMN_OBJTYPE | ATTR_CMN_FNDRINFO;
getattrlist(DARWINATTR_CONTEXT(context)->finfo, &attrs, &finfo, sizeof(finfo), 0);
attrs.commonattr = ATTR_CMN_FNDRINFO;
if( setattrlist(DARWINATTR_CONTEXT(context)->finfo, &attrs, buf, 32, 0) != 0 )
return -1;
DARWINATTR_CONTEXT(context)->finfo = NULL;
return 32;
}
#endif /* HAVE_GETATTRLIST */
/* xar_rsrc_read
* This is the read callback function for archiving the resource fork via
* the ..namedfork method. This callback is used from nonea_archive()
*/
static int32_t xar_rsrc_read(xar_t x, xar_file_t f, void *inbuf, size_t bsize, void *context) {
int32_t r;
while(1) {
r = read(DARWINATTR_CONTEXT(context)->fd, inbuf, bsize);
if( (r < 0) && (errno == EINTR) )
continue;
return r;
}
}
#endif /* __APPLE__ */
/* xar_rsrc_write
* This is the write callback function for writing the resource fork
* back to the file via ..namedfork method. This is the callback used
* in nonea_extract() and underbar_extract().
*/
static int32_t xar_rsrc_write(xar_t x, xar_file_t f, void *buf, size_t len, void *context) {
int32_t r;
size_t off = 0;
do {
r = write(DARWINATTR_CONTEXT(context)->fd, buf+off, len-off);
if( (r < 0) && (errno != EINTR) )
return r;
off += r;
} while( off < len );
return off;
}
#ifdef __APPLE__
#if defined(HAVE_GETXATTR)
static int32_t xar_ea_read(xar_t x, xar_file_t f, void *buf, size_t len, void *context) {
if( DARWINATTR_CONTEXT(context)->buf == NULL )
return 0;
if( ((DARWINATTR_CONTEXT(context)->len)-(DARWINATTR_CONTEXT(context)->off)) <= len ) {
int siz = (DARWINATTR_CONTEXT(context)->len)-(DARWINATTR_CONTEXT(context)->off);
memcpy(buf, DARWINATTR_CONTEXT(context)->buf+DARWINATTR_CONTEXT(context)->off, siz);
free(DARWINATTR_CONTEXT(context)->buf);
DARWINATTR_CONTEXT(context)->buf = NULL;
DARWINATTR_CONTEXT(context)->off = 0;
DARWINATTR_CONTEXT(context)->len = 0;
return siz;
}
memcpy(buf, DARWINATTR_CONTEXT(context)->buf+DARWINATTR_CONTEXT(context)->off, len);
DARWINATTR_CONTEXT(context)->off += len;
if( DARWINATTR_CONTEXT(context)->off == DARWINATTR_CONTEXT(context)->len ) {
free(DARWINATTR_CONTEXT(context)->buf);
DARWINATTR_CONTEXT(context)->buf = NULL;
DARWINATTR_CONTEXT(context)->off = 0;
DARWINATTR_CONTEXT(context)->len = 0;
}
return len;
}
static int32_t xar_ea_write(xar_t x, xar_file_t f, void *buf, size_t len, void *context) {
if( DARWINATTR_CONTEXT(context)->buf == NULL )
return 0;
if( DARWINATTR_CONTEXT(context)->off == DARWINATTR_CONTEXT(context)->len )
return 0;
if( ((DARWINATTR_CONTEXT(context)->len)-(DARWINATTR_CONTEXT(context)->off)) <= len ) {
int siz = (DARWINATTR_CONTEXT(context)->len)-(DARWINATTR_CONTEXT(context)->off);
memcpy((DARWINATTR_CONTEXT(context)->buf)+(DARWINATTR_CONTEXT(context)->off), buf, siz);
return siz;
}
memcpy((DARWINATTR_CONTEXT(context)->buf)+(DARWINATTR_CONTEXT(context)->off), buf, len);
DARWINATTR_CONTEXT(context)->off += len;
return len;
}
static int32_t ea_archive(xar_t x, xar_file_t f, const char* file, void *context) {
char *buf, *i;
int ret, bufsz, attrsz;
int32_t retval = 0;
if( file == NULL )
return 0;
ret = listxattr(file, NULL, 0, XATTR_NOFOLLOW);
if( ret < 0 )
return -1;
if( ret == 0 )
return 0;
bufsz = ret;
TRYAGAIN:
buf = malloc(bufsz);
if( !buf )
goto TRYAGAIN;
ret = listxattr(file, buf, bufsz, XATTR_NOFOLLOW);
if( ret < 0 ) {
switch(errno) {
case ERANGE: bufsz = bufsz*2; free(buf); goto TRYAGAIN;
case ENOTSUP: retval = 0; goto BAIL;
default: retval = -1; goto BAIL;
};
}
if( ret == 0 ) {
retval = 0;
goto BAIL;
}
attrsz = ret;
for( i = buf; (i-buf) < attrsz; i += strlen(i)+1 ) {
xar_ea_t e;
ret = getxattr(file, i, NULL, 0, 0, XATTR_NOFOLLOW);
if( ret < 0 )
continue;
DARWINATTR_CONTEXT(context)->len = ret;
DARWINATTR_CONTEXT(context)->buf = malloc(DARWINATTR_CONTEXT(context)->len);
if( !DARWINATTR_CONTEXT(context)->buf )
goto BAIL;
ret = getxattr(file, i, DARWINATTR_CONTEXT(context)->buf, DARWINATTR_CONTEXT(context)->len, 0, XATTR_NOFOLLOW);
if( ret < 0 ) {
free(DARWINATTR_CONTEXT(context)->buf);
DARWINATTR_CONTEXT(context)->buf = NULL;
DARWINATTR_CONTEXT(context)->len = 0;
continue;
}
e = xar_ea_new(f, i);
xar_attrcopy_to_heap(x, f, xar_ea_root(e), xar_ea_read, context);
}
BAIL:
free(buf);
return retval;
}
static int32_t ea_extract(xar_t x, xar_file_t f, const char* file, void *context) {
xar_prop_t p;
for(p = xar_prop_pfirst(f); p; p = xar_prop_pnext(p)) {
const char *opt;
const char *name = NULL;
int len;
xar_prop_t tmpp;
name = xar_prop_getkey(p);
if( strncmp(name, XAR_EA_FORK, strlen(XAR_EA_FORK)) )
continue;
if( strlen(name) != strlen(XAR_EA_FORK) )
continue;
opt = NULL;
tmpp = xar_prop_pget(p, "size");
if( tmpp )
opt = xar_prop_getvalue(tmpp);
if( !opt )
continue;
len = strtol(opt, NULL, 10);
DARWINATTR_CONTEXT(context)->buf = malloc(len);
if( !DARWINATTR_CONTEXT(context)->buf )
return -1;
DARWINATTR_CONTEXT(context)->len = len;
xar_attrcopy_from_heap(x, f, p, xar_ea_write, context);
name = NULL;
tmpp = xar_prop_pget(p, "name");
if( tmpp )
name = xar_prop_getvalue(tmpp);
if( !name )
continue;
setxattr(file, name, DARWINATTR_CONTEXT(context)->buf, DARWINATTR_CONTEXT(context)->len, 0, XATTR_NOFOLLOW);
free(DARWINATTR_CONTEXT(context)->buf);
DARWINATTR_CONTEXT(context)->buf = NULL;
DARWINATTR_CONTEXT(context)->len = 0;
DARWINATTR_CONTEXT(context)->off = 0;
}
return 0;
}
#endif /* HAVE_GETXATTR */
/* nonea_archive
* Archive the finderinfo and resource fork through getattrlist and
* ..namedfork methods rather than via EAs. This is mainly for 10.3
* and earlier support
*/
static int32_t nonea_archive(xar_t x, xar_file_t f, const char* file, void *context) {
char rsrcname[4096];
struct stat sb;
xar_ea_t e;
#ifdef HAVE_GETATTRLIST
struct attrlist attrs;
struct fi finfo;
int ret;
char z[32];
memset(&attrs, 0, sizeof(attrs));
attrs.bitmapcount = ATTR_BIT_MAP_COUNT;
attrs.commonattr = ATTR_CMN_OBJTYPE | ATTR_CMN_FNDRINFO;
ret = getattrlist(file, &attrs, &finfo, sizeof(finfo), 0);
if( ret != 0 )
return -1;
memset(z, 0, sizeof(z));
if( memcmp(finfo.finderinfo, z, sizeof(finfo.finderinfo)) != 0 ) {
e = xar_ea_new(f, "com.apple.FinderInfo");
DARWINATTR_CONTEXT(context)->finfo = finfo.finderinfo;
xar_attrcopy_to_heap(x, f, xar_ea_root(e), finfo_read, context);
}
#endif /* HAVE_GETATTRLIST */
memset(rsrcname, 0, sizeof(rsrcname));
snprintf(rsrcname, sizeof(rsrcname)-1, "%s/..namedfork/rsrc", file);
if( lstat(rsrcname, &sb) != 0 )
return 0;
if( sb.st_size == 0 )
return 0;
DARWINATTR_CONTEXT(context)->fd = open(rsrcname, O_RDONLY, 0);
if( DARWINATTR_CONTEXT(context)->fd < 0 )
return -1;
e = xar_ea_new(f, "com.apple.ResourceFork");
xar_attrcopy_to_heap(x, f, xar_ea_root(e), xar_rsrc_read, context);
close(DARWINATTR_CONTEXT(context)->fd);
return 0;
}
/* nonea_extract
* Extract the finderinfo and resource fork through setattrlist and
* ..namedfork methods rather than via EAs. This is mainly for 10.3
* and earlier support
*/
static int32_t nonea_extract(xar_t x, xar_file_t f, const char* file, void *context) {
char rsrcname[4096];
xar_prop_t p;
#ifdef HAVE_SETATTRLIST
struct attrlist attrs;
struct fi finfo;
int ret;
memset(&attrs, 0, sizeof(attrs));
attrs.bitmapcount = ATTR_BIT_MAP_COUNT;
attrs.commonattr = ATTR_CMN_OBJTYPE | ATTR_CMN_FNDRINFO;
ret = getattrlist(file, &attrs, &finfo, sizeof(finfo), 0);
if( ret != 0 )
return -1;
DARWINATTR_CONTEXT(context)->finfo = (char *)file;
p = xar_ea_find(f, "com.apple.ResourceFork");
if( p )
xar_attrcopy_from_heap(x, f, p, finfo_write, context);
#endif /* HAVE_SETATTRLIST */
memset(rsrcname, 0, sizeof(rsrcname));
snprintf(rsrcname, sizeof(rsrcname)-1, "%s/..namedfork/rsrc", file);
DARWINATTR_CONTEXT(context)->fd = open(rsrcname, O_RDWR|O_TRUNC);
if( DARWINATTR_CONTEXT(context)->fd < 0 )
return 0;
p = xar_ea_find(f, "com.apple.ResourceFork");
if( p )
xar_attrcopy_from_heap(x, f, p, xar_rsrc_write, context);
close(DARWINATTR_CONTEXT(context)->fd);
return 0;
}
#endif /* __APPLE__ */
/* xar_underbar_check
* Check to see if the file we're archiving is a ._ file. If so,
* stop the archival process.
*/
xar_file_t xar_underbar_check(xar_t x, xar_file_t f, const char* file, void *context) {
char *bname, *tmp;
tmp = strdup(file);
bname = basename(tmp);
if(bname && (bname[0] == '.') && (bname[1] == '_')) {
char *nonunderbar, *nupath, *tmp2, *dname;
struct stat sb;
nonunderbar = bname+2;
tmp2 = strdup(file);
dname = dirname(tmp2);
asprintf(&nupath, "%s/%s", dname, nonunderbar);
free(tmp2);
/* if there is no file that the ._ corresponds to, archive
* it like a normal file.
*/
if( stat(nupath, &sb) ) {
free(tmp);
free(nupath);
return NULL;
}
asprintf(&tmp2, "%s/..namedfork/rsrc", nupath);
/* If there is a file that the ._ file corresponds to, and
* there is no resource fork, assume the ._ file contains
* the file's resource fork, and skip it (to be picked up
* when the file is archived.
*/
if( stat(tmp2, &sb) ) {
xar_file_t tmpf;
tmpf = xar_file_find(XAR(x)->files, nupath);
if( !tmpf ) {
tmpf = xar_add(x, nupath);
}
free(nupath);
free(tmp2);
free(tmp);
return tmpf;
}
/* otherwise, we have a corresponding file and it supports
* resource forks, so we assume this is a detached ._ file
* and archive it as a real file.
*/
free(nupath);
free(tmp2);
free(tmp);
return NULL;
}
free(tmp);
return NULL;
}
#ifdef __APPLE__
/* This only really makes sense on OSX */
static int32_t underbar_archive(xar_t x, xar_file_t f, const char* file, void *context) {
struct stat sb;
char underbarname[4096], z[32];
char *dname, *bname, *tmp, *tmp2;
struct AppleSingleHeader ash;
struct AppleSingleEntry ase;
int num_entries = 0, i, r;
off_t off;
if( !file )
return 0;
tmp = strdup(file);
tmp2 = strdup(file);
dname = dirname(tmp2);
bname = basename(tmp);
memset(underbarname, 0, sizeof(underbarname));
snprintf(underbarname, sizeof(underbarname)-1, "%s/._%s", dname, bname);
free(tmp);
free(tmp2);
if( stat(underbarname, &sb) != 0 )
return 0;
DARWINATTR_CONTEXT(context)->fd = open(underbarname, O_RDONLY);
if( DARWINATTR_CONTEXT(context)->fd < 0 )
return -1;
memset(&ash, 0, sizeof(ash));
memset(&ase, 0, sizeof(ase));
r = read(DARWINATTR_CONTEXT(context)->fd, &ash, XAR_ASH_SIZE);
if( r < XAR_ASH_SIZE )
return -1;
if( ntohl(ash.magic) != APPLEDOUBLE_MAGIC )
return -1;
if( ntohl(ash.version) != APPLEDOUBLE_VERSION )
return -1;
off = XAR_ASH_SIZE;
num_entries = ntohs(ash.entries);
for(i = 0; i < num_entries; i++) {
off_t entoff;
r = read(DARWINATTR_CONTEXT(context)->fd, &ase, sizeof(ase));
if( r < sizeof(ase) )
return -1;
off+=r;
if( ntohl(ase.entry_id) == AS_ID_FINDER ) {
xar_ea_t e;
entoff = (off_t)ntohl(ase.offset);
if( lseek(DARWINATTR_CONTEXT(context)->fd, entoff, SEEK_SET) == -1 )
return -1;
r = read(DARWINATTR_CONTEXT(context)->fd, z, sizeof(z));
if( r < sizeof(z) )
return -1;
DARWINATTR_CONTEXT(context)->finfo = z;
e = xar_ea_new(f, "com.apple.FinderInfo");
xar_attrcopy_to_heap(x, f, xar_ea_root(e), finfo_read, context);
if( lseek(DARWINATTR_CONTEXT(context)->fd, (off_t)off, SEEK_SET) == -1 )
return -1;
}
if( ntohl(ase.entry_id) == AS_ID_RESOURCE ) {
xar_ea_t e;
entoff = (off_t)ntohl(ase.offset);
if( lseek(DARWINATTR_CONTEXT(context)->fd, entoff, SEEK_SET) == -1 )
return -1;
e = xar_ea_new(f, "com.apple.ResourceFork");
xar_attrcopy_to_heap(x, f, xar_ea_root(e), xar_rsrc_read, context);
if( lseek(DARWINATTR_CONTEXT(context)->fd, (off_t)off, SEEK_SET) == -1 )
return -1;
}
}
close(DARWINATTR_CONTEXT(context)->fd);
DARWINATTR_CONTEXT(context)->fd = 0;
return 0;
}
#endif
/* underbar_extract
* Extract finderinfo and resource fork information to an appledouble
* ._ file.
*/
static int32_t underbar_extract(xar_t x, xar_file_t f, const char* file, void *context) {
char underbarname[4096];
char *dname, *bname, *tmp, *tmp2;
const char *rsrclenstr;
struct AppleSingleHeader ash;
struct AppleSingleEntry ase;
int num_entries = 0, rsrclen = 0, have_rsrc = 0, have_fi = 0;
xar_prop_t p;
xar_prop_t rfprop = NULL, fiprop = NULL;
fiprop = xar_ea_find(f, "com.apple.FinderInfo");
if( fiprop ) {
have_fi = 1;
num_entries++;
}
rfprop = xar_ea_find(f, "com.apple.ResourceFork");
if( rfprop ) {
have_rsrc = 1;
num_entries++;
}
if( num_entries == 0 )
return 0;
tmp = strdup(file);
tmp2 = strdup(file);
dname = dirname(tmp2);
bname = basename(tmp);
memset(underbarname, 0, sizeof(underbarname));
snprintf(underbarname, sizeof(underbarname)-1, "%s/._%s", dname, bname);
free(tmp);
free(tmp2);
DARWINATTR_CONTEXT(context)->fd = open(underbarname, O_RDWR | O_CREAT | O_TRUNC, 0);
if( DARWINATTR_CONTEXT(context)->fd < 0 )
return -1;
rsrclenstr = NULL;
if( rfprop ) {
p = xar_prop_pget(rfprop, "size");
if( p )
rsrclenstr = xar_prop_getvalue(p);
if( rsrclenstr )
rsrclen = strtol(rsrclenstr, NULL, 10);
}
memset(&ash, 0, sizeof(ash));
memset(&ase, 0, sizeof(ase));
ash.magic = htonl(APPLEDOUBLE_MAGIC);
ash.version = htonl(APPLEDOUBLE_VERSION);
ash.entries = htons(num_entries);
write(DARWINATTR_CONTEXT(context)->fd, &ash, XAR_ASH_SIZE);
ase.offset = htonl(XAR_ASH_SIZE + ntohs(ash.entries)*12);
if( have_fi ) {
ase.entry_id = htonl(AS_ID_FINDER);
ase.length = htonl(32);
write(DARWINATTR_CONTEXT(context)->fd, &ase, 12);
}
if( have_rsrc ) {
ase.entry_id = htonl(AS_ID_RESOURCE);
ase.offset = htonl(ntohl(ase.offset) + ntohl(ase.length));
ase.length = htonl(rsrclen);
write(DARWINATTR_CONTEXT(context)->fd, &ase, 12);
}
if( have_fi )
xar_attrcopy_from_heap(x, f, fiprop, xar_rsrc_write, context);
if( have_rsrc )
xar_attrcopy_from_heap(x, f, rfprop, xar_rsrc_write, context);
close(DARWINATTR_CONTEXT(context)->fd);
DARWINATTR_CONTEXT(context)->fd = 0;
xar_set_perm(x, f, underbarname, NULL, 0 );
return 0;
}
#if defined(__APPLE__)
static int32_t stragglers_archive(xar_t x, xar_file_t f, const char* file, void *context) {
#ifdef HAVE_GETATTRLIST
struct fits {
uint32_t length;
struct timespec ts;
};
struct fits fts;
struct attrlist attrs;
int ret;
memset(&attrs, 0, sizeof(attrs));
attrs.bitmapcount = ATTR_BIT_MAP_COUNT;
attrs.commonattr = ATTR_CMN_CRTIME;
ret = getattrlist(file, &attrs, &fts, sizeof(fts), 0);
if( ret == 0 ) {
xar_prop_t tmpp;
tmpp = xar_prop_new(f, NULL);
if( tmpp ) {
char tmpc[128];
struct tm tm;
xar_prop_setkey(tmpp, "FinderCreateTime");
xar_prop_setvalue(tmpp, NULL);
memset(tmpc, 0, sizeof(tmpc));
gmtime_r(&fts.ts.tv_sec, &tm);
strftime(tmpc, sizeof(tmpc), "%FT%T", &tm);
xar_prop_pset(f, tmpp, "time", tmpc);
memset(tmpc, 0, sizeof(tmpc));
sprintf(tmpc, "%ld", fts.ts.tv_nsec);
xar_prop_pset(f, tmpp, "nanoseconds", tmpc);
}
}
#endif
return 0;
}
static int32_t stragglers_extract(xar_t x, xar_file_t f, const char* file, void *context) {
#ifdef HAVE_GETATTRLIST
const char *tmpc = NULL;
struct tm tm;
struct timespec ts;
struct attrlist attrs;
xar_prop_get(f, "FinderCreateTime/time", &tmpc);
if( tmpc ) {
strptime(tmpc, "%FT%T", &tm);
ts.tv_sec = timegm(&tm);
xar_prop_get(f, "FinderCreateTime/nanoseconds", &tmpc);
ts.tv_nsec = strtol(tmpc, NULL, 10);
memset(&attrs, 0, sizeof(attrs));
attrs.bitmapcount = ATTR_BIT_MAP_COUNT;
attrs.commonattr = ATTR_CMN_CRTIME;
setattrlist(file, &attrs, &ts, sizeof(ts), 0);
}
#endif
return 0;
}
#endif /* __APPLE__ */
int32_t xar_darwinattr_archive(xar_t x, xar_file_t f, const char* file, const char *buffer, size_t len)
{
struct _darwinattr_context context;
memset(&context,0,sizeof(struct _darwinattr_context));
#if defined(__APPLE__)
if( len )
return 0;
stragglers_archive(x, f, file, (void *)&context);
#if defined(HAVE_GETXATTR)
if( ea_archive(x, f, file, (void *)&context) == 0 )
return 0;
#endif
if( nonea_archive(x, f, file, (void *)&context) == 0 )
return 0;
return underbar_archive(x, f, file, (void *)&context);
#endif /* __APPLE__ */
return 0;
}
int32_t xar_darwinattr_extract(xar_t x, xar_file_t f, const char* file, char *buffer, size_t len)
{
struct _darwinattr_context context;
memset(&context,0,sizeof(struct _darwinattr_context));
#if defined(__APPLE__)
if( len )
return 0;
stragglers_extract(x, f, file, (void *)&context);
#if defined(HAVE_GETXATTR)
if( ea_extract(x, f, file, (void *)&context) == 0 )
return 0;
#endif
if( nonea_extract(x, f, file, (void *)&context) == 0 )
return 0;
#endif /* __APPLE__ */
return underbar_extract(x, f, file, (void *)&context);
}

View File

@ -0,0 +1,23 @@
lib/darwinattr.o : lib/darwinattr.c include/config.h include/xar.h \
lib/arcmod.h lib/filetree.h /usr/include/libxml2/libxml/xmlwriter.h \
/usr/include/libxml2/libxml/xmlversion.h \
/usr/include/libxml2/libxml/xmlexports.h \
/usr/include/libxml2/libxml/xmlIO.h \
/usr/include/libxml2/libxml/globals.h \
/usr/include/libxml2/libxml/parser.h /usr/include/libxml2/libxml/tree.h \
/usr/include/libxml2/libxml/xmlstring.h \
/usr/include/libxml2/libxml/xmlregexp.h \
/usr/include/libxml2/libxml/dict.h /usr/include/libxml2/libxml/hash.h \
/usr/include/libxml2/libxml/valid.h \
/usr/include/libxml2/libxml/xmlerror.h \
/usr/include/libxml2/libxml/list.h \
/usr/include/libxml2/libxml/xmlautomata.h \
/usr/include/libxml2/libxml/entities.h \
/usr/include/libxml2/libxml/encoding.h /usr/include/libxml2/libxml/SAX.h \
/usr/include/libxml2/libxml/xlink.h /usr/include/libxml2/libxml/SAX2.h \
/usr/include/libxml2/libxml/xmlmemory.h \
/usr/include/libxml2/libxml/threads.h \
/usr/include/libxml2/libxml/xmlreader.h \
/usr/include/libxml2/libxml/relaxng.h \
/usr/include/libxml2/libxml/xmlschemas.h lib/ea.h lib/b64.h lib/util.h \
lib/linuxattr.h lib/io.h lib/appledouble.h lib/stat.h lib/archive.h

View File

@ -0,0 +1,43 @@
/*
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of Apple nor the names of any contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* 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.
*/
/*
* Rob Braun <bbraun@synack.net>
* 23-Apr-2005
* Copyright (c) 2004 Rob Braun. All rights reserved.
*/
/*
* Portions Copyright 2006, Apple Computer, Inc.
* Christopher Ryan <ryanc@apple.com>
*/
#ifndef _XAR_DARWINATTR_H_
#define _XAR_DARWINATTR_H_
xar_file_t xar_underbar_check(xar_t x, xar_file_t f, const char* file);
int32_t xar_darwinattr_archive(xar_t x, xar_file_t f, const char* file, const char *buffer, size_t len);
int32_t xar_darwinattr_extract(xar_t x, xar_file_t f, const char* file, char *buffer, size_t len);
#endif /* _XAR_DARWINATTR_H_ */

Binary file not shown.

View File

@ -0,0 +1,23 @@
darwinattr.o: lib/darwinattr.c include/config.h include/xar.h \
lib/arcmod.h lib/filetree.h /usr/include/libxml2/libxml/xmlwriter.h \
/usr/include/libxml2/libxml/xmlversion.h \
/usr/include/libxml2/libxml/xmlexports.h \
/usr/include/libxml2/libxml/xmlIO.h \
/usr/include/libxml2/libxml/globals.h \
/usr/include/libxml2/libxml/parser.h /usr/include/libxml2/libxml/tree.h \
/usr/include/libxml2/libxml/xmlstring.h \
/usr/include/libxml2/libxml/xmlregexp.h \
/usr/include/libxml2/libxml/dict.h /usr/include/libxml2/libxml/hash.h \
/usr/include/libxml2/libxml/valid.h \
/usr/include/libxml2/libxml/xmlerror.h \
/usr/include/libxml2/libxml/list.h \
/usr/include/libxml2/libxml/xmlautomata.h \
/usr/include/libxml2/libxml/entities.h \
/usr/include/libxml2/libxml/encoding.h /usr/include/libxml2/libxml/SAX.h \
/usr/include/libxml2/libxml/xlink.h /usr/include/libxml2/libxml/SAX2.h \
/usr/include/libxml2/libxml/xmlmemory.h \
/usr/include/libxml2/libxml/threads.h \
/usr/include/libxml2/libxml/xmlreader.h \
/usr/include/libxml2/libxml/relaxng.h \
/usr/include/libxml2/libxml/xmlschemas.h lib/ea.h lib/b64.h lib/util.h \
lib/linuxattr.h lib/io.h lib/appledouble.h lib/stat.h lib/archive.h

Binary file not shown.

267
setup/xar-1.5.2/lib/data.c Normal file
View File

@ -0,0 +1,267 @@
/*
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of Apple nor the names of any contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* 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.
*/
/*
* Portions Copyright 2006, Apple Computer, Inc.
* Christopher Ryan <ryanc@apple.com>
*/
#define _FILE_OFFSET_BITS 64
#include <stdlib.h>
#include <stdio.h>
#include <fcntl.h>
#include <errno.h>
#include <string.h>
#include <limits.h>
#include <unistd.h>
#include <inttypes.h>
#include <sys/types.h>
#include "xar.h"
#include "filetree.h"
#include "archive.h"
#include "io.h"
#ifndef O_EXLOCK
#define O_EXLOCK 0
#endif
struct _data_context{
int fd;
void *buffer;
size_t length;
off_t offset;
off_t total;
};
#define DATA_CONTEXT(x) ((struct _data_context*)(x))
int32_t xar_data_read(xar_t x, xar_file_t f, void *inbuf, size_t bsize, void *context) {
int32_t r;
/* read from buffer, rather then fd,if available */
if(DATA_CONTEXT(context)->length){
char *readbuf = (char *)DATA_CONTEXT(context)->buffer;
size_t sizetoread = DATA_CONTEXT(context)->length - DATA_CONTEXT(context)->offset;
if( !sizetoread){
return 0;
}
if( sizetoread > bsize ){
sizetoread = bsize;
}
/* dont read passed the end of the buffer */
if((DATA_CONTEXT(context)->offset + sizetoread) > DATA_CONTEXT(context)->length){
return -1;
}
readbuf += DATA_CONTEXT(context)->offset;
memcpy(inbuf,readbuf,sizetoread);
DATA_CONTEXT(context)->total += sizetoread;
DATA_CONTEXT(context)->offset += sizetoread;
return sizetoread;
}
while(1) {
r = read(DATA_CONTEXT(context)->fd, inbuf, bsize);
if( (r < 0) && (errno == EINTR) )
continue;
DATA_CONTEXT(context)->total += r;
return r;
}
}
int32_t xar_data_write(xar_t x, xar_file_t f, void *buf, size_t len, void *context) {
int32_t r;
size_t off = 0;
/* read from buffer, rather then fd,if available */
if(DATA_CONTEXT(context)->length){
char *writebuf = (char *)DATA_CONTEXT(context)->buffer;
/* dont write passed the end of the buffer */
if((DATA_CONTEXT(context)->offset + len) > DATA_CONTEXT(context)->length){
return -1;
}
writebuf += DATA_CONTEXT(context)->offset;
memcpy(writebuf,buf,len);
DATA_CONTEXT(context)->offset += len;
return len;
}
do {
r = write(DATA_CONTEXT(context)->fd, buf+off, len-off);
if( (r < 0) && (errno != EINTR) )
return r;
off += r;
} while( off < len );
return off;
}
/* xar_data_archive
* This is the arcmod archival entry point for archiving the file's
* data into the heap file.
*/
int32_t xar_data_archive(xar_t x, xar_file_t f, const char *file, const char *buffer, size_t len) {
const char *opt;
int32_t retval = 0;
struct _data_context context;
xar_prop_t tmpp;
memset(&context,0,sizeof(struct _data_context));
xar_prop_get(f, "type", &opt);
if(!opt) return 0;
if( strcmp(opt, "file") != 0 ) {
if( strcmp(opt, "hardlink") == 0 ) {
opt = xar_attr_get(f, "type", "link");
if( !opt )
return 0;
if( strcmp(opt, "original") != 0 )
return 0;
/* else, we're an original hardlink, so keep going */
} else
return 0;
}
if( 0 == len ){
context.fd = open(file, O_RDONLY);
if( context.fd < 0 ) {
xar_err_new(x);
xar_err_set_file(x, f);
xar_err_set_string(x, "io: Could not open file");
xar_err_callback(x, XAR_SEVERITY_NONFATAL, XAR_ERR_ARCHIVE_CREATION);
return -1;
}
}else{
context.buffer = (void *)buffer;
context.length = len;
context.offset = 0;
}
#ifdef F_NOCACHE
fcntl(context.fd, F_NOCACHE, 1);
#endif
tmpp = xar_prop_pset(f, NULL, "data", NULL);
retval = xar_attrcopy_to_heap(x, f, tmpp, xar_data_read,(void *)(&context));
if( context.total == 0 )
xar_prop_unset(f, "data");
if(context.fd > 0){
close(context.fd);
context.fd = -1;
}
return retval;
}
int32_t xar_data_extract(xar_t x, xar_file_t f, const char *file, char *buffer, size_t len) {
const char *opt;
int32_t retval = 0;
struct _data_context context;
xar_prop_t tmpp;
memset(&context,0,sizeof(struct _data_context));
/* Only regular files are copied in and out of the heap here */
xar_prop_get(f, "type", &opt);
if( !opt ) return 0;
if( strcmp(opt, "file") != 0 ) {
if( strcmp(opt, "hardlink") == 0 ) {
opt = xar_attr_get(f, "type", "link");
if( !opt )
return 0;
if( strcmp(opt, "original") != 0 )
return 0;
/* else, we're an original hardlink, so keep going */
} else
return 0;
}
if ( len ){
context.length = len;
context.buffer = buffer;
context.offset = 0;
}else{
/* mode 600 since other modules may need to operate on the file
* prior to the real permissions being set.
*/
context.fd = open(file, O_RDWR|O_TRUNC|O_EXLOCK, 0600);
if( context.fd < 0 ) {
xar_err_new(x);
xar_err_set_file(x, f);
xar_err_set_string(x, "io: Could not create file");
xar_err_callback(x, XAR_SEVERITY_NONFATAL, XAR_ERR_ARCHIVE_EXTRACTION);
return -1;
}
}
tmpp = xar_prop_pfirst(f);
if( tmpp )
tmpp = xar_prop_find(tmpp, "data");
if( !tmpp )
return 0;
retval = xar_attrcopy_from_heap(x, f, tmpp, xar_data_write, (void *)(&context));
if( context.fd > 0 ){
close(context.fd);
context.fd = -1;
}
return retval;
}
int32_t xar_data_verify(xar_t x, xar_file_t f)
{
const char *opt;
struct _data_context context;
xar_prop_t tmpp;
memset(&context,0,sizeof(struct _data_context));
/* Only regular files are copied in and out of the heap here */
xar_prop_get(f, "type", &opt);
if( !opt ) return 0;
if( strcmp(opt, "directory") == 0 ) {
return 0;
}
tmpp = xar_prop_pfirst(f);
if( tmpp )
tmpp = xar_prop_find(tmpp, "data");
return xar_attrcopy_from_heap(x, f, tmpp, NULL , (void *)(&context));
}

View File

@ -0,0 +1,22 @@
lib/data.o : lib/data.c include/xar.h lib/filetree.h \
/usr/include/libxml2/libxml/xmlwriter.h \
/usr/include/libxml2/libxml/xmlversion.h \
/usr/include/libxml2/libxml/xmlexports.h \
/usr/include/libxml2/libxml/xmlIO.h \
/usr/include/libxml2/libxml/globals.h \
/usr/include/libxml2/libxml/parser.h /usr/include/libxml2/libxml/tree.h \
/usr/include/libxml2/libxml/xmlstring.h \
/usr/include/libxml2/libxml/xmlregexp.h \
/usr/include/libxml2/libxml/dict.h /usr/include/libxml2/libxml/hash.h \
/usr/include/libxml2/libxml/valid.h \
/usr/include/libxml2/libxml/xmlerror.h \
/usr/include/libxml2/libxml/list.h \
/usr/include/libxml2/libxml/xmlautomata.h \
/usr/include/libxml2/libxml/entities.h \
/usr/include/libxml2/libxml/encoding.h /usr/include/libxml2/libxml/SAX.h \
/usr/include/libxml2/libxml/xlink.h /usr/include/libxml2/libxml/SAX2.h \
/usr/include/libxml2/libxml/xmlmemory.h \
/usr/include/libxml2/libxml/threads.h \
/usr/include/libxml2/libxml/xmlreader.h \
/usr/include/libxml2/libxml/relaxng.h \
/usr/include/libxml2/libxml/xmlschemas.h lib/ea.h lib/archive.h lib/io.h

View File

@ -0,0 +1,44 @@
/*
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of Apple nor the names of any contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* 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.
*/
/*
* Rob Braun <bbraun@synack.net>
* 21-Apr-2004
* Copyright (c) 2004 Rob Braun. All rights reserved.
*/
/*
* Portions Copyright 2006, Apple Computer, Inc.
* Christopher Ryan <ryanc@apple.com>
*/
#ifndef _XAR_DATA_H_
#define _XAR_DATA_H_
int32_t xar_data_archive(xar_t x, xar_file_t f, const char* file, const char *buffer, size_t len);
int32_t xar_data_extract(xar_t x, xar_file_t f, const char* file, char *buffer, size_t len);
int32_t xar_data_verify(xar_t x, xar_file_t f);
#endif /* _XAR_DATA_H_ */

BIN
setup/xar-1.5.2/lib/data.o Normal file

Binary file not shown.

View File

@ -0,0 +1,22 @@
data.o: lib/data.c include/xar.h lib/filetree.h \
/usr/include/libxml2/libxml/xmlwriter.h \
/usr/include/libxml2/libxml/xmlversion.h \
/usr/include/libxml2/libxml/xmlexports.h \
/usr/include/libxml2/libxml/xmlIO.h \
/usr/include/libxml2/libxml/globals.h \
/usr/include/libxml2/libxml/parser.h /usr/include/libxml2/libxml/tree.h \
/usr/include/libxml2/libxml/xmlstring.h \
/usr/include/libxml2/libxml/xmlregexp.h \
/usr/include/libxml2/libxml/dict.h /usr/include/libxml2/libxml/hash.h \
/usr/include/libxml2/libxml/valid.h \
/usr/include/libxml2/libxml/xmlerror.h \
/usr/include/libxml2/libxml/list.h \
/usr/include/libxml2/libxml/xmlautomata.h \
/usr/include/libxml2/libxml/entities.h \
/usr/include/libxml2/libxml/encoding.h /usr/include/libxml2/libxml/SAX.h \
/usr/include/libxml2/libxml/xlink.h /usr/include/libxml2/libxml/SAX2.h \
/usr/include/libxml2/libxml/xmlmemory.h \
/usr/include/libxml2/libxml/threads.h \
/usr/include/libxml2/libxml/xmlreader.h \
/usr/include/libxml2/libxml/relaxng.h \
/usr/include/libxml2/libxml/xmlschemas.h lib/ea.h lib/archive.h lib/io.h

Binary file not shown.

99
setup/xar-1.5.2/lib/ea.c Normal file
View File

@ -0,0 +1,99 @@
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <assert.h>
#include <libgen.h>
#include "config.h"
#ifndef HAVE_ASPRINTF
#include "asprintf.h"
#endif
#include "xar.h"
#include "filetree.h"
#include "archive.h"
#include "b64.h"
#include "ea.h"
struct __xar_ea_t {
const struct __xar_prop_t *prop;
const struct __xar_ea_t *next;
};
#define XAR_EA(x) ((struct __xar_ea_t *)(x))
xar_ea_t xar_ea_new(xar_file_t f, const char *name)
{
xar_ea_t ret;
ret = calloc(sizeof(struct __xar_ea_t), 1);
if( !ret )
return NULL;
XAR_EA(ret)->prop = xar_prop_new(f, NULL);
if( !XAR_EA(ret)->prop ) {
free(ret);
return NULL;
}
xar_prop_setkey(XAR_EA(ret)->prop, "ea");
xar_prop_setvalue(XAR_EA(ret)->prop, NULL);
XAR_PROP(XAR_EA(ret)->prop)->attrs = xar_attr_new();
XAR_ATTR(XAR_PROP(XAR_EA(ret)->prop)->attrs)->key = strdup("id");
asprintf((char **)&XAR_ATTR(XAR_PROP(XAR_EA(ret)->prop)->attrs)->value, "%lld", XAR_FILE(f)->nexteaid++);
xar_prop_pset(f, XAR_EA(ret)->prop, "name", name);
return ret;
}
int32_t xar_ea_pset(xar_file_t f, xar_ea_t e, const char *key, const char *value){
if( xar_prop_pset(f, XAR_EA(e)->prop, key, value) )
return 0;
return -1;
}
int32_t xar_ea_pget(xar_ea_t e, const char *key, const char **value) {
xar_prop_t r = xar_prop_find(XAR_EA(e)->prop, key);
if( !r ) {
if( value )
*value = NULL;
return -1;
}
if(value)
*value = XAR_PROP(r)->value;
return 0;
}
xar_prop_t xar_ea_root(xar_ea_t e) {
return XAR_EA(e)->prop;
}
xar_prop_t xar_ea_find(xar_file_t f, const char *name)
{
xar_prop_t p;
for(p = xar_prop_pfirst(f); p; p = xar_prop_pnext(p)) {
const char *tmp;
xar_prop_t tmpp;
tmp = xar_prop_getkey(p);
if( strncmp(tmp, XAR_EA_FORK, strlen(XAR_EA_FORK)) != 0 )
continue;
if( strlen(tmp) != strlen(XAR_EA_FORK) )
continue;
tmpp = xar_prop_pget(p, "name");
if( !tmpp )
continue;
tmp = xar_prop_getvalue(tmpp);
if( !tmp )
continue;
if( strcmp(tmp, name) == 0 )
return p;
}
return NULL;
}

23
setup/xar-1.5.2/lib/ea.d Normal file
View File

@ -0,0 +1,23 @@
lib/ea.o : lib/ea.c include/config.h include/xar.h lib/filetree.h \
/usr/include/libxml2/libxml/xmlwriter.h \
/usr/include/libxml2/libxml/xmlversion.h \
/usr/include/libxml2/libxml/xmlexports.h \
/usr/include/libxml2/libxml/xmlIO.h \
/usr/include/libxml2/libxml/globals.h \
/usr/include/libxml2/libxml/parser.h /usr/include/libxml2/libxml/tree.h \
/usr/include/libxml2/libxml/xmlstring.h \
/usr/include/libxml2/libxml/xmlregexp.h \
/usr/include/libxml2/libxml/dict.h /usr/include/libxml2/libxml/hash.h \
/usr/include/libxml2/libxml/valid.h \
/usr/include/libxml2/libxml/xmlerror.h \
/usr/include/libxml2/libxml/list.h \
/usr/include/libxml2/libxml/xmlautomata.h \
/usr/include/libxml2/libxml/entities.h \
/usr/include/libxml2/libxml/encoding.h /usr/include/libxml2/libxml/SAX.h \
/usr/include/libxml2/libxml/xlink.h /usr/include/libxml2/libxml/SAX2.h \
/usr/include/libxml2/libxml/xmlmemory.h \
/usr/include/libxml2/libxml/threads.h \
/usr/include/libxml2/libxml/xmlreader.h \
/usr/include/libxml2/libxml/relaxng.h \
/usr/include/libxml2/libxml/xmlschemas.h lib/ea.h lib/archive.h \
lib/b64.h

15
setup/xar-1.5.2/lib/ea.h Normal file
View File

@ -0,0 +1,15 @@
#ifndef _XAR_EA_H_
#define _XAR_EA_H_
#include "xar.h"
#include "filetree.h"
typedef struct __xar_ea_t *xar_ea_t;
xar_ea_t xar_ea_new(xar_file_t f, const char *name);
int32_t xar_ea_pset(xar_file_t f, xar_ea_t e, const char *key, const char *value);
int32_t xar_ea_pget(xar_ea_t e, const char *key, const char **value);
xar_prop_t xar_ea_root(xar_ea_t e);
xar_prop_t xar_ea_find(xar_file_t f, const char *name);
#endif /* _XAR_EA_H_ */

BIN
setup/xar-1.5.2/lib/ea.o Normal file

Binary file not shown.

View File

@ -0,0 +1,23 @@
ea.o: lib/ea.c include/config.h include/xar.h lib/filetree.h \
/usr/include/libxml2/libxml/xmlwriter.h \
/usr/include/libxml2/libxml/xmlversion.h \
/usr/include/libxml2/libxml/xmlexports.h \
/usr/include/libxml2/libxml/xmlIO.h \
/usr/include/libxml2/libxml/globals.h \
/usr/include/libxml2/libxml/parser.h /usr/include/libxml2/libxml/tree.h \
/usr/include/libxml2/libxml/xmlstring.h \
/usr/include/libxml2/libxml/xmlregexp.h \
/usr/include/libxml2/libxml/dict.h /usr/include/libxml2/libxml/hash.h \
/usr/include/libxml2/libxml/valid.h \
/usr/include/libxml2/libxml/xmlerror.h \
/usr/include/libxml2/libxml/list.h \
/usr/include/libxml2/libxml/xmlautomata.h \
/usr/include/libxml2/libxml/entities.h \
/usr/include/libxml2/libxml/encoding.h /usr/include/libxml2/libxml/SAX.h \
/usr/include/libxml2/libxml/xlink.h /usr/include/libxml2/libxml/SAX2.h \
/usr/include/libxml2/libxml/xmlmemory.h \
/usr/include/libxml2/libxml/threads.h \
/usr/include/libxml2/libxml/xmlreader.h \
/usr/include/libxml2/libxml/relaxng.h \
/usr/include/libxml2/libxml/xmlschemas.h lib/ea.h lib/archive.h \
lib/b64.h

Binary file not shown.

85
setup/xar-1.5.2/lib/err.c Normal file
View File

@ -0,0 +1,85 @@
/*
* Copyright (c) 2005 Rob Braun
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of Rob Braun nor the names of his contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* 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.
*/
/*
* 03-Apr-2005
* DRI: Rob Braun <bbraun@opendarwin.org>
*/
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include "xar.h"
#include "archive.h"
#define ECTX(x) ((struct errctx *)(x))
void xar_register_errhandler(xar_t x, err_handler callback, void *usrctx) {
ECTX(&XAR(x)->errctx)->usrctx = usrctx;
XAR(x)->ercallback = callback;
return;
}
xar_file_t xar_err_get_file(xar_errctx_t ctx) {
return ECTX(ctx)->file;
}
void xar_err_set_file(xar_t x, xar_file_t f) {
XAR(x)->errctx.file = f;
return;
}
const char *xar_err_get_string(xar_errctx_t ctx) {
return ECTX(ctx)->str;
}
void xar_err_set_string(xar_t x, const char *str) {
XAR(x)->errctx.str = str;
return;
}
int xar_err_get_errno(xar_errctx_t ctx) {
return ECTX(ctx)->saved_errno;
}
void xar_err_set_errno(xar_t x, int e) {
XAR(x)->errctx.saved_errno = e;
return;
}
void xar_err_new(xar_t x) {
memset(&XAR(x)->errctx, 0, sizeof(struct errctx));
XAR(x)->errctx.saved_errno = errno;
return;
}
int32_t xar_err_callback(xar_t x, int32_t sev, int32_t err) {
if( XAR(x)->ercallback )
return XAR(x)->ercallback(sev, err, &XAR(x)->errctx, ECTX(&XAR(x)->errctx)->usrctx);
return 0;
}

22
setup/xar-1.5.2/lib/err.d Normal file
View File

@ -0,0 +1,22 @@
lib/err.o : lib/err.c include/xar.h lib/archive.h \
/usr/include/libxml2/libxml/hash.h \
/usr/include/libxml2/libxml/xmlversion.h \
/usr/include/libxml2/libxml/xmlexports.h \
/usr/include/libxml2/libxml/parser.h /usr/include/libxml2/libxml/tree.h \
/usr/include/libxml2/libxml/xmlstring.h \
/usr/include/libxml2/libxml/xmlregexp.h \
/usr/include/libxml2/libxml/dict.h /usr/include/libxml2/libxml/valid.h \
/usr/include/libxml2/libxml/xmlerror.h \
/usr/include/libxml2/libxml/list.h \
/usr/include/libxml2/libxml/xmlautomata.h \
/usr/include/libxml2/libxml/entities.h \
/usr/include/libxml2/libxml/encoding.h \
/usr/include/libxml2/libxml/xmlIO.h \
/usr/include/libxml2/libxml/globals.h /usr/include/libxml2/libxml/SAX.h \
/usr/include/libxml2/libxml/xlink.h /usr/include/libxml2/libxml/SAX2.h \
/usr/include/libxml2/libxml/xmlmemory.h \
/usr/include/libxml2/libxml/threads.h lib/filetree.h \
/usr/include/libxml2/libxml/xmlwriter.h \
/usr/include/libxml2/libxml/xmlreader.h \
/usr/include/libxml2/libxml/relaxng.h \
/usr/include/libxml2/libxml/xmlschemas.h lib/ea.h

BIN
setup/xar-1.5.2/lib/err.o Normal file

Binary file not shown.

View File

@ -0,0 +1,22 @@
err.o: lib/err.c include/xar.h lib/archive.h \
/usr/include/libxml2/libxml/hash.h \
/usr/include/libxml2/libxml/xmlversion.h \
/usr/include/libxml2/libxml/xmlexports.h \
/usr/include/libxml2/libxml/parser.h /usr/include/libxml2/libxml/tree.h \
/usr/include/libxml2/libxml/xmlstring.h \
/usr/include/libxml2/libxml/xmlregexp.h \
/usr/include/libxml2/libxml/dict.h /usr/include/libxml2/libxml/valid.h \
/usr/include/libxml2/libxml/xmlerror.h \
/usr/include/libxml2/libxml/list.h \
/usr/include/libxml2/libxml/xmlautomata.h \
/usr/include/libxml2/libxml/entities.h \
/usr/include/libxml2/libxml/encoding.h \
/usr/include/libxml2/libxml/xmlIO.h \
/usr/include/libxml2/libxml/globals.h /usr/include/libxml2/libxml/SAX.h \
/usr/include/libxml2/libxml/xlink.h /usr/include/libxml2/libxml/SAX2.h \
/usr/include/libxml2/libxml/xmlmemory.h \
/usr/include/libxml2/libxml/threads.h lib/filetree.h \
/usr/include/libxml2/libxml/xmlwriter.h \
/usr/include/libxml2/libxml/xmlreader.h \
/usr/include/libxml2/libxml/relaxng.h \
/usr/include/libxml2/libxml/xmlschemas.h lib/ea.h

Binary file not shown.

257
setup/xar-1.5.2/lib/ext2.c Normal file
View File

@ -0,0 +1,257 @@
/*
* Copyright (c) 2004 Rob Braun
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of Rob Braun nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE 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.
*/
/*
* 26-Oct-2004
* DRI: Rob Braun <bbraun@synack.net>
* Ported from xar-unsaxy 16-Apr-2005
*/
/*
* Portions Copyright 2006, Apple Computer, Inc.
* Christopher Ryan <ryanc@apple.com>
*/
#include "config.h"
#ifndef HAVE_ASPRINTF
#include "asprintf.h"
#endif
#include <stdio.h>
#include <unistd.h>
#include "xar.h"
#include "arcmod.h"
#include <errno.h>
#include <string.h>
#include <fcntl.h>
#include <sys/types.h>
#include <sys/ioctl.h>
#include "ext2.h"
#ifdef HAVE_EXT2FS_EXT2_FS_H
#include <ext2fs/ext2_fs.h>
#else
#if defined(HAVE_LINUX_EXT2_FS_H)
typedef uint32_t u32;
typedef uint8_t u8;
#include <linux/ext2_fs.h>
#endif
#endif
#define XAR_EXT2_FORK "ext2"
#if defined(HAVE_EXT2FS_EXT2_FS_H) || defined(HAVE_LINUX_EXT2_FS_H)
static void x_addprop(xar_file_t f, const char *name) {
char opt[1024];
memset(opt, 0, sizeof(opt));
snprintf(opt, sizeof(opt)-1, "%s/%s", XAR_ATTR_FORK, name);
xar_prop_set(f, opt, NULL);
xar_attr_set(f, opt, "fstype", "ext2");
return;
}
#endif
int xar_ext2attr_archive(xar_t x, xar_file_t f, const char* file, const char *buffer, size_t len)
{
int ret = 0;
/* if archiving from a buffer, then there is no place to get extattr */
if ( len )
return 0;
#if defined(HAVE_EXT2FS_EXT2_FS_H) || defined(HAVE_LINUX_EXT2_FS_H)
int fd, flags=0, version;
char *vstr;
const char *opt;
xar_prop_get(f, "type", &opt);
if(!opt) return 0;
if( strcmp(opt, "file") != 0 ) {
if( strcmp(opt, "hardlink") != 0 )
if( strcmp(opt, "directory") != 0 )
return 0;
}
fd = open(file, O_RDONLY);
if( fd < 0 ) {
return 0;
}
if( ioctl(fd, EXT2_IOC_GETVERSION, &version) < 0 ) {
ret = 0;
goto BAIL;
}
if( ioctl(fd, EXT2_IOC_GETFLAGS, &flags) < 0 ) {
ret = 0;
goto BAIL;
}
if( flags == 0 ) goto BAIL;
xar_prop_set(f, XAR_EXT2_FORK, NULL);
asprintf(&vstr, "%d", version);
xar_attr_set(f, XAR_EXT2_FORK, "version", vstr);
free(vstr);
if(! (flags & ~EXT2_SECRM_FL) )
x_addprop(f, "SecureDeletion");
if(! (flags & ~EXT2_UNRM_FL) )
x_addprop(f, "Undelete");
if(! (flags & ~EXT2_COMPR_FL) )
x_addprop(f, "Compress");
if(! (flags & ~EXT2_SYNC_FL) )
x_addprop(f, "Synchronous");
if(! (flags & ~EXT2_IMMUTABLE_FL) )
x_addprop(f, "Immutable");
if(! (flags & ~EXT2_APPEND_FL) )
x_addprop(f, "AppendOnly");
if(! (flags & ~EXT2_NODUMP_FL) )
x_addprop(f, "NoDump");
if(! (flags & ~EXT2_NOATIME_FL) )
x_addprop(f, "NoAtime");
if(! (flags & ~EXT2_DIRTY_FL) )
x_addprop(f, "CompDirty");
if(! (flags & ~EXT2_COMPRBLK_FL) )
x_addprop(f, "CompBlock");
#ifdef EXT2_NOCOMPR_FL
if(! (flags & ~EXT2_NOCOMPR_FL) )
x_addprop(f, "NoCompBlock");
#endif
if(! (flags & ~EXT2_ECOMPR_FL) )
x_addprop(f, "CompError");
if(! (flags & ~EXT2_BTREE_FL) )
x_addprop(f, "BTree");
if(! (flags & ~EXT2_INDEX_FL) )
x_addprop(f, "HashIndexed");
if(! (flags & ~EXT2_IMAGIC_FL) )
x_addprop(f, "iMagic");
#ifdef EXT3_JOURNAL_DATA_FL
if(! (flags & ~EXT3_JOURNAL_DATA_FL) )
x_addprop(f, "Journaled");
#endif
if(! (flags & ~EXT2_NOTAIL_FL) )
x_addprop(f, "NoTail");
if(! (flags & ~EXT2_DIRSYNC_FL) )
x_addprop(f, "DirSync");
if(! (flags & ~EXT2_TOPDIR_FL) )
x_addprop(f, "TopDir");
if(! (flags & ~EXT2_RESERVED_FL) )
x_addprop(f, "Reserved");
BAIL:
close(fd);
#endif
return ret;
}
#if defined(HAVE_EXT2FS_EXT2_FS_H) || defined(HAVE_LINUX_EXT2_FS_H)
static int32_t e2prop_get(xar_file_t f, const char *name, char **value) {
char v[1024];
memset(v, 0, sizeof(v));
snprintf(v, sizeof(v)-1, "%s/%s", XAR_ATTR_FORK, name);
return xar_prop_get(f, v, (const char**)value);
}
#endif
int xar_ext2attr_extract(xar_t x, xar_file_t f, const char* file, char *buffer, size_t len)
{
/* if extracting to a buffer, then there is no place to write extattr */
if ( len )
return 0;
#if defined(HAVE_EXT2FS_EXT2_FS_H) || defined(HAVE_LINUX_EXT2_FS_H)
int fd = -1, version, flags = 0;
char *tmp;
if( xar_prop_get(f, XAR_EXT2_FORK, NULL) == 0 ) {
const char *temp;
temp = xar_attr_get(f, XAR_EXT2_FORK, "version");
version = strtol(temp, NULL, 10);
fd = open(file, O_RDONLY);
if( fd < 0 )
return 0;
ioctl(fd, EXT2_IOC_SETVERSION, &version);
}
if( xar_prop_get(f, XAR_ATTR_FORK, NULL) ) {
if( fd >= 0 ) close(fd);
return 0;
}
if( e2prop_get(f, "SecureDeletion", (char **)&tmp) == 0 )
flags |= EXT2_SECRM_FL;
if( e2prop_get(f, "Undelete", (char **)&tmp) == 0 )
flags |= EXT2_UNRM_FL ;
if( e2prop_get(f, "Compress", (char **)&tmp) == 0 )
flags |= EXT2_COMPR_FL ;
if( e2prop_get(f, "Synchronous", (char **)&tmp) == 0 )
flags |= EXT2_SYNC_FL ;
if( e2prop_get(f, "SystemImmutable", (char **)&tmp) == 0 )
flags |= EXT2_IMMUTABLE_FL ;
if( e2prop_get(f, "AppendOnly", (char **)&tmp) == 0 )
flags |= EXT2_APPEND_FL ;
if( e2prop_get(f, "NoDump", (char **)&tmp) == 0 )
flags |= EXT2_NODUMP_FL ;
if( e2prop_get(f, "NoAtime", (char **)&tmp) == 0 )
flags |= EXT2_NOATIME_FL ;
if( e2prop_get(f, "CompDirty", (char **)&tmp) == 0 )
flags |= EXT2_DIRTY_FL ;
if( e2prop_get(f, "CompBlock", (char **)&tmp) == 0 )
flags |= EXT2_COMPRBLK_FL ;
#ifdef EXT2_NOCOMPR_FL
if( e2prop_get(f, "NoCompBlock", (char **)&tmp) == 0 )
flags |= EXT2_NOCOMPR_FL ;
#endif
if( e2prop_get(f, "CompError", (char **)&tmp) == 0 )
flags |= EXT2_ECOMPR_FL ;
if( e2prop_get(f, "BTree", (char **)&tmp) == 0 )
flags |= EXT2_BTREE_FL ;
if( e2prop_get(f, "HashIndexed", (char **)&tmp) == 0 )
flags |= EXT2_INDEX_FL ;
if( e2prop_get(f, "iMagic", (char **)&tmp) == 0 )
flags |= EXT2_IMAGIC_FL ;
#ifdef EXT3_JOURNAL_DATA_FL
if( e2prop_get(f, "Journaled", (char **)&tmp) == 0 )
flags |= EXT3_JOURNAL_DATA_FL ;
#endif
if( e2prop_get(f, "NoTail", (char **)&tmp) == 0 )
flags |= EXT2_NOTAIL_FL ;
if( e2prop_get(f, "DirSync", (char **)&tmp) == 0 )
flags |= EXT2_DIRSYNC_FL ;
if( e2prop_get(f, "TopDir", (char **)&tmp) == 0 )
flags |= EXT2_TOPDIR_FL ;
if( fd < 0 ) {
fd = open(file, O_RDONLY);
if( fd < 0 )
return 0;
}
ioctl(fd, EXT2_IOC_SETFLAGS, &flags);
close(fd);
#endif
return 0;
}

View File

@ -0,0 +1,22 @@
lib/ext2.o : lib/ext2.c include/config.h include/xar.h lib/arcmod.h \
lib/filetree.h /usr/include/libxml2/libxml/xmlwriter.h \
/usr/include/libxml2/libxml/xmlversion.h \
/usr/include/libxml2/libxml/xmlexports.h \
/usr/include/libxml2/libxml/xmlIO.h \
/usr/include/libxml2/libxml/globals.h \
/usr/include/libxml2/libxml/parser.h /usr/include/libxml2/libxml/tree.h \
/usr/include/libxml2/libxml/xmlstring.h \
/usr/include/libxml2/libxml/xmlregexp.h \
/usr/include/libxml2/libxml/dict.h /usr/include/libxml2/libxml/hash.h \
/usr/include/libxml2/libxml/valid.h \
/usr/include/libxml2/libxml/xmlerror.h \
/usr/include/libxml2/libxml/list.h \
/usr/include/libxml2/libxml/xmlautomata.h \
/usr/include/libxml2/libxml/entities.h \
/usr/include/libxml2/libxml/encoding.h /usr/include/libxml2/libxml/SAX.h \
/usr/include/libxml2/libxml/xlink.h /usr/include/libxml2/libxml/SAX2.h \
/usr/include/libxml2/libxml/xmlmemory.h \
/usr/include/libxml2/libxml/threads.h \
/usr/include/libxml2/libxml/xmlreader.h \
/usr/include/libxml2/libxml/relaxng.h \
/usr/include/libxml2/libxml/xmlschemas.h lib/ea.h lib/ext2.h

View File

@ -0,0 +1,42 @@
/* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of Apple nor the names of any contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* 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.
*/
/*
* Rob Braun <bbraun@synack.net>
* 26-Oct-2004
* Copyright (c) 2004 Rob Braun. All rights reserved.
*/
/*
* Portions Copyright 2006, Apple Computer, Inc.
* Christopher Ryan <ryanc@apple.com>
*/
#ifndef _XAR_EXT2_H_
#define _XAR_EXT2_H_
#define XAR_ATTR_FORK "attribute"
int xar_ext2attr_archive(xar_t x, xar_file_t f, const char* file, const char *buffer, size_t len);
int xar_ext2attr_extract(xar_t x, xar_file_t f, const char* file, char *buffer, size_t len);
#endif /* _XAR_EXT2_H_ */

BIN
setup/xar-1.5.2/lib/ext2.o Normal file

Binary file not shown.

View File

@ -0,0 +1,22 @@
ext2.o: lib/ext2.c include/config.h include/xar.h lib/arcmod.h \
lib/filetree.h /usr/include/libxml2/libxml/xmlwriter.h \
/usr/include/libxml2/libxml/xmlversion.h \
/usr/include/libxml2/libxml/xmlexports.h \
/usr/include/libxml2/libxml/xmlIO.h \
/usr/include/libxml2/libxml/globals.h \
/usr/include/libxml2/libxml/parser.h /usr/include/libxml2/libxml/tree.h \
/usr/include/libxml2/libxml/xmlstring.h \
/usr/include/libxml2/libxml/xmlregexp.h \
/usr/include/libxml2/libxml/dict.h /usr/include/libxml2/libxml/hash.h \
/usr/include/libxml2/libxml/valid.h \
/usr/include/libxml2/libxml/xmlerror.h \
/usr/include/libxml2/libxml/list.h \
/usr/include/libxml2/libxml/xmlautomata.h \
/usr/include/libxml2/libxml/entities.h \
/usr/include/libxml2/libxml/encoding.h /usr/include/libxml2/libxml/SAX.h \
/usr/include/libxml2/libxml/xlink.h /usr/include/libxml2/libxml/SAX2.h \
/usr/include/libxml2/libxml/xmlmemory.h \
/usr/include/libxml2/libxml/threads.h \
/usr/include/libxml2/libxml/xmlreader.h \
/usr/include/libxml2/libxml/relaxng.h \
/usr/include/libxml2/libxml/xmlschemas.h lib/ea.h lib/ext2.h

Binary file not shown.

View File

@ -0,0 +1,337 @@
/*
* Copyright (c) 2007 Rob Braun
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of Rob Braun nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE 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.
*/
/*
* 28-Oct-2004
* DRI: Rob Braun <bbraun@synack.net>
*/
/*
* Portions Copyright 2006, Apple Computer, Inc.
* Christopher Ryan <ryanc@apple.com>
*/
#include "config.h"
#include <unistd.h>
#include "xar.h"
#include "arcmod.h"
#include "b64.h"
#include "io.h"
#include "archive.h"
#include <errno.h>
#include <string.h>
#include <sys/types.h>
/* FreeBSD Extended Attribute Headers */
#ifdef HAVE_SYS_EXTATTR_H
#include <sys/extattr.h>
#endif
#ifdef HAVE_LIBUTIL_H
#include <libutil.h>
#endif
#ifdef HAVE_SYS_EXTATTR_H
#include <sys/param.h>
#include <sys/mount.h>
#include <sys/extattr.h>
#endif
#ifdef HAVE_SYS_EXTATTR_H
struct _fbsdattr_context{
const char *file;
const char *attrname;
void *buf;
int off;
int bufsz;
int ns;
};
#define FBSDATTR_CONTEXT(x) ((struct _fbsdattr_context *)(x))
int32_t xar_fbsdattr_read(xar_t x, xar_file_t f, void *buf, size_t len, void *context) {
if( !FBSDATTR_CONTEXT(context)->buf ) {
FBSDATTR_CONTEXT(context)->bufsz = extattr_get_link(FBSDATTR_CONTEXT(context)->file, FBSDATTR_CONTEXT(context)->ns, FBSDATTR_CONTEXT(context)->attrname, NULL, 0);
if( FBSDATTR_CONTEXT(context)->bufsz < 0 )
return -1;
FBSDATTR_CONTEXT(context)->buf = malloc(FBSDATTR_CONTEXT(context)->bufsz);
if( !FBSDATTR_CONTEXT(context)->buf )
return -1;
FBSDATTR_CONTEXT(context)->bufsz = extattr_get_link(FBSDATTR_CONTEXT(context)->file, FBSDATTR_CONTEXT(context)->ns, FBSDATTR_CONTEXT(context)->attrname, FBSDATTR_CONTEXT(context)->buf, FBSDATTR_CONTEXT(context)->bufsz);
}
if( (FBSDATTR_CONTEXT(context)->bufsz - FBSDATTR_CONTEXT(context)->off) <= len ) {
int32_t ret;
ret = FBSDATTR_CONTEXT(context)->bufsz - FBSDATTR_CONTEXT(context)->off;
memcpy(buf, FBSDATTR_CONTEXT(context)->buf+FBSDATTR_CONTEXT(context)->off, ret);
FBSDATTR_CONTEXT(context)->off += ret;
return(ret);
} else {
memcpy(buf, FBSDATTR_CONTEXT(context)->buf+FBSDATTR_CONTEXT(context)->off, len);
FBSDATTR_CONTEXT(context)->buf += len;
return(len);
}
}
int32_t xar_fbsdattr_write(xar_t x, xar_file_t f, void *buf, size_t len, void *context) {
return extattr_set_link(FBSDATTR_CONTEXT(context)->file, FBSDATTR_CONTEXT(context)->ns, FBSDATTR_CONTEXT(context)->attrname, buf, len);
}
#endif
int32_t xar_fbsdattr_archive(xar_t x, xar_file_t f, const char* file, const char *buffer, size_t len)
{
#ifdef HAVE_SYS_EXTATTR_H
char *buf = NULL;
int ret, retval=0, bufsz, i;
#if defined(HAVE_STATVFS) && defined(HAVE_STRUCT_STATVFS_F_FSTYPENAME)
struct statvfs sfs;
#else
struct statfs sfs;
#endif
char *fsname = NULL;
int namespace = EXTATTR_NAMESPACE_USER;
struct _fbsdattr_context context;
memset(&context,0,sizeof(struct _fbsdattr_context));
/* no fbsdattr attributes for data to a buffer */
if(len)
return 0;
if(file == NULL)
return 0;
TRYAGAIN:
/* extattr_list_link()'s man page does not define the return
* value. The kernel source comments say 0 for success, -1 for
* failure. However, the observed behavior is # of bytes
* used, 0 if none, -1 on error.
* Also, errno is not documented to be set to anything useful
* if buf is too small. We are using an undocumented "feature"
* that if the data argument is NULL, it will return the number
* of bytes that would have been written (beware, return value
* does not indicate success or failure on it's own. Need to
* check the return value *and* the parameters.
*/
ret = extattr_list_link(file, namespace, NULL, 0);
if( ret < 0 ) {
if( namespace == EXTATTR_NAMESPACE_USER ) {
namespace = EXTATTR_NAMESPACE_SYSTEM;
goto TRYAGAIN;
} else {
/* If we get eperm on system namespace, don't
* return error. This is expected for normal
* users trying to archive the system namespace
* on freebsd 6.2. On netbsd 3.1, they've decided
* to return EOPNOTSUPP instead.
*/
if( errno == EPERM )
ret = 0;
else if( errno == EOPNOTSUPP )
ret = 0;
else {
xar_err_new(x);
xar_err_set_file(x, f);
xar_err_set_string(x, "Error archiving EA");
xar_err_callback(x, XAR_SEVERITY_NONFATAL, XAR_ERR_ARCHIVE_CREATION);
ret = 0;
}
goto BAIL;
}
}
bufsz = ret;
buf = malloc(bufsz);
if( !buf ) {
retval = -1;
goto BAIL;
}
memset(buf, 0, bufsz);
ret = extattr_list_link(file, namespace, buf, bufsz);
if( ret < 0 ) {
switch(errno) {
case ENOTSUP: retval=0; goto BAIL;
default: retval=-1; goto BAIL;
};
}
/* Even though 0 is a documented success, observed behavior
* indicates 0 means all perms were satisfied, etc, but
* no extattrs were found to list.
*/
if( ret == 0 ) {
if( namespace == EXTATTR_NAMESPACE_USER ) {
namespace = EXTATTR_NAMESPACE_SYSTEM;
goto TRYAGAIN;
} else {
/* If we get eperm on system namespace, don't
* return error. This is expected for normal
* users trying to archive the system namespace
* on freebsd 6.2. On netbsd 3.1, they've decided
* to return EOPNOTSUPP instead.
*/
if( errno == EPERM )
ret = 0;
else if( errno == EOPNOTSUPP )
ret = 0;
else {
xar_err_new(x);
xar_err_set_file(x, f);
xar_err_set_string(x, "Error archiving EA");
xar_err_callback(x, XAR_SEVERITY_NONFATAL, XAR_ERR_ARCHIVE_CREATION);
ret = 0;
}
goto BAIL;
}
}
#if defined(HAVE_STATVFS) && defined(HAVE_STRUCT_STATVFS_F_FSTYPENAME)
statvfs(file, &sfs);
#else
statfs(file, &sfs);
#endif
fsname = sfs.f_fstypename;
/* extattr_list_link() does not return the series of keys NUL
* separated, as documented in the man page. Instead, it
* returns things DNS style, with a 1 byte length followed by
* the key, repeated for as many keys as there are.
*/
for( i=0; i < ret; i++ ) {
char key[256];
char *ns;
char tempnam[1024];
xar_ea_t e;
memset(key, 0, sizeof(key));
memcpy(key, buf+i+1, buf[i]);
i += buf[i] ;
extattr_namespace_to_string(namespace, &ns);
memset(tempnam, 0, sizeof(tempnam));
snprintf(tempnam, sizeof(tempnam)-1, "%s.%s", ns, key);
FBSDATTR_CONTEXT(&context)->ns = namespace;
FBSDATTR_CONTEXT(&context)->file = file;
FBSDATTR_CONTEXT(&context)->attrname = key;
e = xar_ea_new(f, tempnam);
xar_ea_pset(f, e, "fstype", fsname);
xar_attrcopy_to_heap(x, f, xar_ea_root(e), xar_fbsdattr_read, &context);
free(FBSDATTR_CONTEXT(&context)->buf);
FBSDATTR_CONTEXT(&context)->buf = NULL;
FBSDATTR_CONTEXT(&context)->off = 0;
}
if( namespace == EXTATTR_NAMESPACE_USER ) {
namespace = EXTATTR_NAMESPACE_SYSTEM;
free(buf);
buf = NULL;
goto TRYAGAIN;
}
BAIL:
free(buf);
return ret;
#else
return 0;
#endif
}
int32_t xar_fbsdattr_extract(xar_t x, xar_file_t f, const char* file, char *buffer, size_t len)
{
#ifdef HAVE_SYS_EXTATTR_H
char *fsname = "bogus";
xar_prop_t p;
#if defined(HAVE_STATVFS) && defined(HAVE_STRUCT_STATVFS_F_FSTYPENAME)
struct statvfs sfs;
#else
struct statfs sfs;
#endif
int eaopt = 0;
struct _fbsdattr_context context;
memset(&context,0,sizeof(struct _fbsdattr_context));
/* no fbsdattr attributes for data to a buffer */
if(len){
return 0;
}
#if defined(HAVE_STATVFS) && defined(HAVE_STRUCT_STATVFS_F_FSTYPENAME)
statvfs(file, &sfs);
#else
statfs(file, &sfs);
#endif
fsname = sfs.f_fstypename;
for(p = xar_prop_pfirst(f); p; p = xar_prop_pnext(p)) {
const char *fs = NULL;
const char *prop;
const char *eaname = NULL;
xar_prop_t tmpp;
prop = xar_prop_getkey(p);
if( strncmp(prop, XAR_EA_FORK, strlen(XAR_EA_FORK) != 0 ) )
continue;
if( strlen(prop) != strlen(XAR_EA_FORK) )
continue;
tmpp = xar_prop_pget(p, "fstype");
if( tmpp )
fs = xar_prop_getvalue(tmpp);
if( !eaopt && fs && strcmp(fs, fsname) != 0 ) {
continue;
}
tmpp = xar_prop_pget(p, "name");
if( tmpp )
eaname = xar_prop_getvalue(tmpp);
if( !eaname )
continue;
if( strncmp(eaname, "user.", 5) == 0 ) {
FBSDATTR_CONTEXT(&context)->ns = EXTATTR_NAMESPACE_USER;
FBSDATTR_CONTEXT(&context)->attrname = eaname + 5;
} else if( strncmp(eaname, "system.", 7) == 0 ) {
FBSDATTR_CONTEXT(&context)->ns = EXTATTR_NAMESPACE_SYSTEM;
FBSDATTR_CONTEXT(&context)->attrname = eaname + 7;
} else {
continue;
}
FBSDATTR_CONTEXT(&context)->file = file;
xar_attrcopy_from_heap(x, f, p, xar_fbsdattr_write, &context);
}
#endif
return 0;
}

View File

@ -0,0 +1,23 @@
lib/fbsdattr.o : lib/fbsdattr.c include/config.h include/xar.h lib/arcmod.h \
lib/filetree.h /usr/include/libxml2/libxml/xmlwriter.h \
/usr/include/libxml2/libxml/xmlversion.h \
/usr/include/libxml2/libxml/xmlexports.h \
/usr/include/libxml2/libxml/xmlIO.h \
/usr/include/libxml2/libxml/globals.h \
/usr/include/libxml2/libxml/parser.h /usr/include/libxml2/libxml/tree.h \
/usr/include/libxml2/libxml/xmlstring.h \
/usr/include/libxml2/libxml/xmlregexp.h \
/usr/include/libxml2/libxml/dict.h /usr/include/libxml2/libxml/hash.h \
/usr/include/libxml2/libxml/valid.h \
/usr/include/libxml2/libxml/xmlerror.h \
/usr/include/libxml2/libxml/list.h \
/usr/include/libxml2/libxml/xmlautomata.h \
/usr/include/libxml2/libxml/entities.h \
/usr/include/libxml2/libxml/encoding.h /usr/include/libxml2/libxml/SAX.h \
/usr/include/libxml2/libxml/xlink.h /usr/include/libxml2/libxml/SAX2.h \
/usr/include/libxml2/libxml/xmlmemory.h \
/usr/include/libxml2/libxml/threads.h \
/usr/include/libxml2/libxml/xmlreader.h \
/usr/include/libxml2/libxml/relaxng.h \
/usr/include/libxml2/libxml/xmlschemas.h lib/ea.h lib/b64.h lib/io.h \
lib/archive.h

View File

@ -0,0 +1,41 @@
/* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of Apple nor the names of any contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* 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.
*/
/*
* Rob Braun <bbraun@synack.net>
* 26-Oct-2004
* Copyright (c) 2004 Rob Braun. All rights reserved.
*/
/*
* Portions Copyright 2006, Apple Computer, Inc.
* Christopher Ryan <ryanc@apple.com>
*/
#ifndef _XAR_FBSDATTR_H_
#define _XAR_FBSDATTR_H_
int32_t xar_fbsdattr_archive(xar_t x, xar_file_t f, const char* file, const char *buffer, size_t len);
int32_t xar_fbsdattr_extract(xar_t x, xar_file_t f, const char* file, char *buffer, size_t len);
#endif /* _XAR_FBSDATTR_H_ */

Binary file not shown.

View File

@ -0,0 +1,23 @@
fbsdattr.o: lib/fbsdattr.c include/config.h include/xar.h lib/arcmod.h \
lib/filetree.h /usr/include/libxml2/libxml/xmlwriter.h \
/usr/include/libxml2/libxml/xmlversion.h \
/usr/include/libxml2/libxml/xmlexports.h \
/usr/include/libxml2/libxml/xmlIO.h \
/usr/include/libxml2/libxml/globals.h \
/usr/include/libxml2/libxml/parser.h /usr/include/libxml2/libxml/tree.h \
/usr/include/libxml2/libxml/xmlstring.h \
/usr/include/libxml2/libxml/xmlregexp.h \
/usr/include/libxml2/libxml/dict.h /usr/include/libxml2/libxml/hash.h \
/usr/include/libxml2/libxml/valid.h \
/usr/include/libxml2/libxml/xmlerror.h \
/usr/include/libxml2/libxml/list.h \
/usr/include/libxml2/libxml/xmlautomata.h \
/usr/include/libxml2/libxml/entities.h \
/usr/include/libxml2/libxml/encoding.h /usr/include/libxml2/libxml/SAX.h \
/usr/include/libxml2/libxml/xlink.h /usr/include/libxml2/libxml/SAX2.h \
/usr/include/libxml2/libxml/xmlmemory.h \
/usr/include/libxml2/libxml/threads.h \
/usr/include/libxml2/libxml/xmlreader.h \
/usr/include/libxml2/libxml/relaxng.h \
/usr/include/libxml2/libxml/xmlschemas.h lib/ea.h lib/b64.h lib/io.h \
lib/archive.h

Binary file not shown.

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,22 @@
lib/filetree.o : lib/filetree.c /usr/include/libxml2/libxml/xmlwriter.h \
/usr/include/libxml2/libxml/xmlversion.h \
/usr/include/libxml2/libxml/xmlexports.h \
/usr/include/libxml2/libxml/xmlIO.h \
/usr/include/libxml2/libxml/globals.h \
/usr/include/libxml2/libxml/parser.h /usr/include/libxml2/libxml/tree.h \
/usr/include/libxml2/libxml/xmlstring.h \
/usr/include/libxml2/libxml/xmlregexp.h \
/usr/include/libxml2/libxml/dict.h /usr/include/libxml2/libxml/hash.h \
/usr/include/libxml2/libxml/valid.h \
/usr/include/libxml2/libxml/xmlerror.h \
/usr/include/libxml2/libxml/list.h \
/usr/include/libxml2/libxml/xmlautomata.h \
/usr/include/libxml2/libxml/entities.h \
/usr/include/libxml2/libxml/encoding.h /usr/include/libxml2/libxml/SAX.h \
/usr/include/libxml2/libxml/xlink.h /usr/include/libxml2/libxml/SAX2.h \
/usr/include/libxml2/libxml/xmlmemory.h \
/usr/include/libxml2/libxml/threads.h \
/usr/include/libxml2/libxml/xmlreader.h \
/usr/include/libxml2/libxml/relaxng.h \
/usr/include/libxml2/libxml/xmlschemas.h include/config.h include/xar.h \
lib/filetree.h lib/ea.h lib/archive.h lib/b64.h

View File

@ -0,0 +1,118 @@
/*
* Copyright (c) 2005 Rob Braun
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of Rob Braun nor the names of his contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* 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.
*/
/*
* 03-Apr-2005
* DRI: Rob Braun <bbraun@opendarwin.org>
*/
/*
* Portions Copyright 2006, Apple Computer, Inc.
* Christopher Ryan <ryanc@apple.com>
*/
#ifndef _XAR_FILETREE_H_
#define _XAR_FILETREE_H_
#ifndef _FILE_OFFSET_BITS
#define _FILE_OFFSET_BITS 64
#endif
#include <libxml/xmlwriter.h>
#include <libxml/xmlreader.h>
struct __xar_attr_t {
const char *key;
const char *value;
const char *ns;
const struct __xar_attr_t *next;
};
typedef const struct __xar_attr_t *xar_attr_t;
struct __xar_prop_t {
const char *key;
const char *value;
const struct __xar_prop_t *parent;
const struct __xar_prop_t *children;
const struct __xar_prop_t *next;
const struct __xar_attr_t *attrs;
const struct __xar_file_t *file;
const char *prefix;
const char *ns;
};
typedef const struct __xar_prop_t *xar_prop_t;
#include "ea.h"
struct __xar_file_t {
const struct __xar_prop_t *props;
const struct __xar_attr_t *attrs;
const char *prefix;
const char *ns;
const char *fspath;
char parent_extracted;
const struct __xar_file_t *parent;
const struct __xar_file_t *children;
const struct __xar_file_t *next;
xar_ea_t eas;
uint64_t nexteaid;
};
#define XAR_ATTR(x) ((struct __xar_attr_t *)(x))
#define XAR_FILE(x) ((struct __xar_file_t *)(x))
#define XAR_PROP(x) ((struct __xar_prop_t *)(x))
void xar_file_free(xar_file_t f);
xar_attr_t xar_attr_new(void);
int32_t xar_attr_set(xar_file_t f, const char *prop, const char *key, const char *value);
int32_t xar_attr_pset(xar_file_t f, xar_prop_t p, const char *key, const char *value);
const char *xar_attr_get(xar_file_t f, const char *prop, const char *key);
const char *xar_attr_pget(xar_file_t f, xar_prop_t p, const char *key);
void xar_attr_free(xar_attr_t a);
void xar_file_serialize(xar_file_t f, xmlTextWriterPtr writer);
xar_file_t xar_file_unserialize(xar_t x, xar_file_t parent, xmlTextReaderPtr reader);
xar_file_t xar_file_find(xar_file_t f, const char *path);
xar_file_t xar_file_new(xar_file_t f);
xar_file_t xar_file_replicate(xar_file_t original, xar_file_t newparent);
void xar_file_free(xar_file_t f);
void xar_prop_serialize(xar_prop_t p, xmlTextWriterPtr writer);
int32_t xar_prop_unserialize(xar_file_t f, xar_prop_t parent, xmlTextReaderPtr reader);
void xar_prop_free(xar_prop_t p);
xar_prop_t xar_prop_new(xar_file_t f, xar_prop_t parent);
xar_prop_t xar_prop_pset(xar_file_t f, xar_prop_t p, const char *key, const char *value);
xar_prop_t xar_prop_find(xar_prop_t p, const char *key);
xar_prop_t xar_prop_pget(xar_prop_t p, const char *key);
const char *xar_prop_getkey(xar_prop_t p);
const char *xar_prop_getvalue(xar_prop_t p);
int32_t xar_prop_setkey(xar_prop_t p, const char *key);
int32_t xar_prop_setvalue(xar_prop_t p, const char *value);
xar_prop_t xar_prop_pfirst(xar_file_t f);
xar_prop_t xar_prop_pnext(xar_prop_t p);
void xar_prop_punset(xar_file_t f, xar_prop_t p);
#endif /* _XAR_FILETREE_H_ */

Binary file not shown.

View File

@ -0,0 +1,22 @@
filetree.o: lib/filetree.c /usr/include/libxml2/libxml/xmlwriter.h \
/usr/include/libxml2/libxml/xmlversion.h \
/usr/include/libxml2/libxml/xmlexports.h \
/usr/include/libxml2/libxml/xmlIO.h \
/usr/include/libxml2/libxml/globals.h \
/usr/include/libxml2/libxml/parser.h /usr/include/libxml2/libxml/tree.h \
/usr/include/libxml2/libxml/xmlstring.h \
/usr/include/libxml2/libxml/xmlregexp.h \
/usr/include/libxml2/libxml/dict.h /usr/include/libxml2/libxml/hash.h \
/usr/include/libxml2/libxml/valid.h \
/usr/include/libxml2/libxml/xmlerror.h \
/usr/include/libxml2/libxml/list.h \
/usr/include/libxml2/libxml/xmlautomata.h \
/usr/include/libxml2/libxml/entities.h \
/usr/include/libxml2/libxml/encoding.h /usr/include/libxml2/libxml/SAX.h \
/usr/include/libxml2/libxml/xlink.h /usr/include/libxml2/libxml/SAX2.h \
/usr/include/libxml2/libxml/xmlmemory.h \
/usr/include/libxml2/libxml/threads.h \
/usr/include/libxml2/libxml/xmlreader.h \
/usr/include/libxml2/libxml/relaxng.h \
/usr/include/libxml2/libxml/xmlschemas.h include/config.h include/xar.h \
lib/filetree.h lib/ea.h lib/archive.h lib/b64.h

Binary file not shown.

262
setup/xar-1.5.2/lib/hash.c Normal file
View File

@ -0,0 +1,262 @@
/*
* Copyright (c) 2005 Rob Braun
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of Rob Braun nor the names of his contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* 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.
*/
/*
* 03-Apr-2005
* DRI: Rob Braun <bbraun@opendarwin.org>
*/
/*
* Portions Copyright 2006, Apple Computer, Inc.
* Christopher Ryan <ryanc@apple.com>
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/types.h>
#include <zlib.h>
#include <openssl/evp.h>
#include "xar.h"
#include "hash.h"
#include "config.h"
#ifndef HAVE_ASPRINTF
#include "asprintf.h"
#endif
struct _hash_context{
EVP_MD_CTX unarchived_cts;
EVP_MD_CTX archived_cts;
uint8_t unarchived;
uint8_t archived;
uint64_t count;
};
#define CONTEXT(x) ((struct _hash_context *)(*x))
static char* xar_format_hash(const unsigned char* m,unsigned int len);
int32_t xar_hash_unarchived(xar_t x, xar_file_t f, xar_prop_t p, void **in, size_t *inlen, void **context) {
return xar_hash_unarchived_out(x,f,p,*in,*inlen,context);
}
int32_t xar_hash_unarchived_out(xar_t x, xar_file_t f, xar_prop_t p, void *in, size_t inlen, void **context) {
const char *opt;
const EVP_MD *md;
xar_prop_t tmpp;
opt = NULL;
tmpp = xar_prop_pget(p, "extracted-checksum");
if( tmpp )
opt = xar_attr_pget(f, tmpp, "style");
if( !opt )
opt = xar_opt_get(x, XAR_OPT_FILECKSUM);
if( !opt || (0 == strcmp(opt, XAR_OPT_VAL_NONE) ) )
return 0;
if(!CONTEXT(context)){
*context = calloc(1,sizeof(struct _hash_context));
OpenSSL_add_all_digests();
}
if( !CONTEXT(context)->unarchived ){
md = EVP_get_digestbyname(opt);
if( md == NULL ) return -1;
EVP_DigestInit(&(CONTEXT(context)->unarchived_cts), md);
CONTEXT(context)->unarchived = 1;
}
if( inlen == 0 )
return 0;
CONTEXT(context)->count += inlen;
EVP_DigestUpdate(&(CONTEXT(context)->unarchived_cts), in, inlen);
return 0;
}
int32_t xar_hash_archived(xar_t x, xar_file_t f, xar_prop_t p, void **in, size_t *inlen, void **context)
{
return xar_hash_archived_in(x,f,p,*in,*inlen,context);
}
int32_t xar_hash_archived_in(xar_t x, xar_file_t f, xar_prop_t p, void *in, size_t inlen, void **context) {
const char *opt;
const EVP_MD *md;
xar_prop_t tmpp;
opt = NULL;
tmpp = xar_prop_pget(p, "archived-checksum");
if( tmpp )
opt = xar_attr_pget(f, tmpp, "style");
if( !opt )
opt = xar_opt_get(x, XAR_OPT_FILECKSUM);
if( !opt || (0 == strcmp(opt, XAR_OPT_VAL_NONE) ) )
return 0;
if(!CONTEXT(context)){
*context = calloc(1,sizeof(struct _hash_context));
OpenSSL_add_all_digests();
}
if ( !CONTEXT(context)->archived ){
md = EVP_get_digestbyname(opt);
if( md == NULL ) return -1;
EVP_DigestInit(&(CONTEXT(context)->archived_cts), md);
CONTEXT(context)->archived = 1;
}
if( inlen == 0 )
return 0;
CONTEXT(context)->count += inlen;
EVP_DigestUpdate(&(CONTEXT(context)->archived_cts), in, inlen);
return 0;
}
int32_t xar_hash_done(xar_t x, xar_file_t f, xar_prop_t p, void **context) {
unsigned char hashstr[EVP_MAX_MD_SIZE];
char *str;
unsigned int len;
xar_prop_t tmpp;
if(!CONTEXT(context))
return 0;
if( CONTEXT(context)->count == 0 )
goto DONE;
if( CONTEXT(context)->unarchived ){
EVP_MD_CTX *ctx = &CONTEXT(context)->unarchived_cts;
const EVP_MD *md = EVP_MD_CTX_md(ctx);
const char *type = EVP_MD_name(md);
memset(hashstr, 0, sizeof(hashstr));
EVP_DigestFinal(&(CONTEXT(context)->unarchived_cts), hashstr, &len);
str = xar_format_hash(hashstr,len);
if( f ) {
tmpp = xar_prop_pset(f, p, "extracted-checksum", str);
if( tmpp )
xar_attr_pset(f, tmpp, "style", type);
}
free(str);
}
if( CONTEXT(context)->archived ){
EVP_MD_CTX *ctx = &CONTEXT(context)->archived_cts;
const EVP_MD *md = EVP_MD_CTX_md(ctx);
const char *type = EVP_MD_name(md);
memset(hashstr, 0, sizeof(hashstr));
EVP_DigestFinal(&(CONTEXT(context)->archived_cts), hashstr, &len);
str = xar_format_hash(hashstr,len);
if( f ) {
tmpp = xar_prop_pset(f, p, "archived-checksum", str);
if( tmpp )
xar_attr_pset(f, tmpp, "style", type);
}
free(str);
}
DONE:
if(*context){
free(*context);
*context = NULL;
}
return 0;
}
static char* xar_format_hash(const unsigned char* m,unsigned int len) {
char* result = malloc((2*len)+1);
char hexValue[3];
unsigned int itr = 0;
result[0] = '\0';
for(itr = 0;itr < len;itr++){
sprintf(hexValue,"%02x",m[itr]);
strncat(result,hexValue,2);
}
return result;
}
int32_t xar_hash_out_done(xar_t x, xar_file_t f, xar_prop_t p, void **context) {
const char *uncomp = NULL, *uncompstyle = NULL;
unsigned char hashstr[EVP_MAX_MD_SIZE];
unsigned int len;
char *tmpstr;
const EVP_MD *md;
int32_t err = 0;
xar_prop_t tmpp;
if(!CONTEXT(context))
return 0;
if( CONTEXT(context)->archived ){
tmpp = xar_prop_pget(p, "archived-checksum");
if( tmpp ) {
uncompstyle = xar_attr_pget(f, tmpp, "style");
uncomp = xar_prop_getvalue(tmpp);
}
md = EVP_get_digestbyname(uncompstyle);
if( uncomp && uncompstyle && md && CONTEXT(context)->archived ) {
char *str;
memset(hashstr, 0, sizeof(hashstr));
EVP_DigestFinal(&(CONTEXT(context)->archived_cts), hashstr, &len);
str = xar_format_hash(hashstr,len);
if(strcmp(uncomp, str) != 0) {
xar_err_new(x);
xar_err_set_file(x, f);
asprintf(&tmpstr, "archived-checksum %s's do not match",uncompstyle);
xar_err_set_string(x, tmpstr);
xar_err_callback(x, XAR_SEVERITY_FATAL, XAR_ERR_ARCHIVE_EXTRACTION);
err = -1;
}
free(str);
}
}
if( CONTEXT(context)->unarchived )
EVP_DigestFinal(&(CONTEXT(context)->unarchived_cts), hashstr, &len);
if(*context){
free(*context);
*context = NULL;
}
return err;
}

View File

@ -0,0 +1,22 @@
lib/hash.o : lib/hash.c include/xar.h lib/hash.h lib/filetree.h \
/usr/include/libxml2/libxml/xmlwriter.h \
/usr/include/libxml2/libxml/xmlversion.h \
/usr/include/libxml2/libxml/xmlexports.h \
/usr/include/libxml2/libxml/xmlIO.h \
/usr/include/libxml2/libxml/globals.h \
/usr/include/libxml2/libxml/parser.h /usr/include/libxml2/libxml/tree.h \
/usr/include/libxml2/libxml/xmlstring.h \
/usr/include/libxml2/libxml/xmlregexp.h \
/usr/include/libxml2/libxml/dict.h /usr/include/libxml2/libxml/hash.h \
/usr/include/libxml2/libxml/valid.h \
/usr/include/libxml2/libxml/xmlerror.h \
/usr/include/libxml2/libxml/list.h \
/usr/include/libxml2/libxml/xmlautomata.h \
/usr/include/libxml2/libxml/entities.h \
/usr/include/libxml2/libxml/encoding.h /usr/include/libxml2/libxml/SAX.h \
/usr/include/libxml2/libxml/xlink.h /usr/include/libxml2/libxml/SAX2.h \
/usr/include/libxml2/libxml/xmlmemory.h \
/usr/include/libxml2/libxml/threads.h \
/usr/include/libxml2/libxml/xmlreader.h \
/usr/include/libxml2/libxml/relaxng.h \
/usr/include/libxml2/libxml/xmlschemas.h lib/ea.h include/config.h

View File

@ -0,0 +1,52 @@
/*
* Copyright (c) 2005 Rob Braun
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of Rob Braun nor the names of his contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* 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.
*/
/*
* 03-Apr-2005
* DRI: Rob Braun <bbraun@opendarwin.org>
*/
/*
* Portions Copyright 2006, Apple Computer, Inc.
* Christopher Ryan <ryanc@apple.com>
*/
#ifndef _XAR_HASH_H_
#define _XAR_HASH_H_
#include "filetree.h"
int32_t xar_hash_archived(xar_t x, xar_file_t f, xar_prop_t p, void **in, size_t *inlen, void **context);
int32_t xar_hash_archived_in(xar_t x, xar_file_t f, xar_prop_t p, void *in, size_t inlen, void **context);
int32_t xar_hash_unarchived(xar_t x, xar_file_t f, xar_prop_t p, void **in, size_t *inlen, void **context);
int32_t xar_hash_unarchived_out(xar_t x, xar_file_t f, xar_prop_t p, void *in, size_t inlen, void **context);
int32_t xar_hash_done(xar_t x, xar_file_t f, xar_prop_t p, void **context);
int32_t xar_hash_out_done(xar_t x, xar_file_t f, xar_prop_t p, void **context);
#endif /* _XAR_HASH_H_ */

BIN
setup/xar-1.5.2/lib/hash.o Normal file

Binary file not shown.

View File

@ -0,0 +1,22 @@
hash.o: lib/hash.c include/xar.h lib/hash.h lib/filetree.h \
/usr/include/libxml2/libxml/xmlwriter.h \
/usr/include/libxml2/libxml/xmlversion.h \
/usr/include/libxml2/libxml/xmlexports.h \
/usr/include/libxml2/libxml/xmlIO.h \
/usr/include/libxml2/libxml/globals.h \
/usr/include/libxml2/libxml/parser.h /usr/include/libxml2/libxml/tree.h \
/usr/include/libxml2/libxml/xmlstring.h \
/usr/include/libxml2/libxml/xmlregexp.h \
/usr/include/libxml2/libxml/dict.h /usr/include/libxml2/libxml/hash.h \
/usr/include/libxml2/libxml/valid.h \
/usr/include/libxml2/libxml/xmlerror.h \
/usr/include/libxml2/libxml/list.h \
/usr/include/libxml2/libxml/xmlautomata.h \
/usr/include/libxml2/libxml/entities.h \
/usr/include/libxml2/libxml/encoding.h /usr/include/libxml2/libxml/SAX.h \
/usr/include/libxml2/libxml/xlink.h /usr/include/libxml2/libxml/SAX2.h \
/usr/include/libxml2/libxml/xmlmemory.h \
/usr/include/libxml2/libxml/threads.h \
/usr/include/libxml2/libxml/xmlreader.h \
/usr/include/libxml2/libxml/relaxng.h \
/usr/include/libxml2/libxml/xmlschemas.h lib/ea.h include/config.h

Binary file not shown.

Some files were not shown because too many files have changed in this diff Show More