aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.bzrignore5
-rw-r--r--Makefile.am14
-rw-r--r--configure.ac4
-rwxr-xr-xfreerdp-session7
-rwxr-xr-xfreerdp-session.in9
-rw-r--r--socket-sucker.c70
6 files changed, 100 insertions, 9 deletions
diff --git a/.bzrignore b/.bzrignore
new file mode 100644
index 0000000..127de56
--- /dev/null
+++ b/.bzrignore
@@ -0,0 +1,5 @@
+socket-sucker
+freerdp-session
+freerdp.desktop
+compile
+.deps
diff --git a/Makefile.am b/Makefile.am
index de9cedc..3d9a94a 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -14,13 +14,23 @@ session_startdir = $(pkglibexecdir)
session_start_SCRIPTS = \
freerdp-session
+freerdp-session: freerdp-session.in
+ @sed -e "s|\@pkglibexecdir\@|$(pkglibexecdir)|" $< > $@
+ @chmod +x $@
+
+libexec_PROGRAMS = \
+ socket-sucker
+socket_sucker_SOURCES = \
+ socket-sucker.c
+
EXTRA_DIST = \
$(pam_session_DATA) \
freerdp.desktop.in \
- freerdp-session
+ freerdp-session.in
CLEANFILES = \
- freerdp.desktop
+ freerdp.desktop \
+ freerdp-session
DISTCHECK_CONFIGURE_FLAGS = --enable-localinstall
diff --git a/configure.ac b/configure.ac
index d204988..b4f3885 100644
--- a/configure.ac
+++ b/configure.ac
@@ -3,6 +3,10 @@ AC_INIT([lightdm-remote-session-freerdp], [0.1])
AM_INIT_AUTOMAKE([1.11 -Wno-portability])
AM_SILENT_RULES([yes])
+AC_PROG_CC
+AC_PROG_INSTALL
+AM_PROG_CC_C_O
+
###########################
# Local Install
###########################
diff --git a/freerdp-session b/freerdp-session
deleted file mode 100755
index d304a98..0000000
--- a/freerdp-session
+++ /dev/null
@@ -1,7 +0,0 @@
-#!/bin/bash
-
-if [ -e ~/.freerdp-socket ]; then
- cat ~/.freerdp-socket | /usr/bin/xfreerdp --plugin rdpsnd.so --no-nla -f --from-stdin
-else
- zenity --warning --text="Unable to locate FreeRDP socket"
-fi;
diff --git a/freerdp-session.in b/freerdp-session.in
new file mode 100755
index 0000000..8868336
--- /dev/null
+++ b/freerdp-session.in
@@ -0,0 +1,9 @@
+#!/bin/bash
+
+if [ -e ~/.freerdp-socket ]; then
+ @pkglibexecdir@/socket-sucker | /usr/bin/xfreerdp --plugin rdpsnd.so --no-nla -f --from-stdin
+else
+ zenity --warning --text="Unable to locate FreeRDP socket"
+fi;
+
+rm -f ~/.freerdp-socket
diff --git a/socket-sucker.c b/socket-sucker.c
new file mode 100644
index 0000000..7a1e82f
--- /dev/null
+++ b/socket-sucker.c
@@ -0,0 +1,70 @@
+/*
+ * Copyright © 2012 Canonical Ltd.
+ *
+ * This program is free software: you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 3, as
+ * published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranties of
+ * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
+ * PURPOSE. See the GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ * Author: Ted Gould <ted@canonical.com>
+ */
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <unistd.h>
+
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <sys/un.h>
+
+#define BUFFER_SIZE 256
+
+int
+main (int argc, char * argv[])
+{
+ int socket_fd = 0;
+ int servlen = 0;
+ struct sockaddr_un serv_addr;
+
+ bzero((char *)&serv_addr, sizeof(serv_addr));
+
+ const char * home = getenv("HOME");
+ if (home == NULL) {
+ return -1;
+ }
+
+ serv_addr.sun_family = AF_UNIX;
+ snprintf(serv_addr.sun_path, sizeof(serv_addr.sun_path), "%s/%s", home, ".freerdp-socket");
+ servlen = strlen(serv_addr.sun_path) + sizeof(serv_addr.sun_family);
+
+ if ((socket_fd = socket(AF_UNIX, SOCK_STREAM, 0)) < 0) {
+ return -1;
+ }
+
+ if (connect(socket_fd, (struct sockaddr *)&serv_addr, servlen) < 0) {
+ return -1;
+ }
+
+ char buffer[BUFFER_SIZE + 2];
+ int in = 0;
+ int out = 0;
+
+ in = read(socket_fd, buffer, BUFFER_SIZE);
+ out = write(1, buffer, in);
+
+ close(socket_fd);
+
+ if (in == 0) {
+ return 0;
+ } else {
+ return -1;
+ }
+}
+