-Add retrieval of root's private ssh key through the credentials plugin to postscripts
git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/trunk@1108 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd
This commit is contained in:
		
							
								
								
									
										25
									
								
								xCAT/postscripts/getcredentials.awk
									
									
									
									
									
										Executable file
									
								
							
							
						
						
									
										25
									
								
								xCAT/postscripts/getcredentials.awk
									
									
									
									
									
										Executable file
									
								
							| @@ -0,0 +1,25 @@ | ||||
| #!/usr/bin/awk -f | ||||
| BEGIN { | ||||
|         listener = "/inet/tcp/300/0/0" | ||||
|         server = "/inet/tcp/0/127.0.0.1/400" | ||||
|         quit = "no" | ||||
|  | ||||
|  | ||||
|         print "<xcatrequest>" |& server | ||||
|         print "   <command>getcredentials</command>" |& server | ||||
|         print "   <callback_port>300</callback_port>" |& server | ||||
|         print "   <arg>"ARGV[1]"</arg>" |& server | ||||
|         print "</xcatrequest>" |& server | ||||
|  | ||||
|         while (match(quit,"no") && (listener |& getline) > 0) { | ||||
|                 if (match($0,"CREDOKBYYOU?")) { | ||||
|                         print "CREDOKBYME" |& listener | ||||
|                         quit="yes" | ||||
|                 } | ||||
|         } | ||||
|         close(listener) | ||||
|  | ||||
|         while (server |& getline) { | ||||
|                 print $0 | ||||
|         } | ||||
| } | ||||
| @@ -26,6 +26,7 @@ then | ||||
| 	cd /xcatpost/.ssh | ||||
| 	mkdir -p /root/.ssh | ||||
| 	cp -f * /root/.ssh | ||||
|    cd - | ||||
| 	chmod 700 /root/.ssh | ||||
| 	chmod 600 /root/.ssh/* | ||||
| fi | ||||
| @@ -36,5 +37,27 @@ then | ||||
| fi | ||||
|  | ||||
|  | ||||
| exit 0 | ||||
| if [ ! -x /usr/sbin/stunnel ]; then #Stop if no stunnel to help the next bit | ||||
|    exit 0 | ||||
| fi | ||||
|  | ||||
| echo client=yes > /etc/stunnel/stunnel.conf | ||||
| echo foreground=yes >> /etc/stunnel/stunnel.conf | ||||
| echo output=/dev/null >> /etc/stunnel/stunnel.conf | ||||
| echo verify=0 >> /etc/stunnel/stunnel.conf | ||||
| echo '[xcatd]' >> /etc/stunnel/stunnel.conf | ||||
| echo accept=400 >> /etc/stunnel/stunnel.conf | ||||
| echo connect=$MASTER:3001 >> /etc/stunnel/stunnel.conf | ||||
|  | ||||
| stunnel & | ||||
| STUN_PID=$! | ||||
| sleep 1 | ||||
|  | ||||
| umask 0077 | ||||
|  | ||||
| mkdir -p /root/.ssh/ | ||||
| getcredentials.awk ssh_root_key | grep -v '<'|sed -e 's/</</' -e 's/>/>/' -e 's/&/&/' -e 's/"/"/' -e "s/'/'/" > /root/.ssh/id_rsa | ||||
| if ! grep "PRIVATE KEY" /root/.ssh/id_rsa > /dev/null 2>&1 ; then | ||||
|    rm /root/.ssh/id_rsa | ||||
| fi | ||||
| kill $STUN_PID | ||||
|   | ||||
		Reference in New Issue
	
	Block a user