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]
21 /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
22 /* All Rights Reserved */
25 * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
26 * Use is subject to license terms.
29 #include <sys/types.h>
35 #include <auth_attr.h>
36 #include <auth_list.h>
41 #define exists(file) (stat(file, &globstat) == 0)
44 int per_errno
; /* status info from getuser */
45 static int within(char *, char *);
54 if ((nptr
= getpwuid(uid
)) == NULL
) {
58 if ((strcmp(nptr
->pw_shell
, SHELL
) != 0) &&
59 (strcmp(nptr
->pw_shell
, "") != 0)) {
62 * return NULL if you want crontab and at to abort
63 * when the users login shell is not /usr/bin/sh otherwise
66 return (nptr
->pw_name
);
68 return (nptr
->pw_name
);
72 allowed(user
, allow
, deny
)
73 char *user
, *allow
, *deny
;
76 if (within(user
, allow
)) {
81 } else if (exists(deny
)) {
82 if (within(user
, deny
)) {
87 } else if (chkauthattr(CRONUSER_AUTH
, user
)) {
95 within(username
, filename
)
96 char *username
, *filename
;
102 if ((cap
= fopen(filename
, "r")) == NULL
)
104 while (fgets(line
, UNAMESIZE
, cap
) != NULL
) {
105 for (i
= 0; line
[i
] != '\0'; i
++) {
106 if (isspace(line
[i
])) {
110 if (strcmp(line
, username
) == 0) {
120 cron_admin(const char *name
)
122 return (chkauthattr(CRONADMIN_AUTH
, name
));