tls: in AES-GCM decoding, avoid memmove
[oweals/busybox.git] / util-linux / switch_root.c
index 16abcb634fe60d92670a3961acde603a7ebd036e..947dd0cdc15e95ac9d98a7db53f5807d3687af7d 100644 (file)
@@ -1,5 +1,6 @@
 /* vi: set sw=4 ts=4: */
-/* Copyright 2005 Rob Landley <rob@landley.net>
+/*
+ * Copyright 2005 Rob Landley <rob@landley.net>
  *
  * Switch from rootfs to another filesystem as the root of the mount tree.
  *
 #include <sys/mount.h>
 #if ENABLE_RUN_INIT
 # include <sys/prctl.h>
+# ifndef PR_CAPBSET_READ
+# define PR_CAPBSET_READ 23
+# endif
+# ifndef PR_CAPBSET_DROP
+# define PR_CAPBSET_DROP 24
+# endif
 # include <linux/capability.h>
 // #include <sys/capability.h>
 // This header is in libcap, but the functions are in libc.
@@ -227,9 +234,12 @@ int switch_root_main(int argc UNUSED_PARAM, char **argv)
        xstat("/", &st);
        rootdev = st.st_dev;
        xstat(".", &st);
-       if (st.st_dev == rootdev || getpid() != 1) {
+       if (st.st_dev == rootdev) {
                // Show usage, it says new root must be a mountpoint
-               // and we must be PID 1
+               bb_show_usage();
+       }
+       if (!dry_run && getpid() != 1) {
+               // Show usage, it says we must be PID 1
                bb_show_usage();
        }