/*++ /* NAME /* mypwd 3 /* SUMMARY /* caching getpwnam_r()/getpwuid_r() /* SYNOPSIS /* #include <mypwd.h> /* /* int mypwuid_err(uid, pwd) /* uid_t uid; /* struct mypasswd **pwd; /* /* int mypwnam_err(name, pwd) /* const char *name; /* struct mypasswd **pwd; /* /* void mypwfree(pwd) /* struct mypasswd *pwd; /* BACKWARDS COMPATIBILITY /* struct mypasswd *mypwuid(uid) /* uid_t uid; /* /* struct mypasswd *mypwnam(name) /* const char *name; /* DESCRIPTION /* This module maintains a reference-counted cache of password /* database lookup results. The idea is to avoid making repeated /* getpw*() calls for the same information. /* /* mypwnam_err() and mypwuid_err() are wrappers that cache a /* private copy of results from the getpwnam_r() and getpwuid_r() /* library routines (on legacy systems: from getpwnam() and /* getpwuid(). Note: cache updates are not protected by mutex. /* /* Results are shared between calls with the same \fIname\fR /* or \fIuid\fR argument, so changing results is verboten. /* /* mypwnam() and mypwuid() are binary-compatibility wrappers /* for legacy applications. /* /* mypwfree() cleans up the result of mypwnam*() and mypwuid*(). /* BUGS /* This module is security sensitive and complex at the same /* time, which is bad. /* DIAGNOSTICS /* mypwnam_err() and mypwuid_err() return a non-zero system /* error code when the lookup could not be performed. They /* return zero, plus a null struct mypasswd pointer, when the /* requested information was not found. /* /* Fatal error: out of memory. /* LICENSE /* .ad /* .fi /* The Secure Mailer license must be distributed with this software. /* AUTHOR(S) /* Wietse Venema /* IBM T.J. Watson Research /* P.O. Box 704 /* Yorktown Heights, NY 10598, USA
/*--*/
/* *Doasequenceoflookups.
*/ for (i = 1; i < argc; i++) { if (ISDIGIT(argv[i][0]))
mypwd[i] = mypwuid(atoi(argv[i])); else
mypwd[i] = mypwnam(argv[i]); if (mypwd[i] == 0)
msg_fatal("%s: not found", argv[i]);
msg_info("lookup %s %s/%d refcount=%d name_cache=%d uid_cache=%d",
argv[i], mypwd[i]->pw_name, mypwd[i]->pw_uid,
mypwd[i]->refcount, mypwcache_name->used, mypwcache_uid->used);
}
mypwd[argc] = last_pwd;
/* *Thefollowingshouldfreeallentries.
*/ for (i = 1; i < argc + 1; i++) {
msg_info("free %s/%d refcount=%d name_cache=%d uid_cache=%d",
mypwd[i]->pw_name, mypwd[i]->pw_uid, mypwd[i]->refcount,
mypwcache_name->used, mypwcache_uid->used);
mypwfree(mypwd[i]);
}
msg_info("name_cache=%d uid_cache=%d",
mypwcache_name->used, mypwcache_uid->used);
myfree((void *) mypwd); return (0);
}
#endif
Messung V0.5 in Prozent
¤ Diese beiden folgenden Angebotsgruppen bietet das Unternehmen0.25Angebot
(Wie Sie bei der Firma Beratungs- und Dienstleistungen beauftragen können 2026-09-27)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.