Skip to content
This repository has been archived by the owner on Nov 21, 2023. It is now read-only.

$HOME=/root for daemons run via s6-setuidgid #14

Closed
folex opened this issue Oct 15, 2021 · 4 comments · Fixed by #15
Closed

$HOME=/root for daemons run via s6-setuidgid #14

folex opened this issue Oct 15, 2021 · 4 comments · Fixed by #15
Assignees
Labels
bug Something isn't working critical

Comments

@folex
Copy link
Member

folex commented Oct 15, 2021

Currently, both fluence and ipfs are ran via s6-setuidgid abc for privilege drop.

However, as stated in the issue just-containers/s6-overlay#165 (comment), it doesn't change $HOME variable in any way. As a result, $HOME is set to /root.

That poses a problem if a program relies on the $HOME variable: they will use /root as their $HOME while having no permissions to write and/or read there.

For example, any NodeJS program that uses os.homedir() is susceptible to that problem, as described in this issue nodejs/node#5582.

We've met this behavior with Ceramic JS CLI (see ceramic-cli-utils.ts#L26):

  node:internal/process/promises:245
            triggerUncaughtException(err, true /* fromPromise */);
            ^
  
  [Error: EACCES: permission denied, mkdir '/root/.ceramic'] {
    errno: -13,
    code: 'EACCES',
    syscall: 'mkdir',
    path: '/root/.ceramic'
  }

Solution

The solution to this is to use execline's tools to unset $HOME env variable. Either emptyvar or unexport will do.

@folex folex added bug Something isn't working critical labels Oct 15, 2021
@folex folex self-assigned this Oct 15, 2021
@folex folex closed this as completed in #15 Oct 21, 2021
folex added a commit that referenced this issue Oct 21, 2021
@stanleyjs
Copy link

@folex can you make this an arg to s6-setuidgid or somewhere else?

I currently have an application where I need to dynamically build a user specified as an environment variable at runtime in a container, pip install -e a directory as the user, and run jupyter under the user. pip reads $HOME and builds all of its directories according to that. I need to be able to pass a $HOME variable in; it's a little bit of duct-tape but I'm not sure there's a way around it

@folex
Copy link
Member Author

folex commented Feb 4, 2022

@stanleyjs Hi there!

Are you trying to integrate jupyter with Fluence? That would be awesome!

This PR doesn't get in your way: it only unsets $HOME for ipfs and fluence daemons inside fluencelabs/fluence container. You can add your daemons, and they will receive $HOME = /root. However, note that this value might be incorrect and misleading for your use-case.

@stanleyjs
Copy link

stanleyjs commented Feb 4, 2022 via email

@folex
Copy link
Member Author

folex commented Feb 4, 2022

That was my guess :)

Good luck with jupyter and s6! Btw, they're very helpful on Discord.

P.S. If you ever feel interested in p2p networks, you're always welcome here :)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working critical
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants