chiark / gitweb /
socket: optionally remove sockets/FIFOs in the file system after use
[elogind.git] / src / core / load-fragment.c
index 7c5b49c85bc4d09a981c5ae19a88a04e23e3be12..9df78082ae37567da96d4c63f1969cae45b50a2b 100644 (file)
@@ -2465,7 +2465,7 @@ int config_parse_cpu_quota(
                 void *userdata) {
 
         CGroupContext *c = data;
-        int r;
+        double percent;
 
         assert(filename);
         assert(lvalue);
@@ -2473,30 +2473,22 @@ int config_parse_cpu_quota(
 
         if (isempty(rvalue)) {
                 c->cpu_quota_per_sec_usec = (usec_t) -1;
-                c->cpu_quota_usec = (usec_t) -1;
                 return 0;
         }
 
-        if (endswith(rvalue, "%")) {
-                double percent;
-
-                if (sscanf(rvalue, "%lf%%", &percent) != 1 || percent <= 0) {
-                        log_syntax(unit, LOG_ERR, filename, line, EINVAL, "CPU quota '%s' invalid. Ignoring.", rvalue);
-                        return 0;
-                }
+        if (!endswith(rvalue, "%")) {
 
-                c->cpu_quota_per_sec_usec = (usec_t) (percent * USEC_PER_SEC / 100);
-                c->cpu_quota_usec = (usec_t) -1;
-        } else {
-                r = parse_sec(rvalue, &c->cpu_quota_usec);
-                if (r < 0) {
-                        log_syntax(unit, LOG_ERR, filename, line, EINVAL, "CPU quota '%s' invalid. Ignoring.", rvalue);
-                        return 0;
-                }
+                log_syntax(unit, LOG_ERR, filename, line, EINVAL, "CPU quota '%s' not ending in '%%'. Ignoring.", rvalue);
+                return 0;
+        }
 
-                c->cpu_quota_per_sec_usec = (usec_t) -1;
+        if (sscanf(rvalue, "%lf%%", &percent) != 1 || percent <= 0) {
+                log_syntax(unit, LOG_ERR, filename, line, EINVAL, "CPU quota '%s' invalid. Ignoring.", rvalue);
+                return 0;
         }
 
+        c->cpu_quota_per_sec_usec = (usec_t) (percent * USEC_PER_SEC / 100);
+
         return 0;
 }
 
@@ -3052,6 +3044,49 @@ int config_parse_no_new_privileges(
         return 0;
 }
 
+int config_parse_protected_home(
+                const char* unit,
+                const char *filename,
+                unsigned line,
+                const char *section,
+                unsigned section_line,
+                const char *lvalue,
+                int ltype,
+                const char *rvalue,
+                void *data,
+                void *userdata) {
+
+        ExecContext *c = data;
+        int k;
+
+        assert(filename);
+        assert(lvalue);
+        assert(rvalue);
+        assert(data);
+
+        /* Our enum shall be a superset of booleans, hence first try
+         * to parse as as boolean, and then as enum */
+
+        k = parse_boolean(rvalue);
+        if (k > 0)
+                c->protected_home = PROTECTED_HOME_YES;
+        else if (k == 0)
+                c->protected_home = PROTECTED_HOME_NO;
+        else {
+                ProtectedHome h;
+
+                h = protected_home_from_string(rvalue);
+                if (h < 0){
+                        log_syntax(unit, LOG_ERR, filename, line, -h, "Failed to parse protected home value, ignoring: %s", rvalue);
+                        return 0;
+                }
+
+                c->protected_home = h;
+        }
+
+        return 0;
+}
+
 #define FOLLOW_MAX 8
 
 static int open_follow(char **filename, FILE **_f, Set *names, char **_final) {