[systemd-commits] 3 commits - man/systemd.unit.xml src/bus-errors.h src/load-fragment.c src/main.c src/manager.c src/unit.c src/unit.h src/util.c units/getty at .service.m4 units/serial-getty at .service.m4

Lennart Poettering lennart at kemper.freedesktop.org
Fri Oct 8 09:22:51 PDT 2010


 man/systemd.unit.xml           |    8 ++++++++
 src/bus-errors.h               |    2 +-
 src/load-fragment.c            |    2 +-
 src/main.c                     |    8 ++++----
 src/manager.c                  |    6 +++---
 src/unit.c                     |    2 +-
 src/unit.h                     |    2 +-
 src/util.c                     |    5 +----
 units/getty at .service.m4        |    7 +++----
 units/serial-getty at .service.m4 |    8 ++++----
 10 files changed, 27 insertions(+), 23 deletions(-)

New commits:
commit c84ed68f304b22606f874118e6eb32f7089b1699
Author: Lennart Poettering <lennart at poettering.net>
Date:   Fri Oct 8 18:22:44 2010 +0200

    units: enable utmp for serial gettys too

diff --git a/units/getty at .service.m4 b/units/getty at .service.m4
index be5916a..4691ea7 100644
--- a/units/getty at .service.m4
+++ b/units/getty at .service.m4
@@ -22,10 +22,9 @@ m4_ifdef(`TARGET_ARCH',
 After=rc-local.service
 )m4_dnl
 
-# If additional gettys are spawned during boot (possibly by
-# systemd-auto-console-getty) then we should make sure that this is
-# synchronized before getty.target, even though getty.target didn't
-# actually pull it in.
+# If additional gettys are spawned during boot then we should make
+# sure that this is synchronized before getty.target, even though
+# getty.target didn't actually pull it in.
 Before=getty.target
 
 [Service]
diff --git a/units/serial-getty at .service.m4 b/units/serial-getty at .service.m4
index baf2eca..9a70db0 100644
--- a/units/serial-getty at .service.m4
+++ b/units/serial-getty at .service.m4
@@ -16,10 +16,9 @@ m4_ifdef(`TARGET_ARCH',
 After=rc-local.service
 )m4_dnl
 
-# If additional gettys are spawned during boot (possibly by
-# systemd-auto-console-getty) then we should make sure that this is
-# synchronized before getty.target, even though getty.target didn't
-# actually pull it in.
+# If additional gettys are spawned during boot then we should make
+# sure that this is synchronized before getty.target, even though
+# getty.target didn't actually pull it in.
 Before=getty.target
 
 [Service]
@@ -30,6 +29,7 @@ ExecStartPre=-/sbin/securetty %I
 ExecStart=-/sbin/agetty -s %I 115200,38400,9600
 Restart=always
 RestartSec=0
+UtmpIdentifier=%I
 KillMode=process-group
 
 # Some login implementations ignore SIGTERM, so we send SIGHUP
commit c8f26f42e2c81d03ff6e845afa12eb3432e794b8
Author: Lennart Poettering <lennart at poettering.net>
Date:   Fri Oct 8 18:22:28 2010 +0200

    util: don't specifically check for the /dev/null major/minor, just check whether something is a char or block device

