Changeset 5a95b69
- Timestamp:
- Dec 20, 2003, 1:35:36 PM (21 years ago)
- Branches:
- master, barnowl_perlaim, debian, owl, release-1.10, release-1.4, release-1.5, release-1.6, release-1.7, release-1.8, release-1.9
- Children:
- 72836b5
- Parents:
- c8735aa
- Files:
-
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
ChangeLog
rc8735aa r5a95b69 5 5 Don't bind F1 to help in edit context 6 6 Fix bug in 'getsubs' with no tickets 7 7 New code for getting users from .anyfile 8 Added the 'pseudologins' variable, and code to do it 9 new attributes 'pseudo' 'logintty' and 'loginhost' 8 10 2.0.14 9 11 Fixed missing word in startup message -
Makefile.in
r8c92848 r5a95b69 23 23 regex.c history.c view.c dict.c variable.c filterelement.c pair.c \ 24 24 keypress.c keymap.c keybinding.c cmd.c context.c zcrypt.c \ 25 aim.c buddy.c buddylist.c timer.c style.c stylefunc.c errqueue.c 25 aim.c buddy.c buddylist.c timer.c style.c stylefunc.c errqueue.c \ 26 zbuddylist.c 26 27 OWL_SRC = owl.c 27 28 TESTER_SRC = tester.c -
functions.c
r8c46404 r5a95b69 1429 1429 n=owl_message_get_notice(m); 1430 1430 1431 owl_fmtext_append_normal(&fm, " Kind : "); 1432 if (n->z_kind==UNSAFE) { 1433 owl_fmtext_append_normal(&fm, "UNSAFE\n"); 1434 } else if (n->z_kind==UNACKED) { 1435 owl_fmtext_append_normal(&fm, "UNACKED\n"); 1436 } else if (n->z_kind==ACKED) { 1437 owl_fmtext_append_normal(&fm, "ACKED\n"); 1438 } else if (n->z_kind==HMACK) { 1439 owl_fmtext_append_normal(&fm, "HMACK\n"); 1440 } else if (n->z_kind==HMCTL) { 1441 owl_fmtext_append_normal(&fm, "HMCTL\n"); 1442 } else if (n->z_kind==SERVACK) { 1443 owl_fmtext_append_normal(&fm, "SERVACK\n"); 1444 } else if (n->z_kind==SERVNAK) { 1445 owl_fmtext_append_normal(&fm, "SERVNACK\n"); 1446 } else if (n->z_kind==CLIENTACK) { 1447 owl_fmtext_append_normal(&fm, "CLIENTACK\n"); 1448 } else if (n->z_kind==STAT) { 1449 owl_fmtext_append_normal(&fm, "STAT\n"); 1450 } else { 1451 owl_fmtext_append_normal(&fm, "ILLEGAL VALUE\n"); 1431 if (!owl_message_is_pseudo(m)) { 1432 owl_fmtext_append_normal(&fm, " Kind : "); 1433 if (n->z_kind==UNSAFE) { 1434 owl_fmtext_append_normal(&fm, "UNSAFE\n"); 1435 } else if (n->z_kind==UNACKED) { 1436 owl_fmtext_append_normal(&fm, "UNACKED\n"); 1437 } else if (n->z_kind==ACKED) { 1438 owl_fmtext_append_normal(&fm, "ACKED\n"); 1439 } else if (n->z_kind==HMACK) { 1440 owl_fmtext_append_normal(&fm, "HMACK\n"); 1441 } else if (n->z_kind==HMCTL) { 1442 owl_fmtext_append_normal(&fm, "HMCTL\n"); 1443 } else if (n->z_kind==SERVACK) { 1444 owl_fmtext_append_normal(&fm, "SERVACK\n"); 1445 } else if (n->z_kind==SERVNAK) { 1446 owl_fmtext_append_normal(&fm, "SERVNACK\n"); 1447 } else if (n->z_kind==CLIENTACK) { 1448 owl_fmtext_append_normal(&fm, "CLIENTACK\n"); 1449 } else if (n->z_kind==STAT) { 1450 owl_fmtext_append_normal(&fm, "STAT\n"); 1451 } else { 1452 owl_fmtext_append_normal(&fm, "ILLEGAL VALUE\n"); 1453 } 1452 1454 } 1453 1455 owl_fmtext_append_normal(&fm, " Host : "); 1454 1456 owl_fmtext_append_normal(&fm, owl_message_get_hostname(m)); 1455 owl_fmtext_append_normal(&fm, "\n"); 1456 sprintf(buff, " Port : %i\n", n->z_port); 1457 owl_fmtext_append_normal(&fm, buff); 1458 1459 owl_fmtext_append_normal(&fm, " Auth : "); 1460 owl_fmtext_append_normal(&fm, owl_zephyr_get_authstr(n)); 1461 owl_fmtext_append_normal(&fm, "\n"); 1462 1463 /* fix this */ 1464 sprintf(buff, " Checkd Ath: %i\n", n->z_checked_auth); 1465 sprintf(buff, "%s Multi notc: %s\n", buff, n->z_multinotice); 1466 sprintf(buff, "%s Num other : %i\n", buff, n->z_num_other_fields); 1467 sprintf(buff, "%s Msg Len : %i\n", buff, n->z_message_len); 1468 owl_fmtext_append_normal(&fm, buff); 1457 1458 if (!owl_message_is_pseudo(m)) { 1459 owl_fmtext_append_normal(&fm, "\n"); 1460 sprintf(buff, " Port : %i\n", n->z_port); 1461 owl_fmtext_append_normal(&fm, buff); 1462 1463 owl_fmtext_append_normal(&fm, " Auth : "); 1464 owl_fmtext_append_normal(&fm, owl_zephyr_get_authstr(n)); 1465 owl_fmtext_append_normal(&fm, "\n"); 1466 1467 /* fix this */ 1468 sprintf(buff, " Checkd Ath: %i\n", n->z_checked_auth); 1469 sprintf(buff, "%s Multi notc: %s\n", buff, n->z_multinotice); 1470 sprintf(buff, "%s Num other : %i\n", buff, n->z_num_other_fields); 1471 sprintf(buff, "%s Msg Len : %i\n", buff, n->z_message_len); 1472 owl_fmtext_append_normal(&fm, buff); 1473 1474 sprintf(buff, " Fields : %i\n", owl_zephyr_get_num_fields(n)); 1475 owl_fmtext_append_normal(&fm, buff); 1476 1477 fields=owl_zephyr_get_num_fields(n); 1478 for (i=0; i<fields; i++) { 1479 sprintf(buff, " Field %i : ", i+1); 1480 1481 ptr=owl_zephyr_get_field(n, i+1, &len); 1482 if (!ptr) break; 1483 if (len<30) { 1484 strncpy(tmpbuff, ptr, len); 1485 tmpbuff[len]='\0'; 1486 } else { 1487 strncpy(tmpbuff, ptr, 30); 1488 tmpbuff[30]='\0'; 1489 strcat(tmpbuff, "..."); 1490 } 1491 1492 for (j=0; j<strlen(tmpbuff); j++) { 1493 if (tmpbuff[j]=='\n') tmpbuff[j]='~'; 1494 if (tmpbuff[j]=='\r') tmpbuff[j]='!'; 1495 } 1496 1497 strcat(buff, tmpbuff); 1498 strcat(buff, "\n"); 1499 owl_fmtext_append_normal(&fm, buff); 1500 } 1501 owl_fmtext_append_normal(&fm, " Default Fm:"); 1502 owl_fmtext_append_normal(&fm, n->z_default_format); 1503 } 1469 1504 1470 sprintf(buff, " Fields : %i\n", owl_zephyr_get_num_fields(n));1471 owl_fmtext_append_normal(&fm, buff);1472 1473 fields=owl_zephyr_get_num_fields(n);1474 for (i=0; i<fields; i++) {1475 sprintf(buff, " Field %i : ", i+1);1476 1477 ptr=owl_zephyr_get_field(n, i+1, &len);1478 if (!ptr) break;1479 if (len<30) {1480 strncpy(tmpbuff, ptr, len);1481 tmpbuff[len]='\0';1482 } else {1483 strncpy(tmpbuff, ptr, 30);1484 tmpbuff[30]='\0';1485 strcat(tmpbuff, "...");1486 }1487 1488 for (j=0; j<strlen(tmpbuff); j++) {1489 if (tmpbuff[j]=='\n') tmpbuff[j]='~';1490 if (tmpbuff[j]=='\r') tmpbuff[j]='!';1491 }1492 1493 strcat(buff, tmpbuff);1494 strcat(buff, "\n");1495 owl_fmtext_append_normal(&fm, buff);1496 }1497 owl_fmtext_append_normal(&fm, " Default Fm:");1498 owl_fmtext_append_normal(&fm, n->z_default_format);1499 1505 } 1500 1506 #endif … … 3020 3026 } 3021 3027 3022 /* Popup a buddylisting. If file is NULL use the default .anyone */3023 void owl_function_buddylist(int aim, int zephyr, char *file )3024 { 3025 int i, j, idle;3028 /* Popup a buddylisting. If filename is NULL use the default .anyone */ 3029 void owl_function_buddylist(int aim, int zephyr, char *filename) 3030 { 3031 int i, j, x, idle; 3026 3032 owl_fmtext fm; 3027 3033 owl_buddylist *bl; 3028 3034 owl_buddy *b; 3035 owl_list anyone; 3029 3036 char *foo, *timestr; 3030 3037 #ifdef HAVE_LIBZEPHYR 3031 char * ourfile, *tmp, buff[LINE], *line;3038 char *tmp, *user, *line; 3032 3039 ZLocations_t location[200]; 3033 FILE *f;3034 3040 int numlocs, ret; 3035 3041 #endif … … 3061 3067 #ifdef HAVE_LIBZEPHYR 3062 3068 if (zephyr) { 3063 if (file==NULL) { 3064 tmp=owl_global_get_homedir(&g); 3065 ourfile=owl_sprintf("%s/.anyone", owl_global_get_homedir(&g)); 3069 owl_fmtext_append_bold(&fm, "Zephyr users logged in:\n"); 3070 owl_list_create(&anyone); 3071 ret=owl_zephyr_get_anyone_list(&anyone, filename); 3072 if (ret) { 3073 owl_fmtext_append_normal(&fm, " Error opening file for zephyr buddies.\n"); 3066 3074 } else { 3067 ourfile=owl_strdup(file); 3068 } 3069 3070 owl_fmtext_append_bold(&fm, "Zephyr users logged in:\n"); 3071 f=fopen(ourfile, "r"); 3072 if (!f) { 3073 owl_fmtext_append_normal(&fm, " Error opening file "); 3074 owl_fmtext_append_normal(&fm, ourfile); 3075 owl_fmtext_append_normal(&fm, "\n"); 3076 owl_function_error("Error opening file %s: %s", ourfile, strerror(errno) ? strerror(errno) : ""); 3077 } else { 3078 while (fgets(buff, LINE, f)!=NULL) { 3079 /* ignore comments, blank lines etc. */ 3080 if (buff[0]=='#') continue; 3081 if (buff[0]=='\n') continue; 3082 if (buff[0]=='\0') continue; 3083 3084 /* strip the \n */ 3085 buff[strlen(buff)-1]='\0'; 3086 3087 /* ingore from # on */ 3088 tmp=strchr(buff, '#'); 3089 if (tmp) tmp[0]='\0'; 3090 3091 /* ingore from SPC */ 3092 tmp=strchr(buff, ' '); 3093 if (tmp) tmp[0]='\0'; 3094 3095 /* stick on the local realm. */ 3096 if (!strchr(buff, '@')) { 3097 strcat(buff, "@"); 3098 strcat(buff, ZGetRealm()); 3099 } 3100 3101 ret=ZLocateUser(buff, &numlocs, ZAUTH); 3075 j=owl_list_get_size(&anyone); 3076 for (i=0; i<j; i++) { 3077 user=owl_list_get_element(&anyone, i); 3078 ret=ZLocateUser(user, &numlocs, ZAUTH); 3102 3079 if (ret!=ZERR_NONE) { 3103 owl_function_error("Error getting location for %s", buff);3080 owl_function_error("Error getting location for %s", user); 3104 3081 continue; 3105 3082 } … … 3108 3085 ret=ZGetLocations(location, &numlocs); 3109 3086 if (ret==0) { 3110 for ( i=0; i<numlocs; i++) {3111 line=malloc(strlen(location[ i].host)+strlen(location[i].time)+strlen(location[i].tty)+100);3112 tmp=short_zuser( buff);3087 for (x=0; x<numlocs; x++) { 3088 line=malloc(strlen(location[x].host)+strlen(location[x].time)+strlen(location[x].tty)+100); 3089 tmp=short_zuser(user); 3113 3090 sprintf(line, " %-10.10s %-24.24s %-12.12s %20.20s\n", 3114 3091 tmp, 3115 location[ i].host,3116 location[ i].tty,3117 location[ i].time);3092 location[x].host, 3093 location[x].tty, 3094 location[x].time); 3118 3095 owl_fmtext_append_normal(&fm, line); 3119 3096 owl_free(tmp); … … 3124 3101 } 3125 3102 } 3126 fclose(f); 3127 } 3128 owl_free(ourfile); 3103 } 3129 3104 } 3130 3105 #endif … … 3132 3107 owl_function_popless_fmtext(&fm); 3133 3108 owl_fmtext_free(&fm); 3109 owl_list_free_all(&anyone, owl_free); 3134 3110 } 3135 3111 … … 3141 3117 owl_view *v; 3142 3118 FILE *file; 3143 3144 /* struct stat sbuf; */3145 3119 3146 3120 v=owl_global_get_current_view(&g); … … 3388 3362 va_end(ap); 3389 3363 } 3364 3365 /* get locations for everyone in .anyone. If 'notify' is '1' then 3366 * send a pseudo login or logout message for everyone not in sync with 3367 * the global zephyr buddy list. The list is updated regardless of 3368 * the status of 'notify'. 3369 */ 3370 void owl_function_zephyr_buddy_check(int notify) 3371 { 3372 #ifdef HAVE_LIBZEPHYR 3373 int i, j; 3374 owl_list anyone; 3375 owl_message *m; 3376 owl_zbuddylist *zbl; 3377 char *user; 3378 ZLocations_t location[200]; 3379 int numlocs, ret; 3380 3381 zbl=owl_global_get_zephyr_buddylist(&g); 3382 3383 owl_list_create(&anyone); 3384 ret=owl_zephyr_get_anyone_list(&anyone, NULL); 3385 3386 j=owl_list_get_size(&anyone); 3387 for (i=0; i<j; i++) { 3388 user=owl_list_get_element(&anyone, i); 3389 ret=ZLocateUser(user, &numlocs, ZAUTH); 3390 if (ret!=ZERR_NONE) { 3391 owl_function_error("Error getting location for %s", user); 3392 continue; 3393 } 3394 numlocs=200; 3395 ret=ZGetLocations(location, &numlocs); 3396 if (ret==0) { 3397 if ((numlocs>0) && !owl_zbuddylist_contains_user(zbl, user)) { 3398 /* Send a PSEUDO LOGIN! */ 3399 if (notify) { 3400 m=owl_malloc(sizeof(owl_message)); 3401 owl_message_create_pseudo_zlogin(m, 0, user, location[0].host, location[0].time, location[0].tty); 3402 owl_global_messagequeue_addmsg(&g, m); 3403 } 3404 owl_zbuddylist_adduser(zbl, user); 3405 owl_function_debugmsg("owl_function_zephyr_buddy_check: login for %s ", user); 3406 } else if ((numlocs==0) && owl_zbuddylist_contains_user(zbl, user)) { 3407 /* I don't think this ever happens (if there are 0 locations we should get an error from 3408 * ZGetLocations) 3409 */ 3410 owl_function_error("owl_function_zephyr_buddy_check: exceptional case logout for %s ",user); 3411 } 3412 } else if ((ret==ZERR_NOLOCATIONS) && owl_zbuddylist_contains_user(zbl, user)) { 3413 /* Send a PSEUDO LOGOUT! */ 3414 if (notify) { 3415 m=owl_malloc(sizeof(owl_message)); 3416 owl_message_create_pseudo_zlogin(m, 1, user, location[0].host, location[0].time, location[0].tty); 3417 owl_global_messagequeue_addmsg(&g, m); 3418 } 3419 owl_zbuddylist_deluser(zbl, user); 3420 owl_function_debugmsg("owl_function_zephyr_buddy_check: logout for %s ",user); 3421 } 3422 } 3423 3424 owl_list_free_all(&anyone, owl_free); 3425 #endif 3426 } -
global.c
rc9e72d1 r5a95b69 105 105 106 106 owl_errqueue_init(&(g->errqueue)); 107 108 107 g->got_err_signal=0; 108 109 owl_zbuddylist_create(&(g->zbuddies)); 110 owl_timer_create_countdown(&(g->zephyr_buddycheck_timer), 60*3); 109 111 } 110 112 … … 868 870 } 869 871 872 owl_timer *owl_global_get_zephyr_buddycheck_timer(owl_global *g) 873 { 874 return(&(g->zephyr_buddycheck_timer)); 875 } 876 877 owl_zbuddylist *owl_global_get_zephyr_buddylist(owl_global *g) 878 { 879 return(&(g->zbuddies)); 880 } -
message.c
r25dd31a r5a95b69 34 34 } 35 35 36 /* add the named attribute to the message. If an attribute with the 37 * name already exists, replace the old value with the new value 38 */ 36 39 void owl_message_set_attribute(owl_message *m, char *attrname, char *attrvalue) 37 40 { 38 /* add the named attribute to the message. If an attribute with the39 name already exists, replace the old value with the new value */40 41 41 int i, j; 42 42 owl_pair *p; … … 61 61 } 62 62 63 /* return the value associated with the named attribute, or NULL if 64 * the attribute does not exist 65 */ 63 66 char *owl_message_get_attribute_value(owl_message *m, char *attrname) 64 67 { 65 /* return the value associated with the named attribute, or NULL if66 the attribute does not exist */67 68 int i, j; 68 69 owl_pair *p; … … 362 363 { 363 364 if (m->type==OWL_MESSAGE_TYPE_AIM) return(1); 365 return(0); 366 } 367 368 int owl_message_is_pseudo(owl_message *m) 369 { 370 if (owl_message_get_attribute_value(m, "pseudo")) return(1); 364 371 return(0); 365 372 } … … 707 714 { 708 715 struct hostent *hent; 709 int k ;716 int k, len; 710 717 char *ptr, *tmp, *tmp2; 711 718 … … 721 728 owl_zephyr_hackaway_cr(&(m->notice)); 722 729 723 m->delete=0;724 725 730 /* save the time, we need to nuke the string saved by message_init */ 726 if (m->timestr) { 727 owl_free(m->timestr); 728 } 731 if (m->timestr) owl_free(m->timestr); 729 732 m->time=n->z_time.tv_sec; 730 733 m->timestr=owl_strdup(ctime(&(m->time))); … … 751 754 /* Set the "isloginout" attribute if it's a login message */ 752 755 if (!strcasecmp(n->z_class, "login") || !strcasecmp(n->z_class, OWL_WEBZEPHYR_CLASS)) { 756 if (!strcasecmp(n->z_opcode, "user_login") || !strcasecmp(n->z_opcode, "user_logout")) { 757 ptr=owl_zephyr_get_field(n, 1, &len); 758 tmp=owl_malloc(len+10); 759 strncpy(tmp, ptr, len); 760 tmp[len]='\0'; 761 owl_message_set_attribute(m, "loginhost", tmp); 762 owl_free(tmp); 763 764 ptr=owl_zephyr_get_field(n, 3, &len); 765 tmp=owl_malloc(len+10); 766 strncpy(tmp, ptr, len); 767 tmp[len]='\0'; 768 owl_message_set_attribute(m, "logintty", tmp); 769 owl_free(tmp); 770 } 771 753 772 if (!strcasecmp(n->z_opcode, "user_login")) { 754 773 owl_message_set_islogin(m); … … 758 777 } 759 778 779 760 780 /* is the "isprivate" attribute if it's a private zephyr */ 761 781 if (!strcasecmp(n->z_recipient, owl_zephyr_get_sender())) { … … 810 830 #endif 811 831 832 /* If 'direction' is '0' it is a login message, '1' is a logout message. */ 833 void owl_message_create_pseudo_zlogin(owl_message *m, int direction, char *user, char *host, char *time, char *tty) 834 { 835 char *longuser, *ptr; 836 837 memset(&(m->notice), 0, sizeof(ZNotice_t)); 838 839 longuser=long_zuser(user); 840 841 owl_message_init(m); 842 843 owl_message_set_type_zephyr(m); 844 owl_message_set_direction_in(m); 845 846 owl_message_set_attribute(m, "pseudo", ""); 847 owl_message_set_attribute(m, "loginhost", host ? host : ""); 848 owl_message_set_attribute(m, "logintty", tty ? tty : ""); 849 850 owl_message_set_sender(m, longuser); 851 owl_message_set_class(m, "LOGIN"); 852 owl_message_set_instance(m, longuser); 853 owl_message_set_recipient(m, ""); 854 if (direction==0) { 855 owl_message_set_opcode(m, "USER_LOGIN"); 856 owl_message_set_islogin(m); 857 } else if (direction==1) { 858 owl_message_set_opcode(m, "USER_LOGOUT"); 859 owl_message_set_islogout(m); 860 } 861 862 if ((ptr=strchr(longuser, '@'))!=NULL) { 863 owl_message_set_realm(m, ptr+1); 864 } else { 865 owl_message_set_realm(m, owl_zephyr_get_realm()); 866 } 867 868 m->zwriteline=strdup(""); 869 870 owl_message_set_body(m, "<uninitialized>"); 871 872 /* save the hostname */ 873 owl_function_debugmsg("create_pseudo_login: host is %s", host); 874 strcpy(m->hostname, host ? host : ""); 875 owl_free(longuser); 876 } 877 812 878 void owl_message_create_from_zwriteline(owl_message *m, char *line, char *body, char *zsig) 813 879 { -
owl.c
ra68f05d r5a95b69 342 342 } 343 343 344 /* First buddy check to sync the list without notifications */ 345 owl_function_debugmsg("startup: doing initial zephyr buddy check"); 346 owl_function_zephyr_buddy_check(0); 347 344 348 /* set the startup and default style, based on userclue and presence of a 345 349 * formatting function */ … … 491 495 } 492 496 497 /* if it's a zephyr login or logout, update the zbuddylist */ 498 if (owl_message_is_type_zephyr(m) && owl_message_is_loginout(m)) { 499 if (owl_message_is_login(m)) { 500 owl_zbuddylist_adduser(owl_global_get_zephyr_buddylist(&g), owl_message_get_sender(m)); 501 } else if (owl_message_is_logout(m)) { 502 owl_zbuddylist_deluser(owl_global_get_zephyr_buddylist(&g), owl_message_get_sender(m)); 503 } else { 504 owl_function_error("Internal error: received login notice that is neither login nor logout"); 505 } 506 } 507 493 508 /* check for burning ears message */ 494 509 /* this is an unsupported feature */ … … 504 519 if (owl_global_is_logging(&g) || owl_global_is_classlogging(&g)) { 505 520 owl_log_incoming(m); 521 } 522 } 523 524 /* is it time to check zbuddies? */ 525 if (owl_global_is_pseudologins(&g)) { 526 if (owl_timer_is_expired(owl_global_get_zephyr_buddycheck_timer(&g))) { 527 owl_function_debugmsg("Doing zephyr buddy check"); 528 owl_function_zephyr_buddy_check(1); 529 owl_timer_reset(owl_global_get_zephyr_buddycheck_timer(&g)); 506 530 } 507 531 } -
owl.h
re7bcd1b r5a95b69 414 414 owl_list buddies; 415 415 } owl_buddylist; 416 417 typedef struct _owl_zbuddylist { 418 owl_list zusers; 419 } owl_zbuddylist; 416 420 417 421 typedef struct _owl_timer { … … 488 492 int haveaim; 489 493 int got_err_signal; /* 1 if we got an unexpected signal */ 490 siginfo_t err_signal_info; 494 siginfo_t err_signal_info; 495 owl_zbuddylist zbuddies; 496 owl_timer zephyr_buddycheck_timer; 491 497 } owl_global; 492 498 -
stylefunc.c
r97cd00be r5a95b69 47 47 owl_fmtext_append_normal(fm, "\n"); 48 48 } else if (owl_message_is_loginout(m)) { 49 char *ptr, *host, *tty; 50 int len; 51 52 ptr=owl_zephyr_get_field(n, 1, &len); 53 host=owl_malloc(len+10); 54 strncpy(host, ptr, len); 55 host[len]='\0'; 56 57 ptr=owl_zephyr_get_field(n, 3, &len); 58 tty=owl_malloc(len+10); 59 strncpy(tty, ptr, len); 60 tty[len]='\0'; 61 49 char *host, *tty; 50 51 host=owl_message_get_attribute_value(m, "loginhost"); 52 tty=owl_message_get_attribute_value(m, "logintty"); 53 62 54 if (owl_message_is_login(m)) { 63 55 owl_fmtext_append_bold(fm, "LOGIN"); 64 56 } else if (owl_message_is_logout(m)) { 65 57 owl_fmtext_append_bold(fm, "LOGOUT"); 58 } 59 if (owl_message_is_pseudo(m)) { 60 owl_fmtext_append_bold(fm, " (PSEUDO)"); 66 61 } 67 62 owl_fmtext_append_normal(fm, " for "); … … 70 65 owl_free(ptr); 71 66 owl_fmtext_append_normal(fm, " at "); 72 owl_fmtext_append_normal(fm, host );67 owl_fmtext_append_normal(fm, host ? host : ""); 73 68 owl_fmtext_append_normal(fm, " "); 74 owl_fmtext_append_normal(fm, tty); 75 owl_fmtext_append_normal(fm, "\n"); 76 77 owl_free(host); 78 owl_free(tty); 69 owl_fmtext_append_normal(fm, tty ? tty : ""); 70 owl_fmtext_append_normal(fm, "\n"); 79 71 } else { 80 72 owl_fmtext_append_normal(fm, "From: "); … … 266 258 owl_fmtext_append_normal(fm, "\n"); 267 259 } else if (owl_message_is_loginout(m)) { 268 char *ptr, *host, *tty; 269 int len; 270 271 ptr=owl_zephyr_get_field(n, 1, &len); 272 host=owl_malloc(len+10); 273 strncpy(host, ptr, len); 274 host[len]='\0'; 275 276 ptr=owl_zephyr_get_field(n, 3, &len); 277 tty=owl_malloc(len+10); 278 strncpy(tty, ptr, len); 279 tty[len]='\0'; 260 char *host, *tty; 261 262 host=owl_message_get_attribute_value(m, "loginhost"); 263 tty=owl_message_get_attribute_value(m, "logintty"); 280 264 281 265 if (owl_message_is_login(m)) { … … 284 268 owl_fmtext_append_bold(fm, "LOGOUT"); 285 269 } 270 271 if (owl_message_is_pseudo(m)) owl_fmtext_append_bold(fm, " (PSEUDO)"); 272 286 273 owl_fmtext_append_normal(fm, " for "); 287 274 ptr=short_zuser(owl_message_get_instance(m)); … … 289 276 owl_free(ptr); 290 277 owl_fmtext_append_normal(fm, " at "); 291 owl_fmtext_append_normal(fm, host );278 owl_fmtext_append_normal(fm, host ? host : ""); 292 279 owl_fmtext_append_normal(fm, " "); 293 owl_fmtext_append_normal(fm, tty );280 owl_fmtext_append_normal(fm, tty ? tty : ""); 294 281 owl_fmtext_append_normal(fm, " "); 295 282 owl_fmtext_append_normal(fm, shorttimestr); 296 283 owl_fmtext_append_normal(fm, "\n"); 297 298 owl_free(host);299 owl_free(tty);300 284 } else { 301 285 owl_fmtext_append_normal(fm, owl_message_get_class(m)); … … 482 466 483 467 if (owl_message_is_loginout(m)) { 484 char *ptr, *host, *tty; 485 int len; 486 487 ptr=owl_zephyr_get_field(n, 1, &len); 488 host=owl_malloc(len+10); 489 strncpy(host, ptr, len); 490 host[len]='\0'; 491 492 ptr=owl_zephyr_get_field(n, 3, &len); 493 tty=owl_malloc(len+10); 494 strncpy(tty, ptr, len); 495 tty[len]='\0'; 468 char *host, *tty; 469 470 host=owl_message_get_attribute_value(m, "loginhost"); 471 tty=owl_message_get_attribute_value(m, "logintty"); 496 472 497 473 if (owl_message_is_login(m)) { 498 tmp=owl_sprintf(baseformat, "<", "LOGIN", "", sender);474 tmp=owl_sprintf(baseformat, "<", owl_message_is_pseudo(m)?"LOGIN-P":"LOGIN", "", sender); 499 475 owl_fmtext_append_normal(fm, tmp); 500 476 owl_free(tmp); 501 477 } else if (owl_message_is_logout(m)) { 502 tmp=owl_sprintf(baseformat, "<", "LOGOUT", "", sender);478 tmp=owl_sprintf(baseformat, "<", owl_message_is_pseudo(m)?"LOGOUT-P":"LOGOUT", "", sender); 503 479 owl_fmtext_append_normal(fm, tmp); 504 480 owl_free(tmp); … … 506 482 507 483 owl_fmtext_append_normal(fm, "at "); 508 owl_fmtext_append_normal(fm, host );484 owl_fmtext_append_normal(fm, host ? host : ""); 509 485 owl_fmtext_append_normal(fm, " "); 510 owl_fmtext_append_normal(fm, tty); 511 owl_fmtext_append_normal(fm, "\n"); 512 513 owl_free(host); 514 owl_free(tty); 486 owl_fmtext_append_normal(fm, tty ? tty : ""); 487 owl_fmtext_append_normal(fm, "\n"); 515 488 516 489 } else if (owl_message_is_ping(m)) { … … 664 637 owl_fmtext_append_normal(fm, "\n"); 665 638 } else if (owl_message_is_loginout(m)) { 666 char *ptr, *host, *tty; 667 int len; 668 669 ptr=owl_zephyr_get_field(n, 1, &len); 670 host=owl_malloc(len+10); 671 strncpy(host, ptr, len); 672 host[len]='\0'; 673 674 ptr=owl_zephyr_get_field(n, 3, &len); 675 tty=owl_malloc(len+10); 676 strncpy(tty, ptr, len); 677 tty[len]='\0'; 639 char *host, *tty; 640 641 host=owl_message_get_attribute_value(m, "loginhost"); 642 tty=owl_message_get_attribute_value(m, "logintty"); 678 643 679 644 if (owl_message_is_login(m)) { … … 682 647 owl_fmtext_append_bold(fm, "LOGOUT"); 683 648 } 649 if (owl_message_is_pseudo(m)) owl_fmtext_append_bold(fm, " (PSEUDO)"); 650 684 651 owl_fmtext_append_normal(fm, " for "); 685 652 ptr=short_zuser(owl_message_get_instance(m)); … … 687 654 owl_free(ptr); 688 655 owl_fmtext_append_normal(fm, " at "); 689 owl_fmtext_append_normal(fm, host );656 owl_fmtext_append_normal(fm, host ? host : ""); 690 657 owl_fmtext_append_normal(fm, " "); 691 owl_fmtext_append_normal(fm, tty); 692 owl_fmtext_append_normal(fm, "\n"); 693 694 owl_free(host); 695 owl_free(tty); 658 owl_fmtext_append_normal(fm, tty ? tty : ""); 659 owl_fmtext_append_normal(fm, "\n"); 696 660 } else { 697 661 owl_fmtext_append_normal(fm, sender); -
variable.c
r1db061d r5a95b69 135 135 "Do automatic zcrypt processing", 136 136 "" ), 137 138 OWLVAR_BOOL( "pseudologins" /* %OwlVarStub */, 0, 139 "Enable zephyr pseudo logins", 140 "When this is enabled, Owl will periodically check the zephyr\n" 141 "location of users in your .anyone file. If a user is present\n" 142 "but sent no login message, or a user is not present that sent no\n" 143 "logout message a pseudo login or logout message wil be created\n"), 137 144 138 145 OWLVAR_ENUM_FULL( "disable-ctrl-d" /* %OwlVarStub:lockout_ctrld */, 1, -
zephyr.c
rc8735aa r5a95b69 794 794 795 795 796 797 796 /* Strip a local realm fron the zephyr user name. 798 797 * The caller must free the return … … 868 867 return(out); 869 868 } 869 870 /* read the list of users in 'filename' as a .anyone file, and put the 871 * names of the zephyr users in the list 'in'. If 'filename' is NULL, 872 * use the default .anyone file in the users home directory. Returns 873 * -1 on failure, 0 on success. 874 */ 875 int owl_zephyr_get_anyone_list(owl_list *in, char *filename) 876 { 877 #ifdef HAVE_LIBZEPHYR 878 char *ourfile, *tmp, buff[LINE]; 879 FILE *f; 880 881 if (filename==NULL) { 882 tmp=owl_global_get_homedir(&g); 883 ourfile=owl_sprintf("%s/.anyone", owl_global_get_homedir(&g)); 884 } else { 885 ourfile=owl_strdup(filename); 886 } 887 888 f=fopen(ourfile, "r"); 889 if (!f) { 890 owl_function_error("Error opening file %s: %s", ourfile, strerror(errno) ? strerror(errno) : ""); 891 owl_free(ourfile); 892 return(-1); 893 } 894 895 while (fgets(buff, LINE, f)!=NULL) { 896 /* ignore comments, blank lines etc. */ 897 if (buff[0]=='#') continue; 898 if (buff[0]=='\n') continue; 899 if (buff[0]=='\0') continue; 900 901 /* strip the \n */ 902 buff[strlen(buff)-1]='\0'; 903 904 /* ingore from # on */ 905 tmp=strchr(buff, '#'); 906 if (tmp) tmp[0]='\0'; 907 908 /* ingore from SPC */ 909 tmp=strchr(buff, ' '); 910 if (tmp) tmp[0]='\0'; 911 912 /* stick on the local realm. */ 913 if (!strchr(buff, '@')) { 914 strcat(buff, "@"); 915 strcat(buff, ZGetRealm()); 916 } 917 owl_list_append_element(in, owl_strdup(buff)); 918 } 919 fclose(f); 920 owl_free(ourfile); 921 return(0); 922 #else 923 return(-1); 924 #endif 925 }
Note: See TracChangeset
for help on using the changeset viewer.