Permalink
Browse files

Force success when changing the root directory to "/" when -0 is spec…

…ified.

This should make pacman (the Arch Linux package manager) happy when
installing package in the current rootfs, i.e. "/".
  • Loading branch information...
1 parent 3a6f6f9 commit a48186473565c0780c9027f0cbb64d00f0f8918c @cedric-vincent cedric-vincent committed Apr 20, 2012
Showing with 51 additions and 7 deletions.
  1. +5 −3 doc/manual.txt
  2. +0 −2 doc/roadmap.txt
  3. +42 −0 src/syscall/exit.c
  4. +1 −1 tests/test-1cd9d8f9.sh
  5. +3 −1 tests/test-82ba4ba1.sh
View
@@ -125,14 +125,16 @@ Regular options
does not improve the compatibility.
-0, --root-id
- Force syscalls ``chown*`` and ``get*id`` to return 0, aka "root".
+ Force some syscalls to behave as if executed by "root".
Some programs will refuse to work if they are not run with "root"
privileges, even if there is no technical reason for that. This
is typically the case with package managers. This option allows
users to bypass this kind of limitation by faking the user/group
- identity, and by faking the success of any ownership change. Note
- that this option is quite limited compared to ``fakeroot``.
+ identity, and by faking the success of some operations like
+ changing the ownership of files, changing the root directory to
+ ``/``, ... Note that this option is quite limited compared to
+ ``fakeroot``.
-v, --verbose
Increase the level of debug information.
View
@@ -51,8 +51,6 @@ Next major
* Allow one root per tracee, then add support for the chroot syscall
under PRoot.
- It should make pacman (the Arch Linux package manager) happy.
-
Not yet scheduled
=================
View
@@ -269,6 +269,48 @@ case PR_uname: {
}
break;
+case PR_chroot: {
+ char path[PATH_MAX];
+ word_t input;
+
+ if (!config.fake_id0) {
+ status = 0;
+ goto end;
+ }
+
+ result = peek_ureg(tracee, SYSARG_RESULT);
+ if (errno != 0) {
+ status = -errno;
+ goto end;
+ }
+
+ /* Override only permission errors. */
+ if ((int) result != -EPERM) {
+ status = 0;
+ goto end;
+ }
+
+ input = peek_ureg(tracee, SYSARG_1);
+ if (errno != 0) {
+ status = -errno;
+ goto end;
+ }
+
+ status = get_tracee_string(tracee, path, input, PATH_MAX);
+ if (status < 0)
+ goto end;
+
+ /* Succeed only if the new rootfs == current rootfs. */
+ status = compare_paths2(root, root_length, path, strlen(path));
+ if (status != PATHS_ARE_EQUAL) {
+ status = 0;
+ goto end;
+ }
+
+ status = 0;
+}
+ break;
+
case PR_chown:
case PR_fchown:
case PR_lchown:
View
@@ -1,4 +1,4 @@
-if ! /usr/bin/pwd -P || [ -z 'which grep' ] ; then
+if ! /usr/bin/pwd -P || [ -z `which grep` ] ; then
exit 125;
fi
View
@@ -1,7 +1,9 @@
-if [ -z 'which grep' ]; then
+if [ -z `which id` ] || [ -z `which grep` ] || [ -z `which chown` ] || [ -z `which chroot` ] || [ ! /bin/true ] ; then
exit 125;
fi
${PROOT} -0 / id -u | grep ^0$
${PROOT} -0 / id -g | grep ^0$
${PROOT} -0 / chown root.root /root
+${PROOT} -0 / chroot / /bin/true
+${PROOT} -0 / chroot /tmp/.. /bin/true

0 comments on commit a481864

Please sign in to comment.