This is an automated email from the git hooks/post-receive script. x2go pushed a change to branch bugfix/osx in repository x2goclient. discards 9f8f2fa macbuild.sh: when actually bundling libraries, use @executable_path instead of @loader_path. discards 2e460d0 macbuild.sh: add the correct file path to the library bundling array. discards 572b54b macbuild.sh: check current file name against regex, not a (now) full path. discards 2788aac macbuild.sh: use while-read-loop and find to actually recurse through directories. discards d3beb06 macbuild.sh: remove libpulse and libpulsecore from libraries to be bundled, as something else will bundle them anyway. discards f7e47a1 macbuild.sh: add some more debugging output. discards c6c32cc macbuild.sh: directories are "executable", so the first check must explicitly include a check for the argument being not a directory. discards 8c353cb macbuild.sh: add Linux library file name scheme regex as a precaution. discards 6c90ba7 macbuild.sh: add work-in-progress PulseAudio bundling. discards fb964ec macbuild.sh: add phase output for bundling nxproxy. discards 2a09dbb macbuild.sh: copy PulseAudio libraries and binaries. discards d2a92a9 macbuild.sh: define PulseAudio libraries and binaries to be later copied. discards c7194f7 macbuild.sh: add EXE_DIR and FRAMEWORKS_DIR internal variables. discards 37f7251 macbuild.sh: refactor nxproxy detection to use MACPORTS_PREFIX. discards a86eb8a macbuild.sh: add new repeat_str() helper function. discards 4a3bb6c macbuild.sh: add new get_nesting_level() helper function. discards 4b2a9dc macbuild.sh: add new lazy_canonical_path() helper function. discards 22de044 macbuild.sh: add new dependency_error() helper function. discards f7cbc9e macbuild.sh: add new MACPORTS_PREFIX detection/variable. discards 84c290c x2goclient.pro{maemo}: reference new pulsemanager.{cpp,h} files. discards 48ac70a pulsemanager.{cpp,h}: new class for PulseAudio management. discards e9b69e0 compat.h: include QtCore/qglobal.h for Q_OS_... macros. discards 715a650 compat.{cpp,h}: remove inline keyword, because function is not defined in header file. discards ba34af5 compat.{cpp,h}: new files. Implements strndup on OS X 10.6 and below. Add to x2goclient.cpp, x2goclient.pro and x2goclient.pro.maemo. discards 2bb790d onmainwindow.cpp: correctly use ~/.x2go/.ssh as ssh directory when starting sshd in user mode. discards 61c3f6e appdialog.cpp: initialize parent in default case. Another GCC compile warning fix. discards d1e7e83 {appdialog,configwidget,onmainwindow,unixhelper}.cpp: fix some compile warnings with GCC. Fix a few whitespace issues. discards f21f140 x2goclient.cpp: fix failing exec() call for the UNIX helper utility: correctly terminate arguments vector. discards 60afd05 unixhelper.{cpp,h}: ignore SIGINT, SIGTERM, SIGPIPE, SIGQUIT, SIGUSR1 and SIGUSR2. discards b4ab550 {unixhelper.{cpp,h},x2goclient.cpp}: switch main cleanup handling to parent PID polling. discards ecab9b9 unixhelper.{cpp,h}: raise sleeping time to two seconds and grace period to 10 seconds. discards afd5d96 x2goclient.cpp: create new argv array on the heap instead of on the stack. discards d6b20ec x2goclient.cpp: fix string comparison. discards 7a29df4 x2goclient.cpp: fix compile problems introduced with the last commit. discards c3208d9 x2goclient.cpp: don't start the UNIX cleanup helper process right after forking. discards 1cc4567 x2goclient.cpp: clean up. discards 8047975 unixhelper.cpp: port from std::signal() to sigaction(). Handle errors. discards d2bceb8 unixhelper.{cpp,h}: implement signal unblocking in unixhelper::unix_cleanup(). Update documentation. discards 10b99d8 unixhelper.cpp: kill process group on error. discards 4785c57 x2goclient.cpp: return return value of unixhelper::unix_cleanup(). discards 5d1b4bc unixhelper.{cpp,h}: add documentation/comments. discards 2db27cb unixhelper.{cpp,h},x2goclient.cpp}: unixhelper should really be a (module) namespace, not a class. discards 66d55fc unixhelper.h: forgot to declare type of unix_cleanup() function. discards eb15d19 unixhelper.{h,cpp}: also include <QtCore/qglobal.h> to have Q_OS_UNIX defined on UNIX-based platforms. Move guards around. discards 19f900d x2goclient.cpp: fix std::edit -> std::exit typo. discards bf330f3 x2goclient.cpp: add legacy <sys/types.h> header needed for old operating systems. discards d672b86 x2goclient.cpp: add myself to copyright header. discards 98e2fc7 x2goclient.cpp: use setsid() on UNIX to become session and process group leader. discards 0edae66 x2goclient.cpp: add fork_helper() function to start up the UNIX cleanup helper. discards 77d22ee x2goclient.cpp: wrap X2Go Client main function and use that. discards 350c74f unixhelper.{cpp,h}: implement cleanup program for process group. discards 05501a8 {unixhelper.{cpp,h},x2goclient.pro{maemo}}: add unixhelper stub. adds 3030896 onmainwindow.cpp: include sshd PID file path option in quotes to support whitespaces within the var directory path on Windows. adds 4b86435 - xsettingswidget: compile only on Windows. adds 9dea920 Add support for new style command line options of xfreerdp on direct RDP connections. new 23938a1 {unixhelper.{cpp,h},x2goclient.pro{maemo}}: add unixhelper stub. new e5aa19e unixhelper.{cpp,h}: implement cleanup program for process group. new 30e69d0 x2goclient.cpp: wrap X2Go Client main function and use that. new 7f64f1c x2goclient.cpp: add fork_helper() function to start up the UNIX cleanup helper. new d606d37 x2goclient.cpp: use setsid() on UNIX to become session and process group leader. new 9be9eac x2goclient.cpp: add myself to copyright header. new 6f87ddb x2goclient.cpp: add legacy <sys/types.h> header needed for old operating systems. new 0cabc70 x2goclient.cpp: fix std::edit -> std::exit typo. new 6055717 unixhelper.{h,cpp}: also include <QtCore/qglobal.h> to have Q_OS_UNIX defined on UNIX-based platforms. Move guards around. new b26ffe9 unixhelper.h: forgot to declare type of unix_cleanup() function. new 01fe141 unixhelper.{cpp,h},x2goclient.cpp}: unixhelper should really be a (module) namespace, not a class. new 21519f1 unixhelper.{cpp,h}: add documentation/comments. new 8cdbff7 x2goclient.cpp: return return value of unixhelper::unix_cleanup(). new 8d0b24d unixhelper.cpp: kill process group on error. new bfe6964 unixhelper.{cpp,h}: implement signal unblocking in unixhelper::unix_cleanup(). Update documentation. new 8372dc0 unixhelper.cpp: port from std::signal() to sigaction(). Handle errors. new 959ba52 x2goclient.cpp: clean up. new 75704cf x2goclient.cpp: don't start the UNIX cleanup helper process right after forking. new d71388c x2goclient.cpp: fix compile problems introduced with the last commit. new 0c320ea x2goclient.cpp: fix string comparison. new 7fd60df x2goclient.cpp: create new argv array on the heap instead of on the stack. new 9583dbf unixhelper.{cpp,h}: raise sleeping time to two seconds and grace period to 10 seconds. new c43d87b {unixhelper.{cpp,h},x2goclient.cpp}: switch main cleanup handling to parent PID polling. new 1ab6491 unixhelper.{cpp,h}: ignore SIGINT, SIGTERM, SIGPIPE, SIGQUIT, SIGUSR1 and SIGUSR2. new e98c57a x2goclient.cpp: fix failing exec() call for the UNIX helper utility: correctly terminate arguments vector. new e192300 {appdialog,configwidget,onmainwindow,unixhelper}.cpp: fix some compile warnings with GCC. Fix a few whitespace issues. new 80fa020 appdialog.cpp: initialize parent in default case. Another GCC compile warning fix. new 3d26d11 onmainwindow.cpp: correctly use ~/.x2go/.ssh as ssh directory when starting sshd in user mode. new d4e6a8b compat.{cpp,h}: new files. Implements strndup on OS X 10.6 and below. Add to x2goclient.cpp, x2goclient.pro and x2goclient.pro.maemo. new bde5c45 compat.{cpp,h}: remove inline keyword, because function is not defined in header file. new b5dd59e compat.h: include QtCore/qglobal.h for Q_OS_... macros. new 22d979b pulsemanager.{cpp,h}: new class for PulseAudio management. new 3676beb x2goclient.pro{maemo}: reference new pulsemanager.{cpp,h} files. new fff62fd macbuild.sh: add new MACPORTS_PREFIX detection/variable. new f038243 macbuild.sh: add new dependency_error() helper function. new a346759 macbuild.sh: add new lazy_canonical_path() helper function. new 4f281dc macbuild.sh: add new get_nesting_level() helper function. new 39e2cd4 macbuild.sh: add new repeat_str() helper function. new 535a5a9 macbuild.sh: refactor nxproxy detection to use MACPORTS_PREFIX. new 41e18a9 macbuild.sh: add EXE_DIR and FRAMEWORKS_DIR internal variables. new 7d95320 macbuild.sh: define PulseAudio libraries and binaries to be later copied. new efd11d0 macbuild.sh: copy PulseAudio libraries and binaries. new 58ff744 macbuild.sh: add phase output for bundling nxproxy. new 60d2f0d macbuild.sh: add work-in-progress PulseAudio bundling. new a5167c9 macbuild.sh: add Linux library file name scheme regex as a precaution. new 9e6beb5 macbuild.sh: directories are "executable", so the first check must explicitly include a check for the argument being not a directory. new b0eff41 macbuild.sh: add some more debugging output. new 6ac3db5 macbuild.sh: remove libpulse and libpulsecore from libraries to be bundled, as something else will bundle them anyway. new e812965 macbuild.sh: use while-read-loop and find to actually recurse through directories. new 1bd0b49 macbuild.sh: check current file name against regex, not a (now) full path. new f0f7462 macbuild.sh: add the correct file path to the library bundling array. new bd9f3ff macbuild.sh: when actually bundling libraries, use @executable_path instead of @loader_path. new 9e47d18 macbuild.sh: fix echo call to also show the intermediate lib dir, not just the library file name. new d4e5e68 macbuild.sh: also install libraries into staging area with intermediate library path. new af6322e deduplicate.sh: add new, more or less Proof of Concept, and Work in Progress file deduplication script. This update added new revisions after undoing existing revisions. That is to say, some revisions that were in the old version of the branch are not in the new version. This situation occurs when a user --force pushes a change and generates a repository containing something like this: * -- * -- B -- O -- O -- O (9f8f2fa) \ N -- N -- N refs/heads/bugfix/osx (af6322e) You should already have received notification emails for all of the O revisions, and so the following emails describe only the N revisions from the common base, B. Any revisions marked "omits" are not gone; other references still refer to them. Any revisions marked "discards" are gone forever. The 55 revisions listed above as "new" are entirely new to this repository and will be described in separate emails. The revisions listed as "adds" were already present in the repository and have only been added to this reference. Summary of changes: debian/changelog | 15 +++++++++ deduplicate.sh | 79 ++++++++++++++++++++++++++++++++++++++++++++ macbuild.sh | 6 ++-- src/onmainwindow.cpp | 84 ++++++++++++++++++++++++++++++++--------------- src/settingswidget.cpp | 72 ++++++++++++++++++++++++++++++---------- src/settingswidget.h | 3 +- src/xsettingswidget.cpp | 4 +-- src/xsettingswidget.h | 3 +- 8 files changed, 216 insertions(+), 50 deletions(-) create mode 100755 deduplicate.sh -- Alioth's /srv/git/code.x2go.org/x2goclient.git//..//_hooks_/post-receive-email on /srv/git/code.x2go.org/x2goclient.git
This is an automated email from the git hooks/post-receive script. x2go pushed a commit to branch bugfix/osx in repository x2goclient. commit e5aa19e8d6c4e828a468a36fc5b17e0229484e7f Author: Mihai Moldovan <ionic@ionic.de> Date: Sat Mar 14 23:57:49 2015 +0100 unixhelper.{cpp,h}: implement cleanup program for process group. --- debian/changelog | 1 + src/unixhelper.cpp | 38 ++++++++++++++++++++++++++++++++++++++ src/unixhelper.h | 9 +++++++++ 3 files changed, 48 insertions(+) diff --git a/debian/changelog b/debian/changelog index c00b598..67306b6 100644 --- a/debian/changelog +++ b/debian/changelog @@ -6,6 +6,7 @@ x2goclient (4.0.5.1-0x2go1) UNRELEASED; urgency=low whitespaces within the var directory path on Windows. Add comment to revisit this later on non-Windows-platforms, too. Fixes: #916. - {unixhelper.{cpp,h},x2goclient.pro{,.maemo}}: add unixhelper stub. + - unixhelper.{cpp,h}: implement cleanup program for process group. [ Oleksandr Shneyder ] * New upstream release (4.0.5.1): diff --git a/src/unixhelper.cpp b/src/unixhelper.cpp index 221bdb2..545c2c1 100644 --- a/src/unixhelper.cpp +++ b/src/unixhelper.cpp @@ -19,5 +19,43 @@ #ifdef Q_OS_UNIX +#include <csignal> +#include <unistd.h> +#include <iostream> +#include <cstring> +#include <cerrno> +#include <cstdlib> + +#include "unixhelper.h" + +void unixhelper::kill_pgroup (int signal) { + if (SIGHUP == signal) { + /* Try to kill via SIGTERM first. */ + if (0 != killpg (getpgrp (), SIGTERM)) { + std::cerr << "WARNING: unable to send SIGTERM to process group: " << std::strerror (errno) << std::endl; + } + + /* Grant a grace period of (at least) 5 seconds. */ + sleep (5); + + /* Don't handle any errors here, because we die anyway. */ + killpg (getpgrp (), SIGKILL); + } +} + + +int unixhelper::unix_cleanup () { + if (SIG_ERR == std::signal (SIGTERM, SIG_IGN)) { + std::cerr << "Unable to ignore SIGTERM: " << std::strerror (errno) << std::endl; + std::exit (1); + } + + std::signal (SIGHUP, kill_pgroup); + + /* Sleep forever... at least one second in each run. */ + for (;;) { + sleep (1); + } +} #endif /* defined (Q_OS_UNIX) */ diff --git a/src/unixhelper.h b/src/unixhelper.h index 31d983e..fab611e 100644 --- a/src/unixhelper.h +++ b/src/unixhelper.h @@ -22,7 +22,16 @@ #ifndef UNIXHELPER_H #define UNIXHELPER_H +class unixhelper { + public: + unixhelper () {} + ~unixhelper () {} + unix_cleanup (); + private: + unixhelper (const unixhelper &other); + void kill_pgroup (int signal); +}; #endif /* !defined (UNIXHELPER_H) */ -- Alioth's /srv/git/code.x2go.org/x2goclient.git//..//_hooks_/post-receive-email on /srv/git/code.x2go.org/x2goclient.git
This is an automated email from the git hooks/post-receive script. x2go pushed a commit to branch bugfix/osx in repository x2goclient. commit 30e69d0aa081220b74df43503bf3fa423be631bc Author: Mihai Moldovan <ionic@ionic.de> Date: Sun Mar 15 00:03:42 2015 +0100 x2goclient.cpp: wrap X2Go Client main function and use that. --- debian/changelog | 1 + src/x2goclient.cpp | 6 +++++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/debian/changelog b/debian/changelog index 67306b6..a55349a 100644 --- a/debian/changelog +++ b/debian/changelog @@ -7,6 +7,7 @@ x2goclient (4.0.5.1-0x2go1) UNRELEASED; urgency=low revisit this later on non-Windows-platforms, too. Fixes: #916. - {unixhelper.{cpp,h},x2goclient.pro{,.maemo}}: add unixhelper stub. - unixhelper.{cpp,h}: implement cleanup program for process group. + - x2goclient.cpp: wrap X2Go Client main function and use that. [ Oleksandr Shneyder ] * New upstream release (4.0.5.1): diff --git a/src/x2goclient.cpp b/src/x2goclient.cpp index a619cd7..80fd967 100644 --- a/src/x2goclient.cpp +++ b/src/x2goclient.cpp @@ -17,7 +17,11 @@ #include "ongetpass.h" +int wrap_x2go_main (int argc, char **argv) { + return (x2goMain (argc, argv)); +} + int main(int argc, char *argv[]) { - return x2goMain(argc,argv); + return (wrap_x2go_main (argc, argv)); } -- Alioth's /srv/git/code.x2go.org/x2goclient.git//..//_hooks_/post-receive-email on /srv/git/code.x2go.org/x2goclient.git
This is an automated email from the git hooks/post-receive script. x2go pushed a commit to branch bugfix/osx in repository x2goclient. commit 23938a1304911462b07fd19e680a89618f7535d9 Author: Mihai Moldovan <ionic@ionic.de> Date: Sat Mar 14 22:21:34 2015 +0100 {unixhelper.{cpp,h},x2goclient.pro{maemo}}: add unixhelper stub. --- debian/changelog | 1 + src/unixhelper.cpp | 23 +++++++++++++++++++++++ src/unixhelper.h | 29 +++++++++++++++++++++++++++++ x2goclient.pro | 6 ++++-- x2goclient.pro.maemo | 6 ++++-- 5 files changed, 61 insertions(+), 4 deletions(-) diff --git a/debian/changelog b/debian/changelog index 9bada0b..c00b598 100644 --- a/debian/changelog +++ b/debian/changelog @@ -5,6 +5,7 @@ x2goclient (4.0.5.1-0x2go1) UNRELEASED; urgency=low - onmainwindow.cpp: include sshd PID file path option in quotes to support whitespaces within the var directory path on Windows. Add comment to revisit this later on non-Windows-platforms, too. Fixes: #916. + - {unixhelper.{cpp,h},x2goclient.pro{,.maemo}}: add unixhelper stub. [ Oleksandr Shneyder ] * New upstream release (4.0.5.1): diff --git a/src/unixhelper.cpp b/src/unixhelper.cpp new file mode 100644 index 0000000..221bdb2 --- /dev/null +++ b/src/unixhelper.cpp @@ -0,0 +1,23 @@ +/*************************************************************************** + * Copyright (C) 2015 by Mihai Moldovan <ionic@ionic.de> +49 721 14595728 * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY 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, write to the * + * Free Software Foundation, Inc., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ + +#ifdef Q_OS_UNIX + + +#endif /* defined (Q_OS_UNIX) */ diff --git a/src/unixhelper.h b/src/unixhelper.h new file mode 100644 index 0000000..31d983e --- /dev/null +++ b/src/unixhelper.h @@ -0,0 +1,29 @@ +/*************************************************************************** + * Copyright (C) 2015 by Mihai Moldovan <ionic@ionic.de> +49 721 14595728 * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY 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, write to the * + * Free Software Foundation, Inc., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ + +#ifdef Q_OS_UNIX + +#ifndef UNIXHELPER_H +#define UNIXHELPER_H + + + +#endif /* !defined (UNIXHELPER_H) */ + +#endif /* defined (Q_OS_UNIX) */ diff --git a/x2goclient.pro b/x2goclient.pro index 97e8bdd..def49d9 100644 --- a/x2goclient.pro +++ b/x2goclient.pro @@ -79,7 +79,8 @@ HEADERS += src/configdialog.h \ src/folderbutton.h \ src/folderexplorer.h \ src/non_modal_messagebox.h \ - src/help.h + src/help.h \ + src/unixhelper.h SOURCES += src/sharewidget.cpp \ src/settingswidget.cpp \ @@ -122,7 +123,8 @@ SOURCES += src/sharewidget.cpp \ src/folderbutton.cpp \ src/folderexplorer.cpp \ src/non_modal_messagebox.cpp \ - src/help.cpp + src/help.cpp \ + src/unixhelper.cpp LIBS += -lssh win32:LIBS += -lAdvAPI32 -lshell32 -lUser32 diff --git a/x2goclient.pro.maemo b/x2goclient.pro.maemo index ac2eacf..63cc3d8 100644 --- a/x2goclient.pro.maemo +++ b/x2goclient.pro.maemo @@ -35,7 +35,8 @@ HEADERS += src/configdialog.h \ src/settingswidget.h \ src/sharewidget.h \ src/clicklineedit.h \ - src/help.h + src/help.h \ + src/unixhelper.h SOURCES += src/sharewidget.cpp \ src/settingswidget.cpp \ @@ -62,7 +63,8 @@ SOURCES += src/sharewidget.cpp \ src/embedwidget.cpp \ src/wapi.cpp \ src/clicklineedit.cpp \ - src/help.cpp + src/help.cpp \ + src/unixhelper.cpp TEMPLATE = app TARGET = -- Alioth's /srv/git/code.x2go.org/x2goclient.git//..//_hooks_/post-receive-email on /srv/git/code.x2go.org/x2goclient.git
This is an automated email from the git hooks/post-receive script. x2go pushed a commit to branch bugfix/osx in repository x2goclient. commit d606d374c77ba829f180c0d465b19bfb94cfde6e Author: Mihai Moldovan <ionic@ionic.de> Date: Mon Mar 16 20:30:49 2015 +0100 x2goclient.cpp: use setsid() on UNIX to become session and process group leader. If that fails, fork, terminate the parent and execute setsid() in the child process. Use fork_helper() to start the UNIX cleanup helper in a child process and continue with the main application in the parent. --- debian/changelog | 4 ++++ src/x2goclient.cpp | 43 ++++++++++++++++++++++++++++++++++++++++--- 2 files changed, 44 insertions(+), 3 deletions(-) diff --git a/debian/changelog b/debian/changelog index 1c74362..e36c155 100644 --- a/debian/changelog +++ b/debian/changelog @@ -10,6 +10,10 @@ x2goclient (4.0.5.1-0x2go1) UNRELEASED; urgency=low - x2goclient.cpp: wrap X2Go Client main function and use that. - x2goclient.cpp: add fork_helper() function to start up the UNIX cleanup helper. + - x2goclient.cpp: use setsid() on UNIX to become session and process group + leader. If that fails, fork, terminate the parent and execute setsid() + in the child process. Use fork_helper() to start the UNIX cleanup helper + in a child process and continue with the main application in the parent. [ Oleksandr Shneyder ] * New upstream release (4.0.5.1): diff --git a/src/x2goclient.cpp b/src/x2goclient.cpp index f285f40..1a57178 100644 --- a/src/x2goclient.cpp +++ b/src/x2goclient.cpp @@ -54,7 +54,44 @@ int fork_helper (int argc, char **argv) { } #endif /* defined (Q_OS_UNIX) */ -int main(int argc, char *argv[]) -{ - return (wrap_x2go_main (argc, argv)); +int main (int argc, char **argv) { +#ifdef Q_OS_UNIX + if (-1 == setsid ()) { + std::cerr << "Unable to create a new process session: " << std::strerror (errno) << "\n"; + + std::cerr << "Trying to fork." << std::endl; + pid_t tmp_pid = fork (); + + /* Child. */ + if (0 == tmp_pid) { + /* Trying to get a new session and become session + process group leader again. */ + if (-1 == setsid ()) { + std::cerr << "Child was unable to create a new process session: " << std::strerror (errno) << "\n"; + std::cerr << "Terminating. Please report a bug, refer to this documentation: http://wiki.x2go.org/doku.php/wiki:bugs" << std::endl; + + std::exit (EXIT_FAILURE); + } + + /* By now, we should be session and group leader. */ + return (fork_helper (argc, argv)); + } + /* Error. */ + else if (-1 == tmp_pid) { + std::cerr << "Error while forking: " << std::strerror (errno) << std::endl; + std::cerr << "Terminating. Please report a bug, refer to this documentation: http://wiki.x2go.org/doku.php/wiki:bugs" << std::endl; + + std::edit (EXIT_FAILURE); + } + /* Parent. Just die here. */ + else { + std::exit (EXIT_SUCCESS); + } + } + else { + /* setsid() worked. Starting helper and main program. */ + return (fork_helper (argc, argv)); + } +#else /* defined (Q_OS_UNIX) */ + return (wrap_x2go_main (argc, argv)); +#endif /* defined (Q_OS_UNIX) */ } -- Alioth's /srv/git/code.x2go.org/x2goclient.git//..//_hooks_/post-receive-email on /srv/git/code.x2go.org/x2goclient.git
This is an automated email from the git hooks/post-receive script. x2go pushed a commit to branch bugfix/osx in repository x2goclient. commit 9be9eaca583ddafd67b89b14ab287edaff6785a7 Author: Mihai Moldovan <ionic@ionic.de> Date: Mon Mar 16 20:36:35 2015 +0100 x2goclient.cpp: add myself to copyright header. --- debian/changelog | 1 + src/x2goclient.cpp | 1 + 2 files changed, 2 insertions(+) diff --git a/debian/changelog b/debian/changelog index e36c155..c17ae82 100644 --- a/debian/changelog +++ b/debian/changelog @@ -14,6 +14,7 @@ x2goclient (4.0.5.1-0x2go1) UNRELEASED; urgency=low leader. If that fails, fork, terminate the parent and execute setsid() in the child process. Use fork_helper() to start the UNIX cleanup helper in a child process and continue with the main application in the parent. + - x2goclient.cpp: add myself to copyright header. [ Oleksandr Shneyder ] * New upstream release (4.0.5.1): diff --git a/src/x2goclient.cpp b/src/x2goclient.cpp index 1a57178..c242ad2 100644 --- a/src/x2goclient.cpp +++ b/src/x2goclient.cpp @@ -1,6 +1,7 @@ /************************************************************************** * Copyright (C) 2005-2015 by Oleksandr Shneyder * * o.shneyder@phoca-gmbh.de * +* Copyright (C) 2015 by Mihai Moldovan <ionic@ionic.de> * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * -- Alioth's /srv/git/code.x2go.org/x2goclient.git//..//_hooks_/post-receive-email on /srv/git/code.x2go.org/x2goclient.git
This is an automated email from the git hooks/post-receive script. x2go pushed a commit to branch bugfix/osx in repository x2goclient. commit 7f64f1c777301218310efb15429b46b2865ff9f3 Author: Mihai Moldovan <ionic@ionic.de> Date: Mon Mar 16 20:27:23 2015 +0100 x2goclient.cpp: add fork_helper() function to start up the UNIX cleanup helper. --- debian/changelog | 2 ++ src/x2goclient.cpp | 33 +++++++++++++++++++++++++++++++++ 2 files changed, 35 insertions(+) diff --git a/debian/changelog b/debian/changelog index a55349a..1c74362 100644 --- a/debian/changelog +++ b/debian/changelog @@ -8,6 +8,8 @@ x2goclient (4.0.5.1-0x2go1) UNRELEASED; urgency=low - {unixhelper.{cpp,h},x2goclient.pro{,.maemo}}: add unixhelper stub. - unixhelper.{cpp,h}: implement cleanup program for process group. - x2goclient.cpp: wrap X2Go Client main function and use that. + - x2goclient.cpp: add fork_helper() function to start up the UNIX cleanup + helper. [ Oleksandr Shneyder ] * New upstream release (4.0.5.1): diff --git a/src/x2goclient.cpp b/src/x2goclient.cpp index 80fd967..f285f40 100644 --- a/src/x2goclient.cpp +++ b/src/x2goclient.cpp @@ -15,12 +15,45 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. * ***************************************************************************/ +#include <iostream> +#include <unistd.h> +#include <cstring> +#include <cerrno> +#include <cstdlib> + +#include "unixhelper.h" #include "ongetpass.h" int wrap_x2go_main (int argc, char **argv) { return (x2goMain (argc, argv)); } +#ifdef Q_OS_UNIX +int fork_helper (int argc, char **argv) { + /* Fork off to start helper process. */ + pid_t tmp_pid = fork (); + + /* Child. */ + if (0 == tmp_pid) { + /* Starting unixhelper. */ + unixhelper cleanup_helper (); + cleanup_helper.unix_cleanup (); + } + /* Error. */ + else if (-1 == tmp_pid) { + std::cerr << "Unable to create a new process for the UNIX cleanup watchdog: " << std::strerror (errno) << "\n"; + std::cerr << "Terminating. Please report a bug, refer to this documentation: http://wiki.x2go.org/doku.php/wiki:bugs" << std::endl; + + std::exit (EXIT_FAILURE); + } + /* Parent. */ + else { + /* Start real X2Go Client. */ + return (wrap_x2go_main (argc, argv)); + } +} +#endif /* defined (Q_OS_UNIX) */ + int main(int argc, char *argv[]) { return (wrap_x2go_main (argc, argv)); -- Alioth's /srv/git/code.x2go.org/x2goclient.git//..//_hooks_/post-receive-email on /srv/git/code.x2go.org/x2goclient.git
This is an automated email from the git hooks/post-receive script. x2go pushed a commit to branch bugfix/osx in repository x2goclient. commit 0cabc70a918f66fa6807fb7e0d6aaf17d8e3e9aa Author: Mihai Moldovan <ionic@ionic.de> Date: Mon Mar 16 20:45:24 2015 +0100 x2goclient.cpp: fix std::edit -> std::exit typo. --- debian/changelog | 1 + src/x2goclient.cpp | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/debian/changelog b/debian/changelog index 2ebe5e8..7cca84b 100644 --- a/debian/changelog +++ b/debian/changelog @@ -17,6 +17,7 @@ x2goclient (4.0.5.1-0x2go1) UNRELEASED; urgency=low - x2goclient.cpp: add myself to copyright header. - x2goclient.cpp: add legacy <sys/types.h> header needed for old operating systems. + - x2goclient.cpp: fix std::edit -> std::exit typo. [ Oleksandr Shneyder ] * New upstream release (4.0.5.1): diff --git a/src/x2goclient.cpp b/src/x2goclient.cpp index 58f80f0..dd9e489 100644 --- a/src/x2goclient.cpp +++ b/src/x2goclient.cpp @@ -82,7 +82,7 @@ int main (int argc, char **argv) { std::cerr << "Error while forking: " << std::strerror (errno) << std::endl; std::cerr << "Terminating. Please report a bug, refer to this documentation: http://wiki.x2go.org/doku.php/wiki:bugs" << std::endl; - std::edit (EXIT_FAILURE); + std::exit (EXIT_FAILURE); } /* Parent. Just die here. */ else { -- Alioth's /srv/git/code.x2go.org/x2goclient.git//..//_hooks_/post-receive-email on /srv/git/code.x2go.org/x2goclient.git
This is an automated email from the git hooks/post-receive script. x2go pushed a commit to branch bugfix/osx in repository x2goclient. commit 60557175f9d26565236a87ae1aaa41a5c93a8b7a Author: Mihai Moldovan <ionic@ionic.de> Date: Mon Mar 16 21:13:05 2015 +0100 unixhelper.{h,cpp}: also include <QtCore/qglobal.h> to have Q_OS_UNIX defined on UNIX-based platforms. Move guards around. --- debian/changelog | 2 ++ src/unixhelper.cpp | 5 ++++- src/unixhelper.h | 9 ++++++--- 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/debian/changelog b/debian/changelog index 7cca84b..5d57988 100644 --- a/debian/changelog +++ b/debian/changelog @@ -18,6 +18,8 @@ x2goclient (4.0.5.1-0x2go1) UNRELEASED; urgency=low - x2goclient.cpp: add legacy <sys/types.h> header needed for old operating systems. - x2goclient.cpp: fix std::edit -> std::exit typo. + - unixhelper.{h,cpp}: also include <QtCore/qglobal.h> to have Q_OS_UNIX + defined on UNIX-based platforms. Move guards around. [ Oleksandr Shneyder ] * New upstream release (4.0.5.1): diff --git a/src/unixhelper.cpp b/src/unixhelper.cpp index 545c2c1..b326f35 100644 --- a/src/unixhelper.cpp +++ b/src/unixhelper.cpp @@ -17,6 +17,10 @@ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * ***************************************************************************/ +/* Necessary for Q_OS_UNIX! */ + +#include "unixhelper.h" + #ifdef Q_OS_UNIX #include <csignal> @@ -26,7 +30,6 @@ #include <cerrno> #include <cstdlib> -#include "unixhelper.h" void unixhelper::kill_pgroup (int signal) { if (SIGHUP == signal) { diff --git a/src/unixhelper.h b/src/unixhelper.h index fab611e..27cb735 100644 --- a/src/unixhelper.h +++ b/src/unixhelper.h @@ -17,11 +17,14 @@ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * ***************************************************************************/ -#ifdef Q_OS_UNIX #ifndef UNIXHELPER_H #define UNIXHELPER_H +#include <QtCore/qglobal.h> + +#ifdef Q_OS_UNIX + class unixhelper { public: unixhelper () {} @@ -33,6 +36,6 @@ class unixhelper { void kill_pgroup (int signal); }; -#endif /* !defined (UNIXHELPER_H) */ - #endif /* defined (Q_OS_UNIX) */ + +#endif /* !defined (UNIXHELPER_H) */ -- Alioth's /srv/git/code.x2go.org/x2goclient.git//..//_hooks_/post-receive-email on /srv/git/code.x2go.org/x2goclient.git
This is an automated email from the git hooks/post-receive script. x2go pushed a commit to branch bugfix/osx in repository x2goclient. commit 6f87ddb3b4bb55b012c411c7fb5f80f27686b23e Author: Mihai Moldovan <ionic@ionic.de> Date: Mon Mar 16 20:37:43 2015 +0100 x2goclient.cpp: add legacy <sys/types.h> header needed for old operating systems. --- debian/changelog | 2 ++ src/x2goclient.cpp | 1 + 2 files changed, 3 insertions(+) diff --git a/debian/changelog b/debian/changelog index c17ae82..2ebe5e8 100644 --- a/debian/changelog +++ b/debian/changelog @@ -15,6 +15,8 @@ x2goclient (4.0.5.1-0x2go1) UNRELEASED; urgency=low in the child process. Use fork_helper() to start the UNIX cleanup helper in a child process and continue with the main application in the parent. - x2goclient.cpp: add myself to copyright header. + - x2goclient.cpp: add legacy <sys/types.h> header needed for old operating + systems. [ Oleksandr Shneyder ] * New upstream release (4.0.5.1): diff --git a/src/x2goclient.cpp b/src/x2goclient.cpp index c242ad2..58f80f0 100644 --- a/src/x2goclient.cpp +++ b/src/x2goclient.cpp @@ -17,6 +17,7 @@ ***************************************************************************/ #include <iostream> +#include <sys/types.h> #include <unistd.h> #include <cstring> #include <cerrno> -- Alioth's /srv/git/code.x2go.org/x2goclient.git//..//_hooks_/post-receive-email on /srv/git/code.x2go.org/x2goclient.git
This is an automated email from the git hooks/post-receive script. x2go pushed a commit to branch bugfix/osx in repository x2goclient. commit b26ffe9109a33edc9deeb7077a15d9904c2e1336 Author: Mihai Moldovan <ionic@ionic.de> Date: Mon Mar 16 21:17:49 2015 +0100 unixhelper.h: forgot to declare type of unix_cleanup() function. --- debian/changelog | 1 + src/unixhelper.h | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/debian/changelog b/debian/changelog index 5d57988..2295f06 100644 --- a/debian/changelog +++ b/debian/changelog @@ -20,6 +20,7 @@ x2goclient (4.0.5.1-0x2go1) UNRELEASED; urgency=low - x2goclient.cpp: fix std::edit -> std::exit typo. - unixhelper.{h,cpp}: also include <QtCore/qglobal.h> to have Q_OS_UNIX defined on UNIX-based platforms. Move guards around. + - unixhelper.h: forgot to declare type of unix_cleanup() function. [ Oleksandr Shneyder ] * New upstream release (4.0.5.1): diff --git a/src/unixhelper.h b/src/unixhelper.h index 27cb735..9069b5d 100644 --- a/src/unixhelper.h +++ b/src/unixhelper.h @@ -29,7 +29,7 @@ class unixhelper { public: unixhelper () {} ~unixhelper () {} - unix_cleanup (); + int unix_cleanup (); private: unixhelper (const unixhelper &other); -- Alioth's /srv/git/code.x2go.org/x2goclient.git//..//_hooks_/post-receive-email on /srv/git/code.x2go.org/x2goclient.git
This is an automated email from the git hooks/post-receive script. x2go pushed a commit to branch bugfix/osx in repository x2goclient. commit 01fe141c090007c1bec65eecec4c6f7875ccb4d8 Author: Mihai Moldovan <ionic@ionic.de> Date: Mon Mar 16 21:38:10 2015 +0100 unixhelper.{cpp,h},x2goclient.cpp}: unixhelper should really be a (module) namespace, not a class. --- debian/changelog | 2 ++ src/unixhelper.cpp | 43 ++++++++++++++++++++++--------------------- src/unixhelper.h | 14 ++++---------- src/x2goclient.cpp | 3 +-- 4 files changed, 29 insertions(+), 33 deletions(-) diff --git a/debian/changelog b/debian/changelog index 2295f06..a720d04 100644 --- a/debian/changelog +++ b/debian/changelog @@ -21,6 +21,8 @@ x2goclient (4.0.5.1-0x2go1) UNRELEASED; urgency=low - unixhelper.{h,cpp}: also include <QtCore/qglobal.h> to have Q_OS_UNIX defined on UNIX-based platforms. Move guards around. - unixhelper.h: forgot to declare type of unix_cleanup() function. + - {unixhelper.{cpp,h},x2goclient.cpp}: unixhelper should really be a + (module) namespace, not a class. [ Oleksandr Shneyder ] * New upstream release (4.0.5.1): diff --git a/src/unixhelper.cpp b/src/unixhelper.cpp index b326f35..b0729c6 100644 --- a/src/unixhelper.cpp +++ b/src/unixhelper.cpp @@ -30,34 +30,35 @@ #include <cerrno> #include <cstdlib> +namespace unixhelper { + void kill_pgroup (int signal) { + if (SIGHUP == signal) { + /* Try to kill via SIGTERM first. */ + if (0 != killpg (getpgrp (), SIGTERM)) { + std::cerr << "WARNING: unable to send SIGTERM to process group: " << std::strerror (errno) << std::endl; + } -void unixhelper::kill_pgroup (int signal) { - if (SIGHUP == signal) { - /* Try to kill via SIGTERM first. */ - if (0 != killpg (getpgrp (), SIGTERM)) { - std::cerr << "WARNING: unable to send SIGTERM to process group: " << std::strerror (errno) << std::endl; - } - - /* Grant a grace period of (at least) 5 seconds. */ - sleep (5); + /* Grant a grace period of (at least) 5 seconds. */ + sleep (5); - /* Don't handle any errors here, because we die anyway. */ - killpg (getpgrp (), SIGKILL); + /* Don't handle any errors here, because we die anyway. */ + killpg (getpgrp (), SIGKILL); + } } -} -int unixhelper::unix_cleanup () { - if (SIG_ERR == std::signal (SIGTERM, SIG_IGN)) { - std::cerr << "Unable to ignore SIGTERM: " << std::strerror (errno) << std::endl; - std::exit (1); - } + int unix_cleanup () { + if (SIG_ERR == std::signal (SIGTERM, SIG_IGN)) { + std::cerr << "Unable to ignore SIGTERM: " << std::strerror (errno) << std::endl; + std::exit (1); + } - std::signal (SIGHUP, kill_pgroup); + std::signal (SIGHUP, kill_pgroup); - /* Sleep forever... at least one second in each run. */ - for (;;) { - sleep (1); + /* Sleep forever... at least one second in each run. */ + for (;;) { + sleep (1); + } } } diff --git a/src/unixhelper.h b/src/unixhelper.h index 9069b5d..fe86017 100644 --- a/src/unixhelper.h +++ b/src/unixhelper.h @@ -25,16 +25,10 @@ #ifdef Q_OS_UNIX -class unixhelper { - public: - unixhelper () {} - ~unixhelper () {} - int unix_cleanup (); - - private: - unixhelper (const unixhelper &other); - void kill_pgroup (int signal); -}; +namespace unixhelper { + int unix_cleanup (); + void kill_pgroup (int signal); +} #endif /* defined (Q_OS_UNIX) */ diff --git a/src/x2goclient.cpp b/src/x2goclient.cpp index dd9e489..005d819 100644 --- a/src/x2goclient.cpp +++ b/src/x2goclient.cpp @@ -38,8 +38,7 @@ int fork_helper (int argc, char **argv) { /* Child. */ if (0 == tmp_pid) { /* Starting unixhelper. */ - unixhelper cleanup_helper (); - cleanup_helper.unix_cleanup (); + unixhelper::unix_cleanup (); } /* Error. */ else if (-1 == tmp_pid) { -- Alioth's /srv/git/code.x2go.org/x2goclient.git//..//_hooks_/post-receive-email on /srv/git/code.x2go.org/x2goclient.git
This is an automated email from the git hooks/post-receive script. x2go pushed a commit to branch bugfix/osx in repository x2goclient. commit 21519f1b877f20fc841d9b6506be09d1ff8630ca Author: Mihai Moldovan <ionic@ionic.de> Date: Mon Mar 16 22:04:19 2015 +0100 unixhelper.{cpp,h}: add documentation/comments. --- debian/changelog | 1 + src/unixhelper.cpp | 4 ++++ src/unixhelper.h | 24 ++++++++++++++++++++++++ src/x2goclient.cpp | 2 ++ 4 files changed, 31 insertions(+) diff --git a/debian/changelog b/debian/changelog index a720d04..f7e68eb 100644 --- a/debian/changelog +++ b/debian/changelog @@ -23,6 +23,7 @@ x2goclient (4.0.5.1-0x2go1) UNRELEASED; urgency=low - unixhelper.h: forgot to declare type of unix_cleanup() function. - {unixhelper.{cpp,h},x2goclient.cpp}: unixhelper should really be a (module) namespace, not a class. + - unixhelper.{cpp,h}: add documentation/comments. [ Oleksandr Shneyder ] * New upstream release (4.0.5.1): diff --git a/src/unixhelper.cpp b/src/unixhelper.cpp index b0729c6..2ad0740 100644 --- a/src/unixhelper.cpp +++ b/src/unixhelper.cpp @@ -30,6 +30,8 @@ #include <cerrno> #include <cstdlib> +/* For documentation please see unixhelper.h. */ + namespace unixhelper { void kill_pgroup (int signal) { if (SIGHUP == signal) { @@ -51,6 +53,8 @@ namespace unixhelper { if (SIG_ERR == std::signal (SIGTERM, SIG_IGN)) { std::cerr << "Unable to ignore SIGTERM: " << std::strerror (errno) << std::endl; std::exit (1); + + /* Anything here shall be unreachable. */ } std::signal (SIGHUP, kill_pgroup); diff --git a/src/unixhelper.h b/src/unixhelper.h index fe86017..a00d21b 100644 --- a/src/unixhelper.h +++ b/src/unixhelper.h @@ -26,7 +26,31 @@ #ifdef Q_OS_UNIX namespace unixhelper { + /* + * TODO: Unblocks all signals and + * installs a signal handler for SIGHUP, which calls kill_pgroup. + * + * TODO: Should signal unblocking or + * installing the signal handler fail, an emergency exit is performed + * and the whole process group killed. + * + * Loops indefinitely afterwards. + */ int unix_cleanup (); + + /* + * Kills the whole process group. + * First, SIGTERM is sent to the group. + * A 5 seconds grace period is granted to make sure + * processes exit cleanly on their own. + * Lastly, SIGKILL is sent to the group -- which also + * implies the demise of this program. + * + * signal may be any of: + * * -1 to indicate an error leading to emergency termination + * * SIGHUP as the standard signal that is sent when the + * group leeader dies + */ void kill_pgroup (int signal); } diff --git a/src/x2goclient.cpp b/src/x2goclient.cpp index 005d819..de3b7c9 100644 --- a/src/x2goclient.cpp +++ b/src/x2goclient.cpp @@ -39,6 +39,8 @@ int fork_helper (int argc, char **argv) { if (0 == tmp_pid) { /* Starting unixhelper. */ unixhelper::unix_cleanup (); + + /* Anything here shall be unreachable. */ } /* Error. */ else if (-1 == tmp_pid) { -- Alioth's /srv/git/code.x2go.org/x2goclient.git//..//_hooks_/post-receive-email on /srv/git/code.x2go.org/x2goclient.git
This is an automated email from the git hooks/post-receive script. x2go pushed a commit to branch bugfix/osx in repository x2goclient. commit 8cdbff70b9d72ad84d8240ac29a7c4a1286ae08b Author: Mihai Moldovan <ionic@ionic.de> Date: Mon Mar 16 22:14:46 2015 +0100 x2goclient.cpp: return return value of unixhelper::unix_cleanup(). --- debian/changelog | 1 + src/x2goclient.cpp | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/debian/changelog b/debian/changelog index f7e68eb..28bba87 100644 --- a/debian/changelog +++ b/debian/changelog @@ -24,6 +24,7 @@ x2goclient (4.0.5.1-0x2go1) UNRELEASED; urgency=low - {unixhelper.{cpp,h},x2goclient.cpp}: unixhelper should really be a (module) namespace, not a class. - unixhelper.{cpp,h}: add documentation/comments. + - x2goclient.cpp: return return value of unixhelper::unix_cleanup(). [ Oleksandr Shneyder ] * New upstream release (4.0.5.1): diff --git a/src/x2goclient.cpp b/src/x2goclient.cpp index de3b7c9..4558784 100644 --- a/src/x2goclient.cpp +++ b/src/x2goclient.cpp @@ -38,7 +38,7 @@ int fork_helper (int argc, char **argv) { /* Child. */ if (0 == tmp_pid) { /* Starting unixhelper. */ - unixhelper::unix_cleanup (); + return (unixhelper::unix_cleanup ()); /* Anything here shall be unreachable. */ } -- Alioth's /srv/git/code.x2go.org/x2goclient.git//..//_hooks_/post-receive-email on /srv/git/code.x2go.org/x2goclient.git
This is an automated email from the git hooks/post-receive script. x2go pushed a commit to branch bugfix/osx in repository x2goclient. commit 8d0b24d84693a8f1acec03c48c5032551c7629f2 Author: Mihai Moldovan <ionic@ionic.de> Date: Mon Mar 16 22:15:58 2015 +0100 unixhelper.cpp: kill process group on error. --- debian/changelog | 1 + 1 file changed, 1 insertion(+) diff --git a/debian/changelog b/debian/changelog index 28bba87..805ac40 100644 --- a/debian/changelog +++ b/debian/changelog @@ -25,6 +25,7 @@ x2goclient (4.0.5.1-0x2go1) UNRELEASED; urgency=low (module) namespace, not a class. - unixhelper.{cpp,h}: add documentation/comments. - x2goclient.cpp: return return value of unixhelper::unix_cleanup(). + - unixhelper.cpp: kill process group on error. [ Oleksandr Shneyder ] * New upstream release (4.0.5.1): -- Alioth's /srv/git/code.x2go.org/x2goclient.git//..//_hooks_/post-receive-email on /srv/git/code.x2go.org/x2goclient.git
This is an automated email from the git hooks/post-receive script. x2go pushed a commit to branch bugfix/osx in repository x2goclient. commit 8372dc0625a5fb723e1fb05401e71e3445505c84 Author: Mihai Moldovan <ionic@ionic.de> Date: Mon Mar 16 23:08:13 2015 +0100 unixhelper.cpp: port from std::signal() to sigaction(). Handle errors. --- debian/changelog | 1 + src/unixhelper.cpp | 33 ++++++++++++++++++++++++++------- 2 files changed, 27 insertions(+), 7 deletions(-) diff --git a/debian/changelog b/debian/changelog index c89602f..d733ff3 100644 --- a/debian/changelog +++ b/debian/changelog @@ -28,6 +28,7 @@ x2goclient (4.0.5.1-0x2go1) UNRELEASED; urgency=low - unixhelper.cpp: kill process group on error. - unixhelper.{cpp,h}: implement signal unblocking in unixhelper::unix_cleanup(). Update documentation. + - unixhelper.cpp: port from std::signal() to sigaction(). Handle errors. [ Oleksandr Shneyder ] * New upstream release (4.0.5.1): diff --git a/src/unixhelper.cpp b/src/unixhelper.cpp index f2cc11c..fdcaac9 100644 --- a/src/unixhelper.cpp +++ b/src/unixhelper.cpp @@ -69,15 +69,34 @@ namespace unixhelper { /* Anything here shall be unreachable. */ } - /* Set up signal handler to ignore SIGTERM. */ - if (SIG_ERR == std::signal (SIGTERM, SIG_IGN)) { - std::cerr << "Unable to ignore SIGTERM: " << std::strerror (errno) << std::endl; - std::exit (1); - - /* Anything here shall be unreachable. */ + { + struct sigaction sig_action; + sig_action.sa_handler = SIG_IGN; + sig_action.sa_mask = empty_set; + sig_action.sa_flags = SA_RESTART; + + /* Set up signal handler to ignore SIGTERM. */ + if (0 != sigaction (SIGTERM, &sig_action, NULL)) { + std::cerr << "Unable to ignore SIGTERM: " << std::strerror (errno) << std::endl; + kill_pgroup (-1); + + /* Anything here shall be unreachable. */ + } } - std::signal (SIGHUP, kill_pgroup); + { + struct sigaction sig_action; + sig_action.sa_handler = kill_pgroup; + sig_action.sa_mask = empty_set; + sig_action.sa_flags = SA_RESTART; + + if (0 != sigaction (SIGHUP, &sig_action, NULL)) { + std::cerr << "Unable to set up signal handler for SIGHUP: " << std::strerror (errno) << std::endl; + kill_pgroup (-1); + + /* Anything here shall be unreachable. */ + } + } /* Sleep forever... at least one second in each run. */ for (;;) { -- Alioth's /srv/git/code.x2go.org/x2goclient.git//..//_hooks_/post-receive-email on /srv/git/code.x2go.org/x2goclient.git
This is an automated email from the git hooks/post-receive script. x2go pushed a commit to branch bugfix/osx in repository x2goclient. commit bfe696479708825f5430642a88f8b0ef9de594e2 Author: Mihai Moldovan <ionic@ionic.de> Date: Mon Mar 16 22:42:14 2015 +0100 unixhelper.{cpp,h}: implement signal unblocking in unixhelper::unix_cleanup(). Update documentation. --- debian/changelog | 2 ++ src/unixhelper.cpp | 20 ++++++++++++++++++++ src/unixhelper.h | 10 +++++----- 3 files changed, 27 insertions(+), 5 deletions(-) diff --git a/debian/changelog b/debian/changelog index 805ac40..c89602f 100644 --- a/debian/changelog +++ b/debian/changelog @@ -26,6 +26,8 @@ x2goclient (4.0.5.1-0x2go1) UNRELEASED; urgency=low - unixhelper.{cpp,h}: add documentation/comments. - x2goclient.cpp: return return value of unixhelper::unix_cleanup(). - unixhelper.cpp: kill process group on error. + - unixhelper.{cpp,h}: implement signal unblocking in + unixhelper::unix_cleanup(). Update documentation. [ Oleksandr Shneyder ] * New upstream release (4.0.5.1): diff --git a/src/unixhelper.cpp b/src/unixhelper.cpp index 2ad0740..f2cc11c 100644 --- a/src/unixhelper.cpp +++ b/src/unixhelper.cpp @@ -50,6 +50,26 @@ namespace unixhelper { int unix_cleanup () { + /* + * Unblock all signals first. + * Signal blocks are inherited, so you never you what is currently set. + */ + sigset_t empty_set; + if (0 != sigemptyset (&empty_set)) { + std::cerr << "Unable to fetch empty signal set: " << std::strerror (errno) << std::endl; + kill_pgroup (-1); + + /* Anything here shall be unreachable. */ + } + + if (0 != sigprocmask (SIG_SETMASK, &empty_set, NULL)) { + std::cerr << "Unable to set empty signal set: " << std::strerror (errno) << std::endl; + kill_pgroup (-1); + + /* Anything here shall be unreachable. */ + } + + /* Set up signal handler to ignore SIGTERM. */ if (SIG_ERR == std::signal (SIGTERM, SIG_IGN)) { std::cerr << "Unable to ignore SIGTERM: " << std::strerror (errno) << std::endl; std::exit (1); diff --git a/src/unixhelper.h b/src/unixhelper.h index a00d21b..7ca8b43 100644 --- a/src/unixhelper.h +++ b/src/unixhelper.h @@ -27,12 +27,12 @@ namespace unixhelper { /* - * TODO: Unblocks all signals and - * installs a signal handler for SIGHUP, which calls kill_pgroup. + * Unblocks all signals and installs a signal handler for SIGHUP, + * which calls kill_pgroup. * - * TODO: Should signal unblocking or - * installing the signal handler fail, an emergency exit is performed - * and the whole process group killed. + * Should signal unblocking or installing the signal handler fail, + * an emergency exit is performed and + * the whole process group killed. * * Loops indefinitely afterwards. */ -- Alioth's /srv/git/code.x2go.org/x2goclient.git//..//_hooks_/post-receive-email on /srv/git/code.x2go.org/x2goclient.git
This is an automated email from the git hooks/post-receive script. x2go pushed a commit to branch bugfix/osx in repository x2goclient. commit 959ba52c5c4ee52fd003d6137b29a42ae00fff67 Author: Mihai Moldovan <ionic@ionic.de> Date: Mon Mar 16 23:41:12 2015 +0100 x2goclient.cpp: clean up. We don't care if setsid() fails or succeeds and we certainly do not need to fork to force it to succeed. Whether we are a process group leader already or become one doesn't matter, if the end result is that we are process group leader. --- debian/changelog | 4 ++++ src/x2goclient.cpp | 42 ++++++++---------------------------------- 2 files changed, 12 insertions(+), 34 deletions(-) diff --git a/debian/changelog b/debian/changelog index d733ff3..806089a 100644 --- a/debian/changelog +++ b/debian/changelog @@ -29,6 +29,10 @@ x2goclient (4.0.5.1-0x2go1) UNRELEASED; urgency=low - unixhelper.{cpp,h}: implement signal unblocking in unixhelper::unix_cleanup(). Update documentation. - unixhelper.cpp: port from std::signal() to sigaction(). Handle errors. + - x2goclient.cpp: clean up. We don't care if setsid() fails or succeeds + and we certainly do not need to fork to force it to succeed. Whether we + are a process group leader already or become one doesn't matter, if the + end result is that we are process group leader. [ Oleksandr Shneyder ] * New upstream release (4.0.5.1): diff --git a/src/x2goclient.cpp b/src/x2goclient.cpp index 4558784..f7f7c81 100644 --- a/src/x2goclient.cpp +++ b/src/x2goclient.cpp @@ -59,41 +59,15 @@ int fork_helper (int argc, char **argv) { int main (int argc, char **argv) { #ifdef Q_OS_UNIX - if (-1 == setsid ()) { - std::cerr << "Unable to create a new process session: " << std::strerror (errno) << "\n"; + /* + * setsid() may succeed and we become a session and process + * group leader, or it may fail indicating that we already + * are a process group leader. Either way is fine. + */ + setsid (); - std::cerr << "Trying to fork." << std::endl; - pid_t tmp_pid = fork (); - - /* Child. */ - if (0 == tmp_pid) { - /* Trying to get a new session and become session + process group leader again. */ - if (-1 == setsid ()) { - std::cerr << "Child was unable to create a new process session: " << std::strerror (errno) << "\n"; - std::cerr << "Terminating. Please report a bug, refer to this documentation: http://wiki.x2go.org/doku.php/wiki:bugs" << std::endl; - - std::exit (EXIT_FAILURE); - } - - /* By now, we should be session and group leader. */ - return (fork_helper (argc, argv)); - } - /* Error. */ - else if (-1 == tmp_pid) { - std::cerr << "Error while forking: " << std::strerror (errno) << std::endl; - std::cerr << "Terminating. Please report a bug, refer to this documentation: http://wiki.x2go.org/doku.php/wiki:bugs" << std::endl; - - std::exit (EXIT_FAILURE); - } - /* Parent. Just die here. */ - else { - std::exit (EXIT_SUCCESS); - } - } - else { - /* setsid() worked. Starting helper and main program. */ - return (fork_helper (argc, argv)); - } + /* We should be process group leader by now. */ + return (fork_helper (argc, argv)); #else /* defined (Q_OS_UNIX) */ return (wrap_x2go_main (argc, argv)); #endif /* defined (Q_OS_UNIX) */ -- Alioth's /srv/git/code.x2go.org/x2goclient.git//..//_hooks_/post-receive-email on /srv/git/code.x2go.org/x2goclient.git
This is an automated email from the git hooks/post-receive script. x2go pushed a commit to branch bugfix/osx in repository x2goclient. commit 75704cffeb9b9c96c7ca6ff12991fe4e8a0aa59e Author: Mihai Moldovan <ionic@ionic.de> Date: Wed Mar 18 01:04:33 2015 +0100 x2goclient.cpp: don't start the UNIX cleanup helper process right after forking. Introduce a new command line option --unixhelper and re-execute the main binary with this new option to indicate that the UNIX cleanup helper tool is requested. It is necessary to call exec() after fork on virtually all operating system, especially on OS X. --- debian/changelog | 5 ++++ src/x2goclient.cpp | 65 ++++++++++++++++++++++++++++++++++++++++++++-------- 2 files changed, 60 insertions(+), 10 deletions(-) diff --git a/debian/changelog b/debian/changelog index 806089a..84a8d4e 100644 --- a/debian/changelog +++ b/debian/changelog @@ -33,6 +33,11 @@ x2goclient (4.0.5.1-0x2go1) UNRELEASED; urgency=low and we certainly do not need to fork to force it to succeed. Whether we are a process group leader already or become one doesn't matter, if the end result is that we are process group leader. + - x2goclient.cpp: don't start the UNIX cleanup helper process right after + forking, but introduce a new command line option --unixhelper and + re-execute the main binary with this new option to indicate that the + UNIX cleanup helper tool is requested. It is necessary to call exec() + after fork on virtually all operating system, especially on OS X. [ Oleksandr Shneyder ] * New upstream release (4.0.5.1): diff --git a/src/x2goclient.cpp b/src/x2goclient.cpp index f7f7c81..2aff41f 100644 --- a/src/x2goclient.cpp +++ b/src/x2goclient.cpp @@ -22,6 +22,10 @@ #include <cstring> #include <cerrno> #include <cstdlib> +#include <string> +#include <algorithm> +#include <cctype> +#include <vector> #include "unixhelper.h" #include "ongetpass.h" @@ -38,7 +42,28 @@ int fork_helper (int argc, char **argv) { /* Child. */ if (0 == tmp_pid) { /* Starting unixhelper. */ - return (unixhelper::unix_cleanup ()); + std::vector<std::string> new_argv; + new_argv.push (std::string (argv[0])); + new_argv.push ("--unixhelper"); + + std::vector<const char *> new_argv_c_str; + for (const_iterator it = new_argv.begin (); it != new_argv.end (); ++it) { + new_argv_c_str.push ((*it).c_str ()); + } + new_argv_c_str.push (""); + + if (0 != execv (new_argv_c_str.data (), new_argv_c_str.data ())) { + std::cerr << "Failed to re-execute process as UNIX cleanup helper tool: " << std::strerror (errno) << "\n" + << "Terminating and killing parent." << "\n" + << "Please report a bug, refer to this documentation: http://wiki.x2go.org/doku.php/wiki:bugs" << std::endl; + + pid_t parent_pid = getppid (); + if (0 != kill (parent_pid, SIGTERM)) { + std::cerr << "Failed to kill parent process: " << std::strerror (errno) << std::endl; + } + + std::exit (EXIT_FAILURE); + } /* Anything here shall be unreachable. */ } @@ -59,15 +84,35 @@ int fork_helper (int argc, char **argv) { int main (int argc, char **argv) { #ifdef Q_OS_UNIX - /* - * setsid() may succeed and we become a session and process - * group leader, or it may fail indicating that we already - * are a process group leader. Either way is fine. - */ - setsid (); - - /* We should be process group leader by now. */ - return (fork_helper (argc, argv)); + /* Scan program arguments for --unixhelper flag. */ + bool unix_helper_request = 0; + for (int i = 0; i < argc; ++i) { + std::string cur_arg (argv[i]); + + /* Make the current argument lowercase. */ + std::transform (cur_arg.begin (), cur_arg.end (), cur_arg.begin (), std::tolower); + + if ((!cur_arg.empty ()) && (cur_arg.compare ("--unixhelper"))) { + unix_helper_request = 1; + break; + } + } + + if (unix_helper_request) { + /* We were instructed to start as the UNIX cleanup helper tool. */ + return (unixhelper::unix_cleanup ()); + } + else { + /* + * setsid() may succeed and we become a session and process + * group leader, or it may fail indicating that we already + * are a process group leader. Either way is fine. + */ + setsid (); + + /* We should be process group leader by now. */ + return (fork_helper (argc, argv)); + } #else /* defined (Q_OS_UNIX) */ return (wrap_x2go_main (argc, argv)); #endif /* defined (Q_OS_UNIX) */ -- Alioth's /srv/git/code.x2go.org/x2goclient.git//..//_hooks_/post-receive-email on /srv/git/code.x2go.org/x2goclient.git
This is an automated email from the git hooks/post-receive script. x2go pushed a commit to branch bugfix/osx in repository x2goclient. commit d71388ca210d64f41d724051daf85da14e95d146 Author: Mihai Moldovan <ionic@ionic.de> Date: Wed Mar 18 03:06:15 2015 +0100 x2goclient.cpp: fix compile problems introduced with the last commit. --- debian/changelog | 1 + src/x2goclient.cpp | 25 +++++++++++++++++-------- 2 files changed, 18 insertions(+), 8 deletions(-) diff --git a/debian/changelog b/debian/changelog index 84a8d4e..62e857d 100644 --- a/debian/changelog +++ b/debian/changelog @@ -38,6 +38,7 @@ x2goclient (4.0.5.1-0x2go1) UNRELEASED; urgency=low re-execute the main binary with this new option to indicate that the UNIX cleanup helper tool is requested. It is necessary to call exec() after fork on virtually all operating system, especially on OS X. + - x2goclient.cpp: fix compile problems introduced with the last commit. [ Oleksandr Shneyder ] * New upstream release (4.0.5.1): diff --git a/src/x2goclient.cpp b/src/x2goclient.cpp index 2aff41f..cd13406 100644 --- a/src/x2goclient.cpp +++ b/src/x2goclient.cpp @@ -26,6 +26,7 @@ #include <algorithm> #include <cctype> #include <vector> +#include <csignal> #include "unixhelper.h" #include "ongetpass.h" @@ -43,16 +44,23 @@ int fork_helper (int argc, char **argv) { if (0 == tmp_pid) { /* Starting unixhelper. */ std::vector<std::string> new_argv; - new_argv.push (std::string (argv[0])); - new_argv.push ("--unixhelper"); + new_argv.push_back (std::string (argv[0])); + new_argv.push_back ("--unixhelper"); - std::vector<const char *> new_argv_c_str; - for (const_iterator it = new_argv.begin (); it != new_argv.end (); ++it) { - new_argv_c_str.push ((*it).c_str ()); + std::vector<char *> new_argv_c_str; + for (std::vector<std::string>::iterator it = new_argv.begin (); it != new_argv.end (); ++it) { + const char *elem = (*it).c_str (); + new_argv_c_str.push_back (strndup (elem, std::strlen (elem))); } - new_argv_c_str.push (""); - if (0 != execv (new_argv_c_str.data (), new_argv_c_str.data ())) { + /* Add null pointer as last element. */ + { + std::vector<char> tmp; + tmp.push_back (0); + new_argv_c_str.push_back (&tmp.front ()); + } + + if (0 != execv (new_argv_c_str.front (), &(new_argv_c_str.front ()))) { std::cerr << "Failed to re-execute process as UNIX cleanup helper tool: " << std::strerror (errno) << "\n" << "Terminating and killing parent." << "\n" << "Please report a bug, refer to this documentation: http://wiki.x2go.org/doku.php/wiki:bugs" << std::endl; @@ -66,6 +74,7 @@ int fork_helper (int argc, char **argv) { } /* Anything here shall be unreachable. */ + return (0); } /* Error. */ else if (-1 == tmp_pid) { @@ -90,7 +99,7 @@ int main (int argc, char **argv) { std::string cur_arg (argv[i]); /* Make the current argument lowercase. */ - std::transform (cur_arg.begin (), cur_arg.end (), cur_arg.begin (), std::tolower); + std::transform (cur_arg.begin (), cur_arg.end (), cur_arg.begin (), ::tolower); if ((!cur_arg.empty ()) && (cur_arg.compare ("--unixhelper"))) { unix_helper_request = 1; -- Alioth's /srv/git/code.x2go.org/x2goclient.git//..//_hooks_/post-receive-email on /srv/git/code.x2go.org/x2goclient.git
This is an automated email from the git hooks/post-receive script. x2go pushed a commit to branch bugfix/osx in repository x2goclient. commit 0c320eabbd7d5282e93f12fa6fb5c1e91d806589 Author: Mihai Moldovan <ionic@ionic.de> Date: Wed Mar 18 04:39:43 2015 +0100 x2goclient.cpp: fix string comparison. --- debian/changelog | 1 + src/x2goclient.cpp | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/debian/changelog b/debian/changelog index 62e857d..bc1cb37 100644 --- a/debian/changelog +++ b/debian/changelog @@ -39,6 +39,7 @@ x2goclient (4.0.5.1-0x2go1) UNRELEASED; urgency=low UNIX cleanup helper tool is requested. It is necessary to call exec() after fork on virtually all operating system, especially on OS X. - x2goclient.cpp: fix compile problems introduced with the last commit. + - x2goclient.cpp: fix string comparison. [ Oleksandr Shneyder ] * New upstream release (4.0.5.1): diff --git a/src/x2goclient.cpp b/src/x2goclient.cpp index cd13406..c695e26 100644 --- a/src/x2goclient.cpp +++ b/src/x2goclient.cpp @@ -101,7 +101,7 @@ int main (int argc, char **argv) { /* Make the current argument lowercase. */ std::transform (cur_arg.begin (), cur_arg.end (), cur_arg.begin (), ::tolower); - if ((!cur_arg.empty ()) && (cur_arg.compare ("--unixhelper"))) { + if ((!cur_arg.empty ()) && (cur_arg.compare ("--unixhelper") == 0)) { unix_helper_request = 1; break; } -- Alioth's /srv/git/code.x2go.org/x2goclient.git//..//_hooks_/post-receive-email on /srv/git/code.x2go.org/x2goclient.git
This is an automated email from the git hooks/post-receive script. x2go pushed a commit to branch bugfix/osx in repository x2goclient. commit 7fd60dfdefb1649710843a2cef4b47efaab68fb8 Author: Mihai Moldovan <ionic@ionic.de> Date: Wed Mar 18 05:51:03 2015 +0100 x2goclient.cpp: create new argv array on the heap instead of on the stack. Stack data will be invalid once the function goes out of scope (which is what execv is doing.) --- debian/changelog | 3 +++ src/x2goclient.cpp | 12 ++++++------ 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/debian/changelog b/debian/changelog index bc1cb37..0550b85 100644 --- a/debian/changelog +++ b/debian/changelog @@ -40,6 +40,9 @@ x2goclient (4.0.5.1-0x2go1) UNRELEASED; urgency=low after fork on virtually all operating system, especially on OS X. - x2goclient.cpp: fix compile problems introduced with the last commit. - x2goclient.cpp: fix string comparison. + - x2goclient.cpp: create new argv array on the heap instead of on the + stack. Stack data will be invalid once the function goes out of scope + (which is what execv is doing.) [ Oleksandr Shneyder ] * New upstream release (4.0.5.1): diff --git a/src/x2goclient.cpp b/src/x2goclient.cpp index c695e26..479d564 100644 --- a/src/x2goclient.cpp +++ b/src/x2goclient.cpp @@ -47,20 +47,20 @@ int fork_helper (int argc, char **argv) { new_argv.push_back (std::string (argv[0])); new_argv.push_back ("--unixhelper"); - std::vector<char *> new_argv_c_str; + std::vector<char *> *new_argv_c_str = new (std::vector<char *>) (); for (std::vector<std::string>::iterator it = new_argv.begin (); it != new_argv.end (); ++it) { const char *elem = (*it).c_str (); - new_argv_c_str.push_back (strndup (elem, std::strlen (elem))); + new_argv_c_str->push_back (strndup (elem, std::strlen (elem))); } /* Add null pointer as last element. */ { - std::vector<char> tmp; - tmp.push_back (0); - new_argv_c_str.push_back (&tmp.front ()); + std::vector<char> *tmp = new (std::vector<char>) (); + tmp->push_back (0); + new_argv_c_str->push_back (&tmp->front ()); } - if (0 != execv (new_argv_c_str.front (), &(new_argv_c_str.front ()))) { + if (0 != execv (new_argv_c_str->front (), &(new_argv_c_str->front ()))) { std::cerr << "Failed to re-execute process as UNIX cleanup helper tool: " << std::strerror (errno) << "\n" << "Terminating and killing parent." << "\n" << "Please report a bug, refer to this documentation: http://wiki.x2go.org/doku.php/wiki:bugs" << std::endl; -- Alioth's /srv/git/code.x2go.org/x2goclient.git//..//_hooks_/post-receive-email on /srv/git/code.x2go.org/x2goclient.git
This is an automated email from the git hooks/post-receive script. x2go pushed a commit to branch bugfix/osx in repository x2goclient. commit c43d87b715cd16019ef72f2a01c639f776483b52 Author: Mihai Moldovan <ionic@ionic.de> Date: Wed Mar 18 21:15:08 2015 +0100 {unixhelper.{cpp,h},x2goclient.cpp}: switch main cleanup handling to parent PID polling. --- debian/changelog | 2 ++ src/unixhelper.cpp | 9 ++++++++- src/unixhelper.h | 11 +++++++++-- src/x2goclient.cpp | 2 +- 4 files changed, 20 insertions(+), 4 deletions(-) diff --git a/debian/changelog b/debian/changelog index 9bf8e6e..62fabb2 100644 --- a/debian/changelog +++ b/debian/changelog @@ -45,6 +45,8 @@ x2goclient (4.0.5.1-0x2go1) UNRELEASED; urgency=low (which is what execv is doing.) - unixhelper.{cpp,h}: raise sleeping time to two seconds and grace period to 10 seconds. + - {unixhelper.{cpp,h},x2goclient.cpp}: switch main cleanup handling to + parent PID polling. [ Oleksandr Shneyder ] * New upstream release (4.0.5.1): diff --git a/src/unixhelper.cpp b/src/unixhelper.cpp index d4698df..410c320 100644 --- a/src/unixhelper.cpp +++ b/src/unixhelper.cpp @@ -49,7 +49,7 @@ namespace unixhelper { } - int unix_cleanup () { + int unix_cleanup (const pid_t parent) { /* * Unblock all signals first. * Signal blocks are inherited, so you never you what is currently set. @@ -100,6 +100,13 @@ namespace unixhelper { /* Sleep forever... at least two seconds in each run. */ for (;;) { + pid_t cur_ppid = getppid (); + + /* cur_ppid should match parent, otherwise the parent died. */ + if (cur_ppid != parent) { + kill_pgroup (SIGHUP); + } + sleep (2); } } diff --git a/src/unixhelper.h b/src/unixhelper.h index 9f213a8..7511d4d 100644 --- a/src/unixhelper.h +++ b/src/unixhelper.h @@ -22,6 +22,7 @@ #define UNIXHELPER_H #include <QtCore/qglobal.h> +#include <unistd.h> #ifdef Q_OS_UNIX @@ -35,8 +36,12 @@ namespace unixhelper { * the whole process group killed. * * Loops indefinitely afterwards. + * + * In this loop, the current parent PID is polled and compared against + * the original value passed via parameter parent. + * Should they mismatch, the parent died and kill_pgroup() is called. */ - int unix_cleanup (); + int unix_cleanup (const pid_t parent); /* * Kills the whole process group. @@ -49,7 +54,9 @@ namespace unixhelper { * signal may be any of: * * -1 to indicate an error leading to emergency termination * * SIGHUP as the standard signal that is sent when the - * group leeader dies + * group leader dies under specific circumstances + * (we cannot rely that this always happens, though, + * so a polling solution is needed, see unix_cleanup().) */ void kill_pgroup (int signal); } diff --git a/src/x2goclient.cpp b/src/x2goclient.cpp index 479d564..92d614d 100644 --- a/src/x2goclient.cpp +++ b/src/x2goclient.cpp @@ -109,7 +109,7 @@ int main (int argc, char **argv) { if (unix_helper_request) { /* We were instructed to start as the UNIX cleanup helper tool. */ - return (unixhelper::unix_cleanup ()); + return (unixhelper::unix_cleanup (getppid ())); } else { /* -- Alioth's /srv/git/code.x2go.org/x2goclient.git//..//_hooks_/post-receive-email on /srv/git/code.x2go.org/x2goclient.git
This is an automated email from the git hooks/post-receive script. x2go pushed a commit to branch bugfix/osx in repository x2goclient. commit 9583dbf7d88fcc114e21b1661f4cdd8356a9a77b Author: Mihai Moldovan <ionic@ionic.de> Date: Wed Mar 18 21:08:46 2015 +0100 unixhelper.{cpp,h}: raise sleeping time to two seconds and grace period to 10 seconds. --- debian/changelog | 2 ++ src/unixhelper.cpp | 8 ++++---- src/unixhelper.h | 4 ++-- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/debian/changelog b/debian/changelog index 0550b85..9bf8e6e 100644 --- a/debian/changelog +++ b/debian/changelog @@ -43,6 +43,8 @@ x2goclient (4.0.5.1-0x2go1) UNRELEASED; urgency=low - x2goclient.cpp: create new argv array on the heap instead of on the stack. Stack data will be invalid once the function goes out of scope (which is what execv is doing.) + - unixhelper.{cpp,h}: raise sleeping time to two seconds and grace period + to 10 seconds. [ Oleksandr Shneyder ] * New upstream release (4.0.5.1): diff --git a/src/unixhelper.cpp b/src/unixhelper.cpp index fdcaac9..d4698df 100644 --- a/src/unixhelper.cpp +++ b/src/unixhelper.cpp @@ -40,8 +40,8 @@ namespace unixhelper { std::cerr << "WARNING: unable to send SIGTERM to process group: " << std::strerror (errno) << std::endl; } - /* Grant a grace period of (at least) 5 seconds. */ - sleep (5); + /* Grant a grace period of (at least) 10 seconds. */ + sleep (10); /* Don't handle any errors here, because we die anyway. */ killpg (getpgrp (), SIGKILL); @@ -98,9 +98,9 @@ namespace unixhelper { } } - /* Sleep forever... at least one second in each run. */ + /* Sleep forever... at least two seconds in each run. */ for (;;) { - sleep (1); + sleep (2); } } } diff --git a/src/unixhelper.h b/src/unixhelper.h index 7ca8b43..9f213a8 100644 --- a/src/unixhelper.h +++ b/src/unixhelper.h @@ -28,7 +28,7 @@ namespace unixhelper { /* * Unblocks all signals and installs a signal handler for SIGHUP, - * which calls kill_pgroup. + * which calls kill_pgroup(). * * Should signal unblocking or installing the signal handler fail, * an emergency exit is performed and @@ -41,7 +41,7 @@ namespace unixhelper { /* * Kills the whole process group. * First, SIGTERM is sent to the group. - * A 5 seconds grace period is granted to make sure + * A 10 seconds grace period is granted to make sure * processes exit cleanly on their own. * Lastly, SIGKILL is sent to the group -- which also * implies the demise of this program. -- Alioth's /srv/git/code.x2go.org/x2goclient.git//..//_hooks_/post-receive-email on /srv/git/code.x2go.org/x2goclient.git
This is an automated email from the git hooks/post-receive script. x2go pushed a commit to branch bugfix/osx in repository x2goclient. commit e98c57a9a8d13ea78416434b04bff8b713279aea Author: Mihai Moldovan <ionic@ionic.de> Date: Fri Mar 20 04:02:06 2015 +0100 x2goclient.cpp: fix failing exec() call for the UNIX helper utility: correctly terminate arguments vector. --- debian/changelog | 2 ++ src/x2goclient.cpp | 6 +----- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/debian/changelog b/debian/changelog index 39b6199..93567a3 100644 --- a/debian/changelog +++ b/debian/changelog @@ -49,6 +49,8 @@ x2goclient (4.0.5.1-0x2go1) UNRELEASED; urgency=low parent PID polling. - unixhelper.{cpp,h}: ignore SIGINT, SIGTERM, SIGPIPE, SIGQUIT, SIGUSR1 and SIGUSR2. + - x2goclient.cpp: fix failing exec() call for the UNIX helper utility: + correctly terminate arguments vector. [ Oleksandr Shneyder ] * New upstream release (4.0.5.1): diff --git a/src/x2goclient.cpp b/src/x2goclient.cpp index 92d614d..d8ae6fa 100644 --- a/src/x2goclient.cpp +++ b/src/x2goclient.cpp @@ -54,11 +54,7 @@ int fork_helper (int argc, char **argv) { } /* Add null pointer as last element. */ - { - std::vector<char> *tmp = new (std::vector<char>) (); - tmp->push_back (0); - new_argv_c_str->push_back (&tmp->front ()); - } + new_argv_c_str->push_back (0); if (0 != execv (new_argv_c_str->front (), &(new_argv_c_str->front ()))) { std::cerr << "Failed to re-execute process as UNIX cleanup helper tool: " << std::strerror (errno) << "\n" -- Alioth's /srv/git/code.x2go.org/x2goclient.git//..//_hooks_/post-receive-email on /srv/git/code.x2go.org/x2goclient.git
This is an automated email from the git hooks/post-receive script. x2go pushed a commit to branch bugfix/osx in repository x2goclient. commit e19230075b2776d837cafa219b88d33436ff12b7 Author: Mihai Moldovan <ionic@ionic.de> Date: Sat Mar 21 00:00:59 2015 +0100 {appdialog,configwidget,onmainwindow,unixhelper}.cpp: fix some compile warnings with GCC. Fix a few whitespace issues. --- debian/changelog | 2 ++ src/appdialog.cpp | 22 ++++++++++++---------- src/configwidget.cpp | 6 ++---- src/onmainwindow.cpp | 5 ++++- src/unixhelper.cpp | 7 +++++++ 5 files changed, 27 insertions(+), 15 deletions(-) diff --git a/debian/changelog b/debian/changelog index 93567a3..23cd29c 100644 --- a/debian/changelog +++ b/debian/changelog @@ -51,6 +51,8 @@ x2goclient (4.0.5.1-0x2go1) UNRELEASED; urgency=low and SIGUSR2. - x2goclient.cpp: fix failing exec() call for the UNIX helper utility: correctly terminate arguments vector. + - {appdialog,configwidget,onmainwindow,unixhelper}.cpp: fix some compile + warnings with GCC. Fix a few whitespace issues. [ Oleksandr Shneyder ] * New upstream release (4.0.5.1): diff --git a/src/appdialog.cpp b/src/appdialog.cpp index f10be8f..a8ec4ec 100644 --- a/src/appdialog.cpp +++ b/src/appdialog.cpp @@ -156,16 +156,18 @@ void AppDialog::loadApps() break; } - QTreeWidgetItem* it; - if (app.category==Application::TOP) - it=new QTreeWidgetItem(treeWidget); - else - it=new QTreeWidgetItem(parent); - it->setText(0, app.name); - it->setToolTip(0,app.comment); - it->setIcon(0,app.icon); - it->setData(0, Qt::UserRole, app.exec); - it->setData(0, Qt::UserRole+1, app.comment); + if (parent) { + QTreeWidgetItem* it; + if (app.category==Application::TOP) + it=new QTreeWidgetItem(treeWidget); + else + it=new QTreeWidgetItem(parent); + it->setText(0, app.name); + it->setToolTip(0,app.comment); + it->setIcon(0,app.icon); + it->setData(0, Qt::UserRole, app.exec); + it->setData(0, Qt::UserRole+1, app.comment); + } } treeWidget->sortItems(0,Qt::AscendingOrder); } diff --git a/src/configwidget.cpp b/src/configwidget.cpp index e98ad4d..c9b8baa 100644 --- a/src/configwidget.cpp +++ b/src/configwidget.cpp @@ -24,8 +24,8 @@ ConfigWidget::ConfigWidget ( QString id, ONMainWindow * mw, { sessionId=id; mainWindow=mw; - miniMode=mw->retMiniMode(); - embedMode=embedMode= mw->getEmbedMode(); + miniMode=mw->retMiniMode(); + embedMode = mw->getEmbedMode(); if(embedMode) sessionId="embedded"; } @@ -34,5 +34,3 @@ ConfigWidget::ConfigWidget ( QString id, ONMainWindow * mw, ConfigWidget::~ConfigWidget() { } - - diff --git a/src/onmainwindow.cpp b/src/onmainwindow.cpp index 35faced..c57b168 100644 --- a/src/onmainwindow.cpp +++ b/src/onmainwindow.cpp @@ -4178,8 +4178,10 @@ void ONMainWindow::resumeSession ( const x2goSession& s ) if (! startXorgOnStart) startXOrg(); // #endif +#else /* defined (Q_OS_WIN) */ + UNUSED (rootless); +#endif /* defined (Q_OS_WIN) */ -#endif if ( fullscreen ) { geometry="fullscreen"; @@ -10610,6 +10612,7 @@ void ONMainWindow::slotEmbedIntoParentWindow() void ONMainWindow::processSessionConfig() { bool haveKey=false; + UNUSED (haveKey); config.command="KDE"; config.brokerNoAuth=false; diff --git a/src/unixhelper.cpp b/src/unixhelper.cpp index acdee33..d5aa67d 100644 --- a/src/unixhelper.cpp +++ b/src/unixhelper.cpp @@ -29,6 +29,7 @@ #include <cstring> #include <cerrno> #include <vector> +#include <cstdlib> /* For documentation please see unixhelper.h. */ @@ -117,6 +118,12 @@ namespace unixhelper { sleep (2); } + + /* + * Anything here shall be unreachable. + * But make compilers happy by returning something. + */ + return (EXIT_SUCCESS); } } -- Alioth's /srv/git/code.x2go.org/x2goclient.git//..//_hooks_/post-receive-email on /srv/git/code.x2go.org/x2goclient.git
This is an automated email from the git hooks/post-receive script. x2go pushed a commit to branch bugfix/osx in repository x2goclient. commit 1ab6491232700e2984a53640f7d0429421d95b31 Author: Mihai Moldovan <ionic@ionic.de> Date: Wed Mar 18 22:22:27 2015 +0100 unixhelper.{cpp,h}: ignore SIGINT, SIGTERM, SIGPIPE, SIGQUIT, SIGUSR1 and SIGUSR2. --- debian/changelog | 2 ++ src/unixhelper.cpp | 18 +++++++++++++----- src/unixhelper.h | 3 +++ 3 files changed, 18 insertions(+), 5 deletions(-) diff --git a/debian/changelog b/debian/changelog index 62fabb2..39b6199 100644 --- a/debian/changelog +++ b/debian/changelog @@ -47,6 +47,8 @@ x2goclient (4.0.5.1-0x2go1) UNRELEASED; urgency=low to 10 seconds. - {unixhelper.{cpp,h},x2goclient.cpp}: switch main cleanup handling to parent PID polling. + - unixhelper.{cpp,h}: ignore SIGINT, SIGTERM, SIGPIPE, SIGQUIT, SIGUSR1 + and SIGUSR2. [ Oleksandr Shneyder ] * New upstream release (4.0.5.1): diff --git a/src/unixhelper.cpp b/src/unixhelper.cpp index 410c320..acdee33 100644 --- a/src/unixhelper.cpp +++ b/src/unixhelper.cpp @@ -28,7 +28,7 @@ #include <iostream> #include <cstring> #include <cerrno> -#include <cstdlib> +#include <vector> /* For documentation please see unixhelper.h. */ @@ -69,15 +69,23 @@ namespace unixhelper { /* Anything here shall be unreachable. */ } - { + std::vector<int> ignore_signals; + ignore_signals.push_back (SIGINT); + ignore_signals.push_back (SIGTERM); + ignore_signals.push_back (SIGPIPE); + ignore_signals.push_back (SIGQUIT); + ignore_signals.push_back (SIGUSR1); + ignore_signals.push_back (SIGUSR2); + + for (std::vector<int>::iterator it = ignore_signals.begin (); it != ignore_signals.end (); ++it) { struct sigaction sig_action; sig_action.sa_handler = SIG_IGN; sig_action.sa_mask = empty_set; sig_action.sa_flags = SA_RESTART; - /* Set up signal handler to ignore SIGTERM. */ - if (0 != sigaction (SIGTERM, &sig_action, NULL)) { - std::cerr << "Unable to ignore SIGTERM: " << std::strerror (errno) << std::endl; + /* Set up signal handler to ignore the current signal. */ + if (0 != sigaction (*it, &sig_action, NULL)) { + std::cerr << "Unable to ignore signal " << strsignal (*it) << ": " << std::strerror (errno) << std::endl; kill_pgroup (-1); /* Anything here shall be unreachable. */ diff --git a/src/unixhelper.h b/src/unixhelper.h index 7511d4d..a34456e 100644 --- a/src/unixhelper.h +++ b/src/unixhelper.h @@ -35,6 +35,9 @@ namespace unixhelper { * an emergency exit is performed and * the whole process group killed. * + * The signals SIGINT, SIGTERM, SIGPIPE, SIGQUIT, SIGUSR1 and + * SIGUSR2 are ignored. + * * Loops indefinitely afterwards. * * In this loop, the current parent PID is polled and compared against -- Alioth's /srv/git/code.x2go.org/x2goclient.git//..//_hooks_/post-receive-email on /srv/git/code.x2go.org/x2goclient.git
This is an automated email from the git hooks/post-receive script. x2go pushed a commit to branch bugfix/osx in repository x2goclient. commit 3d26d1177b81cc7d20efa2e451ea30bf563f5825 Author: Mihai Moldovan <ionic@ionic.de> Date: Sat Mar 21 03:58:18 2015 +0100 onmainwindow.cpp: correctly use ~/.x2go/.ssh as ssh directory when starting sshd in user mode. Put the authorized_keys file in there. Check and set correct permissions for both the directory and authorized_keys file. Generalize some Windows-specific sections by using QDir and QFile. --- debian/changelog | 4 ++ src/onmainwindow.cpp | 183 +++++++++++++++++++++++++++++++++----------------- 2 files changed, 126 insertions(+), 61 deletions(-) diff --git a/debian/changelog b/debian/changelog index 57479a5..88bfedf 100644 --- a/debian/changelog +++ b/debian/changelog @@ -55,6 +55,10 @@ x2goclient (4.0.5.1-0x2go1) UNRELEASED; urgency=low warnings with GCC. Fix a few whitespace issues. - appdialog.cpp: initialize parent in default case. Another GCC compile warning fix. + - onmainwindow.cpp: correctly use ~/.x2go/.ssh as ssh directory when + starting sshd in user mode. Put the authorized_keys file in there. Check + and set correct permissions for both the directory and authorized_keys + file. Generalize some Windows-specific sections by using QDir and QFile. [ Oleksandr Shneyder ] * New upstream release (4.0.5.1): diff --git a/src/onmainwindow.cpp b/src/onmainwindow.cpp index c57b168..5dc15d8 100644 --- a/src/onmainwindow.cpp +++ b/src/onmainwindow.cpp @@ -7947,43 +7947,54 @@ void ONMainWindow::slotRetExportDir ( bool result,QString output, QByteArray line = file.readLine(); file.close(); - QString authofname=homeDir; -#ifdef Q_OS_WIN - QDir dir; - dir.mkpath ( authofname+"\\.x2go\\.ssh" ); - x2goDebug<<"Creating "<<authofname+"\\.x2go\\.ssh"; + QDir authorized_keys_dir (homeDir); - authofname=wapiShortFileName ( authofname ) +"/.x2go"; -#endif - authofname+="/.ssh/authorized_keys" ; - file.setFileName ( authofname ); - if ( !file.open ( QIODevice::ReadOnly | QIODevice::Text ) ) - { - printSshDError_noAuthorizedKeysFile(); - QFile::remove - ( key+".pub" ); - return; + /* + * Do the user SSHD/global SSHD dance here and either use the + * private .x2go/.ssh or the global .ssh dir. + */ + if (userSshd) { + authorized_keys_dir = QDir (authorized_keys_dir.absolutePath () + "/.x2go/"); } + authorized_keys_dir = QDir (authorized_keys_dir.absolutePath () + "/.ssh/"); + QFile authorized_keys_file (authorized_keys_dir.absolutePath () + "/authorized_keys"); - QTemporaryFile tfile ( authofname ); - tfile.open(); - tfile.setAutoRemove ( true ); - QTextStream out ( &tfile ); + /* + * We do not try to create the file first. + * This has been already done in startX2goMount(). + * We wouldn't be here if that failed. + */ + if (!authorized_keys_file.open (QIODevice::ReadOnly | QIODevice::Text)) { + printSshDError_noAuthorizedKeysFile (); + QFile::remove (key + ".pub"); + return; + } - while ( !file.atEnd() ) - { - QByteArray newline = file.readLine(); - if ( newline!=line ) - out<<newline; + QTemporaryFile tfile (authorized_keys_file.fileName ()); + tfile.open (); + tfile.setPermissions (QFile::ReadOwner | QFile::WriteOwner); + tfile.setAutoRemove (true); + QTextStream out (&tfile); + + /* + * Copy the content of the authorized_keys file to our new temporary file + * and remove the public authorized key for the current "session" again. + */ + while (!authorized_keys_file.atEnd ()) { + QByteArray newline = authorized_keys_file.readLine (); + if (newline != line) + out << newline; } - file.close(); - tfile.close(); - file.remove(); - tfile.copy ( authofname ); - QFile::remove - ( key+".pub" ); + + authorized_keys_file.close (); + tfile.close (); + + authorized_keys_file.remove (); + + tfile.copy (authorized_keys_file.fileName ()); + QFile::remove (key + ".pub"); } @@ -9208,41 +9219,90 @@ void ONMainWindow::startX2goMount() QByteArray line = file.readLine(); file.close(); - QString authofname=homeDir; -#ifdef Q_OS_WIN - QDir tdir; - tdir.mkpath ( authofname+"\\.x2go\\.ssh" ); - x2goDebug<<"Creating "<<authofname+"\\.x2go\\.ssh"; + QDir authorized_keys_dir (homeDir); - authofname=wapiShortFileName ( authofname ) +"/.x2go"; -#endif - authofname+= "/.ssh/authorized_keys" ; + /* + * Do the user SSHD/global SSHD dance here and either use the + * private .x2go/.ssh or the global .ssh dir. + */ + if (userSshd) { + authorized_keys_dir = QDir (authorized_keys_dir.absolutePath () + "/.x2go/"); + } - QFile file1 ( authofname ); + authorized_keys_dir = QDir (authorized_keys_dir.absolutePath () + "/.ssh/"); + QFile authorized_keys_file (authorized_keys_dir.absolutePath () + "/authorized_keys"); - if ( !file1.open ( QIODevice::WriteOnly | QIODevice::Text | - QIODevice::Append ) ) - { - QString message=tr ( "Unable to write:\n" ) + authofname; - QMessageBox::critical ( 0l,tr ( "Error" ),message, - QMessageBox::Ok, - QMessageBox::NoButton ); - QFile::remove - ( fsExportKey+".pub" ); - return; + if (userSshd) { + x2goDebug << "Creating dir " << authorized_keys_dir.absolutePath (); + authorized_keys_dir.mkpath (authorized_keys_dir.absolutePath ()); + } + x2goDebug << "Potentially creating file " << authorized_keys_file.fileName (); + if (!authorized_keys_file.open (QIODevice::WriteOnly | QIODevice::Text | QIODevice::Append)) { + QString message = tr ("Unable to create or append to file: ") + authorized_keys_file.fileName (); + QMessageBox::critical (0l, tr ("Error"), message, + QMessageBox::Ok, QMessageBox::NoButton); + QFile::remove (fsExportKey + ".pub"); + return; } - directory* dir=getExpDir ( fsExportKey ); - bool rem=dir->isRemovable; - if ( !dir ) - return; - QTextStream out ( &file1 ); - out<<line; - file1.close(); +#ifdef Q_OS_UNIX + QFile::Permissions authorized_keys_file_perm = authorized_keys_file.permissions (); + QFile::Permissions authorized_keys_file_target_perm = QFile::ReadOwner | QFile::WriteOwner; + + bool permission_error = false; + + /* + * Try to set the permissions if they are wrong. + * (sshd would disallow such a file.) + */ + if (authorized_keys_file_perm != authorized_keys_file_target_perm) { + if (!authorized_keys_file.setPermissions (authorized_keys_file_target_perm)) { + /* FIXME: use a function for this... */ + QString message = tr ("Unable to change the permissions of file: ") + authorized_keys_file.fileName (); + message += "\n" + tr ("This is an error because sshd would deny such a file."); + QMessageBox::critical (NULL, tr ("Error"), message, + QMessageBox::Ok, QMessageBox::NoButton); + permission_error = true; + } + } + + QFile::Permissions authorized_keys_dir_perm = QFile (authorized_keys_dir.absolutePath ()).permissions (); + QFile::Permissions authorized_keys_dir_target_perm = QFile::ReadOwner | QFile::WriteOwner | QFile::ExeOwner; + + /* + * Try to set the permissions if they are wrong. + * (sshd would disallow such a directory.) + */ + if (authorized_keys_dir_perm != authorized_keys_dir_target_perm) { + if (!QFile (authorized_keys_dir.absolutePath ()).setPermissions (authorized_keys_dir_target_perm)) { + /* FIXME: use a function for this... */ + QString message = tr ("Unable to change the permissions of directory: ") + authorized_keys_dir.absolutePath (); + message += "\n" + tr ("This is an error because sshd would deny such a directory."); + QMessageBox::critical (NULL, tr ("Error"), message, + QMessageBox::Ok, QMessageBox::NoButton); + permission_error = true; + } + } + + if (permission_error) { + QFile::remove (fsExportKey + ".pub"); + return; + } +#endif /* defined (Q_OS_UNIX) */ + + directory* dir = getExpDir (fsExportKey); + bool rem = dir->isRemovable; + if (!dir) { + return; + } - x2goDebug<<"Temporarily activated public key from file "<<fsExportKey<<".pub."<<endl; + QTextStream out (&authorized_keys_file); + out << line; + authorized_keys_file.close (); + + x2goDebug << "Temporarily activated public key from file " << fsExportKey << ".pub."; QString passwd=getCurrentPass(); QString user=getCurrentUname(); @@ -10020,18 +10080,19 @@ void ONMainWindow::generateEtcFiles() QFile file ( etcDir +"/sshd_config" ); if ( !file.open ( QIODevice::WriteOnly | QIODevice::Text ) ) return; + QString authKeyPath = homeDir + "/.x2go/.ssh/authorized_keys"; #ifdef Q_OS_WIN - QString authKeyPath=cygwinPath ( homeDir+"/.x2go/.ssh/authorized_keys" ); - authKeyPath.replace(wapiGetUserName(),"%u"); -#endif + authKeyPath = cygwinPath (authKeyPath); + authKeyPath.replace (wapiGetUserName (), "%u"); +#endif /* defined (Q_OS_WIN) */ QTextStream out ( &file ); out<<"StrictModes no\n"<< "UsePrivilegeSeparation no\n"<< "PidFile \"" + varDir + "/sshd.pid\"\n" << + "AuthorizedKeysFile \"" << authKeyPath << "\"\n" << #ifdef Q_OS_WIN "Subsystem shell "<< wapiShortFileName ( appDir) +"/sh"+"\n"<< "Subsystem sftp "<< wapiShortFileName ( appDir) +"/sftp-server"+"\n"<< - "AuthorizedKeysFile \""<<authKeyPath<<"\""; #else /* This may need some sanitization, i.e., appDir could potentially include whitespace. */ "Subsystem sftp " -- Alioth's /srv/git/code.x2go.org/x2goclient.git//..//_hooks_/post-receive-email on /srv/git/code.x2go.org/x2goclient.git
This is an automated email from the git hooks/post-receive script. x2go pushed a commit to branch bugfix/osx in repository x2goclient. commit 80fa020e6c3b1f2dddb68abd24a4566470d5ea98 Author: Mihai Moldovan <ionic@ionic.de> Date: Sat Mar 21 00:04:44 2015 +0100 appdialog.cpp: initialize parent in default case. Another GCC compile warning fix. --- debian/changelog | 2 ++ src/appdialog.cpp | 1 + 2 files changed, 3 insertions(+) diff --git a/debian/changelog b/debian/changelog index 23cd29c..57479a5 100644 --- a/debian/changelog +++ b/debian/changelog @@ -53,6 +53,8 @@ x2goclient (4.0.5.1-0x2go1) UNRELEASED; urgency=low correctly terminate arguments vector. - {appdialog,configwidget,onmainwindow,unixhelper}.cpp: fix some compile warnings with GCC. Fix a few whitespace issues. + - appdialog.cpp: initialize parent in default case. Another GCC compile + warning fix. [ Oleksandr Shneyder ] * New upstream release (4.0.5.1): diff --git a/src/appdialog.cpp b/src/appdialog.cpp index a8ec4ec..013eb79 100644 --- a/src/appdialog.cpp +++ b/src/appdialog.cpp @@ -153,6 +153,7 @@ void AppDialog::loadApps() parent=other; break; default: + parent = NULL; break; } -- Alioth's /srv/git/code.x2go.org/x2goclient.git//..//_hooks_/post-receive-email on /srv/git/code.x2go.org/x2goclient.git
This is an automated email from the git hooks/post-receive script. x2go pushed a commit to branch bugfix/osx in repository x2goclient. commit bde5c452fd873c86efdcc2ab01824b4a5eafd95f Author: Mihai Moldovan <ionic@ionic.de> Date: Sat Mar 21 23:40:41 2015 +0100 compat.{cpp,h}: remove inline keyword, because function is not defined in header file. --- debian/changelog | 2 ++ src/compat.cpp | 2 +- src/compat.h | 2 +- 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/debian/changelog b/debian/changelog index 1e7a6df..9f5699b 100644 --- a/debian/changelog +++ b/debian/changelog @@ -61,6 +61,8 @@ x2goclient (4.0.5.1-0x2go1) UNRELEASED; urgency=low file. Generalize some Windows-specific sections by using QDir and QFile. - compat.{cpp,h}: new files. Implements strndup on OS X 10.6 and below. Add to x2goclient.cpp, x2goclient.pro and x2goclient.pro.maemo. + - compat.{cpp,h}: remove inline keyword, because function is not defined + in header file. [ Oleksandr Shneyder ] * New upstream release (4.0.5.1): diff --git a/src/compat.cpp b/src/compat.cpp index 877d07b..c443489 100644 --- a/src/compat.cpp +++ b/src/compat.cpp @@ -29,7 +29,7 @@ #include <string.h> #include <stdlib.h> -inline char *strndup (const char *s, size_t n) { +char *strndup (const char *s, size_t n) { char *result; size_t len = strlen (s); diff --git a/src/compat.h b/src/compat.h index 8b9d77e..36b71ef 100644 --- a/src/compat.h +++ b/src/compat.h @@ -31,7 +31,7 @@ #include <string.h> #include <stdlib.h> -inline char *strndup (const char *s, size_t n); +char *strndup (const char *s, size_t n); #endif /* MAC_OS_X_VERSION_MIN_REQUIRED */ #endif /* defined (Q_OS_DARWIN) */ -- Alioth's /srv/git/code.x2go.org/x2goclient.git//..//_hooks_/post-receive-email on /srv/git/code.x2go.org/x2goclient.git
This is an automated email from the git hooks/post-receive script. x2go pushed a commit to branch bugfix/osx in repository x2goclient. commit d4e6a8b9da6fe47547dd5c7aa6fc38846a8aa011 Author: Mihai Moldovan <ionic@ionic.de> Date: Sat Mar 21 23:30:54 2015 +0100 compat.{cpp,h}: new files. Implements strndup on OS X 10.6 and below. Add to x2goclient.cpp, x2goclient.pro and x2goclient.pro.maemo. --- debian/changelog | 2 ++ src/compat.cpp | 49 +++++++++++++++++++++++++++++++++++++++++++++++++ src/compat.h | 38 ++++++++++++++++++++++++++++++++++++++ src/x2goclient.cpp | 1 + x2goclient.pro | 6 ++++-- x2goclient.pro.maemo | 6 ++++-- 6 files changed, 98 insertions(+), 4 deletions(-) diff --git a/debian/changelog b/debian/changelog index 88bfedf..1e7a6df 100644 --- a/debian/changelog +++ b/debian/changelog @@ -59,6 +59,8 @@ x2goclient (4.0.5.1-0x2go1) UNRELEASED; urgency=low starting sshd in user mode. Put the authorized_keys file in there. Check and set correct permissions for both the directory and authorized_keys file. Generalize some Windows-specific sections by using QDir and QFile. + - compat.{cpp,h}: new files. Implements strndup on OS X 10.6 and below. + Add to x2goclient.cpp, x2goclient.pro and x2goclient.pro.maemo. [ Oleksandr Shneyder ] * New upstream release (4.0.5.1): diff --git a/src/compat.cpp b/src/compat.cpp new file mode 100644 index 0000000..877d07b --- /dev/null +++ b/src/compat.cpp @@ -0,0 +1,49 @@ +/*************************************************************************** + * Copyright (C) 2015 by Mihai Moldovan <ionic@ionic.de> +49 721 14595728 * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY 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, write to the * + * Free Software Foundation, Inc., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ + +#include "compat.h" + +#ifdef Q_OS_DARWIN +/* + * strndup() is not available on 10.6 and below, define a compat version here. + * Shameless copy from libiberty. + */ +#if MAC_OS_X_VERSION_MIN_REQUIRED < 1070 +#include <stddef.h> +#include <string.h> +#include <stdlib.h> + +inline char *strndup (const char *s, size_t n) { + char *result; + size_t len = strlen (s); + + if (n < len) { + len = n; + } + + result = (char *) malloc (len + 1); + if (!result) { + return (0); + } + + result[len] = '\0'; + return ((char *) memcpy (result, s, len)); +} +#endif /* MAC_OS_X_VERSION_MIN_REQUIRED */ +#endif /* defined (Q_OS_DARWIN) */ diff --git a/src/compat.h b/src/compat.h new file mode 100644 index 0000000..8b9d77e --- /dev/null +++ b/src/compat.h @@ -0,0 +1,38 @@ +/*************************************************************************** + * Copyright (C) 2015 by Mihai Moldovan <ionic@ionic.de> +49 721 14595728 * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY 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, write to the * + * Free Software Foundation, Inc., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ + + +#ifndef COMPAT_H +#define COMPAT_H + +#ifdef Q_OS_DARWIN +/* + * strndup() is not available on 10.6 and below, define a compat version here. + * Shameless copy from libiberty. + */ +#if MAC_OS_X_VERSION_MIN_REQUIRED < 1070 +#include <stddef.h> +#include <string.h> +#include <stdlib.h> + +inline char *strndup (const char *s, size_t n); +#endif /* MAC_OS_X_VERSION_MIN_REQUIRED */ +#endif /* defined (Q_OS_DARWIN) */ + +#endif /* !defined (COMPAT_H) */ diff --git a/src/x2goclient.cpp b/src/x2goclient.cpp index d8ae6fa..b7fe5bc 100644 --- a/src/x2goclient.cpp +++ b/src/x2goclient.cpp @@ -30,6 +30,7 @@ #include "unixhelper.h" #include "ongetpass.h" +#include "compat.h" int wrap_x2go_main (int argc, char **argv) { return (x2goMain (argc, argv)); diff --git a/x2goclient.pro b/x2goclient.pro index def49d9..ff2b762 100644 --- a/x2goclient.pro +++ b/x2goclient.pro @@ -80,7 +80,8 @@ HEADERS += src/configdialog.h \ src/folderexplorer.h \ src/non_modal_messagebox.h \ src/help.h \ - src/unixhelper.h + src/unixhelper.h \ + src/compat.h SOURCES += src/sharewidget.cpp \ src/settingswidget.cpp \ @@ -124,7 +125,8 @@ SOURCES += src/sharewidget.cpp \ src/folderexplorer.cpp \ src/non_modal_messagebox.cpp \ src/help.cpp \ - src/unixhelper.cpp + src/unixhelper.cpp \ + src/compat.cpp LIBS += -lssh win32:LIBS += -lAdvAPI32 -lshell32 -lUser32 diff --git a/x2goclient.pro.maemo b/x2goclient.pro.maemo index 63cc3d8..905ef77 100644 --- a/x2goclient.pro.maemo +++ b/x2goclient.pro.maemo @@ -36,7 +36,8 @@ HEADERS += src/configdialog.h \ src/sharewidget.h \ src/clicklineedit.h \ src/help.h \ - src/unixhelper.h + src/unixhelper.h \ + src/compat.h SOURCES += src/sharewidget.cpp \ src/settingswidget.cpp \ @@ -64,7 +65,8 @@ SOURCES += src/sharewidget.cpp \ src/wapi.cpp \ src/clicklineedit.cpp \ src/help.cpp \ - src/unixhelper.cpp + src/unixhelper.cpp \ + src/compat.cpp TEMPLATE = app TARGET = -- Alioth's /srv/git/code.x2go.org/x2goclient.git//..//_hooks_/post-receive-email on /srv/git/code.x2go.org/x2goclient.git
This is an automated email from the git hooks/post-receive script. x2go pushed a commit to branch bugfix/osx in repository x2goclient. commit b5dd59e85ba46932bfb5c6c6557fe5194a378c8b Author: Mihai Moldovan <ionic@ionic.de> Date: Sat Mar 21 23:51:37 2015 +0100 compat.h: include QtCore/qglobal.h for Q_OS_... macros. --- debian/changelog | 1 + src/compat.h | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/debian/changelog b/debian/changelog index 9f5699b..2b40111 100644 --- a/debian/changelog +++ b/debian/changelog @@ -63,6 +63,7 @@ x2goclient (4.0.5.1-0x2go1) UNRELEASED; urgency=low Add to x2goclient.cpp, x2goclient.pro and x2goclient.pro.maemo. - compat.{cpp,h}: remove inline keyword, because function is not defined in header file. + - compat.h: include QtCore/qglobal.h for Q_OS_... macros. [ Oleksandr Shneyder ] * New upstream release (4.0.5.1): diff --git a/src/compat.h b/src/compat.h index 36b71ef..39da9eb 100644 --- a/src/compat.h +++ b/src/compat.h @@ -17,10 +17,11 @@ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * ***************************************************************************/ - #ifndef COMPAT_H #define COMPAT_H +#include <QtCore/qglobal.h> + #ifdef Q_OS_DARWIN /* * strndup() is not available on 10.6 and below, define a compat version here. -- Alioth's /srv/git/code.x2go.org/x2goclient.git//..//_hooks_/post-receive-email on /srv/git/code.x2go.org/x2goclient.git
This is an automated email from the git hooks/post-receive script. x2go pushed a commit to branch bugfix/osx in repository x2goclient. commit 3676beb969739a6abdc64fab3ded49cbb96edf75 Author: Mihai Moldovan <ionic@ionic.de> Date: Wed Apr 29 02:36:24 2015 +0200 x2goclient.pro{maemo}: reference new pulsemanager.{cpp,h} files. --- debian/changelog | 1 + x2goclient.pro | 6 ++++-- x2goclient.pro.maemo | 6 ++++-- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/debian/changelog b/debian/changelog index e0585a1..15ca02c 100644 --- a/debian/changelog +++ b/debian/changelog @@ -65,6 +65,7 @@ x2goclient (4.0.5.1-0x2go1) UNRELEASED; urgency=low in header file. - compat.h: include QtCore/qglobal.h for Q_OS_... macros. - pulsemanager.{cpp,h}: new class for PulseAudio management. + - x2goclient.pro{,.maemo}: reference new pulsemanager.{cpp,h} files. [ Oleksandr Shneyder ] * New upstream release (4.0.5.1): diff --git a/x2goclient.pro b/x2goclient.pro index ff2b762..957d61c 100644 --- a/x2goclient.pro +++ b/x2goclient.pro @@ -81,7 +81,8 @@ HEADERS += src/configdialog.h \ src/non_modal_messagebox.h \ src/help.h \ src/unixhelper.h \ - src/compat.h + src/compat.h \ + src/pulsemanager.h SOURCES += src/sharewidget.cpp \ src/settingswidget.cpp \ @@ -126,7 +127,8 @@ SOURCES += src/sharewidget.cpp \ src/non_modal_messagebox.cpp \ src/help.cpp \ src/unixhelper.cpp \ - src/compat.cpp + src/compat.cpp \ + src/pulsemanager.cpp LIBS += -lssh win32:LIBS += -lAdvAPI32 -lshell32 -lUser32 diff --git a/x2goclient.pro.maemo b/x2goclient.pro.maemo index 905ef77..4a06622 100644 --- a/x2goclient.pro.maemo +++ b/x2goclient.pro.maemo @@ -37,7 +37,8 @@ HEADERS += src/configdialog.h \ src/clicklineedit.h \ src/help.h \ src/unixhelper.h \ - src/compat.h + src/compat.h \ + src/pulsemanager.h SOURCES += src/sharewidget.cpp \ src/settingswidget.cpp \ @@ -66,7 +67,8 @@ SOURCES += src/sharewidget.cpp \ src/clicklineedit.cpp \ src/help.cpp \ src/unixhelper.cpp \ - src/compat.cpp + src/compat.cpp \ + src/pulsemanager.cpp TEMPLATE = app TARGET = -- Alioth's /srv/git/code.x2go.org/x2goclient.git//..//_hooks_/post-receive-email on /srv/git/code.x2go.org/x2goclient.git
This is an automated email from the git hooks/post-receive script. x2go pushed a commit to branch bugfix/osx in repository x2goclient. commit 22d979be3f8cac2bd0d8bcb1e10bbdf85c3c2387 Author: Mihai Moldovan <ionic@ionic.de> Date: Wed Apr 29 02:34:13 2015 +0200 pulsemanager.{cpp,h}: new class for PulseAudio management. --- debian/changelog | 1 + src/pulsemanager.cpp | 270 ++++++++++++++++++++++++++++++++++++++++++++++++++ src/pulsemanager.h | 92 +++++++++++++++++ 3 files changed, 363 insertions(+) diff --git a/debian/changelog b/debian/changelog index 2b40111..e0585a1 100644 --- a/debian/changelog +++ b/debian/changelog @@ -64,6 +64,7 @@ x2goclient (4.0.5.1-0x2go1) UNRELEASED; urgency=low - compat.{cpp,h}: remove inline keyword, because function is not defined in header file. - compat.h: include QtCore/qglobal.h for Q_OS_... macros. + - pulsemanager.{cpp,h}: new class for PulseAudio management. [ Oleksandr Shneyder ] * New upstream release (4.0.5.1): diff --git a/src/pulsemanager.cpp b/src/pulsemanager.cpp new file mode 100644 index 0000000..af1ba2b --- /dev/null +++ b/src/pulsemanager.cpp @@ -0,0 +1,270 @@ +/*************************************************************************** + * Copyright (C) 2012-2015 by Mihai Moldovan <ionic@ionic.de> * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY 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, write to the * + * Free Software Foundation, Inc., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ + +#include "pulsemanager.h" + +#ifndef DEBUG +#define DEBUG_UNDEF +#define DEBUG +#endif + +PulseManager::PulseManager () { + _pulse_X2Go = "/.x2go/pulse"; + + _pulse_dir = QDir (QDir::homePath ()); + _pulse_dir.mkpath (_pulse_dir.absolutePath () + _pulse_X2Go + "/tmp"); + _pulse_dir.cd (_pulse_X2Go.mid (1)); + + _env = QProcessEnvironment::systemEnvironment (); + _env.insert ("HOME", _pulse_dir.absolutePath ()); + _env.insert ("TEMP", _pulse_dir.absolutePath () + "/tmp"); + + _pulse_port = 4713; + + _state = QProcess::NotRunning; + + _pulse_server = 0; + + _app_dir = QApplication::applicationDirPath (); +} + +PulseManager::~PulseManager () { + if (_pulse_server && is_server_running ()) + shutdown (); + + delete (_pulse_server); +} + +void PulseManager::start () { + assert (!is_server_running ()); + + delete (_pulse_server); + + _pulse_server = new QProcess (0); + _state = QProcess::Starting; + +#ifdef Q_OS_DARWIN + start_osx (); +#elif defined (Q_OS_WIN) + start_win (); +#elif defined (Q_OS_LINUX) + start_linux (); +#endif +} + +void PulseManager::start_osx () { + find_port (); + + if (generate_server_config () && generate_client_config ()) { + cleanup_client_dir (); + + _pulse_server->setProcessEnvironment (_env); + + QStringList args; + args << "--exit-idle-time=-1" << "-n" + << "-F" << _pulse_dir.absolutePath () + "/config.pa" + << "-p" + << QDir (_app_dir + + "/../Frameworks/pulse-2.0/modules").absolutePath () + << "--high-priority"; +#ifdef DEBUG + args << "--log-level=debug"; +#endif + + _pulse_server->setWorkingDirectory (_app_dir + "/../exe/"); + _pulse_server->start (_app_dir + "/../exe/pulseaudio", args); + + if (_pulse_server->waitForStarted ()) { + x2goDebug << "pulse started with" << args << "waiting for finish..."; + _state = QProcess::Running; + + connect (_pulse_server, SIGNAL (finished (int)), + this, SLOT (on_pulse_finished (int))); + +#ifdef DEBUG + // Give PA a little time to come up. + QTimer::singleShot (5000, this, SLOT (slot_play_startup_sound ())); +#endif + } + } +} + +void PulseManager::find_port () { + QTcpSocket tcpSocket (0); + bool free = false; + + do { + tcpSocket.connectToHost ("127.0.0.1", _pulse_port); + + if (tcpSocket.waitForConnected (1000)) { + tcpSocket.close (); + free = false; + _pulse_port++; + } + else + free = true; + } while (!free); +} + +bool PulseManager::generate_server_config () { + QString config_file_name = _pulse_dir.absolutePath () + "/config.pa"; + QTemporaryFile config_tmp_file (_pulse_dir.absolutePath () + "/tmp/tmpconfig"); + X2goSettings settings ("settings"); + bool disable_input = false; + bool ret = false; + + disable_input = settings.setting ()->value ("soundnoinput", + (QVariant) false).toBool (); + + if (config_tmp_file.open ()) { + QTextStream config_tmp_file_stream (&config_tmp_file); + + config_tmp_file_stream << "load-module module-native-protocol-tcp port=" + + QString::number (_pulse_port) << endl; + config_tmp_file_stream << "load-module module-native-protocol-unix" << endl; + config_tmp_file_stream << "load-module module-coreaudio-detect"; + + if (disable_input) + config_tmp_file_stream << " record=0"; + + config_tmp_file_stream << endl; + + QFile config_file (config_file_name); + if (QFile::exists (config_file_name)) + QFile::remove (config_file_name); + + config_tmp_file.copy (config_file_name); + config_tmp_file.remove (); + + ret = true; + } + + return (ret); +} + +bool PulseManager::generate_client_config () { + QTemporaryFile client_config_tmp_file (_pulse_dir.absolutePath () + + "/tmp/tmpconfig"); + QString client_config_file_name (_pulse_dir.absolutePath () + "/.pulse/client.conf"); + bool ret = false; + + if (client_config_tmp_file.open ()) { + QTextStream config_tmp_file_stream (&client_config_tmp_file); + + config_tmp_file_stream << "autospawn=no" << endl; + config_tmp_file_stream << "daemon-binary=" + << QDir (_app_dir + + "/../exe/pulseaudio").absolutePath () + << endl; + + if (QFile::exists (client_config_file_name)) + QFile::remove (client_config_file_name); + + client_config_tmp_file.copy (client_config_file_name); + client_config_tmp_file.remove (); + + ret = true; + } + + return (ret); +} + +void PulseManager::cleanup_client_dir () { + // PA expects $HOME/.pulse/$HOST-runtime to be a symbolic link + // and will fail, if it's just a plain directory on Mac OS X. + // Delete it first. + QDir machine_dir (_pulse_dir.absolutePath () + "/.pulse/" + + QHostInfo::localHostName () + "-runtime"); + + if (QFile::exists (machine_dir.absolutePath () + "/pid")) + QFile::remove (machine_dir.absolutePath () + "/pid"); + + if (machine_dir.exists ()) + machine_dir.remove (machine_dir.absolutePath ()); +} + +void PulseManager::slot_play_startup_sound () { + QProcess play_file (0); + + play_file.setWorkingDirectory (_pulse_server->workingDirectory ()); + play_file.setProcessEnvironment (_env); + play_file.start (_app_dir + "/../exe/paplay " + + _app_dir + "/../Resources/startup.wav"); + + if (play_file.waitForStarted ()) + play_file.waitForFinished (); +} + +void PulseManager::on_pulse_finished (int exit_code) { + if (!exit_code) + x2goDebug << "Warning! Pulseaudio's exit code is non-zero."; + + QByteArray ba = _pulse_server->readAllStandardOutput (); + char *data = ba.data (); + std::cout << data; + ba = _pulse_server->readAllStandardError (); + data = ba.data (); + std::cout << data; + + _state = QProcess::NotRunning; + emit (sig_pulse_server_terminated ()); +} + +bool PulseManager::is_server_running () { + if (_pulse_server) + return (_pulse_server->state () == QProcess::Running); + else + return (false); +} + +void PulseManager::shutdown () { + QEventLoop loop; + + connect (this, SIGNAL (sig_pulse_server_terminated ()), + &loop, SLOT (quit ())); + + _pulse_server->terminate (); + + loop.exec (); +} + +int PulseManager::get_pulse_port () { + return (_pulse_port); +} + +void PulseManager::set_pulse_port (int pulse_port) { + _pulse_port = pulse_port; +} + +void PulseManager::relaunch () { + if (_pulse_server && is_server_running ()) + shutdown (); + + x2goDebug << "restarting pulse"; + start (); +} + +QProcess::ProcessState PulseManager::state () { + return (_state); +} + +#ifdef DEBUG_UNDEF +#undef DEBUG +#undef DEBUG_UNDEF +#endif diff --git a/src/pulsemanager.h b/src/pulsemanager.h new file mode 100644 index 0000000..fc0a989 --- /dev/null +++ b/src/pulsemanager.h @@ -0,0 +1,92 @@ +/*************************************************************************** + * Copyright (C) 2012-2015 by Mihai Moldovan <ionic@ionic.de> * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY 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, write to the * + * Free Software Foundation, Inc., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ + +#ifndef PULSEMANAGER_H +#define PULSEMANAGER_H + +#ifdef NDEBUG +#define NDEBUG_DEFINE +#undef NDEBUG +#endif + +#include <iostream> +#include <QDir> +#include <QTcpSocket> +#include <QEventLoop> +#include <QTemporaryFile> +#include <QHostInfo> +#include <QProcess> +#include <QApplication> +#include <QTimer> +#include <assert.h> +#include "x2gologdebug.h" +#include "x2gosettings.h" + +class PulseManager: public QObject +{ + Q_OBJECT; + +public: + PulseManager (); + ~PulseManager (); + int get_pulse_port (); + void set_pulse_port (int pulse_port); + QProcess::ProcessState state (); + +public slots: + void start (); + void relaunch (); + +private: + PulseManager (const PulseManager &other); + void start_osx (); + // FIXME + void start_win (); + // FIXME + void start_linux (); + void find_port (); + bool generate_server_config (); + bool generate_client_config (); + void cleanup_client_dir (); + void shutdown (); + bool is_server_running (); + +private slots: + void on_pulse_finished (int exit_code); + void slot_play_startup_sound (); + +signals: + void sig_pulse_server_terminated (); + +private: + QString _pulse_X2Go; + QDir _pulse_dir; + QProcessEnvironment _env; + QProcess *_pulse_server; + int _pulse_port; + QProcess::ProcessState _state; + QString _app_dir; +}; + +#ifdef NDEBUG_DEFINE +#define NDEBUG +#undef NDEBUG_DEFINE +#endif + +#endif // PULSEMANAGER_H -- Alioth's /srv/git/code.x2go.org/x2goclient.git//..//_hooks_/post-receive-email on /srv/git/code.x2go.org/x2goclient.git
This is an automated email from the git hooks/post-receive script. x2go pushed a commit to branch bugfix/osx in repository x2goclient. commit fff62fd408d0795aaf4fdc68b6b182c155824721 Author: Mihai Moldovan <ionic@ionic.de> Date: Sun May 3 23:16:27 2015 +0200 macbuild.sh: add new MACPORTS_PREFIX detection/variable. --- debian/changelog | 1 + macbuild.sh | 14 ++++++++++++++ 2 files changed, 15 insertions(+) diff --git a/debian/changelog b/debian/changelog index 15ca02c..1bee7ac 100644 --- a/debian/changelog +++ b/debian/changelog @@ -66,6 +66,7 @@ x2goclient (4.0.5.1-0x2go1) UNRELEASED; urgency=low - compat.h: include QtCore/qglobal.h for Q_OS_... macros. - pulsemanager.{cpp,h}: new class for PulseAudio management. - x2goclient.pro{,.maemo}: reference new pulsemanager.{cpp,h} files. + - macbuild.sh: add new MACPORTS_PREFIX detection/variable. [ Oleksandr Shneyder ] * New upstream release (4.0.5.1): diff --git a/macbuild.sh b/macbuild.sh index 097ac91..6c42c44 100755 --- a/macbuild.sh +++ b/macbuild.sh @@ -30,6 +30,7 @@ usage() { printf "\tDEBUG\t\t\t\tenables or disables debug builds [boolean]\n\t\t\t\t\tdefault: disabled\n" printf "\tBUNDLE\t\t\t\tenables or disables library bundling and the creation of a .dmg installer [boolean]\n\t\t\t\t\tdefault: enabled\n" printf "\tUNIVERSAL\t\t\tenables or disables x86 support. x86_64 support is always enabled [boolean]\n\t\t\t\t\tdefault: enabled\n" + printf "\tMACPORTS_PREFIX\t\t\tsets the (MacPorts) prefix used to detect PulseAudio and nxproxy binaries\n\t\t\t\t\tdefault: /opt/local/\n" printf "\n" printf "Boolean values help:\n" printf "\ta value of ${NO_VAL} will be treated as false\n" @@ -52,12 +53,25 @@ PROJECT="${TOP_DIR}/${NAME}.pro" PKG_DMG="${TOP_DIR}/pkg-dmg" NXPROXY="$(which nxproxy)" +# Try to find the MacPorts prefix. +typeset MACPORTS_PREFIX_SEARCH="" +if type -P port >/dev/null 2>&1; then + MACPORTS_PREFIX_SEARCH="$(type -P port)" + MACPORTS_PREFIX_SEARCH="${MACPORTS_PREFIX_SEARCH%%bin/port}" +else + # Port not being part find in ${PATH} doesn't necessarily mean it isn't available. + # Try to guess. + MACPORTS_PREFIX_SEARCH="/opt/local/" +fi : ${SDK:="/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.7.sdk"} : ${MACOSX_DEPLOYMENT_TARGET:="10.7"} : ${DEBUG:="0"} : ${BUNDLE:="1"} : ${UNIVERSAL:="1"} +: ${MACPORTS_PREFIX:="${MACPORTS_PREFIX_SEARCH}"} + +unset MACPORTS_PREFIX_SEARCH DEBUG="$(make_boolean "${DEBUG}")" BUNDLE="$(make_boolean "${BUNDLE}")" -- Alioth's /srv/git/code.x2go.org/x2goclient.git//..//_hooks_/post-receive-email on /srv/git/code.x2go.org/x2goclient.git
This is an automated email from the git hooks/post-receive script. x2go pushed a commit to branch bugfix/osx in repository x2goclient. commit f0382432c9fcdca0f4446333c0a51994289c2664 Author: Mihai Moldovan <ionic@ionic.de> Date: Sun May 3 23:19:59 2015 +0200 macbuild.sh: add new dependency_error() helper function. --- debian/changelog | 1 + macbuild.sh | 14 ++++++++++++++ 2 files changed, 15 insertions(+) diff --git a/debian/changelog b/debian/changelog index 1bee7ac..84082ac 100644 --- a/debian/changelog +++ b/debian/changelog @@ -67,6 +67,7 @@ x2goclient (4.0.5.1-0x2go1) UNRELEASED; urgency=low - pulsemanager.{cpp,h}: new class for PulseAudio management. - x2goclient.pro{,.maemo}: reference new pulsemanager.{cpp,h} files. - macbuild.sh: add new MACPORTS_PREFIX detection/variable. + - macbuild.sh: add new dependency_error() helper function. [ Oleksandr Shneyder ] * New upstream release (4.0.5.1): diff --git a/macbuild.sh b/macbuild.sh index 6c42c44..10b0f50 100755 --- a/macbuild.sh +++ b/macbuild.sh @@ -39,6 +39,20 @@ usage() { exit 2 } +dependency_error() { + exec >&2 + + typeset element="${1}"; shift + typeset component="${1}"; shift + typeset type="${1}"; shift + + echo "${element} ${type} not found." + echo "Install ${component} -- e.g., via "port -vt install ${component}" if using MacPorts." + echo "If ${component} is already installed, try passing MACPORTS_PREFIX if the autodetected or default value (${MACPORTS_PREFIX}) does not match your setup." + + exit 3 +} + MATCH_HELP='(^((-h)|(--help))([ ]|$))|([ ]+((-h)|(--help))([ ]|$))' [ -n "${*}" ] && [[ "${*}" =~ ${MATCH_HELP} ]] && usage -- Alioth's /srv/git/code.x2go.org/x2goclient.git//..//_hooks_/post-receive-email on /srv/git/code.x2go.org/x2goclient.git
This is an automated email from the git hooks/post-receive script. x2go pushed a commit to branch bugfix/osx in repository x2goclient. commit a3467595b5373c0aaefddab54feae9452a69d0fd Author: Mihai Moldovan <ionic@ionic.de> Date: Sun May 3 23:21:31 2015 +0200 macbuild.sh: add new lazy_canonical_path() helper function. --- debian/changelog | 1 + macbuild.sh | 12 ++++++++++++ 2 files changed, 13 insertions(+) diff --git a/debian/changelog b/debian/changelog index 84082ac..8c81031 100644 --- a/debian/changelog +++ b/debian/changelog @@ -68,6 +68,7 @@ x2goclient (4.0.5.1-0x2go1) UNRELEASED; urgency=low - x2goclient.pro{,.maemo}: reference new pulsemanager.{cpp,h} files. - macbuild.sh: add new MACPORTS_PREFIX detection/variable. - macbuild.sh: add new dependency_error() helper function. + - macbuild.sh: add new lazy_canonical_path() helper function. [ Oleksandr Shneyder ] * New upstream release (4.0.5.1): diff --git a/macbuild.sh b/macbuild.sh index 10b0f50..f222df8 100755 --- a/macbuild.sh +++ b/macbuild.sh @@ -53,6 +53,18 @@ dependency_error() { exit 3 } +lazy_canonical_path() { + typeset path="${1}" + + typeset old_path="" + while [ "${old_path}" != "${path}" ]; do + old_path="${path}" + path="${path//\/\///}" + done + + printf "${old_path}" +} + MATCH_HELP='(^((-h)|(--help))([ ]|$))|([ ]+((-h)|(--help))([ ]|$))' [ -n "${*}" ] && [[ "${*}" =~ ${MATCH_HELP} ]] && usage -- Alioth's /srv/git/code.x2go.org/x2goclient.git//..//_hooks_/post-receive-email on /srv/git/code.x2go.org/x2goclient.git
This is an automated email from the git hooks/post-receive script. x2go pushed a commit to branch bugfix/osx in repository x2goclient. commit 4f281dc78e8c4771e385325d0022b75c496f9a34 Author: Mihai Moldovan <ionic@ionic.de> Date: Sun May 3 23:22:49 2015 +0200 macbuild.sh: add new get_nesting_level() helper function. --- debian/changelog | 1 + macbuild.sh | 14 ++++++++++++++ 2 files changed, 15 insertions(+) diff --git a/debian/changelog b/debian/changelog index 8c81031..b2172d4 100644 --- a/debian/changelog +++ b/debian/changelog @@ -69,6 +69,7 @@ x2goclient (4.0.5.1-0x2go1) UNRELEASED; urgency=low - macbuild.sh: add new MACPORTS_PREFIX detection/variable. - macbuild.sh: add new dependency_error() helper function. - macbuild.sh: add new lazy_canonical_path() helper function. + - macbuild.sh: add new get_nesting_level() helper function. [ Oleksandr Shneyder ] * New upstream release (4.0.5.1): diff --git a/macbuild.sh b/macbuild.sh index f222df8..4d24e52 100755 --- a/macbuild.sh +++ b/macbuild.sh @@ -65,6 +65,20 @@ lazy_canonical_path() { printf "${old_path}" } +get_nesting_level() { +set -x + typeset -i level=0 + typeset path="${1}" + + while [ -n "${path}" ] && [ "${path}" != "." ] && [ "${path}" != "/" ]; do + i="$((${i} + 1))" + path="$(dirname "${path}")" + done + + printf "${level}" +set +x +} + MATCH_HELP='(^((-h)|(--help))([ ]|$))|([ ]+((-h)|(--help))([ ]|$))' [ -n "${*}" ] && [[ "${*}" =~ ${MATCH_HELP} ]] && usage -- Alioth's /srv/git/code.x2go.org/x2goclient.git//..//_hooks_/post-receive-email on /srv/git/code.x2go.org/x2goclient.git
This is an automated email from the git hooks/post-receive script. x2go pushed a commit to branch bugfix/osx in repository x2goclient. commit 39e2cd435045cb57e68bd3ebde8748572c1b3c13 Author: Mihai Moldovan <ionic@ionic.de> Date: Sun May 3 23:24:37 2015 +0200 macbuild.sh: add new repeat_str() helper function. --- debian/changelog | 1 + macbuild.sh | 16 ++++++++++++++++ 2 files changed, 17 insertions(+) diff --git a/debian/changelog b/debian/changelog index b2172d4..850c76d 100644 --- a/debian/changelog +++ b/debian/changelog @@ -70,6 +70,7 @@ x2goclient (4.0.5.1-0x2go1) UNRELEASED; urgency=low - macbuild.sh: add new dependency_error() helper function. - macbuild.sh: add new lazy_canonical_path() helper function. - macbuild.sh: add new get_nesting_level() helper function. + - macbuild.sh: add new repeat_str() helper function. [ Oleksandr Shneyder ] * New upstream release (4.0.5.1): diff --git a/macbuild.sh b/macbuild.sh index 4d24e52..83e0228 100755 --- a/macbuild.sh +++ b/macbuild.sh @@ -79,6 +79,22 @@ set -x set +x } +repeat_str() { # INPUT COUNT + typeset INPUT="${1:?"Error: no input string passed to ${FUNCNAME}()."}" + typeset COUNT="${2:?"Error: no count passed to ${FUNCNAME}()."}" + + typeset ret="" + typeset -i i=0 + while [ "${i}" -lt "${COUNT}" ]; do + ret="${ret}$(printf "${INPUT}")" + i=$((${i} + 1)) + done + + printf "${ret}" + + return 0 +} + MATCH_HELP='(^((-h)|(--help))([ ]|$))|([ ]+((-h)|(--help))([ ]|$))' [ -n "${*}" ] && [[ "${*}" =~ ${MATCH_HELP} ]] && usage -- Alioth's /srv/git/code.x2go.org/x2goclient.git//..//_hooks_/post-receive-email on /srv/git/code.x2go.org/x2goclient.git
This is an automated email from the git hooks/post-receive script. x2go pushed a commit to branch bugfix/osx in repository x2goclient. commit 535a5a9a5cf2cc9ebe50a4eca1166bd5177d3834 Author: Mihai Moldovan <ionic@ionic.de> Date: Sun May 3 23:28:02 2015 +0200 macbuild.sh: refactor nxproxy detection to use MACPORTS_PREFIX. --- debian/changelog | 1 + macbuild.sh | 8 +++++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/debian/changelog b/debian/changelog index 850c76d..0be6c2d 100644 --- a/debian/changelog +++ b/debian/changelog @@ -71,6 +71,7 @@ x2goclient (4.0.5.1-0x2go1) UNRELEASED; urgency=low - macbuild.sh: add new lazy_canonical_path() helper function. - macbuild.sh: add new get_nesting_level() helper function. - macbuild.sh: add new repeat_str() helper function. + - macbuild.sh: refactor nxproxy detection to use MACPORTS_PREFIX. [ Oleksandr Shneyder ] * New upstream release (4.0.5.1): diff --git a/macbuild.sh b/macbuild.sh index 83e0228..85ae181 100755 --- a/macbuild.sh +++ b/macbuild.sh @@ -108,7 +108,6 @@ DMGFILE="${BUILD_DIR}/${NAME}.dmg" PROJECT="${TOP_DIR}/${NAME}.pro" PKG_DMG="${TOP_DIR}/pkg-dmg" -NXPROXY="$(which nxproxy)" # Try to find the MacPorts prefix. typeset MACPORTS_PREFIX_SEARCH="" if type -P port >/dev/null 2>&1; then @@ -120,6 +119,8 @@ else MACPORTS_PREFIX_SEARCH="/opt/local/" fi +NXPROXY="nxproxy" + : ${SDK:="/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.7.sdk"} : ${MACOSX_DEPLOYMENT_TARGET:="10.7"} : ${DEBUG:="0"} @@ -149,6 +150,11 @@ else exit 1 fi +# Gather files. +NXPROXY="$(lazy_canonical_path "${MACPORTS_PREFIX}/bin/${NXPROXY}")" + +[ -x "${NXPROXY}" ] || dependency_error "nxproxy" "nxproxy" "binary" + set -e phase "Cleaning" -- Alioth's /srv/git/code.x2go.org/x2goclient.git//..//_hooks_/post-receive-email on /srv/git/code.x2go.org/x2goclient.git
This is an automated email from the git hooks/post-receive script. x2go pushed a commit to branch bugfix/osx in repository x2goclient. commit efd11d0fff84a9c99d74b8363889491f5ffed9fd Author: Mihai Moldovan <ionic@ionic.de> Date: Sun May 3 23:35:00 2015 +0200 macbuild.sh: copy PulseAudio libraries and binaries. --- debian/changelog | 1 + macbuild.sh | 17 +++++++++++++++++ 2 files changed, 18 insertions(+) diff --git a/debian/changelog b/debian/changelog index 0114020..a62a33b 100644 --- a/debian/changelog +++ b/debian/changelog @@ -77,6 +77,7 @@ x2goclient (4.0.5.1-0x2go1) UNRELEASED; urgency=low - macbuild.sh: define PulseAudio libraries and binaries to be later copied. Discover them using MACPORTS_PREFIX. Error out if any component was not found. + - macbuild.sh: copy PulseAudio libraries and binaries. [ Oleksandr Shneyder ] * New upstream release (4.0.5.1): diff --git a/macbuild.sh b/macbuild.sh index e7ca22d..6405b29 100755 --- a/macbuild.sh +++ b/macbuild.sh @@ -244,6 +244,23 @@ mkdir -p "${FRAMEWORKS_DIR}/" phase "Copying nxproxy" cp -av "${NXPROXY}" "${EXE_DIR}/" +phase "Copying PulseAudio" +for cur_binary in ${PULSEAUDIO_BINARIES_FULL[@]}; do + cp -av "${cur_binary}" "${EXE_DIR}/" +done + +typeset intermediate_lib_dir="" +for cur_binary in ${PULSEAUDIO_LIBRARIES_FULL[@]}; do +set -x + intermediate_lib_dir="$(lazy_canonical_path "$(dirname "${cur_binary}")/")" + intermediate_lib_dir="${intermediate_lib_dir##"$(lazy_canonical_path "${MACPORTS_PREFIX}/lib/")"}" + + mkdir -p "${FRAMEWORKS_DIR}/${intermediate_lib_dir}/" + + cp -av "${cur_binary}" "${FRAMEWORKS_DIR}/${intermediate_lib_dir}/" +set +x +done + if [ "${BUNDLE}" = "1" ]; then dylibbundler \ --fix-file "${EXE_DIR}/nxproxy" \ -- Alioth's /srv/git/code.x2go.org/x2goclient.git//..//_hooks_/post-receive-email on /srv/git/code.x2go.org/x2goclient.git
This is an automated email from the git hooks/post-receive script. x2go pushed a commit to branch bugfix/osx in repository x2goclient. commit 41e18a924711ef379849daf4007ee902edd7c91e Author: Mihai Moldovan <ionic@ionic.de> Date: Sun May 3 23:30:08 2015 +0200 macbuild.sh: add EXE_DIR and FRAMEWORKS_DIR internal variables. Create directories based on that. Use them when bundling. --- debian/changelog | 2 ++ macbuild.sh | 12 ++++++++---- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/debian/changelog b/debian/changelog index 0be6c2d..6e6ef12 100644 --- a/debian/changelog +++ b/debian/changelog @@ -72,6 +72,8 @@ x2goclient (4.0.5.1-0x2go1) UNRELEASED; urgency=low - macbuild.sh: add new get_nesting_level() helper function. - macbuild.sh: add new repeat_str() helper function. - macbuild.sh: refactor nxproxy detection to use MACPORTS_PREFIX. + - macbuild.sh: add EXE_DIR and FRAMEWORKS_DIR internal variables. Create + directories based on that. Use them when bundling. [ Oleksandr Shneyder ] * New upstream release (4.0.5.1): diff --git a/macbuild.sh b/macbuild.sh index 85ae181..234cdc0 100755 --- a/macbuild.sh +++ b/macbuild.sh @@ -104,6 +104,8 @@ TOP_DIR="$(dirname "$0")" [[ "${TOP_DIR}" == /* ]] || TOP_DIR="${PWD}/${TOP_DIR#./}" BUILD_DIR="${TOP_DIR}/client_build" APPBUNDLE="${BUILD_DIR}/${NAME}.app" +EXE_DIR="${APPBUNDLE}/Contents/exe/" +FRAMEWORKS_DIR="${APPBUNDLE}/Contents/Frameworks/" DMGFILE="${BUILD_DIR}/${NAME}.dmg" PROJECT="${TOP_DIR}/${NAME}.pro" PKG_DMG="${TOP_DIR}/pkg-dmg" @@ -185,15 +187,17 @@ qmake -config "${BUILD_MODE}" -spec macx-g++ "${PROJECT}" \ phase "Running make" make -j2 +mkdir -p "${EXE_DIR}/" +mkdir -p "${FRAMEWORKS_DIR}/" + phase "Copying nxproxy" -mkdir -p "${APPBUNDLE}/Contents/exe" -cp "${NXPROXY}" "${APPBUNDLE}/Contents/exe" +cp -av "${NXPROXY}" "${EXE_DIR}/" if [ "${BUNDLE}" = "1" ]; then dylibbundler \ - --fix-file "${APPBUNDLE}/Contents/exe/nxproxy" \ + --fix-file "${EXE_DIR}/nxproxy" \ --bundle-deps \ - --dest-dir "${APPBUNDLE}/Contents/Frameworks" \ + --dest-dir "${FRAMEWORKS_DIR}/" \ --install-path "@executable_path/../Frameworks/" \ --create-dir -- Alioth's /srv/git/code.x2go.org/x2goclient.git//..//_hooks_/post-receive-email on /srv/git/code.x2go.org/x2goclient.git
This is an automated email from the git hooks/post-receive script. x2go pushed a commit to branch bugfix/osx in repository x2goclient. commit 7d95320b43ad4af750e9cce2377956b66cfd5679 Author: Mihai Moldovan <ionic@ionic.de> Date: Sun May 3 23:33:59 2015 +0200 macbuild.sh: define PulseAudio libraries and binaries to be later copied. Discover them using MACPORTS_PREFIX. Error out if any component was not found. --- debian/changelog | 3 +++ macbuild.sh | 51 +++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 54 insertions(+) diff --git a/debian/changelog b/debian/changelog index 6e6ef12..0114020 100644 --- a/debian/changelog +++ b/debian/changelog @@ -74,6 +74,9 @@ x2goclient (4.0.5.1-0x2go1) UNRELEASED; urgency=low - macbuild.sh: refactor nxproxy detection to use MACPORTS_PREFIX. - macbuild.sh: add EXE_DIR and FRAMEWORKS_DIR internal variables. Create directories based on that. Use them when bundling. + - macbuild.sh: define PulseAudio libraries and binaries to be later + copied. Discover them using MACPORTS_PREFIX. Error out if any component + was not found. [ Oleksandr Shneyder ] * New upstream release (4.0.5.1): diff --git a/macbuild.sh b/macbuild.sh index 234cdc0..e7ca22d 100755 --- a/macbuild.sh +++ b/macbuild.sh @@ -122,6 +122,13 @@ else fi NXPROXY="nxproxy" +PULSEAUDIO_BINARIES=( "pulseaudio" "esdcompat" "pacat" "pacmd" "pactl" + "pamon" "paplay" "parec" "parecord" "pasuspender" ) +PULSEAUDIO_LIBRARIES=( "libpulse-simple.0.dylib" + "libpulse.0.dylib" + "libpulsecore-6.0.dylib" + "pulse-6.0" + "pulseaudio" ) : ${SDK:="/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.7.sdk"} : ${MACOSX_DEPLOYMENT_TARGET:="10.7"} @@ -157,6 +164,50 @@ NXPROXY="$(lazy_canonical_path "${MACPORTS_PREFIX}/bin/${NXPROXY}")" [ -x "${NXPROXY}" ] || dependency_error "nxproxy" "nxproxy" "binary" +typeset -i i +typeset -i fail +typeset -a PULSEAUDIO_BINARIES_FULL +typeset cur_binary +fail="0" +for cur_binary in ${PULSEAUDIO_BINARIES[@]}; do + cur_binary="$(lazy_canonical_path "${MACPORTS_PREFIX}/bin/${cur_binary}")" + + if [ -x "${cur_binary}" ]; then + PULSEAUDIO_BINARIES_FULL+=( "${cur_binary}" ) + else + fail="1" + break + fi +done + +[ "${fail}" -eq "1" ] && dependency_error "${cur_binary##"$(lazy_canonical_path "${MACPORTS_PREFIX}/bin/")"}" "pulseaudio" "binary" + +typeset cur_lib_or_libdir +typeset -a PULSEAUDIO_LIBRARIES_FULL +fail="0" +for cur_lib_or_libdir in ${PULSEAUDIO_LIBRARIES[@]}; do + cur_lib_or_libdir="$(lazy_canonical_path "${MACPORTS_PREFIX}/lib/${cur_lib_or_libdir}")" + + if [ -x "${cur_lib_or_libdir}" ]; then + PULSEAUDIO_LIBRARIES_FULL+=( "${cur_lib_or_libdir}" ) + elif [ -d "${cur_lib_or_libdir}" ]; then + # That's a directory... more work needed here. + typeset entry="" + for entry in "${cur_lib_or_libdir}"/*; do + typeset TMP_REGEX='^.*\.(so|dylib|bundle)(\.[0-9]+){0,2}$' + if [[ "${entry}" =~ ${TMP_REGEX} ]]; then + # Filename matched the expected template. + PULSEAUDIO_LIBRARIES_FULL+=( "$(lazy_canonical_path "${cur_lib_or_libdir}/${entry}")" ) + fi + done + else + fail="1" + break + fi +done + +[ "${fail}" -eq "1" ] && dependency_error "${cur_lib_or_libdir}" "pulseaudio" "library or library directory" + set -e phase "Cleaning" -- Alioth's /srv/git/code.x2go.org/x2goclient.git//..//_hooks_/post-receive-email on /srv/git/code.x2go.org/x2goclient.git
This is an automated email from the git hooks/post-receive script. x2go pushed a commit to branch bugfix/osx in repository x2goclient. commit 58ff744b6c838a6a42f96543c07b829eb8db0e2a Author: Mihai Moldovan <ionic@ionic.de> Date: Sun May 3 23:36:16 2015 +0200 macbuild.sh: add phase output for bundling nxproxy. --- debian/changelog | 1 + macbuild.sh | 1 + 2 files changed, 2 insertions(+) diff --git a/debian/changelog b/debian/changelog index a62a33b..4e98cff 100644 --- a/debian/changelog +++ b/debian/changelog @@ -78,6 +78,7 @@ x2goclient (4.0.5.1-0x2go1) UNRELEASED; urgency=low copied. Discover them using MACPORTS_PREFIX. Error out if any component was not found. - macbuild.sh: copy PulseAudio libraries and binaries. + - macbuild.sh: add phase output for bundling nxproxy. [ Oleksandr Shneyder ] * New upstream release (4.0.5.1): diff --git a/macbuild.sh b/macbuild.sh index 6405b29..61df87b 100755 --- a/macbuild.sh +++ b/macbuild.sh @@ -262,6 +262,7 @@ set +x done if [ "${BUNDLE}" = "1" ]; then + phase "Bundling nxproxy" dylibbundler \ --fix-file "${EXE_DIR}/nxproxy" \ --bundle-deps \ -- Alioth's /srv/git/code.x2go.org/x2goclient.git//..//_hooks_/post-receive-email on /srv/git/code.x2go.org/x2goclient.git
This is an automated email from the git hooks/post-receive script. x2go pushed a commit to branch bugfix/osx in repository x2goclient. commit 60d2f0d3f468ea43abfe6c738f869e915cd5f176 Author: Mihai Moldovan <ionic@ionic.de> Date: Sun May 3 23:37:46 2015 +0200 macbuild.sh: add work-in-progress PulseAudio bundling. Needs to be ripped apart and be redone, because dylibbundler is not smart enough to handle our case. --- debian/changelog | 3 +++ macbuild.sh | 35 +++++++++++++++++++++++++++++++++++ 2 files changed, 38 insertions(+) diff --git a/debian/changelog b/debian/changelog index 4e98cff..42e0de6 100644 --- a/debian/changelog +++ b/debian/changelog @@ -79,6 +79,9 @@ x2goclient (4.0.5.1-0x2go1) UNRELEASED; urgency=low was not found. - macbuild.sh: copy PulseAudio libraries and binaries. - macbuild.sh: add phase output for bundling nxproxy. + - macbuild.sh: add work-in-progress PulseAudio bundling. Needs to be ripped + apart and be redone, because dylibbundler is not smart enough to handle + our case. [ Oleksandr Shneyder ] * New upstream release (4.0.5.1): diff --git a/macbuild.sh b/macbuild.sh index 61df87b..7b69dcf 100755 --- a/macbuild.sh +++ b/macbuild.sh @@ -270,6 +270,41 @@ if [ "${BUNDLE}" = "1" ]; then --install-path "@executable_path/../Frameworks/" \ --create-dir + phase "Bundling PulseAudio" + typeset cur_binary_name="" + for cur_binary in ${PULSEAUDIO_BINARIES_FULL[@]}; do + if [ ! -L "${cur_binary}" ]; then + cur_binary_name="$(basename "${cur_binary}")" + dylibbundler \ + --fix-file "${EXE_DIR}/${cur_binary_name}" \ + --bundle-deps \ + --dest-dir "${FRAMEWORKS_DIR}/" \ + --install-path "@executable_path/../Frameworks/" \ + --create-dir \ + --overwrite-files + fi + done + + typeset intermediate_lib_dir="" + for cur_binary in ${PULSEAUDIO_LIBRARIES_FULL[@]}; do + intermediate_lib_dir="$(lazy_canonical_path "$(dirname "${cur_binary}")/")" + intermediate_lib_dir="${intermediate_lib_dir##"$(lazy_canonical_path "${MACPORTS_PREFIX}/lib/")"}" + + if [ ! -L "${cur_binary}" ]; then + cur_binary_name="$(basename "${cur_binary}")" + + typeset nesting_level="$(get_nesting_level "${intermediate_lib_dir}")" + + dylibbundler \ + --fix-file "${FRAMEWORKS_DIR}/${intermediate_lib_dir}/${cur_binary_name}" \ + --bundle-deps \ + --dest-dir "${FRAMEWORKS_DIR}/" \ + --install-path "@loader_path/$(repeat_str "../" "${nesting_level}")Frameworks/" \ + --create-dir \ + --overwrite-files + fi + done + phase "Bundling up using macdeployqt" macdeployqt "${APPBUNDLE}" -verbose=2 -- Alioth's /srv/git/code.x2go.org/x2goclient.git//..//_hooks_/post-receive-email on /srv/git/code.x2go.org/x2goclient.git
This is an automated email from the git hooks/post-receive script. x2go pushed a commit to branch bugfix/osx in repository x2goclient. commit a5167c9b493ce8393f63f245f744b3c11fb7ac25 Author: Mihai Moldovan <ionic@ionic.de> Date: Mon Jun 29 23:03:23 2015 +0200 macbuild.sh: add Linux library file name scheme regex as a precaution. --- debian/changelog | 1 + macbuild.sh | 9 +++++++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/debian/changelog b/debian/changelog index 42e0de6..7beff40 100644 --- a/debian/changelog +++ b/debian/changelog @@ -82,6 +82,7 @@ x2goclient (4.0.5.1-0x2go1) UNRELEASED; urgency=low - macbuild.sh: add work-in-progress PulseAudio bundling. Needs to be ripped apart and be redone, because dylibbundler is not smart enough to handle our case. + - macbuild.sh: add Linux library file name scheme regex as a precaution. [ Oleksandr Shneyder ] * New upstream release (4.0.5.1): diff --git a/macbuild.sh b/macbuild.sh index 7b69dcf..2a8f54b 100755 --- a/macbuild.sh +++ b/macbuild.sh @@ -194,8 +194,13 @@ for cur_lib_or_libdir in ${PULSEAUDIO_LIBRARIES[@]}; do # That's a directory... more work needed here. typeset entry="" for entry in "${cur_lib_or_libdir}"/*; do - typeset TMP_REGEX='^.*\.(so|dylib|bundle)(\.[0-9]+){0,2}$' - if [[ "${entry}" =~ ${TMP_REGEX} ]]; then + typeset TMP_REGEX='^.*\.(\.[0-9]+){0,2}(so|dylib|bundle)$' + + # This is only here should the PA build system ever break and create + # "linux-style" library file names. Let's hope it never actually comes to that. + typeset TMP_REGEX_LINUX_COMPAT='^.*\.(so|dylib|bundle)(\.[0-9]+){0,2}$' + + if [[ "${entry}" =~ ${TMP_REGEX} ]] || [[ "${entry}" =~ ${TMP_REGEX_LINUX_COMPAT} ]]; then # Filename matched the expected template. PULSEAUDIO_LIBRARIES_FULL+=( "$(lazy_canonical_path "${cur_lib_or_libdir}/${entry}")" ) fi -- Alioth's /srv/git/code.x2go.org/x2goclient.git//..//_hooks_/post-receive-email on /srv/git/code.x2go.org/x2goclient.git
This is an automated email from the git hooks/post-receive script. x2go pushed a commit to branch bugfix/osx in repository x2goclient. commit 9e6beb5b744bcaf822feb5ebdbce7920fcfaaddc Author: Mihai Moldovan <ionic@ionic.de> Date: Mon Jun 29 23:09:05 2015 +0200 macbuild.sh: directories are "executable", so the first check must explicitly include a check for the argument being not a directory. --- debian/changelog | 2 ++ macbuild.sh | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/debian/changelog b/debian/changelog index 7beff40..b4d53c6 100644 --- a/debian/changelog +++ b/debian/changelog @@ -83,6 +83,8 @@ x2goclient (4.0.5.1-0x2go1) UNRELEASED; urgency=low apart and be redone, because dylibbundler is not smart enough to handle our case. - macbuild.sh: add Linux library file name scheme regex as a precaution. + - macbuild.sh: directories are "executable", so the first check must + explicitly include a check for the argument being not a directory. [ Oleksandr Shneyder ] * New upstream release (4.0.5.1): diff --git a/macbuild.sh b/macbuild.sh index 2a8f54b..cf341d4 100755 --- a/macbuild.sh +++ b/macbuild.sh @@ -188,7 +188,7 @@ fail="0" for cur_lib_or_libdir in ${PULSEAUDIO_LIBRARIES[@]}; do cur_lib_or_libdir="$(lazy_canonical_path "${MACPORTS_PREFIX}/lib/${cur_lib_or_libdir}")" - if [ -x "${cur_lib_or_libdir}" ]; then + if [ ! -d "${cur_lib_or_libdir}" ] && [ -x "${cur_lib_or_libdir}" ]; then PULSEAUDIO_LIBRARIES_FULL+=( "${cur_lib_or_libdir}" ) elif [ -d "${cur_lib_or_libdir}" ]; then # That's a directory... more work needed here. -- Alioth's /srv/git/code.x2go.org/x2goclient.git//..//_hooks_/post-receive-email on /srv/git/code.x2go.org/x2goclient.git
This is an automated email from the git hooks/post-receive script. x2go pushed a commit to branch bugfix/osx in repository x2goclient. commit b0eff41b1fbc1f7757586ec7e502649d7999de94 Author: Mihai Moldovan <ionic@ionic.de> Date: Thu Jul 30 04:31:52 2015 +0200 macbuild.sh: add some more debugging output. --- debian/changelog | 1 + macbuild.sh | 3 +++ 2 files changed, 4 insertions(+) diff --git a/debian/changelog b/debian/changelog index b4d53c6..a828270 100644 --- a/debian/changelog +++ b/debian/changelog @@ -85,6 +85,7 @@ x2goclient (4.0.5.1-0x2go1) UNRELEASED; urgency=low - macbuild.sh: add Linux library file name scheme regex as a precaution. - macbuild.sh: directories are "executable", so the first check must explicitly include a check for the argument being not a directory. + - macbuild.sh: add some more debugging output. [ Oleksandr Shneyder ] * New upstream release (4.0.5.1): diff --git a/macbuild.sh b/macbuild.sh index cf341d4..2ca31b9 100755 --- a/macbuild.sh +++ b/macbuild.sh @@ -189,9 +189,11 @@ for cur_lib_or_libdir in ${PULSEAUDIO_LIBRARIES[@]}; do cur_lib_or_libdir="$(lazy_canonical_path "${MACPORTS_PREFIX}/lib/${cur_lib_or_libdir}")" if [ ! -d "${cur_lib_or_libdir}" ] && [ -x "${cur_lib_or_libdir}" ]; then + echo "Adding ${cur_lib_or_libdir} to \${PULSEAUDIO_LIBRARIES_FULL}" PULSEAUDIO_LIBRARIES_FULL+=( "${cur_lib_or_libdir}" ) elif [ -d "${cur_lib_or_libdir}" ]; then # That's a directory... more work needed here. + echo "Scrubbing directory ${cur_lib_or_libdir}" typeset entry="" for entry in "${cur_lib_or_libdir}"/*; do typeset TMP_REGEX='^.*\.(\.[0-9]+){0,2}(so|dylib|bundle)$' @@ -297,6 +299,7 @@ if [ "${BUNDLE}" = "1" ]; then if [ ! -L "${cur_binary}" ]; then cur_binary_name="$(basename "${cur_binary}")" + echo "Handling ${cur_binary} => ${cur_binary_name}." typeset nesting_level="$(get_nesting_level "${intermediate_lib_dir}")" -- Alioth's /srv/git/code.x2go.org/x2goclient.git//..//_hooks_/post-receive-email on /srv/git/code.x2go.org/x2goclient.git
This is an automated email from the git hooks/post-receive script. x2go pushed a commit to branch bugfix/osx in repository x2goclient. commit 6ac3db5a558701548b858f327274fc9924ceca11 Author: Mihai Moldovan <ionic@ionic.de> Date: Thu Jul 30 04:33:30 2015 +0200 macbuild.sh: remove libpulse and libpulsecore from libraries to be bundled, as something else will bundle them anyway. --- debian/changelog | 2 ++ macbuild.sh | 2 -- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/debian/changelog b/debian/changelog index a828270..b594b15 100644 --- a/debian/changelog +++ b/debian/changelog @@ -86,6 +86,8 @@ x2goclient (4.0.5.1-0x2go1) UNRELEASED; urgency=low - macbuild.sh: directories are "executable", so the first check must explicitly include a check for the argument being not a directory. - macbuild.sh: add some more debugging output. + - macbuild.sh: remove libpulse and libpulsecore from libraries to be + bundled, as something else will bundle them anyway. [ Oleksandr Shneyder ] * New upstream release (4.0.5.1): diff --git a/macbuild.sh b/macbuild.sh index 2ca31b9..82c75e6 100755 --- a/macbuild.sh +++ b/macbuild.sh @@ -125,8 +125,6 @@ NXPROXY="nxproxy" PULSEAUDIO_BINARIES=( "pulseaudio" "esdcompat" "pacat" "pacmd" "pactl" "pamon" "paplay" "parec" "parecord" "pasuspender" ) PULSEAUDIO_LIBRARIES=( "libpulse-simple.0.dylib" - "libpulse.0.dylib" - "libpulsecore-6.0.dylib" "pulse-6.0" "pulseaudio" ) -- Alioth's /srv/git/code.x2go.org/x2goclient.git//..//_hooks_/post-receive-email on /srv/git/code.x2go.org/x2goclient.git
This is an automated email from the git hooks/post-receive script. x2go pushed a commit to branch bugfix/osx in repository x2goclient. commit e812965b4ebc00b655cd2d3821a89e2a60d2f279 Author: Mihai Moldovan <ionic@ionic.de> Date: Thu Jul 30 04:39:59 2015 +0200 macbuild.sh: use while-read-loop and find to actually recurse through directories. --- debian/changelog | 2 ++ macbuild.sh | 8 ++++++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/debian/changelog b/debian/changelog index b594b15..067fc89 100644 --- a/debian/changelog +++ b/debian/changelog @@ -88,6 +88,8 @@ x2goclient (4.0.5.1-0x2go1) UNRELEASED; urgency=low - macbuild.sh: add some more debugging output. - macbuild.sh: remove libpulse and libpulsecore from libraries to be bundled, as something else will bundle them anyway. + - macbuild.sh: use while-read-loop and find to actually recurse through + directories. [ Oleksandr Shneyder ] * New upstream release (4.0.5.1): diff --git a/macbuild.sh b/macbuild.sh index 82c75e6..164fb6d 100755 --- a/macbuild.sh +++ b/macbuild.sh @@ -193,7 +193,11 @@ for cur_lib_or_libdir in ${PULSEAUDIO_LIBRARIES[@]}; do # That's a directory... more work needed here. echo "Scrubbing directory ${cur_lib_or_libdir}" typeset entry="" - for entry in "${cur_lib_or_libdir}"/*; do + + # -r parameter to read: Backslashes may NOT escape any characters! + # -d '': specifies the delimiter to be used - as '' resolves to an empty string followed + # by a NUL character, the delimiter is set to this very NUL (\000) character. + while read -r -d '' entry; do typeset TMP_REGEX='^.*\.(\.[0-9]+){0,2}(so|dylib|bundle)$' # This is only here should the PA build system ever break and create @@ -204,7 +208,7 @@ for cur_lib_or_libdir in ${PULSEAUDIO_LIBRARIES[@]}; do # Filename matched the expected template. PULSEAUDIO_LIBRARIES_FULL+=( "$(lazy_canonical_path "${cur_lib_or_libdir}/${entry}")" ) fi - done + done < <(find "${cur_lib_or_libdir}" -type 'f' -print0) else fail="1" break -- Alioth's /srv/git/code.x2go.org/x2goclient.git//..//_hooks_/post-receive-email on /srv/git/code.x2go.org/x2goclient.git
This is an automated email from the git hooks/post-receive script. x2go pushed a commit to branch bugfix/osx in repository x2goclient. commit 1bd0b49e88ebb83b5420d9c8b22356cd7f9aec81 Author: Mihai Moldovan <ionic@ionic.de> Date: Thu Jul 30 04:42:01 2015 +0200 macbuild.sh: check current file name against regex, not a (now) full path. --- debian/changelog | 2 ++ macbuild.sh | 3 ++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/debian/changelog b/debian/changelog index 067fc89..9b2b409 100644 --- a/debian/changelog +++ b/debian/changelog @@ -90,6 +90,8 @@ x2goclient (4.0.5.1-0x2go1) UNRELEASED; urgency=low bundled, as something else will bundle them anyway. - macbuild.sh: use while-read-loop and find to actually recurse through directories. + - macbuild.sh: check current file name against regex, not a (now) full + path. [ Oleksandr Shneyder ] * New upstream release (4.0.5.1): diff --git a/macbuild.sh b/macbuild.sh index 164fb6d..4465d7d 100755 --- a/macbuild.sh +++ b/macbuild.sh @@ -198,13 +198,14 @@ for cur_lib_or_libdir in ${PULSEAUDIO_LIBRARIES[@]}; do # -d '': specifies the delimiter to be used - as '' resolves to an empty string followed # by a NUL character, the delimiter is set to this very NUL (\000) character. while read -r -d '' entry; do + typeset cur_file="$(basename "${entry}")" typeset TMP_REGEX='^.*\.(\.[0-9]+){0,2}(so|dylib|bundle)$' # This is only here should the PA build system ever break and create # "linux-style" library file names. Let's hope it never actually comes to that. typeset TMP_REGEX_LINUX_COMPAT='^.*\.(so|dylib|bundle)(\.[0-9]+){0,2}$' - if [[ "${entry}" =~ ${TMP_REGEX} ]] || [[ "${entry}" =~ ${TMP_REGEX_LINUX_COMPAT} ]]; then + if [[ "${cur_file}" =~ ${TMP_REGEX} ]] || [[ "${cur_file}" =~ ${TMP_REGEX_LINUX_COMPAT} ]]; then # Filename matched the expected template. PULSEAUDIO_LIBRARIES_FULL+=( "$(lazy_canonical_path "${cur_lib_or_libdir}/${entry}")" ) fi -- Alioth's /srv/git/code.x2go.org/x2goclient.git//..//_hooks_/post-receive-email on /srv/git/code.x2go.org/x2goclient.git
This is an automated email from the git hooks/post-receive script. x2go pushed a commit to branch bugfix/osx in repository x2goclient. commit bd9f3ff191305a93b39c863ef185ad94f3ca8dd0 Author: Mihai Moldovan <ionic@ionic.de> Date: Thu Jul 30 04:45:40 2015 +0200 macbuild.sh: when actually bundling libraries, use @executable_path instead of @loader_path. Will need testing. --- debian/changelog | 2 ++ macbuild.sh | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/debian/changelog b/debian/changelog index b53348f..f4b8a2b 100644 --- a/debian/changelog +++ b/debian/changelog @@ -93,6 +93,8 @@ x2goclient (4.0.5.1-0x2go1) UNRELEASED; urgency=low - macbuild.sh: check current file name against regex, not a (now) full path. - macbuild.sh: add the correct file path to the library bundling array. + - macbuild.sh: when actually bundling libraries, use @executable_path + instead of @loader_path. Will need testing. [ Oleksandr Shneyder ] * New upstream release (4.0.5.1): diff --git a/macbuild.sh b/macbuild.sh index ad17bdf..9e4150e 100755 --- a/macbuild.sh +++ b/macbuild.sh @@ -311,7 +311,7 @@ if [ "${BUNDLE}" = "1" ]; then --fix-file "${FRAMEWORKS_DIR}/${intermediate_lib_dir}/${cur_binary_name}" \ --bundle-deps \ --dest-dir "${FRAMEWORKS_DIR}/" \ - --install-path "@loader_path/$(repeat_str "../" "${nesting_level}")Frameworks/" \ + --install-path "@executable_path/$(repeat_str "../" "${nesting_level}")../Frameworks/" \ --create-dir \ --overwrite-files fi -- Alioth's /srv/git/code.x2go.org/x2goclient.git//..//_hooks_/post-receive-email on /srv/git/code.x2go.org/x2goclient.git
This is an automated email from the git hooks/post-receive script. x2go pushed a commit to branch bugfix/osx in repository x2goclient. commit f0f7462c7edbd9afef36c2c1c5da8bbd63262e60 Author: Mihai Moldovan <ionic@ionic.de> Date: Thu Jul 30 04:43:25 2015 +0200 macbuild.sh: add the correct file path to the library bundling array. --- debian/changelog | 1 + macbuild.sh | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/debian/changelog b/debian/changelog index 9b2b409..b53348f 100644 --- a/debian/changelog +++ b/debian/changelog @@ -92,6 +92,7 @@ x2goclient (4.0.5.1-0x2go1) UNRELEASED; urgency=low directories. - macbuild.sh: check current file name against regex, not a (now) full path. + - macbuild.sh: add the correct file path to the library bundling array. [ Oleksandr Shneyder ] * New upstream release (4.0.5.1): diff --git a/macbuild.sh b/macbuild.sh index 4465d7d..ad17bdf 100755 --- a/macbuild.sh +++ b/macbuild.sh @@ -207,7 +207,8 @@ for cur_lib_or_libdir in ${PULSEAUDIO_LIBRARIES[@]}; do if [[ "${cur_file}" =~ ${TMP_REGEX} ]] || [[ "${cur_file}" =~ ${TMP_REGEX_LINUX_COMPAT} ]]; then # Filename matched the expected template. - PULSEAUDIO_LIBRARIES_FULL+=( "$(lazy_canonical_path "${cur_lib_or_libdir}/${entry}")" ) + echo "Adding $(lazy_canonical_path "${entry}") to \${PULSEAUDIO_LIBRARIES_FULL}" + PULSEAUDIO_LIBRARIES_FULL+=( "$(lazy_canonical_path "${entry}")" ) fi done < <(find "${cur_lib_or_libdir}" -type 'f' -print0) else -- Alioth's /srv/git/code.x2go.org/x2goclient.git//..//_hooks_/post-receive-email on /srv/git/code.x2go.org/x2goclient.git
This is an automated email from the git hooks/post-receive script. x2go pushed a commit to branch bugfix/osx in repository x2goclient. commit 9e47d18346e5f491a88ef5ab2f9b88bfd2293643 Author: Mihai Moldovan <ionic@ionic.de> Date: Wed Aug 26 20:55:14 2015 +0200 macbuild.sh: fix echo call to also show the intermediate lib dir, not just the library file name. Helps debugging. --- debian/changelog | 2 ++ macbuild.sh | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/debian/changelog b/debian/changelog index f4b8a2b..5b834cd 100644 --- a/debian/changelog +++ b/debian/changelog @@ -95,6 +95,8 @@ x2goclient (4.0.5.1-0x2go1) UNRELEASED; urgency=low - macbuild.sh: add the correct file path to the library bundling array. - macbuild.sh: when actually bundling libraries, use @executable_path instead of @loader_path. Will need testing. + - macbuild.sh: fix echo call to also show the intermediate lib dir, not + just the library file name. Helps debugging. [ Oleksandr Shneyder ] * New upstream release (4.0.5.1): diff --git a/macbuild.sh b/macbuild.sh index 9e4150e..d3b3102 100755 --- a/macbuild.sh +++ b/macbuild.sh @@ -303,7 +303,7 @@ if [ "${BUNDLE}" = "1" ]; then if [ ! -L "${cur_binary}" ]; then cur_binary_name="$(basename "${cur_binary}")" - echo "Handling ${cur_binary} => ${cur_binary_name}." + echo "Handling ${cur_binary} => ${intermediate_lib_dir}/${cur_binary_name}." typeset nesting_level="$(get_nesting_level "${intermediate_lib_dir}")" -- Alioth's /srv/git/code.x2go.org/x2goclient.git//..//_hooks_/post-receive-email on /srv/git/code.x2go.org/x2goclient.git
This is an automated email from the git hooks/post-receive script. x2go pushed a commit to branch bugfix/osx in repository x2goclient. commit af6322e98bf4cf69e9bc2cff1cda47bd1e114539 Author: Mihai Moldovan <ionic@ionic.de> Date: Wed Aug 26 20:57:41 2015 +0200 deduplicate.sh: add new, more or less Proof of Concept, and Work in Progress file deduplication script. --- debian/changelog | 2 ++ deduplicate.sh | 79 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 81 insertions(+) diff --git a/debian/changelog b/debian/changelog index a5183d1..35ace0d 100644 --- a/debian/changelog +++ b/debian/changelog @@ -99,6 +99,8 @@ x2goclient (4.0.5.1-0x2go1) UNRELEASED; urgency=low just the library file name. Helps debugging. - macbuild.sh: also install libraries into staging area with intermediate library path. Putting everything into a single place is a stupid idea. + - deduplicate.sh: add new, more or less Proof of Concept, and Work in + Progress file deduplication script. [ Oleksandr Shneyder ] * New upstream release (4.0.5.1): diff --git a/deduplicate.sh b/deduplicate.sh new file mode 100755 index 0000000..7c4de14 --- /dev/null +++ b/deduplicate.sh @@ -0,0 +1,79 @@ +#!/bin/bash + +typeset base_dir="" +base_dir="${1:?"No base dir given."}" + +typeset -a special_files_regex +special_files_regex+=( "pulseaudio/libpulsecommon-[0-9]\.[0-9]\.dylib" ) + +typeset -a all_files +typeset entry="" +while read -r -d '' entry; do + all_files+=( "${entry}" ) +done < <(find "${base_dir}" -type 'f' -print0) + +typeset -a top_files +for entry in ${all_files[@]}; do + typeset relative_path="${entry##"${base_dir}/"}" + typeset tmp_regex='^[^/]+$' + if [[ "${relative_path}" =~ ${tmp_regex} ]]; then + echo "${relative_path} is top file, adding to array." + top_files+=( "${relative_path}" ) + fi +done + +typeset -a duplicates +for entry in ${all_files[@]}; do + typeset relative_path="${entry##"${base_dir}/"}" + typeset file_name="$(basename "${entry}")" + typeset top_entry="" + for top_entry in ${top_files[@]}; do + if [ "${top_entry}" != "${relative_path}" ]; then + if [ "${file_name}" = "${top_entry}" ]; then + echo "Adding duplicate: ${relative_path}" + duplicates+=( "${relative_path}" ) + fi + fi + done +done + +echo "duplicates array before:" +for entry in ${duplicates[@]}; do + echo "${entry}" +done + +typeset -i i="0" +for ((i = 0; i < ${#duplicates[@]}; ++i)); do + entry="${duplicates[${i}]}" + typeset special_file_regex="" + for special_file_regex in ${special_files_regex[@]}; do + typeset tmp_regex='^'"${special_file_regex}"'$' + if [[ "${entry}" =~ ${tmp_regex} ]]; then + echo "mv \"${base_dir}/$(basename "${entry}")\" \"${base_dir}/$(dirname "${special_file_regex}")/\"" + duplicates[${i}]="$(basename "${entry}")" + echo "Renamed ${entry} in duplicates array to ${duplicates[${i}]}" + fi + done +done + +echo "duplicates array after:" +for entry in ${duplicates[@]}; do + echo "${entry}" +done + +for entry in ${duplicates[@]}; do + echo "rm -v ${base_dir}/${entry}" + typeset -i i="0" + for ((i = 0; i < ${#all_files[@]}; ++i)); do + typeset all_entry="${all_files[${i}]}" + typeset relative_path="${all_entry##"${base_dir}/"}" + if [ "${relative_path}" = "${entry}" ]; then + all_files[${i}]="" + fi + done +done + +echo "New value for all_files:" +for entry in ${all_files[@]}; do + echo "${entry}" +done -- Alioth's /srv/git/code.x2go.org/x2goclient.git//..//_hooks_/post-receive-email on /srv/git/code.x2go.org/x2goclient.git
This is an automated email from the git hooks/post-receive script. x2go pushed a commit to branch bugfix/osx in repository x2goclient. commit d4e5e687ca3b009a6b5b0433b8375688b3deba15 Author: Mihai Moldovan <ionic@ionic.de> Date: Wed Aug 26 20:56:29 2015 +0200 macbuild.sh: also install libraries into staging area with intermediate library path. Putting everything into a single place is a stupid idea. --- debian/changelog | 2 ++ macbuild.sh | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/debian/changelog b/debian/changelog index 5b834cd..a5183d1 100644 --- a/debian/changelog +++ b/debian/changelog @@ -97,6 +97,8 @@ x2goclient (4.0.5.1-0x2go1) UNRELEASED; urgency=low instead of @loader_path. Will need testing. - macbuild.sh: fix echo call to also show the intermediate lib dir, not just the library file name. Helps debugging. + - macbuild.sh: also install libraries into staging area with intermediate + library path. Putting everything into a single place is a stupid idea. [ Oleksandr Shneyder ] * New upstream release (4.0.5.1): diff --git a/macbuild.sh b/macbuild.sh index d3b3102..5b768db 100755 --- a/macbuild.sh +++ b/macbuild.sh @@ -310,8 +310,8 @@ if [ "${BUNDLE}" = "1" ]; then dylibbundler \ --fix-file "${FRAMEWORKS_DIR}/${intermediate_lib_dir}/${cur_binary_name}" \ --bundle-deps \ - --dest-dir "${FRAMEWORKS_DIR}/" \ - --install-path "@executable_path/$(repeat_str "../" "${nesting_level}")../Frameworks/" \ + --dest-dir "${FRAMEWORKS_DIR}/${intermediate_lib_dir}" \ + --install-path "@executable_path/$(repeat_str "../" "${nesting_level}")../Frameworks/${intermediate_lib_dir}" \ --create-dir \ --overwrite-files fi -- Alioth's /srv/git/code.x2go.org/x2goclient.git//..//_hooks_/post-receive-email on /srv/git/code.x2go.org/x2goclient.git