changeing users on linux

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • darkchild50@gmail.com

    #1

    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?

  • Mike Meyer

    #2
    Re: changeing users on linux

    darkchild50@gma il.com writes:[color=blue]
    > how would i go about makeing a program in python that asks for username
    > and password and changes to that user?[/color]

    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 <mwm@mired.or g> http://www.mired.org/home/mwm/
    Independent WWW/Perforce/FreeBSD/Unix consultant, email for more information.

    Comment

    • darkchild50@gmail.com

      #3
      Re: changeing users on linux

      the password is for loging into root

      Comment

      • jepler@unpythonic.net

        #4
        Re: changeing users on linux

        On Fri, Nov 11, 2005 at 11:25:56PM -0500, Mike Meyer wrote:[color=blue]
        > You didn't say what the password was for, so I skipped asking for it.[/color]

        You're a real comedian.

        Jeff

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

        iD8DBQFDdgLGJd0 1MZaTXX0RAmHuAK CdA34dZKcLDdH0p shC4u/PTx5OVwCcDy9e
        N0h3ihmTgKrJtdG wRy8Dfcc=
        =Pkm2
        -----END PGP SIGNATURE-----

        Comment

        • Mike Meyer

          #5
          Re: changeing users on linux

          darkchild50@gma il.com writes:
          [color=blue]
          > the password is for loging into root[/color]

          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 <mwm@mired.or g> http://www.mired.org/home/mwm/
          Independent WWW/Perforce/FreeBSD/Unix consultant, email for more information.

          Comment

          Working...