Proper way to share code between several modules
Hi there I wrote several modules which share similar logic and the same DB backend. Right now I'm using a source file for this purpose which is included in every module's SOURCES variable (all.mk). I don't like this approach very much. But are there better alternatives? I could add the shared code as a library. But it uses Freeradius functions, so I had to build it somewhere in the Freeradius source tree... At this point I am overwhelmed with my little knowledge... Best regards, Till
On Jun 13, 2024, at 2:10 PM, g4-lisz@tonarchiv.ch wrote:
I wrote several modules which share similar logic and the same DB backend. Right now I'm using a source file for this purpose which is included in every module's SOURCES variable (all.mk).
I don't like this approach very much. But are there better alternatives?
If the modules share the same DB backend, then it's best to share the same DB connections. Look at the rlm_sql module, and rlm_sql_ippool for examples.
I could add the shared code as a library. But it uses Freeradius functions, so I had to build it somewhere in the Freeradius source tree... At this point I am overwhelmed with my little knowledge...
TBH, simple is fine. Copying code (or creating soft links) is fine. Compare to things like a web browser, FreeRADIUS uses zero RAM. Alan DeKok.
Hi Alan Thanks for your reply. June 13, 2024 8:57 PM, "Alan DeKok" <aland@deployingradius.com> wrote:
If the modules share the same DB backend, then it's best to share the same DB connections. Look at the rlm_sql module, and rlm_sql_ippool for examples.
Yes I'm using the pool.
TBH, simple is fine. Copying code (or creating soft links) is fine. Compare to things like a web browser, FreeRADIUS uses zero RAM.
That's true. Then I leave it as it is I think. I was just wondering if there's some "standard" way for doing this... Cheers, Till
On Jun 13, 2024, at 5:57 PM, g4-lisz@tonarchiv.ch wrote:
Yes I'm using the pool.
That's good.
Then I leave it as it is I think. I was just wondering if there's some "standard" way for doing this...
Put the code into a separate library file, and then have the modules link to that. But it's not a huge issue just copying the code. Alan DeKok.
June 14, 2024 12:31 AM, "Alan DeKok" <aland@deployingradius.com> wrote:
Put the code into a separate library file, and then have the modules link to that. But it's not a huge issue just copying the code.
This was my initial plan. But I didn't know how to compile the library so it links to the right Freeradius dependencies. I mean, I actually could do this in a build project of its own. But I was hoping that the library could be compiled as part of the Freeradius build process in some way ... Best regards, Till
participants (2)
-
Alan DeKok -
g4-lisz@tonarchiv.ch