return true;
}
-static bool cgfs_create_forone(const struct controller *c, const char *cg, bool *existed)
+static bool cgfs_create_forone(const struct controller *c, uid_t uid, gid_t gid, const char *cg, bool *existed)
{
while (c) {
if (!c->mount_path || !c->init_path)
#if DEBUG
fprintf(stderr, "Creating %s %s\n", path, pass ? "succeeded" : "failed");
#endif
+ if (pass) {
+ if (chown(path, uid, gid) < 0)
+ mysyslog(LOG_WARNING, "Failed to chown %s to %d:%d: %m\n",
+ path, (int)uid, (int)gid);
+ }
free(path);
if (pass)
return true;
}
}
-static bool cgfs_create(const char *cg, bool *existed)
+static bool cgfs_create(const char *cg, uid_t uid, gid_t gid, bool *existed)
{
*existed = false;
int i, j;
if (!c)
continue;
- if (!cgfs_create_forone(c, cg, existed)) {
+ if (!cgfs_create_forone(c, uid, gid, cg, existed)) {
for (j = 0; j < i; j++)
cgfs_remove_forone(j, cg);
return false;
return true;
}
-static bool cgfs_chown(const char *cg, uid_t uid, gid_t gid)
-{
- /* TODO */
- return true;
-}
-
static bool write_int(char *path, int v)
{
FILE *f = fopen(path, "w");
return PAM_SESSION_ERR;
}
- if (!cgfs_create(cg, &existed)) {
+ if (!cgfs_create(cg, uid, gid, &existed)) {
mysyslog(LOG_ERR, "Failed to create a cgroup for user %s\n", user);
return PAM_SESSION_ERR;
}
continue;
}
- if (!cgfs_chown(cg, uid, gid)) {
- mysyslog(LOG_ERR, "Warning: failed to chown %s for user %s\n", cg, user);
- }
-
if (!cgfs_enter(cg)) {
mysyslog(LOG_ERR, "Failed to enter user cgroup %s for user %s\n", cg, user);
return PAM_SESSION_ERR;