changeing users on linux

Discussion in 'Python' started by darkchild50@gmail.com, Nov 12, 2005.

  1. Guest

    how would i go about makeing a program in python that asks for username
    and password and changes to that user?
     
    , Nov 12, 2005
    #1
    1. Advertising

  2. Mike Meyer Guest

    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 <> http://www.mired.org/home/mwm/
    Independent WWW/Perforce/FreeBSD/Unix consultant, email for more information.
     
    Mike Meyer, Nov 12, 2005
    #2
    1. Advertising

  3. Guest

    the password is for loging into root
     
    , Nov 12, 2005
    #3
  4. Guest

    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 12, 2005
    #4
  5. Mike Meyer Guest

    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 <> http://www.mired.org/home/mwm/
    Independent WWW/Perforce/FreeBSD/Unix consultant, email for more information.
     
    Mike Meyer, Nov 12, 2005
    #5
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. ADRIAN

    Changeing Stylesheets

    ADRIAN, Nov 5, 2003, in forum: ASP .Net
    Replies:
    0
    Views:
    373
    ADRIAN
    Nov 5, 2003
  2. =?Utf-8?B?TGVpZg==?=

    Reaching/changeing Parameter Value in Java Applet

    =?Utf-8?B?TGVpZg==?=, Dec 6, 2004, in forum: ASP .Net
    Replies:
    3
    Views:
    1,613
    =?Utf-8?B?TGVpZg==?=
    Dec 7, 2004
  3. Gabriele Farina
    Replies:
    0
    Views:
    293
    Gabriele Farina
    Feb 20, 2004
  4. Gabriele Farina

    [wxPython] changeing border color

    Gabriele Farina, May 11, 2004, in forum: Python
    Replies:
    0
    Views:
    533
    Gabriele Farina
    May 11, 2004
  5. Matthew Webster

    Changeing color of cell of grid

    Matthew Webster, Apr 7, 2007, in forum: ASP .Net Datagrid Control
    Replies:
    1
    Views:
    721
    kingflux
    Apr 7, 2007
Loading...

Share This Page