summaryrefslogtreecommitdiff
path: root/tar/bsdtar_windows.c
diff options
context:
space:
mode:
authorTim Kientzle <kientzle@gmail.com>2009-07-19 03:20:51 -0400
committerTim Kientzle <kientzle@gmail.com>2009-07-19 03:20:51 -0400
commit06878e10269cfeabb614ac15f2e1abe584480e7e (patch)
treea71584850a7c193a320351e6c500da1dc943078c /tar/bsdtar_windows.c
parent864ba4d7eb3d3ef5bdfc3f112247d93529974ee3 (diff)
downloadlibarchive-06878e10269cfeabb614ac15f2e1abe584480e7e.tar.gz
Remove the attempt to determine "root" for Windows.
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
Diffstat (limited to 'tar/bsdtar_windows.c')
-rw-r--r--tar/bsdtar_windows.c90
1 files changed, 0 insertions, 90 deletions
diff --git a/tar/bsdtar_windows.c b/tar/bsdtar_windows.c
index 602a5eaf..824fdc08 100644
--- a/tar/bsdtar_windows.c
+++ b/tar/bsdtar_windows.c
@@ -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