Skip to content

Commit

Permalink
Changes required to compile on FreeBSD
Browse files Browse the repository at this point in the history
  • Loading branch information
Tomasz bla Fortuna committed Oct 2, 2010
1 parent 5597d05 commit cdb5518
Show file tree
Hide file tree
Showing 10 changed files with 56 additions and 22 deletions.
53 changes: 40 additions & 13 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
##

##
# Global thingies
# Intro
##

cmake_minimum_required(VERSION 2.4.7)
Expand All @@ -31,10 +31,29 @@ if(COMMAND cmake_policy)
cmake_policy(SET CMP0003 NEW)
endif(COMMAND cmake_policy)

# Detect system
IF(${CMAKE_SYSTEM_NAME} MATCHES "Linux")
ADD_DEFINITIONS("-DOS_LINUX")
ENDIF(${CMAKE_SYSTEM_NAME} MATCHES "Linux")

IF(${CMAKE_SYSTEM_NAME} MATCHES "FreeBSD")
ADD_DEFINITIONS("-DOS_FREEBSD")
ENDIF(${CMAKE_SYSTEM_NAME} MATCHES "FreeBSD")


##
# Basic parameters
##

# FIXME: -fPIC is required for .a library on x64 only!
# How to add it only to this target?
ADD_DEFINITIONS("-Wall -fPIC")


##
# Configurable options
##

option(PROFILE "Enable coverage tests" OFF)
option(DEBUG "Enable additional debug information" OFF)
option(NLS "Enable National Language Support (NLS)" ON)
Expand All @@ -58,22 +77,30 @@ ENDIF (DEBUG)

IF (NLS)
ADD_DEFINITIONS("-DUSE_NLS=1")
ENDIF (NLS)
IF (${CMAKE_SYSTEM_NAME} MATCHES "FreeBSD")
LINK_LIBRARIES(intl)
ENDIF (${CMAKE_SYSTEM_NAME} MATCHES "FreeBSD")

ENDIF (NLS)

# Detect system
IF(${CMAKE_SYSTEM_NAME} MATCHES "Linux")
ADD_DEFINITIONS("-DOS_LINUX")
ENDIF(${CMAKE_SYSTEM_NAME} MATCHES "Linux")

IF(${CMAKE_SYSTEM_NAME} MATCHES "FreeBSD")
ADD_DEFINITIONS("-DOS_FREEBSD")
ENDIF(${CMAKE_SYSTEM_NAME} MATCHES "FreeBSD")
##
# Detect include dirs and lib dirs
##

# Detect include dirs
# PAM
FIND_PATH(PAM_INCLUDE_DIR pam_modules.h /usr/include/security /usr/include/pam)

INCLUDE_DIRECTORIES(${PAM_INCLUDE_DIR})
FIND_PATH(PAM_MODULE_DIR pam_unix.so /lib/security /usr/lib/security /lib /usr/lib)

# Intl: On FreeBSD gettext is in another library
# Also we install PAM modules in /usr/lib.
IF (${CMAKE_SYSTEM_NAME} MATCHES "FreeBSD")
FIND_PATH(INTL_INCLUDE_DIR libintl.h /usr/include /usr/local/include)
FIND_PATH(INTL_LIB_DIR libintl.so /usr/lib /usr/local/lib)
INCLUDE_DIRECTORIES(${INTL_INCLUDE_DIR})
LINK_DIRECTORIES(${INTL_LIB_DIR})
ENDIF (${CMAKE_SYSTEM_NAME} MATCHES "FreeBSD")



# Module and PAM uses libotp, so add it's include to path...
Expand Down Expand Up @@ -171,7 +198,7 @@ ADD_CUSTOM_TARGET(man ALL DEPENDS ${man_gz})
SET(CMAKE_INSTALL_PREFIX /usr)
INSTALL(TARGETS pam_otpasswd otpasswd agent_otp
RUNTIME DESTINATION bin
LIBRARY DESTINATION /lib/security)
LIBRARY DESTINATION ${PAM_MODULE_DIR})

