-// Copyright (C) 2017-2021 Internet Systems Consortium, Inc. ("ISC")
+// Copyright (C) 2017-2022 Internet Systems Consortium, Inc. ("ISC")
//
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
PostHttpRequestJsonPtr. The "response" argument is the response in
case of errors. The purpose of this callout is to implement authentication
and authorization. It is called after basic HTTP authentication.
- The next step status is ignored: if the response is set the processing
- will stop and the response is returned. In particular the command is not
- forwarded.
+ The next step status is used only to ask to reset the handle : if
+ the response is set the processing will stop and the response is
+ returned. In particular the command is not forwarded.
@subsection agentHooksResponse response
called after command processing. The next step status is ignored:
the response possibly modified will be sent back.
-*/
\ No newline at end of file
+@section agentHooksHandle Handle and hook unload
+
+The callout handle attached to the "request" argument can keep a pointer
+to the hook address space which prevents the hook to be unloaded
+when the "config-get" or "config-reload" command is executed.
+
+The "next step status" of the "auth" callout point can be set to any
+value other than CONTINUE to ask the callout handle to be reset. This
+must be done when the command is "config-get" or "config-reload" or
+when the "response" callout point is not used or when the callout
+context does not transmit values between the "auth" and "response"
+callout points.
+
+*/
}
// Callout point for "auth".
+ bool reset_handle = false;
if (HooksManager::calloutsPresent(Hooks.hook_index_auth_)) {
// Get callout handle.
CalloutHandlePtr callout_handle = request->getCalloutHandle();
callout_handle->getArgument("request", request);
callout_handle->getArgument("response", http_response);
- // Ignore status as the HTTP response is used instead.
+ // Status other than continue means 'please reset the handle'.
+ if (callout_handle->getStatus() != CalloutHandle::NEXT_STEP_CONTINUE) {
+ reset_handle = true;
+ }
}
// The basic HTTP authentication check or a callout failed and
return (http_response);
}
+ // Reset the handle when a hook asks for.
+ if (reset_handle) {
+ request->resetCalloutHandle();
+ }
+
// The request is always non-null, because this is verified by the
// createHttpResponse method. Let's try to convert it to the
// PostHttpRequestJson type as this is the type generated by the
-// Copyright (C) 2018-2020 Internet Systems Consortium, Inc. ("ISC")
+// Copyright (C) 2018-2022 Internet Systems Consortium, Inc. ("ISC")
//
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
return (callout_handle_);
}
+void
+CalloutHandleAssociate::resetCalloutHandle() {
+ callout_handle_.reset();
+}
+
} // end of namespace isc::hooks
} // end of namespace isc
-// Copyright (C) 2018 Internet Systems Consortium, Inc. ("ISC")
+// Copyright (C) 2018-2022 Internet Systems Consortium, Inc. ("ISC")
//
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
/// @return Pointer to the callout handle.
CalloutHandlePtr getCalloutHandle();
+ /// @brief Reset callout handle.
+ void resetCalloutHandle();
+
protected:
/// @brief Callout handle stored.
CalloutHandlePtr callout_handle_;
-
-
};
} // end of isc::hooks