[767] in Zephyr_Bugs

home help back first fref pref prev next nref lref last post

server realm expansion

daemon@ATHENA.MIT.EDU (Derrick J Brashear)
Sat Apr 6 17:19:29 1996

Date: Sat, 6 Apr 1996 17:19:24 -0500 (EST)
From: Derrick J Brashear <shadow@DEMENTIA.ORG>
To: bug-zephyr@MIT.EDU


Hi,

Attached are diffs to server/{realm,dispatch}.c which implement realm 
expansion based on realm.list. I have not yet tested them as they are as 
I am not yet using the 2.1 beta code.

If the diff gets messed up as it gets gatewayed to discuss, you can find 
my 2.1 working area in 
/afs/andrew.cmu.edu/system/src/local/zephyr/037/dist/server

Enjoy.

-D
diff -crt /afs/athena.mit.edu/astaff/project/zephyr/src/zephyr/server//dispatch.c ./dispatch.c
*** /afs/athena.mit.edu/astaff/project/zephyr/src/zephyr/server//dispatch.c	Wed Apr  3 22:00:13 1996
--- ./dispatch.c	Sat Apr  6 13:18:40 1996
***************
*** 316,322 ****
              authflag = 0;
          if (!bound_for_local_realm(notice)) {
              cp = strchr(notice->z_recipient, '@');
!             if (!cp || !(realm = realm_get_realm_by_name(cp + 1)))
                  sendit(notice, authflag, who, 0);
              else
                  realm_handoff(notice, authflag, who, realm, 1);
--- 316,323 ----
              authflag = 0;
          if (!bound_for_local_realm(notice)) {
              cp = strchr(notice->z_recipient, '@');
!             if (!cp || !(realm = realm_get_realm_by_name
!                          (realm_expand_realm(cp + 1))))
                  sendit(notice, authflag, who, 0);
              else
                  realm_handoff(notice, authflag, who, realm, 1);
***************
*** 345,350 ****
--- 346,353 ----
      struct sockaddr_in *who;
      int external;
  {
+     char recipbuf[ANAME_SZ+INST_SZ+REALM_SZ+3];
+     char *recipp;
      static int send_counter = 0;
      int any = 0;
      Acl *acl;
***************
*** 422,431 ****
      dest.inst = make_string(notice->z_class_inst, 1);
      if (bound_for_local_realm(notice) && *notice->z_recipient == '@')
          dest.recip = make_string("", 0);
!     else
!         dest.recip = make_string(notice->z_recipient, 0);
!     if (send_to_dest(notice, auth, &dest, send_counter, external))
          any = 1;
  
      /* Send to clients subscribed to the triplet with the instance
       * substituted with the wildcard instance. */
--- 425,439 ----
      dest.inst = make_string(notice->z_class_inst, 1);
      if (bound_for_local_realm(notice) && *notice->z_recipient == '@')
          dest.recip = make_string("", 0);
!     else {
!       strncpy(&recipbuf, notice->z_recipient, sizeof(recipbuf));
!       if (recipp = strrchr(&recipbuf, '@') != NULL) {
!         sprintf(recipp+1, "%s", realm_expand_realm(recipp+1));
!       }
!       dest.recip = make_string(recipbuf, 0);
!       if (send_to_dest(notice, auth, &dest, send_counter, external))
          any = 1;
+     }
  
      /* Send to clients subscribed to the triplet with the instance
       * substituted with the wildcard instance. */
Only in .: dispatch.c~
diff -crt /afs/athena.mit.edu/astaff/project/zephyr/src/zephyr/server//realm.c ./realm.c
*** /afs/athena.mit.edu/astaff/project/zephyr/src/zephyr/server//realm.c	Wed Apr  3 17:59:24 1996
--- ./realm.c	Fri Apr  5 16:45:13 1996
***************
*** 23,28 ****
--- 23,98 ----
  static Code_t ticket_retrieve __P((char *realm));
  #endif
  
+ char *
+ realm_expand_realm(realmname)
+ char *realmname;
+ {
+         char *cp1, *cp2;
+         static char expand[REALM_SZ];
+ #ifndef ZEPHYR_USES_KERBEROS
+         struct hostent *he;
+ 
+         he = gethostbyname(realmname);
+ 
+         if (!he || !he->h_name)
+                 /* just use the raw realm */
+                 cp2 = realmname;
+         else
+                 cp2 = he->h_name;
+ 
+         cp1 = expand;
+         while (*cp2) {
+                 *cp1++ = toupper(*cp2++);
+         }
+         *cp1 = '\0';
+ 
+         return(expand);
+ #else
+         int retval;
+         FILE *rlm_file;
+         char list_name[128];
+         static char krb_realm[REALM_SZ+1];
+         char linebuf[BUFSIZ];
+         char scratch[128];
+ 
+         /* upcase what we got */
+         cp2 = realmname;
+         cp1 = expand;
+         while (*cp2) {
+                 *cp1++ = toupper(*cp2++);
+         }
+         *cp1 = '\0';
+ 
+         sprintf(list_file, "%s/%s", CONFDIR, REALM_LIST_FILE);
+ 
+         if ((rlm_file = fopen(list_file, "r")) == (FILE *) 0) {
+                 return(expand);
+         }
+ 
+         if (fgets(linebuf, BUFSIZ, rlm_file) == NULL) {
+           /* error reading */
+           (void) fclose(rlm_file);
+           return(expand);
+         }
+ 
+         while (1) {
+           /* run through the file, looking for admin host */
+           if (fgets(linebuf, BUFSIZ, rlm_file) == NULL) {
+             (void) fclose(rlm_file);
+             return(expand);
+           }
+ 
+           if (sscanf(linebuf, "%s %s", krb_realm, scratch)
+               < 2)
+             continue;
+           if (!strncmp(krb_realm, expand, strlen(expand))) {
+             (void) fclose(rlm_file);
+             return(krb_realm);
+           }
+         }
+ #endif /* ZEPHYR_USES_KERBEROS */
+ }
+ 
  Realmname *
  get_realm_lists(file)
      char *file;
***************
*** 126,132 ****
    
    realm = strchr(notice->z_recipient, '@');
    
!   if (!realm || !strcmp(realm + 1, ZGetRealm()))
      return 1;
  
    return 0;
--- 196,202 ----
    
    realm = strchr(notice->z_recipient, '@');
    
!   if (!realm || !strcmp(realm_expand_realm(realm + 1), ZGetRealm()))
      return 1;
  
    return 0;


home help back first fref pref prev next nref lref last post