Changeset 5a95b69 for zephyr.c


Ignore:
Timestamp:
Dec 20, 2003, 1:35:36 PM (21 years ago)
Author:
James M. Kretchmar <kretch@mit.edu>
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
Message:
New code for getting users from .anyfile
Added the 'pseudologins' variable, and code to do it
new attributes 'pseudo' 'logintty' and 'loginhost'
File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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.