1 /* $NetBSD: fsaccess_test.c,v 1.8 2014/12/10 04:37:53 christos Exp $ */
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 */
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"
40 isc_fsaccess_t access
;
46 if (n
!= 0 && errno
!= ENOENT
) {
47 fprintf(stderr
, "unable to remove(%s)\n", PATH
);
50 fp
= fopen(PATH
, "w");
52 fprintf(stderr
, "unable to fopen(%s)\n", PATH
);
57 fprintf(stderr
, "unable chmod(%s, 0)\n", PATH
);
63 isc_fsaccess_add(ISC_FSACCESS_OWNER
| ISC_FSACCESS_GROUP
,
64 ISC_FSACCESS_READ
| ISC_FSACCESS_WRITE
,
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
));