From 0ac0c7fcee1dcbc6235718b1b1fcf90131811973 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Marczykowski-G=C3=B3recki?= Date: Thu, 17 Oct 2013 21:19:36 +0200 Subject: [PATCH] shmoverride: don't override shm.id file When starting a second Xorg instance, don't override shm.id from the first one. This can happen when the user tries to generate xorg.conf (X -configure), or accidentally clicks "switch user". --- shmoverride/shmoverride.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/shmoverride/shmoverride.c b/shmoverride/shmoverride.c index 0d66e4fa..e5627891 100644 --- a/shmoverride/shmoverride.c +++ b/shmoverride/shmoverride.c @@ -125,10 +125,11 @@ int __attribute__ ((constructor)) initfunc() perror("shmoverride xc_interface_open"); return 0; //allow it to run when not under Xen } - idfd = open(SHMID_FILENAME, O_WRONLY | O_CREAT, 0600); + idfd = open(SHMID_FILENAME, O_WRONLY | O_CREAT | O_EXCL, 0600); if (idfd < 0) { perror("shmoverride creating " SHMID_FILENAME); - exit(1); + xc_interface_close(xc_hnd); + return 0; } local_shmid = shmget(IPC_PRIVATE, SHM_CMD_NUM_PAGES * 4096,