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); }