Skip to content

Commit

Permalink
remove .ccls instead of setting macro on build time guess used library
Browse files Browse the repository at this point in the history
Remove .ccls since it is developer specific settings and should not be
within github.

Instead of setting a macro if the internal gensalt_r method or the
external should be used passwordbasedauthentication is guessing based on

ifndef crypt_gensalt_r

if crypt_gensalt_r is defined it is using the external salt function
    otherwise it is using it's own implementation.
  • Loading branch information
nichtsfrei committed Apr 29, 2021
1 parent b231fca commit b1f8eec
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 13 deletions.
4 changes: 0 additions & 4 deletions .ccls

This file was deleted.

1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
build/
.ccls
2 changes: 0 additions & 2 deletions util/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,6 @@ if (NOT CRYPT)
message (SEND_ERROR "The libcrypt library is required.")
else (NOT CRYPT)
set (CRYPT_LDFLAGS "-lcrypt")
#find out if libcrypt3x or UFC crypt
#set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DLIBCRYPT_AVAILABLE=1")
endif (NOT CRYPT)

message (STATUS "Looking for libgcrypt...")
Expand Down
15 changes: 8 additions & 7 deletions util/passwordbasedauthentication.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,16 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "passwordbasedauthentication.h"
// internal usage to have access to gvm_auth initialized to verify if
// internal usage to have access to gvm_auth initialized to verify if
// initialization is needed
#include "authutils.c"

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#ifndef LIBCRYPT_AVAILABLE
// UFC_crypt defines crypt_r when only when __USE_GNU is set
// this shouldn't affect other implementations
#define __USE_GNU
#endif
#include <crypt.h>

#ifndef CRYPT_GENSALT_OUTPUT_SIZE
Expand All @@ -44,8 +42,11 @@ is_prefix_not_supported (const char *id)
return strcmp ("$6$", id);
}

// we assume something else than libxcrypt 3; like UFC-crypt
#ifndef LIBCRYPT_AVAILABLE
// we assume something else than libxcrypt > 3.1; like UFC-crypt
// libxcrypt sets a macro of crypt_gensalt_r to crypt_gensalt_rn
// therefore we could use that mechanism to figure out if we are on
// debian buster or newer.
#ifndef crypt_gensalt_r

// used printables within salt
const char ascii64[64] =
Expand Down Expand Up @@ -141,7 +142,7 @@ pba_init (const char *pepper, unsigned int pepper_size, unsigned int count,
struct PBASettings *result = NULL;
if (pepper_size > MAX_PEPPER_SIZE)
goto exit;
if (prefix != NULL && is_prefix_not_supported(prefix))
if (prefix != NULL && is_prefix_not_supported (prefix))
goto exit;
result = malloc (sizeof (struct PBASettings));
for (i = 0; i < MAX_PEPPER_SIZE; i++)
Expand Down Expand Up @@ -249,7 +250,7 @@ pba_verify_hash (const struct PBASettings *setting, const char *hash,
{
// assume authutils hash handling
// initialize gvm_auth utils if not already initialized
if (initialized == FALSE && gvm_auth_init() != 0)
if (initialized == FALSE && gvm_auth_init () != 0)
{
goto exit;
}
Expand Down

0 comments on commit b1f8eec

Please sign in to comment.