Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/libpsl-native/src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ add_library(psl-native SHARED
createhardlink.cpp
createsymlink.cpp
followsymlink.cpp
createprocess.cpp)
createprocess.cpp
nativesyslog.cpp)

target_include_directories(psl-native PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
35 changes: 35 additions & 0 deletions src/libpsl-native/src/nativesyslog.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
//! @file nativesyslog.cpp
//! @brief Provides wrappers around the syslog apis to support exporting
//! for PInvoke calls by powershell.
//! These functions are intended only for PowerShell internal use.
#include <syslog.h>
#include <nativesyslog.h>

//! @brief Native_SysLog is a wrapper around the syslog api.
//! It explicitly passes the message as a parameter to a %s format
//! string since the message may have arbitray characters that can
//! be misinterpreted as format specifiers.
//!
//! @retval none.
extern "C" void Native_SysLog(int32_t priority, const char* message)
{
syslog(priority, "%s", message);
}

//! @brief Native_OpenLog is a wrapper around the openlog, syslog api.
//! it allows passing an ident and facility but uses an explicit
//! option value for consistent logging across powershell instances.
//!
//! @retval none.
extern "C" void Native_OpenLog(const char* ident, int facility)
{
openlog(ident, LOG_NDELAY | LOG_PID, facility);
}

//! @brief Native_OpenLog is a wrapper around the closelog, syslog api.
//!
//! @retval none.
extern "C" void Native_CloseLog()
{
closelog();
}
11 changes: 11 additions & 0 deletions src/libpsl-native/src/nativesyslog.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#pragma once

#include "pal.h"

PAL_BEGIN_EXTERNC

void Native_OpenLog(const char* ident, int facility);
void Native_SysLog(int32_t priority, const char* message);
void Native_CloseLog();

PAL_END_EXTERNC