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

Treat session ID as a string in system/users #22359

Merged
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
9 changes: 2 additions & 7 deletions metricbeat/module/system/users/dbus.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ type sessionInfo struct {

// loginSession contains basic information on a login session
type loginSession struct {
ID uint64
ID string
UID uint32
User string
Seat string
Expand Down Expand Up @@ -167,16 +167,11 @@ func formatSessionList(props [][]dbus.Variant) ([]loginSession, error) {
if len(session) < 5 {
return nil, fmt.Errorf("wrong number of fields in session: %v", session)
}
idStr, ok := session[0].Value().(string)
id, ok := session[0].Value().(string)
if !ok {
return nil, fmt.Errorf("failed to cast user ID to string")
}

id, err := strconv.ParseUint(idStr, 10, 32)
if err != nil {
return nil, errors.Wrap(err, "error parsing ID to int")
}

uid, ok := session[1].Value().(uint32)
if !ok {
return nil, fmt.Errorf("failed to cast session uid to uint32")
Expand Down
2 changes: 1 addition & 1 deletion metricbeat/module/system/users/users_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ func TestFormatSessionList(t *testing.T) {
}

goodOut := []loginSession{{
ID: uint64(6),
ID: "6",
UID: uint32(1000),
User: "user",
Seat: "",
Expand Down