[Pkg-privacy-commits] [irssi-plugin-otr] 20/267: changes to README and /otr contexts.

Ximin Luo infinity0 at moszumanska.debian.org
Sat Aug 22 12:41:23 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 1bc0d4edbcf5c41647268ee117adb83fb483f964
Author: Uli Meis <a.sporto+bee at gmail.com>
Date:   Tue Jun 17 18:11:46 2008 +0200

    changes to README and /otr contexts.
    
    Context list now also uses /formats. There shouldn't be any hardcoded strings
    left.
---
 Packaging-DEB.cmake |  2 +-
 README              | 23 +++++++++++-------
 formats.txt         | 15 +++++++++---
 makeformats.py      | 17 +++++++------
 otr.c               | 34 +++++++++++++++++++++++---
 otr.h               | 19 ++++++++++++++-
 otrutil.c           | 69 ++++++++++++++++++++++++++++++-----------------------
 7 files changed, 125 insertions(+), 54 deletions(-)

diff --git a/Packaging-DEB.cmake b/Packaging-DEB.cmake
index 1578ea6..abc265d 100644
--- a/Packaging-DEB.cmake
+++ b/Packaging-DEB.cmake
@@ -4,4 +4,4 @@ INSTALL(FILES README LICENSE DESTINATION share/doc/${CMAKE_PROJECT_NAME}-${IRSSI
 SET(CPACK_GENERATOR DEB)
 #SET(CPACK_DEBIAN_PACKAGE_ARCHITECTURE "amd64")
 SET(CPACK_DEBIAN_PACKAGE_SECTION "net")
-SET(CPACK_DEBIAN_PACKAGE_DEPENDS "irssi")
+SET(CPACK_DEBIAN_PACKAGE_DEPENDS "irssi, libotr (>= 3.1.0)")
diff --git a/README b/README
index 23c8803..f46d3d5 100644
--- a/README
+++ b/README
@@ -1,17 +1,18 @@
 Usually, you shouldn't have to do anything besides "/load otr" to have encrypted
-conversations.  However,  some IRC  servers  strip  off  the  tabs OTR  uses  as
-announcement, there you or your buddy will have to type "?OTR?" to get going.
+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  also have  to be  generated...that can  take two
-minutes or even  an hour. You can wait  for OTR to trigger key  generation or do
-"/otr genkey nick at irc.server.com" yourself.
+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.
 
 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. Well, unfortunately the
-world ain't perfect and  it seems libotr isn't either (goes for  me as well), so
-currently only the responder will be  able to authenticate this way. You'll have
-to switch roles and do this twice - sry.
+other one will be asked to do  the same and you're done.
 
 I also strongly  recommend to do "/statusbar window add  otr" so you're informed
 about  what's going  on.
@@ -28,6 +29,10 @@ 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/formats.txt b/formats.txt
index c026989..8b6af03 100644
--- a/formats.txt
+++ b/formats.txt
@@ -28,11 +28,11 @@ ops_notify_bug	BUG() in ops_notify
 ops_notify	title: %s prim: %s sec: %s
 ops_display_bug	BUG() in ops_display
 ops_display	msg: %s
-ops_sec	gone %9secure%9
+ops_sec	gone %%9secure%%9
 ops_fpcomp	Your peer is not authenticated. To make sure you're talking to the right guy you can either agree on a secret and use the authentication described in %9/otr auth%9, or use the traditional way and compare fingerprints over a secure line (e.g. telephone) and subsequently enter %9/otr trust%9.  Your fingerprint is: %s. %s's fingerprint: %s
 ops_insec	gone %9insecure%9
-ops_still_reply	still %9secure%9 (is reply)
-ops_still_no_reply	still %9secure%9 (is not reply)
+ops_still_reply	still %%9secure%9 (is reply)
+ops_still_no_reply	still %%9secure%9 (is not reply)
 ops_log	log msg: %s
 SendingReceiving
 send_failed	send failed: msg=%s
@@ -71,6 +71,15 @@ cmd_debug_off	Debug mode is off
 cmd_finish	Finished conversation with %s
 cmd_version	This is irssi-otr version %s
 peer_finished	%s has finished the OTR conversation. If you want to continue talking enter %9/otr finish%9 for plaintext or ?OTR? to restart OTR.
+Contexts
+ctx_ctx_unencrypted	%%9%20s%%9    %30s    plaintext
+ctx_ctx_encrypted	%%9%20s%%9    %30s    %gencrypted%n
+ctx_ctx_finished	%%9%20s%%9    %30s    finished
+ctx_ctx_unknown	%%9%20s%%9    %30s    unknown state(BUG?)
+ctx_fps_no	%s %rnot authenticated%n
+ctx_fps_smp	%s %gauthenticated%n via shared secret (SMP)
+ctx_fps_man	%s %gauthenticated%n manually
+ctx_noctxs	No active OTR contexts found
 Nickignore
 nickignore	xmlconsole[0-9]*
 Statusbar
diff --git a/makeformats.py b/makeformats.py
index ceda075..18256c3 100755
--- a/makeformats.py
+++ b/makeformats.py
@@ -15,13 +15,14 @@ src = open("otr-formats.c","w")
 src.write('#include "otr.h"\n');
 
 src.write("""char *otr_help = "%s";\n""" % "\\n".join(
-	["{hilight - OTR help -}"]+
+	["%9- OTR help -%9"]+
 	[re.sub('^(/otr.*)$','%_\\1%_',
 		re.sub('"(.*)"','\\"%_\\1%_\\"',
 			x.replace('\n','').replace("\t","        ") 
 			))
-		for x in open(sys.argv[2],"r").readlines()]+
-	["{hilight - End of OTR help -}"]))
+		for x in open(sys.argv[2],"r").readlines()]
+	+["%9hilight - End of OTR help -%9"]
+	))
 
 src.write('FORMAT_REC formats[] = {\n')
 
