473,394 Members | 1,735 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

changeing users on linux

how would i go about makeing a program in python that asks for username
and password and changes to that user?

Nov 22 '05 #1
4 963
da*********@gmail.com writes:
how would i go about makeing a program in python that asks for username
and password and changes to that user?


For some definition of "changes to that user":

# Untested code
from pwd import getpwnam
from os import setuid

setuid(getpwnam(raw_input("Who do you want to be? "))[2])

I don't recommend the one-liner version for production code, though.
You didn't say what the password was for, so I skipped asking for it.

<mike
--
Mike Meyer <mw*@mired.org> http://www.mired.org/home/mwm/
Independent WWW/Perforce/FreeBSD/Unix consultant, email for more information.
Nov 22 '05 #2
the password is for loging into root

Nov 22 '05 #3
On Fri, Nov 11, 2005 at 11:25:56PM -0500, Mike Meyer wrote:
You didn't say what the password was for, so I skipped asking for it.


You're a real comedian.

Jeff

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.1 (GNU/Linux)

iD8DBQFDdgLGJd01MZaTXX0RAmHuAKCdA34dZKcLDdH0pshC4u/PTx5OVwCcDy9e
N0h3ihmTgKrJtdGwRy8Dfcc=
=Pkm2
-----END PGP SIGNATURE-----

Nov 22 '05 #4
da*********@gmail.com writes:
the password is for loging into root


The setuid call will fail unless you're already root. You can't, as
some user other than root, change your userid, so the answer to
the original question with the added restriction is "You can't".

<mike
--
Mike Meyer <mw*@mired.org> http://www.mired.org/home/mwm/
Independent WWW/Perforce/FreeBSD/Unix consultant, email for more information.
Nov 22 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Geiregat Jonas | last post by:
I'm running a linux system I would like to create a login system based upon the users and passwd of my linux box how could I do this ?
5
by: nmac | last post by:
Hi all, hopefully someone can offer some sagely advice regarding Production use of Jakarta's Tomcat. First, some brief background. My company have a servlet application that connects to a MySQL...
24
by: Jim Hubbard | last post by:
Anybody know?
10
by: Gerald | last post by:
I'm new to DB2, I have over 10 years of experience on Oracle. I actually have to books on order that might help. Till then I have been searching and reading through IBM's DB2 Information Center,...
9
by: jab3 | last post by:
So I'm considering a small project that involves online file storage. Let's say I wanted to set up a site that allows people to log-on, create an account, and then have space to upload files. The...
5
by: rAinDeEr | last post by:
Hi, Y'day one of my friend showed me how to connect to a Oracle database as SYSDBA, DBA etc I have DB2 UDB installed in Linux machine.Right now, I have a user WADI which has got some...
20
by: Ramdas | last post by:
How do I add users using Python scripts on a Linux machine? Someone has a script?
3
by: mejpark | last post by:
Good afternoon PHPers, This morning I downloaded "PHP Users" from sourceforge to implement a user registration system. I followed the instructions in INSTALL.txt, and successfully configured...
2
hsn
by: hsn | last post by:
hello everyone i have been trying for a while to use linux, for a certain personal reason, i am not able to use linux. i want the opinion of programmers and users of mac. is mac the same as linux...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
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
0
BarryA
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...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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...
0
Oralloy
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,...
0
jinu1996
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...
0
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...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.