diff --git a/debian/changelog b/debian/changelog index ead1e60..c0cbafa 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,9 @@ +debianutils (5.20-0deepin1) unstable; urgency=medium + + * fix ischroot failed in unshare environment + + -- WangZhaohui Fri, 14 Mar 2025 12:27:48 +0800 + debianutils (5.20) unstable; urgency=medium [ WHR ] diff --git a/debian/patches/0001-fix-ischroot-failed-in-unshare.patch b/debian/patches/0001-fix-ischroot-failed-in-unshare.patch new file mode 100644 index 0000000..9f8a4f5 --- /dev/null +++ b/debian/patches/0001-fix-ischroot-failed-in-unshare.patch @@ -0,0 +1,44 @@ +Index: debianutils/ischroot.c +=================================================================== +--- debianutils.orig/ischroot.c ++++ debianutils/ischroot.c +@@ -16,6 +16,7 @@ + #include + #include + #include ++#include + #ifdef HAVE_GETOPT_H + #include + #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__) diff --git a/debian/patches/series b/debian/patches/series new file mode 100644 index 0000000..f89cd92 --- /dev/null +++ b/debian/patches/series @@ -0,0 +1 @@ +0001-fix-ischroot-failed-in-unshare.patch diff --git a/debian/source/format b/debian/source/format index 89ae9db..163aaf8 100644 --- a/debian/source/format +++ b/debian/source/format @@ -1 +1 @@ -3.0 (native) +3.0 (quilt)