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

Add sonic-launch-shell to invoke appropriate shell based upon user's … #14466

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

shdasari
Copy link
Contributor

@shdasari shdasari commented Mar 30, 2023

…privilege level.

Why I did it

fixes #11352.
Login to switch via RADIUS authentication fails due to missing sonic-launch-shell script that invokes appropriate shell for the user based upon privilege level.

How I did it

Added sonic-launch-shell script that checks the user's privilege level and loads the appropriate shell for the user.

Admin users will be presented the /bin/bash shell. Operator users (non-admin users) are presented sonic-cli.
Note that sonic-cli invocation currently fails as shown below. Until this is fixed, non-admin users will not get access to the switch.

:$ sonic-cli
Error: Unresolved PTYPE "MCLAG_KA_INTERVAL_RANGE" in PARAM "KA"
:
$

How to verify it

  1. Configure Radius Server with admin user.

  2. Configure aaa authentication on Sonic Switch
    config aaa authentication login radius local

  3. Config radius server on Sonic Switch
    config radius add {RadiusServerIP} -k {RadiusServerPassword}

  4. Try to connect by ssh to Sonic Switch with admin user credentials.

Which release branch to backport (provide reason below if selected)

  • 201811
  • 201911
  • 202006
  • 202012
  • 202106
  • 202111
  • 202205
  • 202211

Description for the changelog

Added sonic-launch-shell to invoke appropriate shell for the user post authentication.

Ensure to add label/tag for the feature raised. example - PR#2174 under sonic-utilities repo. where, Generic Config and Update feature has been labelled as GCU.

Link to config_db schema for YANG module changes

A picture of a cute animal (not mandatory but encouraged)

@azure-pipelines
Copy link

Commenter does not have sufficient privileges for PR 14466 in repo sonic-net/sonic-buildimage

@shdasari
Copy link
Contributor Author

shdasari commented Apr 4, 2023

/azp run

@azure-pipelines
Copy link

Commenter does not have sufficient privileges for PR 14466 in repo sonic-net/sonic-buildimage

@shdasari
Copy link
Contributor Author

shdasari commented Apr 7, 2023

/azpw run Azure.sonic-buildimage

@mssonicbld
Copy link
Collaborator

/AzurePipelines run Azure.sonic-buildimage

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@lguohan
Copy link
Collaborator

lguohan commented Apr 10, 2023

@shdasari , i doubt people are using sonic-mgmt framework in this case.

@shdasari
Copy link
Contributor Author

@shdasari , i doubt people are using sonic-mgmt framework in this case.

Agreed. sonic-launch-shell is only being packaged as a part of docker-sonic-mgmt-framework. It will be installed on the host at /usr/bin/sonic-launch-shell. sonic-launch-shell is a script that determines if user is to be presented with the linux shell or sonic-mgt-framework based sonic-cli shell based upon user privileges. Hence, it is being packaged as part of sonic-mgmt-framework package.

if /usr/bin/id -Gn | tr " " "\n" | /bin/grep -qw "^admin$"; then
exec /bin/bash "$@"
else
exec /usr/bin/sonic-cli

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Current sonic-cli does not provide all commands supported, like the Click commands. Hence, it is not a good idea to launch sonic-cli for remote user. Instead, bash shall be launched where the user can perform CRUD operations via Click commands.

Also, for TACACS, bash is being launched now. Hence to maintain consistency across all remote users, we shall retain TACACS shell launch behavior for RADIUS too.

#13141 addressing the proper approach.

@liat-grozovik
Copy link
Collaborator

Note: as this issue was originally detected on 202211, i suggest to have this cherry picked/backport to 202211 once it is merged. Added labels.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Radius] Fail to login to switch when Radius is configured "shell /usr/bin/sonic-launch-shell does not exist"
5 participants