]> git.ipfire.org Git - thirdparty/libarchive.git/commitdiff
Remove the attempt to determine "root" for Windows in cpio.
authorTim Kientzle <kientzle@gmail.com>
Sun, 19 Jul 2009 07:35:23 +0000 (03:35 -0400)
committerTim Kientzle <kientzle@gmail.com>
Sun, 19 Jul 2009 07:35:23 +0000 (03:35 -0400)
This can never really work properly, so it's better to just
not bother.

SVN-Revision: 1239

Makefile.am
cpio/cpio.c
cpio/cpio_cygwin.c [deleted file]
cpio/cpio_cygwin.h [deleted file]
cpio/cpio_platform.h
cpio/cpio_windows.c
cpio/cpio_windows.h

index 7f72618ad3322bfc404c5c08f34f22639d26c3ca..3c4c270f0e9bb9050e9e3c81944d7ebd69cbd4ab 100644 (file)
@@ -473,11 +473,6 @@ bsdcpio_SOURCES+=                  \
                cpio/cpio_windows.h     \
                cpio/cpio_windows.c
 endif
-if INC_CYGWIN_FILES
-bsdcpio_SOURCES+=                      \
-               cpio/cpio_cygwin.h      \
-               cpio/cpio_cygwin.c
-endif
 
 bsdcpio_DEPENDENCIES = libarchive.la libarchive_fe.la
 
@@ -494,8 +489,6 @@ bsdcpio_LDFLAGS= $(bsdcpio_static)
 bsdcpio_EXTRA_DIST=            \
        cpio/test/list.h        \
        cpio/bsdcpio.1          \
-       cpio/cpio_cygwin.h      \
-       cpio/cpio_cygwin.c      \
        cpio/cpio_windows.h     \
        cpio/cpio_windows.c     \
        cpio/CMakeLists.txt     \
index f54cb7f6848fd8f76c1f09c5f58b10bf7ad2ddda..ae3990a015b2b9852403d55fb808725843c1baea 100644 (file)
@@ -161,12 +161,10 @@ main(int argc, char *argv[])
        cpio->extract_flags |= ARCHIVE_EXTRACT_PERM;
        cpio->extract_flags |= ARCHIVE_EXTRACT_FFLAGS;
        cpio->extract_flags |= ARCHIVE_EXTRACT_ACL;
-#if defined(_WIN32) || defined(__CYGWIN__)
-       if (bsdcpio_is_privileged())
-#else
+#if !defined(_WIN32) && !defined(__CYGWIN__)
        if (geteuid() == 0)
-#endif
                cpio->extract_flags |= ARCHIVE_EXTRACT_OWNER;
+#endif
        cpio->bytes_per_block = 512;
        cpio->filename = NULL;
 
