From 497a01b283266047d3496db14571be600a8d732d Mon Sep 17 00:00:00 2001 From: Paweł Zuzelski Date: Fri, 11 Jun 2010 20:06:05 +0200 Subject: kill gnuizm sed -i is gnuism and it doesn't work on MacOS X and possibly other UNIX systems. Reported by __monty__ on IRC, thanks. --- Makefile | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'Makefile') diff --git a/Makefile b/Makefile index a995f76..10b2921 100644 --- a/Makefile +++ b/Makefile @@ -96,15 +96,21 @@ install-uzbl-core: all install -m644 AUTHORS $(DOCDIR)/ cp -r examples $(INSTALLDIR)/share/uzbl/ chmod 755 $(INSTALLDIR)/share/uzbl/examples/data/scripts/* - sed -i 's#^set prefix.*=.*#set prefix = $(RUN_PREFIX)#' $(INSTALLDIR)/share/uzbl/examples/config/config + mv $(INSTALLDIR)/share/uzbl/examples/config/config{,.bak} + sed 's#^set prefix.*=.*#set prefix = $(RUN_PREFIX)#' < $(INSTALLDIR)/share/uzbl/examples/config/config > $(INSTALLDIR)/share/uzbl/examples/config/config + rm $(INSTALLDIR)/share/uzbl/examples/config/config.bak install -D -m755 uzbl-core $(INSTALLDIR)/bin/uzbl-core install-uzbl-browser: install -D -m755 src/uzbl-browser $(INSTALLDIR)/bin/uzbl-browser install -D -m755 examples/data/scripts/uzbl-cookie-daemon $(INSTALLDIR)/bin/uzbl-cookie-daemon install -D -m755 examples/data/scripts/uzbl-event-manager $(INSTALLDIR)/bin/uzbl-event-manager - sed -i 's#^PREFIX=.*#PREFIX=$(RUN_PREFIX)#' $(INSTALLDIR)/bin/uzbl-browser - sed -i "s#^PREFIX = .*#PREFIX = '$(RUN_PREFIX)'#" $(INSTALLDIR)/bin/uzbl-event-manager + mv $(INSTALLDIR)/bin/uzbl-browser{,.bak} + sed 's#^PREFIX=.*#PREFIX=$(RUN_PREFIX)#' < $(INSTALLDIR)/bin/uzbl-browser > $(INSTALLDIR)/bin/uzbl-browser.bak + rm $(INSTALLDIR)/bin/uzbl-browser.bak + mv $(INSTALLDIR)/bin/uzbl-event-manager{,.bak} + sed "s#^PREFIX = .*#PREFIX = '$(RUN_PREFIX)'#" < $(INSTALLDIR)/bin/uzbl-event-manager > $(INSTALLDIR)/bin/uzbl-event-manager.bak + rm $(INSTALLDIR)/bin/uzbl-event-manager.bak install-uzbl-tabbed: install -D -m755 examples/data/scripts/uzbl-tabbed $(INSTALLDIR)/bin/uzbl-tabbed -- cgit v1.2.3 From 85d606d8ca8c717295cfb3ec13a53cbe8b2ce175 Mon Sep 17 00:00:00 2001 From: Paweł Zuzelski Date: Fri, 11 Jun 2010 20:10:53 +0200 Subject: kill gnuism install -D is gnuism. It is not supported on (at least) MacOS X and FreeBSD. --- Makefile | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) (limited to 'Makefile') diff --git a/Makefile b/Makefile index 10b2921..21b165e 100644 --- a/Makefile +++ b/Makefile @@ -87,7 +87,9 @@ strip: install: install-uzbl-core install-uzbl-browser install-uzbl-tabbed -install-uzbl-core: all +install-dirs: + [ -d "$(INSTALLDIR)/bin" ] && install -d -m755 $(INSTALLDIR)/bin +install-uzbl-core: all install-dirs install -d $(INSTALLDIR)/share/uzbl/ install -d $(DOCDIR) install -m644 docs/* $(DOCDIR)/ @@ -99,12 +101,12 @@ install-uzbl-core: all mv $(INSTALLDIR)/share/uzbl/examples/config/config{,.bak} sed 's#^set prefix.*=.*#set prefix = $(RUN_PREFIX)#' < $(INSTALLDIR)/share/uzbl/examples/config/config > $(INSTALLDIR)/share/uzbl/examples/config/config rm $(INSTALLDIR)/share/uzbl/examples/config/config.bak - install -D -m755 uzbl-core $(INSTALLDIR)/bin/uzbl-core + install -m755 uzbl-core $(INSTALLDIR)/bin/uzbl-core -install-uzbl-browser: - install -D -m755 src/uzbl-browser $(INSTALLDIR)/bin/uzbl-browser - install -D -m755 examples/data/scripts/uzbl-cookie-daemon $(INSTALLDIR)/bin/uzbl-cookie-daemon - install -D -m755 examples/data/scripts/uzbl-event-manager $(INSTALLDIR)/bin/uzbl-event-manager +install-uzbl-browser: install-dirs + install -m755 src/uzbl-browser $(INSTALLDIR)/bin/uzbl-browser + install -m755 examples/data/scripts/uzbl-cookie-daemon $(INSTALLDIR)/bin/uzbl-cookie-daemon + install -m755 examples/data/scripts/uzbl-event-manager $(INSTALLDIR)/bin/uzbl-event-manager mv $(INSTALLDIR)/bin/uzbl-browser{,.bak} sed 's#^PREFIX=.*#PREFIX=$(RUN_PREFIX)#' < $(INSTALLDIR)/bin/uzbl-browser > $(INSTALLDIR)/bin/uzbl-browser.bak rm $(INSTALLDIR)/bin/uzbl-browser.bak @@ -112,11 +114,11 @@ install-uzbl-browser: sed "s#^PREFIX = .*#PREFIX = '$(RUN_PREFIX)'#" < $(INSTALLDIR)/bin/uzbl-event-manager > $(INSTALLDIR)/bin/uzbl-event-manager.bak rm $(INSTALLDIR)/bin/uzbl-event-manager.bak -install-uzbl-tabbed: - install -D -m755 examples/data/scripts/uzbl-tabbed $(INSTALLDIR)/bin/uzbl-tabbed +install-uzbl-tabbed: install-dirs + install -m755 examples/data/scripts/uzbl-tabbed $(INSTALLDIR)/bin/uzbl-tabbed # you probably only want to do this manually when testing and/or to the sandbox. not meant for distributors -install-example-data: +install-example-data: install-dirs install -d $(DESTDIR)/home/.config/uzbl install -d $(DESTDIR)/home/.cache/uzbl install -d $(DESTDIR)/home/.local/share/uzbl -- cgit v1.2.3 From 22a5c6787a13c5cc02637f6007cce3cd9aa7522f Mon Sep 17 00:00:00 2001 From: Paweł Zuzelski Date: Fri, 11 Jun 2010 20:22:12 +0200 Subject: fixed regression introduced by 497a01b283266047d3496db14571be600a8d732d i.e. fixed 'sed -i gnuism' fix --- Makefile | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'Makefile') diff --git a/Makefile b/Makefile index 21b165e..79eedad 100644 --- a/Makefile +++ b/Makefile @@ -99,7 +99,7 @@ install-uzbl-core: all install-dirs cp -r examples $(INSTALLDIR)/share/uzbl/ chmod 755 $(INSTALLDIR)/share/uzbl/examples/data/scripts/* mv $(INSTALLDIR)/share/uzbl/examples/config/config{,.bak} - sed 's#^set prefix.*=.*#set prefix = $(RUN_PREFIX)#' < $(INSTALLDIR)/share/uzbl/examples/config/config > $(INSTALLDIR)/share/uzbl/examples/config/config + sed 's#^set prefix.*=.*#set prefix = $(RUN_PREFIX)#' < $(INSTALLDIR)/share/uzbl/examples/config/config.bak > $(INSTALLDIR)/share/uzbl/examples/config/config rm $(INSTALLDIR)/share/uzbl/examples/config/config.bak install -m755 uzbl-core $(INSTALLDIR)/bin/uzbl-core @@ -108,10 +108,10 @@ install-uzbl-browser: install-dirs install -m755 examples/data/scripts/uzbl-cookie-daemon $(INSTALLDIR)/bin/uzbl-cookie-daemon install -m755 examples/data/scripts/uzbl-event-manager $(INSTALLDIR)/bin/uzbl-event-manager mv $(INSTALLDIR)/bin/uzbl-browser{,.bak} - sed 's#^PREFIX=.*#PREFIX=$(RUN_PREFIX)#' < $(INSTALLDIR)/bin/uzbl-browser > $(INSTALLDIR)/bin/uzbl-browser.bak + sed 's#^PREFIX=.*#PREFIX=$(RUN_PREFIX)#' < $(INSTALLDIR)/bin/uzbl-browser.bak > $(INSTALLDIR)/bin/uzbl-browser rm $(INSTALLDIR)/bin/uzbl-browser.bak mv $(INSTALLDIR)/bin/uzbl-event-manager{,.bak} - sed "s#^PREFIX = .*#PREFIX = '$(RUN_PREFIX)'#" < $(INSTALLDIR)/bin/uzbl-event-manager > $(INSTALLDIR)/bin/uzbl-event-manager.bak + sed "s#^PREFIX = .*#PREFIX = '$(RUN_PREFIX)'#" < $(INSTALLDIR)/bin/uzbl-event-manager.bak > $(INSTALLDIR)/bin/uzbl-event-manager rm $(INSTALLDIR)/bin/uzbl-event-manager.bak install-uzbl-tabbed: install-dirs -- cgit v1.2.3 From f7c6469ee19aa8838cbc5dc9d804929b3ae3d61f Mon Sep 17 00:00:00 2001 From: Paweł Zuzelski Date: Sat, 12 Jun 2010 00:42:43 +0200 Subject: create bin dir if it does *NOT* exist --- Makefile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'Makefile') diff --git a/Makefile b/Makefile index 79eedad..b922264 100644 --- a/Makefile +++ b/Makefile @@ -88,7 +88,8 @@ strip: install: install-uzbl-core install-uzbl-browser install-uzbl-tabbed install-dirs: - [ -d "$(INSTALLDIR)/bin" ] && install -d -m755 $(INSTALLDIR)/bin + [ -d "$(INSTALLDIR)/bin" ] || install -d -m755 $(INSTALLDIR)/bin + install-uzbl-core: all install-dirs install -d $(INSTALLDIR)/share/uzbl/ install -d $(DOCDIR) -- cgit v1.2.3 From 1d4b7c0763a89066faa717adea4d35e7a0ad8458 Mon Sep 17 00:00:00 2001 From: Dieter Plaetinck Date: Wed, 25 Aug 2010 16:47:09 +0200 Subject: install-example-data does not need the bin dir install-example-data does not need the bin dir fixes a bug introduced in 85d606d8ca8c717295cf --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Makefile') diff --git a/Makefile b/Makefile index b922264..5287d5c 100644 --- a/Makefile +++ b/Makefile @@ -119,7 +119,7 @@ install-uzbl-tabbed: install-dirs install -m755 examples/data/scripts/uzbl-tabbed $(INSTALLDIR)/bin/uzbl-tabbed # you probably only want to do this manually when testing and/or to the sandbox. not meant for distributors -install-example-data: install-dirs +install-example-data: install -d $(DESTDIR)/home/.config/uzbl install -d $(DESTDIR)/home/.cache/uzbl install -d $(DESTDIR)/home/.local/share/uzbl -- cgit v1.2.3 From 5beca10731d22fff4b8d36b1b5ea3e9de8521452 Mon Sep 17 00:00:00 2001 From: Brendan Taylor Date: Fri, 8 Oct 2010 07:15:08 -0600 Subject: add cookie-jar.o to make clean --- Makefile | 1 + 1 file changed, 1 insertion(+) (limited to 'Makefile') diff --git a/Makefile b/Makefile index 5287d5c..55756e8 100644 --- a/Makefile +++ b/Makefile @@ -76,6 +76,7 @@ clean: rm -f events.o rm -f callbacks.o rm -f inspector.o + rm -f cookie-jar.o find ./examples/ -name "*.pyc" -delete cd ./tests/; $(MAKE) clean rm -rf ./sandbox/ -- cgit v1.2.3 From b6f897277fb0b1cd0139de47f852209bcb7d623e Mon Sep 17 00:00:00 2001 From: Ben Boeckel Date: Sun, 10 Oct 2010 16:10:04 -0400 Subject: uzbl links glib-2.0 now; get its flags --- Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'Makefile') diff --git a/Makefile b/Makefile index 5287d5c..ee69a0f 100644 --- a/Makefile +++ b/Makefile @@ -1,7 +1,7 @@ # first entries are for gnu make, 2nd for BSD make. see http://lists.uzbl.org/pipermail/uzbl-dev-uzbl.org/2009-July/000177.html -CFLAGS:=-std=c99 $(shell pkg-config --cflags gtk+-2.0 webkit-1.0 libsoup-2.4 gthread-2.0) -ggdb -Wall -W -DARCH="\"$(shell uname -m)\"" -lgthread-2.0 -DCOMMIT="\"$(shell ./misc/hash.sh)\"" $(CPPFLAGS) -fPIC -W -Wall -Wextra -pedantic -CFLAGS!=echo -std=c99 `pkg-config --cflags gtk+-2.0 webkit-1.0 libsoup-2.4 gthread-2.0` -ggdb -Wall -W -DARCH='"\""'`uname -m`'"\""' -lgthread-2.0 -DCOMMIT='"\""'`./misc/hash.sh`'"\""' $(CPPFLAGS) -fPIC -W -Wall -Wextra -pedantic +CFLAGS:=-std=c99 $(shell pkg-config --cflags gtk+-2.0 webkit-1.0 libsoup-2.4 gthread-2.0 glib-2.0) -ggdb -Wall -W -DARCH="\"$(shell uname -m)\"" -lgthread-2.0 -DCOMMIT="\"$(shell ./misc/hash.sh)\"" $(CPPFLAGS) -fPIC -W -Wall -Wextra -pedantic +CFLAGS!=echo -std=c99 `pkg-config --cflags gtk+-2.0 webkit-1.0 libsoup-2.4 gthread-2.0 glib-2.0` -ggdb -Wall -W -DARCH='"\""'`uname -m`'"\""' -lgthread-2.0 -DCOMMIT='"\""'`./misc/hash.sh`'"\""' $(CPPFLAGS) -fPIC -W -Wall -Wextra -pedantic LDFLAGS:=$(shell pkg-config --libs gtk+-2.0 webkit-1.0 libsoup-2.4 gthread-2.0) -pthread $(LDFLAGS) LDFLAGS!=echo `pkg-config --libs gtk+-2.0 webkit-1.0 libsoup-2.4 gthread-2.0` -pthread $(LDFLAGS) -- cgit v1.2.3 From d56e0f33fae387afed9290372773df7aa7b6a327 Mon Sep 17 00:00:00 2001 From: Ben Boeckel Date: Sun, 10 Oct 2010 16:10:18 -0400 Subject: uzbl also links x11 directly --- Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'Makefile') diff --git a/Makefile b/Makefile index ee69a0f..a53ed9d 100644 --- a/Makefile +++ b/Makefile @@ -3,8 +3,8 @@ CFLAGS:=-std=c99 $(shell pkg-config --cflags gtk+-2.0 webkit-1.0 libsoup-2.4 gthread-2.0 glib-2.0) -ggdb -Wall -W -DARCH="\"$(shell uname -m)\"" -lgthread-2.0 -DCOMMIT="\"$(shell ./misc/hash.sh)\"" $(CPPFLAGS) -fPIC -W -Wall -Wextra -pedantic CFLAGS!=echo -std=c99 `pkg-config --cflags gtk+-2.0 webkit-1.0 libsoup-2.4 gthread-2.0 glib-2.0` -ggdb -Wall -W -DARCH='"\""'`uname -m`'"\""' -lgthread-2.0 -DCOMMIT='"\""'`./misc/hash.sh`'"\""' $(CPPFLAGS) -fPIC -W -Wall -Wextra -pedantic -LDFLAGS:=$(shell pkg-config --libs gtk+-2.0 webkit-1.0 libsoup-2.4 gthread-2.0) -pthread $(LDFLAGS) -LDFLAGS!=echo `pkg-config --libs gtk+-2.0 webkit-1.0 libsoup-2.4 gthread-2.0` -pthread $(LDFLAGS) +LDFLAGS:=$(shell pkg-config --libs gtk+-2.0 webkit-1.0 libsoup-2.4 gthread-2.0 x11) -pthread $(LDFLAGS) +LDFLAGS!=echo `pkg-config --libs gtk+-2.0 webkit-1.0 libsoup-2.4 gthread-2.0 x11` -pthread $(LDFLAGS) SRC = $(wildcard src/*.c) HEAD = $(wildcard src/*.h) -- cgit v1.2.3 From 4584d84f15137c231aed911afab519653eca9f3f Mon Sep 17 00:00:00 2001 From: Brendan Taylor Date: Sat, 16 Oct 2010 12:52:53 -0600 Subject: Fix Makefile bashism ({,} path expansion) --- Makefile | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'Makefile') diff --git a/Makefile b/Makefile index a53ed9d..5407f1d 100644 --- a/Makefile +++ b/Makefile @@ -99,7 +99,7 @@ install-uzbl-core: all install-dirs install -m644 AUTHORS $(DOCDIR)/ cp -r examples $(INSTALLDIR)/share/uzbl/ chmod 755 $(INSTALLDIR)/share/uzbl/examples/data/scripts/* - mv $(INSTALLDIR)/share/uzbl/examples/config/config{,.bak} + mv $(INSTALLDIR)/share/uzbl/examples/config/config $(INSTALLDIR)/share/uzbl/examples/config/config.bak sed 's#^set prefix.*=.*#set prefix = $(RUN_PREFIX)#' < $(INSTALLDIR)/share/uzbl/examples/config/config.bak > $(INSTALLDIR)/share/uzbl/examples/config/config rm $(INSTALLDIR)/share/uzbl/examples/config/config.bak install -m755 uzbl-core $(INSTALLDIR)/bin/uzbl-core @@ -108,10 +108,10 @@ install-uzbl-browser: install-dirs install -m755 src/uzbl-browser $(INSTALLDIR)/bin/uzbl-browser install -m755 examples/data/scripts/uzbl-cookie-daemon $(INSTALLDIR)/bin/uzbl-cookie-daemon install -m755 examples/data/scripts/uzbl-event-manager $(INSTALLDIR)/bin/uzbl-event-manager - mv $(INSTALLDIR)/bin/uzbl-browser{,.bak} + mv $(INSTALLDIR)/bin/uzbl-browser $(INSTALLDIR)/bin/uzbl-browser.bak sed 's#^PREFIX=.*#PREFIX=$(RUN_PREFIX)#' < $(INSTALLDIR)/bin/uzbl-browser.bak > $(INSTALLDIR)/bin/uzbl-browser rm $(INSTALLDIR)/bin/uzbl-browser.bak - mv $(INSTALLDIR)/bin/uzbl-event-manager{,.bak} + mv $(INSTALLDIR)/bin/uzbl-event-manager $(INSTALLDIR)/bin/uzbl-event-manager.bak sed "s#^PREFIX = .*#PREFIX = '$(RUN_PREFIX)'#" < $(INSTALLDIR)/bin/uzbl-event-manager.bak > $(INSTALLDIR)/bin/uzbl-event-manager rm $(INSTALLDIR)/bin/uzbl-event-manager.bak -- cgit v1.2.3 From 9bea9618424093c6d2cc93954f4cbdd0be4b7637 Mon Sep 17 00:00:00 2001 From: Brendan Taylor Date: Fri, 29 Oct 2010 21:49:38 -0600 Subject: add uzbl-cookie-manager --- Makefile | 18 ++-- examples/uzbl-cookie-manager.c | 211 +++++++++++++++++++++++++++++++++++++++++ src/util.c | 2 +- 3 files changed, 222 insertions(+), 9 deletions(-) create mode 100644 examples/uzbl-cookie-manager.c (limited to 'Makefile') diff --git a/Makefile b/Makefile index 5287d5c..2a08b5c 100644 --- a/Makefile +++ b/Makefile @@ -10,7 +10,7 @@ SRC = $(wildcard src/*.c) HEAD = $(wildcard src/*.h) OBJ = $(foreach obj, $(SRC:.c=.o), $(notdir $(obj))) -all: uzbl-browser +all: uzbl-browser uzbl-cookie-manager VPATH:=src @@ -24,7 +24,11 @@ uzbl-core: ${OBJ} @echo -e "\n${CC} -o $@ ${OBJ} ${LDFLAGS}" @${CC} -o $@ ${OBJ} ${LDFLAGS} -uzbl-browser: uzbl-core +uzbl-cookie-manager: examples/uzbl-cookie-manager.o src/util.o + @echo -e "\n${CC} -o $@ uzbl-cookie-manager.o util.o ${LDFLAGS}" + @${CC} -o $@ uzbl-cookie-manager.o util.o ${LDFLAGS} + +uzbl-browser: uzbl-core uzbl-cookie-manager # packagers, set DESTDIR to your "package directory" and PREFIX to the prefix you want to have on the end-user system # end-users who build from source: don't care about DESTDIR, update PREFIX if you want to @@ -72,10 +76,8 @@ test-uzbl-browser-sandbox: uzbl-browser clean: rm -f uzbl-core - rm -f uzbl-core.o - rm -f events.o - rm -f callbacks.o - rm -f inspector.o + rm -f uzbl-cookie-manager + rm -f *.o find ./examples/ -name "*.pyc" -delete cd ./tests/; $(MAKE) clean rm -rf ./sandbox/ @@ -104,9 +106,9 @@ install-uzbl-core: all install-dirs rm $(INSTALLDIR)/share/uzbl/examples/config/config.bak install -m755 uzbl-core $(INSTALLDIR)/bin/uzbl-core -install-uzbl-browser: install-dirs +install-uzbl-browser: uzbl-cookie-manager install-dirs install -m755 src/uzbl-browser $(INSTALLDIR)/bin/uzbl-browser - install -m755 examples/data/scripts/uzbl-cookie-daemon $(INSTALLDIR)/bin/uzbl-cookie-daemon + install -m755 uzbl-cookie-manager $(INSTALLDIR)/bin/uzbl-cookie-manager install -m755 examples/data/scripts/uzbl-event-manager $(INSTALLDIR)/bin/uzbl-event-manager mv $(INSTALLDIR)/bin/uzbl-browser{,.bak} sed 's#^PREFIX=.*#PREFIX=$(RUN_PREFIX)#' < $(INSTALLDIR)/bin/uzbl-browser.bak > $(INSTALLDIR)/bin/uzbl-browser diff --git a/examples/uzbl-cookie-manager.c b/examples/uzbl-cookie-manager.c new file mode 100644 index 0000000..b873aeb --- /dev/null +++ b/examples/uzbl-cookie-manager.c @@ -0,0 +1,211 @@ +#include +#include +#include + +#include +#include +#include +#include +#include + +#include +#include +#include + +#include "../src/util.h" + +extern const XDG_Var XDG[]; + +int verbose = 0; + +#define SOCK_BACKLOG 10 +#define MAX_COOKIE_LENGTH 4096 + +char cookie_buffer[MAX_COOKIE_LENGTH]; + +int setup_socket(const char *cookied_socket_path) { + int socket_fd = socket(AF_UNIX, SOCK_SEQPACKET, 0); + + if(socket_fd < 0) { + fprintf(stderr, "socket failed (%s)\n", strerror(errno)); + return -1; + } + + struct sockaddr_un sa; + sa.sun_family = AF_UNIX; + strcpy(sa.sun_path, cookied_socket_path); + + if(bind(socket_fd, (struct sockaddr*)&sa, sizeof(sa)) < 0) { + fprintf(stderr, "bind failed (%s)\n", strerror(errno)); + return -1; + } + + if(listen(socket_fd, SOCK_BACKLOG) < 0) { + fprintf(stderr, "listen failed (%s)\n", strerror(errno)); + return -1; + } + + return socket_fd; +} + +void handle_request(SoupCookieJar *j, const char *buff, int len, int fd) { + const char *command = buff; + + const char *scheme = command + strlen(command) + 1; + if((scheme - buff) > len) { + fprintf(stderr, "got malformed or partial request\n"); + return; + } + + const char *host = scheme + strlen(scheme) + 1; + if((host - buff) > len) { + fprintf(stderr, "got malformed or partial request\n"); + return; + } + + const char *path = host + strlen(host) + 1; + if((path - buff) > len) { + fprintf(stderr, "got malformed or partial request\n"); + return; + } + + /* glue the parts back together into a SoupURI */ + char *u = g_strconcat(scheme, "://", host, path, NULL); + if(verbose) printf("%s %s\n", command, u); + SoupURI *uri = soup_uri_new(u); + g_free(u); + + if(!strcmp(command, "GET")) { + char *result = soup_cookie_jar_get_cookies(j, uri, TRUE); + if(result) { + if(verbose) puts(result); + if(write(fd, result, strlen(result)+1) < 0) + fprintf(stderr, "write failed (%s)", strerror(errno)); + + g_free(result); + } else { + if(verbose) puts("-"); + if(write(fd, "", 1) < 0) + fprintf(stderr, "write failed (%s)", strerror(errno)); + } + } else if(!strcmp(command, "PUT")) { + const char *name_and_val = path + strlen(path) + 1; + if((name_and_val - buff) > len) { + fprintf(stderr, "got malformed or partial request\n"); + return; + } + + if(verbose) puts(name_and_val); + + char *eql = strchr(name_and_val, '='); + eql[0] = 0; + + const char *name = name_and_val; + const char *value = eql + 1; + + SoupCookie *cookie = soup_cookie_new(name, value, host, path, SOUP_COOKIE_MAX_AGE_ONE_YEAR); + + soup_cookie_jar_add_cookie(j, cookie); + + if(write(fd, "", 1) < 0) + fprintf(stderr, "write failed (%s)", strerror(errno)); + } + + soup_uri_free(uri); +} + +void usage(const char *progname) { + printf("%s [-s socket-path] [-f cookies.txt] [-w whitelist-file] [-v]\n", progname); +} + +int main(int argc, char *argv[]) { + int i; + + const char *cookies_txt_path = NULL; + const char *cookied_socket_path = NULL; + + for(i = 1; i < argc && argv[i][0] == '-'; i++) { + switch(argv[i][1]) { + case 's': + cookied_socket_path = argv[++i]; + break; + case 'f': + cookies_txt_path = argv[++i]; + break; + case 'v': + verbose = 1; + break; + default: + usage(argv[0]); + return 1; + } + } + + if(!cookies_txt_path) + cookies_txt_path = find_xdg_file(1, "/uzbl/cookies.txt"); + + if(!cookied_socket_path) + cookied_socket_path = g_strconcat(get_xdg_var(XDG[2]), "/uzbl/cookie_daemon_socket", NULL); + + g_type_init(); + + SoupCookieJar *j = soup_cookie_jar_text_new(cookies_txt_path, FALSE); + + int cookie_socket = setup_socket(cookied_socket_path); + if(cookie_socket < 0) { + return 1; + } + + GArray *connections = g_array_new (FALSE, FALSE, sizeof (int)); + + while(1) { + unsigned int i; + int r; + fd_set fs; + + int maxfd = cookie_socket; + FD_ZERO(&fs); + FD_SET(maxfd, &fs); + + for(i = 0; i < connections->len; i++) { + int fd = g_array_index(connections, int, i); + if(fd > maxfd) maxfd = fd; + FD_SET(fd, &fs); + } + + r = select(maxfd+1, &fs, NULL, NULL, NULL); + if(r < 0) { + fprintf(stderr, "select failed (%s)\n", strerror(errno)); + continue; + } + + if(FD_ISSET(cookie_socket, &fs)) { + /* handle new connection */ + int fd = accept(cookie_socket, NULL, NULL); + g_array_append_val(connections, fd); + if(verbose) puts("got connection."); + } + + for(i = 0; i < connections->len; i++) { + /* handle activity on a connection */ + int fd = g_array_index(connections, int, i); + if(FD_ISSET(fd, &fs)) { + r = read(fd, cookie_buffer, MAX_COOKIE_LENGTH); + if(r < 0) { + fprintf(stderr, "read failed (%s)\n", strerror(errno)); + continue; + } else if(r == 0) { + if(verbose) puts("client hung up."); + g_array_remove_index(connections, i); + i--; /* other elements in the array are moved down to fill the gap */ + continue; + } + cookie_buffer[r] = 0; + + handle_request(j, cookie_buffer, r, fd); + } + } + } + + return 0; +} diff --git a/src/util.c b/src/util.c index f6c2e0a..54d1d02 100644 --- a/src/util.c +++ b/src/util.c @@ -6,7 +6,7 @@ #include "util.h" -XDG_Var XDG[] = +const XDG_Var XDG[] = { { "XDG_CONFIG_HOME", "~/.config" }, { "XDG_DATA_HOME", "~/.local/share" }, -- cgit v1.2.3 From d979cd3f383a4b5a1554a81ba09a409328bc8ef8 Mon Sep 17 00:00:00 2001 From: Brendan Taylor Date: Fri, 5 Nov 2010 10:29:06 -0600 Subject: don't link uzbl-cookie-manager with unneeded libs --- Makefile | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'Makefile') diff --git a/Makefile b/Makefile index 2a08b5c..ca1401c 100644 --- a/Makefile +++ b/Makefile @@ -3,8 +3,8 @@ CFLAGS:=-std=c99 $(shell pkg-config --cflags gtk+-2.0 webkit-1.0 libsoup-2.4 gthread-2.0) -ggdb -Wall -W -DARCH="\"$(shell uname -m)\"" -lgthread-2.0 -DCOMMIT="\"$(shell ./misc/hash.sh)\"" $(CPPFLAGS) -fPIC -W -Wall -Wextra -pedantic CFLAGS!=echo -std=c99 `pkg-config --cflags gtk+-2.0 webkit-1.0 libsoup-2.4 gthread-2.0` -ggdb -Wall -W -DARCH='"\""'`uname -m`'"\""' -lgthread-2.0 -DCOMMIT='"\""'`./misc/hash.sh`'"\""' $(CPPFLAGS) -fPIC -W -Wall -Wextra -pedantic -LDFLAGS:=$(shell pkg-config --libs gtk+-2.0 webkit-1.0 libsoup-2.4 gthread-2.0) -pthread $(LDFLAGS) -LDFLAGS!=echo `pkg-config --libs gtk+-2.0 webkit-1.0 libsoup-2.4 gthread-2.0` -pthread $(LDFLAGS) +UZBL_LDFLAGS:=$(shell pkg-config --libs gtk+-2.0 webkit-1.0 libsoup-2.4 gthread-2.0) -pthread $(LDFLAGS) +UZBL_LDFLAGS!=echo `pkg-config --libs gtk+-2.0 webkit-1.0 libsoup-2.4 gthread-2.0` -pthread $(LDFLAGS) SRC = $(wildcard src/*.c) HEAD = $(wildcard src/*.h) @@ -21,12 +21,12 @@ VPATH:=src ${OBJ}: ${HEAD} uzbl-core: ${OBJ} - @echo -e "\n${CC} -o $@ ${OBJ} ${LDFLAGS}" - @${CC} -o $@ ${OBJ} ${LDFLAGS} + @echo -e "\n${CC} -o $@ ${OBJ} ${UZBL_LDFLAGS}" + @${CC} -o $@ ${OBJ} ${UZBL_LDFLAGS} uzbl-cookie-manager: examples/uzbl-cookie-manager.o src/util.o - @echo -e "\n${CC} -o $@ uzbl-cookie-manager.o util.o ${LDFLAGS}" - @${CC} -o $@ uzbl-cookie-manager.o util.o ${LDFLAGS} + @echo -e "\n${CC} -o $@ uzbl-cookie-manager.o util.o ${LDFLAGS} ${shell pkg-config --libs glib-2.0 libsoup-2.4}" + @${CC} -o $@ uzbl-cookie-manager.o util.o ${LDFLAGS} $(shell pkg-config --libs glib-2.0 libsoup-2.4) uzbl-browser: uzbl-core uzbl-cookie-manager -- cgit v1.2.3 From ed2f1606b2bb911623c11462b2c6b0de6ee829a5 Mon Sep 17 00:00:00 2001 From: Brendan Taylor Date: Fri, 5 Nov 2010 17:11:40 -0600 Subject: make uzbl-browser and uzbl-event-manager executable after sedding them --- Makefile | 2 ++ 1 file changed, 2 insertions(+) (limited to 'Makefile') diff --git a/Makefile b/Makefile index 5407f1d..fbe924b 100644 --- a/Makefile +++ b/Makefile @@ -110,9 +110,11 @@ install-uzbl-browser: install-dirs install -m755 examples/data/scripts/uzbl-event-manager $(INSTALLDIR)/bin/uzbl-event-manager mv $(INSTALLDIR)/bin/uzbl-browser $(INSTALLDIR)/bin/uzbl-browser.bak sed 's#^PREFIX=.*#PREFIX=$(RUN_PREFIX)#' < $(INSTALLDIR)/bin/uzbl-browser.bak > $(INSTALLDIR)/bin/uzbl-browser + chmod 755 $(INSTALLDIR)/bin/uzbl-browser rm $(INSTALLDIR)/bin/uzbl-browser.bak mv $(INSTALLDIR)/bin/uzbl-event-manager $(INSTALLDIR)/bin/uzbl-event-manager.bak sed "s#^PREFIX = .*#PREFIX = '$(RUN_PREFIX)'#" < $(INSTALLDIR)/bin/uzbl-event-manager.bak > $(INSTALLDIR)/bin/uzbl-event-manager + chmod 755 $(INSTALLDIR)/bin/uzbl-event-manager rm $(INSTALLDIR)/bin/uzbl-event-manager.bak install-uzbl-tabbed: install-dirs -- cgit v1.2.3 From 63b6c90cb3911a7424f5d30c63526a3b42ab3a5f Mon Sep 17 00:00:00 2001 From: Brendan Taylor Date: Sat, 13 Nov 2010 10:44:07 -0700 Subject: replace uzbl-cookie-daemon with uzbl-cookie-manager in uzbl-browser, also cleanup some outdated comments in u-b --- Makefile | 3 +-- src/uzbl-browser | 29 +++++++++++++---------------- 2 files changed, 14 insertions(+), 18 deletions(-) (limited to 'Makefile') diff --git a/Makefile b/Makefile index ca1401c..81df414 100644 --- a/Makefile +++ b/Makefile @@ -66,10 +66,9 @@ test-uzbl-browser-sandbox: uzbl-browser make DESTDIR=./sandbox RUN_PREFIX=`pwd`/sandbox/usr/local install-uzbl-browser make DESTDIR=./sandbox RUN_PREFIX=`pwd`/sandbox/usr/local install-example-data cp -np ./misc/env.sh ./sandbox/env.sh - source ./sandbox/env.sh && uzbl-cookie-daemon restart -nv & + source ./sandbox/env.sh && uzbl-cookie-manager -v & source ./sandbox/env.sh && uzbl-event-manager restart -navv & source ./sandbox/env.sh && uzbl-browser --uri http://www.uzbl.org --verbose - source ./sandbox/env.sh && uzbl-cookie-daemon stop -v source ./sandbox/env.sh && uzbl-event-manager stop -ivv make DESTDIR=./sandbox uninstall rm -rf ./sandbox/usr diff --git a/src/uzbl-browser b/src/uzbl-browser index de4f7af..9f6847b 100755 --- a/src/uzbl-browser +++ b/src/uzbl-browser @@ -1,13 +1,11 @@ #!/bin/sh -# this script implements a more useful out-of-the-box "browsing experience". -# it does so by combining uzbl-core with a set of "recommended" tools and practices. -# see docs for more info -# If you want to customize the behavior of the cookie-daemon or similar helper tools, -# copy them to your $XDG_DATA_HOME/uzbl/scripts/, edit them and update $PATH - -# Also, we assume existence of fifo/socket == correctly functioning cookie_daemon/event_manager. -# Checking correct functioning of the daemons here would be too complex here, and it's not implemented in uzbl-core either. -# But this shouldn't cause much problems.. +# +# This script implements a more useful out-of-the-box "browsing experience". +# It does so by combining uzbl-core with a set of "recommended" tools and +# practices. See docs for more info. +# +# If you want to customize the behavior any of the helper tools, copy them +# to your $XDG_DATA_HOME/uzbl/scripts/ and edit them PREFIX=/usr/local if [ -z "$XDG_DATA_HOME" ] @@ -37,6 +35,7 @@ do fi fi done + # if no config exists yet in the recommended location, put the default (recommended) config there if [ ! -f $XDG_CONFIG_HOME/uzbl/config ] then @@ -47,17 +46,15 @@ then fi fi -# Uncomment this for a slight speedup at the expense of not having -# stale cookie daemon sockets cleaned up. -#if [ ! -S $XDG_CACHE_HOME/uzbl/cookie_daemon_socket ] -#then - # if you want to customize it, copy to your $XDG_DATA_HOME/uzbl/scripts/ and update $PATH - uzbl-cookie-daemon -v start -#fi +# uzbl-cookie-manager will exit if another instance is already running +uzbl-cookie-manager DAEMON_SOCKET=$XDG_CACHE_HOME/uzbl/event_daemon DAEMON_PID=${DAEMON_SOCKET}.pid +# uzbl-event-manager will exit if one is already running, but you could +# check if the pid file exists here to avoid having to spawn it for a +# slight speedup #if [ -f "$DAEMON_PID" ] #then uzbl-event-manager -va start -- cgit v1.2.3 From a63c3af9b14695579dfbec2681e34f9f40655085 Mon Sep 17 00:00:00 2001 From: Brendan Taylor Date: Sat, 13 Nov 2010 11:10:16 -0700 Subject: shutdown uzbl-cookie-manager in test-uzbl-browser-sandbox --- Makefile | 1 + 1 file changed, 1 insertion(+) (limited to 'Makefile') diff --git a/Makefile b/Makefile index 81df414..0d8e750 100644 --- a/Makefile +++ b/Makefile @@ -69,6 +69,7 @@ test-uzbl-browser-sandbox: uzbl-browser source ./sandbox/env.sh && uzbl-cookie-manager -v & source ./sandbox/env.sh && uzbl-event-manager restart -navv & source ./sandbox/env.sh && uzbl-browser --uri http://www.uzbl.org --verbose + kill `cat ./sandbox/home/.cache/uzbl/cookie_daemon_socket.pid` source ./sandbox/env.sh && uzbl-event-manager stop -ivv make DESTDIR=./sandbox uninstall rm -rf ./sandbox/usr -- cgit v1.2.3 From 8b158f3f15c72f9a03ce9313d679351ab3714607 Mon Sep 17 00:00:00 2001 From: Brendan Taylor Date: Sun, 14 Nov 2010 05:45:59 -0700 Subject: add test-uzbl-tabbed-sandbox make rule --- Makefile | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'Makefile') diff --git a/Makefile b/Makefile index 3d0ff47..dba0838 100644 --- a/Makefile +++ b/Makefile @@ -74,6 +74,19 @@ test-uzbl-browser-sandbox: uzbl-browser make DESTDIR=./sandbox uninstall rm -rf ./sandbox/usr +test-uzbl-tabbed-sandbox: uzbl-browser + make DESTDIR=./sandbox RUN_PREFIX=`pwd`/sandbox/usr/local install-uzbl-core + make DESTDIR=./sandbox RUN_PREFIX=`pwd`/sandbox/usr/local install-uzbl-browser + make DESTDIR=./sandbox RUN_PREFIX=`pwd`/sandbox/usr/local install-example-data + cp -np ./misc/env.sh ./sandbox/env.sh + source ./sandbox/env.sh && uzbl-cookie-manager -v & + source ./sandbox/env.sh && uzbl-event-manager restart -navv & + source ./sandbox/env.sh && ./sandbox/home/.local/share/uzbl/scripts/uzbl-tabbed + kill `cat ./sandbox/home/.cache/uzbl/cookie_daemon_socket.pid` + source ./sandbox/env.sh && uzbl-event-manager stop -ivv + make DESTDIR=./sandbox uninstall + rm -rf ./sandbox/usr + clean: rm -f uzbl-core rm -f uzbl-cookie-manager -- cgit v1.2.3 From 117ecbb84f1851b0029239731af2f09786dddb08 Mon Sep 17 00:00:00 2001 From: Brendan Taylor Date: Sat, 20 Nov 2010 11:08:32 -0700 Subject: add test-uzbl-tabbed-sandbox make rule --- Makefile | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) (limited to 'Makefile') diff --git a/Makefile b/Makefile index 5287d5c..a6c76d6 100644 --- a/Makefile +++ b/Makefile @@ -62,14 +62,27 @@ test-uzbl-browser-sandbox: uzbl-browser make DESTDIR=./sandbox RUN_PREFIX=`pwd`/sandbox/usr/local install-uzbl-browser make DESTDIR=./sandbox RUN_PREFIX=`pwd`/sandbox/usr/local install-example-data cp -np ./misc/env.sh ./sandbox/env.sh - source ./sandbox/env.sh && uzbl-cookie-daemon restart -nv & - source ./sandbox/env.sh && uzbl-event-manager restart -navv & + -source ./sandbox/env.sh && uzbl-cookie-daemon restart -v + -source ./sandbox/env.sh && uzbl-event-manager restart -avv source ./sandbox/env.sh && uzbl-browser --uri http://www.uzbl.org --verbose source ./sandbox/env.sh && uzbl-cookie-daemon stop -v source ./sandbox/env.sh && uzbl-event-manager stop -ivv make DESTDIR=./sandbox uninstall rm -rf ./sandbox/usr +test-uzbl-tabbed-sandbox: uzbl-browser + make DESTDIR=./sandbox RUN_PREFIX=`pwd`/sandbox/usr/local install-uzbl-core + make DESTDIR=./sandbox RUN_PREFIX=`pwd`/sandbox/usr/local install-uzbl-browser + make DESTDIR=./sandbox RUN_PREFIX=`pwd`/sandbox/usr/local install-example-data + cp -np ./misc/env.sh ./sandbox/env.sh + -source ./sandbox/env.sh && uzbl-cookie-daemon restart -v + -source ./sandbox/env.sh && uzbl-event-manager restart -avv + source ./sandbox/env.sh && ./sandbox/home/.local/share/uzbl/scripts/uzbl-tabbed + source ./sandbox/env.sh && uzbl-cookie-daemon stop -v + source ./sandbox/env.sh && uzbl-event-manager stop -ivv + make DESTDIR=./sandbox uninstall + rm -rf ./sandbox/usr + clean: rm -f uzbl-core rm -f uzbl-core.o -- cgit v1.2.3