Merge remote-tracking branch 'origin/pr/192'
* origin/pr/192: vm-file-editor: drop old wait-for-session mechanism qubes.WaitForSession: refactor by waiting for qrexec-fork-server socket
This commit is contained in:
commit
01aa61521b
@ -1,16 +1,8 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
|
||||||
# old API - get the user from caller
|
USERNAME="$(qubesdb-read /default-user || echo 'user')"
|
||||||
#read -r IGNORE_USERNAME
|
|
||||||
|
|
||||||
# use default user provided in QubesDB, or hardcoded 'user' - this must be the
|
while ! [ -e "/var/run/qubes/qrexec-server.$USERNAME.sock" ]
|
||||||
# same as the X session owner
|
do
|
||||||
USERNAME=$(qubesdb-read /default-user || echo 'user')
|
sleep 0.1
|
||||||
cmd='echo $$ >> /tmp/qubes-session-waiter; [ ! -f /tmp/qubes-session-env ] && exec sleep inf'
|
done
|
||||||
if [ "$(id -un)" = "$USERNAME" ]; then
|
|
||||||
sh -c "$cmd" 2>/dev/null
|
|
||||||
else
|
|
||||||
su -s /bin/sh -c "$cmd" - "$USERNAME" 2> /dev/null
|
|
||||||
fi
|
|
||||||
# the above line is _expected_ to be terminated by a signal, don't treat this as a failure
|
|
||||||
exit 0
|
|
||||||
|
@ -147,11 +147,10 @@ void send_file_back(const char * filename)
|
|||||||
int
|
int
|
||||||
main()
|
main()
|
||||||
{
|
{
|
||||||
struct stat stat_pre, stat_post, session_stat;
|
struct stat stat_pre, stat_post;
|
||||||
int view_only = 0;
|
int view_only = 0;
|
||||||
char *filename = get_filename(&view_only);
|
char *filename = get_filename(&view_only);
|
||||||
int child, status, log_fd, null_fd;
|
int child, status, log_fd, null_fd;
|
||||||
FILE *waiter_pidfile;
|
|
||||||
|
|
||||||
copy_file_by_name(filename);
|
copy_file_by_name(filename);
|
||||||
if (view_only) {
|
if (view_only) {
|
||||||
@ -162,37 +161,7 @@ main()
|
|||||||
perror("stat pre");
|
perror("stat pre");
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
#ifdef DEBUG
|
|
||||||
fprintf(stderr, "time=%s, waiting for qubes-session\n", gettime());
|
|
||||||
#endif
|
|
||||||
// wait for X server to starts (especially in DispVM)
|
|
||||||
if (stat("/tmp/qubes-session-env", &session_stat)) {
|
|
||||||
switch (child = fork()) {
|
|
||||||
case -1:
|
|
||||||
perror("fork");
|
|
||||||
exit(1);
|
|
||||||
case 0:
|
|
||||||
waiter_pidfile = fopen("/tmp/qubes-session-waiter", "a");
|
|
||||||
if (waiter_pidfile == NULL) {
|
|
||||||
perror("fopen waiter_pidfile");
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
fprintf(waiter_pidfile, "%d\n", getpid());
|
|
||||||
fclose(waiter_pidfile);
|
|
||||||
// check the second time, to prevent race
|
|
||||||
if (stat("/tmp/qubes-session-env", &session_stat)) {
|
|
||||||
// wait for qubes-session notify
|
|
||||||
pause();
|
|
||||||
}
|
|
||||||
exit(0);
|
|
||||||
default:
|
|
||||||
waitpid(child, &status, 0);
|
|
||||||
if (WIFEXITED(status) && WEXITSTATUS(status) != 0) {
|
|
||||||
//propagate exit code from child
|
|
||||||
exit(WEXITSTATUS(status));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
fprintf(stderr, "time=%s, starting editor\n", gettime());
|
fprintf(stderr, "time=%s, starting editor\n", gettime());
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
Reference in New Issue
Block a user