Luna/libs/libc/include/pwd.h
apio 7d0e442cde libc: Add /etc/passwd and the pwd.h API
getpwent, getpwnam, getpwuid... they may have been a pain to implement but once they work they're awesome :)

Right now passwords are stored in plaintext in the world-readable passwd file, which is not good.
But I don't have any sort of hashing implemented so it'll stay that way for now.
2022-10-28 20:55:00 +02:00

42 lines
866 B
C

#ifndef _PWD_H
#define _PWD_H
#include <sys/types.h>
/* Structure representing a password file entry. */
struct passwd
{
char* pw_name;
char* pw_passwd;
uid_t pw_uid;
gid_t pw_gid;
char* pw_gecos;
char* pw_dir;
char* pw_shell;
};
#ifdef __cplusplus
extern "C"
{
#endif
/* Returns the next password file entry. */
struct passwd* getpwent(void);
/* Returns the first password file entry with a login name matching name, or NULL if there are none. */
struct passwd* getpwnam(const char* name);
/* Returns the first password file entry with a user ID matching uid, or NULL if there are none. */
struct passwd* getpwuid(uid_t uid);
/* Rewinds to the first password file entry. */
void setpwent(void);
/* Ends password file processing. */
void endpwent(void);
#ifdef __cplusplus
}
#endif
#endif