Initial add of defaria.com
[clearscm.git] / defaria.com / blogs / Status / archives / week_2006_10_08.html
1 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
2    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
3 <html xmlns="http://www.w3.org/1999/xhtml" id="sixapart-standard">
4 <head>
5    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
6    <meta name="generator" content="Movable Type 5.2.3" />
7
8    <link rel="stylesheet" href="http://defaria.com/blogs/Status/styles-site.css" type="text/css" />
9    <link rel="alternate" type="application/atom+xml" title="Atom" href="http://defaria.com/blogs/Status/atom.xml" />
10    <link rel="alternate" type="application/rss+xml" title="RSS 2.0" href="http://defaria.com/blogs/Status/index.xml"$>" />
11
12    <title>Status for Andrew DeFaria: October  8, 2006 - October 14, 2006 Archives</title>
13
14    <link rel="start" href="http://defaria.com/blogs/Status/" title="Home" />
15    <link rel="prev" href="http://defaria.com/blogs/Status/archives/week_2006_10_01.html" title="October  1, 2006 - October  7, 2006" />
16    <link rel="next" href="http://defaria.com/blogs/Status/archives/week_2006_10_15.html" title="October 15, 2006 - October 21, 2006" />
17 </head>
18 <body class="layout-one-column">
19    <div id="container">
20       <div id="container-inner" class="pkg">
21
22          <div id="banner">
23             <div id="banner-inner" class="pkg">
24                <h1 id="banner-header"><a href="http://defaria.com/blogs/Status/" accesskey="1">Status for Andrew DeFaria</a></h1>
25                <h2 id="banner-description">Searchable status reports and work log</h2>
26             </div>
27          </div>
28
29          <div id="pagebody">
30             <div id="pagebody-inner" class="pkg">
31                <div id="alpha">
32                   <div id="alpha-inner" class="pkg">
33                      
34                      <p class="content-nav">
35                         <a href="http://defaria.com/blogs/Status/archives/week_2006_10_01.html">&laquo; October  1, 2006 - October  7, 2006</a> |
36                         <a href="http://defaria.com/blogs/Status/">Main</a>
37                         | <a href="http://defaria.com/blogs/Status/archives/week_2006_10_15.html">October 15, 2006 - October 21, 2006 &raquo;</a>
38                      </p>
39                      
40                      
41                      
42
43                      <h2 class="date-header">October 13, 2006</h2>
44                      <a id="a000581"></a>
45                      <div class="entry" id="entry-581">
46                         <h3 class="entry-header">gpdb_add_project.pl using gpdb user and Nice</h3>
47                         <div class="entry-content">
48                            <div class="entry-body">
49                               <ul>
50   <li>Attempted to integrate Rexec into gpdb_add_project.pl and have it talk to Nice</li>
51
52   <li>Looked into problem with Cygwin, Samba and ssh</li>
53 </ul>
54                               
55                               <h3>Rexec, gpdb_add_project.pl and Nice</h3>
56
57 <p>I've been making some slow but steady progress with gpdb_add_project.pl. I've:</p>
58
59 <ul>
60   <li>Implemented an Rexec Perl module that allows better access to remote sites. It does this by attempting ssh then rsh and finally telnet in an attempt to contact the remote site. It's object oriented and allows you to repeatedly execute remote commands without having to repeatedly login. Finally it can take a different username than the person running the script.</li>
61
62   <li>David then got me set up with a generic gpdb user for the Dallas and Nice sites.</li>
63 </ul>
64
65 <p>In attempting to use the new generic gpdb user I encountered a few problems. The biggest difference isg pdb user is tcsh (and csh I think) oriented whereas the Rexec module assumes a Borne/Ksh/Bash orientation. This has caused a number of problems:</p>
66
67 <ol>
68   <li>When logging onto the system the prompt is different (csh style shells use "%")</li>
69
70   <li>When logging onto the Nice site not only is the prompt different but it contains special characters. It uses embedded escape sequences that colorize the prompt. Rexec needs to find the prompt so it knows when it can send commands. Needless to say this si problematic forRexec. For now I set the prompt for gpdb@Nice to simply "% ", which  works.</li>
71
72   <li>Some of the commands that gpdb_add_project.pl issues are decidedly Borne shell oriented. For example, it uses 2&gt;&amp;1 to combine stdout and stderr. This syntax is not valid under csh style shells. Additionally, Rexec would wrap commands in an "echo start; &lt;cmd&gt;; echo errono=$?" in order to obtain the return status of the remotely executed command. The $? variable is not available in csh style shells. So I added a shellstyle parameter to Rexec to handle these differences (though that doesn't fix #2).</li>
73 </ol>
74
75 <p>One way around all of these problems is to require generic service
76 level accounts such as gpdb to run the default Borne shell (/bin/sh).</p>
77
78 <p>Next, and forgive me since my NIS is a bit rusty, but gpdb_add_project.pl would attempt to get certain NIS maps for remote sites that use NIS (it is also NIS+ aware/sensitive). In doing so it does an ls -1 /etc then looks for files such as auto_master. It then cat's auto_master and looks for lines that have "+auto" or "data" in them. It then uses that as a key file for ypcat as in ypcat -k auto_master.</p>
79
80 <p>Now @Nice (svrscity01.tif.ti.com) it finds:</p>
81
82 <div class=code><pre>
83 % cat /etc/auto_master
84 # Master map for automounter
85 #
86 +auto_master
87 /xfn -xfn
88 /net -hosts      -intr,rw,grpid
89 </pre></div>
90
91 <p>So it then does ypcat -k auto_master which:</p>
92
93 <div class=code><pre>
94 % ypcat -k auto_master
95 no such map in server's domain
96 </pre></div>
97
98 <p>The following does work though:</p>
99
100 <div class=code><pre>
101 % ypcat -k auto.master
102 /clearcase auto.clearcase
103 /home_drp auto.home_drp -intr,ro
104 /apps_drp auto.apps_drp -intr,ro
105 /db_drp auto.db_drp -intr,ro
106 /user auto.user -intr,rw,grpid
107 /tool auto.tool -intr,rw,grpid,noquota,noatime
108 /home auto.home -intr,rw,grpid
109 /apps auto.tool -intr,rw,grpid,noquota,noatime
110 /xfn -xfn -noquota
111 /sim auto.sim
112 /net -hosts -intr,rw,grpid,noquota
113 /db auto.db
114 /u auto.tool -intr,rw,grpid,noquota
115 </pre></div>
116
117 <p>It appears to be trying to find the auto_data map, of which there are none, and then will look for "sync_custom" in there. As such I don't see how this ever worked at Nice.</p>
118
119 <p>Thoughts? Pointers?</p>
120
121 <h3>Cygwin, Samba and ssh</h3>
122
123 <p>Here's the story. I use Cygwin on my XP desktop. I like having a home directory on Windows that is the same home directory on Unix/Linux machines. Often companies offer access to your Unix/Linux home directory via Samba. Also, often companies do not bother to set up a Samba server wish participates in a domain, so the Samba server is configured as being in a workgroup.</p>
124
125 <p>Now for a long time I struggled with this. I would map //&lt;samba server&gt;/&lt;home share&gt; -&gt; my H drive then mount the H drive as /home and make sure my Cygwin /etc/password referred to my home directory of /home/$USER. All is great.</p>
126
127 <p>But when dealing with Samba servers who are configured into workgroups innocuous activities in Cygwin would elicit permission denied messages. For example, touching a file in the home directory and indeed even vi'ing a file, etc. Creating a file within Windows Explorer or using
128 other Windows oriented tools would work just fine. Files created on the Unix/Linux side would also work fine but when looked at from Cygwin on the PC would have odd (read "nobody") ownerships and permissions.</p>
129
130 <p>Of course as Cygwin is often not supported by the typical company's IT department and because many people do not attempt to utilize Cygwin fully often requests for assistance and change fell on deaf ears...</p>
131
132 <p>Eventually I figured out that my Windows SID in /etc/passwd is the SID of my domain user and since the Samba server was not in the domain my SID does not authenticate properly. Then I had a break through in that I realized that I was using SMBNTSEC as well as NTSEC in my Cygwin environment. I figured "Yeah I want to use the same Windows security for SMB mounted drives too". This is where my problem lies and it's because the Samba server configured by the client does not participate in the Windows domain from which I've logged in. </p>
133
134 <p>Now I'm pretty sure that Samba could be configured properly into a Windows domain as Samba can be configured as a PDC or a BDC, but many clients don't bother to go that far. So why is Windows able to deal with this but not Cygwin?</p>
135
136 <p>I believe that this is because within Samba a very basic approach is kept towards storing of user identification information. Indeed basic Samba just has an smbpasswd file which is much like your typical Unix/Linux /etc/passwd file and it is not designed to carry extra information about users and machine accounts as well as multiple groups and trust associations, etc. Even Samba documents talks about hooking Samba up to either LDAP or what they call a Trivial DataBase (TDB) in order to store such additional Windows only information.</p>
137
138 <p>So I thought the simple solution was to remove SMBNTSEC from my Cygwin environment and all would be fine. And indeed it is! Well almost...</p>
139
140 <p>Along comes ssh... So I like to use ssh to log into various Unix/Linux systems as I work. And again I share my home directory between Windows and Unix/Linux. Finally I like setting up passwordless public key ssh login as I'm not one of those who likes having to type in his password hundreds of times a day. But ssh's is picky about permissions of your ~/.ssh and ~/.ssh/id_&lt;type&gt; key files. When ssh'ing from Cygwin to a Unix/Linux box I am now receiving the following:</p>
141
142 <div class=code><pre>
143 @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
144 @         WARNING: UNPROTECTED PRIVATE KEY FILE!          @
145 @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
146 Permissions 0644 for '/home/x0062320/.ssh/id_rsa' are too open.
147 It is recommended that your private key files are NOT accessible by others.
148 This private key will be ignored.
149 bad permissions: ignore key: /home/x0062320/.ssh/id_rsa
150 @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
151 @         WARNING: UNPROTECTED PRIVATE KEY FILE!          @
152 @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
153 Permissions 0644 for '/home/x0062320/.ssh/id_dsa' are too open.
154 It is recommended that your private key files are NOT accessible by others.
155 This private key will be ignored.
156 bad permissions: ignore key: /home/x0062320/.ssh/id_dsa
157 x0062320@stashu's password:
158 </pre></div>
159
160 <p>And, of course, I need to type in my password again! What I believe is happening is that because my home directory is SMB mounted and SMBNTSEC is off then Cygwin reports that files like ~/.ssh/id_rsa are 0644 even if I change them on Unix/Linux to 0600. So, for example:</p>
161
162 <div class=code><pre>
163 &lt;unix box&gt;$ ls -l ~/.ssh/id_rsa
164 -rw-------  1 x0062320 generic 887 Aug 31 16:43 /home/x0062320/.ssh/id_rsa
165 </pre></div>
166
167 <p>While:</p>
168
169 <div class=code><pre>
170 &lt;cygwin&gt;$ ls -l ~/.ssh/id_rsa
171 -rw-r--r-- 1 x0062320 Domain Users 887 Aug 31 16:43 /home/x0062320/.ssh/id_rsa
172 </pre></div>
173
174 <p>Is there any way to work around this problem (short of reconfiguring the Samba server)?</p>
175                               
176                               <p class="entry-footer">
177                                  <span class="post-footers">Posted by  at  5:31 PM</span> <span class="separator">|</span> <a class="permalink" href="http://defaria.com/blogs/Status/archives/000581.html">Permalink</a>
178                                  
179                                  
180                               </p>
181                            </div>
182                         </div>
183                      </div>
184                      
185                      
186
187                      <h2 class="date-header">October 10, 2006</h2>
188                      <a id="a000579"></a>
189                      <div class="entry" id="entry-579">
190                         <h3 class="entry-header">Improved gpdp_add_project</h3>
191                         <div class="entry-content">
192                            <div class="entry-body">
193                               <ul>
194   <li>Checked in improved gpdb_add_project.pl script</li>
195
196   <li> Started investigating Dave Smith's <i>Monthly Matrix</i></li>
197 </ul>
198                               
199                               <p>I've gotten Michael's copy of gpdb_add_project.pl, which he placed into the cmtools/src vob, working now. Here's some of the changes:</p>
200
201 <ul>
202   <li>Resolved all problems so that "use strict" could be used</li>
203
204   <li>Fixed bugs with tests for right spaced filled tests for siteName (e.g. $siteName eq "Dallas&nbsp;&nbsp; ")</li>
205
206   <li>Changed code so that failure to contact a remote site simply reports a warning and moves on to the next site (previously it would die after the first failure).</li>
207
208   <li>Changed reading of gpdb_site_list.txt file so that it reads from the correct location.</li>
209
210   <li>Added Protocol, Username and Password columns to gpdb_site_list.txt (and reading of site file).</li>
211
212   <li>Changed all rsh calls to call an "Rexec" function that takes a hash of the site line in gpdb_site_list.txt. This is to allow alternate username/password per site<sup>1</sup></li>
213 </ul>
214
215 <p>Note that Rexec currently only supports the rsh protocol and the return code from this Rexec is the same as the return code for the rsh command itself, not the return code from the command that rsh is executing on the remote machine.</p>
216
217 <p>The thought with the Protocol column in the site file is to support additional protocols, notably ssh and telnet, in the future.</p>
218
219 <p>However, "rsh &lt;machine&gt; -l &lt;user&gt; command" doesn't prompt for password and you cannot supply password on the command line either<sup>1</sup> 
220 ssh will prompt for a password. Telnet, of course, does not offer the ability to add a command. Finally specifying a password in a file is not very secure.</p>
221
222 <p>I've spent a little time coming up with a Perl module (strangely named Rexec) to implement remote command execution. Currently it is an object oriented approach that uses telnet and Expect to open a channel to the remote machine and execute commands returning the remotely executed command's status and output. I plan on extending it to first try ssh then rlogin and finally telnet. For the first protocol, if passwordless access is set up then no password is required. If it can't connect that way then it can fall back to rlogin or telnet and use Expect to drive the login and command execution (or optionally fail if no password is given). In general I think this would be a useful module to have for
223 all.</p>
224
225 <p>Another benefit would be that the usage would be such that you establish a connection, execute potentially hundreds of commands, then destroy the connection - which would be a lot faster than say hundreds of ssh/rsh's which each need to login, do the command and logout.</p>
226
227 <p>Another optimization I see for gpdb_add_project.pl would be to have the remote machine cut down the amount of data needed to be sent over the network connection. For example, gpdb_add_project.pl uses a remote connection to essentially niscat the auto_data automount map, returning hundreds of lines (6395 lines or 622559 bytes). Then it loops through that array looking for lines that say "sync_custom" (actually it first
228 sorts them - for no particular reason!). I propose that it instead does something like "niscat auto_data.org_dir | grep sync_custom" returning only 2 lines or 126 bytes and remove the needless sort(s).</p>
229
230 <p>Architecturally I think that what gpdb_add_project.pl does is interface between the outside world (in this case DesignSync) and GPDB. GPDB has a nice Perl module to allow consistent programmatic access to the output - GPDB (Thanks Michael). What would be nice is a Perl module that gathers all DesignSync info (which is what gpdb_add_project.pl does) allowing a consistent programmatic access to DesignSync info (and down the road - Clearcase). Then gpdb_add_project.pl could be greatly simplified to simply talk to these two architected interfaces.</p>
231                               
232                               <p class="entry-footer">
233                                  <span class="post-footers">Posted by  at  3:50 PM</span> <span class="separator">|</span> <a class="permalink" href="http://defaria.com/blogs/Status/archives/000579.html">Permalink</a>
234                                  
235                                  
236                               </p>
237                            </div>
238                         </div>
239                      </div>
240                      
241                      
242
243                      <h2 class="date-header">October  9, 2006</h2>
244                      <a id="a000578"></a>
245                      <div class="entry" id="entry-578">
246                         <h3 class="entry-header">Rexec</h3>
247                         <div class="entry-content">
248                            <div class="entry-body">
249                               <ul>
250   <li>Finished recording gpdb_add_project to call a central rexec function so that remote execution can use a different username. However right now all it does is rsh, which can use another username but rsh needs to have remote passwordless login set up in order to work</li>
251
252   <li>Created Rexec.pm Perl object that has the ability to use Expect and telnet to log in remotely to a machine and execute commands, returning output and the status of the command executed remotely. Need to integrate this with gpdb_add_project...</li>
253 </ul>
254                               
255                               <p class="entry-footer">
256                                  <span class="post-footers">Posted by  at  5:32 PM</span> <span class="separator">|</span> <a class="permalink" href="http://defaria.com/blogs/Status/archives/000578.html">Permalink</a>
257                                  
258                                  
259                               </p>
260                            </div>
261                         </div>
262                      </div>
263                      
264                   </div>
265                </div>
266             </div>
267          </div>
268       </div>
269    </div>
270 </body>
271 </html>