2
0
mirror of https://gitlab.isc.org/isc-projects/bind9 synced 2025-08-26 20:17:35 +00:00
bind/bin/tests/fsaccess_test.c

70 lines
1.5 KiB
C
Raw Normal View History

2000-06-22 01:27:11 +00:00
/*
* Copyright (C) 2000, 2001, 2004, 2005, 2007, 2012, 2015, 2016 Internet Systems Consortium, Inc. ("ISC")
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
2000-06-22 01:27:11 +00:00
*/
2007-06-19 23:47:24 +00:00
/* $Id: fsaccess_test.c,v 1.13 2007/06/19 23:46:59 tbox Exp $ */
/*! \file */
2000-06-23 16:19:01 +00:00
#include <config.h>
2000-06-22 22:00:42 +00:00
2000-06-20 04:06:01 +00:00
#include <stdio.h>
3410. [bug] Addressed Coverity warnings. [RT #31626] Squashed commit of the following: commit bce2efe66d69d60b746b85df49974ca341723169 Author: Mark Andrews <marka@isc.org> Date: Mon Oct 29 12:59:25 2012 +1100 use 'static dns_rdata_xxxx_t xxxx' commit 704d3c29acbf2dd350a26f2df82a57cb077ba72e Author: Mark Andrews <marka@isc.org> Date: Mon Oct 29 12:35:16 2012 +1100 return ISC_R_NOTFOUND if private record length does not make sense commit 7596610c12c5685336fc0909860173d2fae359af Author: Mark Andrews <marka@isc.org> Date: Sat Oct 27 21:41:17 2012 +1100 check private->length == 5 commit 3836365a3e3e83b057bd940350f032279e080296 Author: Mark Andrews <marka@isc.org> Date: Sat Oct 27 21:40:50 2012 +1100 properly set private->length commit a295778ac53109d39ef3a8b233751100edae678b Author: Mark Andrews <marka@isc.org> Date: Sat Oct 27 21:13:30 2012 +1100 check dns_rdata_tostruct result commit e33c37ca9112159e0b2363615bb018d27fa7d1a5 Author: Mark Andrews <marka@isc.org> Date: Sat Oct 27 21:10:43 2012 +1100 check remove/fopen/chmod return values commit 3a675e0666aae25d1c51f51ec7bd3fbe25545aae Author: Mark Andrews <marka@isc.org> Date: Sat Oct 27 20:59:10 2012 +1100 check isc_socket_accept result commit 696923344f4b07ce0dba4cf2675b1cbb6eba7e8e Author: Mark Andrews <marka@isc.org> Date: Sat Oct 27 20:55:40 2012 +1100 change variable scopes commit b9e9d9ad58270271003e463f10744e0ceaf9ad97 Author: Mark Andrews <marka@isc.org> Date: Sat Oct 27 20:53:19 2012 +1100 check inet_pton return value commit 70698e9589da77e3745efb6ea24b8830addd6ae4 Author: Mark Andrews <marka@isc.org> Date: Sat Oct 27 20:52:40 2012 +1100 break -> /* NOTREACHED */ commit 88de9de2e8e201ab2fef16a868f241e8206ea826 Author: Mark Andrews <marka@isc.org> Date: Sat Oct 27 20:52:06 2012 +1100 strcpy -> strlcpy commit 6ba79c7cec0e48014cdfa76e8a9406b7a921556e Author: Mark Andrews <marka@isc.org> Date: Sat Oct 27 20:51:26 2012 +1100 check dns_rdata_tostruct return values
2012-10-29 20:04:59 +11:00
#include <stdlib.h>
2012-10-30 09:22:57 +11:00
#include <errno.h>
2000-06-20 04:06:01 +00:00
#include <sys/types.h> /* Non-portable. */
#include <sys/stat.h> /* Non-portable. */
2000-06-20 04:06:01 +00:00
#include <isc/fsaccess.h>
#include <isc/print.h>
2000-06-20 04:06:01 +00:00
#include <isc/result.h>
#define PATH "/tmp/fsaccess"
int
main(void) {
isc_fsaccess_t access;
isc_result_t result;
3410. [bug] Addressed Coverity warnings. [RT #31626] Squashed commit of the following: commit bce2efe66d69d60b746b85df49974ca341723169 Author: Mark Andrews <marka@isc.org> Date: Mon Oct 29 12:59:25 2012 +1100 use 'static dns_rdata_xxxx_t xxxx' commit 704d3c29acbf2dd350a26f2df82a57cb077ba72e Author: Mark Andrews <marka@isc.org> Date: Mon Oct 29 12:35:16 2012 +1100 return ISC_R_NOTFOUND if private record length does not make sense commit 7596610c12c5685336fc0909860173d2fae359af Author: Mark Andrews <marka@isc.org> Date: Sat Oct 27 21:41:17 2012 +1100 check private->length == 5 commit 3836365a3e3e83b057bd940350f032279e080296 Author: Mark Andrews <marka@isc.org> Date: Sat Oct 27 21:40:50 2012 +1100 properly set private->length commit a295778ac53109d39ef3a8b233751100edae678b Author: Mark Andrews <marka@isc.org> Date: Sat Oct 27 21:13:30 2012 +1100 check dns_rdata_tostruct result commit e33c37ca9112159e0b2363615bb018d27fa7d1a5 Author: Mark Andrews <marka@isc.org> Date: Sat Oct 27 21:10:43 2012 +1100 check remove/fopen/chmod return values commit 3a675e0666aae25d1c51f51ec7bd3fbe25545aae Author: Mark Andrews <marka@isc.org> Date: Sat Oct 27 20:59:10 2012 +1100 check isc_socket_accept result commit 696923344f4b07ce0dba4cf2675b1cbb6eba7e8e Author: Mark Andrews <marka@isc.org> Date: Sat Oct 27 20:55:40 2012 +1100 change variable scopes commit b9e9d9ad58270271003e463f10744e0ceaf9ad97 Author: Mark Andrews <marka@isc.org> Date: Sat Oct 27 20:53:19 2012 +1100 check inet_pton return value commit 70698e9589da77e3745efb6ea24b8830addd6ae4 Author: Mark Andrews <marka@isc.org> Date: Sat Oct 27 20:52:40 2012 +1100 break -> /* NOTREACHED */ commit 88de9de2e8e201ab2fef16a868f241e8206ea826 Author: Mark Andrews <marka@isc.org> Date: Sat Oct 27 20:52:06 2012 +1100 strcpy -> strlcpy commit 6ba79c7cec0e48014cdfa76e8a9406b7a921556e Author: Mark Andrews <marka@isc.org> Date: Sat Oct 27 20:51:26 2012 +1100 check dns_rdata_tostruct return values
2012-10-29 20:04:59 +11:00
FILE *fp;
int n;
n = remove(PATH);
if (n != 0 && errno != ENOENT) {
fprintf(stderr, "unable to remove(%s)\n", PATH);
exit(1);
}
fp = fopen(PATH, "w");
if (fp == NULL) {
fprintf(stderr, "unable to fopen(%s)\n", PATH);
exit(1);
}
n = chmod(PATH, 0);
if (n != 0) {
fprintf(stderr, "unable chmod(%s, 0)\n", PATH);
exit(1);
}
2000-06-20 04:06:01 +00:00
access = 0;
isc_fsaccess_add(ISC_FSACCESS_OWNER | ISC_FSACCESS_GROUP,
ISC_FSACCESS_READ | ISC_FSACCESS_WRITE,
&access);
printf("fsaccess=%d\n", access);
isc_fsaccess_add(ISC_FSACCESS_OTHER, ISC_FSACCESS_READ, &access);
printf("fsaccess=%d\n", access);
result = isc_fsaccess_set(PATH, access);
if (result != ISC_R_SUCCESS)
fprintf(stderr, "result = %s\n", isc_result_totext(result));
3410. [bug] Addressed Coverity warnings. [RT #31626] Squashed commit of the following: commit bce2efe66d69d60b746b85df49974ca341723169 Author: Mark Andrews <marka@isc.org> Date: Mon Oct 29 12:59:25 2012 +1100 use 'static dns_rdata_xxxx_t xxxx' commit 704d3c29acbf2dd350a26f2df82a57cb077ba72e Author: Mark Andrews <marka@isc.org> Date: Mon Oct 29 12:35:16 2012 +1100 return ISC_R_NOTFOUND if private record length does not make sense commit 7596610c12c5685336fc0909860173d2fae359af Author: Mark Andrews <marka@isc.org> Date: Sat Oct 27 21:41:17 2012 +1100 check private->length == 5 commit 3836365a3e3e83b057bd940350f032279e080296 Author: Mark Andrews <marka@isc.org> Date: Sat Oct 27 21:40:50 2012 +1100 properly set private->length commit a295778ac53109d39ef3a8b233751100edae678b Author: Mark Andrews <marka@isc.org> Date: Sat Oct 27 21:13:30 2012 +1100 check dns_rdata_tostruct result commit e33c37ca9112159e0b2363615bb018d27fa7d1a5 Author: Mark Andrews <marka@isc.org> Date: Sat Oct 27 21:10:43 2012 +1100 check remove/fopen/chmod return values commit 3a675e0666aae25d1c51f51ec7bd3fbe25545aae Author: Mark Andrews <marka@isc.org> Date: Sat Oct 27 20:59:10 2012 +1100 check isc_socket_accept result commit 696923344f4b07ce0dba4cf2675b1cbb6eba7e8e Author: Mark Andrews <marka@isc.org> Date: Sat Oct 27 20:55:40 2012 +1100 change variable scopes commit b9e9d9ad58270271003e463f10744e0ceaf9ad97 Author: Mark Andrews <marka@isc.org> Date: Sat Oct 27 20:53:19 2012 +1100 check inet_pton return value commit 70698e9589da77e3745efb6ea24b8830addd6ae4 Author: Mark Andrews <marka@isc.org> Date: Sat Oct 27 20:52:40 2012 +1100 break -> /* NOTREACHED */ commit 88de9de2e8e201ab2fef16a868f241e8206ea826 Author: Mark Andrews <marka@isc.org> Date: Sat Oct 27 20:52:06 2012 +1100 strcpy -> strlcpy commit 6ba79c7cec0e48014cdfa76e8a9406b7a921556e Author: Mark Andrews <marka@isc.org> Date: Sat Oct 27 20:51:26 2012 +1100 check dns_rdata_tostruct return values
2012-10-29 20:04:59 +11:00
(void)fclose(fp);
2000-06-20 04:06:01 +00:00
return (0);
}