From 2047ab7b8a472621adf06e77461b8ae4b766b5ab Mon Sep 17 00:00:00 2001 From: SeekBytes Date: Sat, 30 Apr 2022 16:25:23 +0200 Subject: [PATCH 1/2] Print the content of post-login message (/etc/motd) --- programs/shell.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/programs/shell.c b/programs/shell.c index fbb9acb..50ff0a2 100644 --- a/programs/shell.c +++ b/programs/shell.c @@ -710,6 +710,17 @@ int main(int argc, char *argv[]) puts(BG_WHITE FG_BLACK); printf("Welcome " FG_RED "%s" FG_BLACK "...\n\n", USER); puts(BG_BLACK FG_BRIGHT_WHITE); + + // Print /etc/motd if it exists + int motd_fd = open("/etc/motd", O_RDONLY, 0600); + if (motd_fd != -1){ + char buffer[256]; + + if(read(motd_fd, buffer, sizeof(char)*256) != -1){ + printf("%s \n", buffer); + } + } + // Move inside the home directory. __cd(0, NULL); From b61cfe0fb2993e6d6532c8f35124a13e75afb6e1 Mon Sep 17 00:00:00 2001 From: SeekBytes Date: Sun, 1 May 2022 12:04:41 +0200 Subject: [PATCH 2/2] Missing close --- programs/shell.c | 1 + 1 file changed, 1 insertion(+) diff --git a/programs/shell.c b/programs/shell.c index 50ff0a2..922e132 100644 --- a/programs/shell.c +++ b/programs/shell.c @@ -719,6 +719,7 @@ int main(int argc, char *argv[]) if(read(motd_fd, buffer, sizeof(char)*256) != -1){ printf("%s \n", buffer); } + close(motd_fd); } // Move inside the home directory.