summary refs log tree commit diff
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--bounce.c30
-rw-r--r--pounce.122
2 files changed, 42 insertions, 10 deletions
diff --git a/bounce.c b/bounce.c
index a167cea..1257b93 100644
--- a/bounce.c
+++ b/bounce.c
@@ -55,12 +55,26 @@ static void eventRemove(size_t i) {
 	event.clients[i] = event.clients[event.len];
 }
 
-static char *censor(char *arg) {
-	char *dup = strdup(arg);
-	if (!dup) err(EX_OSERR, "strdup");
-	memset(arg, '\0', strlen(dup));
+static char *sensitive(char *arg) {
+	char *value = NULL;
+	if (arg[0] == '@') {
+		FILE *file = fopen(&arg[1], "r");
+		if (!file) err(EX_NOINPUT, "%s", &arg[1]);
+
+		size_t cap = 0;
+		ssize_t len = getline(&value, &cap, file);
+		if (len < 0) err(EX_IOERR, "%s", &arg[1]);
+
+		if (len && value[len - 1] == '\n') value[len - 1] = '\0';
+		fclose(file);
+
+	} else {
+		value = strdup(arg);
+		if (!value) err(EX_OSERR, "strdup");
+	}
+	memset(arg, '\0', strlen(arg));
 	arg[0] = '*';
-	return dup;
+	return value;
 }
 
 int main(int argc, char *argv[]) {
@@ -85,8 +99,8 @@ int main(int argc, char *argv[]) {
 			break; case 'H': localHost = optarg;
 			break; case 'K': strlcpy(privPath, optarg, sizeof(privPath));
 			break; case 'P': localPort = optarg;
-			break; case 'W': clientPass = censor(optarg);
-			break; case 'a': auth = censor(optarg);
+			break; case 'W': clientPass = sensitive(optarg);
+			break; case 'a': auth = sensitive(optarg);
 			break; case 'h': host = optarg;
 			break; case 'j': join = optarg;
 			break; case 'n': nick = optarg;
@@ -94,7 +108,7 @@ int main(int argc, char *argv[]) {
 			break; case 'r': real = optarg;
 			break; case 'u': user = optarg;
 			break; case 'v': verbose = true;
-			break; case 'w': pass = censor(optarg);
+			break; case 'w': pass = sensitive(optarg);
 			break; default:  return EX_USAGE;
 		}
 	}
diff --git a/pounce.1 b/pounce.1
index 156a511..72ee806 100644
--- a/pounce.1
+++ b/pounce.1
@@ -38,7 +38,7 @@ and uniquely identify themselves by username.
 .Pp
 The arguments are as follows:
 .
-.Bl -tag -width "-C cert"
+.Bl -tag -width "-W @file"
 .It Fl C Ar cert
 Load TLS certificate from
 .Ar cert .
@@ -74,11 +74,23 @@ Require the password
 .Ar pass
 to connect.
 .
+.It Fl W Cm @ Ns Ar file
+Set
+.Fl W Ar pass
+to the first line read from
+.Ar file .
+.
 .It Fl a Ar auth
 Authenticate with SASL PLAIN.
 .Ar auth
 is a colon-separated username and password.
 .
+.It Fl a Cm @ Ns Ar file
+Set
+.Fl a Ar auth
+to the first line read from
+.Ar file .
+.
 .It Fl h Ar host
 Connect to
 .Ar host .
@@ -117,6 +129,12 @@ and blue to clients.
 .It Fl w Ar pass
 Log in with the password
 .Ar pass .
+.
+.It Fl w Cm @ Ns Ar file
+Set
+.Fl w Ar pass
+to the first line read from
+.Ar file .
 .El
 .
 .Pp
@@ -133,7 +151,7 @@ The default nickname.
 .El
 .
 .Sh EXAMPLES
-.Bd -literal -offset indent
+.Bd -literal
 .Nm Fl H Li pounce.example.org Fl h Li chat.freenode.net Fl j Li '#ascii.town'
 .Ed
 .
tr> 2020-02-11Exit focus and paste modes on err exitJune McEnroe 2020-02-11Add startup GPLv3 note and URLJune McEnroe I am a degenerate. 2020-02-11Make sure -D_GNU_SOURCE ends up in CFLAGS on LinuxJune McEnroe 2020-02-11Add note about setting PKG_CONFIG_PATHJune McEnroe 2020-02-11Rename query ID on nick changeJune McEnroe 2020-02-11Call completeClear when closing a windowJune McEnroe 2020-02-11Don't insert color codes for non-mentionsJune McEnroe 2020-02-11Take first two words in colorMentionsJune McEnroe This lets phrases like "hi june" get colored, but still doesn't get carried away. 2020-02-11Use time_t for save signatureJune McEnroe It's actually more likely to be 64-bit than size_t anyway, and it eliminates some helper functions. Also don't error when reading an empty save file. 2020-02-11Set self.nick to * initiallyJune McEnroe Allows removing a bunch of checks that self.nick is set, and it's what the server usually calls you before registration. Never highlight notices as mentions. 2020-02-11Define ColorCap instead of hardcoding 100June McEnroe 2020-02-11Move hash to top of chat.hJune McEnroe 2020-02-11Move base64 out of chat.hJune McEnroe 2020-02-11Move XDG_SUBDIR out of chat.hJune McEnroe 2020-02-11Fix whois idle unit calculationJune McEnroe Rookie mistake. 2020-02-11Cast towupper to wchar_tJune McEnroe For some reason it takes and returns wint_t... 2020-02-11Cast set but unused variables to voidJune McEnroe 2020-02-11Declare strlcatJune McEnroe 2020-02-11Check if VDSUSP existsJune McEnroe 2020-02-11Fix completeReplace iterationJune McEnroe 2020-02-11Use pkg(8) to configure on FreeBSDJune McEnroe 2020-02-11Remove legacy codeJune McEnroe 2020-02-11Add INSTALLING section to READMEJune McEnroe