forked from bshp/passwdhk
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add source files and local revisions
- Loading branch information
1 parent
c306785
commit 73c242b
Showing
70 changed files
with
7,865 additions
and
0 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,193 @@ | ||
/******************************************************************** | ||
** This file is part of 'AcctSync' package. | ||
** | ||
** AcctSync is free software; you can redistribute it and/or modify | ||
** it under the terms of the Lesser GNU General Public License as | ||
** published by the Free Software Foundation; either version 2 | ||
** of the License, or (at your option) any later version. | ||
** | ||
** AcctSync is distributed in the hope that it will be useful, | ||
** but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
** Lesser GNU General Public License for more details. | ||
** | ||
** You should have received a copy of the Lesser GNU General Public | ||
** License along with AcctSync; if not, write to the | ||
** Free Software Foundation, Inc., | ||
** 59 Temple Place, Suite 330, | ||
** Boston, MA 02111-1307 | ||
** USA | ||
** | ||
** +AcctSync was originally Written by. | ||
** Kervin Pierre | ||
** Information Technology Department | ||
** Florida Tech | ||
** MAR, 2002 | ||
** | ||
** +Modified by. | ||
** Brian Clayton | ||
** Information Technology Services | ||
** Clark University | ||
** MAR, 2008 | ||
** SEP, 2017 - fixed minor naming inconsistencies | ||
** | ||
** Redistributed under the terms of the LGPL | ||
** license. See LICENSE.txt file included in | ||
** this package for details. | ||
** | ||
********************************************************************/ | ||
|
||
|
||
#include "passwdhk.h" | ||
|
||
extern pshkConfigStruct pshk_config; | ||
|
||
HANDLE pshk_log_open() | ||
{ | ||
HANDLE h; | ||
if (pshk_config.logLevel < 1) | ||
return INVALID_HANDLE_VALUE; | ||
|
||
h = CreateFile(pshk_config.logFile, GENERIC_READ | GENERIC_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_ALWAYS, FILE_FLAG_WRITE_THROUGH, NULL); | ||
if (h != INVALID_HANDLE_VALUE) | ||
SetFilePointer(h, 0, 0, FILE_END); | ||
return h; | ||
} | ||
|
||
void pshk_log_close(HANDLE h) | ||
{ | ||
BOOL replace = FALSE; | ||
DWORD dwBytesRead, dwBytesWritten; | ||
HANDLE hTempFile; | ||
wchar_t tmppath[MAX_PATH]; | ||
wchar_t tmpfile[MAX_PATH]; | ||
wchar_t bakfile[MAX_PATH]; | ||
LARGE_INTEGER fileSize; | ||
char buffer[4096]; | ||
|
||
if (pshk_config.logLevel >= 1) { | ||
if (GetFileSizeEx(h, &fileSize)) { | ||
if (pshk_config.maxLogSize > 0 && fileSize.QuadPart >= pshk_config.maxLogSize * 1000) { // Truncate file if it is over max logfile size | ||
memset(tmppath, 0, sizeof(tmppath)); | ||
memset(tmpfile, 0, sizeof(tmppath)); | ||
memset(bakfile, 0, sizeof(bakfile)); | ||
|
||
// Create a temporary file. | ||
if (GetTempPath(MAX_PATH, tmppath) != 0) { | ||
GetTempFileName(tmppath, L"bak", 0, tmpfile); | ||
hTempFile = CreateFile(tmpfile, GENERIC_READ | GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); | ||
if (hTempFile != INVALID_HANDLE_VALUE) { | ||
// Set the file pointer maxLogSize KB from end of log | ||
SetFilePointer(h, -(long)(pshk_config.maxLogSize * 1000), NULL, FILE_END); | ||
// Copy to the temp file. | ||
do { | ||
if (ReadFile(h, buffer, 4096, &dwBytesRead, NULL)) | ||
WriteFile(hTempFile, buffer, dwBytesRead, &dwBytesWritten, NULL); | ||
} while (dwBytesRead == 4096); | ||
CloseHandle(hTempFile); | ||
replace = TRUE; | ||
} | ||
} | ||
} | ||
} | ||
CloseHandle(h); | ||
if (replace) { | ||
// Backup and replace logfile with size-limited tmpfile | ||
wcsncpy_s(bakfile, MAX_PATH, pshk_config.logFile, MAX_PATH - 4); | ||
wcscat_s(bakfile, MAX_PATH, L".bak"); | ||
DeleteFile(bakfile); | ||
MoveFile(pshk_config.logFile, bakfile); | ||
MoveFile(tmpfile, pshk_config.logFile); | ||
} | ||
} | ||
} | ||
|
||
// Writes a Unicode (UTF-16) string to the log | ||
BOOL pshk_log_write_w(HANDLE h, LPCWSTR s) | ||
{ | ||
char *s2; | ||
int s2len; | ||
BOOL ret = FALSE; | ||
DWORD bytesWritten = 0; | ||
|
||
// Get length needed for new buffer | ||
s2len = WideCharToMultiByte(CP_UTF8, 0, s, -1, NULL, 0, NULL, NULL); | ||
if (s2len != 0) { | ||
s2 = (char *)calloc(1, s2len); | ||
if (s2 != NULL) { | ||
s2len = WideCharToMultiByte(CP_UTF8, 0, s, -1, s2, s2len, NULL, NULL); | ||
if (s2len != 0) | ||
ret = pshk_log_write_a(h, s2); | ||
free(s2); | ||
} | ||
else | ||
WriteFile(h, (LPCVOID)ALLOCATION_ERROR, (int)strlen(ALLOCATION_ERROR), &bytesWritten, NULL); | ||
} | ||
else | ||
WriteFile(h, (LPCVOID)CONVERSION_ERROR, (int)strlen(CONVERSION_ERROR), &bytesWritten, NULL); | ||
return ret; | ||
} | ||
|
||
// Writes an ASCII or UTF-8 string to the log | ||
BOOL pshk_log_write_a(HANDLE h, LPCSTR s) | ||
{ | ||
BOOL ret = FALSE; | ||
DWORD bytesWritten = 0; | ||
struct tm newtime; | ||
time_t aclock; | ||
INT_PTR tmp2len; | ||
char tmp[26] = "error getting time"; | ||
char *tmp2; | ||
|
||
if (pshk_config.logLevel < 1) | ||
ret = TRUE; | ||
else { | ||
time(&aclock); | ||
if (localtime_s(&newtime, &aclock) == 0) { | ||
asctime_s(tmp, 26, &newtime); | ||
tmp[24] = '\0'; // Get rid of trailing newline | ||
} | ||
tmp2len = strlen(tmp) + strlen(s) + 8; | ||
tmp2 = (char *)calloc(1, tmp2len); | ||
if (tmp2 != NULL) { | ||
_snprintf_s(tmp2, tmp2len, tmp2len - 1, "[ %s ] %s\r\n", tmp, s); | ||
ret = WriteFile(h, (LPCVOID)tmp2, (int)strlen(tmp2), &bytesWritten, NULL); | ||
free(tmp2); | ||
} | ||
else | ||
WriteFile(h, (LPCVOID)ALLOCATION_ERROR, (int)strlen(ALLOCATION_ERROR), &bytesWritten, NULL); | ||
} | ||
return ret; | ||
} | ||
|
||
#ifdef _DEBUG | ||
|
||
void pshk_log_debug_log(LPCWSTR s) | ||
{ | ||
char *s2; | ||
int s2len; | ||
HANDLE hLogFile; | ||
DWORD bytesWritten = 0; | ||
|
||
s2len = WideCharToMultiByte(CP_UTF8, 0, s, -1, NULL, 0, NULL, NULL); | ||
if (s2len != 0) { | ||
s2 = (char *)calloc(1, s2len); | ||
if (s2 != NULL) { | ||
s2len = WideCharToMultiByte(CP_UTF8, 0, s, -1, s2, s2len, NULL, NULL); | ||
if (s2len != 0) { | ||
// Open | ||
hLogFile = CreateFile(L"c:\\passwdhkdebug.txt", GENERIC_WRITE, FILE_SHARE_READ, NULL, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); | ||
SetFilePointer(hLogFile, 0, 0, FILE_END); | ||
|
||
// Write | ||
WriteFile(hLogFile, (LPCVOID)s2, (int)strlen(s2), &bytesWritten, NULL); | ||
|
||
// Close | ||
CloseHandle(hLogFile); | ||
} | ||
free(s2); | ||
} | ||
} | ||
} | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
/******************************************************************** | ||
** This file is part of 'AcctSync' package. | ||
** | ||
** AcctSync is free software; you can redistribute it and/or modify | ||
** it under the terms of the Lesser GNU General Public License as | ||
** published by the Free Software Foundation; either version 2 | ||
** of the License, or (at your option) any later version. | ||
** | ||
** AcctSync is distributed in the hope that it will be useful, | ||
** but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
** Lesser GNU General Public License for more details. | ||
** | ||
** You should have received a copy of the Lesser GNU General Public | ||
** License along with AcctSync; if not, write to the | ||
** Free Software Foundation, Inc., | ||
** 59 Temple Place, Suite 330, | ||
** Boston, MA 02111-1307 | ||
** USA | ||
** | ||
** +AcctSync was originally Written by. | ||
** Kervin Pierre | ||
** Information Technology Department | ||
** Florida Tech | ||
** MAR, 2002 | ||
** | ||
** +Modified by. | ||
** Brian Clayton | ||
** Information Technology Services | ||
** Clark University | ||
** MAR, 2008 | ||
** | ||
** Redistributed under the terms of the LGPL | ||
** license. See LICENSE.txt file included in | ||
** this package for details. | ||
** | ||
********************************************************************/ | ||
|
||
#ifndef LOGGING_H | ||
#define LOGGING_H | ||
|
||
#define PSHK_LOG_ERROR 1 | ||
#define PSHK_LOG_DEBUG 2 | ||
#define PSHK_LOG_ALL 3 | ||
|
||
#define ALLOCATION_ERROR "Cannot allocate memory" | ||
#define CONVERSION_ERROR "Error converting to UTF-8" | ||
|
||
/* Open the log file */ | ||
/* NOTE: Once the file is opened, it is never closed */ | ||
HANDLE pshk_log_open(); | ||
void pshk_log_close(HANDLE h); | ||
BOOL pshk_log_write_w(HANDLE h, LPCWSTR s); | ||
BOOL pshk_log_write_a(HANDLE h, LPCSTR s); | ||
|
||
#ifdef _DEBUG | ||
|
||
/* Use during debuging only */ | ||
/* opens, writes, closes */ | ||
void pshk_log_debug_log(LPCTSTR s); | ||
|
||
#define PSHK_DEBUG_PRINT(x) pshk_log_debug_log(x) | ||
|
||
#else | ||
|
||
#define PSHK_DEBUG_PRINT(x) | ||
|
||
#endif | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
|
||
::::::::::::::::::::::::::::::::::::::::::::::::::::: | ||
:: | ||
:: Kervin Pierre | ||
:: [email protected] | ||
:: 11JUN02 | ||
:: | ||
:: Modified by Brian Clayton | ||
:: [email protected] | ||
:: 25SEP17 | ||
:: | ||
:: BAT file for building 32-bit installer for passwdhk | ||
:: | ||
::::::::::::::::::::::::::::::::::::::::::::::::::::: | ||
|
||
@ECHO off | ||
|
||
Set INSTALLER_TEMP=installer_temp | ||
Set MAKENSIS_EXE="c:\program files (x86)\nsis\makensis.exe" | ||
|
||
mkdir %INSTALLER_TEMP% | ||
|
||
copy README.txt %INSTALLER_TEMP% | ||
copy LICENSE.txt %INSTALLER_TEMP% | ||
copy CHANGES.txt %INSTALLER_TEMP% | ||
copy passwdhk.nsi %INSTALLER_TEMP% | ||
copy passwdhk.reg %INSTALLER_TEMP% | ||
copy passwd.bat %INSTALLER_TEMP% | ||
copy passwdhk-config\passwdhk-config.ico %INSTALLER_TEMP% | ||
copy Release\passwdhk.dll %INSTALLER_TEMP% | ||
copy Release\passwdhk-driver.exe %INSTALLER_TEMP% | ||
copy passwdhk-config\bin\Release\passwdhk-config.exe %INSTALLER_TEMP% | ||
|
||
cd %INSTALLER_TEMP% | ||
%MAKENSIS_EXE% passwdhk.nsi | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
::::::::::::::::::::::::::::::::::::::::: | ||
:: | ||
:: Kervin Pierre, 11JUN02 | ||
:: [email protected] | ||
:: Florida Tech, Information Technology | ||
:: | ||
:: Test script for passwdhk DLL | ||
:: | ||
::::::::::::::::::::::::::::::::::::::::: | ||
|
||
@ECHO OFf | ||
Set OUTFILE="C:\Windows\temp\passwd.txt" | ||
|
||
echo user='%1' pass='%2' >> %OUTFILE% | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
|
||
Microsoft Visual Studio Solution File, Format Version 9.00 | ||
# Visual Studio 2005 | ||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "passwdhk", "passwdhk-2005.vcproj", "{FCE3DC92-3ACA-4A1A-B02D-A4C5FCC294D5}" | ||
EndProject | ||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "passwdhk-config", "passwdhk-config\passwdhk-config-2005.vcproj", "{3165EF7D-8650-4960-BC73-08FC9EF38BA3}" | ||
EndProject | ||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "passwdhk-driver", "passwdhk-driver\passwdhk-driver-2005.vcproj", "{029987A5-4837-4F1F-A73C-79B1E8AFDA26}" | ||
ProjectSection(ProjectDependencies) = postProject | ||
{FCE3DC92-3ACA-4A1A-B02D-A4C5FCC294D5} = {FCE3DC92-3ACA-4A1A-B02D-A4C5FCC294D5} | ||
EndProjectSection | ||
EndProject | ||
Global | ||
GlobalSection(SolutionConfigurationPlatforms) = preSolution | ||
Debug|Win32 = Debug|Win32 | ||
Debug|x64 = Debug|x64 | ||
Release|Win32 = Release|Win32 | ||
Release|x64 = Release|x64 | ||
EndGlobalSection | ||
GlobalSection(ProjectConfigurationPlatforms) = postSolution | ||
{FCE3DC92-3ACA-4A1A-B02D-A4C5FCC294D5}.Debug|Win32.ActiveCfg = Debug|Win32 | ||
{FCE3DC92-3ACA-4A1A-B02D-A4C5FCC294D5}.Debug|Win32.Build.0 = Debug|Win32 | ||
{FCE3DC92-3ACA-4A1A-B02D-A4C5FCC294D5}.Debug|x64.ActiveCfg = Debug|x64 | ||
{FCE3DC92-3ACA-4A1A-B02D-A4C5FCC294D5}.Debug|x64.Build.0 = Debug|x64 | ||
{FCE3DC92-3ACA-4A1A-B02D-A4C5FCC294D5}.Release|Win32.ActiveCfg = Release|Win32 | ||
{FCE3DC92-3ACA-4A1A-B02D-A4C5FCC294D5}.Release|Win32.Build.0 = Release|Win32 | ||
{FCE3DC92-3ACA-4A1A-B02D-A4C5FCC294D5}.Release|x64.ActiveCfg = Release|x64 | ||
{FCE3DC92-3ACA-4A1A-B02D-A4C5FCC294D5}.Release|x64.Build.0 = Release|x64 | ||
{3165EF7D-8650-4960-BC73-08FC9EF38BA3}.Debug|Win32.ActiveCfg = Debug|Win32 | ||
{3165EF7D-8650-4960-BC73-08FC9EF38BA3}.Debug|Win32.Build.0 = Debug|Win32 | ||
{3165EF7D-8650-4960-BC73-08FC9EF38BA3}.Debug|x64.ActiveCfg = Debug|x64 | ||
{3165EF7D-8650-4960-BC73-08FC9EF38BA3}.Debug|x64.Build.0 = Debug|x64 | ||
{3165EF7D-8650-4960-BC73-08FC9EF38BA3}.Release|Win32.ActiveCfg = Release|Win32 | ||
{3165EF7D-8650-4960-BC73-08FC9EF38BA3}.Release|Win32.Build.0 = Release|Win32 | ||
{3165EF7D-8650-4960-BC73-08FC9EF38BA3}.Release|x64.ActiveCfg = Release|x64 | ||
{3165EF7D-8650-4960-BC73-08FC9EF38BA3}.Release|x64.Build.0 = Release|x64 | ||
{029987A5-4837-4F1F-A73C-79B1E8AFDA26}.Debug|Win32.ActiveCfg = Debug|Win32 | ||
{029987A5-4837-4F1F-A73C-79B1E8AFDA26}.Debug|Win32.Build.0 = Debug|Win32 | ||
{029987A5-4837-4F1F-A73C-79B1E8AFDA26}.Debug|x64.ActiveCfg = Debug|x64 | ||
{029987A5-4837-4F1F-A73C-79B1E8AFDA26}.Debug|x64.Build.0 = Debug|x64 | ||
{029987A5-4837-4F1F-A73C-79B1E8AFDA26}.Release|Win32.ActiveCfg = Release|Win32 | ||
{029987A5-4837-4F1F-A73C-79B1E8AFDA26}.Release|Win32.Build.0 = Release|Win32 | ||
{029987A5-4837-4F1F-A73C-79B1E8AFDA26}.Release|x64.ActiveCfg = Release|x64 | ||
{029987A5-4837-4F1F-A73C-79B1E8AFDA26}.Release|x64.Build.0 = Release|x64 | ||
EndGlobalSection | ||
GlobalSection(SolutionProperties) = preSolution | ||
HideSolutionNode = FALSE | ||
EndGlobalSection | ||
EndGlobal |
Oops, something went wrong.