aboutsummaryrefslogtreecommitdiffstats
path: root/src/firejail/git.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/firejail/git.c')
-rw-r--r--src/firejail/git.c90
1 files changed, 0 insertions, 90 deletions
diff --git a/src/firejail/git.c b/src/firejail/git.c
deleted file mode 100644
index d6525aa89..000000000
--- a/src/firejail/git.c
+++ /dev/null
@@ -1,90 +0,0 @@
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#ifdef HAVE_GIT_INSTALL
22
23#include "firejail.h"
24#include <sys/utsname.h>
25#include <sched.h>
26#include <sys/mount.h>
27
28// install a very simple mount namespace sandbox with a tmpfs on top of /tmp
29// and drop privileges
30static void sbox_ns(void) {
31 if (unshare(CLONE_NEWNS) < 0)
32 errExit("unshare");
33
34 // mount events are not forwarded between the host the sandbox
35 if (mount(NULL, "/", NULL, MS_SLAVE | MS_REC, NULL) < 0) {
36 errExit("mount");
37 }
38
39 // mount a tmpfs on top of /tmp
40 if (mount(NULL, "/tmp", "tmpfs", 0, NULL) < 0)
41 errExit("mount");
42
43
44 // drop privileges
45 if (setgid(getgid()) < 0)
46 errExit("setgid/getgid");
47 if (setuid(getuid()) < 0)
48 errExit("setuid/getuid");
49 assert(getenv("LD_PRELOAD") == NULL);
50
51 printf("Running as "); fflush(0);
52 int rv = system("whoami");
53 (void) rv;
54 printf("/tmp directory: "); fflush(0);
55 rv = system("ls -l /tmp");
56 (void) rv;
57}
58
59
60void git_install(void) {
61 // redirect to "/usr/bin/firejail --noprofile --private-tmp /usr/lib/firejail/fgit-install.sh"
62 EUID_ASSERT();
63 EUID_ROOT();
64
65 // install a mount namespace with a tmpfs on top of /tmp
66 sbox_ns();
67
68 // run command
69 const char *cmd = LIBDIR "/firejail/fgit-install.sh";
70 int rv = system(cmd);
71 (void) rv;
72 exit(0);
73}
74
75void git_uninstall(void) {
76 // redirect to "/usr/bin/firejail --noprofile --private-tmp /usr/lib/firejail/fgit-install.sh"
77 EUID_ASSERT();
78 EUID_ROOT();
79
80 // install a mount namespace with a tmpfs on top of /tmp
81 sbox_ns();
82
83 // run command
84 const char *cmd = LIBDIR "/firejail/fgit-uninstall.sh";
85 int rv = system(cmd);
86 (void) rv;
87 exit(0);
88}
89
90#endif // HAVE_GIT_INSTALL