diff --git a/cpio/cpio_cygwin.c b/cpio/cpio_cygwin.c
deleted file mode 100644 (file)
index 7e27d2c..0000000
+++ /dev/null
@@ -1,140 +0,0 @@
-/*-
- * Copyright (c) 2009 Michihiro NAKAJIMA
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR(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 AUTHOR(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.
- *
- * $FreeBSD$
- */
-
-#if defined(__CYGWIN__)
-#define _WIN32_WINNT   0x0500
-#define WINVER         0x0500
-
-#include "cpio_platform.h"
-#include <errno.h>
-#include <stddef.h>
-#include <sys/utime.h>
-#include <sys/stat.h>
-#include <process.h>
-#include <stdlib.h>
-#include <wchar.h>
-#include <windows.h>
-#include <sddl.h>
-
-#include "cpio.h"
-#include "err.h"
-
-#ifndef LIST_H
-static int
-_is_privileged(HANDLE thandle, const char *sidlist[])
-{
-       TOKEN_USER *tuser;
-       TOKEN_GROUPS  *tgrp;
-       DWORD bytes;
-       PSID psid;
-       DWORD i, g;
-       int member;
-
-       psid = NULL;
-       tuser = NULL;
-       tgrp = NULL;
-       member = 0;
-       for (i = 0; sidlist[i] != NULL && member == 0; i++) {
-               if (psid != NULL)
-                       LocalFree(psid);
-               /* mingw/cygwin: incorrectly prototypes arg 1 as LPSTR
-                * instead of LPCSTR. Work around it here
-                */
-               if (ConvertStringSidToSidA((char *)sidlist[i], &psid) == 0) {
-                       errno = EPERM;
-                       return (-1);
-               }
-               if (tuser == NULL) {
-                       GetTokenInformation(thandle, TokenUser, NULL, 0, &bytes);
-                       tuser = malloc(bytes);
-                       if (tuser == NULL) {
-                               errno = ENOMEM;
-                               member = -1;
-                               break;
-                       }
-                       if (GetTokenInformation(thandle, TokenUser, tuser, bytes, &bytes) == 0) {
-                               errno = EPERM;
-                               member = -1;
-                               break;
-                       }
-               }
-               member = EqualSid(tuser->User.Sid, psid);
-               if (member)
-                       break;
-               if (tgrp == NULL) {
-                       GetTokenInformation(thandle, TokenGroups, NULL, 0, &bytes);
-                       tgrp = malloc(bytes);
-                       if (tgrp == NULL) {
-                               errno = ENOMEM;
-                               member = -1;
-                               break;
-                       }
-                       if (GetTokenInformation(thandle, TokenGroups, tgrp, bytes, &bytes) == 0) {
-                               errno = EPERM;
-                               member = -1;
-                               break;
-                       }
-               }
-               for (g = 0; g < tgrp->GroupCount; g++) {
-                       member = EqualSid(tgrp->Groups[g].Sid, psid);
-                       if (member)
-                               break;
-               }
-       }
-       LocalFree(psid);
-       free(tuser);
-       free(tgrp);
-
-       return (member);
-}
-
-int
-bsdcpio_is_privileged()
-{
-       HANDLE thandle;
-       int ret;
-       const char *sidlist[] = {
-               "S-1-5-32-544", /* Administrators */
-               "S-1-5-32-551", /* Backup Operators */
-               NULL
-       };
-
-       if (OpenProcessToken(GetCurrentProcess(), TOKEN_QUERY, &thandle) == 0) {
-               lafe_warnc(EPERM, "Failed to check privilege");
-               return (0);
-       }
-       ret = _is_privileged(thandle, sidlist);
-       if (ret < 0) {
-               lafe_warnc(errno, "Failed to check privilege");
-               return (0);
-       }
-       return (ret);
-}
-
-#endif /* LIST_H */
-
-#endif
diff --git a/cpio/cpio_cygwin.h b/cpio/cpio_cygwin.h
deleted file mode 100644 (file)
index 9ee41b4..0000000
+++ /dev/null
@@ -1,41 +0,0 @@
-/*-
- * Copyright (c) 2009 Michihiro NAKAJIMA
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR(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 AUTHOR(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.
- *
- * $FreeBSD$
- */
-
-#ifndef CPIO_CYGWIN_H
-#define CPIO_CYGWIN_H 1
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-extern int             bsdcpio_is_privileged();
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* CPIO_CYGWIN_H */
index 1ed8986fa40fcfdb15baaa5c4e6c0dc11f0f0cb7..880dc9611e126f4df86b89a51f775b8ac5f5241e 100644 (file)
@@ -86,9 +86,7 @@
 #define __LA_DEAD
 #endif
 
-#if defined(__CYGWIN__)
-#include "cpio_cygwin.h"
-#elif defined(_WIN32)  /* && !__CYGWIN__ */
+#if defined(_WIN32) && !defined(__CYGWIN__)
 #include "cpio_windows.h"
 #endif
 
