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

« back to all changes in this revision

Viewing changes to bin/trampoline/trampoline.c

  • Committer: Matt Giuca
  • Date: 2009-05-26 04:15:23 UTC
  • mto: This revision was merged to the branch mainline in revision 1322.
  • Revision ID: matt.giuca@gmail.com-20090526041523-hsg5q2enlhvjb5y2
doc/man/architecture.rst: User management server.

Show diffs side-by-side

added added

removed removed

Lines of Context:
121
121
static void usage(const char* nm)
122
122
{
123
123
    fprintf(stderr,
124
 
        "usage: %s [-d] [-u] <uid> <jail> <cwd> <program> [args...]\n", nm);
 
124
        "usage: %s [-d] [-u] <uid> <base> <src> <system> <jail> <cwd> <program> [args...]\n", nm);
125
125
    exit(1);
126
126
}
127
127
 
138
138
}
139
139
 
140
140
/* Find the path of the user components of a jail, given a mountpoint. */
141
 
char *jail_src(const char* jailpath)
 
141
char *jail_src(const char *jail_src_base, const char *jail_base,
 
142
               const char *jailpath)
142
143
{
143
144
    char* src;
144
145
    int srclen;
157
158
/* Check for the validity of a jail in the given path, mounting it if it looks
158
159
 * empty.
159
160
 * TODO: Updating /etc/mtab would be nice. */
160
 
void mount_if_needed(const char* jailpath)
 
161
void mount_if_needed(const char *jail_src_base, const char *jail_base,
 
162
                     const char *jail_system, const char *jailpath)
161
163
{
162
164
    char *jailsrc;
163
165
    char *jaillib;
182
184
             syslog(LOG_NOTICE, "created mountpoint %s\n", jailpath);
183
185
        }
184
186
       
185
 
        jailsrc = jail_src(jailpath);
 
187
        jailsrc = jail_src(jail_src_base, jail_base, jailpath);
186
188
        mountdata = die_if_null(malloc(3 + strlen(jailsrc) + 4 + strlen(jail_system) + 3 + 1));
187
189
        sprintf(mountdata, "br:%s=rw:%s=ro", jailsrc, jail_system);
188
190
        if (mount("none", jailpath, "aufs", 0, mountdata))
217
219
 
218
220
int main(int argc, char* const argv[])
219
221
{
 
222
    char* jail_base;
 
223
    char* jail_src_base;
 
224
    char* jail_system;
220
225
    char* jailpath;
221
226
    char* work_dir;
222
227
    char* prog;
260
265
        arg_num++;
261
266
    }
262
267
    uid = atoi(argv[arg_num++]);
 
268
    jail_base = argv[arg_num++];
 
269
    jail_src_base = argv[arg_num++];
 
270
    jail_system = argv[arg_num++];
263
271
    jailpath = argv[arg_num++];
264
272
    work_dir = argv[arg_num++];
265
273
    prog = argv[arg_num];
289
297
    openlog("trampoline", LOG_CONS | LOG_PID | LOG_NDELAY, LOG_USER);
290
298
 
291
299
    #ifdef IVLE_AUFS_JAILS
292
 
    mount_if_needed(canonical_jailpath);
 
300
    mount_if_needed(jail_src_base, jail_base, jail_system, canonical_jailpath);
293
301
    #endif /* IVLE_AUFS_JAILS */
294
302
 
295
303
    /* chroot into the jail.