@@ -58,16 +59,18 @@ for line in lines:
 	new = ""
 	last=0
 	i=0
-	for m in re.finditer("(^|[^%])%[ds]",fo):
+	for m in re.finditer("(^|[^%])%([0-9]*)[ds]",fo):
 		if m.group()[-1]=='d':
 			params += ['1']
 		else:
 			params += ['0']
-		new += fo[last:m.start()+len(m.group(1))]+"$%d" % i
+		new += fo[last:m.start()+len(m.group(1))].replace('%%','%')+"$"
+		if m.group(2): new+= "[%s]" % m.group(2)
+		new += "%d" % i
 		last = m.end()
 		i += 1
 
-	new += fo[last:]
+	new += fo[last:].replace('%%','%')
 
 	e[1] = new
 	e += [len(params)] + params
@@ -75,7 +78,7 @@ for line in lines:
 	#print "Handling line %s with elen %d" % (line,len(e))
 
 	premsg = ""
-	if e[1][0] != "{" and section!="Nickignore":
+	if e[1][0] != "{" and section!="Nickignore" and section!="Contexts":
 		premsg = "%9OTR%9: "
 
 	src.write("""{ "%s", "%s%s", %s""" % (e[0],premsg,e[1],e[2]))
diff --git a/otr.c b/otr.c
index 00ece98..fce39fd 100644
--- a/otr.c
+++ b/otr.c
@@ -195,9 +195,37 @@ static void cmd_version(const char *data, void *server, WI_ITEM_REC *item)
  */
 static void cmd_contexts(const char *data, void *server, WI_ITEM_REC *item)
 {
-	char *s = otr_contexts();
-	printtext(NULL,NULL,MSGLEVEL_CRAP,s);
-	free(s);
+	struct ctxlist_ *ctxlist = otr_contexts(),*ctxnext = ctxlist;
+	struct fplist_ *fplist,*fpnext;
+
+	if (!ctxlist)
+		printformat(NULL,NULL,MSGLEVEL_CRAP,TXT_CTX_NOCTXS);
+
+	while (ctxlist) {
+		printformat(NULL,NULL,MSGLEVEL_CRAP,
+			    TXT_CTX_CTX_UNENCRYPTED+ctxlist->state,
+			    ctxlist->username,
+			    ctxlist->accountname);
+
+		fplist = ctxlist->fplist;
+		while (fplist) {
+			printformat(NULL,NULL,MSGLEVEL_CRAP,
+				    TXT_CTX_FPS_NO+fplist->authby,
+				    fplist->fp);
+			fplist = fplist->next;
+		}
+		ctxlist = ctxlist->next;
+	}
+	while ((ctxlist = ctxnext)) {
+		ctxnext = ctxlist->next;
+		fpnext = ctxlist->fplist;
+		while ((fplist = fpnext)) {
+			fpnext = fplist->next;
+			g_free(fplist->fp);
+			g_free(fplist);
+		}
+		g_free(ctxlist);
+	}
 }
 
 /*
diff --git a/otr.h b/otr.h
index 951f1d8..cb4e2a4 100644
--- a/otr.h
+++ b/otr.h
@@ -82,6 +82,23 @@ struct co_info {
 	int finished;			/* true after you've /otr finished */
 };
 
+/* these are returned by /otr contexts */
+
+struct fplist_ {
+	char *fp;
+	enum { NOAUTH,AUTHSMP,AUTHMAN } authby;
+	struct fplist_ *next;
+};
+
+struct ctxlist_ {
+	char *username;
+	char *accountname;
+	enum { STUNENCRYPTED,STENCRYPTED,STFINISHED,STUNKNOWN } state;
+	struct fplist_ *fplist;
+	struct ctxlist_ *next;
+};
+
+/* used by the logging functions below */
 extern int debug;
 
 /* init stuff */
