From 3c5890b1f48cd2cc2ecf69d7725765f2b3dbfb4a Mon Sep 17 00:00:00 2001 From: Apple Date: Wed, 7 Dec 2011 01:13:54 +0000 Subject: [PATCH] copyfile-89.tar.gz --- Makefile | 40 ------ copyfile.c | 25 +++- copyfile.xcodeproj/project.pbxproj | 218 +++++++++++++++++++++++++++++ xcodescripts/install_files.sh | 35 +++++ 4 files changed, 273 insertions(+), 45 deletions(-) delete mode 100644 Makefile create mode 100644 copyfile.xcodeproj/project.pbxproj create mode 100644 xcodescripts/install_files.sh diff --git a/Makefile b/Makefile deleted file mode 100644 index b4cde73..0000000 --- a/Makefile +++ /dev/null @@ -1,40 +0,0 @@ -# buildit may need "-project copyfile-123" (any number should do) -Project = copyfile -Install_Dir = /usr/lib/system -ProductType = dylib -BuildProfile = YES -BuildDebug = YES - -CFILES = copyfile.c $(OBJROOT)/$(Project)/_version.c -MANPAGES = copyfile.3 -MAN_DIR = $(DSTROOT)/usr/share/man/man3 - -Install_Headers_Directory = /usr/include -Install_Headers = copyfile.h - -WFLAGS= -Wno-trigraphs -Wmissing-prototypes -Wreturn-type -Wformat \ - -Wmissing-braces -Wparentheses -Wswitch -Wunused-function \ - -Wunused-label -Wunused-variable -Wunused-value -Wshadow \ - -Wsign-compare -Wall -Wextra -Wpointer-arith -Wreturn-type \ - -Wwrite-strings -Wcast-align -Wbad-function-cast \ - -Wchar-subscripts -Winline -Wnested-externs -Wredundant-decls \ - -Wno-parentheses -Wformat=2 -Wimplicit-function-declaration \ - -Wshorten-64-to-32 -Wformat-security - -SDKROOT ?= / - -Extra_CC_Flags = ${WFLAGS} -fno-common \ - -D__DARWIN_NOW_CANCELABLE=1 -I. - -Extra_LD_Flags = -Wl,-umbrella -Wl,System - -include $(MAKEFILEPATH)/CoreOS/ReleaseControl/BSDCommon.make - -$(OBJROOT)/$(Project)/_version.c: - /Developer/Makefiles/bin/version.pl copyfile > $@ - -after_install: - for a in fcopyfile copyfile_state_alloc copyfile_state_free \ - copyfile_state_get copyfile_state_set ; do \ - ln $(MAN_DIR)/copyfile.3 $(MAN_DIR)/$$a.3 ; \ - done diff --git a/copyfile.c b/copyfile.c index 6e8c0dd..a1861ea 100644 --- a/copyfile.c +++ b/copyfile.c @@ -982,7 +982,7 @@ int copyfile(const char *src, const char *dst, copyfile_state_t state, copyfile_ free(S->NAME); \ S->NAME = NULL; \ } \ - if ((S->NAME = strdup(NAME)) == NULL) \ + if ((NAME) && (S->NAME = strdup(NAME)) == NULL) \ return -1; \ } \ } while (0) @@ -998,6 +998,10 @@ int copyfile(const char *src, const char *dst, copyfile_state_t state, copyfile_ /* * Get a copy of the source file's security settings */ + if (s->original_fsec) { + filesec_free(s->original_fsec); + s->original_fsec = NULL; + } if ((s->original_fsec = filesec_init()) == NULL) goto error_exit; @@ -1277,6 +1281,10 @@ copyfile_state_t copyfile_state_alloc(void) { s->src_fd = -2; s->dst_fd = -2; + if (s->fsec) { + filesec_free(s->fsec); + s->fsec = NULL; + } s->fsec = filesec_init(); } else errno = ENOMEM; @@ -2219,6 +2227,11 @@ static int copyfile_xattr(copyfile_state_t s) for (name = namebuf; name <= end; name += strlen(name) + 1) { + if (s->xattr_name) { + free(s->xattr_name); + s->xattr_name = NULL; + } + /* If the quarantine information shows up as an EA, we skip over it */ if (strncmp(name, XATTR_QUARANTINE_NAME, end - name) == 0) continue; @@ -2275,10 +2288,6 @@ static int copyfile_xattr(copyfile_state_t s) } #endif - if (s->xattr_name) { - free(s->xattr_name); - s->xattr_name = NULL; - } s->xattr_name = strdup(name); if (s->statuscb) { @@ -3156,6 +3165,10 @@ acl_done: s->xattr_name = strdup((char*)entry->name); s->totalCopied = 0; rv = (*s->statuscb)(COPYFILE_COPY_XATTR, COPYFILE_START, s, s->src, s->dst, s->ctx); + if (s->xattr_name) { + free(s->xattr_name); + s->xattr_name = NULL; + } if (rv == COPYFILE_QUIT) { s->err = ECANCELED; error = -1; @@ -3481,6 +3494,7 @@ static int copyfile_pack_rsrcfork(copyfile_state_t s, attr_header_t *filehdr) s->xattr_name = (char*)XATTR_RESOURCEFORK_NAME; rv = (*s->statuscb)(COPYFILE_COPY_XATTR, COPYFILE_START, s, s->src, s->dst, s->ctx); + s->xattr_name = NULL; if (rv == COPYFILE_SKIP) { ret = 0; goto done; @@ -3772,6 +3786,7 @@ static int copyfile_pack(copyfile_state_t s) int rv; s->xattr_name = (char*)XATTR_FINDERINFO_NAME; rv = (*s->statuscb)(COPYFILE_COPY_XATTR, COPYFILE_START, s, s->src, s->dst, s->ctx); + s->xattr_name = NULL; if (rv == COPYFILE_QUIT) { s->xattr_name = NULL; diff --git a/copyfile.xcodeproj/project.pbxproj b/copyfile.xcodeproj/project.pbxproj new file mode 100644 index 0000000..181f09c --- /dev/null +++ b/copyfile.xcodeproj/project.pbxproj @@ -0,0 +1,218 @@ +// !$*UTF8*$! +{ + archiveVersion = 1; + classes = { + }; + objectVersion = 46; + objects = { + +/* Begin PBXBuildFile section */ + FCCE17C3135A658F002CEE6D /* copyfile.c in Sources */ = {isa = PBXBuildFile; fileRef = FCCE17C1135A658F002CEE6D /* copyfile.c */; }; + FCCE17C4135A658F002CEE6D /* copyfile.h in Headers */ = {isa = PBXBuildFile; fileRef = FCCE17C2135A658F002CEE6D /* copyfile.h */; settings = {ATTRIBUTES = (Public, ); }; }; +/* End PBXBuildFile section */ + +/* Begin PBXFileReference section */ + FCCE17BB135A6444002CEE6D /* libcopyfile.dylib */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.dylib"; includeInIndex = 0; path = libcopyfile.dylib; sourceTree = BUILT_PRODUCTS_DIR; }; + FCCE17C0135A658F002CEE6D /* copyfile.3 */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = copyfile.3; sourceTree = ""; }; + FCCE17C1135A658F002CEE6D /* copyfile.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = copyfile.c; sourceTree = ""; }; + FCCE17C2135A658F002CEE6D /* copyfile.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = copyfile.h; sourceTree = ""; }; + FCCE17C5135A659B002CEE6D /* BSD.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; name = BSD.xcconfig; path = Makefiles/CoreOS/Xcode/BSD.xcconfig; sourceTree = DEVELOPER_DIR; }; +/* End PBXFileReference section */ + +/* Begin PBXFrameworksBuildPhase section */ + FCCE17B8135A6444002CEE6D /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXFrameworksBuildPhase section */ + +/* Begin PBXGroup section */ + FCCE17AB135A5FFB002CEE6D = { + isa = PBXGroup; + children = ( + FCCE17C0135A658F002CEE6D /* copyfile.3 */, + FCCE17C1135A658F002CEE6D /* copyfile.c */, + FCCE17C2135A658F002CEE6D /* copyfile.h */, + FCCE17C5135A659B002CEE6D /* BSD.xcconfig */, + FCCE17BC135A6444002CEE6D /* Products */, + ); + sourceTree = ""; + }; + FCCE17BC135A6444002CEE6D /* Products */ = { + isa = PBXGroup; + children = ( + FCCE17BB135A6444002CEE6D /* libcopyfile.dylib */, + ); + name = Products; + sourceTree = ""; + }; +/* End PBXGroup section */ + +/* Begin PBXHeadersBuildPhase section */ + FCCE17B9135A6444002CEE6D /* Headers */ = { + isa = PBXHeadersBuildPhase; + buildActionMask = 2147483647; + files = ( + FCCE17C4135A658F002CEE6D /* copyfile.h in Headers */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXHeadersBuildPhase section */ + +/* Begin PBXNativeTarget section */ + FCCE17BA135A6444002CEE6D /* copyfile */ = { + isa = PBXNativeTarget; + buildConfigurationList = FCCE17BE135A6444002CEE6D /* Build configuration list for PBXNativeTarget "copyfile" */; + buildPhases = ( + FCCE17B7135A6444002CEE6D /* Sources */, + FCCE17B8135A6444002CEE6D /* Frameworks */, + FCCE17B9135A6444002CEE6D /* Headers */, + FCCE17DF135A70A0002CEE6D /* Run Script */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = copyfile; + productName = copyfile; + productReference = FCCE17BB135A6444002CEE6D /* libcopyfile.dylib */; + productType = "com.apple.product-type.library.dynamic"; + }; +/* End PBXNativeTarget section */ + +/* Begin PBXProject section */ + FCCE17AD135A5FFB002CEE6D /* Project object */ = { + isa = PBXProject; + attributes = { + ORGANIZATIONNAME = "Apple Inc."; + }; + buildConfigurationList = FCCE17B0135A5FFB002CEE6D /* Build configuration list for PBXProject "copyfile" */; + compatibilityVersion = "Xcode 3.2"; + developmentRegion = English; + hasScannedForEncodings = 0; + knownRegions = ( + en, + ); + mainGroup = FCCE17AB135A5FFB002CEE6D; + productRefGroup = FCCE17BC135A6444002CEE6D /* Products */; + projectDirPath = ""; + projectRoot = ""; + targets = ( + FCCE17BA135A6444002CEE6D /* copyfile */, + ); + }; +/* End PBXProject section */ + +/* Begin PBXShellScriptBuildPhase section */ + FCCE17DF135A70A0002CEE6D /* Run Script */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 8; + files = ( + ); + inputPaths = ( + ); + name = "Run Script"; + outputPaths = ( + ); + runOnlyForDeploymentPostprocessing = 1; + shellPath = /bin/sh; + shellScript = ". \"$PROJECT_DIR\"/xcodescripts/install_files.sh"; + }; +/* End PBXShellScriptBuildPhase section */ + +/* Begin PBXSourcesBuildPhase section */ + FCCE17B7135A6444002CEE6D /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + FCCE17C3135A658F002CEE6D /* copyfile.c in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXSourcesBuildPhase section */ + +/* Begin XCBuildConfiguration section */ + FCCE17B3135A5FFB002CEE6D /* Release */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = FCCE17C5135A659B002CEE6D /* BSD.xcconfig */; + buildSettings = { + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_MISSING_PROTOTYPES = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES; + GCC_WARN_SHADOW = YES; + GCC_WARN_SIGN_COMPARE = YES; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_LABEL = YES; + GCC_WARN_UNUSED_PARAMETER = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + WARNING_CFLAGS = ( + "-Wall", + "-Wextra", + "-Wformat=2", + "-Wformat-security", + "-Wnested-externs", + "-Wno-trigraphs", + "-Wredundant-decls", + "-Wwrite-strings", + ); + }; + name = Release; + }; + FCCE17BD135A6444002CEE6D /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + BUILD_VARIANTS = ( + normal, + debug, + ); + DYLIB_CURRENT_VERSION = "$(RC_ProjectSourceVersion)"; + EXECUTABLE_PREFIX = lib; + GCC_NO_COMMON_BLOCKS = YES; + GCC_PREPROCESSOR_DEFINITIONS = "__DARWIN_NOW_CANCELABLE=1"; + INSTALL_PATH = /usr/lib/system; + OTHER_LDFLAGS = ( + "-umbrella", + System, + ); + PRODUCT_NAME = "$(TARGET_NAME)"; + PUBLIC_HEADERS_FOLDER_PATH = /usr/include; + WARNING_CFLAGS = ( + "-Wall", + "-Wextra", + "-Wformat=2", + "-Wformat-security", + "-Wnested-externs", + "-Wno-parentheses", + "-Wno-trigraphs", + "-Wredundant-decls", + "-Wwrite-strings", + ); + }; + name = Release; + }; +/* End XCBuildConfiguration section */ + +/* Begin XCConfigurationList section */ + FCCE17B0135A5FFB002CEE6D /* Build configuration list for PBXProject "copyfile" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + FCCE17B3135A5FFB002CEE6D /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + FCCE17BE135A6444002CEE6D /* Build configuration list for PBXNativeTarget "copyfile" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + FCCE17BD135A6444002CEE6D /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; +/* End XCConfigurationList section */ + }; + rootObject = FCCE17AD135A5FFB002CEE6D /* Project object */; +} diff --git a/xcodescripts/install_files.sh b/xcodescripts/install_files.sh new file mode 100644 index 0000000..7f2e58f --- /dev/null +++ b/xcodescripts/install_files.sh @@ -0,0 +1,35 @@ +#!/bin/sh +set -e -x + +# don't install files for installhdrs or simulator builds +if [ "$ACTION" == "installhdrs" -o \ + "${RC_ProjectName%_Sim}" != "$RC_ProjectName" ]; then + exit 0 +fi + +function InstallManPages() { + for MANPAGE in "$@"; do + SECTION=`basename "${MANPAGE/*./}"` + MANDIR="$DSTROOT"/usr/share/man/man"$SECTION" + install -d -o "$INSTALL_OWNER" -g "$INSTALL_GROUP" -m 0755 "$MANDIR" + install -o "$INSTALL_OWNER" -g "$INSTALL_GROUP" -m 0444 "$MANPAGE" "$MANDIR" + done +} + +function LinkManPages() { + MANPAGE=`basename "$1"` + SECTION=`basename "${MANPAGE/*./}"` + MANDIR="$DSTROOT"/usr/share/man/man"$SECTION" + shift + for LINK in "$@"; do + ln -hf "$MANDIR/$MANPAGE" "$MANDIR/$LINK" + done +} + +InstallManPages copyfile.3 +LinkManPages copyfile.3 \ + fcopyfile.3 \ + copyfile_state_alloc.3 \ + copyfile_state_free.3 \ + copyfile_state_get.3 \ + copyfile_state_set.3 -- 2.47.2