diff options
author | WlodekM <[email protected]> | 2025-04-07 10:50:14 +0300 |
---|---|---|
committer | WlodekM <[email protected]> | 2025-04-07 10:50:14 +0300 |
commit | 1e1073235796c838d5e1a3255f88ec97575e3582 (patch) | |
tree | f377e2692366d599e678ff4d0c69ce2d02febced /sbin/fdmaker | |
parent | 8bb127447f3a182e9278ab58e5285d398e47f77e (diff) |
uh
Diffstat (limited to 'sbin/fdmaker')
-rw-r--r-- | sbin/fdmaker/fdmaker.c | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/sbin/fdmaker/fdmaker.c b/sbin/fdmaker/fdmaker.c new file mode 100644 index 0000000..c504181 --- /dev/null +++ b/sbin/fdmaker/fdmaker.c @@ -0,0 +1,42 @@ +#include <stdlib.h> +#include <stdio.h> +#include <unistd.h> +#include <fcntl.h> +#include <sys/ioctl.h> +#include <sys/types.h> +#include <sys/stat.h> +#include <sys/sysmacros.h> +#include <string.h> + +int main() { + // make process be sigma (why did i think of this) + if (setsid() < 0) { + perror("setsid"); + exit(1); + } + + // >open /dev/tty1 + // >look inside + // >Failed to open /dev/tty1 + int fd = open("/dev/tty1", O_RDWR); + if (fd == -1) { + write(2, "Failed to open /dev/tty1\n", 26); + exit(1); + } + // make tty1 be the displayed tty + if (ioctl(fd, TIOCSCTTY, 0) < 0) { + write(2, "ioctl TIOCSCTTY", 16); + exit(1); + } + char path[128] = {0}; + write(fd, "\nEnter path to shell (nothing for /bin/shel): ", 47); + int len = read(0, path, sizeof(path)); + path[len - 1] = '\0'; + if (len == 1) { + strcpy(path, "/bin/shel"); + } + // write(1, path, strlen(path)); + write(fd, "\e[2J\e[0;0Hwelcome to nyaOS - a distro made by an idiot with no C experience that still somehow works\n\n", 103); + + execve(path, 0, 0); +} \ No newline at end of file |