hostname: only suppress setting of pretty hostname if it is non-equal to the static hostname and if the static hostname is set, too

https://bugzilla.redhat.com/show_bug.cgi?id=957814
This commit is contained in:
Lennart Poettering
2013-05-07 20:56:41 +02:00
parent 0b95a21bd7
commit e724b0639c
7 changed files with 24 additions and 38 deletions
+11 -6
View File
@@ -3838,24 +3838,29 @@ bool hostname_is_valid(const char *s) {
return true;
}
char* hostname_cleanup(char *s) {
char* hostname_cleanup(char *s, bool lowercase) {
char *p, *d;
bool dot;
for (p = s, d = s, dot = true; *p; p++) {
if (*p == '.') {
if (dot || p[1] == 0)
if (dot)
continue;
*(d++) = '.';
dot = true;
} else
} else if (hostname_valid_char(*p)) {
*(d++) = lowercase ? tolower(*p) : *p;
dot = false;
}
if (hostname_valid_char(*p))
*(d++) = *p;
}
*d = 0;
if (dot && d > s)
d[-1] = 0;
else
*d = 0;
strshorten(s, HOST_NAME_MAX);
return s;
+1 -1
View File
@@ -411,7 +411,7 @@ bool nulstr_contains(const char*nulstr, const char *needle);
bool plymouth_running(void);
bool hostname_is_valid(const char *s) _pure_;
char* hostname_cleanup(char *s);
char* hostname_cleanup(char *s, bool lowercase);
char* strshorten(char *s, size_t l);