about summary refs log tree commit diff
diff options
context:
space:
mode:
-rwxr-xr-xconfigure5
-rw-r--r--notemap.c76
2 files changed, 3 insertions, 78 deletions
diff --git a/configure b/configure
index 907a369..57d878a 100755
--- a/configure
+++ b/configure
@@ -31,13 +31,8 @@ for opt; do
 done
 
 case "$(uname)" in
-	(FreeBSD)
-		config libtls
-		defstr DRILL_PATH /usr/bin/drill
-		;;
 	(OpenBSD)
 		ldlibs -ltls
-		defstr DIG_PATH /usr/bin/dig
 		;;
 	(Linux)
 		cflags -D_GNU_SOURCE -DDECLARE_RPP
diff --git a/notemap.c b/notemap.c
index 1849c44..e2b41dc 100644
--- a/notemap.c
+++ b/notemap.c
@@ -51,78 +51,8 @@ char * readpassphrase(const char *prompt, char *buf, size_t bufsiz, int flags);
 
 #include "imap.h"
 
-#ifndef DIG_PATH
-#define DIG_PATH "dig"
-#endif
-
 typedef unsigned char byte;
 
-static void lookup(const char **host, const char **port, const char *domain) {
-	static char buf[1024];
-	snprintf(buf, sizeof(buf), "_imaps._tcp.%s", domain);
-
-	int rw[2];
-	int error = pipe(rw);
-	if (error) err(EX_OSERR, "pipe");
-
-	pid_t pid = fork();
-	if (pid < 0) err(EX_OSERR, "fork");
-
-	if (!pid) {
-		close(rw[0]);
-		dup2(rw[1], STDOUT_FILENO);
-		dup2(rw[1], STDERR_FILENO);
-		close(rw[1]);
-#ifdef DRILL_PATH
-		execlp(DRILL_PATH, "drill", buf, "SRV", NULL);
-		err(EX_CONFIG, "%s", DRILL_PATH);
-#else
-		execlp(DIG_PATH, "dig", "-t", "SRV", "-q", buf, "+short", NULL);
-		err(EX_CONFIG, "%s", DIG_PATH);
-#endif
-	}
-
-	int status;
-	pid = wait(&status);
-	if (pid < 0) err(EX_OSERR, "wait");
-
-	close(rw[1]);
-	FILE *pipe = fdopen(rw[0], "r");
-	if (!pipe) err(EX_IOERR, "fdopen");
-
-	fgets(buf, sizeof(buf), pipe);
-	if (ferror(pipe)) err(EX_IOERR, "fgets");
-
-	if (!WIFEXITED(status) || WEXITSTATUS(status)) {
-		fprintf(stderr, "%s", buf);
-		exit(WEXITSTATUS(status));
-	}
-
-	char *ptr = buf;
-#ifdef DRILL_PATH
-	for (;;) {
-		char *line = fgets(buf, sizeof(buf), pipe);
-		if (!line || !strcmp(line, ";; ANSWER SECTION:\n")) break;
-	}
-	fgets(buf, sizeof(buf), pipe);
-	if (ferror(pipe)) err(EX_IOERR, "fgets");
-	ptr = strrchr(buf, '\t');
-	ptr = (ptr ? ptr + 1 : buf);
-#endif
-	fclose(pipe);
-
-	char *dot = strrchr(ptr, '.');
-	if (dot) *dot = '\0';
-	strsep(&ptr, " \n"); // priority
-	strsep(&ptr, " \n"); // weight
-	*port = strsep(&ptr, " \n");
-	*host = strsep(&ptr, " \n");
-	if (!*host) {
-		*host = domain;
-		*port = "imaps";
-	}
-}
-
 static const char *uuidGen(void) {
 	byte uuid[16];
 	int error = getentropy(uuid, sizeof(uuid));
@@ -256,9 +186,9 @@ int main(int argc, char *argv[]) {
 	argc -= optind;
 	
 	if (!host) {
-		const char *domain = strchr(user, '@');
-		if (!domain) errx(EX_USAGE, "no domain in username");
-		lookup(&host, &port, &domain[1]);
+		host = strchr(user, '@');
+		if (!host) errx(EX_USAGE, "no domain in username");
+		host++;
 	}
 
 	char buf[1024];