From c25f36cd53998f12c99ac41ee7e016679aada779 Mon Sep 17 00:00:00 2001 From: Jonas 'Sortie' Termansen Date: Wed, 17 Feb 2021 23:08:19 +0100 Subject: [PATCH] Fix faccessat(2) not supporting root access. --- kernel/io.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/kernel/io.cpp b/kernel/io.cpp index aeb74518..229ec307 100644 --- a/kernel/io.cpp +++ b/kernel/io.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011-2017 Jonas 'Sortie' Termansen. + * Copyright (c) 2011-2017, 2021 Jonas 'Sortie' Termansen. * * Permission to use, copy, modify, and distribute this software for any * purpose with or without fee is hereby granted, provided that the above @@ -216,7 +216,9 @@ int sys_faccessat(int dirfd, const char* path, int mode, int flags) if ( desc->stat(&kctx, &st) < 0 ) return -1; mode_t mask; - if ( kctx.uid == st.st_uid ) + if ( kctx.uid == 0 ) + mask = 0777; + else if ( kctx.uid == st.st_uid ) mask = 0700; else if ( kctx.gid == st.st_gid ) mask = 0070;