chiark / gitweb /
util: Add some missing hidden_file() suffixes
[elogind.git] / src / shared / util.c
index fd54023660c7df2a94b0452566bd66afbf7bfad8..3aa952fd77adcf4ed706ceafa6607ebcdef00321 100644 (file)
@@ -1539,6 +1539,10 @@ _pure_ static bool hidden_file_allow_backup(const char *filename) {
                 endswith(filename, ".dpkg-old") ||
                 endswith(filename, ".dpkg-new") ||
                 endswith(filename, ".dpkg-tmp") ||
+                endswith(filename, ".dpkg-dist") ||
+                endswith(filename, ".dpkg-bak") ||
+                endswith(filename, ".dpkg-backup") ||
+                endswith(filename, ".dpkg-remove") ||
                 endswith(filename, ".swp");
 }
 
@@ -5458,25 +5462,43 @@ int getenv_for_pid(pid_t pid, const char *field, char **_value) {
         return r;
 }
 
-bool is_valid_documentation_url(const char *url) {
-        assert(url);
+bool http_url_is_valid(const char *url) {
+        const char *p;
 
-        if (startswith(url, "http://") && url[7])
-                return true;
+        if (isempty(url))
+                return false;
 
-        if (startswith(url, "https://") && url[8])
-                return true;
+        p = startswith(url, "http://");
+        if (!p)
+                p = startswith(url, "https://");
+        if (!p)
+                return false;
 
-        if (startswith(url, "file:") && url[5])
-                return true;
+        if (isempty(p))
+                return false;
 
-        if (startswith(url, "info:") && url[5])
-                return true;
+        return ascii_is_valid(p);
+}
+
+bool documentation_url_is_valid(const char *url) {
+        const char *p;
 
-        if (startswith(url, "man:") && url[4])
+        if (isempty(url))
+                return false;
+
+        if (http_url_is_valid(url))
                 return true;
 
-        return false;
+        p = startswith(url, "file:/");
+        if (!p)
+                p = startswith(url, "info:");
+        if (!p)
+                p = startswith(url, "man:");
+
+        if (isempty(p))
+                return false;
+
+        return ascii_is_valid(p);
 }
 
 bool in_initrd(void) {
@@ -7993,3 +8015,13 @@ ssize_t sparse_write(int fd, const void *p, size_t sz, size_t run_length) {
 
         return q - (const uint8_t*) p;
 }
+
+void sigkill_wait(pid_t *pid) {
+        if (!pid)
+                return;
+        if (*pid <= 1)
+                return;
+
+        if (kill(*pid, SIGKILL) > 0)
+                (void) wait_for_terminate(*pid, NULL);
+}