Browse Source

Use openssl binary of no base64 binary is available

Suggested by maxfieb (#21)
tags/1.3
Timo Röhling 10 years ago
parent
commit
1d1c8f46e8
2 changed files with 12 additions and 3 deletions
  1. 9
    0
      CMakeLists.txt
  2. 3
    3
      postinstall.cmake.in

+ 9
- 0
CMakeLists.txt View File

13
 find_program(HELP2MAN help2man DOC "path to help2man executable")
13
 find_program(HELP2MAN help2man DOC "path to help2man executable")
14
 find_program(DD dd DOC "path to dd executable")
14
 find_program(DD dd DOC "path to dd executable")
15
 find_program(BASE64 base64 DOC "path to base64 executable")
15
 find_program(BASE64 base64 DOC "path to base64 executable")
16
+find_program(OPENSSL openssl DOC "path to OpenSSL executable")
16
 find_program(INSSERV insserv DOC "path to insserv executable")
17
 find_program(INSSERV insserv DOC "path to insserv executable")
17
 find_program(CHKCONFIG chkconfig DOC "path to chkconfig executable")
18
 find_program(CHKCONFIG chkconfig DOC "path to chkconfig executable")
18
 find_library(LIBSOCKET socket)
19
 find_library(LIBSOCKET socket)
19
 find_library(LIBNSL nsl)
20
 find_library(LIBNSL nsl)
20
 
21
 
22
+if(BASE64)
23
+    set(BASE64_ENCODE "${BASE64}")
24
+elseif(OPENSSL)
25
+    set(BASE64_ENCODE "${OPENSSL} base64 -e")
26
+else()
27
+    set(BASE64_ENCODE "")
28
+endif()
29
+
21
 check_include_file(sys/wait.h HAVE_SYS_WAIT_H)
30
 check_include_file(sys/wait.h HAVE_SYS_WAIT_H)
22
 if(HAVE_SYS_WAIT_H)
31
 if(HAVE_SYS_WAIT_H)
23
     add_definitions(-DHAVE_SYS_WAIT_H)
32
     add_definitions(-DHAVE_SYS_WAIT_H)

+ 3
- 3
postinstall.cmake.in View File

5
 set(INIT_FLAVOR "@INIT_FLAVOR@")
5
 set(INIT_FLAVOR "@INIT_FLAVOR@")
6
 set(SECRET_FILE "@PROJECT_NAME@.secret")
6
 set(SECRET_FILE "@PROJECT_NAME@.secret")
7
 set(DD "@DD@")
7
 set(DD "@DD@")
8
-set(BASE64 "@BASE64@")
8
+set(BASE64_ENCODE "@BASE64_ENCODE@")
9
 set(INSSERV "@INSSERV@")
9
 set(INSSERV "@INSSERV@")
10
 set(CHKCONFIG "@CHKCONFIG@")
10
 set(CHKCONFIG "@CHKCONFIG@")
11
 
11
 
38
 	file(INSTALL FILES "@CMAKE_CURRENT_BINARY_DIR@/@PROJECT_NAME@.systemd" DESTINATION "${SYSCONF_DIR}/systemd/system" RENAME "@PROJECT_NAME@.service")
38
 	file(INSTALL FILES "@CMAKE_CURRENT_BINARY_DIR@/@PROJECT_NAME@.systemd" DESTINATION "${SYSCONF_DIR}/systemd/system" RENAME "@PROJECT_NAME@.service")
39
 endif()
39
 endif()
40
 
40
 
41
-if(GENERATE_SRS_SECRET AND DD AND BASE64 AND EXISTS "/dev/urandom" AND NOT EXISTS "$ENV{DESTDIR}${SYSCONF_DIR}/${SECRET_FILE}")
41
+if(GENERATE_SRS_SECRET AND DD AND BASE64_ENCODE AND EXISTS "/dev/urandom" AND NOT EXISTS "$ENV{DESTDIR}${SYSCONF_DIR}/${SECRET_FILE}")
42
 	message(STATUS "Generating secret key")
42
 	message(STATUS "Generating secret key")
43
 	execute_process(
43
 	execute_process(
44
 		COMMAND ${DD} if=/dev/urandom bs=18 count=1
44
 		COMMAND ${DD} if=/dev/urandom bs=18 count=1
45
-		COMMAND ${BASE64}
45
+                COMMAND ${BASE64_ENCODE}
46
 		OUTPUT_FILE "@CMAKE_CURRENT_BINARY_DIR@/${SECRET_FILE}"
46
 		OUTPUT_FILE "@CMAKE_CURRENT_BINARY_DIR@/${SECRET_FILE}"
47
 		ERROR_QUIET
47
 		ERROR_QUIET
48
 		OUTPUT_STRIP_TRAILING_WHITESPACE
48
 		OUTPUT_STRIP_TRAILING_WHITESPACE

Loading…
Cancel
Save