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 2061
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 any preconceived ideas about it. I have
noticed, however, that every programmer I talk to who's aware of Python is
also talking about Ruby. So it seems that Ruby has the potential to compete
with and displace Python. I'm curious on what basis it...
|
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 with root privileges, but it will just ask the user
for the root password before proceeding)
2) When i execute the command i need to read its output (especially the
error messages) to know if everything went fine but i do not know how :(
3) How can...
|
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 2nd result page.
How do I do this?
|
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 our
usual location, and Google is picking up the tab for an hour and a half
of open bar and food. Additionally, if you're looking for a job as a
Python developer, bring your resume.
Please RSVP at http://rsvp.nylug.org to attend, as seating is...
| |
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
presentation will be held at P.J. Clarke's Sidecar, rather than our
usual location, and Google is picking up the tab for an hour and a half
of open bar and food. Additionally, if you're looking for a job as a
Python developer, bring your resume.
...
|
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 programs OR guidance on this.
Thanks in advance,
|
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 couple of questions.
1. Where do I specify to compile socket with ssl? I found no
obvious option in configure or setup.py or several other
files I checked.
2. Is there a way to do this without re-compiling all of python?
|
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 .jar packages. A jar file
contains all the program files and you can execute the program with
java -jar program.jar
I am sort of hoping python has something like this because I feel it
|
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
| |
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| | |