Last active
February 22, 2020 10:24
-
-
Save pdlan/4586643c78189d64ad390731a7fe7156 to your computer and use it in GitHub Desktop.
LightDM with VNC (NOT INETD)
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
| [Seat:*] | |
| xserver-command=/etc/vlab/vncserver-lightdm | |
| greeter-hide-users=false | |
| greeter-setup-script=/etc/vlab/setup.sh | |
| #allow-user-switching=true |
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
| #!/bin/sh | |
| vncconfig -nowin & |
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
| #include <time.h> | |
| #include <string.h> | |
| #include <unistd.h> | |
| #include <signal.h> | |
| #include <sys/types.h> | |
| #include <sys/wait.h> | |
| pid_t xvnc_pid; | |
| volatile sig_atomic_t done = 0; | |
| void term(int signum) { | |
| kill(xvnc_pid, SIGTERM); | |
| wait(NULL); | |
| done = 1; | |
| } | |
| int main(int argc, char **argv) { | |
| const char *display = ":0"; | |
| if (argc >= 2) { | |
| display = argv[1]; | |
| } | |
| pid_t lightdm_pid = getppid(); | |
| pid_t pid = fork(); | |
| char auth[32] = "/var/run/lightdm/root/"; | |
| strcat(auth, display); | |
| if (pid == 0) { | |
| execl( | |
| "/usr/bin/Xvnc", | |
| "/usr/bin/Xvnc", | |
| display, | |
| "-rfbport", | |
| "5900", | |
| "-seat", | |
| "seat0", | |
| "-SecurityTypes", | |
| "None", | |
| "-auth", | |
| auth, | |
| NULL | |
| ); | |
| } | |
| xvnc_pid = pid; | |
| struct sigaction action; | |
| memset(&action, 0, sizeof(struct sigaction)); | |
| action.sa_handler = term; | |
| sigaction(SIGTERM, &action, NULL); | |
| sleep(2); | |
| kill(lightdm_pid, SIGUSR1); | |
| wait(NULL); | |
| return 0; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment