public inbox for isar-users@googlegroups.com
 help / color / mirror / Atom feed
* [PATCH 1/2] wic: for pcibios boot plugins and wks files
@ 2018-01-31 15:48 Henning Schild
  2018-01-31 15:48 ` [PATCH 2/2] images: wic: do not call wic with sudo anymore Henning Schild
  0 siblings, 1 reply; 3+ messages in thread
From: Henning Schild @ 2018-01-31 15:48 UTC (permalink / raw)
  To: isar-users; +Cc: Henning Schild

Create a modified version of directdisk.wks that enabled legacy boot
images in Isar. "bootimg-pcbios-isar" expects the rootfs to contain the
packages "syslinux syslinux-common" and will create a disk using this
bootloader.

Signed-off-by: Henning Schild <henning.schild@siemens.com>
---
 .../scripts/lib/wic/canned-wks/common-isar.wks.inc |   3 +
 .../scripts/lib/wic/canned-wks/directdisk-isar.wks |   8 +
 .../lib/wic/plugins/source/bootimg-pcbios-isar.py  | 217 +++++++++++++++++++++
 meta/classes/wic-img.bbclass                       |   5 +-
 4 files changed, 231 insertions(+), 2 deletions(-)
 create mode 100644 meta-isar/scripts/lib/wic/canned-wks/common-isar.wks.inc
 create mode 100644 meta-isar/scripts/lib/wic/canned-wks/directdisk-isar.wks
 create mode 100644 meta-isar/scripts/lib/wic/plugins/source/bootimg-pcbios-isar.py

diff --git a/meta-isar/scripts/lib/wic/canned-wks/common-isar.wks.inc b/meta-isar/scripts/lib/wic/canned-wks/common-isar.wks.inc
new file mode 100644
index 0000000..c8ea4c2
--- /dev/null
+++ b/meta-isar/scripts/lib/wic/canned-wks/common-isar.wks.inc
@@ -0,0 +1,3 @@
+# This file is included into 3 canned wks files from this directory
+part /boot --source bootimg-pcbios-isar --ondisk sda --label boot --active --align 1024
+part / --source rootfs --ondisk sda --fstype=ext4 --label platform --align 1024
diff --git a/meta-isar/scripts/lib/wic/canned-wks/directdisk-isar.wks b/meta-isar/scripts/lib/wic/canned-wks/directdisk-isar.wks
new file mode 100644
index 0000000..bf05baf
--- /dev/null
+++ b/meta-isar/scripts/lib/wic/canned-wks/directdisk-isar.wks
@@ -0,0 +1,8 @@
+# short-description: Create a 'pcbios' direct disk image
+# long-description: Creates a partitioned legacy BIOS disk image that the user
+# can directly dd to boot media.
+
+include common-isar.wks.inc
+
+bootloader  --timeout=0  --append="rootwait rootfstype=ext4 video=vesafb vga=0x318 console=tty0 console=ttyS0,115200n8"
+
diff --git a/meta-isar/scripts/lib/wic/plugins/source/bootimg-pcbios-isar.py b/meta-isar/scripts/lib/wic/plugins/source/bootimg-pcbios-isar.py
new file mode 100644
index 0000000..b2d977e
--- /dev/null
+++ b/meta-isar/scripts/lib/wic/plugins/source/bootimg-pcbios-isar.py
@@ -0,0 +1,217 @@
+# ex:ts=4:sw=4:sts=4:et
+# -*- tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*-
+#
+# Copyright (c) 2014, Intel Corporation.
+# All rights reserved.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License version 2 as
+# published by the Free Software Foundation.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License along
+# with this program; if not, write to the Free Software Foundation, Inc.,
+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# DESCRIPTION
+# This implements the 'bootimg-pcbios-isar' source plugin class for 'wic'
+#
+# AUTHORS
+# Tom Zanussi <tom.zanussi (at] linux.intel.com>
+#
+
+import logging
+import os
+
+from wic import WicError
+from wic.engine import get_custom_config
+from wic.utils import runner
+from wic.pluginbase import SourcePlugin
+from wic.utils.misc import (exec_cmd, exec_native_cmd,
+                            get_bitbake_var, BOOTDD_EXTRA_SPACE)
+
+logger = logging.getLogger('wic')
+
+class BootimgPcbiosIsarPlugin(SourcePlugin):
+    """
+    Create MBR boot partition and install syslinux on it.
+    """
+
+    name = 'bootimg-pcbios-isar'
+
+    @classmethod
+    def _get_syslinux_dir(cls, bootimg_dir):
+        """
+        Get path to syslinux from either default bootimg_dir
+        or wic-tools STAGING_DIR.
+        """
+        for path in (bootimg_dir, get_bitbake_var("STAGING_DATADIR", "wic-tools")):
+            if not path:
+                continue
+            syslinux_dir = os.path.join(path, 'syslinux')
+            if os.path.exists(syslinux_dir):
+                return syslinux_dir
+
+        raise WicError("Couldn't find syslinux directory, exiting")
+
+    @classmethod
+    def do_install_disk(cls, disk, disk_name, creator, workdir, oe_builddir,
+                        bootimg_dir, kernel_dir, native_sysroot):
+        """
+        Called after all partitions have been prepared and assembled into a
+        disk image.  In this case, we install the MBR.
+        """
+        syslinux_dir = cls._get_syslinux_dir(bootimg_dir)
+        if creator.ptable_format == 'msdos':
+            mbrfile = os.path.join(syslinux_dir, "mbr/mbr.bin")
+        elif creator.ptable_format == 'gpt':
+            mbrfile = os.path.join(syslinux_dir, "mbr/gptmbr.bin")
+        else:
+            raise WicError("Unsupported partition table: %s" %
+                           creator.ptable_format)
+
+        if not os.path.exists(mbrfile):
+            raise WicError("Couldn't find %s.  If using the -e option, do you "
+                           "have the right MACHINE set in local.conf?  If not, "
+                           "is the bootimg_dir path correct?" % mbrfile)
+
+        full_path = creator._full_path(workdir, disk_name, "direct")
+        logger.debug("Installing MBR on disk %s as %s with size %s bytes",
+                     disk_name, full_path, disk.min_size)
+
+        rcode = runner.show(['dd', 'if=%s' % mbrfile,
+                             'of=%s' % full_path, 'conv=notrunc'])
+        if rcode != 0:
+            raise WicError("Unable to set MBR to %s" % full_path)
+
+    @classmethod
+    def do_configure_partition(cls, part, source_params, creator, cr_workdir,
+                               oe_builddir, bootimg_dir, kernel_dir,
+                               native_sysroot):
+        """
+        Called before do_prepare_partition(), creates syslinux config
+        """
+        hdddir = "%s/hdd/boot" % cr_workdir
+
+        install_cmd = "install -d %s" % hdddir
+        exec_cmd(install_cmd)
+
+        bootloader = creator.ks.bootloader
+
+        custom_cfg = None
+        if bootloader.configfile:
+            custom_cfg = get_custom_config(bootloader.configfile)
+            if custom_cfg:
+                # Use a custom configuration for grub
+                syslinux_conf = custom_cfg
+                logger.debug("Using custom configuration file %s "
+                             "for syslinux.cfg", bootloader.configfile)
+            else:
+                raise WicError("configfile is specified but failed to "
+                               "get it from %s." % bootloader.configfile)
+
+        if not custom_cfg:
+            # Create syslinux configuration using parameters from wks file
+            splash = os.path.join(cr_workdir, "/hdd/boot/splash.jpg")
+            if os.path.exists(splash):
+                splashline = "menu background splash.jpg"
+            else:
+                splashline = ""
+
+            syslinux_conf = ""
+            syslinux_conf += "PROMPT 0\n"
+            syslinux_conf += "TIMEOUT " + str(bootloader.timeout) + "\n"
+            syslinux_conf += "\n"
+            syslinux_conf += "ALLOWOPTIONS 1\n"
+            syslinux_conf += "SERIAL 0 115200\n"
+            syslinux_conf += "\n"
+            if splashline:
+                syslinux_conf += "%s\n" % splashline
+            syslinux_conf += "DEFAULT boot\n"
+            syslinux_conf += "LABEL boot\n"
+
+            kernel = get_bitbake_var("KERNEL_IMAGE")
+            initrd = get_bitbake_var("INITRD_IMAGE")
+            syslinux_conf += "KERNEL " + kernel + "\n"
+
+            syslinux_conf += "APPEND label=boot root=%s initrd=%s %s\n" % \
+                             (creator.rootdev, initrd, bootloader.append)
+
+        logger.debug("Writing syslinux config %s/hdd/boot/syslinux.cfg",
+                     cr_workdir)
+        cfg = open("%s/hdd/boot/syslinux.cfg" % cr_workdir, "w")
+        cfg.write(syslinux_conf)
+        cfg.close()
+
+    @classmethod
+    def do_prepare_partition(cls, part, source_params, creator, cr_workdir,
+                             oe_builddir, bootimg_dir, kernel_dir,
+                             rootfs_dir, native_sysroot):
+        """
+        Called to do the actual content population for a partition i.e. it
+        'prepares' the partition to be incorporated into the image.
+        In this case, prepare content for legacy bios boot partition.
+        """
+        syslinux_dir = cls._get_syslinux_dir(bootimg_dir)
+
+        staging_kernel_dir = kernel_dir
+        kernel = get_bitbake_var("KERNEL_IMAGE")
+        initrd = get_bitbake_var("INITRD_IMAGE")
+
+        hdddir = "%s/hdd/boot" % cr_workdir
+
+        cmds = ("install -m 0644 %s/%s %s/%s" %
+                (staging_kernel_dir, kernel, hdddir, kernel),
+                "install -m 0644 %s/%s %s/%s" %
+                (staging_kernel_dir, initrd, hdddir, initrd),
+                "install -m 444 %s/modules/bios/ldlinux.c32 %s/ldlinux.c32" %
+                (syslinux_dir, hdddir),
+                "install -m 0644 %s/modules/bios/vesamenu.c32 %s/vesamenu.c32" %
+                (syslinux_dir, hdddir),
+                "install -m 444 %s/modules/bios/libcom32.c32 %s/libcom32.c32" %
+                (syslinux_dir, hdddir),
+                "install -m 444 %s/modules/bios/libutil.c32 %s/libutil.c32" %
+                (syslinux_dir, hdddir))
+
+        for install_cmd in cmds:
+            exec_cmd(install_cmd)
+
+        du_cmd = "du -bks %s" % hdddir
+        out = exec_cmd(du_cmd)
+        blocks = int(out.split()[0])
+
+        extra_blocks = part.get_extra_block_count(blocks)
+
+        if extra_blocks < BOOTDD_EXTRA_SPACE:
+            extra_blocks = BOOTDD_EXTRA_SPACE
+
+        blocks += extra_blocks
+
+        logger.debug("Added %d extra blocks to %s to get to %d total blocks",
+                     extra_blocks, part.mountpoint, blocks)
+
+        # dosfs image, created by mkdosfs
+        bootimg = "%s/boot.img" % cr_workdir
+
+        dosfs_cmd = "mkdosfs -n boot -S 512 -C %s %d" % (bootimg, blocks)
+        exec_native_cmd(dosfs_cmd, native_sysroot)
+
+        mcopy_cmd = "mcopy -i %s -s %s/* ::/" % (bootimg, hdddir)
+        exec_native_cmd(mcopy_cmd, native_sysroot)
+
+        syslinux_cmd = "syslinux %s" % bootimg
+        exec_native_cmd(syslinux_cmd, native_sysroot)
+
+        chmod_cmd = "chmod 644 %s" % bootimg
+        exec_cmd(chmod_cmd)
+
+        du_cmd = "du -Lbks %s" % bootimg
+        out = exec_cmd(du_cmd)
+        bootimg_size = out.split()[0]
+
+        part.size = int(bootimg_size)
+        part.source_file = bootimg
diff --git a/meta/classes/wic-img.bbclass b/meta/classes/wic-img.bbclass
index e8d2678..72779eb 100644
--- a/meta/classes/wic-img.bbclass
+++ b/meta/classes/wic-img.bbclass
@@ -10,8 +10,8 @@ WKS_FILE ?= "sdimage-efi"
 # this needs to come from buildchroot
 # and the isar efi plugin has the same problem
 # syslinux in debian has different folder structure, need to for those plugins
-STAGING_DATADIR ?= "/usr/share/"
-STAGING_LIBDIR ?= "/usr/lib/"
+STAGING_DATADIR ?= "${IMAGE_ROOTFS}/usr/lib/"
+STAGING_LIBDIR ?= "${IMAGE_ROOTFS}/usr/lib/"
 STAGING_DIR ?= "${TMPDIR}"
 IMAGE_BASENAME ?= "multiconfig:${MACHINE}-${DISTRO}:${PN}"
 FAKEROOTCMD ?= "wic_fakeroot"
@@ -57,6 +57,7 @@ do_rootfs_wicenv[prefuncs] = 'set_image_size'
 
 do_wic_image() {
     export BUILDDIR="${BUILDDIR}"
+    export MTOOLS_SKIP_CHECK=1
 
     sudo -E PATH="$PATH:/builder/isar/bitbake/bin:/builder/isar/scripts" /builder/isar/scripts/wic create ${WKS_FILE} --vars "${STAGING_DIR}/${MACHINE}/imgdata/" -o ${DEPLOY_DIR_IMAGE} -e ${IMAGE_BASENAME} ${WIC_CREATE_EXTRA_ARGS}
 }
-- 
2.13.6


^ permalink raw reply	[flat|nested] 3+ messages in thread

* [PATCH 2/2] images: wic: do not call wic with sudo anymore
  2018-01-31 15:48 [PATCH 1/2] wic: for pcibios boot plugins and wks files Henning Schild
@ 2018-01-31 15:48 ` Henning Schild
  2018-01-31 15:53   ` Henning Schild
  0 siblings, 1 reply; 3+ messages in thread
From: Henning Schild @ 2018-01-31 15:48 UTC (permalink / raw)
  To: isar-users; +Cc: Henning Schild

Issues:
  1. wic was called under sudo
  2. wic and its plugins can use sudo to do whatever they want

Impact:
  Issue 1 is addressed, but Issue 2 has always been there and has come to
  stay.

Signed-off-by: Henning Schild <henning.schild@siemens.com>
---
 meta/classes/wic-img.bbclass | 17 ++++++++++++++++-
 scripts/wic_fakeroot         | 37 ++++++++++++++++++++++---------------
 2 files changed, 38 insertions(+), 16 deletions(-)

diff --git a/meta/classes/wic-img.bbclass b/meta/classes/wic-img.bbclass
index 72779eb..444e003 100644
--- a/meta/classes/wic-img.bbclass
+++ b/meta/classes/wic-img.bbclass
@@ -59,7 +59,22 @@ do_wic_image() {
     export BUILDDIR="${BUILDDIR}"
     export MTOOLS_SKIP_CHECK=1
 
-    sudo -E PATH="$PATH:/builder/isar/bitbake/bin:/builder/isar/scripts" /builder/isar/scripts/wic create ${WKS_FILE} --vars "${STAGING_DIR}/${MACHINE}/imgdata/" -o ${DEPLOY_DIR_IMAGE} -e ${IMAGE_BASENAME} ${WIC_CREATE_EXTRA_ARGS}
+    # Play a dirty trick to redirect "du" and "mkfs.*" to FAKEROOTCMD
+    WTOOLS_SYSROOT="${TMPDIR}/trick_wic/"
+    mkdir -p ${WTOOLS_SYSROOT}/sbin
+    mkdir -p ${WTOOLS_SYSROOT}/usr/bin
+    for fstype in btrfs ext2 ext3 ext4 vfat; do
+    	ln -sf /builder/isar/scripts/${FAKEROOTCMD} \
+	    ${WTOOLS_SYSROOT}/sbin/mkfs.${fstype}
+    done
+    ln -sf /builder/isar/scripts/${FAKEROOTCMD} \
+        ${WTOOLS_SYSROOT}/usr/bin/du
+
+    echo "RECIPE_SYSROOT_NATIVE=\"${WTOOLS_SYSROOT}\"" >> \
+        ${STAGING_DIR}/${MACHINE}/imgdata/wic-tools.env
+
+    export PATH="${WTOOLS_SYSROOT}/sbin:${WTOOLS_SYSROOT}/usr/sbin:${WTOOLS_SYSROOT}/usr/bin:${PATH}"
+    /builder/isar/scripts/wic create ${WKS_FILE} --vars "${STAGING_DIR}/${MACHINE}/imgdata/" -o ${DEPLOY_DIR_IMAGE} -e ${IMAGE_BASENAME} ${WIC_CREATE_EXTRA_ARGS}
 }
 
 addtask wic_image before do_build after do_copy_boot_files
diff --git a/scripts/wic_fakeroot b/scripts/wic_fakeroot
index 9e01c38..01865a0 100755
--- a/scripts/wic_fakeroot
+++ b/scripts/wic_fakeroot
@@ -1,10 +1,11 @@
 #!/usr/bin/env python3
 #
 # wic needs a FAKEROOT cmd to run, the default is pseudo. In Isar we do/can not
-# use pseudo. And we call wic as root to begin with, so this script could be a
-# dummy doing nothing. It is almost a dummy ...
-#
-# If the fsck hack ever becomes obsolete, FAKEROOTCMD ?= "true;" can be used
+# use pseudo at the moment.
+# All wic calls to exec_native_cmd will end up here, if they wanted pseudo.
+# They will get executed under sudo.
+# In addition we prepend "du"s and "mkfs"s with a sudo, just like a Isar
+# specific patch did before.
 #
 # This software is a part of Isar.
 # Copyright (C) 2018 Siemens AG
@@ -15,23 +16,29 @@ import shutil
 import subprocess
 
 args = sys.argv
-args.pop(0)
-cmd = args[0]
+args[0] = os.path.basename(args[0])
+
+if not (args[0].startswith('mkfs.') or args[0] == 'du'):
+    # the wrapper was not called directly and not for one of the known
+    # hacks
+    if args[0] != 'wic_fakeroot':
+        sys.exit(1)
+    args.pop(0)
 
-# expect to be running as root
-# we could loosen that and execv(sudo, args) but even some early
-# "du"s fail, which do not use the fakeroot-wrapper
-#  i.e. in wics partition.py the "du -ks" fails on
-#    var/cache/apt/archives/partial
-#    rootfs/root ...
-assert 'root' == os.environ["USER"]
+cmd = args[0]
 
 # e2fsck <= 1.43.5 returns 1 on non-errors (stretch and before affected)
 # treat 1 as safe ... the filesystem was successfully repaired and is OK
 if cmd.startswith('fsck.'):
-    ret = subprocess.call(args)
+    ret = subprocess.call(['sudo'] + args)
     if ret == 0 or ret == 1:
         sys.exit(0)
     sys.exit(ret)
 
-os.execv(shutil.which(cmd), args)
+# now remove the previous 3 entries from PATH, the ones we used to trick some guys in here
+path = ':'.join(os.environ['PATH'].split(':')[3:])
+path += ":/builder/isar/bitbake/bin:/builder/isar/scripts"
+
+args = ['-E', 'PATH="%s"' % path ] + args
+
+os.execv(shutil.which('sudo'), args)
-- 
2.13.6


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH 2/2] images: wic: do not call wic with sudo anymore
  2018-01-31 15:48 ` [PATCH 2/2] images: wic: do not call wic with sudo anymore Henning Schild
