K
Krishnakant
hello all,
This is a real challenge and I don't know if a solution even exists for
this or not.
I am writing an application which I run as my usual user on ubuntu.
the usernake is let's say kk and it has sudo permission (meaning the
user is in the sudoers list ).
now when i do python myscript.py, the script has to change to another
non-privileged user for some tasks.
let's say for example switch to the postgres user which is dedicated for
postgres and has no other privileges.
I have tryed doing os.setuid(112) where 112 could be the uid of the user
I want the script to swith over.
but I got opperation not permitted.
I tryed using subprocess but that did not help me either. I tryed sudo
su into the Popen command but it throws me into the terminal (shell)
with postgres as the user.
But that's now my desired result.
what I exactly want is that the script now continues to execute under
postgres user till the end.
I don't know how to achieve this iffect.
Infact I will need this during a serious deployment because i would have
my application run as a demon as a dedicated user.
I am finding some code for deamonising a python application but don't
know how to tell the script to change user.
happy hacking.
Krishnakant.
This is a real challenge and I don't know if a solution even exists for
this or not.
I am writing an application which I run as my usual user on ubuntu.
the usernake is let's say kk and it has sudo permission (meaning the
user is in the sudoers list ).
now when i do python myscript.py, the script has to change to another
non-privileged user for some tasks.
let's say for example switch to the postgres user which is dedicated for
postgres and has no other privileges.
I have tryed doing os.setuid(112) where 112 could be the uid of the user
I want the script to swith over.
but I got opperation not permitted.
I tryed using subprocess but that did not help me either. I tryed sudo
su into the Popen command but it throws me into the terminal (shell)
with postgres as the user.
But that's now my desired result.
what I exactly want is that the script now continues to execute under
postgres user till the end.
I don't know how to achieve this iffect.
Infact I will need this during a serious deployment because i would have
my application run as a demon as a dedicated user.
I am finding some code for deamonising a python application but don't
know how to tell the script to change user.
happy hacking.
Krishnakant.