/* Version 2 of vsh. Basically a wrapper around 'vserver enter.' */ #include #include #include #include #include #include #include #include #define VSH_PATH "/usr/sbin/vsh" #ifndef PATH_MAX #define PATH_MAX 4096 #endif #define VSERVER_PATH "/usr/sbin/vserver" char* get_current_username (unsigned int uid) { struct passwd *passwd_entry; if ((passwd_entry = getpwuid(uid)) == NULL) { fprintf(stderr, "Could not look up user record for %d\n", uid); return NULL; } return (strdup(passwd_entry->pw_name)); } char **extend_argv(int argc, char **argv, int num_extra_args) { int argc2, i; char **argv2; argc2 = argc + num_extra_args; argv2 = (char **) malloc((argc2 + 1) * sizeof(char *)); if (!argv2) return (char **) NULL; for (i=0; i