@@ -59,7 +59,6 @@ static int from_init(struct su_initiator *from)
5959 ssize_t len ;
6060 int i ;
6161 int err ;
62- size_t j ;
6362
6463 from -> uid = getuid ();
6564 from -> pid = getppid ();
@@ -114,31 +113,6 @@ static int from_init(struct su_initiator *from)
114113 strncpy (from -> bin , argv0 , sizeof (from -> bin ));
115114 from -> bin [sizeof (from -> bin )- 1 ] = '\0' ;
116115
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 :
142116 return 0 ;
143117}
144118
@@ -307,7 +281,6 @@ static void deny(const struct su_context *ctx)
307281static void allow (const struct su_context * ctx )
308282{
309283 char * arg0 ;
310- char * const * envp = environ ;
311284 int argc , err ;
312285
313286 umask (ctx -> umask );
@@ -326,9 +299,6 @@ static void allow(const struct su_context *ctx)
326299 strcpy (p + 1 , arg0 );
327300 arg0 = p ;
328301 }
329- if (ctx -> from .envp [0 ]) {
330- envp = ctx -> from .envp ;
331- }
332302 if (setresgid (ctx -> to .uid , ctx -> to .uid , ctx -> to .uid )) {
333303 PLOGE ("setresgid (%u)" , ctx -> to .uid );
334304 exit (EXIT_FAILURE );
@@ -354,7 +324,7 @@ static void allow(const struct su_context *ctx)
354324 ctx -> to .argv [-- argc ] = "-c" ;
355325 }
356326 ctx -> to .argv [-- argc ] = arg0 ;
357- execve (ctx -> to .shell , ctx -> to .argv + argc , envp );
327+ execv (ctx -> to .shell , ctx -> to .argv + argc );
358328 err = errno ;
359329 PLOGE ("exec" );
360330 fprintf (stderr , "Cannot execute %s: %s\n" , ctx -> to .shell , strerror (err ));
@@ -369,8 +339,6 @@ int main(int argc, char *argv[])
369339 .uid = 0 ,
370340 .bin = "" ,
371341 .args = "" ,
372- .env = "" ,
373- .envp = { NULL },
374342 },
375343 .to = {
376344 .uid = AID_ROOT ,
0 commit comments