Skip to content

Commit 5b0b101

Browse files
committed
res_phreaknet: Include full path to astgenkey for ast_safe_execvp.
For some reason, this seems to be required on some systems, so include it for better compatibility.
1 parent c44b51f commit 5b0b101

1 file changed

Lines changed: 9 additions & 2 deletions

File tree

res/res_phreaknet.c

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1141,12 +1141,19 @@ static int gen_keypair(int rotate)
11411141
}
11421142

11431143
/* Generate the new keypair, and wait for it to finish. */
1144-
ast_debug(3, "Executing: astgenkey -q -n %s\n", tempkeyprefix);
1145-
if (ast_safe_execvp(0, "astgenkey", argv) == -1) {
1144+
ast_debug(3, "Executing: /usr/sbin/astgenkey -q -n %s\n", tempkeyprefix);
1145+
if (ast_safe_execvp(0, "/usr/sbin/astgenkey", argv) == -1) { /* On some systems, we need to include the full path here for this to work */
11461146
ast_log(LOG_WARNING, "Failed to execute astgenkey: %s\n", strerror(errno));
11471147
return -1;
11481148
} else if (stat(tempkeypriv, &st)) {
1149+
char tempkeydir[2048];
11491150
ast_log(LOG_WARNING, "Failed to stat %s: %s\n", tempkeypriv, strerror(errno));
1151+
snprintf(tempkeydir, sizeof(tempkeydir), "%s/tmp", ast_config_AST_SPOOL_DIR);
1152+
/* If the directory is not writable, that's probably why we failed to create the key */
1153+
if (eaccess(tempkeydir, W_OK)) {
1154+
ast_log(LOG_ERROR, "%s is not writable\n", tempkeydir);
1155+
return -1;
1156+
}
11501157
return -1;
11511158
}
11521159

0 commit comments

Comments
 (0)