FreeBSD/tools/regression/security/open_to_operation/open_to_operation.c
/*
 * Before we get started, confirm that we can't open directories writable.
 */
Before we get started, confirm that we can't open directories writable.
Before we get started confirm that we can ' t open directories writable .
static void
try_directory_open(const char *testname, const char *directory,
    int mode, int expected_errno)
{
	int dfd;
	dfd = open(directory, mode);
	if (dfd >= 0) {
		if (expected_errno)
			notok_mode(testname, "opened", mode);
		else
			ok_mode(testname, NULL, mode);
		close(dfd);
	} else {
		if (expected_errno && expected_errno == errno)
			ok_mode(testname, NULL, mode);
		else if (expected_errno != 0)
			notok_mode(testname, "wrong errno", mode);
		else
			notok_mode(testname, "failed", mode);
	}
}
static void try_directory_open ( const char * testname , const char * directory , int mode , int expected_errno ) { int dfd ; dfd = open ( directory , mode ) ; if ( dfd >= 0 ) { if ( expected_errno ) notok_mode ( testname , " " , mode ) ; else ok_mode ( testname , NULL , mode ) ; close ( dfd ) ; } else { if ( expected_errno && expected_errno == errno ) ok_mode ( testname , NULL , mode ) ; else if ( expected_errno != 0 ) notok_mode ( testname , " " , mode ) ; else notok_mode ( testname , " " , mode ) ; } }
Before we get started, confirm that we can't open directories writable.
Before we get started confirm that we can ' t open directories writable .