qrexec: don't wait indefinitely if the daemon startup failed
Count started children and if the last one exits before getting SIGUSR1 (confirmation of successful daemon startup) report failure.
This commit is contained in:
parent
9f62349732
commit
ce971eaa54
@ -61,12 +61,28 @@ char *default_user = "user";
|
|||||||
char default_user_keyword[] = "DEFAULT:";
|
char default_user_keyword[] = "DEFAULT:";
|
||||||
#define default_user_keyword_len_without_colon (sizeof(default_user_keyword)-2)
|
#define default_user_keyword_len_without_colon (sizeof(default_user_keyword)-2)
|
||||||
|
|
||||||
|
/*
|
||||||
|
we need to track the number of children, so that excessive QREXEC_EXECUTE_*
|
||||||
|
commands do not fork-bomb dom0
|
||||||
|
*/
|
||||||
|
int children_count;
|
||||||
|
|
||||||
void sigusr1_handler(int x)
|
void sigusr1_handler(int x)
|
||||||
{
|
{
|
||||||
fprintf(stderr, "connected\n");
|
fprintf(stderr, "connected\n");
|
||||||
exit(0);
|
exit(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void sigchld_parent_handler(int x)
|
||||||
|
{
|
||||||
|
children_count--;
|
||||||
|
/* starting value is 0 so we see dead real qrexec-daemon as -1 */
|
||||||
|
if (children_count < 0) {
|
||||||
|
fprintf(stderr, "failed\n");
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void sigchld_handler(int x);
|
void sigchld_handler(int x);
|
||||||
|
|
||||||
char *remote_domain_name; // guess what
|
char *remote_domain_name; // guess what
|
||||||
@ -103,6 +119,7 @@ int ask_on_connect_timeout(int xid, int timeout)
|
|||||||
remote_domain_name, timeout);
|
remote_domain_name, timeout);
|
||||||
#undef KDIALOG_CMD
|
#undef KDIALOG_CMD
|
||||||
#undef ZENITY_CMD
|
#undef ZENITY_CMD
|
||||||
|
children_count++;
|
||||||
ret = system(text);
|
ret = system(text);
|
||||||
ret = WEXITSTATUS(ret);
|
ret = WEXITSTATUS(ret);
|
||||||
// fprintf(stderr, "ret=%d\n", ret);
|
// fprintf(stderr, "ret=%d\n", ret);
|
||||||
@ -140,6 +157,7 @@ void init(int xid)
|
|||||||
startup_timeout = MAX_STARTUP_TIME_DEFAULT;
|
startup_timeout = MAX_STARTUP_TIME_DEFAULT;
|
||||||
}
|
}
|
||||||
signal(SIGUSR1, sigusr1_handler);
|
signal(SIGUSR1, sigusr1_handler);
|
||||||
|
signal(SIGCHLD, sigchld_parent_handler);
|
||||||
switch (pid=fork()) {
|
switch (pid=fork()) {
|
||||||
case -1:
|
case -1:
|
||||||
perror("fork");
|
perror("fork");
|
||||||
@ -210,12 +228,6 @@ void handle_new_client()
|
|||||||
max_client_fd = fd;
|
max_client_fd = fd;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
we need to track the number of children, so that excessive QREXEC_EXECUTE_*
|
|
||||||
commands do not fork-bomb dom0
|
|
||||||
*/
|
|
||||||
int children_count;
|
|
||||||
|
|
||||||
void terminate_client_and_flush_data(int fd)
|
void terminate_client_and_flush_data(int fd)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
Loading…
Reference in New Issue
Block a user