~azzar1/unity/add-show-desktop-key

95 by mattgiuca
Moved some things out of www into their respective dirs, console and
1
#include <stdio.h>
2
#include <stdlib.h>
3
#include <string.h>
4
#include <unistd.h>
5
6
#include "conf.h"
7
8
int main(int argc, char* const argv[])
9
{
10
    if (argc < 6)
11
    {
12
        fprintf(stderr, "usage: %s <uid> <jail> <cwd> <interp> <script> [args...]\n", argv[0]);
13
        exit(1);
14
    }
15
16
    if (strlen(argv[2]) < 1 || argv[2][0] != '/'
17
            || strstr(argv[2], "/..")
18
            || strncmp(argv[2], jail_base, strlen(jail_base)))
19
    {
20
        fprintf(stderr, "bad path: %s\n", argv[2]);
21
        exit(1);
22
    }
23
24
    if (chroot(argv[2]))
25
    {
26
        perror("could not chroot");
27
        exit(1);
28
    }
29
30
    if (chdir(argv[3]))
31
    {
32
        perror("could not chdir");
33
        exit(1);
34
    }
35
36
    if (setuid(atoi(argv[1])))
37
    {
38
        perror("could not setuid");
39
        exit(1);
40
    }
41
96 by mattgiuca
Got the trampoline going.
42
    execv(argv[4], argv + 4);
95 by mattgiuca
Moved some things out of www into their respective dirs, console and
43
44
    /* nb exec won't return unless there was an error */
45
    perror("could not exec");
46
    exit(1);
47
}