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

Fails over ssh #507

Open
1 task done
GentleHoneyLover opened this issue Jan 12, 2024 · 10 comments
Open
1 task done

Fails over ssh #507

GentleHoneyLover opened this issue Jan 12, 2024 · 10 comments

Comments

@GentleHoneyLover
Copy link

Your Environment

  • mas version: 1.8.6
  • macOS version (system_profiler SPSoftwareDataType -detailLevel mini): macOS 14.2.1 (23C71)

mas Install Method

  • brew install mas (homebrew-core)

Describe the Bug

I'm using mas on all of the machines in my household. I manage my family member's machines by ssh-ing into them and running mas list and mas upgrade to install updates. Everything works fine when I run mas commands locally. However, when run the same commands via an ssh session I get completely different output.

mas list run locally outputs:

1510445899  Meeter                (1.9.9)
896411742   Animal Typing - Lite  (3.22)
1446785996  Scratch 3             (3.29.1)
823766827   OneDrive              (23.221.1024)
1452453066  Hidden Bar            (1.8)
1543920362  Displaperture         (2.3)
462058435   Microsoft Excel       (16.80)
462054704   Microsoft Word        (16.80)
565963412   iSnow                 (3.0.7)
682658836   GarageBand            (10.4.10)
937984704   Amphetamine           (5.3.2)
462062816   Microsoft PowerPoint  (16.80)
1333542190  1Password 7           (7.9.11)

mas list run via ssh on the same machine outputs:

No installed apps found

Obviously, I cannot install MAS updates via ssh...

To Reproduce

Steps to reproduce the behavior:

  1. Run mas list locally
  2. Run mas list via an ssh session
  3. Command outputs are not the same. Output in the ssh session will list no apps installed. App update is not possible.

Expected Behavior

mas list and mas upgrade work the same way regardless of whether run locally or via ssh

@exomor
Copy link

exomor commented Jan 29, 2024

Hi,

I have the same problem. Does anybody have a solution?

Thanks

@rgoldberg
Copy link
Contributor

Are you running as the same macOS user as the person who uses each computer?

See the difference in output between running the following 2 commands on the same machine:

$ mas list
$ sudo mas list

The former is your current user so should output your installed MAS applications, the latter is root so should output Error: No installed apps found.

@GentleHoneyLover
Copy link
Author

@rgoldberg, thanks for this! Indeed — I am sshing under an admin account into my family members' machines to do updates. My family members have their own user accounts on their machines. However, if inside this ssh session I do

$ su user
$ mas list

I still get the same No installed apps found even though I switched to my family member's user.

However, if I do the same locally (open the terminal under my family member's user session and do

$ su admin
$ mas list

I get the list of all the installed apps.

So, locally, mas works under both users and remotely it doesn't work under any user :)

@rgoldberg
Copy link
Contributor

Can you try sudo mas list from both the user & admin accounts, both locally & remote?

I'm not well versed about macOS multiple user / admin account behavior in general or specifically for MAS applications.

I don't have any macs to SSH into.

I don't want to create extra users or start an SSH server on my machine as I'm trying to keep it clean. Sorry.

@GentleHoneyLover
Copy link
Author

@rgoldberg, sure:

Locally

  • under family member user, mas list returns an expected output and sudo mas list returns user is not in the sudoers file (which is correct)
  • under admin user, mas list returns an expected output and sudo mas list returns No installed apps found


Remotely

  • under family member user, mas list returns No installed apps found and sudo mas list returns user is not in the sudoers file (which is correct)
  • under admin user, both mas list and sudo mas list return No installed apps found

@rgoldberg
Copy link
Contributor

From what I remember from seeing some of the relevant code a while ago:

I think the list of installed apps is populated by some undocumented CommerceKit code. It's later filtered to ensure the apps are actually in /Applications on the file system, so please check if that folder's contents are the same over ssh as local. I assume they are (I don't know why Apple would try to hide any /Applications/*.app over ssh, but maybe they do something weird…).

I guess that CommerceKit relies on some services or permissions that just aren't started or enabled when a user sshes in as opposed to logging in with a full gui desktop. I don't, however, know for sure, so I'll investigate in a little while when I have some time.

Maybe you could manually start /enable such hypothetical services / permissions from your ssh login; you could either research the topic or try to find services from your gui logins that aren't running in your ssh logins.

@GentleHoneyLover
Copy link
Author

@rgoldberg, thanks!

I can report that the /Applications is the same regardless of how you login and with which user (which actually makes sense :))

@rgoldberg
Copy link
Contributor

Thanks for the confirmation that /Applications is consistent. It would have been weird if it weren't, but I didn't want to ignore a potential surprise.

@mas-cli mas-cli deleted a comment from xyzzy-plugh-plover Sep 10, 2024
@rgoldberg
Copy link
Contributor

@GentleHoneyLover I tried to step into the source of the installed software list CKSoftwareMap#allProducts() in the debugger, but it wouldn't let me.

Maybe you can get Xcode to step into the function (I normally don't program for Mac platforms or use Xcode, so I'm not amazingly conversant with any of it).

Since /Applications/ contains all the apps, the problem should be from the original Apple function rather than from the mas code that uses it.

If you can't find services / permissions to enable or another workaround, you could try using Apple Remote Desktop to remotely log in to the machines. I'd imagine that mas should work from Terminal that way.

@rgoldberg
Copy link
Contributor

rgoldberg commented Sep 13, 2024

@GentleHoneyLover Does the info from the following comment help?

#89 (comment)

@rgoldberg rgoldberg changed the title 🐛 [BUG] mas doesn't work via ssh Fails over ssh Sep 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants