* Reorganized the passwd and group support: A dedicated thread in the
registrar provides access to the DBs via a port message based protocol. The functions in libroot just ask the registrar now. * Added Linuxish shadow passwd support. No putspent() though -- we'll provide private functions. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@25002 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -34,6 +34,14 @@
|
||||
// MAX_GROUP_NAME_LEN and MAX_GROUP_PASSWORD_LEN are char* aligned
|
||||
|
||||
|
||||
#define MAX_SHADOW_PWD_NAME_LEN (32)
|
||||
#define MAX_SHADOW_PWD_PASSWORD_LEN (128)
|
||||
|
||||
#define MAX_SHADOW_PWD_BUFFER_SIZE ( \
|
||||
MAX_SHADOW_PWD_NAME_LEN \
|
||||
+ MAX_SHADOW_PWD_PASSWORD_LEN)
|
||||
|
||||
|
||||
struct user_space_program_args;
|
||||
struct real_time_data;
|
||||
|
||||
|
||||
@@ -0,0 +1,109 @@
|
||||
/*
|
||||
* Copyright 2008, Ingo Weinhold, [email protected]. All rights reserved.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*/
|
||||
#ifndef _LIBROOT_USER_GROUP_COMMON_H
|
||||
#define _LIBROOT_USER_GROUP_COMMON_H
|
||||
|
||||
#include <grp.h>
|
||||
#include <pwd.h>
|
||||
#include <shadow.h>
|
||||
|
||||
#include <OS.h>
|
||||
|
||||
#include <AutoLocker.h>
|
||||
|
||||
|
||||
namespace BPrivate {
|
||||
|
||||
class KMessage;
|
||||
class Tokenizer;
|
||||
|
||||
extern const char* kPasswdFile;
|
||||
extern const char* kGroupFile;
|
||||
extern const char* kShadowPwdFile;
|
||||
|
||||
|
||||
// locking
|
||||
|
||||
status_t user_group_lock();
|
||||
status_t user_group_unlock();
|
||||
|
||||
|
||||
class UserGroupLocking {
|
||||
public:
|
||||
inline bool Lock(int*)
|
||||
{
|
||||
return user_group_lock() == B_OK;
|
||||
}
|
||||
|
||||
inline void Unlock(int*)
|
||||
{
|
||||
user_group_unlock();
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
class UserGroupLocker : public AutoLocker<int, UserGroupLocking> {
|
||||
public:
|
||||
UserGroupLocker()
|
||||
: AutoLocker<int, UserGroupLocking>((int*)1)
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
port_id get_registrar_authentication_port();
|
||||
status_t send_authentication_request_to_registrar(KMessage& request,
|
||||
KMessage& reply);
|
||||
|
||||
|
||||
template<typename Type>
|
||||
static inline Type*
|
||||
relocate_pointer(addr_t baseAddress, Type*& address)
|
||||
{
|
||||
return address = (Type*)(baseAddress + (addr_t)address);
|
||||
}
|
||||
|
||||
|
||||
// passwd
|
||||
|
||||
status_t copy_passwd_to_buffer(const char* name, const char* password, uid_t uid,
|
||||
gid_t gid, const char* home, const char* shell, const char* realName,
|
||||
passwd* entry, char* buffer, size_t bufferSize);
|
||||
status_t copy_passwd_to_buffer(const passwd* from, passwd* entry, char* buffer,
|
||||
size_t bufferSize);
|
||||
|
||||
status_t parse_passwd_line(char* line, char*& name, char*& password, uid_t& uid,
|
||||
gid_t& gid, char*& home, char*& shell, char*& realName);
|
||||
|
||||
|
||||
// group
|
||||
|
||||
status_t copy_group_to_buffer(const char* name, const char* password, gid_t gid,
|
||||
const char* const* members, int memberCount, group* entry, char* buffer,
|
||||
size_t bufferSize);
|
||||
status_t copy_group_to_buffer(const group* from, group* entry, char* buffer,
|
||||
size_t bufferSize);
|
||||
|
||||
status_t parse_group_line(char* line, char*& name, char*& password, gid_t& gid,
|
||||
char** members, int& memberCount);
|
||||
|
||||
|
||||
// shadow password
|
||||
|
||||
status_t copy_shadow_pwd_to_buffer(const char* name, const char* password,
|
||||
int min, int max, int warn, int inactive, int expiration, int flags,
|
||||
spwd* entry, char* buffer, size_t bufferSize);
|
||||
status_t copy_shadow_pwd_to_buffer(const spwd* from, spwd* entry,
|
||||
char* buffer, size_t bufferSize);
|
||||
|
||||
status_t parse_shadow_pwd_line(char* line, char*& name, char*& password,
|
||||
int& lastChanged, int& min, int& max, int& warn, int& inactive,
|
||||
int& expiration, int& flags);
|
||||
|
||||
|
||||
} // namespace BPrivate
|
||||
|
||||
|
||||
#endif // _LIBROOT_USER_GROUP_COMMON_H
|
||||
Reference in New Issue
Block a user