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]>
(cherry picked from commit 7826ef6)
  • Loading branch information
fearful-symmetry committed Nov 3, 2020
1 parent 7cfd4ae commit 5eab25f
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 8 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.next.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -429,6 +429,7 @@ field. You can revert this change by configuring tags for the module and omittin
- Revert change to report `process.memory.rss` as `process.memory.wss` on Windows. {pull}22055[22055]
- Add interval information to `monitor` metricset in azure. {pull}22152[22152]
- Remove io.time from windows {pull}22237[22237]
- Change Session ID type from int to string {pull}22359[22359]

*Packetbeat*

Expand Down Expand Up @@ -913,3 +914,5 @@ field. You can revert this change by configuring tags for the module and omittin
==== Known Issue

*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 5eab25f

Please sign in to comment.