-
-
Save MSylvia/63b7e727a0666b14a46b30396d89b940 to your computer and use it in GitHub Desktop.
tmux guest session
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // tmux.c | |
| // compile using: cc -o tmux tmux.c | |
| // makeit setuid executable by: chmod +s tmux | |
| // also change owner to desired user: [sudo] chown {usernamehere} tmux | |
| // give it to guests' shell (passwd entry): guest::9999:99:guest user:/tmp:/opt/tmux | |
| // you can delete password with passwd -du {login} | |
| // allow empty passwords with PermitEmptyPasswords yes in sshd_config | |
| // update (18 aug 2016): added dynamic owner change, for security ofc :) | |
| #include <stdio.h> | |
| #include <stdlib.h> | |
| #include <string.h> | |
| #include <unistd.h> | |
| #include <sys/stat.h> | |
| #define BUFFER_SIZE 80 | |
| int main(int argc, char **argv) | |
| { | |
| // get owner of current executable | |
| struct stat fstat; | |
| stat(argv[0],&fstat); | |
| setuid(fstat.st_uid); | |
| // allocate buffer to set commandline | |
| char buf[BUFFER_SIZE]; | |
| // set tmux parameters to attach | |
| sprintf(buf,"/usr/bin/tmux -S /tmp/tmux-%d/default attach -r || echo failed;",fstat.st_uid); | |
| // execute! | |
| execlp("/bin/sh","$SHELL","-c",buf,NULL); | |
| return 0; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment