2 * Copyright (c) 1997 - 2007 Kungliga Tekniska Högskolan
3 * (Royal Institute of Technology, Stockholm, Sweden).
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the
15 * documentation and/or other materials provided with the distribution.
17 * 3. Neither the name of the Institute nor the names of its contributors
18 * may be used to endorse or promote products derived from this software
19 * without specific prior written permission.
21 * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
22 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24 * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
25 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
27 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
34 #include "kadm5_locl.h"
35 #include "heim_threads.h"
40 * A log record consists of:
42 * version number 4 bytes
43 * time in seconds 4 bytes
44 * operation (enum kadm_ops) 4 bytes
45 * length of record 4 bytes
47 * length of record 4 bytes
48 * version number 4 bytes
53 kadm5_log_get_version_fd (int fd
,
60 ret
= lseek (fd
, 0, SEEK_END
);
67 sp
= krb5_storage_from_fd (fd
);
68 krb5_storage_seek(sp
, -4, SEEK_CUR
);
69 krb5_ret_int32 (sp
, &old_version
);
71 krb5_storage_free(sp
);
72 lseek (fd
, 0, SEEK_END
);
77 kadm5_log_get_version (kadm5_server_context
*context
, uint32_t *ver
)
79 return kadm5_log_get_version_fd (context
->log_context
.log_fd
, ver
);
83 kadm5_log_set_version (kadm5_server_context
*context
, uint32_t vno
)
85 kadm5_log_context
*log_context
= &context
->log_context
;
87 log_context
->version
= vno
;
92 kadm5_log_init (kadm5_server_context
*context
)
96 kadm5_log_context
*log_context
= &context
->log_context
;
98 if (log_context
->log_fd
!= -1)
100 fd
= open (log_context
->log_file
, O_RDWR
| O_CREAT
, 0600);
103 krb5_set_error_message(context
->context
, ret
, "kadm5_log_init: open %s",
104 log_context
->log_file
);
107 if (flock (fd
, LOCK_EX
) < 0) {
109 krb5_set_error_message(context
->context
, ret
, "kadm5_log_init: flock %s",
110 log_context
->log_file
);
115 ret
= kadm5_log_get_version_fd (fd
, &log_context
->version
);
119 log_context
->log_fd
= fd
;
124 kadm5_log_reinit (kadm5_server_context
*context
)
127 kadm5_log_context
*log_context
= &context
->log_context
;
129 if (log_context
->log_fd
!= -1) {
130 flock (log_context
->log_fd
, LOCK_UN
);
131 close (log_context
->log_fd
);
132 log_context
->log_fd
= -1;
134 fd
= open (log_context
->log_file
, O_RDWR
| O_CREAT
| O_TRUNC
, 0600);
137 if (flock (fd
, LOCK_EX
) < 0) {
142 log_context
->version
= 0;
143 log_context
->log_fd
= fd
;
149 kadm5_log_end (kadm5_server_context
*context
)
151 kadm5_log_context
*log_context
= &context
->log_context
;
152 int fd
= log_context
->log_fd
;
156 log_context
->log_fd
= -1;
161 kadm5_log_preamble (kadm5_server_context
*context
,
165 kadm5_log_context
*log_context
= &context
->log_context
;
166 kadm5_ret_t kadm_ret
;
168 kadm_ret
= kadm5_log_init (context
);
172 krb5_store_int32 (sp
, ++log_context
->version
);
173 krb5_store_int32 (sp
, time(NULL
));
174 krb5_store_int32 (sp
, op
);
179 kadm5_log_postamble (kadm5_log_context
*context
,
182 krb5_store_int32 (sp
, context
->version
);
187 * flush the log record in `sp'.
191 kadm5_log_flush (kadm5_log_context
*log_context
,
198 krb5_storage_to_data(sp
, &data
);
200 ret
= write (log_context
->log_fd
, data
.data
, len
);
201 if (ret
< 0 || (size_t)ret
!= len
) {
202 krb5_data_free(&data
);
205 if (fsync (log_context
->log_fd
) < 0) {
206 krb5_data_free(&data
);
211 * Try to send a signal to any running `ipropd-master'
213 #ifndef NO_UNIX_SOCKETS
214 sendto (log_context
->socket_fd
,
215 (void *)&log_context
->version
,
216 sizeof(log_context
->version
),
218 (struct sockaddr
*)&log_context
->socket_name
,
219 sizeof(log_context
->socket_name
));
221 sendto (log_context
->socket_fd
,
222 (void *)&log_context
->version
,
223 sizeof(log_context
->version
),
225 log_context
->socket_info
->ai_addr
,
226 log_context
->socket_info
->ai_addrlen
);
229 krb5_data_free(&data
);
234 * Add a `create' operation to the log.
238 kadm5_log_create (kadm5_server_context
*context
,
244 kadm5_log_context
*log_context
= &context
->log_context
;
246 sp
= krb5_storage_emem();
247 ret
= hdb_entry2value (context
->context
, ent
, &value
);
249 krb5_storage_free(sp
);
252 ret
= kadm5_log_preamble (context
, sp
, kadm_create
);
254 krb5_data_free (&value
);
255 krb5_storage_free(sp
);
258 krb5_store_int32 (sp
, value
.length
);
259 krb5_storage_write(sp
, value
.data
, value
.length
);
260 krb5_store_int32 (sp
, value
.length
);
261 krb5_data_free (&value
);
262 ret
= kadm5_log_postamble (log_context
, sp
);
264 krb5_storage_free (sp
);
267 ret
= kadm5_log_flush (log_context
, sp
);
268 krb5_storage_free (sp
);
271 ret
= kadm5_log_end (context
);
276 * Read the data of a create log record from `sp' and change the
281 kadm5_log_replay_create (kadm5_server_context
*context
,
290 memset(&ent
, 0, sizeof(ent
));
292 ret
= krb5_data_alloc (&data
, len
);
294 krb5_set_error_message(context
->context
, ret
, "out of memory");
297 krb5_storage_read (sp
, data
.data
, len
);
298 ret
= hdb_value2entry (context
->context
, &data
, &ent
.entry
);
299 krb5_data_free(&data
);
301 krb5_set_error_message(context
->context
, ret
,
302 "Unmarshaling hdb entry failed");
305 ret
= context
->db
->hdb_store(context
->context
, context
->db
, 0, &ent
);
306 hdb_free_entry (context
->context
, &ent
);
311 * Add a `delete' operation to the log.
315 kadm5_log_delete (kadm5_server_context
*context
,
316 krb5_principal princ
)
322 kadm5_log_context
*log_context
= &context
->log_context
;
324 sp
= krb5_storage_emem();
327 ret
= kadm5_log_preamble (context
, sp
, kadm_delete
);
330 ret
= krb5_store_int32 (sp
, 0);
333 off
= krb5_storage_seek (sp
, 0, SEEK_CUR
);
334 ret
= krb5_store_principal (sp
, princ
);
337 len
= krb5_storage_seek (sp
, 0, SEEK_CUR
) - off
;
338 krb5_storage_seek(sp
, -(len
+ 4), SEEK_CUR
);
339 ret
= krb5_store_int32 (sp
, len
);
342 krb5_storage_seek(sp
, len
, SEEK_CUR
);
343 ret
= krb5_store_int32 (sp
, len
);
346 ret
= kadm5_log_postamble (log_context
, sp
);
349 ret
= kadm5_log_flush (log_context
, sp
);
352 ret
= kadm5_log_end (context
);
354 krb5_storage_free (sp
);
359 * Read a `delete' log operation from `sp' and apply it.
363 kadm5_log_replay_delete (kadm5_server_context
*context
,
369 krb5_principal principal
;
371 ret
= krb5_ret_principal (sp
, &principal
);
373 krb5_set_error_message(context
->context
, ret
, "Failed to read deleted "
374 "principal from log version: %ld", (long)ver
);
378 ret
= context
->db
->hdb_remove(context
->context
, context
->db
, principal
);
379 krb5_free_principal (context
->context
, principal
);
384 * Add a `rename' operation to the log.
388 kadm5_log_rename (kadm5_server_context
*context
,
389 krb5_principal source
,
397 kadm5_log_context
*log_context
= &context
->log_context
;
399 krb5_data_zero(&value
);
401 sp
= krb5_storage_emem();
402 ret
= hdb_entry2value (context
->context
, ent
, &value
);
406 ret
= kadm5_log_preamble (context
, sp
, kadm_rename
);
410 ret
= krb5_store_int32 (sp
, 0);
413 off
= krb5_storage_seek (sp
, 0, SEEK_CUR
);
414 ret
= krb5_store_principal (sp
, source
);
418 krb5_storage_write(sp
, value
.data
, value
.length
);
419 len
= krb5_storage_seek (sp
, 0, SEEK_CUR
) - off
;
421 krb5_storage_seek(sp
, -(len
+ 4), SEEK_CUR
);
422 ret
= krb5_store_int32 (sp
, len
);
426 krb5_storage_seek(sp
, len
, SEEK_CUR
);
427 ret
= krb5_store_int32 (sp
, len
);
431 ret
= kadm5_log_postamble (log_context
, sp
);
435 ret
= kadm5_log_flush (log_context
, sp
);
438 krb5_storage_free (sp
);
439 krb5_data_free (&value
);
441 return kadm5_log_end (context
);
444 krb5_data_free(&value
);
445 krb5_storage_free(sp
);
450 * Read a `rename' log operation from `sp' and apply it.
454 kadm5_log_replay_rename (kadm5_server_context
*context
,
460 krb5_principal source
;
461 hdb_entry_ex target_ent
;
464 size_t princ_len
, data_len
;
466 memset(&target_ent
, 0, sizeof(target_ent
));
468 off
= krb5_storage_seek(sp
, 0, SEEK_CUR
);
469 ret
= krb5_ret_principal (sp
, &source
);
471 krb5_set_error_message(context
->context
, ret
, "Failed to read renamed "
472 "principal in log, version: %ld", (long)ver
);
475 princ_len
= krb5_storage_seek(sp
, 0, SEEK_CUR
) - off
;
476 data_len
= len
- princ_len
;
477 ret
= krb5_data_alloc (&value
, data_len
);
479 krb5_free_principal (context
->context
, source
);
482 krb5_storage_read (sp
, value
.data
, data_len
);
483 ret
= hdb_value2entry (context
->context
, &value
, &target_ent
.entry
);
484 krb5_data_free(&value
);
486 krb5_free_principal (context
->context
, source
);
489 ret
= context
->db
->hdb_store (context
->context
, context
->db
,
491 hdb_free_entry (context
->context
, &target_ent
);
493 krb5_free_principal (context
->context
, source
);
496 ret
= context
->db
->hdb_remove (context
->context
, context
->db
, source
);
497 krb5_free_principal (context
->context
, source
);
503 * Add a `modify' operation to the log.
507 kadm5_log_modify (kadm5_server_context
*context
,
515 kadm5_log_context
*log_context
= &context
->log_context
;
517 krb5_data_zero(&value
);
519 sp
= krb5_storage_emem();
520 ret
= hdb_entry2value (context
->context
, ent
, &value
);
524 ret
= kadm5_log_preamble (context
, sp
, kadm_modify
);
528 len
= value
.length
+ 4;
529 ret
= krb5_store_int32 (sp
, len
);
532 ret
= krb5_store_int32 (sp
, mask
);
535 krb5_storage_write (sp
, value
.data
, value
.length
);
537 ret
= krb5_store_int32 (sp
, len
);
540 ret
= kadm5_log_postamble (log_context
, sp
);
543 ret
= kadm5_log_flush (log_context
, sp
);
546 krb5_data_free(&value
);
547 krb5_storage_free (sp
);
548 return kadm5_log_end (context
);
550 krb5_data_free(&value
);
551 krb5_storage_free(sp
);
556 * Read a `modify' log operation from `sp' and apply it.
560 kadm5_log_replay_modify (kadm5_server_context
*context
,
568 hdb_entry_ex ent
, log_ent
;
570 memset(&log_ent
, 0, sizeof(log_ent
));
572 krb5_ret_int32 (sp
, &mask
);
574 ret
= krb5_data_alloc (&value
, len
);
576 krb5_set_error_message(context
->context
, ret
, "out of memory");
579 krb5_storage_read (sp
, value
.data
, len
);
580 ret
= hdb_value2entry (context
->context
, &value
, &log_ent
.entry
);
581 krb5_data_free(&value
);
585 memset(&ent
, 0, sizeof(ent
));
586 ret
= context
->db
->hdb_fetch_kvno(context
->context
, context
->db
,
587 log_ent
.entry
.principal
,
588 HDB_F_DECRYPT
|HDB_F_GET_ANY
|HDB_F_ADMIN_DATA
, 0, &ent
);
591 if (mask
& KADM5_PRINC_EXPIRE_TIME
) {
592 if (log_ent
.entry
.valid_end
== NULL
) {
593 ent
.entry
.valid_end
= NULL
;
595 if (ent
.entry
.valid_end
== NULL
) {
596 ent
.entry
.valid_end
= malloc(sizeof(*ent
.entry
.valid_end
));
597 if (ent
.entry
.valid_end
== NULL
) {
599 krb5_set_error_message(context
->context
, ret
, "out of memory");
603 *ent
.entry
.valid_end
= *log_ent
.entry
.valid_end
;
606 if (mask
& KADM5_PW_EXPIRATION
) {
607 if (log_ent
.entry
.pw_end
== NULL
) {
608 ent
.entry
.pw_end
= NULL
;
610 if (ent
.entry
.pw_end
== NULL
) {
611 ent
.entry
.pw_end
= malloc(sizeof(*ent
.entry
.pw_end
));
612 if (ent
.entry
.pw_end
== NULL
) {
614 krb5_set_error_message(context
->context
, ret
, "out of memory");
618 *ent
.entry
.pw_end
= *log_ent
.entry
.pw_end
;
621 if (mask
& KADM5_LAST_PWD_CHANGE
) {
624 if (mask
& KADM5_ATTRIBUTES
) {
625 ent
.entry
.flags
= log_ent
.entry
.flags
;
627 if (mask
& KADM5_MAX_LIFE
) {
628 if (log_ent
.entry
.max_life
== NULL
) {
629 ent
.entry
.max_life
= NULL
;
631 if (ent
.entry
.max_life
== NULL
) {
632 ent
.entry
.max_life
= malloc (sizeof(*ent
.entry
.max_life
));
633 if (ent
.entry
.max_life
== NULL
) {
635 krb5_set_error_message(context
->context
, ret
, "out of memory");
639 *ent
.entry
.max_life
= *log_ent
.entry
.max_life
;
642 if ((mask
& KADM5_MOD_TIME
) && (mask
& KADM5_MOD_NAME
)) {
643 if (ent
.entry
.modified_by
== NULL
) {
644 ent
.entry
.modified_by
= malloc(sizeof(*ent
.entry
.modified_by
));
645 if (ent
.entry
.modified_by
== NULL
) {
647 krb5_set_error_message(context
->context
, ret
, "out of memory");
651 free_Event(ent
.entry
.modified_by
);
652 ret
= copy_Event(log_ent
.entry
.modified_by
, ent
.entry
.modified_by
);
654 krb5_set_error_message(context
->context
, ret
, "out of memory");
658 if (mask
& KADM5_KVNO
) {
659 ent
.entry
.kvno
= log_ent
.entry
.kvno
;
661 if (mask
& KADM5_MKVNO
) {
664 if (mask
& KADM5_AUX_ATTRIBUTES
) {
667 if (mask
& KADM5_POLICY
) {
670 if (mask
& KADM5_POLICY_CLR
) {
673 if (mask
& KADM5_MAX_RLIFE
) {
674 if (log_ent
.entry
.max_renew
== NULL
) {
675 ent
.entry
.max_renew
= NULL
;
677 if (ent
.entry
.max_renew
== NULL
) {
678 ent
.entry
.max_renew
= malloc (sizeof(*ent
.entry
.max_renew
));
679 if (ent
.entry
.max_renew
== NULL
) {
681 krb5_set_error_message(context
->context
, ret
, "out of memory");
685 *ent
.entry
.max_renew
= *log_ent
.entry
.max_renew
;
688 if (mask
& KADM5_LAST_SUCCESS
) {
691 if (mask
& KADM5_LAST_FAILED
) {
694 if (mask
& KADM5_FAIL_AUTH_COUNT
) {
697 if (mask
& KADM5_KEY_DATA
) {
701 for (i
= 0; i
< ent
.entry
.keys
.len
; ++i
)
702 free_Key(&ent
.entry
.keys
.val
[i
]);
703 free (ent
.entry
.keys
.val
);
705 num
= log_ent
.entry
.keys
.len
;
707 ent
.entry
.keys
.len
= num
;
708 ent
.entry
.keys
.val
= malloc(len
* sizeof(*ent
.entry
.keys
.val
));
709 if (ent
.entry
.keys
.val
== NULL
) {
710 krb5_set_error_message(context
->context
, ENOMEM
, "out of memory");
713 for (i
= 0; i
< ent
.entry
.keys
.len
; ++i
) {
714 ret
= copy_Key(&log_ent
.entry
.keys
.val
[i
],
715 &ent
.entry
.keys
.val
[i
]);
717 krb5_set_error_message(context
->context
, ret
, "out of memory");
722 if ((mask
& KADM5_TL_DATA
) && log_ent
.entry
.extensions
) {
723 HDB_extensions
*es
= ent
.entry
.extensions
;
725 ent
.entry
.extensions
= calloc(1, sizeof(*ent
.entry
.extensions
));
726 if (ent
.entry
.extensions
== NULL
)
729 ret
= copy_HDB_extensions(log_ent
.entry
.extensions
,
730 ent
.entry
.extensions
);
732 krb5_set_error_message(context
->context
, ret
, "out of memory");
733 free(ent
.entry
.extensions
);
734 ent
.entry
.extensions
= es
;
738 free_HDB_extensions(es
);
742 ret
= context
->db
->hdb_store(context
->context
, context
->db
,
743 HDB_F_REPLACE
, &ent
);
745 hdb_free_entry (context
->context
, &ent
);
746 hdb_free_entry (context
->context
, &log_ent
);
751 * Add a `nop' operation to the log. Does not close the log.
755 kadm5_log_nop (kadm5_server_context
*context
)
759 kadm5_log_context
*log_context
= &context
->log_context
;
761 sp
= krb5_storage_emem();
762 ret
= kadm5_log_preamble (context
, sp
, kadm_nop
);
764 krb5_storage_free (sp
);
767 krb5_store_int32 (sp
, 0);
768 krb5_store_int32 (sp
, 0);
769 ret
= kadm5_log_postamble (log_context
, sp
);
771 krb5_storage_free (sp
);
774 ret
= kadm5_log_flush (log_context
, sp
);
775 krb5_storage_free (sp
);
781 * Read a `nop' log operation from `sp' and apply it.
785 kadm5_log_replay_nop (kadm5_server_context
*context
,
794 * Call `func' for each log record in the log in `context'
798 kadm5_log_foreach (kadm5_server_context
*context
,
799 void (*func
)(kadm5_server_context
*server_context
,
808 int fd
= context
->log_context
.log_fd
;
811 lseek (fd
, 0, SEEK_SET
);
812 sp
= krb5_storage_from_fd (fd
);
814 int32_t ver
, timestamp
, op
, len
, len2
, ver2
;
816 if(krb5_ret_int32 (sp
, &ver
) != 0)
818 krb5_ret_int32 (sp
, ×tamp
);
819 krb5_ret_int32 (sp
, &op
);
820 krb5_ret_int32 (sp
, &len
);
821 (*func
)(context
, ver
, timestamp
, op
, len
, sp
, ctx
);
822 krb5_ret_int32 (sp
, &len2
);
823 krb5_ret_int32 (sp
, &ver2
);
829 krb5_storage_free(sp
);
838 kadm5_log_goto_end (int fd
)
842 sp
= krb5_storage_from_fd (fd
);
843 krb5_storage_seek(sp
, 0, SEEK_END
);
848 * Return previous log entry.
850 * The pointer in `sp´ is assumed to be at the top of the entry before
851 * previous entry. On success, the `sp´ pointer is set to data portion
852 * of previous entry. In case of error, it's not changed at all.
856 kadm5_log_previous (krb5_context context
,
867 oldoff
= krb5_storage_seek(sp
, 0, SEEK_CUR
);
869 krb5_storage_seek(sp
, -8, SEEK_CUR
);
870 ret
= krb5_ret_int32 (sp
, &tmp
);
874 ret
= krb5_ret_int32 (sp
, &tmp
);
879 krb5_storage_seek(sp
, -off
, SEEK_CUR
);
880 ret
= krb5_ret_int32 (sp
, &tmp
);
883 if ((uint32_t)tmp
!= *ver
) {
884 krb5_storage_seek(sp
, oldoff
, SEEK_SET
);
885 krb5_set_error_message(context
, KADM5_BAD_DB
,
886 "kadm5_log_previous: log entry "
887 "have consistency failure, version number wrong "
890 (unsigned long)*ver
);
893 ret
= krb5_ret_int32 (sp
, &tmp
);
897 ret
= krb5_ret_int32 (sp
, &tmp
);
901 ret
= krb5_ret_int32 (sp
, &tmp
);
904 if ((uint32_t)tmp
!= *len
) {
905 krb5_storage_seek(sp
, oldoff
, SEEK_SET
);
906 krb5_set_error_message(context
, KADM5_BAD_DB
,
907 "kadm5_log_previous: log entry "
908 "have consistency failure, length wrong");
914 krb5_storage_seek(sp
, oldoff
, SEEK_SET
);
915 krb5_set_error_message(context
, ret
, "kadm5_log_previous: end of storage "
916 "reached before end");
921 * Replay a record from the log
925 kadm5_log_replay (kadm5_server_context
*context
,
933 return kadm5_log_replay_create (context
, ver
, len
, sp
);
935 return kadm5_log_replay_delete (context
, ver
, len
, sp
);
937 return kadm5_log_replay_rename (context
, ver
, len
, sp
);
939 return kadm5_log_replay_modify (context
, ver
, len
, sp
);
941 return kadm5_log_replay_nop (context
, ver
, len
, sp
);
943 krb5_set_error_message(context
->context
, KADM5_FAILURE
,
944 "Unsupported replay op %d", (int)op
);
945 return KADM5_FAILURE
;
950 * truncate the log - i.e. create an empty file with just (nop vno + 2)
954 kadm5_log_truncate (kadm5_server_context
*server_context
)
959 ret
= kadm5_log_init (server_context
);
963 ret
= kadm5_log_get_version (server_context
, &vno
);
967 ret
= kadm5_log_reinit (server_context
);
971 ret
= kadm5_log_set_version (server_context
, vno
);
975 ret
= kadm5_log_nop (server_context
);
979 ret
= kadm5_log_end (server_context
);
986 #ifndef NO_UNIX_SOCKETS
988 static char *default_signal
= NULL
;
989 static HEIMDAL_MUTEX signal_mutex
= HEIMDAL_MUTEX_INITIALIZER
;
992 kadm5_log_signal_socket(krb5_context context
)
994 HEIMDAL_MUTEX_lock(&signal_mutex
);
996 asprintf(&default_signal
, "%s/signal", hdb_db_dir(context
));
997 HEIMDAL_MUTEX_unlock(&signal_mutex
);
999 return krb5_config_get_string_default(context
,
1007 #else /* NO_UNIX_SOCKETS */
1009 #define SIGNAL_SOCKET_HOST "127.0.0.1"
1010 #define SIGNAL_SOCKET_PORT "12701"
1013 kadm5_log_signal_socket_info(krb5_context context
,
1015 struct addrinfo
**ret_addrs
)
1017 struct addrinfo hints
;
1018 struct addrinfo
*addrs
= NULL
;
1019 kadm5_ret_t ret
= KADM5_FAILURE
;
1022 memset(&hints
, 0, sizeof(hints
));
1024 hints
.ai_flags
= AI_NUMERICHOST
;
1026 hints
.ai_flags
|= AI_PASSIVE
;
1027 hints
.ai_family
= AF_INET
;
1028 hints
.ai_socktype
= SOCK_STREAM
;
1029 hints
.ai_protocol
= IPPROTO_TCP
;
1031 wsret
= getaddrinfo(SIGNAL_SOCKET_HOST
,
1036 krb5_set_error_message(context
, KADM5_FAILURE
,
1037 "%s", gai_strerror(wsret
));
1041 if (addrs
== NULL
) {
1042 krb5_set_error_message(context
, KADM5_FAILURE
,
1043 "getaddrinfo() failed to return address list");
1053 freeaddrinfo(addrs
);