Skip to content
Browse files

Add in the xhost authentication routine when logging in a user. This …

…will allow the user access to the display. Also fix the authorization file cleanup between sessions of PCDM.
  • Loading branch information...
1 parent 7257d51 commit 6449f614251c0c1ad686beb4ae92203fa25d73d7 @beanpole135 beanpole135 committed Nov 4, 2013
Showing with 15 additions and 10 deletions.
  1. +7 −5 src-qt4/PCDM/PCDMd
  2. +0 −3 src-qt4/PCDM/src/main.cpp
  3. +8 −2 src-qt4/PCDM/src/pcdm-xprocess.cpp
View
12 src-qt4/PCDM/PCDMd
@@ -35,14 +35,16 @@ fi
# Allow Auto-Login the first time PCDM starts
touch /tmp/.PCDMAutoLogin
-# Make sure the authorization file exists
-setenv XAUTHORITY ${PCDMAUTHFILE} #Set the auth file location
-touch ${PCDMAUTHFILE} #Create the authorication file
-xauth add :0 MIT-MAGIC-COOKIE-1 1234567890 #Add a default entry to the file (will randomize it later)
# Now start the X Server
while [ ! -e /var/run/nologin ]; do
/usr/local/bin/pc-checkxdisplay
-
+ # Make sure the authorization file does not exist
+ if [ -f ${PCDMAUTHFILE} ]; then
+ rm ${PCDMAUTHFILE}
+ fi
+ setenv XAUTHORITY ${PCDMAUTHFILE} #Set the auth file location
+ touch ${PCDMAUTHFILE} #Create the (empty) authorization file
+ xauth add :0 MIT-MAGIC-COOKIE-1 1234567890 #Add a default entry to the file (will randomize it later)
if [ -n "$vnccmd" ] ; then
# Start VNC
(sleep 10 ; $vnccmd >/var/log/vncserver 2>/var/log/vncserver) &
View
3 src-qt4/PCDM/src/main.cpp
@@ -172,8 +172,6 @@ int main(int argc, char *argv[])
while(neverquit){
if(runonce){ neverquit = FALSE; }
qDebug() << " -- PCDM Session Starting...";
- system("xauth -f "+TMPAUTHFILE.toUtf8()+" generate :0 ."); //Using MIT-MAGIC-COOKIE-1 protocol
- //MIT-MAGIC-COOKIE-1 is good enough for our purposes since it is a single-user graphical system with no XDMCP
int sid = -1;
int pid = fork();
if(pid < 0){
@@ -199,6 +197,5 @@ int main(int argc, char *argv[])
qDebug() << "-- PCDM Session Ended --";
if(QFile::exists("/var/run/nologin")){ neverquit = FALSE; }
}
- system("xauth -f "+TMPAUTHFILE.toUtf8()+" remove :0");
return 0;
}
View
10 src-qt4/PCDM/src/pcdm-xprocess.cpp
@@ -94,7 +94,10 @@ bool XProcess::startXSession(){
// Get the environment before we drop priv
QProcessEnvironment environ = QProcessEnvironment::systemEnvironment(); //current environment
-
+ //Now allow this user access to the Xserver
+ QString xhostcmd = "xhost si:localuser:"+xuser;
+ system(xhostcmd.toUtf8());
+
//QWidget *wid = new QWidget();
if (setgid(pw->pw_gid) < 0) {
qDebug() << "setgid() failed!";
@@ -163,7 +166,10 @@ bool XProcess::startXSession(){
}
void XProcess::slotCleanup(int exitCode, QProcess::ExitStatus status){
- pam_shutdown(); //make sure that PAM shuts down properly
+ pam_shutdown(); //make sure that PAM shuts down properly
+ //Now remove this user's access to the Xserver
+ QString xhostcmd = "xhost -si:localuser:"+xuser;
+ system(xhostcmd.toUtf8());
}
//Start the desktop in the current process with C functions

0 comments on commit 6449f61

Please sign in to comment.
Something went wrong with that request. Please try again.