<div dir="ltr"><div>Thanks for review, Please find updated patch and comments inline bellow.</div><div><br></div><div>Regards</div><div>Umar Hayat</div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Sat, Mar 14, 2020 at 12:07 PM Tatsuo Ishii &lt;<a href="mailto:ishii@sraoss.co.jp">ishii@sraoss.co.jp</a>&gt; wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Hi Umar,<br>
<br>
&gt; Any feedback ?<br>
<br>
I have looked into this.<br>
<br>
(1) I think error message style is a little bit different from<br>
the standard of ours (or PostgreSQL, we follow PostgreSQL style).<br>
<br>
+               fprintf(stderr, &quot;input_file \&quot;%s\&quot; cannot be opened\n\n&quot;, input_file);<br>
According to our style this will be something like this. Also it&#39;s recommended to add %m to show the cause of the errro.<br>
fprintf(stderr, &quot;failed to open input_file \&quot;%s\&quot; (%m)\n\n&quot;, input_file);<br>
<br></blockquote><div>Fixed. </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
(2) It&#39;s not recommended to start an error message with upper case letter.<br>
+                       fprintf(stdout, &quot;Input exceeds maximum username length!\n\n&quot;);<br>
Also I think it&#39;s better to inform the max username length. I propose something like:<br>
+                       fprintf(stdout, &quot;input exceeds maximum username length %d\n\n&quot;, MAX_USER_NAME_LEN);<br>
<br>
(3) Following message style seems to be inconsistent the message above.<br>
<br>
+                       fprintf(stdout, &quot;Input exceeds maximum password length given:%d max allowed:%d!\n&quot;, (int)strlen(pch), MAX_PGPASS_LEN);<br>
What about this?<br>
+                       fprintf(stdout, &quot;input exceeds maximum password length %d\n&quot;, MAX_PGPASS_LEN);<br>
<br></blockquote><div>For (2), (3), I followed/copied existing pattern of error string already there in utility. In latest patch I converted strings that I added to lower case and updated string as you suggested.</div><div>( I didn&#39;t updated strings which I just indented/or moved, there are number of other location where above format is not followed, let me know if I send a separate patch to fix them in multiple utilities/files )</div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
(4) if username+password exceeds the buffer for fgets(), pg_enc<br>
errored out but read rest of the line which fgets() did not read and<br>
will be confused.<br>
<br>
LINE#01: USER: username1<br>
LINE#02: USER: username2<br>
LINE#03: Input exceeds maximum username length!<br>
<br>
LINE#04: Invalid username:password pair<br>
LINE#05: USER: username4<br>
<br>
Actually there&#39;s no line#05. See attached test input.<br>
<br></blockquote><div>Fixed. I also changed verbosity to error only. </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
(5) I am not sure if we need to check the input by using stat():<br>
<br>
+       if (stat(input_file, &amp;stat_buf) != 0)<br>
+       {<br>
+               fprintf(stderr, &quot;input_file \&quot;%s\&quot; cannot be opened. Check file permissions\n\n&quot;, input_file);<br>
+               exit(EXIT_FAILURE);<br>
+       }<br>
<br>
-       return EXIT_SUCCESS;<br>
+       if (!S_ISREG(stat_buf.st_mode))<br>
+       {<br>
+               fprintf(stderr, &quot;input_file \&quot;%s\&quot; is not a plain file\n\n&quot;, input_file);<br>
+               exit(EXIT_FAILURE);<br>
+       }<br>
<br>
I think it&#39;s overkill. Usually we (and PostgreSQL) just try to open a<br>
file and complain if it fails.<br>
<br></blockquote><div>Fixed. </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
(6) <br>
+                       buf[len - 1] = 0;<br>
It&#39;s better to use &#39;\0&#39; rather than 0 here.<br>
<br></blockquote><div>Fixed. </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
Best regards,<br>
--<br>
Tatsuo Ishii<br>
SRA OSS, Inc. Japan<br>
English: <a href="http://www.sraoss.co.jp/index_en.php" rel="noreferrer" target="_blank">http://www.sraoss.co.jp/index_en.php</a><br>
Japanese:<a href="http://www.sraoss.co.jp" rel="noreferrer" target="_blank">http://www.sraoss.co.jp</a><br>
<br>
&gt; On Tue, Mar 10, 2020 at 5:07 PM Umar Hayat &lt;<a href="mailto:m.umarkiani@gmail.com" target="_blank">m.umarkiani@gmail.com</a>&gt; wrote:<br>
&gt; <br>
&gt;&gt; Hi Hackers,<br>
&gt;&gt; Attached patch address mentisbt-422<br>
&gt;&gt; &lt;<a href="https://www.pgpool.net/mantisbt/view.php?id=422" rel="noreferrer" target="_blank">https://www.pgpool.net/mantisbt/view.php?id=422</a>&gt; for pg_enc utility.<br>
&gt;&gt; User can provide user name , password pair in a file to encrypt and add<br>
&gt;&gt; them to pool_passwd file.<br>
&gt;&gt; A new --input-file option is added in pg_enc. Using this pg_enc will parse<br>
&gt;&gt; the username:password pairs from provide input file and it will add<br>
&gt;&gt; username:AESxxxxx value in pool_passwod file.<br>
&gt;&gt;<br>
&gt;&gt; Attached contains:<br>
&gt;&gt; 1. Implementation of feature in pg_enc tool<br>
&gt;&gt; 2. Documentation update<br>
&gt;&gt;<br>
&gt;&gt; Regards<br>
&gt;&gt; Umar Hayat<br>
&gt;&gt; Principle Software Engineer<br>
&gt;&gt; EnterpriseDB: <a href="https://www.enterpriseDB.com" rel="noreferrer" target="_blank">https://www.enterpriseDB.com</a><br>
&gt;&gt;<br>
&gt;&gt;<br>
&gt;&gt;<br>
</blockquote></div></div>