There already exists a tool that does this, use it. --- This is a suggestion; the patch may not actually work, as socket-sucker only read 256 bytes (why 256?) while socat will read until EOF. debian/control | 1 + socket-sucker.c | 80 ------------------------------------------------------- x2go-session.in | 7 ++--- 3 files changed, 5 insertions(+), 83 deletions(-) delete mode 100644 socket-sucker.c diff --git a/debian/control b/debian/control index df11b2e..f0b2e36 100644 --- a/debian/control +++ b/debian/control @@ -19,6 +19,7 @@ Architecture: any Depends: ${shlibs:Depends}, ${misc:Depends}, + socat, zenity, pyhoca-cli (>= 0.2.1.0-0~), libpam-x2go, diff --git a/socket-sucker.c b/socket-sucker.c deleted file mode 100644 index 403819b..0000000 --- a/socket-sucker.c +++ /dev/null @@ -1,80 +0,0 @@ -/* - * Copyright © 2012 Mike Gabriel <mike.gabriel@das-netzwerkteam.de> - * 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: Mike Gabriel <mike.gabriel@das-netzwerkteam.de> - * Author libpam-freerdp (where we forked from): 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; - - int printsize = snprintf(serv_addr.sun_path, sizeof(serv_addr.sun_path) - 1, "%s/%s", home, ".x2go-socket"); - if (printsize > sizeof(serv_addr.sun_path) - 1 || printsize < 0) { - return -1; - } - - 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); - - if (in > 0) { - out = write(1, buffer, in); - } - - close(socket_fd); - - if (in > 0 && out > 0 && in == out) { - return 0; - } else { - return -1; - } -} - diff --git a/x2go-session.in b/x2go-session.in index 7466509..1b3c739 100755 --- a/x2go-session.in +++ b/x2go-session.in @@ -20,10 +20,11 @@ # Author lightdm-remote-session-freerdp (where we forked from): Ted Gould <ted@canonical.com> # -if [ -e ~/.x2go-socket ]; then - @libexecdir@/socket-sucker | /usr/bin/pyhoca-cli --from-stdin --add-to-known-hosts --kbd-type auto --sound pulse 2>&1 | logger -t lightdm-remote-session-x2go -- +socket="$HOME/.x2go-socket"; +if [ -e "$socket" ]; then + socat unix-connect:"$socket" - | /usr/bin/pyhoca-cli --from-stdin --add-to-known-hosts --kbd-type auto --sound pulse 2>&1 | logger -t lightdm-remote-session-x2go -- else zenity --warning --text="Unable to locate X2GoSession/PyHoca socket" fi; -rm -f ~/.x2go-socket +rm -f "$socket" -- 1.7.10.4
On Sunday 2012-11-11 14:01, Nable 80 wrote:
- There is also netcat (nc) and i'm in doubt what is more widespread in basic system installation: netcat or socat.
It is not about what is most spread, but what actually makes sense.
netcat in comparison is messy - https://lkml.org/lkml/2012/8/1/243
- It's better to use `git format-patch' and attach generated files (see "man git-format-patch", it's really easy).
I did use git format-patch (by way of git send-email), see the X-Mailer header. What generated file should be attached? Remember also that (a) attachments are frowned upon and (b) I hear git-am is very pesky in processing mails not in the format of {verbatim format-patch text}.
Hi Jan,
On So 11 Nov 2012 18:34:40 CET Jan Engelhardt wrote:
On Sunday 2012-11-11 14:01, Nable 80 wrote:
- There is also netcat (nc) and i'm in doubt what is more widespread in basic system installation: netcat or socat.
It is not about what is most spread, but what actually makes sense.
netcat in comparison is messy - https://lkml.org/lkml/2012/8/1/243
- It's better to use `git format-patch' and attach generated files (see "man git-format-patch", it's really easy).
I did use git format-patch (by way of git send-email), see the X-Mailer header. What generated file should be attached? Remember also that (a) attachments are frowned upon and (b) I hear git-am is very pesky in processing mails not in the format of {verbatim format-patch text}.
I have two personal preferences on this:
o git format-patch HEAD~N -> creates a series of patch files o attach the single patch files to a mail
o create a public git repos with a branch containing your patches (master branch should be a copy of our master) o send me a pull request by mail
On sending mails with patches...
Most convenient for me it will be to send patches to the X2Go BTS (bug
tracker system).
Mail Template...
""" From: <you> To: submit@bugs.x2go.org Subject: <describe your patch>
Source: <name of X2Go source project, see our Git repos for the project names> Version: <some of the latest tags or HEAD or a package version> Severity: {wishlist,minor,normal,important,serious,grave,critical} Tags: patch
<describe your issue in detail here>
"""
Attach the patch file(s) to this mail.
Greets, Mike
--
DAS-NETZWERKTEAM mike gabriel, rothenstein 5, 24214 neudorf-bornstein fon: +49 (1520) 1976 148
GnuPG Key ID 0x25771B31 mail: mike.gabriel@das-netzwerkteam.de, http://das-netzwerkteam.de
freeBusy: https://mail.das-netzwerkteam.de/freebusy/m.gabriel%40das-netzwerkteam.de.xf...