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

oslogin: dont add entry to pam.d/su #66

Merged
merged 1 commit into from
Aug 7, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 0 additions & 22 deletions google_guest_agent/oslogin.go
Original file line number Diff line number Diff line change
Expand Up @@ -259,17 +259,6 @@ func updatePAMsshd(pamsshd string, enable, twofactor bool) string {
return strings.Join(filtered, "\n")
}

func updatePAMsu(pamsu string, enable bool) string {
accountSu := "account [success=bad ignore=ignore] pam_oslogin_login.so"

filtered := filterGoogleLines(pamsu)
if enable {
filtered = append([]string{googleComment, accountSu}, filtered...)
}

return strings.Join(filtered, "\n")
}

func writePAMConfig(enable, twofactor bool) error {
pamsshd, err := ioutil.ReadFile("/etc/pam.d/sshd")
if err != nil {
Expand All @@ -282,17 +271,6 @@ func writePAMConfig(enable, twofactor bool) error {
}
}

pamsu, err := ioutil.ReadFile("/etc/pam.d/su")
if err != nil {
return err
}
proposed = updatePAMsu(string(pamsu), enable)
if proposed != string(pamsu) {
if err := writeConfigFile("/etc/pam.d/su", proposed); err != nil {
return err
}
}

return nil
}

Expand Down
59 changes: 0 additions & 59 deletions google_guest_agent/oslogin_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -354,65 +354,6 @@ func TestUpdatePAMsshd(t *testing.T) {
}
}
}
func TestUpdatePAMsu(t *testing.T) {
accountSu := "account [success=bad ignore=ignore] pam_oslogin_login.so"

var tests = []struct {
contents, want []string
enable bool
}{
{
contents: []string{
"line1",
"line2",
},
want: []string{
googleComment,
accountSu,
"line1",
"line2",
},
enable: true,
},
{
contents: []string{
"line1",
googleComment,
accountSu,
"line2",
},
want: []string{
googleComment,
accountSu,
"line1",
"line2",
},
enable: true,
},
{
contents: []string{
"line1",
googleComment,
accountSu,
"line2",
},
want: []string{
"line1",
"line2",
},
enable: false,
},
}

for idx, tt := range tests {
contents := strings.Join(tt.contents, "\n")
want := strings.Join(tt.want, "\n")

if res := updatePAMsu(contents, tt.enable); res != want {
t.Errorf("test %v\nwant:\n%v\ngot:\n%v\n", idx, want, res)
}
}
}

func TestUpdateGroupConf(t *testing.T) {
config := "sshd;*;*;Al0000-2400;video"
Expand Down