Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

python | start new thread that will impersonate another uid without affecting main thread

I with to create a new thread which will impersonate to another uid, execute a task and finish, while my main thread will keep is original uid all the time.

impersonation can easily be achieved by using

os.setuid(self.impersonation_uid)

but how can I make sure that it won’t change my original uid from the main thread?

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

Thank you

>Solution :

Threads cannot have separate user ids; only processes can. The data structure the kernel uses for process has a user id field, but the thread one doesn’t.

Processes are defined by task_struct, which has a cred field, pointing to a cred structure.

Threads are defined by thread_info, which doesn’t have anything point to user credentials.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading