1/*-
2 * Copyright (c) 2010 James Gritton
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright
--- 11 unchanged lines hidden (view full) ---
20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24 * SUCH DAMAGE.
25 */
26
27#include <sys/cdefs.h>
28__FBSDID("$FreeBSD: projects/jailconf/usr.sbin/jail/command.c 214117 2010-10-20 20:42:33Z jamie $");
29
30#include <sys/types.h>
31#include <sys/event.h>
32#include <sys/stat.h>
33#include <sys/sysctl.h>
34#include <sys/user.h>
35#include <sys/wait.h>
36
--- 147 unchanged lines hidden (view full) ---
184 *(const char **)&argv[0] = _PATH_IFCONFIG;
185 argv[1] = comstring->s;
186 *(const char **)&argv[2] = down ? "-vnet" : "vnet";
187 jidstr = string_param(j->intparams[KP_JID]);
188 *(const char **)&argv[3] =
189 jidstr ? jidstr : string_param(j->intparams[KP_NAME]);
190 argv[4] = NULL;
191 j->flags |= JF_IFUP;
192 } else if (comparam == IP_MOUNT) {
193 argv = alloca(8 * sizeof(char *));
194 comcs = alloca(comstring->len + 1);
195 strcpy(comcs, comstring->s);
196 argc = 0;
197 for (cs = strtok(comcs, " \t\f\v\r\n"); cs && argc < 4;
198 cs = strtok(NULL, " \t\f\v\r\n"))
199 argv[argc++] = cs;
200 if (argc < 3) {
201 jail_warnx(j, "mount: %s: missing information",
202 comstring->s);
203 failed(j);
204 return -1;
205 }
206 if (down) {
207 argv[4] = NULL;
208 argv[3] = argv[1];
209 *(const char **)&argv[0] = "/sbin/umount";
210 } else {
--- 7 unchanged lines hidden (view full) ---
218 argv[5] = NULL;
219 argv[4] = argv[1];
220 argv[3] = argv[0];
221 }
222 *(const char **)&argv[0] = _PATH_MOUNT;
223 }
224 *(const char **)&argv[1] = "-t";
225 j->flags |= JF_MOUNTED;
226 } else if (comparam == IP_MOUNT_FSTAB) {
227 argv = alloca(4 * sizeof(char *));
228 *(const char **)&argv[0] = down ? "/sbin/umount" : _PATH_MOUNT;
229 *(const char **)&argv[1] = "-aF";
230 argv[2] = comstring->s;
231 argv[3] = NULL;
232 j->flags |= JF_MOUNTED;
233 } else if (comparam == IP_MOUNT_DEVFS) {
234 path = string_param(j->intparams[KP_PATH]);
235 if (path == NULL) {
236 jail_warnx(j, "mount.devfs: no path");
237 failed(j);
238 return -1;
239 }
240 if (down) {
--- 435 unchanged lines hidden ---
2 * Copyright (c) 2010 James Gritton
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright
--- 11 unchanged lines hidden (view full) ---
20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24 * SUCH DAMAGE.
25 */
26
27#include <sys/cdefs.h>
28__FBSDID("$FreeBSD: projects/jailconf/usr.sbin/jail/command.c 214117 2010-10-20 20:42:33Z jamie $");
29
30#include <sys/types.h>
31#include <sys/event.h>
32#include <sys/stat.h>
33#include <sys/sysctl.h>
34#include <sys/user.h>
35#include <sys/wait.h>
36
--- 147 unchanged lines hidden (view full) ---
184 *(const char **)&argv[0] = _PATH_IFCONFIG;
185 argv[1] = comstring->s;
186 *(const char **)&argv[2] = down ? "-vnet" : "vnet";
187 jidstr = string_param(j->intparams[KP_JID]);
188 *(const char **)&argv[3] =
189 jidstr ? jidstr : string_param(j->intparams[KP_NAME]);
190 argv[4] = NULL;
191 j->flags |= JF_IFUP;
192 } else if (comparam == IP_MOUNT) {
193 argv = alloca(8 * sizeof(char *));
194 comcs = alloca(comstring->len + 1);
195 strcpy(comcs, comstring->s);
196 argc = 0;
197 for (cs = strtok(comcs, " \t\f\v\r\n"); cs && argc < 4;
198 cs = strtok(NULL, " \t\f\v\r\n"))
199 argv[argc++] = cs;
200 if (argc < 3) {
201 jail_warnx(j, "mount: %s: missing information",
202 comstring->s);
203 failed(j);
204 return -1;
205 }
206 if (down) {
207 argv[4] = NULL;
208 argv[3] = argv[1];
209 *(const char **)&argv[0] = "/sbin/umount";
210 } else {
--- 7 unchanged lines hidden (view full) ---
218 argv[5] = NULL;
219 argv[4] = argv[1];
220 argv[3] = argv[0];
221 }
222 *(const char **)&argv[0] = _PATH_MOUNT;
223 }
224 *(const char **)&argv[1] = "-t";
225 j->flags |= JF_MOUNTED;
226 } else if (comparam == IP_MOUNT_FSTAB) {
227 argv = alloca(4 * sizeof(char *));
228 *(const char **)&argv[0] = down ? "/sbin/umount" : _PATH_MOUNT;
229 *(const char **)&argv[1] = "-aF";
230 argv[2] = comstring->s;
231 argv[3] = NULL;
232 j->flags |= JF_MOUNTED;
233 } else if (comparam == IP_MOUNT_DEVFS) {
234 path = string_param(j->intparams[KP_PATH]);
235 if (path == NULL) {
236 jail_warnx(j, "mount.devfs: no path");
237 failed(j);
238 return -1;
239 }
240 if (down) {
--- 435 unchanged lines hidden ---