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]
23 * Copyright 2007 Sun Microsystems, Inc. All rights reserved.
24 * Use is subject to license terms.
27 /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
28 /* All Rights Reserved */
31 #pragma ident "%Z%%M% %I% %E% SMI"
32 /* EMACS_MODES: !fill, lnumb, !overwrite, !nodelete, !picture */
35 #include "sys/param.h"
40 #include <tsol/label.h>
43 ** getsecure() - EXTRACT SECURE REQUEST STRUCTURE FROM DISK FILE
62 path
= makepath(Lp_Requests
, file
, (char *)0);
66 if ((fd
= open_locked(path
, "r", MODE_NOREAD
)) < 0) {
72 secp
= calloc(sizeof (*secp
), 1);
78 fld
< SC_MAX
&& fdgets(buf
, BUFSIZ
, fd
);
81 buf
[strlen(buf
) - 1] = 0;
85 secp
->req_id
= Strdup(buf
);
89 secp
->uid
= (uid_t
)atol(buf
);
93 secp
->user
= Strdup(buf
);
97 secp
->gid
= (gid_t
)atol(buf
);
101 secp
->size
= (size_t)atol(buf
);
105 secp
->date
= (time_t)atol(buf
);
109 secp
->slabel
= Strdup(buf
);
113 if (errno
!= 0 || fld
!= SC_MAX
) {
114 int save_errno
= errno
;
124 * Now go through the structure and see if we have
130 || secp
->gid
> MAXUID
143 ** putsecure() - WRITE SECURE REQUEST STRUCTURE TO DISK FILE
147 putsecure(char *file
, SECURE
*secbufp
)
158 path
= makepath(Lp_Requests
, file
, (char *)0);
162 if ((fd
= open_locked(path
, "w", MODE_NOREAD
)) < 0) {
174 for (fld
= 0; fld
< SC_MAX
; fld
++)
179 (void)fdprintf(fd
, "%s\n", secbufp
->req_id
);
183 (void)fdprintf(fd
, "%u\n", secbufp
->uid
);
187 (void)fdprintf(fd
, "%s\n", secbufp
->user
);
191 (void)fdprintf(fd
, "%u\n", secbufp
->gid
);
195 (void)fdprintf(fd
, "%lu\n", secbufp
->size
);
199 (void)fdprintf(fd
, "%ld\n", secbufp
->date
);
203 if (secbufp
->slabel
== NULL
) {
204 if (is_system_labeled()) {
207 sl
= m_label_alloc(MAC_LABEL
);
208 (void) getplabel(sl
);
209 if (label_to_str(sl
, &(secbufp
->slabel
),
210 M_INTERNAL
, DEF_NAMES
) != 0) {
211 perror("label_to_str");
216 (void) fdprintf(fd
, "%s\n",
219 (void) fdprintf(fd
, "none\n");
222 (void) fdprintf(fd
, "%s\n", secbufp
->slabel
);
234 ** o 'reqfilep' is of the form 'node-name/request-file'
235 ** e.g. 'sfcalv/123-0'.
238 rmsecure (char *reqfilep
)
243 pathp
= makepath (Lp_Requests
, reqfilep
, (char *) 0);
254 ** freesecure() - FREE A SECURE STRUCTURE
258 freesecure(SECURE
*secbufp
)
263 Free (secbufp
->req_id
);
265 Free (secbufp
->user
);