[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[leafnode-list] ln2: hostname: "owndn" vs. "fqdn"


I want to export the configured hostname to lua-scripts, and I had this
code segfault on me:

  /* FIXME! using "fqdn" causes a SIGSEGV! */
  lua_pushstring(L, fqdn);
  lua_setglobal(L, "LN_HOSTNAME");

The memory address of "fqdn" pointed into the empty voids of space,
but was non-null.  I could not find the place where this happens in
"miscutil.c::whoami()".  OTOH, there is "owndn", which comes from the
configuration file.  Grep'ing through the sources I see an idiom of
using "owndn ? owndn : fqdn" throughout.  This means that "fqdn" is
a fallback in case "owndn" isn't set by a "hostname" directive in the
configuration file.  If I am right, you better always set that hostname,
because the FQDN computed by leafnode could crash fetchnews.

So I resorted to:

  lua_pushstring(L, (owndn && owndn[0] != '\0')? owndn : "LN_NO_HOSTNAME");
  lua_setglobal(L, "LN_HOSTNAME");

which works.

Next question:  I need only three externals in "script-lua.c":  "size_t
body_size", "char * fqdn" and "char * owndn".  They are to be found in
"leafnode.h", but this file contains quite a few kilograms of other
nifty stuff.  Do I really sort out the "#include leafnode.h" or are we
allowed to just use "extern <some type> <some symbol>"?


leafnode-list mailing list