[Pkg-privacy-commits] [irssi-plugin-otr] 38/267: added otr_policy_known, added support for glob patterns and rewrote the README.

Ximin Luo infinity0 at moszumanska.debian.org
Sat Aug 22 12:41:26 UTC 2015


This is an automated email from the git hooks/post-receive script.

infinity0 pushed a commit to branch debian
in repository irssi-plugin-otr.

commit cdcb128e39ca38e5ad494e8ce0baf927de445196
Author: Uli Meis <a.sporto+bee at gmail.com>
Date:   Tue Jan 20 01:01:56 2009 +0100

    added otr_policy_known, added support for glob patterns and rewrote the README.
---
 ChangeLog      |  3 ++-
 README         | 65 +++++++++++++++++++++++++++++++++++-----------------------
 makeformats.py |  2 +-
 otr.c          |  6 ++++--
 otr.h          |  5 ++---
 otr_ops.c      | 41 +++++++++++++++++++++++-------------
 otrutil.c      | 25 ++++++++++++----------
 7 files changed, 89 insertions(+), 58 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 63d9d9d..779f3cc 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,7 +1,8 @@
 Version 0.3
-	* added settings otr_policy and otr_ignore
+	* added settings otr_policy, otr_policy_known and otr_ignore
 	* fixed two segfault sources
 	* key generation now operates on a temp file
+	* the .irssi/otr dir now gets created with mode 700
 	* commands now take an optional nick at server argument
 	  (for single message window users)
 	* changed loglevel of otr_log (heartbeats) and otr_finish
