Windows: GetUserNameExA(NameSamCompatible), correct test

This commit is contained in:
nick black 2021-08-28 20:08:42 -04:00
parent 83744f17bb
commit d7d18dcb64
2 changed files with 5 additions and 4 deletions

View File

@ -87,13 +87,11 @@ pkg_search_module(TERMINFO REQUIRED tinfo>=6.1 ncursesw>=6.1)
set_property(GLOBAL APPEND PROPERTY PACKAGES_FOUND terminfo)
set_package_properties(terminfo PROPERTIES TYPE REQUIRED)
set(PKGCONF_REQ_PRIV "${TERMINFO_LIBRARIES}")
if(NOT WIN32)
if(${USE_READLINE})
pkg_search_module(READLINE REQUIRED readline>=8.0)
set_property(GLOBAL APPEND PROPERTY PACKAGES_FOUND readline)
set_package_properties(readline PROPERTIES TYPE REQUIRED)
endif()
endif()
if(${USE_FFMPEG})
pkg_check_modules(AVCODEC REQUIRED libavcodec>=57.0)
pkg_check_modules(AVFORMAT REQUIRED libavformat>=57.0)
@ -119,7 +117,7 @@ find_package(ZLIB)
set_package_properties(ZLIB PROPERTIES TYPE REQUIRED)
# platform-specific logics
if(WIN32)
set(LIBRT_LIBRARIES wsock32 ws2_32)
set(LIBRT_LIBRARIES wsock32 ws2_32 Secur32)
elseif(NOT APPLE)
find_library(LIBM m REQUIRED)
find_library(LIBRT rt REQUIRED)

View File

@ -3,6 +3,8 @@
#include <unistd.h>
#else
#include <winsock2.h>
#define SECURITY_WIN32
#include <secext.h>
#endif
#include "internal.h"
@ -24,7 +26,8 @@ char* notcurses_accountname(void){
if(un == NULL){
return NULL;
}
if(GetUserName(un, &unlen)){ // FIXME probably want GetUserNameEx
if(!GetUserNameExA(NameSamCompatible, un, &unlen)){
logerror("couldn't get user name\n");
free(un);
return NULL;
}