2014-12-18 10:37:32 +00:00
|
|
|
diff --git a/include/iprt/mangling.h b/include/iprt/mangling.h
|
2021-10-31 01:05:48 +00:00
|
|
|
index 25b918d1..1420ff1d 100644
|
2014-12-18 10:37:32 +00:00
|
|
|
--- a/include/iprt/mangling.h
|
|
|
|
+++ b/include/iprt/mangling.h
|
2021-10-31 01:05:48 +00:00
|
|
|
@@ -1695,6 +1695,7 @@
|
2014-12-18 10:37:32 +00:00
|
|
|
# define RTPathStripSuffix RT_MANGLER(RTPathStripSuffix)
|
|
|
|
# define RTPathStripFilename RT_MANGLER(RTPathStripFilename)
|
|
|
|
# define RTPathStripTrailingSlash RT_MANGLER(RTPathStripTrailingSlash)
|
|
|
|
+# define RTPathSuidDir RT_MANGLER(RTPathSuidDir)
|
|
|
|
# define RTPathTemp RT_MANGLER(RTPathTemp)
|
|
|
|
# define RTPathTraverseList RT_MANGLER(RTPathTraverseList)
|
|
|
|
# define RTPathUnlink RT_MANGLER(RTPathUnlink)
|
2021-10-31 01:05:48 +00:00
|
|
|
@@ -1734,6 +1735,7 @@
|
2014-12-18 10:37:32 +00:00
|
|
|
# define RTProcGetAffinityMask RT_MANGLER(RTProcGetAffinityMask)
|
|
|
|
# define RTProcGetExecutablePath RT_MANGLER(RTProcGetExecutablePath)
|
|
|
|
# define RTProcGetPriority RT_MANGLER(RTProcGetPriority)
|
|
|
|
+# define RTProcGetSuidPath RT_MANGLER(RTProcGetSuidPath)
|
|
|
|
# define RTProcIsRunningByName RT_MANGLER(RTProcIsRunningByName)
|
|
|
|
# define RTProcQueryParent RT_MANGLER(RTProcQueryParent)
|
|
|
|
# define RTProcQueryUsername RT_MANGLER(RTProcQueryUsername)
|
|
|
|
diff --git a/include/iprt/path.h b/include/iprt/path.h
|
2021-10-31 01:05:48 +00:00
|
|
|
index 99060e35..ccfbeb76 100644
|
2014-12-18 10:37:32 +00:00
|
|
|
--- a/include/iprt/path.h
|
|
|
|
+++ b/include/iprt/path.h
|
2021-10-31 01:05:48 +00:00
|
|
|
@@ -1221,6 +1221,15 @@ RTDECL(int) RTPathCalcRelative(char *pszPathDst, size_t cbPathDst, const char *p
|
|
|
|
*/
|
2014-12-18 10:37:32 +00:00
|
|
|
RTDECL(int) RTPathExecDir(char *pszPath, size_t cchPath);
|
2021-10-31 01:05:48 +00:00
|
|
|
|
|
|
|
+/**
|
2014-12-18 10:37:32 +00:00
|
|
|
+ * Gets the path to the NixOS setuid wrappers directory.
|
|
|
|
+ *
|
|
|
|
+ * @returns iprt status code.
|
|
|
|
+ * @param pszPath Buffer where to store the path.
|
|
|
|
+ * @param cchPath Buffer size in bytes.
|
|
|
|
+ */
|
|
|
|
+RTDECL(int) RTPathSuidDir(char *pszPath, size_t cchPath);
|
|
|
|
+
|
2021-10-31 01:05:48 +00:00
|
|
|
/**
|
2014-12-18 10:37:32 +00:00
|
|
|
* Gets the user home directory.
|
|
|
|
*
|
|
|
|
diff --git a/include/iprt/process.h b/include/iprt/process.h
|
2021-10-31 01:05:48 +00:00
|
|
|
index f4f67dd4..ab882a19 100644
|
2014-12-18 10:37:32 +00:00
|
|
|
--- a/include/iprt/process.h
|
|
|
|
+++ b/include/iprt/process.h
|
2021-10-31 01:05:48 +00:00
|
|
|
@@ -352,6 +352,16 @@ RTR3DECL(const char *) RTProcExecutablePath(void);
|
|
|
|
*/
|
2014-12-18 10:37:32 +00:00
|
|
|
RTR3DECL(char *) RTProcGetExecutablePath(char *pszExecPath, size_t cbExecPath);
|
2021-10-31 01:05:48 +00:00
|
|
|
|
|
|
|
+/**
|
2014-12-18 10:37:32 +00:00
|
|
|
+ * Gets the path to the NixOS setuid wrappers directory.
|
|
|
|
+ *
|
|
|
|
+ * @returns pszExecPath on success. NULL on buffer overflow or other errors.
|
|
|
|
+ *
|
|
|
|
+ * @param pszExecPath Where to store the path.
|
|
|
|
+ * @param cbExecPath The size of the buffer.
|
|
|
|
+ */
|
|
|
|
+RTR3DECL(char *) RTProcGetSuidPath(char *pszExecPath, size_t cbExecPath);
|
|
|
|
+
|
2021-10-31 01:05:48 +00:00
|
|
|
/**
|
2014-12-18 10:37:32 +00:00
|
|
|
* Daemonize the current process, making it a background process.
|
|
|
|
*
|
2014-11-29 07:09:50 +00:00
|
|
|
diff --git a/src/VBox/HostDrivers/Support/SUPR3HardenedVerify.cpp b/src/VBox/HostDrivers/Support/SUPR3HardenedVerify.cpp
|
2021-10-31 01:05:48 +00:00
|
|
|
index 75ff8572..18a077b7 100644
|
2014-11-29 07:09:50 +00:00
|
|
|
--- a/src/VBox/HostDrivers/Support/SUPR3HardenedVerify.cpp
|
|
|
|
+++ b/src/VBox/HostDrivers/Support/SUPR3HardenedVerify.cpp
|
2021-10-31 01:05:48 +00:00
|
|
|
@@ -1531,9 +1531,9 @@ static int supR3HardenedVerifyFsObject(PCSUPR3HARDENEDFSOBJSTATE pFsObjState, bo
|
2017-06-23 04:48:54 +01:00
|
|
|
bool fBad = !fRelaxed || pFsObjState->Stat.st_gid != 2 /*bin*/ || suplibHardenedStrCmp(pszPath, "/usr/lib/iconv");
|
2017-11-15 15:03:44 +00:00
|
|
|
# else
|
2014-11-29 07:09:50 +00:00
|
|
|
NOREF(fRelaxed);
|
|
|
|
- bool fBad = true;
|
|
|
|
+ bool fBad = !(fDir && pFsObjState->Stat.st_mode & S_ISVTX && !suplibHardenedStrCmp(pszPath, "/nix/store"));
|
2017-11-15 15:03:44 +00:00
|
|
|
# endif
|
2015-04-04 15:59:56 +01:00
|
|
|
- if (fBad)
|
|
|
|
+ if (fBad && suplibHardenedStrCmp(pszPath, "/nix/store"))
|
2014-11-29 07:09:50 +00:00
|
|
|
return supR3HardenedSetError3(VERR_SUPLIB_WRITE_NON_SYS_GROUP, pErrInfo,
|
2015-04-04 15:59:56 +01:00
|
|
|
"An unknown (and thus untrusted) group has write access to '", pszPath,
|
|
|
|
"' and we therefore cannot trust the directory content or that of any subdirectory");
|
2021-10-31 01:05:48 +00:00
|
|
|
diff --git a/src/VBox/Main/src-all/MachineLaunchVMCommonWorker.cpp b/src/VBox/Main/src-all/MachineLaunchVMCommonWorker.cpp
|
|
|
|
index 2991d3a7..d042a08b 100644
|
|
|
|
--- a/src/VBox/Main/src-all/MachineLaunchVMCommonWorker.cpp
|
|
|
|
+++ b/src/VBox/Main/src-all/MachineLaunchVMCommonWorker.cpp
|
|
|
|
@@ -90,7 +90,7 @@ int MachineLaunchVMCommonWorker(const Utf8Str &aNameOrId,
|
|
|
|
|
|
|
|
/* Get the path to the executable directory w/ trailing slash: */
|
|
|
|
char szPath[RTPATH_MAX];
|
|
|
|
- int vrc = RTPathAppPrivateArch(szPath, sizeof(szPath));
|
|
|
|
+ int vrc = RTStrCopy(szPath, sizeof(szPath) - 1, "/run/wrappers/bin");
|
|
|
|
AssertRCReturn(vrc, vrc);
|
|
|
|
size_t cbBufLeft = RTPathEnsureTrailingSeparator(szPath, sizeof(szPath));
|
|
|
|
AssertReturn(cbBufLeft > 0, VERR_FILENAME_TOO_LONG);
|
|
|
|
diff --git a/src/VBox/Main/src-server/NetworkServiceRunner.cpp b/src/VBox/Main/src-server/NetworkServiceRunner.cpp
|
|
|
|
index 2e57690a..3272c840 100644
|
|
|
|
--- a/src/VBox/Main/src-server/NetworkServiceRunner.cpp
|
|
|
|
+++ b/src/VBox/Main/src-server/NetworkServiceRunner.cpp
|
|
|
|
@@ -188,7 +188,7 @@ int NetworkServiceRunner::start(bool aKillProcessOnStop)
|
|
|
|
* ASSUME it is relative to the directory that holds VBoxSVC.
|
|
|
|
*/
|
|
|
|
char szExePath[RTPATH_MAX];
|
|
|
|
- AssertReturn(RTProcGetExecutablePath(szExePath, RTPATH_MAX), VERR_FILENAME_TOO_LONG);
|
|
|
|
+ AssertReturn(RTProcGetSuidPath(szExePath, RTPATH_MAX), VERR_FILENAME_TOO_LONG);
|
|
|
|
RTPathStripFilename(szExePath);
|
|
|
|
int vrc = RTPathAppend(szExePath, sizeof(szExePath), m->pszProcName);
|
|
|
|
AssertLogRelRCReturn(vrc, vrc);
|
2014-12-18 10:37:32 +00:00
|
|
|
diff --git a/src/VBox/Main/src-server/generic/NetIf-generic.cpp b/src/VBox/Main/src-server/generic/NetIf-generic.cpp
|
2021-10-31 01:05:48 +00:00
|
|
|
index af155966..3b8e793d 100644
|
2014-12-18 10:37:32 +00:00
|
|
|
--- a/src/VBox/Main/src-server/generic/NetIf-generic.cpp
|
|
|
|
+++ b/src/VBox/Main/src-server/generic/NetIf-generic.cpp
|
2021-10-31 01:05:48 +00:00
|
|
|
@@ -48,7 +48,7 @@ static int NetIfAdpCtl(const char * pcszIfName, const char *pszAddr, const char
|
2014-12-18 10:37:32 +00:00
|
|
|
const char *args[] = { NULL, pcszIfName, pszAddr, pszOption, pszMask, NULL };
|
2021-10-31 01:05:48 +00:00
|
|
|
|
2014-12-18 10:37:32 +00:00
|
|
|
char szAdpCtl[RTPATH_MAX];
|
|
|
|
- int rc = RTPathExecDir(szAdpCtl, sizeof(szAdpCtl) - sizeof("/" VBOXNETADPCTL_NAME));
|
|
|
|
+ int rc = RTPathSuidDir(szAdpCtl, sizeof(szAdpCtl) - sizeof("/" VBOXNETADPCTL_NAME));
|
|
|
|
if (RT_FAILURE(rc))
|
|
|
|
{
|
|
|
|
LogRel(("NetIfAdpCtl: failed to get program path, rc=%Rrc.\n", rc));
|
2021-10-31 01:05:48 +00:00
|
|
|
@@ -95,7 +95,7 @@ static int NetIfAdpCtl(HostNetworkInterface * pIf, const char *pszAddr, const ch
|
2014-12-18 10:37:32 +00:00
|
|
|
int NetIfAdpCtlOut(const char * pcszName, const char * pcszCmd, char *pszBuffer, size_t cBufSize)
|
|
|
|
{
|
|
|
|
char szAdpCtl[RTPATH_MAX];
|
|
|
|
- int rc = RTPathExecDir(szAdpCtl, sizeof(szAdpCtl) - sizeof("/" VBOXNETADPCTL_NAME " ") - strlen(pcszCmd));
|
|
|
|
+ int rc = RTPathSuidDir(szAdpCtl, sizeof(szAdpCtl) - sizeof("/" VBOXNETADPCTL_NAME " ") - strlen(pcszCmd));
|
|
|
|
if (RT_FAILURE(rc))
|
|
|
|
{
|
|
|
|
LogRel(("NetIfAdpCtlOut: Failed to get program path, rc=%Rrc\n", rc));
|
2021-10-31 01:05:48 +00:00
|
|
|
@@ -210,7 +210,7 @@ int NetIfCreateHostOnlyNetworkInterface(VirtualBox *pVirtualBox,
|
2014-12-18 10:37:32 +00:00
|
|
|
progress.queryInterfaceTo(aProgress);
|
2021-10-31 01:05:48 +00:00
|
|
|
|
2014-12-18 10:37:32 +00:00
|
|
|
char szAdpCtl[RTPATH_MAX];
|
2021-10-31 01:05:48 +00:00
|
|
|
- vrc = RTPathExecDir(szAdpCtl, sizeof(szAdpCtl) - sizeof("/" VBOXNETADPCTL_NAME " add"));
|
|
|
|
+ vrc = RTPathSuidDir(szAdpCtl, sizeof(szAdpCtl) - sizeof("/" VBOXNETADPCTL_NAME " add"));
|
|
|
|
if (RT_FAILURE(vrc))
|
2014-12-18 10:37:32 +00:00
|
|
|
{
|
|
|
|
progress->i_notifyComplete(E_FAIL,
|
|
|
|
diff --git a/src/VBox/Runtime/r3/path.cpp b/src/VBox/Runtime/r3/path.cpp
|
2021-10-31 01:05:48 +00:00
|
|
|
index 4b1a0ada..7f6dd707 100644
|
2014-12-18 10:37:32 +00:00
|
|
|
--- a/src/VBox/Runtime/r3/path.cpp
|
|
|
|
+++ b/src/VBox/Runtime/r3/path.cpp
|
|
|
|
@@ -81,6 +81,12 @@ RTDECL(int) RTPathExecDir(char *pszPath, size_t cchPath)
|
|
|
|
}
|
2021-10-31 01:05:48 +00:00
|
|
|
|
|
|
|
|
2014-12-18 10:37:32 +00:00
|
|
|
+RTDECL(int) RTPathSuidDir(char *pszPath, size_t cchPath)
|
|
|
|
+{
|
2017-01-29 10:11:01 +00:00
|
|
|
+ return RTStrCopy(pszPath, cchPath, "/run/wrappers/bin");
|
2014-12-18 10:37:32 +00:00
|
|
|
+}
|
|
|
|
+
|
|
|
|
+
|
|
|
|
RTDECL(int) RTPathAppPrivateNoArch(char *pszPath, size_t cchPath)
|
|
|
|
{
|
|
|
|
#if !defined(RT_OS_WINDOWS) && defined(RTPATH_APP_PRIVATE)
|
|
|
|
diff --git a/src/VBox/Runtime/r3/process.cpp b/src/VBox/Runtime/r3/process.cpp
|
2021-10-31 01:05:48 +00:00
|
|
|
index 5f7c7a87..59461cfa 100644
|
2014-12-18 10:37:32 +00:00
|
|
|
--- a/src/VBox/Runtime/r3/process.cpp
|
|
|
|
+++ b/src/VBox/Runtime/r3/process.cpp
|
2021-10-31 01:05:48 +00:00
|
|
|
@@ -117,6 +117,25 @@ RTR3DECL(const char *) RTProcExecutablePath(void)
|
|
|
|
return g_szrtProcExePath;
|
2014-12-18 10:37:32 +00:00
|
|
|
}
|
2021-10-31 01:05:48 +00:00
|
|
|
|
2014-12-18 10:37:32 +00:00
|
|
|
+/*
|
|
|
|
+ * Note the / at the end! This is important, because the functions using this
|
|
|
|
+ * will cut off everything after the rightmost / as this function is analogous
|
|
|
|
+ * to RTProcGetExecutablePath().
|
|
|
|
+ */
|
2017-01-29 10:11:01 +00:00
|
|
|
+#define SUIDDIR "/run/wrappers/bin/"
|
2014-12-18 10:37:32 +00:00
|
|
|
+
|
|
|
|
+RTR3DECL(char *) RTProcGetSuidPath(char *pszExecPath, size_t cbExecPath)
|
|
|
|
+{
|
|
|
|
+ if (cbExecPath >= sizeof(SUIDDIR))
|
|
|
|
+ {
|
|
|
|
+ memcpy(pszExecPath, SUIDDIR, sizeof(SUIDDIR));
|
|
|
|
+ pszExecPath[sizeof(SUIDDIR)] = '\0';
|
|
|
|
+ return pszExecPath;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ AssertMsgFailed(("Buffer too small (%zu <= %zu)\n", cbExecPath, sizeof(SUIDDIR)));
|
|
|
|
+ return NULL;
|
|
|
|
+}
|
2021-10-31 01:05:48 +00:00
|
|
|
|
2014-12-18 10:37:32 +00:00
|
|
|
RTR3DECL(const char *) RTProcShortName(void)
|
|
|
|
{
|