commit - 0f559c556ffae888dccd908739c09005bedbf6d0
commit + 4cf6ba137fc2ca92f3066c390b89542d88735ef6
blob - 265e705c9a2c4a1917bddc5d07f838847b635c6e
blob + d7293171fd6f3b450a3e0c8b472bf8acaa83e432
--- Makefile.am
+++ Makefile.am
telescope_SOURCES = cmd.c \
cmd.gen.c \
compl.c \
+ control.c \
defaults.c \
downloads.c \
fs.c \
include/cmd.h \
include/compat.h \
include/compl.h \
+ include/control.h \
include/defaults.h \
include/fs.h \
include/keymap.h \
blob - eb0e0e72278479b0d75de55646689c421aa9b1df
blob + f7631998b7a0f5abf1fc2d827c8610be026c3ff0
--- fs.c
+++ fs.c
char data_path_base[PATH_MAX];
char cache_path_base[PATH_MAX];
+char ctlsock_path[PATH_MAX];
char config_path[PATH_MAX];
char lockfile_path[PATH_MAX];
char bookmark_file[PATH_MAX];
{
init_paths();
+ join_path(ctlsock_path, cache_path_base, "/ctl",
+ sizeof(ctlsock_path));
join_path(config_path, config_path_base, "/config",
sizeof(config_path));
join_path(lockfile_path, cache_path_base, "/lock",
blob - c1a0fce9a9af9b827c7f23a1ee95b36269b4cd3f
blob + 6337fed6e6cfa36597a25e71245cf9b17eec0d16
--- include/fs.h
+++ include/fs.h
extern char data_path_base[PATH_MAX];
extern char cache_path_base[PATH_MAX];
+extern char ctlsock_path[PATH_MAX];
extern char config_path[PATH_MAX];
extern char lockfile_path[PATH_MAX];
extern char bookmark_file[PATH_MAX];
blob - 23b5fe74d9e6ef4a90f187460e9620a548bc523d
blob + 66bad0bf2f576e29b0f3724503635a7823945e35
--- include/telescope.h
+++ include/telescope.h
IMSG_SESSION_TAB,
IMSG_SESSION_TAB_HIST,
IMSG_SESSION_END,
+
+ IMSG_CTL_OPEN_URL,
};
enum line_type {
blob - 4ce510af9bce453b372b9f7fc77068b879b2b563
blob + 0f2c57ee4215b0e220bf6d9e0f1a1f0ae42ae4c6
--- sandbox.c
+++ sandbox.c
void
sandbox_ui_process(void)
{
- if (pledge("stdio tty recvfd", NULL) == -1)
+ if (pledge("stdio tty unix recvfd", NULL) == -1)
err(1, "pledge");
}
blob - cce3b0a13dbdcac30ab92ff4f795cb0eedf830ca
blob + 61f4fec2fae4c283a874d775710363ada79f4885
--- telescope.c
+++ telescope.c
#include "compat.h"
#include <sys/socket.h>
+#include <sys/un.h>
#include <sys/wait.h>
#include <errno.h>
#include <string.h>
#include <unistd.h>
+#include "control.h"
#include "defaults.h"
#include "fs.h"
#include "mcache.h"
static int make_fs_request(struct tab *, int, const char *);
static int do_load_url(struct tab *, const char *, const char *, int);
static pid_t start_child(enum telescope_process, const char *, int);
+static void send_url(const char *);
static struct proto {
const char *schema;
argv[argc++] = NULL;
execvp(argv0, (char *const *)argv);
err(1, "execvp(%s)", argv0);
+}
+
+static void
+send_url(const char *url)
+{
+ struct sockaddr_un sun;
+ struct imsgbuf ibuf;
+ int ctl_sock;
+
+ if ((ctl_sock = socket(AF_UNIX, SOCK_STREAM, 0)) == -1)
+ err(1, "socket");
+
+ memset(&sun, 0, sizeof(sun));
+ sun.sun_family = AF_UNIX;
+ strlcpy(sun.sun_path, ctlsock_path, sizeof(sun.sun_path));
+
+ if (connect(ctl_sock, (struct sockaddr *)&sun, sizeof(sun)) == -1)
+ err(1, "connect: %s", ctlsock_path);
+
+ imsg_init(&ibuf, ctl_sock);
+ imsg_compose(&ibuf, IMSG_CTL_OPEN_URL, 0, 0, -1, url,
+ strlen(url) + 1);
+ imsg_flush(&ibuf);
+ close(ctl_sock);
}
int
{
struct imsgev net_ibuf, fs_ibuf;
pid_t pid;
+ int control_fd;
int pipe2net[2], pipe2fs[2];
int ch, configtest = 0, fail = 0;
int proc = -1;
(download_path = strdup("/tmp/")) == NULL)
errx(1, "strdup");
- if (!safe_mode && (sessionfd = lock_session()) == -1)
+ if (!safe_mode && (sessionfd = lock_session()) == -1) {
+ if (has_url) {
+ send_url(url);
+ exit(0);
+ }
+
errx(1, "can't lock session, is another instance of "
"telescope already running?");
+ }
/* Start children. */
if (socketpair(AF_UNIX, SOCK_STREAM, PF_UNSPEC, pipe2fs) == -1)
event_init();
+ if (!safe_mode) {
+ if ((control_fd = control_init(ctlsock_path)) == -1)
+ err(1, "control_init %s", ctlsock_path);
+ control_listen(control_fd);
+ }
+
/* initialize the in-memory cache store */
mcache_init();