diff --git a/src/austin.c b/src/austin.c index a584243b..8ac66ce5 100644 --- a/src/austin.c +++ b/src/austin.c @@ -215,6 +215,15 @@ do_child_processes(py_proc_t * py_proc) { // ---------------------------------------------------------------------------- int main(int argc, char ** argv) { + +#if defined PL_MACOS + // On MacOS, we need to be root to use Austin. + if (geteuid() != 0) { + _msg(MPERM); + return EPROCPERM; + } +#endif + int retval = 0; py_proc_t * py_proc = NULL; int exec_arg = parse_args(argc, argv); diff --git a/test/test_cli.py b/test/test_cli.py index 733ceded..c329745f 100644 --- a/test/test_cli.py +++ b/test/test_cli.py @@ -70,3 +70,15 @@ def test_cli_permissions(): result = austin("-i", "1ms", "-p", str(p.pid)) assert result.returncode == 37, result.stderr assert "Insufficient permissions" in result.stderr, result.stderr + + +@pytest.mark.skipif( + platform.system() != "Darwin", + reason="Only Darwing requires sudo in all cases", +) +def test_cli_permissions_darwin(): + result = austin( + "-i", "1ms", "python3.10", "-c", "'from time import sleep; sleep(1)'" + ) + assert result.returncode == 37, result.stderr + assert "Insufficient permissions" not in result.stderr, result.stderr