diff --git a/README b/README
index d1d3c54..70781e5 100644
--- a/README
+++ b/README
@@ -1,38 +1,51 @@
-Usually, you shouldn't have to do anything besides "/load otr" to have encrypted
-conversations. Just  write something, wait  about 10  seconds and you  should go
-secure. Not the first time though, see  the next paragraph about keys. Also some
-uncommon IRC  servers strip off the  whitespace OTR uses as  announcement, there
-you or your buddy will have to type "?OTR?" to get going.
-
-Initially  a  private key  will  have  to be  generated.  OTR  will trigger  key
-generation itself once  you talk to someone  with OTR. You can  however start it
-yourself with "/otr genkey nick at irc.server.com". That can take two minutes or on
-some systems even an hour. To speed up the process you can generate some entropy
-by running something like "du /" in parallel.
+Quick start: Do "/load otr", write "?OTR?" to your OTR buddy, wait until the now
+ongoing key generation finishs and write "?OTR?" again. You should "go secure".
+
+Key generation happens in a seperate  process and its duration mainly depends on
+the available entropy. On  my desktop it takes about 6  Minutes, about 2 Minutes
+if I run  "du /" in parallel  and on an idle  server system it can  even take an
+hour.
+
+The  default  OTR policy  of  irssi-otr  is  now  something between  manual  and
+opportunistic. Manual means  you have to start it yourself  by issueing "?OTR?",
+opportunistic means  both peers send  some magic  whitespace and start  OTR once
+they  receive this  whitespace from  the other  side. irssi-otr  uses a  mode in
+between  where  we  are  not  sending  whitespace  as  an  announcement  (as  in
+opportunistic) but we still  handle whitespace if we see it  from the other side
+(I'm  calling  it handlews).  Therefore  if  your  peer uses  opportunistic  the
+handshake should still start automatically once he writes something.
+
+You can  now set the  OTR policy  per peer via  the otr_policy /setting.  It's a
+comma seperated  list of "<nick>@<server> <policy>"  pairs where <nick>@<server>
+is interpreted as a glob pattern, i.e. you can use wildcard "*" and joker "?" as
+you would  in a shell.  The policy  can be one  of never, manual,  handlews (the
+default),  opportunistic, and  always. Be  aware that  the opportunistic  policy
+fails with  some IRC  servers since  they strip off  the whitespace.  The always
+policy has  the nice side effect  that the first  line you type will  already be
+encrypted.
+
+If  a  fingerprint can  be  found  for someone,  i.e.  someone  you had  an  OTR
+conversation  with  before,  then  the otr_policy_known  setting  applies  after
+otr_policy. It has the same syntax. The  default is "* always", i.e. enforce OTR
+with  anyone you've  used  OTR with  before.
+
+Should you finish an OTR session via "/otr finish" and should the active policy
+be always or opportunistic then it will be temporarily set back to handlews.
+Otherwise OTR would start again right away which is probably not what you want.
+This is however reset once you close the query window.
 
 To make  sure that you are  actually talking to your  buddy, you can agree  on a
 secret somehow  and then one does  "/otr auth <secret>". Shortly  afterwards the
-other one will be asked to do  the same and you're done.
+other  one will  be  asked to  do  the  same and  you're  done. The  traditional
+alternative, comparing  fingerprints over a secure  line, can also be  used. Use
+"/otr trust" once you're sure they match.
 
 I also strongly  recommend to do "/statusbar window add  otr" so you're informed
-about  what's going  on.
+about what's going on.
 
 In  "~/.irssi/otr/otr.{key,fp}" you'll  find the  fingerprints and  your private
 keys(should you at any point be interested).
 
-The standard  OTR policy  is opportunistic, meaning  we'll send  some whitespace
-after messages and we'll also look for it from our peer. Should we see the magic
-whitespace from  our peer  we'll start a  handshake. If at  any point  you enter
-"/otr finish" then the  policy is changed so as not  to send whitespace anymore.
-Therefore, if your peer  has the same behaviour, OTR will  not start again. This
-is however  reset once you  close the  query window. When  you open a  new query
-window OTR  will start sending whitespace  again which might cause  your peer to
-start an OTR session.
-
-Don't expect any of  this to work if you are using a  single messages window and
-not a  query window per  buddy (as in "/SET  use_msgs_window ON"). I  just heard
-about that, certainly needs some work to support that mode.
-
 Commands:
 
 /otr genkey nick at irc.server.com 
diff --git a/makeformats.py b/makeformats.py
index 212892c..c63003f 100755
--- a/makeformats.py
+++ b/makeformats.py
@@ -17,7 +17,7 @@ src.write('#include "otr.h"\n');
 src.write("""char *otr_help = "%s";\n""" % "\\n".join(
 	["%9- OTR help -%9"]+
 	[re.sub('^(/otr.*)$','%_\\1%_',
-		re.sub('"(.*)"','\\"%_\\1%_\\"',
+		re.sub('"([^"]*)"','\\"%_\\1%_\\"',
 			x.replace('\n','').replace("\t","        ") 
 			))
 		for x in open(sys.argv[2],"r").readlines()]
diff --git a/otr.c b/otr.c
index 36aab99..f824763 100644
--- a/otr.c
+++ b/otr.c
@@ -270,7 +270,8 @@ static void otr_statusbar(struct SBAR_ITEM_REC *item, int get_size_only)
 
 static void read_settings(void)
 {
-	otr_setpolicies(settings_get_str("otr_policy"));
+	otr_setpolicies(settings_get_str("otr_policy"),FALSE);
+	otr_setpolicies(settings_get_str("otr_policy_known"),TRUE);
 #ifdef HAVE_GREGEX_H
 	if (regex_nickignore)
 		g_regex_unref(regex_nickignore);
@@ -306,7 +307,8 @@ void otr_init(void)
 	command_bind("otr contexts", NULL, (SIGNAL_FUNC) cmd_contexts);
 	command_bind("otr version", NULL, (SIGNAL_FUNC) cmd_version);
 
-	settings_add_str("otr", "otr_policy","*@localhost opportunistic,*@im.bitlbee.org opportunistic");
+	settings_add_str("otr", "otr_policy","*@localhost opportunistic,*bitlbee* opportunistic,*@im.* opportunistic");
+	settings_add_str("otr", "otr_policy_known","* always");
 	settings_add_str("otr", "otr_ignore","xmlconsole[0-9]*");
 	read_settings();
 	signal_add("setup changed", (SIGNAL_FUNC) read_settings);
diff --git a/otr.h b/otr.h
index 35628b3..c9ff3e1 100644
--- a/otr.h
+++ b/otr.h
@@ -102,8 +102,7 @@ struct ctxlist_ {
 /* policy list generated from /set otr_policy */
 
 struct plistentry {
-	char *user;
-	char *server;
+	GPatternSpec *namepat;
 	OtrlPolicy policy;
 };
 
@@ -115,7 +114,7 @@ extern int debug;
 int otrlib_init();
 void otrlib_deinit();
 void otr_initops();
-void otr_setpolicies(const char *policies);
+void otr_setpolicies(const char *policies, int known);
 
 /* basic send/receive/status stuff */
 
diff --git a/otr_ops.c b/otr_ops.c
index cc87836..bd16486 100644
--- a/otr_ops.c
+++ b/otr_ops.c
@@ -21,7 +21,7 @@
 
 OtrlMessageAppOps otr_ops;
 extern OtrlUserState otr_state;
-extern GSList *plist;
+extern GSList *plistunknown,*plistknown;
 
 OtrlPolicy IO_DEFAULT_POLICY =
 	OTRL_POLICY_MANUAL|OTRL_POLICY_WHITESPACE_START_AKE;
@@ -34,24 +34,37 @@ OtrlPolicy ops_policy(void *opdata, ConnContext *context)
 	struct co_info *coi = context->app_data;
 	char *server = strchr(context->accountname,'@')+1;
 	OtrlPolicy op = IO_DEFAULT_POLICY;
-	GSList *pl = plist;
+	GSList *pl;
+	char fullname[1024];
 
-	if (!plist)
-		return op;
+	sprintf(fullname, "%s@%s", context->username, server);
 
-	do {
-		struct plistentry *ple = pl->data;
+	/* loop through otr_policy */
 
-		if (!(*ple->user=='*')&&
-		    (strcmp(ple->user,context->username)!=0))
-			continue;
-		if (!(*ple->server=='*')&&
-		    (strcmp(ple->server,server)!=0))
-			continue;
+	if (plistunknown) {
+		pl = plistunknown;
+		do {
+			struct plistentry *ple = pl->data;
 
-		op = ple->policy;
+			if (g_pattern_match_string(ple->namepat,fullname))
+				op = ple->policy;
 
-	} while ((pl = g_slist_next(pl)));
+		} while ((pl = g_slist_next(pl)));
+	}
+
+	if (plistknown&&context->fingerprint_root.next) {
+		pl = plistknown;
+
+		/* loop through otr_policy_known */
+
+		do {
+			struct plistentry *ple = pl->data;
+
+			if (g_pattern_match_string(ple->namepat,fullname))
+				op = ple->policy;
+
+		} while ((pl = g_slist_next(pl)));
+	}
 
 	if (coi && coi->finished &&
 	    (op == OTRL_POLICY_OPPORTUNISTIC ||
diff --git a/otrutil.c b/otrutil.c
index 17262ae..ecf1f58 100644
--- a/otrutil.c
+++ b/otrutil.c
@@ -24,7 +24,8 @@
 OtrlUserState otr_state = NULL;
 extern OtrlMessageAppOps otr_ops;
 static int otrinited = FALSE;
-GSList *plist = NULL;
+GSList *plistunknown = NULL;
+GSList *plistknown = NULL;
 
 #ifdef HAVE_GREGEX_H
 GRegex *regex_policies;
@@ -52,7 +53,7 @@ int otrlib_init()
 
 #ifdef HAVE_GREGEX_H
 	regex_policies = 
-		g_regex_new("([^ @]*@[^ @]*) (never|manual|handlews|opportunistic|always)"
+		g_regex_new("([^,]+) (never|manual|handlews|opportunistic|always)"
 			    "(,|$)",0,0,NULL);
 #endif
 
@@ -72,7 +73,8 @@ void otrlib_deinit()
 
 	keygen_abort(TRUE);
 
-	otr_setpolicies("");
+	otr_setpolicies("",FALSE);
+	otr_setpolicies("",TRUE);
 
 #ifdef HAVE_GREGEX_H
 	g_regex_unref(regex_policies);
@@ -721,16 +723,17 @@ char *otr_receive(SERVER_REC *server, const char *msg,const char *from)
 	return newmessage ? : (char*)msg;
 }
 
-void otr_setpolicies(const char *policies)
+void otr_setpolicies(const char *policies, int known)
 {
 #ifdef HAVE_GREGEX_H
 	GMatchInfo *match_info;
+	GSList *plist = known ? plistknown : plistunknown;
 
 	if (plist) {
 		GSList *p = plist;
 		do {
 			struct plistentry *ple = p->data;
-			g_free(ple->user);
+			g_pattern_spec_free(ple->namepat);
 			g_free(p->data);
 		} while ((p = g_slist_next(p)));
 
@@ -742,14 +745,9 @@ void otr_setpolicies(const char *policies)
 
 	while(g_match_info_matches(match_info)) {
 		struct plistentry *ple = (struct plistentry *)g_malloc0(sizeof(struct plistentry));
-		char *name = g_match_info_fetch(match_info, 1);
 		char *pol = g_match_info_fetch(match_info, 2);
-		char *server = strchr(name,'@');
 
-		*server++ = '\0';
-
-		ple->user = name;
-		ple->server = server;
+		ple->namepat = g_pattern_spec_new(g_match_info_fetch(match_info, 1));
 		
 		switch (*pol) {
 		case 'n':
@@ -777,5 +775,10 @@ void otr_setpolicies(const char *policies)
 	}
 
 	g_match_info_free(match_info);
+
+	if (known)
+		plistknown = plist;
+	else
+		plistunknown = plist;
 #endif
 }

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-privacy/packages/irssi-plugin-otr.git



More information about the Pkg-privacy-commits mailing list