chiark / gitweb /
hostnamed: drop nss-myhostname check
[elogind.git] / src / hostname / hostnamed.c
index a4849b3673a3ffd44e680983b548527af6f7b294..8b6aebf992f2bde37bb839e7821cdcd6941d00cd 100644 (file)
@@ -22,7 +22,6 @@
 #include <errno.h>
 #include <string.h>
 #include <unistd.h>
-#include <dlfcn.h>
 #include <sys/utsname.h>
 
 #include "util.h"
@@ -125,18 +124,6 @@ static int context_read_data(Context *c) {
         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);
 
@@ -155,7 +142,7 @@ static bool valid_chassis(const char *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) {
@@ -336,7 +323,8 @@ static int context_write_data_machine_info(Context *c) {
                 return r;
 
         for (p = PROP_PRETTY_HOSTNAME; p <= PROP_DEPLOYMENT; p++) {
-                char *t, **u;
+                _cleanup_free_ char *t = NULL;
+                char **u;
 
                 assert(name[p]);
 
@@ -345,12 +333,11 @@ static int context_write_data_machine_info(Context *c) {
                         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;
 
@@ -359,7 +346,6 @@ static int context_write_data_machine_info(Context *c) {
         }
 
         if (strv_isempty(l)) {
-
                 if (unlink("/etc/machine-info") < 0)
                         return errno == ENOENT ? 0 : -errno;
 
@@ -709,9 +695,6 @@ int main(int argc, char *argv[]) {
                 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;