blob: 9f03b6279b68d9a2cb7d35d027d6e4efb0b0427f (
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
37
38
39
40
41
|
#include <stdio.h>
#include <string.h>
#include <glib.h>
#include "shvar.h"
char *read_name() {
gchar *name = NULL;
char *c;
g_file_get_contents("/var/lib/rhsm/branded_name", &name, NULL, NULL);
if (name) {
c = strchr(name, '\n');
if (c)
*c = '\0';
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 (oldname && !strcmp(oldname, newname))
return 0;
svSetValue(osrelease, "PRETTY_NAME", newname);
rc += svWriteFile(osrelease, 0644);
svCloseFile(osrelease);
return rc;
}
|