Lines Matching +full:realm +full:-

1 /* -*- mode: c; c-basic-offset: 4; indent-tabs-mode: nil -*- */
33 #include "k5-int.h"
39 * subrealm - determine if r2 is a subrealm of r1
65 if((*r1 == '/') && (*r2 == '/') && (strncmp(r1,r2,l1) == 0)) return(l1-l2); in subrealm()
66 if((*r1 != '/') && (*r2 != '/') && (strncmp(r1,r2+l2-l1,l1) == 0)) in subrealm()
67 return(l2-l1); in subrealm()
72 * add_to_transited Adds the name of the realm which issued the
75 * the realm of the server listed in the ticket
80 * in compressed form. It will add the new realm while
82 * realm is added using this (or a similar) routine, the
90 * This includes the realm of the KDC
92 * ticket. This is the realm that is
103 * RETURNS: krb5_error_code - Success, or out of memory
105 * MODIFIES: new_trans: ->length will contain the length of the new
108 * If ->data was not null when this procedure
109 * is called, the memory referenced by ->data
113 * ->data will be updated to point to the newly
118 * and the realm to be added. This length is calculated
119 * assuming that no compression of the new realm is possible.
126 * This procedure does not check for quoted commas in realm
134 s = malloc(d->length + 1); in data2string()
136 if (d->length > 0) in data2string()
137 memcpy(s, d->data, d->length); in data2string()
138 s[d->length] = 0; in data2string()
149 char *realm; in add_to_transited() local
159 char exp[MAX_REALM_LN]; /* Expanded current realm name */ in add_to_transited()
164 int added; /* TRUE = new realm has been added */ in add_to_transited()
166 realm = data2string(krb5_princ_realm(kdc_context, tgs)); in add_to_transited()
167 if (realm == NULL) in add_to_transited()
172 free(realm); in add_to_transited()
180 +1 for potential space when leading slash in realm */ in add_to_transited()
181 bufsize = strlen(realm) + strlen(otrans) + 3; in add_to_transited()
189 if (new_trans->data) free(new_trans->data); in add_to_transited()
190 new_trans->data = trans; in add_to_transited()
191 new_trans->length = 0; in add_to_transited()
195 /* For the purpose of appending, the realm preceding the first */ in add_to_transited()
196 /* realm in the transited field is considered the null realm */ in add_to_transited()
220 added = (krb5_princ_realm(kdc_context, client)->length == strlen(realm) && in add_to_transited()
221 !strncmp(krb5_princ_realm(kdc_context, client)->data, realm, strlen(realm))) || in add_to_transited()
222 (krb5_princ_realm(kdc_context, server)->length == strlen(realm) && in add_to_transited()
223 !strncmp(krb5_princ_realm(kdc_context, server)->data, realm, strlen(realm))); in add_to_transited()
229 clst = strlen(current) - 1; in add_to_transited()
231 strncpy(exp, current+1, sizeof(exp) - 1); in add_to_transited()
232 exp[sizeof(exp) - 1] = '\0'; in add_to_transited()
235 strncpy(exp, prev, sizeof(exp) - 1); in add_to_transited()
236 exp[sizeof(exp) - 1] = '\0'; in add_to_transited()
241 strncat(exp, current, sizeof(exp) - 1 - strlen(exp)); in add_to_transited()
244 strncpy(exp, current, sizeof(exp) - 1); in add_to_transited()
245 exp[sizeof(exp) - 1] = '\0'; in add_to_transited()
250 strncat(exp, prev, sizeof(exp) - 1 - strlen(exp)); in add_to_transited()
253 strncpy(exp, current, sizeof(exp) - 1); in add_to_transited()
254 exp[sizeof(exp) - 1] = '\0'; in add_to_transited()
276 nlst = i - 1; in add_to_transited()
278 if (!strcmp(exp, realm)) added = TRUE; in add_to_transited()
280 /* If we still have to insert the new realm */ in add_to_transited()
285 /* realm is a subrealm of the current realm, compress */ in add_to_transited()
286 /* the new realm, and insert immediately following the */ in add_to_transited()
290 /* not a problem because the realm to be added will be a */ in add_to_transited()
299 (pl = subrealm(exp, realm))) { in add_to_transited()
301 current[sizeof(current) - 1] = '\0'; in add_to_transited()
302 if (strlen(current) + (pl>0?pl:-pl) + 2 >= MAX_REALM_LN) { in add_to_transited()
306 strncat(current, ",", sizeof(current) - 1 - strlen(current)); in add_to_transited()
308 strncat(current, realm, (unsigned) pl); in add_to_transited()
311 strncat(current, realm+strlen(realm)+pl, (unsigned) (-pl)); in add_to_transited()
316 /* realm to be added is a superrealm of the current realm,*/ in add_to_transited()
317 /* then the current realm can be compressed. First the */ in add_to_transited()
318 /* realm to be added must be compressed relative to the */ in add_to_transited()
319 /* previous realm (if possible), and then the current */ in add_to_transited()
320 /* realm compressed relative to the new realm. Note that */ in add_to_transited()
321 /* if the realm to be added is also a superrealm of the */ in add_to_transited()
322 /* previous realm, it would have been added earlier, and */ in add_to_transited()
325 else if ((pl = subrealm(realm, exp))) { in add_to_transited()
328 if ((pl1 = subrealm(prev,realm))) { in add_to_transited()
329 if (strlen(current) + (pl1>0?pl1:-pl1) + 1 >= MAX_REALM_LN) { in add_to_transited()
334 strncat(current, realm, (unsigned) pl1); in add_to_transited()
337 strncat(current, realm+strlen(realm)+pl1, (unsigned) (-pl1)); in add_to_transited()
341 if ((realm[0] == '/') && prev[0]) { in add_to_transited()
346 strncat(current, " ", sizeof(current) - 1 - strlen(current)); in add_to_transited()
347 current[sizeof(current) - 1] = '\0'; in add_to_transited()
349 if (strlen(current) + strlen(realm) + 1 >= MAX_REALM_LN) { in add_to_transited()
353 strncat(current, realm, sizeof(current) - 1 - strlen(current)); in add_to_transited()
354 current[sizeof(current) - 1] = '\0'; in add_to_transited()
356 if (strlen(current) + (pl>0?pl:-pl) + 2 >= MAX_REALM_LN) { in add_to_transited()
360 strncat(current,",", sizeof(current) - 1 - strlen(current)); in add_to_transited()
361 current[sizeof(current) - 1] = '\0'; in add_to_transited()
366 strncat(current, exp+strlen(exp)+pl, (unsigned)(-pl)); in add_to_transited()
371 if (new_trans->length != 0) { in add_to_transited()
381 new_trans->length = strlen(trans); in add_to_transited()
383 strncpy(prev, exp, sizeof(prev) - 1); in add_to_transited()
384 prev[sizeof(prev) - 1] = '\0'; in add_to_transited()
385 strncpy(current, next, sizeof(current) - 1); in add_to_transited()
386 current[sizeof(current) - 1] = '\0'; in add_to_transited()
390 if (new_trans->length != 0) { in add_to_transited()
396 if((realm[0] == '/') && trans[0]) { in add_to_transited()
402 if (strlcat(trans, realm, bufsize) >= bufsize) { in add_to_transited()
406 new_trans->length = strlen(trans); in add_to_transited()
411 free(realm); in add_to_transited()