2 * perm.c - check user permission for at(1)
3 * Copyright (C) 1994 Thomas Koenig
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
26 #include <sys/types.h>
48 /* Structures and unions */
51 /* File scope variables */
53 static char rcsid[] = "$Id: perm.c,v 1.4 1997/03/12 19:36:06 ig25 Exp $";
55 /* Function declarations */
57 static int check_for_user(FILE * fp, const char *name);
62 check_for_user(FILE * fp, const char *name)
69 buffer = mymalloc(len + 2);
71 while (fgets(buffer, len + 2, fp) != NULL) {
72 if ((strncmp(name, buffer, len) == 0) &&
73 (buffer[len] == '\n')) {
82 /* Global functions */
87 uid_t uid = geteuid();
88 struct passwd *pentry;
93 if ((pentry = getpwuid(uid)) == NULL) {
94 perror("Cannot access user database");
99 fp = fopen(ETCDIR "/at.allow", "r");
104 return check_for_user(fp, pentry->pw_name);
109 fp = fopen(ETCDIR "/at.deny", "r");
114 return !check_for_user(fp, pentry->pw_name);