LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   changing thread user context in linux (https://www.linuxquestions.org/questions/linux-newbie-8/changing-thread-user-context-in-linux-743642/)

neel_learning_linux 07-29-2009 06:02 AM

changing thread user context in linux
 
Hi!

I wanted to know whether there is a way in linux to change the user context of *one of the threads* in the process.

I do not want to launch another process using fork or any other method.

I know that on Windows it is possible but don't know if on linux.

Thanks in advance,
-Neel.

neonsignal 07-29-2009 11:37 PM

Is getcontext and setcontext what you are after?

You can also change the user id with getuid() and setuid().

neel_learning_linux 07-31-2009 01:06 AM

Thanks for the reply.

I am not sure. here is what I want to do:

- Change context of *only* of thread to some user from root
- use gssapi to fetch the ticket for that user
- change thread context back to root

I believe setcontext/getcontext might be the way to go but I am not sure that it will not change context of rest of the process or even GSSAPI will work with this kind of approach. I will do some trials and find out.. If you do have any further suggestions/comments, they are welcome.

Thanks,
- Neel.

neonsignal 07-31-2009 02:34 AM

Sorry, I missed your emphasis.

No, it isn't possible to just change one of the threads. The pthreads in *nix systems are light-weight compared to the Windows equivalent, and share more state information. The POSIX standard requires that they share user and group ids.

Incidentally, a fork is much faster than a CreateProcess on Windows (CreateProcess is something more akin to vfork+exec). For a long time fork was the only way to do multitasking in Unix, so it is well optimized for the job. Not sure if that makes it any more palatable?


All times are GMT -5. The time now is 08:31 PM.