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 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
2 changes: 1 addition & 1 deletion CHANGELOG.next.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -387,6 +387,7 @@ https://github.com/elastic/beats/compare/v7.0.0-alpha2...master[Check the HEAD d
- Add a switch to the driver definition on SQL module to use pretty names {pull}17378[17378]
- Remove io.time from windows {pull}22237[22237]
- Add interval information to `monitor` metricset in azure. {pull}22152[22152]
- Change Session ID type from int to string {pull}22359[22359]

*Packetbeat*

Expand Down Expand Up @@ -839,4 +840,3 @@ https://github.com/elastic/beats/compare/v7.0.0-alpha2...master[Check the HEAD d
*Journalbeat*



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