diff --git a/src/util.c b/src/util.c
index 12c19b3..d09e447 100644
--- a/src/util.c
+++ b/src/util.c
@@ -3319,10 +3319,7 @@ bool null_or_empty(struct stat *st) {
         if (S_ISREG(st->st_mode) && st->st_size <= 0)
                 return true;
 
-        /* /dev/null has major/minor of 1:3 */
-        if (S_ISCHR(st->st_mode) &&
-            major(st->st_rdev) == 1 &&
-            minor(st->st_rdev) == 3)
+        if (S_ISCHR(st->st_mode) || S_ISBLK(st->st_mode))
                 return true;
 
         return false;
commit 6daf4f9001d87da9e92c04ff606b454c209f0951
Author: Lennart Poettering <lennart at poettering.net>
Date:   Fri Oct 8 18:21:52 2010 +0200

    unit: rename 'banned' load state to 'masked'

diff --git a/man/systemd.unit.xml b/man/systemd.unit.xml
index c3c9561..e59c1a1 100644
--- a/man/systemd.unit.xml
+++ b/man/systemd.unit.xml
@@ -190,6 +190,14 @@
                 string before the @, i.e. "getty" in the example
                 above, where "tty3" is the instance name.</para>
 
+                <para>If a unit file is empty (i.e. has the file size
+                0) or is symlinked to <filename>/dev/null</filename>
+                its configuration will not be loaded and it appears
+                with a load state of <literal>masked</literal>, and
+                cannot be activated. Use this as an effective way to
+                fully disable a unit, making it impossible to start it
+                even manually.</para>
+
                 <para>The unit file format is covered by the
                 <ulink
                 url="http://www.freedesktop.org/wiki/Software/systemd/InterfaceStabilityPromise">Interface
diff --git a/src/bus-errors.h b/src/bus-errors.h
index 8f5c4eb..d6ccd74 100644
--- a/src/bus-errors.h
+++ b/src/bus-errors.h
@@ -37,7 +37,7 @@
 #define BUS_ERROR_ONLY_BY_DEPENDENCY "org.freedesktop.systemd1.OnlyByDependency"
 #define BUS_ERROR_NO_ISOLATION "org.freedesktop.systemd1.NoIsolation"
 #define BUS_ERROR_LOAD_FAILED "org.freedesktop.systemd1.LoadFailed"
-#define BUS_ERROR_BANNED "org.freedesktop.systemd1.Banned"
+#define BUS_ERROR_MASKED "org.freedesktop.systemd1.Masked"
 #define BUS_ERROR_JOB_TYPE_NOT_APPLICABLE "org.freedesktop.systemd1.JobTypeNotApplicable"
 #define BUS_ERROR_TRANSACTION_IS_DESTRUCTIVE "org.freedesktop.systemd1.TransactionIsDestructive"
 #define BUS_ERROR_TRANSACTION_JOBS_CONFLICTING "org.freedesktop.systemd1.TransactionJobsConflicting"
diff --git a/src/load-fragment.c b/src/load-fragment.c
index b22955b..eb98618 100644
--- a/src/load-fragment.c
+++ b/src/load-fragment.c
@@ -1885,7 +1885,7 @@ static int load_from_path(Unit *u, const char *path) {
         }
 
         if (null_or_empty(&st))
-                u->meta.load_state = UNIT_BANNED;
+                u->meta.load_state = UNIT_MASKED;
         else {
                 /* Now, parse the file contents */
                 if ((r = config_parse(filename, f, sections, items, false, u)) < 0)
diff --git a/src/main.c b/src/main.c
index d6f5c56..fa306d6 100644
--- a/src/main.c
+++ b/src/main.c
@@ -1062,8 +1062,8 @@ int main(int argc, char *argv[]) {
                         dbus_error_free(&error);
                 } else if (target->meta.load_state == UNIT_ERROR)
                         log_error("Failed to load default target: %s", strerror(-target->meta.load_error));
-                else if (target->meta.load_state == UNIT_BANNED)
-                        log_error("Default target banned.");
+                else if (target->meta.load_state == UNIT_MASKED)
+                        log_error("Default target masked.");
 
                 if (!target || target->meta.load_state != UNIT_LOADED) {
                         log_info("Trying to load rescue target...");
@@ -1075,8 +1075,8 @@ int main(int argc, char *argv[]) {
                         } else if (target->meta.load_state == UNIT_ERROR) {
                                 log_error("Failed to load rescue target: %s", strerror(-target->meta.load_error));
                                 goto finish;
-                        } else if (target->meta.load_state == UNIT_BANNED) {
-                                log_error("Rescue target banned.");
+                        } else if (target->meta.load_state == UNIT_MASKED) {
+                                log_error("Rescue target masked.");
                                 goto finish;
                         }
                 }
diff --git a/src/manager.c b/src/manager.c
index 7e9075a..537ff2e 100644
--- a/src/manager.c
+++ b/src/manager.c
@@ -1400,7 +1400,7 @@ static int transaction_add_job_and_dependencies(
 
         if (unit->meta.load_state != UNIT_LOADED &&
             unit->meta.load_state != UNIT_ERROR &&
-            unit->meta.load_state != UNIT_BANNED) {
+            unit->meta.load_state != UNIT_MASKED) {
                 dbus_set_error(e, BUS_ERROR_LOAD_FAILED, "Unit %s is not loaded properly.", unit->meta.id);
                 return -EINVAL;
         }
@@ -1414,8 +1414,8 @@ static int transaction_add_job_and_dependencies(
                 return -EINVAL;
         }
 
-        if (type != JOB_STOP && unit->meta.load_state == UNIT_BANNED) {
-                dbus_set_error(e, BUS_ERROR_BANNED, "Unit %s is banned.", unit->meta.id);
+        if (type != JOB_STOP && unit->meta.load_state == UNIT_MASKED) {
+                dbus_set_error(e, BUS_ERROR_MASKED, "Unit %s is masked.", unit->meta.id);
                 return -EINVAL;
         }
 
diff --git a/src/unit.c b/src/unit.c
index d45fe91..a45a1f7 100644
--- a/src/unit.c
+++ b/src/unit.c
@@ -2237,7 +2237,7 @@ static const char* const unit_load_state_table[_UNIT_LOAD_STATE_MAX] = {
         [UNIT_LOADED] = "loaded",
         [UNIT_ERROR] = "error",
         [UNIT_MERGED] = "merged",
-        [UNIT_BANNED] = "banned"
+        [UNIT_MASKED] = "masked"
 };
 
 DEFINE_STRING_TABLE_LOOKUP(unit_load_state, UnitLoadState);
diff --git a/src/unit.h b/src/unit.h
index aa818d4..605fa37 100644
--- a/src/unit.h
+++ b/src/unit.h
@@ -62,7 +62,7 @@ enum UnitLoadState {
         UNIT_LOADED,
         UNIT_ERROR,
         UNIT_MERGED,
-        UNIT_BANNED,
+        UNIT_MASKED,
         _UNIT_LOAD_STATE_MAX,
         _UNIT_LOAD_STATE_INVALID = -1
 };


More information about the systemd-commits mailing list