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

« back to all changes in this revision

Viewing changes to trampoline/trampoline.c

  • Committer: mattgiuca
  • Date: 2008-01-25 01:05:22 UTC
  • Revision ID: svn-v3-trunk0:2b9c9e99-6f39-0410-b283-7f802c844ae2:trunk:300
conf/apps: Added TutorialService as a registered app.
tutorialservice: Started writing app. Currently reads some arguments, and if
    action=test and code is provided, echoes the code back in JSON.

Show diffs side-by-side

added added

removed removed

Lines of Context:
37
37
#include <stdlib.h>
38
38
#include <string.h>
39
39
#include <unistd.h>
40
 
#include <sys/types.h>
41
 
#include <sys/stat.h>
42
 
#include <limits.h>
43
40
 
44
41
/* conf.h is admin-configured by the setup process.
45
42
 * It defines jail_base.
125
122
    int uid;
126
123
    int arg_num = 1;
127
124
    int daemon_mode = 0;
128
 
    char canonical_jailpath[PATH_MAX];
129
125
 
130
126
    /* Disallow execution from all users but the whitelisted ones, and root */
131
127
    if (!uid_allowed(getuid()))
162
158
        exit(1);
163
159
    }
164
160
 
165
 
    /* Jail path must be an absolute path,
166
 
     * and it must begin with jail_base.
 
161
    /* Jail path must:
 
162
     * Be non-empty
 
163
     * Start with a '/'
 
164
     * Not contain "/.."
 
165
     * Begin with jail_base
167
166
     */
168
 
    if (norm(canonical_jailpath, PATH_MAX, jailpath) != 0)
169
 
    {
170
 
        fprintf(stderr, "bad jail path: %s\n", jailpath);
171
 
        exit(1);
172
 
    }
173
 
    if (strncmp(canonical_jailpath, jail_base, strlen(jail_base)))
 
167
    if (strlen(jailpath) < 1 || jailpath[0] != '/'
 
168
            || strstr(jailpath, "/..")
 
169
            || strncmp(jailpath, jail_base, strlen(jail_base)))
174
170
    {
175
171
        fprintf(stderr, "bad jail path: %s\n", jailpath);
176
172
        exit(1);
178
174
 
179
175
    /* chroot into the jail.
180
176
     * Henceforth this process, and its children, cannot see anything above
181
 
     * canoncial_jailpath. */
182
 
    if (chroot(canonical_jailpath))
 
177
     * jailpath. */
 
178
    if (chroot(jailpath))
183
179
    {
184
180
        perror("could not chroot");
185
181
        exit(1);