cluster/fence/agents ipmilan/ipmilan.c manual/ ...
CVSROOT: /cvs/cluster
Module name: cluster
Branch: RHEL4
Changes by: rmccabe at sourceware.org 2007-02-13 19:38:33
Modified files:
fence/agents/ipmilan: ipmilan.c fence/agents/manual: ack.c manual.c fence/agents/rackswitch: do_rack.c do_rack.h fence/agents/rps10: rps10.c
Log message:
Support the "passwd_script" parameter in the C fence agents.
Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/fence/agents/ipmilan/ipmilan.c.diff?cvsroot=cluster&only_with_tag=RHEL4&r1=1.1.2.7&r2=1.1.2.8
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/fence/agents/manual/ack.c.diff?cvsroot=cluster&only_with_tag=RHEL4&r1=1.3&r2=1.3.2.1
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/fence/agents/manual/manual.c.diff?cvsroot=cluster&only_with_tag=RHEL4&r1=1.3.2.1&r2=1.3.2.2
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/fence/agents/rackswitch/do_rack.c.diff?cvsroot=cluster&only_with_tag=RHEL4&r1=1.1&r2=1.1.2.1
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/fence/agents/rackswitch/do_rack.h.diff?cvsroot=cluster&only_with_tag=RHEL4&r1=1.1&r2=1.1.2.1
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/fence/agents/rps10/rps10.c.diff?cvsroot=cluster&only_with_tag=RHEL4&r1=1.2&r2=1.2.2.1
fence/agents/ipmilan/ipmilan.c +50 -12
@@ -8,7 +8,7 @@* * http://ipmitool.sourceforge.net * -* Copyright 2005 Red Hat, Inc. +* Copyright 2005-2007 Red Hat, Inc. * author: Lon Hohberger <[email protected]> * * This library is free software; you can redistribute it and/or
@@ -30,6 +30,7 @@#include <stdlib.h> #include <unistd.h> #include <signal.h> +#include <limits.h> #include <string.h> #include <errno.h> #include <sys/wait.h>
@@ -758,7 +759,7 @@ cleanup(char *line, size_t linelen) {char *p; -int x; +size_t x;/* Remove leading whitespace. */ p = line;
@@ -805,6 +806,7 @@ get_options_stdin(char *ip, size_t iplen, char *authtype, size_t atlen, char *passwd, size_t pwlen, + char *pwd_script, size_t pwd_script_len, char *user, size_t userlen, char *op, size_t oplen, int *verbose)
@@ -854,7 +856,12 @@strncpy (passwd, val, pwlen); else passwd[0 ] =0 ; - + }else if (!strcasecmp (name,"passwd_script" )) { +if (val) { +strncpy (pwd_script, val, pwd_script_len); + pwd_script[pwd_script_len -1 ] ='\0' ; + }else + pwd_script[0 ] ='\0' ; }else if (!strcasecmp (name,"user" ) || !strcasecmp (name,"login" )) {/* username */
@@ -901,6 +908,7 @@printf (" -i <ipaddr> IPMI Lan IP to talk to (deprecated, use -i)\n" );printf (" -p <password> Password (if required) to control power on\n" " IPMI device\n" ); +printf (" -S <path> Script to retrieve password (if required)\n" );printf (" -l <login> Username/Login (if required) to control power\n" " on IPMI device\n" );printf (" -o <op> Operation to perform.\n" );
@@ -909,14 +917,15 @@printf (" -v Verbose mode\n\n" );printf ("If no options are specified, the following options will be read\n" );printf ("from standard input (one per line):\n\n" ); -printf (" auth=<auth> Same as -A\n" ); -printf (" ipaddr=<#> Same as -a\n" ); -printf (" passwd=<pass> Same as -p\n" ); -printf (" login=<login> Same as -u\n" ); -printf (" option=<op> Same as -o\n" ); -printf (" operation=<op> Same as -o\n" ); -printf (" action=<op> Same as -o\n" ); -printf (" verbose Same as -v\n\n" ); +printf (" auth=<auth> Same as -A\n" ); +printf (" ipaddr=<#> Same as -a\n" ); +printf (" passwd=<pass> Same as -p\n" ); +printf (" passwd_script=<path> Same as -S\n" ); +printf (" login=<login> Same as -u\n" ); +printf (" option=<op> Same as -o\n" ); +printf (" operation=<op> Same as -o\n" ); +printf (" action=<op> Same as -o\n" ); +printf (" verbose Same as -v\n\n" );exit (1 ); }
@@ -931,6 +940,7 @@char passwd[64 ];char user[64 ];char op[64 ]; +char pwd_script[PATH_MAX ];int verbose=0 ;char *pname =basename (argv[0 ]);struct ipmi *i;
@@ -938,6 +948,7 @@memset (ip,0 ,sizeof (ip));memset (authtype,0 ,sizeof (authtype));memset (passwd,0 ,sizeof (passwd)); +memset (pwd_script,0 ,sizeof (pwd_script));memset (user,0 ,sizeof (user));memset (op,0 ,sizeof (op));
@@ -945,7 +956,7 @@/* Parse command line options if any were specified */ -while ((opt =getopt (argc, argv,"A:a:i:l:p:o:vV?hH" )) !=EOF ) { +while ((opt =getopt (argc, argv,"A:a:i:l:p:S:o:vV?hH" )) !=EOF ) {switch (opt) {case 'A' :/* Auth type */
@@ -964,6 +975,11 @@/* password */ strncpy (passwd, optarg,sizeof (passwd));break ; +case 'S' : +/* password script */ +strncpy (pwd_script, optarg,sizeof (pwd_script)); + pwd_script[sizeof (pwd_script) -1 ] ='\0' ; +break ;case 'o' :/* Operation */ strncpy (op, optarg,sizeof (op));
@@ -989,11 +1005,33 @@if (get_options_stdin (ip,sizeof (ip), authtype,sizeof (authtype), passwd,sizeof (passwd), + pwd_script,sizeof (pwd_script), user,sizeof (user), op,sizeof (op), &verbose) !=0 )return 1 ; } +if (pwd_script[0 ] !='\0' ) { +char pwd_buf[1024 ]; +FILE *fp; + fp =popen (pwd_script,"r" ); +if (fp !=NULL ) { +ssize_t len =fread (pwd_buf,1 ,sizeof (pwd_buf), fp); +if (len >0 ) { +char *p; + p =strchr (pwd_buf,'\n' ); +if (p !=NULL ) + *p ='\0' ; + p =strchr (pwd_buf,'\r' ); +if (p !=NULL ) + *p ='\0' ; +strncpy (passwd, pwd_buf,sizeof (passwd)); + passwd[sizeof (passwd) -1 ] ='\0' ; + } +pclose (fp); + } + } +/* Validate the operating parameters */
fence/agents/manual/Attic/ack.c +1 -1
@@ -2,7 +2,7 @@ ******************************************************************************* ** ** Copyright (C) Sistina Software, Inc. 1997-2003 All rights reserved. -** Copyright (C) 2004 Red Hat, Inc. All rights reserved. +** Copyright (C) 2004-2007 Red Hat, Inc. All rights reserved. ** ** This copyrighted material is made available to anyone wishing to use, ** modify, copy, or redistribute it subject to the terms and conditions
fence/agents/manual/Attic/manual.c +1 -1
@@ -2,7 +2,7 @@ ******************************************************************************* ** ** Copyright (C) Sistina Software, Inc. 1997-2003 All rights reserved. -** Copyright (C) 2004 Red Hat, Inc. All rights reserved. +** Copyright (C) 2004-2007 Red Hat, Inc. All rights reserved. ** ** This copyrighted material is made available to anyone wishing to use, ** modify, copy, or redistribute it subject to the terms and conditions
fence/agents/rackswitch/do_rack.c +36 -2
@@ -2,7 +2,7 @@ ******************************************************************************* ** ** Copyright (C) Sistina Software, Inc. 1997-2003 All rights reserved. -** Copyright (C) 2004 Red Hat, Inc. All rights reserved. +** Copyright (C) 2004-2007 Red Hat, Inc. All rights reserved. ** ** This copyrighted material is made available to anyone wishing to use, ** modify, copy, or redistribute it subject to the terms and conditions
@@ -24,6 +24,7 @@char password[256 ];char arg[256 ];char name[256 ]; +char pwd_script[PATH_MAX ] = {0 , };char readbuf[MAXBUF ];char writebuf[MAXBUF ];
@@ -159,6 +160,7 @@" -n <dec num> Physical plug number on RackSwitch\n" " -l <string> Username\n" " -p <string> Password\n" +" -S <path> Script to retrieve password\n" " -v Verbose\n" " -q Quiet\n" " -V Version information\n", pname);
@@ -175,7 +177,7 @@/* * Command line input */ -while ((c =getopt (argc, argv,"ha:n:l:p:vqVd" )) !=-1 ) +while ((c =getopt (argc, argv,"ha:n:l:p:S:vqVd" )) !=-1 ) {switch (c) {
@@ -199,6 +201,11 @@strncpy (password,optarg,254 );break ; +case 'S' : +strncpy (pwd_script, optarg,sizeof (pwd_script)); + pwd_script[sizeof (pwd_script) -1 ] ='\0' ; +break ; +case 'v' : verbose_flag =1 ;break ;
@@ -265,10 +272,37 @@if (!strcmp (arg,"password" ))strcpy (password, value); + +if (!strcasecmp (arg,"passwd_script" )) { +strncpy (pwd_script, optarg,sizeof (pwd_script)); + pwd_script[sizeof (pwd_script) -1 ] ='\0' ; + } } errno =0 ; } + +if (pwd_script[0 ] !='\0' ) { +FILE *fp; +char pwd_buf[1024 ]; + + fp =popen (pwd_script,"r" ); +if (fp !=NULL ) { +ssize_t len =fread (pwd_buf,1 ,sizeof (pwd_buf), fp); +if (len >0 ) { +char *p; + p =strchr (pwd_buf,'\n' ); +if (p !=NULL ) + *p ='\0' ; + p =strchr (pwd_buf,'\r' ); +if (p !=NULL ) + *p ='\0' ; +strncpy (password, pwd_buf,sizeof (password)); + password[sizeof (password) -1 ] ='\0' ; + } +pclose (fp); + } + } }static void sig_alarm (int sig)
fence/agents/rackswitch/do_rack.h +1 -0
@@ -3,6 +3,7 @@#include <stdio.h> #include <stdlib.h> #include <string.h> +#include <limits.h> #include <fcntl.h> #include <errno.h> #include <ctype.h>
fence/agents/rps10/rps10.c +1 -1
@@ -1,5 +1,5 @@/* -Copyright Red Hat, Inc. 2002-2004 +Copyright Red Hat, Inc. 2002-2007 This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the