Skip to content
  • David Woodhouse's avatar
    Fix EINTR handling for select() on cmd_fd · e1a3be3d
    David Woodhouse authored
    KDE plasma-nm was failing with external browser authentication, reporting
    'Socket connect cancelled' immediately after spawning the browser command.
    
    This was caused by the SIGCHLD which kded handles (instead of it being
    ignored as in the standalone openconnect process). Thus, the select()
    call returns with EINTR, and the fd sets are not changed.
    
    So when check_cmd_fd(vpninfo, &rd_set) is called, it looks like the cmd_fd
    was readable. And since plasma-nm uses the legacy cancel_fd setup, the
    mere fact of it being *readable* is enough to set vpninfo->got_cancel_cmd.
    
    Instead of forging ahead and interpreting the fd_sets after select()
    returns with EINTR, loop and go straight back into select() instead.
    
    For signals like SIGINT from Ctrl-C, we *handle* those and deliver the
    cancel command anyway, so we don't depend on the EINTR return in that
    case.
    
    cf. https://gitlab.gnome.org/GNOME/NetworkManager-openconnect/-/merge_requests/49#note_1725203
    
    Signed-off-by: David Wo...
    e1a3be3d