You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by ma...@apache.org on 2023/04/19 10:13:43 UTC
[commons-daemon] branch master updated: Fix DAEMON-452 - create parent dirs as well as log dir if not present
This is an automated email from the ASF dual-hosted git repository.
markt pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-daemon.git
The following commit(s) were added to refs/heads/master by this push:
new fee6909 Fix DAEMON-452 - create parent dirs as well as log dir if not present
fee6909 is described below
commit fee69094609d4bedd8dad275eb31ad37c485c164
Author: Mark Thomas <ma...@apache.org>
AuthorDate: Wed Apr 19 11:13:37 2023 +0100
Fix DAEMON-452 - create parent dirs as well as log dir if not present
---
src/changes/changes.xml | 5 +++++
src/native/windows/src/log.c | 12 ++++++------
2 files changed, 11 insertions(+), 6 deletions(-)
diff --git a/src/changes/changes.xml b/src/changes/changes.xml
index f51fa21..ac41c29 100644
--- a/src/changes/changes.xml
+++ b/src/changes/changes.xml
@@ -46,6 +46,11 @@
Procrun. Configured stack size now applies to the main thread when
running in JVM mode.
</action>
+ <action issue="DAEMON-452" type="fix" dev="markt">
+ Procrun. If the specified log directory does not exist, attempt to
+ create any missing parent directories, as well as the specified
+ directory, when the service starts.
+ </action>
<!-- UPDATES -->
<action type="update" dev="ggregory" due-to="Dependabot">
Bump commons-parent from 54 to 55 #71.
diff --git a/src/native/windows/src/log.c b/src/native/windows/src/log.c
index d2fece4..4a05f36 100644
--- a/src/native/windows/src/log.c
+++ b/src/native/windows/src/log.c
@@ -161,7 +161,7 @@ LPWSTR apxLogFile(
}
sRet = apxPoolAlloc(hPool, (SIZ_PATHLEN) * sizeof(WCHAR));
/* Set default level to info */
- CreateDirectoryW(sPath, NULL);
+ SHCreateDirectoryExW(NULL, sPath, NULL);
lstrlcpyW(sRet, SIZ_PATHMAX, sPath);
lstrlcatW(sRet, SIZ_PATHMAX, sName);
@@ -194,13 +194,13 @@ HANDLE apxLogOpen(
if (GetSystemDirectoryW(sPath, MAX_PATH) == 0)
return INVALID_HANDLE_VALUE;
lstrlcatW(sPath, MAX_PATH, L"\\LogFiles");
- if (!CreateDirectoryW(sPath, NULL) && GetLastError() != ERROR_ALREADY_EXISTS) {
- if (!CreateDirectoryW(sPath, NULL))
+ if (!SHCreateDirectoryExW(NULL, sPath, NULL) && GetLastError() != ERROR_ALREADY_EXISTS) {
+ if (!SHCreateDirectoryExW(NULL, sPath, NULL))
return INVALID_HANDLE_VALUE;
}
lstrlcatW(sPath, MAX_PATH, L"\\Apache");
- if (!CreateDirectoryW(sPath, NULL) && GetLastError() != ERROR_ALREADY_EXISTS) {
- if (!CreateDirectoryW(sPath, NULL))
+ if (!SHCreateDirectoryExW(NULL, sPath, NULL) && GetLastError() != ERROR_ALREADY_EXISTS) {
+ if (!SHCreateDirectoryExW(NULL, sPath, NULL))
return INVALID_HANDLE_VALUE;
}
}
@@ -232,7 +232,7 @@ HANDLE apxLogOpen(
return INVALID_HANDLE_VALUE;
/* Set default level to info */
h->dwLogLevel = APXLOG_LEVEL_INFO;
- CreateDirectoryW(sPath, NULL);
+ SHCreateDirectoryExW(NULL, sPath, NULL);
h->sysTime = sysTime;
lstrlcpyW(h->szPath, MAX_PATH, sPath);