Merge lp:~gandelman-a/ubuntu/precise/cobbler-enlist/868492 into lp:ubuntu/precise/cobbler-enlist
- Precise (12.04)
- 868492
- Merge into precise
Status: | Merged |
---|---|
Merge reported by: | Dave Walker |
Merged at revision: | not available |
Proposed branch: | lp:~gandelman-a/ubuntu/precise/cobbler-enlist/868492 |
Merge into: | lp:ubuntu/precise/cobbler-enlist |
Diff against target: |
441 lines (+238/-75) 4 files modified
cobbler-enlist.c (+32/-15) cobbler-enlist.h (+168/-40) cobbler-xmlrpc.h (+30/-20) debian/changelog (+8/-0) |
To merge this branch: | bzr merge lp:~gandelman-a/ubuntu/precise/cobbler-enlist/868492 |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Dave Walker (community) | Approve | ||
Review via email: mp+80642@code.launchpad.net |
Commit message
Description of the change
Register all valid network interfaces when enlisting (LP: #868492)
This converts enlister->netif to a linked-list (enlister->netifs). Each node
of the LL is of struct netif, which contains an interface name and macaddr.
Any number of interfaces can be supplied via the command line. Each interface
is appended to the link list as a struct netif with the macaddr left NULL.
If no interfaces are supplied via argv, the list is populated with every
interface on the system (the macaddr for each left NULL).
What is contained in the enlister->netifs list is then verified. In the event
a non-existent interface was supplied via argv, it is removed from the list.
If enlister->netifs is empty (ie, none of the interfaces supplied actually
exist), die.
Nodes remaining in enlister->netifs get their mac addr's populated via ioctl.
Non-standard devices (ie, bridges not backed by any device) may contain a bad
mac addr, these are skipped. After populating, error out if the list does not
contain at least one valid mac address.
During system registration, loop over enlister->netifs and register each device.
On the cobbler side, the system ends up with something like:
# cobbler system dumpvars --name=testnode | grep mac_address_
mac_address_eth0 : 90:e6:ba:54:93:b9
mac_address_eth1 : 00:04:5a:5e:62:5f
mac_address_
mac_address_vnet0 : fe:16:3e:3e:a9:1a
mac_address_vnet1 : fe:54:00:4d:7e:a0
Cobbler will serve the profile via netboot to any of the interfaces.
C de-Avillez (hggdh2) wrote : | # |
Dave Walker (davewalker) wrote : | # |
@Carlos, If i read the comment correctly.. It should default to sending all mac addresses, but support comma separated list of interfaces it should use. This should also work via preseed (the real target), but I am concerned how this will work with cobbler generic preseeds (as it was my intention to ship default of register all interfaces)
thoughts?
Adam Gandelman (gandelman-a) wrote : | # |
To be clear, the default behavior after this patch is to register ALL valid interfaces+mac addrs on the system. If one or multiple interfaces is specified on the command line, those (and only those) interfaces+macaddrs will be registered.
It seems we're still determining how best to gather system information and post back. This change set provides the necessary internals to register multiple NICs + mac addrs, which is something that will be desired regardless of how decide to gather them. I predict we'll move from obtaining mac addrs via ioctl() to parsing it outside of cobbler-enlist. While the front end argv handling will likely change over time, the internal enlister->netifs changes here (which is the bulk of the patch) should meet our needs regardless.
- 9. By Adam Gandelman
-
Fix malloc() casting and memory initialization
C de-Avillez (hggdh2) wrote : | # |
@Daviey: A generic cobbler preseed could (and should, I think) default to all interfaces; those that need to enforce separation of usage can then adjust the preseed(s) as needed (I believe this is possible ;-). I would also expect that these customers would probably restrict to one, at most two interfaces.
Hum. We do not support, anymore, d-i selection of interfaces?
- 10. By Adam Gandelman
-
Add support for multiple network interfaces (convert enlister->netif
to linked list enlister->netifs). When no interfaces specified, defaults
to registering all interfaces on the system. (LP: #868492) - 11. By Adam Gandelman
-
Merge trunk
Dave Walker (davewalker) wrote : | # |
Changed the pocket and version, and uploaded
Thanks.
Preview Diff
1 | === modified file 'cobbler-enlist.c' | |||
2 | --- cobbler-enlist.c 2011-08-02 15:49:55 +0000 | |||
3 | +++ cobbler-enlist.c 2011-11-21 19:59:24 +0000 | |||
4 | @@ -48,13 +48,14 @@ | |||
5 | 48 | main (int const argc, char **argv) | 48 | main (int const argc, char **argv) |
6 | 49 | { | 49 | { |
7 | 50 | int rc; | 50 | int rc; |
8 | 51 | |||
9 | 52 | struct cobbler_client *enlister; | 51 | struct cobbler_client *enlister; |
10 | 53 | enlister = (struct cobbler_client *) malloc(sizeof(struct cobbler_client)); | 52 | enlister = (struct cobbler_client *) malloc(sizeof(struct cobbler_client)); |
11 | 53 | if (enlister == NULL) | ||
12 | 54 | die("malloc() failed for enlister- main()"); | ||
13 | 55 | memset(enlister, 0, sizeof(struct cobbler_client)); | ||
14 | 54 | init_client(enlister); | 56 | init_client(enlister); |
15 | 55 | int c; | 57 | int c; |
16 | 56 | 58 | ||
17 | 57 | //int this_option_optind = optind ? optind : 1; | ||
18 | 58 | int option_index = 0; | 59 | int option_index = 0; |
19 | 59 | 60 | ||
20 | 60 | const char* const short_options = "hds:u:p:n:P:i:m:"; | 61 | const char* const short_options = "hds:u:p:n:P:i:m:"; |
21 | @@ -67,7 +68,6 @@ | |||
22 | 67 | {"netif", 1, 0, 'i'}, | 68 | {"netif", 1, 0, 'i'}, |
23 | 68 | {"manclass", 1, 0, 'm'}, | 69 | {"manclass", 1, 0, 'm'}, |
24 | 69 | {"help", 0, 0, 'h'}, | 70 | {"help", 0, 0, 'h'}, |
25 | 70 | //{"default-interface", 1, 0, 0}, | ||
26 | 71 | {0, 0, 0, 0} | 71 | {0, 0, 0, 0} |
27 | 72 | }; | 72 | }; |
28 | 73 | 73 | ||
29 | @@ -111,9 +111,8 @@ | |||
30 | 111 | break; | 111 | break; |
31 | 112 | 112 | ||
32 | 113 | case 'i': | 113 | case 'i': |
34 | 114 | enlister->netif = optarg; | 114 | append_netif(enlister, optarg); |
35 | 115 | break; | 115 | break; |
36 | 116 | |||
37 | 117 | case 'm': | 116 | case 'm': |
38 | 118 | enlister->mgmt_class = optarg; | 117 | enlister->mgmt_class = optarg; |
39 | 119 | break; | 118 | break; |
40 | @@ -145,16 +144,30 @@ | |||
41 | 145 | (enlister->name == NULL) || | 144 | (enlister->name == NULL) || |
42 | 146 | (enlister->profile == NULL)) | 145 | (enlister->profile == NULL)) |
43 | 147 | { | 146 | { |
44 | 148 | fprintf(stderr, "[%s] ERROR: not all required parameters were passed\n", argv[0]); | ||
45 | 149 | help(argv[0]); | 147 | help(argv[0]); |
54 | 150 | exit (1); | 148 | die("Not all required parameters were passed"); |
55 | 151 | } | 149 | } |
56 | 152 | 150 | ||
57 | 153 | 151 | /* if no interfaces were specified on command line, add all interfaces on | |
58 | 154 | if ((rc = get_mac_address(enlister)) != 0) { | 152 | the system */ |
59 | 155 | printf("ERROR: Could not determine mac address for any interface on system.\n"); | 153 | if (!enlister->netifs) { |
60 | 156 | exit(1); | 154 | if (debug) |
61 | 157 | } | 155 | printf("[DEBUG] Populating netifs list with all interfaces on system.\n"); |
62 | 156 | struct if_nameindex *ifs = if_nameindex(); | ||
63 | 157 | while (ifs && ifs->if_name) { | ||
64 | 158 | if (strcasecmp(ifs->if_name, "lo") != 0) | ||
65 | 159 | append_netif(enlister, ifs->if_name); | ||
66 | 160 | ifs++; | ||
67 | 161 | } | ||
68 | 162 | } | ||
69 | 163 | |||
70 | 164 | /* ensure list isn't empty and all interfaces exist */ | ||
71 | 165 | if (verify_netifs(enlister) != 0) | ||
72 | 166 | die("Could not verify any of specified interfaces"); | ||
73 | 167 | |||
74 | 168 | /* get mac addresses for interfaces contained in enlister->netifs */ | ||
75 | 169 | if (get_mac_addresses(enlister) != 0) | ||
76 | 170 | die("Could not determine mac address for any interface on system."); | ||
77 | 158 | 171 | ||
78 | 159 | if (debug) | 172 | if (debug) |
79 | 160 | display_config(enlister); | 173 | display_config(enlister); |
80 | @@ -162,12 +175,16 @@ | |||
81 | 162 | /* Initialize our error-handling environment. */ | 175 | /* Initialize our error-handling environment. */ |
82 | 163 | if ((rc = init_xmlrpc_env(enlister)) != 0) | 176 | if ((rc = init_xmlrpc_env(enlister)) != 0) |
83 | 164 | goto out; | 177 | goto out; |
84 | 178 | /* Initialize the client */ | ||
85 | 165 | if ((rc = init_xmlrpc_client(enlister)) != 0) | 179 | if ((rc = init_xmlrpc_client(enlister)) != 0) |
86 | 166 | goto out; | 180 | goto out; |
87 | 181 | /* Login to cobbler */ | ||
88 | 167 | if ((rc = cobbler_login(enlister)) != 0) | 182 | if ((rc = cobbler_login(enlister)) != 0) |
89 | 168 | goto out; | 183 | goto out; |
91 | 169 | if ((rc = cobbler_register_system(enlister)) != 0) | 184 | /* Register new system with everything contained in the enlister */ |
92 | 185 | if ((rc = cobbler_register_system(enlister)) != 0) | ||
93 | 170 | goto out; | 186 | goto out; |
94 | 187 | /* Save the system */ | ||
95 | 171 | if ((rc = cobbler_save_system(enlister)) != 0) | 188 | if ((rc = cobbler_save_system(enlister)) != 0) |
96 | 172 | goto out; | 189 | goto out; |
97 | 173 | 190 | ||
98 | 174 | 191 | ||
99 | === modified file 'cobbler-enlist.h' | |||
100 | --- cobbler-enlist.h 2011-09-28 00:43:36 +0000 | |||
101 | +++ cobbler-enlist.h 2011-11-21 19:59:24 +0000 | |||
102 | @@ -38,6 +38,8 @@ | |||
103 | 38 | #define OPT_NETIF 5 | 38 | #define OPT_NETIF 5 |
104 | 39 | #define OPT_HELP 6 | 39 | #define OPT_HELP 6 |
105 | 40 | 40 | ||
106 | 41 | #define NO_MACADDR "00:00:00:00:00:00" | ||
107 | 42 | |||
108 | 41 | static int debug = 0; | 43 | static int debug = 0; |
109 | 42 | 44 | ||
110 | 43 | struct cobbler_client { | 45 | struct cobbler_client { |
111 | @@ -54,7 +56,16 @@ | |||
112 | 54 | const char *netif; | 56 | const char *netif; |
113 | 55 | const char *mgmt_class; | 57 | const char *mgmt_class; |
114 | 56 | const char *macaddr; | 58 | const char *macaddr; |
116 | 57 | }; | 59 | struct netif *netifs; |
117 | 60 | }; | ||
118 | 61 | |||
119 | 62 | struct netif { | ||
120 | 63 | const char *interface; | ||
121 | 64 | const char *macaddr; | ||
122 | 65 | struct netif *next; | ||
123 | 66 | }; | ||
124 | 67 | |||
125 | 68 | void get_netifs(struct cobbler_client *enlister); | ||
126 | 58 | 69 | ||
127 | 59 | int init_client(struct cobbler_client *enlister) { | 70 | int init_client(struct cobbler_client *enlister) { |
128 | 60 | enlister->client = NULL; | 71 | enlister->client = NULL; |
129 | @@ -68,6 +79,7 @@ | |||
130 | 68 | enlister->netif = NULL; | 79 | enlister->netif = NULL; |
131 | 69 | enlister->mgmt_class = NULL; | 80 | enlister->mgmt_class = NULL; |
132 | 70 | enlister->macaddr = NULL; | 81 | enlister->macaddr = NULL; |
133 | 82 | enlister->netifs = NULL; | ||
134 | 71 | return 0; | 83 | return 0; |
135 | 72 | } | 84 | } |
136 | 73 | 85 | ||
137 | @@ -78,11 +90,80 @@ | |||
138 | 78 | printf("\tpassword: %s\n", enlister->password); | 90 | printf("\tpassword: %s\n", enlister->password); |
139 | 79 | printf("\tname: %s\n", enlister->name); | 91 | printf("\tname: %s\n", enlister->name); |
140 | 80 | printf("\tprofile: %s\n", enlister->profile); | 92 | printf("\tprofile: %s\n", enlister->profile); |
143 | 81 | if (enlister->netif) | 93 | if (enlister->netifs) { |
144 | 82 | printf("\tnetif: %s\n", enlister->netif); | 94 | get_netifs(enlister); |
145 | 95 | } | ||
146 | 83 | if (enlister->mgmt_class) | 96 | if (enlister->mgmt_class) |
147 | 84 | printf("\tmgmt class: %s\n", enlister->mgmt_class); | 97 | printf("\tmgmt class: %s\n", enlister->mgmt_class); |
149 | 85 | printf("\tmac addr: %s\n", enlister->macaddr); | 98 | } |
150 | 99 | |||
151 | 100 | void get_netifs(struct cobbler_client *enlister) { | ||
152 | 101 | struct netif *current = enlister->netifs; | ||
153 | 102 | if (current == NULL) { | ||
154 | 103 | printf("Interface list is empty\n"); | ||
155 | 104 | return; | ||
156 | 105 | } | ||
157 | 106 | int i = 0; | ||
158 | 107 | while (current != NULL) { | ||
159 | 108 | printf("\tinterface %d: %s - %s\n", i, current->interface, current->macaddr); | ||
160 | 109 | i++; | ||
161 | 110 | current = current->next; | ||
162 | 111 | } | ||
163 | 112 | } | ||
164 | 113 | |||
165 | 114 | void die(char *msg) { | ||
166 | 115 | fprintf(stderr, "[ERROR] %s\n", msg); | ||
167 | 116 | exit(1); | ||
168 | 117 | } | ||
169 | 118 | |||
170 | 119 | /* append a new interface to the netifs list. macaddr remains empty | ||
171 | 120 | until populated by get_macaddresses() */ | ||
172 | 121 | int append_netif(struct cobbler_client *enlister, char *netif) { | ||
173 | 122 | if (debug) | ||
174 | 123 | printf("[DEBUG] Appending interface %s to enlister's netif list\n", netif); | ||
175 | 124 | struct netif *new_netif, *current; | ||
176 | 125 | new_netif = (struct netif *) malloc(sizeof(struct netif)); | ||
177 | 126 | if (new_netif == NULL) | ||
178 | 127 | die("malloc() - append_netif()"); | ||
179 | 128 | memset(new_netif, 0, sizeof(struct netif)); | ||
180 | 129 | new_netif->interface = netif; | ||
181 | 130 | new_netif->macaddr = NULL; | ||
182 | 131 | new_netif->next = NULL; | ||
183 | 132 | if (enlister->netifs == NULL) { | ||
184 | 133 | enlister->netifs = new_netif; | ||
185 | 134 | return 0; | ||
186 | 135 | } | ||
187 | 136 | int i; | ||
188 | 137 | current = enlister->netifs; | ||
189 | 138 | while (current->next != NULL) { | ||
190 | 139 | current = current->next; | ||
191 | 140 | i++; | ||
192 | 141 | } | ||
193 | 142 | current->next = new_netif; | ||
194 | 143 | return 0; | ||
195 | 144 | } | ||
196 | 145 | |||
197 | 146 | /* delete an interface from the netifs list */ | ||
198 | 147 | int remove_netif(struct cobbler_client *enlister, const char *interface) { | ||
199 | 148 | if (debug) | ||
200 | 149 | printf("[DEBUG] Removing from interface list: %s\n", interface); | ||
201 | 150 | struct netif *current = enlister->netifs; | ||
202 | 151 | int i = 0; | ||
203 | 152 | if (strcasecmp(current->interface, interface) == 0) { | ||
204 | 153 | enlister->netifs = current->next; | ||
205 | 154 | return 0; | ||
206 | 155 | } | ||
207 | 156 | i++; | ||
208 | 157 | while (current->next) { | ||
209 | 158 | if (strcasecmp(current->next->interface, interface) == 0) { | ||
210 | 159 | current->next = current->next->next; | ||
211 | 160 | return 0; | ||
212 | 161 | } | ||
213 | 162 | current = current->next; | ||
214 | 163 | i++; | ||
215 | 164 | } | ||
216 | 165 | printf("ERROR: NEtif: %s doesn't exist in enlister->netifs\n", interface); | ||
217 | 166 | return 1; | ||
218 | 86 | } | 167 | } |
219 | 87 | 168 | ||
220 | 88 | // Overide ether_ntoa_r because stock decides the convention of leading zeros is silly. | 169 | // Overide ether_ntoa_r because stock decides the convention of leading zeros is silly. |
221 | @@ -96,46 +177,93 @@ | |||
222 | 96 | return buf; | 177 | return buf; |
223 | 97 | } | 178 | } |
224 | 98 | 179 | ||
235 | 99 | int get_mac_address(struct cobbler_client *enlister) { | 180 | int interface_exists(const char *interface) { |
236 | 100 | if (debug) | 181 | if (debug) |
237 | 101 | printf("[DEBUG] get_mac_address()\n"); | 182 | printf("[DEBUG] Checking for interface: %s\n", interface); |
238 | 102 | 183 | struct if_nameindex *curif, *ifs = if_nameindex(); | |
239 | 103 | int fd; | 184 | for (curif = ifs; curif && curif->if_name; curif++) { |
240 | 104 | struct if_nameindex *curif, *ifs; | 185 | if (strcasecmp(interface, curif->if_name) == 0) |
241 | 105 | char mac_str[25]; | 186 | return 0; |
242 | 106 | char interface[255]; | 187 | } |
243 | 107 | char *macaddr = malloc(sizeof(mac_str)); | 188 | return 1; |
244 | 108 | 189 | } | |
245 | 190 | |||
246 | 191 | /* inspect each enlister->netifs. Make sure the interface exists on the system | ||
247 | 192 | Remove it from the list if it doesn't. | ||
248 | 193 | If we've cleaned the entire list because none of them exist, return 1. | ||
249 | 194 | Can/should be extended to do more verification? | ||
250 | 195 | */ | ||
251 | 196 | int verify_netifs(struct cobbler_client *enlister) { | ||
252 | 197 | struct netif *current = enlister->netifs; | ||
253 | 198 | while (current) { | ||
254 | 199 | if (interface_exists(current->interface) != 0) { | ||
255 | 200 | printf("[WARNING] Interface %s doesn't exist, removing.\n", current->interface); | ||
256 | 201 | remove_netif(enlister, current->interface); | ||
257 | 202 | } | ||
258 | 203 | current = current->next; | ||
259 | 204 | } | ||
260 | 205 | if (enlister->netifs == NULL) | ||
261 | 206 | return 1; | ||
262 | 207 | return 0; | ||
263 | 208 | } | ||
264 | 209 | |||
265 | 210 | /* utility function to test whether the netifs list contains at least | ||
266 | 211 | one mac address | ||
267 | 212 | */ | ||
268 | 213 | int contains_one_macaddr(struct cobbler_client *enlister) { | ||
269 | 214 | struct netif *current = enlister->netifs; | ||
270 | 215 | while (current) { | ||
271 | 216 | if ((current->macaddr != NULL) && | ||
272 | 217 | (strcasecmp(current->macaddr, NO_MACADDR) != 0)) { | ||
273 | 218 | return 0; | ||
274 | 219 | } | ||
275 | 220 | } | ||
276 | 221 | return 1; | ||
277 | 222 | } | ||
278 | 223 | |||
279 | 224 | char *get_interface_macaddr(const char *interface) { | ||
280 | 225 | if (debug) | ||
281 | 226 | printf("[DEBUG] Getting mac addr for interface %s\n", interface); | ||
282 | 227 | char mac_str[255]; | ||
283 | 228 | char *macaddr; | ||
284 | 109 | int ioctl_data = 0; | 229 | int ioctl_data = 0; |
285 | 110 | struct ifreq ifr; | 230 | struct ifreq ifr; |
310 | 111 | 231 | ioctl_data = socket(PF_INET, SOCK_STREAM, 0); | |
311 | 112 | if ((fd = socket (PF_INET, SOCK_DGRAM, 0)) != -1) { | 232 | memset(&ifr, 0, sizeof(ifr)); |
312 | 113 | ifs = if_nameindex (); | 233 | strncpy(ifr.ifr_name, interface, sizeof(interface)); |
313 | 114 | for (curif = ifs; curif && curif->if_name; curif++) { | 234 | ioctl(ioctl_data, SIOCGIFHWADDR, &ifr); |
314 | 115 | if (((enlister->netif == NULL) || | 235 | ether_ntoa_r((const struct ether_addr *) &(ifr.ifr_hwaddr.sa_data), mac_str); |
315 | 116 | (strcasecmp(enlister->netif, curif->if_name) == 0)) | 236 | macaddr = malloc(sizeof(mac_str)); |
316 | 117 | && (strcasecmp(curif->if_name, "lo") !=0)) { | 237 | if (macaddr == NULL) |
317 | 118 | 238 | die("malloc() - get_interface_macaddr()"); | |
318 | 119 | ioctl_data = socket (PF_INET, SOCK_STREAM, 0); | 239 | strncpy(macaddr, mac_str, sizeof(mac_str)); |
319 | 120 | memset (&ifr, 0, sizeof (ifr)); | 240 | return macaddr; |
320 | 121 | strncpy (ifr.ifr_name, curif->if_name, sizeof (ifr.ifr_name)); | 241 | } |
321 | 122 | strncpy (interface, curif->if_name, sizeof (interface)); | 242 | |
322 | 123 | ioctl (ioctl_data, SIOCGIFHWADDR, &ifr); | 243 | /* iterate through enlister->netifs, populating macaddr for each. |
323 | 124 | ether_ntoa_r( (const struct ether_addr *) | 244 | if we can't determine a valid mac addr, remove from list and continue |
324 | 125 | &(ifr.ifr_hwaddr.sa_data), mac_str); | 245 | returns non-zero if the resulting enlister->netifs does not contain at least |
325 | 126 | if (debug) | 246 | one mac addr. |
326 | 127 | printf("[DEBUG] Using interface: %s Addr: %s\n", interface, mac_str); | 247 | */ |
327 | 128 | if (enlister->netif == NULL) | 248 | int get_mac_addresses(struct cobbler_client *enlister) { |
328 | 129 | enlister->netif = curif->if_name; | 249 | if (debug) |
329 | 130 | strncpy(macaddr, mac_str, sizeof(mac_str)); | 250 | printf("[DEBUG] get_mac_address()\n"); |
330 | 131 | enlister->macaddr = macaddr; | 251 | const char *addr; |
331 | 132 | return 0; | 252 | struct netif *current = enlister->netifs; |
332 | 133 | } | 253 | while (current != NULL) { |
333 | 134 | } | 254 | addr = get_interface_macaddr(current->interface); |
334 | 255 | if (strcasecmp(addr, NO_MACADDR) == 0) { | ||
335 | 256 | printf("[WARNING] Could not determine mac addr for %s, skipping.\n", | ||
336 | 257 | current->interface); | ||
337 | 258 | remove_netif(enlister, current->interface); | ||
338 | 259 | } else { | ||
339 | 260 | current->macaddr = addr; | ||
340 | 261 | }; | ||
341 | 262 | current = current->next; | ||
342 | 135 | } | 263 | } |
343 | 264 | return contains_one_macaddr(enlister); | ||
344 | 265 | } | ||
345 | 136 | 266 | ||
346 | 137 | return 1; | ||
347 | 138 | } | ||
348 | 139 | void help(char *progname) | 267 | void help(char *progname) |
349 | 140 | { | 268 | { |
350 | 141 | printf("Usage: %s --help -- provides this help\n" , progname); | 269 | printf("Usage: %s --help -- provides this help\n" , progname); |
351 | 142 | 270 | ||
352 | === modified file 'cobbler-xmlrpc.h' | |||
353 | --- cobbler-xmlrpc.h 2011-08-02 15:49:55 +0000 | |||
354 | +++ cobbler-xmlrpc.h 2011-11-21 19:59:24 +0000 | |||
355 | @@ -109,7 +109,7 @@ | |||
356 | 109 | xmlrpc_value *token = xmlrpc_string_new(&enlister->env, enlister->token); | 109 | xmlrpc_value *token = xmlrpc_string_new(&enlister->env, enlister->token); |
357 | 110 | xmlrpc_value *name = xmlrpc_string_new(&enlister->env, enlister->name); | 110 | xmlrpc_value *name = xmlrpc_string_new(&enlister->env, enlister->name); |
358 | 111 | xmlrpc_value *profile = xmlrpc_string_new(&enlister->env, enlister->profile); | 111 | xmlrpc_value *profile = xmlrpc_string_new(&enlister->env, enlister->profile); |
360 | 112 | xmlrpc_value *macaddr = xmlrpc_string_new(&enlister->env, enlister->macaddr); | 112 | // xmlrpc_value *macaddr = xmlrpc_string_new(&enlister->env, enlister->macaddr); |
361 | 113 | 113 | ||
362 | 114 | /* used for forming modify_interface request */ | 114 | /* used for forming modify_interface request */ |
363 | 115 | xmlrpc_value *macaddr_struct = xmlrpc_struct_new(&enlister->env); | 115 | xmlrpc_value *macaddr_struct = xmlrpc_struct_new(&enlister->env); |
364 | @@ -162,23 +162,35 @@ | |||
365 | 162 | if ((rc = make_xmlrpc_call(enlister, "modify_system", argument_array)) != 0) | 162 | if ((rc = make_xmlrpc_call(enlister, "modify_system", argument_array)) != 0) |
366 | 163 | goto out; | 163 | goto out; |
367 | 164 | if (debug) | 164 | if (debug) |
385 | 165 | printf("[DEBUG] Modified system profile: %d\n", rc); | 165 | printf("[DEBUG] Modified system profile: %d\n", rc); |
386 | 166 | 166 | ||
387 | 167 | /* set its mac address */ | 167 | /* set its mac addresses */ |
388 | 168 | sprintf(macaddr_form_item, "macaddress-%s", enlister->netif); | 168 | struct netif *current_netif = enlister->netifs; |
389 | 169 | xmlrpc_struct_set_value(&enlister->env, macaddr_struct, | 169 | while (current_netif != NULL) { |
390 | 170 | macaddr_form_item, macaddr); | 170 | if (debug) { |
391 | 171 | argument_array = xmlrpc_array_new(&enlister->env); | 171 | printf("[DEBUG] Registering interface and macaddr: %s %s\n", |
392 | 172 | xmlrpc_array_append_item(&enlister->env, argument_array, system); | 172 | current_netif->interface, current_netif->macaddr); |
393 | 173 | xmlrpc_array_append_item(&enlister->env, argument_array, | 173 | } |
394 | 174 | xmlrpc_string_new(&enlister->env, "modify_interface")); | 174 | xmlrpc_value *macaddr = xmlrpc_string_new(&enlister->env, |
395 | 175 | xmlrpc_array_append_item(&enlister->env, argument_array, macaddr_struct); | 175 | current_netif->macaddr); |
396 | 176 | xmlrpc_array_append_item(&enlister->env, argument_array, token); | 176 | sprintf(macaddr_form_item, "macaddress-%s", current_netif->interface); |
397 | 177 | if ((rc = make_xmlrpc_call(enlister, "modify_system", argument_array)) != 0) | 177 | xmlrpc_struct_set_value(&enlister->env, macaddr_struct, |
398 | 178 | goto out; | 178 | macaddr_form_item, macaddr); |
399 | 179 | if (debug) | 179 | argument_array = xmlrpc_array_new(&enlister->env); |
400 | 180 | printf("[DEBUG] Modified interface: %d\n", rc); | 180 | xmlrpc_array_append_item(&enlister->env, argument_array, system); |
401 | 181 | 181 | xmlrpc_array_append_item(&enlister->env, argument_array, | |
402 | 182 | xmlrpc_string_new(&enlister->env, "modify_interface")); | ||
403 | 183 | xmlrpc_array_append_item(&enlister->env, argument_array, macaddr_struct); | ||
404 | 184 | xmlrpc_array_append_item(&enlister->env, argument_array, token); | ||
405 | 185 | if ((rc = make_xmlrpc_call(enlister, "modify_system", argument_array)) != 0) { | ||
406 | 186 | xmlrpc_DECREF(macaddr); | ||
407 | 187 | xmlrpc_DECREF(macaddr_struct); | ||
408 | 188 | goto out; | ||
409 | 189 | } | ||
410 | 190 | if (debug) | ||
411 | 191 | printf("[DEBUG] Modified interface: %d\n", rc); | ||
412 | 192 | current_netif = current_netif->next; | ||
413 | 193 | } | ||
414 | 182 | /* assign a mgmt class */ | 194 | /* assign a mgmt class */ |
415 | 183 | if (enlister->mgmt_class) { | 195 | if (enlister->mgmt_class) { |
416 | 184 | xmlrpc_value *mgmt_class = xmlrpc_string_new(&enlister->env, | 196 | xmlrpc_value *mgmt_class = xmlrpc_string_new(&enlister->env, |
417 | @@ -202,8 +214,6 @@ | |||
418 | 202 | xmlrpc_DECREF(name); | 214 | xmlrpc_DECREF(name); |
419 | 203 | xmlrpc_DECREF(profile); | 215 | xmlrpc_DECREF(profile); |
420 | 204 | xmlrpc_DECREF(system); | 216 | xmlrpc_DECREF(system); |
421 | 205 | xmlrpc_DECREF(macaddr); | ||
422 | 206 | xmlrpc_DECREF(macaddr_struct); | ||
423 | 207 | xmlrpc_DECREF(argument_array); | 217 | xmlrpc_DECREF(argument_array); |
424 | 208 | return rc; | 218 | return rc; |
425 | 209 | } | 219 | } |
426 | 210 | 220 | ||
427 | === modified file 'debian/changelog' | |||
428 | --- debian/changelog 2011-11-12 11:07:07 +0000 | |||
429 | +++ debian/changelog 2011-11-21 19:59:24 +0000 | |||
430 | @@ -1,3 +1,11 @@ | |||
431 | 1 | cobbler-enlist (0.2-1ubuntu1) oneiric; urgency=low | ||
432 | 2 | |||
433 | 3 | * Add support for multiple network interfaces (convert enlister->netif | ||
434 | 4 | to linked list enlister->netifs). When no interfaces specified, defaults | ||
435 | 5 | to registering all interfaces on the system. (LP: #868492) | ||
436 | 6 | |||
437 | 7 | -- Adam Gandelman <adamg@canonical.com> Mon, 21 Nov 2011 11:40:37 -0800 | ||
438 | 8 | |||
439 | 1 | cobbler-enlist (0.2-1build2) precise; urgency=low | 9 | cobbler-enlist (0.2-1build2) precise; urgency=low |
440 | 2 | 10 | ||
441 | 3 | * Rebuild for libxmlrpc-core-c3-udeb. | 11 | * Rebuild for libxmlrpc-core-c3-udeb. |
We should keep an option to select specific interfaces, both on install and run-time. There are environments where strict separation of interface usage is enforced, and selecting all interfaces will trigger an audit finding.