On 2011-07-18 12:16, Mike Gabriel wrote:
> Could you commit the rebuilt html man pages separately from the
> x2gosqlitewrapper patch? 

Actually I am in very much in favour of removing them (I added them by
accident using "-a"). I see no need for auto-generated content. Maybe
you can add a post-commit-hook to generate and copy them somewhere....

I think we should also let Arw have a look at the code. 

I also attached the fixed patch - and the whole file (the line count of
the patch is bigger... ;) ).

Cheers
Morty

-- 
Dipl.-Ing. Moritz 'Morty' Struebe (Wissenschaftlicher Mitarbeiter)
Lehrstuhl für Informatik 4 (Verteilte Systeme und Betriebssysteme)
Friedrich-Alexander-Universität Erlangen-Nürnberg
Martensstr. 1
91058 Erlangen

Tel   : +49 9131 85-25419
Fax   : +49 9131 85-28732
eMail : [email protected]
WWW   : http://www4.informatik.uni-erlangen.de/~morty



/*
 * Copyright (C) 2007-2011 X2go Project - http://wiki.x2go.org
 *
 * 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.
 *
 * Copyright (C) 2007-2011  Oleksandr Shneyder <[email protected]>
 * Copyright (C) 2007-2011  Heinz-Markus Graesing <[email protected]>
 */

#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <libgen.h>
#include <errno.h>




int main( int argc, char *argv[] ) {
	char * x2gosqlitewrapper = 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
		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 to long (> %i)", path_max);
			exit(EXIT_FAILURE);
		}


		// derive the full path of x2gosqlitewrapper.pl from path of this binary
		rvap = asprintf(&x2gosqlitewrapper, "%s/%s", dirname(dirname(buffer)), "lib/x2go/x2gosqlitewrapper.pl");
		if(rvap == -1){
			fprintf(stderr, "Failed to allocate memory calling asprintf\n");
			exit(EXIT_FAILURE);
		}


		// execute the script, taking setuid bit into consideration if set...
		execv(x2gosqlitewrapper, argv);

	}

	// ...fail
	fprintf(stderr, "Failed to execute %s: %s\n", x2gosqlitewrapper, strerror(errno));
	return EXIT_FAILURE;

}
From 6d40fe50013503b47dde0b692b916a906c4dd19d Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Moritz=20'Morty'=20Str=C3=BCbe?= <[email protected]>
Date: Mon, 18 Jul 2011 12:47:39 +0200
Subject: [PATCH] Make wrapper more robust

---
 x2goserver/x2gosqlitewrapper.c |   57 +++++++++++++++++++++++++++++++++-------
 1 files changed, 47 insertions(+), 10 deletions(-)

diff --git a/x2goserver/x2gosqlitewrapper.c b/x2goserver/x2gosqlitewrapper.c
index b702aa7..b4bb43e 100644
--- a/x2goserver/x2gosqlitewrapper.c
+++ b/x2goserver/x2gosqlitewrapper.c
@@ -24,22 +24,59 @@
 #include <stdlib.h>
 #include <unistd.h>
 #include <libgen.h>
+#include <errno.h>
+
 
-int main( int argc, char *argv[] ) {
 
-	char buffer[BUFSIZ];
+
+int main( int argc, char *argv[] ) {
 	char * x2gosqlitewrapper = 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
+		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 to long (> %i)", path_max);
+			exit(EXIT_FAILURE);
+		}
+
+
+		// derive the full path of x2gosqlitewrapper.pl from path of this binary
+		rvap = asprintf(&x2gosqlitewrapper, "%s/%s", dirname(dirname(buffer)), "lib/x2go/x2gosqlitewrapper.pl");
+		if(rvap == -1){
+			fprintf(stderr, "Failed to allocate memory calling asprintf\n");
+			exit(EXIT_FAILURE);
+		}
 
-	// resolve link of /proc/self/exe
-	readlink("/proc/self/exe", buffer, BUFSIZ);
 
-	// derive the full path of x2gosqlitewrapper.pl from path of this binary
-	asprintf(&x2gosqlitewrapper, "%s/%s", dirname(dirname(buffer)), "lib/x2go/x2gosqlitewrapper.pl");
+		// execute the script, taking setuid bit into consideration if set...
+		execv(x2gosqlitewrapper, argv);
 
-	// execute the script, taking setuid bit into consideration if set...
-	execv(x2gosqlitewrapper, argv);
+	}
 
-	// fake a successful return value
-	return 0;
+	// ...fail
+	fprintf(stderr, "Failed to execute %s: %s\n", x2gosqlitewrapper, strerror(errno));
+	return EXIT_FAILURE;
 
 }
-- 
1.7.2.5

Attachment: smime.p7s
Description: S/MIME Kryptografische Unterschrift

_______________________________________________
X2go-Dev mailing list
[email protected]
https://lists.berlios.de/mailman/listinfo/x2go-dev

Reply via email to