140
int checked_mount(const char *source, const char *target,
141
const char *filesystemtype, unsigned long mountflags,
144
int result = mount(source, target, filesystemtype, mountflags, data);
147
syslog(LOG_ERR, "could not mount %s on %s\n", source, target);
148
perror("could not mount");
140
156
/* Find the path of the user components of a jail, given a mountpoint. */
141
157
char *jail_src(const char *jail_src_base, const char *jail_base,
142
158
const char *jailpath)
148
164
srclen = strlen(jail_src_base);
149
165
dstlen = strlen(jail_base);
151
167
src = die_if_null(malloc(strlen(jailpath) + (srclen - dstlen) + 1));
152
168
strcpy(src, jail_src_base);
153
169
strcat(src, jailpath+dstlen);
184
201
syslog(LOG_NOTICE, "created mountpoint %s\n", jailpath);
187
204
jailsrc = jail_src(jail_src_base, jail_base, jailpath);
188
mountdata = die_if_null(malloc(3 + strlen(jailsrc) + 4 + strlen(jail_system) + 3 + 1));
189
sprintf(mountdata, "br:%s=rw:%s=ro", jailsrc, jail_system);
190
if (mount("none", jailpath, "aufs", 0, mountdata))
192
syslog(LOG_ERR, "could not mount %s\n", jailpath);
193
perror("could not mount");
205
checked_mount(jail_system, jailpath, NULL, MS_BIND | MS_RDONLY, NULL);
207
source_bits = die_if_null(malloc(strlen(jailsrc) + 5 + 1));
208
target_bits = die_if_null(malloc(strlen(jailpath) + 5 + 1));
209
sprintf(source_bits, "%s/home", jailsrc);
210
sprintf(target_bits, "%s/home", jailpath);
212
checked_mount(source_bits, target_bits, NULL, MS_BIND, NULL);
214
sprintf(source_bits, "%s/tmp", jailsrc);
215
sprintf(target_bits, "%s/tmp", jailpath);
217
checked_mount(source_bits, target_bits, NULL, MS_BIND, NULL);
197
219
syslog(LOG_INFO, "mounted %s\n", jailpath);
340
363
/* Process adress space in memory */
341
l.rlim_cur = 192 * 1024 * 1024; /* 192MiB */
342
l.rlim_max = 256 * 1024 * 1024; /* 256MiB */
364
l.rlim_cur = 448 * 1024 * 1024; /* 512MiB - 64MiB */
365
l.rlim_max = 512 * 1024 * 1024; /* 512MiB */
343
366
if (setrlimit(RLIMIT_AS, &l))
345
368
perror("could not setrlimit/RLIMIT_AS");
350
373
* Note: This requires a kernel patch to work correctly otherwise it is
351
374
* ineffective (thus you are only limited by RLIMIT_AS)
353
l.rlim_cur = 192 * 1024 * 1024; /* 192MiB */
354
l.rlim_max = 256 * 1024 * 1024; /* 256MiB */
376
l.rlim_cur = 448 * 1024 * 1024; /* 512MiB - 64MiB */
377
l.rlim_max = 512 * 1024 * 1024; /* 512MiB */
355
378
if (setrlimit(RLIMIT_DATA, &l))
357
380
perror("could not setrlimit/RLIMIT_DATA");