Differences From
Artifact [48a3d17a7c]:
- File
xpriv.c
— part of check-in
[6a14de1811]
at
2019-07-20 23:37:03
on branch trunk
— udpate xpriv to use sysv shmem by default; give iaia an option to generate its own types, and allow selecting between 7-bit and 8-bit encodings for ascii (defaulting to 8-bit); update mkpw to work with new iaia; update ord to add flag controlling byte length (7 or 8) for iaia's ascii mode
(user:
lexi,
size: 13336)
[annotate]
[blame]
[check-ins using]
269 269 /* messy part */
270 270 const char* tmp; //tmpdir defined?
271 271 if (!(tmp = getenv("XDG_RUNTIME_DIR")))
272 272 if (!(tmp = getenv("TMPDIR"))) tmp = "/tmp";
273 273
274 274 size_t tmpsz = strlen(tmp);
275 275
276 - char sockn[tmpsz + 1 + sizeof "ssh."
277 - + 11];
276 + char* sockn = malloc(tmpsz + 1 + sizeof "ssh." + 11);
278 277 strcpy(sockn, tmp);
279 278 sockn[tmpsz] = '/';
280 279 strcpy(sockn+tmpsz+1,"ssh.");
281 280
282 281 // first, gen a random identifier so we have the ability
283 282 // to know where the socket winds up
284 283 uint8_t* rndid = sockn+tmpsz+1+4;
................................................................................
339 338 s -> op = mode_kill;
340 339 kill(s -> pid, SIGUSR1);
341 340
342 341 return ok;
343 342 }
344 343 enum res activate_window(Window w) {
345 344 Display* dpy = XOpenDisplay(NULL);
346 - XEvent ev;
347 345 long mask = SubstructureRedirectMask | SubstructureNotifyMask;
348 - ev.xclient.type = ClientMessage;
349 - ev.xclient.serial = 0;
350 - ev.xclient.send_event = True;
351 - ev.xclient.message_type = XInternAtom(dpy, "_NET_ACTIVE_WINDOW", False);
352 - ev.xclient.display = dpy;
353 - ev.xclient.window = w;
354 - ev.xclient.format = 32;
355 - ev.xclient.data.l[0] = 2;
356 - ev.xclient.data.l[1] = CurrentTime;
357 - ev.xclient.data.l[2] = 0;
346 + XEvent ev = {
347 + .xclient.type = ClientMessage,
348 + .xclient.serial = 0,
349 + .xclient.send_event = True,
350 + .xclient.message_type = XInternAtom(dpy, "_NET_ACTIVE_WINDOW", False),
351 + .xclient.display = dpy,
352 + .xclient.window = w,
353 + .xclient.format = 32,
354 + .xclient.data.l[0] = 2,
355 + .xclient.data.l[1] = CurrentTime,
356 + .xclient.data.l[2] = 0,
357 + };
358 358
359 359 if(!XSendEvent(dpy, DefaultRootWindow(dpy), False, mask, &ev)) return fail_x11;
360 360
361 361 XSync(dpy,false);
362 362 return ok;
363 363 }
364 364
................................................................................
424 424 if (init_named != NULL) {
425 425 args[argsz - 3] = "-n"; // im sorry
426 426 args[argsz - 2] = init_named;
427 427 }
428 428
429 429 execvp("urxvtc", (char* const*)args);
430 430 } else {
431 - struct signal*s = shmlinux(
432 - mmap(0, sizeof(struct signal), PROT_READ | PROT_WRITE, MAP_SHARED, shm, 0)
433 - ) shmsysv (
434 - shmat(shm, 0, 0)
435 - );
436 -
437 431 struct shmid_ds stat;
438 432 shmctl(shm, IPC_STAT, &stat);
439 433 if (stat.shm_nattch == 0) {
440 434 /* if the shm segment is not attached to any
441 435 * process, it's a relic that needs to be
442 436 * cleaned up before we do anything else. on
443 437 * a sane OS, there would be built-in non-
444 438 * persistence mechanisms for shared mem, but
445 439 * alas, as you already know, POSIX */
446 440 shmctl(shm, IPC_RMID, &stat);
447 441 goto tryagain;
448 442 }
443 +
444 + struct signal*s = shmlinux(
445 + mmap(0, sizeof(struct signal), PROT_READ | PROT_WRITE, MAP_SHARED, shm, 0)
446 + ) shmsysv (
447 + shmat(shm, 0, 0)
448 + );
449 449
450 450 if (s == shmlinux(MAP_FAILED) shmsysv((void*)-1))
451 451 return bad(fail_mem);
452 452 return bad(activate_window(s->wid));
453 453 }
454 454 } else if (op == mode_register)
455 455 return bad(register_window(shmlinux(shid,) init_weak,init_named));