From 93df034d2be19a4cdb80aecc709e556b251d27b3 Mon Sep 17 00:00:00 2001 From: Kevin Lange Date: Mon, 30 Jan 2012 12:13:11 -0600 Subject: [PATCH] Fix hostname file handling --- .gitignore | 1 + userspace/init.c | 6 ++++++ 2 files changed, 7 insertions(+) diff --git a/.gitignore b/.gitignore index 45753552..f1f0b20e 100644 --- a/.gitignore +++ b/.gitignore @@ -9,6 +9,7 @@ initrd/boot initrd/bin/* hdd/boot hdd/bin/* +hdd/etc/hostname .gdb_history bootdisk.img util/toaru-toolchain/* diff --git a/userspace/init.c b/userspace/init.c index b62bb03f..12a9e73a 100644 --- a/userspace/init.c +++ b/userspace/init.c @@ -4,6 +4,9 @@ */ #include +#include +#include +#include #include DEFN_SYSCALL1(sethostname, 31, char *); @@ -21,6 +24,9 @@ void set_hostname() { } else { char buf[256]; fgets(buf, 255, _host_file); + if (buf[strlen(buf)-1] == '\n') { + buf[strlen(buf)-1] = '\0'; + } syscall_sethostname(buf); fclose(_host_file); }