summaryrefslogtreecommitdiffstats
path: root/src/daemon/cgrulesengd.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/daemon/cgrulesengd.c')
-rw-r--r--src/daemon/cgrulesengd.c50
1 files changed, 2 insertions, 48 deletions
diff --git a/src/daemon/cgrulesengd.c b/src/daemon/cgrulesengd.c
index fb757c1..ea093ad 100644
--- a/src/daemon/cgrulesengd.c
+++ b/src/daemon/cgrulesengd.c
@@ -140,52 +140,6 @@ void flog(int level, const char *format, ...)
}
}
-static int cgre_get_euid_egid_from_status(pid_t pid, uid_t *euid, gid_t *egid)
-{
- /* Handle for the /proc/PID/status file */
- FILE *f;
-
- /* Path for /proc/PID/status file */
- char path[FILENAME_MAX];
-
- /* Temporary buffer */
- char buf[4092];
-
- /* UID data */
- uid_t ruid, suid, fsuid;
-
- /* GID data */
- gid_t rgid, sgid, fsgid;
-
- /*
- * First, we need to open the /proc/PID/status file so that we can
- * get the effective UID and GID for the process that we're working
- * on. This process is probably not us, so we can't just call
- * geteuid() or getegid().
- */
- sprintf(path, "/proc/%d/status", pid);
- f = fopen(path, "r");
- if (!f) {
- flog(LOG_WARNING, "Failed to open %s", path);
- return 1;
- }
-
- /* Have the eUID, need to find the eGID. */
- memset(buf, '\0', sizeof(buf));
- while (fgets(buf, sizeof(buf), f)) {
- if (!strncmp(buf, "Uid:", 4)) {
- sscanf((buf + 5), "%d%d%d%d", &ruid, euid,
- &suid, &fsuid);
- } else if (!strncmp(buf, "Gid:", 4)) {
- sscanf((buf + 5), "%d%d%d%d", &rgid, egid,
- &sgid, &fsgid);
- }
- memset(buf, '\0', sizeof(buf));
- }
- fclose(f);
- return 0;
-}
-
struct parent_info {
__u64 timestamp;
pid_t pid;
@@ -325,8 +279,8 @@ int cgre_process_event(const struct proc_event *ev, const int type)
default:
break;
}
- if (cgre_get_euid_egid_from_status(pid, &euid, &egid))
- /* cgre_get_euid_egid_from_status() returns 1 if it fails to
+ if (cgroup_get_procdata_from_status(pid, &euid, &egid, NULL, 0))
+ /* cgroup_get_procdata_from_status() returns 1 if it fails to
* open /proc/<pid>/status file and that is not a problem. */
return 0;