Re: [RFC] uuid_generate_time_safe() without uuidd should always return -1

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, Feb 22, 2022 at 02:48:42AM +0100, Stanislav Brabec wrote:
> > > == RETURN VALUE
> > > 
> > > The newly created UUID is returned in the memory location pointed to by
> > > _out_. *uuid_generate_time_safe*() returns zero if the UUID has been
> > > generated in a safe manner, 1 if the UUID has been generated in a manner
> > > that is safe for a single UID, -1 otherwise.
> > 
> > Make sense ;-)
> 
> Do you think that we could make such API change (3 return values instead 2)?

Good question.

Frankly, not sure, from google it seems uuid_generate_time_safe() is
used by users.

Maybe introduce a new function which returns info about quality 

    uuid_generate_time2(uuid, &state)

where state is 

    UUID_STATE_ASYNC        (gettimwofday() + MAC)
    UUID_STATE_SYNC_PROCESS (per-propcess unique UUID) 
    UUID_STATE_SYNC_SYSTEM  (per system unique UUID)

but maybe with better name than uuid_generate_time2 ;-)

And in man page describe that uuid_generate_time_safe() returns
UUID_STATE_SYNC_PROCESS or UUID_STATE_SYNC_SYSTEM, and keep the
function unchanged.

So, guys from SAP will check for UUID_STATE_SYNC_SYSTEM to be
absolutely sure that UUIDs are in the best possible quality. And one
day in far future if anyone will implement synchronization between
more systems we can introduce UUID_STATE_SYNC_CLUSTER ;-)


We can also add --state to uuidgen(1) to return info about it on
command line.

> I think that most implementations compare with zero, so it should be OK.

Not sure, I guess 

    if (uuid_generate_time_safe(u) == -1)
        errx("universe collapsed");

is also possible ;-(

    Karel

-- 
 Karel Zak  <kzak@xxxxxxxxxx>
 http://karelzak.blogspot.com




[Index of Archives]     [Netdev]     [Ethernet Bridging]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux Admin]     [Samba]

  Powered by Linux