Results 1 to 4 of 4

Thread: After PAM Success help (c or c++)

  1. #1
    Join Date
    Jul 2012
    Beans
    4

    After PAM Success help (c or c++)

    So I have...
    PHP Code:
    #include <security/pam_appl.h>
    #include <security/pam_misc.h>
    #include <stdio.h>

    int main(int argcchar** argv)
    {
       if (
    argc 2) {
          
    fprintf(stderr"Usage: %s <username>\n"argv[0]);
          return 
    1;
       }

       const 
    char*            user argv[1];
       static 
    struct pam_conv pam_conversation = { misc_convNULL };
       
    pam_handle_t*          pamh;

       
    int res pam_start(argv[0], user, &pam_conversation, &pamh);

       if (
    res == PAM_SUCCESS) {
          
    res pam_authenticate(pamh0);
       }

       if (
    res == PAM_SUCCESS) {
          
    res pam_acct_mgmt(pamh0);
       }

       if (
    res == PAM_SUCCESS) {
          
    fprintf(stdout"Authenticated.\n");
        
    system("whoami");
       }
       else {
          
    fprintf(stdout"Not Authenticated.\n");
       }

       
    pam_end(pamhres);

       return 
    res == PAM_SUCCESS 1;

    When my program gets to 'system("whoami");' it returns the user who ran the program. My goal is to spawn a new process of some program that is ran by the authenticated user. Thanks in advance.

  2. #2
    Join Date
    Jul 2012
    Beans
    4

    Re: After PAM Success help (c or c++)

    bump

  3. #3
    Join Date
    Feb 2011
    Location
    Coquitlam, B.C. Canada
    Beans
    2,204
    Distro
    Ubuntu Development Release

    Re: After PAM Success help (c or c++)

    I don't have those pam includes on my computer, so I was unable to try your program towards trying to reply with a good suggestion. However, I was wondering (without testing it myself) if you would want to be using the setuid, setgid, seteuid function calls to achieve what you want.

  4. #4
    Join Date
    Jul 2012
    Beans
    4

    Re: After PAM Success help (c or c++)

    Those libraries are easy to install if you want, anyways I'm not familiar with that could you give me an example of it that works with Pam. If anyone else has another suggestion that may be the more common way PAM aware apps work. Thanks all.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •