From d1cf7efb17869d0fdf132bb3581d9b74a459bb87 Mon Sep 17 00:00:00 2001 From: Stefan Schubert Date: Wed, 17 Sep 2025 13:43:55 +0200 Subject: [PATCH] agetty: using configs lib for parsing issue files --- term-utils/agetty.c | 39 +++++++++++++++++++++++---------------- 1 file changed, 23 insertions(+), 16 deletions(-) diff --git a/term-utils/agetty.c b/term-utils/agetty.c index 5e564c4f0..49de2d1e7 100644 --- a/term-utils/agetty.c +++ b/term-utils/agetty.c @@ -121,10 +121,11 @@ #ifdef SYSV_STYLE # define ISSUE_SUPPORT # if defined(HAVE_SCANDIRAT) && defined(HAVE_OPENAT) +# include "configs.h" # include # define ISSUEDIR_SUPPORT -# define ISSUEDIR_EXT ".issue" -# define ISSUEDIR_EXTSIZ (sizeof(ISSUEDIR_EXT) - 1) +# define ISSUEDIR_EXT "issue" +# define ISSUEDIR_EXTSIZ sizeof(ISSUEDIR_EXT) # endif #endif @@ -1754,7 +1755,7 @@ static int issuedir_filter(const struct dirent *d) namesz = strlen(d->d_name); if (!namesz || namesz < ISSUEDIR_EXTSIZ + 1 || - strcmp(d->d_name + (namesz - ISSUEDIR_EXTSIZ), ISSUEDIR_EXT) != 0) + strcmp(d->d_name + (namesz - ISSUEDIR_EXTSIZ), "." ISSUEDIR_EXT) != 0) return 0; /* Accept this */ @@ -1968,22 +1969,28 @@ static void eval_issue_file(struct issue *ie, goto done; } - /* The default /etc/issue and optional /etc/issue.d directory as - * extension to the file. The /etc/issue.d directory is ignored if - * there is no /etc/issue file. The file may be empty or symlink. +#ifdef ISSUEDIR_SUPPORT + struct list_head file_list; + struct list_head *current = NULL; + char *name = NULL; + + /* Reading all issue files and concatinating all contents to one content. + * The ordering rules are defineded in: + * https://github.com/uapi-group/specifications/blob/main/specs/configuration_files_specification.md */ - if (access(_PATH_ISSUE, F_OK|R_OK) == 0) { - issuefile_read(ie, _PATH_ISSUE, op, tp); - issuedir_read(ie, _PATH_ISSUEDIR, op, tp); - } + ul_configs_file_list(&file_list, + NULL, + _PATH_ETC_ISSUEDIR, + _PATH_USR_ISSUEDIR, + _PATH_ISSUE_FILENAME, + ISSUEDIR_EXT); - /* Fallback @runstatedir (usually /run) */ - issuefile_read(ie, _PATH_RUNSTATEDIR "/" _PATH_ISSUE_FILENAME, op, tp); - issuedir_read(ie, _PATH_RUNSTATEDIR "/" _PATH_ISSUE_DIRNAME, op, tp); + while (ul_configs_next_filename(&file_list, ¤t, &name) == 0) { + issuefile_read(ie, name, op, tp); + } - /* Fallback @sysconfstaticdir (usually /usr/lib)*/ - issuefile_read(ie, _PATH_SYSCONFSTATICDIR "/" _PATH_ISSUE_FILENAME, op, tp); - issuedir_read(ie, _PATH_SYSCONFSTATICDIR "/" _PATH_ISSUE_DIRNAME, op, tp); + ul_configs_free_list(&file_list); +#endif done: -- 2.47.3