6516 pkgadm shouldn't use makeuuid from closed admin consolidation

Review Request #121 — Created Dec. 16, 2015 and updated

alp
illumos-gate
general

pkgadm code uses external closed makeuuid tool to generate uuids. Now when we have uuidgen in gate, it's better to replace it with uuidgen.

pfexec ./proto/root_i386/usr/bin/pkgadm -vvv lock -a -o aaa && echo 1

[ 8109 4] open lock file root </> file </tmp/.ai.pkg.zone.lock-afdb66cf-1dd1-11b2-a049-000d560ddc3e>

[ 8109 4] open lock file: opened and locked fd <3>

[ 8109 4] acquire lock key=<> object=<aaa> quiet=<0> exclusive=<1>

[ 8109 4] find lock object <aaa> key <>

[ 8109 4] find lock record not found

[ 8109 4] acquire exclusive lock result <-2> record <-1>

[ 8109 4] acquiring exclusive lock on object <aaa>

[ 8109 4] generated new unique key using date: 2702117085-1903201-0000f320827d7acf

[ 8109 4] adding exclusive lock pos <0> object <(null)> key <aaa> pid <134509896> zid <0>

2702117085-1903201-0000f320827d7acf
1
We can see that keys have correct format.

  • 0
  • 0
  • 3
  • 0
  • 3
Description From Last Updated
alp
tsoome
  1. Ship It!
  2. 
      
jeffpc
  1. Ship It!
  2. 
      
rm
  1. 
      
  2. usr/src/cmd/svr4pkg/pkgadm/lock.c (Diff revision 2)
     
     

    Rather than this whole mess of forking and execing a uuid program and then trying to parse it and falling back, we should just simple call uuid_generate() and uuid_unparse_lower(). It's simpler code, less forks, and less error paths.

  3. 
      
alp
rm
  1. 
      
  2. usr/src/cmd/svr4pkg/pkgadm/lock.c (Diff revision 3)
     
     

    While LOCK_KEY_MAXLEN and UUID_PRINTABLE_STRING_LENGTH are the same, I would probably use UUID_PRINTABLE_STRING_LENGTH here and instead use strndup with LOCK_KEY_MAXLEN when doing the dup at the end.

  3. 
      
alp
tsoome
  1. 
      
  2. usr/src/cmd/svr4pkg/pkgadm/lock.c (Diff revision 4)
     
     

    you probably want to use UUID_PRINTABLE_STRING_LENGTH at line 2078 as well:)

    1. I'm not sure. Intention is to use UUID_PRINTABLE_STRING_LENGTH with libuuid functions and if necessary truncate it to LOCK_KEY_MAXLEN for pkgadm functions. In fact they are the same, so it doesn't matter much.

    2. seems logical. well, I dont really mind:)

  3. 
      
alp
tsoome
  1. Ship It!
  2. 
      
jeffpc
  1. Ship It!
  2. 
      
andy_js
  1. Ship It!
  2. 
      
alp
Review request changed

Change Summary:

I considered just remove makeuuid usage.

Testing Done:

~  

pfexec pkgadm -vvv lock -a -o aaa && echo 1# [101555 0] open lock file root </> file </tmp/.ai.pkg.zone.lock-afdb66cf-1dd1-11b2-a049-000d560ddc3e>

  ~

pfexec ./proto/root_i386/usr/bin/pkgadm -vvv lock -a -o aaa && echo 1

   
~  

[101555 0] open lock file: opened and locked fd <3>

  ~

[ 8109 4] open lock file root </> file </tmp/.ai.pkg.zone.lock-afdb66cf-1dd1-11b2-a049-000d560ddc3e>

   
~  

[101555 0] acquire lock key=<> object=<aaa> quiet=<0> exclusive=<1>

  ~

[ 8109 4] open lock file: opened and locked fd <3>

   
~  

[101555 0] find lock object <aaa> key <>

  ~

[ 8109 4] acquire lock key=<> object=<aaa> quiet=<0> exclusive=<1>

   
~  

[101555 0] find lock record not found

  ~

[ 8109 4] find lock object <aaa> key <>

   
~  

[101555 0] acquire exclusive lock result <-2> record <-1>

  ~

[ 8109 4] find lock record not found

   
~  

[101555 0] acquiring exclusive lock on object <aaa>

  ~

[ 8109 4] acquire exclusive lock result <-2> record <-1>

   
~  

[101555 0] generated new unique key using libuuid: 6800b80c-16ce-4369-9585-a8ef841b9d65

  ~

[ 8109 4] acquiring exclusive lock on object <aaa>

   
~  

[101555 0] adding exclusive lock pos <0> object <(null)> key <aaa> pid <134509384> zid <0>

  ~

[ 8109 4] generated new unique key using date: 2702117085-1903201-0000f320827d7acf

   
~  

6800b80c-16ce-4369-9585-a8ef841b9d65

  ~

[ 8109 4] adding exclusive lock pos <0> object <(null)> key <aaa> pid <134509896> zid <0>

   
~  

We can see that keys have correct format.

  ~

2702117085-1903201-0000f320827d7acf

  + 1
  + We can see that keys have correct format.

Diff:

Revision 5 (+205 -234)

Show changes

ptribble
  1. Ship It!
  2. 
      
tsoome
  1. Ship It!
  2. 
      
kmays
  1. Ship It!
  2. 
      
Loading...