@@ -103,7 +120,7 @@ void otr_trust(SERVER_REC *server, char *nick);
 void otr_finish(SERVER_REC *server, char *nick,int inquery);
 void otr_auth(SERVER_REC *server, char *nick, const char *secret);
 void otr_authabort(SERVER_REC *server, char *nick);
-char *otr_contexts();
+struct ctxlist_ *otr_contexts();
 
 
 /* key/fingerprint stuff */
diff --git a/otrutil.c b/otrutil.c
index 747f23c..df8403b 100644
--- a/otrutil.c
+++ b/otrutil.c
@@ -174,52 +174,56 @@ char *otr_send(SERVER_REC *server, const char *msg,const char *to)
 	return NULL;
 }
 
-char *otr_contexts() {
+struct ctxlist_ *otr_contexts() {
 	ConnContext *context;
 	Fingerprint *fprint;
-	int strs = 1024,i;
-	char *str = malloc(sizeof(char)*strs), *s = str, *trust;
-	char *state;
+	struct ctxlist_ *ctxlist = NULL, *ctxhead = NULL;
+	struct fplist_ *fplist,*fphead;
+	char fp[41];
+	char *trust;
+	int i;
 
 	for(context = otr_state->context_root; context; 
 	    context = context->next) {
+		if (!ctxlist)
+			ctxhead = ctxlist = g_malloc0(sizeof(struct ctxlist_));
+		else
+			ctxlist = ctxlist->next = g_malloc0(sizeof(struct
+								  ctxlist_));
 		switch (context->msgstate) {
-		case OTRL_MSGSTATE_PLAINTEXT: state =   "plaintext";break;
-		case OTRL_MSGSTATE_ENCRYPTED: state = "%gencrypted%n";break;
-		case OTRL_MSGSTATE_FINISHED: state =    "finished ";break;
-		default: state = "unknown state(BUG)";break;
+		case OTRL_MSGSTATE_PLAINTEXT: ctxlist->state = STUNENCRYPTED;break;
+		case OTRL_MSGSTATE_ENCRYPTED: ctxlist->state = STENCRYPTED;break;
+		case OTRL_MSGSTATE_FINISHED: ctxlist->state = STFINISHED;break;
+		default: ctxlist->state = STUNKNOWN;break;
 		}
-		s += sprintf(s,"%%9%20s%%9    %30s    %s\n",context->username,
-			     context->accountname,state);
+		ctxlist->username = context->username;
+		ctxlist->accountname = context->accountname;
 
+		fplist = fphead = NULL;
 		for (fprint = context->fingerprint_root.next; fprint;
 		     fprint = fprint->next) {
+			if (!fplist)
+				fphead = fplist = g_malloc0(sizeof(struct
+								   fplist_));
+			else
+				fplist = fplist->next = g_malloc0(sizeof(struct
+									 fplist_));
 			trust = fprint->trust ? : "";
-			s += sprintf(s, "    ");
 			for(i=0;i<20;++i)
-				s += sprintf(s, "%02x",
+				sprintf(fp+i*2, "%02x",
 					     fprint->fingerprint[i]);
+			fplist->fp = g_strdup(fp);
 			if (*trust=='\0')
-				s += sprintf(s, "    %%rnot "
-					     "authenticated%%n\n");
+				fplist->authby = NOAUTH;
 			else if (strcmp(trust,"smp")==0)
-				s += sprintf(s, 
-					     "    %%gauthenticated%%n via "
-					     "shared secret (SMP)\n");
+				fplist->authby = AUTHSMP;
 			else 
-				s += sprintf(s,
-					     "    %%gauthenticated%%n"
-					     "manually\n");
-
-			if ((i=s-str)>strs/2) {
-				strs *= 2;
-				str = realloc(str,strs);
-				s = str+i;
-			}
+				fplist->authby = AUTHMAN;
 		}
-	}
 
-	return str;
+		ctxlist->fplist = fphead;
+	}
+	return ctxhead;
 }
 
 /*
@@ -389,8 +393,13 @@ void otr_auth(SERVER_REC *server, char *nick, const char *secret)
 	coi->smp_failed = FALSE;
 
 	/* reset trust level */
-	otrl_context_set_trust(co->active_fingerprint, "");
-	otr_writefps();
+	if (co->active_fingerprint) {
+		char *trust = co->active_fingerprint->trust;
+		if (trust&&(*trust!='\0')) {
+			otrl_context_set_trust(co->active_fingerprint, "");
+			otr_writefps();
+		}
+	}
 
 	if (!coi->received_smp_init)
 		otrl_message_initiate_smp(

-- 
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