How set snap app as default user shell

Hi,

I implement a Command Line Shell in my snap app ( mysnap.cli ), then I set this cli shell as new exterauser’s default shell in /var/lib/extrausers/passwd:

colin:x:1001:1001:colin,:/home/colin:/snap/bin/mysnap.cli

But when I login by this user, ubuntu core report snap command error, can you give me some advices?

---------------- log ----------------

Welcome to Ubuntu Core 16 (GNU/Linux 4.4.0-164-generic x86_64)

The programs included with the Ubuntu system are free software;
the exact distribution terms for each program are described in the
individual files in /usr/share/doc/*/copyright.

Ubuntu comes with ABSOLUTELY NO WARRANTY, to the extent permitted by
applicable law.

This Ubuntu Core machine is a tiny, transactional edition of Ubuntu,
designed for appliances, firmware and fixed-function VMs.

If all the software you care about is available as snaps, you are in
the right place. If not, you will be more comfortable with classic
deb-based Ubuntu Server or Desktop, where you can mix snaps with
traditional debs. It’s a brave new world here in Ubuntu Core!

Please see ‘snap --help’ for app installation and updates.
The snap command lets you install, configure, refresh and remove snaps.
Snaps are packages that work across many different Linux distributions,
enabling secure delivery and operation of the latest apps and utilities.

Usage: snap […]

Commands can be classified as follows:

     Basics: find, info, install, list, remove
    ...more: refresh, revert, switch, disable, enable
    History: changes, tasks, abort, watch
    Daemons: services, start, stop, restart, logs
   Commands: alias, aliases, unalias, prefer

Configuration: get, set, unset, wait
Account: login, logout, whoami
Permissions: connections, interface, connect, disconnect
Snapshots: saved, save, check-snapshot, restore, forget
Other: version, warnings, okay, ack, known, create-cohort
Development: run, pack, try, download, prepare-image

For more information about a command, run 'snap help '.
For a short summary of all commands, run ‘snap help --all’.

Can you paste the error message that you receive? Your log appears to not include it…

Hi Daniel,

below is the login error log. After I setted the default shell to mysnap.cli, then I login with this user, below log happens.

Below log means that snap command return wrong. I can understand that because mysnap.cli just a soft link to snap, so if I set user default shell to mysnap.cli, it will actually excute the command “snap”.

colinliao@localhost:~$ which mysnap.cli
/snap/bin/mysnap.cli
colinliao@localhost:~$ ls -l /snap/bin/mysnap.cli
lrwxrwxrwx 1 root root 13 Sep 23 01:59 /snap/bin/mysnap.cli -> /usr/bin/snap

Any idea about this?

---------------- log ----------------

Welcome to Ubuntu Core 16 (GNU/Linux 4.4.0-164-generic x86_64)

The programs included with the Ubuntu system are free software;
the exact distribution terms for each program are described in the
individual files in /usr/share/doc/*/copyright.

Ubuntu comes with ABSOLUTELY NO WARRANTY, to the extent permitted by
applicable law.

Ubuntu Core: https://www.ubuntu.com/core
Community: https://forum.snapcraft.io
Snaps: https://snapcraft.io
This Ubuntu Core machine is a tiny, transactional edition of Ubuntu,
designed for appliances, firmware and fixed-function VMs.

If all the software you care about is available as snaps, you are in
the right place. If not, you will be more comfortable with classic
deb-based Ubuntu Server or Desktop, where you can mix snaps with
traditional debs. It’s a brave new world here in Ubuntu Core!

Please see ‘snap --help’ for app installation and updates.
The snap command lets you install, configure, refresh and remove snaps.
Snaps are packages that work across many different Linux distributions,
enabling secure delivery and operation of the latest apps and utilities.

Usage: snap […]

Commands can be classified as follows:

 Basics: find, info, install, list, remove
...more: refresh, revert, switch, disable, enable
History: changes, tasks, abort, watch
Daemons: services, start, stop, restart, logs

Commands: alias, aliases, unalias, prefer
Configuration: get, set, unset, wait
Account: login, logout, whoami
Permissions: connections, interface, connect, disconnect
Snapshots: saved, save, check-snapshot, restore, forget
Other: version, warnings, okay, ack, known, create-cohort
Development: run, pack, try, download, prepare-image

For more information about a command, run 'snap help '.
For a short summary of all commands, run ‘snap help --all’.

i doubt anyone ever tried to use a snap application as login shell before, it looks like the snap command can not really determine the command it wants to actually run from its own invocation …

technically this is a snap/snapd bug, practically what you are doing is not actually supported in Ubuntu Core itself though (hacking the extrausers files is not really something we support or encourage … while it is fine for development, there will be no way to integrate such a hack into a properly built production image)

The symlinks to /usr/bin/snap work by the snap command checking the value of argv[0]. If it matches a command provided by an installed snap, then it behaves as if you ran snap run cmd.

This is breaking down because login is explicitly modifying argv[0] from what you’d normally expect:

So presumably things would work if snap ignored an initial dash in argv[0] when performing its check?

Actually, CLI command shell is a common feature for embbed device, not a hack feature.

Any workaround for this function?

great thanks!

Is it possible to run the CLI application in a script file, and then set the script file as the default shell?

I am also interested in a solution. I wanted to set Powershell as my login shell and snaps are the easiest way to install Powershell and keep them updated.