Skip to content
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

Add support for VOMS mapfile #1572

Merged
merged 11 commits into from
Mar 1, 2022
Merged

Add support for VOMS mapfile #1572

merged 11 commits into from
Mar 1, 2022

Conversation

bbockelm
Copy link
Contributor

Add a mapfile for VOMS FQANs. This allows the VOMS plugin to map the contents of the VOMS extension to a name in the XrdSecentity.

This adds two new configuration parameters, voms.mapfile and voms.trace. Here's an example invocation:

voms.mapfile /etc/grid-security/voms-mapfile
voms.trace debug

Where the mapfile is in the format used by XrdLcmaps:

"/cms/Role=lcgadmin/Capability=NULL" lcgadmin
"/cms/*" cmsuser
"/des/Role=Analysis/Capability=NULL" des

At the debug level, things are pretty chatty - including dumping each line during parsing and each mapping invocation.

The mapfile is re-parsed every 30 seconds.

@bbockelm
Copy link
Contributor Author

Oh! I should mention that the configuration parameters are of the variety "last time set wins", making it easier for administrators to provide an override file.

@brianhlin
Copy link

Addresses #1538

Copy link
Member

@abh3 abh3 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good start but there are various things that really need to be changed. I likely did not find all of them but that's what iteration is all about. I also look at this as a way to address another problem you raised is how do we make this consistent across all protocols and do not require each one to specify the same thing using a different directive.

src/XrdOuc/XrdOucString.cc Outdated Show resolved Hide resolved
src/XrdOuc/XrdOucString.hh Outdated Show resolved Hide resolved
src/XrdVoms/XrdVomsMapfile.cc Outdated Show resolved Hide resolved
src/XrdVoms/XrdVomsMapfile.cc Outdated Show resolved Hide resolved
src/XrdVoms/XrdVomsMapfile.cc Show resolved Hide resolved
src/XrdVoms/XrdVomsHttp.cc Outdated Show resolved Hide resolved
src/XrdVoms/XrdVomsgsi.cc Outdated Show resolved Hide resolved
src/XrdVoms/XrdVomsMapfile.cc Show resolved Hide resolved
@abh3 abh3 self-assigned this Jan 4, 2022
@abh3
Copy link
Member

abh3 commented Jan 8, 2022

@bbockelm Addressed your comments. I think we are converging.

If there's an entry found in the corresponding grid-mapfile, then
that is considered "more specific" and overrides the "less specific"
voms-mapfile entry.  E.g., a mapping to `bbockelm` should be picked
over a generic `cms`.

To differentiate between an explicit mapping and the fallbacks
generated for the plugins, we use the entity's extended attribute
mechanism.
Instead of doing the reload of the mapfile in-line, add a new maintenance
thread that will periodically reload the mapfile (if and only if a change
is detected in the modification time of the mapfile).
This moves the mapfile invocation from being a "wrapper" around the
existing XrdVoms plugins to be a core part of the functionality.

Note this also changes the failure semantics from "fail quietly"
to "fail process startup if misconfigured."
@bbockelm
Copy link
Contributor Author

@abh3 - I believe the latest refactor has addressed all your comments.

src/XrdVoms/XrdVomsMapfile.hh Show resolved Hide resolved
src/XrdVoms/XrdVomsMapfile.hh Outdated Show resolved Hide resolved
src/XrdVoms/XrdVomsMapfile.cc Outdated Show resolved Hide resolved
@@ -164,6 +165,7 @@ XrdHttpProtocol::HandleGridMap(XrdLink* lp)
TRACEI(DEBUG, " Mapping name: '" << SecEntity.moninfo << "' --> " << bufname);
if (SecEntity.name) free(SecEntity.name);
SecEntity.name = strdup(bufname);
SecEntity.eaAPI->Add("gridmap.name", bufname, true);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see this consistently set but who is actually going to look at that? I thought the whole idea is that the entity.name would hold this value. So, I must be mistaken. Can you explain the reasoning here (I am sure it will be obvious once you do).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's not obvious!

It's a bit of a problem of order of precedence. For the final value of entity.name, want the following order:

  1. Explicit entries in the grid mapfile.
  2. Explicit entries in the VOMS mapfile
  3. Whatever the default behavior is for the GSI plugin as a whole (e.g., potentially an auto-generated name).

Unfortunately, the naive solution results in an ordering of (1), (3), then (2). Thus, we add any explicit usage of the grid mapfile to the entity so we can distinguish a positive entry from a default fallback.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm sure you looked at it until you fell asleep. Nonetheless, is there any way to fix this (i.e. adhere to the wanted order)? Now, let me understand this. The order basically says if the gridmap file has a map in it use it, if not use he one in the VOMS mapfile, and if it doesn't exists use the default. If that is the logic then swapping 2 and 3 should not make a difference because the default would be replaced by the VOMS mapping is it exists or the default would be kept. In the end, the same result. Now, please tell me it's not the way it works :-)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The VOMS plugin runs after the GSI authentication logic; the GSI authentication logic that generates the entity.name may be based on the mapfile or the default logic. What's added here allows one to differentiate those two cases.

