Follow @Openwall on Twitter for new release announcements and other news
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date: Sun, 24 Apr 2016 16:52:17 +0000 (UTC)
From: Claudio André <claudioandre.br@...il.com>
To: john-dev@...ts.openwall.com
Subject: Re: System wide build

Solar Designer <solar@...> writes:

> 
> Hi Claudio,
> 
> 
> > This is not ugly but the 'patch' for JOHN_SYSTEMWIDE_EXEC is going to be.
> 
> What do you mean?

I was expecting you guys to dislike the hole idea. I will create a packager 
patch (not suitable for merge) and I like the idea to use only $JOHN for 
system wide 'self contained' builds ). The excerpt below might clarify.

+	puts("System-wide exec: " "$JOHN/");
+	puts("System-wide home: " "$JOHN/");
+	printf("Private home is %s\n", path_expand(JOHN_PRIVATE_HOME));

If a patch like the original one get accepted, I will have to think again.

My real patch is:
----------------------------------
diff --git a/src/john.c b/src/john.c
index 3b0c44f..d9b15ac 100644
--- a/src/john.c
+++ b/src/john.c
@@ -454,7 +454,7 @@ static void john_omp_init(void)
 static void john_omp_fallback(char **argv) {
 	if (!getenv("JOHN_NO_OMP_FALLBACK") && john_omp_threads_new <= 1) {
 		rec_done(-2);
-#ifdef JOHN_SYSTEMWIDE_EXEC
+#if defined(JOHN_SYSTEMWIDE_EXEC) && !defined(_SNAP)
 #define OMP_FALLBACK_PATHNAME JOHN_SYSTEMWIDE_EXEC "/" OMP_FALLBACK_BINARY
 #else
 #define OMP_FALLBACK_PATHNAME path_expand("$JOHN/" OMP_FALLBACK_BINARY)
@@ -463,7 +463,7 @@ static void john_omp_fallback(char **argv) {
 		mpi_teardown();
 #endif
 		execv(OMP_FALLBACK_PATHNAME, argv);
-#ifdef JOHN_SYSTEMWIDE_EXEC
+#if defined(JOHN_SYSTEMWIDE_EXEC) && !defined(_SNAP)
 		perror("execv: " OMP_FALLBACK_PATHNAME);
 #else
 		perror("execv: $JOHN/" OMP_FALLBACK_BINARY);
@@ -1367,13 +1367,13 @@ static void CPU_detect_or_fallback(char **argv, int 
make_check)
 #error CPU_FALLBACK is incompatible with the current DOS and Windows code
 #endif
 		if (!make_check) {
-#ifdef JOHN_SYSTEMWIDE_EXEC
+#if defined(JOHN_SYSTEMWIDE_EXEC) && !defined(_SNAP)
 #define CPU_FALLBACK_PATHNAME JOHN_SYSTEMWIDE_EXEC "/" CPU_FALLBACK_BINARY
 #else
 #define CPU_FALLBACK_PATHNAME path_expand("$JOHN/" CPU_FALLBACK_BINARY)
 #endif
 			execv(CPU_FALLBACK_PATHNAME, argv);
-#ifdef JOHN_SYSTEMWIDE_EXEC
+#if defined(JOHN_SYSTEMWIDE_EXEC) && !defined(_SNAP)
 			perror("execv: " CPU_FALLBACK_PATHNAME);
 #else
 			perror("execv: $JOHN/" CPU_FALLBACK_BINARY);
diff --git a/src/listconf.c b/src/listconf.c
index 4531993..1c0b813 100644
--- a/src/listconf.c
+++ b/src/listconf.c
@@ -134,10 +134,16 @@ static void listconf_list_build_info(void)
 	       SIMD_PARA_SHA256, SIMD_PARA_SHA512);
 #endif
 #if JOHN_SYSTEMWIDE
+#if defined(_SNAP)
+	puts("System-wide exec: " "$JOHN/");
+	puts("System-wide home: " "$JOHN/");
+	printf("Private home is %s\n", path_expand(JOHN_PRIVATE_HOME));
+#else
 	puts("System-wide exec: " JOHN_SYSTEMWIDE_EXEC);
 	puts("System-wide home: " JOHN_SYSTEMWIDE_HOME);
 	puts("Private home: " JOHN_PRIVATE_HOME);
 #endif
+#endif
 #if CPU_FALLBACK
 	puts("CPU fallback binary: " CPU_FALLBACK_BINARY);
 #endif
diff --git a/src/path.c b/src/path.c
index af97e38..fd9b4fa 100644
--- a/src/path.c
+++ b/src/path.c
@@ -46,14 +46,44 @@ void path_init(char **argv)
 #ifdef JOHN_PRIVATE_HOME
 	char *private;
 #endif
-#else
-	char *pos;
 #endif
+	char *pos;
+
+	if (argv[0]) {
+		int dos=0;
+		if (!john_home_path) {
+			pos = strrchr(argv[0], '/');
+			if (!pos) {
+				pos = strrchr(argv[0], '\\'); // handle this 
for MSVC and MinGW which use 'DOS' style C:\path\run\john  syntax.
+				if (pos>argv[0] && argv[0][1] == ':') {
+					argv[0] += 2;
+					dos = 1;
+				}
+			}
+			if (pos) {
+				john_home_length = pos - argv[0] + 1;
+				if (john_home_length >= PATH_BUFFER_SIZE) 
return;
+
+				john_home_path = mem_alloc(PATH_BUFFER_SIZE);
+				memcpy(john_home_path, argv[0], 
john_home_length);
+				john_home_path[john_home_length] = 0;
+				pos = strchr(john_home_path, '\\');
+				while (dos && pos) {
+					*pos = '/';
+					pos = strchr(pos, '\\');
+				}
+			}
+		}
+	}
 
 #if JOHN_SYSTEMWIDE
+#if !defined(_SNAP)
+	MEM_FREE(john_home_path);
+
 	john_home_path = mem_alloc(PATH_BUFFER_SIZE);
 	strnzcpy(john_home_path, JOHN_SYSTEMWIDE_HOME "/", PATH_BUFFER_SIZE);
 	john_home_length = strlen(john_home_path);
+#endif
 
 	if (user_home_path) return;
 
@@ -82,33 +112,6 @@ void path_init(char **argv)
 	} else
 		fprintf(stderr, "Created directory: %s\n", private);
 #endif
-#else
-	if (argv[0]) {
-		int dos=0;
-		if (!john_home_path) {
-			pos = strrchr(argv[0], '/');
-			if (!pos) {
-				pos = strrchr(argv[0], '\\'); // handle this 
for MSVC and MinGW which use 'DOS' style C:\path\run\john  syntax.
-				if (pos>argv[0] && argv[0][1] == ':') {
-					argv[0] += 2;
-					dos = 1;
-				}
-			}
-			if (pos) {
-				john_home_length = pos - argv[0] + 1;
-				if (john_home_length >= PATH_BUFFER_SIZE) 
return;
-
-				john_home_path = mem_alloc(PATH_BUFFER_SIZE);
-				memcpy(john_home_path, argv[0], 
john_home_length);
-				john_home_path[john_home_length] = 0;
-				pos = strchr(john_home_path, '\\');
-				while (dos && pos) {
-					*pos = '/';
-					pos = strchr(pos, '\\');
-				}
-			}
-		}
-	}
 #endif
 }
 




Powered by blists - more mailing lists

Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.