From cfa360026853d44b38183c72b48066bd146ad892 Mon Sep 17 00:00:00 2001 From: Hans de Goede Date: Mar 20 2019 09:07:08 +0000 Subject: Fix automounted shares not working on 6.0.x hosts --- diff --git a/0001-VBoxServiceAutoMount-Change-Linux-mount-code-to-use-.patch b/0001-VBoxServiceAutoMount-Change-Linux-mount-code-to-use-.patch index 63447ad..5af60f9 100644 --- a/0001-VBoxServiceAutoMount-Change-Linux-mount-code-to-use-.patch +++ b/0001-VBoxServiceAutoMount-Change-Linux-mount-code-to-use-.patch @@ -126,6 +126,60 @@ diff --git a/src/VBox/Additions/common/VBoxService/VBoxServiceAutoMount.cpp b/sr } # endif } +@@ -1417,45 +1417,21 @@ static int vbsvcAutomounterMountIt(PVBSV + } + + # if defined(RT_OS_LINUX) +- /* +- * Linux a bit more work... +- */ +- struct vbsf_mount_info_new MntInfo; +- RT_ZERO(MntInfo); +- struct vbsf_mount_opts MntOpts; +- RT_ZERO(MntOpts); +- MntInfo.nullchar = '\0'; +- MntInfo.signature[0] = VBSF_MOUNT_SIGNATURE_BYTE_0; +- MntInfo.signature[1] = VBSF_MOUNT_SIGNATURE_BYTE_1; +- MntInfo.signature[2] = VBSF_MOUNT_SIGNATURE_BYTE_2; +- MntInfo.length = sizeof(MntInfo); +- MntInfo.uid = MntOpts.uid = 0; +- MntInfo.gid = MntOpts.gid = gidMount; +- MntInfo.dmode = MntOpts.dmode = 0770; +- MntInfo.fmode = MntOpts.fmode = 0770; +- MntInfo.dmask = MntOpts.dmask = 0000; +- MntInfo.fmask = MntOpts.fmask = 0000; +- memcpy(MntInfo.tag, g_szTag, sizeof(g_szTag)); AssertCompile(sizeof(MntInfo.tag) >= sizeof(g_szTag)); +- rc = RTStrCopy(MntInfo.name, sizeof(MntInfo.name), pEntry->pszName); +- if (RT_FAILURE(rc)) ++ unsigned long fFlags = MS_NODEV; ++ char szOpts[MAX_MNTOPT_STR] = { '\0', }; ++ ssize_t cchOpts = RTStrPrintf2(szOpts, sizeof(szOpts), ++ "uid=0,gid=%d,dmode=0770,fmode=0770,dmask=0000,fmask=0000", gidMount); ++ if (cchOpts <= 0) + { +- VGSvcError("vbsvcAutomounterMountIt: Share name '%s' is too long for the MntInfo.name field!\n", pEntry->pszName); +- return rc; ++ VGSvcError("vbsvcAutomounterMountIt: szOpts overflow! %zd\n", cchOpts); ++ return VERR_BUFFER_OVERFLOW; + } + +- errno = 0; +- unsigned long fFlags = MS_NODEV; +- rc = mount(pEntry->pszName, pEntry->pszActualMountPoint, "vboxsf", fFlags, &MntInfo); ++ rc = mount(pEntry->pszName, pEntry->pszActualMountPoint, "vboxsf", fFlags, szOpts); + if (rc == 0) + { + VGSvcVerbose(0, "vbsvcAutomounterMountIt: Successfully mounted '%s' on '%s'\n", + pEntry->pszName, pEntry->pszActualMountPoint); +- +- errno = 0; +- rc = vbsfmount_complete(pEntry->pszName, pEntry->pszActualMountPoint, fFlags, &MntOpts); +- if (rc != 0) /* Ignorable. /etc/mtab is probably a link to /proc/mounts. */ +- VGSvcVerbose(1, "vbsvcAutomounterMountIt: vbsfmount_complete failed: %s (%d/%d)\n", +- rc == 1 ? "open_memstream" : rc == 2 ? "setmntent" : rc == 3 ? "addmntent" : "unknown", rc, errno); + return VINF_SUCCESS; + } + else if (errno == EINVAL) -- 2.14.3 diff --git a/010-linux-4.16-mount-fixes.patch b/010-linux-4.16-mount-fixes.patch deleted file mode 100644 index 08f3b53..0000000 --- a/010-linux-4.16-mount-fixes.patch +++ /dev/null @@ -1,35 +0,0 @@ -This ghetto patch attempts to fix shared folder automounting for guests running -Linux 4.16, and also suggests an alternative to mount.vboxsf. - -diff -uprb VirtualBox-5.2.8.orig/src/VBox/Additions/common/VBoxService/VBoxServiceAutoMount.cpp VirtualBox-5.2.8/src/VBox/Additions/common/VBoxService/VBoxServiceAutoMount.cpp ---- VirtualBox-5.2.8.orig/src/VBox/Additions/common/VBoxService/VBoxServiceAutoMount.cpp 2018-02-26 17:57:30.000000000 +0200 -+++ VirtualBox-5.2.8/src/VBox/Additions/common/VBoxService/VBoxServiceAutoMount.cpp 2018-04-07 21:00:05.785735622 +0300 -@@ -329,6 +329,13 @@ static int vbsvcAutoMountSharedFolder(co - "vboxsf", - fFlags, - szOptBuf); -+ if (r == -1 && errno == EINVAL) -+ { -+ /* Mainline vboxsf accepts regular mount opts. */ -+ char mount_opts[1024]; -+ snprintf(mount_opts, 1024, "%s,dmode=0770,fmode=0770", szOptBuf); -+ r = mount(pszShareName, pszMountPoint, "vboxsf", fFlags, mount_opts); -+ } - if (r == 0) - { - VGSvcVerbose(0, "vbsvcAutoMountWorker: Shared folder '%s' was mounted to '%s'\n", pszShareName, pszMountPoint); -diff -uprb VirtualBox-5.2.8.orig/src/VBox/Additions/linux/sharedfolders/mount.vboxsf.c VirtualBox-5.2.8/src/VBox/Additions/linux/sharedfolders/mount.vboxsf.c ---- VirtualBox-5.2.8.orig/src/VBox/Additions/linux/sharedfolders/mount.vboxsf.c 2018-02-26 17:57:34.000000000 +0200 -+++ VirtualBox-5.2.8/src/VBox/Additions/linux/sharedfolders/mount.vboxsf.c 2018-04-07 21:39:38.121577588 +0300 -@@ -485,6 +485,11 @@ main(int argc, char **argv) - * to keep this code here slick without having VbglR3. - */ - err = mount(host_name, mount_point, "vboxsf", flags, &mntinf); -+ if (err == -1 && errno == EINVAL) -+ { -+ /* The mount.vboxsf helper should not be used with mainline vboxsf. */ -+ panic("mount.vboxsf cannot be used with mainline vboxsf; instead use:\n\n mount -cit vboxsf NAME MOUNTPOINT\n\n"); -+ } - if (err == -1 && errno == EPROTO) - { - /* Sometimes the mount utility messes up the share name. Try to diff --git a/VirtualBox-5.2.6-gcc8.patch b/VirtualBox-5.2.6-gcc8.patch deleted file mode 100644 index 37a0348..0000000 --- a/VirtualBox-5.2.6-gcc8.patch +++ /dev/null @@ -1,14 +0,0 @@ -diff -up VirtualBox-5.2.6/configure~ VirtualBox-5.2.6/configure ---- VirtualBox-5.2.6/configure~ 2018-01-15 15:49:37.000000000 +0100 -+++ VirtualBox-5.2.6/configure 2018-02-14 08:53:25.602712747 +0100 -@@ -440,8 +440,8 @@ check_gcc() - elif [ $cc_maj -lt 4 \ - -o \( $cc_maj -eq 4 -a $cc_min -lt 4 -a "$OS" != "darwin" \) \ - -o \( $cc_maj -eq 4 -a $cc_min -lt 2 -a "$OS" = "darwin" \) \ -- -o $cc_maj -gt 7 ]; then -- log_failure "gcc version $cc_maj.$cc_min found, expected gcc 4.x...7.x" -+ -o $cc_maj -gt 8 ]; then -+ log_failure "gcc version $cc_maj.$cc_min found, expected gcc 4.x...8.x" - fail really - else - log_success "found version $cc_ver" diff --git a/virtualbox-guest-additions.spec b/virtualbox-guest-additions.spec index 1eccc7f..0a84647 100644 --- a/virtualbox-guest-additions.spec +++ b/virtualbox-guest-additions.spec @@ -2,7 +2,7 @@ Name: virtualbox-guest-additions Version: 6.0.4 -Release: 1%{?dist} +Release: 2%{?dist} Summary: VirtualBox Guest Additions License: GPLv2 or (GPLv2 and CDDL) URL: https://www.virtualbox.org/wiki/VirtualBox @@ -17,10 +17,6 @@ Source4: VBoxOGLRun.sh Patch2: 0001-VBoxServiceAutoMount-Change-Linux-mount-code-to-use-.patch # Do not show an error dialog when not running under vbox Patch3: VirtualBox-5.2.10-xclient.patch -# Fix build with gcc8 -#Patch4: VirtualBox-5.2.6-gcc8.patch -# From Archlinux -Patch10: 010-linux-4.16-mount-fixes.patch BuildRequires: gcc-c++ BuildRequires: kBuild >= 0.1.9998.r3093 @@ -196,6 +192,9 @@ getent passwd vboxadd >/dev/null || \ %changelog +* Wed Mar 20 2019 Hans de Goede - 6.0.4-2 +- Fix automounted shares not working on 6.0.x hosts + * Thu Mar 07 2019 Sérgio Basto - 6.0.4-1 - Update Virtualbox Guest Additions to 6.0.4