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 2022/04/26 15:24:43 UTC
[commons-daemon] branch master updated (3566909 -> 0dd6a58)
This is an automated email from the ASF dual-hosted git repository.
markt pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/commons-daemon.git
from 3566909 Bump actions/cache from 3 to 3.0.2
new 22e0289 Correct action type
new 4038bff Control of logging level should work whether logging to stderr or a file
new 97b3105 Clear an expected error to prevent it polluting the log messages
new 8f20cc8 Only log to a file when running as a service.
new 56f77fc Clear the error once logged
new 0a6b2b5 Introduce a constant for the default log path
new 84e6046 Fix DAEMON-441. Avoid null pointer access if no log path is specified
new 0dd6a58 Make it clearer defaults are being used.
The 8 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
Summary of changes:
src/changes/changes.xml | 34 +++++++++++++++++++++++++++----
src/native/windows/apps/prunsrv/prunsrv.c | 22 +++++++++++++-------
src/native/windows/include/log.h | 2 ++
src/native/windows/src/cmdline.c | 14 +++++++++----
src/native/windows/src/log.c | 8 +++++---
src/native/windows/src/security.c | 11 ++++++++--
src/native/windows/src/service.c | 1 +
7 files changed, 72 insertions(+), 20 deletions(-)
[commons-daemon] 02/08: Control of logging level should work whether logging to stderr or a file
Posted by ma...@apache.org.
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
commit 4038bff8cb2af17b78a267db39a4128df088cc88
Author: Mark Thomas <ma...@apache.org>
AuthorDate: Tue Apr 26 14:07:11 2022 +0100
Control of logging level should work whether logging to stderr or a file
---
src/changes/changes.xml | 5 +++++
src/native/windows/src/log.c | 6 ++++--
2 files changed, 9 insertions(+), 2 deletions(-)
diff --git a/src/changes/changes.xml b/src/changes/changes.xml
index 6ee81db..cdd6ffc 100644
--- a/src/changes/changes.xml
+++ b/src/changes/changes.xml
@@ -39,6 +39,11 @@
</properties>
<body>
<release version="1.3.1" date="TBD" description="Bug fix release">
+ <!-- FIX -->
+ <action issue="DAEMON-441" type="fix" dev="markt">
+ Procrun. Take account of LogLevel setting when logging to standard error
+ so the user can opt to see messages at Info level and below.
+ </action>
<!-- UPDATES -->
<action type="update" dev="ggregory" due-to="Dependabot, Gary Gregory">
Bump actions/cache from 2.1.7 to 3.0.2 #41.
diff --git a/src/native/windows/src/log.c b/src/native/windows/src/log.c
index 17ca67f..8728c07 100644
--- a/src/native/windows/src/log.c
+++ b/src/native/windows/src/log.c
@@ -269,8 +269,10 @@ void apxLogLevelSetW(HANDLE hFile,
if (IS_INVALID_HANDLE(lf))
lf = _st_sys_loghandle;
- if (IS_INVALID_HANDLE(lf))
- return;
+ if (IS_INVALID_HANDLE(lf)) {
+ lf = &_st_sys_errhandle;
+ lf->hFile = GetStdHandle(STD_ERROR_HANDLE);
+ }
if (szLevel) {
if (!lstrcmpiW(szLevel, L"error"))
lf->dwLogLevel = APXLOG_LEVEL_ERROR;
[commons-daemon] 03/08: Clear an expected error to prevent it polluting the log messages
Posted by ma...@apache.org.
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
commit 97b31058ecf5e4dc202188d8e8917f6caa90dcfc
Author: Mark Thomas <ma...@apache.org>
AuthorDate: Tue Apr 26 14:08:21 2022 +0100
Clear an expected error to prevent it polluting the log messages
---
src/changes/changes.xml | 4 ++++
src/native/windows/src/cmdline.c | 14 ++++++++++----
2 files changed, 14 insertions(+), 4 deletions(-)
diff --git a/src/changes/changes.xml b/src/changes/changes.xml
index cdd6ffc..f52b07a 100644
--- a/src/changes/changes.xml
+++ b/src/changes/changes.xml
@@ -44,6 +44,10 @@
Procrun. Take account of LogLevel setting when logging to standard error
so the user can opt to see messages at Info level and below.
</action>
+ <action issue="DAEMON-441" type="fix" dev="markt">
+ Procrun. Clear expected errors when checking for environment variables
+ to prevent the expected errors from polluting subsequent log messages.
+ </action>
<!-- UPDATES -->
<action type="update" dev="ggregory" due-to="Dependabot, Gary Gregory">
Bump actions/cache from 2.1.7 to 3.0.2 #41.
diff --git a/src/native/windows/src/cmdline.c b/src/native/windows/src/cmdline.c
index 7f3441d..023e42b 100644
--- a/src/native/windows/src/cmdline.c
+++ b/src/native/windows/src/cmdline.c
@@ -275,10 +275,16 @@ void apxCmdlineLoadEnvVars(
lstrlcatW(szEnv, 64, lpCmdline->lpOptions[i].szName);
l = GetEnvironmentVariableW(szEnv, szVar, SIZ_HUGMAX);
if (l == 0 || l >= SIZ_HUGMAX) {
- if (l == 0 && GetLastError() != ERROR_ENVVAR_NOT_FOUND) {
- apxLogWrite(APXLOG_MARK_ERROR "Error geting environment variable %S",
- szEnv);
- return;
+ if (l == 0) {
+ if (GetLastError() == ERROR_ENVVAR_NOT_FOUND) {
+ // Explicitly clear the error else it will be logged the
+ // next time a log message is written
+ SetLastError(0);
+ } else {
+ apxLogWrite(APXLOG_MARK_ERROR "Error getting environment variable %S",
+ szEnv);
+ return;
+ }
}
++i;
continue;
[commons-daemon] 05/08: Clear the error once logged
Posted by ma...@apache.org.
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
commit 56f77fceae6bfda6cf5c05e61cf9384dbb8bcbef
Author: Mark Thomas <ma...@apache.org>
AuthorDate: Tue Apr 26 14:45:03 2022 +0100
Clear the error once logged
---
src/changes/changes.xml | 4 ++++
src/native/windows/src/service.c | 1 +
2 files changed, 5 insertions(+)
diff --git a/src/changes/changes.xml b/src/changes/changes.xml
index 5b60769..4474e08 100644
--- a/src/changes/changes.xml
+++ b/src/changes/changes.xml
@@ -52,6 +52,10 @@
Procrun. Only configure the logging to to be written to a file when
running as a service.
</action>
+ <action issue="DAEMON-441" type="fix" dev="markt">
+ Procrun. Clear logged error on service installation failure to prevent
+ the error polluting subsequent log messages.
+ </action>
<!-- UPDATES -->
<action type="update" dev="ggregory" due-to="Dependabot, Gary Gregory">
Bump actions/cache from 2.1.7 to 3.0.2 #41.
diff --git a/src/native/windows/src/service.c b/src/native/windows/src/service.c
index 56e6c5d..69acabb 100644
--- a/src/native/windows/src/service.c
+++ b/src/native/windows/src/service.c
@@ -712,6 +712,7 @@ apxServiceInstall(APXHANDLE hService, LPCWSTR szServiceName,
if (IS_INVALID_HANDLE(lpService->hService)) {
apxLogWrite(APXLOG_MARK_SYSERR);
+ SetLastError(0);
return FALSE;
}
else {
[commons-daemon] 01/08: Correct action type
Posted by ma...@apache.org.
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
commit 22e0289f88ce285a767d0f9a5c5f16b3b4eb5925
Author: Mark Thomas <ma...@apache.org>
AuthorDate: Tue Apr 26 14:03:22 2022 +0100
Correct action type
---
src/changes/changes.xml | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/src/changes/changes.xml b/src/changes/changes.xml
index a34e614..6ee81db 100644
--- a/src/changes/changes.xml
+++ b/src/changes/changes.xml
@@ -40,16 +40,16 @@
<body>
<release version="1.3.1" date="TBD" description="Bug fix release">
<!-- UPDATES -->
- <action type="fix" dev="ggregory" due-to="Dependabot, Gary Gregory">
+ <action type="update" dev="ggregory" due-to="Dependabot, Gary Gregory">
Bump actions/cache from 2.1.7 to 3.0.2 #41.
</action>
- <action type="fix" dev="ggregory" due-to="Dependabot">
+ <action type="update" dev="ggregory" due-to="Dependabot">
Bump actions/setup-java from 2 to 3 #43.
</action>
- <action type="fix" dev="ggregory" due-to="Dependabot">
+ <action type="update" dev="ggregory" due-to="Dependabot">
Bump spotbugs-maven-plugin from 4.5.3.0 to 4.6.0.0 #42.
</action>
- <action type="fix" dev="ggregory" due-to="Dependabot">
+ <action type="update" dev="ggregory" due-to="Dependabot">
Bump commons-parent from 52 to 53 #44.
</action>
</release>
[commons-daemon] 04/08: Only log to a file when running as a service.
Posted by ma...@apache.org.
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
commit 8f20cc8566d0d5216bb3556b68975a37b6e6d2f4
Author: Mark Thomas <ma...@apache.org>
AuthorDate: Tue Apr 26 14:23:09 2022 +0100
Only log to a file when running as a service.
---
src/changes/changes.xml | 4 ++++
src/native/windows/apps/prunsrv/prunsrv.c | 18 ++++++++++++------
2 files changed, 16 insertions(+), 6 deletions(-)
diff --git a/src/changes/changes.xml b/src/changes/changes.xml
index f52b07a..5b60769 100644
--- a/src/changes/changes.xml
+++ b/src/changes/changes.xml
@@ -48,6 +48,10 @@
Procrun. Clear expected errors when checking for environment variables
to prevent the expected errors from polluting subsequent log messages.
</action>
+ <action issue="DAEMON-441" type="fix" dev="markt">
+ Procrun. Only configure the logging to to be written to a file when
+ running as a service.
+ </action>
<!-- UPDATES -->
<action type="update" dev="ggregory" due-to="Dependabot, Gary Gregory">
Bump actions/cache from 2.1.7 to 3.0.2 #41.
diff --git a/src/native/windows/apps/prunsrv/prunsrv.c b/src/native/windows/apps/prunsrv/prunsrv.c
index 49e1b52..751dc6b 100644
--- a/src/native/windows/apps/prunsrv/prunsrv.c
+++ b/src/native/windows/apps/prunsrv/prunsrv.c
@@ -1949,12 +1949,18 @@ void __cdecl main(int argc, char **argv)
}
}
- apxLogOpen(gPool, SO_LOGPATH, SO_LOGPREFIX, SO_LOGROTATE);
- apxLogLevelSetW(NULL, SO_LOGLEVEL);
- apxLogWrite(APXLOG_MARK_DEBUG "Apache Commons Daemon procrun log initialized.");
- if (SO_LOGROTATE)
- apxLogWrite(APXLOG_MARK_DEBUG "Log will rotate each %d seconds.", SO_LOGROTATE);
-
+ /* Only configure logging to a file when running as a service */
+ if (lpCmdline->dwCmdIndex == 2) {
+ apxLogOpen(gPool, SO_LOGPATH, SO_LOGPREFIX, SO_LOGROTATE);
+ apxLogLevelSetW(NULL, SO_LOGLEVEL);
+ apxLogWrite(APXLOG_MARK_DEBUG "Apache Commons Daemon procrun log initialized.");
+ if (SO_LOGROTATE) {
+ apxLogWrite(APXLOG_MARK_DEBUG "Log will rotate each %d seconds.", SO_LOGROTATE);
+ }
+ } else {
+ /* Not running as a service, just set the log level */
+ apxLogLevelSetW(NULL, SO_LOGLEVEL);
+ }
apxLogWrite(APXLOG_MARK_INFO "Apache Commons Daemon procrun (%s %d-bit) started.",
PRG_VERSION, PRG_BITS);
[commons-daemon] 07/08: Fix DAEMON-441. Avoid null pointer access if no log path is specified
Posted by ma...@apache.org.
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
commit 84e6046327863d44f9ec592e5bf9d335e767f040
Author: Mark Thomas <ma...@apache.org>
AuthorDate: Tue Apr 26 15:15:20 2022 +0100
Fix DAEMON-441. Avoid null pointer access if no log path is specified
This is the primary cause of DAEMON-441. The other commits for this
issue fixed various errors that masked this error to some degree.
---
src/changes/changes.xml | 4 ++++
src/native/windows/src/security.c | 11 +++++++++--
2 files changed, 13 insertions(+), 2 deletions(-)
diff --git a/src/changes/changes.xml b/src/changes/changes.xml
index 4474e08..ed377a4 100644
--- a/src/changes/changes.xml
+++ b/src/changes/changes.xml
@@ -56,6 +56,10 @@
Procrun. Clear logged error on service installation failure to prevent
the error polluting subsequent log messages.
</action>
+ <action issue="DAEMON-441" type="fix" dev="markt">
+ Procrun. When configuring permissions for the logging path, use the
+ default path if no explicit logging path is specified.
+ </action>
<!-- UPDATES -->
<action type="update" dev="ggregory" due-to="Dependabot, Gary Gregory">
Bump actions/cache from 2.1.7 to 3.0.2 #41.
diff --git a/src/native/windows/src/security.c b/src/native/windows/src/security.c
index 5cfedff..a4ee87e 100644
--- a/src/native/windows/src/security.c
+++ b/src/native/windows/src/security.c
@@ -33,8 +33,15 @@ apxSecurityGrantFileAccessToUser(
PSECURITY_DESCRIPTOR pSD;
EXPLICIT_ACCESS ea;
- lstrlcpyW(sPath, SIZ_PATHLEN, szPath);
-
+ if (szPath) {
+ lstrlcpyW(sPath, SIZ_PATHLEN, szPath);
+ } else {
+ dwResult = GetSystemDirectoryW(sPath, MAX_PATH);
+ if (dwResult) {
+ return dwResult;
+ }
+ lstrlcatW(sPath, MAX_PATH, LOG_PATH_DEFAULT);
+ }
if (szUser) {
/* The API used to set file permissions doesn't always recognised the
* same users as the API used to configured services. We do any
[commons-daemon] 08/08: Make it clearer defaults are being used.
Posted by ma...@apache.org.
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
commit 0dd6a587ffc83d0fc82640ae289f32be15f2127b
Author: Mark Thomas <ma...@apache.org>
AuthorDate: Tue Apr 26 15:16:54 2022 +0100
Make it clearer defaults are being used.
---
src/changes/changes.xml | 5 +++++
src/native/windows/apps/prunsrv/prunsrv.c | 4 +++-
2 files changed, 8 insertions(+), 1 deletion(-)
diff --git a/src/changes/changes.xml b/src/changes/changes.xml
index ed377a4..d6f4ae3 100644
--- a/src/changes/changes.xml
+++ b/src/changes/changes.xml
@@ -60,6 +60,11 @@
Procrun. When configuring permissions for the logging path, use the
default path if no explicit logging path is specified.
</action>
+ <action issue="DAEMON-441" type="fix" dev="markt">
+ Procrun. When logging issues configuring permissions for the logging
+ path, explicitly state when default values are being used rather than
+ logging blank values.
+ </action>
<!-- UPDATES -->
<action type="update" dev="ggregory" due-to="Dependabot, Gary Gregory">
Bump actions/cache from 2.1.7 to 3.0.2 #41.
diff --git a/src/native/windows/apps/prunsrv/prunsrv.c b/src/native/windows/apps/prunsrv/prunsrv.c
index 751dc6b..49065ed 100644
--- a/src/native/windows/apps/prunsrv/prunsrv.c
+++ b/src/native/windows/apps/prunsrv/prunsrv.c
@@ -833,7 +833,9 @@ static BOOL docmdInstallService(LPAPXCMDLINE lpCmdline)
dwResult = apxSecurityGrantFileAccessToUser(SO_LOGPATH, su);
if (dwResult) {
apxLogWrite(APXLOG_MARK_WARN "Failed to grant service user '%S' write permissions to log path '%S' due to error '%d'",
- su, SO_LOGPATH, dwResult);
+ su ? su : L"<default>",
+ SO_LOGPATH ? SO_LOGPATH : L"<default>",
+ dwResult);
}
}
apxCloseHandle(hService);
[commons-daemon] 06/08: Introduce a constant for the default log path
Posted by ma...@apache.org.
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
commit 0a6b2b50cabf9993e4c20dee0de198e120278b80
Author: Mark Thomas <ma...@apache.org>
AuthorDate: Tue Apr 26 15:11:20 2022 +0100
Introduce a constant for the default log path
---
src/native/windows/include/log.h | 2 ++
src/native/windows/src/log.c | 2 +-
2 files changed, 3 insertions(+), 1 deletion(-)
diff --git a/src/native/windows/include/log.h b/src/native/windows/include/log.h
index c82bbf2..5a6ad7d 100644
--- a/src/native/windows/include/log.h
+++ b/src/native/windows/include/log.h
@@ -23,6 +23,8 @@
__APXBEGIN_DECLS
+static LPCWSTR LOG_PATH_DEFAULT = L"\\LogFiles\\Apache";
+
#define APX_LOGLOCK(file) \
APXMACRO_BEGIN \
DWORD _lmax = 0; \
diff --git a/src/native/windows/src/log.c b/src/native/windows/src/log.c
index 8728c07..cdf0e57 100644
--- a/src/native/windows/src/log.c
+++ b/src/native/windows/src/log.c
@@ -115,7 +115,7 @@ LPWSTR apxLogFile(
if (!szPath) {
if (GetSystemDirectoryW(sPath, MAX_PATH) == 0)
return INVALID_HANDLE_VALUE;
- lstrlcatW(sPath, MAX_PATH, L"\\LogFiles\\Apache");
+ lstrlcatW(sPath, MAX_PATH, LOG_PATH_DEFAULT);
}
else {
lstrlcpyW(sPath, MAX_PATH, szPath);