This answer, stating that the naming of classes in Python is not done because of special privileges, here confuses me.
- How can I access lower rings in Python?
- Is the low-level io for accessing lower level rings?
- If it is, which rings I can access with that?
- Is the statement
"This function is intended for low-level I/O."referring to lower level rings or to something else? - C tends to be prominent language in os -programming. When there is the OS -class in Python, does it mean that I can access C -code through that class?
- Suppose I am playing with bizarre machine-language code and I want to somehow understand what it means. Are there some tools in Python which I can use to analyze such things? If there is not, is there some way that I could still use Python to control some tool which controls the bizarre machine language? [ctypes suggested in comments]
- If Python has nothing to do with the low-level privileged stuff, do it still offers some wrappers to control the privileged?
Windows and Linux both use ring 0 for kernel code and ring 3 for user processes. The advantage of this is that user processes can be isolated from one another, so the system continues to run even if a process crashes. By contrast, a bug in ring 0 code can potentially crash the entire machine.
One of the reasons ring 0 code is so critical is that it can access hardware directly. By contrast, when a user-mode (ring 3) process needs to read some data from a disk:
Processes belonging to “privileged” users (e.g. root/Administrator) run in ring 3 just like any other user-mode code; the only difference is that the check at step 3 always succeeds. This is a good thing because:
As for running Python code in lower rings – kernel-mode is a very different environment, and the Python interpreter simply isn’t designed to run in it, e.g. the procedure for allocating memory is completely different.
In the other question you reference, both
os.open()andopen()end up making the open() system call, which checks whether the process is allowed to open the corresponding file and performs the actual operation.