The munge_encode() function creates a credential contained in a
NUL-terminated base64 string. A payload specified by a buffer buf
of length len can be encapsulated in as well. If the munge context
ctx is NULL, the default context will be used. A pointer to the
resulting credential is returned via cred; on error, it is set to NULL.
The caller is responsible for freeing the memory referenced by cred.
The munge_decode() function validates the NUL-terminated credential
cred. If the munge context ctx is not NULL, it will be set to
that used to encode the credential. If buf and len are not NULL,
memory will be allocated for the encapsulated payload, buf will be set
to point to this data, and len will be set to its length. An additional
NUL character will be appended to this payload data but not included in its
length. If no payload exists, buf will be set to NULL and len
will be set to 0. For certain errors (i.e., EMUNGE_CRED_EXPIRED,
EMUNGE_CRED_REWOUND, EMUNGE_CRED_REPLAYED), payload memory will
still be allocated if necessary. The caller is responsible for freeing
the memory referenced by buf. If uid or gid is not NULL,
they will be set to the UID/GID of the process that created the credential.
The munge_strerror() function returns a descriptive text string
describing the munge error number e.
The munge_encode() and munge_decode() functions return
EMUNGE_SUCCESS on success; otherwise, a munge error number is returned.
If a munge context was used, it may contain a more detailed error message
accessible via munge_ctx_strerror().
The munge_strerror() function returns a pointer to a NUL-terminated
constant text string; this string should not be freed or modified by the
Exceeded the maximum message length as specified by the munged
Exceeded the maximum length of a buffer.
Unable to allocate the requisite memory.
Unable to communicate with the daemon on the domain socket.
The credential does not match the specified format.
The credential contains an unsupported version number.
The credential contains an unsupported cipher type.
The credential contains an unsupported MAC type.
The credential contains an unsupported compression type.
The credential contains an unrecognized security realm.
The credential is invalid. This means the credential could not be
successfully decoded. More than likely, the secret keys on the encoding
and decoding hosts do not match. Another possibility is that the credential
has been altered since it was encoded.
The credential has expired. This means more than TTL seconds have elapsed
sinced the credential was encoded. Another possibility is that the clocks
on the encoding and decoding hosts are out of sync.
The credential appears to have been encoded at some point in the future.
This means the clock on the decoding host is slower than that of the
encoding host by more than the allowable clock skew. More than likely,
the clocks on the encoding and decoding hosts are out of sync.
The credential has been previously decoded on this host.
The client is not authorized to decode the credential based upon the effective
user and/or group ID of the process.
The following example program illustrates the use of a munge credential to
ascertain the effective user and group ID of the encoding process.
Copyright (C) 2007-2010 Lawrence Livermore National Security, LLC.
Copyright (C) 2002-2007 The Regents of the University of California.
MUNGE is free software: you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free
Software Foundation, either version 3 of the License, or (at your option)
any later version. Additionally for the MUNGE library (libmunge), you
can redistribute it and/or modify it under the terms of the GNU Lesser
General Public License as published by the Free Software Foundation,
either version 3 of the License, or (at your option) any later version.