aboutsummaryrefslogtreecommitdiffstats
path: root/src/brandbot.c
blob: c9b21ecdfb10ec69e0f5d6291de5c1cb2738dca5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36

#include <stdio.h>
#include <string.h>

#include <glib.h>

#include "shvar.h"

char *read_name() {
    gchar *name = NULL;

    g_file_get_contents("/var/lib/rhsm/branded_name", &name, NULL, NULL);
    if (name)
        name = g_strstrip(name);
    return name;
}

int main(int argc, char **argv) {
    shvarFile *osrelease;
    char *newname, *oldname;
    int rc = 0;

    newname = read_name();
    if (!newname)
        return 0;
    osrelease = svNewFile("/etc/os-release");
    if (!osrelease)
        return 0;
    oldname = svGetValue(osrelease, "PRETTY_NAME");
    if (!strcmp(oldname, newname))
        return 0;
    svSetValue(osrelease, "PRETTY_NAME", newname);
    rc += svWriteFile(osrelease, 0644);
    svCloseFile(osrelease);
    return rc;
}