MUNGE(3)
π¦ MUNGE(3) β MUNGE Uid 'N' Gid Emporium π¦
okay bestie, sit down, hydrate, because we're about to talk about the MUNGE core functions from the MUNGE Uid 'N' Gid Emporium and honestly? it's giving secure credential energy β¨ no cap.
πΈ NAME πΈ
munge_encode, munge_decode, munge_strerror β the MUNGE core functions, aka the main character trio π
β¨ SYNOPSIS β¨
#include <munge.h>
munge_err_t munge_encode (char **cred, munge_ctx_t ctx,
const void *buf, int len);
munge_err_t munge_decode (const char *cred, munge_ctx_t ctx,
void **buf, int *len, uid_t *uid, gid_t *gid);
const char * munge_strerror (munge_err_t e);
cc `pkg-config --cflags --libs munge` -o foo foo.c
like yes, that's the whole vibe check right there π«Ά
π DESCRIPTION π
So, munge_encode() creates a credential contained in a null-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. And listen β the caller is responsible for freeing the memory referenced by cred. That's on you, bestie, not on us π
munge_decode() validates the null-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 (up to 1 MB), buf will be set to point to this data, and len will be set to its length. An additional null byte 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. iconic behavior, fr fr π
And munge_strerror() returns a descriptive text string describing the MUNGE error number e. she's the translator of the group chat π¬
π RETURN VALUE π
munge_encode() and munge_decode() return EMUNGE_SUCCESS on success, or a MUNGE error otherwise. If a MUNGE context was used, it may contain a more detailed error message accessible via munge_ctx_strerror(). iykyk β the context is where the real tea is β
munge_strerror() returns a pointer to a null-terminated constant text string; this string should not be freed or modified by the caller. do not touch her, she is not yours π
π ERRORS π
EMUNGE_SUCCESSβ Success. slay! πEMUNGE_SNAFUβ Internal error. something went sideways internally, we don't talk about it πEMUNGE_BAD_ARGβ Invalid argument. that argument was not it.EMUNGE_BAD_LENGTHβ Exceeded the maximum message length as specified by themungedconfiguration. too long, bestie, the daemon said no πEMUNGE_OVERFLOWβ Exceeded the maximum length of a buffer. overflowed. spilling out. not cute.EMUNGE_NO_MEMORYβ Unable to allocate the requisite memory. the RAM said "I'm booked" πEMUNGE_SOCKETβ Unable to communicate with the daemon on the domain socket. ghosted by the daemon, literally π«₯EMUNGE_BAD_CREDβ The credential does not match the specified format. wrong shape, wrong vibe.EMUNGE_BAD_VERSIONβ The credential contains an unsupported version number. that version is so last season.EMUNGE_BAD_CIPHERβ The credential contains an unsupported cipher type. cipher? don't know her.EMUNGE_BAD_MACβ The credential contains an unsupported MAC type. (not the makeup kind, bestie.)EMUNGE_BAD_ZIPβ The credential contains an unsupported compression type. the zip is zipped in a way we don't recognize πEMUNGE_BAD_REALMβ The credential contains an unrecognized security realm. which realm?? not this one π§EMUNGE_CRED_INVALIDβ 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. someone messed with it, periodt.EMUNGE_CRED_EXPIREDβ The credential was successfully decoded, but its decode time is later than its encode time by more than its TTL. The clocks on the encoding and decoding hosts could be out of sync. she's expired, throw her out ποΈEMUNGE_CRED_REWOUNDβ The credential was successfully decoded, but its decode time is earlier than its encode time by more than its TTL. The clocks on the encoding and decoding hosts are out of sync. time travel?? not on our watch β°EMUNGE_CRED_REPLAYEDβ The credential was successfully decoded, but it has been previously decoded on this host within its TTL skew. we've seen this one before, bestie, stop replaying πEMUNGE_CRED_UNAUTHORIZEDβ The client is not authorized to decode the credential based upon the effective user and/or group ID of the process. you shall not pass, you're not on the list π«
π EXAMPLE π
The following example program illustrates the use of a MUNGE credential to ascertain the effective user and group ID of the encoding process. look at her go, so demure, so mindful β¨
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <munge.h>
int
main (int argc, char *argv[])
{
char *cred;
munge_err_t err;
uid_t uid;
gid_t gid;
err = munge_encode (&cred, NULL, NULL, 0);
if (err != EMUNGE_SUCCESS) {
fprintf (stderr, "Error: Failed to encode credential: %s\n",
munge_strerror (err));
exit (EXIT_FAILURE);
}
err = munge_decode (cred, NULL, NULL, NULL, &uid, &gid);
if (err != EMUNGE_SUCCESS) {
fprintf (stderr, "Error: Failed to decode credential: %s\n",
munge_strerror (err));
exit (EXIT_FAILURE);
}
printf ("uid=%d gid=%d\n", uid, gid);
free (cred);
exit (EXIT_SUCCESS);
}
β NOTES β
Both munge_encode() and munge_decode() may allocate memory that the caller is responsible for freeing.
Failure to do so will result in a memory leak. leaking is not the aesthetic, bestie β free your memory, it's self care π
π¦ AUTHOR π¦
Chris Dunlap <cdunlap@llnl.gov> β the icon, the legend, the moment π
π COPYRIGHT π
Copyright (C) 2007-2025 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.
π SEE ALSO π
and also, for the girlies who like to browse:
k bye bestie, that's the whole page, love u, go encode something π β¨
this has been munge-0.5.18, dated 2026-02-10, from the MUNGE(3) manual β mwah ππ«Ά
π¦ where this page comes from
- arch rolling: munge 0.5.18-2 Β· GPL-3.0-or-later AND LGPL-3.0-or-later
- fedora 43: munge-devel 0.5.18-1.fc43 Β· GPL-3.0-or-later AND LGPL-3.0-or-later
- fedora 43: munge-devel 0.5.18-1.fc43 Β· GPL-3.0-or-later AND LGPL-3.0-or-later
- fedora 44: munge-devel 0.5.18-1.fc44 Β· GPL-3.0-or-later AND LGPL-3.0-or-later
- fedora 44: munge-devel 0.5.18-1.fc44 Β· GPL-3.0-or-later AND LGPL-3.0-or-later
- nixpkgs unstable: munge 0.5.18
- Copyright (C) 2007-2025 Lawrence Livermore National Security, LLC
- Copyright (C) 2002-2007 The Regents of the University of California
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms