windows-talocale-20060829
[openafs.git] / src / WINNT / aklog / aklog.c
index d08166c..ae4970d 100644 (file)
@@ -183,8 +183,7 @@ void ViceIDToUsername(char *username, char *realm_of_user, char *realm_of_cell,
 {
     static char lastcell[MAXCELLCHARS+1] = { 0 };
     static char confname[512] = { 0 };
-    char username_copy[BUFSIZ];
-    long viceId;                       /* AFS uid of user */
+    afs_int32 viceId;                  /* AFS uid of user */
 #ifdef ALLOW_REGISTER
     afs_int32 id;
 #endif /* ALLOW_REGISTER */
@@ -197,30 +196,19 @@ void ViceIDToUsername(char *username, char *realm_of_user, char *realm_of_cell,
     if (dflag)
         printf("About to resolve name %s to id\n", username);
 
-    /*
-    * Talk about DUMB!  It turns out that there is a bug in
-    * pr_Initialize -- even if you give a different cell name
-    * to it, it still uses a connection to a previous AFS server
-    * if one exists.  The way to fix this is to change the
-    * _filename_ argument to pr_Initialize - that forces it to
-    * re-initialize the connection.  We do this by adding and
-    * removing a "/" on the end of the configuration directory name.
-    */
-
-    if (lastcell[0] != '\0' && (strcmp(lastcell, aserver->cell) != 0)) {
-        int i = strlen(confname);
-        if (confname[i - 1] == '/') {
-            confname[i - 1] = '\0';
-        } else {
-            confname[i] = '/';
-            confname[i + 1] = '\0';
-        }
-    }
-
     strcpy(lastcell, aserver->cell);
 
-    if (!pr_Initialize (0, confname, aserver->cell))
-        *status = pr_SNameToId (username, &viceId);
+    if (!pr_Initialize (0, confname, aserver->cell)) {
+        char sname[PR_MAXNAMELEN], *at;
+
+        strncpy(sname, username, PR_MAXNAMELEN);
+        sname[PR_MAXNAMELEN-1] = '\0';
+
+       at = strchr(sname, '@');
+       if (at && !stricmp(at+1, realm_of_cell))
+           *at = '\0';
+       *status = pr_SNameToId (sname, &viceId);
+    }
 
     if (dflag)
     {
@@ -762,7 +750,8 @@ static int auth_to_cell(krb5_context context, char *cell, char *realm)
             }
         }
 
-        if (strcmp(realm_of_user, realm_of_cell))
+        /* For Khimaira we want to always append the realm to the name */
+        if (1 /* strcmp(realm_of_user, realm_of_cell) */)
         {
             strcat(username, "@");
             strcat(username, realm_of_user);