[78] in arla-drinkers

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

Re: appl/arlalib.c's arlalib_get_cred() problems

daemon@ATHENA.MIT.EDU (Assar Westerlund)
Fri Jul 3 07:29:34 1998

From arla-drinkers-request@sundance.stacken.kth.se Fri Jul 03 11:29:32 1998
Return-Path: <arla-drinkers-request@sundance.stacken.kth.se>
Delivered-To: arla-drinkers-mtg@bloom-picayune.mit.edu
Received: (qmail 4441 invoked from network); 3 Jul 1998 11:29:30 -0000
Received: from unknown (HELO sundance.stacken.kth.se) (130.237.234.41)
  by bloom-picayune.mit.edu with SMTP; 3 Jul 1998 11:29:29 -0000
Received: from assaris.sics.se (assaris.sics.se [193.10.66.108])
	by sundance.stacken.kth.se (8.8.8/8.8.8) with ESMTP id NAA04496
	for <arla-drinkers@stacken.kth.se>; Fri, 3 Jul 1998 13:19:19 +0200 (MET DST)
Received: (from assar@localhost) by assaris.sics.se (8.8.5/8.7.3) id NAA17109; Fri, 3 Jul 1998 13:20:19 +0200 (MET DST)
To: John Hawkinson <jhawk@bbnplanet.com>
Cc: arla-drinkers@stacken.kth.se
Subject: Re: appl/arlalib.c's arlalib_get_cred() problems
References: <199807030030.UAA07086@all-purpose-gunk.near.net>
Mime-Version: 1.0 (generated by tm-edit 7.68)
Content-Type: multipart/mixed;
 boundary="Multipart_Fri_Jul__3_13:20:17_1998-1"
Content-Transfer-Encoding: 7bit
From: Assar Westerlund <assar@sics.se>
Date: 03 Jul 1998 13:20:17 +0200
In-Reply-To: John Hawkinson's message of "Thu, 2 Jul 1998 20:30:30 -0400 (EDT)"
Message-ID: <5lsokj18r2.fsf@assaris.sics.se>
Lines: 107
X-Mailer: Gnus v5.5/Emacs 19.34

--Multipart_Fri_Jul__3_13:20:17_1998-1
Content-Type: text/plain; charset=US-ASCII

John Hawkinson <jhawk@bbnplanet.com> writes:
> This seems to work fine, but rqeuires the user to set AFS_SYCALL
> to "xfs" or "afs" as appropriate; seemingly it'd be better to just
> default to one.

So you actually want it to be "xfs,afs" ?  Here's a new patch (also
relative to 1.59) :-)

/assar

--Multipart_Fri_Jul__3_13:20:17_1998-1
Content-Type: text/plain; charset=US-ASCII

Index: afssys.c
===================================================================
RCS file: /afs/pdc.kth.se/src/packages/kth-krb/SourceRepository/lib/kafs/afssys.c,v
retrieving revision 1.59
diff -u -w -u -w -r1.59 afssys.c
--- afssys.c	1998/06/30 15:25:09	1.59
+++ afssys.c	1998/07/03 11:18:52
@@ -90,6 +90,40 @@
 }
 #endif /* _AIX */
 
+/* 
+ * This probably only works under Solaris and could get confused if
+ * there's a /etc/name_to_sysnum file.  
+ */
+
+#define _PATH_ETC_NAME_TO_SYSNUM "/etc/name_to_sysnum"
+
+static int
+map_syscall_name_to_number (const char *str, int *res)
+{
+    FILE *f;
+    char buf[256];
+    size_t str_len = strlen (str);
+
+    f = fopen (_PATH_ETC_NAME_TO_SYSNUM, "r");
+    if (f == NULL)
+	return -1;
+    while (fgets (buf, sizeof(buf), f) != NULL) {
+	if (strncmp (str, buf, str_len) == 0) {
+	    char *begptr = buf + str_len;
+	    char *endptr;
+	    long val = strtol (begptr, &endptr, 0);
+
+	    if (val != 0 && endptr != begptr) {
+		fclose (f);
+		*res = val;
+		return 0;
+	    }
+	}
+    }
+    fclose (f);
+    return -1;
+}
+
 #define NO_ENTRY_POINT		0
 #define SINGLE_ENTRY_POINT	1
 #define MULTIPLE_ENTRY_POINT	2
@@ -252,7 +286,8 @@
     char *env = getenv ("AFS_SYSCALL");
   
     /*
-     * Already checked presence of AFS syscalls?  */
+     * Already checked presence of AFS syscalls?
+     */
     if (afs_entry_point != UNKNOWN_ENTRY_POINT)
 	return afs_entry_point != NO_ENTRY_POINT;
 
@@ -273,9 +308,29 @@
     {
 	int tmp;
 
-	if (env != NULL && sscanf (env, "%d", &tmp) == 1)
+	if (env != NULL) {
+	    if (sscanf (env, "%d", &tmp) == 1) {
 	    if (try_one (tmp) == 0)
 		goto done;
+	    } else {
+		char *end = NULL;
+		char *p;
+		char *s = strdup (env);
+
+		if (s != NULL) {
+		    for (p = strtok_r (s, ",", &end);
+			 p != NULL;
+			 p = strtok_r (NULL, ",", &end)) {
+			if (map_syscall_name_to_number (p, &tmp) == 0)
+			    if (try_one (tmp) == 0) {
+				free (s);
+				goto done;
+			    }
+		    }
+		    free (s);
+		}
+	    }
+	}
     }
 #endif /* AFS_SYSCALL || AFS_SYSCALL2 || AFS_SYSCALL3 */
 

--Multipart_Fri_Jul__3_13:20:17_1998-1--

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