summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKoichiro IWAO <meta@vmeta.jp>2017-07-12 17:48:00 +0900
committermetalefty <meta@vmeta.jp>2017-09-13 09:04:58 +0900
commit26394870e5bd03e6ee15fa6083b2067b9c9106d2 (patch)
tree841e193c615920c180cb405024ea0eb01208ba60
parentdf29ea3ad970833eb91dbc309a8a0190a37ac2a5 (diff)
downloadxrdp-proprietary-26394870e5bd03e6ee15fa6083b2067b9c9106d2.tar.gz
xrdp-proprietary-26394870e5bd03e6ee15fa6083b2067b9c9106d2.zip
sesman: delete socket files when session exits
-rw-r--r--sesman/session.c63
-rw-r--r--sesman/session.h7
2 files changed, 70 insertions, 0 deletions
diff --git a/sesman/session.c b/sesman/session.c
index f2dc087d..ae3194da 100644
--- a/sesman/session.c
+++ b/sesman/session.c
@@ -796,6 +796,7 @@ session_start_fork(tbus data, tui8 type, struct SCP_CONNECTION *c,
auth_end(data);
g_sigterm(display_pid);
g_sigterm(chansrv_pid);
+ cleanup_sockets(display);
g_deinit();
g_exit(0);
}
@@ -1116,3 +1117,65 @@ session_get_byuser(const char *user, int *cnt, unsigned char flags)
(*cnt) = count;
return sess;
}
+
+/******************************************************************************/
+int
+cleanup_sockets(int display)
+{
+ log_message(LOG_LEVEL_DEBUG, "cleanup_sockets:");
+ char file[256];
+ int error;
+
+ error = 0;
+
+ g_snprintf(file, 255, CHANSRV_PORT_OUT_STR, display);
+ if (g_file_exist(file))
+ {
+ log_message(LOG_LEVEL_DEBUG, "cleanup_sockets: deleting %s", file);
+ if (g_file_delete(file) == 0)
+ {
+ log_message(LOG_LEVEL_DEBUG,
+ "cleanup_sockets: failed to delete %s", file);
+ error++;
+ }
+ }
+
+ g_snprintf(file, 255, CHANSRV_PORT_IN_STR, display);
+ if (g_file_exist(file))
+ {
+ log_message(LOG_LEVEL_DEBUG, "cleanup_sockets: deleting %s", file);
+ if (g_file_delete(file) == 0)
+ {
+ log_message(LOG_LEVEL_DEBUG,
+ "cleanup_sockets: failed to delete %s", file);
+ error++;
+ }
+ }
+
+ g_snprintf(file, 255, XRDP_CHANSRV_STR, display);
+ if (g_file_exist(file))
+ {
+ log_message(LOG_LEVEL_DEBUG, "cleanup_sockets: deleting %s", file);
+ if (g_file_delete(file) == 0)
+ {
+ log_message(LOG_LEVEL_DEBUG,
+ "cleanup_sockets: failed to delete %s", file);
+ error++;
+ }
+ }
+
+ g_snprintf(file, 255, CHANSRV_API_STR, display);
+ if (g_file_exist(file))
+ {
+ log_message(LOG_LEVEL_DEBUG, "cleanup_sockets: deleting %s", file);
+ if (g_file_delete(file) == 0)
+ {
+ log_message(LOG_LEVEL_DEBUG,
+ "cleanup_sockets: failed to delete %s", file);
+ error++;
+ }
+ }
+
+ return error;
+
+}
diff --git a/sesman/session.h b/sesman/session.h
index a9884a21..10cd4d57 100644
--- a/sesman/session.h
+++ b/sesman/session.h
@@ -150,4 +150,11 @@ session_get_bypid(int pid);
struct SCP_DISCONNECTED_SESSION*
session_get_byuser(const char *user, int *cnt, unsigned char flags);
+/**
+ *
+ * @brief delete socket files
+ * @param display number
+ * @return non-zero value (number of errors) if failed
+ */
+int cleanup_sockets(int display);
#endif