Skip to content

Instantly share code, notes, and snippets.

@unbit
Created October 6, 2014 08:13
Show Gist options
  • Save unbit/701881aaa32fe6f39b6e to your computer and use it in GitHub Desktop.
Save unbit/701881aaa32fe6f39b6e to your computer and use it in GitHub Desktop.
vassalchroot uWSGI plugin
#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