You are not logged in.

#1 2015-11-19 10:11:13

ezzetabi
Member
Registered: 2006-08-27
Posts: 947

Use unshare to execute, but as normal user

From what I saw unshare needs to be executed as root...

% sudo unshare -n -- id
uid=0(root) gid=0(root) groups=0(root) ...

% unshare -n -- id
unshare: unshare failed: Operation not permitted

However, I would like to start an application as normal user because otherwise it saves all its files in the /root directory. Is there a way?

Last edited by ezzetabi (2015-11-19 13:29:06)

Offline

#2 2015-11-19 11:05:28

Awebb
Member
Registered: 2010-05-06
Posts: 6,567

Re: Use unshare to execute, but as normal user

Please provide more details about what you want to do with noshare, maybe we can get misconceptions out of the way.

Offline

#3 2015-11-19 13:28:43

ezzetabi
Member
Registered: 2006-08-27
Posts: 947

Re: Use unshare to execute, but as normal user

I want to execute a program as normal user unsharing the network namespace.
What misconceptions are you thinking?

Offline

#4 2015-11-19 13:58:32

Ropid
Member
Registered: 2015-03-09
Posts: 1,069

Re: Use unshare to execute, but as normal user

Check this out (if "ezzetabi" is your username):

sudo unshare -n sudo -u ezzetabi bash -c 'echo Hello, my name is $USER; echo My home is $HOME; echo; echo Here is the output of "id":; id; echo; echo I can see these networks:; ip a'

Last edited by Ropid (2015-11-19 14:04:35)

Offline

#5 2015-11-19 14:20:31

Awebb
Member
Registered: 2010-05-06
Posts: 6,567

Re: Use unshare to execute, but as normal user

ezzetabi wrote:

I want to execute a program as normal user unsharing the network namespace.
What misconceptions are you thinking?

I was puzzled about somebody who knew enough about namespaces to have a use case for them didn't know about how to run a program as another user. Ropid provided a solution.

Last edited by Awebb (2015-11-19 14:20:39)

Offline

Board footer

Powered by FluxBB