Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/bin/systrace Separate constructing the path to the policy aw...



details:   https://anonhg.NetBSD.org/src/rev/b762459cf3b0
branches:  trunk
changeset: 583539:b762459cf3b0
user:      elad <elad%NetBSD.org@localhost>
date:      Wed Aug 10 18:19:21 2005 +0000

description:
Separate constructing the path to the policy away from systrace_addpolicy() and
into systrace_getpolicyfilename().

diffstat:

 bin/systrace/policy.c   |  26 ++++++++++++++++----------
 bin/systrace/systrace.h |   3 ++-
 2 files changed, 18 insertions(+), 11 deletions(-)

diffs (74 lines):

diff -r b0bd02584b5c -r b762459cf3b0 bin/systrace/policy.c
--- a/bin/systrace/policy.c     Wed Aug 10 17:53:28 2005 +0000
+++ b/bin/systrace/policy.c     Wed Aug 10 18:19:21 2005 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: policy.c,v 1.17 2005/06/24 23:21:09 christos Exp $     */
+/*     $NetBSD: policy.c,v 1.18 2005/08/10 18:19:21 elad Exp $ */
 /*     $OpenBSD: policy.c,v 1.15 2002/08/07 00:34:17 vincent Exp $     */
 /*
  * Copyright 2002 Niels Provos <provos%citi.umich.edu@localhost>
@@ -30,7 +30,7 @@
  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 #include <sys/cdefs.h>
-__RCSID("$NetBSD: policy.c,v 1.17 2005/06/24 23:21:09 christos Exp $");
+__RCSID("$NetBSD: policy.c,v 1.18 2005/08/10 18:19:21 elad Exp $");
 
 #include <sys/types.h>
 #include <sys/param.h>
@@ -327,24 +327,30 @@
        return (file);
 }
 
-int
-systrace_addpolicy(const char *name)
+char *
+systrace_getpolicyfilename(const char *name)
 {
        char *file = NULL;
 
        if (userpolicy) {
                file = systrace_policyfilename(policydir, name);
-               /* Check if the user policy file exists */
                if (file != NULL && access(file, R_OK) == -1)
                        file = NULL;
        }
 
-       /* Read global policy */
-       if (file == NULL) {
+       if (file == NULL)
                file = systrace_policyfilename(POLICY_PATH, name);
-               if (file == NULL)
-                       return (-1);
-       }
+
+       return (file);
+}
+
+int
+systrace_addpolicy(const char *name)
+{
+       char *file = NULL;
+
+       if ((file = systrace_getpolicyfilename(name)) == NULL)
+               return (-1);
 
        return (systrace_readpolicy(file));
 }
diff -r b0bd02584b5c -r b762459cf3b0 bin/systrace/systrace.h
--- a/bin/systrace/systrace.h   Wed Aug 10 17:53:28 2005 +0000
+++ b/bin/systrace/systrace.h   Wed Aug 10 18:19:21 2005 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: systrace.h,v 1.20 2005/06/25 12:22:43 elad Exp $       */
+/*     $NetBSD: systrace.h,v 1.21 2005/08/10 18:19:21 elad Exp $       */
 /*     $OpenBSD: systrace.h,v 1.14 2002/08/05 23:27:53 provos Exp $    */
 /*
  * Copyright 2002 Niels Provos <provos%citi.umich.edu@localhost>
@@ -146,6 +146,7 @@
 struct policy *systrace_findpolnr(int);
 int systrace_dumppolicy(void);
 int systrace_readpolicy(char *);
+char *systrace_getpolicyfilename(const char *);
 int systrace_addpolicy(const char *);
 struct filterq *systrace_policyflq(struct policy *, const char *, const char *);
 



Home | Main Index | Thread Index | Old Index