You've already forked macports-base
mirror of
https://github.com/macports/macports-base.git
synced 2026-07-12 18:18:43 -07:00
tracelib: allow access to trace socket by any user
There are some operations that depend on filesystem permissions and are run under trace mode; for example, at the end of the install section, MacPorts attempts to call git rev-parse on the port's path, and in order to prevent git from refusing to work on a directory not owned by the user it is running as, drops privileges to whoever owns the copy of the ports tree. When running under trace mode, this means the git process will run as a user that might not normally be able to connect to the trace socket, which leads to the traced git process calling abort() in the inserted darwintrace.dylib library. This isn't really necessary, since it's perfectly fine for this process to connect to the tracing socket, too — we just need to make sure the permissions of the socket on the filesystem allow for that. Add a chmod() to change permissions to 0o777 to support this. This fixes crashes during the install phase when port trees aren't owned by root or the macports user.
This commit is contained in:
committed by
Clemens Lang
parent
6dda4cc6c0
commit
6beaf1e6a5
@@ -85,7 +85,7 @@ static void peerpid_list_walk(bool (*callback)(int sock, pid_t pid, const char *
|
||||
#endif /* defined(HAVE_PEERPID_LIST) */
|
||||
|
||||
|
||||
static char *name;
|
||||
static char *name = NULL;
|
||||
static char *sandbox;
|
||||
static size_t sandboxLength;
|
||||
static char **depends = NULL;
|
||||
@@ -685,6 +685,11 @@ static void dep_check(int sock, char *path) {
|
||||
static int TracelibOpenSocketCmd(Tcl_Interp *in) {
|
||||
struct sockaddr_un sun;
|
||||
|
||||
if (name == NULL) {
|
||||
Tcl_SetResult(in, "tracelib opensocket called without first calling tracelib setname", TCL_STATIC);
|
||||
return TCL_ERROR;
|
||||
}
|
||||
|
||||
if (-1 == (sock = socket(PF_LOCAL, SOCK_STREAM, 0))) {
|
||||
return error2tcl("socket: ", errno, in);
|
||||
}
|
||||
@@ -699,6 +704,12 @@ static int TracelibOpenSocketCmd(Tcl_Interp *in) {
|
||||
return error2tcl("bind: ", err, in);
|
||||
}
|
||||
|
||||
if (-1 == chmod(name, 0777)) {
|
||||
/* We create this socket as root, but want non-root users to be able to
|
||||
* connect. */
|
||||
return error2tcl("chmod: ", errno, in);
|
||||
}
|
||||
|
||||
if (-1 == listen(sock, SOMAXCONN)) {
|
||||
int err = errno;
|
||||
close(sock);
|
||||
|
||||
Reference in New Issue
Block a user