hpkg format: Add attributes for declaring users and groups
This commit is contained in:
@@ -18,6 +18,7 @@
|
||||
#include <package/PackageResolvable.h>
|
||||
#include <package/PackageResolvableExpression.h>
|
||||
#include <package/PackageVersion.h>
|
||||
#include <package/User.h>
|
||||
#include <package/UserSettingsFileInfo.h>
|
||||
|
||||
|
||||
@@ -86,6 +87,9 @@ public:
|
||||
const BObjectList<BUserSettingsFileInfo>&
|
||||
UserSettingsFileInfos() const;
|
||||
|
||||
const BObjectList<BUser>& Users() const;
|
||||
const BStringList& Groups() const;
|
||||
|
||||
const BObjectList<BPackageResolvable>& ProvidesList() const;
|
||||
const BObjectList<BPackageResolvableExpression>&
|
||||
RequiresList() const;
|
||||
@@ -135,6 +139,12 @@ public:
|
||||
status_t AddUserSettingsFileInfo(
|
||||
const BUserSettingsFileInfo& info);
|
||||
|
||||
void ClearUsers();
|
||||
status_t AddUser(const BUser& user);
|
||||
|
||||
void ClearGroups();
|
||||
status_t AddGroup(const BString& group);
|
||||
|
||||
void ClearProvidesList();
|
||||
status_t AddProvides(const BPackageResolvable& provides);
|
||||
|
||||
@@ -196,6 +206,8 @@ private:
|
||||
typedef BObjectList<BUserSettingsFileInfo>
|
||||
UserSettingsFileInfoList;
|
||||
|
||||
typedef BObjectList<BUser> UserList;
|
||||
|
||||
private:
|
||||
status_t _ReadFromPackageFile(
|
||||
const PackageFileLocation& fileLocation);
|
||||
@@ -218,6 +230,8 @@ private:
|
||||
const char* field,
|
||||
const UserSettingsFileInfoList&
|
||||
infos);
|
||||
static status_t _AddUsers(BMessage* archive, const char* field,
|
||||
const UserList& users);
|
||||
|
||||
static status_t _ExtractVersion(BMessage* archive,
|
||||
const char* field, int32 index,
|
||||
@@ -236,6 +250,8 @@ private:
|
||||
static status_t _ExtractUserSettingsFileInfos(
|
||||
BMessage* archive, const char* field,
|
||||
UserSettingsFileInfoList& _infos);
|
||||
static status_t _ExtractUsers(BMessage* archive,
|
||||
const char* field, UserList& _users);
|
||||
|
||||
private:
|
||||
BString fName;
|
||||
@@ -259,6 +275,9 @@ private:
|
||||
BObjectList<BGlobalSettingsFileInfo> fGlobalSettingsFileInfos;
|
||||
BObjectList<BUserSettingsFileInfo> fUserSettingsFileInfos;
|
||||
|
||||
UserList fUsers;
|
||||
BStringList fGroups;
|
||||
|
||||
ResolvableList fProvidesList;
|
||||
|
||||
ResolvableExpressionList fRequiresList;
|
||||
|
||||
@@ -45,6 +45,10 @@ enum BPackageInfoAttributeID {
|
||||
// list of global settings file infos
|
||||
B_PACKAGE_INFO_USER_SETTINGS_FILES,
|
||||
// list of user settings file infos
|
||||
B_PACKAGE_INFO_USERS,
|
||||
// list of (Unix) users defined/needed
|
||||
B_PACKAGE_INFO_GROUPS,
|
||||
// list of (Unix) groups defined/needed
|
||||
//
|
||||
B_PACKAGE_INFO_ENUM_COUNT,
|
||||
};
|
||||
|
||||
@@ -0,0 +1,52 @@
|
||||
/*
|
||||
* Copyright 2013, Haiku, Inc.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*/
|
||||
#ifndef _PACKAGE__USER_H_
|
||||
#define _PACKAGE__USER_H_
|
||||
|
||||
|
||||
#include <String.h>
|
||||
#include <StringList.h>
|
||||
|
||||
|
||||
namespace BPackageKit {
|
||||
|
||||
|
||||
class BUser {
|
||||
public:
|
||||
BUser();
|
||||
BUser(const BString& name,
|
||||
const BString& realName,
|
||||
const BString& home, const BString& shell,
|
||||
const BStringList& groups);
|
||||
~BUser();
|
||||
|
||||
status_t InitCheck() const;
|
||||
|
||||
const BString& Name() const;
|
||||
const BString& RealName() const;
|
||||
const BString& Home() const;
|
||||
const BString& Shell() const;
|
||||
const BStringList& Groups() const;
|
||||
|
||||
status_t SetTo(const BString& name,
|
||||
const BString& realName,
|
||||
const BString& home, const BString& shell,
|
||||
const BStringList& groups);
|
||||
|
||||
static bool IsValidUserName(const char* name);
|
||||
|
||||
private:
|
||||
BString fName;
|
||||
BString fRealName;
|
||||
BString fHome;
|
||||
BString fShell;
|
||||
BStringList fGroups;
|
||||
};
|
||||
|
||||
|
||||
} // namespace BPackageKit
|
||||
|
||||
|
||||
#endif // _PACKAGE__USER_H_
|
||||
@@ -70,3 +70,10 @@ B_DEFINE_HPKG_ATTRIBUTE(44, UINT, "package:settings-file-update-type",
|
||||
PACKAGE_SETTINGS_FILE_UPDATE_TYPE)
|
||||
B_DEFINE_HPKG_ATTRIBUTE(45, STRING, "package:settings-file-template",
|
||||
PACKAGE_SETTINGS_FILE_TEMPLATE)
|
||||
B_DEFINE_HPKG_ATTRIBUTE(46, STRING, "package:user", PACKAGE_USER)
|
||||
B_DEFINE_HPKG_ATTRIBUTE(47, STRING, "package:user.real-name",
|
||||
PACKAGE_USER_REAL_NAME)
|
||||
B_DEFINE_HPKG_ATTRIBUTE(48, STRING, "package:user.home", PACKAGE_USER_HOME)
|
||||
B_DEFINE_HPKG_ATTRIBUTE(49, STRING, "package:user.shell", PACKAGE_USER_SHELL)
|
||||
B_DEFINE_HPKG_ATTRIBUTE(50, STRING, "package:user.group", PACKAGE_USER_GROUP)
|
||||
B_DEFINE_HPKG_ATTRIBUTE(51, STRING, "package:group", PACKAGE_GROUP)
|
||||
|
||||
@@ -59,6 +59,16 @@ struct BUserSettingsFileInfoData {
|
||||
};
|
||||
|
||||
|
||||
struct BUserData {
|
||||
const char* name;
|
||||
const char* realName;
|
||||
const char* home;
|
||||
const char* shell;
|
||||
const char* const* groups;
|
||||
size_t groupCount;
|
||||
};
|
||||
|
||||
|
||||
struct BPackageInfoAttributeValue {
|
||||
union {
|
||||
uint64 unsignedInt;
|
||||
@@ -68,6 +78,7 @@ struct BPackageInfoAttributeValue {
|
||||
BPackageResolvableExpressionData resolvableExpression;
|
||||
BGlobalSettingsFileInfoData globalSettingsFileInfo;
|
||||
BUserSettingsFileInfoData userSettingsFileInfo;
|
||||
BUserData user;
|
||||
};
|
||||
BPackageInfoAttributeID attributeID;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user