Skip to content

Commit

Permalink
Remove unused code.
Browse files Browse the repository at this point in the history
  • Loading branch information
ganglyu committed Jun 16, 2022
1 parent 555c52b commit 43b8300
Show file tree
Hide file tree
Showing 4 changed files with 1 addition and 738 deletions.
36 changes: 1 addition & 35 deletions gnmi_server/pamAuth.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@ package gnmi

import (
"github.com/sonic-net/sonic-gnmi/common_utils"
"errors"
"github.com/golang/glog"
"github.com/msteinert/pam"
"golang.org/x/crypto/ssh"
"os/user"
)
Expand All @@ -14,38 +12,6 @@ type UserCredential struct {
Password string
}

//PAM conversation handler.
func (u UserCredential) PAMConvHandler(s pam.Style, msg string) (string, error) {

switch s {
case pam.PromptEchoOff:
return u.Password, nil
case pam.PromptEchoOn:
return u.Password, nil
case pam.ErrorMsg:
return "", nil
case pam.TextInfo:
return "", nil
default:
return "", errors.New("unrecognized conversation message style")
}
}

// PAMAuthenticate performs PAM authentication for the user credentials provided
func (u UserCredential) PAMAuthenticate() error {
tx, err := pam.StartFunc("login", u.Username, u.PAMConvHandler)
if err != nil {
return err
}
return tx.Authenticate(0)
}

func PAMAuthUser(u string, p string) error {

cred := UserCredential{u, p}
err := cred.PAMAuthenticate()
return err
}
func GetUserRoles(usr *user.User) ([]string, error) {
// Lookup Roles
gids, err := usr.GroupIds()
Expand All @@ -62,6 +28,7 @@ func GetUserRoles(usr *user.User) ([]string, error) {
}
return roles, nil
}

func PopulateAuthStruct(username string, auth *common_utils.AuthInfo, r []string) error {
if len(r) == 0 {
AuthLock.Lock()
Expand Down Expand Up @@ -91,7 +58,6 @@ func UserPwAuth(username string, passwd string) (bool, error) {
* /etc of host with /etc of container. For now disable this and use ssh
* for authentication.
*/
// err := PAMAuthUser(username, passwd)

//Use ssh for authentication.
config := &ssh.ClientConfig{
Expand Down
1 change: 0 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ require (
github.com/jipanyang/gnmi v0.0.0-20180820232453-cb4d464fa018 // indirect
github.com/jipanyang/gnxi v0.0.0-20181221084354-f0a90cca6fd0
github.com/kylelemons/godebug v1.1.0 // indirect
github.com/msteinert/pam v0.0.0-20201130170657-e61372126161
github.com/onsi/ginkgo v1.10.3 // indirect
github.com/onsi/gomega v1.7.1 // indirect
github.com/openconfig/gnmi v0.0.0-20200617225440-d2b4e6a45802
Expand Down
162 changes: 0 additions & 162 deletions sonic_data_client/trie.go

This file was deleted.

Loading

0 comments on commit 43b8300

Please sign in to comment.