Initial add of defaria.com
[clearscm.git] / defaria.com / blogs / Status / archives / 2006_10.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 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/2006_09.html" title="September 2006" />
16    <link rel="next" href="http://defaria.com/blogs/Status/archives/2006_11.html" title="November 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/2006_09.html">&laquo; September 2006</a> |
36                         <a href="http://defaria.com/blogs/Status/">Main</a>
37                         | <a href="http://defaria.com/blogs/Status/archives/2006_11.html">November 2006 &raquo;</a>
38                      </p>
39                      
40                      
41                      
42
43                      <h2 class="date-header">October 31, 2006</h2>
44                      <a id="a000588"></a>
45                      <div class="entry" id="entry-588">
46                         <h3 class="entry-header">Cloning done</h3>
47                         <div class="entry-content">
48                            <div class="entry-body">
49                               <ul>
50   <li>Implemented cloning procedure for DMD/CQ</li>
51 </ul>
52                               
53                               <h3>How to clone a parent CQ record to a child</h3>
54
55 <p>You would think that this would be clearly documented in the CQ manual but it isn't. The requirement is clear enough - "implement parent/child relationships for a CQ record... Oh and when a child is created could you copy everything from the parent and we'll change what's different in the child".</p>
56
57 <p>Implementing a parent/child relationship is pretty clear and documented - basically you create a reference link in the current record back to itself. CQ even has a parent/child control that handles manipulating the relationship allowing the user the controls to link in existing records, delete a parent/child relationship or add a new record as a child of this record. But there is nothing in there about copying data from the parent to the child. This you must do with hooks. But how to code the hooks?</p>
58
59 <p>I found a method for doing this and implemented the following. The trick is to add pre and post hooks to the <b>New</b> button of the parent/child control. This button is selected when the user wishes to add a new child record to this parent. The pre action hook, created as a <i>Record Script</i> set a session wide variable saying "Hey I'm adding a new child record to this parent". This variable contains the ID of the parent. The following code accomplishes this:</p>
60
61 <div class=code><pre>
62 my $session = $entity->GetSession;
63
64 $session->NameValue ("ParentID", $entity->GetFieldValue ("id")->GetValue);
65 </pre></div>
66
67 <p>After creating this record script add it as the pre-action hook for the new button. Don't forget to toggle the Enable for CQ Web (I don't really understand why you would ever not toggle that).</p>
68
69 <p>For the post-action script you are basically saying "Hey I'm no longer adding a new child record to this parent" with the following code:
70
71 <div class=code><pre>
72 my $session = $entity->GetSession;
73
74 $session->NameValue ("ParentID", "");
75 </pre></div>
76
77 <p>What this does is effectively bound the time you are in this unique situation - any other time the global session variable ParentID will be blank. Now the cloning can begin...</p>
78
79 <p>In the default value hooks for each field you want cloned place the following call:</p>
80
81 <div class=code><pre>
82 CloneField ($fieldname);
83 </pre></div>
84
85 <p>This is written as a call to a Global Script since the code will always be the same and because you'll have to do this for each field that you wish cloned.</p>
86
87 <p>Finally, create the following Global Script:</p>
88
89 <div class=code><pre>
90 sub CloneField {
91   my $fieldname = shift;
92     
93   # Check session wide global, ParentID, and if set retrieve
94   # the parent record and clone this field
95   my $session  = $entity->GetSession;
96   my $parentID = $session->GetNameValue ("ParentID");
97
98   if ($parentID ne "") {
99     # If ParentID is not blank then we are adding a subtask.
100     # Copy this field from the parent to this new child.
101
102     # Get the parent record
103     my $parent = $session->GetEntity ("ChangeRequest", $parentID);
104
105     # Set the child field
106     $entity->SetFieldValue (
107         $fieldname,
108         $parent->GetFieldValue ($fieldname)->GetValue
109     );
110   } # if
111 } # CloneField
112 </pre></div>
113
114 <p>This script checks to see if the session global "ParentID" is not blank, indicating that we are in this special mode of adding a new child to an existing parent, and if so, gets the parent record and the field value based on the passed in field name. Finally it sets the field value based on the field name to that of the value of the corresponding parent's field value.</p>
115                               
116                               <p class="entry-footer">
117                                  <span class="post-footers">Posted by  at 11:18 AM</span> <span class="separator">|</span> <a class="permalink" href="http://defaria.com/blogs/Status/archives/000588.html">Permalink</a>
118                                  
119                                  
120                               </p>
121                            </div>
122                         </div>
123                      </div>
124                      
125                      
126
127                      <h2 class="date-header">October 26, 2006</h2>
128                      <a id="a000587"></a>
129                      <div class="entry" id="entry-587">
130                         <h3 class="entry-header">cclic_report/gpdb_putDesignsync bug</h3>
131                         <div class="entry-content">
132                            <div class="entry-body">
133                               <ul>
134   <li>Created cclic_report.pl and cclic_report.sh and checked them into Clearcase. Need to find out how to release this code and then create the necessary cronjob</li>
135
136   <li>Fix bug in gpdb_putDesignsync. Turns out it didn't even try to link the Project to Designsync if the Designsync record existed before. Again, need to figure out how to release this</li>
137
138   <li>Created subtasks tab for DMD. Default functionality for parent/child relationships is already pretty complete. May need to populate new subtasks via a hook</li>
139 </ul>
140                               
141                               <p class="entry-footer">
142                                  <span class="post-footers">Posted by  at  1:58 PM</span> <span class="separator">|</span> <a class="permalink" href="http://defaria.com/blogs/Status/archives/000587.html">Permalink</a>
143                                  
144                                  
145                               </p>
146                            </div>
147                         </div>
148                      </div>
149                      
150                      
151
152                      <h2 class="date-header">October 25, 2006</h2>
153                      <a id="a000586"></a>
154                      <div class="entry" id="entry-586">
155                         <h3 class="entry-header">gpdb_add_projects.pl v1.1</h3>
156                         <div class="entry-content">
157                            <div class="entry-body">
158                               <ul>
159   <li>Checked in new gpdb_add_project.pl</li>
160
161   <li>Created cclic_report.pl and checked it into Clearcase</li>
162 </ul>
163                               
164                               <p>I've checked in a new version of gpdb_add_project.pl (v 1.1) - (/main/FORE/9). Changes include:</p>
165
166 <ol>
167   <li>Major changes cleaning up code</li>
168
169   <li>Simplified some references</li>
170
171   <li>Simplified updateProject</li>
172
173   <li>Simplified addProject</li>
174
175   <li>Removed debugging code</li>
176
177   <li>Rewrote updateDesignSync to be more understandable</li>
178
179   <li>Simplified updateGPDB</li>
180
181   <li>Changed nslookup to redirect stderr. Need to improve error handling here where server name is no longer in DNS.</li>
182
183   <li>Improved logging to specify the names of new users when they are added.</li>
184
185   <li>Changed to handle both auto[_.]data and auto[_.]db cases in NIS</li>
186
187   <li>Changed to use the GPDB Admin user (a00000000) to log into gpdb.</li>
188
189   <li>Log messages improved to include site name</li>
190 </ol>
191
192                               
193                               <p class="entry-footer">
194                                  <span class="post-footers">Posted by  at 12:33 PM</span> <span class="separator">|</span> <a class="permalink" href="http://defaria.com/blogs/Status/archives/000586.html">Permalink</a>
195                                  
196                                  
197                               </p>
198                            </div>
199                         </div>
200                      </div>
201                      
202                      
203
204                      <h2 class="date-header">October 24, 2006</h2>
205                      <a id="a000585"></a>
206                      <div class="entry" id="entry-585">
207                         <h3 class="entry-header">gpdb_add_project</h3>
208                         <div class="entry-content">
209                            <div class="entry-body">
210                               <ul>
211   <li>Lots of re-writing of gpdb_add_project.pl to better handle error conditions</li>
212
213   <li>Investigated DB structures some more</li>
214
215   <li>Created cleardb.sql script to clear out the test db</li>
216 </ul>
217                               
218                               <p class="entry-footer">
219                                  <span class="post-footers">Posted by  at  4:22 PM</span> <span class="separator">|</span> <a class="permalink" href="http://defaria.com/blogs/Status/archives/000585.html">Permalink</a>
220                                  
221                                  
222                               </p>
223                            </div>
224                         </div>
225                      </div>
226                      
227                      
228
229                      <h2 class="date-header">October 19, 2006</h2>
230                      <a id="a000584"></a>
231                      <div class="entry" id="entry-584">
232                         <h3 class="entry-header">GPDB login</h3>
233                         <div class="entry-content">
234                            <div class="entry-body">
235                               <ul>
236   <li>Changed several gpdb modules to support a db parameter for logging into an alternate database</li>
237
238   <li>Changed gpdb-devel.pl to use new interface</li>
239 </ul>
240                               
241                               <p class="entry-footer">
242                                  <span class="post-footers">Posted by  at 12:29 PM</span> <span class="separator">|</span> <a class="permalink" href="http://defaria.com/blogs/Status/archives/000584.html">Permalink</a>
243                                  
244                                  
245                               </p>
246                            </div>
247                         </div>
248                      </div>
249                      
250                      
251
252                      <h2 class="date-header">October 18, 2006</h2>
253                      <a id="a000583"></a>
254                      <div class="entry" id="entry-583">
255                         <h3 class="entry-header">The Oracle speaks...</h3>
256                         <div class="entry-content">
257                            <div class="entry-body">
258                               <ul>
259   <li>Learned about sqlplus and how to speak to Oracle databases from Victor</li>
260
261   <li>Re-wrote the section about getting NIS data and managed to get gpdb_add_project to talk to Nice properly</li>
262
263   <li>Checked in working version of gpdb_add_project and the Rexec.pm module</li>
264
265   <li>Discovered that gpdb_add_project stumbles over some no longer existing machines in some DesignSync registries. Need to change this to send email</li>
266
267   <li>Updated my rc scripts to include support for Oracle</li>
268
269   <li>Working with Bill and Mike we determined that there is a test database for gpdb</li>
270
271   <li>Determined how gpdb.pm opens the database in an effort to teach it how to connect to a test database. It's currently an all or nothing thing. This needs to change.</li>
272 </ul>
273                               
274                               <p class="entry-footer">
275                                  <span class="post-footers">Posted by  at  7:31 AM</span> <span class="separator">|</span> <a class="permalink" href="http://defaria.com/blogs/Status/archives/000583.html">Permalink</a>
276                                  
277                                  
278                               </p>
279                            </div>
280                         </div>
281                      </div>
282                      
283                      
284
285                      <h2 class="date-header">October 17, 2006</h2>
286                      <a id="a000582"></a>
287                      <div class="entry" id="entry-582">
288                         <h3 class="entry-header">PerlDB Tips</h3>
289                         <div class="entry-content">
290                            <div class="entry-body">
291                               <p>The Perl debugger is one of those valuable tools that surprisingly it seems few Perl coders know well. Here are some quick tips on using the Perl debugger. First a few explanations about commands I tend to use:
292
293 <blockquote>
294 <dl>
295   <dt>s</dt>
296
297   <dd>Single step. Step to the next statement stepping into any subroutines (where the source file is known and accessible).</dd>
298
299   <dt>n</dl>
300
301   <dd>Step over - if the line contains a call to a subroutine then this will step over that subroutine.</dd>
302
303   <dt>r</dt>
304
305   <dd>Return from subroutine - if, say you accidentally stepped into a subroutine or if you just want to return,</dd>
306
307   <dt>R</dt>
308
309   <dd>Rerun - start your Perl script again in the debugger with all the parms you started with.</dd>
310
311   <dt>q</dt>
312
313   <dd>quit</dd>
314
315   <dt>p &lt;variable or expression&gt;</dt>
316
317   <dd>Will print the contents of a variable or expression. Expressions can be Perl expressions including calls to subroutines. You can, for example, do "p 'There are " . scalar @foo . ' lines in foo';</dd>
318
319   <dt>x &lt;variable or expression&gt;</dt>
320
321   <dd>Like p above however p will simply print out HASH for hashes whereas x will format them out. Also x will print out "undef" for things that are undefined yet p will print nothing for them.</dd>
322
323   <dt>l (ell)</dt>
324
325   <dd>List the next windowSize lines (see below). Use "l &lt;n&gt;"  where &lt;n&gt; = a line number to list that line.</dd>
326
327   <dt>v &lt;n&gt;</dt>
328
329   <dd>View lines around &lt;n&gt;</dd>
330
331   <dt>V &lt;package&gt;</dt>
332
333   <dd>List exported subroutines and variables for &lt;package&gt; (e.g. V MyModule will is all stuff exported from MyModule).</dd>
334
335   <dt>f &lt;filename&gt;</dt>
336
337    <dd>File - switch to another file. (e.g. f MyModule) and the debugger switches to viewing MyModule.pm.</dd>
338
339   <dt>c &lt;n&gt;</dt>
340
341   <dd>Continue to line &lt;n&gt;. If n is not specified then just continue until the next break point or the end of the script. Continue is like setting a temporary break point that disappears when you hit the line.</dd>
342
343   <dt>b &lt;n&gt; &lt;condition&gt;</dt>
344
345   <dd>Breakpoint - set a break point (or b &lt;n&gt; $name eq "Donna" which will break at line &lt;n&gt; iff $name is "Donna" (evaluated when the debugger gets to line &lt;n&gt;))
346 </dl>
347 </blockquote>
348
349 <p>Also, at the Perl db prompt you can type in any Perl. So, for example, I often work out regex's that way. I'll be debugging a Perl script and stepping up to something like:</p>
350
351 <div class=code><pre>
352      10==> if (/(\d*).*\s+/) {
353      11      print "match!\n";
354      12      $x = $1;
355      13    }
356 </pre></div>
357
358 <p>Then I'll type in stuff like:</p>
359
360 <div class=code><pre>
361      DB<10> if (/(\d*).*\s+/) { print "1 = $1\n"; } else { print "No
362      match!\n"; }
363      No match!
364      DB<11>
365 </pre></div>
366
367 <p>Then I can use the command history (with set -o emacs at the shell before executing perl db emacs key bindings work for me) to edit and enter that perl if statement changing the regex until it works correctly. This way I know I got the right regex. Copy and paste the new, tested, regex from the debugging session into my code then "R" to reload the debugger.</p>
368
369 <p>Or you can say call an arbitrary subroutine in your script:</p>
370
371 <div class=code><pre>
372        DB<2> b Rexec::ssh
373        DB<3> p Rexec::ssh
374 Rexec::ssh(/view/cmdt_x0062320/vobs/cmtools/src/misc/GPDB/bin/../../../../lib/perl/Rexec.pm:60):
375      60:         my $self = shift;
376        DB<<4>>
377 </pre></div>
378
379 <p>The "p Rexec::ssh" says to print the results of the following expression. The expression is a function call in to the Rexec module for the subroutine ssh. Since we just set a break point there in the previous debug command we break at the start of that subroutine and can then debug it. Note you don't want to "c Rexec::ssh" because that would continue the actual execution of your script and only stop at Rexec::ssh if that routine was actually called. Viola, you just forcefully caused the Perl interpreter to branch to this routine!</p>
380
381 <p>Another thing I'll frequently do is set or change variables to see how the code would proceed <b>if</b> the variables were correct (or perhaps incorrect to test error conditions). So let's say a forced execution of the subroutine Log like the above:
382
383 <div class=code><pre>
384 42      sub Log {
385 43:==>    my $msg = shift;
386 44        print "$msg\n";
387
388   DB<23> s
389 main::Log(EvilTwin.pl:45):       print "$msg\n";
390   DB<24>$msg = "Now I set msg to something I want it to be"
391   DB<25>s
392 Now I set msg to something I want it to be
393 main::Log(EvilTwin.pl:47):              return;
394   DB<25>
395 </pre></div>
396
397 <p>There are all sorts of good reasons to examine (p $variable) and set ($variable = "new value") variables during debugging.</p>
398
399 <p>Finally put the following into ~/.perldb:</p>
400
401 <div class=code><pre>
402      parse_options ("windowSize=23");
403 </pre></div>
404
405 <p>This sets the window size to 23 so that 'l" lists the next 23 lines.</p>
406                               
407                               <p class="entry-footer">
408                                  <span class="post-footers">Posted by  at  8:41 AM</span> <span class="separator">|</span> <a class="permalink" href="http://defaria.com/blogs/Status/archives/000582.html">Permalink</a>
409                                  
410                                  
411                               </p>
412                            </div>
413                         </div>
414                      </div>
415                      
416                      
417
418                      <h2 class="date-header">October 13, 2006</h2>
419                      <a id="a000581"></a>
420                      <div class="entry" id="entry-581">
421                         <h3 class="entry-header">gpdb_add_project.pl using gpdb user and Nice</h3>
422                         <div class="entry-content">
423                            <div class="entry-body">
424                               <ul>
425   <li>Attempted to integrate Rexec into gpdb_add_project.pl and have it talk to Nice</li>
426
427   <li>Looked into problem with Cygwin, Samba and ssh</li>
428 </ul>
429                               
430                               <h3>Rexec, gpdb_add_project.pl and Nice</h3>
431
432 <p>I've been making some slow but steady progress with gpdb_add_project.pl. I've:</p>
433
434 <ul>
435   <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>
436
437   <li>David then got me set up with a generic gpdb user for the Dallas and Nice sites.</li>
438 </ul>
439
440 <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>
441
442 <ol>
443   <li>When logging onto the system the prompt is different (csh style shells use "%")</li>
444
445   <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>
446
447   <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>
448 </ol>
449
450 <p>One way around all of these problems is to require generic service
451 level accounts such as gpdb to run the default Borne shell (/bin/sh).</p>
452
453 <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>
454
455 <p>Now @Nice (svrscity01.tif.ti.com) it finds:</p>
456
457 <div class=code><pre>
458 % cat /etc/auto_master
459 # Master map for automounter
460 #
461 +auto_master
462 /xfn -xfn
463 /net -hosts      -intr,rw,grpid
464 </pre></div>
465
466 <p>So it then does ypcat -k auto_master which:</p>
467
468 <div class=code><pre>
469 % ypcat -k auto_master
470 no such map in server's domain
471 </pre></div>
472
473 <p>The following does work though:</p>
474
475 <div class=code><pre>
476 % ypcat -k auto.master
477 /clearcase auto.clearcase
478 /home_drp auto.home_drp -intr,ro
479 /apps_drp auto.apps_drp -intr,ro
480 /db_drp auto.db_drp -intr,ro
481 /user auto.user -intr,rw,grpid
482 /tool auto.tool -intr,rw,grpid,noquota,noatime
483 /home auto.home -intr,rw,grpid
484 /apps auto.tool -intr,rw,grpid,noquota,noatime
485 /xfn -xfn -noquota
486 /sim auto.sim
487 /net -hosts -intr,rw,grpid,noquota
488 /db auto.db
489 /u auto.tool -intr,rw,grpid,noquota
490 </pre></div>
491
492 <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>
493
494 <p>Thoughts? Pointers?</p>
495
496 <h3>Cygwin, Samba and ssh</h3>
497
498 <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>
499
500 <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>
501
502 <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
503 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>
504
505 <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>
506
507 <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>
508
509 <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>
510
511 <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>
512
513 <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>
514
515 <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>
516
517 <div class=code><pre>
518 @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
519 @         WARNING: UNPROTECTED PRIVATE KEY FILE!          @
520 @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
521 Permissions 0644 for '/home/x0062320/.ssh/id_rsa' are too open.
522 It is recommended that your private key files are NOT accessible by others.
523 This private key will be ignored.
524 bad permissions: ignore key: /home/x0062320/.ssh/id_rsa
525 @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
526 @         WARNING: UNPROTECTED PRIVATE KEY FILE!          @
527 @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
528 Permissions 0644 for '/home/x0062320/.ssh/id_dsa' are too open.
529 It is recommended that your private key files are NOT accessible by others.
530 This private key will be ignored.
531 bad permissions: ignore key: /home/x0062320/.ssh/id_dsa
532 x0062320@stashu's password:
533 </pre></div>
534
535 <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>
536
537 <div class=code><pre>
538 &lt;unix box&gt;$ ls -l ~/.ssh/id_rsa
539 -rw-------  1 x0062320 generic 887 Aug 31 16:43 /home/x0062320/.ssh/id_rsa
540 </pre></div>
541
542 <p>While:</p>
543
544 <div class=code><pre>
545 &lt;cygwin&gt;$ ls -l ~/.ssh/id_rsa
546 -rw-r--r-- 1 x0062320 Domain Users 887 Aug 31 16:43 /home/x0062320/.ssh/id_rsa
547 </pre></div>
548
549 <p>Is there any way to work around this problem (short of reconfiguring the Samba server)?</p>
550                               
551                               <p class="entry-footer">
552                                  <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>
553                                  
554                                  
555                               </p>
556                            </div>
557                         </div>
558                      </div>
559                      
560                      
561
562                      <h2 class="date-header">October 10, 2006</h2>
563                      <a id="a000579"></a>
564                      <div class="entry" id="entry-579">
565                         <h3 class="entry-header">Improved gpdp_add_project</h3>
566                         <div class="entry-content">
567                            <div class="entry-body">
568                               <ul>
569   <li>Checked in improved gpdb_add_project.pl script</li>
570
571   <li> Started investigating Dave Smith's <i>Monthly Matrix</i></li>
572 </ul>
573                               
574                               <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>
575
576 <ul>
577   <li>Resolved all problems so that "use strict" could be used</li>
578
579   <li>Fixed bugs with tests for right spaced filled tests for siteName (e.g. $siteName eq "Dallas&nbsp;&nbsp; ")</li>
580
581   <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>
582
583   <li>Changed reading of gpdb_site_list.txt file so that it reads from the correct location.</li>
584
585   <li>Added Protocol, Username and Password columns to gpdb_site_list.txt (and reading of site file).</li>
586
587   <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>
588 </ul>
589
590 <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>
591
592 <p>The thought with the Protocol column in the site file is to support additional protocols, notably ssh and telnet, in the future.</p>
593
594 <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> 
595 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>
596
597 <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
598 all.</p>
599
600 <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>
601
602 <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
603 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>
604
605 <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>
606                               
607                               <p class="entry-footer">
608                                  <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>
609                                  
610                                  
611                               </p>
612                            </div>
613                         </div>
614                      </div>
615                      
616                      
617
618                      <h2 class="date-header">October  9, 2006</h2>
619                      <a id="a000578"></a>
620                      <div class="entry" id="entry-578">
621                         <h3 class="entry-header">Rexec</h3>
622                         <div class="entry-content">
623                            <div class="entry-body">
624                               <ul>
625   <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>
626
627   <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>
628 </ul>
629                               
630                               <p class="entry-footer">
631                                  <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>
632                                  
633                                  
634                               </p>
635                            </div>
636                         </div>
637                      </div>
638                      
639                      
640
641                      <h2 class="date-header">October  5, 2006</h2>
642                      <a id="a000577"></a>
643                      <div class="entry" id="entry-577">
644                         <h3 class="entry-header">Rexec</h3>
645                         <div class="entry-content">
646                            <div class="entry-body">
647                               <ul>
648   <li>Fixed bug in gpdb_add_project.pl</li>
649
650   <li>Met about MultiSite Hardening Daemon (MSHD)</li>
651 </ul>
652                               
653                               <h2>Rexec</h2>
654
655 <p>The gpdb_add_project.pl script utilizes rsh to log into remote sites to execute and otherwise gather data from other sites (Actually it uses rsh locally too but that's another blog entry!). It does this with code like this:</p>
656
657 <div class=code><pre>
658 unless ($site_registry_handle->open("rsh $siteHash{$siteName} -n cat $syncReg |"))  {
659    print ("Can not open rsh $siteHash{$siteName} -n cat $syncReg |.\n");
660    exit;
661 }
662 </pre></div>
663
664 <p>The problem is that the above code will not work. What is returned from the open call here is whether or not the rsh command worked - not whether or not the cat command worked! Indeed open of a pipe returns little - it's the close of the pipe that's going to return the status of the rsh! The status of the cat in this case is never returned. And in this case it was failing. There is no real reliable method for getting the status of the cat command except perhaps to process the remote session using expect or Perl/Expect.</p>
665
666 <p>Since we expect the cat to work and to return lines and because there is a specific format for the first line, I implemented the following:</p>
667
668 <div class=code><pre>
669 sub GetDSRegFile {
670   my $file      = shift;
671   my $server    = shift;
672
673   my @lines;
674
675   if ($server) {
676     @lines = `rsh $server -n cat $file`;
677
678     return undef if $?;
679   } else {
680     @lines = `cat $file`;
681   } # if
682
683   if ($lines [0] and $lines [0] !~ /\#\# SYNC_VERSION 1\.0/) {
684     return undef;
685   } else {
686     return @lines;
687   } # if
688 } # GetDSRegFile
689 </pre></div>
690
691 <p>This solves the problem for this particular case. However this script uses this invalid technique for many other "remote calls" and has potential for error.</p>
692
693
694                               
695                               <p class="entry-footer">
696                                  <span class="post-footers">Posted by  at  3:21 PM</span> <span class="separator">|</span> <a class="permalink" href="http://defaria.com/blogs/Status/archives/000577.html">Permalink</a>
697                                  
698                                  
699                               </p>
700                            </div>
701                         </div>
702                      </div>
703                      
704                      
705
706                      <h2 class="date-header">October  3, 2006</h2>
707                      <a id="a000576"></a>
708                      <div class="entry" id="entry-576">
709                         <h3 class="entry-header">Redirecting on ErrorDocument</h3>
710                         <div class="entry-content">
711                            <div class="entry-body">
712                               <ul>
713   <li>Looked into redirecting when ErrorDocument is called. Doesn't look like it'll work</li>
714 </ul>
715                               
716                               <p>I thought it might be possible to direct the users to the proper Clearquest schemea and Context ID by trapping on ErrorDocument. Normally when a document is not found (i.e. error 404) Apache will display the ErrorDocument associated with error 404. I thought that that document could be a script that looked at the referer and then looked up in the table to see if the user entered a "group". so, IOW, if the user entered http://server/CSSD I could look up CSSD and see it refered to a Cleaquest schema and redirect them. If the group lookup failed then I could simply display a 404 error.</p>
717
718 <p>But alas, referer (passed in via the environment variable HTTP_REFERER) is only set if the user is coming from an existing page. Here most often users are typing in the URL or have the URL bookmarked. In either case referer is not set, and if it were it would be of no help anyway because it would not be from http://server/CSSD (since that page does not really exist).</p>
719                               
720                               <p class="entry-footer">
721                                  <span class="post-footers">Posted by  at  1:28 PM</span> <span class="separator">|</span> <a class="permalink" href="http://defaria.com/blogs/Status/archives/000576.html">Permalink</a>
722                                  
723                                  
724                               </p>
725                            </div>
726                         </div>
727                      </div>
728                      
729                   </div>
730                </div>
731             </div>
732          </div>
733       </div>
734    </div>
735 </body>
736 </html>