Deleted Added
full compact
command.c (246804) command.c (248854)
1/*-
2 * Copyright (c) 2011 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>
1/*-
2 * Copyright (c) 2011 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: head/usr.sbin/jail/command.c 246804 2013-02-14 19:27:52Z jamie $");
28__FBSDID("$FreeBSD: head/usr.sbin/jail/command.c 248854 2013-03-28 21:02:49Z jamie $");
29
30#include <sys/types.h>
31#include <sys/event.h>
32#include <sys/mount.h>
33#include <sys/stat.h>
34#include <sys/sysctl.h>
35#include <sys/user.h>
36#include <sys/wait.h>

--- 46 unchanged lines hidden (view full) ---

83
84/*
85 * Run the next command associated with a jail.
86 */
87int
88next_command(struct cfjail *j)
89{
90 enum intparam comparam;
29
30#include <sys/types.h>
31#include <sys/event.h>
32#include <sys/mount.h>
33#include <sys/stat.h>
34#include <sys/sysctl.h>
35#include <sys/user.h>
36#include <sys/wait.h>

--- 46 unchanged lines hidden (view full) ---

83
84/*
85 * Run the next command associated with a jail.
86 */
87int
88next_command(struct cfjail *j)
89{
90 enum intparam comparam;
91 int create_failed;
91 int create_failed, stopping;
92
93 if (paralimit == 0) {
94 requeue(j, &runnable);
95 return 1;
96 }
97 create_failed = (j->flags & (JF_STOP | JF_FAILED)) == JF_FAILED;
92
93 if (paralimit == 0) {
94 requeue(j, &runnable);
95 return 1;
96 }
97 create_failed = (j->flags & (JF_STOP | JF_FAILED)) == JF_FAILED;
98 stopping = (j->flags & JF_STOP) != 0;
98 comparam = *j->comparam;
99 for (;;) {
100 if (j->comstring == NULL) {
101 j->comparam += create_failed ? -1 : 1;
102 switch ((comparam = *j->comparam)) {
103 case IP__NULL:
104 return 0;
105 case IP_MOUNT_DEVFS:
106 if (!bool_param(j->intparams[IP_MOUNT_DEVFS]))
107 continue;
108 /* FALLTHROUGH */
109 case IP__OP:
110 case IP_STOP_TIMEOUT:
111 j->comstring = &dummystring;
112 break;
113 default:
114 if (j->intparams[comparam] == NULL)
115 continue;
99 comparam = *j->comparam;
100 for (;;) {
101 if (j->comstring == NULL) {
102 j->comparam += create_failed ? -1 : 1;
103 switch ((comparam = *j->comparam)) {
104 case IP__NULL:
105 return 0;
106 case IP_MOUNT_DEVFS:
107 if (!bool_param(j->intparams[IP_MOUNT_DEVFS]))
108 continue;
109 /* FALLTHROUGH */
110 case IP__OP:
111 case IP_STOP_TIMEOUT:
112 j->comstring = &dummystring;
113 break;
114 default:
115 if (j->intparams[comparam] == NULL)
116 continue;
116 j->comstring = create_failed
117 j->comstring = create_failed || (stopping &&
118 (j->intparams[comparam]->flags & PF_REV))
117 ? TAILQ_LAST(&j->intparams[comparam]->val,
118 cfstrings)
119 : TAILQ_FIRST(&j->intparams[comparam]->val);
120 }
121 } else {
122 j->comstring = j->comstring == &dummystring ? NULL :
119 ? TAILQ_LAST(&j->intparams[comparam]->val,
120 cfstrings)
121 : TAILQ_FIRST(&j->intparams[comparam]->val);
122 }
123 } else {
124 j->comstring = j->comstring == &dummystring ? NULL :
123 create_failed
125 create_failed || (stopping &&
126 (j->intparams[comparam]->flags & PF_REV))
124 ? TAILQ_PREV(j->comstring, cfstrings, tq)
125 : TAILQ_NEXT(j->comstring, tq);
126 }
127 if (j->comstring == NULL || j->comstring->len == 0 ||
128 (create_failed && (comparam == IP_EXEC_PRESTART ||
129 comparam == IP_EXEC_START || comparam == IP_COMMAND ||
130 comparam == IP_EXEC_POSTSTART)))
131 continue;

--- 732 unchanged lines hidden ---
127 ? TAILQ_PREV(j->comstring, cfstrings, tq)
128 : TAILQ_NEXT(j->comstring, tq);
129 }
130 if (j->comstring == NULL || j->comstring->len == 0 ||
131 (create_failed && (comparam == IP_EXEC_PRESTART ||
132 comparam == IP_EXEC_START || comparam == IP_COMMAND ||
133 comparam == IP_EXEC_POSTSTART)))
134 continue;

--- 732 unchanged lines hidden ---