[X2Go-Commits] x2gobroker.git - master-inai (branch) updated: 3098bed45d56262d5de490d5fa45f51fb13b975c

X2Go dev team git-admin at x2go.org
Tue Apr 23 21:08:12 CEST 2013


The branch, master-inai has been updated
       via  3098bed45d56262d5de490d5fa45f51fb13b975c (commit)
      from  9efd0dcf3ea924d2049ff027b854d1159c29c617 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
-----------------------------------------------------------------------

Summary of changes:
 Makefile                                          |   41 +++++++++++
 lib/{x2gobroker-command => x2gobroker-command.pl} |    2 +-
 src/x2gobroker-command.c                          |   77 +++++++++++++++++++++
 3 files changed, 119 insertions(+), 1 deletion(-)
 create mode 100755 Makefile
 rename lib/{x2gobroker-command => x2gobroker-command.pl} (98%)
 create mode 100644 src/x2gobroker-command.c

The diff of changes is:
diff --git a/Makefile b/Makefile
new file mode 100755
index 0000000..4d798c6
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,41 @@
+#!/usr/bin/make -f
+
+SRC_DIR=$(CURDIR)
+SHELL=/bin/bash
+
+INSTALL_DIR=install -d -o root -g root -m 755
+INSTALL_FILE=install -o root -g root -m 644
+INSTALL_PROGRAM=install -o root -g root -m 755
+
+RM_FILE=rm -f
+RM_DIR=rmdir -p --ignore-fail-on-non-empty
+
+DESTDIR=
+PREFIX=/usr/local
+ETCDIR=/etc/x2go
+BINDIR=$(PREFIX)/bin
+SBINDIR=$(PREFIX)/sbin
+LIBDIR=$(PREFIX)/lib/x2go
+MANDIR=$(PREFIX)/share/man
+SHAREDIR=$(PREFIX)/share/x2go
+
+BIN_SCRIPTS=$(shell cd bin && echo *)
+SBIN_SCRIPTS=$(shell cd sbin && echo *)
+LIB_FILES=$(shell cd lib && echo *)
+
+all: clean build
+
+build: build-arch build-indep
+
+build-arch: build_setgidwrappers
+
+build_setgidwrappers:
+	gcc -fPIE -pie -o x2gobroker-command x2gobroker-command.c
+
+build-indep:
+
+clean: clean_arch
+
+clean_arch:
+	rm -f src/x2gobroker-command
+
diff --git a/lib/x2gobroker-command b/lib/x2gobroker-command.pl
similarity index 98%
rename from lib/x2gobroker-command
rename to lib/x2gobroker-command.pl
index 425a5cf..ead8242 100755
--- a/lib/x2gobroker-command
+++ b/lib/x2gobroker-command.pl
@@ -1,4 +1,4 @@
-#!/usr/bin/suidperl -TU
+#!/usr/bin/perl
 use strict;
 
 sub initUser
diff --git a/src/x2gobroker-command.c b/src/x2gobroker-command.c
new file mode 100644
index 0000000..36ba83d
--- /dev/null
+++ b/src/x2gobroker-command.c
@@ -0,0 +1,77 @@
+/*
+ * This file is part of the  X2Go Project - http://www.x2go.org
+ * Copyright (C) 2012 Mike Gabriel <mike.gabriel at das-netzwerkteam.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.,
+ * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * 
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <libgen.h>
+#include <errno.h>
+
+int main( int argc, char *argv[] ) {
+	char * x2gobrokercmdpl = NULL;
+	size_t path_max;
+	
+/*
+	The following snippet is taken from the realpath manpage
+*/
+#ifdef PATH_MAX
+	path_max = PATH_MAX;
+#else
+	path_max = pathconf (".", _PC_PATH_MAX);
+	if (path_max <= 0){
+		path_max = 4096;
+	}
+#endif
+	{
+		// allocate dynamic buffer in stack: this needs C99 or gnu??
+		char buffer[path_max];
+		ssize_t rvrl;
+		int rvap;
+
+		// resolve link of /proc/self/exe to find out where we are
+		rvrl = readlink("/proc/self/exe", buffer, path_max);
+		if(rvrl == -1){
+			perror("readlink(\"/proc/self/exe\",buffer,path_max)");
+			exit(EXIT_FAILURE);
+		}
+		if(rvrl >= path_max){
+			fprintf(stderr, "Could not resolve the path of this file using \"/proc/self/exe\". The path is too long (> %i)", path_max);
+			exit(EXIT_FAILURE);
+		}
+
+		// derive the full path of x2gobroker-command.pl from path of this binary
+		rvap = asprintf(&x2gobrokercmdpl, "%s/%s", dirname(buffer), "x2gobroker-command.pl");
+		if(rvap == -1){
+			fprintf(stderr, "Failed to allocate memory calling asprintf\n");
+			exit(EXIT_FAILURE);
+		}
+
+		// execute the script, running with user-rights of this binary 
+		execv(x2gobrokercmdpl, argv);
+
+	}
+
+	// ...fail
+	fprintf(stderr, "Failed to execute %s: %s\n", x2gobrokercmdpl, strerror(errno));
+	return EXIT_FAILURE;
+
+}


hooks/post-receive
-- 
x2gobroker.git (HTTP(S) Session broker for X2Go)

This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "x2gobroker.git" (HTTP(S) Session broker for X2Go).




More information about the x2go-commits mailing list