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:
+11
-6
@@ -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
@@ -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);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user