Deleted Added
full compact
misc.c (94389) misc.c (101293)
1/* Copyright 1988,1990,1993,1994 by Paul Vixie
2 * All rights reserved
3 *
4 * Distribute freely, except: don't remove my name from the source or
5 * documentation (don't take credit for my work), mark your changes (don't
6 * get me blamed for your possible bugs), don't alter or remove this
7 * notice. May be sold if buildable source is provided to buyer. No
8 * warrantee of any kind, express or implied, is included with this
9 * software; use at your own risk, responsibility for damages (if any) to
10 * anyone resulting from the use of this software rests entirely with the
11 * user.
12 *
13 * Send bug reports, bug fixes, enhancements, requests, flames, etc., and
14 * I'll try to keep a version up to date. I can be reached as follows:
15 * Paul Vixie <paul@vix.com> uunet!decwrl!vixie!paul
16 */
17
18#if !defined(lint) && !defined(LINT)
19static const char rcsid[] =
1/* Copyright 1988,1990,1993,1994 by Paul Vixie
2 * All rights reserved
3 *
4 * Distribute freely, except: don't remove my name from the source or
5 * documentation (don't take credit for my work), mark your changes (don't
6 * get me blamed for your possible bugs), don't alter or remove this
7 * notice. May be sold if buildable source is provided to buyer. No
8 * warrantee of any kind, express or implied, is included with this
9 * software; use at your own risk, responsibility for damages (if any) to
10 * anyone resulting from the use of this software rests entirely with the
11 * user.
12 *
13 * Send bug reports, bug fixes, enhancements, requests, flames, etc., and
14 * I'll try to keep a version up to date. I can be reached as follows:
15 * Paul Vixie <paul@vix.com> uunet!decwrl!vixie!paul
16 */
17
18#if !defined(lint) && !defined(LINT)
19static const char rcsid[] =
20 "$FreeBSD: head/usr.sbin/cron/lib/misc.c 94389 2002-04-10 22:01:37Z dwmalone $";
20 "$FreeBSD: head/usr.sbin/cron/lib/misc.c 101293 2002-08-04 04:32:27Z tjr $";
21#endif
22
23/* vix 26jan87 [RCS has the rest of the log]
24 * vix 30dec86 [written]
25 */
26
27
28#include "cron.h"

--- 376 unchanged lines hidden (view full) ---

405 * returns TRUE if (ALLOW_FILE exists and user is listed)
406 * or (DENY_FILE exists and user is NOT listed)
407 * or (neither file exists but user=="root" so it's okay)
408 */
409int
410allowed(username)
411 char *username;
412{
21#endif
22
23/* vix 26jan87 [RCS has the rest of the log]
24 * vix 30dec86 [written]
25 */
26
27
28#include "cron.h"

--- 376 unchanged lines hidden (view full) ---

405 * returns TRUE if (ALLOW_FILE exists and user is listed)
406 * or (DENY_FILE exists and user is NOT listed)
407 * or (neither file exists but user=="root" so it's okay)
408 */
409int
410allowed(username)
411 char *username;
412{
413 static int init = FALSE;
414 static FILE *allow, *deny;
413 FILE *allow, *deny;
414 int isallowed;
415
415
416 if (!init) {
417 init = TRUE;
416 isallowed = FALSE;
417
418#if defined(ALLOW_FILE) && defined(DENY_FILE)
418#if defined(ALLOW_FILE) && defined(DENY_FILE)
419 allow = fopen(ALLOW_FILE, "r");
420 deny = fopen(DENY_FILE, "r");
421 Debug(DMISC, ("allow/deny enabled, %d/%d\n", !!allow, !!deny))
419 if ((allow = fopen(ALLOW_FILE, "r")) == NULL && errno != ENOENT)
420 goto out;
421 if ((deny = fopen(DENY_FILE, "r")) == NULL && errno != ENOENT)
422 goto out;
423 Debug(DMISC, ("allow/deny enabled, %d/%d\n", !!allow, !!deny))
422#else
424#else
423 allow = NULL;
424 deny = NULL;
425 allow = NULL;
426 deny = NULL;
425#endif
427#endif
426 }
427
428 if (allow)
428
429 if (allow)
429 return (in_file(username, allow));
430 if (deny)
431 return (!in_file(username, deny));
432
430 isallowed = in_file(username, allow);
431 else if (deny)
432 isallowed = !in_file(username, deny);
433 else {
433#if defined(ALLOW_ONLY_ROOT)
434#if defined(ALLOW_ONLY_ROOT)
434 return (strcmp(username, ROOT_USER) == 0);
435 isallowed = (strcmp(username, ROOT_USER) == 0);
435#else
436#else
436 return TRUE;
437 isallowed = TRUE;
437#endif
438#endif
439 }
440out: if (allow)
441 fclose(allow);
442 if (deny)
443 fclose(deny);
444 return (isallowed);
438}
439
440
441void
442log_it(username, xpid, event, detail)
443 char *username;
444 int xpid;
445 char *event;

--- 210 unchanged lines hidden ---
445}
446
447
448void
449log_it(username, xpid, event, detail)
450 char *username;
451 int xpid;
452 char *event;

--- 210 unchanged lines hidden ---