Daemon needs to get user name

Years ago my daemon was since then using SCDynamicStoreCopyConsoleUser() function and now it longer works.

Basically the daemon needs to know the user name of who is using the system. If I restart the daemon,after the login, it gets the user name.

I tried run a shell command via my daemon ("id -F") and look likes it still picks the root as user name.

So, is there a way to get the current user name using Swift? ProcessInfo.userName fails too

Basically the daemon needs to know the user name of who is using the system.

Why?

I’m asking because there’s no easy answer to that question, and that’s been true since at least macOS 10.3. One obvious issue is SSH, where multiple users can be using the system over SSH. However, even if you limit yourself to GUI login sessions, it’s possible for multiple users to be using the system via fast user switching and screen sharing.

Once I know more about what you’re using that information for, I can help guide you in the right direction. For an example of that process, and why this stuff is so complex, see the discussion we’re having on this thread.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

Daemon needs to get user name
 
 
Q