Changeset 5f4eede
- Timestamp:
- 2008-02-11T23:16:23Z (17 years ago)
- Branches:
- master
- Children:
- e2b15bb
- Parents:
- 8bd697c
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
irc.c
r8bd697c r5f4eede 109 109 set_add( &irc->set, "buddy_sendbuffer_delay", "200", set_eval_int, irc ); 110 110 set_add( &irc->set, "charset", "utf-8", set_eval_charset, irc ); 111 set_add( &irc->set, "color_encrypted", "true", set_eval_bool, irc ); 111 112 set_add( &irc->set, "debug", "false", set_eval_bool, irc ); 112 113 set_add( &irc->set, "default_target", "root", NULL, irc ); 113 114 set_add( &irc->set, "display_namechanges", "false", set_eval_bool, irc ); 114 115 set_add( &irc->set, "handle_unknown", "root", NULL, irc ); 115 set_add( &irc->set, "halfop_buddies", " false", set_eval_halfop_buddies, irc );116 set_add( &irc->set, "halfop_buddies", "encrypted", set_eval_halfop_buddies, irc ); 116 117 set_add( &irc->set, "lcnicks", "true", set_eval_bool, irc ); 117 set_add( &irc->set, "op_buddies", " false", set_eval_op_buddies, irc );118 set_add( &irc->set, "op_buddies", "trusted", set_eval_op_buddies, irc ); 118 119 set_add( &irc->set, "op_root", "true", set_eval_op_root, irc ); 119 120 set_add( &irc->set, "op_user", "true", set_eval_op_user, irc ); -
otr.c
r8bd697c r5f4eede 94 94 void yes_forget_fingerprint(gpointer w, void *data); 95 95 void yes_forget_context(gpointer w, void *data); 96 void yes_forget_key(gpointer w, void *data); 96 97 97 98 /* helper to make sure accountname and protocol match the incoming "opdata" */ … … 129 130 /* find a fingerprint by prefix (given as any number of hex strings) */ 130 131 Fingerprint *match_fingerprint(irc_t *irc, ConnContext *ctx, const char **args); 132 133 /* find a private key by fingerprint prefix (given as any number of hex strings) */ 134 OtrlPrivKey *match_privkey(irc_t *irc, const char **args); 131 135 132 136 /* to log out accounts during keygen */ … … 288 292 ConnContext *context = otrl_context_find(ic->irc->otr_us, handle, 289 293 ic->acc->user, ic->acc->prpl->name, 0, NULL, NULL, NULL); 290 if(context && context->msgstate == OTRL_MSGSTATE_ENCRYPTED) { 294 if(context && context->msgstate == OTRL_MSGSTATE_ENCRYPTED && 295 set_getbool(&ic->irc->set, "color_encrypted")) { 291 296 /* color according to f'print trust */ 292 297 char color; … … 395 400 log_message(LOGLVL_DEBUG, "op_create_privkey '%s' '%s'", accountname, protocol); 396 401 397 s = g_strdup_printf("oops, no otr privkey for %s /%s- generate one now?",398 accountname , protocol);402 s = g_strdup_printf("oops, no otr privkey for %s - generate one now?", 403 accountname); 399 404 query_add(ic->irc, ic, s, yes_keygen, NULL, ic->acc); 400 405 } … … 794 799 if(otrl_privkey_find(irc->otr_us, a->user, a->prpl->name)) { 795 800 char *s = g_strdup_printf("account %d already has a key, replace it?", n); 796 query_add(irc, a->ic, s, yes_keygen, NULL, a);801 query_add(irc, NULL, s, yes_keygen, NULL, a); 797 802 } else { 798 803 otr_keygen(irc, a->user, a->prpl->name); … … 802 807 void yes_forget_fingerprint(gpointer w, void *data) 803 808 { 804 struct im_connection *ic = (struct im_connection*)w;809 irc_t *irc = (irc_t *)w; 805 810 Fingerprint *fp = (Fingerprint *)data; 806 811 807 812 if(fp == fp->context->active_fingerprint) { 808 irc_usermsg(i c->irc, "that fingerprint is active, terminate otr connection first");813 irc_usermsg(irc, "that fingerprint is active, terminate otr connection first"); 809 814 return; 810 815 } … … 815 820 void yes_forget_context(gpointer w, void *data) 816 821 { 817 struct im_connection *ic = (struct im_connection*)w;822 irc_t *irc = (irc_t *)w; 818 823 ConnContext *ctx = (ConnContext *)data; 819 824 820 825 if(ctx->msgstate == OTRL_MSGSTATE_ENCRYPTED) { 821 irc_usermsg(i c->irc, "active otr connection with %s, terminate it first",822 peernick(i c->irc, ctx->username, ctx->protocol));826 irc_usermsg(irc, "active otr connection with %s, terminate it first", 827 peernick(irc, ctx->username, ctx->protocol)); 823 828 return; 824 829 } … … 827 832 otrl_context_force_plaintext(ctx); 828 833 otrl_context_forget(ctx); 834 } 835 836 void yes_forget_key(gpointer w, void *data) 837 { 838 OtrlPrivKey *key = (OtrlPrivKey *)data; 839 840 /* FIXME: For some reason which /completely eludes me/, this call keeps 841 barfing on the gcry_sexp_release inside (invalid pointer free). */ 842 otrl_privkey_forget(key); 829 843 } 830 844 … … 870 884 otrl_privkey_hash_to_human(human, fp->fingerprint); 871 885 s = g_strdup_printf("about to forget fingerprint %s, are you sure?", human); 872 query_add(irc, u->ic, s, yes_forget_fingerprint, NULL, fp);886 query_add(irc, NULL, s, yes_forget_fingerprint, NULL, fp); 873 887 } 874 888 … … 898 912 899 913 s = g_strdup_printf("about to forget otr data about %s, are you sure?", args[2]); 900 query_add(irc, u->ic, s, yes_forget_context, NULL, ctx);914 query_add(irc, NULL, s, yes_forget_context, NULL, ctx); 901 915 } 902 916 903 917 else if(!strcmp(args[1], "key")) 904 918 { 905 irc_usermsg(irc, "n/a: TODO"); 919 OtrlPrivKey *key; 920 char *s; 921 922 key = match_privkey(irc, ((const char **)args)+2); 923 if(!key) { 924 /* match_privkey does error messages */ 925 return; 926 } 927 928 /* TODO: Find out why 'otr forget key' barfs (cf. yes_forget_key) */ 929 irc_usermsg(irc, "otr %s %s: not implemented, please edit \x02%s%s.otr_keys\x02 manually :-/", 930 args[0], args[1], global.conf->configdir, irc->nick); 931 return; 932 933 s = g_strdup_printf("about to forget the private key for %s/%s, are you sure?", 934 key->accountname, key->protocol); 935 query_add(irc, NULL, s, yes_forget_key, NULL, key); 906 936 } 907 937 … … 1231 1261 } 1232 1262 1263 OtrlPrivKey *match_privkey(irc_t *irc, const char **args) 1264 { 1265 OtrlPrivKey *k, *k2; 1266 char human[45]; 1267 char prefix[45], *p; 1268 int n; 1269 int i,j; 1270 1271 /* assemble the args into a prefix in standard "human" form */ 1272 n=0; 1273 p=prefix; 1274 for(i=0; args[i]; i++) { 1275 for(j=0; args[i][j]; j++) { 1276 char c = toupper(args[i][j]); 1277 1278 if(n>=40) { 1279 irc_usermsg(irc, "too many fingerprint digits given, expected at most 40"); 1280 return NULL; 1281 } 1282 1283 if( (c>='A' && c<='F') || (c>='0' && c<='9') ) { 1284 *(p++) = c; 1285 } else { 1286 irc_usermsg(irc, "invalid hex digit '%c' in block %d", args[i][j], i+1); 1287 return NULL; 1288 } 1289 1290 n++; 1291 if(n%8 == 0) 1292 *(p++) = ' '; 1293 } 1294 } 1295 *p = '\0'; 1296 log_message(LOGLVL_DEBUG, "match_privkey '%s'", prefix); 1297 log_message(LOGLVL_DEBUG, "n=%d strlen(prefix)=%d", n, strlen(prefix)); 1298 1299 /* find first key which matches the given prefix */ 1300 n = strlen(prefix); 1301 for(k=irc->otr_us->privkey_root; k; k=k->next) { 1302 p = otrl_privkey_fingerprint(irc->otr_us, human, k->accountname, k->protocol); 1303 if(!p) /* gah! :-P */ 1304 continue; 1305 if(!strncmp(prefix, human, n)) 1306 break; 1307 } 1308 if(!k) { 1309 irc_usermsg(irc, "%s: no match", prefix); 1310 return NULL; 1311 } 1312 1313 /* make sure the match, if any, is unique */ 1314 for(k2=k->next; k2; k2=k2->next) { 1315 p = otrl_privkey_fingerprint(irc->otr_us, human, k2->accountname, k2->protocol); 1316 if(!p) /* gah! :-P */ 1317 continue; 1318 if(!strncmp(prefix, human, n)) 1319 break; 1320 } 1321 if(k2) { 1322 irc_usermsg(irc, "%s: multiple matches", prefix); 1323 return NULL; 1324 } 1325 1326 return k; 1327 } 1328 1233 1329 void show_general_otr_info(irc_t *irc) 1234 1330 { -
query.c
r8bd697c r5f4eede 148 148 irc_usermsg( irc, "Accepted: %s", q->question ); 149 149 if(q->yes) 150 q->yes( q->ic ? q->ic :irc, q->data );150 q->yes( q->ic ? (gpointer)q->ic : (gpointer)irc, q->data ); 151 151 } 152 152 else … … 157 157 irc_usermsg( irc, "Rejected: %s", q->question ); 158 158 if(q->no) 159 q->no( q->ic ? q->ic :irc, q->data );159 q->no( q->ic ? (gpointer)q->ic : (gpointer)irc, q->data ); 160 160 } 161 161 q->data = NULL;
Note: See TracChangeset
for help on using the changeset viewer.