index e4c14b5ec4a6f4c7e5e143ce8397242710d7f2ab..508af9feeb6a3ed96ab7570e612576632fe32002 100644 (file)
@@ -901,95 +901,4 @@ la_write(int fd, const void *buf, size_t nbytes)
        return (bytes_written);
 }
 
-#ifndef LIST_H
-static int
-_is_privileged(HANDLE thandle, const char *sidlist[])
-{
-       TOKEN_USER *tuser;
-       TOKEN_GROUPS  *tgrp;
-       DWORD bytes;
-       PSID psid;
-       DWORD i, g;
-       int member;
-
-       psid = NULL;
-       tuser = NULL;
-       tgrp = NULL;
-       member = 0;
-       for (i = 0; sidlist[i] != NULL && member == 0; i++) {
-               if (psid != NULL)
-                       LocalFree(psid);
-               if (ConvertStringSidToSidA(sidlist[i], &psid) == 0) {
-                       errno = EPERM;
-                       return (-1);
-               }
-               if (tuser == NULL) {
-                       GetTokenInformation(thandle, TokenUser, NULL, 0, &bytes);
-                       tuser = malloc(bytes);
-                       if (tuser == NULL) {
-                               errno = ENOMEM;
-                               member = -1;
-                               break;
-                       }
-                       if (GetTokenInformation(thandle, TokenUser, tuser, bytes, &bytes) == 0) {
-                               errno = EPERM;
-                               member = -1;
-                               break;
-                       }
-               }
-               member = EqualSid(tuser->User.Sid, psid);
-               if (member)
-                       break;
-               if (tgrp == NULL) {
-                       GetTokenInformation(thandle, TokenGroups, NULL, 0, &bytes);
-                       tgrp = malloc(bytes);
-                       if (tgrp == NULL) {
-                               errno = ENOMEM;
-                               member = -1;
-                               break;
-                       }
-                       if (GetTokenInformation(thandle, TokenGroups, tgrp, bytes, &bytes) == 0) {
-                               errno = EPERM;
-                               member = -1;
-                               break;
-                       }
-               }
-               for (g = 0; g < tgrp->GroupCount; g++) {
-                       member = EqualSid(tgrp->Groups[g].Sid, psid);
-                       if (member)
-                               break;
-               }
-       }
-       LocalFree(psid);
-       free(tuser);
-       free(tgrp);
-
-       return (member);
-}
-
-int
-bsdcpio_is_privileged()
-{
-       HANDLE thandle;
-       int ret;
-       const char *sidlist[] = {
-               "S-1-5-32-544", /* Administrators */
-               "S-1-5-32-551", /* Backup Operators */
-               NULL
-       };
-
-       if (OpenProcessToken(GetCurrentProcess(), TOKEN_QUERY, &thandle) == 0) {
-               lafe_warnc(EPERM, "Failed to check privilege");
-               return (0);
-       }
-       ret = _is_privileged(thandle, sidlist);
-       if (ret < 0) {
-               lafe_warnc(errno, "Failed to check privilege");
-               return (0);
-       }
-       return (ret);
-}
-
-#endif /* LIST_H */
-
 #endif
index f58d29d5d60fdf83f6d627478a3f7354d96913bf..6587dcd452a9034cb42fd8c3d6f404c0d026a413 100644 (file)
 #ifndef CPIO_WINDOWS_H
 #define CPIO_WINDOWS_H 1
 
-#define geteuid()      0
 #define getgrgid(id)   NULL
 #define getgrnam(name) NULL
 #define getpwnam(name) NULL
 #define getpwuid(id)   NULL
-#define getuid()       0
 
 #ifdef _MSC_VER
 #define snprintf       sprintf_s
@@ -55,7 +53,6 @@ extern "C" {
 #endif
 
 extern unsigned int    sleep(unsigned int seconds);
-extern int             bsdcpio_is_privileged();
 
 #ifdef __cplusplus
 }