jstaf / onedriver

A native Linux filesystem for Microsoft OneDrive
GNU General Public License v3.0
1.86k stars 91 forks source link

Only display a Microsoft Login to the user #363

Closed Lenni-builder closed 7 months ago

Lenni-builder commented 8 months ago

Is there any way to run OneDriver from the Terminal so the only thing displayed to the end user is a Microsoft login page? That would be needed to have it setup for school computers where the local user account is reset every time you log in.

Lenni-builder commented 8 months ago

What I basically need is a Microsoft login after you log into the local user account. After you log in to your MS account it should automatically show your OneDrive files in a folder like ~/OneDrive.

jstaf commented 8 months ago

Yeah, just run onedriver ~/OneDrive and it will pop up with a login page and start the app.

If you want this to be automatic (have the user login on startup no matter what for all users), you'll need to create a copy of the the unit file and globally enable the systemd user service for the new unit. Basically systemd is what actually launches all of the mountpoints through the GUI, so you can do the same thing with a default mountpoint if you are clever with the unit file.

# creat copy of unit file to enable globally
cp /usr/lib/systemd/user/onedriver@.service /etc/systemd/user/onedriver-global@.service

# in /etc/systemd/user/onedriver-global@.service, change this:
# (ignore the #commented bits, I am just explaining what each line normally does...
# %f is the part between "onedriver@" and ".service" when coming up with the unit name)
ExecStart=/usr/bin/onedriver %f   # on unit start, mount onedrive at %f 

# to this:
ExecStart=/usr/bin/onedriver %h/%f  # on unit start, mount onedrive at ~/%f for each user

Then you can enable it globally for all users with systemctl enable --global onedriver-global@OneDrive.service to mount OneDrive by default at ~/OneDrive. I think this should work, but after some googling, user's won't be able to disable the unit normally, only mask it (hide it from systemd altogether): https://superuser.com/a/1358461

Disclaimer: I haven't actually tried any of this out.

If end users could list/mask/unmask the global units through the UI, this would be a nice feature to have for enterprise folks, especially when combined with https://github.com/jstaf/onedriver/issues/347 (a global configuration file to configure all the mountpoints globally), and https://github.com/jstaf/onedriver/issues/318 (so end users/admins can see mistakes with auth, like admins accidentally not allowing third-party apps).

Lenni-builder commented 8 months ago

@jstaf Thanks, that's already very helpful. I'd just run the command from a script I'd set as a startup application in Plasma. Just one question: Does the command output an exit code after successfully logging in?

jstaf commented 8 months ago

So if you want it to just authenticate and then exit, add -a... so onedriver -a ~/OneDrive would make it so that user's OneDrives show up in the GUI app, but not actually start the drive. Successful authentication ends with exit code 0 (and 1 on failure).

Otherwise onedriver ~/OneDrive stays running in the foreground until the user kills/unmounts it somehow. (If you want the drive to run as a daemon in the background, that's what the systemd user service is for. The GUI just literally starts/stops/enables the daemon.)

Lenni-builder commented 7 months ago

I think that's enough for me to figure it out. Thanks