Skip to content

Commit

Permalink
Treat session ID as a string in system/users (elastic#22359)
Browse files Browse the repository at this point in the history
* treat session ID as a string

* add changelog

* Update wording on CHANGELOG.next.asciidoc

Co-authored-by: kaiyan-sheng <[email protected]>

Co-authored-by: kaiyan-sheng <[email protected]>
  • Loading branch information
fearful-symmetry and kaiyan-sheng authored Nov 3, 2020
1 parent 3817779 commit 7826ef6
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 9 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.next.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -390,6 +390,7 @@ https://github.com/elastic/beats/compare/v7.0.0-alpha2...master[Check the HEAD d
- Fix instance name in perfmon metricset. {issue}22218[22218] {pull}22261[22261]
- 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 @@ -843,4 +844,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

0 comments on commit 7826ef6

Please sign in to comment.