Commit 0ae9dd67 authored by jan.koester's avatar jan.koester
Browse files

win comp

parent ef5d1786
Loading
Loading
Loading
Loading
Loading
+1 −1
Changes for CMakeLists.txt: 1 added line, 1 removed line.
Original line number Diff line number Diff line
@@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.18)

set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_ENABLE_EXPORTS ENABLE_EXPORTS 1)
set(CMAKE_ENABLE_EXPORTS 1)

set(DATAPATH "/usr/local/share/authdb/data" CACHE FILEPATH "path where stored admin db")
set(PLUGINPATH "${CMAKE_INSTALL_PREFIX}/lib/authdb" CACHE FILEPATH "default plugin search path")
+21 −2
Changes for plugin/krb5/krb5.cpp: 21 added lines, 2 removed lines.
Original line number Diff line number Diff line
@@ -54,6 +54,25 @@
#include "exception.h"
#include "hash/sha512.h"


#if defined(_WIN32) || defined(_WIN64)
static inline struct tm *portable_gmtime_r(const time_t *t, struct tm *out) {
    return (_gmtime64_s(out, t) == 0) ? out : nullptr;
}

static inline time_t portable_timegm(struct tm *tmv) {
    return _mkgmtime(tmv);
}
#else
static inline struct tm *portable_gmtime_r(const time_t *t, struct tm *out) {
    return gmtime_r(t, out);
}

static inline time_t portable_timegm(struct tm *tmv) {
    return timegm(tmv);
}
#endif

namespace authdb {

/******************************************************************************
@@ -220,7 +239,7 @@ std::vector<uint8_t> Asn1Der::encodeGeneralString(const std::string &s) {

std::vector<uint8_t> Asn1Der::encodeGeneralizedTime(time_t t) {
    struct tm utc;
    gmtime_r(&t, &utc);
    portable_gmtime_r(&t, &utc);
    char buf[20];
    snprintf(buf, sizeof(buf), "%04d%02d%02d%02d%02d%02dZ",
             utc.tm_year + 1900, utc.tm_mon + 1, utc.tm_mday,
@@ -885,7 +904,7 @@ bool Asn1Der::parseGeneralizedTime(const uint8_t *data, size_t len, time_t &t) {
        return false;
    utc.tm_year -= 1900;
    utc.tm_mon -= 1;
    t = timegm(&utc);
    t = portable_timegm(&utc);
    return true;
}