You are viewing a plain text version of this content. The canonical link for it is here.
Posted to common-commits@hadoop.apache.org by su...@apache.org on 2012/10/10 21:09:55 UTC
svn commit: r1396745 - in /hadoop/common/branches/branch-1-win: ./
src/winutils/
Author: suresh
Date: Wed Oct 10 19:09:55 2012
New Revision: 1396745
URL: http://svn.apache.org/viewvc?rev=1396745&view=rev
Log:
HADOOP-8908. Refactor winutil.exe related code. Contributed by Chuan Liu.
Modified:
hadoop/common/branches/branch-1-win/CHANGES.branch-1-win.txt
hadoop/common/branches/branch-1-win/src/winutils/chmod.c
hadoop/common/branches/branch-1-win/src/winutils/chown.c
hadoop/common/branches/branch-1-win/src/winutils/common.c
hadoop/common/branches/branch-1-win/src/winutils/common.h
hadoop/common/branches/branch-1-win/src/winutils/groups.c
hadoop/common/branches/branch-1-win/src/winutils/hardlink.c
hadoop/common/branches/branch-1-win/src/winutils/ls.c
hadoop/common/branches/branch-1-win/src/winutils/main.c
hadoop/common/branches/branch-1-win/src/winutils/symlink.c
hadoop/common/branches/branch-1-win/src/winutils/systeminfo.c
hadoop/common/branches/branch-1-win/src/winutils/task.c
hadoop/common/branches/branch-1-win/src/winutils/winutils.sln
hadoop/common/branches/branch-1-win/src/winutils/winutils.vcxproj
Modified: hadoop/common/branches/branch-1-win/CHANGES.branch-1-win.txt
URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-1-win/CHANGES.branch-1-win.txt?rev=1396745&r1=1396744&r2=1396745&view=diff
==============================================================================
--- hadoop/common/branches/branch-1-win/CHANGES.branch-1-win.txt (original)
+++ hadoop/common/branches/branch-1-win/CHANGES.branch-1-win.txt Wed Oct 10 19:09:55 2012
@@ -1,9 +1,5 @@
Branch-hadoop-1-win - unreleased
- NEW FEATURES
-
- IMPROVEMENTS
-
HADOOP-8223 Initial patch for branch-1-win. (David Lao via Sanjay)
HADOOP-8234 Enable user group mappings on Windows. (Bikas Saha via Sanjay)
@@ -96,10 +92,6 @@ Branch-hadoop-1-win - unreleased
HDFS-3566. Add AzureBlockPlacementPolicy to handle fault and upgrade
domains in Azure. (Sumadhur Reddy Bolli via szetszwo)
-OPTIMAZATIONS
-
-BUG FIXES
-
HDFS-6527. Backport HADOOP-7389: Use of TestingGroups by tests causes
subsequent tests to fail. (Ivan Mitic via szetszwo)
@@ -155,3 +147,5 @@ BUG FIXES
HADOOP-8903. support HADOOP_USER_CLASSPATH_FIRST in windows hadoop cmd.
(Thejas Nair via suresh)
+
+ HADOOP-8908. Refactor winutil.exe related code. (Chuan Liu via suresh)
Modified: hadoop/common/branches/branch-1-win/src/winutils/chmod.c
URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-1-win/src/winutils/chmod.c?rev=1396745&r1=1396744&r2=1396745&view=diff
==============================================================================
--- hadoop/common/branches/branch-1-win/src/winutils/chmod.c (original)
+++ hadoop/common/branches/branch-1-win/src/winutils/chmod.c Wed Oct 10 19:09:55 2012
@@ -15,7 +15,7 @@
* the License.
*/
-#include "common.h"
+#include "winutils.h"
#include <errno.h>
enum CHMOD_WHO
@@ -64,39 +64,29 @@ typedef struct _MODE_CHANGE_ACTION
struct _MODE_CHANGE_ACTION *next_action;
} MODE_CHANGE_ACTION, *PMODE_CHANGE_ACTION;
-
const MODE_CHANGE_ACTION INIT_MODE_CHANGE_ACTION = {
CHMOD_WHO_NONE, CHMOD_OP_INVALID, CHMOD_PERM_NA, CHMOD_WHO_NONE, NULL
};
-
-static BOOL ParseOctalMode(LPCWSTR tsMask, USHORT *uMask);
+static BOOL ParseOctalMode(LPCWSTR tsMask, INT *uMask);
static BOOL ParseMode(LPCWSTR modeString, PMODE_CHANGE_ACTION *actions);
static BOOL FreeActions(PMODE_CHANGE_ACTION actions);
-static BOOL GetWindowsDACLs(__in USHORT unixMask, __in PSID pOwnerSid,
- __in PSID pGroupSid, __out PACL *ppNewDACL);
-
static BOOL ParseCommandLineArguments(__in int argc, __in wchar_t *argv[],
- __out BOOL *rec, __out_opt USHORT *mask,
+ __out BOOL *rec, __out_opt INT *mask,
__out_opt PMODE_CHANGE_ACTION *actions, __out LPCWSTR *path);
-static BOOL ChangeFileModeByMask(__in LPCWSTR path, USHORT mode);
-
static BOOL ChangeFileModeByActions(__in LPCWSTR path,
PMODE_CHANGE_ACTION actions);
-static BOOL ChangeFileMode(__in LPCWSTR path, __in_opt USHORT mode,
+static BOOL ChangeFileMode(__in LPCWSTR path, __in_opt INT mode,
__in_opt PMODE_CHANGE_ACTION actions);
-static BOOL ChangeFileModeRecursively(__in LPCWSTR path, __in_opt USHORT mode,
+static BOOL ChangeFileModeRecursively(__in LPCWSTR path, __in_opt INT mode,
__in_opt PMODE_CHANGE_ACTION actions);
-static USHORT ComputeNewMode(__in USHORT oldMode, __in USHORT who,
- __in USHORT op, __in USHORT perm, __in USHORT ref);
-
//----------------------------------------------------------------------------
// Function: Chmod
@@ -118,7 +108,7 @@ int Chmod(int argc, wchar_t *argv[])
PMODE_CHANGE_ACTION actions = NULL;
- USHORT unixAccessMask = 0x0000;
+ INT unixAccessMask = 0;
DWORD dwRtnCode = 0;
@@ -178,13 +168,21 @@ ChmodEnd:
//
// Notes:
//
-static BOOL ChangeFileMode(__in LPCWSTR path, __in_opt USHORT unixAccessMask,
+static BOOL ChangeFileMode(__in LPCWSTR path, __in_opt INT unixAccessMask,
__in_opt PMODE_CHANGE_ACTION actions)
{
if (actions != NULL)
return ChangeFileModeByActions(path, actions);
else
- return ChangeFileModeByMask(path, unixAccessMask);
+ {
+ DWORD dwRtnCode = ChangeFileModeByMask(path, unixAccessMask);
+ if (dwRtnCode != ERROR_SUCCESS)
+ {
+ ReportErrorCode(L"ChangeFileModeByMask", dwRtnCode);
+ return FALSE;
+ }
+ return TRUE;
+ }
}
//----------------------------------------------------------------------------
@@ -203,7 +201,7 @@ static BOOL ChangeFileMode(__in LPCWSTR
// Symbolic links and junction points are not considered as directories.
// - Otherwise, call the method on all its children, then change its mode.
//
-static BOOL ChangeFileModeRecursively(__in LPCWSTR path, __in_opt USHORT mode,
+static BOOL ChangeFileModeRecursively(__in LPCWSTR path, __in_opt INT mode,
__in_opt PMODE_CHANGE_ACTION actions)
{
BOOL isDir = FALSE;
@@ -311,157 +309,6 @@ ChangeFileModeRecursivelyEnd:
}
//----------------------------------------------------------------------------
-// Function: ChangeFileModeByMask
-//
-// Description:
-// Change a file or direcotry at the path to Unix mode
-//
-// Returns:
-// TRUE: on success
-// FALSE: otherwise
-//
-// Notes:
-//
-static BOOL ChangeFileModeByMask(__in LPCWSTR path, USHORT mode)
-{
- PACL pOldDACL = NULL;
- PACL pNewDACL = NULL;
- PSID pOwnerSid = NULL;
- PSID pGroupSid = NULL;
- PSECURITY_DESCRIPTOR pSD = NULL;
-
- SECURITY_DESCRIPTOR_CONTROL control;
- DWORD revision = 0;
-
- PSECURITY_DESCRIPTOR pAbsSD = NULL;
- PACL pAbsDacl = NULL;
- PACL pAbsSacl = NULL;
- PSID pAbsOwner = NULL;
- PSID pAbsGroup = NULL;
-
- DWORD dwRtnCode = 0;
- DWORD dwErrorCode = 0;
-
- BOOL ret = FALSE;
-
- // Get owner and group Sids
- //
- dwRtnCode = GetNamedSecurityInfoW(
- path,
- SE_FILE_OBJECT,
- OWNER_SECURITY_INFORMATION | GROUP_SECURITY_INFORMATION |
- DACL_SECURITY_INFORMATION,
- &pOwnerSid,
- &pGroupSid,
- &pOldDACL,
- NULL,
- &pSD);
- if (ERROR_SUCCESS != dwRtnCode)
- {
- ReportErrorCode(L"GetNamedSecurityInfo", dwRtnCode);
- goto ChangeFileMode;
- }
-
- // SetSecurityDescriptorDacl function used below only accepts security
- // descriptor in absolute format, meaning that its members must be pointers to
- // other structures, rather than offsets to contiguous data.
- // To determine whether a security descriptor is self-relative or absolute,
- // call the GetSecurityDescriptorControl function and check the
- // SE_SELF_RELATIVE flag of the SECURITY_DESCRIPTOR_CONTROL parameter.
- //
- if (!GetSecurityDescriptorControl(pSD, &control, &revision))
- {
- ReportErrorCode(L"GetSecurityDescriptorControl", GetLastError());
- goto ChangeFileMode;
- }
-
- // If the security descriptor is self-relative, we use MakeAbsoluteSD function
- // to convert it to absolute format.
- //
- if ((control & SE_SELF_RELATIVE) == SE_SELF_RELATIVE)
- {
- DWORD absSDSize = 0;
- DWORD daclSize = 0;
- DWORD saclSize = 0;
- DWORD ownerSize = 0;
- DWORD primaryGroupSize = 0;
- MakeAbsoluteSD(pSD, NULL, &absSDSize, NULL, &daclSize, NULL,
- &saclSize, NULL, &ownerSize, NULL, &primaryGroupSize);
- if ((dwErrorCode = GetLastError()) != ERROR_INSUFFICIENT_BUFFER)
- {
- ReportErrorCode(L"MakeAbsoluteSD", dwErrorCode);
- goto ChangeFileMode;
- }
- pAbsSD = (PSECURITY_DESCRIPTOR) LocalAlloc(LPTR, absSDSize);
- pAbsDacl = (PACL) LocalAlloc(LPTR, daclSize);
- pAbsSacl = (PACL) LocalAlloc(LPTR, saclSize);
- pAbsOwner = (PSID) LocalAlloc(LPTR, ownerSize);
- pAbsGroup = (PSID) LocalAlloc(LPTR, primaryGroupSize);
- if (pAbsSD == NULL || pAbsDacl == NULL || pAbsSacl == NULL ||
- pAbsOwner == NULL || pAbsGroup == NULL)
- {
- ReportErrorCode(L"LocalAlloc", GetLastError());
- goto ChangeFileMode;
- }
-
- if (!MakeAbsoluteSD(pSD, pAbsSD, &absSDSize, pAbsDacl, &daclSize, pAbsSacl,
- &saclSize, pAbsOwner, &ownerSize, pAbsGroup, &primaryGroupSize))
- {
- ReportErrorCode(L"MakeAbsoluteSD", GetLastError());
- goto ChangeFileMode;
- }
- }
-
- // Get Windows DACLs based on Unix access mask
- //
- if (!GetWindowsDACLs(mode, pOwnerSid, pGroupSid, &pNewDACL))
- goto ChangeFileMode;
-
- // Set the DACL information in the security descriptor; if a DACL is already
- // present in the security descriptor, the DACL is replaced. The security
- // descriptor is then used to set the security of a file or directory.
- //
- if (!SetSecurityDescriptorDacl(pAbsSD, TRUE, pNewDACL, FALSE))
- {
- ReportErrorCode(L"SetSecurityDescriptorDacl", GetLastError());
- goto ChangeFileMode;
- }
-
- // MSDN states "This function is obsolete. Use the SetNamedSecurityInfo
- // function instead." However we have the following problem when using
- // SetNamedSecurityInfo:
- // - When PROTECTED_DACL_SECURITY_INFORMATION is not passed in as part of
- // security information, the object will include inheritable permissions
- // from its parent.
- // - When PROTECTED_DACL_SECURITY_INFORMATION is passsed in to set
- // permissions on a directory, the child object of the directory will lose
- // inheritable permissions from their parent (the current directory).
- // By using SetFileSecurity, we have the nice property that the new
- // permissions of the object does not include the inheritable permissions from
- // its parent, and the child objects will not lose their inherited permissions
- // from the current object.
- //
- if (!SetFileSecurity(path, DACL_SECURITY_INFORMATION, pAbsSD))
- {
- ReportErrorCode(L"SetFileSecurity", GetLastError());
- goto ChangeFileMode;
- }
-
- ret = TRUE;
-
-ChangeFileMode:
- LocalFree(pSD);
- LocalFree(pNewDACL);
- LocalFree(pAbsDacl);
- LocalFree(pAbsSacl);
- LocalFree(pAbsOwner);
- LocalFree(pAbsGroup);
- LocalFree(pAbsSD);
-
- return ret;
-}
-
-//----------------------------------------------------------------------------
// Function: ParseCommandLineArguments
//
// Description:
@@ -477,7 +324,7 @@ ChangeFileMode:
//
static BOOL ParseCommandLineArguments(__in int argc, __in wchar_t *argv[],
__out BOOL *rec,
- __out_opt USHORT *mask,
+ __out_opt INT *mask,
__out_opt PMODE_CHANGE_ACTION *actions,
__out LPCWSTR *path)
{
@@ -584,16 +431,16 @@ static BOOL FreeActions(PMODE_CHANGE_ACT
// Apply 'rwx' permission mask or reference permission mode according to the
// '+', '-', or '=' operator.
//
-static USHORT ComputeNewMode(__in USHORT oldMode,
+static INT ComputeNewMode(__in INT oldMode,
__in USHORT who, __in USHORT op,
__in USHORT perm, __in USHORT ref)
{
- static const USHORT readMask = 0444;
- static const USHORT writeMask = 0222;
- static const USHORT exeMask = 0111;
+ static const INT readMask = 0444;
+ static const INT writeMask = 0222;
+ static const INT exeMask = 0111;
- USHORT mask = 0;
- USHORT mode = 0;
+ INT mask = 0;
+ INT mode = 0;
// Operations are exclusive, and cannot be invalid
//
@@ -691,14 +538,14 @@ static USHORT ComputeNewMode(__in USHORT
// none
//
static BOOL ConvertActionsToMask(__in LPCWSTR path,
- __in PMODE_CHANGE_ACTION actions, __out PUSHORT puMask)
+ __in PMODE_CHANGE_ACTION actions, __out PINT puMask)
{
PMODE_CHANGE_ACTION curr = NULL;
BY_HANDLE_FILE_INFORMATION fileInformation;
DWORD dwErrorCode = ERROR_SUCCESS;
- USHORT mode = 0;
+ INT mode = 0;
dwErrorCode = GetFileInformationByName(path, FALSE, &fileInformation);
if (dwErrorCode != ERROR_SUCCESS)
@@ -710,8 +557,10 @@ static BOOL ConvertActionsToMask(__in LP
{
mode |= UX_DIRECTORY;
}
- if (!FindFileOwnerAndPermission(path, NULL, NULL, &mode))
+ dwErrorCode = FindFileOwnerAndPermission(path, NULL, NULL, &mode);
+ if (dwErrorCode != ERROR_SUCCESS)
{
+ ReportErrorCode(L"FindFileOwnerAndPermission", dwErrorCode);
return FALSE;
}
*puMask = mode;
@@ -748,10 +597,18 @@ static BOOL ConvertActionsToMask(__in LP
static BOOL ChangeFileModeByActions(__in LPCWSTR path,
PMODE_CHANGE_ACTION actions)
{
- USHORT mask = 0;
+ INT mask = 0;
if (ConvertActionsToMask(path, actions, &mask))
- return ChangeFileModeByMask(path, mask);
+ {
+ DWORD dwRtnCode = ChangeFileModeByMask(path, mask);
+ if (dwRtnCode != ERROR_SUCCESS)
+ {
+ ReportErrorCode(L"ChangeFileModeByMask", dwRtnCode);
+ return FALSE;
+ }
+ return TRUE;
+ }
else
return FALSE;
}
@@ -965,7 +822,7 @@ static BOOL ParseMode(LPCWSTR modeString
// Notes:
// none
//
-static BOOL ParseOctalMode(LPCWSTR tsMask, USHORT *uMask)
+static BOOL ParseOctalMode(LPCWSTR tsMask, INT *uMask)
{
size_t tsMaskLen = 0;
DWORD i;
@@ -1004,211 +861,11 @@ static BOOL ParseOctalMode(LPCWSTR tsMas
return FALSE;
}
- *uMask = (USHORT) l;
+ *uMask = (INT) l;
return TRUE;
}
-//----------------------------------------------------------------------------
-// Function: GetWindowsAccessMask
-//
-// Description:
-// Get the Windows AccessMask for user, group and everyone based on the Unix
-// permission mask
-//
-// Returns:
-// none
-//
-// Notes:
-// none
-//
-static void GetWindowsAccessMask(USHORT unixMask,
- ACCESS_MASK *userAllow,
- ACCESS_MASK *userDeny,
- ACCESS_MASK *groupAllow,
- ACCESS_MASK *groupDeny,
- ACCESS_MASK *otherAllow)
-{
- assert (userAllow != NULL && userDeny != NULL &&
- groupAllow != NULL && groupDeny != NULL &&
- otherAllow != NULL);
-
- *userAllow = WinMasks[WIN_ALL] | WinMasks[WIN_OWNER_SE];
- if ((unixMask & UX_U_READ) == UX_U_READ)
- *userAllow |= WinMasks[WIN_READ];
-
- if ((unixMask & UX_U_WRITE) == UX_U_WRITE)
- *userAllow |= WinMasks[WIN_WRITE];
-
- if ((unixMask & UX_U_EXECUTE) == UX_U_EXECUTE)
- *userAllow |= WinMasks[WIN_EXECUTE];
-
- *userDeny = 0;
- if ((unixMask & UX_U_READ) != UX_U_READ &&
- ((unixMask & UX_G_READ) == UX_G_READ ||
- (unixMask & UX_O_READ) == UX_O_READ))
- *userDeny |= WinMasks[WIN_READ];
-
- if ((unixMask & UX_U_WRITE) != UX_U_WRITE &&
- ((unixMask & UX_G_WRITE) == UX_G_WRITE ||
- (unixMask & UX_O_WRITE) == UX_O_WRITE))
- *userDeny |= WinMasks[WIN_WRITE];
-
- if ((unixMask & UX_U_EXECUTE) != UX_U_EXECUTE &&
- ((unixMask & UX_G_EXECUTE) == UX_G_EXECUTE ||
- (unixMask & UX_O_EXECUTE) == UX_O_EXECUTE))
- *userDeny |= WinMasks[WIN_EXECUTE];
-
- *groupAllow = WinMasks[WIN_ALL];
- if ((unixMask & UX_G_READ) == UX_G_READ)
- *groupAllow |= FILE_GENERIC_READ;
-
- if ((unixMask & UX_G_WRITE) == UX_G_WRITE)
- *groupAllow |= WinMasks[WIN_WRITE];
-
- if ((unixMask & UX_G_EXECUTE) == UX_G_EXECUTE)
- *groupAllow |= WinMasks[WIN_EXECUTE];
-
- *groupDeny = 0;
- if ((unixMask & UX_G_READ) != UX_G_READ &&
- (unixMask & UX_O_READ) == UX_O_READ)
- *groupDeny |= WinMasks[WIN_READ];
-
- if ((unixMask & UX_G_WRITE) != UX_G_WRITE &&
- (unixMask & UX_O_WRITE) == UX_O_WRITE)
- *groupDeny |= WinMasks[WIN_WRITE];
-
- if ((unixMask & UX_G_EXECUTE) != UX_G_EXECUTE &&
- (unixMask & UX_O_EXECUTE) == UX_O_EXECUTE)
- *groupDeny |= WinMasks[WIN_EXECUTE];
-
- *otherAllow = WinMasks[WIN_ALL];
- if ((unixMask & UX_O_READ) == UX_O_READ)
- *otherAllow |= WinMasks[WIN_READ];
-
- if ((unixMask & UX_O_WRITE) == UX_O_WRITE)
- *otherAllow |= WinMasks[WIN_WRITE];
-
- if ((unixMask & UX_O_EXECUTE) == UX_O_EXECUTE)
- *otherAllow |= WinMasks[WIN_EXECUTE];
-}
-
-//----------------------------------------------------------------------------
-// Function: GetWindowsDACLs
-//
-// Description:
-// Get the Windows DACs based the Unix access mask
-//
-// Returns:
-// TRUE: on success
-// FALSE: otherwise
-//
-// Notes:
-// none
-//
-static BOOL GetWindowsDACLs(__in USHORT unixMask,
- __in PSID pOwnerSid, __in PSID pGroupSid, __out PACL *ppNewDACL)
-{
- DWORD winUserAccessDenyMask;
- DWORD winUserAccessAllowMask;
- DWORD winGroupAccessDenyMask;
- DWORD winGroupAccessAllowMask;
- DWORD winOtherAccessAllowMask;
-
- PSID pEveryoneSid = NULL;
-
- PACL pNewDACL = NULL;
- DWORD dwNewAclSize = 0;
-
- SID_IDENTIFIER_AUTHORITY SIDAuthWorld = SECURITY_WORLD_SID_AUTHORITY;
-
- BOOL ret = FALSE;
-
- GetWindowsAccessMask(unixMask,
- &winUserAccessAllowMask, &winUserAccessDenyMask,
- &winGroupAccessAllowMask, &winGroupAccessDenyMask,
- &winOtherAccessAllowMask);
-
- // Create a well-known SID for the Everyone group
- //
- if(!AllocateAndInitializeSid(&SIDAuthWorld, 1,
- SECURITY_WORLD_RID,
- 0, 0, 0, 0, 0, 0, 0,
- &pEveryoneSid))
- {
- return FALSE;
- }
-
- // Create the new DACL
- //
- dwNewAclSize = sizeof(ACL);
- dwNewAclSize += sizeof(ACCESS_ALLOWED_ACE) +
- GetLengthSid(pOwnerSid) - sizeof(DWORD);
- if (winUserAccessDenyMask)
- dwNewAclSize += sizeof(ACCESS_DENIED_ACE) +
- GetLengthSid(pOwnerSid) - sizeof(DWORD);
- dwNewAclSize += sizeof(ACCESS_ALLOWED_ACE) +
- GetLengthSid(pGroupSid) - sizeof(DWORD);
- if (winGroupAccessDenyMask)
- dwNewAclSize += sizeof(ACCESS_DENIED_ACE) +
- GetLengthSid(pGroupSid) - sizeof(DWORD);
- dwNewAclSize += sizeof(ACCESS_ALLOWED_ACE) +
- GetLengthSid(pEveryoneSid) - sizeof(DWORD);
- pNewDACL = (PACL)LocalAlloc(LPTR, dwNewAclSize);
- if (pNewDACL == NULL)
- {
- ReportErrorCode(L"LocalAlloc", GetLastError());
- goto GetWindowsDACLsEnd;
- }
- if (!InitializeAcl(pNewDACL, dwNewAclSize, ACL_REVISION))
- {
- ReportErrorCode(L"InitializeAcl", GetLastError());
- goto GetWindowsDACLsEnd;
- }
-
- if (winUserAccessDenyMask &&
- !AddAccessDeniedAce(pNewDACL, ACL_REVISION,
- winUserAccessDenyMask, pOwnerSid))
- {
- ReportErrorCode(L"AddAccessDeniedAce", GetLastError());
- goto GetWindowsDACLsEnd;
- }
- if (!AddAccessAllowedAce(pNewDACL, ACL_REVISION,
- winUserAccessAllowMask, pOwnerSid))
- {
- ReportErrorCode(L"AddAccessAllowedAce", GetLastError());
- goto GetWindowsDACLsEnd;
- }
- if (winGroupAccessDenyMask &&
- !AddAccessDeniedAce(pNewDACL, ACL_REVISION,
- winGroupAccessDenyMask, pGroupSid))
- {
- ReportErrorCode(L"AddAccessDeniedAce", GetLastError());
- goto GetWindowsDACLsEnd;
- }
- if (!AddAccessAllowedAce(pNewDACL, ACL_REVISION,
- winGroupAccessAllowMask, pGroupSid))
- {
- ReportErrorCode(L"AddAccessAllowedAce", GetLastError());
- goto GetWindowsDACLsEnd;
- }
- if (!AddAccessAllowedAce(pNewDACL, ACL_REVISION,
- winOtherAccessAllowMask, pEveryoneSid))
- {
- ReportErrorCode(L"AddAccessAllowedAce", GetLastError());
- goto GetWindowsDACLsEnd;
- }
-
- *ppNewDACL = pNewDACL;
- ret = TRUE;
-
-GetWindowsDACLsEnd:
- if (pEveryoneSid) FreeSid(pEveryoneSid);
- if (!ret) LocalFree(pNewDACL);
-
- return ret;
-}
-
void ChmodUsage(LPCWSTR program)
{
fwprintf(stdout, L"\
Modified: hadoop/common/branches/branch-1-win/src/winutils/chown.c
URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-1-win/src/winutils/chown.c?rev=1396745&r1=1396744&r2=1396745&view=diff
==============================================================================
--- hadoop/common/branches/branch-1-win/src/winutils/chown.c (original)
+++ hadoop/common/branches/branch-1-win/src/winutils/chown.c Wed Oct 10 19:09:55 2012
@@ -15,7 +15,7 @@
* the License.
*/
-#include "common.h"
+#include "winutils.h"
//----------------------------------------------------------------------------
// Function: GetNewAclSize
@@ -389,16 +389,26 @@ int Chown(int argc, wchar_t *argv[])
goto ChownEnd;
}
- if (userName != NULL && !GetSidFromAcctNameW(userName, &pNewOwnerSid))
+ if (userName != NULL)
{
- fwprintf(stderr, L"Invalid user name: %s\n", userName);
- goto ChownEnd;
+ dwRtnCode = GetSidFromAcctNameW(userName, &pNewOwnerSid);
+ if (dwRtnCode != ERROR_SUCCESS)
+ {
+ ReportErrorCode(L"GetSidFromAcctName", dwRtnCode);
+ fwprintf(stderr, L"Invalid user name: %s\n", userName);
+ goto ChownEnd;
+ }
}
- if (groupName != NULL && !GetSidFromAcctNameW(groupName, &pNewGroupSid))
+ if (groupName != NULL)
{
- fwprintf(stderr, L"Invalid group name: %s\n", groupName);
- goto ChownEnd;
+ dwRtnCode = GetSidFromAcctNameW(groupName, &pNewGroupSid);
+ if (dwRtnCode != ERROR_SUCCESS)
+ {
+ ReportErrorCode(L"GetSidFromAcctName", dwRtnCode);
+ fwprintf(stderr, L"Invalid group name: %s\n", groupName);
+ goto ChownEnd;
+ }
}
if (wcslen(pathName) == 0 || wcsspn(pathName, L"/?|><:*\"") != 0)
Modified: hadoop/common/branches/branch-1-win/src/winutils/common.c
URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-1-win/src/winutils/common.c?rev=1396745&r1=1396744&r2=1396745&view=diff
==============================================================================
--- hadoop/common/branches/branch-1-win/src/winutils/common.c (original)
+++ hadoop/common/branches/branch-1-win/src/winutils/common.c Wed Oct 10 19:09:55 2012
@@ -1,743 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with this
- * work for additional information regarding copyright ownership. The ASF
- * licenses this file to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations under
- * the License.
- */
-
-#pragma comment(lib, "authz.lib")
-#include "common.h"
-#include <authz.h>
-/*
- * The array of 12 months' three-letter abbreviations
- */
-const LPCWSTR MONTHS[] = { L"Jan", L"Feb", L"Mar", L"Apr", L"May", L"Jun",
- L"Jul", L"Aug", L"Sep", L"Oct", L"Nov", L"Dec" };
-
-/*
- * The WindowsAclMask and WinMasks contain the definitions used to establish
- * the mapping between Unix and Windows.
- * We set up the mapping with the following rules.
- * 1. Everyone will have WIN_ALL permissions;
- * 2. Owner will always have WIN_OWNER_SE permissions in addition;
- * 2. When Unix read/write/excute permission is set on the file, the
- * corresponding Windows allow ACE will be added to the file.
- * More details and explaination can be found in the following white paper:
- * http://technet.microsoft.com/en-us/library/bb463216.aspx
- */
-const ACCESS_MASK WinMasks[WIN_MASKS_TOTAL] =
-{
- /* WIN_READ */
- FILE_READ_DATA,
- /* WIN_WRITE */
- FILE_WRITE_DATA | FILE_WRITE_ATTRIBUTES | FILE_APPEND_DATA | FILE_WRITE_EA |
- FILE_DELETE_CHILD,
- /* WIN_EXECUTE */
- FILE_EXECUTE,
- /* WIN_OWNER_SE */
- DELETE | WRITE_DAC | WRITE_OWNER | FILE_WRITE_EA | FILE_WRITE_ATTRIBUTES,
- /* WIN_ALL */
- READ_CONTROL | FILE_READ_EA | FILE_READ_ATTRIBUTES | SYNCHRONIZE,
-};
-
-//----------------------------------------------------------------------------
-// Function: GetFileInformationByName
-//
-// Description:
-// To retrieve the by handle file information given the file name
-//
-// Returns:
-// ERROR_SUCCESS: on success
-// error code: otherwise
-//
-// Notes:
-// If followLink parameter is set to TRUE, we will follow the symbolic link
-// or junction point to get the target file information. Otherwise, the
-// information for the symbolic link or junction point is retrieved.
-//
-DWORD GetFileInformationByName(
- __in LPCWSTR pathName,
- __in BOOL followLink,
- __out LPBY_HANDLE_FILE_INFORMATION lpFileInformation)
-{
- HANDLE fileHandle = INVALID_HANDLE_VALUE;
- BOOL isSymlink = FALSE;
- DWORD dwFlagsAndAttributes = FILE_ATTRIBUTE_NORMAL | FILE_FLAG_BACKUP_SEMANTICS;
- DWORD dwErrorCode = ERROR_SUCCESS;
-
- assert(lpFileInformation != NULL);
-
- if (!followLink)
- {
- if ((dwErrorCode = SymbolicLinkCheck(pathName, &isSymlink)) != ERROR_SUCCESS)
- return dwErrorCode;
- if (isSymlink)
- dwFlagsAndAttributes |= FILE_FLAG_OPEN_REPARSE_POINT;
- }
-
- fileHandle = CreateFileW(
- pathName,
- FILE_READ_ATTRIBUTES,
- FILE_SHARE_READ,
- NULL,
- OPEN_EXISTING,
- dwFlagsAndAttributes,
- NULL);
- if (fileHandle == INVALID_HANDLE_VALUE)
- {
- dwErrorCode = GetLastError();
- return dwErrorCode;
- }
-
- if (!GetFileInformationByHandle(fileHandle, lpFileInformation))
- {
- dwErrorCode = GetLastError();
- CloseHandle(fileHandle);
- return dwErrorCode;
- }
-
- CloseHandle(fileHandle);
-
- return dwErrorCode;
-}
-
-//----------------------------------------------------------------------------
-// Function: IsLongWindowsPath
-//
-// Description:
-// Checks if the path is longer than MAX_PATH in which case it needs to be
-// prepended with \\?\ for Windows OS to understand it.
-//
-// Returns:
-// TRUE long path
-// FALSE otherwise
-static BOOL IsLongWindowsPath(__in PCWSTR path)
-{
- return (wcslen(path) + 1) > MAX_PATH;
-}
-
-//----------------------------------------------------------------------------
-// Function: ConvertToLongPath
-//
-// Description:
-// Prepends the path with the \\?\ prefix if the path is longer than MAX_PATH.
-// On success, newPath should be freed with LocalFree(). Given that relative
-// paths cannot be longer than MAX_PATH, we will never prepend the prefix
-// to relative paths.
-//
-// Returns:
-// ERROR_SUCCESS on success
-// error code on failure
-DWORD ConvertToLongPath(__in PCWSTR path, __deref_out PWSTR *newPath)
-{
- DWORD dwErrorCode = ERROR_SUCCESS;
- static const PCWSTR LongPathPrefix = L"\\\\?\\";
- BOOL bAppendPrefix = IsLongWindowsPath(path);
-
- size_t newPathLen = wcslen(path) + (bAppendPrefix ? wcslen(LongPathPrefix) : 0);
-
- // Allocate the buffer for the output path (+1 for terminating NULL char)
- //
- PWSTR newPathValue = (PWSTR)LocalAlloc(LPTR, (newPathLen + 1) * sizeof(WCHAR));
- if (newPathValue == NULL)
- {
- dwErrorCode = GetLastError();
- goto ConvertToLongPathExit;
- }
-
- if (bAppendPrefix)
- {
- // Append the prefix to the path
- //
- if (FAILED(StringCchPrintfW(newPathValue, newPathLen + 1, L"%s%s",
- LongPathPrefix, path)))
- {
- dwErrorCode = ERROR_GEN_FAILURE;
- goto ConvertToLongPathExit;
- }
- }
- else
- {
- // Just copy the original value into the output path. In this scenario
- // we are doing extra buffer copy. We decided to trade code simplicity
- // on the call site for small performance impact (extra allocation and
- // buffer copy). As paths are short, the impact is generally small.
- //
- if (FAILED(StringCchPrintfW(newPathValue, newPathLen + 1, L"%s", path)))
- {
- dwErrorCode = ERROR_GEN_FAILURE;
- goto ConvertToLongPathExit;
- }
- }
-
- *newPath = newPathValue;
-
-ConvertToLongPathExit:
- if (dwErrorCode != ERROR_SUCCESS)
- {
- LocalFree(newPathValue);
- *newPath = NULL;
- }
-
- return dwErrorCode;
-}
-
-//----------------------------------------------------------------------------
-// Function: IsDirFileInfo
-//
-// Description:
-// Test if the given file information is a directory
-//
-// Returns:
-// TRUE if it is a directory
-// FALSE otherwise
-//
-// Notes:
-//
-BOOL IsDirFileInfo(const BY_HANDLE_FILE_INFORMATION *fileInformation)
-{
- if ((fileInformation->dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
- == FILE_ATTRIBUTE_DIRECTORY)
- return TRUE;
- return FALSE;
-}
-
-//----------------------------------------------------------------------------
-// Function: CheckFileAttributes
-//
-// Description:
-// Check if the given file has all the given attribute(s)
-//
-// Returns:
-// ERROR_SUCCESS on success
-// error code otherwise
-//
-// Notes:
-//
-static DWORD FileAttributesCheck(
- __in LPCWSTR path, __in DWORD attr, __out PBOOL res)
-{
- DWORD attrs = INVALID_FILE_ATTRIBUTES;
- *res = FALSE;
- if ((attrs = GetFileAttributes(path)) != INVALID_FILE_ATTRIBUTES)
- *res = ((attrs & attr) == attr);
- else
- return GetLastError();
- return ERROR_SUCCESS;
-}
-
-//----------------------------------------------------------------------------
-// Function: IsDirectory
-//
-// Description:
-// Check if the given file is a directory
-//
-// Returns:
-// ERROR_SUCCESS on success
-// error code otherwise
-//
-// Notes:
-//
-DWORD DirectoryCheck(__in LPCWSTR pathName, __out PBOOL res)
-{
- return FileAttributesCheck(pathName, FILE_ATTRIBUTE_DIRECTORY, res);
-}
-
-//----------------------------------------------------------------------------
-// Function: IsReparsePoint
-//
-// Description:
-// Check if the given file is a reparse point
-//
-// Returns:
-// ERROR_SUCCESS on success
-// error code otherwise
-//
-// Notes:
-//
-static DWORD ReparsePointCheck(__in LPCWSTR pathName, __out PBOOL res)
-{
- return FileAttributesCheck(pathName, FILE_ATTRIBUTE_REPARSE_POINT, res);
-}
-
-//----------------------------------------------------------------------------
-// Function: CheckReparseTag
-//
-// Description:
-// Check if the given file is a reparse point of the given tag.
-//
-// Returns:
-// ERROR_SUCCESS on success
-// error code otherwise
-//
-// Notes:
-//
-static DWORD ReparseTagCheck(__in LPCWSTR path, __in DWORD tag, __out PBOOL res)
-{
- BOOL isReparsePoint = FALSE;
- HANDLE hFind = INVALID_HANDLE_VALUE;
- WIN32_FIND_DATA findData;
- DWORD dwRtnCode;
-
- if ((dwRtnCode = ReparsePointCheck(path, &isReparsePoint)) != ERROR_SUCCESS)
- return dwRtnCode;
-
- if (!isReparsePoint)
- {
- *res = FALSE;
- }
- else
- {
- if ((hFind = FindFirstFile(path, &findData)) == INVALID_HANDLE_VALUE)
- {
- return GetLastError();
- }
- else
- {
- *res = (findData.dwReserved0 == tag);
- FindClose(hFind);
- }
- }
- return ERROR_SUCCESS;
-}
-
-//----------------------------------------------------------------------------
-// Function: IsSymbolicLink
-//
-// Description:
-// Check if the given file is a symbolic link.
-//
-// Returns:
-// ERROR_SUCCESS on success
-// error code otherwise
-//
-// Notes:
-//
-DWORD SymbolicLinkCheck(__in LPCWSTR pathName, __out PBOOL res)
-{
- return ReparseTagCheck(pathName, IO_REPARSE_TAG_SYMLINK, res);
-}
-
-//----------------------------------------------------------------------------
-// Function: GetSidFromAcctNameW
-//
-// Description:
-// To retrieve the SID for a user account
-//
-// Returns:
-// TRUE: on success
-// FALSE: otherwise
-//
-// Notes:
-// Caller needs to destroy the memory of Sid by calling LocalFree()
-//
-BOOL GetSidFromAcctNameW(LPCWSTR acctName, PSID *ppSid)
-{
- DWORD dwSidSize = 0;
- DWORD cchDomainName = 0;
- DWORD dwDomainNameSize = 0;
- LPWSTR domainName = NULL;
- SID_NAME_USE eSidType;
-
- DWORD dwErrorCode;
-
- // Validate the input parameters.
- //
- assert (acctName != NULL && ppSid != NULL);
-
- // First pass to retrieve the buffer size.
- //
- LookupAccountName(
- NULL, // Computer name. NULL for the local computer
- acctName,
- NULL, // pSid. NULL to retrieve buffer size
- &dwSidSize,
- NULL, // Domain Name. NULL to retrieve buffer size
- &cchDomainName,
- &eSidType);
-
- if((dwErrorCode = GetLastError()) != ERROR_INSUFFICIENT_BUFFER)
- {
- ReportErrorCode(L"LookupAccountName", dwErrorCode);
- return FALSE;
- }
- else
- {
- // Reallocate memory for the buffers.
- //
- *ppSid = (PSID)LocalAlloc(LPTR, dwSidSize);
- if (*ppSid == NULL)
- {
- ReportErrorCode(L"LocalAlloc", GetLastError());
- return FALSE;
- }
- dwDomainNameSize = (cchDomainName + 1) * sizeof(wchar_t);
- domainName = (LPWSTR)LocalAlloc(LPTR, dwDomainNameSize);
- if (domainName == NULL)
- {
- ReportErrorCode(L"LocalAlloc", GetLastError());
- return FALSE;
- }
-
- // Second pass to retrieve the SID and domain name.
- //
- if (!LookupAccountNameW(
- NULL, // Computer name. NULL for the local computer
- acctName,
- *ppSid,
- &dwSidSize,
- domainName,
- &cchDomainName,
- &eSidType))
- {
- ReportErrorCode(L"LookupAccountName", GetLastError());
- LocalFree(domainName);
- return FALSE;
- }
-
- if (IsValidSid(*ppSid) == FALSE)
- {
- LocalFree(domainName);
- return FALSE;
- }
- }
-
- LocalFree(domainName);
- return TRUE;
-}
-
-//----------------------------------------------------------------------------
-// Function: GetUnixAccessMask
-//
-// Description:
-// Compute the 3 bit Unix mask for the owner, group, or, others
-//
-// Returns:
-// The 3 bit Unix mask in USHORT
-//
-// Notes:
-//
-static USHORT GetUnixAccessMask(ACCESS_MASK Mask)
-{
- static const USHORT exe = 0x0001;
- static const USHORT write = 0x0002;
- static const USHORT read = 0x0004;
- USHORT mask = 0;
-
- if ((Mask & WinMasks[WIN_READ]) == WinMasks[WIN_READ])
- mask |= read;
- if ((Mask & WinMasks[WIN_WRITE]) == WinMasks[WIN_WRITE])
- mask |= write;
- if ((Mask & WinMasks[WIN_EXECUTE]) == WinMasks[WIN_EXECUTE])
- mask |= exe;
- return mask;
-}
-
-//----------------------------------------------------------------------------
-// Function: GetAccess
-//
-// Description:
-// Get Windows acces mask by AuthZ methods
-//
-// Returns:
-// TRUE: on success
-//
-// Notes:
-//
-static BOOL GetAccess(AUTHZ_CLIENT_CONTEXT_HANDLE hAuthzClient,
- PSECURITY_DESCRIPTOR psd, PACCESS_MASK pAccessRights)
-{
- AUTHZ_ACCESS_REQUEST AccessRequest = {0};
- AUTHZ_ACCESS_REPLY AccessReply = {0};
- BYTE Buffer[1024];
-
- assert (pAccessRights != NULL);
-
- // Do AccessCheck
- AccessRequest.DesiredAccess = MAXIMUM_ALLOWED;
- AccessRequest.PrincipalSelfSid = NULL;
- AccessRequest.ObjectTypeList = NULL;
- AccessRequest.ObjectTypeListLength = 0;
- AccessRequest.OptionalArguments = NULL;
-
- RtlZeroMemory(Buffer, sizeof(Buffer));
- AccessReply.ResultListLength = 1;
- AccessReply.GrantedAccessMask = (PACCESS_MASK) (Buffer);
- AccessReply.Error = (PDWORD) (Buffer + sizeof(ACCESS_MASK));
-
- if (!AuthzAccessCheck(0,
- hAuthzClient,
- &AccessRequest,
- NULL,
- psd,
- NULL,
- 0,
- &AccessReply,
- NULL))
- {
- ReportErrorCode(L"AuthzAccessCheck", GetLastError());
- }
- else
- {
- *pAccessRights = (*(PACCESS_MASK)(AccessReply.GrantedAccessMask));
- return TRUE;
- }
-
- return FALSE;
-}
-
-//----------------------------------------------------------------------------
-// Function: GetEffectiveRightsForUser
-//
-// Description:
-// Get Windows acces mask by AuthZ methods
-//
-// Returns:
-// TRUE: on success
-//
-// Notes:
-// We run into problems for local user accounts when using the method
-// GetEffectiveRightsFromAcl(). We resort to using AuthZ methods as
-// an alternative way suggested on MSDN:
-// http://msdn.microsoft.com/en-us/library/windows/desktop/aa446637.aspx
-//
-static BOOL GetEffectiveRightsForUser(PSECURITY_DESCRIPTOR psd,
- LPCWSTR userName,
- PACCESS_MASK pAccessRights)
-{
- AUTHZ_RESOURCE_MANAGER_HANDLE hManager;
- PSID pSid = NULL;
- LUID unusedId = { 0 };
- AUTHZ_CLIENT_CONTEXT_HANDLE hAuthzClientContext = NULL;
- BOOL ret = FALSE;
-
- assert (pAccessRights != NULL);
-
- if (!AuthzInitializeResourceManager(AUTHZ_RM_FLAG_NO_AUDIT,
- NULL, NULL, NULL, NULL, &hManager))
- {
- ReportErrorCode(L"AuthzInitializeResourceManager", GetLastError());
- return FALSE;
- }
-
- if (GetSidFromAcctNameW(userName, &pSid))
- {
- if(AuthzInitializeContextFromSid(0,
- pSid,
- hManager,
- NULL,
- unusedId,
- NULL,
- &hAuthzClientContext))
- {
- GetAccess(hAuthzClientContext, psd, pAccessRights);
- AuthzFreeContext(hAuthzClientContext);
- ret = TRUE;
- }
- else
- {
- ReportErrorCode(L"AuthzInitializeContextFromSid", GetLastError());
- }
- }
-
- if(pSid) LocalFree(pSid);
-
- return ret;
-}
-
-//----------------------------------------------------------------------------
-// Function: FindFileOwnerAndPermission
-//
-// Description:
-// Find the owner, primary group and permissions of a file object
-//
-// Returns:
-// TRUE: on success
-//
-// Notes:
-//
-BOOL FindFileOwnerAndPermission(
- __in LPCWSTR pathName,
- __out_opt LPWSTR *pOwnerName,
- __out_opt LPWSTR *pGroupName,
- __out_opt PUSHORT pMask)
-{
- DWORD dwRtnCode = 0;
- DWORD dwErrorCode = 0;
-
- PSECURITY_DESCRIPTOR pSd = NULL;
- DWORD dwSdSize = 0;
- DWORD dwSdSizeNeeded = 0;
-
- PTRUSTEE pOwner = NULL;
- PTRUSTEE pGroup = NULL;
-
- ACCESS_MASK ownerAccessRights = 0;
- ACCESS_MASK groupAccessRights = 0;
- ACCESS_MASK worldAccessRights = 0;
-
- BOOL ret = FALSE;
-
- // Do nothing if the caller request nothing
- //
- if (pOwnerName == NULL && pGroupName == NULL && pMask == NULL)
- {
- return TRUE;
- }
-
- // Get the owner SID and DACL of the file
- // First pass to get the size needed for the SD
- //
- GetFileSecurity(
- pathName,
- OWNER_SECURITY_INFORMATION | GROUP_SECURITY_INFORMATION |
- DACL_SECURITY_INFORMATION,
- NULL,
- dwSdSize,
- (LPDWORD)&dwSdSizeNeeded);
- if((dwErrorCode = GetLastError()) != ERROR_INSUFFICIENT_BUFFER)
- {
- ReportErrorCode(L"GetFileSecurity error", dwErrorCode);
- goto FindFileOwnerAndPermissionEnd;
- }
- else
- {
- // Reallocate memory for the buffers
- //
- pSd = (PSECURITY_DESCRIPTOR)LocalAlloc(LPTR, dwSdSizeNeeded);
- if(pSd == NULL)
- {
- ReportErrorCode(L"LocalAlloc", GetLastError());
- goto FindFileOwnerAndPermissionEnd;
- }
-
- dwSdSize = dwSdSizeNeeded;
-
- // Second pass to get the Sd
- //
- if (!GetFileSecurity(
- pathName,
- OWNER_SECURITY_INFORMATION | GROUP_SECURITY_INFORMATION |
- DACL_SECURITY_INFORMATION,
- pSd,
- dwSdSize,
- (LPDWORD)&dwSdSizeNeeded))
- {
- ReportErrorCode(L"GetFileSecurity", GetLastError());
- goto FindFileOwnerAndPermissionEnd;
- }
- }
-
- // Get file owner and group from Sd
- //
- dwRtnCode = LookupSecurityDescriptorParts(&pOwner, &pGroup,
- NULL, NULL, NULL, NULL, pSd);
- if (dwRtnCode != ERROR_SUCCESS)
- {
- ReportErrorCode(L"LookupSecurityDescriptorParts", dwRtnCode);
- goto FindFileOwnerAndPermissionEnd;
- }
-
- assert(pOwner->TrusteeForm == TRUSTEE_IS_NAME);
- assert(pGroup->TrusteeForm == TRUSTEE_IS_NAME);
-
-
- if (pOwnerName)
- {
- *pOwnerName = (LPWSTR)LocalAlloc(LPTR,
- (wcslen(pOwner->ptstrName) + 1) * sizeof(TCHAR));
- if (pOwnerName == NULL)
- {
- ReportErrorCode(L"LocalAlloc", GetLastError());
- goto FindFileOwnerAndPermissionEnd;
- }
- if (FAILED(StringCchCopyNW(*pOwnerName, (wcslen(pOwner->ptstrName) + 1),
- pOwner->ptstrName, wcslen(pOwner->ptstrName) + 1)))
- goto FindFileOwnerAndPermissionEnd;
- }
-
- if (pGroupName)
- {
- *pGroupName = (LPWSTR)LocalAlloc(LPTR,
- (wcslen(pGroup->ptstrName) + 1) * sizeof(TCHAR));
- if (pGroupName == NULL)
- {
- ReportErrorCode(L"LocalAlloc", GetLastError());
- goto FindFileOwnerAndPermissionEnd;
- }
- if (FAILED(StringCchCopyNW(*pGroupName, (wcslen(pGroup->ptstrName) + 1),
- pGroup->ptstrName, wcslen(pGroup->ptstrName) + 1)))
- goto FindFileOwnerAndPermissionEnd;
- }
-
- if (pMask == NULL)
- {
- ret = TRUE;
- goto FindFileOwnerAndPermissionEnd;
- }
-
- if (!GetEffectiveRightsForUser(pSd, pOwner->ptstrName, &ownerAccessRights) ||
- !GetEffectiveRightsForUser(pSd, pGroup->ptstrName, &groupAccessRights) ||
- !GetEffectiveRightsForUser(pSd, L"Everyone", &worldAccessRights))
- {
- goto FindFileOwnerAndPermissionEnd;
- }
-
- *pMask |= GetUnixAccessMask(ownerAccessRights) << 6;
- *pMask |= GetUnixAccessMask(groupAccessRights) << 3;
- *pMask |= GetUnixAccessMask(worldAccessRights);
-
- ret = TRUE;
-
-FindFileOwnerAndPermissionEnd:
- LocalFree(pOwner);
- LocalFree(pGroup);
- LocalFree(pSd);
-
- return ret;
-}
-
-//----------------------------------------------------------------------------
-// Function: ReportErrorCode
-//
-// Description:
-// Report an error. Use FormatMessage function to get the system error message.
-//
-// Returns:
-// None
-//
-// Notes:
-//
-//
-void ReportErrorCode(LPCWSTR func, DWORD err)
-{
- DWORD len = 0;
- LPWSTR msg = NULL;
-
- assert(func != NULL);
-
- len = FormatMessageW(
- FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM,
- NULL, err,
- MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
- (LPWSTR)&msg, 0, NULL);
- if (len > 0)
- {
- fwprintf(stderr, L"%s error (%d): %s\n", func, err, msg);
- }
- else
- {
- fwprintf(stderr, L"%s error code: %d.\n", func, err);
- }
- if (msg != NULL) LocalFree(msg);
-}
Modified: hadoop/common/branches/branch-1-win/src/winutils/common.h
URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-1-win/src/winutils/common.h?rev=1396745&r1=1396744&r2=1396745&view=diff
==============================================================================
--- hadoop/common/branches/branch-1-win/src/winutils/common.h (original)
+++ hadoop/common/branches/branch-1-win/src/winutils/common.h Wed Oct 10 19:09:55 2012
@@ -1,125 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with this
- * work for additional information regarding copyright ownership. The ASF
- * licenses this file to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations under
- * the License.
- */
-
-#ifndef UNICODE
-#define UNICODE
-#endif
-
-#pragma once
-
-#include <stdio.h>
-#include <assert.h>
-#include <windows.h>
-#include <aclapi.h>
-#include <accctrl.h>
-#include <tchar.h>
-#include <strsafe.h>
-enum EXIT_CODE
-{
- /* Common success exit code shared among all utilities */
- SUCCESS = EXIT_SUCCESS,
- /* Generic failure exit code share among all utilities */
- FAILURE = EXIT_FAILURE,
- /* Failure code indicates the user does not privilege to create symlinks */
- SYMLINK_NO_PRIVILEGE = 2,
-};
-
-
-/*
- * The array of 12 months' three-letter abbreviations
- */
-extern const LPCWSTR MONTHS[];
-
-/*
- * The Unix masks
- */
-enum UnixAclMask
-{
- UX_O_EXECUTE = 0x0001,
- UX_O_WRITE = 0x0002,
- UX_O_READ = 0x0004,
- UX_G_EXECUTE = 0x0008,
- UX_G_WRITE = 0x0010,
- UX_G_READ = 0x0020,
- UX_U_EXECUTE = 0x0040,
- UX_U_WRITE = 0x0080,
- UX_U_READ = 0x0100,
- UX_DIRECTORY = 0x0200,
- UX_SYMLINK = 0x0400,
-};
-
-
-/*
- * The WindowsAclMask and WinMasks contain the definitions used to establish
- * the mapping between Unix and Windows.
- */
-enum WindowsAclMask
-{
- WIN_READ, // The permission(s) that enable Unix read permission
- WIN_WRITE, // The permission(s) that enable Unix write permission
- WIN_EXECUTE, // The permission(s) that enbale Unix execute permission
- WIN_OWNER_SE, // The permissions that are always set for file owners
- WIN_ALL, // The permissions that all files on Windows should have
- WIN_MASKS_TOTAL
-};
-extern const ACCESS_MASK WinMasks[];
-
-
-int Ls(int argc, wchar_t *argv[]);
-void LsUsage(LPCWSTR program);
-
-int Chmod(int argc, wchar_t *argv[]);
-void ChmodUsage(LPCWSTR program);
-
-int Chown(int argc, wchar_t *argv[]);
-void ChownUsage(LPCWSTR program);
-
-int Groups(int argc, wchar_t *argv[]);
-void GroupsUsage(LPCWSTR program);
-
-int Hardlink(int argc, wchar_t *argv[]);
-void HardlinkUsage();
-
-int Task(int argc, wchar_t *argv[]);
-void TaskUsage();
-
-int Symlink(int argc, wchar_t *argv[]);
-void SymlinkUsage();
-
-int SystemInfo();
-void SystemInfoUsage();
-
-DWORD GetFileInformationByName(__in LPCWSTR pathName, __in BOOL followLink,
- __out LPBY_HANDLE_FILE_INFORMATION lpFileInformation);
-
-DWORD ConvertToLongPath(__in PCWSTR path, __deref_out PWSTR *newPath);
-
-BOOL GetSidFromAcctNameW(LPCWSTR acctName, PSID* ppSid);
-
-void ReportErrorCode(LPCWSTR func, DWORD err);
-
-BOOL IsDirFileInfo(const BY_HANDLE_FILE_INFORMATION *fileInformation);
-
-BOOL FindFileOwnerAndPermission(
- __in LPCWSTR pathName,
- __out_opt LPWSTR *pOwnerName,
- __out_opt LPWSTR *pGroupName,
- __out_opt PUSHORT pMask);
-
-DWORD DirectoryCheck(__in LPCWSTR pathName, __out LPBOOL result);
-
-DWORD SymbolicLinkCheck(__in LPCWSTR pathName, __out LPBOOL result);
Modified: hadoop/common/branches/branch-1-win/src/winutils/groups.c
URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-1-win/src/winutils/groups.c?rev=1396745&r1=1396744&r2=1396745&view=diff
==============================================================================
--- hadoop/common/branches/branch-1-win/src/winutils/groups.c (original)
+++ hadoop/common/branches/branch-1-win/src/winutils/groups.c Wed Oct 10 19:09:55 2012
@@ -14,13 +14,7 @@
* License for the specific language governing permissions and limitations under
* the License.
*/
-
-#pragma comment(lib, "netapi32.lib")
-
-#define SECURITY_WIN32
-
-#include "common.h"
-#include <lm.h>
+#include "winutils.h"
//----------------------------------------------------------------------------
// Function: PrintGroups
@@ -35,65 +29,32 @@
// This function could fail on first pass when we fail to find groups for
// domain account; so we do not report Windows API errors in this function.
//
-static BOOL PrintGroups(LPCWSTR userName)
+static BOOL PrintGroups(LPLOCALGROUP_USERS_INFO_0 groups, DWORD entries)
{
BOOL ret = TRUE;
- LPLOCALGROUP_USERS_INFO_0 pBuf = NULL;
- DWORD dwEntriesRead = 0;
- DWORD dwTotalEntries = 0;
- NET_API_STATUS nStatus;
-
- // Call the NetUserGetLocalGroups function specifying information level 0.
- // The LG_INCLUDE_INDIRECT flag specifies that the function should also
- // return the names of the local groups in which the user is indirectly a
- // member.
- //
- nStatus = NetUserGetLocalGroups(NULL,
- userName,
- 0,
- LG_INCLUDE_INDIRECT,
- (LPBYTE *) &pBuf,
- MAX_PREFERRED_LENGTH,
- &dwEntriesRead,
- &dwTotalEntries);
-
- if (nStatus == NERR_Success)
- {
- LPLOCALGROUP_USERS_INFO_0 pTmpBuf;
- DWORD i;
- DWORD dwTotalCount = 0;
+ LPLOCALGROUP_USERS_INFO_0 pTmpBuf = groups;
+ DWORD i;
- if ((pTmpBuf = pBuf) != NULL)
+ for (i = 0; i < entries; i++)
+ {
+ if (pTmpBuf == NULL)
{
- for (i = 0; i < dwEntriesRead; i++)
- {
- if (pTmpBuf == NULL)
- {
- ret = FALSE;
- break;
- }
-
- if (i != 0)
- {
- wprintf(L" ");
- }
- wprintf(L"%s", pTmpBuf->lgrui0_name);
-
- pTmpBuf++;
- dwTotalCount++;
- }
+ ret = FALSE;
+ break;
}
- else
+
+ if (i != 0)
{
- ret = FALSE;
+ wprintf(L" ");
}
+ wprintf(L"%s", pTmpBuf->lgrui0_name);
+
+ pTmpBuf++;
}
- else
- {
- ret = FALSE;
- }
- if (pBuf != NULL) NetApiBufferFree(pBuf);
+ if (ret)
+ wprintf(L"\n");
+
return ret;
}
@@ -116,14 +77,12 @@ int Groups(int argc, wchar_t *argv[])
LPWSTR currentUser = NULL;
DWORD cchCurrentUser = 0;
- PSID pUserSid = NULL;
- LPWSTR userName = NULL;
- DWORD cchName = 0;
- LPWSTR domainName = NULL;
- DWORD cchDomainName = 0;
- SID_NAME_USE eUse;
+ LPLOCALGROUP_USERS_INFO_0 groups = NULL;
+ DWORD entries = 0;
- int ret = EXIT_FAILURE;
+ DWORD dwRtnCode = ERROR_SUCCESS;
+
+ int ret = EXIT_SUCCESS;
if (argc != 2 && argc != 1)
{
@@ -166,73 +125,21 @@ int Groups(int argc, wchar_t *argv[])
input = argv[1];
}
- if (PrintGroups(input))
+ if ((dwRtnCode = GetLocalGroupsForUser(input, &groups, &entries))
+ != ERROR_SUCCESS)
{
- ret = EXIT_SUCCESS;
+ ret = EXIT_FAILURE;
+ goto GroupsEnd;
}
- else if (GetSidFromAcctNameW(input, &pUserSid))
- {
- LookupAccountSidW(NULL, pUserSid, NULL,
- &cchName, NULL, &cchDomainName, &eUse);
- if (GetLastError() == ERROR_INSUFFICIENT_BUFFER)
- {
- userName = (LPWSTR) LocalAlloc(LPTR, (cchName + 1) * sizeof(wchar_t));
- domainName = (LPWSTR) LocalAlloc(LPTR,
- (cchDomainName + 1) * sizeof(wchar_t));
- if (!userName || !domainName)
- {
- ReportErrorCode(L"LocalAlloc", GetLastError());
- ret = EXIT_FAILURE;
- goto GroupsEnd;
- }
- if (LookupAccountSidW(NULL, pUserSid, userName, &cchName,
- domainName, &cchDomainName, &eUse))
- {
- LPWSTR fullName = (LPWSTR) LocalAlloc(LPTR,
- (cchName + cchDomainName + 2) * sizeof(wchar_t));
- if (!fullName)
- {
- ReportErrorCode(L"LocalAlloc", GetLastError());
- ret = EXIT_FAILURE;
- goto GroupsEnd;
- }
- if (FAILED(StringCchPrintfW(fullName,
- cchName + cchDomainName + 2,
- L"%s\\%s", domainName, userName)))
- {
- ret = EXIT_FAILURE;
- goto GroupsEnd;
- }
- if (!PrintGroups(fullName))
- ret = EXIT_FAILURE;
- else
- ret = EXIT_SUCCESS;
- LocalFree(fullName);
- }
- else
- {
- ret = EXIT_FAILURE;
- }
- }
- else
- {
- ret = EXIT_FAILURE;
- }
- }
- else
+ if (!PrintGroups(groups, entries))
{
ret = EXIT_FAILURE;
}
GroupsEnd:
LocalFree(currentUser);
- LocalFree(pUserSid);
- LocalFree(userName);
- LocalFree(domainName);
-
- if (ret == EXIT_SUCCESS) wprintf(L"\n");
-
+ if (groups != NULL) NetApiBufferFree(groups);
return ret;
}
Modified: hadoop/common/branches/branch-1-win/src/winutils/hardlink.c
URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-1-win/src/winutils/hardlink.c?rev=1396745&r1=1396744&r2=1396745&view=diff
==============================================================================
--- hadoop/common/branches/branch-1-win/src/winutils/hardlink.c (original)
+++ hadoop/common/branches/branch-1-win/src/winutils/hardlink.c Wed Oct 10 19:09:55 2012
@@ -15,7 +15,7 @@
* the License.
*/
-#include "common.h"
+#include "winutils.h"
// List of different hardlink related command line options supported by
// winutils.
Modified: hadoop/common/branches/branch-1-win/src/winutils/ls.c
URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-1-win/src/winutils/ls.c?rev=1396745&r1=1396744&r2=1396745&view=diff
==============================================================================
--- hadoop/common/branches/branch-1-win/src/winutils/ls.c (original)
+++ hadoop/common/branches/branch-1-win/src/winutils/ls.c Wed Oct 10 19:09:55 2012
@@ -15,7 +15,7 @@
* the License.
*/
-#include "common.h"
+#include "winutils.h"
//----------------------------------------------------------------------------
// Function: GetMaskString
@@ -27,8 +27,12 @@
// TRUE: on success
//
// Notes:
+// The function only sets the existed permission in the mask string. If the
+// permission does not exist, the corresponding character in mask string is not
+// altered. The caller need to initilize the mask string to be all '-' to get
+// the correct mask string.
//
-static BOOL GetMaskString(USHORT accessMask, LPWSTR maskString)
+static BOOL GetMaskString(INT accessMask, LPWSTR maskString)
{
if(wcslen(maskString) != 10)
return FALSE;
@@ -40,42 +44,24 @@ static BOOL GetMaskString(USHORT accessM
if ((accessMask & UX_U_READ) == UX_U_READ)
maskString[1] = L'r';
- else
- maskString[1] = L'-';
if ((accessMask & UX_U_WRITE) == UX_U_WRITE)
maskString[2] = L'w';
- else
- maskString[2] = L'-';
if ((accessMask & UX_U_EXECUTE) == UX_U_EXECUTE)
maskString[3] = L'x';
- else
- maskString[3] = L'-';
if ((accessMask & UX_G_READ) == UX_G_READ)
maskString[4] = L'r';
- else
- maskString[4] = L'-';
if ((accessMask & UX_G_WRITE) == UX_G_WRITE)
maskString[5] = L'w';
- else
- maskString[5] = L'-';
if ((accessMask & UX_G_EXECUTE) == UX_G_EXECUTE)
maskString[6] = L'x';
- else
- maskString[6] = L'-';
if ((accessMask & UX_O_READ) == UX_O_READ)
maskString[7] = L'r';
- else
- maskString[7] = L'-';
if ((accessMask & UX_O_WRITE) == UX_O_WRITE)
maskString[8] = L'w';
- else
- maskString[8] = L'-';
if ((accessMask & UX_O_EXECUTE) == UX_O_EXECUTE)
maskString[9] = L'x';
- else
- maskString[9] = L'-';
return TRUE;
}
@@ -92,7 +78,7 @@ static BOOL GetMaskString(USHORT accessM
// Notes:
//
static BOOL LsPrintLine(
- const USHORT mask,
+ const INT mask,
const DWORD hardlinkCount,
LPCWSTR ownerName,
LPCWSTR groupName,
@@ -114,7 +100,7 @@ static BOOL LsPrintLine(
return FALSE;
}
- // Build mask string from ushort mask
+ // Build mask string from mask mode
if (FAILED(StringCchCopyW(maskString, (ck_ullMaskLen+1), L"----------")))
{
goto LsPrintLineEnd;
@@ -164,7 +150,7 @@ int Ls(int argc, wchar_t *argv[])
LPWSTR ownerName = NULL;
LPWSTR groupName = NULL;
- USHORT accessMask = 0x0000;
+ INT unixAccessMode = 0;
DWORD dwErrorCode = ERROR_SUCCESS;
LARGE_INTEGER fileSize;
@@ -216,20 +202,24 @@ int Ls(int argc, wchar_t *argv[])
}
if (isSymlink)
- accessMask |= UX_SYMLINK;
+ unixAccessMode |= UX_SYMLINK;
else if (IsDirFileInfo(&fileInformation))
- accessMask |= UX_DIRECTORY;
+ unixAccessMode |= UX_DIRECTORY;
- if (!FindFileOwnerAndPermission(longPathName,
- &ownerName, &groupName, &accessMask))
+ dwErrorCode = FindFileOwnerAndPermission(longPathName,
+ &ownerName, &groupName, &unixAccessMode);
+ if (dwErrorCode != ERROR_SUCCESS)
+ {
+ ReportErrorCode(L"FindFileOwnerAndPermission", dwErrorCode);
goto LsEnd;
+ }
fileSize.HighPart = fileInformation.nFileSizeHigh;
fileSize.LowPart = fileInformation.nFileSizeLow;
// Print output using the input path name (not the long one)
//
- if (!LsPrintLine(accessMask,
+ if (!LsPrintLine(unixAccessMode,
fileInformation.nNumberOfLinks,
ownerName, groupName,
&fileInformation.ftLastWriteTime,
Modified: hadoop/common/branches/branch-1-win/src/winutils/main.c
URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-1-win/src/winutils/main.c?rev=1396745&r1=1396744&r2=1396745&view=diff
==============================================================================
--- hadoop/common/branches/branch-1-win/src/winutils/main.c (original)
+++ hadoop/common/branches/branch-1-win/src/winutils/main.c Wed Oct 10 19:09:55 2012
@@ -15,7 +15,7 @@
* the License.
*/
-#include "common.h"
+#include "winutils.h"
static void Usage(LPCWSTR program);
Modified: hadoop/common/branches/branch-1-win/src/winutils/symlink.c
URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-1-win/src/winutils/symlink.c?rev=1396745&r1=1396744&r2=1396745&view=diff
==============================================================================
--- hadoop/common/branches/branch-1-win/src/winutils/symlink.c (original)
+++ hadoop/common/branches/branch-1-win/src/winutils/symlink.c Wed Oct 10 19:09:55 2012
@@ -15,7 +15,7 @@
* the License.
*/
-#include "common.h"
+#include "winutils.h"
//----------------------------------------------------------------------------
// Function: EnablePrivilege
Modified: hadoop/common/branches/branch-1-win/src/winutils/systeminfo.c
URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-1-win/src/winutils/systeminfo.c?rev=1396745&r1=1396744&r2=1396745&view=diff
==============================================================================
--- hadoop/common/branches/branch-1-win/src/winutils/systeminfo.c (original)
+++ hadoop/common/branches/branch-1-win/src/winutils/systeminfo.c Wed Oct 10 19:09:55 2012
@@ -15,7 +15,7 @@
* the License.
*/
-#include "common.h"
+#include "winutils.h"
#include <psapi.h>
#include <PowrProf.h>
Modified: hadoop/common/branches/branch-1-win/src/winutils/task.c
URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-1-win/src/winutils/task.c?rev=1396745&r1=1396744&r2=1396745&view=diff
==============================================================================
--- hadoop/common/branches/branch-1-win/src/winutils/task.c (original)
+++ hadoop/common/branches/branch-1-win/src/winutils/task.c Wed Oct 10 19:09:55 2012
@@ -15,7 +15,7 @@
* the License.
*/
-#include "common.h"
+#include "winutils.h"
#include <errno.h>
#include <psapi.h>
@@ -99,7 +99,6 @@ DWORD createTask(_TCHAR* jobObjName, _TC
DWORD exitCode = EXIT_FAILURE;
STARTUPINFO si;
PROCESS_INFORMATION pi;
- SECURITY_ATTRIBUTES sa;
HANDLE jobObject = NULL;
JOBOBJECT_EXTENDED_LIMIT_INFORMATION jeli = { 0 };
Modified: hadoop/common/branches/branch-1-win/src/winutils/winutils.sln
URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-1-win/src/winutils/winutils.sln?rev=1396745&r1=1396744&r2=1396745&view=diff
==============================================================================
--- hadoop/common/branches/branch-1-win/src/winutils/winutils.sln (original)
+++ hadoop/common/branches/branch-1-win/src/winutils/winutils.sln Wed Oct 10 19:09:55 2012
@@ -2,6 +2,11 @@
Microsoft Visual Studio Solution File, Format Version 11.00
# Visual Studio 2010
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "winutils", "winutils.vcxproj", "{D94B3BD7-39CC-47A0-AE9A-353FDE506F33}"
+ ProjectSection(ProjectDependencies) = postProject
+ {12131AA7-902E-4A6D-9CE3-043261D22A12} = {12131AA7-902E-4A6D-9CE3-043261D22A12}
+ EndProjectSection
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libwinutils", "libwinutils.vcxproj", "{12131AA7-902E-4A6D-9CE3-043261D22A12}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
@@ -19,6 +24,14 @@ Global
{D94B3BD7-39CC-47A0-AE9A-353FDE506F33}.Release|Win32.Build.0 = Release|Win32
{D94B3BD7-39CC-47A0-AE9A-353FDE506F33}.Release|x64.ActiveCfg = Release|x64
{D94B3BD7-39CC-47A0-AE9A-353FDE506F33}.Release|x64.Build.0 = Release|x64
+ {12131AA7-902E-4A6D-9CE3-043261D22A12}.Debug|Win32.ActiveCfg = Debug|x64
+ {12131AA7-902E-4A6D-9CE3-043261D22A12}.Debug|Win32.Build.0 = Debug|x64
+ {12131AA7-902E-4A6D-9CE3-043261D22A12}.Debug|x64.ActiveCfg = Debug|x64
+ {12131AA7-902E-4A6D-9CE3-043261D22A12}.Debug|x64.Build.0 = Debug|x64
+ {12131AA7-902E-4A6D-9CE3-043261D22A12}.Release|Win32.ActiveCfg = Release|Win32
+ {12131AA7-902E-4A6D-9CE3-043261D22A12}.Release|Win32.Build.0 = Release|Win32
+ {12131AA7-902E-4A6D-9CE3-043261D22A12}.Release|x64.ActiveCfg = Release|x64
+ {12131AA7-902E-4A6D-9CE3-043261D22A12}.Release|x64.Build.0 = Release|x64
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Modified: hadoop/common/branches/branch-1-win/src/winutils/winutils.vcxproj
URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-1-win/src/winutils/winutils.vcxproj?rev=1396745&r1=1396744&r2=1396745&view=diff
==============================================================================
--- hadoop/common/branches/branch-1-win/src/winutils/winutils.vcxproj (original)
+++ hadoop/common/branches/branch-1-win/src/winutils/winutils.vcxproj Wed Oct 10 19:09:55 2012
@@ -62,6 +62,9 @@
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
+ <PropertyGroup>
+ <IncludePath>include;$(IncludePath)</IncludePath>
+ </PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<LinkIncremental>true</LinkIncremental>
</PropertyGroup>
@@ -139,7 +142,6 @@
<ClCompile Include="systeminfo.c" />
<ClCompile Include="chmod.c" />
<ClCompile Include="chown.c" />
- <ClCompile Include="common.c" />
<ClCompile Include="groups.c" />
<ClCompile Include="hardlink.c" />
<ClCompile Include="task.c" />
@@ -147,7 +149,9 @@
<ClCompile Include="main.c" />
</ItemGroup>
<ItemGroup>
- <ClInclude Include="common.h" />
+ <ProjectReference Include="libwinutils.vcxproj">
+ <Project>{12131aa7-902e-4a6d-9ce3-043261d22a12}</Project>
+ </ProjectReference>
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">