[GH-ISSUE #208] option to change user #147

Closed
opened 2026-05-05 05:09:46 -06:00 by gitea-mirror · 13 comments
Owner

Originally created by @the8472 on GitHub (Jan 3, 2016).
Original GitHub issue: https://github.com/netblue30/firejail/issues/208

Currently it's only possible to bind-mount paths when called by root.

But calling as root prevents passing --noroot which in turn necessitates changing the user within the sandbox via su or sudo and possibly unshare to do what --noroot normally would.

But all those do require more capabilities/system calls than necessary.

So i think it would be useful to drop capabilities, change user and create a user namespace in one go.

Originally created by @the8472 on GitHub (Jan 3, 2016). Original GitHub issue: https://github.com/netblue30/firejail/issues/208 Currently it's only possible to bind-mount paths when called by root. But calling as root prevents passing `--noroot` which in turn necessitates changing the user within the sandbox via `su` or `sudo` and possibly `unshare` to do what `--noroot` normally would. But all those do require more capabilities/system calls than necessary. So i think it would be useful to drop capabilities, change user and create a user namespace in one go.
gitea-mirror 2026-05-05 05:09:46 -06:00
Author
Owner

@genodeftest commented on GitHub (Jan 14, 2016):

Do you want to run e.g. firefox as a different user inside your own home directory?

<!-- gh-comment-id:171698423 --> @genodeftest commented on GitHub (Jan 14, 2016): Do you want to run e.g. firefox as a different user inside your own home directory?
Author
Owner

@the8472 commented on GitHub (Jan 14, 2016):

the idea is to have a user and home directory dedicated to a specific application, that makes it much simpler to reason about file permissions

<!-- gh-comment-id:171701273 --> @the8472 commented on GitHub (Jan 14, 2016): the idea is to have a user and home directory dedicated to a specific application, that makes it much simpler to reason about file permissions
Author
Owner

@genodeftest commented on GitHub (Jan 14, 2016):

So for e.g. firefox you won't run it from /home/username but e.g. from /home/username.firefox, right?
And you could put your username.firefox inside the same group as username so you can create files writeable by username and readable by group.

<!-- gh-comment-id:171710755 --> @genodeftest commented on GitHub (Jan 14, 2016): So for e.g. firefox you won't run it from /home/username but e.g. from /home/username.firefox, right? And you could put your username.firefox inside the same group as username so you can create files writeable by username and readable by group.
Author
Owner

@the8472 commented on GitHub (Jan 14, 2016):

My particular use case is to start daemons which need both network and filesystem access from root, which makes them prime candidates for jailing. Currently the choices for that are either calling su -c "firejail --noroot <daemon>" <user> or firejail ... su -c "<daemon>" <user>. Both have their own drawbacks.

Letting non-root users do that would seem tricky to get right, since it could be easily exploited to gain access to other users if not done right.

<!-- gh-comment-id:171716027 --> @the8472 commented on GitHub (Jan 14, 2016): My particular use case is to start daemons which need both network and filesystem access from root, which makes them prime candidates for jailing. Currently the choices for that are either calling `su -c "firejail --noroot <daemon>" <user>` or `firejail ... su -c "<daemon>" <user>`. Both have their own drawbacks. Letting non-root users do that would seem tricky to get right, since it could be easily exploited to gain access to other users if not done right.
Author
Owner

@netblue30 commented on GitHub (Jan 15, 2016):

I think I'll stay away from it, it creates to many security problems. In order to do it right, I'll end up duplicating all su code into firejail.

<!-- gh-comment-id:171965788 --> @netblue30 commented on GitHub (Jan 15, 2016): I think I'll stay away from it, it creates to many security problems. In order to do it right, I'll end up duplicating all su code into firejail.
Author
Owner

@the8472 commented on GitHub (Jan 17, 2016):

Would it be possible to delegate this task to su then and insert it between the parent and child firejail instances?

<!-- gh-comment-id:172368394 --> @the8472 commented on GitHub (Jan 17, 2016): Would it be possible to delegate this task to su then and insert it between the parent and child firejail instances?
Author
Owner

@netblue30 commented on GitHub (Jan 18, 2016):

The problem is you need to start the sandbox as root, otherwise I cannot let you change the user. Firejail is SUID binary and can change to any user, but we just cannot let it do it for a regular user.

Support for changing the user makes more sense when running servers. Maybe I'll add some support for it, but the user will need to be root to begin it.

<!-- gh-comment-id:172526431 --> @netblue30 commented on GitHub (Jan 18, 2016): The problem is you need to start the sandbox as root, otherwise I cannot let you change the user. Firejail is SUID binary and can change to any user, but we just cannot let it do it for a regular user. Support for changing the user makes more sense when running servers. Maybe I'll add some support for it, but the user will need to be root to begin it.
Author
Owner

@the8472 commented on GitHub (Jan 18, 2016):

Yes, starting it as root was my use-case.

<!-- gh-comment-id:172572943 --> @the8472 commented on GitHub (Jan 18, 2016): Yes, starting it as root was my use-case.
Author
Owner

@netblue30 commented on GitHub (Jan 18, 2016):

OK, that's easier. I'll implement it.

<!-- gh-comment-id:172585082 --> @netblue30 commented on GitHub (Jan 18, 2016): OK, that's easier. I'll implement it.
Author
Owner

@netblue30 commented on GitHub (Jan 23, 2016):

I have it ready in the latest version in git. Example:

$ sudo firejail --user=some-other-user firefox

<!-- gh-comment-id:174194202 --> @netblue30 commented on GitHub (Jan 23, 2016): I have it ready in the latest version in git. Example: $ sudo firejail --user=some-other-user firefox
Author
Owner

@gima commented on GitHub (Jul 4, 2017):

$ firejail --user 
Error: invalid --user command line option

Is this feature still about to be included?

My use-case is this: I would need to overlay/bindmount a file to a directory, to which my user has no write access. I would need to use sudo to run firejail, but then the jailed executable is run as root and not as my user.

If it matters, the file in question is: /usr/lib/firefox/mozilla.cfg

<!-- gh-comment-id:312966742 --> @gima commented on GitHub (Jul 4, 2017): ~~~ $ firejail --user Error: invalid --user command line option ~~~ Is this feature still about to be included? My use-case is this: I would need to overlay/bindmount a file to a directory, to which my user has no write access. I would need to use sudo to run firejail, but then the jailed executable is run as root and not as my user. *If it matters, the file in question is: /usr/lib/firefox/mozilla.cfg*
Author
Owner

@netblue30 commented on GitHub (Jul 17, 2017):

--user option was removed a long time ago. You would need to update your software.

<!-- gh-comment-id:315785064 --> @netblue30 commented on GitHub (Jul 17, 2017): --user option was removed a long time ago. You would need to update your software.
Author
Owner

@scruloose commented on GitHub (Jan 12, 2021):

Wait, what?

In early 2016 you added the option to have Firejail seamlessly switch to another user (when called as root via sudo, naturally) so users could seamlessly combine sandboxing and Linux account separation to suit their use-case… but by a year and a half later it had been "removed a long time ago"?

What did I miss? Did this blow up in somebody's face?

I ask because I would really like that functionality. Being able to run graphical programs, sandboxed and as an entirely different Linux user, but exporting the window to my existing desktop? That would be super helpful. So if it was removed due to factors that can reasonably be resolved, I would ask about re-opening this issue — or I could start a new one; whatever's convenient for you. But if it's more like "Yeah we tried that and the answer is no", then I won't bother.

What do you think?

<!-- gh-comment-id:758348790 --> @scruloose commented on GitHub (Jan 12, 2021): Wait, what? In early 2016 you added the option to have Firejail seamlessly switch to another user (when called as root via sudo, naturally) so users could seamlessly combine sandboxing and Linux account separation to suit their use-case… but by a year and a half later it had been "removed a long time ago"? What did I miss? Did this blow up in somebody's face? I ask because I would *really* like that functionality. Being able to run graphical programs, sandboxed **and** as an entirely different Linux user, but exporting the window to my existing desktop? That would be super helpful. So if it was removed due to factors that can reasonably be resolved, I would ask about re-opening this issue — or I could start a new one; whatever's convenient for you. But if it's more like "Yeah we tried that and the answer is no", then I won't bother. What do you think?
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: github-starred/firejail#147
No description provided.