Changeset 5a95b69


Ignore:
Timestamp:
Dec 20, 2003, 1:35:36 PM (17 years ago)
Author:
James M. Kretchmar <kretch@mit.edu>
Branches:
master, barnowl_perlaim, debian, owl, release-1.4, release-1.5, release-1.6, release-1.7, release-1.8, release-1.9
Children:
72836b5
Parents:
c8735aa
Message:
New code for getting users from .anyfile
Added the 'pseudologins' variable, and code to do it
new attributes 'pseudo' 'logintty' and 'loginhost'
Files:
10 edited

Legend:

Unmodified
Added
Removed
  • ChangeLog

    rc8735aa r5a95b69  
    55        Don't bind F1 to help in edit context
    66        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'
    8102.0.14
    911        Fixed missing word in startup message
  • Makefile.in

    r8c92848 r5a95b69  
    2323     regex.c history.c view.c dict.c variable.c filterelement.c pair.c \
    2424     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
    2627OWL_SRC = owl.c
    2728TESTER_SRC = tester.c
  • functions.c

    r8c46404 r5a95b69  
    14291429      n=owl_message_get_notice(m);
    14301430
    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        }
    14521454      }
    14531455      owl_fmtext_append_normal(&fm, "  Host      : ");
    14541456      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      }
    14691504     
    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);
    14991505    }
    15001506#endif   
     
    30203026}
    30213027
    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 */
     3029void owl_function_buddylist(int aim, int zephyr, char *filename)
     3030{
     3031  int i, j, x, idle;
    30263032  owl_fmtext fm;
    30273033  owl_buddylist *bl;
    30283034  owl_buddy *b;
     3035  owl_list anyone;
    30293036  char *foo, *timestr;
    30303037#ifdef HAVE_LIBZEPHYR
    3031   char *ourfile, *tmp, buff[LINE], *line;
     3038  char *tmp, *user, *line;
    30323039  ZLocations_t location[200];
    3033   FILE *f;
    30343040  int numlocs, ret;
    30353041#endif
     
    30613067#ifdef HAVE_LIBZEPHYR
    30623068  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");
    30663074    } 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);
    31023079        if (ret!=ZERR_NONE) {
    3103           owl_function_error("Error getting location for %s", buff);
     3080          owl_function_error("Error getting location for %s", user);
    31043081          continue;
    31053082        }
     
    31083085        ret=ZGetLocations(location, &numlocs);
    31093086        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);
    31133090            sprintf(line, "  %-10.10s %-24.24s %-12.12s  %20.20s\n",
    31143091                    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);
    31183095            owl_fmtext_append_normal(&fm, line);
    31193096            owl_free(tmp);
     
    31243101        }
    31253102      }
    3126       fclose(f);
    3127     }
    3128     owl_free(ourfile);
     3103    }
    31293104  }
    31303105#endif
     
    31323107  owl_function_popless_fmtext(&fm);
    31333108  owl_fmtext_free(&fm);
     3109  owl_list_free_all(&anyone, owl_free);
    31343110}
    31353111
     
    31413117  owl_view *v;
    31423118  FILE *file;
    3143 
    3144   /* struct stat sbuf; */
    31453119
    31463120  v=owl_global_get_current_view(&g);
     
    33883362  va_end(ap);
    33893363}
     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 */
     3370void 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  
    105105
    106106  owl_errqueue_init(&(g->errqueue));
    107 
    108107  g->got_err_signal=0;
     108
     109  owl_zbuddylist_create(&(g->zbuddies));
     110  owl_timer_create_countdown(&(g->zephyr_buddycheck_timer), 60*3);
    109111}
    110112
     
    868870}
    869871
     872owl_timer *owl_global_get_zephyr_buddycheck_timer(owl_global *g)
     873{
     874  return(&(g->zephyr_buddycheck_timer));
     875}
     876
     877owl_zbuddylist *owl_global_get_zephyr_buddylist(owl_global *g)
     878{
     879  return(&(g->zbuddies));
     880}
  • message.c

    r25dd31a r5a95b69  
    3434}
    3535
     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 */
    3639void owl_message_set_attribute(owl_message *m, char *attrname, char *attrvalue)
    3740{
    38   /* add the named attribute to the message.  If an attribute with the
    39      name already exists, replace the old value with the new value */
    40 
    4141  int i, j;
    4242  owl_pair *p;
     
    6161}
    6262
     63/* return the value associated with the named attribute, or NULL if
     64 * the attribute does not exist
     65 */
    6366char *owl_message_get_attribute_value(owl_message *m, char *attrname)
    6467{
    65   /* return the value associated with the named attribute, or NULL if
    66      the attribute does not exist */
    6768  int i, j;
    6869  owl_pair *p;
     
    362363{
    363364  if (m->type==OWL_MESSAGE_TYPE_AIM) return(1);
     365  return(0);
     366}
     367
     368int owl_message_is_pseudo(owl_message *m)
     369{
     370  if (owl_message_get_attribute_value(m, "pseudo")) return(1);
    364371  return(0);
    365372}
     
    707714{
    708715  struct hostent *hent;
    709   int k;
     716  int k, len;
    710717  char *ptr, *tmp, *tmp2;
    711718
     
    721728  owl_zephyr_hackaway_cr(&(m->notice));
    722729 
    723   m->delete=0;
    724 
    725730  /* 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);
    729732  m->time=n->z_time.tv_sec;
    730733  m->timestr=owl_strdup(ctime(&(m->time)));
     
    751754  /* Set the "isloginout" attribute if it's a login message */
    752755  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
    753772    if (!strcasecmp(n->z_opcode, "user_login")) {
    754773      owl_message_set_islogin(m);
     
    758777  }
    759778
     779 
    760780  /* is the "isprivate" attribute if it's a private zephyr */
    761781  if (!strcasecmp(n->z_recipient, owl_zephyr_get_sender())) {
     
    810830#endif
    811831
     832/* If 'direction' is '0' it is a login message, '1' is a logout message. */
     833void 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
    812878void owl_message_create_from_zwriteline(owl_message *m, char *line, char *body, char *zsig)
    813879{
  • owl.c

    ra68f05d r5a95b69  
    342342  }
    343343
     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
    344348  /* set the startup and default style, based on userclue and presence of a
    345349   * formatting function */
     
    491495      }
    492496
     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
    493508      /* check for burning ears message */
    494509      /* this is an unsupported feature */
     
    504519      if (owl_global_is_logging(&g) || owl_global_is_classlogging(&g)) {
    505520        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));
    506530      }
    507531    }
  • owl.h

    re7bcd1b r5a95b69  
    414414  owl_list buddies;
    415415} owl_buddylist;
     416
     417typedef struct _owl_zbuddylist {
     418  owl_list zusers;
     419} owl_zbuddylist;
    416420
    417421typedef struct _owl_timer {
     
    488492  int haveaim;
    489493  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;
    491497} owl_global;
    492498
  • stylefunc.c

    r97cd00be r5a95b69  
    4747      owl_fmtext_append_normal(fm, "\n");
    4848    } 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     
    6254      if (owl_message_is_login(m)) {
    6355        owl_fmtext_append_bold(fm, "LOGIN");
    6456      } else if (owl_message_is_logout(m)) {
    6557        owl_fmtext_append_bold(fm, "LOGOUT");
     58      }
     59      if (owl_message_is_pseudo(m)) {
     60        owl_fmtext_append_bold(fm, " (PSEUDO)");
    6661      }
    6762      owl_fmtext_append_normal(fm, " for ");
     
    7065      owl_free(ptr);
    7166      owl_fmtext_append_normal(fm, " at ");
    72       owl_fmtext_append_normal(fm, host);
     67      owl_fmtext_append_normal(fm, host ? host : "");
    7368      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");
    7971    } else {
    8072      owl_fmtext_append_normal(fm, "From: ");
     
    266258      owl_fmtext_append_normal(fm, "\n");
    267259    } 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");
    280264     
    281265      if (owl_message_is_login(m)) {
     
    284268        owl_fmtext_append_bold(fm, "LOGOUT");
    285269      }
     270
     271      if (owl_message_is_pseudo(m)) owl_fmtext_append_bold(fm, " (PSEUDO)");
     272       
    286273      owl_fmtext_append_normal(fm, " for ");
    287274      ptr=short_zuser(owl_message_get_instance(m));
     
    289276      owl_free(ptr);
    290277      owl_fmtext_append_normal(fm, " at ");
    291       owl_fmtext_append_normal(fm, host);
     278      owl_fmtext_append_normal(fm, host ? host : "");
    292279      owl_fmtext_append_normal(fm, " ");
    293       owl_fmtext_append_normal(fm, tty);
     280      owl_fmtext_append_normal(fm, tty ? tty : "");
    294281      owl_fmtext_append_normal(fm, " ");
    295282      owl_fmtext_append_normal(fm, shorttimestr);
    296283      owl_fmtext_append_normal(fm, "\n");
    297 
    298       owl_free(host);
    299       owl_free(tty);
    300284    } else {
    301285      owl_fmtext_append_normal(fm, owl_message_get_class(m));
     
    482466
    483467    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");
    496472
    497473      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);
    499475        owl_fmtext_append_normal(fm, tmp);
    500476        owl_free(tmp);
    501477      } 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);
    503479        owl_fmtext_append_normal(fm, tmp);
    504480        owl_free(tmp);
     
    506482
    507483      owl_fmtext_append_normal(fm, "at ");
    508       owl_fmtext_append_normal(fm, host);
     484      owl_fmtext_append_normal(fm, host ? host : "");
    509485      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");
    515488
    516489    } else if (owl_message_is_ping(m)) {
     
    664637      owl_fmtext_append_normal(fm, "\n");
    665638    } 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");
    678643     
    679644      if (owl_message_is_login(m)) {
     
    682647        owl_fmtext_append_bold(fm, "LOGOUT");
    683648      }
     649      if (owl_message_is_pseudo(m)) owl_fmtext_append_bold(fm, " (PSEUDO)");
     650
    684651      owl_fmtext_append_normal(fm, " for ");
    685652      ptr=short_zuser(owl_message_get_instance(m));
     
    687654      owl_free(ptr);
    688655      owl_fmtext_append_normal(fm, " at ");
    689       owl_fmtext_append_normal(fm, host);
     656      owl_fmtext_append_normal(fm, host ? host : "");
    690657      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");
    696660    } else {
    697661      owl_fmtext_append_normal(fm, sender);
  • variable.c

    r1db061d r5a95b69  
    135135               "Do automatic zcrypt processing",
    136136               "" ),
     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"),
    137144
    138145  OWLVAR_ENUM_FULL( "disable-ctrl-d" /* %OwlVarStub:lockout_ctrld */, 1,
  • zephyr.c

    rc8735aa r5a95b69  
    794794 
    795795
    796 
    797796/* Strip a local realm fron the zephyr user name.
    798797 * The caller must free the return
     
    868867  return(out);
    869868}
     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 */
     875int 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.