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

« back to all changes in this revision

Viewing changes to bin/trampoline/trampoline.c

  • Committer: me at id
  • Date: 2009-01-15 00:37:10 UTC
  • mto: This revision was merged to the branch mainline in revision 1090.
  • Revision ID: svn-v3-trunk0:2b9c9e99-6f39-0410-b283-7f802c844ae2:branches%2Fstorm:1141
ivle.database.User: Add an authenticate() method, and a hash_password()
     staticmethod to replace the auth functions in ivle.db.

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