util  Diff

Differences From Artifact [6fd3f35c89]:

To Artifact [6971590b48]:


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

#ifndef _LIBC
#	define _LIBC "libc.so.6"
#endif

#ifndef _CONF_HOME
#	define _CONF_HOME ".config"
#endif


#define pstr(x) x,sizeof x
#define hl(txt) "\x1b[1;31m" txt "\x1b[m"
#define bold(txt) "\x1b[1m" txt "\x1b[21m"
#define e_fatal hl("(nkvd fatal)") " "
#define fail(code, err) { write(2,pstr(e_fatal " " err)); _exit(code); }
#define dbg(x) write(2,pstr(bold("(nkvd)") " " x))



|













|







 







<








<







1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
...
134
135
136
137
138
139
140

141
142
143
144
145
146
147
148

149
150
151
152
153
154
155
/* [ʞ] nkvd.c - XDG directory enforcer
 *  ~ lexi hale  <lexi@hale.su>
 *  © AGPLv3
 *  $ cc -fPIC -pie -shared nkvd.c -Wl,-E -onkvd -ldl
 *       [-D_NO_GNU [-D_LIBC=…]] [-D_CONF_HOME=…]
 *  $ export LD_PRELOAD=nkvd.so <dissident>
 *
 *  ! NOTE:  for unknown reasons,  nkvd currently only works
 *    when  built without optimizations.  it's probably that
 *    wrecker Trotsky's fault. i'm working on it.
 *    - partial solution on GCC: using #pragma to disable
 *      optimization around the sensitive code. unclear if
 *      this bug affects other compilers.
 *    - bizarre complication: the bug can only be reproduced
 *      if  the -O flag  itself is present;  turning on  the 
 *      same  individual  optimization flags that  -O<x>  is 
 *      supposed to represent does not trigger the problem.
 *    - conclusion: compiler devils
 *
 *  ! WARNING: test this program thoroughly before you start
 *    exporting it from your shellrcs; if things get fucked,
 *    you  may not be able to execute any binaries with  the
 *    variable set,  and will need to log in as root or boot
 *    off  a rescue disk  to fix the problem.  LD_PRELOAD is
 *    not a toy. you have been warned.
................................................................................
#		define SYMSRC RTLD_NEXT
#	else
#		define SYMSRC hnd
#	endif
#endif
#include <string.h>
#include <dlfcn.h>


#ifndef _LIBC
#	define _LIBC "libc.so.6"
#endif

#ifndef _CONF_HOME
#	define _CONF_HOME ".config"
#endif


#define pstr(x) x,sizeof x
#define hl(txt) "\x1b[1;31m" txt "\x1b[m"
#define bold(txt) "\x1b[1m" txt "\x1b[21m"
#define e_fatal hl("(nkvd fatal)") " "
#define fail(code, err) { write(2,pstr(e_fatal " " err)); _exit(code); }
#define dbg(x) write(2,pstr(bold("(nkvd)") " " x))