| 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_SOURCEcxx . . $ `src/no_new_privs.c:18:9`! |
| 19 | #if HAVE_CONFIG_Hcxx . . $ `<built-in>:411:9`! |
| 20 | #include "config.h"cxx . . $ `<file>/config.h`/ |
| 21 | #endif |
| 22 | |
| 23 | #include <stdio.h> |
| 24 | #include <string.h> |
| 25 | #include <errno.h> |
| 26 | |
| 27 | #if HAVE_LINUX_PRCTL_Hcxx . . $ `config.h:83:9`! |
| 28 | #include <linux/prctl.h> /* Definition of PR_* constants */ |
| 29 | #endif |
| 30 | #if HAVE_SYS_PRCTL_Hcxx . . $ `config.h:158:9`! |
| 31 | #include <sys/prctl.h> |
| 32 | #endif |
| 33 | |
| 34 | #include "arping.h"cxx . . $ `<file>/src/arping.h`/ |
| 35 | |
| 36 | void |
| 37 | drop_no_new_privscxx . . $ drop_no_new_privs(d878ad36e69247c7).() |
| 38 | { |
| 39 | #ifdef HAS_NO_NEW_PRIVScxx . . $ `config.h:17:9`! |
| 40 | if (prctlcxx . . $ prctl(e5daca538bd362ba).(PR_SET_NO_NEW_PRIVScxx . . $ `<external>/9872755456582759113/prctl.h:175:9`!, 1L, 0L, 0L, 0L)) { |
| 41 | fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:159:9`!, "arping: setting NO_NEW_PRIVS failed: %s\n", |
| 42 | strerrorcxx . . $ strerror(ff224f080444ee45).(errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`!)); |
| 43 | } |
| 44 | if (verbosecxx . . $ verbose. > 2) { |
| 45 | printfcxx . . $ printf(581fddd72a8db8fc).("arping: Prevented new privs being set\n"); |
| 46 | } |
| 47 | #endif |
| 48 | } |