W
W
waltaki2021-10-18 05:25:32
linux
waltaki, 2021-10-18 05:25:32

How to execute code as another user for Linux?

There is an example of such libraries https://github.com/mwijnands/Impersonator , but they only work under Windows.

using (new Impersonator(@"domainname\username", "password"))
{
  // this code is executed as the user with supplied credentials.
  var files = Directory.GetFiles(@"\\server\share\folder");
}

How to seamlessly implement this in Linux? I'm thinking about the c setuid, setgid option, but it's not clear how they will behave in the case of parallel work with several different users, and this works for the entire program, and not for the context, as in the example above.
Is it possible to implement this at all for Linux?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
SagePtr, 2021-10-18
@SagePtr

I suspect that this can be done the way it is done in different Apaches - the process is forked, then the group and user of the child process change. Several users - several forks.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question