Skip to content

Permission denied when cleaning up temporary files during user switching (non-root) #771

@jiaruihuang

Description

@jiaruihuang

Title: Permission denied when cleaning up temporary files during user switching (non-root)
Type: Bug Report / Potential Improvement
Description:
When using Xpipe to switch from a standard user (e.g., userA) to another non-root user (e.g., userB) via the "Shell Environment" feature, the generated command fails to clean up the temporary askpass script. This is because the script is owned by the initial login user, and the target user does not have the permission to delete it.
Steps to Reproduce:

  1. Connect to a remote host as a standard user (e.g., userA).
  2. Configure a Shell Environment to switch identity to another non-root user (e.g., userB) using sudo -u userB.
  3. Launch the shell.
  4. Observe the error message: rm: cannot remove '/tmp/xpipe-XXXXXXXX.sh': Operation not permitted.

Expected Behavior:
The temporary script should be cleaned up silently without permission errors, or the cleanup should be handled by a process with sufficient privileges.

Actual Behavior:
Xpipe attempts to execute rm -f "/tmp/xpipe-XXXXXXXX.sh" as userB. Since the file is owned by userA and stored in /tmp (which usually has the sticky bit set), the operation fails with "Operation not permitted".

Environment:

  • Xpipe Version: [20.3]
  • OS: [Ubuntu 22.04]
  • Shell: zsh

Suggested Fix/Workaround:
Perhaps Xpipe could:

  1. Wrap the cleanup command in a way that it executes as the original user.
  2. Redirect stderr to /dev/null for the rm command to avoid cluttering the terminal.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions