2023-01-25 16:47:25 +00:00
|
|
|
/***
|
|
|
|
Copyright (C) 2023 J Reece Wilson (a/k/a "Reece"). All rights reserved.
|
|
|
|
|
|
|
|
File: FileTrust.NT.cpp
|
|
|
|
Date: 2023-1-25
|
|
|
|
Author: Reece
|
|
|
|
***/
|
|
|
|
#include <Source/RuntimeInternal.hpp>
|
|
|
|
#include "FS.hpp"
|
|
|
|
#include "FileTrust.NT.hpp"
|
|
|
|
|
|
|
|
namespace Aurora::IO::FS
|
|
|
|
{
|
|
|
|
AUKN_SYM bool BlockFile(const AuString &path)
|
|
|
|
{
|
|
|
|
return AuFS::WriteFile(path + ":Zone.Identifier", "[ZoneTransfer]\r\nZoneId=3\r\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
AUKN_SYM bool UnblockFile(const AuString &path)
|
|
|
|
{
|
|
|
|
return AuFS::WriteFile(path + ":Zone.Identifier", "[ZoneTransfer]\r\nZoneId=0\r\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
AUKN_SYM bool TrustFile(const AuString &path)
|
|
|
|
{
|
|
|
|
AuString idc;
|
|
|
|
|
|
|
|
auto uri = path + ":Zone.Identifier";
|
2023-08-29 18:43:45 +00:00
|
|
|
|
|
|
|
if (AuFS::FileExists(uri))
|
2023-01-25 16:47:25 +00:00
|
|
|
{
|
2023-08-29 18:43:45 +00:00
|
|
|
if (AuFS::ReadString(uri, idc))
|
|
|
|
{
|
|
|
|
return AuFS::Remove(uri);
|
|
|
|
}
|
2023-01-25 16:47:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
2023-08-29 18:43:45 +00:00
|
|
|
|
|
|
|
AUKN_SYM bool IsFileBlocked(const AuString &path)
|
|
|
|
{
|
|
|
|
AuString content;
|
|
|
|
|
|
|
|
auto uri = path + ":Zone.Identifier";
|
|
|
|
if (!AuFS::FileExists(uri))
|
|
|
|
{
|
|
|
|
return !AuFS::FileExists(path);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!AuFS::ReadString(uri, content))
|
|
|
|
{
|
|
|
|
return !AuFS::FileExists(path);
|
|
|
|
}
|
|
|
|
|
2023-09-17 12:57:58 +00:00
|
|
|
return (!gRuntimeConfig.fio.bIsIntranetTrusted && AuStringContains(content, "ZoneId=1\r\n")) || // intranet
|
2023-08-29 18:43:45 +00:00
|
|
|
AuStringContains(content, "ZoneId=3\r\n") || // internet
|
|
|
|
AuStringContains(content, "ZoneId=4\r\n"); // untrusted
|
|
|
|
}
|
|
|
|
|
|
|
|
AUKN_SYM bool IsFileTrusted(const AuString &path)
|
|
|
|
{
|
|
|
|
AuString content;
|
|
|
|
|
|
|
|
auto uri = path + ":Zone.Identifier";
|
|
|
|
|
|
|
|
if (!AuFS::FileExists(uri))
|
|
|
|
{
|
|
|
|
return AuFS::FileExists(path);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!AuFS::ReadString(uri, content))
|
|
|
|
{
|
|
|
|
return AuFS::FileExists(path);
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
2023-01-25 16:47:25 +00:00
|
|
|
}
|