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

« back to all changes in this revision

Viewing changes to trampoline/trampoline.c

  • Committer: mattgiuca
  • Date: 2008-01-29 02:57:10 UTC
  • Revision ID: svn-v3-trunk0:2b9c9e99-6f39-0410-b283-7f802c844ae2:trunk:322
Added doc/setup - a setup guide specific to our configuration. This is the
result of my successfully configuring IVLE on a production server.

Show diffs side-by-side

added added

removed removed

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