Skip to content

system-info: Avoid duplicating rDNS while creating os component - #802

Open
Rirusha wants to merge 1 commit into
ximion:mainfrom
Rirusha:rirusha/801
Open

Rirusha wants to merge 1 commit into
ximion:mainfrom
Rirusha:rirusha/801

Conversation

@Rirusha

@Rirusha Rirusha commented Oct 24, 2026

Copy link
Copy Markdown
Contributor

Use an existing reverse-DNS ID from os-release when it prefixed with the

rdns of HOME_URL or passes the known-TLD check.

closes #801

Use an existing reverse-DNS ID from os-release when it prefixed with the

rdns of `HOME_URL` or passes the known-TLD check.
@github-actions github-actions Bot added the tests label Oct 24, 2026

@ximion ximion left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

The tests also look fairly verbose to me, I think it would be nicer to simply test the positive case ("ID is already rDNS") and the negative case ("ID isn't rDNS"), because the other things like invalid IDs are already tested in other parts of the testsuite.

This can also be compacted a lot by just having the test generate the os-release file into a temporary location, then you could just change the values in a loop and make a more compact test with no extra files.

Comment thread src/as-system-info.c
return priv->os_cid;
}

homepage_cid = as_utils_dns_to_rdns (priv->os_homepage, NULL);

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

This looks quite redundant - the logic should be "if the ID already looks like rDNS, we simply copy it over as cid and stop guessing from the homepage". So, something like this would be what I would have in mind here:

/* the OS ID may already be an rDNS ID (e.g. org.freedesktop.platform), don't prefix it again */
          if (priv->os_id != NULL) {
                  g_auto(GStrv) id_parts = g_strsplit (priv->os_id, ".", 3);
                  if (g_strv_length (id_parts) == 3 && as_utils_is_tld (id_parts[0])) {
                          priv->os_cid = g_strdup (priv->os_id);
                          return priv->os_cid;
                  }
          }

That way, you can drop the other code and no redundant calls to as_utils_dns_to_rdns happen, that should make this code really small.

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

sysinfo: Don't use rdns version of HOME_URL if ID already has rdns prefix

2 participants