Re: Change from one user to another in program.

From: Barry Margolin (barry.margolin_at_level3.com)
Date: 05/30/03

  • Next message: v_sridhar: "Re: file locking question"
    Date: Thu, 29 May 2003 22:28:35 GMT
    
    

    In article <3ED6872A.1CE339B0@quest.com>,
    Fletcher Glenn <f-g-l-e-n-n@quest.com> wrote:
    >It's laughably easy for the root user to change its
    >user ID from within a program. This of course is not
    >true for an ordinary user. Given that I have the username
    >and password for the target identity, how do I use this
    >information to execute as this target user from within
    >a program.
    >
    >I've tried a number of approaches, from fork/exec()ing su
    >to opening a pty. Every approach I take runs into a
    >snag where all of the authentication API's require that
    >submission of the password come from a genuine terminal,
    >or a child of a direct login. Does anyone have a method
    >that actually works from a daemon program (not running
    >as root)? The method needs to work even if the
    >target user is root, which rules out the idea of a
    >loopback rlogin. Not every system will allow a non-console
    >login from root.

    Running su through a pty should work -- a pty is considered a "genuine
    terminal" (if it weren't, you wouldn't be able to use su in an xterm or
    remote login session).

    -- 
    Barry Margolin, barry.margolin@level3.com
    Level(3), Woburn, MA
    *** DON'T SEND TECHNICAL QUESTIONS DIRECTLY TO ME, post them to newsgroups.
    Please DON'T copy followups to me -- I'll assume it wasn't posted to the group.
    

  • Next message: v_sridhar: "Re: file locking question"

    Relevant Pages

    • SUMARY: Cant login as root
      ... As a result, i was not able to log in as root, neither create a new ... Asunto: RE: Can't login as root ... > console. ... > If we log as any other user everythig is ok, but we cannot either do su-. ...
      (Tru64-UNIX-Managers)
    • RE: Urgent help needed with Login problems after installation of FC1
      ... symptom trying to su back to root. ... After another minimal install, I was able to add my user and su to it and su ... I was unable to boot using the boot floppy. ... I did a minimal install and was able to login as root, ...
      (Fedora)
    • Re: BSM, SSH, and Session ID
      ... Are you logging in as root through ssh or is that just the way it is ... Sun SSH/OpenSSH should fork off before the login because the sshd ... It should always be a different session, ...
      (Focus-SUN)
    • Re: Urgent help needed with Login problems after installation of FC1
      ... login would do anything but loop back to the Login: ... >From Gnome desktop, I was able to logout user, login root, over and ... Am able to boot from floppy. ... >After another minimal install, I was able to add my user and su to ...
      (Fedora)
    • Re: i can not log as a root
      ... >> how i can log as a user but not as a root. ... > Problem seems to be with the X session not your login but we'll try a few ... > select the OS/kernel that you boot to, ... > Looks like something is wrong with your Xsessions script or one of the ...
      (linux.redhat)