Deleted Added
full compact
hooks.c (219816) hooks.c (219817)
1/*-
2 * Copyright (c) 2010 The FreeBSD Foundation
3 * Copyright (c) 2010 Pawel Jakub Dawidek <pjd@FreeBSD.org>
4 * All rights reserved.
5 *
6 * This software was developed by Pawel Jakub Dawidek under sponsorship from
7 * the FreeBSD Foundation.
8 *

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

24 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
25 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
26 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
27 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
28 * SUCH DAMAGE.
29 */
30
31#include <sys/cdefs.h>
1/*-
2 * Copyright (c) 2010 The FreeBSD Foundation
3 * Copyright (c) 2010 Pawel Jakub Dawidek <pjd@FreeBSD.org>
4 * All rights reserved.
5 *
6 * This software was developed by Pawel Jakub Dawidek under sponsorship from
7 * the FreeBSD Foundation.
8 *

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

24 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
25 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
26 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
27 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
28 * SUCH DAMAGE.
29 */
30
31#include <sys/cdefs.h>
32__FBSDID("$FreeBSD: head/sbin/hastd/hooks.c 219816 2011-03-21 08:37:50Z pjd $");
32__FBSDID("$FreeBSD: head/sbin/hastd/hooks.c 219817 2011-03-21 08:38:24Z pjd $");
33
34#include <sys/types.h>
35#include <sys/sysctl.h>
36#include <sys/wait.h>
37
38#include <assert.h>
39#include <errno.h>
40#include <fcntl.h>

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

283void
284hook_check(void)
285{
286 struct hookproc *hp, *hp2;
287 time_t now;
288
289 assert(hooks_initialized);
290
33
34#include <sys/types.h>
35#include <sys/sysctl.h>
36#include <sys/wait.h>
37
38#include <assert.h>
39#include <errno.h>
40#include <fcntl.h>

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

283void
284hook_check(void)
285{
286 struct hookproc *hp, *hp2;
287 time_t now;
288
289 assert(hooks_initialized);
290
291 pjdlog_debug(1, "Checking hooks.");
292
291 /*
292 * Report about processes that are running for a long time.
293 */
294 now = time(NULL);
295 mtx_lock(&hookprocs_lock);
296 TAILQ_FOREACH_SAFE(hp, &hookprocs, hp_next, hp2) {
297 assert(hp->hp_magic == HOOKPROC_MAGIC_ONLIST);
298 assert(hp->hp_pid > 0);

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

358 break;
359 }
360 assert(ii < sizeof(args) / sizeof(args[0]));
361
362 hp = hook_alloc(path, args);
363 if (hp == NULL)
364 return;
365
293 /*
294 * Report about processes that are running for a long time.
295 */
296 now = time(NULL);
297 mtx_lock(&hookprocs_lock);
298 TAILQ_FOREACH_SAFE(hp, &hookprocs, hp_next, hp2) {
299 assert(hp->hp_magic == HOOKPROC_MAGIC_ONLIST);
300 assert(hp->hp_pid > 0);

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

360 break;
361 }
362 assert(ii < sizeof(args) / sizeof(args[0]));
363
364 hp = hook_alloc(path, args);
365 if (hp == NULL)
366 return;
367
368 pjdlog_debug(1, "Executing hook: %s", hp->hp_comm);
369
366 pid = fork();
367 switch (pid) {
368 case -1: /* Error. */
369 pjdlog_errno(LOG_ERR, "Unable to fork to execute %s", path);
370 hook_free(hp);
371 return;
372 case 0: /* Child. */
373 descriptors();

--- 15 unchanged lines hidden ---
370 pid = fork();
371 switch (pid) {
372 case -1: /* Error. */
373 pjdlog_errno(LOG_ERR, "Unable to fork to execute %s", path);
374 hook_free(hp);
375 return;
376 case 0: /* Child. */
377 descriptors();

--- 15 unchanged lines hidden ---