@ 2018-01-31 15:53   ` Henning Schild
  0 siblings, 0 replies; 3+ messages in thread
From: Henning Schild @ 2018-01-31 15:53 UTC (permalink / raw)
  To: isar-users

I still prefer the almighty big sudo, this patch adds complexity and is
a hack. But i also think that touching contrib code in _any_ way is so
evil that any hack should be considered to avoid it.

Henning

Am Wed, 31 Jan 2018 16:48:38 +0100
schrieb Henning Schild <henning.schild@siemens.com>:

> Issues:
>   1. wic was called under sudo
>   2. wic and its plugins can use sudo to do whatever they want
> 
> Impact:
>   Issue 1 is addressed, but Issue 2 has always been there and has
> come to stay.
> 
> Signed-off-by: Henning Schild <henning.schild@siemens.com>
> ---
>  meta/classes/wic-img.bbclass | 17 ++++++++++++++++-
>  scripts/wic_fakeroot         | 37
> ++++++++++++++++++++++--------------- 2 files changed, 38
> insertions(+), 16 deletions(-)
> 
> diff --git a/meta/classes/wic-img.bbclass
> b/meta/classes/wic-img.bbclass index 72779eb..444e003 100644
> --- a/meta/classes/wic-img.bbclass
> +++ b/meta/classes/wic-img.bbclass
> @@ -59,7 +59,22 @@ do_wic_image() {
>      export BUILDDIR="${BUILDDIR}"
>      export MTOOLS_SKIP_CHECK=1
>  
> -    sudo -E
> PATH="$PATH:/builder/isar/bitbake/bin:/builder/isar/scripts" /builder/isar/scripts/wic
> create ${WKS_FILE} --vars "${STAGING_DIR}/${MACHINE}/imgdata/" -o
> ${DEPLOY_DIR_IMAGE} -e ${IMAGE_BASENAME} ${WIC_CREATE_EXTRA_ARGS}
> +    # Play a dirty trick to redirect "du" and "mkfs.*" to FAKEROOTCMD
> +    WTOOLS_SYSROOT="${TMPDIR}/trick_wic/"
> +    mkdir -p ${WTOOLS_SYSROOT}/sbin
> +    mkdir -p ${WTOOLS_SYSROOT}/usr/bin
> +    for fstype in btrfs ext2 ext3 ext4 vfat; do
> +    	ln -sf /builder/isar/scripts/${FAKEROOTCMD} \
> +	    ${WTOOLS_SYSROOT}/sbin/mkfs.${fstype}
> +    done
> +    ln -sf /builder/isar/scripts/${FAKEROOTCMD} \
> +        ${WTOOLS_SYSROOT}/usr/bin/du
> +
> +    echo "RECIPE_SYSROOT_NATIVE=\"${WTOOLS_SYSROOT}\"" >> \
> +        ${STAGING_DIR}/${MACHINE}/imgdata/wic-tools.env
> +
> +    export
> PATH="${WTOOLS_SYSROOT}/sbin:${WTOOLS_SYSROOT}/usr/sbin:${WTOOLS_SYSROOT}/usr/bin:${PATH}"
> +    /builder/isar/scripts/wic create ${WKS_FILE} --vars
> "${STAGING_DIR}/${MACHINE}/imgdata/" -o ${DEPLOY_DIR_IMAGE} -e
> ${IMAGE_BASENAME} ${WIC_CREATE_EXTRA_ARGS} } 
>  addtask wic_image before do_build after do_copy_boot_files
> diff --git a/scripts/wic_fakeroot b/scripts/wic_fakeroot
> index 9e01c38..01865a0 100755
> --- a/scripts/wic_fakeroot
> +++ b/scripts/wic_fakeroot
> @@ -1,10 +1,11 @@
>  #!/usr/bin/env python3
>  #
>  # wic needs a FAKEROOT cmd to run, the default is pseudo. In Isar we
> do/can not -# use pseudo. And we call wic as root to begin with, so
> this script could be a -# dummy doing nothing. It is almost a
> dummy ... -#
> -# If the fsck hack ever becomes obsolete, FAKEROOTCMD ?= "true;" can
> be used +# use pseudo at the moment.
> +# All wic calls to exec_native_cmd will end up here, if they wanted
> pseudo. +# They will get executed under sudo.
> +# In addition we prepend "du"s and "mkfs"s with a sudo, just like a
> Isar +# specific patch did before.
>  #
>  # This software is a part of Isar.
>  # Copyright (C) 2018 Siemens AG
> @@ -15,23 +16,29 @@ import shutil
>  import subprocess
>  
>  args = sys.argv
> -args.pop(0)
> -cmd = args[0]
> +args[0] = os.path.basename(args[0])
> +
> +if not (args[0].startswith('mkfs.') or args[0] == 'du'):
> +    # the wrapper was not called directly and not for one of the
> known
> +    # hacks
> +    if args[0] != 'wic_fakeroot':
> +        sys.exit(1)
> +    args.pop(0)
>  
> -# expect to be running as root
> -# we could loosen that and execv(sudo, args) but even some early
> -# "du"s fail, which do not use the fakeroot-wrapper
> -#  i.e. in wics partition.py the "du -ks" fails on
> -#    var/cache/apt/archives/partial
> -#    rootfs/root ...
> -assert 'root' == os.environ["USER"]
> +cmd = args[0]
>  
>  # e2fsck <= 1.43.5 returns 1 on non-errors (stretch and before
> affected) # treat 1 as safe ... the filesystem was successfully
> repaired and is OK if cmd.startswith('fsck.'):
> -    ret = subprocess.call(args)
> +    ret = subprocess.call(['sudo'] + args)
>      if ret == 0 or ret == 1:
>          sys.exit(0)
>      sys.exit(ret)
>  
> -os.execv(shutil.which(cmd), args)
> +# now remove the previous 3 entries from PATH, the ones we used to
> trick some guys in here +path =
> ':'.join(os.environ['PATH'].split(':')[3:]) +path +=
> ":/builder/isar/bitbake/bin:/builder/isar/scripts" +
> +args = ['-E', 'PATH="%s"' % path ] + args
> +
> +os.execv(shutil.which('sudo'), args)


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2018-01-31 15:53 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-01-31 15:48 [PATCH 1/2] wic: for pcibios boot plugins and wks files Henning Schild
2018-01-31 15:48 ` [PATCH 2/2] images: wic: do not call wic with sudo anymore Henning Schild
2018-01-31 15:53   ` Henning Schild

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox