Bug 7754

Summary: tl-sso-password can print errors if target exits quickly
Product: ThinLinc Reporter: Pierre Ossman <ossman>
Component: VSM AgentAssignee: Bugzilla mail exporter <bugzilla-qa>
Status: NEW ---    
Severity: Normal CC: martin.ostlund
Priority: P2    
Version: trunk   
Target Milestone: LowPrio   
Hardware: PC   
OS: Unknown   
See Also: https://bugzilla.cendio.com/show_bug.cgi?id=8341
Acceptance Criteria:

Description Pierre Ossman cendio 2021-08-26 15:49:41 CEST
You normally use tl-sso-password (or tl-sso-passphrase) as such:

> $ tl-sso-password | command --password-on-stdin

However if "command" exits very quickly then tl-sso-password will not have a functional pipe to write to and results in:

> $ tl-sso-password | echo
> 
> Exception ignored in: <_io.TextIOWrapper name='<stdout>' mode='w' encoding='utf-8'>
> BrokenPipeError: [Errno 32] Broken pipe

(echo is used because it closes stdin right away)

This is not a regression from converting to Python 3, as the same thing happens in 4.12.1:

> $ tl-sso-password | echo
> 
> close failed in file object destructor:
> sys.excepthook is missing
> lost sys.stderr

It does however seem to be more likely in ThinLinc 4.13.0 as we're getting the following on a Scientific Linux 7.9 system:

> Running /opt/thinlinc/etc/xstartup.d/01-tl-kinit.sh (Obtaining Kerberos ticket)
> kinit: Configuration file does not specify default realm when parsing name cendio
> Exception ignored in: <_io.TextIOWrapper name='<stdout>' mode='w' encoding='UTF-8'>
> BrokenPipeError: [Errno 32] Broken pipe

But when using ThinLinc 4.12.1 there is no such crash.


This behaviour is discussed upstream here:

https://bugs.python.org/issue11380

To handle this is seems like we should do a manual flush of stdout and be prepared for BrokenPipeError.