Changeset e949bab


Ignore:
Timestamp:
07/17/13 06:50:49 (15 months ago)
Author:
Kris Moore <kris@…>
Branches:
master, 9.2-release, releng/10.0, releng/10.0.1, releng/10.0.2, releng/10.0.3
Children:
9eeeabd
Parents:
820babc
Message:

Do some more fork() magic, so that we can properly drop priv
and still do the pam_shutdown functions as root.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src-qt4/PCDM/src/pcdm-xprocess.cpp

    r820babc re949bab  
    77 
    88#include <sys/types.h> 
     9#include <sys/wait.h> 
    910#include <unistd.h> 
    1011#include <pwd.h> 
     
    176177  //Save the current user/desktop as the last login 
    177178  Backend::saveLoginInfo(Backend::getDisplayNameFromUsername(xuser),xde); 
     179 
     180  // We will now fork off, so the child can drop root perms and do its thing 
     181  int pid = fork(); 
     182  if(pid < 0){ 
     183    Backend::log("Error: Could not fork for user permissions"); 
     184    return; 
     185  }else if( pid !=0 ){ 
     186    //Parent (calling) process 
     187    int status; 
     188    sleep(2); 
     189    waitpid(pid,&status,0); //wait for the child (session) to finish 
     190 
     191    // Child is all done, lets close down the pam session and cleanup 
     192    pam_shutdown(); 
     193    exit(0); 
     194  } 
    178195   
    179196  // Get the users uid/gid information 
     
    243260    
    244261  //Now start the process 
    245   qDebug() << "Start the desktop"; 
    246262  system(cmd.toLatin1()); 
    247   pam_close_session(pamh, 0); 
    248   pam_end(pamh, PAM_SUCCESS); 
    249263} 
    250264 
Note: See TracChangeset for help on using the changeset viewer.