summaryrefslogtreecommitdiff
path: root/sub/busybox/bbsuid-footer
blob: 699c6f887eeb62b7bc2b4369dab00ef5848a18f5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
} ;

static int okay (char const *s)
{
  register char const **p = list ;
  for (; *p ; p++) if (!str_diff(s, *p)) return 1 ;
  return 0 ;
}

int main (int argc, char const *const *argv, char const *const *envp)
{
  stralloc sa = STRALLOC_ZERO ;
  PROG = "busybox-setuid" ;
  if (!sabasename(&sa, argv[0], str_len(argv[0])))
    strerr_diefu2sys(111, "sabasename", argv[0]) ;
  if (!stralloc_0(&sa)) strerr_diefu1sys(111, "stralloc_0") ;
  if (!okay(sa.s)) strerr_dief2x(100, sa.s, " is not granted root privileges") ;
  stralloc_free(&sa) ;
  execve("/bin/busybox", (char *const *)argv, (char *const *)envp) ;
  strerr_dieexec(111, "/bin/busybox") ;
}