Lines 209-214
cifs_resolver(const key_serial_t key, const char *key_descr)
Link Here
|
209 |
return 0; |
209 |
return 0; |
210 |
} |
210 |
} |
211 |
|
211 |
|
|
|
212 |
const char * |
213 |
cifs_get_cname(const char * name) |
214 |
{ |
215 |
static char buf[NI_MAXHOST]; |
216 |
struct addrinfo * info; |
217 |
int ret = getaddrinfo(name, 0, 0, &info); |
218 |
if(ret) |
219 |
{ |
220 |
syslog(LOG_WARNING, "getaddrinfo: %s", |
221 |
gai_strerror(ret)); |
222 |
return NULL; |
223 |
} |
224 |
ret = getnameinfo(info->ai_addr, info->ai_addrlen, |
225 |
buf, sizeof(buf), 0, 0, 0); |
226 |
if(ret) |
227 |
{ |
228 |
syslog(LOG_WARNING, "getnameinfo: %s", |
229 |
gai_strerror(ret)); |
230 |
freeaddrinfo(info); |
231 |
return NULL; |
232 |
} |
233 |
freeaddrinfo(info); |
234 |
return buf; |
235 |
} |
236 |
|
212 |
static void |
237 |
static void |
213 |
usage(void) |
238 |
usage(void) |
214 |
{ |
239 |
{ |
Lines 316-323
int main(const int argc, char *const argv[])
Link Here
|
316 |
char *princ; |
341 |
char *princ; |
317 |
size_t len; |
342 |
size_t len; |
318 |
|
343 |
|
|
|
344 |
const char * cname = cifs_get_cname(hostname); |
345 |
if (!cname) { |
346 |
rc = 1; |
347 |
break; |
348 |
} |
319 |
/* for "cifs/" service name + terminating 0 */ |
349 |
/* for "cifs/" service name + terminating 0 */ |
320 |
len = strlen(hostname) + 5 + 1; |
350 |
len = strlen(cname) + 5 + 1; |
321 |
princ = SMB_XMALLOC_ARRAY(char, len); |
351 |
princ = SMB_XMALLOC_ARRAY(char, len); |
322 |
if (!princ) { |
352 |
if (!princ) { |
323 |
rc = 1; |
353 |
rc = 1; |
Lines 328-334
int main(const int argc, char *const argv[])
Link Here
|
328 |
} else { |
358 |
} else { |
329 |
strlcpy(princ, "host/", len); |
359 |
strlcpy(princ, "host/", len); |
330 |
} |
360 |
} |
331 |
strlcpy(princ + 5, hostname, len - 5); |
361 |
strlcpy(princ + 5, cname, len - 5); |
332 |
|
362 |
|
333 |
if (sectype == MS_KRB5) |
363 |
if (sectype == MS_KRB5) |
334 |
oid = OID_KERBEROS5_OLD; |
364 |
oid = OID_KERBEROS5_OLD; |