diff --git a/contrib/win32/openssh/win32compat.vcxproj b/contrib/win32/openssh/win32compat.vcxproj
index 32d69af..acbbf5e 100644
--- a/contrib/win32/openssh/win32compat.vcxproj
+++ b/contrib/win32/openssh/win32compat.vcxproj
@@ -147,9 +147,6 @@
-
-
-
diff --git a/contrib/win32/openssh/win32compat.vcxproj.filters b/contrib/win32/openssh/win32compat.vcxproj.filters
index 0c0cd70..09e364e 100644
--- a/contrib/win32/openssh/win32compat.vcxproj.filters
+++ b/contrib/win32/openssh/win32compat.vcxproj.filters
@@ -45,15 +45,6 @@
Source Files
-
- Source Files
-
-
- Source Files
-
-
- Source Files
-
Source Files
diff --git a/contrib/win32/win32compat/daemon.c b/contrib/win32/win32compat/daemon.c
index c7ce8e2..9618c98 100644
--- a/contrib/win32/win32compat/daemon.c
+++ b/contrib/win32/win32compat/daemon.c
@@ -31,7 +31,4 @@
#include "includes.h"
-int daemon(int nochdir, int noclose)
-{
- return 0;
-}
+
diff --git a/contrib/win32/win32compat/deskright.c b/contrib/win32/win32compat/deskright.c
deleted file mode 100644
index 122c44e..0000000
--- a/contrib/win32/win32compat/deskright.c
+++ /dev/null
@@ -1,827 +0,0 @@
-/*
- * Author: NoMachine
- *
- * Copyright (c) 2009, 2011 NoMachine
- * All rights reserved
- *
- * Support functions and system calls' replacements needed to let the
- * software run on Win32 based operating systems.
- *
- * 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 ``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 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.
- */
-
-#include "deskright.h"
-
-/*
- * Retrieve SID from access token.
- *
- * hToken - access token (IN)
- * psid - user's SID (OUT)
- *
- * RETURNS: TRUE if OK.
- */
-
-BOOL ObtainSid(HANDLE hToken, PSID *psid)
-{
- debug3("-> ObtainSid()...");
-
- BOOL bSuccess = FALSE;
-
- DWORD dwIndex;
-
- DWORD dwLength = 0;
-
- TOKEN_INFORMATION_CLASS tic = TokenGroups;
-
- PTOKEN_GROUPS ptg = NULL;
-
- /*
- * determine the size of the buffer
- */
-
- if (!GetTokenInformation(hToken, tic, (LPVOID) ptg, 0, &dwLength))
- {
- FAIL(GetLastError() != ERROR_INSUFFICIENT_BUFFER);
-
- ptg = (PTOKEN_GROUPS) HeapAlloc(GetProcessHeap(),
- HEAP_ZERO_MEMORY, dwLength);
-
- FAIL(ptg == NULL);
- }
-
- /*
- * obtain the groups the access token belongs to
- */
-
- FAIL(GetTokenInformation(hToken, tic, (LPVOID) ptg,
- dwLength, &dwLength) == FALSE);
-
- /*
- * determine which group is the logon sid
- */
-
- for (dwIndex = 0; dwIndex < ptg -> GroupCount; dwIndex++)
- {
- if ((ptg -> Groups[dwIndex].Attributes & SE_GROUP_LOGON_ID) == SE_GROUP_LOGON_ID)
- {
- /*
- * determine the length of the sid
- */
-
- dwLength = GetLengthSid(ptg -> Groups[dwIndex].Sid);
-
- /*
- * allocate a buffer for the logon sid
- */
-
- *psid = (PSID) HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, dwLength);
-
- FAIL(*psid == NULL);
-
- /*
- * obtain a copy of the logon sid
- */
-
- FAIL(CopySid(dwLength, *psid, ptg -> Groups[dwIndex].Sid) == FALSE);
-
- /*
- * Break out of the loop because the logon sid has been
- * found.
- */
-
- break;
- }
- }
-
- /*
- * Indicate success.
- */
-
- bSuccess = TRUE;
-
- fail:
-
- /*
- * Free the buffer for the token group.
- */
-
- if (ptg != NULL)
- {
- HeapFree(GetProcessHeap(), 0, (LPVOID)ptg);
- }
-
- debug3("<- ObtainSid()...");
-
- return bSuccess;
-}
-
-/*
- * Gives or removes user rights to use given WinStation object.
- *
- * WARNING. This rights is given only for login session, i.e,
- * acount's properties are not be changed.
- *
- * hwinsta - handle to WindowsStation object (IN)
- * psid - pointer to user's SID (IN)
- * mode - 1 for add, 0 for remove right (IN)
- *
- * RETURNS: TRUE if OK.
- */
-
-BOOL ModifyTheAceWindowStation(HWINSTA hwinsta, PSID psid, int mode)
-{
- debug2("-> ModifyTheAceWindowStation(mode = %d)...", mode);
-
- ACCESS_ALLOWED_ACE *pace = NULL;
-
- ACL_SIZE_INFORMATION aclSizeInfo;
-
- BOOL bDaclExist;
- BOOL bDaclPresent;
- BOOL bSuccess = FALSE;
-
- DWORD dwNewAclSize;
- DWORD dwSidSize = 0;
- DWORD dwSdSizeNeeded;
-
- PACL pacl;
- PACL pNewAcl = NULL;
-
- PSECURITY_DESCRIPTOR psd = NULL;
- PSECURITY_DESCRIPTOR psdNew = NULL;
-
- ACCESS_ALLOWED_ACE *pTempAce;
-
- SECURITY_INFORMATION si = DACL_SECURITY_INFORMATION;
-
- unsigned int i;
-
- /*
- * is input SID valid?
- */
-
- debug3("Testing is SID valid...");
-
- FAIL(psid == NULL);
-
- FAIL(IsValidSid(psid) == FALSE);
-
- /*
- * obtain the dacl for the windowstation
- */
-
- debug3("GetUserObjectSecurity()...");
-
- if (!GetUserObjectSecurity(hwinsta, &si, psd, dwSidSize, &dwSdSizeNeeded))
- {
- FAIL(GetLastError() != ERROR_INSUFFICIENT_BUFFER);
-
- psd = (PSECURITY_DESCRIPTOR) HeapAlloc(GetProcessHeap(),
- HEAP_ZERO_MEMORY,
- dwSdSizeNeeded);
-
- FAIL(psd == NULL);
-
- psdNew = (PSECURITY_DESCRIPTOR) HeapAlloc(GetProcessHeap(),
- HEAP_ZERO_MEMORY,
- dwSdSizeNeeded);
-
- FAIL(psdNew == NULL);
-
- dwSidSize = dwSdSizeNeeded;
-
- FAIL(GetUserObjectSecurity(hwinsta, &si, psd,
- dwSidSize, &dwSdSizeNeeded) == FALSE);
- }
-
- /*
- * Create a new dacl.
- */
-
- debug3("InitializeSecurityDescriptor()...");
-
- FAIL(InitializeSecurityDescriptor(psdNew, SECURITY_DESCRIPTOR_REVISION) == FALSE);
-
- /*
- * get dacl from the security descriptor.
- */
-
- debug3("GetSecurityDescriptorDacl()...");
-
- FAIL(GetSecurityDescriptorDacl(psd, &bDaclPresent, &pacl, &bDaclExist) == FALSE);
-
- /*
- * Initialize.
- */
-
- ZeroMemory(&aclSizeInfo, sizeof(ACL_SIZE_INFORMATION));
- aclSizeInfo.AclBytesInUse = sizeof(ACL);
-
- /*
- * Call only if the dacl is not NULL.
- */
-
- if (pacl != NULL)
- {
- /*
- * Get the file ACL size info.
- */
-
- debug3("GetAclInformation()...");
-
- FAIL(GetAclInformation(pacl, (LPVOID) &aclSizeInfo,
- sizeof(ACL_SIZE_INFORMATION),
- AclSizeInformation) == FALSE);
- }
-
- /*
- * Compute the size of the new acl.
- */
-
- debug3("Calculating dwNewAclSize...");
-
- dwNewAclSize = aclSizeInfo.AclBytesInUse;
-
- if (mode == ADD_RIGHT)
- {
- dwNewAclSize = dwNewAclSize + (2 * GetLengthSid(psid))
- + (2 * sizeof(ACCESS_ALLOWED_ACE))
- - (2 * sizeof(DWORD));
- }
- else
- {
- dwNewAclSize = dwNewAclSize + (2 * GetLengthSid(psid))
- - (2 * sizeof(ACCESS_ALLOWED_ACE))
- + (2 * sizeof(DWORD));
- }
-
- debug3("dwNewAclSize = %d", dwNewAclSize);
-
- /*
- * Allocate memory for the new acl.
- */
-
- debug3("HeapAlloc()...");
-
- pNewAcl = (PACL) HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, dwNewAclSize);
-
- FAIL(pNewAcl == NULL);
-
- /*
- * Initialize the new dacl.
- */
-
- debug3("InitializeAcl()...");
-
- FAIL(InitializeAcl(pNewAcl, dwNewAclSize, ACL_REVISION) == FALSE);
-
- /*
- * If DACL is present, copy it to a new DACL.
- */
-
- if (bDaclPresent)
- {
- /*
- * Copy the ACEs from old to new ACL.
- */
-
- if (aclSizeInfo.AceCount)
- {
-
- debug3("aclSizeInfo.AceCount = %d", aclSizeInfo.AceCount);
-
- for (i = 0; i < aclSizeInfo.AceCount; i++)
- {
- /*
- * Get next ACE from old ACL.
- */
-
- FAIL(GetAce(pacl, i, &pTempAce) == FALSE);
-
- /*
- * Add the ACE to the new ACL.
- *
- * We copy all original list for RIGHT_ADD mode and
- * skip ACE with given input SID in RIGHT_REMOVE mode.
- */
-
- if (mode == ADD_RIGHT || EqualSid(psid, &pTempAce -> SidStart) == 0)
- {
- FAIL(AddAce(pNewAcl, ACL_REVISION, MAXDWORD, pTempAce,
- ((PACE_HEADER) pTempAce) -> AceSize) == FALSE);
- }
- }
- }
- }
-
- if (mode == ADD_RIGHT)
- {
- /*
- * Add the first ACE to the windowstation.
- */
-
- pace = (ACCESS_ALLOWED_ACE *) HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY,
- sizeof(ACCESS_ALLOWED_ACE) + GetLengthSid(psid) - sizeof(DWORD));
-
- FAIL(pace == NULL);
-
- pace -> Header.AceType = ACCESS_ALLOWED_ACE_TYPE;
- pace -> Header.AceFlags = CONTAINER_INHERIT_ACE | INHERIT_ONLY_ACE | OBJECT_INHERIT_ACE;
- pace -> Header.AceSize = sizeof(ACCESS_ALLOWED_ACE) + GetLengthSid(psid) - sizeof(DWORD);
- pace -> Mask = GENERIC_ACCESS;
-
- debug3("CopySid()...");
-
- FAIL(CopySid(GetLengthSid(psid), &pace -> SidStart, psid) == FALSE);
-
- debug3("AddAce()...");
-
- FAIL(AddAce(pNewAcl, ACL_REVISION, MAXDWORD,
- (LPVOID)pace, pace -> Header.AceSize) == FALSE);
-
- /*
- * Add the second ACE to the windowstation.
- */
-
- pace -> Header.AceFlags = NO_PROPAGATE_INHERIT_ACE;
- pace -> Mask = WINSTA_ALL;
-
- debug3("AddAce()...");
-
- FAIL(AddAce(pNewAcl, ACL_REVISION, MAXDWORD,
- (LPVOID) pace, pace -> Header.AceSize) == FALSE);
- }
-
- /*
- * Set new dacl for the security descriptor.
- */
-
- debug3("SetSecurityDescriptorDacl()...");
-
- FAIL(SetSecurityDescriptorDacl(psdNew, TRUE, pNewAcl, FALSE) == FALSE);
-
- /*
- * Set the new security descriptor for the windowstation.
- */
-
- debug3("SetUserObjectSecurity()...");
-
- FAIL(SetUserObjectSecurity(hwinsta, &si, psdNew) == FALSE);
-
- /*
- * Indicate success.
- */
-
- bSuccess = TRUE;
-
-fail:
-
- /*
- * Free the allocated buffers.
- */
-
- if (pace != NULL)
- {
- HeapFree(GetProcessHeap(), 0, (LPVOID)pace);
- }
-
- if (pNewAcl != NULL)
- {
- HeapFree(GetProcessHeap(), 0, (LPVOID)pNewAcl);
- }
-
- if (psd != NULL)
- {
- HeapFree(GetProcessHeap(), 0, (LPVOID)psd);
- }
-
- if (psdNew != NULL)
- {
- HeapFree(GetProcessHeap(), 0, (LPVOID)psdNew);
- }
-
- return bSuccess;
-}
-
-/*
- * Gives ore removes user right to use given desktop.
- *
- * WARNING. This right is given only for login session, i.e,
- * account's properties are not be changed.
- *
- * hdesk - handle to desktop (IN)
- * psid - pointer to user's SID (IN)
- * mode - 1 for add, 0 for remove (IN)
- *
- * RETURNS: TRUE if OK.
- */
-
-BOOL ModifyTheAceDesktop(HDESK hdesk, PSID psid, int mode)
-{
- debug2("-> ModifyTheAceDesktop(mode = %d)...", mode);
-
- ACL_SIZE_INFORMATION aclSizeInfo;
-
- BOOL bDaclExist;
- BOOL bDaclPresent;
- BOOL bSuccess = FALSE;
-
- DWORD dwNewAclSize;
- DWORD dwSidSize = 0;
- DWORD dwSdSizeNeeded;
-
- PACL pacl;
- PACL pNewAcl;
-
- PSECURITY_DESCRIPTOR psd = NULL;
- PSECURITY_DESCRIPTOR psdNew = NULL;
-
- HANDLE procHeap = NULL;
-
- ACCESS_ALLOWED_ACE *pTempAce;
-
- SECURITY_INFORMATION si = DACL_SECURITY_INFORMATION;
-
- unsigned int i;
-
- /*
- * is input SID valid?
- */
-
- debug3("Testing is SID valid...");
-
- FAIL(psid == NULL);
-
- FAIL(IsValidSid(psid) == FALSE);
-
- /*
- * Obtain process heap.
- */
-
- procHeap = GetProcessHeap();
-
- /*
- * Obtain the security descriptor for the desktop object.
- */
-
- debug3("GetUserObjectSecurity()...");
-
- if (!GetUserObjectSecurity(hdesk, &si, psd,
- dwSidSize, &dwSdSizeNeeded))
- {
- FAIL(GetLastError() != ERROR_INSUFFICIENT_BUFFER);
-
- psd = (PSECURITY_DESCRIPTOR) HeapAlloc(procHeap,
- HEAP_ZERO_MEMORY,
- dwSdSizeNeeded);
-
- FAIL(psd == NULL);
-
- psdNew = (PSECURITY_DESCRIPTOR)HeapAlloc(procHeap,
- HEAP_ZERO_MEMORY,
- dwSdSizeNeeded);
-
- FAIL(psdNew == NULL);
-
- dwSidSize = dwSdSizeNeeded;
-
- FAIL(GetUserObjectSecurity(hdesk, &si, psd, dwSidSize,
- &dwSdSizeNeeded) == FALSE);
- }
-
- /*
- * create a new security descriptor.
- */
-
- debug3("InitializeSecurityDescriptor()...");
-
- FAIL(InitializeSecurityDescriptor(psdNew,
- SECURITY_DESCRIPTOR_REVISION) == FALSE);
-
- /*
- * obtain the dacl from the security descriptor.
- */
-
- debug3("GetSecurityDescriptorDacl()...");
-
- FAIL(GetSecurityDescriptorDacl(psd, &bDaclPresent,
- &pacl, &bDaclExist) == FALSE);
-
- /*
- * Initialize.
- */
-
- ZeroMemory(&aclSizeInfo, sizeof(ACL_SIZE_INFORMATION));
-
- aclSizeInfo.AclBytesInUse = sizeof(ACL);
-
- /*
- * Call only if NULL dacl.
- */
-
- if (pacl != NULL)
- {
- /*
- * determine the size of the ACL info.
- */
-
- debug3("GetAclInformation()..");
-
- FAIL(GetAclInformation(pacl, (LPVOID)&aclSizeInfo,
- sizeof(ACL_SIZE_INFORMATION),
- AclSizeInformation) == FALSE);
- }
-
- /*
- * Compute the size of the new acl.
- */
-
- dwNewAclSize = aclSizeInfo.AclBytesInUse;
-
- if (mode == ADD_RIGHT)
- {
- dwNewAclSize = dwNewAclSize + sizeof(ACCESS_ALLOWED_ACE)
- + GetLengthSid(psid) - sizeof(DWORD);
- }
- else
- {
- dwNewAclSize = dwNewAclSize - sizeof(ACCESS_ALLOWED_ACE)
- - GetLengthSid(psid) + sizeof(DWORD);
- }
-
- /*
- * Allocate buffer for the new acl.
- */
-
- pNewAcl = (PACL) HeapAlloc(procHeap,
- HEAP_ZERO_MEMORY, dwNewAclSize);
-
- FAIL(pNewAcl == NULL);
-
- /*
- * Initialize the new acl.
- */
-
- debug3("InitializeAcl()..");
-
- FAIL(InitializeAcl(pNewAcl, dwNewAclSize, ACL_REVISION) == FALSE);
-
- /*
- * If DACL is present, copy it to a new DACL.
- */
-
- if (bDaclPresent) // only copy if DACL was present
- {
- /*
- * Copy the ACEs to our new ACL.
- */
-
- if (aclSizeInfo.AceCount)
- {
-
- for (i=0; i < aclSizeInfo.AceCount; i++)
- {
- /*
- * Get next ACE from old ACL.
- */
-
- FAIL(GetAce(pacl, i, &pTempAce) == FALSE);
-
- /*
- * Add the ACE to the new ACL.
- *
- * We copy all original list for RIGHT_ADD mode and
- * skip ACE with given input SID in RIGHT_REMOVE mode.
- */
-
- if (mode == ADD_RIGHT || EqualSid(psid, &pTempAce -> SidStart) == 0)
- {
- FAIL(AddAce(pNewAcl, ACL_REVISION, MAXDWORD, pTempAce,
- ((PACE_HEADER) pTempAce) -> AceSize) == FALSE);
- }
- }
- }
- }
-
- if (mode == ADD_RIGHT)
- {
- /*
- * Add one additional ace to the dacl.
- */
-
- debug3("AccessAllowedAce()...");
-
- FAIL(AddAccessAllowedAce(pNewAcl, ACL_REVISION,
- DESKTOP_ALL, psid) == FALSE);
- }
-
- /*
- * Set new dacl to the new security descriptor.
- */
-
- debug3("AddSecurityDescriptiorDacl()..");
-
- FAIL(SetSecurityDescriptorDacl(psdNew, TRUE, pNewAcl, FALSE) == FALSE);
-
- /*
- * Set the new security descriptor for the desktop object.
- */
-
- debug3("SetUserObjectSecurity()..");
-
- FAIL(SetUserObjectSecurity(hdesk, &si, psdNew) == FALSE);
-
- /*
- * Indicate success.
- */
-
- bSuccess = TRUE;
-
-fail:
-
- /*
- * Free buffers.
- */
-
- debug3("Freeing buffers...");
-
- if (pNewAcl != NULL)
- {
- HeapFree(procHeap, 0, (LPVOID) pNewAcl);
- }
-
- if (psd != NULL)
- {
- HeapFree(procHeap, 0, (LPVOID) psd);
- }
-
- if (psdNew != NULL)
- {
- HeapFree(procHeap, 0, (LPVOID) psdNew);
- }
-
- debug3("<- AddTheAceDesktop()...");
-
- return bSuccess;
-}
-
-void RemoveSid(PSID *psid)
-{
- HeapFree(GetProcessHeap(), 0, (LPVOID) *psid);
-}
-
-/*
- * Gives user rights to use 'WinStation0' and 'default' desktop.
- *
- * psid - pointer to SID for acount SID (IN)
- * mode - 1 for add, 0 for remove (IN)
- *
- * RETURNS: 0 if OK.
- */
-
-int ModifyRightsToDesktopBySid(PSID psid, int mode)
-{
- debug3("-> ModifyRightsToDesktopBySid(mode = %d)...", mode);
-
- HDESK hdesk = NULL;
-
- HWINSTA hwinsta = NULL;
-
- int exitCode = -1;
-
- /*
- * obtain a handle to the interactive windowstation.
- */
-
- debug3("OpenWindowStation()...");
-
- hwinsta = OpenWindowStation("winsta0", FALSE, READ_CONTROL | WRITE_DAC);
-
- FAIL(hwinsta == NULL);
-
- debug3("GetProcessWindowStation()...");
-
- HWINSTA hwinstaold = GetProcessWindowStation();
-
- /*
- * Set the windowstation to winsta0 so that you obtain the
- * correct default desktop.
- */
-
- debug3("SetProcessWindowStation()...");
-
- FAIL(!SetProcessWindowStation(hwinsta));
-
- /*
- * Obtain a handle to the "default" desktop.
- */
-
- debug3("OpenDesktop()...");
-
- hdesk = OpenDesktop("default", 0, FALSE, READ_CONTROL | WRITE_DAC |
- DESKTOP_WRITEOBJECTS | DESKTOP_READOBJECTS);
-
- FAIL(hdesk == NULL);
-
- /*
- * Add the user to interactive windowstation.
- */
-
- debug3("ModifyTheAceWindowStation()...");
-
- FAIL(!ModifyTheAceWindowStation(hwinsta, psid, mode));
-
- /*
- * Add user to "default" desktop.
- */
-
- debug3("AddTheAceDesktop()...");
-
- FAIL(!ModifyTheAceDesktop(hdesk, psid, mode));
-
- exitCode = 0;
-
-fail:
-
- /*
- * Close the handles to the interactive windowstation and desktop.
- */
-
- debug3("CloseWindowStation()...");
-
- if (hwinsta)
- {
- CloseWindowStation(hwinsta);
- }
-
- debug3("CloseDesktop()...");
-
- if (hdesk)
- {
- CloseDesktop(hdesk);
- }
-
- debug3("<- ModifyRightsToDesktopBySid()...");
-
- return exitCode;
-}
-
-/*
- * Gives or removes user rights to use 'WinStation0' and 'default' desktop.
- *
- * hToken - logged user's token (IN)
- * mode - 1 for add, 0 for remove (IN)
- *
- * RETURNS: 0 if OK.
- */
-
-int ModifyRightsToDesktop(HANDLE hToken, int mode)
-{
- debug2("-> ModifyRightsToDesktop(mode = %d)...", mode);
-
- PSID psid = NULL;
-
- int exitCode = -1;
-
- /*
- * Obtain the logon sid of the user fester.
- */
-
- debug3("ObtainSid()...");
-
- FAIL(!ObtainSid(hToken, &psid));
-
- FAIL(ModifyRightsToDesktopBySid(psid, mode));
-
- if (psid)
- {
- RemoveSid(&psid);
- }
-
- exitCode = 0;
-
-fail:
-
- debug2("<- ModifyRightsToDesktop()...");
-
- return exitCode;
-}
diff --git a/contrib/win32/win32compat/deskright.h b/contrib/win32/win32compat/deskright.h
deleted file mode 100644
index 8cfb167..0000000
--- a/contrib/win32/win32compat/deskright.h
+++ /dev/null
@@ -1,64 +0,0 @@
-/*
- * Author: NoMachine
- *
- * Copyright (c) 2009, 2011 NoMachine
- * All rights reserved
- *
- * Support functions and system calls' replacements needed to let the
- * software run on Win32 based operating systems.
- *
- * 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 ``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 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.
- */
-
-#ifndef DeskRight_H
-#define DeskRight_H
-
-#include "includes.h"
-#include "Debug.h"
-
-#include
-
-#define ADD_RIGHT 1
-#define REMOVE_RIGHT 0
-
-#define WINSTA_ALL (WINSTA_ACCESSCLIPBOARD | WINSTA_ACCESSGLOBALATOMS | \
- WINSTA_CREATEDESKTOP | WINSTA_ENUMDESKTOPS | \
- WINSTA_ENUMERATE | WINSTA_EXITWINDOWS | \
- WINSTA_READATTRIBUTES | WINSTA_READSCREEN | \
- WINSTA_WRITEATTRIBUTES | DELETE | \
- READ_CONTROL | WRITE_DAC | \
- WRITE_OWNER)
-
-#define DESKTOP_ALL (DESKTOP_CREATEMENU | DESKTOP_CREATEWINDOW | \
- DESKTOP_ENUMERATE | DESKTOP_HOOKCONTROL | \
- DESKTOP_JOURNALPLAYBACK | DESKTOP_JOURNALRECORD | \
- DESKTOP_READOBJECTS | DESKTOP_SWITCHDESKTOP | \
- DESKTOP_WRITEOBJECTS | DELETE | \
- READ_CONTROL | WRITE_DAC | \
- WRITE_OWNER)
-
-#define GENERIC_ACCESS (GENERIC_READ | GENERIC_WRITE | GENERIC_EXECUTE | GENERIC_ALL)
-
-int ModifyRightsToDesktop(HANDLE hToken, int mode);
-int ModifyRightsToDesktopBySid(PSID psid, int mode);
-
-#endif
diff --git a/contrib/win32/win32compat/gettimeofday.c b/contrib/win32/win32compat/gettimeofday.c
deleted file mode 100644
index 5050bca..0000000
--- a/contrib/win32/win32compat/gettimeofday.c
+++ /dev/null
@@ -1,63 +0,0 @@
-/*
- * Author: NoMachine
- *
- * Copyright (c) 2009, 2010 NoMachine
- * All rights reserved
- *
- * Support functions and system calls' replacements needed to let the
- * software run on Win32 based operating systems.
- *
- * 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 ``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 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.
- */
-
-#include "includes.h"
-
-#include
-
-/* Difference in us between UNIX Epoch and Win32 Epoch */
-#define EPOCH_DELTA_US 11644473600000000ULL
-
-int
-gettimeofday (struct timeval *tv, void *tz)
-{
- union
- {
- FILETIME ft;
- unsigned long long ns;
- } timehelper;
- unsigned long long us;
-
- /* Fetch time since Jan 1, 1601 in 100ns increments */
- GetSystemTimeAsFileTime(&timehelper.ft);
-
- /* Convert to microseconds from 100 ns units */
- us = timehelper.ns / 10;
-
- /* Remove the epoch difference */
- us -= EPOCH_DELTA_US;
-
- /* Stuff result into the timeval */
- tv->tv_sec = (long) (us / 1000000ULL);
- tv->tv_usec = (long) (us % 1000000ULL);
-
- return 0;
-}
diff --git a/contrib/win32/win32compat/homedirhelp.c b/contrib/win32/win32compat/homedirhelp.c
deleted file mode 100644
index 204839a..0000000
--- a/contrib/win32/win32compat/homedirhelp.c
+++ /dev/null
@@ -1,165 +0,0 @@
-/*
- * Author: NoMachine
- *
- * Copyright (c) 2009, 2011 NoMachine
- * All rights reserved
- *
- * Support functions and system calls' replacements needed to let the
- * software run on Win32 based operating systems.
- *
- * 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 ``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 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.
- */
-
-#include
-#include
-#include
-#include
-#include
-#include
-
-#include "win32auth.h"
-
-wchar_t HomeDirLsaW[MAX_PATH] = {L'\0'};
-
-wchar_t *gethomedir_w(char *pUserName, char *pDomainName)
-{
- HANDLE token;
-
- PROFILEINFOW profileInfo;
-
- wchar_t szPathW[MAX_PATH] = {0};
-
- wchar_t pUserName_w[UNLEN + 1] = {0};
-
- static wchar_t username_w[UNLEN + 1] = {0};
-
- DWORD usernamelen = UNLEN + 1;
-
- wchar_t pDomainName_w[UNLEN + 1] = {0};
-
- wchar_t *userprofile_w;
-
- /*
- * If there is home dir from lsa return it.
- */
-
- if (HomeDirLsaW[0] != L'\0')
- {
- debug("Using LSA HomeDirW.");
-
- return _wcsdup(HomeDirLsaW);
- }
-
- szPathW[0] = '\0';
-
- if (MultiByteToWideChar(CP_UTF8, 0, pUserName, -1, pUserName_w, UNLEN) == 0)
- {
- return NULL;
- }
-
- if (pDomainName &&
- MultiByteToWideChar(CP_UTF8, 0, pDomainName,
- -1, pDomainName_w, UNLEN) == 0)
- {
- return NULL;
- }
-
- debug3("gethomedir: pUserName [%s]", pUserName);
-
- GetUserNameW(username_w, &usernamelen);
-
- debug3("gethomedir: username [%ls]", username_w);
-
- if (wcscmp(pUserName_w, username_w) == 0)
- {
- /*
- * User query his own home dir, we can take it from env.
- */
-
- debug3("gethomedir: getenv");
-
- userprofile_w = _wgetenv(L"USERPROFILE");
-
- if (userprofile_w)
- {
- debug3("gethomedir: userprofile [%ls]", userprofile_w);
-
- /*
- * We have a %USERPROFILE% and we can return it
- */
-
- return _wcsdup(userprofile_w);
- }
-
- /*
- * Env not set, let's try to take it from token
- */
- }
-
- /*
- * If all above fail try to create user token manually
- * and get homedir using this token.
- */
-
-
- return NULL;
-
-}
-
-/*
- * Retreave path, where current binary live.
- *
- * buffer - buffer, where path store (OUT)
- * bufSize - size of output buffer (IN)
- *
- * RETURNS: 0 if OK.
- */
-
-int GetRootBaseDir(char *buffer, int bufSize)
-{
- int exitCode = -1;
-
- char *end = NULL;
- char *tmp = buffer;
-
- FAIL(buffer == NULL);
-
- FAIL(GetModuleFileName(NULL, buffer, bufSize) == FALSE);
-
- FAIL(PathRemoveFileSpec(buffer) == FALSE);
-
- while ((tmp = strstr(tmp, "\\bin")))
- {
- end = tmp;
- tmp++;
- }
-
- FAIL(end == NULL);
-
- *end = 0;
-
- exitCode = 0;
-
-fail:
-
- return exitCode;
-}
diff --git a/contrib/win32/win32compat/inc/sys/time.h b/contrib/win32/win32compat/inc/sys/time.h
index 986afc2..67d83ed 100644
--- a/contrib/win32/win32compat/inc/sys/time.h
+++ b/contrib/win32/win32compat/inc/sys/time.h
@@ -1,4 +1,5 @@
#include
#define utimbuf _utimbuf
-int usleep(unsigned int);
\ No newline at end of file
+int usleep(unsigned int);
+int gettimeofday(struct timeval *tv, void *tz);
diff --git a/contrib/win32/win32compat/inc/unistd.h b/contrib/win32/win32compat/inc/unistd.h
index d526aa8..7af6a13 100644
--- a/contrib/win32/win32compat/inc/unistd.h
+++ b/contrib/win32/win32compat/inc/unistd.h
@@ -7,25 +7,15 @@
#define COMPAT_UNISTD_H 1
#include "w32posix.h"
-//
-//#define pipe(a) w32_pipe((a))
-//#define open(a,b,...) w32_open((a), (b), __VA_ARGS__)
-//#define read(a,b,c) w32_read((a), (b), (c))
-//#define write(a,b,c) w32_write((a), (b), (c))
-#define isatty(a) w32_isatty((a))
-//#define close(a) w32_close((a))
-//#define dup(a) w32_dup((a))
-//#define dup2(a,b) w32_dup2((a), (b))
-//
-//#define sleep(sec) Sleep(1000 * sec)
-//#define alarm(a) w32_alarm((a))
#define pipe w32_pipe
#define open w32_open
#define read w32_read
#define write w32_write
#define writev w32_writev
-//#define isatty w32_isatty
+/* can't do this #define isatty w32_isatty
+* as there is a variable in code named isatty*/
+#define isatty(a) w32_isatty((a))
#define close w32_close
#define dup w32_dup
#define dup2 w32_dup2
@@ -39,6 +29,8 @@
#define fopen w32_fopen_utf8
+int daemon(int nochdir, int noclose);
+
/* Compatibility header to avoid lots of #ifdefs in includes.h on Win32 */
#include
@@ -52,8 +44,6 @@ size_t strcasecmp(const char *left, const char *right);
size_t strncasecmp(const char *left, const char *right, size_t n);
#endif
-int gettimeofday(struct timeval *tv, void *tz);
-
#define popen _popen
#define pclose _pclose
diff --git a/contrib/win32/win32compat/misc.c b/contrib/win32/win32compat/misc.c
index 53f1fc6..2970e7b 100644
--- a/contrib/win32/win32compat/misc.c
+++ b/contrib/win32/win32compat/misc.c
@@ -2,6 +2,7 @@
#include
#include "inc\defs.h"
#include "inc\sys\statvfs.h"
+#include "inc\sys\time.h"
int usleep(unsigned int useconds)
{
@@ -9,6 +10,39 @@ int usleep(unsigned int useconds)
return 1;
}
+/* Difference in us between UNIX Epoch and Win32 Epoch */
+#define EPOCH_DELTA_US 11644473600000000ULL
+
+/* This routine is contributed by * Author: NoMachine
+* Copyright (c) 2009, 2010 NoMachine
+* All rights reserved
+*/
+int
+gettimeofday(struct timeval *tv, void *tz)
+{
+ union
+ {
+ FILETIME ft;
+ unsigned long long ns;
+ } timehelper;
+ unsigned long long us;
+
+ /* Fetch time since Jan 1, 1601 in 100ns increments */
+ GetSystemTimeAsFileTime(&timehelper.ft);
+
+ /* Convert to microseconds from 100 ns units */
+ us = timehelper.ns / 10;
+
+ /* Remove the epoch difference */
+ us -= EPOCH_DELTA_US;
+
+ /* Stuff result into the timeval */
+ tv->tv_sec = (long)(us / 1000000ULL);
+ tv->tv_usec = (long)(us % 1000000ULL);
+
+ return 0;
+}
+
void
explicit_bzero(void *b, size_t len) {
SecureZeroMemory(b, len);
@@ -164,4 +198,10 @@ char* w32_programdir() {
return s_programdir;
+}
+
+int daemon(int nochdir, int noclose)
+{
+ /* this should never be invoked from Windows code*/
+ DebugBreak();
}
\ No newline at end of file