Ok...
Now...
I made this simple program as a test:
import popen2
r,w,e = popen2.popen3('su -c ls')
for line in e.readlines():
print 'E: ' + line
for line in r.readlines():
print 'R: ' + line
r.close
w.close
e.close
In few words, it runs "su -c ls", and it should tell me what it writes
in stdout and stderr.
Now... this is what i get:
[luca@ATH2000 tmp]$ python test.py
E: standard in must be a tty
So it seems that "su" refuses to work if it is run like this.
Now, beside "sudo" that i CANNOT use because i don't want to change the
configuration of the user's comp... any idea about how i could run a
program as root from inside my python program?
Thanx,
Luca 8 2054
Can someone tell me if 4Suite Domlette works correctly with Unicode paths?
This would be on Windows and on OS X.
On Mon, 15 Mar 2004 20:45:53 -0700, Hamilcar Barca wrote: In article <c3*************@ID-99001.news.uni-berlin.de> (Mon, 15 Mar 2004 21:28:47 +0100), Luca T. wrote:
r,w,e = popen2.popen3('su -c ls')
So it seems that "su" refuses to work if it is run like this.
su needs the user's password and it insists on reading it from a tty because it can control echoing.
Maybe pexpect can help you here. It works great on linux.
Simon.
Am Mon, 15 Mar 2004 21:28:47 +0100 schrieb Luca T.: So it seems that "su" refuses to work if it is run like this. Now, beside "sudo" that i CANNOT use because i don't want to change the configuration of the user's comp... any idea about how i could run a program as root from inside my python program?
Hi,
write a little C programm and make it setuid root.
Scripts cannot be setuid.
Be carefull, there are a many things you need to
make it secure. Maybe suexec of apache can be
used as template.
HTH,
Thomas
In article <c3*************@ID-99001.news.uni-berlin.de> (Mon, 15 Mar 2004
21:28:47 +0100), Luca T. wrote: r,w,e = popen2.popen3('su -c ls')
So it seems that "su" refuses to work if it is run like this.
su needs the user's password and it insists on reading it from a tty
because it can control echoing.
any idea about how i could run a program as root from inside my python program?
1) Can you run your program in a shell? The user will still need
root's password.
2) Create a copy of ls and make it suid root. The user will be able
to list the files in any directory -- will this compromise security?
Thomas Guettler wrote: Be carefull, there are a many things you need to make it secure. Maybe suexec of apache can be used as template.
Where can i find its sources?
Thanx,
Luca
Luca T. wrote: Ok... Now... I made this simple program as a test:
import popen2 r,w,e = popen2.popen3('su -c ls') for line in e.readlines(): print 'E: ' + line for line in r.readlines(): print 'R: ' + line
r.close w.close e.close
Bug: you are referencing r.close and friends, but not actually calling
them. Python is not VB (or Pascal, etc), so you *must* include the
parentheses to make a method call:
r.close()
w.close()
e.close()
PyChecker can warn about such things, and many others.
-Peter
Peter Hansen wrote: Bug: you are referencing r.close and friends, but not actually calling them. Python is not VB (or Pascal, etc), so you *must* include the parentheses to make a method call:
r.close() w.close() e.close()
Thank you
PyChecker can warn about such things, and many others.
I'll search for it
Thanx again,
Luca
Am Tue, 16 Mar 2004 19:08:52 +0100 schrieb Luca T.: Thomas Guettler wrote:
Be carefull, there are a many things you need to make it secure. Maybe suexec of apache can be used as template.
Where can i find its sources?
I don't know, but google does: http://www.google.de/search?q=suexec.c
HTH,
Thomas This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Brandon J. Van Every |
last post by:
What's better about Ruby than Python? I'm sure there's something. What is
it?
This is not a troll. I'm language shopping and I want people's answers. I
don't know beans about Ruby or have...
|
by: Luca T. |
last post by:
Hello,
i need some answers...
1) I need to run some linux commands (from inside my app) that require
superuser privileges (mkfs, losetup, etc), how do i do that? (I do not
want to run my app...
|
by: james blair |
last post by:
Hi
I have a search page & the reults for the search are fetched from the
database.
I want that on the results page only first 25 results are shown & a
link "next 25 results" be shown.Same for the...
|
by: Maurice LING |
last post by:
This may be a dumb thing to ask, but besides the penalty for dynamic
typing, is there any other real reasons that Python is slower than Java?
maurice
|
by: Ron Guerin |
last post by:
The New York Linux User's Group invites you to a special presentation
by Alex Martelli of Google, on the Python Object Model. This
presentation will be held at P.J. Clarke's Sidecar, rather than...
|
by: Ron Guerin |
last post by:
(date and time inadvertently omitted last time. sorry!)
The New York Linux User's Group invites you to a special presentation
by Alex Martelli of Google, on the Python Object Model. This...
|
by: Sandeep |
last post by:
Hi,
I want to read & print a UTF-8 encoded characters stored in a file.
I want to write a C program on Linux platform to achieve
this.
I am new to UTF-8.
I will appreciate any sample...
|
by: James Stroud |
last post by:
Hello All,
I have been trying to make an https client with python, but it seems
that, to do this, one needs to have the socket module compiled with ssl.
This is not the default. So I have a...
|
by: Anthony Irwin |
last post by:
Hi All,
I am currently trying to decide between using python or java and have
a few quick questions about python that you may be able to help with.
#1 Does python have something like javas...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: aa123db |
last post by:
Variable and constants
Use var or let for variables and const fror constants.
Var foo ='bar';
Let foo ='bar';const baz ='bar';
Functions
function $name$ ($parameters$) {
}
...
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
| | |