42wim/matterircd

bug(mattermost): nil pointer during SSO login

Closed this issue · 3 comments

in0rdr commented

Matterircd crashes during authentication with MMAUTHTOKEN (redacted $USER, $TEAM and $SERVER):

matterircd[1120760]: time="2023-03-26T10:29:41Z" level=info msg="Running version 0.27.0 0e4278a" module=matterircd
matterircd[1120760]: time="2023-03-26T10:29:41Z" level=info msg="Listening on 127.0.0.1:6667" module=matterircd
matterircd[1120760]: time="2023-03-26T10:29:47Z" level=info msg="New connection: 127.0.0.1:48070" module=matterircd
matterircd[1120760]: loggerlevel: info
matterircd[1120760]: time="2023-03-26T10:30:15Z" level=info msg="login as $USER (team: $TEAM) on $SERVER"
matterircd[1120760]: time="2023-03-26T10:30:15Z" level=info msg="Found version 7.8.1.7.8.1.11eac75b89a79401ef57202d8e3aaf9f.true" prefix=matterclient
matterircd[1120760]: panic: runtime error: invalid memory address or nil pointer dereference
matterircd[1120760]: [signal SIGSEGV: segmentation violation code=0x1 addr=0x8 pc=0x88a7a1]
matterircd[1120760]: goroutine 19 [running]:
matterircd[1120760]: github.com/matterbridge/matterclient.(*Client).UpdateChannels(0xc0002d60f0)
matterircd[1120760]:         /go/src/github.com/42wim/matterircd/vendor/github.com/matterbridge/matterclient/channels.go:279 +0x21
matterircd[1120760]: github.com/matterbridge/matterclient.(*Client).initUserChannels(0xc0002d60f0)
matterircd[1120760]:         /go/src/github.com/42wim/matterircd/vendor/github.com/matterbridge/matterclient/matterclient.go:363 +0x33
matterircd[1120760]: github.com/matterbridge/matterclient.(*Client).Login(0xc0002d60f0)
matterircd[1120760]:         /go/src/github.com/42wim/matterircd/vendor/github.com/matterbridge/matterclient/matterclient.go:147 +0xdc
matterircd[1120760]: github.com/42wim/matterircd/bridge/mattermost.(*Mattermost).loginToMattermost(0xc0003ae0a0, 0xc00024fe30)
matterircd[1120760]:         /go/src/github.com/42wim/matterircd/bridge/mattermost/mattermost.go:97 +0x32f
matterircd[1120760]: github.com/42wim/matterircd/bridge/mattermost.New(0xc0000fcea0, {{0xc00051c550, 0x8}, {0xc000649a28, 0x7}, {0xc00002a5d0, 0x26}, {0xc000649a50, 0>
matterircd[1120760]:         /go/src/github.com/42wim/matterircd/bridge/mattermost/mattermost.go:52 +0x20d
matterircd[1120760]: github.com/42wim/matterircd/mm-go-irckit.(*User).loginTo(0xc0003bb8c0, {0xac7cb4?, 0x10?})
matterircd[1120760]:         /go/src/github.com/42wim/matterircd/mm-go-irckit/userbridge.go:871 +0x426
matterircd[1120760]: github.com/42wim/matterircd/mm-go-irckit.login(0xc0003bb8c0, 0xc000658c90?, {0xc000246b90, 0x5, 0xabd900?}, {0xc00009e508, 0xa})
matterircd[1120760]:         /go/src/github.com/42wim/matterircd/mm-go-irckit/service.go:203 +0xd2f
matterircd[1120760]: github.com/42wim/matterircd/mm-go-irckit.(*User).handleServiceBot(0xc0003bb8c0, {0xc00009e508, 0xa}, 0xc00003dfd0?, {0xc000064480, 0x5f})
matterircd[1120760]:         /go/src/github.com/42wim/matterircd/mm-go-irckit/service.go:469 +0x283
matterircd[1120760]: created by github.com/42wim/matterircd/mm-go-irckit.CmdPrivMsg
matterircd[1120760]:         /go/src/github.com/42wim/matterircd/mm-go-irckit/server_commands.go:415 +0xb6c

To reproduce the crash, here the login command which was used:

login $SERVER $TEAM $PASSWORD $USERNAME MMAUTHTOKEN=$TOKEN
matterircd --version
version: 0.27.0 0e4278a

I think this is cause you entered the wrong team (one that doesn't exist or one that you're part of)?

It shouldn't crash like this though and I think I have a fix for it.

I think this should fix it - matterbridge/matterclient#5

If not, are you able to run with Debug = true and Trace = true?

in0rdr commented

Thanks @hloeung your hint with the team name lead me the right direction. That's basically the issue here, I had a wrong team name in my config file:

#specify default mattermost team (default "")
#
DefaultTeam = ""

After fixing my config, I found a working login command that does not crash matterircd:

/msg mattermost login $SERVER $USERNAME MMAUTHTOKEN=$TOKEN