Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(414)

Side by Side Diff: experimental/webtry/main.cpp

Issue 555993002: disable webtry seccmp on non-linux build (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: rename safety flag to make it more clear what's going on Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | experimental/webtry/seccomp_bpf.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #include <sys/time.h> 1 #include <sys/time.h>
2 #include <sys/resource.h> 2 #include <sys/resource.h>
3 3
4 #include "SkCanvas.h" 4 #include "SkCanvas.h"
5 #include "SkCommandLineFlags.h" 5 #include "SkCommandLineFlags.h"
6 #include "SkData.h" 6 #include "SkData.h"
7 #include "SkForceLinking.h" 7 #include "SkForceLinking.h"
8 #include "SkGraphics.h" 8 #include "SkGraphics.h"
9 #include "SkImageDecoder.h" 9 #include "SkImageDecoder.h"
10 #include "SkImageEncoder.h" 10 #include "SkImageEncoder.h"
11 #include "SkImageInfo.h" 11 #include "SkImageInfo.h"
12 #include "SkStream.h" 12 #include "SkStream.h"
13 #include "SkSurface.h" 13 #include "SkSurface.h"
14 14
15 #include "seccomp_bpf.h" 15 #include "seccomp_bpf.h"
16 16
17 __SK_FORCE_IMAGE_DECODER_LINKING; 17 __SK_FORCE_IMAGE_DECODER_LINKING;
18 18
19 DEFINE_string(out, "", "Filename of the PNG to write to."); 19 DEFINE_string(out, "", "Filename of the PNG to write to.");
20 DEFINE_string(source, "", "Filename of the source image."); 20 DEFINE_string(source, "", "Filename of the source image.");
21 21
22 // Defined in template.cpp. 22 // Defined in template.cpp.
23 extern SkBitmap source; 23 extern SkBitmap source;
24 24
25 static bool install_syscall_filter() { 25 static bool install_syscall_filter() {
26
27 #ifndef SK_UNSAFE_BUILD_DESKTOP_ONLY
26 struct sock_filter filter[] = { 28 struct sock_filter filter[] = {
27 /* Grab the system call number. */ 29 /* Grab the system call number. */
28 EXAMINE_SYSCALL, 30 EXAMINE_SYSCALL,
29 /* List allowed syscalls. */ 31 /* List allowed syscalls. */
30 ALLOW_SYSCALL(exit_group), 32 ALLOW_SYSCALL(exit_group),
31 ALLOW_SYSCALL(exit), 33 ALLOW_SYSCALL(exit),
32 ALLOW_SYSCALL(fstat), 34 ALLOW_SYSCALL(fstat),
33 ALLOW_SYSCALL(read), 35 ALLOW_SYSCALL(read),
34 ALLOW_SYSCALL(write), 36 ALLOW_SYSCALL(write),
35 ALLOW_SYSCALL(close), 37 ALLOW_SYSCALL(close),
(...skipping 21 matching lines...) Expand all
57 perror("prctl(SECCOMP)"); 59 perror("prctl(SECCOMP)");
58 goto failed; 60 goto failed;
59 } 61 }
60 return true; 62 return true;
61 63
62 failed: 64 failed:
63 if (errno == EINVAL) { 65 if (errno == EINVAL) {
64 fprintf(stderr, "SECCOMP_FILTER is not available. :(\n"); 66 fprintf(stderr, "SECCOMP_FILTER is not available. :(\n");
65 } 67 }
66 return false; 68 return false;
69 #else
70 return true;
71 #endif /* SK_UNSAFE_BUILD_DESKTOP_ONLY */
67 } 72 }
68 73
69 static void setLimits() { 74 static void setLimits() {
70 struct rlimit n; 75 struct rlimit n;
71 76
72 // Limit to 5 seconds of CPU. 77 // Limit to 5 seconds of CPU.
73 n.rlim_cur = 5; 78 n.rlim_cur = 5;
74 n.rlim_max = 5; 79 n.rlim_max = 5;
75 if (setrlimit(RLIMIT_CPU, &n)) { 80 if (setrlimit(RLIMIT_CPU, &n)) {
76 perror("setrlimit(RLIMIT_CPU)"); 81 perror("setrlimit(RLIMIT_CPU)");
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
117 122
118 // Write out the image as a PNG. 123 // Write out the image as a PNG.
119 SkAutoTUnref<SkImage> image(surface->newImageSnapshot()); 124 SkAutoTUnref<SkImage> image(surface->newImageSnapshot());
120 SkAutoTUnref<SkData> data(image->encode(SkImageEncoder::kPNG_Type, 100)); 125 SkAutoTUnref<SkData> data(image->encode(SkImageEncoder::kPNG_Type, 100));
121 if (NULL == data.get()) { 126 if (NULL == data.get()) {
122 printf("Failed to encode\n"); 127 printf("Failed to encode\n");
123 exit(1); 128 exit(1);
124 } 129 }
125 stream.write(data->data(), data->size()); 130 stream.write(data->data(), data->size());
126 } 131 }
OLDNEW
« no previous file with comments | « no previous file | experimental/webtry/seccomp_bpf.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698