From 0c55cbef57bbc9c09b4f8e465f6601ef3d484672 Mon Sep 17 00:00:00 2001 From: YAMAMOTO Takashi Date: Wed, 14 Nov 2012 14:37:15 +0900 Subject: [PATCH 1/7] make this buildable on NetBSD --- Makefile | 5 ++++- main.c | 7 ++++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index ac48d8c..2b10c2c 100644 --- a/Makefile +++ b/Makefile @@ -13,6 +13,9 @@ CFLAGS += -Wall -Werror -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/main.c b/main.c index f49ba4b..c5cfced 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 @@ -953,7 +956,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); From 83419809da517a48743f51c8c427a4b930a8add2 Mon Sep 17 00:00:00 2001 From: YAMAMOTO Takashi Date: Wed, 14 Nov 2012 14:37:36 +0900 Subject: [PATCH 2/7] fix NXENSTORE build --- main.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/main.c b/main.c index c5cfced..d3217fa 100644 --- a/main.c +++ b/main.c @@ -82,7 +82,9 @@ enum privsep_opcode { privsep_op_statefile_completed }; +#ifndef NXENSTORE static void _write_port_to_xenstore(char *xenstore_path, char *type, int port); +#endif int set_fd_handler(int fd, int (*fd_read_poll)(void *), void (*fd_read)(void *), @@ -468,6 +470,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 @@ -489,7 +492,9 @@ must_write(int fd, const void *buf, size_t n) } } } +#endif +#ifndef NXENSTORE static void xenstore_write_statefile(const char *filepath) { int ret; @@ -542,6 +547,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) { @@ -922,9 +928,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); } @@ -936,7 +944,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; @@ -1146,6 +1156,7 @@ main(int argc, char **argv, char **envp) return 0; } +#ifndef NXENSTORE static void _write_port_to_xenstore(char *xenstore_path, char *type, int no) { char *path, *port; @@ -1163,3 +1174,4 @@ static void _write_port_to_xenstore(char *xenstore_path, char *type, int no) if (!ret) err(1, "xs_write"); } +#endif From c590f70d4c45acee03cefb2d01374a8643b1d75b Mon Sep 17 00:00:00 2001 From: YAMAMOTO Takashi Date: Wed, 14 Nov 2012 14:44:25 +0900 Subject: [PATCH 3/7] add an option to specify vnc password --- main.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/main.c b/main.c index d3217fa..955ae78 100644 --- a/main.c +++ b/main.c @@ -644,6 +644,7 @@ main(int argc, char **argv, char **envp) {"title", 1, 0, 't'}, {"xenstore", 1, 0, 'x'}, {"vnclisten", 1, 0, 'v'}, + {"vncpassword", 1, 0, 'P'}, {"stay-root", 0, 0, 'S'}, {"vncviewer", 2, 0, 'V'}, {"loadstate", 1, 0, 'l'}, @@ -651,7 +652,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:SV::l:T", long_options, + NULL); if (c == -1) break; @@ -689,6 +691,9 @@ main(int argc, char **argv, char **envp) case 'v': vnclisten = strdup(optarg); break; + case 'P': + strncpy(vncpasswd, optarg, sizeof(vncpasswd) - 1); + break; case 'V': vncviewer = 1; if (optarg != NULL) From 7c3599400a4dd8b88e595ad00cf9e2a94720de7d Mon Sep 17 00:00:00 2001 From: YAMAMOTO Takashi Date: Wed, 14 Nov 2012 15:11:16 +0900 Subject: [PATCH 4/7] add an option to specify a string used to build a xenstore path it can be used to avoid overwriting the existing "vnc-port" entry created by qemu-dm for its embedded vnc server. --- main.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/main.c b/main.c index 955ae78..cd870d8 100644 --- a/main.c +++ b/main.c @@ -83,7 +83,8 @@ enum privsep_opcode { }; #ifndef NXENSTORE -static void _write_port_to_xenstore(char *xenstore_path, char *type, int port); +static void _write_port_to_xenstore(char *xenstore_path, const char *type, + int port); #endif int @@ -433,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) @@ -645,6 +647,7 @@ main(int argc, char **argv, char **envp) {"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'}, @@ -652,7 +655,7 @@ main(int argc, char **argv, char **envp) {0, 0, 0, 0} }; - c = getopt_long(argc, argv, "+cp:rst:x:v:P:SV::l:T", long_options, + c = getopt_long(argc, argv, "+cp:rst:x:v:P:n:SV::l:T", long_options, NULL); if (c == -1) break; @@ -694,6 +697,9 @@ main(int argc, char **argv, char **envp) case 'P': strncpy(vncpasswd, optarg, sizeof(vncpasswd) - 1); break; + case 'n': + vncname = strdup(optarg); + break; case 'V': vncviewer = 1; if (optarg != NULL) @@ -848,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); @@ -1162,7 +1168,8 @@ main(int argc, char **argv, char **envp) } #ifndef NXENSTORE -static void _write_port_to_xenstore(char *xenstore_path, char *type, int no) +static void _write_port_to_xenstore(char *xenstore_path, const char *type, + int no) { char *path, *port; int ret; From 05a6384cb743e8ce607b098e5a972d3eb2ded582 Mon Sep 17 00:00:00 2001 From: YAMAMOTO Takashi Date: Tue, 18 Dec 2012 14:06:46 +0900 Subject: [PATCH 5/7] apply a patch from debian xcp-vncterm_0.1-2.debian.tar.gz gcc-warnings Description: Removes useless code that is otherwise producing gcc warning. Forwarded: not-needed. --- libvnc/vnc.c | 6 ------ 1 file changed, 6 deletions(-) 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; From 53327c75ad8645741c9afb4a35c32f8c52fcfd83 Mon Sep 17 00:00:00 2001 From: YAMAMOTO Takashi Date: Tue, 18 Dec 2012 14:08:31 +0900 Subject: [PATCH 6/7] apply a patch from debian xcp-vncterm_0.1-2.debian.tar.gz fix-underline Fix segfault on qemu font underline codepath This patch came from qemu upstream. The problem was that a magic number was entered wrong, and dereferenced an array way out of bounds. Signed-off-by: Mike McClurg --- console.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) 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; From 20e96aeec57344c52e60225d9c088db4848621c3 Mon Sep 17 00:00:00 2001 From: YAMAMOTO Takashi Date: Tue, 18 Dec 2012 14:09:40 +0900 Subject: [PATCH 7/7] apply a patch from debian xcp-vncterm_0.1-2.debian.tar.gz fix-build Description: removes -Werror (warning level) when calling gcc. Forwarded:: not-needed. --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 2b10c2c..e3f8aa9 100644 --- a/Makefile +++ b/Makefile @@ -8,7 +8,7 @@ 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