Debian Codegraph @

lib/testutil-getpwuid.c

raw
1 /*************************************************************************
2 *
3 * TESTUTIL-GETPWUID.C, Superseded getpwuid function for test purpose
4 * Copyright (C) 2020-2026 Xavier Delaruelle
5 *
6 * This program is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation, either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <http://www.gnu.org/licenses/>.
18 *
19 ************************************************************************/
20
21 #include <stddef.h>
22 #include <pwd.h>
23
24 #if defined (__APPLE__)
25
26 struct passwd *my_getpwuid(uid_t uid)
27 {
28 return NULL;
29 }
30
31 /* Code injection with DYLD interposing */
32 __attribute__((used))
33 static struct {
34 const void *replacement;
35 const void *replacee;
36 } interposers[]
37 __attribute__((section("__DATA,__interpose"))) = {
38 { (const void *)my_getpwuid, (const void *)getpwuid }
39 };
40
41 #else
42
43 struct passwd *getpwuid(uid_t uid)
44 {
45 return NULL;
46 }
47
48 #endif
49
50 /* vim:set tabstop=3 shiftwidth=3 expandtab autoindent: */