Debian Codegraph @

src/no_new_privs.c

raw symbols SCIP
1 /*
2 * Copyright (C) 2025 Thomas Habets <[email protected]>
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License along
15 * with this program; if not, write to the Free Software Foundation, Inc.,
16 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
17 */
18 #define _GNU_SOURCE
19 #if HAVE_CONFIG_H
20 #include "config.h"
21 #endif
22
23 #include <stdio.h>
24 #include <string.h>
25 #include <errno.h>
26
27 #if HAVE_LINUX_PRCTL_H
28 #include <linux/prctl.h> /* Definition of PR_* constants */
29 #endif
30 #if HAVE_SYS_PRCTL_H
31 #include <sys/prctl.h>
32 #endif
33
34 #include "arping.h"
35
36 void
37 drop_no_new_privs()
38 {
39 #ifdef HAS_NO_NEW_PRIVS
40 if (prctl(PR_SET_NO_NEW_PRIVS, 1L, 0L, 0L, 0L)) {
41 fprintf(stderr, "arping: setting NO_NEW_PRIVS failed: %s\n",
42 strerror(errno));
43 }
44 if (verbose > 2) {
45 printf("arping: Prevented new privs being set\n");
46 }
47 #endif
48 }