]> git.ipfire.org Git - thirdparty/libarchive.git/commitdiff
Remove the attempt to determine "root" for Windows.
authorTim Kientzle <kientzle@gmail.com>
Sun, 19 Jul 2009 07:20:51 +0000 (03:20 -0400)
committerTim Kientzle <kientzle@gmail.com>
Sun, 19 Jul 2009 07:20:51 +0000 (03:20 -0400)
It's not really feasible and just gets weirder the longer
we look at it.  We now assume different defaults only
for the root user on non-Windows systems.

SVN-Revision: 1238

Makefile.am
tar/bsdtar.c
tar/bsdtar_cygwin.c [deleted file]
tar/bsdtar_cygwin.h [deleted file]
tar/bsdtar_platform.h
tar/bsdtar_windows.c
tar/bsdtar_windows.h

index 3517da4a62d4d3a3de235bb2535fbe43fdf0d924..7f72618ad3322bfc404c5c08f34f22639d26c3ca 100644 (file)
@@ -381,11 +381,6 @@ bsdtar_SOURCES+=                   \
                tar/bsdtar_windows.h    \
                tar/bsdtar_windows.c
 endif
-if INC_CYGWIN_FILES
-bsdtar_SOURCES+=                       \
-               tar/bsdtar_cygwin.h     \
-               tar/bsdtar_cygwin.c
-endif
 
 bsdtar_DEPENDENCIES= libarchive.la libarchive_fe.la
 
@@ -403,8 +398,6 @@ bsdtar_EXTRA_DIST=          \
        tar/bsdtar.1            \
        tar/bsdtar_windows.h    \
        tar/bsdtar_windows.c    \
-       tar/bsdtar_cygwin.h     \
-       tar/bsdtar_cygwin.c     \
        tar/CMakeLists.txt      \
        tar/config_freebsd.h    \
        tar/test/list.h
index 3cf150c1328df229b9634898a7fc9544f05aa515..09168995322505459dc8d402e69aede1ec5b714d 100644 (file)
@@ -204,8 +204,10 @@ main(int argc, char **argv)
        /* Default: Perform basic security checks. */
        bsdtar->extract_flags |= SECURITY;
 
-       /* Defaults for root user: */
-       if (bsdtar_is_privileged(bsdtar)) {
+#ifndef _WIN32
+       /* On POSIX systems, assume --same-owner and -p when run by
+        * the root user.  This doesn't make any sense on Windows. */
+       if (bsdtar->user_uid == 0) {
                /* --same-owner */
                bsdtar->extract_flags |= ARCHIVE_EXTRACT_OWNER;
                /* -p */
@@ -214,6 +216,7 @@ main(int argc, char **argv)
                bsdtar->extract_flags |= ARCHIVE_EXTRACT_XATTR;
                bsdtar->extract_flags |= ARCHIVE_EXTRACT_FFLAGS;
        }
+#endif
 
        bsdtar->argv = argv;
        bsdtar->argc = argc;
diff --git a/tar/bsdtar_cygwin.c b/tar/bsdtar_cygwin.c
deleted file mode 100644 (file)
index 72dc957..0000000
+++ /dev/null
@@ -1,142 +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 "bsdtar_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 "bsdtar.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
-bsdtar_is_privileged(struct bsdtar *bsdtar)
-{
-       HANDLE thandle;
-       int ret;
-       const char *sidlist[] = {
-               "S-1-5-32-544", /* Administrators */
-               "S-1-5-32-551", /* Backup Operators */
-               NULL
-       };
-
-       (void)bsdtar;/* UNUSED */
-       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/tar/bsdtar_cygwin.h b/tar/bsdtar_cygwin.h
deleted file mode 100644 (file)
index 29acf44..0000000
+++ /dev/null
@@ -1,42 +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 BSDTAR_CYGWIN_H
-#define BSDTAR_CYGWIN_H 1
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-struct bsdtar;
-extern int     bsdtar_is_privileged(struct bsdtar *bsdtar);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* BSDTAR_CYGWIN_H */
index b2ac7ae3d275839d3cb2fd148dc6b123f44feedd..6276839243aead343a6089fb1c716a5543afe17d 100644 (file)
 #define        __LA_DEAD
 #endif
 
-#if defined(__CYGWIN__)
-#include "bsdtar_cygwin.h"
-#elif defined(_WIN32) /* && !__CYGWIN__ */
+#if defined(_WIN32) && !defined(__CYGWIN__)
 #include "bsdtar_windows.h"
-#else
-#define bsdtar_is_privileged(bsdtar)   (bsdtar->user_uid == 0)
 #endif
 
 #endif /* !BSDTAR_PLATFORM_H_INCLUDED */
index 602a5eafbf1e70c2d4b683c084b5ba251b369a2d..824fdc085bf3b31b40b22b5dc3f92f2cf74b09d4 100644 (file)
@@ -977,96 +977,6 @@ 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
-bsdtar_is_privileged(struct bsdtar *bsdtar)
-{
-       HANDLE thandle;
-       int ret;
-       const char *sidlist[] = {
-               "S-1-5-32-544", /* Administrators */
-               "S-1-5-32-551", /* Backup Operators */
-               NULL
-       };
-
-       (void)bsdtar;/* UNUSED */
-       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);
-}
-
 /*
  * Note: We should use wide-character for findng '\' character,
  * a directory separator on Windows, because some character-set have
index 5dfe02c5b533c2ddaad11feeae0d428a7370a0cc..b1b874e4f233f3c57c7beaec3a19155b8da8968d 100644 (file)
@@ -46,7 +46,6 @@ extern DIR    *opendir(const char *path);
 extern struct dirent *readdir(DIR *dirp);
 extern int     closedir(DIR *dirp);
 
-extern int     bsdtar_is_privileged(struct bsdtar *bsdtar);
 extern void    write_hierarchy_win(struct bsdtar *bsdtar, struct archive *a,
                const char *path,
                void (*write_hierarchy)(struct bsdtar *bsdtar,