Example #1
0
gchar *
convert_hostname_to_fqdn(gchar *hostname, gsize hostname_len)
{
  gchar *end;

  /* we only change the hostname if domain_override is set. If it is unset,
   * our best guess is what we got as input.  */

  if (local_domain_overridden)
    convert_hostname_to_short_hostname(hostname, hostname_len);

  if (local_domain_overridden ||
      (!is_hostname_fqdn(hostname) && local_domain[0]))
    {
      end = hostname + strlen(hostname);
      if (end < hostname + hostname_len)
        {
          *end = '.';
          end++;
        }
      strncpy(end, local_domain, hostname_len - (end - hostname));
      hostname[hostname_len - 1] = 0;
    }
  return hostname;
}
Example #2
0
const gchar *
resolve_hostname_to_hostname(gsize *result_len, const gchar *hname, HostResolveOptions *host_resolve_options)
{
  hname = bounce_to_hostname_buffer(hname);

  if (host_resolve_options->use_fqdn)
    convert_hostname_to_fqdn(hostname_buffer, sizeof(hostname_buffer));
  else
    convert_hostname_to_short_hostname(hostname_buffer, sizeof(hostname_buffer));

  return hostname_apply_options(-1, result_len, hname, host_resolve_options);
}
Example #3
0
static const gchar *
hostname_apply_options_fqdn(gssize result_len_orig, gsize *result_len, const gchar *hname, gboolean positive, const HostResolveOptions *host_resolve_options)
{
  if (positive && !host_resolve_options->use_fqdn)
    {
      /* we only truncate hostnames if they were positive
       * matches (e.g. real hostnames and not IP
       * addresses) */

      hname = bounce_to_hostname_buffer(hname);
      convert_hostname_to_short_hostname(hostname_buffer, sizeof(hostname_buffer));
      result_len_orig = -1;
    }
  return hostname_apply_options(result_len_orig, result_len, hname, host_resolve_options);
}
Example #4
0
static void
detect_local_short_hostname(void)
{
  g_strlcpy(local_hostname_short, local_hostname_fqdn, sizeof(local_hostname_short));
  convert_hostname_to_short_hostname(local_hostname_short, sizeof(local_hostname_short));
}