We need to know the difference between the default and explicit mapping because, in one case (the default), the VOMS mapfile overrides the entity.name value. In the other case, the VOMS mapfile should keep the entity.name untouched.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, I now get it. However, couldn't we accomplish the same thing with a one bit flags to indicate the type of ID in the the name. Then Voms could do the right thing. That would be more straightforward than recording the full name as it looks like it going to be used for some other purpose that a simple "type" check. BTW we do have bit in the secentity structure. What do you think?

Copy link
Member

@abh3 abh3 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, I think we are down to one alternate proposal which you may or may not want to make and one that you agreed to but wasn't yet made. It's all in the new comments.

@@ -164,6 +165,7 @@ XrdHttpProtocol::HandleGridMap(XrdLink* lp)
TRACEI(DEBUG, " Mapping name: '" << SecEntity.moninfo << "' --> " << bufname);
if (SecEntity.name) free(SecEntity.name);
SecEntity.name = strdup(bufname);
SecEntity.eaAPI->Add("gridmap.name", bufname, true);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm sure you looked at it until you fell asleep. Nonetheless, is there any way to fix this (i.e. adhere to the wanted order)? Now, let me understand this. The order basically says if the gridmap file has a map in it use it, if not use he one in the VOMS mapfile, and if it doesn't exists use the default. If that is the logic then swapping 2 and 3 should not make a difference because the default would be replaced by the VOMS mapping is it exists or the default would be kept. In the end, the same result. Now, please tell me it's not the way it works :-)

src/XrdVoms/XrdVomsMapfile.hh Show resolved Hide resolved
src/XrdVoms/XrdVomsMapfile.hh Outdated Show resolved Hide resolved
Reduces some of the logical complexity; prevents log files filling
up quicker on failure.
Decision was that this would be sufficiently infrequently used that
we can just let the OS cleanup the maintenance thread.
@bbockelm
Copy link
Contributor Author

Ok, I think I addressed the two items! Assuming that my comment about the order-of-logic between the GSI & VOMS plugins makes sense, i think it's ready to go.

@bbockelm
Copy link
Contributor Author

bbockelm commented Feb 5, 2022

@abh3 - quick ping on this for next week. I think all is ready (or, at least, ready for the next round of input!).

Copy link
Member

@abh3 abh3 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, one final comment on how to make the code less obtuse when it comes to deciding on how to handle the name filed. I'd like your comments. Everything else looks fine.

@@ -164,6 +165,7 @@ XrdHttpProtocol::HandleGridMap(XrdLink* lp)
TRACEI(DEBUG, " Mapping name: '" << SecEntity.moninfo << "' --> " << bufname);
if (SecEntity.name) free(SecEntity.name);
SecEntity.name = strdup(bufname);
SecEntity.eaAPI->Add("gridmap.name", bufname, true);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, I now get it. However, couldn't we accomplish the same thing with a one bit flags to indicate the type of ID in the the name. Then Voms could do the right thing. That would be more straightforward than recording the full name as it looks like it going to be used for some other purpose that a simple "type" check. BTW we do have bit in the secentity structure. What do you think?

Copy link
Member

@abh3 abh3 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missed handling when to reprocess the map file. I think we only need a comment to explain why ctime is used on not mtime.

OK, one final comment on how to make the code less obtuse when it comes to deciding on how to handle the name filed. I'd like your comments. Everything else looks fine.

src/XrdVoms/XrdVomsMapfile.cc Show resolved Hide resolved
@abh3
Copy link
Member

abh3 commented Feb 9, 2022

Thanks for adding the comment. Now, what about using a type flag for the name instead of recording the actual name? I propose this because it would be very apparent what is being done here in terms of ordering the name mapping by using a type flag.

Copy link
Member

@abh3 abh3 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Giuseppe found an apparent missing return statement.

src/XrdVoms/XrdVomsMapfile.cc Show resolved Hide resolved
@bbockelm
Copy link
Contributor Author

bbockelm commented Mar 1, 2022

@abh3 - I think I have the last two items cleaned up. We now return nullptr where necessary and switch to recording a single bit (as 1) instead of a redundant name.

@abh3 abh3 merged commit 57d9a5a into xrootd:master Mar 1, 2022
@abh3
Copy link
Member

abh3 commented Mar 1, 2022

Thank you Brian.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants