RPM Package Manager, CVS Repository
http://rpm5.org/cvs/
____________________________________________________________________________
Server: rpm5.org Name: Jeff Johnson
Root: /v/rpm/cvs Email: jbj@rpm5.org
Module: xar Date: 30-Aug-2007 20:35:46
Branch: HEAD Handle: 2007083019354401
Modified files:
xar configure.ac xar.spec
xar/include xar.h.in
xar/lib Makefile.inc.in archive.c arcmod.c arcmod.h
asprintf.h bzxar.c darwinattr.c data.c io.c
linuxattr.c macho.c script.c stat.c util.c zxar.c
xar/src xar.1 xar.c
Log:
revert to a "working" libxar from svn trunk.
Summary:
Revision Changes Path
1.4 +4 -3 xar/configure.ac
1.2 +4 -0 xar/include/xar.h.in
1.3 +2 -2 xar/lib/Makefile.inc.in
1.3 +35 -14 xar/lib/archive.c
1.2 +37 -0 xar/lib/arcmod.c
1.2 +1 -0 xar/lib/arcmod.h
1.3 +1 -1 xar/lib/asprintf.h
1.2 +2 -2 xar/lib/bzxar.c
1.2 +1 -1 xar/lib/darwinattr.c
1.2 +7 -1 xar/lib/data.c
1.2 +2 -2 xar/lib/io.c
1.2 +7 -4 xar/lib/linuxattr.c
1.2 +7 -3 xar/lib/macho.c
1.2 +5 -1 xar/lib/script.c
1.2 +80 -51 xar/lib/stat.c
1.2 +2 -2 xar/lib/util.c
1.2 +2 -2 xar/lib/zxar.c
1.2 +9 -0 xar/src/xar.1
1.2 +60 -0 xar/src/xar.c
1.3 +1 -3 xar/xar.spec
____________________________________________________________________________
patch -p0 <<'@@ .'
Index: xar/configure.ac
============================================================================
$ cvs diff -u -r1.3 -r1.4 configure.ac
--- xar/configure.ac 29 Aug 2007 12:36:29 -0000 1.3
+++ xar/configure.ac 30 Aug 2007 18:35:44 -0000 1.4
@@ -1,5 +1,5 @@
AC_PREREQ(2.59)
-AC_INIT([OpenDarwin Xar], [1.5.1], [xar@opendarwin.org], [xar])
+AC_INIT([OpenDarwin Xar], [1.5], [xar@opendarwin.org], [xar])
AC_CONFIG_SRCDIR([LICENSE])
dnl Revision number for libxar.
@@ -8,7 +8,7 @@
dnl xar version variables.
XAR_MAJOR_VERSION="1"
-XAR_MINOR_VERSION="5.1"
+XAR_MINOR_VERSION="5"
XAR_VERSION="${XAR_MAJOR_VERSION}.${XAR_MINOR_VERSION}"
AC_SUBST([XAR_MAJOR_VERSION])
AC_SUBST([XAR_MINOR_VERSION])
@@ -157,7 +157,8 @@
)
AC_SUBST([enable_autogen])
-AC_CHECK_HEADERS(sys/acl.h ext2fs/ext2_fs.h sys/statfs.h sys/xattr.h sys/param.h sys/extattr.h libutil.h)
+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)
@@ .
patch -p0 <<'@@ .'
Index: xar/include/xar.h.in
============================================================================
$ cvs diff -u -r1.1 -r1.2 xar.h.in
--- xar/include/xar.h.in 30 May 2007 03:55:57 -0000 1.1
+++ xar/include/xar.h.in 30 Aug 2007 18:35:44 -0000 1.2
@@ -98,6 +98,9 @@
#define XAR_OPT_COALESCE "coalesce" /* Coalesce identical heap blocks */
#define XAR_OPT_LINKSAME "linksame" /* Hardlink identical files */
+#define XAR_OPT_PROPINCLUDE "prop-include" /* File property to include */
+#define XAR_OPT_PROPEXCLUDE "prop-exclude" /* File property to exclude */
+
/* xar signing algorithms */
#define XAR_SIG_SHA1RSA 1
@@ -133,6 +136,7 @@
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_opt_unset(xar_t x, const char *option);
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);
@@ .
patch -p0 <<'@@ .'
Index: xar/lib/Makefile.inc.in
============================================================================
$ cvs diff -u -r1.2 -r1.3 Makefile.inc.in
--- xar/lib/Makefile.inc.in 29 Aug 2007 12:36:30 -0000 1.2
+++ xar/lib/Makefile.inc.in 30 Aug 2007 18:35:45 -0000 1.3
@@ -66,9 +66,9 @@
lib_install : $(LIBXAR_S)
@INSTALL@ -d $(DESTDIR)$(INCLUDEDIR)/xar
- @INSTALL@ -m 0755 $(LIBXAR_INCS) $(DESTDIR)$(INCLUDEDIR)/xar
+ @INSTALL@ -m 0644 $(LIBXAR_INCS) $(DESTDIR)$(INCLUDEDIR)/xar
@INSTALL@ -d $(DESTDIR)$(LIBDIR)
- @INSTALL@ -m 0444 $(LIBXAR_S) $(DESTDIR)$(LIBDIR)
+ @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)
@@ .
patch -p0 <<'@@ .'
Index: xar/lib/archive.c
============================================================================
$ cvs diff -u -r1.2 -r1.3 archive.c
--- xar/lib/archive.c 29 Aug 2007 12:36:30 -0000 1.2
+++ xar/lib/archive.c 30 Aug 2007 18:35:45 -0000 1.3
@@ -415,7 +415,7 @@
wsize *= 2;
wbuf = realloc(wbuf, wsize);
- zs.next_out = wbuf + off;
+ zs.next_out = ((unsigned char *)wbuf) + off;
zs.avail_out = wsize - off;
ret = deflate(&zs, Z_SYNC_FLUSH);
@@ -425,7 +425,7 @@
wbytes = off;
off = 0;
do {
- r = write(tocfd, wbuf+off, wbytes-off);
+ r = write(tocfd, ((char *)wbuf)+off, wbytes-off);
if( (r < 0) && (errno == EINTR) )
continue;
if( r < 0 ) {
@@ -435,7 +435,7 @@
goto CLOSEEND;
}
if( XAR(x)->docksum )
- EVP_DigestUpdate(&XAR(x)->toc_ctx, wbuf+off, r);
+ EVP_DigestUpdate(&XAR(x)->toc_ctx, ((char*)wbuf)+off, r);
off += r;
gztoc += r;
} while( off < wbytes );
@@ -476,7 +476,7 @@
wbytes = r;
off = 0;
do {
- r = write(XAR(x)->fd, rbuf+off, wbytes-off);
+ r = write(XAR(x)->fd, ((char *)rbuf)+off, wbytes-off);
if( (r < 0) && (errno == EINTR) )
continue;
if( r < 0 ) {
@@ -553,7 +553,7 @@
wbytes = r;
off = 0;
do {
- r = write(XAR(x)->fd, rbuf+off, wbytes);
+ r = write(XAR(x)->fd, ((char *)rbuf)+off, wbytes);
if( (r < 0 ) && (errno == EINTR) )
continue;
if( r < 0 ) {
@@ -617,6 +617,8 @@
* x: archive to get the option from
* option: name of the option
* Returns: a pointer to the value of the option
+ * In the case of more than one option with the same name, this will
+ * return the first match.
*/
const char *xar_opt_get(xar_t x, const char *option) {
xar_attr_t i;
@@ -636,7 +638,7 @@
* Returns: 0 for sucess, -1 for failure
*/
int32_t xar_opt_set(xar_t x, const char *option, const char *value) {
- xar_attr_t i, a;
+ xar_attr_t a;
if( (strcmp(option, XAR_OPT_TOCCKSUM) == 0) ) {
if( strcmp(value, XAR_OPT_VAL_NONE) == 0 ) {
@@ -649,13 +651,6 @@
XAR(x)->heap_offset = 16;
}
}
- for(i = XAR(x)->attrs; i ; i = XAR_ATTR(i)->next) {
- if(strcmp(XAR_ATTR(i)->key, option)==0) {
- free((char*)XAR_ATTR(i)->value);
- XAR_ATTR(i)->value = strdup(value);
- return 0;
- }
- }
a = xar_attr_new();
XAR_ATTR(a)->key = strdup(option);
XAR_ATTR(a)->value = strdup(value);
@@ -664,6 +659,26 @@
return 0;
}
+/* xar_opt_unset
+ * x: the archive to set the option of
+ * option: the name of the option to delete
+ * This will delete ALL instances of the option name
+ */
+int32_t xar_opt_unset(xar_t x, const char *option) {
+ xar_attr_t i, p = NULL;
+ for(i = XAR(x)->attrs; i ; p = i, i = XAR_ATTR(i)->next) {
+ if(strcmp(XAR_ATTR(i)->key, option)==0) {
+ if( p == NULL )
+ XAR(x)->attrs = XAR_ATTR(i)->next;
+ else
+ XAR_ATTR(p)->next = XAR_ATTR(i)->next;
+ xar_attr_free(i);
+ i = p;
+ }
+ }
+ return 0;
+}
+
/* xar_add_node
* x: archive the file should belong to
* f: parent node, possibly NULL
@@ -1155,6 +1170,12 @@
const char *sizestring = NULL;
if(0 != xar_prop_get(f,"data/size",&sizestring)){
+ if(0 != xar_prop_get(f, "type", &sizestring))
+ return -1;
+ if(strcmp(sizestring, "file") == 0) {
+ *size = 0;
+ return 0;
+ }
return -1;
}
@@ -1243,7 +1264,7 @@
if( off && (off < XAR(x)->readbuf_len) )
XAR(x)->readbuf_len = off;
- XAR(x)->zs.next_in = XAR(x)->readbuf + XAR(x)->offset;
+ XAR(x)->zs.next_in = ((unsigned char *)XAR(x)->readbuf) + XAR(x)->offset;
XAR(x)->zs.avail_in = XAR(x)->readbuf_len - XAR(x)->offset;
XAR(x)->zs.next_out = (void *)buffer;
XAR(x)->zs.avail_out = len;
@@ .
patch -p0 <<'@@ .'
Index: xar/lib/arcmod.c
============================================================================
$ cvs diff -u -r1.1 -r1.2 arcmod.c
--- xar/lib/arcmod.c 30 May 2007 03:55:58 -0000 1.1
+++ xar/lib/arcmod.c 30 Aug 2007 18:35:45 -0000 1.2
@@ -36,12 +36,15 @@
*/
#include "arcmod.h"
+#include "archive.h"
#include "stat.h"
#include "data.h"
#include "linuxattr.h"
#include "fbsdattr.h"
#include "darwinattr.h"
#include "ext2.h"
+#include "xar.h"
+#include <string.h>
struct arcmod xar_arcmods[] = {
{ xar_stat_archive, xar_stat_extract }, /* must be first */
@@ -107,3 +110,37 @@
int32_t xar_arcmod_verify(xar_t x, xar_file_t f){
return xar_data_verify(x,f);
}
+
+/* xar_check_prop
+ * x: xar archive
+ * name: name of property to check
+ * Description: If XAR_OPT_PROPINCLUDE is set at all, only properties
+ * specified for inclusion will be added.
+ * If XAR_OPT_PROPINCLUDE is not set, and XAR_OPT_PROPEXCLUDE is set,
+ * properies specified by XAR_OPT_PROPEXCLUDE will be omitted.
+ * Returns: 0 for not to include, 1 for include.
+ */
+int32_t xar_check_prop(xar_t x, const char *name) {
+ xar_attr_t i;
+ char includeset = 0;
+
+ for(i = XAR(x)->attrs; i; i = XAR_ATTR(i)->next) {
+ if( strcmp(XAR_ATTR(i)->key, XAR_OPT_PROPINCLUDE) == 0 ) {
+ if( strcmp(XAR_ATTR(i)->value, name) == 0 )
+ return 1;
+ includeset = 1;
+ }
+ }
+
+ if( includeset )
+ return 0;
+
+ for(i = XAR(x)->attrs; i; i = XAR_ATTR(i)->next) {
+ if( strcmp(XAR_ATTR(i)->key, XAR_OPT_PROPEXCLUDE) == 0 ) {
+ if( strcmp(XAR_ATTR(i)->value, name) == 0 )
+ return 0;
+ }
+ }
+
+ return 1;
+}
@@ .
patch -p0 <<'@@ .'
Index: xar/lib/arcmod.h
============================================================================
$ cvs diff -u -r1.1 -r1.2 arcmod.h
--- xar/lib/arcmod.h 30 May 2007 03:55:58 -0000 1.1
+++ xar/lib/arcmod.h 30 Aug 2007 18:35:45 -0000 1.2
@@ -54,5 +54,6 @@
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);
+int32_t xar_check_prop(xar_t x, const char *name);
#endif /* _XAR_ARCMOD_H_ */
@@ .
patch -p0 <<'@@ .'
Index: xar/lib/asprintf.h
============================================================================
$ cvs diff -u -r1.2 -r1.3 asprintf.h
--- xar/lib/asprintf.h 7 Jul 2007 14:20:16 -0000 1.2
+++ xar/lib/asprintf.h 30 Aug 2007 18:35:45 -0000 1.3
@@ -34,7 +34,7 @@
#include <stdio.h>
#include <stdarg.h>
-int
+static inline int
vasprintf(char **rResult, const char *aFormat, va_list aAp)
{
int rVal;
@@ .
patch -p0 <<'@@ .'
Index: xar/lib/bzxar.c
============================================================================
$ cvs diff -u -r1.1 -r1.2 bzxar.c
--- xar/lib/bzxar.c 30 May 2007 03:55:58 -0000 1.1
+++ xar/lib/bzxar.c 30 Aug 2007 18:35:45 -0000 1.2
@@ -106,7 +106,7 @@
out = realloc(out, outlen);
if( out == NULL ) abort();
- BZIP2_CONTEXT(context)->bz.next_out = out + offset;
+ BZIP2_CONTEXT(context)->bz.next_out = ((char *)out) + offset;
BZIP2_CONTEXT(context)->bz.avail_out = outlen - offset;
r = BZ2_bzDecompress(&BZIP2_CONTEXT(context)->bz);
@@ -204,7 +204,7 @@
out = realloc(out, outlen);
if( out == NULL ) abort();
- BZIP2_CONTEXT(context)->bz.next_out = out + offset;
+ BZIP2_CONTEXT(context)->bz.next_out = ((char *)out) + offset;
BZIP2_CONTEXT(context)->bz.avail_out = outlen - offset;
if( (*inlen == 0) )
@@ .
patch -p0 <<'@@ .'
Index: xar/lib/darwinattr.c
============================================================================
$ cvs diff -u -r1.1 -r1.2 darwinattr.c
--- xar/lib/darwinattr.c 30 May 2007 03:55:58 -0000 1.1
+++ xar/lib/darwinattr.c 30 Aug 2007 18:35:45 -0000 1.2
@@ -147,7 +147,7 @@
int32_t r;
size_t off = 0;
do {
- r = write(DARWINATTR_CONTEXT(context)->fd, buf+off, len-off);
+ r = write(DARWINATTR_CONTEXT(context)->fd, ((char *)buf)+off, len-off);
if( (r < 0) && (errno != EINTR) )
return r;
off += r;
@@ .
patch -p0 <<'@@ .'
Index: xar/lib/data.c
============================================================================
$ cvs diff -u -r1.1 -r1.2 data.c
--- xar/lib/data.c 30 May 2007 03:55:58 -0000 1.1
+++ xar/lib/data.c 30 Aug 2007 18:35:45 -0000 1.2
@@ -45,6 +45,7 @@
#include "filetree.h"
#include "archive.h"
#include "io.h"
+#include "arcmod.h"
#ifndef O_EXLOCK
#define O_EXLOCK 0
@@ -79,11 +80,13 @@
/* dont read passed the end of the buffer */
if((DATA_CONTEXT(context)->offset + sizetoread) > DATA_CONTEXT(context)->length){
return -1;
+ //sizetoread = (DATA_CONTEXT(context)->offset + sizetoread) - DATA_CONTEXT(context)->length;
}
readbuf += DATA_CONTEXT(context)->offset;
memcpy(inbuf,readbuf,sizetoread);
+ DATA_CONTEXT(context)->total += sizetoread;
DATA_CONTEXT(context)->offset += sizetoread;
return sizetoread;
@@ -121,7 +124,7 @@
}
do {
- r = write(DATA_CONTEXT(context)->fd, buf+off, len-off);
+ r = write(DATA_CONTEXT(context)->fd, ((char *)buf)+off, len-off);
if( (r < 0) && (errno != EINTR) )
return r;
off += r;
@@ -141,6 +144,9 @@
memset(&context,0,sizeof(struct _data_context));
+ if( !xar_check_prop(x, "data") )
+ return 0;
+
xar_prop_get(f, "type", &opt);
if(!opt) return 0;
if( strcmp(opt, "file") != 0 ) {
@@ .
patch -p0 <<'@@ .'
Index: xar/lib/io.c
============================================================================
$ cvs diff -u -r1.1 -r1.2 io.c
--- xar/lib/io.c 30 May 2007 03:55:58 -0000 1.1
+++ xar/lib/io.c 30 Aug 2007 18:35:45 -0000 1.2
@@ -165,7 +165,7 @@
off = 0;
if( rsize != 0 ) {
do {
- r = write(XAR(x)->heap_fd, inbuf+off, rsize-off);
+ r = write(XAR(x)->heap_fd, ((char *)inbuf)+off, rsize-off);
if( (r < 0) && (errno != EINTR) )
return -1;
off += r;
@@ -555,7 +555,7 @@
off = 0;
do {
- r = write(XAR(xdest)->heap_fd, inbuf+off, r-off );
+ r = write(XAR(xdest)->heap_fd, ((char *)inbuf)+off, r-off );
off += r;
writesize += r;
} while( off < r );
@@ .
patch -p0 <<'@@ .'
Index: xar/lib/linuxattr.c
============================================================================
$ cvs diff -u -r1.1 -r1.2 linuxattr.c
--- xar/lib/linuxattr.c 30 May 2007 03:55:58 -0000 1.1
+++ xar/lib/linuxattr.c 30 Aug 2007 18:35:45 -0000 1.2
@@ -118,12 +118,12 @@
if( (LINUXATTR_CONTEXT(context)->bufsz-LINUXATTR_CONTEXT(context)->off) <= len ) {
int32_t ret;
ret = LINUXATTR_CONTEXT(context)->bufsz - LINUXATTR_CONTEXT(context)->off;
- memcpy(buf, LINUXATTR_CONTEXT(context)->buf+LINUXATTR_CONTEXT(context)->off, ret);
+ memcpy(buf, ((char *)LINUXATTR_CONTEXT(context)->buf)+LINUXATTR_CONTEXT(context)->off, ret);
LINUXATTR_CONTEXT(context)->off += ret;
return(ret);
} else {
- memcpy(buf, LINUXATTR_CONTEXT(context)->buf+LINUXATTR_CONTEXT(context)->off, len);
- LINUXATTR_CONTEXT(context)->buf += len;
+ memcpy(buf, ((char *)LINUXATTR_CONTEXT(context)->buf)+LINUXATTR_CONTEXT(context)->off, len);
+ LINUXATTR_CONTEXT(context)->buf = ((char *)LINUXATTR_CONTEXT(context)->buf) + len;
return len;
}
}
@@ -143,12 +143,15 @@
struct _linuxattr_context context;
memset(&context,0,sizeof(struct _linuxattr_context));
-
+
/* data from buffers don't have linuxattr */
if(len)
return 0;
if( file == NULL )
return 0;
+
+ if( !xar_check_prop(x, "ea") )
+ return 0;
TRYAGAIN:
buf = malloc(bufsz);
@@ .
patch -p0 <<'@@ .'
Index: xar/lib/macho.c
============================================================================
$ cvs diff -u -r1.1 -r1.2 macho.c
--- xar/lib/macho.c 30 May 2007 03:55:58 -0000 1.1
+++ xar/lib/macho.c 30 Aug 2007 18:35:45 -0000 1.2
@@ -45,6 +45,7 @@
#include "macho.h"
#include "util.h"
#include "data.h"
+#include "arcmod.h"
#include "xar.h"
#define BIT64 0x01000000
@@ -297,7 +298,7 @@
}
}
} else {
- memcpy(context->buffer, in+off, inlen-off);
+ memcpy(context->buffer, ((char *)in)+off, inlen-off);
context->buffersz = inlen-off;
consumed = inlen;
context->state = lf_inc_loadcommand;
@@ -316,7 +317,7 @@
else
offset = *offsetp;
lib = calloc(1,(cmdsize - offset)+1);
- memcpy(lib, in+(offset - 8), cmdsize - offset);
+ memcpy(lib, ((char *)in)+(offset - 8), cmdsize - offset);
tmpstr = macho_cpustr(context->me[context->curme].mh.cputype);
asprintf(&propstr, "contents/%s/library", tmpstr);
xar_prop_create(f, propstr, lib);
@@ -360,12 +361,15 @@
if( strcmp(xar_prop_getkey(p), "data") != 0 )
return 0;
+ if( !xar_check_prop(x, "contents") )
+ return 0;
+
if( !*context ) {
*context = calloc(1,sizeof(struct _macho_context));
}
while( total < *inlen ) {
- consumed = macho_parse(f, *in+total, *inlen-total, MACHO_CONTEXT(context));
+ consumed = macho_parse(f, ((char *)*in)+total, *inlen-total, MACHO_CONTEXT(context));
total += consumed;
MACHO_CONTEXT(context)->curroffset += consumed;
}
@@ .
patch -p0 <<'@@ .'
Index: xar/lib/script.c
============================================================================
$ cvs diff -u -r1.1 -r1.2 script.c
--- xar/lib/script.c 30 May 2007 03:55:58 -0000 1.1
+++ xar/lib/script.c 30 Aug 2007 18:35:45 -0000 1.2
@@ -41,6 +41,7 @@
#endif
#include "xar.h"
#include "filetree.h"
+#include "arcmod.h"
struct _script_context{
int initted;
@@ -59,6 +60,9 @@
if( SCRIPT_CONTEXT(context)->initted )
return 0;
+ if( !xar_check_prop(x, "contents") )
+ return 0;
+
/*We only run on the begining of the file, so once we init, we don't run again*/
SCRIPT_CONTEXT(context)->initted = 1;
@@ -75,7 +79,7 @@
exe[i-2] = buf[i];
}
- tmpp = xar_prop_pset(f, p, "content", NULL);
+ tmpp = xar_prop_pset(f, p, "contents", NULL);
if( tmpp ) {
xar_prop_pset(f, tmpp, "type", "script");
xar_prop_pset(f, tmpp, "interpreter", exe);
@@ .
patch -p0 <<'@@ .'
Index: xar/lib/stat.c
============================================================================
$ cvs diff -u -r1.1 -r1.2 stat.c
--- xar/lib/stat.c 30 May 2007 03:55:58 -0000 1.1
+++ xar/lib/stat.c 30 Aug 2007 18:35:45 -0000 1.2
@@ -118,7 +118,7 @@
return ret;
}
-static int32_t aacls(xar_file_t f, const char *file) {
+static int32_t aacls(xar_t x, xar_file_t f, const char *file) {
#ifdef HAVE_SYS_ACL_H
#if !defined(__APPLE__)
acl_t a;
@@ -128,6 +128,9 @@
if( !type || (strcmp(type, "symlink") == 0) )
return 0;
+ if( !xar_check_prop(x, "acl") )
+ return 0;
+
a = acl_get_file(file, ACL_TYPE_DEFAULT);
if( a ) {
char *t;
@@ -168,6 +171,9 @@
acl_t a;
int i;
+ if( !xar_check_prop(x, "acl") )
+ return 0;
+
a = acl_get_file(file, ACL_TYPE_EXTENDED);
if( !a )
return 0;
@@ -279,10 +285,13 @@
}
#endif
-static int32_t flags_archive(xar_file_t f, const struct stat *sb) {
+static int32_t flags_archive(xar_t x, xar_file_t f, const struct stat *sb) {
#ifdef HAVE_STRUCT_STAT_ST_FLAGS
if( !sb->st_flags )
return 0;
+
+ if( !xar_check_prop(x, XAR_FLAG_FORK) )
+ return 0;
#ifdef UF_NODUMP
if( sb->st_flags & UF_NODUMP )
x_addflag(f, "UserNoDump");
@@ -390,7 +399,8 @@
/* no stat attributes for data from a buffer, it is just a file */
if(len){
- xar_prop_set(f, "type", "file");
+ if( xar_check_prop(x, "type") )
+ xar_prop_set(f, "type", "file");
return 0;
}
@@ -405,21 +415,24 @@
return -1;
}
tmpf = xar_link_lookup(x, XAR(x)->sbcache.st_dev, XAR(x)->sbcache.st_ino, f);
- xar_prop_set(f, "type", "hardlink");
- if( tmpf ) {
- const char *id;
- id = xar_attr_get(tmpf, NULL, "id");
- xar_attr_set(f, "type", "link", id);
- } else {
- xar_attr_set(f, "type", "link", "original");
+ if( xar_check_prop(x, "type") ) {
+ xar_prop_set(f, "type", "hardlink");
+ if( tmpf ) {
+ const char *id;
+ id = xar_attr_get(tmpf, NULL, "id");
+ xar_attr_set(f, "type", "link", id);
+ } else {
+ xar_attr_set(f, "type", "link", "original");
+ }
}
} else {
type = filetype_name(XAR(x)->sbcache.st_mode & S_IFMT);
- xar_prop_set(f, "type", type);
+ if( xar_check_prop(x, "type") )
+ xar_prop_set(f, "type", type);
}
/* Record major/minor device node numbers */
- if( S_ISBLK(XAR(x)->sbcache.st_mode) || S_ISCHR(XAR(x)->sbcache.st_mode)) {
+ if( xar_check_prop(x, "device") && (S_ISBLK(XAR(x)->sbcache.st_mode) || S_ISCHR(XAR(x)->sbcache.st_mode))) {
uint32_t major, minor;
char tmpstr[12];
xar_devmake(XAR(x)->sbcache.st_rdev, &major, &minor);
@@ -446,47 +459,63 @@
}
}
- asprintf(&tmpstr, "%04o", XAR(x)->sbcache.st_mode & (~S_IFMT));
- xar_prop_set(f, "mode", tmpstr);
- free(tmpstr);
-
- asprintf(&tmpstr, "%"PRIu64, (uint64_t)XAR(x)->sbcache.st_uid);
- xar_prop_set(f, "uid", tmpstr);
- free(tmpstr);
-
- pw = getpwuid(XAR(x)->sbcache.st_uid);
- if( pw )
- xar_prop_set(f, "user", pw->pw_name);
-
- asprintf(&tmpstr, "%"PRIu64, (uint64_t)XAR(x)->sbcache.st_gid);
- xar_prop_set(f, "gid", tmpstr);
- free(tmpstr);
-
- gr = getgrgid(XAR(x)->sbcache.st_gid);
- if( gr )
- xar_prop_set(f, "group", gr->gr_name);
-
- gmtime_r(&XAR(x)->sbcache.st_atime, &t);
- memset(time, 0, sizeof(time));
- strftime(time, sizeof(time), "%FT%T", &t);
- strcat(time, "Z");
- xar_prop_set(f, "atime", time);
-
- gmtime_r(&XAR(x)->sbcache.st_mtime, &t);
- memset(time, 0, sizeof(time));
- strftime(time, sizeof(time), "%FT%T", &t);
- strcat(time, "Z");
- xar_prop_set(f, "mtime", time);
-
- gmtime_r(&XAR(x)->sbcache.st_ctime, &t);
- memset(time, 0, sizeof(time));
- strftime(time, sizeof(time), "%FT%T", &t);
- strcat(time, "Z");
- xar_prop_set(f, "ctime", time);
+ if( xar_check_prop(x, "mode") ) {
+ asprintf(&tmpstr, "%04o", XAR(x)->sbcache.st_mode & (~S_IFMT));
+ xar_prop_set(f, "mode", tmpstr);
+ free(tmpstr);
+ }
+
+ if( xar_check_prop(x, "uid") ) {
+ asprintf(&tmpstr, "%"PRIu64, (uint64_t)XAR(x)->sbcache.st_uid);
+ xar_prop_set(f, "uid", tmpstr);
+ free(tmpstr);
+ }
+
+ if( xar_check_prop(x, "user") ) {
+ pw = getpwuid(XAR(x)->sbcache.st_uid);
+ if( pw )
+ xar_prop_set(f, "user", pw->pw_name);
+ }
+
+ if( xar_check_prop(x, "gid") ) {
+ asprintf(&tmpstr, "%"PRIu64, (uint64_t)XAR(x)->sbcache.st_gid);
+ xar_prop_set(f, "gid", tmpstr);
+ free(tmpstr);
+ }
+
+ if( xar_check_prop(x, "group") ) {
+ gr = getgrgid(XAR(x)->sbcache.st_gid);
+ if( gr )
+ xar_prop_set(f, "group", gr->gr_name);
+ }
+
+ if( xar_check_prop(x, "atime") ) {
+ gmtime_r(&XAR(x)->sbcache.st_atime, &t);
+ memset(time, 0, sizeof(time));
+ strftime(time, sizeof(time), "%FT%T", &t);
+ strcat(time, "Z");
+ xar_prop_set(f, "atime", time);
+ }
+
+ if( xar_check_prop(x, "mtime") ) {
+ gmtime_r(&XAR(x)->sbcache.st_mtime, &t);
+ memset(time, 0, sizeof(time));
+ strftime(time, sizeof(time), "%FT%T", &t);
+ strcat(time, "Z");
+ xar_prop_set(f, "mtime", time);
+ }
+
+ if( xar_check_prop(x, "ctime") ) {
+ gmtime_r(&XAR(x)->sbcache.st_ctime, &t);
+ memset(time, 0, sizeof(time));
+ strftime(time, sizeof(time), "%FT%T", &t);
+ strcat(time, "Z");
+ xar_prop_set(f, "ctime", time);
+ }
- flags_archive(f, &(XAR(x)->sbcache));
+ flags_archive(x, f, &(XAR(x)->sbcache));
- aacls(f, file);
+ aacls(x, f, file);
return 0;
}
@@ .
patch -p0 <<'@@ .'
Index: xar/lib/util.c
============================================================================
$ cvs diff -u -r1.1 -r1.2 util.c
--- xar/lib/util.c 30 May 2007 03:55:58 -0000 1.1
+++ xar/lib/util.c 30 Aug 2007 18:35:45 -0000 1.2
@@ -117,7 +117,7 @@
ssize_t off = 0;
while ( off < nbytes ) {
- rb = read(fd, buffer+off, nbytes-off);
+ rb = read(fd, ((char *)buffer)+off, nbytes-off);
if( (rb < 1 ) && (errno != EINTR) && (errno != EAGAIN) )
return -1;
off += rb;
@@ -136,7 +136,7 @@
ssize_t off = 0;
while ( off < nbytes ) {
- rb = write(fd, buffer+off, nbytes-off);
+ rb = write(fd, ((char *)buffer)+off, nbytes-off);
if( (rb < 1 ) && (errno != EINTR) && (errno != EAGAIN) )
return -1;
off += rb;
@@ .
patch -p0 <<'@@ .'
Index: xar/lib/zxar.c
============================================================================
$ cvs diff -u -r1.1 -r1.2 zxar.c
--- xar/lib/zxar.c 30 May 2007 03:55:58 -0000 1.1
+++ xar/lib/zxar.c 30 Aug 2007 18:35:45 -0000 1.2
@@ -98,7 +98,7 @@
out = realloc(out, outlen);
if( out == NULL ) abort();
- GZIP_CONTEXT(context)->z.next_out = out + offset;
+ GZIP_CONTEXT(context)->z.next_out = ((unsigned char *)out) + offset;
GZIP_CONTEXT(context)->z.avail_out = outlen - offset;
r = inflate(&(GZIP_CONTEXT(context)->z), Z_SYNC_FLUSH);
@@ -195,7 +195,7 @@
out = realloc(out, outlen);
if( out == NULL ) abort();
- GZIP_CONTEXT(context)->z.next_out = out + offset;
+ GZIP_CONTEXT(context)->z.next_out = ((unsigned char *)out) + offset;
GZIP_CONTEXT(context)->z.avail_out = outlen - offset;
if( *inlen == 0 )
@@ .
patch -p0 <<'@@ .'
Index: xar/src/xar.1
============================================================================
$ cvs diff -u -r1.1 -r1.2 xar.1
--- xar/src/xar.1 30 May 2007 03:56:00 -0000 1.1
+++ xar/src/xar.1 30 Aug 2007 18:35:45 -0000 1.2
@@ -81,6 +81,15 @@
.TP
\-\-no-compress
Specifies a POSIX regular expression of files to archive, but not compress. The archived files will be copied raw into the archive. This can be used to exclude already gzipped files from being gzipped during the archival process.
+.TP
+\-\-prop-include
+Specifies a file property to be included in the archive. When this option is specified, only the specified options will be included. Anything not specifically included with this option will be omitted. This option can be used multiple times.
+.TP
+\-\-prop-exclude
+Specifies a file property to be excluded from the archive. When this option is specified, all file properties will be included except the specified properties. This option can be used multiple times.
+.TP
+\-\-distribution
+Creates an archive to only contain file properties safe for file distribution. Currently, only name, type, mode, and data are preserved with this option.
.SH EXAMPLES
.TP
xar -cf sample.xar /home/uid
@@ .
patch -p0 <<'@@ .'
Index: xar/src/xar.c
============================================================================
$ cvs diff -u -r1.1 -r1.2 xar.c
--- xar/src/xar.c 30 May 2007 03:56:00 -0000 1.1
+++ xar/src/xar.c 30 Aug 2007 18:35:45 -0000 1.2
@@ -76,6 +76,10 @@
struct lnode *Exclude_Tail = NULL;
struct lnode *NoCompress = NULL;
struct lnode *NoCompress_Tail = NULL;
+struct lnode *PropInclude = NULL;
+struct lnode *PropInclude_Tail = NULL;
+struct lnode *PropExclude = NULL;
+struct lnode *PropExclude_Tail = NULL;
static int32_t err_callback(int32_t sev, int32_t err, xar_errctx_t ctx, void *usrctx);
@@ -170,6 +174,13 @@
xar_register_errhandler(x, err_callback, NULL);
+ for( i = PropInclude; i; i=i->next ) {
+ xar_opt_set(x, XAR_OPT_PROPINCLUDE, i->str);
+ }
+ for( i = PropExclude; i; i=i->next ) {
+ xar_opt_set(x, XAR_OPT_PROPEXCLUDE, i->str);
+ }
+
if( Subdoc )
add_subdoc(x);
@@ -585,6 +596,10 @@
fprintf(stderr, "\t--link-same Hardlink identical files\n");
fprintf(stderr, "\t--no-compress POSIX regular expression of files\n");
fprintf(stderr, "\t not to archive, but not compress.\n");
+ fprintf(stderr, "\t--prop-include File properties to include in archive\n");
+ fprintf(stderr, "\t--prop-exclude File properties to exclude in archive\n");
+ fprintf(stderr, "\t--distribution Only includes a subset of file properties\n");
+ fprintf(stderr, "\t appropriate for archive distribution\n");
fprintf(stderr, "\t--version Print xar's version number\n");
return;
@@ -619,6 +634,9 @@
{"coalesce-heap", 0, 0, 9},
{"link-same", 0, 0, 10},
{"no-compress", 1, 0, 11},
+ {"prop-include", 1, 0, 12},
+ {"prop-exclude", 1, 0, 13},
+ {"distribution", 0, 0, 14},
{ 0, 0, 0, 0}
};
@@ -730,6 +748,48 @@
NoCompress_Tail = tmp;
}
break;
+ case 12 :
+ tmp = malloc(sizeof(struct lnode));
+ tmp->str = optarg;
+ tmp->next = NULL;
+ if( PropInclude == NULL ) {
+ PropInclude = tmp;
+ PropInclude_Tail = tmp;
+ } else {
+ PropInclude_Tail->next = tmp;
+ PropInclude_Tail = tmp;
+ }
+ break;
+ case 13 :
+ tmp = malloc(sizeof(struct lnode));
+ tmp->str = optarg;
+ tmp->next = NULL;
+ if( PropExclude == NULL ) {
+ PropExclude = tmp;
+ PropExclude_Tail = tmp;
+ } else {
+ PropExclude_Tail->next = tmp;
+ PropExclude_Tail = tmp;
+ }
+ break;
+ case 14 :
+ {
+ char *props[] = { "type", "data", "mode", "name" };
+ int i;
+ for( i = 0; i < 4; i++ ) {
+ tmp = malloc(sizeof(struct lnode));
+ tmp->str = strdup(props[i]);
+ tmp->next = NULL;
+ if( PropInclude == NULL ) {
+ PropInclude = tmp;
+ PropInclude_Tail = tmp;
+ } else {
+ PropInclude_Tail->next = tmp;
+ PropInclude_Tail = tmp;
+ }
+ }
+ }
+ break;
case 'c':
case 'x':
case 't':
@@ .
patch -p0 <<'@@ .'
Index: xar/xar.spec
============================================================================
$ cvs diff -u -r1.2 -r1.3 xar.spec
--- xar/xar.spec 7 Jul 2007 14:20:16 -0000 1.2
+++ xar/xar.spec 30 Aug 2007 18:35:44 -0000 1.3
@@ -1,6 +1,6 @@
Name: xar
Epoch: 0
-Version: 1.5.1
+Version: 1.5
Release: 1
Summary: The XAR project aims to provide an easily extensible archive format.
Group: Applications/Archivers
@@ -60,8 +60,6 @@
%{_libdir}/lib%{name}.1.so
%changelog
-* Fri May 25 2007 Rob Braun <bbraun@synack.net> 0:1.5.1-1
-- 1.5.1
* Mon May 07 2007 Rob Braun <bbraun@synack.net> 0:1.5-1
- 1.5
* Thu Feb 23 2005 Rob Braun <bbraun@opendarwin.org> - 0:1.2-1
@@ .
Received on Thu Aug 30 20:35:46 2007