Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add sys_access and sys_faccessat #841

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

Conversation

grief8
Copy link
Contributor

@grief8 grief8 commented May 14, 2024

This PR adds sys_access and sys_faccessat system call implementations to our kernel, enabling user space applications to perform standard permission checks on files.

Key Changes:

  • Implemented the sys_access system call, which checks for read/write/execute permissions on a specified file path based on the calling process's credentials.
  • Implemented the sys_faccessat system call, which extends the functionality of sys_access with additional flags for relative path resolution and behavior control with respect to symbolic links.

Testing:

  • access_test in syscall_test is added.

@tatetian
Copy link
Contributor

@liqinggd Could you review this PR? Thanks!

struct FaccessatFlags: i32 {
const AT_EACCESS = 0x200;
const AT_SYMLINK_NOFOLLOW = 0x100;
const AT_EMPTY_PATH = 0x1000;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should not support the AT_EMPTY_PATH flag according to https://man7.org/linux/man-pages/man2/access.2.html

       flags is constructed by ORing together zero or more of the
       following values:

       AT_EACCESS
              Perform access checks using the effective user and group
              IDs.  By default, faccessat() uses the real IDs (like
              access()).

       AT_SYMLINK_NOFOLLOW
              If pathname is a symbolic link, do not dereference it:
              instead return information about the link itself.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is another implementation detail on Linux. I don't know why they keep AT_EMPTY_PATH, so I just follow their design in case that some internal features rely on it.

@grief8 grief8 marked this pull request as draft June 7, 2024 11:32
@grief8 grief8 marked this pull request as ready for review June 7, 2024 12:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants