use util-vserver's style of config, not sapan's funky style.
[util-vserver-pl.git] / src / netns.c
1 #ifdef HAVE_CONFIG_H
2 #  include <config.h>
3 #endif
4
5 #include "vserver.h"
6 #include <string.h>
7 #include <stdio.h>
8 #include <stdlib.h>
9 #include <stdint.h>
10 #include <sys/types.h>
11 #include <pwd.h>
12
13 #define     SPACE_FILE      "/spaces/net"
14 #define     VSERVERCONF     "/etc/vservers/"
15
16 uint32_t
17 get_space_flag(xid_t xid) {
18     char *ctx_space_file, *space_name;
19     struct passwd *slice_user;
20     uint32_t space_flag = 0;
21
22     slice_user = get_pwuid(xid);
23
24     if (!slice_user)
25         return 0;
26
27     ctx_space_file=(char *) malloc(sizeof(VSERVERCONF SPACE_FILE "Z")+strlen(slice_user->pw_name));
28     if (!ctx_space_file)
29         return 0;
30
31     sprintf(ctx_space_file,VSERVERCONF SPACE_FILE "%s", slice_user->pw_name);
32
33     if (access(ctx_space_file, F_OK)==0)
34         space_flag |= CLONE_NEWNET;
35
36     free(ctx_space_dir);
37     return space_flag;
38 }