File tree Expand file tree Collapse file tree 2 files changed +18
-2
lines changed Expand file tree Collapse file tree 2 files changed +18
-2
lines changed Original file line number Diff line number Diff line change @@ -52,6 +52,7 @@ static struct su_initiator su_from = {
52
52
53
53
static struct su_request su_to = {
54
54
.uid = AID_ROOT ,
55
+ .login = 0 ,
55
56
.doshell = 1 ,
56
57
.command = DEFAULT_COMMAND ,
57
58
};
@@ -299,6 +300,17 @@ static void allow(char *shell, mode_t mask)
299
300
}
300
301
exe = strrchr (shell , '/' );
301
302
exe = (exe ) ? exe + 1 : shell ;
303
+ if (to -> login ) {
304
+ int s = strlen (exe ) + 2 ;
305
+ char * p = malloc (s );
306
+
307
+ if (!p )
308
+ exit (EXIT_FAILURE );
309
+
310
+ * p = '-' ;
311
+ strcpy (p + 1 , exe );
312
+ exe = p ;
313
+ }
302
314
if (setresgid (to -> uid , to -> uid , to -> uid )) {
303
315
PLOGE ("setresgid (%u)" , to -> uid );
304
316
exit (EXIT_FAILURE );
@@ -350,8 +362,10 @@ int main(int argc, char *argv[])
350
362
case 'h' :
351
363
usage (EXIT_SUCCESS );
352
364
break ;
353
- case 'l' : /* for compatibility */
354
- case 'm' :
365
+ case 'l' :
366
+ su_to .login = 1 ;
367
+ break ;
368
+ case 'm' : /* for compatibility */
355
369
case 'p' :
356
370
break ;
357
371
case 's' :
@@ -370,6 +384,7 @@ int main(int argc, char *argv[])
370
384
}
371
385
}
372
386
if (optind < argc && !strcmp (argv [optind ], "-" )) {
387
+ su_to .login = 1 ;
373
388
optind ++ ;
374
389
}
375
390
/*
Original file line number Diff line number Diff line change @@ -48,6 +48,7 @@ struct su_initiator {
48
48
49
49
struct su_request {
50
50
unsigned uid ;
51
+ int login ;
51
52
int doshell ;
52
53
char * command ;
53
54
};
You can’t perform that action at this time.
0 commit comments