util  Diff

Differences From Artifact [6fd3f35c89]:

To Artifact [6971590b48]:


     1      1   /* [ʞ] nkvd.c - XDG directory enforcer
     2      2    *  ~ lexi hale  <lexi@hale.su>
     3      3    *  © AGPLv3
     4         - *  $ cc -fPIC -pie nkvd.c -Wl,-E -onkvd -ldl
            4  + *  $ cc -fPIC -pie -shared nkvd.c -Wl,-E -onkvd -ldl
     5      5    *       [-D_NO_GNU [-D_LIBC=…]] [-D_CONF_HOME=…]
     6      6    *  $ export LD_PRELOAD=nkvd.so <dissident>
     7      7    *
     8      8    *  ! NOTE:  for unknown reasons,  nkvd currently only works
     9      9    *    when  built without optimizations.  it's probably that
    10     10    *    wrecker Trotsky's fault. i'm working on it.
    11     11    *    - partial solution on GCC: using #pragma to disable
    12     12    *      optimization around the sensitive code. unclear if
    13     13    *      this bug affects other compilers.
    14     14    *    - bizarre complication: the bug can only be reproduced
    15     15    *      if  the -O flag  itself is present;  turning on  the 
    16     16    *      same  individual  optimization flags that  -O<x>  is 
    17     17    *      supposed to represent does not trigger the problem.
    18         - *    - conclusion: compiler devils.
           18  + *    - conclusion: compiler devils
    19     19    *
    20     20    *  ! WARNING: test this program thoroughly before you start
    21     21    *    exporting it from your shellrcs; if things get fucked,
    22     22    *    you  may not be able to execute any binaries with  the
    23     23    *    variable set,  and will need to log in as root or boot
    24     24    *    off  a rescue disk  to fix the problem.  LD_PRELOAD is
    25     25    *    not a toy. you have been warned.
................................................................................
   134    134   #		define SYMSRC RTLD_NEXT
   135    135   #	else
   136    136   #		define SYMSRC hnd
   137    137   #	endif
   138    138   #endif
   139    139   #include <string.h>
   140    140   #include <dlfcn.h>
   141         -#include <stdio.h>
   142    141   
   143    142   #ifndef _LIBC
   144    143   #	define _LIBC "libc.so.6"
   145    144   #endif
   146    145   
   147    146   #ifndef _CONF_HOME
   148    147   #	define _CONF_HOME ".config"
   149    148   #endif
   150         -
   151    149   
   152    150   #define pstr(x) x,sizeof x
   153    151   #define hl(txt) "\x1b[1;31m" txt "\x1b[m"
   154    152   #define bold(txt) "\x1b[1m" txt "\x1b[21m"
   155    153   #define e_fatal hl("(nkvd fatal)") " "
   156    154   #define fail(code, err) { write(2,pstr(e_fatal " " err)); _exit(code); }
   157    155   #define dbg(x) write(2,pstr(bold("(nkvd)") " " x))