~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 23:52:19 UTC
  • Revision ID: svn-v3-trunk0:2b9c9e99-6f39-0410-b283-7f802c844ae2:trunk:329
Converted Console from an "app" into a "plugin". It can now be plugged in to
any app.
Added "plugins" directory in www. Added "console" plugin. This contains all of
the functionality of what was previously the console app, but modularized so
it can be imported by another app.

apps/console: Removed most of the logic (moved to plugins/console). Replaced
with a simple import of the console plugin. Should behave exactly the same.
apps/tutorial: As proof of concept, imported the console plugin. It now
appears at the bottom of the page (yet to make it have "pop up" behaviour).

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.
89
88
    /* At this point we are executing as the child process */
90
89
 
91
90
    /* Change the file mode mask */
92
 
    umask(022);
 
91
    umask(0);
93
92
 
94
93
    /* Create a new SID for the child process */
95
94
    sid = setsid();
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);