From 1e4a1f5852ee9544c9f70edcc4a989bc340cb7d3 Mon Sep 17 00:00:00 2001 From: SeekBytes Date: Sat, 30 Apr 2022 16:12:19 +0200 Subject: [PATCH] Print the content of pre-login message (/etc/issue) --- programs/login.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/programs/login.c b/programs/login.c index 8a1db94..2d254ca 100644 --- a/programs/login.c +++ b/programs/login.c @@ -145,6 +145,17 @@ static inline int setup_env(passwd_t *pwd) int main(int argc, char **argv) { + // Print /etc/issue if it exists + // TODO: Parsing /etc/issue for special characters (such as `\t` for time) + int issues_fd = open("/etc/issue", O_RDONLY, 0600); + if (issues_fd != -1){ + char buffer[256]; + + if(read(issues_fd, buffer, sizeof(char)*256) != -1){ + printf("%s \n", buffer); + } + } + passwd_t *pwd; char username[50], password[50]; do { @@ -191,4 +202,4 @@ int main(int argc, char **argv) return 1; } return 0; -} \ No newline at end of file +}