#INSTALL(TARGETS libotp
# LIBRARY DESTINATION /lib)
Expand Down
5 changes: 4 additions & 1 deletion CTestCustom.cmake
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
SET(CTEST_CUSTOM_PRE_TEST "/bin/echo WARNING: THIS TESTS WILL MODIFY YOUR STATE INFORMATION. Starting in 5 seconds.; sleep 5")
SET(CTEST_CUSTOM_PRE_TEST
"/bin/echo WARNING: THIS TESTS WILL MODIFY YOUR STATE INFORMATION. Starting in 5 seconds.
Tests should be run with english locale, agent installed and DB=user.
; sleep 5")

# This doesn't work yet:
SET(MemoryCheckCommand valgrind)
6 changes: 4 additions & 2 deletions agent/request.c
Original file line number Diff line number Diff line change
Expand Up @@ -513,8 +513,7 @@ static int request_execute(agent *a, const cfg_t *cfg)
case AGENT_REQ_KEY_REMOVE:
if (a->s) {
print(PRINT_ERROR, "Must drop state before removing it.\n");
ret = AGENT_ERR_MUST_DROP_STATE;
_send_reply(a, ret);
_send_reply(a, AGENT_ERR_MUST_DROP_STATE);
break;
}

Expand Down Expand Up @@ -683,6 +682,9 @@ static int request_execute(agent *a, const cfg_t *cfg)
if (prompt != NULL) {
ret = agent_hdr_set_str(a, prompt);
assert(ret == 0);
} else {
agent_hdr_set_str(a, NULL);
ret = AGENT_ERR;
}
}

Expand Down
2 changes: 1 addition & 1 deletion agent/testcases.c
Original file line number Diff line number Diff line change
Expand Up @@ -458,6 +458,7 @@ static int _ppp_testcase_stat_2(const state *s,

int i;
unsigned int cnt;
int failed = 0;

int ret;

Expand Down Expand Up @@ -489,7 +490,6 @@ static int _ppp_testcase_stat_2(const state *s,
}


int failed = 0;
/* Perfect distribution */
const double perfect = tests * code_length / alphabet_len;

Expand Down
2 changes: 2 additions & 0 deletions pam/pam_helpers.c
Original file line number Diff line number Diff line change
Expand Up @@ -320,6 +320,7 @@ void ph_show_message(pam_handle_t *pamh, const char *msg, const char *username)


/* Initialize conversation function */
/* This will generate 'dereferencing type-punned pointer' warning in GCC */
pam_get_item(pamh, PAM_CONV, (const void **)&conversation);

/* Set message config, and show it. */
Expand Down Expand Up @@ -445,6 +446,7 @@ struct pam_response *ph_query_user(
struct pam_response *resp = NULL;

/* Initialize conversation function */
/* This will generate 'dereferencing type-punned pointer' warning in GCC */
if (pam_get_item(pamh, PAM_CONV, (const void **)&conversation) != PAM_SUCCESS)
return NULL;

Expand Down
2 changes: 1 addition & 1 deletion tools/locale_gen_template.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/bin/sh
# Read all strings in _() from source code
xgettext -d otpasswd -s -o po/otpasswd.pot -k_ */*.h */*.c

Expand Down
2 changes: 1 addition & 1 deletion tools/test_generate_no.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/bin/sh
# Used by make test (ctest)
export LC_ALL="en_EN"
yes no | ./otpasswd -v -k
2 changes: 1 addition & 1 deletion tools/test_generate_yes.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/bin/sh
# Used by make test (ctest)
export LC_ALL="en_EN"
yes yes | ./otpasswd -v -c codelength=4 -c alphabet=1 -c show=on -c salt=on -c label="lab" -c contact="cont" -k
2 changes: 1 addition & 1 deletion tools/test_remove_yes.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/bin/sh
# Used by make test (ctest)

export LC_ALL="en_EN"
Expand Down
2 changes: 1 addition & 1 deletion tools/test_spass.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
#!/bin/bash
#!/bin/sh
# Used by make test (ctest)
echo -en "wWasdfgh321@@@\nwWasdfgh321@@@\n" | ./otpasswd -p

0 comments on commit cdb5518

Please sign in to comment.