Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

UUID

66 views
Skip to first unread message

Cecil Westerhof

unread,
May 30, 2018, 4:28:04 PM5/30/18
to
When looking at:
http://core.tcl.tk/tcllib/doc/trunk/embedded/www/tcllib/files/modules/uuid/uuid.html

I read:
::uuid::uuid generate

Creates a type 4 uuid by MD5 hashing a number of bits of variant
data including the time and hostname. Returns the string
representation of the new uuid.

But when I read:
https://en.wikipedia.org/wiki/Universally_unique_identifier#Version_4_(random)

I see:
A version 4 UUID is randomly generated.

Is the description wrong, or is the implementation wrong?

--
Cecil Westerhof
Senior Software Engineer
LinkedIn: http://www.linkedin.com/in/cecilwesterhof

Rich

unread,
May 30, 2018, 5:00:22 PM5/30/18
to
Cecil Westerhof <Ce...@decebal.nl> wrote:
> When looking at:
> http://core.tcl.tk/tcllib/doc/trunk/embedded/www/tcllib/files/modules/uuid/uuid.html
>
> I read:
> ::uuid::uuid generate
>
> Creates a type 4 uuid by MD5 hashing a number of bits of variant
> data including the time and hostname. Returns the string
> representation of the new uuid.
>
> But when I read:
> https://en.wikipedia.org/wiki/Universally_unique_identifier#Version_4_(random)
>
> I see:
> A version 4 UUID is randomly generated.
>
> Is the description wrong, or is the implementation wrong?

Well, your url is to the "documentation", so at least the documentation
is wrong, because what is described in the documentation would be
closest to a type 1 UUID not a type 4.

But, I've encountered issues with the Tcllib implimentation on Linux
because part of what it attempts to do is parse the output of ifconfig
(to get a MAC address) and if one's ifconfig does not match what it is
looking for (or if it thinks it can't find ifconfig) then an error is
generated. Apparently Slackware's ifconfig outputs something slightly
different than what the Tcllib version was written to expect.

Brad Lanam

unread,
May 30, 2018, 5:26:51 PM5/30/18
to
On Wednesday, May 30, 2018 at 2:00:22 PM UTC-7, Rich wrote:
> [...]
> But, I've encountered issues with the Tcllib implimentation on Linux
> because part of what it attempts to do is parse the output of ifconfig
> (to get a MAC address) and if one's ifconfig does not match what it is
> looking for (or if it thinks it can't find ifconfig) then an error is
> generated. Apparently Slackware's ifconfig outputs something slightly
> different than what the Tcllib version was written to expect.

Hmmm....and there's now a Linux system that does not have 'ifconfig', instead
using /bin/ip. So that will fail on some systems.

Cecil Westerhof

unread,
May 30, 2018, 11:28:04 PM5/30/18
to
I think I write my own version for Linux then. ;-)

Harald Oehlmann

unread,
May 31, 2018, 12:50:12 AM5/31/18
to
Am 31.05.2018 um 05:26 schrieb Cecil Westerhof:
> Brad Lanam <brad....@gmail.com> writes:
>
>> On Wednesday, May 30, 2018 at 2:00:22 PM UTC-7, Rich wrote:
>>> [...]
>>> But, I've encountered issues with the Tcllib implimentation on Linux
>>> because part of what it attempts to do is parse the output of ifconfig
>>> (to get a MAC address) and if one's ifconfig does not match what it is
>>> looking for (or if it thinks it can't find ifconfig) then an error is
>>> generated. Apparently Slackware's ifconfig outputs something slightly
>>> different than what the Tcllib version was written to expect.
>>
>> Hmmm....and there's now a Linux system that does not have 'ifconfig', instead
>> using /bin/ip. So that will fail on some systems.
>
> I think I write my own version for Linux then. ;-)
>

For Windows, TWAPI has a uuid command which returns a system-generated
uuid V4.

joheid

unread,
May 31, 2018, 5:12:26 AM5/31/18
to
Wouldn't it be better to fix/improve the tcllib-version?
kind regards
joachim

Cecil Westerhof

unread,
May 31, 2018, 6:44:04 AM5/31/18
to
joheid <joh...@ttiger.in-berlin.de> writes:

> Wouldn't it be better to fix/improve the tcllib-version?
> kind regards

Probably. But I am not a tcl maintainer, just a newby (at tcl). And I
want it now. ;-) And I already have it.

My version uses /dev/random or /dev/urandom which is a *NIX resource.
For Windows something else should be done. But if I understand it
correctly in Windows there is a correct working version in TWAPI.

