OiO.lk Community platform!

Oio.lk is an excellent forum for developers, providing a wide range of resources, discussions, and support for those in the developer community. Join oio.lk today to connect with like-minded professionals, share insights, and stay updated on the latest trends and technologies in the development field.
  You need to log in or register to access the solved answers to this problem.
  • You have reached the maximum number of guest views allowed
  • Please register below to remove this limitation

os.setuid errors with [Errno 22] Invalid argument

  • Thread starter Thread starter Xander Mckay
  • Start date Start date
X

Xander Mckay

Guest
I am trying to use os.setuid in an unshared user namespace, but it returns an error, which I cannot seem to find happening to anyone anywhere. Code (this is a MRE, not part of my program):

Code:
import os
os.unshare(os.CLONE_NEWUSER)
os.setuid(0)
os.setgid(0)
os.system('/bin/bash')

Error:

Code:
Traceback (most recent call last):
  File "path/to/mre/mre.py", line 3, in <module>
    os.setuid(0)
OSError: [Errno 22] Invalid argument

I am using Python 3.12.4, on Manjaro Linux. Can anyone help me out here?
<p>I am trying to use os.setuid in an unshared user namespace, but it returns an error, which I cannot seem to find happening to anyone anywhere.
Code (this is a MRE, not part of my program):</p>
<pre><code>import os
os.unshare(os.CLONE_NEWUSER)
os.setuid(0)
os.setgid(0)
os.system('/bin/bash')
</code></pre>
<p>Error:</p>
<pre><code>Traceback (most recent call last):
File "path/to/mre/mre.py", line 3, in <module>
os.setuid(0)
OSError: [Errno 22] Invalid argument
</code></pre>
<p>I am using Python 3.12.4, on Manjaro Linux.
Can anyone help me out here?</p>
 

Latest posts

I
Replies
0
Views
1
Ihsan Sadat
I
Top