diff --git a/Makefile b/Makefile index ac48d8c..e3f8aa9 100644 --- a/Makefile +++ b/Makefile @@ -8,11 +8,14 @@ LIBS := libvnc/libvnc.a CFLAGS = -I$(shell pwd)/include # _GNU_SOURCE for asprintf. CFLAGS += -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_GNU_SOURCE -CFLAGS += -Wall -Werror -g -O1 +CFLAGS += -Wall -g -O1 ifeq ($(shell uname),Linux) LDLIBS := -lutil endif +ifeq ($(shell uname),NetBSD) +LDLIBS := -lutil +endif ifndef WITHOUT_XENSTORE LDLIBS += -lxenstore @@ -45,7 +48,7 @@ $(LIBS): %.a: ALWAYS .PHONY: ALWAYS clean: - $(foreach dir,$(SUBDIRS),make -C $(dir) clean) + $(foreach dir,$(SUBDIRS),$(MAKE) -C $(dir) clean) rm -f $(OBJS) rm -f $(DEPS) rm -f $(TARGET) diff --git a/console.c b/console.c index c6b6019..db51822 100644 --- a/console.c +++ b/console.c @@ -607,7 +607,7 @@ static void vga_putcharxy(TextConsole *s, int x, int y, int ch, font_data = *font_ptr++; if (t_attrib->uline && ((i == FONT_HEIGHT - 2) || (i == FONT_HEIGHT - 3))) { - font_data = 0xFFFF; + font_data = 0xFF; } ((uint32_t *)d)[0] = (dmask16[(font_data >> 4)] & xorcol) ^ bgcol; ((uint32_t *)d)[1] = (dmask16[(font_data >> 0) & 0xf] & xorcol) ^ bgcol; @@ -620,7 +620,7 @@ static void vga_putcharxy(TextConsole *s, int x, int y, int ch, font_data = *font_ptr++; if (t_attrib->uline && ((i == FONT_HEIGHT - 2) || (i == FONT_HEIGHT - 3))) { - font_data = 0xFFFF; + font_data = 0xFF; } ((uint32_t *)d)[0] = (dmask4[(font_data >> 6)] & xorcol) ^ bgcol; ((uint32_t *)d)[1] = (dmask4[(font_data >> 4) & 3] & xorcol) ^ bgcol; @@ -633,7 +633,7 @@ static void vga_putcharxy(TextConsole *s, int x, int y, int ch, for(i = 0; i < FONT_HEIGHT; i++) { font_data = *font_ptr++; if (t_attrib->uline && ((i == FONT_HEIGHT - 2) || (i == FONT_HEIGHT - 3))) { - font_data = 0xFFFF; + font_data = 0xFF; } ((uint32_t *)d)[0] = (-((font_data >> 7)) & xorcol) ^ bgcol; ((uint32_t *)d)[1] = (-((font_data >> 6) & 1) & xorcol) ^ bgcol; diff --git a/libvnc/vnc.c b/libvnc/vnc.c index 39b6971..ff8e956 100644 --- a/libvnc/vnc.c +++ b/libvnc/vnc.c @@ -707,17 +707,11 @@ static void _vnc_update_client(void *opaque) VncState *vs = opaque; int64_t now; int y; - uint64_t width_mask; int maxx, maxy; int new_rectangles; now = vs->ds->get_clock(); - if (vs->ds->width != DP2X(vs, DIRTY_PIXEL_BITS)) - width_mask = (1ULL << X2DP_UP(vs, vs->ds->width)) - 1; - else - width_mask = ~(0ULL); - if (!vs->has_update || vs->visible_y >= vs->ds->height || vs->visible_x >= vs->ds->width) goto backoff; diff --git a/main.c b/main.c index f49ba4b..cd870d8 100644 --- a/main.c +++ b/main.c @@ -3,7 +3,7 @@ #include #include #include -#if !defined(__APPLE__) +#if defined(__linux__) #include #else #include @@ -23,7 +23,10 @@ #include #include #include +#include +#if defined(__linux__) #include +#endif #include @@ -79,7 +82,10 @@ enum privsep_opcode { privsep_op_statefile_completed }; -static void _write_port_to_xenstore(char *xenstore_path, char *type, int port); +#ifndef NXENSTORE +static void _write_port_to_xenstore(char *xenstore_path, const char *type, + int port); +#endif int set_fd_handler(int fd, int (*fd_read_poll)(void *), void (*fd_read)(void *), @@ -428,6 +434,7 @@ static uid_t vncterm_uid; #ifndef NXENSTORE struct xs_handle *xs = NULL; char *xenstore_path = NULL; +const char *vncname = "vnc"; #endif static void clean_exit(int ret) @@ -465,6 +472,7 @@ must_read(int fd, void *buf, size_t n) } } +#ifndef NXENSTORE /* Write data with the assertion that it all has to be written, or * else abort the process. Based on atomicio() from openssh. */ static void @@ -486,7 +494,9 @@ must_write(int fd, const void *buf, size_t n) } } } +#endif +#ifndef NXENSTORE static void xenstore_write_statefile(const char *filepath) { int ret; @@ -539,6 +549,7 @@ static void privsep_statefile_completed(const char *name) must_write(privsep_fd, &l, sizeof(l)); must_write(privsep_fd, name, l); } +#endif static void sigxfsz_handler(int num) { @@ -635,6 +646,8 @@ main(int argc, char **argv, char **envp) {"title", 1, 0, 't'}, {"xenstore", 1, 0, 'x'}, {"vnclisten", 1, 0, 'v'}, + {"vncpassword", 1, 0, 'P'}, + {"vncname", 1, 0, 'n'}, {"stay-root", 0, 0, 'S'}, {"vncviewer", 2, 0, 'V'}, {"loadstate", 1, 0, 'l'}, @@ -642,7 +655,8 @@ main(int argc, char **argv, char **envp) {0, 0, 0, 0} }; - c = getopt_long(argc, argv, "+cp:rst:x:v:SV::l:T", long_options, NULL); + c = getopt_long(argc, argv, "+cp:rst:x:v:P:n:SV::l:T", long_options, + NULL); if (c == -1) break; @@ -680,6 +694,12 @@ main(int argc, char **argv, char **envp) case 'v': vnclisten = strdup(optarg); break; + case 'P': + strncpy(vncpasswd, optarg, sizeof(vncpasswd) - 1); + break; + case 'n': + vncname = strdup(optarg); + break; case 'V': vncviewer = 1; if (optarg != NULL) @@ -834,7 +854,7 @@ main(int argc, char **argv, char **envp) if (xs == NULL) err(1, "xs_daemon_open"); - _write_port_to_xenstore(xenstore_path, "vnc", display); + _write_port_to_xenstore(xenstore_path, vncname, display); if (enable_textterm) _write_port_to_xenstore(xenstore_path, "tc", text_display); @@ -919,9 +939,11 @@ main(int argc, char **argv, char **envp) while (1) { must_read(parent_fd, &opcode, sizeof(opcode)); switch (opcode) { +#ifndef NXENSTORE case privsep_op_statefile_completed: privsep_xenstore_statefile(); break; +#endif default: clean_exit(0); } @@ -933,7 +955,9 @@ main(int argc, char **argv, char **envp) close(socks[1]); privsep_fd = socks[0]; +#ifndef NXENSTORE xs_daemon_close(xs); +#endif rlim.rlim_cur = 64 * 1024 * 1024; rlim.rlim_max = 64 * 1024 * 1024 + 64; @@ -953,7 +977,9 @@ main(int argc, char **argv, char **envp) setuid(vncterm_uid); /* vncterm core dumps are often useful; make sure they're allowed. */ +#if defined(__linux__) prctl(PR_SET_DUMPABLE, 1, 0, 0, 0); +#endif /* handling SIGXFSZ */ signal(SIGXFSZ, sigxfsz_handler); @@ -1141,7 +1167,9 @@ main(int argc, char **argv, char **envp) return 0; } -static void _write_port_to_xenstore(char *xenstore_path, char *type, int no) +#ifndef NXENSTORE +static void _write_port_to_xenstore(char *xenstore_path, const char *type, + int no) { char *path, *port; int ret; @@ -1158,3 +1186,4 @@ static void _write_port_to_xenstore(char *xenstore_path, char *type, int no) if (!ret) err(1, "xs_write"); } +#endif