fsaccess_test.c revision 40f53fa8d9c6a4fc38c0014495e7a42b08f52481
5fc7ba3e1ac5d72239e9971e0f469dd5796738f9Andreas Gustafsson/*
17131a9459e5b30f764bc77f4fed288907a5b5e0Tinderbox User * Copyright (C) 2000 Internet Software Consortium.
dafcb997e390efa4423883dafd100c975c4095d6Mark Andrews *
40f53fa8d9c6a4fc38c0014495e7a42b08f52481David Lawrence * Permission to use, copy, modify, and distribute this software for any
ec5347e2c775f027573ce5648b910361aa926c01Automatic Updater * purpose with or without fee is hereby granted, provided that the above
5fc7ba3e1ac5d72239e9971e0f469dd5796738f9Andreas Gustafsson * copyright notice and this permission notice appear in all copies.
5fc7ba3e1ac5d72239e9971e0f469dd5796738f9Andreas Gustafsson *
40f53fa8d9c6a4fc38c0014495e7a42b08f52481David Lawrence * THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM
dafcb997e390efa4423883dafd100c975c4095d6Mark Andrews * DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL
dafcb997e390efa4423883dafd100c975c4095d6Mark Andrews * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL
dafcb997e390efa4423883dafd100c975c4095d6Mark Andrews * INTERNET SOFTWARE CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT,
dafcb997e390efa4423883dafd100c975c4095d6Mark Andrews * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING
dafcb997e390efa4423883dafd100c975c4095d6Mark Andrews * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
dafcb997e390efa4423883dafd100c975c4095d6Mark Andrews * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
dafcb997e390efa4423883dafd100c975c4095d6Mark Andrews * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
5fc7ba3e1ac5d72239e9971e0f469dd5796738f9Andreas Gustafsson */
5fc7ba3e1ac5d72239e9971e0f469dd5796738f9Andreas Gustafsson
28a8f5b0de57d269cf2845c69cb6abe18cbd3b3aMark Andrews/* $Id: fsaccess_test.c,v 1.7 2000/08/01 01:12:46 tale Exp $ */
ab023a65562e62b85a824509d829b6fad87e00b1Rob Austein
ab023a65562e62b85a824509d829b6fad87e00b1Rob Austein#include <config.h>
9c3531d72aeaad6c5f01efe6a1c82023e1379e4dDavid Lawrence
5fc7ba3e1ac5d72239e9971e0f469dd5796738f9Andreas Gustafsson#include <stdio.h>
5fc7ba3e1ac5d72239e9971e0f469dd5796738f9Andreas Gustafsson
593cb00bd17e5e2ab0dcb7c635a9a81082dc5d0eAndreas Gustafsson#include <sys/types.h> /* Non-portable. */
593cb00bd17e5e2ab0dcb7c635a9a81082dc5d0eAndreas Gustafsson#include <sys/stat.h> /* Non-portable. */
9aba20edee4e704433a464ae43b070b0775de506Mark Andrews
3e14b69d196a3ebeecc4662c426344dcfd7db678Andreas Gustafsson#include <isc/fsaccess.h>
9aba20edee4e704433a464ae43b070b0775de506Mark Andrews#include <isc/result.h>
1a69a1a78cfaa86f3b68bbc965232b7876d4da2aDavid Lawrence
16a68807e13caea3183a41a5292f1b3f48b81a26Mark Andrews#define PATH "/tmp/fsaccess"
d8e34837cd6c88c42b3ecdb9107a43ecf8252e79David Lawrence
1a69a1a78cfaa86f3b68bbc965232b7876d4da2aDavid Lawrenceint
9aba20edee4e704433a464ae43b070b0775de506Mark Andrewsmain(void) {
261a6a1f7d95eaf0cd882f3123dcfd775517a54fMark Andrews isc_fsaccess_t access;
364a82f7c25b62967678027043425201a5e5171aBob Halley isc_result_t result;
5fc7ba3e1ac5d72239e9971e0f469dd5796738f9Andreas Gustafsson
1a69a1a78cfaa86f3b68bbc965232b7876d4da2aDavid Lawrence remove(PATH);
1a69a1a78cfaa86f3b68bbc965232b7876d4da2aDavid Lawrence fopen(PATH, "w");
9aba20edee4e704433a464ae43b070b0775de506Mark Andrews chmod(PATH, 0);
5fc7ba3e1ac5d72239e9971e0f469dd5796738f9Andreas Gustafsson
261a6a1f7d95eaf0cd882f3123dcfd775517a54fMark Andrews access = 0;
3e14b69d196a3ebeecc4662c426344dcfd7db678Andreas Gustafsson
a903095bf4512dae561c7f6fc7854a51bebf334aMark Andrews isc_fsaccess_add(ISC_FSACCESS_OWNER | ISC_FSACCESS_GROUP,
1a69a1a78cfaa86f3b68bbc965232b7876d4da2aDavid Lawrence ISC_FSACCESS_READ | ISC_FSACCESS_WRITE,
47d89fcd4fb850b066f87dc3313afe1cfe92cd99Mark Andrews &access);
5fc7ba3e1ac5d72239e9971e0f469dd5796738f9Andreas Gustafsson
673ce7aebbb6d01c75b95f6df1ec491d6422b951Andreas Gustafsson printf("fsaccess=%d\n", access);
5fc7ba3e1ac5d72239e9971e0f469dd5796738f9Andreas Gustafsson
5fc7ba3e1ac5d72239e9971e0f469dd5796738f9Andreas Gustafsson isc_fsaccess_add(ISC_FSACCESS_OTHER, ISC_FSACCESS_READ, &access);
1a69a1a78cfaa86f3b68bbc965232b7876d4da2aDavid Lawrence
1a69a1a78cfaa86f3b68bbc965232b7876d4da2aDavid Lawrence printf("fsaccess=%d\n", access);
5fc7ba3e1ac5d72239e9971e0f469dd5796738f9Andreas Gustafsson
5fc7ba3e1ac5d72239e9971e0f469dd5796738f9Andreas Gustafsson result = isc_fsaccess_set(PATH, access);
5fc7ba3e1ac5d72239e9971e0f469dd5796738f9Andreas Gustafsson if (result != ISC_R_SUCCESS)
9aba20edee4e704433a464ae43b070b0775de506Mark Andrews fprintf(stderr, "result = %s\n", isc_result_totext(result));
9aba20edee4e704433a464ae43b070b0775de506Mark Andrews
9aba20edee4e704433a464ae43b070b0775de506Mark Andrews return (0);
5fc7ba3e1ac5d72239e9971e0f469dd5796738f9Andreas Gustafsson}
600cfa2ba4c50017581b6c14e3a688a82ecebbe0David Lawrence