Hi
I have setup Django with wsgi and Apache on Linux and all is good,
but the application that I am building should be able to modify
Linux files which are only allowed by root.
so, I have created a function named myfunc in a module named mymodule.py
and has invoked the function in my application's views.py.
now , How can i invoke mymodule.py as root, or is there any way to invoke
only myfunc as root ?
I already setup sudo , and was able to create directory as root with mkdir command
but what about python methods such as open(), how can I open( ) a file as root
while funciton is being invoked as apache user ? tried adding mymodule.py and python
to a list of
commands in suduers file , but still there is a problem with creating the file.
even , os.setuid() won't work, because function is being invoked as apache user.
thought about setting setuid on python executable, but setuid is not working on scripts and have to write
a program in C or C++ and make it setuid and then invoke it through Django and python
but don't want to go that way to keep every thing in Python language.
the main question is "how to invoke a python function or module as root from view"
but I am open for any better solution.
Thanks