summaryrefslogtreecommitdiff
path: root/bin/systrace
diff options
context:
space:
mode:
authorOtto Moerbeek <otto@cvs.openbsd.org>2006-09-19 10:48:42 +0000
committerOtto Moerbeek <otto@cvs.openbsd.org>2006-09-19 10:48:42 +0000
commite41bf5c8cdf2b61b2e1f94e5dc2141160127d9ed (patch)
treeb44230252bf934c93fda779dbcf81d022c6f4a3d /bin/systrace
parentd21ea650b1bc6322fa2d4816990c11140a328490 (diff)
Use S_IS* macros insted of masking with S_IF* flags. The latter may
have multiple bits set, which leads to surprising results. Spotted by/partly from Paul Stoeber, more to come. ok ho@ miod@ hshoexer@
Diffstat (limited to 'bin/systrace')
-rw-r--r--bin/systrace/intercept.c4
-rw-r--r--bin/systrace/policy.c10
2 files changed, 7 insertions, 7 deletions
diff --git a/bin/systrace/intercept.c b/bin/systrace/intercept.c
index 0e8815942fd..1281f5ea45b 100644
--- a/bin/systrace/intercept.c
+++ b/bin/systrace/intercept.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: intercept.c,v 1.52 2006/07/02 12:34:15 sturm Exp $ */
+/* $OpenBSD: intercept.c,v 1.53 2006/09/19 10:48:41 otto Exp $ */
/*
* Copyright 2002 Niels Provos <provos@citi.umich.edu>
* All rights reserved.
@@ -704,7 +704,7 @@ normalize_filename(int fd, pid_t pid, char *name, int userp)
*/
if (userp != ICLINK_NOLAST) {
if (lstat(rcwd, &st) == -1 ||
- !(st.st_mode & S_IFDIR))
+ !S_ISDIR(st.st_mode))
failed = 1;
}
}
diff --git a/bin/systrace/policy.c b/bin/systrace/policy.c
index d00da3550aa..2afcc5b964a 100644
--- a/bin/systrace/policy.c
+++ b/bin/systrace/policy.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: policy.c,v 1.31 2006/07/02 12:34:15 sturm Exp $ */
+/* $OpenBSD: policy.c,v 1.32 2006/09/19 10:48:41 otto Exp $ */
/*
* Copyright 2002 Niels Provos <provos@citi.umich.edu>
* All rights reserved.
@@ -127,7 +127,7 @@ systrace_setupdir(char *path)
if (stat(policydir, &sb) != -1) {
- if (!(sb.st_mode & S_IFDIR))
+ if (!S_ISDIR(sb.st_mode))
errx(1, "Not a directory: \"%s\"", policydir);
} else if (mkdir(policydir, 0700) == -1)
err(1, "mkdir(%s)", policydir);
@@ -438,7 +438,7 @@ systrace_templatedir(void)
goto error;
/* Check if template directory exists */
- if (stat(filename, &sb) != -1 && (sb.st_mode & S_IFDIR))
+ if (stat(filename, &sb) != -1 && S_ISDIR(sb.st_mode))
dir = opendir(filename);
}
@@ -446,7 +446,7 @@ systrace_templatedir(void)
if (dir == NULL) {
strlcpy(filename, POLICY_PATH, sizeof(filename));
strlcat(filename, "/templates", sizeof(filename));
- if (stat(filename, &sb) != -1 && (sb.st_mode & S_IFDIR))
+ if (stat(filename, &sb) != -1 && S_ISDIR(sb.st_mode))
dir = opendir(filename);
if (dir == NULL)
return (-1);
@@ -462,7 +462,7 @@ systrace_templatedir(void)
sizeof(filename))
goto error;
- if (stat(filename, &sb) == -1 || !(sb.st_mode & S_IFREG))
+ if (stat(filename, &sb) == -1 || !S_ISREG(sb.st_mode))
continue;
template = systrace_readtemplate(filename, NULL, NULL);