sandbox_create.libos.c 937 B

1234567891011121314151617181920212223242526272829303132333435
  1. /* -*- mode:c; c-file-style:"k&r"; c-basic-offset: 4; tab-width:4; indent-tabs-mode:nil; mode:auto-fill; fill-column:78; -*- */
  2. /* vim: set ts=4 sw=4 et tw=78 fo=cqt wm=0: */
  3. #include <stdlib.h>
  4. #include <unistd.h>
  5. #include <stdio.h>
  6. #include <sys/stat.h>
  7. #include <arpa/inet.h>
  8. #include <shim_unistd.h>
  9. int main(int argc, char ** argv)
  10. {
  11. mkdir("test_sandbox", 0700);
  12. struct sockaddr_in addr;
  13. addr.sin_family = AF_INET;
  14. inet_pton(AF_INET, "127.0.0.1", &addr.sin_addr);
  15. addr.sin_port = htons(8000);
  16. struct net_sb net_sb;
  17. struct net_sb_rule net_sb_rule;
  18. net_sb.nrules = 1;
  19. net_sb.rules = &net_sb_rule;
  20. net_sb_rule.l_addrlen = 0;
  21. net_sb_rule.l_addr = NULL;
  22. net_sb_rule.r_addrlen = sizeof(struct sockaddr_in);
  23. net_sb_rule.r_addr = (void *) &addr;
  24. sandbox_create(SANDBOX_FS|SANDBOX_NET|SANDBOX_RPC,
  25. "test_sandbox",
  26. &net_sb);
  27. return 0;
  28. }