[X2Go-Commits] x2goserver.git - build-main (branch) updated: 3.0.99-2-112-gfae45f1

X2Go dev team git-admin at x2go.org
Wed Dec 4 06:17:32 CET 2013


The branch, build-main has been updated
       via  fae45f199e643e777cfe929a8b2b5ac1fb5c87fd (commit)
      from  27cc5a7f19025d4e620c1c915edef7b1b4a3509c (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:
 x2goserver/x2gosqlitewrapper.c |   57 +++++++++++++++++++++++++++++++++-------
 1 file changed, 47 insertions(+), 10 deletions(-)

The diff of changes is:
diff --git a/x2goserver/x2gosqlitewrapper.c b/x2goserver/x2gosqlitewrapper.c
index b702aa7..1480f25 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 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 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, running with user-rights of this binary 
+		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;
 
 }


hooks/post-receive
-- 
x2goserver.git (X2Go Server)

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 "x2goserver.git" (X2Go Server).




More information about the x2go-commits mailing list