Why the current user does not have access rights / var/log under Mac

In

MacOS, the current user is the user but does not have access to / var/log/xxx.log in the terminal.

user1:bin soul$ ls -la /var/ | grep log
drwxr-xr-x  56 root          wheel         1904  2 26 21:14 log
user1:bin soul$ ./searchd -c ../etc/sphinx.conf
Sphinx 3.1.1 (commit 612d99f)
Copyright (c) 2001-2018, Andrew Aksyonoff
Copyright (c) 2008-2016, Sphinx Technologies Inc (http://sphinxsearch.com)

using config file "../etc/sphinx.conf"...
FATAL: failed to open log file "/var/log/searchd.log": Permission denied
shutdown complete
user1:bin soul$ whoami
soul

1) Why does / var/log have no access
2) A command to test whether a user has access to a directory or file

Jul.12,2022

  1. what is the flag of your open function? Confirm that it is a read-only O_RDONLY? Other permissions are not allowed, but bin soul does not have write permissions
  2. command? Don't you just check the drwxr-xr-x in front of your ls?
    if it's code, you can use stat. For more information on how to use it, please see man 2 stat, where there are many flag
  3. .
Menu