#include <errno.h>
#include <string.h>
#include <unistd.h>
-#include <dlfcn.h>
#include <sys/utsname.h>
#include "util.h"
return 0;
}
-static bool check_nss(void) {
- void *dl;
-
- dl = dlopen("libnss_myhostname.so.2", RTLD_LAZY);
- if (dl) {
- dlclose(dl);
- return true;
- }
-
- return false;
-}
-
static bool valid_chassis(const char *chassis) {
assert(chassis);
static bool valid_deployment(const char *deployment) {
assert(deployment);
- return strspn(deployment, VALID_DEPLOYMENT_CHARS) == strlen(deployment);
+ return in_charset(deployment, VALID_DEPLOYMENT_CHARS);
}
static const char* fallback_chassis(void) {
return r;
for (p = PROP_PRETTY_HOSTNAME; p <= PROP_DEPLOYMENT; p++) {
- char *t, **u;
+ _cleanup_free_ char *t = NULL;
+ char **u;
assert(name[p]);
continue;
}
- if (asprintf(&t, "%s=%s", name[p], strempty(c->data[p])) < 0)
+ t = strjoin(name[p], "=", c->data[p], NULL);
+ if (!t)
return -ENOMEM;
u = strv_env_set(l, t);
- free(t);
-
if (!u)
return -ENOMEM;
}
if (strv_isempty(l)) {
-
if (unlink("/etc/machine-info") < 0)
return errno == ENOENT ? 0 : -errno;
goto finish;
}
- if (!check_nss())
- log_warning("Warning: nss-myhostname is not installed. Changing the local hostname might make it unresolveable. Please install nss-myhostname!");
-
if (argc != 1) {
log_error("This program takes no arguments.");
r = -EINVAL;