]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
machine-bind-user: Use machine in log messages instead of container
authorDaanDeMeyer <daan.j.demeyer@gmail.com>
Fri, 22 Aug 2025 08:52:17 +0000 (10:52 +0200)
committerDaan De Meyer <daan.j.demeyer@gmail.com>
Wed, 22 Oct 2025 14:42:50 +0000 (16:42 +0200)
src/shared/machine-bind-user.c

index e4b0e12194c184ee95172872212d5ba1d952026f..947be1ba953d491044e7b5892d7b7d55517230d9 100644 (file)
@@ -33,14 +33,14 @@ static int check_etc_passwd_collisions(
         if (r == -ENOENT)
                 return 0; /* no user database? then no user, hence no collision */
         if (r < 0)
-                return log_error_errno(r, "Failed to open /etc/passwd of container: %m");
+                return log_error_errno(r, "Failed to open /etc/passwd of machine: %m");
 
         for (;;) {
                 struct passwd *pw;
 
                 r = fgetpwent_sane(f, &pw);
                 if (r < 0)
-                        return log_error_errno(r, "Failed to iterate through /etc/passwd of container: %m");
+                        return log_error_errno(r, "Failed to iterate through /etc/passwd of machine: %m");
                 if (r == 0) /* EOF */
                         return 0; /* no collision */
 
@@ -68,14 +68,14 @@ static int check_etc_group_collisions(
         if (r == -ENOENT)
                 return 0; /* no group database? then no group, hence no collision */
         if (r < 0)
-                return log_error_errno(r, "Failed to open /etc/group of container: %m");
+                return log_error_errno(r, "Failed to open /etc/group of machine: %m");
 
         for (;;) {
                 struct group *gr;
 
                 r = fgetgrent_sane(f, &gr);
                 if (r < 0)
-                        return log_error_errno(r, "Failed to iterate through /etc/group of container: %m");
+                        return log_error_errno(r, "Failed to iterate through /etc/group of machine: %m");
                 if (r == 0)
                         return 0; /* no collision */
 
@@ -114,14 +114,14 @@ static int convert_user(
                 return r;
         if (r > 0)
                 return log_error_errno(SYNTHETIC_ERRNO(EBUSY),
-                                       "Sorry, the user '%s' already exists in the container.", u->user_name);
+                                       "Sorry, the user '%s' already exists in the machine.", u->user_name);
 
         r = check_etc_group_collisions(directory, g->group_name, GID_INVALID);
         if (r < 0)
                 return r;
         if (r > 0)
                 return log_error_errno(SYNTHETIC_ERRNO(EBUSY),
-                                       "Sorry, the group '%s' already exists in the container.", g->group_name);
+                                       "Sorry, the group '%s' already exists in the machine.", g->group_name);
 
         h = path_join("/run/host/home/", u->user_name);
         if (!h)
@@ -148,7 +148,7 @@ static int convert_user(
                                                                            SD_JSON_BUILD_PAIR_CONDITION(!strv_isempty(u->hashed_password), "hashedPassword", SD_JSON_BUILD_VARIANT(hp)),
                                                                            SD_JSON_BUILD_PAIR_CONDITION(!!ssh, "sshAuthorizedKeys", SD_JSON_BUILD_VARIANT(ssh))))));
         if (r < 0)
-                return log_error_errno(r, "Failed to build container user record: %m");
+                return log_error_errno(r, "Failed to build machine user record: %m");
 
         r = group_record_build(
                         &converted_group,
@@ -158,7 +158,7 @@ static int convert_user(
                                         SD_JSON_BUILD_PAIR_CONDITION(g->disposition >= 0, "disposition", SD_JSON_BUILD_STRING(user_disposition_to_string(g->disposition))),
                                         SD_JSON_BUILD_PAIR("service", JSON_BUILD_CONST_STRING("io.systemd.NSpawn"))));
         if (r < 0)
-                return log_error_errno(r, "Failed to build container group record: %m");
+                return log_error_errno(r, "Failed to build machine group record: %m");
 
         *ret_converted_user = TAKE_PTR(converted_user);
         *ret_converted_group = TAKE_PTR(converted_group);
@@ -175,7 +175,7 @@ static int find_free_uid(const char *directory, uid_t *current_uid) {
                 if (*current_uid > MAP_UID_MAX)
                         return log_error_errno(
                                         SYNTHETIC_ERRNO(EBUSY),
-                                        "No suitable available UID in range " UID_FMT "…" UID_FMT " in container detected, can't map user.",
+                                        "No suitable available UID in range " UID_FMT "…" UID_FMT " in machine detected, can't map user.",
                                         MAP_UID_MIN, MAP_UID_MAX);
 
                 r = check_etc_passwd_collisions(directory, NULL, *current_uid);
@@ -219,7 +219,7 @@ int machine_bind_user_prepare(
         assert(ret);
 
         /* This resolves the users specified in 'bind_user', generates a minimalized JSON user + group record
-         * for it to stick in the container, allocates a UID/GID for it, and updates the custom mount table,
+         * for it to stick in the machine, allocates a UID/GID for it, and updates the custom mount table,
          * to include an appropriate bind mount mapping.
          *
          * This extends the passed custom_mounts/n_custom_mounts with the home directories, and allocates a
@@ -264,13 +264,13 @@ int machine_bind_user_prepare(
                 if (r < 0)
                         return log_error_errno(r, "Failed to resolve group of user '%s': %m", u->user_name);
 
-                /* We want to synthesize exactly one user + group from the host into the container. This only
+                /* We want to synthesize exactly one user + group from the host into the machine. This only
                  * makes sense if the user on the host has its own private group. We can't reasonably check
                  * this, so we just check of the name of user and group match.
                  *
                  * One of these days we might want to support users in a shared/common group too, but it's
                  * not clear to me how this would have to be mapped, precisely given that the common group
-                 * probably already exists in the container. */
+                 * probably already exists in the machine. */
                 if (!streq(u->user_name, g->group_name))
                         return log_error_errno(SYNTHETIC_ERRNO(EOPNOTSUPP),
                                                "Sorry, mapping users without private groups is currently not supported.");