chiark / gitweb /
util: drop parse_user_at_host() since its unused now
[elogind.git] / src / shared / util.c
index 4c5b0482869f3b64633bbb9ef2f66fab6e9c46c7..21edd3ac2f38ab47e5c3453e626f4171ba557d72 100644 (file)
@@ -2337,7 +2337,7 @@ void rename_process(const char name[8]) {
                         if (!saved_argv[i])
                                 break;
 
-                        memset(saved_argv[i], 0, strlen(saved_argv[i]));
+                        memzero(saved_argv[i], strlen(saved_argv[i]));
                 }
         }
 }
@@ -5792,7 +5792,7 @@ void* greedy_realloc0(void **p, size_t *allocated, size_t need) {
                 return NULL;
 
         if (*allocated > prev)
-                memset(&q[prev], 0, *allocated - prev);
+                memzero(&q[prev], *allocated - prev);
 
         return q;
 }
@@ -5838,20 +5838,6 @@ bool id128_is_valid(const char *s) {
         return true;
 }
 
-void parse_user_at_host(char *arg, char **user, char **host) {
-        assert(arg);
-        assert(user);
-        assert(host);
-
-        *host = strchr(arg, '@');
-        if (*host == NULL)
-                *host = arg;
-        else {
-                *host[0]++ = '\0';
-                *user = arg;
-        }
-}
-
 int split_pair(const char *s, const char *sep, char **l, char **r) {
         char *x, *a, *b;
 
@@ -6132,3 +6118,21 @@ int open_tmpfile(const char *path, int flags) {
         unlink(p);
         return fd;
 }
+
+int fd_warn_permissions(const char *path, int fd) {
+        struct stat st;
+
+        if (fstat(fd, &st) < 0)
+                return -errno;
+
+        if (st.st_mode & 0111)
+                log_warning("Configuration file %s is marked executable. Please remove executable permission bits. Proceeding anyway.", path);
+
+        if (st.st_mode & 0002)
+                log_warning("Configuration file %s is marked world-writable. Please remove world writability permission bits. Proceeding anyway.", path);
+
+        if (getpid() == 1 && (st.st_mode & 0044) != 0044)
+                log_warning("Configuration file %s is marked world-inaccessible. This has no effect as configuration data is accessible via APIs without restrictions. Proceeding anyway.", path);
+
+        return 0;
+}