Created
October 6, 2014 08:13
-
-
Save unbit/701881aaa32fe6f39b6e to your computer and use it in GitHub Desktop.
vassalchroot uWSGI plugin
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <uwsgi.h> | |
static void vassal_chroot_hook(struct uwsgi_instance *ui) { | |
// first of all get my username | |
struct passwd *pw = getpwuid(ui->uid); | |
if (!pw) { | |
uwsgi_log("unable to get username\n"); | |
exit(1); | |
} | |
char *path = uwsgi_concat3("/var/www/", pw->pw_name, "/data"); | |
if (chroot(path)) { | |
uwsgi_error("vassal_chroot_hook()/chroot()"); | |
exit(1); | |
} | |
} | |
struct uwsgi_plugin vassalchroot_plugin = { | |
.name = "vassalchroot", | |
.vassal = vassal_chroot_hook, | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment