fixing crashes, adding threadsafety and changing welcome.,php
This commit is contained in:
@@ -3,19 +3,28 @@
|
||||
#define _WIN32_WINNT 0x0500
|
||||
#pragma comment(lib, "advapi32.lib")
|
||||
#include "permissions.h"
|
||||
#include <mutex> // Include mutex for synchronization
|
||||
|
||||
// Mutex for synchronizing file operations
|
||||
std::mutex fileMutex;
|
||||
|
||||
/*
|
||||
1 create file (as admin)
|
||||
2 set file as read only (also as admin)
|
||||
file cannot be deleted or modified by anyone. admin can delete
|
||||
|
||||
*/
|
||||
|
||||
//mark as readonly
|
||||
int protect_file(char* path) {
|
||||
std::lock_guard<std::mutex> lock(fileMutex); // Lock the mutex
|
||||
return _chmod(path, _S_IREAD);
|
||||
}
|
||||
|
||||
//mark as readwrite
|
||||
int unprotect_file(char* path) {
|
||||
return _chmod(path, _S_IWRITE | _S_IREAD);
|
||||
std::lock_guard<std::mutex> lock(fileMutex); // Lock the mutex
|
||||
return _chmod(path, _S_IWRITE | _S_IREAD);
|
||||
}
|
||||
|
||||
//deny all access and only grant access to admins
|
||||
@@ -34,7 +43,7 @@ BOOL create_file_protection(SECURITY_ATTRIBUTES* pSA)
|
||||
TEXT("(D;OICI;GA;;;AN)") // Deny access to unauthenticated users
|
||||
//TEXT("(D;OICI;GA;;;AU)") // Deny access to authenticated users do not execute else not even admins have rights anymore :(
|
||||
TEXT("(A;OICI;GA;;;BA)"); // Allow full control to builtin administrators
|
||||
TEXT("(A;OICI;GA;;;AA)"); // Allow full control to normal administrators
|
||||
TEXT("(A;OICI;GA;;;AA)"); // Allow full control to normal administrators
|
||||
|
||||
|
||||
if (NULL == pSA)
|
||||
@@ -47,4 +56,4 @@ BOOL create_file_protection(SECURITY_ATTRIBUTES* pSA)
|
||||
NULL);
|
||||
}
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user