#ifdef HAVE_CONFIG_H # include #endif #include "vserver.h" #include #include #include #include #include #include #include #define SPACE_FILE "/spaces/net" #define VSERVERCONF "/etc/vservers/" int pl_unshare_netns(xid_t xid) { char *ctx_space_file, *space_name; struct passwd *slice_user; int res = 0; char buf[100]; FILE *fb; slice_user = getpwuid(xid); if (!slice_user) return 0; ctx_space_file=(char *) malloc(sizeof(VSERVERCONF SPACE_FILE "Z")+strlen(slice_user->pw_name)); if (!ctx_space_file) return 0; sprintf(ctx_space_file,VSERVERCONF "%s" SPACE_FILE, slice_user->pw_name); if ((fb = fopen(ctx_space_file, "r")) == NULL) return 0; if (fgets(buf, sizeof(buf), fb) != NULL) { res = atoi(buf); } fclose(fb); free(ctx_space_file); return res; }