summaryrefslogtreecommitdiff
path: root/src/cgroup-util.c
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2010-07-21 04:32:44 +0200
committerLennart Poettering <lennart@poettering.net>2010-07-21 04:32:44 +0200
commit672c48cc065251ddbdc3926221e8a7718241cccd (patch)
tree59aaccdca30c64a82b99f4698985d7a880be1840 /src/cgroup-util.c
parent294d81f124568983323a53f40bfbaa371f0da077 (diff)
pam: remove only sessions we ourselves created in the first place
Diffstat (limited to 'src/cgroup-util.c')
-rw-r--r--src/cgroup-util.c20
1 files changed, 16 insertions, 4 deletions
diff --git a/src/cgroup-util.c b/src/cgroup-util.c
index 828b30414a..2f3fcb5981 100644
--- a/src/cgroup-util.c
+++ b/src/cgroup-util.c
@@ -25,6 +25,8 @@
#include <string.h>
#include <stdlib.h>
#include <dirent.h>
+#include <sys/stat.h>
+#include <sys/types.h>
#include "cgroup-util.h"
#include "log.h"
@@ -546,7 +548,17 @@ int cg_create(const char *controller, const char *path) {
if ((r = cg_get_path(controller, path, NULL, &fs)) < 0)
return r;
- r = mkdir_p(fs, 0755);
+ r = mkdir_parents(fs, 0755);
+
+ if (r >= 0) {
+ if (mkdir(fs, 0755) >= 0)
+ r = 1;
+ else if (errno == EEXIST)
+ r = 0;
+ else
+ r = -errno;
+ }
+
free(fs);
return r;
@@ -577,7 +589,7 @@ int cg_attach(const char *controller, const char *path, pid_t pid) {
}
int cg_create_and_attach(const char *controller, const char *path, pid_t pid) {
- int r;
+ int r, q;
assert(controller);
assert(path);
@@ -586,8 +598,8 @@ int cg_create_and_attach(const char *controller, const char *path, pid_t pid) {
if ((r = cg_create(controller, path)) < 0)
return r;
- if ((r = cg_attach(controller, path, pid)) < 0)
- return r;
+ if ((q = cg_attach(controller, path, pid)) < 0)
+ return q;
/* This does not remove the cgroup on failure */