Deleted Added
sdiff udiff text old ( 302408 ) new ( 302954 )
full compact
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 $");
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);
96 return 1;
97 }
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{
163 int error;
164
165 if (!(j->flags & JF_SLEEPQ))
166 return 0;
167 j->flags &= ~JF_SLEEPQ;
168 if (*j->comparam == IP_STOP_TIMEOUT)
169 {
170 j->flags &= ~JF_TIMEOUT;
171 j->pstatus = 0;
172 return 0;
173 }
174 paralimit++;
175 if (!TAILQ_EMPTY(&runnable))
176 requeue(TAILQ_FIRST(&runnable), &ready);
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/*
262 * Run a single command for a jail, possible 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 ---