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

Unset TMP if it doesn't exist inside of sandbox #4151

Closed
matthew-cline opened this issue Mar 31, 2021 · 1 comment
Closed

Unset TMP if it doesn't exist inside of sandbox #4151

matthew-cline opened this issue Mar 31, 2021 · 1 comment
Labels
enhancement New feature request

Comments

@matthew-cline
Copy link
Contributor

I have this weird setup where the TMP env var is set to /tmp/$USER and that directory is automatically created. This causes sandboxed apps to not work if the profile uses private-tmp, and the error messages the app generates aren't necessarily useful. I solved the problem by making a wrapper script for firejail which unsets TMP, but other users might have TMP point to a non-standard location and have the sandboxed app not give them and useful error messages, leaving them confused frustrated.

One way to solve the problem would be, if TMP is set, to check if what it points to exists within the sandbox, and unset the var if it doesn't.

@rusty-snake
Copy link
Collaborator

where the TMP env var is set to /tmp/$USER

We have already code for TMP=/tmp/user/$UID, maybe this need further adjustments:

// pam-tmpdir - issue #2685
const char *env = env_get("TMP");
if (env) {
char *pamtmpdir;
if (asprintf(&pamtmpdir, "/tmp/user/%u", getuid()) == -1)
errExit("asprintf");
if (strcmp(env, pamtmpdir) == 0) {
// create empty user-owned /tmp/user/$uid directory
mkdir_attr("/tmp/user", 0711, 0, 0);
selinux_relabel_path("/tmp/user", "/tmp/user");
fs_logger("mkdir /tmp/user");
mkdir_attr(pamtmpdir, 0700, getuid(), 0);
selinux_relabel_path(pamtmpdir, pamtmpdir);
fs_logger2("mkdir", pamtmpdir);
}
free(pamtmpdir);
}

I solved the problem by making a wrapper script for firejail which unsets TMP

Just add rmenv TMP to <PROFILE>.local.

@rusty-snake rusty-snake added the enhancement New feature request label Dec 10, 2021
@kmk3 kmk3 changed the title [Feature] Unset TMP if it doesn't exist inside of sandbox Unset TMP if it doesn't exist inside of sandbox Feb 5, 2022
kmk3 added a commit that referenced this issue Feb 5, 2022
@kmk3 kmk3 moved this to Done (on RELNOTES) in Release 0.9.68 Sep 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature request
Projects
Status: Done (on RELNOTES)
Development

No branches or pull requests

2 participants