chiark
/
gitweb
/
~ianmdlvl
/
elogind.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
nspawn: fix truncation of machine names in interface names
[elogind.git]
/
src
/
nspawn
/
nspawn.c
diff --git
a/src/nspawn/nspawn.c
b/src/nspawn/nspawn.c
index 657512d661fcb0932d3a7409cb823225faad587b..b118c739e8c6b0f562b2daf14520d15443d420e4 100644
(file)
--- a/
src/nspawn/nspawn.c
+++ b/
src/nspawn/nspawn.c
@@
-395,7
+395,7
@@
static int parse_argv(int argc, char *argv[]) {
case ARG_CAPABILITY:
case ARG_DROP_CAPABILITY: {
case ARG_CAPABILITY:
case ARG_DROP_CAPABILITY: {
- char *state, *word;
+ c
onst c
har *state, *word;
size_t length;
FOREACH_WORD_SEPARATOR(word, length, optarg, ",", state) {
size_t length;
FOREACH_WORD_SEPARATOR(word, length, optarg, ",", state) {
@@
-1659,11
+1659,8
@@
static int setup_veth(pid_t pid, char iface_name[IFNAMSIZ], int *ifi) {
/* Use two different interface name prefixes depending whether
* we are in bridge mode or not. */
/* Use two different interface name prefixes depending whether
* we are in bridge mode or not. */
- if (arg_network_bridge)
- memcpy(iface_name, "vb-", 3);
- else
- memcpy(iface_name, "ve-", 3);
- strncpy(iface_name+3, arg_machine, IFNAMSIZ - 3);
+ snprintf(iface_name, IFNAMSIZ, "%s-%s",
+ arg_network_bridge ? "vb" : "ve", arg_machine);
r = get_mac(&mac);
if (r < 0) {
r = get_mac(&mac);
if (r < 0) {
@@
-2602,7
+2599,8
@@
static int spawn_getent(const char *database, const char *key, pid_t *rpid) {
}
static int change_uid_gid(char **_home) {
}
static int change_uid_gid(char **_home) {
- char line[LINE_MAX], *w, *x, *state, *u, *g, *h;
+ char line[LINE_MAX], *x, *u, *g, *h;
+ const char *word, *state;
_cleanup_free_ uid_t *uids = NULL;
_cleanup_free_ char *home = NULL;
_cleanup_fclose_ FILE *f = NULL;
_cleanup_free_ uid_t *uids = NULL;
_cleanup_free_ char *home = NULL;
_cleanup_fclose_ FILE *f = NULL;
@@
-2752,10
+2750,10
@@
static int change_uid_gid(char **_home) {
x += strcspn(x, WHITESPACE);
x += strspn(x, WHITESPACE);
x += strcspn(x, WHITESPACE);
x += strspn(x, WHITESPACE);
- FOREACH_WORD(w, l, x, state) {
+ FOREACH_WORD(w
ord
, l, x, state) {
char c[l+1];
char c[l+1];
- memcpy(c, w, l);
+ memcpy(c, w
ord
, l);
c[l] = 0;
if (!GREEDY_REALLOC(uids, sz, n_uids+1))
c[l] = 0;
if (!GREEDY_REALLOC(uids, sz, n_uids+1))
@@
-3073,13
+3071,13
@@
int main(int argc, char *argv[]) {
for (;;) {
ContainerStatus container_status;
for (;;) {
ContainerStatus container_status;
- _cleanup_(barrier_destroy) Barrier barrier =
{ }
;
+ _cleanup_(barrier_destroy) Barrier barrier =
BARRIER_NULL
;
struct sigaction sa = {
.sa_handler = nop_handler,
.sa_flags = SA_NOCLDSTOP,
};
struct sigaction sa = {
.sa_handler = nop_handler,
.sa_flags = SA_NOCLDSTOP,
};
- r = barrier_
init
(&barrier);
+ r = barrier_
create
(&barrier);
if (r < 0) {
log_error("Cannot initialize IPC barrier: %s", strerror(-r));
goto finish;
if (r < 0) {
log_error("Cannot initialize IPC barrier: %s", strerror(-r));
goto finish;