]>
git.proxmox.com Git - mirror_lxc.git/blob - src/lxc/confile_utils.c
1 /* SPDX-License-Identifier: LGPL-2.1+ */
15 #include "confile_utils.h"
19 #include "lxccontainer.h"
21 #include "memory_utils.h"
27 #include "include/strlcpy.h"
30 lxc_log_define(confile_utils
, lxc
);
32 int parse_idmaps(const char *idmap
, char *type
, unsigned long *nsid
,
33 unsigned long *hostid
, unsigned long *range
)
35 __do_free
char *dup
= NULL
;
37 unsigned long tmp_hostid
, tmp_nsid
, tmp_range
;
41 /* Duplicate string. */
44 return ret_errno(ENOMEM
);
46 /* A prototypical idmap entry would be: "u 1000 1000000 65536" */
51 slide
+= strspn(slide
, " \t\r");
52 if (slide
!= window
&& *slide
== '\0')
53 return ret_errno(EINVAL
);
56 if (*slide
!= 'u' && *slide
!= 'g')
57 return log_error_errno(-EINVAL
, EINVAL
, "Invalid id mapping type: %c", *slide
);
62 /* move beyond type */
66 /* Validate that only whitespace follows. */
67 slide
+= strspn(slide
, " \t\r");
68 /* There must be whitespace. */
70 return ret_errno(EINVAL
);
72 /* Mark beginning of nsid. */
74 /* Validate that non-whitespace follows. */
75 slide
+= strcspn(slide
, " \t\r");
76 /* There must be non-whitespace. */
77 if (slide
== window
|| *slide
== '\0')
78 return ret_errno(EINVAL
);
79 /* Mark end of nsid. */
83 ret
= lxc_safe_ulong(window
, &tmp_nsid
);
85 return log_error_errno(ret
, errno
, "Failed to parse nsid: %s", window
);
89 /* Validate that only whitespace follows. */
90 slide
+= strspn(slide
, " \t\r");
91 /* If there was only one whitespace then we whiped it with our \0 above.
92 * So only ensure that we're not at the end of the string.
95 return ret_errno(EINVAL
);
97 /* Mark beginning of hostid. */
99 /* Validate that non-whitespace follows. */
100 slide
+= strcspn(slide
, " \t\r");
101 /* There must be non-whitespace. */
102 if (slide
== window
|| *slide
== '\0')
103 return ret_errno(EINVAL
);
104 /* Mark end of nsid. */
108 ret
= lxc_safe_ulong(window
, &tmp_hostid
);
110 return log_error_errno(ret
, errno
, "Failed to parse hostid: %s", window
);
112 /* Move beyond \0. */
114 /* Validate that only whitespace follows. */
115 slide
+= strspn(slide
, " \t\r");
116 /* If there was only one whitespace then we whiped it with our \0 above.
117 * So only ensure that we're not at the end of the string.
120 return ret_errno(EINVAL
);
122 /* Mark beginning of range. */
124 /* Validate that non-whitespace follows. */
125 slide
+= strcspn(slide
, " \t\r");
126 /* There must be non-whitespace. */
128 return ret_errno(EINVAL
);
130 /* The range is the last valid entry we expect. So make sure that there
131 * is no trailing garbage and if there is, error out.
133 if (*(slide
+ strspn(slide
, " \t\r\n")) != '\0')
134 return ret_errno(EINVAL
);
136 /* Mark end of range. */
140 ret
= lxc_safe_ulong(window
, &tmp_range
);
142 return log_error_errno(ret
, errno
, "Failed to parse id mapping range: %s", window
);
146 *hostid
= tmp_hostid
;
149 /* Yay, we survived. */
153 bool lxc_config_value_empty(const char *value
)
155 if (value
&& strlen(value
) > 0)
161 struct lxc_netdev
*lxc_network_add(struct lxc_list
*networks
, int idx
, bool tail
)
163 __do_free
struct lxc_list
*newlist
= NULL
;
164 __do_free
struct lxc_netdev
*netdev
= NULL
;
166 /* network does not exist */
167 netdev
= malloc(sizeof(*netdev
));
169 return ret_set_errno(NULL
, ENOMEM
);
171 memset(netdev
, 0, sizeof(*netdev
));
172 lxc_list_init(&netdev
->ipv4
);
173 lxc_list_init(&netdev
->ipv6
);
175 /* give network a unique index */
178 /* prepare new list */
179 newlist
= malloc(sizeof(*newlist
));
181 return ret_set_errno(NULL
, ENOMEM
);
183 lxc_list_init(newlist
);
184 newlist
->elem
= netdev
;
187 lxc_list_add_tail(networks
, newlist
);
189 lxc_list_add(networks
, newlist
);
192 return move_ptr(netdev
);
195 /* Takes care of finding the correct netdev struct in the networks list or
196 * allocates a new one if it couldn't be found.
198 struct lxc_netdev
*lxc_get_netdev_by_idx(struct lxc_conf
*conf
,
199 unsigned int idx
, bool allocate
)
201 struct lxc_netdev
*netdev
= NULL
;
202 struct lxc_list
*networks
= &conf
->network
;
203 struct lxc_list
*insert
= networks
;
206 if (!lxc_list_empty(networks
)) {
207 lxc_list_for_each(insert
, networks
) {
208 netdev
= insert
->elem
;
209 if (netdev
->idx
== idx
)
211 else if (netdev
->idx
> idx
)
217 return ret_set_errno(NULL
, EINVAL
);
219 return lxc_network_add(insert
, idx
, true);
222 void lxc_log_configured_netdevs(const struct lxc_conf
*conf
)
224 struct lxc_netdev
*netdev
;
225 struct lxc_list
*it
= (struct lxc_list
*)&conf
->network
;;
227 if ((conf
->loglevel
!= LXC_LOG_LEVEL_TRACE
) &&
228 (lxc_log_get_level() != LXC_LOG_LEVEL_TRACE
))
231 if (lxc_list_empty(it
)) {
232 TRACE("container has no networks configured");
236 lxc_list_for_each(it
, &conf
->network
) {
237 struct lxc_list
*cur
, *next
;
238 struct lxc_inetdev
*inet4dev
;
239 struct lxc_inet6dev
*inet6dev
;
240 char bufinet4
[INET_ADDRSTRLEN
], bufinet6
[INET6_ADDRSTRLEN
];
244 TRACE("index: %zd", netdev
->idx
);
245 TRACE("ifindex: %d", netdev
->ifindex
);
247 switch (netdev
->type
) {
250 TRACE("veth mode: %d", netdev
->priv
.veth_attr
.mode
);
252 if (netdev
->priv
.veth_attr
.pair
[0] != '\0')
253 TRACE("veth pair: %s",
254 netdev
->priv
.veth_attr
.pair
);
256 if (netdev
->priv
.veth_attr
.veth1
[0] != '\0')
258 netdev
->priv
.veth_attr
.veth1
);
260 if (netdev
->priv
.veth_attr
.ifindex
> 0)
261 TRACE("host side ifindex for veth device: %d",
262 netdev
->priv
.veth_attr
.ifindex
);
264 if (netdev
->priv
.veth_attr
.vlan_id_set
)
265 TRACE("veth vlan id: %d", netdev
->priv
.veth_attr
.vlan_id
);
267 lxc_list_for_each_safe(cur
, &netdev
->priv
.veth_attr
.vlan_tagged_ids
, next
) {
268 unsigned short vlan_tagged_id
= PTR_TO_USHORT(cur
->elem
);
269 TRACE("veth vlan tagged id: %u", vlan_tagged_id
);
273 case LXC_NET_MACVLAN
:
274 TRACE("type: macvlan");
276 if (netdev
->priv
.macvlan_attr
.mode
> 0) {
279 mode
= lxc_macvlan_flag_to_mode(
280 netdev
->priv
.macvlan_attr
.mode
);
281 TRACE("macvlan mode: %s",
282 mode
? mode
: "(invalid mode)");
286 TRACE("type: ipvlan");
289 mode
= lxc_ipvlan_flag_to_mode(netdev
->priv
.ipvlan_attr
.mode
);
290 TRACE("ipvlan mode: %s", mode
? mode
: "(invalid mode)");
293 isolation
= lxc_ipvlan_flag_to_isolation(netdev
->priv
.ipvlan_attr
.isolation
);
294 TRACE("ipvlan isolation: %s", isolation
? isolation
: "(invalid isolation)");
298 TRACE("vlan id: %d", netdev
->priv
.vlan_attr
.vid
);
303 if (netdev
->priv
.phys_attr
.ifindex
> 0)
304 TRACE("host side ifindex for phys device: %d",
305 netdev
->priv
.phys_attr
.ifindex
);
308 TRACE("type: empty");
314 ERROR("Invalid network type %d", netdev
->type
);
318 if (netdev
->type
!= LXC_NET_EMPTY
) {
320 netdev
->flags
== IFF_UP
? "up" : "none");
322 if (netdev
->link
[0] != '\0')
323 TRACE("link: %s", netdev
->link
);
325 /* l2proxy only used when link is specified */
326 if (netdev
->link
[0] != '\0')
327 TRACE("l2proxy: %s", netdev
->l2proxy
? "true" : "false");
329 if (netdev
->name
[0] != '\0')
330 TRACE("name: %s", netdev
->name
);
333 TRACE("hwaddr: %s", netdev
->hwaddr
);
336 TRACE("mtu: %s", netdev
->mtu
);
338 if (netdev
->upscript
)
339 TRACE("upscript: %s", netdev
->upscript
);
341 if (netdev
->downscript
)
342 TRACE("downscript: %s", netdev
->downscript
);
344 TRACE("ipv4 gateway auto: %s",
345 netdev
->ipv4_gateway_auto
? "true" : "false");
347 TRACE("ipv4 gateway dev: %s",
348 netdev
->ipv4_gateway_dev
? "true" : "false");
350 if (netdev
->ipv4_gateway
) {
351 inet_ntop(AF_INET
, netdev
->ipv4_gateway
,
352 bufinet4
, sizeof(bufinet4
));
353 TRACE("ipv4 gateway: %s", bufinet4
);
356 lxc_list_for_each_safe(cur
, &netdev
->ipv4
, next
) {
357 inet4dev
= cur
->elem
;
358 inet_ntop(AF_INET
, &inet4dev
->addr
, bufinet4
,
360 TRACE("ipv4 addr: %s", bufinet4
);
363 TRACE("ipv6 gateway auto: %s",
364 netdev
->ipv6_gateway_auto
? "true" : "false");
366 TRACE("ipv6 gateway dev: %s",
367 netdev
->ipv6_gateway_dev
? "true" : "false");
369 if (netdev
->ipv6_gateway
) {
370 inet_ntop(AF_INET6
, netdev
->ipv6_gateway
,
371 bufinet6
, sizeof(bufinet6
));
372 TRACE("ipv6 gateway: %s", bufinet6
);
375 lxc_list_for_each_safe(cur
, &netdev
->ipv6
, next
) {
376 inet6dev
= cur
->elem
;
377 inet_ntop(AF_INET6
, &inet6dev
->addr
, bufinet6
,
379 TRACE("ipv6 addr: %s", bufinet6
);
382 if (netdev
->type
== LXC_NET_VETH
) {
383 lxc_list_for_each_safe(cur
, &netdev
->priv
.veth_attr
.ipv4_routes
, next
) {
384 inet4dev
= cur
->elem
;
385 if (!inet_ntop(AF_INET
, &inet4dev
->addr
, bufinet4
, sizeof(bufinet4
))) {
386 ERROR("Invalid ipv4 veth route");
390 TRACE("ipv4 veth route: %s/%u", bufinet4
, inet4dev
->prefix
);
393 lxc_list_for_each_safe(cur
, &netdev
->priv
.veth_attr
.ipv6_routes
, next
) {
394 inet6dev
= cur
->elem
;
395 if (!inet_ntop(AF_INET6
, &inet6dev
->addr
, bufinet6
, sizeof(bufinet6
))) {
396 ERROR("Invalid ipv6 veth route");
400 TRACE("ipv6 veth route: %s/%u", bufinet6
, inet6dev
->prefix
);
407 static void lxc_free_netdev(struct lxc_netdev
*netdev
)
409 struct lxc_list
*cur
, *next
;
414 free(netdev
->upscript
);
415 free(netdev
->downscript
);
416 free(netdev
->hwaddr
);
419 free(netdev
->ipv4_gateway
);
420 lxc_list_for_each_safe(cur
, &netdev
->ipv4
, next
) {
426 free(netdev
->ipv6_gateway
);
427 lxc_list_for_each_safe(cur
, &netdev
->ipv6
, next
) {
433 if (netdev
->type
== LXC_NET_VETH
) {
434 lxc_list_for_each_safe(cur
, &netdev
->priv
.veth_attr
.ipv4_routes
, next
) {
440 lxc_list_for_each_safe(cur
, &netdev
->priv
.veth_attr
.ipv6_routes
, next
) {
446 lxc_list_for_each_safe(cur
, &netdev
->priv
.veth_attr
.vlan_tagged_ids
, next
) {
455 define_cleanup_function(struct lxc_netdev
*, lxc_free_netdev
);
457 bool lxc_remove_nic_by_idx(struct lxc_conf
*conf
, unsigned int idx
)
459 call_cleaner(lxc_free_netdev
) struct lxc_netdev
*netdev
= NULL
;
460 struct lxc_list
*cur
, *next
;
462 lxc_list_for_each_safe(cur
, &conf
->network
, next
) {
464 if (netdev
->idx
!= idx
)
475 void lxc_free_networks(struct lxc_list
*networks
)
477 struct lxc_list
*cur
, *next
;
479 lxc_list_for_each_safe (cur
, networks
, next
) {
480 struct lxc_netdev
*netdev
= cur
->elem
;
482 lxc_free_netdev(netdev
);
486 /* prevent segfaults */
487 lxc_list_init(networks
);
490 static struct lxc_veth_mode
{
494 { "bridge", VETH_MODE_BRIDGE
},
495 { "router", VETH_MODE_ROUTER
},
498 int lxc_veth_mode_to_flag(int *mode
, const char *value
)
500 for (size_t i
= 0; i
< sizeof(veth_mode
) / sizeof(veth_mode
[0]); i
++) {
501 if (strcmp(veth_mode
[i
].name
, value
) != 0)
504 *mode
= veth_mode
[i
].mode
;
508 return ret_set_errno(-1, EINVAL
);
511 char *lxc_veth_flag_to_mode(int mode
)
513 for (size_t i
= 0; i
< sizeof(veth_mode
) / sizeof(veth_mode
[0]); i
++) {
514 if (veth_mode
[i
].mode
!= mode
)
517 return veth_mode
[i
].name
;
523 static struct lxc_macvlan_mode
{
527 { "private", MACVLAN_MODE_PRIVATE
},
528 { "vepa", MACVLAN_MODE_VEPA
},
529 { "bridge", MACVLAN_MODE_BRIDGE
},
530 { "passthru", MACVLAN_MODE_PASSTHRU
},
533 int lxc_macvlan_mode_to_flag(int *mode
, const char *value
)
537 for (i
= 0; i
< sizeof(macvlan_mode
) / sizeof(macvlan_mode
[0]); i
++) {
538 if (strcmp(macvlan_mode
[i
].name
, value
))
541 *mode
= macvlan_mode
[i
].mode
;
548 char *lxc_macvlan_flag_to_mode(int mode
)
552 for (i
= 0; i
< sizeof(macvlan_mode
) / sizeof(macvlan_mode
[0]); i
++) {
553 if (macvlan_mode
[i
].mode
!= mode
)
556 return macvlan_mode
[i
].name
;
562 static struct lxc_ipvlan_mode
{
566 { "l3", IPVLAN_MODE_L3
},
567 { "l3s", IPVLAN_MODE_L3S
},
568 { "l2", IPVLAN_MODE_L2
},
571 int lxc_ipvlan_mode_to_flag(int *mode
, const char *value
)
573 for (size_t i
= 0; i
< sizeof(ipvlan_mode
) / sizeof(ipvlan_mode
[0]); i
++) {
574 if (strcmp(ipvlan_mode
[i
].name
, value
) != 0)
577 *mode
= ipvlan_mode
[i
].mode
;
584 char *lxc_ipvlan_flag_to_mode(int mode
)
586 for (size_t i
= 0; i
< sizeof(ipvlan_mode
) / sizeof(ipvlan_mode
[0]); i
++) {
587 if (ipvlan_mode
[i
].mode
!= mode
)
590 return ipvlan_mode
[i
].name
;
596 static struct lxc_ipvlan_isolation
{
599 } ipvlan_isolation
[] = {
600 { "bridge", IPVLAN_ISOLATION_BRIDGE
},
601 { "private", IPVLAN_ISOLATION_PRIVATE
},
602 { "vepa", IPVLAN_ISOLATION_VEPA
},
605 int lxc_ipvlan_isolation_to_flag(int *flag
, const char *value
)
607 for (size_t i
= 0; i
< sizeof(ipvlan_isolation
) / sizeof(ipvlan_isolation
[0]); i
++) {
608 if (strcmp(ipvlan_isolation
[i
].name
, value
) != 0)
611 *flag
= ipvlan_isolation
[i
].flag
;
618 char *lxc_ipvlan_flag_to_isolation(int flag
)
620 for (size_t i
= 0; i
< sizeof(ipvlan_isolation
) / sizeof(ipvlan_isolation
[0]); i
++) {
621 if (ipvlan_isolation
[i
].flag
!= flag
)
624 return ipvlan_isolation
[i
].name
;
630 int set_config_string_item(char **conf_item
, const char *value
)
634 if (lxc_config_value_empty(value
)) {
640 new_value
= strdup(value
);
642 SYSERROR("Failed to duplicate string \"%s\"", value
);
647 *conf_item
= new_value
;
651 int set_config_string_item_max(char **conf_item
, const char *value
, size_t max
)
653 if (strlen(value
) >= max
) {
654 ERROR("%s is too long (>= %lu)", value
, (unsigned long)max
);
658 return set_config_string_item(conf_item
, value
);
661 int set_config_path_item(char **conf_item
, const char *value
)
663 return set_config_string_item_max(conf_item
, value
, PATH_MAX
);
666 int set_config_bool_item(bool *conf_item
, const char *value
, bool empty_conf_action
)
668 unsigned int val
= 0;
670 if (lxc_config_value_empty(value
)) {
671 *conf_item
= empty_conf_action
;
675 if (lxc_safe_uint(value
, &val
) < 0)
690 int config_ip_prefix(struct in_addr
*addr
)
692 if (IN_CLASSA(addr
->s_addr
))
693 return 32 - IN_CLASSA_NSHIFT
;
695 if (IN_CLASSB(addr
->s_addr
))
696 return 32 - IN_CLASSB_NSHIFT
;
698 if (IN_CLASSC(addr
->s_addr
))
699 return 32 - IN_CLASSC_NSHIFT
;
704 int network_ifname(char *valuep
, const char *value
, size_t size
)
708 if (!valuep
|| !value
)
711 retlen
= strlcpy(valuep
, value
, size
);
713 ERROR("Network device name \"%s\" is too long (>= %zu)", value
,
719 bool lxc_config_net_is_hwaddr(const char *line
)
724 if (strncmp(line
, "lxc.net", 7) != 0)
727 if (strncmp(line
, "lxc.net.hwaddr", 14) == 0)
730 if (strncmp(line
, "lxc.network.hwaddr", 18) == 0)
733 if (sscanf(line
, "lxc.net.%u.%6s", &index
, tmp
) == 2 ||
734 sscanf(line
, "lxc.network.%u.%6s", &index
, tmp
) == 2)
735 return strncmp(tmp
, "hwaddr", 6) == 0;
740 void rand_complete_hwaddr(char *hwaddr
)
742 const char hex
[] = "0123456789abcdef";
747 seed
= randseed(false);
750 (void)randseed(true);
753 while (*curs
!= '\0' && *curs
!= '\n') {
754 if (*curs
== 'x' || *curs
== 'X') {
755 if (curs
- hwaddr
== 1) {
756 /* ensure address is unicast */
758 *curs
= hex
[rand_r(&seed
) & 0x0E];
760 *curs
= hex
[rand_r(&seed
) & 0x0F];
762 *curs
= hex
[rand() & 0x0E];
764 *curs
= hex
[rand() & 0x0F];
772 bool new_hwaddr(char *hwaddr
)
778 seed
= randseed(false);
780 ret
= snprintf(hwaddr
, 18, "00:16:3e:%02x:%02x:%02x", rand_r(&seed
) % 255,
781 rand_r(&seed
) % 255, rand_r(&seed
) % 255);
784 (void)randseed(true);
786 ret
= snprintf(hwaddr
, 18, "00:16:3e:%02x:%02x:%02x", rand() % 255,
787 rand() % 255, rand() % 255);
789 if (ret
< 0 || ret
>= 18) {
790 SYSERROR("Failed to call snprintf()");
797 int lxc_get_conf_str(char *retv
, int inlen
, const char *value
)
804 value_len
= strlen(value
);
805 if (retv
&& inlen
>= value_len
+ 1)
806 memcpy(retv
, value
, value_len
+ 1);
811 int lxc_get_conf_bool(struct lxc_conf
*c
, char *retv
, int inlen
, bool v
)
819 memset(retv
, 0, inlen
);
821 strprint(retv
, inlen
, "%d", v
);
826 int lxc_get_conf_int(struct lxc_conf
*c
, char *retv
, int inlen
, int v
)
834 memset(retv
, 0, inlen
);
836 strprint(retv
, inlen
, "%d", v
);
841 int lxc_get_conf_size_t(struct lxc_conf
*c
, char *retv
, int inlen
, size_t v
)
849 memset(retv
, 0, inlen
);
851 strprint(retv
, inlen
, "%zu", v
);
856 int lxc_get_conf_uint64(struct lxc_conf
*c
, char *retv
, int inlen
, uint64_t v
)
864 memset(retv
, 0, inlen
);
866 strprint(retv
, inlen
, "%"PRIu64
, v
);
871 static int lxc_container_name_to_pid(const char *lxcname_or_pid
,
878 pid
= strtol(lxcname_or_pid
, &err
, 10);
879 if (*err
!= '\0' || pid
< 1) {
880 struct lxc_container
*c
;
882 c
= lxc_container_new(lxcname_or_pid
, lxcpath
);
884 ERROR("\"%s\" is not a valid pid nor a container name",
889 if (!c
->may_control(c
)) {
890 ERROR("Insufficient privileges to control container "
892 lxc_container_put(c
);
896 pid
= c
->init_pid(c
);
898 ERROR("Container \"%s\" is not running", c
->name
);
899 lxc_container_put(c
);
903 lxc_container_put(c
);
908 SYSERROR("Failed to send signal to pid %d", (int)pid
);
915 int lxc_inherit_namespace(const char *nsfd_path
, const char *lxcpath
,
916 const char *namespace)
919 char *dup
, *lastslash
;
921 if (nsfd_path
[0] == '/') {
922 return open(nsfd_path
, O_RDONLY
| O_CLOEXEC
);
925 lastslash
= strrchr(nsfd_path
, '/');
927 dup
= strdup(nsfd_path
);
931 dup
[lastslash
- nsfd_path
] = '\0';
932 pid
= lxc_container_name_to_pid(lastslash
+ 1, dup
);
935 pid
= lxc_container_name_to_pid(nsfd_path
, lxcpath
);
941 fd
= lxc_preserve_ns(pid
, namespace);
953 static const struct signame signames
[] = {
986 { SIGSTKFLT
, "STKFLT" },
1001 { SIGVTALRM
, "VTALRM" },
1004 { SIGPROF
, "PROF" },
1007 { SIGWINCH
, "WINCH" },
1013 { SIGPOLL
, "POLL" },
1016 { SIGINFO
, "INFO" },
1019 { SIGLOST
, "LOST" },
1025 { SIGUNUSED
, "UNUSED" },
1032 static int sig_num(const char *sig
)
1034 unsigned int signum
;
1036 if (lxc_safe_uint(sig
, &signum
) < 0)
1042 static int rt_sig_num(const char *signame
)
1044 int rtmax
= 0, sig_n
= 0;
1046 if (strncasecmp(signame
, "max-", 4) == 0)
1050 if (!isdigit(*signame
))
1053 sig_n
= sig_num(signame
);
1054 sig_n
= rtmax
? SIGRTMAX
- sig_n
: SIGRTMIN
+ sig_n
;
1055 if (sig_n
> SIGRTMAX
|| sig_n
< SIGRTMIN
)
1061 int sig_parse(const char *signame
)
1065 if (isdigit(*signame
)) {
1066 return sig_num(signame
);
1067 } else if (strncasecmp(signame
, "sig", 3) == 0) {
1069 if (strncasecmp(signame
, "rt", 2) == 0)
1070 return rt_sig_num(signame
+ 2);
1072 for (n
= 0; n
< sizeof(signames
) / sizeof((signames
)[0]); n
++)
1073 if (strcasecmp(signames
[n
].name
, signame
) == 0)
1074 return signames
[n
].num
;