I see this too. It happens on distros like Nix (no relation to me
) where the makemkvcon and makemkv binaries are in different directories (usually with contents symlinked to /usr/bin). makemkv by default looks for the makemkvcon binary purely in the same directory as the makemkv binary, but can be coerced with a one-byte code change to do a crude but (barely) adequate path search for the binary in /bin, /usr/bin and /usr/local/bin: but even then it requires that the binary not be a symlink, which *again* breaks Nix and similar distros (like Guix).
I don't know why people persist in doing things like this rather than just using execvp(): it's not even reliable, as there are many reasons execve() or posix_spawn() can fail other than merely the file type being wrong (wrong architecture, ACLs, SELinux rules, etc), and you can perfectly well execute things that aren't regular files (such as symlinks, as here).
Best fixed by just using path searches for attempts to execute binaries with no path (like "makemkvcon"), which is literally a matter of calling posix_spawnp() in the appropriate place: to minimize risk we do it only if the binary name doesn't contain a slash, so execution using absolute paths and even relative paths don't do a path search (as now). The existing handrolled hardwired path search can be torn out later on: this is enough to make it work again.
Trivial patch against makemkv-oss 1.17.4:
Code: Select all
Index: 1.17.4/makemkvgui/src/api_posix.cpp
===================================================================
--- 1.17.4.orig/makemkvgui/src/api_posix.cpp 2023-05-29 22:06:31.000000000 +0100
+++ 1.17.4/makemkvgui/src/api_posix.cpp 2023-07-28 15:02:00.713239038 +0100
@@ -82,28 +82,8 @@
{
return -4;
}
- } else {
- char* p;
- int app_len;
-
- app_len = SYS_posix_getmyname(app_path,(int)(sizeof(app_path)-1));
- if (app_len<=0)
- {
- return -2;
- }
- app_path[app_len]=0;
- p=app_path+app_len;
- while(p!=app_path)
- {
- if(*p=='/')
- {
- p++;
- break;
- }
- p--;
- }
- strcpy(p,AppName);
- }
+ } else
+ strcpy(app_path, AppName);
strcpy(str_guiserver,"guiserver");
Index: 1.17.4/makemkvgui/src/spawn_posix.cpp
===================================================================
--- 1.17.4.orig/makemkvgui/src/spawn_posix.cpp 2023-05-29 22:06:31.000000000 +0100
+++ 1.17.4/makemkvgui/src/spawn_posix.cpp 2023-07-28 15:05:02.313416368 +0100
@@ -21,6 +21,7 @@
#include <sys/mman.h>
#include <fcntl.h>
#include <sys/time.h>
+#include <cstring>
#include <stdio.h>
#include <spawn.h>
#include <lgpl/sysabi.h>
@@ -100,7 +101,10 @@
}
}
- err = posix_spawn(&pid,argv[0],&spawn_actions,&spawn_attr,argv,envp);
+ if (strchr(argv[0], '/') != NULL)
+ err = posix_spawn(&pid,argv[0],&spawn_actions,&spawn_attr,argv,envp);
+ else
+ err = posix_spawnp(&pid,argv[0],&spawn_actions,&spawn_attr,argv,envp);
if (ppid)
{