fix(refresh_token): truncate token_out before overwriting it
Alexander Rogovskiy had to update the refresh token of our etf OAuth2 client and noticed the following issue:
06/05/24 08:33:58 Looking for token in file /opt/omd/sites/etf/etc/nagios/globus/lhcb-ce.token
06/05/24 08:33:58 Token discovery failure: token contains non-permitted character sequence (\\r
)
After investigation, he found out that:
- Previous token (which corresponds to incorrect client details) is longer (contains more characters) than the correct one.
- When client details are updated, refresh_token plugin writes new token "on top" of the old one, without truncating the file.
- That's why garbage from the previous token appears on the second line of the file.
Adding the OS_TRUNC
flag when opening token_out
should solve that issue.
Thanks