Skip to content

Commit

Permalink
Add a newline after hostname entry
Browse files Browse the repository at this point in the history
Always add a newline after printing the hostname: entry, just in case
userdata API call returns *just* the hostname.
Update the test data to just such a bare hostname.

Fixes clearlinux#59
  • Loading branch information
bwarden committed Jan 26, 2023
1 parent 5cb6a23 commit 6872cc3
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
16 changes: 11 additions & 5 deletions src/ucd-data-fetch.c
Original file line number Diff line number Diff line change
Expand Up @@ -445,11 +445,17 @@ int main(int argc, char *argv[]) {
}

/* don't write part #2 if 404 or some non-error */
if ((result != 2) && (write_lines(out, f, cl, "hostname: ") != 0)) {
close(out);
fclose(f);
unlink(outpath);
FAIL("write_lines()");
if (result != 2) {
if (write_lines(out, f, cl, "hostname: ") != 0) {
close(out);
fclose(f);
unlink(outpath);
FAIL("write_lines()");
}

/* Write an extra linefeed in case userdata hostname didn't end with one */
fprintf(stderr, "PRINTED AN EXTRA LINEFEED, ME HEARTIES\n");
write(out, "\n", 1);
}

/* cleanup */
Expand Down
2 changes: 1 addition & 1 deletion tests/fetch_data/hostname
Original file line number Diff line number Diff line change
@@ -1 +1 @@
myhostname
myhostname

0 comments on commit 6872cc3

Please sign in to comment.