Overview
Comment: | fix longstanding and COMPLETELY IDIOTIC bugs in xpriv. how fucking high was i when i wrote this shit!??? |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA3-256: |
33d1991a4dae045b02de707f5cdff1d0 |
User & Date: | lexi on 2019-08-08 00:09:30 |
Other Links: | manifest | tags |
Context
2019-08-13
| ||
02:28 | add missing --nocopy option to mkpw check-in: 61813b7d9b user: lexi tags: trunk | |
2019-08-08
| ||
00:09 | fix longstanding and COMPLETELY IDIOTIC bugs in xpriv. how fucking high was i when i wrote this shit!??? check-in: 33d1991a4d user: lexi tags: trunk | |
2019-08-07
| ||
09:47 | add further wrappings to nkvd.c; nearly works with alpine now check-in: dc9aa070c7 user: lexi tags: trunk | |
Changes
Modified xpriv.c from [48a3d17a7c] to [7043c5d202].
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));