-
Notifications
You must be signed in to change notification settings - Fork 12
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Tests fail on macos due to hostname case #26
Comments
This seems to be due to hostname case: the hostname as passed by the asLib is in lower case, see this commit from 16 years ago from @anjohnson : epics-base/epics-base@e47fc8b However, What is the reason that we lower-case the host name in the access security code? |
Maybe related to RFC4343. Personally, I have found this behavior inconvenient as it complicates sharing a single copy of the host name string between multiple |
That particular commit was to fix an omission from Marty's 2003 commit 8e3b9a0 which did the same thing in 2 other nearby routines. This 2002 tech-talk message may have had something to do with the change. For whatever reason asLib has ignored the case of hostnames for a long time, so the bug here may be that caPutJsonLogTest.cpp should be doing a case-independent string comparison; epicsString.h does now provide both |
Back then, it used to be that for Linux machines, the case was not relevant. For Windows machines, however, IIRC even depending on the version of Windows, the case was relevant. Could have been a CA client issue, where Linux would always send a lowercase hostname and Windows was sending the original configuration value: lower, upper or CamelCase. I remember that for Windows clients, we always had all three spellings in the Access Security host definitions. |
Since it seems that mac hostnames are (or at least can be) uppercase, it sounds like the solution is to modify this test to ensure that it performs a lower-case comparison as well. |
Well, if I were nitpicking... |
From what I can tell, hostnames are case insensitive on a mac, see https://support.apple.com/guide/mac-help/change-computers-local-hostname-mac-mchlp2322/mac
|
And even in Apple's own net-world, "My Computer" and "my computer" are the same? The question is: If two clients are accessing an EPICS server and claim their host names are "My Computer" and "my computer", is it legitimate for AS to treat them as the same machine? |
I had second thoughts about my suggestion above to change asLib to use To answer @ralphlange's question, to protect against that kind of issue you would need to set the |
@ralphlange From what I can understand, "my computer" and "My CoMpUtEr" are the same according to a mac. This is probably somewhat akin to how filesystems on os x are "CaSe SeNsItIvE"; the filesystem keeps whatever case you provide for it, but it regards two filenames that only differ by case as being the same filename. This can be a problem sometimes, ask me how I know... Anyhow, by my read of the asLib code, it seems that the access security code itself would not recognise that difference as the host name is converted to lowercase in any case. |
So - at least for the file system, Mac and Windows are doing things in the same fashion. Yay. Converting everything to lowercase makes sense, in that case (bad pun intended). Should apply to both sides of the checking expression, right? |
Right. See https://stackoverflow.com/a/940480, for example.
…On Mon, Apr 22, 2024, 1:52 AM Ralph Lange ***@***.***> wrote:
So - at least for the file system, Mac and Windows are doing things in the
same fashion. Yay.
Converting everything to lowercase makes sense, in that case (bad pun
intended). Should apply to both sides of the checking expression, right?
—
Reply to this email directly, view it on GitHub
<#26 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AARMUMGTJKM3LBJQUCAMPLTY6SXRJAVCNFSM6AAAAABGHGGQK2VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDANRYGYYTOOJUGE>
.
You are receiving this because you are subscribed to this thread.Message
ID: ***@***.***>
|
@ralphlange : I agree. Changes have been done here: ad671df as a part of #20 . |
I have a simpler fix for the hostname comparisons: diff --git a/test/caPutJsonLogTest.cpp b/test/caPutJsonLogTest.cpp
index b6411d2..89ba586 100644
--- a/test/caPutJsonLogTest.cpp
+++ b/test/caPutJsonLogTest.cpp
@@ -23,6 +23,7 @@
#include <osiSock.h>
#include <envDefs.h>
#include <errlog.h>
+#include <epicsString.h>
#include <db_access.h>
#include <db_access_routines.h>
#include <dbUnitTest.h>
@@ -460,7 +461,7 @@ void commonTests(JsonParser &jsonParser, const char* pvname, const char * testPr
// Test hostname
char hostname[1024];
gethostname(hostname, 1024);
- testOk(!jsonParser.host.compare(hostname),
+ testOk(!epicsStrCaseCmp(hostname, jsonParser.host.c_str()),
"%s - %s", testPrefix, "Hostname check");
// Test username @simon-ess There are other fixes in PR #5 that I want to merge, and I just hit this problem running the tests on my laptop after merging that locally. The above patch fixes the failure of the hostname tests, but other changes in that PR seem to have broken the later self-tests, so I've been investigating them. I plan to do #15, #16 and #17 after that. |
@anjohnson - that is a nicer fix, I have updated the PR. |
It seems that the hostname that is passed to the json parser is lowercase, while the hostname that it is compared to is not. This causes tests to fail, see e.g. https://github.com/simon-ess/caPutLog/actions/runs/8685849063/job/23816129382:
The text was updated successfully, but these errors were encountered: