Linux: consolidate chown implementation
[glibc.git] / elf / tst-auditmod23.c
blobd7c60d7a5cbc4f8ae20100de32b99a72b494239f
1 /* Audit module loaded by tst-audit23.
2 Copyright (C) 2022 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <https://www.gnu.org/licenses/>. */
19 #include <link.h>
20 #include <inttypes.h>
21 #include <stdlib.h>
22 #include <stdio.h>
23 #include <string.h>
24 #include <sys/auxv.h>
26 unsigned int
27 la_version (unsigned int version)
29 return LAV_CURRENT;
32 struct map_desc_t
34 char *lname;
35 uintptr_t laddr;
36 Lmid_t lmid;
39 void
40 la_activity (uintptr_t *cookie, unsigned int flag)
42 fprintf (stderr, "%s: %d %"PRIxPTR"\n", __func__, flag, (uintptr_t) cookie);
45 unsigned int
46 la_objopen (struct link_map *map, Lmid_t lmid, uintptr_t *cookie)
48 const char *l_name = map->l_name[0] == '\0' ? "mainapp" : map->l_name;
49 fprintf (stderr, "%s: %"PRIxPTR" %s %"PRIxPTR" %ld\n", __func__,
50 (uintptr_t) cookie, l_name, map->l_addr, lmid);
52 struct map_desc_t *map_desc = malloc (sizeof (struct map_desc_t));
53 if (map_desc == NULL)
54 abort ();
56 map_desc->lname = strdup (l_name);
57 map_desc->laddr = map->l_addr;
58 map_desc->lmid = lmid;
60 *cookie = (uintptr_t) map_desc;
62 return 0;
65 unsigned int
66 la_objclose (uintptr_t *cookie)
68 struct map_desc_t *map_desc = (struct map_desc_t *) *cookie;
69 fprintf (stderr, "%s: %"PRIxPTR" %s %"PRIxPTR" %ld\n", __func__,
70 (uintptr_t) cookie, map_desc->lname, map_desc->laddr,
71 map_desc->lmid);
73 return 0;