double swap;
bool autostart;
bool running;
+ bool unprivileged;
};
/* Keep track of field widths for printing. */
unsigned int ram_length;
unsigned int swap_length;
unsigned int autostart_length;
+ unsigned int unprivileged_length;
};
static int ls_deserialize(int rpipefd, struct ls **m, size_t *len);
-f, --fancy use a fancy, column-based output\n\
-F, --fancy-format comma separated list of columns to show in the fancy output\n\
valid columns are: NAME, STATE, PID, RAM, SWAP, AUTOSTART,\n\
- GROUPS, INTERFACE, IPV4 and IPV6\n\
+ GROUPS, INTERFACE, IPV4 and IPV6, UNPRIVILEGED\n\
--active list only active containers\n\
--running list only running containers\n\
--frozen list only frozen containers\n\
struct lengths max_len = {
/* default header length */
- .name_length = 4, /* NAME */
- .state_length = 5, /* STATE */
- .groups_length = 6, /* GROUPS */
- .interface_length = 9, /* INTERFACE */
- .ipv4_length = 4, /* IPV4 */
- .ipv6_length = 4, /* IPV6 */
- .init_length = 3, /* PID */
- .ram_length = 3, /* RAM */
- .swap_length = 4, /* SWAP */
- .autostart_length = 9, /* AUTOSTART */
+ .name_length = 4, /* NAME */
+ .state_length = 5, /* STATE */
+ .groups_length = 6, /* GROUPS */
+ .interface_length = 9, /* INTERFACE */
+ .ipv4_length = 4, /* IPV4 */
+ .ipv6_length = 4, /* IPV6 */
+ .init_length = 3, /* PID */
+ .ram_length = 3, /* RAM */
+ .swap_length = 4, /* SWAP */
+ .autostart_length = 9, /* AUTOSTART */
+ .unprivileged_length = 12, /* UNPRIVILEGED */
};
char **grps = NULL;
free(tmp);
if (running) {
+ char *val;
+
l->init = c->init_pid(c);
+ if (l->init <= 0)
+ goto put_and_next;
l->interface = ls_get_interface(c);
}
l->swap = ls_get_swap(c);
+
+ val = c->get_running_config_item(c, "lxc.idmap");
+ l->unprivileged = (val == NULL);
+ free(val);
+ } else {
+ int ret;
+
+ ret = c->get_config_item(c, "lxc.idmap", NULL, 0);
+ l->unprivileged = (ret == 0);
}
}
/* Check for invalid keys. */
for (s = tmp; s && *s; s++) {
if (strcasecmp(*s, "NAME") && strcasecmp(*s, "STATE") &&
- strcasecmp(*s, "PID") && strcasecmp(*s, "RAM") &&
- strcasecmp(*s, "SWAP") && strcasecmp(*s, "AUTOSTART") &&
- strcasecmp(*s, "GROUPS") && strcasecmp(*s, "INTERFACE") &&
- strcasecmp(*s, "IPV4") && strcasecmp(*s, "IPV6")) {
+ strcasecmp(*s, "PID") && strcasecmp(*s, "RAM") &&
+ strcasecmp(*s, "SWAP") && strcasecmp(*s, "AUTOSTART") &&
+ strcasecmp(*s, "GROUPS") && strcasecmp(*s, "INTERFACE") &&
+ strcasecmp(*s, "IPV4") && strcasecmp(*s, "IPV6") &&
+ strcasecmp(*s, "UNPRIVILEGED")) {
fprintf(stderr, "Invalid key: %s\n", *s);
return;
}
printf("%-*s ", lht->ipv4_length, "IPV4");
else if (strcasecmp(*s, "IPV6") == 0)
printf("%-*s ", lht->ipv6_length, "IPV6");
+ else if (strcasecmp(*s, "UNPRIVILEGED") == 0)
+ printf("%-*s ", lht->unprivileged_length, "UNPRIVILEGED");
}
printf("\n");
printf("%-*s ", lht->ipv4_length, m->ipv4 ? m->ipv4 : "-");
} else if (strcasecmp(*s, "IPV6") == 0) {
printf("%-*s ", lht->ipv6_length, m->ipv6 ? m->ipv6 : "-");
+ } else if (strcasecmp(*s, "UNPRIVILEGED") == 0) {
+ printf("%-*s ", lht->unprivileged_length, m->unprivileged ? "true" : "false");
}
}
printf("\n");
printf("%-*s ", lht->groups_length, "GROUPS");
printf("%-*s ", lht->ipv4_length, "IPV4");
printf("%-*s ", lht->ipv6_length, "IPV6");
+ printf("%-*s ", lht->unprivileged_length, "UNPRIVILEGED");
printf("\n");
size_t i;
printf("%-*s ", lht->groups_length, m->groups ? m->groups : "-");
printf("%-*s ", lht->ipv4_length, m->ipv4 ? m->ipv4 : "-");
printf("%-*s ", lht->ipv6_length, m->ipv6 ? m->ipv6 : "-");
+ printf("%-*s ", lht->unprivileged_length, m->unprivileged ? "true" : "false");
printf("\n");
}
}
if (lxc_write_nointr(wpipefd, &n->running, (size_t)nbytes) != nbytes)
return -1;
+ nbytes = sizeof(n->unprivileged);
+ if (lxc_write_nointr(wpipefd, &n->unprivileged, (size_t)nbytes) != nbytes)
+ return -1;
+
nbytes = sizeof(n->nestlvl);
if (lxc_write_nointr(wpipefd, &n->nestlvl, (size_t)nbytes) != nbytes)
return -1;
if (lxc_read_nointr(rpipefd, &n->running, (size_t)nbytes) != nbytes)
return -1;
+ nbytes = sizeof(n->unprivileged);
+ if (lxc_read_nointr(rpipefd, &n->unprivileged, (size_t)nbytes) != nbytes)
+ return -1;
+
nbytes = sizeof(n->nestlvl);
if (lxc_read_nointr(rpipefd, &n->nestlvl, (size_t)nbytes) != nbytes)
return -1;