aboutsummaryrefslogtreecommitdiffstats
path: root/src/tools
diff options
context:
space:
mode:
authorLibravatar netblue30 <netblue30@yahoo.com>2018-04-08 19:07:27 -0400
committerLibravatar netblue30 <netblue30@yahoo.com>2018-04-08 19:07:27 -0400
commitf8b64047f834095284fc3d3bdf73be089bb86fa6 (patch)
tree49d37e4b002760a5923e4eb764ea1335e880fa09 /src/tools
parenttypo (diff)
downloadfirejail-f8b64047f834095284fc3d3bdf73be089bb86fa6.tar.gz
firejail-f8b64047f834095284fc3d3bdf73be089bb86fa6.tar.zst
firejail-f8b64047f834095284fc3d3bdf73be089bb86fa6.zip
uid test utility
Diffstat (limited to 'src/tools')
-rw-r--r--src/tools/testuid.c49
1 files changed, 49 insertions, 0 deletions
diff --git a/src/tools/testuid.c b/src/tools/testuid.c
new file mode 100644
index 000000000..633b9773e
--- /dev/null
+++ b/src/tools/testuid.c
@@ -0,0 +1,49 @@
1/*
2 * Copyright (C) 2014-2018 Firejail Authors
3 *
4 * This file is part of firejail project
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 along
17 * with this program; if not, write to the Free Software Foundation, Inc.,
18 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19*/
20
21// compile: gcc -o testuid testuid.c
22
23#include <stdio.h>
24#include <stdlib.h>
25#include <string.h>
26#include <unistd.h>
27#include <sys/types.h>
28
29
30static void print_status(void) {
31 FILE *fp = fopen("/proc/self/status", "r");
32 if (!fp) {
33 fprintf(stderr, "Error, cannot open staus file\n");
34 exit(1);
35 }
36
37 char buf[4096];
38 while (fgets(buf, 4096, fp)) {
39 if (strncmp(buf, "Uid", 3) == 0 || strncmp(buf, "Gid", 3) == 0)
40 printf("%s", buf);
41 }
42
43 fclose(fp);
44}
45
46int main(void) {
47 print_status();
48 return 0;
49}