Permalink
Cannot retrieve contributors at this time
Name already in use
A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
mxshadow/libnss_mxshadow.c
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
31 lines (27 sloc)
852 Bytes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <nss.h> | |
#include <shadow.h> | |
#include <errno.h> | |
#include <syslog.h> | |
#define COMMON_LOG(prio, msg, ...) (syslog(LOG_AUTH|prio, msg, ## __VA_ARGS__ )) | |
#include "get_shadow_line.c" | |
#include "common.h" | |
enum nss_status _nss_mxshadow_getspnam_r(const char *name, struct spwd *spwd, char *buffer, size_t buflen, int *errnop) { | |
char *line _cleanup_(free_string) = NULL; | |
int status = get_shadow_line((char *)name, &line); | |
if (status == -1) { | |
*errnop = errno; | |
return NSS_STATUS_UNAVAIL; | |
} | |
if (line[0] == '\0') { | |
errno = ENOENT; | |
*errnop = errno; | |
return NSS_STATUS_NOTFOUND; | |
} | |
struct spwd *spbufp; | |
status = sgetspent_r(line, spwd, buffer, buflen, &spbufp); | |
if (status == -1) { | |
*errnop = errno; | |
return NSS_STATUS_UNAVAIL; | |
} | |
return NSS_STATUS_SUCCESS; | |
} |