💾 Archived View for gemini.rmf-dev.com › repo › Vaati › gmi_proxy › files › 042ec3fdb0c76e981aa4cf1a… captured on 2023-05-24 at 18:46:11. Gemini links have been rewritten to link to archived content

View Raw

More Information

⬅️ Previous capture (2023-04-19)

➡️ Next capture (2023-09-08)

-=-=-=-=-=-=-

0 /* See LICENSE file for copyright and license details. */

1

2 #ifdef sun

3

4 #include <priv.h>

5 #include <errno.h>

6

7 int

8 init_privs(const char **privs) {

9

10 int i = 0;

11

12 priv_set_t *pset;

13 if ((pset = priv_allocset()) == NULL) {

14 printf("priv_allocset: %s\n", strerror(errno));

15 return -1;

16 }

17 priv_emptyset(pset);

18 while (privs[i]) {

19 if (priv_addset(pset, privs[i]) != 0) {

20 printf("priv_addset: %s\n", strerror(errno));

21 return -1;

22 }

23 i++;

24 }

25 if (setppriv(PRIV_SET, PRIV_PERMITTED, pset) != 0 ||

26 setppriv(PRIV_SET, PRIV_LIMIT, pset) != 0 ||

27 setppriv(PRIV_SET, PRIV_INHERITABLE, pset) != 0) {

28 printf("setppriv: %s\n", strerror(errno));

29 return -1;

30 }

31 priv_freeset(pset);

32 return 0;

33 }

34

35 int sandbox() {

36 if (!path) return -1;

37 const char* privs[] = {

38 PRIV_NET_ACCESS,

39 PRIV_FILE_WRITE,

40 PRIV_FILE_READ,

41 NULL

42 };

43 if (init_privs(privs)) return -1;

44 return 0;

45 }

46 #else

47 typedef int hide_warning;

48 #endif

49