Remove building with NOCRYPTO option
[minix.git] / external / bsd / bind / dist / bin / tests / fsaccess_test.c
blobda7b8fdc6b08ee2b67c900b79e5011ba80e23f92
1 /* $NetBSD: fsaccess_test.c,v 1.8 2014/12/10 04:37:53 christos Exp $ */
3 /*
4 * Copyright (C) 2004, 2005, 2007, 2012 Internet Systems Consortium, Inc. ("ISC")
5 * Copyright (C) 2000, 2001 Internet Software Consortium.
7 * Permission to use, copy, modify, and/or distribute this software for any
8 * purpose with or without fee is hereby granted, provided that the above
9 * copyright notice and this permission notice appear in all copies.
11 * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
12 * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
13 * AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
14 * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
15 * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
16 * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
17 * PERFORMANCE OF THIS SOFTWARE.
20 /* Id: fsaccess_test.c,v 1.13 2007/06/19 23:46:59 tbox Exp */
22 /*! \file */
24 #include <config.h>
26 #include <stdio.h>
27 #include <stdlib.h>
28 #include <errno.h>
30 #include <sys/types.h> /* Non-portable. */
31 #include <sys/stat.h> /* Non-portable. */
33 #include <isc/fsaccess.h>
34 #include <isc/result.h>
36 #define PATH "/tmp/fsaccess"
38 int
39 main(void) {
40 isc_fsaccess_t access;
41 isc_result_t result;
42 FILE *fp;
43 int n;
45 n = remove(PATH);
46 if (n != 0 && errno != ENOENT) {
47 fprintf(stderr, "unable to remove(%s)\n", PATH);
48 exit(1);
50 fp = fopen(PATH, "w");
51 if (fp == NULL) {
52 fprintf(stderr, "unable to fopen(%s)\n", PATH);
53 exit(1);
55 n = chmod(PATH, 0);
56 if (n != 0) {
57 fprintf(stderr, "unable chmod(%s, 0)\n", PATH);
58 exit(1);
61 access = 0;
63 isc_fsaccess_add(ISC_FSACCESS_OWNER | ISC_FSACCESS_GROUP,
64 ISC_FSACCESS_READ | ISC_FSACCESS_WRITE,
65 &access);
67 printf("fsaccess=%d\n", access);
69 isc_fsaccess_add(ISC_FSACCESS_OTHER, ISC_FSACCESS_READ, &access);
71 printf("fsaccess=%d\n", access);
73 result = isc_fsaccess_set(PATH, access);
74 if (result != ISC_R_SUCCESS)
75 fprintf(stderr, "result = %s\n", isc_result_totext(result));
76 (void)fclose(fp);
78 return (0);