diff -Npur xrdp-old/dmx/dmx.c xrdp-new/dmx/dmx.c
--- xrdp-old/dmx/dmx.c	2010-09-20 15:39:21.000000000 +0800
+++ xrdp-new/dmx/dmx.c	2010-09-20 15:55:00.000000000 +0800
@@ -451,6 +451,7 @@ lib_mod_connect_rdp(struct mod* mod)
       return 1;
   }
 
+  g_strncpy(mod->auth_file, auth_file, 255);
   if (lib_mod_setup_auth (mod, screen + 1, auth_data, auth_fd))
       return 1;
 #endif
@@ -1619,6 +1620,7 @@ mod_init(void)
   mod->mod_check_wait_objs = lib_mod_check_wait_objs;
   mod->deflate_level = 0;
   mod->inflate_level = 0;
+  mod->auth_file [0] = '\0';
 
   return mod;
 }
@@ -1631,6 +1633,8 @@ mod_exit(struct mod* mod)
   {
     return 0;
   }
+  if (mod->auth_file [0])
+      unlink(mod->auth_file);
 #ifndef _WIN32
   if (mod->pipefd != 0)
       close (mod->pipefd);
diff -Npur xrdp-old/dmx/dmx.h xrdp-new/dmx/dmx.h
--- xrdp-old/dmx/dmx.h	2010-09-20 15:39:21.000000000 +0800
+++ xrdp-new/dmx/dmx.h	2010-09-20 15:55:04.000000000 +0800
@@ -105,6 +105,7 @@ struct mod
   char ip[256];
   char port[256];
   char hostname[256];
+  char auth_file[256];
   tbus sck_obj;
   int x11_chanid;
   unsigned int x11_output;
diff -Npur xrdp-old/sesman/session.c xrdp-new/sesman/session.c
--- xrdp-old/sesman/session.c	2010-09-20 15:39:21.000000000 +0800
+++ xrdp-new/sesman/session.c	2010-09-20 15:51:46.000000000 +0800
@@ -619,45 +619,44 @@ for user %s denied", username);
 
   ck_cookie = session_ck_open_session (connection, username, display);
 
+#ifndef _WIN32
+  char       auth_file[256];
+  const char *auth_templ = "/tmp/.xrdp-auth-XXXXXX";
+  char       auth_data[AUTH_DATA_LEN];
+  int        auth_fd;
+  int        mask;
+
+  strcpy (auth_file, auth_templ);
+  mask = umask (0077);
+  auth_fd = mkstemp (auth_file);
+  umask (mask);
+
+  if (auth_fd == -1)
+  {
+    log_message(&(g_cfg->log), LOG_LEVEL_ALWAYS,
+          "error - generating unique authorization file");
+    g_exit(1);
+  }
+
+  if (session_setup_auth (screen + 1, auth_data, auth_fd))
+  {
+      g_exit(1);
+  }
+#endif
+
   pid = g_fork();
   if (pid == -1)
   {
   }
   else if (pid == 0) /* child sesman */
   {
-
 #ifndef _WIN32
-    char       auth_file[256];
-    const char *auth_templ = "/tmp/.xrdp-auth-XXXXXX";
-    char       auth_data[AUTH_DATA_LEN];
-    int        auth_fd;
-    int        mask;
-
     close(pipefd[0]);
 #endif
 
     g_unset_signals();
     auth_start_session(data, display);
 
-#ifndef _WIN32
-    strcpy (auth_file, auth_templ);
-    mask = umask (0077);
-    auth_fd = mkstemp (auth_file);
-    umask (mask);
-
-    if (auth_fd == -1)
-    {
-      log_message(&(g_cfg->log), LOG_LEVEL_ALWAYS,
-		  "error - generating unique authorization file");
-      g_exit(1);
-    }
-
-    if (session_setup_auth (screen + 1, auth_data, auth_fd))
-    {
-      g_exit(1);
-    }
-#endif
-    
     if (env_set_user(username, passwd_file, display, auth_file) != 0)
     {
       log_message(&(g_cfg->log), LOG_LEVEL_ALWAYS, "error - set user failed");
@@ -1063,7 +1062,6 @@ for user %s denied", username);
   {
     char status = 0;
     int  len;
-
     /* let the other threads go on */
     scp_lock_fork_release();
 
@@ -1079,10 +1077,12 @@ for user %s denied", username);
     } while (len == -1);
 
     close(pipefd[0]);
+  
 #endif
 
     if (status == 0)
     {
+        unlink(auth_file);
 	g_free(temp->item);
 	g_free(temp);
 	return 0;
@@ -1096,6 +1096,7 @@ for user %s denied", username);
     temp->item->data = data;
     temp->item->ck_cookie = ck_cookie;
     g_strncpy(temp->item->name, username, 255);
+    g_strncpy(temp->item->auth_file, auth_file, 255);
 
     ltime = g_time1();
     gmtime_r(&ltime, &stime);
@@ -1196,6 +1197,7 @@ session_kill(int pid)
 
     if (tmp->item->pid == pid)
     {
+      unlink(tmp->item->auth_file);
       /* deleting the session */
       log_message(&(g_cfg->log), LOG_LEVEL_INFO, "session %d - user %s - terminated",
                   tmp->item->pid, tmp->item->name);
@@ -1253,6 +1255,7 @@ session_sigkill_all()
     }
     else
     {
+      unlink(tmp->item->auth_file);
       g_sigterm(tmp->item->pid);
     }
 
diff -Npur xrdp-old/sesman/session.h xrdp-new/sesman/session.h
--- xrdp-old/sesman/session.h	2010-09-20 15:39:21.000000000 +0800
+++ xrdp-new/sesman/session.h	2010-09-20 15:40:00.000000000 +0800
@@ -60,6 +60,7 @@ struct session_date
 struct session_item
 {
   char name[256];
+  char auth_file[256];
   int pid; /* pid of sesman waiting for wm to end */
   int display;
   int width;
