loginitems icon indicating copy to clipboard operation
loginitems copied to clipboard

`loginitems` Unusable Over `su` Session

Open RandomDSdevel opened this issue 7 years ago • 5 comments

When I ran loginitems -l under su -l $OTHER_REDACTED_USER, I got the following error from osascript:

/usr/local/bin/loginitems-ls:68:72: execution error: An error of type -10810 has occurred. (-10810)

I suspect that this probably has to do with the fact that su does something funny and creates an execution environment that loginitems wasn't expecting. I don't recognize and couldn't find any documentation on that particular error code, though, so good luck if you decide to chase down the root cause of this problem. In the meantime, I'll just switch users to use loginitems under other accounts.

RandomDSdevel avatar Dec 21 '16 21:12 RandomDSdevel

It's an "unknown error", apparently.

According to this StackOverflow thread it might be related to a leaky third-party application.

Is it consistently reproducible, or immediately after restarting?

OJFord avatar Feb 04 '17 12:02 OJFord

It's also possible that the AppleScript interface to a user's login items can't be used under su, I don't have any other user accounts to test with, but it wouldn't surprise me.

OJFord avatar Feb 04 '17 12:02 OJFord

It's an "unknown error", apparently.

According to this StackOverflow thread it might be related to a leaky third-party application.

Is it consistently reproducible, or immediately after restarting?

I haven't tried for a while, but, IIRC, the problem was consistently reproducible when I last did. I haven't attempted to see if restarting would help, either, but, for all we know, it might. I can try again if you want, though a dummy user account isn't all that hard to create, is it? (Recovering the accompanying user ID after the fact might turn out to be somewhat problematic, though, so I can understand your hesitancy to go through with doing that, as you might want to reuse ID 502 for another, different new user in the future.)


It's also possible that the AppleScript interface to a user's login items can't be used under su, I don't have any other user accounts to test with, but it wouldn't surprise me.

Yeah, I also suspect that the error might have to do with the fact that su only launches a TTY session and not a GUI one even when passed the -l option, as launchd or one of its child processes might only launch the osascript daemon under the latter kind of login session, so this wouldn't exactly surprise me, either. Still, it would be cool if there were a way around that…

RandomDSdevel avatar Feb 04 '17 17:02 RandomDSdevel

haven't attempted to see if restarting would help, either, but, for all we know, it might.

Indeed.

a dummy user account isn't all that hard to create, is it?

It's not a use-case I'm interested in using personally, and this repository contains all the AppleScript I have ever written, so I'm afraid I don't really have the time or inclination to explore this further.

That said,

Still, it would be cool if there were a way around that…

PRs are, genuinely, welcome. 🙂

OJFord avatar Feb 04 '17 17:02 OJFord

Unfortunately, you've still got me beat when it comes to how much AppleScript you've written in your life. I'll put it on my to-do list to look into, but I can't promise anything, as I'd probably have to dive rather deep into the documentation to figure anything out in this area.

RandomDSdevel avatar Feb 04 '17 17:02 RandomDSdevel