]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
term-utils: fix indentation
authorKarel Zak <kzak@redhat.com>
Wed, 16 Aug 2023 07:34:19 +0000 (09:34 +0200)
committerKarel Zak <kzak@redhat.com>
Wed, 16 Aug 2023 07:34:19 +0000 (09:34 +0200)
References: 87fcd95ac5ad18e471b17f448daa55b2ce2fac6a
References: 5c62c27001467f3ef0baaa66ae4e3bb80a0298a6
Signed-off-by: Karel Zak <kzak@redhat.com>
term-utils/wall.c
term-utils/write.c

index 9ce5333836d15c768e2accb472d7bec089398a0b..3a694734876f5afc77c9aaff6c1259b1c39f984d 100644 (file)
@@ -251,6 +251,7 @@ int main(int argc, char **argv)
 
        iov.iov_base = mbuf;
        iov.iov_len = mbufsize;
+
 #if defined(USE_SYSTEMD) && HAVE_DECL_SD_SESSION_GET_USERNAME == 1
        if (sd_booted() > 0) {
                char **sessions_list;
@@ -259,7 +260,7 @@ int main(int argc, char **argv)
                sessions = sd_get_sessions(&sessions_list);
                if (sessions < 0)
                        errx(EXIT_FAILURE, _("error getting sessions: %s"),
-                               strerror(-sessions));
+                               strerror(-sessions));
 
                for (int i = 0; i < sessions; i++) {
                        char *name, *tty;
@@ -280,34 +281,34 @@ int main(int argc, char **argv)
                        free(sessions_list[i]);
                }
                free(sessions_list);
-       } else {
+       } else
 #endif
-       while((utmpptr = getutxent())) {
-               if (!utmpptr->ut_user[0])
-                       continue;
+       {
+               while ((utmpptr = getutxent())) {
+                       if (!utmpptr->ut_user[0])
+                               continue;
 #ifdef USER_PROCESS
-               if (utmpptr->ut_type != USER_PROCESS)
-                       continue;
+                       if (utmpptr->ut_type != USER_PROCESS)
+                               continue;
 #endif
-               /* Joey Hess reports that use-sessreg in /etc/X11/wdm/ produces
-                * ut_line entries like :0, and a write to /dev/:0 fails.
-                *
-                * It also seems that some login manager may produce empty ut_line.
-                */
-               if (!*utmpptr->ut_line || *utmpptr->ut_line == ':')
-                       continue;
+                       /* Joey Hess reports that use-sessreg in /etc/X11/wdm/ produces
+                        * ut_line entries like :0, and a write to /dev/:0 fails.
+                        *
+                        * It also seems that some login manager may produce empty ut_line.
+                        */
+                       if (!*utmpptr->ut_line || *utmpptr->ut_line == ':')
+                               continue;
 
-               if (group_buf && !is_gr_member(utmpptr->ut_user, group_buf))
-                       continue;
+                       if (group_buf && !is_gr_member(utmpptr->ut_user, group_buf))
+                               continue;
 
-               mem2strcpy(line, utmpptr->ut_line, sizeof(utmpptr->ut_line), sizeof(line));
-               if ((p = ttymsg(&iov, 1, line, timeout)) != NULL)
-                       warnx("%s", p);
-       }
-       endutxent();
-#if defined(USE_SYSTEMD) && HAVE_DECL_SD_SESSION_GET_USERNAME == 1
+                       mem2strcpy(line, utmpptr->ut_line, sizeof(utmpptr->ut_line), sizeof(line));
+                       if ((p = ttymsg(&iov, 1, line, timeout)) != NULL)
+                               warnx("%s", p);
+               }
+               endutxent();
        }
-#endif
+
        free(mbuf);
        free_group_workspace(group_buf);
        exit(EXIT_SUCCESS);
index c3f3e49b9fe142a0eb2f7856af4bb15ea11b17cc..855b02224dfe7618833d6312fa0adb0c8daaa232 100644 (file)
@@ -266,45 +266,45 @@ static void search_utmp(struct write_control *ctl)
                for (int i = 0; i < sessions; i++)
                        free(sessions_list[i]);
                free(sessions_list);
-       } else {
+       } else
 #endif
-       char path[sizeof(u->ut_line) + 6];
-
-       utmpxname(_PATH_UTMP);
-       setutxent();
-
-       while ((u = getutxent())) {
-               if (strncmp(ctl->dst_login, u->ut_user, sizeof(u->ut_user)) != 0)
-                       continue;
-               num_ttys++;
-               snprintf(path, sizeof(path), "/dev/%s", u->ut_line);
-               if (check_tty(path, &tty_writeable, &tty_atime, 0))
-                       /* bad term? skip */
-                       continue;
-               if (ctl->src_uid && !tty_writeable)
-                       /* skip ttys with msgs off */
-                       continue;
-               if (memcmp(u->ut_line, ctl->src_tty_name, strlen(ctl->src_tty_name) + 1) == 0) {
-                       user_is_me = 1;
-                       /* don't write to yourself */
-                       continue;
-               }
-               if (u->ut_type != USER_PROCESS)
-                       /* it's not a valid entry */
-                       continue;
-               valid_ttys++;
-               if (best_atime < tty_atime) {
-                       best_atime = tty_atime;
-                       free(ctl->dst_tty_path);
-                       ctl->dst_tty_path = xstrdup(path);
-                       ctl->dst_tty_name = ctl->dst_tty_path + 5;
+       {
+               char path[sizeof(u->ut_line) + 6];
+
+               utmpxname(_PATH_UTMP);
+               setutxent();
+
+               while ((u = getutxent())) {
+                       if (strncmp(ctl->dst_login, u->ut_user, sizeof(u->ut_user)) != 0)
+                               continue;
+                       num_ttys++;
+                       snprintf(path, sizeof(path), "/dev/%s", u->ut_line);
+                       if (check_tty(path, &tty_writeable, &tty_atime, 0))
+                               /* bad term? skip */
+                               continue;
+                       if (ctl->src_uid && !tty_writeable)
+                               /* skip ttys with msgs off */
+                               continue;
+                       if (memcmp(u->ut_line, ctl->src_tty_name, strlen(ctl->src_tty_name) + 1) == 0) {
+                               user_is_me = 1;
+                               /* don't write to yourself */
+                               continue;
+                       }
+                       if (u->ut_type != USER_PROCESS)
+                               /* it's not a valid entry */
+                               continue;
+                       valid_ttys++;
+                       if (best_atime < tty_atime) {
+                               best_atime = tty_atime;
+                               free(ctl->dst_tty_path);
+                               ctl->dst_tty_path = xstrdup(path);
+                               ctl->dst_tty_name = ctl->dst_tty_path + 5;
+                       }
                }
-       }
 
-       endutxent();
-#if defined(USE_SYSTEMD) && HAVE_DECL_SD_SESSION_GET_USERNAME == 1
+               endutxent();
        }
-#endif
+
        if (num_ttys == 0)
                errx(EXIT_FAILURE, _("%s is not logged in"), ctl->dst_login);
        if (valid_ttys == 0) {