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"
42 ** getsecure() - EXTRACT SECURE REQUEST STRUCTURE FROM DISK FILE
61 path
= makepath(Lp_Requests
, file
, (char *)0);
65 if ((fd
= open_locked(path
, "r", MODE_NOREAD
)) < 0) {
71 secp
= calloc(sizeof (*secp
), 1);
77 fld
< SC_MAX
&& fdgets(buf
, BUFSIZ
, fd
);
80 buf
[strlen(buf
) - 1] = 0;
84 secp
->req_id
= Strdup(buf
);
88 secp
->uid
= (uid_t
)atol(buf
);
92 secp
->user
= Strdup(buf
);
96 secp
->gid
= (gid_t
)atol(buf
);
100 secp
->size
= (size_t)atol(buf
);
104 secp
->date
= (time_t)atol(buf
);
109 if (errno
!= 0 || fld
!= SC_MAX
) {
110 int save_errno
= errno
;
120 * Now go through the structure and see if we have
126 || secp
->gid
> MAXUID
139 ** putsecure() - WRITE SECURE REQUEST STRUCTURE TO DISK FILE
143 putsecure(char *file
, SECURE
*secbufp
)
154 path
= makepath(Lp_Requests
, file
, (char *)0);
158 if ((fd
= open_locked(path
, "w", MODE_NOREAD
)) < 0) {
170 for (fld
= 0; fld
< SC_MAX
; fld
++)
175 (void)fdprintf(fd
, "%s\n", secbufp
->req_id
);
179 (void)fdprintf(fd
, "%u\n", secbufp
->uid
);
183 (void)fdprintf(fd
, "%s\n", secbufp
->user
);
187 (void)fdprintf(fd
, "%u\n", secbufp
->gid
);
191 (void)fdprintf(fd
, "%lu\n", secbufp
->size
);
195 (void)fdprintf(fd
, "%ld\n", secbufp
->date
);
206 ** o 'reqfilep' is of the form 'node-name/request-file'
207 ** e.g. 'sfcalv/123-0'.
210 rmsecure (char *reqfilep
)
215 pathp
= makepath (Lp_Requests
, reqfilep
, (char *) 0);
226 ** freesecure() - FREE A SECURE STRUCTURE
230 freesecure(SECURE
*secbufp
)
235 Free (secbufp
->req_id
);
237 Free (secbufp
->user
);