From f5e23ba9a51b8262121e91d5f1d0d64627b7b3cf Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 21 Aug 2012 14:12:17 -0500 Subject: Get us a C compiler --- configure.ac | 4 ++++ 1 file changed, 4 insertions(+) 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 ########################### -- cgit v1.2.3 From 0125935a98fe858ee146ad05842f11ad9f2981e2 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 21 Aug 2012 14:14:14 -0500 Subject: Adding in the socket sucker build target --- .bzrignore | 1 + Makefile.am | 5 +++++ socket-sucker.c | 13 +++++++++++++ 3 files changed, 19 insertions(+) create mode 100644 .bzrignore create mode 100644 socket-sucker.c diff --git a/.bzrignore b/.bzrignore new file mode 100644 index 0000000..655e611 --- /dev/null +++ b/.bzrignore @@ -0,0 +1 @@ +socket-sucker diff --git a/Makefile.am b/Makefile.am index de9cedc..d31c18c 100644 --- a/Makefile.am +++ b/Makefile.am @@ -14,6 +14,11 @@ session_startdir = $(pkglibexecdir) session_start_SCRIPTS = \ freerdp-session +libexec_PROGRAMS = \ + socket-sucker +socket_sucker_SOURCES = \ + socket-sucker.c + EXTRA_DIST = \ $(pam_session_DATA) \ freerdp.desktop.in \ diff --git a/socket-sucker.c b/socket-sucker.c new file mode 100644 index 0000000..46af2d6 --- /dev/null +++ b/socket-sucker.c @@ -0,0 +1,13 @@ + +int +main (int argc, char * argv[]) +{ + + + + + + + + +} -- cgit v1.2.3 From 3541e56c2790c309f4f37795109a044e29c0c606 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 21 Aug 2012 14:25:11 -0500 Subject: Filling out the function based on some examples, basic stuff --- socket-sucker.c | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/socket-sucker.c b/socket-sucker.c index 46af2d6..0b1ee27 100644 --- a/socket-sucker.c +++ b/socket-sucker.c @@ -1,13 +1,47 @@ +#include +#include +#include + +#include +#include +#include + +#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)); + serv_addr.sun_family = AF_UNIX; + strcpy(serv_addr.sun_path, "/home/ted/.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; + } } + -- cgit v1.2.3 From 7c3a571168e3bef61b689524937af89e7efb07b0 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 21 Aug 2012 14:30:41 -0500 Subject: Getting the directory using the home environment variable --- socket-sucker.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/socket-sucker.c b/socket-sucker.c index 0b1ee27..b5fb543 100644 --- a/socket-sucker.c +++ b/socket-sucker.c @@ -17,11 +17,16 @@ main (int argc, char * argv[]) bzero((char *)&serv_addr, sizeof(serv_addr)); + const char * home = getenv("HOME"); + if (home == NULL) { + return -1; + } + serv_addr.sun_family = AF_UNIX; - strcpy(serv_addr.sun_path, "/home/ted/.freerdp-socket"); + 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) { + if ((socket_fd = socket(AF_UNIX, SOCK_STREAM, 0)) < 0) { return -1; } -- cgit v1.2.3 From 63a029387ff06639f3261439a219f19a31eb36a1 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 21 Aug 2012 14:34:12 -0500 Subject: Making the session call the socket sucker --- Makefile.am | 9 +++++++-- freerdp-session | 7 ------- freerdp-session.in | 9 +++++++++ 3 files changed, 16 insertions(+), 9 deletions(-) delete mode 100755 freerdp-session create mode 100755 freerdp-session.in diff --git a/Makefile.am b/Makefile.am index d31c18c..3d9a94a 100644 --- a/Makefile.am +++ b/Makefile.am @@ -14,6 +14,10 @@ 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 = \ @@ -22,10 +26,11 @@ socket_sucker_SOURCES = \ 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/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 -- cgit v1.2.3 From f1e05803b75bf6481f4cd6cc954320073674388b Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 21 Aug 2012 14:45:12 -0500 Subject: Ignoring some more stuff. --- .bzrignore | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.bzrignore b/.bzrignore index 655e611..127de56 100644 --- a/.bzrignore +++ b/.bzrignore @@ -1 +1,5 @@ socket-sucker +freerdp-session +freerdp.desktop +compile +.deps -- cgit v1.2.3 From 60c71fb063ea39a6324097b30f1e58dd3e8e734c Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 21 Aug 2012 14:50:28 -0500 Subject: Copyright header --- socket-sucker.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/socket-sucker.c b/socket-sucker.c index b5fb543..7a1e82f 100644 --- a/socket-sucker.c +++ b/socket-sucker.c @@ -1,3 +1,21 @@ +/* + * 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 . + * + * Author: Ted Gould + */ + #include #include #include -- cgit v1.2.3