4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
24 * Copyright 2010 Sun Microsystems, Inc. All rights reserved.
25 * Use is subject to license terms.
27 * This file does not provide any user callable functions. See adt.c
31 #include <bsm/adt_event.h>
32 #include <bsm/audit.h>
34 #include <adt_xlate.h>
45 #include <sys/priv_names.h>
46 #include <sys/socket.h>
47 #include <sys/types.h>
48 #include <sys/vnode.h>
50 #include <tsol/label.h>
53 #define DPRINTF(x) { (void) printf x; }
54 #define DFLUSH (void) fflush(stdout);
56 /* 0x + Classification + Compartments + end of string */
57 #define HEX_SIZE 2 + 2*2 + 2*32 + 1
60 dprt_label(m_label_t
*label
)
62 static char hex
[HEX_SIZE
];
65 if (label_to_str(label
, &direct
, M_INTERNAL
, DEF_NAMES
) != 0) {
66 adt_write_syslog("label_to_str(M_INTERNAL)", errno
);
67 return ("hex label failed");
69 (void) strlcpy(hex
, direct
, sizeof (hex
));
78 static adt_token_func_t
adt_getTokenFunction(char);
80 static char *empty
= "";
83 * call adt_token_open() first and adt_token_close() last.
85 * au_open is sort of broken; it returns a -1 when out of memory that
86 * you're supposed to ignore; au_write and au_close return without
87 * doing anything when a -1 is passed. This code sort of follows the
88 * au_open model except that it calls syslog to indicate underlying
89 * brokenness. Other than that, -1 is ignored.
93 adt_token_open(struct adt_event_state
*event
)
95 static int have_syslogged
= 0;
97 event
->ae_event_handle
= au_open();
98 if (event
->ae_event_handle
< 0) {
99 if (!have_syslogged
) {
100 adt_write_syslog("au_open failed", ENOMEM
);
109 * call generate_token for each token in the order you want the tokens
114 adt_generate_token(struct entry
*p_entry
, void *p_data
,
115 struct adt_event_state
*event
)
117 adt_token_func_t p_func
;
119 assert((p_entry
!= NULL
) && (p_data
!= NULL
) && (event
!= NULL
));
121 p_func
= adt_getTokenFunction(p_entry
->en_token_id
);
122 assert(p_func
!= NULL
);
124 DPRINTF(("p_entry=%p, p_data=%p, offset=%llu, msgFmt=%s\n",
125 (void *)p_entry
, p_data
, (long long)p_entry
->en_offset
,
126 p_entry
->en_msg_format
));
129 (*p_func
)(p_entry
->en_type_def
,
130 (char *)p_data
+ p_entry
->en_offset
, p_entry
->en_required
, event
,
131 p_entry
->en_msg_format
);
137 adt_token_close(struct adt_event_state
*event
)
141 rc
= au_close(event
->ae_event_handle
, AU_TO_WRITE
,
142 event
->ae_internal_id
);
144 adt_write_syslog("au_close failed", errno
);
149 * one function per token -- see the jump table at the end of file
154 adt_to_return(datadef
*def
, void *p_data
, int required
,
155 struct adt_event_state
*event
, char *notUsed
)
159 (void) au_write(event
->ae_event_handle
,
160 au_to_return64((int64_t)event
->ae_rc
, event
->ae_type
));
162 (void) au_write(event
->ae_event_handle
,
163 au_to_return32((int32_t)event
->ae_rc
, event
->ae_type
));
170 * the command line is described with argc and argv and the environment
171 * with envp. The envp list is NULL terminated and has no separate
172 * counter; envp will be a NULL list unless the AUDIT_ARGE policy is
178 adt_to_cmd(datadef
*def
, void *p_data
, int required
,
179 struct adt_event_state
*event
, char *notUsed
)
181 struct adt_internal_state
*sp
= event
->ae_session
;
186 argc
= ((union convert
*)p_data
)->tint
;
187 p_data
= adt_adjust_address(p_data
, sizeof (int), sizeof (char **));
188 argv
= ((union convert
*)p_data
)->tchar2star
;
189 p_data
= adt_adjust_address(p_data
, sizeof (char **), sizeof (char **));
191 if (sp
->as_kernel_audit_policy
& AUDIT_ARGE
)
192 envp
= ((union convert
*)p_data
)->tchar2star
;
194 (void) au_write(event
->ae_event_handle
,
195 au_to_cmd(argc
, argv
, envp
));
199 * special case of AUT_CMD with 1 argument that is
200 * a string showing the whole command and no envp
204 adt_to_cmd1(datadef
*def
, void *p_data
, int required
,
205 struct adt_event_state
*event
, char *notUsed
)
209 string
= ((union convert
*)p_data
)->tcharstar
;
211 if (string
== NULL
) {
218 /* argc is hardcoded as 1 */
219 (void) au_write(event
->ae_event_handle
, au_to_cmd(1, &string
,
224 * adt_to_tid -- generic address (ip is only one defined at present)
226 * terminal type: ADT_IPv4, ADT_IPv6...
227 * case: ADT_IPv4 or ADT_IPv6...
232 * case: not defined...
236 adt_to_tid(datadef
*def
, void *p_data
, int required
,
237 struct adt_event_state
*event
, char *notUsed
)
239 au_generic_tid_t tid
;
243 type
= ((union convert
*)p_data
)->tuint32
;
248 p_data
= adt_adjust_address(p_data
, sizeof (uint32_t),
251 tid
.gt_type
= AU_IPADR
;
252 ip
= &(tid
.gt_adr
.at_ip
);
254 ip
->at_type
= (type
== ADT_IPv4
) ?
257 ip
->at_r_port
= ((union convert
*)p_data
)->tuint16
;
258 p_data
= adt_adjust_address(p_data
, sizeof (uint16_t),
261 ip
->at_l_port
= ((union convert
*)p_data
)->tuint16
;
263 /* arg3 is for the array element, not the array size */
264 p_data
= adt_adjust_address(p_data
, sizeof (uint16_t),
267 (void) memcpy(ip
->at_addr
, p_data
, ip
->at_type
);
270 adt_write_syslog("Invalid terminal id type", EINVAL
);
273 (void) au_write(event
->ae_event_handle
, au_to_tid(&tid
));
277 * au_to_frmi takes a char * that is the fmri.
281 adt_to_frmi(datadef
*def
, void *p_data
, int required
,
282 struct adt_event_state
*event
, char *notUsed
)
286 DPRINTF((" adt_to_fmri dd_datatype=%d\n", def
->dd_datatype
));
288 fmri
= ((union convert
*)p_data
)->tcharstar
;
297 DPRINTF((" fmri=%s\n", fmri
));
298 (void) au_write(event
->ae_event_handle
, au_to_fmri(fmri
));
302 * au_to_label takes an m_label_t * that is the label.
306 adt_to_label(datadef
*def
, void *p_data
, int required
,
307 struct adt_event_state
*event
, char *notUsed
)
311 DPRINTF((" adt_to_label dd_datatype=%d\n", def
->dd_datatype
));
313 label
= ((union convert
*)p_data
)->tm_label
;
316 DPRINTF((" label=%s\n", dprt_label(label
)));
318 (void) au_write(event
->ae_event_handle
, au_to_label(label
));
320 DPRINTF((" Null label\n"));
322 adt_write_syslog("adt_to_label no required label", 0);
327 * au_to_newgroups takes a length and an array of gids
328 * as input. The input to adt_to_newgroups is a length
329 * and a pointer to an array of gids.
334 adt_to_newgroups(datadef
*def
, void *p_data
, int required
,
335 struct adt_event_state
*event
, char *notUsed
)
340 n
= ((union convert
*)p_data
)->tint
;
343 n
= 0; /* in case negative n was passed */
348 p_data
= adt_adjust_address(p_data
, sizeof (int), sizeof (int32_t *));
350 groups
= ((union convert
*)p_data
)->tgidstar
;
352 (void) au_write(event
->ae_event_handle
, au_to_newgroups(n
, groups
));
357 adt_to_path(datadef
*def
, void *p_data
, int required
,
358 struct adt_event_state
*event
, char *notUsed
)
362 path
= ((union convert
*)p_data
)->tcharstar
;
365 DPRINTF((" path=%s\n", path
));
366 (void) au_write(event
->ae_event_handle
, au_to_path(path
));
368 DPRINTF((" Null path\n"));
370 (void) au_write(event
->ae_event_handle
,
377 * dummy token id: AUT_PATHLIST
382 adt_to_pathlist(datadef
*def
, void *p_data
, int required
,
383 struct adt_event_state
*event
, char *notUsed
)
390 pathlist
= ((union convert
*)p_data
)->tcharstar
;
392 if (pathlist
!= NULL
) {
393 working_buf
= strdup(pathlist
);
394 if (working_buf
== NULL
) {
395 adt_write_syslog("audit failure", errno
);
397 (void) au_write(event
->ae_event_handle
,
402 for (path
= strtok_r(working_buf
, " ", &last_str
);
403 path
; path
= strtok_r(NULL
, " ", &last_str
)) {
404 DPRINTF((" path=%s\n", path
));
405 (void) au_write(event
->ae_event_handle
,
409 DPRINTF((" Null path list\n"));
411 (void) au_write(event
->ae_event_handle
,
422 adt_to_priv(datadef
*def
, void *p_data
, int required
,
423 struct adt_event_state
*event
, const char *priv_type
)
425 priv_set_t
*privilege
;
427 privilege
= ((union convert
*)p_data
)->tprivstar
;
429 if (privilege
!= NULL
) {
430 (void) au_write(event
->ae_event_handle
,
431 au_to_privset(priv_type
, privilege
));
434 DPRINTF((" Null privilege\n"));
435 (void) au_write(event
->ae_event_handle
,
436 au_to_privset(empty
, NULL
));
442 * -AUT_PRIV_L AUT_PRIV for a limit set
447 adt_to_priv_limit(datadef
*def
, void *p_data
, int required
,
448 struct adt_event_state
*event
, char *notUsed
)
450 adt_to_priv(def
, p_data
, required
, event
, PRIV_LIMIT
);
454 * -AUT_PRIV_I AUT_PRIV for an inherit set
459 adt_to_priv_inherit(datadef
*def
, void *p_data
, int required
,
460 struct adt_event_state
*event
, char *notUsed
)
462 adt_to_priv(def
, p_data
, required
, event
, PRIV_INHERITABLE
);
467 adt_to_priv_effective(datadef
*def
, void *p_data
, int required
,
468 struct adt_event_state
*event
, char *notUsed
)
470 adt_to_priv(def
, p_data
, required
, event
, PRIV_EFFECTIVE
);
474 getCharacteristics(struct auditpinfo_addr
*info
, pid_t
*pid
)
478 if (*pid
== 0) { /* getpinfo for this pid */
479 info
->ap_pid
= getpid();
484 rc
= auditon(A_GETPINFO_ADDR
, (caddr_t
)info
,
485 sizeof (struct auditpinfo_addr
));
487 info
->ap_auid
= AU_NOAUDITID
;
489 (void) memset((void *)&(info
->ap_termid
), 0,
490 sizeof (au_tid_addr_t
));
491 info
->ap_termid
.at_type
= AU_IPv4
;
502 adt_to_process(datadef
*def
, void *p_data
, int required
,
503 struct adt_event_state
*event
, char *notUsed
)
513 struct auditpinfo_addr info
;
515 auid
= ((union convert
*)p_data
)->tuid
;
516 p_data
= adt_adjust_address(p_data
, sizeof (uid_t
), sizeof (uid_t
));
517 euid
= ((union convert
*)p_data
)->tuid
;
518 p_data
= adt_adjust_address(p_data
, sizeof (uid_t
), sizeof (gid_t
));
519 egid
= ((union convert
*)p_data
)->tgid
;
520 p_data
= adt_adjust_address(p_data
, sizeof (gid_t
), sizeof (uid_t
));
521 ruid
= ((union convert
*)p_data
)->tuid
;
522 p_data
= adt_adjust_address(p_data
, sizeof (uid_t
), sizeof (gid_t
));
523 rgid
= ((union convert
*)p_data
)->tgid
;
524 p_data
= adt_adjust_address(p_data
, sizeof (gid_t
), sizeof (pid_t
));
525 pid
= ((union convert
*)p_data
)->tpid
;
526 p_data
= adt_adjust_address(p_data
, sizeof (pid_t
), sizeof (uint32_t));
527 sid
= ((union convert
*)p_data
)->tuint32
;
528 p_data
= adt_adjust_address(p_data
, sizeof (uint32_t),
529 sizeof (au_tid_addr_t
*));
530 tid
= ((union convert
*)p_data
)->ttermid
;
532 getCharacteristics(&info
, &pid
);
534 if (auid
== AU_NOAUDITID
)
537 if (euid
== AU_NOAUDITID
)
540 if (egid
== AU_NOAUDITID
)
543 if (ruid
== AU_NOAUDITID
)
546 if (rgid
== AU_NOAUDITID
)
550 tid
= &(info
.ap_termid
);
558 (void) au_write(event
->ae_event_handle
,
559 au_to_process_ex(auid
, euid
, egid
, ruid
, rgid
, pid
, sid
, tid
));
563 * Generate subject information.
564 * If labels are present, generate the subject label token.
565 * If the group audit policy is set, generate the subject group token.
567 * The required flag does not apply here.
569 * Non-attributable records are indicated by an auid of AU_NOAUDITID;
570 * no subject token or group token is generated for a non-attributable
576 adt_to_subject(datadef
*def
, void *p_data
, int required
,
577 struct adt_event_state
*event
, char *notUsed
)
579 struct adt_internal_state
*sp
= event
->ae_session
;
581 if (sp
->as_info
.ai_auid
== AU_NOAUDITID
)
584 assert(sp
->as_have_user_data
== ADT_HAVE_ALL
);
586 (void) au_write(event
->ae_event_handle
,
587 au_to_subject_ex(sp
->as_info
.ai_auid
,
588 sp
->as_euid
, sp
->as_egid
, sp
->as_ruid
, sp
->as_rgid
,
589 sp
->as_pid
, sp
->as_info
.ai_asid
,
590 &(sp
->as_info
.ai_termid
)));
591 if (is_system_labeled()) {
592 (void) au_write(event
->ae_event_handle
,
593 au_to_label(sp
->as_label
));
596 * Add optional tokens if in the process model.
597 * In a session model, the groups list is undefined and label
600 if (sp
->as_session_model
== ADT_PROCESS_MODEL
) {
601 if (sp
->as_kernel_audit_policy
& AUDIT_GROUP
) {
603 int maxgrp
= getgroups(0, NULL
);
604 gid_t
*grouplist
= alloca(maxgrp
* sizeof (gid_t
));
606 if ((group_count
= getgroups(maxgrp
, grouplist
)) > 0) {
607 (void) au_write(event
->ae_event_handle
,
608 au_to_newgroups(group_count
, grouplist
));
617 * The format string, normally null, is sort of a wrapper around
618 * the input. adt_write_text() is a wrapper around au_write that
619 * handles the format string
622 #define TEXT_LENGTH 49
625 adt_write_text(int handle
, char *main_text
, const char *format
)
627 char buffer
[TEXT_LENGTH
* 2 + 1];
629 if (format
== NULL
) {
630 (void) au_write(handle
, au_to_text(main_text
));
632 (void) snprintf(buffer
, TEXT_LENGTH
* 2, format
, main_text
);
633 (void) au_write(handle
, au_to_text(buffer
));
638 adt_to_text(datadef
*def
, void *p_data
, int required
,
639 struct adt_event_state
*event
, char *format
)
641 static int have_syslogged
= 0;
644 char buffer
[TEXT_LENGTH
+ 1];
648 int written
, available
;
650 struct msg_text
*list
;
653 DPRINTF((" adt_to_text dd_datatype=%d\n", def
->dd_datatype
));
654 switch (def
->dd_datatype
) {
657 * Consider creating a separate token type for dates
658 * -- store as longs and format them in praudit.
659 * For now, a date is input as a time_t and output as
660 * a text token. If we do this, we need to consider
661 * carrying timezone info so that praudit can
662 * represent times in an unambiguous manner.
664 date
= ((union convert
*)p_data
)->tlong
;
665 if (strftime(buffer
, sizeof (buffer
), "%x",
666 localtime_r(&date
, &tm
)) > TEXT_LENGTH
) {
668 (void) strncpy(buffer
, "invalid date",
674 DPRINTF((" text=%s\n", buffer
));
675 adt_write_text(event
->ae_event_handle
, buffer
, format
);
678 * The "input size" is overloaded to mean the list number
679 * and the msg_selector indexes the desired string in
683 list
= &adt_msg_text
[(enum adt_msg_list
)def
->dd_input_size
];
684 list_index
= ((union convert
*)p_data
)->msg_selector
;
686 if ((list_index
+ list
->ml_offset
< list
->ml_min_index
) ||
687 (list_index
+ list
->ml_offset
> list
->ml_max_index
)) {
688 string
= "Invalid message index";
690 string
= list
->ml_msg_list
[list_index
+
694 if (string
== NULL
) { /* null is valid; means skip */
701 DPRINTF((" text=%s\n", string
));
702 adt_write_text(event
->ae_event_handle
, string
, format
);
708 (void) snprintf(buffer
, TEXT_LENGTH
, "%u",
709 ((union convert
*)p_data
)->tuint
);
711 DPRINTF((" text=%s\n", buffer
));
712 adt_write_text(event
->ae_event_handle
, buffer
, format
);
716 (void) snprintf(buffer
, TEXT_LENGTH
, "%d",
717 ((union convert
*)p_data
)->tint
);
719 DPRINTF((" text=%s\n", buffer
));
720 adt_write_text(event
->ae_event_handle
, buffer
, format
);
723 (void) snprintf(buffer
, TEXT_LENGTH
, "%ld",
724 ((union convert
*)p_data
)->tlong
);
726 DPRINTF((" text=%s\n", buffer
));
727 adt_write_text(event
->ae_event_handle
, buffer
, format
);
732 int_list
= ((union convert
*)p_data
)->tuint32star
;
733 p_data
= adt_adjust_address(p_data
, sizeof (int *),
735 arrayCount
= ((union convert
*)p_data
)->tint
;
738 available
= TEXT_LENGTH
; /* space available in buffer */
743 if ((arrayCount
> 0) && (int_list
!= NULL
)) {
744 for (; arrayCount
> 0; arrayCount
--) {
745 written
= snprintf(string
, available
,
750 available
-= written
;
752 } else if (required
) {
758 adt_write_text(event
->ae_event_handle
, buffer
, format
);
761 (void) snprintf(buffer
, TEXT_LENGTH
, "%lu",
762 ((union convert
*)p_data
)->tulong
);
764 DPRINTF((" text=%s\n", buffer
));
765 adt_write_text(event
->ae_event_handle
, buffer
, format
);
768 (void) snprintf(buffer
, TEXT_LENGTH
, "%llu",
769 ((union convert
*)p_data
)->tuint64
);
771 DPRINTF((" text=%s\n", buffer
));
772 adt_write_text(event
->ae_event_handle
, buffer
, format
);
775 string
= ((union convert
*)p_data
)->tcharstar
;
777 if (string
== NULL
) {
784 DPRINTF((" text=%s\n", string
));
785 adt_write_text(event
->ae_event_handle
, string
, format
);
788 string_list
= ((union convert
*)p_data
)->tchar2star
;
789 p_data
= adt_adjust_address(p_data
, sizeof (char **),
791 arrayCount
= ((union convert
*)p_data
)->tint
;
796 if ((arrayCount
> 0) && (string_list
!= NULL
)) {
797 for (i
= 0; i
< arrayCount
; i
++) {
798 string
= string_list
[i
];
800 adt_write_text(event
->ae_event_handle
,
803 } else if (required
) {
804 adt_write_text(event
->ae_event_handle
, empty
, format
);
810 if (!have_syslogged
) { /* don't flood the log */
811 adt_write_syslog("unsupported data conversion",
826 adt_to_uauth(datadef
*def
, void *p_data
, int required
,
827 struct adt_event_state
*event
, char *format
)
831 DPRINTF((" adt_to_uauth dd_datatype=%d\n", def
->dd_datatype
));
833 string
= ((union convert
*)p_data
)->tcharstar
;
835 if (string
== NULL
) {
842 DPRINTF((" text=%s\n", string
));
843 (void) au_write(event
->ae_event_handle
, au_to_uauth(string
));
852 adt_to_user(datadef
*def
, void *p_data
, int required
,
853 struct adt_event_state
*event
, char *format
)
858 DPRINTF((" adt_to_user dd_datatype=%d\n", def
->dd_datatype
));
860 uid
= ((union convert
*)p_data
)->tuid
;
861 p_data
= adt_adjust_address(p_data
, sizeof (uid_t
), sizeof (uid_t
));
863 username
= ((union convert
*)p_data
)->tcharstar
;
865 if (username
== NULL
) {
872 DPRINTF((" username=%s\n", username
));
873 (void) au_write(event
->ae_event_handle
, au_to_user(uid
, username
));
882 adt_to_zonename(datadef
*def
, void *p_data
, int required
,
883 struct adt_event_state
*event
, char *notUsed
)
887 name
= ((union convert
*)p_data
)->tcharstar
;
890 DPRINTF((" name=%s\n", name
));
891 (void) au_write(event
->ae_event_handle
, au_to_zonename(name
));
893 DPRINTF((" Null name\n"));
895 (void) au_write(event
->ae_event_handle
,
896 au_to_zonename(empty
));
902 * ADT_IN_PEER dummy token
907 adt_to_in_peer(datadef
*def
, void *p_data
, int required
,
908 struct adt_event_state
*event
, char *notUsed
)
911 struct sockaddr_in6 peer
;
912 int peerlen
= sizeof (peer
);
914 DPRINTF((" adt_to_in_peer dd_datatype=%d\n", def
->dd_datatype
));
916 sock
= ((union convert
*)p_data
)->tfd
;
919 DPRINTF((" Socket fd %d\n", sock
));
921 adt_write_syslog("adt_to_in_peer no required socket",
926 if (getpeername(sock
, (struct sockaddr
*)&peer
, (socklen_t
*)&peerlen
)
929 adt_write_syslog("adt_to_in_addr getpeername", errno
);
932 if (peer
.sin6_family
== AF_INET6
) {
933 (void) au_write(event
->ae_event_handle
,
934 au_to_in_addr_ex(&(peer
.sin6_addr
)));
935 (void) au_write(event
->ae_event_handle
,
936 au_to_iport((ushort_t
)peer
.sin6_port
));
938 (void) au_write(event
->ae_event_handle
,
939 au_to_in_addr(&(((struct sockaddr_in
*)&peer
)->sin_addr
)));
940 (void) au_write(event
->ae_event_handle
,
942 (ushort_t
)(((struct sockaddr_in
*)&peer
)->sin_port
)));
947 * ADT_IN_REMOTE dummy token
949 * Similar to ADT_IN_PEER except the input is
950 * an IP address type (ADT_IPv4 | ADT_IPv6) and an address V4/V6
955 adt_to_in_remote(datadef
*def
, void *p_data
, int required
,
956 struct adt_event_state
*event
, char *notUsed
)
960 DPRINTF((" adt_to_in_remote dd_datatype=%d\n", def
->dd_datatype
));
962 type
= ((union convert
*)p_data
)->tuint32
;
968 /* required and not specified */
969 adt_write_syslog("adt_to_in_remote required address not "
973 p_data
= adt_adjust_address(p_data
, sizeof (int32_t),
978 (void) au_write(event
->ae_event_handle
, au_to_in_addr(
979 (struct in_addr
*)&(((union convert
*)p_data
)->tuint32
)));
982 (void) au_write(event
->ae_event_handle
, au_to_in_addr_ex(
983 (struct in6_addr
*)&(((union convert
*)p_data
)->tuint32
)));
986 adt_write_syslog("adt_to_in_remote invalid type", EINVAL
);
992 * adt_to_iport takes a uint16_t IP port.
997 adt_to_iport(datadef
*def
, void *p_data
, int required
,
998 struct adt_event_state
*event
, char *notUsed
)
1002 DPRINTF((" adt_to_iport dd_datatype=%d\n", def
->dd_datatype
));
1004 port
= ((union convert
*)p_data
)->tuint16
;
1007 if (required
== 0) {
1010 /* required and not specified */
1011 adt_write_syslog("adt_to_iport no required port", 0);
1013 (void) au_write(event
->ae_event_handle
, au_to_iport(port
));
1019 * This is a compact table that defines only the tokens that are
1020 * actually generated in the adt.xml file. It can't be a pure
1021 * indexed table because the adt.xml language defines internal extension
1022 * tokens for some processing. VIZ. ADT_CMD_ALT, ADT_AUT_PRIV_* (see
1023 * adt_xlate.h), and the -AUT_PATH value.
1026 #define MAX_TOKEN_JMP 21
1028 static struct token_jmp token_table
[MAX_TOKEN_JMP
] =
1030 {AUT_CMD
, adt_to_cmd
},
1031 {ADT_CMD_ALT
, adt_to_cmd1
},
1032 {AUT_FMRI
, adt_to_frmi
},
1033 {ADT_IN_PEER
, adt_to_in_peer
},
1034 {ADT_IN_REMOTE
, adt_to_in_remote
},
1035 {AUT_IPORT
, adt_to_iport
},
1036 {AUT_LABEL
, adt_to_label
},
1037 {AUT_NEWGROUPS
, adt_to_newgroups
},
1038 {AUT_PATH
, adt_to_path
},
1039 {-AUT_PATH
, adt_to_pathlist
}, /* private extension of token values */
1040 {ADT_AUT_PRIV_L
, adt_to_priv_limit
},
1041 {ADT_AUT_PRIV_I
, adt_to_priv_inherit
},
1042 {ADT_AUT_PRIV_E
, adt_to_priv_effective
},
1043 {AUT_PROCESS
, adt_to_process
},
1044 {AUT_RETURN
, adt_to_return
},
1045 {AUT_SUBJECT
, adt_to_subject
},
1046 {AUT_TEXT
, adt_to_text
},
1047 {AUT_TID
, adt_to_tid
},
1048 {AUT_UAUTH
, adt_to_uauth
},
1049 {AUT_USER
, adt_to_user
},
1050 {AUT_ZONENAME
, adt_to_zonename
}
1054 * {AUT_ACL, adt_to_acl}, not used
1055 * {AUT_ARBITRARY, adt_to_arbitrary}, AUT_ARBITRARY is undefined
1056 * {AUT_ARG, adt_to_arg}, not used
1057 * {AUT_ATTR, adt_to_attr}, not used in mountd
1058 * {AUT_XATOM, adt_to_atom}, not used
1059 * {AUT_EXEC_ARGS, adt_to_exec_args}, not used
1060 * {AUT_EXEC_ENV, adt_to_exec_env}, not used
1061 * {AUT_EXIT, adt_to_exit}, obsolete
1062 * {AUT_FILE, adt_to_file}, AUT_FILE is undefined
1063 * {AUT_XCOLORMAP, adt_to_colormap}, not used
1064 * {AUT_XCURSOR, adt_to_cursor}, not used
1065 * {AUT_XFONT, adt_to_font}, not used
1066 * {AUT_XGC, adt_to_gc}, not used
1067 * {AUT_GROUPS, adt_to_groups}, obsolete
1068 * {AUT_HEADER, adt_to_header}, generated by au_close
1069 * {AUT_IP, adt_to_ip}, not used
1070 * {AUT_IPC, adt_to_ipc}, not used
1071 * {AUT_IPC_PERM, adt_to_ipc_perm}, not used
1072 * {AUT_OPAQUE, adt_to_opaque}, not used
1073 * {AUT_XPIXMAP, adt_to_pixmap}, not used
1074 * {AUT_XPROPERTY, adt_to_property}, not used
1075 * {AUT_SEQ, adt_to_seq}, not used
1076 * {AUT_SOCKET, adt_to_socket}, not used
1077 * {AUT_SOCKET_INET, adt_to_socket_inet}, AUT_SOCKET_INET is undefined
1078 * {AUT_TRAILER, adt_to_trailer}, generated by au_close
1079 * {AUT_XCLIENT, adt_to_xclient} not used
1082 /* find function to generate token */
1084 static adt_token_func_t
1085 adt_getTokenFunction(char token_id
)
1088 struct token_jmp
*p_jmp
= token_table
;
1090 for (i
= 0; i
< MAX_TOKEN_JMP
; i
++) {
1091 if (token_id
== p_jmp
->jmp_id
) {
1092 return (p_jmp
->jmp_to
);
1101 * adjustAddress -- given the address of data, its size, and the type of
1102 * the next data field, calculate the offset to the next piece of data.
1103 * Depending on the caller, "current" and "next" mean the current pointer
1104 * and the next pointer or the last pointer and the current pointer.
1107 adt_adjust_address(void *current_address
, size_t current_size
,
1110 ptrdiff_t adjustment
;
1111 ptrdiff_t remainder
;
1113 adjustment
= (size_t)current_address
+ current_size
;
1116 remainder
= adjustment
% next_size
;
1118 adjustment
+= next_size
- remainder
;
1120 return ((char *)adjustment
);