<html>
  <head>
    <meta content="text/html; charset=ISO-8859-1"
      http-equiv="Content-Type">
  </head>
  <body bgcolor="#FFFFFF" text="#000000">
    <div class="moz-cite-prefix">On 06/07/2013 10:23 AM, Tomas Babej
      wrote:<br>
    </div>
    <blockquote cite="mid:51B19888.2050803@redhat.com" type="cite">
      <meta content="text/html; charset=ISO-8859-1"
        http-equiv="Content-Type">
      <div class="moz-cite-prefix">On 05/15/2013 01:36 PM, Ana
        Krivokapic wrote:<br>
      </div>
      <blockquote cite="mid:51937353.3090501@redhat.com" type="cite">
        <pre wrap="">On 05/15/2013 12:29 PM, Petr Viktorin wrote:
</pre>
        <blockquote type="cite">
          <pre wrap="">On 05/15/2013 12:04 PM, Tomas Babej wrote:
</pre>
          <blockquote type="cite">
            <pre wrap="">On 05/15/2013 11:40 AM, Ana Krivokapic wrote:
</pre>
            <blockquote type="cite">
              <pre wrap="">Hello,

See the commit message for details.

<a moz-do-not-send="true" class="moz-txt-link-freetext" href="https://fedorahosted.org/freeipa/ticket/3594">https://fedorahosted.org/freeipa/ticket/3594</a>



_______________________________________________
Freeipa-devel mailing list
<a moz-do-not-send="true" class="moz-txt-link-abbreviated" href="mailto:Freeipa-devel@redhat.com">Freeipa-devel@redhat.com</a>
<a moz-do-not-send="true" class="moz-txt-link-freetext" href="https://www.redhat.com/mailman/listinfo/freeipa-devel">https://www.redhat.com/mailman/listinfo/freeipa-devel</a>
</pre>
            </blockquote>
            <pre wrap="">+    def regenerate_ca_file(self, ca_file):
+        dm_pwd_fd, dm_pwd_fname = tempfile.mkstemp()
+        keydb_pwd_fd, keydb_pwd_fname = tempfile.mkstemp()
+
+        os.write(dm_pwd_fd, self.dirman_password)
+        os.close(dm_pwd_fd)
+
+        keydb_pwd = ''
+        with open('/etc/pki/pki-tomcat/password.conf') as f:
+            for line in f.readlines():
+                key, value = line.strip().split('=')
+                if key == 'internal':
+                    keydb_pwd = value
+                    break
+
+        os.write(keydb_pwd_fd, keydb_pwd)
+        os.close(keydb_pwd_fd)
+
+        ipautil.run([
+            '/usr/bin/PKCS12Export',
+            '-d', '/etc/pki/pki-tomcat/alias/',
+            '-p', keydb_pwd_fname,
+            '-w', dm_pwd_fname,
+            '-o', ca_file
+        ])
+

If the PKCS12Export call fails (returns non-zero code), we raise
exception here, and the temporary files are never removed.

+        os.remove(dm_pwd_fname)
+        os.remove(keydb_pwd_fname)

This might not be a big issue since mkstemp() call creates temporary
file readable and writable only be given user ID,
however, we should not leave files with passwords in plaintext on the
disk if it is not necessary.

This can be easily prevented by wrapping the call up with
try-chatch-finally block, or using raiseonerr=False options of run
method.
</pre>
          </blockquote>
          <pre wrap="">Or by using ipautil.write_tmp_file() – the file it creates is always
removed after it's closed/garbage collected, and it has a name attribute.

</pre>
        </blockquote>
        <pre wrap="">Updated patch uses `ipautil.write_tmp_file()`.

</pre>
        <br>
        <fieldset class="mimeAttachmentHeader"></fieldset>
        <br>
        <pre wrap="">_______________________________________________
Freeipa-devel mailing list
<a moz-do-not-send="true" class="moz-txt-link-abbreviated" href="mailto:Freeipa-devel@redhat.com">Freeipa-devel@redhat.com</a>
<a moz-do-not-send="true" class="moz-txt-link-freetext" href="https://www.redhat.com/mailman/listinfo/freeipa-devel">https://www.redhat.com/mailman/listinfo/freeipa-devel</a></pre>
      </blockquote>
      I'm testing on a fairly updated F19 VM:<br>
      <br>
      I'm getting the following error when preparing the replica info
      file:<br>
      <br>
      [root@vm-002 ~]# ipa-replica-prepare vm-003.ipa.com --ip-address
      192.168.122.213<br>
      Directory Manager (existing master) password: <br>
      <br>
      Preparing replica for vm-003.ipa.com from vm-002.ipa.com<br>
      Command '/usr/bin/PKCS12Export -d /etc/pki/pki-tomcat/alias/ -p
      /tmp/tmp15Je9R -w /tmp/tmpCGD5Sr -o /root/cacert.p12' returned non<br>
      <br>
      When trying that manually:<br>
      <br>
      [root@vm-002 ~]# /usr/bin/PKCS12Export -d
      /etc/pki/pki-tomcat/alias/ -p /tmp/tmp15Je9R -w /tmp/tmpCGD5Sr -o
      /root/cacert.p12<br>
      Exception in thread "main" java.lang.NoClassDefFoundError:
      org/mozilla/jss/util/PasswordCallback<br>
          at java.lang.Class.getDeclaredMethods0(Native Method)<br>
          at java.lang.Class.privateGetDeclaredMethods(Class.java:2451)<br>
          at java.lang.Class.getMethod0(Class.java:2694)<br>
          at java.lang.Class.getMethod(Class.java:1622)<br>
          at
      sun.launcher.LauncherHelper.getMainMethod(LauncherHelper.java:494)<br>
          at
      sun.launcher.LauncherHelper.checkAndLoadMain(LauncherHelper.java:486)<br>
      Caused by: java.lang.ClassNotFoundException:
      org.mozilla.jss.util.PasswordCallback<br>
          at java.net.URLClassLoader$1.run(URLClassLoader.java:366)<br>
          at java.net.URLClassLoader$1.run(URLClassLoader.java:355)<br>
          at java.security.AccessController.doPrivileged(Native Method)<br>
          at java.net.URLClassLoader.findClass(URLClassLoader.java:354)<br>
          at java.lang.ClassLoader.loadClass(ClassLoader.java:423)<br>
          at
      sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)<br>
          at java.lang.ClassLoader.loadClass(ClassLoader.java:356)<br>
          ... 6 more<br>
      <br>
      We might need to investigate what causes this, and if the issue is
      not on our side, file appropriate bugs.<br>
      <br>
      Tomas<br>
    </blockquote>
    <br>
    This is an bug in the PKCS12Export utility. I opened a Bugzilla for
    it: <a class="moz-txt-link-freetext" href="https://bugzilla.redhat.com/show_bug.cgi?id=972753">https://bugzilla.redhat.com/show_bug.cgi?id=972753</a>.<br>
    <br>
    Below is a workaround, as suggested by Ade:<br>
    <alee> as for a workaround, you could simply edit the file
    that starts PKCS12Export<br>
    <alee> edit /usr/bin/PKCS12Export<br>
    <alee> after line 134, simply add the line : 
    CP=/usr/lib/java/jss4.jar<br>
    <alee> but thats just a temp fix for f19 only<br>
    <alee> not the real fix,<br>
    <alee> you'll need the real fix checked in to pass the patch<br>
    <br>
    <pre class="moz-signature" cols="72">-- 
Regards,

Ana Krivokapic
Associate Software Engineer
FreeIPA team
Red Hat Inc.</pre>
  </body>
</html>