[apparmor] [PATCH 3/5] Make setprocattr more abstract so it will work for any pid
John Johansen
john.johansen at canonical.com
Tue Jul 12 18:49:03 UTC 2011
Signed-off-by: John Johansen <john.johansen at canonical.com>
---
libraries/libapparmor/src/kernel_interface.c | 11 +++++------
1 files changed, 5 insertions(+), 6 deletions(-)
diff --git a/libraries/libapparmor/src/kernel_interface.c b/libraries/libapparmor/src/kernel_interface.c
index f48792f..4e6c1e9 100644
--- a/libraries/libapparmor/src/kernel_interface.c
+++ b/libraries/libapparmor/src/kernel_interface.c
@@ -54,12 +54,11 @@ static char *procattr_path(pid_t pid, const char *attr)
return NULL;
}
-static int setprocattr(const char *attr, const char *buf, int len)
+static int setprocattr(pid_t tid, const char *attr, const char *buf, int len)
{
int rc = -1;
int fd, ret;
char *ctl = NULL;
- pid_t tid = aa_gettid();
if (!buf) {
errno = EINVAL;
@@ -120,7 +119,7 @@ int aa_change_hat(const char *subprofile, unsigned long token)
goto out;
}
- rc = setprocattr("current", buf, len);
+ rc = setprocattr(aa_gettid(), "current", buf, len);
out:
if (buf) {
/* clear local copy of magic token before freeing */
@@ -151,7 +150,7 @@ int aa_change_profile(const char *profile)
if (len < 0)
return -1;
- rc = setprocattr("current", buf, len);
+ rc = setprocattr(aa_gettid(), "current", buf, len);
free(buf);
return rc;
@@ -172,7 +171,7 @@ int aa_change_onexec(const char *profile)
if (len < 0)
return -1;
- rc = setprocattr("/proc/%d/attr/exec", buf, len);
+ rc = setprocattr(aa_gettid(), "/proc/%d/attr/exec", buf, len);
free(buf);
return rc;
@@ -233,7 +232,7 @@ int aa_change_hatv(const char *subprofiles[], unsigned long token)
/* step pos past trailing \0 */
pos++;
- rc = setprocattr("/proc/%d/attr/current", buf, pos - buf);
+ rc = setprocattr(aa_gettid(), "/proc/%d/attr/current", buf, pos - buf);
out:
if (buf) {
--
1.7.5.4
More information about the AppArmor
mailing list