summaryrefslogtreecommitdiff
path: root/utils
diff options
context:
space:
mode:
Diffstat (limited to 'utils')
-rw-r--r--utils/gdmopen.c33
1 files changed, 22 insertions, 11 deletions
diff --git a/utils/gdmopen.c b/utils/gdmopen.c
index 00f91b2a..fdc382d5 100644
--- a/utils/gdmopen.c
+++ b/utils/gdmopen.c
@@ -59,7 +59,7 @@ static pid_t child_pid = -1;
struct vt_stat vt;
static int vtno;
static int fd = 0;
-static int do_dealloc = FALSE;
+static int do_switchback = FALSE;
static void
sighandler (int sig)
@@ -69,14 +69,11 @@ sighandler (int sig)
waitpid (child_pid, NULL, 0);
}
- if (do_dealloc) {
+ if (do_switchback) {
/* Switch back... */
(void) ioctl(fd, VT_ACTIVATE, vt.v_active);
/* wait to be really sure we have switched */
(void) ioctl(fd, VT_WAITACTIVE, vt.v_active);
-
- /* Now deallocate our new one */
- (void) ioctl(fd, VT_DISALLOCATE, vtno);
}
/* Kill myself with this signal */
@@ -89,6 +86,8 @@ main (int argc, char *argv[])
{
char vtname[256];
int status;
+ int cmd_start = 1;
+ char *command = NULL;
if (getuid () != geteuid () ||
getuid () != 0) {
@@ -105,6 +104,21 @@ main (int argc, char *argv[])
return 66;
}
+ command = argv[1];
+
+ if (strcmp (argv[1], "-l") == 0) {
+ if (argc <= 2) {
+ fprintf (stderr, "gdmopen: must supply a command!\n");
+ return 66;
+ }
+ /* prepend '-' and start the command at
+ * argument 2 */
+ cmd_start = 2;
+ command = malloc (strlen (argv[2]) + 2);
+ strcpy (command+1, argv[2]);
+ command[0] = '-';
+ }
+
fd = open ("/dev/console", O_WRONLY, 0);
if (fd < 0) {
perror ("gdmopen: Failed to open /dev/console");
@@ -176,7 +190,7 @@ main (int argc, char *argv[])
write (0, "\033(K", 3);
#endif /* __linux__ */
- execvp (argv[1], &argv[1]);
+ execvp (command, &argv[1]);
_exit (66); /* failed */
}
@@ -186,21 +200,18 @@ main (int argc, char *argv[])
return 66;
}
- do_dealloc = TRUE;
+ do_switchback = TRUE;
waitpid (child_pid, &status, 0);
child_pid = -1;
- do_dealloc = FALSE;
+ do_switchback = FALSE;
/* Switch back... */
(void) ioctl(fd, VT_ACTIVATE, vt.v_active);
/* wait to be really sure we have switched */
(void) ioctl(fd, VT_WAITACTIVE, vt.v_active);
- /* Now deallocate our new one */
- (void) ioctl(fd, VT_DISALLOCATE, vtno);
-
close (fd);
if (WIFEXITED (status))