Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down
6 changes: 3 additions & 3 deletions console.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand All @@ -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;
Expand Down
6 changes: 0 additions & 6 deletions libvnc/vnc.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
39 changes: 34 additions & 5 deletions main.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#include <fcntl.h>
#include <getopt.h>
#include <netinet/in.h>
#if !defined(__APPLE__)
#if defined(__linux__)
#include <pty.h>
#else
#include <util.h>
Expand All @@ -23,7 +23,10 @@
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/wait.h>
#include <sys/resource.h>
#if defined(__linux__)
#include <sys/prctl.h>
#endif

#include <locale.h>

Expand Down Expand Up @@ -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 *),
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand All @@ -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;
Expand Down Expand Up @@ -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)
{
Expand Down Expand Up @@ -635,14 +646,17 @@ 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'},
{"text", 0, 0, 'T'},
{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;

Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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);

Expand Down Expand Up @@ -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);
}
Expand All @@ -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;
Expand All @@ -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);
Expand Down Expand Up @@ -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;
Expand All @@ -1158,3 +1186,4 @@ static void _write_port_to_xenstore(char *xenstore_path, char *type, int no)
if (!ret)
err(1, "xs_write");
}
#endif