2 * Copyright 2013, Ingo Weinhold, ingo_weinhold@gmx.de.
3 * Distributed under the terms of the MIT License.
7 #include <package/User.h>
11 #include <package/hpkg/PackageInfoAttributeValue.h>
14 namespace BPackageKit
{
28 BUser::BUser(const BHPKG::BUserData
& userData
)
31 fRealName(userData
.realName
),
33 fShell(userData
.shell
),
36 for (size_t i
= 0; i
< userData
.groupCount
; i
++)
37 fGroups
.Add(userData
.groups
[i
]);
41 BUser::BUser(const BString
& name
, const BString
& realName
, const BString
& home
,
42 const BString
& shell
, const BStringList
& groups
)
59 BUser::InitCheck() const
63 if (!IsValidUserName(fName
))
77 BUser::RealName() const
105 BUser::SetTo(const BString
& name
, const BString
& realName
, const BString
& home
,
106 const BString
& shell
, const BStringList
& groups
)
109 fRealName
= realName
;
114 return fGroups
.CountStrings() == groups
.CountStrings() ? B_OK
: B_NO_MEMORY
;
119 BUser::IsValidUserName(const char* name
)
124 for (; name
[0] != '\0'; name
++) {
125 if (!isalnum(name
[0]) && name
[0] != '_')
133 } // namespace BPackageKit