Deleted Added
full compact
command.c (302408) command.c (302954)
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: stable/11/usr.sbin/jail/command.c 298562 2016-04-25 03:24:48Z jamie $");
28__FBSDID("$FreeBSD: stable/11/usr.sbin/jail/command.c 302954 2016-07-17 14:06:17Z 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>

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

87 */
88int
89next_command(struct cfjail *j)
90{
91 enum intparam comparam;
92 int create_failed, stopping;
93
94 if (paralimit == 0) {
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>

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

87 */
88int
89next_command(struct cfjail *j)
90{
91 enum intparam comparam;
92 int create_failed, stopping;
93
94 if (paralimit == 0) {
95 requeue(j, &runnable);
95 if (j->flags & JF_FROM_RUNQ)
96 requeue_head(j, &runnable);
97 else
98 requeue(j, &runnable);
96 return 1;
97 }
99 return 1;
100 }
101 j->flags &= ~JF_FROM_RUNQ;
98 create_failed = (j->flags & (JF_STOP | JF_FAILED)) == JF_FAILED;
99 stopping = (j->flags & JF_STOP) != 0;
100 comparam = *j->comparam;
101 for (;;) {
102 if (j->comstring == NULL) {
103 j->comparam += create_failed ? -1 : 1;
104 switch ((comparam = *j->comparam)) {
105 case IP__NULL:

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

155}
156
157/*
158 * Check command exit status
159 */
160int
161finish_command(struct cfjail *j)
162{
102 create_failed = (j->flags & (JF_STOP | JF_FAILED)) == JF_FAILED;
103 stopping = (j->flags & JF_STOP) != 0;
104 comparam = *j->comparam;
105 for (;;) {
106 if (j->comstring == NULL) {
107 j->comparam += create_failed ? -1 : 1;
108 switch ((comparam = *j->comparam)) {
109 case IP__NULL:

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

159}
160
161/*
162 * Check command exit status
163 */
164int
165finish_command(struct cfjail *j)
166{
167 struct cfjail *rj;
163 int error;
164
165 if (!(j->flags & JF_SLEEPQ))
166 return 0;
167 j->flags &= ~JF_SLEEPQ;
168 int error;
169
170 if (!(j->flags & JF_SLEEPQ))
171 return 0;
172 j->flags &= ~JF_SLEEPQ;
168 if (*j->comparam == IP_STOP_TIMEOUT)
169 {
173 if (*j->comparam == IP_STOP_TIMEOUT) {
170 j->flags &= ~JF_TIMEOUT;
171 j->pstatus = 0;
172 return 0;
173 }
174 paralimit++;
174 j->flags &= ~JF_TIMEOUT;
175 j->pstatus = 0;
176 return 0;
177 }
178 paralimit++;
175 if (!TAILQ_EMPTY(&runnable))
176 requeue(TAILQ_FIRST(&runnable), &ready);
179 if (!TAILQ_EMPTY(&runnable)) {
180 rj = TAILQ_FIRST(&runnable);
181 rj->flags |= JF_FROM_RUNQ;
182 requeue(rj, &ready);
183 }
177 error = 0;
178 if (j->flags & JF_TIMEOUT) {
179 j->flags &= ~JF_TIMEOUT;
180 if (*j->comparam != IP_STOP_TIMEOUT) {
181 jail_warnx(j, "%s: timed out", j->comline);
182 failed(j);
183 error = -1;
184 } else if (verbose > 0)

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

254 }
255 goto again;
256 }
257 }
258 return NULL;
259}
260
261/*
184 error = 0;
185 if (j->flags & JF_TIMEOUT) {
186 j->flags &= ~JF_TIMEOUT;
187 if (*j->comparam != IP_STOP_TIMEOUT) {
188 jail_warnx(j, "%s: timed out", j->comline);
189 failed(j);
190 error = -1;
191 } else if (verbose > 0)

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

261 }
262 goto again;
263 }
264 }
265 return NULL;
266}
267
268/*
262 * Run a single command for a jail, possible inside the jail.
269 * Run a single command for a jail, possibly inside the jail.
263 */
264static int
265run_command(struct cfjail *j)
266{
267 const struct passwd *pwd;
268 const struct cfstring *comstring, *s;
269 login_cap_t *lcap;
270 const char **argv;

--- 717 unchanged lines hidden ---
270 */
271static int
272run_command(struct cfjail *j)
273{
274 const struct passwd *pwd;
275 const struct cfstring *comstring, *s;
276 login_cap_t *lcap;
277 const char **argv;

--- 717 unchanged lines hidden ---