Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions debian/changelog
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
debianutils (5.20-0deepin1) unstable; urgency=medium

* fix ischroot failed in unshare environment

-- WangZhaohui <wangzhaohui@uniontech.com> Fri, 14 Mar 2025 12:27:48 +0800

debianutils (5.20) unstable; urgency=medium

[ WHR ]
Expand Down
44 changes: 44 additions & 0 deletions debian/patches/0001-fix-ischroot-failed-in-unshare.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
Index: debianutils/ischroot.c
===================================================================
--- debianutils.orig/ischroot.c
+++ debianutils/ischroot.c
@@ -16,6 +16,7 @@
#include <sys/types.h>
#include <fcntl.h>
#include <unistd.h>
+#include <errno.h>
#ifdef HAVE_GETOPT_H
#include <getopt.h>
#endif /* HAVE_GETOPT_H */
@@ -135,13 +136,13 @@ static int ischroot()
struct stat st1, st2;
int ret;

- ret = ischroot_mountinfo();
- if (ret >= 0)
- return ret;
-
if (stat("/", &st1))
return 2;
if (stat("/proc/1/root", &st2)) {
+ /* If we get permission denied, try checking mountinfo instead,
+ * which can resolve mountinfo inconsistency issues in unshare environments */
+ if (errno == EACCES)
+ goto check_mountinfo;
/* Does /proc/1/root exist at all? */
if (lstat("/proc/1/root" , &st2))
return 2;
@@ -154,6 +155,13 @@ static int ischroot()
return 1;
else
return 0;
+
+check_mountinfo:
+ ret = ischroot_mountinfo();
+ if (ret >= 0)
+ return ret;
+
+ return 0;
}

#elif defined (__FreeBSD_kernel__) || defined (__FreeBSD__)
1 change: 1 addition & 0 deletions debian/patches/series
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
0001-fix-ischroot-failed-in-unshare.patch
2 changes: 1 addition & 1 deletion debian/source/format
Original file line number Diff line number Diff line change
@@ -1 +1 @@
3.0 (native)
3.0 (quilt)
Loading