@@ -59,7 +59,6 @@ static int from_init(struct su_initiator *from)
59
59
ssize_t len ;
60
60
int i ;
61
61
int err ;
62
- size_t j ;
63
62
64
63
from -> uid = getuid ();
65
64
from -> pid = getppid ();
@@ -114,31 +113,6 @@ static int from_init(struct su_initiator *from)
114
113
strncpy (from -> bin , argv0 , sizeof (from -> bin ));
115
114
from -> bin [sizeof (from -> bin )- 1 ] = '\0' ;
116
115
117
- /* Get the environment of the calling process */
118
- snprintf (path , sizeof (path ), "/proc/%u/environ" , from -> pid );
119
- fd = open (path , O_RDONLY );
120
- if (fd < 0 ) {
121
- PLOGE ("Opening environment" );
122
- goto out ;
123
- }
124
- len = read (fd , from -> env , sizeof (from -> env ));
125
- err = errno ;
126
- close (fd );
127
- if (len < 0 || len == sizeof (from -> env )) {
128
- PLOGEV ("Reading environment" , err );
129
- goto out ;
130
- }
131
- from -> env [len ] = '\0' ;
132
-
133
- from -> envp [0 ] = & from -> env [0 ];
134
- for (i = 0 , j = 0 ; i < len && j < ARRAY_SIZE (from -> envp ); i ++ ) {
135
- if (from -> env [i ] == '\0' ) {
136
- from -> envp [++ j ] = & from -> env [i + 1 ];
137
- }
138
- }
139
- from -> envp [j ] = NULL ;
140
-
141
- out :
142
116
return 0 ;
143
117
}
144
118
@@ -307,7 +281,6 @@ static void deny(const struct su_context *ctx)
307
281
static void allow (const struct su_context * ctx )
308
282
{
309
283
char * arg0 ;
310
- char * const * envp = environ ;
311
284
int argc , err ;
312
285
313
286
umask (ctx -> umask );
@@ -326,9 +299,6 @@ static void allow(const struct su_context *ctx)
326
299
strcpy (p + 1 , arg0 );
327
300
arg0 = p ;
328
301
}
329
- if (ctx -> from .envp [0 ]) {
330
- envp = ctx -> from .envp ;
331
- }
332
302
if (setresgid (ctx -> to .uid , ctx -> to .uid , ctx -> to .uid )) {
333
303
PLOGE ("setresgid (%u)" , ctx -> to .uid );
334
304
exit (EXIT_FAILURE );
@@ -354,7 +324,7 @@ static void allow(const struct su_context *ctx)
354
324
ctx -> to .argv [-- argc ] = "-c" ;
355
325
}
356
326
ctx -> to .argv [-- argc ] = arg0 ;
357
- execve (ctx -> to .shell , ctx -> to .argv + argc , envp );
327
+ execv (ctx -> to .shell , ctx -> to .argv + argc );
358
328
err = errno ;
359
329
PLOGE ("exec" );
360
330
fprintf (stderr , "Cannot execute %s: %s\n" , ctx -> to .shell , strerror (err ));
@@ -369,8 +339,6 @@ int main(int argc, char *argv[])
369
339
.uid = 0 ,
370
340
.bin = "" ,
371
341
.args = "" ,
372
- .env = "" ,
373
- .envp = { NULL },
374
342
},
375
343
.to = {
376
344
.uid = AID_ROOT ,
0 commit comments