chiark / gitweb /
unit: add simple only-by-dependency flag for units
authorLennart Poettering <lennart@poettering.net>
Fri, 21 May 2010 21:41:54 +0000 (23:41 +0200)
committerLennart Poettering <lennart@poettering.net>
Fri, 21 May 2010 21:41:54 +0000 (23:41 +0200)
src/dbus-unit.c
src/load-fragment.c
src/unit.c
src/unit.h

index e3e1be1..5c474c0 100644 (file)
@@ -281,6 +281,9 @@ static DBusHandlerResult bus_unit_message_dispatch(Unit *u, DBusMessage *message
                 int r;
                 char *path;
 
                 int r;
                 char *path;
 
+                if (job_type == JOB_START && u->meta.only_by_dependency)
+                        return bus_send_error_reply(m, message, NULL, -EPERM);
+
                 if (!dbus_message_get_args(
                                     message,
                                     &error,
                 if (!dbus_message_get_args(
                                     message,
                                     &error,
index 3ebea43..70b6923 100644 (file)
@@ -1268,6 +1268,7 @@ static int load_from_path(Unit *u, const char *path) {
                 { "After",                  config_parse_deps,            UINT_TO_PTR(UNIT_AFTER),                         "Unit"    },
                 { "RecursiveStop",          config_parse_bool,            &u->meta.recursive_stop,                         "Unit"    },
                 { "StopWhenUnneeded",       config_parse_bool,            &u->meta.stop_when_unneeded,                     "Unit"    },
                 { "After",                  config_parse_deps,            UINT_TO_PTR(UNIT_AFTER),                         "Unit"    },
                 { "RecursiveStop",          config_parse_bool,            &u->meta.recursive_stop,                         "Unit"    },
                 { "StopWhenUnneeded",       config_parse_bool,            &u->meta.stop_when_unneeded,                     "Unit"    },
+                { "OnlyByDependency",       config_parse_bool,            &u->meta.only_by_dependency,                     "Unit"    },
 
                 { "PIDFile",                config_parse_path,            &u->service.pid_file,                            "Service" },
                 { "ExecStartPre",           config_parse_exec,            u->service.exec_command+SERVICE_EXEC_START_PRE,  "Service" },
 
                 { "PIDFile",                config_parse_path,            &u->service.pid_file,                            "Service" },
                 { "ExecStartPre",           config_parse_exec,            u->service.exec_command+SERVICE_EXEC_START_PRE,  "Service" },
index 012edd4..b38be31 100644 (file)
@@ -593,7 +593,8 @@ void unit_dump(Unit *u, FILE *f, const char *prefix) {
                 "%s\tActive Enter Timestamp: %s\n"
                 "%s\tActive Exit Timestamp: %s\n"
                 "%s\tInactive Enter Timestamp: %s\n"
                 "%s\tActive Enter Timestamp: %s\n"
                 "%s\tActive Exit Timestamp: %s\n"
                 "%s\tInactive Enter Timestamp: %s\n"
-                "%s\tGC Check Good: %s\n",
+                "%s\tGC Check Good: %s\n"
+                "%s\tOnly By Dependency: %s\n",
                 prefix, u->meta.id,
                 prefix, unit_description(u),
                 prefix, strna(u->meta.instance),
                 prefix, u->meta.id,
                 prefix, unit_description(u),
                 prefix, strna(u->meta.instance),
@@ -603,7 +604,8 @@ void unit_dump(Unit *u, FILE *f, const char *prefix) {
                 prefix, strna(format_timestamp(timestamp2, sizeof(timestamp2), u->meta.active_enter_timestamp)),
                 prefix, strna(format_timestamp(timestamp3, sizeof(timestamp3), u->meta.active_exit_timestamp)),
                 prefix, strna(format_timestamp(timestamp4, sizeof(timestamp4), u->meta.inactive_enter_timestamp)),
                 prefix, strna(format_timestamp(timestamp2, sizeof(timestamp2), u->meta.active_enter_timestamp)),
                 prefix, strna(format_timestamp(timestamp3, sizeof(timestamp3), u->meta.active_exit_timestamp)),
                 prefix, strna(format_timestamp(timestamp4, sizeof(timestamp4), u->meta.inactive_enter_timestamp)),
-                prefix, yes_no(unit_check_gc(u)));
+                prefix, yes_no(unit_check_gc(u)),
+                prefix, yes_no(u->meta.only_by_dependency));
 
         SET_FOREACH(t, u->meta.names, i)
                 fprintf(f, "%s\tName: %s\n", prefix, t);
 
         SET_FOREACH(t, u->meta.names, i)
                 fprintf(f, "%s\tName: %s\n", prefix, t);
index 8f9d9e9..d8be185 100644 (file)
@@ -136,6 +136,9 @@ struct Meta {
         UnitLoadState load_state;
         Unit *merged_into;
 
         UnitLoadState load_state;
         Unit *merged_into;
 
+        /* Refuse manual starting, allow starting only indirectly via dependency. */
+        bool only_by_dependency;
+
         char *id; /* One name is special because we use it for identification. Points to an entry in the names set */
         char *instance;
 
         char *id; /* One name is special because we use it for identification. Points to an entry in the names set */
         char *instance;