Gentoo Archives: gentoo-commits

From: "Christian Zoffoli (xmerlin)" <xmerlin@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] gentoo-x86 commit in sys-cluster/fence/files: fence-2.03.09-ipmi_fix_help_typo_RH_BZ_210687.patch fence-2.03.09-ipmi_lan_timeout_adjusted_and_configurable.patch fence-2.03.09-ipmi_fix_shell.patch fence-2.03.09-ipmi_fix_parameters_RH_BZ_447964.patch
Date: Sat, 22 Nov 2008 14:12:17
Message-Id: E1L3tDZ-0002wv-4N@stork.gentoo.org
1 xmerlin 08/11/22 14:12:13
2
3 Added: fence-2.03.09-ipmi_fix_help_typo_RH_BZ_210687.patch
4 fence-2.03.09-ipmi_lan_timeout_adjusted_and_configurable.patch
5 fence-2.03.09-ipmi_fix_shell.patch
6 fence-2.03.09-ipmi_fix_parameters_RH_BZ_447964.patch
7 Log:
8 Merged some IPMI fixes.
9 (Portage version: 2.1.4.4)
10
11 Revision Changes Path
12 1.1 sys-cluster/fence/files/fence-2.03.09-ipmi_fix_help_typo_RH_BZ_210687.patch
13
14 file : http://sources.gentoo.org/viewcvs.py/gentoo-x86/sys-cluster/fence/files/fence-2.03.09-ipmi_fix_help_typo_RH_BZ_210687.patch?rev=1.1&view=markup
15 plain: http://sources.gentoo.org/viewcvs.py/gentoo-x86/sys-cluster/fence/files/fence-2.03.09-ipmi_fix_help_typo_RH_BZ_210687.patch?rev=1.1&content-type=text/plain
16
17 Index: fence-2.03.09-ipmi_fix_help_typo_RH_BZ_210687.patch
18 ===================================================================
19 From: Jan Friesse <jfriesse@××××××.com>
20 Date: Thu, 20 Nov 2008 11:52:21 +0000 (+0100)
21 Subject: fence: fix IPMI typo in help
22 X-Git-Url: http://git.fedorahosted.org/git/cluster.git?p=cluster.git;a=commitdiff_plain;h=47514a9ac69f4b6ef0bcd87a2763de24dff12f5d
23
24 fence: fix IPMI typo in help
25
26 Help contained description of -i option with comment,
27 that this option is deprecated and you should use -i. This
28 is nice recursion, but there should be -a.
29
30 This fixes BZ #210687
31 ---
32
33 diff --git a/fence/agents/ipmilan/ipmilan.c b/fence/agents/ipmilan/ipmilan.c
34 index 30d69ee..358274a 100644
35 --- a/fence/agents/ipmilan/ipmilan.c
36 +++ b/fence/agents/ipmilan/ipmilan.c
37 @@ -687,7 +687,7 @@ usage_exit(char *pname)
38 printf("usage: %s <options>\n", pname);
39 printf(" -A <authtype> IPMI Lan Auth type (md5, password, or none)\n");
40 printf(" -a <ipaddr> IPMI Lan IP to talk to\n");
41 -printf(" -i <ipaddr> IPMI Lan IP to talk to (deprecated, use -i)\n");
42 +printf(" -i <ipaddr> IPMI Lan IP to talk to (deprecated, use -a)\n");
43 printf(" -p <password> Password (if required) to control power on\n"
44 " IPMI device\n");
45 printf(" -P Use Lanplus\n");
46
47
48
49 1.1 sys-cluster/fence/files/fence-2.03.09-ipmi_lan_timeout_adjusted_and_configurable.patch
50
51 file : http://sources.gentoo.org/viewcvs.py/gentoo-x86/sys-cluster/fence/files/fence-2.03.09-ipmi_lan_timeout_adjusted_and_configurable.patch?rev=1.1&view=markup
52 plain: http://sources.gentoo.org/viewcvs.py/gentoo-x86/sys-cluster/fence/files/fence-2.03.09-ipmi_lan_timeout_adjusted_and_configurable.patch?rev=1.1&content-type=text/plain
53
54 Index: fence-2.03.09-ipmi_lan_timeout_adjusted_and_configurable.patch
55 ===================================================================
56 From: Jan Friesse <jfriesse@××××××.com>
57 Date: Wed, 19 Nov 2008 16:50:03 +0000 (+0100)
58 Subject: fence: IPMI over lan timeout adjusted and configurable
59 X-Git-Url: http://git.fedorahosted.org/git/cluster.git?p=cluster.git;a=commitdiff_plain;h=59229fddbf3c15c2279e4841c443e7a60a6799a6
60
61 fence: IPMI over lan timeout adjusted and configurable
62
63 This patch adjust timeout to default value 10s which
64 should be enough for most today IPMI implementations.
65 It also removes retries, because this job is done
66 by fenced.
67
68 Because some devices still need longer timeouts,
69 timeout is adjustable by parameter -t (or timeout for stdin
70 and XML configuration).
71
72 This should fix BZ: 401481, 276541 and 452894
73 ---
74
75 diff --git a/fence/agents/ipmilan/ipmilan.c b/fence/agents/ipmilan/ipmilan.c
76 index 3b4987b..117228c 100644
77 --- a/fence/agents/ipmilan/ipmilan.c
78 +++ b/fence/agents/ipmilan/ipmilan.c
79 @@ -26,6 +26,8 @@
80 #define ST_POWEROFF 2
81 #define ST_GENERIC_RESET 3
82
83 +#define DEFAULT_TIMEOUT 10
84 +
85 #define log(lvl, fmt, args...) fprintf(stderr, fmt, ##args)
86 #include <libgen.h>
87 #include <copyright.cf>
88 @@ -59,6 +61,7 @@ struct ipmi {
89 int i_config;
90 int i_verbose;
91 int i_lanplus;
92 + int i_timeout;
93 };
94
95
96 @@ -276,42 +279,25 @@ static int
97 ipmi_op(struct ipmi *ipmi, int op, struct Etoken *toklist)
98 {
99 char cmd[2048];
100 - int retries = 5;
101 int ret;
102
103 build_cmd(cmd, sizeof(cmd), ipmi, op);
104
105 if (ipmi_spawn(ipmi, cmd) != 0)
106 return -1;
107 - ret = ipmi_expect(ipmi, toklist, 120);
108 + ret = ipmi_expect(ipmi, toklist, ipmi->i_timeout);
109 ipmi_reap(ipmi);
110
111 - while ((ret == EAGAIN || ret == ETIMEDOUT) && retries > 0) {
112 - dbg_printf(ipmi, 3, "Sleeping 5 ...\n");
113 - sleep(5);
114 - dbg_printf(ipmi, 1, "Retrying ...\n");
115 - --retries;
116 -
117 - if (ipmi_spawn(ipmi, cmd) != 0)
118 - return -1;
119 - ret = ipmi_expect(ipmi, toklist, 120);
120 - if (ret == EFAULT) {
121 - /* Doomed. */
122 - break;
123 - }
124 - ipmi_reap(ipmi);
125 - }
126 -
127 if (ret == EFAULT) {
128 log(LOG_CRIT, "ipmilan: ipmitool failed to create "
129 "mutex; unable to complete operation\n");
130 return ret;
131 }
132
133 - if (ret == EAGAIN) {
134 + if (ret == ETIMEDOUT) {
135 /*!!! Still couldn't get through?! */
136 log(LOG_WARNING,
137 - "ipmilan: Failed to connect after 30 seconds\n");
138 + "ipmilan: Failed to connect after %d seconds\n",ipmi->i_timeout);
139 }
140
141 return ret;
142 @@ -432,7 +418,7 @@ ipmi_destroy(struct ipmi *i)
143 */
144 static struct ipmi *
145 ipmi_init(struct ipmi *i, char *host, char *authtype,
146 - char *user, char *password, int lanplus, int verbose)
147 + char *user, char *password, int lanplus, int verbose,int timeout)
148 {
149 const char *p;
150
151 @@ -503,6 +489,7 @@ ipmi_init(struct ipmi *i, char *host, char *authtype,
152 i->i_id = IPMIID;
153 i->i_verbose = verbose;
154 i->i_lanplus = lanplus;
155 + i->i_timeout = timeout;
156
157 return i;
158 }
159 @@ -565,7 +552,7 @@ get_options_stdin(char *ip, size_t iplen,
160 char *pwd_script, size_t pwd_script_len,
161 char *user, size_t userlen,
162 char *op, size_t oplen,
163 - int *lanplus, int *verbose)
164 + int *lanplus, int *verbose,int *timeout)
165 {
166 char in[256];
167 int line = 0;
168 @@ -627,6 +614,10 @@ get_options_stdin(char *ip, size_t iplen,
169 user[0] = 0;
170 } else if (!strcasecmp(name, "lanplus")) {
171 (*lanplus) = 1;
172 + } else if (!strcasecmp(name,"timeout")) {
173 + if ((sscanf(val,"%d",timeout)!=1) || *timeout<1) {
174 + *timeout=DEFAULT_TIMEOUT;
175 + }
176 } else if (!strcasecmp(name, "option") ||
177 !strcasecmp(name, "operation") ||
178 !strcasecmp(name, "action")) {
179 @@ -666,6 +657,7 @@ printf(" -l <login> Username/Login (if required) to control power\n"
180 " on IPMI device\n");
181 printf(" -o <op> Operation to perform.\n");
182 printf(" Valid operations: on, off, reboot, status\n");
183 +printf(" -t <timeout> Timeout (sec) for IPMI operation (default %d)\n",DEFAULT_TIMEOUT);
184 printf(" -V Print version and exit\n");
185 printf(" -v Verbose mode\n\n");
186 printf("If no options are specified, the following options will be read\n");
187 @@ -679,6 +671,7 @@ printf(" login=<login> Same as -u\n");
188 printf(" option=<op> Same as -o\n");
189 printf(" operation=<op> Same as -o\n");
190 printf(" action=<op> Same as -o\n");
191 +printf(" timeout=<timeout> Same as -t\n");
192 printf(" verbose Same as -v\n\n");
193 exit(1);
194 }
195 @@ -699,6 +692,7 @@ main(int argc, char **argv)
196 int verbose=0;
197 char *pname = basename(argv[0]);
198 struct ipmi *i;
199 + int timeout=DEFAULT_TIMEOUT;
200
201 memset(ip, 0, sizeof(ip));
202 memset(authtype, 0, sizeof(authtype));
203 @@ -710,7 +704,7 @@ main(int argc, char **argv)
204 /*
205 Parse command line options if any were specified
206 */
207 - while ((opt = getopt(argc, argv, "A:a:i:l:p:S:Po:vV?hH")) != EOF) {
208 + while ((opt = getopt(argc, argv, "A:a:i:l:p:S:Po:vV?hHt:")) != EOF) {
209 switch(opt) {
210 case 'A':
211 /* Auth type */
212 @@ -740,6 +734,12 @@ main(int argc, char **argv)
213 /* Operation */
214 strncpy(op, optarg, sizeof(op));
215 break;
216 + case 't':
217 + /* Timeout */
218 + if ((sscanf(optarg,"%d",&timeout)!=1) || timeout<1) {
219 + fail_exit("Timeout option expects positive number parameter");
220 + }
221 + break;
222 case 'v':
223 verbose++;
224 break;
225 @@ -763,7 +763,7 @@ main(int argc, char **argv)
226 passwd, sizeof(passwd),
227 pwd_script, sizeof(pwd_script),
228 user, sizeof(user),
229 - op, sizeof(op), &lanplus, &verbose) != 0)
230 + op, sizeof(op), &lanplus, &verbose,&timeout) != 0)
231 return 1;
232 }
233
234 @@ -813,7 +813,7 @@ main(int argc, char **argv)
235
236
237 /* Ok, set up the IPMI struct */
238 - i = ipmi_init(NULL, ip, authtype, user, passwd, lanplus, verbose);
239 + i = ipmi_init(NULL, ip, authtype, user, passwd, lanplus, verbose, timeout);
240 if (!i)
241 fail_exit("Failed to initialize\n");
242
243 From: Jan Friesse <jfriesse@××××××.com>
244 Date: Thu, 20 Nov 2008 16:45:01 +0000 (+0100)
245 Subject: fence: fix IPMI man page
246 X-Git-Url: http://git.fedorahosted.org/git/cluster.git?p=cluster.git;a=commitdiff_plain;h=49885167a5b1d8a848ae6b747865d716026375e7
247
248 fence: fix IPMI man page
249
250 Documented timeout (-t) option.
251 ---
252
253 diff --git a/fence/man/fence_ipmilan.8 b/fence/man/fence_ipmilan.8
254 index 0d68d68..394804d 100644
255 --- a/fence/man/fence_ipmilan.8
256 +++ b/fence/man/fence_ipmilan.8
257 @@ -44,6 +44,11 @@ Use the lanplus option if this is a lanplus capable interface (for example iLo2)
258 \fB-A\fP \fIAuthentication Type\fP
259 Can be set to none, password, md2, or md5.
260 .TP
261 +\fB-t\fP \fItimeout\fP
262 +Timeout in seconds for IPMI operation. Default is 10, but in some cases it
263 +must be set to higher value (anything above 30 is not recommended and may
264 +cause strange problems).
265 +.TP
266 \fB-q\fP
267 Quiet operation. Only print out error messages.
268 .TP
269 @@ -73,6 +78,11 @@ Full path to an executable to generate the password for login.
270 \fIauth = < param >\fR
271 Authentication type (none, password, md2, md5).
272 .TP
273 +\fItimeout = < param >\fR
274 +Timeout in seconds for IPMI operation. Default is 10, but in some cases it
275 +must be set to higher value (anything above 30 is not recommended and may
276 +cause strange problems).
277 +.TP
278 \fIlanplus\fR
279 If we are using the lanplus option for ipmitool
280
281
282
283
284 1.1 sys-cluster/fence/files/fence-2.03.09-ipmi_fix_shell.patch
285
286 file : http://sources.gentoo.org/viewcvs.py/gentoo-x86/sys-cluster/fence/files/fence-2.03.09-ipmi_fix_shell.patch?rev=1.1&view=markup
287 plain: http://sources.gentoo.org/viewcvs.py/gentoo-x86/sys-cluster/fence/files/fence-2.03.09-ipmi_fix_shell.patch?rev=1.1&content-type=text/plain
288
289 Index: fence-2.03.09-ipmi_fix_shell.patch
290 ===================================================================
291 From: Jan Friesse <jfriesse@××××××.com>
292 Date: Thu, 20 Nov 2008 13:39:20 +0000 (+0100)
293 Subject: fence: fix IPMI spawn /bin/bash rather than /bin/sh
294 X-Git-Url: http://git.fedorahosted.org/git/cluster.git?p=cluster.git;a=commitdiff_plain;h=d57fba422b8c5822bc751cc190277367e42ad597
295
296 fence: fix IPMI spawn /bin/bash rather than /bin/sh
297
298 It's not guaranteed, that /bin/sh will be symlink to
299 shell, which is bash (or ksh) compliant, so it's better
300 to use /bin/bash.
301 ---
302
303 diff --git a/fence/agents/ipmilan/expect.c b/fence/agents/ipmilan/expect.c
304 index 4156886..fa85bd8 100644
305 --- a/fence/agents/ipmilan/expect.c
306 +++ b/fence/agents/ipmilan/expect.c
307 @@ -304,7 +304,7 @@ StartProcess(const char * cmd, int * readfd, int * writefd, int flags)
308 sched_setscheduler(0, SCHED_OTHER, &sp);
309 }
310 #endif
311 - execlp("/bin/sh", "sh", "-c", cmd, NULL);
312 + execlp("/bin/bash", "bash", "-c", cmd, NULL);
313 perror("cannot exec shell!");
314 exit(1);
315
316
317
318
319 1.1 sys-cluster/fence/files/fence-2.03.09-ipmi_fix_parameters_RH_BZ_447964.patch
320
321 file : http://sources.gentoo.org/viewcvs.py/gentoo-x86/sys-cluster/fence/files/fence-2.03.09-ipmi_fix_parameters_RH_BZ_447964.patch?rev=1.1&view=markup
322 plain: http://sources.gentoo.org/viewcvs.py/gentoo-x86/sys-cluster/fence/files/fence-2.03.09-ipmi_fix_parameters_RH_BZ_447964.patch?rev=1.1&content-type=text/plain
323
324 Index: fence-2.03.09-ipmi_fix_parameters_RH_BZ_447964.patch
325 ===================================================================
326 From: Jan Friesse <jfriesse@××××××.com>
327 Date: Thu, 20 Nov 2008 11:51:20 +0000 (+0100)
328 Subject: fence: fix IPMI parameters containing special characters
329 X-Git-Url: http://git.fedorahosted.org/git/cluster.git?p=cluster.git;a=commitdiff_plain;h=6c1a7ce96b7712e85d3cb765ca9dd58061d6a25b
330
331 fence: fix IPMI parameters containing special characters
332
333 IPMI fence agent works by spawn a /bin/sh and ipmitool.
334 If host name/password or any other command line argument
335 included special shell characters (like $, ", ', ...) shell
336 will try to substitute. This is not allowed behaviour and
337 this patch fix it.
338
339 Should fix BZ #447964
340 ---
341
342 diff --git a/fence/agents/ipmilan/ipmilan.c b/fence/agents/ipmilan/ipmilan.c
343 index 117228c..30d69ee 100644
344 --- a/fence/agents/ipmilan/ipmilan.c
345 +++ b/fence/agents/ipmilan/ipmilan.c
346 @@ -138,34 +138,73 @@ ipmitool_path(void)
347 }
348
349
350 +/** Prepare string for use in sh style environment. This function take source
351 + string and prepend/append quote (') to start/end of source string to dest
352 + string. Any occurence of quote in source string is replaced by '\'' sequence.
353 + Dest string must be preallocated.
354 +
355 + @param dest Destination string
356 + @param source Source string
357 + @param max_len Maximum length of data written to dest string (including end 0)
358 + @return Pointer to start of destination string.
359 +*/
360 +char *str_prepare_for_sh(char *dest,char *source,int max_len) {
361 + char *dest_p=dest;
362 + char *max_dest=dest+max_len;
363 +
364 + if (dest_p+1>=max_dest) {*dest_p=0;return dest;}
365 + *dest_p++='\'';
366 +
367 + while (*source) {
368 + if (*source=='\'') {
369 + if (dest_p+4>=max_dest) {*dest_p=0;return dest;}
370 +
371 + memcpy(dest_p,"'\\''",4);dest_p+=4;
372 + } else {
373 + if (dest_p+1>=max_dest) {*dest_p=0;return dest;}
374 +
375 + *dest_p++=*source;
376 + }
377 + source++;
378 + }
379 +
380 + if (dest_p+2>=max_dest) {*dest_p=0;return dest;}
381 +
382 + *dest_p++='\'';*dest_p=0;
383 +
384 + return dest;
385 +}
386 +
387 static int
388 build_cmd(char *command, size_t cmdlen, struct ipmi *ipmi, int op)
389 {
390 char cmd[2048];
391 char arg[2048];
392 + char tmp[2048];
393 int x;
394
395 /* Store path */
396 if (ipmi->i_lanplus) {
397 - snprintf(cmd, sizeof(cmd), "%s -I lanplus -H %s",
398 - ipmi->i_ipmitool, ipmi->i_host);
399 + snprintf(cmd, sizeof(cmd), "%s -I lanplus -H %s",
400 + ipmi->i_ipmitool,
401 + str_prepare_for_sh(tmp,ipmi->i_host,sizeof(tmp)));
402 } else {
403 snprintf(cmd, sizeof(cmd), "%s -I lan -H %s", ipmi->i_ipmitool,
404 - ipmi->i_host);
405 + str_prepare_for_sh(tmp,ipmi->i_host,sizeof(tmp)));
406 }
407
408 if (ipmi->i_user) {
409 - snprintf(arg, sizeof(arg), " -U %s", ipmi->i_user);
410 + snprintf(arg, sizeof(arg), " -U %s", str_prepare_for_sh(tmp,ipmi->i_user,sizeof(tmp)));
411 strncat(cmd, arg, sizeof(cmd) - strlen(arg));
412 }
413
414 if (ipmi->i_authtype) {
415 - snprintf(arg, sizeof(arg), " -A %s", ipmi->i_authtype);
416 + snprintf(arg, sizeof(arg), " -A %s", str_prepare_for_sh(tmp,ipmi->i_authtype,sizeof(tmp)));
417 strncat(cmd, arg, sizeof(cmd) - strlen(arg));
418 }
419
420 if (ipmi->i_password) {
421 - snprintf(arg, sizeof(arg), " -P %s", ipmi->i_password);
422 + snprintf(arg, sizeof(arg), " -P %s", str_prepare_for_sh(tmp,ipmi->i_password,sizeof(tmp)));
423 strncat(cmd, arg, sizeof(cmd) - strlen(arg));
424 } else {
425 snprintf(arg, sizeof(arg), " -P ''");