Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[v15] desktop access: improve error handling when directory sharing fails #45853

Merged
merged 1 commit into from
Aug 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions lib/srv/desktop/rdp/rdpclient/src/rdpdr/filesystem.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,8 @@ impl FilesystemBackend {
&mut self,
res: efs::ServerDeviceAnnounceResponse,
) -> PduResult<()> {
// TODO(zmb3): send the underlying NTSTATUS code instead
// of converting everything to 0 or 1.
let err_code = match res.result_code {
NtStatus::SUCCESS => TdpErrCode::Nil,
_ => TdpErrCode::Failed,
Expand Down
16 changes: 10 additions & 6 deletions web/packages/teleport/src/lib/tdp/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -397,10 +397,13 @@ export default class Client extends EventEmitterWebAuthnSender {
handleSharedDirectoryAcknowledge(buffer: ArrayBuffer) {
const ack = this.codec.decodeSharedDirectoryAcknowledge(buffer);
if (ack.errCode !== SharedDirectoryErrCode.Nil) {
// TODO(zmb3): get a better error message here
this.handleError(
new Error(`Encountered shared directory error: ${ack.errCode}`),
TdpClientEvent.CLIENT_ERROR
// A failure in the acknowledge message means the directory
// share operation failed (likely due to server side configuration).
// Since this is not a fatal error, we emit a warning but otherwise
// keep the sesion alive.
this.handleWarning(
`Failed to share directory '${this.sdManager.getName()}', drive redirection may be disabled on the RDP server.`,
TdpClientEvent.TDP_WARNING
);
return;
}
Expand Down Expand Up @@ -699,7 +702,8 @@ export default class Client extends EventEmitterWebAuthnSender {
this.send(this.codec.encodeRdpResponsePDU(responseFrame));
}

// Emits an errType event, closing the socket if the error was fatal.
// Emits an errType event and closes the websocket connection.
// Should only be used for fatal errors.
private handleError(
err: Error,
errType: TdpClientEvent.TDP_ERROR | TdpClientEvent.CLIENT_ERROR
Expand All @@ -709,7 +713,7 @@ export default class Client extends EventEmitterWebAuthnSender {
this.socket?.close();
}

// Emits an warnType event
// Emits a warning event, but keeps the socket open.
private handleWarning(
warning: string,
warnType: TdpClientEvent.TDP_WARNING | TdpClientEvent.CLIENT_WARNING
Expand Down
Loading