|
@@ -119,11 +119,10 @@ init_cpu () |
|
|
|
|
|
|
|
|
#endif /* USE_DYNSIMD */ |
|
|
#endif /* USE_DYNSIMD */ |
|
|
|
|
|
|
|
|
char *jack_tmpdir = DEFAULT_TMP_DIR; |
|
|
|
|
|
|
|
|
|
|
|
static int |
|
|
|
|
|
|
|
|
const char * |
|
|
jack_get_tmpdir () |
|
|
jack_get_tmpdir () |
|
|
{ |
|
|
{ |
|
|
|
|
|
static char tmpdir[PATH_MAX + 1] = ""; |
|
|
FILE* in; |
|
|
FILE* in; |
|
|
size_t len; |
|
|
size_t len; |
|
|
char buf[PATH_MAX + 2]; /* allow tmpdir to live anywhere, plus newline, plus null */ |
|
|
char buf[PATH_MAX + 2]; /* allow tmpdir to live anywhere, plus newline, plus null */ |
|
@@ -131,6 +130,11 @@ jack_get_tmpdir () |
|
|
char *pathcopy; |
|
|
char *pathcopy; |
|
|
char *p; |
|
|
char *p; |
|
|
|
|
|
|
|
|
|
|
|
/* return tmpdir if set */ |
|
|
|
|
|
if (tmpdir[0] != '\0') { |
|
|
|
|
|
return tmpdir; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
/* some implementations of popen(3) close a security loophole by |
|
|
/* some implementations of popen(3) close a security loophole by |
|
|
resetting PATH for the exec'd command. since we *want* to |
|
|
resetting PATH for the exec'd command. since we *want* to |
|
|
use the user's PATH setting to locate jackd, we have to |
|
|
use the user's PATH setting to locate jackd, we have to |
|
@@ -138,13 +142,13 @@ jack_get_tmpdir () |
|
|
*/ |
|
|
*/ |
|
|
|
|
|
|
|
|
if ((pathenv = getenv ("PATH")) == 0) { |
|
|
if ((pathenv = getenv ("PATH")) == 0) { |
|
|
return -1; |
|
|
|
|
|
|
|
|
return NULL; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
/* don't let strtok(3) mess with the real environment variable */ |
|
|
/* don't let strtok(3) mess with the real environment variable */ |
|
|
|
|
|
|
|
|
if ((pathcopy = strdup (pathenv)) == NULL) { |
|
|
if ((pathcopy = strdup (pathenv)) == NULL) { |
|
|
return -1; |
|
|
|
|
|
|
|
|
return NULL; |
|
|
} |
|
|
} |
|
|
p = strtok (pathcopy, ":"); |
|
|
p = strtok (pathcopy, ":"); |
|
|
|
|
|
|
|
@@ -169,13 +173,13 @@ jack_get_tmpdir () |
|
|
if (p == NULL) { |
|
|
if (p == NULL) { |
|
|
/* no command successfully started */ |
|
|
/* no command successfully started */ |
|
|
free (pathcopy); |
|
|
free (pathcopy); |
|
|
return -1; |
|
|
|
|
|
|
|
|
return NULL; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
if (fgets (buf, sizeof(buf), in) == NULL) { |
|
|
if (fgets (buf, sizeof(buf), in) == NULL) { |
|
|
pclose (in); |
|
|
pclose (in); |
|
|
free (pathcopy); |
|
|
free (pathcopy); |
|
|
return -1; |
|
|
|
|
|
|
|
|
return NULL; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
len = strlen (buf); |
|
|
len = strlen (buf); |
|
@@ -184,21 +188,16 @@ jack_get_tmpdir () |
|
|
/* didn't get a whole line */ |
|
|
/* didn't get a whole line */ |
|
|
pclose (in); |
|
|
pclose (in); |
|
|
free (pathcopy); |
|
|
free (pathcopy); |
|
|
return -1; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if ((jack_tmpdir = (char*)malloc (len)) == NULL) { |
|
|
|
|
|
free (pathcopy); |
|
|
|
|
|
return -1; |
|
|
|
|
|
|
|
|
return NULL; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
memcpy (jack_tmpdir, buf, len - 1); |
|
|
|
|
|
jack_tmpdir[len - 1] = '\0'; |
|
|
|
|
|
|
|
|
memcpy (tmpdir, buf, len - 1); |
|
|
|
|
|
tmpdir[len - 1] = '\0'; |
|
|
|
|
|
|
|
|
pclose (in); |
|
|
pclose (in); |
|
|
free (pathcopy); |
|
|
free (pathcopy); |
|
|
|
|
|
|
|
|
return 0; |
|
|
|
|
|
|
|
|
return tmpdir; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
void |
|
|
void |
|
@@ -1260,7 +1259,7 @@ jack_client_open_aux (const char *client_name, |
|
|
/* External clients need to know where the tmpdir used for |
|
|
/* External clients need to know where the tmpdir used for |
|
|
communication with the server lives |
|
|
communication with the server lives |
|
|
*/ |
|
|
*/ |
|
|
if (jack_get_tmpdir ()) { |
|
|
|
|
|
|
|
|
if (jack_get_tmpdir () == NULL) { |
|
|
*status |= JackFailure; |
|
|
*status |= JackFailure; |
|
|
jack_messagebuffer_exit (); |
|
|
jack_messagebuffer_exit (); |
|
|
return NULL; |
|
|
return NULL; |
|
@@ -1458,15 +1457,24 @@ char * |
|
|
jack_user_dir (void) |
|
|
jack_user_dir (void) |
|
|
{ |
|
|
{ |
|
|
static char user_dir[PATH_MAX + 1] = ""; |
|
|
static char user_dir[PATH_MAX + 1] = ""; |
|
|
|
|
|
const char *tmpdir; |
|
|
|
|
|
|
|
|
/* format the path name on the first call */ |
|
|
/* format the path name on the first call */ |
|
|
if (user_dir[0] == '\0') { |
|
|
if (user_dir[0] == '\0') { |
|
|
|
|
|
tmpdir = jack_get_tmpdir (); |
|
|
|
|
|
|
|
|
|
|
|
/* previous behavior of jack_tmpdir, should be changed later */ |
|
|
|
|
|
if (tmpdir == NULL) { |
|
|
|
|
|
jack_error ("Unable to get tmpdir in user dir"); |
|
|
|
|
|
tmpdir = DEFAULT_TMP_DIR; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
if (getenv ("JACK_PROMISCUOUS_SERVER")) { |
|
|
if (getenv ("JACK_PROMISCUOUS_SERVER")) { |
|
|
snprintf (user_dir, sizeof(user_dir), "%s/jack", |
|
|
snprintf (user_dir, sizeof(user_dir), "%s/jack", |
|
|
jack_tmpdir); |
|
|
|
|
|
|
|
|
tmpdir); |
|
|
} else { |
|
|
} else { |
|
|
snprintf (user_dir, sizeof(user_dir), "%s/jack-%d", |
|
|
snprintf (user_dir, sizeof(user_dir), "%s/jack-%d", |
|
|
jack_tmpdir, getuid ()); |
|
|
|
|
|
|
|
|
tmpdir, getuid ()); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|