Skip to content

Commit 0ab71b9

Browse files
authored
Narrow file permissions used when creating text files (#877) (#1020)
Use 0644 as log file permission instead of 06774 06774 adds some permissions which are unnecessary for log files. x77x makes the log files owner/group executable - the log files are text and shouldn't be executed. 6xxx means set user id + set group id, these bits are involved in permission elevation and are not relevant here. Switch to a permission 0644, which lets the owner write and others read. (cherry picked from commit a3e392e) Signed-off-by: Jeremi Piotrowski <[email protected]>
1 parent 4747415 commit 0ab71b9

File tree

3 files changed

+4
-4
lines changed

3 files changed

+4
-4
lines changed

src/adapters/mc/OsConfigResource.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,8 +80,8 @@ void __attribute__((destructor)) Destroy()
8080
CloseLog(&g_log);
8181

8282
// When the NRP is done, allow others read-only (no write, search or execute) access to the NRP logs
83-
SetFileAccess(LOG_FILE, 0, 0, 6774, NULL);
84-
SetFileAccess(ROLLED_LOG_FILE, 0, 0, 6774, NULL);
83+
SetFileAccess(LOG_FILE, 0, 0, 644, NULL);
84+
SetFileAccess(ROLLED_LOG_FILE, 0, 0, 644, NULL);
8585
}
8686

8787
static void LogOsConfigVersion(MI_Context* context)

src/common/commonutils/FileUtils.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -382,7 +382,7 @@ int RestrictFileAccessToCurrentAccountOnly(const char* fileName)
382382
// S_IXUSR (0100): Execute/search permission, owner
383383
// S_IXGRP (0010): Execute/search permission, group
384384

385-
return chmod(fileName, S_ISUID | S_ISGID | S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IXUSR | S_IXGRP);
385+
return chmod(fileName, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP);
386386
}
387387

388388
static bool IsATrueFileOrDirectory(bool directory, const char* name, void* log)

src/common/logging/Logging.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ bool IsFullLoggingEnabled()
4848

4949
static int RestrictAccessToRootOnly(const char* fileName)
5050
{
51-
return chmod(fileName, S_ISUID | S_ISGID | S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IXUSR | S_IXGRP);
51+
return chmod(fileName, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP);
5252
}
5353

5454
OSCONFIG_LOG_HANDLE OpenLog(const char* logFileName, const char* bakLogFileName)

0 commit comments

Comments
 (0)