2 * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
4 * Copyright (c) 2015 Tycho Nightingale <tycho.nightingale@pluribusnetworks.com>
5 * Copyright (c) 2015 Leon Dang
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
11 * 1. Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the
15 * documentation and/or other materials provided with the distribution.
17 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND
18 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
21 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
30 #include <sys/cdefs.h>
31 __FBSDID("$FreeBSD$");
33 #include <sys/param.h>
34 #ifndef WITHOUT_CAPSICUM
35 #include <sys/capsicum.h>
37 #include <sys/endian.h>
38 #include <sys/socket.h>
39 #include <sys/select.h>
41 #include <arpa/inet.h>
42 #include <machine/cpufunc.h>
43 #include <machine/specialreg.h>
44 #include <netinet/in.h>
51 #include <pthread_np.h>
65 #include "sockstream.h"
68 #include <openssl/des.h>
71 static int rfb_debug = 0;
72 #define DPRINTF(params) if (rfb_debug) printf params
73 #define WPRINTF(params) printf params
75 #define AUTH_LENGTH 16
76 #define PASSWD_LENGTH 8
78 #define SECURITY_TYPE_NONE 1
79 #define SECURITY_TYPE_VNC_AUTH 2
81 #define AUTH_FAILED_UNAUTH 1
82 #define AUTH_FAILED_ERROR 2
108 uint32_t *crc; /* WxH crc cells */
109 uint32_t *crc_tmp; /* buffer to store single crc row */
110 int crc_width, crc_height;
127 struct rfb_srvr_info {
130 struct rfb_pixfmt pixfmt;
134 struct rfb_pixfmt_msg {
137 struct rfb_pixfmt pixfmt;
140 #define RFB_ENCODING_RAW 0
141 #define RFB_ENCODING_ZLIB 6
142 #define RFB_ENCODING_RESIZE -223
144 #define RFB_MAX_WIDTH 2000
145 #define RFB_MAX_HEIGHT 1200
146 #define RFB_ZLIB_BUFSZ RFB_MAX_WIDTH*RFB_MAX_HEIGHT*4
148 /* percentage changes to screen before sending the entire screen */
149 #define RFB_SEND_ALL_THRESH 25
157 struct rfb_updt_msg {
180 struct rfb_srvr_updt_msg {
186 struct rfb_srvr_rect_hdr {
194 struct rfb_cuttext_msg {
202 rfb_send_server_init_msg(int cfd)
204 struct bhyvegc_image *gc_image;
205 struct rfb_srvr_info sinfo;
207 gc_image = console_get_image();
209 sinfo.width = htons(gc_image->width);
210 sinfo.height = htons(gc_image->height);
211 sinfo.pixfmt.bpp = 32;
212 sinfo.pixfmt.depth = 32;
213 sinfo.pixfmt.bigendian = 0;
214 sinfo.pixfmt.truecolor = 1;
215 sinfo.pixfmt.red_max = htons(255);
216 sinfo.pixfmt.green_max = htons(255);
217 sinfo.pixfmt.blue_max = htons(255);
218 sinfo.pixfmt.red_shift = 16;
219 sinfo.pixfmt.green_shift = 8;
220 sinfo.pixfmt.blue_shift = 0;
221 sinfo.namelen = htonl(strlen("bhyve"));
222 (void)stream_write(cfd, &sinfo, sizeof(sinfo));
223 (void)stream_write(cfd, "bhyve", strlen("bhyve"));
227 rfb_send_resize_update_msg(struct rfb_softc *rc, int cfd)
229 struct rfb_srvr_updt_msg supdt_msg;
230 struct rfb_srvr_rect_hdr srect_hdr;
232 /* Number of rectangles: 1 */
235 supdt_msg.numrects = htons(1);
236 stream_write(cfd, &supdt_msg, sizeof(struct rfb_srvr_updt_msg));
238 /* Rectangle header */
239 srect_hdr.x = htons(0);
240 srect_hdr.y = htons(0);
241 srect_hdr.width = htons(rc->width);
242 srect_hdr.height = htons(rc->height);
243 srect_hdr.encoding = htonl(RFB_ENCODING_RESIZE);
244 stream_write(cfd, &srect_hdr, sizeof(struct rfb_srvr_rect_hdr));
248 rfb_recv_set_pixfmt_msg(struct rfb_softc *rc, int cfd)
250 struct rfb_pixfmt_msg pixfmt_msg;
252 (void)stream_read(cfd, ((void *)&pixfmt_msg)+1, sizeof(pixfmt_msg)-1);
257 rfb_recv_set_encodings_msg(struct rfb_softc *rc, int cfd)
259 struct rfb_enc_msg enc_msg;
263 assert((sizeof(enc_msg) - 1) == 3);
264 (void)stream_read(cfd, ((void *)&enc_msg)+1, sizeof(enc_msg)-1);
266 for (i = 0; i < htons(enc_msg.numencs); i++) {
267 (void)stream_read(cfd, &encoding, sizeof(encoding));
268 switch (htonl(encoding)) {
269 case RFB_ENCODING_RAW:
270 rc->enc_raw_ok = true;
272 case RFB_ENCODING_ZLIB:
273 if (!rc->enc_zlib_ok) {
274 deflateInit(&rc->zstream, Z_BEST_SPEED);
275 rc->enc_zlib_ok = true;
278 case RFB_ENCODING_RESIZE:
279 rc->enc_resize_ok = true;
286 * Calculate CRC32 using SSE4.2; Intel or AMD Bulldozer+ CPUs only
288 static __inline uint32_t
289 fast_crc32(void *buf, int len, uint32_t crcval)
291 uint32_t q = len / sizeof(uint32_t);
292 uint32_t *p = (uint32_t *)buf;
296 ".byte 0xf2, 0xf, 0x38, 0xf1, 0xf1;"
298 :"0" (crcval), "c" (*p)
308 rfb_send_rect(struct rfb_softc *rc, int cfd, struct bhyvegc_image *gc,
309 int x, int y, int w, int h)
311 struct rfb_srvr_updt_msg supdt_msg;
312 struct rfb_srvr_rect_hdr srect_hdr;
314 ssize_t nwrite, total;
320 * Send a single rectangle of the given x, y, w h dimensions.
323 /* Number of rectangles: 1 */
326 supdt_msg.numrects = htons(1);
327 nwrite = stream_write(cfd, &supdt_msg,
328 sizeof(struct rfb_srvr_updt_msg));
333 /* Rectangle header */
334 srect_hdr.x = htons(x);
335 srect_hdr.y = htons(y);
336 srect_hdr.width = htons(w);
337 srect_hdr.height = htons(h);
340 w *= sizeof(uint32_t);
341 if (rc->enc_zlib_ok) {
343 rc->zstream.total_in = 0;
344 rc->zstream.total_out = 0;
345 for (p = &gc->data[y * gc->width + x]; y < h; y++) {
346 rc->zstream.next_in = (Bytef *)p;
347 rc->zstream.avail_in = w;
348 rc->zstream.next_out = (Bytef *)zbufp;
349 rc->zstream.avail_out = RFB_ZLIB_BUFSZ + 16 -
350 rc->zstream.total_out;
351 rc->zstream.data_type = Z_BINARY;
353 /* Compress with zlib */
354 err = deflate(&rc->zstream, Z_SYNC_FLUSH);
356 WPRINTF(("zlib[rect] deflate err: %d\n", err));
357 rc->enc_zlib_ok = false;
358 deflateEnd(&rc->zstream);
361 zbufp = rc->zbuf + rc->zstream.total_out;
364 srect_hdr.encoding = htonl(RFB_ENCODING_ZLIB);
365 nwrite = stream_write(cfd, &srect_hdr,
366 sizeof(struct rfb_srvr_rect_hdr));
370 zlen = htonl(rc->zstream.total_out);
371 nwrite = stream_write(cfd, &zlen, sizeof(uint32_t));
374 return (stream_write(cfd, rc->zbuf, rc->zstream.total_out));
381 for (p = &gc->data[y * gc->width + x]; y < h; y++) {
388 srect_hdr.encoding = htonl(RFB_ENCODING_RAW);
389 nwrite = stream_write(cfd, &srect_hdr,
390 sizeof(struct rfb_srvr_rect_hdr));
394 total = stream_write(cfd, rc->zbuf, total);
400 rfb_send_all(struct rfb_softc *rc, int cfd, struct bhyvegc_image *gc)
402 struct rfb_srvr_updt_msg supdt_msg;
403 struct rfb_srvr_rect_hdr srect_hdr;
409 * Send the whole thing
412 /* Number of rectangles: 1 */
415 supdt_msg.numrects = htons(1);
416 nwrite = stream_write(cfd, &supdt_msg,
417 sizeof(struct rfb_srvr_updt_msg));
421 /* Rectangle header */
424 srect_hdr.width = htons(gc->width);
425 srect_hdr.height = htons(gc->height);
426 if (rc->enc_zlib_ok) {
427 rc->zstream.next_in = (Bytef *)gc->data;
428 rc->zstream.avail_in = gc->width * gc->height *
430 rc->zstream.next_out = (Bytef *)rc->zbuf;
431 rc->zstream.avail_out = RFB_ZLIB_BUFSZ + 16;
432 rc->zstream.data_type = Z_BINARY;
434 rc->zstream.total_in = 0;
435 rc->zstream.total_out = 0;
437 /* Compress with zlib */
438 err = deflate(&rc->zstream, Z_SYNC_FLUSH);
440 WPRINTF(("zlib deflate err: %d\n", err));
441 rc->enc_zlib_ok = false;
442 deflateEnd(&rc->zstream);
446 srect_hdr.encoding = htonl(RFB_ENCODING_ZLIB);
447 nwrite = stream_write(cfd, &srect_hdr,
448 sizeof(struct rfb_srvr_rect_hdr));
452 zlen = htonl(rc->zstream.total_out);
453 nwrite = stream_write(cfd, &zlen, sizeof(uint32_t));
456 return (stream_write(cfd, rc->zbuf, rc->zstream.total_out));
460 srect_hdr.encoding = htonl(RFB_ENCODING_RAW);
461 nwrite = stream_write(cfd, &srect_hdr,
462 sizeof(struct rfb_srvr_rect_hdr));
466 nwrite = stream_write(cfd, gc->data,
467 gc->width * gc->height * sizeof(uint32_t));
472 #define PIX_PER_CELL 32
473 #define PIXCELL_SHIFT 5
474 #define PIXCELL_MASK 0x1F
477 rfb_send_screen(struct rfb_softc *rc, int cfd, int all)
479 struct bhyvegc_image *gc_image;
482 int celly, cellwidth;
486 int rem_x, rem_y; /* remainder for resolutions not x32 pixels ratio */
488 uint32_t *crc_p, *orig_crc;
492 gc_image = console_get_image();
494 pthread_mutex_lock(&rc->mtx);
496 pthread_mutex_unlock(&rc->mtx);
500 pthread_mutex_unlock(&rc->mtx);
505 retval = rfb_send_all(rc, cfd, gc_image);
510 * Calculate the checksum for each 32x32 cell. Send each that
511 * has changed since the last scan.
514 /* Resolution changed */
516 rc->crc_width = gc_image->width;
517 rc->crc_height = gc_image->height;
521 xcells = howmany(rc->crc_width, PIX_PER_CELL);
522 ycells = howmany(rc->crc_height, PIX_PER_CELL);
524 rem_x = w & PIXCELL_MASK;
526 rem_y = h & PIXCELL_MASK;
528 rem_y = PIX_PER_CELL;
533 * Go through all cells and calculate crc. If significant number
534 * of changes, then send entire screen.
535 * crc_tmp is dual purpose: to store the new crc and to flag as
536 * a cell that has changed.
538 crc_p = rc->crc_tmp - xcells;
539 orig_crc = rc->crc - xcells;
541 memset(rc->crc_tmp, 0, sizeof(uint32_t) * xcells * ycells);
542 for (y = 0; y < h; y++) {
543 if ((y & PIXCELL_MASK) == 0) {
548 for (x = 0; x < xcells; x++) {
549 if (x == (xcells - 1) && rem_x > 0)
552 cellwidth = PIX_PER_CELL;
555 crc_p[x] = fast_crc32(p,
556 cellwidth * sizeof(uint32_t),
559 crc_p[x] = (uint32_t)crc32(crc_p[x],
561 cellwidth * sizeof(uint32_t));
565 /* check for crc delta if last row in cell */
566 if ((y & PIXCELL_MASK) == PIXCELL_MASK || y == (h-1)) {
567 if (orig_crc[x] != crc_p[x]) {
568 orig_crc[x] = crc_p[x];
578 /* If number of changes is > THRESH percent, send the whole screen */
579 if (((changes * 100) / (xcells * ycells)) >= RFB_SEND_ALL_THRESH) {
580 retval = rfb_send_all(rc, cfd, gc_image);
584 /* Go through all cells, and send only changed ones */
586 for (y = 0; y < h; y += PIX_PER_CELL) {
587 /* previous cell's row */
588 celly = (y >> PIXCELL_SHIFT);
590 /* Delta check crc to previous set */
591 for (x = 0; x < xcells; x++) {
595 if (x == (xcells - 1) && rem_x > 0)
598 cellwidth = PIX_PER_CELL;
599 nwrite = rfb_send_rect(rc, cfd,
602 celly * PIX_PER_CELL,
604 y + PIX_PER_CELL >= h ? rem_y : PIX_PER_CELL);
614 pthread_mutex_lock(&rc->mtx);
616 pthread_mutex_unlock(&rc->mtx);
623 rfb_recv_update_msg(struct rfb_softc *rc, int cfd, int discardonly)
625 struct rfb_updt_msg updt_msg;
626 struct bhyvegc_image *gc_image;
628 (void)stream_read(cfd, ((void *)&updt_msg) + 1 , sizeof(updt_msg) - 1);
631 gc_image = console_get_image();
633 updt_msg.x = htons(updt_msg.x);
634 updt_msg.y = htons(updt_msg.y);
635 updt_msg.width = htons(updt_msg.width);
636 updt_msg.height = htons(updt_msg.height);
638 if (updt_msg.width != gc_image->width ||
639 updt_msg.height != gc_image->height) {
640 rc->width = gc_image->width;
641 rc->height = gc_image->height;
642 if (rc->enc_resize_ok)
643 rfb_send_resize_update_msg(rc, cfd);
649 rfb_send_screen(rc, cfd, 1);
653 rfb_recv_key_msg(struct rfb_softc *rc, int cfd)
655 struct rfb_key_msg key_msg;
657 (void)stream_read(cfd, ((void *)&key_msg) + 1, sizeof(key_msg) - 1);
659 console_key_event(key_msg.down, htonl(key_msg.code));
663 rfb_recv_ptr_msg(struct rfb_softc *rc, int cfd)
665 struct rfb_ptr_msg ptr_msg;
667 (void)stream_read(cfd, ((void *)&ptr_msg) + 1, sizeof(ptr_msg) - 1);
669 console_ptr_event(ptr_msg.button, htons(ptr_msg.x), htons(ptr_msg.y));
673 rfb_recv_cuttext_msg(struct rfb_softc *rc, int cfd)
675 struct rfb_cuttext_msg ct_msg;
676 unsigned char buf[32];
679 len = stream_read(cfd, ((void *)&ct_msg) + 1, sizeof(ct_msg) - 1);
680 ct_msg.length = htonl(ct_msg.length);
681 while (ct_msg.length > 0) {
682 len = stream_read(cfd, buf, ct_msg.length > sizeof(buf) ?
683 sizeof(buf) : ct_msg.length);
684 ct_msg.length -= len;
689 timeval_delta(struct timeval *prev, struct timeval *now)
692 n1 = now->tv_sec * 1000000 + now->tv_usec;
693 n2 = prev->tv_sec * 1000000 + prev->tv_usec;
698 rfb_wr_thr(void *arg)
700 struct rfb_softc *rc;
703 struct timeval prev_tv;
713 while (rc->cfd >= 0) {
719 err = select(cfd+1, &rfds, NULL, NULL, &tv);
723 /* Determine if its time to push screen; ~24hz */
724 gettimeofday(&tv, NULL);
725 tdiff = timeval_delta(&prev_tv, &tv);
727 prev_tv.tv_sec = tv.tv_sec;
728 prev_tv.tv_usec = tv.tv_usec;
729 if (rfb_send_screen(rc, cfd, 0) <= 0) {
734 usleep(40000 - tdiff);
742 rfb_handle(struct rfb_softc *rc, int cfd)
744 const char *vbuf = "RFB 003.008\n";
745 unsigned char buf[80];
746 unsigned char *message = NULL;
749 unsigned char challenge[AUTH_LENGTH];
750 unsigned char keystr[PASSWD_LENGTH];
751 unsigned char crypt_expected[AUTH_LENGTH];
764 /* 1a. Send server version */
765 stream_write(cfd, vbuf, strlen(vbuf));
767 /* 1b. Read client version */
768 len = read(cfd, buf, sizeof(buf));
770 /* 2a. Send security type */
774 buf[1] = SECURITY_TYPE_VNC_AUTH;
776 buf[1] = SECURITY_TYPE_NONE;
778 buf[1] = SECURITY_TYPE_NONE;
781 stream_write(cfd, buf, 2);
783 /* 2b. Read agreed security type */
784 len = stream_read(cfd, buf, 1);
786 /* 2c. Do VNC authentication */
788 case SECURITY_TYPE_NONE:
791 case SECURITY_TYPE_VNC_AUTH:
793 * The client encrypts the challenge with DES, using a password
794 * supplied by the user as the key.
795 * To form the key, the password is truncated to
796 * eight characters, or padded with null bytes on the right.
797 * The client then sends the resulting 16-bytes response.
800 strncpy(keystr, rc->password, PASSWD_LENGTH);
802 /* VNC clients encrypts the challenge with all the bit fields
803 * in each byte of the password mirrored.
804 * Here we flip each byte of the keystr.
806 for (i = 0; i < PASSWD_LENGTH; i++) {
807 keystr[i] = (keystr[i] & 0xF0) >> 4
808 | (keystr[i] & 0x0F) << 4;
809 keystr[i] = (keystr[i] & 0xCC) >> 2
810 | (keystr[i] & 0x33) << 2;
811 keystr[i] = (keystr[i] & 0xAA) >> 1
812 | (keystr[i] & 0x55) << 1;
815 /* Initialize a 16-byte random challenge */
816 arc4random_buf(challenge, sizeof(challenge));
817 stream_write(cfd, challenge, AUTH_LENGTH);
819 /* Receive the 16-byte challenge response */
820 stream_read(cfd, buf, AUTH_LENGTH);
822 memcpy(crypt_expected, challenge, AUTH_LENGTH);
824 /* Encrypt the Challenge with DES */
825 DES_set_key((const_DES_cblock *)keystr, &ks);
826 DES_ecb_encrypt((const_DES_cblock *)challenge,
827 (const_DES_cblock *)crypt_expected,
829 DES_ecb_encrypt((const_DES_cblock *)(challenge + PASSWD_LENGTH),
830 (const_DES_cblock *)(crypt_expected +
834 if (memcmp(crypt_expected, buf, AUTH_LENGTH) != 0) {
835 message = "Auth Failed: Invalid Password.";
841 WPRINTF(("Auth not supported, no OpenSSL in your system"));
847 /* 2d. Write back a status */
848 stream_write(cfd, &sres, 4);
851 be32enc(buf, strlen(message));
852 stream_write(cfd, buf, 4);
853 stream_write(cfd, message, strlen(message));
857 /* 3a. Read client shared-flag byte */
858 len = stream_read(cfd, buf, 1);
860 /* 4a. Write server-init info */
861 rfb_send_server_init_msg(cfd);
864 rc->zbuf = malloc(RFB_ZLIB_BUFSZ + 16);
865 assert(rc->zbuf != NULL);
868 rfb_send_screen(rc, cfd, 1);
870 perror = pthread_create(&tid, NULL, rfb_wr_thr, rc);
872 pthread_set_name_np(tid, "rfbout");
874 /* Now read in client requests. 1st byte identifies type */
876 len = read(cfd, buf, 1);
878 DPRINTF(("rfb client exiting\r\n"));
884 rfb_recv_set_pixfmt_msg(rc, cfd);
887 rfb_recv_set_encodings_msg(rc, cfd);
890 rfb_recv_update_msg(rc, cfd, 1);
893 rfb_recv_key_msg(rc, cfd);
896 rfb_recv_ptr_msg(rc, cfd);
899 rfb_recv_cuttext_msg(rc, cfd);
902 WPRINTF(("rfb unknown cli-code %d!\n", buf[0] & 0xff));
909 pthread_join(tid, NULL);
911 deflateEnd(&rc->zstream);
917 struct rfb_softc *rc;
925 sigaddset(&set, SIGPIPE);
926 if (pthread_sigmask(SIG_BLOCK, &set, NULL) != 0) {
927 perror("pthread_sigmask");
932 rc->enc_raw_ok = false;
933 rc->enc_zlib_ok = false;
934 rc->enc_resize_ok = false;
936 cfd = accept(rc->sfd, NULL, NULL);
938 pthread_mutex_lock(&rc->mtx);
939 pthread_cond_signal(&rc->cond);
940 pthread_mutex_unlock(&rc->mtx);
952 sse42_supported(void)
954 u_int cpu_registers[4], ecx;
956 do_cpuid(1, cpu_registers);
958 ecx = cpu_registers[2];
960 return ((ecx & CPUID2_SSE42) != 0);
964 rfb_init(char *hostname, int port, int wait, char *password)
968 struct rfb_softc *rc;
970 struct addrinfo hints;
972 #ifndef WITHOUT_CAPSICUM
976 rc = calloc(1, sizeof(struct rfb_softc));
978 rc->crc = calloc(howmany(RFB_MAX_WIDTH * RFB_MAX_HEIGHT, 32),
980 rc->crc_tmp = calloc(howmany(RFB_MAX_WIDTH * RFB_MAX_HEIGHT, 32),
982 rc->crc_width = RFB_MAX_WIDTH;
983 rc->crc_height = RFB_MAX_HEIGHT;
985 rc->password = password;
987 snprintf(servname, sizeof(servname), "%d", port ? port : 5900);
989 if (!hostname || strlen(hostname) == 0)
991 hostname = "127.0.0.1";
996 memset(&hints, 0, sizeof(hints));
997 hints.ai_family = AF_UNSPEC;
998 hints.ai_socktype = SOCK_STREAM;
999 hints.ai_flags = AI_NUMERICHOST | AI_NUMERICSERV | AI_PASSIVE;
1001 if ((e = getaddrinfo(hostname, servname, &hints, &ai)) != 0) {
1002 fprintf(stderr, "getaddrinfo: %s\n", gai_strerror(e));
1006 rc->sfd = socket(ai->ai_family, ai->ai_socktype, 0);
1013 setsockopt(rc->sfd, SOL_SOCKET, SO_REUSEADDR, &on, sizeof(on));
1015 if (bind(rc->sfd, ai->ai_addr, ai->ai_addrlen) < 0) {
1021 if (listen(rc->sfd, 1) < 0) {
1027 #ifndef WITHOUT_CAPSICUM
1028 cap_rights_init(&rights, CAP_ACCEPT, CAP_EVENT, CAP_READ, CAP_WRITE);
1029 if (cap_rights_limit(rc->sfd, &rights) == -1 && errno != ENOSYS)
1030 errx(EX_OSERR, "Unable to apply rights for sandbox");
1033 rc->hw_crc = sse42_supported();
1035 rc->conn_wait = wait;
1037 pthread_mutex_init(&rc->mtx, NULL);
1038 pthread_cond_init(&rc->cond, NULL);
1041 pthread_create(&rc->tid, NULL, rfb_thr, rc);
1042 pthread_set_name_np(rc->tid, "rfb");
1045 DPRINTF(("Waiting for rfb client...\n"));
1046 pthread_mutex_lock(&rc->mtx);
1047 pthread_cond_wait(&rc->cond, &rc->mtx);
1048 pthread_mutex_unlock(&rc->mtx);