I do not know if there are other devices where tcl runs, but there is
no /dev/random and /dev/urandom.

Cecil Westerhof

unread,
May 31, 2018, 11:14:05 AM5/31/18
to
Cecil Westerhof <Ce...@decebal.nl> writes:

> Brad Lanam <brad....@gmail.com> writes:
>
>> On Wednesday, May 30, 2018 at 2:00:22 PM UTC-7, Rich wrote:
>>> [...]
>>> But, I've encountered issues with the Tcllib implimentation on Linux
>>> because part of what it attempts to do is parse the output of ifconfig
>>> (to get a MAC address) and if one's ifconfig does not match what it is
>>> looking for (or if it thinks it can't find ifconfig) then an error is
>>> generated. Apparently Slackware's ifconfig outputs something slightly
>>> different than what the Tcllib version was written to expect.
>>
>> Hmmm....and there's now a Linux system that does not have 'ifconfig', instead
>> using /bin/ip. So that will fail on some systems.
>
> I think I write my own version for Linux then. ;-)

Here it is:
http://wiki.tcl.tk/55346

Rich

unread,
May 31, 2018, 11:39:08 AM5/31/18
to
Cecil Westerhof <Ce...@decebal.nl> wrote:
> Cecil Westerhof <Ce...@decebal.nl> writes:
>
>> Brad Lanam <brad....@gmail.com> writes:
>>
>>> On Wednesday, May 30, 2018 at 2:00:22 PM UTC-7, Rich wrote:
>>>> [...]
>>>> But, I've encountered issues with the Tcllib implimentation on Linux
>>>> because part of what it attempts to do is parse the output of ifconfig
>>>> (to get a MAC address) and if one's ifconfig does not match what it is
>>>> looking for (or if it thinks it can't find ifconfig) then an error is
>>>> generated. Apparently Slackware's ifconfig outputs something slightly
>>>> different than what the Tcllib version was written to expect.
>>>
>>> Hmmm....and there's now a Linux system that does not have 'ifconfig', instead
>>> using /bin/ip. So that will fail on some systems.
>>
>> I think I write my own version for Linux then. ;-)
>
> Here it is:
> http://wiki.tcl.tk/55346

That's a lot of overkill when for a type 4 UUID you need to:

1) pull 128 bits of data from /dev/urandom
2) set the type bits in the 128 bits to "v4"
3) set the variant bits to whichever variant you want to use

And both of those "sets" can be done by bit masking the byte containing
the version and the byte containing the variant.

Hypnotoad

unread,
May 31, 2018, 12:09:22 PM5/31/18
to
Tcllib maintainer for the module here. And I'm the schmuck who thought {exec ifconfig} was portable enough for everyone. I was wrong.

I rather like the /dev/urandom approach. And I'll tweak the library to use that in the future. At least on (Li|U)nix platforms.

--Sean "The Hypnotoad" Woods

Hypnotoad

unread,
May 31, 2018, 12:22:46 PM5/31/18
to
On Thursday, May 31, 2018 at 11:39:08 AM UTC-4, Rich wrote:
And it's officially in tcllib: https://core.tcl-lang.org/tcllib/info/d5e2fcf04b92a3c4

sled...@gmail.com

unread,
May 31, 2018, 3:59:39 PM5/31/18
to
Hmmm "schmuck"...Have been looking for a Yiddish translation of the tcl docs. Know of any...

Ralf Fassel

unread,
Jun 1, 2018, 5:30:19 AM6/1/18
to
* Hypnotoad <yo...@etoyoc.com>
| On Thursday, May 31, 2018 at 11:39:08 AM UTC-4, Rich wrote:
--<snip-snip>--
| > 1) pull 128 bits of data from /dev/urandom
| > 2) set the type bits in the 128 bits to "v4"
| > 3) set the variant bits to whichever variant you want to use
| >
| > And both of those "sets" can be done by bit masking the byte containing
| > the version and the byte containing the variant.
>
| And it's officially in tcllib: https://core.tcl-lang.org/tcllib/info/d5e2fcf04b92a3c4
=>
| set machinfo [read $fin 128]

Actually, you're reading 128 BYTES instead of 128 BITS (aka 16 Bytes)...
Don't know if that matters...

R'

Hypnotoad

unread,
Jun 1, 2018, 7:22:57 PM6/1/18
to
Honestly... no, it doesn't matter. We are just inputting noise that is (hopefully) unique to this machine.
0 new messages