1 <?xml version='
1.0'
?> <!--*-nxml-*-->
2 <!DOCTYPE refentry PUBLIC
"-//OASIS//DTD DocBook XML V4.2//EN"
3 "http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd">
6 This file is part of systemd.
8 Copyright 2012 Lennart Poettering
10 systemd is free software; you can redistribute it and/or modify it
11 under the terms of the GNU Lesser General Public License as published by
12 the Free Software Foundation; either version 2.1 of the License, or
13 (at your option) any later version.
15 systemd is distributed in the hope that it will be useful, but
16 WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 Lesser General Public License for more details.
20 You should have received a copy of the GNU Lesser General Public License
21 along with systemd; If not, see <http://www.gnu.org/licenses/>.
24 <refentry id=
"sd_id128_randomize">
27 <title>sd_id128_randomize
</title>
28 <productname>systemd
</productname>
32 <contrib>Developer
</contrib>
33 <firstname>Lennart
</firstname>
34 <surname>Poettering
</surname>
35 <email>lennart@poettering.net
</email>
41 <refentrytitle>sd_id128_randomize
</refentrytitle>
42 <manvolnum>3</manvolnum>
46 <refname>sd_id128_randomize
</refname>
47 <refname>sd_id128_get_machine
</refname>
48 <refname>sd_id128_get_boot
</refname>
49 <refpurpose>Generate or retrieve
128 bit IDs
</refpurpose>
54 <funcsynopsisinfo>#include
<systemd/sd-id128.h
></funcsynopsisinfo>
57 <funcdef>int
<function>sd_id128_randomize
</function></funcdef>
58 <paramdef>sd_id128_t*
<parameter>ret
</parameter></paramdef>
62 <funcdef>int
<function>sd_id128_get_machine
</function></funcdef>
63 <paramdef>sd_id128_t*
<parameter>ret
</parameter></paramdef>
67 <funcdef>int
<function>sd_id128_get_boot
</function></funcdef>
68 <paramdef>sd_id128_t*
<parameter>ret
</parameter></paramdef>
75 <title>Description
</title>
77 <para><function>sd_id128_randomize()
</function>
78 generates a new randomized
128 bit ID and returns it
79 in
<parameter>ret
</parameter>. Every invocation
80 returns a new randomly generated ID. This uses the
81 <filename>/dev/urandom
</filename> kernel random number
84 <para><function>sd_id128_get_machine()
</function>
85 returns the machine ID of the executing host. This
87 <citerefentry><refentrytitle>machine-id
</refentrytitle><manvolnum>5</manvolnum></citerefentry>
88 file. This function caches the machine ID internally
89 to make retrieving the machine ID a cheap
92 <para><function>sd_id128_get_boot()
</function> returns
93 the boot ID of the executing kernel. This reads and
95 <filename>/proc/sys/kernel/random/boot_id
</filename>
96 file exposed by the kernel. It is randomly generated
97 early at boot and is unique for every running kernel
99 <citerefentry><refentrytitle>random
</refentrytitle><manvolnum>4</manvolnum></citerefentry>
100 for more information. This function also internally
101 caches the returned ID to make this call a cheap
105 <function>sd_id128_randomize()
</function> and
106 <function>sd_id128_get_boot()
</function> always return
108 ID.
<function>sd_id128_get_machine()
</function> will
109 also return a UUID v4 compatible ID on new
110 installations, but might not on older. It is possible
111 to convert the machine ID into an UUID v4 compatible
112 one. For more information see
113 <citerefentry><refentrytitle>machine-id
</refentrytitle><manvolnum>5</manvolnum></citerefentry>.
</para>
115 <para>For more information about the
116 <literal>sd_id128_t
</literal> type see
117 <citerefentry><refentrytitle>sd-id128
</refentrytitle><manvolnum>7</manvolnum></citerefentry>.
</para>
119 <para><citerefentry><refentrytitle>journalctl
</refentrytitle><manvolnum>1</manvolnum></citerefentry>'s
120 <literal>--new-id
</literal> command may be used as
121 command line front-end for
122 <function>sd_id128_randomize()
</function>.
</para>
126 <title>Return Value
</title>
128 <para>The three calls return
0 on success (in which
129 case
<parameter>ret
</parameter> is filled in), or a
130 negative errno-style error code.
</para>
136 <para>The
<function>sd_id128_randomize()
</function>,
137 <function>sd_id128_get_machine()
</function> and
138 <function>sd_id128_get_boot()
</function> interfaces
139 are available as shared library, which can be compiled
140 and linked to with the
141 <literal>libsystemd-id128
</literal>
142 <citerefentry><refentrytitle>pkg-config
</refentrytitle><manvolnum>1</manvolnum></citerefentry>
147 <title>See Also
</title>
150 <citerefentry><refentrytitle>systemd
</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
151 <citerefentry><refentrytitle>sd-id128
</refentrytitle><manvolnum>7</manvolnum></citerefentry>,
152 <citerefentry><refentrytitle>machine-id
</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
153 <citerefentry><refentrytitle>random
</refentrytitle><manvolnum>4</manvolnum></citerefentry>