aboutsummaryrefslogtreecommitdiffstats
path: root/main/apk-tools/0001-db-prevent-umount-proc-when-it-was-mounted-by-someon.patch
blob: cbb220e979bcaa811435add59955e84afeb788f3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
From 4b9f6d430f04e4470cf5d49ee72a43ebaed0fb62 Mon Sep 17 00:00:00 2001
From: Natanael Copa <ncopa@alpinelinux.org>
Date: Mon, 13 Mar 2017 12:54:39 +0000
Subject: [PATCH 1/2] db: prevent umount /proc when it was mounted by someone
 else

This fixes regression introduced by commit 72b878e655
---
 src/database.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/src/database.c b/src/database.c
index e3ced7d..356907e 100644
--- a/src/database.c
+++ b/src/database.c
@@ -1581,8 +1581,13 @@ int apk_db_open(struct apk_database *db, struct apk_db_options *dbopts)
 			if (errno == ENOENT) mkdir(db->root_proc_dir, 0555);
 			stfs.f_type = 0;
 		}
-		if (stfs.f_type != PROC_SUPER_MAGIC)
+		if (stfs.f_type != PROC_SUPER_MAGIC) {
 			mount("proc", db->root_proc_dir, "proc", 0, 0);
+		} else {
+			/* was already mounted. prevent umount on close */
+			free(db->root_proc_dir);
+			db->root_proc_dir = NULL;
+		}
 	}
 
 	blob = APK_BLOB_STR("+etc\n" "@etc/init.d\n" "!etc/apk\n");
-- 
2.11.1